@agent-dock/cli 0.3.4 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +135 -11
- package/dist/cli.js.map +4 -4
- package/dist/vendor/claude-agent-acp.mjs +279 -279
- package/dist/vendor/codex-acp.mjs +1 -1
- package/dist/vendor/lark-sdk.cjs +1 -1
- package/package.json +1 -1
- package/public/assets/{ImageLightbox-BHea3LMX.js → ImageLightbox-6D7xjwqD.js} +1 -1
- package/public/assets/{PromptEditor-FsL3X16B.js → PromptEditor-CX3eQM-7.js} +1 -1
- package/public/assets/{main-BERHVIlV.js → main-BoLf1Hnm.js} +4 -4
- package/public/index.html +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ImageLightbox-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ImageLightbox-6D7xjwqD.js","assets/index-CFj59-Ku.js","assets/syntax-highlighter-d-DuIo_w.js","assets/index-BaSVfeZs.css","assets/ImageLightbox-cV5bVqLR.css","assets/PromptEditor-CX3eQM-7.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var MM=e=>{throw TypeError(e)};var g1=(e,t,n)=>t.has(e)||MM("Cannot "+n);var H=(e,t,n)=>(g1(e,t,"read from private field"),n?n.call(e):t.get(e)),Ve=(e,t,n)=>t.has(e)?MM("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),be=(e,t,n,r)=>(g1(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),nn=(e,t,n)=>(g1(e,t,"access private method"),n);var j0=(e,t,n,r)=>({set _(i){be(e,t,i,n)},get _(){return H(e,t,r)}});import{j as d,r as _G,c as CG}from"./index-CFj59-Ku.js";import{r as m,c as z0,g as ts,R as Ne,a as _a,H as kG,t as $M,P as NG}from"./syntax-highlighter-d-DuIo_w.js";function EG(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const o4=m.createContext(void 0),Ln=e=>{const t=m.useContext(o4);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},jG=({client:e,children:t})=>(m.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),d.jsx(o4.Provider,{value:e,children:t})),zG={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)};var ql,eN,B5,MG=(B5=class{constructor(){Ve(this,ql,zG);Ve(this,eN,!1)}setTimeoutProvider(e){be(this,ql,e)}setTimeout(e,t){return H(this,ql).setTimeout(e,t)}clearTimeout(e){H(this,ql).clearTimeout(e)}setInterval(e,t){return H(this,ql).setInterval(e,t)}clearInterval(e){H(this,ql).clearInterval(e)}},ql=new WeakMap,eN=new WeakMap,B5);const du=new MG;function $G(e){setTimeout(e,0)}const IG=typeof window>"u"||"Deno"in globalThis;function Zi(){}function RG(e,t){return typeof e=="function"?e(t):e}function a4(e){return typeof e=="number"&&e>=0&&e!==1/0}function l4(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Xn(e,t){return typeof e=="function"?e(t):e}function IM(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:o,stale:a}=e;if(o){if(r){if(t.queryHash!==tN(o,t.options))return!1}else if(!Qh(t.queryKey,o))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||i&&i!==t.state.fetchStatus||s&&!s(t))}function RM(e,t){const{exact:n,status:r,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(ed(t.options.mutationKey)!==ed(s))return!1}else if(!Qh(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function tN(e,t){return((t==null?void 0:t.queryKeyHashFn)||ed)(e)}function ed(e){return JSON.stringify(e,(t,n)=>c_(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function Qh(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t)){if(t.length>e.length)return!1;for(let r=0;r<t.length;r++)if(!Qh(e[r],t[r]))return!1;return!0}const n=Object.keys(t);for(const r of n)if(!Qh(e[r],t[r]))return!1;return!0}return!1}const c4=Object.prototype.hasOwnProperty;function u4(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=OM(e)&&OM(t);if(!r&&!(c_(e)&&c_(t)))return t;const i=(r?e:Object.keys(e)).length,s=r?t:Object.keys(t),o=s.length,a=r?new Array(o):{};let l=0;for(let c=0;c<o;c++){const u=r?c:s[c],h=e[u],f=t[u];if(h===f){a[u]=h,(r?c<i:c4.call(e,u))&&l++;continue}if(h===null||f===null||typeof h!="object"||typeof f!="object"){a[u]=f;continue}const p=u4(h,f,n+1);a[u]=p,p===h&&l++}return i===o&&l===i?e:a}function zv(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n of Object.keys(e))if(!c4.call(t,n)||e[n]!==t[n])return!1;return!0}function OM(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function c_(e){if(!PM(e))return!1;const t=Object.getPrototypeOf(e),n=t==null?void 0:t.constructor;if(n===void 0)return!0;if(typeof n!="function")return!1;const r=n.prototype;return!(!PM(r)||!r.hasOwnProperty("isPrototypeOf")||t!==Object.prototype)}function PM(e){return Object.prototype.toString.call(e)==="[object Object]"}function OG(e){return new Promise(t=>{du.setTimeout(t,e)})}function u_(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?u4(e,t):t}function PG(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(-n):r}function TG(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,n):r}const nN=Symbol();function d4(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===nN?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function rN(e,t){return typeof e=="function"?e(...t):!!e}const iN=Symbol();function AG(e,t,n,r){let i=!1,s;return Object.defineProperties(e,{[iN]:{value:r},signal:{enumerable:!0,get:()=>(s??(s=t()),i||(i=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}}),e}let DG=()=>IG;const sN=()=>DG();var wf=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},bu,Ul,yh,H5,LG=(H5=class extends wf{constructor(){super();Ve(this,bu);Ve(this,Ul);Ve(this,yh);be(this,yh,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){H(this,Ul)||this.setEventListener(H(this,yh))}onUnsubscribe(){var t;this.hasListeners()||((t=H(this,Ul))==null||t.call(this),be(this,Ul,void 0))}setEventListener(t){var n;be(this,yh,t),(n=H(this,Ul))==null||n.call(this),be(this,Ul,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){H(this,bu)!==t&&(be(this,bu,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof H(this,bu)=="boolean"?H(this,bu):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},bu=new WeakMap,Ul=new WeakMap,yh=new WeakMap,H5);const oN=new LG,FG=$G;function BG(){let e=[],t=0,n=a=>{a()},r=a=>{a()},i=FG;const s=a=>{t?e.push(a):i(()=>{n(a)})},o=()=>{const a=e;e=[],a.length&&i(()=>{r(()=>{a.forEach(l=>{n(l)})})})};return{batch:a=>{let l;t++;try{l=a()}finally{t--,t||o()}return l},batchCalls:a=>(...l)=>{s(()=>{a(...l)})},schedule:s,setNotifyFunction:a=>{n=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{i=a}}}const Ar=BG();var wh,Kl,Sh,V5,HG=(V5=class extends wf{constructor(){super();Ve(this,wh,!0);Ve(this,Kl);Ve(this,Sh);be(this,Sh,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){H(this,Kl)||this.setEventListener(H(this,Sh))}onUnsubscribe(){var t;this.hasListeners()||((t=H(this,Kl))==null||t.call(this),be(this,Kl,void 0))}setEventListener(t){var n;be(this,Sh,t),(n=H(this,Kl))==null||n.call(this),be(this,Kl,t(this.setOnline.bind(this)))}setOnline(t){H(this,wh)!==t&&(be(this,wh,t),this.listeners.forEach(n=>{n(t)}))}isOnline(){return H(this,wh)}},wh=new WeakMap,Kl=new WeakMap,Sh=new WeakMap,V5);const xx=new HG;function VG(e){return Math.min(1e3*2**e,3e4)}function h4(e){return(e??"online")==="online"?xx.isOnline():!0}var d_=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function f4(e){let t=!1,n=0,r,i="pending",s,o;const a=new Promise((y,w)=>{s=y,o=w});a.catch(Zi);const l=()=>i!=="pending",c=y=>{var w;if(!l()){const S=new d_(y);x(S),(w=e.onCancel)==null||w.call(e,S)}},u=()=>{t=!0},h=()=>{t=!1},f=()=>oN.isFocused()&&(e.networkMode==="always"||xx.isOnline())&&e.canRun(),p=()=>h4(e.networkMode)&&e.canRun(),g=y=>{l()||(r==null||r(),i="resolved",s(y))},x=y=>{l()||(r==null||r(),i="rejected",o(y))},v=y=>new Promise(w=>{var S;r=C=>{(l()||y())&&w(C)},(S=e.onPause)==null||S.call(e)}).then(()=>{var w;r=void 0,l()||(w=e.onContinue)==null||w.call(e)}),b=()=>{if(l())return;let y;const w=n===0?e.initialPromise:void 0;try{y=w??e.fn()}catch(S){y=Promise.reject(S)}Promise.resolve(y).then(g).catch(S=>{var z;if(l())return;const C=e.retry??(sN()?0:3),_=e.retryDelay??VG,k=typeof _=="function"?_(n,S):_,j=C===!0||typeof C=="number"&&n<C||typeof C=="function"&&C(n,S);if(t||!j){x(S);return}n++,(z=e.onFail)==null||z.call(e,n,S),OG(k).then(()=>l()||f()?void 0:v(f)).then(()=>{t?x(S):b()})})};return{promise:a,status:()=>i,cancel:c,continue:()=>(r==null||r(),a),cancelRetry:u,continueRetry:h,canStart:p,start:()=>(p()?b():v(p).then(b),a)}}var yu,W5,p4=(W5=class{constructor(){Ve(this,yu)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),a4(this.gcTime)&&be(this,yu,du.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(sN()?1/0:3e5))}clearGcTimeout(){H(this,yu)!==void 0&&(du.clearTimeout(H(this,yu)),be(this,yu,void 0))}},yu=new WeakMap,W5);function WG(e){return{onFetch:(t,n)=>{var u,h,f,p,g;const r=t.options,i=(f=(h=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:h.fetchMore)==null?void 0:f.direction,s=((p=t.state.data)==null?void 0:p.pages)||[],o=((g=t.state.data)==null?void 0:g.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const c=async()=>{let x=!1;const v=t,b=S=>{AG(S,()=>t.signal,()=>x=!0,v[iN])},y=d4(t.options,t.fetchOptions),w=async(S,C,_)=>{if(x)return Promise.reject(t.signal.reason);if(C==null&&S.pages.length)return Promise.resolve(S);const j=(()=>{const $={client:t.client,queryKey:t.queryKey,pageParam:C,direction:_?"backward":"forward",meta:t.options.meta};return b($),$})(),z=await y(j),{maxPages:N}=t.options,I=_?TG:PG;return{pages:I(S.pages,z,N),pageParams:I(S.pageParams,C,N)}};if(i&&s.length){const S=i==="backward",C=S?m4:h_,_={pages:s,pageParams:o};a=await w(_,C(r,_),S)}else{const S=e??s.length;do{const C=l===0?o[0]===void 0?r.initialPageParam:o[0]:h_(r,a);if(l>0&&C==null)break;a=await w(a,C),l++}while(l<S)}return a};t.options.persister?t.fetchFn=()=>{var x,v;return(v=(x=t.options).persister)==null?void 0:v.call(x,c,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=c}}}function h_(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function m4(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}function qG(e,t){return t?h_(e,t)!=null:!1}function UG(e,t){return!t||!e.getPreviousPageParam?!1:m4(e,t)!=null}var _h,wu,Ch,Gs,Su,Yr,Ta,pg,_u,Co,Ia,q5,KG=(q5=class extends p4{constructor(t){super();Ve(this,Co);Ve(this,_h);Ve(this,wu);Ve(this,Ch);Ve(this,Gs);Ve(this,Su);Ve(this,Yr);Ve(this,Ta);Ve(this,pg);Ve(this,_u);be(this,_u,!1),be(this,pg,t.defaultOptions),this.setOptions(t.options),this.observers=[],be(this,Su,t.client),be(this,Gs,H(this,Su).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,be(this,wu,AM(this.options)),this.state=t.state??H(this,wu),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return H(this,_h)}get promise(){var t;return(t=H(this,Yr))==null?void 0:t.promise}setOptions(t){if(this.options={...H(this,pg),...t},t!=null&&t._type&&be(this,_h,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=AM(this.options);n.data!==void 0&&(this.setState(TM(n.data,n.dataUpdatedAt)),be(this,wu,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&H(this,Gs).remove(this)}setData(t,n){const r=u_(this.state.data,t,this.options);return nn(this,Co,Ia).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t){nn(this,Co,Ia).call(this,{type:"setState",state:t})}cancel(t){var r,i;const n=(r=H(this,Yr))==null?void 0:r.promise;return(i=H(this,Yr))==null||i.cancel(t),n?n.then(Zi).catch(Zi):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return H(this,wu)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>Xn(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===nN||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.state.data===void 0?!1:this.getObserversCount()>0?this.observers.some(t=>Xn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!l4(this.state.dataUpdatedAt,t)}onFocus(){var t,n;(t=this.observers.find(r=>r.shouldFetchOnWindowFocus()))==null||t.refetch({cancelRefetch:!1}),(n=H(this,Yr))==null||n.continue()}onOnline(){var t,n;(t=this.observers.find(r=>r.shouldFetchOnReconnect()))==null||t.refetch({cancelRefetch:!1}),(n=H(this,Yr))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),H(this,Gs).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){const n=this.observers.indexOf(t);n!==-1&&(this.observers.splice(n,1),this.observers.length||(H(this,Yr)&&(H(this,_u)||this.state.fetchStatus==="paused"&&this.state.status==="pending"?H(this,Yr).cancel({revert:!0}):H(this,Yr).cancelRetry()),this.scheduleGc()),H(this,Gs).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||nn(this,Co,Ia).call(this,{type:"invalidate"})}async fetch(t,n){var u,h,f,p;if(this.state.fetchStatus!=="idle"&&((u=H(this,Yr))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(H(this,Yr)&&H(this,Ta))return H(this,Yr).continueRetry(),H(this,Ta)}if(t&&this.setOptions(t),!this.options.queryFn){const g=this.observers.find(x=>x.options.queryFn);g&&this.setOptions(g.options)}const r=new AbortController,i=g=>{Object.defineProperties(g,{[iN]:{value:r.signal,enumerable:!0},signal:{enumerable:!0,get:()=>(be(this,_u,!0),r.signal)}})},s=()=>{const g=d4(this.options,n),v=(()=>{const b={client:H(this,Su),queryKey:this.queryKey,meta:this.meta};return i(b),b})();return be(this,_u,!1),this.options.persister?this.options.persister(g,v,this):g(v)},a=(()=>{const g={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:H(this,Su),state:this.state,fetchFn:s};return i(g),g})();(h=H(this,_h)==="infinite"?WG(this.options.pages):this.options.behavior)==null||h.onFetch(a,this),be(this,Ch,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=a.fetchOptions)==null?void 0:f.meta))&&nn(this,Co,Ia).call(this,{type:"fetch",meta:(p=a.fetchOptions)==null?void 0:p.meta});const l=be(this,Yr,f4({initialPromise:n==null?void 0:n.initialPromise,fn:a.fetchFn,onCancel:g=>{g instanceof d_&&g.revert&&this.setState({...H(this,Ch),fetchStatus:"idle"}),r.abort()},onFail:(g,x)=>{nn(this,Co,Ia).call(this,{type:"failed",failureCount:g,error:x})},onPause:()=>{nn(this,Co,Ia).call(this,{type:"pause"})},onContinue:()=>{nn(this,Co,Ia).call(this,{type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0})),c=(async()=>{var g,x,v,b,y,w,S,C;try{const _=await l.promise;if(_===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(_),(x=(g=H(this,Gs).config).onSuccess)==null||x.call(g,_,this),(b=(v=H(this,Gs).config).onSettled)==null||b.call(v,_,this.state.error,this),_}catch(_){if(_ instanceof d_){if(_.silent){if(H(this,Yr)!==l&&H(this,Ta))return H(this,Ta);throw _}else if(_.revert){if(this.state.data===void 0)throw _;return this.state.data}}throw nn(this,Co,Ia).call(this,{type:"error",error:_}),(w=(y=H(this,Gs).config).onError)==null||w.call(y,_,this),(C=(S=H(this,Gs).config).onSettled)==null||C.call(S,this.state.data,_,this),_}finally{H(this,Yr)===l&&(be(this,Yr,void 0),be(this,Ta,void 0)),this.scheduleGc()}})();return be(this,Ta,c),l.start(),c}},_h=new WeakMap,wu=new WeakMap,Ch=new WeakMap,Gs=new WeakMap,Su=new WeakMap,Yr=new WeakMap,Ta=new WeakMap,pg=new WeakMap,_u=new WeakMap,Co=new WeakSet,Ia=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...g4(r.data,this.options),fetchMeta:t.meta??null};case"success":const i={...r,...TM(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return be(this,Ch,t.manual?i:void 0),i;case"error":const s=t.error;return{...r,error:s,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Ar.batch(()=>{this.observers.slice().forEach(r=>{r.onQueryUpdate()}),H(this,Gs).notify({query:this,type:"updated",action:t})})},q5);function g4(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:h4(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function TM(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function AM(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Ki,mn,mg,Gi,Cu,kh,Aa,gg,Nh,Eh,ku,Nu,Gl,jh,kn,Pp,f_,p_,m_,g_,v_,x_,b_,y_,U5,v4=(U5=class extends wf{constructor(t,n){super();Ve(this,kn);Ve(this,Ki);Ve(this,mn);Ve(this,mg);Ve(this,Gi);Ve(this,Cu);Ve(this,kh);Ve(this,Aa);Ve(this,gg);Ve(this,Nh);Ve(this,Eh);Ve(this,ku);Ve(this,Nu);Ve(this,Gl);Ve(this,jh,new Set);this.options=n,be(this,Ki,t),be(this,Aa,null),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(H(this,mn).addObserver(this),DM(H(this,mn),this.options)?nn(this,kn,Pp).call(this):this.updateResult(),nn(this,kn,v_).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return w_(H(this,mn),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return w_(H(this,mn),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,nn(this,kn,x_).call(this),nn(this,kn,b_).call(this),H(this,mn).removeObserver(this)}setOptions(t){const n=this.options,r=H(this,mn);if(this.options=H(this,Ki).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Xn(this.options.enabled,H(this,mn))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");nn(this,kn,y_).call(this),H(this,mn).setOptions(this.options),n._defaulted&&!zv(this.options,n)&&H(this,Ki).getQueryCache().notify({type:"observerOptionsUpdated",query:H(this,mn),observer:this});const i=this.hasListeners();i&&LM(H(this,mn),r,this.options,n)&&nn(this,kn,Pp).call(this),this.updateResult(),i&&(H(this,mn)!==r||Xn(this.options.enabled,H(this,mn))!==Xn(n.enabled,H(this,mn))||Xn(this.options.staleTime,H(this,mn))!==Xn(n.staleTime,H(this,mn)))&&nn(this,kn,p_).call(this);const s=nn(this,kn,m_).call(this);i&&(H(this,mn)!==r||Xn(this.options.enabled,H(this,mn))!==Xn(n.enabled,H(this,mn))||s!==H(this,Gl))&&nn(this,kn,g_).call(this,s)}getOptimisticResult(t){const n=H(this,Ki).getQueryCache().build(H(this,Ki),t),r=this.createResult(n,t);return zv(this.getCurrentResult(),r)||(be(this,Gi,r),be(this,kh,this.options),be(this,Cu,H(this,mn).state)),r}getCurrentResult(){return H(this,Gi)}trackResult(t,n){return new Proxy(t,{get:(r,i)=>(this.trackProp(i),n==null||n(i),Reflect.get(r,i))})}trackProp(t){H(this,jh).add(t)}getCurrentQuery(){return H(this,mn)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=H(this,Ki).defaultQueryOptions(t),r=H(this,Ki).getQueryCache().build(H(this,Ki),n);let i=()=>{},s;const o=new Promise(a=>{s=a,i=H(this,Ki).getQueryCache().subscribe(l=>{l.type==="updated"&&l.query.queryHash===r.queryHash&&r.state.data!==void 0&&(i(),a(this.createResult(r,n)))})});return Promise.race([r.fetch(n).then(()=>{const a=this.createResult(r,n);return s==null||s(a),a}).finally(()=>{i()}),o])}fetch(t){return nn(this,kn,Pp).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),H(this,Gi)))}createResult(t,n){var _;const r=H(this,mn),i=this.options,s=H(this,Gi),o=H(this,Cu),a=H(this,kh),l=t!==r?t.state:H(this,mg),{state:c}=t;let u={...c},h=!1,f;if(n._optimisticResults){const k=this.hasListeners(),j=!k&&DM(t,n),z=k&&LM(t,r,n,i);(j||z)&&(u={...u,...g4(c.data,t.options)}),n._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:p,errorUpdatedAt:g,status:x}=u;f=u.data;let v=!1;if(n.placeholderData!==void 0&&f===void 0&&x==="pending"){let k;s!=null&&s.isPlaceholderData&&n.placeholderData===(a==null?void 0:a.placeholderData)?(k=s.data,v=!0):k=typeof n.placeholderData=="function"?n.placeholderData((_=H(this,Eh))==null?void 0:_.state.data,H(this,Eh)):n.placeholderData,k!==void 0&&(x="success",f=u_(s==null?void 0:s.data,k,n),h=!0)}if(n.select&&f!==void 0&&!v)if(s&&f===(o==null?void 0:o.data)&&n.select===H(this,gg))f=H(this,Nh);else try{be(this,gg,n.select),f=n.select(f),f=u_(s==null?void 0:s.data,f,n),be(this,Nh,f),be(this,Aa,null)}catch(k){be(this,Aa,k)}else f===void 0&&be(this,Aa,null);H(this,Aa)&&(p=H(this,Aa),f=H(this,Nh),g=(s==null?void 0:s.error)===p?s.errorUpdatedAt:Date.now(),x="error",h=!1);const b=u.fetchStatus==="fetching",y=x==="pending",w=x==="error",S=y&&b,C=f!==void 0;return{status:x,fetchStatus:u.fetchStatus,isPending:y,isSuccess:x==="success",isError:w,isInitialLoading:S,isLoading:S,data:f,dataUpdatedAt:u.dataUpdatedAt,error:p,errorUpdatedAt:g,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:u.dataUpdateCount>l.dataUpdateCount||u.errorUpdateCount>l.errorUpdateCount,isFetching:b,isRefetching:b&&!y,isLoadingError:w&&!C,isPaused:u.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:w&&C,isStale:aN(t,n),refetch:this.refetch,isEnabled:Xn(n.enabled,t)!==!1}}updateResult(){const t=H(this,Gi),n=this.createResult(H(this,mn),this.options);if(be(this,Cu,H(this,mn).state),be(this,kh,this.options),H(this,Cu).data!==void 0&&be(this,Eh,H(this,mn)),zv(n,t))return;be(this,Gi,n);const i=(()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,o=typeof s=="function"?s():s;if(o==="all"||!o&&!H(this,jh).size||this.options.throwOnError&&H(this,Gi).error!==t.error)return!0;for(const a of o??H(this,jh))if(H(this,Gi)[a]!==t[a])return!0;return!1})();Ar.batch(()=>{i&&this.listeners.forEach(s=>{s(H(this,Gi))}),H(this,Ki).getQueryCache().notify({query:H(this,mn),type:"observerResultsUpdated"})})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&nn(this,kn,v_).call(this)}},Ki=new WeakMap,mn=new WeakMap,mg=new WeakMap,Gi=new WeakMap,Cu=new WeakMap,kh=new WeakMap,Aa=new WeakMap,gg=new WeakMap,Nh=new WeakMap,Eh=new WeakMap,ku=new WeakMap,Nu=new WeakMap,Gl=new WeakMap,jh=new WeakMap,kn=new WeakSet,Pp=function(t){nn(this,kn,y_).call(this);let n=H(this,mn).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Zi)),n},f_=function(t){return!sN()&&Xn(this.options.enabled,H(this,mn))!==!1&&a4(t)},p_=function(){nn(this,kn,x_).call(this);const t=Xn(this.options.staleTime,H(this,mn));if(H(this,Gi).isStale||!nn(this,kn,f_).call(this,t))return;const n=l4(H(this,Gi).dataUpdatedAt,t)+1;be(this,ku,du.setTimeout(()=>{H(this,Gi).isStale||this.updateResult()},n))},m_=function(){return Xn(this.options.refetchInterval,H(this,mn))??!1},g_=function(t){nn(this,kn,b_).call(this),be(this,Gl,t),!(H(this,Gl)===0||!nn(this,kn,f_).call(this,H(this,Gl)))&&be(this,Nu,du.setInterval(()=>{(this.options.refetchIntervalInBackground||oN.isFocused())&&nn(this,kn,Pp).call(this)},H(this,Gl)))},v_=function(){nn(this,kn,p_).call(this),nn(this,kn,g_).call(this,nn(this,kn,m_).call(this))},x_=function(){H(this,ku)!==void 0&&(du.clearTimeout(H(this,ku)),be(this,ku,void 0))},b_=function(){H(this,Nu)!==void 0&&(du.clearInterval(H(this,Nu)),be(this,Nu,void 0))},y_=function(){const t=H(this,Ki).getQueryCache().build(H(this,Ki),this.options);if(t===H(this,mn))return;const n=H(this,mn);be(this,mn,t),be(this,mg,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},U5);function GG(e,t){return Xn(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&Xn(t.retryOnMount,e)===!1)}function DM(e,t){return GG(e,t)||e.state.data!==void 0&&w_(e,t,t.refetchOnMount)}function w_(e,t,n){if(Xn(t.enabled,e)!==!1&&Xn(t.staleTime,e)!=="static"){const r=Xn(n,e);return r==="always"||r!==!1&&aN(e,t)}return!1}function LM(e,t,n,r){return(e!==t||Xn(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&aN(e,n)}function aN(e,t){return Xn(t.enabled,e)!==!1&&e.isStaleByTime(Xn(t.staleTime,e))}var YG=class extends v4{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){e._type="infinite",super.setOptions(e)}getOptimisticResult(e){return e._type="infinite",super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){var p,g;const{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:s,isError:o,isRefetchError:a}=r,l=(g=(p=n.fetchMeta)==null?void 0:p.fetchMore)==null?void 0:g.direction,c=o&&l==="forward",u=i&&l==="forward",h=o&&l==="backward",f=i&&l==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:qG(t,n.data),hasPreviousPage:UG(t,n.data),isFetchNextPageError:c,isFetchingNextPage:u,isFetchPreviousPageError:h,isFetchingPreviousPage:f,isRefetchError:a&&!c&&!h,isRefetching:s&&!u&&!f}}},vg,Qo,ji,Eu,ea,Il,K5,ZG=(K5=class extends p4{constructor(t){super();Ve(this,ea);Ve(this,vg);Ve(this,Qo);Ve(this,ji);Ve(this,Eu);be(this,vg,t.client),this.mutationId=t.mutationId,be(this,ji,t.mutationCache),be(this,Qo,[]),this.state=t.state||x4(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){H(this,Qo).includes(t)||(H(this,Qo).push(t),this.clearGcTimeout(),H(this,ji).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){be(this,Qo,H(this,Qo).filter(n=>n!==t)),this.scheduleGc(),H(this,ji).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){H(this,Qo).length||(this.state.status==="pending"?this.scheduleGc():H(this,ji).remove(this))}continue(){var t;return((t=H(this,Eu))==null?void 0:t.continue())??(this.state.status==="pending"?this.execute(this.state.variables):Promise.resolve())}async execute(t){var a,l,c,u,h,f,p,g,x,v,b,y,w,S,C,_,k,j;const n=()=>{nn(this,ea,Il).call(this,{type:"continue"})},r={client:H(this,vg),meta:this.options.meta,mutationKey:this.options.mutationKey},i=be(this,Eu,f4({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(z,N)=>{nn(this,ea,Il).call(this,{type:"failed",failureCount:z,error:N})},onPause:()=>{nn(this,ea,Il).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>H(this,ji).canRun(this)})),s=this.state.status==="pending",o=!i.canStart();try{if(s)n();else{nn(this,ea,Il).call(this,{type:"pending",variables:t,isPaused:o}),H(this,ji).config.onMutate&&await H(this,ji).config.onMutate(t,this,r);const N=await((l=(a=this.options).onMutate)==null?void 0:l.call(a,t,r));N!==this.state.context&&nn(this,ea,Il).call(this,{type:"pending",context:N,variables:t,isPaused:o})}this.state.isPaused&&i.canStart()&&n();const z=await i.start();return await((u=(c=H(this,ji).config).onSuccess)==null?void 0:u.call(c,z,t,this.state.context,this,r)),await((f=(h=this.options).onSuccess)==null?void 0:f.call(h,z,t,this.state.context,r)),await((g=(p=H(this,ji).config).onSettled)==null?void 0:g.call(p,z,null,this.state.variables,this.state.context,this,r)),await((v=(x=this.options).onSettled)==null?void 0:v.call(x,z,null,t,this.state.context,r)),nn(this,ea,Il).call(this,{type:"success",data:z}),z}catch(z){try{await((y=(b=H(this,ji).config).onError)==null?void 0:y.call(b,z,t,this.state.context,this,r))}catch(N){Promise.reject(N)}try{await((S=(w=this.options).onError)==null?void 0:S.call(w,z,t,this.state.context,r))}catch(N){Promise.reject(N)}try{await((_=(C=H(this,ji).config).onSettled)==null?void 0:_.call(C,void 0,z,this.state.variables,this.state.context,this,r))}catch(N){Promise.reject(N)}try{await((j=(k=this.options).onSettled)==null?void 0:j.call(k,void 0,z,t,this.state.context,r))}catch(N){Promise.reject(N)}throw nn(this,ea,Il).call(this,{type:"error",error:z}),z}finally{H(this,Eu)===i&&be(this,Eu,void 0),H(this,ji).runNext(this)}}},vg=new WeakMap,Qo=new WeakMap,ji=new WeakMap,Eu=new WeakMap,ea=new WeakSet,Il=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Ar.batch(()=>{H(this,Qo).forEach(r=>{r.onMutationUpdate(t)}),H(this,ji).notify({mutation:this,type:"updated",action:t})})},K5);function x4(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Yl,ko,xg,G5,XG=(G5=class extends wf{constructor(t={}){super();Ve(this,Yl);Ve(this,ko);Ve(this,xg);this.config=t,be(this,Yl,new Set),be(this,ko,new Map),be(this,xg,0)}build(t,n,r){const i=new ZG({client:t,mutationCache:this,mutationId:++j0(this,xg)._,options:t.defaultMutationOptions(n),state:r});return this.add(i),i}add(t){H(this,Yl).add(t);const n=M0(t);if(typeof n=="string"){const r=H(this,ko).get(n);r?r.push(t):H(this,ko).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(H(this,Yl).delete(t)){const n=M0(t);if(typeof n=="string"){const r=H(this,ko).get(n);if(r)if(r.length>1){const i=r.indexOf(t);i!==-1&&r.splice(i,1)}else r[0]===t&&H(this,ko).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){var r;const n=M0(t);if(typeof n=="string"){const i=(r=H(this,ko).get(n))==null?void 0:r.find(s=>s.state.status==="pending");return!i||i===t}else return!0}runNext(t){var r,i;const n=M0(t);return typeof n=="string"?((i=(r=H(this,ko).get(n))==null?void 0:r.find(s=>s!==t&&s.state.isPaused))==null?void 0:i.continue())??Promise.resolve():Promise.resolve()}clear(){Ar.batch(()=>{const t=this.getAll();H(this,Yl).clear(),H(this,ko).clear(),t.forEach(n=>{this.notify({type:"removed",mutation:n})})})}getAll(){return Array.from(H(this,Yl))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>RM(n,r))}findAll(t={}){return this.getAll().filter(n=>RM(t,n))}notify(t){Ar.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Ar.batch(()=>Promise.all(t.map(n=>n.continue().catch(Zi))))}},Yl=new WeakMap,ko=new WeakMap,xg=new WeakMap,G5);function M0(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Da,Zl,zi,bg,ca,Tp,S_,Y5,JG=(Y5=class extends wf{constructor(n,r){super();Ve(this,ca);Ve(this,Da);Ve(this,Zl);Ve(this,zi);Ve(this,bg);be(this,Da,n),this.setOptions(r),this.bindMethods(),nn(this,ca,Tp).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var i;const r=this.options;this.options=H(this,Da).defaultMutationOptions(n),zv(this.options,r)||H(this,Da).getMutationCache().notify({type:"observerOptionsUpdated",mutation:H(this,zi),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&ed(r.mutationKey)!==ed(this.options.mutationKey)?this.reset():((i=H(this,zi))==null?void 0:i.state.status)==="pending"&&H(this,zi).setOptions(this.options)}onSubscribe(){this.listeners.size===1&&H(this,zi)&&(H(this,zi).addObserver(this),nn(this,ca,Tp).call(this))}onUnsubscribe(){var n;this.hasListeners()||(n=H(this,zi))==null||n.removeObserver(this)}onMutationUpdate(n){nn(this,ca,Tp).call(this),nn(this,ca,S_).call(this,n)}getCurrentResult(){return H(this,Zl)}reset(){var n;(n=H(this,zi))==null||n.removeObserver(this),be(this,zi,void 0),nn(this,ca,Tp).call(this),nn(this,ca,S_).call(this)}mutate(n,r){var i;return be(this,bg,r),(i=H(this,zi))==null||i.removeObserver(this),be(this,zi,H(this,Da).getMutationCache().build(H(this,Da),this.options)),H(this,zi).addObserver(this),H(this,zi).execute(n)}},Da=new WeakMap,Zl=new WeakMap,zi=new WeakMap,bg=new WeakMap,ca=new WeakSet,Tp=function(){var r;const n=((r=H(this,zi))==null?void 0:r.state)??x4();be(this,Zl,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},S_=function(n){Ar.batch(()=>{var i,s,o,a;const r=H(this,bg);if(r&&this.hasListeners()){const l=H(this,Zl).variables,c=H(this,Zl).context,u={client:H(this,Da),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(i=r.onSuccess)==null||i.call(r,n.data,l,c,u)}catch(h){Promise.reject(h)}try{(s=r.onSettled)==null||s.call(r,n.data,null,l,c,u)}catch(h){Promise.reject(h)}}else if((n==null?void 0:n.type)==="error"){try{(o=r.onError)==null||o.call(r,n.error,l,c,u)}catch(h){Promise.reject(h)}try{(a=r.onSettled)==null||a.call(r,void 0,n.error,l,c,u)}catch(h){Promise.reject(h)}}}this.listeners.forEach(l=>{l(H(this,Zl))})})},Y5),ta,Z5,QG=(Z5=class extends wf{constructor(t={}){super();Ve(this,ta);this.config=t,be(this,ta,new Map)}build(t,n,r){const i=n.queryKey,s=n.queryHash??tN(i,n);let o=this.get(s);return o||(o=new KG({client:t,queryKey:i,queryHash:s,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(i)}),this.add(o)),o}add(t){H(this,ta).has(t.queryHash)||(H(this,ta).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){H(this,ta).get(t.queryHash)===t&&(t.destroy(),H(this,ta).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Ar.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return H(this,ta).get(t)}getAll(){return[...H(this,ta).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>IM(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>IM(t,r)):n}notify(t){Ar.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Ar.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Ar.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},ta=new WeakMap,Z5),sr,Xl,Jl,zh,Mh,Ql,$h,Ih,X5,eY=(X5=class{constructor(e={}){Ve(this,sr);Ve(this,Xl);Ve(this,Jl);Ve(this,zh);Ve(this,Mh);Ve(this,Ql);Ve(this,$h);Ve(this,Ih);be(this,sr,e.queryCache||new QG),be(this,Xl,e.mutationCache||new XG),be(this,Jl,e.defaultOptions||{}),be(this,zh,new Map),be(this,Mh,new Map),be(this,Ql,0)}mount(){j0(this,Ql)._++,H(this,Ql)===1&&(be(this,$h,oN.subscribe(async e=>{e&&(await this.resumePausedMutations(),H(this,sr).onFocus())})),be(this,Ih,xx.subscribe(async e=>{e&&(await this.resumePausedMutations(),H(this,sr).onOnline())})))}unmount(){var e,t;j0(this,Ql)._--,H(this,Ql)===0&&((e=H(this,$h))==null||e.call(this),be(this,$h,void 0),(t=H(this,Ih))==null||t.call(this),be(this,Ih,void 0))}isFetching(e){return H(this,sr).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return H(this,Xl).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=H(this,sr).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=H(this,sr).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Xn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return H(this,sr).findAll(e).map(({queryKey:t,state:n})=>[t,n.data])}setQueryData(e,t,n){var o;const r=this.defaultQueryOptions({queryKey:e}),i=(o=H(this,sr).get(r.queryHash))==null?void 0:o.state.data,s=RG(t,i);if(s!==void 0)return H(this,sr).build(this,r).setData(s,{...n,manual:!0})}setQueriesData(e,t,n){return Ar.batch(()=>H(this,sr).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=H(this,sr).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=H(this,sr);Ar.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=H(this,sr);return Ar.batch(()=>{const r=n.findAll(e),i=new Set(r);return r.forEach(s=>{s.reset()}),this.refetchQueries({type:"active",predicate:s=>i.has(s)},t)})}cancelQueries(e,t={}){const n={revert:!0,...t},r=Ar.batch(()=>H(this,sr).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(Zi).catch(Zi)}invalidateQueries(e,t={}){return Ar.batch(()=>(H(this,sr).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Ar.batch(()=>H(this,sr).findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);const o=i.state.fetchStatus==="paused";return(!n.throwOnError||o)&&(s=s.catch(Zi)),o?Promise.resolve():s}));return Promise.all(r).then(Zi)}async query(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=H(this,sr).build(this,t),r=n.isStaleByTime(Xn(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=H(this,sr).build(this,t);return n.isStaleByTime(Xn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Zi).catch(Zi)}infiniteQuery(e){return e._type="infinite",this.query(e)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Zi).catch(Zi)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return xx.isOnline()?H(this,Xl).resumePausedMutations():Promise.resolve()}getQueryCache(){return H(this,sr)}getMutationCache(){return H(this,Xl)}getDefaultOptions(){return H(this,Jl)}setDefaultOptions(e){be(this,Jl,e)}setQueryDefaults(e,t){H(this,zh).set(ed(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...H(this,zh).values()],n={};return t.forEach(r=>{Qh(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){H(this,Mh).set(ed(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...H(this,Mh).values()],n={};return t.forEach(r=>{Qh(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...H(this,Jl).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=tN(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===nN&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...H(this,Jl).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){H(this,sr).clear(),H(this,Xl).clear()}},sr=new WeakMap,Xl=new WeakMap,Jl=new WeakMap,zh=new WeakMap,Mh=new WeakMap,Ql=new WeakMap,$h=new WeakMap,Ih=new WeakMap,X5);const b4=m.createContext(!1),tY=()=>m.useContext(b4);b4.Provider;function nY(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}const rY=m.createContext(nY()),iY=()=>m.useContext(rY),sY=(e,t,n)=>{const r=(n==null?void 0:n.state.status)==="error"&&typeof e.throwOnError=="function"?rN(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},oY=e=>{m.useEffect(()=>{e.clearReset()},[e])},aY=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||rN(n,[e.error,r])),lY=e=>{if(e.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},cY=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,uY=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function y4(e,t,n){const r=tY(),i=iY(),s=Ln(),o=s.defaultQueryOptions(e),a=s.getQueryCache().get(o.queryHash),l=e.subscribed!==!1;o._optimisticResults=r?"isRestoring":l?"optimistic":void 0,lY(o),sY(o,i,a),oY(i);const[c]=m.useState(()=>new t(s,o)),u=c.getOptimisticResult(o);m.useEffect(()=>{c.setOptions(o)},[o,c]);const h=!r&&l;if(m.useSyncExternalStore(m.useCallback(f=>{const p=h?c.subscribe(Ar.batchCalls(f)):Zi;return c.updateResult(),p},[c,h]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),cY(o,u))throw uY(o,c,i);if(aY({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:a,suspense:o.suspense}))throw u.error;return o.notifyOnChangeProps?u:c.trackResult(u)}function Et(e,t){return y4(e,v4)}function yt(e,t){const n=Ln(),[r]=m.useState(()=>new JG(n,e));m.useEffect(()=>{r.setOptions(e)},[r,e]);const i=m.useSyncExternalStore(m.useCallback(o=>r.subscribe(Ar.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=m.useCallback((...o)=>{r.mutate(o[0],o[1]).catch(Zi)},[r]);if(i.error&&rN(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}function dY(e,t){return y4(e,YG)}const hY="modulepreload",fY=function(e){return"/"+e},FM={},w4=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let o=function(c){return Promise.all(c.map(u=>Promise.resolve(u).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=o(n.map(c=>{if(c=fY(c),c in FM)return;FM[c]=!0;const u=c.endsWith(".css"),h=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${h}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":hY,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((p,g)=>{f.addEventListener("load",p),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return t().catch(s)})};function lN({open:e,children:t,ms:n=180}){const r=m.useRef(t),[i,s]=m.useState(e);return e&&(r.current=t),m.useEffect(()=>{if(e){s(!0);return}const o=window.setTimeout(()=>s(!1),n);return()=>window.clearTimeout(o)},[e,n]),!e&&!i?null:d.jsx("div",{style:{display:"contents"},...e?{}:{"data-closing":""},children:e?t:r.current})}let Bl=null;const bx=new Set,pY=e=>(bx.add(e),()=>{bx.delete(e)}),BM=()=>Bl;function xr(e,t){if(!((Bl==null?void 0:Bl.kind)===e&&Bl.sessionId===(t==null?void 0:t.sessionId))){Bl={kind:e,...t!=null&&t.sessionId?{sessionId:t.sessionId}:{}};for(const n of bx)n()}}function Ni(){if(Bl!==null){Bl=null;for(const e of bx)e()}}function mY(){return m.useSyncExternalStore(pY,BM,BM)}function gY({dialogs:e}){const t=mY();return d.jsx(d.Fragment,{children:Object.keys(e).map(n=>{const r=(t==null?void 0:t.kind)===n,i=e[n],s=r?typeof i=="function"?i(t.sessionId):i:null;return d.jsx(lN,{open:r,children:s},n)})})}const vY=e=>(t,n)=>{const r=m.useRef(!1);e(()=>()=>{r.current=!1},[]),e(()=>{if(!r.current)r.current=!0;else return t()},n)},iu=e=>typeof e=="function",cN=e=>typeof e=="number"&&!Number.isNaN(e),xY=e=>typeof e>"u",bY=e=>e!=null,yY=e=>bY(e)&&iu(e.then),bn=e=>{const t=m.useRef(e);t.current=m.useMemo(()=>e,[e]);const n=m.useRef(void 0);return n.current||(n.current=function(...r){return t.current.apply(this,r)}),n.current},Pu=vY(m.useEffect);function HM(e,t){if(e===t)return!0;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function Lg(e){const t=m.useRef(e);return t.current=e,t}const Fg=e=>{const t=Lg(e);m.useEffect(()=>()=>{t.current()},[])};var v1,VM;function uN(){if(VM)return v1;VM=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return v1=e,v1}var x1,WM;function wY(){if(WM)return x1;WM=1;var e=typeof z0=="object"&&z0&&z0.Object===Object&&z0;return x1=e,x1}var b1,qM;function S4(){if(qM)return b1;qM=1;var e=wY(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return b1=n,b1}var y1,UM;function SY(){if(UM)return y1;UM=1;var e=S4(),t=function(){return e.Date.now()};return y1=t,y1}var w1,KM;function _Y(){if(KM)return w1;KM=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return w1=t,w1}var S1,GM;function CY(){if(GM)return S1;GM=1;var e=_Y(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return S1=n,S1}var _1,YM;function _4(){if(YM)return _1;YM=1;var e=S4(),t=e.Symbol;return _1=t,_1}var C1,ZM;function kY(){if(ZM)return C1;ZM=1;var e=_4(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;function s(o){var a=n.call(o,i),l=o[i];try{o[i]=void 0;var c=!0}catch{}var u=r.call(o);return c&&(a?o[i]=l:delete o[i]),u}return C1=s,C1}var k1,XM;function NY(){if(XM)return k1;XM=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return k1=n,k1}var N1,JM;function EY(){if(JM)return N1;JM=1;var e=_4(),t=kY(),n=NY(),r="[object Null]",i="[object Undefined]",s=e?e.toStringTag:void 0;function o(a){return a==null?a===void 0?i:r:s&&s in Object(a)?t(a):n(a)}return N1=o,N1}var E1,QM;function jY(){if(QM)return E1;QM=1;function e(t){return t!=null&&typeof t=="object"}return E1=e,E1}var j1,e$;function zY(){if(e$)return j1;e$=1;var e=EY(),t=jY(),n="[object Symbol]";function r(i){return typeof i=="symbol"||t(i)&&e(i)==n}return j1=r,j1}var z1,t$;function MY(){if(t$)return z1;t$=1;var e=CY(),t=uN(),n=zY(),r=NaN,i=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,o=/^0o[0-7]+$/i,a=parseInt;function l(c){if(typeof c=="number")return c;if(n(c))return r;if(t(c)){var u=typeof c.valueOf=="function"?c.valueOf():c;c=t(u)?u+"":u}if(typeof c!="string")return c===0?c:+c;c=e(c);var h=s.test(c);return h||o.test(c)?a(c.slice(2),h?2:8):i.test(c)?r:+c}return z1=l,z1}var M1,n$;function C4(){if(n$)return M1;n$=1;var e=uN(),t=SY(),n=MY(),r="Expected a function",i=Math.max,s=Math.min;function o(a,l,c){var u,h,f,p,g,x,v=0,b=!1,y=!1,w=!0;if(typeof a!="function")throw new TypeError(r);l=n(l)||0,e(c)&&(b=!!c.leading,y="maxWait"in c,f=y?i(n(c.maxWait)||0,l):f,w="trailing"in c?!!c.trailing:w);function S(R){var E=u,M=h;return u=h=void 0,v=R,p=a.apply(M,E),p}function C(R){return v=R,g=setTimeout(j,l),b?S(R):p}function _(R){var E=R-x,M=R-v,P=l-E;return y?s(P,f-M):P}function k(R){var E=R-x,M=R-v;return x===void 0||E>=l||E<0||y&&M>=f}function j(){var R=t();if(k(R))return z(R);g=setTimeout(j,_(R))}function z(R){return g=void 0,w&&u?S(R):(u=h=void 0,p)}function N(){g!==void 0&&clearTimeout(g),v=0,u=x=h=g=void 0}function I(){return g===void 0?p:z(t())}function $(){var R=t(),E=k(R);if(u=arguments,h=this,x=R,E){if(g===void 0)return C(x);if(y)return clearTimeout(g),g=setTimeout(j,l),S(x)}return g===void 0&&(g=setTimeout(j,l)),p}return $.cancel=N,$.flush=I,$}return M1=o,M1}var $Y=C4();const IY=ts($Y),k4=!!(typeof window<"u"&&window.document&&window.document.createElement);var $1,r$;function RY(){if(r$)return $1;r$=1;var e=C4(),t=uN(),n="Expected a function";function r(i,s,o){var a=!0,l=!0;if(typeof i!="function")throw new TypeError(n);return t(o)&&(a="leading"in o?!!o.leading:a,l="trailing"in o?!!o.trailing:l),e(i,s,{leading:a,maxWait:s,trailing:l})}return $1=r,$1}var OY=RY();const PY=ts(OY),Db=e=>{m.useEffect(()=>{const t=e==null?void 0:e();if(!yY(t))return t},[])};function N4(e,t){if(!k4)return;if(!e)return t;let n;return iu(e)?n=e():"current"in e?n=e.current:n=e,n}const TY=e=>(n,r,i)=>{const s=m.useRef(!1),o=m.useRef([]),a=m.useRef([]),l=m.useRef(void 0);e(()=>{var c;const h=(Array.isArray(i)?i:[i]).map(f=>N4(f));if(!s.current){s.current=!0,o.current=h,a.current=r,l.current=n();return}(h.length!==o.current.length||!HM(o.current,h)||!HM(a.current,r))&&((c=l.current)===null||c===void 0||c.call(l),o.current=h,a.current=r,l.current=n())}),Fg(()=>{var c;(c=l.current)===null||c===void 0||c.call(l),s.current=!1})},AY=TY(m.useEffect);var Mv={exports:{}},DY=Mv.exports,i$;function E4(){return i$||(i$=1,(function(e,t){(function(n,r){e.exports=r()})(DY,(function(){var n=1e3,r=6e4,i=36e5,s="millisecond",o="second",a="minute",l="hour",c="day",u="week",h="month",f="quarter",p="year",g="date",x="Invalid Date",v=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,b=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,y={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(E){var M=["th","st","nd","rd"],P=E%100;return"["+E+(M[(P-20)%10]||M[P]||M[0])+"]"}},w=function(E,M,P){var A=String(E);return!A||A.length>=M?E:""+Array(M+1-A.length).join(P)+E},S={s:w,z:function(E){var M=-E.utcOffset(),P=Math.abs(M),A=Math.floor(P/60),D=P%60;return(M<=0?"+":"-")+w(A,2,"0")+":"+w(D,2,"0")},m:function E(M,P){if(M.date()<P.date())return-E(P,M);var A=12*(P.year()-M.year())+(P.month()-M.month()),D=M.clone().add(A,h),F=P-D<0,O=M.clone().add(A+(F?-1:1),h);return+(-(A+(P-D)/(F?D-O:O-D))||0)},a:function(E){return E<0?Math.ceil(E)||0:Math.floor(E)},p:function(E){return{M:h,y:p,w:u,d:c,D:g,h:l,m:a,s:o,ms:s,Q:f}[E]||String(E||"").toLowerCase().replace(/s$/,"")},u:function(E){return E===void 0}},C="en",_={};_[C]=y;var k="$isDayjsObject",j=function(E){return E instanceof $||!(!E||!E[k])},z=function E(M,P,A){var D;if(!M)return C;if(typeof M=="string"){var F=M.toLowerCase();_[F]&&(D=F),P&&(_[F]=P,D=F);var O=M.split("-");if(!D&&O.length>1)return E(O[0])}else{var B=M.name;_[B]=M,D=B}return!A&&D&&(C=D),D||!A&&C},N=function(E,M){if(j(E))return E.clone();var P=typeof M=="object"?M:{};return P.date=E,P.args=arguments,new $(P)},I=S;I.l=z,I.i=j,I.w=function(E,M){return N(E,{locale:M.$L,utc:M.$u,x:M.$x,$offset:M.$offset})};var $=(function(){function E(P){this.$L=z(P.locale,null,!0),this.parse(P),this.$x=this.$x||P.x||{},this[k]=!0}var M=E.prototype;return M.parse=function(P){this.$d=(function(A){var D=A.date,F=A.utc;if(D===null)return new Date(NaN);if(I.u(D))return new Date;if(D instanceof Date)return new Date(D);if(typeof D=="string"&&!/Z$/i.test(D)){var O=D.match(v);if(O){var B=O[2]-1||0,V=(O[7]||"0").substring(0,3);return F?new Date(Date.UTC(O[1],B,O[3]||1,O[4]||0,O[5]||0,O[6]||0,V)):new Date(O[1],B,O[3]||1,O[4]||0,O[5]||0,O[6]||0,V)}}return new Date(D)})(P),this.init()},M.init=function(){var P=this.$d;this.$y=P.getFullYear(),this.$M=P.getMonth(),this.$D=P.getDate(),this.$W=P.getDay(),this.$H=P.getHours(),this.$m=P.getMinutes(),this.$s=P.getSeconds(),this.$ms=P.getMilliseconds()},M.$utils=function(){return I},M.isValid=function(){return this.$d.toString()!==x},M.isSame=function(P,A){var D=N(P);return this.startOf(A)<=D&&D<=this.endOf(A)},M.isAfter=function(P,A){return N(P)<this.startOf(A)},M.isBefore=function(P,A){return this.endOf(A)<N(P)},M.$g=function(P,A,D){return I.u(P)?this[A]:this.set(D,P)},M.unix=function(){return Math.floor(this.valueOf()/1e3)},M.valueOf=function(){return this.$d.getTime()},M.startOf=function(P,A){var D=this,F=!!I.u(A)||A,O=I.p(P),B=function(ae,ne){var re=I.w(D.$u?Date.UTC(D.$y,ne,ae):new Date(D.$y,ne,ae),D);return F?re:re.endOf(c)},V=function(ae,ne){return I.w(D.toDate()[ae].apply(D.toDate("s"),(F?[0,0,0,0]:[23,59,59,999]).slice(ne)),D)},T=this.$W,W=this.$M,L=this.$D,q="set"+(this.$u?"UTC":"");switch(O){case p:return F?B(1,0):B(31,11);case h:return F?B(1,W):B(0,W+1);case u:var X=this.$locale().weekStart||0,J=(T<X?T+7:T)-X;return B(F?L-J:L+(6-J),W);case c:case g:return V(q+"Hours",0);case l:return V(q+"Minutes",1);case a:return V(q+"Seconds",2);case o:return V(q+"Milliseconds",3);default:return this.clone()}},M.endOf=function(P){return this.startOf(P,!1)},M.$set=function(P,A){var D,F=I.p(P),O="set"+(this.$u?"UTC":""),B=(D={},D[c]=O+"Date",D[g]=O+"Date",D[h]=O+"Month",D[p]=O+"FullYear",D[l]=O+"Hours",D[a]=O+"Minutes",D[o]=O+"Seconds",D[s]=O+"Milliseconds",D)[F],V=F===c?this.$D+(A-this.$W):A;if(F===h||F===p){var T=this.clone().set(g,1);T.$d[B](V),T.init(),this.$d=T.set(g,Math.min(this.$D,T.daysInMonth())).$d}else B&&this.$d[B](V);return this.init(),this},M.set=function(P,A){return this.clone().$set(P,A)},M.get=function(P){return this[I.p(P)]()},M.add=function(P,A){var D,F=this;P=Number(P);var O=I.p(A),B=function(W){var L=N(F);return I.w(L.date(L.date()+Math.round(W*P)),F)};if(O===h)return this.set(h,this.$M+P);if(O===p)return this.set(p,this.$y+P);if(O===c)return B(1);if(O===u)return B(7);var V=(D={},D[a]=r,D[l]=i,D[o]=n,D)[O]||1,T=this.$d.getTime()+P*V;return I.w(T,this)},M.subtract=function(P,A){return this.add(-1*P,A)},M.format=function(P){var A=this,D=this.$locale();if(!this.isValid())return D.invalidDate||x;var F=P||"YYYY-MM-DDTHH:mm:ssZ",O=I.z(this),B=this.$H,V=this.$m,T=this.$M,W=D.weekdays,L=D.months,q=D.meridiem,X=function(ne,re,ie,G){return ne&&(ne[re]||ne(A,F))||ie[re].slice(0,G)},J=function(ne){return I.s(B%12||12,ne,"0")},ae=q||function(ne,re,ie){var G=ne<12?"AM":"PM";return ie?G.toLowerCase():G};return F.replace(b,(function(ne,re){return re||(function(ie){switch(ie){case"YY":return String(A.$y).slice(-2);case"YYYY":return I.s(A.$y,4,"0");case"M":return T+1;case"MM":return I.s(T+1,2,"0");case"MMM":return X(D.monthsShort,T,L,3);case"MMMM":return X(L,T);case"D":return A.$D;case"DD":return I.s(A.$D,2,"0");case"d":return String(A.$W);case"dd":return X(D.weekdaysMin,A.$W,W,2);case"ddd":return X(D.weekdaysShort,A.$W,W,3);case"dddd":return W[A.$W];case"H":return String(B);case"HH":return I.s(B,2,"0");case"h":return J(1);case"hh":return J(2);case"a":return ae(B,V,!0);case"A":return ae(B,V,!1);case"m":return String(V);case"mm":return I.s(V,2,"0");case"s":return String(A.$s);case"ss":return I.s(A.$s,2,"0");case"SSS":return I.s(A.$ms,3,"0");case"Z":return O}return null})(ne)||O.replace(":","")}))},M.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},M.diff=function(P,A,D){var F,O=this,B=I.p(A),V=N(P),T=(V.utcOffset()-this.utcOffset())*r,W=this-V,L=function(){return I.m(O,V)};switch(B){case p:F=L()/12;break;case h:F=L();break;case f:F=L()/3;break;case u:F=(W-T)/6048e5;break;case c:F=(W-T)/864e5;break;case l:F=W/i;break;case a:F=W/r;break;case o:F=W/n;break;default:F=W}return D?F:I.a(F)},M.daysInMonth=function(){return this.endOf(h).$D},M.$locale=function(){return _[this.$L]},M.locale=function(P,A){if(!P)return this.$L;var D=this.clone(),F=z(P,A,!0);return F&&(D.$L=F),D},M.clone=function(){return I.w(this.$d,this)},M.toDate=function(){return new Date(this.valueOf())},M.toJSON=function(){return this.isValid()?this.toISOString():null},M.toISOString=function(){return this.$d.toISOString()},M.toString=function(){return this.$d.toUTCString()},E})(),R=$.prototype;return N.prototype=R,[["$ms",s],["$s",o],["$m",a],["$H",l],["$W",c],["$M",h],["$y",p],["$D",g]].forEach((function(E){R[E[1]]=function(M){return this.$g(M,E[0],E[1])}})),N.extend=function(E,M){return E.$i||(E(M,$,N),E.$i=!0),N},N.locale=z,N.isDayjs=j,N.unix=function(E){return N(1e3*E)},N.en=_[C],N.Ls=_,N.p={},N}))})(Mv)),Mv.exports}var LY=E4();const Tr=ts(LY),I1=e=>{if(!e)return 0;const t=Tr(e).valueOf()-Date.now();return t<0?0:t},FY=e=>({days:Math.floor(e/864e5),hours:Math.floor(e/36e5)%24,minutes:Math.floor(e/6e4)%60,seconds:Math.floor(e/1e3)%60,milliseconds:Math.floor(e)%1e3}),BY=(e={})=>{const{leftTime:t,targetDate:n,interval:r=1e3,onEnd:i}=e||{},s=m.useMemo(()=>cN(t)&&t>0?Date.now()+t:void 0,[t]),o="leftTime"in e?s:n,[a,l]=m.useState(()=>I1(o)),c=Lg(i);m.useEffect(()=>{if(!o){l(0);return}l(I1(o));const h=setInterval(()=>{var f;const p=I1(o);l(p),p===0&&(clearInterval(h),(f=c.current)===null||f===void 0||f.call(c))},r);return()=>clearInterval(h)},[o,r]);const u=m.useMemo(()=>FY(a),[a]);return[a,u]};function HY(){const e=(typeof global>"u"?"undefined":typeof global)=="object"&&global&&global.Object===Object&&global,t=typeof self=="object"&&self&&self.Object===Object&&self;return e||t}HY()||(global.Date=Date);function VY(e,t){var n;const r=Lg(e),i=(n=t==null?void 0:t.wait)!==null&&n!==void 0?n:1e3,s=m.useMemo(()=>IY((...o)=>r.current(...o),i,t),[]);return Fg(()=>{s.cancel()}),{run:s,cancel:s.cancel,flush:s.flush}}function WY(e,t){const[n,r]=m.useState(e),{run:i}=VY(()=>{r(e)},t);return m.useEffect(()=>{i()},[e]),n}function yr(e,t,n={}){const{enable:r=!0}=n,i=Lg(t);AY(()=>{if(!r)return;const s=N4(n.target,window);if(!(s!=null&&s.addEventListener))return;const o=l=>i.current(l),a=Array.isArray(e)?e:[e];return a.forEach(l=>{s.addEventListener(l,o,{capture:n.capture,once:n.once,passive:n.passive})}),()=>{a.forEach(l=>{s.removeEventListener(l,o,{capture:n.capture})})}},[e,n.capture,n.once,n.passive,r],n.target)}var j4=(function(){if(typeof Map<"u")return Map;function e(t,n){var r=-1;return t.some(function(i,s){return i[0]===n?(r=s,!0):!1}),r}return(function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(n){var r=e(this.__entries__,n),i=this.__entries__[r];return i&&i[1]},t.prototype.set=function(n,r){var i=e(this.__entries__,n);~i?this.__entries__[i][1]=r:this.__entries__.push([n,r])},t.prototype.delete=function(n){var r=this.__entries__,i=e(r,n);~i&&r.splice(i,1)},t.prototype.has=function(n){return!!~e(this.__entries__,n)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(n,r){r===void 0&&(r=null);for(var i=0,s=this.__entries__;i<s.length;i++){var o=s[i];n.call(r,o[1],o[0])}},t})()})(),__=typeof window<"u"&&typeof document<"u"&&window.document===document,yx=(function(){return typeof global<"u"&&global.Math===Math?global:typeof self<"u"&&self.Math===Math?self:typeof window<"u"&&window.Math===Math?window:Function("return this")()})(),qY=(function(){return typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(yx):function(e){return setTimeout(function(){return e(Date.now())},1e3/60)}})(),UY=2;function KY(e,t){var n=!1,r=!1,i=0;function s(){n&&(n=!1,e()),r&&a()}function o(){qY(s)}function a(){var l=Date.now();if(n){if(l-i<UY)return;r=!0}else n=!0,r=!1,setTimeout(o,t);i=l}return a}var GY=20,YY=["top","right","bottom","left","width","height","size","weight"],ZY=typeof MutationObserver<"u",XY=(function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=KY(this.refresh.bind(this),GY)}return e.prototype.addObserver=function(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()},e.prototype.removeObserver=function(t){var n=this.observers_,r=n.indexOf(t);~r&&n.splice(r,1),!n.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){var t=this.updateObservers_();t&&this.refresh()},e.prototype.updateObservers_=function(){var t=this.observers_.filter(function(n){return n.gatherActive(),n.hasActive()});return t.forEach(function(n){return n.broadcastActive()}),t.length>0},e.prototype.connect_=function(){!__||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),ZY?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){!__||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var n=t.propertyName,r=n===void 0?"":n,i=YY.some(function(s){return!!~r.indexOf(s)});i&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e})(),z4=(function(e,t){for(var n=0,r=Object.keys(t);n<r.length;n++){var i=r[n];Object.defineProperty(e,i,{value:t[i],enumerable:!1,writable:!1,configurable:!0})}return e}),ef=(function(e){var t=e&&e.ownerDocument&&e.ownerDocument.defaultView;return t||yx}),M4=Lb(0,0,0,0);function wx(e){return parseFloat(e)||0}function s$(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return t.reduce(function(r,i){var s=e["border-"+i+"-width"];return r+wx(s)},0)}function JY(e){for(var t=["top","right","bottom","left"],n={},r=0,i=t;r<i.length;r++){var s=i[r],o=e["padding-"+s];n[s]=wx(o)}return n}function QY(e){var t=e.getBBox();return Lb(0,0,t.width,t.height)}function eZ(e){var t=e.clientWidth,n=e.clientHeight;if(!t&&!n)return M4;var r=ef(e).getComputedStyle(e),i=JY(r),s=i.left+i.right,o=i.top+i.bottom,a=wx(r.width),l=wx(r.height);if(r.boxSizing==="border-box"&&(Math.round(a+s)!==t&&(a-=s$(r,"left","right")+s),Math.round(l+o)!==n&&(l-=s$(r,"top","bottom")+o)),!nZ(e)){var c=Math.round(a+s)-t,u=Math.round(l+o)-n;Math.abs(c)!==1&&(a-=c),Math.abs(u)!==1&&(l-=u)}return Lb(i.left,i.top,a,l)}var tZ=(function(){return typeof SVGGraphicsElement<"u"?function(e){return e instanceof ef(e).SVGGraphicsElement}:function(e){return e instanceof ef(e).SVGElement&&typeof e.getBBox=="function"}})();function nZ(e){return e===ef(e).document.documentElement}function rZ(e){return __?tZ(e)?QY(e):eZ(e):M4}function iZ(e){var t=e.x,n=e.y,r=e.width,i=e.height,s=typeof DOMRectReadOnly<"u"?DOMRectReadOnly:Object,o=Object.create(s.prototype);return z4(o,{x:t,y:n,width:r,height:i,top:n,right:t+r,bottom:i+n,left:t}),o}function Lb(e,t,n,r){return{x:e,y:t,width:n,height:r}}var sZ=(function(){function e(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=Lb(0,0,0,0),this.target=t}return e.prototype.isActive=function(){var t=rZ(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t},e})(),oZ=(function(){function e(t,n){var r=iZ(n);z4(this,{target:t,contentRect:r})}return e})(),aZ=(function(){function e(t,n,r){if(this.activeObservations_=[],this.observations_=new j4,typeof t!="function")throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=t,this.controller_=n,this.callbackCtx_=r}return e.prototype.observe=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof ef(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)||(n.set(t,new sZ(t)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof ef(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var n=this.observations_;n.has(t)&&(n.delete(t),n.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var t=this;this.clearActive(),this.observations_.forEach(function(n){n.isActive()&&t.activeObservations_.push(n)})},e.prototype.broadcastActive=function(){if(this.hasActive()){var t=this.callbackCtx_,n=this.activeObservations_.map(function(r){return new oZ(r.target,r.broadcastRect())});this.callback_.call(t,n,t),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e})(),$4=typeof WeakMap<"u"?new WeakMap:new j4,I4=(function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var n=XY.getInstance(),r=new aZ(t,n,this);$4.set(this,r)}return e})();["observe","unobserve","disconnect"].forEach(function(e){I4.prototype[e]=function(){var t;return(t=$4.get(this))[e].apply(t,arguments)}});var lZ=(function(){return typeof yx.ResizeObserver<"u"?yx.ResizeObserver:I4})();const dN=(e,t,n={})=>{const r=bn(e),i=m.useRef(null),s=m.useCallback(()=>{i.current&&clearInterval(i.current)},[]);return m.useEffect(()=>{if(!(!cN(t)||t<0))return n.immediate&&r(),i.current=setInterval(r,t),s},[t,n.immediate]),s},o$="AHOOKS_SYNC_STORAGE_EVENT_NAME",cZ=e=>(n,r={})=>{let i;const{listenStorageChange:s=!1,getInitialValueInEffect:o=!1}=r,a=iu(r.serializer)?r.serializer:JSON.stringify,l=iu(r.deserializer)?r.deserializer:JSON.parse,c=iu(r.onError)?r.onError:console.error;try{i=e()}catch(y){c(y)}const u=()=>{try{const y=i==null?void 0:i.getItem(n);if(y)return l(y)}catch(y){c(y)}return h()};function h(){return iu(r.defaultValue)?r.defaultValue():r.defaultValue}const[f,p]=m.useState(()=>o?h():u());Db(()=>{o&&p(u())});const g=m.useRef(f);g.current=f,Pu(()=>{const y=u();Object.is(y,g.current)||(g.current=y,p(y))},[n]);const x=y=>{const w=g.current,S=iu(y)?y(w):y;if(!Object.is(S,w)){s||(g.current=S,p(S));try{let C;const _=i==null?void 0:i.getItem(n);xY(S)?(C=null,i==null||i.removeItem(n)):(C=a(S),i==null||i.setItem(n,C)),dispatchEvent(new CustomEvent(o$,{detail:{key:n,newValue:C,oldValue:_,storageArea:i}}))}catch(C){c(C)}}},v=y=>{if(y.key!==n||y.storageArea!==i)return;const w=u();Object.is(w,g.current)||(g.current=w,p(w))},b=y=>{v(y.detail)};return yr("storage",v,{enable:s}),yr(o$,b,{enable:s}),[f,bn(x)]},th=cZ(()=>k4?localStorage:void 0);function uZ(e,t){var n;const r=Lg(e),i=(n=t==null?void 0:t.wait)!==null&&n!==void 0?n:1e3,s=m.useMemo(()=>PY((...o)=>r.current(...o),i,t),[]);return Fg(()=>{s.cancel()}),{run:s,cancel:s.cancel,flush:s.flush}}function dZ(e,t){const[n,r]=m.useState(e),{run:i}=uZ(()=>{r(e)},t);return m.useEffect(()=>{i()},[e]),n}const hZ=(e,t)=>{const n=bn(e),r=m.useRef(null),i=m.useCallback(()=>{r.current&&clearTimeout(r.current)},[]);return m.useEffect(()=>{if(!(!cN(t)||t<0))return r.current=setTimeout(n,t),i},[t]),i};/**
|
|
3
3
|
* @license lucide-react v1.72.0 - ISC
|
|
4
4
|
*
|
|
@@ -909,7 +909,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
909
909
|
`)){const o=s.match(/^\s*(?:#{1,6}\s+(.+?)|\*\*(.+?)\*\*|__(.+?)__)\s*:?\s*$/),a=(i=(o==null?void 0:o[1])??(o==null?void 0:o[2])??(o==null?void 0:o[3]))==null?void 0:i.replace(/[*_`]/g,"").trim();a&&n.push(a)}if(n.length)return t?n.at(-1):n[0];const r=e.split(`
|
|
910
910
|
`).map(s=>s.trim()).find(Boolean);return r&&S7(r)||void 0}function U1e(e){const t=[];for(const n of e.flatMap(r=>r.events))if(n.type==="tool_call"||n.type==="tool_result"){const r=t.at(-1);(r==null?void 0:r.kind)==="tools"?r.events.push(n):t.push({kind:"tools",id:`tools-${n.id}`,events:[n]})}else n.type==="thinking"?t.push({kind:"thinking",id:n.id,event:n}):n.type==="text"&&n.data.role!=="user"&&t.push({kind:"text",id:n.id,event:n});return t}function C7(e,t=[]){if(!e.length)return[];const n=[];for(const r of e)(r.type==="text"&&r.data.role==="user"||!n.length)&&n.push([]),n.at(-1).push(r);return n.flatMap((r,i)=>{const s=r.find(N=>N.type==="text"&&N.data.role==="user"),o=t.find(N=>N.id===(s==null?void 0:s.data.taskId)),a=o?sj.has(o.status):i<n.length-1,l=(o==null?void 0:o.createdAt)??(s==null?void 0:s.timestamp),c=`turn-${(s==null?void 0:s.data.taskId)??(s==null?void 0:s.id)??r[0].id}`,u={terminal:a,turnId:c,...a&&l?{sentAt:l}:{}},h=a?Qbe(r):void 0,f=!!h,p=[];let g=[],x=[];const v=()=>{var I,$;const N=g;N.length&&p.push({kind:"group",group:{id:`group-${N[0].id}`,...W1e(N),events:N,startedAt:N[0].timestamp,completedAt:typeof((I=N.at(-1))==null?void 0:I.data.completedAt)=="string"?N.at(-1).data.completedAt:($=N.at(-1))==null?void 0:$.timestamp}}),g=[]},b=()=>{x.length&&g.push(...x),x=[]};for(const N of r){if(N===h){b(),v(),p.push({kind:"event",event:N,final:!0});continue}if(V1e(N)){v(),g=[...x,N],x=[];continue}if(N.type==="thinking"){x.push(N);continue}if(ib(N)){b(),g.push(N);continue}b(),v(),p.push({kind:"event",event:N,final:!1})}b(),v();const y=p.flatMap(N=>N.kind==="group"?[N.group]:[]);if(!y.length)return p.filter(N=>N.kind==="event").map(N=>({...N,...u}));const w=p.findIndex(N=>N.kind==="group"),S=y.at(-1),C=a&&(o!=null&&o.updatedAt)?o.updatedAt:f?h==null?void 0:h.timestamp:S.completedAt,_=(o==null?void 0:o.status)??(a?"completed":"running"),k=_==="completed"&&!f?"incomplete":_,j={kind:"activity",id:`activity-${y[0].id}`,groups:y,hasAnswer:f,taskStatus:k,isLatestTurn:i===n.length-1,startedAt:(s==null?void 0:s.timestamp)??y[0].startedAt,...C?{completedAt:C}:{},...u},z=[];for(const[N,I]of p.entries())N===w&&z.push(j),I.kind==="event"&&z.push({...I,...u});return z})}const Ty="emoji",Ay="agentdock:silent-trigger-ledger",K1e=4,G1e=800,HP=typeof Intl<"u"&&"Segmenter"in Intl?new Intl.Segmenter("zh",{granularity:"grapheme"}):void 0;function Y1e(e){if(e==null)return"";if(typeof e!="string")return;const t=e.trim();return t?(HP?[...HP.segment(t)].map(i=>i.segment):Array.from(t)).length!==1?void 0:new RegExp("\\p{Extended_Pictographic}","u").test(t)||/^[\u{1F1E6}-\u{1F1FF}]{2}$/u.test(t)||/\u20E3/u.test(t)?t:void 0:""}function Z1e(e){return e?["main","tab","here"]:["here"]}function X1e(e){const t=typeof e.data.taskId=="string"?e.data.taskId:void 0;return t&&e.data.role==="user"?`task:${t}:user`:`event:${e.id}:${e.data.role==="user"?"user":"assistant"}`}function Dy(e){return`${e.sessionId}\0${X1e(e.event)}\0${e.emoji}`}function Ly(e){if(!e)return new Set;try{const t=JSON.parse(e);return Array.isArray(t)?new Set(t.filter(n=>typeof n=="string"&&n.length>0)):new Set}catch{return new Set}}function J1e(e,t,n=G1e){const r=Ly(e);if(r.has(t))return{value:e??JSON.stringify([...r]),added:!1};r.add(t);const i=[...r].slice(-Math.max(1,n));return{value:JSON.stringify(i),added:!0}}function Q1e(e,t){const n=Ly(e);return n.delete(t)?{value:JSON.stringify([...n]),removed:!0}:{value:e??JSON.stringify([...n]),removed:!1}}const um=new Set;let Zm,hk=new Set;function oj(){try{return typeof window>"u"?void 0:window.localStorage}catch{return}}function k7(e){const t=(e==null?void 0:e.getItem(Ay))??null;return t!==Zm&&(Zm=t,hk=Ly(t)),hk}function N7(e){Zm=e,hk=Ly(e)}function ewe(e){const t=Dy(e);if(um.has(t))return!1;const n=oj(),r=k7(n),i=J1e(Zm??null,t);if(!i.added)return um.add(t),r.add(t),!1;um.add(t),N7(i.value);try{n==null||n.setItem(Ay,i.value)}catch{}return!0}function twe(e){const t=Dy(e);return um.has(t)?!0:k7(oj()).has(t)}function nwe(e){const t=Dy(e);um.delete(t);const n=oj(),r=Q1e(Zm??rwe(n),t);if(r.removed){N7(r.value);try{n==null||n.setItem(Ay,r.value)}catch{}}}function rwe(e){return(e==null?void 0:e.getItem(Ay))??null}function iwe(e){return e.length>=19?`${e.slice(0,10)} ${e.slice(11,19)}`:e}function xp(e){return typeof e=="string"?e.replace(/\s+/g," ").trim():""}function Hd(e,t){return e.length<=t?e:`${e.slice(0,Math.max(1,t-1)).trimEnd()}…`}function VP(e,t,n){const r=t?"→ [目标消息] ":"",i=iwe(e.timestamp),s=e.data;if(e.type==="text"){const o=xp(s.text);if(!o)return;const a=s.role==="user"?"用户":"Agent";return`${r}[${a} · ${i}] ${Hd(o,n)}`}if(e.type==="thinking"){const o=xp(s.text);return o?`${r}[Agent 思考 · ${i}] ${Hd(o,Math.min(n,480))}`:void 0}if(e.type==="tool_call"||e.type==="tool_result"){const o=g7(s)??nj(s),a=typeof s.status=="string"?`(${s.status})`:"";return`${r}[工具 · ${i}] ${Hd(o,Math.min(n,480))}${a}`}if(e.type==="warning"){const o=xp(s.text);return o?`${r}[系统提示 · ${i}] ${Hd(o,Math.min(n,480))}`:void 0}if(e.type==="error"){const o=xp(s.message);return o?`${r}[错误 · ${i}] ${Hd(o,Math.min(n,480))}`:void 0}if(e.type==="permission_request"){const o=xp(s.title);return o?`${r}[授权请求 · ${i}] ${Hd(o,Math.min(n,480))}`:void 0}}function swe(e){return e.data.origin!==Ty&&e.data.origin!=="injected"&&e.data.origin!=="maintenance"&&e.data.origin!=="handoff"}function owe(e,t,n,r=K1e){const i=e.findIndex(l=>l===t||l.id===t.id&&l.timestamp===t.timestamp),s=Math.max(0,Math.floor(r)),o=i>=0?e.slice(Math.max(0,i-s),i+s+1):[t],a=[];for(const l of o){if(l!==t&&!swe(l))continue;const c=VP(l,l===t,l===t?2e3:800);c&&a.push(c)}if(!a.some(l=>l.startsWith("→ [目标消息]"))){const l=VP(t,!0,2e3);l&&a.push(l)}return[`用户给一条消息新增了「${n}」表情。这是静默触发:没有新的文字输入,请直接结合上下文继续处理目标消息指向的事。`,"不要复述这段说明,也不要等待用户重新描述。","","上下文(按时间顺序;→ 标记目标消息):",...a].join(`
|
|
911
911
|
`)}const co=()=>typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,awe={soft:"linear(0, 0.033, 0.114, 0.222, 0.34, 0.457, 0.567, 0.665, 0.749, 0.82, 0.876, 0.921, 0.955, 0.979, 0.997, 1.008, 1.015, 1.019, 1.02, 1.019, 1.018, 1.016, 1.013, 1.011, 1.009, 1.007, 1.005, 1.004, 1.003, 1.002, 1.001, 1, 1)",bouncy:"linear(0, 0.049, 0.171, 0.335, 0.512, 0.682, 0.832, 0.954, 1.044, 1.104, 1.137, 1.148, 1.141, 1.124, 1.1, 1.074, 1.049, 1.026, 1.008, 0.994, 0.985, 0.98, 0.978, 0.979, 0.981, 0.985, 0.989, 0.993, 0.996, 0.999, 1.001, 1.002, 1.003, 1.003, 1.003, 1.003, 1.002, 1.002, 1.001, 1.001, 1)"},lwe={soft:"cubic-bezier(.22, 1.2, .36, 1)",bouncy:"cubic-bezier(.34, 1.56, .64, 1)"};let WP;function cwe(e="soft"){return WP??(WP=typeof CSS<"u"&&typeof CSS.supports=="function"&&CSS.supports("animation-timing-function","linear(0, 1)")),WP?awe[e]:lwe[e]}const Xv=new Map;function gh(e){const t=m.useRef(null);return m.useCallback(n=>{if(n){t.current=n,Xv.set(e,n);return}t.current&&Xv.get(e)===t.current&&Xv.delete(e),t.current=null},[e])}function dm(e){const t=Xv.get(e);return t!=null&&t.isConnected?t:void 0}function hm(e){for(const t of e){const n=dm(t);if(!n)continue;const r=n.checkVisibility;if(typeof r=="function"&&!r.call(n,{checkVisibilityCSS:!0}))continue;const i=n.getBoundingClientRect();if(!(i.width===0||i.height===0)&&!(i.bottom<0||i.top>window.innerHeight||i.right<0||i.left>window.innerWidth))return i}}function uwe(e,t,n="running"){if(co())return Promise.resolve();const r=26,i=22,s=document.createElement("div");s.className=`ui-flying-note ui-note-paper-${n}`,s.setAttribute("aria-hidden","true"),document.body.appendChild(s);const o={x:e.left+e.width/2-r/2,y:e.top+e.height/2-i/2},a={x:t.left+t.width/2-r/2,y:t.top+t.height/2-i/2},l=a.x-o.x,c=a.y-o.y,u=Math.hypot(l,c),h={x:o.x+l/2-(Math.abs(l)<90?90:0),y:Math.min(o.y,a.y)-Math.min(170,60+u*.22)},f=y=>({x:(1-y)**2*o.x+2*(1-y)*y*h.x+y**2*a.x,y:(1-y)**2*o.y+2*(1-y)*y*h.y+y**2*a.y}),p=[0,.15,.35,.55,.75,.9,1],g=[-18,-6,6,12,6,2,0],x=[.4,1.12,1.05,.95,.8,.66,.52],v=p.map((y,w)=>{const S=f(y);return{transform:`translate(${S.x}px, ${S.y}px) rotate(${g[w]}deg) scale(${x[w]})`,opacity:w===0?0:w===p.length-1?.2:1,offset:y}});return s.animate(v,{duration:760+Math.min(360,u*.35),easing:"cubic-bezier(.4, 0, .25, 1)",fill:"forwards"}).finished.then(()=>s.remove(),()=>s.remove())}const dwe='<svg viewBox="0 0 24 24" width="100%" height="100%"><path d="M12 20.5C6.2 16.6 3 13.4 3 9.6 3 6.9 5.1 5 7.6 5c1.8 0 3.4 1 4.4 2.5C13 6 14.6 5 16.4 5 18.9 5 21 6.9 21 9.6c0 3.8-3.2 7-9 10.9Z" fill="currentColor"/></svg>',hwe='<svg viewBox="0 0 24 24" width="100%" height="100%"><path d="M12 20.5C6.2 16.6 3 13.4 3 9.6 3 6.9 5.1 5 7.6 5c1.8 0 3.4 1 4.4 2.5C13 6 14.6 5 16.4 5 18.9 5 21 6.9 21 9.6c0 3.8-3.2 7-9 10.9Z" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linejoin="round"/></svg>',fwe='<svg viewBox="0 0 24 24" width="100%" height="100%"><path d="M12 2.5c.6 4.6 2.9 6.9 7.5 7.5-4.6.6-6.9 2.9-7.5 7.5-.6-4.6-2.9-6.9-7.5-7.5 4.6-.6 6.9-2.9 7.5-7.5Z" fill="currentColor"/></svg>',qP=["running","review","needs","done"];function jc(e,t="hearts",n=8){if(co())return;const r=document.createElement("div");r.className="ui-burst-layer",r.setAttribute("aria-hidden","true"),document.body.appendChild(r);const i=e.left+e.width/2,s=e.top+e.height*.4,o=[];for(let a=0;a<n;a++){const l=document.createElement("span"),c=t==="confetti"?7+Math.random()*4:10+Math.random()*9;l.className=`ui-burst-particle ui-burst-${t}`,t==="confetti"?l.classList.add(`ui-note-paper-${qP[a%qP.length]}`):l.innerHTML=t==="sparkles"?fwe:a%3===2?hwe:dwe,l.style.width=`${c}px`,l.style.height=`${t==="confetti"?c*.7:c}px`,r.appendChild(l);const u=(-160+120/Math.max(1,n-1)*a+(Math.random()*16-8))*Math.PI/180,h=46+Math.random()*64,f=i+Math.cos(u)*h,p=s+Math.sin(u)*h-18,g=(Math.random()*2-1)*(t==="confetti"?360:40),x=l.animate([{transform:`translate(${i-c/2}px, ${s-c/2}px) scale(.3) rotate(0deg)`,opacity:0},{transform:`translate(${(i+f)/2-c/2}px, ${(s+p)/2-c/2-12}px) scale(1.1) rotate(${g/2}deg)`,opacity:1,offset:.35},{transform:`translate(${f-c/2}px, ${p-c/2+(t==="confetti"?30:0)}px) scale(.6) rotate(${g}deg)`,opacity:0}],{duration:900+Math.random()*500,delay:a*22,easing:"cubic-bezier(.2, .7, .3, 1)",fill:"forwards"});o.push(x)}Promise.allSettled(o.map(a=>a.finished)).then(()=>r.remove())}function Uw(e,t=1){!e||co()||e.animate([{transform:"scale(1)"},{transform:`scale(${1+.2*t})`,offset:.3},{transform:`scale(${1-.06*t})`,offset:.6},{transform:"scale(1)"}],{duration:460,easing:"cubic-bezier(.3, .7, .4, 1)"})}function pwe(e){!e||co()||e.animate([{transform:"translateX(0) rotate(0)"},{transform:"translateX(-12px) rotate(-3deg)",offset:.25},{transform:"translateX(-6px) rotate(2deg)",offset:.5},{transform:"translateX(-9px) rotate(-1deg)",offset:.7},{transform:"translateX(0) rotate(0)"}],{duration:900,easing:"cubic-bezier(.3, .7, .4, 1)",composite:"add"})}function mwe(e){const t=document;if(typeof t.startViewTransition!="function"||co()){e();return}t.startViewTransition(()=>{Ai.flushSync(e)})}const E7="agentdock-kitten",cv=e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&!["checkbox","radio","range","button","submit"].includes(e.type)||e instanceof HTMLElement&&e.isContentEditable,Fi=m.forwardRef(function({size:t=96,variant:n="full",mood:r="idle",stage:i,retired:s=!1,collar:o=!1,drawCollar:a=!1,track:l=!1,typingAware:c=!1,interactive:u=!0,celebrateKey:h,viewTransitionName:f,label:p,className:g="",style:x,onClick:v},b){const y=m.useRef(null),w=m.useRef({twitch:!1,hop:!1}),S=()=>{const R=y.current;R&&(R.classList.remove("ui-cat-ear-wiggle-a","ui-cat-ear-wiggle-b"),w.current.twitch=!w.current.twitch,R.classList.toggle("ui-cat-twitching-a",w.current.twitch),R.classList.toggle("ui-cat-twitching-b",!w.current.twitch))},C=()=>{const R=y.current;!R||co()||(w.current.hop=!w.current.hop,R.classList.toggle("ui-cat-hop-a",w.current.hop),R.classList.toggle("ui-cat-hop-b",!w.current.hop))};m.useImperativeHandle(b,()=>({get element(){return y.current},hop:C,twitch:S}),[]);const _=m.useRef(h);m.useEffect(()=>{if(h===void 0||h===_.current)return;_.current=h,C();const R=y.current;R&&window.setTimeout(()=>jc(R.getBoundingClientRect(),"hearts",9),180)},[h]),m.useEffect(()=>{const R=y.current;if(!R||co())return;let E=0,M=0,P=0,A=0,D=!1,F=!1;const O=(X,J)=>{cancelAnimationFrame(E),E=requestAnimationFrame(()=>{R.style.setProperty("--mx",X.toFixed(3)),R.style.setProperty("--my",J.toFixed(3))})},B=()=>O(0,0),V=X=>{if(D)return;const J=R.getBoundingClientRect(),ae=X.clientX-(J.left+J.width/2),ne=X.clientY-(J.top+J.height/2),re=Math.hypot(ae,ne)||1,ie=Math.min(1,re/220);O(ae/re*ie,ne/re*ie),window.clearTimeout(M),M=window.setTimeout(B,1500)},T=X=>{cv(X.target)&&(D=!0,R.classList.add("ui-cat-typing"),B())},W=X=>{cv(X.target)&&(D=!1,R.classList.remove("ui-cat-typing"),B())},L=X=>{cv(X.target)&&(R.classList.remove("ui-cat-twitching-a","ui-cat-twitching-b"),F=!F,R.classList.toggle("ui-cat-ear-wiggle-a",F),R.classList.toggle("ui-cat-ear-wiggle-b",!F))},q=()=>{P=window.setTimeout(()=>{R.classList.add("ui-cat-blinking"),A=window.setTimeout(()=>{R.classList.remove("ui-cat-blinking"),q()},120)},3500+Math.random()*3500)};return l&&(window.addEventListener("pointermove",V,{passive:!0}),document.documentElement.addEventListener("pointerleave",B)),c&&(document.addEventListener("focusin",T),document.addEventListener("focusout",W),document.addEventListener("input",L),cv(document.activeElement)&&(D=!0,R.classList.add("ui-cat-typing"))),q(),()=>{cancelAnimationFrame(E),window.clearTimeout(M),window.clearTimeout(P),window.clearTimeout(A),window.removeEventListener("pointermove",V),document.documentElement.removeEventListener("pointerleave",B),document.removeEventListener("focusin",T),document.removeEventListener("focusout",W),document.removeEventListener("input",L)}},[l,c]);const k=R=>{S(),n==="full"&&Math.random()<.34&&y.current&&jc(y.current.getBoundingClientRect(),"hearts",4),v==null||v(R)},j=n==="face",z=j?Math.max(2.2,Math.min(3.4,64/t*1.6)):1.75,N=d.jsxs("svg",{viewBox:j?"15 7 66 62":"0 0 96 96",width:t,height:t,"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeWidth:z,strokeLinecap:"round",strokeLinejoin:"round",overflow:"visible",children:[d.jsxs("g",{className:"ui-cat-body-group",children:[!j&&d.jsxs(d.Fragment,{children:[d.jsx("path",{className:"ui-cat-tail",d:"M59 79 C69 80 75 74 72.5 67 C71 63 67 63.5 67 67.5"}),d.jsx("path",{d:"M36 61 C33 68 33 77 39 82 C44 86 52 86 57 82 C63 77 63 68 60 61"}),d.jsx("path",{d:"M40 81.5 Q42.5 85.5 45 81.5"}),d.jsx("path",{d:"M51 81.5 Q53.5 85.5 56 81.5"})]}),d.jsxs("g",{className:"ui-cat-head",children:[d.jsx("path",{className:"ui-cat-ear ui-cat-ear-l",d:"M33 29 L28.5 13.5 Q28 11 30.5 11.8 L42 17.5"}),d.jsx("path",{className:"ui-cat-ear ui-cat-ear-r",d:"M63 29 L67.5 13.5 Q68 11 65.5 11.8 L54 17.5"}),d.jsx("path",{d:"M30 32 C30 24 37 21 48 21 C59 21 66 24 66 32 L66 44 C66 56 58 63 48 63 C38 63 30 56 30 44 Z"}),d.jsxs("g",{className:"ui-cat-eye",children:[d.jsx("circle",{cx:"39.5",cy:"40",r:"5.2"}),d.jsx("circle",{className:"ui-cat-pupil",cx:"39.5",cy:"40",r:"2",fill:"currentColor",stroke:"none"})]}),d.jsxs("g",{className:"ui-cat-eye",children:[d.jsx("circle",{cx:"56.5",cy:"40",r:"5.2"}),d.jsx("circle",{className:"ui-cat-pupil",cx:"56.5",cy:"40",r:"2",fill:"currentColor",stroke:"none"})]}),d.jsxs("g",{className:"ui-cat-happy",children:[d.jsx("path",{d:"M35.5 41 Q39.5 36.5 43.5 41"}),d.jsx("path",{d:"M52.5 41 Q56.5 36.5 60.5 41"})]}),d.jsxs("g",{className:"ui-cat-blush",stroke:"none",children:[d.jsx("ellipse",{cx:"35",cy:"48.5",rx:"3.6",ry:"2"}),d.jsx("ellipse",{cx:"61",cy:"48.5",rx:"3.6",ry:"2"})]}),d.jsx("path",{d:"M45.8 46.5 L50.2 46.5 L48 49 Z"}),d.jsx("path",{d:"M48 49 C46 52.5 43 52.5 42 50.5 M48 49 C50 52.5 53 52.5 54 50.5"}),d.jsx("g",{className:"ui-cat-whiskers ui-cat-whiskers-l",children:d.jsx("path",{d:"M29 44 L19.5 43 M29 48 L19.5 49.5"})}),d.jsx("g",{className:"ui-cat-whiskers ui-cat-whiskers-r",children:d.jsx("path",{d:"M67 44 L76.5 43 M67 48 L76.5 49.5"})}),d.jsxs("g",{className:"ui-cat-tuft",children:[d.jsx("path",{d:"M46.5 21 C45.8 17.8 47.6 16 49.8 16.6"}),d.jsx("path",{d:"M49.2 21 C49.4 18.9 50.9 18 52.4 18.5"})]}),d.jsxs("g",{className:"ui-cat-glasses",children:[d.jsx("circle",{cx:"39.5",cy:"40",r:"7.4"}),d.jsx("circle",{cx:"56.5",cy:"40",r:"7.4"}),d.jsx("path",{d:"M46.9 39.2 Q48 38 49.1 39.2"}),d.jsx("path",{d:"M32.1 38.6 L29.6 37.2 M63.9 38.6 L66.4 37.2"})]}),d.jsxs("g",{className:"ui-cat-brows",children:[d.jsx("path",{d:"M34.2 31.6 Q39.5 28.6 44.6 31.6"}),d.jsx("path",{d:"M51.4 31.6 Q56.5 28.6 61.8 31.6"})]}),d.jsxs("g",{className:"ui-cat-hat",children:[d.jsx("path",{d:"M36.5 22.4 C38 16.4 58 16.4 59.5 22.4 C52 21 44 21 36.5 22.4 Z"}),d.jsx("path",{d:"M48 17 L48.8 14.2"})]})]}),o&&d.jsxs("g",{className:`ui-cat-collar${a?" ui-cat-collar-draw":""}`,children:[d.jsx("path",{pathLength:1,d:"M36.6 61.6 Q48 68.2 59.4 61.6"}),d.jsx("circle",{className:"ui-cat-bell",pathLength:1,cx:"48",cy:"67.4",r:"2.3"})]})]}),d.jsxs("g",{className:"ui-cat-thought",stroke:"none",fill:"currentColor",children:[d.jsx("circle",{cx:"68",cy:"13",r:"1.6"}),d.jsx("circle",{cx:"73.5",cy:"9",r:"1.6"}),d.jsx("circle",{cx:"79",cy:"5",r:"1.6"})]}),d.jsxs("g",{className:"ui-cat-alert",children:[d.jsx("path",{d:"M75 4.5 L75 12"}),d.jsx("circle",{cx:"75",cy:"16",r:".4",fill:"currentColor"})]}),d.jsxs("g",{className:"ui-cat-zzz",strokeWidth:j?z*.7:1.4,children:[d.jsx("path",{className:"ui-cat-z1",d:"M68 15 h5 l-5 5 h5"}),d.jsx("path",{className:"ui-cat-z2",d:"M75 6 h4 l-4 4 h4"})]})]}),I=`ui-cat ui-kitten ${j?"ui-kitten-face":"ui-kitten-full"} ${g}`,$={width:t,height:t,...f?{viewTransitionName:f}:{},...x};return d.jsx("div",{ref:y,className:I,"data-mood":r,"data-stage":i,"data-retired":s||void 0,style:$,children:u?d.jsx("button",{type:"button",tabIndex:v?0:-1,"aria-label":p??"小猫",onClick:k,className:"ui-cat-stage",style:{width:t,height:t},children:N}):d.jsx("span",{className:"ui-cat-stage",role:p?"img":void 0,"aria-label":p,style:{width:t,height:t},children:N})})}),UP=["小A同学","年糕","芝麻","布丁","栗子","可乐","小满","豆包","麻薯","橘子","汤圆","奶盖"],j7=new Set(["starting","thinking","running_tool","interrupting"]);function aj(e){return e.state==="closed"?e.outcome==="cancelled"?"cancelled":"done":e.plan?"plan":e.state==="needs_user"?"needs":e.state==="review"?"review":"running"}const KP={running:"进行中",review:"待验收",needs:"需要你",plan:"计划待开工",done:"已验收",cancelled:"已取消",interrupted:"已打断"};function z7(e){return e.state==="closed"?"closed":e.plan?"planned":e.state==="needs_user"?"needs_user":e.state==="review"?"review":"running"}const gwe={needs_user:"需要你",planned:"等你点头",review:"待验收",running:"进行中",closed:"已完成"},vwe=["needs_user","planned","review","running","closed"];function xwe(e){const t={running:0,review:0,planned:0,needsUser:0,closed:0,open:0,attention:0};for(const n of e){const r=z7(n);if(r==="closed"){t.closed+=1;continue}t.open+=1,r==="running"?t.running+=1:r==="review"?t.review+=1:r==="planned"?t.planned+=1:t.needsUser+=1}return t.attention=t.review+t.needsUser,t}const GP=e=>e.state==="closed"?e.closedAt??e.updatedAt:e.updatedAt;function bwe(e,t="all"){const n=new Map;for(const s of e){const o=z7(s);n.set(o,[...n.get(o)??[],s])}const r=t==="all"?vwe:t==="needs_user"?["needs_user","planned"]:[t],i=t==="all"||t==="needs_user";return r.map(s=>({key:s,label:gwe[s],tasks:[...n.get(s)??[]].sort((o,a)=>GP(a).localeCompare(GP(o)))})).filter(s=>!i||s.tasks.length>0)}function YP(e){return new Map(e.map(t=>[t.id,{state:t.state,plan:t.plan,outcome:t.outcome,round:t.round}]))}function ywe(e,t){if(!e)return[];const n=[],r=[...t].sort((i,s)=>i.createdAt.localeCompare(s.createdAt));for(const i of r){const s=e.get(i.id);if(!s){i.state!=="closed"&&n.push({kind:i.plan?"planned":"dispatched",task:i});continue}if(s.state===i.state&&s.plan===i.plan){i.state==="running"&&i.round>s.round&&n.push({kind:"rework",task:i});continue}if(i.state==="closed"){n.push({kind:i.outcome==="cancelled"?"cancelled":"accepted",task:i});continue}if(i.state==="needs_user"){n.push({kind:"needs_user",task:i});continue}if(s.plan&&!i.plan&&i.state==="running"){n.push({kind:"started",task:i});continue}if(i.state==="review"&&s.state==="running"){n.push({kind:"review",task:i});continue}i.state==="running"&&(s.state==="review"||s.state==="needs_user")&&n.push({kind:"rework",task:i})}return n}function wwe(e){const t=e.task.title;switch(e.kind){case"dispatched":return{text:`派出一张便签:${t}`,tone:"info"};case"planned":return{text:`写了张计划便签「${t}」,你点头就开工`,tone:"info"};case"started":return{text:`便签「${t}」开工啦`,tone:"info"};case"review":return{text:`「${t}」做完了,我去验收`,tone:"info"};case"needs_user":return{text:`「${t}」需要你拍板`,tone:"alert"};case"accepted":return{text:`验收通过:${t}`,tone:"success"};case"cancelled":return{text:`撕掉了便签:${t}`,tone:"muted"};case"rework":return{text:`「${t}」打回去返工了`,tone:"info"}}}const Swe=6e3,_we=3*6e4;function Cwe(e){const{mainState:t,tasks:n,recent:r,lastActiveAt:i,now:s}=e;if(!t)return"curious";if(t==="waiting_for_permission"||n.some(o=>o.state==="needs_user"))return"alert";if(r&&s-r.at<Swe){if(r.kind==="accepted"||r.kind==="cheer")return"happy";if(r.kind==="dispatched"||r.kind==="started")return"busy"}return j7.has(t)?"busy":t==="failed"?"sad":n.some(o=>o.state==="running"||o.state==="review")?"idle":s-i>_we?"sleepy":"idle"}function kwe(e){const{mainState:t,counts:n,mood:r,recent:i}=e;return t?t==="starting"?"醒来中…":t==="waiting_for_permission"?"在等你授权":n.needsUser>0?`${n.needsUser} 件事等你拍板`:n.planned>0?`${n.planned} 张计划等你点头`:t==="thinking"?"正在思考…":t==="running_tool"?"正在忙活…":t==="interrupting"?"停下手头的事…":r==="happy"?i==="cheer"?"开心地摇尾巴":"验收通过啦":n.review>0?`${n.review} 张便签待验收`:n.running>0?`在盯着 ${n.running} 张便签`:t==="failed"?"出了点状况":r==="sleepy"?"打盹中":"随时待命":"等你来认领"}const ob=e=>!!(e&&j7.has(e));function M7(e=new Date){const t=e.getHours();return t<5?"夜深了":t<11?"早上好":t<13?"中午好":t<18?"下午好":"晚上好"}function $7(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function I7(e){return Math.round(($7(e)%1e3/1e3*3.2-1.6)*100)/100}function Nwe(e){return Math.round(($7(`${e}:tape`)%1e3/1e3*10-5)*100)/100}function Fy(e,t=Math.random){const n=UP.filter(r=>r!==e);return n[Math.floor(t()*n.length)%n.length]??UP[0]}function ra(e,t=Date.now()){if(!e)return"";const n=Date.parse(e);if(!Number.isFinite(n))return"";const r=Math.max(0,Math.floor((t-n)/6e4));if(r<1)return"刚刚";if(r<60)return`${r} 分钟前`;const i=Math.floor(r/60);return i<24?`${i} 小时前`:`${Math.floor(i/24)} 天前`}function Ewe(e){const t=[];for(const n of e.split(`
|
|
912
|
-
`)){const r=n.trim().match(/^- \[([\w-]+)\]\s*(.+)$/);if(!r)continue;let i=r[2].trim(),s;const o=i.match(/((atask_[^)]+))$/);o&&(s=o[1],i=i.slice(0,o.index).trim());const a=i.indexOf(":"),l=a>0?i.slice(0,a).trim():i,c=a>0?i.slice(a+1).trim():"";t.push({kind:r[1],title:l,detail:c,...s?{taskId:s}:{}})}return t}const jwe={review:"待验收",needs_you:"需要你",failed:"出错了",interrupted:"已打断"},R7={review:"review",needs_you:"needs",failed:"needs",interrupted:"interrupted"};function zwe(e,t){return e==="interrupted"?"interrupted":t??R7[e]??"plan"}const ZP="agentdock:companion-invite-dismissed",XP="agentdock:home-target";function JP(e){try{return window.localStorage.getItem(e)}catch{return null}}function QP(e,t){try{t===null?window.localStorage.removeItem(e):window.localStorage.setItem(e,t)}catch{}}let Mwe=0;const zt=X9(e=>({drawerOpen:!1,drawerNonce:0,filter:"all",queue:[],lastActiveAt:Date.now(),adoptPending:!1,celebrateNonce:0,inviteDismissed:JP(ZP)==="1",homeTarget:JP(XP)==="companion"?"companion":"new",openCeremony:t=>e(n=>{var r;return{ceremony:{...t?{handoffId:t}:{},nonce:(((r=n.ceremony)==null?void 0:r.nonce)??0)+1},drawerOpen:!1,bubble:void 0,queue:[]}}),closeCeremony:()=>e({ceremony:void 0}),openDrawer:t=>e(n=>{var r;return{drawerOpen:!0,drawerNonce:n.drawerOpen?n.drawerNonce:n.drawerNonce+1,filter:(t==null?void 0:t.filter)??(t!=null&&t.highlight?"all":n.filter),...t!=null&&t.highlight?{highlight:{taskId:t.highlight,nonce:(((r=n.highlight)==null?void 0:r.nonce)??0)+1}}:{},bubble:void 0,queue:[],lastActiveAt:Date.now()}}),closeDrawer:()=>e({drawerOpen:!1}),toggleDrawer:()=>e(t=>t.drawerOpen?{drawerOpen:!1}:{drawerOpen:!0,drawerNonce:t.drawerNonce+1,bubble:void 0,queue:[],lastActiveAt:Date.now()}),setFilter:t=>e({filter:t}),say:(t,n="info",r)=>e(i=>{if(i.drawerOpen)return{};const s={id:++Mwe,text:t,tone:n,...r?{action:r}:{}};return i.bubble?{queue:[...i.queue,s].slice(-3)}:{bubble:s}}),nextBubble:()=>e(t=>({bubble:t.queue[0],queue:t.queue.slice(1)})),markRecent:t=>e({recent:{kind:t,at:Date.now()},lastActiveAt:Date.now()}),touch:()=>e({lastActiveAt:Date.now()}),draftForMain:t=>e(n=>{var r;return{mainDraft:{text:t,nonce:(((r=n.mainDraft)==null?void 0:r.nonce)??0)+1}}}),consumeMainDraft:()=>e({mainDraft:void 0}),requestAdoption:()=>e({adoptPending:!0,drawerOpen:!1}),consumeAdoption:()=>e({adoptPending:!1}),celebrate:()=>e(t=>({celebrateNonce:t.celebrateNonce+1,recent:{kind:"cheer",at:Date.now()},lastActiveAt:Date.now()})),dismissInvite:(t=!0)=>{QP(ZP,t?"1":null),e({inviteDismissed:t})},setHomeTarget:t=>{QP(XP,t),e({homeTarget:t})}})),Up="小A同学",eT=[];function By(e=!0){return Et({queryKey:["assistant-lifecycle"],queryFn:we.assistantLifecycle,enabled:e,retry:!1,refetchInterval:t=>{var i;const n=t.state.data;if(t.state.error)return!1;const r=!!(n!=null&&n.handoff&&n.handoff.state!=="proposed");return((i=n==null?void 0:n.maintenance)==null?void 0:i.state)==="running"||r?1500:15e3}})}function Hy(e=!0){return Et({queryKey:["assistant-state"],queryFn:we.assistantState,enabled:e,retry:!1,refetchInterval:t=>{var i;const n=t.state.data;return t.state.error?3e4:n!=null&&n.mainSessionId?ob((i=n.mainSession)==null?void 0:i.state)||n.tasks.some(s=>s.state==="running")?2500:5e3:8e3}})}function $we(e,t){const[n,r]=m.useState(()=>Date.now());return m.useEffect(()=>{const i=Date.now(),s=[e===void 0?0:e+6e3,t+3*6e4].filter(a=>a>i);if(!s.length)return;const o=window.setTimeout(()=>r(Date.now()),Math.min(...s)-i+60);return()=>window.clearTimeout(o)},[e,t,n]),n}function Hi(){const e=Hy(),t=e.data,n=(t==null?void 0:t.mainSessionId)??void 0,r=m.useCallback(x=>x.find(v=>v.id===n),[n]),i=Et({queryKey:["sessions"],queryFn:we.sessions,refetchInterval:2e3,refetchIntervalInBackground:!0,enabled:!!n,select:r}).data,s=n?i??(t==null?void 0:t.mainSession)??void 0:void 0,o=(t==null?void 0:t.tasks)??eT,a=m.useMemo(()=>o.some(x=>x.archivedAt)?o.filter(x=>!x.archivedAt):o,[o]),l=m.useMemo(()=>o.some(x=>x.archivedAt)?o.filter(x=>x.archivedAt):eT,[o]),c=(t==null?void 0:t.lifecycle)??void 0,u=zt(x=>x.recent),h=zt(x=>x.lastActiveAt),f=$we(u==null?void 0:u.at,h),p=(t==null?void 0:t.companion)??void 0,g=t==null?void 0:t.drafts;return m.useMemo(()=>{var w;const x=xwe(a),v=s==null?void 0:s.state,b=Cwe({mainState:v,tasks:a,recent:u,lastActiveAt:h,now:f}),y=(p==null?void 0:p.name)??(((w=s==null?void 0:s.customTitle)==null?void 0:w.trim())||Up);return{loaded:e.isSuccess,adopted:!!n,mainId:n,mainSession:s,companion:p,name:y,tasks:a,counts:x,pendingDrafts:(g??[]).filter(S=>S.state==="pending").length,mood:b,status:c!=null&&c.maintenance&&!ob(v)?"在收拾便签和记忆":kwe({mainState:v,counts:x,mood:b,...u?{recent:u.kind}:{}}),busy:ob(v),archivedTasks:l,...c?{lifecycle:c}:{},...c!=null&&c.cat?{stage:c.cat.lifeStage,generation:c.cat.generation}:{}}},[e.isSuccess,n,s,p,a,l,c,g,u,h,f])}const bp=()=>{},Iwe={openMain:bp,openTask:bp,goAdopt:bp,openSettings:bp,openSession:bp},O7=m.createContext(Iwe),Rwe=O7.Provider,Na=()=>m.useContext(O7),ab=["kitten","adult","senior","elder"],pu={kitten:"幼猫",adult:"成年",senior:"资深",elder:"老年"},lj={kitten:"幼猫",adult:"成年猫",senior:"资深猫",elder:"老年猫"},P7={kitten:"刚接班,精神满满,什么都想试试",adult:"状态正好,派活验收都利索",senior:"经验老到,就是记忆有点沉了",elder:"有点累了,该考虑交接给下一代"},tT={kitten:0,adult:.15,senior:.45,elder:.8},Lu=e=>e?`第 ${e} 代`:"";function Owe(e){return!e||!Number.isFinite(e)?0:Math.round(Math.min(1,Math.max(0,e))*100)}function Pwe(e){return ab[ab.indexOf(e)+1]}const T7=["rounds","events","contextPercent","openNotes","closedNotes","archivedNotes","uptimeDays"],fk={rounds:"主会话轮次",events:"事件条数",contextPercent:"上下文用量",openNotes:"未关闭便签",closedNotes:"已完成便签",archivedNotes:"归档区便签",uptimeDays:"连续运行天数"};function pk(e,t){return t===void 0||!Number.isFinite(t)?"—":e==="contextPercent"?`${Math.round(t)}%`:e==="uptimeDays"?`${Math.round(t*10)/10} 天`:String(Math.round(t))}function A7(e){return`${fk[e.metric]} ${pk(e.metric,e.value)}/${pk(e.metric,e.threshold)}`}const nT={ok:"正常",tidy:"该整理",handoff:"该交接"};function Twe(e){switch(e){case void 0:case"proposed":return"invite";case"confirmed":case"packing":return"farewell";case"spawning":return"newborn";case"transferring":case"switching":return"transfer";case"retiring":case"briefing":return"closing";case"done":return"done";case"rolling_back":case"rolled_back":return"rolled_back";case"cancelled":return"cancelled"}}const Awe={invite:"交接仪式",farewell:"老猫在收拾行李",newborn:"新猫来了",transfer:"便签交到新猫手里",closing:"老猫退休",done:"交接完成",rolled_back:"已回滚,旧主会话完好",cancelled:"这次先不交接"},Dwe=["packing","spawning","transferring","switching","retiring","briefing"],Lwe={packing:"打包交接包",spawning:"新猫出生",transferring:"便签交接",switching:"换主会话",retiring:"老猫退休",briefing:"交接说明"};function Fwe(e){return Dwe.map(t=>{var a;const n=((e==null?void 0:e.steps)??[]).filter(l=>l.step===t).reverse(),r=n.find(l=>l.ok),i=n.find(l=>!l.ok),s=r?"done":i?"failed":(e==null?void 0:e.state)===t?"active":"pending",o=(a=r??i)==null?void 0:a.detail;return{key:t,label:Lwe[t],status:s,...o?{detail:o}:{}}})}const Bwe=new Set(["confirmed","packing","spawning","transferring","switching","retiring","briefing","rolling_back"]),rT=e=>!!(e&&Bwe.has(e)),Kw=e=>e==="done"||e==="rolled_back"||e==="cancelled",D7={succeeded:"交接成功",partial:"部分失败",needs_confirmation:"需要你确认"},Hwe={succeeded:"ok",partial:"bad",needs_confirmation:"warn"},Vwe={user:"你发起的",threshold:"指标到了交接档",agent:"主会话提议"},Wwe={transferred:"已转交",needs_confirmation:"待你确认",failed:"失败",reverted:"已回滚"},qwe={task:"事项",watch:"watch",draft:"草稿"};function Uwe(e){const t=n=>e.filter(r=>r.status===n).length;return{total:e.length,transferred:t("transferred"),needsConfirmation:t("needs_confirmation"),failed:t("failed"),reverted:t("reverted")}}const Kwe={handoff:"交接时折叠",maintenance:"整理轮次折叠",manual:"手动收起"};function cj(e,t){return e==="elder"?`${t}有点累了,要不要交接给下一代?`:e==="senior"?`${t}的记忆有点沉了,要不要交接?`:`${t}觉得该交接一下了,看看?`}const Gwe=e=>e==="maintenance"||e==="handoff";function Ywe(e,t){const n=(t??"").trim(),r=n.indexOf("·"),i=r>=0?n.slice(r+1).trim():n.replace(/^[🧹🐾]\s*/u,"");return{title:e==="maintenance"?"整理轮次":"交接说明",subtitle:i}}function Zwe(e,t,n=[]){return e?e===t||n.includes(e):!1}function Xwe(e,t){var i,s,o,a;if(!e||!t)return[];const n=[];((i=t.handoff)==null?void 0:i.state)==="proposed"&&((s=e.handoff)==null?void 0:s.id)!==t.handoff.id&&n.push({kind:"handoff_proposed",handoffId:t.handoff.id}),!e.maintenance&&t.maintenance&&n.push({kind:"maintenance_started",trigger:t.maintenance.trigger}),e.maintenance&&!t.maintenance&&n.push({kind:"maintenance_finished"});const r=t.lastHandoff;return r&&r.id!==((o=e.lastHandoff)==null?void 0:o.id)&&(((a=e.handoff)==null?void 0:a.id)===r.id||!e.lastHandoff||Date.parse(r.completedAt??r.createdAt)>Date.parse(e.lastHandoff.completedAt??e.lastHandoff.createdAt))&&(r.state==="done"?n.push({kind:"handoff_done",handoffId:r.id,outcome:r.outcome}):r.state==="rolled_back"&&n.push({kind:"handoff_rolled_back",handoffId:r.id})),e.cat&&t.cat&&e.cat.id===t.cat.id&&ab.indexOf(t.cat.lifeStage)>ab.indexOf(e.cat.lifeStage)&&n.push({kind:"aged",from:e.cat.lifeStage,to:t.cat.lifeStage}),n}function Jwe(e,t,n){switch(e.kind){case"handoff_proposed":return{text:cj(n,t),tone:"alert"};case"maintenance_started":return{text:e.trigger==="manual"?`${t}开始收拾便签和记忆~`:`${t}自己收拾一下便签和记忆,马上好`,tone:"muted"};case"maintenance_finished":return{text:`${t}收拾好了,摘要在主会话里`,tone:"success"};case"handoff_done":return{text:e.outcome==="succeeded"?`新猫${t}接班啦,喵!`:`新猫${t}接班了,有几件事等你看看`,tone:e.outcome==="partial"?"alert":"success"};case"handoff_rolled_back":return{text:"交接没成功,已经回滚,旧主会话完好",tone:"alert"};case"aged":return{text:`${t}长大了:现在是${lj[e.to]}`,tone:"info"}}}const Qwe=e=>e instanceof Error?e.message:"操作失败",eSe={active:"在岗",retired:"已退休",released:"已解除",aborted:"没接上班"},tSe={running:"进行中",completed:"已完成",failed:"失败",interrupted:"被打断"},iT={ok:"text-zinc-500",tidy:"text-amber-700",handoff:"text-orange-700"},sT=e=>Object.fromEntries(T7.flatMap(t=>{var n,r;return[[`${t}.tidy`,((n=e.thresholds[t])==null?void 0:n.tidy)===void 0?"":String(e.thresholds[t].tidy)],[`${t}.handoff`,((r=e.thresholds[t])==null?void 0:r.handoff)===void 0?"":String(e.thresholds[t].handoff)]]}));function nSe({onOpenSession:e,onOpenCeremony:t}){var M,P;const n=Ln(),r=By(),i=r.data,[s,o]=m.useState({}),[a,l]=m.useState(""),[c,u]=m.useState(),[h,f]=m.useState(),p=i?JSON.stringify(i.config):"";i&&p!==a&&(l(p),o(sT(i.config)));const g=()=>{n.invalidateQueries({queryKey:["assistant-lifecycle"]}),n.invalidateQueries({queryKey:["assistant-state"]}),n.invalidateQueries({queryKey:["assistant-notes-archive"]})},x=A=>{u(void 0),f(A),g()},v=A=>{f(void 0),u(Qwe(A))},b=yt({mutationFn:()=>we.assistantRunMaintenance({reason:"你在小猫档案里点了立即整理"}),onSuccess:()=>x("整理轮次开始了,进度在主会话时间线上"),onError:v}),y=yt({mutationFn:we.assistantSaveLifecycleConfig,onSuccess:()=>x("已保存"),onError:v}),w=yt({mutationFn:A=>we.assistantUnarchiveNotes({batchId:A}),onSuccess:A=>x(`已取出 ${A.restored.length} 张便签`),onError:v}),S=yt({mutationFn:()=>we.handoverSyncBot(),onSuccess:A=>A.ok?x(A.message):v(new Error(A.message)),onError:v}),C=m.useMemo(()=>{if(!i)return{};const A=sT(i.config),D={};for(const[F,O]of Object.entries(s))(A[F]??"")!==O.trim()&&(D[F]=O.trim()===""?null:Number(O));return D},[s,i]),_=Object.values(C).some(A=>A!==null&&(!Number.isFinite(A)||A<=0));if(r.isError)return d.jsx("div",{className:"border-t border-zinc-100 px-4 py-3 text-[12px] text-zinc-400",children:"这个版本的服务端还没有小猫档案。"});if(!i)return d.jsxs("div",{className:"flex items-center gap-1.5 border-t border-zinc-100 px-4 py-3 text-[12px] text-zinc-400",children:[d.jsx(_i,{size:13,className:"animate-spin"}),"正在读小猫档案…"]});const k=i.cat,j=i.config,z=k?Pwe(k.lifeStage):void 0,N=Owe(k==null?void 0:k.peakAgeScore),I=((M=i.maintenance)==null?void 0:M.state)==="running",$=((P=i.handoff)==null?void 0:P.state)==="proposed"?i.handoff:void 0,R=i.handoff&&i.handoff.state!=="proposed"?i.handoff:void 0,E=[...i.lineage].sort((A,D)=>A.generation-D.generation);return d.jsxs("section",{"aria-label":"小猫档案",className:"border-t border-zinc-100 px-4 py-3.5",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsxs("h3",{className:"flex items-center gap-1.5 text-[14px] text-zinc-900",children:[d.jsx(T3,{size:14}),"小猫档案"]}),k&&d.jsxs("span",{className:"ui-stage-chip","data-stage":k.lifeStage,children:[Lu(k.generation)," · ",pu[k.lifeStage]]}),d.jsx("span",{className:`text-[12px] ${iT[i.level]}`,children:i.level==="ok"?"指标都正常":`${nT[i.level]}:${i.reasons.filter(A=>A.level===i.level).map(A7).join("、")}`}),d.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[E.length>1&&d.jsxs("button",{type:"button",disabled:S.isPending,onClick:()=>S.mutate(),className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-zinc-200 px-2.5 text-[12px] text-zinc-700 hover:bg-zinc-50 disabled:opacity-40",children:[d.jsx(Hn,{size:13,className:S.isPending?"animate-spin":""}),S.isPending?"同步中…":"同步飞书机器人"]}),d.jsxs("button",{type:"button",disabled:!k||I||b.isPending||!!R,onClick:()=>b.mutate(),className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-zinc-200 px-2.5 text-[12px] text-zinc-700 hover:bg-zinc-50 disabled:opacity-40",children:[I||b.isPending?d.jsx(_i,{size:13,className:"animate-spin"}):d.jsx(U4,{size:13}),I?"正在整理…":"立即整理"]}),d.jsx("button",{type:"button",disabled:!k,onClick:()=>t(($==null?void 0:$.id)??(R==null?void 0:R.id)),className:"inline-flex h-8 items-center gap-1.5 rounded-lg bg-zinc-900 px-2.5 text-[12px] font-medium text-white hover:bg-zinc-700 disabled:opacity-40",children:R?"查看交接进度":$?"交接提议待确认":"交接仪式"})]})]}),k&&d.jsxs("div",{className:"mt-3",children:[d.jsxs("p",{className:"text-[12.5px] text-zinc-700",children:[Lu(k.generation),k.name,"现在是",d.jsx("b",{className:"font-semibold",children:lj[k.lifeStage]}),":",P7[k.lifeStage],"。"]}),d.jsxs("div",{className:"mt-2 ui-age-bar",role:"meter","aria-label":"小猫年纪","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":N,children:[d.jsx("span",{className:"ui-age-bar-fill",style:{width:`${N}%`}}),["adult","senior","elder"].map(A=>d.jsx("span",{className:"ui-age-bar-tick",style:{left:`${tT[A]*100}%`},title:`${pu[A]}从这里开始`},A))]}),d.jsxs("p",{className:"mt-1.5 text-[11.5px] leading-5 text-zinc-500",children:["年纪看轮次、事件量、上下文用量,时间只占两成;只长不缩,整理不会让它变年轻。",z?` 再长到 ${Math.round(tT[z]*100)}% 就是${pu[z]}。`:" 已经是最后一个阶段,交接后新猫从幼猫开始。",` 认领于 ${ra(k.adoptedAt)||"刚刚"},陪你聊了 ${k.rounds} 轮。`]})]}),d.jsx("div",{className:"mt-3 overflow-x-auto",children:d.jsxs("table",{className:"w-full min-w-[440px] text-left text-[12px]",children:[d.jsx("thead",{className:"text-[11px] text-zinc-400",children:d.jsxs("tr",{children:[d.jsx("th",{className:"py-1 font-normal",children:"指标"}),d.jsx("th",{className:"py-1 font-normal",children:"现在"}),d.jsx("th",{className:"py-1 font-normal",children:"整理档"}),d.jsx("th",{className:"py-1 font-normal",children:"交接档"}),d.jsx("th",{className:"py-1 font-normal",children:"状态"})]})}),d.jsx("tbody",{children:T7.map(A=>{var F,O;const D=((F=i.levels)==null?void 0:F[A])??"ok";return d.jsxs("tr",{className:"border-t border-zinc-100","data-level":D,children:[d.jsx("td",{className:"py-1.5 text-zinc-700",children:fk[A]}),d.jsx("td",{className:"py-1.5 tabular-nums text-zinc-900",children:pk(A,(O=i.metrics)==null?void 0:O[A])}),["tidy","handoff"].map(B=>d.jsx("td",{className:"py-1",children:d.jsx("input",{inputMode:"decimal",value:s[`${A}.${B}`]??"",placeholder:"关","aria-label":`${fk[A]}的${B==="tidy"?"整理":"交接"}阈值`,onChange:V=>{const T=V.target.value;f(void 0),o(W=>({...W,[`${A}.${B}`]:T}))},className:"ui-field h-7 w-16 rounded-md border border-zinc-200 bg-white px-1.5 text-[12px] tabular-nums text-zinc-800 outline-none placeholder:text-zinc-300"})},B)),d.jsx("td",{className:`py-1.5 ${iT[D]}`,children:nT[D]})]},A)})})]})}),d.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-2 text-[12px] text-zinc-600",children:[d.jsxs("label",{className:"flex items-center gap-1.5",children:[d.jsx("input",{type:"checkbox",checked:j.autoMaintenance,disabled:y.isPending,onChange:A=>y.mutate({autoMaintenance:A.target.checked}),className:"h-3.5 w-3.5 accent-zinc-900"}),"到整理档自动开整理轮次"]}),d.jsxs("label",{className:"flex items-center gap-1.5",children:[d.jsx("input",{type:"checkbox",checked:j.autoProposeHandoff,disabled:y.isPending,onChange:A=>y.mutate({autoProposeHandoff:A.target.checked}),className:"h-3.5 w-3.5 accent-zinc-900"}),"到交接档提议交接(仍要你确认)"]}),d.jsxs("span",{className:"text-zinc-400",children:["每天最多自动整理 ",j.maxAutoRunsPerDay," 次;已完成超过 ",j.foldClosedAfterHours," 小时的便签才会被折叠"]}),d.jsx("button",{type:"button",disabled:!Object.keys(C).length||_||y.isPending,onClick:()=>y.mutate({set:C}),className:"ml-auto h-7 rounded-md bg-zinc-900 px-2.5 text-[12px] font-medium text-white hover:bg-zinc-800 disabled:opacity-40",children:y.isPending?"保存中…":"保存阈值"})]}),_&&d.jsx("p",{className:"mt-1 text-[11px] text-red-600",children:"阈值要填正数,留空表示关掉这一档。"}),h&&d.jsx("p",{className:"mt-1 text-[11px] text-emerald-600",children:h}),c&&d.jsx("p",{className:"mt-1 rounded-md border border-red-200 bg-red-50 px-2 py-1.5 text-[12px] text-red-700",children:c}),E.length>0&&d.jsxs("div",{className:"mt-4",children:[d.jsx("h4",{className:"text-[12px] font-semibold text-zinc-500",children:"历代小猫"}),d.jsx("ol",{className:"mt-1 flex flex-col gap-1",children:E.map(A=>d.jsxs("li",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 rounded-md bg-zinc-50 px-2 py-1.5 text-[12px]","data-state":A.state,children:[d.jsxs("span",{className:"font-medium text-zinc-800",children:[Lu(A.generation)," · ",A.name]}),d.jsxs("span",{className:`rounded px-1 text-[10.5px] leading-[18px] ${A.state==="active"?"bg-emerald-100 text-emerald-700":"bg-zinc-200 text-zinc-600"}`,children:[eSe[A.state]," · ",pu[A.lifeStage]]}),d.jsxs("span",{className:"text-zinc-500",children:[A.rounds," 轮 · 认领于 ",ra(A.adoptedAt)||"刚刚",A.retiredAt?` · 退休于 ${ra(A.retiredAt)||"刚刚"}`:""]}),d.jsx("code",{className:"truncate font-mono text-[10.5px] text-zinc-400",title:A.sessionId,children:A.sessionId}),A.state!=="active"&&d.jsxs("button",{type:"button",onClick:()=>e(A.sessionId),className:"ml-auto inline-flex h-6 items-center gap-1 rounded px-1.5 text-[11.5px] text-zinc-600 hover:bg-zinc-200",children:[d.jsx(Bg,{size:12}),"查看会话(只读)"]})]},A.id))})]}),(i.maintenanceRuns.length>0||i.handoffs.length>0)&&d.jsxs("div",{className:"mt-4 grid gap-3 min-[560px]:grid-cols-2",children:[i.maintenanceRuns.length>0&&d.jsxs("div",{children:[d.jsx("h4",{className:"text-[12px] font-semibold text-zinc-500",children:"最近的整理轮次"}),d.jsx("ul",{className:"mt-1 flex flex-col gap-1",children:i.maintenanceRuns.slice(0,4).map(A=>d.jsxs("li",{className:"rounded-md bg-zinc-50 px-2 py-1.5 text-[12px]","data-state":A.state,children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsxs("span",{className:"text-zinc-800",children:[A.trigger==="auto"?"自动":"手动"," · ",tSe[A.state]]}),d.jsx("span",{className:"text-zinc-400",children:ra(A.createdAt)}),A.batch&&A.archiveBatchId&&(A.batch.undoneAt?d.jsxs("span",{className:"ml-auto text-[11px] text-zinc-400",children:["已取出 ",A.batch.count," 张"]}):d.jsxs("button",{type:"button",disabled:w.isPending,onClick:()=>w.mutate(A.archiveBatchId),className:"ml-auto inline-flex h-6 items-center gap-1 rounded px-1.5 text-[11.5px] text-zinc-600 hover:bg-zinc-200 disabled:opacity-40",children:[d.jsx(Cf,{size:11}),"撤销折叠 ",A.batch.count," 张"]}))]}),(A.summary||A.error)&&d.jsx("p",{className:"mt-0.5 line-clamp-2 text-[11.5px] leading-5 text-zinc-500",children:A.summary??A.error})]},A.id))})]}),i.handoffs.length>0&&d.jsxs("div",{children:[d.jsx("h4",{className:"text-[12px] font-semibold text-zinc-500",children:"交接记录"}),d.jsx("ul",{className:"mt-1 flex flex-col gap-1",children:i.handoffs.slice(0,4).map(A=>d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:()=>t(A.id),className:"flex w-full items-center gap-1.5 rounded-md bg-zinc-50 px-2 py-1.5 text-left text-[12px] hover:bg-zinc-100",children:[d.jsx(Sf,{size:12,className:"shrink-0 text-zinc-400"}),d.jsxs("span",{className:"truncate text-zinc-800",children:[A.successorName?`交给${A.successorName}`:"交接"," · ",A.outcome?D7[A.outcome]:A.state==="cancelled"?"已取消":A.state==="rolled_back"?"已回滚":A.state==="proposed"?"等你确认":"进行中"]}),d.jsx("span",{className:"ml-auto shrink-0 text-zinc-400",children:ra(A.completedAt??A.createdAt)})]})},A.id))})]})]})]})}const oT=e=>e instanceof Error?e.message:"操作失败";function rSe({onClose:e,onOpenMain:t,onAdopt:n,onOpenSession:r}){var B,V,T,W;const i=Ln(),s=m.useRef(null),o=m.useRef(null);Vo({panel:s,initial:o,dismissible:!0,onDismiss:e});const a=Hy(),l=Hi(),c=zt(L=>L.inviteDismissed),[u,h]=m.useState(null),[f,p]=m.useState(""),[g,x]=m.useState(""),[v,b]=m.useState(),[y,w]=m.useState(),[S,C]=m.useState(!1),[_,k]=m.useState(!1),[j,z]=m.useState(!1);m.useEffect(()=>{var L;(L=a.data)!=null&&L.quietHours&&!u&&h(a.data.quietHours)},[(B=a.data)==null?void 0:B.quietHours,u]),m.useEffect(()=>{var L;((L=a.data)==null?void 0:L.silentEmoji)!==void 0&&x(a.data.silentEmoji)},[(V=a.data)==null?void 0:V.silentEmoji]),m.useEffect(()=>{l.adopted&&p(l.name)},[l.adopted,l.name]);const N=()=>{w(void 0),i.invalidateQueries({queryKey:["assistant-state"]}),i.invalidateQueries({queryKey:["sessions"]})},I=L=>w(oT(L)),$=yt({mutationFn:L=>we.assistantRenameCompanion(L),onSuccess:()=>{N(),zt.getState().celebrate()},onError:I}),R=yt({mutationFn:()=>we.assistantClearMain(),onSuccess:()=>{z(!1),N()},onError:L=>{z(!1),I(L)}}),E=yt({mutationFn:L=>we.assistantSaveSettings({quietHours:L}),onSuccess:L=>{h(L.quietHours),C(!0),N()},onError:I}),M=yt({mutationFn:L=>we.assistantSaveSettings({silentEmoji:L}),onSuccess:L=>{x(L.silentEmoji),k(!0),b(void 0),N()},onError:L=>b(oT(L))}),P=l.mainSession,A=l.counts.needsUser+l.counts.planned+l.pendingDrafts,D=f.trim(),F=Y1e(g),O=F!==void 0&&F!==(((T=a.data)==null?void 0:T.silentEmoji)??"");return d.jsxs("div",{className:"ui-overlay fixed inset-0 z-[60] grid place-items-center bg-zinc-950/30 p-2 sm:p-4",onMouseDown:L=>{L.currentTarget===L.target&&e()},children:[d.jsxs("div",{ref:s,role:"dialog","aria-modal":"true","aria-label":"小猫与督办",className:"ui-dialog flex max-h-[86dvh] w-full max-w-2xl flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-[0_24px_80px_rgba(24,24,27,.2)]",children:[d.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-zinc-100 px-4",children:[d.jsxs("div",{className:"flex items-center gap-2 text-[16px] font-semibold text-zinc-900",children:[d.jsx(Ji,{size:16}),"小猫与督办"]}),A>0&&d.jsxs("span",{className:"rounded-full bg-amber-100 px-1.5 py-0.5 text-[11px] leading-none text-amber-700",children:[A," 项待你处理"]}),d.jsx("button",{ref:o,type:"button",onClick:e,"aria-label":"关闭",className:"ml-auto grid h-8 w-8 place-items-center rounded-lg text-zinc-400 hover:bg-zinc-100 hover:text-zinc-800",children:d.jsx(Wn,{size:16})})]}),d.jsx(fl,{placeholder:d.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-3",children:d.jsx(pl,{})}),children:d.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[l.adopted&&P?d.jsxs("div",{className:"flex items-center gap-4 border-b border-zinc-100 px-5 py-4",children:[d.jsx("span",{className:"grid h-16 w-16 shrink-0 place-items-center rounded-2xl bg-zinc-50 ring-1 ring-zinc-200",children:d.jsx(Fi,{variant:"face",size:50,mood:l.mood,stage:l.stage,collar:!0,label:l.name})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("form",{className:"flex items-center gap-1.5",onSubmit:L=>{L.preventDefault(),D&&D!==l.name&&$.mutate(D)},children:[d.jsx("input",{value:f,maxLength:16,onChange:L=>p(L.target.value),"aria-label":"小猫的名字",className:"ui-field h-8 w-36 rounded-lg border border-zinc-300 bg-white px-2.5 text-[14px] font-semibold text-zinc-900 outline-none"}),d.jsx("button",{type:"button",onClick:()=>p(L=>Fy(L.trim())),"aria-label":"随机换一个名字",title:"随机换一个名字",className:"ui-dice grid h-8 w-8 place-items-center rounded-lg text-zinc-500 hover:bg-zinc-100 hover:text-zinc-900",children:d.jsx(Fb,{size:15})}),D&&D!==l.name&&d.jsx("button",{type:"submit",disabled:$.isPending,className:"h-8 rounded-lg bg-zinc-900 px-3 text-[12px] font-medium text-white hover:bg-zinc-700 disabled:opacity-40",children:$.isPending?"改名中…":"改名"})]}),d.jsxs("p",{className:"mt-1.5 text-[12px] text-zinc-500",children:[l.status," · 认领于 ",ra(((W=l.companion)==null?void 0:W.adoptedAt)??P.createdAt)||"刚刚"," · ",l.counts.open," 张便签还没收尾"]}),d.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-zinc-400",title:P.id,children:P.id})]}),d.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[d.jsx("button",{type:"button",onClick:t,className:"h-8 rounded-lg bg-zinc-900 px-3 text-[12px] font-medium text-white hover:bg-zinc-700",children:"打开主会话"}),d.jsx("button",{type:"button",disabled:R.isPending,onClick:()=>z(!0),className:"h-7 rounded-lg px-2 text-[12px] text-zinc-500 hover:bg-zinc-100 hover:text-zinc-800 disabled:opacity-40",children:"让它休息"})]})]}):d.jsxs("div",{className:"flex items-center gap-4 border-b border-zinc-100 px-5 py-4",children:[d.jsx("span",{className:"grid h-16 w-16 shrink-0 place-items-center rounded-2xl border border-dashed border-zinc-300",children:d.jsx(Fi,{variant:"face",size:46,mood:"curious",label:"等待认领的小猫"})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"text-[14px] font-semibold text-zinc-900",children:"还没有认领小猫"}),d.jsx("p",{className:"mt-1 text-[12px] leading-5 text-zinc-500",children:"认领后它就是你的主会话:派侧边会话干活、盯进度、验收结果,派出去的事都贴成便签。"}),c&&d.jsx("button",{type:"button",onClick:()=>zt.getState().dismissInvite(!1),className:"mt-1 text-[12px] text-zinc-500 underline underline-offset-2 hover:text-zinc-800",children:"重新在首页和侧栏显示邀请"})]}),d.jsxs("button",{type:"button",onClick:n,className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-zinc-900 px-4 text-[13px] font-medium text-white hover:bg-zinc-700",children:[d.jsx(Ji,{size:14}),"去认领"]})]}),l.adopted&&P&&d.jsx(nSe,{onOpenSession:L=>r==null?void 0:r(L),onOpenCeremony:L=>{e(),zt.getState().openCeremony(L)}}),d.jsx(fi,{title:d.jsxs("span",{className:"flex items-center gap-1.5",children:[d.jsx(i3,{size:14}),"静默时段"]}),description:"开启后,普通通知会压到结束时间再发;紧急通知(notify --urgent)不受影响。默认关闭。",children:d.jsxs("div",{className:"flex flex-col items-end gap-2",children:[d.jsxs("label",{className:"flex items-center gap-2 text-[12px] text-zinc-600",children:[d.jsx("input",{type:"checkbox",checked:(u==null?void 0:u.enabled)??!1,onChange:L=>h(q=>q&&{...q,enabled:L.target.checked}),className:"h-3.5 w-3.5 accent-zinc-900"}),"启用"]}),d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("input",{type:"time",value:(u==null?void 0:u.start)??"23:00",disabled:!(u!=null&&u.enabled),onChange:L=>h(q=>q&&{...q,start:L.target.value}),"aria-label":"静默开始时间",className:"h-7 rounded-md border border-zinc-200 px-1.5 text-[12px] tabular-nums text-zinc-700 outline-none disabled:bg-zinc-50 disabled:text-zinc-400"}),d.jsx("span",{className:"text-[12px] text-zinc-400",children:"至"}),d.jsx("input",{type:"time",value:(u==null?void 0:u.end)??"08:00",disabled:!(u!=null&&u.enabled),onChange:L=>h(q=>q&&{...q,end:L.target.value}),"aria-label":"静默结束时间",className:"h-7 rounded-md border border-zinc-200 px-1.5 text-[12px] tabular-nums text-zinc-700 outline-none disabled:bg-zinc-50 disabled:text-zinc-400"}),d.jsx("button",{type:"button",disabled:!u||E.isPending||!l.adopted,onClick:()=>{C(!1),u&&E.mutate(u)},className:"h-7 rounded-md bg-zinc-900 px-2.5 text-[12px] font-medium text-white hover:bg-zinc-800 disabled:opacity-40",children:"保存"})]}),S&&d.jsx("span",{className:"text-[11px] text-emerald-600",children:"已保存"})]})}),d.jsx(fi,{title:d.jsxs("span",{className:"flex items-center gap-1.5",children:[d.jsx(Lo,{size:14}),"静默触发表情"]}),description:"在时间线的消息上点这个表情,就在背后开一轮 Agent。不会新增用户气泡,也不会弹通知;只接受一个 emoji,留空关闭。",children:d.jsxs("div",{className:"flex flex-col items-end gap-1.5",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("input",{value:g,maxLength:16,onChange:L=>{x(L.target.value),k(!1),b(void 0)},"aria-label":"静默触发表情",placeholder:"例如 🐱",className:"h-8 w-20 rounded-lg border border-zinc-300 bg-white px-2 text-center text-[16px] text-zinc-900 outline-none placeholder:text-[12px] placeholder:text-zinc-400"}),d.jsx("button",{type:"button","aria-label":"保存静默触发表情",disabled:M.isPending||!O,onClick:()=>{F!==void 0&&M.mutate(F)},className:"h-8 rounded-md bg-zinc-900 px-2.5 text-[12px] font-medium text-white hover:bg-zinc-800 disabled:opacity-40",children:M.isPending?"保存中…":"保存"})]}),g.trim()&&F===void 0&&d.jsx("span",{className:"text-[11px] text-red-600",children:"只支持单个 emoji"}),_&&F!==void 0&&!O&&d.jsx("span",{className:"text-[11px] text-emerald-600",children:"已保存"}),v&&d.jsx("span",{className:"max-w-56 text-right text-[11px] text-red-600",children:v})]})}),d.jsxs("div",{className:"px-4 py-3 text-[12px] leading-5 text-zinc-400",children:["小猫派活、验收和 watch 用 CLI 完成:",d.jsx("code",{className:"rounded bg-zinc-100 px-1 py-0.5 font-mono text-[11px] text-zinc-600",children:"agent-dock task|watch|notify -h"}),"。侧边会话只能 ",d.jsx("code",{className:"rounded bg-zinc-100 px-1 py-0.5 font-mono text-[11px] text-zinc-600",children:"task report"})," 和 ",d.jsx("code",{className:"rounded bg-zinc-100 px-1 py-0.5 font-mono text-[11px] text-zinc-600",children:"draft create"}),"。命令行认领:",d.jsx("code",{className:"rounded bg-zinc-100 px-1 py-0.5 font-mono text-[11px] text-zinc-600",children:"agent-dock main set --agent claude --name 小A同学"}),"。"]}),y&&d.jsx("div",{className:"mx-4 mb-3 rounded-md border border-red-200 bg-red-50 px-2.5 py-2 text-[12px] text-red-700",children:y})]})})]}),d.jsx(To,{open:j,tone:"warning",title:`让${l.name}休息?`,description:"解除后它不再是主会话:不会再收到督办信号,也不能派活和验收。会话本身和已有的便签都会保留,之后可以在首页重新认领一只。",confirmLabel:"让它休息",busy:R.isPending,onCancel:()=>{R.isPending||z(!1)},onConfirm:()=>R.mutate()})]})}function L7(e){const t=(e??"").split(":"),[n,r,i,...s]=t;if(!(!n||!(r!=null&&r.startsWith("oc_")))){if(t.length===2)return{appId:n,chatId:r,chatType:"p2p",scope:""};if(!(t.length<3))return{appId:n,chatId:r,chatType:i,scope:s.join(":")}}}function aT(e){return`https://applink.feishu.cn/client/chat/open?openChatId=${encodeURIComponent(e)}`}function iSe(e){const t=L7(e);if(!t)return;const n=t.scope.startsWith("thread:")?t.scope.slice(7).trim():void 0;return n?{url:`${aT(t.chatId)}&threadId=${encodeURIComponent(n)}`,exact:!1,threadId:n}:{url:aT(t.chatId),exact:!0}}function sSe(e,t,n){const r=i=>e.some(s=>s.openId===i);return n&&r(n)?[n]:t&&r(t)?[t]:e.length?[e[0].openId]:[]}function oSe(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function aSe(e,t,n){const r=t.trim().toLowerCase(),i=new Set(n);return e.filter(s=>i.has(s.openId)||!r||s.name.toLowerCase().includes(r)).sort((s,o)=>Number(i.has(o.openId))-Number(i.has(s.openId)))}function lSe({session:e,agent:t,onClose:n}){var J,ae,ne,re,ie,G,oe,ge;const r=Ln(),i=m.useRef(null);Vo({panel:i,initial:i,dismissible:!0,onDismiss:n});const s=Et({queryKey:["lark-config"],queryFn:we.larkConfig}),o=((J=s.data)==null?void 0:J.bots)??[],l=((ae=Et({queryKey:["session-handover",e.id],queryFn:()=>we.sessionHandover(e.id),staleTime:3e4}).data)==null?void 0:ae.kitten)??void 0,[c,u]=m.useState(""),[h,f]=m.useState(),p=l?`${l.name} · AgentDock`:`${aye(e.title)||(t==null?void 0:t.name)||e.agentId} · AgentDock`,g=h??p,[x,v]=m.useState(""),[b,y]=m.useState(""),[w,S]=m.useState(),[C,_]=th("agentdock:handover-self-openid",{defaultValue:""}),[k,j]=m.useState(null),[z,N]=m.useState([]),I=o.some(U=>U.appId===c)?c:((ne=o[0])==null?void 0:ne.appId)??"",$=o.find(U=>U.appId===I),R=(re=L7(e.sourceId))==null?void 0:re.chatId,E=Et({queryKey:["lark-app-owner",I],queryFn:()=>we.larkAppOwner(I),enabled:!!I,staleTime:5*6e4}),M=Et({queryKey:["lark-chat-members",I,R],queryFn:()=>we.larkChatMembers(I,R),enabled:!!(I&&R),staleTime:6e4}),P=m.useMemo(()=>{var ce,ve;const U=new Map;(ce=E.data)!=null&&ce.owner&&U.set(E.data.owner.openId,E.data.owner.name);for(const fe of($==null?void 0:$.allowedUsers)??[])U.has(fe.openId)||U.set(fe.openId,fe.name);for(const fe of((ve=M.data)==null?void 0:ve.users)??[])U.has(fe.openId)||U.set(fe.openId,fe.name);for(const fe of z)U.has(fe.openId)||U.set(fe.openId,fe.name);return[...U].map(([fe,Ce])=>({openId:fe,name:Ce}))},[$,M.data,z,E.data]),A=yt({mutationFn:U=>we.larkMemberSearch(I,U),onSuccess:U=>{U.users.length&&(N(ce=>{const ve=new Map(ce.map(fe=>[fe.openId,fe]));for(const fe of U.users)ve.set(fe.openId,fe);return[...ve.values()]}),j(ce=>ce??[U.users[0].openId]))}}),D=P.map(U=>U.openId).sort(),F=Et({queryKey:["lark-user-profiles",I,D.join(",")],queryFn:()=>we.larkUserProfiles(I,D),enabled:!!(I&&D.length),staleTime:5*6e4}),O=U=>{var ce,ve,fe,Ce;return((ve=(ce=F.data)==null?void 0:ce.users.find(Pe=>Pe.openId===U))==null?void 0:ve.avatarUrl)??(((Ce=(fe=E.data)==null?void 0:fe.owner)==null?void 0:Ce.openId)===U?E.data.owner.avatarUrl:void 0)},B=k??sSe(P,(G=(ie=E.data)==null?void 0:ie.owner)==null?void 0:G.openId,C),V=U=>j(oSe(B,U)),T=m.useMemo(()=>aSe(P,b,B),[P,b,B]),W=x.trim(),L=W===""||W.startsWith("ou_"),q=[...new Set([...B,...L&&W?[W]:[]])],X=yt({mutationFn:()=>we.handoverSession(e.id,{appId:I,name:g,memberOpenIds:q}),onSuccess:U=>{B[0]&&_(B[0]),S(U),r.invalidateQueries({queryKey:["sessions"]}),r.invalidateQueries({queryKey:["session-handover",e.id]})}});return d.jsx("div",{className:"ui-overlay fixed inset-0 z-[60] grid place-items-center bg-zinc-950/30 p-3",onMouseDown:U=>{U.currentTarget===U.target&&n()},children:d.jsxs("div",{ref:i,role:"dialog","aria-modal":"true","aria-label":"托管给机器人",className:"ui-dialog flex max-h-[calc(100dvh-1.5rem)] w-full max-w-lg flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-[0_24px_80px_rgba(24,24,27,.2)]",children:[d.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-2 border-b border-zinc-100 px-4",children:[d.jsx(ti,{size:16,className:"text-zinc-500"}),d.jsx("span",{className:"text-[16px] font-semibold",children:"托管给机器人"}),d.jsx("span",{className:"hidden truncate text-[12px] text-zinc-400 sm:inline",children:"建一个飞书群,用群聊继续这个会话"}),d.jsx("button",{type:"button",onClick:n,"aria-label":"关闭",className:"ml-auto grid h-8 w-8 place-items-center rounded-lg text-zinc-400 hover:bg-zinc-100 hover:text-zinc-800",children:d.jsx(Wn,{size:16})})]}),d.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:d.jsxs(fl,{placeholder:d.jsx(pl,{}),children:[l&&d.jsxs("div",{"data-testid":"handover-kitten",className:"mb-3 flex items-center gap-2.5 rounded-lg border border-amber-100 bg-amber-50/60 px-2.5 py-2",children:[d.jsx("img",{src:l.avatarUrl,alt:`${l.name}的头像`,className:"h-9 w-9 shrink-0 rounded-full object-cover"}),d.jsxs("div",{className:"min-w-0 text-[12px] leading-4",children:[d.jsxs("div",{className:"font-medium text-zinc-800",children:["当前小猫:",l.name," · 第 ",l.generation," 代"]}),d.jsx("div",{className:"text-zinc-500",children:"建群后会尝试把飞书机器人名称和头像同步成这只小猫;不支持时会提示你手动处理。"})]})]}),s.isLoading&&d.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-zinc-400",children:[d.jsx(Gn,{size:13}),"正在读取机器人配置…"]}),!s.isLoading&&!o.length&&d.jsx("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] leading-5 text-amber-800",children:"还没有配置任何飞书机器人。先到「飞书设置」添加一个,再回来托管。"}),o.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("label",{className:"block text-[12px] font-medium text-zinc-700",children:"用哪个机器人"}),d.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:o.map(U=>d.jsx("button",{type:"button",onClick:()=>{u(U.appId),j(null),y("")},className:`flex h-8 items-center gap-1.5 rounded-full border px-3 text-[12px] font-medium transition-colors ${U.appId===I?"border-zinc-900 bg-zinc-900 text-white":"border-zinc-200 bg-white text-zinc-600 hover:border-zinc-300"}`,children:U.name||U.appId},U.appId))}),d.jsx("label",{className:"mt-4 block text-[12px] font-medium text-zinc-700",children:"群名称"}),d.jsx(Qn,{size:"large",value:g,onChange:U=>f(U.target.value),className:"mt-1.5 text-[13px]"}),d.jsxs("div",{className:"mt-4 flex items-center gap-1.5 text-[12px] font-medium text-zinc-700",children:[d.jsx(Sx,{size:12}),"邀请成员",d.jsx("span",{className:"font-normal text-zinc-400",children:"(点成员胶囊勾选,可全部取消)"})]}),d.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[d.jsx(Qn,{className:"min-w-0 flex-1",value:b,onChange:U=>y(U.target.value),onPressEnter:U=>{b.trim()&&(U.preventDefault(),A.mutate(b.trim()))},placeholder:"输入姓名后回车搜索(机器人可见范围)",prefix:d.jsx(fa,{size:13,className:"text-zinc-400"}),suffix:M.isFetching||A.isPending?d.jsx(Gn,{size:12,className:"text-zinc-400"}):d.jsx("span",{})}),d.jsx("button",{type:"button",disabled:!I||!b.trim()||A.isPending,onClick:()=>A.mutate(b.trim()),className:"h-8 shrink-0 rounded-md border border-zinc-200 px-2.5 text-[12px] text-zinc-600 hover:bg-zinc-50 disabled:opacity-40",children:"搜索"})]}),(((oe=A.data)==null?void 0:oe.error)||A.error)&&d.jsx("p",{className:"mt-1.5 text-[12px] text-amber-700",children:((ge=A.data)==null?void 0:ge.error)??(A.error instanceof Error?A.error.message:"搜索失败")}),d.jsxs("div",{className:"mt-2.5 rounded-lg border border-zinc-100 bg-zinc-50/60 p-2.5",children:[d.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-[12px] text-zinc-400",children:[d.jsx(Sx,{size:11}),"已选 ",B.length," 人",B.length===0&&d.jsx("span",{className:"text-zinc-400",children:"· 仅机器人和自己可在群内,其他人可稍后邀请"})]}),d.jsx("div",{className:"max-h-40 overflow-y-auto",children:T.length>0?d.jsx("div",{className:"flex flex-wrap gap-1.5",children:T.map(U=>{const ce=B.includes(U.openId),ve=O(U.openId);return d.jsxs("button",{type:"button","aria-pressed":ce,onClick:()=>V(U.openId),className:`flex h-8 items-center gap-1.5 rounded-full border py-0.5 pl-0.5 pr-2.5 text-[12px] transition-colors ${ce?"border-blue-500 bg-blue-50 text-blue-700":"border-zinc-200 bg-white text-zinc-600 hover:border-zinc-300"}`,children:[ve?d.jsx("img",{src:ve,alt:"",className:"h-6 w-6 rounded-full object-cover"}):d.jsx("span",{className:"grid h-6 w-6 place-items-center rounded-full bg-zinc-100 text-[12px] text-zinc-500",children:(U.name||"?").slice(0,1)}),U.name,ce&&d.jsx("span",{"aria-hidden":"true",className:"ml-0.5 text-[10px] font-semibold",children:"✓"})]},U.openId)})}):d.jsx("p",{className:"text-[12px] text-zinc-400",children:M.isError&&R?"读取原群成员失败(机器人可能不在该群);用上面的搜索按姓名找人,或在下面填 open_id。":"没有匹配的成员:换个名字搜索,或在下面填 open_id。"})})]}),d.jsx(Qn,{value:x,status:L?void 0:"error",onChange:U=>v(U.target.value),placeholder:"补充一个 open_id(ou_ 开头,可选)",className:"mt-2 font-mono text-[12px]"}),!L&&d.jsx("p",{className:"mt-1 text-[12px] text-red-600",children:"open_id 必须以 ou_ 开头。"}),d.jsx("p",{className:"mt-3 text-[12px] leading-4 text-zinc-400",children:"建群后,这个群的消息会直接进入当前会话;现有 Agent、模型、历史都保持不变。群里需要 @ 机器人来唤醒。机器人白名单内的群成员都能以完全信任权限驱动这个会话,请只拉信任的人。"})]}),X.error&&d.jsx("p",{role:"alert",className:"mt-3 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[12px] leading-5 text-red-700",children:X.error instanceof Error?X.error.message:String(X.error)}),w&&d.jsxs("div",{className:"mt-3 rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2.5 text-[12px] leading-5 text-emerald-800",children:["已建群并绑定:",d.jsx("span",{className:"font-medium",children:w.name}),d.jsxs("a",{href:w.url,target:"_blank",rel:"noreferrer",className:"ml-2 inline-flex items-center gap-1 font-medium text-emerald-700 underline",children:[d.jsx(Ja,{size:11}),"打开群聊"]}),w.botProfile&&d.jsx("p",{className:`mt-1.5 border-t pt-1.5 ${w.botProfile.ok?"border-emerald-200 text-emerald-700":"border-amber-200 text-amber-800"}`,children:w.botProfile.message})]})]})}),d.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t border-zinc-100 px-4 py-3",children:[d.jsx("button",{type:"button",onClick:n,className:"rounded-lg border border-zinc-300 px-3.5 py-2 text-xs font-medium text-zinc-700 hover:bg-zinc-50",children:w?"完成":"取消"}),!w&&d.jsxs("button",{type:"button",disabled:!I||!g.trim()||!L||X.isPending,onClick:()=>X.mutate(),className:"flex items-center gap-1.5 rounded-lg bg-zinc-900 px-3.5 py-2 text-xs font-medium text-white hover:bg-zinc-700 disabled:cursor-not-allowed disabled:bg-zinc-200 disabled:text-zinc-400",children:[X.isPending&&d.jsx(Gn,{size:12}),"建群并托管"]})]})]})})}const cSe=/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/;function uSe(e){var r;const t=e.trim();return t?(((r=t.match(cSe))==null?void 0:r[0])??t).toLowerCase():void 0}function dSe(e,t){const n=t.trim().toLowerCase();if(!n||(e.title??"").toLowerCase().includes(n)||e.cwd.toLowerCase().includes(n))return!0;const r=uSe(t);return r?e.sessionId.toLowerCase().includes(r):!1}function hSe(e){if(!e)return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return e;const n=r=>String(r).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function fSe({session:e,selected:t,onSelect:n}){var r;return d.jsxs("button",{type:"button",onClick:n,"aria-pressed":t,className:`flex w-full items-center gap-3 border-b border-zinc-100 px-4 py-2.5 text-left transition-colors last:border-b-0 ${t?"bg-blue-50/70":"hover:bg-zinc-50"}`,children:[d.jsx("span",{className:`grid h-4 w-4 shrink-0 place-items-center rounded-full border ${t?"border-blue-500 bg-blue-500 text-white":"border-zinc-300 text-transparent"}`,children:d.jsx(gi,{size:11})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:"truncate text-[13px] text-zinc-800",title:e.title??e.sessionId,children:((r=e.title)==null?void 0:r.trim())||"(无标题)"}),d.jsxs("div",{className:"mt-0.5 flex min-w-0 items-center gap-2 text-[12px] text-zinc-400",children:[d.jsx("span",{className:"truncate font-mono",title:e.cwd,children:e.cwd}),e.updatedAt&&d.jsx("span",{className:"shrink-0 tabular-nums",children:hSe(e.updatedAt)})]})]}),d.jsx("span",{className:"hidden shrink-0 font-mono text-[12px] text-zinc-300 sm:inline",title:e.sessionId,children:e.sessionId.slice(0,8)})]})}const pSe={full:"完整导入:把外部历史写进 AgentDock 时间线,并接管后续对话。",session:"仅接管会话:不回填历史,但 Agent 记得之前的上下文,下一条消息即可继续。"};function mSe({agents:e,onClose:t,onImported:n}){var j,z,N,I,$,R;const r=Ln(),i=m.useRef(null);Vo({panel:i,initial:i,dismissible:!0,onDismiss:t});const s=m.useMemo(()=>e.filter(E=>!E.disabled&&(E.protocol==="auto"||E.protocol==="acp")),[e]),[o,a]=m.useState((j=s[0])==null?void 0:j.id),[l,c]=m.useState(""),[u,h]=m.useState("full"),[f,p]=m.useState(),g=s,x=g.some(E=>E.id===o)?o:(z=g[0])==null?void 0:z.id,v=dY({queryKey:["external-sessions",x],enabled:!!x,initialPageParam:void 0,queryFn:({pageParam:E})=>we.externalSessions(x,E?{cursor:E}:{}),getNextPageParam:E=>E.nextCursor||void 0,retry:!1,refetchOnWindowFocus:!1,staleTime:3e4}),b=m.useMemo(()=>{var E;return((E=v.data)==null?void 0:E.pages.flatMap(M=>M.sessions))??[]},[v.data]),y=m.useMemo(()=>b.filter(E=>dSe(E,l)),[b,l]),w=v.error instanceof Error?v.error.message:void 0,S=yt({mutationFn:()=>we.importSession({agentId:x,externalSessionId:f.sessionId,cwd:f.cwd,mode:u}),onSuccess:E=>{r.invalidateQueries({queryKey:["sessions"]}),n(E),t()}}),C=S.error instanceof Error?S.error.message:void 0,_=yl();Pu(()=>{C&&_.show(`导入失败:${C}`)},[C]);const k=!!(x&&f)&&!S.isPending;return d.jsxs("div",{className:"ui-overlay fixed inset-0 z-[60] grid place-items-center bg-zinc-950/30 p-2 sm:p-4",children:[d.jsxs("div",{ref:i,role:"dialog","aria-modal":"true","aria-label":"导入外部会话",className:"ui-dialog flex h-[86dvh] w-full max-w-4xl flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-[0_24px_80px_rgba(24,24,27,.2)]",children:[d.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-zinc-100 px-4",children:[d.jsxs("div",{className:"flex items-center gap-2 text-[16px] font-semibold text-zinc-900",children:[d.jsx(ha,{size:16}),"导入外部会话"]}),d.jsx("span",{className:"hidden truncate text-[12px] text-zinc-400 sm:inline",children:"浏览各 Agent 自己记录的会话,选中后导入到 AgentDock"}),d.jsx("button",{type:"button",onClick:t,"aria-label":"关闭",className:"ml-auto grid h-8 w-8 place-items-center rounded-lg text-zinc-400 hover:bg-zinc-100 hover:text-zinc-800",children:d.jsx(Wn,{size:16})})]}),d.jsx(fl,{placeholder:d.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-3",children:d.jsx(pl,{})}),children:d.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 md:grid-cols-[200px_1fr]",children:[d.jsxs("div",{className:"hidden min-h-0 overflow-y-auto border-r border-zinc-100 bg-zinc-50/60 p-2 md:block",children:[g.map(E=>{const M=E.id===x;return d.jsxs("button",{type:"button",onClick:()=>{a(E.id),c(""),p(void 0)},className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-[12px] font-medium transition-colors ${M?"bg-white text-zinc-900 shadow-[0_1px_2px_rgba(24,24,27,.06)]":"text-zinc-600 hover:bg-white/70"}`,children:[d.jsx(Hr,{agentId:E.id,agentName:E.name,size:14}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:E.name})]},E.id)}),g.length===0&&d.jsx("div",{className:"px-2 py-2 text-[12px] text-zinc-400",children:"没有支持 ACP 的 Agent"})]}),d.jsxs("div",{className:"flex min-h-0 min-w-0 flex-col",children:[d.jsxs("div",{className:"flex shrink-0 gap-1.5 overflow-x-auto border-b border-zinc-100 bg-zinc-50/60 px-3 py-2 md:hidden",children:[g.map(E=>{const M=E.id===x;return d.jsxs("button",{type:"button",onClick:()=>{a(E.id),c(""),p(void 0)},className:`flex h-8 shrink-0 items-center gap-1.5 rounded-full border px-3 text-[12px] font-medium transition-colors ${M?"border-zinc-900 bg-zinc-900 text-white":"border-zinc-200 bg-white text-zinc-600"}`,children:[d.jsx(Hr,{agentId:E.id,agentName:E.name,size:13}),E.name]},E.id)}),g.length===0&&d.jsx("span",{className:"px-1 text-[12px] text-zinc-400",children:"没有支持 ACP 的 Agent"})]}),d.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-zinc-100 px-4 py-2.5",children:[d.jsxs("div",{className:"flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md border border-zinc-200 px-2.5 ui-field-within",children:[d.jsx(fa,{size:13,className:"shrink-0 text-zinc-400"}),d.jsx("input",{value:l,onChange:E=>c(E.target.value),placeholder:"按标题、工作目录或会话 ID 过滤(支持 codex://threads/…)",className:"min-w-0 flex-1 bg-transparent text-[12px] text-zinc-800 placeholder:text-zinc-400 outline-none"})]}),d.jsxs("button",{type:"button",disabled:!x||v.isFetching,onClick:()=>v.refetch(),className:"flex h-8 items-center gap-1 rounded-md border border-zinc-200 px-2.5 text-[12px] text-zinc-600 hover:bg-zinc-50 disabled:opacity-40",children:[d.jsx(Hn,{size:12,className:v.isFetching?"animate-spin":""}),"刷新"]})]}),d.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[v.isLoading&&d.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 text-[12px] text-zinc-400",children:[d.jsx(Gn,{size:13}),"正在读取会话列表…"]}),v.isError&&d.jsx("div",{className:"m-4 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[12px] leading-5 text-red-700",children:w??"读取失败"}),!v.isLoading&&!v.isError&&((I=(N=v.data)==null?void 0:N.pages[0])==null?void 0:I.supported)===!1&&d.jsx("div",{className:"m-4 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] leading-5 text-amber-800",children:"该 Agent 未实现会话列表能力(ACP session/list),暂时无法浏览它的历史会话。"}),!v.isLoading&&!v.isError&&((R=($=v.data)==null?void 0:$.pages[0])==null?void 0:R.supported)!==!1&&y.length===0&&d.jsx("div",{className:"px-4 py-3 text-[12px] text-zinc-400",children:l?"没有匹配的会话":"这个 Agent 没有历史会话"}),y.map(E=>d.jsx(fSe,{session:E,selected:(f==null?void 0:f.sessionId)===E.sessionId&&(f==null?void 0:f.cwd)===E.cwd,onSelect:()=>p(E)},`${E.cwd}:${E.sessionId}`)),v.hasNextPage&&!l&&d.jsx("div",{className:"p-3",children:d.jsxs("button",{type:"button",disabled:v.isFetchingNextPage,onClick:()=>v.fetchNextPage(),className:"flex h-8 w-full items-center justify-center gap-1.5 rounded-md border border-zinc-200 text-[12px] text-zinc-600 hover:bg-zinc-50 disabled:opacity-40",children:[v.isFetchingNextPage?d.jsx(Gn,{size:12}):null,"加载更多"]})})]}),d.jsxs("div",{className:"shrink-0 border-t border-zinc-100 px-4 py-2.5",children:[d.jsxs("div",{className:"flex flex-col gap-2 text-[12px] text-zinc-400 sm:flex-row sm:items-center sm:gap-3",children:[d.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["已列出 ",y.length," 条",v.hasNextPage?"(还有更多)":"",f?` · 已选 ${f.sessionId.slice(0,8)}`:""]}),d.jsx("div",{className:"flex w-full shrink-0 items-center gap-0.5 rounded-lg bg-zinc-100 p-0.5 sm:w-auto",children:["full","session"].map(E=>d.jsx("button",{type:"button",onClick:()=>h(E),className:`flex-1 rounded-md px-2.5 py-1 text-[12px] font-medium transition-colors sm:flex-none ${u===E?"bg-white text-zinc-900 shadow-[0_1px_2px_rgba(24,24,27,.08)]":"text-zinc-500 hover:text-zinc-800"}`,children:E==="full"?"完整导入":"仅接管会话"},E))}),d.jsxs("button",{type:"button",disabled:!k,onClick:()=>S.mutate(),className:"flex h-8 w-full shrink-0 items-center justify-center gap-1.5 rounded-lg bg-zinc-900 px-3 text-[12px] font-medium text-white hover:bg-zinc-700 disabled:cursor-not-allowed disabled:bg-zinc-200 disabled:text-zinc-400 sm:w-auto",children:[S.isPending?d.jsx(Gn,{size:12}):d.jsx(m3,{size:12}),"导入"]})]}),d.jsx("p",{className:"mt-1.5 text-[12px] leading-4 text-zinc-400",children:pSe[u]})]})]})]})})]}),_.toast]})}function gSe({session:e,onClose:t}){return d.jsx("div",{className:"ui-overlay fixed inset-0 z-30 grid place-items-center bg-zinc-950/30 p-4",onMouseDown:n=>{n.currentTarget===n.target&&t()},children:d.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"系统提示词",className:"ui-dialog flex max-h-[80dvh] w-full max-w-2xl flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-[0_24px_80px_rgba(24,24,27,.2)]",children:[d.jsxs("div",{className:"flex items-center border-b border-zinc-100 px-4 py-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("h2",{className:"text-[16px] font-semibold text-zinc-900",children:"系统提示词"}),d.jsx("p",{className:"mt-0.5 truncate text-[12px] text-zinc-500",children:"创建时提示词"})]}),d.jsx("span",{className:"ml-auto",children:d.jsx($o,{label:"关闭",onClick:t,children:d.jsx(Wn,{size:16})})})]}),d.jsx("div",{className:"space-y-5 overflow-y-auto px-4 py-4",children:d.jsxs("section",{children:[d.jsx("h3",{className:"mb-2 text-[12px] font-semibold text-zinc-500",children:"创建时提示词"}),d.jsx("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono text-[12px] leading-5 text-zinc-700",children:e.systemPrompt})]})})]})})}function vSe(){var e;return typeof window>"u"||(e=window.agentdockDesktop)==null?void 0:e.network}function xSe(){const e=vSe(),[t,n]=m.useState();m.useEffect(()=>{if(!e)return;let i=!0;return e.getState().then(s=>{i&&n(s)}).catch(()=>{}),()=>{i=!1}},[e]);const r=m.useCallback(async i=>{if(!e)return;const s=await e.setLanAccess(i);return n(s),s},[e]);return{api:e,state:t,setLanAccess:r}}function lT(e){try{const t=new URL(e);return t.searchParams.delete("t"),t.toString()}catch{return e}}function bSe(e){try{return new URL(e).host}catch{return e}}function cT(e){const t=["lan-v4","hostname","public","lan-v6"];for(const n of t){const r=e.find(i=>i.kind===n);if(r)return r}return e[0]}function ySe({onClose:e}){var C,_,k,j,z;const t=xSe(),n=Et({queryKey:["share-link"],queryFn:()=>we.shareLink(),retry:!1}),[r,i]=m.useState(),[s,o]=m.useState(!1),[a,l]=m.useState(!1),[c,u]=m.useState(!1),[h,f]=m.useState(),[p,g]=m.useState(!1),x=n.data,v=m.useMemo(()=>(x==null?void 0:x.urls.filter(N=>N.kind!=="public"))??[],[x]),b=m.useMemo(()=>v.find(N=>N.url===r)??(x?cT(v):void 0),[x,v,r]);m.useEffect(()=>{x&&i(N=>{var I;return N&&v.some($=>$.url===N)?N:(I=cT(v))==null?void 0:I.url})},[x,v]),m.useEffect(()=>{if(!s)return;const N=setTimeout(()=>o(!1),1500);return()=>clearTimeout(N)},[s]);const y=async()=>{if(b)try{await navigator.clipboard.writeText(b.url),o(!0)}catch{const N=document.createElement("textarea");N.value=b.url,N.style.position="fixed",N.style.opacity="0",document.body.appendChild(N),N.select(),document.execCommand("copy"),N.remove(),o(!0)}},w=async N=>{u(!0),f(void 0);try{await t.setLanAccess(N),l(!1),g(!0)}catch(I){f(I instanceof Error?I.message:String(I))}finally{u(!1)}},S=x&&!v.length?t.api&&!((C=t.state)!=null&&C.lanAccess)?"桌面客户端目前只监听本机(127.0.0.1),手机无法连接。开启局域网访问后即可扫码。":x.lanEnabled?"没有检测到可用的局域网地址,请确认电脑已连接 Wi-Fi 或网线。":"当前服务只监听本机(--local-only)。用 agent-dock --host 0.0.0.0 重启后,手机才能访问。":void 0;return d.jsx("div",{className:"ui-overlay fixed inset-0 z-50 grid place-items-center bg-zinc-950/35 p-4",onMouseDown:N=>{N.currentTarget===N.target&&!p&&e()},children:d.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"在手机上打开",className:"ui-dialog flex max-h-[88dvh] w-full max-w-[460px] flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-[0_24px_80px_rgba(24,24,27,.22)]",children:[d.jsxs("div",{className:"flex items-center border-b border-zinc-100 px-4 py-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("h2",{className:"text-[16px] font-semibold text-zinc-900",children:"在手机上打开"}),d.jsx("p",{className:"mt-0.5 truncate text-[12px] text-zinc-500",children:"扫码后可操作整个控制台"})]}),d.jsx("span",{className:"ml-auto",children:d.jsx($o,{label:"关闭",onClick:e,children:d.jsx(Wn,{size:16})})})]}),d.jsxs("div",{className:"space-y-4 overflow-y-auto px-4 py-4",children:[n.isLoading&&d.jsxs("div",{className:"flex items-center justify-center gap-2 py-12 text-[12px] text-zinc-500",children:[d.jsx(_i,{size:16,className:"animate-spin"}),"正在生成扫码链接…"]}),n.isError&&d.jsxs("div",{className:"rounded-xl border border-red-100 bg-red-50 px-3 py-3 text-[12px] leading-5 text-red-700",children:[n.error instanceof Error?n.error.message:"扫码链接生成失败",d.jsxs("button",{type:"button",onClick:()=>void n.refetch(),className:"ml-2 inline-flex items-center gap-1 font-medium underline underline-offset-2",children:[d.jsx(Hn,{size:11}),"重试"]})]}),x&&b&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"flex justify-center",children:d.jsx("div",{className:"w-full max-w-[248px] rounded-xl bg-white p-2.5 ring-1 ring-zinc-200",children:d.jsx(zy,{value:b.url,size:228,marginSize:2,className:"h-auto w-full",title:"扫码在手机上打开 AgentDock"})})}),d.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-zinc-200 bg-zinc-50/70 px-2.5 py-2",children:[d.jsx(rX,{size:14,className:"shrink-0 text-zinc-400"}),d.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-zinc-600",title:lT(b.url),children:[bSe(b.url),d.jsx("span",{className:"text-zinc-400",children:new URL(lT(b.url)).pathname})]}),d.jsxs("button",{type:"button",onClick:()=>void y(),className:"flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-[12px] font-medium text-zinc-700 transition-colors hover:bg-white hover:text-zinc-900",children:[s?d.jsx(gi,{size:12,className:"text-emerald-600"}):d.jsx(a3,{size:12}),s?"已复制":"复制"]})]}),v.length>1&&d.jsx("div",{className:"flex flex-wrap gap-1.5",children:v.map(N=>d.jsxs("button",{type:"button","aria-pressed":N.url===b.url,onClick:()=>i(N.url),className:`flex h-7 items-center gap-1.5 rounded-full border px-2.5 text-[12px] transition-colors ${N.url===b.url?"border-zinc-900 bg-zinc-900 text-white":"border-zinc-200 bg-white text-zinc-600 hover:border-zinc-300 hover:text-zinc-900"}`,children:[d.jsx(_x,{size:11}),N.label]},N.url))}),d.jsxs("p",{className:"text-[12px] leading-5 text-zinc-500",children:["链接拥有整个控制台权限,有效至 ",new Date(x.expiresAt).toLocaleDateString("zh-CN",{year:"numeric",month:"long",day:"numeric"}),"。请勿转发或公开展示。"]})]}),x&&!v.length&&d.jsx("div",{className:"rounded-xl border border-amber-100 bg-amber-50/70 px-3 py-3 text-[12px] leading-5 text-amber-800",children:S}),(t.api||x&&!x.lanEnabled)&&d.jsxs("section",{className:"border-t border-zinc-100 pt-3",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(_x,{size:14,className:"text-zinc-400"}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:"text-[13px] text-zinc-800",children:"局域网访问"}),d.jsx("div",{className:"mt-0.5 text-[12px] leading-5 text-zinc-500",children:t.api?(_=t.state)!=null&&_.lanAccess?"已开启,同一 Wi-Fi 下的手机可以连接。":"关闭中,手机无法通过局域网连接。":"服务端监听设置由启动参数决定。"})]}),t.api&&!p&&d.jsx("button",{type:"button",disabled:c,onClick:()=>l(!0),className:"h-7 shrink-0 rounded-md border border-zinc-200 px-2.5 text-[12px] font-medium text-zinc-700 transition-colors hover:border-zinc-300 hover:bg-zinc-50 disabled:opacity-50",children:c?"处理中…":(k=t.state)!=null&&k.lanAccess?"关闭…":"开启…"})]}),p&&d.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[12px] text-emerald-700",children:[d.jsx(_i,{size:12,className:"animate-spin"}),"本地服务正在重启,页面会自动刷新。"]}),h&&d.jsx("div",{className:"mt-2 rounded-lg border border-red-100 bg-red-50 px-2.5 py-2 text-[12px] text-red-700",children:h})]})]}),d.jsx(To,{open:a,tone:"warning",title:(j=t.state)!=null&&j.lanAccess?"关闭局域网访问?":"开启局域网访问?",description:"切换需要重启本地服务,正在运行的 Agent 任务会中断。二维码只在服务重启完成后生效。",confirmLabel:(z=t.state)!=null&&z.lanAccess?"关闭并重启":"开启并重启",busy:c,error:h,onCancel:()=>{c||l(!1)},onConfirm:()=>{var N;return void w(!((N=t.state)!=null&&N.lanAccess))}})]})})}function wSe(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const SSe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_Se=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,CSe={};function uT(e,t){return(CSe.jsx?_Se:SSe).test(e)}const kSe=/[ \t\n\f\r]/g;function NSe(e){return typeof e=="object"?e.type==="text"?dT(e.value):!1:dT(e)}function dT(e){return e.replace(kSe,"")===""}let r0=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};r0.prototype.normal={};r0.prototype.property={};r0.prototype.space=void 0;function F7(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new r0(n,r,t)}function mk(e){return e.toLowerCase()}class gs{constructor(t,n){this.attribute=n,this.property=t}}gs.prototype.attribute="";gs.prototype.booleanish=!1;gs.prototype.boolean=!1;gs.prototype.commaOrSpaceSeparated=!1;gs.prototype.commaSeparated=!1;gs.prototype.defined=!1;gs.prototype.mustUseProperty=!1;gs.prototype.number=!1;gs.prototype.overloadedBoolean=!1;gs.prototype.property="";gs.prototype.spaceSeparated=!1;gs.prototype.space=void 0;let ESe=0;const Zt=kd(),Er=kd(),gk=kd(),lt=kd(),Bn=kd(),Fu=kd(),Ns=kd();function kd(){return 2**++ESe}const vk=Object.freeze(Object.defineProperty({__proto__:null,boolean:Zt,booleanish:Er,commaOrSpaceSeparated:Ns,commaSeparated:Fu,number:lt,overloadedBoolean:gk,spaceSeparated:Bn},Symbol.toStringTag,{value:"Module"})),Gw=Object.keys(vk);class uj extends gs{constructor(t,n,r,i){let s=-1;if(super(t,n),hT(this,"space",i),typeof r=="number")for(;++s<Gw.length;){const o=Gw[s];hT(this,Gw[s],(r&vk[o])===vk[o])}}}uj.prototype.defined=!0;function hT(e,t,n){n&&(e[t]=n)}function Hf(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new uj(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[mk(r)]=r,n[mk(s.attribute)]=r}return new r0(t,n,e.space)}const B7=Hf({properties:{ariaActiveDescendant:null,ariaAtomic:Er,ariaAutoComplete:null,ariaBusy:Er,ariaChecked:Er,ariaColCount:lt,ariaColIndex:lt,ariaColSpan:lt,ariaControls:Bn,ariaCurrent:null,ariaDescribedBy:Bn,ariaDetails:null,ariaDisabled:Er,ariaDropEffect:Bn,ariaErrorMessage:null,ariaExpanded:Er,ariaFlowTo:Bn,ariaGrabbed:Er,ariaHasPopup:null,ariaHidden:Er,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Bn,ariaLevel:lt,ariaLive:null,ariaModal:Er,ariaMultiLine:Er,ariaMultiSelectable:Er,ariaOrientation:null,ariaOwns:Bn,ariaPlaceholder:null,ariaPosInSet:lt,ariaPressed:Er,ariaReadOnly:Er,ariaRelevant:null,ariaRequired:Er,ariaRoleDescription:Bn,ariaRowCount:lt,ariaRowIndex:lt,ariaRowSpan:lt,ariaSelected:Er,ariaSetSize:lt,ariaSort:null,ariaValueMax:lt,ariaValueMin:lt,ariaValueNow:lt,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function H7(e,t){return t in e?e[t]:t}function V7(e,t){return H7(e,t.toLowerCase())}const jSe=Hf({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Fu,acceptCharset:Bn,accessKey:Bn,action:null,allow:null,allowFullScreen:Zt,allowPaymentRequest:Zt,allowUserMedia:Zt,alpha:Zt,alt:null,as:null,async:Zt,autoCapitalize:null,autoComplete:Bn,autoFocus:Zt,autoPlay:Zt,blocking:Bn,capture:null,charSet:null,checked:Zt,cite:null,className:Bn,closedBy:null,colorSpace:null,cols:lt,colSpan:lt,command:null,commandFor:null,content:null,contentEditable:Er,controls:Zt,controlsList:Bn,coords:lt|Fu,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Zt,defer:Zt,dir:null,dirName:null,disabled:Zt,download:gk,draggable:Er,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Zt,formTarget:null,headers:Bn,height:lt,hidden:gk,high:lt,href:null,hrefLang:null,htmlFor:Bn,httpEquiv:Bn,id:null,imageSizes:null,imageSrcSet:null,inert:Zt,inputMode:null,integrity:null,is:null,isMap:Zt,itemId:null,itemProp:Bn,itemRef:Bn,itemScope:Zt,itemType:Bn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Zt,low:lt,manifest:null,max:null,maxLength:lt,media:null,method:null,min:null,minLength:lt,multiple:Zt,muted:Zt,name:null,nonce:null,noModule:Zt,noValidate:Zt,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:Zt,optimum:lt,pattern:null,ping:Bn,placeholder:null,playsInline:Zt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Zt,referrerPolicy:null,rel:Bn,required:Zt,reversed:Zt,rows:lt,rowSpan:lt,sandbox:Bn,scope:null,scoped:Zt,seamless:Zt,selected:Zt,shadowRootClonable:Zt,shadowRootCustomElementRegistry:Zt,shadowRootDelegatesFocus:Zt,shadowRootMode:null,shadowRootSerializable:Zt,shape:null,size:lt,sizes:null,slot:null,span:lt,spellCheck:Er,src:null,srcDoc:null,srcLang:null,srcSet:null,start:lt,step:null,style:null,tabIndex:lt,target:null,title:null,translate:null,type:null,typeMustMatch:Zt,useMap:null,value:Er,width:lt,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Bn,axis:null,background:null,bgColor:null,border:lt,borderColor:null,bottomMargin:lt,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Zt,declare:Zt,event:null,face:null,frame:null,frameBorder:null,hSpace:lt,leftMargin:lt,link:null,longDesc:null,lowSrc:null,marginHeight:lt,marginWidth:lt,noResize:Zt,noHref:Zt,noShade:Zt,noWrap:Zt,object:null,profile:null,prompt:null,rev:null,rightMargin:lt,rules:null,scheme:null,scrolling:Er,standby:null,summary:null,text:null,topMargin:lt,valueType:null,version:null,vAlign:null,vLink:null,vSpace:lt,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Zt,disablePictureInPicture:Zt,disableRemotePlayback:Zt,exportParts:Fu,part:Bn,prefix:null,property:null,results:lt,security:null,unselectable:null},space:"html",transform:V7}),zSe=Hf({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:Ns,accentHeight:lt,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:lt,amplitude:lt,arabicForm:null,ascent:lt,attributeName:null,attributeType:null,azimuth:lt,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:lt,by:null,calcMode:null,capHeight:lt,className:Bn,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:lt,diffuseConstant:lt,direction:null,display:null,dur:null,divisor:lt,dominantBaseline:null,download:Zt,dx:null,dy:null,edgeMode:null,editable:null,elevation:lt,enableBackground:null,end:null,event:null,exponent:lt,externalResourcesRequired:null,fill:null,fillOpacity:lt,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:Fu,g2:Fu,glyphName:Fu,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:lt,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:lt,horizOriginX:lt,horizOriginY:lt,id:null,ideographic:lt,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:lt,k:lt,k1:lt,k2:lt,k3:lt,k4:lt,kernelMatrix:Ns,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:lt,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:lt,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:lt,overlineThickness:lt,paintOrder:null,panose1:null,path:null,pathLength:lt,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Bn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:lt,pointsAtY:lt,pointsAtZ:lt,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ns,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ns,rev:Ns,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ns,requiredFeatures:Ns,requiredFonts:Ns,requiredFormats:Ns,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:lt,specularExponent:lt,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:lt,strikethroughThickness:lt,string:null,stroke:null,strokeDashArray:Ns,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:lt,strokeOpacity:lt,strokeWidth:null,style:null,surfaceScale:lt,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ns,tabIndex:lt,tableValues:null,target:null,targetX:lt,targetY:lt,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ns,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:lt,underlineThickness:lt,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:lt,values:null,vAlphabetic:lt,vMathematical:lt,vectorEffect:null,vHanging:lt,vIdeographic:lt,version:null,vertAdvY:lt,vertOriginX:lt,vertOriginY:lt,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:lt,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:H7}),W7=Hf({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),q7=Hf({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:V7}),U7=Hf({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),MSe={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"},$Se=/[A-Z]/g,fT=/-[a-z]/g,ISe=/^data[-\w.:]+$/i;function RSe(e,t){const n=mk(t);let r=t,i=gs;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&ISe.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(fT,PSe);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!fT.test(s)){let o=s.replace($Se,OSe);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=uj}return new i(r,t)}function OSe(e){return"-"+e.toLowerCase()}function PSe(e){return e.charAt(1).toUpperCase()}const TSe=F7([B7,jSe,W7,q7,U7],"html"),dj=F7([B7,zSe,W7,q7,U7],"svg");function ASe(e){return e.join(" ").trim()}var Vd={},Yw,pT;function DSe(){if(pT)return Yw;pT=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=`
|
|
912
|
+
`)){const r=n.trim().match(/^- \[([\w-]+)\]\s*(.+)$/);if(!r)continue;let i=r[2].trim(),s;const o=i.match(/((atask_[^)]+))$/);o&&(s=o[1],i=i.slice(0,o.index).trim());const a=i.indexOf(":"),l=a>0?i.slice(0,a).trim():i,c=a>0?i.slice(a+1).trim():"";t.push({kind:r[1],title:l,detail:c,...s?{taskId:s}:{}})}return t}const jwe={review:"待验收",needs_you:"需要你",failed:"出错了",interrupted:"已打断"},R7={review:"review",needs_you:"needs",failed:"needs",interrupted:"interrupted"};function zwe(e,t){return e==="interrupted"?"interrupted":t??R7[e]??"plan"}const ZP="agentdock:companion-invite-dismissed",XP="agentdock:home-target";function JP(e){try{return window.localStorage.getItem(e)}catch{return null}}function QP(e,t){try{t===null?window.localStorage.removeItem(e):window.localStorage.setItem(e,t)}catch{}}let Mwe=0;const zt=X9(e=>({drawerOpen:!1,drawerNonce:0,filter:"all",queue:[],lastActiveAt:Date.now(),adoptPending:!1,celebrateNonce:0,inviteDismissed:JP(ZP)==="1",homeTarget:JP(XP)==="companion"?"companion":"new",openCeremony:t=>e(n=>{var r;return{ceremony:{...t?{handoffId:t}:{},nonce:(((r=n.ceremony)==null?void 0:r.nonce)??0)+1},drawerOpen:!1,bubble:void 0,queue:[]}}),closeCeremony:()=>e({ceremony:void 0}),openDrawer:t=>e(n=>{var r;return{drawerOpen:!0,drawerNonce:n.drawerOpen?n.drawerNonce:n.drawerNonce+1,filter:(t==null?void 0:t.filter)??(t!=null&&t.highlight?"all":n.filter),...t!=null&&t.highlight?{highlight:{taskId:t.highlight,nonce:(((r=n.highlight)==null?void 0:r.nonce)??0)+1}}:{},bubble:void 0,queue:[],lastActiveAt:Date.now()}}),closeDrawer:()=>e({drawerOpen:!1}),toggleDrawer:()=>e(t=>t.drawerOpen?{drawerOpen:!1}:{drawerOpen:!0,drawerNonce:t.drawerNonce+1,bubble:void 0,queue:[],lastActiveAt:Date.now()}),setFilter:t=>e({filter:t}),say:(t,n="info",r)=>e(i=>{if(i.drawerOpen)return{};const s={id:++Mwe,text:t,tone:n,...r?{action:r}:{}};return i.bubble?{queue:[...i.queue,s].slice(-3)}:{bubble:s}}),nextBubble:()=>e(t=>({bubble:t.queue[0],queue:t.queue.slice(1)})),markRecent:t=>e({recent:{kind:t,at:Date.now()},lastActiveAt:Date.now()}),touch:()=>e({lastActiveAt:Date.now()}),draftForMain:t=>e(n=>{var r;return{mainDraft:{text:t,nonce:(((r=n.mainDraft)==null?void 0:r.nonce)??0)+1}}}),consumeMainDraft:()=>e({mainDraft:void 0}),requestAdoption:()=>e({adoptPending:!0,drawerOpen:!1}),consumeAdoption:()=>e({adoptPending:!1}),celebrate:()=>e(t=>({celebrateNonce:t.celebrateNonce+1,recent:{kind:"cheer",at:Date.now()},lastActiveAt:Date.now()})),dismissInvite:(t=!0)=>{QP(ZP,t?"1":null),e({inviteDismissed:t})},setHomeTarget:t=>{QP(XP,t),e({homeTarget:t})}})),Up="小A同学",eT=[];function By(e=!0){return Et({queryKey:["assistant-lifecycle"],queryFn:we.assistantLifecycle,enabled:e,retry:!1,refetchInterval:t=>{var i;const n=t.state.data;if(t.state.error)return!1;const r=!!(n!=null&&n.handoff&&n.handoff.state!=="proposed");return((i=n==null?void 0:n.maintenance)==null?void 0:i.state)==="running"||r?1500:15e3}})}function Hy(e=!0){return Et({queryKey:["assistant-state"],queryFn:we.assistantState,enabled:e,retry:!1,refetchInterval:t=>{var i;const n=t.state.data;return t.state.error?3e4:n!=null&&n.mainSessionId?ob((i=n.mainSession)==null?void 0:i.state)||n.tasks.some(s=>s.state==="running")?2500:5e3:8e3}})}function $we(e,t){const[n,r]=m.useState(()=>Date.now());return m.useEffect(()=>{const i=Date.now(),s=[e===void 0?0:e+6e3,t+3*6e4].filter(a=>a>i);if(!s.length)return;const o=window.setTimeout(()=>r(Date.now()),Math.min(...s)-i+60);return()=>window.clearTimeout(o)},[e,t,n]),n}function Hi(){const e=Hy(),t=e.data,n=(t==null?void 0:t.mainSessionId)??void 0,r=m.useCallback(x=>x.find(v=>v.id===n),[n]),i=Et({queryKey:["sessions"],queryFn:we.sessions,refetchInterval:2e3,refetchIntervalInBackground:!0,enabled:!!n,select:r}).data,s=n?i??(t==null?void 0:t.mainSession)??void 0:void 0,o=(t==null?void 0:t.tasks)??eT,a=m.useMemo(()=>o.some(x=>x.archivedAt)?o.filter(x=>!x.archivedAt):o,[o]),l=m.useMemo(()=>o.some(x=>x.archivedAt)?o.filter(x=>x.archivedAt):eT,[o]),c=(t==null?void 0:t.lifecycle)??void 0,u=zt(x=>x.recent),h=zt(x=>x.lastActiveAt),f=$we(u==null?void 0:u.at,h),p=(t==null?void 0:t.companion)??void 0,g=t==null?void 0:t.drafts;return m.useMemo(()=>{var w;const x=xwe(a),v=s==null?void 0:s.state,b=Cwe({mainState:v,tasks:a,recent:u,lastActiveAt:h,now:f}),y=(p==null?void 0:p.name)??(((w=s==null?void 0:s.customTitle)==null?void 0:w.trim())||Up);return{loaded:e.isSuccess,adopted:!!n,mainId:n,mainSession:s,companion:p,name:y,tasks:a,counts:x,pendingDrafts:(g??[]).filter(S=>S.state==="pending").length,mood:b,status:c!=null&&c.maintenance&&!ob(v)?"在收拾便签和记忆":kwe({mainState:v,counts:x,mood:b,...u?{recent:u.kind}:{}}),busy:ob(v),archivedTasks:l,...c?{lifecycle:c}:{},...c!=null&&c.cat?{stage:c.cat.lifeStage,generation:c.cat.generation}:{}}},[e.isSuccess,n,s,p,a,l,c,g,u,h,f])}const bp=()=>{},Iwe={openMain:bp,openTask:bp,goAdopt:bp,openSettings:bp,openSession:bp},O7=m.createContext(Iwe),Rwe=O7.Provider,Na=()=>m.useContext(O7),ab=["kitten","adult","senior","elder"],pu={kitten:"幼猫",adult:"成年",senior:"资深",elder:"老年"},lj={kitten:"幼猫",adult:"成年猫",senior:"资深猫",elder:"老年猫"},P7={kitten:"刚接班,精神满满,什么都想试试",adult:"状态正好,派活验收都利索",senior:"经验老到,就是记忆有点沉了",elder:"有点累了,该考虑交接给下一代"},tT={kitten:0,adult:.15,senior:.45,elder:.8},Lu=e=>e?`第 ${e} 代`:"";function Owe(e){return!e||!Number.isFinite(e)?0:Math.round(Math.min(1,Math.max(0,e))*100)}function Pwe(e){return ab[ab.indexOf(e)+1]}const T7=["rounds","compactions","events","contextPercent","openNotes","closedNotes","archivedNotes","uptimeDays"],fk={rounds:"主会话轮次",compactions:"上下文压缩",events:"事件段数",contextPercent:"上下文用量",openNotes:"未关闭便签",closedNotes:"已完成便签",archivedNotes:"归档区便签",uptimeDays:"连续运行天数"};function pk(e,t){return t===void 0||!Number.isFinite(t)?"—":e==="contextPercent"?`${Math.round(t)}%`:e==="uptimeDays"?`${Math.round(t*10)/10} 天`:e==="compactions"?`${Math.round(t)} 次`:String(Math.round(t))}function A7(e){return`${fk[e.metric]} ${pk(e.metric,e.value)}/${pk(e.metric,e.threshold)}`}const nT={ok:"正常",tidy:"该整理",handoff:"该交接"};function Twe(e){switch(e){case void 0:case"proposed":return"invite";case"confirmed":case"packing":return"farewell";case"spawning":return"newborn";case"transferring":case"switching":return"transfer";case"retiring":case"briefing":return"closing";case"done":return"done";case"rolling_back":case"rolled_back":return"rolled_back";case"cancelled":return"cancelled"}}const Awe={invite:"交接仪式",farewell:"老猫在收拾行李",newborn:"新猫来了",transfer:"便签交到新猫手里",closing:"老猫退休",done:"交接完成",rolled_back:"已回滚,旧主会话完好",cancelled:"这次先不交接"},Dwe=["packing","spawning","transferring","switching","retiring","briefing"],Lwe={packing:"打包交接包",spawning:"新猫出生",transferring:"便签交接",switching:"换主会话",retiring:"老猫退休",briefing:"交接说明"};function Fwe(e){return Dwe.map(t=>{var a;const n=((e==null?void 0:e.steps)??[]).filter(l=>l.step===t).reverse(),r=n.find(l=>l.ok),i=n.find(l=>!l.ok),s=r?"done":i?"failed":(e==null?void 0:e.state)===t?"active":"pending",o=(a=r??i)==null?void 0:a.detail;return{key:t,label:Lwe[t],status:s,...o?{detail:o}:{}}})}const Bwe=new Set(["confirmed","packing","spawning","transferring","switching","retiring","briefing","rolling_back"]),rT=e=>!!(e&&Bwe.has(e)),Kw=e=>e==="done"||e==="rolled_back"||e==="cancelled",D7={succeeded:"交接成功",partial:"部分失败",needs_confirmation:"需要你确认"},Hwe={succeeded:"ok",partial:"bad",needs_confirmation:"warn"},Vwe={user:"你发起的",threshold:"指标到了交接档",agent:"主会话提议"},Wwe={transferred:"已转交",needs_confirmation:"待你确认",failed:"失败",reverted:"已回滚"},qwe={task:"事项",watch:"watch",draft:"草稿"};function Uwe(e){const t=n=>e.filter(r=>r.status===n).length;return{total:e.length,transferred:t("transferred"),needsConfirmation:t("needs_confirmation"),failed:t("failed"),reverted:t("reverted")}}const Kwe={handoff:"交接时折叠",maintenance:"整理轮次折叠",manual:"手动收起"};function cj(e,t){return e==="elder"?`${t}有点累了,要不要交接给下一代?`:e==="senior"?`${t}的记忆有点沉了,要不要交接?`:`${t}觉得该交接一下了,看看?`}const Gwe=e=>e==="maintenance"||e==="handoff";function Ywe(e,t){const n=(t??"").trim(),r=n.indexOf("·"),i=r>=0?n.slice(r+1).trim():n.replace(/^[🧹🐾]\s*/u,"");return{title:e==="maintenance"?"整理轮次":"交接说明",subtitle:i}}function Zwe(e,t,n=[]){return e?e===t||n.includes(e):!1}function Xwe(e,t){var i,s,o,a;if(!e||!t)return[];const n=[];((i=t.handoff)==null?void 0:i.state)==="proposed"&&((s=e.handoff)==null?void 0:s.id)!==t.handoff.id&&n.push({kind:"handoff_proposed",handoffId:t.handoff.id}),!e.maintenance&&t.maintenance&&n.push({kind:"maintenance_started",trigger:t.maintenance.trigger}),e.maintenance&&!t.maintenance&&n.push({kind:"maintenance_finished"});const r=t.lastHandoff;return r&&r.id!==((o=e.lastHandoff)==null?void 0:o.id)&&(((a=e.handoff)==null?void 0:a.id)===r.id||!e.lastHandoff||Date.parse(r.completedAt??r.createdAt)>Date.parse(e.lastHandoff.completedAt??e.lastHandoff.createdAt))&&(r.state==="done"?n.push({kind:"handoff_done",handoffId:r.id,outcome:r.outcome}):r.state==="rolled_back"&&n.push({kind:"handoff_rolled_back",handoffId:r.id})),e.cat&&t.cat&&e.cat.id===t.cat.id&&ab.indexOf(t.cat.lifeStage)>ab.indexOf(e.cat.lifeStage)&&n.push({kind:"aged",from:e.cat.lifeStage,to:t.cat.lifeStage}),n}function Jwe(e,t,n){switch(e.kind){case"handoff_proposed":return{text:cj(n,t),tone:"alert"};case"maintenance_started":return{text:e.trigger==="manual"?`${t}开始收拾便签和记忆~`:`${t}自己收拾一下便签和记忆,马上好`,tone:"muted"};case"maintenance_finished":return{text:`${t}收拾好了,摘要在主会话里`,tone:"success"};case"handoff_done":return{text:e.outcome==="succeeded"?`新猫${t}接班啦,喵!`:`新猫${t}接班了,有几件事等你看看`,tone:e.outcome==="partial"?"alert":"success"};case"handoff_rolled_back":return{text:"交接没成功,已经回滚,旧主会话完好",tone:"alert"};case"aged":return{text:`${t}长大了:现在是${lj[e.to]}`,tone:"info"}}}const Qwe=e=>e instanceof Error?e.message:"操作失败",eSe={active:"在岗",retired:"已退休",released:"已解除",aborted:"没接上班"},tSe={running:"进行中",completed:"已完成",failed:"失败",interrupted:"被打断"},iT={ok:"text-zinc-500",tidy:"text-amber-700",handoff:"text-orange-700"},sT=e=>Object.fromEntries(T7.flatMap(t=>{var n,r;return[[`${t}.tidy`,((n=e.thresholds[t])==null?void 0:n.tidy)===void 0?"":String(e.thresholds[t].tidy)],[`${t}.handoff`,((r=e.thresholds[t])==null?void 0:r.handoff)===void 0?"":String(e.thresholds[t].handoff)]]}));function nSe({onOpenSession:e,onOpenCeremony:t}){var M,P;const n=Ln(),r=By(),i=r.data,[s,o]=m.useState({}),[a,l]=m.useState(""),[c,u]=m.useState(),[h,f]=m.useState(),p=i?JSON.stringify(i.config):"";i&&p!==a&&(l(p),o(sT(i.config)));const g=()=>{n.invalidateQueries({queryKey:["assistant-lifecycle"]}),n.invalidateQueries({queryKey:["assistant-state"]}),n.invalidateQueries({queryKey:["assistant-notes-archive"]})},x=A=>{u(void 0),f(A),g()},v=A=>{f(void 0),u(Qwe(A))},b=yt({mutationFn:()=>we.assistantRunMaintenance({reason:"你在小猫档案里点了立即整理"}),onSuccess:()=>x("整理轮次开始了,进度在主会话时间线上"),onError:v}),y=yt({mutationFn:we.assistantSaveLifecycleConfig,onSuccess:()=>x("已保存"),onError:v}),w=yt({mutationFn:A=>we.assistantUnarchiveNotes({batchId:A}),onSuccess:A=>x(`已取出 ${A.restored.length} 张便签`),onError:v}),S=yt({mutationFn:()=>we.handoverSyncBot(),onSuccess:A=>A.ok?x(A.message):v(new Error(A.message)),onError:v}),C=m.useMemo(()=>{if(!i)return{};const A=sT(i.config),D={};for(const[F,O]of Object.entries(s))(A[F]??"")!==O.trim()&&(D[F]=O.trim()===""?null:Number(O));return D},[s,i]),_=Object.values(C).some(A=>A!==null&&(!Number.isFinite(A)||A<=0));if(r.isError)return d.jsx("div",{className:"border-t border-zinc-100 px-4 py-3 text-[12px] text-zinc-400",children:"这个版本的服务端还没有小猫档案。"});if(!i)return d.jsxs("div",{className:"flex items-center gap-1.5 border-t border-zinc-100 px-4 py-3 text-[12px] text-zinc-400",children:[d.jsx(_i,{size:13,className:"animate-spin"}),"正在读小猫档案…"]});const k=i.cat,j=i.config,z=k?Pwe(k.lifeStage):void 0,N=Owe(k==null?void 0:k.peakAgeScore),I=((M=i.maintenance)==null?void 0:M.state)==="running",$=((P=i.handoff)==null?void 0:P.state)==="proposed"?i.handoff:void 0,R=i.handoff&&i.handoff.state!=="proposed"?i.handoff:void 0,E=[...i.lineage].sort((A,D)=>A.generation-D.generation);return d.jsxs("section",{"aria-label":"小猫档案",className:"border-t border-zinc-100 px-4 py-3.5",children:[d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsxs("h3",{className:"flex items-center gap-1.5 text-[14px] text-zinc-900",children:[d.jsx(T3,{size:14}),"小猫档案"]}),k&&d.jsxs("span",{className:"ui-stage-chip","data-stage":k.lifeStage,children:[Lu(k.generation)," · ",pu[k.lifeStage]]}),d.jsx("span",{className:`text-[12px] ${iT[i.level]}`,children:i.level==="ok"?"指标都正常":`${nT[i.level]}:${i.reasons.filter(A=>A.level===i.level).map(A7).join("、")}`}),d.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[E.length>1&&d.jsxs("button",{type:"button",disabled:S.isPending,onClick:()=>S.mutate(),className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-zinc-200 px-2.5 text-[12px] text-zinc-700 hover:bg-zinc-50 disabled:opacity-40",children:[d.jsx(Hn,{size:13,className:S.isPending?"animate-spin":""}),S.isPending?"同步中…":"同步飞书机器人"]}),d.jsxs("button",{type:"button",disabled:!k||I||b.isPending||!!R,onClick:()=>b.mutate(),className:"inline-flex h-8 items-center gap-1.5 rounded-lg border border-zinc-200 px-2.5 text-[12px] text-zinc-700 hover:bg-zinc-50 disabled:opacity-40",children:[I||b.isPending?d.jsx(_i,{size:13,className:"animate-spin"}):d.jsx(U4,{size:13}),I?"正在整理…":"立即整理"]}),d.jsx("button",{type:"button",disabled:!k,onClick:()=>t(($==null?void 0:$.id)??(R==null?void 0:R.id)),className:"inline-flex h-8 items-center gap-1.5 rounded-lg bg-zinc-900 px-2.5 text-[12px] font-medium text-white hover:bg-zinc-700 disabled:opacity-40",children:R?"查看交接进度":$?"交接提议待确认":"交接仪式"})]})]}),k&&d.jsxs("div",{className:"mt-3",children:[d.jsxs("p",{className:"text-[12.5px] text-zinc-700",children:[Lu(k.generation),k.name,"现在是",d.jsx("b",{className:"font-semibold",children:lj[k.lifeStage]}),":",P7[k.lifeStage],"。"]}),d.jsxs("div",{className:"mt-2 ui-age-bar",role:"meter","aria-label":"小猫年纪","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":N,children:[d.jsx("span",{className:"ui-age-bar-fill",style:{width:`${N}%`}}),["adult","senior","elder"].map(A=>d.jsx("span",{className:"ui-age-bar-tick",style:{left:`${tT[A]*100}%`},title:`${pu[A]}从这里开始`},A))]}),d.jsxs("p",{className:"mt-1.5 text-[11.5px] leading-5 text-zinc-500",children:["年纪看压缩次数、轮次和上下文用量,事件量只在极高时作上限保护;时间占两成,只长不缩。",z?` 再长到 ${Math.round(tT[z]*100)}% 就是${pu[z]}。`:" 已经是最后一个阶段,交接后新猫从幼猫开始。",` 认领于 ${ra(k.adoptedAt)||"刚刚"},陪你聊了 ${k.rounds} 轮。`]})]}),d.jsx("div",{className:"mt-3 overflow-x-auto",children:d.jsxs("table",{className:"w-full min-w-[440px] text-left text-[12px]",children:[d.jsx("thead",{className:"text-[11px] text-zinc-400",children:d.jsxs("tr",{children:[d.jsx("th",{className:"py-1 font-normal",children:"指标"}),d.jsx("th",{className:"py-1 font-normal",children:"现在"}),d.jsx("th",{className:"py-1 font-normal",children:"整理档"}),d.jsx("th",{className:"py-1 font-normal",children:"交接档"}),d.jsx("th",{className:"py-1 font-normal",children:"状态"})]})}),d.jsx("tbody",{children:T7.map(A=>{var F,O;const D=((F=i.levels)==null?void 0:F[A])??"ok";return d.jsxs("tr",{className:"border-t border-zinc-100","data-level":D,children:[d.jsx("td",{className:"py-1.5 text-zinc-700",children:fk[A]}),d.jsx("td",{className:"py-1.5 tabular-nums text-zinc-900",children:pk(A,(O=i.metrics)==null?void 0:O[A])}),["tidy","handoff"].map(B=>d.jsx("td",{className:"py-1",children:d.jsx("input",{inputMode:"decimal",value:s[`${A}.${B}`]??"",placeholder:"关","aria-label":`${fk[A]}的${B==="tidy"?"整理":"交接"}阈值`,onChange:V=>{const T=V.target.value;f(void 0),o(W=>({...W,[`${A}.${B}`]:T}))},className:"ui-field h-7 w-16 rounded-md border border-zinc-200 bg-white px-1.5 text-[12px] tabular-nums text-zinc-800 outline-none placeholder:text-zinc-300"})},B)),d.jsx("td",{className:`py-1.5 ${iT[D]}`,children:nT[D]})]},A)})})]})}),d.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-2 text-[12px] text-zinc-600",children:[d.jsxs("label",{className:"flex items-center gap-1.5",children:[d.jsx("input",{type:"checkbox",checked:j.autoMaintenance,disabled:y.isPending,onChange:A=>y.mutate({autoMaintenance:A.target.checked}),className:"h-3.5 w-3.5 accent-zinc-900"}),"到整理档自动开整理轮次"]}),d.jsxs("label",{className:"flex items-center gap-1.5",children:[d.jsx("input",{type:"checkbox",checked:j.autoProposeHandoff,disabled:y.isPending,onChange:A=>y.mutate({autoProposeHandoff:A.target.checked}),className:"h-3.5 w-3.5 accent-zinc-900"}),"到交接档提议交接(仍要你确认)"]}),d.jsxs("span",{className:"text-zinc-400",children:["每天最多自动整理 ",j.maxAutoRunsPerDay," 次;已完成超过 ",j.foldClosedAfterHours," 小时的便签才会被折叠"]}),d.jsx("button",{type:"button",disabled:!Object.keys(C).length||_||y.isPending,onClick:()=>y.mutate({set:C}),className:"ml-auto h-7 rounded-md bg-zinc-900 px-2.5 text-[12px] font-medium text-white hover:bg-zinc-800 disabled:opacity-40",children:y.isPending?"保存中…":"保存阈值"})]}),_&&d.jsx("p",{className:"mt-1 text-[11px] text-red-600",children:"阈值要填正数,留空表示关掉这一档。"}),h&&d.jsx("p",{className:"mt-1 text-[11px] text-emerald-600",children:h}),c&&d.jsx("p",{className:"mt-1 rounded-md border border-red-200 bg-red-50 px-2 py-1.5 text-[12px] text-red-700",children:c}),E.length>0&&d.jsxs("div",{className:"mt-4",children:[d.jsx("h4",{className:"text-[12px] font-semibold text-zinc-500",children:"历代小猫"}),d.jsx("ol",{className:"mt-1 flex flex-col gap-1",children:E.map(A=>d.jsxs("li",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 rounded-md bg-zinc-50 px-2 py-1.5 text-[12px]","data-state":A.state,children:[d.jsxs("span",{className:"font-medium text-zinc-800",children:[Lu(A.generation)," · ",A.name]}),d.jsxs("span",{className:`rounded px-1 text-[10.5px] leading-[18px] ${A.state==="active"?"bg-emerald-100 text-emerald-700":"bg-zinc-200 text-zinc-600"}`,children:[eSe[A.state]," · ",pu[A.lifeStage]]}),d.jsxs("span",{className:"text-zinc-500",children:[A.rounds," 轮 · 认领于 ",ra(A.adoptedAt)||"刚刚",A.retiredAt?` · 退休于 ${ra(A.retiredAt)||"刚刚"}`:""]}),d.jsx("code",{className:"truncate font-mono text-[10.5px] text-zinc-400",title:A.sessionId,children:A.sessionId}),A.state!=="active"&&d.jsxs("button",{type:"button",onClick:()=>e(A.sessionId),className:"ml-auto inline-flex h-6 items-center gap-1 rounded px-1.5 text-[11.5px] text-zinc-600 hover:bg-zinc-200",children:[d.jsx(Bg,{size:12}),"查看会话(只读)"]})]},A.id))})]}),(i.maintenanceRuns.length>0||i.handoffs.length>0)&&d.jsxs("div",{className:"mt-4 grid gap-3 min-[560px]:grid-cols-2",children:[i.maintenanceRuns.length>0&&d.jsxs("div",{children:[d.jsx("h4",{className:"text-[12px] font-semibold text-zinc-500",children:"最近的整理轮次"}),d.jsx("ul",{className:"mt-1 flex flex-col gap-1",children:i.maintenanceRuns.slice(0,4).map(A=>d.jsxs("li",{className:"rounded-md bg-zinc-50 px-2 py-1.5 text-[12px]","data-state":A.state,children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsxs("span",{className:"text-zinc-800",children:[A.trigger==="auto"?"自动":"手动"," · ",tSe[A.state]]}),d.jsx("span",{className:"text-zinc-400",children:ra(A.createdAt)}),A.batch&&A.archiveBatchId&&(A.batch.undoneAt?d.jsxs("span",{className:"ml-auto text-[11px] text-zinc-400",children:["已取出 ",A.batch.count," 张"]}):d.jsxs("button",{type:"button",disabled:w.isPending,onClick:()=>w.mutate(A.archiveBatchId),className:"ml-auto inline-flex h-6 items-center gap-1 rounded px-1.5 text-[11.5px] text-zinc-600 hover:bg-zinc-200 disabled:opacity-40",children:[d.jsx(Cf,{size:11}),"撤销折叠 ",A.batch.count," 张"]}))]}),(A.summary||A.error)&&d.jsx("p",{className:"mt-0.5 line-clamp-2 text-[11.5px] leading-5 text-zinc-500",children:A.summary??A.error})]},A.id))})]}),i.handoffs.length>0&&d.jsxs("div",{children:[d.jsx("h4",{className:"text-[12px] font-semibold text-zinc-500",children:"交接记录"}),d.jsx("ul",{className:"mt-1 flex flex-col gap-1",children:i.handoffs.slice(0,4).map(A=>d.jsx("li",{children:d.jsxs("button",{type:"button",onClick:()=>t(A.id),className:"flex w-full items-center gap-1.5 rounded-md bg-zinc-50 px-2 py-1.5 text-left text-[12px] hover:bg-zinc-100",children:[d.jsx(Sf,{size:12,className:"shrink-0 text-zinc-400"}),d.jsxs("span",{className:"truncate text-zinc-800",children:[A.successorName?`交给${A.successorName}`:"交接"," · ",A.outcome?D7[A.outcome]:A.state==="cancelled"?"已取消":A.state==="rolled_back"?"已回滚":A.state==="proposed"?"等你确认":"进行中"]}),d.jsx("span",{className:"ml-auto shrink-0 text-zinc-400",children:ra(A.completedAt??A.createdAt)})]})},A.id))})]})]})]})}const oT=e=>e instanceof Error?e.message:"操作失败";function rSe({onClose:e,onOpenMain:t,onAdopt:n,onOpenSession:r}){var B,V,T,W;const i=Ln(),s=m.useRef(null),o=m.useRef(null);Vo({panel:s,initial:o,dismissible:!0,onDismiss:e});const a=Hy(),l=Hi(),c=zt(L=>L.inviteDismissed),[u,h]=m.useState(null),[f,p]=m.useState(""),[g,x]=m.useState(""),[v,b]=m.useState(),[y,w]=m.useState(),[S,C]=m.useState(!1),[_,k]=m.useState(!1),[j,z]=m.useState(!1);m.useEffect(()=>{var L;(L=a.data)!=null&&L.quietHours&&!u&&h(a.data.quietHours)},[(B=a.data)==null?void 0:B.quietHours,u]),m.useEffect(()=>{var L;((L=a.data)==null?void 0:L.silentEmoji)!==void 0&&x(a.data.silentEmoji)},[(V=a.data)==null?void 0:V.silentEmoji]),m.useEffect(()=>{l.adopted&&p(l.name)},[l.adopted,l.name]);const N=()=>{w(void 0),i.invalidateQueries({queryKey:["assistant-state"]}),i.invalidateQueries({queryKey:["sessions"]})},I=L=>w(oT(L)),$=yt({mutationFn:L=>we.assistantRenameCompanion(L),onSuccess:()=>{N(),zt.getState().celebrate()},onError:I}),R=yt({mutationFn:()=>we.assistantClearMain(),onSuccess:()=>{z(!1),N()},onError:L=>{z(!1),I(L)}}),E=yt({mutationFn:L=>we.assistantSaveSettings({quietHours:L}),onSuccess:L=>{h(L.quietHours),C(!0),N()},onError:I}),M=yt({mutationFn:L=>we.assistantSaveSettings({silentEmoji:L}),onSuccess:L=>{x(L.silentEmoji),k(!0),b(void 0),N()},onError:L=>b(oT(L))}),P=l.mainSession,A=l.counts.needsUser+l.counts.planned+l.pendingDrafts,D=f.trim(),F=Y1e(g),O=F!==void 0&&F!==(((T=a.data)==null?void 0:T.silentEmoji)??"");return d.jsxs("div",{className:"ui-overlay fixed inset-0 z-[60] grid place-items-center bg-zinc-950/30 p-2 sm:p-4",onMouseDown:L=>{L.currentTarget===L.target&&e()},children:[d.jsxs("div",{ref:s,role:"dialog","aria-modal":"true","aria-label":"小猫与督办",className:"ui-dialog flex max-h-[86dvh] w-full max-w-2xl flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-[0_24px_80px_rgba(24,24,27,.2)]",children:[d.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-zinc-100 px-4",children:[d.jsxs("div",{className:"flex items-center gap-2 text-[16px] font-semibold text-zinc-900",children:[d.jsx(Ji,{size:16}),"小猫与督办"]}),A>0&&d.jsxs("span",{className:"rounded-full bg-amber-100 px-1.5 py-0.5 text-[11px] leading-none text-amber-700",children:[A," 项待你处理"]}),d.jsx("button",{ref:o,type:"button",onClick:e,"aria-label":"关闭",className:"ml-auto grid h-8 w-8 place-items-center rounded-lg text-zinc-400 hover:bg-zinc-100 hover:text-zinc-800",children:d.jsx(Wn,{size:16})})]}),d.jsx(fl,{placeholder:d.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-3",children:d.jsx(pl,{})}),children:d.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[l.adopted&&P?d.jsxs("div",{className:"flex items-center gap-4 border-b border-zinc-100 px-5 py-4",children:[d.jsx("span",{className:"grid h-16 w-16 shrink-0 place-items-center rounded-2xl bg-zinc-50 ring-1 ring-zinc-200",children:d.jsx(Fi,{variant:"face",size:50,mood:l.mood,stage:l.stage,collar:!0,label:l.name})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsxs("form",{className:"flex items-center gap-1.5",onSubmit:L=>{L.preventDefault(),D&&D!==l.name&&$.mutate(D)},children:[d.jsx("input",{value:f,maxLength:16,onChange:L=>p(L.target.value),"aria-label":"小猫的名字",className:"ui-field h-8 w-36 rounded-lg border border-zinc-300 bg-white px-2.5 text-[14px] font-semibold text-zinc-900 outline-none"}),d.jsx("button",{type:"button",onClick:()=>p(L=>Fy(L.trim())),"aria-label":"随机换一个名字",title:"随机换一个名字",className:"ui-dice grid h-8 w-8 place-items-center rounded-lg text-zinc-500 hover:bg-zinc-100 hover:text-zinc-900",children:d.jsx(Fb,{size:15})}),D&&D!==l.name&&d.jsx("button",{type:"submit",disabled:$.isPending,className:"h-8 rounded-lg bg-zinc-900 px-3 text-[12px] font-medium text-white hover:bg-zinc-700 disabled:opacity-40",children:$.isPending?"改名中…":"改名"})]}),d.jsxs("p",{className:"mt-1.5 text-[12px] text-zinc-500",children:[l.status," · 认领于 ",ra(((W=l.companion)==null?void 0:W.adoptedAt)??P.createdAt)||"刚刚"," · ",l.counts.open," 张便签还没收尾"]}),d.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-zinc-400",title:P.id,children:P.id})]}),d.jsxs("div",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[d.jsx("button",{type:"button",onClick:t,className:"h-8 rounded-lg bg-zinc-900 px-3 text-[12px] font-medium text-white hover:bg-zinc-700",children:"打开主会话"}),d.jsx("button",{type:"button",disabled:R.isPending,onClick:()=>z(!0),className:"h-7 rounded-lg px-2 text-[12px] text-zinc-500 hover:bg-zinc-100 hover:text-zinc-800 disabled:opacity-40",children:"让它休息"})]})]}):d.jsxs("div",{className:"flex items-center gap-4 border-b border-zinc-100 px-5 py-4",children:[d.jsx("span",{className:"grid h-16 w-16 shrink-0 place-items-center rounded-2xl border border-dashed border-zinc-300",children:d.jsx(Fi,{variant:"face",size:46,mood:"curious",label:"等待认领的小猫"})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("p",{className:"text-[14px] font-semibold text-zinc-900",children:"还没有认领小猫"}),d.jsx("p",{className:"mt-1 text-[12px] leading-5 text-zinc-500",children:"认领后它就是你的主会话:派侧边会话干活、盯进度、验收结果,派出去的事都贴成便签。"}),c&&d.jsx("button",{type:"button",onClick:()=>zt.getState().dismissInvite(!1),className:"mt-1 text-[12px] text-zinc-500 underline underline-offset-2 hover:text-zinc-800",children:"重新在首页和侧栏显示邀请"})]}),d.jsxs("button",{type:"button",onClick:n,className:"inline-flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-zinc-900 px-4 text-[13px] font-medium text-white hover:bg-zinc-700",children:[d.jsx(Ji,{size:14}),"去认领"]})]}),l.adopted&&P&&d.jsx(nSe,{onOpenSession:L=>r==null?void 0:r(L),onOpenCeremony:L=>{e(),zt.getState().openCeremony(L)}}),d.jsx(fi,{title:d.jsxs("span",{className:"flex items-center gap-1.5",children:[d.jsx(i3,{size:14}),"静默时段"]}),description:"开启后,普通通知会压到结束时间再发;紧急通知(notify --urgent)不受影响。默认关闭。",children:d.jsxs("div",{className:"flex flex-col items-end gap-2",children:[d.jsxs("label",{className:"flex items-center gap-2 text-[12px] text-zinc-600",children:[d.jsx("input",{type:"checkbox",checked:(u==null?void 0:u.enabled)??!1,onChange:L=>h(q=>q&&{...q,enabled:L.target.checked}),className:"h-3.5 w-3.5 accent-zinc-900"}),"启用"]}),d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("input",{type:"time",value:(u==null?void 0:u.start)??"23:00",disabled:!(u!=null&&u.enabled),onChange:L=>h(q=>q&&{...q,start:L.target.value}),"aria-label":"静默开始时间",className:"h-7 rounded-md border border-zinc-200 px-1.5 text-[12px] tabular-nums text-zinc-700 outline-none disabled:bg-zinc-50 disabled:text-zinc-400"}),d.jsx("span",{className:"text-[12px] text-zinc-400",children:"至"}),d.jsx("input",{type:"time",value:(u==null?void 0:u.end)??"08:00",disabled:!(u!=null&&u.enabled),onChange:L=>h(q=>q&&{...q,end:L.target.value}),"aria-label":"静默结束时间",className:"h-7 rounded-md border border-zinc-200 px-1.5 text-[12px] tabular-nums text-zinc-700 outline-none disabled:bg-zinc-50 disabled:text-zinc-400"}),d.jsx("button",{type:"button",disabled:!u||E.isPending||!l.adopted,onClick:()=>{C(!1),u&&E.mutate(u)},className:"h-7 rounded-md bg-zinc-900 px-2.5 text-[12px] font-medium text-white hover:bg-zinc-800 disabled:opacity-40",children:"保存"})]}),S&&d.jsx("span",{className:"text-[11px] text-emerald-600",children:"已保存"})]})}),d.jsx(fi,{title:d.jsxs("span",{className:"flex items-center gap-1.5",children:[d.jsx(Lo,{size:14}),"静默触发表情"]}),description:"在时间线的消息上点这个表情,就在背后开一轮 Agent。不会新增用户气泡,也不会弹通知;只接受一个 emoji,留空关闭。",children:d.jsxs("div",{className:"flex flex-col items-end gap-1.5",children:[d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsx("input",{value:g,maxLength:16,onChange:L=>{x(L.target.value),k(!1),b(void 0)},"aria-label":"静默触发表情",placeholder:"例如 🐱",className:"h-8 w-20 rounded-lg border border-zinc-300 bg-white px-2 text-center text-[16px] text-zinc-900 outline-none placeholder:text-[12px] placeholder:text-zinc-400"}),d.jsx("button",{type:"button","aria-label":"保存静默触发表情",disabled:M.isPending||!O,onClick:()=>{F!==void 0&&M.mutate(F)},className:"h-8 rounded-md bg-zinc-900 px-2.5 text-[12px] font-medium text-white hover:bg-zinc-800 disabled:opacity-40",children:M.isPending?"保存中…":"保存"})]}),g.trim()&&F===void 0&&d.jsx("span",{className:"text-[11px] text-red-600",children:"只支持单个 emoji"}),_&&F!==void 0&&!O&&d.jsx("span",{className:"text-[11px] text-emerald-600",children:"已保存"}),v&&d.jsx("span",{className:"max-w-56 text-right text-[11px] text-red-600",children:v})]})}),d.jsxs("div",{className:"px-4 py-3 text-[12px] leading-5 text-zinc-400",children:["小猫派活、验收和 watch 用 CLI 完成:",d.jsx("code",{className:"rounded bg-zinc-100 px-1 py-0.5 font-mono text-[11px] text-zinc-600",children:"agent-dock task|watch|notify -h"}),"。侧边会话只能 ",d.jsx("code",{className:"rounded bg-zinc-100 px-1 py-0.5 font-mono text-[11px] text-zinc-600",children:"task report"})," 和 ",d.jsx("code",{className:"rounded bg-zinc-100 px-1 py-0.5 font-mono text-[11px] text-zinc-600",children:"draft create"}),"。命令行认领:",d.jsx("code",{className:"rounded bg-zinc-100 px-1 py-0.5 font-mono text-[11px] text-zinc-600",children:"agent-dock main set --agent claude --name 小A同学"}),"。"]}),y&&d.jsx("div",{className:"mx-4 mb-3 rounded-md border border-red-200 bg-red-50 px-2.5 py-2 text-[12px] text-red-700",children:y})]})})]}),d.jsx(To,{open:j,tone:"warning",title:`让${l.name}休息?`,description:"解除后它不再是主会话:不会再收到督办信号,也不能派活和验收。会话本身和已有的便签都会保留,之后可以在首页重新认领一只。",confirmLabel:"让它休息",busy:R.isPending,onCancel:()=>{R.isPending||z(!1)},onConfirm:()=>R.mutate()})]})}function L7(e){const t=(e??"").split(":"),[n,r,i,...s]=t;if(!(!n||!(r!=null&&r.startsWith("oc_")))){if(t.length===2)return{appId:n,chatId:r,chatType:"p2p",scope:""};if(!(t.length<3))return{appId:n,chatId:r,chatType:i,scope:s.join(":")}}}function aT(e){return`https://applink.feishu.cn/client/chat/open?openChatId=${encodeURIComponent(e)}`}function iSe(e){const t=L7(e);if(!t)return;const n=t.scope.startsWith("thread:")?t.scope.slice(7).trim():void 0;return n?{url:`${aT(t.chatId)}&threadId=${encodeURIComponent(n)}`,exact:!1,threadId:n}:{url:aT(t.chatId),exact:!0}}function sSe(e,t,n){const r=i=>e.some(s=>s.openId===i);return n&&r(n)?[n]:t&&r(t)?[t]:e.length?[e[0].openId]:[]}function oSe(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function aSe(e,t,n){const r=t.trim().toLowerCase(),i=new Set(n);return e.filter(s=>i.has(s.openId)||!r||s.name.toLowerCase().includes(r)).sort((s,o)=>Number(i.has(o.openId))-Number(i.has(s.openId)))}function lSe({session:e,agent:t,onClose:n}){var J,ae,ne,re,ie,G,oe,ge;const r=Ln(),i=m.useRef(null);Vo({panel:i,initial:i,dismissible:!0,onDismiss:n});const s=Et({queryKey:["lark-config"],queryFn:we.larkConfig}),o=((J=s.data)==null?void 0:J.bots)??[],l=((ae=Et({queryKey:["session-handover",e.id],queryFn:()=>we.sessionHandover(e.id),staleTime:3e4}).data)==null?void 0:ae.kitten)??void 0,[c,u]=m.useState(""),[h,f]=m.useState(),p=l?`${l.name} · AgentDock`:`${aye(e.title)||(t==null?void 0:t.name)||e.agentId} · AgentDock`,g=h??p,[x,v]=m.useState(""),[b,y]=m.useState(""),[w,S]=m.useState(),[C,_]=th("agentdock:handover-self-openid",{defaultValue:""}),[k,j]=m.useState(null),[z,N]=m.useState([]),I=o.some(U=>U.appId===c)?c:((ne=o[0])==null?void 0:ne.appId)??"",$=o.find(U=>U.appId===I),R=(re=L7(e.sourceId))==null?void 0:re.chatId,E=Et({queryKey:["lark-app-owner",I],queryFn:()=>we.larkAppOwner(I),enabled:!!I,staleTime:5*6e4}),M=Et({queryKey:["lark-chat-members",I,R],queryFn:()=>we.larkChatMembers(I,R),enabled:!!(I&&R),staleTime:6e4}),P=m.useMemo(()=>{var ce,ve;const U=new Map;(ce=E.data)!=null&&ce.owner&&U.set(E.data.owner.openId,E.data.owner.name);for(const fe of($==null?void 0:$.allowedUsers)??[])U.has(fe.openId)||U.set(fe.openId,fe.name);for(const fe of((ve=M.data)==null?void 0:ve.users)??[])U.has(fe.openId)||U.set(fe.openId,fe.name);for(const fe of z)U.has(fe.openId)||U.set(fe.openId,fe.name);return[...U].map(([fe,Ce])=>({openId:fe,name:Ce}))},[$,M.data,z,E.data]),A=yt({mutationFn:U=>we.larkMemberSearch(I,U),onSuccess:U=>{U.users.length&&(N(ce=>{const ve=new Map(ce.map(fe=>[fe.openId,fe]));for(const fe of U.users)ve.set(fe.openId,fe);return[...ve.values()]}),j(ce=>ce??[U.users[0].openId]))}}),D=P.map(U=>U.openId).sort(),F=Et({queryKey:["lark-user-profiles",I,D.join(",")],queryFn:()=>we.larkUserProfiles(I,D),enabled:!!(I&&D.length),staleTime:5*6e4}),O=U=>{var ce,ve,fe,Ce;return((ve=(ce=F.data)==null?void 0:ce.users.find(Pe=>Pe.openId===U))==null?void 0:ve.avatarUrl)??(((Ce=(fe=E.data)==null?void 0:fe.owner)==null?void 0:Ce.openId)===U?E.data.owner.avatarUrl:void 0)},B=k??sSe(P,(G=(ie=E.data)==null?void 0:ie.owner)==null?void 0:G.openId,C),V=U=>j(oSe(B,U)),T=m.useMemo(()=>aSe(P,b,B),[P,b,B]),W=x.trim(),L=W===""||W.startsWith("ou_"),q=[...new Set([...B,...L&&W?[W]:[]])],X=yt({mutationFn:()=>we.handoverSession(e.id,{appId:I,name:g,memberOpenIds:q}),onSuccess:U=>{B[0]&&_(B[0]),S(U),r.invalidateQueries({queryKey:["sessions"]}),r.invalidateQueries({queryKey:["session-handover",e.id]})}});return d.jsx("div",{className:"ui-overlay fixed inset-0 z-[60] grid place-items-center bg-zinc-950/30 p-3",onMouseDown:U=>{U.currentTarget===U.target&&n()},children:d.jsxs("div",{ref:i,role:"dialog","aria-modal":"true","aria-label":"托管给机器人",className:"ui-dialog flex max-h-[calc(100dvh-1.5rem)] w-full max-w-lg flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-[0_24px_80px_rgba(24,24,27,.2)]",children:[d.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-2 border-b border-zinc-100 px-4",children:[d.jsx(ti,{size:16,className:"text-zinc-500"}),d.jsx("span",{className:"text-[16px] font-semibold",children:"托管给机器人"}),d.jsx("span",{className:"hidden truncate text-[12px] text-zinc-400 sm:inline",children:"建一个飞书群,用群聊继续这个会话"}),d.jsx("button",{type:"button",onClick:n,"aria-label":"关闭",className:"ml-auto grid h-8 w-8 place-items-center rounded-lg text-zinc-400 hover:bg-zinc-100 hover:text-zinc-800",children:d.jsx(Wn,{size:16})})]}),d.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:d.jsxs(fl,{placeholder:d.jsx(pl,{}),children:[l&&d.jsxs("div",{"data-testid":"handover-kitten",className:"mb-3 flex items-center gap-2.5 rounded-lg border border-amber-100 bg-amber-50/60 px-2.5 py-2",children:[d.jsx("img",{src:l.avatarUrl,alt:`${l.name}的头像`,className:"h-9 w-9 shrink-0 rounded-full object-cover"}),d.jsxs("div",{className:"min-w-0 text-[12px] leading-4",children:[d.jsxs("div",{className:"font-medium text-zinc-800",children:["当前小猫:",l.name," · 第 ",l.generation," 代"]}),d.jsx("div",{className:"text-zinc-500",children:"建群后会尝试把飞书机器人名称和头像同步成这只小猫;不支持时会提示你手动处理。"})]})]}),s.isLoading&&d.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-zinc-400",children:[d.jsx(Gn,{size:13}),"正在读取机器人配置…"]}),!s.isLoading&&!o.length&&d.jsx("div",{className:"rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] leading-5 text-amber-800",children:"还没有配置任何飞书机器人。先到「飞书设置」添加一个,再回来托管。"}),o.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("label",{className:"block text-[12px] font-medium text-zinc-700",children:"用哪个机器人"}),d.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:o.map(U=>d.jsx("button",{type:"button",onClick:()=>{u(U.appId),j(null),y("")},className:`flex h-8 items-center gap-1.5 rounded-full border px-3 text-[12px] font-medium transition-colors ${U.appId===I?"border-zinc-900 bg-zinc-900 text-white":"border-zinc-200 bg-white text-zinc-600 hover:border-zinc-300"}`,children:U.name||U.appId},U.appId))}),d.jsx("label",{className:"mt-4 block text-[12px] font-medium text-zinc-700",children:"群名称"}),d.jsx(Qn,{size:"large",value:g,onChange:U=>f(U.target.value),className:"mt-1.5 text-[13px]"}),d.jsxs("div",{className:"mt-4 flex items-center gap-1.5 text-[12px] font-medium text-zinc-700",children:[d.jsx(Sx,{size:12}),"邀请成员",d.jsx("span",{className:"font-normal text-zinc-400",children:"(点成员胶囊勾选,可全部取消)"})]}),d.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[d.jsx(Qn,{className:"min-w-0 flex-1",value:b,onChange:U=>y(U.target.value),onPressEnter:U=>{b.trim()&&(U.preventDefault(),A.mutate(b.trim()))},placeholder:"输入姓名后回车搜索(机器人可见范围)",prefix:d.jsx(fa,{size:13,className:"text-zinc-400"}),suffix:M.isFetching||A.isPending?d.jsx(Gn,{size:12,className:"text-zinc-400"}):d.jsx("span",{})}),d.jsx("button",{type:"button",disabled:!I||!b.trim()||A.isPending,onClick:()=>A.mutate(b.trim()),className:"h-8 shrink-0 rounded-md border border-zinc-200 px-2.5 text-[12px] text-zinc-600 hover:bg-zinc-50 disabled:opacity-40",children:"搜索"})]}),(((oe=A.data)==null?void 0:oe.error)||A.error)&&d.jsx("p",{className:"mt-1.5 text-[12px] text-amber-700",children:((ge=A.data)==null?void 0:ge.error)??(A.error instanceof Error?A.error.message:"搜索失败")}),d.jsxs("div",{className:"mt-2.5 rounded-lg border border-zinc-100 bg-zinc-50/60 p-2.5",children:[d.jsxs("div",{className:"mb-2 flex items-center gap-1.5 text-[12px] text-zinc-400",children:[d.jsx(Sx,{size:11}),"已选 ",B.length," 人",B.length===0&&d.jsx("span",{className:"text-zinc-400",children:"· 仅机器人和自己可在群内,其他人可稍后邀请"})]}),d.jsx("div",{className:"max-h-40 overflow-y-auto",children:T.length>0?d.jsx("div",{className:"flex flex-wrap gap-1.5",children:T.map(U=>{const ce=B.includes(U.openId),ve=O(U.openId);return d.jsxs("button",{type:"button","aria-pressed":ce,onClick:()=>V(U.openId),className:`flex h-8 items-center gap-1.5 rounded-full border py-0.5 pl-0.5 pr-2.5 text-[12px] transition-colors ${ce?"border-blue-500 bg-blue-50 text-blue-700":"border-zinc-200 bg-white text-zinc-600 hover:border-zinc-300"}`,children:[ve?d.jsx("img",{src:ve,alt:"",className:"h-6 w-6 rounded-full object-cover"}):d.jsx("span",{className:"grid h-6 w-6 place-items-center rounded-full bg-zinc-100 text-[12px] text-zinc-500",children:(U.name||"?").slice(0,1)}),U.name,ce&&d.jsx("span",{"aria-hidden":"true",className:"ml-0.5 text-[10px] font-semibold",children:"✓"})]},U.openId)})}):d.jsx("p",{className:"text-[12px] text-zinc-400",children:M.isError&&R?"读取原群成员失败(机器人可能不在该群);用上面的搜索按姓名找人,或在下面填 open_id。":"没有匹配的成员:换个名字搜索,或在下面填 open_id。"})})]}),d.jsx(Qn,{value:x,status:L?void 0:"error",onChange:U=>v(U.target.value),placeholder:"补充一个 open_id(ou_ 开头,可选)",className:"mt-2 font-mono text-[12px]"}),!L&&d.jsx("p",{className:"mt-1 text-[12px] text-red-600",children:"open_id 必须以 ou_ 开头。"}),d.jsx("p",{className:"mt-3 text-[12px] leading-4 text-zinc-400",children:"建群后,这个群的消息会直接进入当前会话;现有 Agent、模型、历史都保持不变。群里需要 @ 机器人来唤醒。机器人白名单内的群成员都能以完全信任权限驱动这个会话,请只拉信任的人。"})]}),X.error&&d.jsx("p",{role:"alert",className:"mt-3 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[12px] leading-5 text-red-700",children:X.error instanceof Error?X.error.message:String(X.error)}),w&&d.jsxs("div",{className:"mt-3 rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2.5 text-[12px] leading-5 text-emerald-800",children:["已建群并绑定:",d.jsx("span",{className:"font-medium",children:w.name}),d.jsxs("a",{href:w.url,target:"_blank",rel:"noreferrer",className:"ml-2 inline-flex items-center gap-1 font-medium text-emerald-700 underline",children:[d.jsx(Ja,{size:11}),"打开群聊"]}),w.botProfile&&d.jsx("p",{className:`mt-1.5 border-t pt-1.5 ${w.botProfile.ok?"border-emerald-200 text-emerald-700":"border-amber-200 text-amber-800"}`,children:w.botProfile.message})]})]})}),d.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t border-zinc-100 px-4 py-3",children:[d.jsx("button",{type:"button",onClick:n,className:"rounded-lg border border-zinc-300 px-3.5 py-2 text-xs font-medium text-zinc-700 hover:bg-zinc-50",children:w?"完成":"取消"}),!w&&d.jsxs("button",{type:"button",disabled:!I||!g.trim()||!L||X.isPending,onClick:()=>X.mutate(),className:"flex items-center gap-1.5 rounded-lg bg-zinc-900 px-3.5 py-2 text-xs font-medium text-white hover:bg-zinc-700 disabled:cursor-not-allowed disabled:bg-zinc-200 disabled:text-zinc-400",children:[X.isPending&&d.jsx(Gn,{size:12}),"建群并托管"]})]})]})})}const cSe=/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/;function uSe(e){var r;const t=e.trim();return t?(((r=t.match(cSe))==null?void 0:r[0])??t).toLowerCase():void 0}function dSe(e,t){const n=t.trim().toLowerCase();if(!n||(e.title??"").toLowerCase().includes(n)||e.cwd.toLowerCase().includes(n))return!0;const r=uSe(t);return r?e.sessionId.toLowerCase().includes(r):!1}function hSe(e){if(!e)return"";const t=new Date(e);if(Number.isNaN(t.getTime()))return e;const n=r=>String(r).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}function fSe({session:e,selected:t,onSelect:n}){var r;return d.jsxs("button",{type:"button",onClick:n,"aria-pressed":t,className:`flex w-full items-center gap-3 border-b border-zinc-100 px-4 py-2.5 text-left transition-colors last:border-b-0 ${t?"bg-blue-50/70":"hover:bg-zinc-50"}`,children:[d.jsx("span",{className:`grid h-4 w-4 shrink-0 place-items-center rounded-full border ${t?"border-blue-500 bg-blue-500 text-white":"border-zinc-300 text-transparent"}`,children:d.jsx(gi,{size:11})}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:"truncate text-[13px] text-zinc-800",title:e.title??e.sessionId,children:((r=e.title)==null?void 0:r.trim())||"(无标题)"}),d.jsxs("div",{className:"mt-0.5 flex min-w-0 items-center gap-2 text-[12px] text-zinc-400",children:[d.jsx("span",{className:"truncate font-mono",title:e.cwd,children:e.cwd}),e.updatedAt&&d.jsx("span",{className:"shrink-0 tabular-nums",children:hSe(e.updatedAt)})]})]}),d.jsx("span",{className:"hidden shrink-0 font-mono text-[12px] text-zinc-300 sm:inline",title:e.sessionId,children:e.sessionId.slice(0,8)})]})}const pSe={full:"完整导入:把外部历史写进 AgentDock 时间线,并接管后续对话。",session:"仅接管会话:不回填历史,但 Agent 记得之前的上下文,下一条消息即可继续。"};function mSe({agents:e,onClose:t,onImported:n}){var j,z,N,I,$,R;const r=Ln(),i=m.useRef(null);Vo({panel:i,initial:i,dismissible:!0,onDismiss:t});const s=m.useMemo(()=>e.filter(E=>!E.disabled&&(E.protocol==="auto"||E.protocol==="acp")),[e]),[o,a]=m.useState((j=s[0])==null?void 0:j.id),[l,c]=m.useState(""),[u,h]=m.useState("full"),[f,p]=m.useState(),g=s,x=g.some(E=>E.id===o)?o:(z=g[0])==null?void 0:z.id,v=dY({queryKey:["external-sessions",x],enabled:!!x,initialPageParam:void 0,queryFn:({pageParam:E})=>we.externalSessions(x,E?{cursor:E}:{}),getNextPageParam:E=>E.nextCursor||void 0,retry:!1,refetchOnWindowFocus:!1,staleTime:3e4}),b=m.useMemo(()=>{var E;return((E=v.data)==null?void 0:E.pages.flatMap(M=>M.sessions))??[]},[v.data]),y=m.useMemo(()=>b.filter(E=>dSe(E,l)),[b,l]),w=v.error instanceof Error?v.error.message:void 0,S=yt({mutationFn:()=>we.importSession({agentId:x,externalSessionId:f.sessionId,cwd:f.cwd,mode:u}),onSuccess:E=>{r.invalidateQueries({queryKey:["sessions"]}),n(E),t()}}),C=S.error instanceof Error?S.error.message:void 0,_=yl();Pu(()=>{C&&_.show(`导入失败:${C}`)},[C]);const k=!!(x&&f)&&!S.isPending;return d.jsxs("div",{className:"ui-overlay fixed inset-0 z-[60] grid place-items-center bg-zinc-950/30 p-2 sm:p-4",children:[d.jsxs("div",{ref:i,role:"dialog","aria-modal":"true","aria-label":"导入外部会话",className:"ui-dialog flex h-[86dvh] w-full max-w-4xl flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-[0_24px_80px_rgba(24,24,27,.2)]",children:[d.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-zinc-100 px-4",children:[d.jsxs("div",{className:"flex items-center gap-2 text-[16px] font-semibold text-zinc-900",children:[d.jsx(ha,{size:16}),"导入外部会话"]}),d.jsx("span",{className:"hidden truncate text-[12px] text-zinc-400 sm:inline",children:"浏览各 Agent 自己记录的会话,选中后导入到 AgentDock"}),d.jsx("button",{type:"button",onClick:t,"aria-label":"关闭",className:"ml-auto grid h-8 w-8 place-items-center rounded-lg text-zinc-400 hover:bg-zinc-100 hover:text-zinc-800",children:d.jsx(Wn,{size:16})})]}),d.jsx(fl,{placeholder:d.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-4 py-3",children:d.jsx(pl,{})}),children:d.jsxs("div",{className:"grid min-h-0 flex-1 grid-cols-1 md:grid-cols-[200px_1fr]",children:[d.jsxs("div",{className:"hidden min-h-0 overflow-y-auto border-r border-zinc-100 bg-zinc-50/60 p-2 md:block",children:[g.map(E=>{const M=E.id===x;return d.jsxs("button",{type:"button",onClick:()=>{a(E.id),c(""),p(void 0)},className:`flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-left text-[12px] font-medium transition-colors ${M?"bg-white text-zinc-900 shadow-[0_1px_2px_rgba(24,24,27,.06)]":"text-zinc-600 hover:bg-white/70"}`,children:[d.jsx(Hr,{agentId:E.id,agentName:E.name,size:14}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:E.name})]},E.id)}),g.length===0&&d.jsx("div",{className:"px-2 py-2 text-[12px] text-zinc-400",children:"没有支持 ACP 的 Agent"})]}),d.jsxs("div",{className:"flex min-h-0 min-w-0 flex-col",children:[d.jsxs("div",{className:"flex shrink-0 gap-1.5 overflow-x-auto border-b border-zinc-100 bg-zinc-50/60 px-3 py-2 md:hidden",children:[g.map(E=>{const M=E.id===x;return d.jsxs("button",{type:"button",onClick:()=>{a(E.id),c(""),p(void 0)},className:`flex h-8 shrink-0 items-center gap-1.5 rounded-full border px-3 text-[12px] font-medium transition-colors ${M?"border-zinc-900 bg-zinc-900 text-white":"border-zinc-200 bg-white text-zinc-600"}`,children:[d.jsx(Hr,{agentId:E.id,agentName:E.name,size:13}),E.name]},E.id)}),g.length===0&&d.jsx("span",{className:"px-1 text-[12px] text-zinc-400",children:"没有支持 ACP 的 Agent"})]}),d.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-zinc-100 px-4 py-2.5",children:[d.jsxs("div",{className:"flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md border border-zinc-200 px-2.5 ui-field-within",children:[d.jsx(fa,{size:13,className:"shrink-0 text-zinc-400"}),d.jsx("input",{value:l,onChange:E=>c(E.target.value),placeholder:"按标题、工作目录或会话 ID 过滤(支持 codex://threads/…)",className:"min-w-0 flex-1 bg-transparent text-[12px] text-zinc-800 placeholder:text-zinc-400 outline-none"})]}),d.jsxs("button",{type:"button",disabled:!x||v.isFetching,onClick:()=>v.refetch(),className:"flex h-8 items-center gap-1 rounded-md border border-zinc-200 px-2.5 text-[12px] text-zinc-600 hover:bg-zinc-50 disabled:opacity-40",children:[d.jsx(Hn,{size:12,className:v.isFetching?"animate-spin":""}),"刷新"]})]}),d.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[v.isLoading&&d.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 text-[12px] text-zinc-400",children:[d.jsx(Gn,{size:13}),"正在读取会话列表…"]}),v.isError&&d.jsx("div",{className:"m-4 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-[12px] leading-5 text-red-700",children:w??"读取失败"}),!v.isLoading&&!v.isError&&((I=(N=v.data)==null?void 0:N.pages[0])==null?void 0:I.supported)===!1&&d.jsx("div",{className:"m-4 rounded-md border border-amber-200 bg-amber-50 px-3 py-2 text-[12px] leading-5 text-amber-800",children:"该 Agent 未实现会话列表能力(ACP session/list),暂时无法浏览它的历史会话。"}),!v.isLoading&&!v.isError&&((R=($=v.data)==null?void 0:$.pages[0])==null?void 0:R.supported)!==!1&&y.length===0&&d.jsx("div",{className:"px-4 py-3 text-[12px] text-zinc-400",children:l?"没有匹配的会话":"这个 Agent 没有历史会话"}),y.map(E=>d.jsx(fSe,{session:E,selected:(f==null?void 0:f.sessionId)===E.sessionId&&(f==null?void 0:f.cwd)===E.cwd,onSelect:()=>p(E)},`${E.cwd}:${E.sessionId}`)),v.hasNextPage&&!l&&d.jsx("div",{className:"p-3",children:d.jsxs("button",{type:"button",disabled:v.isFetchingNextPage,onClick:()=>v.fetchNextPage(),className:"flex h-8 w-full items-center justify-center gap-1.5 rounded-md border border-zinc-200 text-[12px] text-zinc-600 hover:bg-zinc-50 disabled:opacity-40",children:[v.isFetchingNextPage?d.jsx(Gn,{size:12}):null,"加载更多"]})})]}),d.jsxs("div",{className:"shrink-0 border-t border-zinc-100 px-4 py-2.5",children:[d.jsxs("div",{className:"flex flex-col gap-2 text-[12px] text-zinc-400 sm:flex-row sm:items-center sm:gap-3",children:[d.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["已列出 ",y.length," 条",v.hasNextPage?"(还有更多)":"",f?` · 已选 ${f.sessionId.slice(0,8)}`:""]}),d.jsx("div",{className:"flex w-full shrink-0 items-center gap-0.5 rounded-lg bg-zinc-100 p-0.5 sm:w-auto",children:["full","session"].map(E=>d.jsx("button",{type:"button",onClick:()=>h(E),className:`flex-1 rounded-md px-2.5 py-1 text-[12px] font-medium transition-colors sm:flex-none ${u===E?"bg-white text-zinc-900 shadow-[0_1px_2px_rgba(24,24,27,.08)]":"text-zinc-500 hover:text-zinc-800"}`,children:E==="full"?"完整导入":"仅接管会话"},E))}),d.jsxs("button",{type:"button",disabled:!k,onClick:()=>S.mutate(),className:"flex h-8 w-full shrink-0 items-center justify-center gap-1.5 rounded-lg bg-zinc-900 px-3 text-[12px] font-medium text-white hover:bg-zinc-700 disabled:cursor-not-allowed disabled:bg-zinc-200 disabled:text-zinc-400 sm:w-auto",children:[S.isPending?d.jsx(Gn,{size:12}):d.jsx(m3,{size:12}),"导入"]})]}),d.jsx("p",{className:"mt-1.5 text-[12px] leading-4 text-zinc-400",children:pSe[u]})]})]})]})})]}),_.toast]})}function gSe({session:e,onClose:t}){return d.jsx("div",{className:"ui-overlay fixed inset-0 z-30 grid place-items-center bg-zinc-950/30 p-4",onMouseDown:n=>{n.currentTarget===n.target&&t()},children:d.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"系统提示词",className:"ui-dialog flex max-h-[80dvh] w-full max-w-2xl flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-[0_24px_80px_rgba(24,24,27,.2)]",children:[d.jsxs("div",{className:"flex items-center border-b border-zinc-100 px-4 py-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("h2",{className:"text-[16px] font-semibold text-zinc-900",children:"系统提示词"}),d.jsx("p",{className:"mt-0.5 truncate text-[12px] text-zinc-500",children:"创建时提示词"})]}),d.jsx("span",{className:"ml-auto",children:d.jsx($o,{label:"关闭",onClick:t,children:d.jsx(Wn,{size:16})})})]}),d.jsx("div",{className:"space-y-5 overflow-y-auto px-4 py-4",children:d.jsxs("section",{children:[d.jsx("h3",{className:"mb-2 text-[12px] font-semibold text-zinc-500",children:"创建时提示词"}),d.jsx("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono text-[12px] leading-5 text-zinc-700",children:e.systemPrompt})]})})]})})}function vSe(){var e;return typeof window>"u"||(e=window.agentdockDesktop)==null?void 0:e.network}function xSe(){const e=vSe(),[t,n]=m.useState();m.useEffect(()=>{if(!e)return;let i=!0;return e.getState().then(s=>{i&&n(s)}).catch(()=>{}),()=>{i=!1}},[e]);const r=m.useCallback(async i=>{if(!e)return;const s=await e.setLanAccess(i);return n(s),s},[e]);return{api:e,state:t,setLanAccess:r}}function lT(e){try{const t=new URL(e);return t.searchParams.delete("t"),t.toString()}catch{return e}}function bSe(e){try{return new URL(e).host}catch{return e}}function cT(e){const t=["lan-v4","hostname","public","lan-v6"];for(const n of t){const r=e.find(i=>i.kind===n);if(r)return r}return e[0]}function ySe({onClose:e}){var C,_,k,j,z;const t=xSe(),n=Et({queryKey:["share-link"],queryFn:()=>we.shareLink(),retry:!1}),[r,i]=m.useState(),[s,o]=m.useState(!1),[a,l]=m.useState(!1),[c,u]=m.useState(!1),[h,f]=m.useState(),[p,g]=m.useState(!1),x=n.data,v=m.useMemo(()=>(x==null?void 0:x.urls.filter(N=>N.kind!=="public"))??[],[x]),b=m.useMemo(()=>v.find(N=>N.url===r)??(x?cT(v):void 0),[x,v,r]);m.useEffect(()=>{x&&i(N=>{var I;return N&&v.some($=>$.url===N)?N:(I=cT(v))==null?void 0:I.url})},[x,v]),m.useEffect(()=>{if(!s)return;const N=setTimeout(()=>o(!1),1500);return()=>clearTimeout(N)},[s]);const y=async()=>{if(b)try{await navigator.clipboard.writeText(b.url),o(!0)}catch{const N=document.createElement("textarea");N.value=b.url,N.style.position="fixed",N.style.opacity="0",document.body.appendChild(N),N.select(),document.execCommand("copy"),N.remove(),o(!0)}},w=async N=>{u(!0),f(void 0);try{await t.setLanAccess(N),l(!1),g(!0)}catch(I){f(I instanceof Error?I.message:String(I))}finally{u(!1)}},S=x&&!v.length?t.api&&!((C=t.state)!=null&&C.lanAccess)?"桌面客户端目前只监听本机(127.0.0.1),手机无法连接。开启局域网访问后即可扫码。":x.lanEnabled?"没有检测到可用的局域网地址,请确认电脑已连接 Wi-Fi 或网线。":"当前服务只监听本机(--local-only)。用 agent-dock --host 0.0.0.0 重启后,手机才能访问。":void 0;return d.jsx("div",{className:"ui-overlay fixed inset-0 z-50 grid place-items-center bg-zinc-950/35 p-4",onMouseDown:N=>{N.currentTarget===N.target&&!p&&e()},children:d.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"在手机上打开",className:"ui-dialog flex max-h-[88dvh] w-full max-w-[460px] flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-[0_24px_80px_rgba(24,24,27,.22)]",children:[d.jsxs("div",{className:"flex items-center border-b border-zinc-100 px-4 py-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("h2",{className:"text-[16px] font-semibold text-zinc-900",children:"在手机上打开"}),d.jsx("p",{className:"mt-0.5 truncate text-[12px] text-zinc-500",children:"扫码后可操作整个控制台"})]}),d.jsx("span",{className:"ml-auto",children:d.jsx($o,{label:"关闭",onClick:e,children:d.jsx(Wn,{size:16})})})]}),d.jsxs("div",{className:"space-y-4 overflow-y-auto px-4 py-4",children:[n.isLoading&&d.jsxs("div",{className:"flex items-center justify-center gap-2 py-12 text-[12px] text-zinc-500",children:[d.jsx(_i,{size:16,className:"animate-spin"}),"正在生成扫码链接…"]}),n.isError&&d.jsxs("div",{className:"rounded-xl border border-red-100 bg-red-50 px-3 py-3 text-[12px] leading-5 text-red-700",children:[n.error instanceof Error?n.error.message:"扫码链接生成失败",d.jsxs("button",{type:"button",onClick:()=>void n.refetch(),className:"ml-2 inline-flex items-center gap-1 font-medium underline underline-offset-2",children:[d.jsx(Hn,{size:11}),"重试"]})]}),x&&b&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"flex justify-center",children:d.jsx("div",{className:"w-full max-w-[248px] rounded-xl bg-white p-2.5 ring-1 ring-zinc-200",children:d.jsx(zy,{value:b.url,size:228,marginSize:2,className:"h-auto w-full",title:"扫码在手机上打开 AgentDock"})})}),d.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-zinc-200 bg-zinc-50/70 px-2.5 py-2",children:[d.jsx(rX,{size:14,className:"shrink-0 text-zinc-400"}),d.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-[12px] text-zinc-600",title:lT(b.url),children:[bSe(b.url),d.jsx("span",{className:"text-zinc-400",children:new URL(lT(b.url)).pathname})]}),d.jsxs("button",{type:"button",onClick:()=>void y(),className:"flex h-7 shrink-0 items-center gap-1 rounded-md px-2 text-[12px] font-medium text-zinc-700 transition-colors hover:bg-white hover:text-zinc-900",children:[s?d.jsx(gi,{size:12,className:"text-emerald-600"}):d.jsx(a3,{size:12}),s?"已复制":"复制"]})]}),v.length>1&&d.jsx("div",{className:"flex flex-wrap gap-1.5",children:v.map(N=>d.jsxs("button",{type:"button","aria-pressed":N.url===b.url,onClick:()=>i(N.url),className:`flex h-7 items-center gap-1.5 rounded-full border px-2.5 text-[12px] transition-colors ${N.url===b.url?"border-zinc-900 bg-zinc-900 text-white":"border-zinc-200 bg-white text-zinc-600 hover:border-zinc-300 hover:text-zinc-900"}`,children:[d.jsx(_x,{size:11}),N.label]},N.url))}),d.jsxs("p",{className:"text-[12px] leading-5 text-zinc-500",children:["链接拥有整个控制台权限,有效至 ",new Date(x.expiresAt).toLocaleDateString("zh-CN",{year:"numeric",month:"long",day:"numeric"}),"。请勿转发或公开展示。"]})]}),x&&!v.length&&d.jsx("div",{className:"rounded-xl border border-amber-100 bg-amber-50/70 px-3 py-3 text-[12px] leading-5 text-amber-800",children:S}),(t.api||x&&!x.lanEnabled)&&d.jsxs("section",{className:"border-t border-zinc-100 pt-3",children:[d.jsxs("div",{className:"flex items-center gap-2",children:[d.jsx(_x,{size:14,className:"text-zinc-400"}),d.jsxs("div",{className:"min-w-0 flex-1",children:[d.jsx("div",{className:"text-[13px] text-zinc-800",children:"局域网访问"}),d.jsx("div",{className:"mt-0.5 text-[12px] leading-5 text-zinc-500",children:t.api?(_=t.state)!=null&&_.lanAccess?"已开启,同一 Wi-Fi 下的手机可以连接。":"关闭中,手机无法通过局域网连接。":"服务端监听设置由启动参数决定。"})]}),t.api&&!p&&d.jsx("button",{type:"button",disabled:c,onClick:()=>l(!0),className:"h-7 shrink-0 rounded-md border border-zinc-200 px-2.5 text-[12px] font-medium text-zinc-700 transition-colors hover:border-zinc-300 hover:bg-zinc-50 disabled:opacity-50",children:c?"处理中…":(k=t.state)!=null&&k.lanAccess?"关闭…":"开启…"})]}),p&&d.jsxs("div",{className:"mt-2 flex items-center gap-1.5 text-[12px] text-emerald-700",children:[d.jsx(_i,{size:12,className:"animate-spin"}),"本地服务正在重启,页面会自动刷新。"]}),h&&d.jsx("div",{className:"mt-2 rounded-lg border border-red-100 bg-red-50 px-2.5 py-2 text-[12px] text-red-700",children:h})]})]}),d.jsx(To,{open:a,tone:"warning",title:(j=t.state)!=null&&j.lanAccess?"关闭局域网访问?":"开启局域网访问?",description:"切换需要重启本地服务,正在运行的 Agent 任务会中断。二维码只在服务重启完成后生效。",confirmLabel:(z=t.state)!=null&&z.lanAccess?"关闭并重启":"开启并重启",busy:c,error:h,onCancel:()=>{c||l(!1)},onConfirm:()=>{var N;return void w(!((N=t.state)!=null&&N.lanAccess))}})]})})}function wSe(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const SSe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,_Se=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,CSe={};function uT(e,t){return(CSe.jsx?_Se:SSe).test(e)}const kSe=/[ \t\n\f\r]/g;function NSe(e){return typeof e=="object"?e.type==="text"?dT(e.value):!1:dT(e)}function dT(e){return e.replace(kSe,"")===""}let r0=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};r0.prototype.normal={};r0.prototype.property={};r0.prototype.space=void 0;function F7(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new r0(n,r,t)}function mk(e){return e.toLowerCase()}class gs{constructor(t,n){this.attribute=n,this.property=t}}gs.prototype.attribute="";gs.prototype.booleanish=!1;gs.prototype.boolean=!1;gs.prototype.commaOrSpaceSeparated=!1;gs.prototype.commaSeparated=!1;gs.prototype.defined=!1;gs.prototype.mustUseProperty=!1;gs.prototype.number=!1;gs.prototype.overloadedBoolean=!1;gs.prototype.property="";gs.prototype.spaceSeparated=!1;gs.prototype.space=void 0;let ESe=0;const Zt=kd(),Er=kd(),gk=kd(),lt=kd(),Bn=kd(),Fu=kd(),Ns=kd();function kd(){return 2**++ESe}const vk=Object.freeze(Object.defineProperty({__proto__:null,boolean:Zt,booleanish:Er,commaOrSpaceSeparated:Ns,commaSeparated:Fu,number:lt,overloadedBoolean:gk,spaceSeparated:Bn},Symbol.toStringTag,{value:"Module"})),Gw=Object.keys(vk);class uj extends gs{constructor(t,n,r,i){let s=-1;if(super(t,n),hT(this,"space",i),typeof r=="number")for(;++s<Gw.length;){const o=Gw[s];hT(this,Gw[s],(r&vk[o])===vk[o])}}}uj.prototype.defined=!0;function hT(e,t,n){n&&(e[t]=n)}function Hf(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new uj(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[mk(r)]=r,n[mk(s.attribute)]=r}return new r0(t,n,e.space)}const B7=Hf({properties:{ariaActiveDescendant:null,ariaAtomic:Er,ariaAutoComplete:null,ariaBusy:Er,ariaChecked:Er,ariaColCount:lt,ariaColIndex:lt,ariaColSpan:lt,ariaControls:Bn,ariaCurrent:null,ariaDescribedBy:Bn,ariaDetails:null,ariaDisabled:Er,ariaDropEffect:Bn,ariaErrorMessage:null,ariaExpanded:Er,ariaFlowTo:Bn,ariaGrabbed:Er,ariaHasPopup:null,ariaHidden:Er,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Bn,ariaLevel:lt,ariaLive:null,ariaModal:Er,ariaMultiLine:Er,ariaMultiSelectable:Er,ariaOrientation:null,ariaOwns:Bn,ariaPlaceholder:null,ariaPosInSet:lt,ariaPressed:Er,ariaReadOnly:Er,ariaRelevant:null,ariaRequired:Er,ariaRoleDescription:Bn,ariaRowCount:lt,ariaRowIndex:lt,ariaRowSpan:lt,ariaSelected:Er,ariaSetSize:lt,ariaSort:null,ariaValueMax:lt,ariaValueMin:lt,ariaValueNow:lt,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function H7(e,t){return t in e?e[t]:t}function V7(e,t){return H7(e,t.toLowerCase())}const jSe=Hf({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Fu,acceptCharset:Bn,accessKey:Bn,action:null,allow:null,allowFullScreen:Zt,allowPaymentRequest:Zt,allowUserMedia:Zt,alpha:Zt,alt:null,as:null,async:Zt,autoCapitalize:null,autoComplete:Bn,autoFocus:Zt,autoPlay:Zt,blocking:Bn,capture:null,charSet:null,checked:Zt,cite:null,className:Bn,closedBy:null,colorSpace:null,cols:lt,colSpan:lt,command:null,commandFor:null,content:null,contentEditable:Er,controls:Zt,controlsList:Bn,coords:lt|Fu,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Zt,defer:Zt,dir:null,dirName:null,disabled:Zt,download:gk,draggable:Er,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Zt,formTarget:null,headers:Bn,height:lt,hidden:gk,high:lt,href:null,hrefLang:null,htmlFor:Bn,httpEquiv:Bn,id:null,imageSizes:null,imageSrcSet:null,inert:Zt,inputMode:null,integrity:null,is:null,isMap:Zt,itemId:null,itemProp:Bn,itemRef:Bn,itemScope:Zt,itemType:Bn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Zt,low:lt,manifest:null,max:null,maxLength:lt,media:null,method:null,min:null,minLength:lt,multiple:Zt,muted:Zt,name:null,nonce:null,noModule:Zt,noValidate:Zt,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:Zt,optimum:lt,pattern:null,ping:Bn,placeholder:null,playsInline:Zt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Zt,referrerPolicy:null,rel:Bn,required:Zt,reversed:Zt,rows:lt,rowSpan:lt,sandbox:Bn,scope:null,scoped:Zt,seamless:Zt,selected:Zt,shadowRootClonable:Zt,shadowRootCustomElementRegistry:Zt,shadowRootDelegatesFocus:Zt,shadowRootMode:null,shadowRootSerializable:Zt,shape:null,size:lt,sizes:null,slot:null,span:lt,spellCheck:Er,src:null,srcDoc:null,srcLang:null,srcSet:null,start:lt,step:null,style:null,tabIndex:lt,target:null,title:null,translate:null,type:null,typeMustMatch:Zt,useMap:null,value:Er,width:lt,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Bn,axis:null,background:null,bgColor:null,border:lt,borderColor:null,bottomMargin:lt,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Zt,declare:Zt,event:null,face:null,frame:null,frameBorder:null,hSpace:lt,leftMargin:lt,link:null,longDesc:null,lowSrc:null,marginHeight:lt,marginWidth:lt,noResize:Zt,noHref:Zt,noShade:Zt,noWrap:Zt,object:null,profile:null,prompt:null,rev:null,rightMargin:lt,rules:null,scheme:null,scrolling:Er,standby:null,summary:null,text:null,topMargin:lt,valueType:null,version:null,vAlign:null,vLink:null,vSpace:lt,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:Zt,disablePictureInPicture:Zt,disableRemotePlayback:Zt,exportParts:Fu,part:Bn,prefix:null,property:null,results:lt,security:null,unselectable:null},space:"html",transform:V7}),zSe=Hf({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:Ns,accentHeight:lt,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:lt,amplitude:lt,arabicForm:null,ascent:lt,attributeName:null,attributeType:null,azimuth:lt,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:lt,by:null,calcMode:null,capHeight:lt,className:Bn,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:lt,diffuseConstant:lt,direction:null,display:null,dur:null,divisor:lt,dominantBaseline:null,download:Zt,dx:null,dy:null,edgeMode:null,editable:null,elevation:lt,enableBackground:null,end:null,event:null,exponent:lt,externalResourcesRequired:null,fill:null,fillOpacity:lt,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:Fu,g2:Fu,glyphName:Fu,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:lt,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:lt,horizOriginX:lt,horizOriginY:lt,id:null,ideographic:lt,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:lt,k:lt,k1:lt,k2:lt,k3:lt,k4:lt,kernelMatrix:Ns,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:lt,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:lt,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:lt,overlineThickness:lt,paintOrder:null,panose1:null,path:null,pathLength:lt,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Bn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:lt,pointsAtY:lt,pointsAtZ:lt,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ns,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ns,rev:Ns,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ns,requiredFeatures:Ns,requiredFonts:Ns,requiredFormats:Ns,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:lt,specularExponent:lt,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:lt,strikethroughThickness:lt,string:null,stroke:null,strokeDashArray:Ns,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:lt,strokeOpacity:lt,strokeWidth:null,style:null,surfaceScale:lt,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ns,tabIndex:lt,tableValues:null,target:null,targetX:lt,targetY:lt,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ns,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:lt,underlineThickness:lt,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:lt,values:null,vAlphabetic:lt,vMathematical:lt,vectorEffect:null,vHanging:lt,vIdeographic:lt,version:null,vertAdvY:lt,vertOriginX:lt,vertOriginY:lt,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:lt,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:H7}),W7=Hf({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),q7=Hf({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:V7}),U7=Hf({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),MSe={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"},$Se=/[A-Z]/g,fT=/-[a-z]/g,ISe=/^data[-\w.:]+$/i;function RSe(e,t){const n=mk(t);let r=t,i=gs;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&ISe.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(fT,PSe);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!fT.test(s)){let o=s.replace($Se,OSe);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=uj}return new i(r,t)}function OSe(e){return"-"+e.toLowerCase()}function PSe(e){return e.charAt(1).toUpperCase()}const TSe=F7([B7,jSe,W7,q7,U7],"html"),dj=F7([B7,zSe,W7,q7,U7],"svg");function ASe(e){return e.join(" ").trim()}var Vd={},Yw,pT;function DSe(){if(pT)return Yw;pT=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=`
|
|
913
913
|
`,c="/",u="*",h="",f="comment",p="declaration";function g(v,b){if(typeof v!="string")throw new TypeError("First argument must be a string");if(!v)return[];b=b||{};var y=1,w=1;function S(E){var M=E.match(t);M&&(y+=M.length);var P=E.lastIndexOf(l);w=~P?E.length-P:w+E.length}function C(){var E={line:y,column:w};return function(M){return M.position=new _(E),z(),M}}function _(E){this.start=E,this.end={line:y,column:w},this.source=b.source}_.prototype.content=v;function k(E){var M=new Error(b.source+":"+y+":"+w+": "+E);if(M.reason=E,M.filename=b.source,M.line=y,M.column=w,M.source=v,!b.silent)throw M}function j(E){var M=E.exec(v);if(M){var P=M[0];return S(P),v=v.slice(P.length),M}}function z(){j(n)}function N(E){var M;for(E=E||[];M=I();)M!==!1&&E.push(M);return E}function I(){var E=C();if(!(c!=v.charAt(0)||u!=v.charAt(1))){for(var M=2;h!=v.charAt(M)&&(u!=v.charAt(M)||c!=v.charAt(M+1));)++M;if(M+=2,h===v.charAt(M-1))return k("End of comment missing");var P=v.slice(2,M-2);return w+=2,S(P),v=v.slice(M),w+=2,E({type:f,comment:P})}}function $(){var E=C(),M=j(r);if(M){if(I(),!j(i))return k("property missing ':'");var P=j(s),A=E({type:p,property:x(M[0].replace(e,h)),value:P?x(P[0].replace(e,h)):h});return j(o),A}}function R(){var E=[];N(E);for(var M;M=$();)M!==!1&&(E.push(M),N(E));return E}return z(),R()}function x(v){return v?v.replace(a,h):h}return Yw=g,Yw}var mT;function LSe(){if(mT)return Vd;mT=1;var e=Vd&&Vd.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Vd,"__esModule",{value:!0}),Vd.default=n;const t=e(DSe());function n(r,i){let s=null;if(!r||typeof r!="string")return s;const o=(0,t.default)(r),a=typeof i=="function";return o.forEach(l=>{if(l.type!=="declaration")return;const{property:c,value:u}=l;a?i(c,u,l):u&&(s=s||{},s[c]=u)}),s}return Vd}var yp={},gT;function FSe(){if(gT)return yp;gT=1,Object.defineProperty(yp,"__esModule",{value:!0}),yp.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,i=/^-(ms)-/,s=function(c){return!c||n.test(c)||e.test(c)},o=function(c,u){return u.toUpperCase()},a=function(c,u){return"".concat(u,"-")},l=function(c,u){return u===void 0&&(u={}),s(c)?c:(c=c.toLowerCase(),u.reactCompat?c=c.replace(i,a):c=c.replace(r,a),c.replace(t,o))};return yp.camelCase=l,yp}var wp,vT;function BSe(){if(vT)return wp;vT=1;var e=wp&&wp.__importDefault||function(i){return i&&i.__esModule?i:{default:i}},t=e(LSe()),n=FSe();function r(i,s){var o={};return!i||typeof i!="string"||(0,t.default)(i,function(a,l){a&&l&&(o[(0,n.camelCase)(a,s)]=l)}),o}return r.default=r,wp=r,wp}var HSe=BSe();const VSe=ts(HSe),K7=G7("end"),hj=G7("start");function G7(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function WSe(e){const t=hj(e),n=K7(e);if(t&&n)return{start:t,end:n}}function fm(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?xT(e.position):"start"in e||"end"in e?xT(e):"line"in e||"column"in e?xk(e):""}function xk(e){return bT(e&&e.line)+":"+bT(e&&e.column)}function xT(e){return xk(e&&e.start)+"-"+xk(e&&e.end)}function bT(e){return e&&typeof e=="number"?e:1}class Vi extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=fm(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Vi.prototype.file="";Vi.prototype.name="";Vi.prototype.reason="";Vi.prototype.message="";Vi.prototype.stack="";Vi.prototype.column=void 0;Vi.prototype.line=void 0;Vi.prototype.ancestors=void 0;Vi.prototype.cause=void 0;Vi.prototype.fatal=void 0;Vi.prototype.place=void 0;Vi.prototype.ruleId=void 0;Vi.prototype.source=void 0;const fj={}.hasOwnProperty,qSe=new Map,USe=/[A-Z]/g,KSe=new Set(["table","tbody","thead","tfoot","tr"]),GSe=new Set(["td","th"]),Y7="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function YSe(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=r_e(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=n_e(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?dj:TSe,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=Z7(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function Z7(e,t,n){if(t.type==="element")return ZSe(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return XSe(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return QSe(e,t,n);if(t.type==="mdxjsEsm")return JSe(e,t);if(t.type==="root")return e_e(e,t,n);if(t.type==="text")return t_e(e,t)}function ZSe(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=dj,e.schema=i),e.ancestors.push(t);const s=J7(e,t.tagName,!1),o=i_e(e,t);let a=mj(e,t);return KSe.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!NSe(l):!0})),X7(e,o,s,t),pj(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function XSe(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}Xm(e,t.position)}function JSe(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Xm(e,t.position)}function QSe(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=dj,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:J7(e,t.name,!0),o=s_e(e,t),a=mj(e,t);return X7(e,o,s,t),pj(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function e_e(e,t,n){const r={};return pj(r,mj(e,t)),e.create(t,e.Fragment,r,n)}function t_e(e,t){return t.value}function X7(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function pj(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function n_e(e,t,n){return r;function r(i,s,o,a){const c=Array.isArray(o.children)?n:t;return a?c(s,o,a):c(s,o)}}function r_e(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=hj(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function i_e(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&fj.call(t.properties,i)){const s=o_e(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&GSe.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function s_e(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else Xm(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else Xm(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function mj(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:qSe;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;o=l+"-"+c,i.set(l,c+1)}}const a=Z7(e,s,o);a!==void 0&&n.push(a)}return n}function o_e(e,t,n){const r=RSe(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?wSe(n):ASe(n)),r.property==="style"){let i=typeof n=="object"?n:a_e(e,String(n));return e.stylePropertyNameCase==="css"&&(i=l_e(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?MSe[r.property]||r.property:r.attribute,n]}}function a_e(e,t){try{return VSe(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Vi("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=Y7+"#cannot-parse-style-attribute",i}}function J7(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=uT(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=uT(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return fj.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Xm(e)}function Xm(e,t){const n=new Vi("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=Y7+"#cannot-handle-mdx-estrees-without-createevaluater",n}function l_e(e){const t={};let n;for(n in e)fj.call(e,n)&&(t[c_e(n)]=e[n]);return t}function c_e(e){let t=e.replace(USe,u_e);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function u_e(e){return"-"+e.toLowerCase()}const Zw={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"]},d_e={};function gj(e,t){const n=d_e,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return Q7(e,r,i)}function Q7(e,t,n){if(h_e(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return yT(e.children,t,n)}return Array.isArray(e)?yT(e,t,n):""}function yT(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=Q7(e[i],t,n);return r.join("")}function h_e(e){return!!(e&&typeof e=="object")}const wT=document.createElement("i");function vj(e){const t="&"+e+";";wT.innerHTML=t;const n=wT.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Rs(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function to(e,t){return e.length>0?(Rs(e,e.length,0,t),e):t}const ST={}.hasOwnProperty;function eV(e){const t={};let n=-1;for(;++n<e.length;)f_e(t,e[n]);return t}function f_e(e,t){let n;for(n in t){const i=(ST.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){ST.call(i,o)||(i[o]=[]);const a=s[o];p_e(i[o],Array.isArray(a)?a:a?[a]:[])}}}function p_e(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Rs(e,0,0,r)}function tV(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Ao(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Xi=Fc(/[A-Za-z]/),Oi=Fc(/[\dA-Za-z]/),m_e=Fc(/[#-'*+\--9=?A-Z^-~]/);function lb(e){return e!==null&&(e<32||e===127)}const bk=Fc(/\d/),g_e=Fc(/[\dA-Fa-f]/),v_e=Fc(/[!-/:-@[-`{-~]/);function Dt(e){return e!==null&&e<-2}function Vn(e){return e!==null&&(e<0||e===32)}function cn(e){return e===-2||e===-1||e===32}const Vy=Fc(new RegExp("\\p{P}|\\p{S}","u")),ud=Fc(/\s/);function Fc(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Vf(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&Oi(e.charCodeAt(n+1))&&Oi(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function yn(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return cn(l)?(e.enter(n),a(l)):t(l)}function a(l){return cn(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const x_e={tokenize:b_e};function b_e(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),yn(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return Dt(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const y_e={tokenize:w_e},_T={tokenize:S_e};function w_e(e){const t=this,n=[];let r=0,i,s,o;return a;function a(w){if(r<n.length){const S=n[r];return t.containerState=S[1],e.attempt(S[0].continuation,l,c)(w)}return c(w)}function l(w){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&y();const S=t.events.length;let C=S,_;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){_=t.events[C][1].end;break}b(r);let k=S;for(;k<t.events.length;)t.events[k][1].end={..._},k++;return Rs(t.events,C+1,0,t.events.slice(S)),t.events.length=k,c(w)}return a(w)}function c(w){if(r===n.length){if(!i)return f(w);if(i.currentConstruct&&i.currentConstruct.concrete)return g(w);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(_T,u,h)(w)}function u(w){return i&&y(),b(r),f(w)}function h(w){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(w)}function f(w){return t.containerState={},e.attempt(_T,p,g)(w)}function p(w){return r++,n.push([t.currentConstruct,t.containerState]),f(w)}function g(w){if(w===null){i&&y(),b(0),e.consume(w);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),x(w)}function x(w){if(w===null){v(e.exit("chunkFlow"),!0),b(0),e.consume(w);return}return Dt(w)?(e.consume(w),v(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(w),x)}function v(w,S){const C=t.sliceStream(w);if(S&&C.push(null),w.previous=s,s&&(s.next=w),s=w,i.defineSkip(w.start),i.write(C),t.parser.lazy[w.start.line]){let _=i.events.length;for(;_--;)if(i.events[_][1].start.offset<o&&(!i.events[_][1].end||i.events[_][1].end.offset>o))return;const k=t.events.length;let j=k,z,N;for(;j--;)if(t.events[j][0]==="exit"&&t.events[j][1].type==="chunkFlow"){if(z){N=t.events[j][1].end;break}z=!0}for(b(r),_=k;_<t.events.length;)t.events[_][1].end={...N},_++;Rs(t.events,j+1,0,t.events.slice(k)),t.events.length=_}}function b(w){let S=n.length;for(;S-- >w;){const C=n[S];t.containerState=C[1],C[0].exit.call(t,e)}n.length=w}function y(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function S_e(e,t,n){return yn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function hf(e){if(e===null||Vn(e)||ud(e))return 1;if(Vy(e))return 2}function Wy(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const yk={name:"attention",resolveAll:__e,tokenize:C_e};function __e(e,t){let n=-1,r,i,s,o,a,l,c,u;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const h={...e[r][1].end},f={...e[n][1].start};CT(h,-l),CT(f,l),o={type:l>1?"strongSequence":"emphasisSequence",start:h,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=to(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=to(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=to(c,Wy(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=to(c,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,c=to(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,Rs(e,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function C_e(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=hf(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const c=e.exit("attentionSequence"),u=hf(l),h=!u||u===2&&i||n.includes(l),f=!i||i===2&&u||n.includes(r);return c._open=!!(s===42?h:h&&(i||!f)),c._close=!!(s===42?f:f&&(u||!h)),t(l)}}function CT(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const k_e={name:"autolink",tokenize:N_e};function N_e(e,t,n){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return Xi(p)?(e.consume(p),o):p===64?n(p):c(p)}function o(p){return p===43||p===45||p===46||Oi(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||Oi(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||lb(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),u):m_e(p)?(e.consume(p),c):n(p)}function u(p){return Oi(p)?h(p):n(p)}function h(p){return p===46?(e.consume(p),r=0,u):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||Oi(p))&&r++<63){const g=p===45?f:h;return e.consume(p),g}return n(p)}}const i0={partial:!0,tokenize:E_e};function E_e(e,t,n){return r;function r(s){return cn(s)?yn(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||Dt(s)?t(s):n(s)}}const nV={continuation:{tokenize:z_e},exit:M_e,name:"blockQuote",tokenize:j_e};function j_e(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return cn(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function z_e(e,t,n){const r=this;return i;function i(o){return cn(o)?yn(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(nV,t,n)(o)}}function M_e(e){e.exit("blockQuote")}const rV={name:"characterEscape",tokenize:$_e};function $_e(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return v_e(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const iV={name:"characterReference",tokenize:I_e};function I_e(e,t,n){const r=this;let i=0,s,o;return a;function a(h){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),l}function l(h){return h===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(h),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,o=Oi,u(h))}function c(h){return h===88||h===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(h),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=g_e,u):(e.enter("characterReferenceValue"),s=7,o=bk,u(h))}function u(h){if(h===59&&i){const f=e.exit("characterReferenceValue");return o===Oi&&!vj(r.sliceSerialize(f))?n(h):(e.enter("characterReferenceMarker"),e.consume(h),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(h)&&i++<s?(e.consume(h),u):n(h)}}const kT={partial:!0,tokenize:O_e},NT={concrete:!0,name:"codeFenced",tokenize:R_e};function R_e(e,t,n){const r=this,i={partial:!0,tokenize:C};let s=0,o=0,a;return l;function l(_){return c(_)}function c(_){const k=r.events[r.events.length-1];return s=k&&k[1].type==="linePrefix"?k[2].sliceSerialize(k[1],!0).length:0,a=_,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(_)}function u(_){return _===a?(o++,e.consume(_),u):o<3?n(_):(e.exit("codeFencedFenceSequence"),cn(_)?yn(e,h,"whitespace")(_):h(_))}function h(_){return _===null||Dt(_)?(e.exit("codeFencedFence"),r.interrupt?t(_):e.check(kT,x,S)(_)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(_))}function f(_){return _===null||Dt(_)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),h(_)):cn(_)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),yn(e,p,"whitespace")(_)):_===96&&_===a?n(_):(e.consume(_),f)}function p(_){return _===null||Dt(_)?h(_):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(_))}function g(_){return _===null||Dt(_)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),h(_)):_===96&&_===a?n(_):(e.consume(_),g)}function x(_){return e.attempt(i,S,v)(_)}function v(_){return e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),b}function b(_){return s>0&&cn(_)?yn(e,y,"linePrefix",s+1)(_):y(_)}function y(_){return _===null||Dt(_)?e.check(kT,x,S)(_):(e.enter("codeFlowValue"),w(_))}function w(_){return _===null||Dt(_)?(e.exit("codeFlowValue"),y(_)):(e.consume(_),w)}function S(_){return e.exit("codeFenced"),t(_)}function C(_,k,j){let z=0;return N;function N(M){return _.enter("lineEnding"),_.consume(M),_.exit("lineEnding"),I}function I(M){return _.enter("codeFencedFence"),cn(M)?yn(_,$,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):$(M)}function $(M){return M===a?(_.enter("codeFencedFenceSequence"),R(M)):j(M)}function R(M){return M===a?(z++,_.consume(M),R):z>=o?(_.exit("codeFencedFenceSequence"),cn(M)?yn(_,E,"whitespace")(M):E(M)):j(M)}function E(M){return M===null||Dt(M)?(_.exit("codeFencedFence"),k(M)):j(M)}}}function O_e(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Xw={name:"codeIndented",tokenize:T_e},P_e={partial:!0,tokenize:A_e};function T_e(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),yn(e,s,"linePrefix",5)(c)}function s(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?l(c):Dt(c)?e.attempt(P_e,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||Dt(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function A_e(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):Dt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):yn(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):Dt(o)?i(o):n(o)}}const D_e={name:"codeText",previous:F_e,resolve:L_e,tokenize:B_e};function L_e(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function F_e(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function B_e(e,t,n){let r=0,i,s;return o;function o(h){return e.enter("codeText"),e.enter("codeTextSequence"),a(h)}function a(h){return h===96?(e.consume(h),r++,a):(e.exit("codeTextSequence"),l(h))}function l(h){return h===null?n(h):h===32?(e.enter("space"),e.consume(h),e.exit("space"),l):h===96?(s=e.enter("codeTextSequence"),i=0,u(h)):Dt(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(h))}function c(h){return h===null||h===32||h===96||Dt(h)?(e.exit("codeTextData"),l(h)):(e.consume(h),c)}function u(h){return h===96?(e.consume(h),i++,u):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(h)):(s.type="codeTextData",c(h))}}class H_e{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Sp(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Sp(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Sp(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Sp(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Sp(this.left,n.reverse())}}}function Sp(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function sV(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new H_e(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type==="chunkFlow"&&u.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,V_e(u,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=u.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},a=u.slice(i,n),a.unshift(r),u.splice(i,n-i+1,a))}}return Rs(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function V_e(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],c={};let u,h,f=-1,p=n,g=0,x=0;const v=[x];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),h&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),h=p,p=p.next}for(p=n;++f<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(x=f+1,v.push(x),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):v.pop(),f=v.length;f--;){const b=a.slice(v[f],v[f+1]),y=s.pop();l.push([y,y+b.length-1]),e.splice(y,2,b)}for(l.reverse(),f=-1;++f<l.length;)c[g+l[f][0]]=g+l[f][1],g+=l[f][1]-l[f][0]-1;return c}const W_e={resolve:U_e,tokenize:K_e},q_e={partial:!0,tokenize:G_e};function U_e(e){return sV(e),e}function K_e(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):Dt(a)?e.check(q_e,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function G_e(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),yn(e,s,"linePrefix")}function s(o){if(o===null||Dt(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function oV(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return h;function h(b){return b===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(b),e.exit(s),f):b===null||b===32||b===41||lb(b)?n(b):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),x(b))}function f(b){return b===62?(e.enter(s),e.consume(b),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===62?(e.exit("chunkString"),e.exit(a),f(b)):b===null||b===60||Dt(b)?n(b):(e.consume(b),b===92?g:p)}function g(b){return b===60||b===62||b===92?(e.consume(b),p):p(b)}function x(b){return!u&&(b===null||b===41||Vn(b))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(b)):u<c&&b===40?(e.consume(b),u++,x):b===41?(e.consume(b),u--,x):b===null||b===32||b===40||lb(b)?n(b):(e.consume(b),b===92?v:x)}function v(b){return b===40||b===41||b===92?(e.consume(b),x):x(b)}}function aV(e,t,n,r,i,s){const o=this;let a=0,l;return c;function c(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),u}function u(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):Dt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),h(p))}function h(p){return p===null||p===91||p===93||Dt(p)||a++>999?(e.exit("chunkString"),u(p)):(e.consume(p),l||(l=!cn(p)),p===92?f:h)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,h):h(p)}}function lV(e,t,n,r,i,s){let o;return a;function a(f){return f===34||f===39||f===40?(e.enter(r),e.enter(i),e.consume(f),e.exit(i),o=f===40?41:f,l):n(f)}function l(f){return f===o?(e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):(e.enter(s),c(f))}function c(f){return f===o?(e.exit(s),l(o)):f===null?n(f):Dt(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),yn(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===o||f===null||Dt(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?h:u)}function h(f){return f===o||f===92?(e.consume(f),u):u(f)}}function pm(e,t){let n;return r;function r(i){return Dt(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):cn(i)?yn(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Y_e={name:"definition",tokenize:X_e},Z_e={partial:!0,tokenize:J_e};function X_e(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return aV.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Ao(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return Vn(p)?pm(e,c)(p):c(p)}function c(p){return oV(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(Z_e,h,h)(p)}function h(p){return cn(p)?yn(e,f,"whitespace")(p):f(p)}function f(p){return p===null||Dt(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function J_e(e,t,n){return r;function r(a){return Vn(a)?pm(e,i)(a):n(a)}function i(a){return lV(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return cn(a)?yn(e,o,"whitespace")(a):o(a)}function o(a){return a===null||Dt(a)?t(a):n(a)}}const Q_e={name:"hardBreakEscape",tokenize:eCe};function eCe(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return Dt(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const tCe={name:"headingAtx",resolve:nCe,tokenize:rCe};function nCe(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Rs(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function rCe(e,t,n){let r=0;return i;function i(u){return e.enter("atxHeading"),s(u)}function s(u){return e.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(e.consume(u),o):u===null||Vn(u)?(e.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||Dt(u)?(e.exit("atxHeading"),t(u)):cn(u)?yn(e,a,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||Vn(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}const iCe=["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"],ET=["pre","script","style","textarea"],sCe={concrete:!0,name:"htmlFlow",resolveTo:lCe,tokenize:cCe},oCe={partial:!0,tokenize:dCe},aCe={partial:!0,tokenize:uCe};function lCe(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function cCe(e,t,n){const r=this;let i,s,o,a,l;return c;function c(T){return u(T)}function u(T){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(T),h}function h(T){return T===33?(e.consume(T),f):T===47?(e.consume(T),s=!0,x):T===63?(e.consume(T),i=3,r.interrupt?t:O):Xi(T)?(e.consume(T),o=String.fromCharCode(T),v):n(T)}function f(T){return T===45?(e.consume(T),i=2,p):T===91?(e.consume(T),i=5,a=0,g):Xi(T)?(e.consume(T),i=4,r.interrupt?t:O):n(T)}function p(T){return T===45?(e.consume(T),r.interrupt?t:O):n(T)}function g(T){const W="CDATA[";return T===W.charCodeAt(a++)?(e.consume(T),a===W.length?r.interrupt?t:$:g):n(T)}function x(T){return Xi(T)?(e.consume(T),o=String.fromCharCode(T),v):n(T)}function v(T){if(T===null||T===47||T===62||Vn(T)){const W=T===47,L=o.toLowerCase();return!W&&!s&&ET.includes(L)?(i=1,r.interrupt?t(T):$(T)):iCe.includes(o.toLowerCase())?(i=6,W?(e.consume(T),b):r.interrupt?t(T):$(T)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(T):s?y(T):w(T))}return T===45||Oi(T)?(e.consume(T),o+=String.fromCharCode(T),v):n(T)}function b(T){return T===62?(e.consume(T),r.interrupt?t:$):n(T)}function y(T){return cn(T)?(e.consume(T),y):N(T)}function w(T){return T===47?(e.consume(T),N):T===58||T===95||Xi(T)?(e.consume(T),S):cn(T)?(e.consume(T),w):N(T)}function S(T){return T===45||T===46||T===58||T===95||Oi(T)?(e.consume(T),S):C(T)}function C(T){return T===61?(e.consume(T),_):cn(T)?(e.consume(T),C):w(T)}function _(T){return T===null||T===60||T===61||T===62||T===96?n(T):T===34||T===39?(e.consume(T),l=T,k):cn(T)?(e.consume(T),_):j(T)}function k(T){return T===l?(e.consume(T),l=null,z):T===null||Dt(T)?n(T):(e.consume(T),k)}function j(T){return T===null||T===34||T===39||T===47||T===60||T===61||T===62||T===96||Vn(T)?C(T):(e.consume(T),j)}function z(T){return T===47||T===62||cn(T)?w(T):n(T)}function N(T){return T===62?(e.consume(T),I):n(T)}function I(T){return T===null||Dt(T)?$(T):cn(T)?(e.consume(T),I):n(T)}function $(T){return T===45&&i===2?(e.consume(T),P):T===60&&i===1?(e.consume(T),A):T===62&&i===4?(e.consume(T),B):T===63&&i===3?(e.consume(T),O):T===93&&i===5?(e.consume(T),F):Dt(T)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(oCe,V,R)(T)):T===null||Dt(T)?(e.exit("htmlFlowData"),R(T)):(e.consume(T),$)}function R(T){return e.check(aCe,E,V)(T)}function E(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),M}function M(T){return T===null||Dt(T)?R(T):(e.enter("htmlFlowData"),$(T))}function P(T){return T===45?(e.consume(T),O):$(T)}function A(T){return T===47?(e.consume(T),o="",D):$(T)}function D(T){if(T===62){const W=o.toLowerCase();return ET.includes(W)?(e.consume(T),B):$(T)}return Xi(T)&&o.length<8?(e.consume(T),o+=String.fromCharCode(T),D):$(T)}function F(T){return T===93?(e.consume(T),O):$(T)}function O(T){return T===62?(e.consume(T),B):T===45&&i===2?(e.consume(T),O):$(T)}function B(T){return T===null||Dt(T)?(e.exit("htmlFlowData"),V(T)):(e.consume(T),B)}function V(T){return e.exit("htmlFlow"),t(T)}}function uCe(e,t,n){const r=this;return i;function i(o){return Dt(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function dCe(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(i0,t,n)}}const hCe={name:"htmlText",tokenize:fCe};function fCe(e,t,n){const r=this;let i,s,o;return a;function a(O){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(O),l}function l(O){return O===33?(e.consume(O),c):O===47?(e.consume(O),C):O===63?(e.consume(O),w):Xi(O)?(e.consume(O),j):n(O)}function c(O){return O===45?(e.consume(O),u):O===91?(e.consume(O),s=0,g):Xi(O)?(e.consume(O),y):n(O)}function u(O){return O===45?(e.consume(O),p):n(O)}function h(O){return O===null?n(O):O===45?(e.consume(O),f):Dt(O)?(o=h,A(O)):(e.consume(O),h)}function f(O){return O===45?(e.consume(O),p):h(O)}function p(O){return O===62?P(O):O===45?f(O):h(O)}function g(O){const B="CDATA[";return O===B.charCodeAt(s++)?(e.consume(O),s===B.length?x:g):n(O)}function x(O){return O===null?n(O):O===93?(e.consume(O),v):Dt(O)?(o=x,A(O)):(e.consume(O),x)}function v(O){return O===93?(e.consume(O),b):x(O)}function b(O){return O===62?P(O):O===93?(e.consume(O),b):x(O)}function y(O){return O===null||O===62?P(O):Dt(O)?(o=y,A(O)):(e.consume(O),y)}function w(O){return O===null?n(O):O===63?(e.consume(O),S):Dt(O)?(o=w,A(O)):(e.consume(O),w)}function S(O){return O===62?P(O):w(O)}function C(O){return Xi(O)?(e.consume(O),_):n(O)}function _(O){return O===45||Oi(O)?(e.consume(O),_):k(O)}function k(O){return Dt(O)?(o=k,A(O)):cn(O)?(e.consume(O),k):P(O)}function j(O){return O===45||Oi(O)?(e.consume(O),j):O===47||O===62||Vn(O)?z(O):n(O)}function z(O){return O===47?(e.consume(O),P):O===58||O===95||Xi(O)?(e.consume(O),N):Dt(O)?(o=z,A(O)):cn(O)?(e.consume(O),z):P(O)}function N(O){return O===45||O===46||O===58||O===95||Oi(O)?(e.consume(O),N):I(O)}function I(O){return O===61?(e.consume(O),$):Dt(O)?(o=I,A(O)):cn(O)?(e.consume(O),I):z(O)}function $(O){return O===null||O===60||O===61||O===62||O===96?n(O):O===34||O===39?(e.consume(O),i=O,R):Dt(O)?(o=$,A(O)):cn(O)?(e.consume(O),$):(e.consume(O),E)}function R(O){return O===i?(e.consume(O),i=void 0,M):O===null?n(O):Dt(O)?(o=R,A(O)):(e.consume(O),R)}function E(O){return O===null||O===34||O===39||O===60||O===61||O===96?n(O):O===47||O===62||Vn(O)?z(O):(e.consume(O),E)}function M(O){return O===47||O===62||Vn(O)?z(O):n(O)}function P(O){return O===62?(e.consume(O),e.exit("htmlTextData"),e.exit("htmlText"),t):n(O)}function A(O){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),D}function D(O){return cn(O)?yn(e,F,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):F(O)}function F(O){return e.enter("htmlTextData"),o(O)}}const xj={name:"labelEnd",resolveAll:vCe,resolveTo:xCe,tokenize:bCe},pCe={tokenize:yCe},mCe={tokenize:wCe},gCe={tokenize:SCe};function vCe(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&Rs(e,0,e.length,n),e}function xCe(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},u={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",c,t]],a=to(a,e.slice(s+1,s+r+3)),a=to(a,[["enter",u,t]]),a=to(a,Wy(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=to(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=to(a,e.slice(o+1)),a=to(a,[["exit",l,t]]),Rs(e,s,e.length,a),e}function bCe(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(f){return s?s._inactive?h(f):(o=r.parser.defined.includes(Ao(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),l):n(f)}function l(f){return f===40?e.attempt(pCe,u,o?u:h)(f):f===91?e.attempt(mCe,u,o?c:h)(f):o?u(f):h(f)}function c(f){return e.attempt(gCe,u,h)(f)}function u(f){return t(f)}function h(f){return s._balanced=!0,n(f)}}function yCe(e,t,n){return r;function r(h){return e.enter("resource"),e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),i}function i(h){return Vn(h)?pm(e,s)(h):s(h)}function s(h){return h===41?u(h):oV(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(h)}function o(h){return Vn(h)?pm(e,l)(h):u(h)}function a(h){return n(h)}function l(h){return h===34||h===39||h===40?lV(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(h):u(h)}function c(h){return Vn(h)?pm(e,u)(h):u(h)}function u(h){return h===41?(e.enter("resourceMarker"),e.consume(h),e.exit("resourceMarker"),e.exit("resource"),t):n(h)}}function wCe(e,t,n){const r=this;return i;function i(a){return aV.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Ao(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function SCe(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const _Ce={name:"labelStartImage",resolveAll:xj.resolveAll,tokenize:CCe};function CCe(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const kCe={name:"labelStartLink",resolveAll:xj.resolveAll,tokenize:NCe};function NCe(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Jw={name:"lineEnding",tokenize:ECe};function ECe(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),yn(e,t,"linePrefix")}}const Jv={name:"thematicBreak",tokenize:jCe};function jCe(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,a(c)}function a(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||Dt(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),cn(c)?yn(e,a,"whitespace")(c):a(c))}}const ss={continuation:{tokenize:ICe},exit:OCe,name:"list",tokenize:$Ce},zCe={partial:!0,tokenize:PCe},MCe={partial:!0,tokenize:RCe};function $Ce(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(p){const g=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:bk(p)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(Jv,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return bk(p)&&++o<10?(e.consume(p),l):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(i0,r.interrupt?n:u,e.attempt(zCe,f,h))}function u(p){return r.containerState.initialBlankLine=!0,s++,f(p)}function h(p){return cn(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):n(p)}function f(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function ICe(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(i0,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,yn(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!cn(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(MCe,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,yn(e,e.attempt(ss,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function RCe(e,t,n){const r=this;return yn(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function OCe(e){e.exit(this.containerState.type)}function PCe(e,t,n){const r=this;return yn(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!cn(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const jT={name:"setextUnderline",resolveTo:TCe,tokenize:ACe};function TCe(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function ACe(e,t,n){const r=this;let i;return s;function s(c){let u=r.events.length,h;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){h=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||h)?(e.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),cn(c)?yn(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||Dt(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const DCe={tokenize:LCe};function LCe(e){const t=this,n=e.attempt(i0,r,e.attempt(this.parser.constructs.flowInitial,i,yn(e,e.attempt(this.parser.constructs.flow,i,e.attempt(W_e,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const FCe={resolveAll:uV()},BCe=cV("string"),HCe=cV("text");function cV(e){return{resolveAll:uV(e==="text"?VCe:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(u){return c(u)?s(u):a(u)}function a(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),l}function l(u){return c(u)?(n.exit("data"),s(u)):(n.consume(u),l)}function c(u){if(u===null)return!0;const h=i[u];let f=-1;if(h)for(;++f<h.length;){const p=h[f];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function uV(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function VCe(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,a=0,l;for(;s--;){const c=i[s];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(c===-2)l=!0,a++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const c={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const WCe={42:ss,43:ss,45:ss,48:ss,49:ss,50:ss,51:ss,52:ss,53:ss,54:ss,55:ss,56:ss,57:ss,62:nV},qCe={91:Y_e},UCe={[-2]:Xw,[-1]:Xw,32:Xw},KCe={35:tCe,42:Jv,45:[jT,Jv],60:sCe,61:jT,95:Jv,96:NT,126:NT},GCe={38:iV,92:rV},YCe={[-5]:Jw,[-4]:Jw,[-3]:Jw,33:_Ce,38:iV,42:yk,60:[k_e,hCe],91:kCe,92:[Q_e,rV],93:xj,95:yk,96:D_e},ZCe={null:[yk,FCe]},XCe={null:[42,95]},JCe={null:[]},QCe=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:XCe,contentInitial:qCe,disable:JCe,document:WCe,flow:KCe,flowInitial:UCe,insideSpan:ZCe,string:GCe,text:YCe},Symbol.toStringTag,{value:"Module"}));function eke(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:k(C),check:k(_),consume:y,enter:w,exit:S,interrupt:k(_,{interrupt:!0})},c={code:null,containerState:{},defineSkip:x,events:[],now:g,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:h};let u=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function h(I){return o=to(o,I),v(),o[o.length-1]!==null?[]:(j(t,0),c.events=Wy(s,c.events,c),c.events)}function f(I,$){return nke(p(I),$)}function p(I){return tke(o,I)}function g(){const{_bufferIndex:I,_index:$,line:R,column:E,offset:M}=r;return{_bufferIndex:I,_index:$,line:R,column:E,offset:M}}function x(I){i[I.line]=I.column,N()}function v(){let I;for(;r._index<o.length;){const $=o[r._index];if(typeof $=="string")for(I=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===I&&r._bufferIndex<$.length;)b($.charCodeAt(r._bufferIndex));else b($)}}function b(I){u=u(I)}function y(I){Dt(I)?(r.line++,r.column=1,r.offset+=I===-3?2:1,N()):I!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=I}function w(I,$){const R=$||{};return R.type=I,R.start=g(),c.events.push(["enter",R,c]),a.push(R),R}function S(I){const $=a.pop();return $.end=g(),c.events.push(["exit",$,c]),$}function C(I,$){j(I,$.from)}function _(I,$){$.restore()}function k(I,$){return R;function R(E,M,P){let A,D,F,O;return Array.isArray(E)?V(E):"tokenize"in E?V([E]):B(E);function B(q){return X;function X(J){const ae=J!==null&&q[J],ne=J!==null&&q.null,re=[...Array.isArray(ae)?ae:ae?[ae]:[],...Array.isArray(ne)?ne:ne?[ne]:[]];return V(re)(J)}}function V(q){return A=q,D=0,q.length===0?P:T(q[D])}function T(q){return X;function X(J){return O=z(),F=q,q.partial||(c.currentConstruct=q),q.name&&c.parser.constructs.disable.null.includes(q.name)?L():q.tokenize.call($?Object.assign(Object.create(c),$):c,l,W,L)(J)}}function W(q){return I(F,O),M}function L(q){return O.restore(),++D<A.length?T(A[D]):P}}}function j(I,$){I.resolveAll&&!s.includes(I)&&s.push(I),I.resolve&&Rs(c.events,$,c.events.length-$,I.resolve(c.events.slice($),c)),I.resolveTo&&(c.events=I.resolveTo(c.events,c))}function z(){const I=g(),$=c.previous,R=c.currentConstruct,E=c.events.length,M=Array.from(a);return{from:E,restore:P};function P(){r=I,c.previous=$,c.currentConstruct=R,c.events.length=E,a=M,N()}}function N(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function tke(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function nke(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
|
|
914
914
|
`;break}case-3:{o=`\r
|
|
915
915
|
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function rke(e){const r={constructs:eV([QCe,...(e||{}).extensions||[]]),content:i(x_e),defined:[],document:i(y_e),flow:i(DCe),lazy:{},string:i(BCe),text:i(HCe)};return r;function i(s){return o;function o(a){return eke(r,s,a)}}}function ike(e){for(;!sV(e););return e}const zT=/[\0\t\n\r]/g;function ske(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const l=[];let c,u,h,f,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),h=0,t="",n&&(s.charCodeAt(0)===65279&&h++,n=void 0);h<s.length;){if(zT.lastIndex=h,c=zT.exec(s),f=c&&c.index!==void 0?c.index:s.length,p=s.charCodeAt(f),!c){t=s.slice(h);break}if(p===10&&h===f&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),h<f&&(l.push(s.slice(h,f)),e+=f-h),p){case 0:{l.push(65533),e++;break}case 9:{for(u=Math.ceil(e/4)*4,l.push(-2);e++<u;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}h=f+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const oke=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function dV(e){return e.replace(oke,ake)}function ake(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return tV(n.slice(s?2:1),s?16:10)}return vj(n)||e}const hV={}.hasOwnProperty;function lke(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),cke(n)(ike(rke(n).document().write(ske()(e,t,!0))))}function cke(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(fe),autolinkProtocol:z,autolinkEmail:z,atxHeading:s(ge),blockQuote:s(ne),characterEscape:z,characterReference:z,codeFenced:s(re),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(re,o),codeText:s(ie,o),codeTextData:z,data:z,codeFlowValue:z,definition:s(G),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(oe),hardBreakEscape:s(U),hardBreakTrailing:s(U),htmlFlow:s(ce,o),htmlFlowData:z,htmlText:s(ce,o),htmlTextData:z,image:s(ve),label:o,link:s(fe),listItem:s(Pe),listItemValue:f,listOrdered:s(Ce,h),listUnordered:s(Ce),paragraph:s(Ie),reference:T,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(ge),strong:s(Te),thematicBreak:s(Le)},exit:{atxHeading:l(),atxHeadingSequence:C,autolink:l(),autolinkEmail:ae,autolinkProtocol:J,blockQuote:l(),characterEscapeValue:N,characterReferenceMarkerHexadecimal:L,characterReferenceMarkerNumeric:L,characterReferenceValue:q,characterReference:X,codeFenced:l(v),codeFencedFence:x,codeFencedFenceInfo:p,codeFencedFenceMeta:g,codeFlowValue:N,codeIndented:l(b),codeText:l(M),codeTextData:N,data:N,definition:l(),definitionDestinationString:S,definitionLabelString:y,definitionTitleString:w,emphasis:l(),hardBreakEscape:l($),hardBreakTrailing:l($),htmlFlow:l(R),htmlFlowData:N,htmlText:l(E),htmlTextData:N,image:l(A),label:F,labelText:D,lineEnding:I,link:l(P),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:W,resourceDestinationString:O,resourceTitleString:B,resource:V,setextHeading:l(j),setextHeadingLineSequence:k,setextHeadingText:_,strong:l(),thematicBreak:l()}};fV(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(te){let me={type:"root",children:[]};const _e={stack:[me],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},$e=[];let xe=-1;for(;++xe<te.length;)if(te[xe][1].type==="listOrdered"||te[xe][1].type==="listUnordered")if(te[xe][0]==="enter")$e.push(xe);else{const Ze=$e.pop();xe=i(te,Ze,xe)}for(xe=-1;++xe<te.length;){const Ze=t[te[xe][0]];hV.call(Ze,te[xe][1].type)&&Ze[te[xe][1].type].call(Object.assign({sliceSerialize:te[xe][2].sliceSerialize},_e),te[xe][1])}if(_e.tokenStack.length>0){const Ze=_e.tokenStack[_e.tokenStack.length-1];(Ze[1]||MT).call(_e,void 0,Ze[0])}for(me.position={start:jl(te.length>0?te[0][1].start:{line:1,column:1,offset:0}),end:jl(te.length>0?te[te.length-2][1].end:{line:1,column:1,offset:0})},xe=-1;++xe<t.transforms.length;)me=t.transforms[xe](me)||me;return me}function i(te,me,_e){let $e=me-1,xe=-1,Ze=!1,le,Me,pe,ye;for(;++$e<=_e;){const Ee=te[$e];switch(Ee[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ee[0]==="enter"?xe++:xe--,ye=void 0;break}case"lineEndingBlank":{Ee[0]==="enter"&&(le&&!ye&&!xe&&!pe&&(pe=$e),ye=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ye=void 0}if(!xe&&Ee[0]==="enter"&&Ee[1].type==="listItemPrefix"||xe===-1&&Ee[0]==="exit"&&(Ee[1].type==="listUnordered"||Ee[1].type==="listOrdered")){if(le){let Se=$e;for(Me=void 0;Se--;){const De=te[Se];if(De[1].type==="lineEnding"||De[1].type==="lineEndingBlank"){if(De[0]==="exit")continue;Me&&(te[Me][1].type="lineEndingBlank",Ze=!0),De[1].type="lineEnding",Me=Se}else if(!(De[1].type==="linePrefix"||De[1].type==="blockQuotePrefix"||De[1].type==="blockQuotePrefixWhitespace"||De[1].type==="blockQuoteMarker"||De[1].type==="listItemIndent"))break}pe&&(!Me||pe<Me)&&(le._spread=!0),le.end=Object.assign({},Me?te[Me][1].start:Ee[1].end),te.splice(Me||$e,0,["exit",le,Ee[2]]),$e++,_e++}if(Ee[1].type==="listItemPrefix"){const Se={type:"listItem",_spread:!1,start:Object.assign({},Ee[1].start),end:void 0};le=Se,te.splice($e,0,["enter",Se,Ee[2]]),$e++,_e++,pe=void 0,ye=!0}}}return te[me][1]._spread=Ze,_e}function s(te,me){return _e;function _e($e){a.call(this,te($e),$e),me&&me.call(this,$e)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(te,me,_e){this.stack[this.stack.length-1].children.push(te),this.stack.push(te),this.tokenStack.push([me,_e||void 0]),te.position={start:jl(me.start),end:void 0}}function l(te){return me;function me(_e){te&&te.call(this,_e),c.call(this,_e)}}function c(te,me){const _e=this.stack.pop(),$e=this.tokenStack.pop();if($e)$e[0].type!==te.type&&(me?me.call(this,te,$e[0]):($e[1]||MT).call(this,te,$e[0]));else throw new Error("Cannot close `"+te.type+"` ("+fm({start:te.start,end:te.end})+"): it’s not open");_e.position.end=jl(te.end)}function u(){return gj(this.stack.pop())}function h(){this.data.expectingFirstListItemValue=!0}function f(te){if(this.data.expectingFirstListItemValue){const me=this.stack[this.stack.length-2];me.start=Number.parseInt(this.sliceSerialize(te),10),this.data.expectingFirstListItemValue=void 0}}function p(){const te=this.resume(),me=this.stack[this.stack.length-1];me.lang=te}function g(){const te=this.resume(),me=this.stack[this.stack.length-1];me.meta=te}function x(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){const te=this.resume(),me=this.stack[this.stack.length-1];me.value=te.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function b(){const te=this.resume(),me=this.stack[this.stack.length-1];me.value=te.replace(/(\r?\n|\r)$/g,"")}function y(te){const me=this.resume(),_e=this.stack[this.stack.length-1];_e.label=me,_e.identifier=Ao(this.sliceSerialize(te)).toLowerCase()}function w(){const te=this.resume(),me=this.stack[this.stack.length-1];me.title=te}function S(){const te=this.resume(),me=this.stack[this.stack.length-1];me.url=te}function C(te){const me=this.stack[this.stack.length-1];if(!me.depth){const _e=this.sliceSerialize(te).length;me.depth=_e}}function _(){this.data.setextHeadingSlurpLineEnding=!0}function k(te){const me=this.stack[this.stack.length-1];me.depth=this.sliceSerialize(te).codePointAt(0)===61?1:2}function j(){this.data.setextHeadingSlurpLineEnding=void 0}function z(te){const _e=this.stack[this.stack.length-1].children;let $e=_e[_e.length-1];(!$e||$e.type!=="text")&&($e=de(),$e.position={start:jl(te.start),end:void 0},_e.push($e)),this.stack.push($e)}function N(te){const me=this.stack.pop();me.value+=this.sliceSerialize(te),me.position.end=jl(te.end)}function I(te){const me=this.stack[this.stack.length-1];if(this.data.atHardBreak){const _e=me.children[me.children.length-1];_e.position.end=jl(te.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(me.type)&&(z.call(this,te),N.call(this,te))}function $(){this.data.atHardBreak=!0}function R(){const te=this.resume(),me=this.stack[this.stack.length-1];me.value=te}function E(){const te=this.resume(),me=this.stack[this.stack.length-1];me.value=te}function M(){const te=this.resume(),me=this.stack[this.stack.length-1];me.value=te}function P(){const te=this.stack[this.stack.length-1];if(this.data.inReference){const me=this.data.referenceType||"shortcut";te.type+="Reference",te.referenceType=me,delete te.url,delete te.title}else delete te.identifier,delete te.label;this.data.referenceType=void 0}function A(){const te=this.stack[this.stack.length-1];if(this.data.inReference){const me=this.data.referenceType||"shortcut";te.type+="Reference",te.referenceType=me,delete te.url,delete te.title}else delete te.identifier,delete te.label;this.data.referenceType=void 0}function D(te){const me=this.sliceSerialize(te),_e=this.stack[this.stack.length-2];_e.label=dV(me),_e.identifier=Ao(me).toLowerCase()}function F(){const te=this.stack[this.stack.length-1],me=this.resume(),_e=this.stack[this.stack.length-1];if(this.data.inReference=!0,_e.type==="link"){const $e=te.children;_e.children=$e}else _e.alt=me}function O(){const te=this.resume(),me=this.stack[this.stack.length-1];me.url=te}function B(){const te=this.resume(),me=this.stack[this.stack.length-1];me.title=te}function V(){this.data.inReference=void 0}function T(){this.data.referenceType="collapsed"}function W(te){const me=this.resume(),_e=this.stack[this.stack.length-1];_e.label=me,_e.identifier=Ao(this.sliceSerialize(te)).toLowerCase(),this.data.referenceType="full"}function L(te){this.data.characterReferenceType=te.type}function q(te){const me=this.sliceSerialize(te),_e=this.data.characterReferenceType;let $e;_e?($e=tV(me,_e==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):$e=vj(me);const xe=this.stack[this.stack.length-1];xe.value+=$e}function X(te){const me=this.stack.pop();me.position.end=jl(te.end)}function J(te){N.call(this,te);const me=this.stack[this.stack.length-1];me.url=this.sliceSerialize(te)}function ae(te){N.call(this,te);const me=this.stack[this.stack.length-1];me.url="mailto:"+this.sliceSerialize(te)}function ne(){return{type:"blockquote",children:[]}}function re(){return{type:"code",lang:null,meta:null,value:""}}function ie(){return{type:"inlineCode",value:""}}function G(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function oe(){return{type:"emphasis",children:[]}}function ge(){return{type:"heading",depth:0,children:[]}}function U(){return{type:"break"}}function ce(){return{type:"html",value:""}}function ve(){return{type:"image",title:null,url:"",alt:null}}function fe(){return{type:"link",title:null,url:"",children:[]}}function Ce(te){return{type:"list",ordered:te.type==="listOrdered",start:null,spread:te._spread,children:[]}}function Pe(te){return{type:"listItem",spread:te._spread,checked:null,children:[]}}function Ie(){return{type:"paragraph",children:[]}}function Te(){return{type:"strong",children:[]}}function de(){return{type:"text",value:""}}function Le(){return{type:"thematicBreak"}}}function jl(e){return{line:e.line,column:e.column,offset:e.offset}}function fV(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?fV(e,r):uke(e,r)}}function uke(e,t){let n;for(n in t)if(hV.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function MT(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+fm({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+fm({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+fm({start:t.start,end:t.end})+") is still open")}function cb(e){const t=this;t.parser=n;function n(r){return lke(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function dke(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function hke(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -957,7 +957,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
957
957
|
`),i;function s(o){return r.stack.push(o),a;function a(){r.stack.pop()}}}function oEe(e){throw new Error("Cannot handle value `"+e+"`, expected node")}function aEe(e){const t=e;throw new Error("Cannot handle unknown node `"+t.type+"`")}function lEe(e,t){if(e.type==="definition"&&e.type===t.type)return 0}function cEe(e,t){return XNe(e,this,t)}function uEe(e,t){return JNe(e,this,t)}function dEe(e,t){return nEe(this,e,t)}function hEe(){return{enter:{table:fEe,tableData:QT,tableHeader:QT,tableRow:mEe},exit:{codeText:gEe,table:pEe,tableData:uS,tableHeader:uS,tableRow:uS}}}function fEe(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function pEe(e){this.exit(e),this.data.inTable=void 0}function mEe(e){this.enter({type:"tableRow",children:[]},e)}function uS(e){this.exit(e)}function QT(e){this.enter({type:"tableCell",children:[]},e)}function gEe(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,vEe));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function vEe(e,t){return t==="|"?t:e}function xEe(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
958
958
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:o,tableCell:l,tableRow:a}};function o(p,g,x,v){return c(u(p,x,v),p.align)}function a(p,g,x,v){const b=h(p,x,v),y=c([b]);return y.slice(0,y.indexOf(`
|
|
959
959
|
`))}function l(p,g,x,v){const b=x.enter("tableCell"),y=x.enter("phrasing"),w=x.containerPhrasing(p,{...v,before:s,after:s});return y(),b(),w}function c(p,g){return hNe(p,{align:g,alignDelimiters:r,padding:n,stringLength:i})}function u(p,g,x){const v=p.children;let b=-1;const y=[],w=g.enter("table");for(;++b<v.length;)y[b]=h(v[b],g,x);return w(),y}function h(p,g,x){const v=p.children;let b=-1;const y=[],w=g.enter("tableRow");for(;++b<v.length;)y[b]=l(v[b],p,g,x);return w(),y}function f(p,g,x){let v=Ej.inlineCode(p,g,x);return x.stack.includes("tableCell")&&(v=v.replace(/\|/g,"\\$&")),v}}function bEe(){return{exit:{taskListCheckValueChecked:eA,taskListCheckValueUnchecked:eA,paragraph:wEe}}}function yEe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:SEe}}}function eA(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function wEe(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function SEe(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=Ej.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function _Ee(){return[P2e(),nNe(),oNe(),hEe(),bEe()]}function CEe(e){return{extensions:[T2e(),rNe(e),aNe(),xEe(e),yEe()]}}const kEe={tokenize:$Ee,partial:!0},BV={tokenize:IEe,partial:!0},HV={tokenize:REe,partial:!0},VV={tokenize:OEe,partial:!0},NEe={tokenize:PEe,partial:!0},WV={name:"wwwAutolink",tokenize:zEe,previous:UV},qV={name:"protocolAutolink",tokenize:MEe,previous:KV},wl={name:"emailAutolink",tokenize:jEe,previous:GV},Ea={};function EEe(){return{text:Ea}}let Jc=48;for(;Jc<123;)Ea[Jc]=wl,Jc++,Jc===58?Jc=65:Jc===91&&(Jc=97);Ea[43]=wl;Ea[45]=wl;Ea[46]=wl;Ea[95]=wl;Ea[72]=[wl,qV];Ea[104]=[wl,qV];Ea[87]=[wl,WV];Ea[119]=[wl,WV];function jEe(e,t,n){const r=this;let i,s;return o;function o(h){return!Nk(h)||!GV.call(r,r.previous)||jj(r.events)?n(h):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(h))}function a(h){return Nk(h)?(e.consume(h),a):h===64?(e.consume(h),l):n(h)}function l(h){return h===46?e.check(NEe,u,c)(h):h===45||h===95||Oi(h)?(s=!0,e.consume(h),l):u(h)}function c(h){return e.consume(h),i=!0,l}function u(h){return s&&i&&Xi(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(h)):n(h)}}function zEe(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!UV.call(r,r.previous)||jj(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(kEe,e.attempt(BV,e.attempt(HV,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function MEe(e,t,n){const r=this;let i="",s=!1;return o;function o(h){return(h===72||h===104)&&KV.call(r,r.previous)&&!jj(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(h),e.consume(h),a):n(h)}function a(h){if(Xi(h)&&i.length<5)return i+=String.fromCodePoint(h),e.consume(h),a;if(h===58){const f=i.toLowerCase();if(f==="http"||f==="https")return e.consume(h),l}return n(h)}function l(h){return h===47?(e.consume(h),s?c:(s=!0,l)):n(h)}function c(h){return h===null||lb(h)||Vn(h)||ud(h)||Vy(h)?n(h):e.attempt(BV,e.attempt(HV,u),n)(h)}function u(h){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(h)}}function $Ee(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function IEe(e,t,n){let r,i,s;return o;function o(c){return c===46||c===95?e.check(VV,l,a)(c):c===null||Vn(c)||ud(c)||c!==45&&Vy(c)?l(c):(s=!0,e.consume(c),o)}function a(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),o}function l(c){return i||r||!s?n(c):t(c)}}function REe(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(VV,t,s)(o):o===null||Vn(o)||ud(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function OEe(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||Vn(a)||ud(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||Vn(a)||ud(a)?t(a):r(a)}function s(a){return Xi(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):Xi(a)?(e.consume(a),o):n(a)}}function PEe(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return Oi(s)?n(s):t(s)}}function UV(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Vn(e)}function KV(e){return!Xi(e)}function GV(e){return!(e===47||Nk(e))}function Nk(e){return e===43||e===45||e===46||e===95||Oi(e)}function jj(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const TEe={tokenize:WEe,partial:!0};function AEe(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:BEe,continuation:{tokenize:HEe},exit:VEe}},text:{91:{name:"gfmFootnoteCall",tokenize:FEe},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:DEe,resolveTo:LEe}}}}function DEe(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const c=Ao(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function LEe(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function FEe(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(h){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),l}function l(h){return h!==94?n(h):(e.enter("gfmFootnoteCallMarker"),e.consume(h),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(h){if(s>999||h===93&&!o||h===null||h===91||Vn(h))return n(h);if(h===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return i.includes(Ao(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(h),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(h)}return Vn(h)||(o=!0),s++,e.consume(h),h===92?u:c}function u(h){return h===91||h===92||h===93?(e.consume(h),s++,c):c(h)}}function BEe(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(g){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(g){return g===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(g)}function u(g){if(o>999||g===93&&!a||g===null||g===91||Vn(g))return n(g);if(g===93){e.exit("chunkString");const x=e.exit("gfmFootnoteDefinitionLabelString");return s=Ao(r.sliceSerialize(x)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(g),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return Vn(g)||(a=!0),o++,e.consume(g),g===92?h:u}function h(g){return g===91||g===92||g===93?(e.consume(g),o++,u):u(g)}function f(g){return g===58?(e.enter("definitionMarker"),e.consume(g),e.exit("definitionMarker"),i.includes(s)||i.push(s),yn(e,p,"gfmFootnoteDefinitionWhitespace")):n(g)}function p(g){return t(g)}}function HEe(e,t,n){return e.check(i0,t,e.attempt(TEe,t,n))}function VEe(e){e.exit("gfmFootnoteDefinition")}function WEe(e,t,n){const r=this;return yn(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function qEe(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},h={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},f=[["enter",u,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",h,a]],p=a.parser.constructs.insideSpan.null;p&&Rs(f,f.length,0,Wy(p,o.slice(c+1,l),a)),Rs(f,f.length,0,[["exit",h,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",u,a]]),Rs(o,c-1,l-c+3,f),l=c+f.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const c=this.previous,u=this.events;let h=0;return f;function f(g){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(g):(o.enter("strikethroughSequenceTemporary"),p(g))}function p(g){const x=hf(c);if(g===126)return h>1?l(g):(o.consume(g),h++,p);if(h<2&&!n)return l(g);const v=o.exit("strikethroughSequenceTemporary"),b=hf(g);return v._open=!b||b===2&&!!x,v._close=!x||x===2&&!!b,a(g)}}}class UEe{constructor(){this.map=[],this.index=new Map}add(t,n,r){KEe(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0,this.index.clear()}}function KEe(e,t,n,r){if(n===0&&r.length===0)return;const i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}const s=[t,n,r];e.map.push(s),e.index.set(t,s)}function GEe(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function YEe(){return{flow:{null:{name:"table",tokenize:ZEe,resolveAll:XEe}}}}function ZEe(e,t,n){const r=this;let i=0,s=0,o;return a;function a(N){let I=r.events.length-1;for(;I>-1;){const{type:E}=r.events[I][1];if(E==="lineEnding"||E==="linePrefix")I--;else break}const $=I>-1?r.events[I][1].type:null,R=$==="tableHead"||$==="tableRow"?_:l;return R===_&&r.parser.lazy[r.now().line]?n(N):R(N)}function l(N){return e.enter("tableHead"),e.enter("tableRow"),c(N)}function c(N){return N===124||(o=!0,s+=1),u(N)}function u(N){return N===null?n(N):Dt(N)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),p):n(N):cn(N)?yn(e,u,"whitespace")(N):(s+=1,o&&(o=!1,i+=1),N===124?(e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),o=!0,u):(e.enter("data"),h(N)))}function h(N){return N===null||N===124||Vn(N)?(e.exit("data"),u(N)):(e.consume(N),N===92?f:h)}function f(N){return N===92||N===124?(e.consume(N),h):h(N)}function p(N){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(N):(e.enter("tableDelimiterRow"),o=!1,cn(N)?yn(e,g,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(N):g(N))}function g(N){return N===45||N===58?v(N):N===124?(o=!0,e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),x):C(N)}function x(N){return cn(N)?yn(e,v,"whitespace")(N):v(N)}function v(N){return N===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(N),e.exit("tableDelimiterMarker"),b):N===45?(s+=1,b(N)):N===null||Dt(N)?S(N):C(N)}function b(N){return N===45?(e.enter("tableDelimiterFiller"),y(N)):C(N)}function y(N){return N===45?(e.consume(N),y):N===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(N),e.exit("tableDelimiterMarker"),w):(e.exit("tableDelimiterFiller"),w(N))}function w(N){return cn(N)?yn(e,S,"whitespace")(N):S(N)}function S(N){return N===124?g(N):N===null||Dt(N)?!o||i!==s?C(N):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(N)):C(N)}function C(N){return n(N)}function _(N){return e.enter("tableRow"),k(N)}function k(N){return N===124?(e.enter("tableCellDivider"),e.consume(N),e.exit("tableCellDivider"),k):N===null||Dt(N)?(e.exit("tableRow"),t(N)):cn(N)?yn(e,k,"whitespace")(N):(e.enter("data"),j(N))}function j(N){return N===null||N===124||Vn(N)?(e.exit("data"),k(N)):(e.consume(N),N===92?z:j)}function z(N){return N===92||N===124?(e.consume(N),j):j(N)}}function XEe(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,u,h;const f=new UEe;for(;++n<e.length;){const p=e[n],g=p[1];p[0]==="enter"?g.type==="tableHead"?(a=!1,l!==0&&(tA(f,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},g.start),end:Object.assign({},g.end)},f.add(n,0,[["enter",c,t]])):g.type==="tableRow"||g.type==="tableDelimiterRow"?(r=!0,h=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,u={type:"tableBody",start:Object.assign({},g.start),end:Object.assign({},g.end)},f.add(n,0,[["enter",u,t]])),i=g.type==="tableDelimiterRow"?2:u?3:1):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],h=fv(f,t,s,i,void 0,h),s=[0,0,0,0]),o[2]=n)):g.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],h=fv(f,t,s,i,void 0,h)),s=o,o=[s[1],n,0,0])):g.type==="tableHead"?(a=!0,l=n):g.type==="tableRow"||g.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],h=fv(f,t,s,i,n,h)):o[1]!==0&&(h=fv(f,t,o,i,n,h)),i=0):i&&(g.type==="data"||g.type==="tableDelimiterMarker"||g.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&tA(f,t,l,c,u),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=GEe(t.events,n))}return e}function fv(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},Zd(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=Zd(t.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=Zd(t.events,n[2]),u=Zd(t.events,n[3]),h={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",h,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const g=n[2]+1,x=n[3]-n[2]-1;e.add(g,x,[])}}e.add(n[3]+1,0,[["exit",h,t]])}return i!==void 0&&(s.end=Object.assign({},Zd(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function tA(e,t,n,r,i){const s=[],o=Zd(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function Zd(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const JEe={name:"tasklistCheck",tokenize:eje};function QEe(){return{text:{91:JEe}}}function eje(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return Vn(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return Dt(l)?t(l):cn(l)?e.check({tokenize:tje},t,n)(l):n(l)}}function tje(e,t,n){return yn(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function nje(e){return eV([EEe(),AEe(),qEe(e),YEe(),QEe()])}const rje={};function YV(e){const t=this,n=e||rje,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(nje(n)),s.push(_Ee()),o.push(CEe(n))}function ije(e){_V(e,[/\r?\n|\r/g,sje])}function sje(){return{type:"break"}}function oje(){return function(e){ije(e)}}const aje=new Set(["code","pre","a"]),lje=/[\u3000-\u303f\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff00-\uffef]/;function cje(e){const t=[];let n="";const r=()=>{n&&(t.push(n),n="")};for(const i of e){if(i===`
|
|
960
|
-
`){r(),t.push(i);continue}if(lje.test(i)){r(),t.push(i);continue}n+=i}return r(),t}function uje(e){return{type:"element",tagName:"span",properties:{className:["ui-tw-unit"]},children:[{type:"text",value:e}]}}function ZV(e,t){if(!Array.isArray(e.children))return;const n=t||e.type==="element"&&aje.has(e.tagName??""),r=[];for(const i of e.children){if(i.type==="text"&&typeof i.value=="string"&&!n&&i.value.trim()){for(const s of cje(i.value))r.push(uje(s));continue}ZV(i,n),r.push(i)}e.children=r}function dje(){return e=>{ZV(e,!1)}}function zj(e){if(!e||e.startsWith("#")||e.startsWith("//")||/^(?!file:)[a-z][a-z\d+.-]*:/i.test(e))return;let t=e;if(/^file:/i.test(t))try{const r=new URL(t);if(r.protocol!=="file:"||r.hostname&&r.hostname!=="localhost")return;t=decodeURIComponent(r.pathname)}catch{return}else try{t=decodeURIComponent(t.split(/[?#]/,1)[0])}catch{return}const n=t.slice(t.lastIndexOf("/")+1);if(/\.[^/.]+:\d+(?::\d+)?$/.test(n)&&(t=t.replace(/:\d+(?::\d+)?$/,"")),!(!t||t.includes("\0")||t.startsWith("/api/")||t.startsWith("/sessions/")))return t}function XV(e,t){var s;const n=(s=zj(e))==null?void 0:s.replace(/\\/g,"/");if(!n)return;const r=t.replace(/\\/g,"/").replace(/\/$/,"");if(n.startsWith("/"))return!r||!n.startsWith(`${r}/`)?void 0:n.slice(r.length+1);const i=[];for(const o of n.split("/"))if(!(!o||o==="."))if(o===".."){if(!i.length)return;i.pop()}else i.push(o);return i.join("/")||void 0}function hje(e,t){const n=zj(e);return XV(e,t)??(n!=null&&n.startsWith("/")?n:void 0)}const fje=m.lazy(()=>w4(()=>import("./ImageLightbox-
|
|
960
|
+
`){r(),t.push(i);continue}if(lje.test(i)){r(),t.push(i);continue}n+=i}return r(),t}function uje(e){return{type:"element",tagName:"span",properties:{className:["ui-tw-unit"]},children:[{type:"text",value:e}]}}function ZV(e,t){if(!Array.isArray(e.children))return;const n=t||e.type==="element"&&aje.has(e.tagName??""),r=[];for(const i of e.children){if(i.type==="text"&&typeof i.value=="string"&&!n&&i.value.trim()){for(const s of cje(i.value))r.push(uje(s));continue}ZV(i,n),r.push(i)}e.children=r}function dje(){return e=>{ZV(e,!1)}}function zj(e){if(!e||e.startsWith("#")||e.startsWith("//")||/^(?!file:)[a-z][a-z\d+.-]*:/i.test(e))return;let t=e;if(/^file:/i.test(t))try{const r=new URL(t);if(r.protocol!=="file:"||r.hostname&&r.hostname!=="localhost")return;t=decodeURIComponent(r.pathname)}catch{return}else try{t=decodeURIComponent(t.split(/[?#]/,1)[0])}catch{return}const n=t.slice(t.lastIndexOf("/")+1);if(/\.[^/.]+:\d+(?::\d+)?$/.test(n)&&(t=t.replace(/:\d+(?::\d+)?$/,"")),!(!t||t.includes("\0")||t.startsWith("/api/")||t.startsWith("/sessions/")))return t}function XV(e,t){var s;const n=(s=zj(e))==null?void 0:s.replace(/\\/g,"/");if(!n)return;const r=t.replace(/\\/g,"/").replace(/\/$/,"");if(n.startsWith("/"))return!r||!n.startsWith(`${r}/`)?void 0:n.slice(r.length+1);const i=[];for(const o of n.split("/"))if(!(!o||o==="."))if(o===".."){if(!i.length)return;i.pop()}else i.push(o);return i.join("/")||void 0}function hje(e,t){const n=zj(e);return XV(e,t)??(n!=null&&n.startsWith("/")?n:void 0)}const fje=m.lazy(()=>w4(()=>import("./ImageLightbox-6D7xjwqD.js"),__vite__mapDeps([0,1,2,3,4]))),pje=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".svg"]);function mje(e,t){var r;if(!e||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")||e.startsWith("/api/"))return e;const n=(r=e.split(".").pop())==null?void 0:r.toLowerCase();if(n&&pje.has(`.${n}`)&&t&&e.includes(".agentdock/uploads")){const i=e.split(/[/\\]/).pop();if(i)return`/api/sessions/${t}/uploads/${i}`}return e}const gje={csharp:"csharp",cs:"csharp",html:"markup",js:"javascript",jsx:"jsx",md:"markdown",py:"python",rb:"ruby",rs:"rust",sh:"bash",shell:"bash",ts:"typescript",tsx:"tsx",xml:"markup",yml:"yaml",zsh:"bash"};function vje(e){var r,i;const t=((i=(r=/(?:^|\s)language-([\w-]+)/.exec(e??""))==null?void 0:r[1])==null?void 0:i.toLowerCase())??"",n=gje[t]??t;return{language:n&&NG.languages[n]?n:"plain",label:t||"text"}}function JV(e,t){return!!(e!=null&&e.includes("language-")||String(t).includes(`
|
|
961
961
|
`))}const QV=m.memo(function({code:t,className:n}){const{language:r,label:i}=vje(n),s=OH()==="dark",[o,a]=m.useState(!1);hZ(()=>a(!1),o?1500:void 0);const l=async()=>{var c;try{if((c=navigator.clipboard)!=null&&c.writeText)await navigator.clipboard.writeText(t);else{const u=document.createElement("textarea");u.value=t,u.style.position="fixed",u.style.opacity="0",document.body.appendChild(u),u.select(),document.execCommand("copy"),document.body.removeChild(u)}a(!0)}catch{a(!1)}};return d.jsxs("div",{className:"code-renderer group/code my-4 overflow-hidden rounded-[10px] border border-zinc-200 bg-[rgb(var(--code-bg))] [contain:layout_paint]",children:[d.jsxs("div",{className:"flex h-8 items-center px-3",children:[d.jsx("span",{className:"font-mono text-[12px] text-zinc-500",children:i}),d.jsxs("button",{type:"button",onClick:()=>void l(),className:"ml-auto flex h-6 items-center gap-1.5 rounded-md px-2 text-[12px] font-medium text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400/50","aria-label":o?"代码已复制":"复制代码",children:[o?d.jsx(gi,{size:12}):d.jsx(a3,{size:12}),d.jsx("span",{children:o?"已复制":"复制"})]})]}),d.jsx(kG,{theme:s?$M.vsDark:$M.vsLight,code:t,language:r,children:({className:c,style:u,tokens:h,getLineProps:f,getTokenProps:p})=>d.jsx("pre",{className:`${c} code-renderer-scroll m-0 overflow-x-auto px-4 pb-3.5 pt-1 text-[13px] leading-6`,style:{...u,backgroundColor:"transparent"},children:d.jsx("code",{children:h.map((g,x)=>d.jsx("span",{...f({line:g}),className:"block min-h-6",children:g.map((v,b)=>d.jsx("span",{...p({token:v})},b))},x))})})})]})});function xje({src:e,alt:t}){const[n,r]=m.useState(!1),[i,s]=m.useState(!1);return d.jsxs(d.Fragment,{children:[d.jsx("img",{src:e,alt:t??"",loading:"lazy",onClick:()=>{r(!0),s(!0)},className:"my-2 max-h-40 w-auto max-w-full cursor-zoom-in object-contain transition-shadow hover:shadow-md"}),n&&d.jsx(m.Suspense,{fallback:null,children:d.jsx(fje,{src:e,alt:t,open:i,onClose:()=>s(!1)})})]})}const eW={a({href:e,children:t}){return d.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-link underline decoration-[#2563eb]/40 underline-offset-2 hover:decoration-[#2563eb]",children:t})},code({className:e,children:t}){return JV(e,t)?d.jsx(QV,{className:e,code:String(t).replace(/\n$/,"")}):d.jsx("code",{className:"rounded bg-zinc-100 px-[.32rem] py-[.12rem] font-mono text-[.9em] text-zinc-800",children:t})},pre({children:e}){return d.jsx(d.Fragment,{children:e})},table({children:e}){return d.jsx("div",{className:"markdown-table-scroll",children:d.jsx("table",{children:e})})}},bje={...eW,code({className:e,children:t}){return JV(e,t)?d.jsx(QV,{className:e,code:String(t).replace(/\n$/,"")}):/^\/[^\s]+$/.test(String(t))?d.jsx("code",{className:"ui-slash-command",children:t}):d.jsx("code",{className:"rounded bg-zinc-100 px-[.32rem] py-[.12rem] font-mono text-[.9em] text-zinc-800",children:t})}},vh=m.memo(function({children:t,sessionId:n,throttleMs:r,animateUnits:i=!1,highlightSlashCommands:s=!1}){const o=dZ(t,{wait:r??0}),a=r?o:t,l={...s?bje:eW,a({href:c,children:u}){const h=c?zj(c):void 0;return h&&n?d.jsx("button",{type:"button",title:h,onClick:()=>{const f=Js.getState();f.openTab({id:`preview:${f.primarySessionId}:${n}:${h}`,kind:"files",anchorSessionId:n,filePath:h,title:h.split("/").at(-1)||"文件"})},className:"font-medium text-link underline decoration-[#2563eb]/40 underline-offset-2 hover:decoration-[#2563eb]",children:u}):d.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-link underline decoration-[#2563eb]/40 underline-offset-2 hover:decoration-[#2563eb]",children:u})},img({src:c,alt:u}){const h=mje(c??"",n);return h?d.jsx(xje,{src:h,alt:u??""}):null}};return d.jsx(E2e,{remarkPlugins:[YV,oje],rehypePlugins:i?[dje]:[],urlTransform:c=>/^file:/i.test(c)?c:SV(c),components:l,children:a})}),tW={baseCharsPerSecond:14,catchUpSeconds:3,drainSeconds:.9},yje=.1,wje=40;function Sje(e,t,n,r,i=tW){if(e>=t)return t;const s=t-e,a=(r?i.baseCharsPerSecond+s/Math.max(.1,i.catchUpSeconds):s/Math.max(.05,i.drainSeconds))*Math.max(0,Math.min(yje,n));return Math.min(t,e+(r?a:Math.max(1,a)))}function _je(e){var n;if(!e)return e;const t=kje(e);if(t.openStart>=0){const r=((n=/^\s*(`{3,}|~{3,})/.exec(e.slice(t.openStart)))==null?void 0:n[1])??"```";return`${e}
|
|
962
962
|
${r}`}return zje(Nje(Eje(e,t.ranges)),t.ranges)}function Cje(e,t){return _je(e.slice(0,Math.max(0,Math.min(t,e.length))))}function kje(e){const t=[];let n=0,r=-1;for(;n<e.length;){const i=e.indexOf(`
|
|
963
963
|
`,n),s=i===-1?e.length:i,o=e.slice(n,s);if(/^\s*(`{3,}|~{3,})/.test(o)&&(r<0?r=n:/^\s*(`{3,}|~{3,})\s*$/.test(o)&&(t.push({start:r,end:s+1}),r=-1)),i===-1)break;n=i+1}return{ranges:t,openStart:r}}function nW(e,t){if(t.length===0)return e;const n=e.split("");for(const r of t)for(let i=r.start;i<Math.min(r.end,n.length);i+=1)n[i]=" ";return n.join("")}function Nje(e){const t=e.split(`
|
|
@@ -1113,7 +1113,7 @@ ${e.raw??JSON.stringify(e.data,null,2)??""}`}function a3e({sessionId:e,active:t=
|
|
|
1113
1113
|
2. …
|
|
1114
1114
|
3. …`,multiline:!0},{key:"期望结果",label:"期望结果",placeholder:"正确时应该发生什么",multiline:!0},{key:"错误日志",label:"错误日志 / 堆栈(可选)",placeholder:"粘贴完整堆栈,不要截断",multiline:!0,optional:!0}]},{id:"builtin-review",title:"代码审查",description:"按清单审查 diff,给出带文件行号的发现",icon:"review",body:X3e,builtin:!0,fields:[{key:"审查范围",label:"审查范围",placeholder:"例如:git diff main...HEAD",defaultValue:"git diff main...HEAD"},{key:"重点关注",label:"重点关注(可选)",placeholder:"例如:并发、鉴权、错误处理",defaultValue:"正确性、边界条件、回归风险",optional:!0}]},{id:"builtin-test",title:"补测试",description:"为目标模块补齐关键路径和边界用例",icon:"test",body:J3e,builtin:!0,fields:[{key:"目标模块",label:"目标模块 / 文件",placeholder:"例如:packages/storage/src/index.ts",multiline:!0},{key:"测试命令",label:"测试命令",defaultValue:"pnpm test"},{key:"重点场景",label:"重点场景(可选)",placeholder:"例如:空输入、并发写入、失败重试",defaultValue:"正常路径、边界条件、错误路径",optional:!0}]},{id:"builtin-onboarding",title:"项目上手",description:"先画出代码地图,再做一次最小验证",icon:"compass",body:Q3e,builtin:!0,fields:[{key:"想了解的问题",label:"想了解什么",placeholder:"例如:一次请求从入口到存储经过了哪些模块?",multiline:!0},{key:"关注目录",label:"关注目录(可选)",placeholder:"例如:apps/server/src",defaultValue:"整个仓库",optional:!0}]}];function jM(e){const t=new Set,n=[];for(const r of e.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)){const i=r[1].trim();!i||t.has(i)||(t.add(i),n.push({key:i,label:i,multiline:!0}))}return n}function yG(e,t){return e.body.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{var s;const i=r.trim();return((s=t[i])==null?void 0:s.trim())||`{{${i}}}`})}function tLe(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];const n=[],r=new Set;for(const i of t){if(!i||typeof i!="object")continue;const s=i;if(typeof s.id!="string"||!s.id.trim()||r.has(s.id)||typeof s.title!="string"||!s.title.trim()||typeof s.body!="string"||!s.body.trim())continue;const o=s.title.trim().slice(0,kM),a=typeof s.description=="string"&&s.description.trim()?s.description.trim().slice(0,NM):"自定义提示词模板",l=s.body.slice(0,EM);if(r.add(s.id),n.push({id:s.id,title:o,description:a,body:l,icon:"custom",builtin:!1,fields:jM(l)}),n.length>=K3e)break}return n}function nLe(e){return JSON.stringify(e.map(t=>({id:t.id,title:t.title.slice(0,kM),description:t.description.slice(0,NM),body:t.body.slice(0,EM)})))}function rLe(e,t){const n=e.title.trim().slice(0,kM),r=e.body.trim().slice(0,EM);if(!n)throw new Error("模板名称不能为空");if(!r)throw new Error("模板内容不能为空");return{id:t??`custom_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,title:n,description:e.description.trim().slice(0,NM)||"自定义提示词模板",icon:"custom",body:r,builtin:!1,fields:jM(r)}}function A5(){try{return tLe(window.localStorage.getItem(CM))}catch{return[]}}function iLe(e){try{window.localStorage.setItem(CM,nLe(e))}catch{}}const sLe={repeat:bL,sparkles:Lo,bug:jZ,review:sX,test:j3,compass:IZ,custom:DZ};function oLe({onUse:e}){const[t,n]=m.useState(()=>A5()),[r,i]=m.useState();m.useEffect(()=>{const a=l=>{l.key===CM&&n(A5())};return window.addEventListener("storage",a),()=>window.removeEventListener("storage",a)},[]);const s=a=>{n(a),iLe(a)},o=a=>{const l=Object.fromEntries(a.fields.map(c=>[c.key,c.defaultValue??""]));e(yG(a,l))};return d.jsxs("section",{"aria-label":"提示词模板",className:"mt-4",children:[d.jsxs("div",{className:"mb-2 flex items-center gap-1.5 px-0.5 text-[12px] font-medium text-zinc-500",children:[d.jsx(M_,{size:12}),d.jsx("span",{children:"提示词模板"}),d.jsx("span",{className:"ml-auto font-normal text-zinc-400",children:"点卡片直接填入,右上角可填写变量"})]}),d.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3",children:[[...eLe,...t].map(a=>{const l=sLe[a.icon],c=a.fields.length>0;return d.jsxs("div",{className:"group relative h-full",children:[d.jsxs("button",{type:"button",onClick:()=>o(a),title:"点击直接填入输入框",className:`flex h-full min-h-[78px] w-full flex-col rounded-xl border border-zinc-200 bg-white px-3 py-2.5 text-left transition-[border-color,box-shadow,transform] duration-150 ease-[cubic-bezier(.2,0,0,1)] hover:-translate-y-px hover:border-zinc-300 hover:shadow-[0_4px_14px_rgba(24,24,27,.06)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400/50 ${a.builtin?c?"pr-8":"":"pr-14"}`,children:[d.jsxs("span",{className:"flex w-full items-center gap-1.5 pr-5 text-[12px] font-medium text-zinc-800",children:[d.jsx(l,{size:13,className:"shrink-0 text-zinc-400"}),d.jsx("span",{className:"truncate",children:a.title})]}),d.jsx("span",{className:"mt-1 line-clamp-2 block text-[12px] leading-[1.5] text-zinc-500",children:a.description})]}),c&&d.jsx("button",{type:"button",onClick:()=>i({kind:"fill",template:a}),"aria-label":`填写模板变量:${a.title}`,title:"填写变量并预览最终文案",className:`absolute top-1.5 grid h-6 w-6 place-items-center rounded-md text-zinc-400 opacity-100 transition-opacity hover:bg-zinc-100 hover:text-zinc-700 focus-visible:opacity-100 sm:opacity-0 sm:group-hover:opacity-100 ${a.builtin?"right-1.5":"right-8"}`,children:d.jsx(lX,{size:11})}),!a.builtin&&d.jsx("button",{type:"button",onClick:()=>i({kind:"edit",template:a}),"aria-label":`编辑模板:${a.title}`,title:"编辑模板",className:"absolute right-1.5 top-1.5 grid h-6 w-6 place-items-center rounded-md text-zinc-400 opacity-100 transition-opacity hover:bg-zinc-100 hover:text-zinc-700 focus-visible:opacity-100 sm:opacity-0 sm:group-hover:opacity-100",children:d.jsx(fN,{size:11})})]},a.id)}),d.jsxs("button",{type:"button",onClick:()=>i({kind:"edit"}),className:"flex min-h-[78px] w-full flex-col items-center justify-center gap-1 rounded-xl border border-dashed border-zinc-300 px-3 py-2.5 text-[12px] text-zinc-500 transition-colors hover:border-zinc-400 hover:bg-zinc-50 hover:text-zinc-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400/50",children:[d.jsx(sa,{size:14}),d.jsx("span",{children:"新建模板"})]})]}),r&&d.jsx(aLe,{state:r,onClose:()=>i(void 0),onApply:a=>{i(void 0),e(a)},onSave:a=>{s(t.some(l=>l.id===a.id)?t.map(l=>l.id===a.id?a:l):[...t,a]),i(void 0)},onDelete:a=>{s(t.filter(l=>l.id!==a)),i(void 0)}})]})}function aLe({state:e,onClose:t,onApply:n,onSave:r,onDelete:i}){const s=m.useRef(null);Vo({panel:s,initial:s,dismissible:!0,onDismiss:t});const o=e.kind==="edit",a=o?e.template?"编辑模板":"新建模板":e.template.title;return d.jsx("div",{className:"ui-overlay fixed inset-0 z-[60] grid place-items-center bg-zinc-950/30 p-2 sm:p-4",children:d.jsxs("div",{ref:s,role:"dialog","aria-modal":"true","aria-label":a,className:"ui-dialog flex max-h-[88dvh] w-full max-w-xl flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-[0_24px_80px_rgba(24,24,27,.2)]",children:[d.jsxs("div",{className:"flex h-12 shrink-0 items-center gap-3 border-b border-zinc-100 px-4",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("div",{className:"truncate text-[15px] font-semibold text-zinc-900",children:a}),!o&&d.jsx("div",{className:"truncate text-[12px] text-zinc-400",children:e.template.description})]}),d.jsx("button",{type:"button",onClick:t,"aria-label":"关闭",className:"ml-auto grid h-8 w-8 shrink-0 place-items-center rounded-lg text-zinc-400 hover:bg-zinc-100 hover:text-zinc-800",children:d.jsx(Wn,{size:16})})]}),o?d.jsx(cLe,{template:e.template,onClose:t,onSave:r,onDelete:i}):d.jsx(lLe,{template:e.template,onClose:t,onApply:n})]})})}function lLe({template:e,onClose:t,onApply:n}){const[r,i]=m.useState(()=>Object.fromEntries(e.fields.map(a=>[a.key,a.defaultValue??""]))),s=m.useMemo(()=>yG(e,r),[e,r]),o=a=>{a.preventDefault(),n(s)};return d.jsxs("form",{onSubmit:o,className:"flex min-h-0 flex-1 flex-col",children:[d.jsxs("div",{className:"min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-3",children:[e.fields.map((a,l)=>d.jsxs("label",{className:"block",children:[d.jsx("span",{className:"mb-1.5 flex items-center gap-1 text-[12px] font-medium text-zinc-600",children:a.label}),a.multiline?d.jsx("textarea",{autoFocus:l===0,value:r[a.key]??"",onChange:c=>i(u=>({...u,[a.key]:c.target.value})),rows:3,placeholder:a.placeholder,className:"ui-field w-full resize-y rounded-lg border border-zinc-200 bg-white px-3 py-2 text-[13px] leading-5 text-zinc-800 outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-400"}):d.jsx("input",{autoFocus:l===0,value:r[a.key]??"",onChange:c=>i(u=>({...u,[a.key]:c.target.value})),placeholder:a.placeholder,spellCheck:!1,className:"ui-field h-9 w-full rounded-lg border border-zinc-200 bg-white px-3 text-[13px] text-zinc-800 outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-400"})]},a.key)),e.fields.length===0&&d.jsx("p",{className:"text-[12px] text-zinc-400",children:"这个模板没有变量,会直接填入输入框。"}),d.jsxs("div",{children:[d.jsxs("div",{className:"mb-1.5 flex items-center gap-1.5 text-[12px] font-medium text-zinc-600",children:[d.jsx(Bg,{size:12,className:"text-zinc-400"}),"最终文案预览"]}),d.jsx("pre",{"aria-label":"最终文案预览",className:"max-h-44 overflow-y-auto whitespace-pre-wrap break-words rounded-lg border border-zinc-200 bg-zinc-50 px-3 py-2 font-sans text-[12px] leading-5 text-zinc-600",children:s}),d.jsxs("p",{className:"mt-1 text-[12px] text-zinc-400",children:["变量留空会保留 ","{{变量}}"," 占位,填入后仍可在输入框里修改。"]})]})]}),d.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t border-zinc-100 px-4 py-3",children:[d.jsx("button",{type:"button",onClick:t,className:"rounded-lg px-3 py-1.5 text-[12px] text-zinc-600 hover:bg-zinc-100",children:"取消"}),d.jsx("button",{type:"submit",className:"rounded-lg bg-zinc-900 px-3.5 py-1.5 text-[12px] font-medium text-white transition-colors hover:bg-zinc-800",children:"填入输入框"})]})]})}function cLe({template:e,onClose:t,onSave:n,onDelete:r}){const[i,s]=m.useState((e==null?void 0:e.title)??""),[o,a]=m.useState((e==null?void 0:e.description)??""),[l,c]=m.useState((e==null?void 0:e.body)??""),[u,h]=m.useState(),[f,p]=m.useState(!1),g=m.useMemo(()=>jM(l).map(v=>v.key),[l]),x=v=>{v.preventDefault();try{n(rLe({title:i,description:o,body:l},e==null?void 0:e.id))}catch(b){h(b instanceof Error?b.message:String(b))}};return d.jsxs("form",{onSubmit:x,className:"flex min-h-0 flex-1 flex-col",children:[d.jsxs("div",{className:"min-h-0 flex-1 space-y-3 overflow-y-auto px-4 py-3",children:[d.jsxs("label",{className:"block",children:[d.jsxs("span",{className:"mb-1.5 flex items-center gap-1 text-[12px] font-medium text-zinc-600",children:["模板名称",d.jsx("span",{className:"text-red-500",children:"*"})]}),d.jsx("input",{autoFocus:!0,value:i,onChange:v=>s(v.target.value),maxLength:40,placeholder:"例如:发布前检查",className:"ui-field h-9 w-full rounded-lg border border-zinc-200 bg-white px-3 text-[13px] text-zinc-800 outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-400"})]}),d.jsxs("label",{className:"block",children:[d.jsx("span",{className:"mb-1.5 block text-[12px] font-medium text-zinc-600",children:"一句话说明"}),d.jsx("input",{value:o,onChange:v=>a(v.target.value),maxLength:120,placeholder:"显示在卡片上,可留空",className:"ui-field h-9 w-full rounded-lg border border-zinc-200 bg-white px-3 text-[13px] text-zinc-800 outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-400"})]}),d.jsxs("label",{className:"block",children:[d.jsxs("span",{className:"mb-1.5 flex items-center gap-1 text-[12px] font-medium text-zinc-600",children:["模板内容",d.jsx("span",{className:"text-red-500",children:"*"})]}),d.jsx("textarea",{value:l,onChange:v=>c(v.target.value),rows:8,placeholder:`直接写完整提示词。用 {{变量名}} 标记需要每次填写的内容。
|
|
1115
1115
|
|
|
1116
|
-
例如:请检查 {{项目}} 的发布前状态,并运行 {{验证命令}}。`,className:"ui-field w-full resize-y rounded-lg border border-zinc-200 bg-white px-3 py-2 font-mono text-[12px] leading-5 text-zinc-800 outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-400"})]}),d.jsx("div",{className:"text-[12px] leading-5 text-zinc-500",children:g.length?d.jsxs(d.Fragment,{children:["识别到变量:",d.jsx("span",{className:"font-mono text-zinc-700",children:g.join("、")})]}):"没有 {{变量}},点击卡片会直接填入整段提示词。"}),u&&d.jsx("p",{role:"alert",className:"text-[12px] text-red-600",children:u})]}),d.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-t border-zinc-100 px-4 py-3",children:[e&&d.jsxs("button",{type:"button",onClick:()=>{if(!f){p(!0);return}r(e.id)},className:"flex items-center gap-1 rounded-lg px-2.5 py-1.5 text-[12px] text-red-600 hover:bg-red-50",children:[d.jsx(kf,{size:12}),f?"确认删除":"删除"]}),d.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded-lg px-3 py-1.5 text-[12px] text-zinc-600 hover:bg-zinc-100",children:"取消"}),d.jsx("button",{type:"submit",disabled:!i.trim()||!l.trim(),className:"rounded-lg bg-zinc-900 px-3.5 py-1.5 text-[12px] font-medium text-white transition-colors hover:bg-zinc-800 disabled:cursor-not-allowed disabled:opacity-40",children:"保存模板"})]})]})}function uLe({agents:e,sessions:t,onCreated:n,editorRef:r,hero:i,collapsed:s=!1,companion:o}){var X,J,ae,ne,re,ie,G,oe,ge;const a=Ln(),[l,c]=m.useState(""),[u,h]=m.useState([]),[f,p]=m.useState(""),[g,x]=m.useState(""),[v,b]=m.useState(""),[y,w]=m.useState(""),[S,C]=m.useState(),[_,k]=m.useState(!1),j=m.useRef(new Map),z=m.useRef(new Set),N=m.useRef(0),I=e.some(U=>U.id===f)?f:((X=t.find(U=>!U.archivedAt&&e.some(ce=>ce.id===U.agentId)))==null?void 0:X.agentId)||((J=e[0])==null?void 0:J.id)||"",$=e.find(U=>U.id===I),R=Et({queryKey:["system-capabilities"],queryFn:we.systemCapabilities}),E=($==null?void 0:$.cwd)||((ae=R.data)==null?void 0:ae.workingDirectory),M=m.useMemo(()=>{const U=new Set,ce=[];for(const ve of[E,...t.map(fe=>fe.cwd)])!ve||U.has(ve)||(U.add(ve),ce.push(ve));return ce.slice(0,30)},[E,t]),P=(ne=R.data)==null?void 0:ne.homeDirectory,A=Et({queryKey:ul(I,v),queryFn:()=>dl(I,v||void 0),enabled:!!I,initialData:()=>Cd(I,v||void 0),initialDataUpdatedAt:0,refetchOnMount:"always",staleTime:6e4}),D=Et({queryKey:["skills",g],queryFn:()=>we.skills(g||void 0),staleTime:6e4}),F=yt({mutationFn:()=>dl(I,v||void 0,!0),onSuccess:U=>a.setQueryData(ul(I,v||void 0),U),onError:U=>C(U instanceof Error?U.message:String(U))}),O=yt({mutationFn:we.selectDirectory,onSuccess:U=>x(U.path),onError:U=>C(U instanceof Error?U.message:String(U))}),B=wK({loaded:A.data!==void 0,loading:A.data===void 0&&(A.isPending||A.isFetching||F.isPending),switching:!1,failed:A.data===void 0&&A.isError}),V=async U=>{const ce=`draft-${++N.current}`,ve="name"in U?U.name:"(未命名文件)",fe=U.type.startsWith("image/");U instanceof File&&j.current.set(ce,U);const Ce=fe?URL.createObjectURL(U):void 0;return Ce&&z.current.add(Ce),{id:ce,kind:fe?"image":"file",label:ve,value:ce,...Ce?{url:Ce}:{}}},T=()=>{for(const U of z.current)URL.revokeObjectURL(U);z.current.clear(),j.current.clear()},W=U=>{c(U),requestAnimationFrame(()=>{var ce;return(ce=r==null?void 0:r.current)==null?void 0:ce.focus()})},L=U=>{const ce=l,ve=u,fe=p2();k(!0),(async()=>{try{const Ce=await Promise.all(ve.map(async Ie=>{const Te=j.current.get(Ie.id);if(!Te)return Ie;const de=await d2(U.sessionId,Te);return h2(de,Te.type.startsWith("image/"))})),Pe=u2(ce,Ce);Pe&&await we.send(U.sessionId,Pe,"queue",void 0,fe),a.invalidateQueries({queryKey:["sessions"]}),a.invalidateQueries({queryKey:["tasks",U.sessionId]}),c(""),h([]),T(),U.onSent()}catch(Ce){C(Ce instanceof Error?Ce.message:String(Ce))}finally{k(!1)}})()},q=()=>{if(_)return;if(C(void 0),o){L(o);return}if(!I)return;const U=l,ce=u,ve=p2();k(!0),(async()=>{let fe;try{fe=await we.create({agentId:I,...g.trim()?{cwd:g.trim()}:{},...v?{model:v}:{},...y?{reasoningEffort:y}:{}});const Ce=await Promise.all(ce.map(async Ie=>{const Te=j.current.get(Ie.id);if(!Te)return Ie;const de=await d2(fe.id,Te);return h2(de,Te.type.startsWith("image/"))})),Pe=u2(U,Ce);Pe&&await we.send(fe.id,Pe,"queue",void 0,ve),a.invalidateQueries({queryKey:["sessions"]}),a.invalidateQueries({queryKey:["tasks",fe.id]}),c(""),h([]),T(),n(fe)}catch(Ce){C(Ce instanceof Error?Ce.message:String(Ce)),fe&&(a.invalidateQueries({queryKey:["sessions"]}),n(fe))}finally{k(!1)}})()};return d.jsxs("div",{className:"relative my-auto w-full max-w-[720px]",children:[i??d.jsxs("div",{className:"flex flex-col items-center text-center",children:[d.jsx(U3e,{size:88}),d.jsx("h1",{className:"ui-empty-state ui-hero-title mt-4 text-[22px] font-semibold tracking-[-.02em]",children:"有什么要做的?"})]}),d.jsx("div",{className:"ui-collapse","data-collapsed":s||void 0,"aria-hidden":s||void 0,inert:s,children:d.jsxs("div",{children:[d.jsx("div",{className:"mt-6",children:d.jsx(CK,{draft:!0,...o?{placeholder:d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"hidden sm:inline",children:["跟",o.name,"说说要做什么,Enter 发送;它会派侧边会话去办"]}),d.jsxs("span",{className:"sm:hidden",children:["跟",o.name,"说说要做什么"]})]}),sendLabel:`交给${o.name}`,lockedTarget:d.jsxs("span",{title:`消息会发进主会话,由${o.name}安排`,className:"flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-zinc-100 px-2.5 text-[12px] font-medium text-zinc-700",children:[d.jsx(Ji,{size:12}),o.name," · 主会话"]})}:{},editorRef:r,sessionId:"",state:"idle",value:l,references:u,sending:_,mode:"queue",queuedTasks:[],skills:D.data??[],models:((re=A.data)==null?void 0:re.models)??[],reasoningEfforts:((ie=A.data)==null?void 0:ie.reasoningEfforts)??[],currentModel:v||((G=A.data)==null?void 0:G.defaultModel),currentReasoningEffort:y||((oe=A.data)==null?void 0:oe.defaultReasoningEffort),context:{},advertisedCommands:[],modelReadiness:B,switchingModel:!1,switchingReasoningEffort:!1,refreshingModels:A.isFetching||F.isPending,agents:e,currentAgentId:(o==null?void 0:o.agentId)??I,onAgentChange:U=>{p(U),b(""),w("")},workspace:g,onWorkspaceChange:x,workspaceSuggestion:E,homeDirectory:P,workspaceOptions:M,directoryPickerAvailable:(ge=R.data)==null?void 0:ge.directoryPicker,pickingDirectory:O.isPending,onPickDirectory:()=>O.mutate(),onAttachFile:V,onChange:c,onReferencesChange:h,onModeChange:()=>{},onSubmit:q,onInterrupt:()=>{},onCancelQueued:()=>{},onSteerQueued:()=>{},onEditQueued:()=>{},onModelChange:b,onReasoningEffortChange:w,onRefreshModels:()=>F.mutate()})}),!o&&d.jsx(oLe,{onUse:W}),S&&d.jsx("p",{role:"alert",className:"mt-2 text-center text-[12px] text-red-600",children:S}),u.length>0&&d.jsxs("p",{className:"mt-2 text-center text-[12px] text-zinc-400",children:[u.length," 个附件会在",o?"发送":"会话创建","后上传"]})]})})]})}const wG="agentdock:adopt-agent";function dLe(){try{return typeof window>"u"?"":window.localStorage.getItem(wG)||""}catch{return""}}function hLe(e,t){const n=e instanceof Error?e.message:String(e);return/authentication required|not authenticated|unauthorized|\b401\b/i.test(n)?`${t} 还没在这台机器上登录,暂时开不了工。换一个已登录的 Agent,或先在终端完成 ${t} 的登录再回来认领。`:n}function D5(){const e=d.jsxs("svg",{viewBox:"0 0 24 24",width:"11",height:"11",fill:"currentColor","aria-hidden":"true",children:[d.jsx("ellipse",{cx:"12",cy:"16",rx:"5",ry:"4.2"}),d.jsx("circle",{cx:"6",cy:"9.5",r:"2.2"}),d.jsx("circle",{cx:"10",cy:"6",r:"2.2"}),d.jsx("circle",{cx:"14",cy:"6",r:"2.2"}),d.jsx("circle",{cx:"18",cy:"9.5",r:"2.2"})]});return d.jsxs("span",{className:"ui-paw-walk",children:[e,e,e,e]})}function L5(e){const t=M7();return e.counts.needsUser?`${t}~有 ${e.counts.needsUser} 件事等你拍板,右边的便签里看看吧`:e.counts.planned?`${t}~有 ${e.counts.planned} 张计划等你点头,右边的便签里看看`:e.busy?`${t}~我正在忙,有新想法也可以先丢给我`:e.counts.running?`${t}~我在盯着 ${e.counts.running} 张便签,有进展会叫你`:e.counts.review?`${t}~${e.counts.review} 张便签做完了,我在验收`:`${t}~我是${e.name},有事交给我,我派人去办`}function fLe({value:e,name:t,onChange:n}){return d.jsxs("div",{className:"ui-target mt-4","data-value":e,role:"group","aria-label":"这条消息发给谁",children:[d.jsx("span",{className:"ui-target-pill","aria-hidden":"true"}),d.jsxs("button",{type:"button","aria-pressed":e==="new",onClick:()=>n("new"),className:"ui-target-option",children:[d.jsx(ZZ,{size:13}),"新对话"]}),d.jsxs("button",{type:"button","aria-pressed":e==="companion",onClick:()=>n("companion"),className:"ui-target-option ui-cat-hover-host",children:[d.jsx(Ji,{size:13}),d.jsxs("span",{className:"max-w-[9rem] truncate",children:["交给",t]})]})]})}function pLe({agents:e,sessions:t,editorRef:n,onCreated:r}){var Ce,Pe,Ie,Te,de,Le,te,me,_e,$e,xe,Ze;const i=Ln(),s=Hi(),o=Na(),a=zt(le=>le.adoptPending),l=zt(le=>le.inviteDismissed),c=zt(le=>le.homeTarget),u=zt(le=>le.celebrateNonce),[h,f]=m.useState("idle"),[p,g]=m.useState(Up),[x,v]=m.useState(dLe),[b,y]=m.useState(""),[w,S]=m.useState(""),[C,_]=m.useState(""),[k,j]=m.useState(),[z,N]=m.useState(),[I,$]=m.useState(""),R=gh("kitten-hero"),E=m.useRef(null),M=m.useRef(null),P=Et({queryKey:["system-capabilities"],queryFn:we.systemCapabilities});m.useEffect(()=>{!a||!s.loaded||(zt.getState().consumeAdoption(),s.adopted||f("form"))},[a,s.loaded,s.adopted]),m.useEffect(()=>{if(h!=="form")return;const le=window.setTimeout(()=>{var Me,pe;(Me=E.current)==null||Me.focus(),(pe=E.current)==null||pe.select()},260);return()=>window.clearTimeout(le)},[h]),m.useEffect(()=>{if(!z)return;const le=window.setTimeout(()=>N(void 0),1800);return()=>window.clearTimeout(le)},[z]);const A=m.useMemo(()=>e.filter(le=>!le.disabled),[e]),D=A.some(le=>le.id===x)?x:((Ce=t.find(le=>!le.archivedAt&&A.some(Me=>Me.id===le.agentId)))==null?void 0:Ce.agentId)||((Pe=A[0])==null?void 0:Pe.id)||"",F=A.find(le=>le.id===D),O=(F==null?void 0:F.cwd)||((Ie=P.data)==null?void 0:Ie.workingDirectory),B=(Te=P.data)==null?void 0:Te.homeDirectory,V=m.useMemo(()=>{const le=new Set,Me=[];for(const pe of[O,...t.map(ye=>ye.cwd)])!pe||le.has(pe)||(le.add(pe),Me.push(pe));return Me.slice(0,20)},[O,t]),T=Et({queryKey:ul(D,w),queryFn:()=>dl(D,w||void 0),enabled:!!D&&(h==="form"||h==="adopting"),initialData:()=>Cd(D,w||void 0),initialDataUpdatedAt:0,refetchOnMount:"always",staleTime:6e4});m.useEffect(()=>{S(""),_("")},[D]);const W=((Le=(de=T.data)==null?void 0:de.models.find(le=>{var Me;return le.id===((Me=T.data)==null?void 0:Me.defaultModel)}))==null?void 0:Le.name)??((te=T.data)==null?void 0:te.defaultModel),L=((_e=(me=T.data)==null?void 0:me.reasoningEfforts.find(le=>{var Me;return le.id===((Me=T.data)==null?void 0:Me.defaultReasoningEffort)}))==null?void 0:_e.name)??(($e=T.data)==null?void 0:$e.defaultReasoningEffort),q=m.useMemo(()=>{var le;return(le=T.data)!=null&&le.models.length?[{value:"",label:W?`Agent 默认 · ${W}`:"Agent 默认"},...T.data.models.map(Me=>({value:Me.id,label:Me.name,meta:Me.name===Me.id?void 0:Me.id}))]:[]},[W,T.data]),X=m.useMemo(()=>{var le;return(le=T.data)!=null&&le.reasoningEfforts.length?[{value:"",label:L?`Agent 默认 · ${L}`:"Agent 默认"},...T.data.reasoningEfforts.map(Me=>({value:Me.id,label:Me.name}))]:[]},[L,T.data]),J=T.isPending||T.isFetching,ae=yt({mutationFn:we.selectDirectory,onSuccess:le=>{y(le.path),j(void 0)},onError:le=>j(le instanceof Error?le.message:String(le))}),ne=yt({mutationFn:()=>we.assistantSetMain({agentId:D,name:p.trim()||Up,...b.trim()?{cwd:b.trim()}:{},...w?{model:w}:{},...C?{reasoningEffort:C}:{}}),onMutate:()=>{j(void 0),f("adopting")},onSuccess:le=>{var ye;try{window.localStorage.setItem(wG,D)}catch{}const Me=((ye=le.companion)==null?void 0:ye.name)??(p.trim()||Up);$(Me),i.setQueryData(["assistant-state"],Ee=>Ee&&{...Ee,mainSessionId:le.session.id,mainSession:le.session,companion:le.companion??{name:Me,adoptedAt:new Date().toISOString()}}),i.setQueryData(["sessions"],Ee=>Ee&&[le.session,...Ee.filter(Se=>Se.id!==le.session.id)]),i.invalidateQueries({queryKey:["assistant-state"]}),i.invalidateQueries({queryKey:["sessions"]});const pe=zt.getState();pe.dismissInvite(!1),pe.celebrate(),f("celebrate"),window.setTimeout(()=>{M.current&&jc(M.current.getBoundingClientRect(),"confetti",18)},120),window.setTimeout(()=>o.openMain(le.session.id),co()?900:2300)},onError:le=>{f("form"),j(hLe(le,(F==null?void 0:F.name)??D))}}),re=()=>{const le=b.trim();if(le&&!le.startsWith("/")){j("工作目录请填绝对路径,例如 /Users/you/project");return}ne.mutate()},ie=()=>{zt.getState().dismissInvite(),N("sad"),f("idle")},G=s.adopted&&h!=="celebrate",oe=G&&c==="companion"&&!!s.mainId,ge=!s.adopted&&s.loaded&&(h==="invite"||h==="idle"&&!l),U=h==="form"||h==="adopting"||h==="celebrate",ce=z??(h==="celebrate"?"happy":h==="adopting"?"busy":G?s.mood==="curious"?"idle":s.mood:"curious"),ve=d.jsx("div",{ref:R,className:"ui-stage-kitten",children:d.jsx(Fi,{size:h==="form"||h==="adopting"?76:88,mood:ce,stage:G?s.stage:void 0,collar:G||h==="celebrate",drawCollar:h==="celebrate",track:!0,typingAware:!0,celebrateKey:u,viewTransitionName:E7,label:G?`进入主会话(${s.name})`:"小猫",onClick:()=>{G?o.openMain():h==="idle"&&f("invite")}})});let fe;if(G){const le=s.counts;fe=d.jsxs("div",{className:"ui-stage",children:[d.jsx("div",{className:"ui-speech text-center",children:L5(s)},L5(s)),ve,d.jsx("span",{className:"ui-name-tag",children:s.name}),d.jsxs("div",{className:"mt-3 flex flex-wrap justify-center gap-1.5",children:[le.needsUser>0&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().openDrawer({filter:"needs_user"}),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-needs"}),le.needsUser," 件需要你"]}),le.planned>0&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().openDrawer({filter:"needs_user"}),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-plan"}),le.planned," 张计划等你点头"]}),le.review>0&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().openDrawer({filter:"review"}),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-review"}),le.review," 张待验收"]}),le.running>0&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().openDrawer({filter:"running"}),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-running"}),le.running," 张进行中"]}),!le.open&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().toggleDrawer(),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-done"}),le.closed?`${le.closed} 张已完成`:"便签墙"]})]}),d.jsx("h1",{className:"ui-empty-state ui-hero-title mt-5 text-[22px] font-semibold tracking-[-.02em]",children:oe?`交给${s.name}吧`:"有什么要做的?"}),d.jsx(fLe,{value:c,name:s.name,onChange:Me=>{zt.getState().setHomeTarget(Me),requestAnimationFrame(()=>{var pe;return(pe=n==null?void 0:n.current)==null?void 0:pe.focus()})}})]})}else fe=d.jsxs("div",{className:"ui-stage",children:[ge&&d.jsxs("div",{className:"ui-speech text-center",children:[d.jsx("p",{className:"text-[14px] font-medium text-zinc-900",children:"喵~带我回家吧?"}),d.jsx("p",{className:"mt-0.5 text-[12.5px] leading-5 text-zinc-500",children:"认领后我就是你的主会话:你说要做什么,我派侧边会话去干、盯进度、做完帮你验收,每件事都贴成便签。"}),d.jsxs("div",{className:"mt-2.5 flex justify-center gap-2",children:[d.jsxs("button",{type:"button",onClick:()=>f("form"),className:"inline-flex h-8 items-center gap-1.5 rounded-full bg-zinc-900 px-3.5 text-[12.5px] font-medium text-white transition-[background-color,transform] hover:bg-zinc-700 active:scale-95",children:[d.jsx(Ji,{size:13}),"认领它"]}),d.jsx("button",{type:"button",onClick:ie,className:"inline-flex h-8 items-center rounded-full px-3 text-[12.5px] text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-800",children:"先不了"})]})]}),h==="celebrate"&&d.jsxs("div",{className:"ui-speech text-center",children:[d.jsxs("p",{className:"text-[14px] font-medium text-zinc-900",children:["喵!我是",I,",以后请多指教~"]}),d.jsxs("p",{className:"mt-1 inline-flex items-center gap-1.5 text-[12px] text-zinc-500",children:[d.jsx(D5,{}),"正在去主会话…"]})]}),ve,h==="celebrate"&&d.jsx("span",{className:"ui-name-tag",children:I}),(h==="form"||h==="adopting")&&d.jsx("div",{ref:M,className:"ui-adopt-card mt-4",children:d.jsxs("form",{onSubmit:le=>{le.preventDefault(),!ne.isPending&&D&&re()},children:[d.jsxs("div",{className:"px-5 pt-5",children:[d.jsxs("label",{className:"block",children:[d.jsx("span",{className:"text-[14px] font-semibold text-zinc-900",children:"给它起个名字"}),d.jsxs("span",{className:"mt-2 flex items-center gap-2",children:[d.jsx("input",{ref:E,value:p,maxLength:16,disabled:h==="adopting",onChange:le=>g(le.target.value),placeholder:Up,"aria-label":"小猫的名字",className:"ui-field h-10 min-w-0 flex-1 rounded-xl border border-zinc-300 bg-white px-3 text-[15px] font-semibold text-zinc-900 outline-none placeholder:font-normal placeholder:text-zinc-400 disabled:opacity-60"}),d.jsx("button",{type:"button",disabled:h==="adopting",onClick:()=>g(le=>Fy(le.trim())),"aria-label":"随机换一个名字",title:"随机换一个名字",className:"ui-dice grid h-10 w-10 shrink-0 place-items-center rounded-xl border border-zinc-200 text-zinc-500 hover:border-zinc-300 hover:text-zinc-900 disabled:opacity-50",children:d.jsx(Fb,{size:17})})]})]}),d.jsx("div",{className:"mt-4 text-[12.5px] font-medium text-zinc-600",children:"它用哪个 Agent 思考"}),d.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[A.map(le=>d.jsxs("button",{type:"button",disabled:h==="adopting","aria-pressed":le.id===D,onClick:()=>{v(le.id),S(""),_(""),j(void 0)},className:"ui-pill-choice",children:[d.jsx(Hr,{agentId:le.id,agentName:le.name,size:13}),le.name]},le.id)),!A.length&&d.jsx("span",{className:"text-[12.5px] text-zinc-400",children:"还没有可用的 Agent,先到设置里配一个。"})]}),d.jsxs("div",{className:"mt-4 grid gap-3",children:[d.jsxs("div",{children:[d.jsxs("div",{className:"text-[12.5px] font-medium text-zinc-600",children:["模型 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选"})]}),d.jsx(ua,{size:"sm",options:q,value:w,placeholder:"Agent 默认",disabledText:J?"正在读取模型…":T.isError?"模型列表读取失败,可先不选":"这个 Agent 没有提供模型选项",disabled:h==="adopting",onChange:le=>{S(le),_("")}})]}),d.jsxs("div",{children:[d.jsxs("div",{className:"text-[12.5px] font-medium text-zinc-600",children:["思考深度 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选"})]}),d.jsx(ua,{size:"sm",options:X,value:C,placeholder:"Agent 默认",disabledText:J?"正在读取…":T.isError?"读取失败,可先不选":"这个模型没有思考深度选项",disabled:h==="adopting",onChange:_})]})]}),((xe=T.data)==null?void 0:xe.warning)&&d.jsxs("p",{className:"mt-1.5 text-[11px] leading-4 text-amber-600",children:["这个 Agent 的配置没读出来:",T.data.warning," 如果一直这样,先检查它是否已登录。"]}),d.jsxs("div",{className:"mt-4 text-[12.5px] font-medium text-zinc-600",children:["常驻目录 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选,派活时仍可指定别的目录"})]}),d.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[d.jsx("input",{list:"adopt-workspaces",value:b,disabled:h==="adopting",onChange:le=>y(le.target.value),placeholder:O??"绝对路径,例如 /Users/you/project","aria-label":"常驻目录",spellCheck:!1,className:"ui-field h-9 min-w-0 flex-1 rounded-xl border border-zinc-300 bg-white px-3 font-mono text-[12.5px] text-zinc-800 outline-none placeholder:font-sans placeholder:text-zinc-400 disabled:opacity-60"}),((Ze=P.data)==null?void 0:Ze.directoryPicker)&&d.jsx("button",{type:"button",disabled:h==="adopting"||ae.isPending,onClick:()=>ae.mutate(),title:ae.isPending?"选择中…":"选择目录","aria-label":"选择目录",className:"grid h-9 w-9 shrink-0 place-items-center rounded-xl border border-zinc-200 text-zinc-500 transition-colors hover:border-zinc-300 hover:text-zinc-900 disabled:opacity-50",children:ae.isPending?d.jsx(Hn,{size:14,className:"animate-spin"}):d.jsx(ha,{size:14})})]}),d.jsx("datalist",{id:"adopt-workspaces",children:V.map(le=>d.jsx("option",{value:le,children:f2(le,B)},le))}),d.jsx("p",{className:"mt-1.5 text-[11.5px] leading-4 text-zinc-400",children:"可以直接粘贴任意绝对路径,或从最近用过的目录里挑;留空就用 Agent 自己的默认目录。"}),d.jsxs("p",{className:"mt-4 rounded-xl bg-zinc-50 px-3 py-2.5 text-[12px] leading-5 text-zinc-500",children:["它会成为你的",d.jsx("b",{className:"font-medium text-zinc-700",children:"主会话"}),":听你说要做什么,派侧边会话去干、盯进度、验收结果。派出去的每件事都是一张便签,贴在屏幕右边,随时划出来看。"]}),k&&d.jsx("p",{role:"alert",className:"mt-3 text-[12px] text-red-600",children:k})]}),d.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2 border-t border-zinc-100 px-4 py-3",children:[d.jsx("button",{type:"button",disabled:h==="adopting",onClick:()=>f(l?"idle":"invite"),className:"h-9 rounded-full px-3.5 text-[13px] text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-800 disabled:opacity-50",children:"先不了"}),d.jsx("button",{type:"submit",disabled:h==="adopting"||!D,className:"inline-flex h-9 min-w-[8.5rem] items-center justify-center gap-1.5 rounded-full bg-zinc-900 px-4 text-[13px] font-medium text-white transition-[background-color,transform] hover:bg-zinc-700 active:scale-95 disabled:opacity-60",children:h==="adopting"?d.jsxs(d.Fragment,{children:[d.jsx(D5,{}),"正在带它回家…"]}):d.jsxs(d.Fragment,{children:[d.jsx(Ji,{size:14}),"带它回家"]})})]})]})}),!U&&d.jsx("h1",{className:"ui-empty-state ui-hero-title mt-4 text-[22px] font-semibold tracking-[-.02em]",children:"有什么要做的?"})]});return d.jsx(uLe,{editorRef:n,agents:e,sessions:t,onCreated:r,hero:fe,collapsed:U&&!G,companion:oe&&s.mainSession?{sessionId:s.mainSession.id,agentId:s.mainSession.agentId,name:s.name,onSent:()=>{const le=hm(["kitten-hero"]);le&&jc(le,"sparkles",6),window.setTimeout(()=>o.openMain(),co()?0:260)}}:void 0})}const mLe=m.lazy(()=>w4(()=>import("./PromptEditor-FsL3X16B.js"),__vite__mapDeps([5,1,2,3]))),gLe=e=>[...new Set(e.split(/[\n,,]/).map(t=>t.trim()).filter(Boolean))];function vLe({className:e=""}){return d.jsx("img",{src:"/agent-dock.svg",alt:"","aria-hidden":"true",className:`${e} ui-logo-tile`})}function xLe({cwd:e,top:t,left:n,agents:r,creatingPair:i,onSelect:s,onClose:o}){const a=m.useRef(null);return jy(a,!0,o),d.jsxs("div",{ref:a,className:"ui-popover fixed z-50 max-h-64 w-52 overflow-y-auto rounded-lg border border-zinc-200 bg-white p-1 shadow-[0_16px_40px_rgba(24,24,27,.16)]",style:{top:t,left:n},children:[d.jsx("div",{className:"px-2 py-1 text-[12px] text-zinc-400",children:"在此工作区新建会话"}),r.length===0&&d.jsx("div",{className:"px-2 py-2 text-[12px] text-zinc-400",children:"暂无可用 Agent"}),r.map(l=>{const c=(i==null?void 0:i.agentId)===l.id&&i.cwd===e;return d.jsxs("button",{type:"button",disabled:!!i,onClick:()=>s(l.id),className:"flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-[12px] text-zinc-700 hover:bg-zinc-100 disabled:opacity-50",children:[c?d.jsx(Hn,{size:13,className:"shrink-0 animate-spin text-zinc-500"}):d.jsx(Hr,{agentId:l.id,agentName:l.name,size:14}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:l.name})]},l.id)})]})}function bLe({options:e,value:t,onChange:n}){return d.jsx(vi,{className:"w-40 shrink-0",size:"small",popupMatchSelectWidth:!1,value:t,onChange:n,options:e.map(r=>({value:r.value,label:r.label}))})}function F5({options:e,value:t,onChange:n}){return d.jsx("div",{className:"flex shrink-0 rounded-md bg-zinc-100 p-0.5",children:e.map(r=>d.jsx("button",{type:"button",onClick:()=>n(r.value),className:`h-7 rounded px-2.5 text-[12px] font-medium transition-colors ${t===r.value?"bg-white text-zinc-900 shadow-sm":"text-zinc-500 hover:text-zinc-700"}`,children:r.label},r.value))})}function yLe({agents:e,value:t,disabled:n,size:r="default",popupWidth:i,onChange:s}){return d.jsx(ua,{size:r,popupWidth:i,options:e.map(o=>({value:o.id,label:o.name,meta:o.version,agentId:o.id})),value:t,placeholder:"选择 Agent",disabledText:"未扫描到可用 Agent",disabled:n,onChange:s})}function l_({value:e,placeholder:t,onChange:n}){const[r,i]=m.useState(""),s=m.useRef(null),o=(c=r)=>{const u=gLe(c);u.length&&n([...new Set([...e,...u])]),i("")},a=c=>n(e.filter(u=>u!==c)),l=c=>{c.nativeEvent.isComposing||(c.key==="Enter"||c.key===","||c.key===","?(c.preventDefault(),o()):c.key==="Backspace"&&!r&&e.length&&a(e[e.length-1]))};return d.jsxs("div",{role:"group","aria-label":"成员真实姓名",onClick:()=>{var c;return(c=s.current)==null?void 0:c.focus()},className:"mt-2 flex min-h-11 cursor-text flex-wrap items-center gap-x-2 gap-y-2 rounded-lg border border-zinc-300 bg-zinc-50/70 p-2 ui-field-within focus-within:bg-white",children:[e.map(c=>d.jsxs("span",{title:c,className:"flex h-7 max-w-full items-center rounded-md border border-zinc-200 bg-white pl-2.5 pr-1 text-[12px] font-medium text-zinc-700 shadow-[0_1px_1px_rgba(24,24,27,.04)]",children:[d.jsx("span",{className:"min-w-0 truncate",children:c}),d.jsx("button",{type:"button","aria-label":`移除 ${c}`,onPointerDown:u=>u.preventDefault(),onClick:()=>a(c),className:"ml-1.5 grid h-5 w-5 shrink-0 place-items-center rounded text-zinc-400 transition-colors hover:bg-zinc-100 hover:text-zinc-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-300",children:d.jsx(Wn,{size:11})})]},c)),d.jsx("input",{ref:s,"aria-label":"输入成员真实姓名",value:r,onChange:c=>i(c.target.value),onKeyDown:l,onBlur:()=>o(),onPaste:c=>{const u=c.clipboardData.getData("text");/[\n,,]/.test(u)&&(c.preventDefault(),o(`${r}
|
|
1116
|
+
例如:请检查 {{项目}} 的发布前状态,并运行 {{验证命令}}。`,className:"ui-field w-full resize-y rounded-lg border border-zinc-200 bg-white px-3 py-2 font-mono text-[12px] leading-5 text-zinc-800 outline-none transition-colors placeholder:text-zinc-400 focus:border-zinc-400"})]}),d.jsx("div",{className:"text-[12px] leading-5 text-zinc-500",children:g.length?d.jsxs(d.Fragment,{children:["识别到变量:",d.jsx("span",{className:"font-mono text-zinc-700",children:g.join("、")})]}):"没有 {{变量}},点击卡片会直接填入整段提示词。"}),u&&d.jsx("p",{role:"alert",className:"text-[12px] text-red-600",children:u})]}),d.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-t border-zinc-100 px-4 py-3",children:[e&&d.jsxs("button",{type:"button",onClick:()=>{if(!f){p(!0);return}r(e.id)},className:"flex items-center gap-1 rounded-lg px-2.5 py-1.5 text-[12px] text-red-600 hover:bg-red-50",children:[d.jsx(kf,{size:12}),f?"确认删除":"删除"]}),d.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded-lg px-3 py-1.5 text-[12px] text-zinc-600 hover:bg-zinc-100",children:"取消"}),d.jsx("button",{type:"submit",disabled:!i.trim()||!l.trim(),className:"rounded-lg bg-zinc-900 px-3.5 py-1.5 text-[12px] font-medium text-white transition-colors hover:bg-zinc-800 disabled:cursor-not-allowed disabled:opacity-40",children:"保存模板"})]})]})}function uLe({agents:e,sessions:t,onCreated:n,editorRef:r,hero:i,collapsed:s=!1,companion:o}){var X,J,ae,ne,re,ie,G,oe,ge;const a=Ln(),[l,c]=m.useState(""),[u,h]=m.useState([]),[f,p]=m.useState(""),[g,x]=m.useState(""),[v,b]=m.useState(""),[y,w]=m.useState(""),[S,C]=m.useState(),[_,k]=m.useState(!1),j=m.useRef(new Map),z=m.useRef(new Set),N=m.useRef(0),I=e.some(U=>U.id===f)?f:((X=t.find(U=>!U.archivedAt&&e.some(ce=>ce.id===U.agentId)))==null?void 0:X.agentId)||((J=e[0])==null?void 0:J.id)||"",$=e.find(U=>U.id===I),R=Et({queryKey:["system-capabilities"],queryFn:we.systemCapabilities}),E=($==null?void 0:$.cwd)||((ae=R.data)==null?void 0:ae.workingDirectory),M=m.useMemo(()=>{const U=new Set,ce=[];for(const ve of[E,...t.map(fe=>fe.cwd)])!ve||U.has(ve)||(U.add(ve),ce.push(ve));return ce.slice(0,30)},[E,t]),P=(ne=R.data)==null?void 0:ne.homeDirectory,A=Et({queryKey:ul(I,v),queryFn:()=>dl(I,v||void 0),enabled:!!I,initialData:()=>Cd(I,v||void 0),initialDataUpdatedAt:0,refetchOnMount:"always",staleTime:6e4}),D=Et({queryKey:["skills",g],queryFn:()=>we.skills(g||void 0),staleTime:6e4}),F=yt({mutationFn:()=>dl(I,v||void 0,!0),onSuccess:U=>a.setQueryData(ul(I,v||void 0),U),onError:U=>C(U instanceof Error?U.message:String(U))}),O=yt({mutationFn:we.selectDirectory,onSuccess:U=>x(U.path),onError:U=>C(U instanceof Error?U.message:String(U))}),B=wK({loaded:A.data!==void 0,loading:A.data===void 0&&(A.isPending||A.isFetching||F.isPending),switching:!1,failed:A.data===void 0&&A.isError}),V=async U=>{const ce=`draft-${++N.current}`,ve="name"in U?U.name:"(未命名文件)",fe=U.type.startsWith("image/");U instanceof File&&j.current.set(ce,U);const Ce=fe?URL.createObjectURL(U):void 0;return Ce&&z.current.add(Ce),{id:ce,kind:fe?"image":"file",label:ve,value:ce,...Ce?{url:Ce}:{}}},T=()=>{for(const U of z.current)URL.revokeObjectURL(U);z.current.clear(),j.current.clear()},W=U=>{c(U),requestAnimationFrame(()=>{var ce;return(ce=r==null?void 0:r.current)==null?void 0:ce.focus()})},L=U=>{const ce=l,ve=u,fe=p2();k(!0),(async()=>{try{const Ce=await Promise.all(ve.map(async Ie=>{const Te=j.current.get(Ie.id);if(!Te)return Ie;const de=await d2(U.sessionId,Te);return h2(de,Te.type.startsWith("image/"))})),Pe=u2(ce,Ce);Pe&&await we.send(U.sessionId,Pe,"queue",void 0,fe),a.invalidateQueries({queryKey:["sessions"]}),a.invalidateQueries({queryKey:["tasks",U.sessionId]}),c(""),h([]),T(),U.onSent()}catch(Ce){C(Ce instanceof Error?Ce.message:String(Ce))}finally{k(!1)}})()},q=()=>{if(_)return;if(C(void 0),o){L(o);return}if(!I)return;const U=l,ce=u,ve=p2();k(!0),(async()=>{let fe;try{fe=await we.create({agentId:I,...g.trim()?{cwd:g.trim()}:{},...v?{model:v}:{},...y?{reasoningEffort:y}:{}});const Ce=await Promise.all(ce.map(async Ie=>{const Te=j.current.get(Ie.id);if(!Te)return Ie;const de=await d2(fe.id,Te);return h2(de,Te.type.startsWith("image/"))})),Pe=u2(U,Ce);Pe&&await we.send(fe.id,Pe,"queue",void 0,ve),a.invalidateQueries({queryKey:["sessions"]}),a.invalidateQueries({queryKey:["tasks",fe.id]}),c(""),h([]),T(),n(fe)}catch(Ce){C(Ce instanceof Error?Ce.message:String(Ce)),fe&&(a.invalidateQueries({queryKey:["sessions"]}),n(fe))}finally{k(!1)}})()};return d.jsxs("div",{className:"relative my-auto w-full max-w-[720px]",children:[i??d.jsxs("div",{className:"flex flex-col items-center text-center",children:[d.jsx(U3e,{size:88}),d.jsx("h1",{className:"ui-empty-state ui-hero-title mt-4 text-[22px] font-semibold tracking-[-.02em]",children:"有什么要做的?"})]}),d.jsx("div",{className:"ui-collapse","data-collapsed":s||void 0,"aria-hidden":s||void 0,inert:s,children:d.jsxs("div",{children:[d.jsx("div",{className:"mt-6",children:d.jsx(CK,{draft:!0,...o?{placeholder:d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"hidden sm:inline",children:["跟",o.name,"说说要做什么,Enter 发送;它会派侧边会话去办"]}),d.jsxs("span",{className:"sm:hidden",children:["跟",o.name,"说说要做什么"]})]}),sendLabel:`交给${o.name}`,lockedTarget:d.jsxs("span",{title:`消息会发进主会话,由${o.name}安排`,className:"flex h-8 shrink-0 items-center gap-1.5 rounded-lg bg-zinc-100 px-2.5 text-[12px] font-medium text-zinc-700",children:[d.jsx(Ji,{size:12}),o.name," · 主会话"]})}:{},editorRef:r,sessionId:"",state:"idle",value:l,references:u,sending:_,mode:"queue",queuedTasks:[],skills:D.data??[],models:((re=A.data)==null?void 0:re.models)??[],reasoningEfforts:((ie=A.data)==null?void 0:ie.reasoningEfforts)??[],currentModel:v||((G=A.data)==null?void 0:G.defaultModel),currentReasoningEffort:y||((oe=A.data)==null?void 0:oe.defaultReasoningEffort),context:{},advertisedCommands:[],modelReadiness:B,switchingModel:!1,switchingReasoningEffort:!1,refreshingModels:A.isFetching||F.isPending,agents:e,currentAgentId:(o==null?void 0:o.agentId)??I,onAgentChange:U=>{p(U),b(""),w("")},workspace:g,onWorkspaceChange:x,workspaceSuggestion:E,homeDirectory:P,workspaceOptions:M,directoryPickerAvailable:(ge=R.data)==null?void 0:ge.directoryPicker,pickingDirectory:O.isPending,onPickDirectory:()=>O.mutate(),onAttachFile:V,onChange:c,onReferencesChange:h,onModeChange:()=>{},onSubmit:q,onInterrupt:()=>{},onCancelQueued:()=>{},onSteerQueued:()=>{},onEditQueued:()=>{},onModelChange:b,onReasoningEffortChange:w,onRefreshModels:()=>F.mutate()})}),!o&&d.jsx(oLe,{onUse:W}),S&&d.jsx("p",{role:"alert",className:"mt-2 text-center text-[12px] text-red-600",children:S}),u.length>0&&d.jsxs("p",{className:"mt-2 text-center text-[12px] text-zinc-400",children:[u.length," 个附件会在",o?"发送":"会话创建","后上传"]})]})})]})}const wG="agentdock:adopt-agent";function dLe(){try{return typeof window>"u"?"":window.localStorage.getItem(wG)||""}catch{return""}}function hLe(e,t){const n=e instanceof Error?e.message:String(e);return/authentication required|not authenticated|unauthorized|\b401\b/i.test(n)?`${t} 还没在这台机器上登录,暂时开不了工。换一个已登录的 Agent,或先在终端完成 ${t} 的登录再回来认领。`:n}function D5(){const e=d.jsxs("svg",{viewBox:"0 0 24 24",width:"11",height:"11",fill:"currentColor","aria-hidden":"true",children:[d.jsx("ellipse",{cx:"12",cy:"16",rx:"5",ry:"4.2"}),d.jsx("circle",{cx:"6",cy:"9.5",r:"2.2"}),d.jsx("circle",{cx:"10",cy:"6",r:"2.2"}),d.jsx("circle",{cx:"14",cy:"6",r:"2.2"}),d.jsx("circle",{cx:"18",cy:"9.5",r:"2.2"})]});return d.jsxs("span",{className:"ui-paw-walk",children:[e,e,e,e]})}function L5(e){const t=M7();return e.counts.needsUser?`${t}~有 ${e.counts.needsUser} 件事等你拍板,右边的便签里看看吧`:e.counts.planned?`${t}~有 ${e.counts.planned} 张计划等你点头,右边的便签里看看`:e.busy?`${t}~我正在忙,有新想法也可以先丢给我`:e.counts.running?`${t}~我在盯着 ${e.counts.running} 张便签,有进展会叫你`:e.counts.review?`${t}~${e.counts.review} 张便签做完了,我在验收`:`${t}~我是${e.name},有事交给我,我派人去办`}function fLe({value:e,name:t,onChange:n}){return d.jsxs("div",{className:"ui-target mt-4","data-value":e,role:"group","aria-label":"这条消息发给谁",children:[d.jsx("span",{className:"ui-target-pill","aria-hidden":"true"}),d.jsxs("button",{type:"button","aria-pressed":e==="new",onClick:()=>n("new"),className:"ui-target-option",children:[d.jsx(ZZ,{size:13}),"新对话"]}),d.jsxs("button",{type:"button","aria-pressed":e==="companion",onClick:()=>n("companion"),className:"ui-target-option ui-cat-hover-host",children:[d.jsx(Ji,{size:13}),d.jsxs("span",{className:"max-w-[9rem] truncate",children:["交给",t]})]})]})}function pLe({agents:e,sessions:t,editorRef:n,onCreated:r}){var Ce,Pe,Ie,Te,de,Le,te,me,_e,$e,xe,Ze;const i=Ln(),s=Hi(),o=Na(),a=zt(le=>le.adoptPending),l=zt(le=>le.inviteDismissed),c=zt(le=>le.homeTarget),u=zt(le=>le.celebrateNonce),[h,f]=m.useState("idle"),[p,g]=m.useState(Up),[x,v]=m.useState(dLe),[b,y]=m.useState(""),[w,S]=m.useState(""),[C,_]=m.useState(""),[k,j]=m.useState(),[z,N]=m.useState(),[I,$]=m.useState(""),R=gh("kitten-hero"),E=m.useRef(null),M=m.useRef(null),P=Et({queryKey:["system-capabilities"],queryFn:we.systemCapabilities});m.useEffect(()=>{!a||!s.loaded||(zt.getState().consumeAdoption(),s.adopted||f("form"))},[a,s.loaded,s.adopted]),m.useEffect(()=>{if(h!=="form")return;const le=window.setTimeout(()=>{var Me,pe;(Me=E.current)==null||Me.focus(),(pe=E.current)==null||pe.select()},260);return()=>window.clearTimeout(le)},[h]),m.useEffect(()=>{if(!z)return;const le=window.setTimeout(()=>N(void 0),1800);return()=>window.clearTimeout(le)},[z]);const A=m.useMemo(()=>e.filter(le=>!le.disabled),[e]),D=A.some(le=>le.id===x)?x:((Ce=t.find(le=>!le.archivedAt&&A.some(Me=>Me.id===le.agentId)))==null?void 0:Ce.agentId)||((Pe=A[0])==null?void 0:Pe.id)||"",F=A.find(le=>le.id===D),O=(F==null?void 0:F.cwd)||((Ie=P.data)==null?void 0:Ie.workingDirectory),B=(Te=P.data)==null?void 0:Te.homeDirectory,V=m.useMemo(()=>{const le=new Set,Me=[];for(const pe of[O,...t.map(ye=>ye.cwd)])!pe||le.has(pe)||(le.add(pe),Me.push(pe));return Me.slice(0,20)},[O,t]),T=Et({queryKey:ul(D,w),queryFn:()=>dl(D,w||void 0),enabled:!!D&&(h==="form"||h==="adopting"),initialData:()=>Cd(D,w||void 0),initialDataUpdatedAt:0,refetchOnMount:"always",staleTime:6e4});m.useEffect(()=>{S(""),_("")},[D]);const W=((Le=(de=T.data)==null?void 0:de.models.find(le=>{var Me;return le.id===((Me=T.data)==null?void 0:Me.defaultModel)}))==null?void 0:Le.name)??((te=T.data)==null?void 0:te.defaultModel),L=((_e=(me=T.data)==null?void 0:me.reasoningEfforts.find(le=>{var Me;return le.id===((Me=T.data)==null?void 0:Me.defaultReasoningEffort)}))==null?void 0:_e.name)??(($e=T.data)==null?void 0:$e.defaultReasoningEffort),q=m.useMemo(()=>{var le;return(le=T.data)!=null&&le.models.length?[{value:"",label:W?`Agent 默认 · ${W}`:"Agent 默认"},...T.data.models.map(Me=>({value:Me.id,label:Me.name,meta:Me.name===Me.id?void 0:Me.id}))]:[]},[W,T.data]),X=m.useMemo(()=>{var le;return(le=T.data)!=null&&le.reasoningEfforts.length?[{value:"",label:L?`Agent 默认 · ${L}`:"Agent 默认"},...T.data.reasoningEfforts.map(Me=>({value:Me.id,label:Me.name}))]:[]},[L,T.data]),J=T.isPending||T.isFetching,ae=yt({mutationFn:we.selectDirectory,onSuccess:le=>{y(le.path),j(void 0)},onError:le=>j(le instanceof Error?le.message:String(le))}),ne=yt({mutationFn:()=>we.assistantSetMain({agentId:D,name:p.trim()||Up,...b.trim()?{cwd:b.trim()}:{},...w?{model:w}:{},...C?{reasoningEffort:C}:{}}),onMutate:()=>{j(void 0),f("adopting")},onSuccess:le=>{var ye;try{window.localStorage.setItem(wG,D)}catch{}const Me=((ye=le.companion)==null?void 0:ye.name)??(p.trim()||Up);$(Me),i.setQueryData(["assistant-state"],Ee=>Ee&&{...Ee,mainSessionId:le.session.id,mainSession:le.session,companion:le.companion??{name:Me,adoptedAt:new Date().toISOString()}}),i.setQueryData(["sessions"],Ee=>Ee&&[le.session,...Ee.filter(Se=>Se.id!==le.session.id)]),i.invalidateQueries({queryKey:["assistant-state"]}),i.invalidateQueries({queryKey:["sessions"]});const pe=zt.getState();pe.dismissInvite(!1),pe.celebrate(),f("celebrate"),window.setTimeout(()=>{M.current&&jc(M.current.getBoundingClientRect(),"confetti",18)},120),window.setTimeout(()=>o.openMain(le.session.id),co()?900:2300)},onError:le=>{f("form"),j(hLe(le,(F==null?void 0:F.name)??D))}}),re=()=>{const le=b.trim();if(le&&!le.startsWith("/")){j("工作目录请填绝对路径,例如 /Users/you/project");return}ne.mutate()},ie=()=>{zt.getState().dismissInvite(),N("sad"),f("idle")},G=s.adopted&&h!=="celebrate",oe=G&&c==="companion"&&!!s.mainId,ge=!s.adopted&&s.loaded&&(h==="invite"||h==="idle"&&!l),U=h==="form"||h==="adopting"||h==="celebrate",ce=z??(h==="celebrate"?"happy":h==="adopting"?"busy":G?s.mood==="curious"?"idle":s.mood:"curious"),ve=d.jsx("div",{ref:R,className:"ui-stage-kitten",children:d.jsx(Fi,{size:h==="form"||h==="adopting"?76:88,mood:ce,stage:G?s.stage:void 0,collar:G||h==="celebrate",drawCollar:h==="celebrate",track:!0,typingAware:!0,celebrateKey:u,viewTransitionName:E7,label:G?`进入主会话(${s.name})`:"小猫",onClick:()=>{G?o.openMain():h==="idle"&&f("invite")}})});let fe;if(G){const le=s.counts;fe=d.jsxs("div",{className:"ui-stage",children:[d.jsx("div",{className:"ui-speech text-center",children:L5(s)},L5(s)),ve,d.jsx("span",{className:"ui-name-tag",children:s.name}),d.jsxs("div",{className:"mt-3 flex flex-wrap justify-center gap-1.5",children:[le.needsUser>0&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().openDrawer({filter:"needs_user"}),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-needs"}),le.needsUser," 件需要你"]}),le.planned>0&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().openDrawer({filter:"needs_user"}),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-plan"}),le.planned," 张计划等你点头"]}),le.review>0&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().openDrawer({filter:"review"}),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-review"}),le.review," 张待验收"]}),le.running>0&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().openDrawer({filter:"running"}),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-running"}),le.running," 张进行中"]}),!le.open&&d.jsxs("button",{type:"button",className:"ui-status-chip",onClick:()=>zt.getState().toggleDrawer(),children:[d.jsx("span",{className:"ui-note-swatch ui-note-paper-done"}),le.closed?`${le.closed} 张已完成`:"便签墙"]})]}),d.jsx("h1",{className:"ui-empty-state ui-hero-title mt-5 text-[22px] font-semibold tracking-[-.02em]",children:oe?`交给${s.name}吧`:"有什么要做的?"}),d.jsx(fLe,{value:c,name:s.name,onChange:Me=>{zt.getState().setHomeTarget(Me),requestAnimationFrame(()=>{var pe;return(pe=n==null?void 0:n.current)==null?void 0:pe.focus()})}})]})}else fe=d.jsxs("div",{className:"ui-stage",children:[ge&&d.jsxs("div",{className:"ui-speech text-center",children:[d.jsx("p",{className:"text-[14px] font-medium text-zinc-900",children:"喵~带我回家吧?"}),d.jsx("p",{className:"mt-0.5 text-[12.5px] leading-5 text-zinc-500",children:"认领后我就是你的主会话:你说要做什么,我派侧边会话去干、盯进度、做完帮你验收,每件事都贴成便签。"}),d.jsxs("div",{className:"mt-2.5 flex justify-center gap-2",children:[d.jsxs("button",{type:"button",onClick:()=>f("form"),className:"inline-flex h-8 items-center gap-1.5 rounded-full bg-zinc-900 px-3.5 text-[12.5px] font-medium text-white transition-[background-color,transform] hover:bg-zinc-700 active:scale-95",children:[d.jsx(Ji,{size:13}),"认领它"]}),d.jsx("button",{type:"button",onClick:ie,className:"inline-flex h-8 items-center rounded-full px-3 text-[12.5px] text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-800",children:"先不了"})]})]}),h==="celebrate"&&d.jsxs("div",{className:"ui-speech text-center",children:[d.jsxs("p",{className:"text-[14px] font-medium text-zinc-900",children:["喵!我是",I,",以后请多指教~"]}),d.jsxs("p",{className:"mt-1 inline-flex items-center gap-1.5 text-[12px] text-zinc-500",children:[d.jsx(D5,{}),"正在去主会话…"]})]}),ve,h==="celebrate"&&d.jsx("span",{className:"ui-name-tag",children:I}),(h==="form"||h==="adopting")&&d.jsx("div",{ref:M,className:"ui-adopt-card mt-4",children:d.jsxs("form",{onSubmit:le=>{le.preventDefault(),!ne.isPending&&D&&re()},children:[d.jsxs("div",{className:"px-5 pt-5",children:[d.jsxs("label",{className:"block",children:[d.jsx("span",{className:"text-[14px] font-semibold text-zinc-900",children:"给它起个名字"}),d.jsxs("span",{className:"mt-2 flex items-center gap-2",children:[d.jsx("input",{ref:E,value:p,maxLength:16,disabled:h==="adopting",onChange:le=>g(le.target.value),placeholder:Up,"aria-label":"小猫的名字",className:"ui-field h-10 min-w-0 flex-1 rounded-xl border border-zinc-300 bg-white px-3 text-[15px] font-semibold text-zinc-900 outline-none placeholder:font-normal placeholder:text-zinc-400 disabled:opacity-60"}),d.jsx("button",{type:"button",disabled:h==="adopting",onClick:()=>g(le=>Fy(le.trim())),"aria-label":"随机换一个名字",title:"随机换一个名字",className:"ui-dice grid h-10 w-10 shrink-0 place-items-center rounded-xl border border-zinc-200 text-zinc-500 hover:border-zinc-300 hover:text-zinc-900 disabled:opacity-50",children:d.jsx(Fb,{size:17})})]})]}),d.jsx("div",{className:"mt-4 text-[12.5px] font-medium text-zinc-600",children:"它用哪个 Agent 思考"}),d.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[A.map(le=>d.jsxs("button",{type:"button",disabled:h==="adopting","aria-pressed":le.id===D,onClick:()=>{v(le.id),S(""),_(""),j(void 0)},className:"ui-pill-choice",children:[d.jsx(Hr,{agentId:le.id,agentName:le.name,size:13}),le.name]},le.id)),!A.length&&d.jsx("span",{className:"text-[12.5px] text-zinc-400",children:"还没有可用的 Agent,先到设置里配一个。"})]}),d.jsxs("div",{className:"mt-4 grid gap-3",children:[d.jsxs("div",{children:[d.jsxs("div",{className:"text-[12.5px] font-medium text-zinc-600",children:["模型 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选"})]}),d.jsx(ua,{size:"sm",options:q,value:w,placeholder:"Agent 默认",disabledText:J?"正在读取模型…":T.isError?"模型列表读取失败,可先不选":"这个 Agent 没有提供模型选项",disabled:h==="adopting",onChange:le=>{S(le),_("")}})]}),d.jsxs("div",{children:[d.jsxs("div",{className:"text-[12.5px] font-medium text-zinc-600",children:["思考深度 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选"})]}),d.jsx(ua,{size:"sm",options:X,value:C,placeholder:"Agent 默认",disabledText:J?"正在读取…":T.isError?"读取失败,可先不选":"这个模型没有思考深度选项",disabled:h==="adopting",onChange:_})]})]}),((xe=T.data)==null?void 0:xe.warning)&&d.jsxs("p",{className:"mt-1.5 text-[11px] leading-4 text-amber-600",children:["这个 Agent 的配置没读出来:",T.data.warning," 如果一直这样,先检查它是否已登录。"]}),d.jsxs("div",{className:"mt-4 text-[12.5px] font-medium text-zinc-600",children:["常驻目录 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选,派活时仍可指定别的目录"})]}),d.jsxs("div",{className:"mt-2 flex items-center gap-1.5",children:[d.jsx("input",{list:"adopt-workspaces",value:b,disabled:h==="adopting",onChange:le=>y(le.target.value),placeholder:O??"绝对路径,例如 /Users/you/project","aria-label":"常驻目录",spellCheck:!1,className:"ui-field h-9 min-w-0 flex-1 rounded-xl border border-zinc-300 bg-white px-3 font-mono text-[12.5px] text-zinc-800 outline-none placeholder:font-sans placeholder:text-zinc-400 disabled:opacity-60"}),((Ze=P.data)==null?void 0:Ze.directoryPicker)&&d.jsx("button",{type:"button",disabled:h==="adopting"||ae.isPending,onClick:()=>ae.mutate(),title:ae.isPending?"选择中…":"选择目录","aria-label":"选择目录",className:"grid h-9 w-9 shrink-0 place-items-center rounded-xl border border-zinc-200 text-zinc-500 transition-colors hover:border-zinc-300 hover:text-zinc-900 disabled:opacity-50",children:ae.isPending?d.jsx(Hn,{size:14,className:"animate-spin"}):d.jsx(ha,{size:14})})]}),d.jsx("datalist",{id:"adopt-workspaces",children:V.map(le=>d.jsx("option",{value:le,children:f2(le,B)},le))}),d.jsx("p",{className:"mt-1.5 text-[11.5px] leading-4 text-zinc-400",children:"可以直接粘贴任意绝对路径,或从最近用过的目录里挑;留空就用 Agent 自己的默认目录。"}),d.jsxs("p",{className:"mt-4 rounded-xl bg-zinc-50 px-3 py-2.5 text-[12px] leading-5 text-zinc-500",children:["它会成为你的",d.jsx("b",{className:"font-medium text-zinc-700",children:"主会话"}),":听你说要做什么,派侧边会话去干、盯进度、验收结果。派出去的每件事都是一张便签,贴在屏幕右边,随时划出来看。"]}),k&&d.jsx("p",{role:"alert",className:"mt-3 text-[12px] text-red-600",children:k})]}),d.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2 border-t border-zinc-100 px-4 py-3",children:[d.jsx("button",{type:"button",disabled:h==="adopting",onClick:()=>f(l?"idle":"invite"),className:"h-9 rounded-full px-3.5 text-[13px] text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-800 disabled:opacity-50",children:"先不了"}),d.jsx("button",{type:"submit",disabled:h==="adopting"||!D,className:"inline-flex h-9 min-w-[8.5rem] items-center justify-center gap-1.5 rounded-full bg-zinc-900 px-4 text-[13px] font-medium text-white transition-[background-color,transform] hover:bg-zinc-700 active:scale-95 disabled:opacity-60",children:h==="adopting"?d.jsxs(d.Fragment,{children:[d.jsx(D5,{}),"正在带它回家…"]}):d.jsxs(d.Fragment,{children:[d.jsx(Ji,{size:14}),"带它回家"]})})]})]})}),!U&&d.jsx("h1",{className:"ui-empty-state ui-hero-title mt-4 text-[22px] font-semibold tracking-[-.02em]",children:"有什么要做的?"})]});return d.jsx(uLe,{editorRef:n,agents:e,sessions:t,onCreated:r,hero:fe,collapsed:U&&!G,companion:oe&&s.mainSession?{sessionId:s.mainSession.id,agentId:s.mainSession.agentId,name:s.name,onSent:()=>{const le=hm(["kitten-hero"]);le&&jc(le,"sparkles",6),window.setTimeout(()=>o.openMain(),co()?0:260)}}:void 0})}const mLe=m.lazy(()=>w4(()=>import("./PromptEditor-CX3eQM-7.js"),__vite__mapDeps([5,1,2,3]))),gLe=e=>[...new Set(e.split(/[\n,,]/).map(t=>t.trim()).filter(Boolean))];function vLe({className:e=""}){return d.jsx("img",{src:"/agent-dock.svg",alt:"","aria-hidden":"true",className:`${e} ui-logo-tile`})}function xLe({cwd:e,top:t,left:n,agents:r,creatingPair:i,onSelect:s,onClose:o}){const a=m.useRef(null);return jy(a,!0,o),d.jsxs("div",{ref:a,className:"ui-popover fixed z-50 max-h-64 w-52 overflow-y-auto rounded-lg border border-zinc-200 bg-white p-1 shadow-[0_16px_40px_rgba(24,24,27,.16)]",style:{top:t,left:n},children:[d.jsx("div",{className:"px-2 py-1 text-[12px] text-zinc-400",children:"在此工作区新建会话"}),r.length===0&&d.jsx("div",{className:"px-2 py-2 text-[12px] text-zinc-400",children:"暂无可用 Agent"}),r.map(l=>{const c=(i==null?void 0:i.agentId)===l.id&&i.cwd===e;return d.jsxs("button",{type:"button",disabled:!!i,onClick:()=>s(l.id),className:"flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-[12px] text-zinc-700 hover:bg-zinc-100 disabled:opacity-50",children:[c?d.jsx(Hn,{size:13,className:"shrink-0 animate-spin text-zinc-500"}):d.jsx(Hr,{agentId:l.id,agentName:l.name,size:14}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:l.name})]},l.id)})]})}function bLe({options:e,value:t,onChange:n}){return d.jsx(vi,{className:"w-40 shrink-0",size:"small",popupMatchSelectWidth:!1,value:t,onChange:n,options:e.map(r=>({value:r.value,label:r.label}))})}function F5({options:e,value:t,onChange:n}){return d.jsx("div",{className:"flex shrink-0 rounded-md bg-zinc-100 p-0.5",children:e.map(r=>d.jsx("button",{type:"button",onClick:()=>n(r.value),className:`h-7 rounded px-2.5 text-[12px] font-medium transition-colors ${t===r.value?"bg-white text-zinc-900 shadow-sm":"text-zinc-500 hover:text-zinc-700"}`,children:r.label},r.value))})}function yLe({agents:e,value:t,disabled:n,size:r="default",popupWidth:i,onChange:s}){return d.jsx(ua,{size:r,popupWidth:i,options:e.map(o=>({value:o.id,label:o.name,meta:o.version,agentId:o.id})),value:t,placeholder:"选择 Agent",disabledText:"未扫描到可用 Agent",disabled:n,onChange:s})}function l_({value:e,placeholder:t,onChange:n}){const[r,i]=m.useState(""),s=m.useRef(null),o=(c=r)=>{const u=gLe(c);u.length&&n([...new Set([...e,...u])]),i("")},a=c=>n(e.filter(u=>u!==c)),l=c=>{c.nativeEvent.isComposing||(c.key==="Enter"||c.key===","||c.key===","?(c.preventDefault(),o()):c.key==="Backspace"&&!r&&e.length&&a(e[e.length-1]))};return d.jsxs("div",{role:"group","aria-label":"成员真实姓名",onClick:()=>{var c;return(c=s.current)==null?void 0:c.focus()},className:"mt-2 flex min-h-11 cursor-text flex-wrap items-center gap-x-2 gap-y-2 rounded-lg border border-zinc-300 bg-zinc-50/70 p-2 ui-field-within focus-within:bg-white",children:[e.map(c=>d.jsxs("span",{title:c,className:"flex h-7 max-w-full items-center rounded-md border border-zinc-200 bg-white pl-2.5 pr-1 text-[12px] font-medium text-zinc-700 shadow-[0_1px_1px_rgba(24,24,27,.04)]",children:[d.jsx("span",{className:"min-w-0 truncate",children:c}),d.jsx("button",{type:"button","aria-label":`移除 ${c}`,onPointerDown:u=>u.preventDefault(),onClick:()=>a(c),className:"ml-1.5 grid h-5 w-5 shrink-0 place-items-center rounded text-zinc-400 transition-colors hover:bg-zinc-100 hover:text-zinc-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-300",children:d.jsx(Wn,{size:11})})]},c)),d.jsx("input",{ref:s,"aria-label":"输入成员真实姓名",value:r,onChange:c=>i(c.target.value),onKeyDown:l,onBlur:()=>o(),onPaste:c=>{const u=c.clipboardData.getData("text");/[\n,,]/.test(u)&&(c.preventDefault(),o(`${r}
|
|
1117
1117
|
${u}`))},placeholder:e.length?"继续添加成员…":t,className:"h-7 min-w-36 flex-[1_0_9rem] border-0 bg-transparent px-1 text-[12px] text-zinc-800 outline-none placeholder:text-zinc-400"})]})}function wLe({agents:e,onClose:t}){var Yt,Y,Ae,et,Tt,dt,At,He,it,jt,St,It,Rn,Tn,Sn,mr,qn,nr,Ur,_r,ci,Rr,rr,Cr,kr,Nr,Kr,ui,Ft,Rt;const[n,r]=m.useState(!1),i=Ln(),s=Et({queryKey:["lark-config"],queryFn:we.larkConfig}),o=Et({queryKey:["system-capabilities"],queryFn:we.systemCapabilities}),[a,l]=m.useState(),c=m.useRef(null),[u,h]=m.useState(null),[f,p]=m.useState(1),[g,x]=m.useState(""),[v,b]=m.useState(""),[y,w]=m.useState(""),[S,C]=m.useState(""),[_,k]=m.useState(""),[j,z]=m.useState(!1),[N,I]=m.useState([]),[$,R]=m.useState([]),[E,M]=m.useState(!0),[P,A]=m.useState(""),[D,F]=m.useState(""),[O,B]=m.useState(""),[V,T]=m.useState(""),[W,L]=m.useState(!1),[q,X]=m.useState(!1),[J,ae]=m.useState("user"),[ne,re]=m.useState([]),[ie,G]=m.useState(""),[oe,ge]=m.useState(!1),[U,ce]=m.useState(!1),[ve,fe]=m.useState(!1),[Ce,Pe]=m.useState(!1),[Ie,Te]=m.useState(!1),[de,Le]=m.useState(1e3),[te,me]=m.useState(String(Lw)),[_e,$e]=m.useState(!1),xe=(Yt=s.data)==null?void 0:Yt.bots.find(se=>se.appId===u),Ze=((Y=e.find(se=>se.id===P))==null?void 0:Y.cwd)||((Ae=o.data)==null?void 0:Ae.workingDirectory),le=!!(xe!=null&&xe.setupComplete&&xe.defaultAgentId===P),Me=!!(U||xe!=null&&xe.hardGateEnabled),pe=m.useMemo(()=>lye(ie),[ie]),ye=Et({queryKey:["lark-hook-status",xe==null?void 0:xe.appId,P],queryFn:()=>we.larkHookStatus(xe.appId),enabled:!!(le&&oe&&f===2)}),Ee=Et({queryKey:ul(P,D),queryFn:()=>dl(P,D||void 0),enabled:!!P,initialData:()=>Cd(P,D||void 0),initialDataUpdatedAt:0,refetchOnMount:"always",staleTime:5*6e4}),Se=yt({mutationFn:se=>dl(se.agentId,se.model,!0),onSuccess:(se,gt)=>i.setQueryData(ul(gt.agentId,gt.model),se)}),De={enabled:U,persisted:!!(xe!=null&&xe.hardGateEnabled),agentSelectionSaved:le,hookInstalled:!!((et=ye.data)!=null&&et.installed)},at=nme(De),xt=rme(De),Mt=!!(U&&(xe!=null&&xe.hardGateEnabled)&&ye.isSuccess&&!ye.data.installed),rt=!!(oe&&(xe!=null&&xe.highRiskAllowedEmails.length)&&!ne.length),nt=ime(O,(Tt=Ee.data)!=null&&Tt.warning?void 0:Ee.data,Ee.isFetching),Qe=[`机器人名称:${g.trim()||S.trim()||"未命名"}`,`Agent:${((dt=e.find(se=>se.id===P))==null?void 0:dt.name)??(P||"未选择")}`,`工作区:${v.trim()||"使用 Agent 默认工作目录"}`,`群协作工具:${W?q?"已开启(可读写)":"已开启(只读)":"未开启"}`,`回复模式:${_e?"静默回复(最终答案由服务端自动发送)":"Trace 卡片"}`].join(`
|
|
1118
1118
|
`);_P(s.data,()=>{if(u!==null)return;const se=s.data.bots[0];h((se==null?void 0:se.appId)??""),p(se&&!se.setupComplete?2:1)}),_P(s.data&&u!==null?u:null,()=>{var gt,bt,tn,Nn,Un;if(u===null||c.current===u)return;c.current=u;const se=s.data.bots.find(Fn=>Fn.appId===u);x((se==null?void 0:se.name)??""),b((se==null?void 0:se.workspace)??""),w((se==null?void 0:se.webBaseUrl)??""),C((se==null?void 0:se.appId)??""),k(""),z(!!(se!=null&&se.allowedUsers.length||se!=null&&se.allowedEmails.length||(gt=se==null?void 0:se.allowedUserNames)!=null&>.length)),I((bt=se==null?void 0:se.allowedUserNames)!=null&&bt.length?se.allowedUserNames:((se==null?void 0:se.allowedUsers)??[]).map(Fn=>Fn.name)),R((tn=se==null?void 0:se.allowedBotNames)!=null&&tn.length?se.allowedBotNames:((se==null?void 0:se.allowedBots)??[]).map(Fn=>Fn.name)),M((se==null?void 0:se.peerBotsAllowed)!==!1),A(e.some(Fn=>Fn.id===(se==null?void 0:se.defaultAgentId))?(se==null?void 0:se.defaultAgentId)??"":((Nn=e[0])==null?void 0:Nn.id)??""),F((se==null?void 0:se.defaultModel)??""),B((se==null?void 0:se.defaultReasoningEffort)??""),Te((se==null?void 0:se.listening)??!1),Le((se==null?void 0:se.pushIntervalMs)??1e3),me(((se==null?void 0:se.traceLimit)??Lw).toString()),$e((se==null?void 0:se.quietReply)??!1),T((se==null?void 0:se.preInjectPrompt)??""),L((se==null?void 0:se.groupToolsEnabled)??!1),X((se==null?void 0:se.groupToolsAllowSend)??!1),ae((se==null?void 0:se.groupSessionScope)??"user"),re((Un=se==null?void 0:se.highRiskAllowedUserNames)!=null&&Un.length?se.highRiskAllowedUserNames:((se==null?void 0:se.highRiskAllowedUsers)??[]).map(Fn=>Fn.name)),G((se==null?void 0:se.highRiskPattern)??""),ge((se==null?void 0:se.gateEnabled)??!1),ce((se==null?void 0:se.hardGateEnabled)??!1),fe((se==null?void 0:se.hookTrustConfirmed)??!1)});const tt=yt({mutationFn:()=>we.inspectLarkBot({appId:S.trim(),appSecret:_.trim()}),onSuccess:se=>x(se.appName)}),ft=yt({mutationFn:async()=>{const se=await we.saveLarkConfig({stage:"lark",...xe?{originalAppId:xe.appId}:{},appId:S.trim(),..._.trim()?{appSecret:_.trim()}:{},workspace:v.trim(),webBaseUrl:y.trim(),allowedUserNames:j?N:[],allowedEmails:[],allowedBotNames:E?[]:$,peerBotsAllowed:E,listening:Ie,pushIntervalMs:de,traceLimit:Number(te),quietReply:_e});return i.setQueryData(["lark-config"],se),we.saveLarkConfig({stage:"agent",originalAppId:S.trim(),defaultAgentId:P,defaultModel:D,defaultReasoningEffort:nt,preInjectPrompt:V,groupToolsEnabled:W,groupToolsAllowSend:q,groupSessionScope:J,highRiskAllowedUserNames:ne,highRiskAllowedEmails:[],highRiskPattern:ie,gateEnabled:oe,softGateEnabled:oe,hardGateEnabled:U,hookTrustConfirmed:ve})},onSuccess:se=>{i.setQueryData(["lark-config"],se);const gt=S.trim();h(gt),k(""),i.invalidateQueries({queryKey:["lark-hook-status",gt]}),t()}}),ue=yt({mutationFn:async()=>{const se=await we.saveLarkConfig({stage:"agent",originalAppId:xe.appId,defaultAgentId:P,defaultModel:D,defaultReasoningEffort:nt,preInjectPrompt:V,listening:Ie,groupToolsEnabled:W,groupToolsAllowSend:q,groupSessionScope:J,highRiskAllowedUserNames:ne,highRiskAllowedEmails:[],highRiskPattern:ie,gateEnabled:!0,softGateEnabled:!0,hardGateEnabled:!1,hookTrustConfirmed:!1});return i.setQueryData(["lark-config"],se),we.installLarkHook(xe.appId,ie)},onSuccess:se=>{i.setQueryData(["lark-hook-status",xe.appId,P],se),ge(!0),ce(!1),fe(!0),i.invalidateQueries({queryKey:["lark-config"]})}}),Oe=yt({mutationFn:()=>we.deleteLarkConfig(xe.appId),onSuccess:se=>{i.setQueryData(["lark-config"],se);const gt=se.bots[0];h((gt==null?void 0:gt.appId)??""),p(gt&&!gt.setupComplete?2:1),l(void 0)}}),ke=yt({mutationFn:we.selectDirectory,onSuccess:se=>b(se.path)}),pt=f===2&&!!P&&!Ee.data&&(Ee.isLoading||Ee.isFetching),mt=f!==2||!!Ee.data,Ye=!!(S.trim()&&(xe||_.trim())&&(!j||N.length)&&(E||$.length)&&(_e||Number.isInteger(de)&&de>=500&&de<=2e4)),ze=!!(P&&mt&&(!oe||pe.valid)&&!rt&&at),Re=f===1&&!(xe!=null&&xe.setupComplete),Q=Re?Ye:Ye&&ze,Ge=!!(xe||S.trim()&&_.trim()),qe=Se.error??ft.error??Oe.error??ke.error??tt.error??ue.error??(Ee.data?void 0:Ee.error)??s.error,$t=/^cli_[\w-]+$/.test(S.trim())?`https://open.larkoffice.com/app/${encodeURIComponent(S.trim())}/auth`:void 0,Gt=!!(qe&&/权限|permission|通讯录|邮箱|open[_ ]?id|资源点|visible range/i.test(qe.message)),Qt=()=>{const se=!!(xe&&!xe.setupComplete),gt=!xe&&u===""&&!!(S.trim()||_.trim()||v.trim());if(se||gt){l(se?"incomplete":"discard");return}t()};return d.jsxs(d.Fragment,{children:[n&&d.jsx(Zpe,{onClose:()=>{r(!1),i.invalidateQueries({queryKey:["lark-config"]})},onComplete:se=>{i.setQueryData(["lark-config"],se.config),h(se.appId),p(1),r(!1)}}),d.jsx("div",{inert:n,"aria-hidden":n||void 0,className:"ui-overlay fixed inset-0 z-30 grid place-items-center bg-zinc-950/25 p-4",onMouseDown:se=>{se.currentTarget===se.target&&Qt()},children:d.jsxs("form",{onSubmit:se=>{se.preventDefault(),Q&&(Re?p(2):ft.mutate())},className:"ui-dialog flex max-h-[calc(100dvh-2rem)] w-full max-w-[640px] flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-[0_20px_64px_rgba(24,24,27,.18)]",children:[d.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-y-2 border-b border-zinc-100 px-4 py-3",children:[d.jsxs("div",{className:"min-w-0",children:[d.jsx("h2",{className:"text-[16px] font-semibold text-zinc-900",children:"飞书机器人"}),d.jsx("p",{className:"mt-0.5 truncate text-[12px] text-zinc-500",children:"每个机器人拥有独立工作区和会话"})]}),d.jsxs("div",{className:"col-span-2 row-start-2 flex min-w-0 flex-wrap items-center justify-end gap-0.5",children:[d.jsxs("a",{href:"https://open.larkoffice.com/app",target:"_blank",rel:"noreferrer",className:"flex h-8 items-center gap-1.5 whitespace-nowrap rounded-lg px-2.5 text-[12px] font-medium text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400/50",children:["飞书开发者后台",d.jsx(Ja,{size:12})]}),d.jsxs("a",{href:"https://open.larkoffice.com/page/launcher?from=backend_oneclick",target:"_blank",rel:"noreferrer",className:"flex h-8 items-center gap-1.5 whitespace-nowrap rounded-lg px-2.5 text-[12px] font-medium text-zinc-600 transition-colors hover:bg-zinc-100 hover:text-zinc-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-zinc-400/50",children:["快速创建机器人",d.jsx(Ja,{size:12})]}),d.jsxs("button",{type:"button",onClick:()=>r(!0),disabled:!s.data||ft.isPending,className:"flex h-8 items-center gap-1.5 whitespace-nowrap rounded-lg px-2.5 text-[12px] font-medium text-zinc-700 transition-colors hover:bg-zinc-100 disabled:opacity-40",children:["扫码创建机器人",d.jsx(sa,{size:12})]})]}),d.jsx("span",{className:"col-start-2 row-start-1 ml-1",children:d.jsx($o,{label:"关闭",onClick:Qt,children:d.jsx(Wn,{size:15})})})]}),d.jsxs("div",{className:"flex shrink-0 gap-1 overflow-x-auto border-b border-zinc-100 bg-zinc-50/70 px-3 py-2",children:[(At=s.data)==null?void 0:At.bots.map(se=>d.jsxs("button",{type:"button",onClick:()=>{h(se.appId),p(se.setupComplete?1:2)},className:`flex h-8 max-w-[250px] shrink-0 items-center gap-1.5 rounded-lg px-2.5 text-[12px] font-medium transition-colors ${u===se.appId?"bg-white text-zinc-900 shadow-sm ring-1 ring-zinc-200":"text-zinc-500 hover:bg-white/70 hover:text-zinc-800"}`,children:[se.avatarUrl?d.jsx(YH,{url:se.avatarUrl,size:13,className:"h-[13px] w-[13px] shrink-0 rounded-sm object-cover"}):d.jsx(ti,{size:13,className:"shrink-0"}),d.jsx("span",{title:se.name,className:"min-w-0 max-w-32 truncate",children:se.tabLabel}),se.setupComplete?d.jsxs("span",{title:"配置完成",className:"flex shrink-0 items-center gap-0.5 rounded bg-emerald-50 px-1 py-0.5 text-[12px] font-medium text-emerald-700",children:[d.jsx(gi,{size:9}),"已配置"]}):d.jsx("span",{className:"shrink-0 rounded bg-amber-100 px-1 py-0.5 text-[12px] text-amber-700",children:"待配置"}),se.activeListening&&d.jsx("span",{title:"长连接已连接",className:"h-1.5 w-1.5 shrink-0 rounded-full bg-emerald-500"})]},se.appId)),d.jsxs("button",{type:"button",onClick:()=>{h(""),p(1)},className:`flex h-8 shrink-0 items-center gap-1 rounded-lg px-2.5 text-[12px] font-medium ${u===""?"bg-white text-zinc-900 shadow-sm ring-1 ring-zinc-200":"text-zinc-500 hover:bg-white/70 hover:text-zinc-800"}`,children:[d.jsx(sa,{size:13}),"新增机器人"]})]}),d.jsxs("div",{className:"space-y-3.5 overflow-y-auto px-4 py-4",children:[d.jsx(fl,{placeholder:d.jsx("div",{className:"min-h-[420px]",children:d.jsx(pl,{})}),children:s.isLoading?d.jsxs("div",{className:"space-y-2.5",children:[d.jsx("div",{className:"h-9 ui-skeleton rounded-md bg-zinc-100"}),d.jsx("div",{className:"h-9 ui-skeleton rounded-md bg-zinc-100"}),d.jsx("div",{className:"h-9 ui-skeleton rounded-md bg-zinc-100"})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"mb-1 grid grid-cols-2 rounded-lg bg-zinc-100 p-1",children:[d.jsxs("button",{type:"button",onClick:()=>p(1),className:`rounded-md px-3 py-2 text-[12px] font-medium transition-colors ${f===1?"bg-white text-zinc-900 shadow-sm":"text-zinc-500"}`,children:[d.jsx("span",{className:"mr-1.5 inline-grid h-4 w-4 place-items-center rounded-full bg-zinc-900 text-[12px] text-white",children:"1"}),"飞书与白名单"]}),d.jsxs("button",{type:"button",disabled:!xe&&!Ye,onClick:()=>p(2),className:`rounded-md px-3 py-2 text-[12px] font-medium transition-colors disabled:opacity-40 ${f===2?"bg-white text-zinc-900 shadow-sm":"text-zinc-500"}`,children:[d.jsx("span",{className:"mr-1.5 inline-grid h-4 w-4 place-items-center rounded-full bg-zinc-900 text-[12px] text-white",children:"2"}),"Agent 与门禁"]})]}),d.jsx("p",{className:"-mt-1 text-[12px] leading-4 text-zinc-400",children:f===1?"点「下一步」继续配置 Agent,最后点「保存」才会一次性生效;指定成员和机器人的姓名在实际使用时再校验。":"Agent 配置不影响长连接;收到消息时才会校验运行配置。"}),f===1?d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[d.jsxs("label",{className:"block",children:[d.jsx("span",{className:"text-[12px] font-medium text-zinc-700",children:"机器人名称"}),d.jsx(Qn,{size:"large",value:g,readOnly:!0,variant:"filled",placeholder:"校验凭证后自动识别",className:"mt-1.5 font-mono text-[12px]"})]}),d.jsxs("label",{className:"block",children:[d.jsx("span",{className:"text-[12px] font-medium text-zinc-700",children:"App ID"}),d.jsx(Qn,{size:"large",value:S,onChange:se=>{C(se.target.value),x("")},placeholder:"cli_xxx",autoComplete:"off",className:"mt-1.5 font-mono text-[12px]"})]})]}),d.jsxs("label",{className:"block",children:[d.jsxs("span",{className:"flex items-center text-[12px] font-medium text-zinc-700",children:["App Secret",xe&&d.jsx("span",{className:"ml-2 font-normal text-zinc-400",children:"留空不修改"})]}),d.jsx(Qn.Password,{size:"large",value:_,onChange:se=>k(se.target.value),visibilityToggle:{visible:Ce,onVisibleChange:Pe},iconRender:se=>se?d.jsx(TZ,{size:13}):d.jsx(Bg,{size:13}),placeholder:xe?"已保存":"输入 App Secret",autoComplete:"new-password",className:"mt-1.5 font-mono text-[12px]"})]}),d.jsxs("div",{children:[d.jsxs("span",{className:"text-[12px] font-medium text-zinc-700",children:["工作区 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选"})]}),d.jsxs("div",{className:"flex items-start gap-2",children:[d.jsx("div",{className:"min-w-0 flex-1",children:d.jsx(IE,{value:v,onChange:b,label:"工作区",placeholder:"留空使用默认工作目录",suggestion:Ze,suggestionLabel:"使用默认工作目录"})}),d.jsxs("button",{type:"button",disabled:!((He=o.data)!=null&&He.directoryPicker)||ke.isPending,onClick:()=>ke.mutate(),className:"mt-1.5 flex h-9 shrink-0 items-center gap-1.5 rounded-md border border-zinc-300 bg-white px-3 text-[12px] font-medium text-zinc-700 hover:bg-zinc-50 disabled:cursor-not-allowed disabled:opacity-40",children:[d.jsx(ha,{size:13}),(it=o.data)!=null&&it.directoryPicker?"选择":"仅支持 Mac"]})]}),d.jsx("p",{className:"mt-1 text-[12px] leading-4 text-zinc-400",children:"留空时使用所选 Agent 的默认工作目录;路径位于 AgentDock 服务所在机器。"})]}),d.jsxs("div",{className:"block",children:[d.jsxs("span",{className:"text-[12px] font-medium text-zinc-700",children:["Web 访问地址 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选"})]}),d.jsx(ume,{value:y,onChange:w}),d.jsx("p",{className:"mt-1 text-[12px] leading-4 text-zinc-400",children:"配置后,飞书卡片底部会显示“查看详情”链接,指向该域名下的会话 Trace 页面。"})]}),!xe&&d.jsxs("button",{type:"button",disabled:!S.trim()||!_.trim()||tt.isPending,onClick:()=>tt.mutate(),className:"flex h-9 w-full items-center justify-center gap-2 rounded-md border border-zinc-300 bg-white text-[12px] font-medium text-zinc-700 hover:bg-zinc-50 disabled:opacity-40",children:[tt.isPending?d.jsx(Hn,{size:12,className:"animate-spin"}):d.jsx(ti,{size:12}),"校验凭证并识别机器人名称"]}),d.jsxs("div",{className:"overflow-hidden rounded-xl border border-zinc-200 bg-white",children:[d.jsx(fi,{title:"可使用机器人的成员",description:"输入飞书真实姓名;收到消息时再解析为稳定的 open_id,不读取邮箱。",children:d.jsx(F5,{value:j?"restricted":"all",onChange:se=>z(se==="restricted"),options:[{value:"all",label:"所有人"},{value:"restricted",label:"指定成员"}]})}),j&&d.jsxs("div",{className:"border-t border-zinc-100 px-4 pb-3.5 pt-3",children:[!!(xe!=null&&xe.allowedEmails.length&&!xe.allowedUsers.length)&&d.jsx("div",{className:"mb-2 border-l-2 border-amber-400 bg-amber-50 px-2.5 py-2 text-[12px] leading-5 text-amber-800",children:"检测到旧邮箱白名单。请重新填写真实姓名;保存后改用姓名白名单,使用时解析 open_id,停止查询通讯录。"}),d.jsxs("div",{children:[d.jsx("div",{className:"text-[12px] font-medium text-zinc-500",children:"成员真实姓名"}),d.jsx(l_,{value:N,onChange:I,placeholder:"输入姓名后按 Enter"}),d.jsx("p",{className:"mt-1 text-[12px] leading-5 text-zinc-400",children:"支持 Enter、逗号或粘贴多行生成标签。保存时不查询群成员;使用时精确匹配,找不到或重名时拒绝访问。"})]})]})]}),d.jsxs("div",{className:"overflow-hidden rounded-xl border border-zinc-200 bg-white",children:[d.jsx(fi,{title:"可调用机器人的其他机器人",description:"输入机器人名称;收到调用时再在群成员中解析 open_id。",children:d.jsx(F5,{value:E?"all":"restricted",onChange:se=>M(se==="all"),options:[{value:"all",label:"所有机器人"},{value:"restricted",label:"指定机器人"}]})}),!E&&d.jsx("div",{className:"border-t border-zinc-100 px-4 pb-3.5 pt-3",children:d.jsxs("div",{children:[d.jsx("div",{className:"text-[12px] font-medium text-zinc-500",children:"机器人名称"}),d.jsx(l_,{value:$,onChange:R,placeholder:"输入机器人名称后按 Enter"})]})})]}),d.jsxs("div",{className:"overflow-hidden rounded-xl border border-zinc-200 bg-white",children:[d.jsxs("div",{className:"px-4 py-3",children:[d.jsx("div",{className:"text-[14px] font-medium text-zinc-900",children:"Trace 卡片"}),d.jsx("div",{className:"mt-0.5 text-[12px] leading-5 text-zinc-500",children:"控制任务过程中推送的 trace 卡片如何渲染与刷新。"})]}),d.jsx(fi,{title:"静默回复(不显示 trace 卡片)",description:"不发送 trace 卡片,任务结束时由服务自动把最终回复以文本发送到会话;Agent 会被提示如何在本模式下 @ 他人。",children:d.jsx(js,{size:"small",checked:_e,onChange:()=>$e(se=>!se)})}),!_e&&d.jsxs(d.Fragment,{children:[d.jsx(fi,{title:"飞书推送间隔",description:"500-20000 ms;心跳消息的最短间隔。",children:d.jsx(Fx,{size:"middle",min:500,max:2e4,step:100,value:de,onChange:se=>Le(se??1e3),suffix:"ms",className:"!w-40 font-mono"})}),d.jsx(fi,{title:"Trace 阶段上限",description:`默认 ${Lw};心跳渲染时最多保留最近 N 个执行阶段,超过飞书 24KB / 180 组件限制时仍会自动裁剪较早记录。`,children:d.jsx(Fx,{size:"middle",min:1,max:200,step:1,precision:0,value:te===""?null:Number(te),onChange:se=>me(se==null?"":String(se)),className:"!w-40 font-mono"})})]})]}),d.jsx("div",{className:"overflow-hidden rounded-xl border border-zinc-200 bg-white",children:d.jsx(fi,{className:(jt=s.data)!=null&&jt.listeningDisabled||!Ge?"opacity-50":"",title:"监听飞书消息",description:(St=s.data)!=null&&St.listeningDisabled?"本次启动已通过 --no-lark-listen 禁用,保存值不受影响":Ge?xe!=null&&xe.activeListening?"长连接已连接":xe!=null&&xe.setupComplete?"使用长连接接收机器人消息":"可先监听;收到消息时再校验 Agent 运行配置":"请先填写飞书凭证",children:d.jsx(js,{size:"small",checked:Ie&&!((It=s.data)!=null&&It.listeningDisabled),disabled:((Rn=s.data)==null?void 0:Rn.listeningDisabled)||!Ge,onChange:()=>Te(se=>!se)})})})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"overflow-hidden rounded-xl border border-zinc-200 bg-white",children:[d.jsx(fi,{title:"默认 Agent",description:Me?"硬门禁已开启,保存关闭后解锁。":"飞书会话默认使用的 Agent。",children:d.jsx("div",{className:"w-64",children:d.jsx(yLe,{size:"sm",popupWidth:360,agents:e,value:P,disabled:Me,onChange:se=>{A(se),F(""),B(""),ce(!1),fe(!1)}})})}),d.jsx(fi,{title:"默认模型",description:!Ee.isFetching&&!((Tn=Ee.data)!=null&&Tn.models.length)?"暂未取得可选模型,保留当前配置;可尝试重新读取。":"由 Agent 提供,可覆盖 Agent 默认模型。",children:d.jsx("div",{className:"w-64",children:d.jsx(ua,{size:"sm",popupWidth:380,options:[{value:"",label:(Sn=Ee.data)!=null&&Sn.defaultModel?`Agent 默认 (${Ee.data.defaultModel})`:"使用 Agent 默认模型"},...Gx(((mr=Ee.data)==null?void 0:mr.models)??[],D).map(se=>({value:se.id,label:se.name,meta:se.name===se.id?void 0:se.id}))],value:D,placeholder:"选择默认模型",disabled:!((qn=Ee.data)!=null&&qn.models.length),disabledText:"",onChange:se=>{F(se),B("")}})})}),d.jsx(fi,{title:"推理强度",description:!Ee.isFetching&&!((nr=Ee.data)!=null&&nr.reasoningEfforts.length)?"该 Agent / 模型暂未提供可选强度,保留当前配置。":"由 Agent / 模型提供。",children:d.jsx("div",{className:"w-64",children:d.jsx(ua,{size:"sm",popupWidth:300,options:[{value:"",label:(Ur=Ee.data)!=null&&Ur.defaultReasoningEffort?`Agent 默认 (${Ee.data.defaultReasoningEffort})`:"使用 Agent 默认强度"},...Gx(((_r=Ee.data)==null?void 0:_r.reasoningEfforts)??[],nt).map(se=>({value:se.id,label:se.name}))],value:nt,placeholder:"选择推理强度",disabled:!((ci=Ee.data)!=null&&ci.reasoningEfforts.length),disabledText:"",onChange:B})})}),d.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-zinc-100 px-4 py-2 text-[12px] text-zinc-400",children:[d.jsx("span",{children:Ee.isFetching||Se.isPending?"正在读取 Agent 配置…":"模型与推理强度由 Agent 提供"}),d.jsxs("button",{type:"button",disabled:!P||Ee.isFetching||Se.isPending,onClick:()=>Se.mutate({agentId:P,model:D||void 0}),className:"flex h-7 items-center gap-1 rounded px-1.5 text-[12px] text-zinc-500 hover:bg-zinc-100 disabled:opacity-40",children:[d.jsx(Hn,{size:12}),"重新读取"]})]}),(((Rr=Ee.data)==null?void 0:Rr.warning)||Ee.isError||Se.isError)&&d.jsx("p",{role:"status",className:"mx-4 mb-3 border-l-2 border-amber-300 bg-amber-50 px-2 py-1.5 text-[12px] leading-5 text-amber-800",children:((rr=Ee.data)==null?void 0:rr.warning)??"Agent 配置请求失败,请检查服务连接后重新读取。"})]}),d.jsxs("div",{children:[d.jsxs("span",{className:"text-[12px] font-medium text-zinc-700",children:["预注入 Prompt ",d.jsx("span",{className:"font-normal text-zinc-400",children:"可选,Markdown"})]}),d.jsx(m.Suspense,{fallback:d.jsx("div",{className:"mt-1.5 rounded-md border border-zinc-200 bg-zinc-50 p-3 text-[12px] text-zinc-400",children:"正在加载编辑器…"}),children:d.jsx(mLe,{value:V,onChange:T,aiContext:Qe})}),d.jsx("p",{className:"mt-1 text-[12px] leading-5 text-zinc-400",children:"每轮飞书对话都会在用户请求前隐式注入,不会在 Agent 聊天记录中重复显示为用户消息。"})]}),d.jsxs("div",{className:"overflow-hidden rounded-xl border border-zinc-200 bg-white",children:[d.jsx(fi,{title:"启用 Agent 群协作工具",description:"允许 Agent 在当前飞书群发现其他已配置 Agent,并读取增量消息。",children:d.jsx(js,{size:"small",checked:W,onChange:()=>L(se=>!se)})}),W&&d.jsx(fi,{title:"允许 Agent 发消息与 @交接",description:"关闭后仅保留 self、peers、messages 和 wait 只读能力。",children:d.jsx(js,{size:"small",checked:q,onChange:()=>X(se=>!se)})}),W&&d.jsx(fi,{title:"群聊主流消息的会话隔离",description:"话题内消息始终按话题隔离;此处仅影响群主流(非话题)消息。",children:d.jsx(bLe,{value:J,onChange:se=>ae(se),options:[{value:"user",label:"按发送人隔离"},{value:"chat",label:"全群共享"}]})}),d.jsxs("div",{className:"flex items-start gap-1.5 border-t border-zinc-100 px-4 py-3 text-[12px] leading-5 text-zinc-500",children:[d.jsx(HZ,{size:14,className:"mt-0.5 shrink-0"}),d.jsx("span",{children:"缺少群成员、消息或发消息权限时,Agent 会停止对应操作并给出管理员授权链接;不会索要 App Secret。"})]})]}),d.jsx("div",{className:"overflow-hidden rounded-xl border border-zinc-200 bg-white",children:d.jsx(fi,{title:"启用高危操作门禁",description:"启用后强制开启软门禁,并可继续配置 Hook 硬门禁。",children:d.jsx(js,{size:"small",checked:oe,onChange:()=>{const se=!oe;ge(se),se||ce(!1)}})})}),oe&&d.jsxs("div",{className:"rounded-xl border border-zinc-200 bg-zinc-50/70 p-3",children:[d.jsx("div",{className:"px-1 text-[14px] font-medium text-zinc-900",children:"高危操作门禁"}),d.jsx("p",{className:"mt-1 px-1 text-[12px] leading-5 text-zinc-500",children:"不在允许名单内的发送人会收到软门禁 Prompt;开启硬门禁后,再通过 ACP 权限层和 Agent 原生工具调用 Hook 拦截。"}),d.jsxs("div",{className:"mt-3",children:[d.jsxs("div",{className:"text-[12px] font-medium text-zinc-700",children:["允许执行高危操作的成员 ",d.jsx("span",{className:"font-normal text-zinc-400",children:"留空则继承普通成员名单"})]}),d.jsx("p",{className:"mt-0.5 text-[12px] leading-5 text-zinc-500",children:"输入真实姓名,保存时解析为 open_id。"}),rt&&d.jsx("div",{className:"mt-2 border-l-2 border-amber-400 bg-amber-50 px-2.5 py-2 text-[12px] leading-5 text-amber-800",children:"检测到旧高危邮箱名单。请重新选择成员后再保存,避免意外扩大高危权限。"}),d.jsx(l_,{value:ne,onChange:re,placeholder:"输入姓名后按 Enter"})]}),d.jsxs("label",{className:"mt-3 block",children:[d.jsx("span",{className:"text-[12px] font-medium text-zinc-700",children:"高危操作正则表达式"}),d.jsx(Qn.TextArea,{value:ie,onChange:se=>G(se.target.value),autoSize:{minRows:4,maxRows:10},status:pe.valid?void 0:"error",className:"mt-1.5 font-mono text-[12px] leading-5"}),!pe.valid&&d.jsxs("p",{className:"mt-1.5 flex items-start gap-1 text-[12px] leading-5 text-red-600",children:[d.jsx(al,{size:12,className:"mt-0.5 shrink-0"}),pe.error]})]}),d.jsxs("div",{className:"mt-3 overflow-hidden rounded-lg border border-zinc-200 bg-white",children:[d.jsx(fi,{title:"软门禁",description:"门禁启用后固定开启,隐式注入禁止绕过的安全 Prompt。",children:d.jsx(js,{size:"small",checked:!0,disabled:!0})}),d.jsx(fi,{className:!((Cr=ye.data)!=null&&Cr.installed)&&!U?"opacity-60":"",title:"硬门禁",description:(kr=ye.data)!=null&&kr.installed?"Hook 已配置,可以开启硬门禁。":le?((Nr=ye.data)==null?void 0:Nr.reason)??"请先检测并配置 Hook。":"点击下方按钮会先保存当前默认 Agent,再检测并配置 Hook。",children:d.jsx(js,{size:"small",checked:U,disabled:!xt,onChange:()=>ce(se=>!se)})})]}),Mt&&d.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2.5 py-2 text-[12px] leading-5 text-amber-800",children:"已保存的硬门禁 Hook 当前未检测到。其他设置仍可保存;如需恢复硬门禁,请先关闭上方开关,再重新检测并配置 Hook。"}),d.jsxs("button",{type:"button",disabled:!xe||U||ue.isPending||rt||!v.trim()||!pe.valid||((Kr=ye.data)==null?void 0:Kr.supported)===!1,onClick:()=>ue.mutate(),className:"mt-3 flex h-9 w-full items-center justify-center gap-2 rounded-md border border-zinc-300 bg-white text-[12px] font-medium text-zinc-700 hover:bg-zinc-50 disabled:cursor-not-allowed disabled:opacity-40",children:[d.jsx(gN,{size:13}),ue.isPending?"正在检测并配置 Hook":(ui=ye.data)!=null&&ui.installed?"重新检测并配置 Hook":"检测并配置 Hook"]}),((Ft=ye.data)==null?void 0:Ft.supported)===!1&&d.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2.5 py-2 text-[12px] leading-5 text-amber-800",children:ye.data.reason}),((Rt=ye.data)==null?void 0:Rt.trustInstructions)&&d.jsx("div",{className:"mt-2 rounded-md border border-zinc-200 bg-white px-3 py-2 text-[12px] leading-5 text-zinc-500",children:ye.data.trustInstructions})]})]})]})}),qe&&d.jsxs("div",{className:"rounded-md border border-red-100 bg-red-50 px-2.5 py-2 text-[12px] leading-4 text-red-700",children:[d.jsx("div",{children:qe.message}),Gt&&$t&&d.jsxs("a",{href:$t,target:"_blank",rel:"noreferrer",className:"mt-2 inline-flex items-center gap-1 font-medium text-red-800 underline decoration-red-300 underline-offset-2 hover:text-red-950",children:["打开当前机器人的权限配置",d.jsx(Ja,{size:11})]})]})]}),d.jsxs("div",{className:"flex items-center border-t border-zinc-100 px-4 py-3",children:[xe?d.jsxs("button",{type:"button",onClick:()=>{Oe.reset(),l("delete")},className:"flex items-center gap-1.5 rounded-md px-2 py-1.5 text-[12px] font-medium text-red-600 hover:bg-red-50",children:[d.jsx(kf,{size:13}),"删除配置"]}):d.jsx("span",{className:"text-[12px] text-zinc-400",children:"App ID 将作为唯一主键,不能重复配置"}),f===2&&d.jsx("button",{type:"button",onClick:()=>p(1),className:"ml-auto rounded-md px-3 py-1.5 text-xs font-medium text-zinc-600 hover:bg-zinc-100",children:"上一步"}),d.jsx("button",{type:"button",onClick:Qt,className:`${f===2?"":"ml-auto"} rounded-md px-3 py-1.5 text-xs font-medium text-zinc-600 hover:bg-zinc-100`,children:f===2&&xe&&!xe.setupComplete?"稍后完成":"取消"}),d.jsx("button",{type:"submit",disabled:!Q||ft.isPending,className:"ml-1 min-w-20 rounded-md bg-zinc-900 px-3 py-1.5 text-xs font-medium text-white hover:bg-zinc-700 active:scale-[.98] disabled:cursor-not-allowed disabled:opacity-35",children:ft.isPending?"保存中":pt?"读取模型中":Re?"下一步":"保存"})]})]})}),d.jsx(To,{open:!!a,tone:a==="delete"?"danger":"warning",title:a==="delete"?"删除机器人配置?":a==="incomplete"?"稍后再完成配置?":"放弃未保存的配置?",description:a==="delete"?`将删除“${(xe==null?void 0:xe.name)??"当前机器人"}”的凭证、监听和门禁配置。已有会话记录不会删除。`:a==="incomplete"?"Agent 配置尚未完成。若已开启监听,机器人仍会接收消息,并提示发送人补充运行配置。":"当前填写的机器人信息尚未保存,关闭后需要重新填写。",confirmLabel:a==="delete"?"确认删除":a==="incomplete"?"稍后完成":"放弃修改",busy:a==="delete"&&Oe.isPending,error:a==="delete"&&Oe.error?Oe.error.message:void 0,onCancel:()=>{Oe.isPending||l(void 0)},onConfirm:()=>{a==="delete"?Oe.mutate():(l(void 0),t())}})]})}function SLe({onClose:e}){return d.jsx("div",{className:"ui-overlay fixed inset-0 z-[60] grid place-items-center bg-zinc-950/30 p-2 sm:p-4",onMouseDown:t=>{t.currentTarget===t.target&&e()},children:d.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"AI 飞书替身",className:"ui-dialog flex h-[min(860px,calc(100dvh-2rem))] w-full max-w-[1120px] flex-col overflow-hidden rounded-[14px] border border-zinc-200 bg-white shadow-xl",children:[d.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-100 px-4 py-3",children:[d.jsx("h2",{className:"text-[16px] font-semibold text-zinc-900",children:"AI 飞书替身"}),d.jsx("button",{type:"button","aria-label":"关闭 AI 飞书替身",onClick:e,className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-500 hover:bg-zinc-100",children:d.jsx(Wn,{size:15})})]}),d.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:d.jsx(cme,{})})]})})}function _Le({session:e,size:t=12}){return Ka.has(e.state)&&e.state!=="waiting_for_permission"?d.jsx(_i,{size:t,"aria-label":Ym[e.state],className:`shrink-0 animate-spin ${N1e[e.state]??"text-zinc-400"}`}):d.jsx("span",{"aria-label":Ym[e.state],className:`h-1.5 w-1.5 shrink-0 rounded-full ${ej[e.state]??"bg-zinc-400"}`})}function CLe({session:e,agent:t,botName:n,parentLabel:r,active:i,drag:s,noteOf:o,onClick:a}){const l=JE(e),c=!!YE(e),u=(t==null?void 0:t.name)??e.agentId,h=lc(e,t==null?void 0:t.name),f=d.jsx(g3e,{session:e,agentName:u,botName:n,parentLabel:r,now:new Date}),p=Ka.has(e.state)||e.state==="failed",g=p?d.jsx(_Le,{session:e,size:12}):d.jsx("span",{className:"text-[12px] tabular-nums text-zinc-400 transition-opacity group-hover:opacity-0 max-md:hidden",children:d1e(Gm(e))}),x=d.jsxs("div",{onClick:a,role:"button",tabIndex:0,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),a())},...(s==null?void 0:s.props)??{},className:`group relative flex h-[34px] w-full cursor-pointer items-center gap-2 rounded-lg px-2 text-left transition-colors ${i?"bg-zinc-100 text-zinc-900":"text-zinc-700 hover:bg-zinc-100/60"} ${s!=null&&s.dragging?"opacity-40":""} ${s!=null&&s.over?"ring-1 ring-zinc-300":""}`,children:[l?d.jsx(ol,{size:12,"aria-label":"定时任务会话",className:"shrink-0 text-zinc-400"}):o?d.jsx(Wb,{size:12,"aria-label":`${o}派出的便签`,className:"shrink-0 text-amber-600/80"}):c?d.jsx(Bb,{size:12,"aria-label":"侧边会话",className:"shrink-0 text-zinc-400"}):null,d.jsx(o1e,{session:e,label:h,nameClassName:"min-w-0 flex-1 truncate text-[14px]",editButtonVisible:!p}),d.jsx("span",{className:"flex shrink-0 items-center justify-end",children:g})]});return d.jsx(rn,{content:f,side:"right",align:"start",hoverOnly:!0,children:x})}function kLe(){var Re,Q,Ge,qe,$t,Gt,Qt,Yt;const e=Ln(),{primarySessionId:t,setSession:n,openTab:r,closeTab:i,activateTab:s,renameTab:o,restoreFromUrl:a,togglePane:l}=Js(),c=Js(Y=>Y.tabs),u=m.useMemo(()=>c.filter(Y=>Y.ownerSessionId===t),[c,t]),h=Js(Y=>Y.paneOpen),f=Js(Y=>Y.activeTabId),p=u.find(Y=>Y.id===f),[g,x]=m.useState();yr("agentdock:web-access-denied",Y=>{x(Y.detail),e.cancelQueries({predicate:g1e})},{target:()=>window});const[v,b]=m.useState(!1),[y,w]=m.useState(new Set),[S,C]=m.useState(new Set),[_,k]=m.useState("all"),j=r1e(),z=Et({queryKey:["agents"],queryFn:()=>we.agents(),enabled:!g}),N=Et({queryKey:["sessions"],queryFn:we.sessions,enabled:!g,refetchInterval:g?!1:2e3,refetchIntervalInBackground:!0}),I=Et({queryKey:["lark-config"],queryFn:we.larkConfig,enabled:!g,refetchInterval:g?!1:5e3});Et({queryKey:["system-capabilities"],queryFn:we.systemCapabilities,enabled:!g});const $=Hy(!g),R=()=>{const Y=window.location.pathname.match(/^\/sessions\/([^/]+)$/),Ae=Y!=null&&Y[1]?decodeURIComponent(Y[1]):void 0,et=t1e(window.location.search,Ae);if(!et||!Ae){a(Ae);return}if(et.kind==="session"){et.sessionId&&a(Ae,dk(Ae,et.sessionId,et.sessionId));return}a(Ae,{id:`${et.kind}:${Ae}`,kind:et.kind,anchorSessionId:Ae,title:et.kind==="terminal"?"终端":et.kind==="files"?"文件":"原始日志"})};Db(R),yr("popstate",R),Pu(()=>{window.history.replaceState(null,"",e1e(t,h?p:void 0))},[t,f,u,h]);const E=m.useMemo(()=>[...N.data??[]].sort((Y,Ae)=>Gm(Ae).localeCompare(Gm(Y))),[N.data]),M=m.useMemo(()=>E.filter(Y=>{var Ae,et;return Y.id!==((Ae=$.data)==null?void 0:Ae.mainSessionId)&&!Y.archivedAt&&(_==="all"||_==="local"?_==="all"||Y.source!=="lark":Y.source==="lark"&&((et=Y.sourceId)==null?void 0:et.startsWith(`${_}:`)))}),[E,_,(Re=$.data)==null?void 0:Re.mainSessionId]),P=m.useMemo(()=>E.filter(Y=>Y.archivedAt),[E]),A=m.useMemo(()=>l1e(M,z.data??[]),[M,z.data]),D=((Q=$.data)==null?void 0:Q.mainSessionId)??void 0,[F,O]=th("agentdock:sidebar-item-order",{defaultValue:NP}),B=m.useMemo(()=>sv(F),[F]),V=m.useMemo(()=>Vw(A,B.workspaces,Y=>Y.cwd).map(Y=>({...Y,agents:Vw(Y.agents,B.agents[Y.cwd],Ae=>Ae.agentId).map(Ae=>({...Ae,sessions:Vw(Ae.sessions,B.sessions[`${Y.cwd}\0${Ae.agentId}`],et=>et.id)}))})),[A,B]),T=m.useMemo(()=>!h1e(A,V),[A,V]),[W,L]=th("agentdock:sidebar-grouping",{defaultValue:"time"}),q=W==="project"?"project":"time",X=m.useRef(null),J=bn(()=>{zt.getState().setHomeTarget("new"),n(void 0),Te(!1),b(!1),Se(void 0),requestAnimationFrame(()=>{var Y;return(Y=X.current)==null?void 0:Y.focus()})}),ae=bn(()=>{b(!1),xr("search")});yr("keydown",Y=>{(Y.metaKey||Y.ctrlKey)&&Y.key.toLowerCase()==="k"&&(Y.preventDefault(),ae())});const ne=Y=>w(Ae=>{const et=new Set(Ae);return et.has(Y)?et.delete(Y):et.add(Y),et}),re=Y=>C(Ae=>{const et=new Set(Ae);return et.has(Y)?et.delete(Y):et.add(Y),et}),ie=m.useRef(!1);Pu(()=>{ie.current||!A.length||(ie.current=!0,w(new Set(A.slice(1).map(Y=>Y.cwd))))},[A]);const G=E.find(Y=>Y.id===t);p1e(G?lc(G,(qe=(Ge=z.data)==null?void 0:Ge.find(Y=>Y.id===G.agentId))==null?void 0:qe.name):void 0);const oe=Y=>{n(Y),b(!1),Se(void 0)},ge=Y=>{var et,Tt;if(!t||Y===t)return;const Ae=E.find(dt=>dt.id===Y);Ae&&r(dk(t,Y,lc(Ae,(Tt=(et=z.data)==null?void 0:et.find(dt=>dt.id===Ae.agentId))==null?void 0:Tt.name)),t)};Pu(()=>{var Y,Ae;for(const et of c){if(et.kind!=="session"&&et.kind!=="side-chat")continue;const Tt=E.find(dt=>dt.id===et.sessionId);Tt&&o(et.id,lc(Tt,(Ae=(Y=z.data)==null?void 0:Y.find(dt=>dt.id===Tt.agentId))==null?void 0:Ae.name))}},[c,E,z.data]);const U=bn(Y=>{t&&r({id:`raw:${Y}`,kind:"raw",anchorSessionId:Y,title:Y===t?"原始日志":"侧边日志"},t)}),ce=bn(Y=>{if(Se(void 0),!!t){if(Y==="raw"){const Ae=u.find(et=>et.id===f);U((Ae==null?void 0:Ae.sessionId)??(Ae==null?void 0:Ae.anchorSessionId)??t);return}if(Y==="terminal"||Y==="files"){r({id:`${Y}:${t}`,kind:Y,anchorSessionId:t,title:Y==="terminal"?"终端":"文件"});return}G&&ve.mutate(G)}}),ve=yt({mutationFn:async Y=>we.create({agentId:Y.agentId,cwd:Y.cwd,systemPrompt:_ye(Y.id),source:Q9,sourceId:Y.id}),onSuccess:(Y,Ae)=>{e.invalidateQueries({queryKey:["sessions"]}),r({id:`side-chat:${Y.id}`,kind:"side-chat",sessionId:Y.id,title:"侧边聊天"},Ae.id)},onError:Y=>at(Y instanceof Error?Y.message:String(Y))}),fe=[{key:"t",label:Bw("t"),description:"终端",run:()=>ce("terminal")},{key:"s",shift:!0,label:Bw("s",!0),description:"侧边聊天",run:()=>ce("side-chat")},{key:"p",label:Bw("p"),description:"文件",run:()=>ce("files")}];Sye(fe);const[Ce,Pe]=th("agentdock:sidebar-width",{defaultValue:268}),[Ie,Te]=th("agentdock:sidebar-collapsed",{defaultValue:!1}),[de,Le]=m.useState(),[te,me]=m.useState(),[_e,$e]=m.useState(!1),xe=m.useRef({x:0,width:268}),Ze=Math.min(480,Math.max(200,Ce??268));yr("pointermove",Y=>{if(!_e)return;const Ae=Math.min(560,Math.max(140,xe.current.width+(Y.clientX-xe.current.x)));Pe(Ae)},{target:()=>document,enable:_e}),yr("pointerup",()=>{_e&&($e(!1),(Ce??268)<180&&Te(!0))},{target:()=>document,enable:_e});const[le,Me]=m.useState(null),[pe,ye]=m.useState(),[Ee,Se]=m.useState(),[De,at]=m.useState(),xt=yt({mutationFn:({agentId:Y,cwd:Ae})=>we.create({agentId:Y,cwd:Ae}),onMutate:Y=>ye(Y),onSuccess:Y=>{e.invalidateQueries({queryKey:["sessions"]}),ye(void 0),Me(null),oe(Y.id)},onError:()=>ye(void 0)}),Mt=bn(()=>{zt.getState().requestAdoption(),n(void 0),b(!1),Se(void 0)}),rt=bn(Y=>{const Ae=Y??D;if(!Ae){Mt();return}if(zt.getState().closeDrawer(),t===Ae){b(!1);return}mwe(()=>oe(Ae))}),nt=bn((Y,Ae="auto")=>{if(!Y.sessionId){zt.getState().openDrawer({highlight:Y.id});return}const et=E.find(dt=>dt.id===Y.sessionId);if((Ae==="pane"||Ae==="auto"&&!!t&&t===D)&&t&&et&&Y.sessionId!==t){ge(Y.sessionId);return}oe(Y.sessionId)}),Qe=bn(()=>{b(!1),xr("assistant")}),tt=bn(Y=>{zt.getState().closeDrawer(),oe(Y)}),ft=m.useMemo(()=>({openMain:rt,openTask:nt,goAdopt:Mt,openSettings:Qe,openSession:tt}),[rt,nt,Mt,Qe,tt]),ue=G?G.id===D?"main":"session":"home";if(g)return d.jsx(x1e,{denied:g});const Oe=(Y,Ae,et,Tt)=>{const dt=(de==null?void 0:de.scope)===Y&&de.id===Ae,At=(te==null?void 0:te.scope)===Y&&te.id===Ae;return{dragging:dt,over:At,props:{draggable:!0,onDragStart:He=>{Le({scope:Y,id:Ae,...Tt?{sessionId:Tt}:{}}),He.dataTransfer.effectAllowed="move"},onDragEnd:()=>{Le(void 0),me(void 0)},onDragOver:He=>{!de||de.scope!==Y||de.id===Ae||(He.preventDefault(),He.dataTransfer.dropEffect="move",me(it=>(it==null?void 0:it.scope)===Y&&it.id===Ae?it:{scope:Y,id:Ae}))},onDragLeave:()=>me(He=>(He==null?void 0:He.scope)===Y&&He.id===Ae?void 0:He),onDrop:He=>{He.preventDefault(),de&&de.scope===Y&&de.id!==Ae&&et(de.id,Ae),Le(void 0),me(void 0)}}}},ke=Y=>({dragging:(de==null?void 0:de.scope)==="session-pane"&&de.id===Y,over:!1,props:{draggable:!0,onDragStart:Ae=>{Le({scope:"session-pane",id:Y,sessionId:Y}),Ae.dataTransfer.effectAllowed="copy"},onDragEnd:()=>{Le(void 0),me(void 0)}}}),pt=(Y,Ae)=>O(et=>{const Tt=V.map(dt=>dt.cwd);return{...sv(et),workspaces:Hw(Tt,Y,Ae)}}),mt=(Y,Ae,et)=>O(Tt=>{var He;const dt=(((He=V.find(it=>it.cwd===Y))==null?void 0:He.agents)??[]).map(it=>it.agentId),At=sv(Tt);return{...At,agents:{...At.agents,[Y]:Hw(dt,Ae,et)}}}),Ye=(Y,Ae,et)=>O(Tt=>{var jt,St;const[dt,At]=Y.split("\0"),He=(((St=(jt=V.find(It=>It.cwd===dt))==null?void 0:jt.agents.find(It=>It.agentId===At))==null?void 0:St.sessions)??[]).map(It=>It.id),it=sv(Tt);return{...it,sessions:{...it.sessions,[Y]:Hw(He,Ae,et)}}}),ze=(Y,Ae)=>{var dt,At,He,it,jt,St,It,Rn,Tn;const et=Y.sourceId?E.find(Sn=>Sn.id===Y.sourceId):void 0,Tt=D&&Zwe(Y.sourceId,D,(At=(dt=$.data)==null?void 0:dt.lifecycle)==null?void 0:At.ancestorSessionIds)&&YE(Y)?((it=(He=$.data)==null?void 0:He.companion)==null?void 0:it.name)??"小猫":void 0;return d.jsx(CLe,{session:Y,drag:Ae,noteOf:Tt,agent:(jt=z.data)==null?void 0:jt.find(Sn=>Sn.id===Y.agentId),botName:(It=(St=I.data)==null?void 0:St.bots.find(Sn=>{var mr;return(mr=Y.sourceId)==null?void 0:mr.startsWith(`${Sn.appId}:`)}))==null?void 0:It.name,parentLabel:et?lc(et,(Tn=(Rn=z.data)==null?void 0:Rn.find(Sn=>Sn.id===et.agentId))==null?void 0:Tn.name):void 0,active:t===Y.id||u.some(Sn=>(Sn.kind==="session"||Sn.kind==="side-chat")&&Sn.sessionId===Y.id),onClick:()=>oe(Y.id)},Y.id)};return d.jsx(spe,{children:d.jsx(Rwe,{value:ft,children:d.jsxs("div",{ref:j,className:"ui-shell relative flex h-full overflow-hidden bg-canvas font-sans text-zinc-900",children:[v&&d.jsx("button",{type:"button","aria-label":"关闭会话列表",onClick:()=>b(!1),className:"ui-overlay fixed inset-0 z-40 bg-zinc-950/20 md:hidden"}),d.jsxs("aside",{style:{"--sb-w":`${Ze}px`},className:`ui-sidebar-safe fixed inset-y-0 left-0 z-50 flex shrink-0 flex-col overflow-hidden border-r border-zinc-200 bg-rail shadow-[12px_0_36px_rgba(24,24,27,.08)] transition-transform duration-300 ease-[cubic-bezier(.16,1,.3,1)] w-[286px] md:static md:z-20 md:translate-x-0 md:shadow-none ${v?"translate-x-0":"-translate-x-full"} ${Ie?"md:w-11":"md:w-[var(--sb-w)]"}`,children:[!Ie&&d.jsx("div",{onPointerDown:Y=>{Y.preventDefault(),xe.current={x:Y.clientX,width:Ze},$e(!0)},title:"拖拽调整宽度,拖到最窄可收起",className:"absolute inset-y-0 right-0 z-20 hidden w-1.5 cursor-col-resize touch-none bg-transparent hover:bg-blue-400/30 md:block"}),d.jsxs("div",{className:`flex h-full flex-col ${Ie?"md:hidden":""}`,children:[d.jsx("div",{className:"flex min-w-[268px] items-center pr-3",children:d.jsxs("button",{type:"button",onClick:()=>{n(void 0),b(!1),Se(void 0)},title:"回到首页","aria-label":"回到首页",className:"flex h-14 min-w-0 flex-1 items-center gap-2.5 px-4 text-left transition-colors hover:bg-zinc-100/70 active:bg-zinc-200/60",children:[d.jsx(vLe,{className:"h-7 w-7 shrink-0"}),d.jsx("span",{className:"text-sm font-semibold tracking-[-.02em]",children:"AgentDock"})]})}),d.jsxs("div",{className:"flex min-w-[268px] flex-col gap-1 px-2.5",children:[d.jsxs("button",{onClick:J,"aria-label":"新建对话",className:"flex h-9 w-full items-center gap-2 rounded-lg px-2.5 text-[14px] font-medium text-zinc-700 transition-colors hover:bg-zinc-100 active:bg-zinc-200/60",children:[d.jsx(sa,{size:16}),"新建对话"]}),d.jsxs("div",{className:"flex items-center gap-1.5",children:[d.jsxs("button",{type:"button",onClick:ae,"aria-label":"搜索会话(⌘K)",className:"flex h-9 min-w-0 flex-1 items-center gap-2 rounded-lg border border-zinc-200 bg-white px-2.5 text-[13px] text-zinc-500 transition-colors hover:border-zinc-300 hover:text-zinc-700",children:[d.jsx(fa,{size:14,className:"shrink-0"}),"搜索会话",d.jsx("span",{className:"ml-auto shrink-0 rounded border border-zinc-200 bg-zinc-50 px-1 py-0.5 font-sans text-[12px] leading-none text-zinc-400",children:"⌘K"})]}),d.jsx(s1e,{compact:!0,value:_,bots:(($t=I.data)==null?void 0:$t.bots)??[],agents:z.data??[],onChange:k})]})]}),d.jsx("div",{className:"mt-3 min-w-[268px] px-2",children:d.jsx(W3e,{active:!!D&&t===D})}),d.jsxs("div",{className:"mt-3 flex min-w-[268px] items-center justify-between pl-3.5 pr-2",children:[d.jsx("span",{className:"text-[12px] font-medium text-zinc-500",children:"会话列表"}),d.jsxs("div",{className:"flex items-center gap-1",children:[q==="project"&&T&&d.jsx("button",{type:"button",title:"恢复默认排序(按最近对话时间)",onClick:()=>O(NP),className:"grid h-6 w-6 place-items-center rounded text-zinc-400 transition-colors hover:bg-zinc-100 hover:text-zinc-700",children:d.jsx(Cf,{size:12})}),d.jsx("div",{className:"flex rounded-md bg-zinc-100 p-0.5",children:["time","project"].map(Y=>d.jsx("button",{type:"button",onClick:()=>L(Y),"aria-pressed":q===Y,className:`h-6 rounded-[5px] px-2 text-[12px] font-medium transition-colors ${q===Y?"bg-white text-zinc-900 shadow-[0_1px_2px_rgba(0,0,0,.06)]":"text-zinc-500 hover:text-zinc-700"}`,children:Y==="time"?"时间":"项目"},Y))})]})]}),_!=="all"&&d.jsx("div",{className:"mt-1 flex min-w-[268px] items-center gap-1.5 px-3.5",children:d.jsxs("div",{className:"flex h-6 min-w-0 flex-1 items-center gap-1 rounded-md bg-zinc-100 px-2 text-[12px] text-zinc-600",children:[d.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["来源:",_==="local"?"本地":`飞书 · ${((Qt=(Gt=I.data)==null?void 0:Gt.bots.find(Y=>Y.appId===_))==null?void 0:Qt.name)??"机器人"}`]}),d.jsx("button",{type:"button","aria-label":"清除来源筛选",onClick:()=>k("all"),className:"grid h-4 w-4 shrink-0 place-items-center rounded text-zinc-400 transition-colors hover:bg-zinc-200 hover:text-zinc-700",children:d.jsx(Wn,{size:12})})]})}),d.jsx("div",{className:"mt-1 flex min-h-0 min-w-[268px] flex-1 flex-col px-2",children:N.isLoading?d.jsxs("div",{className:"space-y-1 px-2 pt-1",children:[d.jsx("div",{className:"h-[34px] ui-skeleton rounded-lg bg-zinc-200/70"}),d.jsx("div",{className:"h-[34px] ui-skeleton rounded-lg bg-zinc-200/50"}),d.jsx("div",{className:"h-[34px] ui-skeleton rounded-lg bg-zinc-200/40"})]}):M.length?d.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto pb-2",children:q==="time"?u1e(M).map(Y=>d.jsxs("section",{className:"mb-2",children:[d.jsx("div",{className:"flex h-7 items-center px-2 text-[12px] font-medium text-zinc-400",children:Y.label}),Y.sessions.map(Ae=>ze(Ae,ke(Ae.id)))]},Y.key)):V.map(Y=>{const Ae=y.has(Y.cwd),et=Oe("workspaces",Y.cwd,pt),Tt=Y.agents.reduce((dt,At)=>dt+At.sessions.filter(He=>Ka.has(He.state)).length,0);return d.jsxs("div",{className:"mb-0.5",children:[d.jsxs("div",{role:"button",tabIndex:0,...et.props,onClick:()=>ne(Y.cwd),onKeyDown:dt=>{(dt.key==="Enter"||dt.key===" ")&&(dt.preventDefault(),ne(Y.cwd))},title:`${Y.cwd}(拖拽可换位)`,className:`group sticky top-0 z-[1] flex h-7 w-full cursor-pointer items-center gap-1.5 rounded-lg bg-rail pl-2 pr-1 text-left transition-opacity hover:bg-zinc-100/70 ${et.dragging?"opacity-40":""} ${et.over?"ring-1 ring-zinc-300":""}`,children:[Ae?d.jsx(ao,{size:12,className:"shrink-0 text-zinc-400"}):d.jsx(cs,{size:12,className:"shrink-0 text-zinc-400"}),d.jsx(_f,{size:12,className:"shrink-0 text-zinc-400"}),d.jsx(EH,{content:Y.cwd,className:"min-w-0 flex-1 truncate text-[12px] font-medium text-zinc-600",children:Y.label}),Tt>0&&d.jsx("span",{className:"ui-status-pulse h-1.5 w-1.5 shrink-0 rounded-full bg-blue-500"}),d.jsx("span",{role:"button",tabIndex:-1,onClick:dt=>{dt.stopPropagation();const At=dt.currentTarget.getBoundingClientRect();Me({cwd:Y.cwd,top:At.bottom+4,left:Math.min(At.left,window.innerWidth-224)})},className:"grid h-5 w-5 shrink-0 place-items-center rounded text-zinc-400 opacity-0 transition-opacity hover:bg-zinc-200 hover:text-zinc-800 focus:opacity-100 group-hover:opacity-100 max-md:opacity-100",children:d.jsx(sa,{size:12})}),d.jsx(l$,{size:11,className:"shrink-0 cursor-grab text-zinc-300 opacity-0 transition-opacity group-hover:opacity-100"}),d.jsx("span",{className:"shrink-0 text-[12px] tabular-nums text-zinc-400",children:Y.agents.reduce((dt,At)=>dt+At.sessions.length,0)})]}),!Ae&&d.jsx("div",{className:"ml-1.5 border-l border-zinc-200 pl-1",children:Y.agents.map(dt=>{const At=`${Y.cwd}\0${dt.agentId}`,He=S.has(At),it=Oe(`agents:${Y.cwd}`,dt.agentId,(St,It)=>mt(Y.cwd,St,It)),jt=dt.sessions.some(St=>Ka.has(St.state));return d.jsxs("div",{className:"group/agent",children:[d.jsxs("div",{role:"button",tabIndex:0,...it.props,onClick:()=>re(At),onKeyDown:St=>{(St.key==="Enter"||St.key===" ")&&(St.preventDefault(),re(At))},title:He?`展开 ${dt.agentName}(拖拽可换位)`:`收起 ${dt.agentName}(拖拽可换位)`,className:`flex h-7 w-full cursor-pointer items-center gap-1 rounded-lg px-2 text-left text-[12px] text-zinc-500 transition-opacity hover:bg-zinc-100/70 hover:text-zinc-700 ${it.dragging?"opacity-40":""} ${it.over?"ring-1 ring-zinc-300":""}`,children:[He?d.jsx(ao,{size:11,className:"shrink-0"}):d.jsx(cs,{size:11,className:"shrink-0"}),d.jsx(Hr,{agentId:dt.agentId,agentName:dt.agentName,size:12}),d.jsx("span",{className:"min-w-0 flex-1 truncate",children:dt.agentName}),jt&&!He&&d.jsx("span",{className:"ui-status-pulse h-1.5 w-1.5 shrink-0 rounded-full bg-blue-500"}),d.jsx("button",{type:"button",title:`用 ${dt.agentName} 在此工作区新建会话`,disabled:!!pe,onClick:St=>{St.stopPropagation(),xt.mutate({agentId:dt.agentId,cwd:Y.cwd})},className:"grid h-4 w-4 shrink-0 place-items-center rounded opacity-0 transition-opacity hover:bg-zinc-200 hover:text-zinc-800 focus:opacity-100 group-hover/agent:opacity-100 max-md:opacity-100 disabled:opacity-50",children:(pe==null?void 0:pe.agentId)===dt.agentId&&pe.cwd===Y.cwd?d.jsx(Hn,{size:10,className:"animate-spin"}):d.jsx(sa,{size:10})}),d.jsx(l$,{size:10,className:"shrink-0 cursor-grab text-zinc-300 opacity-0 transition-opacity group-hover/agent:opacity-100"}),d.jsx("span",{className:"shrink-0 tabular-nums",children:dt.sessions.length})]}),!He&&d.jsx("div",{className:"ml-1.5 border-l border-zinc-200 pl-1",children:dt.sessions.map(St=>d.jsxs("div",{children:[ze(St,Oe(`sessions:${At}`,St.id,(It,Rn)=>Ye(At,It,Rn),St.id)),(dt.sideChats.get(St.id)??[]).map(It=>ze(It,ke(It.id)))]},St.id))})]},`${Y.cwd}:${dt.agentId}`)})})]},Y.cwd)})}):d.jsx("div",{className:"px-3 py-6 text-xs leading-5 text-zinc-500",children:"当前分类暂无会话。"})}),d.jsx(Dpe,{webDenied:!!g,archivedCount:P.length,onSchedule:()=>{b(!1),xr("schedule")},onArchived:()=>{b(!1),xr("archived")},onImport:()=>{b(!1),xr("import")},onAgentConfig:()=>{b(!1),xr("agent")},onAssistant:Qe,onLark:()=>{b(!1),xr("lark")},onLarkAvatar:()=>{b(!1),xr("lark-avatar")},onShare:()=>{b(!1),xr("share")}})]}),d.jsxs("div",{className:`hidden h-full w-full flex-col items-center gap-1 py-3 ${Ie?"md:flex":""}`,children:[d.jsx(rn,{content:"展开会话列表",children:d.jsx("button",{type:"button",onClick:()=>Te(!1),"aria-label":"展开会话列表",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-600 hover:bg-white hover:text-zinc-900",children:d.jsx(QZ,{size:16})})}),d.jsx(rn,{content:"新建对话",children:d.jsx("button",{type:"button",onClick:J,"aria-label":"新建对话",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-600 hover:bg-white hover:text-zinc-900",children:d.jsx(sa,{size:16})})}),d.jsx(rn,{content:"搜索会话(⌘K)",children:d.jsx("button",{type:"button",onClick:ae,"aria-label":"搜索会话",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-600 hover:bg-white hover:text-zinc-900",children:d.jsx(fa,{size:16})})}),d.jsx(q3e,{}),d.jsxs("span",{className:"mt-auto flex flex-col items-center gap-1",children:[d.jsx(rn,{content:"定时任务",children:d.jsx("button",{type:"button",onClick:()=>xr("schedule"),"aria-label":"定时任务",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-500 hover:bg-white hover:text-zinc-900",children:d.jsx(ol,{size:15})})}),d.jsx(rn,{content:"归档会话",children:d.jsx("button",{type:"button",onClick:()=>xr("archived"),"aria-label":"归档会话",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-500 hover:bg-white hover:text-zinc-900",children:d.jsx(Sf,{size:15})})}),d.jsx(rn,{content:"导入外部会话",children:d.jsx("button",{type:"button",onClick:()=>{Te(!1),xr("import")},"aria-label":"导入外部会话",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-500 hover:bg-white hover:text-zinc-900",children:d.jsx(ha,{size:15})})}),d.jsx(rn,{content:"Agent 设置",children:d.jsx("button",{type:"button",onClick:()=>{Te(!1),xr("agent")},"aria-label":"Agent 设置",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-500 hover:bg-white hover:text-zinc-900",children:d.jsx(ti,{size:15})})}),d.jsx(rn,{content:"飞书设置",children:d.jsx("button",{type:"button",onClick:()=>{Te(!1),xr("lark")},"aria-label":"飞书设置",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-500 hover:bg-white hover:text-zinc-900",children:d.jsx(Hb,{size:15})})}),d.jsx(rn,{content:"在手机上打开",children:d.jsx("button",{type:"button",onClick:()=>xr("share"),"aria-label":"在手机上打开",className:"grid h-8 w-8 place-items-center rounded-lg text-zinc-500 hover:bg-white hover:text-zinc-900",children:d.jsx($L,{size:15})})})]})]})]}),d.jsx("main",{className:"flex min-w-0 flex-1 bg-canvas",children:G?d.jsxs(d.Fragment,{children:[d.jsx("div",{className:`flex min-w-0 flex-1 ${h?"max-lg:hidden":""}`,children:d.jsx(ID,{session:G,agent:(Yt=z.data)==null?void 0:Yt.find(Y=>Y.id===G.agentId),pane:"primary",onOpenSidebar:()=>b(!0),paneOpen:h,onTogglePane:()=>{Se(void 0),l()}},`primary:${G.id}`)}),(h||c.length>0)&&d.jsx(xye,{tabs:u,mountedTabs:c,activeTabId:f,visible:h,shortcuts:fe,acceptsDrop:!!(de!=null&&de.sessionId),onDropSession:()=>{const Y=de==null?void 0:de.sessionId;Le(void 0),me(void 0),Y&&ge(Y)},onActivate:s,onClose:i,onAdd:Y=>Se(Y),onPick:ce,onHide:()=>{Se(void 0),l()},children:Object.fromEntries(c.map(Y=>{var Ae;return[Y.id,Y.kind==="terminal"?d.jsx(R4e,{sessionId:Y.anchorSessionId??G.id,sshHost:(E.find(et=>et.id===Y.anchorSessionId)??G).sshHost},Y.id):Y.kind==="files"?d.jsx(P4e,{sessionId:Y.anchorSessionId??G.id,cwd:((Ae=E.find(et=>et.id===Y.anchorSessionId))==null?void 0:Ae.cwd)??G.cwd,initialPath:Y.filePath,disabledReason:(E.find(et=>et.id===Y.anchorSessionId)??G).sshHost?`SSH 远端会话(${(E.find(et=>et.id===Y.anchorSessionId)??G).sshHost})暂不支持文件浏览;终端面板可以直接连到远端。`:void 0},Y.id):Y.kind==="raw"?d.jsx(a3e,{sessionId:Y.anchorSessionId??G.id,active:h&&Y.id===f},Y.id):(()=>{var Tt;const et=E.find(dt=>dt.id===Y.sessionId);return et?d.jsx(ID,{session:et,agent:(Tt=z.data)==null?void 0:Tt.find(dt=>dt.id===et.agentId),pane:"secondary",onOpenSidebar:()=>b(!0),onOpenRawLog:U},Y.id):d.jsx("div",{className:"grid h-full place-items-center text-[12px] text-zinc-400",children:"会话已不存在。"})})()]}))}),(de==null?void 0:de.sessionId)&&!h&&d.jsx("div",{onDragOver:Y=>Y.preventDefault(),onDrop:Y=>{Y.preventDefault();const Ae=de==null?void 0:de.sessionId;Le(void 0),me(void 0),Ae&&ge(Ae)},className:"fixed inset-y-0 right-0 z-40 flex w-20 items-center justify-center border-l-2 border-dashed border-zinc-400 bg-zinc-900/5",children:d.jsx("span",{className:"text-[12px] font-medium text-zinc-600 [writing-mode:vertical-rl]",children:"放到这里,在副屏打开"})})]}):d.jsxs("div",{className:"ui-page relative flex flex-1 justify-center overflow-y-auto px-4 sm:px-8",children:[d.jsx("span",{className:"absolute left-[max(0.75rem,env(safe-area-inset-left))] top-[max(0.75rem,env(safe-area-inset-top))] md:hidden",children:d.jsx($o,{label:"打开会话列表",onClick:()=>b(!0),children:d.jsx(G3,{size:17})})}),d.jsx(pLe,{editorRef:X,agents:z.data??[],sessions:N.data??[],onCreated:Y=>oe(Y.id)})]})}),Ee&&d.jsx(mye,{anchor:Ee,shortcuts:fe,onPick:ce,onClose:()=>Se(void 0)}),De&&d.jsxs("div",{className:"fixed bottom-4 left-1/2 z-50 -translate-x-1/2 rounded-lg border border-red-200 bg-red-50 px-3.5 py-2 text-[12px] text-red-700 shadow-[0_12px_32px_rgba(24,24,27,.12)]",children:[d.jsx("button",{type:"button",onClick:()=>at(void 0),className:"mr-2 font-medium underline",children:"关闭"}),De]}),d.jsx(gY,{dialogs:{lark:d.jsx(wLe,{agents:z.data??[],onClose:Ni}),"lark-avatar":d.jsx(SLe,{onClose:Ni}),agent:d.jsx(k1e,{onClose:Ni}),assistant:d.jsx(rSe,{onClose:Ni,onOpenMain:()=>{Ni(),rt()},onAdopt:()=>{Ni(),Mt()},onOpenSession:Y=>{Ni(),oe(Y)}}),schedule:Y=>d.jsx(Jye,{...Y?{session:E.find(Ae=>Ae.id===Y)}:{},sessions:E,onClose:Ni,onOpenSession:oe}),handover:Y=>{var et;const Ae=Y?E.find(Tt=>Tt.id===Y):void 0;return Ae?d.jsx(lSe,{session:Ae,agent:(et=z.data)==null?void 0:et.find(Tt=>Tt.id===Ae.agentId),onClose:Ni}):null},"system-prompt":Y=>{const Ae=Y?E.find(et=>et.id===Y):void 0;return Ae!=null&&Ae.systemPrompt?d.jsx(gSe,{session:Ae,onClose:Ni}):null},share:d.jsx(ySe,{onClose:Ni}),archived:d.jsx(Qye,{sessions:P,agents:z.data??[],onClose:Ni,onOpenSession:Y=>{Ni(),oe(Y)}}),import:d.jsx(mSe,{agents:z.data??[],onClose:Ni,onImported:Y=>oe(Y.id)}),search:d.jsx(m1e,{agents:z.data??[],sessions:N.data??[],onClose:Ni,onOpen:Y=>{Ni(),oe(Y.id)}})}}),le&&d.jsx(xLe,{cwd:le.cwd,top:le.top,left:le.left,agents:z.data??[],creatingPair:pe,onSelect:Y=>xt.mutate({agentId:Y,cwd:le.cwd}),onClose:()=>Me(null)}),d.jsx(V3e,{view:ue})]})})})}const SG=new eY({defaultOptions:{queries:{retry:(e,t)=>!(t instanceof Ub)&&e<3}}});SG.setQueryDefaults(["events"],{structuralSharing:!1,gcTime:6e4,staleTime:3e4});CG.createRoot(document.getElementById("root")).render(d.jsx(m.StrictMode,{children:d.jsx(jG,{client:SG,children:d.jsx(jpe,{children:d.jsx(kLe,{})})})}));if(new URLSearchParams(window.location.search).get("vvdebug")==="1"&&window.visualViewport){const e=window.visualViewport,t=document.createElement("div");t.style.cssText="position:fixed;top:0;left:0;right:0;z-index:99999;margin:0;padding:6px 8px;font:11px/1.5 ui-monospace,Menlo,monospace;background:rgba(0,0,0,.78);color:#7CFC9A;pointer-events:none;white-space:pre-wrap;word-break:break-all",document.body.appendChild(t);const n=()=>`${(window.innerHeight/100).toFixed(1)}dvh?`,r=()=>{var i;t.textContent=[`vv.h=${Math.round(e.height)} offTop=${Math.round(e.offsetTop)} scale=${e.scale} w=${Math.round(e.width)}`,`innerH=${window.innerHeight} innerW=${window.innerWidth} dpr=${window.devicePixelRatio}`,`dvh100≈${n()} apply=${Math.abs(e.scale-1)<=.01}`,`docH=${document.documentElement.clientHeight} ua=${((i=navigator.userAgent.match(/OS [0-9_]+/))==null?void 0:i[0])??""}`].join(`
|
|
1119
1119
|
`)};r(),e.addEventListener("resize",r),e.addEventListener("scroll",r)}export{Bg as E,vh as M,fN as P,Gn as S,Lo as a,Ic as b,we as c,g$e as k,Ai as r,wb as s};
|