@cjhyy/code-shell-web 0.9.35 → 0.9.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,57 @@
1
+ (function(){const i=document.createElement("link").relList;if(i&&i.supports&&i.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const f of o)if(f.type==="childList")for(const u of f.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&a(u)}).observe(document,{childList:!0,subtree:!0});function l(o){const f={};return o.integrity&&(f.integrity=o.integrity),o.referrerPolicy&&(f.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?f.credentials="include":o.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function a(o){if(o.ep)return;o.ep=!0;const f=l(o);fetch(o.href,f)}})();function co(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ac={exports:{}},la={};var mg;function W0(){if(mg)return la;mg=1;var t=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function l(a,o,f){var u=null;if(f!==void 0&&(u=""+f),o.key!==void 0&&(u=""+o.key),"key"in o){f={};for(var p in o)p!=="key"&&(f[p]=o[p])}else f=o;return o=f.ref,{$$typeof:t,type:a,key:u,ref:o!==void 0?o:null,props:f}}return la.Fragment=i,la.jsx=l,la.jsxs=l,la}var gg;function e1(){return gg||(gg=1,Ac.exports=W0()),Ac.exports}var c=e1(),Tc={exports:{}},Fe={};var yg;function t1(){if(yg)return Fe;yg=1;var t=Symbol.for("react.transitional.element"),i=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),f=Symbol.for("react.consumer"),u=Symbol.for("react.context"),p=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),x=Symbol.iterator;function v(O){return O===null||typeof O!="object"?null:(O=x&&O[x]||O["@@iterator"],typeof O=="function"?O:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},z=Object.assign,A={};function N(O,te,R){this.props=O,this.context=te,this.refs=A,this.updater=R||j}N.prototype.isReactComponent={},N.prototype.setState=function(O,te){if(typeof O!="object"&&typeof O!="function"&&O!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,O,te,"setState")},N.prototype.forceUpdate=function(O){this.updater.enqueueForceUpdate(this,O,"forceUpdate")};function T(){}T.prototype=N.prototype;function M(O,te,R){this.props=O,this.context=te,this.refs=A,this.updater=R||j}var G=M.prototype=new T;G.constructor=M,z(G,N.prototype),G.isPureReactComponent=!0;var ae=Array.isArray;function D(){}var H={H:null,A:null,T:null,S:null},W=Object.prototype.hasOwnProperty;function q(O,te,R){var ee=R.ref;return{$$typeof:t,type:O,key:te,ref:ee!==void 0?ee:null,props:R}}function C(O,te){return q(O.type,te,O.props)}function L(O){return typeof O=="object"&&O!==null&&O.$$typeof===t}function B(O){var te={"=":"=0",":":"=2"};return"$"+O.replace(/[=:]/g,function(R){return te[R]})}var Q=/\/+/g;function J(O,te){return typeof O=="object"&&O!==null&&O.key!=null?B(""+O.key):te.toString(36)}function K(O){switch(O.status){case"fulfilled":return O.value;case"rejected":throw O.reason;default:switch(typeof O.status=="string"?O.then(D,D):(O.status="pending",O.then(function(te){O.status==="pending"&&(O.status="fulfilled",O.value=te)},function(te){O.status==="pending"&&(O.status="rejected",O.reason=te)})),O.status){case"fulfilled":return O.value;case"rejected":throw O.reason}}throw O}function I(O,te,R,ee,ve){var le=typeof O;(le==="undefined"||le==="boolean")&&(O=null);var ue=!1;if(O===null)ue=!0;else switch(le){case"bigint":case"string":case"number":ue=!0;break;case"object":switch(O.$$typeof){case t:case i:ue=!0;break;case y:return ue=O._init,I(ue(O._payload),te,R,ee,ve)}}if(ue)return ve=ve(O),ue=ee===""?"."+J(O,0):ee,ae(ve)?(R="",ue!=null&&(R=ue.replace(Q,"$&/")+"/"),I(ve,te,R,"",function(ke){return ke})):ve!=null&&(L(ve)&&(ve=C(ve,R+(ve.key==null||O&&O.key===ve.key?"":(""+ve.key).replace(Q,"$&/")+"/")+ue)),te.push(ve)),1;ue=0;var xe=ee===""?".":ee+":";if(ae(O))for(var F=0;F<O.length;F++)ee=O[F],le=xe+J(ee,F),ue+=I(ee,te,R,le,ve);else if(F=v(O),typeof F=="function")for(O=F.call(O),F=0;!(ee=O.next()).done;)ee=ee.value,le=xe+J(ee,F++),ue+=I(ee,te,R,le,ve);else if(le==="object"){if(typeof O.then=="function")return I(K(O),te,R,ee,ve);throw te=String(O),Error("Objects are not valid as a React child (found: "+(te==="[object Object]"?"object with keys {"+Object.keys(O).join(", ")+"}":te)+"). If you meant to render a collection of children, use an array instead.")}return ue}function Y(O,te,R){if(O==null)return O;var ee=[],ve=0;return I(O,ee,"","",function(le){return te.call(R,le,ve++)}),ee}function X(O){if(O._status===-1){var te=O._result;te=te(),te.then(function(R){(O._status===0||O._status===-1)&&(O._status=1,O._result=R)},function(R){(O._status===0||O._status===-1)&&(O._status=2,O._result=R)}),O._status===-1&&(O._status=0,O._result=te)}if(O._status===1)return O._result.default;throw O._result}var pe=typeof reportError=="function"?reportError:function(O){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var te=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof O=="object"&&O!==null&&typeof O.message=="string"?String(O.message):String(O),error:O});if(!window.dispatchEvent(te))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",O);return}console.error(O)},k={map:Y,forEach:function(O,te,R){Y(O,function(){te.apply(this,arguments)},R)},count:function(O){var te=0;return Y(O,function(){te++}),te},toArray:function(O){return Y(O,function(te){return te})||[]},only:function(O){if(!L(O))throw Error("React.Children.only expected to receive a single React element child.");return O}};return Fe.Activity=b,Fe.Children=k,Fe.Component=N,Fe.Fragment=l,Fe.Profiler=o,Fe.PureComponent=M,Fe.StrictMode=a,Fe.Suspense=h,Fe.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=H,Fe.__COMPILER_RUNTIME={__proto__:null,c:function(O){return H.H.useMemoCache(O)}},Fe.cache=function(O){return function(){return O.apply(null,arguments)}},Fe.cacheSignal=function(){return null},Fe.cloneElement=function(O,te,R){if(O==null)throw Error("The argument must be a React element, but you passed "+O+".");var ee=z({},O.props),ve=O.key;if(te!=null)for(le in te.key!==void 0&&(ve=""+te.key),te)!W.call(te,le)||le==="key"||le==="__self"||le==="__source"||le==="ref"&&te.ref===void 0||(ee[le]=te[le]);var le=arguments.length-2;if(le===1)ee.children=R;else if(1<le){for(var ue=Array(le),xe=0;xe<le;xe++)ue[xe]=arguments[xe+2];ee.children=ue}return q(O.type,ve,ee)},Fe.createContext=function(O){return O={$$typeof:u,_currentValue:O,_currentValue2:O,_threadCount:0,Provider:null,Consumer:null},O.Provider=O,O.Consumer={$$typeof:f,_context:O},O},Fe.createElement=function(O,te,R){var ee,ve={},le=null;if(te!=null)for(ee in te.key!==void 0&&(le=""+te.key),te)W.call(te,ee)&&ee!=="key"&&ee!=="__self"&&ee!=="__source"&&(ve[ee]=te[ee]);var ue=arguments.length-2;if(ue===1)ve.children=R;else if(1<ue){for(var xe=Array(ue),F=0;F<ue;F++)xe[F]=arguments[F+2];ve.children=xe}if(O&&O.defaultProps)for(ee in ue=O.defaultProps,ue)ve[ee]===void 0&&(ve[ee]=ue[ee]);return q(O,le,ve)},Fe.createRef=function(){return{current:null}},Fe.forwardRef=function(O){return{$$typeof:p,render:O}},Fe.isValidElement=L,Fe.lazy=function(O){return{$$typeof:y,_payload:{_status:-1,_result:O},_init:X}},Fe.memo=function(O,te){return{$$typeof:m,type:O,compare:te===void 0?null:te}},Fe.startTransition=function(O){var te=H.T,R={};H.T=R;try{var ee=O(),ve=H.S;ve!==null&&ve(R,ee),typeof ee=="object"&&ee!==null&&typeof ee.then=="function"&&ee.then(D,pe)}catch(le){pe(le)}finally{te!==null&&R.types!==null&&(te.types=R.types),H.T=te}},Fe.unstable_useCacheRefresh=function(){return H.H.useCacheRefresh()},Fe.use=function(O){return H.H.use(O)},Fe.useActionState=function(O,te,R){return H.H.useActionState(O,te,R)},Fe.useCallback=function(O,te){return H.H.useCallback(O,te)},Fe.useContext=function(O){return H.H.useContext(O)},Fe.useDebugValue=function(){},Fe.useDeferredValue=function(O,te){return H.H.useDeferredValue(O,te)},Fe.useEffect=function(O,te){return H.H.useEffect(O,te)},Fe.useEffectEvent=function(O){return H.H.useEffectEvent(O)},Fe.useId=function(){return H.H.useId()},Fe.useImperativeHandle=function(O,te,R){return H.H.useImperativeHandle(O,te,R)},Fe.useInsertionEffect=function(O,te){return H.H.useInsertionEffect(O,te)},Fe.useLayoutEffect=function(O,te){return H.H.useLayoutEffect(O,te)},Fe.useMemo=function(O,te){return H.H.useMemo(O,te)},Fe.useOptimistic=function(O,te){return H.H.useOptimistic(O,te)},Fe.useReducer=function(O,te,R){return H.H.useReducer(O,te,R)},Fe.useRef=function(O){return H.H.useRef(O)},Fe.useState=function(O){return H.H.useState(O)},Fe.useSyncExternalStore=function(O,te,R){return H.H.useSyncExternalStore(O,te,R)},Fe.useTransition=function(){return H.H.useTransition()},Fe.version="19.2.6",Fe}var bg;function Pf(){return bg||(bg=1,Tc.exports=t1()),Tc.exports}var n1=Pf();const w=co(n1);let ka,fo=null;const i1=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,db=/^\/p\/([0-9a-f-]{36})(\/.*)$/;function xa(t){return typeof t=="string"&&i1.test(t)}function Vs(t){if(t!==null&&!xa(t))throw new Error("项目标识无效。");fo=t}function Sa(){return fo}function no(){return{workspace:ka??"",projectId:fo}}function Ys(t){ka=void 0}function io(){return ka}function vg(t=ka){return t?{"X-CodeShell-Workspace":encodeURIComponent(t)}:{}}function hb(t){return/^\/api\/v1\/(?:auth|projects|environment)(?:\/|\?|$)/.test(t)||/^\/api\/v1\/desktop\/session(?:\?|$)/.test(t)}function r1(t){const i=db.exec(t);return!!i&&xa(i[1])}function xt(t,i=ka,l=fo){const a=db.exec(t),o=a?a[2]:t;if(a&&!xa(a[1])||!o.startsWith("/api/v1/")&&o!=="/ws"||/[\\\r\n]/.test(t))throw new Error("Workspace URLs must use the local API");const f=new URL(o,"http://codeshell.invalid");if(f.pathname!==o.split(/[?#]/,1)[0])throw new Error("Workspace URLs must use the local API");if(hb(o))return o;if(a)return t;if(l!==null&&!xa(l))throw new Error("项目标识无效。");return i&&o.startsWith("/api/v1/")&&f.searchParams.set("workspace",i),`${l?`/p/${l}`:""}${f.pathname}${f.search}${f.hash}`}class Ke extends Error{constructor(i,l,a,o){super(i),this.status=l,this.code=a,this.retryAfterMs=o}status;code;retryAfterMs}class pb extends Error{constructor(){super("服务端返回了无效的登录状态,请稍后重试。")}}async function qe(t,i={},l){const a=l?vg(l.workspace):vg(),o={...i};if(Object.keys(a).length&&!hb(t)&&!r1(t)&&!t.includes("workspace=")){const p=new Headers(i.headers);for(const[h,m]of Object.entries(a))p.has(h)||p.set(h,m);o.headers=p}const f=await fetch(l?xt(t,l.workspace,l.projectId):xt(t,""),{...o,credentials:"same-origin",cache:"no-store"}),u=await f.json().catch(()=>({}));if(!f.ok){const p=typeof u.error=="string"?u.error:u.error?.message;throw new Ke(p??u.message??`请求失败(${f.status})`,f.status,typeof u.code=="string"?u.code:void 0,typeof u.retryAfterMs=="number"?u.retryAfterMs:void 0)}return u}function Rf(t,i={}){return qe(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}async function l1(){try{const t=await qe("/api/v1/auth/status"),i=()=>new pb;if(!t||typeof t.initialized!="boolean"||typeof t.authenticated!="boolean"||t.mode!==void 0&&t.mode!=="cloud-account")throw i();if(t.mode==="cloud-account"){if(!t.initialized||!t.authenticated&&t.session!==void 0)throw i();let l;if(t.authenticated){const a=t.session,o=/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/,f=u=>{if(typeof u!="string")return!1;try{const p=new URL(u);return p.origin===u&&!p.username&&!p.password&&(p.protocol==="https:"||p.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(p.hostname))}catch{return!1}};if(!a||Array.isArray(a)||a.kind!=="cloud-management"||![a.id,a.installationId,a.accountId,a.managementEpoch].every(u=>typeof u=="string"&&o.test(u))||!f(a.audience)||!f(a.accountOrigin)||typeof window<"u"&&a.audience!==window.location.origin||!Number.isSafeInteger(a.expiresAt)||a.expiresAt<=Date.now())throw i();l={id:a.id,kind:"cloud-management",audience:a.audience,installationId:a.installationId,accountOrigin:a.accountOrigin,accountId:a.accountId,managementEpoch:a.managementEpoch,expiresAt:a.expiresAt}}return{initialized:!0,authenticated:t.authenticated,mode:"cloud-account",...l?{cloudSession:l}:{}}}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 Ke&&t.status===404)return null;throw t}}function a1(t,i){const l=new URLSearchParams(t.hash.replace(/^#/,"")),a=l.get("setup")??"";if(l.has("setup")){l.delete("setup");const o=l.toString();i.replaceState(i.state,"",`${t.pathname}${t.search}${o?`#${o}`:""}`)}return a}function Ca(){if(typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=crypto.getRandomValues(new Uint8Array(16));t[6]=t[6]&15|64,t[8]=t[8]&63|128;const i=Array.from(t,l=>l.toString(16).padStart(2,"0")).join("");return`${i.slice(0,8)}-${i.slice(8,12)}-${i.slice(12,16)}-${i.slice(16,20)}-${i.slice(20)}`}async function s1(t,i={}){const l=i.scope??no();return qe(xt(`/api/v1/uploads/${Ca()}`,l.workspace,l.projectId),{method:"PUT",headers:{"Content-Type":t.type||"application/octet-stream","X-File-Name":encodeURIComponent(t.name)},body:t,signal:i.signal})}function o1(t){try{const i=new URL(t??"");return(i.protocol==="https:"||i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))&&!i.username&&!i.password?i.href:void 0}catch{return}}function Rc(t,i){const l=t.authModes?.filter(a=>a.available&&(!i||a.methodId===i));return l?.find(a=>a.preferred)??l?.[0]}function xi(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 u1=new Set(["redirect","device-code","qr-code","credential-input","local-session","consent","processing"]);function c1(t,i){if(typeof t.id!="string"||!t.id||i&&t.id!==i)throw new Error("授权响应与当前连接不匹配。");if(!["pending","connected","failed","cancelled"].includes(t.state))throw new Error("无法识别授权状态,请更新客户端。");if(t.state==="connected"&&!t.connection)throw new Error("服务尚未确认连接已保存,请刷新后重试。");if(t.state==="connected"&&(t.connection?.providerId!==t.providerId||t.methodId&&t.connection.methodId!==t.methodId))throw new Error("保存的连接与当前授权不匹配。");const l=xi(t);if(t.state==="pending"&&(!l||!u1.has(l.kind)))throw new Error("当前客户端不支持这个授权步骤,请更新客户端。");if(l&&(!l.id||!Number.isFinite(Date.parse(l.expiresAt))))throw new Error("授权步骤缺少有效期限,请重新连接。");if(t.expiresAt&&(!Number.isFinite(Date.parse(t.expiresAt))||l&&Date.parse(l.expiresAt)>Date.parse(t.expiresAt)))throw new Error("授权任务的有效期限无效,请重新连接。")}class f1{constructor(i,l={}){this.transport=i,this.options=l}transport;options;value={busy:!1};listeners=new Set;timer;generation=0;disposed=!1;binding;getSnapshot=()=>this.value;subscribe=i=>(this.listeners.add(i),()=>this.listeners.delete(i));publish(i){if(!this.disposed){this.value=i;for(const l of this.listeners)l()}}stop(){return clearTimeout(this.timer),++this.generation}current(i){return!this.disposed&&i===this.generation}deadline(i){const l=xi(i);return Math.min(i.expiresAt?Date.parse(i.expiresAt):1/0,l?Date.parse(l.expiresAt):1/0)}accept(i,l,a){if(this.current(l)){if(c1(i,a),this.binding&&(i.providerId!==this.binding.providerId||i.methodId&&i.methodId!==this.binding.methodId))throw new Error("授权响应与当前服务不匹配。");this.publish({authorization:i,busy:!1}),i.state==="pending"&&this.schedule(l)}}schedule(i,l=this.options.pollIntervalMs??2e3){const a=this.value.authorization;if(!this.current(i)||a?.state!=="pending")return;const o=this.deadline(a)-Date.now();if(o<=0){this.stop(),this.publish({busy:!1,authorization:{...a,state:"failed",step:void 0,prompt:void 0,redirect:void 0,errorCode:"authorization_expired"}}),this.transport.cancel(a.id).catch(()=>{});return}const f=xi(a),u=f&&["credential-input","local-session","consent"].includes(f.kind);this.timer=setTimeout(()=>{u?this.schedule(i):this.poll(i)},Math.min(l,o))}async poll(i){const l=this.value.authorization;if(!(!this.current(i)||l?.state!=="pending")){if(this.deadline(l)<=Date.now()){this.schedule(i);return}try{const a=await this.transport.status(l.id);this.accept(a,i,l.id)}catch(a){if(!this.current(i))return;this.publish({...this.value,busy:!1,error:Gs(a)});const o=a?.status;o!==401&&o!==404&&this.schedule(i,this.options.retryIntervalMs??4e3)}}}async begin(i,l){if(this.disposed||this.value.busy||this.value.authorization?.state==="pending")return;const a=this.stop();this.binding=i,this.publish({busy:!0});try{const o=await this.transport.begin(i,l);if(!this.current(a)){o.state==="pending"&&this.transport.cancel(o.id).catch(()=>{});return}try{this.accept(o,a)}catch(f){throw o.state==="pending"&&this.transport.cancel(o.id).catch(()=>{}),f}return o}catch(o){this.current(a)&&this.publish({busy:!1,error:Gs(o)})}}async respond(i){const l=this.value.authorization,a=l&&xi(l);if(this.disposed||this.value.busy||l?.state!=="pending"||!a||a.id!==i.stepId)return;if(this.deadline(l)<=Date.now()){this.schedule(this.generation);return}const o=this.stop();this.publish({authorization:l,busy:!0});try{const f=await this.transport.respond(l.id,i);return this.accept(f,o,l.id),this.current(o)?f:void 0}catch(f){this.current(o)&&(this.publish({authorization:l,busy:!1,error:Gs(f)}),this.timer=setTimeout(()=>{this.poll(o)},this.options.retryIntervalMs??4e3))}}async cancel(){const i=this.value.authorization,l=this.stop();if(i?.state!=="pending"){this.publish({busy:!1});return}this.publish({authorization:i,busy:!0});try{const a=await this.transport.cancel(i.id);if(!this.current(l))return;this.publish({busy:!1,authorization:a??{...i,state:"cancelled",step:void 0,prompt:void 0,redirect:void 0}})}catch(a){this.current(l)&&(this.publish({authorization:i,busy:!1,error:Gs(a)}),this.schedule(l,this.options.retryIntervalMs??4e3))}}clearError(){this.publish({...this.value,error:void 0})}reset(){this.value.busy||this.value.authorization?.state==="pending"||(this.stop(),this.publish({busy:!1}))}dispose(){const i=this.value.authorization;this.stop(),this.disposed=!0,this.listeners.clear(),i?.state==="pending"&&this.transport.cancel(i.id).catch(()=>{})}}function Gs(t){return t instanceof Error?t:new Error("连接操作失败,请重试。")}const zf="codeshell.remote-link.authorization.v1",Zf="/api/v1/links/authorizations/",Df="[a-f0-9-]{36}",d1=new RegExp(`^(?:/p/${Df})?${Zf}${Df}$`);function Jf(t){return t==="/link/callback"?"/":t==="/mobile/link/callback"?"/mobile/":void 0}function h1(t,i){const l=new URL(t),a=new URL(i);if(l.origin!==a.origin||l.pathname!=="/oauth/authorize"||l.username||l.password||l.hash||l.protocol!=="https:"&&!(l.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(l.hostname)))throw new Error("授权地址无效,请检查 Link 服务配置。");return l}function p1(t,i,l,a=window.location.origin,o=window.sessionStorage){const f=xi(t);if(f?.kind!=="redirect"||!new RegExp(`^${Df}$`).test(t.id))throw new Error("授权请求无效。");const u=h1(f.authorizationUrl,i),p=u.searchParams.get("state"),h=u.searchParams.get("redirect_uri"),m=Date.parse(f.expiresAt),y=h?Jf(new URL(h,a).pathname):void 0;if(!p||!h||!y||h!==`${a}${y}link/callback`||y==="/mobile/"&&l.projectId!==null||u.searchParams.getAll("state").length!==1||u.searchParams.getAll("redirect_uri").length!==1||!Number.isFinite(m)||m<=Date.now())throw new Error("授权回调地址或有效期无效,请检查服务配置。");const b=xt(Zf+t.id,l.workspace,l.projectId),x=new URLSearchParams({view:"links",...l.projectId?{project:l.projectId}:{},...y==="/mobile/"?{workspace:l.workspace}:{}});return o.setItem(zf,JSON.stringify({target:b,state:p,redirectUri:h,returnUrl:`${y}?${x}`,expiresAt:m,providerId:t.providerId})),u.href}function m1(t,i,l){const a=Jf(t.pathname);if(!a)return;const o=t.href;i.replaceState(i.state,"",t.pathname);try{const f=l.getItem(zf);l.removeItem(zf);const u=JSON.parse(f??"null");if(!u||!Number.isFinite(u.expiresAt)||u.expiresAt<=Date.now())throw new Error;const p=new URL(o),h=new URL(u.target,t.origin),m=new URL(u.returnUrl,t.origin);if(u.redirectUri!==`${t.origin}${t.pathname}`||p.origin!==t.origin||p.hash||p.searchParams.getAll("state").length!==1||p.searchParams.get("state")!==u.state||h.origin!==t.origin||!d1.test(h.pathname)||h.hash||h.username||h.password||[...h.searchParams.keys()].some(y=>y!=="workspace")||h.searchParams.getAll("workspace").length>1||m.origin!==t.origin||m.pathname!==a||m.username||m.password||m.hash||[...m.searchParams.keys()].some(y=>!(a==="/mobile/"?["workspace","view"]:["project","view"]).includes(y))||m.searchParams.getAll("view").length!==1||m.searchParams.get("view")!=="links"||a==="/mobile/"&&(!h.pathname.startsWith(Zf)||m.searchParams.getAll("workspace").length!==1||m.searchParams.get("workspace")!==(h.searchParams.get("workspace")??"")))throw new Error;return{callbackUrl:o,pending:u,denied:p.searchParams.has("error")}}catch{return{error:"找不到匹配的授权,或授权已过期。请返回原项目重新连接。",home:a}}}async function g1(t){const i=new URL(t.pending.target,window.location.origin),l=mb(i);return t.denied?(await qe(t.pending.target,{method:"DELETE"},l),{id:"",providerId:t.pending.providerId??"",state:"cancelled"}):(i.pathname+="/complete",qe(i.pathname+i.search,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callbackUrl:t.callbackUrl})},l))}function mb(t){return{workspace:t.searchParams.get("workspace")??"",projectId:/^\/p\/([a-f0-9-]{36})\//.exec(t.pathname)?.[1]??null}}function y1(t){const i=new URL(t.pending.target,window.location.origin);return qe(t.pending.target,{},mb(i))}function b1(){const t=Jf(window.location.pathname);if(t)try{return m1(window.location,window.history,window.sessionStorage)}catch{return window.history.replaceState(window.history.state,"",window.location.pathname),{error:"浏览器无法读取原授权记录。请允许此站点保存临时数据后重新连接。",home:t}}}function v1({callback:t}){const i=w.useRef(void 0),[l,a]=w.useState(),[o,f]=w.useState("error"in t?t.error:""),[u,p]=w.useState(!1),h=b=>f(b instanceof Ke&&b.status===401?"原登录已失效。请返回工作台登录,并重新发起授权。":b instanceof Error?b.message:"无法确认授权结果,请检查结果或返回项目重新连接。"),m=b=>{if(b.state==="connected"&&!b.connection){h(new Error("服务尚未确认连接已保存,请检查授权结果。"));return}a(b),f("")};w.useEffect(()=>{if("error"in t)return;let b=!0;return i.current??=g1(t),i.current.then(x=>{b&&m(x)},x=>{b&&h(x)}),()=>{b=!1}},[t]);const y=!l&&!o;return c.jsx("main",{className:"auth-page",children:c.jsxs("section",{className:"auth-card",children:[c.jsx("h1",{children:"Link 授权"}),y&&c.jsx("p",{role:"status",children:"正在确认授权并保存到原项目…"}),l?.state==="connected"&&c.jsxs("p",{role:"status",children:["已连接 ",l.connection?.account?.label??l.connection?.providerId,",授权已保存到原项目。"]}),l?.previousGrantRevocationPending&&c.jsx("p",{role:"alert",children:"新连接已保存。有遗留授权等待撤销,项目所在环境将自动重试,重启后仍会继续;也可在 Link 服务中撤销。"}),l?.state==="cancelled"&&c.jsx("p",{role:"status",children:"授权已取消,没有新增连接。"}),l?.state==="failed"&&c.jsx("p",{role:"alert",children:"授权未完成。请返回原项目重新连接。"}),l?.state==="pending"&&c.jsx("p",{role:"status",children:"服务端尚未确认完成。可以稍后检查结果,或返回项目重新发起授权。"}),o&&c.jsx("p",{className:"form-error",role:"alert",children:o}),!("error"in t)&&(o||l?.state==="pending")&&c.jsx("button",{disabled:u,onClick:()=>{u||(p(!0),y1(t).then(m,h).finally(()=>p(!1)))},children:u?"正在查询…":"检查授权结果"}),!y&&c.jsx("a",{href:"error"in t?t.home??"/":t.pending.returnUrl,children:"返回原项目"})]})})}var zc={exports:{}},aa={},Dc={exports:{}},_c={};var xg;function x1(){return xg||(xg=1,(function(t){function i(I,Y){var X=I.length;I.push(Y);e:for(;0<X;){var pe=X-1>>>1,k=I[pe];if(0<o(k,Y))I[pe]=Y,I[X]=k,X=pe;else break e}}function l(I){return I.length===0?null:I[0]}function a(I){if(I.length===0)return null;var Y=I[0],X=I.pop();if(X!==Y){I[0]=X;e:for(var pe=0,k=I.length,O=k>>>1;pe<O;){var te=2*(pe+1)-1,R=I[te],ee=te+1,ve=I[ee];if(0>o(R,X))ee<k&&0>o(ve,R)?(I[pe]=ve,I[ee]=X,pe=ee):(I[pe]=R,I[te]=X,pe=te);else if(ee<k&&0>o(ve,X))I[pe]=ve,I[ee]=X,pe=ee;else break e}}return Y}function o(I,Y){var X=I.sortIndex-Y.sortIndex;return X!==0?X:I.id-Y.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var f=performance;t.unstable_now=function(){return f.now()}}else{var u=Date,p=u.now();t.unstable_now=function(){return u.now()-p}}var h=[],m=[],y=1,b=null,x=3,v=!1,j=!1,z=!1,A=!1,N=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,M=typeof setImmediate<"u"?setImmediate:null;function G(I){for(var Y=l(m);Y!==null;){if(Y.callback===null)a(m);else if(Y.startTime<=I)a(m),Y.sortIndex=Y.expirationTime,i(h,Y);else break;Y=l(m)}}function ae(I){if(z=!1,G(I),!j)if(l(h)!==null)j=!0,D||(D=!0,B());else{var Y=l(m);Y!==null&&K(ae,Y.startTime-I)}}var D=!1,H=-1,W=5,q=-1;function C(){return A?!0:!(t.unstable_now()-q<W)}function L(){if(A=!1,D){var I=t.unstable_now();q=I;var Y=!0;try{e:{j=!1,z&&(z=!1,T(H),H=-1),v=!0;var X=x;try{t:{for(G(I),b=l(h);b!==null&&!(b.expirationTime>I&&C());){var pe=b.callback;if(typeof pe=="function"){b.callback=null,x=b.priorityLevel;var k=pe(b.expirationTime<=I);if(I=t.unstable_now(),typeof k=="function"){b.callback=k,G(I),Y=!0;break t}b===l(h)&&a(h),G(I)}else a(h);b=l(h)}if(b!==null)Y=!0;else{var O=l(m);O!==null&&K(ae,O.startTime-I),Y=!1}}break e}finally{b=null,x=X,v=!1}Y=void 0}}finally{Y?B():D=!1}}}var B;if(typeof M=="function")B=function(){M(L)};else if(typeof MessageChannel<"u"){var Q=new MessageChannel,J=Q.port2;Q.port1.onmessage=L,B=function(){J.postMessage(null)}}else B=function(){N(L,0)};function K(I,Y){H=N(function(){I(t.unstable_now())},Y)}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(I){I.callback=null},t.unstable_forceFrameRate=function(I){0>I||125<I?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):W=0<I?Math.floor(1e3/I):5},t.unstable_getCurrentPriorityLevel=function(){return x},t.unstable_next=function(I){switch(x){case 1:case 2:case 3:var Y=3;break;default:Y=x}var X=x;x=Y;try{return I()}finally{x=X}},t.unstable_requestPaint=function(){A=!0},t.unstable_runWithPriority=function(I,Y){switch(I){case 1:case 2:case 3:case 4:case 5:break;default:I=3}var X=x;x=I;try{return Y()}finally{x=X}},t.unstable_scheduleCallback=function(I,Y,X){var pe=t.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?pe+X:pe):X=pe,I){case 1:var k=-1;break;case 2:k=250;break;case 5:k=1073741823;break;case 4:k=1e4;break;default:k=5e3}return k=X+k,I={id:y++,callback:Y,priorityLevel:I,startTime:X,expirationTime:k,sortIndex:-1},X>pe?(I.sortIndex=X,i(m,I),l(h)===null&&I===l(m)&&(z?(T(H),H=-1):z=!0,K(ae,X-pe))):(I.sortIndex=k,i(h,I),j||v||(j=!0,D||(D=!0,B()))),I},t.unstable_shouldYield=C,t.unstable_wrapCallback=function(I){var Y=x;return function(){var X=x;x=Y;try{return I.apply(this,arguments)}finally{x=X}}}})(_c)),_c}var Sg;function S1(){return Sg||(Sg=1,Dc.exports=x1()),Dc.exports}var Mc={exports:{}},rn={};var wg;function w1(){if(wg)return rn;wg=1;var t=Pf();function i(h){var m="https://react.dev/errors/"+h;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)m+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+h+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function l(){}var a={d:{f:l,r:function(){throw Error(i(522))},D:l,C:l,L:l,m:l,X:l,S:l,M:l},p:0,findDOMNode:null},o=Symbol.for("react.portal");function f(h,m,y){var b=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:b==null?null:""+b,children:h,containerInfo:m,implementation:y}}var u=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function p(h,m){if(h==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return rn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,rn.createPortal=function(h,m){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(i(299));return f(h,m,null,y)},rn.flushSync=function(h){var m=u.T,y=a.p;try{if(u.T=null,a.p=2,h)return h()}finally{u.T=m,a.p=y,a.d.f()}},rn.preconnect=function(h,m){typeof h=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,a.d.C(h,m))},rn.prefetchDNS=function(h){typeof h=="string"&&a.d.D(h)},rn.preinit=function(h,m){if(typeof h=="string"&&m&&typeof m.as=="string"){var y=m.as,b=p(y,m.crossOrigin),x=typeof m.integrity=="string"?m.integrity:void 0,v=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;y==="style"?a.d.S(h,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:b,integrity:x,fetchPriority:v}):y==="script"&&a.d.X(h,{crossOrigin:b,integrity:x,fetchPriority:v,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},rn.preinitModule=function(h,m){if(typeof h=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var y=p(m.as,m.crossOrigin);a.d.M(h,{crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&a.d.M(h)},rn.preload=function(h,m){if(typeof h=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var y=m.as,b=p(y,m.crossOrigin);a.d.L(h,y,{crossOrigin:b,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},rn.preloadModule=function(h,m){if(typeof h=="string")if(m){var y=p(m.as,m.crossOrigin);a.d.m(h,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else a.d.m(h)},rn.requestFormReset=function(h){a.d.r(h)},rn.unstable_batchedUpdates=function(h,m){return h(m)},rn.useFormState=function(h,m,y){return u.H.useFormState(h,m,y)},rn.useFormStatus=function(){return u.H.useHostTransitionStatus()},rn.version="19.2.6",rn}var jg;function gb(){if(jg)return Mc.exports;jg=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(i){console.error(i)}}return t(),Mc.exports=w1(),Mc.exports}var kg;function j1(){if(kg)return aa;kg=1;var t=S1(),i=Pf(),l=gb();function a(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var r=2;r<arguments.length;r++)n+="&args[]="+encodeURIComponent(arguments[r])}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 f(e){var n=e,r=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(r=n.return),e=n.return;while(e)}return n.tag===3?r:null}function u(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 p(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 h(e){if(f(e)!==e)throw Error(a(188))}function m(e){var n=e.alternate;if(!n){if(n=f(e),n===null)throw Error(a(188));return n!==e?null:e}for(var r=e,s=n;;){var d=r.return;if(d===null)break;var g=d.alternate;if(g===null){if(s=d.return,s!==null){r=s;continue}break}if(d.child===g.child){for(g=d.child;g;){if(g===r)return h(d),e;if(g===s)return h(d),n;g=g.sibling}throw Error(a(188))}if(r.return!==s.return)r=d,s=g;else{for(var S=!1,E=d.child;E;){if(E===r){S=!0,r=d,s=g;break}if(E===s){S=!0,s=d,r=g;break}E=E.sibling}if(!S){for(E=g.child;E;){if(E===r){S=!0,r=g,s=d;break}if(E===s){S=!0,s=g,r=d;break}E=E.sibling}if(!S)throw Error(a(189))}}if(r.alternate!==s)throw Error(a(190))}if(r.tag!==3)throw Error(a(188));return r.stateNode.current===r?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,x=Symbol.for("react.element"),v=Symbol.for("react.transitional.element"),j=Symbol.for("react.portal"),z=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),M=Symbol.for("react.context"),G=Symbol.for("react.forward_ref"),ae=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),q=Symbol.for("react.activity"),C=Symbol.for("react.memo_cache_sentinel"),L=Symbol.iterator;function B(e){return e===null||typeof e!="object"?null:(e=L&&e[L]||e["@@iterator"],typeof e=="function"?e:null)}var Q=Symbol.for("react.client.reference");function J(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Q?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case z:return"Fragment";case N:return"Profiler";case A:return"StrictMode";case ae:return"Suspense";case D:return"SuspenseList";case q:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case j:return"Portal";case M:return e.displayName||"Context";case T:return(e._context.displayName||"Context")+".Consumer";case G:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case H:return n=e.displayName||null,n!==null?n:J(e.type)||"Memo";case W:n=e._payload,e=e._init;try{return J(e(n))}catch{}}return null}var K=Array.isArray,I=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Y=l.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X={pending:!1,data:null,method:null,action:null},pe=[],k=-1;function O(e){return{current:e}}function te(e){0>k||(e.current=pe[k],pe[k]=null,k--)}function R(e,n){k++,pe[k]=e.current,e.current=n}var ee=O(null),ve=O(null),le=O(null),ue=O(null);function xe(e,n){switch(R(le,n),R(ve,e),R(ee,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?Um(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=Um(n),e=Im(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}te(ee),R(ee,e)}function F(){te(ee),te(ve),te(le)}function ke(e){e.memoizedState!==null&&R(ue,e);var n=ee.current,r=Im(n,e.type);n!==r&&(R(ve,e),R(ee,r))}function ze(e){ve.current===e&&(te(ee),te(ve)),ue.current===e&&(te(ue),ta._currentValue=X)}var Le,Ee;function Xe(e){if(Le===void 0)try{throw Error()}catch(r){var n=r.stack.trim().match(/\n( *(at )?)/);Le=n&&n[1]||"",Ee=-1<r.stack.indexOf(`
2
+ at`)?" (<anonymous>)":-1<r.stack.indexOf("@")?"@unknown:0:0":""}return`
3
+ `+Le+e+Ee}var gt=!1;function He(e,n){if(!e||gt)return"";gt=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var s={DetermineComponentFrameRoot:function(){try{if(n){var me=function(){throw Error()};if(Object.defineProperty(me.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(me,[])}catch(ce){var se=ce}Reflect.construct(e,[],me)}else{try{me.call()}catch(ce){se=ce}e.call(me.prototype)}}else{try{throw Error()}catch(ce){se=ce}(me=e())&&typeof me.catch=="function"&&me.catch(function(){})}}catch(ce){if(ce&&se&&typeof ce.stack=="string")return[ce.stack,se.stack]}return[null,null]}};s.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var d=Object.getOwnPropertyDescriptor(s.DetermineComponentFrameRoot,"name");d&&d.configurable&&Object.defineProperty(s.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=s.DetermineComponentFrameRoot(),S=g[0],E=g[1];if(S&&E){var V=S.split(`
4
+ `),re=E.split(`
5
+ `);for(d=s=0;s<V.length&&!V[s].includes("DetermineComponentFrameRoot");)s++;for(;d<re.length&&!re[d].includes("DetermineComponentFrameRoot");)d++;if(s===V.length||d===re.length)for(s=V.length-1,d=re.length-1;1<=s&&0<=d&&V[s]!==re[d];)d--;for(;1<=s&&0<=d;s--,d--)if(V[s]!==re[d]){if(s!==1||d!==1)do if(s--,d--,0>d||V[s]!==re[d]){var de=`
6
+ `+V[s].replace(" at new "," at ");return e.displayName&&de.includes("<anonymous>")&&(de=de.replace("<anonymous>",e.displayName)),de}while(1<=s&&0<=d);break}}}finally{gt=!1,Error.prepareStackTrace=r}return(r=e?e.displayName||e.name:"")?Xe(r):""}function Lt(e,n){switch(e.tag){case 26:case 27:case 5:return Xe(e.type);case 16:return Xe("Lazy");case 13:return e.child!==n&&n!==null?Xe("Suspense Fallback"):Xe("Suspense");case 19:return Xe("SuspenseList");case 0:case 15:return He(e.type,!1);case 11:return He(e.type.render,!1);case 1:return He(e.type,!0);case 31:return Xe("Activity");default:return""}}function st(e){try{var n="",r=null;do n+=Lt(e,r),r=e,e=e.return;while(e);return n}catch(s){return`
7
+ Error generating stack: `+s.message+`
8
+ `+s.stack}}var Ve=Object.prototype.hasOwnProperty,At=t.unstable_scheduleCallback,Ie=t.unstable_cancelCallback,yt=t.unstable_shouldYield,ot=t.unstable_requestPaint,Ze=t.unstable_now,pt=t.unstable_getCurrentPriorityLevel,_=t.unstable_ImmediatePriority,Z=t.unstable_UserBlockingPriority,ge=t.unstable_NormalPriority,we=t.unstable_LowPriority,Ne=t.unstable_IdlePriority,De=t.log,Ge=t.unstable_setDisableYieldValue,mt=null,ut=null;function dt(e){if(typeof De=="function"&&Ge(e),ut&&typeof ut.setStrictMode=="function")try{ut.setStrictMode(mt,e)}catch{}}var tt=Math.clz32?Math.clz32:Se,Ot=Math.log,oe=Math.LN2;function Se(e){return e>>>=0,e===0?32:31-(Ot(e)/oe|0)|0}var Ae=256,Re=262144,ne=4194304;function ye(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 Oe(e,n,r){var s=e.pendingLanes;if(s===0)return 0;var d=0,g=e.suspendedLanes,S=e.pingedLanes;e=e.warmLanes;var E=s&134217727;return E!==0?(s=E&~g,s!==0?d=ye(s):(S&=E,S!==0?d=ye(S):r||(r=E&~e,r!==0&&(d=ye(r))))):(E=s&~g,E!==0?d=ye(E):S!==0?d=ye(S):r||(r=s&~e,r!==0&&(d=ye(r)))),d===0?0:n!==0&&n!==d&&(n&g)===0&&(g=d&-d,r=n&-n,g>=r||g===32&&(r&4194048)!==0)?n:d}function Ce(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function U(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 fe(){var e=ne;return ne<<=1,(ne&62914560)===0&&(ne=4194304),e}function je(e){for(var n=[],r=0;31>r;r++)n.push(e);return n}function Pe(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function lt(e,n,r,s,d,g){var S=e.pendingLanes;e.pendingLanes=r,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=r,e.entangledLanes&=r,e.errorRecoveryDisabledLanes&=r,e.shellSuspendCounter=0;var E=e.entanglements,V=e.expirationTimes,re=e.hiddenUpdates;for(r=S&~r;0<r;){var de=31-tt(r),me=1<<de;E[de]=0,V[de]=-1;var se=re[de];if(se!==null)for(re[de]=null,de=0;de<se.length;de++){var ce=se[de];ce!==null&&(ce.lane&=-536870913)}r&=~me}s!==0&&Tt(e,s,0),g!==0&&d===0&&e.tag!==0&&(e.suspendedLanes|=g&~(S&~n))}function Tt(e,n,r){e.pendingLanes|=n,e.suspendedLanes&=~n;var s=31-tt(n);e.entangledLanes|=n,e.entanglements[s]=e.entanglements[s]|1073741824|r&261930}function kt(e,n){var r=e.entangledLanes|=n;for(e=e.entanglements;r;){var s=31-tt(r),d=1<<s;d&n|e[s]&n&&(e[s]|=n),r&=~d}}function Wn(e,n){var r=n&-n;return r=(r&42)!==0?1:Vt(r),(r&(e.suspendedLanes|n))!==0?0:r}function Vt(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 wr(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function Ta(){var e=Y.p;return e!==0?e:(e=window.event,e===void 0?32:og(e.type))}function Ki(e,n){var r=Y.p;try{return Y.p=e,n()}finally{Y.p=r}}var En=Math.random().toString(36).slice(2),Bt="__reactFiber$"+En,Jt="__reactProps$"+En,Gn="__reactContainer$"+En,Fn="__reactEvents$"+En,Vv="__reactListeners$"+En,Yv="__reactHandles$"+En,Cd="__reactResources$"+En,gl="__reactMarker$"+En;function xo(e){delete e[Bt],delete e[Jt],delete e[Fn],delete e[Vv],delete e[Yv]}function jr(e){var n=e[Bt];if(n)return n;for(var r=e.parentNode;r;){if(n=r[Gn]||r[Bt]){if(r=n.alternate,n.child!==null||r!==null&&r.child!==null)for(e=$m(e);e!==null;){if(r=e[Bt])return r;e=$m(e)}return n}e=r,r=e.parentNode}return null}function kr(e){if(e=e[Bt]||e[Gn]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function yl(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(a(33))}function Cr(e){var n=e[Cd];return n||(n=e[Cd]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Kt(e){e[gl]=!0}var Ed=new Set,Nd={};function Pi(e,n){Er(e,n),Er(e+"Capture",n)}function Er(e,n){for(Nd[e]=n,e=0;e<n.length;e++)Ed.add(n[e])}var Gv=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]*$"),Ad={},Td={};function Fv(e){return Ve.call(Td,e)?!0:Ve.call(Ad,e)?!1:Gv.test(e)?Td[e]=!0:(Ad[e]=!0,!1)}function Ra(e,n,r){if(Fv(n))if(r===null)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var s=n.toLowerCase().slice(0,5);if(s!=="data-"&&s!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+r)}}function za(e,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttribute(n,""+r)}}function ei(e,n,r,s){if(s===null)e.removeAttribute(r);else{switch(typeof s){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(r);return}e.setAttributeNS(n,r,""+s)}}function Nn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Rd(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function $v(e,n,r){var s=Object.getOwnPropertyDescriptor(e.constructor.prototype,n);if(!e.hasOwnProperty(n)&&typeof s<"u"&&typeof s.get=="function"&&typeof s.set=="function"){var d=s.get,g=s.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return d.call(this)},set:function(S){r=""+S,g.call(this,S)}}),Object.defineProperty(e,n,{enumerable:s.enumerable}),{getValue:function(){return r},setValue:function(S){r=""+S},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function So(e){if(!e._valueTracker){var n=Rd(e)?"checked":"value";e._valueTracker=$v(e,n,""+e[n])}}function zd(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var r=n.getValue(),s="";return e&&(s=Rd(e)?e.checked?"true":"false":e.value),e=s,e!==r?(n.setValue(e),!0):!1}function Da(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 Qv=/[\n"\\]/g;function An(e){return e.replace(Qv,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function wo(e,n,r,s,d,g,S,E){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=""+Nn(n)):e.value!==""+Nn(n)&&(e.value=""+Nn(n)):S!=="submit"&&S!=="reset"||e.removeAttribute("value"),n!=null?jo(e,S,Nn(n)):r!=null?jo(e,S,Nn(r)):s!=null&&e.removeAttribute("value"),d==null&&g!=null&&(e.defaultChecked=!!g),d!=null&&(e.checked=d&&typeof d!="function"&&typeof d!="symbol"),E!=null&&typeof E!="function"&&typeof E!="symbol"&&typeof E!="boolean"?e.name=""+Nn(E):e.removeAttribute("name")}function Dd(e,n,r,s,d,g,S,E){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(e.type=g),n!=null||r!=null){if(!(g!=="submit"&&g!=="reset"||n!=null)){So(e);return}r=r!=null?""+Nn(r):"",n=n!=null?""+Nn(n):r,E||n===e.value||(e.value=n),e.defaultValue=n}s=s??d,s=typeof s!="function"&&typeof s!="symbol"&&!!s,e.checked=E?e.checked:!!s,e.defaultChecked=!!s,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(e.name=S),So(e)}function jo(e,n,r){n==="number"&&Da(e.ownerDocument)===e||e.defaultValue===""+r||(e.defaultValue=""+r)}function Nr(e,n,r,s){if(e=e.options,n){n={};for(var d=0;d<r.length;d++)n["$"+r[d]]=!0;for(r=0;r<e.length;r++)d=n.hasOwnProperty("$"+e[r].value),e[r].selected!==d&&(e[r].selected=d),d&&s&&(e[r].defaultSelected=!0)}else{for(r=""+Nn(r),n=null,d=0;d<e.length;d++){if(e[d].value===r){e[d].selected=!0,s&&(e[d].defaultSelected=!0);return}n!==null||e[d].disabled||(n=e[d])}n!==null&&(n.selected=!0)}}function _d(e,n,r){if(n!=null&&(n=""+Nn(n),n!==e.value&&(e.value=n),r==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=r!=null?""+Nn(r):""}function Md(e,n,r,s){if(n==null){if(s!=null){if(r!=null)throw Error(a(92));if(K(s)){if(1<s.length)throw Error(a(93));s=s[0]}r=s}r==null&&(r=""),n=r}r=Nn(n),e.defaultValue=r,s=e.textContent,s===r&&s!==""&&s!==null&&(e.value=s),So(e)}function Ar(e,n){if(n){var r=e.firstChild;if(r&&r===e.lastChild&&r.nodeType===3){r.nodeValue=n;return}}e.textContent=n}var Xv=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 Od(e,n,r){var s=n.indexOf("--")===0;r==null||typeof r=="boolean"||r===""?s?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":s?e.setProperty(n,r):typeof r!="number"||r===0||Xv.has(n)?n==="float"?e.cssFloat=r:e[n]=(""+r).trim():e[n]=r+"px"}function Ld(e,n,r){if(n!=null&&typeof n!="object")throw Error(a(62));if(e=e.style,r!=null){for(var s in r)!r.hasOwnProperty(s)||n!=null&&n.hasOwnProperty(s)||(s.indexOf("--")===0?e.setProperty(s,""):s==="float"?e.cssFloat="":e[s]="");for(var d in n)s=n[d],n.hasOwnProperty(d)&&r[d]!==s&&Od(e,d,s)}else for(var g in n)n.hasOwnProperty(g)&&Od(e,g,n[g])}function ko(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 Kv=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"]]),Pv=/^[\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 _a(e){return Pv.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function ti(){}var Co=null;function Eo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Tr=null,Rr=null;function Bd(e){var n=kr(e);if(n&&(e=n.stateNode)){var r=e[Jt]||null;e:switch(e=n.stateNode,n.type){case"input":if(wo(e,r.value,r.defaultValue,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name),n=r.name,r.type==="radio"&&n!=null){for(r=e;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll('input[name="'+An(""+n)+'"][type="radio"]'),n=0;n<r.length;n++){var s=r[n];if(s!==e&&s.form===e.form){var d=s[Jt]||null;if(!d)throw Error(a(90));wo(s,d.value,d.defaultValue,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name)}}for(n=0;n<r.length;n++)s=r[n],s.form===e.form&&zd(s)}break e;case"textarea":_d(e,r.value,r.defaultValue);break e;case"select":n=r.value,n!=null&&Nr(e,!!r.multiple,n,!1)}}}var No=!1;function Ud(e,n,r){if(No)return e(n,r);No=!0;try{var s=e(n);return s}finally{if(No=!1,(Tr!==null||Rr!==null)&&(xs(),Tr&&(n=Tr,e=Rr,Rr=Tr=null,Bd(n),e)))for(n=0;n<e.length;n++)Bd(e[n])}}function bl(e,n){var r=e.stateNode;if(r===null)return null;var s=r[Jt]||null;if(s===null)return null;r=s[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":(s=!s.disabled)||(e=e.type,s=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!s;break e;default:e=!1}if(e)return null;if(r&&typeof r!="function")throw Error(a(231,n,typeof r));return r}var ni=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ao=!1;if(ni)try{var vl={};Object.defineProperty(vl,"passive",{get:function(){Ao=!0}}),window.addEventListener("test",vl,vl),window.removeEventListener("test",vl,vl)}catch{Ao=!1}var wi=null,To=null,Ma=null;function Id(){if(Ma)return Ma;var e,n=To,r=n.length,s,d="value"in wi?wi.value:wi.textContent,g=d.length;for(e=0;e<r&&n[e]===d[e];e++);var S=r-e;for(s=1;s<=S&&n[r-s]===d[g-s];s++);return Ma=d.slice(e,1<s?1-s:void 0)}function Oa(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 La(){return!0}function qd(){return!1}function un(e){function n(r,s,d,g,S){this._reactName=r,this._targetInst=d,this.type=s,this.nativeEvent=g,this.target=S,this.currentTarget=null;for(var E in e)e.hasOwnProperty(E)&&(r=e[E],this[E]=r?r(g):g[E]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?La:qd,this.isPropagationStopped=qd,this}return b(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=La)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=La)},persist:function(){},isPersistent:La}),n}var Zi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ba=un(Zi),xl=b({},Zi,{view:0,detail:0}),Zv=un(xl),Ro,zo,Sl,Ua=b({},xl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:_o,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!==Sl&&(Sl&&e.type==="mousemove"?(Ro=e.screenX-Sl.screenX,zo=e.screenY-Sl.screenY):zo=Ro=0,Sl=e),Ro)},movementY:function(e){return"movementY"in e?e.movementY:zo}}),Hd=un(Ua),Jv=b({},Ua,{dataTransfer:0}),Wv=un(Jv),ex=b({},xl,{relatedTarget:0}),Do=un(ex),tx=b({},Zi,{animationName:0,elapsedTime:0,pseudoElement:0}),nx=un(tx),ix=b({},Zi,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),rx=un(ix),lx=b({},Zi,{data:0}),Vd=un(lx),ax={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},sx={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},ox={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ux(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=ox[e])?!!n[e]:!1}function _o(){return ux}var cx=b({},xl,{key:function(e){if(e.key){var n=ax[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=Oa(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?sx[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:_o,charCode:function(e){return e.type==="keypress"?Oa(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Oa(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),fx=un(cx),dx=b({},Ua,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Yd=un(dx),hx=b({},xl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:_o}),px=un(hx),mx=b({},Zi,{propertyName:0,elapsedTime:0,pseudoElement:0}),gx=un(mx),yx=b({},Ua,{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}),bx=un(yx),vx=b({},Zi,{newState:0,oldState:0}),xx=un(vx),Sx=[9,13,27,32],Mo=ni&&"CompositionEvent"in window,wl=null;ni&&"documentMode"in document&&(wl=document.documentMode);var wx=ni&&"TextEvent"in window&&!wl,Gd=ni&&(!Mo||wl&&8<wl&&11>=wl),Fd=" ",$d=!1;function Qd(e,n){switch(e){case"keyup":return Sx.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Xd(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var zr=!1;function jx(e,n){switch(e){case"compositionend":return Xd(n);case"keypress":return n.which!==32?null:($d=!0,Fd);case"textInput":return e=n.data,e===Fd&&$d?null:e;default:return null}}function kx(e,n){if(zr)return e==="compositionend"||!Mo&&Qd(e,n)?(e=Id(),Ma=To=wi=null,zr=!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 Gd&&n.locale!=="ko"?null:n.data;default:return null}}var Cx={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 Kd(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!Cx[e.type]:n==="textarea"}function Pd(e,n,r,s){Tr?Rr?Rr.push(s):Rr=[s]:Tr=s,n=Ns(n,"onChange"),0<n.length&&(r=new Ba("onChange","change",null,r,s),e.push({event:r,listeners:n}))}var jl=null,kl=null;function Ex(e){Dm(e,0)}function Ia(e){var n=yl(e);if(zd(n))return e}function Zd(e,n){if(e==="change")return n}var Jd=!1;if(ni){var Oo;if(ni){var Lo="oninput"in document;if(!Lo){var Wd=document.createElement("div");Wd.setAttribute("oninput","return;"),Lo=typeof Wd.oninput=="function"}Oo=Lo}else Oo=!1;Jd=Oo&&(!document.documentMode||9<document.documentMode)}function eh(){jl&&(jl.detachEvent("onpropertychange",th),kl=jl=null)}function th(e){if(e.propertyName==="value"&&Ia(kl)){var n=[];Pd(n,kl,e,Eo(e)),Ud(Ex,n)}}function Nx(e,n,r){e==="focusin"?(eh(),jl=n,kl=r,jl.attachEvent("onpropertychange",th)):e==="focusout"&&eh()}function Ax(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ia(kl)}function Tx(e,n){if(e==="click")return Ia(n)}function Rx(e,n){if(e==="input"||e==="change")return Ia(n)}function zx(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var yn=typeof Object.is=="function"?Object.is:zx;function Cl(e,n){if(yn(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var r=Object.keys(e),s=Object.keys(n);if(r.length!==s.length)return!1;for(s=0;s<r.length;s++){var d=r[s];if(!Ve.call(n,d)||!yn(e[d],n[d]))return!1}return!0}function nh(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ih(e,n){var r=nh(e);e=0;for(var s;r;){if(r.nodeType===3){if(s=e+r.textContent.length,e<=n&&s>=n)return{node:r,offset:n-e};e=s}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=nh(r)}}function rh(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?rh(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function lh(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=Da(e.document);n instanceof e.HTMLIFrameElement;){try{var r=typeof n.contentWindow.location.href=="string"}catch{r=!1}if(r)e=n.contentWindow;else break;n=Da(e.document)}return n}function Bo(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 Dx=ni&&"documentMode"in document&&11>=document.documentMode,Dr=null,Uo=null,El=null,Io=!1;function ah(e,n,r){var s=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;Io||Dr==null||Dr!==Da(s)||(s=Dr,"selectionStart"in s&&Bo(s)?s={start:s.selectionStart,end:s.selectionEnd}:(s=(s.ownerDocument&&s.ownerDocument.defaultView||window).getSelection(),s={anchorNode:s.anchorNode,anchorOffset:s.anchorOffset,focusNode:s.focusNode,focusOffset:s.focusOffset}),El&&Cl(El,s)||(El=s,s=Ns(Uo,"onSelect"),0<s.length&&(n=new Ba("onSelect","select",null,n,r),e.push({event:n,listeners:s}),n.target=Dr)))}function Ji(e,n){var r={};return r[e.toLowerCase()]=n.toLowerCase(),r["Webkit"+e]="webkit"+n,r["Moz"+e]="moz"+n,r}var _r={animationend:Ji("Animation","AnimationEnd"),animationiteration:Ji("Animation","AnimationIteration"),animationstart:Ji("Animation","AnimationStart"),transitionrun:Ji("Transition","TransitionRun"),transitionstart:Ji("Transition","TransitionStart"),transitioncancel:Ji("Transition","TransitionCancel"),transitionend:Ji("Transition","TransitionEnd")},qo={},sh={};ni&&(sh=document.createElement("div").style,"AnimationEvent"in window||(delete _r.animationend.animation,delete _r.animationiteration.animation,delete _r.animationstart.animation),"TransitionEvent"in window||delete _r.transitionend.transition);function Wi(e){if(qo[e])return qo[e];if(!_r[e])return e;var n=_r[e],r;for(r in n)if(n.hasOwnProperty(r)&&r in sh)return qo[e]=n[r];return e}var oh=Wi("animationend"),uh=Wi("animationiteration"),ch=Wi("animationstart"),_x=Wi("transitionrun"),Mx=Wi("transitionstart"),Ox=Wi("transitioncancel"),fh=Wi("transitionend"),dh=new Map,Ho="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(" ");Ho.push("scrollEnd");function Un(e,n){dh.set(e,n),Pi(n,[e])}var qa=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Tn=[],Mr=0,Vo=0;function Ha(){for(var e=Mr,n=Vo=Mr=0;n<e;){var r=Tn[n];Tn[n++]=null;var s=Tn[n];Tn[n++]=null;var d=Tn[n];Tn[n++]=null;var g=Tn[n];if(Tn[n++]=null,s!==null&&d!==null){var S=s.pending;S===null?d.next=d:(d.next=S.next,S.next=d),s.pending=d}g!==0&&hh(r,d,g)}}function Va(e,n,r,s){Tn[Mr++]=e,Tn[Mr++]=n,Tn[Mr++]=r,Tn[Mr++]=s,Vo|=s,e.lanes|=s,e=e.alternate,e!==null&&(e.lanes|=s)}function Yo(e,n,r,s){return Va(e,n,r,s),Ya(e)}function er(e,n){return Va(e,null,null,n),Ya(e)}function hh(e,n,r){e.lanes|=r;var s=e.alternate;s!==null&&(s.lanes|=r);for(var d=!1,g=e.return;g!==null;)g.childLanes|=r,s=g.alternate,s!==null&&(s.childLanes|=r),g.tag===22&&(e=g.stateNode,e===null||e._visibility&1||(d=!0)),e=g,g=g.return;return e.tag===3?(g=e.stateNode,d&&n!==null&&(d=31-tt(r),e=g.hiddenUpdates,s=e[d],s===null?e[d]=[n]:s.push(n),n.lane=r|536870912),g):null}function Ya(e){if(50<Xl)throw Xl=0,Ju=null,Error(a(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var Or={};function Lx(e,n,r,s){this.tag=e,this.key=r,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=s,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function bn(e,n,r,s){return new Lx(e,n,r,s)}function Go(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ii(e,n){var r=e.alternate;return r===null?(r=bn(e.tag,n,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=n,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&65011712,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,n=e.dependencies,r.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r.refCleanup=e.refCleanup,r}function ph(e,n){e.flags&=65011714;var r=e.alternate;return r===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=r.childLanes,e.lanes=r.lanes,e.child=r.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=r.memoizedProps,e.memoizedState=r.memoizedState,e.updateQueue=r.updateQueue,e.type=r.type,n=r.dependencies,e.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function Ga(e,n,r,s,d,g){var S=0;if(s=e,typeof e=="function")Go(e)&&(S=1);else if(typeof e=="string")S=H0(e,r,ee.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case q:return e=bn(31,r,n,d),e.elementType=q,e.lanes=g,e;case z:return tr(r.children,d,g,n);case A:S=8,d|=24;break;case N:return e=bn(12,r,n,d|2),e.elementType=N,e.lanes=g,e;case ae:return e=bn(13,r,n,d),e.elementType=ae,e.lanes=g,e;case D:return e=bn(19,r,n,d),e.elementType=D,e.lanes=g,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case M:S=10;break e;case T:S=9;break e;case G:S=11;break e;case H:S=14;break e;case W:S=16,s=null;break e}S=29,r=Error(a(130,e===null?"null":typeof e,"")),s=null}return n=bn(S,r,n,d),n.elementType=e,n.type=s,n.lanes=g,n}function tr(e,n,r,s){return e=bn(7,e,s,n),e.lanes=r,e}function Fo(e,n,r){return e=bn(6,e,null,n),e.lanes=r,e}function mh(e){var n=bn(18,null,null,0);return n.stateNode=e,n}function $o(e,n,r){return n=bn(4,e.children!==null?e.children:[],e.key,n),n.lanes=r,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var gh=new WeakMap;function Rn(e,n){if(typeof e=="object"&&e!==null){var r=gh.get(e);return r!==void 0?r:(n={value:e,source:n,stack:st(n)},gh.set(e,n),n)}return{value:e,source:n,stack:st(n)}}var Lr=[],Br=0,Fa=null,Nl=0,zn=[],Dn=0,ji=null,$n=1,Qn="";function ri(e,n){Lr[Br++]=Nl,Lr[Br++]=Fa,Fa=e,Nl=n}function yh(e,n,r){zn[Dn++]=$n,zn[Dn++]=Qn,zn[Dn++]=ji,ji=e;var s=$n;e=Qn;var d=32-tt(s)-1;s&=~(1<<d),r+=1;var g=32-tt(n)+d;if(30<g){var S=d-d%5;g=(s&(1<<S)-1).toString(32),s>>=S,d-=S,$n=1<<32-tt(n)+d|r<<d|s,Qn=g+e}else $n=1<<g|r<<d|s,Qn=e}function Qo(e){e.return!==null&&(ri(e,1),yh(e,1,0))}function Xo(e){for(;e===Fa;)Fa=Lr[--Br],Lr[Br]=null,Nl=Lr[--Br],Lr[Br]=null;for(;e===ji;)ji=zn[--Dn],zn[Dn]=null,Qn=zn[--Dn],zn[Dn]=null,$n=zn[--Dn],zn[Dn]=null}function bh(e,n){zn[Dn++]=$n,zn[Dn++]=Qn,zn[Dn++]=ji,$n=n.id,Qn=n.overflow,ji=e}var Wt=null,Rt=null,rt=!1,ki=null,_n=!1,Ko=Error(a(519));function Ci(e){var n=Error(a(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Al(Rn(n,e)),Ko}function vh(e){var n=e.stateNode,r=e.type,s=e.memoizedProps;switch(n[Bt]=e,n[Jt]=s,r){case"dialog":We("cancel",n),We("close",n);break;case"iframe":case"object":case"embed":We("load",n);break;case"video":case"audio":for(r=0;r<Pl.length;r++)We(Pl[r],n);break;case"source":We("error",n);break;case"img":case"image":case"link":We("error",n),We("load",n);break;case"details":We("toggle",n);break;case"input":We("invalid",n),Dd(n,s.value,s.defaultValue,s.checked,s.defaultChecked,s.type,s.name,!0);break;case"select":We("invalid",n);break;case"textarea":We("invalid",n),Md(n,s.value,s.defaultValue,s.children)}r=s.children,typeof r!="string"&&typeof r!="number"&&typeof r!="bigint"||n.textContent===""+r||s.suppressHydrationWarning===!0||Lm(n.textContent,r)?(s.popover!=null&&(We("beforetoggle",n),We("toggle",n)),s.onScroll!=null&&We("scroll",n),s.onScrollEnd!=null&&We("scrollend",n),s.onClick!=null&&(n.onclick=ti),n=!0):n=!1,n||Ci(e,!0)}function xh(e){for(Wt=e.return;Wt;)switch(Wt.tag){case 5:case 31:case 13:_n=!1;return;case 27:case 3:_n=!0;return;default:Wt=Wt.return}}function Ur(e){if(e!==Wt)return!1;if(!rt)return xh(e),rt=!0,!1;var n=e.tag,r;if((r=n!==3&&n!==27)&&((r=n===5)&&(r=e.type,r=!(r!=="form"&&r!=="button")||hc(e.type,e.memoizedProps)),r=!r),r&&Rt&&Ci(e),xh(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));Rt=Fm(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(317));Rt=Fm(e)}else n===27?(n=Rt,Ii(e.type)?(e=bc,bc=null,Rt=e):Rt=n):Rt=Wt?On(e.stateNode.nextSibling):null;return!0}function nr(){Rt=Wt=null,rt=!1}function Po(){var e=ki;return e!==null&&(hn===null?hn=e:hn.push.apply(hn,e),ki=null),e}function Al(e){ki===null?ki=[e]:ki.push(e)}var Zo=O(null),ir=null,li=null;function Ei(e,n,r){R(Zo,n._currentValue),n._currentValue=r}function ai(e){e._currentValue=Zo.current,te(Zo)}function Jo(e,n,r){for(;e!==null;){var s=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,s!==null&&(s.childLanes|=n)):s!==null&&(s.childLanes&n)!==n&&(s.childLanes|=n),e===r)break;e=e.return}}function Wo(e,n,r,s){var d=e.child;for(d!==null&&(d.return=e);d!==null;){var g=d.dependencies;if(g!==null){var S=d.child;g=g.firstContext;e:for(;g!==null;){var E=g;g=d;for(var V=0;V<n.length;V++)if(E.context===n[V]){g.lanes|=r,E=g.alternate,E!==null&&(E.lanes|=r),Jo(g.return,r,e),s||(S=null);break e}g=E.next}}else if(d.tag===18){if(S=d.return,S===null)throw Error(a(341));S.lanes|=r,g=S.alternate,g!==null&&(g.lanes|=r),Jo(S,r,e),S=null}else S=d.child;if(S!==null)S.return=d;else for(S=d;S!==null;){if(S===e){S=null;break}if(d=S.sibling,d!==null){d.return=S.return,S=d;break}S=S.return}d=S}}function Ir(e,n,r,s){e=null;for(var d=n,g=!1;d!==null;){if(!g){if((d.flags&524288)!==0)g=!0;else if((d.flags&262144)!==0)break}if(d.tag===10){var S=d.alternate;if(S===null)throw Error(a(387));if(S=S.memoizedProps,S!==null){var E=d.type;yn(d.pendingProps.value,S.value)||(e!==null?e.push(E):e=[E])}}else if(d===ue.current){if(S=d.alternate,S===null)throw Error(a(387));S.memoizedState.memoizedState!==d.memoizedState.memoizedState&&(e!==null?e.push(ta):e=[ta])}d=d.return}e!==null&&Wo(n,e,r,s),n.flags|=262144}function $a(e){for(e=e.firstContext;e!==null;){if(!yn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function rr(e){ir=e,li=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function en(e){return Sh(ir,e)}function Qa(e,n){return ir===null&&rr(e),Sh(e,n)}function Sh(e,n){var r=n._currentValue;if(n={context:n,memoizedValue:r,next:null},li===null){if(e===null)throw Error(a(308));li=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else li=li.next=n;return r}var Bx=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(r,s){e.push(s)}};this.abort=function(){n.aborted=!0,e.forEach(function(r){return r()})}},Ux=t.unstable_scheduleCallback,Ix=t.unstable_NormalPriority,Yt={$$typeof:M,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function eu(){return{controller:new Bx,data:new Map,refCount:0}}function Tl(e){e.refCount--,e.refCount===0&&Ux(Ix,function(){e.controller.abort()})}var Rl=null,tu=0,qr=0,Hr=null;function qx(e,n){if(Rl===null){var r=Rl=[];tu=0,qr=rc(),Hr={status:"pending",value:void 0,then:function(s){r.push(s)}}}return tu++,n.then(wh,wh),n}function wh(){if(--tu===0&&Rl!==null){Hr!==null&&(Hr.status="fulfilled");var e=Rl;Rl=null,qr=0,Hr=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function Hx(e,n){var r=[],s={status:"pending",value:null,reason:null,then:function(d){r.push(d)}};return e.then(function(){s.status="fulfilled",s.value=n;for(var d=0;d<r.length;d++)(0,r[d])(n)},function(d){for(s.status="rejected",s.reason=d,d=0;d<r.length;d++)(0,r[d])(void 0)}),s}var jh=I.S;I.S=function(e,n){am=Ze(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&qx(e,n),jh!==null&&jh(e,n)};var lr=O(null);function nu(){var e=lr.current;return e!==null?e:Ct.pooledCache}function Xa(e,n){n===null?R(lr,lr.current):R(lr,n.pool)}function kh(){var e=nu();return e===null?null:{parent:Yt._currentValue,pool:e}}var Vr=Error(a(460)),iu=Error(a(474)),Ka=Error(a(542)),Pa={then:function(){}};function Ch(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Eh(e,n,r){switch(r=e[r],r===void 0?e.push(n):r!==n&&(n.then(ti,ti),n=r),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Ah(e),e;default:if(typeof n.status=="string")n.then(ti,ti);else{if(e=Ct,e!==null&&100<e.shellSuspendCounter)throw Error(a(482));e=n,e.status="pending",e.then(function(s){if(n.status==="pending"){var d=n;d.status="fulfilled",d.value=s}},function(s){if(n.status==="pending"){var d=n;d.status="rejected",d.reason=s}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Ah(e),e}throw sr=n,Vr}}function ar(e){try{var n=e._init;return n(e._payload)}catch(r){throw r!==null&&typeof r=="object"&&typeof r.then=="function"?(sr=r,Vr):r}}var sr=null;function Nh(){if(sr===null)throw Error(a(459));var e=sr;return sr=null,e}function Ah(e){if(e===Vr||e===Ka)throw Error(a(483))}var Yr=null,zl=0;function Za(e){var n=zl;return zl+=1,Yr===null&&(Yr=[]),Eh(Yr,e,n)}function Dl(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function Ja(e,n){throw n.$$typeof===x?Error(a(525)):(e=Object.prototype.toString.call(n),Error(a(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function Th(e){function n(P,$){if(e){var ie=P.deletions;ie===null?(P.deletions=[$],P.flags|=16):ie.push($)}}function r(P,$){if(!e)return null;for(;$!==null;)n(P,$),$=$.sibling;return null}function s(P){for(var $=new Map;P!==null;)P.key!==null?$.set(P.key,P):$.set(P.index,P),P=P.sibling;return $}function d(P,$){return P=ii(P,$),P.index=0,P.sibling=null,P}function g(P,$,ie){return P.index=ie,e?(ie=P.alternate,ie!==null?(ie=ie.index,ie<$?(P.flags|=67108866,$):ie):(P.flags|=67108866,$)):(P.flags|=1048576,$)}function S(P){return e&&P.alternate===null&&(P.flags|=67108866),P}function E(P,$,ie,he){return $===null||$.tag!==6?($=Fo(ie,P.mode,he),$.return=P,$):($=d($,ie),$.return=P,$)}function V(P,$,ie,he){var Me=ie.type;return Me===z?de(P,$,ie.props.children,he,ie.key):$!==null&&($.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===W&&ar(Me)===$.type)?($=d($,ie.props),Dl($,ie),$.return=P,$):($=Ga(ie.type,ie.key,ie.props,null,P.mode,he),Dl($,ie),$.return=P,$)}function re(P,$,ie,he){return $===null||$.tag!==4||$.stateNode.containerInfo!==ie.containerInfo||$.stateNode.implementation!==ie.implementation?($=$o(ie,P.mode,he),$.return=P,$):($=d($,ie.children||[]),$.return=P,$)}function de(P,$,ie,he,Me){return $===null||$.tag!==7?($=tr(ie,P.mode,he,Me),$.return=P,$):($=d($,ie),$.return=P,$)}function me(P,$,ie){if(typeof $=="string"&&$!==""||typeof $=="number"||typeof $=="bigint")return $=Fo(""+$,P.mode,ie),$.return=P,$;if(typeof $=="object"&&$!==null){switch($.$$typeof){case v:return ie=Ga($.type,$.key,$.props,null,P.mode,ie),Dl(ie,$),ie.return=P,ie;case j:return $=$o($,P.mode,ie),$.return=P,$;case W:return $=ar($),me(P,$,ie)}if(K($)||B($))return $=tr($,P.mode,ie,null),$.return=P,$;if(typeof $.then=="function")return me(P,Za($),ie);if($.$$typeof===M)return me(P,Qa(P,$),ie);Ja(P,$)}return null}function se(P,$,ie,he){var Me=$!==null?$.key:null;if(typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint")return Me!==null?null:E(P,$,""+ie,he);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case v:return ie.key===Me?V(P,$,ie,he):null;case j:return ie.key===Me?re(P,$,ie,he):null;case W:return ie=ar(ie),se(P,$,ie,he)}if(K(ie)||B(ie))return Me!==null?null:de(P,$,ie,he,null);if(typeof ie.then=="function")return se(P,$,Za(ie),he);if(ie.$$typeof===M)return se(P,$,Qa(P,ie),he);Ja(P,ie)}return null}function ce(P,$,ie,he,Me){if(typeof he=="string"&&he!==""||typeof he=="number"||typeof he=="bigint")return P=P.get(ie)||null,E($,P,""+he,Me);if(typeof he=="object"&&he!==null){switch(he.$$typeof){case v:return P=P.get(he.key===null?ie:he.key)||null,V($,P,he,Me);case j:return P=P.get(he.key===null?ie:he.key)||null,re($,P,he,Me);case W:return he=ar(he),ce(P,$,ie,he,Me)}if(K(he)||B(he))return P=P.get(ie)||null,de($,P,he,Me,null);if(typeof he.then=="function")return ce(P,$,ie,Za(he),Me);if(he.$$typeof===M)return ce(P,$,ie,Qa($,he),Me);Ja($,he)}return null}function Te(P,$,ie,he){for(var Me=null,ct=null,_e=$,Qe=$=0,it=null;_e!==null&&Qe<ie.length;Qe++){_e.index>Qe?(it=_e,_e=null):it=_e.sibling;var ft=se(P,_e,ie[Qe],he);if(ft===null){_e===null&&(_e=it);break}e&&_e&&ft.alternate===null&&n(P,_e),$=g(ft,$,Qe),ct===null?Me=ft:ct.sibling=ft,ct=ft,_e=it}if(Qe===ie.length)return r(P,_e),rt&&ri(P,Qe),Me;if(_e===null){for(;Qe<ie.length;Qe++)_e=me(P,ie[Qe],he),_e!==null&&($=g(_e,$,Qe),ct===null?Me=_e:ct.sibling=_e,ct=_e);return rt&&ri(P,Qe),Me}for(_e=s(_e);Qe<ie.length;Qe++)it=ce(_e,P,Qe,ie[Qe],he),it!==null&&(e&&it.alternate!==null&&_e.delete(it.key===null?Qe:it.key),$=g(it,$,Qe),ct===null?Me=it:ct.sibling=it,ct=it);return e&&_e.forEach(function(Gi){return n(P,Gi)}),rt&&ri(P,Qe),Me}function Ue(P,$,ie,he){if(ie==null)throw Error(a(151));for(var Me=null,ct=null,_e=$,Qe=$=0,it=null,ft=ie.next();_e!==null&&!ft.done;Qe++,ft=ie.next()){_e.index>Qe?(it=_e,_e=null):it=_e.sibling;var Gi=se(P,_e,ft.value,he);if(Gi===null){_e===null&&(_e=it);break}e&&_e&&Gi.alternate===null&&n(P,_e),$=g(Gi,$,Qe),ct===null?Me=Gi:ct.sibling=Gi,ct=Gi,_e=it}if(ft.done)return r(P,_e),rt&&ri(P,Qe),Me;if(_e===null){for(;!ft.done;Qe++,ft=ie.next())ft=me(P,ft.value,he),ft!==null&&($=g(ft,$,Qe),ct===null?Me=ft:ct.sibling=ft,ct=ft);return rt&&ri(P,Qe),Me}for(_e=s(_e);!ft.done;Qe++,ft=ie.next())ft=ce(_e,P,Qe,ft.value,he),ft!==null&&(e&&ft.alternate!==null&&_e.delete(ft.key===null?Qe:ft.key),$=g(ft,$,Qe),ct===null?Me=ft:ct.sibling=ft,ct=ft);return e&&_e.forEach(function(J0){return n(P,J0)}),rt&&ri(P,Qe),Me}function jt(P,$,ie,he){if(typeof ie=="object"&&ie!==null&&ie.type===z&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case v:e:{for(var Me=ie.key;$!==null;){if($.key===Me){if(Me=ie.type,Me===z){if($.tag===7){r(P,$.sibling),he=d($,ie.props.children),he.return=P,P=he;break e}}else if($.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===W&&ar(Me)===$.type){r(P,$.sibling),he=d($,ie.props),Dl(he,ie),he.return=P,P=he;break e}r(P,$);break}else n(P,$);$=$.sibling}ie.type===z?(he=tr(ie.props.children,P.mode,he,ie.key),he.return=P,P=he):(he=Ga(ie.type,ie.key,ie.props,null,P.mode,he),Dl(he,ie),he.return=P,P=he)}return S(P);case j:e:{for(Me=ie.key;$!==null;){if($.key===Me)if($.tag===4&&$.stateNode.containerInfo===ie.containerInfo&&$.stateNode.implementation===ie.implementation){r(P,$.sibling),he=d($,ie.children||[]),he.return=P,P=he;break e}else{r(P,$);break}else n(P,$);$=$.sibling}he=$o(ie,P.mode,he),he.return=P,P=he}return S(P);case W:return ie=ar(ie),jt(P,$,ie,he)}if(K(ie))return Te(P,$,ie,he);if(B(ie)){if(Me=B(ie),typeof Me!="function")throw Error(a(150));return ie=Me.call(ie),Ue(P,$,ie,he)}if(typeof ie.then=="function")return jt(P,$,Za(ie),he);if(ie.$$typeof===M)return jt(P,$,Qa(P,ie),he);Ja(P,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint"?(ie=""+ie,$!==null&&$.tag===6?(r(P,$.sibling),he=d($,ie),he.return=P,P=he):(r(P,$),he=Fo(ie,P.mode,he),he.return=P,P=he),S(P)):r(P,$)}return function(P,$,ie,he){try{zl=0;var Me=jt(P,$,ie,he);return Yr=null,Me}catch(_e){if(_e===Vr||_e===Ka)throw _e;var ct=bn(29,_e,null,P.mode);return ct.lanes=he,ct.return=P,ct}}}var or=Th(!0),Rh=Th(!1),Ni=!1;function ru(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function lu(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 Ai(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ti(e,n,r){var s=e.updateQueue;if(s===null)return null;if(s=s.shared,(ht&2)!==0){var d=s.pending;return d===null?n.next=n:(n.next=d.next,d.next=n),s.pending=n,n=Ya(e),hh(e,null,r),n}return Va(e,s,n,r),Ya(e)}function _l(e,n,r){if(n=n.updateQueue,n!==null&&(n=n.shared,(r&4194048)!==0)){var s=n.lanes;s&=e.pendingLanes,r|=s,n.lanes=r,kt(e,r)}}function au(e,n){var r=e.updateQueue,s=e.alternate;if(s!==null&&(s=s.updateQueue,r===s)){var d=null,g=null;if(r=r.firstBaseUpdate,r!==null){do{var S={lane:r.lane,tag:r.tag,payload:r.payload,callback:null,next:null};g===null?d=g=S:g=g.next=S,r=r.next}while(r!==null);g===null?d=g=n:g=g.next=n}else d=g=n;r={baseState:s.baseState,firstBaseUpdate:d,lastBaseUpdate:g,shared:s.shared,callbacks:s.callbacks},e.updateQueue=r;return}e=r.lastBaseUpdate,e===null?r.firstBaseUpdate=n:e.next=n,r.lastBaseUpdate=n}var su=!1;function Ml(){if(su){var e=Hr;if(e!==null)throw e}}function Ol(e,n,r,s){su=!1;var d=e.updateQueue;Ni=!1;var g=d.firstBaseUpdate,S=d.lastBaseUpdate,E=d.shared.pending;if(E!==null){d.shared.pending=null;var V=E,re=V.next;V.next=null,S===null?g=re:S.next=re,S=V;var de=e.alternate;de!==null&&(de=de.updateQueue,E=de.lastBaseUpdate,E!==S&&(E===null?de.firstBaseUpdate=re:E.next=re,de.lastBaseUpdate=V))}if(g!==null){var me=d.baseState;S=0,de=re=V=null,E=g;do{var se=E.lane&-536870913,ce=se!==E.lane;if(ce?(nt&se)===se:(s&se)===se){se!==0&&se===qr&&(su=!0),de!==null&&(de=de.next={lane:0,tag:E.tag,payload:E.payload,callback:null,next:null});e:{var Te=e,Ue=E;se=n;var jt=r;switch(Ue.tag){case 1:if(Te=Ue.payload,typeof Te=="function"){me=Te.call(jt,me,se);break e}me=Te;break e;case 3:Te.flags=Te.flags&-65537|128;case 0:if(Te=Ue.payload,se=typeof Te=="function"?Te.call(jt,me,se):Te,se==null)break e;me=b({},me,se);break e;case 2:Ni=!0}}se=E.callback,se!==null&&(e.flags|=64,ce&&(e.flags|=8192),ce=d.callbacks,ce===null?d.callbacks=[se]:ce.push(se))}else ce={lane:se,tag:E.tag,payload:E.payload,callback:E.callback,next:null},de===null?(re=de=ce,V=me):de=de.next=ce,S|=se;if(E=E.next,E===null){if(E=d.shared.pending,E===null)break;ce=E,E=ce.next,ce.next=null,d.lastBaseUpdate=ce,d.shared.pending=null}}while(!0);de===null&&(V=me),d.baseState=V,d.firstBaseUpdate=re,d.lastBaseUpdate=de,g===null&&(d.shared.lanes=0),Mi|=S,e.lanes=S,e.memoizedState=me}}function zh(e,n){if(typeof e!="function")throw Error(a(191,e));e.call(n)}function Dh(e,n){var r=e.callbacks;if(r!==null)for(e.callbacks=null,e=0;e<r.length;e++)zh(r[e],n)}var Gr=O(null),Wa=O(0);function _h(e,n){e=mi,R(Wa,e),R(Gr,n),mi=e|n.baseLanes}function ou(){R(Wa,mi),R(Gr,Gr.current)}function uu(){mi=Wa.current,te(Gr),te(Wa)}var vn=O(null),Mn=null;function Ri(e){var n=e.alternate;R(qt,qt.current&1),R(vn,e),Mn===null&&(n===null||Gr.current!==null||n.memoizedState!==null)&&(Mn=e)}function cu(e){R(qt,qt.current),R(vn,e),Mn===null&&(Mn=e)}function Mh(e){e.tag===22?(R(qt,qt.current),R(vn,e),Mn===null&&(Mn=e)):zi()}function zi(){R(qt,qt.current),R(vn,vn.current)}function xn(e){te(vn),Mn===e&&(Mn=null),te(qt)}var qt=O(0);function es(e){for(var n=e;n!==null;){if(n.tag===13){var r=n.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||gc(r)||yc(r)))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 si=0,$e=null,St=null,Gt=null,ts=!1,Fr=!1,ur=!1,ns=0,Ll=0,$r=null,Vx=0;function Ut(){throw Error(a(321))}function fu(e,n){if(n===null)return!1;for(var r=0;r<n.length&&r<e.length;r++)if(!yn(e[r],n[r]))return!1;return!0}function du(e,n,r,s,d,g){return si=g,$e=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,I.H=e===null||e.memoizedState===null?yp:Nu,ur=!1,g=r(s,d),ur=!1,Fr&&(g=Lh(n,r,s,d)),Oh(e),g}function Oh(e){I.H=Il;var n=St!==null&&St.next!==null;if(si=0,Gt=St=$e=null,ts=!1,Ll=0,$r=null,n)throw Error(a(300));e===null||Ft||(e=e.dependencies,e!==null&&$a(e)&&(Ft=!0))}function Lh(e,n,r,s){$e=e;var d=0;do{if(Fr&&($r=null),Ll=0,Fr=!1,25<=d)throw Error(a(301));if(d+=1,Gt=St=null,e.updateQueue!=null){var g=e.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}I.H=bp,g=n(r,s)}while(Fr);return g}function Yx(){var e=I.H,n=e.useState()[0];return n=typeof n.then=="function"?Bl(n):n,e=e.useState()[0],(St!==null?St.memoizedState:null)!==e&&($e.flags|=1024),n}function hu(){var e=ns!==0;return ns=0,e}function pu(e,n,r){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~r}function mu(e){if(ts){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}ts=!1}si=0,Gt=St=$e=null,Fr=!1,Ll=ns=0,$r=null}function sn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Gt===null?$e.memoizedState=Gt=e:Gt=Gt.next=e,Gt}function Ht(){if(St===null){var e=$e.alternate;e=e!==null?e.memoizedState:null}else e=St.next;var n=Gt===null?$e.memoizedState:Gt.next;if(n!==null)Gt=n,St=e;else{if(e===null)throw $e.alternate===null?Error(a(467)):Error(a(310));St=e,e={memoizedState:St.memoizedState,baseState:St.baseState,baseQueue:St.baseQueue,queue:St.queue,next:null},Gt===null?$e.memoizedState=Gt=e:Gt=Gt.next=e}return Gt}function is(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Bl(e){var n=Ll;return Ll+=1,$r===null&&($r=[]),e=Eh($r,e,n),n=$e,(Gt===null?n.memoizedState:Gt.next)===null&&(n=n.alternate,I.H=n===null||n.memoizedState===null?yp:Nu),e}function rs(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return Bl(e);if(e.$$typeof===M)return en(e)}throw Error(a(438,String(e)))}function gu(e){var n=null,r=$e.updateQueue;if(r!==null&&(n=r.memoCache),n==null){var s=$e.alternate;s!==null&&(s=s.updateQueue,s!==null&&(s=s.memoCache,s!=null&&(n={data:s.data.map(function(d){return d.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),r===null&&(r=is(),$e.updateQueue=r),r.memoCache=n,r=n.data[n.index],r===void 0)for(r=n.data[n.index]=Array(e),s=0;s<e;s++)r[s]=C;return n.index++,r}function oi(e,n){return typeof n=="function"?n(e):n}function ls(e){var n=Ht();return yu(n,St,e)}function yu(e,n,r){var s=e.queue;if(s===null)throw Error(a(311));s.lastRenderedReducer=r;var d=e.baseQueue,g=s.pending;if(g!==null){if(d!==null){var S=d.next;d.next=g.next,g.next=S}n.baseQueue=d=g,s.pending=null}if(g=e.baseState,d===null)e.memoizedState=g;else{n=d.next;var E=S=null,V=null,re=n,de=!1;do{var me=re.lane&-536870913;if(me!==re.lane?(nt&me)===me:(si&me)===me){var se=re.revertLane;if(se===0)V!==null&&(V=V.next={lane:0,revertLane:0,gesture:null,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null}),me===qr&&(de=!0);else if((si&se)===se){re=re.next,se===qr&&(de=!0);continue}else me={lane:0,revertLane:re.revertLane,gesture:null,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null},V===null?(E=V=me,S=g):V=V.next=me,$e.lanes|=se,Mi|=se;me=re.action,ur&&r(g,me),g=re.hasEagerState?re.eagerState:r(g,me)}else se={lane:me,revertLane:re.revertLane,gesture:re.gesture,action:re.action,hasEagerState:re.hasEagerState,eagerState:re.eagerState,next:null},V===null?(E=V=se,S=g):V=V.next=se,$e.lanes|=me,Mi|=me;re=re.next}while(re!==null&&re!==n);if(V===null?S=g:V.next=E,!yn(g,e.memoizedState)&&(Ft=!0,de&&(r=Hr,r!==null)))throw r;e.memoizedState=g,e.baseState=S,e.baseQueue=V,s.lastRenderedState=g}return d===null&&(s.lanes=0),[e.memoizedState,s.dispatch]}function bu(e){var n=Ht(),r=n.queue;if(r===null)throw Error(a(311));r.lastRenderedReducer=e;var s=r.dispatch,d=r.pending,g=n.memoizedState;if(d!==null){r.pending=null;var S=d=d.next;do g=e(g,S.action),S=S.next;while(S!==d);yn(g,n.memoizedState)||(Ft=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),r.lastRenderedState=g}return[g,s]}function Bh(e,n,r){var s=$e,d=Ht(),g=rt;if(g){if(r===void 0)throw Error(a(407));r=r()}else r=n();var S=!yn((St||d).memoizedState,r);if(S&&(d.memoizedState=r,Ft=!0),d=d.queue,Su(qh.bind(null,s,d,e),[e]),d.getSnapshot!==n||S||Gt!==null&&Gt.memoizedState.tag&1){if(s.flags|=2048,Qr(9,{destroy:void 0},Ih.bind(null,s,d,r,n),null),Ct===null)throw Error(a(349));g||(si&127)!==0||Uh(s,n,r)}return r}function Uh(e,n,r){e.flags|=16384,e={getSnapshot:n,value:r},n=$e.updateQueue,n===null?(n=is(),$e.updateQueue=n,n.stores=[e]):(r=n.stores,r===null?n.stores=[e]:r.push(e))}function Ih(e,n,r,s){n.value=r,n.getSnapshot=s,Hh(n)&&Vh(e)}function qh(e,n,r){return r(function(){Hh(n)&&Vh(e)})}function Hh(e){var n=e.getSnapshot;e=e.value;try{var r=n();return!yn(e,r)}catch{return!0}}function Vh(e){var n=er(e,2);n!==null&&pn(n,e,2)}function vu(e){var n=sn();if(typeof e=="function"){var r=e;if(e=r(),ur){dt(!0);try{r()}finally{dt(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:oi,lastRenderedState:e},n}function Yh(e,n,r,s){return e.baseState=r,yu(e,St,typeof s=="function"?s:oi)}function Gx(e,n,r,s,d){if(os(e))throw Error(a(485));if(e=n.action,e!==null){var g={payload:d,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(S){g.listeners.push(S)}};I.T!==null?r(!0):g.isTransition=!1,s(g),r=n.pending,r===null?(g.next=n.pending=g,Gh(n,g)):(g.next=r.next,n.pending=r.next=g)}}function Gh(e,n){var r=n.action,s=n.payload,d=e.state;if(n.isTransition){var g=I.T,S={};I.T=S;try{var E=r(d,s),V=I.S;V!==null&&V(S,E),Fh(e,n,E)}catch(re){xu(e,n,re)}finally{g!==null&&S.types!==null&&(g.types=S.types),I.T=g}}else try{g=r(d,s),Fh(e,n,g)}catch(re){xu(e,n,re)}}function Fh(e,n,r){r!==null&&typeof r=="object"&&typeof r.then=="function"?r.then(function(s){$h(e,n,s)},function(s){return xu(e,n,s)}):$h(e,n,r)}function $h(e,n,r){n.status="fulfilled",n.value=r,Qh(n),e.state=r,n=e.pending,n!==null&&(r=n.next,r===n?e.pending=null:(r=r.next,n.next=r,Gh(e,r)))}function xu(e,n,r){var s=e.pending;if(e.pending=null,s!==null){s=s.next;do n.status="rejected",n.reason=r,Qh(n),n=n.next;while(n!==s)}e.action=null}function Qh(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function Xh(e,n){return n}function Kh(e,n){if(rt){var r=Ct.formState;if(r!==null){e:{var s=$e;if(rt){if(Rt){t:{for(var d=Rt,g=_n;d.nodeType!==8;){if(!g){d=null;break t}if(d=On(d.nextSibling),d===null){d=null;break t}}g=d.data,d=g==="F!"||g==="F"?d:null}if(d){Rt=On(d.nextSibling),s=d.data==="F!";break e}}Ci(s)}s=!1}s&&(n=r[0])}}return r=sn(),r.memoizedState=r.baseState=n,s={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Xh,lastRenderedState:n},r.queue=s,r=pp.bind(null,$e,s),s.dispatch=r,s=vu(!1),g=Eu.bind(null,$e,!1,s.queue),s=sn(),d={state:n,dispatch:null,action:e,pending:null},s.queue=d,r=Gx.bind(null,$e,d,g,r),d.dispatch=r,s.memoizedState=e,[n,r,!1]}function Ph(e){var n=Ht();return Zh(n,St,e)}function Zh(e,n,r){if(n=yu(e,n,Xh)[0],e=ls(oi)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var s=Bl(n)}catch(S){throw S===Vr?Ka:S}else s=n;n=Ht();var d=n.queue,g=d.dispatch;return r!==n.memoizedState&&($e.flags|=2048,Qr(9,{destroy:void 0},Fx.bind(null,d,r),null)),[s,g,e]}function Fx(e,n){e.action=n}function Jh(e){var n=Ht(),r=St;if(r!==null)return Zh(n,r,e);Ht(),n=n.memoizedState,r=Ht();var s=r.queue.dispatch;return r.memoizedState=e,[n,s,!1]}function Qr(e,n,r,s){return e={tag:e,create:r,deps:s,inst:n,next:null},n=$e.updateQueue,n===null&&(n=is(),$e.updateQueue=n),r=n.lastEffect,r===null?n.lastEffect=e.next=e:(s=r.next,r.next=e,e.next=s,n.lastEffect=e),e}function Wh(){return Ht().memoizedState}function as(e,n,r,s){var d=sn();$e.flags|=e,d.memoizedState=Qr(1|n,{destroy:void 0},r,s===void 0?null:s)}function ss(e,n,r,s){var d=Ht();s=s===void 0?null:s;var g=d.memoizedState.inst;St!==null&&s!==null&&fu(s,St.memoizedState.deps)?d.memoizedState=Qr(n,g,r,s):($e.flags|=e,d.memoizedState=Qr(1|n,g,r,s))}function ep(e,n){as(8390656,8,e,n)}function Su(e,n){ss(2048,8,e,n)}function $x(e){$e.flags|=4;var n=$e.updateQueue;if(n===null)n=is(),$e.updateQueue=n,n.events=[e];else{var r=n.events;r===null?n.events=[e]:r.push(e)}}function tp(e){var n=Ht().memoizedState;return $x({ref:n,nextImpl:e}),function(){if((ht&2)!==0)throw Error(a(440));return n.impl.apply(void 0,arguments)}}function np(e,n){return ss(4,2,e,n)}function ip(e,n){return ss(4,4,e,n)}function rp(e,n){if(typeof n=="function"){e=e();var r=n(e);return function(){typeof r=="function"?r():n(null)}}if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function lp(e,n,r){r=r!=null?r.concat([e]):null,ss(4,4,rp.bind(null,n,e),r)}function wu(){}function ap(e,n){var r=Ht();n=n===void 0?null:n;var s=r.memoizedState;return n!==null&&fu(n,s[1])?s[0]:(r.memoizedState=[e,n],e)}function sp(e,n){var r=Ht();n=n===void 0?null:n;var s=r.memoizedState;if(n!==null&&fu(n,s[1]))return s[0];if(s=e(),ur){dt(!0);try{e()}finally{dt(!1)}}return r.memoizedState=[s,n],s}function ju(e,n,r){return r===void 0||(si&1073741824)!==0&&(nt&261930)===0?e.memoizedState=n:(e.memoizedState=r,e=om(),$e.lanes|=e,Mi|=e,r)}function op(e,n,r,s){return yn(r,n)?r:Gr.current!==null?(e=ju(e,r,s),yn(e,n)||(Ft=!0),e):(si&42)===0||(si&1073741824)!==0&&(nt&261930)===0?(Ft=!0,e.memoizedState=r):(e=om(),$e.lanes|=e,Mi|=e,n)}function up(e,n,r,s,d){var g=Y.p;Y.p=g!==0&&8>g?g:8;var S=I.T,E={};I.T=E,Eu(e,!1,n,r);try{var V=d(),re=I.S;if(re!==null&&re(E,V),V!==null&&typeof V=="object"&&typeof V.then=="function"){var de=Hx(V,s);Ul(e,n,de,jn(e))}else Ul(e,n,s,jn(e))}catch(me){Ul(e,n,{then:function(){},status:"rejected",reason:me},jn())}finally{Y.p=g,S!==null&&E.types!==null&&(S.types=E.types),I.T=S}}function Qx(){}function ku(e,n,r,s){if(e.tag!==5)throw Error(a(476));var d=cp(e).queue;up(e,d,n,X,r===null?Qx:function(){return fp(e),r(s)})}function cp(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:X,baseState:X,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:oi,lastRenderedState:X},next:null};var r={};return n.next={memoizedState:r,baseState:r,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:oi,lastRenderedState:r},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function fp(e){var n=cp(e);n.next===null&&(n=e.alternate.memoizedState),Ul(e,n.next.queue,{},jn())}function Cu(){return en(ta)}function dp(){return Ht().memoizedState}function hp(){return Ht().memoizedState}function Xx(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var r=jn();e=Ai(r);var s=Ti(n,e,r);s!==null&&(pn(s,n,r),_l(s,n,r)),n={cache:eu()},e.payload=n;return}n=n.return}}function Kx(e,n,r){var s=jn();r={lane:s,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},os(e)?mp(n,r):(r=Yo(e,n,r,s),r!==null&&(pn(r,e,s),gp(r,n,s)))}function pp(e,n,r){var s=jn();Ul(e,n,r,s)}function Ul(e,n,r,s){var d={lane:s,revertLane:0,gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null};if(os(e))mp(n,d);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var S=n.lastRenderedState,E=g(S,r);if(d.hasEagerState=!0,d.eagerState=E,yn(E,S))return Va(e,n,d,0),Ct===null&&Ha(),!1}catch{}if(r=Yo(e,n,d,s),r!==null)return pn(r,e,s),gp(r,n,s),!0}return!1}function Eu(e,n,r,s){if(s={lane:2,revertLane:rc(),gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},os(e)){if(n)throw Error(a(479))}else n=Yo(e,r,s,2),n!==null&&pn(n,e,2)}function os(e){var n=e.alternate;return e===$e||n!==null&&n===$e}function mp(e,n){Fr=ts=!0;var r=e.pending;r===null?n.next=n:(n.next=r.next,r.next=n),e.pending=n}function gp(e,n,r){if((r&4194048)!==0){var s=n.lanes;s&=e.pendingLanes,r|=s,n.lanes=r,kt(e,r)}}var Il={readContext:en,use:rs,useCallback:Ut,useContext:Ut,useEffect:Ut,useImperativeHandle:Ut,useLayoutEffect:Ut,useInsertionEffect:Ut,useMemo:Ut,useReducer:Ut,useRef:Ut,useState:Ut,useDebugValue:Ut,useDeferredValue:Ut,useTransition:Ut,useSyncExternalStore:Ut,useId:Ut,useHostTransitionStatus:Ut,useFormState:Ut,useActionState:Ut,useOptimistic:Ut,useMemoCache:Ut,useCacheRefresh:Ut};Il.useEffectEvent=Ut;var yp={readContext:en,use:rs,useCallback:function(e,n){return sn().memoizedState=[e,n===void 0?null:n],e},useContext:en,useEffect:ep,useImperativeHandle:function(e,n,r){r=r!=null?r.concat([e]):null,as(4194308,4,rp.bind(null,n,e),r)},useLayoutEffect:function(e,n){return as(4194308,4,e,n)},useInsertionEffect:function(e,n){as(4,2,e,n)},useMemo:function(e,n){var r=sn();n=n===void 0?null:n;var s=e();if(ur){dt(!0);try{e()}finally{dt(!1)}}return r.memoizedState=[s,n],s},useReducer:function(e,n,r){var s=sn();if(r!==void 0){var d=r(n);if(ur){dt(!0);try{r(n)}finally{dt(!1)}}}else d=n;return s.memoizedState=s.baseState=d,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:d},s.queue=e,e=e.dispatch=Kx.bind(null,$e,e),[s.memoizedState,e]},useRef:function(e){var n=sn();return e={current:e},n.memoizedState=e},useState:function(e){e=vu(e);var n=e.queue,r=pp.bind(null,$e,n);return n.dispatch=r,[e.memoizedState,r]},useDebugValue:wu,useDeferredValue:function(e,n){var r=sn();return ju(r,e,n)},useTransition:function(){var e=vu(!1);return e=up.bind(null,$e,e.queue,!0,!1),sn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,r){var s=$e,d=sn();if(rt){if(r===void 0)throw Error(a(407));r=r()}else{if(r=n(),Ct===null)throw Error(a(349));(nt&127)!==0||Uh(s,n,r)}d.memoizedState=r;var g={value:r,getSnapshot:n};return d.queue=g,ep(qh.bind(null,s,g,e),[e]),s.flags|=2048,Qr(9,{destroy:void 0},Ih.bind(null,s,g,r,n),null),r},useId:function(){var e=sn(),n=Ct.identifierPrefix;if(rt){var r=Qn,s=$n;r=(s&~(1<<32-tt(s)-1)).toString(32)+r,n="_"+n+"R_"+r,r=ns++,0<r&&(n+="H"+r.toString(32)),n+="_"}else r=Vx++,n="_"+n+"r_"+r.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:Cu,useFormState:Kh,useActionState:Kh,useOptimistic:function(e){var n=sn();n.memoizedState=n.baseState=e;var r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=r,n=Eu.bind(null,$e,!0,r),r.dispatch=n,[e,n]},useMemoCache:gu,useCacheRefresh:function(){return sn().memoizedState=Xx.bind(null,$e)},useEffectEvent:function(e){var n=sn(),r={impl:e};return n.memoizedState=r,function(){if((ht&2)!==0)throw Error(a(440));return r.impl.apply(void 0,arguments)}}},Nu={readContext:en,use:rs,useCallback:ap,useContext:en,useEffect:Su,useImperativeHandle:lp,useInsertionEffect:np,useLayoutEffect:ip,useMemo:sp,useReducer:ls,useRef:Wh,useState:function(){return ls(oi)},useDebugValue:wu,useDeferredValue:function(e,n){var r=Ht();return op(r,St.memoizedState,e,n)},useTransition:function(){var e=ls(oi)[0],n=Ht().memoizedState;return[typeof e=="boolean"?e:Bl(e),n]},useSyncExternalStore:Bh,useId:dp,useHostTransitionStatus:Cu,useFormState:Ph,useActionState:Ph,useOptimistic:function(e,n){var r=Ht();return Yh(r,St,e,n)},useMemoCache:gu,useCacheRefresh:hp};Nu.useEffectEvent=tp;var bp={readContext:en,use:rs,useCallback:ap,useContext:en,useEffect:Su,useImperativeHandle:lp,useInsertionEffect:np,useLayoutEffect:ip,useMemo:sp,useReducer:bu,useRef:Wh,useState:function(){return bu(oi)},useDebugValue:wu,useDeferredValue:function(e,n){var r=Ht();return St===null?ju(r,e,n):op(r,St.memoizedState,e,n)},useTransition:function(){var e=bu(oi)[0],n=Ht().memoizedState;return[typeof e=="boolean"?e:Bl(e),n]},useSyncExternalStore:Bh,useId:dp,useHostTransitionStatus:Cu,useFormState:Jh,useActionState:Jh,useOptimistic:function(e,n){var r=Ht();return St!==null?Yh(r,St,e,n):(r.baseState=e,[e,r.queue.dispatch])},useMemoCache:gu,useCacheRefresh:hp};bp.useEffectEvent=tp;function Au(e,n,r,s){n=e.memoizedState,r=r(s,n),r=r==null?n:b({},n,r),e.memoizedState=r,e.lanes===0&&(e.updateQueue.baseState=r)}var Tu={enqueueSetState:function(e,n,r){e=e._reactInternals;var s=jn(),d=Ai(s);d.payload=n,r!=null&&(d.callback=r),n=Ti(e,d,s),n!==null&&(pn(n,e,s),_l(n,e,s))},enqueueReplaceState:function(e,n,r){e=e._reactInternals;var s=jn(),d=Ai(s);d.tag=1,d.payload=n,r!=null&&(d.callback=r),n=Ti(e,d,s),n!==null&&(pn(n,e,s),_l(n,e,s))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var r=jn(),s=Ai(r);s.tag=2,n!=null&&(s.callback=n),n=Ti(e,s,r),n!==null&&(pn(n,e,r),_l(n,e,r))}};function vp(e,n,r,s,d,g,S){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(s,g,S):n.prototype&&n.prototype.isPureReactComponent?!Cl(r,s)||!Cl(d,g):!0}function xp(e,n,r,s){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(r,s),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(r,s),n.state!==e&&Tu.enqueueReplaceState(n,n.state,null)}function cr(e,n){var r=n;if("ref"in n){r={};for(var s in n)s!=="ref"&&(r[s]=n[s])}if(e=e.defaultProps){r===n&&(r=b({},r));for(var d in e)r[d]===void 0&&(r[d]=e[d])}return r}function Sp(e){qa(e)}function wp(e){console.error(e)}function jp(e){qa(e)}function us(e,n){try{var r=e.onUncaughtError;r(n.value,{componentStack:n.stack})}catch(s){setTimeout(function(){throw s})}}function kp(e,n,r){try{var s=e.onCaughtError;s(r.value,{componentStack:r.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(d){setTimeout(function(){throw d})}}function Ru(e,n,r){return r=Ai(r),r.tag=3,r.payload={element:null},r.callback=function(){us(e,n)},r}function Cp(e){return e=Ai(e),e.tag=3,e}function Ep(e,n,r,s){var d=r.type.getDerivedStateFromError;if(typeof d=="function"){var g=s.value;e.payload=function(){return d(g)},e.callback=function(){kp(n,r,s)}}var S=r.stateNode;S!==null&&typeof S.componentDidCatch=="function"&&(e.callback=function(){kp(n,r,s),typeof d!="function"&&(Oi===null?Oi=new Set([this]):Oi.add(this));var E=s.stack;this.componentDidCatch(s.value,{componentStack:E!==null?E:""})})}function Px(e,n,r,s,d){if(r.flags|=32768,s!==null&&typeof s=="object"&&typeof s.then=="function"){if(n=r.alternate,n!==null&&Ir(n,r,d,!0),r=vn.current,r!==null){switch(r.tag){case 31:case 13:return Mn===null?Ss():r.alternate===null&&It===0&&(It=3),r.flags&=-257,r.flags|=65536,r.lanes=d,s===Pa?r.flags|=16384:(n=r.updateQueue,n===null?r.updateQueue=new Set([s]):n.add(s),tc(e,s,d)),!1;case 22:return r.flags|=65536,s===Pa?r.flags|=16384:(n=r.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([s])},r.updateQueue=n):(r=n.retryQueue,r===null?n.retryQueue=new Set([s]):r.add(s)),tc(e,s,d)),!1}throw Error(a(435,r.tag))}return tc(e,s,d),Ss(),!1}if(rt)return n=vn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=d,s!==Ko&&(e=Error(a(422),{cause:s}),Al(Rn(e,r)))):(s!==Ko&&(n=Error(a(423),{cause:s}),Al(Rn(n,r))),e=e.current.alternate,e.flags|=65536,d&=-d,e.lanes|=d,s=Rn(s,r),d=Ru(e.stateNode,s,d),au(e,d),It!==4&&(It=2)),!1;var g=Error(a(520),{cause:s});if(g=Rn(g,r),Ql===null?Ql=[g]:Ql.push(g),It!==4&&(It=2),n===null)return!0;s=Rn(s,r),r=n;do{switch(r.tag){case 3:return r.flags|=65536,e=d&-d,r.lanes|=e,e=Ru(r.stateNode,s,e),au(r,e),!1;case 1:if(n=r.type,g=r.stateNode,(r.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(Oi===null||!Oi.has(g))))return r.flags|=65536,d&=-d,r.lanes|=d,d=Cp(d),Ep(d,e,r,s),au(r,d),!1}r=r.return}while(r!==null);return!1}var zu=Error(a(461)),Ft=!1;function tn(e,n,r,s){n.child=e===null?Rh(n,null,r,s):or(n,e.child,r,s)}function Np(e,n,r,s,d){r=r.render;var g=n.ref;if("ref"in s){var S={};for(var E in s)E!=="ref"&&(S[E]=s[E])}else S=s;return rr(n),s=du(e,n,r,S,g,d),E=hu(),e!==null&&!Ft?(pu(e,n,d),ui(e,n,d)):(rt&&E&&Qo(n),n.flags|=1,tn(e,n,s,d),n.child)}function Ap(e,n,r,s,d){if(e===null){var g=r.type;return typeof g=="function"&&!Go(g)&&g.defaultProps===void 0&&r.compare===null?(n.tag=15,n.type=g,Tp(e,n,g,s,d)):(e=Ga(r.type,null,s,n,n.mode,d),e.ref=n.ref,e.return=n,n.child=e)}if(g=e.child,!Iu(e,d)){var S=g.memoizedProps;if(r=r.compare,r=r!==null?r:Cl,r(S,s)&&e.ref===n.ref)return ui(e,n,d)}return n.flags|=1,e=ii(g,s),e.ref=n.ref,e.return=n,n.child=e}function Tp(e,n,r,s,d){if(e!==null){var g=e.memoizedProps;if(Cl(g,s)&&e.ref===n.ref)if(Ft=!1,n.pendingProps=s=g,Iu(e,d))(e.flags&131072)!==0&&(Ft=!0);else return n.lanes=e.lanes,ui(e,n,d)}return Du(e,n,r,s,d)}function Rp(e,n,r,s){var d=s.children,g=e!==null?e.memoizedState:null;if(e===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),s.mode==="hidden"){if((n.flags&128)!==0){if(g=g!==null?g.baseLanes|r:r,e!==null){for(s=n.child=e.child,d=0;s!==null;)d=d|s.lanes|s.childLanes,s=s.sibling;s=d&~g}else s=0,n.child=null;return zp(e,n,g,r,s)}if((r&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&Xa(n,g!==null?g.cachePool:null),g!==null?_h(n,g):ou(),Mh(n);else return s=n.lanes=536870912,zp(e,n,g!==null?g.baseLanes|r:r,r,s)}else g!==null?(Xa(n,g.cachePool),_h(n,g),zi(),n.memoizedState=null):(e!==null&&Xa(n,null),ou(),zi());return tn(e,n,d,r),n.child}function ql(e,n){return e!==null&&e.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function zp(e,n,r,s,d){var g=nu();return g=g===null?null:{parent:Yt._currentValue,pool:g},n.memoizedState={baseLanes:r,cachePool:g},e!==null&&Xa(n,null),ou(),Mh(n),e!==null&&Ir(e,n,s,!0),n.childLanes=d,null}function cs(e,n){return n=ds({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function Dp(e,n,r){return or(n,e.child,null,r),e=cs(n,n.pendingProps),e.flags|=2,xn(n),n.memoizedState=null,e}function Zx(e,n,r){var s=n.pendingProps,d=(n.flags&128)!==0;if(n.flags&=-129,e===null){if(rt){if(s.mode==="hidden")return e=cs(n,s),n.lanes=536870912,ql(null,e);if(cu(n),(e=Rt)?(e=Gm(e,_n),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:ji!==null?{id:$n,overflow:Qn}:null,retryLane:536870912,hydrationErrors:null},r=mh(e),r.return=n,n.child=r,Wt=n,Rt=null)):e=null,e===null)throw Ci(n);return n.lanes=536870912,null}return cs(n,s)}var g=e.memoizedState;if(g!==null){var S=g.dehydrated;if(cu(n),d)if(n.flags&256)n.flags&=-257,n=Dp(e,n,r);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(a(558));else if(Ft||Ir(e,n,r,!1),d=(r&e.childLanes)!==0,Ft||d){if(s=Ct,s!==null&&(S=Wn(s,r),S!==0&&S!==g.retryLane))throw g.retryLane=S,er(e,S),pn(s,e,S),zu;Ss(),n=Dp(e,n,r)}else e=g.treeContext,Rt=On(S.nextSibling),Wt=n,rt=!0,ki=null,_n=!1,e!==null&&bh(n,e),n=cs(n,s),n.flags|=4096;return n}return e=ii(e.child,{mode:s.mode,children:s.children}),e.ref=n.ref,n.child=e,e.return=n,e}function fs(e,n){var r=n.ref;if(r===null)e!==null&&e.ref!==null&&(n.flags|=4194816);else{if(typeof r!="function"&&typeof r!="object")throw Error(a(284));(e===null||e.ref!==r)&&(n.flags|=4194816)}}function Du(e,n,r,s,d){return rr(n),r=du(e,n,r,s,void 0,d),s=hu(),e!==null&&!Ft?(pu(e,n,d),ui(e,n,d)):(rt&&s&&Qo(n),n.flags|=1,tn(e,n,r,d),n.child)}function _p(e,n,r,s,d,g){return rr(n),n.updateQueue=null,r=Lh(n,s,r,d),Oh(e),s=hu(),e!==null&&!Ft?(pu(e,n,g),ui(e,n,g)):(rt&&s&&Qo(n),n.flags|=1,tn(e,n,r,g),n.child)}function Mp(e,n,r,s,d){if(rr(n),n.stateNode===null){var g=Or,S=r.contextType;typeof S=="object"&&S!==null&&(g=en(S)),g=new r(s,g),n.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=Tu,n.stateNode=g,g._reactInternals=n,g=n.stateNode,g.props=s,g.state=n.memoizedState,g.refs={},ru(n),S=r.contextType,g.context=typeof S=="object"&&S!==null?en(S):Or,g.state=n.memoizedState,S=r.getDerivedStateFromProps,typeof S=="function"&&(Au(n,r,S,s),g.state=n.memoizedState),typeof r.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&&Tu.enqueueReplaceState(g,g.state,null),Ol(n,s,g,d),Ml(),g.state=n.memoizedState),typeof g.componentDidMount=="function"&&(n.flags|=4194308),s=!0}else if(e===null){g=n.stateNode;var E=n.memoizedProps,V=cr(r,E);g.props=V;var re=g.context,de=r.contextType;S=Or,typeof de=="object"&&de!==null&&(S=en(de));var me=r.getDerivedStateFromProps;de=typeof me=="function"||typeof g.getSnapshotBeforeUpdate=="function",E=n.pendingProps!==E,de||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(E||re!==S)&&xp(n,g,s,S),Ni=!1;var se=n.memoizedState;g.state=se,Ol(n,s,g,d),Ml(),re=n.memoizedState,E||se!==re||Ni?(typeof me=="function"&&(Au(n,r,me,s),re=n.memoizedState),(V=Ni||vp(n,r,V,s,se,re,S))?(de||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=s,n.memoizedState=re),g.props=s,g.state=re,g.context=S,s=V):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),s=!1)}else{g=n.stateNode,lu(e,n),S=n.memoizedProps,de=cr(r,S),g.props=de,me=n.pendingProps,se=g.context,re=r.contextType,V=Or,typeof re=="object"&&re!==null&&(V=en(re)),E=r.getDerivedStateFromProps,(re=typeof E=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(S!==me||se!==V)&&xp(n,g,s,V),Ni=!1,se=n.memoizedState,g.state=se,Ol(n,s,g,d),Ml();var ce=n.memoizedState;S!==me||se!==ce||Ni||e!==null&&e.dependencies!==null&&$a(e.dependencies)?(typeof E=="function"&&(Au(n,r,E,s),ce=n.memoizedState),(de=Ni||vp(n,r,de,s,se,ce,V)||e!==null&&e.dependencies!==null&&$a(e.dependencies))?(re||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(s,ce,V),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(s,ce,V)),typeof g.componentDidUpdate=="function"&&(n.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof g.componentDidUpdate!="function"||S===e.memoizedProps&&se===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&se===e.memoizedState||(n.flags|=1024),n.memoizedProps=s,n.memoizedState=ce),g.props=s,g.state=ce,g.context=V,s=de):(typeof g.componentDidUpdate!="function"||S===e.memoizedProps&&se===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||S===e.memoizedProps&&se===e.memoizedState||(n.flags|=1024),s=!1)}return g=s,fs(e,n),s=(n.flags&128)!==0,g||s?(g=n.stateNode,r=s&&typeof r.getDerivedStateFromError!="function"?null:g.render(),n.flags|=1,e!==null&&s?(n.child=or(n,e.child,null,d),n.child=or(n,null,r,d)):tn(e,n,r,d),n.memoizedState=g.state,e=n.child):e=ui(e,n,d),e}function Op(e,n,r,s){return nr(),n.flags|=256,tn(e,n,r,s),n.child}var _u={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Mu(e){return{baseLanes:e,cachePool:kh()}}function Ou(e,n,r){return e=e!==null?e.childLanes&~r:0,n&&(e|=wn),e}function Lp(e,n,r){var s=n.pendingProps,d=!1,g=(n.flags&128)!==0,S;if((S=g)||(S=e!==null&&e.memoizedState===null?!1:(qt.current&2)!==0),S&&(d=!0,n.flags&=-129),S=(n.flags&32)!==0,n.flags&=-33,e===null){if(rt){if(d?Ri(n):zi(),(e=Rt)?(e=Gm(e,_n),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:ji!==null?{id:$n,overflow:Qn}:null,retryLane:536870912,hydrationErrors:null},r=mh(e),r.return=n,n.child=r,Wt=n,Rt=null)):e=null,e===null)throw Ci(n);return yc(e)?n.lanes=32:n.lanes=536870912,null}var E=s.children;return s=s.fallback,d?(zi(),d=n.mode,E=ds({mode:"hidden",children:E},d),s=tr(s,d,r,null),E.return=n,s.return=n,E.sibling=s,n.child=E,s=n.child,s.memoizedState=Mu(r),s.childLanes=Ou(e,S,r),n.memoizedState=_u,ql(null,s)):(Ri(n),Lu(n,E))}var V=e.memoizedState;if(V!==null&&(E=V.dehydrated,E!==null)){if(g)n.flags&256?(Ri(n),n.flags&=-257,n=Bu(e,n,r)):n.memoizedState!==null?(zi(),n.child=e.child,n.flags|=128,n=null):(zi(),E=s.fallback,d=n.mode,s=ds({mode:"visible",children:s.children},d),E=tr(E,d,r,null),E.flags|=2,s.return=n,E.return=n,s.sibling=E,n.child=s,or(n,e.child,null,r),s=n.child,s.memoizedState=Mu(r),s.childLanes=Ou(e,S,r),n.memoizedState=_u,n=ql(null,s));else if(Ri(n),yc(E)){if(S=E.nextSibling&&E.nextSibling.dataset,S)var re=S.dgst;S=re,s=Error(a(419)),s.stack="",s.digest=S,Al({value:s,source:null,stack:null}),n=Bu(e,n,r)}else if(Ft||Ir(e,n,r,!1),S=(r&e.childLanes)!==0,Ft||S){if(S=Ct,S!==null&&(s=Wn(S,r),s!==0&&s!==V.retryLane))throw V.retryLane=s,er(e,s),pn(S,e,s),zu;gc(E)||Ss(),n=Bu(e,n,r)}else gc(E)?(n.flags|=192,n.child=e.child,n=null):(e=V.treeContext,Rt=On(E.nextSibling),Wt=n,rt=!0,ki=null,_n=!1,e!==null&&bh(n,e),n=Lu(n,s.children),n.flags|=4096);return n}return d?(zi(),E=s.fallback,d=n.mode,V=e.child,re=V.sibling,s=ii(V,{mode:"hidden",children:s.children}),s.subtreeFlags=V.subtreeFlags&65011712,re!==null?E=ii(re,E):(E=tr(E,d,r,null),E.flags|=2),E.return=n,s.return=n,s.sibling=E,n.child=s,ql(null,s),s=n.child,E=e.child.memoizedState,E===null?E=Mu(r):(d=E.cachePool,d!==null?(V=Yt._currentValue,d=d.parent!==V?{parent:V,pool:V}:d):d=kh(),E={baseLanes:E.baseLanes|r,cachePool:d}),s.memoizedState=E,s.childLanes=Ou(e,S,r),n.memoizedState=_u,ql(e.child,s)):(Ri(n),r=e.child,e=r.sibling,r=ii(r,{mode:"visible",children:s.children}),r.return=n,r.sibling=null,e!==null&&(S=n.deletions,S===null?(n.deletions=[e],n.flags|=16):S.push(e)),n.child=r,n.memoizedState=null,r)}function Lu(e,n){return n=ds({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function ds(e,n){return e=bn(22,e,null,n),e.lanes=0,e}function Bu(e,n,r){return or(n,e.child,null,r),e=Lu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Bp(e,n,r){e.lanes|=n;var s=e.alternate;s!==null&&(s.lanes|=n),Jo(e.return,n,r)}function Uu(e,n,r,s,d,g){var S=e.memoizedState;S===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:s,tail:r,tailMode:d,treeForkCount:g}:(S.isBackwards=n,S.rendering=null,S.renderingStartTime=0,S.last=s,S.tail=r,S.tailMode=d,S.treeForkCount=g)}function Up(e,n,r){var s=n.pendingProps,d=s.revealOrder,g=s.tail;s=s.children;var S=qt.current,E=(S&2)!==0;if(E?(S=S&1|2,n.flags|=128):S&=1,R(qt,S),tn(e,n,s,r),s=rt?Nl:0,!E&&e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Bp(e,r,n);else if(e.tag===19)Bp(e,r,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(d){case"forwards":for(r=n.child,d=null;r!==null;)e=r.alternate,e!==null&&es(e)===null&&(d=r),r=r.sibling;r=d,r===null?(d=n.child,n.child=null):(d=r.sibling,r.sibling=null),Uu(n,!1,d,r,g,s);break;case"backwards":case"unstable_legacy-backwards":for(r=null,d=n.child,n.child=null;d!==null;){if(e=d.alternate,e!==null&&es(e)===null){n.child=d;break}e=d.sibling,d.sibling=r,r=d,d=e}Uu(n,!0,r,null,g,s);break;case"together":Uu(n,!1,null,null,void 0,s);break;default:n.memoizedState=null}return n.child}function ui(e,n,r){if(e!==null&&(n.dependencies=e.dependencies),Mi|=n.lanes,(r&n.childLanes)===0)if(e!==null){if(Ir(e,n,r,!1),(r&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(a(153));if(n.child!==null){for(e=n.child,r=ii(e,e.pendingProps),n.child=r,r.return=n;e.sibling!==null;)e=e.sibling,r=r.sibling=ii(e,e.pendingProps),r.return=n;r.sibling=null}return n.child}function Iu(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&$a(e)))}function Jx(e,n,r){switch(n.tag){case 3:xe(n,n.stateNode.containerInfo),Ei(n,Yt,e.memoizedState.cache),nr();break;case 27:case 5:ke(n);break;case 4:xe(n,n.stateNode.containerInfo);break;case 10:Ei(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,cu(n),null;break;case 13:var s=n.memoizedState;if(s!==null)return s.dehydrated!==null?(Ri(n),n.flags|=128,null):(r&n.child.childLanes)!==0?Lp(e,n,r):(Ri(n),e=ui(e,n,r),e!==null?e.sibling:null);Ri(n);break;case 19:var d=(e.flags&128)!==0;if(s=(r&n.childLanes)!==0,s||(Ir(e,n,r,!1),s=(r&n.childLanes)!==0),d){if(s)return Up(e,n,r);n.flags|=128}if(d=n.memoizedState,d!==null&&(d.rendering=null,d.tail=null,d.lastEffect=null),R(qt,qt.current),s)break;return null;case 22:return n.lanes=0,Rp(e,n,r,n.pendingProps);case 24:Ei(n,Yt,e.memoizedState.cache)}return ui(e,n,r)}function Ip(e,n,r){if(e!==null)if(e.memoizedProps!==n.pendingProps)Ft=!0;else{if(!Iu(e,r)&&(n.flags&128)===0)return Ft=!1,Jx(e,n,r);Ft=(e.flags&131072)!==0}else Ft=!1,rt&&(n.flags&1048576)!==0&&yh(n,Nl,n.index);switch(n.lanes=0,n.tag){case 16:e:{var s=n.pendingProps;if(e=ar(n.elementType),n.type=e,typeof e=="function")Go(e)?(s=cr(e,s),n.tag=1,n=Mp(null,n,e,s,r)):(n.tag=0,n=Du(null,n,e,s,r));else{if(e!=null){var d=e.$$typeof;if(d===G){n.tag=11,n=Np(null,n,e,s,r);break e}else if(d===H){n.tag=14,n=Ap(null,n,e,s,r);break e}}throw n=J(e)||e,Error(a(306,n,""))}}return n;case 0:return Du(e,n,n.type,n.pendingProps,r);case 1:return s=n.type,d=cr(s,n.pendingProps),Mp(e,n,s,d,r);case 3:e:{if(xe(n,n.stateNode.containerInfo),e===null)throw Error(a(387));s=n.pendingProps;var g=n.memoizedState;d=g.element,lu(e,n),Ol(n,s,null,r);var S=n.memoizedState;if(s=S.cache,Ei(n,Yt,s),s!==g.cache&&Wo(n,[Yt],r,!0),Ml(),s=S.element,g.isDehydrated)if(g={element:s,isDehydrated:!1,cache:S.cache},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){n=Op(e,n,s,r);break e}else if(s!==d){d=Rn(Error(a(424)),n),Al(d),n=Op(e,n,s,r);break e}else for(e=n.stateNode.containerInfo,e.nodeType===9?e=e.body:e=e.nodeName==="HTML"?e.ownerDocument.body:e,Rt=On(e.firstChild),Wt=n,rt=!0,ki=null,_n=!0,r=Rh(n,null,s,r),n.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(nr(),s===d){n=ui(e,n,r);break e}tn(e,n,s,r)}n=n.child}return n;case 26:return fs(e,n),e===null?(r=Pm(n.type,null,n.pendingProps,null))?n.memoizedState=r:rt||(r=n.type,e=n.pendingProps,s=As(le.current).createElement(r),s[Bt]=n,s[Jt]=e,nn(s,r,e),Kt(s),n.stateNode=s):n.memoizedState=Pm(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return ke(n),e===null&&rt&&(s=n.stateNode=Qm(n.type,n.pendingProps,le.current),Wt=n,_n=!0,d=Rt,Ii(n.type)?(bc=d,Rt=On(s.firstChild)):Rt=d),tn(e,n,n.pendingProps.children,r),fs(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&rt&&((d=s=Rt)&&(s=A0(s,n.type,n.pendingProps,_n),s!==null?(n.stateNode=s,Wt=n,Rt=On(s.firstChild),_n=!1,d=!0):d=!1),d||Ci(n)),ke(n),d=n.type,g=n.pendingProps,S=e!==null?e.memoizedProps:null,s=g.children,hc(d,g)?s=null:S!==null&&hc(d,S)&&(n.flags|=32),n.memoizedState!==null&&(d=du(e,n,Yx,null,null,r),ta._currentValue=d),fs(e,n),tn(e,n,s,r),n.child;case 6:return e===null&&rt&&((e=r=Rt)&&(r=T0(r,n.pendingProps,_n),r!==null?(n.stateNode=r,Wt=n,Rt=null,e=!0):e=!1),e||Ci(n)),null;case 13:return Lp(e,n,r);case 4:return xe(n,n.stateNode.containerInfo),s=n.pendingProps,e===null?n.child=or(n,null,s,r):tn(e,n,s,r),n.child;case 11:return Np(e,n,n.type,n.pendingProps,r);case 7:return tn(e,n,n.pendingProps,r),n.child;case 8:return tn(e,n,n.pendingProps.children,r),n.child;case 12:return tn(e,n,n.pendingProps.children,r),n.child;case 10:return s=n.pendingProps,Ei(n,n.type,s.value),tn(e,n,s.children,r),n.child;case 9:return d=n.type._context,s=n.pendingProps.children,rr(n),d=en(d),s=s(d),n.flags|=1,tn(e,n,s,r),n.child;case 14:return Ap(e,n,n.type,n.pendingProps,r);case 15:return Tp(e,n,n.type,n.pendingProps,r);case 19:return Up(e,n,r);case 31:return Zx(e,n,r);case 22:return Rp(e,n,r,n.pendingProps);case 24:return rr(n),s=en(Yt),e===null?(d=nu(),d===null&&(d=Ct,g=eu(),d.pooledCache=g,g.refCount++,g!==null&&(d.pooledCacheLanes|=r),d=g),n.memoizedState={parent:s,cache:d},ru(n),Ei(n,Yt,d)):((e.lanes&r)!==0&&(lu(e,n),Ol(n,null,null,r),Ml()),d=e.memoizedState,g=n.memoizedState,d.parent!==s?(d={parent:s,cache:s},n.memoizedState=d,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=d),Ei(n,Yt,s)):(s=g.cache,Ei(n,Yt,s),s!==d.cache&&Wo(n,[Yt],r,!0))),tn(e,n,n.pendingProps.children,r),n.child;case 29:throw n.pendingProps}throw Error(a(156,n.tag))}function ci(e){e.flags|=4}function qu(e,n,r,s,d){if((n=(e.mode&32)!==0)&&(n=!1),n){if(e.flags|=16777216,(d&335544128)===d)if(e.stateNode.complete)e.flags|=8192;else if(dm())e.flags|=8192;else throw sr=Pa,iu}else e.flags&=-16777217}function qp(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!tg(n))if(dm())e.flags|=8192;else throw sr=Pa,iu}function hs(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?fe():536870912,e.lanes|=n,Zr|=n)}function Hl(e,n){if(!rt)switch(e.tailMode){case"hidden":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e.tail=null:r.sibling=null;break;case"collapsed":r=e.tail;for(var s=null;r!==null;)r.alternate!==null&&(s=r),r=r.sibling;s===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:s.sibling=null}}function zt(e){var n=e.alternate!==null&&e.alternate.child===e.child,r=0,s=0;if(n)for(var d=e.child;d!==null;)r|=d.lanes|d.childLanes,s|=d.subtreeFlags&65011712,s|=d.flags&65011712,d.return=e,d=d.sibling;else for(d=e.child;d!==null;)r|=d.lanes|d.childLanes,s|=d.subtreeFlags,s|=d.flags,d.return=e,d=d.sibling;return e.subtreeFlags|=s,e.childLanes=r,n}function Wx(e,n,r){var s=n.pendingProps;switch(Xo(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return zt(n),null;case 1:return zt(n),null;case 3:return r=n.stateNode,s=null,e!==null&&(s=e.memoizedState.cache),n.memoizedState.cache!==s&&(n.flags|=2048),ai(Yt),F(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Ur(n)?ci(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Po())),zt(n),null;case 26:var d=n.type,g=n.memoizedState;return e===null?(ci(n),g!==null?(zt(n),qp(n,g)):(zt(n),qu(n,d,null,s,r))):g?g!==e.memoizedState?(ci(n),zt(n),qp(n,g)):(zt(n),n.flags&=-16777217):(e=e.memoizedProps,e!==s&&ci(n),zt(n),qu(n,d,e,s,r)),null;case 27:if(ze(n),r=le.current,d=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==s&&ci(n);else{if(!s){if(n.stateNode===null)throw Error(a(166));return zt(n),null}e=ee.current,Ur(n)?vh(n):(e=Qm(d,s,r),n.stateNode=e,ci(n))}return zt(n),null;case 5:if(ze(n),d=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==s&&ci(n);else{if(!s){if(n.stateNode===null)throw Error(a(166));return zt(n),null}if(g=ee.current,Ur(n))vh(n);else{var S=As(le.current);switch(g){case 1:g=S.createElementNS("http://www.w3.org/2000/svg",d);break;case 2:g=S.createElementNS("http://www.w3.org/1998/Math/MathML",d);break;default:switch(d){case"svg":g=S.createElementNS("http://www.w3.org/2000/svg",d);break;case"math":g=S.createElementNS("http://www.w3.org/1998/Math/MathML",d);break;case"script":g=S.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof s.is=="string"?S.createElement("select",{is:s.is}):S.createElement("select"),s.multiple?g.multiple=!0:s.size&&(g.size=s.size);break;default:g=typeof s.is=="string"?S.createElement(d,{is:s.is}):S.createElement(d)}}g[Bt]=n,g[Jt]=s;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(nn(g,d,s),d){case"button":case"input":case"select":case"textarea":s=!!s.autoFocus;break e;case"img":s=!0;break e;default:s=!1}s&&ci(n)}}return zt(n),qu(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,r),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==s&&ci(n);else{if(typeof s!="string"&&n.stateNode===null)throw Error(a(166));if(e=le.current,Ur(n)){if(e=n.stateNode,r=n.memoizedProps,s=null,d=Wt,d!==null)switch(d.tag){case 27:case 5:s=d.memoizedProps}e[Bt]=n,e=!!(e.nodeValue===r||s!==null&&s.suppressHydrationWarning===!0||Lm(e.nodeValue,r)),e||Ci(n,!0)}else e=As(e).createTextNode(s),e[Bt]=n,n.stateNode=e}return zt(n),null;case 31:if(r=n.memoizedState,e===null||e.memoizedState!==null){if(s=Ur(n),r!==null){if(e===null){if(!s)throw Error(a(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(a(557));e[Bt]=n}else nr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;zt(n),e=!1}else r=Po(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=r),e=!0;if(!e)return n.flags&256?(xn(n),n):(xn(n),null);if((n.flags&128)!==0)throw Error(a(558))}return zt(n),null;case 13:if(s=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(d=Ur(n),s!==null&&s.dehydrated!==null){if(e===null){if(!d)throw Error(a(318));if(d=n.memoizedState,d=d!==null?d.dehydrated:null,!d)throw Error(a(317));d[Bt]=n}else nr(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;zt(n),d=!1}else d=Po(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=d),d=!0;if(!d)return n.flags&256?(xn(n),n):(xn(n),null)}return xn(n),(n.flags&128)!==0?(n.lanes=r,n):(r=s!==null,e=e!==null&&e.memoizedState!==null,r&&(s=n.child,d=null,s.alternate!==null&&s.alternate.memoizedState!==null&&s.alternate.memoizedState.cachePool!==null&&(d=s.alternate.memoizedState.cachePool.pool),g=null,s.memoizedState!==null&&s.memoizedState.cachePool!==null&&(g=s.memoizedState.cachePool.pool),g!==d&&(s.flags|=2048)),r!==e&&r&&(n.child.flags|=8192),hs(n,n.updateQueue),zt(n),null);case 4:return F(),e===null&&oc(n.stateNode.containerInfo),zt(n),null;case 10:return ai(n.type),zt(n),null;case 19:if(te(qt),s=n.memoizedState,s===null)return zt(n),null;if(d=(n.flags&128)!==0,g=s.rendering,g===null)if(d)Hl(s,!1);else{if(It!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(g=es(e),g!==null){for(n.flags|=128,Hl(s,!1),e=g.updateQueue,n.updateQueue=e,hs(n,e),n.subtreeFlags=0,e=r,r=n.child;r!==null;)ph(r,e),r=r.sibling;return R(qt,qt.current&1|2),rt&&ri(n,s.treeForkCount),n.child}e=e.sibling}s.tail!==null&&Ze()>bs&&(n.flags|=128,d=!0,Hl(s,!1),n.lanes=4194304)}else{if(!d)if(e=es(g),e!==null){if(n.flags|=128,d=!0,e=e.updateQueue,n.updateQueue=e,hs(n,e),Hl(s,!0),s.tail===null&&s.tailMode==="hidden"&&!g.alternate&&!rt)return zt(n),null}else 2*Ze()-s.renderingStartTime>bs&&r!==536870912&&(n.flags|=128,d=!0,Hl(s,!1),n.lanes=4194304);s.isBackwards?(g.sibling=n.child,n.child=g):(e=s.last,e!==null?e.sibling=g:n.child=g,s.last=g)}return s.tail!==null?(e=s.tail,s.rendering=e,s.tail=e.sibling,s.renderingStartTime=Ze(),e.sibling=null,r=qt.current,R(qt,d?r&1|2:r&1),rt&&ri(n,s.treeForkCount),e):(zt(n),null);case 22:case 23:return xn(n),uu(),s=n.memoizedState!==null,e!==null?e.memoizedState!==null!==s&&(n.flags|=8192):s&&(n.flags|=8192),s?(r&536870912)!==0&&(n.flags&128)===0&&(zt(n),n.subtreeFlags&6&&(n.flags|=8192)):zt(n),r=n.updateQueue,r!==null&&hs(n,r.retryQueue),r=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(r=e.memoizedState.cachePool.pool),s=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(s=n.memoizedState.cachePool.pool),s!==r&&(n.flags|=2048),e!==null&&te(lr),null;case 24:return r=null,e!==null&&(r=e.memoizedState.cache),n.memoizedState.cache!==r&&(n.flags|=2048),ai(Yt),zt(n),null;case 25:return null;case 30:return null}throw Error(a(156,n.tag))}function e0(e,n){switch(Xo(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return ai(Yt),F(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return ze(n),null;case 31:if(n.memoizedState!==null){if(xn(n),n.alternate===null)throw Error(a(340));nr()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(xn(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(a(340));nr()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return te(qt),null;case 4:return F(),null;case 10:return ai(n.type),null;case 22:case 23:return xn(n),uu(),e!==null&&te(lr),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return ai(Yt),null;case 25:return null;default:return null}}function Hp(e,n){switch(Xo(n),n.tag){case 3:ai(Yt),F();break;case 26:case 27:case 5:ze(n);break;case 4:F();break;case 31:n.memoizedState!==null&&xn(n);break;case 13:xn(n);break;case 19:te(qt);break;case 10:ai(n.type);break;case 22:case 23:xn(n),uu(),e!==null&&te(lr);break;case 24:ai(Yt)}}function Vl(e,n){try{var r=n.updateQueue,s=r!==null?r.lastEffect:null;if(s!==null){var d=s.next;r=d;do{if((r.tag&e)===e){s=void 0;var g=r.create,S=r.inst;s=g(),S.destroy=s}r=r.next}while(r!==d)}}catch(E){vt(n,n.return,E)}}function Di(e,n,r){try{var s=n.updateQueue,d=s!==null?s.lastEffect:null;if(d!==null){var g=d.next;s=g;do{if((s.tag&e)===e){var S=s.inst,E=S.destroy;if(E!==void 0){S.destroy=void 0,d=n;var V=r,re=E;try{re()}catch(de){vt(d,V,de)}}}s=s.next}while(s!==g)}}catch(de){vt(n,n.return,de)}}function Vp(e){var n=e.updateQueue;if(n!==null){var r=e.stateNode;try{Dh(n,r)}catch(s){vt(e,e.return,s)}}}function Yp(e,n,r){r.props=cr(e.type,e.memoizedProps),r.state=e.memoizedState;try{r.componentWillUnmount()}catch(s){vt(e,n,s)}}function Yl(e,n){try{var r=e.ref;if(r!==null){switch(e.tag){case 26:case 27:case 5:var s=e.stateNode;break;case 30:s=e.stateNode;break;default:s=e.stateNode}typeof r=="function"?e.refCleanup=r(s):r.current=s}}catch(d){vt(e,n,d)}}function Xn(e,n){var r=e.ref,s=e.refCleanup;if(r!==null)if(typeof s=="function")try{s()}catch(d){vt(e,n,d)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof r=="function")try{r(null)}catch(d){vt(e,n,d)}else r.current=null}function Gp(e){var n=e.type,r=e.memoizedProps,s=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":r.autoFocus&&s.focus();break e;case"img":r.src?s.src=r.src:r.srcSet&&(s.srcset=r.srcSet)}}catch(d){vt(e,e.return,d)}}function Hu(e,n,r){try{var s=e.stateNode;w0(s,e.type,r,n),s[Jt]=n}catch(d){vt(e,e.return,d)}}function Fp(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Ii(e.type)||e.tag===4}function Vu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Fp(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&&Ii(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 Yu(e,n,r){var s=e.tag;if(s===5||s===6)e=e.stateNode,n?(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r).insertBefore(e,n):(n=r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,n.appendChild(e),r=r._reactRootContainer,r!=null||n.onclick!==null||(n.onclick=ti));else if(s!==4&&(s===27&&Ii(e.type)&&(r=e.stateNode,n=null),e=e.child,e!==null))for(Yu(e,n,r),e=e.sibling;e!==null;)Yu(e,n,r),e=e.sibling}function ps(e,n,r){var s=e.tag;if(s===5||s===6)e=e.stateNode,n?r.insertBefore(e,n):r.appendChild(e);else if(s!==4&&(s===27&&Ii(e.type)&&(r=e.stateNode),e=e.child,e!==null))for(ps(e,n,r),e=e.sibling;e!==null;)ps(e,n,r),e=e.sibling}function $p(e){var n=e.stateNode,r=e.memoizedProps;try{for(var s=e.type,d=n.attributes;d.length;)n.removeAttributeNode(d[0]);nn(n,s,r),n[Bt]=e,n[Jt]=r}catch(g){vt(e,e.return,g)}}var fi=!1,$t=!1,Gu=!1,Qp=typeof WeakSet=="function"?WeakSet:Set,Pt=null;function t0(e,n){if(e=e.containerInfo,fc=Os,e=lh(e),Bo(e)){if("selectionStart"in e)var r={start:e.selectionStart,end:e.selectionEnd};else e:{r=(r=e.ownerDocument)&&r.defaultView||window;var s=r.getSelection&&r.getSelection();if(s&&s.rangeCount!==0){r=s.anchorNode;var d=s.anchorOffset,g=s.focusNode;s=s.focusOffset;try{r.nodeType,g.nodeType}catch{r=null;break e}var S=0,E=-1,V=-1,re=0,de=0,me=e,se=null;t:for(;;){for(var ce;me!==r||d!==0&&me.nodeType!==3||(E=S+d),me!==g||s!==0&&me.nodeType!==3||(V=S+s),me.nodeType===3&&(S+=me.nodeValue.length),(ce=me.firstChild)!==null;)se=me,me=ce;for(;;){if(me===e)break t;if(se===r&&++re===d&&(E=S),se===g&&++de===s&&(V=S),(ce=me.nextSibling)!==null)break;me=se,se=me.parentNode}me=ce}r=E===-1||V===-1?null:{start:E,end:V}}else r=null}r=r||{start:0,end:0}}else r=null;for(dc={focusedElem:e,selectionRange:r},Os=!1,Pt=n;Pt!==null;)if(n=Pt,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,Pt=e;else for(;Pt!==null;){switch(n=Pt,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(r=0;r<e.length;r++)d=e[r],d.ref.impl=d.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&g!==null){e=void 0,r=n,d=g.memoizedProps,g=g.memoizedState,s=r.stateNode;try{var Te=cr(r.type,d);e=s.getSnapshotBeforeUpdate(Te,g),s.__reactInternalSnapshotBeforeUpdate=e}catch(Ue){vt(r,r.return,Ue)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,r=e.nodeType,r===9)mc(e);else if(r===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":mc(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(a(163))}if(e=n.sibling,e!==null){e.return=n.return,Pt=e;break}Pt=n.return}}function Xp(e,n,r){var s=r.flags;switch(r.tag){case 0:case 11:case 15:hi(e,r),s&4&&Vl(5,r);break;case 1:if(hi(e,r),s&4)if(e=r.stateNode,n===null)try{e.componentDidMount()}catch(S){vt(r,r.return,S)}else{var d=cr(r.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(d,n,e.__reactInternalSnapshotBeforeUpdate)}catch(S){vt(r,r.return,S)}}s&64&&Vp(r),s&512&&Yl(r,r.return);break;case 3:if(hi(e,r),s&64&&(e=r.updateQueue,e!==null)){if(n=null,r.child!==null)switch(r.child.tag){case 27:case 5:n=r.child.stateNode;break;case 1:n=r.child.stateNode}try{Dh(e,n)}catch(S){vt(r,r.return,S)}}break;case 27:n===null&&s&4&&$p(r);case 26:case 5:hi(e,r),n===null&&s&4&&Gp(r),s&512&&Yl(r,r.return);break;case 12:hi(e,r);break;case 31:hi(e,r),s&4&&Zp(e,r);break;case 13:hi(e,r),s&4&&Jp(e,r),s&64&&(e=r.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(r=c0.bind(null,r),R0(e,r))));break;case 22:if(s=r.memoizedState!==null||fi,!s){n=n!==null&&n.memoizedState!==null||$t,d=fi;var g=$t;fi=s,($t=n)&&!g?pi(e,r,(r.subtreeFlags&8772)!==0):hi(e,r),fi=d,$t=g}break;case 30:break;default:hi(e,r)}}function Kp(e){var n=e.alternate;n!==null&&(e.alternate=null,Kp(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&xo(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 Dt=null,cn=!1;function di(e,n,r){for(r=r.child;r!==null;)Pp(e,n,r),r=r.sibling}function Pp(e,n,r){if(ut&&typeof ut.onCommitFiberUnmount=="function")try{ut.onCommitFiberUnmount(mt,r)}catch{}switch(r.tag){case 26:$t||Xn(r,n),di(e,n,r),r.memoizedState?r.memoizedState.count--:r.stateNode&&(r=r.stateNode,r.parentNode.removeChild(r));break;case 27:$t||Xn(r,n);var s=Dt,d=cn;Ii(r.type)&&(Dt=r.stateNode,cn=!1),di(e,n,r),Jl(r.stateNode),Dt=s,cn=d;break;case 5:$t||Xn(r,n);case 6:if(s=Dt,d=cn,Dt=null,di(e,n,r),Dt=s,cn=d,Dt!==null)if(cn)try{(Dt.nodeType===9?Dt.body:Dt.nodeName==="HTML"?Dt.ownerDocument.body:Dt).removeChild(r.stateNode)}catch(g){vt(r,n,g)}else try{Dt.removeChild(r.stateNode)}catch(g){vt(r,n,g)}break;case 18:Dt!==null&&(cn?(e=Dt,Vm(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,r.stateNode),ll(e)):Vm(Dt,r.stateNode));break;case 4:s=Dt,d=cn,Dt=r.stateNode.containerInfo,cn=!0,di(e,n,r),Dt=s,cn=d;break;case 0:case 11:case 14:case 15:Di(2,r,n),$t||Di(4,r,n),di(e,n,r);break;case 1:$t||(Xn(r,n),s=r.stateNode,typeof s.componentWillUnmount=="function"&&Yp(r,n,s)),di(e,n,r);break;case 21:di(e,n,r);break;case 22:$t=(s=$t)||r.memoizedState!==null,di(e,n,r),$t=s;break;default:di(e,n,r)}}function Zp(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{ll(e)}catch(r){vt(n,n.return,r)}}}function Jp(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{ll(e)}catch(r){vt(n,n.return,r)}}function n0(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new Qp),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new Qp),n;default:throw Error(a(435,e.tag))}}function ms(e,n){var r=n0(e);n.forEach(function(s){if(!r.has(s)){r.add(s);var d=f0.bind(null,e,s);s.then(d,d)}})}function fn(e,n){var r=n.deletions;if(r!==null)for(var s=0;s<r.length;s++){var d=r[s],g=e,S=n,E=S;e:for(;E!==null;){switch(E.tag){case 27:if(Ii(E.type)){Dt=E.stateNode,cn=!1;break e}break;case 5:Dt=E.stateNode,cn=!1;break e;case 3:case 4:Dt=E.stateNode.containerInfo,cn=!0;break e}E=E.return}if(Dt===null)throw Error(a(160));Pp(g,S,d),Dt=null,cn=!1,g=d.alternate,g!==null&&(g.return=null),d.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)Wp(n,e),n=n.sibling}var In=null;function Wp(e,n){var r=e.alternate,s=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:fn(n,e),dn(e),s&4&&(Di(3,e,e.return),Vl(3,e),Di(5,e,e.return));break;case 1:fn(n,e),dn(e),s&512&&($t||r===null||Xn(r,r.return)),s&64&&fi&&(e=e.updateQueue,e!==null&&(s=e.callbacks,s!==null&&(r=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=r===null?s:r.concat(s))));break;case 26:var d=In;if(fn(n,e),dn(e),s&512&&($t||r===null||Xn(r,r.return)),s&4){var g=r!==null?r.memoizedState:null;if(s=e.memoizedState,r===null)if(s===null)if(e.stateNode===null){e:{s=e.type,r=e.memoizedProps,d=d.ownerDocument||d;t:switch(s){case"title":g=d.getElementsByTagName("title")[0],(!g||g[gl]||g[Bt]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=d.createElement(s),d.head.insertBefore(g,d.querySelector("head > title"))),nn(g,s,r),g[Bt]=e,Kt(g),s=g;break e;case"link":var S=Wm("link","href",d).get(s+(r.href||""));if(S){for(var E=0;E<S.length;E++)if(g=S[E],g.getAttribute("href")===(r.href==null||r.href===""?null:r.href)&&g.getAttribute("rel")===(r.rel==null?null:r.rel)&&g.getAttribute("title")===(r.title==null?null:r.title)&&g.getAttribute("crossorigin")===(r.crossOrigin==null?null:r.crossOrigin)){S.splice(E,1);break t}}g=d.createElement(s),nn(g,s,r),d.head.appendChild(g);break;case"meta":if(S=Wm("meta","content",d).get(s+(r.content||""))){for(E=0;E<S.length;E++)if(g=S[E],g.getAttribute("content")===(r.content==null?null:""+r.content)&&g.getAttribute("name")===(r.name==null?null:r.name)&&g.getAttribute("property")===(r.property==null?null:r.property)&&g.getAttribute("http-equiv")===(r.httpEquiv==null?null:r.httpEquiv)&&g.getAttribute("charset")===(r.charSet==null?null:r.charSet)){S.splice(E,1);break t}}g=d.createElement(s),nn(g,s,r),d.head.appendChild(g);break;default:throw Error(a(468,s))}g[Bt]=e,Kt(g),s=g}e.stateNode=s}else eg(d,e.type,e.stateNode);else e.stateNode=Jm(d,s,e.memoizedProps);else g!==s?(g===null?r.stateNode!==null&&(r=r.stateNode,r.parentNode.removeChild(r)):g.count--,s===null?eg(d,e.type,e.stateNode):Jm(d,s,e.memoizedProps)):s===null&&e.stateNode!==null&&Hu(e,e.memoizedProps,r.memoizedProps)}break;case 27:fn(n,e),dn(e),s&512&&($t||r===null||Xn(r,r.return)),r!==null&&s&4&&Hu(e,e.memoizedProps,r.memoizedProps);break;case 5:if(fn(n,e),dn(e),s&512&&($t||r===null||Xn(r,r.return)),e.flags&32){d=e.stateNode;try{Ar(d,"")}catch(Te){vt(e,e.return,Te)}}s&4&&e.stateNode!=null&&(d=e.memoizedProps,Hu(e,d,r!==null?r.memoizedProps:d)),s&1024&&(Gu=!0);break;case 6:if(fn(n,e),dn(e),s&4){if(e.stateNode===null)throw Error(a(162));s=e.memoizedProps,r=e.stateNode;try{r.nodeValue=s}catch(Te){vt(e,e.return,Te)}}break;case 3:if(zs=null,d=In,In=Ts(n.containerInfo),fn(n,e),In=d,dn(e),s&4&&r!==null&&r.memoizedState.isDehydrated)try{ll(n.containerInfo)}catch(Te){vt(e,e.return,Te)}Gu&&(Gu=!1,em(e));break;case 4:s=In,In=Ts(e.stateNode.containerInfo),fn(n,e),dn(e),In=s;break;case 12:fn(n,e),dn(e);break;case 31:fn(n,e),dn(e),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,ms(e,s)));break;case 13:fn(n,e),dn(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(ys=Ze()),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,ms(e,s)));break;case 22:d=e.memoizedState!==null;var V=r!==null&&r.memoizedState!==null,re=fi,de=$t;if(fi=re||d,$t=de||V,fn(n,e),$t=de,fi=re,dn(e),s&8192)e:for(n=e.stateNode,n._visibility=d?n._visibility&-2:n._visibility|1,d&&(r===null||V||fi||$t||fr(e)),r=null,n=e;;){if(n.tag===5||n.tag===26){if(r===null){V=r=n;try{if(g=V.stateNode,d)S=g.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none";else{E=V.stateNode;var me=V.memoizedProps.style,se=me!=null&&me.hasOwnProperty("display")?me.display:null;E.style.display=se==null||typeof se=="boolean"?"":(""+se).trim()}}catch(Te){vt(V,V.return,Te)}}}else if(n.tag===6){if(r===null){V=n;try{V.stateNode.nodeValue=d?"":V.memoizedProps}catch(Te){vt(V,V.return,Te)}}}else if(n.tag===18){if(r===null){V=n;try{var ce=V.stateNode;d?Ym(ce,!0):Ym(V.stateNode,!1)}catch(Te){vt(V,V.return,Te)}}}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;r===n&&(r=null),n=n.return}r===n&&(r=null),n.sibling.return=n.return,n=n.sibling}s&4&&(s=e.updateQueue,s!==null&&(r=s.retryQueue,r!==null&&(s.retryQueue=null,ms(e,r))));break;case 19:fn(n,e),dn(e),s&4&&(s=e.updateQueue,s!==null&&(e.updateQueue=null,ms(e,s)));break;case 30:break;case 21:break;default:fn(n,e),dn(e)}}function dn(e){var n=e.flags;if(n&2){try{for(var r,s=e.return;s!==null;){if(Fp(s)){r=s;break}s=s.return}if(r==null)throw Error(a(160));switch(r.tag){case 27:var d=r.stateNode,g=Vu(e);ps(e,g,d);break;case 5:var S=r.stateNode;r.flags&32&&(Ar(S,""),r.flags&=-33);var E=Vu(e);ps(e,E,S);break;case 3:case 4:var V=r.stateNode.containerInfo,re=Vu(e);Yu(e,re,V);break;default:throw Error(a(161))}}catch(de){vt(e,e.return,de)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function em(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;em(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function hi(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)Xp(e,n.alternate,n),n=n.sibling}function fr(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Di(4,n,n.return),fr(n);break;case 1:Xn(n,n.return);var r=n.stateNode;typeof r.componentWillUnmount=="function"&&Yp(n,n.return,r),fr(n);break;case 27:Jl(n.stateNode);case 26:case 5:Xn(n,n.return),fr(n);break;case 22:n.memoizedState===null&&fr(n);break;case 30:fr(n);break;default:fr(n)}e=e.sibling}}function pi(e,n,r){for(r=r&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var s=n.alternate,d=e,g=n,S=g.flags;switch(g.tag){case 0:case 11:case 15:pi(d,g,r),Vl(4,g);break;case 1:if(pi(d,g,r),s=g,d=s.stateNode,typeof d.componentDidMount=="function")try{d.componentDidMount()}catch(re){vt(s,s.return,re)}if(s=g,d=s.updateQueue,d!==null){var E=s.stateNode;try{var V=d.shared.hiddenCallbacks;if(V!==null)for(d.shared.hiddenCallbacks=null,d=0;d<V.length;d++)zh(V[d],E)}catch(re){vt(s,s.return,re)}}r&&S&64&&Vp(g),Yl(g,g.return);break;case 27:$p(g);case 26:case 5:pi(d,g,r),r&&s===null&&S&4&&Gp(g),Yl(g,g.return);break;case 12:pi(d,g,r);break;case 31:pi(d,g,r),r&&S&4&&Zp(d,g);break;case 13:pi(d,g,r),r&&S&4&&Jp(d,g);break;case 22:g.memoizedState===null&&pi(d,g,r),Yl(g,g.return);break;case 30:break;default:pi(d,g,r)}n=n.sibling}}function Fu(e,n){var r=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(r=e.memoizedState.cachePool.pool),e=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(e=n.memoizedState.cachePool.pool),e!==r&&(e!=null&&e.refCount++,r!=null&&Tl(r))}function $u(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Tl(e))}function qn(e,n,r,s){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)tm(e,n,r,s),n=n.sibling}function tm(e,n,r,s){var d=n.flags;switch(n.tag){case 0:case 11:case 15:qn(e,n,r,s),d&2048&&Vl(9,n);break;case 1:qn(e,n,r,s);break;case 3:qn(e,n,r,s),d&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&Tl(e)));break;case 12:if(d&2048){qn(e,n,r,s),e=n.stateNode;try{var g=n.memoizedProps,S=g.id,E=g.onPostCommit;typeof E=="function"&&E(S,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(V){vt(n,n.return,V)}}else qn(e,n,r,s);break;case 31:qn(e,n,r,s);break;case 13:qn(e,n,r,s);break;case 23:break;case 22:g=n.stateNode,S=n.alternate,n.memoizedState!==null?g._visibility&2?qn(e,n,r,s):Gl(e,n):g._visibility&2?qn(e,n,r,s):(g._visibility|=2,Xr(e,n,r,s,(n.subtreeFlags&10256)!==0||!1)),d&2048&&Fu(S,n);break;case 24:qn(e,n,r,s),d&2048&&$u(n.alternate,n);break;default:qn(e,n,r,s)}}function Xr(e,n,r,s,d){for(d=d&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var g=e,S=n,E=r,V=s,re=S.flags;switch(S.tag){case 0:case 11:case 15:Xr(g,S,E,V,d),Vl(8,S);break;case 23:break;case 22:var de=S.stateNode;S.memoizedState!==null?de._visibility&2?Xr(g,S,E,V,d):Gl(g,S):(de._visibility|=2,Xr(g,S,E,V,d)),d&&re&2048&&Fu(S.alternate,S);break;case 24:Xr(g,S,E,V,d),d&&re&2048&&$u(S.alternate,S);break;default:Xr(g,S,E,V,d)}n=n.sibling}}function Gl(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var r=e,s=n,d=s.flags;switch(s.tag){case 22:Gl(r,s),d&2048&&Fu(s.alternate,s);break;case 24:Gl(r,s),d&2048&&$u(s.alternate,s);break;default:Gl(r,s)}n=n.sibling}}var Fl=8192;function Kr(e,n,r){if(e.subtreeFlags&Fl)for(e=e.child;e!==null;)nm(e,n,r),e=e.sibling}function nm(e,n,r){switch(e.tag){case 26:Kr(e,n,r),e.flags&Fl&&e.memoizedState!==null&&V0(r,In,e.memoizedState,e.memoizedProps);break;case 5:Kr(e,n,r);break;case 3:case 4:var s=In;In=Ts(e.stateNode.containerInfo),Kr(e,n,r),In=s;break;case 22:e.memoizedState===null&&(s=e.alternate,s!==null&&s.memoizedState!==null?(s=Fl,Fl=16777216,Kr(e,n,r),Fl=s):Kr(e,n,r));break;default:Kr(e,n,r)}}function im(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 $l(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];Pt=s,lm(s,e)}im(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)rm(e),e=e.sibling}function rm(e){switch(e.tag){case 0:case 11:case 15:$l(e),e.flags&2048&&Di(9,e,e.return);break;case 3:$l(e);break;case 12:$l(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,gs(e)):$l(e);break;default:$l(e)}}function gs(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];Pt=s,lm(s,e)}im(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Di(8,n,n.return),gs(n);break;case 22:r=n.stateNode,r._visibility&2&&(r._visibility&=-3,gs(n));break;default:gs(n)}e=e.sibling}}function lm(e,n){for(;Pt!==null;){var r=Pt;switch(r.tag){case 0:case 11:case 15:Di(8,r,n);break;case 23:case 22:if(r.memoizedState!==null&&r.memoizedState.cachePool!==null){var s=r.memoizedState.cachePool.pool;s!=null&&s.refCount++}break;case 24:Tl(r.memoizedState.cache)}if(s=r.child,s!==null)s.return=r,Pt=s;else e:for(r=e;Pt!==null;){s=Pt;var d=s.sibling,g=s.return;if(Kp(s),s===r){Pt=null;break e}if(d!==null){d.return=g,Pt=d;break e}Pt=g}}}var i0={getCacheForType:function(e){var n=en(Yt),r=n.data.get(e);return r===void 0&&(r=e(),n.data.set(e,r)),r},cacheSignal:function(){return en(Yt).controller.signal}},r0=typeof WeakMap=="function"?WeakMap:Map,ht=0,Ct=null,Je=null,nt=0,bt=0,Sn=null,_i=!1,Pr=!1,Qu=!1,mi=0,It=0,Mi=0,dr=0,Xu=0,wn=0,Zr=0,Ql=null,hn=null,Ku=!1,ys=0,am=0,bs=1/0,vs=null,Oi=null,Xt=0,Li=null,Jr=null,gi=0,Pu=0,Zu=null,sm=null,Xl=0,Ju=null;function jn(){return(ht&2)!==0&&nt!==0?nt&-nt:I.T!==null?rc():Ta()}function om(){if(wn===0)if((nt&536870912)===0||rt){var e=Re;Re<<=1,(Re&3932160)===0&&(Re=262144),wn=e}else wn=536870912;return e=vn.current,e!==null&&(e.flags|=32),wn}function pn(e,n,r){(e===Ct&&(bt===2||bt===9)||e.cancelPendingCommit!==null)&&(Wr(e,0),Bi(e,nt,wn,!1)),Pe(e,r),((ht&2)===0||e!==Ct)&&(e===Ct&&((ht&2)===0&&(dr|=r),It===4&&Bi(e,nt,wn,!1)),Kn(e))}function um(e,n,r){if((ht&6)!==0)throw Error(a(327));var s=!r&&(n&127)===0&&(n&e.expiredLanes)===0||Ce(e,n),d=s?s0(e,n):ec(e,n,!0),g=s;do{if(d===0){Pr&&!s&&Bi(e,n,0,!1);break}else{if(r=e.current.alternate,g&&!l0(r)){d=ec(e,n,!1),g=!1;continue}if(d===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 E=e;d=Ql;var V=E.current.memoizedState.isDehydrated;if(V&&(Wr(E,S).flags|=256),S=ec(E,S,!1),S!==2){if(Qu&&!V){E.errorRecoveryDisabledLanes|=g,dr|=g,d=4;break e}g=hn,hn=d,g!==null&&(hn===null?hn=g:hn.push.apply(hn,g))}d=S}if(g=!1,d!==2)continue}}if(d===1){Wr(e,0),Bi(e,n,0,!0);break}e:{switch(s=e,g=d,g){case 0:case 1:throw Error(a(345));case 4:if((n&4194048)!==n)break;case 6:Bi(s,n,wn,!_i);break e;case 2:hn=null;break;case 3:case 5:break;default:throw Error(a(329))}if((n&62914560)===n&&(d=ys+300-Ze(),10<d)){if(Bi(s,n,wn,!_i),Oe(s,0,!0)!==0)break e;gi=n,s.timeoutHandle=qm(cm.bind(null,s,r,hn,vs,Ku,n,wn,dr,Zr,_i,g,"Throttled",-0,0),d);break e}cm(s,r,hn,vs,Ku,n,wn,dr,Zr,_i,g,null,-0,0)}}break}while(!0);Kn(e)}function cm(e,n,r,s,d,g,S,E,V,re,de,me,se,ce){if(e.timeoutHandle=-1,me=n.subtreeFlags,me&8192||(me&16785408)===16785408){me={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:ti},nm(n,g,me);var Te=(g&62914560)===g?ys-Ze():(g&4194048)===g?am-Ze():0;if(Te=Y0(me,Te),Te!==null){gi=g,e.cancelPendingCommit=Te(bm.bind(null,e,n,g,r,s,d,S,E,V,de,me,null,se,ce)),Bi(e,g,S,!re);return}}bm(e,n,g,r,s,d,S,E,V)}function l0(e){for(var n=e;;){var r=n.tag;if((r===0||r===11||r===15)&&n.flags&16384&&(r=n.updateQueue,r!==null&&(r=r.stores,r!==null)))for(var s=0;s<r.length;s++){var d=r[s],g=d.getSnapshot;d=d.value;try{if(!yn(g(),d))return!1}catch{return!1}}if(r=n.child,n.subtreeFlags&16384&&r!==null)r.return=n,n=r;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 Bi(e,n,r,s){n&=~Xu,n&=~dr,e.suspendedLanes|=n,e.pingedLanes&=~n,s&&(e.warmLanes|=n),s=e.expirationTimes;for(var d=n;0<d;){var g=31-tt(d),S=1<<g;s[g]=-1,d&=~S}r!==0&&Tt(e,r,n)}function xs(){return(ht&6)===0?(Kl(0),!1):!0}function Wu(){if(Je!==null){if(bt===0)var e=Je.return;else e=Je,li=ir=null,mu(e),Yr=null,zl=0,e=Je;for(;e!==null;)Hp(e.alternate,e),e=e.return;Je=null}}function Wr(e,n){var r=e.timeoutHandle;r!==-1&&(e.timeoutHandle=-1,C0(r)),r=e.cancelPendingCommit,r!==null&&(e.cancelPendingCommit=null,r()),gi=0,Wu(),Ct=e,Je=r=ii(e.current,null),nt=n,bt=0,Sn=null,_i=!1,Pr=Ce(e,n),Qu=!1,Zr=wn=Xu=dr=Mi=It=0,hn=Ql=null,Ku=!1,(n&8)!==0&&(n|=n&32);var s=e.entangledLanes;if(s!==0)for(e=e.entanglements,s&=n;0<s;){var d=31-tt(s),g=1<<d;n|=e[d],s&=~g}return mi=n,Ha(),r}function fm(e,n){$e=null,I.H=Il,n===Vr||n===Ka?(n=Nh(),bt=3):n===iu?(n=Nh(),bt=4):bt=n===zu?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,Sn=n,Je===null&&(It=1,us(e,Rn(n,e.current)))}function dm(){var e=vn.current;return e===null?!0:(nt&4194048)===nt?Mn===null:(nt&62914560)===nt||(nt&536870912)!==0?e===Mn:!1}function hm(){var e=I.H;return I.H=Il,e===null?Il:e}function pm(){var e=I.A;return I.A=i0,e}function Ss(){It=4,_i||(nt&4194048)!==nt&&vn.current!==null||(Pr=!0),(Mi&134217727)===0&&(dr&134217727)===0||Ct===null||Bi(Ct,nt,wn,!1)}function ec(e,n,r){var s=ht;ht|=2;var d=hm(),g=pm();(Ct!==e||nt!==n)&&(vs=null,Wr(e,n)),n=!1;var S=It;e:do try{if(bt!==0&&Je!==null){var E=Je,V=Sn;switch(bt){case 8:Wu(),S=6;break e;case 3:case 2:case 9:case 6:vn.current===null&&(n=!0);var re=bt;if(bt=0,Sn=null,el(e,E,V,re),r&&Pr){S=0;break e}break;default:re=bt,bt=0,Sn=null,el(e,E,V,re)}}a0(),S=It;break}catch(de){fm(e,de)}while(!0);return n&&e.shellSuspendCounter++,li=ir=null,ht=s,I.H=d,I.A=g,Je===null&&(Ct=null,nt=0,Ha()),S}function a0(){for(;Je!==null;)mm(Je)}function s0(e,n){var r=ht;ht|=2;var s=hm(),d=pm();Ct!==e||nt!==n?(vs=null,bs=Ze()+500,Wr(e,n)):Pr=Ce(e,n);e:do try{if(bt!==0&&Je!==null){n=Je;var g=Sn;t:switch(bt){case 1:bt=0,Sn=null,el(e,n,g,1);break;case 2:case 9:if(Ch(g)){bt=0,Sn=null,gm(n);break}n=function(){bt!==2&&bt!==9||Ct!==e||(bt=7),Kn(e)},g.then(n,n);break e;case 3:bt=7;break e;case 4:bt=5;break e;case 7:Ch(g)?(bt=0,Sn=null,gm(n)):(bt=0,Sn=null,el(e,n,g,7));break;case 5:var S=null;switch(Je.tag){case 26:S=Je.memoizedState;case 5:case 27:var E=Je;if(S?tg(S):E.stateNode.complete){bt=0,Sn=null;var V=E.sibling;if(V!==null)Je=V;else{var re=E.return;re!==null?(Je=re,ws(re)):Je=null}break t}}bt=0,Sn=null,el(e,n,g,5);break;case 6:bt=0,Sn=null,el(e,n,g,6);break;case 8:Wu(),It=6;break e;default:throw Error(a(462))}}o0();break}catch(de){fm(e,de)}while(!0);return li=ir=null,I.H=s,I.A=d,ht=r,Je!==null?0:(Ct=null,nt=0,Ha(),It)}function o0(){for(;Je!==null&&!yt();)mm(Je)}function mm(e){var n=Ip(e.alternate,e,mi);e.memoizedProps=e.pendingProps,n===null?ws(e):Je=n}function gm(e){var n=e,r=n.alternate;switch(n.tag){case 15:case 0:n=_p(r,n,n.pendingProps,n.type,void 0,nt);break;case 11:n=_p(r,n,n.pendingProps,n.type.render,n.ref,nt);break;case 5:mu(n);default:Hp(r,n),n=Je=ph(n,mi),n=Ip(r,n,mi)}e.memoizedProps=e.pendingProps,n===null?ws(e):Je=n}function el(e,n,r,s){li=ir=null,mu(n),Yr=null,zl=0;var d=n.return;try{if(Px(e,d,n,r,nt)){It=1,us(e,Rn(r,e.current)),Je=null;return}}catch(g){if(d!==null)throw Je=d,g;It=1,us(e,Rn(r,e.current)),Je=null;return}n.flags&32768?(rt||s===1?e=!0:Pr||(nt&536870912)!==0?e=!1:(_i=e=!0,(s===2||s===9||s===3||s===6)&&(s=vn.current,s!==null&&s.tag===13&&(s.flags|=16384))),ym(n,e)):ws(n)}function ws(e){var n=e;do{if((n.flags&32768)!==0){ym(n,_i);return}e=n.return;var r=Wx(n.alternate,n,mi);if(r!==null){Je=r;return}if(n=n.sibling,n!==null){Je=n;return}Je=n=e}while(n!==null);It===0&&(It=5)}function ym(e,n){do{var r=e0(e.alternate,e);if(r!==null){r.flags&=32767,Je=r;return}if(r=e.return,r!==null&&(r.flags|=32768,r.subtreeFlags=0,r.deletions=null),!n&&(e=e.sibling,e!==null)){Je=e;return}Je=e=r}while(e!==null);It=6,Je=null}function bm(e,n,r,s,d,g,S,E,V){e.cancelPendingCommit=null;do js();while(Xt!==0);if((ht&6)!==0)throw Error(a(327));if(n!==null){if(n===e.current)throw Error(a(177));if(g=n.lanes|n.childLanes,g|=Vo,lt(e,r,g,S,E,V),e===Ct&&(Je=Ct=null,nt=0),Jr=n,Li=e,gi=r,Pu=g,Zu=d,sm=s,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,d0(ge,function(){return jm(),null})):(e.callbackNode=null,e.callbackPriority=0),s=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||s){s=I.T,I.T=null,d=Y.p,Y.p=2,S=ht,ht|=4;try{t0(e,n,r)}finally{ht=S,Y.p=d,I.T=s}}Xt=1,vm(),xm(),Sm()}}function vm(){if(Xt===1){Xt=0;var e=Li,n=Jr,r=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||r){r=I.T,I.T=null;var s=Y.p;Y.p=2;var d=ht;ht|=4;try{Wp(n,e);var g=dc,S=lh(e.containerInfo),E=g.focusedElem,V=g.selectionRange;if(S!==E&&E&&E.ownerDocument&&rh(E.ownerDocument.documentElement,E)){if(V!==null&&Bo(E)){var re=V.start,de=V.end;if(de===void 0&&(de=re),"selectionStart"in E)E.selectionStart=re,E.selectionEnd=Math.min(de,E.value.length);else{var me=E.ownerDocument||document,se=me&&me.defaultView||window;if(se.getSelection){var ce=se.getSelection(),Te=E.textContent.length,Ue=Math.min(V.start,Te),jt=V.end===void 0?Ue:Math.min(V.end,Te);!ce.extend&&Ue>jt&&(S=jt,jt=Ue,Ue=S);var P=ih(E,Ue),$=ih(E,jt);if(P&&$&&(ce.rangeCount!==1||ce.anchorNode!==P.node||ce.anchorOffset!==P.offset||ce.focusNode!==$.node||ce.focusOffset!==$.offset)){var ie=me.createRange();ie.setStart(P.node,P.offset),ce.removeAllRanges(),Ue>jt?(ce.addRange(ie),ce.extend($.node,$.offset)):(ie.setEnd($.node,$.offset),ce.addRange(ie))}}}}for(me=[],ce=E;ce=ce.parentNode;)ce.nodeType===1&&me.push({element:ce,left:ce.scrollLeft,top:ce.scrollTop});for(typeof E.focus=="function"&&E.focus(),E=0;E<me.length;E++){var he=me[E];he.element.scrollLeft=he.left,he.element.scrollTop=he.top}}Os=!!fc,dc=fc=null}finally{ht=d,Y.p=s,I.T=r}}e.current=n,Xt=2}}function xm(){if(Xt===2){Xt=0;var e=Li,n=Jr,r=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||r){r=I.T,I.T=null;var s=Y.p;Y.p=2;var d=ht;ht|=4;try{Xp(e,n.alternate,n)}finally{ht=d,Y.p=s,I.T=r}}Xt=3}}function Sm(){if(Xt===4||Xt===3){Xt=0,ot();var e=Li,n=Jr,r=gi,s=sm;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Xt=5:(Xt=0,Jr=Li=null,wm(e,e.pendingLanes));var d=e.pendingLanes;if(d===0&&(Oi=null),wr(r),n=n.stateNode,ut&&typeof ut.onCommitFiberRoot=="function")try{ut.onCommitFiberRoot(mt,n,void 0,(n.current.flags&128)===128)}catch{}if(s!==null){n=I.T,d=Y.p,Y.p=2,I.T=null;try{for(var g=e.onRecoverableError,S=0;S<s.length;S++){var E=s[S];g(E.value,{componentStack:E.stack})}}finally{I.T=n,Y.p=d}}(gi&3)!==0&&js(),Kn(e),d=e.pendingLanes,(r&261930)!==0&&(d&42)!==0?e===Ju?Xl++:(Xl=0,Ju=e):Xl=0,Kl(0)}}function wm(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,Tl(n)))}function js(){return vm(),xm(),Sm(),jm()}function jm(){if(Xt!==5)return!1;var e=Li,n=Pu;Pu=0;var r=wr(gi),s=I.T,d=Y.p;try{Y.p=32>r?32:r,I.T=null,r=Zu,Zu=null;var g=Li,S=gi;if(Xt=0,Jr=Li=null,gi=0,(ht&6)!==0)throw Error(a(331));var E=ht;if(ht|=4,rm(g.current),tm(g,g.current,S,r),ht=E,Kl(0,!1),ut&&typeof ut.onPostCommitFiberRoot=="function")try{ut.onPostCommitFiberRoot(mt,g)}catch{}return!0}finally{Y.p=d,I.T=s,wm(e,n)}}function km(e,n,r){n=Rn(r,n),n=Ru(e.stateNode,n,2),e=Ti(e,n,2),e!==null&&(Pe(e,2),Kn(e))}function vt(e,n,r){if(e.tag===3)km(e,e,r);else for(;n!==null;){if(n.tag===3){km(n,e,r);break}else if(n.tag===1){var s=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof s.componentDidCatch=="function"&&(Oi===null||!Oi.has(s))){e=Rn(r,e),r=Cp(2),s=Ti(n,r,2),s!==null&&(Ep(r,s,n,e),Pe(s,2),Kn(s));break}}n=n.return}}function tc(e,n,r){var s=e.pingCache;if(s===null){s=e.pingCache=new r0;var d=new Set;s.set(n,d)}else d=s.get(n),d===void 0&&(d=new Set,s.set(n,d));d.has(r)||(Qu=!0,d.add(r),e=u0.bind(null,e,n,r),n.then(e,e))}function u0(e,n,r){var s=e.pingCache;s!==null&&s.delete(n),e.pingedLanes|=e.suspendedLanes&r,e.warmLanes&=~r,Ct===e&&(nt&r)===r&&(It===4||It===3&&(nt&62914560)===nt&&300>Ze()-ys?(ht&2)===0&&Wr(e,0):Xu|=r,Zr===nt&&(Zr=0)),Kn(e)}function Cm(e,n){n===0&&(n=fe()),e=er(e,n),e!==null&&(Pe(e,n),Kn(e))}function c0(e){var n=e.memoizedState,r=0;n!==null&&(r=n.retryLane),Cm(e,r)}function f0(e,n){var r=0;switch(e.tag){case 31:case 13:var s=e.stateNode,d=e.memoizedState;d!==null&&(r=d.retryLane);break;case 19:s=e.stateNode;break;case 22:s=e.stateNode._retryCache;break;default:throw Error(a(314))}s!==null&&s.delete(n),Cm(e,r)}function d0(e,n){return At(e,n)}var ks=null,tl=null,nc=!1,Cs=!1,ic=!1,Ui=0;function Kn(e){e!==tl&&e.next===null&&(tl===null?ks=tl=e:tl=tl.next=e),Cs=!0,nc||(nc=!0,p0())}function Kl(e,n){if(!ic&&Cs){ic=!0;do for(var r=!1,s=ks;s!==null;){if(e!==0){var d=s.pendingLanes;if(d===0)var g=0;else{var S=s.suspendedLanes,E=s.pingedLanes;g=(1<<31-tt(42|e)+1)-1,g&=d&~(S&~E),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(r=!0,Tm(s,g))}else g=nt,g=Oe(s,s===Ct?g:0,s.cancelPendingCommit!==null||s.timeoutHandle!==-1),(g&3)===0||Ce(s,g)||(r=!0,Tm(s,g));s=s.next}while(r);ic=!1}}function h0(){Em()}function Em(){Cs=nc=!1;var e=0;Ui!==0&&k0()&&(e=Ui);for(var n=Ze(),r=null,s=ks;s!==null;){var d=s.next,g=Nm(s,n);g===0?(s.next=null,r===null?ks=d:r.next=d,d===null&&(tl=r)):(r=s,(e!==0||(g&3)!==0)&&(Cs=!0)),s=d}Xt!==0&&Xt!==5||Kl(e),Ui!==0&&(Ui=0)}function Nm(e,n){for(var r=e.suspendedLanes,s=e.pingedLanes,d=e.expirationTimes,g=e.pendingLanes&-62914561;0<g;){var S=31-tt(g),E=1<<S,V=d[S];V===-1?((E&r)===0||(E&s)!==0)&&(d[S]=U(E,n)):V<=n&&(e.expiredLanes|=E),g&=~E}if(n=Ct,r=nt,r=Oe(e,e===n?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s=e.callbackNode,r===0||e===n&&(bt===2||bt===9)||e.cancelPendingCommit!==null)return s!==null&&s!==null&&Ie(s),e.callbackNode=null,e.callbackPriority=0;if((r&3)===0||Ce(e,r)){if(n=r&-r,n===e.callbackPriority)return n;switch(s!==null&&Ie(s),wr(r)){case 2:case 8:r=Z;break;case 32:r=ge;break;case 268435456:r=Ne;break;default:r=ge}return s=Am.bind(null,e),r=At(r,s),e.callbackPriority=n,e.callbackNode=r,n}return s!==null&&s!==null&&Ie(s),e.callbackPriority=2,e.callbackNode=null,2}function Am(e,n){if(Xt!==0&&Xt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var r=e.callbackNode;if(js()&&e.callbackNode!==r)return null;var s=nt;return s=Oe(e,e===Ct?s:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),s===0?null:(um(e,s,n),Nm(e,Ze()),e.callbackNode!=null&&e.callbackNode===r?Am.bind(null,e):null)}function Tm(e,n){if(js())return null;um(e,n,!0)}function p0(){E0(function(){(ht&6)!==0?At(_,h0):Em()})}function rc(){if(Ui===0){var e=qr;e===0&&(e=Ae,Ae<<=1,(Ae&261888)===0&&(Ae=256)),Ui=e}return Ui}function Rm(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:_a(""+e)}function zm(e,n){var r=n.ownerDocument.createElement("input");return r.name=n.name,r.value=n.value,e.id&&r.setAttribute("form",e.id),n.parentNode.insertBefore(r,n),e=new FormData(e),r.parentNode.removeChild(r),e}function m0(e,n,r,s,d){if(n==="submit"&&r&&r.stateNode===d){var g=Rm((d[Jt]||null).action),S=s.submitter;S&&(n=(n=S[Jt]||null)?Rm(n.formAction):S.getAttribute("formAction"),n!==null&&(g=n,S=null));var E=new Ba("action","action",null,s,d);e.push({event:E,listeners:[{instance:null,listener:function(){if(s.defaultPrevented){if(Ui!==0){var V=S?zm(d,S):new FormData(d);ku(r,{pending:!0,data:V,method:d.method,action:g},null,V)}}else typeof g=="function"&&(E.preventDefault(),V=S?zm(d,S):new FormData(d),ku(r,{pending:!0,data:V,method:d.method,action:g},g,V))},currentTarget:d}]})}}for(var lc=0;lc<Ho.length;lc++){var ac=Ho[lc],g0=ac.toLowerCase(),y0=ac[0].toUpperCase()+ac.slice(1);Un(g0,"on"+y0)}Un(oh,"onAnimationEnd"),Un(uh,"onAnimationIteration"),Un(ch,"onAnimationStart"),Un("dblclick","onDoubleClick"),Un("focusin","onFocus"),Un("focusout","onBlur"),Un(_x,"onTransitionRun"),Un(Mx,"onTransitionStart"),Un(Ox,"onTransitionCancel"),Un(fh,"onTransitionEnd"),Er("onMouseEnter",["mouseout","mouseover"]),Er("onMouseLeave",["mouseout","mouseover"]),Er("onPointerEnter",["pointerout","pointerover"]),Er("onPointerLeave",["pointerout","pointerover"]),Pi("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Pi("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Pi("onBeforeInput",["compositionend","keypress","textInput","paste"]),Pi("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Pi("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Pi("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Pl="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(" "),b0=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Pl));function Dm(e,n){n=(n&4)!==0;for(var r=0;r<e.length;r++){var s=e[r],d=s.event;s=s.listeners;e:{var g=void 0;if(n)for(var S=s.length-1;0<=S;S--){var E=s[S],V=E.instance,re=E.currentTarget;if(E=E.listener,V!==g&&d.isPropagationStopped())break e;g=E,d.currentTarget=re;try{g(d)}catch(de){qa(de)}d.currentTarget=null,g=V}else for(S=0;S<s.length;S++){if(E=s[S],V=E.instance,re=E.currentTarget,E=E.listener,V!==g&&d.isPropagationStopped())break e;g=E,d.currentTarget=re;try{g(d)}catch(de){qa(de)}d.currentTarget=null,g=V}}}}function We(e,n){var r=n[Fn];r===void 0&&(r=n[Fn]=new Set);var s=e+"__bubble";r.has(s)||(_m(n,e,2,!1),r.add(s))}function sc(e,n,r){var s=0;n&&(s|=4),_m(r,e,s,n)}var Es="_reactListening"+Math.random().toString(36).slice(2);function oc(e){if(!e[Es]){e[Es]=!0,Ed.forEach(function(r){r!=="selectionchange"&&(b0.has(r)||sc(r,!1,e),sc(r,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[Es]||(n[Es]=!0,sc("selectionchange",!1,n))}}function _m(e,n,r,s){switch(og(n)){case 2:var d=$0;break;case 8:d=Q0;break;default:d=jc}r=d.bind(null,n,r,e),d=void 0,!Ao||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(d=!0),s?d!==void 0?e.addEventListener(n,r,{capture:!0,passive:d}):e.addEventListener(n,r,!0):d!==void 0?e.addEventListener(n,r,{passive:d}):e.addEventListener(n,r,!1)}function uc(e,n,r,s,d){var g=s;if((n&1)===0&&(n&2)===0&&s!==null)e:for(;;){if(s===null)return;var S=s.tag;if(S===3||S===4){var E=s.stateNode.containerInfo;if(E===d)break;if(S===4)for(S=s.return;S!==null;){var V=S.tag;if((V===3||V===4)&&S.stateNode.containerInfo===d)return;S=S.return}for(;E!==null;){if(S=jr(E),S===null)return;if(V=S.tag,V===5||V===6||V===26||V===27){s=g=S;continue e}E=E.parentNode}}s=s.return}Ud(function(){var re=g,de=Eo(r),me=[];e:{var se=dh.get(e);if(se!==void 0){var ce=Ba,Te=e;switch(e){case"keypress":if(Oa(r)===0)break e;case"keydown":case"keyup":ce=fx;break;case"focusin":Te="focus",ce=Do;break;case"focusout":Te="blur",ce=Do;break;case"beforeblur":case"afterblur":ce=Do;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":ce=Hd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ce=Wv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ce=px;break;case oh:case uh:case ch:ce=nx;break;case fh:ce=gx;break;case"scroll":case"scrollend":ce=Zv;break;case"wheel":ce=bx;break;case"copy":case"cut":case"paste":ce=rx;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ce=Yd;break;case"toggle":case"beforetoggle":ce=xx}var Ue=(n&4)!==0,jt=!Ue&&(e==="scroll"||e==="scrollend"),P=Ue?se!==null?se+"Capture":null:se;Ue=[];for(var $=re,ie;$!==null;){var he=$;if(ie=he.stateNode,he=he.tag,he!==5&&he!==26&&he!==27||ie===null||P===null||(he=bl($,P),he!=null&&Ue.push(Zl($,he,ie))),jt)break;$=$.return}0<Ue.length&&(se=new ce(se,Te,null,r,de),me.push({event:se,listeners:Ue}))}}if((n&7)===0){e:{if(se=e==="mouseover"||e==="pointerover",ce=e==="mouseout"||e==="pointerout",se&&r!==Co&&(Te=r.relatedTarget||r.fromElement)&&(jr(Te)||Te[Gn]))break e;if((ce||se)&&(se=de.window===de?de:(se=de.ownerDocument)?se.defaultView||se.parentWindow:window,ce?(Te=r.relatedTarget||r.toElement,ce=re,Te=Te?jr(Te):null,Te!==null&&(jt=f(Te),Ue=Te.tag,Te!==jt||Ue!==5&&Ue!==27&&Ue!==6)&&(Te=null)):(ce=null,Te=re),ce!==Te)){if(Ue=Hd,he="onMouseLeave",P="onMouseEnter",$="mouse",(e==="pointerout"||e==="pointerover")&&(Ue=Yd,he="onPointerLeave",P="onPointerEnter",$="pointer"),jt=ce==null?se:yl(ce),ie=Te==null?se:yl(Te),se=new Ue(he,$+"leave",ce,r,de),se.target=jt,se.relatedTarget=ie,he=null,jr(de)===re&&(Ue=new Ue(P,$+"enter",Te,r,de),Ue.target=ie,Ue.relatedTarget=jt,he=Ue),jt=he,ce&&Te)t:{for(Ue=v0,P=ce,$=Te,ie=0,he=P;he;he=Ue(he))ie++;he=0;for(var Me=$;Me;Me=Ue(Me))he++;for(;0<ie-he;)P=Ue(P),ie--;for(;0<he-ie;)$=Ue($),he--;for(;ie--;){if(P===$||$!==null&&P===$.alternate){Ue=P;break t}P=Ue(P),$=Ue($)}Ue=null}else Ue=null;ce!==null&&Mm(me,se,ce,Ue,!1),Te!==null&&jt!==null&&Mm(me,jt,Te,Ue,!0)}}e:{if(se=re?yl(re):window,ce=se.nodeName&&se.nodeName.toLowerCase(),ce==="select"||ce==="input"&&se.type==="file")var ct=Zd;else if(Kd(se))if(Jd)ct=Rx;else{ct=Ax;var _e=Nx}else ce=se.nodeName,!ce||ce.toLowerCase()!=="input"||se.type!=="checkbox"&&se.type!=="radio"?re&&ko(re.elementType)&&(ct=Zd):ct=Tx;if(ct&&(ct=ct(e,re))){Pd(me,ct,r,de);break e}_e&&_e(e,se,re),e==="focusout"&&re&&se.type==="number"&&re.memoizedProps.value!=null&&jo(se,"number",se.value)}switch(_e=re?yl(re):window,e){case"focusin":(Kd(_e)||_e.contentEditable==="true")&&(Dr=_e,Uo=re,El=null);break;case"focusout":El=Uo=Dr=null;break;case"mousedown":Io=!0;break;case"contextmenu":case"mouseup":case"dragend":Io=!1,ah(me,r,de);break;case"selectionchange":if(Dx)break;case"keydown":case"keyup":ah(me,r,de)}var Qe;if(Mo)e:{switch(e){case"compositionstart":var it="onCompositionStart";break e;case"compositionend":it="onCompositionEnd";break e;case"compositionupdate":it="onCompositionUpdate";break e}it=void 0}else zr?Qd(e,r)&&(it="onCompositionEnd"):e==="keydown"&&r.keyCode===229&&(it="onCompositionStart");it&&(Gd&&r.locale!=="ko"&&(zr||it!=="onCompositionStart"?it==="onCompositionEnd"&&zr&&(Qe=Id()):(wi=de,To="value"in wi?wi.value:wi.textContent,zr=!0)),_e=Ns(re,it),0<_e.length&&(it=new Vd(it,e,null,r,de),me.push({event:it,listeners:_e}),Qe?it.data=Qe:(Qe=Xd(r),Qe!==null&&(it.data=Qe)))),(Qe=wx?jx(e,r):kx(e,r))&&(it=Ns(re,"onBeforeInput"),0<it.length&&(_e=new Vd("onBeforeInput","beforeinput",null,r,de),me.push({event:_e,listeners:it}),_e.data=Qe)),m0(me,e,re,r,de)}Dm(me,n)})}function Zl(e,n,r){return{instance:e,listener:n,currentTarget:r}}function Ns(e,n){for(var r=n+"Capture",s=[];e!==null;){var d=e,g=d.stateNode;if(d=d.tag,d!==5&&d!==26&&d!==27||g===null||(d=bl(e,r),d!=null&&s.unshift(Zl(e,d,g)),d=bl(e,n),d!=null&&s.push(Zl(e,d,g))),e.tag===3)return s;e=e.return}return[]}function v0(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Mm(e,n,r,s,d){for(var g=n._reactName,S=[];r!==null&&r!==s;){var E=r,V=E.alternate,re=E.stateNode;if(E=E.tag,V!==null&&V===s)break;E!==5&&E!==26&&E!==27||re===null||(V=re,d?(re=bl(r,g),re!=null&&S.unshift(Zl(r,re,V))):d||(re=bl(r,g),re!=null&&S.push(Zl(r,re,V)))),r=r.return}S.length!==0&&e.push({event:n,listeners:S})}var x0=/\r\n?/g,S0=/\u0000|\uFFFD/g;function Om(e){return(typeof e=="string"?e:""+e).replace(x0,`
9
+ `).replace(S0,"")}function Lm(e,n){return n=Om(n),Om(e)===n}function wt(e,n,r,s,d,g){switch(r){case"children":typeof s=="string"?n==="body"||n==="textarea"&&s===""||Ar(e,s):(typeof s=="number"||typeof s=="bigint")&&n!=="body"&&Ar(e,""+s);break;case"className":za(e,"class",s);break;case"tabIndex":za(e,"tabindex",s);break;case"dir":case"role":case"viewBox":case"width":case"height":za(e,r,s);break;case"style":Ld(e,s,g);break;case"data":if(n!=="object"){za(e,"data",s);break}case"src":case"href":if(s===""&&(n!=="a"||r!=="href")){e.removeAttribute(r);break}if(s==null||typeof s=="function"||typeof s=="symbol"||typeof s=="boolean"){e.removeAttribute(r);break}s=_a(""+s),e.setAttribute(r,s);break;case"action":case"formAction":if(typeof s=="function"){e.setAttribute(r,"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"&&(r==="formAction"?(n!=="input"&&wt(e,n,"name",d.name,d,null),wt(e,n,"formEncType",d.formEncType,d,null),wt(e,n,"formMethod",d.formMethod,d,null),wt(e,n,"formTarget",d.formTarget,d,null)):(wt(e,n,"encType",d.encType,d,null),wt(e,n,"method",d.method,d,null),wt(e,n,"target",d.target,d,null)));if(s==null||typeof s=="symbol"||typeof s=="boolean"){e.removeAttribute(r);break}s=_a(""+s),e.setAttribute(r,s);break;case"onClick":s!=null&&(e.onclick=ti);break;case"onScroll":s!=null&&We("scroll",e);break;case"onScrollEnd":s!=null&&We("scrollend",e);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(a(61));if(r=s.__html,r!=null){if(d.children!=null)throw Error(a(60));e.innerHTML=r}}break;case"multiple":e.multiple=s&&typeof s!="function"&&typeof s!="symbol";break;case"muted":e.muted=s&&typeof s!="function"&&typeof s!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(s==null||typeof s=="function"||typeof s=="boolean"||typeof s=="symbol"){e.removeAttribute("xlink:href");break}r=_a(""+s),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",r);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":s!=null&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(r,""+s):e.removeAttribute(r);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":s&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(r,""):e.removeAttribute(r);break;case"capture":case"download":s===!0?e.setAttribute(r,""):s!==!1&&s!=null&&typeof s!="function"&&typeof s!="symbol"?e.setAttribute(r,s):e.removeAttribute(r);break;case"cols":case"rows":case"size":case"span":s!=null&&typeof s!="function"&&typeof s!="symbol"&&!isNaN(s)&&1<=s?e.setAttribute(r,s):e.removeAttribute(r);break;case"rowSpan":case"start":s==null||typeof s=="function"||typeof s=="symbol"||isNaN(s)?e.removeAttribute(r):e.setAttribute(r,s);break;case"popover":We("beforetoggle",e),We("toggle",e),Ra(e,"popover",s);break;case"xlinkActuate":ei(e,"http://www.w3.org/1999/xlink","xlink:actuate",s);break;case"xlinkArcrole":ei(e,"http://www.w3.org/1999/xlink","xlink:arcrole",s);break;case"xlinkRole":ei(e,"http://www.w3.org/1999/xlink","xlink:role",s);break;case"xlinkShow":ei(e,"http://www.w3.org/1999/xlink","xlink:show",s);break;case"xlinkTitle":ei(e,"http://www.w3.org/1999/xlink","xlink:title",s);break;case"xlinkType":ei(e,"http://www.w3.org/1999/xlink","xlink:type",s);break;case"xmlBase":ei(e,"http://www.w3.org/XML/1998/namespace","xml:base",s);break;case"xmlLang":ei(e,"http://www.w3.org/XML/1998/namespace","xml:lang",s);break;case"xmlSpace":ei(e,"http://www.w3.org/XML/1998/namespace","xml:space",s);break;case"is":Ra(e,"is",s);break;case"innerText":case"textContent":break;default:(!(2<r.length)||r[0]!=="o"&&r[0]!=="O"||r[1]!=="n"&&r[1]!=="N")&&(r=Kv.get(r)||r,Ra(e,r,s))}}function cc(e,n,r,s,d,g){switch(r){case"style":Ld(e,s,g);break;case"dangerouslySetInnerHTML":if(s!=null){if(typeof s!="object"||!("__html"in s))throw Error(a(61));if(r=s.__html,r!=null){if(d.children!=null)throw Error(a(60));e.innerHTML=r}}break;case"children":typeof s=="string"?Ar(e,s):(typeof s=="number"||typeof s=="bigint")&&Ar(e,""+s);break;case"onScroll":s!=null&&We("scroll",e);break;case"onScrollEnd":s!=null&&We("scrollend",e);break;case"onClick":s!=null&&(e.onclick=ti);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Nd.hasOwnProperty(r))e:{if(r[0]==="o"&&r[1]==="n"&&(d=r.endsWith("Capture"),n=r.slice(2,d?r.length-7:void 0),g=e[Jt]||null,g=g!=null?g[r]:null,typeof g=="function"&&e.removeEventListener(n,g,d),typeof s=="function")){typeof g!="function"&&g!==null&&(r in e?e[r]=null:e.hasAttribute(r)&&e.removeAttribute(r)),e.addEventListener(n,s,d);break e}r in e?e[r]=s:s===!0?e.setAttribute(r,""):Ra(e,r,s)}}}function nn(e,n,r){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":We("error",e),We("load",e);var s=!1,d=!1,g;for(g in r)if(r.hasOwnProperty(g)){var S=r[g];if(S!=null)switch(g){case"src":s=!0;break;case"srcSet":d=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(a(137,n));default:wt(e,n,g,S,r,null)}}d&&wt(e,n,"srcSet",r.srcSet,r,null),s&&wt(e,n,"src",r.src,r,null);return;case"input":We("invalid",e);var E=g=S=d=null,V=null,re=null;for(s in r)if(r.hasOwnProperty(s)){var de=r[s];if(de!=null)switch(s){case"name":d=de;break;case"type":S=de;break;case"checked":V=de;break;case"defaultChecked":re=de;break;case"value":g=de;break;case"defaultValue":E=de;break;case"children":case"dangerouslySetInnerHTML":if(de!=null)throw Error(a(137,n));break;default:wt(e,n,s,de,r,null)}}Dd(e,g,E,V,re,S,d,!1);return;case"select":We("invalid",e),s=S=g=null;for(d in r)if(r.hasOwnProperty(d)&&(E=r[d],E!=null))switch(d){case"value":g=E;break;case"defaultValue":S=E;break;case"multiple":s=E;default:wt(e,n,d,E,r,null)}n=g,r=S,e.multiple=!!s,n!=null?Nr(e,!!s,n,!1):r!=null&&Nr(e,!!s,r,!0);return;case"textarea":We("invalid",e),g=d=s=null;for(S in r)if(r.hasOwnProperty(S)&&(E=r[S],E!=null))switch(S){case"value":s=E;break;case"defaultValue":d=E;break;case"children":g=E;break;case"dangerouslySetInnerHTML":if(E!=null)throw Error(a(91));break;default:wt(e,n,S,E,r,null)}Md(e,s,d,g);return;case"option":for(V in r)r.hasOwnProperty(V)&&(s=r[V],s!=null)&&(V==="selected"?e.selected=s&&typeof s!="function"&&typeof s!="symbol":wt(e,n,V,s,r,null));return;case"dialog":We("beforetoggle",e),We("toggle",e),We("cancel",e),We("close",e);break;case"iframe":case"object":We("load",e);break;case"video":case"audio":for(s=0;s<Pl.length;s++)We(Pl[s],e);break;case"image":We("error",e),We("load",e);break;case"details":We("toggle",e);break;case"embed":case"source":case"link":We("error",e),We("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(re in r)if(r.hasOwnProperty(re)&&(s=r[re],s!=null))switch(re){case"children":case"dangerouslySetInnerHTML":throw Error(a(137,n));default:wt(e,n,re,s,r,null)}return;default:if(ko(n)){for(de in r)r.hasOwnProperty(de)&&(s=r[de],s!==void 0&&cc(e,n,de,s,r,void 0));return}}for(E in r)r.hasOwnProperty(E)&&(s=r[E],s!=null&&wt(e,n,E,s,r,null))}function w0(e,n,r,s){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var d=null,g=null,S=null,E=null,V=null,re=null,de=null;for(ce in r){var me=r[ce];if(r.hasOwnProperty(ce)&&me!=null)switch(ce){case"checked":break;case"value":break;case"defaultValue":V=me;default:s.hasOwnProperty(ce)||wt(e,n,ce,null,s,me)}}for(var se in s){var ce=s[se];if(me=r[se],s.hasOwnProperty(se)&&(ce!=null||me!=null))switch(se){case"type":g=ce;break;case"name":d=ce;break;case"checked":re=ce;break;case"defaultChecked":de=ce;break;case"value":S=ce;break;case"defaultValue":E=ce;break;case"children":case"dangerouslySetInnerHTML":if(ce!=null)throw Error(a(137,n));break;default:ce!==me&&wt(e,n,se,ce,s,me)}}wo(e,S,E,V,re,de,g,d);return;case"select":ce=S=E=se=null;for(g in r)if(V=r[g],r.hasOwnProperty(g)&&V!=null)switch(g){case"value":break;case"multiple":ce=V;default:s.hasOwnProperty(g)||wt(e,n,g,null,s,V)}for(d in s)if(g=s[d],V=r[d],s.hasOwnProperty(d)&&(g!=null||V!=null))switch(d){case"value":se=g;break;case"defaultValue":E=g;break;case"multiple":S=g;default:g!==V&&wt(e,n,d,g,s,V)}n=E,r=S,s=ce,se!=null?Nr(e,!!r,se,!1):!!s!=!!r&&(n!=null?Nr(e,!!r,n,!0):Nr(e,!!r,r?[]:"",!1));return;case"textarea":ce=se=null;for(E in r)if(d=r[E],r.hasOwnProperty(E)&&d!=null&&!s.hasOwnProperty(E))switch(E){case"value":break;case"children":break;default:wt(e,n,E,null,s,d)}for(S in s)if(d=s[S],g=r[S],s.hasOwnProperty(S)&&(d!=null||g!=null))switch(S){case"value":se=d;break;case"defaultValue":ce=d;break;case"children":break;case"dangerouslySetInnerHTML":if(d!=null)throw Error(a(91));break;default:d!==g&&wt(e,n,S,d,s,g)}_d(e,se,ce);return;case"option":for(var Te in r)se=r[Te],r.hasOwnProperty(Te)&&se!=null&&!s.hasOwnProperty(Te)&&(Te==="selected"?e.selected=!1:wt(e,n,Te,null,s,se));for(V in s)se=s[V],ce=r[V],s.hasOwnProperty(V)&&se!==ce&&(se!=null||ce!=null)&&(V==="selected"?e.selected=se&&typeof se!="function"&&typeof se!="symbol":wt(e,n,V,se,s,ce));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 Ue in r)se=r[Ue],r.hasOwnProperty(Ue)&&se!=null&&!s.hasOwnProperty(Ue)&&wt(e,n,Ue,null,s,se);for(re in s)if(se=s[re],ce=r[re],s.hasOwnProperty(re)&&se!==ce&&(se!=null||ce!=null))switch(re){case"children":case"dangerouslySetInnerHTML":if(se!=null)throw Error(a(137,n));break;default:wt(e,n,re,se,s,ce)}return;default:if(ko(n)){for(var jt in r)se=r[jt],r.hasOwnProperty(jt)&&se!==void 0&&!s.hasOwnProperty(jt)&&cc(e,n,jt,void 0,s,se);for(de in s)se=s[de],ce=r[de],!s.hasOwnProperty(de)||se===ce||se===void 0&&ce===void 0||cc(e,n,de,se,s,ce);return}}for(var P in r)se=r[P],r.hasOwnProperty(P)&&se!=null&&!s.hasOwnProperty(P)&&wt(e,n,P,null,s,se);for(me in s)se=s[me],ce=r[me],!s.hasOwnProperty(me)||se===ce||se==null&&ce==null||wt(e,n,me,se,s,ce)}function Bm(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function j0(){if(typeof performance.getEntriesByType=="function"){for(var e=0,n=0,r=performance.getEntriesByType("resource"),s=0;s<r.length;s++){var d=r[s],g=d.transferSize,S=d.initiatorType,E=d.duration;if(g&&E&&Bm(S)){for(S=0,E=d.responseEnd,s+=1;s<r.length;s++){var V=r[s],re=V.startTime;if(re>E)break;var de=V.transferSize,me=V.initiatorType;de&&Bm(me)&&(V=V.responseEnd,S+=de*(V<E?1:(E-re)/(V-re)))}if(--s,n+=8*(g+S)/(d.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 fc=null,dc=null;function As(e){return e.nodeType===9?e:e.ownerDocument}function Um(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 Im(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 hc(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 pc=null;function k0(){var e=window.event;return e&&e.type==="popstate"?e===pc?!1:(pc=e,!0):(pc=null,!1)}var qm=typeof setTimeout=="function"?setTimeout:void 0,C0=typeof clearTimeout=="function"?clearTimeout:void 0,Hm=typeof Promise=="function"?Promise:void 0,E0=typeof queueMicrotask=="function"?queueMicrotask:typeof Hm<"u"?function(e){return Hm.resolve(null).then(e).catch(N0)}:qm;function N0(e){setTimeout(function(){throw e})}function Ii(e){return e==="head"}function Vm(e,n){var r=n,s=0;do{var d=r.nextSibling;if(e.removeChild(r),d&&d.nodeType===8)if(r=d.data,r==="/$"||r==="/&"){if(s===0){e.removeChild(d),ll(n);return}s--}else if(r==="$"||r==="$?"||r==="$~"||r==="$!"||r==="&")s++;else if(r==="html")Jl(e.ownerDocument.documentElement);else if(r==="head"){r=e.ownerDocument.head,Jl(r);for(var g=r.firstChild;g;){var S=g.nextSibling,E=g.nodeName;g[gl]||E==="SCRIPT"||E==="STYLE"||E==="LINK"&&g.rel.toLowerCase()==="stylesheet"||r.removeChild(g),g=S}}else r==="body"&&Jl(e.ownerDocument.body);r=d}while(r);ll(n)}function Ym(e,n){var r=e;e=0;do{var s=r.nextSibling;if(r.nodeType===1?n?(r._stashedDisplay=r.style.display,r.style.display="none"):(r.style.display=r._stashedDisplay||"",r.getAttribute("style")===""&&r.removeAttribute("style")):r.nodeType===3&&(n?(r._stashedText=r.nodeValue,r.nodeValue=""):r.nodeValue=r._stashedText||""),s&&s.nodeType===8)if(r=s.data,r==="/$"){if(e===0)break;e--}else r!=="$"&&r!=="$?"&&r!=="$~"&&r!=="$!"||e++;r=s}while(r)}function mc(e){var n=e.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var r=n;switch(n=n.nextSibling,r.nodeName){case"HTML":case"HEAD":case"BODY":mc(r),xo(r);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(r.rel.toLowerCase()==="stylesheet")continue}e.removeChild(r)}}function A0(e,n,r,s){for(;e.nodeType===1;){var d=r;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!s&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(s){if(!e[gl])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!==d.rel||e.getAttribute("href")!==(d.href==null||d.href===""?null:d.href)||e.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin)||e.getAttribute("title")!==(d.title==null?null:d.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(g=e.getAttribute("src"),(g!==(d.src==null?null:d.src)||e.getAttribute("type")!==(d.type==null?null:d.type)||e.getAttribute("crossorigin")!==(d.crossOrigin==null?null:d.crossOrigin))&&g&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var g=d.name==null?null:""+d.name;if(d.type==="hidden"&&e.getAttribute("name")===g)return e}else return e;if(e=On(e.nextSibling),e===null)break}return null}function T0(e,n,r){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!r||(e=On(e.nextSibling),e===null))return null;return e}function Gm(e,n){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=On(e.nextSibling),e===null))return null;return e}function gc(e){return e.data==="$?"||e.data==="$~"}function yc(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function R0(e,n){var r=e.ownerDocument;if(e.data==="$~")e._reactRetry=n;else if(e.data!=="$?"||r.readyState!=="loading")n();else{var s=function(){n(),r.removeEventListener("DOMContentLoaded",s)};r.addEventListener("DOMContentLoaded",s),e._reactRetry=s}}function On(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 bc=null;function Fm(e){e=e.nextSibling;for(var n=0;e;){if(e.nodeType===8){var r=e.data;if(r==="/$"||r==="/&"){if(n===0)return On(e.nextSibling);n--}else r!=="$"&&r!=="$!"&&r!=="$?"&&r!=="$~"&&r!=="&"||n++}e=e.nextSibling}return null}function $m(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var r=e.data;if(r==="$"||r==="$!"||r==="$?"||r==="$~"||r==="&"){if(n===0)return e;n--}else r!=="/$"&&r!=="/&"||n++}e=e.previousSibling}return null}function Qm(e,n,r){switch(n=As(r),e){case"html":if(e=n.documentElement,!e)throw Error(a(452));return e;case"head":if(e=n.head,!e)throw Error(a(453));return e;case"body":if(e=n.body,!e)throw Error(a(454));return e;default:throw Error(a(451))}}function Jl(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);xo(e)}var Ln=new Map,Xm=new Set;function Ts(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var yi=Y.d;Y.d={f:z0,r:D0,D:_0,C:M0,L:O0,m:L0,X:U0,S:B0,M:I0};function z0(){var e=yi.f(),n=xs();return e||n}function D0(e){var n=kr(e);n!==null&&n.tag===5&&n.type==="form"?fp(n):yi.r(e)}var nl=typeof document>"u"?null:document;function Km(e,n,r){var s=nl;if(s&&typeof n=="string"&&n){var d=An(n);d='link[rel="'+e+'"][href="'+d+'"]',typeof r=="string"&&(d+='[crossorigin="'+r+'"]'),Xm.has(d)||(Xm.add(d),e={rel:e,crossOrigin:r,href:n},s.querySelector(d)===null&&(n=s.createElement("link"),nn(n,"link",e),Kt(n),s.head.appendChild(n)))}}function _0(e){yi.D(e),Km("dns-prefetch",e,null)}function M0(e,n){yi.C(e,n),Km("preconnect",e,n)}function O0(e,n,r){yi.L(e,n,r);var s=nl;if(s&&e&&n){var d='link[rel="preload"][as="'+An(n)+'"]';n==="image"&&r&&r.imageSrcSet?(d+='[imagesrcset="'+An(r.imageSrcSet)+'"]',typeof r.imageSizes=="string"&&(d+='[imagesizes="'+An(r.imageSizes)+'"]')):d+='[href="'+An(e)+'"]';var g=d;switch(n){case"style":g=il(e);break;case"script":g=rl(e)}Ln.has(g)||(e=b({rel:"preload",href:n==="image"&&r&&r.imageSrcSet?void 0:e,as:n},r),Ln.set(g,e),s.querySelector(d)!==null||n==="style"&&s.querySelector(Wl(g))||n==="script"&&s.querySelector(ea(g))||(n=s.createElement("link"),nn(n,"link",e),Kt(n),s.head.appendChild(n)))}}function L0(e,n){yi.m(e,n);var r=nl;if(r&&e){var s=n&&typeof n.as=="string"?n.as:"script",d='link[rel="modulepreload"][as="'+An(s)+'"][href="'+An(e)+'"]',g=d;switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=rl(e)}if(!Ln.has(g)&&(e=b({rel:"modulepreload",href:e},n),Ln.set(g,e),r.querySelector(d)===null)){switch(s){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(r.querySelector(ea(g)))return}s=r.createElement("link"),nn(s,"link",e),Kt(s),r.head.appendChild(s)}}}function B0(e,n,r){yi.S(e,n,r);var s=nl;if(s&&e){var d=Cr(s).hoistableStyles,g=il(e);n=n||"default";var S=d.get(g);if(!S){var E={loading:0,preload:null};if(S=s.querySelector(Wl(g)))E.loading=5;else{e=b({rel:"stylesheet",href:e,"data-precedence":n},r),(r=Ln.get(g))&&vc(e,r);var V=S=s.createElement("link");Kt(V),nn(V,"link",e),V._p=new Promise(function(re,de){V.onload=re,V.onerror=de}),V.addEventListener("load",function(){E.loading|=1}),V.addEventListener("error",function(){E.loading|=2}),E.loading|=4,Rs(S,n,s)}S={type:"stylesheet",instance:S,count:1,state:E},d.set(g,S)}}}function U0(e,n){yi.X(e,n);var r=nl;if(r&&e){var s=Cr(r).hoistableScripts,d=rl(e),g=s.get(d);g||(g=r.querySelector(ea(d)),g||(e=b({src:e,async:!0},n),(n=Ln.get(d))&&xc(e,n),g=r.createElement("script"),Kt(g),nn(g,"link",e),r.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},s.set(d,g))}}function I0(e,n){yi.M(e,n);var r=nl;if(r&&e){var s=Cr(r).hoistableScripts,d=rl(e),g=s.get(d);g||(g=r.querySelector(ea(d)),g||(e=b({src:e,async:!0,type:"module"},n),(n=Ln.get(d))&&xc(e,n),g=r.createElement("script"),Kt(g),nn(g,"link",e),r.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},s.set(d,g))}}function Pm(e,n,r,s){var d=(d=le.current)?Ts(d):null;if(!d)throw Error(a(446));switch(e){case"meta":case"title":return null;case"style":return typeof r.precedence=="string"&&typeof r.href=="string"?(n=il(r.href),r=Cr(d).hoistableStyles,s=r.get(n),s||(s={type:"style",instance:null,count:0,state:null},r.set(n,s)),s):{type:"void",instance:null,count:0,state:null};case"link":if(r.rel==="stylesheet"&&typeof r.href=="string"&&typeof r.precedence=="string"){e=il(r.href);var g=Cr(d).hoistableStyles,S=g.get(e);if(S||(d=d.ownerDocument||d,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(e,S),(g=d.querySelector(Wl(e)))&&!g._p&&(S.instance=g,S.state.loading=5),Ln.has(e)||(r={rel:"preload",as:"style",href:r.href,crossOrigin:r.crossOrigin,integrity:r.integrity,media:r.media,hrefLang:r.hrefLang,referrerPolicy:r.referrerPolicy},Ln.set(e,r),g||q0(d,e,r,S.state))),n&&s===null)throw Error(a(528,""));return S}if(n&&s!==null)throw Error(a(529,""));return null;case"script":return n=r.async,r=r.src,typeof r=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=rl(r),r=Cr(d).hoistableScripts,s=r.get(n),s||(s={type:"script",instance:null,count:0,state:null},r.set(n,s)),s):{type:"void",instance:null,count:0,state:null};default:throw Error(a(444,e))}}function il(e){return'href="'+An(e)+'"'}function Wl(e){return'link[rel="stylesheet"]['+e+"]"}function Zm(e){return b({},e,{"data-precedence":e.precedence,precedence:null})}function q0(e,n,r,s){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?s.loading=1:(n=e.createElement("link"),s.preload=n,n.addEventListener("load",function(){return s.loading|=1}),n.addEventListener("error",function(){return s.loading|=2}),nn(n,"link",r),Kt(n),e.head.appendChild(n))}function rl(e){return'[src="'+An(e)+'"]'}function ea(e){return"script[async]"+e}function Jm(e,n,r){if(n.count++,n.instance===null)switch(n.type){case"style":var s=e.querySelector('style[data-href~="'+An(r.href)+'"]');if(s)return n.instance=s,Kt(s),s;var d=b({},r,{"data-href":r.href,"data-precedence":r.precedence,href:null,precedence:null});return s=(e.ownerDocument||e).createElement("style"),Kt(s),nn(s,"style",d),Rs(s,r.precedence,e),n.instance=s;case"stylesheet":d=il(r.href);var g=e.querySelector(Wl(d));if(g)return n.state.loading|=4,n.instance=g,Kt(g),g;s=Zm(r),(d=Ln.get(d))&&vc(s,d),g=(e.ownerDocument||e).createElement("link"),Kt(g);var S=g;return S._p=new Promise(function(E,V){S.onload=E,S.onerror=V}),nn(g,"link",s),n.state.loading|=4,Rs(g,r.precedence,e),n.instance=g;case"script":return g=rl(r.src),(d=e.querySelector(ea(g)))?(n.instance=d,Kt(d),d):(s=r,(d=Ln.get(g))&&(s=b({},r),xc(s,d)),e=e.ownerDocument||e,d=e.createElement("script"),Kt(d),nn(d,"link",s),e.head.appendChild(d),n.instance=d);case"void":return null;default:throw Error(a(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(s=n.instance,n.state.loading|=4,Rs(s,r.precedence,e));return n.instance}function Rs(e,n,r){for(var s=r.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),d=s.length?s[s.length-1]:null,g=d,S=0;S<s.length;S++){var E=s[S];if(E.dataset.precedence===n)g=E;else if(g!==d)break}g?g.parentNode.insertBefore(e,g.nextSibling):(n=r.nodeType===9?r.head:r,n.insertBefore(e,n.firstChild))}function vc(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function xc(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var zs=null;function Wm(e,n,r){if(zs===null){var s=new Map,d=zs=new Map;d.set(r,s)}else d=zs,s=d.get(r),s||(s=new Map,d.set(r,s));if(s.has(e))return s;for(s.set(e,null),r=r.getElementsByTagName(e),d=0;d<r.length;d++){var g=r[d];if(!(g[gl]||g[Bt]||e==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var S=g.getAttribute(n)||"";S=e+S;var E=s.get(S);E?E.push(g):s.set(S,[g])}}return s}function eg(e,n,r){e=e.ownerDocument||e,e.head.insertBefore(r,n==="title"?e.querySelector("head > title"):null)}function H0(e,n,r){if(r===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 tg(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function V0(e,n,r,s){if(r.type==="stylesheet"&&(typeof s.media!="string"||matchMedia(s.media).matches!==!1)&&(r.state.loading&4)===0){if(r.instance===null){var d=il(s.href),g=n.querySelector(Wl(d));if(g){n=g._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=Ds.bind(e),n.then(e,e)),r.state.loading|=4,r.instance=g,Kt(g);return}g=n.ownerDocument||n,s=Zm(s),(d=Ln.get(d))&&vc(s,d),g=g.createElement("link"),Kt(g);var S=g;S._p=new Promise(function(E,V){S.onload=E,S.onerror=V}),nn(g,"link",s),r.instance=g}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(r,n),(n=r.state.preload)&&(r.state.loading&3)===0&&(e.count++,r=Ds.bind(e),n.addEventListener("load",r),n.addEventListener("error",r))}}var Sc=0;function Y0(e,n){return e.stylesheets&&e.count===0&&Ms(e,e.stylesheets),0<e.count||0<e.imgCount?function(r){var s=setTimeout(function(){if(e.stylesheets&&Ms(e,e.stylesheets),e.unsuspend){var g=e.unsuspend;e.unsuspend=null,g()}},6e4+n);0<e.imgBytes&&Sc===0&&(Sc=62500*j0());var d=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Ms(e,e.stylesheets),e.unsuspend)){var g=e.unsuspend;e.unsuspend=null,g()}},(e.imgBytes>Sc?50:800)+n);return e.unsuspend=r,function(){e.unsuspend=null,clearTimeout(s),clearTimeout(d)}}:null}function Ds(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Ms(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var _s=null;function Ms(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,_s=new Map,n.forEach(G0,e),_s=null,Ds.call(e))}function G0(e,n){if(!(n.state.loading&4)){var r=_s.get(e);if(r)var s=r.get(null);else{r=new Map,_s.set(e,r);for(var d=e.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<d.length;g++){var S=d[g];(S.nodeName==="LINK"||S.getAttribute("media")!=="not all")&&(r.set(S.dataset.precedence,S),s=S)}s&&r.set(null,s)}d=n.instance,S=d.getAttribute("data-precedence"),g=r.get(S)||s,g===s&&r.set(null,d),r.set(S,d),this.count++,s=Ds.bind(this),d.addEventListener("load",s),d.addEventListener("error",s),g?g.parentNode.insertBefore(d,g.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(d,e.firstChild)),n.state.loading|=4}}var ta={$$typeof:M,Provider:null,Consumer:null,_currentValue:X,_currentValue2:X,_threadCount:0};function F0(e,n,r,s,d,g,S,E,V){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=je(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=je(0),this.hiddenUpdates=je(null),this.identifierPrefix=s,this.onUncaughtError=d,this.onCaughtError=g,this.onRecoverableError=S,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=V,this.incompleteTransitions=new Map}function ng(e,n,r,s,d,g,S,E,V,re,de,me){return e=new F0(e,n,r,S,V,re,de,me,E),n=1,g===!0&&(n|=24),g=bn(3,null,null,n),e.current=g,g.stateNode=e,n=eu(),n.refCount++,e.pooledCache=n,n.refCount++,g.memoizedState={element:s,isDehydrated:r,cache:n},ru(g),e}function ig(e){return e?(e=Or,e):Or}function rg(e,n,r,s,d,g){d=ig(d),s.context===null?s.context=d:s.pendingContext=d,s=Ai(n),s.payload={element:r},g=g===void 0?null:g,g!==null&&(s.callback=g),r=Ti(e,s,n),r!==null&&(pn(r,e,n),_l(r,e,n))}function lg(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var r=e.retryLane;e.retryLane=r!==0&&r<n?r:n}}function wc(e,n){lg(e,n),(e=e.alternate)&&lg(e,n)}function ag(e){if(e.tag===13||e.tag===31){var n=er(e,67108864);n!==null&&pn(n,e,67108864),wc(e,67108864)}}function sg(e){if(e.tag===13||e.tag===31){var n=jn();n=Vt(n);var r=er(e,n);r!==null&&pn(r,e,n),wc(e,n)}}var Os=!0;function $0(e,n,r,s){var d=I.T;I.T=null;var g=Y.p;try{Y.p=2,jc(e,n,r,s)}finally{Y.p=g,I.T=d}}function Q0(e,n,r,s){var d=I.T;I.T=null;var g=Y.p;try{Y.p=8,jc(e,n,r,s)}finally{Y.p=g,I.T=d}}function jc(e,n,r,s){if(Os){var d=kc(s);if(d===null)uc(e,n,s,Ls,r),ug(e,s);else if(K0(d,e,n,r,s))s.stopPropagation();else if(ug(e,s),n&4&&-1<X0.indexOf(e)){for(;d!==null;){var g=kr(d);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var S=ye(g.pendingLanes);if(S!==0){var E=g;for(E.pendingLanes|=2,E.entangledLanes|=2;S;){var V=1<<31-tt(S);E.entanglements[1]|=V,S&=~V}Kn(g),(ht&6)===0&&(bs=Ze()+500,Kl(0))}}break;case 31:case 13:E=er(g,2),E!==null&&pn(E,g,2),xs(),wc(g,2)}if(g=kc(s),g===null&&uc(e,n,s,Ls,r),g===d)break;d=g}d!==null&&s.stopPropagation()}else uc(e,n,s,null,r)}}function kc(e){return e=Eo(e),Cc(e)}var Ls=null;function Cc(e){if(Ls=null,e=jr(e),e!==null){var n=f(e);if(n===null)e=null;else{var r=n.tag;if(r===13){if(e=u(n),e!==null)return e;e=null}else if(r===31){if(e=p(n),e!==null)return e;e=null}else if(r===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null)}}return Ls=e,null}function og(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(pt()){case _:return 2;case Z:return 8;case ge:case we:return 32;case Ne:return 268435456;default:return 32}default:return 32}}var Ec=!1,qi=null,Hi=null,Vi=null,na=new Map,ia=new Map,Yi=[],X0="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 ug(e,n){switch(e){case"focusin":case"focusout":qi=null;break;case"dragenter":case"dragleave":Hi=null;break;case"mouseover":case"mouseout":Vi=null;break;case"pointerover":case"pointerout":na.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":ia.delete(n.pointerId)}}function ra(e,n,r,s,d,g){return e===null||e.nativeEvent!==g?(e={blockedOn:n,domEventName:r,eventSystemFlags:s,nativeEvent:g,targetContainers:[d]},n!==null&&(n=kr(n),n!==null&&ag(n)),e):(e.eventSystemFlags|=s,n=e.targetContainers,d!==null&&n.indexOf(d)===-1&&n.push(d),e)}function K0(e,n,r,s,d){switch(n){case"focusin":return qi=ra(qi,e,n,r,s,d),!0;case"dragenter":return Hi=ra(Hi,e,n,r,s,d),!0;case"mouseover":return Vi=ra(Vi,e,n,r,s,d),!0;case"pointerover":var g=d.pointerId;return na.set(g,ra(na.get(g)||null,e,n,r,s,d)),!0;case"gotpointercapture":return g=d.pointerId,ia.set(g,ra(ia.get(g)||null,e,n,r,s,d)),!0}return!1}function cg(e){var n=jr(e.target);if(n!==null){var r=f(n);if(r!==null){if(n=r.tag,n===13){if(n=u(r),n!==null){e.blockedOn=n,Ki(e.priority,function(){sg(r)});return}}else if(n===31){if(n=p(r),n!==null){e.blockedOn=n,Ki(e.priority,function(){sg(r)});return}}else if(n===3&&r.stateNode.current.memoizedState.isDehydrated){e.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Bs(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var r=kc(e.nativeEvent);if(r===null){r=e.nativeEvent;var s=new r.constructor(r.type,r);Co=s,r.target.dispatchEvent(s),Co=null}else return n=kr(r),n!==null&&ag(n),e.blockedOn=r,!1;n.shift()}return!0}function fg(e,n,r){Bs(e)&&r.delete(n)}function P0(){Ec=!1,qi!==null&&Bs(qi)&&(qi=null),Hi!==null&&Bs(Hi)&&(Hi=null),Vi!==null&&Bs(Vi)&&(Vi=null),na.forEach(fg),ia.forEach(fg)}function Us(e,n){e.blockedOn===n&&(e.blockedOn=null,Ec||(Ec=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,P0)))}var Is=null;function dg(e){Is!==e&&(Is=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Is===e&&(Is=null);for(var n=0;n<e.length;n+=3){var r=e[n],s=e[n+1],d=e[n+2];if(typeof s!="function"){if(Cc(s||r)===null)continue;break}var g=kr(r);g!==null&&(e.splice(n,3),n-=3,ku(g,{pending:!0,data:d,method:r.method,action:s},s,d))}}))}function ll(e){function n(V){return Us(V,e)}qi!==null&&Us(qi,e),Hi!==null&&Us(Hi,e),Vi!==null&&Us(Vi,e),na.forEach(n),ia.forEach(n);for(var r=0;r<Yi.length;r++){var s=Yi[r];s.blockedOn===e&&(s.blockedOn=null)}for(;0<Yi.length&&(r=Yi[0],r.blockedOn===null);)cg(r),r.blockedOn===null&&Yi.shift();if(r=(e.ownerDocument||e).$$reactFormReplay,r!=null)for(s=0;s<r.length;s+=3){var d=r[s],g=r[s+1],S=d[Jt]||null;if(typeof g=="function")S||dg(r);else if(S){var E=null;if(g&&g.hasAttribute("formAction")){if(d=g,S=g[Jt]||null)E=S.formAction;else if(Cc(d)!==null)continue}else E=S.action;typeof E=="function"?r[s+1]=E:(r.splice(s,3),s-=3),dg(r)}}}function hg(){function e(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(S){return d=S})},focusReset:"manual",scroll:"manual"})}function n(){d!==null&&(d(),d=null),s||setTimeout(r,20)}function r(){if(!s&&!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 s=!1,d=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(r,100),function(){s=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),d!==null&&(d(),d=null)}}}function Nc(e){this._internalRoot=e}qs.prototype.render=Nc.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(a(409));var r=n.current,s=jn();rg(r,s,e,n,null,null)},qs.prototype.unmount=Nc.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;rg(e.current,2,null,e,null,null),xs(),n[Gn]=null}};function qs(e){this._internalRoot=e}qs.prototype.unstable_scheduleHydration=function(e){if(e){var n=Ta();e={blockedOn:null,target:e,priority:n};for(var r=0;r<Yi.length&&n!==0&&n<Yi[r].priority;r++);Yi.splice(r,0,e),r===0&&cg(e)}};var pg=i.version;if(pg!=="19.2.6")throw Error(a(527,pg,"19.2.6"));Y.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(a(188)):(e=Object.keys(e).join(","),Error(a(268,e)));return e=m(n),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var Z0={bundleType:0,version:"19.2.6",rendererPackageName:"react-dom",currentDispatcherRef:I,reconcilerVersion:"19.2.6"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Hs=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hs.isDisabled&&Hs.supportsFiber)try{mt=Hs.inject(Z0),ut=Hs}catch{}}return aa.createRoot=function(e,n){if(!o(e))throw Error(a(299));var r=!1,s="",d=Sp,g=wp,S=jp;return n!=null&&(n.unstable_strictMode===!0&&(r=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onUncaughtError!==void 0&&(d=n.onUncaughtError),n.onCaughtError!==void 0&&(g=n.onCaughtError),n.onRecoverableError!==void 0&&(S=n.onRecoverableError)),n=ng(e,1,!1,null,null,r,s,null,d,g,S,hg),e[Gn]=n.current,oc(e),new Nc(n)},aa.hydrateRoot=function(e,n,r){if(!o(e))throw Error(a(299));var s=!1,d="",g=Sp,S=wp,E=jp,V=null;return r!=null&&(r.unstable_strictMode===!0&&(s=!0),r.identifierPrefix!==void 0&&(d=r.identifierPrefix),r.onUncaughtError!==void 0&&(g=r.onUncaughtError),r.onCaughtError!==void 0&&(S=r.onCaughtError),r.onRecoverableError!==void 0&&(E=r.onRecoverableError),r.formState!==void 0&&(V=r.formState)),n=ng(e,1,!0,n,r??null,s,d,V,g,S,E,hg),n.context=ig(null),r=n.current,s=jn(),s=Vt(s),d=Ai(s),d.callback=null,Ti(r,d,s),r=s,n.current.lanes=r,Pe(n,r),Kn(n),e[Gn]=n.current,oc(e),new qs(n)},aa.version="19.2.6",aa}var Cg;function k1(){if(Cg)return zc.exports;Cg=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(i){console.error(i)}}return t(),zc.exports=j1(),zc.exports}var C1=k1();const E1=/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;function yb(t){if(!t||typeof t!="object")return!1;const i=t;return i.version===1&&typeof i.id=="string"&&E1.test(i.id)&&typeof i.name=="string"&&i.name.trim().length>0&&i.name.length<=128&&!/[\u0000-\u001f\u007f]/.test(i.name)&&["desktop","hub","project-host"].includes(i.kind)&&i.entryPath===(i.kind==="desktop"?"/mobile":"/")}const Wf="codeshell.environments.v1",bb=32;function ed(t){if(t.length>2048||/[\\\u0000-\u0020\u007f]/.test(t))throw new Error("请输入完整的工作台地址。");const i=new URL(t);if(!["https:","http:"].includes(i.protocol)||i.username||i.password||i.search||i.hash)throw new Error("请使用不含密码、配对令牌或查询参数的工作台地址。");if(!["/","/mobile","/mobile/"].includes(i.pathname))throw new Error("请填写工作台首页或桌面 /mobile 地址。");return i.origin+(i.pathname.startsWith("/mobile")?"/mobile":"/")}function vb(t){if(!t||typeof t!="object")throw new Error("无效的连接记录。");const i=t;if(typeof i.address!="string"||typeof i.name!="string"||!i.name.trim()||i.name.length>80||/[\u0000-\u001f\u007f]/.test(i.name))throw new Error("连接名称需为 1–80 个字符。");if(i.environmentId!==void 0&&!yb({version:1,id:i.environmentId,name:"Host",kind:"hub",entryPath:"/"}))throw new Error("无效的环境身份。");return{address:ed(i.address),name:i.name.trim(),...i.environmentId?{environmentId:i.environmentId}:{}}}function ro(t){const i=t.getItem(Wf);if(i===null)return[];if(i.length>1e5)throw new Error("连接记录过大,请清理当前工作台的连接记录。");const l=JSON.parse(i);if(!Array.isArray(l)||l.length>bb)throw new Error("连接记录格式无效。");return l.map(vb)}function Eg(t,i){const l=vb(i),a=ro(t),o=a.find(u=>u.address===l.address);if(o?.environmentId&&l.environmentId&&o.environmentId!==l.environmentId)throw new Error("这个地址的环境身份已变化。请确认目标后,删除旧连接再添加。");const f=[...a.filter(u=>u.address!==l.address),{...l,...o?.environmentId?{environmentId:o.environmentId}:{}}];if(f.length>bb)throw new Error("最多保存 32 个环境,请先移除不再使用的连接。");return t.setItem(Wf,JSON.stringify(f)),f}function N1(t,i){const l=ro(t).filter(a=>a.address!==ed(i));return t.setItem(Wf,JSON.stringify(l)),l}function A1(t,i,l){const a=t.find(o=>o.address===i+l.entryPath);if(a?.environmentId&&a.environmentId!==l.id)throw new Error("当前地址对应的环境已变化,请核对项目后重新保存连接。")}function td({discover:t=!0,navigate:i}){const[l,a]=w.useState(!1),[o,f]=w.useState(),[u,p]=w.useState([]),[h,m]=w.useState(""),[y,b]=w.useState(""),[x,v]=w.useState(""),j=w.useRef(null),z=w.useRef(null);w.useEffect(()=>{try{p(ro(window.localStorage))}catch{v("无法读取连接记录。当前项目仍可使用。")}},[]),w.useEffect(()=>{if(!t)return;const T=new AbortController;return qe("/api/v1/environment",{signal:T.signal}).then(M=>{if(!T.signal.aborted){if(!yb(M))throw new Error("环境信息无效,请更新工作台后重试。");f(M),A1(ro(window.localStorage),window.location.origin,M)}}).catch(M=>{T.signal.aborted||M instanceof Ke&&[401,404].includes(M.status)||v(M instanceof Error?M.message:"无法读取环境信息。")}),()=>T.abort()},[t]),w.useEffect(()=>{l&&(j.current?.showModal(),z.current?.focus())},[l]);const A=T=>{try{p(T()),v("")}catch(M){v(M instanceof Error?M.message:"保存连接失败。")}},N=T=>{const M=ed(T);a(!1),i?i(M):window.location.assign(M)};return c.jsxs("div",{className:"environment-switcher",children:[c.jsxs("button",{type:"button",className:"ghost environment-trigger",onClick:()=>a(!0),children:[o?.name??"连接环境",c.jsx("span",{"aria-hidden":"true",children:" ▾"})]}),l?c.jsxs("dialog",{ref:j,className:"environment-dialog","aria-labelledby":"environment-title",onCancel:()=>a(!1),onClose:()=>a(!1),children:[c.jsxs("header",{children:[c.jsx("h2",{id:"environment-title",children:"电脑与云端"}),c.jsx("button",{ref:z,type:"button",className:"ghost",onClick:()=>a(!1),children:"关闭"})]}),c.jsx("p",{children:"打开目标环境后选择项目。切换入口不会移动文件或正在运行的任务。"}),c.jsxs("p",{className:"environment-location",children:["当前地址:",window.location.origin]}),x?c.jsx("p",{role:"alert",className:"form-error",children:x}):null,o?c.jsx("button",{type:"button",className:"library-button",onClick:()=>A(()=>Eg(window.localStorage,{name:o.name,address:window.location.origin+o.entryPath,environmentId:o.id})),children:"保存当前环境"}):null,c.jsx("ul",{className:"environment-list",children:u.map(T=>c.jsxs("li",{children:[c.jsxs("div",{children:[c.jsx("strong",{children:T.name}),c.jsx("small",{children:T.address})]}),c.jsx("button",{type:"button",className:"library-button",onClick:()=>N(T.address),children:"打开"}),c.jsx("button",{type:"button",className:"ghost","aria-label":`移除 ${T.name}`,onClick:()=>A(()=>N1(window.localStorage,T.address)),children:"移除"})]},T.address))}),c.jsxs("form",{onSubmit:T=>{T.preventDefault(),A(()=>Eg(window.localStorage,{name:h,address:y.trim()}))},children:[c.jsxs("label",{children:["连接名称",c.jsx("input",{required:!0,maxLength:80,value:h,onChange:T=>m(T.target.value),placeholder:"例如:家里的电脑"})]}),c.jsxs("label",{children:["工作台地址",c.jsx("input",{required:!0,type:"url",maxLength:2048,value:y,onChange:T=>b(T.target.value),placeholder:"https://example.com/"})]}),c.jsx("button",{type:"submit",className:"library-button primary",children:"添加连接"})]}),c.jsx("p",{className:"environment-hint",children:"连接记录保存在当前工作台的浏览器存储中。目标环境需要单独登录或配对,请勿保存带配对令牌的地址。未连接的环境不会显示为在线。"})]}):null]})}function T1({session:t,onClose:i,onAuthLost:l}){const[a,o]=w.useState([]),[f,u]=w.useState(""),[p,h]=w.useState("loading"),m=w.useRef(null),y=w.useCallback(v=>{v instanceof Ke&&v.status===401?l():u(v instanceof Error?v.message:"操作失败,请重试。")},[l]);w.useEffect(()=>{let v=!0;return m.current?.showModal(),qe("/api/v1/auth/sessions").then(j=>{v&&o(j.sessions)}).catch(j=>{v&&y(j)}).finally(()=>{v&&h(null)}),()=>{v=!1}},[y]);const b=async v=>{h(v.id),u("");try{await qe(`/api/v1/auth/sessions/${encodeURIComponent(v.id)}`,{method:"DELETE"}),v.current?l():o(j=>j.filter(z=>z.id!==v.id))}catch(j){y(j)}finally{h(null)}},x=async()=>{h("logout"),u("");try{await Rf("/api/v1/auth/logout"),l()}catch(v){y(v)}finally{h(null)}};return c.jsxs("dialog",{className:"devices-dialog",ref:m,onCancel:i,"aria-labelledby":"devices-title",children:[c.jsxs("div",{className:"dialog-head",children:[c.jsx("h2",{id:"devices-title",children:"账号与设备"}),c.jsx("button",{className:"ghost",onClick:i,"aria-label":"关闭",children:"×"})]}),c.jsxs("p",{className:"muted",children:[t?.username," · ",t?.deviceName||"当前设备"]}),f?c.jsx("p",{className:"form-error",role:"alert",children:f}):null,p==="loading"?c.jsx("p",{role:"status",children:"正在读取设备…"}):null,c.jsx("ul",{className:"device-list",children:a.map(v=>c.jsxs("li",{children:[c.jsxs("div",{children:[c.jsxs("strong",{children:[v.deviceName||"未命名设备",v.current?"(当前)":""]}),c.jsxs("span",{children:["最近活动 ",new Date(v.lastSeenAt).toLocaleString()]})]}),c.jsx("button",{className:"ghost",disabled:p!==null,onClick:()=>{b(v)},children:p===v.id?"处理中…":"撤销登录"})]},v.id))}),c.jsx("button",{className:"stop",disabled:p!==null,onClick:()=>{x()},children:"退出当前设备"})]})}function R1(t){if(!(!t||t.length>2048))try{const i=new URL(t);return i.origin!==t||i.username||i.password||i.pathname!=="/"||i.search||i.hash||i.protocol!=="https:"&&!(i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))?void 0:`${i.origin}/api/v1/account/manage`}catch{return}}function xb({pending:t,error:i,onLogout:l,accountOrigin:a}){const o=R1(a);return c.jsxs("div",{className:"cloud-account-controls",children:[c.jsx("span",{children:"Cloud 工作台"}),o?c.jsx("a",{className:"library-button",href:o,target:"_blank",rel:"noopener noreferrer",children:"账号资料"}):c.jsx("button",{className:"library-button",disabled:!0,title:"此工作台尚未提供账号服务地址",children:"账号资料"}),c.jsx("button",{className:"library-button",disabled:t,onClick:l,children:t?"正在退出…":"退出此 Cloud 工作台"}),i?c.jsx("p",{className:"form-error",role:"alert",children:i}):null]})}function Oc(t){return{expectedRevision:t?t.revision:null,id:t?.id??"",catalogId:t?.catalogId??"",model:t?.model??"",baseUrl:t?.baseUrl??"",apiKey:""}}function z1(t){const i={id:t.id.trim(),catalogId:t.catalogId,model:t.model.trim(),baseUrl:t.baseUrl.trim()};return t.expectedRevision!==void 0&&(i.expectedRevision=t.expectedRevision),t.apiKey.trim()&&(i.apiKey=t.apiKey.trim()),i}function nd(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 Sb(t){return nd(await qe("/api/v1/configuration",{signal:t}))}async function id(t,i,l){return nd(await qe(`/api/v1/configuration/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i),signal:l}))}function D1(t,i){return id("connections",z1(t),i)}function _1(t,i){return id("defaults",t,i)}function M1(t,i,l){return id("skills",{name:t,enabled:i},l)}function wb(t){const i=t instanceof Error?t.message:"设置更新失败,请重试。",l={"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 l[i]?l[i]:/^(id|catalogId|model|text|auxText|apiKey) is invalid$/.exec(i)?"配置字段无效,请检查名称、模型与密钥后重试。":i}async function O1(t,i,l,a){return nd(await qe("/api/v1/configuration/connections",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,...i?{replacementText:i}:{},...a?{expectedRevision:a}:{}}),signal:l}))}async function L1(t,i){const l=Ca(),a=xt("/api/v1/configuration/connections/probe"),o=xt("/api/v1/configuration/connections/probe/cancel");let f;try{f=await qe(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,requestId:l}),signal:i})}catch(u){throw i?.aborted&&await qe(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:l}),signal:AbortSignal.timeout(2e3)}).catch(()=>{}),u}if(!f||f.connectionId!==t||typeof f.ok!="boolean"||typeof f.message!="string"||typeof f.code!="string"||!Number.isFinite(f.latencyMs))throw new Error("服务端返回了无效的测试结果,请重试。");return f}const rd="/api/v1/skills";async function Ng(t){const i=await qe(rd,{signal:t});if(!i||!Array.isArray(i.skills)||!Array.isArray(i.directories))throw new Error("Skills 列表读取失败,请刷新重试。");return i}async function B1(t,i){const l=await qe(`${rd}/detail?name=${encodeURIComponent(t)}`,{signal:i});if(l.name!==t||typeof l.content!="string"||typeof l.revision!="string")throw new Error("Skill 内容读取失败,请重试。");return l}function br(t,i,l,a){return qe(`${rd}${t}`,{method:i,headers:{"Content-Type":"application/json"},body:JSON.stringify(l),signal:a})}const U1=(t,i,l)=>br("/local","POST",{name:t,content:i},l),I1=(t,i,l,a)=>br("/local","PUT",{name:t,content:i,revision:l},a),q1=(t,i,l)=>br("/local","DELETE",{name:t,revision:i},l),H1=(t,i)=>br("/github/preview","POST",{url:t.trim()},i),V1=(t,i,l,a)=>br("/github/install","POST",{reviewToken:t,pathInRepo:i,name:l.trim()},a),Y1=(t,i,l)=>br("/github/update-preview","POST",{name:t,revision:i},l),G1=(t,i)=>br("/github/update","POST",{reviewToken:t},i);function Fs(t){return`---
10
+ name: ${t||"my-skill"}
11
+ description: 描述这个 Skill 适合处理什么任务
12
+ ---
13
+
14
+ # 工作方式
15
+
16
+ 在这里写下具体步骤、输入要求和完成标准。
17
+ `}function _f(t){return/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(t)&&!t.includes("..")}function F1(t,i,l){const a=i.trim().toLocaleLowerCase();return t.filter(o=>(l==="all"||o.source===l)&&(!a||`${o.name} ${o.description}`.toLocaleLowerCase().includes(a)))}const Ag={project:"工作区",user:"用户级",plugin:"插件","panel-app":"Panel App"};function $1({onAuthLost:t,onChanged:i,onDirtyChange:l,configurationVersion:a=0}){const[o,f]=w.useState(null),[u,p]=w.useState(null),[h,m]=w.useState(""),[y,b]=w.useState("all"),[x,v]=w.useState(""),[j,z]=w.useState(""),[A,N]=w.useState(""),[T,M]=w.useState(0),[G,ae]=w.useState(!1),[D,H]=w.useState(!1),W=w.useRef(null),q=w.useRef(null),C=w.useRef(!1),L=w.useRef({onAuthLost:t,onChanged:i});L.current={onAuthLost:t,onChanged:i};const B=w.useRef(null),Q=w.useRef(null),J=w.useCallback(k=>{k instanceof Ke&&k.status===401?L.current.onAuthLost():z(k instanceof Error?k.message:"操作失败,请重试。")},[]);w.useEffect(()=>()=>{W.current?.abort(),q.current?.abort()},[]),w.useEffect(()=>{if(W.current){C.current=!0;return}const k=new AbortController;return q.current=k,Ng(k.signal).then(O=>{k.signal.aborted||f(O)}).catch(O=>{k.signal.aborted||J(O)}),()=>k.abort()},[T,a,J]),w.useEffect(()=>{u&&B.current?.focus()},[u?.kind]);const K=k=>{Q.current=document.activeElement,z(""),N(""),ae(!1),H(!1),p(k)},I=()=>{p(null),ae(!1),H(!1),z(""),Q.current?.focus()},Y=()=>{if(!W.current){if(G){H(!0);return}I()}},X=async(k,O,te=!1)=>{if(W.current)return;q.current?.abort();const R=new AbortController;W.current=R,v(k),z(""),N("");try{const ee=await O(R.signal);if(R.signal.aborted)return;if(te){try{const ve=await Ng(R.signal);R.signal.aborted||f(ve)}catch(ve){if(ve instanceof Ke&&ve.status===401)throw ve;R.signal.aborted||z("操作已完成,但列表刷新失败。请点击刷新查看最新状态。")}if(R.signal.aborted)return;N(ee.message||"设置已保存,下次任务生效。"),L.current.onChanged?.()}return ee}catch(ee){R.signal.aborted||J(ee);return}finally{W.current===R&&(W.current=null),R.signal.aborted||(v(""),C.current&&(C.current=!1,M(ee=>ee+1)))}};w.useEffect(()=>(l?.(G||!!x),()=>l?.(!1)),[G,x,l]);const pe=F1(o?.skills??[],h,y);return c.jsxs("section",{className:"hub-skills","aria-labelledby":"skills-title",onKeyDown:k=>{k.key==="Escape"&&u&&!x&&(k.preventDefault(),Y())},children:[c.jsxs("header",{className:"skills-heading",children:[c.jsxs("div",{children:[c.jsx("span",{className:"skills-eyebrow",children:"工作区能力"}),c.jsx("h1",{id:"skills-title",children:"Skills"}),c.jsx("p",{children:"创建工作说明,导入社区技能,把常用流程留在工作区。"})]}),c.jsxs("div",{className:"skills-actions",children:[c.jsx("button",{className:"config-button",disabled:!!x||!!u,onClick:()=>K({kind:"import"}),children:"从 GitHub 导入"}),c.jsx("button",{className:"config-button config-button-primary",disabled:!!x||!!u,onClick:()=>K({kind:"create"}),children:"+ 创建 Skill"})]})]}),j&&c.jsx("div",{className:"config-message config-error",role:"alert",children:j}),A&&c.jsx("div",{className:"config-message config-success",role:"status",children:A}),x&&c.jsxs("p",{className:"skills-progress",role:"status",children:[x,"…"]}),u&&c.jsxs("section",{className:"skills-workspace-panel","aria-labelledby":"skills-panel-title",children:[c.jsxs("header",{children:[c.jsx("h2",{id:"skills-panel-title",ref:B,tabIndex:-1,children:u.kind==="create"?"创建 Skill":u.kind==="detail"?u.detail.editable?`编辑 ${u.detail.name}`:u.detail.name:u.kind==="import"?"从 GitHub 导入":u.kind==="update"?`更新 ${u.preview.name}`:`移除 ${u.skill.name}`}),c.jsx("button",{className:"config-button config-button-quiet",disabled:!!x,onClick:Y,children:"关闭"})]}),D&&c.jsxs("div",{className:"skills-discard-confirm",role:"alert",children:[c.jsx("p",{children:"还有未保存的修改。关闭会丢弃这些修改。"}),c.jsxs("div",{className:"skills-actions",children:[c.jsx("button",{className:"config-button",onClick:()=>H(!1),children:"继续编辑"}),c.jsx("button",{className:"config-button skills-danger",onClick:I,children:"放弃修改并关闭"})]})]}),(u.kind==="create"||u.kind==="detail")&&c.jsx(Q1,{detail:u.kind==="detail"?u.detail:void 0,busy:!!x,run:X,onSaved:I,onDirtyChange:ae},u.kind==="detail"?u.detail.name+u.detail.revision:"create"),u.kind==="import"&&c.jsx(X1,{preview:u.preview,busy:!!x,run:X,onPreview:k=>p({kind:"import",preview:k}),onInstalled:I},u.preview?.reviewToken??"url"),u.kind==="update"&&c.jsx(K1,{preview:u.preview,busy:!!x,run:X,onUpdated:I}),u.kind==="remove"&&c.jsxs("div",{className:"skills-remove-confirm",children:[c.jsxs("p",{children:["确认从当前工作区移除 ",c.jsx("strong",{children:u.skill.name}),"?它的 SKILL.md、脚本和资源文件都会移除。"]}),c.jsx("p",{className:"config-help",children:"已保存的对话会保留。其他设备下一次运行任务时将不再使用这个工作区 Skill。"}),c.jsxs("div",{className:"skills-actions",children:[c.jsx("button",{className:"config-button",disabled:!!x,onClick:Y,children:"取消"}),c.jsx("button",{className:"config-button skills-danger",disabled:!!x,onClick:()=>{X("正在移除 Skill",k=>q1(u.skill.name,u.skill.revision,k),!0).then(k=>{k&&I()})},children:"确认移除"})]})]})]}),c.jsxs("div",{className:"skills-filter",children:[c.jsxs("label",{children:[c.jsx("span",{className:"config-sr-only",children:"搜索 Skills"}),c.jsx("input",{type:"search","aria-label":"搜索 Skills",value:h,onChange:k=>m(k.target.value),placeholder:"搜索名称或用途…"})]}),c.jsxs("select",{"aria-label":"Skill 来源",value:y,onChange:k=>b(k.target.value),children:[c.jsx("option",{value:"all",children:"全部来源"}),Object.entries(Ag).map(([k,O])=>c.jsx("option",{value:k,children:O},k))]}),c.jsx("button",{className:"config-button config-button-quiet",disabled:!!x,onClick:()=>{z(""),M(k=>k+1)},children:"刷新"})]}),!o&&!j?c.jsx("p",{className:"config-help",children:"正在读取 Skills…"}):o?c.jsxs("p",{className:"skills-count",children:[pe.length===o.skills.length?`${pe.length} 个 Skill`:`显示 ${pe.length} / ${o.skills.length} 个 Skill`," · ",o.skills.filter(k=>k.enabled).length," 个已启用"]}):null,o&&!pe.length&&c.jsxs("div",{className:"skills-empty",children:[c.jsx("h2",{children:h||y!=="all"?"没有匹配的 Skills":"从一个常用流程开始"}),c.jsx("p",{children:h||y!=="all"?"调整搜索词或来源筛选。":"创建自己的 Skill,或粘贴 GitHub 地址导入完整的社区技能。"})]}),c.jsx("div",{className:"skills-list",children:pe.map(k=>c.jsxs("article",{className:"skills-card",children:[c.jsxs("div",{className:"skills-card-heading",children:[c.jsxs("div",{children:[c.jsx("h2",{children:k.name}),c.jsx("span",{className:"config-badge",children:Ag[k.source]}),k.origin&&c.jsx("span",{className:"config-badge",children:"GitHub"})]}),c.jsx("button",{className:"config-switch",role:"switch","aria-checked":k.enabled,"aria-label":`${k.enabled?"停用":"启用"} ${k.name}`,disabled:!!x||!!k.disabledReason,title:k.disabledReason,onClick:()=>{X("正在更新 Skill",async O=>(await M1(k.name,!k.enabled,O),{ok:!0,name:k.name,message:k.enabled?"Skill 已停用,下次任务生效。":"Skill 已启用,下次任务生效。"}),!0)},children:c.jsx("span",{})})]}),c.jsx("p",{children:k.description||"暂未填写用途描述。"}),k.origin&&c.jsxs("p",{className:"skills-source",children:[k.origin.url.replace("https://github.com/","")," · ",k.origin.ref," ·"," ",k.origin.commit.slice(0,8)]}),k.readOnlyReason&&c.jsx("p",{className:"config-help",children:k.readOnlyReason}),k.disabledReason&&c.jsx("p",{className:"config-help",children:k.disabledReason}),c.jsxs("footer",{className:"skills-actions",children:[c.jsx("button",{className:"config-button config-button-quiet",disabled:!!x||!!u,onClick:()=>{Q.current=document.activeElement,X("正在读取 Skill",O=>B1(k.name,O)).then(O=>{O&&K({kind:"detail",detail:O})})},children:k.editable?"查看与编辑":"查看说明"}),k.editable&&k.origin&&c.jsx("button",{className:"config-button config-button-quiet",disabled:!!x||!!u,onClick:()=>{X("正在检查来源更新",O=>Y1(k.name,k.revision,O)).then(O=>{O?.changed?K({kind:"update",preview:O}):O&&N(`${k.name} 已是最新版本。`)})},children:"检查更新"}),k.removable&&c.jsx("button",{className:"config-button config-button-quiet skills-remove",disabled:!!x||!!u,onClick:()=>K({kind:"remove",skill:k}),children:"移除"})]})]},k.name))}),o&&c.jsxs("details",{className:"skills-directories",children:[c.jsx("summary",{children:"Skills 存在哪里"}),c.jsx("p",{children:"这里管理当前工作区。用户级、插件和 Panel App 的 Skills 可以查看和启停,安装内容由各自来源管理。"}),c.jsx("ul",{children:o.directories.map(k=>c.jsx("li",{children:c.jsx("code",{children:k})},k))})]})]})}function Q1({detail:t,busy:i,run:l,onSaved:a,onDirtyChange:o}){const[f,u]=w.useState(t?.name??"my-skill"),[p,h]=w.useState(t?.content??Fs("my-skill")),m=p!==t?.content,y=!t||t.editable;return w.useEffect(()=>{o(y&&(t?p!==t.content:f!=="my-skill"||p!==Fs("my-skill")))},[p,f,t,y,o]),c.jsx("form",{className:"skills-editor",onSubmit:b=>{b.preventDefault(),l(t?"正在保存 Skill":"正在创建 Skill",x=>t?I1(t.name,p,t.revision,x):U1(f.trim(),p,x),!0).then(x=>{x&&a()})},children:c.jsxs("fieldset",{disabled:i,children:[!t&&c.jsxs("label",{children:[c.jsx("span",{children:"名称"}),c.jsx("input",{required:!0,value:f,maxLength:128,onChange:b=>{const x=b.target.value;p===Fs(f)&&h(Fs(x)),u(x)},"aria-describedby":"skill-name-help","aria-label":"Skill 名称"}),c.jsx("small",{id:"skill-name-help",children:"字母、数字、短横线、下划线或点;创建后名称保持不变。"}),!_f(f)&&c.jsx("span",{className:"skills-field-error",children:"请输入有效名称。"})]}),c.jsxs("label",{children:[c.jsxs("span",{children:[y?"SKILL.md":"说明",t&&y&&m&&c.jsx("small",{className:"skills-unsaved",children:"未保存"})]}),c.jsx("textarea",{value:p,readOnly:!y,onChange:b=>h(b.target.value),rows:18,spellCheck:!1,"aria-label":"SKILL.md 内容"})]}),t?.origin&&y&&c.jsx("p",{className:"config-help",children:"手动编辑会保留 GitHub 来源;以后更新来源时,会预览将替换的完整内容。"}),y&&c.jsxs("div",{className:"skills-actions",children:[c.jsx("span",{className:"config-help",children:"支持 Markdown 和 YAML Frontmatter。变更在下一次任务中生效。"}),c.jsx("button",{className:"config-button config-button-primary",type:"submit",disabled:!p.trim()||!t&&!_f(f)||!!t&&!m,children:t?"保存修改":"创建 Skill"})]})]})})}function X1({preview:t,busy:i,run:l,onPreview:a,onInstalled:o}){const[f,u]=w.useState(""),[p,h]=w.useState(t?.skills[0]?.pathInRepo??""),[m,y]=w.useState(t?.skills[0]?.name??"");return t?c.jsxs("form",{className:"skills-import-preview",onSubmit:b=>{b.preventDefault(),l("正在导入 Skill 与资源",x=>V1(t.reviewToken,p,m,x),!0).then(x=>{x&&o()})},children:[c.jsxs("p",{children:[c.jsx("a",{href:t.repoUrl,target:"_blank",rel:"noreferrer",children:t.repoUrl.replace("https://github.com/","")})," ",c.jsx("span",{className:"config-badge",children:t.commit.slice(0,8)})]}),t.warning&&c.jsx("p",{className:"config-help",children:t.warning}),c.jsxs("fieldset",{disabled:i,children:[c.jsx("legend",{children:"选择一个 Skill"}),c.jsx("div",{className:"skills-source-choices",children:t.skills.map(b=>c.jsxs("label",{children:[c.jsx("input",{type:"radio",name:"github-skill",checked:p===b.pathInRepo,onChange:()=>{h(b.pathInRepo),y(b.name)}}),c.jsxs("span",{children:[c.jsx("strong",{children:b.name}),c.jsx("small",{children:b.description||b.pathInRepo}),b.alreadyInstalled&&c.jsx("small",{children:"已有同名 Skill,可修改安装名称。"})]})]},b.pathInRepo))}),!!t.skills.length&&c.jsxs(c.Fragment,{children:[c.jsxs("label",{children:[c.jsx("span",{children:"安装到工作区时使用的名称"}),c.jsx("input",{required:!0,maxLength:128,value:m,onChange:b=>y(b.target.value)})]}),c.jsx("p",{className:"config-help",children:"将导入预览时的确定版本。不会执行其中的脚本。"}),c.jsx("button",{className:"config-button config-button-primary",disabled:!p||!_f(m),type:"submit",children:"确认导入到工作区"})]})]})]}):c.jsxs("form",{className:"skills-import-url",onSubmit:b=>{b.preventDefault(),l("正在检查 GitHub 来源",x=>H1(f,x)).then(x=>{x&&a(x)})},children:[c.jsxs("label",{children:[c.jsx("span",{children:"GitHub 仓库或 Skill 目录地址"}),c.jsx("input",{type:"url",required:!0,value:f,onChange:b=>u(b.target.value),placeholder:"https://github.com/owner/repository/tree/main/skills/example",disabled:i})]}),c.jsx("p",{className:"config-help",children:"先查看可导入的技能,再确认安装。脚本和资源文件会一起保留。"}),c.jsx("button",{className:"config-button config-button-primary",disabled:i||!f.trim(),children:"预览来源"})]})}function K1({preview:t,busy:i,run:l,onUpdated:a}){return c.jsxs("div",{className:"skills-update-preview",children:[c.jsxs("p",{children:["来源版本 ",c.jsx("code",{children:t.currentCommit.slice(0,8)})," →"," ",c.jsx("code",{children:t.latestCommit.slice(0,8)})]}),c.jsx("p",{children:"确认后会用下方版本替换此 Skill 的说明、脚本和资源,包括你在其中做过的本地修改。"}),c.jsxs("details",{children:[c.jsxs("summary",{children:["查看将导入的 ",t.files?.length??0," 个文件"]}),c.jsx("ul",{children:t.files?.map(o=>c.jsxs("li",{children:[c.jsx("code",{children:o.path}),c.jsxs("span",{children:[Math.ceil(o.size/1024)," KB",o.executable?" · 可执行脚本":""]})]},o.path))})]}),c.jsxs("label",{children:[c.jsx("span",{children:"新的 SKILL.md"}),c.jsx("textarea",{value:t.content??"",readOnly:!0,rows:16,"aria-label":"更新后的 SKILL.md"})]}),c.jsx("button",{className:"config-button config-button-primary",disabled:i||!t.reviewToken,onClick:()=>{l("正在更新 Skill",o=>G1(t.reviewToken,o),!0).then(o=>{o&&a()})},children:"确认更新到预览版本"})]})}function P1(t){const i=l=>l.map((a,o)=>({id:`stored-${o}`,name:a,value:"",stored:!0,removed:!1}));return{name:t?.name??"",transport:t?.transport??"stdio",command:t?.command??"",args:"",clearArgs:!1,url:t?.url??"",env:i(t?.envKeys??[]),headers:i(t?.headerKeys??[]),envHeaders:Object.entries(t?.envHeaders??{}).map(([l,a],o)=>({id:`stored-${o}`,name:l,value:a,initialValue:a,stored:!0,removed:!1})),envVars:(t?.envVars??[]).join(`
18
+ `),bearerTokenEnvVar:t?.bearerTokenEnvVar??"",credentialRef:t?.credentialRef??"",enabled:t?.enabled??!0,restrictTools:t?.allowedTools!==void 0,allowedTools:(t?.allowedTools??[]).join(`
19
+ `),disabledTools:(t?.disabledTools??[]).join(`
20
+ `),reuseStoredSecrets:!1}}function Lc(t){return t.split(/\r?\n/).map(i=>i.trim()).filter(Boolean)}function Z1(t,i){const l={},a=new Set;for(const o of t){if(!o.stored&&o.removed)continue;const f=o.name.trim();if(["__proto__","prototype","constructor"].includes(f))throw new Error(`${i}名称无效。`);if(!f&&!o.value&&!o.stored)continue;if(!f||!o.stored&&!o.value)throw new Error(`请完整填写${i}的名称和值,或移除空行。`);const u=i==="环境变量"?f:f.toLowerCase();if(a.has(u))throw new Error(`${i}名称不能重复。`);a.add(u),o.removed?l[f]=null:o.value&&o.value!==o.initialValue&&(l[f]=o.value)}return l}function Tg(t){try{return new URL(t).origin}catch{return""}}function J1(t,i){if(!i)return!1;const l=i.envKeys.length||i.headerKeys.length||i.envVars.length||Object.keys(i.envHeaders).length||i.credentialRef||i.bearerTokenEnvVar||i.argsCount,a=t.transport!==i.transport||(t.transport==="stdio"?t.command.trim()!==i.command||!!t.args.trim()||t.clearArgs:Tg(t.url)!==Tg(i.url??""));return!!l&&a}function W1(t,i){const l={name:t.name.trim()};(!i||t.transport!==i.transport)&&(l.transport=t.transport),(!i||t.enabled!==i.enabled)&&(l.enabled=t.enabled),t.transport==="stdio"?((!i||t.command.trim()!==i.command)&&(l.command=t.command.trim()),t.clearArgs?l.args=[]:t.args.trim()&&(l.args=t.args.split(/\r?\n/).filter(u=>u.length>0))):(!i||t.url.trim()!==i.url)&&(l.url=t.url.trim());for(const[u,p]of[["env","环境变量"],["headers","请求头"],["envHeaders","环境变量请求头"]]){const h=Z1(t[u],p);Object.keys(h).length&&(l[u]=h)}const a=Lc(t.envVars);(!i||JSON.stringify(a)!==JSON.stringify(i.envVars))&&(l.envVars=a);for(const u of["bearerTokenEnvVar","credentialRef"])(!i||t[u].trim()!==(i[u]??""))&&(l[u]=t[u].trim()||null);const o=t.restrictTools?Lc(t.allowedTools):void 0;(!i||JSON.stringify(o)!==JSON.stringify(i.allowedTools))&&(l.allowedTools=o??null);const f=Lc(t.disabledTools);return(!i||JSON.stringify(f)!==JSON.stringify(i.disabledTools))&&(l.disabledTools=f),t.reuseStoredSecrets&&(l.reuseStoredSecrets=!0),l}function jb(t){if(!t||typeof t.workspacePath!="string"||!Array.isArray(t.servers)||!Array.isArray(t.removed))throw new Error("服务端返回了无效的 MCP 配置,请刷新重试。");return t}const hl=(t,i="")=>`/api/v1/mcp/servers/${encodeURIComponent(t)}${i}`;async function eS(t){return jb(await qe("/api/v1/mcp",{signal:t}))}async function ho(t,i,l,a){return jb(await qe(t,{method:i,headers:{"Content-Type":"application/json"},...l===void 0?{}:{body:JSON.stringify(l)},signal:a}))}function tS(t,i,l){return ho(i?hl(i.name):"/api/v1/mcp/servers",i?"PUT":"POST",W1(t,i),l)}function nS(t,i,l){return ho(hl(t,"/enabled"),"PUT",{enabled:i},l)}function iS(t,i){return ho(hl(t),"DELETE",void 0,i)}function Rg(t,i){return ho(hl(t,"/inherit"),"POST",{},i)}async function rS(t,i){const l=await qe(hl(t,"/probe"),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}",signal:i});if(l.name!==t||!["ok","error","cancelled"].includes(l.status))throw new Error("服务端返回了无效的连接测试结果。");return l}function zg(t,i,l){return qe(xt(hl(t,"/cancel-probe"),i,l),{method:"POST",headers:{"Content-Type":"application/json"},body:"{}",keepalive:!0})}const lS={local:"工作区本地",project:"工作区配置",user:"用户级",managed:"启动配置",plugin:"插件提供"};function aS({onAuthLost:t,onConfigurationChange:i,configurationVersion:l=0,onDirtyChange:a}){const[o,f]=w.useState(null),[u,p]=w.useState(!0),[h,m]=w.useState(!1),[y,b]=w.useState(!1),[x,v]=w.useState(""),[j,z]=w.useState(""),[A,N]=w.useState(null),[T,M]=w.useState(null),[G,ae]=w.useState(""),[D,H]=w.useState({}),[W,q]=w.useState(null),[C,L]=w.useState(0),B=w.useRef({onAuthLost:t,onConfigurationChange:i,onDirtyChange:a});B.current={onAuthLost:t,onConfigurationChange:i,onDirtyChange:a};const Q=w.useRef(!1),J=w.useRef(null),K=w.useRef(null),I=w.useRef(null),Y=w.useRef(0),X=w.useRef(!1),pe=w.useRef(l);w.useEffect(()=>{B.current.onDirtyChange?.(y||h)},[y,h]);const k=w.useCallback(F=>{F instanceof Ke&&F.status===401?B.current.onAuthLost():v(F instanceof Error?F.message:"MCP 操作失败,请重试。")},[]);w.useEffect(()=>(Q.current=!0,()=>{Q.current=!1,B.current.onDirtyChange?.(!1),K.current?.abort();const F=I.current;F&&(F.controller.abort(),zg(F.name,F.workspace,F.projectId).catch(()=>{}))}),[]),w.useEffect(()=>{pe.current!==l&&(pe.current=l,K.current?X.current=!0:L(F=>F+1))},[l]),w.useEffect(()=>{const F=new AbortController;J.current=F;const ke=Date.now(),ze=++Y.current;return p(!0),v(""),eS(F.signal).then(Le=>{!F.signal.aborted&&ze===Y.current&&(f(Le),H(Ee=>Object.fromEntries(Object.entries(Ee).filter(([,Xe])=>Date.parse(Xe.checkedAt)>=ke))))}).catch(Le=>{!F.signal.aborted&&ze===Y.current&&k(Le)}).finally(()=>{!F.signal.aborted&&ze===Y.current&&p(!1)}),()=>F.abort()},[C,k]);const O=async(F,ke="MCP 设置已保存,任务进程会加载新的配置。")=>{if(K.current||I.current)return!1;J.current?.abort();const ze=++Y.current,Le=new AbortController;K.current=Le,m(!0),p(!1),v(""),z("");try{const Ee=await F(Le.signal);return!Q.current||Le.signal.aborted||ze!==Y.current?!1:(f(Ee),H({}),z(ke),B.current.onConfigurationChange?.(),!0)}catch(Ee){return Q.current&&!Le.signal.aborted&&k(Ee),!1}finally{K.current===Le&&(K.current=null),Q.current&&!Le.signal.aborted&&(m(!1),X.current&&(X.current=!1,L(Ee=>Ee+1)))}},te=async F=>{if(I.current||K.current)return;const ke=new AbortController;I.current={name:F,controller:ke,workspace:io()??"",projectId:Sa()},q(F),v(""),z(""),H(ze=>{const Le={...ze};return delete Le[F],Le});try{const ze=await rS(F,ke.signal);Q.current&&!ke.signal.aborted&&H(Le=>({...Le,[F]:ze}))}catch(ze){Q.current&&!ke.signal.aborted&&k(ze)}finally{I.current?.controller===ke&&(I.current=null),Q.current&&q(null)}},R=async()=>{const F=I.current;if(F)try{await zg(F.name,F.workspace,F.projectId)}catch(ke){Q.current&&k(ke)}finally{F.controller.abort(),I.current===F&&(I.current=null),Q.current&&(q(null),H(ke=>({...ke,[F.name]:{name:F.name,status:"cancelled",checkedAt:new Date().toISOString(),durationMs:0,error:{code:"cancelled",message:"测试已取消。"}}})))}},ee=h||u||W!==null,ve=G.trim().toLocaleLowerCase(),le=[...o?.servers??[]];A?.kind==="edit"&&!le.some(F=>F.name===A.name)&&le.push(A.original);const ue=le.filter(F=>!ve||F.name.toLocaleLowerCase().includes(ve)||A?.kind==="edit"&&A.name===F.name),xe=A?.kind==="edit"?le.find(F=>F.name===A.name):void 0;return c.jsxs("div",{className:"hub-mcp",children:[c.jsxs("div",{className:"config-section-heading hub-mcp-toolbar",children:[c.jsxs("label",{className:"config-search",children:[c.jsx("span",{"aria-hidden":"true",children:"⌕"}),c.jsx("input",{type:"search",value:G,onChange:F=>ae(F.target.value),placeholder:"搜索 MCP 服务…","aria-label":"搜索 MCP 服务"})]}),c.jsxs("div",{className:"hub-mcp-toolbar-actions",children:[c.jsx("button",{className:"config-button config-button-quiet",disabled:ee,onClick:()=>L(F=>F+1),children:"刷新 MCP"}),c.jsx("button",{className:"config-button",disabled:ee||A!==null,onClick:()=>N({kind:"new"}),children:"+ 添加服务"})]})]}),x&&c.jsx("p",{className:"config-message config-error",role:"alert",children:x}),j&&c.jsx("p",{className:"config-message config-success",role:"status",children:j}),h&&c.jsx("p",{className:"config-help",role:"status",children:"正在保存 MCP 配置…"}),u&&!o&&c.jsx("p",{className:"config-help",role:"status",children:"正在读取 MCP 配置…"}),A?.kind==="new"&&c.jsxs("div",{className:"config-card hub-mcp-editor-card",children:[c.jsx("h2",{children:"添加 MCP 服务"}),c.jsx(Dg,{disabled:ee,save:O,onDone:()=>N(null),onProbe:F=>{te(F)},onDirtyChange:b})]}),!ue.length&&o&&A?.kind!=="new"&&c.jsxs("div",{className:"config-empty",children:[c.jsx("span",{"aria-hidden":"true",children:"⌘"}),c.jsx("h3",{children:ve?"没有匹配的服务":"连接你的工具与数据"}),c.jsx("p",{children:ve?"试试其他服务名称。":"添加运行 CodeShell 的设备上的命令,或连接提供 MCP 接口的 HTTP 服务。"})]}),c.jsx("div",{className:"hub-mcp-list",children:ue.map(F=>c.jsxs("article",{className:"config-card hub-mcp-card",children:[c.jsxs("div",{className:"hub-mcp-card-head",children:[c.jsx("span",{className:"config-row-icon","aria-hidden":"true",children:"⌘"}),c.jsxs("div",{className:"config-row-copy",children:[c.jsx("strong",{children:F.name}),c.jsxs("span",{children:[F.transport==="stdio"?"本地命令":F.transport==="inprocess"?"内置工具":"HTTP 服务"," ","· ",lS[F.scope]]})]}),c.jsx("button",{className:"config-switch",type:"button",role:"switch","aria-checked":F.enabled,"aria-label":`${F.enabled?"停用":"启用"} MCP ${F.name}`,disabled:ee||F.pluginDisabled,onClick:()=>{O(ke=>nS(F.name,!F.enabled,ke))},children:c.jsx("span",{})})]}),A?.kind==="edit"&&A.name===F.name&&xe?c.jsx(Dg,{server:xe,disabled:ee,save:O,onDone:()=>N(null),onProbe:ke=>{te(ke)},onDirtyChange:b},F.name):c.jsxs(c.Fragment,{children:[c.jsxs("p",{className:"hub-mcp-endpoint",children:[c.jsx("code",{children:F.transport==="stdio"?F.command:F.url||"由任务进程提供"}),F.argsCount>0&&c.jsxs("span",{children:[F.argsCount," 个已保存参数"]})]}),c.jsxs("div",{className:"hub-mcp-metadata",children:[c.jsx("span",{className:`config-badge${F.enabled?" config-badge-accent":""}`,children:F.enabled?"配置启用":"配置停用"}),F.envKeys.length>0&&c.jsxs("span",{children:[F.envKeys.length," 个环境变量"]}),(F.headerKeys.length>0||F.credentialRef||F.bearerTokenEnvVar||Object.keys(F.envHeaders).length>0)&&c.jsx("span",{children:"已配置认证"}),F.hasLocalOverride&&c.jsx("span",{children:"本地覆盖"})]}),F.source==="plugin"&&c.jsx("p",{className:"config-help",children:F.pluginDisabled?"所属插件已停用。启用插件后,才能启用或测试这个服务。":"连接命令与地址由插件提供,可在此启停或测试。"}),c.jsxs("div",{className:"hub-mcp-card-actions",children:[W===F.name?c.jsx("button",{className:"config-button",onClick:()=>{R()},children:"取消测试"}):c.jsx("button",{className:"config-button",disabled:ee||F.pluginDisabled||F.transport==="inprocess",onClick:()=>{te(F.name)},children:"测试连接"}),F.editable&&c.jsx("button",{className:"config-button config-button-quiet",disabled:ee||A!==null,onClick:()=>{M(null),N({kind:"edit",name:F.name,original:F})},children:"编辑"}),F.hasLocalOverride&&c.jsx("button",{className:"config-button config-button-quiet",disabled:ee,onClick:()=>{O(ke=>Rg(F.name,ke),"已移除本地覆盖,恢复继承配置。")},children:"恢复继承"}),F.deletable&&c.jsx("button",{className:"config-button config-button-quiet hub-mcp-remove",disabled:ee||A!==null,onClick:()=>M(F.name),children:"移除"})]}),T===F.name&&c.jsxs("div",{className:"hub-mcp-delete",role:"alert",children:[c.jsxs("span",{children:["从当前工作区移除 ",F.name,"?其他工作区的配置不受影响。"]}),c.jsxs("div",{children:[c.jsx("button",{className:"config-button config-button-quiet",disabled:ee,onClick:()=>M(null),children:"取消"}),c.jsx("button",{className:"config-button hub-mcp-remove",disabled:ee,onClick:async()=>{await O(ke=>iS(F.name,ke),"已从当前工作区移除服务。")&&M(null)},children:"确认移除"})]})]}),W===F.name&&c.jsx("p",{className:"hub-mcp-probing",role:"status",children:"正在建立测试连接并读取工具列表…"}),D[F.name]&&c.jsx(sS,{result:D[F.name]})]})]},F.name))}),!!o?.removed.length&&c.jsxs("details",{className:"hub-mcp-removed",children:[c.jsxs("summary",{children:["已在当前工作区移除(",o.removed.length,")"]}),o.removed.map(F=>c.jsxs("div",{className:"hub-mcp-removed-row",children:[c.jsx("span",{children:F.name}),c.jsx("button",{className:"config-button config-button-quiet",disabled:ee,onClick:()=>{O(ke=>Rg(F.name,ke),"已恢复继承的 MCP 配置。")},children:"恢复继承"})]},F.name))]}),c.jsx("p",{className:"config-help hub-mcp-explanation",children:"连接使用运行 CodeShell 的设备上的网络、环境和凭据。测试只建立一次短连接并读取工具列表,完成后关闭;不会调用工具或改变启用状态。"})]})}function Dg({server:t,disabled:i,save:l,onDone:a,onProbe:o,onDirtyChange:f}){const u=w.useRef(t).current,[p,h]=w.useState(()=>P1(u)),m=w.useRef(JSON.stringify(p)).current,y=JSON.stringify(p)!==m;w.useEffect(()=>{f(y)},[y,f]),w.useEffect(()=>()=>f(!1),[f]);const[b,x]=w.useState(""),v=(A,N)=>h(T=>({...T,[A]:N})),j=J1(p,u),z=p.transport==="stdio";return c.jsx("form",{className:"hub-mcp-editor",onSubmit:async A=>{A.preventDefault(),x("");const N=A.nativeEvent.submitter?.getAttribute("data-probe")==="true";try{await l(T=>tS(p,u,T))&&(a(),N&&o(p.name.trim()))}catch(T){x(T instanceof Error?T.message:"请检查填写内容。")}},children:c.jsxs("fieldset",{disabled:i,children:[c.jsx("legend",{className:"config-sr-only",children:u?`编辑 MCP ${u.name}`:"新 MCP 服务"}),c.jsxs("div",{className:"config-form-grid",children:[c.jsxs("label",{children:[c.jsx("span",{children:"服务名称"}),c.jsx("input",{required:!0,readOnly:!!u,maxLength:128,pattern:"[A-Za-z0-9][A-Za-z0-9._:\\-]*",value:p.name,onChange:A=>v("name",A.target.value),placeholder:"例如 workspace-tools"})]}),c.jsxs("label",{children:[c.jsx("span",{children:"连接方式"}),c.jsxs("select",{"aria-label":"连接方式",value:p.transport,onChange:A=>v("transport",A.target.value),children:[c.jsx("option",{value:"stdio",children:"本地命令(stdio)"}),c.jsx("option",{value:"streamable-http",children:"HTTP(Streamable HTTP)"}),u?.transport==="sse"&&c.jsx("option",{value:"sse",children:"HTTP(已有 SSE 配置)"})]})]}),z?c.jsxs(c.Fragment,{children:[c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"启动命令"}),c.jsx("input",{required:!0,"aria-label":"启动命令",value:p.command,onChange:A=>v("command",A.target.value),placeholder:"例如 node、uvx 或可执行文件路径"}),c.jsx("small",{children:"在当前工作区执行。命令与参数分别填写。"})]}),c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"命令参数"}),c.jsx("textarea",{"aria-label":"命令参数",rows:3,disabled:p.clearArgs,value:p.args,onChange:A=>v("args",A.target.value),placeholder:u?.argsCount?`已有 ${u.argsCount} 个参数,留空保留。填写后将完整替换。`:"每行一个参数,不需要额外添加引号",autoComplete:"off",spellCheck:!1}),c.jsx("small",{children:"参数可能含密钥,因此不会读回已有值。每一行会作为一个完整参数。"})]}),!!u?.argsCount&&c.jsxs("label",{className:"hub-mcp-check config-full-width",children:[c.jsx("input",{type:"checkbox",checked:p.clearArgs,onChange:A=>v("clearArgs",A.target.checked)}),c.jsx("span",{children:"清空已保存的所有参数"})]})]}):c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"MCP 接口地址"}),c.jsx("input",{type:"url","aria-label":"MCP 接口地址",required:!0,value:p.url,onChange:A=>v("url",A.target.value),placeholder:"https://example.com/mcp"}),u?.urlHasHiddenParts&&c.jsx("small",{children:"已有地址的查询参数已隐藏;不修改地址时会保留。"})]})]}),z?c.jsx(Bc,{title:"环境变量",rows:p.env,onChange:A=>v("env",A)}):c.jsx(Bc,{title:"请求头",rows:p.headers,onChange:A=>v("headers",A)}),c.jsxs("details",{className:"hub-mcp-advanced",children:[c.jsx("summary",{children:"高级配置"}),c.jsx("div",{className:"config-form-grid",children:z?c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"转发运行环境变量"}),c.jsx("textarea",{"aria-label":"转发运行环境变量",rows:2,value:p.envVars,onChange:A=>v("envVars",A.target.value),placeholder:"每行一个环境变量名称,例如 GITHUB_TOKEN"}),c.jsx("small",{children:"只填写名称,实际值在连接时从CodeShell 的启动环境读取。"})]}):c.jsxs(c.Fragment,{children:[c.jsxs("label",{children:[c.jsx("span",{children:"Bearer Token 环境变量"}),c.jsx("input",{"aria-label":"Bearer Token 环境变量",value:p.bearerTokenEnvVar,onChange:A=>v("bearerTokenEnvVar",A.target.value),placeholder:"例如 MCP_ACCESS_TOKEN",autoComplete:"off"}),c.jsx("small",{children:"填写运行环境中的变量名称。"})]}),c.jsxs("label",{children:[c.jsx("span",{children:"已存储的凭据 ID"}),c.jsx("input",{"aria-label":"已存储的凭据 ID",value:p.credentialRef,onChange:A=>v("credentialRef",A.target.value),placeholder:"可选",autoComplete:"off"}),c.jsx("small",{children:"引用已有凭据;优先于 Bearer 环境变量。"})]})]})}),!z&&c.jsx(Bc,{title:"环境变量请求头",rows:p.envHeaders,onChange:A=>v("envHeaders",A),visibleValues:!0}),c.jsxs("label",{className:"hub-mcp-check",children:[c.jsx("input",{type:"checkbox",checked:p.restrictTools,onChange:A=>v("restrictTools",A.target.checked)}),c.jsx("span",{children:"只允许指定工具"})]}),c.jsxs("div",{className:"config-form-grid",children:[p.restrictTools&&c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"允许的工具名称"}),c.jsx("textarea",{rows:2,value:p.allowedTools,onChange:A=>v("allowedTools",A.target.value),placeholder:"每行一个精确工具名称;留空则不开放任何工具"})]}),c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"停用的工具名称"}),c.jsx("textarea",{rows:2,value:p.disabledTools,onChange:A=>v("disabledTools",A.target.value),placeholder:"每行一个精确工具名称,可留空"})]})]})]}),c.jsxs("label",{className:"hub-mcp-check",children:[c.jsx("input",{type:"checkbox",checked:p.enabled,onChange:A=>v("enabled",A.target.checked)}),c.jsx("span",{children:"启用服务,让任务可以使用这些工具"})]}),j&&c.jsxs("label",{className:"hub-mcp-check hub-mcp-reuse",children:[c.jsx("input",{type:"checkbox",required:!0,checked:p.reuseStoredSecrets,onChange:A=>v("reuseStoredSecrets",A.target.checked)}),c.jsx("span",{children:"允许新的启动方式或服务地址使用已保存的参数、环境变量和认证配置。"})]}),b&&c.jsx("p",{className:"config-error config-message",role:"alert",children:b}),c.jsxs("div",{className:"config-form-actions",children:[c.jsx("button",{type:"button",className:"config-button config-button-quiet",onClick:a,children:"取消"}),c.jsx("button",{type:"submit","data-probe":"true",className:"config-button",children:"保存并测试"}),c.jsx("button",{type:"submit",className:"config-button config-button-primary",children:"保存配置"})]})]})})}function Bc({title:t,rows:i,onChange:l,visibleValues:a=!1}){const o=(f,u)=>l(i.map(p=>p.id===f?{...p,...u}:p));return c.jsxs("div",{className:"hub-mcp-keys",children:[c.jsxs("div",{className:"hub-mcp-key-heading",children:[c.jsx("h3",{children:t}),c.jsxs("button",{className:"config-text-button",type:"button",onClick:()=>l([...i,{id:Ca(),name:"",value:"",stored:!1,removed:!1}]),children:["+ 添加",t]})]}),!i.length&&c.jsx("p",{className:"config-help",children:a?"可按请求头名称引用运行环境变量。":"无需此项时可以留空。"}),i.map(f=>c.jsxs("div",{className:`hub-mcp-key-row${f.removed?" hub-mcp-key-removed":""}`,children:[c.jsxs("label",{children:[c.jsxs("span",{className:"config-sr-only",children:[t,"名称"]}),c.jsx("input",{"aria-label":`${t}名称`,value:f.name,readOnly:f.stored,disabled:f.removed,onChange:u=>o(f.id,{name:u.target.value}),placeholder:t==="环境变量"?"例如 API_KEY":"例如 Authorization",autoComplete:"off"})]}),c.jsxs("label",{children:[c.jsxs("span",{className:"config-sr-only",children:[t,"值"]}),c.jsx("input",{"aria-label":`${t} ${f.name||"新条目"} 的值`,type:a?"text":"password",value:f.value,disabled:f.removed,onChange:u=>o(f.id,{value:u.target.value}),placeholder:f.removed?"保存时移除":a?"运行环境变量名称":f.stored?"已配置 · 留空保留":"输入值",autoComplete:a?"off":"new-password",spellCheck:!1})]}),c.jsx("button",{className:"config-button config-button-quiet",type:"button",onClick:()=>f.stored?o(f.id,{removed:!f.removed}):l(i.filter(u=>u.id!==f.id)),children:f.removed?"撤销移除":"移除"})]},f.id)),!!i.length&&!a&&c.jsx("p",{className:"config-help",children:"已有值保留在运行 CodeShell 的设备上;留空保留,填写新值替换,点击“移除”后保存才能删除。"})]})}function sS({result:t}){return c.jsxs("div",{className:`hub-mcp-probe-result hub-mcp-probe-${t.status}`,role:"status",children:[c.jsxs("div",{className:"hub-mcp-probe-summary",children:[c.jsx("strong",{children:t.status==="ok"?"测试连接成功":t.status==="cancelled"?"测试已取消":"连接测试失败"}),c.jsxs("span",{children:[new Date(t.checkedAt).toLocaleTimeString()," ·"," ",t.durationMs<1e3?`${t.durationMs} ms`:`${(t.durationMs/1e3).toFixed(1)} 秒`]})]}),t.error&&c.jsx("p",{children:t.error.message}),t.status==="ok"&&c.jsxs(c.Fragment,{children:[c.jsxs("p",{children:["发现 ",t.toolCount??0," 个工具",t.truncated?"(列表已截取)":"","。测试连接现已关闭。"]}),!!t.tools?.length&&c.jsxs("details",{children:[c.jsx("summary",{children:"查看工具列表"}),c.jsx("ul",{children:t.tools.map((i,l)=>c.jsxs("li",{children:[c.jsxs("div",{children:[c.jsx("code",{children:i.name}),!i.allowed&&c.jsx("span",{className:"config-badge",children:"被工具策略停用"})]}),i.description&&c.jsx("p",{children:i.description})]},`${i.name}-${l}`))})]})]})]})}const oS={overview:{title:"设置",description:"管理当前工作区的模型、Skills 和工具连接。"},models:{title:"模型与连接",description:"选择默认模型,管理工作区使用的服务商连接与凭据。"},skills:{title:"Skills",description:"让 CodeShell 按照你熟悉的工作方式完成任务。"},mcp:{title:"MCP 工具",description:"管理工具连接,测试连接并查看可用工具。"}};function uS(t){return t.section==="skills"?c.jsx($1,{onAuthLost:t.onAuthLost,onDirtyChange:t.onDirtyChange,onChanged:t.onConfigurationChange,configurationVersion:t.configurationVersion}):c.jsx(cS,{...t})}function cS({host:t="hub",section:i,onSectionChange:l,onAuthLost:a,onDirtyChange:o,onConfigurationChange:f,configurationVersion:u=0}){const[p,h]=w.useState(null),[m,y]=w.useState(!0),[b,x]=w.useState(""),[v,j]=w.useState(""),[z,A]=w.useState(null),[N,T]=w.useState(0),M=w.useRef({onAuthLost:a,onConfigurationChange:f});M.current={onAuthLost:a,onConfigurationChange:f};const G=w.useRef(!1),ae=w.useRef(0),D=w.useRef(null),H=w.useRef(null),W=w.useRef(!1),q=w.useRef(u),C=w.useCallback(Q=>{Q instanceof Ke&&Q.status===401?M.current.onAuthLost():x(wb(Q))},[]);w.useEffect(()=>{u!==q.current&&(q.current=u,H.current?W.current=!0:T(Q=>Q+1))},[u]),w.useEffect(()=>(G.current=!0,()=>{G.current=!1,H.current?.abort()}),[]),w.useEffect(()=>{const Q=new AbortController;D.current=Q;const J=++ae.current;return y(!0),x(""),Sb(Q.signal).then(K=>{!Q.signal.aborted&&J===ae.current&&h(K)}).catch(K=>{!Q.signal.aborted&&J===ae.current&&C(K)}).finally(()=>{!Q.signal.aborted&&J===ae.current&&y(!1)}),()=>Q.abort()},[N,C]);const L=async(Q,J)=>{if(H.current)return!1;D.current?.abort();const K=++ae.current,I=new AbortController;H.current=I,y(!1),A(Q),x(""),j("");try{const Y=await J(I.signal);return!G.current||I.signal.aborted||K!==ae.current?!1:(h(Y),j(Y.restartRequired?"设置已保存,重启服务后生效。":"设置已保存,下次运行任务时生效。"),M.current.onConfigurationChange?.(),!0)}catch(Y){return Y instanceof Ke&&Y.status===409&&(W.current=!0),G.current&&!I.signal.aborted&&C(Y),!1}finally{H.current===I&&(H.current=null),G.current&&!I.signal.aborted&&(A(null),W.current&&(W.current=!1,T(Y=>Y+1)))}},B=oS[i];return c.jsxs("section",{className:"hub-settings","aria-labelledby":"hub-settings-title",children:[c.jsxs("div",{className:"hub-settings-heading",children:[c.jsxs("div",{children:[c.jsx("span",{className:"hub-settings-eyebrow",children:t==="desktop"?"桌面工作区":"服务端工作区"}),c.jsx("h1",{id:"hub-settings-title",children:B.title}),c.jsx("p",{children:B.description})]}),c.jsx("button",{className:"config-button config-button-quiet",disabled:m||z!==null,onClick:()=>{j(""),T(Q=>Q+1)},children:m?"读取中…":"刷新"})]}),b&&c.jsx("div",{className:"config-message config-error",role:"alert",children:b}),v&&c.jsx("div",{className:"config-message config-success",role:"status",children:v}),z&&c.jsxs("p",{className:"config-loading",role:"status",children:["正在保存",z,"…"]}),!p&&m?c.jsx("p",{className:"config-loading",role:"status",children:"正在读取工作区设置…"}):null,p&&c.jsxs(c.Fragment,{children:[i==="overview"&&c.jsx(fS,{host:t,configuration:p,onSectionChange:l}),i==="models"&&c.jsx(dS,{configuration:p,disabled:z!==null||m,saving:z!==null,save:L,onDirtyChange:o,onAuthLost:a}),i==="mcp"&&c.jsx(aS,{onAuthLost:a,onDirtyChange:o,onConfigurationChange:f,configurationVersion:u}),c.jsx("p",{className:"config-scope-note",children:"配置作用于当前工作区,所有连接到这里的设备共用。"})]})]})}function fS({host:t,configuration:i,onSectionChange:l}){const a=i.connections.find(u=>u.id===i.defaults.text),o=i.skills.filter(u=>u.enabled).length,f=[{section:"models",title:"模型与连接",summary:a?`${a.id} · ${a.model}`:"尚未设置默认模型",icon:"◈"},{section:"skills",title:"Skills",summary:`${i.skills.length} 个可用 · ${o} 个已启用`,icon:"✧"},{section:"mcp",title:"MCP 工具",summary:`${i.mcpServers.length} 个已配置的工具服务`,icon:"⌘"}];return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"config-workspace-card",children:[c.jsx("span",{className:"config-workspace-icon","aria-hidden":"true",children:"▱"}),c.jsxs("div",{children:[c.jsx("strong",{children:"当前工作区"}),c.jsx("code",{children:i.workspace.path}),c.jsx("p",{children:t==="desktop"?"对话、文件操作和工具都由已连接的桌面端执行。":"对话、文件操作和工具都在服务端运行。"})]}),c.jsx("span",{className:"config-badge",children:t==="desktop"?"桌面工作区":"服务端工作区"})]}),c.jsx("h2",{className:"config-section-title",children:"工作区配置"}),c.jsx("div",{className:"config-card config-overview-list",children:f.map(u=>{const p=c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"config-row-icon","aria-hidden":"true",children:u.icon}),c.jsxs("span",{className:"config-row-copy",children:[c.jsx("strong",{children:u.title}),c.jsx("span",{children:u.summary})]}),l&&c.jsx("span",{className:"config-chevron","aria-hidden":"true",children:"›"})]});return l?c.jsx("button",{className:"config-overview-row",onClick:()=>l(u.section),children:p},u.section):c.jsx("div",{className:"config-overview-row",children:p},u.section)})}),c.jsxs("div",{className:"config-explanation",children:[c.jsx("h2",{children:"工作区与执行位置"}),c.jsx("p",{children:t==="desktop"?"这里直接使用桌面端的任务、模型、Skills 和工具连接。修改配置后,桌面窗口和已配对的网页共同使用。":"这里使用服务端的任务、模型、Skills 和工具连接。修改配置后,连接到这个服务端的网页共同使用。"}),c.jsx("p",{children:t==="desktop"?"切换项目会切换对应的文件、历史和工作区设置;无需复制桌面配置。":"独立部署使用自己的运行环境。部署到另一台机器时,需要迁移配置和数据,或在这里重新设置。"})]})]})}function dS({configuration:t,disabled:i,saving:l,save:a,onDirtyChange:o,onAuthLost:f}){const[u,p]=w.useState(null),[h,m]=w.useState(null),[y,b]=w.useState(""),[x,v]=w.useState(!1),[j,z]=w.useState(!1),[A,N]=w.useState(null),[T,M]=w.useState({}),G=w.useRef(null),ae=t.connections.filter(C=>C.tag==="text"),D=t.connections.length-ae.length,H=i||!!A;w.useEffect(()=>{h&&!t.connections.some(C=>C.id===h.id)&&m(null)},[t.connections,h]),w.useEffect(()=>()=>G.current?.abort(),[]);const W=w.useRef(new Map);w.useEffect(()=>{const C=new Map(t.connections.map(B=>[B.id,B.revision??JSON.stringify(B)])),L=new Set([...W.current].filter(([B,Q])=>C.get(B)!==Q).map(([B])=>B));W.current=C,A&&L.has(A)&&G.current?.abort(),L.size&&M(B=>Object.fromEntries(Object.entries(B).filter(([Q])=>!L.has(Q))))},[t,A]),w.useEffect(()=>(o?.(x||j||l||!!A),()=>o?.(!1)),[x,j,l,A,o]);const q=async C=>{if(G.current)return;const L=new AbortController;G.current=L,N(C.id),M(B=>({...B,[C.id]:"正在发送一条简短测试请求…"}));try{const B=await L1(C.id,L.signal);L.signal.aborted||M(Q=>({...Q,[C.id]:B}))}catch(B){L.signal.aborted||(B instanceof Ke&&B.status===401?f():M(Q=>({...Q,[C.id]:wb(B)})))}finally{G.current===L&&(G.current=null,N(null))}};return c.jsxs(c.Fragment,{children:[c.jsx(hS,{configuration:t,disabled:H,save:a,onDirtyChange:z}),c.jsxs("div",{className:"config-section-heading",children:[c.jsxs("h2",{children:["文字模型连接 ",c.jsx("span",{className:"config-count",children:ae.length})]}),c.jsxs("button",{className:"config-button",disabled:H||u!==null||h!==null||!t.catalog.length,onClick:()=>p("__new__"),children:[c.jsx("span",{"aria-hidden":"true",children:"+"})," 添加连接"]})]}),u!==null&&c.jsxs("div",{className:"config-card config-editor-card",children:[c.jsx("h3",{children:u==="__new__"?"添加模型连接":`编辑 ${u.id}`}),c.jsx(pS,{connection:u==="__new__"?void 0:u,configuration:t,disabled:H,save:a,onDone:()=>p(null),onDirtyChange:v},u==="__new__"?"new":u.id)]}),!ae.length&&u!=="__new__"&&c.jsx(mS,{title:"还没有文字模型连接",description:"添加服务商地址、模型名称和 API Key,再选择一个默认模型。"}),c.jsx("div",{className:"config-connection-list",children:ae.map(C=>{const L=t.catalog.find(I=>I.id===C.catalogId),B=h?.id===C.id,Q=B&&h?.revision!==C.revision,J=t.defaults.text===C.id&&ae.length>1,K=T[C.id];return c.jsxs("article",{className:"config-card config-connection-card",children:[c.jsxs("div",{className:"config-connection-head",children:[c.jsx("span",{className:"config-model-icon","aria-hidden":"true",children:"◈"}),c.jsxs("div",{className:"config-row-copy",children:[c.jsx("strong",{children:C.id}),c.jsx("span",{children:L?.displayName??C.catalogId})]}),t.defaults.text===C.id&&c.jsx("span",{className:"config-badge config-badge-accent",children:"默认"}),c.jsx("button",{className:"config-button config-button-quiet",disabled:H||u!==null||h!==null,onClick:()=>p(C),children:"编辑"})]}),c.jsxs("dl",{className:"config-connection-facts",children:[c.jsxs("div",{children:[c.jsx("dt",{children:"模型"}),c.jsx("dd",{children:C.model||"未填写"})]}),c.jsxs("div",{children:[c.jsx("dt",{children:"服务地址"}),c.jsx("dd",{children:C.baseUrl||L?.defaultBaseUrl||"服务商默认地址"})]}),c.jsxs("div",{children:[c.jsx("dt",{children:"API Key"}),c.jsx("dd",{children:C.hasApiKey?"•••••••• · 已配置":C.needsKey?"未配置":"无需 API Key"})]})]}),c.jsxs("div",{className:"config-model-actions",children:[A===C.id?c.jsx("button",{className:"config-button",onClick:()=>{G.current?.abort(),M(I=>({...I,[C.id]:"已取消连接测试。"}))},children:"取消测试"}):c.jsx("button",{className:"config-button",disabled:H||u!==null||h!==null,onClick:()=>{q(C)},children:"测试连接"}),c.jsx("span",{className:"config-help",children:"发送一条简短请求,服务商可能计费。"}),c.jsx("button",{className:"config-button config-button-quiet config-remove-connection",disabled:H||u!==null||h!==null,onClick:()=>{m(C),b("")},children:"删除"})]}),K&&c.jsxs("div",{className:`config-probe-result ${typeof K!="string"&&K.ok?"is-success":""}`,role:"status",children:[c.jsx("span",{children:typeof K=="string"?K:K.message}),typeof K!="string"&&c.jsxs("small",{children:[Math.max(.01,K.latencyMs/1e3).toFixed(2)," 秒 ·"," ",new Date(K.checkedAt).toLocaleTimeString()]})]}),B&&c.jsxs("div",{className:"config-remove-confirm",children:[c.jsxs("h3",{children:["删除连接 ",C.id,"?"]}),c.jsx("p",{children:"连接会从当前工作区移除,已有对话记录会保留。"}),Q&&c.jsx("p",{role:"alert",children:"连接已被其他设备更新,请取消后重新检查再删除。"}),ae.length===1&&c.jsx("p",{children:"这是最后一个文字模型连接。删除后需重新添加连接才能继续对话。"}),J&&c.jsxs("label",{children:[c.jsx("span",{children:"替代默认模型"}),c.jsxs("select",{"aria-label":"替代默认模型",value:y,onChange:I=>b(I.target.value),disabled:H,children:[c.jsx("option",{value:"",children:"请选择其他连接"}),ae.filter(I=>I.id!==C.id).map(I=>c.jsxs("option",{value:I.id,children:[I.id," · ",I.model]},I.id))]})]}),c.jsxs("div",{className:"config-form-actions",children:[c.jsx("button",{className:"config-button",disabled:H,onClick:()=>m(null),children:"取消删除"}),c.jsx("button",{className:"config-button config-button-danger",disabled:H||Q||J&&!y,onClick:()=>{a("删除连接",I=>O1(C.id,y||void 0,I,h?.revision)).then(I=>{I&&m(null)})},children:"确认删除连接"})]})]})]},C.id)})}),D>0&&c.jsxs("p",{className:"config-help",children:["另有 ",D," 个其他类型的模型连接,保留在工作区配置中。目前此处提供文字模型编辑。"]})]})}function hS({configuration:t,disabled:i,save:l,onDirtyChange:a}){const[o,f]=w.useState(t.defaults.text??""),[u,p]=w.useState(t.defaults.auxText??""),h=w.useRef(t.defaults);w.useEffect(()=>{const b=h.current;h.current=t.defaults,f(x=>x===(b.text??"")?t.defaults.text??"":x),p(x=>x===(b.auxText??"")?t.defaults.auxText??"":x)},[t.defaults]);const m=t.connections.filter(b=>b.tag==="text"),y=o!==(t.defaults.text??"")||u!==(t.defaults.auxText??"");return w.useEffect(()=>(a(y),()=>a(!1)),[y,a]),c.jsx("form",{className:"config-card config-defaults",onSubmit:b=>{b.preventDefault(),l("默认模型",x=>_1({text:o,auxText:u||null},x))},children:c.jsxs("fieldset",{disabled:i||!m.length,children:[c.jsx("legend",{children:"默认模型"}),c.jsxs("div",{className:"config-form-grid",children:[c.jsxs("label",{children:[c.jsx("span",{children:"对话模型"}),c.jsxs("select",{required:!0,value:o,onChange:b=>f(b.target.value),"aria-label":"默认对话模型",children:[c.jsx("option",{value:"",disabled:!0,children:"选择模型连接"}),o&&!m.some(b=>b.id===o)&&c.jsxs("option",{value:o,disabled:!0,children:[o,"(连接不可用)"]}),m.map(b=>c.jsxs("option",{value:b.id,children:[b.id," · ",b.model]},b.id))]})]}),c.jsxs("label",{children:[c.jsx("span",{children:"辅助模型"}),c.jsxs("select",{value:u,onChange:b=>p(b.target.value),"aria-label":"默认辅助模型",children:[c.jsx("option",{value:"",children:"跟随对话模型"}),u&&!m.some(b=>b.id===u)&&c.jsxs("option",{value:u,disabled:!0,children:[u,"(连接不可用)"]}),m.map(b=>c.jsxs("option",{value:b.id,children:[b.id," · ",b.model]},b.id))]})]})]}),c.jsxs("div",{className:"config-form-footer",children:[c.jsx("p",{className:"config-help",children:"辅助模型用于标题生成等轻量任务。"}),c.jsx("button",{className:"config-button",disabled:!y||!o,type:"submit",children:"保存默认模型"})]})]})})}function pS({connection:t,configuration:i,disabled:l,save:a,onDone:o,onDirtyChange:f}){const[u,p]=w.useState(()=>{const T=Oc(t);return t||(T.catalogId=i.catalog[0]?.id??""),T}),h=w.useRef(u),m=JSON.stringify(u)!==JSON.stringify(h.current),[y,b]=w.useState(!1),x=t?i.connections.find(T=>T.id===t.id):void 0,v=!!t&&(!x||u.expectedRevision!==x.revision);w.useEffect(()=>{if(!m&&x&&u.expectedRevision!==x.revision){const T=Oc(x);h.current=T,p(T)}},[m,x,u.expectedRevision]);const j=()=>{if(!x)return;const T=Oc(x);h.current=T,p(T),b(!1)};w.useEffect(()=>(f(m),()=>f(!1)),[m,f]);const z=i.catalog.find(T=>T.id===u.catalogId),A=!t&&i.connections.some(T=>T.id===u.id.trim()),N=(T,M)=>p(G=>({...G,[T]:M}));return c.jsx("form",{className:"config-connection-editor",onSubmit:async T=>{T.preventDefault(),!v&&await a("模型连接",M=>D1(u,M))&&o()},children:c.jsxs("fieldset",{disabled:l,children:[c.jsx("legend",{className:"config-sr-only",children:t?`编辑 ${t.id}`:"新模型连接"}),v&&c.jsxs("div",{className:"config-remove-confirm",role:"alert",children:[c.jsx("p",{children:x?"其他设备已更新这个连接。你的草稿已保留,请检查最新设置后再保存。":"这个连接已被其他设备删除。草稿仍保留,你可以复制内容后关闭编辑。"}),x&&c.jsx("button",{className:"config-button",type:"button",onClick:j,children:"放弃草稿并载入最新设置"})]}),c.jsxs("div",{className:"config-form-grid",children:[c.jsxs("label",{children:[c.jsx("span",{children:"连接名称"}),c.jsx("input",{required:!0,maxLength:120,value:u.id,readOnly:!!t,onChange:T=>N("id",T.target.value),placeholder:"例如 work-model",autoComplete:"off"})]}),c.jsxs("label",{children:[c.jsx("span",{children:"服务商"}),c.jsxs("select",{required:!0,disabled:!!t,"aria-label":"服务商",value:u.catalogId,onChange:T=>N("catalogId",T.target.value),children:[t&&!z&&c.jsx("option",{value:u.catalogId,children:u.catalogId}),i.catalog.map(T=>c.jsx("option",{value:T.id,children:T.displayName},T.id))]})]}),c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"模型名称"}),c.jsx("input",{required:!0,maxLength:240,value:u.model,onChange:T=>N("model",T.target.value),placeholder:"服务商提供的模型 ID",autoComplete:"off"})]}),c.jsxs("label",{className:"config-full-width",children:[c.jsx("span",{children:"服务地址"}),c.jsx("input",{type:"url","aria-label":"服务地址",value:u.baseUrl,onChange:T=>N("baseUrl",T.target.value),placeholder:z?.defaultBaseUrl||"使用服务商默认地址",autoComplete:"off"}),c.jsx("small",{children:"留空使用服务商默认地址,支持兼容接口。"})]}),c.jsxs("label",{className:"config-full-width",children:[c.jsxs("span",{children:["API Key ",t?.hasApiKey&&c.jsx("span",{className:"config-field-meta",children:"已配置"})]}),c.jsx("input",{type:"password","aria-label":"API Key",required:z?.needsKey&&!t?.hasApiKey,value:u.apiKey,onChange:T=>N("apiKey",T.target.value),placeholder:t?.hasApiKey?"留空保留现有 API Key":z?.needsKey?"输入 API Key":"可选",autoComplete:"new-password",spellCheck:!1}),c.jsx("small",{children:t?.hasApiKey?"现有密钥保留在运行 CodeShell 的设备上,输入新值可替换。":"密钥保存在当前工作区配置中。"})]})]}),A&&c.jsx("p",{className:"config-error config-message",role:"alert",children:"连接名称已存在,请使用其他名称或编辑现有连接。"}),c.jsx("p",{className:"config-help",children:"保存后可在连接卡片中测试实际连接。"}),y&&c.jsxs("div",{className:"config-remove-confirm",role:"alert",children:[c.jsx("p",{children:"还有未保存的修改,确定放弃?"}),c.jsxs("div",{className:"config-form-actions",children:[c.jsx("button",{type:"button",className:"config-button",onClick:()=>b(!1),children:"继续编辑"}),c.jsx("button",{type:"button",className:"config-button config-button-danger",onClick:o,children:"放弃修改"})]})]}),c.jsxs("div",{className:"config-form-actions",children:[c.jsx("button",{type:"button",className:"config-button config-button-quiet",onClick:()=>m?b(!0):o(),children:"取消"}),c.jsx("button",{type:"submit",className:"config-button config-button-primary",disabled:A||v,children:"保存连接"})]})]})})}function mS({title:t,description:i}){return c.jsxs("div",{className:"config-empty",children:[c.jsx("span",{"aria-hidden":"true",children:"◇"}),c.jsx("h3",{children:t}),c.jsx("p",{children:i})]})}function Uc(t,i=!1){return xt(`/api/v1/files/content?path=${encodeURIComponent(t)}${i?"&inline=true":""}`)}function _g(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function gS({initialPath:t,openVersion:i=0,onAuthLost:l}){const[a,o]=w.useState(""),[f,u]=w.useState(null),[p,h]=w.useState(null),[m,y]=w.useState(!1),[b,x]=w.useState(!1),[v,j]=w.useState(""),[z,A]=w.useState(0),[N,T]=w.useState(""),M=w.useRef(null),G=w.useRef(l);G.current=l;const ae=w.useCallback(q=>{q instanceof Ke&&q.status===401?G.current():j(q instanceof Error?q.message:"文件读取失败,请重试。")},[]);w.useEffect(()=>{const q=new AbortController;return y(!0),j(""),qe(`/api/v1/files?path=${encodeURIComponent(a)}`,{signal:q.signal}).then(C=>{q.signal.aborted||u(C)}).catch(C=>{q.signal.aborted||ae(C)}).finally(()=>{q.signal.aborted||y(!1)}),()=>q.abort()},[a,z,ae]);const D=w.useCallback((q,C=!1)=>{M.current?.abort();const L=new AbortController;M.current=L,h(null),x(!0),j(""),qe(`${Uc(q)}&preview=true`,{signal:L.signal}).then(B=>{L.signal.aborted||(C&&o(B.path.split("/").slice(0,-1).join("/")),h(B))}).catch(B=>{L.signal.aborted||ae(B)}).finally(()=>{L.signal.aborted||x(!1)})},[ae]);w.useEffect(()=>{t&&D(t,!0)},[t,i,D]),w.useEffect(()=>()=>M.current?.abort(),[]);const H=q=>{M.current?.abort(),x(!1),h(null),o(q),T("")},W=f?.files.filter(q=>q.name.toLocaleLowerCase().includes(N.toLocaleLowerCase()))??[];return c.jsxs("section",{className:"hub-library hub-files","aria-labelledby":"hub-files-heading",children:[c.jsxs("header",{className:"library-heading",children:[c.jsxs("div",{children:[c.jsx("h1",{id:"hub-files-heading",children:"工作区文件"}),c.jsx("p",{children:"查看任务生成的内容,下载到当前设备。"})]}),c.jsx("button",{className:"library-button",onClick:()=>{A(q=>q+1),p&&D(p.path)},children:"刷新"})]}),v?c.jsx("div",{className:"library-error",role:"alert",children:v}):null,c.jsxs("nav",{className:"file-breadcrumbs","aria-label":"文件位置",children:[c.jsx("button",{onClick:()=>H(""),children:"工作区"}),(f?.path??a).split("/").filter(Boolean).map((q,C,L)=>c.jsxs(w.Fragment,{children:[c.jsx("span",{"aria-hidden":"true",children:"/"}),c.jsx("button",{onClick:()=>H(L.slice(0,C+1).join("/")),children:q})]},C))]}),c.jsxs("div",{className:`file-columns${p||b?" has-preview":""}`,children:[c.jsxs("div",{className:"file-directory",children:[c.jsxs("label",{className:"library-search",children:[c.jsx("span",{className:"sr-only",children:"筛选当前文件夹"}),c.jsx("input",{type:"search",placeholder:"筛选当前文件夹…",value:N,onChange:q=>T(q.target.value)})]}),c.jsx("div",{className:"file-entries","aria-busy":m,children:m?c.jsx("p",{className:"library-empty",role:"status",children:"正在读取文件…"}):W.length===0?c.jsx("p",{className:"library-empty",children:N?"没有匹配的文件。":"这个文件夹还没有文件。"}):W.map(q=>c.jsxs("button",{className:`file-entry${p?.path===q.path?" selected":""}`,onClick:()=>q.kind==="directory"?H(q.path):D(q.path),children:[c.jsx("span",{className:"file-glyph","aria-hidden":"true",children:q.kind==="directory"?"▱":"▤"}),c.jsx("span",{className:"file-entry-name",children:q.name}),c.jsx("span",{className:"file-entry-size",children:q.kind==="directory"?"文件夹":_g(q.size)})]},q.path))}),f?.truncated?c.jsx("p",{className:"library-hint",children:"这里只显示前 500 项。可以进入子文件夹继续查看。"}):null]}),b||p?c.jsxs("article",{className:"file-preview","aria-label":"文件预览",children:[c.jsxs("header",{children:[c.jsxs("div",{children:[c.jsx("strong",{children:p?.name??"正在打开…"}),p?c.jsx("span",{children:_g(p.size)}):null]}),c.jsxs("div",{className:"library-actions",children:[p?c.jsx("a",{className:"library-button",href:Uc(p.path),download:!0,children:"下载"}):null,c.jsx("button",{className:"library-button",onClick:()=>{M.current?.abort(),x(!1),h(null)},children:"关闭预览"})]})]}),b?c.jsx("p",{className:"library-empty",role:"status",children:"正在读取内容…"}):p?.kind==="text"?c.jsxs(c.Fragment,{children:[c.jsx("pre",{tabIndex:0,children:p.content}),p.truncated?c.jsx("p",{className:"library-hint",children:"预览显示前 512 KB,下载可获取完整内容。"}):null]}):p?.kind==="image"?c.jsx("img",{src:Uc(p.path,!0),alt:p.name,onError:()=>j("图片无法预览,可以下载后打开。")}):c.jsx("div",{className:"library-empty",children:"这个文件暂不支持直接预览,可以下载后打开。"})]}):null]})]})}async function Mf(t={}){const i=new URLSearchParams({archived:t.archived??"false",limit:"50"});return t.query&&i.set("query",t.query),t.cursor&&i.set("cursor",t.cursor),qe(`/api/v1/sessions?${i}`,{signal:t.signal})}function Mg(t,i="markdown"){return xt(`/api/v1/sessions/${encodeURIComponent(t)}/export?format=${i}`)}function yS({onAuthLost:t,onOpen:i,onChanged:l,version:a=0,onDirtyChange:o}){const[f,u]=w.useState(""),[p,h]=w.useState(""),[m,y]=w.useState("false"),[b,x]=w.useState([]),[v,j]=w.useState(null),[z,A]=w.useState(!0),[N,T]=w.useState(!1),[M,G]=w.useState(""),[ae,D]=w.useState(""),[H,W]=w.useState(0),[q,C]=w.useState(""),[L,B]=w.useState(null),Q=w.useRef(null),J=w.useRef(null),K=w.useRef(null),I=w.useRef(null);w.useEffect(()=>{L?.id&&Q.current?.focus()},[L?.id]),w.useEffect(()=>{L?.error&&J.current?.focus()},[L?.error]);const Y=()=>{B(null),requestAnimationFrame(()=>{K.current?.isConnected?K.current.focus():I.current?.focus()})};w.useEffect(()=>{o?.(!!L||!!q)},[L,q,o]),w.useEffect(()=>()=>o?.(!1),[o]);const X=w.useRef(null),pe=w.useRef(null),k=w.useRef({onAuthLost:t,onChanged:l,onOpen:i});k.current={onAuthLost:t,onChanged:l,onOpen:i};const O=w.useCallback(le=>{le instanceof Ke&&le.status===401?k.current.onAuthLost():G(le instanceof Error?le.message:"会话操作失败,请重试。")},[]);w.useEffect(()=>{const le=setTimeout(()=>h(f.trim()),200);return()=>clearTimeout(le)},[f]),w.useEffect(()=>{X.current?.abort();const le=new AbortController;return X.current=le,A(!0),T(!1),G(""),Mf({query:p,archived:m,signal:le.signal}).then(ue=>{le.signal.aborted||(x(ue.sessions),j(ue.nextCursor))}).catch(ue=>{le.signal.aborted||O(ue)}).finally(()=>{le.signal.aborted||A(!1)}),()=>le.abort()},[p,m,a,H,O]),w.useEffect(()=>()=>{X.current?.abort(),pe.current?.abort()},[]);const te=()=>{if(!v||N||z)return;const le=new AbortController;X.current?.abort(),X.current=le,T(!0),Mf({query:p,archived:m,cursor:v,signal:le.signal}).then(ue=>{le.signal.aborted||(x(xe=>{const F=new Set(xe.map(ke=>ke.sessionId));return[...xe,...ue.sessions.filter(ke=>!F.has(ke.sessionId))]}),j(ue.nextCursor))}).catch(ue=>{le.signal.aborted||O(ue)}).finally(()=>{le.signal.aborted||T(!1)})},R=async(le,ue,xe=!1)=>{if(pe.current)return;const F=new AbortController;pe.current=F,C(le),G(""),D(""),"title"in ue&&B(ke=>ke&&{...ke,error:""});try{if(await qe(`/api/v1/sessions/${encodeURIComponent(le)}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(ue),signal:F.signal}),F.signal.aborted)return;"title"in ue?(Y(),D(ue.title?"标题已保存。":"已恢复自动标题。")):D(ue.archived?"对话已归档,可以在“已归档”中恢复。":"对话已恢复。"),W(ke=>ke+1),k.current.onChanged?.(),xe&&k.current.onOpen(le)}catch(ke){F.signal.aborted||("title"in ue&&!(ke instanceof Ke&&ke.status===401)?B(ze=>ze?.id===le?{...ze,error:ke instanceof Error?ke.message:"标题保存失败,请重试。",conflict:ke instanceof Ke&&ke.status===409,unavailable:ke instanceof Ke&&ke.status===404}:ze):O(ke))}finally{pe.current===F&&(pe.current=null),F.signal.aborted||C("")}},ee=async()=>{if(!L||pe.current)return;const le=L.id,ue=new AbortController;pe.current=ue,C(le),B(xe=>xe&&{...xe,error:""});try{const xe=await qe(`/api/v1/sessions/${encodeURIComponent(le)}`,{signal:ue.signal});if(ue.signal.aborted)return;B(F=>F?.id===le?{...F,expectedTitle:xe.customTitle,reviewedTitle:xe.title,conflict:!1,unavailable:!1,error:""}:F),Q.current?.focus()}catch(xe){ue.signal.aborted||(xe instanceof Ke&&xe.status===401?O(xe):B(F=>F?.id===le?{...F,error:xe instanceof Error?xe.message:"无法读取最新标题,请重试。",unavailable:xe instanceof Ke&&xe.status===404}:F))}finally{pe.current===ue&&(pe.current=null),ue.signal.aborted||C("")}},ve=le=>le.archivedAt?void R(le.sessionId,{archived:!1},!0):k.current.onOpen(le.sessionId);return c.jsxs("section",{className:"hub-library hub-sessions","aria-labelledby":"hub-history-heading",children:[c.jsxs("header",{className:"library-heading",children:[c.jsxs("div",{children:[c.jsx("h1",{id:"hub-history-heading",children:"历史对话"}),c.jsx("p",{children:"查找、整理并导出当前工作区的对话。"})]}),c.jsx("button",{className:"library-button",onClick:()=>W(le=>le+1),children:"刷新"})]}),M?c.jsx("div",{className:"library-error",role:"alert",children:M}):null,ae?c.jsx("p",{className:"library-hint",role:"status",children:ae}):null,c.jsxs("div",{className:"session-toolbar",children:[c.jsxs("label",{className:"library-search",children:[c.jsx("span",{className:"sr-only",children:"搜索对话标题"}),c.jsx("input",{ref:I,type:"search",placeholder:"搜索对话标题…",value:f,onChange:le=>u(le.target.value)})]}),c.jsxs("label",{children:[c.jsx("span",{className:"sr-only",children:"对话范围"}),c.jsxs("select",{value:m,onChange:le=>y(le.target.value),children:[c.jsx("option",{value:"false",children:"当前对话"}),c.jsx("option",{value:"true",children:"已归档"}),c.jsx("option",{value:"all",children:"全部对话"})]})]})]}),L?c.jsxs("form",{className:"session-history-editor","aria-labelledby":"session-title-editor-heading",onSubmit:le=>{le.preventDefault(),!q&&!L.conflict&&!L.unavailable&&R(L.id,{title:L.title,expectedTitle:L.expectedTitle})},children:[c.jsxs("div",{children:[c.jsx("h2",{id:"session-title-editor-heading",children:"重命名对话"}),c.jsxs("p",{className:"library-hint",children:["正在编辑:",L.originalTitle]}),!z&&!b.some(le=>le.sessionId===L.id)?c.jsx("p",{className:"library-hint",children:"此对话已不在当前列表中,标题草稿仍保留在这里。"}):null]}),L.error?c.jsx("div",{className:"library-error",id:"session-title-error",role:"alert",tabIndex:-1,ref:J,children:L.error}):null,L.reviewedTitle?c.jsxs("p",{className:"session-title-review",role:"status",children:["最新标题:",c.jsx("strong",{children:L.reviewedTitle}),"。你的草稿仍保留,请核对后再保存。"]}):null,c.jsxs("label",{children:[c.jsx("span",{children:"对话标题"}),c.jsx("input",{ref:Q,className:"library-title-input",value:L.title,maxLength:1024,"aria-describedby":L.error?"session-title-error":void 0,onChange:le=>{const ue=le.target.value;B(xe=>xe&&{...xe,title:ue})},readOnly:!!q})]}),c.jsxs("div",{className:"library-actions",children:[c.jsx("button",{type:"submit",className:"library-button primary",disabled:!!q||L.conflict||L.unavailable,children:q?"处理中…":L.reviewedTitle?"确认保存我的标题":"保存标题"}),L.conflict||L.unavailable?c.jsx("button",{type:"button",className:"library-button",disabled:!!q,onClick:()=>{ee()},children:"读取最新标题"}):null,c.jsx("button",{type:"button",className:"library-button",disabled:!!q,onClick:Y,children:"取消"}),L.expectedTitle?c.jsx("button",{type:"button",className:"library-button",disabled:!!q||L.conflict||L.unavailable,onClick:()=>{R(L.id,{title:"",expectedTitle:L.expectedTitle})},children:"使用自动标题"}):null]})]}):null,c.jsx("div",{className:"session-history-list","aria-busy":z,children:z?c.jsx("p",{className:"library-empty",role:"status",children:"正在读取对话…"}):b.length===0?c.jsx("p",{className:"library-empty",children:p?"没有找到匹配的对话。":m==="true"?"还没有归档的对话。":"还没有保存的对话,开始一条新对话后会显示在这里。"}):b.map(le=>c.jsxs("article",{className:"session-history-row",children:[c.jsxs("div",{className:"session-history-info",children:[c.jsx("button",{className:"session-history-title",onClick:()=>ve(le),children:le.title}),le.preview&&le.preview!==le.title?c.jsx("p",{children:le.preview.slice(0,150)}):null,c.jsxs("div",{className:"session-history-meta",children:[c.jsx("span",{children:new Date(le.lastActiveAt||le.startedAt).toLocaleString()}),c.jsxs("span",{children:[le.turnCount," 轮"]}),le.running?c.jsx("span",{children:"正在运行"}):le.archivedAt?c.jsx("span",{children:"已归档"}):null]})]}),c.jsxs("div",{className:"library-actions",children:[c.jsx("button",{className:"library-button",disabled:!!q||!!L,onClick:ue=>{K.current=ue.currentTarget,D(""),B({id:le.sessionId,title:le.title,originalTitle:le.title,expectedTitle:le.customTitle})},children:L?.id===le.sessionId?"正在编辑":"重命名"}),c.jsx("button",{className:"library-button",disabled:!!q||le.running,onClick:()=>{R(le.sessionId,{archived:!le.archivedAt})},children:q===le.sessionId?"处理中…":le.archivedAt?"恢复":"归档"}),le.running?c.jsx("button",{className:"library-button",disabled:!0,children:"运行结束后导出"}):c.jsxs("details",{className:"session-export",children:[c.jsx("summary",{className:"library-button",children:"导出"}),c.jsxs("div",{children:[c.jsx("a",{href:Mg(le.sessionId),download:!0,children:"Markdown 文档"}),c.jsx("a",{href:Mg(le.sessionId,"json"),download:!0,children:"完整 JSON 记录"})]})]})]})]},le.sessionId))}),v&&!z?c.jsx("div",{className:"session-load-more",children:c.jsx("button",{className:"library-button",disabled:N,onClick:te,children:N?"读取中…":"加载更多"})}):null]})}var bS=gb();function lo(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Ws(t){return typeof t=="string"?t:""}function kb(t){return Array.isArray(t)?t.map(lo).filter(i=>i!==void 0):[]}function vS(t){return typeof t=="string"?t:kb(t).filter(i=>i.type==="text").map(i=>Ws(i.text)).join("")}function sa(t){return t.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}function Ic(t){const i=t.replace(/\\/g,"/").split("/").filter(Boolean).pop()||"附件";return t.includes(".code-shell/attachments/")?i.replace(/^[a-f0-9]{16}-/,""):i}function qc(t){const i=typeof t=="number"?t:Number(t);return Number.isSafeInteger(i)&&i>=0?i:0}function Cb(t,i={}){const l=[],a=h=>/^(?:[a-zA-Z]:[\\/]|[\\/])/.test(h)||!i.cwd?h:`${i.cwd.replace(/[\\/]$/,"")}/${h}`,o=[];let f=vS(t.content);f=f.replace(/<attached-file\s+path="([^"]*)">\s*([\s\S]*?)<\/attached-file>/g,(h,m,y)=>{if(!/^absolutePath:\s*.+$/m.test(y)||!/^origin:\s*.+$/m.test(y))return h;const b=y.match(/^mime:\s*(.+)$/m)?.[1]?.trim();return l.push({name:Ic(sa(m)),path:sa(m),...i.includeAbsolutePaths?{absPath:y.match(/^absolutePath:\s*(.+)$/m)[1].trim()}:{},size:qc(y.match(/^size:\s*(\d+)\s*$/m)?.[1]),...b?{mime:b}:{}}),""}),f=f.replace(/<attached-directory\s+path="([^"]*)"[^>]*>[\s\S]*?<\/attached-directory>/g,(h,m)=>(l.push({name:`${Ic(sa(m))}/`,path:sa(m),...i.includeAbsolutePaths?{absPath:a(sa(m))}:{},size:0}),"")),f=f.replace(/<attached-image-paths>\s*([\s\S]*?)<\/attached-image-paths>\s*(?:\(上面附带的图片在工作区的真实路径[^\n]*\))?/g,(h,m)=>(o.push(...m.split(`
21
+ `).map(y=>y.trim()).filter(Boolean)),""));const u=kb(t.content).filter(h=>h.type==="image");for(let h=0;h<Math.max(u.length,o.length);h++){const m=lo(u[h]?.source),y=Ws(m?.data).replace(/\s/g,"");l.push({name:o[h]?Ic(o[h]):`图片 ${h+1}`,...o[h]?{path:o[h]}:{},...i.includeAbsolutePaths&&o[h]?{absPath:a(o[h])}:{},size:y?Math.max(0,Math.floor(y.length*3/4)-(y.match(/=+$/)?.[0].length??0)):qc(m?.byteLength),...typeof m?.media_type=="string"?{mime:m.media_type}:{}})}const p=Array.isArray(t.attachments)?t.attachments.flatMap(h=>{const m=lo(h),y=Ws(m?.name)||Ws(m?.originalName);return y?[{name:y,size:qc(m?.size),...typeof m?.mime=="string"?{mime:m.mime}:{},...typeof m?.path=="string"?{path:m.path}:{}}]:[]}):[];return{text:typeof t.displayText=="string"?t.displayText:f.trim(),attachments:p.length?p:l}}function Eb(t){if(t.type!=="session_user_message"&&t.type!=="steer_injected")return t;const i=lo(t.transcriptMessage);return i?{...t,...Cb(i,{includeAbsolutePaths:!0,...typeof i.cwd=="string"?{cwd:i.cwd}:{}})}:t}function Og(t){return t.replace(/<system-reminder>[\s\S]*?<\/system-reminder>\s*/g,"")}function eo(){return{items:[],run:"idle",seq:0,liveByAgent:{}}}function oa(t){return t.agentId??""}function $s(t,i,l=!1){const a=i.goalId;if(t.goalId!==a&&!(l&&t.goalId===void 0&&a!==void 0))return!0;const o=i.revision;return t.goalRevision!==void 0&&(o===void 0||o<t.goalRevision)}function xS(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"unverified_write":return"error";default:return"completed"}}function SS(t){if(!t||typeof t!="object")return null;const i=t;if(i.method==="agent/streamEvent"&&i.params&&typeof i.params=="object"){const l=i.params;if(l.event&&typeof l.event=="object")return{event:l.event,sessionId:typeof l.sessionId=="string"?l.sessionId:void 0}}return typeof i.type=="string"?{event:i}:null}function mr(t,i){const l=SS(i);if(!l)return t;const{sessionId:a}=l,o=Eb(l.event),f=o.type;let u=t;a&&a!==u.sessionId&&(u={...u,sessionId:a});const p=h=>{const m=u.seq+1;return[`${h}-${m}`,{...u,seq:m}]};switch(f){case"stream_request_start":{const h=oa(o),[m,y]=p("a"),b={kind:"assistant",id:m,text:"",reasoning:"",done:!1,agentId:o.agentId,...typeof o.messageId=="string"?{messageId:o.messageId}:{}};return{...y,items:[...y.items,b],liveByAgent:{...y.liveByAgent,[h]:m},run:"running"}}case"text_delta":{const h=o.text??"",m=oa(o),y=u.liveByAgent[m];if(y&&u.items.find(z=>z.id===y&&z.kind==="assistant"))return{...u,run:"running",items:u.items.map(z=>z.id===y&&z.kind==="assistant"?{...z,text:z.text+h}:z)};const[x,v]=p("a"),j={kind:"assistant",id:x,text:h,reasoning:"",done:!1,agentId:o.agentId};return{...v,items:[...v.items,j],liveByAgent:{...v.liveByAgent,[m]:x},run:"running"}}case"thinking_delta":{const h=o.text??"",m=oa(o),y=u.liveByAgent[m];if(y&&u.items.some(j=>j.id===y&&j.kind==="assistant"))return{...u,run:"running",items:u.items.map(j=>j.id===y&&j.kind==="assistant"?{...j,reasoning:j.reasoning+h}:j)};const[b,x]=p("a"),v={kind:"assistant",id:b,text:"",reasoning:h,done:!1,agentId:o.agentId};return{...x,items:[...x.items,v],liveByAgent:{...x.liveByAgent,[m]:b},run:"running"}}case"tool_use_start":{const h=o.toolCall;if(!h||u.items.some(x=>x.kind==="tool"&&x.id===h.id))return u;const m=u.orphanResults?.[h.id],y={kind:"tool",id:h.id,name:h.toolName,args:h.args,summary:h.summary,done:!!m,result:m?.result,error:m?.error,agentId:o.agentId};let b=u.orphanResults;if(m){const{[h.id]:x,...v}=u.orphanResults;b=Object.keys(v).length>0?v:void 0}return{...u,run:"running",items:[...u.items,y],orphanResults:b}}case"tool_use_args_delta":{const h=o.toolCallId,m=o.args;return!h||!m?u:{...u,items:u.items.map(y=>y.kind==="tool"&&y.id===h?{...y,args:{...y.args??{},...m}}:y)}}case"tool_result":{const h=o.result;return h?u.items.some(y=>y.kind==="tool"&&y.id===h.id)?{...u,items:u.items.map(y=>y.kind==="tool"&&y.id===h.id?{...y,done:!0,result:Og(h.result??h.error??""),error:!!(h.isError||h.error)}:y)}:{...u,orphanResults:{...u.orphanResults??{},[h.id]:{result:h.result??h.error??"",error:!!(h.isError||h.error)}}}:u}case"room_tool_result":{const h=o.summary??"",m=Og(h),y=!!o.isError;let b=-1;for(let j=u.items.length-1;j>=0;j--)if(u.items[j].kind==="tool"&&!u.items[j].done){b=j;break}if(b===-1)return u;const x=u.items.slice(),v=x[b];return x[b]={...v,done:!0,result:m,summary:m||v.summary,error:y},{...u,items:x}}case"tool_summary":{const h=o.summary??"",m=Array.isArray(o.toolCallIds)?o.toolCallIds.filter(z=>typeof z=="string"):[],b=m.length>0?m[m.length-1]:void 0,x=o.agentId;if(b){let z=!1;const A=u.items.map(N=>N.kind!=="tool"||N.id!==b||N.agentId!==x?N:(z=!0,{...N,summary:h}));return z?{...u,items:A}:u}if(x){let z=-1;for(let N=u.items.length-1;N>=0;N--){const T=u.items[N];if(T.kind==="tool"&&T.agentId===x){z=N;break}}if(z===-1)return u;const A=u.items.slice();return A[z]={...A[z],summary:h},{...u,items:A}}let v=-1;for(let z=u.items.length-1;z>=0;z--){const A=u.items[z];if(A.kind==="tool"&&A.agentId===void 0){v=z;break}}if(v===-1)return u;const j=u.items.slice();return j[v]={...j[v],summary:h},{...u,items:j}}case"tombstone":{if(typeof o.messageId!="string")return u;const h=new Set(u.items.filter(m=>m.kind==="assistant"&&m.messageId===o.messageId||m.kind==="tool"&&m.id===o.messageId).map(m=>m.id));return h.size?{...u,items:u.items.filter(m=>!h.has(m.id)),liveByAgent:Object.fromEntries(Object.entries(u.liveByAgent).filter(([,m])=>!h.has(m)))}:u}case"assistant_message":{const h=oa(o);if(!(h in u.liveByAgent))return u;const{[h]:m,...y}=u.liveByAgent,b=u.items.map(x=>x.kind==="assistant"&&!x.done&&(x.agentId??"")===h?{...x,done:!0}:x);return{...u,liveByAgent:y,items:b}}case"turn_complete":{const h=o.reason??"completed",m=oa(o),{[m]:y,...b}=u.liveByAgent,x=u.items.map(v=>v.kind==="assistant"&&!v.done&&(v.agentId??"")===m?{...v,done:!0}:v);return o.agentId?{...u,liveByAgent:b,items:x}:{...u,liveByAgent:b,items:x,run:xS(h)}}case"goal_set":{const h=o.objective??"",m=!!o.paused;return u.goal&&u.goalId===o.goalId&&$s(u,o)?u:{...u,goal:h?`◎ ${h}${m?" (已暂停)":""}`:"◎ 目标",goalId:o.goalId,goalPaused:m,goalRevision:o.revision}}case"goal_updated":{if(u.goal&&$s(u,o,!0))return u;const h=o.goalId,m=o.objective??"",y=!!o.paused;return{...u,goal:m?`◎ ${m}${y?" (已暂停)":""}`:u.goal,goalId:h??u.goalId,goalPaused:y,goalRevision:o.revision??u.goalRevision}}case"goal_cleared":return u.goal&&$s(u,o)?u:{...u,goal:void 0,goalId:void 0,goalPaused:void 0,goalRevision:void 0};case"goal_progress":{if(u.goal&&$s(u,o))return u;const h=o.status??"";if(h==="met"||h==="exhausted")return{...u,goal:void 0,goalId:void 0,goalPaused:void 0,goalRevision:void 0};const m=o.round,y=m?`目标 · 第 ${m} 轮 (${h})`:`目标 (${h})`;return{...u,goal:y,goalRevision:o.revision??u.goalRevision}}case"task_update":{const h=o.agentId;if(!h)return u;const m=o.tasks??[],y=m.filter(j=>j.status==="completed").length,b=`任务 ${y}/${m.length}`,x=u.items.findIndex(j=>j.kind==="subagent"&&j.agentId===h),v={kind:"subagent",id:`sub-${h}`,agentId:h,label:b,status:m.length>0&&y===m.length?"completed":"running"};if(x>=0){const j=u.items.slice();return j[x]=v,{...u,items:j}}return{...u,items:[...u.items,v]}}case"agent_start":{const h=o.agentId;if(!h)return u;const m={kind:"subagent",id:`sub-${h}`,agentId:h,label:o.name||o.description||"子代理",status:o.status==="recorded"?"recorded":"running"};return u.items.some(y=>y.kind==="subagent"&&y.agentId===h)?u:{...u,items:[...u.items,m]}}case"agent_end":{const h=o.agentId;return{...u,items:u.items.map(m=>m.kind==="subagent"&&m.agentId===h?{...m,status:o.error?"error":"completed"}:m)}}case"background_agent_completed":{const h=typeof o.agentId=="string"?o.agentId:"",m=o.status==="failed",y=m?"error":o.status==="cancelled"?"cancelled":"completed",b=typeof o.name=="string"?o.name:"后台任务",x=m?o.error??o.description:o.finalText??o.description,v=`${b} · ${y}${typeof x=="string"&&x.trim()?`: ${x.trim().slice(0,240)}`:""}`,[j,z]=p("bg-done");return{...z,items:[...u.items.map(A=>A.kind==="subagent"&&A.agentId===h?{...A,status:y}:A),{kind:"system",id:j,text:v}]}}case"error":{const[h,m]=p("err");return{...m,run:"error",liveByAgent:{},items:[...m.items,{kind:"system_error",id:h,text:o.error||"运行出错"}]}}case"session_title":return{...u,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 u;const h=typeof o.clientMessageId=="string"?o.clientMessageId:void 0,m=Array.isArray(o.attachments)?o.attachments.map(x=>x).filter(x=>!!x&&typeof x.name=="string"&&typeof x.size=="number"&&Number.isFinite(x.size)&&x.size>=0).map(x=>({name:x.name,size:x.size,...typeof x.mime=="string"?{mime:x.mime}:{},...typeof x.path=="string"?{path:x.path}:{}})):void 0;if(h&&u.items.some(x=>x.kind==="user"&&x.clientMessageId===h))return m?.length?{...u,items:u.items.map(x=>x.kind==="user"&&x.clientMessageId===h?{...x,attachments:m.map((v,j)=>{const z=x.attachments?.[j];return z?.name===v.name?{...z,...v}:v})}:x)}:u;const[y,b]=p("u");return{...b,items:[...b.items,{kind:"user",id:y,text:o.text??"",...m?.length?{attachments:m}:{},...h?{clientMessageId:h}:{}}]}}case"assistant_text":{const[h,m]=p("a");return{...m,run:"running",items:[...m.items,{kind:"assistant",id:h,text:o.text??"",reasoning:"",done:!0,agentId:o.agentId}]}}default:return u}}function wS(t,i,l,a){const o=`u-${t.seq+1}`;return{...t,seq:t.seq+1,items:[...t.items,{kind:"user",id:o,text:i,...l?.length?{attachments:l}:{},...a?{clientMessageId:a}:{}}]}}const jS="codeshell.uiLanguage";function kS(){try{const t=globalThis.localStorage?.getItem(jS);if(t==="zh"||t==="en")return t}catch{}return"zh"}const CS={zh:{mobile:{app:{extendGoal:"延长目标",clearGoal:"清除目标",loadingCcSession:"正在加载 CC 会话…",loadingSession:"正在加载会话…",conversationFallback:"对话",desktopSession:"桌面会话",newSession:"新会话",openSessionsAria:"打开会话",leaveSessionAria:"退出会话",deviceFallback:"设备",logoutAria:"退出登录",permission:"权限",ccRoomObserving:"此会话当前为只读查看;请在桌面端明确接管后再发送消息。"},approval:{risk:{low:"低风险",medium:"中风险",high:"高风险"},readSourceSummary:"读取数据源 {source} / {scope} / {resource}",question:"问题",customPlaceholder:"或输入自定义回答…",sendCustom:"发送自定义回答",rememberScope:"记住范围",scope:{once:"仅本次",session:"本会话",project:"本项目"},pathScopeLabel:"路径范围",pathScope:{file:"此文件",dir:"此目录",tool:"此工具"},allow:"允许",reject:"拒绝"},cc:{title:"CC 会话",subtitle:"外部 {label} 会话",selectProjectFirst:"先选择一个项目。",probingCli:"正在检测 {label} CLI…",cliMissing:"未检测到 {label} CLI(需在桌面端机器的 PATH 中)。",loadingSessions:"正在加载 cc 会话…",empty:"该项目下没有 {label} 会话。",messageCount:"{count} 条"},sidePane:{localTab:"会话",ccTab:"CC 会话"},composer:{disconnected:"未连接",placeholder:"发消息…",stop:"停止",send:"发送",chooseImages:"从相册选择图片",takePhoto:"拍照",removeImage:"移除图片",uploading:"上传中…",tooManyImages:"每条消息最多发送 4 张图片",unsupportedImage:"不支持此图片格式",sendFailed:"图片发送失败,请重试"},connection:{connectingTitle:"正在连接…",connectingBody:"与 CodeShell 建立通道",authenticatingTitle:"认证中…",authenticatingBody:"正在校验设备身份",unpairedTitle:"未配对",unpairedBody:"请在 CodeShell 桌面端打开「设置 → 远程」,扫码或打开配对链接。",offlineTitle:"连接断开",offlineBody:"正在自动重连…"},format:{noProject:"无项目",justNow:"刚刚",minutesAgo:"{n} 分钟前",hoursAgo:"{n} 小时前",daysAgo:"{n} 天前",monthsAgo:"{n} 个月前",yearsAgo:"{n} 年前"},notice:{roomMissing:"会话不存在或未就绪",roomError:"会话错误",sessionRecoveryIncomplete:"当前回复的开头尚未恢复,请重新打开会话以读取已保存的内容。",sessionRecoveryHistoryOnly:"已恢复保存的聊天记录。当前回复的实时部分暂时无法接续,请稍后重新打开会话。",goalExtendFailed:"延长目标失败",ccRoomOpenFailed:"cc 会话无法打开",ccRoomObserving:"此 CC 会话当前为只读查看,消息未发送",attachmentSendFailed:"图片发送失败:{error}"},permissionMode:{default:"默认",acceptEdits:"自动改",bypassPermissions:"全放行",defaultDesc:"每个工具调用都要你确认",acceptEditsDesc:"自动放行文件编辑,其余仍确认",bypassDesc:"跳过所有权限确认(危险)",title:"选择权限模式",confirmBypass:"全放行模式会跳过所有权限确认。确定吗?"},sessionList:{title:"会话",takeoverCount:"{count} 个可接管",refreshAria:"刷新会话",new:"新建",createHint:"新会话默认使用当前目录",currentProject:"当前项目 · {name}",noProjectConversation:"无项目对话",desktopCwd:"当前桌面目录",unboundRepo:"不绑定 repo",followsDesktopCwd:"跟随桌面当前 cwd",otherProjects:"其他项目",loading:"正在加载会话…",empty:"还没有会话。点「新建」开一个,或在桌面端开始。",automation:"自动",noProjectPath:"无项目路径",unreadAria:"有新内容",primaryRoot:"主目录",secondaryRoot:"次目录"},status:{conn:{connecting:"连接中…",authenticating:"认证中…",unpaired:"未配对",online:"在线",offline:"已断开"},run:{idle:"空闲",running:"运行中",waiting:"待审批",completed:"已完成",error:"出错"}},storage:{browserDevice:"{platform} 浏览器"},stream:{showReasoning:"显示思考",hideReasoning:"隐藏思考",subagent:"子代理",loading:"正在加载…",generating:"正在生成回复",emptyHint:"发个任务试试,或在侧栏打开一个 Claude Code 会话。"},tool:{running:"运行中",failed:"失败",completed:"完成",fallbackName:"操作",truncated:"… (已截断)"}}},en:{mobile:{app:{extendGoal:"Extend goal",clearGoal:"Clear goal",loadingCcSession:"Loading CC session…",loadingSession:"Loading conversation…",conversationFallback:"Conversation",desktopSession:"Desktop session",newSession:"New session",openSessionsAria:"Open sessions",leaveSessionAria:"Leave session",deviceFallback:"Device",logoutAria:"Log out",permission:"Permission",ccRoomObserving:"This session is read-only. Take it over explicitly on desktop before sending messages."},approval:{risk:{low:"Low risk",medium:"Medium risk",high:"High risk"},readSourceSummary:"Read data source {source} / {scope} / {resource}",question:"Question",customPlaceholder:"Or enter a custom answer…",sendCustom:"Send custom answer",rememberScope:"Remember scope",scope:{once:"Once",session:"This session",project:"This project"},pathScopeLabel:"Path scope",pathScope:{file:"This file",dir:"This directory",tool:"This tool"},allow:"Allow",reject:"Deny"},cc:{title:"CC sessions",subtitle:"External {label} sessions",selectProjectFirst:"Select a project first.",probingCli:"Checking {label} CLI…",cliMissing:"{label} CLI was not found (it must be in PATH on the desktop machine).",loadingSessions:"Loading cc sessions…",empty:"No {label} sessions in this project.",messageCount:"{count} messages"},sidePane:{localTab:"Sessions",ccTab:"CC"},composer:{disconnected:"Disconnected",placeholder:"Message…",stop:"Stop",send:"Send",chooseImages:"Choose images",takePhoto:"Take photo",removeImage:"Remove image",uploading:"Uploading…",tooManyImages:"Up to 4 images can be sent per message",unsupportedImage:"This image format is not supported",sendFailed:"Could not send images; try again"},connection:{connectingTitle:"Connecting…",connectingBody:"Opening a channel to CodeShell",authenticatingTitle:"Authenticating…",authenticatingBody:"Verifying this device",unpairedTitle:"Not paired",unpairedBody:"Open Settings → Remote in CodeShell desktop, then scan the QR code or open the pairing link.",offlineTitle:"Disconnected",offlineBody:"Reconnecting automatically…"},format:{noProject:"No project",justNow:"Just now",minutesAgo:"{n} min ago",hoursAgo:"{n} hr ago",daysAgo:"{n} days ago",monthsAgo:"{n} mo ago",yearsAgo:"{n} yr ago"},notice:{roomMissing:"Session does not exist or is not ready",roomError:"Session error",sessionRecoveryIncomplete:"The beginning of this reply could not be restored. Reopen the conversation to read its saved content.",sessionRecoveryHistoryOnly:"Saved chat history has been restored. Reopen the conversation later to see the rest of this reply.",goalExtendFailed:"Failed to extend goal",ccRoomOpenFailed:"Could not open cc session",ccRoomObserving:"This CC session is read-only; the message was not sent",attachmentSendFailed:"Could not send images: {error}"},permissionMode:{default:"Default",acceptEdits:"Auto-edit",bypassPermissions:"Allow all",defaultDesc:"Confirm every tool call",acceptEditsDesc:"Allow file edits automatically; confirm everything else",bypassDesc:"Skip all permission confirmations (dangerous)",title:"Choose permission mode",confirmBypass:"Allow all mode skips every permission confirmation. Continue?"},sessionList:{title:"Sessions",takeoverCount:"{count} available",refreshAria:"Refresh sessions",new:"New",createHint:"New sessions default to the current directory",currentProject:"Current project · {name}",noProjectConversation:"No-project conversation",desktopCwd:"Current desktop directory",unboundRepo:"Do not bind a repo",followsDesktopCwd:"Follow desktop current cwd",otherProjects:"Other projects",loading:"Loading sessions…",empty:"No sessions yet. Tap “New” to start one, or start from desktop.",automation:"Automation",noProjectPath:"No project path",unreadAria:"New content",primaryRoot:"Primary",secondaryRoot:"Secondary"},status:{conn:{connecting:"Connecting…",authenticating:"Authenticating…",unpaired:"Not paired",online:"Online",offline:"Disconnected"},run:{idle:"Idle",running:"Running",waiting:"Awaiting approval",completed:"Completed",error:"Error"}},storage:{browserDevice:"{platform} browser"},stream:{showReasoning:"Show reasoning",hideReasoning:"Hide reasoning",subagent:"Subagent",loading:"Loading…",generating:"Generating response",emptyHint:"Send a task, or open a Claude Code session from the sidebar."},tool:{running:"Running",failed:"Failed",completed:"Completed",fallbackName:"Operation",truncated:"… (truncated)"}}}},Lg=CS;function Bg(t,i){let l=t;for(const a of i.split(".")){if(l==null||typeof l!="object")return;l=l[a]}return typeof l=="string"?l:void 0}function ES(t,i){return i?t.replace(/\{(\w+)\}/g,(l,a)=>a in i?String(i[a]):l):t}function NS(t,i,l){const a=Bg(Lg[t],i)??Bg(Lg.zh,i)??i;return ES(a,l)}function AS(t,i){return NS(kS(),t,i)}const TS=["command","file_path","path","url","pattern","query"];function RS(t,i,l){let a="";const o=t?.source,f=t?.scope,u=t?.resource;if(l==="ReadSource"&&typeof o=="string"&&o.length>0&&typeof f=="string"&&f.length>0&&typeof u=="string"&&u.length>0)a=AS("mobile.approval.readSourceSummary",{source:o,scope:f,resource:u});else for(const h of TS){const m=t?.[h];if(typeof m=="string"&&m.length>0){a=m;break}}a||(a=JSON.stringify(t??{}));let p;return i==="low"||i==="medium"||i==="high"?p=i:i===void 0||i===""?p="medium":p="high",{summary:a,risk:p}}const zS=16*1024*1024;function pr(t){if(typeof t!="string"||t.length>2048||!/^[A-Za-z0-9_-]+$/.test(t))throw new Error("Invalid output cursor");const i=JSON.parse(atob(t.replace(/-/g,"+").replace(/_/g,"/")));if(typeof i.identity!="string"||!Number.isSafeInteger(i.sequence)||i.sequence<0||!Number.isSafeInteger(i.offset)||i.offset<0)throw new Error("Invalid output cursor");return i}function DS(t){if(t.length>Math.ceil(64*1024/3)*4||!/^[A-Za-z0-9+/]*={0,2}$/.test(t))throw new Error("Invalid output fragment");const i=atob(t);return Uint8Array.from(i,l=>l.charCodeAt(0))}function ga(t,i){try{const l=pr(t),a=pr(i);return l.identity===a.identity?Math.sign(l.sequence-a.sequence):void 0}catch{return}}function _S(t,i,l){if(t.incomplete)return!1;try{if(i.version!==1||i.status!=="ok"||!i.from||!i.through||!i.next||!i.coverageStart||!Array.isArray(i.frames)||i.frames.length>512||new TextEncoder().encode(JSON.stringify(i)).length>1024*1024+16*1024)throw new Error("Output recovery is incomplete");if((t.cursor??i.coverageStart)!==i.from||t.through&&t.through!==i.through||t.coverageStart&&t.coverageStart!==i.coverageStart||t.legacyBaseThroughEventId!==void 0&&t.legacyBaseThroughEventId!==i.legacyBaseThroughEventId)throw new Error("Output recovery page changed its snapshot");let a=pr(i.from);const o=pr(i.through),f=pr(i.coverageStart);if(f.sequence!==0||f.identity!==a.identity||o.identity!==a.identity||a.sequence>o.sequence)throw new Error("Output recovery cursor domain changed");let u=t.pending?{...t.pending,chunks:t.pending.chunks.slice()}:void 0,p=t.appliedCursor??i.from;const h=[];for(const y of i.frames){const b=pr(y.cursor);if(b.identity!==a.identity||b.sequence!==a.sequence+1||y.sequence!==b.sequence||b.offset<=a.offset||b.sequence>o.sequence||!!y.event==!!y.fragment)throw new Error("Output recovery has a gap");let x=y.event;if(y.fragment){const v=y.fragment;if(!u){if(v.index!==0||!Number.isSafeInteger(v.total)||v.total<2||v.total>256)throw new Error("Output fragment has no beginning");u={id:v.id,total:v.total,next:0,bytes:0,chunks:[]}}if(v.id!==u.id||v.total!==u.total||v.index!==u.next)throw new Error("Output fragment has a gap");const j=DS(v.data);if(u.bytes+=j.length,u.bytes>zS)throw new Error("Output fragment exceeds its budget");if(u.chunks.push(j),u.next++,u.next===u.total){const z=new Uint8Array(u.bytes);let A=0;for(const N of u.chunks)z.set(N,A),A+=N.length;x=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(z)),u=void 0}}else if(u)throw new Error("Output fragment was interrupted");if(x){if(typeof x!="object"||typeof x.type!="string"||x.outputRecovery==="incomplete")throw new Error("Invalid output event");h.push({...Eb(x),outputCursor:y.cursor}),p=y.cursor}a=b}const m=pr(i.next);if(m.identity!==a.identity||m.sequence!==a.sequence||m.offset!==a.offset||(i.frames.at(-1)?.cursor??i.from)!==i.next||i.complete!==(i.next===i.through)||i.complete&&u||!i.complete&&!i.frames.length)throw new Error("Output recovery page did not establish coverage");t.cursor=i.next,t.appliedCursor=p,t.through=i.through,t.coverageStart=i.coverageStart,t.legacyBaseThroughEventId=i.legacyBaseThroughEventId,t.pending=u;for(const y of h)l(y);return i.complete}catch{return t.incomplete=!0,t.pending=void 0,!1}}const MS=new Set(["session_started","stream_request_start","text_delta","thinking_delta","tool_use_start","tool_use_args_delta","tool_result","room_tool_result","tool_summary","tombstone","assistant_message","turn_complete","goal_set","goal_updated","goal_cleared","goal_progress","task_update","agent_start","agent_end","background_agent_completed","context_compact","error","session_user_message","steer_injected","user_message","assistant_text"]);function OS(t){if(typeof t!="string"||t.length>2048||!/^[A-Za-z0-9_-]+$/.test(t))return!1;try{const i=JSON.parse(atob(t.replace(/-/g,"+").replace(/_/g,"/")));return typeof i.identity=="string"&&typeof i.hash=="string"&&/^[a-f0-9]{64}$/.test(i.identity)&&/^[a-f0-9]{64}$/.test(i.hash)&&Number.isSafeInteger(i.sequence)&&i.sequence>0&&Number.isSafeInteger(i.offset)&&i.offset>0}catch{return!1}}class ld{lastCursor;blocked=!1;overflowed=!1;inputs=new Set;copy(){const i=new ld;i.lastCursor=this.lastCursor,i.blocked=this.blocked,i.overflowed=this.overflowed;for(const l of this.inputs)i.inputs.add(l);return i}observe(i){if(this.overflowed)return;const l=i;if(l){if(l.outputCursor!==void 0){const a=OS(l.outputCursor)?this.lastCursor?ga(l.outputCursor,this.lastCursor):1:void 0;if(a===void 0||a<=0){this.discardProof();return}this.lastCursor=l.outputCursor;return}if(!(!l.type||!MS.has(l.type))&&!(["session_user_message","steer_injected","user_message"].includes(l.type)&&(l.agentId||l.injected===!0||["agent","system","policy"].includes(String(l.authority)))))if(l.type==="session_user_message"){const a=l.clientMessageId;typeof a!="string"||!a.trim()||a.length>512?this.blocked=!0:this.inputs.add(a),(this.inputIds.length>128||this.memoryBytes>32*1024)&&this.discardProof()}else this.blocked=!0}}acknowledgeInputs(i){for(const l of i)this.inputs.delete(l)}get inputIds(){return[...this.inputs]}get incomplete(){return this.blocked||this.overflowed}get memoryBytes(){return this.inputIds.reduce((i,l)=>i+new TextEncoder().encode(l).length,0)}discardProof(){this.overflowed=!0,this.inputs.clear()}}function ua(t,i,l,a={}){if(t.unpaired)throw new Error("Output recovery contains unpaired visible output");if(i.coverageIdentity!==void 0&&a.requireIdentity!==!1&&(t.incarnation===void 0||t.journalIdentity===void 0))throw new Error("Output recovery Session incarnation proof is unavailable");if(t.incarnation!==void 0&&t.incarnation!==i.coverageIdentity)throw new Error("Output recovery Session incarnation changed");if(t.journalIdentity!==void 0){let f;try{f=JSON.parse(atob((i.coverageStart??"").replace(/-/g,"+").replace(/_/g,"/"))).hash}catch{throw new Error("Output recovery journal pin is unpaired")}if(f!==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(f=>typeof f!="string"||!f.trim()||f.length>512)||o.reduce((f,u)=>f+new TextEncoder().encode(u).length,0)>32*1024)throw new Error("Output recovery input identities are unpaired");if(o.some(f=>!l(f)))throw new Error("Output recovery input has no recorded anchor")}function bi(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)?t:void 0}function Mt(t){return typeof t=="string"?t:""}function Of(t){return Array.isArray(t)?t.map(bi).filter(i=>i!==void 0):[]}function Ug(t){return typeof t=="string"?t:Of(t).filter(i=>i.type==="text").map(i=>Mt(i.text)).join("")}function Ig(t){return bi(t.data)??bi(t.message)??t}function LS(t){const i=[],l=new Set,a=new Set,o=new Map;for(const p of t){const h=bi(p);if(!h)continue;const m=Ig(h);h.type==="tool_use"&&Mt(m.toolCallId)&&o.set(Mt(m.toolCallId),{name:Mt(m.toolName)||"工具",args:bi(m.args)??{}});for(const y of Of(m.content))y.type==="tool_use"&&Mt(y.id)&&o.set(Mt(y.id),{name:Mt(y.name)||"工具",args:bi(y.input)??{}})}const f=(p,h,m,y)=>{p&&(a.has(p)?i.push({type:"tool_use_args_delta",toolCallId:p,args:m,...y?{agentId:y}:{}}):(a.add(p),i.push({type:"tool_use_start",toolCall:{id:p,toolName:h||"工具",args:m},...y?{agentId:y}:{}})))},u=(p,h,m)=>{if(!p)return;const y=o.get(p);a.has(p)||f(p,y?.name||Mt(h.toolName)||"工具",y?.args??{},m);const b=typeof h.result=="string"?h.result:Ug(h.content??h.contentBlocks),x=Mt(h.error);i.push({type:"tool_result",result:{id:p,result:b||x,...x?{error:x}:{},isError:h.isError===!0||h.is_error===!0||!!x},...m?{agentId:m}:{}})};for(const p of t){const h=bi(p);if(!h)continue;const m=Mt(h.id);if(m&&l.has(m))continue;m&&l.add(m);const y=Ig(h),b=Mt(y.agentId)||void 0;switch(typeof h.type=="string"?h.type:typeof y.role=="string"?"message":""){case"message":{const v=Of(y.content);if(y.role==="user"){if(y.injected===!0||y.authority==="agent"||y.authority==="system"||y.authority==="policy")break;const j=Cb(y);if(j.text.startsWith("<system-reminder>"))break;(j.text||j.attachments.length)&&i.push({type:"user_message",...j,...typeof y.clientMessageId=="string"?{clientMessageId:y.clientMessageId}:{}});for(const z of v)z.type==="tool_result"&&u(Mt(z.tool_use_id),z,b)}else if(y.role==="assistant"){const j=Ug(y.content),z=v.filter(A=>A.type==="reasoning").map(A=>Mt(A.reasoningContent)||Mt(A.text)).join("");if(j||z){const A=b?{agentId:b}:{};i.push({type:"stream_request_start",...A}),z&&i.push({type:"thinking_delta",text:z,...A}),j&&i.push({type:"text_delta",text:j,...A}),i.push({type:"assistant_message",...A})}for(const A of v)A.type==="tool_use"&&f(Mt(A.id),Mt(A.name),bi(A.input)??{},b)}else y.role==="tool"&&u(Mt(y.tool_call_id),y,b);break}case"tool_use":f(Mt(y.toolCallId),Mt(y.toolName),bi(y.args)??{},b);break;case"tool_result":u(Mt(y.toolCallId),y,b);break;case"subagent":b&&i.push({type:"agent_start",agentId:b,name:Mt(y.name),description:Mt(y.description),status:"recorded"});break;case"error":Mt(y.error)&&i.push({type:"error",error:y.error});break;case"turn_stopped":i.push({type:"turn_complete",reason:"aborted_tools"});break;case"session_meta":Mt(y.sessionId)&&i.push({type:"session_started",sessionId:y.sessionId});break}}return i}function Nb(t){let i=eo();for(const l of LS(t))i=mr(i,l);return{...i,run:i.run==="error"?"error":"idle",liveByAgent:{}}}var al={},Hc,qg;function BS(){return qg||(qg=1,Hc=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}),Hc}var Vc={},Fi={},Hg;function vr(){if(Hg)return Fi;Hg=1;let t;const i=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];return Fi.getSymbolSize=function(a){if(!a)throw new Error('"version" cannot be null or undefined');if(a<1||a>40)throw new Error('"version" should be in range from 1 to 40');return a*4+17},Fi.getSymbolTotalCodewords=function(a){return i[a]},Fi.getBCHDigit=function(l){let a=0;for(;l!==0;)a++,l>>>=1;return a},Fi.setToSJISFunction=function(a){if(typeof a!="function")throw new Error('"toSJISFunc" is not a valid function.');t=a},Fi.isKanjiModeEnabled=function(){return typeof t<"u"},Fi.toSJIS=function(a){return t(a)},Fi}var Yc={},Vg;function ad(){return Vg||(Vg=1,(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function i(l){if(typeof l!="string")throw new Error("Param is not a string");switch(l.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: "+l)}}t.isValid=function(a){return a&&typeof a.bit<"u"&&a.bit>=0&&a.bit<4},t.from=function(a,o){if(t.isValid(a))return a;try{return i(a)}catch{return o}}})(Yc)),Yc}var Gc,Yg;function US(){if(Yg)return Gc;Yg=1;function t(){this.buffer=[],this.length=0}return t.prototype={get:function(i){const l=Math.floor(i/8);return(this.buffer[l]>>>7-i%8&1)===1},put:function(i,l){for(let a=0;a<l;a++)this.putBit((i>>>l-a-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(i){const l=Math.floor(this.length/8);this.buffer.length<=l&&this.buffer.push(0),i&&(this.buffer[l]|=128>>>this.length%8),this.length++}},Gc=t,Gc}var Fc,Gg;function IS(){if(Gg)return Fc;Gg=1;function t(i){if(!i||i<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=i,this.data=new Uint8Array(i*i),this.reservedBit=new Uint8Array(i*i)}return t.prototype.set=function(i,l,a,o){const f=i*this.size+l;this.data[f]=a,o&&(this.reservedBit[f]=!0)},t.prototype.get=function(i,l){return this.data[i*this.size+l]},t.prototype.xor=function(i,l,a){this.data[i*this.size+l]^=a},t.prototype.isReserved=function(i,l){return this.reservedBit[i*this.size+l]},Fc=t,Fc}var $c={},Fg;function qS(){return Fg||(Fg=1,(function(t){const i=vr().getSymbolSize;t.getRowColCoords=function(a){if(a===1)return[];const o=Math.floor(a/7)+2,f=i(a),u=f===145?26:Math.ceil((f-13)/(2*o-2))*2,p=[f-7];for(let h=1;h<o-1;h++)p[h]=p[h-1]-u;return p.push(6),p.reverse()},t.getPositions=function(a){const o=[],f=t.getRowColCoords(a),u=f.length;for(let p=0;p<u;p++)for(let h=0;h<u;h++)p===0&&h===0||p===0&&h===u-1||p===u-1&&h===0||o.push([f[p],f[h]]);return o}})($c)),$c}var Qc={},$g;function HS(){if($g)return Qc;$g=1;const t=vr().getSymbolSize,i=7;return Qc.getPositions=function(a){const o=t(a);return[[0,0],[o-i,0],[0,o-i]]},Qc}var Xc={},Qg;function VS(){return Qg||(Qg=1,(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const i={N1:3,N2:3,N3:40,N4:10};t.isValid=function(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 f=o.size;let u=0,p=0,h=0,m=null,y=null;for(let b=0;b<f;b++){p=h=0,m=y=null;for(let x=0;x<f;x++){let v=o.get(b,x);v===m?p++:(p>=5&&(u+=i.N1+(p-5)),m=v,p=1),v=o.get(x,b),v===y?h++:(h>=5&&(u+=i.N1+(h-5)),y=v,h=1)}p>=5&&(u+=i.N1+(p-5)),h>=5&&(u+=i.N1+(h-5))}return u},t.getPenaltyN2=function(o){const f=o.size;let u=0;for(let p=0;p<f-1;p++)for(let h=0;h<f-1;h++){const m=o.get(p,h)+o.get(p,h+1)+o.get(p+1,h)+o.get(p+1,h+1);(m===4||m===0)&&u++}return u*i.N2},t.getPenaltyN3=function(o){const f=o.size;let u=0,p=0,h=0;for(let m=0;m<f;m++){p=h=0;for(let y=0;y<f;y++)p=p<<1&2047|o.get(m,y),y>=10&&(p===1488||p===93)&&u++,h=h<<1&2047|o.get(y,m),y>=10&&(h===1488||h===93)&&u++}return u*i.N3},t.getPenaltyN4=function(o){let f=0;const u=o.data.length;for(let h=0;h<u;h++)f+=o.data[h];return Math.abs(Math.ceil(f*100/u/5)-10)*i.N4};function l(a,o,f){switch(a){case t.Patterns.PATTERN000:return(o+f)%2===0;case t.Patterns.PATTERN001:return o%2===0;case t.Patterns.PATTERN010:return f%3===0;case t.Patterns.PATTERN011:return(o+f)%3===0;case t.Patterns.PATTERN100:return(Math.floor(o/2)+Math.floor(f/3))%2===0;case t.Patterns.PATTERN101:return o*f%2+o*f%3===0;case t.Patterns.PATTERN110:return(o*f%2+o*f%3)%2===0;case t.Patterns.PATTERN111:return(o*f%3+(o+f)%2)%2===0;default:throw new Error("bad maskPattern:"+a)}}t.applyMask=function(o,f){const u=f.size;for(let p=0;p<u;p++)for(let h=0;h<u;h++)f.isReserved(h,p)||f.xor(h,p,l(o,h,p))},t.getBestMask=function(o,f){const u=Object.keys(t.Patterns).length;let p=0,h=1/0;for(let m=0;m<u;m++){f(m),t.applyMask(m,o);const y=t.getPenaltyN1(o)+t.getPenaltyN2(o)+t.getPenaltyN3(o)+t.getPenaltyN4(o);t.applyMask(m,o),y<h&&(h=y,p=m)}return p}})(Xc)),Xc}var Qs={},Xg;function Ab(){if(Xg)return Qs;Xg=1;const t=ad(),i=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],l=[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 Qs.getBlocksCount=function(o,f){switch(f){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}},Qs.getTotalCodewordsCount=function(o,f){switch(f){case t.L:return l[(o-1)*4+0];case t.M:return l[(o-1)*4+1];case t.Q:return l[(o-1)*4+2];case t.H:return l[(o-1)*4+3];default:return}},Qs}var Kc={},ca={},Kg;function YS(){if(Kg)return ca;Kg=1;const t=new Uint8Array(512),i=new Uint8Array(256);return(function(){let a=1;for(let o=0;o<255;o++)t[o]=a,i[a]=o,a<<=1,a&256&&(a^=285);for(let o=255;o<512;o++)t[o]=t[o-255]})(),ca.log=function(a){if(a<1)throw new Error("log("+a+")");return i[a]},ca.exp=function(a){return t[a]},ca.mul=function(a,o){return a===0||o===0?0:t[i[a]+i[o]]},ca}var Pg;function GS(){return Pg||(Pg=1,(function(t){const i=YS();t.mul=function(a,o){const f=new Uint8Array(a.length+o.length-1);for(let u=0;u<a.length;u++)for(let p=0;p<o.length;p++)f[u+p]^=i.mul(a[u],o[p]);return f},t.mod=function(a,o){let f=new Uint8Array(a);for(;f.length-o.length>=0;){const u=f[0];for(let h=0;h<o.length;h++)f[h]^=i.mul(o[h],u);let p=0;for(;p<f.length&&f[p]===0;)p++;f=f.slice(p)}return f},t.generateECPolynomial=function(a){let o=new Uint8Array([1]);for(let f=0;f<a;f++)o=t.mul(o,new Uint8Array([1,i.exp(f)]));return o}})(Kc)),Kc}var Pc,Zg;function FS(){if(Zg)return Pc;Zg=1;const t=GS();function i(l){this.genPoly=void 0,this.degree=l,this.degree&&this.initialize(this.degree)}return i.prototype.initialize=function(a){this.degree=a,this.genPoly=t.generateECPolynomial(this.degree)},i.prototype.encode=function(a){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(a.length+this.degree);o.set(a);const f=t.mod(o,this.genPoly),u=this.degree-f.length;if(u>0){const p=new Uint8Array(this.degree);return p.set(f,u),p}return f},Pc=i,Pc}var Zc={},Jc={},Wc={},Jg;function Tb(){return Jg||(Jg=1,Wc.isValid=function(i){return!isNaN(i)&&i>=1&&i<=40}),Wc}var Pn={},Wg;function Rb(){if(Wg)return Pn;Wg=1;const t="[0-9]+",i="[A-Z $%*+\\-./:]+";let l="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";l=l.replace(/u/g,"\\u");const a="(?:(?![A-Z0-9 $%*+\\-./:]|"+l+`)(?:.|[\r
22
+ ]))+`;Pn.KANJI=new RegExp(l,"g"),Pn.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),Pn.BYTE=new RegExp(a,"g"),Pn.NUMERIC=new RegExp(t,"g"),Pn.ALPHANUMERIC=new RegExp(i,"g");const o=new RegExp("^"+l+"$"),f=new RegExp("^"+t+"$"),u=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");return Pn.testKanji=function(h){return o.test(h)},Pn.testNumeric=function(h){return f.test(h)},Pn.testAlphanumeric=function(h){return u.test(h)},Pn}var ey;function xr(){return ey||(ey=1,(function(t){const i=Tb(),l=Rb();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(f,u){if(!f.ccBits)throw new Error("Invalid mode: "+f);if(!i.isValid(u))throw new Error("Invalid version: "+u);return u>=1&&u<10?f.ccBits[0]:u<27?f.ccBits[1]:f.ccBits[2]},t.getBestModeForData=function(f){return l.testNumeric(f)?t.NUMERIC:l.testAlphanumeric(f)?t.ALPHANUMERIC:l.testKanji(f)?t.KANJI:t.BYTE},t.toString=function(f){if(f&&f.id)return f.id;throw new Error("Invalid mode")},t.isValid=function(f){return f&&f.bit&&f.ccBits};function a(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(f,u){if(t.isValid(f))return f;try{return a(f)}catch{return u}}})(Jc)),Jc}var ty;function $S(){return ty||(ty=1,(function(t){const i=vr(),l=Ab(),a=ad(),o=xr(),f=Tb(),u=7973,p=i.getBCHDigit(u);function h(x,v,j){for(let z=1;z<=40;z++)if(v<=t.getCapacity(z,j,x))return z}function m(x,v){return o.getCharCountIndicator(x,v)+4}function y(x,v){let j=0;return x.forEach(function(z){const A=m(z.mode,v);j+=A+z.getBitsLength()}),j}function b(x,v){for(let j=1;j<=40;j++)if(y(x,j)<=t.getCapacity(j,v,o.MIXED))return j}t.from=function(v,j){return f.isValid(v)?parseInt(v,10):j},t.getCapacity=function(v,j,z){if(!f.isValid(v))throw new Error("Invalid QR Code version");typeof z>"u"&&(z=o.BYTE);const A=i.getSymbolTotalCodewords(v),N=l.getTotalCodewordsCount(v,j),T=(A-N)*8;if(z===o.MIXED)return T;const M=T-m(z,v);switch(z){case o.NUMERIC:return Math.floor(M/10*3);case o.ALPHANUMERIC:return Math.floor(M/11*2);case o.KANJI:return Math.floor(M/13);case o.BYTE:default:return Math.floor(M/8)}},t.getBestVersionForData=function(v,j){let z;const A=a.from(j,a.M);if(Array.isArray(v)){if(v.length>1)return b(v,A);if(v.length===0)return 1;z=v[0]}else z=v;return h(z.mode,z.getLength(),A)},t.getEncodedBits=function(v){if(!f.isValid(v)||v<7)throw new Error("Invalid QR Code version");let j=v<<12;for(;i.getBCHDigit(j)-p>=0;)j^=u<<i.getBCHDigit(j)-p;return v<<12|j}})(Zc)),Zc}var ef={},ny;function QS(){if(ny)return ef;ny=1;const t=vr(),i=1335,l=21522,a=t.getBCHDigit(i);return ef.getEncodedBits=function(f,u){const p=f.bit<<3|u;let h=p<<10;for(;t.getBCHDigit(h)-a>=0;)h^=i<<t.getBCHDigit(h)-a;return(p<<10|h)^l},ef}var tf={},nf,iy;function XS(){if(iy)return nf;iy=1;const t=xr();function i(l){this.mode=t.NUMERIC,this.data=l.toString()}return i.getBitsLength=function(a){return 10*Math.floor(a/3)+(a%3?a%3*3+1:0)},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(a){let o,f,u;for(o=0;o+3<=this.data.length;o+=3)f=this.data.substr(o,3),u=parseInt(f,10),a.put(u,10);const p=this.data.length-o;p>0&&(f=this.data.substr(o),u=parseInt(f,10),a.put(u,p*3+1))},nf=i,nf}var rf,ry;function KS(){if(ry)return rf;ry=1;const t=xr(),i=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function l(a){this.mode=t.ALPHANUMERIC,this.data=a}return l.getBitsLength=function(o){return 11*Math.floor(o/2)+6*(o%2)},l.prototype.getLength=function(){return this.data.length},l.prototype.getBitsLength=function(){return l.getBitsLength(this.data.length)},l.prototype.write=function(o){let f;for(f=0;f+2<=this.data.length;f+=2){let u=i.indexOf(this.data[f])*45;u+=i.indexOf(this.data[f+1]),o.put(u,11)}this.data.length%2&&o.put(i.indexOf(this.data[f]),6)},rf=l,rf}var lf,ly;function PS(){if(ly)return lf;ly=1;const t=xr();function i(l){this.mode=t.BYTE,typeof l=="string"?this.data=new TextEncoder().encode(l):this.data=new Uint8Array(l)}return i.getBitsLength=function(a){return a*8},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(l){for(let a=0,o=this.data.length;a<o;a++)l.put(this.data[a],8)},lf=i,lf}var af,ay;function ZS(){if(ay)return af;ay=1;const t=xr(),i=vr();function l(a){this.mode=t.KANJI,this.data=a}return l.getBitsLength=function(o){return o*13},l.prototype.getLength=function(){return this.data.length},l.prototype.getBitsLength=function(){return l.getBitsLength(this.data.length)},l.prototype.write=function(a){let o;for(o=0;o<this.data.length;o++){let f=i.toSJIS(this.data[o]);if(f>=33088&&f<=40956)f-=33088;else if(f>=57408&&f<=60351)f-=49472;else throw new Error("Invalid SJIS character: "+this.data[o]+`
23
+ Make sure your charset is UTF-8`);f=(f>>>8&255)*192+(f&255),a.put(f,13)}},af=l,af}var sf={exports:{}},sy;function JS(){return sy||(sy=1,(function(t){var i={single_source_shortest_paths:function(l,a,o){var f={},u={};u[a]=0;var p=i.PriorityQueue.make();p.push(a,0);for(var h,m,y,b,x,v,j,z,A;!p.empty();){h=p.pop(),m=h.value,b=h.cost,x=l[m]||{};for(y in x)x.hasOwnProperty(y)&&(v=x[y],j=b+v,z=u[y],A=typeof u[y]>"u",(A||z>j)&&(u[y]=j,p.push(y,j),f[y]=m))}if(typeof o<"u"&&typeof u[o]>"u"){var N=["Could not find a path from ",a," to ",o,"."].join("");throw new Error(N)}return f},extract_shortest_path_from_predecessor_list:function(l,a){for(var o=[],f=a;f;)o.push(f),l[f],f=l[f];return o.reverse(),o},find_path:function(l,a,o){var f=i.single_source_shortest_paths(l,a,o);return i.extract_shortest_path_from_predecessor_list(f,o)},PriorityQueue:{make:function(l){var a=i.PriorityQueue,o={},f;l=l||{};for(f in a)a.hasOwnProperty(f)&&(o[f]=a[f]);return o.queue=[],o.sorter=l.sorter||a.default_sorter,o},default_sorter:function(l,a){return l.cost-a.cost},push:function(l,a){var o={value:l,cost:a};this.queue.push(o),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=i})(sf)),sf.exports}var oy;function WS(){return oy||(oy=1,(function(t){const i=xr(),l=XS(),a=KS(),o=PS(),f=ZS(),u=Rb(),p=vr(),h=JS();function m(N){return unescape(encodeURIComponent(N)).length}function y(N,T,M){const G=[];let ae;for(;(ae=N.exec(M))!==null;)G.push({data:ae[0],index:ae.index,mode:T,length:ae[0].length});return G}function b(N){const T=y(u.NUMERIC,i.NUMERIC,N),M=y(u.ALPHANUMERIC,i.ALPHANUMERIC,N);let G,ae;return p.isKanjiModeEnabled()?(G=y(u.BYTE,i.BYTE,N),ae=y(u.KANJI,i.KANJI,N)):(G=y(u.BYTE_KANJI,i.BYTE,N),ae=[]),T.concat(M,G,ae).sort(function(H,W){return H.index-W.index}).map(function(H){return{data:H.data,mode:H.mode,length:H.length}})}function x(N,T){switch(T){case i.NUMERIC:return l.getBitsLength(N);case i.ALPHANUMERIC:return a.getBitsLength(N);case i.KANJI:return f.getBitsLength(N);case i.BYTE:return o.getBitsLength(N)}}function v(N){return N.reduce(function(T,M){const G=T.length-1>=0?T[T.length-1]:null;return G&&G.mode===M.mode?(T[T.length-1].data+=M.data,T):(T.push(M),T)},[])}function j(N){const T=[];for(let M=0;M<N.length;M++){const G=N[M];switch(G.mode){case i.NUMERIC:T.push([G,{data:G.data,mode:i.ALPHANUMERIC,length:G.length},{data:G.data,mode:i.BYTE,length:G.length}]);break;case i.ALPHANUMERIC:T.push([G,{data:G.data,mode:i.BYTE,length:G.length}]);break;case i.KANJI:T.push([G,{data:G.data,mode:i.BYTE,length:m(G.data)}]);break;case i.BYTE:T.push([{data:G.data,mode:i.BYTE,length:m(G.data)}])}}return T}function z(N,T){const M={},G={start:{}};let ae=["start"];for(let D=0;D<N.length;D++){const H=N[D],W=[];for(let q=0;q<H.length;q++){const C=H[q],L=""+D+q;W.push(L),M[L]={node:C,lastCount:0},G[L]={};for(let B=0;B<ae.length;B++){const Q=ae[B];M[Q]&&M[Q].node.mode===C.mode?(G[Q][L]=x(M[Q].lastCount+C.length,C.mode)-x(M[Q].lastCount,C.mode),M[Q].lastCount+=C.length):(M[Q]&&(M[Q].lastCount=C.length),G[Q][L]=x(C.length,C.mode)+4+i.getCharCountIndicator(C.mode,T))}}ae=W}for(let D=0;D<ae.length;D++)G[ae[D]].end=0;return{map:G,table:M}}function A(N,T){let M;const G=i.getBestModeForData(N);if(M=i.from(T,G),M!==i.BYTE&&M.bit<G.bit)throw new Error('"'+N+'" cannot be encoded with mode '+i.toString(M)+`.
24
+ Suggested mode is: `+i.toString(G));switch(M===i.KANJI&&!p.isKanjiModeEnabled()&&(M=i.BYTE),M){case i.NUMERIC:return new l(N);case i.ALPHANUMERIC:return new a(N);case i.KANJI:return new f(N);case i.BYTE:return new o(N)}}t.fromArray=function(T){return T.reduce(function(M,G){return typeof G=="string"?M.push(A(G,null)):G.data&&M.push(A(G.data,G.mode)),M},[])},t.fromString=function(T,M){const G=b(T,p.isKanjiModeEnabled()),ae=j(G),D=z(ae,M),H=h.find_path(D.map,"start","end"),W=[];for(let q=1;q<H.length-1;q++)W.push(D.table[H[q]].node);return t.fromArray(v(W))},t.rawSplit=function(T){return t.fromArray(b(T,p.isKanjiModeEnabled()))}})(tf)),tf}var uy;function ew(){if(uy)return Vc;uy=1;const t=vr(),i=ad(),l=US(),a=IS(),o=qS(),f=HS(),u=VS(),p=Ab(),h=FS(),m=$S(),y=QS(),b=xr(),x=WS();function v(D,H){const W=D.size,q=f.getPositions(H);for(let C=0;C<q.length;C++){const L=q[C][0],B=q[C][1];for(let Q=-1;Q<=7;Q++)if(!(L+Q<=-1||W<=L+Q))for(let J=-1;J<=7;J++)B+J<=-1||W<=B+J||(Q>=0&&Q<=6&&(J===0||J===6)||J>=0&&J<=6&&(Q===0||Q===6)||Q>=2&&Q<=4&&J>=2&&J<=4?D.set(L+Q,B+J,!0,!0):D.set(L+Q,B+J,!1,!0))}}function j(D){const H=D.size;for(let W=8;W<H-8;W++){const q=W%2===0;D.set(W,6,q,!0),D.set(6,W,q,!0)}}function z(D,H){const W=o.getPositions(H);for(let q=0;q<W.length;q++){const C=W[q][0],L=W[q][1];for(let B=-2;B<=2;B++)for(let Q=-2;Q<=2;Q++)B===-2||B===2||Q===-2||Q===2||B===0&&Q===0?D.set(C+B,L+Q,!0,!0):D.set(C+B,L+Q,!1,!0)}}function A(D,H){const W=D.size,q=m.getEncodedBits(H);let C,L,B;for(let Q=0;Q<18;Q++)C=Math.floor(Q/3),L=Q%3+W-8-3,B=(q>>Q&1)===1,D.set(C,L,B,!0),D.set(L,C,B,!0)}function N(D,H,W){const q=D.size,C=y.getEncodedBits(H,W);let L,B;for(L=0;L<15;L++)B=(C>>L&1)===1,L<6?D.set(L,8,B,!0):L<8?D.set(L+1,8,B,!0):D.set(q-15+L,8,B,!0),L<8?D.set(8,q-L-1,B,!0):L<9?D.set(8,15-L-1+1,B,!0):D.set(8,15-L-1,B,!0);D.set(q-8,8,1,!0)}function T(D,H){const W=D.size;let q=-1,C=W-1,L=7,B=0;for(let Q=W-1;Q>0;Q-=2)for(Q===6&&Q--;;){for(let J=0;J<2;J++)if(!D.isReserved(C,Q-J)){let K=!1;B<H.length&&(K=(H[B]>>>L&1)===1),D.set(C,Q-J,K),L--,L===-1&&(B++,L=7)}if(C+=q,C<0||W<=C){C-=q,q=-q;break}}}function M(D,H,W){const q=new l;W.forEach(function(J){q.put(J.mode.bit,4),q.put(J.getLength(),b.getCharCountIndicator(J.mode,D)),J.write(q)});const C=t.getSymbolTotalCodewords(D),L=p.getTotalCodewordsCount(D,H),B=(C-L)*8;for(q.getLengthInBits()+4<=B&&q.put(0,4);q.getLengthInBits()%8!==0;)q.putBit(0);const Q=(B-q.getLengthInBits())/8;for(let J=0;J<Q;J++)q.put(J%2?17:236,8);return G(q,D,H)}function G(D,H,W){const q=t.getSymbolTotalCodewords(H),C=p.getTotalCodewordsCount(H,W),L=q-C,B=p.getBlocksCount(H,W),Q=q%B,J=B-Q,K=Math.floor(q/B),I=Math.floor(L/B),Y=I+1,X=K-I,pe=new h(X);let k=0;const O=new Array(B),te=new Array(B);let R=0;const ee=new Uint8Array(D.buffer);for(let F=0;F<B;F++){const ke=F<J?I:Y;O[F]=ee.slice(k,k+ke),te[F]=pe.encode(O[F]),k+=ke,R=Math.max(R,ke)}const ve=new Uint8Array(q);let le=0,ue,xe;for(ue=0;ue<R;ue++)for(xe=0;xe<B;xe++)ue<O[xe].length&&(ve[le++]=O[xe][ue]);for(ue=0;ue<X;ue++)for(xe=0;xe<B;xe++)ve[le++]=te[xe][ue];return ve}function ae(D,H,W,q){let C;if(Array.isArray(D))C=x.fromArray(D);else if(typeof D=="string"){let K=H;if(!K){const I=x.rawSplit(D);K=m.getBestVersionForData(I,W)}C=x.fromString(D,K||40)}else throw new Error("Invalid data");const L=m.getBestVersionForData(C,W);if(!L)throw new Error("The amount of data is too big to be stored in a QR Code");if(!H)H=L;else if(H<L)throw new Error(`
25
+ The chosen QR Code version cannot contain this amount of data.
26
+ Minimum version required to store current data is: `+L+`.
27
+ `);const B=M(H,W,C),Q=t.getSymbolSize(H),J=new a(Q);return v(J,H),j(J),z(J,H),N(J,W,0),H>=7&&A(J,H),T(J,B),isNaN(q)&&(q=u.getBestMask(J,N.bind(null,J,W))),u.applyMask(q,J),N(J,W,q),{modules:J,version:H,errorCorrectionLevel:W,maskPattern:q,segments:C}}return Vc.create=function(H,W){if(typeof H>"u"||H==="")throw new Error("No input text");let q=i.M,C,L;return typeof W<"u"&&(q=i.from(W.errorCorrectionLevel,i.M),C=m.from(W.version),L=u.from(W.maskPattern),W.toSJISFunc&&t.setToSJISFunction(W.toSJISFunc)),ae(H,C,q,L)},Vc}var of={},uf={},cy;function zb(){return cy||(cy=1,(function(t){function i(l){if(typeof l=="number"&&(l=l.toString()),typeof l!="string")throw new Error("Color should be defined as hex string");let a=l.slice().replace("#","").split("");if(a.length<3||a.length===5||a.length>8)throw new Error("Invalid hex color: "+l);(a.length===3||a.length===4)&&(a=Array.prototype.concat.apply([],a.map(function(f){return[f,f]}))),a.length===6&&a.push("F","F");const o=parseInt(a.join(""),16);return{r:o>>24&255,g:o>>16&255,b:o>>8&255,a:o&255,hex:"#"+a.slice(0,6).join("")}}t.getOptions=function(a){a||(a={}),a.color||(a.color={});const o=typeof a.margin>"u"||a.margin===null||a.margin<0?4:a.margin,f=a.width&&a.width>=21?a.width:void 0,u=a.scale||4;return{width:f,scale:f?4:u,margin:o,color:{dark:i(a.color.dark||"#000000ff"),light:i(a.color.light||"#ffffffff")},type:a.type,rendererOpts:a.rendererOpts||{}}},t.getScale=function(a,o){return o.width&&o.width>=a+o.margin*2?o.width/(a+o.margin*2):o.scale},t.getImageWidth=function(a,o){const f=t.getScale(a,o);return Math.floor((a+o.margin*2)*f)},t.qrToImageData=function(a,o,f){const u=o.modules.size,p=o.modules.data,h=t.getScale(u,f),m=Math.floor((u+f.margin*2)*h),y=f.margin*h,b=[f.color.light,f.color.dark];for(let x=0;x<m;x++)for(let v=0;v<m;v++){let j=(x*m+v)*4,z=f.color.light;if(x>=y&&v>=y&&x<m-y&&v<m-y){const A=Math.floor((x-y)/h),N=Math.floor((v-y)/h);z=b[p[A*u+N]?1:0]}a[j++]=z.r,a[j++]=z.g,a[j++]=z.b,a[j]=z.a}}})(uf)),uf}var fy;function tw(){return fy||(fy=1,(function(t){const i=zb();function l(o,f,u){o.clearRect(0,0,f.width,f.height),f.style||(f.style={}),f.height=u,f.width=u,f.style.height=u+"px",f.style.width=u+"px"}function a(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(f,u,p){let h=p,m=u;typeof h>"u"&&(!u||!u.getContext)&&(h=u,u=void 0),u||(m=a()),h=i.getOptions(h);const y=i.getImageWidth(f.modules.size,h),b=m.getContext("2d"),x=b.createImageData(y,y);return i.qrToImageData(x.data,f,h),l(b,m,y),b.putImageData(x,0,0),m},t.renderToDataURL=function(f,u,p){let h=p;typeof h>"u"&&(!u||!u.getContext)&&(h=u,u=void 0),h||(h={});const m=t.render(f,u,h),y=h.type||"image/png",b=h.rendererOpts||{};return m.toDataURL(y,b.quality)}})(of)),of}var cf={},dy;function nw(){if(dy)return cf;dy=1;const t=zb();function i(o,f){const u=o.a/255,p=f+'="'+o.hex+'"';return u<1?p+" "+f+'-opacity="'+u.toFixed(2).slice(1)+'"':p}function l(o,f,u){let p=o+f;return typeof u<"u"&&(p+=" "+u),p}function a(o,f,u){let p="",h=0,m=!1,y=0;for(let b=0;b<o.length;b++){const x=Math.floor(b%f),v=Math.floor(b/f);!x&&!m&&(m=!0),o[b]?(y++,b>0&&x>0&&o[b-1]||(p+=m?l("M",x+u,.5+v+u):l("m",h,0),h=0,m=!1),x+1<f&&o[b+1]||(p+=l("h",y),y=0)):h++}return p}return cf.render=function(f,u,p){const h=t.getOptions(u),m=f.modules.size,y=f.modules.data,b=m+h.margin*2,x=h.color.light.a?"<path "+i(h.color.light,"fill")+' d="M0 0h'+b+"v"+b+'H0z"/>':"",v="<path "+i(h.color.dark,"stroke")+' d="'+a(y,m,h.margin)+'"/>',j='viewBox="0 0 '+b+" "+b+'"',A='<svg xmlns="http://www.w3.org/2000/svg" '+(h.width?'width="'+h.width+'" height="'+h.width+'" ':"")+j+' shape-rendering="crispEdges">'+x+v+`</svg>
28
+ `;return typeof p=="function"&&p(null,A),A},cf}var hy;function iw(){if(hy)return al;hy=1;const t=BS(),i=ew(),l=tw(),a=nw();function o(f,u,p,h,m){const y=[].slice.call(arguments,1),b=y.length,x=typeof y[b-1]=="function";if(!x&&!t())throw new Error("Callback required as last argument");if(x){if(b<2)throw new Error("Too few arguments provided");b===2?(m=p,p=u,u=h=void 0):b===3&&(u.getContext&&typeof m>"u"?(m=h,h=void 0):(m=h,h=p,p=u,u=void 0))}else{if(b<1)throw new Error("Too few arguments provided");return b===1?(p=u,u=h=void 0):b===2&&!u.getContext&&(h=p,p=u,u=void 0),new Promise(function(v,j){try{const z=i.create(p,h);v(f(z,u,h))}catch(z){j(z)}})}try{const v=i.create(p,h);m(null,f(v,u,h))}catch(v){m(v)}}return al.create=i.create,al.toCanvas=o.bind(null,l.render),al.toDataURL=o.bind(null,l.renderToDataURL),al.toString=o.bind(null,function(f,u,p){return a.render(f,p)}),al}var rw=iw();const lw=co(rw),aw={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 sw(t){const i={...aw,...t.labels},l=xi(t.authorization),[a,o]=w.useState({}),[f,u]=w.useState({}),[p,h]=w.useState(),[m,y]=w.useState(!1),[b,x]=w.useState(Date.now()),v=Math.min(t.authorization.expiresAt?Date.parse(t.authorization.expiresAt):1/0,l?Date.parse(l.expiresAt):1/0),j=l?.kind==="qr-code"&&l.qr?Date.parse(l.qr.challengeExpiresAt):1/0,z=l?.kind==="qr-code"&&l.phase!=="expired"?l.qr?.payload:void 0;if(w.useEffect(()=>{o({}),u({})},[t.authorization.id,l?.id]),w.useEffect(()=>{x(Date.now());const D=[v,j].filter(H=>Number.isFinite(H)&&H>Date.now()).map(H=>setTimeout(()=>x(Date.now()),H-Date.now()+1));return()=>{for(const H of D)clearTimeout(H)}},[v,j]),w.useEffect(()=>{let D=!0;if(h(void 0),y(!1),!z||z.length>4096||j<=Date.now()){z&&z.length>4096&&y(!0);return}return lw.toDataURL(z,{width:220,margin:2,errorCorrectionLevel:"M"}).then(H=>{D&&h(H)}).catch(()=>{D&&y(!0)}),()=>{D=!1}},[z,j]),t.authorization.state!=="pending"){const D=t.authorization.state==="connected"?t.authorization.connection?i.connected:i.processing:t.authorization.state==="cancelled"?i.cancelled:t.authorization.errorCode==="authorization_expired"?i.expired:i.failed;return c.jsx("p",{className:"link-authorization-status",role:"status",children:D})}if(!l)return c.jsx("p",{role:"alert",children:i.unsupported});if(!Number.isFinite(v)||v<=b)return c.jsx("p",{className:"link-authorization-status",role:"status",children:i.expired});const A=!!t.busy,N=(D,H)=>t.onRespond({stepId:l.id,operation:D,...H?{input:H}:{}}),T=D=>{if(t.canOpenUrl===!1)return null;const H=o1(D);return H?c.jsxs("button",{type:"button",disabled:A,onClick:()=>t.onOpenUrl(H),children:[i.openPage," ↗"]}):c.jsx("p",{role:"alert",children:i.invalidUrl})},M=c.jsxs("p",{className:"link-authorization-expires",children:[i.expiresAt," ",new Date(v).toLocaleTimeString()]}),G=t.authorization.errorCode?c.jsx("p",{className:"link-authorization-error",role:"alert",children:t.authorization.errorCode==="provider_rejected"?i.rejected:t.authorization.errorCode==="cli_unavailable"?i.cliUnavailable:i.failed}):null,ae=()=>{switch(l.kind){case"redirect":return c.jsxs("div",{className:"link-authorization-step",role:"status",children:[c.jsx("p",{children:i.waitingBrowser}),T(l.authorizationUrl),M]});case"device-code":return c.jsxs("div",{className:"link-authorization-step link-authorization-device",children:[c.jsx("p",{children:i.deviceInstruction}),c.jsx("strong",{className:"link-authorization-code",children:l.userCode}),c.jsxs("div",{className:"link-authorization-actions",children:[t.onCopy&&c.jsx("button",{type:"button",onClick:()=>t.onCopy?.(l.userCode),children:i.copy}),T(l.verificationUriComplete??l.verificationUri)]}),M]});case"qr-code":{const D=l.phase==="expired"||j<=b;return c.jsxs("div",{className:"link-authorization-step link-authorization-qr",children:[c.jsx("p",{role:"status",children:D?i.qrExpired:l.phase==="awaiting-confirmation"?i.confirmOnPhone:i.scan}),!D&&p&&c.jsx("img",{width:220,height:220,src:p,alt:i.qrAlt}),!D&&m&&c.jsx("p",{role:"alert",children:i.qrError}),!D&&l.qr?.instructions.map((H,W)=>c.jsx("p",{children:H},W)),l.canRefresh&&c.jsx("button",{type:"button",disabled:A,onClick:()=>N("refresh-qr"),children:i.refreshQr}),M]})}case"credential-input":return c.jsxs("form",{className:"link-authorization-step link-authorization-fields",onSubmit:D=>{if(D.preventDefault(),A)return;const H={};for(const W of l.fields)H[W.id]=a[W.id]??"";o({}),N("submit",H)},children:[l.purpose!=="credential"&&c.jsx("p",{children:l.purpose==="verification-code"?i.verifyCode:i.secondFactor}),l.fields.map(D=>c.jsxs("label",{children:[D.label,c.jsx("input",{name:D.id,type:D.secret?"password":"text",autoComplete:"off",spellCheck:!1,value:a[D.id]??"",placeholder:D.placeholder,maxLength:Math.min(D.maxLength??16384,16384),required:D.required,disabled:A,onChange:H=>o(W=>({...W,[D.id]:H.target.value}))})]},D.id)),c.jsx("button",{type:"submit",disabled:A||l.fields.some(D=>D.required&&!a[D.id]?.trim()),children:i.submit}),M]});case"local-session":return c.jsxs("div",{className:"link-authorization-step",children:[c.jsx("p",{role:"status",children:l.session.authenticated?`${i.authenticated}${l.session.account?`:${l.session.account}`:""}`:l.session.installed?i.notAuthenticated:i.notInstalled}),l.session.message&&c.jsx("p",{children:l.session.message}),c.jsxs("div",{className:"link-authorization-actions",children:[c.jsx("button",{type:"button",disabled:A,onClick:()=>N("detect-session"),children:i.detectSession}),!l.session.authenticated&&l.session.canLogin&&c.jsx("button",{type:"button",disabled:A,onClick:()=>N("login-session"),children:i.loginSession}),l.session.authenticated&&c.jsx("button",{type:"button",disabled:A,onClick:()=>N("bind-session"),children:i.bindSession})]}),M]});case"consent":{const D=f.permissions??l.permissions.filter(q=>q.required).map(q=>q.id),H=(q,C,L,B)=>u(Q=>({...Q,[q]:L?[...new Set([...B,C])]:B.filter(J=>J!==C)})),W=l.resourceGroups.some(q=>{const C=(f[q.id]??[]).length;return C<(q.minSelected??0)||C>(q.maxSelected??1/0)||q.truncated});return c.jsxs("form",{className:"link-authorization-step link-authorization-consent",onSubmit:q=>{q.preventDefault(),!A&&!W&&N("confirm",{...f,permissions:D})},children:[c.jsx("p",{children:c.jsx("strong",{children:l.account.label})}),c.jsx("div",{children:l.permissions.map(q=>c.jsxs("label",{children:[c.jsx("input",{type:"checkbox",checked:q.required||D.includes(q.id),disabled:A||q.required,onChange:C=>H("permissions",q.id,C.target.checked,D)}),q.label,q.description&&c.jsx("small",{children:q.description})]},q.id))}),l.resourceGroups.map(q=>c.jsxs("fieldset",{children:[c.jsx("legend",{children:q.label}),q.items.map(C=>c.jsxs("label",{children:[c.jsx("input",{type:"checkbox",checked:(f[q.id]??[]).includes(C.id),disabled:A,onChange:L=>H(q.id,C.id,L.target.checked,f[q.id]??[])}),C.label,C.description&&c.jsx("small",{children:C.description})]},C.id)),q.truncated&&c.jsx("p",{children:i.resourcesTruncated})]},q.id)),c.jsx("button",{type:"submit",disabled:A||W,children:i.confirm}),M]})}case"processing":return c.jsx("p",{className:"link-authorization-status",role:"status",children:i.processing});default:return c.jsx("p",{role:"alert",children:i.unsupported})}};return c.jsxs(c.Fragment,{children:[G,ae()]})}const Hn="/api/v1/links",ow={connected:"已连接",expired:"授权已过期",invalid:"需要重新连接",unavailable:"凭据不可用"};function sl(t){try{const i=new URL(t??"");return i.protocol==="https:"&&!i.username&&!i.password?i.href:void 0}catch{return}}function uw({onAuthLost:t,onDirtyChange:i,hostLabel:l="服务端",configurationVersion:a=0}){const[o,f]=w.useState(),[u,p]=w.useState(),[h,m]=w.useState(""),[y,b]=w.useState(""),[x,v]=w.useState(""),[j,z]=w.useState(!0),[A,N]=w.useState(!1),[T,M]=w.useState(),[G,ae]=w.useState(),[D,H]=w.useState(),[W,q]=w.useState(),C=w.useRef(new Map),L=w.useRef(new Set),[B,Q]=w.useState(),J=w.useMemo(()=>new f1({begin:async(_,Z)=>{const ge=no(),{workspace:we,projectId:Ne}=ge,De=await qe(xt(`${Hn}/authorizations`,we,Ne),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({..._,authModeId:Z})},ge);return C.current.set(De.id,{target:xt(`${Hn}/authorizations/${encodeURIComponent(De.id)}`,we,Ne),scope:ge}),De},status:_=>{const Z=C.current.get(_);return qe(Z.target,{},Z.scope)},respond:(_,Z)=>{const ge=C.current.get(_),we=new URL(ge.target,window.location.origin);return we.pathname+="/responses",qe(we.pathname+we.search,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z)},ge.scope)},cancel:async _=>{if(L.current.has(_))return;const Z=C.current.get(_);Z&&(await qe(Z.target,{method:"DELETE",keepalive:!0},Z.scope),C.current.delete(_))}}),[]),K=w.useSyncExternalStore(J.subscribe,J.getSnapshot),I=o?.capabilities.authorizationSteps===1&&!!u?.provider.authModes,Y=I&&K.authorization?.state==="pending",[X,pe]=w.useState(0),k=w.useRef(!1),O=w.useRef(0),te=w.useRef(null),R=w.useRef(void 0),ee=w.useRef(void 0),ve=w.useRef(void 0),le=w.useRef(void 0),ue=w.useRef({onAuthLost:t,onDirtyChange:i});ue.current={onAuthLost:t,onDirtyChange:i};const xe=A||K.busy||Y||D?.state==="pending"||!!(u&&(u.token||u.label!==(u.original?.label??u.provider.displayName))),F=w.useCallback(_=>{_ instanceof Ke&&_.status===401?ue.current.onAuthLost():b(_ instanceof Error?_.message:"连接操作失败,请重试。")},[]);w.useEffect(()=>{if(!u)return;const _=document.activeElement;return te.current?.querySelector("input:not(:disabled), button:not(:disabled)")?.focus(),()=>_?.focus?.()},[!!u]),w.useEffect(()=>{ue.current.onDirtyChange?.(xe)},[xe]),w.useEffect(()=>{k.current=!0;const _=++O.current;return()=>{k.current=!1,ue.current.onDirtyChange?.(!1),R.current?.abort(),queueMicrotask(()=>{O.current===_&&J.dispose()}),ee.current&&qe(ee.current,{method:"DELETE",keepalive:!0},ve.current).catch(()=>{})}},[J]),w.useEffect(()=>{const _=new AbortController;return le.current=_,z(!0),qe(Hn,{signal:_.signal}).then(Z=>{_.signal.aborted||f(Z)}).catch(Z=>{_.signal.aborted||F(Z)}).finally(()=>{_.signal.aborted||z(!1)}),()=>_.abort()},[X,a,F]),w.useEffect(()=>{I&&(K.error&&F(K.error),K.authorization?.state==="connected"&&K.authorization.connection&&(p(void 0),v("授权完成,连接已保存。"),pe(_=>_+1)))},[I,K.authorization,K.error,F]),w.useEffect(()=>{if(!o?.remoteCleanupPending)return;const _=setInterval(()=>pe(Z=>Z+1),3e4);return()=>clearInterval(_)},[o?.remoteCleanupPending]),w.useEffect(()=>{if(D?.state!=="pending"||!ee.current)return;const _=ee.current,Z=ve.current,ge=new AbortController;let we;const Ne=async()=>{try{const De=await qe(_,{signal:ge.signal},Z);if(ge.signal.aborted||ee.current!==_)return;H(De),De.state==="connected"?(ee.current=void 0,p(void 0),v("授权完成,连接已保存。"),pe(Ge=>Ge+1)):De.state!=="pending"?(ee.current=void 0,b(De.state==="cancelled"?"授权已取消。":"授权未完成或已过期,请重新开始。")):we=setTimeout(()=>{Ne()},2e3)}catch(De){if(ge.signal.aborted||ee.current!==_)return;F(De),De instanceof Ke&&[401,404].includes(De.status)?(ee.current=void 0,H(Ge=>Ge?{...Ge,state:"failed"}:void 0)):we=setTimeout(()=>{Ne()},4e3)}};return we=setTimeout(()=>{Ne()},1e3),()=>{ge.abort(),clearTimeout(we)}},[D?.id,D?.state,F]);async function ke(_,Z){if(R.current)return;const ge=new AbortController;R.current=ge,le.current?.abort(),N(!0),z(!1),b(""),v("");try{const we=await _(ge.signal);k.current&&!ge.signal.aborted&&Z(we)}catch(we){k.current&&!ge.signal.aborted&&(F(we),we instanceof Ke&&[409,503].includes(we.status)&&pe(Ne=>Ne+1))}finally{R.current===ge&&(R.current=void 0),k.current&&N(!1)}}function ze(_,Z,ge,we,Ne){return qe(_,{method:Z,headers:{"Content-Type":"application/json"},body:JSON.stringify(ge),signal:we},Ne)}function Le(){return{providerId:u.provider.id,methodId:u.methodId,label:u.label.trim(),expectedRevision:u.original?.revision??null,...u.original?{connectionId:u.original.id}:{}}}function Ee(){p(void 0),ae(void 0),v("连接已保存。"),pe(_=>_+1)}function Xe(_,Z){if(A||K.busy||Y||D?.state==="pending"||xe&&!window.confirm("放弃当前未保存的连接修改?"))return;J.reset();const ge=Z?Rc(_,Z.methodId):Rc(_),we=Z?_.connectionMethods.find(De=>De.id===Z.methodId):_.connectionMethods.find(De=>De.id===ge?.methodId)??_.connectionMethods.find(De=>De.executionRuntime==="local"&&De.availability==="available");if(!we){b("当前环境未提供此连接的授权方式,请检查服务器连接设置。");return}const Ne={provider:_,original:Z,methodId:we.id,label:Z?.label??_.displayName,token:""};p(Ne),ae(void 0),H(void 0),q(ge?.id),b(""),v(""),!Z&&o?.capabilities.authorizationSteps===1&&ge&&gt(Ne,ge)}async function gt(_,Z){if(!Z.available||!_.label.trim()||J.getSnapshot().authorization?.state==="pending"&&(await J.cancel(),J.getSnapshot().authorization?.state==="pending"))return;b(""),q(Z.id),p({..._,methodId:Z.methodId});const ge={workspace:io()??"",projectId:Sa()},we=await J.begin({providerId:_.provider.id,methodId:Z.methodId,label:_.label.trim(),expectedRevision:_.original?.revision??null,..._.original?{connectionId:_.original.id}:{}},Z.id);if(!(we?.state!=="pending"||xi(we)?.kind!=="redirect"))try{if(o?.capabilities.browserHandoff===1){const Ge=C.current.get(we.id),mt=new URL(Ge.target,window.location.origin);mt.pathname+="/browser";const ut=await qe(mt.pathname+mt.search,{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"},Ge.scope),dt=new URL(ut.launchUrl);if(dt.origin!==window.location.origin||dt.pathname!=="/link/authorize"||dt.username||dt.password||dt.hash||dt.searchParams.size!==1||!/^[A-Za-z0-9_-]{43}$/.test(dt.searchParams.get("ticket")??""))throw new Error("授权浏览器入口无效,请重新连接。");J.getSnapshot().authorization?.id===we.id&&J.getSnapshot().authorization?.state==="pending"&&Q({id:we.id,url:dt.href});return}const Ne=o?.remoteServer?.issuer;if(!Ne)throw new Error("当前 Host 尚未配置授权服务。");const De=p1(we,Ne,ge);L.current.add(we.id),bS.flushSync(()=>{p(void 0),ue.current.onDirtyChange?.(!1)}),window.location.assign(De)}catch(Ne){await J.cancel(),F(Ne)}}async function He(){if(Y){await J.cancel(),J.getSnapshot().authorization?.state==="cancelled"&&v("授权已取消。");return}if(!ee.current)return;const _=ee.current,Z=ve.current;await ke(ge=>qe(_,{method:"DELETE",signal:ge},Z),()=>{ee.current=void 0,H(void 0),v("授权已取消。")})}function Lt(){I?J.cancel().then(()=>{J.getSnapshot().authorization?.state!=="pending"&&p(void 0)}):!Ie&&(!xe||window.confirm("放弃未保存的连接修改?"))&&p(void 0)}function st(_,Z=no()){if(I&&J.getSnapshot().authorization?.state==="pending"&&u?.original?.id===_.id){J.cancel().then(()=>{J.getSnapshot().authorization?.state!=="pending"&&st(_,Z)});return}const ge=u?.original?.id===_.id&&D?.state==="pending"?ee.current:void 0,we=xt(`${Hn}/connections/${encodeURIComponent(_.id)}`,Z.workspace,Z.projectId),Ne=ve.current;ke(async De=>{if(ge){try{await qe(ge,{method:"DELETE",signal:De},Ne)}catch(Ge){if(!(Ge instanceof Ke&&Ge.status===404))throw Ge}k.current&&!De.aborted&&ee.current===ge&&(ee.current=void 0,H(void 0))}return ze(we,"DELETE",{expectedRevision:_.revision},De,Z)},()=>{u?.original?.id===_.id&&p(void 0),M(void 0),pe(De=>De+1),v("连接已断开。")})}const Ve=u?.provider.connectionMethods.find(_=>_.id===u.methodId),At=D?.state==="pending",Ie=A||K.busy||At||Y,yt=h.trim().toLowerCase(),ot=(o?.providers??[]).filter(_=>(o?.capabilities.authorizationSteps!==1||_.authModes?.some(Z=>Z.available))&&`${_.displayName} ${_.description.zh}`.toLowerCase().includes(yt)),Ze=u&&o?.connections.find(_=>u.original?_.id===u.original.id:_.id===`link-${u.provider.id}-${u.methodId}`&&_.providerId===u.provider.id&&_.methodId===u.methodId),pt=u&&o&&(u.original?Ze?.revision!==u.original.revision:!!Ze);return c.jsxs("section",{className:"hub-links",children:[c.jsxs("header",{className:"links-heading",children:[c.jsxs("div",{children:[c.jsx("h1",{children:"Link"}),c.jsx("p",{children:"连接你的工具与账号,让任务访问已授权的服务。"})]}),c.jsx("button",{onClick:()=>{b(""),pe(_=>_+1)},disabled:A||j,children:"刷新"})]}),!!o?.remoteCleanupPending&&c.jsxs("p",{role:"status",className:"links-muted",children:["有 ",o.remoteCleanupPending," 项遗留授权等待撤销。项目所在环境 会自动重试,重启后仍会继续;也可在 Link 服务中撤销。"]}),c.jsxs("p",{className:"links-host",children:["连接由当前项目所属的",l,"管理,授权后只访问你允许的服务与资源。"]}),y&&c.jsx("p",{className:"form-error",role:"alert",children:y}),x&&c.jsx("p",{className:"links-notice",role:"status",children:x}),j&&!o&&c.jsx("p",{role:"status",children:"正在加载连接…"}),c.jsx("h2",{children:"已连接"}),o&&o.connections.length===0&&c.jsx("p",{className:"links-muted",children:"还没有连接。选择下面的服务开始。"}),c.jsx("div",{className:"links-connections",children:o?.connections.map(_=>{const Z=o.providers.find(ge=>ge.id===_.providerId);return c.jsxs("article",{className:"links-connection",children:[c.jsxs("div",{children:[c.jsx("strong",{children:_.label}),c.jsxs("p",{children:[Z?.displayName??_.providerId," ·"," ",_.account?.label??_.account?.id??"已授权账号"]}),c.jsx("span",{className:`links-state ${_.status==="connected"?"ready":""}`,children:ow[_.status]}),c.jsxs("small",{children:[_.authSource==="remote-link"?"独立 Link 授权":_.authSource==="cli-session"?"CLI 登录":_.authSource==="browser-oauth"?"浏览器授权":"Token",_.expiresAt?` · 到期 ${new Date(_.expiresAt).toLocaleString()}`:""]}),_.account?.resources.length?c.jsx("p",{children:_.account.resources.join("、")}):null]}),c.jsx("div",{className:"links-actions",children:_.editable?c.jsxs(c.Fragment,{children:[c.jsx("button",{disabled:Ie||!Z,onClick:()=>Z&&Xe(Z,_),children:"管理连接"}),c.jsx("button",{disabled:A,onClick:()=>M(_),children:"断开"})]}):c.jsx("small",{children:"项目配置管理"})})]},_.id)})}),T&&c.jsxs("div",{className:"links-confirm",role:"alertdialog","aria-label":"断开连接",children:[c.jsxs("p",{children:["断开「",T.label,"」后,后续任务将无法使用这个连接,正在执行的请求会尝试停止。"]}),c.jsx("button",{disabled:A,onClick:()=>st(T),children:"确认断开"}),c.jsx("button",{disabled:A,onClick:()=>M(void 0),children:"取消"})]}),u&&Ve&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"links-editor-backdrop","aria-hidden":"true"}),c.jsxs("section",{className:"links-editor",ref:te,onKeyDown:_=>{if(_.key==="Escape"&&(_.preventDefault(),Lt()),_.key!=="Tab")return;const Z=te.current?.querySelectorAll("button:not(:disabled), input:not(:disabled), a[href], summary");if(!Z?.length)return;const ge=Z[0],we=Z[Z.length-1];_.shiftKey&&document.activeElement===ge?(_.preventDefault(),we.focus()):!_.shiftKey&&document.activeElement===we&&(_.preventDefault(),ge.focus())},role:"dialog","aria-modal":"true","aria-label":`${u.provider.displayName} 连接设置`,children:[c.jsxs("div",{className:"links-heading",children:[c.jsxs("h2",{children:[u.provider.displayName," · ",u.original?"管理连接":"添加连接"]}),c.jsx("button",{disabled:!I&&Ie,onClick:Lt,children:"关闭"})]}),c.jsxs("label",{children:["连接名称",c.jsx("input",{maxLength:100,value:u.label,disabled:Ie,onChange:_=>p({...u,label:_.target.value})})]}),pt&&c.jsxs("div",{className:"links-conflict",role:"alert",children:[c.jsx("p",{children:"这个连接已在其他设备创建、修改或删除。你的输入仍然保留,请先载入最新版本。"}),c.jsx("button",{disabled:Ie,onClick:()=>p({...u,original:Ze||void 0}),children:"载入最新版本,保留输入"})]}),I?c.jsxs("div",{className:"links-authorization",children:[c.jsx("p",{className:"links-muted",children:Ve.executionRuntime==="server"?"由 Link 服务保存授权并访问已选择的资源。":`连接保存到当前项目所属的${l}。`}),K.authorization?c.jsx(sw,{authorization:K.authorization,busy:K.busy||!!pt||o?.capabilities.browserHandoff===1&&xi(K.authorization)?.kind==="redirect"&&B?.id!==K.authorization.id,onRespond:_=>{J.respond(_)},onOpenUrl:_=>{const ge=o?.capabilities.browserHandoff===1&&xi(K.authorization)?.kind==="redirect"?B&&B.id===K.authorization?.id?B.url:void 0:_;ge&&window.open(ge,"_blank","noopener,noreferrer")},onCopy:_=>{navigator.clipboard?.writeText(_).catch(F)}}):c.jsx("button",{disabled:K.busy||!!pt||!u.label.trim(),onClick:()=>{const _=u.provider.authModes?.find(Z=>Z.id===W&&Z.available)??Rc(u.provider,u.methodId);_&&gt(u,_)},children:K.busy?"正在连接…":u.original?"重新连接":"开始连接"}),c.jsxs("div",{className:"links-actions",children:[Y&&c.jsx("button",{disabled:K.busy,onClick:()=>{He()},children:"取消授权"}),K.authorization&&K.authorization.state!=="pending"&&c.jsx("button",{disabled:K.busy||!!pt||!u.label.trim(),onClick:()=>{const _=u.provider.authModes?.find(Z=>Z.id===W&&Z.available);_&&gt(u,_)},children:"重新连接"})]}),c.jsxs("details",{className:"links-other-methods",children:[c.jsx("summary",{children:"其他连接方式"}),c.jsx("div",{className:"links-methods",children:u.provider.authModes?.map(_=>c.jsxs("button",{disabled:K.busy||!_.available||!!pt||!u.label.trim(),title:_.unavailableReason,onClick:()=>{gt(u,_)},children:[_.label,_.id===W?" · 当前":""]},_.id))})]}),u.original&&c.jsx("button",{disabled:Ie||!!pt||!u.label.trim(),onClick:()=>{ke(_=>ze(`${Hn}/connections/${encodeURIComponent(u.original.id)}`,"PATCH",{label:u.label.trim(),expectedRevision:u.original.revision},_),Ee)},children:"保存名称"})]}):c.jsxs(c.Fragment,{children:[Ve.browserAuth&&c.jsxs("div",{className:"links-auth-option",children:[c.jsx("h3",{children:"浏览器授权"}),u.provider.deviceAuth?.configured?c.jsx("button",{disabled:Ie||!u.label.trim()||!!pt,onClick:()=>{const _=io()??"",Z=Sa(),ge={workspace:_,projectId:Z},we=xt(`${Hn}/authorizations/device`,_,Z);ke(Ne=>ze(we,"POST",Le(),Ne,ge),Ne=>{ee.current=xt(`${Hn}/authorizations/${encodeURIComponent(Ne.id)}`,_,Z),ve.current=ge,H(Ne)})},children:"开始授权"}):c.jsxs("p",{className:"links-muted",children:["这台",l,"尚未配置此服务的浏览器授权,可使用下面的连接方式。"]}),At&&D.prompt&&c.jsxs("div",{className:"links-device-code",role:"status",children:[c.jsx("p",{children:"在服务商页面输入验证码:"}),c.jsx("strong",{children:D.prompt.userCode}),c.jsx("p",{children:sl(D.prompt.verificationUriComplete??D.prompt.verificationUri)&&c.jsx("a",{href:sl(D.prompt.verificationUriComplete??D.prompt.verificationUri),target:"_blank",rel:"noreferrer",children:"打开授权页面 ↗"})}),c.jsxs("p",{children:["完成后会自动保存。有效期至"," ",new Date(D.prompt.expiresAt).toLocaleTimeString(),"。"]}),c.jsx("button",{disabled:A,onClick:()=>{He()},children:"取消授权"})]})]}),Ve.quickAuth&&c.jsxs("div",{className:"links-auth-option",children:[c.jsx("h3",{children:"使用已登录的 CLI"}),c.jsxs("p",{children:[l,"需要已安装并登录 ",Ve.quickAuth.command,"。"]}),c.jsx("button",{disabled:Ie,onClick:()=>{ke(_=>qe(`${Hn}/providers/${encodeURIComponent(u.provider.id)}/cli`,{signal:_}),ae)},children:"检查登录状态"}),G&&c.jsx("p",{role:"status",children:G.authenticated?`已登录${G.account?`:${G.account}`:""}`:G.installed?"已安装,尚未登录。请在运行服务的机器上登录。":"尚未安装。"}),G?.authenticated&&c.jsx("button",{disabled:Ie||!u.label.trim()||!!pt,onClick:()=>{ke(_=>ze(`${Hn}/connections/cli`,"POST",Le(),_),Ee)},children:"绑定这个登录"})]}),Ve.authKind==="token"&&c.jsxs("form",{className:"links-auth-option",onSubmit:_=>{_.preventDefault(),!(Ie||pt)&&ke(Z=>u.original&&!u.token.trim()?ze(`${Hn}/connections/${encodeURIComponent(u.original.id)}`,"PATCH",{label:u.label.trim(),expectedRevision:u.original.revision},Z):ze(`${Hn}/connections/token`,"POST",{...Le(),token:u.token.trim()},Z),Ee)},children:[c.jsx("h3",{children:u.original?"名称与 Token":"使用 Token"}),Ve.authGuide&&c.jsxs(c.Fragment,{children:[c.jsx("p",{children:Ve.authGuide.summary.zh}),c.jsxs("div",{className:"links-actions",children:[sl(Ve.authGuide.createCredentialUrl)&&c.jsx("a",{href:sl(Ve.authGuide.createCredentialUrl),target:"_blank",rel:"noreferrer",children:"创建凭据 ↗"}),sl(Ve.authGuide.docsUrl)&&c.jsx("a",{href:sl(Ve.authGuide.docsUrl),target:"_blank",rel:"noreferrer",children:"授权说明 ↗"})]}),c.jsxs("details",{children:[c.jsx("summary",{children:"所需权限与设置步骤"}),c.jsx("ul",{children:Ve.authGuide.permissions.map(_=>c.jsxs("li",{children:[_.label,"(",_.level==="required"?"必需":"可选",")",_.description?`:${_.description.zh}`:""]},_.id))}),c.jsx("ol",{children:Ve.authGuide.steps.map((_,Z)=>c.jsx("li",{children:_.zh},Z))})]})]}),c.jsxs("label",{children:[Ve.tokenLabel??u.provider.tokenLabel,c.jsx("input",{type:"password",autoComplete:"off",value:u.token,disabled:Ie,placeholder:u.original?"留空保留当前授权,仅修改名称":Ve.tokenPlaceholder??u.provider.tokenPlaceholder,onChange:_=>p({...u,token:_.target.value}),required:!u.original,maxLength:16384})]}),c.jsx("button",{type:"submit",className:"send",disabled:Ie||!!pt||!u.label.trim(),children:A?"正在验证并保存…":u.token.trim()||!u.original?"验证并保存":"保存名称"})]})]}),c.jsxs("details",{children:[c.jsxs("summary",{children:[I?"服务支持的操作":"可用操作","(",u.provider.actions.length,")"]}),I&&c.jsx("p",{className:"links-muted",children:"此连接实际可用的操作以授权时确认的权限为准。"}),c.jsx("ul",{children:u.provider.actions.map(_=>c.jsxs("li",{children:[c.jsx("strong",{children:_.title}),_.risk==="write"?" · 执行前需要确认":"",c.jsx("p",{children:_.description})]},_.id))})]})]})]}),c.jsxs("div",{className:"links-heading",children:[c.jsx("h2",{children:"添加服务"}),c.jsx("input",{type:"search","aria-label":"搜索 Link 服务",placeholder:"搜索服务",value:h,onChange:_=>m(_.target.value)})]}),c.jsx("div",{className:"links-providers",children:ot.map(_=>{const Z=o?.connections.find(ge=>ge.providerId===_.id);return c.jsxs("article",{className:"links-provider",children:[c.jsx("div",{className:`links-brand accent-${_.accent}`,"aria-hidden":"true",children:_.brandText}),c.jsx("h3",{children:_.displayName}),c.jsx("p",{children:_.description.zh}),c.jsxs("small",{children:[_.actions.length," 项操作"]}),c.jsx("button",{disabled:Ie||o?.capabilities.authorizationSteps!==1&&!!(Z&&!Z.editable),onClick:()=>Xe(_,o?.capabilities.authorizationSteps===1?void 0:Z),children:o?.capabilities.authorizationSteps===1?"添加连接":Z?Z.editable?"管理连接":"项目配置管理":"添加连接"})]},_.id)})}),o&&ot.length===0&&c.jsx("p",{className:"links-muted",children:"没有匹配的服务。"})]})}const ff="/api/v1/panels",py="https://github.com/cjhyy/codeshell-panel-apps.git",my={"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 Vn(t){return t["zh-CN"]||t.default}function Xs({value:t}){return t.supported&&t.reasons.length===0?null:c.jsxs("div",{className:"panels-warning",children:[c.jsx("strong",{children:t.supported?"部分功能可用":"当前 Web 工作台暂不支持此面板"}),t.supported&&c.jsx("p",{children:"可以打开面板,以下功能当前不可用或需要额外配置。"}),t.reasons.length>0&&c.jsx("ul",{children:t.reasons.map(i=>c.jsx("li",{children:i},i))})]})}function cw({onAuthLost:t,onDirtyChange:i,onChanged:l,onOpen:a,hostLabel:o="服务端",configurationVersion:f=0}){const[u,p]=w.useState(),[h,m]=w.useState(""),[y,b]=w.useState(""),[x,v]=w.useState(""),[j,z]=w.useState(""),[A,N]=w.useState(),[T,M]=w.useState(),[G,ae]=w.useState(),[D,H]=w.useState(),[W,q]=w.useState(!1),[C,L]=w.useState(),[B,Q]=w.useState(),[J,K]=w.useState(!1),[I,Y]=w.useState(!0),[X,pe]=w.useState(!1),[k,O]=w.useState(),[te,R]=w.useState(!0),[ee,ve]=w.useState(""),[le,ue]=w.useState(""),[xe,F]=w.useState(""),[ke,ze]=w.useState(0),Le=w.useRef(!1),Ee=w.useRef(void 0),Xe=w.useRef(void 0),gt=w.useRef(!1),He=w.useRef(void 0),Lt=w.useRef(null),st=w.useRef({onAuthLost:t,onDirtyChange:i,onChanged:l,onOpen:a});st.current={onAuthLost:t,onDirtyChange:i,onChanged:l,onOpen:a};function Ve(U){fetch(U.target,{method:"DELETE",credentials:"same-origin",cache:"no-store",headers:{"Content-Type":"application/json"},body:JSON.stringify({reviewToken:U.token}),keepalive:!0,signal:AbortSignal.timeout(5e3)}).catch(()=>{})}const At=!!(ee||T||G||B||k||h.trim()||y.trim()||x.trim()),Ie=w.useCallback(U=>{U instanceof Ke&&U.status===401?st.current.onAuthLost():ue(U instanceof Error?U.message:"面板操作失败,请重试。")},[]);w.useEffect(()=>(Le.current=!0,()=>{Le.current=!1,Ee.current?.abort(),Xe.current?.abort(),He.current&&(Ve(He.current),He.current=void 0),st.current.onDirtyChange?.(!1)}),[]),w.useEffect(()=>{st.current.onDirtyChange?.(At)},[At]),w.useEffect(()=>{if(Ee.current){gt.current=!0;return}const U=new AbortController;return Xe.current=U,R(!0),qe(xt(ff),{signal:U.signal}).then(fe=>{U.signal.aborted||p(fe)}).catch(fe=>{U.signal.aborted||Ie(fe)}).finally(()=>{U.signal.aborted||R(!1)}),()=>U.abort()},[ke,f,Ie]),w.useEffect(()=>{T&&Lt.current?.focus()},[T?.reviewToken]);async function yt(U,fe,je,Pe,lt=!1,Tt){if(Ee.current||!Le.current)return;const kt=new AbortController;Ee.current=kt,Xe.current?.abort(),R(!1),ve(U),ue(""),F("");const Wn=xt(`${ff}${fe}`);try{const Vt=await qe(Wn,{method:je,headers:{"Content-Type":"application/json"},body:JSON.stringify(Pe),signal:kt.signal});if(kt.signal.aborted||!Le.current){Tt?.(Vt);return}return lt&&(gt.current=!0,st.current.onChanged?.()),Vt}catch(Vt){if(kt.signal.aborted||!Le.current)return;Vt instanceof Ke&&(Vt.status===409||Vt.status===410)&&(T&&K(!0),D&&q(!0),gt.current=!0),Ie(Vt);return}finally{Ee.current===kt&&(Ee.current=void 0),Le.current&&!kt.signal.aborted&&(ve(""),gt.current&&(gt.current=!1,ze(Vt=>Vt+1)))}}const ot=async U=>{if(!await Ge())return;ae(void 0),H(void 0),Q(void 0),M(void 0),O(void 0),N(void 0);const fe=await yt("正在读取仓库…","/github/discover","POST",{url:U.url,...U.ref?{ref:U.ref}:{},...U.subdir?{subdir:U.subdir}:{}});fe&&N(fe)},Ze=async U=>{if(!await Ge())return;ae(void 0),H(void 0);const fe=await yt("正在准备安装审阅…","/preview","POST",{source:U});fe&&(O(void 0),L(U),M(fe),K(!1),pe(!1),Y(!!u?.hasProject&&fe.compatibility.supported))},pt=async U=>{if(!await Ge())return;ae(void 0),H(void 0);const fe=await yt("正在检查更新…",`/${encodeURIComponent(U.id)}/update-preview`,"POST",{expectedRevision:U.revision});fe&&(O(void 0),L(void 0),M(fe),K(!1),pe(U.bound),Y(U.bound&&fe.compatibility.supported))},_=()=>{if(T)if(T.kind==="update"){const U=u?.panels.find(fe=>fe.id===T.preview.id);U?pt(U):(ue("此面板已被卸载,请重新从 GitHub 选择安装。"),M(void 0))}else C&&Ze(C)},Z=()=>{Q(void 0),N(void 0),m(""),b(""),v("")},ge=async()=>{if(M(void 0),!B||B.position+1>=B.candidates.length){Z();return}const U=B.position+1;Q({...B,position:U}),await Ze(B.candidates[U].source)},we=async U=>{U.length&&(Q({candidates:U,position:0}),await Ze(U[0].source))},Ne=async()=>{if(!T||J)return;if(T.expiresAt<=Date.now()){K(!0),ue("安装审阅已过期,请重新审阅后继续。");return}await yt(T.kind==="update"?"正在更新面板…":"正在安装面板…","/install","POST",{reviewToken:T.reviewToken,bind:I},!0)&&(F(`${Vn(T.preview.title)} 已${T.kind==="update"?"更新":"安装"}${I?"并绑定当前工作区":""}。`),M(void 0),B?await ge():Z())},De=async U=>{const fe=await yt(U.bound?"正在解除绑定…":"正在绑定工作区…",`/${encodeURIComponent(U.id)}/binding`,"PATCH",{bound:!U.bound,expectedRevision:U.revision},!0);fe&&(p(fe),F(`${Vn(U.title)} 已${U.bound?"解除当前工作区绑定":"绑定当前工作区"}。`))},Ge=async()=>D?(await yt("正在关闭版本审阅…","/restore/review","DELETE",{reviewToken:D.reviewToken}))?.cancelled?(He.current=void 0,H(void 0),!0):!1:!0,mt=async()=>{await Ge()&&ae(void 0)},ut=async U=>{if(!await Ge())return;M(void 0),O(void 0),H(void 0),ae(void 0);const fe=await yt("正在检查保留版本…",`/${encodeURIComponent(U.id)}/versions`,"POST",{expectedRevision:U.revision});fe&&(ae(fe),q(!1))},dt=async U=>{if(!G||!await Ge())return;const fe=xt(`${ff}/restore/review`),je=await yt("正在审阅项目版本…",`/${encodeURIComponent(G.appId)}/restore-preview`,"POST",{packageDigest:U,expectedRevision:G.expectedRevision},!1,Pe=>Ve({target:fe,token:Pe.reviewToken}));if(je){if(!Le.current){Ve({target:fe,token:je.reviewToken});return}He.current={target:fe,token:je.reviewToken},H(je),q(!1)}},tt=async()=>{if(!D||Ce)return;if(D.expiresAt<=Date.now()){q(!0),ue("版本审阅已过期,请重新选择版本。");return}await yt("正在恢复项目版本…","/restore","POST",{reviewToken:D.reviewToken},!0)&&(He.current=void 0,F(`${Vn(D.title)} 的项目版本已恢复为 v${D.version}。`),ae(void 0),H(void 0))},Ot=async()=>{if(!k||u?.panels.find(fe=>fe.id===k.id)?.revision!==k.revision)return;(await yt("正在卸载面板…",`/${encodeURIComponent(k.id)}`,"DELETE",{expectedRevision:k.revision},!0))?.removed&&(F(`${Vn(k.title)} 已卸载。`),O(void 0))},oe=!!ee||!u||!!B,Se=j.trim().toLowerCase(),Ae=(u?.panels??[]).filter(U=>[Vn(U.title),U.id,U.description??"",U.source.label].join(" ").toLowerCase().includes(Se)),Re=A?.panels.filter(U=>!u?.panels.some(fe=>fe.id===U.id)&&!u?.issues?.some(fe=>fe.id===U.id)&&A.panels.filter(fe=>fe.id===U.id).length===1)??[],ne=k&&u?.panels.find(U=>U.id===k.id),ye=!!k&&ne?.revision!==k.revision,Oe=T?.kind==="update"?u?.panels.find(U=>U.id===T.preview.id):void 0,Ce=W||!!G&&(u?.panels.find(U=>U.id===G.appId)?.revision??u?.issues?.find(U=>U.id===G.appId)?.revision)!==G.expectedRevision;return c.jsxs("section",{className:"hub-panels",children:[c.jsxs("header",{className:"panels-heading",children:[c.jsxs("div",{children:[c.jsx("h1",{children:"面板"}),c.jsx("p",{children:"从 GitHub 安装工具面板,绑定工作区后直接在工作台中打开。"})]}),c.jsx("button",{disabled:!!ee||te,onClick:()=>ze(U=>U+1),children:te?"正在刷新…":"刷新"})]}),c.jsxs("p",{className:"panels-muted",children:["面板安装在",o,"上,文件和任务操作使用当前工作区。"]}),u&&!u.hasProject&&c.jsx("div",{className:"panels-warning",children:"请先选择一个项目,才能绑定和打开面板。"}),le&&c.jsx("p",{role:"alert",className:"error",children:le}),xe&&c.jsx("p",{role:"status",className:"panels-notice",children:xe}),ee&&c.jsx("p",{role:"status",className:"panels-muted",children:ee}),u?.issues?.filter(U=>U.id.toLowerCase().includes(Se)).map(U=>c.jsxs("section",{className:"panels-warning","aria-label":"需要修复的面板",children:[c.jsx("h2",{children:U.id}),c.jsxs("p",{children:["项目记录版本:",U.version??"未记录","。安装包缺失或无法校验,面板暂不可用。"]}),c.jsx("p",{children:"项目数据和任务记录仍保留。可检查宿主保留的版本,审阅权限后恢复。"}),c.jsx("button",{disabled:!!ee||!U.bound||!u.canRestorePackages,onClick:()=>{ut(U)},children:"检查可用版本"})]},U.id)),G&&c.jsxs("section",{className:"panels-review","aria-label":"项目保留版本",children:[c.jsxs("header",{className:"panels-heading",children:[c.jsxs("div",{children:[c.jsxs("h2",{children:[Vn(G.title)," · 项目版本"]}),c.jsxs("p",{children:["项目记录版本:",G.current.version]})]}),c.jsx("button",{disabled:!!ee,onClick:()=>{mt()},children:"关闭版本记录"})]}),c.jsx("p",{children:"选择宿主已保留的程序版本,仅切换当前项目。其他项目继续使用各自版本。"}),c.jsx("p",{className:"panels-warning",children:"切换程序版本不会恢复旧数据。请先备份项目,确认该版本支持当前文档格式;任务与产物记录会保留。"}),G.current.unavailable&&c.jsx("p",{role:"status",children:"当前安装包不可用,无法读取原权限;恢复前需重新审阅目标版本的全部权限。"}),G.unavailablePackages>0&&c.jsxs("p",{role:"status",children:["有 ",G.unavailablePackages," 个保留包无法校验,暂不能选择。"]}),!G.versions.length&&c.jsx("p",{children:"没有可用的保留版本。"}),c.jsx("div",{className:"panels-grid",children:G.versions.map(U=>c.jsxs("article",{className:"panels-card",children:[c.jsxs("h3",{children:["v",U.version]}),c.jsxs("small",{children:["内容编号 ",U.packageDigest.slice(0,12)]}),c.jsx(Xs,{value:U.compatibility}),c.jsx("button",{disabled:!!ee||!U.compatibility.supported||U.packageDigest===G.current.packageDigest,onClick:()=>{dt(U.packageDigest)},children:U.packageDigest===G.current.packageDigest?"当前项目版本":`审阅 v${U.version}`})]},U.packageDigest))}),D&&c.jsxs("section",{className:"panels-confirm","aria-label":"确认恢复项目版本",children:[c.jsxs("h3",{children:["v",D.current.version," → v",D.version]}),c.jsx("h4",{children:"此版本请求的权限"}),!D.permissions.length&&c.jsx("p",{children:"未申请宿主权限。"}),D.permissions.map(U=>c.jsxs("div",{className:"panels-permission",children:[c.jsx("span",{children:my[U]??U}),D.addedPermissions.includes(U)&&c.jsx("strong",{children:D.current.unavailable?"需重新确认":"新增权限"})]},U)),c.jsx(Xs,{value:D.compatibility}),Ce&&c.jsx("p",{role:"alert",children:"项目或审阅已变化,请关闭版本记录并重新读取。"}),c.jsx("button",{disabled:!!ee||Ce||!D.compatibility.supported,onClick:()=>{tt()},children:"确认权限并恢复项目版本"})]})]}),B&&c.jsxs("section",{className:"panels-confirm","aria-label":"逐个审阅面板",children:[c.jsxs("p",{children:["正在审阅第 ",B.position+1," / ",B.candidates.length," 个面板:",Vn(B.candidates[B.position].title),"。每个面板都需要单独确认安装。"]}),c.jsxs("div",{className:"panels-actions",children:[!T&&c.jsx("button",{disabled:!!ee,onClick:()=>{Ze(B.candidates[B.position].source)},children:"重新读取此面板"}),c.jsx("button",{disabled:!!ee,onClick:()=>{ge()},children:"跳过此面板"}),c.jsx("button",{disabled:!!ee,onClick:()=>{Q(void 0),M(void 0),ue("")},children:"取消逐个审阅"})]})]}),T&&c.jsxs("section",{className:"panels-review","aria-labelledby":"panel-review-heading",children:[c.jsxs("header",{className:"panels-heading",children:[c.jsxs("div",{children:[c.jsx("h2",{id:"panel-review-heading",ref:Lt,tabIndex:-1,children:T.kind==="update"?"审阅面板更新":"审阅面板安装"}),c.jsxs("p",{children:[Vn(T.preview.title)," · ",T.preview.id," · v",T.preview.version]})]}),c.jsx("button",{disabled:!!ee,onClick:()=>{Q(void 0),M(void 0),ue("")},children:"取消审阅"})]}),T.preview.description&&c.jsx("p",{children:T.preview.description}),Oe&&c.jsxs("p",{className:"panels-warning",children:["当前版本 v",Oe.version," → 更新后 v",T.preview.version,Oe.source.commit&&c.jsxs(c.Fragment,{children:[c.jsx("br",{}),"当前提交 ",c.jsx("code",{children:Oe.source.commit.slice(0,12)})," → 更新提交"," ",c.jsx("code",{children:T.source.commit.slice(0,12)})]})]}),c.jsxs("section",{children:[c.jsx("h3",{children:"安装来源"}),c.jsxs("dl",{children:[c.jsx("dt",{children:"仓库"}),c.jsx("dd",{children:T.source.url}),c.jsx("dt",{children:"分支 / 标签"}),c.jsx("dd",{children:T.source.ref}),c.jsx("dt",{children:"已锁定提交"}),c.jsx("dd",{children:c.jsx("code",{children:T.source.commit})}),c.jsx("dt",{children:"面板目录"}),c.jsx("dd",{children:T.source.subdir||"仓库根目录"}),c.jsx("dt",{children:"界面入口"}),c.jsx("dd",{children:c.jsx("code",{children:T.preview.entry})})]})]}),c.jsxs("section",{children:[c.jsx("h3",{children:"面板请求的权限"}),T.preview.permissions.length===0?c.jsx("p",{className:"panels-muted",children:"未申请宿主权限。"}):T.preview.permissions.map(U=>c.jsxs("div",{className:"panels-permission",children:[c.jsx("span",{children:my[U]??U}),c.jsx("small",{children:U})]},U))]}),c.jsxs("section",{children:[c.jsx("h3",{children:"随面板安装的工具与 Skills"}),T.preview.agent?.tools.length||T.preview.agent?.skills.length?c.jsxs("div",{className:"panels-badges",children:[T.preview.agent?.tools.map(U=>c.jsxs("span",{className:"panels-badge",title:U.description,children:[U.name," · ",U.readOnly?"只读":"可修改数据"]},U.name)),T.preview.agent?.skills.map(U=>c.jsxs("span",{className:"panels-badge",children:["Skill · ",U.split("/").at(-2)??U]},U))]}):c.jsx("p",{className:"panels-muted",children:"此面板没有额外的 Agent 工具或 Skills。"})]}),c.jsx(Xs,{value:T.compatibility}),T.preview.warnings.length>0&&c.jsx("div",{className:"panels-warning",children:c.jsx("ul",{children:T.preview.warnings.map(U=>c.jsx("li",{children:U},U))})}),c.jsxs("footer",{children:[!T.compatibility.supported&&c.jsxs("p",{className:"panels-muted",children:["可以安装到",o,",但当前 Web 工作台无法绑定或打开它。"]}),X?c.jsx("p",{className:"panels-muted",children:"已绑定当前工作区,更新将保留绑定。"}):c.jsxs("label",{className:"panels-check",children:[c.jsx("input",{type:"checkbox",checked:I,disabled:!!ee||!u?.hasProject||!T.compatibility.supported,onChange:U=>Y(U.target.checked)}),"绑定当前工作区"]}),J?c.jsxs("div",{className:"panels-actions",children:[c.jsx("span",{className:"panels-muted",children:"安装内容或本地版本已变化,请重新审阅。"}),c.jsx("button",{disabled:!!ee,onClick:_,children:"重新审阅"})]}):c.jsx("button",{className:"panels-primary",disabled:!!ee,onClick:()=>{Ne()},children:T.kind==="update"?"确认更新":"确认安装"})]})]}),c.jsxs("section",{className:"panels-section","aria-labelledby":"installed-panels-heading",children:[c.jsxs("div",{className:"panels-heading",children:[c.jsxs("h2",{id:"installed-panels-heading",children:["已安装面板",u?` · ${u.panels.length+(u.issues?.length??0)}`:""]}),c.jsx("input",{type:"search","aria-label":"搜索已安装面板",placeholder:"搜索已安装面板",value:j,onChange:U=>z(U.target.value)})]}),!u&&c.jsx("p",{className:"panels-muted",children:te?"正在读取面板…":"暂时无法读取面板,请刷新重试。"}),u&&Ae.length===0&&!u.issues?.some(U=>U.id.toLowerCase().includes(Se))&&c.jsxs("div",{className:"panels-empty",children:[c.jsx("strong",{children:u.panels.length||u.issues?.length?"没有匹配的面板":"还没有安装面板"}),c.jsx("p",{className:"panels-muted",children:u.panels.length||u.issues?.length?"试试其他名称或清除搜索。":"在下方粘贴 GitHub 仓库地址,或浏览官方面板仓库。"})]}),c.jsx("div",{className:"panels-grid",children:Ae.map(U=>c.jsxs("article",{className:"panels-card",children:[c.jsxs("div",{className:"panels-card-heading",children:[c.jsx("h3",{children:Vn(U.title)}),c.jsxs("span",{className:"panels-badge",children:["v",U.version]})]}),c.jsx("small",{children:U.id}),U.description&&c.jsx("p",{children:U.description}),c.jsx("div",{className:"panels-badges",children:c.jsx("span",{className:`panels-badge ${U.enabled&&U.compatibility.supported?"panels-badge-ready":""}`,children:U.globalDisabled?"已全局停用":U.bound?"已绑定当前工作区":"未绑定当前工作区"})}),c.jsxs("dl",{children:[c.jsx("dt",{children:"来源"}),c.jsx("dd",{children:U.source.label}),U.source.ref&&c.jsxs(c.Fragment,{children:[c.jsx("dt",{children:"分支 / 标签"}),c.jsx("dd",{children:U.source.ref})]})]}),c.jsx(Xs,{value:U.compatibility}),U.globalDisabled&&c.jsx("p",{className:"panels-muted",children:"请在宿主配置中启用此面板后使用。"}),c.jsxs("div",{className:"panels-actions",children:[c.jsx("button",{className:"panels-primary",disabled:oe||!U.enabled||!U.compatibility.supported,onClick:()=>st.current.onOpen(U),children:"打开面板"}),c.jsx("button",{disabled:oe||!u?.hasProject||!U.bound&&(U.globalDisabled||!U.compatibility.supported),onClick:()=>{De(U)},children:U.bound?"解除绑定":"绑定工作区"}),U.updatable&&c.jsx("button",{disabled:oe,onClick:()=>{pt(U)},children:"检查更新"}),u?.canRestorePackages&&U.bound&&c.jsx("button",{disabled:oe,onClick:()=>{ut(U)},children:"项目版本"}),c.jsx("button",{className:"panels-danger",disabled:oe,onClick:async()=>{!await Ge()||!Le.current||(O(U),M(void 0),ae(void 0),H(void 0),ue(""),F(""))},children:"卸载"})]})]},U.id))}),k&&c.jsxs("section",{className:"panels-confirm","aria-label":"确认卸载面板",children:[c.jsxs("p",{children:["卸载「",Vn(k.title),"」v",k.version,"?面板将从",o,"移除,其他工作区也将无法打开它。"]}),c.jsxs("div",{className:"panels-actions",children:[c.jsx("button",{disabled:!!ee,onClick:()=>O(void 0),children:"取消卸载"}),ye&&c.jsx("span",{className:"panels-muted",children:ne?"面板已被其他设备修改,请查看最新版本后重新确认。":"此面板已被其他设备卸载。"}),ye&&ne&&c.jsx("button",{disabled:!!ee||te,onClick:()=>{O(ne),ue("")},children:"查看最新版本"}),c.jsx("button",{className:"panels-danger",disabled:!!ee||te||ye,onClick:()=>{Ot()},children:"确认卸载"})]})]})]}),c.jsxs("section",{className:"panels-import panels-section","aria-labelledby":"github-panels-heading",children:[c.jsxs("div",{className:"panels-heading",children:[c.jsxs("div",{children:[c.jsx("h2",{id:"github-panels-heading",children:"从 GitHub 安装"}),c.jsx("p",{children:"先读取仓库并选择面板,再查看安装内容和所需权限。"})]}),c.jsx("button",{disabled:oe,onClick:()=>{m(py),b(""),v(""),ot({url:py})},children:"浏览官方仓库"})]}),c.jsxs("form",{onSubmit:U=>{U.preventDefault(),h.trim()&&ot({url:h.trim(),...y.trim()?{ref:y.trim()}:{},...x.trim()?{subdir:x.trim()}:{}})},children:[c.jsxs("label",{children:["GitHub 仓库地址",c.jsx("input",{type:"url",placeholder:"https://github.com/owner/repository",value:h,required:!0,disabled:!!ee||!!B,onChange:U=>{m(U.target.value),N(void 0)}})]}),c.jsxs("details",{children:[c.jsx("summary",{children:"指定分支或子目录"}),c.jsxs("div",{className:"panels-source-fields",children:[c.jsxs("label",{children:["分支 / 标签(可选)",c.jsx("input",{value:y,placeholder:"使用默认分支",disabled:!!ee||!!B,onChange:U=>{b(U.target.value),N(void 0)}})]}),c.jsxs("label",{children:["子目录(可选)",c.jsx("input",{value:x,placeholder:"例如 apps/my-panel",disabled:!!ee||!!B,onChange:U=>{v(U.target.value),N(void 0)}})]})]})]}),c.jsxs("div",{className:"panels-actions",children:[c.jsx("button",{type:"submit",disabled:oe||!h.trim(),children:"读取仓库"}),(h||y||x||A)&&c.jsx("button",{type:"button",disabled:!!ee,onClick:()=>{Z(),M(void 0)},children:"清除"})]})]}),A&&c.jsxs("div",{className:"panels-candidates",children:[c.jsxs("h3",{children:["找到 ",A.panels.length," 个面板"]}),c.jsxs("p",{className:"panels-muted",children:[A.source.url," · ",A.source.ref," ·"," ",c.jsx("code",{children:A.source.commit.slice(0,12)})]}),A.panels.length===0&&c.jsx("p",{className:"panels-muted",children:"仓库中没有找到可安装的面板。请检查地址和子目录。"}),Re.length>1&&c.jsxs("div",{className:"panels-actions panels-batch-start",children:[c.jsxs("button",{disabled:oe,onClick:()=>{we(Re)},children:["逐个审阅未安装面板(",Re.length,")"]}),c.jsx("small",{children:"按顺序确认,可随时跳过或停止。"})]}),c.jsx("div",{className:"panels-grid",children:A.panels.map(U=>{const fe=u?.panels.find(je=>je.id===U.id);return c.jsxs("article",{className:"panels-card",children:[c.jsxs("div",{className:"panels-card-heading",children:[c.jsx("h3",{children:Vn(U.title)}),c.jsxs("span",{className:"panels-badge",children:["v",U.version]})]}),U.description&&c.jsx("p",{children:U.description}),c.jsx("small",{children:U.subdir==="."?"仓库根目录":U.subdir}),c.jsx("div",{className:"panels-actions",children:c.jsx("button",{disabled:oe||!!(fe&&!fe.updatable),onClick:()=>fe?void pt(fe):void Ze(U.source),children:fe?fe.updatable?"已安装 · 检查更新":"已从其他来源安装":"审阅安装"})})]},`${U.id}:${U.subdir}`)})}),A.issues.length>0&&c.jsxs("div",{className:"panels-warning",children:[c.jsx("strong",{children:"部分目录无法作为面板安装"}),c.jsx("ul",{children:A.issues.map(U=>c.jsxs("li",{children:[U.subdir,":",U.error]},U.subdir))})]})]})]})]})}function fw(t){const i=t.projectId===void 0?Sa():t.projectId,l=`/api/v1/panels/runtime/${encodeURIComponent(t.instanceId)}`,a=new Set,o=new Set;let f=!1,u=t.expiresAt,p=u-6e4,h,m=0,y=0,b=0,x,v;const j=(C,L)=>{const B=setTimeout(()=>{a.delete(B),f||C()},Math.max(0,Math.min(L,2147483647)));return a.add(B),B},z=C=>{C!==void 0&&(clearTimeout(C),a.delete(C))},A=()=>{if(!f){f=!0;for(const C of a)clearTimeout(C);a.clear();for(const C of o)C.abort();o.clear()}},N=C=>{f||(A(),t.onTerminal(C))},T=()=>N(new Error("面板连接已到期,请重新打开继续使用。")),M=C=>C instanceof Ke&&[401,403,410].includes(C.status),G=()=>{f||t.onStatus(m||y?"面板连接暂时中断,正在重试;当前内容会保留。":"")},ae=async(C,L="GET")=>{const B=new AbortController;o.add(B);const Q=j(()=>B.abort(),8e3);try{return await qe(xt(`${l}${C}`,t.workspace,i),{method:L,...L==="POST"?{headers:{"Content-Type":"application/json"},body:"{}"}:{},signal:B.signal})}finally{z(Q),o.delete(B)}},D=()=>{z(x),x=j(()=>{Date.now()>=u?T():D()},u-Date.now())},H=()=>{z(v),m<5&&(v=j(W,p-Date.now()))};function W(){if(!f){if(Date.now()>=u){T();return}h||m>=5||Date.now()<p||(h=(async()=>{try{const C=await ae("/renew","POST");if(f)return;if(!C||typeof C!="object"||!("expiresAt"in C)||typeof C.expiresAt!="number"||!Number.isFinite(C.expiresAt)||C.expiresAt<=Date.now()+6e4)throw new Error("面板续期响应无效。");u=C.expiresAt,p=u-6e4,m=0,D(),G()}catch(C){if(f)return;if(M(C)){N(C);return}m++,p=Date.now()+Math.min(5e3*2**(m-1),3e4),G()}finally{h=void 0,f||H()}})())}}async function q(){try{const C=await ae(`/events?after=${b}`);if(f)return;if(!C||typeof C!="object"||!("cursor"in C)||!("events"in C))throw new Error("面板事件响应无效。");if(!Number.isSafeInteger(C.cursor)||C.cursor<b||!Array.isArray(C.events)||C.events.length>2048)throw new Error("面板事件响应无效。");const L=[];let B=b;for(const Q of C.events){if(!Q||typeof Q!="object"||!Number.isSafeInteger(Q.id)||Q.id<=B||Q.id>C.cursor||typeof Q.event!="string"||!/^[A-Za-z][A-Za-z0-9._-]{0,100}$/.test(Q.event))throw new Error("面板事件响应无效。");B=Q.id,L.push(Q)}t.onEvents(L),b=C.cursor,y=0,G()}catch(C){if(f)return;if(M(C)){N(C);return}y++,G()}finally{f||j(()=>{q()},Math.min(1e3*2**y,5e3))}}return D(),H(),q(),{stop:A,refresh:W}}function dw(t){if(!Number.isInteger(t.maxDurationSeconds)||t.maxDurationSeconds<1||t.maxDurationSeconds>600||!Number.isInteger(t.maxBytes)||t.maxBytes<1||t.maxBytes>25*1024*1024)throw new Error("录音限制无效。");let i={phase:"idle",elapsedSeconds:0,message:"点击开始录音后,浏览器才会请求麦克风。"},l=0,a,o,f,u=[],p=0,h="",m=t.signal.aborted;const y=j=>{i={...i,...j},m||t.onChange({...i})},b=()=>{a?.getTracks().forEach(j=>j.stop()),a=void 0,f&&clearInterval(f),f=void 0},x=()=>{try{o?.state!=="inactive"&&o?.stop()}finally{b()}},v=()=>{if(!m){m=!0,l++,o&&(o.ondataavailable=null,o.onstop=null,o.onerror=null);try{x()}finally{b()}u=[],i={phase:"closed",elapsedSeconds:0,message:"录音已关闭。"},t.signal.removeEventListener("abort",v)}};return m?i={phase:"closed",elapsedSeconds:0,message:"录音授权已结束。"}:t.signal.addEventListener("abort",v,{once:!0}),{snapshot:()=>({...i}),async start(){if(m||t.signal.aborted)throw new Error("录音授权已结束。");if(["requesting","recording"].includes(i.phase))throw new Error("已有录音正在进行。");const j=++l,z=()=>!m&&j===l&&!t.signal.aborted;u=[],p=0,h="",y({phase:"requesting",elapsedSeconds:0,blob:void 0,message:"正在等待麦克风授权…"});try{const A=await(t.getStream?t.getStream():navigator.mediaDevices.getUserMedia({audio:!0,video:!1}));if(!z()){A.getTracks().forEach(G=>G.stop());return}a=A;const N=["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg;codecs=opus"].find(G=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(G));o=t.makeRecorder?t.makeRecorder(a):new MediaRecorder(a,{...N?{mimeType:N}:{},audioBitsPerSecond:128e3});const T=o;T.ondataavailable=G=>{!z()||!G.data.size||(u.push(G.data),p+=G.data.size,p>t.maxBytes&&(h="录音超过大小限制;可以下载备份,或重新录制较短的音频。",x()))},T.onerror=()=>{if(z()){h="录音设备发生错误;请检查麦克风后重新录制。";try{x()}catch{b()}y({phase:"error",message:h})}},T.onstop=()=>{if(!z())return;b();const G=new Blob(u,{type:T.mimeType.split(";")[0]||"audio/webm"});u=[],y({phase:G.size&&!h?"review":"error",blob:G.size?G:void 0,message:h||(G.size?"录音已停止。可以试听,再保存到当前项目。":"没有录到声音,请重新录制。")})};const M=Date.now();T.start(250),y({phase:"recording",message:"正在使用这台设备的麦克风录音。"}),f=setInterval(()=>{if(!z())return;const G=Math.floor((Date.now()-M)/1e3);y({elapsedSeconds:G}),G>=t.maxDurationSeconds&&x()},250)}catch(A){if(b(),!z())return;y({phase:"error",message:A instanceof Error&&["NotAllowedError","SecurityError"].includes(A.name)?"麦克风未获授权,请检查浏览器和系统的麦克风权限。":"无法启动录音,请确认安全连接、麦克风和浏览器录音支持。"})}},stop:x,close:v}}function Db(t){const i=new Blob([t.blob],{type:t.blob.type.split(";")[0].trim().toLowerCase()}),l=[],a=t.timing?.now??Date.now,o=t.timing?.sleep??((x,v)=>new Promise((j,z)=>{const A=()=>{clearTimeout(N),z(v.reason)},N=setTimeout(()=>{v.removeEventListener("abort",A),j()},x);v.addEventListener("abort",A,{once:!0}),v.aborted&&A()})),f=async()=>{const x=t.transferBudget;if(!(!x||!Number.isSafeInteger(x.rateWindowMs)||x.rateWindowMs<1||!Number.isSafeInteger(x.maxTransferCallsPerWindow)||x.maxTransferCallsPerWindow<1))for(;;){t.signal.throwIfAborted();const v=a();for(;l.length&&l[0]<=v-x.rateWindowMs;)l.shift();if(l.length<x.maxTransferCallsPerWindow){l.push(v);return}await o(Math.max(1,l[0]+x.rateWindowMs-v),t.signal)}};let u,p=!1,h;const m=()=>t.signal.throwIfAborted(),y=async(x,v)=>{m();const j=await t.call(x,v);return m(),j},b=x=>{const v=x;if(!v||typeof v.sessionId!="string"||!/^upload-[a-f0-9-]{36}$/.test(v.sessionId)||u&&u!==v.sessionId||v.mimeType!==i.type||!["uploading","finished"].includes(String(v.state))||!Number.isSafeInteger(v.receivedBytes)||Number(v.receivedBytes)<0||Number(v.receivedBytes)>i.size||!Number.isSafeInteger(v.nextSequence)||Number(v.nextSequence)<0||!Number.isSafeInteger(v.maxChunkBytes)||Number(v.maxChunkBytes)<1||Number(v.maxChunkBytes)>32768)throw new Error("文件上传状态无效,请保留本机备份后重新打开面板。");return v};return{async save(){if(m(),p)throw new Error("文件正在保存,请稍候。");if(!i.size||i.size>t.maxBytes||!t.mimeTypes.includes(i.type))throw new Error("文件格式或大小无效。");p=!0;try{if(!h){const j=await i.arrayBuffer();m(),h=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",j)),z=>z.toString(16).padStart(2,"0")).join(""),m()}let x=b(u?await y("resources.upload.get",{sessionId:u}):await y("resources.upload.begin",{name:t.name,mimeType:i.type,expectedBytes:i.size,expectedSha256:h}));for(u=x.sessionId,t.onProgress(x.receivedBytes);x.receivedBytes<i.size;){if(x.state!=="uploading")throw new Error("文件上传已结束,文件大小不匹配。");const j=x.receivedBytes,z=new Uint8Array(await i.slice(j,j+x.maxChunkBytes).arrayBuffer());m(),await f(),m();const A=b(await y("resources.upload.write",{sessionId:u,sequence:x.nextSequence,offset:j,dataBase64:btoa(String.fromCharCode(...z))}));if(A.receivedBytes!==j+z.length||A.nextSequence!==x.nextSequence+1)throw new Error("文件上传进度不匹配,请重试保存以核对服务端状态。");x=A,t.onProgress(x.receivedBytes)}const v=await y("resources.upload.finish",{sessionId:u});if(!v?.asset||v.asset.id!==`asset-${h}`||v.asset.bytes!==i.size||v.asset.mimeType!==i.type)throw new Error("文件保存回执不匹配,请保留本机备份并重试。");return v}finally{p=!1}}}}function hw(t){return Db({...t,maxBytes:25*1024*1024,mimeTypes:["audio/webm","audio/mp4","audio/ogg","audio/wav"]})}function pw({request:t}){const[i,l]=w.useState({phase:"idle",elapsedSeconds:0,message:"点击开始录音后,浏览器才会请求麦克风。"}),[a,o]=w.useState(""),[f,u]=w.useState(!1),[p,h]=w.useState(0),[m,y]=w.useState(""),b=w.useRef(null),x=w.useRef(void 0),v=w.useRef(void 0),j=w.useRef(void 0);w.useEffect(()=>{const N=new AbortController;j.current=N;const T=AbortSignal.any([t.signal,N.signal]);return x.current=dw({...t,signal:T,onChange:l}),b.current?.focus(),b.current?.scrollIntoView?.({block:"nearest"}),()=>{N.abort(),x.current?.close(),x.current=void 0,v.current=void 0}},[t]),w.useEffect(()=>{if(!i.blob){y("");return}const N=URL.createObjectURL(i.blob);return y(N),()=>URL.revokeObjectURL(N)},[i.blob]);const z=i.blob?.type==="audio/mp4"?"m4a":i.blob?.type==="audio/ogg"?"ogg":"webm",A=async()=>{const N=i.blob,T=j.current;if(!N||!T||f||i.phase!=="review")return;const M=AbortSignal.any([t.signal,T.signal]);u(!0),o("");try{v.current?.blob!==N&&(v.current={blob:N,transfer:hw({blob:N,name:`recording.${z}`,signal:M,call:(ae,D)=>t.call(ae,D,M),onProgress:h})});const G=await v.current.transfer.save();M.throwIfAborted(),t.finish(G)}catch(G){M.aborted||o(`${G instanceof Error?G.message:"保存失败。"} 录音仍保留在本页,可重试保存或下载备份。`)}finally{M.aborted||u(!1)}};return c.jsxs("section",{className:"panel-host-audio panel-host-preview","aria-label":"录音",tabIndex:-1,ref:b,children:[c.jsxs("header",{children:[c.jsx("h2",{children:"录音并保存到当前项目"}),c.jsx("button",{onClick:()=>t.finish({cancelled:!0}),children:"取消录音"})]}),c.jsxs("p",{children:["使用当前设备的麦克风;最长 ",t.maxDurationSeconds," ","秒。停止后可试听,点击保存才会上传到当前项目。关闭面板会丢弃未保存录音。"]}),c.jsxs("p",{role:"status",children:[i.message," ",i.elapsedSeconds>0&&`${i.elapsedSeconds} 秒`]}),m&&c.jsx("audio",{controls:!0,src:m}),a&&c.jsx("p",{role:"alert",children:a}),f&&c.jsxs("p",{role:"status",children:["正在保存录音:",Math.round(p/(i.blob?.size||1)*100),"%"]}),c.jsxs("div",{className:"panel-host-actions",children:[["idle","error"].includes(i.phase)&&!i.blob&&c.jsx("button",{onClick:()=>{o(""),x.current?.start().catch(N=>o(String(N)))},children:"开始录音"}),i.phase==="recording"&&c.jsx("button",{onClick:()=>x.current?.stop(),children:"停止录音"}),i.phase==="review"&&c.jsx("button",{disabled:f,className:"panel-host-primary",onClick:()=>{A()},children:f?"正在保存…":"保存到当前项目"}),m&&c.jsx("button",{disabled:f,onClick:()=>{o(""),v.current=void 0,x.current?.start().catch(N=>o(String(N)))},children:"丢弃并重新录制"}),m&&c.jsx("a",{href:m,download:`recording.${z}`,children:"下载本机备份"})]})]})}const fl=Object.freeze({maxDurationSeconds:1200,maxBytes:200*1024*1024,defaultDurationSeconds:300,defaultBytes:64*1024*1024});function _b(t){const i=t;if(!i||typeof i!="object"||Array.isArray(i)||Object.keys(i).some(o=>!["source","microphone","systemAudio","maxDurationSeconds","maxBytes"].includes(o))||i.source!=="camera"&&i.source!=="screen"||i.microphone!==void 0&&typeof i.microphone!="boolean"||i.systemAudio!==void 0&&typeof i.systemAudio!="boolean"||i.source!=="screen"&&i.systemAudio===!0)throw new Error("视频录制请求无效。");const l=i.maxDurationSeconds??fl.defaultDurationSeconds,a=i.maxBytes??fl.defaultBytes;if(!Number.isSafeInteger(l)||Number(l)<1||Number(l)>fl.maxDurationSeconds||!Number.isSafeInteger(a)||Number(a)<1||Number(a)>fl.maxBytes)throw new Error("视频录制限制无效。");return{source:i.source,microphone:i.microphone!==!1,systemAudio:i.systemAudio===!0,maxDurationSeconds:Number(l),maxBytes:Number(a)}}const mw=["video/webm;codecs=vp8,opus","video/webm;codecs=vp9,opus","video/webm","video/mp4"];function Mb(){try{return mw.find(t=>typeof MediaRecorder<"u"&&MediaRecorder.isTypeSupported(t))}catch{return}}function df(){const t=typeof navigator>"u"?void 0:navigator.mediaDevices,i=typeof window<"u"&&window.isSecureContext===!0&&!!Mb(),l=i&&typeof t?.getUserMedia=="function",a=i&&typeof t?.getDisplayMedia=="function";return{camera:l,screen:a,microphone:l,systemAudio:a,maxDurationSeconds:fl.maxDurationSeconds,maxBytes:fl.maxBytes}}function gw(t){const i=_b({source:t.source,microphone:t.microphone,systemAudio:t.systemAudio,maxDurationSeconds:t.maxDurationSeconds,maxBytes:t.maxBytes});let l={phase:"idle",elapsedSeconds:0,message:"点击开始录制后,才会请求设备授权。",capture:{source:i.source,microphone:!1,systemAudio:!1}},a=0,o=t.signal.aborted,f,u,p,h=[],m=0,y="";const b=new Set,x=A=>{l={...l,...A},o||t.onChange({...l})},v=()=>{p&&clearInterval(p),p=void 0;for(const A of new Set([...b].flatMap(N=>N.getTracks())))A.onended=null,A.stop();b.clear(),u&&u.state!=="closed"&&u.close().catch(()=>{}),u=void 0},j=()=>{try{f?.state!=="inactive"&&f?.stop()}finally{v()}},z=()=>{if(!o){o=!0,a++,f&&(f.ondataavailable=null,f.onstop=null,f.onerror=null);try{j()}finally{v()}h=[],l={...l,phase:"closed",stream:void 0,blob:void 0},t.signal.removeEventListener("abort",z)}};return o?l.phase="closed":t.signal.addEventListener("abort",z,{once:!0}),{snapshot:()=>({...l}),async start(){if(o||t.signal.aborted)throw new Error("录制授权已结束。");if(["requesting","recording"].includes(l.phase))throw new Error("已有录制正在进行。");const A=++a,N=()=>!o&&a===A&&!t.signal.aborted,T=M=>{if(!N())throw M.getTracks().forEach(G=>G.stop()),new Error("录制授权已结束。");b.add(M);for(const G of M.getTracks()){if(G.readyState==="ended")throw new Error("所选采集来源已经停止,请重新连接。");G.onended=()=>{N()&&(l.phase==="recording"?j():(a++,v(),x({phase:"error",stream:void 0,message:"采集来源已停止,请重新连接。"})))}}return M};v(),h=[],m=0,y="",x({phase:"requesting",elapsedSeconds:0,stream:void 0,blob:void 0,message:"正在等待设备授权…"});try{const M=t.devices??navigator.mediaDevices;if(!M)throw new Error("录制需要安全连接和浏览器设备支持。");const G=T(await(i.source==="screen"?M.getDisplayMedia({video:!0,audio:i.systemAudio}):M.getUserMedia({video:!0,audio:i.microphone})));if(!G.getVideoTracks().length)throw new Error("没有获得可录制的画面。");const ae=i.source==="screen"&&i.microphone?T(await M.getUserMedia({audio:!0,video:!1})):void 0,D=i.microphone?(i.source==="camera"?G:ae)?.getAudioTracks()??[]:[];if(i.microphone&&!D.length)throw new Error("没有获得麦克风音轨。");const H=i.source==="screen"&&i.systemAudio?G.getAudioTracks():[];let W=T(new MediaStream([...G.getVideoTracks(),...D,...H]));if(D.length&&i.source==="screen")if(H.length){u=t.makeAudioContext?t.makeAudioContext():new AudioContext;const B=u,Q=B.createMediaStreamDestination();T(Q.stream);for(const K of[D,H])B.createMediaStreamSource(new MediaStream(K)).connect(Q);let J;try{await Promise.race([B.resume(),new Promise((K,I)=>{J=setTimeout(()=>I(new Error("声音混合未能启动,请重新录制。")),2e3)})])}finally{J&&clearTimeout(J)}t.signal.throwIfAborted(),W=T(new MediaStream([...G.getVideoTracks(),...Q.stream.getAudioTracks()]))}else W=T(new MediaStream([...G.getVideoTracks(),...D]));if(!N()){v();return}const q=Mb();if(!q)throw new Error("此浏览器不支持视频录制编码。");f=t.makeRecorder?t.makeRecorder(W,q):new MediaRecorder(W,{mimeType:q});const C=f;C.ondataavailable=B=>{!N()||!B.data.size||(h.push(B.data),m+=B.data.size,m>i.maxBytes&&(y="录制超过大小限制;可以下载备份或重新录制较短的视频。",j()))},C.onerror=()=>{if(N()){y="录制设备或编码器发生错误,请保留备份后重试。";try{j()}catch{v()}x({phase:"error",stream:void 0,message:y})}},C.onstop=()=>{if(!N())return;v();const B=new Blob(h,{type:C.mimeType.split(";")[0]||q.split(";")[0]});h=[],x({phase:B.size&&!y?"review":"error",stream:void 0,blob:B.size?B:void 0,message:y||(B.size?"录制已停止。可以预览,再保存到当前项目。":"没有录到内容,请重新录制。")})};const L=Date.now();C.start(250),x({phase:"recording",stream:W,capture:{source:i.source,microphone:D.length>0,systemAudio:H.length>0},message:"正在使用这台设备录制;停止后可以预览和保存。"}),p=setInterval(()=>{if(!N())return;const B=Math.floor((Date.now()-L)/1e3);x({elapsedSeconds:B}),B>=i.maxDurationSeconds&&j()},250)}catch(M){if(v(),!N())return;x({phase:"error",stream:void 0,message:M instanceof Error&&["NotAllowedError","SecurityError"].includes(M.name)?"设备未获授权或屏幕选择已取消,请检查浏览器和系统权限后重试。":M instanceof Error?M.message:"无法启动录制,请检查设备和浏览器支持。"})}},stop:j,close:z}}function yw({request:t}){const[i,l]=w.useState({phase:"idle",elapsedSeconds:0,message:"点击开始录制后,才会请求设备授权。",capture:{source:t.source,microphone:!1,systemAudio:!1}}),[a,o]=w.useState(""),[f,u]=w.useState(!1),[p,h]=w.useState(0),[m,y]=w.useState(""),b=w.useRef(null),x=w.useRef(null),v=w.useRef(void 0),j=w.useRef(void 0),z=w.useRef(void 0);w.useEffect(()=>{const M=new AbortController;z.current=M;const G=AbortSignal.any([t.signal,M.signal]);v.current=gw({...t,signal:G,onChange:l});const ae=()=>{M.abort(),t.finish({cancelled:!0})};return window.addEventListener("pagehide",ae,{once:!0}),b.current?.focus(),b.current?.scrollIntoView?.({block:"nearest"}),()=>{window.removeEventListener("pagehide",ae),M.abort(),v.current?.close(),v.current=void 0,j.current=void 0}},[t]),w.useEffect(()=>{const M=x.current;if(M)return M.srcObject=i.stream??null,i.stream&&M.play().catch(()=>{}),()=>{M.srcObject=null}},[i.stream]),w.useEffect(()=>{if(!i.blob){y("");return}const M=URL.createObjectURL(i.blob);return y(M),()=>URL.revokeObjectURL(M)},[i.blob]);const A=i.blob?.type==="video/mp4"?"mp4":"webm",N=()=>{o(""),j.current=void 0,v.current?.start().catch(M=>o(String(M)))},T=async()=>{const M=i.blob,G=z.current;if(!M||!G||f||i.phase!=="review")return;const ae=AbortSignal.any([t.signal,G.signal]);u(!0),o("");try{j.current?.blob!==M&&(j.current={blob:M,transfer:Db({blob:M,name:`recording.${A}`,signal:ae,maxBytes:t.maxBytes,mimeTypes:["video/webm","video/mp4"],transferBudget:t.transferBudget,call:(H,W)=>t.call(H,W,ae),onProgress:h})});const D=await j.current.transfer.save();ae.throwIfAborted(),t.finish({...D,capture:i.capture})}catch(D){ae.aborted||o(`${D instanceof Error?D.message:"保存失败。"} 视频仍保留在本页,可重试保存或下载备份。若已保存但未收到回复,重开面板后可从项目资源找回。`)}finally{ae.aborted||u(!1)}};return c.jsxs("section",{className:"panel-host-video panel-host-preview","aria-label":"视频录制",tabIndex:-1,ref:b,children:[c.jsxs("header",{children:[c.jsxs("h2",{children:[t.source==="camera"?"摄像头录制":"屏幕录制","并保存到当前项目"]}),c.jsx("button",{onClick:()=>t.finish({cancelled:!0}),children:"取消录制"})]}),c.jsxs("p",{children:["使用当前设备;最长 ",t.maxDurationSeconds," 秒,最多"," ",Math.ceil(t.maxBytes/1024/1024)," MiB。",t.microphone?"使用麦克风。":"不使用麦克风。",t.systemAudio&&"屏幕声音取决于浏览器和你选择的共享来源,可能没有声音音轨。","停止后可预览,点击保存才会上传。关闭面板会丢弃未保存录制。"]}),c.jsxs("p",{role:"status",children:[i.message," ",i.elapsedSeconds>0&&`${i.elapsedSeconds} 秒`]}),i.stream&&c.jsx("video",{ref:x,muted:!0,playsInline:!0,"aria-label":"实时录制预览"}),m&&c.jsx("video",{controls:!0,playsInline:!0,src:m,"aria-label":"录制预览"}),i.phase==="recording"&&c.jsxs("p",{children:["麦克风:",i.capture.microphone?"已采集":"未采集",";屏幕声音:",i.capture.systemAudio?"已采集":"未采集"]}),a&&c.jsx("p",{role:"alert",children:a}),f&&c.jsxs("p",{role:"status",children:["正在保存视频:",Math.round(p/(i.blob?.size||1)*100),"%"]}),c.jsxs("div",{className:"panel-host-actions",children:[["idle","error"].includes(i.phase)&&!i.blob&&c.jsx("button",{onClick:N,children:"开始录制"}),i.phase==="recording"&&c.jsx("button",{onClick:()=>v.current?.stop(),children:"停止录制"}),i.phase==="review"&&c.jsx("button",{disabled:f,className:"panel-host-primary",onClick:()=>{T()},children:f?"正在保存…":"保存到当前项目"}),m&&c.jsx("button",{disabled:f,onClick:N,children:"丢弃并重新录制"}),m&&c.jsx("a",{href:m,download:`recording.${A}`,children:"下载本机备份"})]})]})}const Qi="/api/v1/panels/runtime";function Zt(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function bw(t){try{if(typeof t!="string"||t.length>2048)return;const i=new URL(t);if(i.protocol==="https:"&&!i.username&&!i.password)return i.href}catch{}}function vw(t,i){const l=`${Qi}/${i}/directory/`;return typeof t=="string"&&t.startsWith(l)&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t.slice(l.length))}function xw(t,i,l){if(!Zt(t)||t.effect!=="resources.open"||!Zt(t.asset))return;const a=t.asset;if(typeof a.id!="string"||!/^(?:asset|external)-[a-f0-9]{64}$/.test(a.id)||a.id!==l||t.url!==`${Qi}/${i}/resources/${a.id}`||typeof a.name!="string"||!a.name||a.name.length>1024||typeof a.mimeType!="string"||!Number.isSafeInteger(a.bytes)||Number(a.bytes)<0)return;const o=["video/mp4","video/webm","video/ogg","video/quicktime"].includes(a.mimeType)?"video":["audio/mpeg","audio/mp4","audio/ogg","audio/wav","audio/webm","audio/flac","audio/aac"].includes(a.mimeType)?"audio":["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp"].includes(a.mimeType)?"image":"file";return{name:a.name,url:t.url,kind:o}}function Sw(t){if(typeof t!="string"||!/^\/api\/v1\/panel-assets\/[A-Za-z0-9_-]{20,128}\/[A-Za-z0-9_%./-]+$/.test(t))return!1;try{return t.split("/").slice(5).every(i=>{const l=decodeURIComponent(i);return!!l&&!l.startsWith(".")&&!/[\\/:\u0000-\u001f\u007f]/.test(l)})}catch{return!1}}function ww(t){return Zt(t)?typeof t.instanceId=="string"&&/^[A-Za-z0-9_-]{20,128}$/.test(t.instanceId)&&Sw(t.src)&&typeof t.expiresAt=="number"&&Number.isFinite(t.expiresAt)&&Zt(t.context)&&Array.isArray(t.limitations)&&t.limitations.every(i=>typeof i=="string"):!1}function jw({panel:t,sessionId:i,busy:l,onClose:a,onAuthLost:o,onDirtyChange:f,onSubmitPrompt:u}){const p=w.useRef(null),[h,m]=w.useState(),[y,b]=w.useState(!0),[x,v]=w.useState(""),[j,z]=w.useState(""),[A,N]=w.useState(),[T,M]=w.useState(),[G,ae]=w.useState(!1),D=w.useRef(null);w.useEffect(()=>{T&&(D.current?.focus(),D.current?.scrollIntoView?.({block:"nearest"}))},[T]);const[H,W]=w.useState(""),[q,C]=w.useState(""),[L,B]=w.useState(),[Q,J]=w.useState(),K=w.useRef(void 0),[I,Y]=w.useState(),[X,pe]=w.useState(!1),[k,O]=w.useState(0),te=w.useRef({onClose:a,onAuthLost:o,onDirtyChange:f,onSubmitPrompt:u,busy:l});te.current={onClose:a,onAuthLost:o,onDirtyChange:f,onSubmitPrompt:u,busy:l};const R=w.useRef(!1),ee=w.useRef(void 0),ve=w.useRef(void 0),le=w.useRef(null);return w.useEffect(()=>{te.current.onDirtyChange?.(!!L||X||!!Q||!!I),L&&(le.current?.focus(),le.current?.scrollIntoView?.({block:"nearest"}))},[L,X,Q,I]),w.useEffect(()=>{const ue=io()??"",xe=Sa(),F={workspace:ue,grant:void 0},ke=new AbortController,ze=new Set,Le=new Set;let Ee=!1,Xe;const gt=[],He=[],Lt=new Set,st=new Set;let Ve,At=!1,Ie=!1,yt=!1,ot=!1;const Ze=()=>{const Se=p.current?.contentWindow;if(!(Ee||!F.grant||!Se||!ot))for(const Ae of gt.splice(0))Ae.event==="tools.invoke"&&Zt(Ae.payload)&&typeof Ae.payload.requestId=="string"&&/^[A-Za-z0-9_-]{1,128}$/.test(Ae.payload.requestId)&&st.add(Ae.payload.requestId),Se.postMessage({type:"codeshell-panel:event",instanceId:F.grant.instanceId,event:Ae.event,payload:Ae.payload},"*")},pt=()=>{Ee||!yt||!ot||!F.grant||(Ve&&clearTimeout(Ve),b(!1),Ze())},_={loaded:()=>{yt=!0,pt()}};ve.current=_,m(void 0),b(!0),v(""),z(""),N(void 0),M(void 0),ae(!1),W(""),C(""),B(void 0),pe(!1),J(void 0),Y(void 0);const Z=Se=>{At||(At=!0,qe(xt(`${Qi}/${encodeURIComponent(Se.instanceId)}`,ue,xe),{method:"DELETE",keepalive:!0}).catch(()=>{}))},ge=Se=>{Ee||(Se instanceof Ke&&Se.status===401&&!R.current&&(R.current=!0,te.current.onAuthLost()),v(Se instanceof Error?Se.message:"面板连接失败,请重新打开。"))},we=Se=>{if(Ee||!F.grant)return;const Ae=F.grant;F.grant=void 0,Xe?.stop(),ee.current?.cancel(),He.length=0,gt.length=0,Z(Ae);for(const Re of ze)Re.abort();Ve&&clearTimeout(Ve),m(void 0),N(void 0),M(void 0),b(!1),pe(!1),W(""),ge(Se)},Ne=Se=>{const Ae=df();return{...Se,...Array.isArray(Se.availableMethods)?{availableMethods:Se.availableMethods.filter(Re=>Re!=="resources.recordVideo"||Ae.camera||Ae.screen)}:{},...typeof Se.sessionId=="string"?{busy:te.current.busy}:{}}},De=(Se,Ae,Re,ne,ye)=>{Ee||!F.grant||Se!==p.current?.contentWindow||Se.postMessage({type:"codeshell-panel:response",instanceId:F.grant.instanceId,requestId:Ae,...ne?{error:ne,...ye?.code?{code:ye.code}:{},...ye?.retryAfterMs!==void 0?{retryAfterMs:ye.retryAfterMs}:{}}:{result:Re}},"*")},Ge=()=>{if(Ee||!F.grant||ee.current||K.current||Ie)return;const Se=He.shift();if(!Se)return;if(Se.expiresAt<=Date.now()){Ge();return}let Ae=!1;const Re={effect:Se,cancel:()=>{ee.current===Re&&(clearTimeout(ne),ee.current=void 0,Ee||(B(void 0),C(""),pe(!1)))},finish:ye=>{if(Ee||!F.grant||ee.current!==Re||Ae)return;Ae=!0,pe(!0),C("");const Oe=new AbortController;ze.add(Oe);const Ce=setTimeout(()=>Oe.abort(),8e3);qe(xt(`${Qi}/${F.grant.instanceId}/confirm`,ue,xe),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({requestId:Se.requestId,allowed:ye}),signal:Oe.signal}).then(U=>{if(!(Ee||ee.current!==Re)){if(typeof U.allowed!="boolean")throw new Error("确认响应无效。");ye&&U.allowed===!1&&z("此确认已超时或被取消,操作未获准执行,请在面板中重新发起。"),!ye&&U.allowed===!0&&z("该操作此前已获准执行,请在面板中查看进度或停止。"),Re.cancel(),Ge()}}).catch(U=>{if(!(Ee||ee.current!==Re)){if(U instanceof Ke&&[401,403,410].includes(U.status)){we(U);return}if(U instanceof Ke&&U.status===409){Re.cancel(),z("面板操作确认已失效,请在面板中重新发起。"),Ge();return}C("暂未收到确认结果。可以重试本次确认,或取消尚未执行的请求。")}}).finally(()=>{clearTimeout(Ce),ze.delete(Oe),Ae=!1,!Ee&&ee.current===Re&&pe(!1)})}},ne=setTimeout(()=>{Re.cancel(),!Ee&&F.grant&&(z("面板操作确认已超时,请在面板中重新发起。"),Ge())},Se.expiresAt-Date.now());ee.current=Re,B(Re),C("")},mt=Se=>{for(const Ae of Se){if(Ae.event!=="host.confirm"){gt.push(Ae);continue}const Re=Ae.payload;if(!Zt(Re)||typeof Re.requestId!="string"||!/^[A-Za-z0-9_-]{1,128}$/.test(Re.requestId)||typeof Re.title!="string"||Re.title.length>500||typeof Re.body!="string"||Re.body.length>3e4)throw new Error("面板操作确认格式无效。");Lt.has(Re.requestId)||(Lt.add(Re.requestId),He.push({effect:"host.confirm",requestId:Re.requestId,title:Re.title,body:Re.body,expiresAt:Date.now()+5e4}))}if(gt.length>2048||He.length>32){we(new Error("面板状态积压过多,请重新打开面板。"));return}Ge(),Ze()},ut=Se=>new Promise(Ae=>{if(ee.current||K.current||Ie){Ae(!1);return}const Re={effect:Se,finish:ye=>{ee.current===Re&&(clearTimeout(ne),ee.current=void 0,Ee||B(void 0),Ae(ye),queueMicrotask(Ge))},cancel:()=>Re.finish(!1)},ne=setTimeout(()=>Re.finish(!1),55e3);ee.current=Re,B(Re)}),dt=async Se=>{const Ae=p.current?.contentWindow,Re=F.grant,ne=Se.data;if(Ee||!Ae||Se.source!==Ae||Se.origin!=="null"||!Re||!Zt(ne)||ne.instanceId!==Re.instanceId)return;if(ne.type==="codeshell-panel:ready"){ot=!0,pt();return}if(ne.type==="codeshell-panel:tool-result"){if(typeof ne.requestId!="string"||!st.has(ne.requestId)||ze.size>=32)return;let fe;try{if(fe=JSON.stringify({requestId:ne.requestId,...typeof ne.error=="string"?{error:ne.error}:{result:ne.result}}),new TextEncoder().encode(fe).length>512*1024)return}catch{return}st.delete(ne.requestId);const je=new AbortController;ze.add(je);const Pe=setTimeout(()=>je.abort(),8e3);try{await qe(xt(`${Qi}/${Re.instanceId}/tool-results`,ue,xe),{method:"POST",headers:{"Content-Type":"application/json"},body:fe,signal:je.signal})}catch(lt){!Ee&&F.grant&&(lt instanceof Ke&&[401,410].includes(lt.status)?we(lt):z("面板工具结果未能送达,请在对话中重新发起操作。"))}finally{clearTimeout(Pe),ze.delete(je)}return}if(ne.type!=="codeshell-panel:call"||typeof ne.requestId!="string"||!/^[A-Za-z0-9_-]{1,80}$/.test(ne.requestId))return;const ye=ne.requestId;if(Le.has(ye)){De(Ae,ye,void 0,"此请求已经处理,请重新发起。");return}if(Le.size>=8192||ze.size>=32){De(Ae,ye,void 0,"面板请求过于频繁,请稍后重试。");return}if(Le.add(ye),typeof ne.method!="string"||!/^[A-Za-z][A-Za-z0-9.]{0,63}$/.test(ne.method)){De(Ae,ye,void 0,"面板方法无效。");return}let Oe;try{if(Oe=JSON.stringify({method:ne.method,params:ne.params}),new TextEncoder().encode(Oe).length>3*1024*1024)throw new Error("too large")}catch{De(Ae,ye,void 0,"面板请求内容过大或格式无效。");return}const Ce=new AbortController;let U=!1;ze.add(Ce);try{const fe=await qe(xt(`${Qi}/${Re.instanceId}/call`,ue,xe),{method:"POST",headers:{"Content-Type":"application/json"},body:Oe,signal:Ce.signal});if(Ee||Ce.signal.aborted)return;if(ne.method==="context.get"&&(ot=!0,pt()),ne.method==="external.open"){const je=Zt(fe)&&fe.effect===ne.method?bw(fe.url):void 0;if(!je)throw new Error("面板返回的外部链接无效。");if(!await ut({effect:"external.open",url:je}))throw new Error("你取消了打开链接,或确认已超时。");De(Ae,ye,{opened:!0})}else if(ne.method==="agent.submitPrompt"){if(!Zt(fe)||fe.effect!==ne.method||typeof fe.prompt!="string"||!fe.prompt.trim()||fe.prompt.length>2e4||fe.sessionId!==i)throw new Error("面板任务与当前对话不匹配,请重新打开面板。");if(!await ut({effect:"agent.submitPrompt",prompt:fe.prompt,sessionId:i}))throw new Error("你取消了发送任务,或确认已超时。");if(Ee||Ce.signal.aborted)return;U=!0,Ie=!0,pe(!0);const je=await te.current.onSubmitPrompt({prompt:fe.prompt,sessionId:i});if(Ee||Ce.signal.aborted)return;z("面板任务已提交到当前对话,可切换到对话查看进度。"),De(Ae,ye,je)}else if(ne.method==="resources.recordVideo.capabilities"){if(!Zt(fe)||fe.effect!==ne.method)throw new Error("视频录制能力响应无效。");De(Ae,ye,df())}else if(ne.method==="resources.recordAudio"||ne.method==="resources.recordVideo"){const je=ne.method==="resources.recordVideo";if(!Zt(fe)||fe.effect!==ne.method)throw new Error("录制请求无效。");const Pe=je?_b(Object.fromEntries(Object.entries(fe).filter(([Tt])=>Tt!=="effect"))):void 0;if(Pe){const Tt=df();if(!Tt[Pe.source]||Pe.microphone&&!Tt.microphone)throw new Error("当前浏览器不支持所选视频录制方式,请检查安全连接和设备支持。")}if(!je&&(!Zt(fe)||fe.effect!==ne.method||!Number.isInteger(fe.maxDurationSeconds)||Number(fe.maxDurationSeconds)<1||Number(fe.maxDurationSeconds)>600||!Number.isInteger(fe.maxBytes)||Number(fe.maxBytes)<1||Number(fe.maxBytes)>25*1024*1024))throw new Error("录音请求无效。");if(K.current||ee.current||Ie)throw new Error("请先完成当前的录制或确认操作。");const lt=await new Promise((Tt,kt)=>{let Wn=!1;const Vt=(En,Bt)=>{Wn||(Wn=!0,clearTimeout(Ta),Ce.signal.removeEventListener("abort",wr),K.current===Ki&&(K.current=void 0,Ee||(J(void 0),Y(void 0))),Bt?kt(Bt):Tt(En),Ge())},wr=()=>Vt(void 0,new Error("录制已关闭或授权已结束。")),Ta=setTimeout(()=>Vt(void 0,new Error("录制操作已超时,请重新打开。")),25*6e4),Ki={signal:Ce.signal,maxDurationSeconds:Number(fe.maxDurationSeconds),maxBytes:Number(fe.maxBytes),...Pe?{...Pe,transferBudget:Zt(Re.context.capabilities)&&Zt(Re.context.capabilities.bridge)?Re.context.capabilities.bridge:void 0}:{},call:async(En,Bt,Jt)=>{const Gn=Jt?AbortSignal.any([Ce.signal,Jt]):Ce.signal;if(Gn.throwIfAborted(),Ee||F.grant!==Re)throw new Error("当前项目授权已结束。");try{const Fn=await qe(xt(`${Qi}/${Re.instanceId}/call`,ue,xe),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({method:En,params:Bt}),signal:Gn});if(Gn.throwIfAborted(),Ee||F.grant!==Re)throw new Error("当前项目授权已结束。");return Fn}catch(Fn){throw Fn instanceof Ke&&[401,403,410].includes(Fn.status)&&we(Fn),Fn}},finish:Vt};K.current=Ki,Ce.signal.addEventListener("abort",wr,{once:!0}),je?Y(Ki):J(Ki)});De(Ae,ye,lt)}else if(ne.method==="resources.open"){M(void 0),ae(!1);const je=xw(fe,Re.instanceId,Zt(ne.params)?ne.params.assetId:void 0);if(!je)throw new Error("面板文件预览链接无效,请重新打开文件。");M({...je,url:xt(je.url,ue,xe),downloadUrl:xt(`${je.url}?download=1`,ue,xe)}),De(Ae,ye,{opened:!0})}else if(ne.method==="filesystem.openDirectory"){if(N(void 0),!Zt(fe)||fe.effect!==ne.method||typeof fe.path!="string")throw new Error("面板目录信息无效。");if(fe.url!==void 0&&!vw(fe.url,Re.instanceId))throw new Error("面板目录链接无效,请重新打开目录。");N({path:fe.path,...typeof fe.url=="string"?{url:xt(fe.url,ue,xe)}:{}}),De(Ae,ye,{opened:!1,path:fe.path})}else if(ne.method==="notifications.send"){if(!Zt(fe)||fe.effect!==ne.method||typeof fe.title!="string"||fe.title.length>160||typeof fe.body!="string"||fe.body.length>2e3)throw new Error("面板通知格式无效。");z(`${fe.title}${fe.body?`:${fe.body}`:""}`),De(Ae,ye,{sent:!0})}else De(Ae,ye,ne.method==="context.get"&&Zt(fe)?Ne(fe):fe)}catch(fe){!Ee&&!Ce.signal.aborted&&(fe instanceof Ke&&[401,410].includes(fe.status)&&we(fe),(ne.method==="agent.submitPrompt"||ne.method==="external.open")&&z(fe instanceof Error?fe.message:"面板操作未完成。"),De(Ae,ye,void 0,fe instanceof Error?fe.message:"面板请求失败。",fe instanceof Ke?{code:fe.code,retryAfterMs:fe.retryAfterMs}:void 0))}finally{ze.delete(Ce),U&&(Ie=!1,Ee||pe(!1),Ge())}},tt=Se=>{dt(Se)};window.addEventListener("message",tt);const Ot=()=>Xe?.refresh(),oe=()=>{document.visibilityState==="visible"&&Ot()};return window.addEventListener("focus",Ot),window.addEventListener("online",Ot),document.addEventListener("visibilitychange",oe),qe(xt(`${Qi}/prepare`,ue,xe),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({appId:t.id,revision:t.revision,...i?{sessionId:i}:{},theme:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light",locale:"zh-CN"}),signal:ke.signal}).then(Se=>{if(!ww(Se))throw new Error("面板启动信息无效,请刷新面板列表后重试。");if(Ee||ke.signal.aborted){Z(Se);return}if(Se.expiresAt<=Date.now())throw Z(Se),new Error("面板授权已过期,请重新打开。");F.grant=Se,m({...Se,context:Ne(Se.context),src:xt(Se.src,ue,xe)}),Ve=setTimeout(()=>{we(new Error("面板未能完成加载,请重新打开。若仍无法加载,可检查面板文件或使用桌面客户端。"))},45e3),Xe=fw({instanceId:Se.instanceId,expiresAt:Se.expiresAt,workspace:ue,projectId:xe,onEvents:mt,onTerminal:we,onStatus:W})}).catch(Se=>{!Ee&&!ke.signal.aborted&&(b(!1),ge(Se))}),()=>{Ee=!0,ee.current?.cancel(),window.removeEventListener("message",tt),window.removeEventListener("focus",Ot),window.removeEventListener("online",Ot),document.removeEventListener("visibilitychange",oe),Xe?.stop(),ke.abort();for(const Se of ze)Se.abort();Ve&&clearTimeout(Ve),F.grant&&Z(F.grant),te.current.onDirtyChange?.(!1),ve.current===_&&(ve.current=void 0)}},[t.id,t.revision,i,k]),w.useEffect(()=>{!h||!p.current?.contentWindow||p.current.contentWindow.postMessage({type:"codeshell-panel:event",instanceId:h.instanceId,event:"context.changed",payload:{...h.context,...typeof h.context.sessionId=="string"?{busy:l}:{}}},"*")},[l,h]),c.jsxs("section",{className:"panel-host",children:[c.jsxs("header",{className:"panel-host-heading",children:[c.jsxs("div",{children:[c.jsx("h1",{children:t.title["zh-CN"]||t.title.default}),c.jsxs("p",{children:["v",t.version," · 运行于当前工作区"]})]}),c.jsx("button",{onClick:a,children:"返回面板"})]}),(h?.limitations??t.compatibility.reasons).length>0&&c.jsxs("details",{className:"panel-host-limitations",open:!0,children:[c.jsx("summary",{children:"部分功能可用"}),c.jsx("p",{children:"面板界面可以使用;以下功能尚未接入网页,使用时会显示具体限制。"}),c.jsx("ul",{children:(h?.limitations??t.compatibility.reasons).map(ue=>c.jsx("li",{children:ue},ue))})]}),j&&c.jsx("p",{className:"panel-host-notice",role:"status",children:j}),A&&c.jsxs("div",{className:"panel-host-notice panel-host-directory",role:"status",children:[c.jsxs("p",{children:["文件保存在服务器目录:",A.path]}),A.url&&c.jsx("a",{href:A.url,target:"_blank",rel:"noopener noreferrer",children:"查看并下载文件"})]}),T&&c.jsxs("section",{className:"panel-host-preview","aria-label":"文件预览",tabIndex:-1,ref:D,children:[c.jsxs("header",{children:[c.jsx("h2",{children:T.name}),c.jsx("button",{onClick:()=>M(void 0),children:"关闭预览"})]}),!G&&T.kind==="video"&&c.jsx("video",{src:T.url,controls:!0,playsInline:!0,preload:"metadata",onError:()=>ae(!0)},T.url),!G&&T.kind==="audio"&&c.jsx("audio",{src:T.url,controls:!0,preload:"metadata",onError:()=>ae(!0)},T.url),!G&&T.kind==="image"&&c.jsx("img",{src:T.url,alt:T.name,onError:()=>ae(!0)},T.url),(G||T.kind==="file")&&c.jsx("p",{role:"status",children:"当前浏览器无法预览此文件。可以保存后打开;若保存失败,请重新打开面板检查访问权限。"}),c.jsx("a",{href:T.downloadUrl,download:T.name,children:"保存到此设备"})]}),H&&c.jsx("p",{className:"panel-host-notice",role:"status",children:H}),x&&c.jsxs("div",{className:"panel-host-error",role:"alert",children:[c.jsx("p",{children:x}),c.jsx("button",{disabled:y,onClick:()=>O(ue=>ue+1),children:"重新打开面板"})]}),y&&c.jsx("p",{className:"panel-host-loading",role:"status",children:"正在打开面板…"}),Q&&c.jsx(pw,{request:Q}),I&&c.jsx(yw,{request:I}),L&&c.jsxs("section",{className:"panel-host-confirm",ref:le,tabIndex:-1,onKeyDown:ue=>{ue.key==="Escape"&&!X&&(ue.preventDefault(),L.finish(!1))},"aria-label":L.effect.effect==="external.open"?"确认打开外部链接":L.effect.effect==="host.confirm"?"确认面板操作":"确认发送面板任务",children:[c.jsx("h2",{children:L.effect.effect==="external.open"?"面板请求打开网页":L.effect.effect==="host.confirm"?L.effect.title:"面板请求向当前对话发送任务"}),L.effect.effect==="external.open"?c.jsx("p",{className:"panel-host-url",children:L.effect.url}):L.effect.effect==="host.confirm"?c.jsx("pre",{children:L.effect.body}):c.jsx("pre",{children:L.effect.prompt}),q&&c.jsx("p",{role:"alert",children:q}),c.jsxs("div",{className:"panel-host-actions",children:[c.jsx("button",{disabled:X,onClick:()=>L.finish(!1),children:"取消"}),L.effect.effect==="external.open"?c.jsx("a",{href:L.effect.url,target:"_blank",rel:"noopener noreferrer",onClick:()=>L.finish(!0),children:"确认打开网页"}):c.jsx("button",{className:"panel-host-primary",disabled:X,onClick:()=>L.finish(!0),children:X?"正在确认…":L.effect.effect==="host.confirm"?"确认执行":"确认发送任务"})]})]}),h&&c.jsx("iframe",{ref:p,src:h.src,title:`${t.title["zh-CN"]||t.title.default}面板`,sandbox:"allow-scripts allow-downloads",referrerPolicy:"no-referrer",inert:!!L||X||!!Q||!!I,onLoad:()=>ve.current?.loaded(),allow:"camera 'none'; microphone 'none'; geolocation 'none'; display-capture 'none'; clipboard-read 'none'; clipboard-write 'none'",className:"panel-host-frame"})]})}function kw(t,i){const l={};return(t[t.length-1]===""?[...t,""]:t).join((l.padRight?" ":"")+","+(l.padLeft===!1?"":" ")).trim()}const Cw=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Ew=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,Nw={};function gy(t,i){return(Nw.jsx?Ew:Cw).test(t)}const Aw=/[ \t\n\f\r]/g;function Tw(t){return typeof t=="object"?t.type==="text"?yy(t.value):!1:yy(t)}function yy(t){return t.replace(Aw,"")===""}class Ea{constructor(i,l,a){this.normal=l,this.property=i,a&&(this.space=a)}}Ea.prototype.normal={};Ea.prototype.property={};Ea.prototype.space=void 0;function Ob(t,i){const l={},a={};for(const o of t)Object.assign(l,o.property),Object.assign(a,o.normal);return new Ea(l,a,i)}function Lf(t){return t.toLowerCase()}class gn{constructor(i,l){this.attribute=l,this.property=i}}gn.prototype.attribute="";gn.prototype.booleanish=!1;gn.prototype.boolean=!1;gn.prototype.commaOrSpaceSeparated=!1;gn.prototype.commaSeparated=!1;gn.prototype.defined=!1;gn.prototype.mustUseProperty=!1;gn.prototype.number=!1;gn.prototype.overloadedBoolean=!1;gn.prototype.property="";gn.prototype.spaceSeparated=!1;gn.prototype.space=void 0;let Rw=0;const Ye=Sr(),Qt=Sr(),Bf=Sr(),be=Sr(),Et=Sr(),gr=Sr(),kn=Sr();function Sr(){return 2**++Rw}const Uf=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ye,booleanish:Qt,commaOrSpaceSeparated:kn,commaSeparated:gr,number:be,overloadedBoolean:Bf,spaceSeparated:Et},Symbol.toStringTag,{value:"Module"})),hf=Object.keys(Uf);class sd extends gn{constructor(i,l,a,o){let f=-1;if(super(i,l),by(this,"space",o),typeof a=="number")for(;++f<hf.length;){const u=hf[f];by(this,hf[f],(a&Uf[u])===Uf[u])}}}sd.prototype.defined=!0;function by(t,i,l){l&&(t[i]=l)}function pl(t){const i={},l={};for(const[a,o]of Object.entries(t.properties)){const f=new sd(a,t.transform(t.attributes||{},a),o,t.space);t.mustUseProperty&&t.mustUseProperty.includes(a)&&(f.mustUseProperty=!0),i[a]=f,l[Lf(a)]=a,l[Lf(f.attribute)]=a}return new Ea(i,l,t.space)}const Lb=pl({properties:{ariaActiveDescendant:null,ariaAtomic:Qt,ariaAutoComplete:null,ariaBusy:Qt,ariaChecked:Qt,ariaColCount:be,ariaColIndex:be,ariaColSpan:be,ariaControls:Et,ariaCurrent:null,ariaDescribedBy:Et,ariaDetails:null,ariaDisabled:Qt,ariaDropEffect:Et,ariaErrorMessage:null,ariaExpanded:Qt,ariaFlowTo:Et,ariaGrabbed:Qt,ariaHasPopup:null,ariaHidden:Qt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Et,ariaLevel:be,ariaLive:null,ariaModal:Qt,ariaMultiLine:Qt,ariaMultiSelectable:Qt,ariaOrientation:null,ariaOwns:Et,ariaPlaceholder:null,ariaPosInSet:be,ariaPressed:Qt,ariaReadOnly:Qt,ariaRelevant:null,ariaRequired:Qt,ariaRoleDescription:Et,ariaRowCount:be,ariaRowIndex:be,ariaRowSpan:be,ariaSelected:Qt,ariaSetSize:be,ariaSort:null,ariaValueMax:be,ariaValueMin:be,ariaValueNow:be,ariaValueText:null,role:null},transform(t,i){return i==="role"?i:"aria-"+i.slice(4).toLowerCase()}});function Bb(t,i){return i in t?t[i]:i}function Ub(t,i){return Bb(t,i.toLowerCase())}const zw=pl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:gr,acceptCharset:Et,accessKey:Et,action:null,allow:null,allowFullScreen:Ye,allowPaymentRequest:Ye,allowUserMedia:Ye,alpha:Ye,alt:null,as:null,async:Ye,autoCapitalize:null,autoComplete:Et,autoFocus:Ye,autoPlay:Ye,blocking:Et,capture:null,charSet:null,checked:Ye,cite:null,className:Et,closedBy:null,colorSpace:null,cols:be,colSpan:be,command:null,commandFor:null,content:null,contentEditable:Qt,controls:Ye,controlsList:Et,coords:be|gr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ye,defer:Ye,dir:null,dirName:null,disabled:Ye,download:Bf,draggable:Qt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ye,formTarget:null,headers:Et,height:be,hidden:Bf,high:be,href:null,hrefLang:null,htmlFor:Et,httpEquiv:Et,id:null,imageSizes:null,imageSrcSet:null,inert:Ye,inputMode:null,integrity:null,is:null,isMap:Ye,itemId:null,itemProp:Et,itemRef:Et,itemScope:Ye,itemType:Et,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ye,low:be,manifest:null,max:null,maxLength:be,media:null,method:null,min:null,minLength:be,multiple:Ye,muted:Ye,name:null,nonce:null,noModule:Ye,noValidate:Ye,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:Ye,optimum:be,pattern:null,ping:Et,placeholder:null,playsInline:Ye,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ye,referrerPolicy:null,rel:Et,required:Ye,reversed:Ye,rows:be,rowSpan:be,sandbox:Et,scope:null,scoped:Ye,seamless:Ye,selected:Ye,shadowRootClonable:Ye,shadowRootCustomElementRegistry:Ye,shadowRootDelegatesFocus:Ye,shadowRootMode:null,shadowRootSerializable:Ye,shape:null,size:be,sizes:null,slot:null,span:be,spellCheck:Qt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:be,step:null,style:null,tabIndex:be,target:null,title:null,translate:null,type:null,typeMustMatch:Ye,useMap:null,value:Qt,width:be,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Et,axis:null,background:null,bgColor:null,border:be,borderColor:null,bottomMargin:be,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ye,declare:Ye,event:null,face:null,frame:null,frameBorder:null,hSpace:be,leftMargin:be,link:null,longDesc:null,lowSrc:null,marginHeight:be,marginWidth:be,noResize:Ye,noHref:Ye,noShade:Ye,noWrap:Ye,object:null,profile:null,prompt:null,rev:null,rightMargin:be,rules:null,scheme:null,scrolling:Qt,standby:null,summary:null,text:null,topMargin:be,valueType:null,version:null,vAlign:null,vLink:null,vSpace:be,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Ye,disablePictureInPicture:Ye,disableRemotePlayback:Ye,exportParts:gr,part:Et,prefix:null,property:null,results:be,security:null,unselectable:null},space:"html",transform:Ub}),Dw=pl({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:kn,accentHeight:be,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:be,amplitude:be,arabicForm:null,ascent:be,attributeName:null,attributeType:null,azimuth:be,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:be,by:null,calcMode:null,capHeight:be,className:Et,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:be,diffuseConstant:be,direction:null,display:null,dur:null,divisor:be,dominantBaseline:null,download:Ye,dx:null,dy:null,edgeMode:null,editable:null,elevation:be,enableBackground:null,end:null,event:null,exponent:be,externalResourcesRequired:null,fill:null,fillOpacity:be,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:gr,g2:gr,glyphName:gr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:be,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:be,horizOriginX:be,horizOriginY:be,id:null,ideographic:be,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:be,k:be,k1:be,k2:be,k3:be,k4:be,kernelMatrix:kn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:be,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:be,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:be,overlineThickness:be,paintOrder:null,panose1:null,path:null,pathLength:be,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Et,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:be,pointsAtY:be,pointsAtZ:be,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:kn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:kn,rev:kn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:kn,requiredFeatures:kn,requiredFonts:kn,requiredFormats:kn,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:be,specularExponent:be,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:be,strikethroughThickness:be,string:null,stroke:null,strokeDashArray:kn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:be,strokeOpacity:be,strokeWidth:null,style:null,surfaceScale:be,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:kn,tabIndex:be,tableValues:null,target:null,targetX:be,targetY:be,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:kn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:be,underlineThickness:be,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:be,values:null,vAlphabetic:be,vMathematical:be,vectorEffect:null,vHanging:be,vIdeographic:be,version:null,vertAdvY:be,vertOriginX:be,vertOriginY:be,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:be,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Bb}),Ib=pl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,i){return"xlink:"+i.slice(5).toLowerCase()}}),qb=pl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ub}),Hb=pl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,i){return"xml:"+i.slice(3).toLowerCase()}}),_w={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"},Mw=/[A-Z]/g,vy=/-[a-z]/g,Ow=/^data[-\w.:]+$/i;function Lw(t,i){const l=Lf(i);let a=i,o=gn;if(l in t.normal)return t.property[t.normal[l]];if(l.length>4&&l.slice(0,4)==="data"&&Ow.test(i)){if(i.charAt(4)==="-"){const f=i.slice(5).replace(vy,Uw);a="data"+f.charAt(0).toUpperCase()+f.slice(1)}else{const f=i.slice(4);if(!vy.test(f)){let u=f.replace(Mw,Bw);u.charAt(0)!=="-"&&(u="-"+u),i="data"+u}}o=sd}return new o(a,i)}function Bw(t){return"-"+t.toLowerCase()}function Uw(t){return t.charAt(1).toUpperCase()}const Iw=Ob([Lb,zw,Ib,qb,Hb],"html"),od=Ob([Lb,Dw,Ib,qb,Hb],"svg");function qw(t){return t.join(" ").trim()}var ol={},pf,xy;function Hw(){if(xy)return pf;xy=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,i=/\n/g,l=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,f=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,p=/^\s+|\s+$/g,h=`
29
+ `,m="/",y="*",b="",x="comment",v="declaration";function j(A,N){if(typeof A!="string")throw new TypeError("First argument must be a string");if(!A)return[];N=N||{};var T=1,M=1;function G(J){var K=J.match(i);K&&(T+=K.length);var I=J.lastIndexOf(h);M=~I?J.length-I:M+J.length}function ae(){var J={line:T,column:M};return function(K){return K.position=new D(J),q(),K}}function D(J){this.start=J,this.end={line:T,column:M},this.source=N.source}D.prototype.content=A;function H(J){var K=new Error(N.source+":"+T+":"+M+": "+J);if(K.reason=J,K.filename=N.source,K.line=T,K.column=M,K.source=A,!N.silent)throw K}function W(J){var K=J.exec(A);if(K){var I=K[0];return G(I),A=A.slice(I.length),K}}function q(){W(l)}function C(J){var K;for(J=J||[];K=L();)K!==!1&&J.push(K);return J}function L(){var J=ae();if(!(m!=A.charAt(0)||y!=A.charAt(1))){for(var K=2;b!=A.charAt(K)&&(y!=A.charAt(K)||m!=A.charAt(K+1));)++K;if(K+=2,b===A.charAt(K-1))return H("End of comment missing");var I=A.slice(2,K-2);return M+=2,G(I),A=A.slice(K),M+=2,J({type:x,comment:I})}}function B(){var J=ae(),K=W(a);if(K){if(L(),!W(o))return H("property missing ':'");var I=W(f),Y=J({type:v,property:z(K[0].replace(t,b)),value:I?z(I[0].replace(t,b)):b});return W(u),Y}}function Q(){var J=[];C(J);for(var K;K=B();)K!==!1&&(J.push(K),C(J));return J}return q(),Q()}function z(A){return A?A.replace(p,b):b}return pf=j,pf}var Sy;function Vw(){if(Sy)return ol;Sy=1;var t=ol&&ol.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(ol,"__esModule",{value:!0}),ol.default=l;const i=t(Hw());function l(a,o){let f=null;if(!a||typeof a!="string")return f;const u=(0,i.default)(a),p=typeof o=="function";return u.forEach(h=>{if(h.type!=="declaration")return;const{property:m,value:y}=h;p?o(m,y,h):y&&(f=f||{},f[m]=y)}),f}return ol}var fa={},wy;function Yw(){if(wy)return fa;wy=1,Object.defineProperty(fa,"__esModule",{value:!0}),fa.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,i=/-([a-z])/g,l=/^[^-]+$/,a=/^-(webkit|moz|ms|o|khtml)-/,o=/^-(ms)-/,f=function(m){return!m||l.test(m)||t.test(m)},u=function(m,y){return y.toUpperCase()},p=function(m,y){return"".concat(y,"-")},h=function(m,y){return y===void 0&&(y={}),f(m)?m:(m=m.toLowerCase(),y.reactCompat?m=m.replace(o,p):m=m.replace(a,p),m.replace(i,u))};return fa.camelCase=h,fa}var da,jy;function Gw(){if(jy)return da;jy=1;var t=da&&da.__importDefault||function(o){return o&&o.__esModule?o:{default:o}},i=t(Vw()),l=Yw();function a(o,f){var u={};return!o||typeof o!="string"||(0,i.default)(o,function(p,h){p&&h&&(u[(0,l.camelCase)(p,f)]=h)}),u}return a.default=a,da=a,da}var Fw=Gw();const $w=co(Fw),Vb=Yb("end"),ud=Yb("start");function Yb(t){return i;function i(l){const a=l&&l.position&&l.position[t]||{};if(typeof a.line=="number"&&a.line>0&&typeof a.column=="number"&&a.column>0)return{line:a.line,column:a.column,offset:typeof a.offset=="number"&&a.offset>-1?a.offset:void 0}}}function Qw(t){const i=ud(t),l=Vb(t);if(i&&l)return{start:i,end:l}}function ya(t){return!t||typeof t!="object"?"":"position"in t||"type"in t?ky(t.position):"start"in t||"end"in t?ky(t):"line"in t||"column"in t?If(t):""}function If(t){return Cy(t&&t.line)+":"+Cy(t&&t.column)}function ky(t){return If(t&&t.start)+"-"+If(t&&t.end)}function Cy(t){return t&&typeof t=="number"?t:1}class an extends Error{constructor(i,l,a){super(),typeof l=="string"&&(a=l,l=void 0);let o="",f={},u=!1;if(l&&("line"in l&&"column"in l?f={place:l}:"start"in l&&"end"in l?f={place:l}:"type"in l?f={ancestors:[l],place:l.position}:f={...l}),typeof i=="string"?o=i:!f.cause&&i&&(u=!0,o=i.message,f.cause=i),!f.ruleId&&!f.source&&typeof a=="string"){const h=a.indexOf(":");h===-1?f.ruleId=a:(f.source=a.slice(0,h),f.ruleId=a.slice(h+1))}if(!f.place&&f.ancestors&&f.ancestors){const h=f.ancestors[f.ancestors.length-1];h&&(f.place=h.position)}const p=f.place&&"start"in f.place?f.place.start:f.place;this.ancestors=f.ancestors||void 0,this.cause=f.cause||void 0,this.column=p?p.column:void 0,this.fatal=void 0,this.file="",this.message=o,this.line=p?p.line:void 0,this.name=ya(f.place)||"1:1",this.place=f.place||void 0,this.reason=this.message,this.ruleId=f.ruleId||void 0,this.source=f.source||void 0,this.stack=u&&f.cause&&typeof f.cause.stack=="string"?f.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}an.prototype.file="";an.prototype.name="";an.prototype.reason="";an.prototype.message="";an.prototype.stack="";an.prototype.column=void 0;an.prototype.line=void 0;an.prototype.ancestors=void 0;an.prototype.cause=void 0;an.prototype.fatal=void 0;an.prototype.place=void 0;an.prototype.ruleId=void 0;an.prototype.source=void 0;const cd={}.hasOwnProperty,Xw=new Map,Kw=/[A-Z]/g,Pw=new Set(["table","tbody","thead","tfoot","tr"]),Zw=new Set(["td","th"]),Gb="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function Jw(t,i){if(!i||i.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const l=i.filePath||void 0;let a;if(i.development){if(typeof i.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");a=aj(l,i.jsxDEV)}else{if(typeof i.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof i.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");a=lj(l,i.jsx,i.jsxs)}const o={Fragment:i.Fragment,ancestors:[],components:i.components||{},create:a,elementAttributeNameCase:i.elementAttributeNameCase||"react",evaluater:i.createEvaluater?i.createEvaluater():void 0,filePath:l,ignoreInvalidStyle:i.ignoreInvalidStyle||!1,passKeys:i.passKeys!==!1,passNode:i.passNode||!1,schema:i.space==="svg"?od:Iw,stylePropertyNameCase:i.stylePropertyNameCase||"dom",tableCellAlignToStyle:i.tableCellAlignToStyle!==!1},f=Fb(o,t,void 0);return f&&typeof f!="string"?f:o.create(t,o.Fragment,{children:f||void 0},void 0)}function Fb(t,i,l){if(i.type==="element")return Ww(t,i,l);if(i.type==="mdxFlowExpression"||i.type==="mdxTextExpression")return ej(t,i);if(i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement")return nj(t,i,l);if(i.type==="mdxjsEsm")return tj(t,i);if(i.type==="root")return ij(t,i,l);if(i.type==="text")return rj(t,i)}function Ww(t,i,l){const a=t.schema;let o=a;i.tagName.toLowerCase()==="svg"&&a.space==="html"&&(o=od,t.schema=o),t.ancestors.push(i);const f=Qb(t,i.tagName,!1),u=sj(t,i);let p=dd(t,i);return Pw.has(i.tagName)&&(p=p.filter(function(h){return typeof h=="string"?!Tw(h):!0})),$b(t,u,f,i),fd(u,p),t.ancestors.pop(),t.schema=a,t.create(i,f,u,l)}function ej(t,i){if(i.data&&i.data.estree&&t.evaluater){const a=i.data.estree.body[0];return a.type,t.evaluater.evaluateExpression(a.expression)}wa(t,i.position)}function tj(t,i){if(i.data&&i.data.estree&&t.evaluater)return t.evaluater.evaluateProgram(i.data.estree);wa(t,i.position)}function nj(t,i,l){const a=t.schema;let o=a;i.name==="svg"&&a.space==="html"&&(o=od,t.schema=o),t.ancestors.push(i);const f=i.name===null?t.Fragment:Qb(t,i.name,!0),u=oj(t,i),p=dd(t,i);return $b(t,u,f,i),fd(u,p),t.ancestors.pop(),t.schema=a,t.create(i,f,u,l)}function ij(t,i,l){const a={};return fd(a,dd(t,i)),t.create(i,t.Fragment,a,l)}function rj(t,i){return i.value}function $b(t,i,l,a){typeof l!="string"&&l!==t.Fragment&&t.passNode&&(i.node=a)}function fd(t,i){if(i.length>0){const l=i.length>1?i:i[0];l&&(t.children=l)}}function lj(t,i,l){return a;function a(o,f,u,p){const m=Array.isArray(u.children)?l:i;return p?m(f,u,p):m(f,u)}}function aj(t,i){return l;function l(a,o,f,u){const p=Array.isArray(f.children),h=ud(a);return i(o,f,u,p,{columnNumber:h?h.column-1:void 0,fileName:t,lineNumber:h?h.line:void 0},void 0)}}function sj(t,i){const l={};let a,o;for(o in i.properties)if(o!=="children"&&cd.call(i.properties,o)){const f=uj(t,o,i.properties[o]);if(f){const[u,p]=f;t.tableCellAlignToStyle&&u==="align"&&typeof p=="string"&&Zw.has(i.tagName)?a=p:l[u]=p}}if(a){const f=l.style||(l.style={});f[t.stylePropertyNameCase==="css"?"text-align":"textAlign"]=a}return l}function oj(t,i){const l={};for(const a of i.attributes)if(a.type==="mdxJsxExpressionAttribute")if(a.data&&a.data.estree&&t.evaluater){const f=a.data.estree.body[0];f.type;const u=f.expression;u.type;const p=u.properties[0];p.type,Object.assign(l,t.evaluater.evaluateExpression(p.argument))}else wa(t,i.position);else{const o=a.name;let f;if(a.value&&typeof a.value=="object")if(a.value.data&&a.value.data.estree&&t.evaluater){const p=a.value.data.estree.body[0];p.type,f=t.evaluater.evaluateExpression(p.expression)}else wa(t,i.position);else f=a.value===null?!0:a.value;l[o]=f}return l}function dd(t,i){const l=[];let a=-1;const o=t.passKeys?new Map:Xw;for(;++a<i.children.length;){const f=i.children[a];let u;if(t.passKeys){const h=f.type==="element"?f.tagName:f.type==="mdxJsxFlowElement"||f.type==="mdxJsxTextElement"?f.name:void 0;if(h){const m=o.get(h)||0;u=h+"-"+m,o.set(h,m+1)}}const p=Fb(t,f,u);p!==void 0&&l.push(p)}return l}function uj(t,i,l){const a=Lw(t.schema,i);if(!(l==null||typeof l=="number"&&Number.isNaN(l))){if(Array.isArray(l)&&(l=a.commaSeparated?kw(l):qw(l)),a.property==="style"){let o=typeof l=="object"?l:cj(t,String(l));return t.stylePropertyNameCase==="css"&&(o=fj(o)),["style",o]}return[t.elementAttributeNameCase==="react"&&a.space?_w[a.property]||a.property:a.attribute,l]}}function cj(t,i){try{return $w(i,{reactCompat:!0})}catch(l){if(t.ignoreInvalidStyle)return{};const a=l,o=new an("Cannot parse `style` attribute",{ancestors:t.ancestors,cause:a,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw o.file=t.filePath||void 0,o.url=Gb+"#cannot-parse-style-attribute",o}}function Qb(t,i,l){let a;if(!l)a={type:"Literal",value:i};else if(i.includes(".")){const o=i.split(".");let f=-1,u;for(;++f<o.length;){const p=gy(o[f])?{type:"Identifier",name:o[f]}:{type:"Literal",value:o[f]};u=u?{type:"MemberExpression",object:u,property:p,computed:!!(f&&p.type==="Literal"),optional:!1}:p}a=u}else a=gy(i)&&!/^[a-z]/.test(i)?{type:"Identifier",name:i}:{type:"Literal",value:i};if(a.type==="Literal"){const o=a.value;return cd.call(t.components,o)?t.components[o]:o}if(t.evaluater)return t.evaluater.evaluateExpression(a);wa(t)}function wa(t,i){const l=new an("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:i,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw l.file=t.filePath||void 0,l.url=Gb+"#cannot-handle-mdx-estrees-without-createevaluater",l}function fj(t){const i={};let l;for(l in t)cd.call(t,l)&&(i[dj(l)]=t[l]);return i}function dj(t){let i=t.replace(Kw,hj);return i.slice(0,3)==="ms-"&&(i="-"+i),i}function hj(t){return"-"+t.toLowerCase()}const mf={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"]},pj={};function hd(t,i){const l=pj,a=typeof l.includeImageAlt=="boolean"?l.includeImageAlt:!0,o=typeof l.includeHtml=="boolean"?l.includeHtml:!0;return Xb(t,a,o)}function Xb(t,i,l){if(mj(t)){if("value"in t)return t.type==="html"&&!l?"":t.value;if(i&&"alt"in t&&t.alt)return t.alt;if("children"in t)return Ey(t.children,i,l)}return Array.isArray(t)?Ey(t,i,l):""}function Ey(t,i,l){const a=[];let o=-1;for(;++o<t.length;)a[o]=Xb(t[o],i,l);return a.join("")}function mj(t){return!!(t&&typeof t=="object")}const Ny=document.createElement("i");function pd(t){const i="&"+t+";";Ny.innerHTML=i;const l=Ny.textContent;return l.charCodeAt(l.length-1)===59&&t!=="semi"||l===i?!1:l}function Cn(t,i,l,a){const o=t.length;let f=0,u;if(i<0?i=-i>o?0:o+i:i=i>o?o:i,l=l>0?l:0,a.length<1e4)u=Array.from(a),u.unshift(i,l),t.splice(...u);else for(l&&t.splice(i,l);f<a.length;)u=a.slice(f,f+1e4),u.unshift(i,0),t.splice(...u),f+=1e4,i+=1e4}function Bn(t,i){return t.length>0?(Cn(t,t.length,0,i),t):i}const Ay={}.hasOwnProperty;function Kb(t){const i={};let l=-1;for(;++l<t.length;)gj(i,t[l]);return i}function gj(t,i){let l;for(l in i){const o=(Ay.call(t,l)?t[l]:void 0)||(t[l]={}),f=i[l];let u;if(f)for(u in f){Ay.call(o,u)||(o[u]=[]);const p=f[u];yj(o[u],Array.isArray(p)?p:p?[p]:[])}}}function yj(t,i){let l=-1;const a=[];for(;++l<i.length;)(i[l].add==="after"?t:a).push(i[l]);Cn(t,0,0,a)}function Pb(t,i){const l=Number.parseInt(t,i);return l<9||l===11||l>13&&l<32||l>126&&l<160||l>55295&&l<57344||l>64975&&l<65008||(l&65535)===65535||(l&65535)===65534||l>1114111?"�":String.fromCodePoint(l)}function Yn(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const on=Xi(/[A-Za-z]/),ln=Xi(/[\dA-Za-z]/),bj=Xi(/[#-'*+\--9=?A-Z^-~]/);function ao(t){return t!==null&&(t<32||t===127)}const qf=Xi(/\d/),vj=Xi(/[\dA-Fa-f]/),xj=Xi(/[!-/:-@[-`{-~]/);function Be(t){return t!==null&&t<-2}function Nt(t){return t!==null&&(t<0||t===32)}function et(t){return t===-2||t===-1||t===32}const po=Xi(new RegExp("\\p{P}|\\p{S}","u")),yr=Xi(/\s/);function Xi(t){return i;function i(l){return l!==null&&l>-1&&t.test(String.fromCharCode(l))}}function ml(t){const i=[];let l=-1,a=0,o=0;for(;++l<t.length;){const f=t.charCodeAt(l);let u="";if(f===37&&ln(t.charCodeAt(l+1))&&ln(t.charCodeAt(l+2)))o=2;else if(f<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(f))||(u=String.fromCharCode(f));else if(f>55295&&f<57344){const p=t.charCodeAt(l+1);f<56320&&p>56319&&p<57344?(u=String.fromCharCode(f,p),o=1):u="�"}else u=String.fromCharCode(f);u&&(i.push(t.slice(a,l),encodeURIComponent(u)),a=l+o+1,u=""),o&&(l+=o,o=0)}return i.join("")+t.slice(a)}function at(t,i,l,a){const o=a?a-1:Number.POSITIVE_INFINITY;let f=0;return u;function u(h){return et(h)?(t.enter(l),p(h)):i(h)}function p(h){return et(h)&&f++<o?(t.consume(h),p):(t.exit(l),i(h))}}const Sj={tokenize:wj};function wj(t){const i=t.attempt(this.parser.constructs.contentInitial,a,o);let l;return i;function a(p){if(p===null){t.consume(p);return}return t.enter("lineEnding"),t.consume(p),t.exit("lineEnding"),at(t,i,"linePrefix")}function o(p){return t.enter("paragraph"),f(p)}function f(p){const h=t.enter("chunkText",{contentType:"text",previous:l});return l&&(l.next=h),l=h,u(p)}function u(p){if(p===null){t.exit("chunkText"),t.exit("paragraph"),t.consume(p);return}return Be(p)?(t.consume(p),t.exit("chunkText"),f):(t.consume(p),u)}}const jj={tokenize:kj},Ty={tokenize:Cj};function kj(t){const i=this,l=[];let a=0,o,f,u;return p;function p(M){if(a<l.length){const G=l[a];return i.containerState=G[1],t.attempt(G[0].continuation,h,m)(M)}return m(M)}function h(M){if(a++,i.containerState._closeFlow){i.containerState._closeFlow=void 0,o&&T();const G=i.events.length;let ae=G,D;for(;ae--;)if(i.events[ae][0]==="exit"&&i.events[ae][1].type==="chunkFlow"){D=i.events[ae][1].end;break}N(a);let H=G;for(;H<i.events.length;)i.events[H][1].end={...D},H++;return Cn(i.events,ae+1,0,i.events.slice(G)),i.events.length=H,m(M)}return p(M)}function m(M){if(a===l.length){if(!o)return x(M);if(o.currentConstruct&&o.currentConstruct.concrete)return j(M);i.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return i.containerState={},t.check(Ty,y,b)(M)}function y(M){return o&&T(),N(a),x(M)}function b(M){return i.parser.lazy[i.now().line]=a!==l.length,u=i.now().offset,j(M)}function x(M){return i.containerState={},t.attempt(Ty,v,j)(M)}function v(M){return a++,l.push([i.currentConstruct,i.containerState]),x(M)}function j(M){if(M===null){o&&T(),N(0),t.consume(M);return}return o=o||i.parser.flow(i.now()),t.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:f}),z(M)}function z(M){if(M===null){A(t.exit("chunkFlow"),!0),N(0),t.consume(M);return}return Be(M)?(t.consume(M),A(t.exit("chunkFlow")),a=0,i.interrupt=void 0,p):(t.consume(M),z)}function A(M,G){const ae=i.sliceStream(M);if(G&&ae.push(null),M.previous=f,f&&(f.next=M),f=M,o.defineSkip(M.start),o.write(ae),i.parser.lazy[M.start.line]){let D=o.events.length;for(;D--;)if(o.events[D][1].start.offset<u&&(!o.events[D][1].end||o.events[D][1].end.offset>u))return;const H=i.events.length;let W=H,q,C;for(;W--;)if(i.events[W][0]==="exit"&&i.events[W][1].type==="chunkFlow"){if(q){C=i.events[W][1].end;break}q=!0}for(N(a),D=H;D<i.events.length;)i.events[D][1].end={...C},D++;Cn(i.events,W+1,0,i.events.slice(H)),i.events.length=D}}function N(M){let G=l.length;for(;G-- >M;){const ae=l[G];i.containerState=ae[1],ae[0].exit.call(i,t)}l.length=M}function T(){o.write([null]),f=void 0,o=void 0,i.containerState._closeFlow=void 0}}function Cj(t,i,l){return at(t,t.attempt(this.parser.constructs.document,i,l),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function dl(t){if(t===null||Nt(t)||yr(t))return 1;if(po(t))return 2}function mo(t,i,l){const a=[];let o=-1;for(;++o<t.length;){const f=t[o].resolveAll;f&&!a.includes(f)&&(i=f(i,l),a.push(f))}return i}const Hf={name:"attention",resolveAll:Ej,tokenize:Nj};function Ej(t,i){let l=-1,a,o,f,u,p,h,m,y;for(;++l<t.length;)if(t[l][0]==="enter"&&t[l][1].type==="attentionSequence"&&t[l][1]._close){for(a=l;a--;)if(t[a][0]==="exit"&&t[a][1].type==="attentionSequence"&&t[a][1]._open&&i.sliceSerialize(t[a][1]).charCodeAt(0)===i.sliceSerialize(t[l][1]).charCodeAt(0)){if((t[a][1]._close||t[l][1]._open)&&(t[l][1].end.offset-t[l][1].start.offset)%3&&!((t[a][1].end.offset-t[a][1].start.offset+t[l][1].end.offset-t[l][1].start.offset)%3))continue;h=t[a][1].end.offset-t[a][1].start.offset>1&&t[l][1].end.offset-t[l][1].start.offset>1?2:1;const b={...t[a][1].end},x={...t[l][1].start};Ry(b,-h),Ry(x,h),u={type:h>1?"strongSequence":"emphasisSequence",start:b,end:{...t[a][1].end}},p={type:h>1?"strongSequence":"emphasisSequence",start:{...t[l][1].start},end:x},f={type:h>1?"strongText":"emphasisText",start:{...t[a][1].end},end:{...t[l][1].start}},o={type:h>1?"strong":"emphasis",start:{...u.start},end:{...p.end}},t[a][1].end={...u.start},t[l][1].start={...p.end},m=[],t[a][1].end.offset-t[a][1].start.offset&&(m=Bn(m,[["enter",t[a][1],i],["exit",t[a][1],i]])),m=Bn(m,[["enter",o,i],["enter",u,i],["exit",u,i],["enter",f,i]]),m=Bn(m,mo(i.parser.constructs.insideSpan.null,t.slice(a+1,l),i)),m=Bn(m,[["exit",f,i],["enter",p,i],["exit",p,i],["exit",o,i]]),t[l][1].end.offset-t[l][1].start.offset?(y=2,m=Bn(m,[["enter",t[l][1],i],["exit",t[l][1],i]])):y=0,Cn(t,a-1,l-a+3,m),l=a+m.length-y-2;break}}for(l=-1;++l<t.length;)t[l][1].type==="attentionSequence"&&(t[l][1].type="data");return t}function Nj(t,i){const l=this.parser.constructs.attentionMarkers.null,a=this.previous,o=dl(a);let f;return u;function u(h){return f=h,t.enter("attentionSequence"),p(h)}function p(h){if(h===f)return t.consume(h),p;const m=t.exit("attentionSequence"),y=dl(h),b=!y||y===2&&o||l.includes(h),x=!o||o===2&&y||l.includes(a);return m._open=!!(f===42?b:b&&(o||!x)),m._close=!!(f===42?x:x&&(y||!b)),i(h)}}function Ry(t,i){t.column+=i,t.offset+=i,t._bufferIndex+=i}const Aj={name:"autolink",tokenize:Tj};function Tj(t,i,l){let a=0;return o;function o(v){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(v),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),f}function f(v){return on(v)?(t.consume(v),u):v===64?l(v):m(v)}function u(v){return v===43||v===45||v===46||ln(v)?(a=1,p(v)):m(v)}function p(v){return v===58?(t.consume(v),a=0,h):(v===43||v===45||v===46||ln(v))&&a++<32?(t.consume(v),p):(a=0,m(v))}function h(v){return v===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(v),t.exit("autolinkMarker"),t.exit("autolink"),i):v===null||v===32||v===60||ao(v)?l(v):(t.consume(v),h)}function m(v){return v===64?(t.consume(v),y):bj(v)?(t.consume(v),m):l(v)}function y(v){return ln(v)?b(v):l(v)}function b(v){return v===46?(t.consume(v),a=0,y):v===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(v),t.exit("autolinkMarker"),t.exit("autolink"),i):x(v)}function x(v){if((v===45||ln(v))&&a++<63){const j=v===45?x:b;return t.consume(v),j}return l(v)}}const Na={partial:!0,tokenize:Rj};function Rj(t,i,l){return a;function a(f){return et(f)?at(t,o,"linePrefix")(f):o(f)}function o(f){return f===null||Be(f)?i(f):l(f)}}const Zb={continuation:{tokenize:Dj},exit:_j,name:"blockQuote",tokenize:zj};function zj(t,i,l){const a=this;return o;function o(u){if(u===62){const p=a.containerState;return p.open||(t.enter("blockQuote",{_container:!0}),p.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(u),t.exit("blockQuoteMarker"),f}return l(u)}function f(u){return et(u)?(t.enter("blockQuotePrefixWhitespace"),t.consume(u),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),i):(t.exit("blockQuotePrefix"),i(u))}}function Dj(t,i,l){const a=this;return o;function o(u){return et(u)?at(t,f,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):f(u)}function f(u){return t.attempt(Zb,i,l)(u)}}function _j(t){t.exit("blockQuote")}const Jb={name:"characterEscape",tokenize:Mj};function Mj(t,i,l){return a;function a(f){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(f),t.exit("escapeMarker"),o}function o(f){return xj(f)?(t.enter("characterEscapeValue"),t.consume(f),t.exit("characterEscapeValue"),t.exit("characterEscape"),i):l(f)}}const Wb={name:"characterReference",tokenize:Oj};function Oj(t,i,l){const a=this;let o=0,f,u;return p;function p(b){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(b),t.exit("characterReferenceMarker"),h}function h(b){return b===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(b),t.exit("characterReferenceMarkerNumeric"),m):(t.enter("characterReferenceValue"),f=31,u=ln,y(b))}function m(b){return b===88||b===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(b),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),f=6,u=vj,y):(t.enter("characterReferenceValue"),f=7,u=qf,y(b))}function y(b){if(b===59&&o){const x=t.exit("characterReferenceValue");return u===ln&&!pd(a.sliceSerialize(x))?l(b):(t.enter("characterReferenceMarker"),t.consume(b),t.exit("characterReferenceMarker"),t.exit("characterReference"),i)}return u(b)&&o++<f?(t.consume(b),y):l(b)}}const zy={partial:!0,tokenize:Bj},Dy={concrete:!0,name:"codeFenced",tokenize:Lj};function Lj(t,i,l){const a=this,o={partial:!0,tokenize:ae};let f=0,u=0,p;return h;function h(D){return m(D)}function m(D){const H=a.events[a.events.length-1];return f=H&&H[1].type==="linePrefix"?H[2].sliceSerialize(H[1],!0).length:0,p=D,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),y(D)}function y(D){return D===p?(u++,t.consume(D),y):u<3?l(D):(t.exit("codeFencedFenceSequence"),et(D)?at(t,b,"whitespace")(D):b(D))}function b(D){return D===null||Be(D)?(t.exit("codeFencedFence"),a.interrupt?i(D):t.check(zy,z,G)(D)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),x(D))}function x(D){return D===null||Be(D)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),b(D)):et(D)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),at(t,v,"whitespace")(D)):D===96&&D===p?l(D):(t.consume(D),x)}function v(D){return D===null||Be(D)?b(D):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),j(D))}function j(D){return D===null||Be(D)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),b(D)):D===96&&D===p?l(D):(t.consume(D),j)}function z(D){return t.attempt(o,G,A)(D)}function A(D){return t.enter("lineEnding"),t.consume(D),t.exit("lineEnding"),N}function N(D){return f>0&&et(D)?at(t,T,"linePrefix",f+1)(D):T(D)}function T(D){return D===null||Be(D)?t.check(zy,z,G)(D):(t.enter("codeFlowValue"),M(D))}function M(D){return D===null||Be(D)?(t.exit("codeFlowValue"),T(D)):(t.consume(D),M)}function G(D){return t.exit("codeFenced"),i(D)}function ae(D,H,W){let q=0;return C;function C(K){return D.enter("lineEnding"),D.consume(K),D.exit("lineEnding"),L}function L(K){return D.enter("codeFencedFence"),et(K)?at(D,B,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(K):B(K)}function B(K){return K===p?(D.enter("codeFencedFenceSequence"),Q(K)):W(K)}function Q(K){return K===p?(q++,D.consume(K),Q):q>=u?(D.exit("codeFencedFenceSequence"),et(K)?at(D,J,"whitespace")(K):J(K)):W(K)}function J(K){return K===null||Be(K)?(D.exit("codeFencedFence"),H(K)):W(K)}}}function Bj(t,i,l){const a=this;return o;function o(u){return u===null?l(u):(t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),f)}function f(u){return a.parser.lazy[a.now().line]?l(u):i(u)}}const gf={name:"codeIndented",tokenize:Ij},Uj={partial:!0,tokenize:qj};function Ij(t,i,l){const a=this;return o;function o(m){return t.enter("codeIndented"),at(t,f,"linePrefix",5)(m)}function f(m){const y=a.events[a.events.length-1];return y&&y[1].type==="linePrefix"&&y[2].sliceSerialize(y[1],!0).length>=4?u(m):l(m)}function u(m){return m===null?h(m):Be(m)?t.attempt(Uj,u,h)(m):(t.enter("codeFlowValue"),p(m))}function p(m){return m===null||Be(m)?(t.exit("codeFlowValue"),u(m)):(t.consume(m),p)}function h(m){return t.exit("codeIndented"),i(m)}}function qj(t,i,l){const a=this;return o;function o(u){return a.parser.lazy[a.now().line]?l(u):Be(u)?(t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),o):at(t,f,"linePrefix",5)(u)}function f(u){const p=a.events[a.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?i(u):Be(u)?o(u):l(u)}}const Hj={name:"codeText",previous:Yj,resolve:Vj,tokenize:Gj};function Vj(t){let i=t.length-4,l=3,a,o;if((t[l][1].type==="lineEnding"||t[l][1].type==="space")&&(t[i][1].type==="lineEnding"||t[i][1].type==="space")){for(a=l;++a<i;)if(t[a][1].type==="codeTextData"){t[l][1].type="codeTextPadding",t[i][1].type="codeTextPadding",l+=2,i-=2;break}}for(a=l-1,i++;++a<=i;)o===void 0?a!==i&&t[a][1].type!=="lineEnding"&&(o=a):(a===i||t[a][1].type==="lineEnding")&&(t[o][1].type="codeTextData",a!==o+2&&(t[o][1].end=t[a-1][1].end,t.splice(o+2,a-o-2),i-=a-o-2,a=o+2),o=void 0);return t}function Yj(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"}function Gj(t,i,l){let a=0,o,f;return u;function u(b){return t.enter("codeText"),t.enter("codeTextSequence"),p(b)}function p(b){return b===96?(t.consume(b),a++,p):(t.exit("codeTextSequence"),h(b))}function h(b){return b===null?l(b):b===32?(t.enter("space"),t.consume(b),t.exit("space"),h):b===96?(f=t.enter("codeTextSequence"),o=0,y(b)):Be(b)?(t.enter("lineEnding"),t.consume(b),t.exit("lineEnding"),h):(t.enter("codeTextData"),m(b))}function m(b){return b===null||b===32||b===96||Be(b)?(t.exit("codeTextData"),h(b)):(t.consume(b),m)}function y(b){return b===96?(t.consume(b),o++,y):o===a?(t.exit("codeTextSequence"),t.exit("codeText"),i(b)):(f.type="codeTextData",m(b))}}class Fj{constructor(i){this.left=i?[...i]:[],this.right=[]}get(i){if(i<0||i>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+i+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return i<this.left.length?this.left[i]:this.right[this.right.length-i+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(i,l){const a=l??Number.POSITIVE_INFINITY;return a<this.left.length?this.left.slice(i,a):i>this.left.length?this.right.slice(this.right.length-a+this.left.length,this.right.length-i+this.left.length).reverse():this.left.slice(i).concat(this.right.slice(this.right.length-a+this.left.length).reverse())}splice(i,l,a){const o=l||0;this.setCursor(Math.trunc(i));const f=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return a&&ha(this.left,a),f.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(i){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(i)}pushMany(i){this.setCursor(Number.POSITIVE_INFINITY),ha(this.left,i)}unshift(i){this.setCursor(0),this.right.push(i)}unshiftMany(i){this.setCursor(0),ha(this.right,i.reverse())}setCursor(i){if(!(i===this.left.length||i>this.left.length&&this.right.length===0||i<0&&this.left.length===0))if(i<this.left.length){const l=this.left.splice(i,Number.POSITIVE_INFINITY);ha(this.right,l.reverse())}else{const l=this.right.splice(this.left.length+this.right.length-i,Number.POSITIVE_INFINITY);ha(this.left,l.reverse())}}}function ha(t,i){let l=0;if(i.length<1e4)t.push(...i);else for(;l<i.length;)t.push(...i.slice(l,l+1e4)),l+=1e4}function ev(t){const i={};let l=-1,a,o,f,u,p,h,m;const y=new Fj(t);for(;++l<y.length;){for(;l in i;)l=i[l];if(a=y.get(l),l&&a[1].type==="chunkFlow"&&y.get(l-1)[1].type==="listItemPrefix"&&(h=a[1]._tokenizer.events,f=0,f<h.length&&h[f][1].type==="lineEndingBlank"&&(f+=2),f<h.length&&h[f][1].type==="content"))for(;++f<h.length&&h[f][1].type!=="content";)h[f][1].type==="chunkText"&&(h[f][1]._isInFirstContentOfListItem=!0,f++);if(a[0]==="enter")a[1].contentType&&(Object.assign(i,$j(y,l)),l=i[l],m=!0);else if(a[1]._container){for(f=l,o=void 0;f--;)if(u=y.get(f),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(o&&(y.get(o)[1].type="lineEndingBlank"),u[1].type="lineEnding",o=f);else if(!(u[1].type==="linePrefix"||u[1].type==="listItemIndent"))break;o&&(a[1].end={...y.get(o)[1].start},p=y.slice(o,l),p.unshift(a),y.splice(o,l-o+1,p))}}return Cn(t,0,Number.POSITIVE_INFINITY,y.slice(0)),!m}function $j(t,i){const l=t.get(i)[1],a=t.get(i)[2];let o=i-1;const f=[];let u=l._tokenizer;u||(u=a.parser[l.contentType](l.start),l._contentTypeTextTrailing&&(u._contentTypeTextTrailing=!0));const p=u.events,h=[],m={};let y,b,x=-1,v=l,j=0,z=0;const A=[z];for(;v;){for(;t.get(++o)[1]!==v;);f.push(o),v._tokenizer||(y=a.sliceStream(v),v.next||y.push(null),b&&u.defineSkip(v.start),v._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(y),v._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),b=v,v=v.next}for(v=l;++x<p.length;)p[x][0]==="exit"&&p[x-1][0]==="enter"&&p[x][1].type===p[x-1][1].type&&p[x][1].start.line!==p[x][1].end.line&&(z=x+1,A.push(z),v._tokenizer=void 0,v.previous=void 0,v=v.next);for(u.events=[],v?(v._tokenizer=void 0,v.previous=void 0):A.pop(),x=A.length;x--;){const N=p.slice(A[x],A[x+1]),T=f.pop();h.push([T,T+N.length-1]),t.splice(T,2,N)}for(h.reverse(),x=-1;++x<h.length;)m[j+h[x][0]]=j+h[x][1],j+=h[x][1]-h[x][0]-1;return m}const Qj={resolve:Kj,tokenize:Pj},Xj={partial:!0,tokenize:Zj};function Kj(t){return ev(t),t}function Pj(t,i){let l;return a;function a(p){return t.enter("content"),l=t.enter("chunkContent",{contentType:"content"}),o(p)}function o(p){return p===null?f(p):Be(p)?t.check(Xj,u,f)(p):(t.consume(p),o)}function f(p){return t.exit("chunkContent"),t.exit("content"),i(p)}function u(p){return t.consume(p),t.exit("chunkContent"),l.next=t.enter("chunkContent",{contentType:"content",previous:l}),l=l.next,o}}function Zj(t,i,l){const a=this;return o;function o(u){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),at(t,f,"linePrefix")}function f(u){if(u===null||Be(u))return l(u);const p=a.events[a.events.length-1];return!a.parser.constructs.disable.null.includes("codeIndented")&&p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?i(u):t.interrupt(a.parser.constructs.flow,l,i)(u)}}function tv(t,i,l,a,o,f,u,p,h){const m=h||Number.POSITIVE_INFINITY;let y=0;return b;function b(N){return N===60?(t.enter(a),t.enter(o),t.enter(f),t.consume(N),t.exit(f),x):N===null||N===32||N===41||ao(N)?l(N):(t.enter(a),t.enter(u),t.enter(p),t.enter("chunkString",{contentType:"string"}),z(N))}function x(N){return N===62?(t.enter(f),t.consume(N),t.exit(f),t.exit(o),t.exit(a),i):(t.enter(p),t.enter("chunkString",{contentType:"string"}),v(N))}function v(N){return N===62?(t.exit("chunkString"),t.exit(p),x(N)):N===null||N===60||Be(N)?l(N):(t.consume(N),N===92?j:v)}function j(N){return N===60||N===62||N===92?(t.consume(N),v):v(N)}function z(N){return!y&&(N===null||N===41||Nt(N))?(t.exit("chunkString"),t.exit(p),t.exit(u),t.exit(a),i(N)):y<m&&N===40?(t.consume(N),y++,z):N===41?(t.consume(N),y--,z):N===null||N===32||N===40||ao(N)?l(N):(t.consume(N),N===92?A:z)}function A(N){return N===40||N===41||N===92?(t.consume(N),z):z(N)}}function nv(t,i,l,a,o,f){const u=this;let p=0,h;return m;function m(v){return t.enter(a),t.enter(o),t.consume(v),t.exit(o),t.enter(f),y}function y(v){return p>999||v===null||v===91||v===93&&!h||v===94&&!p&&"_hiddenFootnoteSupport"in u.parser.constructs?l(v):v===93?(t.exit(f),t.enter(o),t.consume(v),t.exit(o),t.exit(a),i):Be(v)?(t.enter("lineEnding"),t.consume(v),t.exit("lineEnding"),y):(t.enter("chunkString",{contentType:"string"}),b(v))}function b(v){return v===null||v===91||v===93||Be(v)||p++>999?(t.exit("chunkString"),y(v)):(t.consume(v),h||(h=!et(v)),v===92?x:b)}function x(v){return v===91||v===92||v===93?(t.consume(v),p++,b):b(v)}}function iv(t,i,l,a,o,f){let u;return p;function p(x){return x===34||x===39||x===40?(t.enter(a),t.enter(o),t.consume(x),t.exit(o),u=x===40?41:x,h):l(x)}function h(x){return x===u?(t.enter(o),t.consume(x),t.exit(o),t.exit(a),i):(t.enter(f),m(x))}function m(x){return x===u?(t.exit(f),h(u)):x===null?l(x):Be(x)?(t.enter("lineEnding"),t.consume(x),t.exit("lineEnding"),at(t,m,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),y(x))}function y(x){return x===u||x===null||Be(x)?(t.exit("chunkString"),m(x)):(t.consume(x),x===92?b:y)}function b(x){return x===u||x===92?(t.consume(x),y):y(x)}}function ba(t,i){let l;return a;function a(o){return Be(o)?(t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),l=!0,a):et(o)?at(t,a,l?"linePrefix":"lineSuffix")(o):i(o)}}const Jj={name:"definition",tokenize:ek},Wj={partial:!0,tokenize:tk};function ek(t,i,l){const a=this;let o;return f;function f(v){return t.enter("definition"),u(v)}function u(v){return nv.call(a,t,p,l,"definitionLabel","definitionLabelMarker","definitionLabelString")(v)}function p(v){return o=Yn(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)),v===58?(t.enter("definitionMarker"),t.consume(v),t.exit("definitionMarker"),h):l(v)}function h(v){return Nt(v)?ba(t,m)(v):m(v)}function m(v){return tv(t,y,l,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(v)}function y(v){return t.attempt(Wj,b,b)(v)}function b(v){return et(v)?at(t,x,"whitespace")(v):x(v)}function x(v){return v===null||Be(v)?(t.exit("definition"),a.parser.defined.push(o),i(v)):l(v)}}function tk(t,i,l){return a;function a(p){return Nt(p)?ba(t,o)(p):l(p)}function o(p){return iv(t,f,l,"definitionTitle","definitionTitleMarker","definitionTitleString")(p)}function f(p){return et(p)?at(t,u,"whitespace")(p):u(p)}function u(p){return p===null||Be(p)?i(p):l(p)}}const nk={name:"hardBreakEscape",tokenize:ik};function ik(t,i,l){return a;function a(f){return t.enter("hardBreakEscape"),t.consume(f),o}function o(f){return Be(f)?(t.exit("hardBreakEscape"),i(f)):l(f)}}const rk={name:"headingAtx",resolve:lk,tokenize:ak};function lk(t,i){let l=t.length-2,a=3,o,f;return t[a][1].type==="whitespace"&&(a+=2),l-2>a&&t[l][1].type==="whitespace"&&(l-=2),t[l][1].type==="atxHeadingSequence"&&(a===l-1||l-4>a&&t[l-2][1].type==="whitespace")&&(l-=a+1===l?2:4),l>a&&(o={type:"atxHeadingText",start:t[a][1].start,end:t[l][1].end},f={type:"chunkText",start:t[a][1].start,end:t[l][1].end,contentType:"text"},Cn(t,a,l-a+1,[["enter",o,i],["enter",f,i],["exit",f,i],["exit",o,i]])),t}function ak(t,i,l){let a=0;return o;function o(y){return t.enter("atxHeading"),f(y)}function f(y){return t.enter("atxHeadingSequence"),u(y)}function u(y){return y===35&&a++<6?(t.consume(y),u):y===null||Nt(y)?(t.exit("atxHeadingSequence"),p(y)):l(y)}function p(y){return y===35?(t.enter("atxHeadingSequence"),h(y)):y===null||Be(y)?(t.exit("atxHeading"),i(y)):et(y)?at(t,p,"whitespace")(y):(t.enter("atxHeadingText"),m(y))}function h(y){return y===35?(t.consume(y),h):(t.exit("atxHeadingSequence"),p(y))}function m(y){return y===null||y===35||Nt(y)?(t.exit("atxHeadingText"),p(y)):(t.consume(y),m)}}const sk=["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"],_y=["pre","script","style","textarea"],ok={concrete:!0,name:"htmlFlow",resolveTo:fk,tokenize:dk},uk={partial:!0,tokenize:pk},ck={partial:!0,tokenize:hk};function fk(t){let i=t.length;for(;i--&&!(t[i][0]==="enter"&&t[i][1].type==="htmlFlow"););return i>1&&t[i-2][1].type==="linePrefix"&&(t[i][1].start=t[i-2][1].start,t[i+1][1].start=t[i-2][1].start,t.splice(i-2,2)),t}function dk(t,i,l){const a=this;let o,f,u,p,h;return m;function m(R){return y(R)}function y(R){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(R),b}function b(R){return R===33?(t.consume(R),x):R===47?(t.consume(R),f=!0,z):R===63?(t.consume(R),o=3,a.interrupt?i:k):on(R)?(t.consume(R),u=String.fromCharCode(R),A):l(R)}function x(R){return R===45?(t.consume(R),o=2,v):R===91?(t.consume(R),o=5,p=0,j):on(R)?(t.consume(R),o=4,a.interrupt?i:k):l(R)}function v(R){return R===45?(t.consume(R),a.interrupt?i:k):l(R)}function j(R){const ee="CDATA[";return R===ee.charCodeAt(p++)?(t.consume(R),p===ee.length?a.interrupt?i:B:j):l(R)}function z(R){return on(R)?(t.consume(R),u=String.fromCharCode(R),A):l(R)}function A(R){if(R===null||R===47||R===62||Nt(R)){const ee=R===47,ve=u.toLowerCase();return!ee&&!f&&_y.includes(ve)?(o=1,a.interrupt?i(R):B(R)):sk.includes(u.toLowerCase())?(o=6,ee?(t.consume(R),N):a.interrupt?i(R):B(R)):(o=7,a.interrupt&&!a.parser.lazy[a.now().line]?l(R):f?T(R):M(R))}return R===45||ln(R)?(t.consume(R),u+=String.fromCharCode(R),A):l(R)}function N(R){return R===62?(t.consume(R),a.interrupt?i:B):l(R)}function T(R){return et(R)?(t.consume(R),T):C(R)}function M(R){return R===47?(t.consume(R),C):R===58||R===95||on(R)?(t.consume(R),G):et(R)?(t.consume(R),M):C(R)}function G(R){return R===45||R===46||R===58||R===95||ln(R)?(t.consume(R),G):ae(R)}function ae(R){return R===61?(t.consume(R),D):et(R)?(t.consume(R),ae):M(R)}function D(R){return R===null||R===60||R===61||R===62||R===96?l(R):R===34||R===39?(t.consume(R),h=R,H):et(R)?(t.consume(R),D):W(R)}function H(R){return R===h?(t.consume(R),h=null,q):R===null||Be(R)?l(R):(t.consume(R),H)}function W(R){return R===null||R===34||R===39||R===47||R===60||R===61||R===62||R===96||Nt(R)?ae(R):(t.consume(R),W)}function q(R){return R===47||R===62||et(R)?M(R):l(R)}function C(R){return R===62?(t.consume(R),L):l(R)}function L(R){return R===null||Be(R)?B(R):et(R)?(t.consume(R),L):l(R)}function B(R){return R===45&&o===2?(t.consume(R),I):R===60&&o===1?(t.consume(R),Y):R===62&&o===4?(t.consume(R),O):R===63&&o===3?(t.consume(R),k):R===93&&o===5?(t.consume(R),pe):Be(R)&&(o===6||o===7)?(t.exit("htmlFlowData"),t.check(uk,te,Q)(R)):R===null||Be(R)?(t.exit("htmlFlowData"),Q(R)):(t.consume(R),B)}function Q(R){return t.check(ck,J,te)(R)}function J(R){return t.enter("lineEnding"),t.consume(R),t.exit("lineEnding"),K}function K(R){return R===null||Be(R)?Q(R):(t.enter("htmlFlowData"),B(R))}function I(R){return R===45?(t.consume(R),k):B(R)}function Y(R){return R===47?(t.consume(R),u="",X):B(R)}function X(R){if(R===62){const ee=u.toLowerCase();return _y.includes(ee)?(t.consume(R),O):B(R)}return on(R)&&u.length<8?(t.consume(R),u+=String.fromCharCode(R),X):B(R)}function pe(R){return R===93?(t.consume(R),k):B(R)}function k(R){return R===62?(t.consume(R),O):R===45&&o===2?(t.consume(R),k):B(R)}function O(R){return R===null||Be(R)?(t.exit("htmlFlowData"),te(R)):(t.consume(R),O)}function te(R){return t.exit("htmlFlow"),i(R)}}function hk(t,i,l){const a=this;return o;function o(u){return Be(u)?(t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),f):l(u)}function f(u){return a.parser.lazy[a.now().line]?l(u):i(u)}}function pk(t,i,l){return a;function a(o){return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),t.attempt(Na,i,l)}}const mk={name:"htmlText",tokenize:gk};function gk(t,i,l){const a=this;let o,f,u;return p;function p(k){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(k),h}function h(k){return k===33?(t.consume(k),m):k===47?(t.consume(k),ae):k===63?(t.consume(k),M):on(k)?(t.consume(k),W):l(k)}function m(k){return k===45?(t.consume(k),y):k===91?(t.consume(k),f=0,j):on(k)?(t.consume(k),T):l(k)}function y(k){return k===45?(t.consume(k),v):l(k)}function b(k){return k===null?l(k):k===45?(t.consume(k),x):Be(k)?(u=b,Y(k)):(t.consume(k),b)}function x(k){return k===45?(t.consume(k),v):b(k)}function v(k){return k===62?I(k):k===45?x(k):b(k)}function j(k){const O="CDATA[";return k===O.charCodeAt(f++)?(t.consume(k),f===O.length?z:j):l(k)}function z(k){return k===null?l(k):k===93?(t.consume(k),A):Be(k)?(u=z,Y(k)):(t.consume(k),z)}function A(k){return k===93?(t.consume(k),N):z(k)}function N(k){return k===62?I(k):k===93?(t.consume(k),N):z(k)}function T(k){return k===null||k===62?I(k):Be(k)?(u=T,Y(k)):(t.consume(k),T)}function M(k){return k===null?l(k):k===63?(t.consume(k),G):Be(k)?(u=M,Y(k)):(t.consume(k),M)}function G(k){return k===62?I(k):M(k)}function ae(k){return on(k)?(t.consume(k),D):l(k)}function D(k){return k===45||ln(k)?(t.consume(k),D):H(k)}function H(k){return Be(k)?(u=H,Y(k)):et(k)?(t.consume(k),H):I(k)}function W(k){return k===45||ln(k)?(t.consume(k),W):k===47||k===62||Nt(k)?q(k):l(k)}function q(k){return k===47?(t.consume(k),I):k===58||k===95||on(k)?(t.consume(k),C):Be(k)?(u=q,Y(k)):et(k)?(t.consume(k),q):I(k)}function C(k){return k===45||k===46||k===58||k===95||ln(k)?(t.consume(k),C):L(k)}function L(k){return k===61?(t.consume(k),B):Be(k)?(u=L,Y(k)):et(k)?(t.consume(k),L):q(k)}function B(k){return k===null||k===60||k===61||k===62||k===96?l(k):k===34||k===39?(t.consume(k),o=k,Q):Be(k)?(u=B,Y(k)):et(k)?(t.consume(k),B):(t.consume(k),J)}function Q(k){return k===o?(t.consume(k),o=void 0,K):k===null?l(k):Be(k)?(u=Q,Y(k)):(t.consume(k),Q)}function J(k){return k===null||k===34||k===39||k===60||k===61||k===96?l(k):k===47||k===62||Nt(k)?q(k):(t.consume(k),J)}function K(k){return k===47||k===62||Nt(k)?q(k):l(k)}function I(k){return k===62?(t.consume(k),t.exit("htmlTextData"),t.exit("htmlText"),i):l(k)}function Y(k){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(k),t.exit("lineEnding"),X}function X(k){return et(k)?at(t,pe,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):pe(k)}function pe(k){return t.enter("htmlTextData"),u(k)}}const md={name:"labelEnd",resolveAll:xk,resolveTo:Sk,tokenize:wk},yk={tokenize:jk},bk={tokenize:kk},vk={tokenize:Ck};function xk(t){let i=-1;const l=[];for(;++i<t.length;){const a=t[i][1];if(l.push(t[i]),a.type==="labelImage"||a.type==="labelLink"||a.type==="labelEnd"){const o=a.type==="labelImage"?4:2;a.type="data",i+=o}}return t.length!==l.length&&Cn(t,0,t.length,l),t}function Sk(t,i){let l=t.length,a=0,o,f,u,p;for(;l--;)if(o=t[l][1],f){if(o.type==="link"||o.type==="labelLink"&&o._inactive)break;t[l][0]==="enter"&&o.type==="labelLink"&&(o._inactive=!0)}else if(u){if(t[l][0]==="enter"&&(o.type==="labelImage"||o.type==="labelLink")&&!o._balanced&&(f=l,o.type!=="labelLink")){a=2;break}}else o.type==="labelEnd"&&(u=l);const h={type:t[f][1].type==="labelLink"?"link":"image",start:{...t[f][1].start},end:{...t[t.length-1][1].end}},m={type:"label",start:{...t[f][1].start},end:{...t[u][1].end}},y={type:"labelText",start:{...t[f+a+2][1].end},end:{...t[u-2][1].start}};return p=[["enter",h,i],["enter",m,i]],p=Bn(p,t.slice(f+1,f+a+3)),p=Bn(p,[["enter",y,i]]),p=Bn(p,mo(i.parser.constructs.insideSpan.null,t.slice(f+a+4,u-3),i)),p=Bn(p,[["exit",y,i],t[u-2],t[u-1],["exit",m,i]]),p=Bn(p,t.slice(u+1)),p=Bn(p,[["exit",h,i]]),Cn(t,f,t.length,p),t}function wk(t,i,l){const a=this;let o=a.events.length,f,u;for(;o--;)if((a.events[o][1].type==="labelImage"||a.events[o][1].type==="labelLink")&&!a.events[o][1]._balanced){f=a.events[o][1];break}return p;function p(x){return f?f._inactive?b(x):(u=a.parser.defined.includes(Yn(a.sliceSerialize({start:f.end,end:a.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(x),t.exit("labelMarker"),t.exit("labelEnd"),h):l(x)}function h(x){return x===40?t.attempt(yk,y,u?y:b)(x):x===91?t.attempt(bk,y,u?m:b)(x):u?y(x):b(x)}function m(x){return t.attempt(vk,y,b)(x)}function y(x){return i(x)}function b(x){return f._balanced=!0,l(x)}}function jk(t,i,l){return a;function a(b){return t.enter("resource"),t.enter("resourceMarker"),t.consume(b),t.exit("resourceMarker"),o}function o(b){return Nt(b)?ba(t,f)(b):f(b)}function f(b){return b===41?y(b):tv(t,u,p,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(b)}function u(b){return Nt(b)?ba(t,h)(b):y(b)}function p(b){return l(b)}function h(b){return b===34||b===39||b===40?iv(t,m,l,"resourceTitle","resourceTitleMarker","resourceTitleString")(b):y(b)}function m(b){return Nt(b)?ba(t,y)(b):y(b)}function y(b){return b===41?(t.enter("resourceMarker"),t.consume(b),t.exit("resourceMarker"),t.exit("resource"),i):l(b)}}function kk(t,i,l){const a=this;return o;function o(p){return nv.call(a,t,f,u,"reference","referenceMarker","referenceString")(p)}function f(p){return a.parser.defined.includes(Yn(a.sliceSerialize(a.events[a.events.length-1][1]).slice(1,-1)))?i(p):l(p)}function u(p){return l(p)}}function Ck(t,i,l){return a;function a(f){return t.enter("reference"),t.enter("referenceMarker"),t.consume(f),t.exit("referenceMarker"),o}function o(f){return f===93?(t.enter("referenceMarker"),t.consume(f),t.exit("referenceMarker"),t.exit("reference"),i):l(f)}}const Ek={name:"labelStartImage",resolveAll:md.resolveAll,tokenize:Nk};function Nk(t,i,l){const a=this;return o;function o(p){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(p),t.exit("labelImageMarker"),f}function f(p){return p===91?(t.enter("labelMarker"),t.consume(p),t.exit("labelMarker"),t.exit("labelImage"),u):l(p)}function u(p){return p===94&&"_hiddenFootnoteSupport"in a.parser.constructs?l(p):i(p)}}const Ak={name:"labelStartLink",resolveAll:md.resolveAll,tokenize:Tk};function Tk(t,i,l){const a=this;return o;function o(u){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(u),t.exit("labelMarker"),t.exit("labelLink"),f}function f(u){return u===94&&"_hiddenFootnoteSupport"in a.parser.constructs?l(u):i(u)}}const yf={name:"lineEnding",tokenize:Rk};function Rk(t,i){return l;function l(a){return t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),at(t,i,"linePrefix")}}const to={name:"thematicBreak",tokenize:zk};function zk(t,i,l){let a=0,o;return f;function f(m){return t.enter("thematicBreak"),u(m)}function u(m){return o=m,p(m)}function p(m){return m===o?(t.enter("thematicBreakSequence"),h(m)):a>=3&&(m===null||Be(m))?(t.exit("thematicBreak"),i(m)):l(m)}function h(m){return m===o?(t.consume(m),a++,h):(t.exit("thematicBreakSequence"),et(m)?at(t,p,"whitespace")(m):p(m))}}const mn={continuation:{tokenize:Ok},exit:Bk,name:"list",tokenize:Mk},Dk={partial:!0,tokenize:Uk},_k={partial:!0,tokenize:Lk};function Mk(t,i,l){const a=this,o=a.events[a.events.length-1];let f=o&&o[1].type==="linePrefix"?o[2].sliceSerialize(o[1],!0).length:0,u=0;return p;function p(v){const j=a.containerState.type||(v===42||v===43||v===45?"listUnordered":"listOrdered");if(j==="listUnordered"?!a.containerState.marker||v===a.containerState.marker:qf(v)){if(a.containerState.type||(a.containerState.type=j,t.enter(j,{_container:!0})),j==="listUnordered")return t.enter("listItemPrefix"),v===42||v===45?t.check(to,l,m)(v):m(v);if(!a.interrupt||v===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),h(v)}return l(v)}function h(v){return qf(v)&&++u<10?(t.consume(v),h):(!a.interrupt||u<2)&&(a.containerState.marker?v===a.containerState.marker:v===41||v===46)?(t.exit("listItemValue"),m(v)):l(v)}function m(v){return t.enter("listItemMarker"),t.consume(v),t.exit("listItemMarker"),a.containerState.marker=a.containerState.marker||v,t.check(Na,a.interrupt?l:y,t.attempt(Dk,x,b))}function y(v){return a.containerState.initialBlankLine=!0,f++,x(v)}function b(v){return et(v)?(t.enter("listItemPrefixWhitespace"),t.consume(v),t.exit("listItemPrefixWhitespace"),x):l(v)}function x(v){return a.containerState.size=f+a.sliceSerialize(t.exit("listItemPrefix"),!0).length,i(v)}}function Ok(t,i,l){const a=this;return a.containerState._closeFlow=void 0,t.check(Na,o,f);function o(p){return a.containerState.furtherBlankLines=a.containerState.furtherBlankLines||a.containerState.initialBlankLine,at(t,i,"listItemIndent",a.containerState.size+1)(p)}function f(p){return a.containerState.furtherBlankLines||!et(p)?(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,u(p)):(a.containerState.furtherBlankLines=void 0,a.containerState.initialBlankLine=void 0,t.attempt(_k,i,u)(p))}function u(p){return a.containerState._closeFlow=!0,a.interrupt=void 0,at(t,t.attempt(mn,i,l),"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(p)}}function Lk(t,i,l){const a=this;return at(t,o,"listItemIndent",a.containerState.size+1);function o(f){const u=a.events[a.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===a.containerState.size?i(f):l(f)}}function Bk(t){t.exit(this.containerState.type)}function Uk(t,i,l){const a=this;return at(t,o,"listItemPrefixWhitespace",a.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function o(f){const u=a.events[a.events.length-1];return!et(f)&&u&&u[1].type==="listItemPrefixWhitespace"?i(f):l(f)}}const My={name:"setextUnderline",resolveTo:Ik,tokenize:qk};function Ik(t,i){let l=t.length,a,o,f;for(;l--;)if(t[l][0]==="enter"){if(t[l][1].type==="content"){a=l;break}t[l][1].type==="paragraph"&&(o=l)}else t[l][1].type==="content"&&t.splice(l,1),!f&&t[l][1].type==="definition"&&(f=l);const u={type:"setextHeading",start:{...t[a][1].start},end:{...t[t.length-1][1].end}};return t[o][1].type="setextHeadingText",f?(t.splice(o,0,["enter",u,i]),t.splice(f+1,0,["exit",t[a][1],i]),t[a][1].end={...t[f][1].end}):t[a][1]=u,t.push(["exit",u,i]),t}function qk(t,i,l){const a=this;let o;return f;function f(m){let y=a.events.length,b;for(;y--;)if(a.events[y][1].type!=="lineEnding"&&a.events[y][1].type!=="linePrefix"&&a.events[y][1].type!=="content"){b=a.events[y][1].type==="paragraph";break}return!a.parser.lazy[a.now().line]&&(a.interrupt||b)?(t.enter("setextHeadingLine"),o=m,u(m)):l(m)}function u(m){return t.enter("setextHeadingLineSequence"),p(m)}function p(m){return m===o?(t.consume(m),p):(t.exit("setextHeadingLineSequence"),et(m)?at(t,h,"lineSuffix")(m):h(m))}function h(m){return m===null||Be(m)?(t.exit("setextHeadingLine"),i(m)):l(m)}}const Hk={tokenize:Vk};function Vk(t){const i=this,l=t.attempt(Na,a,t.attempt(this.parser.constructs.flowInitial,o,at(t,t.attempt(this.parser.constructs.flow,o,t.attempt(Qj,o)),"linePrefix")));return l;function a(f){if(f===null){t.consume(f);return}return t.enter("lineEndingBlank"),t.consume(f),t.exit("lineEndingBlank"),i.currentConstruct=void 0,l}function o(f){if(f===null){t.consume(f);return}return t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),i.currentConstruct=void 0,l}}const Yk={resolveAll:lv()},Gk=rv("string"),Fk=rv("text");function rv(t){return{resolveAll:lv(t==="text"?$k:void 0),tokenize:i};function i(l){const a=this,o=this.parser.constructs[t],f=l.attempt(o,u,p);return u;function u(y){return m(y)?f(y):p(y)}function p(y){if(y===null){l.consume(y);return}return l.enter("data"),l.consume(y),h}function h(y){return m(y)?(l.exit("data"),f(y)):(l.consume(y),h)}function m(y){if(y===null)return!0;const b=o[y];let x=-1;if(b)for(;++x<b.length;){const v=b[x];if(!v.previous||v.previous.call(a,a.previous))return!0}return!1}}}function lv(t){return i;function i(l,a){let o=-1,f;for(;++o<=l.length;)f===void 0?l[o]&&l[o][1].type==="data"&&(f=o,o++):(!l[o]||l[o][1].type!=="data")&&(o!==f+2&&(l[f][1].end=l[o-1][1].end,l.splice(f+2,o-f-2),o=f+2),f=void 0);return t?t(l,a):l}}function $k(t,i){let l=0;for(;++l<=t.length;)if((l===t.length||t[l][1].type==="lineEnding")&&t[l-1][1].type==="data"){const a=t[l-1][1],o=i.sliceStream(a);let f=o.length,u=-1,p=0,h;for(;f--;){const m=o[f];if(typeof m=="string"){for(u=m.length;m.charCodeAt(u-1)===32;)p++,u--;if(u)break;u=-1}else if(m===-2)h=!0,p++;else if(m!==-1){f++;break}}if(i._contentTypeTextTrailing&&l===t.length&&(p=0),p){const m={type:l===t.length||h||p<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:f?u:a.start._bufferIndex+u,_index:a.start._index+f,line:a.end.line,column:a.end.column-p,offset:a.end.offset-p},end:{...a.end}};a.end={...m.start},a.start.offset===a.end.offset?Object.assign(a,m):(t.splice(l,0,["enter",m,i],["exit",m,i]),l+=2)}l++}return t}const Qk={42:mn,43:mn,45:mn,48:mn,49:mn,50:mn,51:mn,52:mn,53:mn,54:mn,55:mn,56:mn,57:mn,62:Zb},Xk={91:Jj},Kk={[-2]:gf,[-1]:gf,32:gf},Pk={35:rk,42:to,45:[My,to],60:ok,61:My,95:to,96:Dy,126:Dy},Zk={38:Wb,92:Jb},Jk={[-5]:yf,[-4]:yf,[-3]:yf,33:Ek,38:Wb,42:Hf,60:[Aj,mk],91:Ak,92:[nk,Jb],93:md,95:Hf,96:Hj},Wk={null:[Hf,Yk]},eC={null:[42,95]},tC={null:[]},nC=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:eC,contentInitial:Xk,disable:tC,document:Qk,flow:Pk,flowInitial:Kk,insideSpan:Wk,string:Zk,text:Jk},Symbol.toStringTag,{value:"Module"}));function iC(t,i,l){let a={_bufferIndex:-1,_index:0,line:l&&l.line||1,column:l&&l.column||1,offset:l&&l.offset||0};const o={},f=[];let u=[],p=[];const h={attempt:H(ae),check:H(D),consume:T,enter:M,exit:G,interrupt:H(D,{interrupt:!0})},m={code:null,containerState:{},defineSkip:z,events:[],now:j,parser:t,previous:null,sliceSerialize:x,sliceStream:v,write:b};let y=i.tokenize.call(m,h);return i.resolveAll&&f.push(i),m;function b(L){return u=Bn(u,L),A(),u[u.length-1]!==null?[]:(W(i,0),m.events=mo(f,m.events,m),m.events)}function x(L,B){return lC(v(L),B)}function v(L){return rC(u,L)}function j(){const{_bufferIndex:L,_index:B,line:Q,column:J,offset:K}=a;return{_bufferIndex:L,_index:B,line:Q,column:J,offset:K}}function z(L){o[L.line]=L.column,C()}function A(){let L;for(;a._index<u.length;){const B=u[a._index];if(typeof B=="string")for(L=a._index,a._bufferIndex<0&&(a._bufferIndex=0);a._index===L&&a._bufferIndex<B.length;)N(B.charCodeAt(a._bufferIndex));else N(B)}}function N(L){y=y(L)}function T(L){Be(L)?(a.line++,a.column=1,a.offset+=L===-3?2:1,C()):L!==-1&&(a.column++,a.offset++),a._bufferIndex<0?a._index++:(a._bufferIndex++,a._bufferIndex===u[a._index].length&&(a._bufferIndex=-1,a._index++)),m.previous=L}function M(L,B){const Q=B||{};return Q.type=L,Q.start=j(),m.events.push(["enter",Q,m]),p.push(Q),Q}function G(L){const B=p.pop();return B.end=j(),m.events.push(["exit",B,m]),B}function ae(L,B){W(L,B.from)}function D(L,B){B.restore()}function H(L,B){return Q;function Q(J,K,I){let Y,X,pe,k;return Array.isArray(J)?te(J):"tokenize"in J?te([J]):O(J);function O(le){return ue;function ue(xe){const F=xe!==null&&le[xe],ke=xe!==null&&le.null,ze=[...Array.isArray(F)?F:F?[F]:[],...Array.isArray(ke)?ke:ke?[ke]:[]];return te(ze)(xe)}}function te(le){return Y=le,X=0,le.length===0?I:R(le[X])}function R(le){return ue;function ue(xe){return k=q(),pe=le,le.partial||(m.currentConstruct=le),le.name&&m.parser.constructs.disable.null.includes(le.name)?ve():le.tokenize.call(B?Object.assign(Object.create(m),B):m,h,ee,ve)(xe)}}function ee(le){return L(pe,k),K}function ve(le){return k.restore(),++X<Y.length?R(Y[X]):I}}}function W(L,B){L.resolveAll&&!f.includes(L)&&f.push(L),L.resolve&&Cn(m.events,B,m.events.length-B,L.resolve(m.events.slice(B),m)),L.resolveTo&&(m.events=L.resolveTo(m.events,m))}function q(){const L=j(),B=m.previous,Q=m.currentConstruct,J=m.events.length,K=Array.from(p);return{from:J,restore:I};function I(){a=L,m.previous=B,m.currentConstruct=Q,m.events.length=J,p=K,C()}}function C(){a.line in o&&a.column<2&&(a.column=o[a.line],a.offset+=o[a.line]-1)}}function rC(t,i){const l=i.start._index,a=i.start._bufferIndex,o=i.end._index,f=i.end._bufferIndex;let u;if(l===o)u=[t[l].slice(a,f)];else{if(u=t.slice(l,o),a>-1){const p=u[0];typeof p=="string"?u[0]=p.slice(a):u.shift()}f>0&&u.push(t[o].slice(0,f))}return u}function lC(t,i){let l=-1;const a=[];let o;for(;++l<t.length;){const f=t[l];let u;if(typeof f=="string")u=f;else switch(f){case-5:{u="\r";break}case-4:{u=`
30
+ `;break}case-3:{u=`\r
31
+ `;break}case-2:{u=i?" ":" ";break}case-1:{if(!i&&o)continue;u=" ";break}default:u=String.fromCharCode(f)}o=f===-2,a.push(u)}return a.join("")}function aC(t){const a={constructs:Kb([nC,...(t||{}).extensions||[]]),content:o(Sj),defined:[],document:o(jj),flow:o(Hk),lazy:{},string:o(Gk),text:o(Fk)};return a;function o(f){return u;function u(p){return iC(a,f,p)}}}function sC(t){for(;!ev(t););return t}const Oy=/[\0\t\n\r]/g;function oC(){let t=1,i="",l=!0,a;return o;function o(f,u,p){const h=[];let m,y,b,x,v;for(f=i+(typeof f=="string"?f.toString():new TextDecoder(u||void 0).decode(f)),b=0,i="",l&&(f.charCodeAt(0)===65279&&b++,l=void 0);b<f.length;){if(Oy.lastIndex=b,m=Oy.exec(f),x=m&&m.index!==void 0?m.index:f.length,v=f.charCodeAt(x),!m){i=f.slice(b);break}if(v===10&&b===x&&a)h.push(-3),a=void 0;else switch(a&&(h.push(-5),a=void 0),b<x&&(h.push(f.slice(b,x)),t+=x-b),v){case 0:{h.push(65533),t++;break}case 9:{for(y=Math.ceil(t/4)*4,h.push(-2);t++<y;)h.push(-1);break}case 10:{h.push(-4),t=1;break}default:a=!0,t=1}b=x+1}return p&&(a&&h.push(-5),i&&h.push(i),h.push(null)),h}}const uC=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function cC(t){return t.replace(uC,fC)}function fC(t,i,l){if(i)return i;if(l.charCodeAt(0)===35){const o=l.charCodeAt(1),f=o===120||o===88;return Pb(l.slice(f?2:1),f?16:10)}return pd(l)||t}const av={}.hasOwnProperty;function dC(t,i,l){return i&&typeof i=="object"&&(l=i,i=void 0),hC(l)(sC(aC(l).document().write(oC()(t,i,!0))))}function hC(t){const i={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:f(Ve),autolinkProtocol:q,autolinkEmail:q,atxHeading:f(gt),blockQuote:f(ke),characterEscape:q,characterReference:q,codeFenced:f(ze),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:f(ze,u),codeText:f(Le,u),codeTextData:q,data:q,codeFlowValue:q,definition:f(Ee),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:f(Xe),hardBreakEscape:f(He),hardBreakTrailing:f(He),htmlFlow:f(Lt,u),htmlFlowData:q,htmlText:f(Lt,u),htmlTextData:q,image:f(st),label:u,link:f(Ve),listItem:f(Ie),listItemValue:x,listOrdered:f(At,b),listUnordered:f(At),paragraph:f(yt),reference:R,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:f(gt),strong:f(ot),thematicBreak:f(pt)},exit:{atxHeading:h(),atxHeadingSequence:ae,autolink:h(),autolinkEmail:F,autolinkProtocol:xe,blockQuote:h(),characterEscapeValue:C,characterReferenceMarkerHexadecimal:ve,characterReferenceMarkerNumeric:ve,characterReferenceValue:le,characterReference:ue,codeFenced:h(A),codeFencedFence:z,codeFencedFenceInfo:v,codeFencedFenceMeta:j,codeFlowValue:C,codeIndented:h(N),codeText:h(K),codeTextData:C,data:C,definition:h(),definitionDestinationString:G,definitionLabelString:T,definitionTitleString:M,emphasis:h(),hardBreakEscape:h(B),hardBreakTrailing:h(B),htmlFlow:h(Q),htmlFlowData:C,htmlText:h(J),htmlTextData:C,image:h(Y),label:pe,labelText:X,lineEnding:L,link:h(I),listItem:h(),listOrdered:h(),listUnordered:h(),paragraph:h(),referenceString:ee,resourceDestinationString:k,resourceTitleString:O,resource:te,setextHeading:h(W),setextHeadingLineSequence:H,setextHeadingText:D,strong:h(),thematicBreak:h()}};sv(i,(t||{}).mdastExtensions||[]);const l={};return a;function a(_){let Z={type:"root",children:[]};const ge={stack:[Z],tokenStack:[],config:i,enter:p,exit:m,buffer:u,resume:y,data:l},we=[];let Ne=-1;for(;++Ne<_.length;)if(_[Ne][1].type==="listOrdered"||_[Ne][1].type==="listUnordered")if(_[Ne][0]==="enter")we.push(Ne);else{const De=we.pop();Ne=o(_,De,Ne)}for(Ne=-1;++Ne<_.length;){const De=i[_[Ne][0]];av.call(De,_[Ne][1].type)&&De[_[Ne][1].type].call(Object.assign({sliceSerialize:_[Ne][2].sliceSerialize},ge),_[Ne][1])}if(ge.tokenStack.length>0){const De=ge.tokenStack[ge.tokenStack.length-1];(De[1]||Ly).call(ge,void 0,De[0])}for(Z.position={start:$i(_.length>0?_[0][1].start:{line:1,column:1,offset:0}),end:$i(_.length>0?_[_.length-2][1].end:{line:1,column:1,offset:0})},Ne=-1;++Ne<i.transforms.length;)Z=i.transforms[Ne](Z)||Z;return Z}function o(_,Z,ge){let we=Z-1,Ne=-1,De=!1,Ge,mt,ut,dt;for(;++we<=ge;){const tt=_[we];switch(tt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{tt[0]==="enter"?Ne++:Ne--,dt=void 0;break}case"lineEndingBlank":{tt[0]==="enter"&&(Ge&&!dt&&!Ne&&!ut&&(ut=we),dt=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:dt=void 0}if(!Ne&&tt[0]==="enter"&&tt[1].type==="listItemPrefix"||Ne===-1&&tt[0]==="exit"&&(tt[1].type==="listUnordered"||tt[1].type==="listOrdered")){if(Ge){let Ot=we;for(mt=void 0;Ot--;){const oe=_[Ot];if(oe[1].type==="lineEnding"||oe[1].type==="lineEndingBlank"){if(oe[0]==="exit")continue;mt&&(_[mt][1].type="lineEndingBlank",De=!0),oe[1].type="lineEnding",mt=Ot}else if(!(oe[1].type==="linePrefix"||oe[1].type==="blockQuotePrefix"||oe[1].type==="blockQuotePrefixWhitespace"||oe[1].type==="blockQuoteMarker"||oe[1].type==="listItemIndent"))break}ut&&(!mt||ut<mt)&&(Ge._spread=!0),Ge.end=Object.assign({},mt?_[mt][1].start:tt[1].end),_.splice(mt||we,0,["exit",Ge,tt[2]]),we++,ge++}if(tt[1].type==="listItemPrefix"){const Ot={type:"listItem",_spread:!1,start:Object.assign({},tt[1].start),end:void 0};Ge=Ot,_.splice(we,0,["enter",Ot,tt[2]]),we++,ge++,ut=void 0,dt=!0}}}return _[Z][1]._spread=De,ge}function f(_,Z){return ge;function ge(we){p.call(this,_(we),we),Z&&Z.call(this,we)}}function u(){this.stack.push({type:"fragment",children:[]})}function p(_,Z,ge){this.stack[this.stack.length-1].children.push(_),this.stack.push(_),this.tokenStack.push([Z,ge||void 0]),_.position={start:$i(Z.start),end:void 0}}function h(_){return Z;function Z(ge){_&&_.call(this,ge),m.call(this,ge)}}function m(_,Z){const ge=this.stack.pop(),we=this.tokenStack.pop();if(we)we[0].type!==_.type&&(Z?Z.call(this,_,we[0]):(we[1]||Ly).call(this,_,we[0]));else throw new Error("Cannot close `"+_.type+"` ("+ya({start:_.start,end:_.end})+"): it’s not open");ge.position.end=$i(_.end)}function y(){return hd(this.stack.pop())}function b(){this.data.expectingFirstListItemValue=!0}function x(_){if(this.data.expectingFirstListItemValue){const Z=this.stack[this.stack.length-2];Z.start=Number.parseInt(this.sliceSerialize(_),10),this.data.expectingFirstListItemValue=void 0}}function v(){const _=this.resume(),Z=this.stack[this.stack.length-1];Z.lang=_}function j(){const _=this.resume(),Z=this.stack[this.stack.length-1];Z.meta=_}function z(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function A(){const _=this.resume(),Z=this.stack[this.stack.length-1];Z.value=_.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function N(){const _=this.resume(),Z=this.stack[this.stack.length-1];Z.value=_.replace(/(\r?\n|\r)$/g,"")}function T(_){const Z=this.resume(),ge=this.stack[this.stack.length-1];ge.label=Z,ge.identifier=Yn(this.sliceSerialize(_)).toLowerCase()}function M(){const _=this.resume(),Z=this.stack[this.stack.length-1];Z.title=_}function G(){const _=this.resume(),Z=this.stack[this.stack.length-1];Z.url=_}function ae(_){const Z=this.stack[this.stack.length-1];if(!Z.depth){const ge=this.sliceSerialize(_).length;Z.depth=ge}}function D(){this.data.setextHeadingSlurpLineEnding=!0}function H(_){const Z=this.stack[this.stack.length-1];Z.depth=this.sliceSerialize(_).codePointAt(0)===61?1:2}function W(){this.data.setextHeadingSlurpLineEnding=void 0}function q(_){const ge=this.stack[this.stack.length-1].children;let we=ge[ge.length-1];(!we||we.type!=="text")&&(we=Ze(),we.position={start:$i(_.start),end:void 0},ge.push(we)),this.stack.push(we)}function C(_){const Z=this.stack.pop();Z.value+=this.sliceSerialize(_),Z.position.end=$i(_.end)}function L(_){const Z=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ge=Z.children[Z.children.length-1];ge.position.end=$i(_.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&i.canContainEols.includes(Z.type)&&(q.call(this,_),C.call(this,_))}function B(){this.data.atHardBreak=!0}function Q(){const _=this.resume(),Z=this.stack[this.stack.length-1];Z.value=_}function J(){const _=this.resume(),Z=this.stack[this.stack.length-1];Z.value=_}function K(){const _=this.resume(),Z=this.stack[this.stack.length-1];Z.value=_}function I(){const _=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";_.type+="Reference",_.referenceType=Z,delete _.url,delete _.title}else delete _.identifier,delete _.label;this.data.referenceType=void 0}function Y(){const _=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";_.type+="Reference",_.referenceType=Z,delete _.url,delete _.title}else delete _.identifier,delete _.label;this.data.referenceType=void 0}function X(_){const Z=this.sliceSerialize(_),ge=this.stack[this.stack.length-2];ge.label=cC(Z),ge.identifier=Yn(Z).toLowerCase()}function pe(){const _=this.stack[this.stack.length-1],Z=this.resume(),ge=this.stack[this.stack.length-1];if(this.data.inReference=!0,ge.type==="link"){const we=_.children;ge.children=we}else ge.alt=Z}function k(){const _=this.resume(),Z=this.stack[this.stack.length-1];Z.url=_}function O(){const _=this.resume(),Z=this.stack[this.stack.length-1];Z.title=_}function te(){this.data.inReference=void 0}function R(){this.data.referenceType="collapsed"}function ee(_){const Z=this.resume(),ge=this.stack[this.stack.length-1];ge.label=Z,ge.identifier=Yn(this.sliceSerialize(_)).toLowerCase(),this.data.referenceType="full"}function ve(_){this.data.characterReferenceType=_.type}function le(_){const Z=this.sliceSerialize(_),ge=this.data.characterReferenceType;let we;ge?(we=Pb(Z,ge==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):we=pd(Z);const Ne=this.stack[this.stack.length-1];Ne.value+=we}function ue(_){const Z=this.stack.pop();Z.position.end=$i(_.end)}function xe(_){C.call(this,_);const Z=this.stack[this.stack.length-1];Z.url=this.sliceSerialize(_)}function F(_){C.call(this,_);const Z=this.stack[this.stack.length-1];Z.url="mailto:"+this.sliceSerialize(_)}function ke(){return{type:"blockquote",children:[]}}function ze(){return{type:"code",lang:null,meta:null,value:""}}function Le(){return{type:"inlineCode",value:""}}function Ee(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Xe(){return{type:"emphasis",children:[]}}function gt(){return{type:"heading",depth:0,children:[]}}function He(){return{type:"break"}}function Lt(){return{type:"html",value:""}}function st(){return{type:"image",title:null,url:"",alt:null}}function Ve(){return{type:"link",title:null,url:"",children:[]}}function At(_){return{type:"list",ordered:_.type==="listOrdered",start:null,spread:_._spread,children:[]}}function Ie(_){return{type:"listItem",spread:_._spread,checked:null,children:[]}}function yt(){return{type:"paragraph",children:[]}}function ot(){return{type:"strong",children:[]}}function Ze(){return{type:"text",value:""}}function pt(){return{type:"thematicBreak"}}}function $i(t){return{line:t.line,column:t.column,offset:t.offset}}function sv(t,i){let l=-1;for(;++l<i.length;){const a=i[l];Array.isArray(a)?sv(t,a):pC(t,a)}}function pC(t,i){let l;for(l in i)if(av.call(i,l))switch(l){case"canContainEols":{const a=i[l];a&&t[l].push(...a);break}case"transforms":{const a=i[l];a&&t[l].push(...a);break}case"enter":case"exit":{const a=i[l];a&&Object.assign(t[l],a);break}}}function Ly(t,i){throw t?new Error("Cannot close `"+t.type+"` ("+ya({start:t.start,end:t.end})+"): a different token (`"+i.type+"`, "+ya({start:i.start,end:i.end})+") is open"):new Error("Cannot close document, a token (`"+i.type+"`, "+ya({start:i.start,end:i.end})+") is still open")}function mC(t){const i=this;i.parser=l;function l(a){return dC(a,{...i.data("settings"),...t,extensions:i.data("micromarkExtensions")||[],mdastExtensions:i.data("fromMarkdownExtensions")||[]})}}function gC(t,i){const l={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(i),!0)};return t.patch(i,l),t.applyData(i,l)}function yC(t,i){const l={type:"element",tagName:"br",properties:{},children:[]};return t.patch(i,l),[t.applyData(i,l),{type:"text",value:`
32
+ `}]}function bC(t,i){const l=i.value?i.value+`
33
+ `:"",a={},o=i.lang?i.lang.split(/\s+/):[];o.length>0&&(a.className=["language-"+o[0]]);let f={type:"element",tagName:"code",properties:a,children:[{type:"text",value:l}]};return i.meta&&(f.data={meta:i.meta}),t.patch(i,f),f=t.applyData(i,f),f={type:"element",tagName:"pre",properties:{},children:[f]},t.patch(i,f),f}function vC(t,i){const l={type:"element",tagName:"del",properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}function xC(t,i){const l={type:"element",tagName:"em",properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}function SC(t,i){const l=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",a=String(i.identifier).toUpperCase(),o=ml(a.toLowerCase()),f=t.footnoteOrder.indexOf(a);let u,p=t.footnoteCounts.get(a);p===void 0?(p=0,t.footnoteOrder.push(a),u=t.footnoteOrder.length):u=f+1,p+=1,t.footnoteCounts.set(a,p);const h={type:"element",tagName:"a",properties:{href:"#"+l+"fn-"+o,id:l+"fnref-"+o+(p>1?"-"+p:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};t.patch(i,h);const m={type:"element",tagName:"sup",properties:{},children:[h]};return t.patch(i,m),t.applyData(i,m)}function wC(t,i){const l={type:"element",tagName:"h"+i.depth,properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}function jC(t,i){if(t.options.allowDangerousHtml){const l={type:"raw",value:i.value};return t.patch(i,l),t.applyData(i,l)}}function ov(t,i){const l=i.referenceType;let a="]";if(l==="collapsed"?a+="[]":l==="full"&&(a+="["+(i.label||i.identifier)+"]"),i.type==="imageReference")return[{type:"text",value:"!["+i.alt+a}];const o=t.all(i),f=o[0];f&&f.type==="text"?f.value="["+f.value:o.unshift({type:"text",value:"["});const u=o[o.length-1];return u&&u.type==="text"?u.value+=a:o.push({type:"text",value:a}),o}function kC(t,i){const l=String(i.identifier).toUpperCase(),a=t.definitionById.get(l);if(!a)return ov(t,i);const o={src:ml(a.url||""),alt:i.alt};a.title!==null&&a.title!==void 0&&(o.title=a.title);const f={type:"element",tagName:"img",properties:o,children:[]};return t.patch(i,f),t.applyData(i,f)}function CC(t,i){const l={src:ml(i.url)};i.alt!==null&&i.alt!==void 0&&(l.alt=i.alt),i.title!==null&&i.title!==void 0&&(l.title=i.title);const a={type:"element",tagName:"img",properties:l,children:[]};return t.patch(i,a),t.applyData(i,a)}function EC(t,i){const l={type:"text",value:i.value.replace(/\r?\n|\r/g," ")};t.patch(i,l);const a={type:"element",tagName:"code",properties:{},children:[l]};return t.patch(i,a),t.applyData(i,a)}function NC(t,i){const l=String(i.identifier).toUpperCase(),a=t.definitionById.get(l);if(!a)return ov(t,i);const o={href:ml(a.url||"")};a.title!==null&&a.title!==void 0&&(o.title=a.title);const f={type:"element",tagName:"a",properties:o,children:t.all(i)};return t.patch(i,f),t.applyData(i,f)}function AC(t,i){const l={href:ml(i.url)};i.title!==null&&i.title!==void 0&&(l.title=i.title);const a={type:"element",tagName:"a",properties:l,children:t.all(i)};return t.patch(i,a),t.applyData(i,a)}function TC(t,i,l){const a=t.all(i),o=l?RC(l):uv(i),f={},u=[];if(typeof i.checked=="boolean"){const y=a[0];let b;y&&y.type==="element"&&y.tagName==="p"?b=y:(b={type:"element",tagName:"p",properties:{},children:[]},a.unshift(b)),b.children.length>0&&b.children.unshift({type:"text",value:" "}),b.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:i.checked,disabled:!0},children:[]}),f.className=["task-list-item"]}let p=-1;for(;++p<a.length;){const y=a[p];(o||p!==0||y.type!=="element"||y.tagName!=="p")&&u.push({type:"text",value:`
34
+ `}),y.type==="element"&&y.tagName==="p"&&!o?u.push(...y.children):u.push(y)}const h=a[a.length-1];h&&(o||h.type!=="element"||h.tagName!=="p")&&u.push({type:"text",value:`
35
+ `});const m={type:"element",tagName:"li",properties:f,children:u};return t.patch(i,m),t.applyData(i,m)}function RC(t){let i=!1;if(t.type==="list"){i=t.spread||!1;const l=t.children;let a=-1;for(;!i&&++a<l.length;)i=uv(l[a])}return i}function uv(t){const i=t.spread;return i??t.children.length>1}function zC(t,i){const l={},a=t.all(i);let o=-1;for(typeof i.start=="number"&&i.start!==1&&(l.start=i.start);++o<a.length;){const u=a[o];if(u.type==="element"&&u.tagName==="li"&&u.properties&&Array.isArray(u.properties.className)&&u.properties.className.includes("task-list-item")){l.className=["contains-task-list"];break}}const f={type:"element",tagName:i.ordered?"ol":"ul",properties:l,children:t.wrap(a,!0)};return t.patch(i,f),t.applyData(i,f)}function DC(t,i){const l={type:"element",tagName:"p",properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}function _C(t,i){const l={type:"root",children:t.wrap(t.all(i))};return t.patch(i,l),t.applyData(i,l)}function MC(t,i){const l={type:"element",tagName:"strong",properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}function OC(t,i){const l=t.all(i),a=l.shift(),o=[];if(a){const u={type:"element",tagName:"thead",properties:{},children:t.wrap([a],!0)};t.patch(i.children[0],u),o.push(u)}if(l.length>0){const u={type:"element",tagName:"tbody",properties:{},children:t.wrap(l,!0)},p=ud(i.children[1]),h=Vb(i.children[i.children.length-1]);p&&h&&(u.position={start:p,end:h}),o.push(u)}const f={type:"element",tagName:"table",properties:{},children:t.wrap(o,!0)};return t.patch(i,f),t.applyData(i,f)}function LC(t,i,l){const a=l?l.children:void 0,f=(a?a.indexOf(i):1)===0?"th":"td",u=l&&l.type==="table"?l.align:void 0,p=u?u.length:i.children.length;let h=-1;const m=[];for(;++h<p;){const b=i.children[h],x={},v=u?u[h]:void 0;v&&(x.align=v);let j={type:"element",tagName:f,properties:x,children:[]};b&&(j.children=t.all(b),t.patch(b,j),j=t.applyData(b,j)),m.push(j)}const y={type:"element",tagName:"tr",properties:{},children:t.wrap(m,!0)};return t.patch(i,y),t.applyData(i,y)}function BC(t,i){const l={type:"element",tagName:"td",properties:{},children:t.all(i)};return t.patch(i,l),t.applyData(i,l)}const By=9,Uy=32;function UC(t){const i=String(t),l=/\r?\n|\r/g;let a=l.exec(i),o=0;const f=[];for(;a;)f.push(Iy(i.slice(o,a.index),o>0,!0),a[0]),o=a.index+a[0].length,a=l.exec(i);return f.push(Iy(i.slice(o),o>0,!1)),f.join("")}function Iy(t,i,l){let a=0,o=t.length;if(i){let f=t.codePointAt(a);for(;f===By||f===Uy;)a++,f=t.codePointAt(a)}if(l){let f=t.codePointAt(o-1);for(;f===By||f===Uy;)o--,f=t.codePointAt(o-1)}return o>a?t.slice(a,o):""}function IC(t,i){const l={type:"text",value:UC(String(i.value))};return t.patch(i,l),t.applyData(i,l)}function qC(t,i){const l={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(i,l),t.applyData(i,l)}const HC={blockquote:gC,break:yC,code:bC,delete:vC,emphasis:xC,footnoteReference:SC,heading:wC,html:jC,imageReference:kC,image:CC,inlineCode:EC,linkReference:NC,link:AC,listItem:TC,list:zC,paragraph:DC,root:_C,strong:MC,table:OC,tableCell:BC,tableRow:LC,text:IC,thematicBreak:qC,toml:Ks,yaml:Ks,definition:Ks,footnoteDefinition:Ks};function Ks(){}const cv=-1,go=0,va=1,so=2,gd=3,yd=4,bd=5,vd=6,fv=7,dv=8,VC=typeof self=="object"?self:globalThis,qy=(t,i)=>{switch(t){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+t)}return new VC[t](i)},YC=(t,i)=>{const l=(o,f)=>(t.set(f,o),o),a=o=>{if(t.has(o))return t.get(o);const[f,u]=i[o];switch(f){case go:case cv:return l(u,o);case va:{const p=l([],o);for(const h of u)p.push(a(h));return p}case so:{const p=l({},o);for(const[h,m]of u)p[a(h)]=a(m);return p}case gd:return l(new Date(u),o);case yd:{const{source:p,flags:h}=u;return l(new RegExp(p,h),o)}case bd:{const p=l(new Map,o);for(const[h,m]of u)p.set(a(h),a(m));return p}case vd:{const p=l(new Set,o);for(const h of u)p.add(a(h));return p}case fv:{const{name:p,message:h}=u;return l(qy(p,h),o)}case dv:return l(BigInt(u),o);case"BigInt":return l(Object(BigInt(u)),o);case"ArrayBuffer":return l(new Uint8Array(u).buffer,u);case"DataView":{const{buffer:p}=new Uint8Array(u);return l(new DataView(p),u)}}return l(qy(f,u),o)};return a},Hy=t=>YC(new Map,t)(0),ul="",{toString:GC}={},{keys:FC}=Object,pa=t=>{const i=typeof t;if(i!=="object"||!t)return[go,i];const l=GC.call(t).slice(8,-1);switch(l){case"Array":return[va,ul];case"Object":return[so,ul];case"Date":return[gd,ul];case"RegExp":return[yd,ul];case"Map":return[bd,ul];case"Set":return[vd,ul];case"DataView":return[va,l]}return l.includes("Array")?[va,l]:l.includes("Error")?[fv,l]:[so,l]},Ps=([t,i])=>t===go&&(i==="function"||i==="symbol"),$C=(t,i,l,a)=>{const o=(u,p)=>{const h=a.push(u)-1;return l.set(p,h),h},f=u=>{if(l.has(u))return l.get(u);let[p,h]=pa(u);switch(p){case go:{let y=u;switch(h){case"bigint":p=dv,y=u.toString();break;case"function":case"symbol":if(t)throw new TypeError("unable to serialize "+h);y=null;break;case"undefined":return o([cv],u)}return o([p,y],u)}case va:{if(h){let x=u;return h==="DataView"?x=new Uint8Array(u.buffer):h==="ArrayBuffer"&&(x=new Uint8Array(u)),o([h,[...x]],u)}const y=[],b=o([p,y],u);for(const x of u)y.push(f(x));return b}case so:{if(h)switch(h){case"BigInt":return o([h,u.toString()],u);case"Boolean":case"Number":case"String":return o([h,u.valueOf()],u)}if(i&&"toJSON"in u)return f(u.toJSON());const y=[],b=o([p,y],u);for(const x of FC(u))(t||!Ps(pa(u[x])))&&y.push([f(x),f(u[x])]);return b}case gd:return o([p,u.toISOString()],u);case yd:{const{source:y,flags:b}=u;return o([p,{source:y,flags:b}],u)}case bd:{const y=[],b=o([p,y],u);for(const[x,v]of u)(t||!(Ps(pa(x))||Ps(pa(v))))&&y.push([f(x),f(v)]);return b}case vd:{const y=[],b=o([p,y],u);for(const x of u)(t||!Ps(pa(x)))&&y.push(f(x));return b}}const{message:m}=u;return o([p,{name:h,message:m}],u)};return f},Vy=(t,{json:i,lossy:l}={})=>{const a=[];return $C(!(i||l),!!i,new Map,a)(t),a},oo=typeof structuredClone=="function"?(t,i)=>i&&("json"in i||"lossy"in i)?Hy(Vy(t,i)):structuredClone(t):(t,i)=>Hy(Vy(t,i));function QC(t,i){const l=[{type:"text",value:"↩"}];return i>1&&l.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(i)}]}),l}function XC(t,i){return"Back to reference "+(t+1)+(i>1?"-"+i:"")}function KC(t){const i=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",l=t.options.footnoteBackContent||QC,a=t.options.footnoteBackLabel||XC,o=t.options.footnoteLabel||"Footnotes",f=t.options.footnoteLabelTagName||"h2",u=t.options.footnoteLabelProperties||{className:["sr-only"]},p=[];let h=-1;for(;++h<t.footnoteOrder.length;){const m=t.footnoteById.get(t.footnoteOrder[h]);if(!m)continue;const y=t.all(m),b=String(m.identifier).toUpperCase(),x=ml(b.toLowerCase());let v=0;const j=[],z=t.footnoteCounts.get(b);for(;z!==void 0&&++v<=z;){j.length>0&&j.push({type:"text",value:" "});let T=typeof l=="string"?l:l(h,v);typeof T=="string"&&(T={type:"text",value:T}),j.push({type:"element",tagName:"a",properties:{href:"#"+i+"fnref-"+x+(v>1?"-"+v:""),dataFootnoteBackref:"",ariaLabel:typeof a=="string"?a:a(h,v),className:["data-footnote-backref"]},children:Array.isArray(T)?T:[T]})}const A=y[y.length-1];if(A&&A.type==="element"&&A.tagName==="p"){const T=A.children[A.children.length-1];T&&T.type==="text"?T.value+=" ":A.children.push({type:"text",value:" "}),A.children.push(...j)}else y.push(...j);const N={type:"element",tagName:"li",properties:{id:i+"fn-"+x},children:t.wrap(y,!0)};t.patch(m,N),p.push(N)}if(p.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:f,properties:{...oo(u),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
36
+ `},{type:"element",tagName:"ol",properties:{},children:t.wrap(p,!0)},{type:"text",value:`
37
+ `}]}}const yo=(function(t){if(t==null)return WC;if(typeof t=="function")return bo(t);if(typeof t=="object")return Array.isArray(t)?PC(t):ZC(t);if(typeof t=="string")return JC(t);throw new Error("Expected function, string, or object as test")});function PC(t){const i=[];let l=-1;for(;++l<t.length;)i[l]=yo(t[l]);return bo(a);function a(...o){let f=-1;for(;++f<i.length;)if(i[f].apply(this,o))return!0;return!1}}function ZC(t){const i=t;return bo(l);function l(a){const o=a;let f;for(f in t)if(o[f]!==i[f])return!1;return!0}}function JC(t){return bo(i);function i(l){return l&&l.type===t}}function bo(t){return i;function i(l,a,o){return!!(eE(l)&&t.call(this,l,typeof a=="number"?a:void 0,o||void 0))}}function WC(){return!0}function eE(t){return t!==null&&typeof t=="object"&&"type"in t}const hv=[],tE=!0,Vf=!1,nE="skip";function pv(t,i,l,a){let o;typeof i=="function"&&typeof l!="function"?(a=l,l=i):o=i;const f=yo(o),u=a?-1:1;p(t,void 0,[])();function p(h,m,y){const b=h&&typeof h=="object"?h:{};if(typeof b.type=="string"){const v=typeof b.tagName=="string"?b.tagName:typeof b.name=="string"?b.name:void 0;Object.defineProperty(x,"name",{value:"node ("+(h.type+(v?"<"+v+">":""))+")"})}return x;function x(){let v=hv,j,z,A;if((!i||f(h,m,y[y.length-1]||void 0))&&(v=iE(l(h,y)),v[0]===Vf))return v;if("children"in h&&h.children){const N=h;if(N.children&&v[0]!==nE)for(z=(a?N.children.length:-1)+u,A=y.concat(N);z>-1&&z<N.children.length;){const T=N.children[z];if(j=p(T,z,A)(),j[0]===Vf)return j;z=typeof j[1]=="number"?j[1]:z+u}}return v}}}function iE(t){return Array.isArray(t)?t:typeof t=="number"?[tE,t]:t==null?hv:[t]}function xd(t,i,l,a){let o,f,u;typeof i=="function"&&typeof l!="function"?(f=void 0,u=i,o=l):(f=i,u=l,o=a),pv(t,f,p,o);function p(h,m){const y=m[m.length-1],b=y?y.children.indexOf(h):void 0;return u(h,b,y)}}const Yf={}.hasOwnProperty,rE={};function lE(t,i){const l=i||rE,a=new Map,o=new Map,f=new Map,u={...HC,...l.handlers},p={all:m,applyData:sE,definitionById:a,footnoteById:o,footnoteCounts:f,footnoteOrder:[],handlers:u,one:h,options:l,patch:aE,wrap:uE};return xd(t,function(y){if(y.type==="definition"||y.type==="footnoteDefinition"){const b=y.type==="definition"?a:o,x=String(y.identifier).toUpperCase();b.has(x)||b.set(x,y)}}),p;function h(y,b){const x=y.type,v=p.handlers[x];if(Yf.call(p.handlers,x)&&v)return v(p,y,b);if(p.options.passThrough&&p.options.passThrough.includes(x)){if("children"in y){const{children:z,...A}=y,N=oo(A);return N.children=p.all(y),N}return oo(y)}return(p.options.unknownHandler||oE)(p,y,b)}function m(y){const b=[];if("children"in y){const x=y.children;let v=-1;for(;++v<x.length;){const j=p.one(x[v],y);if(j){if(v&&x[v-1].type==="break"&&(!Array.isArray(j)&&j.type==="text"&&(j.value=Yy(j.value)),!Array.isArray(j)&&j.type==="element")){const z=j.children[0];z&&z.type==="text"&&(z.value=Yy(z.value))}Array.isArray(j)?b.push(...j):b.push(j)}}}return b}}function aE(t,i){t.position&&(i.position=Qw(t))}function sE(t,i){let l=i;if(t&&t.data){const a=t.data.hName,o=t.data.hChildren,f=t.data.hProperties;if(typeof a=="string")if(l.type==="element")l.tagName=a;else{const u="children"in l?l.children:[l];l={type:"element",tagName:a,properties:{},children:u}}l.type==="element"&&f&&Object.assign(l.properties,oo(f)),"children"in l&&l.children&&o!==null&&o!==void 0&&(l.children=o)}return l}function oE(t,i){const l=i.data||{},a="value"in i&&!(Yf.call(l,"hProperties")||Yf.call(l,"hChildren"))?{type:"text",value:i.value}:{type:"element",tagName:"div",properties:{},children:t.all(i)};return t.patch(i,a),t.applyData(i,a)}function uE(t,i){const l=[];let a=-1;for(i&&l.push({type:"text",value:`
38
+ `});++a<t.length;)a&&l.push({type:"text",value:`
39
+ `}),l.push(t[a]);return i&&t.length>0&&l.push({type:"text",value:`
40
+ `}),l}function Yy(t){let i=0,l=t.charCodeAt(i);for(;l===9||l===32;)i++,l=t.charCodeAt(i);return t.slice(i)}function Gy(t,i){const l=lE(t,i),a=l.one(t,void 0),o=KC(l),f=Array.isArray(a)?{type:"root",children:a}:a||{type:"root",children:[]};return o&&f.children.push({type:"text",value:`
41
+ `},o),f}function cE(t,i){return t&&"run"in t?async function(l,a){const o=Gy(l,{file:a,...i});await t.run(o,a)}:function(l,a){return Gy(l,{file:a,...t||i})}}function Fy(t){if(t)throw t}var bf,$y;function fE(){if($y)return bf;$y=1;var t=Object.prototype.hasOwnProperty,i=Object.prototype.toString,l=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(m){return typeof Array.isArray=="function"?Array.isArray(m):i.call(m)==="[object Array]"},f=function(m){if(!m||i.call(m)!=="[object Object]")return!1;var y=t.call(m,"constructor"),b=m.constructor&&m.constructor.prototype&&t.call(m.constructor.prototype,"isPrototypeOf");if(m.constructor&&!y&&!b)return!1;var x;for(x in m);return typeof x>"u"||t.call(m,x)},u=function(m,y){l&&y.name==="__proto__"?l(m,y.name,{enumerable:!0,configurable:!0,value:y.newValue,writable:!0}):m[y.name]=y.newValue},p=function(m,y){if(y==="__proto__")if(t.call(m,y)){if(a)return a(m,y).value}else return;return m[y]};return bf=function h(){var m,y,b,x,v,j,z=arguments[0],A=1,N=arguments.length,T=!1;for(typeof z=="boolean"&&(T=z,z=arguments[1]||{},A=2),(z==null||typeof z!="object"&&typeof z!="function")&&(z={});A<N;++A)if(m=arguments[A],m!=null)for(y in m)b=p(z,y),x=p(m,y),z!==x&&(T&&x&&(f(x)||(v=o(x)))?(v?(v=!1,j=b&&o(b)?b:[]):j=b&&f(b)?b:{},u(z,{name:y,newValue:h(T,j,x)})):typeof x<"u"&&u(z,{name:y,newValue:x}));return z},bf}var dE=fE();const vf=co(dE);function Gf(t){if(typeof t!="object"||t===null)return!1;const i=Object.getPrototypeOf(t);return(i===null||i===Object.prototype||Object.getPrototypeOf(i)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)}function hE(){const t=[],i={run:l,use:a};return i;function l(...o){let f=-1;const u=o.pop();if(typeof u!="function")throw new TypeError("Expected function as last argument, not "+u);p(null,...o);function p(h,...m){const y=t[++f];let b=-1;if(h){u(h);return}for(;++b<o.length;)(m[b]===null||m[b]===void 0)&&(m[b]=o[b]);o=m,y?pE(y,p)(...m):u(null,...m)}}function a(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return t.push(o),i}}function pE(t,i){let l;return a;function a(...u){const p=t.length>u.length;let h;p&&u.push(o);try{h=t.apply(this,u)}catch(m){const y=m;if(p&&l)throw y;return o(y)}p||(h&&h.then&&typeof h.then=="function"?h.then(f,o):h instanceof Error?o(h):f(h))}function o(u,...p){l||(l=!0,i(u,...p))}function f(u){o(null,u)}}const Zn={basename:mE,dirname:gE,extname:yE,join:bE,sep:"/"};function mE(t,i){if(i!==void 0&&typeof i!="string")throw new TypeError('"ext" argument must be a string');Aa(t);let l=0,a=-1,o=t.length,f;if(i===void 0||i.length===0||i.length>t.length){for(;o--;)if(t.codePointAt(o)===47){if(f){l=o+1;break}}else a<0&&(f=!0,a=o+1);return a<0?"":t.slice(l,a)}if(i===t)return"";let u=-1,p=i.length-1;for(;o--;)if(t.codePointAt(o)===47){if(f){l=o+1;break}}else u<0&&(f=!0,u=o+1),p>-1&&(t.codePointAt(o)===i.codePointAt(p--)?p<0&&(a=o):(p=-1,a=u));return l===a?a=u:a<0&&(a=t.length),t.slice(l,a)}function gE(t){if(Aa(t),t.length===0)return".";let i=-1,l=t.length,a;for(;--l;)if(t.codePointAt(l)===47){if(a){i=l;break}}else a||(a=!0);return i<0?t.codePointAt(0)===47?"/":".":i===1&&t.codePointAt(0)===47?"//":t.slice(0,i)}function yE(t){Aa(t);let i=t.length,l=-1,a=0,o=-1,f=0,u;for(;i--;){const p=t.codePointAt(i);if(p===47){if(u){a=i+1;break}continue}l<0&&(u=!0,l=i+1),p===46?o<0?o=i:f!==1&&(f=1):o>-1&&(f=-1)}return o<0||l<0||f===0||f===1&&o===l-1&&o===a+1?"":t.slice(o,l)}function bE(...t){let i=-1,l;for(;++i<t.length;)Aa(t[i]),t[i]&&(l=l===void 0?t[i]:l+"/"+t[i]);return l===void 0?".":vE(l)}function vE(t){Aa(t);const i=t.codePointAt(0)===47;let l=xE(t,!i);return l.length===0&&!i&&(l="."),l.length>0&&t.codePointAt(t.length-1)===47&&(l+="/"),i?"/"+l:l}function xE(t,i){let l="",a=0,o=-1,f=0,u=-1,p,h;for(;++u<=t.length;){if(u<t.length)p=t.codePointAt(u);else{if(p===47)break;p=47}if(p===47){if(!(o===u-1||f===1))if(o!==u-1&&f===2){if(l.length<2||a!==2||l.codePointAt(l.length-1)!==46||l.codePointAt(l.length-2)!==46){if(l.length>2){if(h=l.lastIndexOf("/"),h!==l.length-1){h<0?(l="",a=0):(l=l.slice(0,h),a=l.length-1-l.lastIndexOf("/")),o=u,f=0;continue}}else if(l.length>0){l="",a=0,o=u,f=0;continue}}i&&(l=l.length>0?l+"/..":"..",a=2)}else l.length>0?l+="/"+t.slice(o+1,u):l=t.slice(o+1,u),a=u-o-1;o=u,f=0}else p===46&&f>-1?f++:f=-1}return l}function Aa(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const SE={cwd:wE};function wE(){return"/"}function Ff(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function jE(t){if(typeof t=="string")t=new URL(t);else if(!Ff(t)){const i=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw i.code="ERR_INVALID_ARG_TYPE",i}if(t.protocol!=="file:"){const i=new TypeError("The URL must be of scheme file");throw i.code="ERR_INVALID_URL_SCHEME",i}return kE(t)}function kE(t){if(t.hostname!==""){const a=new TypeError('File URL host must be "localhost" or empty on darwin');throw a.code="ERR_INVALID_FILE_URL_HOST",a}const i=t.pathname;let l=-1;for(;++l<i.length;)if(i.codePointAt(l)===37&&i.codePointAt(l+1)===50){const a=i.codePointAt(l+2);if(a===70||a===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(i)}const xf=["history","path","basename","stem","extname","dirname"];class mv{constructor(i){let l;i?Ff(i)?l={path:i}:typeof i=="string"||CE(i)?l={value:i}:l=i:l={},this.cwd="cwd"in l?"":SE.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let a=-1;for(;++a<xf.length;){const f=xf[a];f in l&&l[f]!==void 0&&l[f]!==null&&(this[f]=f==="history"?[...l[f]]:l[f])}let o;for(o in l)xf.includes(o)||(this[o]=l[o])}get basename(){return typeof this.path=="string"?Zn.basename(this.path):void 0}set basename(i){wf(i,"basename"),Sf(i,"basename"),this.path=Zn.join(this.dirname||"",i)}get dirname(){return typeof this.path=="string"?Zn.dirname(this.path):void 0}set dirname(i){Qy(this.basename,"dirname"),this.path=Zn.join(i||"",this.basename)}get extname(){return typeof this.path=="string"?Zn.extname(this.path):void 0}set extname(i){if(Sf(i,"extname"),Qy(this.dirname,"extname"),i){if(i.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(i.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Zn.join(this.dirname,this.stem+(i||""))}get path(){return this.history[this.history.length-1]}set path(i){Ff(i)&&(i=jE(i)),wf(i,"path"),this.path!==i&&this.history.push(i)}get stem(){return typeof this.path=="string"?Zn.basename(this.path,this.extname):void 0}set stem(i){wf(i,"stem"),Sf(i,"stem"),this.path=Zn.join(this.dirname||"",i+(this.extname||""))}fail(i,l,a){const o=this.message(i,l,a);throw o.fatal=!0,o}info(i,l,a){const o=this.message(i,l,a);return o.fatal=void 0,o}message(i,l,a){const o=new an(i,l,a);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(i){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(i||void 0).decode(this.value)}}function Sf(t,i){if(t&&t.includes(Zn.sep))throw new Error("`"+i+"` cannot be a path: did not expect `"+Zn.sep+"`")}function wf(t,i){if(!t)throw new Error("`"+i+"` cannot be empty")}function Qy(t,i){if(!t)throw new Error("Setting `"+i+"` requires `path` to be set too")}function CE(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const EE=(function(t){const a=this.constructor.prototype,o=a[t],f=function(){return o.apply(f,arguments)};return Object.setPrototypeOf(f,a),f}),NE={}.hasOwnProperty;class Sd extends EE{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=hE()}copy(){const i=new Sd;let l=-1;for(;++l<this.attachers.length;){const a=this.attachers[l];i.use(...a)}return i.data(vf(!0,{},this.namespace)),i}data(i,l){return typeof i=="string"?arguments.length===2?(Cf("data",this.frozen),this.namespace[i]=l,this):NE.call(this.namespace,i)&&this.namespace[i]||void 0:i?(Cf("data",this.frozen),this.namespace=i,this):this.namespace}freeze(){if(this.frozen)return this;const i=this;for(;++this.freezeIndex<this.attachers.length;){const[l,...a]=this.attachers[this.freezeIndex];if(a[0]===!1)continue;a[0]===!0&&(a[0]=void 0);const o=l.call(i,...a);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(i){this.freeze();const l=Zs(i),a=this.parser||this.Parser;return jf("parse",a),a(String(l),l)}process(i,l){const a=this;return this.freeze(),jf("process",this.parser||this.Parser),kf("process",this.compiler||this.Compiler),l?o(void 0,l):new Promise(o);function o(f,u){const p=Zs(i),h=a.parse(p);a.run(h,p,function(y,b,x){if(y||!b||!x)return m(y);const v=b,j=a.stringify(v,x);RE(j)?x.value=j:x.result=j,m(y,x)});function m(y,b){y||!b?u(y):f?f(b):l(void 0,b)}}}processSync(i){let l=!1,a;return this.freeze(),jf("processSync",this.parser||this.Parser),kf("processSync",this.compiler||this.Compiler),this.process(i,o),Ky("processSync","process",l),a;function o(f,u){l=!0,Fy(f),a=u}}run(i,l,a){Xy(i),this.freeze();const o=this.transformers;return!a&&typeof l=="function"&&(a=l,l=void 0),a?f(void 0,a):new Promise(f);function f(u,p){const h=Zs(l);o.run(i,h,m);function m(y,b,x){const v=b||i;y?p(y):u?u(v):a(void 0,v,x)}}}runSync(i,l){let a=!1,o;return this.run(i,l,f),Ky("runSync","run",a),o;function f(u,p){Fy(u),o=p,a=!0}}stringify(i,l){this.freeze();const a=Zs(l),o=this.compiler||this.Compiler;return kf("stringify",o),Xy(i),o(i,a)}use(i,...l){const a=this.attachers,o=this.namespace;if(Cf("use",this.frozen),i!=null)if(typeof i=="function")h(i,l);else if(typeof i=="object")Array.isArray(i)?p(i):u(i);else throw new TypeError("Expected usable value, not `"+i+"`");return this;function f(m){if(typeof m=="function")h(m,[]);else if(typeof m=="object")if(Array.isArray(m)){const[y,...b]=m;h(y,b)}else u(m);else throw new TypeError("Expected usable value, not `"+m+"`")}function u(m){if(!("plugins"in m)&&!("settings"in m))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");p(m.plugins),m.settings&&(o.settings=vf(!0,o.settings,m.settings))}function p(m){let y=-1;if(m!=null)if(Array.isArray(m))for(;++y<m.length;){const b=m[y];f(b)}else throw new TypeError("Expected a list of plugins, not `"+m+"`")}function h(m,y){let b=-1,x=-1;for(;++b<a.length;)if(a[b][0]===m){x=b;break}if(x===-1)a.push([m,...y]);else if(y.length>0){let[v,...j]=y;const z=a[x][1];Gf(z)&&Gf(v)&&(v=vf(!0,z,v)),a[x]=[m,v,...j]}}}}const AE=new Sd().freeze();function jf(t,i){if(typeof i!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function kf(t,i){if(typeof i!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function Cf(t,i){if(i)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Xy(t){if(!Gf(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function Ky(t,i,l){if(!l)throw new Error("`"+t+"` finished async. Use `"+i+"` instead")}function Zs(t){return TE(t)?t:new mv(t)}function TE(t){return!!(t&&typeof t=="object"&&"message"in t&&"messages"in t)}function RE(t){return typeof t=="string"||zE(t)}function zE(t){return!!(t&&typeof t=="object"&&"byteLength"in t&&"byteOffset"in t)}const DE="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Py=[],Zy={allowDangerousHtml:!0},_E=/^(https?|ircs?|mailto|xmpp)$/i,ME=[{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 OE(t){const i=LE(t),l=BE(t);return UE(i.runSync(i.parse(l),l),t)}function LE(t){const i=t.rehypePlugins||Py,l=t.remarkPlugins||Py,a=t.remarkRehypeOptions?{...t.remarkRehypeOptions,...Zy}:Zy;return AE().use(mC).use(l).use(cE,a).use(i)}function BE(t){const i=t.children||"",l=new mv;return typeof i=="string"&&(l.value=i),l}function UE(t,i){const l=i.allowedElements,a=i.allowElement,o=i.components,f=i.disallowedElements,u=i.skipHtml,p=i.unwrapDisallowed,h=i.urlTransform||IE;for(const y of ME)Object.hasOwn(i,y.from)&&(""+y.from+(y.to?"use `"+y.to+"` instead":"remove it")+DE+y.id,void 0);return i.className&&(t={type:"element",tagName:"div",properties:{className:i.className},children:t.type==="root"?t.children:[t]}),xd(t,m),Jw(t,{Fragment:c.Fragment,components:o,ignoreInvalidStyle:!0,jsx:c.jsx,jsxs:c.jsxs,passKeys:!0,passNode:!0});function m(y,b,x){if(y.type==="raw"&&x&&typeof b=="number")return u?x.children.splice(b,1):x.children[b]={type:"text",value:y.value},b;if(y.type==="element"){let v;for(v in mf)if(Object.hasOwn(mf,v)&&Object.hasOwn(y.properties,v)){const j=y.properties[v],z=mf[v];(z===null||z.includes(y.tagName))&&(y.properties[v]=h(String(j||""),v,y))}}if(y.type==="element"){let v=l?!l.includes(y.tagName):f?f.includes(y.tagName):!1;if(!v&&a&&typeof b=="number"&&(v=!a(y,b,x)),v&&x&&typeof b=="number")return p&&y.children?x.children.splice(b,1,...y.children):x.children.splice(b,1),b}}}function IE(t){const i=t.indexOf(":"),l=t.indexOf("?"),a=t.indexOf("#"),o=t.indexOf("/");return i===-1||o!==-1&&i>o||l!==-1&&i>l||a!==-1&&i>a||_E.test(t.slice(0,i))?t:""}function Jy(t,i){const l=String(t);if(typeof i!="string")throw new TypeError("Expected character");let a=0,o=l.indexOf(i);for(;o!==-1;)a++,o=l.indexOf(i,o+i.length);return a}function qE(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function HE(t,i,l){const o=yo((l||{}).ignore||[]),f=VE(i);let u=-1;for(;++u<f.length;)pv(t,"text",p);function p(m,y){let b=-1,x;for(;++b<y.length;){const v=y[b],j=x?x.children:void 0;if(o(v,j?j.indexOf(v):void 0,x))return;x=v}if(x)return h(m,y)}function h(m,y){const b=y[y.length-1],x=f[u][0],v=f[u][1];let j=0;const A=b.children.indexOf(m);let N=!1,T=[];x.lastIndex=0;let M=x.exec(m.value);for(;M;){const G=M.index,ae={index:M.index,input:M.input,stack:[...y,m]};let D=v(...M,ae);if(typeof D=="string"&&(D=D.length>0?{type:"text",value:D}:void 0),D===!1?x.lastIndex=G+1:(j!==G&&T.push({type:"text",value:m.value.slice(j,G)}),Array.isArray(D)?T.push(...D):D&&T.push(D),j=G+M[0].length,N=!0),!x.global)break;M=x.exec(m.value)}return N?(j<m.value.length&&T.push({type:"text",value:m.value.slice(j)}),b.children.splice(A,1,...T)):T=[m],A+T.length}}function VE(t){const i=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const l=!t[0]||Array.isArray(t[0])?t:[t];let a=-1;for(;++a<l.length;){const o=l[a];i.push([YE(o[0]),GE(o[1])])}return i}function YE(t){return typeof t=="string"?new RegExp(qE(t),"g"):t}function GE(t){return typeof t=="function"?t:function(){return t}}const Ef="phrasing",Nf=["autolink","link","image","label"];function FE(){return{transforms:[JE],enter:{literalAutolink:QE,literalAutolinkEmail:Af,literalAutolinkHttp:Af,literalAutolinkWww:Af},exit:{literalAutolink:ZE,literalAutolinkEmail:PE,literalAutolinkHttp:XE,literalAutolinkWww:KE}}}function $E(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Ef,notInConstruct:Nf},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Ef,notInConstruct:Nf},{character:":",before:"[ps]",after:"\\/",inConstruct:Ef,notInConstruct:Nf}]}}function QE(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function Af(t){this.config.enter.autolinkProtocol.call(this,t)}function XE(t){this.config.exit.autolinkProtocol.call(this,t)}function KE(t){this.config.exit.data.call(this,t);const i=this.stack[this.stack.length-1];i.type,i.url="http://"+this.sliceSerialize(t)}function PE(t){this.config.exit.autolinkEmail.call(this,t)}function ZE(t){this.exit(t)}function JE(t){HE(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,WE],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),e2]],{ignore:["link","linkReference"]})}function WE(t,i,l,a,o){let f="";if(!gv(o)||(/^w/i.test(i)&&(l=i+l,i="",f="http://"),!t2(l)))return!1;const u=n2(l+a);if(!u[0])return!1;const p={type:"link",title:null,url:f+i+u[0],children:[{type:"text",value:i+u[0]}]};return u[1]?[p,{type:"text",value:u[1]}]:p}function e2(t,i,l,a){return!gv(a,!0)||/[-\d_]$/.test(l)?!1:{type:"link",title:null,url:"mailto:"+i+"@"+l,children:[{type:"text",value:i+"@"+l}]}}function t2(t){const i=t.split(".");return!(i.length<2||i[i.length-1]&&(/_/.test(i[i.length-1])||!/[a-zA-Z\d]/.test(i[i.length-1]))||i[i.length-2]&&(/_/.test(i[i.length-2])||!/[a-zA-Z\d]/.test(i[i.length-2])))}function n2(t){const i=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!i)return[t,void 0];t=t.slice(0,i.index);let l=i[0],a=l.indexOf(")");const o=Jy(t,"(");let f=Jy(t,")");for(;a!==-1&&o>f;)t+=l.slice(0,a+1),l=l.slice(a+1),a=l.indexOf(")"),f++;return[t,l]}function gv(t,i){const l=t.input.charCodeAt(t.index-1);return(t.index===0||yr(l)||po(l))&&(!i||l!==47)}yv.peek=f2;function i2(){this.buffer()}function r2(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function l2(){this.buffer()}function a2(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function s2(t){const i=this.resume(),l=this.stack[this.stack.length-1];l.type,l.identifier=Yn(this.sliceSerialize(t)).toLowerCase(),l.label=i}function o2(t){this.exit(t)}function u2(t){const i=this.resume(),l=this.stack[this.stack.length-1];l.type,l.identifier=Yn(this.sliceSerialize(t)).toLowerCase(),l.label=i}function c2(t){this.exit(t)}function f2(){return"["}function yv(t,i,l,a){const o=l.createTracker(a);let f=o.move("[^");const u=l.enter("footnoteReference"),p=l.enter("reference");return f+=o.move(l.safe(l.associationId(t),{after:"]",before:f})),p(),u(),f+=o.move("]"),f}function d2(){return{enter:{gfmFootnoteCallString:i2,gfmFootnoteCall:r2,gfmFootnoteDefinitionLabelString:l2,gfmFootnoteDefinition:a2},exit:{gfmFootnoteCallString:s2,gfmFootnoteCall:o2,gfmFootnoteDefinitionLabelString:u2,gfmFootnoteDefinition:c2}}}function h2(t){let i=!1;return t&&t.firstLineBlank&&(i=!0),{handlers:{footnoteDefinition:l,footnoteReference:yv},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function l(a,o,f,u){const p=f.createTracker(u);let h=p.move("[^");const m=f.enter("footnoteDefinition"),y=f.enter("label");return h+=p.move(f.safe(f.associationId(a),{before:h,after:"]"})),y(),h+=p.move("]:"),a.children&&a.children.length>0&&(p.shift(4),h+=p.move((i?`
42
+ `:" ")+f.indentLines(f.containerFlow(a,p.current()),i?bv:p2))),m(),h}}function p2(t,i,l){return i===0?t:bv(t,i,l)}function bv(t,i,l){return(l?"":" ")+t}const m2=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];vv.peek=x2;function g2(){return{canContainEols:["delete"],enter:{strikethrough:b2},exit:{strikethrough:v2}}}function y2(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:m2}],handlers:{delete:vv}}}function b2(t){this.enter({type:"delete",children:[]},t)}function v2(t){this.exit(t)}function vv(t,i,l,a){const o=l.createTracker(a),f=l.enter("strikethrough");let u=o.move("~~");return u+=l.containerPhrasing(t,{...o.current(),before:u,after:"~"}),u+=o.move("~~"),f(),u}function x2(){return"~"}function S2(t){return t.length}function w2(t,i){const l=i||{},a=(l.align||[]).concat(),o=l.stringLength||S2,f=[],u=[],p=[],h=[];let m=0,y=-1;for(;++y<t.length;){const z=[],A=[];let N=-1;for(t[y].length>m&&(m=t[y].length);++N<t[y].length;){const T=j2(t[y][N]);if(l.alignDelimiters!==!1){const M=o(T);A[N]=M,(h[N]===void 0||M>h[N])&&(h[N]=M)}z.push(T)}u[y]=z,p[y]=A}let b=-1;if(typeof a=="object"&&"length"in a)for(;++b<m;)f[b]=Wy(a[b]);else{const z=Wy(a);for(;++b<m;)f[b]=z}b=-1;const x=[],v=[];for(;++b<m;){const z=f[b];let A="",N="";z===99?(A=":",N=":"):z===108?A=":":z===114&&(N=":");let T=l.alignDelimiters===!1?1:Math.max(1,h[b]-A.length-N.length);const M=A+"-".repeat(T)+N;l.alignDelimiters!==!1&&(T=A.length+T+N.length,T>h[b]&&(h[b]=T),v[b]=T),x[b]=M}u.splice(1,0,x),p.splice(1,0,v),y=-1;const j=[];for(;++y<u.length;){const z=u[y],A=p[y];b=-1;const N=[];for(;++b<m;){const T=z[b]||"";let M="",G="";if(l.alignDelimiters!==!1){const ae=h[b]-(A[b]||0),D=f[b];D===114?M=" ".repeat(ae):D===99?ae%2?(M=" ".repeat(ae/2+.5),G=" ".repeat(ae/2-.5)):(M=" ".repeat(ae/2),G=M):G=" ".repeat(ae)}l.delimiterStart!==!1&&!b&&N.push("|"),l.padding!==!1&&!(l.alignDelimiters===!1&&T==="")&&(l.delimiterStart!==!1||b)&&N.push(" "),l.alignDelimiters!==!1&&N.push(M),N.push(T),l.alignDelimiters!==!1&&N.push(G),l.padding!==!1&&N.push(" "),(l.delimiterEnd!==!1||b!==m-1)&&N.push("|")}j.push(l.delimiterEnd===!1?N.join("").replace(/ +$/,""):N.join(""))}return j.join(`
43
+ `)}function j2(t){return t==null?"":String(t)}function Wy(t){const i=typeof t=="string"?t.codePointAt(0):0;return i===67||i===99?99:i===76||i===108?108:i===82||i===114?114:0}function k2(t,i,l,a){const o=l.enter("blockquote"),f=l.createTracker(a);f.move("> "),f.shift(2);const u=l.indentLines(l.containerFlow(t,f.current()),C2);return o(),u}function C2(t,i,l){return">"+(l?"":" ")+t}function E2(t,i){return eb(t,i.inConstruct,!0)&&!eb(t,i.notInConstruct,!1)}function eb(t,i,l){if(typeof i=="string"&&(i=[i]),!i||i.length===0)return l;let a=-1;for(;++a<i.length;)if(t.includes(i[a]))return!0;return!1}function tb(t,i,l,a){let o=-1;for(;++o<l.unsafe.length;)if(l.unsafe[o].character===`
44
+ `&&E2(l.stack,l.unsafe[o]))return/[ \t]/.test(a.before)?"":" ";return`\\
45
+ `}function N2(t,i){const l=String(t);let a=l.indexOf(i),o=a,f=0,u=0;if(typeof i!="string")throw new TypeError("Expected substring");for(;a!==-1;)a===o?++f>u&&(u=f):f=1,o=a+i.length,a=l.indexOf(i,o);return u}function A2(t,i){return!!(i.options.fences===!1&&t.value&&!t.lang&&/[^ \r\n]/.test(t.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(t.value))}function T2(t){const i=t.options.fence||"`";if(i!=="`"&&i!=="~")throw new Error("Cannot serialize code with `"+i+"` for `options.fence`, expected `` ` `` or `~`");return i}function R2(t,i,l,a){const o=T2(l),f=t.value||"",u=o==="`"?"GraveAccent":"Tilde";if(A2(t,l)){const b=l.enter("codeIndented"),x=l.indentLines(f,z2);return b(),x}const p=l.createTracker(a),h=o.repeat(Math.max(N2(f,o)+1,3)),m=l.enter("codeFenced");let y=p.move(h);if(t.lang){const b=l.enter(`codeFencedLang${u}`);y+=p.move(l.safe(t.lang,{before:y,after:" ",encode:["`"],...p.current()})),b()}if(t.lang&&t.meta){const b=l.enter(`codeFencedMeta${u}`);y+=p.move(" "),y+=p.move(l.safe(t.meta,{before:y,after:`
46
+ `,encode:["`"],...p.current()})),b()}return y+=p.move(`
47
+ `),f&&(y+=p.move(f+`
48
+ `)),y+=p.move(h),m(),y}function z2(t,i,l){return(l?"":" ")+t}function wd(t){const i=t.options.quote||'"';if(i!=='"'&&i!=="'")throw new Error("Cannot serialize title with `"+i+"` for `options.quote`, expected `\"`, or `'`");return i}function D2(t,i,l,a){const o=wd(l),f=o==='"'?"Quote":"Apostrophe",u=l.enter("definition");let p=l.enter("label");const h=l.createTracker(a);let m=h.move("[");return m+=h.move(l.safe(l.associationId(t),{before:m,after:"]",...h.current()})),m+=h.move("]: "),p(),!t.url||/[\0- \u007F]/.test(t.url)?(p=l.enter("destinationLiteral"),m+=h.move("<"),m+=h.move(l.safe(t.url,{before:m,after:">",...h.current()})),m+=h.move(">")):(p=l.enter("destinationRaw"),m+=h.move(l.safe(t.url,{before:m,after:t.title?" ":`
49
+ `,...h.current()}))),p(),t.title&&(p=l.enter(`title${f}`),m+=h.move(" "+o),m+=h.move(l.safe(t.title,{before:m,after:o,...h.current()})),m+=h.move(o),p()),u(),m}function _2(t){const i=t.options.emphasis||"*";if(i!=="*"&&i!=="_")throw new Error("Cannot serialize emphasis with `"+i+"` for `options.emphasis`, expected `*`, or `_`");return i}function ja(t){return"&#x"+t.toString(16).toUpperCase()+";"}function uo(t,i,l){const a=dl(t),o=dl(i);return a===void 0?o===void 0?l==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:o===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:a===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}}xv.peek=M2;function xv(t,i,l,a){const o=_2(l),f=l.enter("emphasis"),u=l.createTracker(a),p=u.move(o);let h=u.move(l.containerPhrasing(t,{after:o,before:p,...u.current()}));const m=h.charCodeAt(0),y=uo(a.before.charCodeAt(a.before.length-1),m,o);y.inside&&(h=ja(m)+h.slice(1));const b=h.charCodeAt(h.length-1),x=uo(a.after.charCodeAt(0),b,o);x.inside&&(h=h.slice(0,-1)+ja(b));const v=u.move(o);return f(),l.attentionEncodeSurroundingInfo={after:x.outside,before:y.outside},p+h+v}function M2(t,i,l){return l.options.emphasis||"*"}function O2(t,i){let l=!1;return xd(t,function(a){if("value"in a&&/\r?\n|\r/.test(a.value)||a.type==="break")return l=!0,Vf}),!!((!t.depth||t.depth<3)&&hd(t)&&(i.options.setext||l))}function L2(t,i,l,a){const o=Math.max(Math.min(6,t.depth||1),1),f=l.createTracker(a);if(O2(t,l)){const y=l.enter("headingSetext"),b=l.enter("phrasing"),x=l.containerPhrasing(t,{...f.current(),before:`
50
+ `,after:`
51
+ `});return b(),y(),x+`
52
+ `+(o===1?"=":"-").repeat(x.length-(Math.max(x.lastIndexOf("\r"),x.lastIndexOf(`
53
+ `))+1))}const u="#".repeat(o),p=l.enter("headingAtx"),h=l.enter("phrasing");f.move(u+" ");let m=l.containerPhrasing(t,{before:"# ",after:`
54
+ `,...f.current()});return/^[\t ]/.test(m)&&(m=ja(m.charCodeAt(0))+m.slice(1)),m=m?u+" "+m:u,l.options.closeAtx&&(m+=" "+u),h(),p(),m}Sv.peek=B2;function Sv(t){return t.value||""}function B2(){return"<"}wv.peek=U2;function wv(t,i,l,a){const o=wd(l),f=o==='"'?"Quote":"Apostrophe",u=l.enter("image");let p=l.enter("label");const h=l.createTracker(a);let m=h.move("![");return m+=h.move(l.safe(t.alt,{before:m,after:"]",...h.current()})),m+=h.move("]("),p(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(p=l.enter("destinationLiteral"),m+=h.move("<"),m+=h.move(l.safe(t.url,{before:m,after:">",...h.current()})),m+=h.move(">")):(p=l.enter("destinationRaw"),m+=h.move(l.safe(t.url,{before:m,after:t.title?" ":")",...h.current()}))),p(),t.title&&(p=l.enter(`title${f}`),m+=h.move(" "+o),m+=h.move(l.safe(t.title,{before:m,after:o,...h.current()})),m+=h.move(o),p()),m+=h.move(")"),u(),m}function U2(){return"!"}jv.peek=I2;function jv(t,i,l,a){const o=t.referenceType,f=l.enter("imageReference");let u=l.enter("label");const p=l.createTracker(a);let h=p.move("![");const m=l.safe(t.alt,{before:h,after:"]",...p.current()});h+=p.move(m+"]["),u();const y=l.stack;l.stack=[],u=l.enter("reference");const b=l.safe(l.associationId(t),{before:h,after:"]",...p.current()});return u(),l.stack=y,f(),o==="full"||!m||m!==b?h+=p.move(b+"]"):o==="shortcut"?h=h.slice(0,-1):h+=p.move("]"),h}function I2(){return"!"}kv.peek=q2;function kv(t,i,l){let a=t.value||"",o="`",f=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(a);)o+="`";for(/[^ \r\n]/.test(a)&&(/^[ \r\n]/.test(a)&&/[ \r\n]$/.test(a)||/^`|`$/.test(a))&&(a=" "+a+" ");++f<l.unsafe.length;){const u=l.unsafe[f],p=l.compilePattern(u);let h;if(u.atBreak)for(;h=p.exec(a);){let m=h.index;a.charCodeAt(m)===10&&a.charCodeAt(m-1)===13&&m--,a=a.slice(0,m)+" "+a.slice(h.index+1)}}return o+a+o}function q2(){return"`"}function Cv(t,i){const l=hd(t);return!!(!i.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(l===t.url||"mailto:"+l===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}Ev.peek=H2;function Ev(t,i,l,a){const o=wd(l),f=o==='"'?"Quote":"Apostrophe",u=l.createTracker(a);let p,h;if(Cv(t,l)){const y=l.stack;l.stack=[],p=l.enter("autolink");let b=u.move("<");return b+=u.move(l.containerPhrasing(t,{before:b,after:">",...u.current()})),b+=u.move(">"),p(),l.stack=y,b}p=l.enter("link"),h=l.enter("label");let m=u.move("[");return m+=u.move(l.containerPhrasing(t,{before:m,after:"](",...u.current()})),m+=u.move("]("),h(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(h=l.enter("destinationLiteral"),m+=u.move("<"),m+=u.move(l.safe(t.url,{before:m,after:">",...u.current()})),m+=u.move(">")):(h=l.enter("destinationRaw"),m+=u.move(l.safe(t.url,{before:m,after:t.title?" ":")",...u.current()}))),h(),t.title&&(h=l.enter(`title${f}`),m+=u.move(" "+o),m+=u.move(l.safe(t.title,{before:m,after:o,...u.current()})),m+=u.move(o),h()),m+=u.move(")"),p(),m}function H2(t,i,l){return Cv(t,l)?"<":"["}Nv.peek=V2;function Nv(t,i,l,a){const o=t.referenceType,f=l.enter("linkReference");let u=l.enter("label");const p=l.createTracker(a);let h=p.move("[");const m=l.containerPhrasing(t,{before:h,after:"]",...p.current()});h+=p.move(m+"]["),u();const y=l.stack;l.stack=[],u=l.enter("reference");const b=l.safe(l.associationId(t),{before:h,after:"]",...p.current()});return u(),l.stack=y,f(),o==="full"||!m||m!==b?h+=p.move(b+"]"):o==="shortcut"?h=h.slice(0,-1):h+=p.move("]"),h}function V2(){return"["}function jd(t){const i=t.options.bullet||"*";if(i!=="*"&&i!=="+"&&i!=="-")throw new Error("Cannot serialize items with `"+i+"` for `options.bullet`, expected `*`, `+`, or `-`");return i}function Y2(t){const i=jd(t),l=t.options.bulletOther;if(!l)return i==="*"?"-":"*";if(l!=="*"&&l!=="+"&&l!=="-")throw new Error("Cannot serialize items with `"+l+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(l===i)throw new Error("Expected `bullet` (`"+i+"`) and `bulletOther` (`"+l+"`) to be different");return l}function G2(t){const i=t.options.bulletOrdered||".";if(i!=="."&&i!==")")throw new Error("Cannot serialize items with `"+i+"` for `options.bulletOrdered`, expected `.` or `)`");return i}function Av(t){const i=t.options.rule||"*";if(i!=="*"&&i!=="-"&&i!=="_")throw new Error("Cannot serialize rules with `"+i+"` for `options.rule`, expected `*`, `-`, or `_`");return i}function F2(t,i,l,a){const o=l.enter("list"),f=l.bulletCurrent;let u=t.ordered?G2(l):jd(l);const p=t.ordered?u==="."?")":".":Y2(l);let h=i&&l.bulletLastUsed?u===l.bulletLastUsed:!1;if(!t.ordered){const y=t.children?t.children[0]:void 0;if((u==="*"||u==="-")&&y&&(!y.children||!y.children[0])&&l.stack[l.stack.length-1]==="list"&&l.stack[l.stack.length-2]==="listItem"&&l.stack[l.stack.length-3]==="list"&&l.stack[l.stack.length-4]==="listItem"&&l.indexStack[l.indexStack.length-1]===0&&l.indexStack[l.indexStack.length-2]===0&&l.indexStack[l.indexStack.length-3]===0&&(h=!0),Av(l)===u&&y){let b=-1;for(;++b<t.children.length;){const x=t.children[b];if(x&&x.type==="listItem"&&x.children&&x.children[0]&&x.children[0].type==="thematicBreak"){h=!0;break}}}}h&&(u=p),l.bulletCurrent=u;const m=l.containerFlow(t,a);return l.bulletLastUsed=u,l.bulletCurrent=f,o(),m}function $2(t){const i=t.options.listItemIndent||"one";if(i!=="tab"&&i!=="one"&&i!=="mixed")throw new Error("Cannot serialize items with `"+i+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return i}function Q2(t,i,l,a){const o=$2(l);let f=l.bulletCurrent||jd(l);i&&i.type==="list"&&i.ordered&&(f=(typeof i.start=="number"&&i.start>-1?i.start:1)+(l.options.incrementListMarker===!1?0:i.children.indexOf(t))+f);let u=f.length+1;(o==="tab"||o==="mixed"&&(i&&i.type==="list"&&i.spread||t.spread))&&(u=Math.ceil(u/4)*4);const p=l.createTracker(a);p.move(f+" ".repeat(u-f.length)),p.shift(u);const h=l.enter("listItem"),m=l.indentLines(l.containerFlow(t,p.current()),y);return h(),m;function y(b,x,v){return x?(v?"":" ".repeat(u))+b:(v?f:f+" ".repeat(u-f.length))+b}}function X2(t,i,l,a){const o=l.enter("paragraph"),f=l.enter("phrasing"),u=l.containerPhrasing(t,a);return f(),o(),u}const K2=yo(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function P2(t,i,l,a){return(t.children.some(function(u){return K2(u)})?l.containerPhrasing:l.containerFlow).call(l,t,a)}function Z2(t){const i=t.options.strong||"*";if(i!=="*"&&i!=="_")throw new Error("Cannot serialize strong with `"+i+"` for `options.strong`, expected `*`, or `_`");return i}Tv.peek=J2;function Tv(t,i,l,a){const o=Z2(l),f=l.enter("strong"),u=l.createTracker(a),p=u.move(o+o);let h=u.move(l.containerPhrasing(t,{after:o,before:p,...u.current()}));const m=h.charCodeAt(0),y=uo(a.before.charCodeAt(a.before.length-1),m,o);y.inside&&(h=ja(m)+h.slice(1));const b=h.charCodeAt(h.length-1),x=uo(a.after.charCodeAt(0),b,o);x.inside&&(h=h.slice(0,-1)+ja(b));const v=u.move(o+o);return f(),l.attentionEncodeSurroundingInfo={after:x.outside,before:y.outside},p+h+v}function J2(t,i,l){return l.options.strong||"*"}function W2(t,i,l,a){return l.safe(t.value,a)}function eN(t){const i=t.options.ruleRepetition||3;if(i<3)throw new Error("Cannot serialize rules with repetition `"+i+"` for `options.ruleRepetition`, expected `3` or more");return i}function tN(t,i,l){const a=(Av(l)+(l.options.ruleSpaces?" ":"")).repeat(eN(l));return l.options.ruleSpaces?a.slice(0,-1):a}const Rv={blockquote:k2,break:tb,code:R2,definition:D2,emphasis:xv,hardBreak:tb,heading:L2,html:Sv,image:wv,imageReference:jv,inlineCode:kv,link:Ev,linkReference:Nv,list:F2,listItem:Q2,paragraph:X2,root:P2,strong:Tv,text:W2,thematicBreak:tN};function nN(){return{enter:{table:iN,tableData:nb,tableHeader:nb,tableRow:lN},exit:{codeText:aN,table:rN,tableData:Tf,tableHeader:Tf,tableRow:Tf}}}function iN(t){const i=t._align;this.enter({type:"table",align:i.map(function(l){return l==="none"?null:l}),children:[]},t),this.data.inTable=!0}function rN(t){this.exit(t),this.data.inTable=void 0}function lN(t){this.enter({type:"tableRow",children:[]},t)}function Tf(t){this.exit(t)}function nb(t){this.enter({type:"tableCell",children:[]},t)}function aN(t){let i=this.resume();this.data.inTable&&(i=i.replace(/\\([\\|])/g,sN));const l=this.stack[this.stack.length-1];l.type,l.value=i,this.exit(t)}function sN(t,i){return i==="|"?i:t}function oN(t){const i=t||{},l=i.tableCellPadding,a=i.tablePipeAlign,o=i.stringLength,f=l?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
55
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:x,table:u,tableCell:h,tableRow:p}};function u(v,j,z,A){return m(y(v,z,A),v.align)}function p(v,j,z,A){const N=b(v,z,A),T=m([N]);return T.slice(0,T.indexOf(`
56
+ `))}function h(v,j,z,A){const N=z.enter("tableCell"),T=z.enter("phrasing"),M=z.containerPhrasing(v,{...A,before:f,after:f});return T(),N(),M}function m(v,j){return w2(v,{align:j,alignDelimiters:a,padding:l,stringLength:o})}function y(v,j,z){const A=v.children;let N=-1;const T=[],M=j.enter("table");for(;++N<A.length;)T[N]=b(A[N],j,z);return M(),T}function b(v,j,z){const A=v.children;let N=-1;const T=[],M=j.enter("tableRow");for(;++N<A.length;)T[N]=h(A[N],v,j,z);return M(),T}function x(v,j,z){let A=Rv.inlineCode(v,j,z);return z.stack.includes("tableCell")&&(A=A.replace(/\|/g,"\\$&")),A}}function uN(){return{exit:{taskListCheckValueChecked:ib,taskListCheckValueUnchecked:ib,paragraph:fN}}}function cN(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:dN}}}function ib(t){const i=this.stack[this.stack.length-2];i.type,i.checked=t.type==="taskListCheckValueChecked"}function fN(t){const i=this.stack[this.stack.length-2];if(i&&i.type==="listItem"&&typeof i.checked=="boolean"){const l=this.stack[this.stack.length-1];l.type;const a=l.children[0];if(a&&a.type==="text"){const o=i.children;let f=-1,u;for(;++f<o.length;){const p=o[f];if(p.type==="paragraph"){u=p;break}}u===l&&(a.value=a.value.slice(1),a.value.length===0?l.children.shift():l.position&&a.position&&typeof a.position.start.offset=="number"&&(a.position.start.column++,a.position.start.offset++,l.position.start=Object.assign({},a.position.start)))}}this.exit(t)}function dN(t,i,l,a){const o=t.children[0],f=typeof t.checked=="boolean"&&o&&o.type==="paragraph",u="["+(t.checked?"x":" ")+"] ",p=l.createTracker(a);f&&p.move(u);let h=Rv.listItem(t,i,l,{...a,...p.current()});return f&&(h=h.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,m)),h;function m(y){return y+u}}function hN(){return[FE(),d2(),g2(),nN(),uN()]}function pN(t){return{extensions:[$E(),h2(t),y2(),oN(t),cN()]}}const mN={tokenize:SN,partial:!0},zv={tokenize:wN,partial:!0},Dv={tokenize:jN,partial:!0},_v={tokenize:kN,partial:!0},gN={tokenize:CN,partial:!0},Mv={name:"wwwAutolink",tokenize:vN,previous:Lv},Ov={name:"protocolAutolink",tokenize:xN,previous:Bv},Si={name:"emailAutolink",tokenize:bN,previous:Uv},Jn={};function yN(){return{text:Jn}}let hr=48;for(;hr<123;)Jn[hr]=Si,hr++,hr===58?hr=65:hr===91&&(hr=97);Jn[43]=Si;Jn[45]=Si;Jn[46]=Si;Jn[95]=Si;Jn[72]=[Si,Ov];Jn[104]=[Si,Ov];Jn[87]=[Si,Mv];Jn[119]=[Si,Mv];function bN(t,i,l){const a=this;let o,f;return u;function u(b){return!$f(b)||!Uv.call(a,a.previous)||kd(a.events)?l(b):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),p(b))}function p(b){return $f(b)?(t.consume(b),p):b===64?(t.consume(b),h):l(b)}function h(b){return b===46?t.check(gN,y,m)(b):b===45||b===95||ln(b)?(f=!0,t.consume(b),h):y(b)}function m(b){return t.consume(b),o=!0,h}function y(b){return f&&o&&on(a.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),i(b)):l(b)}}function vN(t,i,l){const a=this;return o;function o(u){return u!==87&&u!==119||!Lv.call(a,a.previous)||kd(a.events)?l(u):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(mN,t.attempt(zv,t.attempt(Dv,f),l),l)(u))}function f(u){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),i(u)}}function xN(t,i,l){const a=this;let o="",f=!1;return u;function u(b){return(b===72||b===104)&&Bv.call(a,a.previous)&&!kd(a.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),o+=String.fromCodePoint(b),t.consume(b),p):l(b)}function p(b){if(on(b)&&o.length<5)return o+=String.fromCodePoint(b),t.consume(b),p;if(b===58){const x=o.toLowerCase();if(x==="http"||x==="https")return t.consume(b),h}return l(b)}function h(b){return b===47?(t.consume(b),f?m:(f=!0,h)):l(b)}function m(b){return b===null||ao(b)||Nt(b)||yr(b)||po(b)?l(b):t.attempt(zv,t.attempt(Dv,y),l)(b)}function y(b){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),i(b)}}function SN(t,i,l){let a=0;return o;function o(u){return(u===87||u===119)&&a<3?(a++,t.consume(u),o):u===46&&a===3?(t.consume(u),f):l(u)}function f(u){return u===null?l(u):i(u)}}function wN(t,i,l){let a,o,f;return u;function u(m){return m===46||m===95?t.check(_v,h,p)(m):m===null||Nt(m)||yr(m)||m!==45&&po(m)?h(m):(f=!0,t.consume(m),u)}function p(m){return m===95?a=!0:(o=a,a=void 0),t.consume(m),u}function h(m){return o||a||!f?l(m):i(m)}}function jN(t,i){let l=0,a=0;return o;function o(u){return u===40?(l++,t.consume(u),o):u===41&&a<l?f(u):u===33||u===34||u===38||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===60||u===63||u===93||u===95||u===126?t.check(_v,i,f)(u):u===null||Nt(u)||yr(u)?i(u):(t.consume(u),o)}function f(u){return u===41&&a++,t.consume(u),o}}function kN(t,i,l){return a;function a(p){return p===33||p===34||p===39||p===41||p===42||p===44||p===46||p===58||p===59||p===63||p===95||p===126?(t.consume(p),a):p===38?(t.consume(p),f):p===93?(t.consume(p),o):p===60||p===null||Nt(p)||yr(p)?i(p):l(p)}function o(p){return p===null||p===40||p===91||Nt(p)||yr(p)?i(p):a(p)}function f(p){return on(p)?u(p):l(p)}function u(p){return p===59?(t.consume(p),a):on(p)?(t.consume(p),u):l(p)}}function CN(t,i,l){return a;function a(f){return t.consume(f),o}function o(f){return ln(f)?l(f):i(f)}}function Lv(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Nt(t)}function Bv(t){return!on(t)}function Uv(t){return!(t===47||$f(t))}function $f(t){return t===43||t===45||t===46||t===95||ln(t)}function kd(t){let i=t.length,l=!1;for(;i--;){const a=t[i][1];if((a.type==="labelLink"||a.type==="labelImage")&&!a._balanced){l=!0;break}if(a._gfmAutolinkLiteralWalkedInto){l=!1;break}}return t.length>0&&!l&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),l}const EN={tokenize:MN,partial:!0};function NN(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:zN,continuation:{tokenize:DN},exit:_N}},text:{91:{name:"gfmFootnoteCall",tokenize:RN},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:AN,resolveTo:TN}}}}function AN(t,i,l){const a=this;let o=a.events.length;const f=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let u;for(;o--;){const h=a.events[o][1];if(h.type==="labelImage"){u=h;break}if(h.type==="gfmFootnoteCall"||h.type==="labelLink"||h.type==="label"||h.type==="image"||h.type==="link")break}return p;function p(h){if(!u||!u._balanced)return l(h);const m=Yn(a.sliceSerialize({start:u.end,end:a.now()}));return m.codePointAt(0)!==94||!f.includes(m.slice(1))?l(h):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(h),t.exit("gfmFootnoteCallLabelMarker"),i(h))}}function TN(t,i){let l=t.length;for(;l--;)if(t[l][1].type==="labelImage"&&t[l][0]==="enter"){t[l][1];break}t[l+1][1].type="data",t[l+3][1].type="gfmFootnoteCallLabelMarker";const a={type:"gfmFootnoteCall",start:Object.assign({},t[l+3][1].start),end:Object.assign({},t[t.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},t[l+3][1].end),end:Object.assign({},t[l+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const f={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},t[t.length-1][1].start)},u={type:"chunkString",contentType:"string",start:Object.assign({},f.start),end:Object.assign({},f.end)},p=[t[l+1],t[l+2],["enter",a,i],t[l+3],t[l+4],["enter",o,i],["exit",o,i],["enter",f,i],["enter",u,i],["exit",u,i],["exit",f,i],t[t.length-2],t[t.length-1],["exit",a,i]];return t.splice(l,t.length-l+1,...p),t}function RN(t,i,l){const a=this,o=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let f=0,u;return p;function p(b){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(b),t.exit("gfmFootnoteCallLabelMarker"),h}function h(b){return b!==94?l(b):(t.enter("gfmFootnoteCallMarker"),t.consume(b),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",m)}function m(b){if(f>999||b===93&&!u||b===null||b===91||Nt(b))return l(b);if(b===93){t.exit("chunkString");const x=t.exit("gfmFootnoteCallString");return o.includes(Yn(a.sliceSerialize(x)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(b),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),i):l(b)}return Nt(b)||(u=!0),f++,t.consume(b),b===92?y:m}function y(b){return b===91||b===92||b===93?(t.consume(b),f++,m):m(b)}}function zN(t,i,l){const a=this,o=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let f,u=0,p;return h;function h(j){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionLabelMarker"),m}function m(j){return j===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",y):l(j)}function y(j){if(u>999||j===93&&!p||j===null||j===91||Nt(j))return l(j);if(j===93){t.exit("chunkString");const z=t.exit("gfmFootnoteDefinitionLabelString");return f=Yn(a.sliceSerialize(z)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(j),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),x}return Nt(j)||(p=!0),u++,t.consume(j),j===92?b:y}function b(j){return j===91||j===92||j===93?(t.consume(j),u++,y):y(j)}function x(j){return j===58?(t.enter("definitionMarker"),t.consume(j),t.exit("definitionMarker"),o.includes(f)||o.push(f),at(t,v,"gfmFootnoteDefinitionWhitespace")):l(j)}function v(j){return i(j)}}function DN(t,i,l){return t.check(Na,i,t.attempt(EN,i,l))}function _N(t){t.exit("gfmFootnoteDefinition")}function MN(t,i,l){const a=this;return at(t,o,"gfmFootnoteDefinitionIndent",5);function o(f){const u=a.events[a.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?i(f):l(f)}}function ON(t){let l=(t||{}).singleTilde;const a={name:"strikethrough",tokenize:f,resolveAll:o};return l==null&&(l=!0),{text:{126:a},insideSpan:{null:[a]},attentionMarkers:{null:[126]}};function o(u,p){let h=-1;for(;++h<u.length;)if(u[h][0]==="enter"&&u[h][1].type==="strikethroughSequenceTemporary"&&u[h][1]._close){let m=h;for(;m--;)if(u[m][0]==="exit"&&u[m][1].type==="strikethroughSequenceTemporary"&&u[m][1]._open&&u[h][1].end.offset-u[h][1].start.offset===u[m][1].end.offset-u[m][1].start.offset){u[h][1].type="strikethroughSequence",u[m][1].type="strikethroughSequence";const y={type:"strikethrough",start:Object.assign({},u[m][1].start),end:Object.assign({},u[h][1].end)},b={type:"strikethroughText",start:Object.assign({},u[m][1].end),end:Object.assign({},u[h][1].start)},x=[["enter",y,p],["enter",u[m][1],p],["exit",u[m][1],p],["enter",b,p]],v=p.parser.constructs.insideSpan.null;v&&Cn(x,x.length,0,mo(v,u.slice(m+1,h),p)),Cn(x,x.length,0,[["exit",b,p],["enter",u[h][1],p],["exit",u[h][1],p],["exit",y,p]]),Cn(u,m-1,h-m+3,x),h=m+x.length-2;break}}for(h=-1;++h<u.length;)u[h][1].type==="strikethroughSequenceTemporary"&&(u[h][1].type="data");return u}function f(u,p,h){const m=this.previous,y=this.events;let b=0;return x;function x(j){return m===126&&y[y.length-1][1].type!=="characterEscape"?h(j):(u.enter("strikethroughSequenceTemporary"),v(j))}function v(j){const z=dl(m);if(j===126)return b>1?h(j):(u.consume(j),b++,v);if(b<2&&!l)return h(j);const A=u.exit("strikethroughSequenceTemporary"),N=dl(j);return A._open=!N||N===2&&!!z,A._close=!z||z===2&&!!N,p(j)}}}class LN{constructor(){this.map=[]}add(i,l,a){BN(this,i,l,a)}consume(i){if(this.map.sort(function(f,u){return f[0]-u[0]}),this.map.length===0)return;let l=this.map.length;const a=[];for(;l>0;)l-=1,a.push(i.slice(this.map[l][0]+this.map[l][1]),this.map[l][2]),i.length=this.map[l][0];a.push(i.slice()),i.length=0;let o=a.pop();for(;o;){for(const f of o)i.push(f);o=a.pop()}this.map.length=0}}function BN(t,i,l,a){let o=0;if(!(l===0&&a.length===0)){for(;o<t.map.length;){if(t.map[o][0]===i){t.map[o][1]+=l,t.map[o][2].push(...a);return}o+=1}t.map.push([i,l,a])}}function UN(t,i){let l=!1;const a=[];for(;i<t.length;){const o=t[i];if(l){if(o[0]==="enter")o[1].type==="tableContent"&&a.push(t[i+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(t[i-1][1].type==="tableDelimiterMarker"){const f=a.length-1;a[f]=a[f]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(l=!0);i+=1}return a}function IN(){return{flow:{null:{name:"table",tokenize:qN,resolveAll:HN}}}}function qN(t,i,l){const a=this;let o=0,f=0,u;return p;function p(C){let L=a.events.length-1;for(;L>-1;){const J=a.events[L][1].type;if(J==="lineEnding"||J==="linePrefix")L--;else break}const B=L>-1?a.events[L][1].type:null,Q=B==="tableHead"||B==="tableRow"?D:h;return Q===D&&a.parser.lazy[a.now().line]?l(C):Q(C)}function h(C){return t.enter("tableHead"),t.enter("tableRow"),m(C)}function m(C){return C===124||(u=!0,f+=1),y(C)}function y(C){return C===null?l(C):Be(C)?f>1?(f=0,a.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(C),t.exit("lineEnding"),v):l(C):et(C)?at(t,y,"whitespace")(C):(f+=1,u&&(u=!1,o+=1),C===124?(t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),u=!0,y):(t.enter("data"),b(C)))}function b(C){return C===null||C===124||Nt(C)?(t.exit("data"),y(C)):(t.consume(C),C===92?x:b)}function x(C){return C===92||C===124?(t.consume(C),b):b(C)}function v(C){return a.interrupt=!1,a.parser.lazy[a.now().line]?l(C):(t.enter("tableDelimiterRow"),u=!1,et(C)?at(t,j,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(C):j(C))}function j(C){return C===45||C===58?A(C):C===124?(u=!0,t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),z):ae(C)}function z(C){return et(C)?at(t,A,"whitespace")(C):A(C)}function A(C){return C===58?(f+=1,u=!0,t.enter("tableDelimiterMarker"),t.consume(C),t.exit("tableDelimiterMarker"),N):C===45?(f+=1,N(C)):C===null||Be(C)?G(C):ae(C)}function N(C){return C===45?(t.enter("tableDelimiterFiller"),T(C)):ae(C)}function T(C){return C===45?(t.consume(C),T):C===58?(u=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(C),t.exit("tableDelimiterMarker"),M):(t.exit("tableDelimiterFiller"),M(C))}function M(C){return et(C)?at(t,G,"whitespace")(C):G(C)}function G(C){return C===124?j(C):C===null||Be(C)?!u||o!==f?ae(C):(t.exit("tableDelimiterRow"),t.exit("tableHead"),i(C)):ae(C)}function ae(C){return l(C)}function D(C){return t.enter("tableRow"),H(C)}function H(C){return C===124?(t.enter("tableCellDivider"),t.consume(C),t.exit("tableCellDivider"),H):C===null||Be(C)?(t.exit("tableRow"),i(C)):et(C)?at(t,H,"whitespace")(C):(t.enter("data"),W(C))}function W(C){return C===null||C===124||Nt(C)?(t.exit("data"),H(C)):(t.consume(C),C===92?q:W)}function q(C){return C===92||C===124?(t.consume(C),W):W(C)}}function HN(t,i){let l=-1,a=!0,o=0,f=[0,0,0,0],u=[0,0,0,0],p=!1,h=0,m,y,b;const x=new LN;for(;++l<t.length;){const v=t[l],j=v[1];v[0]==="enter"?j.type==="tableHead"?(p=!1,h!==0&&(rb(x,i,h,m,y),y=void 0,h=0),m={type:"table",start:Object.assign({},j.start),end:Object.assign({},j.end)},x.add(l,0,[["enter",m,i]])):j.type==="tableRow"||j.type==="tableDelimiterRow"?(a=!0,b=void 0,f=[0,0,0,0],u=[0,l+1,0,0],p&&(p=!1,y={type:"tableBody",start:Object.assign({},j.start),end:Object.assign({},j.end)},x.add(l,0,[["enter",y,i]])),o=j.type==="tableDelimiterRow"?2:y?3:1):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")?(a=!1,u[2]===0&&(f[1]!==0&&(u[0]=u[1],b=Js(x,i,f,o,void 0,b),f=[0,0,0,0]),u[2]=l)):j.type==="tableCellDivider"&&(a?a=!1:(f[1]!==0&&(u[0]=u[1],b=Js(x,i,f,o,void 0,b)),f=u,u=[f[1],l,0,0])):j.type==="tableHead"?(p=!0,h=l):j.type==="tableRow"||j.type==="tableDelimiterRow"?(h=l,f[1]!==0?(u[0]=u[1],b=Js(x,i,f,o,l,b)):u[1]!==0&&(b=Js(x,i,u,o,l,b)),o=0):o&&(j.type==="data"||j.type==="tableDelimiterMarker"||j.type==="tableDelimiterFiller")&&(u[3]=l)}for(h!==0&&rb(x,i,h,m,y),x.consume(i.events),l=-1;++l<i.events.length;){const v=i.events[l];v[0]==="enter"&&v[1].type==="table"&&(v[1]._align=UN(i.events,l))}return t}function Js(t,i,l,a,o,f){const u=a===1?"tableHeader":a===2?"tableDelimiter":"tableData",p="tableContent";l[0]!==0&&(f.end=Object.assign({},cl(i.events,l[0])),t.add(l[0],0,[["exit",f,i]]));const h=cl(i.events,l[1]);if(f={type:u,start:Object.assign({},h),end:Object.assign({},h)},t.add(l[1],0,[["enter",f,i]]),l[2]!==0){const m=cl(i.events,l[2]),y=cl(i.events,l[3]),b={type:p,start:Object.assign({},m),end:Object.assign({},y)};if(t.add(l[2],0,[["enter",b,i]]),a!==2){const x=i.events[l[2]],v=i.events[l[3]];if(x[1].end=Object.assign({},v[1].end),x[1].type="chunkText",x[1].contentType="text",l[3]>l[2]+1){const j=l[2]+1,z=l[3]-l[2]-1;t.add(j,z,[])}}t.add(l[3]+1,0,[["exit",b,i]])}return o!==void 0&&(f.end=Object.assign({},cl(i.events,o)),t.add(o,0,[["exit",f,i]]),f=void 0),f}function rb(t,i,l,a,o){const f=[],u=cl(i.events,l);o&&(o.end=Object.assign({},u),f.push(["exit",o,i])),a.end=Object.assign({},u),f.push(["exit",a,i]),t.add(l+1,0,f)}function cl(t,i){const l=t[i],a=l[0]==="enter"?"start":"end";return l[1][a]}const VN={name:"tasklistCheck",tokenize:GN};function YN(){return{text:{91:VN}}}function GN(t,i,l){const a=this;return o;function o(h){return a.previous!==null||!a._gfmTasklistFirstContentOfListItem?l(h):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(h),t.exit("taskListCheckMarker"),f)}function f(h){return Nt(h)?(t.enter("taskListCheckValueUnchecked"),t.consume(h),t.exit("taskListCheckValueUnchecked"),u):h===88||h===120?(t.enter("taskListCheckValueChecked"),t.consume(h),t.exit("taskListCheckValueChecked"),u):l(h)}function u(h){return h===93?(t.enter("taskListCheckMarker"),t.consume(h),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),p):l(h)}function p(h){return Be(h)?i(h):et(h)?t.check({tokenize:FN},i,l)(h):l(h)}}function FN(t,i,l){return at(t,a,"whitespace");function a(o){return o===null?l(o):i(o)}}function $N(t){return Kb([yN(),NN(),ON(t),IN(),YN()])}const QN={};function XN(t){const i=this,l=t||QN,a=i.data(),o=a.micromarkExtensions||(a.micromarkExtensions=[]),f=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),u=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);o.push($N(l)),f.push(hN()),u.push(pN(l))}function Qf(t){const i=t.trim();if(!(!i||/[\u0000-\u0020\u007f]/.test(i)))try{const l=new URL(i);if(l.protocol==="https:"||l.protocol==="http:"||l.protocol==="mailto:")return i}catch{}}function Xf(t){return!!t&&!/[\u0000-\u001f\u007f]/.test(t)&&!/^[a-z][a-z\d+.-]*:/i.test(t)&&!t.startsWith("//")}function lb(t){if(!Xf(t))return;const i=t.split(/[?#]/,1)[0];if(i)try{const l=decodeURIComponent(i);return Xf(l)?l:void 0}catch{return}}async function KN(t){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(t);return}const i=document.activeElement,l=document.createElement("textarea");l.value=t,l.setAttribute("aria-label","复制内容"),l.style.cssText="position:fixed;left:-10000px;top:0",document.body.append(l);try{if(l.select(),!document.execCommand("copy"))throw new Error("复制不可用")}finally{l.remove(),i instanceof HTMLElement&&i.focus({preventScroll:!0})}}function vo({text:t,label:i="复制"}){const[l,a]=w.useState("idle"),o=w.useRef(!0),f=w.useRef(void 0);w.useEffect(()=>(o.current=!0,()=>{o.current=!1,clearTimeout(f.current)}),[]);const u=async()=>{clearTimeout(f.current);try{await KN(t),o.current&&a("copied")}catch{o.current&&a("error")}o.current&&(f.current=setTimeout(()=>a("idle"),2500))};return c.jsx("button",{className:"message-copy",onClick:()=>{u()},"aria-label":i,title:i,children:l==="copied"?"已复制":l==="error"?"复制失败":i})}function Kf(t){return typeof t=="string"||typeof t=="number"?String(t):Array.isArray(t)?t.map(Kf).join(""):w.isValidElement(t)?Kf(t.props.children):""}function PN({children:t}){const i=w.Children.toArray(t).find(f=>w.isValidElement(f)),a=(w.isValidElement(i)?i.props.className??"":"").match(/(?:^|\s)language-([\w+-]+)/)?.[1]??"代码",o=Kf(t).replace(/\n$/,"");return c.jsxs("div",{className:"message-code-block",children:[c.jsxs("div",{className:"message-code-heading",children:[c.jsx("span",{children:a}),c.jsx(vo,{text:o,label:"复制代码"})]}),c.jsx("pre",{tabIndex:0,children:t})]})}function ZN(t){return{a:({href:i,children:l,title:a})=>{const o=Qf(i??"");if(o)return c.jsx("a",{href:o,title:a,target:"_blank",rel:"noopener noreferrer",referrerPolicy:"no-referrer",children:l});const f=i?lb(i):void 0;return f?c.jsxs("span",{className:"message-file-reference",title:f,children:[t?c.jsx("button",{className:"message-file-open",onClick:()=>t(f),children:l}):l,c.jsx(vo,{text:f,label:"复制路径"})]}):c.jsx("span",{children:l})},img:({src:i,alt:l})=>{const a=Qf(typeof i=="string"?i:""),o=typeof i=="string"?lb(i):void 0;return a?c.jsxs("a",{className:"message-image-reference",href:a,target:"_blank",rel:"noopener noreferrer",referrerPolicy:"no-referrer",children:[l||"图片",c.jsx("span",{children:"打开图片 ↗"})]}):o&&t?c.jsxs("button",{className:"message-image-reference",title:o,onClick:()=>t(o),children:[l||"图片",c.jsx("span",{children:"查看图片"})]}):c.jsxs("span",{className:"message-image-reference",children:[l||"图片",c.jsx("span",{children:"图片路径不可直接访问"})]})},pre:({children:i})=>c.jsx(PN,{children:i}),table:({children:i})=>c.jsx("div",{className:"message-table-scroll",role:"region","aria-label":"表格",tabIndex:0,children:c.jsx("table",{children:i})})}}const JN=w.memo(function({text:i,reasoning:l="",streaming:a=!1,onOpenFile:o}){const f=w.useMemo(()=>ZN(o),[o]);return c.jsxs("div",{className:"message-content",children:[l?c.jsxs("details",{className:"message-reasoning",children:[c.jsx("summary",{children:a&&!i?"思考中…":"思考过程"}),c.jsx("pre",{children:l})]}):null,a?c.jsxs("div",{className:"message-streaming",children:[i||(l?"":"正在思考…"),c.jsx("span",{className:"cursor","aria-hidden":"true",children:"▍"})]}):i?c.jsx(OE,{remarkPlugins:[XN],skipHtml:!0,urlTransform:u=>Qf(u)??(Xf(u)?u:""),components:f,children:i}):null,!a&&i?c.jsx("div",{className:"message-actions",children:c.jsx(vo,{text:i,label:"复制回复"})}):null]})});function WN(t){const i=t.args??{},l=t.summary||[i.description,i.command,i.file_path,i.path,i.query,i.url].find(a=>typeof a=="string"&&a.trim());return typeof l=="string"?l.replace(/\s+/g," ").slice(0,180):""}const eA=w.memo(function({item:i,running:l}){const a=WN(i),o=i.done?i.error?"失败":"已完成":l?"执行中":"未完成";return c.jsxs("details",{className:`message-tool-card${i.error?" message-tool-error":""}`,children:[c.jsxs("summary",{children:[c.jsx("span",{className:"message-tool-indicator","aria-hidden":"true",children:i.done?i.error?"!":"✓":"·"}),c.jsx("span",{className:"message-tool-name",children:i.name}),c.jsx("span",{className:"message-tool-summary",children:a}),c.jsx("span",{className:"message-tool-status",children:o})]}),i.args&&Object.keys(i.args).length?c.jsxs("div",{className:"message-tool-section",children:[c.jsx("strong",{children:"参数"}),c.jsx("pre",{tabIndex:0,children:JSON.stringify(i.args,null,2)})]}):null,c.jsxs("div",{className:"message-tool-section",children:[c.jsxs("div",{className:"message-tool-result-heading",children:[c.jsx("strong",{children:"结果"}),i.result?c.jsx(vo,{text:i.result,label:"复制结果"}):null]}),c.jsx("pre",{tabIndex:0,children:i.result??(i.done?"工具没有返回文本内容。":l?"等待工具返回结果…":"这次工具调用没有保存结果。")})]})]})});function tA(t){return{running:"运行中",completed:"已完成",error:"失败",recorded:"历史记录"}[t]??t}function nA(t){const i=new URLSearchParams(t).get("session");return i&&/^[a-zA-Z0-9_-]{1,128}$/.test(i)?i:null}function Iv(t,i){return!i||!t.hubEpoch||t.hubSequence===void 0?!0:t.hubEpoch===i.epoch&&t.hubSequence>i.sequence}function ab(t,i=[]){let l=Nb(t.transcript);for(const o of t.liveStream?.events??[])l=mr(l,o.event);t.running?l={...l,run:"running"}:t.running===!1&&(l.run==="running"||l.run==="waiting")&&(l={...l,run:"idle"});let a=t.streamCursor;for(const o of i)Iv(o,a)&&(l=mr(l,o.event),o.hubEpoch&&o.hubSequence!==void 0&&(a={epoch:o.hubEpoch,sequence:o.hubSequence}));return{chat:l,cursor:a,truncated:t.liveStream?.truncated??!1}}async function iA(t,i,l,a,o,f=()=>!0){let u=t.outputJournal??await i({});if(!f())throw new Error("Output recovery cancelled");if(u.status==="unavailable"){const v=o?await o():t.outputCoverage;if(!f())throw new Error("Output recovery cancelled");for(const j of[t.outputCoverage,v])ua({unpaired:j?.unpaired,inputIds:j?.inputIds},{},()=>!1);if(v?.outputCursor||a?.()||l.some(j=>j.event.outputCursor)){if(u=await i({}),u.status==="unavailable")throw new Error("Output recovery journal is unavailable")}else{if(v?.journalIdentity||t.outputCoverage?.journalIdentity)throw new Error("Output recovery journal is unavailable");return null}}if(u.status!=="ok"||!u.legacyBaseThroughEventId||t.transcript[0]?.type!=="session_meta")throw new Error("Output recovery has no complete legacy base");const p=t.transcript.findIndex(v=>v.id===u.legacyBaseThroughEventId);if(p<0)throw new Error("Output recovery legacy anchor was not retained");let h=Nb(t.transcript.slice(0,p+1)),m={incomplete:!1},y=0;const b=async()=>{for(;;){if(!f()||++y>2048)throw new Error("Output recovery exceeded its page budget");const v=_S(m,u,j=>{h=mr(h,j)});if(m.incomplete)throw new Error("Output recovery is incomplete");if(v)break;u=await i({after:m.cursor,through:m.through})}};await b();for(let v=0;v<8;v++){const j=o?await o():t.outputCoverage;if(!f())throw new Error("Output recovery cancelled");ua({...j,inputIds:void 0},u,()=>!0);let z;for(const N of[j?.outputCursor,a?.(),...l.map(T=>T.event.outputCursor)]){if(typeof N!="string")continue;const T=z?ga(N,z):1;if(T===void 0)throw new Error("Output recovery journal changed");T>0&&(z=N)}if(typeof z!="string"){j&&ua(j,u,N=>h.items.some(T=>T.kind==="user"&&T.clientMessageId===N));break}const A=ga(z,m.cursor);if(A===void 0)throw new Error("Output recovery journal changed");if(A<=0){j&&ua(j,u,N=>h.items.some(T=>T.kind==="user"&&T.clientMessageId===N));break}if(v===7)throw new Error("Output recovery could not catch up within its round budget");m={incomplete:!1,cursor:m.appliedCursor},u=await i({after:m.cursor,through:z}),await b()}const x=new ld;for(const v of l)x.observe(v.event);ua({unpaired:x.incomplete,inputIds:x.inputIds},u,v=>h.items.some(j=>j.kind==="user"&&j.clientMessageId===v),{requireIdentity:!1});for(const v of l){const j=v.event.outputCursor;if(typeof j=="string"){const z=ga(j,m.cursor);if(z===void 0)throw new Error("Output recovery journal changed");if(z<=0)continue;m.cursor=j}else if(v.event.type==="session_title"){h=mr(h,v.event);continue}else{if(v.event.type==="session_user_message"&&typeof v.event.clientMessageId=="string"&&h.items.some(z=>z.kind==="user"&&z.clientMessageId===v.event.clientMessageId))continue;throw new Error("Output recovery received an unpaired legacy event")}h=mr(h,v.event)}return{chat:h,outputCursor:m.cursor}}function qv(t,i){if(t?.title)return t.title;const l=t?.items.find(a=>a.kind==="user");if(l&&l.kind==="user"&&l.text.trim()){const a=l.text.trim().split(`
57
+ `)[0];return a.length>32?`${a.slice(0,32)}…`:a}return l?.kind==="user"&&l.attachments?.length?`附件:${l.attachments[0].name}`:i.slice(0,8)}function rA(t,i){if(i.workspaceKey!==t.workspaceKey||i.sessionId!==t.activeId)throw new Error("当前工作区或对话已经变化,请重新打开面板后发送。");if(t.connection!=="open"||t.loading)throw new Error("工作台尚未连接,请连接后重新发送面板任务。");if(t.readOnly)throw new Error("当前对话为只读,无法发送面板任务。");if(t.running||t.chat.run==="running"||t.chat.run==="waiting"||t.approvals.some(l=>!l.sessionId||l.sessionId===i.sessionId))throw new Error("当前对话仍在处理任务,请完成后再发送面板任务。");if(t.uncertain||t.uploading||t.uploadBusy)throw new Error("当前消息或附件仍在发送,请等待结果后重试。");if(t.draft.length>0||t.files.length>0)throw new Error("当前对话还有草稿或附件,请先处理它们,再发送面板任务。");if(!i.prompt.trim()||i.prompt.length>2e4)throw new Error("面板任务内容无效。");if(t.setDraft(i.prompt),!t.send())throw t.setDraft(""),new Error("当前对话暂时无法接收任务,请稍后重新发送。");return{accepted:!0}}function lA({controller:t,onBackToProjects:i,projectName:l,cloudAccount:a}){const{connection:o,sessions:f,activeId:u,chat:p,draft:h,files:m,uploading:y,workerNote:b,replayNote:x,error:v,workspaceCwd:j,workspaceName:z,configuration:A,configurationVersion:N,sessionsVersion:T,localDrafts:M,running:G,title:ae,approvalCount:D,onAuthLost:H,refreshSessions:W,refreshConfiguration:q,session:C}=t,L=t.workspaceApi,B=t.host==="desktop"?"桌面":"服务端",[Q,J]=w.useState(!1),K=w.useRef(null),I=w.useRef(null),[Y,X]=w.useState(()=>new URLSearchParams(window.location?.search??"").get("view")==="links"?"links":"chat"),[pe,k]=w.useState(),[O,te]=w.useState(),[R,ee]=w.useState(0),[ve,le]=w.useState(!1),[ue,xe]=w.useState(null),[F,ke]=w.useState("overview"),[ze,Le]=w.useState(()=>window.matchMedia("(max-width: 760px)").matches),[Ee,Xe]=w.useState(()=>!window.matchMedia("(max-width: 760px)").matches),gt=w.useRef(null),He=w.useRef(null),Lt=w.useRef(!1),st=w.useRef(null),Ve=w.useRef(null),At=w.useRef(!0);w.useEffect(()=>{k(void 0),X(oe=>oe==="panel"?"panels":oe)},[t.workspaceKey]),w.useEffect(()=>{ze&&!Ee&&Lt.current&&!Q&&He.current?.focus(),Lt.current=Ee},[ze,Ee,Q]),w.useEffect(()=>{const oe=window.matchMedia("(max-width: 760px)"),Se=()=>{Le(oe.matches),Xe(!oe.matches)};return oe.addEventListener("change",Se),()=>oe.removeEventListener("change",Se)},[]),w.useEffect(()=>{if(!ze||!Ee)return;const oe=gt.current;oe?.querySelector("button")?.focus();const Se=Ae=>{if(!document.querySelector("dialog[open]")){if(Ae.key==="Escape"&&!Ae.isComposing)Ae.preventDefault(),Xe(!1),He.current?.focus();else if(Ae.key==="Tab"){const Re=Array.from(oe?.querySelectorAll('button:not(:disabled), select:not(:disabled), input:not(:disabled), textarea:not(:disabled), a[href], summary, [tabindex]:not([tabindex="-1"])')??[]).filter(Oe=>Oe.getClientRects().length>0),ne=Re?.[0],ye=Re?.[Re.length-1];Ae.shiftKey&&document.activeElement===ne?(Ae.preventDefault(),ye?.focus()):!Ae.shiftKey&&document.activeElement===ye&&(Ae.preventDefault(),ne?.focus())}}};return document.addEventListener("keydown",Se),()=>document.removeEventListener("keydown",Se)},[ze,Ee]),w.useLayoutEffect(()=>{const oe=Ve.current;!oe||Y!=="chat"||(oe.style.height="auto",oe.style.height=`${Math.min(180,Math.max(64,oe.scrollHeight))}px`)},[h,Y]),w.useLayoutEffect(()=>{const oe=st.current;oe&&At.current&&Y==="chat"&&(oe.scrollTop=oe.scrollHeight)},[p.items,t.approvals.length,Y]);const Ie=()=>{ze&&(Xe(!1),He.current?.focus())},yt=oe=>{if(Y==="settings"&&F===oe){Ie();return}ot(()=>{ke(oe),X("settings"),Ie()})},ot=oe=>{ve?xe(()=>oe):oe()},Ze=oe=>ot(()=>{te(oe),ee(Se=>Se+1),X("files"),Ie()}),pt=w.useRef(Ze);pt.current=Ze;const _=w.useCallback(oe=>pt.current(oe),[]);w.useEffect(()=>{if(!ve&&!t.uploadBusy&&!t.hasUnsent)return;const oe=Se=>{Se.preventDefault(),Se.returnValue=""};return window.addEventListener("beforeunload",oe),()=>window.removeEventListener("beforeunload",oe)},[ve,t.uploadBusy,t.hasUnsent]);const Z=oe=>ot(()=>{X("chat"),Ie(),At.current=!0,oe()}),ge=oe=>Z(()=>{t.selectSession(oe)}),we=()=>Z(t.newSession),Ne=()=>{At.current=!0,t.send()},De=t.stop,Ge=t.approvals.filter(oe=>!oe.sessionId||oe.sessionId===u),mt=t.approvals.filter(oe=>oe.sessionId&&oe.sessionId!==u),ut=p.items.length===0&&Ge.length===0,dt=A?.connections.find(oe=>oe.id===A.defaults.text),tt=o==="open"?"已连接":o==="connecting"?"连接中":"正在重连",Ot=Y==="chat"?ae:Y==="files"?"工作区文件":Y==="history"?"历史对话":Y==="links"?"Link":Y==="panels"||Y==="panel"?pe&&Y==="panel"?pe.panel.title["zh-CN"]||pe.panel.title.default:"面板":F==="skills"?"Skills":"设置";return c.jsxs("div",{className:`shell${Ee?" sidebar-open":""}`,children:[ze&&Ee?c.jsx("div",{className:"sidebar-backdrop",onClick:()=>{Xe(!1),He.current?.focus()},"aria-hidden":"true"}):null,c.jsxs("aside",{id:"workbench-sidebar",ref:gt,className:"rail",hidden:!Ee,role:ze?"dialog":void 0,"aria-modal":ze&&Ee?!0:void 0,"aria-label":"工作台导航",children:[c.jsxs("div",{className:"rail-head",children:[c.jsx("span",{className:"brand-mark",children:c.jsx(_t,{name:"brand"})}),c.jsx("strong",{children:"CodeShell"}),c.jsx("span",{className:"hub-badge",children:a?"Cloud":t.host==="desktop"?"Desktop":L?"Hub":"Web"}),c.jsx("button",{className:"icon-button sidebar-close","aria-label":"收起侧栏",onClick:()=>{Xe(!1),He.current?.focus()},children:c.jsx(_t,{name:"sidebar"})})]}),c.jsx(td,{discover:t.workspaceApi,navigate:oe=>{const Se=()=>window.location.assign(oe);ve||t.hasUnsent||t.uploadBusy?xe(()=>Se):Se()}}),c.jsxs("nav",{className:"workbench-nav","aria-label":"主要功能",children:[i?c.jsxs("button",{className:"nav-button",title:l,onClick:()=>{ve||t.hasUnsent||t.uploadBusy?xe(()=>i):i()},children:[c.jsx(_t,{name:"folder"}),c.jsx("span",{children:"返回项目列表"})]}):null,c.jsxs("button",{className:"nav-button new-chat-button",onClick:we,children:[c.jsx(_t,{name:"plus"}),c.jsx("span",{children:"新对话"})]}),c.jsxs("button",{className:`nav-button${Y==="chat"?" active":""}`,onClick:()=>{ot(()=>{X("chat"),Ie()})},"aria-current":Y==="chat"?"page":void 0,children:[c.jsx(_t,{name:"chat"}),c.jsx("span",{children:"对话"})]}),L?c.jsxs(c.Fragment,{children:[c.jsxs("button",{className:`nav-button${Y==="history"?" active":""}`,onClick:()=>ot(()=>{X("history"),Ie()}),"aria-current":Y==="history"?"page":void 0,children:[c.jsx(_t,{name:"history"}),c.jsx("span",{children:"历史对话"})]}),c.jsxs("button",{className:`nav-button${Y==="files"?" active":""}`,onClick:()=>Ze(),"aria-current":Y==="files"?"page":void 0,children:[c.jsx(_t,{name:"folder"}),c.jsx("span",{children:"文件"})]}),c.jsxs("button",{className:`nav-button${Y==="settings"&&F==="skills"?" active":""}`,onClick:()=>yt("skills"),"aria-current":Y==="settings"&&F==="skills"?"page":void 0,children:[c.jsx(_t,{name:"skills"}),c.jsx("span",{children:"Skills"})]}),c.jsxs("button",{className:`nav-button${Y==="panels"||Y==="panel"?" active":""}`,onClick:()=>ot(()=>{X("panels"),Ie()}),"aria-current":Y==="panels"||Y==="panel"?"page":void 0,children:[c.jsx(_t,{name:"panels"}),c.jsx("span",{children:"面板"})]}),c.jsxs("button",{className:`nav-button${Y==="links"?" active":""}`,onClick:()=>ot(()=>{X("links"),Ie()}),"aria-current":Y==="links"?"page":void 0,children:[c.jsx(_t,{name:"links"}),c.jsx("span",{children:"Link"})]}),c.jsxs("button",{className:`nav-button${Y==="settings"&&F!=="skills"?" active":""}`,onClick:()=>yt("overview"),"aria-current":Y==="settings"&&F!=="skills"?"page":void 0,children:[c.jsx(_t,{name:"settings"}),c.jsx("span",{children:"设置"})]})]}):null]}),c.jsx("div",{className:"rail-section-label",children:"工作区"}),L?c.jsxs("button",{className:"workspace-button",title:j??void 0,onClick:()=>Ze(),children:[c.jsx(_t,{name:"folder"}),c.jsx("span",{children:l??z}),c.jsx(_t,{name:"chevron"})]}):c.jsxs("div",{className:"workspace-button",title:j??void 0,children:[c.jsx(_t,{name:"folder"}),c.jsx("span",{children:l??z})]}),c.jsxs("div",{className:"rail-section-label history-label",children:[c.jsx("span",{children:"最近对话"}),c.jsx("span",{children:f.length})]}),t.renderSidebar?.({guard:ot,conversation:Z}),c.jsxs("ul",{className:"sessions","aria-label":"最近对话",children:[M.map(({sessionId:oe,draft:Se})=>c.jsx("li",{children:c.jsxs("button",{className:oe===u&&Y==="chat"?"session active":"session",onClick:()=>{ge(oe)},children:[c.jsx("span",{className:"session-title",children:Se.text.trim()||`附件:${Se.files[0]?.name??"新对话"}`}),c.jsx("span",{className:"session-meta",children:"草稿"})]})},`draft-${oe}`)),f.map(oe=>c.jsx("li",{children:c.jsxs("button",{className:oe.sessionId===u&&Y==="chat"?"session active":"session",onClick:()=>{ge(oe.sessionId)},"aria-current":oe.sessionId===u&&Y==="chat"?"page":void 0,children:[c.jsx("span",{className:"session-title",children:oe.sessionId===u?oe.customTitle||p.title||oe.title||qv(p,oe.sessionId):oe.title||oe.preview?.trim()||oe.sessionId.slice(0,8)}),c.jsxs("span",{className:"session-meta",children:[t.unreadSessionIds?.has(oe.sessionId)&&oe.sessionId!==u?c.jsxs("span",{className:"session-unread","aria-label":"有新消息",children:["●"," "]}):null,D(oe.sessionId)?`${D(oe.sessionId)} 项待审批`:oe.running?"进行中":sA(oe.status),t.showTurnCounts!==!1?c.jsxs("span",{children:[" · ",oe.turnCount," 轮"]}):null]})]})},oe.sessionId)),f.length===0&&M.length===0?c.jsx("li",{className:"empty",children:"开始对话后,记录会保存在这里。"}):null]}),c.jsxs("div",{className:"rail-footer",children:[c.jsxs("div",{className:"host-label",children:[c.jsx("span",{className:`dot ${o}`}),c.jsxs("span",{children:[B,tt]})]}),a?c.jsx(xb,{...a}):null,t.host==="hub"&&!a?c.jsxs("button",{className:"account-button",onClick:()=>{Ie(),J(!0)},children:[c.jsx("span",{className:"account-avatar",children:(C?.username||"C").slice(0,1).toUpperCase()}),c.jsxs("span",{className:"account-copy",children:[c.jsx("strong",{children:C?.username||"账号"}),c.jsx("span",{children:"设备与退出"})]}),c.jsx(_t,{name:"chevron"})]}):null,t.logout?c.jsxs("button",{className:"account-button",onClick:t.logout,children:[c.jsx("span",{className:"account-avatar",children:(t.accountName||"D").slice(0,1)}),c.jsxs("span",{className:"account-copy",children:[c.jsx("strong",{children:t.accountName||"已配对设备"}),c.jsx("span",{children:"退出此设备"})]})]}):null]})]}),c.jsxs("main",{className:"workbench-main",inert:ze&&Ee?!0:void 0,children:[c.jsxs("header",{className:"workbench-topbar",children:[c.jsx("button",{ref:He,className:"icon-button","aria-label":Ee?"收起侧栏":"展开侧栏","aria-expanded":Ee,"aria-controls":"workbench-sidebar",onClick:()=>Xe(oe=>!oe),children:c.jsx(_t,{name:"sidebar"})}),c.jsxs("div",{className:"topbar-context",children:[c.jsx("span",{className:"topbar-project","aria-label":"当前项目",title:l??z,children:l??z}),c.jsx("span",{className:"topbar-title",title:Ot,children:Ot})]}),c.jsxs("span",{className:"connection-pill",title:`任务在${B}工作区执行`,children:[c.jsx("span",{className:`dot ${o}`}),c.jsx("span",{children:B})]})]}),b?c.jsx("div",{className:"banner",children:b}):null,x?c.jsx("div",{className:"banner",children:x}):null,v?c.jsxs("div",{className:"banner form-error",role:"alert",children:[v,c.jsx("button",{className:"ghost","aria-label":"关闭错误提示",onClick:t.clearError,children:"×"})]}):null,mt.length?c.jsxs("div",{className:"banner",children:["其他会话有待处理审批。",mt.map(oe=>c.jsxs("button",{className:"ghost",onClick:()=>{ge(oe.sessionId)},children:["打开 ",oe.sessionId.slice(0,8)]},oe.id))]}):null,o!=="open"?c.jsxs("div",{className:"banner",children:["连接",o==="connecting"?"中…":"已断开,重连中…"]}):null,Y!=="chat"&&Ge.length>0?c.jsxs("div",{className:"banner",children:["当前对话需要你的确认。",c.jsx("button",{className:"ghost",onClick:()=>ot(()=>X("chat")),children:"返回对话"})]}):null,c.jsxs("section",{className:`chat${ut?" chat-empty":""}`,hidden:Y!=="chat","aria-label":"对话",children:[c.jsx("div",{className:"messages",ref:st,onScroll:oe=>{const Se=oe.currentTarget;At.current=Se.scrollHeight-Se.scrollTop-Se.clientHeight<100},children:c.jsxs("div",{className:"transcript",children:[t.chatControls,t.loading?c.jsx("div",{className:"banner",role:"status",children:"正在恢复会话记录…"}):null,p.goal?c.jsxs("div",{className:"banner goal",children:[c.jsx("span",{children:p.goal}),t.goalActions]}):null,p.items.map(oe=>{switch(oe.kind){case"user":return c.jsxs("div",{className:"msg user",children:[oe.text,oe.attachments?.map((Se,Ae)=>L&&Se.path?c.jsxs("button",{className:"attachment attachment-open",onClick:()=>Ze(Se.path),children:["📎 ",Se.name]},Ae):c.jsxs("span",{className:"attachment",children:["📎 ",Se.name]},Ae))]},oe.id);case"assistant":return oe.done&&!oe.text&&!oe.reasoning?null:c.jsx("div",{className:"msg assistant",children:c.jsx(JN,{text:oe.text,reasoning:oe.reasoning,streaming:!oe.done,onOpenFile:L?_:void 0})},oe.id);case"tool":return c.jsx("div",{className:`msg tool${oe.error?" tool-error":""}`,children:c.jsx(eA,{item:oe,running:G})},oe.id);case"subagent":return c.jsxs("div",{className:"msg info",children:["↳ ",oe.label," · ",tA(oe.status)]},oe.id);case"system":return c.jsx("div",{className:"msg info",children:oe.text},oe.id);case"system_error":return c.jsx("div",{className:"msg error",children:oe.text},oe.id);default:return null}}),t.approvalContent,ut?c.jsxs("div",{className:"empty-chat",children:[c.jsx("span",{className:"welcome-mark",children:c.jsx(_t,{name:"brand"})}),c.jsx("h1",{children:"今天想完成什么?"}),c.jsx("p",{children:"从一个问题或想法开始,让 CodeShell 帮你一步步完成。"}),c.jsxs("span",{className:"welcome-workspace",children:[c.jsx(_t,{name:"folder"}),l??z]})]}):null]})}),t.readOnlyNote?c.jsx("div",{className:"banner",children:t.readOnlyNote}):null,c.jsxs("div",{className:"composer-wrap",children:[c.jsxs("footer",{className:"composer",children:[m.length||y&&t.host==="hub"?c.jsxs("div",{className:"attachments","aria-live":"polite",children:[m.map(oe=>c.jsxs("span",{className:"attachment",children:[c.jsx(_t,{name:"attachment"}),oe.name,c.jsx("button",{className:"ghost","aria-label":`移除 ${oe.name}`,onClick:()=>{t.removeFile(oe.id)},children:"×"})]},oe.id)),y&&t.host==="hub"?c.jsx("span",{children:"正在上传…"}):null]}):null,c.jsx("textarea",{ref:Ve,"aria-label":"任务内容",value:h,disabled:t.readOnly,rows:2,placeholder:"描述你的任务,或提出一个问题…",onChange:oe=>{t.setDraft(oe.target.value)},onKeyDown:oe=>{oe.key==="Enter"&&!oe.shiftKey&&!oe.nativeEvent.isComposing&&(oe.preventDefault(),Ne())}}),c.jsxs("div",{className:"composer-toolbar",children:[L?c.jsxs(c.Fragment,{children:[c.jsx("input",{hidden:!0,multiple:!0,type:"file",accept:t.attachmentAccept,ref:K,onChange:oe=>{const Se=oe.currentTarget;Promise.resolve(t.addFiles(Se.files)).finally(()=>{Se.value=""})}}),c.jsx("button",{className:"icon-button attach-button","aria-label":"添加附件",title:"添加附件",disabled:t.uploadBusy||o!=="open"||t.readOnly,onClick:()=>K.current?.click(),children:c.jsx(_t,{name:"plus"})}),t.cameraAttachments?c.jsxs(c.Fragment,{children:[c.jsx("input",{hidden:!0,type:"file",accept:"image/*",capture:"environment",ref:I,onChange:oe=>{const Se=oe.currentTarget;Promise.resolve(t.addFiles(Se.files)).finally(()=>{Se.value=""})}}),c.jsx("button",{className:"icon-button attach-button","aria-label":"拍照",title:"拍照",disabled:t.uploadBusy||o!=="open"||t.readOnly,onClick:()=>I.current?.click(),children:c.jsx(_t,{name:"camera"})})]}):null,c.jsxs("button",{className:"model-button",title:"打开模型设置",onClick:()=>yt("models"),children:[c.jsx("span",{children:dt?.model||"配置模型"}),c.jsx(_t,{name:"chevron"})]})]}):null,c.jsx("span",{className:"composer-run-status",role:"status",children:t.uncertain?"正在核对消息…":y?t.host==="desktop"?"正在发送…":"正在上传附件…":Ge.length?"等待你的确认":G?"正在处理…":""}),G?c.jsx("button",{className:"stop composer-submit","aria-label":"停止",title:"停止",onClick:De,disabled:o!=="open",children:c.jsx(_t,{name:"stop"})}):c.jsx("button",{className:"send composer-submit","aria-label":"发送",title:"发送",onClick:Ne,disabled:o!=="open"||y||t.uncertain||t.readOnly||!h.trim()&&!m.length,children:c.jsx(_t,{name:"send"})})]})]}),c.jsxs("div",{className:"composer-caption",children:[c.jsxs("span",{children:["任务在",B,"工作区执行"]}),c.jsx("span",{children:"Enter 发送 · Shift + Enter 换行"})]})]})]}),Y==="settings"&&L?c.jsx(uS,{host:t.host==="desktop"?"desktop":"hub",section:F,onSectionChange:yt,onAuthLost:H,onConfigurationChange:()=>{q()},configurationVersion:N,onDirtyChange:le},`${t.workspaceKey}:settings`):null,Y==="files"&&L?c.jsx(gS,{initialPath:O,openVersion:R,onAuthLost:H},`${t.workspaceKey}:files`):null,Y==="history"&&L?c.jsx(yS,{onAuthLost:H,onOpen:oe=>{ge(oe)},onChanged:()=>{W()},version:T,onDirtyChange:le},`${t.workspaceKey}:history`):null,Y==="links"&&L?c.jsx(uw,{onAuthLost:H,onDirtyChange:le,hostLabel:B,configurationVersion:N},`${t.workspaceKey}:links`):null,Y==="panels"&&L?c.jsx(cw,{onAuthLost:H,onDirtyChange:le,onChanged:()=>{q()},hostLabel:B,configurationVersion:N,onOpen:oe=>ot(()=>{k({panel:oe,workspaceKey:t.workspaceKey}),X("panel"),Ie()})},`${t.workspaceKey}:panels`):null,Y==="panel"&&L&&pe?.workspaceKey===t.workspaceKey?c.jsx(jw,{panel:pe.panel,sessionId:u,busy:G||y||t.uncertain,onAuthLost:H,onDirtyChange:le,onClose:()=>ot(()=>X("panels")),onSubmitPrompt:async oe=>rA(t,{...oe,workspaceKey:pe.workspaceKey})},`${t.workspaceKey}:panel:${pe.panel.id}:${u}`):null]}),ue?c.jsx(aA,{onStay:()=>xe(null),onLeave:()=>{const oe=ue;xe(null),le(!1),oe()}}):null,Q&&t.host==="hub"&&!a?c.jsx(T1,{session:C,onClose:()=>J(!1),onAuthLost:H}):null]})}function aA({onStay:t,onLeave:i}){const l=w.useRef(null);return w.useEffect(()=>{const a=document.activeElement;return l.current?.showModal(),()=>{l.current?.close(),a?.focus()}},[]),c.jsxs("dialog",{className:"navigation-prompt",ref:l,"aria-labelledby":"navigation-prompt-title",onCancel:a=>{a.preventDefault(),t()},children:[c.jsx("h2",{id:"navigation-prompt-title",children:"还有未保存的修改"}),c.jsx("p",{children:"离开会丢弃未提交的修改;切换项目还会清除未发送的草稿和附件。已经提交的操作可能仍会完成,请等待结果后再离开。"}),c.jsxs("div",{className:"library-actions",children:[c.jsx("button",{className:"library-button primary",onClick:t,autoFocus:!0,children:"留在此页"}),c.jsx("button",{className:"library-button",onClick:i,children:"放弃修改并离开"})]})]})}function sA(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 _t({name:t}){const i={panels:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),c.jsx("path",{d:"M15 3v18M15 10h6"})]}),camera:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M3 7h4l2-3h6l2 3h4v13H3Z"}),c.jsx("circle",{cx:"12",cy:"13",r:"4"})]}),links:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M10 13a5 5 0 0 0 7 0l3-3a5 5 0 0 0-7-7l-2 2"}),c.jsx("path",{d:"M14 11a5 5 0 0 0-7 0l-3 3a5 5 0 0 0 7 7l2-2"})]}),brand:c.jsx(c.Fragment,{children:c.jsx("path",{d:"m5 7 5 5-5 5M13 17h6"})}),sidebar:c.jsxs(c.Fragment,{children:[c.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),c.jsx("path",{d:"M9 4v16"})]}),plus:c.jsx("path",{d:"M12 5v14M5 12h14"}),chat:c.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:c.jsxs(c.Fragment,{children:[c.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7L3 8"}),c.jsx("path",{d:"M3 3v5h5M12 7v5l3 2"})]}),skills:c.jsx(c.Fragment,{children:c.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:c.jsxs(c.Fragment,{children:[c.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"}),c.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),folder:c.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:c.jsx("path",{d:"m9 5 7 7-7 7"}),attachment:c.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:c.jsx("path",{d:"M12 19V5m-6 6 6-6 6 6"}),stop:c.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2",fill:"currentColor",stroke:"none"})};return c.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i[t]})}class vi extends Error{constructor(i,l,a){super(i),this.kind=l,this.code=a,this.name="ProtocolRequestError"}kind;code}const oA=3e4,sb=800,uA=15e3;class cA{constructor(i){this.url=i}url;ws=null;nextId=1;pending=new Map;notificationHandlers=new Set;stateHandlers=new Set;reconnectDelay=sb;closedByUser=!1;reconnectTimer;authHandlers=new Set;connect(){this.ws||(clearTimeout(this.reconnectTimer),this.closedByUser=!1,this.openSocket())}openSocket(){if(this.closedByUser)return;this.reconnectTimer=void 0,this.emitState("connecting");const i=new WebSocket(this.url);this.ws=i,i.onopen=()=>{this.ws!==i||this.closedByUser||(this.reconnectDelay=sb,this.emitState("open"))},i.onmessage=l=>{if(this.ws!==i||this.closedByUser)return;let a;try{if(a=JSON.parse(String(l.data)),!a||typeof a!="object"||Array.isArray(a))return}catch{return}if(a.id!==void 0&&a.method===void 0){const o=this.pending.get(String(a.id));if(!o)return;this.pending.delete(String(a.id)),clearTimeout(o.timer),a.error?o.reject(new vi(a.error.message??"request failed","response",a.error.code)):o.resolve(a.result);return}if(a.method)for(const o of this.notificationHandlers)o(a.method,a.params??{})},i.onclose=l=>{if(this.ws===i){if(this.ws=null,this.emitState("closed"),this.failAllPending(new vi("connection closed","transport")),l.code===4401||l.code===4403){this.closedByUser=!0;for(const a of this.authHandlers)a()}this.closedByUser||(this.reconnectTimer=setTimeout(()=>this.openSocket(),this.reconnectDelay),this.reconnectDelay=Math.min(this.reconnectDelay*2,uA))}},i.onerror=()=>{}}close(){this.closedByUser=!0,clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0;const i=this.ws;this.ws=null,i?.close(),this.failAllPending(new vi("connection closed","transport"))}onNotification(i){return this.notificationHandlers.add(i),()=>this.notificationHandlers.delete(i)}onStateChange(i){return this.stateHandlers.add(i),()=>this.stateHandlers.delete(i)}onAuthLost(i){return this.authHandlers.add(i),()=>this.authHandlers.delete(i)}request(i,l,a=oA){const o=this.ws;if(!o||o.readyState!==WebSocket.OPEN)return Promise.reject(new vi("not connected","not-sent"));const f=`web-${this.nextId++}`;return new Promise((u,p)=>{const h=a>0?setTimeout(()=>{this.pending.delete(f),p(new vi(`request timed out: ${i}`,"timeout"))},a):void 0;this.pending.set(f,{resolve:u,reject:p,timer:h});try{o.send(JSON.stringify({jsonrpc:"2.0",id:f,method:i,params:l}))}catch(m){clearTimeout(h),this.pending.delete(f),p(new vi(m instanceof Error?m.message:"send failed","not-sent"))}})}run(i){return this.request("agent/run",i,0)}listSessions(){return this.request("agent/query",{type:"sessions"})}sessionDetail(i,l=!1){return this.request("agent/query",{type:"session_detail",sessionId:i,...l?{outputRecovery:!0}:{}})}outputCoverage(i){return this.request("agent/query",{type:"output_coverage",sessionId:i})}outputJournal(i,l={}){return this.request("agent/query",{type:"output_journal",sessionId:i,...l})}approve(i,l,a){return this.request("agent/approve",{sessionId:i.sessionId??"",...i.connectionId?{connectionId:i.connectionId}:{},...i.generation!==void 0?{generation:i.generation}:{},requestId:i.requestId,decision:l?{approved:!0,...a?{answer:a}:{}}:{approved:!1}})}cancel(i){return this.request("agent/cancel",{sessionId:i})}emitState(i){for(const l of this.stateHandlers)l(i)}failAllPending(i){for(const[,l]of this.pending)clearTimeout(l.timer),l.reject(i);this.pending.clear()}}function fA(){return`${location.protocol==="https:"?"wss:":"ws:"}//${location.host}${xt("/ws")}`}function dA(t,i){const{method:l,params:a}=i;if(l==="serve/approvalSnapshot"){if(!Array.isArray(a.approvals))return t;const f={};for(const u of a.approvals)u?.requestId&&u.request&&(f[u.requestId]={payload:u});return f}if(l==="agent/approvalRequest"){const f=a;return!f.requestId||!f.request?t:{...t,[f.requestId]:{...t[f.requestId],payload:f}}}const o=a.requestId;if(typeof o!="string"||!t[o])return t;if(l==="agent/approvalResolved"){const f={...t};return delete f[o],f}return l==="serve/approvalLease"?{...t,[o]:{...t[o],lease:a}}:t}class hA{drafts=new Map;get(i){return this.drafts.get(i)??{text:"",files:[],revision:0}}update(i,l){const a={...l,revision:this.get(i).revision+1};return this.drafts.set(i,a),a}setText(i,l){return this.update(i,{...this.get(i),text:l})}addFile(i,l){const a=this.get(i);return this.update(i,{...a,files:[...a.files,l]})}removeFile(i,l){const a=this.get(i);return this.update(i,{...a,files:a.files.filter(o=>o.id!==l)})}take(i){const l=this.get(i),a=this.update(i,{text:"",files:[]});return{sessionId:i,draft:l,clearedRevision:a.revision}}restore(i){const l=this.get(i.sessionId);return l.revision!==i.clearedRevision||l.text||l.files.length?!1:(this.update(i.sessionId,i.draft),!0)}unsent(){return[...this.drafts].flatMap(([i,l])=>l.text.trim()||l.files.length?[{sessionId:i,draft:l}]:[])}}function pA({payload:t,onDecide:i,busy:l,connected:a}){const[o,f]=w.useState(""),u=t.request.toolName==="__ask_user__",{summary:p,risk:h}=RS(t.request.args,t.request.riskLevel,t.request.toolName);return c.jsxs("div",{className:"approval",children:[c.jsxs("div",{className:"approval-title",children:[u?"Agent 提问":`工具审批:${t.request.toolName}`,u?null:c.jsxs("em",{children:[" · ",h]})]}),t.request.description?c.jsx("div",{className:"approval-desc",children:t.request.description}):null,u?null:c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"approval-summary",children:p}),c.jsxs("details",{className:"approval-raw",children:[c.jsx("summary",{children:"原始参数"}),c.jsx("pre",{className:"approval-args",children:JSON.stringify(t.request.args,null,2)})]})]}),u?c.jsx("textarea",{className:"approval-answer",value:o,placeholder:"输入回答…",onChange:m=>f(m.target.value)}):null,l?c.jsx("span",{className:"muted",role:"status",children:"设备正在处理此审批…"}):null,c.jsxs("div",{className:"approval-actions",children:[c.jsx("button",{className:"send",disabled:l||!a||u&&!o.trim(),onClick:()=>i(t,!0,u?o:void 0),children:u?"回答":"允许"}),c.jsx("button",{className:"stop",disabled:l||!a,onClick:()=>i(t,!1),children:"拒绝"})]})]})}function ob(){return Ca()}const mA=()=>{},gA=async()=>{};function yA({session:t,hub:i=!1,onAuthLost:l=mA,onCheckAuth:a=gA}){const o=w.useRef(null),[f,u]=w.useState("connecting"),[p,h]=w.useState([]),m=w.useRef([]),[y,b]=w.useState(()=>nA(window.location.search)??ob()),[x,v]=w.useState(eo()),[j,z]=w.useReducer(dA,{}),[A,N]=w.useState({}),[T,M]=w.useState(""),[G,ae]=w.useState([]),D=w.useRef(new hA),[H,W]=w.useState(0),[q,C]=w.useState(null),L=q===y,[B,Q]=w.useState(null),[J,K]=w.useState(null),[I,Y]=w.useState(""),[X,pe]=w.useState(Date.now()),[k,O]=w.useState(0),[te,R]=w.useState(null),[ee,ve]=w.useState(0),le=w.useRef(0),ue=w.useRef(y),xe=w.useRef(null),F=w.useRef(null),ke=w.useRef(!1),ze=w.useRef(new Map),Le=w.useRef(new Map),Ee=w.useRef(new Set),Xe=w.useRef(new Set),gt=w.useRef(new Set),He=w.useRef(!1),Lt=w.useRef(null),st=w.useRef(null),Ve=w.useCallback(ne=>{if(W(Oe=>Oe+1),ue.current!==ne)return;const ye=D.current.get(ne);M(ye.text),ae(ye.files)},[]);w.useEffect(()=>{const ne=new URL(window.location.href);ne.searchParams.set("session",y),window.history.replaceState(window.history.state,"",ne)},[y]);const At=w.useCallback((ne,ye)=>{const Oe=D.current.restore(ne.draft);Ve(ne.draft.sessionId),ue.current===ne.draft.sessionId&&(v(Ce=>({...Ce,run:"error",items:Ce.items.filter(U=>U.kind!=="user"||U.clientMessageId!==ne.clientMessageId)})),Oe&&Y(`${ye?`${ye} `:"消息未送达。"}内容和附件已恢复,可以重试。`))},[Ve]),Ie=w.useCallback(ne=>{He.current&&(ne instanceof Ke&&ne.status===401?l():Y(ne instanceof Error?ne.message:"操作失败,请重试。"))},[l]),yt=w.useCallback(async()=>{if(!i||!He.current)return;const ne=++le.current;try{const ye=await Sb();He.current&&ne===le.current&&R(ye)}catch(ye){He.current&&ye instanceof Ke&&ye.status===401&&l()}},[i,l]),ot=w.useCallback(async()=>{const ne=o.current;if(ne)try{const ye=i?(await Mf()).sessions:(await ne.listSessions()).data;if(o.current===ne&&He.current){const Oe=[...ye].sort((Ce,U)=>(U.lastActiveAt??U.startedAt)-(Ce.lastActiveAt??Ce.startedAt));m.current=Oe,h(Oe)}}catch(ye){Ie(ye)}},[Ie,i]),Ze=w.useCallback(async()=>{const ne=o.current;if(ne)for(const[ye,Oe]of Le.current)try{const Ce=await ne.sessionDetail(ye);if(!He.current||ne!==o.current||Le.current.get(ye)!==Oe)continue;ab(Ce.data).chat.items.some(je=>je.kind==="user"&&je.clientMessageId===Oe.clientMessageId)?Le.current.delete(ye):Ce.data.running||(Le.current.delete(ye),At(Oe))}catch(Ce){if(!He.current||ne!==o.current||Le.current.get(ye)!==Oe)continue;Ce instanceof vi&&Ce.kind==="response"&&Ce.code===-32001&&Ce.message===`Session not found: ${ye}`&&(Le.current.delete(ye),At(Oe))}},[At]),pt=w.useCallback(async ne=>{const ye=o.current;if(!ye)return;const Oe={sessionId:ne,events:[],bytes:0};st.current=Oe;try{const Ce=await ye.sessionDetail(ne,!0);if(!He.current||st.current!==Oe||ue.current!==ne)return;let U=Oe.running??Ce.data.running;U?Xe.current.add(ne):U===!1&&Xe.current.delete(ne);const fe=ab(Ce.data,Oe.events);let je=fe.chat,Pe=!1,lt=!1;try{const Tt=await iA(Ce.data,async kt=>(await ye.outputJournal(ne,kt)).data,Oe.events,()=>Oe.latestOutputCursor,Ce.data.outputCoverage?async()=>(await ye.outputCoverage(ne)).data:void 0,()=>He.current&&st.current===Oe&&ue.current===ne);Tt?(je=Tt.chat,F.current=Tt.outputCursor,Pe=!0):F.current=null}catch(Tt){F.current=null,lt=!(!Ce.data.outputJournal&&Tt instanceof vi&&Tt.kind==="response"&&Tt.code===-32602&&Tt.message==="Unknown query type: output_journal")}if(!He.current||st.current!==Oe||ue.current!==ne)return;U=Oe.running??Ce.data.running,ke.current=lt,lt||(xe.current=fe.cursor??null),K(lt?"部分运行记录无法验证,已保留当前可见内容。请修复会话记录后重试。":!Pe&&(fe.truncated||Oe.overflow)?"这次运行的实时记录较长,已恢复已保存的内容;结束后重新打开可查看完整记录。":null),U||Ee.current.has(ne)?je.run="running":U===!1&&(je.run==="running"||je.run==="waiting")&&(je.run="idle"),v(Tt=>lt?Tt:je)}catch(Ce){ue.current===ne&&Ie(Ce)}finally{st.current===Oe&&(st.current=null)}},[Ie]);w.useEffect(()=>{He.current=!0;const ne=new cA(fA());o.current=ne;const ye=ne.onAuthLost(l),Oe=ne.onStateChange(U=>{u(U),U==="open"?(Q(null),Y(""),ot().then(()=>{const fe=ue.current;He.current&&o.current===ne&&(m.current.some(je=>je.sessionId===fe)||Xe.current.has(fe)||Ee.current.has(fe)||Le.current.has(fe))&&pt(fe)}),yt(),Ze()):U==="closed"&&(i&&a(),v(fe=>({...fe,run:"idle"})))}),Ce=ne.onNotification((U,fe)=>{if(U==="serve/sessionsChanged"){ot(),O(je=>je+1);return}if(U==="agent/runAccepted"&&typeof fe.sessionId=="string"){const je=ze.current.get(fe.sessionId);je&&(je.accepted=!0);return}if(U==="serve/configurationChanged"){yt(),ve(je=>je+1);return}if(U==="agent/streamEvent"){const je=fe,{sessionId:Pe,event:lt}=je,Tt=ze.current.get(Pe);if(Tt&&["stream_request_start","text_delta","thinking_delta","tool_use_start"].includes(String(lt.type))&&(Tt.accepted=!0),Pe===ue.current){if(st.current?.sessionId===Pe){const kt=st.current;typeof lt.outputCursor=="string"&&(kt.latestOutputCursor=lt.outputCursor);const Wn=new TextEncoder().encode(JSON.stringify(je)).length;for(kt.events.push(je),kt.bytes+=Wn;kt.events.length>2048||kt.bytes>8*1024*1024;){const Vt=kt.events.shift();Vt&&(kt.bytes-=new TextEncoder().encode(JSON.stringify(Vt)).length),kt.overflow=!0}}if(ke.current&&lt.type!=="session_title")return;if(typeof lt.outputCursor=="string"&&F.current){const kt=ga(lt.outputCursor,F.current);if(kt===void 0){pt(Pe);return}if(kt<=0)return;F.current=lt.outputCursor}if(!Iv(je,xe.current))return;je.hubEpoch&&je.hubSequence!==void 0&&(xe.current={epoch:je.hubEpoch,sequence:je.hubSequence}),v(kt=>mr(kt,lt))}lt.type==="stream_request_start"&&Q(null),lt.type==="turn_complete"&&ot();return}if(U==="serve/sessionStatus"){O(lt=>lt+1);const{sessionId:je,running:Pe}=fe;if(typeof je!="string"||typeof Pe!="boolean")return;st.current?.sessionId===je&&(st.current.running=Pe),Pe?Xe.current.add(je):Xe.current.delete(je),!Pe&&Le.current.has(je)&&Ze(),je===ue.current&&v(lt=>Pe?{...lt,run:"running"}:lt.run==="running"||lt.run==="waiting"?{...lt,run:"idle"}:lt),ot();return}if(U==="agent/approvalRequest"||U==="agent/approvalResolved"||U==="serve/approvalSnapshot"||U==="serve/approvalLease"){z({method:U,params:fe});return}if(U==="serve/workerExit"){Xe.current.clear();const je=fe.clean;Q(je?"服务进程已退出,发送消息会自动重启":"服务进程异常退出,发送消息会自动重启"),v(Pe=>({...Pe,run:"idle"}))}});return ne.connect(),()=>{He.current=!1,Lt.current?.abort(),Oe(),Ce(),ye(),ne.close(),o.current=null}},[ot,pt,yt,Ze,l,a,i]);const _=Object.values(j).some(ne=>ne.lease?.holderId&&(ne.lease.expiresAt??0)>X);w.useEffect(()=>{if(!_)return;pe(Date.now());const ne=setInterval(()=>pe(Date.now()),1e3);return()=>clearInterval(ne)},[_]);const Z=async ne=>{ue.current=ne,xe.current=null,F.current=null,ke.current=!1,b(ne),Ve(ne),v(eo()),Y(""),K(null),!(!p.some(ye=>ye.sessionId===ne)&&!Xe.current.has(ne)&&D.current.unsent().some(ye=>ye.sessionId===ne))&&await pt(ne)},ge=()=>{const ne=ob();ue.current=ne,xe.current=null,F.current=null,ke.current=!1,st.current=null,b(ne),Ve(ne),v(eo()),Y(""),K(null)},we=()=>{const ne=D.current.get(ue.current),ye=ne.text.trim(),Oe=o.current;if(!ye&&!ne.files.length||!Oe||f!=="open"||L)return!1;const Ce=ue.current;if(Ee.current.has(Ce)||Xe.current.has(Ce)||x.run==="running"||x.run==="waiting"||Object.values(j).some(je=>je.payload.sessionId===Ce)||Le.current.has(Ce))return!1;ue.current=Ce,b(Ce),Ee.current.add(Ce);const U={clientMessageId:Ca(),draft:D.current.take(Ce),accepted:!1};ze.current.set(Ce,U);const fe=U.draft.draft.files;return Ve(Ce),Y(""),v(je=>({...wS(je,ye,fe.map(Pe=>({name:Pe.name,mime:Pe.mimeType,size:Pe.size})),U.clientMessageId),run:"running"})),Oe.run({sessionId:Ce,task:ye,clientMessageId:U.clientMessageId,displayText:ye,...fe.length?{uploadIds:fe.map(je=>je.id)}:{}}).catch(je=>{He.current&&(Ie(je),je instanceof vi&&(je.kind==="transport"||je.kind==="timeout")?(Le.current.set(Ce,U),Y("连接中断,重新连接后会核对这条消息是否已经送达。")):U.accepted||At(U,je instanceof Error?je.message==="upload not found or expired"?"附件已失效,请移除后重新上传。":je.message:void 0),ue.current===Ce&&v(Pe=>({...Pe,run:"error"})))}).finally(()=>{Ee.current.delete(Ce),ze.current.get(Ce)===U&&ze.current.delete(Ce),He.current&&ue.current===Ce&&!Xe.current.has(Ce)&&v(je=>je.run==="running"?{...je,run:"idle"}:je)}),!0},Ne=(ne,ye,Oe)=>{const Ce=o.current;!Ce||f!=="open"||gt.current.has(ne.requestId)||(gt.current.add(ne.requestId),N(U=>({...U,[ne.requestId]:!0})),Y(""),Ce.approve({...ne,sessionId:ne.sessionId??ue.current??""},ye,Oe).then(()=>z({method:"agent/approvalResolved",params:{requestId:ne.requestId}})).catch(Ie).finally(()=>{gt.current.delete(ne.requestId),N(U=>{const fe={...U};return delete fe[ne.requestId],fe})}))},De=()=>{y&&o.current?.cancel(y).catch(Ie)},Ge=async ne=>{if(!ne?.length||Lt.current)return;const ye=new AbortController,Oe=no();Lt.current=ye,C(ue.current),Y("");const Ce=ue.current;try{for(const U of Array.from(ne)){if(!He.current||ye.signal.aborted)break;const fe=await s1(U,{signal:ye.signal,scope:Oe});He.current&&!ye.signal.aborted&&(D.current.addFile(Ce,fe),Ve(Ce))}}catch(U){Ie(U)}finally{Lt.current===ye&&(Lt.current=null),He.current&&C(null)}},mt=Object.values(j).filter(ne=>!ne.payload.sessionId||ne.payload.sessionId===y),ut=ne=>Object.values(j).filter(ye=>ye.payload.sessionId===ne).length,dt=x.run==="running"||x.run==="waiting"||mt.length>0,tt=w.useMemo(()=>D.current.unsent().filter(ne=>!p.some(ye=>ye.sessionId===ne.sessionId)),[H,p]),Ot=te?.workspace.path??p.find(ne=>ne.sessionId===y)?.cwd??p[0]?.cwd??null,oe=Ot?.split(/[\\/]/).filter(Boolean).pop()??"服务端工作区",Se=x.items.length===0&&mt.length===0,Ae=p.find(ne=>ne.sessionId===y),Re=Se?"新对话":Ae?.customTitle||x.title||Ae?.title||Ae?.preview?.trim()||qv(x,y??"新对话");return{host:i?"hub":"legacy",workspaceApi:i,connection:f,session:t,activeId:y,chat:x,sessions:p,workspaceCwd:Ot,workspaceName:oe,title:Re,workspaceKey:Ot??"hub",configuration:te,configurationVersion:ee,sessionsVersion:k,draft:T,files:G,uploading:L,uploadBusy:q!==null,hasUnsent:D.current.unsent().length>0,localDrafts:tt,uncertain:Le.current.has(y),running:dt,approvals:Object.values(j).map(ne=>({id:ne.payload.requestId,sessionId:ne.payload.sessionId})),approvalCount:ut,approvalContent:mt.map(ne=>c.jsx(pA,{payload:ne.payload,onDecide:Ne,busy:!!A[ne.payload.requestId]||!!(ne.lease?.holderId&&(ne.lease.expiresAt??0)>X),connected:f==="open"},ne.payload.requestId)),workerNote:B,replayNote:J,error:I,clearError:()=>Y(""),setDraft:ne=>{D.current.setText(ue.current,ne),Ve(ue.current)},removeFile:ne=>{D.current.removeFile(ue.current,ne),Ve(ue.current)},selectSession:Z,newSession:ge,send:we,stop:De,addFiles:Ge,refreshSessions:ot,refreshConfiguration:yt,onAuthLost:l}}function ub({onBackToProjects:t,projectName:i,cloudAccount:l,...a}){return c.jsx(lA,{controller:yA(a),onBackToProjects:t,projectName:i,cloudAccount:l})}function Hv(t){if(!t||typeof t!="object")return!1;const i=t;return xa(i.id)&&typeof i.name=="string"&&i.name.length>0&&["stopped","starting","running","stopping","error"].includes(i.status)&&Number.isSafeInteger(i.generation)&&i.generation>=0&&Number.isSafeInteger(i.createdAt)&&i.createdAt>=0&&(i.error===void 0||typeof i.error=="string")}function bA(t){const i=t;if(!i||i.runtime!=="docker"||typeof i.available!="boolean"||!Array.isArray(i.projects)||!i.projects.every(Hv)||new Set(i.projects.map(l=>l.id)).size!==i.projects.length||i.error!==void 0&&typeof i.error!="string")throw new Error("服务端返回了无效的项目列表,请重试。");return i}function cb(){return new URL(window.location.href).searchParams.get("project")}function ma(t,i=!1){const l=new URL(window.location.href);t?l.searchParams.set("project",t):l.searchParams.delete("project"),i||l.searchParams.delete("session"),window.history.replaceState(window.history.state,"",l)}const vA={stopped:"已停止",starting:"正在启动",running:"运行中",stopping:"正在停止",error:"启动失败"};function xA({children:t,onAuthLost:i,accountControl:l,allowLegacy:a=!0}){const[o,f]=w.useState(null),[u,p]=w.useState(!1),[h,m]=w.useState(null),[y,b]=w.useState(""),[x,v]=w.useState(!0),[j,z]=w.useState(null),[A,N]=w.useState(""),[T,M]=w.useState(null),G=w.useRef(null),ae=w.useRef(cb()),D=w.useRef(h),H=w.useRef(o),W=w.useRef(0),q=w.useRef(0),C=w.useRef(null),L=w.useRef(i),B=w.useRef(!1);L.current=i,D.current=h,H.current=o;const Q=w.useCallback(X=>{if(X.status!=="running")return;const pe=cb()===X.id;Ys(),Vs(X.id),ma(X.id,pe),ae.current=null,D.current=X,m(X),b("")},[]),J=w.useCallback(()=>{ae.current=null,D.current=null,m(null),Vs(null),Ys(),ma(null)},[]),K=w.useCallback(async X=>{if(B.current)return;const pe=++q.current,k=W.current;try{const O=bA(await qe("/api/v1/projects",{signal:X}));if(X?.aborted||pe!==q.current||k!==W.current)return;f(O),H.current=O,v(!1),b("");const te=D.current;if(te){const ee=O.projects.find(ve=>ve.id===te.id);(!ee||ee.status!=="running"||ee.generation!==te.generation)&&(J(),b("项目运行状态已经变化,请重新打开项目。未发送的内容不会带入其他项目。"));return}if(!ae.current)return;const R=O.projects.find(ee=>ee.id===ae.current);R?R.status==="running"&&O.available&&Q(R):(ae.current=null,ma(null),b("链接中的项目不存在或当前账号无权访问,请选择一个项目。"))}catch(O){if(X?.aborted||pe!==q.current||k!==W.current)return;v(!1),a&&O instanceof Ke&&O.status===404&&!H.current?(Vs(null),Ys(),B.current=!0,p(!0)):O instanceof Ke&&O.status===401?L.current():b(O instanceof Error?O.message:"无法读取项目,请重试。")}},[J,Q,a]);w.useEffect(()=>{W.current++;const X=new AbortController;K(X.signal);const pe=()=>{K(X.signal)},k=()=>{document.visibilityState==="visible"&&pe()};return window.addEventListener("focus",pe),document.addEventListener("visibilitychange",k),()=>{W.current++,X.abort(),C.current?.abort(),window.removeEventListener("focus",pe),document.removeEventListener("visibilitychange",k),Vs(null),Ys()}},[K]);const I=o?.projects.some(X=>X.status==="starting"||X.status==="stopping");w.useEffect(()=>{if(u||!o)return;const X=new AbortController,pe=setInterval(()=>{K(X.signal)},I?2e3:1e4);return()=>{clearInterval(pe),X.abort()}},[u,!!o,I,K]),w.useEffect(()=>{if(!T)return;const X=document.activeElement,pe=G.current;return pe?.showModal?.(),()=>{pe?.close?.(),X?.focus()}},[T]);const Y=async(X,pe)=>{if(C.current||X==="create"&&!A.trim())return;const k=new AbortController;C.current=k,z(pe?.id??"create"),b(""),q.current++;try{const O=await qe(X==="create"?"/api/v1/projects":`/api/v1/projects/${pe.id}/${X}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(X==="create"?{name:A.trim()}:{}),signal:k.signal});if(k.signal.aborted)return;if(!Hv(O.project)||pe&&pe.id!==O.project.id)throw new Error("服务端返回了无效的项目状态,请刷新列表。");const te=O.project;f(R=>R&&{...R,projects:R.projects.some(ee=>ee.id===te.id)?R.projects.map(ee=>ee.id===te.id?te:ee):[...R.projects,te]}),X==="create"&&N(""),X==="start"&&(ae.current=te.id,ma(te.id),te.status==="running"&&Q(te)),X==="stop"&&(ae.current===te.id&&(ae.current=null,ma(null)),M(null)),await K(k.signal)}catch(O){if(k.signal.aborted)return;O instanceof Ke&&O.status===401?L.current():b(O instanceof Error?O.message:"项目操作失败,请重试。")}finally{C.current===k&&(C.current=null),k.signal.aborted||z(null)}};return u?c.jsx(w.Fragment,{children:t(null)},"single-project"):h?c.jsxs(w.Fragment,{children:[y?c.jsxs("div",{className:"project-connection-note",role:"status",children:["项目状态暂时无法刷新,当前工作台会保留。",y]}):null,t(h,J)]},`${h.id}:${h.generation}`):c.jsxs("main",{className:"projects-page",children:[c.jsxs("header",{className:"projects-header",children:[c.jsxs("div",{className:"auth-brand",children:["CodeShell ",c.jsx("span",{children:l?"Cloud":"Hub"})]}),c.jsx(td,{}),l,c.jsx("h1",{children:"你的项目"}),c.jsx("p",{children:"每个项目有独立的运行环境、文件、会话和配置。启动后进入同一个工作台。"})]}),x?c.jsx("p",{role:"status",children:"正在读取项目…"}):null,y?c.jsxs("div",{className:"form-error",role:"alert",children:[y,c.jsx("button",{className:"library-button",onClick:()=>{K()},children:"刷新项目"})]}):null,o?c.jsxs(c.Fragment,{children:[o.available?null:c.jsxs("p",{className:"form-error",role:"alert",children:["项目运行环境暂不可用。",o.error||"请检查服务端 Docker 是否已启动。"]}),c.jsxs("form",{className:"project-create",onSubmit:X=>{X.preventDefault(),Y("create")},children:[c.jsxs("label",{children:["新项目名称",c.jsx("input",{value:A,maxLength:80,required:!0,placeholder:"例如:个人网站",onChange:X=>N(X.target.value)})]}),c.jsx("button",{className:"library-button primary",disabled:!!j||!A.trim(),type:"submit",children:j==="create"?"正在创建…":"创建项目"})]}),c.jsxs("section",{className:"projects-grid","aria-label":"项目列表",children:[o.projects.length===0?c.jsx("p",{className:"project-empty",children:"创建第一个项目,开始配置模型、添加技能和使用面板。"}):null,o.projects.map(X=>c.jsxs("article",{className:"project-card",children:[c.jsxs("div",{className:"project-card-heading",children:[c.jsx("h2",{children:X.name}),c.jsx("span",{className:`project-status ${X.status}`,children:vA[X.status]})]}),c.jsxs("p",{className:"project-date",children:["创建于 ",new Date(X.createdAt).toLocaleDateString()]}),X.error?c.jsx("p",{className:"form-error",role:"alert",children:X.error}):null,c.jsxs("div",{className:"library-actions",children:[c.jsx("button",{className:"library-button primary",disabled:!!j||!o.available||X.status==="starting"||X.status==="stopping",onClick:()=>X.status==="running"?Q(X):void Y("start",X),children:j===X.id||X.status==="starting"||X.status==="stopping"?"正在处理…":X.status==="running"?"打开项目":"启动并打开"}),X.status==="running"?c.jsx("button",{className:"library-button",disabled:!!j,onClick:()=>M(X),children:"停止项目"}):null]})]},X.id))]})]}):null,T?c.jsxs("dialog",{className:"project-stop-confirm",ref:G,role:"alertdialog","aria-modal":"true","aria-labelledby":"project-stop-title",onCancel:X=>{X.preventDefault(),j||M(null)},children:[c.jsxs("h2",{id:"project-stop-title",children:["停止 ",T.name,"?"]}),c.jsx("p",{children:"正在运行的任务和面板进程会中断。项目文件和配置保留,可稍后重新启动。"}),c.jsxs("div",{className:"library-actions",children:[c.jsx("button",{className:"library-button primary",disabled:!!j,onClick:()=>M(null),children:"继续运行"}),c.jsx("button",{className:"library-button",disabled:!!j,onClick:()=>{Y("stop",T)},children:"确认停止"})]})]}):null]})}function SA({setupToken:t}){const[i,l]=w.useState("checking"),[a,o]=w.useState(),[f,u]=w.useState(),[p,h]=w.useState(!1),[m,y]=w.useState(""),[b,x]=w.useState(""),[v,j]=w.useState(""),[z,A]=w.useState(t),[N,T]=w.useState(""),[M,G]=w.useState(!1),[ae,D]=w.useState(""),H=w.useRef(!1),W=w.useRef(!1),q=w.useRef(!1),C=w.useRef(0),L=w.useRef(i);L.current=i;const B=w.useCallback(Y=>{q.current&&(W.current=Y?.mode==="cloud-account",h(W.current),u(Y?.cloudSession),o(Y?.session),l(Y===null?"legacy":Y.mode==="cloud-account"?Y.authenticated?"authenticated":"cloud-login":Y.initialized?Y.authenticated?"authenticated":"login":"setup"),G(!1),T(""),Y?.initialized&&A(""))},[]),Q=w.useCallback(()=>{q.current&&(C.current++,o(void 0),u(void 0),l(W.current?"cloud-login":"login"),x(""),T(W.current?"Cloud 管理登录已失效,请从桌面 Cloud 管理器重新打开。":"登录已过期或此设备已被撤销,请重新登录。"))},[]),J=w.useCallback(async()=>{if(H.current)return;const Y=++C.current;try{const X=await l1();if(Y===C.current&&W.current&&X?.mode!=="cloud-account"){Q();return}Y===C.current&&B(X)}catch(X){if(!q.current||Y!==C.current)return;if(W.current&&(X instanceof Ke&&X.status===401||X instanceof pb)){Q();return}if(L.current==="authenticated"||L.current==="legacy")return;l("error"),T(X instanceof Error?X.message:"无法连接服务端")}},[B,Q]);w.useEffect(()=>{q.current=!0,J();const Y=()=>{J()},X=()=>{document.visibilityState==="visible"&&J()};return window.addEventListener("focus",Y),document.addEventListener("visibilitychange",X),()=>{q.current=!1,window.removeEventListener("focus",Y),document.removeEventListener("visibilitychange",X)}},[J]),w.useEffect(()=>{if(!f)return;const Y=setTimeout(Q,Math.max(0,f.expiresAt-Date.now()));return()=>clearTimeout(Y)},[f,Q]);const K=async()=>{if(H.current||!W.current)return;H.current=!0;const Y=++C.current;G(!0),D("");try{const X=await Rf("/api/v1/auth/logout");if(!q.current||Y!==C.current)return;if(X.revoked!==!0)throw new Error("Cloud 退出尚未确认。");Q(),T("此 Cloud 工作台已退出。请从桌面 Cloud 管理器重新打开。")}catch(X){if(!q.current||Y!==C.current)return;X instanceof Ke&&X.status===401?Q():D("未能确认退出此 Cloud 工作台,请重试。也可关闭此页并在桌面撤销登录。")}finally{H.current=!1,q.current&&G(!1)}},I=async Y=>{if(Y.preventDefault(),M||W.current)return;const X=++C.current;G(!0),T("");try{const pe=await Rf(`/api/v1/auth/${i==="setup"?"setup":"login"}`,{username:m.trim(),password:b,deviceName:v.trim()||void 0,...i==="setup"?{token:z.trim()}:{}});if(!q.current||X!==C.current)return;if(!pe.authenticated)throw new Error("登录失败,请重试。");x(""),A(""),B({initialized:!0,authenticated:!0,session:pe.session})}catch(pe){if(!q.current||X!==C.current)return;T(pe instanceof Error?pe.message:"登录失败,请重试。"),pe instanceof Ke&&pe.status===409&&J()}finally{q.current&&X===C.current&&G(!1)}};if(i==="authenticated"){const Y=p?{pending:M,error:ae,onLogout:()=>{K()},accountOrigin:f?.accountOrigin}:void 0;return c.jsx(xA,{onAuthLost:Q,allowLegacy:!p,accountControl:Y?c.jsx(xb,{...Y}):void 0,children:(X,pe)=>c.jsx(ub,{session:a,hub:!0,onAuthLost:Q,onCheckAuth:J,projectName:X?.name,onBackToProjects:pe,cloudAccount:Y})},f?`${f.audience}:${f.installationId}:${f.managementEpoch}:${f.accountOrigin}:${f.accountId}:${f.id}`:a?.id)}return i==="legacy"?c.jsx(ub,{session:a,hub:!1,onAuthLost:Q,onCheckAuth:J}):c.jsx("main",{className:"auth-page",children:c.jsxs("section",{className:"auth-card",children:[c.jsx(td,{discover:!1}),c.jsxs("div",{className:"auth-brand",children:["CodeShell ",c.jsx("span",{children:p?"Cloud":"Hub"})]}),i==="checking"?c.jsx("p",{role:"status",children:"正在连接你的工作空间…"}):null,i==="error"?c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"form-error",role:"alert",children:N}),c.jsx("button",{className:"send",onClick:()=>{J()},children:"重试连接"})]}):null,i==="cloud-login"?c.jsxs(c.Fragment,{children:[c.jsx("h1",{children:"请从桌面 Cloud 管理器登录"}),c.jsx("p",{children:"在 CodeShell 桌面端登录云账号,再从 Cloud 管理器打开这个工作台。"}),N?c.jsx("p",{role:"status",children:N}):null,c.jsx("button",{className:"send",onClick:()=>{J()},children:"重新检查 Cloud 登录"})]}):null,i==="setup"||i==="login"?c.jsxs("form",{onSubmit:Y=>{I(Y)},children:[c.jsx("h1",{children:i==="setup"?"创建管理员账号":"登录工作空间"}),c.jsx("p",{children:i==="setup"?"首次启动需要服务端提供的初始化令牌。创建后,可在其他设备使用此账号登录。":"连接服务端,继续你的会话与任务。"}),i==="setup"?c.jsxs("label",{children:["初始化令牌",c.jsx("input",{type:"password",autoComplete:"off",required:!0,value:z,onChange:Y=>A(Y.target.value)})]}):null,c.jsxs("label",{children:["用户名",c.jsx("input",{autoComplete:"username",required:!0,maxLength:64,value:m,onChange:Y=>y(Y.target.value)})]}),c.jsxs("label",{children:["密码",c.jsx("input",{type:"password",autoComplete:i==="setup"?"new-password":"current-password",required:!0,maxLength:256,minLength:i==="setup"?12:void 0,value:b,onChange:Y=>x(Y.target.value)})]}),i==="setup"?c.jsx("small",{children:"密码至少 12 个字符。"}):null,c.jsxs("label",{children:["设备名称 ",c.jsx("span",{children:"(可选)"}),c.jsx("input",{autoComplete:"off",maxLength:100,placeholder:"例如:我的笔记本",value:v,onChange:Y=>j(Y.target.value)})]}),N?c.jsx("p",{className:"form-error",role:"alert",children:N}):null,c.jsx("button",{className:"send",type:"submit",disabled:M,children:M?"正在连接…":i==="setup"?"创建并进入":"登录"})]}):null]})})}function wA(t="/"){"serviceWorker"in navigator&&window.isSecureContext&&navigator.serviceWorker.register(`${t}sw.js`).catch(()=>{})}const fb=b1(),jA=a1(window.location,window.history);C1.createRoot(document.getElementById("root")).render(c.jsx(w.StrictMode,{children:fb?c.jsx(v1,{callback:fb}):c.jsx(SA,{setupToken:jA})}));wA("/");