@linkshell/gateway 0.6.51 → 0.6.52
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/package.json +1 -1
- package/web-client/assets/app-icon-SJEseeVg.png +0 -0
- package/web-client/assets/{highlight-engine-DYUPoK0n.js → highlight-engine-xqDwxvyZ.js} +1 -1
- package/web-client/assets/{index-02i0gtP_.js → index-D2tA406X.js} +2 -2
- package/web-client/assets/{qr-scanner.min-DszHMeGT.js → qr-scanner.min-BrJY21Dj.js} +1 -1
- package/web-client/assets/{render-DTUh4feU.js → render-GOxWKoIQ.js} +5 -5
- package/web-client/index.html +1 -1
- package/web-client/assets/mark-glyph-D_OhbJdd.png +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlight-engine-
|
|
2
|
-
import{r as iN,g as o8,a as m,R as Ro,j as s,b as _d,M as l8,c as c8,d as u8}from"./markdown-gsWh3zpl.js";import{_ as fo,a as aN,b as d8,c as f8}from"./account-R7yD1rZE.js";import{i as me,_ as Z0,r as jy,s as ky,d as h8,a as Gp,D as p8,b as m8,c as K0,e as g8,f as Jn,g as v8,h as br,j as x8,k as b8,o as Rm,l as yS,m as y8,n as w8,p as j8,q as k8,t as Sy,u as Zp,v as su,w as S8,x as wS,y as nn,z as Lt,A as Ul,T as ai,B as ys,C as C8,E as _8,R as Cy,F as _y,G as oN,H as E8,I as jS}from"./index-02i0gtP_.js";import{D as N8,o as A8}from"./terminal-DWFexEE4.js";function lN(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=lN(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function cN(){for(var e,t,n=0,r="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=lN(e))&&(r&&(r+=" "),r+=t);return r}const T8=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},M8=(e,t)=>({classGroupId:e,validator:t}),uN=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Kp="-",kS=[],z8="arbitrary..",R8=e=>{const t=O8(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{if(c.startsWith("[")&&c.endsWith("]"))return D8(c);const d=c.split(Kp),f=d[0]===""&&d.length>1?1:0;return dN(d,f,t)},getConflictingClassGroupIds:(c,d)=>{if(d){const f=r[c],h=n[c];return f?h?T8(h,f):f:h||kS}return n[c]||kS}}},dN=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const a=e[t],l=n.nextPart.get(a);if(l){const h=dN(e,t+1,l);if(h)return h}const c=n.validators;if(c===null)return;const d=t===0?e.join(Kp):e.slice(t).join(Kp),f=c.length;for(let h=0;h<f;h++){const v=c[h];if(v.validator(d))return v.classGroupId}},D8=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?z8+r:void 0})(),O8=e=>{const{theme:t,classGroups:n}=e;return I8(n,t)},I8=(e,t)=>{const n=uN();for(const r in e){const a=e[r];Ey(a,n,r,t)}return n},Ey=(e,t,n,r)=>{const a=e.length;for(let l=0;l<a;l++){const c=e[l];$8(c,t,n,r)}},$8=(e,t,n,r)=>{if(typeof e=="string"){L8(e,t,n);return}if(typeof e=="function"){P8(e,t,n,r);return}B8(e,t,n,r)},L8=(e,t,n)=>{const r=e===""?t:fN(t,e);r.classGroupId=n},P8=(e,t,n,r)=>{if(U8(e)){Ey(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(M8(n,e))},B8=(e,t,n,r)=>{const a=Object.entries(e),l=a.length;for(let c=0;c<l;c++){const[d,f]=a[c];Ey(f,fN(t,d),n,r)}},fN=(e,t)=>{let n=e;const r=t.split(Kp),a=r.length;for(let l=0;l<a;l++){const c=r[l];let d=n.nextPart.get(c);d||(d=uN(),n.nextPart.set(c,d)),n=d}return n},U8=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,F8=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const a=(l,c)=>{n[l]=c,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(l){let c=n[l];if(c!==void 0)return c;if((c=r[l])!==void 0)return a(l,c),c},set(l,c){l in n?n[l]=c:a(l,c)}}},Y0="!",SS=":",q8=[],CS=(e,t,n,r,a)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:a}),H8=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=a=>{const l=[];let c=0,d=0,f=0,h;const v=a.length;for(let k=0;k<v;k++){const C=a[k];if(c===0&&d===0){if(C===SS){l.push(a.slice(f,k)),f=k+1;continue}if(C==="/"){h=k;continue}}C==="["?c++:C==="]"?c--:C==="("?d++:C===")"&&d--}const g=l.length===0?a:a.slice(f);let x=g,y=!1;g.endsWith(Y0)?(x=g.slice(0,-1),y=!0):g.startsWith(Y0)&&(x=g.slice(1),y=!0);const j=h&&h>f?h-f:void 0;return CS(l,y,x,j)};if(t){const a=t+SS,l=r;r=c=>c.startsWith(a)?l(c.slice(a.length)):CS(q8,!1,c,void 0,!0)}if(n){const a=r;r=l=>n({className:l,parseClassName:a})}return r},V8=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let a=[];for(let l=0;l<n.length;l++){const c=n[l],d=c[0]==="[",f=t.has(c);d||f?(a.length>0&&(a.sort(),r.push(...a),a=[]),r.push(c)):a.push(c)}return a.length>0&&(a.sort(),r.push(...a)),r}},G8=e=>({cache:F8(e.cacheSize),parseClassName:H8(e),sortModifiers:V8(e),postfixLookupClassGroupIds:Z8(e),...R8(e)}),Z8=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let r=0;r<n.length;r++)t[n[r]]=!0;return t},K8=/\s+/,Y8=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:l,postfixLookupClassGroupIds:c}=t,d=[],f=e.trim().split(K8);let h="";for(let v=f.length-1;v>=0;v-=1){const g=f[v],{isExternal:x,modifiers:y,hasImportantModifier:j,baseClassName:k,maybePostfixModifierPosition:C}=n(g);if(x){h=g+(h.length>0?" "+h:h);continue}let _=!!C,N;if(_){const B=k.substring(0,C);N=r(B);const O=N&&c[N]?r(k):void 0;O&&O!==N&&(N=O,_=!1)}else N=r(k);if(!N){if(!_){h=g+(h.length>0?" "+h:h);continue}if(N=r(k),!N){h=g+(h.length>0?" "+h:h);continue}_=!1}const S=y.length===0?"":y.length===1?y[0]:l(y).join(":"),T=j?S+Y0:S,z=T+N;if(d.indexOf(z)>-1)continue;d.push(z);const L=a(N,_);for(let B=0;B<L.length;++B){const O=L[B];d.push(T+O)}h=g+(h.length>0?" "+h:h)}return h},W8=(...e)=>{let t=0,n,r,a="";for(;t<e.length;)(n=e[t++])&&(r=hN(n))&&(a&&(a+=" "),a+=r);return a},hN=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=hN(e[r]))&&(n&&(n+=" "),n+=t);return n},X8=(e,...t)=>{let n,r,a,l;const c=f=>{const h=t.reduce((v,g)=>g(v),e());return n=G8(h),r=n.cache.get,a=n.cache.set,l=d,d(f)},d=f=>{const h=r(f);if(h)return h;const v=Y8(f,n);return a(f,v),v};return l=c,(...f)=>l(W8(...f))},Q8=[],Kn=e=>{const t=n=>n[e]||Q8;return t.isThemeGetter=!0,t.themeKey=e,t},pN=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,mN=/^\((?:(\w[\w-]*):)?(.+)\)$/i,J8=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,eI=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,tI=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,nI=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,sI=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,rI=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,to=e=>J8.test(e),St=e=>!!e&&!Number.isNaN(Number(e)),ji=e=>!!e&&Number.isInteger(Number(e)),Px=e=>e.endsWith("%")&&St(e.slice(0,-1)),ra=e=>eI.test(e),gN=()=>!0,iI=e=>tI.test(e)&&!nI.test(e),Ny=()=>!1,aI=e=>sI.test(e),oI=e=>rI.test(e),lI=e=>!Be(e)&&!Ue(e),cI=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),uI=e=>Do(e,bN,Ny),Be=e=>pN.test(e),dl=e=>Do(e,yN,iI),_S=e=>Do(e,xI,St),dI=e=>Do(e,jN,gN),fI=e=>Do(e,wN,Ny),ES=e=>Do(e,vN,Ny),hI=e=>Do(e,xN,oI),Zh=e=>Do(e,kN,aI),Ue=e=>mN.test(e),gd=e=>Fl(e,yN),pI=e=>Fl(e,wN),NS=e=>Fl(e,vN),mI=e=>Fl(e,bN),gI=e=>Fl(e,xN),Kh=e=>Fl(e,kN,!0),vI=e=>Fl(e,jN,!0),Do=(e,t,n)=>{const r=pN.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Fl=(e,t,n=!1)=>{const r=mN.exec(e);return r?r[1]?t(r[1]):n:!1},vN=e=>e==="position"||e==="percentage",xN=e=>e==="image"||e==="url",bN=e=>e==="length"||e==="size"||e==="bg-size",yN=e=>e==="length",xI=e=>e==="number",wN=e=>e==="family-name",jN=e=>e==="number"||e==="weight",kN=e=>e==="shadow",bI=()=>{const e=Kn("color"),t=Kn("font"),n=Kn("text"),r=Kn("font-weight"),a=Kn("tracking"),l=Kn("leading"),c=Kn("breakpoint"),d=Kn("container"),f=Kn("spacing"),h=Kn("radius"),v=Kn("shadow"),g=Kn("inset-shadow"),x=Kn("text-shadow"),y=Kn("drop-shadow"),j=Kn("blur"),k=Kn("perspective"),C=Kn("aspect"),_=Kn("ease"),N=Kn("animate"),S=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],z=()=>[...T(),Ue,Be],L=()=>["auto","hidden","clip","visible","scroll"],B=()=>["auto","contain","none"],O=()=>[Ue,Be,f],$=()=>[to,"full","auto",...O()],D=()=>[ji,"none","subgrid",Ue,Be],Y=()=>["auto",{span:["full",ji,Ue,Be]},ji,Ue,Be],P=()=>[ji,"auto",Ue,Be],M=()=>["auto","min","max","fr",Ue,Be],R=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],H=()=>["start","end","center","stretch","center-safe","end-safe"],I=()=>["auto",...O()],q=()=>[to,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...O()],G=()=>[d,to,"screen","full","dvw","lvw","svw","min","max","fit",...O()],X=()=>[to,"screen","full","lh","dvh","lvh","svh","min","max","fit",...O()],K=()=>[e,Ue,Be],ee=()=>[...T(),NS,ES,{position:[Ue,Be]}],Z=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ne=()=>["auto","cover","contain",mI,uI,{size:[Ue,Be]}],ie=()=>[Px,gd,dl],de=()=>["","none","full",h,Ue,Be],oe=()=>["",St,gd,dl],ae=()=>["solid","dashed","dotted","double"],Q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],pe=()=>[St,Px,NS,ES],Me=()=>["","none",j,Ue,Be],ze=()=>["none",St,Ue,Be],Le=()=>["none",St,Ue,Be],He=()=>[St,Ue,Be],Te=()=>[to,"full",...O()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ra],breakpoint:[ra],color:[gN],container:[ra],"drop-shadow":[ra],ease:["in","out","in-out"],font:[lI],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ra],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ra],shadow:[ra],spacing:["px",St],text:[ra],"text-shadow":[ra],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",to,Be,Ue,C]}],container:["container"],"container-type":[{"@container":["","normal","size",Ue,Be]}],"container-named":[cI],columns:[{columns:[St,"auto",Be,Ue,d]}],"break-after":[{"break-after":S()}],"break-before":[{"break-before":S()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:z()}],overflow:[{overflow:L()}],"overflow-x":[{"overflow-x":L()}],"overflow-y":[{"overflow-y":L()}],overscroll:[{overscroll:B()}],"overscroll-x":[{"overscroll-x":B()}],"overscroll-y":[{"overscroll-y":B()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:$()}],"inset-x":[{"inset-x":$()}],"inset-y":[{"inset-y":$()}],start:[{"inset-s":$(),start:$()}],end:[{"inset-e":$(),end:$()}],"inset-bs":[{"inset-bs":$()}],"inset-be":[{"inset-be":$()}],top:[{top:$()}],right:[{right:$()}],bottom:[{bottom:$()}],left:[{left:$()}],visibility:["visible","invisible","collapse"],z:[{z:[ji,"auto",Ue,Be]}],basis:[{basis:[to,"full","auto",d,...O()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[St,to,"auto","initial","none",Be]}],grow:[{grow:["",St,Ue,Be]}],shrink:[{shrink:["",St,Ue,Be]}],order:[{order:[ji,"first","last","none",Ue,Be]}],"grid-cols":[{"grid-cols":D()}],"col-start-end":[{col:Y()}],"col-start":[{"col-start":P()}],"col-end":[{"col-end":P()}],"grid-rows":[{"grid-rows":D()}],"row-start-end":[{row:Y()}],"row-start":[{"row-start":P()}],"row-end":[{"row-end":P()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":M()}],"auto-rows":[{"auto-rows":M()}],gap:[{gap:O()}],"gap-x":[{"gap-x":O()}],"gap-y":[{"gap-y":O()}],"justify-content":[{justify:[...R(),"normal"]}],"justify-items":[{"justify-items":[...H(),"normal"]}],"justify-self":[{"justify-self":["auto",...H()]}],"align-content":[{content:["normal",...R()]}],"align-items":[{items:[...H(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...H(),{baseline:["","last"]}]}],"place-content":[{"place-content":R()}],"place-items":[{"place-items":[...H(),"baseline"]}],"place-self":[{"place-self":["auto",...H()]}],p:[{p:O()}],px:[{px:O()}],py:[{py:O()}],ps:[{ps:O()}],pe:[{pe:O()}],pbs:[{pbs:O()}],pbe:[{pbe:O()}],pt:[{pt:O()}],pr:[{pr:O()}],pb:[{pb:O()}],pl:[{pl:O()}],m:[{m:I()}],mx:[{mx:I()}],my:[{my:I()}],ms:[{ms:I()}],me:[{me:I()}],mbs:[{mbs:I()}],mbe:[{mbe:I()}],mt:[{mt:I()}],mr:[{mr:I()}],mb:[{mb:I()}],ml:[{ml:I()}],"space-x":[{"space-x":O()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":O()}],"space-y-reverse":["space-y-reverse"],size:[{size:q()}],"inline-size":[{inline:["auto",...G()]}],"min-inline-size":[{"min-inline":["auto",...G()]}],"max-inline-size":[{"max-inline":["none",...G()]}],"block-size":[{block:["auto",...X()]}],"min-block-size":[{"min-block":["auto",...X()]}],"max-block-size":[{"max-block":["none",...X()]}],w:[{w:[d,"screen",...q()]}],"min-w":[{"min-w":[d,"screen","none",...q()]}],"max-w":[{"max-w":[d,"screen","none","prose",{screen:[c]},...q()]}],h:[{h:["screen","lh",...q()]}],"min-h":[{"min-h":["screen","lh","none",...q()]}],"max-h":[{"max-h":["screen","lh","none",...q()]}],"font-size":[{text:["base",n,gd,dl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,vI,dI]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Px,Be]}],"font-family":[{font:[pI,fI,t]}],"font-features":[{"font-features":[Be]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,Ue,Be]}],"line-clamp":[{"line-clamp":[St,"none",Ue,_S]}],leading:[{leading:["none",l,...O()]}],"list-image":[{"list-image":["none",Ue,Be]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ue,Be]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:K()}],"text-color":[{text:K()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ae(),"wavy"]}],"text-decoration-thickness":[{decoration:[St,"from-font","auto",Ue,dl]}],"text-decoration-color":[{decoration:K()}],"underline-offset":[{"underline-offset":[St,"auto",Ue,Be]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:O()}],"tab-size":[{tab:[ji,Ue,Be]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ue,Be]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ue,Be]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ee()}],"bg-repeat":[{bg:Z()}],"bg-size":[{bg:ne()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ji,Ue,Be],radial:["",Ue,Be],conic:["",ji,Ue,Be]},gI,hI]}],"bg-color":[{bg:K()}],"gradient-from-pos":[{from:ie()}],"gradient-via-pos":[{via:ie()}],"gradient-to-pos":[{to:ie()}],"gradient-from":[{from:K()}],"gradient-via":[{via:K()}],"gradient-to":[{to:K()}],rounded:[{rounded:de()}],"rounded-s":[{"rounded-s":de()}],"rounded-e":[{"rounded-e":de()}],"rounded-t":[{"rounded-t":de()}],"rounded-r":[{"rounded-r":de()}],"rounded-b":[{"rounded-b":de()}],"rounded-l":[{"rounded-l":de()}],"rounded-ss":[{"rounded-ss":de()}],"rounded-se":[{"rounded-se":de()}],"rounded-ee":[{"rounded-ee":de()}],"rounded-es":[{"rounded-es":de()}],"rounded-tl":[{"rounded-tl":de()}],"rounded-tr":[{"rounded-tr":de()}],"rounded-br":[{"rounded-br":de()}],"rounded-bl":[{"rounded-bl":de()}],"border-w":[{border:oe()}],"border-w-x":[{"border-x":oe()}],"border-w-y":[{"border-y":oe()}],"border-w-s":[{"border-s":oe()}],"border-w-e":[{"border-e":oe()}],"border-w-bs":[{"border-bs":oe()}],"border-w-be":[{"border-be":oe()}],"border-w-t":[{"border-t":oe()}],"border-w-r":[{"border-r":oe()}],"border-w-b":[{"border-b":oe()}],"border-w-l":[{"border-l":oe()}],"divide-x":[{"divide-x":oe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":oe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ae(),"hidden","none"]}],"divide-style":[{divide:[...ae(),"hidden","none"]}],"border-color":[{border:K()}],"border-color-x":[{"border-x":K()}],"border-color-y":[{"border-y":K()}],"border-color-s":[{"border-s":K()}],"border-color-e":[{"border-e":K()}],"border-color-bs":[{"border-bs":K()}],"border-color-be":[{"border-be":K()}],"border-color-t":[{"border-t":K()}],"border-color-r":[{"border-r":K()}],"border-color-b":[{"border-b":K()}],"border-color-l":[{"border-l":K()}],"divide-color":[{divide:K()}],"outline-style":[{outline:[...ae(),"none","hidden"]}],"outline-offset":[{"outline-offset":[St,Ue,Be]}],"outline-w":[{outline:["",St,gd,dl]}],"outline-color":[{outline:K()}],shadow:[{shadow:["","inner","none",v,Kh,Zh]}],"shadow-color":[{shadow:K()}],"inset-shadow":[{"inset-shadow":["none",g,Kh,Zh]}],"inset-shadow-color":[{"inset-shadow":K()}],"ring-w":[{ring:oe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:K()}],"ring-offset-w":[{"ring-offset":[St,dl]}],"ring-offset-color":[{"ring-offset":K()}],"inset-ring-w":[{"inset-ring":oe()}],"inset-ring-color":[{"inset-ring":K()}],"text-shadow":[{"text-shadow":["none",x,Kh,Zh]}],"text-shadow-color":[{"text-shadow":K()}],opacity:[{opacity:[St,Ue,Be]}],"mix-blend":[{"mix-blend":[...Q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Q()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[St]}],"mask-image-linear-from-pos":[{"mask-linear-from":pe()}],"mask-image-linear-to-pos":[{"mask-linear-to":pe()}],"mask-image-linear-from-color":[{"mask-linear-from":K()}],"mask-image-linear-to-color":[{"mask-linear-to":K()}],"mask-image-t-from-pos":[{"mask-t-from":pe()}],"mask-image-t-to-pos":[{"mask-t-to":pe()}],"mask-image-t-from-color":[{"mask-t-from":K()}],"mask-image-t-to-color":[{"mask-t-to":K()}],"mask-image-r-from-pos":[{"mask-r-from":pe()}],"mask-image-r-to-pos":[{"mask-r-to":pe()}],"mask-image-r-from-color":[{"mask-r-from":K()}],"mask-image-r-to-color":[{"mask-r-to":K()}],"mask-image-b-from-pos":[{"mask-b-from":pe()}],"mask-image-b-to-pos":[{"mask-b-to":pe()}],"mask-image-b-from-color":[{"mask-b-from":K()}],"mask-image-b-to-color":[{"mask-b-to":K()}],"mask-image-l-from-pos":[{"mask-l-from":pe()}],"mask-image-l-to-pos":[{"mask-l-to":pe()}],"mask-image-l-from-color":[{"mask-l-from":K()}],"mask-image-l-to-color":[{"mask-l-to":K()}],"mask-image-x-from-pos":[{"mask-x-from":pe()}],"mask-image-x-to-pos":[{"mask-x-to":pe()}],"mask-image-x-from-color":[{"mask-x-from":K()}],"mask-image-x-to-color":[{"mask-x-to":K()}],"mask-image-y-from-pos":[{"mask-y-from":pe()}],"mask-image-y-to-pos":[{"mask-y-to":pe()}],"mask-image-y-from-color":[{"mask-y-from":K()}],"mask-image-y-to-color":[{"mask-y-to":K()}],"mask-image-radial":[{"mask-radial":[Ue,Be]}],"mask-image-radial-from-pos":[{"mask-radial-from":pe()}],"mask-image-radial-to-pos":[{"mask-radial-to":pe()}],"mask-image-radial-from-color":[{"mask-radial-from":K()}],"mask-image-radial-to-color":[{"mask-radial-to":K()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":T()}],"mask-image-conic-pos":[{"mask-conic":[St]}],"mask-image-conic-from-pos":[{"mask-conic-from":pe()}],"mask-image-conic-to-pos":[{"mask-conic-to":pe()}],"mask-image-conic-from-color":[{"mask-conic-from":K()}],"mask-image-conic-to-color":[{"mask-conic-to":K()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ee()}],"mask-repeat":[{mask:Z()}],"mask-size":[{mask:ne()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ue,Be]}],filter:[{filter:["","none",Ue,Be]}],blur:[{blur:Me()}],brightness:[{brightness:[St,Ue,Be]}],contrast:[{contrast:[St,Ue,Be]}],"drop-shadow":[{"drop-shadow":["","none",y,Kh,Zh]}],"drop-shadow-color":[{"drop-shadow":K()}],grayscale:[{grayscale:["",St,Ue,Be]}],"hue-rotate":[{"hue-rotate":[St,Ue,Be]}],invert:[{invert:["",St,Ue,Be]}],saturate:[{saturate:[St,Ue,Be]}],sepia:[{sepia:["",St,Ue,Be]}],"backdrop-filter":[{"backdrop-filter":["","none",Ue,Be]}],"backdrop-blur":[{"backdrop-blur":Me()}],"backdrop-brightness":[{"backdrop-brightness":[St,Ue,Be]}],"backdrop-contrast":[{"backdrop-contrast":[St,Ue,Be]}],"backdrop-grayscale":[{"backdrop-grayscale":["",St,Ue,Be]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[St,Ue,Be]}],"backdrop-invert":[{"backdrop-invert":["",St,Ue,Be]}],"backdrop-opacity":[{"backdrop-opacity":[St,Ue,Be]}],"backdrop-saturate":[{"backdrop-saturate":[St,Ue,Be]}],"backdrop-sepia":[{"backdrop-sepia":["",St,Ue,Be]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":O()}],"border-spacing-x":[{"border-spacing-x":O()}],"border-spacing-y":[{"border-spacing-y":O()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ue,Be]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[St,"initial",Ue,Be]}],ease:[{ease:["linear","initial",_,Ue,Be]}],delay:[{delay:[St,Ue,Be]}],animate:[{animate:["none",N,Ue,Be]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[k,Ue,Be]}],"perspective-origin":[{"perspective-origin":z()}],rotate:[{rotate:ze()}],"rotate-x":[{"rotate-x":ze()}],"rotate-y":[{"rotate-y":ze()}],"rotate-z":[{"rotate-z":ze()}],scale:[{scale:Le()}],"scale-x":[{"scale-x":Le()}],"scale-y":[{"scale-y":Le()}],"scale-z":[{"scale-z":Le()}],"scale-3d":["scale-3d"],skew:[{skew:He()}],"skew-x":[{"skew-x":He()}],"skew-y":[{"skew-y":He()}],transform:[{transform:[Ue,Be,"","none","gpu","cpu"]}],"transform-origin":[{origin:z()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Te()}],"translate-x":[{"translate-x":Te()}],"translate-y":[{"translate-y":Te()}],"translate-z":[{"translate-z":Te()}],"translate-none":["translate-none"],zoom:[{zoom:[ji,Ue,Be]}],accent:[{accent:K()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:K()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ue,Be]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":K()}],"scrollbar-track-color":[{"scrollbar-track":K()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mbs":[{"scroll-mbs":O()}],"scroll-mbe":[{"scroll-mbe":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pbs":[{"scroll-pbs":O()}],"scroll-pbe":[{"scroll-pbe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ue,Be]}],fill:[{fill:["none",...K()]}],"stroke-w":[{stroke:[St,gd,dl,_S]}],stroke:[{stroke:["none",...K()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["start","end","right","left"],"inset-y":["inset-bs","inset-be","top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["ps","pe","pr","pl"],py:["pbs","pbe","pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["ms","me","mr","ml"],my:["mbs","mbe","mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-s","border-w-e","border-w-r","border-w-l"],"border-w-y":["border-w-bs","border-w-be","border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-s","border-color-e","border-color-r","border-color-l"],"border-color-y":["border-color-bs","border-color-be","border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-ms","scroll-me","scroll-mr","scroll-ml"],"scroll-my":["scroll-mbs","scroll-mbe","scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-ps","scroll-pe","scroll-pr","scroll-pl"],"scroll-py":["scroll-pbs","scroll-pbe","scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},yI=X8(bI);function je(...e){return yI(cN(e))}var Bx={exports:{}},_s={};/**
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlight-engine-xqDwxvyZ.js","assets/index-D2tA406X.js","assets/index-DEJBGTqg.css","assets/markdown-gsWh3zpl.js","assets/qr-scanner.min-BrJY21Dj.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as iN,g as o8,a as m,R as Ro,j as s,b as _d,M as l8,c as c8,d as u8}from"./markdown-gsWh3zpl.js";import{_ as fo,a as aN,b as d8,c as f8}from"./account-R7yD1rZE.js";import{i as me,_ as Z0,r as jy,s as ky,d as h8,a as Gp,D as p8,b as m8,c as K0,e as g8,f as Jn,g as v8,h as br,j as x8,k as b8,o as Rm,l as yS,m as y8,n as w8,p as j8,q as k8,t as Sy,u as Zp,v as su,w as S8,x as wS,y as nn,z as Lt,A as Ul,T as ai,B as ys,C as C8,E as _8,R as Cy,F as _y,G as oN,H as E8,I as jS}from"./index-D2tA406X.js";import{D as N8,o as A8}from"./terminal-DWFexEE4.js";function lN(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=lN(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function cN(){for(var e,t,n=0,r="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=lN(e))&&(r&&(r+=" "),r+=t);return r}const T8=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},M8=(e,t)=>({classGroupId:e,validator:t}),uN=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Kp="-",kS=[],z8="arbitrary..",R8=e=>{const t=O8(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{if(c.startsWith("[")&&c.endsWith("]"))return D8(c);const d=c.split(Kp),f=d[0]===""&&d.length>1?1:0;return dN(d,f,t)},getConflictingClassGroupIds:(c,d)=>{if(d){const f=r[c],h=n[c];return f?h?T8(h,f):f:h||kS}return n[c]||kS}}},dN=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const a=e[t],l=n.nextPart.get(a);if(l){const h=dN(e,t+1,l);if(h)return h}const c=n.validators;if(c===null)return;const d=t===0?e.join(Kp):e.slice(t).join(Kp),f=c.length;for(let h=0;h<f;h++){const v=c[h];if(v.validator(d))return v.classGroupId}},D8=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?z8+r:void 0})(),O8=e=>{const{theme:t,classGroups:n}=e;return I8(n,t)},I8=(e,t)=>{const n=uN();for(const r in e){const a=e[r];Ey(a,n,r,t)}return n},Ey=(e,t,n,r)=>{const a=e.length;for(let l=0;l<a;l++){const c=e[l];$8(c,t,n,r)}},$8=(e,t,n,r)=>{if(typeof e=="string"){L8(e,t,n);return}if(typeof e=="function"){P8(e,t,n,r);return}B8(e,t,n,r)},L8=(e,t,n)=>{const r=e===""?t:fN(t,e);r.classGroupId=n},P8=(e,t,n,r)=>{if(U8(e)){Ey(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(M8(n,e))},B8=(e,t,n,r)=>{const a=Object.entries(e),l=a.length;for(let c=0;c<l;c++){const[d,f]=a[c];Ey(f,fN(t,d),n,r)}},fN=(e,t)=>{let n=e;const r=t.split(Kp),a=r.length;for(let l=0;l<a;l++){const c=r[l];let d=n.nextPart.get(c);d||(d=uN(),n.nextPart.set(c,d)),n=d}return n},U8=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,F8=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const a=(l,c)=>{n[l]=c,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(l){let c=n[l];if(c!==void 0)return c;if((c=r[l])!==void 0)return a(l,c),c},set(l,c){l in n?n[l]=c:a(l,c)}}},Y0="!",SS=":",q8=[],CS=(e,t,n,r,a)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:a}),H8=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=a=>{const l=[];let c=0,d=0,f=0,h;const v=a.length;for(let k=0;k<v;k++){const C=a[k];if(c===0&&d===0){if(C===SS){l.push(a.slice(f,k)),f=k+1;continue}if(C==="/"){h=k;continue}}C==="["?c++:C==="]"?c--:C==="("?d++:C===")"&&d--}const g=l.length===0?a:a.slice(f);let x=g,y=!1;g.endsWith(Y0)?(x=g.slice(0,-1),y=!0):g.startsWith(Y0)&&(x=g.slice(1),y=!0);const j=h&&h>f?h-f:void 0;return CS(l,y,x,j)};if(t){const a=t+SS,l=r;r=c=>c.startsWith(a)?l(c.slice(a.length)):CS(q8,!1,c,void 0,!0)}if(n){const a=r;r=l=>n({className:l,parseClassName:a})}return r},V8=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let a=[];for(let l=0;l<n.length;l++){const c=n[l],d=c[0]==="[",f=t.has(c);d||f?(a.length>0&&(a.sort(),r.push(...a),a=[]),r.push(c)):a.push(c)}return a.length>0&&(a.sort(),r.push(...a)),r}},G8=e=>({cache:F8(e.cacheSize),parseClassName:H8(e),sortModifiers:V8(e),postfixLookupClassGroupIds:Z8(e),...R8(e)}),Z8=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let r=0;r<n.length;r++)t[n[r]]=!0;return t},K8=/\s+/,Y8=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:l,postfixLookupClassGroupIds:c}=t,d=[],f=e.trim().split(K8);let h="";for(let v=f.length-1;v>=0;v-=1){const g=f[v],{isExternal:x,modifiers:y,hasImportantModifier:j,baseClassName:k,maybePostfixModifierPosition:C}=n(g);if(x){h=g+(h.length>0?" "+h:h);continue}let _=!!C,N;if(_){const B=k.substring(0,C);N=r(B);const O=N&&c[N]?r(k):void 0;O&&O!==N&&(N=O,_=!1)}else N=r(k);if(!N){if(!_){h=g+(h.length>0?" "+h:h);continue}if(N=r(k),!N){h=g+(h.length>0?" "+h:h);continue}_=!1}const S=y.length===0?"":y.length===1?y[0]:l(y).join(":"),T=j?S+Y0:S,z=T+N;if(d.indexOf(z)>-1)continue;d.push(z);const L=a(N,_);for(let B=0;B<L.length;++B){const O=L[B];d.push(T+O)}h=g+(h.length>0?" "+h:h)}return h},W8=(...e)=>{let t=0,n,r,a="";for(;t<e.length;)(n=e[t++])&&(r=hN(n))&&(a&&(a+=" "),a+=r);return a},hN=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=hN(e[r]))&&(n&&(n+=" "),n+=t);return n},X8=(e,...t)=>{let n,r,a,l;const c=f=>{const h=t.reduce((v,g)=>g(v),e());return n=G8(h),r=n.cache.get,a=n.cache.set,l=d,d(f)},d=f=>{const h=r(f);if(h)return h;const v=Y8(f,n);return a(f,v),v};return l=c,(...f)=>l(W8(...f))},Q8=[],Kn=e=>{const t=n=>n[e]||Q8;return t.isThemeGetter=!0,t.themeKey=e,t},pN=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,mN=/^\((?:(\w[\w-]*):)?(.+)\)$/i,J8=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,eI=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,tI=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,nI=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,sI=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,rI=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,to=e=>J8.test(e),St=e=>!!e&&!Number.isNaN(Number(e)),ji=e=>!!e&&Number.isInteger(Number(e)),Px=e=>e.endsWith("%")&&St(e.slice(0,-1)),ra=e=>eI.test(e),gN=()=>!0,iI=e=>tI.test(e)&&!nI.test(e),Ny=()=>!1,aI=e=>sI.test(e),oI=e=>rI.test(e),lI=e=>!Be(e)&&!Ue(e),cI=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),uI=e=>Do(e,bN,Ny),Be=e=>pN.test(e),dl=e=>Do(e,yN,iI),_S=e=>Do(e,xI,St),dI=e=>Do(e,jN,gN),fI=e=>Do(e,wN,Ny),ES=e=>Do(e,vN,Ny),hI=e=>Do(e,xN,oI),Zh=e=>Do(e,kN,aI),Ue=e=>mN.test(e),gd=e=>Fl(e,yN),pI=e=>Fl(e,wN),NS=e=>Fl(e,vN),mI=e=>Fl(e,bN),gI=e=>Fl(e,xN),Kh=e=>Fl(e,kN,!0),vI=e=>Fl(e,jN,!0),Do=(e,t,n)=>{const r=pN.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Fl=(e,t,n=!1)=>{const r=mN.exec(e);return r?r[1]?t(r[1]):n:!1},vN=e=>e==="position"||e==="percentage",xN=e=>e==="image"||e==="url",bN=e=>e==="length"||e==="size"||e==="bg-size",yN=e=>e==="length",xI=e=>e==="number",wN=e=>e==="family-name",jN=e=>e==="number"||e==="weight",kN=e=>e==="shadow",bI=()=>{const e=Kn("color"),t=Kn("font"),n=Kn("text"),r=Kn("font-weight"),a=Kn("tracking"),l=Kn("leading"),c=Kn("breakpoint"),d=Kn("container"),f=Kn("spacing"),h=Kn("radius"),v=Kn("shadow"),g=Kn("inset-shadow"),x=Kn("text-shadow"),y=Kn("drop-shadow"),j=Kn("blur"),k=Kn("perspective"),C=Kn("aspect"),_=Kn("ease"),N=Kn("animate"),S=()=>["auto","avoid","all","avoid-page","page","left","right","column"],T=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],z=()=>[...T(),Ue,Be],L=()=>["auto","hidden","clip","visible","scroll"],B=()=>["auto","contain","none"],O=()=>[Ue,Be,f],$=()=>[to,"full","auto",...O()],D=()=>[ji,"none","subgrid",Ue,Be],Y=()=>["auto",{span:["full",ji,Ue,Be]},ji,Ue,Be],P=()=>[ji,"auto",Ue,Be],M=()=>["auto","min","max","fr",Ue,Be],R=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],H=()=>["start","end","center","stretch","center-safe","end-safe"],I=()=>["auto",...O()],q=()=>[to,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...O()],G=()=>[d,to,"screen","full","dvw","lvw","svw","min","max","fit",...O()],X=()=>[to,"screen","full","lh","dvh","lvh","svh","min","max","fit",...O()],K=()=>[e,Ue,Be],ee=()=>[...T(),NS,ES,{position:[Ue,Be]}],Z=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ne=()=>["auto","cover","contain",mI,uI,{size:[Ue,Be]}],ie=()=>[Px,gd,dl],de=()=>["","none","full",h,Ue,Be],oe=()=>["",St,gd,dl],ae=()=>["solid","dashed","dotted","double"],Q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],pe=()=>[St,Px,NS,ES],Me=()=>["","none",j,Ue,Be],ze=()=>["none",St,Ue,Be],Le=()=>["none",St,Ue,Be],He=()=>[St,Ue,Be],Te=()=>[to,"full",...O()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[ra],breakpoint:[ra],color:[gN],container:[ra],"drop-shadow":[ra],ease:["in","out","in-out"],font:[lI],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[ra],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[ra],shadow:[ra],spacing:["px",St],text:[ra],"text-shadow":[ra],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",to,Be,Ue,C]}],container:["container"],"container-type":[{"@container":["","normal","size",Ue,Be]}],"container-named":[cI],columns:[{columns:[St,"auto",Be,Ue,d]}],"break-after":[{"break-after":S()}],"break-before":[{"break-before":S()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:z()}],overflow:[{overflow:L()}],"overflow-x":[{"overflow-x":L()}],"overflow-y":[{"overflow-y":L()}],overscroll:[{overscroll:B()}],"overscroll-x":[{"overscroll-x":B()}],"overscroll-y":[{"overscroll-y":B()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:$()}],"inset-x":[{"inset-x":$()}],"inset-y":[{"inset-y":$()}],start:[{"inset-s":$(),start:$()}],end:[{"inset-e":$(),end:$()}],"inset-bs":[{"inset-bs":$()}],"inset-be":[{"inset-be":$()}],top:[{top:$()}],right:[{right:$()}],bottom:[{bottom:$()}],left:[{left:$()}],visibility:["visible","invisible","collapse"],z:[{z:[ji,"auto",Ue,Be]}],basis:[{basis:[to,"full","auto",d,...O()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[St,to,"auto","initial","none",Be]}],grow:[{grow:["",St,Ue,Be]}],shrink:[{shrink:["",St,Ue,Be]}],order:[{order:[ji,"first","last","none",Ue,Be]}],"grid-cols":[{"grid-cols":D()}],"col-start-end":[{col:Y()}],"col-start":[{"col-start":P()}],"col-end":[{"col-end":P()}],"grid-rows":[{"grid-rows":D()}],"row-start-end":[{row:Y()}],"row-start":[{"row-start":P()}],"row-end":[{"row-end":P()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":M()}],"auto-rows":[{"auto-rows":M()}],gap:[{gap:O()}],"gap-x":[{"gap-x":O()}],"gap-y":[{"gap-y":O()}],"justify-content":[{justify:[...R(),"normal"]}],"justify-items":[{"justify-items":[...H(),"normal"]}],"justify-self":[{"justify-self":["auto",...H()]}],"align-content":[{content:["normal",...R()]}],"align-items":[{items:[...H(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...H(),{baseline:["","last"]}]}],"place-content":[{"place-content":R()}],"place-items":[{"place-items":[...H(),"baseline"]}],"place-self":[{"place-self":["auto",...H()]}],p:[{p:O()}],px:[{px:O()}],py:[{py:O()}],ps:[{ps:O()}],pe:[{pe:O()}],pbs:[{pbs:O()}],pbe:[{pbe:O()}],pt:[{pt:O()}],pr:[{pr:O()}],pb:[{pb:O()}],pl:[{pl:O()}],m:[{m:I()}],mx:[{mx:I()}],my:[{my:I()}],ms:[{ms:I()}],me:[{me:I()}],mbs:[{mbs:I()}],mbe:[{mbe:I()}],mt:[{mt:I()}],mr:[{mr:I()}],mb:[{mb:I()}],ml:[{ml:I()}],"space-x":[{"space-x":O()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":O()}],"space-y-reverse":["space-y-reverse"],size:[{size:q()}],"inline-size":[{inline:["auto",...G()]}],"min-inline-size":[{"min-inline":["auto",...G()]}],"max-inline-size":[{"max-inline":["none",...G()]}],"block-size":[{block:["auto",...X()]}],"min-block-size":[{"min-block":["auto",...X()]}],"max-block-size":[{"max-block":["none",...X()]}],w:[{w:[d,"screen",...q()]}],"min-w":[{"min-w":[d,"screen","none",...q()]}],"max-w":[{"max-w":[d,"screen","none","prose",{screen:[c]},...q()]}],h:[{h:["screen","lh",...q()]}],"min-h":[{"min-h":["screen","lh","none",...q()]}],"max-h":[{"max-h":["screen","lh","none",...q()]}],"font-size":[{text:["base",n,gd,dl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,vI,dI]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Px,Be]}],"font-family":[{font:[pI,fI,t]}],"font-features":[{"font-features":[Be]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[a,Ue,Be]}],"line-clamp":[{"line-clamp":[St,"none",Ue,_S]}],leading:[{leading:["none",l,...O()]}],"list-image":[{"list-image":["none",Ue,Be]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",Ue,Be]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:K()}],"text-color":[{text:K()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ae(),"wavy"]}],"text-decoration-thickness":[{decoration:[St,"from-font","auto",Ue,dl]}],"text-decoration-color":[{decoration:K()}],"underline-offset":[{"underline-offset":[St,"auto",Ue,Be]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:O()}],"tab-size":[{tab:[ji,Ue,Be]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",Ue,Be]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",Ue,Be]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:ee()}],"bg-repeat":[{bg:Z()}],"bg-size":[{bg:ne()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ji,Ue,Be],radial:["",Ue,Be],conic:["",ji,Ue,Be]},gI,hI]}],"bg-color":[{bg:K()}],"gradient-from-pos":[{from:ie()}],"gradient-via-pos":[{via:ie()}],"gradient-to-pos":[{to:ie()}],"gradient-from":[{from:K()}],"gradient-via":[{via:K()}],"gradient-to":[{to:K()}],rounded:[{rounded:de()}],"rounded-s":[{"rounded-s":de()}],"rounded-e":[{"rounded-e":de()}],"rounded-t":[{"rounded-t":de()}],"rounded-r":[{"rounded-r":de()}],"rounded-b":[{"rounded-b":de()}],"rounded-l":[{"rounded-l":de()}],"rounded-ss":[{"rounded-ss":de()}],"rounded-se":[{"rounded-se":de()}],"rounded-ee":[{"rounded-ee":de()}],"rounded-es":[{"rounded-es":de()}],"rounded-tl":[{"rounded-tl":de()}],"rounded-tr":[{"rounded-tr":de()}],"rounded-br":[{"rounded-br":de()}],"rounded-bl":[{"rounded-bl":de()}],"border-w":[{border:oe()}],"border-w-x":[{"border-x":oe()}],"border-w-y":[{"border-y":oe()}],"border-w-s":[{"border-s":oe()}],"border-w-e":[{"border-e":oe()}],"border-w-bs":[{"border-bs":oe()}],"border-w-be":[{"border-be":oe()}],"border-w-t":[{"border-t":oe()}],"border-w-r":[{"border-r":oe()}],"border-w-b":[{"border-b":oe()}],"border-w-l":[{"border-l":oe()}],"divide-x":[{"divide-x":oe()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":oe()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...ae(),"hidden","none"]}],"divide-style":[{divide:[...ae(),"hidden","none"]}],"border-color":[{border:K()}],"border-color-x":[{"border-x":K()}],"border-color-y":[{"border-y":K()}],"border-color-s":[{"border-s":K()}],"border-color-e":[{"border-e":K()}],"border-color-bs":[{"border-bs":K()}],"border-color-be":[{"border-be":K()}],"border-color-t":[{"border-t":K()}],"border-color-r":[{"border-r":K()}],"border-color-b":[{"border-b":K()}],"border-color-l":[{"border-l":K()}],"divide-color":[{divide:K()}],"outline-style":[{outline:[...ae(),"none","hidden"]}],"outline-offset":[{"outline-offset":[St,Ue,Be]}],"outline-w":[{outline:["",St,gd,dl]}],"outline-color":[{outline:K()}],shadow:[{shadow:["","inner","none",v,Kh,Zh]}],"shadow-color":[{shadow:K()}],"inset-shadow":[{"inset-shadow":["none",g,Kh,Zh]}],"inset-shadow-color":[{"inset-shadow":K()}],"ring-w":[{ring:oe()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:K()}],"ring-offset-w":[{"ring-offset":[St,dl]}],"ring-offset-color":[{"ring-offset":K()}],"inset-ring-w":[{"inset-ring":oe()}],"inset-ring-color":[{"inset-ring":K()}],"text-shadow":[{"text-shadow":["none",x,Kh,Zh]}],"text-shadow-color":[{"text-shadow":K()}],opacity:[{opacity:[St,Ue,Be]}],"mix-blend":[{"mix-blend":[...Q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Q()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[St]}],"mask-image-linear-from-pos":[{"mask-linear-from":pe()}],"mask-image-linear-to-pos":[{"mask-linear-to":pe()}],"mask-image-linear-from-color":[{"mask-linear-from":K()}],"mask-image-linear-to-color":[{"mask-linear-to":K()}],"mask-image-t-from-pos":[{"mask-t-from":pe()}],"mask-image-t-to-pos":[{"mask-t-to":pe()}],"mask-image-t-from-color":[{"mask-t-from":K()}],"mask-image-t-to-color":[{"mask-t-to":K()}],"mask-image-r-from-pos":[{"mask-r-from":pe()}],"mask-image-r-to-pos":[{"mask-r-to":pe()}],"mask-image-r-from-color":[{"mask-r-from":K()}],"mask-image-r-to-color":[{"mask-r-to":K()}],"mask-image-b-from-pos":[{"mask-b-from":pe()}],"mask-image-b-to-pos":[{"mask-b-to":pe()}],"mask-image-b-from-color":[{"mask-b-from":K()}],"mask-image-b-to-color":[{"mask-b-to":K()}],"mask-image-l-from-pos":[{"mask-l-from":pe()}],"mask-image-l-to-pos":[{"mask-l-to":pe()}],"mask-image-l-from-color":[{"mask-l-from":K()}],"mask-image-l-to-color":[{"mask-l-to":K()}],"mask-image-x-from-pos":[{"mask-x-from":pe()}],"mask-image-x-to-pos":[{"mask-x-to":pe()}],"mask-image-x-from-color":[{"mask-x-from":K()}],"mask-image-x-to-color":[{"mask-x-to":K()}],"mask-image-y-from-pos":[{"mask-y-from":pe()}],"mask-image-y-to-pos":[{"mask-y-to":pe()}],"mask-image-y-from-color":[{"mask-y-from":K()}],"mask-image-y-to-color":[{"mask-y-to":K()}],"mask-image-radial":[{"mask-radial":[Ue,Be]}],"mask-image-radial-from-pos":[{"mask-radial-from":pe()}],"mask-image-radial-to-pos":[{"mask-radial-to":pe()}],"mask-image-radial-from-color":[{"mask-radial-from":K()}],"mask-image-radial-to-color":[{"mask-radial-to":K()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":T()}],"mask-image-conic-pos":[{"mask-conic":[St]}],"mask-image-conic-from-pos":[{"mask-conic-from":pe()}],"mask-image-conic-to-pos":[{"mask-conic-to":pe()}],"mask-image-conic-from-color":[{"mask-conic-from":K()}],"mask-image-conic-to-color":[{"mask-conic-to":K()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:ee()}],"mask-repeat":[{mask:Z()}],"mask-size":[{mask:ne()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",Ue,Be]}],filter:[{filter:["","none",Ue,Be]}],blur:[{blur:Me()}],brightness:[{brightness:[St,Ue,Be]}],contrast:[{contrast:[St,Ue,Be]}],"drop-shadow":[{"drop-shadow":["","none",y,Kh,Zh]}],"drop-shadow-color":[{"drop-shadow":K()}],grayscale:[{grayscale:["",St,Ue,Be]}],"hue-rotate":[{"hue-rotate":[St,Ue,Be]}],invert:[{invert:["",St,Ue,Be]}],saturate:[{saturate:[St,Ue,Be]}],sepia:[{sepia:["",St,Ue,Be]}],"backdrop-filter":[{"backdrop-filter":["","none",Ue,Be]}],"backdrop-blur":[{"backdrop-blur":Me()}],"backdrop-brightness":[{"backdrop-brightness":[St,Ue,Be]}],"backdrop-contrast":[{"backdrop-contrast":[St,Ue,Be]}],"backdrop-grayscale":[{"backdrop-grayscale":["",St,Ue,Be]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[St,Ue,Be]}],"backdrop-invert":[{"backdrop-invert":["",St,Ue,Be]}],"backdrop-opacity":[{"backdrop-opacity":[St,Ue,Be]}],"backdrop-saturate":[{"backdrop-saturate":[St,Ue,Be]}],"backdrop-sepia":[{"backdrop-sepia":["",St,Ue,Be]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":O()}],"border-spacing-x":[{"border-spacing-x":O()}],"border-spacing-y":[{"border-spacing-y":O()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",Ue,Be]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[St,"initial",Ue,Be]}],ease:[{ease:["linear","initial",_,Ue,Be]}],delay:[{delay:[St,Ue,Be]}],animate:[{animate:["none",N,Ue,Be]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[k,Ue,Be]}],"perspective-origin":[{"perspective-origin":z()}],rotate:[{rotate:ze()}],"rotate-x":[{"rotate-x":ze()}],"rotate-y":[{"rotate-y":ze()}],"rotate-z":[{"rotate-z":ze()}],scale:[{scale:Le()}],"scale-x":[{"scale-x":Le()}],"scale-y":[{"scale-y":Le()}],"scale-z":[{"scale-z":Le()}],"scale-3d":["scale-3d"],skew:[{skew:He()}],"skew-x":[{"skew-x":He()}],"skew-y":[{"skew-y":He()}],transform:[{transform:[Ue,Be,"","none","gpu","cpu"]}],"transform-origin":[{origin:z()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Te()}],"translate-x":[{"translate-x":Te()}],"translate-y":[{"translate-y":Te()}],"translate-z":[{"translate-z":Te()}],"translate-none":["translate-none"],zoom:[{zoom:[ji,Ue,Be]}],accent:[{accent:K()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:K()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",Ue,Be]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":K()}],"scrollbar-track-color":[{"scrollbar-track":K()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":O()}],"scroll-mx":[{"scroll-mx":O()}],"scroll-my":[{"scroll-my":O()}],"scroll-ms":[{"scroll-ms":O()}],"scroll-me":[{"scroll-me":O()}],"scroll-mbs":[{"scroll-mbs":O()}],"scroll-mbe":[{"scroll-mbe":O()}],"scroll-mt":[{"scroll-mt":O()}],"scroll-mr":[{"scroll-mr":O()}],"scroll-mb":[{"scroll-mb":O()}],"scroll-ml":[{"scroll-ml":O()}],"scroll-p":[{"scroll-p":O()}],"scroll-px":[{"scroll-px":O()}],"scroll-py":[{"scroll-py":O()}],"scroll-ps":[{"scroll-ps":O()}],"scroll-pe":[{"scroll-pe":O()}],"scroll-pbs":[{"scroll-pbs":O()}],"scroll-pbe":[{"scroll-pbe":O()}],"scroll-pt":[{"scroll-pt":O()}],"scroll-pr":[{"scroll-pr":O()}],"scroll-pb":[{"scroll-pb":O()}],"scroll-pl":[{"scroll-pl":O()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",Ue,Be]}],fill:[{fill:["none",...K()]}],"stroke-w":[{stroke:[St,gd,dl,_S]}],stroke:[{stroke:["none",...K()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["start","end","right","left"],"inset-y":["inset-bs","inset-be","top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["ps","pe","pr","pl"],py:["pbs","pbe","pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["ms","me","mr","ml"],my:["mbs","mbe","mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-s","border-w-e","border-w-r","border-w-l"],"border-w-y":["border-w-bs","border-w-be","border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-s","border-color-e","border-color-r","border-color-l"],"border-color-y":["border-color-bs","border-color-be","border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-ms","scroll-me","scroll-mr","scroll-ml"],"scroll-my":["scroll-mbs","scroll-mbe","scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-ps","scroll-pe","scroll-pr","scroll-pl"],"scroll-py":["scroll-pbs","scroll-pbe","scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},yI=X8(bI);function je(...e){return yI(cN(e))}var Bx={exports:{}},_s={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-dom.production.js
|
|
5
5
|
*
|
|
@@ -752,7 +752,7 @@ ${$.requestId}`;"resolved"in $?L.add(D):L.delete(D),B.setState(Y=>({interactions
|
|
|
752
752
|
`),r=[])}return r.length&&n.push(r.join(`
|
|
753
753
|
`)),n.filter(c=>c!=="")}const nJ={ts:"typescript",mts:"typescript",cts:"typescript",js:"javascript",mjs:"javascript",cjs:"javascript",node:"javascript",sh:"bash",shell:"bash",zsh:"bash",console:"bash",shellscript:"bash",fish:"bash",ksh:"bash",py:"python",python3:"python",rb:"ruby",rs:"rust",golang:"go",yml:"yaml",md:"markdown",mdx:"markdown",kt:"kotlin",kts:"kotlin",objc:"objective-c","objective-c":"objective-c",m:"objective-c",mm:"objective-c",cs:"csharp","c#":"csharp","c++":"cpp",cc:"cpp",cxx:"cpp",hpp:"cpp",hh:"cpp",h:"c",docker:"dockerfile",containerfile:"dockerfile",tf:"terraform",tfvars:"terraform",ps1:"powershell",pwsh:"powershell",ps:"powershell",cmd:"bat",batch:"bat",htm:"html",xhtml:"html",svg:"xml",plist:"xml",xsd:"xml",patch:"diff",gql:"graphql",tex:"latex",mk:"makefile",make:"makefile",protobuf:"proto",conf:"ini",cfg:"ini",properties:"ini",env:"ini",json5:"jsonc",jsonl:"json",ndjson:"json",babelrc:"json",eslintrc:"jsonc",ex:"elixir",exs:"elixir",hs:"haskell",clj:"clojure",cljs:"clojure",pl:"perl",rmd:"r"},sJ=new Set(["astro","bash","bat","c","clojure","cpp","csharp","css","dart","diff","dockerfile","elixir","go","graphql","haskell","hcl","html","ini","java","javascript","json","jsonc","jsx","kotlin","latex","less","lua","makefile","markdown","nginx","nix","objective-c","perl","php","powershell","prisma","proto","python","r","ruby","rust","sass","scala","scss","sql","svelte","swift","terraform","toml","tsx","typescript","vim","vue","xml","yaml","zig"]);function X5(e){if(!e)return;const t=e.toLowerCase(),n=nJ[t]??t;return sJ.has(n)?n:void 0}const cE={dockerfile:"dockerfile",containerfile:"dockerfile",makefile:"makefile",gnumakefile:"makefile",gemfile:"ruby",rakefile:"ruby",podfile:"ruby",brewfile:"ruby","cmakelists.txt":"makefile",".bashrc":"bash",".zshrc":"bash",".profile":"bash",".env":"ini",".gitconfig":"ini",".editorconfig":"ini"};function Q5(e){const t=e.split(/[\\/]/).at(-1).toLowerCase();if(cE[t])return cE[t];if(t.startsWith("dockerfile."))return"dockerfile";const n=t.lastIndexOf(".");return n>0?X5(t.slice(n+1)):void 0}const rJ=6e4,iJ=2e3;function aJ(e){if(e.length>rJ)return!1;let t=1;for(let n=e.indexOf(`
|
|
754
754
|
`);n!==-1;n=e.indexOf(`
|
|
755
|
-
`,n+1))if(++t>iJ)return!1;return!0}const bl=new Map,oJ=200;function lJ(e,t){bl.delete(e),bl.set(e,t),bl.size>oJ&&bl.delete(bl.keys().next().value)}const cJ=()=>new Promise(e=>{typeof requestIdleCallback=="function"?requestIdleCallback(()=>e(),{timeout:300}):setTimeout(e,16)});function Sm(e,t,n=!0){const r=X5(t),a=r&&`${r}\0${e}`,[l,c]=m.useState();if(m.useEffect(()=>{if(!n||!a||!r||bl.has(a)||!aJ(e))return;let d=!0;return cJ().then(()=>d?Z0(()=>import("./highlight-engine-
|
|
755
|
+
`,n+1))if(++t>iJ)return!1;return!0}const bl=new Map,oJ=200;function lJ(e,t){bl.delete(e),bl.set(e,t),bl.size>oJ&&bl.delete(bl.keys().next().value)}const cJ=()=>new Promise(e=>{typeof requestIdleCallback=="function"?requestIdleCallback(()=>e(),{timeout:300}):setTimeout(e,16)});function Sm(e,t,n=!0){const r=X5(t),a=r&&`${r}\0${e}`,[l,c]=m.useState();if(m.useEffect(()=>{if(!n||!a||!r||bl.has(a)||!aJ(e))return;let d=!0;return cJ().then(()=>d?Z0(()=>import("./highlight-engine-xqDwxvyZ.js"),__vite__mapDeps([0,1,2,3])).then(f=>f.tokenize(e,r)):void 0).then(f=>{f&&(lJ(a,f),d&&c({key:a,tokens:f}))}).catch(()=>{}),()=>{d=!1}},[e,n,r,a]),!!a)return l?.key===a?l.tokens:bl.get(a)}function uJ(e,t){let n=e.trim();if(!n||n.startsWith("#"))return;n=n.replace(/^file:\/\//,"");try{n=decodeURI(n)}catch{}let r;const a=/(?:#L(\d+)(?:-L?\d+)?|:(\d+)(?::\d+)?)$/.exec(n);if(a&&(r=Number(a[1]??a[2]),n=n.slice(0,a.index)),!/^[a-z][a-z0-9+.-]*:/i.test(n)){if(!n.startsWith("/")&&!n.startsWith("~")){if(!t)return;n=`${t.replace(/\/$/,"")}/${n.replace(/^\.\//,"")}`}return n?{path:n,...r&&r>0?{line:r}:{}}:void 0}}function sf({added:e,removed:t,className:n="diff-stat"}){return!e&&!t?null:s.jsxs("span",{className:n,children:[e>0&&s.jsxs("span",{className:"diff-add",children:["+",e]}),e>0&&t>0&&" ",t>0&&s.jsxs("span",{className:"diff-del",children:["−",t]})]})}function J5({steps:e,open:t,onToggle:n}){const r=KX(e),a=WX(r),l=XX(r);return s.jsxs("button",{type:"button",className:"steps-summary","aria-expanded":t,onClick:n,children:[s.jsx(au,{className:"steps-summary-icon","aria-hidden":"true"}),s.jsx("span",{className:"steps-summary-label",children:a}),l&&s.jsx("span",{className:"steps-summary-failed",children:l}),s.jsx(sf,{added:r.added,removed:r.removed,className:"steps-summary-diff"}),s.jsx(li,{className:"steps-summary-chevron","aria-hidden":"true"})]})}function rf({text:e,label:t="复制消息"}){const[n,r]=m.useState(!1),a=$t();return m.useEffect(()=>{if(!n)return;const l=setTimeout(()=>r(!1),2e3);return()=>clearTimeout(l)},[n]),s.jsxs("span",{className:"message-copy",children:[s.jsx(F,{variant:"ghost",size:"icon-sm",disabled:a.busy,"aria-label":n?"已复制":t,title:n?"已复制":t,onClick:()=>void a.run(async()=>{await navigator.clipboard.writeText(e),r(!0)}),children:n?s.jsx(Hn,{}):s.jsx(El,{})}),a.error&&s.jsx("span",{className:"form-error",role:"alert",children:"复制失败,请选中文本复制。"})]})}const Vo=m.createContext(null),ez=m.createContext(void 0),tz=m.createContext(!0);function Xb(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Xb).join(""):m.isValidElement(e)?Xb(e.props.children):""}function dJ({tokens:e}){return e.map((t,n)=>s.jsxs(m.Fragment,{children:[n>0&&`
|
|
756
756
|
`,t.map((r,a)=>r.color?s.jsx("span",{style:{color:r.color},children:r.content},a):r.content)]},n))}function fJ({children:e}){const t=m.Children.toArray(e).find(m.isValidElement),n=t&&t.props.className,r=n?.match(/language-([\w+-]+)/)?.[1],a=m.useMemo(()=>Xb(t).replace(/\n$/,""),[t]),l=Sm(a,r,m.useContext(tz)),c=m.useRef(null),[d,f]=m.useState(!1),h=$t();return m.useEffect(()=>{if(!d)return;const v=setTimeout(()=>f(!1),2e3);return()=>clearTimeout(v)},[d]),s.jsxs("div",{className:"code-surface",children:[s.jsxs("div",{className:"code-toolbar",children:[s.jsx("span",{children:r??"代码"}),s.jsxs(F,{variant:"ghost",size:me?"icon-sm":"sm",className:"code-copy",disabled:h.busy,"aria-label":d?"代码已复制":"复制代码",title:d?"已复制":"复制代码",onClick:()=>void h.run(async()=>{await navigator.clipboard.writeText(c.current?.textContent??""),f(!0)}),children:[d?s.jsx(Hn,{"data-icon":"inline-start"}):s.jsx(El,{"data-icon":"inline-start"}),!me&&(d?"已复制":"复制")]})]}),s.jsx("pre",{ref:c,tabIndex:0,"aria-label":r?r+" 代码":"代码",children:s.jsx("code",{className:n,"data-highlighted":l?!0:void 0,children:l?s.jsx(dJ,{tokens:l}):a})}),s.jsx(it,{error:h.error?"无法访问剪贴板,请选中代码后复制。":void 0})]})}function hJ({href:e,children:t}){const n=m.useContext(Vo),r=e&&uJ(e,n?.cwd);return s.jsx("a",{href:e,target:r?void 0:"_blank",rel:"noreferrer",onClick:a=>{r&&n&&(a.preventDefault(),n.open(r.path,r.line))},children:t})}const pJ=[c8],mJ=e=>e.startsWith("file://")?e:u8(e),gJ={pre:({children:e})=>s.jsx(fJ,{children:e}),a:({href:e,children:t})=>s.jsx(hJ,{href:e,children:t}),img:({src:e,alt:t})=>s.jsxs("a",{href:typeof e=="string"?e:void 0,target:"_blank",rel:"noreferrer",children:[t||"查看图片"," ↗"]})},nz=m.memo(function({text:t}){return s.jsx(l8,{remarkPlugins:pJ,urlTransform:mJ,components:gJ,children:t})});function ja({text:e}){return s.jsx("div",{className:"markdown",children:s.jsx(nz,{text:e})})}function uE({text:e,streaming:t}){const n=eJ(e,t),r=m.useMemo(()=>tJ(n),[n]);return s.jsx("div",{className:"markdown",children:r.map((a,l)=>s.jsx("div",{className:"markdown-block",children:s.jsx(tz.Provider,{value:!t||l<r.length-1,children:s.jsx(nz,{text:a})})},l))})}function sz({uri:e,alt:t,download:n,onError:r}){const[a,l]=m.useState(!1);return s.jsxs(Bo,{open:a,onOpenChange:l,children:[s.jsx("button",{type:"button",className:"message-image-trigger","aria-label":"查看大图",onClick:()=>l(!0),children:s.jsx("img",{className:"message-image",src:e,alt:t,loading:"lazy",referrerPolicy:"no-referrer",onError:r})}),s.jsxs(Uo,{className:"image-lightbox-content w-auto max-w-[92vw] gap-0 bg-transparent p-0 shadow-none ring-0 sm:max-w-[92vw]",showCloseButton:!1,children:[s.jsx(Fo,{className:"sr-only",children:t}),s.jsx("img",{className:"image-lightbox-image",src:e,alt:t,referrerPolicy:"no-referrer"}),s.jsxs("div",{className:"image-lightbox-actions",children:[s.jsx(F,{variant:"ghost",size:"icon-sm",asChild:!0,title:"下载原图","aria-label":"下载原图",children:s.jsx("a",{href:e,download:n??(e.startsWith("data:")?"image":void 0),target:"_blank",rel:"noreferrer",children:s.jsx(S1,{})})}),s.jsx(M1,{asChild:!0,children:s.jsx(F,{variant:"ghost",size:"icon-sm","aria-label":"关闭",children:s.jsx(zn,{})})})]})]})]})}function vJ({block:e,sessionId:t}){const n=Gn(),[r,a]=m.useState(e.data?`data:${e.mimeType};base64,${e.data}`:e.uri&&/^(data:image\/|https?:\/\/)/.test(e.uri)?e.uri:void 0),[l,c]=m.useState(),[d,f]=m.useState(0),h=n.loadImage;return m.useEffect(()=>{let v=!0;return c(void 0),a(e.data?`data:${e.mimeType};base64,${e.data}`:e.uri&&/^(data:image\/|https?:\/\/)/.test(e.uri)?e.uri:void 0),e.uri?.startsWith("linkshell-event:")&&h(t,e.uri).then(g=>{v&&a(g)},()=>{v&&c("图片加载失败")}),()=>{v=!1}},[h,e.uri,e.data,e.mimeType,t,d]),r?s.jsx(sz,{uri:r,alt:"会话图片",onError:()=>{a(void 0),c("图片加载失败")}}):s.jsxs("span",{className:"message-asset-state",role:"status",children:[l??"图片加载中…",l&&s.jsx(F,{variant:"link",size:"sm",onClick:()=>f(v=>v+1),children:"重试图片"})]})}function dE({block:e,sessionId:t,download:n}){const{loadImage:r}=Gn(),[a,l]=m.useState(e.data?`data:${e.mimeType};base64,${e.data}`:e.uri?.startsWith("linkshell-event:")?void 0:e.uri),[c,d]=m.useState();return m.useEffect(()=>{let f=!0;return d(void 0),l(e.data?`data:${e.mimeType};base64,${e.data}`:e.uri?.startsWith("linkshell-event:")?void 0:e.uri),e.uri?.startsWith("linkshell-event:")&&r(t,e.uri).then(h=>{f&&l(h)},()=>{f&&d("附件加载失败")}),()=>{f=!1}},[e.data,e.uri,e.mimeType,r,t]),a?/^(data:|https?:\/\/)/.test(a)?s.jsxs("div",{className:"protocol-asset",children:[e.mimeType.startsWith("audio/")?s.jsx("audio",{controls:!0,preload:"metadata",src:a}):e.mimeType.startsWith("image/")?s.jsx(sz,{uri:a,alt:n??"附件",download:n}):null,s.jsxs("a",{className:"resource-chip",href:a,download:n??"audio",children:["下载",n?` ${n}`:"音频"]})]}):s.jsx("span",{className:"muted",children:"附件地址无效"}):s.jsx("span",{className:"muted",children:c??"附件加载中…"})}function kg({blocks:e,sessionId:t,onFile:n}){return s.jsx(s.Fragment,{children:e.map((r,a)=>r.type==="text"?s.jsx(ja,{text:r.text},a):r.type==="image"?s.jsx(vJ,{block:r,sessionId:t},a):r.type==="audio"?s.jsx(dE,{block:r,sessionId:t},a):r.type==="resource"?s.jsxs("details",{className:"notice-card",open:!!r.resource.text&&r.resource.text.length<2e3,children:[s.jsxs("summary",{children:[r.resource.uri," · ",r.resource.mimeType??"附件"]}),r.resource.text!==void 0?s.jsxs(s.Fragment,{children:[s.jsx(rf,{text:r.resource.text,label:"复制附件文本"}),s.jsx("pre",{tabIndex:0,children:r.resource.text})]}):s.jsx(dE,{block:{data:r.resource.blob,uri:r.resource.assetUri,mimeType:r.resource.mimeType??"application/octet-stream"},sessionId:t,download:r.resource.uri.split("/").at(-1)})]},a):/^https?:\/\//.test(r.uri)?s.jsxs("a",{href:r.uri,target:"_blank",rel:"noreferrer",className:"resource-chip",children:[r.name," ↗"]},a):s.jsxs(F,{variant:"ghost",size:"plain",className:"resource-chip",onClick:()=>n(r.uri.replace(/^file:\/\//,"")),children:[r.kind==="skill"?"技能 · ":"文件 · ",r.name]},a))})}function hw(e){return e.type==="diff"?uw(e.oldText??"",e.newText):A5(e.diff)}function rz({lines:e,path:t}){const n=m.useMemo(()=>PX(e),[e]),r=t?Q5(t):void 0,a=m.useMemo(()=>{const h=[],v=[],g=e.map(x=>x.kind==="del"?h.push(x.text)-1:(x.kind==="same"&&h.push(x.text),v.push(x.text)-1));return{before:h.join(`
|
|
757
757
|
`),after:v.join(`
|
|
758
758
|
`),at:g}},[e]),l=Sm(a.before,r),c=Sm(a.after,r),d=m.useMemo(()=>new Map(e.map((h,v)=>[h,v])),[e]),f=h=>(h.kind==="del"?l:c)?.[a.at[d.get(h)]];return s.jsxs("div",{className:"diff-view",role:"table","aria-label":"差异",children:[n.map((h,v)=>s.jsxs(m.Fragment,{children:[h.skipped>0&&s.jsxs("div",{className:"diff-skip",role:"row",children:[h.skipped," 行未改动"]}),h.lines.map((g,x)=>s.jsxs("div",{className:"diff-line","data-kind":g.kind,role:"row",children:[s.jsx("span",{className:"diff-number","aria-hidden":!0,children:g.old??""}),s.jsx("span",{className:"diff-number","aria-hidden":!0,children:g.new??""}),s.jsx("span",{className:"diff-sign","aria-hidden":!0,children:g.kind==="add"?"+":g.kind==="del"?"−":""}),s.jsx("code",{children:g.text?s.jsx(xJ,{text:g.text,tokens:f(g)}):" "})]},x))]},v)),!n.length&&s.jsx("div",{className:"diff-skip",children:"没有内容变化"})]})}function xJ({text:e,tokens:t}){return!t||t.map(n=>n.content).join("")!==e?e:t.map((n,r)=>n.color?s.jsx("span",{style:{color:n.color},children:n.content},r):n.content)}function pw({change:e}){const t=m.useContext(Vo)?.cwd,n=c=>t&&c.startsWith(`${t.replace(/\/$/,"")}/`)?c.slice(t.replace(/\/$/,"").length+1):c,r=m.useMemo(()=>hw(e),[e]),a=jg(r),l=e.type==="patch"&&e.movePath?`${e.path} → ${e.movePath}`:e.path;return s.jsxs("details",{className:"diff-block",open:!0,children:[s.jsxs("summary",{title:l,children:[s.jsxs("span",{className:"diff-path",children:[n(e.path),e.type==="patch"&&e.movePath?` → ${n(e.movePath)}`:""]}),s.jsx(sf,{added:a.added,removed:a.removed})]}),s.jsx(rz,{lines:r,path:e.type==="patch"&&e.movePath?e.movePath:e.path})]})}function bJ({blocks:e,sessionId:t,onFile:n}){const r=Sf(e),a=fM(r.text);if(a)return s.jsx(s.Fragment,{children:a.map((c,d)=>s.jsxs("div",{className:"question-reply",children:[s.jsx("small",{children:c.question}),s.jsx("p",{children:c.answer})]},d))});const l=e.filter(c=>c.type!=="text");return s.jsxs(s.Fragment,{children:[r.text&&s.jsx(ja,{text:r.text}),l.length>0&&s.jsx(kg,{blocks:l,sessionId:t,onFile:n})]})}function fE(e){return e.length>2400||e.split(`
|
|
@@ -771,7 +771,7 @@ ${t.detail}`:t.label,children:[s.jsx(r,{"aria-hidden":!0}),s.jsx("span",{childre
|
|
|
771
771
|
`),Z=await r.call("agents.editor",{agent:v,editorId:g.editorId,operation:"suggest",text:y,position:{line:ee.length-1,character:ee.at(-1).length}},6e4);x(ne=>({...ne,...Z})),N(Z.suggestions??[]),T(void 0)}),children:[s.jsx(pC,{"data-icon":"inline-start"}),"获取光标处建议"]})]}),s.jsx("span",{className:"resource-caption",role:"status",children:z&&s.jsxs(s.Fragment,{children:[s.jsx(vt,{className:"resource-inline-spinner animate-spin","aria-hidden":"true"}),z]})}),_?.length===0&&s.jsx(an,{title:"这个位置暂时没有编辑建议",description:"移动光标到需要调整的代码,或修改内容后再试。"}),!!_?.length&&s.jsxs("section",{className:"resource-suggestions","aria-label":"编辑建议",children:[s.jsxs("h3",{children:["编辑建议 ",s.jsx(ui,{variant:"secondary",children:_.length})]}),_.map(ee=>s.jsxs("article",{className:"resource-suggestion",children:[s.jsxs("div",{children:[s.jsx("strong",{children:ee.kind==="jump"?"跳转到相关代码":ee.kind==="rename"?`重命名为 ${ee.newName}`:ee.kind==="searchAndReplace"?"搜索并替换":`${ee.edits.length} 处代码修改`}),s.jsx("p",{className:"resource-path",title:ee.uri,children:ee.uri}),ee.kind==="rename"&&s.jsx("p",{className:"resource-caption",children:"语义重命名需要在电脑编辑器中执行。"})]}),s.jsxs("div",{className:"resource-inline-actions",children:[ee.kind!=="rename"&&s.jsx(F,{variant:"outline",size:"sm",disabled:l.busy,onClick:()=>void q("正在生成预览…",async()=>{T((await r.call("agents.editor",{agent:v,editorId:g.editorId,operation:"preview",suggestionId:ee.id})).preview)}),children:"预览差异"}),s.jsx(F,{variant:"ghost",size:"sm",disabled:l.busy,onClick:()=>void q("正在忽略建议…",async()=>{await r.call("agents.editor",{agent:v,editorId:g.editorId,operation:"reject",suggestionId:ee.id}),N(Z=>Z?.filter(ne=>ne.id!==ee.id)),T(void 0)}),children:"忽略"})]})]},ee.id))]}),S&&s.jsxs("article",{className:"resource-edit-preview",children:[s.jsxs("header",{className:"resource-reader-heading",children:[s.jsx("strong",{children:S.kind==="jump"?"跳转预览":"确认修改"}),s.jsx(F,{variant:"ghost",size:"icon-sm","aria-label":"关闭修改预览",disabled:l.busy,onClick:()=>T(void 0),children:s.jsx(zn,{})})]}),s.jsxs("p",{className:"resource-path",children:[S.path,S.position?`:${S.position.line+1}`:""]}),S.kind!=="jump"&&s.jsxs(s.Fragment,{children:[s.jsx(pw,{change:{type:"diff",path:S.path,oldText:S.before,newText:S.after}}),s.jsx("p",{className:"resource-caption",children:"应用后会立即保存到电脑。请确认上方的修改内容。"})]}),s.jsx(F,{disabled:l.busy,onClick:()=>void q(S.kind==="jump"?"正在跳转…":"正在应用修改…",async()=>{const ee=await r.call("agents.editor",{agent:v,editorId:g.editorId,operation:"apply",previewId:S.id});x(Z=>({...Z,...ee})),j(ee.text??""),C(ee.text??""),T(void 0),N(void 0),O(S.kind==="jump"?"已跳转到目标位置":"修改已应用并保存到电脑"),ee.position&&requestAnimationFrame(()=>{const ne=(ee.text??"").split(`
|
|
772
772
|
`).slice(0,ee.position.line).reduce((ie,de)=>ie+de.length+1,0)+ee.position.character;Y.current?.focus(),Y.current?.setSelectionRange(ne,ne)})}),children:S.kind==="jump"?"跳转到这里":"应用并保存"})]})]}):d.length?s.jsxs(Yn,{children:[s.jsxs(Et,{children:[s.jsx(Rt,{children:"选择编辑 Agent"}),s.jsx(Br,{label:"选择支持编辑建议的 ACP Agent",value:v,onValueChange:h,placeholder:"选择 Agent",options:d.map(ee=>({value:ee.id,label:ee.label}))}),s.jsx(as,{children:"Agent 需要开启并支持 ACP 编辑建议。打开后可以修改文本,或在光标位置获取建议;应用前会展示差异。"})]}),s.jsxs(F,{disabled:!v||l.busy,onClick:()=>void q("正在打开编辑器…",K),children:[l.busy?s.jsx(vt,{className:"animate-spin","data-icon":"inline-start"}):s.jsx(pC,{"data-icon":"inline-start"}),l.busy?"正在打开…":"打开编辑器"]})]}):s.jsx(an,{title:"还没有可用的编辑 Agent",description:"请先在电脑上安装 ACP Agent,并在 Agent 设置中启用编辑建议,再返回这里编辑文件。"})]})}async function GJ(e,t,n){const r=window.showSaveFilePicker,a=()=>{if(n.signal?.aborted)throw dw()};if(r){const f=await r.call(window,{suggestedName:J_(t)});a();const h=await f.createWritable();try{await eE(e,t,v=>h.write(v),n),a(),await h.close()}catch(v){throw await h.abort().catch(()=>{}),v}return"saved"}const l=[];await eE(e,t,f=>{l.push(new Uint8Array(f))},{...n,maxBytes:256*1024*1024}),a();const c=URL.createObjectURL(new Blob(l,{type:"application/octet-stream"})),d=document.createElement("a");d.href=c,d.download=J_(t),document.body.appendChild(d);try{d.click()}finally{d.remove(),setTimeout(()=>URL.revokeObjectURL(c),6e4)}return"downloaded"}function vz(e){const{link:t}=Dt(),n=m.useRef(null),[r,a]=m.useState(!1),[l,c]=m.useState(),[d,f]=m.useState(""),[h,v]=m.useState("");m.useEffect(()=>(a(!1),c(void 0),f(""),v(""),()=>{n.current?.abort(),n.current=null}),[t,e]);async function g(){if(n.current)return;const y=new AbortController;n.current=y,a(!0),c(void 0),v(""),f("");try{const j=await GJ(t,e,{signal:y.signal,onProgress:c});y.signal.aborted||f(j==="saved"?"已保存到本地":"已交给浏览器下载")}catch(j){if(n.current!==y)return;y.signal.aborted||j instanceof Error&&j.name==="AbortError"?f("已取消下载"):v(Ps(j))}finally{n.current===y&&(n.current=null,a(!1))}}const x=r&&l?`${Oi(l.received)} / ${Oi(l.total)}`:r?"正在下载…":d;return{save:g,cancel:()=>n.current?.abort(),busy:r,status:x,error:h}}function ZJ({path:e}){const t=vz(e);return s.jsxs("div",{children:[s.jsxs("div",{className:"resource-reader-tools",children:[s.jsxs(F,{variant:"outline",size:"sm",disabled:t.busy,onClick:()=>void t.save(),children:[t.busy?s.jsx(vt,{className:"animate-spin","data-icon":"inline-start"}):s.jsx(S1,{"data-icon":"inline-start"}),t.busy?"正在下载…":"下载文件"]}),t.busy&&s.jsxs(F,{variant:"ghost",size:"sm",onClick:t.cancel,children:[s.jsx(zn,{"data-icon":"inline-start"}),"取消"]}),s.jsx("span",{className:"resource-caption",role:"status",children:t.busy?t.status.replace("正在下载…",""):t.status})]}),s.jsx(it,{error:t.error})]})}function KJ(e,t){if(t?.kind==="image")return"image";if(t?.kind==="text"&&/\.(md|markdown|mdx)$/i.test(e))return"markdown"}function YJ({path:e,line:t,close:n,onDirtyChange:r,content:a}){const{loaded:l,file:c,more:d,job:f}=a,h=vz(e),[v,g]=m.useState(!1),[x,y]=m.useState(!1),[j,k]=m.useState(),C=KJ(e,c),[_,N]=m.useState(!!t);m.useEffect(()=>{t&&N(!0)},[t,e]);const S=C==="markdown"?_:C!=="image";m.useEffect(()=>{if(!j)return;const L=setTimeout(()=>k(void 0),2e3);return()=>clearTimeout(L)},[j]);const T=(L,B)=>void f.run(async()=>{await navigator.clipboard.writeText(L),k(B)});if(v)return s.jsx(gz,{path:e,onDirtyChange:r,close:()=>{g(!1),l.reload()}},e);const z=c?`${Oi(c.size)} · ${c.kind==="text"?"文本":c.kind==="image"?"图片":"二进制"}${t?` · 第 ${t} 行`:""}`:"正在读取";return s.jsxs("section",{className:"file-preview","aria-label":bs(e),"aria-busy":l.loading,children:[s.jsxs("header",{className:"file-preview-bar",children:[n&&s.jsx(F,{variant:"ghost",size:"icon",className:"file-preview-back",onClick:n,title:"返回文件列表","aria-label":"返回文件列表",children:s.jsx(Po,{})}),s.jsxs(ts,{children:[s.jsx(ns,{asChild:!0,children:s.jsx("span",{className:"file-preview-name",tabIndex:0,children:bs(e)})}),s.jsxs(ss,{className:"max-w-sm break-all",children:[e," · ",z]})]}),s.jsx("span",{className:"file-preview-spacer"}),C==="markdown"&&s.jsx(Ti,{value:S?"source":"reading",onValueChange:L=>N(L==="source"),children:s.jsxs(Mi,{variant:"line","aria-label":"文件显示方式",children:[s.jsx(Pn,{value:"reading",children:"预览"}),s.jsx(Pn,{value:"source",children:"源码"})]})}),c?.kind==="text"&&S&&s.jsx(F,{variant:"ghost",size:"icon","aria-pressed":x,title:x?"不换行":"自动换行","aria-label":"自动换行",onClick:()=>y(!x),children:s.jsx(r6,{})}),c?.kind==="text"&&s.jsx(F,{variant:"ghost",size:"icon",title:j==="content"?"已复制":c.truncated?"复制已加载内容":"复制内容","aria-label":"复制内容",disabled:f.busy,onClick:()=>T(c.text??"","content"),children:j==="content"?s.jsx(Hn,{}):s.jsx(El,{})}),s.jsxs(As,{children:[s.jsx(Ts,{asChild:!0,children:s.jsx(F,{variant:"ghost",size:"icon","aria-label":"更多文件操作",title:"更多",children:h.busy?s.jsx(vt,{className:"animate-spin"}):s.jsx(bf,{})})}),s.jsxs(Ms,{align:"end",children:[c?.kind==="text"&&!c.truncated&&s.jsxs(mt,{onSelect:()=>g(!0),children:[s.jsx(OU,{}),"AI 编辑"]}),h.busy?s.jsxs(mt,{onSelect:h.cancel,children:[s.jsx(zn,{}),"取消下载 · ",h.status]}):s.jsxs(mt,{onSelect:()=>void h.save(),children:[s.jsx(S1,{}),"下载到这台电脑"]}),s.jsxs(mt,{onSelect:()=>T(e,"path"),children:[s.jsx(El,{}),j==="path"?"路径已复制":"复制路径"]}),s.jsx(sr,{}),s.jsxs(mt,{disabled:l.loading||f.busy,onSelect:l.reload,children:[s.jsx(ws,{}),"重新读取"]})]})]})]}),!h.busy&&h.status&&s.jsx("p",{className:"file-preview-note",role:"status",children:h.status}),s.jsx(it,{error:f.error||h.error||void 0}),s.jsx(js,{...l}),l.error&&s.jsx(F,{variant:"outline",size:"sm",className:"self-start",onClick:l.reload,children:"重新读取"}),c&&s.jsxs("div",{className:"file-preview-body",children:[c.kind==="image"?s.jsx("div",{className:"file-preview-image",children:s.jsx("img",{src:`data:${c.mimeType};base64,${c.data}`,alt:bs(e)})}):c.kind==="text"?c.text?C==="markdown"&&!S?s.jsx("div",{className:"file-preview-markdown",children:s.jsx(ja,{text:c.text})}):s.jsx(WJ,{text:c.text,path:e,line:t,wrap:x}):s.jsx(an,{title:"这是一个空文件",description:"文件中还没有文本内容。"}):s.jsx(an,{title:"此文件暂不支持预览",description:"可以下载到这台电脑,再用支持此格式的应用打开。"}),c.nextOffset!==void 0&&s.jsxs("div",{className:"file-preview-more",children:[s.jsxs("span",{children:["已加载 ",Oi(c.nextOffset)," / ",Oi(c.size)]}),s.jsxs(F,{variant:"ghost",size:"sm",disabled:f.busy,onClick:d,children:[f.busy&&s.jsx(vt,{className:"animate-spin","data-icon":"inline-start"}),f.busy?"正在读取…":"加载更多"]})]})]}),s.jsx("span",{className:"sr-only",role:"status",children:j?"已复制到剪贴板":""})]})}function WJ({text:e,path:t,line:n,wrap:r}){const a=m.useMemo(()=>e.replace(/\n$/,"").split(`
|
|
773
773
|
`),[e]),l=Sm(a.join(`
|
|
774
|
-
`),Q5(t)),c=m.useRef(null);return m.useEffect(()=>{const d=c.current,f=d?.closest(".file-preview-body");!d||!f||(f.scrollTop+=d.getBoundingClientRect().top-f.getBoundingClientRect().top-(f.clientHeight-d.offsetHeight)/2)},[n,t]),s.jsx("div",{className:je("file-preview-source",r&&"file-preview-source-wrap"),tabIndex:0,role:"region","aria-label":"文件源码",style:{"--gutter-digits":String(a.length).length},children:a.map((d,f)=>s.jsxs("div",{className:"file-preview-line","data-target":f+1===n||void 0,ref:f+1===n?c:void 0,children:[s.jsx("span",{className:"file-preview-number","aria-hidden":!0,children:f+1}),s.jsx("code",{children:s.jsx(XJ,{text:d,tokens:l?.[f]})})]},f))})}function XJ({text:e,tokens:t}){return e?!t||t.map(n=>n.content).join("")!==e?e:t.map((n,r)=>n.color?s.jsx("span",{style:{color:n.color},children:n.content},r):n.content):" "}async function bw(e){if(e.size>3e7)throw new Error(`${e.name} 超过 30 MB`);return new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>n(new Error("文件读取失败")),r.onload=()=>t(String(r.result).split(",")[1]??""),r.readAsDataURL(e)})}function xz(e,t){const{link:n}=Dt(),r=$t(),a=Rn(()=>qJ(v=>n.call("fs.read",{path:e,offset:v}),t),[n,e,t]),[l,c]=m.useState(),d=l&&l.source===a.value?l.file:a.value,f=m.useMemo(()=>t&&d?.text?FJ(d.text,t):void 0,[d?.text,t]);return{loaded:a,file:d,highlighted:f,more:()=>void r.run(async()=>{if(!d||d.nextOffset===void 0)return;const v=await n.call("fs.read",{path:e,offset:d.nextOffset});c({source:a.value,file:mz(d,v)})}),job:r}}function bz(e){return me?s.jsx(QJ,{...e}):s.jsx(JJ,{...e})}function QJ(e){const t=xz(e.path,e.line);return s.jsx(YJ,{...e,content:t})}function JJ({path:e,line:t,close:n,onDirtyChange:r}){const a=m.useRef(null),{loaded:l,file:c,highlighted:d,more:f,job:h}=xz(e,t),[v,g]=m.useState(!1),[x,y]=m.useState(!1),j=/\.(md|markdown)$/i.test(e),[k,C]=m.useState(j&&!t),[_,N]=m.useState();m.useEffect(()=>{a.current?.scrollIntoView({block:"center"})},[e,t,l.value]),m.useEffect(()=>{if(!_)return;const T=setTimeout(()=>N(void 0),2e3);return()=>clearTimeout(T)},[_]);function S(T,z){h.run(async()=>{await navigator.clipboard.writeText(T),N(z)})}return v?s.jsx(gz,{path:e,onDirtyChange:r,close:()=>{g(!1),l.reload()}},e):s.jsxs("section",{className:"file-reader resource-reader","aria-label":bs(e),"aria-busy":l.loading,children:[s.jsxs("header",{className:"resource-reader-heading",children:[s.jsxs("div",{className:"resource-file-title",children:[n&&s.jsx(F,{variant:"ghost",size:"icon-sm",onClick:n,title:"返回文件列表","aria-label":"返回文件列表",children:s.jsx(Po,{})}),s.jsx(Gd,{"aria-hidden":"true"}),s.jsxs("div",{children:[s.jsx("strong",{title:e,children:bs(e)}),s.jsxs("span",{children:[c?`${Oi(c.size)} · ${c.kind==="text"?"文本文件":c.kind==="image"?"图片":"二进制文件"}`:"读取文件",t?` · 第 ${t} 行`:""]})]})]}),s.jsxs("div",{className:"resource-inline-actions",children:[s.jsx(F,{variant:"ghost",size:"icon-sm",title:_==="path"?"路径已复制":"复制文件路径","aria-label":_==="path"?"路径已复制":"复制文件路径",onClick:()=>S(e,"path"),children:_==="path"?s.jsx(Hn,{}):s.jsx(El,{})}),s.jsx(F,{variant:"ghost",size:"icon-sm",disabled:l.loading||h.busy,title:"重新读取文件","aria-label":"重新读取文件",onClick:l.reload,children:s.jsx(ws,{})})]})]}),s.jsx("p",{className:"resource-path",title:e,children:e}),s.jsx(js,{...l}),s.jsx(ZJ,{path:e},e),l.error&&s.jsx(F,{variant:"outline",size:"sm",onClick:l.reload,children:"重新读取"}),s.jsx(it,{error:h.error}),c&&s.jsxs(s.Fragment,{children:[c.kind==="text"&&s.jsxs("div",{className:"resource-reader-tools",children:[j&&s.jsx(Ti,{value:k?"reading":"source",onValueChange:T=>C(T==="reading"),children:s.jsxs(Mi,{variant:"line","aria-label":"文件显示方式",children:[s.jsx(Pn,{value:"reading",children:"阅读"}),s.jsx(Pn,{value:"source",children:"源码"})]})}),s.jsxs(F,{variant:x?"secondary":"ghost",size:"sm","aria-pressed":x,disabled:k,onClick:()=>y(!x),children:[s.jsx(r6,{"data-icon":"inline-start"}),"自动换行"]}),s.jsxs(F,{variant:"ghost",size:"sm",disabled:h.busy,onClick:()=>S(c.text??"","content"),children:[_==="content"?s.jsx(Hn,{"data-icon":"inline-start"}):s.jsx(El,{"data-icon":"inline-start"}),_==="content"?"已复制":c.truncated?"复制已加载内容":"复制内容"]}),!c.truncated&&s.jsx(F,{variant:"outline",size:"sm",onClick:()=>g(!0),children:"AI 编辑"})]}),c.kind==="image"?s.jsx("div",{className:"resource-image-stage",children:s.jsx("img",{className:"file-image",src:`data:${c.mimeType};base64,${c.data}`,alt:bs(e)})}):c.kind==="text"?s.jsxs(s.Fragment,{children:[c.text&&k?s.jsx("div",{className:"resource-markdown",children:s.jsx(ja,{text:c.text})}):c.text?s.jsx("pre",{className:je("source-code resource-source",x&&"resource-source-wrap"),tabIndex:0,"aria-label":"文件内容",children:s.jsx("code",{children:d?s.jsxs(s.Fragment,{children:[d.before,s.jsx("span",{ref:a,className:"file-highlight-line",children:d.target||""}),d.after]}):c.text})}):s.jsx(an,{title:"这是一个空文件",description:"文件中还没有文本内容。"}),t&&!d&&!c.truncated&&s.jsxs("p",{className:"resource-caption",role:"status",children:["文件不足 ",t," 行,已显示全部内容。"]}),c.nextOffset!==void 0&&s.jsxs("div",{className:"resource-pagination",children:[s.jsxs("span",{className:"resource-caption",children:["已加载 ",Oi(c.nextOffset)," /"," ",Oi(c.size)]}),s.jsxs(F,{variant:"outline",size:"sm",disabled:h.busy,onClick:f,children:[h.busy&&s.jsx(vt,{className:"animate-spin","data-icon":"inline-start"}),h.busy?"正在读取…":"加载更多内容"]})]})]}):s.jsx(an,{title:"此文件暂不支持预览",description:"可以下载到本地,再用支持此格式的应用打开。"}),s.jsx("p",{className:"resource-caption resource-reader-footer",children:c.modifiedAt?`修改于 ${new Date(c.modifiedAt).toLocaleString("zh-CN",{dateStyle:"medium",timeStyle:"short"})}`:"内容来自已连接的电脑"})]}),s.jsx("span",{className:"sr-only",role:"status",children:_?"已复制到剪贴板":""})]})}function Ef({start:e,onPick:t,onDirtyChange:n,directoriesOnly:r=!1,page:a=!1}){const l=ar(),c=m.useRef(null),d=m.useRef(null),[f,h]=m.useState(!1),{link:v}=Dt(),[g,x]=m.useState(e),[y,j]=m.useState(!1),[k,C]=m.useState(),[_,N]=m.useState(),[S,T]=m.useState(!1),[z,L]=m.useState(()=>dn("desktopFilesListFolded",!1)),[B,O]=m.useState(()=>dn("desktopFilesListWidth",300)),$=(ye,$e)=>ft=>{$e(ft);try{sn(ye,ft)}catch{}},D=$("desktopFilesListFolded",L),Y=$("desktopFilesListWidth",O);m.useEffect(()=>(n?.(S),()=>n?.(!1)),[S,n]);const P=m.useRef(null),M=m.useRef(null),R=m.useRef(!1),[H,I]=m.useState(""),[q,G]=m.useState(""),[X,K]=m.useState(""),[ee,Z]=m.useState(),ne=$t(),ie=Rn(()=>v.call("fs.list",{path:g,hidden:y,files:!r}),[v,g,y,r]),de=Rn(()=>q?v.call("fs.search",{query:q}):Promise.resolve(void 0),[v,q]),oe=q?de:ie,ae=oe.value?.entries??[],Q=ie.value?.path??g??"主目录";m.useEffect(()=>{if(ie.loading||!ie.value||!R.current)return;R.current=!1,(M.current?.querySelector("button:not(:disabled)")??M.current)?.focus()},[ie.loading,ie.value]);async function pe(){return!S||await l.confirm("文件还有未保存的修改。放弃修改并离开编辑器?")}async function Me(ye){await pe()&&(R.current=!0,T(!1),C(void 0),x(ye),I(""),G(""),K(""),ne.clear())}async function ze(ye,$e){await pe()&&(T(!1),C(ye),N($e),ye||requestAnimationFrame(()=>P.current?.focus()))}const Le=!ne.busy&&!!ie.value&&!ie.loading&&!q;function He(ye){const $e=Array.from(ye??[]),ft=ie.value?.path;!ft||!$e.length||(K(""),ne.run(async()=>{for(const Se of $e)if(Se.size>3e7)throw new Error(`${Se.name} 超过 30 MB,尚未上传任何文件。`);let lt=0;try{for(const Se of $e)Z({done:lt,total:$e.length,name:Se.name}),await v.call("fs.upload",{dir:ft,name:Se.name,data:await bw(Se)},18e4),lt++;K(`已上传 ${lt} 个文件。同名文件已自动编号,原文件不会被覆盖。`)}catch(Se){throw new Error(`${lt?`已上传 ${lt} / ${$e.length} 个文件。`:""}${Ps(Se)}`,{cause:Se})}finally{Z(void 0),lt&&ie.reload()}}))}async function Te(){const ye=ie.value?.path,$e=await l.prompt("新目录名称");!ye||!$e?.trim()||ne.run(async()=>{const ft=$e.trim();if(ft==="."||ft===".."||/[/\\\0]/.test(ft)||ft.length>255)throw new Error("请输入有效的目录名称,不要包含斜杠,最多 255 个字符。");await v.call("fs.mkdir",{parent:ye,name:ft}),K(`已创建目录“${ft}”`),ie.reload()})}async function st(){const ye=await l.prompt("输入要打开的目录路径",ie.value?.path??g??"","打开目录");ye?.trim()&&Me(ye.trim())}function wt(){H.trim()&&(G(H.trim()),q===H.trim()&&de.reload())}const xt=()=>{I(""),G("")},Zt=q?`“${q}”的目录结果`:`${ae.length}${ie.value?.truncated?"+":""} 个${r?"目录":"项目"}`,rt=me&&!r,se=s.jsxs(s.Fragment,{children:[s.jsx(F,{variant:"ghost",size:"icon",disabled:ne.busy||ie.loading,title:"主目录","aria-label":"前往主目录",onClick:()=>void Me(),children:s.jsx(yb,{})}),s.jsx(F,{variant:"ghost",size:"icon",disabled:ne.busy||!ie.value?.parent,title:"上一级目录","aria-label":"前往上一级目录",onClick:()=>void Me(ie.value?.parent),children:s.jsx(em,{})})]}),Ae=s.jsx(F,{variant:"ghost",size:"icon",disabled:oe.loading||ne.busy,title:"刷新目录","aria-label":"刷新目录",onClick:oe.reload,children:s.jsx(ws,{})}),et=s.jsx("form",{className:"resource-search",onSubmit:ye=>{ye.preventDefault(),wt()},children:s.jsxs(zi,{className:"page-search",children:[s.jsx(Is,{children:s.jsx(Lr,{"aria-hidden":"true"})}),s.jsx(yo,{"aria-label":"搜索电脑上的目录",placeholder:"搜索目录",maxLength:200,autoFocus:!a,value:H,onChange:ye=>{I(ye.target.value),ye.target.value||G("")},onKeyDown:ye=>{ye.key==="Escape"&&(xt(),a||h(!1))}}),H&&s.jsx(Is,{align:"inline-end",children:s.jsx(bo,{size:"icon-xs",title:"清空搜索","aria-label":"清空搜索",onClick:xt,children:s.jsx(zn,{})})})]})}),jt=s.jsx("input",{ref:c,type:"file",multiple:!0,hidden:!0,tabIndex:-1,onChange:ye=>{const $e=ye.target.files;He($e),ye.target.value=""}}),ht=()=>{c.current&&(c.current.value="",c.current.click())},mn=s.jsxs(Yd,{className:"resource-hidden-toggle",children:[s.jsx(Ol,{checked:y,onCheckedChange:ye=>j(ye===!0)}),"显示隐藏项目"]});return s.jsxs("section",{ref:d,className:je("file-browser resource-files",k&&"resource-has-preview"),"data-layout":rt?a?"page":"panel":void 0,"data-list-folded":rt&&a&&!!k&&z||void 0,style:rt&&a?{"--files-list-width":`${B}px`}:void 0,"aria-label":r?"选择目录":"文件浏览器",children:[rt&&jt,rt&&a&&s.jsx(lr,{leading:s.jsxs("span",{className:"resource-toolbar-nav",children:[s.jsx(F,{variant:"ghost",size:"icon",className:"files-list-toggle","data-unused":!k||void 0,"aria-hidden":!k||void 0,tabIndex:k?void 0:-1,disabled:!k,"aria-pressed":!z,title:z?"显示文件列表":"隐藏文件列表","aria-label":z?"显示文件列表":"隐藏文件列表",onClick:()=>D(!z),children:s.jsx($U,{})}),se]}),title:s.jsx("span",{title:Q,children:bs(Q)||"根目录"}),detail:s.jsx("span",{className:"resource-toolbar-path",title:Q,children:Q}),actions:s.jsxs(s.Fragment,{children:[et,s.jsx(F,{variant:"ghost",size:"icon",title:"前往目录","aria-label":"前往目录",disabled:ne.busy,onClick:()=>void st(),children:s.jsx(vo,{})}),Ae,s.jsxs(F,{variant:"ghost",size:"sm",disabled:!Le,onClick:()=>void Te(),children:[s.jsx(e0,{"data-icon":"inline-start"}),"新建目录"]}),s.jsxs(F,{size:"sm",disabled:!Le,title:"单个文件最大 30 MB",onClick:ht,children:[s.jsx(Kd,{"data-icon":"inline-start"}),"上传文件"]})]})}),rt&&!a&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"resource-toolbar",children:[se,s.jsx("span",{className:"resource-toolbar-name",title:Q,children:bs(Q)||"根目录"}),s.jsx(F,{variant:"ghost",size:"icon",title:"搜索目录","aria-label":"搜索目录","aria-pressed":f,onClick:()=>{f&&xt(),h(!f)},children:s.jsx(Lr,{})}),Ae,s.jsxs(As,{children:[s.jsx(Ts,{asChild:!0,children:s.jsx(F,{variant:"ghost",size:"icon",title:"更多","aria-label":"更多文件操作",children:s.jsx(bf,{})})}),s.jsxs(Ms,{align:"end",children:[s.jsxs(mt,{disabled:!Le,onSelect:ht,children:[s.jsx(Kd,{}),"上传文件"]}),s.jsxs(mt,{disabled:!Le,onSelect:()=>void Te(),children:[s.jsx(e0,{}),"新建目录"]}),s.jsxs(mt,{disabled:ne.busy,onSelect:()=>void st(),children:[s.jsx(vo,{}),"前往目录…"]}),s.jsx(sr,{}),s.jsx(YQ,{checked:y,onCheckedChange:ye=>j(ye===!0),children:"显示隐藏项目"})]})]})]}),f&&et]}),!rt&&s.jsxs("div",{className:"resource-browser-controls",children:[s.jsxs("div",{className:"resource-location-bar",children:[s.jsx(F,{variant:"outline",size:"icon",disabled:ne.busy||ie.loading,title:"主目录","aria-label":"前往主目录",onClick:()=>void Me(),children:s.jsx(yb,{})}),s.jsx(F,{variant:"outline",size:"icon",disabled:ne.busy||!ie.value?.parent,title:"上一级目录","aria-label":"前往上一级目录",onClick:()=>void Me(ie.value?.parent),children:s.jsx(em,{})}),s.jsxs("div",{className:"resource-location",children:[s.jsx("strong",{children:bs(Q)||"根目录"}),s.jsx("span",{title:Q,children:Q})]}),s.jsx(F,{variant:"ghost",size:"icon",title:"前往目录","aria-label":"前往目录",disabled:ne.busy,onClick:()=>void st(),children:s.jsx(vo,{})}),Ae]}),s.jsx("form",{onSubmit:ye=>{ye.preventDefault(),wt()},children:s.jsx(Yn,{children:s.jsxs(Et,{children:[s.jsx(Rt,{className:"sr-only",children:"搜索电脑上的目录"}),s.jsxs(zi,{children:[s.jsx(Is,{children:s.jsx(Lr,{"aria-hidden":"true"})}),s.jsx(yo,{"aria-label":"搜索电脑上的目录",placeholder:"搜索电脑上的目录…",maxLength:200,value:H,onChange:ye=>{I(ye.target.value),ye.target.value||G("")},onKeyDown:ye=>{ye.key==="Escape"&&xt()}}),s.jsxs(Is,{align:"inline-end",children:[H&&s.jsx(bo,{size:"icon-xs",title:"清空搜索","aria-label":"清空搜索",onClick:xt,children:s.jsx(zn,{})}),s.jsx(bo,{type:"submit",variant:"secondary",disabled:!H.trim()||de.loading&&!!q,children:"搜索"})]})]})]})})}),s.jsxs("div",{className:"resource-directory-summary",children:[s.jsx("span",{children:Zt}),q?s.jsx(F,{variant:"link",size:"sm",onClick:xt,children:"返回当前目录"}):mn]})]}),r?s.jsxs("div",{className:"resource-picker-footer",children:[s.jsxs("p",{className:"resource-path",title:Q,children:["将使用:",Q]}),s.jsx(F,{disabled:!ie.value||ie.loading||!!q,onClick:()=>{ie.value&&t?.(ie.value.path)},children:"选择此目录"})]}):rt?null:s.jsxs("div",{className:"resource-files-footer",children:[s.jsxs("div",{className:"resource-inline-actions",children:[s.jsx(vw,{multiple:!0,disabled:!Le,onChange:ye=>{const $e=ye.target.files;He($e),ye.target.value=""},children:"上传文件"}),s.jsxs(F,{variant:"outline",disabled:!Le,onClick:()=>void Te(),children:[s.jsx(e0,{"data-icon":"inline-start"}),"新建目录"]})]}),s.jsx("span",{className:"resource-caption",children:"单个文件最大 30 MB"})]}),s.jsx(it,{error:ne.error}),X&&s.jsxs(cn,{role:"status",children:[s.jsx(Hn,{}),s.jsx(rn,{children:X})]}),ee&&s.jsxs(cn,{role:"status",children:[s.jsx(vt,{className:"animate-spin"}),s.jsxs(rn,{children:["正在上传 ",ee.done+1," / ",ee.total,":",ee.name]})]}),s.jsxs("div",{className:"resource-file-layout",children:[s.jsxs("div",{className:"resource-directory",ref:M,tabIndex:-1,"aria-busy":oe.loading,children:[s.jsx(js,{...oe}),oe.error&&s.jsxs(F,{variant:"outline",size:"sm",onClick:oe.reload,children:["重新",q?"搜索":"加载"]}),!oe.loading&&!oe.error&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"resource-entry-list","aria-label":q?"目录搜索结果":"目录内容",onKeyDown:ye=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(ye.key)||ye.altKey||ye.metaKey||ye.ctrlKey)return;const $e=[...ye.currentTarget.querySelectorAll("button:not(:disabled)")],ft=$e.indexOf(document.activeElement);if(ft<0)return;ye.preventDefault();const lt=ye.key==="Home"?0:ye.key==="End"?$e.length-1:Math.max(0,Math.min($e.length-1,ft+(ye.key==="ArrowDown"?1:-1)));$e[lt]?.focus()},children:ae.map(ye=>s.jsxs(F,{variant:k===ye.path?"secondary":"ghost",className:"resource-entry h-10 gap-2.5 rounded-none px-2","aria-current":k===ye.path?"true":void 0,title:ye.path,disabled:ne.busy,onClick:$e=>{ye.file&&(P.current=$e.currentTarget),ye.file?ze(ye.path):Me(ye.path)},children:[ye.file?s.jsx(Gd,{"data-icon":"inline-start"}):s.jsx(q3,{"data-icon":"inline-start"}),s.jsxs("span",{className:"resource-entry-main",children:[s.jsx("span",{className:"resource-entry-name",children:ye.name}),q&&s.jsx("span",{className:"resource-entry-path",children:ye.path})]}),ye.project?s.jsx(ui,{variant:"secondary",children:"项目"}):ye.size!==void 0?s.jsx("span",{className:"resource-entry-size",children:Oi(ye.size)}):null,!ye.file&&s.jsx(li,{"data-icon":"inline-end"})]},ye.path))}),ae.length===0&&s.jsx(an,{title:q?"没有找到匹配的目录":r?"没有可选的子目录":"这个目录是空的",description:q?"试试更短的目录名,搜索范围为电脑的主目录。":r?"可以选择当前目录,或返回上一级继续浏览。":"上传文件或新建目录,开始整理这个位置。"}),rt&&ae.length>0&&s.jsxs("p",{className:"resource-list-foot",children:[s.jsx("span",{children:Zt}),q?s.jsx(F,{variant:"link",size:"sm",onClick:xt,children:"返回当前目录"}):a?mn:null]}),oe.value?.truncated&&s.jsxs("p",{className:"resource-caption resource-results-note",children:["结果较多,仅显示前 ",ae.length," ","项。请使用更具体的目录名搜索。"]})]})]}),rt&&a&&!(k&&z)&&s.jsx(xw,{className:"files-list-resizer",label:"调整文件列表宽度",width:B,clamp:ye=>Math.round(Math.min(Math.max(ye,200),Math.max(200,Math.min(560,(d.current?.clientWidth??window.innerWidth)*.5)))),side:"end",target:".file-browser",column:".resource-directory",variable:"--files-list-width",resize:Y,initial:300}),rt&&a&&!k&&s.jsxs("div",{className:"file-preview-empty",children:[s.jsx(Gd,{"aria-hidden":"true"}),s.jsx("span",{children:"选择一个文件查看内容"})]}),k&&s.jsx(Vo.Provider,{value:{cwd:k.slice(0,k.lastIndexOf("/"))||"/",open:(ye,$e)=>void ze(ye,$e)},children:s.jsx(bz,{path:k,line:_,close:()=>void ze(),onDirtyChange:T},`${k}:${_??""}`)})]})]})}const eee="https://mkbeusztkzffnzjdwmqk.supabase.co",tee="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1rYmV1c3p0a3pmZm56amR3bXFrIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjU5Nzc0NzgsImV4cCI6MjA4MTU1MzQ3OH0.2wlT6q6687Z5rpEYsdp01IQpNNl_XWv0IAfBgwPyDP0";let nee;function yz(){return{supabaseUrl:window.__LINKSHELL_CONFIG__?.account?.url??eee,anonKey:window.__LINKSHELL_CONFIG__?.account?.anonKey??tee}}function tu(){if(me)throw new Error("桌面端使用 LinkShell 的系统浏览器登录");const{supabaseUrl:e,anonKey:t}=yz();return nee??=f8(e,t,{global:{fetch:(n,r)=>{const a=r?.signal??(n instanceof Request?n.signal:void 0);return fetch(n,{...r,signal:AbortSignal.any([...a?[a]:[],AbortSignal.timeout(3e4)])})}},auth:{persistSession:!0,autoRefreshToken:!0,detectSessionInUrl:!1,flowType:"pkce",storageKey:"linkshell.web.account.v2"}})}function Pd(e,t){if(!e)throw new Error("登录已失效,请重新登录");if(e!==t)throw new Error("账号已切换,请在当前账户下重新操作")}async function wz(e){if(me){const l=await Gp();return e!==void 0&&Pd(l.userId,e),l.accessToken}const t=tu().auth,{data:n,error:r}=await t.getSession();if(r)throw r;if(e!==void 0&&Pd(n.session?.user.id,e),!n.session)return;if((n.session.expires_at??0)*1e3>Date.now()+12e4)return n.session.access_token;const a=await t.refreshSession();if(a.error)throw a.error;if(!a.data.session)throw new Error("登录已失效,请重新登录");return e!==void 0&&Pd(a.data.session.user.id,e),a.data.session.access_token}async function yw(e){if(me){const r=await Gp();if(Pd(r.userId,e),!r.accessToken)throw new Error("登录已失效,请重新登录");return{access_token:r.accessToken}}const{data:t,error:n}=await tu().auth.getSession();if(n)throw n;if(!t.session)throw new Error("登录已失效,请重新登录");return Pd(t.session.user.id,e),t.session}async function jz(e){const t=await wz(e),n=await yw(e);if(!t||n.access_token!==t)throw new Error("账号状态已更新,请重试");return t}async function see(e){const t=await jz(e),n=await wQ({...yz(),accessToken:t,userId:e});return await yw(e),n}async function ree(e,t){const n=await jz(e),r=await kQ(n,t);return await yw(e),r}const iee=e=>{const t=new RTCPeerConnection({iceServers:e.map(r=>({urls:r}))}),n=t.createDataChannel(yW,{ordered:!0});return n.binaryType="arraybuffer",{async offer(){if(await t.setLocalDescription(await t.createOffer()),t.iceGatheringState!=="complete"&&await new Promise(r=>{const a=()=>{clearTimeout(c),t.removeEventListener("icegatheringstatechange",l),r()},l=()=>{t.iceGatheringState==="complete"&&a()},c=setTimeout(a,2e3);t.addEventListener("icegatheringstatechange",l)}),!t.localDescription?.sdp)throw new Error("无法建立直连通道");return t.localDescription.sdp},accept:r=>t.setRemoteDescription({type:"answer",sdp:r}),send(r){n.send(r)},onState(r){n.addEventListener("open",()=>r("open")),n.addEventListener("close",()=>r("closed")),t.addEventListener("connectionstatechange",()=>{["failed","closed"].includes(t.connectionState)&&r("closed")})},onMessage(r){n.addEventListener("message",a=>{a.data instanceof ArrayBuffer&&r(new Uint8Array(a.data))})},close(){t.close()}}};class aee{constructor(t){this.open=t}entries=new Map;acquire(t,n){let r=this.entries.get(t.key);r||(r={...this.open(t),users:0,streamUsers:0},this.entries.set(t.key,r));const a=r;a.users++;const l=!n?.metadataOnly;if(l&&a.streamUsers++===0)try{a.connection.streams.start()}catch(d){throw a.streamUsers--,--a.users===0?this.remove(t.key):a.connection.streams.stop(),d}let c=!1;return{connection:a.connection,release:()=>{c||this.entries.get(t.key)!==a||(c=!0,l&&a.streamUsers--,--a.users===0?this.remove(t.key):l&&a.streamUsers===0&&a.connection.streams.stop())}}}values(){return[...this.entries.values()].map(({connection:t})=>t)}remove(t){const n=this.entries.get(t);this.entries.delete(t),n?.close()}clear(){for(const t of this.entries.keys())this.remove(t)}}const Cm=40,qc=e=>`@shared:${e}`;function mE(e){return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([t,n])=>typeof n=="string"&&n.trim().length>0&&n.length<=(t.startsWith("@shared:")?120:Cm)))}function Mn(e,t){return(e.machine.namingConfigured?e.machine.name:t[qc(e.key)])||t[e.key]||e.machine.name||"电脑"}function Nf(e){return`${{darwin:"macOS",linux:"Linux",win32:"Windows"}[e.machine.platform??""]||e.machine.platform||"电脑"} · ${e.machine.id.slice(0,8)}`}function kz(e,t){return`${Mn(e,t)} · ${e.machine.id.slice(0,8)} · ${e.machine.online?"在线":"离线"}`}function oee(){const e=Cf(()=>mE(dn("computer-names",{}))),t=new Map,n=()=>{const a=mE(dn("computer-names",{})),l={...a};for(const[c,d]of t){if(a[qc(c)]!==d.saved){t.delete(c);continue}l[qc(c)]=d.name,delete l[c]}return{saved:a,next:l}},r=(a,l)=>{const{saved:c,next:d}=n();if(d[qc(a.key)]===l&&!d[a.key]&&!t.size){e.setState(d,!0);return}delete d[a.key],d[qc(a.key)]=l,t.set(a.key,{name:l,saved:c[qc(a.key)]});try{sn("computer-names",d),t.clear()}catch{}e.setState(d,!0)};return{store:e,refresh(){e.setState(n().next,!0)},remember(a){a.machine.namingConfigured&&r(a,a.machine.name)},sync(a,l){l.naming?.configured&&r(a,l.hostname)},async rename(a,l,c){const d=l.trim();if(d.length>Cm)throw new Error(`名称不能超过 ${Cm} 个字符`);const f=await c.call("machine.rename",{name:d});return r(a,f.hostname),f}}}const Vn=oee();if(typeof window<"u"){const e=t=>{(t.key===null||t.key==="linkshell.web.computer-names")&&Vn.refresh()};window.addEventListener("storage",e)}function _m(e,t,n){const r=e.find(l=>l.key===t);if(r)return r;const a=n??e.find(l=>l.key==="desktop:local");if(!(!a?.relayId||t!==a.key&&!t.endsWith(`#${a.relayId}`)))return e.find(l=>l.key===a.key||l.machine.id===a.relayId)}function lee(e){const t=e.find(r=>r.key==="desktop:local");if(!t?.relayId)return e;const n=t.machine.online?t:e.find(r=>r!==t&&r.machine.id===t.relayId&&r.machine.online)??t;return e.filter(r=>r===n||r!==t&&r.machine.id!==t.relayId)}const cee=dn("source",pa),Sz=pa==="self-hosted"?"self-hosted":cee,uee=Sz==="official"?Ks:dn("gateway",BQ),gE="网关未确认当前账号,请退出账号后重新登录。";function dee(e){switch(e.code){case"disconnected":case"connect_failed":return"与网关的连接断开了,正在自动重连…";case"replaced":return"这台设备已在别处连上网关";default:return e.message}}class fee{state=Cf(()=>({source:Sz,gateway:uee,computers:[],relayStatus:{},locked:!1,ready:!1}));identity;relays=new Map;relayErrors=new Map;paired=dn("paired",[]);localAliases=new Map;selected=dn("selected","");releaseLock;starting;authUser;accountRevision=0;authSubscribed=!1;generation=0;desktopPoll;accountAuthTimer;desktopRefresh;desktopLocalRequest;desktopLocalAbort;desktopLocalRetry;desktopLocalAttempt;connections=new aee(t=>this.openComputer(t));releaseSelected;channel=typeof BroadcastChannel<"u"?new BroadcastChannel("linkshell.web.owner"):void 0;constructor(){me&&(window.addEventListener(p8,t=>this.report(t.detail)),window.addEventListener(m8,t=>this.applyAccount(t.detail)),window.addEventListener(K0,t=>{t.detail?.visible&&this.reconnect()})),this.channel?.addEventListener("message",t=>{t.data==="yield"&&(this.stop(),this.state.setState({locked:!0}))}),window.addEventListener("pagehide",()=>this.stop()),window.addEventListener("pageshow",()=>{this.start()}),window.addEventListener("online",()=>this.reconnect()),document.addEventListener("visibilitychange",()=>{document.hidden||this.reconnect()})}report(t){this.state.setState({error:t instanceof Error?t.message:String(t)})}async start(){return this.releaseLock||this.starting?this.starting:(this.starting=this.acquire(!1).finally(()=>{this.starting=void 0}),this.starting)}async claim(){this.channel?.postMessage("yield"),await this.acquire(!0)}async acquire(t){if(me){this.releaseLock=()=>{},this.state.setState({locked:!1}),await this.boot().catch(n=>this.report(n));return}if(!navigator.locks){this.report(new Error("此浏览器不支持设备连接锁,请使用最新版 Chrome、Edge、Safari 或 Firefox"));return}await new Promise((n,r)=>{navigator.locks.request("linkshell.web.connection",{ifAvailable:!t},async a=>{if(!a){this.state.setState({locked:!0,ready:!0}),n();return}await new Promise(l=>{this.releaseLock=l,this.state.setState({locked:!1}),this.boot().then(n,r)})}).catch(r)}).catch(n=>this.report(n))}async boot(){const t=++this.generation;if(this.identity=await UJ(),t===this.generation){if(this.localAliases.clear(),this.state.setState({localComputer:void 0,computers:this.paired.map(n=>({...n,machine:{...n.machine,online:!1}})),ready:!0}),me){const n=g8();n?this.setLocalComputer(n):this.desktopLocalAttempt=0,this.desktopPoll=setInterval(()=>{this.refreshDesktop()},3e4),this.refreshDesktop()}for(const n of this.paired)this.relay(n.gateway);this.state.getState().source==="official"?await this.connectAccount():this.state.getState().gateway&&this.relay(Bp(this.state.getState().gateway))}}async connectAccount(){if(pa==="self-hosted")throw new Error("私有部署使用设备配对");if(me){const l=await Gp();this.applyAccount(l),this.state.setState({source:"official",gateway:Ks}),sn("source","official");return}const t=tu().auth,n=this.accountRevision,{data:r,error:a}=await t.getSession();if(n===this.accountRevision){if(a)throw a;this.applyAccount({userId:r.session?.user.id,email:r.session?.user.email})}this.state.setState({source:"official",gateway:Ks}),this.authSubscribed||(this.authSubscribed=!0,t.onAuthStateChange((l,c)=>{this.applyAccount({userId:c?.user.id,email:c?.user.email})})),sn("source","official")}applyAccount(t){const n=this.authUser!==t.userId;if(this.authUser=t.userId,n){this.accountRevision++;const a=[...this.state.getState().computers,...this.connections.values().map(l=>l.computer)];for(const l of a)l.gateway!==Ks||l.machine.via!=="account"||(this.state.getState().connection?.computer.key===l.key&&this.disconnect(),this.connections.remove(l.key));for(const[l,c]of this.localAliases)c.gateway===Ks&&c.machine.via==="account"&&this.localAliases.delete(l)}if(this.state.setState(a=>({account:t.email,accountUserId:t.userId,computers:n?this.mergeComputers(a.computers.filter(l=>l.gateway!==Ks||l.machine.via!=="account"),a.localComputer):a.computers})),!this.releaseLock||!n&&(this.accountAuthTimer||this.relays.has(Ks)))return;this.accountAuthTimer&&clearTimeout(this.accountAuthTimer);const r=this.generation;this.accountAuthTimer=setTimeout(()=>{this.accountAuthTimer=void 0,!(!this.releaseLock||r!==this.generation||t.userId!==this.authUser)&&(n&&this.relays.get(Ks)?.reauthenticate(),t.userId&&this.relay(Ks))},0)}setLocalComputer(t){t&&(this.desktopLocalRetry&&clearTimeout(this.desktopLocalRetry),this.desktopLocalRetry=void 0,this.desktopLocalAttempt=void 0),this.state.setState(n=>{const r=n.localComputer??n.computers.find(l=>l.key===Jn),a=t?{...t,relayId:t.relayId??(t.machine.id===r?.machine.id?r.relayId:void 0)}:r?{...r,machine:{...r.machine,online:!1}}:void 0;return{localComputer:a,computers:this.mergeComputers(n.computers.filter(l=>l.key!==Jn),a),localError:t?void 0:"本机服务未运行,请在本机服务中启动。"}}),t&&!this.state.getState().connection&&(!this.selected||this.computerForKey(this.selected)?.key===Jn)&&this.select(t)}mergeComputers(t,n){for(const[a,l]of this.localAliases)(!n?.relayId||l.machine.id!==n.relayId)&&this.localAliases.delete(a);for(const a of t)a.key!==Jn&&n?.relayId===a.machine.id&&this.localAliases.set(a.key,a);const r=new Map([...this.localAliases.values(),...t].map(a=>[a.key,a]));return r.delete(Jn),lee([...n?[n]:[],...r.values()])}refreshLocal(){if(!me||!this.releaseLock)return Promise.resolve();if(this.desktopLocalRequest)return this.desktopLocalRequest;const t=this.generation,n=new AbortController,r=setTimeout(()=>n.abort(),15e3);this.desktopLocalAbort=n;const a=v8("/desktop/local",{signal:n.signal}).then(({computer:l})=>{t===this.generation&&this.setLocalComputer(l)}).catch(l=>{t===this.generation&&(this.setLocalComputer(void 0),this.state.setState({localError:l instanceof Error?l.message:String(l)}))}).finally(()=>{clearTimeout(r),this.desktopLocalRequest===a&&(this.desktopLocalRequest=void 0,this.desktopLocalAbort=void 0),this.retryInitialLocalDiscovery(t)});return this.desktopLocalRequest=a,a}retryInitialLocalDiscovery(t){if(!this.releaseLock||t!==this.generation||this.desktopLocalRetry||this.desktopLocalAttempt===void 0)return;const n=[500,1e3,2e3,4e3,8e3][this.desktopLocalAttempt++];if(n===void 0){this.desktopLocalAttempt=void 0;return}this.desktopLocalRetry=setTimeout(()=>{this.desktopLocalRetry=void 0,this.releaseLock&&t===this.generation&&this.refreshLocal()},n)}refreshDesktop(){return this.desktopRefresh?this.desktopRefresh:(this.desktopRefresh=Promise.all([this.refreshLocal(),Gp().then(()=>{},t=>this.report(t))]).then(()=>{}).finally(()=>{this.desktopRefresh=void 0}),this.desktopRefresh)}relay(t){if(!this.identity||!this.releaseLock)throw new Error("请先在本标签页启用连接");const n=Bp(t),r=this.relays.get(n);if(r)return r;const a=n===Ks&&pa!=="self-hosted",l=new bW({url:n+dW,identity:this.identity,role:"device",name:me?"LinkShell Desktop":"LinkShell Web",platform:br?"Windows":me?"macOS":"web",token:a?async()=>{const c=this.accountRevision,d=this.authUser;try{const f=await wz(d);if(c!==this.accountRevision||d!==this.authUser)throw new Error("账号已更新,正在重新连接");return f}catch(f){throw c===this.accountRevision&&this.report(f),f}}:void 0,createSocket:c=>{const d=new WebSocket(c),f=d.send.bind(d);return d.send=h=>{if(typeof h=="string"&&a&&this.authUser){const v=JSON.parse(h);if(v.t==="auth"&&!v.token){d.close(4001,"账号续期失败,正在重试");return}}f(h)},d}});return this.relays.set(n,l),l.onStatus((c,d)=>{const f=d?dee(d):void 0,h=this.relayErrors.get(n);f?this.relayErrors.set(n,f):c==="online"&&this.relayErrors.delete(n),this.state.setState(v=>({relayStatus:{...v.relayStatus,[n]:c},...f?{error:f}:c==="online"&&h!==void 0&&v.error===h?{error:void 0}:{}})),c==="online"&&this.refresh(n).catch(v=>this.report(v))}),l.on("machines.changed",()=>{this.refresh(n).catch(c=>this.report(c))}),l.on("presence",({id:c,online:d})=>{const f=`${n}#${c}`,h=this.localAliases.get(f);if(h&&this.localAliases.set(f,{...h,machine:{...h.machine,online:d}}),d&&!h&&!this.state.getState().computers.some(v=>v.gateway===n&&v.machine.id===c)){this.refresh(n).catch(v=>this.report(v));return}this.state.setState(v=>({computers:this.mergeComputers(v.computers.map(g=>g.gateway===n&&g.machine.id===c?{...g,machine:{...g.machine,online:d}}:g),v.localComputer)}))}),l.start(),l}async refresh(t){const n=this.relays.get(t);if(!n)return;const r=this.generation,a=this.authUser,l=this.accountRevision,{machines:c}=await n.request("machines.list",{});if(r!==this.generation||n!==this.relays.get(t)||t===Ks&&(a!==this.authUser||l!==this.accountRevision))return;const d=t===Ks&&pa!=="self-hosted",f=d&&!!a&&n.account?.userId===a,h=c.filter(g=>g.via==="paired"||f).map(g=>({gateway:t,machine:g,key:`${t}#${g.id}`}));for(const[g,x]of this.localAliases)x.gateway===t&&this.localAliases.delete(g);for(const g of h)Vn.remember(g);this.state.setState(g=>({computers:this.mergeComputers([...g.computers.filter(x=>x.gateway!==t),...h],g.localComputer)}));const v=this.state.getState();if(!v.connection){const g=_m(v.computers,this.selected,v.localComputer)??v.computers.find(x=>x.machine.online);g&&this.select(g)}d&&a&&!f?this.state.setState({error:gE}):d&&this.state.getState().error===gE&&this.state.setState({error:void 0})}select(t){t=this.computerForKey(t.key)??t;const n=this.retainComputer(t);this.disconnect(),this.releaseSelected=n.release,this.state.setState({connection:n.connection,error:void 0}),this.selected=t.key,sn("selected",t.key)}computerForKey(t){const n=this.state.getState();return _m(n.computers,t,n.localComputer)}retainComputer(t,n){if(!this.identity||!this.releaseLock)throw new Error("请先在本标签页启用连接");return this.connections.acquire(this.computerForKey(t.key)??t,n)}openComputer(t){if(!this.identity)throw new Error("设备身份尚未就绪");const n=this.identity,r=me&&t.key===Jn&&t.gateway===Jn,a=r?void 0:this.relay(t.gateway),l=new oQ({url:t.key,createSocket:()=>r?x8():new pQ(a,n,t.machine),lazyImages:!0}),c=hQ(l,{lazyImages:!0}),d=new vQ(l,{connector:r?void 0:iee,iceServers:()=>c.getState().machine?.direct?.iceServers});d.stop();const f={computer:t,link:l,store:c,streams:d},h=c.subscribe((v,g)=>{if(v.machine!==g.machine){if(v.machine?.naming){Vn.sync(t,v.machine);const x={...f.computer,machine:{...f.computer.machine,name:v.machine.hostname,namingConfigured:v.machine.naming.configured}};f.computer=x,this.state.setState(y=>({computers:y.computers.map(j=>j.key===t.key?{...j,machine:{...j.machine,name:x.machine.name,namingConfigured:x.machine.namingConfigured}}:j),connection:y.connection?.computer.key===t.key?{...y.connection,computer:x}:y.connection,localComputer:y.localComputer?.key===t.key?{...y.localComputer,machine:{...y.localComputer.machine,name:x.machine.name,namingConfigured:x.machine.namingConfigured}}:y.localComputer}))}d.connect()}});return c.getState().connect(),{connection:f,close:()=>{h(),d.stop(),c.getState().disconnect()}}}async pair(t,n){const r=n.trim().startsWith("linkshell:")?xm(n.trim()):void 0;if(n.trim().startsWith("linkshell:")&&!r)throw new Error("配对链接格式不正确");if(!r&&!/^\d{6}$/.test(n.trim()))throw new Error("请输入 6 位配对码");const a=Bp((r?.gateway??t).replace(/^http/,"ws")),l=this.relay(a),c=r?await mQ(l,this.identity,r):await gQ(l,this.identity,n.trim()),d={key:`${a}#${c.id}`,gateway:a,machine:c};this.paired=[...this.paired.filter(f=>f.key!==d.key),d],sn("paired",this.paired),sn("source","self-hosted"),sn("gateway",a),this.state.setState({source:"self-hosted",gateway:a}),await this.refresh(a),this.select(d)}async forget(t){if(t.key===Jn)throw new Error("本机无需配对,请在本机服务中管理连接");await this.relay(t.gateway).request("machines.forget",{machineId:t.machine.id}),this.paired=this.paired.filter(n=>n.key!==t.key),sn("paired",this.paired),this.state.getState().connection?.computer.key===t.key&&this.disconnect(),this.connections.remove(t.key),this.localAliases.delete(t.key),this.state.setState(n=>({computers:this.mergeComputers(n.computers.filter(r=>r.key!==t.key),n.localComputer)}))}async refreshComputers(){if(!this.releaseLock)return;const t=[];me&&t.push(this.refreshDesktop());for(const[r,a]of this.relays)a.status==="online"?t.push(this.refresh(r)):a.reconnectNow();const n=(await Promise.allSettled(t)).find(r=>r.status==="rejected");if(n)throw n.reason}reconnect(){if(this.releaseLock){me&&(b8(),this.refreshDesktop());for(const t of this.relays.values())t.reconnectNow();for(const t of this.connections.values())t.link.reconnectNow()}}disconnect(){this.releaseSelected?.(),this.releaseSelected=void 0,this.state.setState({connection:void 0})}stop(){this.generation++,this.desktopLocalRetry&&clearTimeout(this.desktopLocalRetry),this.desktopLocalRetry=void 0,this.desktopLocalAttempt=void 0,this.desktopLocalAbort?.abort(),this.desktopLocalAbort=void 0,this.desktopLocalRequest=void 0,this.desktopPoll&&clearInterval(this.desktopPoll),this.desktopPoll=void 0,this.accountAuthTimer&&clearTimeout(this.accountAuthTimer),this.accountAuthTimer=void 0,this.disconnect(),this.connections.clear();for(const t of this.relays.values())t.stop();this.relays.clear(),this.releaseLock?.(),this.releaseLock=void 0}}const We=new fee,kd=e=>e.installed&&!e.problem&&e.auth?.state!=="missing"&&e.tier!=="terminal";function hee({initialDirectory:e,created:t,cancel:n}){const r=yt(Q=>Q.machine),a=yt(Q=>Q.projects),l=yt(Q=>Q.status==="online"),c=Gn(),{store:d}=Dt(),f=qe(We.state),h=qe(Vn.store),v=$t(),[g,x]=m.useState(()=>r?.agents.find(kd)?.id??""),[y,j]=m.useState(e??a[0]?.cwd??r?.home??""),[k,C]=m.useState(""),[_,N]=m.useState(!1),[S,T]=m.useState(!1),[z,L]=m.useState(),[B,O]=m.useState(),[$,D]=m.useState(0),Y=m.useRef(null);m.useEffect(()=>{!g&&r&&x(r.agents.find(kd)?.id??"")},[r,g]),m.useEffect(()=>{N(!1)},[y]);const P=Rn(()=>y.trim()?c.gitInfo(y):Promise.resolve(void 0),[d,y]),M=r?.agents.find(Q=>Q.id===g),R=!!M&&kd(M),H=z?.store===d&&z.agent===g?z.model:void 0,I=dz(g,y,l&&R,H,$),q=l&&R&&!!y.trim()&&!v.busy&&!!I&&!I.error,G=pz(I,H),X=I?.models.find(Q=>Q.value===(G??I.current)),K=JSON.stringify([g,y.trim()]),ee=B?.store===d&&B.key===K?B.values:{},Z=fz(I?.config,ee),ne=H&&I&&!I.error&&!I.models.some(Q=>Q.value===H),de=a.find(Q=>Q.cwd===y)?.name??(y.split(/[\\/]/).filter(Boolean).pop()||y||"选择目录"),oe=f.connection?.computer,ae=()=>{q&&v.run(async()=>t(await c.createSession({agent:g,cwd:y.trim(),worktree:_&&!!P.value,model:G,config:hz(I?.config,ee),prompt:k.trim()?[{type:"text",text:k.trim()}]:void 0})))};return s.jsxs("div",{className:"new-session-page",children:[s.jsx(_f,{agent:g}),s.jsxs("div",{className:"new-session-stage",children:[s.jsx("h1",{children:oe?`在 ${Mn(oe,h)} 上开始`:"新建会话"}),s.jsxs("form",{className:"new-session-composer",onSubmit:Q=>{Q.preventDefault(),ae()},children:[s.jsx("textarea",{ref:Y,autoFocus:!0,rows:3,value:k,disabled:v.busy,"aria-label":"任务描述",placeholder:"描述要完成的工作,或者直接开始…",onChange:Q=>C(Q.target.value),onKeyDown:Q=>{Q.key==="Escape"&&(Q.preventDefault(),n()),Q.key==="Enter"&&!Q.shiftKey&&!Q.nativeEvent.isComposing&&(Q.preventDefault(),ae())}}),s.jsxs("div",{className:"new-session-bar flex-wrap",children:[s.jsxs(As,{children:[s.jsx(Ts,{asChild:!0,children:s.jsxs(F,{type:"button",variant:"ghost",size:"sm",className:"new-session-pill",disabled:v.busy,"aria-label":"选择 Agent",children:[M&&s.jsx(Ao,{agent:M.id}),s.jsx("span",{children:M?.label??"选择 Agent"}),s.jsx(jr,{className:"new-session-caret"})]})}),s.jsxs(Ms,{side:"top",align:"start",sideOffset:8,collisionPadding:12,className:"new-session-menu",children:[s.jsx(Di,{children:"Agent"}),s.jsx(Il,{value:g,onValueChange:x,children:(r?.agents??[]).map(Q=>s.jsxs(Ri,{value:Q.id,disabled:!kd(Q),children:[s.jsx(Ao,{agent:Q.id}),s.jsxs("span",{className:"new-session-option",children:[s.jsx("span",{children:Q.label}),!kd(Q)&&s.jsx("small",{children:Q.installed?Q.auth?.state==="missing"?"未登录":Q.tier==="terminal"?"请从终端打开":Q.problem:"未安装"})]})]},Q.id))})]})]}),l&&R&&!I&&s.jsxs("span",{className:"new-session-pill new-session-pill-static",role:"status",children:[s.jsx(vt,{className:"animate-spin"}),s.jsx("span",{children:"正在读取模型与设置…"})]}),I&&!I.models.length&&!I.error&&s.jsxs(F,{type:"button",variant:"ghost",size:"sm",className:"new-session-pill",title:"Agent 尚未提供可预选的模型;点击重新读取",disabled:v.busy,onClick:()=>D(Q=>Q+1),children:[s.jsx(xb,{}),s.jsx("span",{children:"默认模型"})]}),!!I?.models.length&&s.jsxs(As,{children:[s.jsx(Ts,{asChild:!0,children:s.jsxs(F,{type:"button",variant:"ghost",size:"sm",className:"new-session-pill",disabled:v.busy,title:X?`模型:${X.name}`:"模型","aria-label":"选择模型",children:[s.jsx(xb,{}),s.jsx("span",{children:X?Qb(X):"默认模型"}),s.jsx(jr,{className:"new-session-caret"})]})}),s.jsxs(Ms,{side:"top",align:"start",sideOffset:8,collisionPadding:12,className:"new-session-menu",children:[s.jsx(Di,{children:"模型"}),s.jsx(Il,{value:X?.value??"",onValueChange:Q=>L({store:d,agent:g,model:Q}),children:I.models.map(Q=>{const pe=Qb(Q),Me=[Q.value===I.current&&!pe.startsWith("默认")?"默认":void 0,Q.description].filter(Boolean).join(" · ");return s.jsx(Ri,{value:Q.value,children:s.jsxs("span",{className:"new-session-option",children:[s.jsx("span",{children:pe}),Me&&s.jsx("small",{children:Me})]})},Q.value)})})]})]}),s.jsx(PJ,{options:Z,disabled:v.busy,onChange:(Q,pe)=>O({store:d,key:K,values:{...ee,[Q]:pe}})}),s.jsxs(As,{children:[s.jsx(Ts,{asChild:!0,children:s.jsxs(F,{type:"button",variant:"ghost",size:"sm",className:"new-session-pill",disabled:v.busy,title:y,"aria-label":"选择工作目录",children:[s.jsx(vo,{}),s.jsx("span",{children:de}),s.jsx(jr,{className:"new-session-caret"})]})}),s.jsxs(Ms,{side:"top",align:"start",sideOffset:8,collisionPadding:12,className:"new-session-menu",children:[s.jsx(Di,{children:"最近的项目"}),a.slice(0,8).map(Q=>s.jsxs(mt,{onSelect:()=>j(Q.cwd),children:[s.jsxs("span",{className:"new-session-option",children:[s.jsx("span",{children:Q.name}),s.jsx("small",{children:Q.cwd})]}),Q.cwd===y&&s.jsx(Hn,{className:"ml-auto"})]},Q.cwd)),!a.length&&s.jsx("p",{className:"new-session-menu-empty",children:"还没有项目"}),s.jsx(sr,{}),s.jsxs(mt,{disabled:!l,onSelect:()=>T(!0),children:[s.jsx(vo,{}),"浏览电脑上的目录…"]})]})]}),P.value&&s.jsxs(F,{type:"button",variant:"ghost",size:"sm",className:"new-session-pill","data-active":_||void 0,"aria-pressed":_,disabled:v.busy,title:"基于当前 Git 仓库创建独立工作目录",onClick:()=>N(Q=>!Q),children:[s.jsx(Nl,{}),s.jsx("span",{children:_?"独立 worktree":"当前分支"})]}),s.jsx("span",{className:"new-session-spacer"}),s.jsx(F,{type:"submit",size:"icon",className:"send-button",disabled:!q,"aria-label":"开始会话",title:"开始 · Enter(Shift Enter 换行)",children:v.busy?s.jsx(vt,{className:"animate-spin"}):s.jsx(em,{})})]})]}),s.jsx(it,{error:v.error}),ne&&s.jsx("p",{className:"new-session-note",role:"status",children:"此前选择的模型已不可用,将使用 Agent 的默认模型;也可以重新选择。"}),I?.error&&s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(it,{error:`模型与设置加载失败:${I.error}`}),s.jsx(F,{type:"button",variant:"outline",size:"sm",className:"self-start",disabled:v.busy,onClick:()=>D(Q=>Q+1),children:"重新读取模型与设置"})]}),!l&&s.jsx("p",{className:"new-session-note",role:"status",children:"电脑连接恢复后即可开始,已写的内容会保留。"}),l&&r&&!R&&s.jsx("p",{className:"new-session-note",children:"先在「电脑与 Agent」里确认 Agent 已安装并登录。"}),s.jsxs("p",{className:"new-session-hint",children:["Agent 在 ",s.jsx("code",{title:y,children:y||"所选目录"})," 里读写文件、运行命令 · Esc 取消"]})]}),S&&s.jsx(To,{title:"选择工作目录",wide:!0,close:()=>T(!1),children:s.jsx(Ef,{start:y,directoriesOnly:!0,onPick:Q=>{j(Q),T(!1),Y.current?.focus()}})})]})}const Cz="/assets/mark-RyKpi76M.png";function Em({computer:e,iconOnly:t=!1}){const n=qe(Vn.store),[r,a]=m.useState(!1),[l,c]=m.useState(""),[d,f]=m.useState(),[h,v]=m.useState(),[g,x]=m.useState(!1),[y,j]=m.useState(!1),k=m.useRef(void 0),C=m.useId();m.useEffect(()=>{if(!r)return;let N=!1,S;x(!0),j(!1),f(void 0),v(void 0);try{const T=We.retainComputer(e,{metadataOnly:!0});S=T.release,k.current=T.connection,T.connection.link.call("machine.info",{},15e3).then(z=>{N||(v(z),c(z.naming?.configured?z.naming.customName??"":n[e.key]??""),z.naming||f("请先更新这台电脑上的 LinkShell,更新后即可在所有端同步名称。"))}).catch(z=>{N||f(z instanceof Error?z.message:String(z))}).finally(()=>{N||x(!1)})}catch(T){x(!1),f(T instanceof Error?T.message:String(T))}return()=>{N=!0,k.current=void 0,S?.()}},[r,e.key]);async function _(N){const S=k.current;if(!(!S||!h?.naming||y)){j(!0),f(void 0);try{const T=await Vn.rename(e,N,S.link);S.store.setState({machine:T}),k.current===S&&a(!1)}catch(T){k.current===S&&f(T instanceof Error?T.message:String(T))}finally{k.current===S&&j(!1)}}}return s.jsxs(Bo,{open:r,onOpenChange:N=>{y||(a(N),N&&(c(n[e.key]??""),f(void 0)))},children:[s.jsx(cF,{asChild:!0,children:s.jsxs(F,{variant:"ghost",size:t?"icon-sm":"sm",className:t?"size-5 shrink-0":void 0,title:"给电脑命名","aria-label":`给 ${Mn(e,n)} 命名`,children:[s.jsx(XU,{"data-icon":"inline-start"}),!t&&"命名"]})}),s.jsxs(Uo,{children:[s.jsxs(Kl,{children:[s.jsx(Fo,{children:"给电脑命名"}),s.jsx(Yl,{children:"名称保存在这台电脑上,会同步到已连接的手机和电脑端。"})]}),s.jsx("form",{onSubmit:N=>{N.preventDefault(),_(l)},children:s.jsxs(Yn,{children:[s.jsxs(Et,{"data-invalid":!!d,children:[s.jsx(Rt,{htmlFor:C,children:"电脑名称"}),s.jsx(un,{id:C,value:l,disabled:g||y||!h?.naming,maxLength:Cm,placeholder:"例如:办公室 Mac mini",autoComplete:"off","aria-invalid":!!d,"aria-describedby":`${C}-hint${d?` ${C}-error`:""}`,onChange:N=>{c(N.target.value),f(void 0)}}),s.jsxs(as,{id:`${C}-hint`,className:"break-all",children:[g?"正在读取电脑名称…":h?`原名:${h.naming?.defaultName??h.hostname}`:"连接电脑后可读取原名"," · ",Nf(e),"。留空将恢复原名。"]}),d&&s.jsx(Pr,{id:`${C}-error`,children:d})]}),s.jsxs(c6,{children:[(h?.naming?.customName||n[e.key])&&s.jsx(F,{type:"button",variant:"ghost",disabled:g||y||!h?.naming,onClick:()=>void _(""),children:"恢复原名"}),s.jsx(M1,{asChild:!0,children:s.jsx(F,{type:"button",variant:"outline",disabled:y,children:"取消"})}),s.jsx(F,{type:"submit",disabled:g||y||!h?.naming,children:y?"正在同步…":"保存名称"})]})]})})]})]})}function Nm(e){return e instanceof Error?e.message:String(e)}function pee({name:e}){const t=yt(v=>v.unlock),[n,r]=m.useState(""),[a,l]=m.useState(),[c,d]=m.useState(!1),f=m.useId(),h=async()=>{if(!(!n||c)){d(!0),l(void 0);try{await t(n)}catch(v){l(Nm(v)),r("")}finally{d(!1)}}};return s.jsxs("div",{className:"access-unlock",role:"region","aria-labelledby":`${f}-title`,children:[s.jsx("span",{className:"access-unlock-mark","aria-hidden":!0,children:s.jsx(_u,{size:20})}),s.jsxs("h2",{id:`${f}-title`,children:[e," 设置了访问密码"]}),s.jsx("p",{children:"输入访问密码后继续。密码在那台电脑上设置。"}),s.jsxs("form",{className:"access-unlock-form",onSubmit:v=>{v.preventDefault(),h()},children:[s.jsxs(Et,{"data-invalid":a?!0:void 0,children:[s.jsx(Rt,{htmlFor:`${f}-password`,className:"sr-only",children:"访问密码"}),s.jsx(un,{id:`${f}-password`,type:"password",autoComplete:"current-password",autoFocus:!0,placeholder:"访问密码",value:n,"aria-invalid":a?!0:void 0,onChange:v=>r(v.target.value)}),a&&s.jsx(Pr,{children:a})]}),s.jsx(F,{type:"submit",disabled:!n||c,children:c?"正在解锁…":"解锁"})]})]})}function mee({open:e}){const{link:t}=Dt(),n=Rn(()=>t.call("access.status",{}),[t],0);if(n.error&&/unknown method|no handler/.test(Nm(n.error)))return null;const r=n.value?.password??!1;return s.jsxs("div",{className:"access-settings list-row list-row-static",children:[s.jsx("span",{className:"access-settings-mark","data-enabled":r||void 0,"aria-hidden":!0,children:r?s.jsx(_u,{size:16}):s.jsx(lT,{size:16})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"font-medium",children:"访问密码"}),s.jsx("p",{className:"text-xs text-[var(--tertiaryLabel)]",children:n.value?r?"已开启,其他设备打开这台电脑前要先输入密码":"未设置":"正在读取…"})]}),s.jsx(F,{variant:"secondary",size:"sm",onClick:e,children:r?"管理":"设置"})]})}function gee(){const{link:e}=Dt(),t=ar(),n=Rn(()=>e.call("access.status",{}),[e],0),[r,a]=m.useState(!1),[l,c]=m.useState(""),[d,f]=m.useState(""),[h,v]=m.useState(),[g,x]=m.useState(!1),y=m.useId(),j=n.value?.password??!1;if(n.error&&/unknown method|no handler/.test(Nm(n.error)))return null;const k=async _=>{x(!0),v(void 0);try{await e.call("access.set",_?{password:_}:{}),a(!1),c(""),f(""),n.reload()}catch(N){v(Nm(N))}finally{x(!1)}},C=d.length>0&&d!==l;return s.jsxs("div",{className:"access-settings list-row list-row-static",children:[s.jsx("span",{className:"access-settings-mark","data-enabled":j||void 0,"aria-hidden":!0,children:j?s.jsx(_u,{size:16}):s.jsx(lT,{size:16})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"font-medium",children:"访问密码"}),s.jsx("p",{className:"text-xs text-[var(--tertiaryLabel)]",children:j?"已开启。其他设备切换到这台电脑时,要先输入密码;这台电脑本身不受影响。":"未设置。同一账号或已配对的设备可以直接打开这台电脑。"}),r&&s.jsxs("form",{className:"access-settings-form",onSubmit:_=>{_.preventDefault(),l.length>=4&&!C&&k(l)},children:[s.jsxs(Et,{children:[s.jsx(Rt,{htmlFor:`${y}-new`,children:j?"新密码":"密码"}),s.jsx(un,{id:`${y}-new`,type:"password",autoComplete:"new-password",autoFocus:!0,minLength:4,maxLength:128,placeholder:"至少 4 位",value:l,onChange:_=>c(_.target.value)})]}),s.jsxs(Et,{"data-invalid":C||void 0,children:[s.jsx(Rt,{htmlFor:`${y}-confirm`,children:"再输一次"}),s.jsx(un,{id:`${y}-confirm`,type:"password",autoComplete:"new-password",maxLength:128,"aria-invalid":C||void 0,value:d,onChange:_=>f(_.target.value)}),C&&s.jsx(Pr,{children:"两次输入不一致"})]}),h&&s.jsx(Pr,{children:h}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(F,{type:"submit",size:"sm",disabled:g||l.length<4||d!==l,children:"保存"}),s.jsx(F,{type:"button",size:"sm",variant:"ghost",disabled:g,onClick:()=>{a(!1),v(void 0)},children:"取消"})]})]}),!r&&h&&s.jsx(Pr,{children:h})]}),!r&&s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx(F,{variant:"outline",size:"sm",disabled:g||n.loading,onClick:()=>a(!0),children:j?"修改":"设置密码"}),j&&s.jsx(F,{variant:"ghost",size:"sm",disabled:g,onClick:async()=>{await t.confirm("移除访问密码?其他设备将可以直接打开这台电脑。")&&k(void 0)},children:"移除"})]})]})}function vee({locked:e}){return e?s.jsx(_u,{className:"computer-lock-mark",size:12,"aria-label":"已设置访问密码"}):null}function xee({found:e,disabled:t=!1}){const n=m.useRef(null),[r,a]=m.useState(!1),[l,c]=m.useState(!1),[d,f]=m.useState(!1),[h,v]=m.useState(!1),[g,x]=m.useState(!1),[y,j]=m.useState(),k=m.useRef(e),C=m.useRef(t),_=m.useRef(0),N=m.useRef(!1);k.current=e,C.current=t,m.useEffect(()=>()=>{_.current++},[]),m.useEffect(()=>{let z=!0;if(!(!window.matchMedia("(pointer: coarse)").matches||!navigator.mediaDevices?.enumerateDevices))return navigator.mediaDevices.enumerateDevices().then(B=>{z&&c(B.some(O=>O.kind==="videoinput"))},()=>{}),()=>{z=!1}},[]);function S(z){if(!(N.current||C.current)){if(!xm(z)){j("这不是有效的 LinkShell 配对二维码,请扫描电脑上 linkshell pair 生成的二维码。");return}N.current=!0,k.current(z.trim()),a(!1),x(!0),j(void 0)}}const T=m.useRef(S);return T.current=S,m.useEffect(()=>{if(!r||t||!n.current)return;let z=!1,L;return Z0(()=>import("./qr-scanner.min-DszHMeGT.js"),__vite__mapDeps([4,1,2])).then(async({default:B})=>{z||!n.current||(L=new B(n.current,O=>{z||T.current(O.data)},{preferredCamera:"environment",returnDetailedScanResult:!0,highlightScanRegion:!0}),await L.start(),z||f(!1))}).catch(()=>{z||(j("无法打开摄像头。请检查浏览器的摄像头权限,或选择二维码图片、手动输入配对码。"),a(!1),f(!1))}),()=>{z=!0,L?.destroy()}},[r,t]),s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[s.jsxs("div",{className:"flex flex-wrap gap-2 [&>*]:flex-1",children:[l&&s.jsxs(F,{variant:"outline",type:"button",disabled:t||h,"aria-expanded":r&&!t,onClick:()=>{N.current=!1,x(!1),j(void 0),f(!r),a(!r)},children:[r?s.jsx(zn,{"data-icon":"inline-start"}):s.jsx(SU,{"data-icon":"inline-start"}),r?"关闭摄像头":"扫描二维码"]}),s.jsx(vw,{accept:"image/*",disabled:t||h,"aria-label":"选择包含 LinkShell 配对二维码的图片",onChange:z=>{const L=z.target.files?.[0];if(z.target.value="",!L)return;const B=++_.current;N.current=!1,a(!1),v(!0),x(!1),j(void 0),Z0(()=>import("./qr-scanner.min-DszHMeGT.js"),__vite__mapDeps([4,1,2])).then(O=>O.default.scanImage(L,{returnDetailedScanResult:!0})).then(O=>{B===_.current&&T.current(O.data)},()=>{B===_.current&&j("没有识别到二维码,请选择清晰的二维码图片,或手动输入配对码。")}).finally(()=>{B===_.current&&v(!1)})},children:h?"正在识别…":"从图片识别"})]}),r&&!t&&s.jsxs("div",{className:"min-w-0 text-center",children:[s.jsx("video",{ref:n,className:"mb-2 block aspect-[4/3] w-full rounded-lg bg-muted object-cover",muted:!0,playsInline:!0,"aria-label":"配对二维码扫描画面"}),s.jsx("p",{className:"text-xs text-muted-foreground",role:"status",children:d?"正在打开摄像头…":"将电脑上的配对二维码放入取景框"})]}),h&&s.jsxs("p",{className:"flex items-center gap-2 text-xs text-muted-foreground [&>svg]:size-4 [&>svg]:shrink-0",role:"status",children:[s.jsx(vt,{className:"animate-spin"}),"正在读取二维码图片…"]}),g&&s.jsxs("p",{className:"flex items-center gap-2 text-xs text-muted-foreground [&>svg]:size-4 [&>svg]:shrink-0",role:"status",children:[s.jsx(ig,{}),"已读取二维码,请确认后连接。"]}),s.jsx(it,{error:y})]})}function vE({userId:e,disabled:t}){const n=m.useId(),[r,a]=m.useState(""),[l,c]=m.useState(),d=Rn(()=>see(e),[e]),f=$t(),h=d.value?.plan==="pro"?d.value:l??d.value;return s.jsxs("section",{className:"flex min-w-0 flex-col gap-4","aria-label":"Pro 会员",children:[s.jsx(mC,{}),d.loading&&!l?s.jsx(js,{loading:!0}):d.error&&!h?s.jsxs(cn,{variant:"destructive",children:[s.jsx(Ws,{children:"暂时无法获取会员状态"}),s.jsxs(rn,{className:"flex flex-col items-start gap-2",children:[s.jsx("p",{children:d.error}),s.jsx(F,{type:"button",variant:"outline",onClick:d.reload,children:"重试"})]})]}):h?.plan==="pro"?s.jsxs(s.Fragment,{children:[s.jsxs(cn,{variant:"success",role:"status",children:[s.jsx(Ws,{children:l?"兑换成功,Pro 已激活":"Pro 会员"}),s.jsx(rn,{children:h.expiresAt?`有效期至 ${new Date(h.expiresAt).toLocaleString("zh-CN",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:"Pro 权益已生效"})]}),d.error&&s.jsxs(cn,{variant:"warning",children:[s.jsx(Ws,{children:"会员信息暂时未能刷新"}),s.jsxs(rn,{className:"flex flex-col items-start gap-2",children:[s.jsx("p",{children:"兑换结果已保存,可稍后重试刷新。"}),s.jsx(F,{type:"button",variant:"outline",onClick:d.reload,children:"刷新会员状态"})]})]})]}):h?s.jsx("form",{"aria-label":"兑换 Pro 激活码","aria-busy":f.busy,onSubmit:v=>{v.preventDefault(),!(t||f.busy||!r.trim())&&f.run(async()=>{const g=await ree(e,r.trim());c({plan:"pro",expiresAt:g.expiresAt}),a(""),d.reload()})},children:s.jsxs(Yn,{children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsx("span",{className:"text-sm font-medium",children:"升级 Pro"}),s.jsx(ui,{variant:"secondary",children:"普通账户"})]}),s.jsxs(Et,{"data-disabled":t||f.busy,"data-invalid":!!f.error,children:[s.jsx(Rt,{htmlFor:`${n}-code`,children:"激活码"}),s.jsx(un,{id:`${n}-code`,value:r,onChange:v=>{a(v.target.value),f.clear()},autoComplete:"off",autoCapitalize:"none",spellCheck:!1,placeholder:"输入 Pro 激活码",disabled:t||f.busy,"aria-invalid":!!f.error,"aria-describedby":f.error?`${n}-error`:`${n}-description`,required:!0}),s.jsx(as,{id:`${n}-description`,children:"兑换后,当前 iTool 账户即可使用 Pro 权益。"}),f.error&&s.jsx(Pr,{id:`${n}-error`,children:f.error})]}),s.jsxs(F,{type:"submit",disabled:t||f.busy||!r.trim(),children:[f.busy&&s.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}),f.busy?"正在兑换…":"兑换并升级 Pro"]}),s.jsxs(as,{children:["没有激活码?"," ",s.jsx("a",{href:D5,target:"_blank",rel:"noopener noreferrer",children:"前往链动小铺 ↗"})]})]})}):null,s.jsx(mC,{})]})}const bee="https://itool.tech/zh/register",yee="https://itool.tech/zh/forgot-password",wee=45e3,_z={github:"GitHub",google:"Google"};function jee(){return s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",fill:"currentColor",children:s.jsx("path",{d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61-.546-1.385-1.335-1.755-1.335-1.755-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23a11.5 11.5 0 0 1 3-.405c1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})})}function kee(){return s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",fill:"currentColor",children:s.jsx("path",{d:"M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z"})})}function xE({href:e,children:t}){const n=r=>{r.preventDefault(),Rm(e)};return s.jsx("a",{href:e,target:"_blank",rel:"noreferrer",onClick:n,children:t})}function See(e){return e.key==="Enter"&&(e.isComposing===!0||e.keyCode===229)}function bE(e){See({key:e.key,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&e.preventDefault()}function Cee(e,t){const n=e.trim();if(!n)return{field:"email",message:"请输入邮箱。"};if(!/^[^\s@]+@[^\s@]+$/.test(n))return{field:"email",message:"邮箱格式不正确。"};if(!t)return{field:"password",message:"请输入密码。"}}function Ez(e){const{pending:t,link:n,error:r,disabled:a,title:l,description:c,onPassword:d,onProvider:f,onBrowser:h,onCancel:v,onEdit:g}=e,x=m.useId(),[y,j]=m.useState(""),[k,C]=m.useState(""),[_,N]=m.useState(),S=m.useRef(null),T=m.useRef(null),z=t!==void 0&&t!=="password",L=a||t!==void 0,B=_?.message??r,O=()=>{if(L)return;const D=Cee(y,k);if(D?.field==="password"&&!k&&document.activeElement===S.current){N(void 0),T.current?.focus();return}if(N(D),D){(D.field==="email"?S:T).current?.focus();return}d(y.trim(),k)},$=()=>{N(void 0),g?.()};return z?s.jsx(_ee,{method:t,link:n,title:l,onCancel:v}):s.jsxs("div",{className:"signin",children:[(l||c)&&s.jsxs("header",{className:"signin-header",children:[l&&s.jsx("h2",{children:l}),c&&s.jsx("p",{children:c})]}),s.jsx("div",{className:"signin-providers",children:["github","google"].map(D=>s.jsxs("button",{type:"button",className:"signin-button","data-kind":"provider",disabled:L,onClick:()=>f(D),children:[D==="github"?s.jsx(jee,{}):s.jsx(kee,{}),"使用 ",_z[D]," 继续"]},D))}),s.jsx("div",{className:"signin-divider",role:"separator","aria-label":"或使用邮箱",children:s.jsx("span",{children:"或"})}),s.jsxs("form",{className:"signin-form",noValidate:!0,"aria-busy":t==="password",onSubmit:D=>{D.preventDefault(),O()},children:[s.jsxs("div",{className:"signin-field",children:[s.jsx("label",{className:"signin-field-label",htmlFor:`${x}-email`,children:"邮箱"}),s.jsx("input",{ref:S,autoFocus:!0,id:`${x}-email`,className:"signin-input",type:"email",name:"username",autoComplete:"username",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,inputMode:"email",placeholder:"你的 iTool 账号邮箱",value:y,disabled:L,"aria-invalid":_?.field==="email","aria-describedby":B?`${x}-error`:void 0,onKeyDown:bE,onChange:D=>{j(D.target.value),$()}})]}),s.jsxs("div",{className:"signin-field",children:[s.jsxs("div",{className:"signin-field-label",children:[s.jsx("label",{htmlFor:`${x}-password`,children:"密码"}),s.jsx(xE,{href:yee,children:"忘记密码?"})]}),s.jsx("input",{ref:T,id:`${x}-password`,className:"signin-input",type:"password",name:"password",autoComplete:"current-password",value:k,disabled:L,"aria-invalid":_?.field==="password","aria-describedby":B?`${x}-error`:void 0,onKeyDown:bE,onChange:D=>{C(D.target.value),$()}})]}),B&&s.jsx("p",{id:`${x}-error`,className:"signin-error",role:"alert",children:B}),s.jsxs("button",{type:"submit",className:"signin-button","data-kind":"primary",disabled:L,children:[t==="password"&&s.jsx(vt,{className:"signin-spinner","aria-hidden":!0}),t==="password"?"正在登录…":"登录"]})]}),s.jsxs("footer",{className:"signin-footer",children:[s.jsxs("p",{children:["没有账号?",s.jsx(xE,{href:bee,children:"注册 iTool 账号"})]}),s.jsxs("p",{children:["已在浏览器登录 iTool?",s.jsx("button",{type:"button",className:"signin-link",disabled:L,onClick:h,children:"在浏览器中授权"})]})]})]})}function _ee({method:e,link:t,title:n,onCancel:r}){const[a,l]=m.useState(!1),[c,d]=m.useState("idle");m.useEffect(()=>{const v=setTimeout(()=>l(!0),wee);return()=>clearTimeout(v)},[]),m.useEffect(()=>{if(c!=="copied")return;const v=setTimeout(()=>d("idle"),2e3);return()=>clearTimeout(v)},[c]);const f=e==="web"?void 0:_z[e],h=()=>{t&&navigator.clipboard.writeText(t).then(()=>d("copied"),()=>d("failed"))};return s.jsxs("div",{className:"signin","data-state":"waiting",children:[n&&s.jsx("header",{className:"signin-header",children:s.jsx("h2",{children:n})}),s.jsxs("div",{className:"signin-waiting",role:"status","aria-live":"polite",children:[s.jsx(vt,{className:"signin-spinner","data-size":"large","aria-hidden":!0}),s.jsx("h3",{children:f?`请在浏览器中完成 ${f} 登录`:"请在浏览器中完成授权"}),s.jsx("p",{children:f?"完成后会自动回到 LinkShell。":"在 iTool 页面确认后,会自动回到 LinkShell。"}),a&&s.jsx("p",{className:"signin-hint",children:"还没有收到浏览器的结果。如果浏览器停在了错误页,请取消后重试,或改用邮箱和密码登录。等待 5 分钟后会自动取消。"})]}),f&&s.jsxs("div",{className:"signin-actions",children:[s.jsx("button",{type:"button",className:"signin-button","data-kind":"provider",disabled:!t,onClick:()=>t&&Rm(t),children:"重新打开浏览器"}),s.jsx("button",{type:"button",className:"signin-button","data-kind":"provider",disabled:!t,onClick:h,children:c==="copied"?"已复制":"复制链接"})]}),c==="failed"&&t&&s.jsxs("p",{className:"signin-hint",children:["无法写入剪贴板,请手动复制:",s.jsx("span",{className:"signin-link-text",children:t})]}),s.jsx("button",{type:"button",className:"signin-button","data-kind":"quiet",onClick:r,children:"取消"})]})}const Eee=400;function Nee(e){return e instanceof DOMException&&e.name==="TimeoutError"?"等待登录超时,请重试。":e instanceof TypeError?"桌面服务暂时不可用,请重试。":Ps(e)}function Aee(e){const[t,n]=m.useState(),[r,a]=m.useState(),[l,c]=m.useState(),d=m.useRef(!1),f=m.useRef(!1),h=m.useRef(!0);m.useEffect(()=>(h.current=!0,()=>{h.current=!1,d.current&&(f.current=!0,yS().catch(()=>{}))}),[]);const v=async g=>{if(d.current)return;d.current=!0,f.current=!1,n(g.method),a(void 0),c(void 0);let x=g.method==="github"||g.method==="google";x&&(async()=>{for(;x;){if(await new Promise(j=>setTimeout(j,Eee)),!x)return;try{const j=await w8();if(x&&j?.method===g.method&&j.url){a(j.url);return}}catch{}}})();try{await y8(g),h.current&&await e()}catch(j){!f.current&&h.current&&c(Nee(j))}finally{x=!1,d.current=!1,h.current&&(n(void 0),a(void 0))}};return{pending:t,link:r,error:l,onPassword:(g,x)=>void v({method:"password",email:g,password:x}),onProvider:g=>void v({method:g}),onBrowser:()=>void v({method:"web"}),onCancel:()=>{f.current=!0,yS().catch(()=>{})},onEdit:()=>c(void 0)}}function Tee({close:e}){const t=qe(We.state),n=m.useId(),[r,a]=m.useState(t.source),[l,c]=m.useState(""),[d,f]=m.useState(""),[h,v]=m.useState(r==="self-hosted"?t.gateway:""),[g,x]=m.useState(""),[y,j]=m.useState({}),k=$t(),C=m.useRef(null),[_,N]=m.useState();m.useEffect(()=>()=>C.current?.abort(),[]);const S=k.busy||t.locked,T=Aee(async()=>{await We.connectAccount(),e()}),z=xm(g);function L($){x($);const D=xm($);D&&v(D.gateway.replace(/^http/,"ws")),j({}),k.clear()}const B=me?t.accountUserId?s.jsxs(Yn,{children:[s.jsxs(cn,{role:"status",children:[s.jsx(Ws,{children:t.account??"已登录"}),s.jsx(rn,{children:"已使用 LinkShell 的同一账号。其他电脑登录此账号后,会自动显示在工作台。"})]}),s.jsx(vE,{userId:t.accountUserId,disabled:k.busy},t.accountUserId),s.jsx(F,{disabled:S,onClick:()=>void k.run(async()=>{await We.connectAccount(),e()}),children:"刷新账号电脑"}),s.jsx(F,{variant:"outline",disabled:k.busy,onClick:()=>void k.run(j8),children:"退出 LinkShell 账号"}),s.jsx("p",{className:"field-hint",children:"账号与这台电脑的 LinkShell 服务共用。退出后,本机工作台和已配对的电脑仍可使用。"})]}):s.jsx(Ez,{...T,disabled:S,description:"登录 iTool 账号,即可访问同一账号下的电脑。电脑接入官方网关需要 Pro 订阅。"}):t.account?s.jsxs(Yn,{className:"min-w-0 [&_[data-slot=alert-description]]:break-words [&_[data-slot=alert-title]]:break-words [&_[data-slot=field]]:min-w-0",children:[s.jsxs(cn,{role:"status",children:[s.jsx(Ws,{className:"break-words",children:t.account}),s.jsxs(rn,{children:["在电脑运行 ",s.jsx("code",{children:"linkshell login"}),",使用同一账号即可发现电脑。电脑接入官方网关需要 Pro 订阅。"]})]}),t.accountUserId&&s.jsx(vE,{userId:t.accountUserId,disabled:k.busy},t.accountUserId),s.jsxs(F,{type:"button",disabled:S,onClick:()=>void k.run(async()=>{await We.connectAccount(),e()}),children:[k.busy&&s.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}),"刷新账号电脑"]}),s.jsx(F,{variant:"outline",type:"button",disabled:k.busy,onClick:()=>void k.run(async()=>{const $=await tu().auth.signOut({scope:"local"});if($.error)throw $.error;We.disconnect()}),children:"退出本浏览器账号"})]}):s.jsx("form",{className:"min-w-0 [&_[data-slot=alert-description]]:break-words [&_[data-slot=alert-title]]:break-words [&_[data-slot=field]]:min-w-0","aria-busy":k.busy,onSubmit:$=>{$.preventDefault(),!S&&k.run(async()=>{const D=await tu().auth.signInWithPassword({email:l.trim(),password:d});if(D.error)throw D.error;await We.connectAccount(),e()})},children:s.jsxs(Yn,{children:[s.jsxs(Et,{"data-disabled":S,children:[s.jsx(Rt,{htmlFor:`${n}-email`,children:"邮箱"}),s.jsx(un,{id:`${n}-email`,type:"email",autoComplete:"username",autoCapitalize:"none",spellCheck:!1,placeholder:"你的 iTool 账号邮箱",value:l,disabled:S,onChange:$=>{c($.target.value),k.clear()},required:!0})]}),s.jsxs(Et,{"data-disabled":S,children:[s.jsx(Rt,{htmlFor:`${n}-password`,children:"密码"}),s.jsx(un,{id:`${n}-password`,type:"password",autoComplete:"current-password",value:d,disabled:S,onChange:$=>{f($.target.value),k.clear()},required:!0})]}),s.jsxs(F,{disabled:S,children:[k.busy&&s.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}),k.busy?"正在连接…":"登录并连接"]}),s.jsx("div",{className:"grid grid-cols-1 gap-2 min-[381px]:grid-cols-2",children:["github","google"].map($=>s.jsx(F,{variant:"outline",type:"button",disabled:S,onClick:()=>void k.run(async()=>{const D=new AbortController;C.current=D,N("waiting");try{if(await k8(tu().auth,$,{signal:D.signal,onExchanging:()=>N("exchanging")}),D.signal.aborted||(await We.connectAccount(),D.signal.aborted))return;e()}finally{C.current=null,N(void 0)}}),children:$==="github"?"GitHub 登录":"Google 登录"},$))}),_&&s.jsxs("div",{className:"flex items-center justify-between gap-3",role:"status",children:[s.jsx("p",{className:"field-hint",children:_==="waiting"?"请在登录窗口中完成授权。":"正在完成登录…"}),s.jsx(F,{type:"button",variant:"ghost",size:"sm",disabled:_==="exchanging",onClick:()=>C.current?.abort(),children:"取消登录"})]}),s.jsxs("p",{className:"field-hint flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1",children:["登录状态会自动续期。",s.jsx("a",{href:"https://itool.tech/zh/register",target:"_blank",rel:"noreferrer",children:"注册 iTool 账号 ↗"})]})]})}),O=s.jsx("form",{className:"min-w-0 [&_[data-slot=alert-description]]:break-words [&_[data-slot=alert-title]]:break-words [&_[data-slot=field]]:min-w-0","aria-busy":k.busy,onSubmit:$=>{if($.preventDefault(),S)return;const D=g.trim();if(!z&&!/^\d{6}$/.test(D)){j({pairing:D.startsWith("linkshell:")?"配对链接不完整,请重新复制。":"请输入 6 位数字配对码,或完整的配对链接。"}),document.getElementById(`${n}-pairing`)?.focus();return}try{Bp((z?.gateway??h).replace(/^http/,"ws"))}catch(Y){j({gateway:Y instanceof Error?Y.message:"请检查网关地址"}),document.getElementById(`${n}-gateway`)?.focus();return}j({}),k.run(async()=>{await We.pair(h,D),e()})},children:s.jsxs(Yn,{children:[s.jsxs(cn,{role:"note",children:[s.jsx(Ws,{children:"先在电脑上生成配对码"}),s.jsxs(rn,{children:["运行 ",s.jsx("code",{children:"linkshell pair"}),",扫描二维码,或输入电脑上显示的配对码。配对码在 10 分钟内有效。"]})]}),s.jsx(xee,{found:L,disabled:S}),s.jsxs(Et,{"data-invalid":!!y.pairing,"data-disabled":S,children:[s.jsx(Rt,{htmlFor:`${n}-pairing`,children:"配对码或配对链接"}),s.jsx(un,{id:`${n}-pairing`,value:g,disabled:S,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,"aria-invalid":!!y.pairing,"aria-describedby":`${n}-pairing-hint${y.pairing?` ${n}-pairing-error`:""}`,onChange:$=>L($.target.value),placeholder:"6 位配对码,或 linkshell://pair 链接",required:!0}),s.jsx(as,{id:`${n}-pairing-hint`,children:z?"已读取配对链接,网关地址已自动填写。":me?"配对成功后,LinkShell 会记住你的电脑。":"配对成功后,此浏览器会记住你的电脑。"}),y.pairing&&s.jsx(Pr,{id:`${n}-pairing-error`,children:y.pairing})]}),s.jsxs(Et,{"data-invalid":!!y.gateway,"data-disabled":S||!!z,children:[s.jsx(Rt,{htmlFor:`${n}-gateway`,children:"网关地址"}),s.jsx(un,{id:`${n}-gateway`,type:"url",placeholder:"wss://gateway.example.com",value:h,autoComplete:"url",autoCapitalize:"none",spellCheck:!1,disabled:S,readOnly:!!z,"aria-invalid":!!y.gateway,"aria-describedby":`${n}-gateway-hint${y.gateway?` ${n}-gateway-error`:""}`,onChange:$=>{v($.target.value),j({}),k.clear()},required:!z}),s.jsx(as,{id:`${n}-gateway-hint`,children:z?"使用配对链接中指定的网关。更换网关时,请重新生成配对码。":"填写电脑当前连接的网关地址。"}),y.gateway&&s.jsx(Pr,{id:`${n}-gateway-error`,children:y.gateway})]}),s.jsxs(F,{disabled:S,children:[k.busy&&s.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}),k.busy?"正在配对…":"配对并连接"]}),s.jsxs("p",{className:"field-hint",children:[me?"配对保存在这台电脑的 LinkShell 中。":"清除网站数据后需要重新配对。","自托管连接不会使用 iTool 登录凭证。"]})]})});return s.jsxs(To,{title:"连接你的电脑",close:e,children:[s.jsx("p",{className:"muted modal-subtitle",children:me?"从这台电脑继续对话、审批和控制远程电脑。":"电脑保持运行,网页即可继续你的会话。"}),me&&s.jsxs(cn,{className:"mb-4",children:[s.jsx(Ws,{children:"本机工作台无需登录"}),s.jsxs(rn,{children:[s.jsx("p",{children:t.localError??"本机服务已连接,可以直接管理这台电脑的会话。"}),s.jsxs("div",{className:"mt-2 flex gap-2",children:[s.jsx(F,{type:"button",variant:"outline",size:"sm",onClick:Sy,children:"本机服务"}),t.localError&&s.jsx(F,{type:"button",variant:"ghost",size:"sm",disabled:k.busy,onClick:()=>void k.run(()=>We.refreshLocal()),children:"重新检测"})]})]})]}),t.locked&&s.jsxs(cn,{children:[s.jsx(Ws,{children:"连接正在另一个标签页中使用"}),s.jsxs(rn,{children:[s.jsx("p",{children:"切换到此页后,另一个标签页会断开连接。"}),s.jsx(F,{type:"button",variant:"outline",size:"sm",disabled:k.busy,onClick:()=>void k.run(()=>We.claim()),children:"在此页继续"})]})]}),pa==="official"?s.jsxs(Ti,{value:r,onValueChange:$=>{a($),k.clear(),j({})},children:[s.jsxs(Mi,{className:"w-full","aria-label":"连接方式",children:[s.jsxs(Pn,{value:"official",disabled:k.busy,children:[s.jsx(tn,{name:"globe"}),"官方账号"]}),s.jsxs(Pn,{value:"self-hosted",disabled:k.busy,children:[s.jsx(tn,{name:"server"}),"配对电脑"]})]}),s.jsx(Yb,{value:"official",className:"pt-4",children:B}),s.jsx(Yb,{value:"self-hosted",className:"pt-4",children:O})]}):O,s.jsx(it,{error:k.error})]})}function Nz({...e}){return s.jsx($y,{"data-slot":"sheet",...e})}function Mee({...e}){return s.jsx(Ly,{"data-slot":"sheet-portal",...e})}function zee({className:e,...t}){return s.jsx(Py,{"data-slot":"sheet-overlay",className:je("fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0",e),...t})}function Az({className:e,children:t,side:n="right",showCloseButton:r=!0,...a}){return s.jsxs(Mee,{children:[s.jsx(zee,{}),s.jsxs(By,{"data-slot":"sheet-content","data-side":n,className:je("fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[side=bottom]:data-[state=open]:slide-in-from-bottom-10 data-[side=left]:data-[state=open]:slide-in-from-left-10 data-[side=right]:data-[state=open]:slide-in-from-right-10 data-[side=top]:data-[state=open]:slide-in-from-top-10 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[side=bottom]:data-[state=closed]:slide-out-to-bottom-10 data-[side=left]:data-[state=closed]:slide-out-to-left-10 data-[side=right]:data-[state=closed]:slide-out-to-right-10 data-[side=top]:data-[state=closed]:slide-out-to-top-10",e),...a,children:[t,r&&s.jsx(wu,{"data-slot":"sheet-close",asChild:!0,children:s.jsxs(F,{variant:"ghost",className:"absolute top-3 right-3",size:"icon-sm",children:[s.jsx(zn,{}),s.jsx("span",{className:"sr-only",children:"Close"})]})})]})]})}function Tz({className:e,...t}){return s.jsx("div",{"data-slot":"sheet-header",className:je("flex flex-col gap-0.5 p-4",e),...t})}function Mz({className:e,...t}){return s.jsx(Uy,{"data-slot":"sheet-title",className:je("text-base font-medium text-foreground",e),...t})}function Ree({className:e,...t}){return s.jsx(Fy,{"data-slot":"sheet-description",className:je("text-sm text-muted-foreground",e),...t})}const Dee=768;function zz(e=Dee){const[t,n]=m.useState(void 0);return m.useEffect(()=>{const r=window.matchMedia(`(max-width: ${e-1}px)`),a=()=>{n(window.innerWidth<e)};return r.addEventListener("change",a),n(window.innerWidth<e),()=>r.removeEventListener("change",a)},[e]),!!t}function Oee(e){if(!e)return;const t=e.parentElement;if(!t)return;t.style.setProperty("--composer-height",`${Math.round(e.offsetHeight)}px`);const n=new ResizeObserver(([r])=>{const a=r?.borderBoxSize?.[0]?.blockSize??e.offsetHeight;t.style.setProperty("--composer-height",`${Math.round(a)}px`)});return n.observe(e),()=>{n.disconnect(),t.style.removeProperty("--composer-height")}}function Af({...e}){return s.jsx(cP,{"data-slot":"popover",...e})}function Sg({...e}){return s.jsx(hP,{"data-slot":"popover-trigger",...e})}function Tf({className:e,align:t="center",sideOffset:n=4,container:r,...a}){return s.jsx(gP,{container:r,children:s.jsx(vP,{"data-slot":"popover-content",align:t,sideOffset:n,className:je("z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",e),...a})})}function Iee({...e}){return s.jsx(dP,{"data-slot":"popover-anchor",...e})}function $ee({className:e,...t}){return s.jsx("div",{"data-slot":"popover-header",className:je("flex flex-col gap-0.5 text-sm",e),...t})}function Lee({className:e,...t}){return s.jsx("div",{"data-slot":"popover-title",className:je("font-medium",e),...t})}function Pee({className:e,...t}){return s.jsx("p",{"data-slot":"popover-description",className:je("text-muted-foreground",e),...t})}var yE=1,Bee=.9,Uee=.8,Fee=.17,C0=.1,_0=.999,qee=.9999,Hee=.99,Vee=/[\\\/_+.#"@\[\(\{&]/,Gee=/[\\\/_+.#"@\[\(\{&]/g,Zee=/[\s-]/,Rz=/[\s-]/g;function ty(e,t,n,r,a,l,c){if(l===t.length)return a===e.length?yE:Hee;var d=`${a},${l}`;if(c[d]!==void 0)return c[d];for(var f=r.charAt(l),h=n.indexOf(f,a),v=0,g,x,y,j;h>=0;)g=ty(e,t,n,r,h+1,l+1,c),g>v&&(h===a?g*=yE:Vee.test(e.charAt(h-1))?(g*=Uee,y=e.slice(a,h-1).match(Gee),y&&a>0&&(g*=Math.pow(_0,y.length))):Zee.test(e.charAt(h-1))?(g*=Bee,j=e.slice(a,h-1).match(Rz),j&&a>0&&(g*=Math.pow(_0,j.length))):(g*=Fee,a>0&&(g*=Math.pow(_0,h-a))),e.charAt(h)!==t.charAt(l)&&(g*=qee)),(g<C0&&n.charAt(h-1)===r.charAt(l+1)||r.charAt(l+1)===r.charAt(l)&&n.charAt(h-1)!==r.charAt(l))&&(x=ty(e,t,n,r,h+1,l+2,c),x*C0>g&&(g=x*C0)),g>v&&(v=g),h=n.indexOf(f,h+1);return c[d]=v,v}function wE(e){return e.toLowerCase().replace(Rz," ")}function Kee(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,ty(e,t,wE(e),wE(t),0,0,{})}function wo(e,t,{checkForDefaultPrevented:n=!0}={}){return function(a){if(e?.(a),n===!1||!a.defaultPrevented)return t?.(a)}}function jE(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function $l(...e){return t=>{let n=!1;const r=e.map(a=>{const l=jE(a,t);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let a=0;a<r.length;a++){const l=r[a];typeof l=="function"?l():jE(e[a],null)}}}}function Wl(...e){return m.useCallback($l(...e),e)}function Yee(e,t){const n=m.createContext(t),r=l=>{const{children:c,...d}=l,f=m.useMemo(()=>d,Object.values(d));return s.jsx(n.Provider,{value:f,children:c})};r.displayName=e+"Provider";function a(l){const c=m.useContext(n);if(c)return c;if(t!==void 0)return t;throw new Error(`\`${l}\` must be used within \`${e}\``)}return[r,a]}function Wee(e,t=[]){let n=[];function r(l,c){const d=m.createContext(c),f=n.length;n=[...n,c];const h=g=>{const{scope:x,children:y,...j}=g,k=x?.[e]?.[f]||d,C=m.useMemo(()=>j,Object.values(j));return s.jsx(k.Provider,{value:C,children:y})};h.displayName=l+"Provider";function v(g,x){const y=x?.[e]?.[f]||d,j=m.useContext(y);if(j)return j;if(c!==void 0)return c;throw new Error(`\`${g}\` must be used within \`${l}\``)}return[h,v]}const a=()=>{const l=n.map(c=>m.createContext(c));return function(d){const f=d?.[e]||l;return m.useMemo(()=>({[`__scope${e}`]:{...d,[e]:f}}),[d,f])}};return a.scopeName=e,[r,Xee(a,...t)]}function Xee(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(l){const c=r.reduce((d,{useScope:f,scopeName:h})=>{const g=f(l)[`__scope${h}`];return{...d,...g}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}var af=globalThis?.document?m.useLayoutEffect:()=>{},Qee=Ro[" useId ".trim().toString()]||(()=>{}),Jee=0;function ga(e){const[t,n]=m.useState(Qee());return af(()=>{n(r=>r??String(Jee++))},[e]),t?`radix-${t}`:""}var ete=Ro[" useInsertionEffect ".trim().toString()]||af;function tte({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[a,l,c]=nte({defaultProp:t,onChange:n}),d=e!==void 0,f=d?e:a;{const v=m.useRef(e!==void 0);m.useEffect(()=>{const g=v.current;g!==d&&console.warn(`${r} is changing from ${g?"controlled":"uncontrolled"} to ${d?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),v.current=d},[d,r])}const h=m.useCallback(v=>{if(d){const g=ste(v)?v(e):v;g!==e&&c.current?.(g)}else l(v)},[d,e,l,c]);return[f,h]}function nte({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),a=m.useRef(n),l=m.useRef(t);return ete(()=>{l.current=t},[t]),m.useEffect(()=>{a.current!==n&&(l.current?.(n),a.current=n)},[n,a]),[n,r,l]}function ste(e){return typeof e=="function"}function Dz(e){const t=rte(e),n=m.forwardRef((r,a)=>{const{children:l,...c}=r,d=m.Children.toArray(l),f=d.find(ate);if(f){const h=f.props.children,v=d.map(g=>g===f?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return s.jsx(t,{...c,ref:a,children:m.isValidElement(h)?m.cloneElement(h,void 0,v):null})}return s.jsx(t,{...c,ref:a,children:l})});return n.displayName=`${e}.Slot`,n}function rte(e){const t=m.forwardRef((n,r)=>{const{children:a,...l}=n;if(m.isValidElement(a)){const c=lte(a),d=ote(l,a.props);return a.type!==m.Fragment&&(d.ref=r?$l(r,c):c),m.cloneElement(a,d)}return m.Children.count(a)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ite=Symbol("radix.slottable");function ate(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ite}function ote(e,t){const n={...t};for(const r in t){const a=e[r],l=t[r];/^on[A-Z]/.test(r)?a&&l?n[r]=(...d)=>{const f=l(...d);return a(...d),f}:a&&(n[r]=a):r==="style"?n[r]={...a,...l}:r==="className"&&(n[r]=[a,l].filter(Boolean).join(" "))}return{...e,...n}}function lte(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var cte=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ss=cte.reduce((e,t)=>{const n=Dz(`Primitive.${t}`),r=m.forwardRef((a,l)=>{const{asChild:c,...d}=a,f=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(f,{...d,ref:l})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function ute(e,t){e&&Oo.flushSync(()=>e.dispatchEvent(t))}function of(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>t.current?.(...n),[])}function dte(e,t=globalThis?.document){const n=of(e);m.useEffect(()=>{const r=a=>{a.key==="Escape"&&n(a)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var fte="DismissableLayer",ny="dismissableLayer.update",hte="dismissableLayer.pointerDownOutside",pte="dismissableLayer.focusOutside",kE,Oz=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Iz=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:l,onInteractOutside:c,onDismiss:d,...f}=e,h=m.useContext(Oz),[v,g]=m.useState(null),x=v?.ownerDocument??globalThis?.document,[,y]=m.useState({}),j=Wl(t,B=>g(B)),k=Array.from(h.layers),[C]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),_=k.indexOf(C),N=v?k.indexOf(v):-1,S=h.layersWithOutsidePointerEventsDisabled.size>0,T=N>=_,z=vte(B=>{const O=B.target,$=[...h.branches].some(D=>D.contains(O));!T||$||(a?.(B),c?.(B),B.defaultPrevented||d?.())},x),L=xte(B=>{const O=B.target;[...h.branches].some(D=>D.contains(O))||(l?.(B),c?.(B),B.defaultPrevented||d?.())},x);return dte(B=>{N===h.layers.size-1&&(r?.(B),!B.defaultPrevented&&d&&(B.preventDefault(),d()))},x),m.useEffect(()=>{if(v)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(kE=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(v)),h.layers.add(v),SE(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=kE)}},[v,x,n,h]),m.useEffect(()=>()=>{v&&(h.layers.delete(v),h.layersWithOutsidePointerEventsDisabled.delete(v),SE())},[v,h]),m.useEffect(()=>{const B=()=>y({});return document.addEventListener(ny,B),()=>document.removeEventListener(ny,B)},[]),s.jsx(Ss.div,{...f,ref:j,style:{pointerEvents:S?T?"auto":"none":void 0,...e.style},onFocusCapture:wo(e.onFocusCapture,L.onFocusCapture),onBlurCapture:wo(e.onBlurCapture,L.onBlurCapture),onPointerDownCapture:wo(e.onPointerDownCapture,z.onPointerDownCapture)})});Iz.displayName=fte;var mte="DismissableLayerBranch",gte=m.forwardRef((e,t)=>{const n=m.useContext(Oz),r=m.useRef(null),a=Wl(t,r);return m.useEffect(()=>{const l=r.current;if(l)return n.branches.add(l),()=>{n.branches.delete(l)}},[n.branches]),s.jsx(Ss.div,{...e,ref:a})});gte.displayName=mte;function vte(e,t=globalThis?.document){const n=of(e),r=m.useRef(!1),a=m.useRef(()=>{});return m.useEffect(()=>{const l=d=>{if(d.target&&!r.current){let f=function(){$z(hte,n,h,{discrete:!0})};const h={originalEvent:d};d.pointerType==="touch"?(t.removeEventListener("click",a.current),a.current=f,t.addEventListener("click",a.current,{once:!0})):f()}else t.removeEventListener("click",a.current);r.current=!1},c=window.setTimeout(()=>{t.addEventListener("pointerdown",l)},0);return()=>{window.clearTimeout(c),t.removeEventListener("pointerdown",l),t.removeEventListener("click",a.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function xte(e,t=globalThis?.document){const n=of(e),r=m.useRef(!1);return m.useEffect(()=>{const a=l=>{l.target&&!r.current&&$z(pte,n,{originalEvent:l},{discrete:!1})};return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function SE(){const e=new CustomEvent(ny);document.dispatchEvent(e)}function $z(e,t,n,{discrete:r}){const a=n.originalEvent.target,l=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&a.addEventListener(e,t,{once:!0}),r?ute(a,l):a.dispatchEvent(l)}var E0="focusScope.autoFocusOnMount",N0="focusScope.autoFocusOnUnmount",CE={bubbles:!1,cancelable:!0},bte="FocusScope",Lz=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:l,...c}=e,[d,f]=m.useState(null),h=of(a),v=of(l),g=m.useRef(null),x=Wl(t,k=>f(k)),y=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let k=function(S){if(y.paused||!d)return;const T=S.target;d.contains(T)?g.current=T:co(g.current,{select:!0})},C=function(S){if(y.paused||!d)return;const T=S.relatedTarget;T!==null&&(d.contains(T)||co(g.current,{select:!0}))},_=function(S){if(document.activeElement===document.body)for(const z of S)z.removedNodes.length>0&&co(d)};document.addEventListener("focusin",k),document.addEventListener("focusout",C);const N=new MutationObserver(_);return d&&N.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",k),document.removeEventListener("focusout",C),N.disconnect()}}},[r,d,y.paused]),m.useEffect(()=>{if(d){EE.add(y);const k=document.activeElement;if(!d.contains(k)){const _=new CustomEvent(E0,CE);d.addEventListener(E0,h),d.dispatchEvent(_),_.defaultPrevented||(yte(Cte(Pz(d)),{select:!0}),document.activeElement===k&&co(d))}return()=>{d.removeEventListener(E0,h),setTimeout(()=>{const _=new CustomEvent(N0,CE);d.addEventListener(N0,v),d.dispatchEvent(_),_.defaultPrevented||co(k??document.body,{select:!0}),d.removeEventListener(N0,v),EE.remove(y)},0)}}},[d,h,v,y]);const j=m.useCallback(k=>{if(!n&&!r||y.paused)return;const C=k.key==="Tab"&&!k.altKey&&!k.ctrlKey&&!k.metaKey,_=document.activeElement;if(C&&_){const N=k.currentTarget,[S,T]=wte(N);S&&T?!k.shiftKey&&_===T?(k.preventDefault(),n&&co(S,{select:!0})):k.shiftKey&&_===S&&(k.preventDefault(),n&&co(T,{select:!0})):_===N&&k.preventDefault()}},[n,r,y.paused]);return s.jsx(Ss.div,{tabIndex:-1,...c,ref:x,onKeyDown:j})});Lz.displayName=bte;function yte(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(co(r,{select:t}),document.activeElement!==n)return}function wte(e){const t=Pz(e),n=_E(t,e),r=_E(t.reverse(),e);return[n,r]}function Pz(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const a=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||a?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function _E(e,t){for(const n of e)if(!jte(n,{upTo:t}))return n}function jte(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function kte(e){return e instanceof HTMLInputElement&&"select"in e}function co(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&kte(e)&&t&&e.select()}}var EE=Ste();function Ste(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=NE(e,t),e.unshift(t)},remove(t){e=NE(e,t),e[0]?.resume()}}}function NE(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Cte(e){return e.filter(t=>t.tagName!=="A")}var _te="Portal",Bz=m.forwardRef((e,t)=>{const{container:n,...r}=e,[a,l]=m.useState(!1);af(()=>l(!0),[]);const c=n||a&&globalThis?.document?.body;return c?jI.createPortal(s.jsx(Ss.div,{...r,ref:t}),c):null});Bz.displayName=_te;function Ete(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Cg=e=>{const{present:t,children:n}=e,r=Nte(t),a=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),l=Wl(r.ref,Ate(a));return typeof n=="function"||r.isPresent?m.cloneElement(a,{ref:l}):null};Cg.displayName="Presence";function Nte(e){const[t,n]=m.useState(),r=m.useRef(null),a=m.useRef(e),l=m.useRef("none"),c=e?"mounted":"unmounted",[d,f]=Ete(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const h=bp(r.current);l.current=d==="mounted"?h:"none"},[d]),af(()=>{const h=r.current,v=a.current;if(v!==e){const x=l.current,y=bp(h);e?f("MOUNT"):y==="none"||h?.display==="none"?f("UNMOUNT"):f(v&&x!==y?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,f]),af(()=>{if(t){let h;const v=t.ownerDocument.defaultView??window,g=y=>{const k=bp(r.current).includes(CSS.escape(y.animationName));if(y.target===t&&k&&(f("ANIMATION_END"),!a.current)){const C=t.style.animationFillMode;t.style.animationFillMode="forwards",h=v.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=C)})}},x=y=>{y.target===t&&(l.current=bp(r.current))};return t.addEventListener("animationstart",x),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{v.clearTimeout(h),t.removeEventListener("animationstart",x),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else f("ANIMATION_END")},[t,f]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:m.useCallback(h=>{r.current=h?getComputedStyle(h):null,n(h)},[])}}function bp(e){return e?.animationName||"none"}function Ate(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var A0=0;function Tte(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??AE()),document.body.insertAdjacentElement("beforeend",e[1]??AE()),A0++,()=>{A0===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),A0--}},[])}function AE(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var _g="Dialog",[Uz]=Wee(_g),[Mte,hi]=Uz(_g),Fz=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:a,onOpenChange:l,modal:c=!0}=e,d=m.useRef(null),f=m.useRef(null),[h,v]=tte({prop:r,defaultProp:a??!1,onChange:l,caller:_g});return s.jsx(Mte,{scope:t,triggerRef:d,contentRef:f,contentId:ga(),titleId:ga(),descriptionId:ga(),open:h,onOpenChange:v,onOpenToggle:m.useCallback(()=>v(g=>!g),[v]),modal:c,children:n})};Fz.displayName=_g;var qz="DialogTrigger",zte=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(qz,n),l=Wl(t,a.triggerRef);return s.jsx(Ss.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":kw(a.open),...r,ref:l,onClick:wo(e.onClick,a.onOpenToggle)})});zte.displayName=qz;var ww="DialogPortal",[Rte,Hz]=Uz(ww,{forceMount:void 0}),Vz=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:a}=e,l=hi(ww,t);return s.jsx(Rte,{scope:t,forceMount:n,children:m.Children.map(r,c=>s.jsx(Cg,{present:n||l.open,children:s.jsx(Bz,{asChild:!0,container:a,children:c})}))})};Vz.displayName=ww;var Am="DialogOverlay",Gz=m.forwardRef((e,t)=>{const n=Hz(Am,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,l=hi(Am,e.__scopeDialog);return l.modal?s.jsx(Cg,{present:r||l.open,children:s.jsx(Ote,{...a,ref:t})}):null});Gz.displayName=Am;var Dte=Dz("DialogOverlay.RemoveScroll"),Ote=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(Am,n);return s.jsx(yu,{as:Dte,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(Ss.div,{"data-state":kw(a.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Ll="DialogContent",Zz=m.forwardRef((e,t)=>{const n=Hz(Ll,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,l=hi(Ll,e.__scopeDialog);return s.jsx(Cg,{present:r||l.open,children:l.modal?s.jsx(Ite,{...a,ref:t}):s.jsx($te,{...a,ref:t})})});Zz.displayName=Ll;var Ite=m.forwardRef((e,t)=>{const n=hi(Ll,e.__scopeDialog),r=m.useRef(null),a=Wl(t,n.contentRef,r);return m.useEffect(()=>{const l=r.current;if(l)return hf(l)},[]),s.jsx(Kz,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:wo(e.onCloseAutoFocus,l=>{l.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:wo(e.onPointerDownOutside,l=>{const c=l.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0;(c.button===2||d)&&l.preventDefault()}),onFocusOutside:wo(e.onFocusOutside,l=>l.preventDefault())})}),$te=m.forwardRef((e,t)=>{const n=hi(Ll,e.__scopeDialog),r=m.useRef(!1),a=m.useRef(!1);return s.jsx(Kz,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:l=>{e.onCloseAutoFocus?.(l),l.defaultPrevented||(r.current||n.triggerRef.current?.focus(),l.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:l=>{e.onInteractOutside?.(l),l.defaultPrevented||(r.current=!0,l.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const c=l.target;n.triggerRef.current?.contains(c)&&l.preventDefault(),l.detail.originalEvent.type==="focusin"&&a.current&&l.preventDefault()}})}),Kz=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:l,...c}=e,d=hi(Ll,n),f=m.useRef(null),h=Wl(t,f);return Tte(),s.jsxs(s.Fragment,{children:[s.jsx(Lz,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:l,children:s.jsx(Iz,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":kw(d.open),...c,ref:h,onDismiss:()=>d.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(Ute,{titleId:d.titleId}),s.jsx(qte,{contentRef:f,descriptionId:d.descriptionId})]})]})}),jw="DialogTitle",Lte=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(jw,n);return s.jsx(Ss.h2,{id:a.titleId,...r,ref:t})});Lte.displayName=jw;var Yz="DialogDescription",Pte=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(Yz,n);return s.jsx(Ss.p,{id:a.descriptionId,...r,ref:t})});Pte.displayName=Yz;var Wz="DialogClose",Bte=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(Wz,n);return s.jsx(Ss.button,{type:"button",...r,ref:t,onClick:wo(e.onClick,()=>a.onOpenChange(!1))})});Bte.displayName=Wz;function kw(e){return e?"open":"closed"}var Xz="DialogTitleWarning",[ioe,Qz]=Yee(Xz,{contentName:Ll,titleName:jw,docsSlug:"dialog"}),Ute=({titleId:e})=>{const t=Qz(Xz),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
774
|
+
`),Q5(t)),c=m.useRef(null);return m.useEffect(()=>{const d=c.current,f=d?.closest(".file-preview-body");!d||!f||(f.scrollTop+=d.getBoundingClientRect().top-f.getBoundingClientRect().top-(f.clientHeight-d.offsetHeight)/2)},[n,t]),s.jsx("div",{className:je("file-preview-source",r&&"file-preview-source-wrap"),tabIndex:0,role:"region","aria-label":"文件源码",style:{"--gutter-digits":String(a.length).length},children:a.map((d,f)=>s.jsxs("div",{className:"file-preview-line","data-target":f+1===n||void 0,ref:f+1===n?c:void 0,children:[s.jsx("span",{className:"file-preview-number","aria-hidden":!0,children:f+1}),s.jsx("code",{children:s.jsx(XJ,{text:d,tokens:l?.[f]})})]},f))})}function XJ({text:e,tokens:t}){return e?!t||t.map(n=>n.content).join("")!==e?e:t.map((n,r)=>n.color?s.jsx("span",{style:{color:n.color},children:n.content},r):n.content):" "}async function bw(e){if(e.size>3e7)throw new Error(`${e.name} 超过 30 MB`);return new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>n(new Error("文件读取失败")),r.onload=()=>t(String(r.result).split(",")[1]??""),r.readAsDataURL(e)})}function xz(e,t){const{link:n}=Dt(),r=$t(),a=Rn(()=>qJ(v=>n.call("fs.read",{path:e,offset:v}),t),[n,e,t]),[l,c]=m.useState(),d=l&&l.source===a.value?l.file:a.value,f=m.useMemo(()=>t&&d?.text?FJ(d.text,t):void 0,[d?.text,t]);return{loaded:a,file:d,highlighted:f,more:()=>void r.run(async()=>{if(!d||d.nextOffset===void 0)return;const v=await n.call("fs.read",{path:e,offset:d.nextOffset});c({source:a.value,file:mz(d,v)})}),job:r}}function bz(e){return me?s.jsx(QJ,{...e}):s.jsx(JJ,{...e})}function QJ(e){const t=xz(e.path,e.line);return s.jsx(YJ,{...e,content:t})}function JJ({path:e,line:t,close:n,onDirtyChange:r}){const a=m.useRef(null),{loaded:l,file:c,highlighted:d,more:f,job:h}=xz(e,t),[v,g]=m.useState(!1),[x,y]=m.useState(!1),j=/\.(md|markdown)$/i.test(e),[k,C]=m.useState(j&&!t),[_,N]=m.useState();m.useEffect(()=>{a.current?.scrollIntoView({block:"center"})},[e,t,l.value]),m.useEffect(()=>{if(!_)return;const T=setTimeout(()=>N(void 0),2e3);return()=>clearTimeout(T)},[_]);function S(T,z){h.run(async()=>{await navigator.clipboard.writeText(T),N(z)})}return v?s.jsx(gz,{path:e,onDirtyChange:r,close:()=>{g(!1),l.reload()}},e):s.jsxs("section",{className:"file-reader resource-reader","aria-label":bs(e),"aria-busy":l.loading,children:[s.jsxs("header",{className:"resource-reader-heading",children:[s.jsxs("div",{className:"resource-file-title",children:[n&&s.jsx(F,{variant:"ghost",size:"icon-sm",onClick:n,title:"返回文件列表","aria-label":"返回文件列表",children:s.jsx(Po,{})}),s.jsx(Gd,{"aria-hidden":"true"}),s.jsxs("div",{children:[s.jsx("strong",{title:e,children:bs(e)}),s.jsxs("span",{children:[c?`${Oi(c.size)} · ${c.kind==="text"?"文本文件":c.kind==="image"?"图片":"二进制文件"}`:"读取文件",t?` · 第 ${t} 行`:""]})]})]}),s.jsxs("div",{className:"resource-inline-actions",children:[s.jsx(F,{variant:"ghost",size:"icon-sm",title:_==="path"?"路径已复制":"复制文件路径","aria-label":_==="path"?"路径已复制":"复制文件路径",onClick:()=>S(e,"path"),children:_==="path"?s.jsx(Hn,{}):s.jsx(El,{})}),s.jsx(F,{variant:"ghost",size:"icon-sm",disabled:l.loading||h.busy,title:"重新读取文件","aria-label":"重新读取文件",onClick:l.reload,children:s.jsx(ws,{})})]})]}),s.jsx("p",{className:"resource-path",title:e,children:e}),s.jsx(js,{...l}),s.jsx(ZJ,{path:e},e),l.error&&s.jsx(F,{variant:"outline",size:"sm",onClick:l.reload,children:"重新读取"}),s.jsx(it,{error:h.error}),c&&s.jsxs(s.Fragment,{children:[c.kind==="text"&&s.jsxs("div",{className:"resource-reader-tools",children:[j&&s.jsx(Ti,{value:k?"reading":"source",onValueChange:T=>C(T==="reading"),children:s.jsxs(Mi,{variant:"line","aria-label":"文件显示方式",children:[s.jsx(Pn,{value:"reading",children:"阅读"}),s.jsx(Pn,{value:"source",children:"源码"})]})}),s.jsxs(F,{variant:x?"secondary":"ghost",size:"sm","aria-pressed":x,disabled:k,onClick:()=>y(!x),children:[s.jsx(r6,{"data-icon":"inline-start"}),"自动换行"]}),s.jsxs(F,{variant:"ghost",size:"sm",disabled:h.busy,onClick:()=>S(c.text??"","content"),children:[_==="content"?s.jsx(Hn,{"data-icon":"inline-start"}):s.jsx(El,{"data-icon":"inline-start"}),_==="content"?"已复制":c.truncated?"复制已加载内容":"复制内容"]}),!c.truncated&&s.jsx(F,{variant:"outline",size:"sm",onClick:()=>g(!0),children:"AI 编辑"})]}),c.kind==="image"?s.jsx("div",{className:"resource-image-stage",children:s.jsx("img",{className:"file-image",src:`data:${c.mimeType};base64,${c.data}`,alt:bs(e)})}):c.kind==="text"?s.jsxs(s.Fragment,{children:[c.text&&k?s.jsx("div",{className:"resource-markdown",children:s.jsx(ja,{text:c.text})}):c.text?s.jsx("pre",{className:je("source-code resource-source",x&&"resource-source-wrap"),tabIndex:0,"aria-label":"文件内容",children:s.jsx("code",{children:d?s.jsxs(s.Fragment,{children:[d.before,s.jsx("span",{ref:a,className:"file-highlight-line",children:d.target||""}),d.after]}):c.text})}):s.jsx(an,{title:"这是一个空文件",description:"文件中还没有文本内容。"}),t&&!d&&!c.truncated&&s.jsxs("p",{className:"resource-caption",role:"status",children:["文件不足 ",t," 行,已显示全部内容。"]}),c.nextOffset!==void 0&&s.jsxs("div",{className:"resource-pagination",children:[s.jsxs("span",{className:"resource-caption",children:["已加载 ",Oi(c.nextOffset)," /"," ",Oi(c.size)]}),s.jsxs(F,{variant:"outline",size:"sm",disabled:h.busy,onClick:f,children:[h.busy&&s.jsx(vt,{className:"animate-spin","data-icon":"inline-start"}),h.busy?"正在读取…":"加载更多内容"]})]})]}):s.jsx(an,{title:"此文件暂不支持预览",description:"可以下载到本地,再用支持此格式的应用打开。"}),s.jsx("p",{className:"resource-caption resource-reader-footer",children:c.modifiedAt?`修改于 ${new Date(c.modifiedAt).toLocaleString("zh-CN",{dateStyle:"medium",timeStyle:"short"})}`:"内容来自已连接的电脑"})]}),s.jsx("span",{className:"sr-only",role:"status",children:_?"已复制到剪贴板":""})]})}function Ef({start:e,onPick:t,onDirtyChange:n,directoriesOnly:r=!1,page:a=!1}){const l=ar(),c=m.useRef(null),d=m.useRef(null),[f,h]=m.useState(!1),{link:v}=Dt(),[g,x]=m.useState(e),[y,j]=m.useState(!1),[k,C]=m.useState(),[_,N]=m.useState(),[S,T]=m.useState(!1),[z,L]=m.useState(()=>dn("desktopFilesListFolded",!1)),[B,O]=m.useState(()=>dn("desktopFilesListWidth",300)),$=(ye,$e)=>ft=>{$e(ft);try{sn(ye,ft)}catch{}},D=$("desktopFilesListFolded",L),Y=$("desktopFilesListWidth",O);m.useEffect(()=>(n?.(S),()=>n?.(!1)),[S,n]);const P=m.useRef(null),M=m.useRef(null),R=m.useRef(!1),[H,I]=m.useState(""),[q,G]=m.useState(""),[X,K]=m.useState(""),[ee,Z]=m.useState(),ne=$t(),ie=Rn(()=>v.call("fs.list",{path:g,hidden:y,files:!r}),[v,g,y,r]),de=Rn(()=>q?v.call("fs.search",{query:q}):Promise.resolve(void 0),[v,q]),oe=q?de:ie,ae=oe.value?.entries??[],Q=ie.value?.path??g??"主目录";m.useEffect(()=>{if(ie.loading||!ie.value||!R.current)return;R.current=!1,(M.current?.querySelector("button:not(:disabled)")??M.current)?.focus()},[ie.loading,ie.value]);async function pe(){return!S||await l.confirm("文件还有未保存的修改。放弃修改并离开编辑器?")}async function Me(ye){await pe()&&(R.current=!0,T(!1),C(void 0),x(ye),I(""),G(""),K(""),ne.clear())}async function ze(ye,$e){await pe()&&(T(!1),C(ye),N($e),ye||requestAnimationFrame(()=>P.current?.focus()))}const Le=!ne.busy&&!!ie.value&&!ie.loading&&!q;function He(ye){const $e=Array.from(ye??[]),ft=ie.value?.path;!ft||!$e.length||(K(""),ne.run(async()=>{for(const Se of $e)if(Se.size>3e7)throw new Error(`${Se.name} 超过 30 MB,尚未上传任何文件。`);let lt=0;try{for(const Se of $e)Z({done:lt,total:$e.length,name:Se.name}),await v.call("fs.upload",{dir:ft,name:Se.name,data:await bw(Se)},18e4),lt++;K(`已上传 ${lt} 个文件。同名文件已自动编号,原文件不会被覆盖。`)}catch(Se){throw new Error(`${lt?`已上传 ${lt} / ${$e.length} 个文件。`:""}${Ps(Se)}`,{cause:Se})}finally{Z(void 0),lt&&ie.reload()}}))}async function Te(){const ye=ie.value?.path,$e=await l.prompt("新目录名称");!ye||!$e?.trim()||ne.run(async()=>{const ft=$e.trim();if(ft==="."||ft===".."||/[/\\\0]/.test(ft)||ft.length>255)throw new Error("请输入有效的目录名称,不要包含斜杠,最多 255 个字符。");await v.call("fs.mkdir",{parent:ye,name:ft}),K(`已创建目录“${ft}”`),ie.reload()})}async function st(){const ye=await l.prompt("输入要打开的目录路径",ie.value?.path??g??"","打开目录");ye?.trim()&&Me(ye.trim())}function wt(){H.trim()&&(G(H.trim()),q===H.trim()&&de.reload())}const xt=()=>{I(""),G("")},Zt=q?`“${q}”的目录结果`:`${ae.length}${ie.value?.truncated?"+":""} 个${r?"目录":"项目"}`,rt=me&&!r,se=s.jsxs(s.Fragment,{children:[s.jsx(F,{variant:"ghost",size:"icon",disabled:ne.busy||ie.loading,title:"主目录","aria-label":"前往主目录",onClick:()=>void Me(),children:s.jsx(yb,{})}),s.jsx(F,{variant:"ghost",size:"icon",disabled:ne.busy||!ie.value?.parent,title:"上一级目录","aria-label":"前往上一级目录",onClick:()=>void Me(ie.value?.parent),children:s.jsx(em,{})})]}),Ae=s.jsx(F,{variant:"ghost",size:"icon",disabled:oe.loading||ne.busy,title:"刷新目录","aria-label":"刷新目录",onClick:oe.reload,children:s.jsx(ws,{})}),et=s.jsx("form",{className:"resource-search",onSubmit:ye=>{ye.preventDefault(),wt()},children:s.jsxs(zi,{className:"page-search",children:[s.jsx(Is,{children:s.jsx(Lr,{"aria-hidden":"true"})}),s.jsx(yo,{"aria-label":"搜索电脑上的目录",placeholder:"搜索目录",maxLength:200,autoFocus:!a,value:H,onChange:ye=>{I(ye.target.value),ye.target.value||G("")},onKeyDown:ye=>{ye.key==="Escape"&&(xt(),a||h(!1))}}),H&&s.jsx(Is,{align:"inline-end",children:s.jsx(bo,{size:"icon-xs",title:"清空搜索","aria-label":"清空搜索",onClick:xt,children:s.jsx(zn,{})})})]})}),jt=s.jsx("input",{ref:c,type:"file",multiple:!0,hidden:!0,tabIndex:-1,onChange:ye=>{const $e=ye.target.files;He($e),ye.target.value=""}}),ht=()=>{c.current&&(c.current.value="",c.current.click())},mn=s.jsxs(Yd,{className:"resource-hidden-toggle",children:[s.jsx(Ol,{checked:y,onCheckedChange:ye=>j(ye===!0)}),"显示隐藏项目"]});return s.jsxs("section",{ref:d,className:je("file-browser resource-files",k&&"resource-has-preview"),"data-layout":rt?a?"page":"panel":void 0,"data-list-folded":rt&&a&&!!k&&z||void 0,style:rt&&a?{"--files-list-width":`${B}px`}:void 0,"aria-label":r?"选择目录":"文件浏览器",children:[rt&&jt,rt&&a&&s.jsx(lr,{leading:s.jsxs("span",{className:"resource-toolbar-nav",children:[s.jsx(F,{variant:"ghost",size:"icon",className:"files-list-toggle","data-unused":!k||void 0,"aria-hidden":!k||void 0,tabIndex:k?void 0:-1,disabled:!k,"aria-pressed":!z,title:z?"显示文件列表":"隐藏文件列表","aria-label":z?"显示文件列表":"隐藏文件列表",onClick:()=>D(!z),children:s.jsx($U,{})}),se]}),title:s.jsx("span",{title:Q,children:bs(Q)||"根目录"}),detail:s.jsx("span",{className:"resource-toolbar-path",title:Q,children:Q}),actions:s.jsxs(s.Fragment,{children:[et,s.jsx(F,{variant:"ghost",size:"icon",title:"前往目录","aria-label":"前往目录",disabled:ne.busy,onClick:()=>void st(),children:s.jsx(vo,{})}),Ae,s.jsxs(F,{variant:"ghost",size:"sm",disabled:!Le,onClick:()=>void Te(),children:[s.jsx(e0,{"data-icon":"inline-start"}),"新建目录"]}),s.jsxs(F,{size:"sm",disabled:!Le,title:"单个文件最大 30 MB",onClick:ht,children:[s.jsx(Kd,{"data-icon":"inline-start"}),"上传文件"]})]})}),rt&&!a&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"resource-toolbar",children:[se,s.jsx("span",{className:"resource-toolbar-name",title:Q,children:bs(Q)||"根目录"}),s.jsx(F,{variant:"ghost",size:"icon",title:"搜索目录","aria-label":"搜索目录","aria-pressed":f,onClick:()=>{f&&xt(),h(!f)},children:s.jsx(Lr,{})}),Ae,s.jsxs(As,{children:[s.jsx(Ts,{asChild:!0,children:s.jsx(F,{variant:"ghost",size:"icon",title:"更多","aria-label":"更多文件操作",children:s.jsx(bf,{})})}),s.jsxs(Ms,{align:"end",children:[s.jsxs(mt,{disabled:!Le,onSelect:ht,children:[s.jsx(Kd,{}),"上传文件"]}),s.jsxs(mt,{disabled:!Le,onSelect:()=>void Te(),children:[s.jsx(e0,{}),"新建目录"]}),s.jsxs(mt,{disabled:ne.busy,onSelect:()=>void st(),children:[s.jsx(vo,{}),"前往目录…"]}),s.jsx(sr,{}),s.jsx(YQ,{checked:y,onCheckedChange:ye=>j(ye===!0),children:"显示隐藏项目"})]})]})]}),f&&et]}),!rt&&s.jsxs("div",{className:"resource-browser-controls",children:[s.jsxs("div",{className:"resource-location-bar",children:[s.jsx(F,{variant:"outline",size:"icon",disabled:ne.busy||ie.loading,title:"主目录","aria-label":"前往主目录",onClick:()=>void Me(),children:s.jsx(yb,{})}),s.jsx(F,{variant:"outline",size:"icon",disabled:ne.busy||!ie.value?.parent,title:"上一级目录","aria-label":"前往上一级目录",onClick:()=>void Me(ie.value?.parent),children:s.jsx(em,{})}),s.jsxs("div",{className:"resource-location",children:[s.jsx("strong",{children:bs(Q)||"根目录"}),s.jsx("span",{title:Q,children:Q})]}),s.jsx(F,{variant:"ghost",size:"icon",title:"前往目录","aria-label":"前往目录",disabled:ne.busy,onClick:()=>void st(),children:s.jsx(vo,{})}),Ae]}),s.jsx("form",{onSubmit:ye=>{ye.preventDefault(),wt()},children:s.jsx(Yn,{children:s.jsxs(Et,{children:[s.jsx(Rt,{className:"sr-only",children:"搜索电脑上的目录"}),s.jsxs(zi,{children:[s.jsx(Is,{children:s.jsx(Lr,{"aria-hidden":"true"})}),s.jsx(yo,{"aria-label":"搜索电脑上的目录",placeholder:"搜索电脑上的目录…",maxLength:200,value:H,onChange:ye=>{I(ye.target.value),ye.target.value||G("")},onKeyDown:ye=>{ye.key==="Escape"&&xt()}}),s.jsxs(Is,{align:"inline-end",children:[H&&s.jsx(bo,{size:"icon-xs",title:"清空搜索","aria-label":"清空搜索",onClick:xt,children:s.jsx(zn,{})}),s.jsx(bo,{type:"submit",variant:"secondary",disabled:!H.trim()||de.loading&&!!q,children:"搜索"})]})]})]})})}),s.jsxs("div",{className:"resource-directory-summary",children:[s.jsx("span",{children:Zt}),q?s.jsx(F,{variant:"link",size:"sm",onClick:xt,children:"返回当前目录"}):mn]})]}),r?s.jsxs("div",{className:"resource-picker-footer",children:[s.jsxs("p",{className:"resource-path",title:Q,children:["将使用:",Q]}),s.jsx(F,{disabled:!ie.value||ie.loading||!!q,onClick:()=>{ie.value&&t?.(ie.value.path)},children:"选择此目录"})]}):rt?null:s.jsxs("div",{className:"resource-files-footer",children:[s.jsxs("div",{className:"resource-inline-actions",children:[s.jsx(vw,{multiple:!0,disabled:!Le,onChange:ye=>{const $e=ye.target.files;He($e),ye.target.value=""},children:"上传文件"}),s.jsxs(F,{variant:"outline",disabled:!Le,onClick:()=>void Te(),children:[s.jsx(e0,{"data-icon":"inline-start"}),"新建目录"]})]}),s.jsx("span",{className:"resource-caption",children:"单个文件最大 30 MB"})]}),s.jsx(it,{error:ne.error}),X&&s.jsxs(cn,{role:"status",children:[s.jsx(Hn,{}),s.jsx(rn,{children:X})]}),ee&&s.jsxs(cn,{role:"status",children:[s.jsx(vt,{className:"animate-spin"}),s.jsxs(rn,{children:["正在上传 ",ee.done+1," / ",ee.total,":",ee.name]})]}),s.jsxs("div",{className:"resource-file-layout",children:[s.jsxs("div",{className:"resource-directory",ref:M,tabIndex:-1,"aria-busy":oe.loading,children:[s.jsx(js,{...oe}),oe.error&&s.jsxs(F,{variant:"outline",size:"sm",onClick:oe.reload,children:["重新",q?"搜索":"加载"]}),!oe.loading&&!oe.error&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"resource-entry-list","aria-label":q?"目录搜索结果":"目录内容",onKeyDown:ye=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(ye.key)||ye.altKey||ye.metaKey||ye.ctrlKey)return;const $e=[...ye.currentTarget.querySelectorAll("button:not(:disabled)")],ft=$e.indexOf(document.activeElement);if(ft<0)return;ye.preventDefault();const lt=ye.key==="Home"?0:ye.key==="End"?$e.length-1:Math.max(0,Math.min($e.length-1,ft+(ye.key==="ArrowDown"?1:-1)));$e[lt]?.focus()},children:ae.map(ye=>s.jsxs(F,{variant:k===ye.path?"secondary":"ghost",className:"resource-entry h-10 gap-2.5 rounded-none px-2","aria-current":k===ye.path?"true":void 0,title:ye.path,disabled:ne.busy,onClick:$e=>{ye.file&&(P.current=$e.currentTarget),ye.file?ze(ye.path):Me(ye.path)},children:[ye.file?s.jsx(Gd,{"data-icon":"inline-start"}):s.jsx(q3,{"data-icon":"inline-start"}),s.jsxs("span",{className:"resource-entry-main",children:[s.jsx("span",{className:"resource-entry-name",children:ye.name}),q&&s.jsx("span",{className:"resource-entry-path",children:ye.path})]}),ye.project?s.jsx(ui,{variant:"secondary",children:"项目"}):ye.size!==void 0?s.jsx("span",{className:"resource-entry-size",children:Oi(ye.size)}):null,!ye.file&&s.jsx(li,{"data-icon":"inline-end"})]},ye.path))}),ae.length===0&&s.jsx(an,{title:q?"没有找到匹配的目录":r?"没有可选的子目录":"这个目录是空的",description:q?"试试更短的目录名,搜索范围为电脑的主目录。":r?"可以选择当前目录,或返回上一级继续浏览。":"上传文件或新建目录,开始整理这个位置。"}),rt&&ae.length>0&&s.jsxs("p",{className:"resource-list-foot",children:[s.jsx("span",{children:Zt}),q?s.jsx(F,{variant:"link",size:"sm",onClick:xt,children:"返回当前目录"}):a?mn:null]}),oe.value?.truncated&&s.jsxs("p",{className:"resource-caption resource-results-note",children:["结果较多,仅显示前 ",ae.length," ","项。请使用更具体的目录名搜索。"]})]})]}),rt&&a&&!(k&&z)&&s.jsx(xw,{className:"files-list-resizer",label:"调整文件列表宽度",width:B,clamp:ye=>Math.round(Math.min(Math.max(ye,200),Math.max(200,Math.min(560,(d.current?.clientWidth??window.innerWidth)*.5)))),side:"end",target:".file-browser",column:".resource-directory",variable:"--files-list-width",resize:Y,initial:300}),rt&&a&&!k&&s.jsxs("div",{className:"file-preview-empty",children:[s.jsx(Gd,{"aria-hidden":"true"}),s.jsx("span",{children:"选择一个文件查看内容"})]}),k&&s.jsx(Vo.Provider,{value:{cwd:k.slice(0,k.lastIndexOf("/"))||"/",open:(ye,$e)=>void ze(ye,$e)},children:s.jsx(bz,{path:k,line:_,close:()=>void ze(),onDirtyChange:T},`${k}:${_??""}`)})]})]})}const eee="https://mkbeusztkzffnzjdwmqk.supabase.co",tee="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1rYmV1c3p0a3pmZm56amR3bXFrIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjU5Nzc0NzgsImV4cCI6MjA4MTU1MzQ3OH0.2wlT6q6687Z5rpEYsdp01IQpNNl_XWv0IAfBgwPyDP0";let nee;function yz(){return{supabaseUrl:window.__LINKSHELL_CONFIG__?.account?.url??eee,anonKey:window.__LINKSHELL_CONFIG__?.account?.anonKey??tee}}function tu(){if(me)throw new Error("桌面端使用 LinkShell 的系统浏览器登录");const{supabaseUrl:e,anonKey:t}=yz();return nee??=f8(e,t,{global:{fetch:(n,r)=>{const a=r?.signal??(n instanceof Request?n.signal:void 0);return fetch(n,{...r,signal:AbortSignal.any([...a?[a]:[],AbortSignal.timeout(3e4)])})}},auth:{persistSession:!0,autoRefreshToken:!0,detectSessionInUrl:!1,flowType:"pkce",storageKey:"linkshell.web.account.v2"}})}function Pd(e,t){if(!e)throw new Error("登录已失效,请重新登录");if(e!==t)throw new Error("账号已切换,请在当前账户下重新操作")}async function wz(e){if(me){const l=await Gp();return e!==void 0&&Pd(l.userId,e),l.accessToken}const t=tu().auth,{data:n,error:r}=await t.getSession();if(r)throw r;if(e!==void 0&&Pd(n.session?.user.id,e),!n.session)return;if((n.session.expires_at??0)*1e3>Date.now()+12e4)return n.session.access_token;const a=await t.refreshSession();if(a.error)throw a.error;if(!a.data.session)throw new Error("登录已失效,请重新登录");return e!==void 0&&Pd(a.data.session.user.id,e),a.data.session.access_token}async function yw(e){if(me){const r=await Gp();if(Pd(r.userId,e),!r.accessToken)throw new Error("登录已失效,请重新登录");return{access_token:r.accessToken}}const{data:t,error:n}=await tu().auth.getSession();if(n)throw n;if(!t.session)throw new Error("登录已失效,请重新登录");return Pd(t.session.user.id,e),t.session}async function jz(e){const t=await wz(e),n=await yw(e);if(!t||n.access_token!==t)throw new Error("账号状态已更新,请重试");return t}async function see(e){const t=await jz(e),n=await wQ({...yz(),accessToken:t,userId:e});return await yw(e),n}async function ree(e,t){const n=await jz(e),r=await kQ(n,t);return await yw(e),r}const iee=e=>{const t=new RTCPeerConnection({iceServers:e.map(r=>({urls:r}))}),n=t.createDataChannel(yW,{ordered:!0});return n.binaryType="arraybuffer",{async offer(){if(await t.setLocalDescription(await t.createOffer()),t.iceGatheringState!=="complete"&&await new Promise(r=>{const a=()=>{clearTimeout(c),t.removeEventListener("icegatheringstatechange",l),r()},l=()=>{t.iceGatheringState==="complete"&&a()},c=setTimeout(a,2e3);t.addEventListener("icegatheringstatechange",l)}),!t.localDescription?.sdp)throw new Error("无法建立直连通道");return t.localDescription.sdp},accept:r=>t.setRemoteDescription({type:"answer",sdp:r}),send(r){n.send(r)},onState(r){n.addEventListener("open",()=>r("open")),n.addEventListener("close",()=>r("closed")),t.addEventListener("connectionstatechange",()=>{["failed","closed"].includes(t.connectionState)&&r("closed")})},onMessage(r){n.addEventListener("message",a=>{a.data instanceof ArrayBuffer&&r(new Uint8Array(a.data))})},close(){t.close()}}};class aee{constructor(t){this.open=t}entries=new Map;acquire(t,n){let r=this.entries.get(t.key);r||(r={...this.open(t),users:0,streamUsers:0},this.entries.set(t.key,r));const a=r;a.users++;const l=!n?.metadataOnly;if(l&&a.streamUsers++===0)try{a.connection.streams.start()}catch(d){throw a.streamUsers--,--a.users===0?this.remove(t.key):a.connection.streams.stop(),d}let c=!1;return{connection:a.connection,release:()=>{c||this.entries.get(t.key)!==a||(c=!0,l&&a.streamUsers--,--a.users===0?this.remove(t.key):l&&a.streamUsers===0&&a.connection.streams.stop())}}}values(){return[...this.entries.values()].map(({connection:t})=>t)}remove(t){const n=this.entries.get(t);this.entries.delete(t),n?.close()}clear(){for(const t of this.entries.keys())this.remove(t)}}const Cm=40,qc=e=>`@shared:${e}`;function mE(e){return!e||typeof e!="object"||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(([t,n])=>typeof n=="string"&&n.trim().length>0&&n.length<=(t.startsWith("@shared:")?120:Cm)))}function Mn(e,t){return(e.machine.namingConfigured?e.machine.name:t[qc(e.key)])||t[e.key]||e.machine.name||"电脑"}function Nf(e){return`${{darwin:"macOS",linux:"Linux",win32:"Windows"}[e.machine.platform??""]||e.machine.platform||"电脑"} · ${e.machine.id.slice(0,8)}`}function kz(e,t){return`${Mn(e,t)} · ${e.machine.id.slice(0,8)} · ${e.machine.online?"在线":"离线"}`}function oee(){const e=Cf(()=>mE(dn("computer-names",{}))),t=new Map,n=()=>{const a=mE(dn("computer-names",{})),l={...a};for(const[c,d]of t){if(a[qc(c)]!==d.saved){t.delete(c);continue}l[qc(c)]=d.name,delete l[c]}return{saved:a,next:l}},r=(a,l)=>{const{saved:c,next:d}=n();if(d[qc(a.key)]===l&&!d[a.key]&&!t.size){e.setState(d,!0);return}delete d[a.key],d[qc(a.key)]=l,t.set(a.key,{name:l,saved:c[qc(a.key)]});try{sn("computer-names",d),t.clear()}catch{}e.setState(d,!0)};return{store:e,refresh(){e.setState(n().next,!0)},remember(a){a.machine.namingConfigured&&r(a,a.machine.name)},sync(a,l){l.naming?.configured&&r(a,l.hostname)},async rename(a,l,c){const d=l.trim();if(d.length>Cm)throw new Error(`名称不能超过 ${Cm} 个字符`);const f=await c.call("machine.rename",{name:d});return r(a,f.hostname),f}}}const Vn=oee();if(typeof window<"u"){const e=t=>{(t.key===null||t.key==="linkshell.web.computer-names")&&Vn.refresh()};window.addEventListener("storage",e)}function _m(e,t,n){const r=e.find(l=>l.key===t);if(r)return r;const a=n??e.find(l=>l.key==="desktop:local");if(!(!a?.relayId||t!==a.key&&!t.endsWith(`#${a.relayId}`)))return e.find(l=>l.key===a.key||l.machine.id===a.relayId)}function lee(e){const t=e.find(r=>r.key==="desktop:local");if(!t?.relayId)return e;const n=t.machine.online?t:e.find(r=>r!==t&&r.machine.id===t.relayId&&r.machine.online)??t;return e.filter(r=>r===n||r!==t&&r.machine.id!==t.relayId)}const cee=dn("source",pa),Sz=pa==="self-hosted"?"self-hosted":cee,uee=Sz==="official"?Ks:dn("gateway",BQ),gE="网关未确认当前账号,请退出账号后重新登录。";function dee(e){switch(e.code){case"disconnected":case"connect_failed":return"与网关的连接断开了,正在自动重连…";case"replaced":return"这台设备已在别处连上网关";default:return e.message}}class fee{state=Cf(()=>({source:Sz,gateway:uee,computers:[],relayStatus:{},locked:!1,ready:!1}));identity;relays=new Map;relayErrors=new Map;paired=dn("paired",[]);localAliases=new Map;selected=dn("selected","");releaseLock;starting;authUser;accountRevision=0;authSubscribed=!1;generation=0;desktopPoll;accountAuthTimer;desktopRefresh;desktopLocalRequest;desktopLocalAbort;desktopLocalRetry;desktopLocalAttempt;connections=new aee(t=>this.openComputer(t));releaseSelected;channel=typeof BroadcastChannel<"u"?new BroadcastChannel("linkshell.web.owner"):void 0;constructor(){me&&(window.addEventListener(p8,t=>this.report(t.detail)),window.addEventListener(m8,t=>this.applyAccount(t.detail)),window.addEventListener(K0,t=>{t.detail?.visible&&this.reconnect()})),this.channel?.addEventListener("message",t=>{t.data==="yield"&&(this.stop(),this.state.setState({locked:!0}))}),window.addEventListener("pagehide",()=>this.stop()),window.addEventListener("pageshow",()=>{this.start()}),window.addEventListener("online",()=>this.reconnect()),document.addEventListener("visibilitychange",()=>{document.hidden||this.reconnect()})}report(t){this.state.setState({error:t instanceof Error?t.message:String(t)})}async start(){return this.releaseLock||this.starting?this.starting:(this.starting=this.acquire(!1).finally(()=>{this.starting=void 0}),this.starting)}async claim(){this.channel?.postMessage("yield"),await this.acquire(!0)}async acquire(t){if(me){this.releaseLock=()=>{},this.state.setState({locked:!1}),await this.boot().catch(n=>this.report(n));return}if(!navigator.locks){this.report(new Error("此浏览器不支持设备连接锁,请使用最新版 Chrome、Edge、Safari 或 Firefox"));return}await new Promise((n,r)=>{navigator.locks.request("linkshell.web.connection",{ifAvailable:!t},async a=>{if(!a){this.state.setState({locked:!0,ready:!0}),n();return}await new Promise(l=>{this.releaseLock=l,this.state.setState({locked:!1}),this.boot().then(n,r)})}).catch(r)}).catch(n=>this.report(n))}async boot(){const t=++this.generation;if(this.identity=await UJ(),t===this.generation){if(this.localAliases.clear(),this.state.setState({localComputer:void 0,computers:this.paired.map(n=>({...n,machine:{...n.machine,online:!1}})),ready:!0}),me){const n=g8();n?this.setLocalComputer(n):this.desktopLocalAttempt=0,this.desktopPoll=setInterval(()=>{this.refreshDesktop()},3e4),this.refreshDesktop()}for(const n of this.paired)this.relay(n.gateway);this.state.getState().source==="official"?await this.connectAccount():this.state.getState().gateway&&this.relay(Bp(this.state.getState().gateway))}}async connectAccount(){if(pa==="self-hosted")throw new Error("私有部署使用设备配对");if(me){const l=await Gp();this.applyAccount(l),this.state.setState({source:"official",gateway:Ks}),sn("source","official");return}const t=tu().auth,n=this.accountRevision,{data:r,error:a}=await t.getSession();if(n===this.accountRevision){if(a)throw a;this.applyAccount({userId:r.session?.user.id,email:r.session?.user.email})}this.state.setState({source:"official",gateway:Ks}),this.authSubscribed||(this.authSubscribed=!0,t.onAuthStateChange((l,c)=>{this.applyAccount({userId:c?.user.id,email:c?.user.email})})),sn("source","official")}applyAccount(t){const n=this.authUser!==t.userId;if(this.authUser=t.userId,n){this.accountRevision++;const a=[...this.state.getState().computers,...this.connections.values().map(l=>l.computer)];for(const l of a)l.gateway!==Ks||l.machine.via!=="account"||(this.state.getState().connection?.computer.key===l.key&&this.disconnect(),this.connections.remove(l.key));for(const[l,c]of this.localAliases)c.gateway===Ks&&c.machine.via==="account"&&this.localAliases.delete(l)}if(this.state.setState(a=>({account:t.email,accountUserId:t.userId,computers:n?this.mergeComputers(a.computers.filter(l=>l.gateway!==Ks||l.machine.via!=="account"),a.localComputer):a.computers})),!this.releaseLock||!n&&(this.accountAuthTimer||this.relays.has(Ks)))return;this.accountAuthTimer&&clearTimeout(this.accountAuthTimer);const r=this.generation;this.accountAuthTimer=setTimeout(()=>{this.accountAuthTimer=void 0,!(!this.releaseLock||r!==this.generation||t.userId!==this.authUser)&&(n&&this.relays.get(Ks)?.reauthenticate(),t.userId&&this.relay(Ks))},0)}setLocalComputer(t){t&&(this.desktopLocalRetry&&clearTimeout(this.desktopLocalRetry),this.desktopLocalRetry=void 0,this.desktopLocalAttempt=void 0),this.state.setState(n=>{const r=n.localComputer??n.computers.find(l=>l.key===Jn),a=t?{...t,relayId:t.relayId??(t.machine.id===r?.machine.id?r.relayId:void 0)}:r?{...r,machine:{...r.machine,online:!1}}:void 0;return{localComputer:a,computers:this.mergeComputers(n.computers.filter(l=>l.key!==Jn),a),localError:t?void 0:"本机服务未运行,请在本机服务中启动。"}}),t&&!this.state.getState().connection&&(!this.selected||this.computerForKey(this.selected)?.key===Jn)&&this.select(t)}mergeComputers(t,n){for(const[a,l]of this.localAliases)(!n?.relayId||l.machine.id!==n.relayId)&&this.localAliases.delete(a);for(const a of t)a.key!==Jn&&n?.relayId===a.machine.id&&this.localAliases.set(a.key,a);const r=new Map([...this.localAliases.values(),...t].map(a=>[a.key,a]));return r.delete(Jn),lee([...n?[n]:[],...r.values()])}refreshLocal(){if(!me||!this.releaseLock)return Promise.resolve();if(this.desktopLocalRequest)return this.desktopLocalRequest;const t=this.generation,n=new AbortController,r=setTimeout(()=>n.abort(),15e3);this.desktopLocalAbort=n;const a=v8("/desktop/local",{signal:n.signal}).then(({computer:l})=>{t===this.generation&&this.setLocalComputer(l)}).catch(l=>{t===this.generation&&(this.setLocalComputer(void 0),this.state.setState({localError:l instanceof Error?l.message:String(l)}))}).finally(()=>{clearTimeout(r),this.desktopLocalRequest===a&&(this.desktopLocalRequest=void 0,this.desktopLocalAbort=void 0),this.retryInitialLocalDiscovery(t)});return this.desktopLocalRequest=a,a}retryInitialLocalDiscovery(t){if(!this.releaseLock||t!==this.generation||this.desktopLocalRetry||this.desktopLocalAttempt===void 0)return;const n=[500,1e3,2e3,4e3,8e3][this.desktopLocalAttempt++];if(n===void 0){this.desktopLocalAttempt=void 0;return}this.desktopLocalRetry=setTimeout(()=>{this.desktopLocalRetry=void 0,this.releaseLock&&t===this.generation&&this.refreshLocal()},n)}refreshDesktop(){return this.desktopRefresh?this.desktopRefresh:(this.desktopRefresh=Promise.all([this.refreshLocal(),Gp().then(()=>{},t=>this.report(t))]).then(()=>{}).finally(()=>{this.desktopRefresh=void 0}),this.desktopRefresh)}relay(t){if(!this.identity||!this.releaseLock)throw new Error("请先在本标签页启用连接");const n=Bp(t),r=this.relays.get(n);if(r)return r;const a=n===Ks&&pa!=="self-hosted",l=new bW({url:n+dW,identity:this.identity,role:"device",name:me?"LinkShell Desktop":"LinkShell Web",platform:br?"Windows":me?"macOS":"web",token:a?async()=>{const c=this.accountRevision,d=this.authUser;try{const f=await wz(d);if(c!==this.accountRevision||d!==this.authUser)throw new Error("账号已更新,正在重新连接");return f}catch(f){throw c===this.accountRevision&&this.report(f),f}}:void 0,createSocket:c=>{const d=new WebSocket(c),f=d.send.bind(d);return d.send=h=>{if(typeof h=="string"&&a&&this.authUser){const v=JSON.parse(h);if(v.t==="auth"&&!v.token){d.close(4001,"账号续期失败,正在重试");return}}f(h)},d}});return this.relays.set(n,l),l.onStatus((c,d)=>{const f=d?dee(d):void 0,h=this.relayErrors.get(n);f?this.relayErrors.set(n,f):c==="online"&&this.relayErrors.delete(n),this.state.setState(v=>({relayStatus:{...v.relayStatus,[n]:c},...f?{error:f}:c==="online"&&h!==void 0&&v.error===h?{error:void 0}:{}})),c==="online"&&this.refresh(n).catch(v=>this.report(v))}),l.on("machines.changed",()=>{this.refresh(n).catch(c=>this.report(c))}),l.on("presence",({id:c,online:d})=>{const f=`${n}#${c}`,h=this.localAliases.get(f);if(h&&this.localAliases.set(f,{...h,machine:{...h.machine,online:d}}),d&&!h&&!this.state.getState().computers.some(v=>v.gateway===n&&v.machine.id===c)){this.refresh(n).catch(v=>this.report(v));return}this.state.setState(v=>({computers:this.mergeComputers(v.computers.map(g=>g.gateway===n&&g.machine.id===c?{...g,machine:{...g.machine,online:d}}:g),v.localComputer)}))}),l.start(),l}async refresh(t){const n=this.relays.get(t);if(!n)return;const r=this.generation,a=this.authUser,l=this.accountRevision,{machines:c}=await n.request("machines.list",{});if(r!==this.generation||n!==this.relays.get(t)||t===Ks&&(a!==this.authUser||l!==this.accountRevision))return;const d=t===Ks&&pa!=="self-hosted",f=d&&!!a&&n.account?.userId===a,h=c.filter(g=>g.via==="paired"||f).map(g=>({gateway:t,machine:g,key:`${t}#${g.id}`}));for(const[g,x]of this.localAliases)x.gateway===t&&this.localAliases.delete(g);for(const g of h)Vn.remember(g);this.state.setState(g=>({computers:this.mergeComputers([...g.computers.filter(x=>x.gateway!==t),...h],g.localComputer)}));const v=this.state.getState();if(!v.connection){const g=_m(v.computers,this.selected,v.localComputer)??v.computers.find(x=>x.machine.online);g&&this.select(g)}d&&a&&!f?this.state.setState({error:gE}):d&&this.state.getState().error===gE&&this.state.setState({error:void 0})}select(t){t=this.computerForKey(t.key)??t;const n=this.retainComputer(t);this.disconnect(),this.releaseSelected=n.release,this.state.setState({connection:n.connection,error:void 0}),this.selected=t.key,sn("selected",t.key)}computerForKey(t){const n=this.state.getState();return _m(n.computers,t,n.localComputer)}retainComputer(t,n){if(!this.identity||!this.releaseLock)throw new Error("请先在本标签页启用连接");return this.connections.acquire(this.computerForKey(t.key)??t,n)}openComputer(t){if(!this.identity)throw new Error("设备身份尚未就绪");const n=this.identity,r=me&&t.key===Jn&&t.gateway===Jn,a=r?void 0:this.relay(t.gateway),l=new oQ({url:t.key,createSocket:()=>r?x8():new pQ(a,n,t.machine),lazyImages:!0}),c=hQ(l,{lazyImages:!0}),d=new vQ(l,{connector:r?void 0:iee,iceServers:()=>c.getState().machine?.direct?.iceServers});d.stop();const f={computer:t,link:l,store:c,streams:d},h=c.subscribe((v,g)=>{if(v.machine!==g.machine){if(v.machine?.naming){Vn.sync(t,v.machine);const x={...f.computer,machine:{...f.computer.machine,name:v.machine.hostname,namingConfigured:v.machine.naming.configured}};f.computer=x,this.state.setState(y=>({computers:y.computers.map(j=>j.key===t.key?{...j,machine:{...j.machine,name:x.machine.name,namingConfigured:x.machine.namingConfigured}}:j),connection:y.connection?.computer.key===t.key?{...y.connection,computer:x}:y.connection,localComputer:y.localComputer?.key===t.key?{...y.localComputer,machine:{...y.localComputer.machine,name:x.machine.name,namingConfigured:x.machine.namingConfigured}}:y.localComputer}))}d.connect()}});return c.getState().connect(),{connection:f,close:()=>{h(),d.stop(),c.getState().disconnect()}}}async pair(t,n){const r=n.trim().startsWith("linkshell:")?xm(n.trim()):void 0;if(n.trim().startsWith("linkshell:")&&!r)throw new Error("配对链接格式不正确");if(!r&&!/^\d{6}$/.test(n.trim()))throw new Error("请输入 6 位配对码");const a=Bp((r?.gateway??t).replace(/^http/,"ws")),l=this.relay(a),c=r?await mQ(l,this.identity,r):await gQ(l,this.identity,n.trim()),d={key:`${a}#${c.id}`,gateway:a,machine:c};this.paired=[...this.paired.filter(f=>f.key!==d.key),d],sn("paired",this.paired),sn("source","self-hosted"),sn("gateway",a),this.state.setState({source:"self-hosted",gateway:a}),await this.refresh(a),this.select(d)}async forget(t){if(t.key===Jn)throw new Error("本机无需配对,请在本机服务中管理连接");await this.relay(t.gateway).request("machines.forget",{machineId:t.machine.id}),this.paired=this.paired.filter(n=>n.key!==t.key),sn("paired",this.paired),this.state.getState().connection?.computer.key===t.key&&this.disconnect(),this.connections.remove(t.key),this.localAliases.delete(t.key),this.state.setState(n=>({computers:this.mergeComputers(n.computers.filter(r=>r.key!==t.key),n.localComputer)}))}async refreshComputers(){if(!this.releaseLock)return;const t=[];me&&t.push(this.refreshDesktop());for(const[r,a]of this.relays)a.status==="online"?t.push(this.refresh(r)):a.reconnectNow();const n=(await Promise.allSettled(t)).find(r=>r.status==="rejected");if(n)throw n.reason}reconnect(){if(this.releaseLock){me&&(b8(),this.refreshDesktop());for(const t of this.relays.values())t.reconnectNow();for(const t of this.connections.values())t.link.reconnectNow()}}disconnect(){this.releaseSelected?.(),this.releaseSelected=void 0,this.state.setState({connection:void 0})}stop(){this.generation++,this.desktopLocalRetry&&clearTimeout(this.desktopLocalRetry),this.desktopLocalRetry=void 0,this.desktopLocalAttempt=void 0,this.desktopLocalAbort?.abort(),this.desktopLocalAbort=void 0,this.desktopLocalRequest=void 0,this.desktopPoll&&clearInterval(this.desktopPoll),this.desktopPoll=void 0,this.accountAuthTimer&&clearTimeout(this.accountAuthTimer),this.accountAuthTimer=void 0,this.disconnect(),this.connections.clear();for(const t of this.relays.values())t.stop();this.relays.clear(),this.releaseLock?.(),this.releaseLock=void 0}}const We=new fee,kd=e=>e.installed&&!e.problem&&e.auth?.state!=="missing"&&e.tier!=="terminal";function hee({initialDirectory:e,created:t,cancel:n}){const r=yt(Q=>Q.machine),a=yt(Q=>Q.projects),l=yt(Q=>Q.status==="online"),c=Gn(),{store:d}=Dt(),f=qe(We.state),h=qe(Vn.store),v=$t(),[g,x]=m.useState(()=>r?.agents.find(kd)?.id??""),[y,j]=m.useState(e??a[0]?.cwd??r?.home??""),[k,C]=m.useState(""),[_,N]=m.useState(!1),[S,T]=m.useState(!1),[z,L]=m.useState(),[B,O]=m.useState(),[$,D]=m.useState(0),Y=m.useRef(null);m.useEffect(()=>{!g&&r&&x(r.agents.find(kd)?.id??"")},[r,g]),m.useEffect(()=>{N(!1)},[y]);const P=Rn(()=>y.trim()?c.gitInfo(y):Promise.resolve(void 0),[d,y]),M=r?.agents.find(Q=>Q.id===g),R=!!M&&kd(M),H=z?.store===d&&z.agent===g?z.model:void 0,I=dz(g,y,l&&R,H,$),q=l&&R&&!!y.trim()&&!v.busy&&!!I&&!I.error,G=pz(I,H),X=I?.models.find(Q=>Q.value===(G??I.current)),K=JSON.stringify([g,y.trim()]),ee=B?.store===d&&B.key===K?B.values:{},Z=fz(I?.config,ee),ne=H&&I&&!I.error&&!I.models.some(Q=>Q.value===H),de=a.find(Q=>Q.cwd===y)?.name??(y.split(/[\\/]/).filter(Boolean).pop()||y||"选择目录"),oe=f.connection?.computer,ae=()=>{q&&v.run(async()=>t(await c.createSession({agent:g,cwd:y.trim(),worktree:_&&!!P.value,model:G,config:hz(I?.config,ee),prompt:k.trim()?[{type:"text",text:k.trim()}]:void 0})))};return s.jsxs("div",{className:"new-session-page",children:[s.jsx(_f,{agent:g}),s.jsxs("div",{className:"new-session-stage",children:[s.jsx("h1",{children:oe?`在 ${Mn(oe,h)} 上开始`:"新建会话"}),s.jsxs("form",{className:"new-session-composer",onSubmit:Q=>{Q.preventDefault(),ae()},children:[s.jsx("textarea",{ref:Y,autoFocus:!0,rows:3,value:k,disabled:v.busy,"aria-label":"任务描述",placeholder:"描述要完成的工作,或者直接开始…",onChange:Q=>C(Q.target.value),onKeyDown:Q=>{Q.key==="Escape"&&(Q.preventDefault(),n()),Q.key==="Enter"&&!Q.shiftKey&&!Q.nativeEvent.isComposing&&(Q.preventDefault(),ae())}}),s.jsxs("div",{className:"new-session-bar flex-wrap",children:[s.jsxs(As,{children:[s.jsx(Ts,{asChild:!0,children:s.jsxs(F,{type:"button",variant:"ghost",size:"sm",className:"new-session-pill",disabled:v.busy,"aria-label":"选择 Agent",children:[M&&s.jsx(Ao,{agent:M.id}),s.jsx("span",{children:M?.label??"选择 Agent"}),s.jsx(jr,{className:"new-session-caret"})]})}),s.jsxs(Ms,{side:"top",align:"start",sideOffset:8,collisionPadding:12,className:"new-session-menu",children:[s.jsx(Di,{children:"Agent"}),s.jsx(Il,{value:g,onValueChange:x,children:(r?.agents??[]).map(Q=>s.jsxs(Ri,{value:Q.id,disabled:!kd(Q),children:[s.jsx(Ao,{agent:Q.id}),s.jsxs("span",{className:"new-session-option",children:[s.jsx("span",{children:Q.label}),!kd(Q)&&s.jsx("small",{children:Q.installed?Q.auth?.state==="missing"?"未登录":Q.tier==="terminal"?"请从终端打开":Q.problem:"未安装"})]})]},Q.id))})]})]}),l&&R&&!I&&s.jsxs("span",{className:"new-session-pill new-session-pill-static",role:"status",children:[s.jsx(vt,{className:"animate-spin"}),s.jsx("span",{children:"正在读取模型与设置…"})]}),I&&!I.models.length&&!I.error&&s.jsxs(F,{type:"button",variant:"ghost",size:"sm",className:"new-session-pill",title:"Agent 尚未提供可预选的模型;点击重新读取",disabled:v.busy,onClick:()=>D(Q=>Q+1),children:[s.jsx(xb,{}),s.jsx("span",{children:"默认模型"})]}),!!I?.models.length&&s.jsxs(As,{children:[s.jsx(Ts,{asChild:!0,children:s.jsxs(F,{type:"button",variant:"ghost",size:"sm",className:"new-session-pill",disabled:v.busy,title:X?`模型:${X.name}`:"模型","aria-label":"选择模型",children:[s.jsx(xb,{}),s.jsx("span",{children:X?Qb(X):"默认模型"}),s.jsx(jr,{className:"new-session-caret"})]})}),s.jsxs(Ms,{side:"top",align:"start",sideOffset:8,collisionPadding:12,className:"new-session-menu",children:[s.jsx(Di,{children:"模型"}),s.jsx(Il,{value:X?.value??"",onValueChange:Q=>L({store:d,agent:g,model:Q}),children:I.models.map(Q=>{const pe=Qb(Q),Me=[Q.value===I.current&&!pe.startsWith("默认")?"默认":void 0,Q.description].filter(Boolean).join(" · ");return s.jsx(Ri,{value:Q.value,children:s.jsxs("span",{className:"new-session-option",children:[s.jsx("span",{children:pe}),Me&&s.jsx("small",{children:Me})]})},Q.value)})})]})]}),s.jsx(PJ,{options:Z,disabled:v.busy,onChange:(Q,pe)=>O({store:d,key:K,values:{...ee,[Q]:pe}})}),s.jsxs(As,{children:[s.jsx(Ts,{asChild:!0,children:s.jsxs(F,{type:"button",variant:"ghost",size:"sm",className:"new-session-pill",disabled:v.busy,title:y,"aria-label":"选择工作目录",children:[s.jsx(vo,{}),s.jsx("span",{children:de}),s.jsx(jr,{className:"new-session-caret"})]})}),s.jsxs(Ms,{side:"top",align:"start",sideOffset:8,collisionPadding:12,className:"new-session-menu",children:[s.jsx(Di,{children:"最近的项目"}),a.slice(0,8).map(Q=>s.jsxs(mt,{onSelect:()=>j(Q.cwd),children:[s.jsxs("span",{className:"new-session-option",children:[s.jsx("span",{children:Q.name}),s.jsx("small",{children:Q.cwd})]}),Q.cwd===y&&s.jsx(Hn,{className:"ml-auto"})]},Q.cwd)),!a.length&&s.jsx("p",{className:"new-session-menu-empty",children:"还没有项目"}),s.jsx(sr,{}),s.jsxs(mt,{disabled:!l,onSelect:()=>T(!0),children:[s.jsx(vo,{}),"浏览电脑上的目录…"]})]})]}),P.value&&s.jsxs(F,{type:"button",variant:"ghost",size:"sm",className:"new-session-pill","data-active":_||void 0,"aria-pressed":_,disabled:v.busy,title:"基于当前 Git 仓库创建独立工作目录",onClick:()=>N(Q=>!Q),children:[s.jsx(Nl,{}),s.jsx("span",{children:_?"独立 worktree":"当前分支"})]}),s.jsx("span",{className:"new-session-spacer"}),s.jsx(F,{type:"submit",size:"icon",className:"send-button",disabled:!q,"aria-label":"开始会话",title:"开始 · Enter(Shift Enter 换行)",children:v.busy?s.jsx(vt,{className:"animate-spin"}):s.jsx(em,{})})]})]}),s.jsx(it,{error:v.error}),ne&&s.jsx("p",{className:"new-session-note",role:"status",children:"此前选择的模型已不可用,将使用 Agent 的默认模型;也可以重新选择。"}),I?.error&&s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(it,{error:`模型与设置加载失败:${I.error}`}),s.jsx(F,{type:"button",variant:"outline",size:"sm",className:"self-start",disabled:v.busy,onClick:()=>D(Q=>Q+1),children:"重新读取模型与设置"})]}),!l&&s.jsx("p",{className:"new-session-note",role:"status",children:"电脑连接恢复后即可开始,已写的内容会保留。"}),l&&r&&!R&&s.jsx("p",{className:"new-session-note",children:"先在「电脑与 Agent」里确认 Agent 已安装并登录。"}),s.jsxs("p",{className:"new-session-hint",children:["Agent 在 ",s.jsx("code",{title:y,children:y||"所选目录"})," 里读写文件、运行命令 · Esc 取消"]})]}),S&&s.jsx(To,{title:"选择工作目录",wide:!0,close:()=>T(!1),children:s.jsx(Ef,{start:y,directoriesOnly:!0,onPick:Q=>{j(Q),T(!1),Y.current?.focus()}})})]})}const Cz="/assets/mark-RyKpi76M.png";function Em({computer:e,iconOnly:t=!1}){const n=qe(Vn.store),[r,a]=m.useState(!1),[l,c]=m.useState(""),[d,f]=m.useState(),[h,v]=m.useState(),[g,x]=m.useState(!1),[y,j]=m.useState(!1),k=m.useRef(void 0),C=m.useId();m.useEffect(()=>{if(!r)return;let N=!1,S;x(!0),j(!1),f(void 0),v(void 0);try{const T=We.retainComputer(e,{metadataOnly:!0});S=T.release,k.current=T.connection,T.connection.link.call("machine.info",{},15e3).then(z=>{N||(v(z),c(z.naming?.configured?z.naming.customName??"":n[e.key]??""),z.naming||f("请先更新这台电脑上的 LinkShell,更新后即可在所有端同步名称。"))}).catch(z=>{N||f(z instanceof Error?z.message:String(z))}).finally(()=>{N||x(!1)})}catch(T){x(!1),f(T instanceof Error?T.message:String(T))}return()=>{N=!0,k.current=void 0,S?.()}},[r,e.key]);async function _(N){const S=k.current;if(!(!S||!h?.naming||y)){j(!0),f(void 0);try{const T=await Vn.rename(e,N,S.link);S.store.setState({machine:T}),k.current===S&&a(!1)}catch(T){k.current===S&&f(T instanceof Error?T.message:String(T))}finally{k.current===S&&j(!1)}}}return s.jsxs(Bo,{open:r,onOpenChange:N=>{y||(a(N),N&&(c(n[e.key]??""),f(void 0)))},children:[s.jsx(cF,{asChild:!0,children:s.jsxs(F,{variant:"ghost",size:t?"icon-sm":"sm",className:t?"size-5 shrink-0":void 0,title:"给电脑命名","aria-label":`给 ${Mn(e,n)} 命名`,children:[s.jsx(XU,{"data-icon":"inline-start"}),!t&&"命名"]})}),s.jsxs(Uo,{children:[s.jsxs(Kl,{children:[s.jsx(Fo,{children:"给电脑命名"}),s.jsx(Yl,{children:"名称保存在这台电脑上,会同步到已连接的手机和电脑端。"})]}),s.jsx("form",{onSubmit:N=>{N.preventDefault(),_(l)},children:s.jsxs(Yn,{children:[s.jsxs(Et,{"data-invalid":!!d,children:[s.jsx(Rt,{htmlFor:C,children:"电脑名称"}),s.jsx(un,{id:C,value:l,disabled:g||y||!h?.naming,maxLength:Cm,placeholder:"例如:办公室 Mac mini",autoComplete:"off","aria-invalid":!!d,"aria-describedby":`${C}-hint${d?` ${C}-error`:""}`,onChange:N=>{c(N.target.value),f(void 0)}}),s.jsxs(as,{id:`${C}-hint`,className:"break-all",children:[g?"正在读取电脑名称…":h?`原名:${h.naming?.defaultName??h.hostname}`:"连接电脑后可读取原名"," · ",Nf(e),"。留空将恢复原名。"]}),d&&s.jsx(Pr,{id:`${C}-error`,children:d})]}),s.jsxs(c6,{children:[(h?.naming?.customName||n[e.key])&&s.jsx(F,{type:"button",variant:"ghost",disabled:g||y||!h?.naming,onClick:()=>void _(""),children:"恢复原名"}),s.jsx(M1,{asChild:!0,children:s.jsx(F,{type:"button",variant:"outline",disabled:y,children:"取消"})}),s.jsx(F,{type:"submit",disabled:g||y||!h?.naming,children:y?"正在同步…":"保存名称"})]})]})})]})]})}function Nm(e){return e instanceof Error?e.message:String(e)}function pee({name:e}){const t=yt(v=>v.unlock),[n,r]=m.useState(""),[a,l]=m.useState(),[c,d]=m.useState(!1),f=m.useId(),h=async()=>{if(!(!n||c)){d(!0),l(void 0);try{await t(n)}catch(v){l(Nm(v)),r("")}finally{d(!1)}}};return s.jsxs("div",{className:"access-unlock",role:"region","aria-labelledby":`${f}-title`,children:[s.jsx("span",{className:"access-unlock-mark","aria-hidden":!0,children:s.jsx(_u,{size:20})}),s.jsxs("h2",{id:`${f}-title`,children:[e," 设置了访问密码"]}),s.jsx("p",{children:"输入访问密码后继续。密码在那台电脑上设置。"}),s.jsxs("form",{className:"access-unlock-form",onSubmit:v=>{v.preventDefault(),h()},children:[s.jsxs(Et,{"data-invalid":a?!0:void 0,children:[s.jsx(Rt,{htmlFor:`${f}-password`,className:"sr-only",children:"访问密码"}),s.jsx(un,{id:`${f}-password`,type:"password",autoComplete:"current-password",autoFocus:!0,placeholder:"访问密码",value:n,"aria-invalid":a?!0:void 0,onChange:v=>r(v.target.value)}),a&&s.jsx(Pr,{children:a})]}),s.jsx(F,{type:"submit",disabled:!n||c,children:c?"正在解锁…":"解锁"})]})]})}function mee({open:e}){const{link:t}=Dt(),n=Rn(()=>t.call("access.status",{}),[t],0);if(n.error&&/unknown method|no handler/.test(Nm(n.error)))return null;const r=n.value?.password??!1;return s.jsxs("div",{className:"access-settings list-row list-row-static",children:[s.jsx("span",{className:"access-settings-mark","data-enabled":r||void 0,"aria-hidden":!0,children:r?s.jsx(_u,{size:16}):s.jsx(lT,{size:16})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"font-medium",children:"访问密码"}),s.jsx("p",{className:"text-xs text-[var(--tertiaryLabel)]",children:n.value?r?"已开启,其他设备打开这台电脑前要先输入密码":"未设置":"正在读取…"})]}),s.jsx(F,{variant:"secondary",size:"sm",onClick:e,children:r?"管理":"设置"})]})}function gee(){const{link:e}=Dt(),t=ar(),n=Rn(()=>e.call("access.status",{}),[e],0),[r,a]=m.useState(!1),[l,c]=m.useState(""),[d,f]=m.useState(""),[h,v]=m.useState(),[g,x]=m.useState(!1),y=m.useId(),j=n.value?.password??!1;if(n.error&&/unknown method|no handler/.test(Nm(n.error)))return null;const k=async _=>{x(!0),v(void 0);try{await e.call("access.set",_?{password:_}:{}),a(!1),c(""),f(""),n.reload()}catch(N){v(Nm(N))}finally{x(!1)}},C=d.length>0&&d!==l;return s.jsxs("div",{className:"access-settings list-row list-row-static",children:[s.jsx("span",{className:"access-settings-mark","data-enabled":j||void 0,"aria-hidden":!0,children:j?s.jsx(_u,{size:16}):s.jsx(lT,{size:16})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"font-medium",children:"访问密码"}),s.jsx("p",{className:"text-xs text-[var(--tertiaryLabel)]",children:j?"已开启。其他设备切换到这台电脑时,要先输入密码;这台电脑本身不受影响。":"未设置。同一账号或已配对的设备可以直接打开这台电脑。"}),r&&s.jsxs("form",{className:"access-settings-form",onSubmit:_=>{_.preventDefault(),l.length>=4&&!C&&k(l)},children:[s.jsxs(Et,{children:[s.jsx(Rt,{htmlFor:`${y}-new`,children:j?"新密码":"密码"}),s.jsx(un,{id:`${y}-new`,type:"password",autoComplete:"new-password",autoFocus:!0,minLength:4,maxLength:128,placeholder:"至少 4 位",value:l,onChange:_=>c(_.target.value)})]}),s.jsxs(Et,{"data-invalid":C||void 0,children:[s.jsx(Rt,{htmlFor:`${y}-confirm`,children:"再输一次"}),s.jsx(un,{id:`${y}-confirm`,type:"password",autoComplete:"new-password",maxLength:128,"aria-invalid":C||void 0,value:d,onChange:_=>f(_.target.value)}),C&&s.jsx(Pr,{children:"两次输入不一致"})]}),h&&s.jsx(Pr,{children:h}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(F,{type:"submit",size:"sm",disabled:g||l.length<4||d!==l,children:"保存"}),s.jsx(F,{type:"button",size:"sm",variant:"ghost",disabled:g,onClick:()=>{a(!1),v(void 0)},children:"取消"})]})]}),!r&&h&&s.jsx(Pr,{children:h})]}),!r&&s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx(F,{variant:"outline",size:"sm",disabled:g||n.loading,onClick:()=>a(!0),children:j?"修改":"设置密码"}),j&&s.jsx(F,{variant:"ghost",size:"sm",disabled:g,onClick:async()=>{await t.confirm("移除访问密码?其他设备将可以直接打开这台电脑。")&&k(void 0)},children:"移除"})]})]})}function vee({locked:e}){return e?s.jsx(_u,{className:"computer-lock-mark",size:12,"aria-label":"已设置访问密码"}):null}function xee({found:e,disabled:t=!1}){const n=m.useRef(null),[r,a]=m.useState(!1),[l,c]=m.useState(!1),[d,f]=m.useState(!1),[h,v]=m.useState(!1),[g,x]=m.useState(!1),[y,j]=m.useState(),k=m.useRef(e),C=m.useRef(t),_=m.useRef(0),N=m.useRef(!1);k.current=e,C.current=t,m.useEffect(()=>()=>{_.current++},[]),m.useEffect(()=>{let z=!0;if(!(!window.matchMedia("(pointer: coarse)").matches||!navigator.mediaDevices?.enumerateDevices))return navigator.mediaDevices.enumerateDevices().then(B=>{z&&c(B.some(O=>O.kind==="videoinput"))},()=>{}),()=>{z=!1}},[]);function S(z){if(!(N.current||C.current)){if(!xm(z)){j("这不是有效的 LinkShell 配对二维码,请扫描电脑上 linkshell pair 生成的二维码。");return}N.current=!0,k.current(z.trim()),a(!1),x(!0),j(void 0)}}const T=m.useRef(S);return T.current=S,m.useEffect(()=>{if(!r||t||!n.current)return;let z=!1,L;return Z0(()=>import("./qr-scanner.min-BrJY21Dj.js"),__vite__mapDeps([4,1,2])).then(async({default:B})=>{z||!n.current||(L=new B(n.current,O=>{z||T.current(O.data)},{preferredCamera:"environment",returnDetailedScanResult:!0,highlightScanRegion:!0}),await L.start(),z||f(!1))}).catch(()=>{z||(j("无法打开摄像头。请检查浏览器的摄像头权限,或选择二维码图片、手动输入配对码。"),a(!1),f(!1))}),()=>{z=!0,L?.destroy()}},[r,t]),s.jsxs("div",{className:"flex min-w-0 flex-col gap-3",children:[s.jsxs("div",{className:"flex flex-wrap gap-2 [&>*]:flex-1",children:[l&&s.jsxs(F,{variant:"outline",type:"button",disabled:t||h,"aria-expanded":r&&!t,onClick:()=>{N.current=!1,x(!1),j(void 0),f(!r),a(!r)},children:[r?s.jsx(zn,{"data-icon":"inline-start"}):s.jsx(SU,{"data-icon":"inline-start"}),r?"关闭摄像头":"扫描二维码"]}),s.jsx(vw,{accept:"image/*",disabled:t||h,"aria-label":"选择包含 LinkShell 配对二维码的图片",onChange:z=>{const L=z.target.files?.[0];if(z.target.value="",!L)return;const B=++_.current;N.current=!1,a(!1),v(!0),x(!1),j(void 0),Z0(()=>import("./qr-scanner.min-BrJY21Dj.js"),__vite__mapDeps([4,1,2])).then(O=>O.default.scanImage(L,{returnDetailedScanResult:!0})).then(O=>{B===_.current&&T.current(O.data)},()=>{B===_.current&&j("没有识别到二维码,请选择清晰的二维码图片,或手动输入配对码。")}).finally(()=>{B===_.current&&v(!1)})},children:h?"正在识别…":"从图片识别"})]}),r&&!t&&s.jsxs("div",{className:"min-w-0 text-center",children:[s.jsx("video",{ref:n,className:"mb-2 block aspect-[4/3] w-full rounded-lg bg-muted object-cover",muted:!0,playsInline:!0,"aria-label":"配对二维码扫描画面"}),s.jsx("p",{className:"text-xs text-muted-foreground",role:"status",children:d?"正在打开摄像头…":"将电脑上的配对二维码放入取景框"})]}),h&&s.jsxs("p",{className:"flex items-center gap-2 text-xs text-muted-foreground [&>svg]:size-4 [&>svg]:shrink-0",role:"status",children:[s.jsx(vt,{className:"animate-spin"}),"正在读取二维码图片…"]}),g&&s.jsxs("p",{className:"flex items-center gap-2 text-xs text-muted-foreground [&>svg]:size-4 [&>svg]:shrink-0",role:"status",children:[s.jsx(ig,{}),"已读取二维码,请确认后连接。"]}),s.jsx(it,{error:y})]})}function vE({userId:e,disabled:t}){const n=m.useId(),[r,a]=m.useState(""),[l,c]=m.useState(),d=Rn(()=>see(e),[e]),f=$t(),h=d.value?.plan==="pro"?d.value:l??d.value;return s.jsxs("section",{className:"flex min-w-0 flex-col gap-4","aria-label":"Pro 会员",children:[s.jsx(mC,{}),d.loading&&!l?s.jsx(js,{loading:!0}):d.error&&!h?s.jsxs(cn,{variant:"destructive",children:[s.jsx(Ws,{children:"暂时无法获取会员状态"}),s.jsxs(rn,{className:"flex flex-col items-start gap-2",children:[s.jsx("p",{children:d.error}),s.jsx(F,{type:"button",variant:"outline",onClick:d.reload,children:"重试"})]})]}):h?.plan==="pro"?s.jsxs(s.Fragment,{children:[s.jsxs(cn,{variant:"success",role:"status",children:[s.jsx(Ws,{children:l?"兑换成功,Pro 已激活":"Pro 会员"}),s.jsx(rn,{children:h.expiresAt?`有效期至 ${new Date(h.expiresAt).toLocaleString("zh-CN",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:"Pro 权益已生效"})]}),d.error&&s.jsxs(cn,{variant:"warning",children:[s.jsx(Ws,{children:"会员信息暂时未能刷新"}),s.jsxs(rn,{className:"flex flex-col items-start gap-2",children:[s.jsx("p",{children:"兑换结果已保存,可稍后重试刷新。"}),s.jsx(F,{type:"button",variant:"outline",onClick:d.reload,children:"刷新会员状态"})]})]})]}):h?s.jsx("form",{"aria-label":"兑换 Pro 激活码","aria-busy":f.busy,onSubmit:v=>{v.preventDefault(),!(t||f.busy||!r.trim())&&f.run(async()=>{const g=await ree(e,r.trim());c({plan:"pro",expiresAt:g.expiresAt}),a(""),d.reload()})},children:s.jsxs(Yn,{children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsx("span",{className:"text-sm font-medium",children:"升级 Pro"}),s.jsx(ui,{variant:"secondary",children:"普通账户"})]}),s.jsxs(Et,{"data-disabled":t||f.busy,"data-invalid":!!f.error,children:[s.jsx(Rt,{htmlFor:`${n}-code`,children:"激活码"}),s.jsx(un,{id:`${n}-code`,value:r,onChange:v=>{a(v.target.value),f.clear()},autoComplete:"off",autoCapitalize:"none",spellCheck:!1,placeholder:"输入 Pro 激活码",disabled:t||f.busy,"aria-invalid":!!f.error,"aria-describedby":f.error?`${n}-error`:`${n}-description`,required:!0}),s.jsx(as,{id:`${n}-description`,children:"兑换后,当前 iTool 账户即可使用 Pro 权益。"}),f.error&&s.jsx(Pr,{id:`${n}-error`,children:f.error})]}),s.jsxs(F,{type:"submit",disabled:t||f.busy||!r.trim(),children:[f.busy&&s.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}),f.busy?"正在兑换…":"兑换并升级 Pro"]}),s.jsxs(as,{children:["没有激活码?"," ",s.jsx("a",{href:D5,target:"_blank",rel:"noopener noreferrer",children:"前往链动小铺 ↗"})]})]})}):null,s.jsx(mC,{})]})}const bee="https://itool.tech/zh/register",yee="https://itool.tech/zh/forgot-password",wee=45e3,_z={github:"GitHub",google:"Google"};function jee(){return s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",fill:"currentColor",children:s.jsx("path",{d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61-.546-1.385-1.335-1.755-1.335-1.755-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23a11.5 11.5 0 0 1 3-.405c1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})})}function kee(){return s.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",fill:"currentColor",children:s.jsx("path",{d:"M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z"})})}function xE({href:e,children:t}){const n=r=>{r.preventDefault(),Rm(e)};return s.jsx("a",{href:e,target:"_blank",rel:"noreferrer",onClick:n,children:t})}function See(e){return e.key==="Enter"&&(e.isComposing===!0||e.keyCode===229)}function bE(e){See({key:e.key,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&e.preventDefault()}function Cee(e,t){const n=e.trim();if(!n)return{field:"email",message:"请输入邮箱。"};if(!/^[^\s@]+@[^\s@]+$/.test(n))return{field:"email",message:"邮箱格式不正确。"};if(!t)return{field:"password",message:"请输入密码。"}}function Ez(e){const{pending:t,link:n,error:r,disabled:a,title:l,description:c,onPassword:d,onProvider:f,onBrowser:h,onCancel:v,onEdit:g}=e,x=m.useId(),[y,j]=m.useState(""),[k,C]=m.useState(""),[_,N]=m.useState(),S=m.useRef(null),T=m.useRef(null),z=t!==void 0&&t!=="password",L=a||t!==void 0,B=_?.message??r,O=()=>{if(L)return;const D=Cee(y,k);if(D?.field==="password"&&!k&&document.activeElement===S.current){N(void 0),T.current?.focus();return}if(N(D),D){(D.field==="email"?S:T).current?.focus();return}d(y.trim(),k)},$=()=>{N(void 0),g?.()};return z?s.jsx(_ee,{method:t,link:n,title:l,onCancel:v}):s.jsxs("div",{className:"signin",children:[(l||c)&&s.jsxs("header",{className:"signin-header",children:[l&&s.jsx("h2",{children:l}),c&&s.jsx("p",{children:c})]}),s.jsx("div",{className:"signin-providers",children:["github","google"].map(D=>s.jsxs("button",{type:"button",className:"signin-button","data-kind":"provider",disabled:L,onClick:()=>f(D),children:[D==="github"?s.jsx(jee,{}):s.jsx(kee,{}),"使用 ",_z[D]," 继续"]},D))}),s.jsx("div",{className:"signin-divider",role:"separator","aria-label":"或使用邮箱",children:s.jsx("span",{children:"或"})}),s.jsxs("form",{className:"signin-form",noValidate:!0,"aria-busy":t==="password",onSubmit:D=>{D.preventDefault(),O()},children:[s.jsxs("div",{className:"signin-field",children:[s.jsx("label",{className:"signin-field-label",htmlFor:`${x}-email`,children:"邮箱"}),s.jsx("input",{ref:S,autoFocus:!0,id:`${x}-email`,className:"signin-input",type:"email",name:"username",autoComplete:"username",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,inputMode:"email",placeholder:"你的 iTool 账号邮箱",value:y,disabled:L,"aria-invalid":_?.field==="email","aria-describedby":B?`${x}-error`:void 0,onKeyDown:bE,onChange:D=>{j(D.target.value),$()}})]}),s.jsxs("div",{className:"signin-field",children:[s.jsxs("div",{className:"signin-field-label",children:[s.jsx("label",{htmlFor:`${x}-password`,children:"密码"}),s.jsx(xE,{href:yee,children:"忘记密码?"})]}),s.jsx("input",{ref:T,id:`${x}-password`,className:"signin-input",type:"password",name:"password",autoComplete:"current-password",value:k,disabled:L,"aria-invalid":_?.field==="password","aria-describedby":B?`${x}-error`:void 0,onKeyDown:bE,onChange:D=>{C(D.target.value),$()}})]}),B&&s.jsx("p",{id:`${x}-error`,className:"signin-error",role:"alert",children:B}),s.jsxs("button",{type:"submit",className:"signin-button","data-kind":"primary",disabled:L,children:[t==="password"&&s.jsx(vt,{className:"signin-spinner","aria-hidden":!0}),t==="password"?"正在登录…":"登录"]})]}),s.jsxs("footer",{className:"signin-footer",children:[s.jsxs("p",{children:["没有账号?",s.jsx(xE,{href:bee,children:"注册 iTool 账号"})]}),s.jsxs("p",{children:["已在浏览器登录 iTool?",s.jsx("button",{type:"button",className:"signin-link",disabled:L,onClick:h,children:"在浏览器中授权"})]})]})]})}function _ee({method:e,link:t,title:n,onCancel:r}){const[a,l]=m.useState(!1),[c,d]=m.useState("idle");m.useEffect(()=>{const v=setTimeout(()=>l(!0),wee);return()=>clearTimeout(v)},[]),m.useEffect(()=>{if(c!=="copied")return;const v=setTimeout(()=>d("idle"),2e3);return()=>clearTimeout(v)},[c]);const f=e==="web"?void 0:_z[e],h=()=>{t&&navigator.clipboard.writeText(t).then(()=>d("copied"),()=>d("failed"))};return s.jsxs("div",{className:"signin","data-state":"waiting",children:[n&&s.jsx("header",{className:"signin-header",children:s.jsx("h2",{children:n})}),s.jsxs("div",{className:"signin-waiting",role:"status","aria-live":"polite",children:[s.jsx(vt,{className:"signin-spinner","data-size":"large","aria-hidden":!0}),s.jsx("h3",{children:f?`请在浏览器中完成 ${f} 登录`:"请在浏览器中完成授权"}),s.jsx("p",{children:f?"完成后会自动回到 LinkShell。":"在 iTool 页面确认后,会自动回到 LinkShell。"}),a&&s.jsx("p",{className:"signin-hint",children:"还没有收到浏览器的结果。如果浏览器停在了错误页,请取消后重试,或改用邮箱和密码登录。等待 5 分钟后会自动取消。"})]}),f&&s.jsxs("div",{className:"signin-actions",children:[s.jsx("button",{type:"button",className:"signin-button","data-kind":"provider",disabled:!t,onClick:()=>t&&Rm(t),children:"重新打开浏览器"}),s.jsx("button",{type:"button",className:"signin-button","data-kind":"provider",disabled:!t,onClick:h,children:c==="copied"?"已复制":"复制链接"})]}),c==="failed"&&t&&s.jsxs("p",{className:"signin-hint",children:["无法写入剪贴板,请手动复制:",s.jsx("span",{className:"signin-link-text",children:t})]}),s.jsx("button",{type:"button",className:"signin-button","data-kind":"quiet",onClick:r,children:"取消"})]})}const Eee=400;function Nee(e){return e instanceof DOMException&&e.name==="TimeoutError"?"等待登录超时,请重试。":e instanceof TypeError?"桌面服务暂时不可用,请重试。":Ps(e)}function Aee(e){const[t,n]=m.useState(),[r,a]=m.useState(),[l,c]=m.useState(),d=m.useRef(!1),f=m.useRef(!1),h=m.useRef(!0);m.useEffect(()=>(h.current=!0,()=>{h.current=!1,d.current&&(f.current=!0,yS().catch(()=>{}))}),[]);const v=async g=>{if(d.current)return;d.current=!0,f.current=!1,n(g.method),a(void 0),c(void 0);let x=g.method==="github"||g.method==="google";x&&(async()=>{for(;x;){if(await new Promise(j=>setTimeout(j,Eee)),!x)return;try{const j=await w8();if(x&&j?.method===g.method&&j.url){a(j.url);return}}catch{}}})();try{await y8(g),h.current&&await e()}catch(j){!f.current&&h.current&&c(Nee(j))}finally{x=!1,d.current=!1,h.current&&(n(void 0),a(void 0))}};return{pending:t,link:r,error:l,onPassword:(g,x)=>void v({method:"password",email:g,password:x}),onProvider:g=>void v({method:g}),onBrowser:()=>void v({method:"web"}),onCancel:()=>{f.current=!0,yS().catch(()=>{})},onEdit:()=>c(void 0)}}function Tee({close:e}){const t=qe(We.state),n=m.useId(),[r,a]=m.useState(t.source),[l,c]=m.useState(""),[d,f]=m.useState(""),[h,v]=m.useState(r==="self-hosted"?t.gateway:""),[g,x]=m.useState(""),[y,j]=m.useState({}),k=$t(),C=m.useRef(null),[_,N]=m.useState();m.useEffect(()=>()=>C.current?.abort(),[]);const S=k.busy||t.locked,T=Aee(async()=>{await We.connectAccount(),e()}),z=xm(g);function L($){x($);const D=xm($);D&&v(D.gateway.replace(/^http/,"ws")),j({}),k.clear()}const B=me?t.accountUserId?s.jsxs(Yn,{children:[s.jsxs(cn,{role:"status",children:[s.jsx(Ws,{children:t.account??"已登录"}),s.jsx(rn,{children:"已使用 LinkShell 的同一账号。其他电脑登录此账号后,会自动显示在工作台。"})]}),s.jsx(vE,{userId:t.accountUserId,disabled:k.busy},t.accountUserId),s.jsx(F,{disabled:S,onClick:()=>void k.run(async()=>{await We.connectAccount(),e()}),children:"刷新账号电脑"}),s.jsx(F,{variant:"outline",disabled:k.busy,onClick:()=>void k.run(j8),children:"退出 LinkShell 账号"}),s.jsx("p",{className:"field-hint",children:"账号与这台电脑的 LinkShell 服务共用。退出后,本机工作台和已配对的电脑仍可使用。"})]}):s.jsx(Ez,{...T,disabled:S,description:"登录 iTool 账号,即可访问同一账号下的电脑。电脑接入官方网关需要 Pro 订阅。"}):t.account?s.jsxs(Yn,{className:"min-w-0 [&_[data-slot=alert-description]]:break-words [&_[data-slot=alert-title]]:break-words [&_[data-slot=field]]:min-w-0",children:[s.jsxs(cn,{role:"status",children:[s.jsx(Ws,{className:"break-words",children:t.account}),s.jsxs(rn,{children:["在电脑运行 ",s.jsx("code",{children:"linkshell login"}),",使用同一账号即可发现电脑。电脑接入官方网关需要 Pro 订阅。"]})]}),t.accountUserId&&s.jsx(vE,{userId:t.accountUserId,disabled:k.busy},t.accountUserId),s.jsxs(F,{type:"button",disabled:S,onClick:()=>void k.run(async()=>{await We.connectAccount(),e()}),children:[k.busy&&s.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}),"刷新账号电脑"]}),s.jsx(F,{variant:"outline",type:"button",disabled:k.busy,onClick:()=>void k.run(async()=>{const $=await tu().auth.signOut({scope:"local"});if($.error)throw $.error;We.disconnect()}),children:"退出本浏览器账号"})]}):s.jsx("form",{className:"min-w-0 [&_[data-slot=alert-description]]:break-words [&_[data-slot=alert-title]]:break-words [&_[data-slot=field]]:min-w-0","aria-busy":k.busy,onSubmit:$=>{$.preventDefault(),!S&&k.run(async()=>{const D=await tu().auth.signInWithPassword({email:l.trim(),password:d});if(D.error)throw D.error;await We.connectAccount(),e()})},children:s.jsxs(Yn,{children:[s.jsxs(Et,{"data-disabled":S,children:[s.jsx(Rt,{htmlFor:`${n}-email`,children:"邮箱"}),s.jsx(un,{id:`${n}-email`,type:"email",autoComplete:"username",autoCapitalize:"none",spellCheck:!1,placeholder:"你的 iTool 账号邮箱",value:l,disabled:S,onChange:$=>{c($.target.value),k.clear()},required:!0})]}),s.jsxs(Et,{"data-disabled":S,children:[s.jsx(Rt,{htmlFor:`${n}-password`,children:"密码"}),s.jsx(un,{id:`${n}-password`,type:"password",autoComplete:"current-password",value:d,disabled:S,onChange:$=>{f($.target.value),k.clear()},required:!0})]}),s.jsxs(F,{disabled:S,children:[k.busy&&s.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}),k.busy?"正在连接…":"登录并连接"]}),s.jsx("div",{className:"grid grid-cols-1 gap-2 min-[381px]:grid-cols-2",children:["github","google"].map($=>s.jsx(F,{variant:"outline",type:"button",disabled:S,onClick:()=>void k.run(async()=>{const D=new AbortController;C.current=D,N("waiting");try{if(await k8(tu().auth,$,{signal:D.signal,onExchanging:()=>N("exchanging")}),D.signal.aborted||(await We.connectAccount(),D.signal.aborted))return;e()}finally{C.current=null,N(void 0)}}),children:$==="github"?"GitHub 登录":"Google 登录"},$))}),_&&s.jsxs("div",{className:"flex items-center justify-between gap-3",role:"status",children:[s.jsx("p",{className:"field-hint",children:_==="waiting"?"请在登录窗口中完成授权。":"正在完成登录…"}),s.jsx(F,{type:"button",variant:"ghost",size:"sm",disabled:_==="exchanging",onClick:()=>C.current?.abort(),children:"取消登录"})]}),s.jsxs("p",{className:"field-hint flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1",children:["登录状态会自动续期。",s.jsx("a",{href:"https://itool.tech/zh/register",target:"_blank",rel:"noreferrer",children:"注册 iTool 账号 ↗"})]})]})}),O=s.jsx("form",{className:"min-w-0 [&_[data-slot=alert-description]]:break-words [&_[data-slot=alert-title]]:break-words [&_[data-slot=field]]:min-w-0","aria-busy":k.busy,onSubmit:$=>{if($.preventDefault(),S)return;const D=g.trim();if(!z&&!/^\d{6}$/.test(D)){j({pairing:D.startsWith("linkshell:")?"配对链接不完整,请重新复制。":"请输入 6 位数字配对码,或完整的配对链接。"}),document.getElementById(`${n}-pairing`)?.focus();return}try{Bp((z?.gateway??h).replace(/^http/,"ws"))}catch(Y){j({gateway:Y instanceof Error?Y.message:"请检查网关地址"}),document.getElementById(`${n}-gateway`)?.focus();return}j({}),k.run(async()=>{await We.pair(h,D),e()})},children:s.jsxs(Yn,{children:[s.jsxs(cn,{role:"note",children:[s.jsx(Ws,{children:"先在电脑上生成配对码"}),s.jsxs(rn,{children:["运行 ",s.jsx("code",{children:"linkshell pair"}),",扫描二维码,或输入电脑上显示的配对码。配对码在 10 分钟内有效。"]})]}),s.jsx(xee,{found:L,disabled:S}),s.jsxs(Et,{"data-invalid":!!y.pairing,"data-disabled":S,children:[s.jsx(Rt,{htmlFor:`${n}-pairing`,children:"配对码或配对链接"}),s.jsx(un,{id:`${n}-pairing`,value:g,disabled:S,autoComplete:"off",autoCapitalize:"none",spellCheck:!1,"aria-invalid":!!y.pairing,"aria-describedby":`${n}-pairing-hint${y.pairing?` ${n}-pairing-error`:""}`,onChange:$=>L($.target.value),placeholder:"6 位配对码,或 linkshell://pair 链接",required:!0}),s.jsx(as,{id:`${n}-pairing-hint`,children:z?"已读取配对链接,网关地址已自动填写。":me?"配对成功后,LinkShell 会记住你的电脑。":"配对成功后,此浏览器会记住你的电脑。"}),y.pairing&&s.jsx(Pr,{id:`${n}-pairing-error`,children:y.pairing})]}),s.jsxs(Et,{"data-invalid":!!y.gateway,"data-disabled":S||!!z,children:[s.jsx(Rt,{htmlFor:`${n}-gateway`,children:"网关地址"}),s.jsx(un,{id:`${n}-gateway`,type:"url",placeholder:"wss://gateway.example.com",value:h,autoComplete:"url",autoCapitalize:"none",spellCheck:!1,disabled:S,readOnly:!!z,"aria-invalid":!!y.gateway,"aria-describedby":`${n}-gateway-hint${y.gateway?` ${n}-gateway-error`:""}`,onChange:$=>{v($.target.value),j({}),k.clear()},required:!z}),s.jsx(as,{id:`${n}-gateway-hint`,children:z?"使用配对链接中指定的网关。更换网关时,请重新生成配对码。":"填写电脑当前连接的网关地址。"}),y.gateway&&s.jsx(Pr,{id:`${n}-gateway-error`,children:y.gateway})]}),s.jsxs(F,{disabled:S,children:[k.busy&&s.jsx(vt,{"data-icon":"inline-start",className:"animate-spin"}),k.busy?"正在配对…":"配对并连接"]}),s.jsxs("p",{className:"field-hint",children:[me?"配对保存在这台电脑的 LinkShell 中。":"清除网站数据后需要重新配对。","自托管连接不会使用 iTool 登录凭证。"]})]})});return s.jsxs(To,{title:"连接你的电脑",close:e,children:[s.jsx("p",{className:"muted modal-subtitle",children:me?"从这台电脑继续对话、审批和控制远程电脑。":"电脑保持运行,网页即可继续你的会话。"}),me&&s.jsxs(cn,{className:"mb-4",children:[s.jsx(Ws,{children:"本机工作台无需登录"}),s.jsxs(rn,{children:[s.jsx("p",{children:t.localError??"本机服务已连接,可以直接管理这台电脑的会话。"}),s.jsxs("div",{className:"mt-2 flex gap-2",children:[s.jsx(F,{type:"button",variant:"outline",size:"sm",onClick:Sy,children:"本机服务"}),t.localError&&s.jsx(F,{type:"button",variant:"ghost",size:"sm",disabled:k.busy,onClick:()=>void k.run(()=>We.refreshLocal()),children:"重新检测"})]})]})]}),t.locked&&s.jsxs(cn,{children:[s.jsx(Ws,{children:"连接正在另一个标签页中使用"}),s.jsxs(rn,{children:[s.jsx("p",{children:"切换到此页后,另一个标签页会断开连接。"}),s.jsx(F,{type:"button",variant:"outline",size:"sm",disabled:k.busy,onClick:()=>void k.run(()=>We.claim()),children:"在此页继续"})]})]}),pa==="official"?s.jsxs(Ti,{value:r,onValueChange:$=>{a($),k.clear(),j({})},children:[s.jsxs(Mi,{className:"w-full","aria-label":"连接方式",children:[s.jsxs(Pn,{value:"official",disabled:k.busy,children:[s.jsx(tn,{name:"globe"}),"官方账号"]}),s.jsxs(Pn,{value:"self-hosted",disabled:k.busy,children:[s.jsx(tn,{name:"server"}),"配对电脑"]})]}),s.jsx(Yb,{value:"official",className:"pt-4",children:B}),s.jsx(Yb,{value:"self-hosted",className:"pt-4",children:O})]}):O,s.jsx(it,{error:k.error})]})}function Nz({...e}){return s.jsx($y,{"data-slot":"sheet",...e})}function Mee({...e}){return s.jsx(Ly,{"data-slot":"sheet-portal",...e})}function zee({className:e,...t}){return s.jsx(Py,{"data-slot":"sheet-overlay",className:je("fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0",e),...t})}function Az({className:e,children:t,side:n="right",showCloseButton:r=!0,...a}){return s.jsxs(Mee,{children:[s.jsx(zee,{}),s.jsxs(By,{"data-slot":"sheet-content","data-side":n,className:je("fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[side=bottom]:data-[state=open]:slide-in-from-bottom-10 data-[side=left]:data-[state=open]:slide-in-from-left-10 data-[side=right]:data-[state=open]:slide-in-from-right-10 data-[side=top]:data-[state=open]:slide-in-from-top-10 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[side=bottom]:data-[state=closed]:slide-out-to-bottom-10 data-[side=left]:data-[state=closed]:slide-out-to-left-10 data-[side=right]:data-[state=closed]:slide-out-to-right-10 data-[side=top]:data-[state=closed]:slide-out-to-top-10",e),...a,children:[t,r&&s.jsx(wu,{"data-slot":"sheet-close",asChild:!0,children:s.jsxs(F,{variant:"ghost",className:"absolute top-3 right-3",size:"icon-sm",children:[s.jsx(zn,{}),s.jsx("span",{className:"sr-only",children:"Close"})]})})]})]})}function Tz({className:e,...t}){return s.jsx("div",{"data-slot":"sheet-header",className:je("flex flex-col gap-0.5 p-4",e),...t})}function Mz({className:e,...t}){return s.jsx(Uy,{"data-slot":"sheet-title",className:je("text-base font-medium text-foreground",e),...t})}function Ree({className:e,...t}){return s.jsx(Fy,{"data-slot":"sheet-description",className:je("text-sm text-muted-foreground",e),...t})}const Dee=768;function zz(e=Dee){const[t,n]=m.useState(void 0);return m.useEffect(()=>{const r=window.matchMedia(`(max-width: ${e-1}px)`),a=()=>{n(window.innerWidth<e)};return r.addEventListener("change",a),n(window.innerWidth<e),()=>r.removeEventListener("change",a)},[e]),!!t}function Oee(e){if(!e)return;const t=e.parentElement;if(!t)return;t.style.setProperty("--composer-height",`${Math.round(e.offsetHeight)}px`);const n=new ResizeObserver(([r])=>{const a=r?.borderBoxSize?.[0]?.blockSize??e.offsetHeight;t.style.setProperty("--composer-height",`${Math.round(a)}px`)});return n.observe(e),()=>{n.disconnect(),t.style.removeProperty("--composer-height")}}function Af({...e}){return s.jsx(cP,{"data-slot":"popover",...e})}function Sg({...e}){return s.jsx(hP,{"data-slot":"popover-trigger",...e})}function Tf({className:e,align:t="center",sideOffset:n=4,container:r,...a}){return s.jsx(gP,{container:r,children:s.jsx(vP,{"data-slot":"popover-content",align:t,sideOffset:n,className:je("z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",e),...a})})}function Iee({...e}){return s.jsx(dP,{"data-slot":"popover-anchor",...e})}function $ee({className:e,...t}){return s.jsx("div",{"data-slot":"popover-header",className:je("flex flex-col gap-0.5 text-sm",e),...t})}function Lee({className:e,...t}){return s.jsx("div",{"data-slot":"popover-title",className:je("font-medium",e),...t})}function Pee({className:e,...t}){return s.jsx("p",{"data-slot":"popover-description",className:je("text-muted-foreground",e),...t})}var yE=1,Bee=.9,Uee=.8,Fee=.17,C0=.1,_0=.999,qee=.9999,Hee=.99,Vee=/[\\\/_+.#"@\[\(\{&]/,Gee=/[\\\/_+.#"@\[\(\{&]/g,Zee=/[\s-]/,Rz=/[\s-]/g;function ty(e,t,n,r,a,l,c){if(l===t.length)return a===e.length?yE:Hee;var d=`${a},${l}`;if(c[d]!==void 0)return c[d];for(var f=r.charAt(l),h=n.indexOf(f,a),v=0,g,x,y,j;h>=0;)g=ty(e,t,n,r,h+1,l+1,c),g>v&&(h===a?g*=yE:Vee.test(e.charAt(h-1))?(g*=Uee,y=e.slice(a,h-1).match(Gee),y&&a>0&&(g*=Math.pow(_0,y.length))):Zee.test(e.charAt(h-1))?(g*=Bee,j=e.slice(a,h-1).match(Rz),j&&a>0&&(g*=Math.pow(_0,j.length))):(g*=Fee,a>0&&(g*=Math.pow(_0,h-a))),e.charAt(h)!==t.charAt(l)&&(g*=qee)),(g<C0&&n.charAt(h-1)===r.charAt(l+1)||r.charAt(l+1)===r.charAt(l)&&n.charAt(h-1)!==r.charAt(l))&&(x=ty(e,t,n,r,h+1,l+2,c),x*C0>g&&(g=x*C0)),g>v&&(v=g),h=n.indexOf(f,h+1);return c[d]=v,v}function wE(e){return e.toLowerCase().replace(Rz," ")}function Kee(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,ty(e,t,wE(e),wE(t),0,0,{})}function wo(e,t,{checkForDefaultPrevented:n=!0}={}){return function(a){if(e?.(a),n===!1||!a.defaultPrevented)return t?.(a)}}function jE(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function $l(...e){return t=>{let n=!1;const r=e.map(a=>{const l=jE(a,t);return!n&&typeof l=="function"&&(n=!0),l});if(n)return()=>{for(let a=0;a<r.length;a++){const l=r[a];typeof l=="function"?l():jE(e[a],null)}}}}function Wl(...e){return m.useCallback($l(...e),e)}function Yee(e,t){const n=m.createContext(t),r=l=>{const{children:c,...d}=l,f=m.useMemo(()=>d,Object.values(d));return s.jsx(n.Provider,{value:f,children:c})};r.displayName=e+"Provider";function a(l){const c=m.useContext(n);if(c)return c;if(t!==void 0)return t;throw new Error(`\`${l}\` must be used within \`${e}\``)}return[r,a]}function Wee(e,t=[]){let n=[];function r(l,c){const d=m.createContext(c),f=n.length;n=[...n,c];const h=g=>{const{scope:x,children:y,...j}=g,k=x?.[e]?.[f]||d,C=m.useMemo(()=>j,Object.values(j));return s.jsx(k.Provider,{value:C,children:y})};h.displayName=l+"Provider";function v(g,x){const y=x?.[e]?.[f]||d,j=m.useContext(y);if(j)return j;if(c!==void 0)return c;throw new Error(`\`${g}\` must be used within \`${l}\``)}return[h,v]}const a=()=>{const l=n.map(c=>m.createContext(c));return function(d){const f=d?.[e]||l;return m.useMemo(()=>({[`__scope${e}`]:{...d,[e]:f}}),[d,f])}};return a.scopeName=e,[r,Xee(a,...t)]}function Xee(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(l){const c=r.reduce((d,{useScope:f,scopeName:h})=>{const g=f(l)[`__scope${h}`];return{...d,...g}},{});return m.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}var af=globalThis?.document?m.useLayoutEffect:()=>{},Qee=Ro[" useId ".trim().toString()]||(()=>{}),Jee=0;function ga(e){const[t,n]=m.useState(Qee());return af(()=>{n(r=>r??String(Jee++))},[e]),t?`radix-${t}`:""}var ete=Ro[" useInsertionEffect ".trim().toString()]||af;function tte({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[a,l,c]=nte({defaultProp:t,onChange:n}),d=e!==void 0,f=d?e:a;{const v=m.useRef(e!==void 0);m.useEffect(()=>{const g=v.current;g!==d&&console.warn(`${r} is changing from ${g?"controlled":"uncontrolled"} to ${d?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),v.current=d},[d,r])}const h=m.useCallback(v=>{if(d){const g=ste(v)?v(e):v;g!==e&&c.current?.(g)}else l(v)},[d,e,l,c]);return[f,h]}function nte({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),a=m.useRef(n),l=m.useRef(t);return ete(()=>{l.current=t},[t]),m.useEffect(()=>{a.current!==n&&(l.current?.(n),a.current=n)},[n,a]),[n,r,l]}function ste(e){return typeof e=="function"}function Dz(e){const t=rte(e),n=m.forwardRef((r,a)=>{const{children:l,...c}=r,d=m.Children.toArray(l),f=d.find(ate);if(f){const h=f.props.children,v=d.map(g=>g===f?m.Children.count(h)>1?m.Children.only(null):m.isValidElement(h)?h.props.children:null:g);return s.jsx(t,{...c,ref:a,children:m.isValidElement(h)?m.cloneElement(h,void 0,v):null})}return s.jsx(t,{...c,ref:a,children:l})});return n.displayName=`${e}.Slot`,n}function rte(e){const t=m.forwardRef((n,r)=>{const{children:a,...l}=n;if(m.isValidElement(a)){const c=lte(a),d=ote(l,a.props);return a.type!==m.Fragment&&(d.ref=r?$l(r,c):c),m.cloneElement(a,d)}return m.Children.count(a)>1?m.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ite=Symbol("radix.slottable");function ate(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ite}function ote(e,t){const n={...t};for(const r in t){const a=e[r],l=t[r];/^on[A-Z]/.test(r)?a&&l?n[r]=(...d)=>{const f=l(...d);return a(...d),f}:a&&(n[r]=a):r==="style"?n[r]={...a,...l}:r==="className"&&(n[r]=[a,l].filter(Boolean).join(" "))}return{...e,...n}}function lte(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var cte=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ss=cte.reduce((e,t)=>{const n=Dz(`Primitive.${t}`),r=m.forwardRef((a,l)=>{const{asChild:c,...d}=a,f=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(f,{...d,ref:l})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function ute(e,t){e&&Oo.flushSync(()=>e.dispatchEvent(t))}function of(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>t.current?.(...n),[])}function dte(e,t=globalThis?.document){const n=of(e);m.useEffect(()=>{const r=a=>{a.key==="Escape"&&n(a)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var fte="DismissableLayer",ny="dismissableLayer.update",hte="dismissableLayer.pointerDownOutside",pte="dismissableLayer.focusOutside",kE,Oz=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Iz=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:l,onInteractOutside:c,onDismiss:d,...f}=e,h=m.useContext(Oz),[v,g]=m.useState(null),x=v?.ownerDocument??globalThis?.document,[,y]=m.useState({}),j=Wl(t,B=>g(B)),k=Array.from(h.layers),[C]=[...h.layersWithOutsidePointerEventsDisabled].slice(-1),_=k.indexOf(C),N=v?k.indexOf(v):-1,S=h.layersWithOutsidePointerEventsDisabled.size>0,T=N>=_,z=vte(B=>{const O=B.target,$=[...h.branches].some(D=>D.contains(O));!T||$||(a?.(B),c?.(B),B.defaultPrevented||d?.())},x),L=xte(B=>{const O=B.target;[...h.branches].some(D=>D.contains(O))||(l?.(B),c?.(B),B.defaultPrevented||d?.())},x);return dte(B=>{N===h.layers.size-1&&(r?.(B),!B.defaultPrevented&&d&&(B.preventDefault(),d()))},x),m.useEffect(()=>{if(v)return n&&(h.layersWithOutsidePointerEventsDisabled.size===0&&(kE=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(v)),h.layers.add(v),SE(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=kE)}},[v,x,n,h]),m.useEffect(()=>()=>{v&&(h.layers.delete(v),h.layersWithOutsidePointerEventsDisabled.delete(v),SE())},[v,h]),m.useEffect(()=>{const B=()=>y({});return document.addEventListener(ny,B),()=>document.removeEventListener(ny,B)},[]),s.jsx(Ss.div,{...f,ref:j,style:{pointerEvents:S?T?"auto":"none":void 0,...e.style},onFocusCapture:wo(e.onFocusCapture,L.onFocusCapture),onBlurCapture:wo(e.onBlurCapture,L.onBlurCapture),onPointerDownCapture:wo(e.onPointerDownCapture,z.onPointerDownCapture)})});Iz.displayName=fte;var mte="DismissableLayerBranch",gte=m.forwardRef((e,t)=>{const n=m.useContext(Oz),r=m.useRef(null),a=Wl(t,r);return m.useEffect(()=>{const l=r.current;if(l)return n.branches.add(l),()=>{n.branches.delete(l)}},[n.branches]),s.jsx(Ss.div,{...e,ref:a})});gte.displayName=mte;function vte(e,t=globalThis?.document){const n=of(e),r=m.useRef(!1),a=m.useRef(()=>{});return m.useEffect(()=>{const l=d=>{if(d.target&&!r.current){let f=function(){$z(hte,n,h,{discrete:!0})};const h={originalEvent:d};d.pointerType==="touch"?(t.removeEventListener("click",a.current),a.current=f,t.addEventListener("click",a.current,{once:!0})):f()}else t.removeEventListener("click",a.current);r.current=!1},c=window.setTimeout(()=>{t.addEventListener("pointerdown",l)},0);return()=>{window.clearTimeout(c),t.removeEventListener("pointerdown",l),t.removeEventListener("click",a.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function xte(e,t=globalThis?.document){const n=of(e),r=m.useRef(!1);return m.useEffect(()=>{const a=l=>{l.target&&!r.current&&$z(pte,n,{originalEvent:l},{discrete:!1})};return t.addEventListener("focusin",a),()=>t.removeEventListener("focusin",a)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function SE(){const e=new CustomEvent(ny);document.dispatchEvent(e)}function $z(e,t,n,{discrete:r}){const a=n.originalEvent.target,l=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&a.addEventListener(e,t,{once:!0}),r?ute(a,l):a.dispatchEvent(l)}var E0="focusScope.autoFocusOnMount",N0="focusScope.autoFocusOnUnmount",CE={bubbles:!1,cancelable:!0},bte="FocusScope",Lz=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:l,...c}=e,[d,f]=m.useState(null),h=of(a),v=of(l),g=m.useRef(null),x=Wl(t,k=>f(k)),y=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(r){let k=function(S){if(y.paused||!d)return;const T=S.target;d.contains(T)?g.current=T:co(g.current,{select:!0})},C=function(S){if(y.paused||!d)return;const T=S.relatedTarget;T!==null&&(d.contains(T)||co(g.current,{select:!0}))},_=function(S){if(document.activeElement===document.body)for(const z of S)z.removedNodes.length>0&&co(d)};document.addEventListener("focusin",k),document.addEventListener("focusout",C);const N=new MutationObserver(_);return d&&N.observe(d,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",k),document.removeEventListener("focusout",C),N.disconnect()}}},[r,d,y.paused]),m.useEffect(()=>{if(d){EE.add(y);const k=document.activeElement;if(!d.contains(k)){const _=new CustomEvent(E0,CE);d.addEventListener(E0,h),d.dispatchEvent(_),_.defaultPrevented||(yte(Cte(Pz(d)),{select:!0}),document.activeElement===k&&co(d))}return()=>{d.removeEventListener(E0,h),setTimeout(()=>{const _=new CustomEvent(N0,CE);d.addEventListener(N0,v),d.dispatchEvent(_),_.defaultPrevented||co(k??document.body,{select:!0}),d.removeEventListener(N0,v),EE.remove(y)},0)}}},[d,h,v,y]);const j=m.useCallback(k=>{if(!n&&!r||y.paused)return;const C=k.key==="Tab"&&!k.altKey&&!k.ctrlKey&&!k.metaKey,_=document.activeElement;if(C&&_){const N=k.currentTarget,[S,T]=wte(N);S&&T?!k.shiftKey&&_===T?(k.preventDefault(),n&&co(S,{select:!0})):k.shiftKey&&_===S&&(k.preventDefault(),n&&co(T,{select:!0})):_===N&&k.preventDefault()}},[n,r,y.paused]);return s.jsx(Ss.div,{tabIndex:-1,...c,ref:x,onKeyDown:j})});Lz.displayName=bte;function yte(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(co(r,{select:t}),document.activeElement!==n)return}function wte(e){const t=Pz(e),n=_E(t,e),r=_E(t.reverse(),e);return[n,r]}function Pz(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const a=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||a?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function _E(e,t){for(const n of e)if(!jte(n,{upTo:t}))return n}function jte(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function kte(e){return e instanceof HTMLInputElement&&"select"in e}function co(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&kte(e)&&t&&e.select()}}var EE=Ste();function Ste(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=NE(e,t),e.unshift(t)},remove(t){e=NE(e,t),e[0]?.resume()}}}function NE(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Cte(e){return e.filter(t=>t.tagName!=="A")}var _te="Portal",Bz=m.forwardRef((e,t)=>{const{container:n,...r}=e,[a,l]=m.useState(!1);af(()=>l(!0),[]);const c=n||a&&globalThis?.document?.body;return c?jI.createPortal(s.jsx(Ss.div,{...r,ref:t}),c):null});Bz.displayName=_te;function Ete(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Cg=e=>{const{present:t,children:n}=e,r=Nte(t),a=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),l=Wl(r.ref,Ate(a));return typeof n=="function"||r.isPresent?m.cloneElement(a,{ref:l}):null};Cg.displayName="Presence";function Nte(e){const[t,n]=m.useState(),r=m.useRef(null),a=m.useRef(e),l=m.useRef("none"),c=e?"mounted":"unmounted",[d,f]=Ete(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const h=bp(r.current);l.current=d==="mounted"?h:"none"},[d]),af(()=>{const h=r.current,v=a.current;if(v!==e){const x=l.current,y=bp(h);e?f("MOUNT"):y==="none"||h?.display==="none"?f("UNMOUNT"):f(v&&x!==y?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,f]),af(()=>{if(t){let h;const v=t.ownerDocument.defaultView??window,g=y=>{const k=bp(r.current).includes(CSS.escape(y.animationName));if(y.target===t&&k&&(f("ANIMATION_END"),!a.current)){const C=t.style.animationFillMode;t.style.animationFillMode="forwards",h=v.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=C)})}},x=y=>{y.target===t&&(l.current=bp(r.current))};return t.addEventListener("animationstart",x),t.addEventListener("animationcancel",g),t.addEventListener("animationend",g),()=>{v.clearTimeout(h),t.removeEventListener("animationstart",x),t.removeEventListener("animationcancel",g),t.removeEventListener("animationend",g)}}else f("ANIMATION_END")},[t,f]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:m.useCallback(h=>{r.current=h?getComputedStyle(h):null,n(h)},[])}}function bp(e){return e?.animationName||"none"}function Ate(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var A0=0;function Tte(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??AE()),document.body.insertAdjacentElement("beforeend",e[1]??AE()),A0++,()=>{A0===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),A0--}},[])}function AE(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var _g="Dialog",[Uz]=Wee(_g),[Mte,hi]=Uz(_g),Fz=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:a,onOpenChange:l,modal:c=!0}=e,d=m.useRef(null),f=m.useRef(null),[h,v]=tte({prop:r,defaultProp:a??!1,onChange:l,caller:_g});return s.jsx(Mte,{scope:t,triggerRef:d,contentRef:f,contentId:ga(),titleId:ga(),descriptionId:ga(),open:h,onOpenChange:v,onOpenToggle:m.useCallback(()=>v(g=>!g),[v]),modal:c,children:n})};Fz.displayName=_g;var qz="DialogTrigger",zte=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(qz,n),l=Wl(t,a.triggerRef);return s.jsx(Ss.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":kw(a.open),...r,ref:l,onClick:wo(e.onClick,a.onOpenToggle)})});zte.displayName=qz;var ww="DialogPortal",[Rte,Hz]=Uz(ww,{forceMount:void 0}),Vz=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:a}=e,l=hi(ww,t);return s.jsx(Rte,{scope:t,forceMount:n,children:m.Children.map(r,c=>s.jsx(Cg,{present:n||l.open,children:s.jsx(Bz,{asChild:!0,container:a,children:c})}))})};Vz.displayName=ww;var Am="DialogOverlay",Gz=m.forwardRef((e,t)=>{const n=Hz(Am,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,l=hi(Am,e.__scopeDialog);return l.modal?s.jsx(Cg,{present:r||l.open,children:s.jsx(Ote,{...a,ref:t})}):null});Gz.displayName=Am;var Dte=Dz("DialogOverlay.RemoveScroll"),Ote=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(Am,n);return s.jsx(yu,{as:Dte,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(Ss.div,{"data-state":kw(a.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Ll="DialogContent",Zz=m.forwardRef((e,t)=>{const n=Hz(Ll,e.__scopeDialog),{forceMount:r=n.forceMount,...a}=e,l=hi(Ll,e.__scopeDialog);return s.jsx(Cg,{present:r||l.open,children:l.modal?s.jsx(Ite,{...a,ref:t}):s.jsx($te,{...a,ref:t})})});Zz.displayName=Ll;var Ite=m.forwardRef((e,t)=>{const n=hi(Ll,e.__scopeDialog),r=m.useRef(null),a=Wl(t,n.contentRef,r);return m.useEffect(()=>{const l=r.current;if(l)return hf(l)},[]),s.jsx(Kz,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:wo(e.onCloseAutoFocus,l=>{l.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:wo(e.onPointerDownOutside,l=>{const c=l.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0;(c.button===2||d)&&l.preventDefault()}),onFocusOutside:wo(e.onFocusOutside,l=>l.preventDefault())})}),$te=m.forwardRef((e,t)=>{const n=hi(Ll,e.__scopeDialog),r=m.useRef(!1),a=m.useRef(!1);return s.jsx(Kz,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:l=>{e.onCloseAutoFocus?.(l),l.defaultPrevented||(r.current||n.triggerRef.current?.focus(),l.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:l=>{e.onInteractOutside?.(l),l.defaultPrevented||(r.current=!0,l.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const c=l.target;n.triggerRef.current?.contains(c)&&l.preventDefault(),l.detail.originalEvent.type==="focusin"&&a.current&&l.preventDefault()}})}),Kz=m.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:l,...c}=e,d=hi(Ll,n),f=m.useRef(null),h=Wl(t,f);return Tte(),s.jsxs(s.Fragment,{children:[s.jsx(Lz,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:l,children:s.jsx(Iz,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":kw(d.open),...c,ref:h,onDismiss:()=>d.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(Ute,{titleId:d.titleId}),s.jsx(qte,{contentRef:f,descriptionId:d.descriptionId})]})]})}),jw="DialogTitle",Lte=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(jw,n);return s.jsx(Ss.h2,{id:a.titleId,...r,ref:t})});Lte.displayName=jw;var Yz="DialogDescription",Pte=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(Yz,n);return s.jsx(Ss.p,{id:a.descriptionId,...r,ref:t})});Pte.displayName=Yz;var Wz="DialogClose",Bte=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(Wz,n);return s.jsx(Ss.button,{type:"button",...r,ref:t,onClick:wo(e.onClick,()=>a.onOpenChange(!1))})});Bte.displayName=Wz;function kw(e){return e?"open":"closed"}var Xz="DialogTitleWarning",[ioe,Qz]=Yee(Xz,{contentName:Ll,titleName:jw,docsSlug:"dialog"}),Ute=({titleId:e})=>{const t=Qz(Xz),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
775
775
|
|
|
776
776
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
777
777
|
|
|
@@ -818,7 +818,7 @@ Accept-Encoding: identity\r
|
|
|
818
818
|
Content-Length: ${l.length}\r
|
|
819
819
|
${S.map(([T,z])=>`${T}: ${z}\r
|
|
820
820
|
`).join("")}\r
|
|
821
|
-
`)),l.length&&N.write(l)},N=>k(new Error(String(N))))})}const dre={tabs:[],focused:!1};function KE(e,t){switch(t.type){case"open":{const n=e.tabs.find(a=>a.port===t.port);if(t.multiple&&n)return e.selected===t.port?e:{...e,selected:t.port};const r={port:t.port,revision:n?n.revision+1:0};return{...e,tabs:t.multiple?[...e.tabs,r]:[r],selected:t.port}}case"select":return e.selected===t.port||!e.tabs.some(n=>n.port===t.port)?e:{...e,selected:t.port};case"refresh":return e.tabs.some(n=>n.port===t.port)?{...e,tabs:e.tabs.map(n=>n.port===t.port?{...n,revision:n.revision+1}:n)}:e;case"close":{const n=e.tabs.findIndex(a=>a.port===t.port);if(n<0)return e;const r=e.tabs.filter(a=>a.port!==t.port);return{tabs:r,selected:e.selected===t.port?(r[n]??r[n-1])?.port:e.selected,focused:r.length>0&&e.focused}}case"focus":return e.focused===t.focused||t.focused&&e.tabs.length===0?e:{...e,focused:t.focused}}}function fre(){const e=window.__LINKSHELL_CONFIG__?.previewOrigin,t=void 0;if(!e&&!t)return;let n;try{n=new URL(e??t)}catch{return}if(!(n.origin===location.origin||!["http:","https:"].includes(n.protocol)||n.username||n.password)&&!(location.protocol==="https:"&&n.protocol!=="https:"))return n.origin}function hre({port:e,retry:t}){const{streams:n}=Dt(),r=m.useRef(null),[a,l]=m.useState(),[c,d]=m.useState(),[f,h]=m.useState(!0),[v,g]=m.useState(!1),[x]=m.useState(()=>crypto.randomUUID()),y=fre();return m.useEffect(()=>{if(!y)return;let j=!0,k;const C=setTimeout(()=>{j&&g(!0)},15e3),_=($,D)=>{!j||$!==k||(clearTimeout(C),h(!1),D&&d(D))},N=new Map,S=new Set;let T=0;const z=new Map,L=new Map,B=$=>{j&&r.current?.contentWindow?.postMessage({...$,channel:x},y)},O=$=>{if($.source!==r.current?.contentWindow||$.origin!==y||$.data?.channel!==x)return;const D=$.data;if(D.type==="preview-ready"&&B({type:"preview-init",bootstrap:oy.toString()}),D.type==="http-cancel"&&L.get(D.id)?.abort(),D.type==="http-request"){if(k??=D.id,++T>128){T--,B({type:"http-error",id:D.id,error:"同时请求过多"});return}const Y=(D.headers??[]).filter(([M])=>!/^(cookie|proxy-authorization)$/i.test(M));z.size&&Y.push(["cookie",[...z].map(([M,R])=>`${M}=${R}`).join("; ")]);const P=new AbortController;L.set(D.id,P),ure(n,e,D.path??"/",D.method??"GET",Y,D.body?new Uint8Array(D.body):new Uint8Array,P.signal).then(async M=>{D.id===k&&M.status>=400&&j&&l(`开发服务返回 HTTP ${M.status}。请检查电脑上的服务日志后重试。`);for(const[q,G]of M.headers)if(q==="set-cookie"){const X=G.split(";")[0],K=X.indexOf("=");if(K>0){const ee=X.slice(0,K);/max-age=0/i.test(G)?z.delete(ee):z.set(ee,X.slice(K+1))}}let R=M.body;const H=M.headers.find(([q])=>q==="content-encoding")?.[1];if(D.method!=="HEAD"&&![204,205,304].includes(M.status)&&(H==="gzip"||H==="deflate"))R=R.pipeThrough(new DecompressionStream(H));else if(H&&!["identity","gzip","deflate"].includes(H))throw new Error(`预览暂不支持 ${H} 压缩`);B({type:"http-head",id:D.id,status:M.status,headers:M.headers});const I=R.getReader();try{for(;j;){const q=await I.read();if(q.done)break;B({type:"http-chunk",id:D.id,body:q.value})}}finally{I.releaseLock(),j||P.abort()}B({type:"http-end",id:D.id}),_(D.id)}).catch(M=>{_(D.id,Ps(M)),P.abort(),B({type:"http-error",id:D.id,error:String(M)})}).finally(()=>{L.delete(D.id),T--})}if(D.type==="ws-open"){if(N.has(D.id)||S.has(D.id)||N.size+S.size>=24)return;try{const Y=new URL(D.url,y);if(![new URL(y).hostname,"localhost","127.0.0.1"].includes(Y.hostname)||!["ws:","wss:"].includes(Y.protocol))throw new Error("仅代理当前预览端口的 WebSocket");const M=Y.pathname.replace(new RegExp(`^/preview/view/${x}/`),"/")+Y.search;S.add(D.id),Ag(n,e,M,{open:()=>B({type:"ws-open",id:D.id}),data:R=>B({type:"ws-data",id:D.id,data:R}),close:R=>{S.delete(D.id),N.delete(D.id),B({type:"ws-close",id:D.id,reason:R})}},D.protocols).then(R=>{!j||!S.has(D.id)?R.close():(S.delete(D.id),N.set(D.id,R))},R=>{S.delete(D.id),B({type:"ws-close",id:D.id,reason:String(R)})})}catch(Y){B({type:"ws-close",id:D.id,reason:String(Y)})}}D.type==="ws-send"&&(typeof D.data=="string"||D.data instanceof ArrayBuffer)&&N.get(D.id)?.send(D.data),D.type==="ws-close"&&(S.delete(D.id),N.get(D.id)?.close(),N.delete(D.id))};return window.addEventListener("message",O),()=>{j=!1,clearTimeout(C),window.removeEventListener("message",O);for(const $ of N.values())$.close();S.clear();for(const $ of L.values())$.abort();L.clear()}},[n,e,x,y]),y?s.jsxs("div",{className:"resource-preview-body",children:[a&&!c&&s.jsxs(cn,{variant:"destructive",children:[s.jsx(iu,{}),s.jsx(Ws,{children:"预览遇到问题"}),s.jsxs(rn,{children:[a,s.jsx("div",{className:"resource-alert-actions",children:s.jsx(F,{variant:"outline",size:"sm",onClick:t,children:"重新连接预览"})})]})]}),(f||c)&&s.jsxs("div",{className:"resource-preview-loading",role:"status","data-failed":c?"":void 0,children:[c?s.jsx(iu,{"aria-hidden":!0}):s.jsx(vt,{className:"animate-spin","aria-hidden":!0}),s.jsx("strong",{children:c?`无法连接 127.0.0.1:${e}`:v?"连接时间较长":`正在连接 127.0.0.1:${e}`}),(c||v)&&s.jsx("p",{title:c,children:c??"请确认电脑上的服务仍在运行,也可以重新连接。"}),(c||v)&&s.jsx(F,{variant:"secondary",size:"sm",onClick:t,children:"重试"})]}),s.jsx("iframe",{className:"port-frame",ref:r,title:`端口 ${e} 预览`,src:`${y}/preview/bridge.html#${x}`,sandbox:"allow-scripts allow-same-origin allow-forms allow-downloads allow-modals allow-pointer-lock",allow:"autoplay; fullscreen",onLoad:()=>r.current?.contentWindow?.postMessage({channel:x,type:"preview-init",bootstrap:oy.toString()},y),onError:()=>{h(!1),d("隔离预览页面加载失败,请检查预览域名配置")}})]}):s.jsxs(cn,{children:[s.jsx(wf,{}),s.jsx(Ws,{children:"当前部署尚未启用网页预览"}),s.jsx(rn,{children:"需要配置独立的预览域名后,才能安全打开电脑上的开发服务。请联系管理员设置 previewOrigin,并在该域名部署 preview 目录。"})]})}function pre(){const{link:e}=Dt(),t=Rn(()=>e.call("ports.list",{}),[e],1e4),[{tabs:n,selected:r,focused:a},l]=m.useReducer(KE,dre),[c,d]=m.useState(""),[f,h]=m.useState(!1),[v,g]=m.useState(""),[x,y]=m.useState(),j=m.useRef(null),k=m.useRef(null),C=m.useId(),[_,N]=m.useState(!1);m.useEffect(()=>{const M=()=>N(document.fullscreenElement===j.current);return document.addEventListener("fullscreenchange",M),()=>document.removeEventListener("fullscreenchange",M)},[]);const S=[...t.value?.ports??[]].sort((M,R)=>Number(R.http)-Number(M.http)||M.port-R.port),T=S.find(M=>M.port===r),z=me&&r!==void 0,L=S.filter(M=>!n.some(R=>R.port===M.port));function B(M){l({type:"open",port:M,multiple:me}),d(String(M)),y(void 0),h(!1)}function O(M){l({type:"select",port:M}),d(String(M)),y(void 0)}function $(M){const R=KE({tabs:n,selected:r,focused:a},{type:"close",port:M});l({type:"close",port:M}),y(void 0),R.selected!==void 0&&d(String(R.selected)),requestAnimationFrame(()=>{R.selected===void 0?k.current?.focus():document.getElementById(`${C}-tab-${R.selected}`)?.focus()})}function D(M,R){const H=n.findIndex(q=>q.port===R),I=M.key==="ArrowRight"?(H+1)%n.length:M.key==="ArrowLeft"?(H+n.length-1)%n.length:M.key==="Home"?0:M.key==="End"?n.length-1:void 0;I!==void 0?(M.preventDefault(),O(n[I].port),document.getElementById(`${C}-tab-${n[I].port}`)?.focus()):M.key==="Delete"&&(M.preventDefault(),$(R))}const Y=(M=r)=>{M!==void 0&&l({type:"refresh",port:M})},P=M=>{M.preventDefault();const R=Number(c);Number.isInteger(R)&&R>=1&&R<=65535&&B(R)};return s.jsxs("section",{className:"ports-page resource-ports","data-browsing":z||void 0,children:[s.jsx(lr,{title:"端口预览",actions:s.jsxs(s.Fragment,{children:[me&&!z&&s.jsxs("form",{className:"port-toolbar-form",onSubmit:P,children:[s.jsx(zi,{className:"port-toolbar-field",children:s.jsx(yo,{ref:k,"aria-label":"预览端口",type:"number",inputMode:"numeric",min:"1",max:"65535",step:"1",value:c,onChange:M=>d(M.target.value),required:!0,placeholder:"端口,如 3000"})}),s.jsx(F,{type:"submit",variant:"secondary",size:"sm",disabled:!c,children:"打开"})]}),s.jsxs(F,{variant:"ghost",size:"sm",disabled:t.loading,onClick:t.reload,children:[s.jsx(ws,{"data-icon":"inline-start",className:t.loading?"animate-spin":void 0}),"刷新"]})]}),detail:S.length||me?s.jsxs(s.Fragment,{children:[!!S.length&&s.jsxs("span",{children:[S.length," 个服务"]}),me&&s.jsx("span",{children:"加密连接"})]}):void 0}),!z&&!me&&s.jsxs("div",{className:"resource-port-connect",children:[s.jsxs("div",{className:"resource-port-connect-copy",children:[s.jsx(wf,{"aria-hidden":"true"}),s.jsx("span",{children:"电脑本地服务 · 加密连接"})]}),s.jsx("form",{className:"resource-port-form",onSubmit:P,children:s.jsx(Yn,{children:s.jsxs(Et,{children:[s.jsx(Rt,{className:"sr-only",children:"端口号"}),s.jsxs(zi,{children:[s.jsx(Is,{children:s.jsx(jb,{"aria-hidden":"true"})}),s.jsx(yo,{ref:k,"aria-label":"预览端口",type:"number",inputMode:"numeric",min:"1",max:"65535",step:"1",value:c,onChange:M=>d(M.target.value),required:!0,placeholder:"输入端口,如 3000"}),s.jsx(Is,{align:"inline-end",children:s.jsxs(bo,{type:"submit",variant:"secondary",disabled:!c,children:["打开",s.jsx(i3,{"data-icon":"inline-end"})]})})]})]})})})]}),!z&&s.jsx(js,{...t}),!z&&t.error&&s.jsxs("div",{className:"resource-retry",children:[s.jsx("span",{className:"resource-caption",children:"服务发现失败,仍可输入端口手动打开。"}),s.jsx(F,{variant:"outline",size:"sm",onClick:t.reload,children:"重新发现"})]}),!z&&!!S.length&&s.jsxs("section",{className:"resource-services","aria-label":"已发现的开发服务",children:[!me&&s.jsxs("div",{className:"resource-directory-summary",children:[s.jsxs("span",{children:["已发现 ",S.length," 个服务"]}),s.jsx("span",{children:"每 10 秒自动更新"})]}),s.jsx("div",{className:"resource-service-list",children:S.map(M=>s.jsxs(F,{variant:r===M.port?"secondary":"ghost",className:"resource-service","aria-pressed":r===M.port,title:[M.title??M.process,M.cwd,`端口 ${M.port}`].filter(Boolean).join(" · "),onClick:()=>B(M.port),children:[s.jsx(ho,{"data-icon":"inline-start"}),s.jsxs("span",{className:"resource-service-main",children:[s.jsx("strong",{children:M.title||M.process||"开发服务"}),s.jsxs("span",{children:[M.cwd||M.process,M.http?"":" · 未识别为 HTTP"]})]}),s.jsx(ui,{variant:"outline",children:M.port})]},M.port))})]}),s.jsx(it,{error:x}),r?s.jsxs("div",{className:`resource-preview${a?" port-preview-focused":""}`,ref:j,onKeyDown:M=>{a&&M.key==="Escape"&&!M.defaultPrevented&&(M.preventDefault(),l({type:"focus",focused:!1}))},children:[me&&s.jsxs("div",{className:"port-preview-tab-bar",children:[s.jsx("div",{className:"port-preview-tabs",role:"tablist","aria-label":"打开的端口预览",children:n.map(M=>{const R=S.find(I=>I.port===M.port),H=R?.title||R?.process||"端口预览";return s.jsxs("div",{className:"port-preview-tab","data-active":M.port===r||void 0,children:[s.jsxs(F,{variant:"ghost",size:"plain",className:"port-preview-tab-trigger",role:"tab",id:`${C}-tab-${M.port}`,"aria-label":`端口 ${M.port}`,"aria-selected":M.port===r,"aria-controls":`${C}-panel-${M.port}`,tabIndex:M.port===r?0:-1,title:`${H} · 127.0.0.1:${M.port}`,onClick:()=>O(M.port),onKeyDown:I=>D(I,M.port),children:[s.jsx(ho,{"aria-hidden":"true"}),s.jsx("span",{children:H}),s.jsx("small",{children:M.port})]}),s.jsx(F,{variant:"ghost",size:"icon-xs",className:"port-preview-tab-close","aria-label":`关闭端口 ${M.port} 预览`,title:`关闭端口 ${M.port} 预览`,onClick:()=>$(M.port),children:s.jsx(zn,{})})]},M.port)})}),s.jsxs(Af,{open:f,onOpenChange:h,children:[s.jsx(Sg,{asChild:!0,children:s.jsx(F,{variant:"ghost",size:"icon-sm","aria-label":"打开新的端口预览",title:"打开新的端口预览",children:s.jsx(Js,{})})}),s.jsxs(Tf,{align:"end",className:"port-new-tab w-72",children:[s.jsx("form",{onSubmit:M=>{M.preventDefault();const R=Number(v);Number.isInteger(R)&&R>=1&&R<=65535&&(B(R),g(""))},children:s.jsx(Yn,{children:s.jsxs(Et,{children:[s.jsx(Rt,{htmlFor:`${C}-new-port`,children:"打开端口预览"}),s.jsxs(zi,{children:[s.jsx(yo,{id:`${C}-new-port`,"aria-label":"新预览端口",type:"number",inputMode:"numeric",min:"1",max:"65535",step:"1",required:!0,value:v,onChange:M=>g(M.target.value),placeholder:"如 3000"}),s.jsx(Is,{align:"inline-end",children:s.jsx(bo,{type:"submit",variant:"secondary",disabled:!v,children:"打开"})})]})]})})}),!!L.length&&s.jsxs("div",{className:"port-new-tab-services",role:"group","aria-label":"已发现的开发服务",children:[s.jsx("span",{children:"已发现的服务"}),L.map(M=>s.jsxs("button",{type:"button",className:"port-new-tab-service",title:[M.title??M.process,M.cwd].filter(Boolean).join(" · "),onClick:()=>B(M.port),children:[s.jsx(ho,{"aria-hidden":"true"}),s.jsx("span",{children:M.title||M.process||"开发服务"}),s.jsx("small",{children:M.port})]},M.port))]})]})]})]}),s.jsxs("div",{className:"resource-preview-toolbar",children:[s.jsxs("div",{className:"resource-preview-address",children:[s.jsx(ho,{"aria-hidden":"true"}),!me&&s.jsx("strong",{title:T?.title??`端口 ${r}`,children:T?.title||`端口 ${r}`}),s.jsxs("span",{title:`所连接电脑上的本地服务:127.0.0.1:${r}`,children:["127.0.0.1:",r]})]}),s.jsxs("div",{className:"resource-inline-actions",children:[s.jsx(F,{variant:"ghost",size:"icon",title:"重新加载预览","aria-label":"重新加载预览",onClick:()=>Y(),children:s.jsx(ws,{})}),me?s.jsxs(F,{variant:a?"outline":"ghost",size:"sm","aria-label":a?"退出铺满窗口":"铺满窗口","aria-pressed":a,title:a?"退出铺满窗口":"在当前窗口铺满预览",onClick:()=>l({type:"focus",focused:!a}),children:[a?s.jsx(Tl,{}):s.jsx(Al,{}),a?"退出铺满窗口":"铺满窗口"]}):document.fullscreenEnabled&&s.jsx(F,{variant:"ghost",size:"icon",title:_?"退出全屏":"全屏预览","aria-label":_?"退出全屏":"全屏预览",onClick:()=>{(_?document.exitFullscreen():j.current?.requestFullscreen())?.catch(R=>y(`无法切换全屏:${Ps(R)}`))},children:_?s.jsx(Tl,{}):s.jsx(Al,{})}),!me&&s.jsx(F,{variant:"ghost",size:"icon",title:"关闭预览","aria-label":"关闭预览",onClick:()=>$(r),children:s.jsx(zn,{})})]})]}),T&&!T.http&&s.jsx("p",{className:"resource-caption resource-preview-note",children:"此端口未识别为 HTTP 服务。终端、数据库等服务无法作为网页预览。"}),n.map(M=>s.jsx("div",{className:"port-preview-panel",role:me?"tabpanel":void 0,id:`${C}-panel-${M.port}`,"aria-labelledby":me?`${C}-tab-${M.port}`:void 0,hidden:M.port!==r,children:s.jsx(hre,{port:M.port,retry:()=>Y(M.port)},M.revision)},M.port))]}):!t.loading&&!(me&&S.length)&&s.jsx(an,{icon:s.jsx(jb,{}),title:S.length?"选择一个开发服务":"还没有发现开发服务",description:S.length?"选择上方服务打开预览,或输入端口号访问其他服务。":"先在电脑或终端中启动项目,再刷新服务列表。已知端口号时也可以直接输入。"})]})}const mre="/assets/mark-glyph-D_OhbJdd.png",gre="linkshell-desktop-update",vre="linkshell-desktop-login",xre=5e3,bre=3e5,zo=Cf(()=>({busy:!1,started:!1,settings:{opaqueWindow:!1,autoCheck:!0,updateChannel:"stable"},permissions:{known:!1,recording:!1,control:!1},loginItem:{enabled:!1,approval:!1},loginItemMessage:"",activity:[],signingIn:!1,signInError:"",accountMessage:"",checkingMembership:!1,gatewayMessage:"",passwordMessage:"",passwordIsError:!1,savingPassword:!1,redemptionMessage:"",redemptionIsError:!1,redeeming:!1,commandMessage:"",log:"",update:{checking:!1,installing:!1,available:!1,message:"尚未检查更新"}})),Ve=e=>zo.setState(e),Nt=()=>zo.getState(),zs=e=>e instanceof Error?e.message:String(e);let nu,my,B0=!1,Rd=0,Mg=0,gy=!1;function CR(e={}){Rd++,Ve({...e,busy:!0})}function ka(e){Ve({activity:[{at:Date.now(),text:e},...Nt().activity].slice(0,20)})}function Aa(e){Nt().snapshot?.account?.userId!==e.account?.userId&&(Mg=0,Ve({redemptionMessage:"",redemptionIsError:!1,accountMessage:""})),Ve({snapshot:e})}const yre=e=>e.snapshot?.status==="running"&&!e.problem,_R=e=>e.about?.standalone===!0,ER=e=>{if(_R(e))return e.update.available;const t=e.snapshot?.cliVersion;return!!e.update.latest&&!!t&&wR(e.update.latest,t)};function wre(){!nn||Nt().started||(Ve({started:!0}),window.addEventListener(gre,Pre),window.addEventListener(vre,Ere),Lt("updateStatus").then(e=>{e&&Ve({update:e})},()=>{}),Promise.all([Lt("about"),kre()]).then(([e])=>{Ve({about:e}),!e.standalone&&Nt().settings.autoCheck&&RR()},()=>{}),AR(),CR(),(async()=>{try{Aa(await Lt("startup",{},1e5)),nu=void 0,ka(`桌面启动:后台服务${Nt().snapshot?.status==="running"?"已就绪":"需要检查"}`)}catch(e){const t=zs(e);t.startsWith("服务恢复")?nu=t:my=t,Ve({problem:t}),Ul(t)}Ve({busy:!1}),Bl()})())}function Bl(){if(!nn||B0||Nt().busy)return;B0=!0;const e=Rd;(async()=>{try{const t=await Lt("snapshot",{},3e4);if(Nt().busy||e!==Rd)return;const n=Nt().snapshot;t.status!==n?.status&&ka(t.status==="running"?"本机服务已连接":`本机服务:${t.status==="stopped"?"已停止":"无法连接"}`),n?.gateway?.status&&n.gateway.status!==t.gateway?.status&&ka("网关连接状态已变化"),t.status==="running"&&!t.error&&(my=void 0),Aa(t),Ve({problem:t.error??nu??my}),NR()}catch(t){!Nt().busy&&e===Rd&&Ve({snapshot:void 0,problem:zs(t)})}finally{B0=!1}if(e!==Rd){Nt().busy||Bl();return}Nt().snapshot?.account?.state==="signed-in"&&Date.now()-Mg>bre&&TR()})()}function jre(){Bl();const e=setInterval(Bl,xre);return()=>clearInterval(e)}async function NR(){try{const e=await Lt("permissions",{},15e3);Ve({permissions:{known:!e.unavailable,recording:e.recording,control:e.control,sharing:e.sharing}})}catch{Ve({permissions:{known:!1,recording:!1,control:!1}})}}async function kre(){try{Ve({settings:await Lt("settings")})}catch{}}async function AR(){try{Ve({loginItem:await Lt("loginItem")})}catch{}}async function Go(e,t={}){if(!Nt().busy){CR(t);try{await e()}finally{Ve({busy:!1}),Bl()}}}function zm(e){return Go(async()=>{try{Aa(await Lt("action",{name:e})),e==="recover-update"&&(nu=void 0),ka({start:"已启动本机服务",stop:"已停止本机服务",restart:"已重启本机服务","recover-update":"已恢复后台服务"}[e])}catch(t){const n=zs(t);e==="recover-update"&&(nu=`服务恢复需要处理:${n}`),Ve({problem:e==="recover-update"?nu:n})}},{problem:void 0})}function Tw(e,t){return gy=!1,Go(async()=>{try{const n=await t();if(n.error)throw new Error(n.error);Aa(n),Ve({accountMessage:`登录成功。手机登录同一账号后,可通过官方网关连接${ys}(需要 Pro)。`}),ka("账号已登录")}catch(n){Ve({signInError:gy?"":zs(n)})}finally{Ve({signingIn:!1,signInMethod:void 0,signInLink:void 0})}},{signingIn:!0,signInMethod:e,signInLink:void 0,signInError:"",accountMessage:""})}function Sre(){return Tw("web",()=>Lt("login",{},4e5))}function Cre(e,t){return Tw("password",()=>Lt("loginPassword",{email:e,password:t},9e4))}function _re(e){return Tw(e,()=>Lt("loginOAuth",{provider:e},4e5))}function vy(){gy=!0,Lt("cancelLogin").catch(()=>{})}function YE(){Nt().signInError&&Ve({signInError:""})}function Ere(e){const t=e.detail??{},n=Nt();n.signingIn&&t.provider===n.signInMethod&&typeof t.url=="string"&&Ve({signInLink:t.url})}function Nre(e){return Go(async()=>{try{Aa(await Lt("action",{name:e})),Ve({accountMessage:`已退出${ai}的账号。`})}catch(t){Ve({accountMessage:zs(t)})}},{accountMessage:"正在处理…"})}function TR(){const e=Nt();if(e.snapshot?.account?.state!=="signed-in"||e.busy)return;const t=e.snapshot.account.userId;Mg=Date.now(),Go(async()=>{try{const n=await Lt("action",{name:"account-refresh"});if(Nt().snapshot?.account?.userId!==t)return;Aa(n),n.account?.userId===t&&Ve({accountMessage:n.accountWarning??""})}catch(n){Nt().snapshot?.account?.userId===t&&Ve({accountMessage:zs(n)})}finally{Ve({checkingMembership:!1})}},{checkingMembership:!0})}async function MR(e){if(Nt().busy)return!1;if(e!==null){const n=Lse(e);if(n)return Ve({passwordMessage:n,passwordIsError:!0}),!1}let t=!1;return await Go(async()=>{try{const n=e===null?await Lt("action",{name:"remove-password"}):await Lt("action",{name:"set-password",input:{password:e}});if(n.error)throw new Error(n.error);Aa(n),t=!0,Ve({passwordMessage:e===null?"已移除访问密码。":`已设置访问密码。其他设备下次打开${ai}时需要输入。`}),ka(e===null?"访问密码已移除":"访问密码已设置")}catch(n){Ve({passwordMessage:zs(n),passwordIsError:!0})}finally{Ve({savingPassword:!1})}},{savingPassword:!0,passwordMessage:"",passwordIsError:!1}),t}async function Are(e){if(Nt().busy)return!1;let t=!1;return await Go(async()=>{try{const n=e.kind==="official"?await Lt("action",{name:"connect-gateway"}):await Lt("action",{name:"set-gateway",input:{gateway:e.kind==="off"?"off":e.url}});if(n.error)throw new Error(n.error);Aa(n),t=!0,ka(e.kind==="official"?"已切换到官方网关":e.kind==="off"?"已关闭网关":`已切换到自建网关 ${e.url}`)}catch(n){Ve({gatewayMessage:zs(n)})}},{gatewayMessage:""}),t}function U0(){Ve({gatewayMessage:""})}function Tre(){Ve({passwordMessage:"",passwordIsError:!1})}async function Mre(e){const t=Nt(),n=t.snapshot?.account?.userId;if(t.busy||!n||cy(t.snapshot?.account).kind!=="free")return!1;const r=Pse(e);if(r)return Ve({redemptionMessage:r,redemptionIsError:!0}),!1;let a=!1;return await Go(async()=>{try{const l=await Lt("action",{name:"redeem-pro",input:{code:e.trim(),userId:n}});if(Nt().snapshot?.account?.userId!==n||(Aa(l),l.account?.userId!==n))return;if(l.redemption?.userId!==n||cy(l.account).kind!=="pro")throw new Error("尚未确认 Pro 有效期,请刷新会员状态后重试。");a=!0,Mg=Date.now(),Ve({redemptionMessage:l.redemption.idempotent?"该激活码已为当前账号兑换,Pro 会员状态已更新。":"兑换成功,Pro 会员已开通。",accountMessage:l.accountWarning??""}),ka("Pro 会员状态已更新")}catch(l){Nt().snapshot?.account?.userId===n&&Ve({redemptionMessage:zs(l),redemptionIsError:!0})}finally{Ve({redeeming:!1})}},{redeeming:!0,redemptionMessage:"",redemptionIsError:!1}),a}async function WE(){try{Ve({log:(await Lt("log")).text})}catch(e){Ve({log:zs(e)})}}async function zre(e){try{await Lt("setScreenSharing",{enabled:e})}catch(t){Ul(t)}await NR()}async function Rre(){try{Ve({commandMessage:`已复制:${(await Lt("copyCommandPath")).path}`})}catch(e){Ve({commandMessage:zs(e)})}}async function Dre(){try{Ve({commandMessage:`已安装:${(await Lt("installCommand")).path}。请将 ~/.local/bin 加入 PATH。`})}catch(e){Ve({commandMessage:zs(e)})}}async function Ore(e){try{Ve({loginItem:await Lt("setLoginItem",{enabled:e}),loginItemMessage:""})}catch(t){Ve({loginItemMessage:zs(t)}),AR()}}async function xy(e,t){const n=Nt().settings;Ve({settings:{...n,[e]:t}}),e==="updateChannel"&&Ve({update:{...Nt().update,available:!1,version:void 0,message:"通道已切换,检查更新后生效"}});try{await Lt("setSetting",{key:e,value:t})}catch(r){Ve({settings:n}),Ul(r)}}function zR(){Lt("openSetup").catch(e=>Ul(e))}function Ire(){Lt("openLoginItems").catch(()=>{})}async function RR(){const e=Nt();if(!(e.update.checking||e.update.installing)){try{if((await Lt("checkUpdates")).started)return}catch{}Ve({update:{...Nt().update,checking:!0,message:"正在检查…"}});try{const t=await fetch("https://registry.npmjs.org/linkshell-cli/latest",{cache:"no-store",credentials:"omit",signal:AbortSignal.timeout(15e3)}),n=await t.json();if(!t.ok||typeof n.version!="string")throw new Error("版本信息无效");const r=n.version,a=Nt().snapshot?.cliVersion,l=a?wR(r,a)?`有新版本 ${r}`:"当前已是最新稳定版":`最新稳定版 ${r};当前 CLI 版本未知`;Ve({update:{...Nt().update,checking:!1,latest:r,message:l,checkedAt:Date.now()}})}catch(t){Ve({update:{...Nt().update,checking:!1,message:`检查失败:${zs(t)}`,checkedAt:Date.now()}})}}}function $re(){return Go(async()=>{Ve({update:{...Nt().update,message:"正在更新 CLI 和 Host…"}});try{const e=await Lt("upgrade",{},25e4);Ve({update:{...Nt().update,message:e.message??"更新完成。"}}),ka("CLI 更新完成")}catch(e){Ve({update:{...Nt().update,message:zs(e)}})}})}function Lre(){Nt().update.checking||Nt().update.installing||(Ve({update:{...Nt().update,message:"正在打开更新窗口…"}}),Lt("installUpdate").catch(e=>Ve({update:{...Nt().update,message:`更新未完成:${zs(e)}`}})))}function Pre(e){const t=e.detail??{},n=Nt().update,r=typeof t.message=="string"?t.message:n.message;switch(t.name){case"checking":Ve({update:{...n,checking:!0,message:r}});break;case"available":Ve({update:{...n,available:!0,version:typeof t.version=="string"?t.version:n.version,message:r,checkedAt:Date.now()}});break;case"current":Ve({update:{...n,available:!1,message:r,checkedAt:Date.now()}});break;case"message":Ve({update:{...n,message:r}});break;case"installing":Ve({update:{...n,installing:!0,message:r}});break;case"finished":Ve({update:{...n,checking:!1,installing:!1}});break}}function Hp({className:e,...t}){return s.jsx(zB,{"data-slot":"switch",className:je("peer inline-flex h-[18px] w-8 shrink-0 items-center rounded-full border border-transparent bg-[var(--quaternaryLabel)] transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary",e),...t,children:s.jsx(DB,{"data-slot":"switch-thumb",className:"pointer-events-none block size-3.5 rounded-full bg-[var(--plain)] ring-0 transition-transform data-[state=checked]:translate-x-[15px] data-[state=checked]:bg-primary-foreground data-[state=unchecked]:translate-x-px"})})}const Bre=["#4a6cf7","#7d95ff"],Ure=["#4a6cf7","#4466f6"],Fre=["rgba(74,108,247,0.11)","rgba(125,149,255,0.18)"],qre=["#4a6cf7","#7d95ff"],Hre=["rgba(232,131,12,0.12)","rgba(255,166,61,0.16)"],Vre=["rgba(15,149,96,0.12)","rgba(61,214,140,0.15)"],Gre=["rgba(220,61,61,0.10)","rgba(255,107,107,0.15)"],Zre=["#F0F0F4","#26262B"],Kre=["#f1f1f6","#1c1c22"],Yre=["#2a2b35","#e4e4ec"],Wre=["rgba(15,149,96,0.12)","rgba(61,214,140,0.14)"],Xre=["rgba(220,61,61,0.10)","rgba(255,107,107,0.14)"],Qre=["#0b7a4f","#7fddb4"],Jre=["#b42f2f","#ff9a9a"],eie=["#000000","#FFFFFF"],tie=["rgba(60,60,67,0.6)","rgba(235,235,245,0.6)"],nie=["rgba(60,60,67,0.3)","rgba(235,235,245,0.3)"],sie=["rgba(60,60,67,0.3)","rgba(235,235,245,0.3)"],rie=["rgba(60,60,67,0.18)","rgba(84,84,88,0.6)"],iie=["#F2F2F7","#000000"],aie=["#FFFFFF","#1C1C1E"],oie=["#FFFFFF","#2C2C2E"],lie=["#F2F2F7","#1C1C1E"],cie=["#FFFFFF","#000000"],uie=["rgba(118,118,128,0.12)","rgba(118,118,128,0.24)"],die=["rgba(120,120,128,0.16)","rgba(120,120,128,0.32)"],fie=["#E8830C","#FF9F0A"],hie=["#0F9560","#30D158"],pie=["#DC3D3D","#FF453A"],mie=["#F2F2F7","#1C1C1E"],gie=["#FFFFFF","#2C2C2E"],DR={accent:Bre,accentFill:Ure,accentSoft:Fre,running:qre,waitingSoft:Hre,okSoft:Vre,dangerSoft:Gre,userBubble:Zre,code:Kre,codeText:Yre,diffAdd:Wre,diffDel:Xre,diffAddText:Qre,diffDelText:Jre,label:eie,secondaryLabel:tie,tertiaryLabel:nie,placeholder:sie,separator:rie,background:iie,card:aie,cardRaised:oie,inset:lie,plain:cie,fill:uie,fillStrong:die,waiting:fie,ok:hie,danger:pie,sheet:mie,sheetCard:gie},OR={background:["#f6f6f8","#08090a"],plain:["#ffffff","#0f1011"],card:["#ffffff","#131417"],cardRaised:["#ffffff","#16171a"],inset:["#f1f1f4","#0b0c0d"],label:["#17181b","#f0f1f3"],secondaryLabel:["#5c5f68","#a0a3ab"],tertiaryLabel:["#8a8d96","#70737b"],quaternaryLabel:["#aeb0b8","#4e5059"],separator:["#0000000f","#ffffff12"],separatorStrong:["#00000020","#ffffff1f"],fill:["#1b1c200a","#ffffff0a"],fillStrong:["#1b1c2014","#ffffff14"],sidebarBackground:["#f6f6f8","#08090a"],sidebarAccent:["#00000010","#ffffff14"],code:["#f3f3f6","#0b0c0d"],codeText:["#30323b","#dedfe8"],userBubble:["#ececf1","#1a1b1f"],accent:["#5e6ad2","#6872e5"],accentHover:["#515dc0","#7681ec"],accentSoft:["#5e6ad214","#6872e524"],primaryForeground:["#ffffff","#ffffff"],link:["#5260c5","#9aa5ff"],success:["#218058","#6cc29a"],ok:["#218058","#6cc29a"],warning:["#917021","#d8b76c"],waiting:["#917021","#d8b76c"],waitingSoft:["#9170210d","#d8b76c10"],info:["#5260c5","#9aa5ff"],running:["#5260c5","#9aa5ff"],danger:["#c03e48","#f08891"]},F0=e=>Object.entries({...DR,...OR,...IR}).map(([t,n])=>`--${t}: ${n[e]};`).join(`
|
|
821
|
+
`)),l.length&&N.write(l)},N=>k(new Error(String(N))))})}const dre={tabs:[],focused:!1};function KE(e,t){switch(t.type){case"open":{const n=e.tabs.find(a=>a.port===t.port);if(t.multiple&&n)return e.selected===t.port?e:{...e,selected:t.port};const r={port:t.port,revision:n?n.revision+1:0};return{...e,tabs:t.multiple?[...e.tabs,r]:[r],selected:t.port}}case"select":return e.selected===t.port||!e.tabs.some(n=>n.port===t.port)?e:{...e,selected:t.port};case"refresh":return e.tabs.some(n=>n.port===t.port)?{...e,tabs:e.tabs.map(n=>n.port===t.port?{...n,revision:n.revision+1}:n)}:e;case"close":{const n=e.tabs.findIndex(a=>a.port===t.port);if(n<0)return e;const r=e.tabs.filter(a=>a.port!==t.port);return{tabs:r,selected:e.selected===t.port?(r[n]??r[n-1])?.port:e.selected,focused:r.length>0&&e.focused}}case"focus":return e.focused===t.focused||t.focused&&e.tabs.length===0?e:{...e,focused:t.focused}}}function fre(){const e=window.__LINKSHELL_CONFIG__?.previewOrigin,t=void 0;if(!e&&!t)return;let n;try{n=new URL(e??t)}catch{return}if(!(n.origin===location.origin||!["http:","https:"].includes(n.protocol)||n.username||n.password)&&!(location.protocol==="https:"&&n.protocol!=="https:"))return n.origin}function hre({port:e,retry:t}){const{streams:n}=Dt(),r=m.useRef(null),[a,l]=m.useState(),[c,d]=m.useState(),[f,h]=m.useState(!0),[v,g]=m.useState(!1),[x]=m.useState(()=>crypto.randomUUID()),y=fre();return m.useEffect(()=>{if(!y)return;let j=!0,k;const C=setTimeout(()=>{j&&g(!0)},15e3),_=($,D)=>{!j||$!==k||(clearTimeout(C),h(!1),D&&d(D))},N=new Map,S=new Set;let T=0;const z=new Map,L=new Map,B=$=>{j&&r.current?.contentWindow?.postMessage({...$,channel:x},y)},O=$=>{if($.source!==r.current?.contentWindow||$.origin!==y||$.data?.channel!==x)return;const D=$.data;if(D.type==="preview-ready"&&B({type:"preview-init",bootstrap:oy.toString()}),D.type==="http-cancel"&&L.get(D.id)?.abort(),D.type==="http-request"){if(k??=D.id,++T>128){T--,B({type:"http-error",id:D.id,error:"同时请求过多"});return}const Y=(D.headers??[]).filter(([M])=>!/^(cookie|proxy-authorization)$/i.test(M));z.size&&Y.push(["cookie",[...z].map(([M,R])=>`${M}=${R}`).join("; ")]);const P=new AbortController;L.set(D.id,P),ure(n,e,D.path??"/",D.method??"GET",Y,D.body?new Uint8Array(D.body):new Uint8Array,P.signal).then(async M=>{D.id===k&&M.status>=400&&j&&l(`开发服务返回 HTTP ${M.status}。请检查电脑上的服务日志后重试。`);for(const[q,G]of M.headers)if(q==="set-cookie"){const X=G.split(";")[0],K=X.indexOf("=");if(K>0){const ee=X.slice(0,K);/max-age=0/i.test(G)?z.delete(ee):z.set(ee,X.slice(K+1))}}let R=M.body;const H=M.headers.find(([q])=>q==="content-encoding")?.[1];if(D.method!=="HEAD"&&![204,205,304].includes(M.status)&&(H==="gzip"||H==="deflate"))R=R.pipeThrough(new DecompressionStream(H));else if(H&&!["identity","gzip","deflate"].includes(H))throw new Error(`预览暂不支持 ${H} 压缩`);B({type:"http-head",id:D.id,status:M.status,headers:M.headers});const I=R.getReader();try{for(;j;){const q=await I.read();if(q.done)break;B({type:"http-chunk",id:D.id,body:q.value})}}finally{I.releaseLock(),j||P.abort()}B({type:"http-end",id:D.id}),_(D.id)}).catch(M=>{_(D.id,Ps(M)),P.abort(),B({type:"http-error",id:D.id,error:String(M)})}).finally(()=>{L.delete(D.id),T--})}if(D.type==="ws-open"){if(N.has(D.id)||S.has(D.id)||N.size+S.size>=24)return;try{const Y=new URL(D.url,y);if(![new URL(y).hostname,"localhost","127.0.0.1"].includes(Y.hostname)||!["ws:","wss:"].includes(Y.protocol))throw new Error("仅代理当前预览端口的 WebSocket");const M=Y.pathname.replace(new RegExp(`^/preview/view/${x}/`),"/")+Y.search;S.add(D.id),Ag(n,e,M,{open:()=>B({type:"ws-open",id:D.id}),data:R=>B({type:"ws-data",id:D.id,data:R}),close:R=>{S.delete(D.id),N.delete(D.id),B({type:"ws-close",id:D.id,reason:R})}},D.protocols).then(R=>{!j||!S.has(D.id)?R.close():(S.delete(D.id),N.set(D.id,R))},R=>{S.delete(D.id),B({type:"ws-close",id:D.id,reason:String(R)})})}catch(Y){B({type:"ws-close",id:D.id,reason:String(Y)})}}D.type==="ws-send"&&(typeof D.data=="string"||D.data instanceof ArrayBuffer)&&N.get(D.id)?.send(D.data),D.type==="ws-close"&&(S.delete(D.id),N.get(D.id)?.close(),N.delete(D.id))};return window.addEventListener("message",O),()=>{j=!1,clearTimeout(C),window.removeEventListener("message",O);for(const $ of N.values())$.close();S.clear();for(const $ of L.values())$.abort();L.clear()}},[n,e,x,y]),y?s.jsxs("div",{className:"resource-preview-body",children:[a&&!c&&s.jsxs(cn,{variant:"destructive",children:[s.jsx(iu,{}),s.jsx(Ws,{children:"预览遇到问题"}),s.jsxs(rn,{children:[a,s.jsx("div",{className:"resource-alert-actions",children:s.jsx(F,{variant:"outline",size:"sm",onClick:t,children:"重新连接预览"})})]})]}),(f||c)&&s.jsxs("div",{className:"resource-preview-loading",role:"status","data-failed":c?"":void 0,children:[c?s.jsx(iu,{"aria-hidden":!0}):s.jsx(vt,{className:"animate-spin","aria-hidden":!0}),s.jsx("strong",{children:c?`无法连接 127.0.0.1:${e}`:v?"连接时间较长":`正在连接 127.0.0.1:${e}`}),(c||v)&&s.jsx("p",{title:c,children:c??"请确认电脑上的服务仍在运行,也可以重新连接。"}),(c||v)&&s.jsx(F,{variant:"secondary",size:"sm",onClick:t,children:"重试"})]}),s.jsx("iframe",{className:"port-frame",ref:r,title:`端口 ${e} 预览`,src:`${y}/preview/bridge.html#${x}`,sandbox:"allow-scripts allow-same-origin allow-forms allow-downloads allow-modals allow-pointer-lock",allow:"autoplay; fullscreen",onLoad:()=>r.current?.contentWindow?.postMessage({channel:x,type:"preview-init",bootstrap:oy.toString()},y),onError:()=>{h(!1),d("隔离预览页面加载失败,请检查预览域名配置")}})]}):s.jsxs(cn,{children:[s.jsx(wf,{}),s.jsx(Ws,{children:"当前部署尚未启用网页预览"}),s.jsx(rn,{children:"需要配置独立的预览域名后,才能安全打开电脑上的开发服务。请联系管理员设置 previewOrigin,并在该域名部署 preview 目录。"})]})}function pre(){const{link:e}=Dt(),t=Rn(()=>e.call("ports.list",{}),[e],1e4),[{tabs:n,selected:r,focused:a},l]=m.useReducer(KE,dre),[c,d]=m.useState(""),[f,h]=m.useState(!1),[v,g]=m.useState(""),[x,y]=m.useState(),j=m.useRef(null),k=m.useRef(null),C=m.useId(),[_,N]=m.useState(!1);m.useEffect(()=>{const M=()=>N(document.fullscreenElement===j.current);return document.addEventListener("fullscreenchange",M),()=>document.removeEventListener("fullscreenchange",M)},[]);const S=[...t.value?.ports??[]].sort((M,R)=>Number(R.http)-Number(M.http)||M.port-R.port),T=S.find(M=>M.port===r),z=me&&r!==void 0,L=S.filter(M=>!n.some(R=>R.port===M.port));function B(M){l({type:"open",port:M,multiple:me}),d(String(M)),y(void 0),h(!1)}function O(M){l({type:"select",port:M}),d(String(M)),y(void 0)}function $(M){const R=KE({tabs:n,selected:r,focused:a},{type:"close",port:M});l({type:"close",port:M}),y(void 0),R.selected!==void 0&&d(String(R.selected)),requestAnimationFrame(()=>{R.selected===void 0?k.current?.focus():document.getElementById(`${C}-tab-${R.selected}`)?.focus()})}function D(M,R){const H=n.findIndex(q=>q.port===R),I=M.key==="ArrowRight"?(H+1)%n.length:M.key==="ArrowLeft"?(H+n.length-1)%n.length:M.key==="Home"?0:M.key==="End"?n.length-1:void 0;I!==void 0?(M.preventDefault(),O(n[I].port),document.getElementById(`${C}-tab-${n[I].port}`)?.focus()):M.key==="Delete"&&(M.preventDefault(),$(R))}const Y=(M=r)=>{M!==void 0&&l({type:"refresh",port:M})},P=M=>{M.preventDefault();const R=Number(c);Number.isInteger(R)&&R>=1&&R<=65535&&B(R)};return s.jsxs("section",{className:"ports-page resource-ports","data-browsing":z||void 0,children:[s.jsx(lr,{title:"端口预览",actions:s.jsxs(s.Fragment,{children:[me&&!z&&s.jsxs("form",{className:"port-toolbar-form",onSubmit:P,children:[s.jsx(zi,{className:"port-toolbar-field",children:s.jsx(yo,{ref:k,"aria-label":"预览端口",type:"number",inputMode:"numeric",min:"1",max:"65535",step:"1",value:c,onChange:M=>d(M.target.value),required:!0,placeholder:"端口,如 3000"})}),s.jsx(F,{type:"submit",variant:"secondary",size:"sm",disabled:!c,children:"打开"})]}),s.jsxs(F,{variant:"ghost",size:"sm",disabled:t.loading,onClick:t.reload,children:[s.jsx(ws,{"data-icon":"inline-start",className:t.loading?"animate-spin":void 0}),"刷新"]})]}),detail:S.length||me?s.jsxs(s.Fragment,{children:[!!S.length&&s.jsxs("span",{children:[S.length," 个服务"]}),me&&s.jsx("span",{children:"加密连接"})]}):void 0}),!z&&!me&&s.jsxs("div",{className:"resource-port-connect",children:[s.jsxs("div",{className:"resource-port-connect-copy",children:[s.jsx(wf,{"aria-hidden":"true"}),s.jsx("span",{children:"电脑本地服务 · 加密连接"})]}),s.jsx("form",{className:"resource-port-form",onSubmit:P,children:s.jsx(Yn,{children:s.jsxs(Et,{children:[s.jsx(Rt,{className:"sr-only",children:"端口号"}),s.jsxs(zi,{children:[s.jsx(Is,{children:s.jsx(jb,{"aria-hidden":"true"})}),s.jsx(yo,{ref:k,"aria-label":"预览端口",type:"number",inputMode:"numeric",min:"1",max:"65535",step:"1",value:c,onChange:M=>d(M.target.value),required:!0,placeholder:"输入端口,如 3000"}),s.jsx(Is,{align:"inline-end",children:s.jsxs(bo,{type:"submit",variant:"secondary",disabled:!c,children:["打开",s.jsx(i3,{"data-icon":"inline-end"})]})})]})]})})})]}),!z&&s.jsx(js,{...t}),!z&&t.error&&s.jsxs("div",{className:"resource-retry",children:[s.jsx("span",{className:"resource-caption",children:"服务发现失败,仍可输入端口手动打开。"}),s.jsx(F,{variant:"outline",size:"sm",onClick:t.reload,children:"重新发现"})]}),!z&&!!S.length&&s.jsxs("section",{className:"resource-services","aria-label":"已发现的开发服务",children:[!me&&s.jsxs("div",{className:"resource-directory-summary",children:[s.jsxs("span",{children:["已发现 ",S.length," 个服务"]}),s.jsx("span",{children:"每 10 秒自动更新"})]}),s.jsx("div",{className:"resource-service-list",children:S.map(M=>s.jsxs(F,{variant:r===M.port?"secondary":"ghost",className:"resource-service","aria-pressed":r===M.port,title:[M.title??M.process,M.cwd,`端口 ${M.port}`].filter(Boolean).join(" · "),onClick:()=>B(M.port),children:[s.jsx(ho,{"data-icon":"inline-start"}),s.jsxs("span",{className:"resource-service-main",children:[s.jsx("strong",{children:M.title||M.process||"开发服务"}),s.jsxs("span",{children:[M.cwd||M.process,M.http?"":" · 未识别为 HTTP"]})]}),s.jsx(ui,{variant:"outline",children:M.port})]},M.port))})]}),s.jsx(it,{error:x}),r?s.jsxs("div",{className:`resource-preview${a?" port-preview-focused":""}`,ref:j,onKeyDown:M=>{a&&M.key==="Escape"&&!M.defaultPrevented&&(M.preventDefault(),l({type:"focus",focused:!1}))},children:[me&&s.jsxs("div",{className:"port-preview-tab-bar",children:[s.jsx("div",{className:"port-preview-tabs",role:"tablist","aria-label":"打开的端口预览",children:n.map(M=>{const R=S.find(I=>I.port===M.port),H=R?.title||R?.process||"端口预览";return s.jsxs("div",{className:"port-preview-tab","data-active":M.port===r||void 0,children:[s.jsxs(F,{variant:"ghost",size:"plain",className:"port-preview-tab-trigger",role:"tab",id:`${C}-tab-${M.port}`,"aria-label":`端口 ${M.port}`,"aria-selected":M.port===r,"aria-controls":`${C}-panel-${M.port}`,tabIndex:M.port===r?0:-1,title:`${H} · 127.0.0.1:${M.port}`,onClick:()=>O(M.port),onKeyDown:I=>D(I,M.port),children:[s.jsx(ho,{"aria-hidden":"true"}),s.jsx("span",{children:H}),s.jsx("small",{children:M.port})]}),s.jsx(F,{variant:"ghost",size:"icon-xs",className:"port-preview-tab-close","aria-label":`关闭端口 ${M.port} 预览`,title:`关闭端口 ${M.port} 预览`,onClick:()=>$(M.port),children:s.jsx(zn,{})})]},M.port)})}),s.jsxs(Af,{open:f,onOpenChange:h,children:[s.jsx(Sg,{asChild:!0,children:s.jsx(F,{variant:"ghost",size:"icon-sm","aria-label":"打开新的端口预览",title:"打开新的端口预览",children:s.jsx(Js,{})})}),s.jsxs(Tf,{align:"end",className:"port-new-tab w-72",children:[s.jsx("form",{onSubmit:M=>{M.preventDefault();const R=Number(v);Number.isInteger(R)&&R>=1&&R<=65535&&(B(R),g(""))},children:s.jsx(Yn,{children:s.jsxs(Et,{children:[s.jsx(Rt,{htmlFor:`${C}-new-port`,children:"打开端口预览"}),s.jsxs(zi,{children:[s.jsx(yo,{id:`${C}-new-port`,"aria-label":"新预览端口",type:"number",inputMode:"numeric",min:"1",max:"65535",step:"1",required:!0,value:v,onChange:M=>g(M.target.value),placeholder:"如 3000"}),s.jsx(Is,{align:"inline-end",children:s.jsx(bo,{type:"submit",variant:"secondary",disabled:!v,children:"打开"})})]})]})})}),!!L.length&&s.jsxs("div",{className:"port-new-tab-services",role:"group","aria-label":"已发现的开发服务",children:[s.jsx("span",{children:"已发现的服务"}),L.map(M=>s.jsxs("button",{type:"button",className:"port-new-tab-service",title:[M.title??M.process,M.cwd].filter(Boolean).join(" · "),onClick:()=>B(M.port),children:[s.jsx(ho,{"aria-hidden":"true"}),s.jsx("span",{children:M.title||M.process||"开发服务"}),s.jsx("small",{children:M.port})]},M.port))]})]})]})]}),s.jsxs("div",{className:"resource-preview-toolbar",children:[s.jsxs("div",{className:"resource-preview-address",children:[s.jsx(ho,{"aria-hidden":"true"}),!me&&s.jsx("strong",{title:T?.title??`端口 ${r}`,children:T?.title||`端口 ${r}`}),s.jsxs("span",{title:`所连接电脑上的本地服务:127.0.0.1:${r}`,children:["127.0.0.1:",r]})]}),s.jsxs("div",{className:"resource-inline-actions",children:[s.jsx(F,{variant:"ghost",size:"icon",title:"重新加载预览","aria-label":"重新加载预览",onClick:()=>Y(),children:s.jsx(ws,{})}),me?s.jsxs(F,{variant:a?"outline":"ghost",size:"sm","aria-label":a?"退出铺满窗口":"铺满窗口","aria-pressed":a,title:a?"退出铺满窗口":"在当前窗口铺满预览",onClick:()=>l({type:"focus",focused:!a}),children:[a?s.jsx(Tl,{}):s.jsx(Al,{}),a?"退出铺满窗口":"铺满窗口"]}):document.fullscreenEnabled&&s.jsx(F,{variant:"ghost",size:"icon",title:_?"退出全屏":"全屏预览","aria-label":_?"退出全屏":"全屏预览",onClick:()=>{(_?document.exitFullscreen():j.current?.requestFullscreen())?.catch(R=>y(`无法切换全屏:${Ps(R)}`))},children:_?s.jsx(Tl,{}):s.jsx(Al,{})}),!me&&s.jsx(F,{variant:"ghost",size:"icon",title:"关闭预览","aria-label":"关闭预览",onClick:()=>$(r),children:s.jsx(zn,{})})]})]}),T&&!T.http&&s.jsx("p",{className:"resource-caption resource-preview-note",children:"此端口未识别为 HTTP 服务。终端、数据库等服务无法作为网页预览。"}),n.map(M=>s.jsx("div",{className:"port-preview-panel",role:me?"tabpanel":void 0,id:`${C}-panel-${M.port}`,"aria-labelledby":me?`${C}-tab-${M.port}`:void 0,hidden:M.port!==r,children:s.jsx(hre,{port:M.port,retry:()=>Y(M.port)},M.revision)},M.port))]}):!t.loading&&!(me&&S.length)&&s.jsx(an,{icon:s.jsx(jb,{}),title:S.length?"选择一个开发服务":"还没有发现开发服务",description:S.length?"选择上方服务打开预览,或输入端口号访问其他服务。":"先在电脑或终端中启动项目,再刷新服务列表。已知端口号时也可以直接输入。"})]})}const mre="/assets/app-icon-SJEseeVg.png",gre="linkshell-desktop-update",vre="linkshell-desktop-login",xre=5e3,bre=3e5,zo=Cf(()=>({busy:!1,started:!1,settings:{opaqueWindow:!1,autoCheck:!0,updateChannel:"stable"},permissions:{known:!1,recording:!1,control:!1},loginItem:{enabled:!1,approval:!1},loginItemMessage:"",activity:[],signingIn:!1,signInError:"",accountMessage:"",checkingMembership:!1,gatewayMessage:"",passwordMessage:"",passwordIsError:!1,savingPassword:!1,redemptionMessage:"",redemptionIsError:!1,redeeming:!1,commandMessage:"",log:"",update:{checking:!1,installing:!1,available:!1,message:"尚未检查更新"}})),Ve=e=>zo.setState(e),Nt=()=>zo.getState(),zs=e=>e instanceof Error?e.message:String(e);let nu,my,B0=!1,Rd=0,Mg=0,gy=!1;function CR(e={}){Rd++,Ve({...e,busy:!0})}function ka(e){Ve({activity:[{at:Date.now(),text:e},...Nt().activity].slice(0,20)})}function Aa(e){Nt().snapshot?.account?.userId!==e.account?.userId&&(Mg=0,Ve({redemptionMessage:"",redemptionIsError:!1,accountMessage:""})),Ve({snapshot:e})}const yre=e=>e.snapshot?.status==="running"&&!e.problem,_R=e=>e.about?.standalone===!0,ER=e=>{if(_R(e))return e.update.available;const t=e.snapshot?.cliVersion;return!!e.update.latest&&!!t&&wR(e.update.latest,t)};function wre(){!nn||Nt().started||(Ve({started:!0}),window.addEventListener(gre,Pre),window.addEventListener(vre,Ere),Lt("updateStatus").then(e=>{e&&Ve({update:e})},()=>{}),Promise.all([Lt("about"),kre()]).then(([e])=>{Ve({about:e}),!e.standalone&&Nt().settings.autoCheck&&RR()},()=>{}),AR(),CR(),(async()=>{try{Aa(await Lt("startup",{},1e5)),nu=void 0,ka(`桌面启动:后台服务${Nt().snapshot?.status==="running"?"已就绪":"需要检查"}`)}catch(e){const t=zs(e);t.startsWith("服务恢复")?nu=t:my=t,Ve({problem:t}),Ul(t)}Ve({busy:!1}),Bl()})())}function Bl(){if(!nn||B0||Nt().busy)return;B0=!0;const e=Rd;(async()=>{try{const t=await Lt("snapshot",{},3e4);if(Nt().busy||e!==Rd)return;const n=Nt().snapshot;t.status!==n?.status&&ka(t.status==="running"?"本机服务已连接":`本机服务:${t.status==="stopped"?"已停止":"无法连接"}`),n?.gateway?.status&&n.gateway.status!==t.gateway?.status&&ka("网关连接状态已变化"),t.status==="running"&&!t.error&&(my=void 0),Aa(t),Ve({problem:t.error??nu??my}),NR()}catch(t){!Nt().busy&&e===Rd&&Ve({snapshot:void 0,problem:zs(t)})}finally{B0=!1}if(e!==Rd){Nt().busy||Bl();return}Nt().snapshot?.account?.state==="signed-in"&&Date.now()-Mg>bre&&TR()})()}function jre(){Bl();const e=setInterval(Bl,xre);return()=>clearInterval(e)}async function NR(){try{const e=await Lt("permissions",{},15e3);Ve({permissions:{known:!e.unavailable,recording:e.recording,control:e.control,sharing:e.sharing}})}catch{Ve({permissions:{known:!1,recording:!1,control:!1}})}}async function kre(){try{Ve({settings:await Lt("settings")})}catch{}}async function AR(){try{Ve({loginItem:await Lt("loginItem")})}catch{}}async function Go(e,t={}){if(!Nt().busy){CR(t);try{await e()}finally{Ve({busy:!1}),Bl()}}}function zm(e){return Go(async()=>{try{Aa(await Lt("action",{name:e})),e==="recover-update"&&(nu=void 0),ka({start:"已启动本机服务",stop:"已停止本机服务",restart:"已重启本机服务","recover-update":"已恢复后台服务"}[e])}catch(t){const n=zs(t);e==="recover-update"&&(nu=`服务恢复需要处理:${n}`),Ve({problem:e==="recover-update"?nu:n})}},{problem:void 0})}function Tw(e,t){return gy=!1,Go(async()=>{try{const n=await t();if(n.error)throw new Error(n.error);Aa(n),Ve({accountMessage:`登录成功。手机登录同一账号后,可通过官方网关连接${ys}(需要 Pro)。`}),ka("账号已登录")}catch(n){Ve({signInError:gy?"":zs(n)})}finally{Ve({signingIn:!1,signInMethod:void 0,signInLink:void 0})}},{signingIn:!0,signInMethod:e,signInLink:void 0,signInError:"",accountMessage:""})}function Sre(){return Tw("web",()=>Lt("login",{},4e5))}function Cre(e,t){return Tw("password",()=>Lt("loginPassword",{email:e,password:t},9e4))}function _re(e){return Tw(e,()=>Lt("loginOAuth",{provider:e},4e5))}function vy(){gy=!0,Lt("cancelLogin").catch(()=>{})}function YE(){Nt().signInError&&Ve({signInError:""})}function Ere(e){const t=e.detail??{},n=Nt();n.signingIn&&t.provider===n.signInMethod&&typeof t.url=="string"&&Ve({signInLink:t.url})}function Nre(e){return Go(async()=>{try{Aa(await Lt("action",{name:e})),Ve({accountMessage:`已退出${ai}的账号。`})}catch(t){Ve({accountMessage:zs(t)})}},{accountMessage:"正在处理…"})}function TR(){const e=Nt();if(e.snapshot?.account?.state!=="signed-in"||e.busy)return;const t=e.snapshot.account.userId;Mg=Date.now(),Go(async()=>{try{const n=await Lt("action",{name:"account-refresh"});if(Nt().snapshot?.account?.userId!==t)return;Aa(n),n.account?.userId===t&&Ve({accountMessage:n.accountWarning??""})}catch(n){Nt().snapshot?.account?.userId===t&&Ve({accountMessage:zs(n)})}finally{Ve({checkingMembership:!1})}},{checkingMembership:!0})}async function MR(e){if(Nt().busy)return!1;if(e!==null){const n=Lse(e);if(n)return Ve({passwordMessage:n,passwordIsError:!0}),!1}let t=!1;return await Go(async()=>{try{const n=e===null?await Lt("action",{name:"remove-password"}):await Lt("action",{name:"set-password",input:{password:e}});if(n.error)throw new Error(n.error);Aa(n),t=!0,Ve({passwordMessage:e===null?"已移除访问密码。":`已设置访问密码。其他设备下次打开${ai}时需要输入。`}),ka(e===null?"访问密码已移除":"访问密码已设置")}catch(n){Ve({passwordMessage:zs(n),passwordIsError:!0})}finally{Ve({savingPassword:!1})}},{savingPassword:!0,passwordMessage:"",passwordIsError:!1}),t}async function Are(e){if(Nt().busy)return!1;let t=!1;return await Go(async()=>{try{const n=e.kind==="official"?await Lt("action",{name:"connect-gateway"}):await Lt("action",{name:"set-gateway",input:{gateway:e.kind==="off"?"off":e.url}});if(n.error)throw new Error(n.error);Aa(n),t=!0,ka(e.kind==="official"?"已切换到官方网关":e.kind==="off"?"已关闭网关":`已切换到自建网关 ${e.url}`)}catch(n){Ve({gatewayMessage:zs(n)})}},{gatewayMessage:""}),t}function U0(){Ve({gatewayMessage:""})}function Tre(){Ve({passwordMessage:"",passwordIsError:!1})}async function Mre(e){const t=Nt(),n=t.snapshot?.account?.userId;if(t.busy||!n||cy(t.snapshot?.account).kind!=="free")return!1;const r=Pse(e);if(r)return Ve({redemptionMessage:r,redemptionIsError:!0}),!1;let a=!1;return await Go(async()=>{try{const l=await Lt("action",{name:"redeem-pro",input:{code:e.trim(),userId:n}});if(Nt().snapshot?.account?.userId!==n||(Aa(l),l.account?.userId!==n))return;if(l.redemption?.userId!==n||cy(l.account).kind!=="pro")throw new Error("尚未确认 Pro 有效期,请刷新会员状态后重试。");a=!0,Mg=Date.now(),Ve({redemptionMessage:l.redemption.idempotent?"该激活码已为当前账号兑换,Pro 会员状态已更新。":"兑换成功,Pro 会员已开通。",accountMessage:l.accountWarning??""}),ka("Pro 会员状态已更新")}catch(l){Nt().snapshot?.account?.userId===n&&Ve({redemptionMessage:zs(l),redemptionIsError:!0})}finally{Ve({redeeming:!1})}},{redeeming:!0,redemptionMessage:"",redemptionIsError:!1}),a}async function WE(){try{Ve({log:(await Lt("log")).text})}catch(e){Ve({log:zs(e)})}}async function zre(e){try{await Lt("setScreenSharing",{enabled:e})}catch(t){Ul(t)}await NR()}async function Rre(){try{Ve({commandMessage:`已复制:${(await Lt("copyCommandPath")).path}`})}catch(e){Ve({commandMessage:zs(e)})}}async function Dre(){try{Ve({commandMessage:`已安装:${(await Lt("installCommand")).path}。请将 ~/.local/bin 加入 PATH。`})}catch(e){Ve({commandMessage:zs(e)})}}async function Ore(e){try{Ve({loginItem:await Lt("setLoginItem",{enabled:e}),loginItemMessage:""})}catch(t){Ve({loginItemMessage:zs(t)}),AR()}}async function xy(e,t){const n=Nt().settings;Ve({settings:{...n,[e]:t}}),e==="updateChannel"&&Ve({update:{...Nt().update,available:!1,version:void 0,message:"通道已切换,检查更新后生效"}});try{await Lt("setSetting",{key:e,value:t})}catch(r){Ve({settings:n}),Ul(r)}}function zR(){Lt("openSetup").catch(e=>Ul(e))}function Ire(){Lt("openLoginItems").catch(()=>{})}async function RR(){const e=Nt();if(!(e.update.checking||e.update.installing)){try{if((await Lt("checkUpdates")).started)return}catch{}Ve({update:{...Nt().update,checking:!0,message:"正在检查…"}});try{const t=await fetch("https://registry.npmjs.org/linkshell-cli/latest",{cache:"no-store",credentials:"omit",signal:AbortSignal.timeout(15e3)}),n=await t.json();if(!t.ok||typeof n.version!="string")throw new Error("版本信息无效");const r=n.version,a=Nt().snapshot?.cliVersion,l=a?wR(r,a)?`有新版本 ${r}`:"当前已是最新稳定版":`最新稳定版 ${r};当前 CLI 版本未知`;Ve({update:{...Nt().update,checking:!1,latest:r,message:l,checkedAt:Date.now()}})}catch(t){Ve({update:{...Nt().update,checking:!1,message:`检查失败:${zs(t)}`,checkedAt:Date.now()}})}}}function $re(){return Go(async()=>{Ve({update:{...Nt().update,message:"正在更新 CLI 和 Host…"}});try{const e=await Lt("upgrade",{},25e4);Ve({update:{...Nt().update,message:e.message??"更新完成。"}}),ka("CLI 更新完成")}catch(e){Ve({update:{...Nt().update,message:zs(e)}})}})}function Lre(){Nt().update.checking||Nt().update.installing||(Ve({update:{...Nt().update,message:"正在打开更新窗口…"}}),Lt("installUpdate").catch(e=>Ve({update:{...Nt().update,message:`更新未完成:${zs(e)}`}})))}function Pre(e){const t=e.detail??{},n=Nt().update,r=typeof t.message=="string"?t.message:n.message;switch(t.name){case"checking":Ve({update:{...n,checking:!0,message:r}});break;case"available":Ve({update:{...n,available:!0,version:typeof t.version=="string"?t.version:n.version,message:r,checkedAt:Date.now()}});break;case"current":Ve({update:{...n,available:!1,message:r,checkedAt:Date.now()}});break;case"message":Ve({update:{...n,message:r}});break;case"installing":Ve({update:{...n,installing:!0,message:r}});break;case"finished":Ve({update:{...n,checking:!1,installing:!1}});break}}function Hp({className:e,...t}){return s.jsx(zB,{"data-slot":"switch",className:je("peer inline-flex h-[18px] w-8 shrink-0 items-center rounded-full border border-transparent bg-[var(--quaternaryLabel)] transition-colors outline-none focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary",e),...t,children:s.jsx(DB,{"data-slot":"switch-thumb",className:"pointer-events-none block size-3.5 rounded-full bg-[var(--plain)] ring-0 transition-transform data-[state=checked]:translate-x-[15px] data-[state=checked]:bg-primary-foreground data-[state=unchecked]:translate-x-px"})})}const Bre=["#4a6cf7","#7d95ff"],Ure=["#4a6cf7","#4466f6"],Fre=["rgba(74,108,247,0.11)","rgba(125,149,255,0.18)"],qre=["#4a6cf7","#7d95ff"],Hre=["rgba(232,131,12,0.12)","rgba(255,166,61,0.16)"],Vre=["rgba(15,149,96,0.12)","rgba(61,214,140,0.15)"],Gre=["rgba(220,61,61,0.10)","rgba(255,107,107,0.15)"],Zre=["#F0F0F4","#26262B"],Kre=["#f1f1f6","#1c1c22"],Yre=["#2a2b35","#e4e4ec"],Wre=["rgba(15,149,96,0.12)","rgba(61,214,140,0.14)"],Xre=["rgba(220,61,61,0.10)","rgba(255,107,107,0.14)"],Qre=["#0b7a4f","#7fddb4"],Jre=["#b42f2f","#ff9a9a"],eie=["#000000","#FFFFFF"],tie=["rgba(60,60,67,0.6)","rgba(235,235,245,0.6)"],nie=["rgba(60,60,67,0.3)","rgba(235,235,245,0.3)"],sie=["rgba(60,60,67,0.3)","rgba(235,235,245,0.3)"],rie=["rgba(60,60,67,0.18)","rgba(84,84,88,0.6)"],iie=["#F2F2F7","#000000"],aie=["#FFFFFF","#1C1C1E"],oie=["#FFFFFF","#2C2C2E"],lie=["#F2F2F7","#1C1C1E"],cie=["#FFFFFF","#000000"],uie=["rgba(118,118,128,0.12)","rgba(118,118,128,0.24)"],die=["rgba(120,120,128,0.16)","rgba(120,120,128,0.32)"],fie=["#E8830C","#FF9F0A"],hie=["#0F9560","#30D158"],pie=["#DC3D3D","#FF453A"],mie=["#F2F2F7","#1C1C1E"],gie=["#FFFFFF","#2C2C2E"],DR={accent:Bre,accentFill:Ure,accentSoft:Fre,running:qre,waitingSoft:Hre,okSoft:Vre,dangerSoft:Gre,userBubble:Zre,code:Kre,codeText:Yre,diffAdd:Wre,diffDel:Xre,diffAddText:Qre,diffDelText:Jre,label:eie,secondaryLabel:tie,tertiaryLabel:nie,placeholder:sie,separator:rie,background:iie,card:aie,cardRaised:oie,inset:lie,plain:cie,fill:uie,fillStrong:die,waiting:fie,ok:hie,danger:pie,sheet:mie,sheetCard:gie},OR={background:["#f6f6f8","#08090a"],plain:["#ffffff","#0f1011"],card:["#ffffff","#131417"],cardRaised:["#ffffff","#16171a"],inset:["#f1f1f4","#0b0c0d"],label:["#17181b","#f0f1f3"],secondaryLabel:["#5c5f68","#a0a3ab"],tertiaryLabel:["#8a8d96","#70737b"],quaternaryLabel:["#aeb0b8","#4e5059"],separator:["#0000000f","#ffffff12"],separatorStrong:["#00000020","#ffffff1f"],fill:["#1b1c200a","#ffffff0a"],fillStrong:["#1b1c2014","#ffffff14"],sidebarBackground:["#f6f6f8","#08090a"],sidebarAccent:["#00000010","#ffffff14"],code:["#f3f3f6","#0b0c0d"],codeText:["#30323b","#dedfe8"],userBubble:["#ececf1","#1a1b1f"],accent:["#5e6ad2","#6872e5"],accentHover:["#515dc0","#7681ec"],accentSoft:["#5e6ad214","#6872e524"],primaryForeground:["#ffffff","#ffffff"],link:["#5260c5","#9aa5ff"],success:["#218058","#6cc29a"],ok:["#218058","#6cc29a"],warning:["#917021","#d8b76c"],waiting:["#917021","#d8b76c"],waitingSoft:["#9170210d","#d8b76c10"],info:["#5260c5","#9aa5ff"],running:["#5260c5","#9aa5ff"],danger:["#c03e48","#f08891"]},F0=e=>Object.entries({...DR,...OR,...IR}).map(([t,n])=>`--${t}: ${n[e]};`).join(`
|
|
822
822
|
`),IR={"code-foreground":["currentColor","currentColor"],"code-background":["transparent","transparent"],"code-token-keyword":["#ab4f7a","#f8a6c8"],"code-token-string":["#3a843f","#83d197"],"code-token-string-expression":["#3a843f","#83d197"],"code-token-function":["#1f4e94","#63a8f8"],"code-token-constant":["#ac4f23","#f1a275"],"code-token-parameter":["#643cae","#b897f4"],"code-token-comment":["#1a1c1f80","#ffffff73"],"code-token-punctuation":["currentColor","currentColor"],"code-token-link":["#1f4e94","#63a8f8"],"code-token-inserted":["#3a843f","#83d197"],"code-token-deleted":["#c0271f","#f8a6a3"],"code-token-changed":["#ac4f23","#f1a275"]},vie=`
|
|
823
823
|
:root { ${F0(0)} color-scheme: light; }
|
|
824
824
|
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { ${F0(1)} color-scheme: dark; } }
|