@linkshell/gateway 0.6.47 → 0.6.48
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/{highlight-engine-C0ncfjMp.js → highlight-engine-Cp6ksLJU.js} +1 -1
- package/web-client/assets/{index-D0Gc4UeJ.js → index-CxbpSowb.js} +2 -2
- package/web-client/assets/{qr-scanner.min-BW5Ya5ED.js → qr-scanner.min-BhmL6roF.js} +1 -1
- package/web-client/assets/render-BLHKh2Fv.css +1 -0
- package/web-client/assets/{render-B5pFejXi.js → render-CA_iNo75.js} +4 -4
- package/web-client/index.html +1 -1
- package/web-client/assets/render-Cb-N_5Eh.css +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlight-engine-
|
|
2
|
-
import{r as rN,g as a8,a as m,R as Ro,j as s,b as Ed,M as o8,c as l8,d as c8}from"./markdown-gsWh3zpl.js";import{_ as fo,a as iN,b as u8,c as d8}from"./account-R7yD1rZE.js";import{i as me,_ as Z0,r as wy,s as jy,d as f8,a as Gp,D as h8,b as p8,c as K0,e as m8,f as Jn,g as g8,h as br,j as v8,k as x8,o as Rm,l as bS,m as b8,n as y8,p as w8,q as j8,t as ky,u as Zp,v as ru,w as k8,x as yS,y as Wt,z as Lt,A as Ul,T as ai,B as ys,C as S8,E as C8,R as Sy,F as Cy,G as aN,H as _8,I as wS}from"./index-D0Gc4UeJ.js";import{D as E8,o as N8}from"./terminal-DWFexEE4.js";function oN(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=oN(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function lN(){for(var e,t,n=0,r="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=oN(e))&&(r&&(r+=" "),r+=t);return r}const A8=(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},T8=(e,t)=>({classGroupId:e,validator:t}),cN=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Kp="-",jS=[],M8="arbitrary..",z8=e=>{const t=D8(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{if(c.startsWith("[")&&c.endsWith("]"))return R8(c);const d=c.split(Kp),f=d[0]===""&&d.length>1?1:0;return uN(d,f,t)},getConflictingClassGroupIds:(c,d)=>{if(d){const f=r[c],h=n[c];return f?h?A8(h,f):f:h||jS}return n[c]||jS}}},uN=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const a=e[t],l=n.nextPart.get(a);if(l){const h=uN(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}},R8=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?M8+r:void 0})(),D8=e=>{const{theme:t,classGroups:n}=e;return O8(n,t)},O8=(e,t)=>{const n=cN();for(const r in e){const a=e[r];_y(a,n,r,t)}return n},_y=(e,t,n,r)=>{const a=e.length;for(let l=0;l<a;l++){const c=e[l];I8(c,t,n,r)}},I8=(e,t,n,r)=>{if(typeof e=="string"){$8(e,t,n);return}if(typeof e=="function"){L8(e,t,n,r);return}P8(e,t,n,r)},$8=(e,t,n)=>{const r=e===""?t:dN(t,e);r.classGroupId=n},L8=(e,t,n,r)=>{if(B8(e)){_y(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(T8(n,e))},P8=(e,t,n,r)=>{const a=Object.entries(e),l=a.length;for(let c=0;c<l;c++){const[d,f]=a[c];_y(f,dN(t,d),n,r)}},dN=(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=cN(),n.nextPart.set(c,d)),n=d}return n},B8=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,U8=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="!",kS=":",F8=[],SS=(e,t,n,r,a)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:a}),q8=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===kS){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 SS(l,y,x,j)};if(t){const a=t+kS,l=r;r=c=>c.startsWith(a)?l(c.slice(a.length)):SS(F8,!1,c,void 0,!0)}if(n){const a=r;r=l=>n({className:l,parseClassName:a})}return r},H8=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}},V8=e=>({cache:U8(e.cacheSize),parseClassName:q8(e),sortModifiers:H8(e),postfixLookupClassGroupIds:G8(e),...z8(e)}),G8=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},Z8=/\s+/,K8=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:l,postfixLookupClassGroupIds:c}=t,d=[],f=e.trim().split(Z8);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},Y8=(...e)=>{let t=0,n,r,a="";for(;t<e.length;)(n=e[t++])&&(r=fN(n))&&(a&&(a+=" "),a+=r);return a},fN=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=fN(e[r]))&&(n&&(n+=" "),n+=t);return n},W8=(e,...t)=>{let n,r,a,l;const c=f=>{const h=t.reduce((v,g)=>g(v),e());return n=V8(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=K8(f,n);return a(f,v),v};return l=c,(...f)=>l(Y8(...f))},X8=[],Kn=e=>{const t=n=>n[e]||X8;return t.isThemeGetter=!0,t.themeKey=e,t},hN=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,pN=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Q8=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,J8=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,eI=/\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$/,tI=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,nI=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,sI=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,to=e=>Q8.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=>J8.test(e),mN=()=>!0,rI=e=>eI.test(e)&&!tI.test(e),Ey=()=>!1,iI=e=>nI.test(e),aI=e=>sI.test(e),oI=e=>!Be(e)&&!Ue(e),lI=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)),cI=e=>Do(e,xN,Ey),Be=e=>hN.test(e),dl=e=>Do(e,bN,rI),CS=e=>Do(e,vI,St),uI=e=>Do(e,wN,mN),dI=e=>Do(e,yN,Ey),_S=e=>Do(e,gN,Ey),fI=e=>Do(e,vN,aI),Kh=e=>Do(e,jN,iI),Ue=e=>pN.test(e),vd=e=>Fl(e,bN),hI=e=>Fl(e,yN),ES=e=>Fl(e,gN),pI=e=>Fl(e,xN),mI=e=>Fl(e,vN),Yh=e=>Fl(e,jN,!0),gI=e=>Fl(e,wN,!0),Do=(e,t,n)=>{const r=hN.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Fl=(e,t,n=!1)=>{const r=pN.exec(e);return r?r[1]?t(r[1]):n:!1},gN=e=>e==="position"||e==="percentage",vN=e=>e==="image"||e==="url",xN=e=>e==="length"||e==="size"||e==="bg-size",bN=e=>e==="length",vI=e=>e==="number",yN=e=>e==="family-name",wN=e=>e==="number"||e==="weight",jN=e=>e==="shadow",xI=()=>{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(),ES,_S,{position:[Ue,Be]}],Z=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ne=()=>["auto","cover","contain",pI,cI,{size:[Ue,Be]}],ie=()=>[Px,vd,dl],de=()=>["","none","full",h,Ue,Be],oe=()=>["",St,vd,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,ES,_S],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:[mN],container:[ra],"drop-shadow":[ra],ease:["in","out","in-out"],font:[oI],"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":[lI],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,vd,dl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,gI,uI]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Px,Be]}],"font-family":[{font:[hI,dI,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,CS]}],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]},mI,fI]}],"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,vd,dl]}],"outline-color":[{outline:K()}],shadow:[{shadow:["","inner","none",v,Yh,Kh]}],"shadow-color":[{shadow:K()}],"inset-shadow":[{"inset-shadow":["none",g,Yh,Kh]}],"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,Yh,Kh]}],"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,Yh,Kh]}],"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,vd,dl,CS]}],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"]}},bI=W8(xI);function je(...e){return bI(lN(e))}var Bx={exports:{}},_s={};/**
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/highlight-engine-Cp6ksLJU.js","assets/index-CxbpSowb.js","assets/index-DEJBGTqg.css","assets/markdown-gsWh3zpl.js","assets/qr-scanner.min-BhmL6roF.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as rN,g as a8,a as m,R as Ro,j as s,b as Ed,M as o8,c as l8,d as c8}from"./markdown-gsWh3zpl.js";import{_ as fo,a as iN,b as u8,c as d8}from"./account-R7yD1rZE.js";import{i as me,_ as Z0,r as wy,s as jy,d as f8,a as Gp,D as h8,b as p8,c as K0,e as m8,f as Jn,g as g8,h as br,j as v8,k as x8,o as Rm,l as bS,m as b8,n as y8,p as w8,q as j8,t as ky,u as Zp,v as ru,w as k8,x as yS,y as Wt,z as Lt,A as Ul,T as ai,B as ys,C as S8,E as C8,R as Sy,F as Cy,G as aN,H as _8,I as wS}from"./index-CxbpSowb.js";import{D as E8,o as N8}from"./terminal-DWFexEE4.js";function oN(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=oN(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function lN(){for(var e,t,n=0,r="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=oN(e))&&(r&&(r+=" "),r+=t);return r}const A8=(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},T8=(e,t)=>({classGroupId:e,validator:t}),cN=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Kp="-",jS=[],M8="arbitrary..",z8=e=>{const t=D8(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:c=>{if(c.startsWith("[")&&c.endsWith("]"))return R8(c);const d=c.split(Kp),f=d[0]===""&&d.length>1?1:0;return uN(d,f,t)},getConflictingClassGroupIds:(c,d)=>{if(d){const f=r[c],h=n[c];return f?h?A8(h,f):f:h||jS}return n[c]||jS}}},uN=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const a=e[t],l=n.nextPart.get(a);if(l){const h=uN(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}},R8=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?M8+r:void 0})(),D8=e=>{const{theme:t,classGroups:n}=e;return O8(n,t)},O8=(e,t)=>{const n=cN();for(const r in e){const a=e[r];_y(a,n,r,t)}return n},_y=(e,t,n,r)=>{const a=e.length;for(let l=0;l<a;l++){const c=e[l];I8(c,t,n,r)}},I8=(e,t,n,r)=>{if(typeof e=="string"){$8(e,t,n);return}if(typeof e=="function"){L8(e,t,n,r);return}P8(e,t,n,r)},$8=(e,t,n)=>{const r=e===""?t:dN(t,e);r.classGroupId=n},L8=(e,t,n,r)=>{if(B8(e)){_y(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(T8(n,e))},P8=(e,t,n,r)=>{const a=Object.entries(e),l=a.length;for(let c=0;c<l;c++){const[d,f]=a[c];_y(f,dN(t,d),n,r)}},dN=(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=cN(),n.nextPart.set(c,d)),n=d}return n},B8=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,U8=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="!",kS=":",F8=[],SS=(e,t,n,r,a)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:a}),q8=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===kS){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 SS(l,y,x,j)};if(t){const a=t+kS,l=r;r=c=>c.startsWith(a)?l(c.slice(a.length)):SS(F8,!1,c,void 0,!0)}if(n){const a=r;r=l=>n({className:l,parseClassName:a})}return r},H8=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}},V8=e=>({cache:U8(e.cacheSize),parseClassName:q8(e),sortModifiers:H8(e),postfixLookupClassGroupIds:G8(e),...z8(e)}),G8=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},Z8=/\s+/,K8=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:a,sortModifiers:l,postfixLookupClassGroupIds:c}=t,d=[],f=e.trim().split(Z8);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},Y8=(...e)=>{let t=0,n,r,a="";for(;t<e.length;)(n=e[t++])&&(r=fN(n))&&(a&&(a+=" "),a+=r);return a},fN=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=fN(e[r]))&&(n&&(n+=" "),n+=t);return n},W8=(e,...t)=>{let n,r,a,l;const c=f=>{const h=t.reduce((v,g)=>g(v),e());return n=V8(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=K8(f,n);return a(f,v),v};return l=c,(...f)=>l(Y8(...f))},X8=[],Kn=e=>{const t=n=>n[e]||X8;return t.isThemeGetter=!0,t.themeKey=e,t},hN=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,pN=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Q8=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,J8=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,eI=/\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$/,tI=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix|color|light-dark)\(.+\)$/,nI=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,sI=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,to=e=>Q8.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=>J8.test(e),mN=()=>!0,rI=e=>eI.test(e)&&!tI.test(e),Ey=()=>!1,iI=e=>nI.test(e),aI=e=>sI.test(e),oI=e=>!Be(e)&&!Ue(e),lI=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)),cI=e=>Do(e,xN,Ey),Be=e=>hN.test(e),dl=e=>Do(e,bN,rI),CS=e=>Do(e,vI,St),uI=e=>Do(e,wN,mN),dI=e=>Do(e,yN,Ey),_S=e=>Do(e,gN,Ey),fI=e=>Do(e,vN,aI),Kh=e=>Do(e,jN,iI),Ue=e=>pN.test(e),vd=e=>Fl(e,bN),hI=e=>Fl(e,yN),ES=e=>Fl(e,gN),pI=e=>Fl(e,xN),mI=e=>Fl(e,vN),Yh=e=>Fl(e,jN,!0),gI=e=>Fl(e,wN,!0),Do=(e,t,n)=>{const r=hN.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Fl=(e,t,n=!1)=>{const r=pN.exec(e);return r?r[1]?t(r[1]):n:!1},gN=e=>e==="position"||e==="percentage",vN=e=>e==="image"||e==="url",xN=e=>e==="length"||e==="size"||e==="bg-size",bN=e=>e==="length",vI=e=>e==="number",yN=e=>e==="family-name",wN=e=>e==="number"||e==="weight",jN=e=>e==="shadow",xI=()=>{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(),ES,_S,{position:[Ue,Be]}],Z=()=>["no-repeat",{repeat:["","x","y","space","round"]}],ne=()=>["auto","cover","contain",pI,cI,{size:[Ue,Be]}],ie=()=>[Px,vd,dl],de=()=>["","none","full",h,Ue,Be],oe=()=>["",St,vd,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,ES,_S],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:[mN],container:[ra],"drop-shadow":[ra],ease:["in","out","in-out"],font:[oI],"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":[lI],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,vd,dl]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,gI,uI]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Px,Be]}],"font-family":[{font:[hI,dI,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,CS]}],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]},mI,fI]}],"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,vd,dl]}],"outline-color":[{outline:K()}],shadow:[{shadow:["","inner","none",v,Yh,Kh]}],"shadow-color":[{shadow:K()}],"inset-shadow":[{"inset-shadow":["none",g,Yh,Kh]}],"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,Yh,Kh]}],"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,Yh,Kh]}],"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,vd,dl,CS]}],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"]}},bI=W8(xI);function je(...e){return bI(lN(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 tJ={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"},nJ=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 W5(e){if(!e)return;const t=e.toLowerCase(),n=tJ[t]??t;return nJ.has(n)?n:void 0}const lE={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 X5(e){const t=e.split(/[\\/]/).at(-1).toLowerCase();if(lE[t])return lE[t];if(t.startsWith("dockerfile."))return"dockerfile";const n=t.lastIndexOf(".");return n>0?W5(t.slice(n+1)):void 0}const sJ=6e4,rJ=2e3;function iJ(e){if(e.length>sJ)return!1;let t=1;for(let n=e.indexOf(`
|
|
754
754
|
`);n!==-1;n=e.indexOf(`
|
|
755
|
-
`,n+1))if(++t>rJ)return!1;return!0}const bl=new Map,aJ=200;function oJ(e,t){bl.delete(e),bl.set(e,t),bl.size>aJ&&bl.delete(bl.keys().next().value)}const lJ=()=>new Promise(e=>{typeof requestIdleCallback=="function"?requestIdleCallback(()=>e(),{timeout:300}):setTimeout(e,16)});function Sm(e,t,n=!0){const r=W5(t),a=r&&`${r}\0${e}`,[l,c]=m.useState();if(m.useEffect(()=>{if(!n||!a||!r||bl.has(a)||!iJ(e))return;let d=!0;return lJ().then(()=>d?Z0(()=>import("./highlight-engine-
|
|
755
|
+
`,n+1))if(++t>rJ)return!1;return!0}const bl=new Map,aJ=200;function oJ(e,t){bl.delete(e),bl.set(e,t),bl.size>aJ&&bl.delete(bl.keys().next().value)}const lJ=()=>new Promise(e=>{typeof requestIdleCallback=="function"?requestIdleCallback(()=>e(),{timeout:300}):setTimeout(e,16)});function Sm(e,t,n=!0){const r=W5(t),a=r&&`${r}\0${e}`,[l,c]=m.useState();if(m.useEffect(()=>{if(!n||!a||!r||bl.has(a)||!iJ(e))return;let d=!0;return lJ().then(()=>d?Z0(()=>import("./highlight-engine-Cp6ksLJU.js"),__vite__mapDeps([0,1,2,3])).then(f=>f.tokenize(e,r)):void 0).then(f=>{f&&(oJ(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 cJ(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 rf({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 Q5({steps:e,open:t,onToggle:n}){const r=ZX(e),a=YX(r),l=WX(r);return s.jsxs("button",{type:"button",className:"steps-summary","aria-expanded":t,onClick:n,children:[s.jsx(ou,{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(rf,{added:r.added,removed:r.removed,className:"steps-summary-diff"}),s.jsx(li,{className:"steps-summary-chevron","aria-hidden":"true"})]})}function af({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),J5=m.createContext(void 0),ez=m.createContext(!0);function Wb(e){return typeof e=="string"||typeof e=="number"?String(e):Array.isArray(e)?e.map(Wb).join(""):m.isValidElement(e)?Wb(e.props.children):""}function uJ({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 dJ({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(()=>Wb(t).replace(/\n$/,""),[t]),l=Sm(a,r,m.useContext(ez)),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(uJ,{tokens:l}):a})}),s.jsx(it,{error:h.error?"无法访问剪贴板,请选中代码后复制。":void 0})]})}function fJ({href:e,children:t}){const n=m.useContext(Vo),r=e&&cJ(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 hJ=[l8],pJ=e=>e.startsWith("file://")?e:c8(e),mJ={pre:({children:e})=>s.jsx(dJ,{children:e}),a:({href:e,children:t})=>s.jsx(fJ,{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||"查看图片"," ↗"]})},tz=m.memo(function({text:t}){return s.jsx(o8,{remarkPlugins:hJ,urlTransform:pJ,components:mJ,children:t})});function ja({text:e}){return s.jsx("div",{className:"markdown",children:s.jsx(tz,{text:e})})}function cE({text:e,streaming:t}){const n=JQ(e,t),r=m.useMemo(()=>eJ(n),[n]);return s.jsx("div",{className:"markdown",children:r.map((a,l)=>s.jsx("div",{className:"markdown-block",children:s.jsx(ez.Provider,{value:!t||l<r.length-1,children:s.jsx(tz,{text:a})})},l))})}function nz({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(k1,{})})}),s.jsx(T1,{asChild:!0,children:s.jsx(F,{variant:"ghost",size:"icon-sm","aria-label":"关闭",children:s.jsx(zn,{})})})]})]})]})}function gJ({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(nz,{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 uE({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(nz,{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(gJ,{block:r,sessionId:t},a):r.type==="audio"?s.jsx(uE,{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(af,{text:r.resource.text,label:"复制附件文本"}),s.jsx("pre",{tabIndex:0,children:r.resource.text})]}):s.jsx(uE,{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 fw(e){return e.type==="diff"?cw(e.oldText??"",e.newText):N5(e.diff)}function sz({lines:e,path:t}){const n=m.useMemo(()=>LX(e),[e]),r=t?X5(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(vJ,{text:g.text,tokens:f(g)}):" "})]},x))]},v)),!n.length&&s.jsx("div",{className:"diff-skip",children:"没有内容变化"})]})}function vJ({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 hw({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(()=>fw(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(rf,{added:a.added,removed:a.removed})]}),s.jsx(sz,{lines:r,path:e.type==="patch"&&e.movePath?e.movePath:e.path})]})}function xJ({blocks:e,sessionId:t,onFile:n}){const r=Cf(e),a=dM(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 dE(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(hC,{"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(hw,{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(hC,{"data-icon":"inline-start"}),l.busy?"正在打开…":"打开编辑器"]})]}):s.jsx(an,{title:"还没有可用的编辑 Agent",description:"请先在电脑上安装 ACP Agent,并在 Agent 设置中启用编辑建议,再返回这里编辑文件。"})]})}async function VJ(e,t,n){const r=window.showSaveFilePicker,a=()=>{if(n.signal?.aborted)throw uw()};if(r){const f=await r.call(window,{suggestedName:Q_(t)});a();const h=await f.createWritable();try{await J_(e,t,v=>h.write(v),n),a(),await h.close()}catch(v){throw await h.abort().catch(()=>{}),v}return"saved"}const l=[];await J_(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=Q_(t),document.body.appendChild(d);try{d.click()}finally{d.remove(),setTimeout(()=>URL.revokeObjectURL(c),6e4)}return"downloaded"}function gz(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 VJ(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 GJ({path:e}){const t=gz(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(k1,{"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 ZJ(e,t){if(t?.kind==="image")return"image";if(t?.kind==="text"&&/\.(md|markdown|mdx)$/i.test(e))return"markdown"}function KJ({path:e,line:t,close:n,onDirtyChange:r,content:a}){const{loaded:l,file:c,more:d,job:f}=a,h=gz(e),[v,g]=m.useState(!1),[x,y]=m.useState(!1),[j,k]=m.useState(),C=ZJ(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(mz,{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(s6,{})}),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(yf,{})})}),s.jsxs(Ms,{align:"end",children:[c?.kind==="text"&&!c.truncated&&s.jsxs(mt,{onSelect:()=>g(!0),children:[s.jsx(DU,{}),"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(k1,{}),"下载到这台电脑"]}),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(YJ,{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 YJ({text:e,path:t,line:n,wrap:r}){const a=m.useMemo(()=>e.replace(/\n$/,"").split(`
|
|
773
773
|
`),[e]),l=Sm(a.join(`
|
|
774
|
-
`),X5(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(WJ,{text:d,tokens:l?.[f]})})]},f))})}function WJ({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 xw(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 vz(e,t){const{link:n}=Dt(),r=$t(),a=Rn(()=>FJ(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?UJ(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:pz(d,v)})}),job:r}}function xz(e){return me?s.jsx(XJ,{...e}):s.jsx(QJ,{...e})}function XJ(e){const t=vz(e.path,e.line);return s.jsx(KJ,{...e,content:t})}function QJ({path:e,line:t,close:n,onDirtyChange:r}){const a=m.useRef(null),{loaded:l,file:c,highlighted:d,more:f,job:h}=vz(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(mz,{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(Zd,{"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(GJ,{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(s6,{"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 Nf({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 xw(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("")},Vt=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(Wd,{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(IU,{})}),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(Yd,{"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(yf,{})})}),s.jsxs(Ms,{align:"end",children:[s.jsxs(mt,{disabled:!Le,onSelect:ht,children:[s.jsx(Yd,{}),"上传文件"]}),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(KQ,{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:Vt}),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(gw,{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(Zd,{"data-icon":"inline-start"}):s.jsx(F3,{"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:Vt}),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(vw,{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(Zd,{"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(xz,{path:k,line:_,close:()=>void ze(),onDirtyChange:T},`${k}:${_??""}`)})]})]})}const JJ="https://mkbeusztkzffnzjdwmqk.supabase.co",eee="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1rYmV1c3p0a3pmZm56amR3bXFrIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjU5Nzc0NzgsImV4cCI6MjA4MTU1MzQ3OH0.2wlT6q6687Z5rpEYsdp01IQpNNl_XWv0IAfBgwPyDP0";let tee;function bz(){return{supabaseUrl:window.__LINKSHELL_CONFIG__?.account?.url??JJ,anonKey:window.__LINKSHELL_CONFIG__?.account?.anonKey??eee}}function nu(){if(me)throw new Error("桌面端使用 LinkShell 的系统浏览器登录");const{supabaseUrl:e,anonKey:t}=bz();return tee??=d8(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 Bd(e,t){if(!e)throw new Error("登录已失效,请重新登录");if(e!==t)throw new Error("账号已切换,请在当前账户下重新操作")}async function yz(e){if(me){const l=await Gp();return e!==void 0&&Bd(l.userId,e),l.accessToken}const t=nu().auth,{data:n,error:r}=await t.getSession();if(r)throw r;if(e!==void 0&&Bd(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&&Bd(a.data.session.user.id,e),a.data.session.access_token}async function bw(e){if(me){const r=await Gp();if(Bd(r.userId,e),!r.accessToken)throw new Error("登录已失效,请重新登录");return{access_token:r.accessToken}}const{data:t,error:n}=await nu().auth.getSession();if(n)throw n;if(!t.session)throw new Error("登录已失效,请重新登录");return Bd(t.session.user.id,e),t.session}async function wz(e){const t=await yz(e),n=await bw(e);if(!t||n.access_token!==t)throw new Error("账号状态已更新,请重试");return t}async function nee(e){const t=await wz(e),n=await yQ({...bz(),accessToken:t,userId:e});return await bw(e),n}async function see(e,t){const n=await wz(e),r=await jQ(n,t);return await bw(e),r}const ree=e=>{const t=new RTCPeerConnection({iceServers:e.map(r=>({urls:r}))}),n=t.createDataChannel(bW,{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 iee{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,Hc=e=>`@shared:${e}`;function pE(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[Hc(e.key)])||t[e.key]||e.machine.name||"电脑"}function Af(e){return`${{darwin:"macOS",linux:"Linux",win32:"Windows"}[e.machine.platform??""]||e.machine.platform||"电脑"} · ${e.machine.id.slice(0,8)}`}function jz(e,t){return`${Mn(e,t)} · ${e.machine.id.slice(0,8)} · ${e.machine.online?"在线":"离线"}`}function aee(){const e=_f(()=>pE(dn("computer-names",{}))),t=new Map,n=()=>{const a=pE(dn("computer-names",{})),l={...a};for(const[c,d]of t){if(a[Hc(c)]!==d.saved){t.delete(c);continue}l[Hc(c)]=d.name,delete l[c]}return{saved:a,next:l}},r=(a,l)=>{const{saved:c,next:d}=n();if(d[Hc(a.key)]===l&&!d[a.key]&&!t.size){e.setState(d,!0);return}delete d[a.key],d[Hc(a.key)]=l,t.set(a.key,{name:l,saved:c[Hc(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=aee();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 oee(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 lee=dn("source",pa),kz=pa==="self-hosted"?"self-hosted":lee,cee=kz==="official"?Ks:dn("gateway",PQ),mE="网关未确认当前账号,请退出账号后重新登录。";function uee(e){switch(e.code){case"disconnected":case"connect_failed":return"与网关的连接断开了,正在自动重连…";case"replaced":return"这台设备已在别处连上网关";default:return e.message}}class dee{state=_f(()=>({source:kz,gateway:cee,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 iee(t=>this.openComputer(t));releaseSelected;channel=typeof BroadcastChannel<"u"?new BroadcastChannel("linkshell.web.owner"):void 0;constructor(){me&&(window.addEventListener(h8,t=>this.report(t.detail)),window.addEventListener(p8,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 BJ(),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=m8();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=nu().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),oee([...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=g8("/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 xW({url:n+uW,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 yz(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?uee(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:mE}):d&&this.state.getState().error===mE&&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 aQ({url:t.key,createSocket:()=>r?v8():new hQ(a,n,t.machine),lazyImages:!0}),c=fQ(l,{lazyImages:!0}),d=new gQ(l,{connector:r?void 0:ree,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 pQ(l,this.identity,r):await mQ(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&&(x8(),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 dee,Sd=e=>e.installed&&!e.problem&&e.auth?.state!=="missing"&&e.tier!=="terminal";function fee({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(Sd)?.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(Sd)?.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&&Sd(M),H=z?.store===d&&z.agent===g?z.model:void 0,I=uz(g,y,l&&R,H,$),q=l&&R&&!!y.trim()&&!v.busy&&!!I&&!I.error,G=hz(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=dz(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:fz(I?.config,ee),prompt:k.trim()?[{type:"text",text:k.trim()}]:void 0})))};return s.jsxs("div",{className:"new-session-page",children:[s.jsx(Ef,{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:!Sd(Q),children:[s.jsx(Ao,{agent:Q.id}),s.jsxs("span",{className:"new-session-option",children:[s.jsx("span",{children:Q.label}),!Sd(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?Xb(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=Xb(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(LJ,{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(Nf,{start:y,directoriesOnly:!0,onPick:Q=>{j(Q),T(!1),Y.current?.focus()}})})]})}const Sz="/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(lF,{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(WU,{"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}`:"连接电脑后可读取原名"," · ",Af(e),"。留空将恢复原名。"]}),d&&s.jsx(Pr,{id:`${C}-error`,children:d})]}),s.jsxs(l6,{children:[(h?.naming?.customName||n[e.key])&&s.jsx(F,{type:"button",variant:"ghost",disabled:g||y||!h?.naming,onClick:()=>void _(""),children:"恢复原名"}),s.jsx(T1,{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 hee({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(Eu,{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 pee({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(Eu,{size:16}):s.jsx(oT,{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 mee(){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(Eu,{size:16}):s.jsx(oT,{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 gee({locked:e}){return e?s.jsx(Eu,{className:"computer-lock-mark",size:12,"aria-label":"已设置访问密码"}):null}function vee({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-BW5Ya5ED.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(kU,{"data-icon":"inline-start"}),r?"关闭摄像头":"扫描二维码"]}),s.jsx(gw,{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-BW5Ya5ED.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 gE({userId:e,disabled:t}){const n=m.useId(),[r,a]=m.useState(""),[l,c]=m.useState(),d=Rn(()=>nee(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(pC,{}),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 see(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:R5,target:"_blank",rel:"noopener noreferrer",children:"前往链动小铺 ↗"})]})]})}):null,s.jsx(pC,{})]})}const xee="https://itool.tech/zh/register",bee="https://itool.tech/zh/forgot-password",yee=45e3,Cz={github:"GitHub",google:"Google"};function wee(){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 jee(){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 vE({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 kee(e){return e.key==="Enter"&&(e.isComposing===!0||e.keyCode===229)}function xE(e){kee({key:e.key,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&e.preventDefault()}function See(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 _z(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=See(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(Cee,{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(wee,{}):s.jsx(jee,{}),"使用 ",Cz[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:xE,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(vE,{href:bee,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:xE,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(vE,{href:xee,children:"注册 iTool 账号"})]}),s.jsxs("p",{children:["已在浏览器登录 iTool?",s.jsx("button",{type:"button",className:"signin-link",disabled:L,onClick:h,children:"在浏览器中授权"})]})]})]})}function Cee({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),yee);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:Cz[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 _ee=400;function Eee(e){return e instanceof DOMException&&e.name==="TimeoutError"?"等待登录超时,请重试。":e instanceof TypeError?"桌面服务暂时不可用,请重试。":Ps(e)}function Nee(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,bS().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,_ee)),!x)return;try{const j=await y8();if(x&&j?.method===g.method&&j.url){a(j.url);return}}catch{}}})();try{await b8(g),h.current&&await e()}catch(j){!f.current&&h.current&&c(Eee(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,bS().catch(()=>{})},onEdit:()=>c(void 0)}}function Aee({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=Nee(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(gE,{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(w8),children:"退出 LinkShell 账号"}),s.jsx("p",{className:"field-hint",children:"账号与这台电脑的 LinkShell 服务共用。退出后,本机工作台和已配对的电脑仍可使用。"})]}):s.jsx(_z,{...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(gE,{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 nu().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 nu().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 j8(nu().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(vee,{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:ky,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(nn,{name:"globe"}),"官方账号"]}),s.jsxs(Pn,{value:"self-hosted",disabled:k.busy,children:[s.jsx(nn,{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 Ez({...e}){return s.jsx(Iy,{"data-slot":"sheet",...e})}function Tee({...e}){return s.jsx($y,{"data-slot":"sheet-portal",...e})}function Mee({className:e,...t}){return s.jsx(Ly,{"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 Nz({className:e,children:t,side:n="right",showCloseButton:r=!0,...a}){return s.jsxs(Tee,{children:[s.jsx(Mee,{}),s.jsxs(Py,{"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(ju,{"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 Az({className:e,...t}){return s.jsx("div",{"data-slot":"sheet-header",className:je("flex flex-col gap-0.5 p-4",e),...t})}function Tz({className:e,...t}){return s.jsx(By,{"data-slot":"sheet-title",className:je("text-base font-medium text-foreground",e),...t})}function zee({className:e,...t}){return s.jsx(Uy,{"data-slot":"sheet-description",className:je("text-sm text-muted-foreground",e),...t})}const Ree=768;function Mz(e=Ree){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 Dee(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 Tf({...e}){return s.jsx(lP,{"data-slot":"popover",...e})}function Sg({...e}){return s.jsx(fP,{"data-slot":"popover-trigger",...e})}function Mf({className:e,align:t="center",sideOffset:n=4,container:r,...a}){return s.jsx(mP,{container:r,children:s.jsx(gP,{"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 Oee({...e}){return s.jsx(uP,{"data-slot":"popover-anchor",...e})}function Iee({className:e,...t}){return s.jsx("div",{"data-slot":"popover-header",className:je("flex flex-col gap-0.5 text-sm",e),...t})}function $ee({className:e,...t}){return s.jsx("div",{"data-slot":"popover-title",className:je("font-medium",e),...t})}function Lee({className:e,...t}){return s.jsx("p",{"data-slot":"popover-description",className:je("text-muted-foreground",e),...t})}var bE=1,Pee=.9,Bee=.8,Uee=.17,C0=.1,_0=.999,Fee=.9999,qee=.99,Hee=/[\\\/_+.#"@\[\(\{&]/,Vee=/[\\\/_+.#"@\[\(\{&]/g,Gee=/[\s-]/,zz=/[\s-]/g;function ey(e,t,n,r,a,l,c){if(l===t.length)return a===e.length?bE:qee;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=ey(e,t,n,r,h+1,l+1,c),g>v&&(h===a?g*=bE:Hee.test(e.charAt(h-1))?(g*=Bee,y=e.slice(a,h-1).match(Vee),y&&a>0&&(g*=Math.pow(_0,y.length))):Gee.test(e.charAt(h-1))?(g*=Pee,j=e.slice(a,h-1).match(zz),j&&a>0&&(g*=Math.pow(_0,j.length))):(g*=Uee,a>0&&(g*=Math.pow(_0,h-a))),e.charAt(h)!==t.charAt(l)&&(g*=Fee)),(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=ey(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 yE(e){return e.toLowerCase().replace(zz," ")}function Zee(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,ey(e,t,yE(e),yE(t),0,0,{})}function wo(e,t,{checkForDefaultPrevented:n=!0}={}){return function(a){if(e?.(a),n===!1||!a.defaultPrevented)return t?.(a)}}function wE(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=wE(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():wE(e[a],null)}}}}function Wl(...e){return m.useCallback($l(...e),e)}function Kee(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 Yee(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,Wee(a,...t)]}function Wee(...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 of=globalThis?.document?m.useLayoutEffect:()=>{},Xee=Ro[" useId ".trim().toString()]||(()=>{}),Qee=0;function ga(e){const[t,n]=m.useState(Xee());return of(()=>{n(r=>r??String(Qee++))},[e]),t?`radix-${t}`:""}var Jee=Ro[" useInsertionEffect ".trim().toString()]||of;function ete({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[a,l,c]=tte({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=nte(v)?v(e):v;g!==e&&c.current?.(g)}else l(v)},[d,e,l,c]);return[f,h]}function tte({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),a=m.useRef(n),l=m.useRef(t);return Jee(()=>{l.current=t},[t]),m.useEffect(()=>{a.current!==n&&(l.current?.(n),a.current=n)},[n,a]),[n,r,l]}function nte(e){return typeof e=="function"}function Rz(e){const t=ste(e),n=m.forwardRef((r,a)=>{const{children:l,...c}=r,d=m.Children.toArray(l),f=d.find(ite);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 ste(e){const t=m.forwardRef((n,r)=>{const{children:a,...l}=n;if(m.isValidElement(a)){const c=ote(a),d=ate(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 rte=Symbol("radix.slottable");function ite(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rte}function ate(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 ote(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 lte=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ss=lte.reduce((e,t)=>{const n=Rz(`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 cte(e,t){e&&Oo.flushSync(()=>e.dispatchEvent(t))}function lf(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>t.current?.(...n),[])}function ute(e,t=globalThis?.document){const n=lf(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 dte="DismissableLayer",ty="dismissableLayer.update",fte="dismissableLayer.pointerDownOutside",hte="dismissableLayer.focusOutside",jE,Dz=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Oz=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:l,onInteractOutside:c,onDismiss:d,...f}=e,h=m.useContext(Dz),[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=gte(B=>{const O=B.target,$=[...h.branches].some(D=>D.contains(O));!T||$||(a?.(B),c?.(B),B.defaultPrevented||d?.())},x),L=vte(B=>{const O=B.target;[...h.branches].some(D=>D.contains(O))||(l?.(B),c?.(B),B.defaultPrevented||d?.())},x);return ute(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&&(jE=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(v)),h.layers.add(v),kE(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=jE)}},[v,x,n,h]),m.useEffect(()=>()=>{v&&(h.layers.delete(v),h.layersWithOutsidePointerEventsDisabled.delete(v),kE())},[v,h]),m.useEffect(()=>{const B=()=>y({});return document.addEventListener(ty,B),()=>document.removeEventListener(ty,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)})});Oz.displayName=dte;var pte="DismissableLayerBranch",mte=m.forwardRef((e,t)=>{const n=m.useContext(Dz),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})});mte.displayName=pte;function gte(e,t=globalThis?.document){const n=lf(e),r=m.useRef(!1),a=m.useRef(()=>{});return m.useEffect(()=>{const l=d=>{if(d.target&&!r.current){let f=function(){Iz(fte,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 vte(e,t=globalThis?.document){const n=lf(e),r=m.useRef(!1);return m.useEffect(()=>{const a=l=>{l.target&&!r.current&&Iz(hte,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 kE(){const e=new CustomEvent(ty);document.dispatchEvent(e)}function Iz(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?cte(a,l):a.dispatchEvent(l)}var E0="focusScope.autoFocusOnMount",N0="focusScope.autoFocusOnUnmount",SE={bubbles:!1,cancelable:!0},xte="FocusScope",$z=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:l,...c}=e,[d,f]=m.useState(null),h=lf(a),v=lf(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){_E.add(y);const k=document.activeElement;if(!d.contains(k)){const _=new CustomEvent(E0,SE);d.addEventListener(E0,h),d.dispatchEvent(_),_.defaultPrevented||(bte(Ste(Lz(d)),{select:!0}),document.activeElement===k&&co(d))}return()=>{d.removeEventListener(E0,h),setTimeout(()=>{const _=new CustomEvent(N0,SE);d.addEventListener(N0,v),d.dispatchEvent(_),_.defaultPrevented||co(k??document.body,{select:!0}),d.removeEventListener(N0,v),_E.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]=yte(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})});$z.displayName=xte;function bte(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(co(r,{select:t}),document.activeElement!==n)return}function yte(e){const t=Lz(e),n=CE(t,e),r=CE(t.reverse(),e);return[n,r]}function Lz(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 CE(e,t){for(const n of e)if(!wte(n,{upTo:t}))return n}function wte(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 jte(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&&jte(e)&&t&&e.select()}}var _E=kte();function kte(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=EE(e,t),e.unshift(t)},remove(t){e=EE(e,t),e[0]?.resume()}}}function EE(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Ste(e){return e.filter(t=>t.tagName!=="A")}var Cte="Portal",Pz=m.forwardRef((e,t)=>{const{container:n,...r}=e,[a,l]=m.useState(!1);of(()=>l(!0),[]);const c=n||a&&globalThis?.document?.body;return c?wI.createPortal(s.jsx(Ss.div,{...r,ref:t}),c):null});Pz.displayName=Cte;function _te(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Cg=e=>{const{present:t,children:n}=e,r=Ete(t),a=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),l=Wl(r.ref,Nte(a));return typeof n=="function"||r.isPresent?m.cloneElement(a,{ref:l}):null};Cg.displayName="Presence";function Ete(e){const[t,n]=m.useState(),r=m.useRef(null),a=m.useRef(e),l=m.useRef("none"),c=e?"mounted":"unmounted",[d,f]=_te(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const h=yp(r.current);l.current=d==="mounted"?h:"none"},[d]),of(()=>{const h=r.current,v=a.current;if(v!==e){const x=l.current,y=yp(h);e?f("MOUNT"):y==="none"||h?.display==="none"?f("UNMOUNT"):f(v&&x!==y?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,f]),of(()=>{if(t){let h;const v=t.ownerDocument.defaultView??window,g=y=>{const k=yp(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=yp(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 yp(e){return e?.animationName||"none"}function Nte(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 Ate(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??NE()),document.body.insertAdjacentElement("beforeend",e[1]??NE()),A0++,()=>{A0===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),A0--}},[])}function NE(){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",[Bz]=Yee(_g),[Tte,hi]=Bz(_g),Uz=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]=ete({prop:r,defaultProp:a??!1,onChange:l,caller:_g});return s.jsx(Tte,{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})};Uz.displayName=_g;var Fz="DialogTrigger",Mte=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(Fz,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":jw(a.open),...r,ref:l,onClick:wo(e.onClick,a.onOpenToggle)})});Mte.displayName=Fz;var yw="DialogPortal",[zte,qz]=Bz(yw,{forceMount:void 0}),Hz=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:a}=e,l=hi(yw,t);return s.jsx(zte,{scope:t,forceMount:n,children:m.Children.map(r,c=>s.jsx(Cg,{present:n||l.open,children:s.jsx(Pz,{asChild:!0,container:a,children:c})}))})};Hz.displayName=yw;var Am="DialogOverlay",Vz=m.forwardRef((e,t)=>{const n=qz(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(Dte,{...a,ref:t})}):null});Vz.displayName=Am;var Rte=Rz("DialogOverlay.RemoveScroll"),Dte=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(Am,n);return s.jsx(wu,{as:Rte,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(Ss.div,{"data-state":jw(a.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Ll="DialogContent",Gz=m.forwardRef((e,t)=>{const n=qz(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(Ote,{...a,ref:t}):s.jsx(Ite,{...a,ref:t})})});Gz.displayName=Ll;var Ote=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 pf(l)},[]),s.jsx(Zz,{...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())})}),Ite=m.forwardRef((e,t)=>{const n=hi(Ll,e.__scopeDialog),r=m.useRef(!1),a=m.useRef(!1);return s.jsx(Zz,{...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()}})}),Zz=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 Ate(),s.jsxs(s.Fragment,{children:[s.jsx($z,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:l,children:s.jsx(Oz,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":jw(d.open),...c,ref:h,onDismiss:()=>d.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(Bte,{titleId:d.titleId}),s.jsx(Fte,{contentRef:f,descriptionId:d.descriptionId})]})]})}),ww="DialogTitle",$te=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(ww,n);return s.jsx(Ss.h2,{id:a.titleId,...r,ref:t})});$te.displayName=ww;var Kz="DialogDescription",Lte=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(Kz,n);return s.jsx(Ss.p,{id:a.descriptionId,...r,ref:t})});Lte.displayName=Kz;var Yz="DialogClose",Pte=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(Yz,n);return s.jsx(Ss.button,{type:"button",...r,ref:t,onClick:wo(e.onClick,()=>a.onOpenChange(!1))})});Pte.displayName=Yz;function jw(e){return e?"open":"closed"}var Wz="DialogTitleWarning",[roe,Xz]=Kee(Wz,{contentName:Ll,titleName:ww,docsSlug:"dialog"}),Bte=({titleId:e})=>{const t=Xz(Wz),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
774
|
+
`),X5(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(WJ,{text:d,tokens:l?.[f]})})]},f))})}function WJ({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 xw(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 vz(e,t){const{link:n}=Dt(),r=$t(),a=Rn(()=>FJ(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?UJ(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:pz(d,v)})}),job:r}}function xz(e){return me?s.jsx(XJ,{...e}):s.jsx(QJ,{...e})}function XJ(e){const t=vz(e.path,e.line);return s.jsx(KJ,{...e,content:t})}function QJ({path:e,line:t,close:n,onDirtyChange:r}){const a=m.useRef(null),{loaded:l,file:c,highlighted:d,more:f,job:h}=vz(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(mz,{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(Zd,{"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(GJ,{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(s6,{"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 Nf({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 xw(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("")},Vt=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(Wd,{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(IU,{})}),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(Yd,{"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(yf,{})})}),s.jsxs(Ms,{align:"end",children:[s.jsxs(mt,{disabled:!Le,onSelect:ht,children:[s.jsx(Yd,{}),"上传文件"]}),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(KQ,{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:Vt}),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(gw,{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(Zd,{"data-icon":"inline-start"}):s.jsx(F3,{"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:Vt}),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(vw,{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(Zd,{"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(xz,{path:k,line:_,close:()=>void ze(),onDirtyChange:T},`${k}:${_??""}`)})]})]})}const JJ="https://mkbeusztkzffnzjdwmqk.supabase.co",eee="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1rYmV1c3p0a3pmZm56amR3bXFrIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjU5Nzc0NzgsImV4cCI6MjA4MTU1MzQ3OH0.2wlT6q6687Z5rpEYsdp01IQpNNl_XWv0IAfBgwPyDP0";let tee;function bz(){return{supabaseUrl:window.__LINKSHELL_CONFIG__?.account?.url??JJ,anonKey:window.__LINKSHELL_CONFIG__?.account?.anonKey??eee}}function nu(){if(me)throw new Error("桌面端使用 LinkShell 的系统浏览器登录");const{supabaseUrl:e,anonKey:t}=bz();return tee??=d8(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 Bd(e,t){if(!e)throw new Error("登录已失效,请重新登录");if(e!==t)throw new Error("账号已切换,请在当前账户下重新操作")}async function yz(e){if(me){const l=await Gp();return e!==void 0&&Bd(l.userId,e),l.accessToken}const t=nu().auth,{data:n,error:r}=await t.getSession();if(r)throw r;if(e!==void 0&&Bd(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&&Bd(a.data.session.user.id,e),a.data.session.access_token}async function bw(e){if(me){const r=await Gp();if(Bd(r.userId,e),!r.accessToken)throw new Error("登录已失效,请重新登录");return{access_token:r.accessToken}}const{data:t,error:n}=await nu().auth.getSession();if(n)throw n;if(!t.session)throw new Error("登录已失效,请重新登录");return Bd(t.session.user.id,e),t.session}async function wz(e){const t=await yz(e),n=await bw(e);if(!t||n.access_token!==t)throw new Error("账号状态已更新,请重试");return t}async function nee(e){const t=await wz(e),n=await yQ({...bz(),accessToken:t,userId:e});return await bw(e),n}async function see(e,t){const n=await wz(e),r=await jQ(n,t);return await bw(e),r}const ree=e=>{const t=new RTCPeerConnection({iceServers:e.map(r=>({urls:r}))}),n=t.createDataChannel(bW,{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 iee{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,Hc=e=>`@shared:${e}`;function pE(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[Hc(e.key)])||t[e.key]||e.machine.name||"电脑"}function Af(e){return`${{darwin:"macOS",linux:"Linux",win32:"Windows"}[e.machine.platform??""]||e.machine.platform||"电脑"} · ${e.machine.id.slice(0,8)}`}function jz(e,t){return`${Mn(e,t)} · ${e.machine.id.slice(0,8)} · ${e.machine.online?"在线":"离线"}`}function aee(){const e=_f(()=>pE(dn("computer-names",{}))),t=new Map,n=()=>{const a=pE(dn("computer-names",{})),l={...a};for(const[c,d]of t){if(a[Hc(c)]!==d.saved){t.delete(c);continue}l[Hc(c)]=d.name,delete l[c]}return{saved:a,next:l}},r=(a,l)=>{const{saved:c,next:d}=n();if(d[Hc(a.key)]===l&&!d[a.key]&&!t.size){e.setState(d,!0);return}delete d[a.key],d[Hc(a.key)]=l,t.set(a.key,{name:l,saved:c[Hc(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=aee();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 oee(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 lee=dn("source",pa),kz=pa==="self-hosted"?"self-hosted":lee,cee=kz==="official"?Ks:dn("gateway",PQ),mE="网关未确认当前账号,请退出账号后重新登录。";function uee(e){switch(e.code){case"disconnected":case"connect_failed":return"与网关的连接断开了,正在自动重连…";case"replaced":return"这台设备已在别处连上网关";default:return e.message}}class dee{state=_f(()=>({source:kz,gateway:cee,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 iee(t=>this.openComputer(t));releaseSelected;channel=typeof BroadcastChannel<"u"?new BroadcastChannel("linkshell.web.owner"):void 0;constructor(){me&&(window.addEventListener(h8,t=>this.report(t.detail)),window.addEventListener(p8,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 BJ(),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=m8();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=nu().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),oee([...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=g8("/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 xW({url:n+uW,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 yz(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?uee(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:mE}):d&&this.state.getState().error===mE&&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 aQ({url:t.key,createSocket:()=>r?v8():new hQ(a,n,t.machine),lazyImages:!0}),c=fQ(l,{lazyImages:!0}),d=new gQ(l,{connector:r?void 0:ree,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 pQ(l,this.identity,r):await mQ(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&&(x8(),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 dee,Sd=e=>e.installed&&!e.problem&&e.auth?.state!=="missing"&&e.tier!=="terminal";function fee({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(Sd)?.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(Sd)?.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&&Sd(M),H=z?.store===d&&z.agent===g?z.model:void 0,I=uz(g,y,l&&R,H,$),q=l&&R&&!!y.trim()&&!v.busy&&!!I&&!I.error,G=hz(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=dz(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:fz(I?.config,ee),prompt:k.trim()?[{type:"text",text:k.trim()}]:void 0})))};return s.jsxs("div",{className:"new-session-page",children:[s.jsx(Ef,{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:!Sd(Q),children:[s.jsx(Ao,{agent:Q.id}),s.jsxs("span",{className:"new-session-option",children:[s.jsx("span",{children:Q.label}),!Sd(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?Xb(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=Xb(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(LJ,{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(Nf,{start:y,directoriesOnly:!0,onPick:Q=>{j(Q),T(!1),Y.current?.focus()}})})]})}const Sz="/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(lF,{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(WU,{"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}`:"连接电脑后可读取原名"," · ",Af(e),"。留空将恢复原名。"]}),d&&s.jsx(Pr,{id:`${C}-error`,children:d})]}),s.jsxs(l6,{children:[(h?.naming?.customName||n[e.key])&&s.jsx(F,{type:"button",variant:"ghost",disabled:g||y||!h?.naming,onClick:()=>void _(""),children:"恢复原名"}),s.jsx(T1,{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 hee({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(Eu,{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 pee({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(Eu,{size:16}):s.jsx(oT,{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 mee(){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(Eu,{size:16}):s.jsx(oT,{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 gee({locked:e}){return e?s.jsx(Eu,{className:"computer-lock-mark",size:12,"aria-label":"已设置访问密码"}):null}function vee({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-BhmL6roF.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(kU,{"data-icon":"inline-start"}),r?"关闭摄像头":"扫描二维码"]}),s.jsx(gw,{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-BhmL6roF.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 gE({userId:e,disabled:t}){const n=m.useId(),[r,a]=m.useState(""),[l,c]=m.useState(),d=Rn(()=>nee(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(pC,{}),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 see(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:R5,target:"_blank",rel:"noopener noreferrer",children:"前往链动小铺 ↗"})]})]})}):null,s.jsx(pC,{})]})}const xee="https://itool.tech/zh/register",bee="https://itool.tech/zh/forgot-password",yee=45e3,Cz={github:"GitHub",google:"Google"};function wee(){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 jee(){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 vE({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 kee(e){return e.key==="Enter"&&(e.isComposing===!0||e.keyCode===229)}function xE(e){kee({key:e.key,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&e.preventDefault()}function See(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 _z(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=See(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(Cee,{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(wee,{}):s.jsx(jee,{}),"使用 ",Cz[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:xE,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(vE,{href:bee,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:xE,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(vE,{href:xee,children:"注册 iTool 账号"})]}),s.jsxs("p",{children:["已在浏览器登录 iTool?",s.jsx("button",{type:"button",className:"signin-link",disabled:L,onClick:h,children:"在浏览器中授权"})]})]})]})}function Cee({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),yee);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:Cz[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 _ee=400;function Eee(e){return e instanceof DOMException&&e.name==="TimeoutError"?"等待登录超时,请重试。":e instanceof TypeError?"桌面服务暂时不可用,请重试。":Ps(e)}function Nee(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,bS().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,_ee)),!x)return;try{const j=await y8();if(x&&j?.method===g.method&&j.url){a(j.url);return}}catch{}}})();try{await b8(g),h.current&&await e()}catch(j){!f.current&&h.current&&c(Eee(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,bS().catch(()=>{})},onEdit:()=>c(void 0)}}function Aee({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=Nee(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(gE,{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(w8),children:"退出 LinkShell 账号"}),s.jsx("p",{className:"field-hint",children:"账号与这台电脑的 LinkShell 服务共用。退出后,本机工作台和已配对的电脑仍可使用。"})]}):s.jsx(_z,{...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(gE,{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 nu().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 nu().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 j8(nu().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(vee,{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:ky,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(nn,{name:"globe"}),"官方账号"]}),s.jsxs(Pn,{value:"self-hosted",disabled:k.busy,children:[s.jsx(nn,{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 Ez({...e}){return s.jsx(Iy,{"data-slot":"sheet",...e})}function Tee({...e}){return s.jsx($y,{"data-slot":"sheet-portal",...e})}function Mee({className:e,...t}){return s.jsx(Ly,{"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 Nz({className:e,children:t,side:n="right",showCloseButton:r=!0,...a}){return s.jsxs(Tee,{children:[s.jsx(Mee,{}),s.jsxs(Py,{"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(ju,{"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 Az({className:e,...t}){return s.jsx("div",{"data-slot":"sheet-header",className:je("flex flex-col gap-0.5 p-4",e),...t})}function Tz({className:e,...t}){return s.jsx(By,{"data-slot":"sheet-title",className:je("text-base font-medium text-foreground",e),...t})}function zee({className:e,...t}){return s.jsx(Uy,{"data-slot":"sheet-description",className:je("text-sm text-muted-foreground",e),...t})}const Ree=768;function Mz(e=Ree){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 Dee(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 Tf({...e}){return s.jsx(lP,{"data-slot":"popover",...e})}function Sg({...e}){return s.jsx(fP,{"data-slot":"popover-trigger",...e})}function Mf({className:e,align:t="center",sideOffset:n=4,container:r,...a}){return s.jsx(mP,{container:r,children:s.jsx(gP,{"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 Oee({...e}){return s.jsx(uP,{"data-slot":"popover-anchor",...e})}function Iee({className:e,...t}){return s.jsx("div",{"data-slot":"popover-header",className:je("flex flex-col gap-0.5 text-sm",e),...t})}function $ee({className:e,...t}){return s.jsx("div",{"data-slot":"popover-title",className:je("font-medium",e),...t})}function Lee({className:e,...t}){return s.jsx("p",{"data-slot":"popover-description",className:je("text-muted-foreground",e),...t})}var bE=1,Pee=.9,Bee=.8,Uee=.17,C0=.1,_0=.999,Fee=.9999,qee=.99,Hee=/[\\\/_+.#"@\[\(\{&]/,Vee=/[\\\/_+.#"@\[\(\{&]/g,Gee=/[\s-]/,zz=/[\s-]/g;function ey(e,t,n,r,a,l,c){if(l===t.length)return a===e.length?bE:qee;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=ey(e,t,n,r,h+1,l+1,c),g>v&&(h===a?g*=bE:Hee.test(e.charAt(h-1))?(g*=Bee,y=e.slice(a,h-1).match(Vee),y&&a>0&&(g*=Math.pow(_0,y.length))):Gee.test(e.charAt(h-1))?(g*=Pee,j=e.slice(a,h-1).match(zz),j&&a>0&&(g*=Math.pow(_0,j.length))):(g*=Uee,a>0&&(g*=Math.pow(_0,h-a))),e.charAt(h)!==t.charAt(l)&&(g*=Fee)),(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=ey(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 yE(e){return e.toLowerCase().replace(zz," ")}function Zee(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,ey(e,t,yE(e),yE(t),0,0,{})}function wo(e,t,{checkForDefaultPrevented:n=!0}={}){return function(a){if(e?.(a),n===!1||!a.defaultPrevented)return t?.(a)}}function wE(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=wE(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():wE(e[a],null)}}}}function Wl(...e){return m.useCallback($l(...e),e)}function Kee(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 Yee(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,Wee(a,...t)]}function Wee(...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 of=globalThis?.document?m.useLayoutEffect:()=>{},Xee=Ro[" useId ".trim().toString()]||(()=>{}),Qee=0;function ga(e){const[t,n]=m.useState(Xee());return of(()=>{n(r=>r??String(Qee++))},[e]),t?`radix-${t}`:""}var Jee=Ro[" useInsertionEffect ".trim().toString()]||of;function ete({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[a,l,c]=tte({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=nte(v)?v(e):v;g!==e&&c.current?.(g)}else l(v)},[d,e,l,c]);return[f,h]}function tte({defaultProp:e,onChange:t}){const[n,r]=m.useState(e),a=m.useRef(n),l=m.useRef(t);return Jee(()=>{l.current=t},[t]),m.useEffect(()=>{a.current!==n&&(l.current?.(n),a.current=n)},[n,a]),[n,r,l]}function nte(e){return typeof e=="function"}function Rz(e){const t=ste(e),n=m.forwardRef((r,a)=>{const{children:l,...c}=r,d=m.Children.toArray(l),f=d.find(ite);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 ste(e){const t=m.forwardRef((n,r)=>{const{children:a,...l}=n;if(m.isValidElement(a)){const c=ote(a),d=ate(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 rte=Symbol("radix.slottable");function ite(e){return m.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rte}function ate(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 ote(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 lte=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ss=lte.reduce((e,t)=>{const n=Rz(`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 cte(e,t){e&&Oo.flushSync(()=>e.dispatchEvent(t))}function lf(e){const t=m.useRef(e);return m.useEffect(()=>{t.current=e}),m.useMemo(()=>(...n)=>t.current?.(...n),[])}function ute(e,t=globalThis?.document){const n=lf(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 dte="DismissableLayer",ty="dismissableLayer.update",fte="dismissableLayer.pointerDownOutside",hte="dismissableLayer.focusOutside",jE,Dz=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Oz=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:a,onFocusOutside:l,onInteractOutside:c,onDismiss:d,...f}=e,h=m.useContext(Dz),[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=gte(B=>{const O=B.target,$=[...h.branches].some(D=>D.contains(O));!T||$||(a?.(B),c?.(B),B.defaultPrevented||d?.())},x),L=vte(B=>{const O=B.target;[...h.branches].some(D=>D.contains(O))||(l?.(B),c?.(B),B.defaultPrevented||d?.())},x);return ute(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&&(jE=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),h.layersWithOutsidePointerEventsDisabled.add(v)),h.layers.add(v),kE(),()=>{n&&h.layersWithOutsidePointerEventsDisabled.size===1&&(x.body.style.pointerEvents=jE)}},[v,x,n,h]),m.useEffect(()=>()=>{v&&(h.layers.delete(v),h.layersWithOutsidePointerEventsDisabled.delete(v),kE())},[v,h]),m.useEffect(()=>{const B=()=>y({});return document.addEventListener(ty,B),()=>document.removeEventListener(ty,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)})});Oz.displayName=dte;var pte="DismissableLayerBranch",mte=m.forwardRef((e,t)=>{const n=m.useContext(Dz),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})});mte.displayName=pte;function gte(e,t=globalThis?.document){const n=lf(e),r=m.useRef(!1),a=m.useRef(()=>{});return m.useEffect(()=>{const l=d=>{if(d.target&&!r.current){let f=function(){Iz(fte,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 vte(e,t=globalThis?.document){const n=lf(e),r=m.useRef(!1);return m.useEffect(()=>{const a=l=>{l.target&&!r.current&&Iz(hte,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 kE(){const e=new CustomEvent(ty);document.dispatchEvent(e)}function Iz(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?cte(a,l):a.dispatchEvent(l)}var E0="focusScope.autoFocusOnMount",N0="focusScope.autoFocusOnUnmount",SE={bubbles:!1,cancelable:!0},xte="FocusScope",$z=m.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:a,onUnmountAutoFocus:l,...c}=e,[d,f]=m.useState(null),h=lf(a),v=lf(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){_E.add(y);const k=document.activeElement;if(!d.contains(k)){const _=new CustomEvent(E0,SE);d.addEventListener(E0,h),d.dispatchEvent(_),_.defaultPrevented||(bte(Ste(Lz(d)),{select:!0}),document.activeElement===k&&co(d))}return()=>{d.removeEventListener(E0,h),setTimeout(()=>{const _=new CustomEvent(N0,SE);d.addEventListener(N0,v),d.dispatchEvent(_),_.defaultPrevented||co(k??document.body,{select:!0}),d.removeEventListener(N0,v),_E.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]=yte(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})});$z.displayName=xte;function bte(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(co(r,{select:t}),document.activeElement!==n)return}function yte(e){const t=Lz(e),n=CE(t,e),r=CE(t.reverse(),e);return[n,r]}function Lz(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 CE(e,t){for(const n of e)if(!wte(n,{upTo:t}))return n}function wte(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 jte(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&&jte(e)&&t&&e.select()}}var _E=kte();function kte(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=EE(e,t),e.unshift(t)},remove(t){e=EE(e,t),e[0]?.resume()}}}function EE(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Ste(e){return e.filter(t=>t.tagName!=="A")}var Cte="Portal",Pz=m.forwardRef((e,t)=>{const{container:n,...r}=e,[a,l]=m.useState(!1);of(()=>l(!0),[]);const c=n||a&&globalThis?.document?.body;return c?wI.createPortal(s.jsx(Ss.div,{...r,ref:t}),c):null});Pz.displayName=Cte;function _te(e,t){return m.useReducer((n,r)=>t[n][r]??n,e)}var Cg=e=>{const{present:t,children:n}=e,r=Ete(t),a=typeof n=="function"?n({present:r.isPresent}):m.Children.only(n),l=Wl(r.ref,Nte(a));return typeof n=="function"||r.isPresent?m.cloneElement(a,{ref:l}):null};Cg.displayName="Presence";function Ete(e){const[t,n]=m.useState(),r=m.useRef(null),a=m.useRef(e),l=m.useRef("none"),c=e?"mounted":"unmounted",[d,f]=_te(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return m.useEffect(()=>{const h=yp(r.current);l.current=d==="mounted"?h:"none"},[d]),of(()=>{const h=r.current,v=a.current;if(v!==e){const x=l.current,y=yp(h);e?f("MOUNT"):y==="none"||h?.display==="none"?f("UNMOUNT"):f(v&&x!==y?"ANIMATION_OUT":"UNMOUNT"),a.current=e}},[e,f]),of(()=>{if(t){let h;const v=t.ownerDocument.defaultView??window,g=y=>{const k=yp(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=yp(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 yp(e){return e?.animationName||"none"}function Nte(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 Ate(){m.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??NE()),document.body.insertAdjacentElement("beforeend",e[1]??NE()),A0++,()=>{A0===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),A0--}},[])}function NE(){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",[Bz]=Yee(_g),[Tte,hi]=Bz(_g),Uz=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]=ete({prop:r,defaultProp:a??!1,onChange:l,caller:_g});return s.jsx(Tte,{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})};Uz.displayName=_g;var Fz="DialogTrigger",Mte=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(Fz,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":jw(a.open),...r,ref:l,onClick:wo(e.onClick,a.onOpenToggle)})});Mte.displayName=Fz;var yw="DialogPortal",[zte,qz]=Bz(yw,{forceMount:void 0}),Hz=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:a}=e,l=hi(yw,t);return s.jsx(zte,{scope:t,forceMount:n,children:m.Children.map(r,c=>s.jsx(Cg,{present:n||l.open,children:s.jsx(Pz,{asChild:!0,container:a,children:c})}))})};Hz.displayName=yw;var Am="DialogOverlay",Vz=m.forwardRef((e,t)=>{const n=qz(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(Dte,{...a,ref:t})}):null});Vz.displayName=Am;var Rte=Rz("DialogOverlay.RemoveScroll"),Dte=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(Am,n);return s.jsx(wu,{as:Rte,allowPinchZoom:!0,shards:[a.contentRef],children:s.jsx(Ss.div,{"data-state":jw(a.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Ll="DialogContent",Gz=m.forwardRef((e,t)=>{const n=qz(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(Ote,{...a,ref:t}):s.jsx(Ite,{...a,ref:t})})});Gz.displayName=Ll;var Ote=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 pf(l)},[]),s.jsx(Zz,{...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())})}),Ite=m.forwardRef((e,t)=>{const n=hi(Ll,e.__scopeDialog),r=m.useRef(!1),a=m.useRef(!1);return s.jsx(Zz,{...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()}})}),Zz=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 Ate(),s.jsxs(s.Fragment,{children:[s.jsx($z,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:l,children:s.jsx(Oz,{role:"dialog",id:d.contentId,"aria-describedby":d.descriptionId,"aria-labelledby":d.titleId,"data-state":jw(d.open),...c,ref:h,onDismiss:()=>d.onOpenChange(!1)})}),s.jsxs(s.Fragment,{children:[s.jsx(Bte,{titleId:d.titleId}),s.jsx(Fte,{contentRef:f,descriptionId:d.descriptionId})]})]})}),ww="DialogTitle",$te=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(ww,n);return s.jsx(Ss.h2,{id:a.titleId,...r,ref:t})});$te.displayName=ww;var Kz="DialogDescription",Lte=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(Kz,n);return s.jsx(Ss.p,{id:a.descriptionId,...r,ref:t})});Lte.displayName=Kz;var Yz="DialogClose",Pte=m.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,a=hi(Yz,n);return s.jsx(Ss.button,{type:"button",...r,ref:t,onClick:wo(e.onClick,()=>a.onOpenChange(!1))})});Pte.displayName=Yz;function jw(e){return e?"open":"closed"}var Wz="DialogTitleWarning",[roe,Xz]=Kee(Wz,{contentName:Ll,titleName:ww,docsSlug:"dialog"}),Bte=({titleId:e})=>{const t=Xz(Wz),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
|
|