dsh-mobile-plugin 0.5.87 → 0.5.88

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.
@@ -104,7 +104,7 @@ Sugerimos que pergunte à sua IA para configurar uma solução de rede adequada
104
104
  `);e.setCustomValidity(r),S.current=[e,r,n]}function C(){let e=S.current;S.current=null,e&&(!e[0].willValidate||e[0].validationMessage===e[1])&&e[0].setCustomValidity(e[2])}function w(e,t,n){let i=g(e,t);h(i,n),r(i)}function T(e){let t=fj.reduce((t,n)=>(t[n]=e.validity[n],t),{}),n=!1;for(let e of fj)if(e!==`valid`){if(e===`valueMissing`&&t[e])n=!0;else if(t[e])return t}return n&&!c.current&&(t.valid=!0,t.valueMissing=!1),t}function E(){return b.size>0?mj(b,t.current):v.current}let D=E();function O(){return D=E(),D?.willValidate?T(D):hj(!1)}if(o){if(l.valid!==!1||!D)return;if(!D.validity.valueMissing){C();let e=E(),t=e?.validity.customError?gj(e):[];w(hj(t.length>0),t,!1);return}for(let e of fj)if(e!==`valid`&&e!==`valueMissing`&&e!==`customError`&&D.validity[e])return}_.clear(),C();let k=O(),A=gj(D),j=u();if(A.length===0||j){let t=Array.from(n.current.fields.values()).reduce((e,t)=>(t.name&&(e[t.name]=t.getValue()),e),{}),r=i(e,t),o;if(typeof r==`object`&&r&&`then`in r){if(k.valid===!1?w(k,A):(d===`onSubmit`||!a.state.customError)&&(k.valid=null,w(k,A)),o=await r,m!==x.current)return;k=O()}else o=r;A=o?[].concat(o).filter(Boolean):[],A.length>0?(k.valid=!1,k.customError=!0,D?.willValidate&&y(D,A.join(`
105
105
  `))):A=gj(D)}w(k,A)}),E=q((e,t=!1)=>{if(_.clear(),x.current+=1,t)return;let n=u();n&&e!==``&&o?_.start(o,()=>{T(e)}):T(e,!n)}),D=g.useCallback((e,t={})=>Or(m(t),l.valid===!1&&!l.disabled&&!e?{"aria-invalid":!0}:h),[m,l.disabled,l.valid]);return g.useMemo(()=>({getValidationProps:D,inputRef:v,registeredInputs:b,registerInput:C,getInputControl:w,commit:T,change:E}),[D,b,C,w,T,E])}var vj=g.createContext(void 0);function yj(e=!1){let t=g.useContext(vj);if(!t&&!e)throw Error(S(86));return t}var bj=[Yd],xj=g.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,form:u,name:d,inputRef:f,id:p,style:m,...h}=e,{setTouched:_,setFocused:v,validationMode:y,name:b,disabled:x,state:S,validation:C,setDirty:w,setFilled:T,validityData:E}=FD(),{labelId:D}=BD(),{clearErrors:O,elementRef:k}=RD(),A=yj(!0),j=x||i,M=b??d,N=Md(p),[P,F]=vf({controlled:c,default:l,name:`RadioGroup`,state:`value`}),[I,L]=g.useState(!1),R=q((e,t)=>{s?.(e,t),!t.isCanceled&&F(e)}),z=C.getInputControl,B=g.useMemo(()=>({get current(){return z()}}),[z]),V=g.useRef(null),H=g.useRef(null);function ee(e){let t;return f&&(typeof f==`function`?t=f(e):f.current=e),V.current=e,t}let te=q(e=>{if(!e||e.disabled)return;H.current||=e;let t=V.current,n=e.checked||t==null||t.disabled?ee(e):void 0;return()=>{H.current===e&&(H.current=null),V.current===e?n?(n(),V.current=null):ee(null):n?.()}}),ne=q(()=>{let e=k.current;if(!e)return P??null;for(let t of C.registeredInputs.keys())if(t.checked&&pj(t,e))return P??null;return null});ID(B,N,P??null,ne,!j,d),Kf(P,()=>{O(M),w(P!==E.initialValue),T(P!=null),C.change(P);let e=H.current;P==null&&e&&!e.disabled&&ee(e)});let W=D??A?.legendId,re={...S,disabled:j??!1,required:o??!1,readOnly:a??!1},G=g.useMemo(()=>({checkedValue:P,disabled:j,form:u,validation:C,name:M,readOnly:a,registerInputRef:te,required:o,setCheckedValue:R,setTouched:L,touched:I}),[P,j,u,C,M,a,te,o,R,L,I]),K={id:p,role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":j||void 0,"aria-readonly":a||void 0,"aria-labelledby":W,onFocus(){v(!0)},onBlur(e){J(e.currentTarget,e.relatedTarget)||(_(!0),v(!1),y===`onBlur`&&C.commit(P))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&(L(!0),v(!0))}};return(0,U.jsx)(JA.Provider,{value:G,children:(0,U.jsx)(uj,{render:n,className:r,style:m,state:re,props:[K,h,e=>C.getValidationProps(j??!1,e)],refs:[t],stateAttributesMapping:kD,enableHomeAndEndKeys:!1,modifierKeys:bj})})});function Sj({className:e,orientation:t=`vertical`,...n}){return(0,U.jsx)(xj,{"data-slot":`radio-group`,"aria-orientation":t,className:Z(`flex`,t===`horizontal`?`flex-wrap gap-4`:`flex-col gap-2`,e),...n})}function Cj(e){return e?e.lan.length>0?e.lan:e.public:[]}function wj(e){return!e||e.lan.length===0?[]:e.public}function Tj(e){return e?.ipv6??[]}function Ej(e,t){let n=$(e===`lan`?`panel.address.lan`:e===`ipv6`?`panel.address.ipv6`:`panel.address.public`);return t?`${n} · ${t}`:n}function Dj(e,t){return`http://${e.includes(`:`)?`[${e}]`:e}:${String(t??``)}`}function Oj({book:e,error:t=``,onRetry:n,port:r,value:i,busy:a=!1,onChange:o,fallbackUrls:s=[],align:c=`end`}){let l=c===`start`?`items-start`:`items-end`,u=c===`start`?`justify-start`:`justify-end`,d=c===`start`?`text-start`:`text-end`,f=String(r??``),p=Cj(e),m=wj(e),h=Tj(e),g=e&&e.lan.length>0?`lan`:`public`,_=p.some(e=>e.address===i)?i:p[0]?.address??``;return t?(0,U.jsxs)(`span`,{className:`flex flex-col gap-0.5 ${l}`,children:[(0,U.jsx)(`span`,{className:`font-sans text-foreground-muted`,children:$(`panel.address.loadFailed`)}),n?(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:n,children:$(`panel.address.retry`)}):null]}):p.length===0?h.length===0&&s.length>0?(0,U.jsxs)(`span`,{className:`flex flex-col gap-0.5 ${l}`,children:[s.map(e=>(0,U.jsx)(`span`,{children:e},e)),e?(0,U.jsx)(`span`,{className:`font-sans text-xs text-foreground-muted`,children:$(`panel.address.natHint`)}):null]}):h.length===0?(0,U.jsxs)(`span`,{className:`flex flex-col gap-0.5 ${l}`,children:[(0,U.jsx)(`span`,{className:`font-sans text-foreground-muted`,children:$(e?`panel.address.none`:`panel.address.empty`)}),e?(0,U.jsx)(`span`,{className:`font-sans text-xs text-foreground-muted`,children:$(`panel.address.natHint`)}):null]}):(0,U.jsx)(`span`,{className:`flex w-full flex-col gap-1 ${l}`,children:h.map(e=>(0,U.jsxs)(`span`,{className:`inline-flex flex-wrap items-baseline gap-x-2 ${u}`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs text-foreground-muted`,children:Dj(e.address,f)}),(0,U.jsx)(`span`,{className:`shrink-0 font-sans text-xs text-foreground-subtle`,children:`${Ej(`ipv6`,e.interface)}${$(`panel.address.ipv6Hint`)}`})]},e.address))}):(0,U.jsxs)(`span`,{className:`flex w-full flex-col gap-1 ${l}`,children:[p.length>1?(0,U.jsx)(Sj,{className:fg(`w-full gap-1`,l,a&&`pointer-events-none opacity-60`),value:_,onValueChange:e=>{typeof e==`string`&&e!==_&&o(e)},children:p.map(e=>(0,U.jsxs)(`label`,{className:`flex w-full cursor-pointer flex-wrap items-baseline gap-x-2 ${u}`,children:[(0,U.jsx)(oj,{value:e.address,"aria-label":Dj(e.address,f)}),(0,U.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:Dj(e.address,f)}),(0,U.jsx)(`span`,{className:`shrink-0 font-sans text-xs text-foreground-muted`,children:Ej(g,e.interface)})]},e.address))}):(0,U.jsxs)(`span`,{className:`inline-flex flex-wrap items-baseline gap-x-2 ${u}`,children:[(0,U.jsx)(`span`,{className:`font-mono`,children:Dj(p[0].address,f)}),(0,U.jsx)(`span`,{className:`shrink-0 font-sans text-xs text-foreground-muted`,children:Ej(g,p[0].interface)})]}),m.map(e=>(0,U.jsxs)(`span`,{className:`inline-flex flex-wrap items-baseline gap-x-2 ${u}`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs text-foreground-muted`,children:Dj(e.address,f)}),(0,U.jsx)(`span`,{className:`shrink-0 font-sans text-xs text-foreground-subtle`,children:`${Ej(`public`,e.interface)}${$(`panel.address.publicHint`)}`})]},e.address)),h.map(e=>(0,U.jsxs)(`span`,{className:`inline-flex flex-wrap items-baseline gap-x-2 ${u}`,children:[(0,U.jsx)(`span`,{className:`font-mono text-xs text-foreground-muted`,children:Dj(e.address,f)}),(0,U.jsx)(`span`,{className:`shrink-0 font-sans text-xs text-foreground-subtle`,children:$(`panel.address.ipv6Pick`,{kind:Ej(`ipv6`,e.interface)})})]},e.address)),e&&e.lan.length>0&&e.public.length===0&&h.length===0?(0,U.jsx)(`span`,{className:`font-sans text-xs text-foreground-muted ${d}`,children:$(`panel.address.natHint`)}):null,p.length>1?(0,U.jsx)(`span`,{className:`font-sans text-xs text-foreground-muted ${d}`,children:$(`panel.address.hint`)}):null]})}function kj({on:e,what:t,label:n,className:r,disabled:i,onClick:a}){let o=n??$(e?`panel.common.hide`:`panel.common.show`);return(0,U.jsx)(Q,{variant:`ghost`,size:`icon-sm`,className:r,"aria-label":`${o}${t}`,title:`${o}${t}`,disabled:i,onClick:a,children:(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:e?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`m3 3 18 18M10.58 10.59a2 2 0 0 0 2.83 2.82`}),(0,U.jsx)(`path`,{d:`M9.88 5.09A10.94 10.94 0 0 1 12 5c7 0 10 7 10 7a14.5 14.5 0 0 1-3.17 4.36M6.61 6.61A16.77 16.77 0 0 0 2 12s3 7 10 7a10.94 10.94 0 0 0 5.39-1.39`})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`path`,{d:`M2 12s3-7 10-7 10 7 10 7-3 7-10 7S2 12 2 12Z`}),(0,U.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})})})}function Aj(){return(0,U.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,className:`size-6`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1`}),(0,U.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`1`}),(0,U.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`}),(0,U.jsx)(`path`,{d:`M14 14h3v3M21 14v.01M14 21h.01M17 21h4v-4`})]})}function jj({status:e,pairing:t,addressBook:n,addressError:r=``,onRetryAddresses:i,version:a,versionIssues:o=[],busy:s,error:c,onRetryPairing:l,onSavePreferred:u,onEditPort:d,bare:f=!1}){let p=s!==``,m=t?.relayUrl||e.relayUrl||`—`,h=r?`error`:Nj(n,t),[_,v]=g.useState({relay:!1}),[y,b]=g.useState(!1),[x,S]=g.useState(!1);VA(e.lastPairingAt,()=>S(!1));let C=t?.pairingCode===e.pairingCode,w=g.useRef(null),[T,E]=g.useState(0);g.useEffect(()=>{let e=w.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>E(Math.round(e.getBoundingClientRect().height));t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let D=e=>v(t=>({...t,[e]:!t[e]})),O=(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`${f?``:`mt-3`} flex flex-col gap-4 sm:flex-row sm:items-stretch`,children:[(0,U.jsx)(`div`,{className:`relative mx-auto aspect-square w-full max-w-[200px] shrink-0 self-center sm:mx-0 sm:h-[var(--qr-size)] sm:w-[var(--qr-size)] sm:max-w-none sm:self-start`,style:T>0?{"--qr-size":`${T}px`}:void 0,children:!t?.svg||!C?(0,U.jsx)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 rounded-md border border-border-muted bg-background-muted p-3 text-foreground-subtle`,children:c?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`span`,{className:`text-xs`,children:$(`panel.pairing.qrFailed`)}),(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:p,onClick:l,children:$(`panel.console.retryPairing`)})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(BE,{}),(0,U.jsx)(`span`,{className:`text-xs`,children:$(`panel.pairing.noQr`)})]})}):(0,U.jsxs)(`button`,{type:`button`,className:`absolute inset-0 flex cursor-zoom-in flex-col items-center justify-center gap-2 rounded-md border border-border-muted bg-background-muted p-3 text-foreground-subtle transition-colors hover:bg-background-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>S(!0),"aria-label":`${$(`panel.pairing.qrZoom`)}:${$(`panel.pairing.qr`)}`,children:[(0,U.jsx)(Aj,{}),(0,U.jsx)(`span`,{className:`text-xs`,children:$(`panel.pairing.qrHidden`)}),(0,U.jsx)(`span`,{className:`text-xs`,children:$(`panel.common.show`)})]})}),(0,U.jsx)(`div`,{ref:w,className:`flex min-w-0 flex-1 flex-col`,children:(0,U.jsxs)(rk,{className:nk,children:[(0,U.jsx)(ek,{label:$(`panel.connection.relayUrl`),nowrap:!0,children:(0,U.jsxs)(`span`,{className:`inline-flex min-w-0 flex-wrap items-center justify-end gap-x-2 gap-y-1`,children:[_.relay?(0,U.jsx)(`span`,{className:`min-w-0 font-mono text-xs text-foreground-strong`,children:m}):(0,U.jsx)(`span`,{className:`text-xs text-foreground-subtle`,children:$(`panel.pairing.hidden`)}),(0,U.jsx)(kj,{on:_.relay,what:$(`panel.connection.relayUrl`),label:_.relay?$(`panel.common.hide`):$(`panel.common.show`),onClick:()=>D(`relay`)})]})}),(0,U.jsx)(ek,{label:$(`panel.pairing.port`),mono:!0,nowrap:!0,children:(0,U.jsxs)(`span`,{className:`inline-flex flex-wrap items-center justify-end gap-x-2 gap-y-1`,children:[(0,U.jsxs)(`span`,{children:[t?.lanPort??e.lan.port,t?.lanPortAdjusted?(0,U.jsx)(`span`,{className:`ml-2 font-sans text-xs text-foreground-muted`,children:$(`panel.pairing.portFallback`)}):null]}),(0,U.jsx)(Q,{variant:`ghost`,size:`icon-sm`,"aria-label":$(`panel.pairing.portTitle`),title:$(`panel.pairing.portTitle`),disabled:p,onClick:d,children:(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:`m16 3 5 5M4 15 16 3a3.54 3.54 0 0 1 5 5L9 20l-6 1 1-6Z`})})})]})}),(0,U.jsx)(ek,{label:$(`panel.pairing.phoneAddress`),nowrap:!0,children:(0,U.jsxs)(`span`,{className:`inline-flex flex-wrap items-center justify-end gap-x-2 gap-y-1`,children:[h?null:(0,U.jsx)(`span`,{className:`text-xs text-foreground-subtle`,children:$(`panel.pairing.noAddress`)}),(0,U.jsx)(kj,{on:!1,what:$(`panel.pairing.phoneAddress`),label:$(`panel.common.show`),onClick:()=>b(!0)})]})}),(0,U.jsx)(ek,{label:$(`panel.update.runningVersion`),mono:!0,labelExtra:o.length>0?(0,U.jsx)(wk,{issue:o[0]}):void 0,children:a||$(`panel.update.unknownVersion`)})]})})]}),(0,U.jsx)(hD,{open:x,onOpenChange:S,children:(0,U.jsxs)(gD,{className:`w-[min(680px,94vw)] max-h-[90vh] max-w-none`,closeLabel:$(`panel.common.close`),children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.pairing.qr`)})}),(0,U.jsx)(bD,{children:(0,U.jsx)(`div`,{className:`flex items-center justify-center overflow-auto rounded-md bg-white p-2 sm:p-4`,children:t?.svg&&C?(0,U.jsx)(`div`,{className:`aspect-square h-[min(64vh,560px)] w-auto max-w-full [&_svg]:h-full [&_svg]:w-full`,dangerouslySetInnerHTML:{__html:t.svg}}):null})})]})}),(0,U.jsx)(hD,{open:y,onOpenChange:b,children:(0,U.jsxs)(gD,{className:`max-w-xl`,closeLabel:$(`panel.common.close`),children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.pairing.phoneAddress`)})}),(0,U.jsx)(bD,{children:(0,U.jsx)(Oj,{book:n,error:r,onRetry:i,port:t?.lanPort??e.lan.port,value:n?.preferred??``,busy:p,onChange:u,fallbackUrls:t?.lanUrls??[]})}),(0,U.jsx)(xD,{className:`flex justify-end`,children:(0,U.jsx)(Q,{variant:`outline`,onClick:()=>b(!1),children:$(`panel.common.close`)})})]})})]});return f?O:(0,U.jsxs)(cD,{frame:`solid`,children:[(0,U.jsx)(lD,{className:`flex-none px-4 py-3`,children:(0,U.jsx)(uD,{className:`text-base lg:text-lg`,children:$(`panel.pairing.cardTitle`)})}),O]})}function Mj({status:e,busy:t,onChangePolicy:n,onToggleRemote:r,onChangeControlReport:i}){let a=t!==``,o=e.pairingPolicy===`code`,s=e.controlReportEnabled!==!1,[c,l]=g.useState(!1);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ek,{label:$(`panel.pairing.policy`),children:(0,U.jsx)(ZD,{size:`md`,checked:o,disabled:a,onCheckedChange:e=>n(e?`code`:`deny`),"aria-label":$(`panel.devices.allowTitle`)})}),(0,U.jsx)(ek,{label:$(`panel.connection.remoteControl`),children:(0,U.jsx)(ZD,{size:`md`,checked:e.enabled,disabled:a,onCheckedChange:e=>r(e),"aria-label":$(`panel.connection.remoteControl`)})}),(0,U.jsx)(ek,{label:$(`panel.pairing.controlReport`),nowrap:!0,labelExtra:(0,U.jsx)(`button`,{type:`button`,"aria-label":$(`panel.pairing.controlReportInfo`),title:$(`panel.pairing.controlReportInfo`),className:`shrink-0 cursor-pointer rounded text-foreground-muted transition-colors duration-200 hover:text-foreground-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none`,onClick:()=>l(!0),children:(0,U.jsx)(uk,{})}),children:(0,U.jsx)(ZD,{size:`md`,checked:s,disabled:a,"aria-label":$(`panel.pairing.controlReport`),onCheckedChange:e=>{e!==s&&i(e)}})}),(0,U.jsx)(hD,{open:c,onOpenChange:l,children:(0,U.jsxs)(gD,{className:`max-w-md`,closeLabel:$(`panel.common.close`),children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.pairing.controlReport`)})}),(0,U.jsxs)(bD,{className:`whitespace-pre-line text-sm leading-6 text-foreground-muted`,children:[$(`panel.pairing.controlReportDetail`),`
106
106
 
107
- `,$(`panel.pairing.controlReportTarget`,{target:e.controlReportTargetUrl||$(`panel.pairing.controlReportUnknown`)}),e.relayUrl&&!oA(e.relayUrl)?`\n\n${$(`panel.pairing.controlReportSelfHosted`)}`:``]}),(0,U.jsx)(xD,{className:`flex justify-end`,children:(0,U.jsx)(Q,{variant:`outline`,onClick:()=>l(!1),children:$(`panel.common.close`)})})]})})]})}function Nj(e,t){return e&&e.lan.length+e.public.length>0?`book`:t?.lanUrls?.[0]??``}function Pj(e){return e.available?e.enabled?e.path===`direct`&&e.active?`panel.p2p.open`:e.error?`panel.p2p.error`:e.path===`failed`?`panel.p2p.blocked`:e.ready?e.path===`waiting`?`panel.p2p.waiting`:`panel.p2p.punching`:e.started?`panel.p2p.punching`:`panel.p2p.waiting`:`panel.p2p.disabled`:`panel.p2p.unavailable`}function Fj(e){return e.length>16?`${e.slice(0,12)}…${e.slice(-4)}`:e}function Ij({open:e,onOpenChange:t,onChanged:n}){let r=uO(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``),u=(0,g.useCallback)(async()=>{try{let e=await rO(`/api/relay/p2p`);a(e.status??null),s(``)}catch(e){s(cO(e))}},[]),d=async e=>{l(`toggle`);try{let t=await iO(`/api/relay/p2p/enabled`,{enabled:e});a(t.status??null),r(`soft`,$(e?`panel.p2p.enabledToast`:`panel.p2p.disabledToast`)),n?.()}catch(e){r(`error`,cO(e))}finally{l(``)}};(0,g.useEffect)(()=>{if(!e)return;let t=()=>{c_()&&u()};t();let n=window.setInterval(t,2e3);return document.addEventListener(`visibilitychange`,t),()=>{window.clearInterval(n),document.removeEventListener(`visibilitychange`,t)}},[e,u]);let f=i,p=Array.isArray(f?.candidates)?f.candidates:[];return(0,U.jsx)(hD,{open:e,onOpenChange:t,children:(0,U.jsxs)(gD,{className:`max-w-md`,children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.p2p.title`)})}),(0,U.jsxs)(bD,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.p2p.hint`)}),o?(0,U.jsx)(`p`,{className:`text-xs text-error`,children:o}):null,f===null?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,U.jsx)(BE,{}),$(`panel.shell.readingStatus`)]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.p2p.stateLabel`)}),(0,U.jsxs)(`span`,{className:`min-w-0 text-right text-sm break-all`,children:[$(Pj(f)),f.error?(0,U.jsx)(`span`,{className:`ml-1 text-xs text-foreground-muted`,children:f.error}):null]})]}),(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.p2p.addressLabel`)}),(0,U.jsx)(`span`,{className:`min-w-0 text-right font-mono text-xs break-all text-foreground-strong`,children:f.url||$(`panel.p2p.noAddress`)})]}),(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-4 border-b border-border-muted py-2`,children:[(0,U.jsx)(`span`,{className:`text-sm text-foreground-muted`,children:$(`panel.p2p.enableLabel`)}),(0,U.jsx)(ZD,{size:`md`,checked:f.enabled,disabled:!f.available||c!==``,onCheckedChange:e=>void d(e),"aria-label":$(`panel.p2p.enableLabel`)})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border-muted py-2`,children:[(0,U.jsxs)(`span`,{className:`text-sm text-foreground-muted`,children:[$(`panel.p2p.candidatesLabel`),` (`,p.length,`)`]}),p.length===0?(0,U.jsx)(`span`,{className:`text-xs text-foreground-muted`,children:$(`panel.p2p.noCandidates`)}):(0,U.jsx)(`ul`,{className:`flex flex-col gap-1`,children:p.map(e=>(0,U.jsx)(`li`,{className:`font-mono text-xs break-all text-foreground-strong`,children:e},e))})]}),(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 py-2`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.p2p.keyLabel`)}),(0,U.jsx)(`span`,{className:`min-w-0 text-right font-mono text-xs break-all text-foreground-strong`,children:f.publicKey?Fj(f.publicKey):$(`panel.p2p.noKey`)})]})]})]}),(0,U.jsx)(xD,{className:`flex justify-end gap-2`,children:(0,U.jsx)(Q,{variant:`outline`,disabled:c!==``,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}var Lj=function(e){let t=Md(),[n,r]=g.useState(t),[i,a]=g.useState(),[o,s]=g.useState([]),c=n===void 0?t:n,l=y(()=>new Map),{messageIds:u}=BD(),d=q((e,t)=>{let n=l.current;t===void 0?n.delete(e):n.set(e,t),r(e=>{if(n.size===0)return e;let t;for(let r of n.values()){if(r===e)return e;t===void 0&&(t=r)}return t})}),f=q(()=>{l.current.size===0&&r(t)}),p=g.useCallback(e=>{let t=e[`aria-describedby`]?e[`aria-describedby`].split(` `):[];return t.push(...u,...o),{...e,"aria-describedby":Array.from(new Set(t)).join(` `)||void 0}},[u,o]),m=g.useMemo(()=>({controlId:c,registerControlId:d,resetControlId:f,labelId:i,setLabelId:a,messageIds:o,setMessageIds:s,getDescriptionProps:p}),[c,d,f,i,a,o,s,p]);return(0,U.jsx)(zD.Provider,{value:m,children:e.children})};function Rj(e,t){let n=Md(e);return b(()=>(t(n),()=>{t(e=>e===n?void 0:e)}),[n,t]),n}function zj(e={}){let{id:t,fallbackControlId:n,native:r=!1,setLabelId:i,focusControl:a}=e,{controlId:o,setLabelId:s}=BD(),c=Rj(t,q(e=>{s(e),i?.(e)})),l=o??n;function u(e){if(a){a(e,l);return}if(!l)return;let t=Re(e.currentTarget).getElementById(l);ve(t)&&Bj(t)}function d(e){dt(e.nativeEvent)?.closest(`button,input,select,textarea`)||(!e.defaultPrevented&&e.detail>1&&e.preventDefault(),!r&&u(e))}return r?{id:c,htmlFor:l,onMouseDown:d}:{id:c,onClick:d,onPointerDown(e){e.preventDefault()}}}function Bj(e){e.focus({focusVisible:!0})}function Vj(e){let{change:t,commit:n,invalid:r,markedDirtyRef:i,name:a,setRegisteredFieldName:o,registeredFieldIdRef:s,setValidityData:c,validityData:l}=e,{formRef:u}=RD(),d=g.useRef(null),f=g.useRef(null),p=g.useRef(!1),m=q(()=>{let e=f.current;if(e)return e.getValue?e.getValue():e.value});function h(e){return e.value===void 0?m():e.value}let _=q(()=>{let e=f.current;if(i.current=!0,!e){n(l.value);return}n(h(e))});function v(){let e=f.current;e&&e.id&&u.current.fields.set(e.id,{getValue:m,name:a??e.name,controlRef:e.controlRef,validityData:dj(l,r),validate:_})}function y(e=f.current?.id){e&&u.current.fields.delete(e)}function x(e){if(p.current)return;p.current=!0;let t=h(e);c(e=>e.initialValue===t?e:{...e,initialValue:t})}return b(()=>{let e=f.current;e&&e.id&&(o(a?void 0:e.name),u.current.fields.set(e.id,{getValue:m,name:a??e.name,controlRef:e.controlRef,validityData:dj(l,r),validate:_}))},[u,m,r,a,o,_,l]),b(()=>{let e=u.current.fields;return()=>{let t=f.current?.id;t&&e.delete(t)}},[u]),[_,q((e,n)=>{if(!n){d.current===e&&(d.current=null,t(void 0,!0),y(),f.current=null,o(void 0),s.current=void 0);return}let r=f.current?.id,i=d.current;i&&i!==e&&t(void 0,!0),d.current=e,f.current=n,a||o(n.name),s.current=n.id,r&&r!==n.id&&y(r),x(n),v()})]}var Hj=g.forwardRef(function(e,t){let{errors:n,validationMode:r,submitCountRef:i}=RD(),{render:a,className:o,validate:s,validationDebounceTime:c=0,validationMode:l=r,name:u,disabled:d=!1,invalid:f,dirty:p,touched:m,actionsRef:h,style:_,...v}=e,y=yj(!0)?.disabled,x=q(s||(()=>null)),S=y||d,[C,w]=g.useState(!1),[T,E]=g.useState(!1),[D,O]=g.useState(!1),[k,A]=g.useState(!1),j=p??T,M=m??C,N=g.useRef(j),P=g.useRef(void 0),[F,I]=g.useState(),L=u??F;b(()=>{p!==void 0&&(N.current=p)},[p]);let R=q(e=>{p===void 0&&(e&&(N.current=!0),E(e))}),z=q(e=>{m===void 0&&w(e)}),B=q(()=>l===`onChange`||l===`onSubmit`&&i.current>0),V=L&&Object.hasOwn(n,L)?n[L]:null,H=!!(Array.isArray(V)?V.length:V),ee=f===!0||H,[te,ne]=g.useState({state:DD,error:``,errors:[],value:null,initialValue:null}),W=!ee&&(S?null:te.state.valid),re=g.useMemo(()=>({disabled:S,touched:M,dirty:j,valid:W,filled:D,focused:k}),[S,M,j,W,D,k]),G=_j({setValidityData:ne,validate:x,validityData:te,validationDebounceTime:c,invalid:ee,markedDirtyRef:N,state:re,shouldValidateOnChange:B,validationMode:l,registeredFieldIdRef:P}),[K,ie]=Vj({change:G.change,commit:G.commit,invalid:ee,markedDirtyRef:N,name:u,setRegisteredFieldName:I,registeredFieldIdRef:P,setValidityData:ne,validityData:te});g.useImperativeHandle(h,()=>({validate:K}),[K]);let ae=g.useMemo(()=>({invalid:ee,name:L,validityData:te,setValidityData:ne,disabled:S,setTouched:z,setDirty:R,setFilled:O,setFocused:A,validationMode:l,shouldValidateOnChange:B,state:re,registerFieldControl:ie,validation:G}),[ee,L,te,S,z,R,O,A,l,B,re,ie,G]),oe=Hr(`div`,e,{ref:t,state:re,props:v,stateAttributesMapping:kD});return(0,U.jsx)(PD.Provider,{value:ae,children:oe})}),Uj=g.forwardRef(function(e,t){return(0,U.jsx)(Lj,{children:(0,U.jsx)(Hj,{...e,ref:t})})}),Wj=g.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,nativeLabel:o=!0,...s}=e,c=FD(!1),l=qA(),{labelId:u}=BD(),d={...c.state,disabled:c.disabled||l.disabled},f=g.useRef(null),p=zj({id:u??a,native:o});return Hr(`label`,e,{ref:[t,f],state:d,props:[p,s],stateAttributesMapping:kD})}),Gj=g.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:_,setDirty:v,validityData:y,setFocused:x,setFilled:S,validationMode:C,validation:w}=FD(),{clearErrors:T,elementRef:E,submitCountRef:D}=RD(),O=h||s,k=m??a,A={...p,disabled:O},{labelId:j}=BD(),M=WD({id:i}),[N]=vf({controlled:o,default:l,name:`FieldControl`,state:`value`}),P=o!==void 0,F=P?N:void 0,I=F==null?void 0:String(F),L=q(()=>w.inputRef.current?.value);ID(w.inputRef,M,I,L,!O,a),b(()=>{let e=I??w.inputRef.current?.value;e!==void 0&&S(e!==``)},[I,w.inputRef,S]),Kf(I,()=>{I!==void 0&&(T(k),v(I!==(y.initialValue??``)),w.change(I))});let R=g.useRef(null),z=Ke();return b(()=>{u&&R.current===ut(Re(R.current))&&x(!0)},[u,x]),Hr(`input`,e,{ref:[t,R],state:A,props:[{id:M,disabled:O,name:k,ref:w.inputRef,"aria-labelledby":j,autoFocus:u,...P?{value:F}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=ja(ha,e.nativeEvent);c?.(t,n),!P&&(v(t!==(y.initialValue??``)),S(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(T(k),w.change(t)))},onFocus(){x(!0)},onBlur(e){if(_(!0),x(!1),C===`onBlur`){let t=e.currentTarget.value;w.commit(t),P&&queueMicrotask(()=>{let e=w.inputRef.current?.value;e!==void 0&&e!==t&&e!==(y.initialValue??``)&&w.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){_(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===E.current&&!e.defaultPrevented){let t=e.currentTarget,n=D.current;z.start(0,()=>{D.current===n&&w.commit(t.value)})}else w.commit(t)}}},f,e=>w.getValidationProps(O,e)],stateAttributesMapping:kD})});function Kj({className:e,...t}){return(0,U.jsx)(Uj,{"data-slot":`field`,className:Z(e),...t})}function qj({className:e,...t}){return(0,U.jsx)(Wj,{"data-slot":`field-label`,className:Z(`text-foreground-intense mb-1.5 flex w-fit items-center text-sm font-medium select-none`,`data-disabled:opacity-disabled`,e),...t})}var Jj=g.forwardRef(function(e,t){return(0,U.jsx)(Gj,{ref:t,...e})}),Yj=Uu(`w-full border text-foreground outline-none transition-[background-color,border-color,box-shadow] duration-200 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{outline:`bg-background border-border-strong hover:not-focus:not-focus-visible:not-has-focus:not-has-focus-visible:not-data-popup-open:not-has-data-popup-open:not-data-pressed:not-has-data-pressed:not-data-invalid:not-has-data-invalid:border-border-emphasis`,soft:`bg-background-muted border-transparent hover:not-focus:not-focus-visible:not-has-focus:not-has-focus-visible:not-data-popup-open:not-has-data-popup-open:not-data-pressed:not-has-data-pressed:not-data-invalid:not-has-data-invalid:border-border-strong`},size:{sm:`h-8 px-3 text-xs pointer-coarse:text-base rounded-sm gap-1.5 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75]`,md:`h-10 px-3.5 text-sm pointer-coarse:text-base rounded-md gap-2 [&_svg:not([class*='size-'])]:size-4.5 [&_svg:not([class*='stroke-'])]:stroke-[1.65]`,lg:`h-12 px-4 text-base rounded-lg gap-2 [&_svg:not([class*='size-'])]:size-5 [&_svg:not([class*='stroke-'])]:stroke-[1.65]`},state:{self:Z(`focus-visible:ring-3 focus-visible:ring-ring-input focus-visible:border-transparent focus-visible:bg-background`,`data-popup-open:ring-3 data-popup-open:ring-ring-input data-popup-open:border-transparent data-popup-open:bg-background`,`data-pressed:ring-3 data-pressed:ring-ring-input data-pressed:border-transparent data-pressed:bg-background`,`data-invalid:bg-error-subtle data-invalid:border-error`,`data-invalid:focus-visible:border-transparent data-invalid:focus-visible:ring-ring-error data-invalid:focus-visible:bg-background`,`data-invalid:data-popup-open:border-transparent data-invalid:data-popup-open:ring-ring-error data-invalid:data-popup-open:bg-background`,`data-invalid:data-pressed:border-transparent data-invalid:data-pressed:ring-ring-error data-invalid:data-pressed:bg-background`,`data-disabled:border-border-strong! data-disabled:bg-background-subtle! data-disabled:cursor-not-allowed data-disabled:border-dashed data-disabled:opacity-disabled`),within:Z(`flex items-center`,`has-focus:ring-[3px] has-focus:ring-ring-input has-focus:border-transparent has-focus:bg-background`,`has-data-popup-open:ring-3 has-data-popup-open:ring-ring-input has-data-popup-open:border-transparent has-data-popup-open:bg-background`,`has-data-pressed:ring-3 has-data-pressed:ring-ring-input has-data-pressed:border-transparent has-data-pressed:bg-background`,`data-invalid:bg-error-subtle data-invalid:border-error data-invalid:has-focus:border-transparent data-invalid:has-focus:ring-ring-error data-invalid:has-focus:bg-background`,`data-invalid:has-data-popup-open:border-transparent data-invalid:has-data-popup-open:ring-ring-error data-invalid:has-data-popup-open:bg-background`,`data-invalid:has-data-pressed:border-transparent data-invalid:has-data-pressed:ring-ring-error data-invalid:has-data-pressed:bg-background`,`has-data-invalid:bg-error-subtle has-data-invalid:border-error has-data-invalid:has-focus:border-transparent has-data-invalid:has-focus:ring-ring-error has-data-invalid:has-focus:bg-background`,`has-data-invalid:has-data-popup-open:border-transparent has-data-invalid:has-data-popup-open:ring-ring-error has-data-invalid:has-data-popup-open:bg-background`,`has-data-invalid:has-data-pressed:border-transparent has-data-invalid:has-data-pressed:ring-ring-error has-data-invalid:has-data-pressed:bg-background`,`has-[input:disabled]:border-border-strong! has-[input:disabled]:bg-background-subtle! has-[input:disabled]:cursor-not-allowed has-[input:disabled]:border-dashed has-[input:disabled]:opacity-disabled`)}},defaultVariants:{variant:`outline`,size:`md`,state:`self`}});function Xj(e,t){(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`)?.set)?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function Zj({className:e,variant:t=`outline`,inputSize:n=`md`,clearable:r,startSlot:i,endSlot:a,onClear:o,inputProps:s,ref:c,...l}){let u=g.useRef(null),d=!!(r||i||a),f=l[`aria-invalid`],p=f===!0||f===`true`,m=zu(c,u),h=()=>{u.current&&l.value===void 0&&Xj(u.current,``),u.current?.focus(),o?.()};return d?(0,U.jsxs)(`div`,{"data-slot":`input-wrapper`,className:Z(Yj({variant:t,size:n,state:`within`}),e),...p?{"data-invalid":``}:{},children:[i&&(0,U.jsx)(`div`,{"data-slot":`input-start`,className:`-ms-1 flex shrink-0 items-center`,children:i}),(0,U.jsx)(Jj,{"data-slot":`input`,ref:m,placeholder:l.placeholder??` `,...s,className:Z(`peer text-foreground placeholder:text-foreground-subtle h-full min-w-0 flex-1 bg-transparent outline-none disabled:cursor-not-allowed`,s?.className),...l}),r&&(0,U.jsx)(`button`,{"data-slot":`input-clear`,type:`button`,onClick:h,className:`text-foreground-subtle hover:text-foreground pointer-events-none shrink-0 cursor-pointer opacity-0 transition-[opacity,color] duration-200 peer-not-placeholder-shown:pointer-events-auto peer-not-placeholder-shown:opacity-100`,tabIndex:-1,"aria-label":`Clear input`,children:(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`2 2 16 16`,fill:`currentColor`,className:`size-[1em]`,children:(0,U.jsx)(`path`,{d:`M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z`})})}),a&&(0,U.jsx)(`div`,{"data-slot":`input-end`,className:`-me-1 flex shrink-0 items-center`,children:a})]}):(0,U.jsx)(Jj,{"data-slot":`input`,ref:m,...s,className:Z(Yj({variant:t,size:n,state:`self`}),`placeholder:text-foreground-subtle`,s?.className,e),...l,...p?{"data-invalid":``}:{}})}var Qj=1024,$j=65535;function eM({open:e,onOpenChange:t,port:n,busy:r,fixed:i,forwarding:a,onSave:o}){let[s,c]=(0,g.useState)(String(n)),[l,u]=(0,g.useState)(i);(0,g.useEffect)(()=>{e&&(c(String(n)),u(i))},[e]);let d=s.trim(),f=Number(d),p=d!==``&&Number.isInteger(f)&&f>=Qj&&f<=$j&&r===``;return(0,U.jsx)(hD,{open:e,onOpenChange:t,children:(0,U.jsxs)(gD,{className:`max-w-sm`,children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.pairing.portTitle`)})}),(0,U.jsxs)(bD,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(Kj,{children:[(0,U.jsx)(qj,{htmlFor:`relay-lan-port`,children:$(`panel.pairing.port`)}),(0,U.jsx)(Zj,{inputProps:{id:`relay-lan-port`,inputMode:`numeric`},value:s,onChange:e=>c(e.target.value)})]}),(0,U.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(`panel.pairing.portHint`)}),(0,U.jsxs)(Kj,{children:[(0,U.jsx)(qj,{htmlFor:`relay-port-fixed`,children:$(`panel.pairing.portFixed`)}),(0,U.jsx)(ZD,{id:`relay-port-fixed`,size:`md`,checked:l,disabled:r!==``,onCheckedChange:u,"aria-label":$(`panel.pairing.portFixed`)})]}),(0,U.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(a?`panel.pairing.portForwarding`:`panel.pairing.portFixedHint`)})]}),(0,U.jsxs)(xD,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(Q,{variant:`outline`,disabled:r!==``,onClick:()=>t(!1),children:$(`panel.common.cancel`)}),(0,U.jsx)(Q,{variant:`primary`,disabled:!p,onClick:()=>o(f,l),children:$(`panel.common.save`)})]})]})})}function tM({visible:e,onOpenConfig:t}){let[n,r]=(0,g.useState)(!1);return!e||n?null:(0,U.jsx)(hD,{open:!0,onOpenChange:e=>{e||r(!0)},children:(0,U.jsxs)(gD,{className:`max-w-md`,children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.publicRelayNotice.title`)})}),(0,U.jsx)(bD,{className:`whitespace-pre-line text-sm leading-6 text-foreground-muted`,children:$(`panel.publicRelayNotice.body`)}),(0,U.jsxs)(xD,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(Q,{variant:`outline`,onClick:()=>{r(!0),t()},children:$(`panel.pairing.openConfig`)}),(0,U.jsx)(Q,{variant:`primary`,onClick:()=>r(!0),children:$(`panel.publicRelayNotice.action`)})]})]})})}var nM={sm:`py-2`,md:`py-2.5`,lg:`py-3`},rM={sm:`min-h-16`,md:`min-h-20`,lg:`min-h-24`},iM={sm:`0.5rem`,md:`0.625rem`,lg:`0.75rem`};function aM(e,t){(Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,`value`)?.set)?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function oM({className:e,variant:t=`outline`,inputSize:n=`md`,clearable:r,startSlot:i,endSlot:a,onClear:o,ref:s,rows:c=3,...l}){let u=g.useRef(null),d=zu(s,u),f=!!(r||i||a),p=l[`aria-invalid`],m=p===!0||p===`true`,h=()=>{u.current&&l.value===void 0&&aM(u.current,``),u.current?.focus(),o?.()};return f?(0,U.jsxs)(`div`,{"data-slot":`textarea-wrapper`,"data-invalid":m?``:void 0,style:{"--textarea-h":`calc(${c} * 1lh + 2 * ${iM[n]} + 2px)`},className:Z(Yj({variant:t,size:n,state:`within`}),`h-(--textarea-h) resize-y items-start overflow-hidden`,rM[n],nM[n],`has-[textarea:disabled]:border-border-strong! has-[textarea:disabled]:bg-background-subtle! has-[textarea:disabled]:opacity-disabled has-[textarea:disabled]:cursor-not-allowed has-[textarea:disabled]:border-dashed`,e),children:[i&&(0,U.jsx)(`div`,{"data-slot":`textarea-start`,className:`-ms-1 inline-flex h-lh shrink-0 items-center`,children:i}),(0,U.jsx)(Gj,{"data-slot":`textarea`,ref:d,render:(0,U.jsx)(`textarea`,{rows:c}),placeholder:l.placeholder??` `,className:`peer text-foreground placeholder:text-foreground-subtle min-w-0 flex-1 resize-none self-stretch bg-transparent outline-none disabled:cursor-not-allowed`,...l}),r&&(0,U.jsx)(`button`,{"data-slot":`textarea-clear`,type:`button`,onClick:h,className:`text-foreground-subtle hover:text-foreground pointer-events-none inline-flex h-lh shrink-0 cursor-pointer items-center opacity-0 transition-[opacity,color] duration-200 peer-not-placeholder-shown:pointer-events-auto peer-not-placeholder-shown:opacity-100 motion-reduce:transition-none`,tabIndex:-1,"aria-label":`Clear input`,children:(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`2 2 16 16`,fill:`currentColor`,className:`size-[1em]`,children:(0,U.jsx)(`path`,{d:`M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z`})})}),a&&(0,U.jsx)(`div`,{"data-slot":`textarea-end`,className:`-me-1 inline-flex h-lh shrink-0 items-center`,children:a})]}):(0,U.jsx)(Gj,{"data-slot":`textarea`,ref:d,render:(0,U.jsx)(`textarea`,{rows:c}),className:Z(Yj({variant:t,size:n,state:`self`}),`placeholder:text-foreground-subtle h-auto resize-y`,nM[n],rM[n],e),...l,...m?{"data-invalid":``}:{}})}function sM(e){return String(e||``).replace(/\s+#.*$/,``).trim().replace(/^["']/,``).replace(/["']$/,``).trim()}function cM(e){let t={};for(let n of String(e||``).split(/\r?\n/)){let e=n.trim();if(!e||e.startsWith(`#`)||e.startsWith(`;`)||e.startsWith(`[`))continue;let r=/^([A-Za-z0-9_.]+)\s*[=:]\s*(.+)$/.exec(e);if(!r)continue;let i=r[1].toLowerCase();i in t||(t[i]=sM(r[2]))}return t}function lM(e){let t=String(e||``).trim();if(!t)return[];let n=[...t.matchAll(/["']([^"']+)["']/g)].map(e=>e[1].trim()).filter(Boolean);return n.length?n:t.replace(/^\[|\]$/g,``).split(/[,\s]+/).map(e=>e.trim()).filter(Boolean)}function uM(e){let t=(...t)=>{for(let n of t)if(e[n])return e[n];return``};return{type:(t(`type`)||``).toLowerCase(),remotePort:t(`remoteport`,`remote_port`),localPort:t(`localport`,`local_port`),domains:lM(t(`customdomains`,`custom_domains`))}}function dM(e){let t=e.split(/\[\[\s*proxies\s*\]\]/i),n=cM(t[0]);return{serverAddr:n.serveraddr||n.server_addr||``,proxies:t.slice(1).map(e=>uM(cM(e)))}}function fM(e){let t=[{name:`__global__`,pairs:{}}];for(let n of e.split(/\r?\n/)){let e=n.trim();if(!e||e.startsWith(`#`)||e.startsWith(`;`))continue;let r=/^\[([^\]]+)\]$/.exec(e);if(r){t.push({name:r[1].trim().toLowerCase(),pairs:{}});continue}let i=/^([A-Za-z0-9_.]+)\s*[=:]\s*(.+)$/.exec(e);if(!i)continue;let a=t[t.length-1],o=i[1].toLowerCase();o in a.pairs||(a.pairs[o]=sM(i[2]))}let n=t.find(e=>e.name===`common`)||t[0];return{serverAddr:n.pairs.server_addr||n.pairs.serveraddr||``,proxies:t.filter(e=>e.name!==`__global__`&&e.name!==`common`).map(e=>uM(e.pairs))}}function pM(e){let t;try{t=JSON.parse(e)}catch{return null}let n=t&&typeof t==`object`?t:{};return{serverAddr:typeof n.serverAddr==`string`?n.serverAddr:typeof n.server_addr==`string`?n.server_addr:``,proxies:(Array.isArray(n.proxies)?n.proxies:[]).map(e=>{let t=e&&typeof e==`object`?e:{},n=e=>typeof e==`string`||typeof e==`number`?String(e):``,r=t.customDomains??t.custom_domains;return{type:n(t.type).toLowerCase(),remotePort:n(t.remotePort??t.remote_port),localPort:n(t.localPort??t.local_port),domains:Array.isArray(r)?r.map(e=>String(e)):lM(n(r))}})}}function mM(e){if(!/^\d+$/.test(String(e||``)))return null;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=65535?t:null}function hM(e,t){for(let n of t){if(n.type&&n.type!==`tcp`)continue;let t=mM(n.remotePort);if(e&&t!==null)return{ok:!0,field:`tcp`,value:`${e}:${t}`,kind:`tcp`}}for(let e of t)if((e.type===`https`||e.type===`http`)&&e.domains.length)return{ok:!0,field:`direct`,value:`https://${e.domains[0]}`,kind:`https`};for(let n of t){if(n.type&&n.type!==`tcp`)continue;let t=mM(n.localPort);if(e&&t!==null)return{ok:!0,field:`tcp`,value:`${e}:${t}`,kind:`tcp`,note:`inferred-local-port`,port:t}}return{ok:!1,reason:`no-address`}}function gM(e){let t=String(e||``).trim();if(!t)return{ok:!1,reason:`empty`};let n=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``).replace(/\/+$/,``).trim(),r=/^(\[[^\]]+\]|[^\s/:?#]+):(\d+)$/.exec(n);if(r){let e=Number(r[2]);return Number.isInteger(e)&&e>=1&&e<=65535?{ok:!0,field:`tcp`,value:`${r[1]}:${e}`,kind:`tcp`}:{ok:!1,reason:`bad-tcp`}}let i;return i=t.startsWith(`{`)?pM(t)||{serverAddr:``,proxies:[]}:/\[\[\s*proxies\s*\]\]/i.test(t)?dM(t):/^\s*\[common\]\s*$/im.test(t)||/(?:^|[\r\n])\s*server_addr\s*=/i.test(t)?fM(t):dM(t),hM(i.serverAddr,i.proxies)}function _M(e){return/serverAddr|server_addr|\[\[\s*proxies\s*\]\]|\[common\]/i.test(e)}function vM({open:e,onOpenChange:t,onImport:n}){let[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(``),s=(0,g.useMemo)(()=>gM(r),[r]);(0,g.useEffect)(()=>{e&&o(``)},[e]);function c(){if(!s.ok)return;if(/^\s*\[common\]\s*$/im.test(r)||/^\s*server_addr\s*=/im.test(r)){o($(`panel.frp.iniUnsupported`));return}let e=s.value;n({field:s.field,value:e,..._M(r)?{config:r}:{}}),t(!1)}return(0,U.jsx)(hD,{open:e,onOpenChange:t,children:(0,U.jsxs)(gD,{className:`w-[min(560px,92vw)]`,children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.frp.title`)})}),(0,U.jsxs)(bD,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.frp.hint`)}),(0,U.jsxs)(Kj,{children:[(0,U.jsx)(qj,{htmlFor:`frp-import`,children:$(`panel.frp.label`)}),(0,U.jsx)(oM,{id:`frp-import`,rows:6,value:r,onChange:e=>i(e.target.value),autoComplete:`off`,spellCheck:!1})]}),r.trim()?s.ok?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{role:`status`,className:`text-xs text-foreground-muted`,children:$(s.field===`tcp`?`panel.frp.detectedTcp`:`panel.frp.detectedDirect`,{address:s.value})}),s.note===`inferred-local-port`?(0,U.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(`panel.frp.inferredPort`,{port:s.port??``})}):null]}):(0,U.jsx)(`p`,{className:`text-xs text-error`,children:$(s.reason===`empty`?`panel.frp.empty`:`panel.frp.badFormat`)}):null,a?(0,U.jsx)(`p`,{className:`text-xs text-error`,children:a}):null]}),(0,U.jsxs)(xD,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(Q,{variant:`outline`,onClick:()=>t(!1),children:$(`panel.common.cancel`)}),(0,U.jsx)(Q,{variant:`primary`,disabled:!s.ok,onClick:c,children:$(`panel.frp.fill`)})]})]})})}var yM=.7,bM=2;function xM(e){let t=Number.isFinite(e)&&e>0?e:0;return t>=600?1:t<=100?t/100*yM:yM+(t-100)/500*.30000000000000004}function SM(e,t,n){let r=e.map(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0?e:null);if(!r.some(e=>e!==null))return``;let i=r.length>1?t/(r.length-1):0,a=Math.max(1,n-4),o=[],s=!1;return r.forEach((e,n)=>{if(e===null){s=!1;return}let c=r.length>1?n*i:t/2,l=bM+xM(e)*a;o.push(`${s?`L`:`M`}${c.toFixed(1)} ${l.toFixed(1)}`),s=!0}),o.join(` `)}function CM(e){return typeof e!=`number`||!Number.isFinite(e)?`none`:e<=100?`fast`:e<=600?`ok`:`slow`}var wM=5e3,TM=132,EM=28;function DM(e){return e===`fast`?`text-success`:e===`ok`?`text-warning`:e===`slow`?`text-destructive`:`text-foreground-muted`}function OM(e){return e===`fast`?`#16a34a`:e===`ok`?`#d97706`:e===`slow`?`#dc2626`:`#9ca3af`}function kM(e){return typeof e!=`number`||!Number.isFinite(e)?`—`:`${Math.round(e)} ms`}function AM({open:e,onOpenChange:t,activeUrl:n}){let[r,i]=(0,g.useState)({}),[a,o]=(0,g.useState)(``),s=(0,g.useRef)(!1),c=n.trim().replace(/\/+$/,``),l=[...new Set([...aA.map(e=>e.url),.../^https?:\/\//i.test(c)?[c]:[]])],u=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(!e){u.current!==null&&(clearInterval(u.current),u.current=null);return}let t=!0;o(``);let n=[...new Set([...aA.map(e=>e.url),.../^https?:\/\//i.test(c)?[c]:[]])];i(Object.fromEntries(n.map(e=>[e,[null]])));async function r(){if(t&&!s.current){s.current=!0;try{let e=await iO(`/api/relay/probe-relays`,{urls:n});if(!t)return;let r=new Map((e.results||[]).map(e=>[e.url,e.ms]));i(e=>{let t={};for(let i of n)t[i]=[...e[i]||[],r.get(i)??null].slice(-14);return t}),o(``)}catch(e){t&&(i(e=>Object.fromEntries(n.map(t=>[t,[...e[t]||[],null].slice(-14)]))),o(cO(e)))}finally{s.current=!1}}}return r(),u.current=setInterval(()=>{r()},wM),()=>{t=!1,u.current!==null&&(clearInterval(u.current),u.current=null)}},[e,c]),(0,U.jsx)(hD,{open:e,onOpenChange:t,children:(0,U.jsxs)(gD,{children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.relay.panelTitle`)})}),(0,U.jsxs)(bD,{className:`flex max-h-[60vh] flex-col gap-1 overflow-y-auto`,children:[(0,U.jsx)(`p`,{className:`mb-2 text-xs text-foreground-muted`,children:$(`panel.relay.panelHint`)}),l.map(e=>{let t={url:e},i=r[t.url]||[null],a=i[i.length-1]??null,o=CM(a),s=SM(i,TM,EM),c=t.url===n;return(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border-muted px-3 py-2`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate font-mono text-sm`,children:t.url}),c?(0,U.jsx)(`span`,{className:`text-xs text-primary`,children:$(`panel.relay.selected`)}):null]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3`,children:[s?(0,U.jsx)(`svg`,{width:TM,height:EM,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:s,stroke:OM(o),strokeWidth:1.5,fill:`none`})}):null,(0,U.jsx)(`span`,{className:`w-16 text-right text-sm tabular-nums ${DM(o)}`,children:kM(a)})]})]},t.url)}),a?(0,U.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:a}):null]}),(0,U.jsx)(xD,{children:(0,U.jsx)(Q,{variant:`outline`,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}function jM({id:e,value:t,placeholder:n,ariaLabel:r,options:i,emptyText:a,onChange:o}){return(0,U.jsx)(Zj,{inputProps:{id:e,className:`font-mono`},value:t,placeholder:n,onChange:e=>o(e.target.value),endSlot:(0,U.jsxs)(kh,{children:[(0,U.jsx)(Ah,{"aria-label":r,className:`-mr-1 flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded text-foreground-muted hover:text-foreground-strong focus-visible:outline-none`,children:(0,U.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`size-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}),(0,U.jsx)(Nh,{align:`end`,style:{width:`auto`,minWidth:`18rem`,maxWidth:`32rem`},children:i.length===0?(0,U.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground-muted`,children:a}):i.map(e=>(0,U.jsx)(Ih,{onClick:()=>o(e.value),children:(0,U.jsx)(`span`,{className:`font-mono text-xs break-all`,children:e.label})},e.value))})]})})}function MM({open:e,onOpenChange:t,status:n,addressBook:r,addressError:i=``,onRetryAddresses:a,lanUrls:o,busy:s,onSave:c,onSavePreferred:l}){let[u,d]=(0,g.useState)(n.relayUrl),[f,p]=(0,g.useState)(``),[m,h]=(0,g.useState)(``),[_,v]=(0,g.useState)(``),[y,b]=(0,g.useState)(``),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(!1),[D,O]=(0,g.useState)(),[k,A]=(0,g.useState)(!1),j=(0,g.useRef)(null),M=(0,g.useRef)(null),N=(0,g.useRef)(!1),P=(0,g.useRef)(!1),F=(0,g.useRef)(!1),I=(0,g.useRef)(!1),L=r?r.lan.length>0?r.lan:r.public:[];(0,g.useEffect)(()=>{e&&d(n.relayUrl)},[e]),(0,g.useEffect)(()=>{e||(w(!1),E(!1),O(void 0))},[e]),(0,g.useEffect)(()=>{if(!e){N.current=!1,P.current=!1,F.current=!1,I.current=!1,S(``);return}if(N.current||p(r?.manual??``),P.current||h(r?.manualIpv6||r?.ipv6?.[0]?.url||``),F.current||v(r?.manualTcp??``),!I.current){let e=r?r.lan.length>0?r.lan:r.public:[];b((r?.preferred||``).trim()||(e[0]?.address??``))}},[e,r]);let R=s===``,z=aA.find(e=>e.url===u.trim())??null,B=n.publicRelayBlocked===!0,V=e=>e.trim().replace(/\/+$/,``);function H(){if(!R)return;let e={};z?e.relayUrls=aA.map(e=>e.url):u.trim()!==n.relayUrl&&(e.relayUrl=u.trim());let t=V(f);t!==V(r?.manual??``)&&(e.manualLanUrl=t);let i=V(m);i!==V(r?.manualIpv6||r?.ipv6?.[0]?.url||``)&&(e.manualIpv6Url=i);let a=V(_);a!==V(r?.manualTcp??``)&&(e.manualTcpUrl=a);let o=y.trim();if(I.current&&o!==(r?.preferred??``).trim()){if(o&&!L.some(e=>e.address===o)){S($(`panel.address.lanUnknown`));return}e.preferredLanAddress=o}c(e,D)}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(hD,{open:e,onOpenChange:e=>{s!==`config`&&t(e)},children:(0,U.jsxs)(gD,{className:`w-[min(1100px,92vw)]`,initialFocus:M,children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.pairing.openConfig`)})}),(0,U.jsx)(`div`,{ref:M,tabIndex:-1,className:`outline-none`,children:(0,U.jsxs)(bD,{className:`grid max-h-[calc(100vh-13rem)] grid-cols-2 items-start gap-x-8 gap-y-4 overflow-y-auto`,children:[(0,U.jsxs)(Kj,{children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,U.jsx)(qj,{children:$(`panel.relay.publicKind`)}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>A(!0),children:$(`panel.relay.viewPanel`)}),(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:!R||B,onClick:()=>d(z?``:aA[0].url),children:$(z?`panel.relay.disablePublic`:`panel.relay.enablePublic`)})]})]}),B?(0,U.jsx)(Zj,{inputProps:{className:`text-foreground-muted`,readOnly:!0,"aria-label":$(`panel.relay.publicKind`)},value:$(`panel.relay.publicDisabled`)}):(0,U.jsx)(`div`,{className:`flex flex-col gap-1`,children:aA.map(e=>(0,U.jsx)(Zj,{inputProps:{className:`font-mono`,readOnly:!0,"aria-label":$(`panel.relay.publicKind`)},value:e.url},e.url))})]}),(0,U.jsxs)(Kj,{children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,U.jsx)(qj,{htmlFor:`relay-url`,children:$(`panel.relay.selfKind`)}),(0,U.jsx)(`a`,{href:nA,target:`_blank`,rel:`noreferrer noopener`,className:Gu({variant:`ghost`,size:`sm`}),children:$(`panel.relay.selfRepo`)})]}),(0,U.jsx)(Zj,{inputProps:{id:`relay-url`,className:`font-mono`},value:z?``:u,placeholder:`https://example.com`,onChange:e=>d(e.target.value)})]}),(0,U.jsxs)(Kj,{children:[(0,U.jsx)(qj,{htmlFor:`relay-manual-lan`,children:$(`panel.address.direct`)}),(0,U.jsx)(Zj,{inputProps:{id:`relay-manual-lan`,className:`font-mono`},value:f,placeholder:$(`panel.address.directPlaceholder`),onChange:e=>{N.current=!0,p(e.target.value)}})]}),(0,U.jsxs)(Kj,{children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,U.jsx)(qj,{htmlFor:`relay-manual-tcp`,children:$(`panel.address.tcp`)}),(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>E(!0),children:$(`panel.address.frpImport`)})]}),(0,U.jsx)(Zj,{inputProps:{id:`relay-manual-tcp`,className:`font-mono`},value:_,placeholder:$(`panel.address.tcpPlaceholder`),onChange:e=>{F.current=!0,v(e.target.value)}})]}),(0,U.jsxs)(Kj,{children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,U.jsx)(qj,{htmlFor:`relay-preferred-lan`,children:$(`panel.address.lan`)}),(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>w(!0),children:$(`panel.onboarding.chooseAddress`)})]}),(0,U.jsx)(jM,{id:`relay-preferred-lan`,value:y,placeholder:$(`panel.address.lanPlaceholder`),ariaLabel:$(`panel.address.lan`),options:L.map(e=>({value:e.address,label:e.url})),emptyText:$(`panel.address.empty`),onChange:e=>{I.current=!0,S(``),b(e)}}),x?(0,U.jsx)(`p`,{className:`text-xs text-error`,children:x}):null,i?(0,U.jsxs)(`p`,{className:`text-xs text-error`,children:[$(`panel.address.loadFailed`),(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:a,children:$(`panel.address.retry`)})]}):null]}),(0,U.jsxs)(Kj,{children:[(0,U.jsx)(qj,{htmlFor:`relay-manual-ipv6`,children:$(`panel.address.ipv6Url`)}),(0,U.jsx)(jM,{id:`relay-manual-ipv6`,value:m,placeholder:$(`panel.address.ipv6Placeholder`),ariaLabel:$(`panel.address.ipv6Url`),options:(r?.ipv6??[]).map(e=>({value:e.url,label:e.interface?`${e.url} · ${e.interface}`:e.url})),emptyText:$(`panel.address.empty`),onChange:e=>{P.current=!0,h(e)}})]})]})}),(0,U.jsxs)(xD,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(Q,{variant:`outline`,disabled:s===`config`,onClick:()=>t(!1),children:$(`panel.common.cancel`)}),(0,U.jsx)(Q,{variant:`primary`,disabled:!R,onClick:H,children:$(`panel.relay.saveConfig`)})]})]})}),(0,U.jsx)(hD,{open:C,onOpenChange:w,children:(0,U.jsxs)(gD,{className:`w-[min(560px,92vw)]`,initialFocus:j,children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.address.lan`)})}),(0,U.jsx)(`div`,{ref:j,tabIndex:-1,className:`outline-none`,children:(0,U.jsx)(bD,{className:`max-h-[60vh] overflow-y-auto px-1 py-2`,children:(0,U.jsx)(Oj,{align:`start`,book:r,error:i,onRetry:a,port:n.lan.port,value:r?.preferred??``,busy:s!==``,fallbackUrls:o,onChange:e=>{l(e),w(!1)}})})}),(0,U.jsx)(xD,{className:`flex justify-end`,children:(0,U.jsx)(Q,{variant:`outline`,onClick:()=>w(!1),children:$(`panel.common.close`)})})]})}),(0,U.jsx)(vM,{open:T,onOpenChange:E,onImport:e=>{O(e.config?{config:e.config,field:e.field,value:e.value}:void 0),e.field===`tcp`?(F.current=!0,v(e.value)):(N.current=!0,p(e.value))}}),(0,U.jsx)(AM,{open:k,onOpenChange:A,activeUrl:n.relayUrl})]})}function NM(e){return e.available?e.enabled?e.error?`panel.tailcat.error`:e.ready?`panel.tailcat.ready`:`panel.tailcat.starting`:`panel.tailcat.disabled`:`panel.tailcat.unavailable`}function PM(e){return e.length>16?`${e.slice(0,12)}…${e.slice(-4)}`:e}function FM({open:e,onOpenChange:t,onChanged:n}){let r=uO(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``),u=(0,g.useCallback)(async()=>{try{a(await rO(`/api/relay/tailcat`)),s(``)}catch(e){s(cO(e))}},[]);(0,g.useEffect)(()=>{if(!e)return;let t=()=>{c_()&&u()};t();let n=window.setInterval(t,2e3);return document.addEventListener(`visibilitychange`,t),()=>{window.clearInterval(n),document.removeEventListener(`visibilitychange`,t)}},[e,u]);let d=(0,g.useCallback)(async(e,t,i)=>{l(e);try{a(await t()),r(`soft`,i),n?.()}catch(e){r(`error`,cO(e))}finally{l(``)}},[r,n]),f=e=>void d(`toggle`,()=>iO(`/api/relay/tailcat/enabled`,{enabled:e}),$(e?`panel.tailcat.enabledToast`:`panel.tailcat.disabledToast`)),p=e=>{window.confirm($(`panel.tailcat.revokeConfirm`))&&d(`revoke`,()=>iO(`/api/relay/tailcat/revoke`,{client:e}),$(`panel.tailcat.revokedToast`))},m=i?.status??null,h=i?.allowedClients??[];return(0,U.jsx)(hD,{open:e,onOpenChange:t,children:(0,U.jsxs)(gD,{className:`max-w-md`,children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.tailcat.title`)})}),(0,U.jsxs)(bD,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.tailcat.hint`)}),o?(0,U.jsx)(`p`,{className:`text-xs text-error`,children:o}):null,i===null?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,U.jsx)(BE,{}),$(`panel.shell.readingStatus`)]}):m===null?(0,U.jsx)(`p`,{className:`text-sm text-foreground-muted`,children:$(`panel.tailcat.unavailable`)}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.tailcat.title`)}),(0,U.jsxs)(`span`,{className:`min-w-0 text-right text-sm break-all`,children:[$(NM(m)),m.error?(0,U.jsx)(`span`,{className:`ml-1 text-xs text-foreground-muted`,children:m.error}):null]})]}),(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.tailcat.addressLabel`)}),(0,U.jsx)(`span`,{className:`min-w-0 text-right font-mono text-xs break-all text-foreground-strong`,children:m.address||$(`panel.tailcat.noAddress`)})]}),(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-4 border-b border-border-muted py-2`,children:[(0,U.jsx)(`span`,{className:`text-sm text-foreground-muted`,children:$(`panel.tailcat.enableLabel`)}),(0,U.jsx)(ZD,{size:`md`,checked:m.enabled,disabled:!m.available||c!==``,onCheckedChange:e=>f(e),"aria-label":$(`panel.tailcat.enableLabel`)})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`span`,{className:`text-sm text-foreground-muted`,children:[$(`panel.tailcat.pairedLabel`),` (`,m.paired,`)`]}),h.length===0?(0,U.jsx)(`span`,{className:`text-xs text-foreground-muted`,children:$(`panel.tailcat.noClients`)}):(0,U.jsx)(`ul`,{className:`flex flex-col`,children:h.map(e=>(0,U.jsxs)(`li`,{className:`flex items-center justify-between gap-3 border-b border-border-muted py-1.5 last:border-b-0`,children:[(0,U.jsx)(`span`,{className:`min-w-0 font-mono text-xs break-all text-foreground-strong`,children:PM(e)}),(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:c!==``,onClick:()=>p(e),children:$(`panel.tailcat.revoke`)})]},e))})]})]})]}),(0,U.jsx)(xD,{className:`flex justify-end gap-2`,children:(0,U.jsx)(Q,{variant:`outline`,disabled:c!==``,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}var IM=`/dsh-market/api/v1`,LM=`dsh-mobile-plugin`,RM=class extends Error{constructor(e,t,n){super(n),G(this,`status`,void 0),G(this,`code`,void 0),this.name=`MarketError`,this.status=e,this.code=t}},zM=e=>e&&typeof e==`object`?e:{},BM=e=>typeof e==`string`&&e!==``?e:null;async function VM(e,t){let n;try{n=await fetch(`${IM}${e}`,{credentials:`same-origin`,...t})}catch(e){throw new RM(0,`market_unreachable`,$(`panel.net.marketUnreachable`,{message:String(e?.message||e)}))}let r=await n.json().catch(()=>null);if(!n.ok){let e=zM(r),t=zM(e.failure),i=BM(t.code)??(typeof e.error==`string`?e.error:`HTTP ${n.status}`),a=BM(t.message)??BM(e.error)??$(`panel.net.marketHttp`,{status:n.status});throw new RM(n.status,i,a)}return r}async function HM(){try{return{available:!0,restartSupported:zM(zM(await VM(`/capabilities`)).restart).supported===!0}}catch{return{available:!1,restartSupported:!1}}}async function UM(e=LM,t=!1){let n=zM(await VM(`/updates${`?name=${encodeURIComponent(e)}${t?`&force=1`:``}`}`)),r=zM(n.package??n);return{installedVersion:BM(r.installedVersion),latestVersion:BM(r.latestVersion),updateAvailable:r.updateAvailable===!0,source:BM(r.source)}}var WM=new Set([`OPERATION_BUSY`,`RELEASE_TOO_FRESH`,`VERSION_UNCHANGED`,`PLUGIN_NOT_INSTALLED`,`AGENTS_RUNNING`]);function GM(e){let t=e.installedVersion??e.beforeVersion;return e.failure?{text:$(`panel.update.applyFailed`,{message:e.failure.message}),ok:!1}:e.installed===!1?e.skipped?{text:t?$(`panel.update.applyUpToDate`,{version:t}):$(`panel.update.applyUpToDatePlain`),ok:!0}:{text:t?$(`panel.update.applyDiskUnchanged`,{version:t}):$(`panel.update.applyFailedRetry`),ok:!1}:{text:t?$(`panel.update.applySwitched`,{version:t}):$(`panel.update.applySwitchedPlain`),ok:!0}}function KM({version:e,busy:t,onRestartSidecar:n,extraActions:r,onIssues:i,bare:a=!1}){let[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(null),[_,v]=(0,g.useState)(``),y=uO(),b=(0,g.useCallback)(e=>{e&&s(t=>({...e,available:e.available===!0||t?.available===!0}))},[]),x=o!==null&&o.available&&!u,S=t!==``||_!==``,C=(0,g.useCallback)(async()=>{try{let e=await SO();s(e),d(e.available!==!0)}catch(e){s(null),d(vO(e))}finally{l(!0)}},[]);(0,g.useEffect)(()=>{C()},[C]),(0,g.useEffect)(()=>{if(!c)return;let e=!0;return CO().then(t=>{e&&(t.update&&h(t.update),t.status&&b(t.status))}).catch(()=>{}),()=>{e=!1}},[c]);let w=o?.swapping===!0;(0,g.useEffect)(()=>{if(!w)return;let e=window.setInterval(()=>void C(),1500);return()=>window.clearInterval(e)},[w,C]),(0,g.useEffect)(()=>{if(x||!c)return;let e=!0;return HM().then(t=>{e&&p(t)}),()=>{e=!1}},[x,c]);let T=(0,g.useCallback)(e=>{if(e instanceof RM&&WM.has(e.code)){y(`soft`,`${e.message}(${e.code})`);return}y(`error`,cO(e))},[]),E=(0,g.useCallback)(async()=>{v(`check`);try{let e=await CO();e.status&&b(e.status),e.update&&h(e.update)}catch(e){_O(e)||vO(e)?await C():y(`error`,cO(e))}finally{v(``)}},[C]),D=(0,g.useCallback)(async e=>{v(`apply`);try{let t=await wO(e);t.status&&b(t.status);let n=GM(t),r=t.failure!==null&&WM.has(t.failure.code);n.ok||r?y(`soft`,n.text):y(`error`,n.text)}catch(e){_O(e)||vO(e)?await C():y(`error`,cO(e))}finally{v(``)}},[C]),O=(0,g.useCallback)(async()=>{v(`check`);try{let e=await CO();e.status&&b(e.status),h(e.update)}catch(e){if(!_O(e))h(null),y(`error`,cO(e));else try{h(await UM(void 0,!0))}catch(e){h(null),T(e)}}finally{v(``)}},[T]),k=m?.source??o?.marketResult?.source??null,A=k===`linked`||k===`file`||k===`workspace`,j=m?.updateAvailable??o?.marketResult?.updateAvailable??!1,M=o?.lastApply?GM(o.lastApply):null,N=o?.version??null,P=x&&!!N&&!!e&&N!==e,F=o?.installedVersion??null,I=x&&!!F&&!!e&&F!==e;(0,g.useEffect)(()=>{if(!i)return;let t=[];P&&t.push({title:$(`panel.update.runningVersion`),detail:$(`panel.update.versionDrift`,{version:e??``,shell:N??``})}),I&&t.push({title:$(`panel.update.diskVersion`),detail:$(`panel.update.diskDrift`,{disk:F??``,running:e??``})}),i(t)},[i,P,I,e,N,F]);let L=(0,U.jsxs)(U.Fragment,{children:[c?null:(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,U.jsx)(BE,{}),$(`panel.update.reading`)]}),u?(0,U.jsx)(U.Fragment,{children:(0,U.jsxs)(`p`,{className:`mt-3 text-xs text-foreground-muted`,children:[j?$(`panel.update.hasNew`):``,$(`panel.update.nothingToInstall`)]})}):null,c&&!x&&!u&&f!==null&&!f.available?(0,U.jsxs)(JE,{variant:`info`,className:`mt-3`,children:[(0,U.jsx)(XE,{}),(0,U.jsx)(ZE,{children:$(`panel.update.noMarketTitle`)}),(0,U.jsx)(QE,{children:$(`panel.update.noMarketBody`)})]}):null,x&&o?(0,U.jsxs)(U.Fragment,{children:[o.lastError?(0,U.jsx)(`p`,{className:`mt-2 text-xs text-foreground-muted`,children:$(`panel.update.lastErrorLine`,{message:o.lastError})}):null,(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1 lg:flex-nowrap`,children:[r,(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:S,onClick:n,children:$(`panel.update.restartSidecar`)}),(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:S,onClick:()=>void E(),children:$(_===`check`?`panel.update.checking`:`panel.update.check`)}),A?null:(0,U.jsx)(Q,{variant:`primary`,size:`sm`,disabled:S,onClick:()=>void D(!1),children:$(_===`apply`?`panel.update.updating`:`panel.update.updateNow`)})]}),!A&&(j||M!==null&&!M.ok)?(0,U.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:S,onClick:()=>void D(!0),children:$(`panel.update.forceHint`)})}):null]}):null,c&&!x&&!u&&f?.available?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rk,{className:tk,children:(0,U.jsx)(ek,{label:$(`panel.update.checkResult`),children:$(j?`panel.update.resultHasNew`:`panel.update.resultUpToDate`)})}),(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1 lg:flex-nowrap`,children:[r,(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:S,onClick:n,children:$(`panel.update.restartSidecar`)}),(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:S,onClick:()=>void O(),children:$(_===`check`?`panel.update.checking`:`panel.update.check`)}),o!==null&&!A?(0,U.jsx)(Q,{variant:`primary`,size:`sm`,disabled:S,onClick:()=>void D(!1),children:$(_===`apply`?`panel.update.updating`:`panel.update.updateNow`)}):null]})]}):null]});return a?L:(0,U.jsxs)(cD,{frame:`solid`,children:[(0,U.jsx)(lD,{className:`px-4 py-3`,children:(0,U.jsxs)(uD,{className:`flex items-center gap-2 text-base lg:text-lg`,children:[(0,U.jsx)(`span`,{children:$(`panel.update.title`)}),(0,U.jsx)(nD,{variant:`soft`,size:`sm`,children:e||$(`panel.update.unknownVersion`)})]})}),L]})}function qM({webAccess:e,busy:t,onToggle:n}){let r=e?.enabled===!0,i=typeof e?.expiresAt==`number`?e.expiresAt:0;return(0,U.jsxs)(cD,{frame:`solid`,children:[(0,U.jsx)(lD,{className:`px-4 py-3`,children:(0,U.jsx)(uD,{className:`text-base lg:text-lg`,children:$(`panel.webAccess.title`)})}),(0,U.jsx)(rk,{children:(0,U.jsx)(ek,{label:$(`panel.webAccess.state`),tone:r?`ok`:`off`,children:r?$(`panel.webAccess.expires`,{time:hg(i)}):$(`panel.webAccess.closed`)})}),(0,U.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-foreground-muted`,children:$(`panel.webAccess.hint`)}),(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:r?(0,U.jsx)(Q,{variant:`outline`,size:`sm`,disabled:t===`webAccess`,onClick:()=>n(!1),children:$(`panel.webAccess.close`)}):(0,U.jsx)(Q,{variant:`outline`,size:`sm`,disabled:t===`webAccess`,onClick:()=>n(!0),children:$(`panel.webAccess.open`)})})]})}function JM(e,t=``){let n=document.documentElement;n.setAttribute(`data-dshm-panel-state`,e),t?n.setAttribute(`data-dshm-panel-error`,t):n.removeAttribute(`data-dshm-panel-error`),window.parent!==window&&window.parent.postMessage({type:`dsh-mobile-plugin:panel-state`,state:e,message:t},`*`)}var YM=1500,XM=600;function ZM(){return(0,U.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,className:`size-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`path`,{d:`M4 7h16`}),(0,U.jsx)(`path`,{d:`M9 7V4.5A1.5 1.5 0 0 1 10.5 3h3A1.5 1.5 0 0 1 15 4.5V7`}),(0,U.jsx)(`path`,{d:`M6 7l1 12.5A2 2 0 0 0 9 21h6a2 2 0 0 0 2-1.5L18 7`}),(0,U.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})}function QM(){let[e,t]=(0,g.useState)(null),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(``),[m,h]=(0,g.useState)([]),[_,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(!1),D=uO();(0,g.useEffect)(()=>{e?JM(`ready`):n&&JM(`error`,n)},[e,n]);let O=(0,g.useRef)(null),[k,A]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=O.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>A(e.getBoundingClientRect().height);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e]);let j=(0,g.useCallback)(async()=>{try{t(await rO(`/api/relay/status`)),r(``)}catch(e){r(cO(e))}},[]),M=(0,g.useCallback)(async()=>{l(``);try{s(await rO(`/api/relay/pairing`)),l(``)}catch(e){s(null),l(cO(e))}},[]),N=(0,g.useCallback)(async()=>{try{d(await rO(`/api/relay/addresses`)),p(``)}catch(e){d(null),p(cO(e))}},[]);(0,g.useEffect)(()=>{let e=()=>{c_()&&j()};e();let t=0,n=window.setTimeout(()=>{t=window.setInterval(e,3e3)},YM);return document.addEventListener(`visibilitychange`,e),()=>{window.clearTimeout(n),t&&window.clearInterval(t),document.removeEventListener(`visibilitychange`,e)}},[j]),(0,g.useEffect)(()=>{if(!e?.enabled)return;let t=window.setTimeout(()=>void M(),XM);return()=>window.clearTimeout(t)},[e?.enabled,M]),(0,g.useEffect)(()=>{e?.enabled&&o&&e.pairingCode&&o.pairingCode!==e.pairingCode&&M()},[e?.pairingCode,e?.enabled,o,M]);let P=(0,g.useCallback)(async()=>{try{s(await rO(`/api/relay/pairing`)),l(``)}catch{}},[]);(0,g.useEffect)(()=>{if(!e?.enabled)return;let t=eO(o);if(t===null)return;let n=window.setTimeout(()=>void P(),t);return()=>window.clearTimeout(n)},[o,e?.enabled,P]),(0,g.useEffect)(()=>{if(!e?.enabled)return;let t=window.setTimeout(()=>void N(),XM);return()=>window.clearTimeout(t)},[e?.enabled,o,N]),(0,g.useEffect)(()=>{_&&e?.enabled&&(M(),N())},[_,e?.enabled,M,N]);let F=(0,g.useCallback)(async(e,t)=>{a(e);try{await t()}catch(e){D(`error`,cO(e))}finally{a(``)}},[D]),I=e=>F(`toggle`,async()=>{t(await iO(`/api/relay/toggle`,{enabled:e})),e?await M():(s(null),l(``)),D(`soft`,$(e?`panel.shell.remoteEnabled`:`panel.shell.remoteDisabled`))}),L=()=>F(`restart`,async()=>{let e=await iO(`/api/relay/restart-sidecar`);t(e.status),D(`soft`,$(`panel.shell.sidecarRestarted`))}),R=e=>F(`webAccess`,async()=>{let n=await iO(`/api/relay/web-access`,{enabled:e});t(e=>e&&{...e,webAccess:n.webAccess}),D(`soft`,$(e?`panel.webAccess.opened`:`panel.webAccess.closedNotice`))}),z=(e,n)=>F(`config`,async()=>{let r={...e};if(n){let e=await oO(n.config);if(!e.ok||!e.status?.running||e.status.error)throw await j(),Error(e.status?.error||$(`panel.connection.tcpFailed`));n.field===`tcp`&&(r.manualTcpUrl===void 0||r.manualTcpUrl===n.value)&&(r.manualTcpUrl=e.status.remoteAddress||n.value)}t(await iO(`/api/relay/config`,r)),v(!1),await Promise.all([M(),N()]),D(`soft`,$(`panel.shell.configSaved`))}),B=()=>{window.confirm($(`panel.frp.stopConfirm`))&&F(`frp`,async()=>{await sO(),await Promise.all([j(),N(),M()])})},V=(e,n)=>F(`config`,async()=>{let r=await iO(`/api/relay/config`,e,{keepApplyError:!0});t(r),r.applyError?D(`error`,$(`panel.shell.applyFailed`,{message:r.applyError})):D(`soft`,$(n))}),H=e=>V({pairingPolicy:e},e===`code`?`panel.shell.deviceAllowed`:`panel.shell.deviceDenied`),ee=e=>V({controlReportEnabled:e},`panel.shell.configSaved`),te=(e,n)=>F(`lan`,async()=>{t(await iO(`/api/relay/config`,{lanPort:e,lanPortFixed:n})),b(!1),await M(),D(`soft`,$(`panel.shell.lanSaved`))}),ne=e=>F(`lan`,async()=>{t(await iO(`/api/relay/config`,{preferredLanAddress:e})),await Promise.all([M(),N()]),D(`soft`,e?$(`panel.shell.preferredAddress`,{address:e}):$(`panel.shell.preferredAuto`))}),W=e?e.tunnel.state===`connected`||e.lan.state===`listening`?`ok`:e.enabled?`warn`:`off`:null;return e?(0,U.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[1200px] flex-col gap-3 p-4 sm:p-5`,children:[(0,U.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[W?(0,U.jsx)($O,{tone:W}):null,(0,U.jsx)(nD,{variant:`soft`,size:`sm`,children:e.appVersion||$(`panel.shell.unknownVersion`)}),(0,U.jsx)(LA,{compact:!0})]}),i?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-foreground-muted`,children:[(0,U.jsx)(BE,{}),$(`panel.shell.busy`)]}):null,(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,U.jsx)(Eg,{}),(0,U.jsx)(i_,{}),(0,U.jsx)(Q,{variant:`ghost`,size:`icon-md`,"aria-label":$(`panel.inbox.title`),title:$(`panel.inbox.title`),onClick:()=>E(!0),children:(0,U.jsx)(ZM,{})}),(0,U.jsx)(Ik,{})]})]}),n?(0,U.jsxs)(JE,{variant:`error`,children:[(0,U.jsx)(XE,{}),(0,U.jsx)(ZE,{children:$(`panel.shell.statusFailed`)}),(0,U.jsx)(QE,{children:n})]}):null,(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-3`,children:[(0,U.jsxs)(cD,{frame:`solid`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 p-4 lg:grid-cols-10 lg:gap-6`,children:[(0,U.jsx)(`div`,{className:`lg:col-span-6`,children:(0,U.jsx)(jj,{bare:!0,status:e,pairing:o,addressBook:u,addressError:f,onRetryAddresses:()=>void N(),version:e.appVersion||``,versionIssues:m,busy:i,error:c,onRetryPairing:()=>void M(),onSavePreferred:e=>void ne(e),onEditPort:()=>b(!0)})}),(0,U.jsxs)(`div`,{className:`lg:col-span-4`,children:[(0,U.jsx)(rk,{className:nk,children:(0,U.jsx)(Mj,{status:e,busy:i,onChangePolicy:e=>void H(e),onToggleRemote:e=>void I(e),onChangeControlReport:e=>void ee(e)})}),(0,U.jsx)(DO,{})]})]}),(0,U.jsx)(`div`,{className:`mt-4 flex h-12 items-center justify-end border-t border-border-muted`,children:(0,U.jsx)(KM,{bare:!0,version:e.appVersion||``,busy:i,onRestartSidecar:()=>void L(),onIssues:h,extraActions:(0,U.jsx)(U.Fragment,{children:(0,U.jsx)(Q,{variant:`primary`,size:`sm`,onClick:()=>v(!0),children:$(`panel.pairing.openConfig`)})})})})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,U.jsx)(`div`,{ref:O,children:(0,U.jsx)(kk,{status:e,addressBook:u,busy:i,onStopFrp:B,onManageTailcat:()=>S(!0),onManageP2P:()=>w(!0),restartError:e.sidecar.restartError})}),(0,U.jsx)(`div`,{className:`min-h-0`,style:k>0?{height:`${k}px`}:void 0,children:(0,U.jsx)(eA,{busy:i,fill:!0})})]}),(0,U.jsx)(`div`,{className:`columns-1 gap-3 md:columns-2 xl:columns-3 [&>*]:mb-3 [&>*]:break-inside-avoid`,children:e.webAccess?.enabled&&e.panelScope!==`loopback`?(0,U.jsx)(qM,{webAccess:e.webAccess,busy:i,onToggle:e=>void R(e)}):null})]}),(0,U.jsx)(MM,{open:_,onOpenChange:v,status:e,addressBook:u,addressError:f,onRetryAddresses:()=>void N(),lanUrls:o?.lanUrls??[],busy:i,onSave:(e,t)=>void z(e,t),onSavePreferred:e=>void ne(e)}),(0,U.jsx)(FM,{open:x,onOpenChange:S,onChanged:()=>void j()}),(0,U.jsx)(Ij,{open:C,onOpenChange:w,onChanged:()=>void j()}),(0,U.jsx)(eM,{open:y,onOpenChange:b,port:o?.lanPort??e.lan.requestedPort??e.lan.port,busy:i,fixed:e.lanPortFixed===!0,forwarding:e.lanPortLockReason===`forwarding`,onSave:(e,t)=>void te(e,t)}),(0,U.jsx)(hD,{open:T,onOpenChange:E,children:(0,U.jsxs)(gD,{className:`max-w-md`,children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.inbox.title`)})}),(0,U.jsx)(bD,{children:(0,U.jsx)(BA,{framed:!1})})]})}),(0,U.jsx)(tM,{visible:oA(e.relayUrl),onOpenConfig:()=>v(!0)})]}):(0,U.jsx)(`main`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-3 p-5`,children:n?(0,U.jsx)(`p`,{className:`text-sm text-error`,children:n}):(0,U.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-foreground-muted`,children:[(0,U.jsx)(BE,{}),$(`panel.shell.readingStatus`)]})})}var $M=[{textKey:`panel.onboarding.linuxStep1`},{text:`systemctl status firewalld`,cmd:!0},{text:`sudo ufw status`,cmd:!0},{textKey:`panel.onboarding.linuxStep2`},{text:`sudo firewall-cmd --permanent --add-port={port}/tcp
107
+ `,$(`panel.pairing.controlReportTarget`,{target:e.controlReportTargetUrl||$(`panel.pairing.controlReportUnknown`)}),e.relayUrl&&!oA(e.relayUrl)?`\n\n${$(`panel.pairing.controlReportSelfHosted`)}`:``]}),(0,U.jsx)(xD,{className:`flex justify-end`,children:(0,U.jsx)(Q,{variant:`outline`,onClick:()=>l(!1),children:$(`panel.common.close`)})})]})})]})}function Nj(e,t){return e&&e.lan.length+e.public.length>0?`book`:t?.lanUrls?.[0]??``}function Pj(e){return e.available?e.enabled?e.path===`direct`&&e.active?`panel.p2p.open`:e.error?`panel.p2p.error`:e.path===`failed`?`panel.p2p.blocked`:e.ready?e.path===`waiting`?`panel.p2p.waiting`:`panel.p2p.punching`:e.started?`panel.p2p.punching`:`panel.p2p.waiting`:`panel.p2p.disabled`:`panel.p2p.unavailable`}function Fj(e){return e.length>16?`${e.slice(0,12)}…${e.slice(-4)}`:e}function Ij({open:e,onOpenChange:t,onChanged:n}){let r=uO(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``),u=(0,g.useCallback)(async()=>{try{let e=await rO(`/api/relay/p2p`);a(e.status??null),s(``)}catch(e){s(cO(e))}},[]),d=async e=>{l(`toggle`);try{let t=await iO(`/api/relay/p2p/enabled`,{enabled:e});a(t.status??null),r(`soft`,$(e?`panel.p2p.enabledToast`:`panel.p2p.disabledToast`)),n?.()}catch(e){r(`error`,cO(e))}finally{l(``)}};(0,g.useEffect)(()=>{if(!e)return;let t=()=>{c_()&&u()};t();let n=window.setInterval(t,2e3);return document.addEventListener(`visibilitychange`,t),()=>{window.clearInterval(n),document.removeEventListener(`visibilitychange`,t)}},[e,u]);let f=i,p=Array.isArray(f?.candidates)?f.candidates:[];return(0,U.jsx)(hD,{open:e,onOpenChange:t,children:(0,U.jsxs)(gD,{className:`max-w-md`,children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.p2p.title`)})}),(0,U.jsxs)(bD,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.p2p.hint`)}),o?(0,U.jsx)(`p`,{className:`text-xs text-error`,children:o}):null,f===null?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,U.jsx)(BE,{}),$(`panel.shell.readingStatus`)]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.p2p.stateLabel`)}),(0,U.jsxs)(`span`,{className:`min-w-0 text-right text-sm break-all`,children:[$(Pj(f)),f.error?(0,U.jsx)(`span`,{className:`ml-1 text-xs text-foreground-muted`,children:f.error}):null]})]}),(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.p2p.addressLabel`)}),(0,U.jsx)(`span`,{className:`min-w-0 text-right font-mono text-xs break-all text-foreground-strong`,children:f.url||$(`panel.p2p.noAddress`)})]}),(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-4 border-b border-border-muted py-2`,children:[(0,U.jsx)(`span`,{className:`text-sm text-foreground-muted`,children:$(`panel.p2p.enableLabel`)}),(0,U.jsx)(ZD,{size:`md`,checked:f.enabled,disabled:!f.available||c!==``,onCheckedChange:e=>void d(e),"aria-label":$(`panel.p2p.enableLabel`)})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border-muted py-2`,children:[(0,U.jsxs)(`span`,{className:`text-sm text-foreground-muted`,children:[$(`panel.p2p.candidatesLabel`),` (`,p.length,`)`]}),p.length===0?(0,U.jsx)(`span`,{className:`text-xs text-foreground-muted`,children:$(`panel.p2p.noCandidates`)}):(0,U.jsx)(`ul`,{className:`flex flex-col gap-1`,children:p.map(e=>(0,U.jsx)(`li`,{className:`font-mono text-xs break-all text-foreground-strong`,children:e},e))})]}),(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 py-2`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.p2p.keyLabel`)}),(0,U.jsx)(`span`,{className:`min-w-0 text-right font-mono text-xs break-all text-foreground-strong`,children:f.publicKey?Fj(f.publicKey):$(`panel.p2p.noKey`)})]})]})]}),(0,U.jsx)(xD,{className:`flex justify-end gap-2`,children:(0,U.jsx)(Q,{variant:`outline`,disabled:c!==``,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}var Lj=function(e){let t=Md(),[n,r]=g.useState(t),[i,a]=g.useState(),[o,s]=g.useState([]),c=n===void 0?t:n,l=y(()=>new Map),{messageIds:u}=BD(),d=q((e,t)=>{let n=l.current;t===void 0?n.delete(e):n.set(e,t),r(e=>{if(n.size===0)return e;let t;for(let r of n.values()){if(r===e)return e;t===void 0&&(t=r)}return t})}),f=q(()=>{l.current.size===0&&r(t)}),p=g.useCallback(e=>{let t=e[`aria-describedby`]?e[`aria-describedby`].split(` `):[];return t.push(...u,...o),{...e,"aria-describedby":Array.from(new Set(t)).join(` `)||void 0}},[u,o]),m=g.useMemo(()=>({controlId:c,registerControlId:d,resetControlId:f,labelId:i,setLabelId:a,messageIds:o,setMessageIds:s,getDescriptionProps:p}),[c,d,f,i,a,o,s,p]);return(0,U.jsx)(zD.Provider,{value:m,children:e.children})};function Rj(e,t){let n=Md(e);return b(()=>(t(n),()=>{t(e=>e===n?void 0:e)}),[n,t]),n}function zj(e={}){let{id:t,fallbackControlId:n,native:r=!1,setLabelId:i,focusControl:a}=e,{controlId:o,setLabelId:s}=BD(),c=Rj(t,q(e=>{s(e),i?.(e)})),l=o??n;function u(e){if(a){a(e,l);return}if(!l)return;let t=Re(e.currentTarget).getElementById(l);ve(t)&&Bj(t)}function d(e){dt(e.nativeEvent)?.closest(`button,input,select,textarea`)||(!e.defaultPrevented&&e.detail>1&&e.preventDefault(),!r&&u(e))}return r?{id:c,htmlFor:l,onMouseDown:d}:{id:c,onClick:d,onPointerDown(e){e.preventDefault()}}}function Bj(e){e.focus({focusVisible:!0})}function Vj(e){let{change:t,commit:n,invalid:r,markedDirtyRef:i,name:a,setRegisteredFieldName:o,registeredFieldIdRef:s,setValidityData:c,validityData:l}=e,{formRef:u}=RD(),d=g.useRef(null),f=g.useRef(null),p=g.useRef(!1),m=q(()=>{let e=f.current;if(e)return e.getValue?e.getValue():e.value});function h(e){return e.value===void 0?m():e.value}let _=q(()=>{let e=f.current;if(i.current=!0,!e){n(l.value);return}n(h(e))});function v(){let e=f.current;e&&e.id&&u.current.fields.set(e.id,{getValue:m,name:a??e.name,controlRef:e.controlRef,validityData:dj(l,r),validate:_})}function y(e=f.current?.id){e&&u.current.fields.delete(e)}function x(e){if(p.current)return;p.current=!0;let t=h(e);c(e=>e.initialValue===t?e:{...e,initialValue:t})}return b(()=>{let e=f.current;e&&e.id&&(o(a?void 0:e.name),u.current.fields.set(e.id,{getValue:m,name:a??e.name,controlRef:e.controlRef,validityData:dj(l,r),validate:_}))},[u,m,r,a,o,_,l]),b(()=>{let e=u.current.fields;return()=>{let t=f.current?.id;t&&e.delete(t)}},[u]),[_,q((e,n)=>{if(!n){d.current===e&&(d.current=null,t(void 0,!0),y(),f.current=null,o(void 0),s.current=void 0);return}let r=f.current?.id,i=d.current;i&&i!==e&&t(void 0,!0),d.current=e,f.current=n,a||o(n.name),s.current=n.id,r&&r!==n.id&&y(r),x(n),v()})]}var Hj=g.forwardRef(function(e,t){let{errors:n,validationMode:r,submitCountRef:i}=RD(),{render:a,className:o,validate:s,validationDebounceTime:c=0,validationMode:l=r,name:u,disabled:d=!1,invalid:f,dirty:p,touched:m,actionsRef:h,style:_,...v}=e,y=yj(!0)?.disabled,x=q(s||(()=>null)),S=y||d,[C,w]=g.useState(!1),[T,E]=g.useState(!1),[D,O]=g.useState(!1),[k,A]=g.useState(!1),j=p??T,M=m??C,N=g.useRef(j),P=g.useRef(void 0),[F,I]=g.useState(),L=u??F;b(()=>{p!==void 0&&(N.current=p)},[p]);let R=q(e=>{p===void 0&&(e&&(N.current=!0),E(e))}),z=q(e=>{m===void 0&&w(e)}),B=q(()=>l===`onChange`||l===`onSubmit`&&i.current>0),V=L&&Object.hasOwn(n,L)?n[L]:null,H=!!(Array.isArray(V)?V.length:V),ee=f===!0||H,[te,ne]=g.useState({state:DD,error:``,errors:[],value:null,initialValue:null}),W=!ee&&(S?null:te.state.valid),re=g.useMemo(()=>({disabled:S,touched:M,dirty:j,valid:W,filled:D,focused:k}),[S,M,j,W,D,k]),G=_j({setValidityData:ne,validate:x,validityData:te,validationDebounceTime:c,invalid:ee,markedDirtyRef:N,state:re,shouldValidateOnChange:B,validationMode:l,registeredFieldIdRef:P}),[K,ie]=Vj({change:G.change,commit:G.commit,invalid:ee,markedDirtyRef:N,name:u,setRegisteredFieldName:I,registeredFieldIdRef:P,setValidityData:ne,validityData:te});g.useImperativeHandle(h,()=>({validate:K}),[K]);let ae=g.useMemo(()=>({invalid:ee,name:L,validityData:te,setValidityData:ne,disabled:S,setTouched:z,setDirty:R,setFilled:O,setFocused:A,validationMode:l,shouldValidateOnChange:B,state:re,registerFieldControl:ie,validation:G}),[ee,L,te,S,z,R,O,A,l,B,re,ie,G]),oe=Hr(`div`,e,{ref:t,state:re,props:v,stateAttributesMapping:kD});return(0,U.jsx)(PD.Provider,{value:ae,children:oe})}),Uj=g.forwardRef(function(e,t){return(0,U.jsx)(Lj,{children:(0,U.jsx)(Hj,{...e,ref:t})})}),Wj=g.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,nativeLabel:o=!0,...s}=e,c=FD(!1),l=qA(),{labelId:u}=BD(),d={...c.state,disabled:c.disabled||l.disabled},f=g.useRef(null),p=zj({id:u??a,native:o});return Hr(`label`,e,{ref:[t,f],state:d,props:[p,s],stateAttributesMapping:kD})}),Gj=g.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:_,setDirty:v,validityData:y,setFocused:x,setFilled:S,validationMode:C,validation:w}=FD(),{clearErrors:T,elementRef:E,submitCountRef:D}=RD(),O=h||s,k=m??a,A={...p,disabled:O},{labelId:j}=BD(),M=WD({id:i}),[N]=vf({controlled:o,default:l,name:`FieldControl`,state:`value`}),P=o!==void 0,F=P?N:void 0,I=F==null?void 0:String(F),L=q(()=>w.inputRef.current?.value);ID(w.inputRef,M,I,L,!O,a),b(()=>{let e=I??w.inputRef.current?.value;e!==void 0&&S(e!==``)},[I,w.inputRef,S]),Kf(I,()=>{I!==void 0&&(T(k),v(I!==(y.initialValue??``)),w.change(I))});let R=g.useRef(null),z=Ke();return b(()=>{u&&R.current===ut(Re(R.current))&&x(!0)},[u,x]),Hr(`input`,e,{ref:[t,R],state:A,props:[{id:M,disabled:O,name:k,ref:w.inputRef,"aria-labelledby":j,autoFocus:u,...P?{value:F}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=ja(ha,e.nativeEvent);c?.(t,n),!P&&(v(t!==(y.initialValue??``)),S(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(T(k),w.change(t)))},onFocus(){x(!0)},onBlur(e){if(_(!0),x(!1),C===`onBlur`){let t=e.currentTarget.value;w.commit(t),P&&queueMicrotask(()=>{let e=w.inputRef.current?.value;e!==void 0&&e!==t&&e!==(y.initialValue??``)&&w.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){_(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===E.current&&!e.defaultPrevented){let t=e.currentTarget,n=D.current;z.start(0,()=>{D.current===n&&w.commit(t.value)})}else w.commit(t)}}},f,e=>w.getValidationProps(O,e)],stateAttributesMapping:kD})});function Kj({className:e,...t}){return(0,U.jsx)(Uj,{"data-slot":`field`,className:Z(e),...t})}function qj({className:e,...t}){return(0,U.jsx)(Wj,{"data-slot":`field-label`,className:Z(`text-foreground-intense mb-1.5 flex w-fit items-center text-sm font-medium select-none`,`data-disabled:opacity-disabled`,e),...t})}var Jj=g.forwardRef(function(e,t){return(0,U.jsx)(Gj,{ref:t,...e})}),Yj=Uu(`w-full border text-foreground outline-none transition-[background-color,border-color,box-shadow] duration-200 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{outline:`bg-background border-border-strong hover:not-focus:not-focus-visible:not-has-focus:not-has-focus-visible:not-data-popup-open:not-has-data-popup-open:not-data-pressed:not-has-data-pressed:not-data-invalid:not-has-data-invalid:border-border-emphasis`,soft:`bg-background-muted border-transparent hover:not-focus:not-focus-visible:not-has-focus:not-has-focus-visible:not-data-popup-open:not-has-data-popup-open:not-data-pressed:not-has-data-pressed:not-data-invalid:not-has-data-invalid:border-border-strong`},size:{sm:`h-8 px-3 text-xs pointer-coarse:text-base rounded-sm gap-1.5 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75]`,md:`h-10 px-3.5 text-sm pointer-coarse:text-base rounded-md gap-2 [&_svg:not([class*='size-'])]:size-4.5 [&_svg:not([class*='stroke-'])]:stroke-[1.65]`,lg:`h-12 px-4 text-base rounded-lg gap-2 [&_svg:not([class*='size-'])]:size-5 [&_svg:not([class*='stroke-'])]:stroke-[1.65]`},state:{self:Z(`focus-visible:ring-3 focus-visible:ring-ring-input focus-visible:border-transparent focus-visible:bg-background`,`data-popup-open:ring-3 data-popup-open:ring-ring-input data-popup-open:border-transparent data-popup-open:bg-background`,`data-pressed:ring-3 data-pressed:ring-ring-input data-pressed:border-transparent data-pressed:bg-background`,`data-invalid:bg-error-subtle data-invalid:border-error`,`data-invalid:focus-visible:border-transparent data-invalid:focus-visible:ring-ring-error data-invalid:focus-visible:bg-background`,`data-invalid:data-popup-open:border-transparent data-invalid:data-popup-open:ring-ring-error data-invalid:data-popup-open:bg-background`,`data-invalid:data-pressed:border-transparent data-invalid:data-pressed:ring-ring-error data-invalid:data-pressed:bg-background`,`data-disabled:border-border-strong! data-disabled:bg-background-subtle! data-disabled:cursor-not-allowed data-disabled:border-dashed data-disabled:opacity-disabled`),within:Z(`flex items-center`,`has-focus:ring-[3px] has-focus:ring-ring-input has-focus:border-transparent has-focus:bg-background`,`has-data-popup-open:ring-3 has-data-popup-open:ring-ring-input has-data-popup-open:border-transparent has-data-popup-open:bg-background`,`has-data-pressed:ring-3 has-data-pressed:ring-ring-input has-data-pressed:border-transparent has-data-pressed:bg-background`,`data-invalid:bg-error-subtle data-invalid:border-error data-invalid:has-focus:border-transparent data-invalid:has-focus:ring-ring-error data-invalid:has-focus:bg-background`,`data-invalid:has-data-popup-open:border-transparent data-invalid:has-data-popup-open:ring-ring-error data-invalid:has-data-popup-open:bg-background`,`data-invalid:has-data-pressed:border-transparent data-invalid:has-data-pressed:ring-ring-error data-invalid:has-data-pressed:bg-background`,`has-data-invalid:bg-error-subtle has-data-invalid:border-error has-data-invalid:has-focus:border-transparent has-data-invalid:has-focus:ring-ring-error has-data-invalid:has-focus:bg-background`,`has-data-invalid:has-data-popup-open:border-transparent has-data-invalid:has-data-popup-open:ring-ring-error has-data-invalid:has-data-popup-open:bg-background`,`has-data-invalid:has-data-pressed:border-transparent has-data-invalid:has-data-pressed:ring-ring-error has-data-invalid:has-data-pressed:bg-background`,`has-[input:disabled]:border-border-strong! has-[input:disabled]:bg-background-subtle! has-[input:disabled]:cursor-not-allowed has-[input:disabled]:border-dashed has-[input:disabled]:opacity-disabled`)}},defaultVariants:{variant:`outline`,size:`md`,state:`self`}});function Xj(e,t){(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`)?.set)?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function Zj({className:e,variant:t=`outline`,inputSize:n=`md`,clearable:r,startSlot:i,endSlot:a,onClear:o,inputProps:s,ref:c,...l}){let u=g.useRef(null),d=!!(r||i||a),f=l[`aria-invalid`],p=f===!0||f===`true`,m=zu(c,u),h=()=>{u.current&&l.value===void 0&&Xj(u.current,``),u.current?.focus(),o?.()};return d?(0,U.jsxs)(`div`,{"data-slot":`input-wrapper`,className:Z(Yj({variant:t,size:n,state:`within`}),e),...p?{"data-invalid":``}:{},children:[i&&(0,U.jsx)(`div`,{"data-slot":`input-start`,className:`-ms-1 flex shrink-0 items-center`,children:i}),(0,U.jsx)(Jj,{"data-slot":`input`,ref:m,placeholder:l.placeholder??` `,...s,className:Z(`peer text-foreground placeholder:text-foreground-subtle h-full min-w-0 flex-1 bg-transparent outline-none disabled:cursor-not-allowed`,s?.className),...l}),r&&(0,U.jsx)(`button`,{"data-slot":`input-clear`,type:`button`,onClick:h,className:`text-foreground-subtle hover:text-foreground pointer-events-none shrink-0 cursor-pointer opacity-0 transition-[opacity,color] duration-200 peer-not-placeholder-shown:pointer-events-auto peer-not-placeholder-shown:opacity-100`,tabIndex:-1,"aria-label":`Clear input`,children:(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`2 2 16 16`,fill:`currentColor`,className:`size-[1em]`,children:(0,U.jsx)(`path`,{d:`M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z`})})}),a&&(0,U.jsx)(`div`,{"data-slot":`input-end`,className:`-me-1 flex shrink-0 items-center`,children:a})]}):(0,U.jsx)(Jj,{"data-slot":`input`,ref:m,...s,className:Z(Yj({variant:t,size:n,state:`self`}),`placeholder:text-foreground-subtle`,s?.className,e),...l,...p?{"data-invalid":``}:{}})}var Qj=1024,$j=65535;function eM({open:e,onOpenChange:t,port:n,busy:r,fixed:i,forwarding:a,onSave:o}){let[s,c]=(0,g.useState)(String(n)),[l,u]=(0,g.useState)(i);(0,g.useEffect)(()=>{e&&(c(String(n)),u(i))},[e]);let d=s.trim(),f=Number(d),p=d!==``&&Number.isInteger(f)&&f>=Qj&&f<=$j&&r===``;return(0,U.jsx)(hD,{open:e,onOpenChange:t,children:(0,U.jsxs)(gD,{className:`max-w-sm`,children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.pairing.portTitle`)})}),(0,U.jsxs)(bD,{className:`flex flex-col gap-2`,children:[(0,U.jsxs)(Kj,{children:[(0,U.jsx)(qj,{htmlFor:`relay-lan-port`,children:$(`panel.pairing.port`)}),(0,U.jsx)(Zj,{inputProps:{id:`relay-lan-port`,inputMode:`numeric`},value:s,onChange:e=>c(e.target.value)})]}),(0,U.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(`panel.pairing.portHint`)}),(0,U.jsxs)(Kj,{children:[(0,U.jsx)(qj,{htmlFor:`relay-port-fixed`,children:$(`panel.pairing.portFixed`)}),(0,U.jsx)(ZD,{id:`relay-port-fixed`,size:`md`,checked:l,disabled:r!==``,onCheckedChange:u,"aria-label":$(`panel.pairing.portFixed`)})]}),(0,U.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(a?`panel.pairing.portForwarding`:`panel.pairing.portFixedHint`)})]}),(0,U.jsxs)(xD,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(Q,{variant:`outline`,disabled:r!==``,onClick:()=>t(!1),children:$(`panel.common.cancel`)}),(0,U.jsx)(Q,{variant:`primary`,disabled:!p,onClick:()=>o(f,l),children:$(`panel.common.save`)})]})]})})}function tM({visible:e,onOpenConfig:t}){let[n,r]=(0,g.useState)(!1);return!e||n?null:(0,U.jsx)(hD,{open:!0,onOpenChange:e=>{e||r(!0)},children:(0,U.jsxs)(gD,{className:`max-w-md`,children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.publicRelayNotice.title`)})}),(0,U.jsx)(bD,{className:`whitespace-pre-line text-sm leading-6 text-foreground-muted`,children:$(`panel.publicRelayNotice.body`)}),(0,U.jsxs)(xD,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(Q,{variant:`outline`,onClick:()=>{r(!0),t()},children:$(`panel.pairing.openConfig`)}),(0,U.jsx)(Q,{variant:`primary`,onClick:()=>r(!0),children:$(`panel.publicRelayNotice.action`)})]})]})})}var nM={sm:`py-2`,md:`py-2.5`,lg:`py-3`},rM={sm:`min-h-16`,md:`min-h-20`,lg:`min-h-24`},iM={sm:`0.5rem`,md:`0.625rem`,lg:`0.75rem`};function aM(e,t){(Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,`value`)?.set)?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function oM({className:e,variant:t=`outline`,inputSize:n=`md`,clearable:r,startSlot:i,endSlot:a,onClear:o,ref:s,rows:c=3,...l}){let u=g.useRef(null),d=zu(s,u),f=!!(r||i||a),p=l[`aria-invalid`],m=p===!0||p===`true`,h=()=>{u.current&&l.value===void 0&&aM(u.current,``),u.current?.focus(),o?.()};return f?(0,U.jsxs)(`div`,{"data-slot":`textarea-wrapper`,"data-invalid":m?``:void 0,style:{"--textarea-h":`calc(${c} * 1lh + 2 * ${iM[n]} + 2px)`},className:Z(Yj({variant:t,size:n,state:`within`}),`h-(--textarea-h) resize-y items-start overflow-hidden`,rM[n],nM[n],`has-[textarea:disabled]:border-border-strong! has-[textarea:disabled]:bg-background-subtle! has-[textarea:disabled]:opacity-disabled has-[textarea:disabled]:cursor-not-allowed has-[textarea:disabled]:border-dashed`,e),children:[i&&(0,U.jsx)(`div`,{"data-slot":`textarea-start`,className:`-ms-1 inline-flex h-lh shrink-0 items-center`,children:i}),(0,U.jsx)(Gj,{"data-slot":`textarea`,ref:d,render:(0,U.jsx)(`textarea`,{rows:c}),placeholder:l.placeholder??` `,className:`peer text-foreground placeholder:text-foreground-subtle min-w-0 flex-1 resize-none self-stretch bg-transparent outline-none disabled:cursor-not-allowed`,...l}),r&&(0,U.jsx)(`button`,{"data-slot":`textarea-clear`,type:`button`,onClick:h,className:`text-foreground-subtle hover:text-foreground pointer-events-none inline-flex h-lh shrink-0 cursor-pointer items-center opacity-0 transition-[opacity,color] duration-200 peer-not-placeholder-shown:pointer-events-auto peer-not-placeholder-shown:opacity-100 motion-reduce:transition-none`,tabIndex:-1,"aria-label":`Clear input`,children:(0,U.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`2 2 16 16`,fill:`currentColor`,className:`size-[1em]`,children:(0,U.jsx)(`path`,{d:`M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z`})})}),a&&(0,U.jsx)(`div`,{"data-slot":`textarea-end`,className:`-me-1 inline-flex h-lh shrink-0 items-center`,children:a})]}):(0,U.jsx)(Gj,{"data-slot":`textarea`,ref:d,render:(0,U.jsx)(`textarea`,{rows:c}),className:Z(Yj({variant:t,size:n,state:`self`}),`placeholder:text-foreground-subtle h-auto resize-y`,nM[n],rM[n],e),...l,...m?{"data-invalid":``}:{}})}function sM(e){return String(e||``).replace(/\s+#.*$/,``).trim().replace(/^["']/,``).replace(/["']$/,``).trim()}function cM(e){let t={};for(let n of String(e||``).split(/\r?\n/)){let e=n.trim();if(!e||e.startsWith(`#`)||e.startsWith(`;`)||e.startsWith(`[`))continue;let r=/^([A-Za-z0-9_.]+)\s*[=:]\s*(.+)$/.exec(e);if(!r)continue;let i=r[1].toLowerCase();i in t||(t[i]=sM(r[2]))}return t}function lM(e){let t=String(e||``).trim();if(!t)return[];let n=[...t.matchAll(/["']([^"']+)["']/g)].map(e=>e[1].trim()).filter(Boolean);return n.length?n:t.replace(/^\[|\]$/g,``).split(/[,\s]+/).map(e=>e.trim()).filter(Boolean)}function uM(e){let t=(...t)=>{for(let n of t)if(e[n])return e[n];return``};return{type:(t(`type`)||``).toLowerCase(),remotePort:t(`remoteport`,`remote_port`),localPort:t(`localport`,`local_port`),domains:lM(t(`customdomains`,`custom_domains`))}}function dM(e){let t=e.split(/\[\[\s*proxies\s*\]\]/i),n=cM(t[0]);return{serverAddr:n.serveraddr||n.server_addr||``,proxies:t.slice(1).map(e=>uM(cM(e)))}}function fM(e){let t=[{name:`__global__`,pairs:{}}];for(let n of e.split(/\r?\n/)){let e=n.trim();if(!e||e.startsWith(`#`)||e.startsWith(`;`))continue;let r=/^\[([^\]]+)\]$/.exec(e);if(r){t.push({name:r[1].trim().toLowerCase(),pairs:{}});continue}let i=/^([A-Za-z0-9_.]+)\s*[=:]\s*(.+)$/.exec(e);if(!i)continue;let a=t[t.length-1],o=i[1].toLowerCase();o in a.pairs||(a.pairs[o]=sM(i[2]))}let n=t.find(e=>e.name===`common`)||t[0];return{serverAddr:n.pairs.server_addr||n.pairs.serveraddr||``,proxies:t.filter(e=>e.name!==`__global__`&&e.name!==`common`).map(e=>uM(e.pairs))}}function pM(e){let t;try{t=JSON.parse(e)}catch{return null}let n=t&&typeof t==`object`?t:{};return{serverAddr:typeof n.serverAddr==`string`?n.serverAddr:typeof n.server_addr==`string`?n.server_addr:``,proxies:(Array.isArray(n.proxies)?n.proxies:[]).map(e=>{let t=e&&typeof e==`object`?e:{},n=e=>typeof e==`string`||typeof e==`number`?String(e):``,r=t.customDomains??t.custom_domains;return{type:n(t.type).toLowerCase(),remotePort:n(t.remotePort??t.remote_port),localPort:n(t.localPort??t.local_port),domains:Array.isArray(r)?r.map(e=>String(e)):lM(n(r))}})}}function mM(e){if(!/^\d+$/.test(String(e||``)))return null;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=65535?t:null}function hM(e,t){for(let n of t){if(n.type&&n.type!==`tcp`)continue;let t=mM(n.remotePort);if(e&&t!==null)return{ok:!0,field:`tcp`,value:`${e}:${t}`,kind:`tcp`}}for(let e of t)if((e.type===`https`||e.type===`http`)&&e.domains.length)return{ok:!0,field:`direct`,value:`https://${e.domains[0]}`,kind:`https`};for(let n of t){if(n.type&&n.type!==`tcp`)continue;let t=mM(n.localPort);if(e&&t!==null)return{ok:!0,field:`tcp`,value:`${e}:${t}`,kind:`tcp`,note:`inferred-local-port`,port:t}}return{ok:!1,reason:`no-address`}}function gM(e){let t=String(e||``).trim();if(!t)return{ok:!1,reason:`empty`};let n=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``).replace(/\/+$/,``).trim(),r=/^(\[[^\]]+\]|[^\s/:?#]+):(\d+)$/.exec(n);if(r){let e=Number(r[2]);return Number.isInteger(e)&&e>=1&&e<=65535?{ok:!0,field:`tcp`,value:`${r[1]}:${e}`,kind:`tcp`}:{ok:!1,reason:`bad-tcp`}}let i;return i=t.startsWith(`{`)?pM(t)||{serverAddr:``,proxies:[]}:/\[\[\s*proxies\s*\]\]/i.test(t)?dM(t):/^\s*\[common\]\s*$/im.test(t)||/(?:^|[\r\n])\s*server_addr\s*=/i.test(t)?fM(t):dM(t),hM(i.serverAddr,i.proxies)}function _M(e){return/serverAddr|server_addr|\[\[\s*proxies\s*\]\]|\[common\]/i.test(e)}function vM({open:e,onOpenChange:t,onImport:n}){let[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(``),s=(0,g.useMemo)(()=>gM(r),[r]);(0,g.useEffect)(()=>{e&&o(``)},[e]);function c(){if(!s.ok)return;if(/^\s*\[common\]\s*$/im.test(r)||/^\s*server_addr\s*=/im.test(r)){o($(`panel.frp.iniUnsupported`));return}let e=s.value;n({field:s.field,value:e,..._M(r)?{config:r}:{}}),t(!1)}return(0,U.jsx)(hD,{open:e,onOpenChange:t,children:(0,U.jsxs)(gD,{className:`w-[min(560px,92vw)]`,children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.frp.title`)})}),(0,U.jsxs)(bD,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.frp.hint`)}),(0,U.jsxs)(Kj,{children:[(0,U.jsx)(qj,{htmlFor:`frp-import`,children:$(`panel.frp.label`)}),(0,U.jsx)(oM,{id:`frp-import`,rows:6,value:r,onChange:e=>i(e.target.value),autoComplete:`off`,spellCheck:!1})]}),r.trim()?s.ok?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{role:`status`,className:`text-xs text-foreground-muted`,children:$(s.field===`tcp`?`panel.frp.detectedTcp`:`panel.frp.detectedDirect`,{address:s.value})}),s.note===`inferred-local-port`?(0,U.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(`panel.frp.inferredPort`,{port:s.port??``})}):null]}):(0,U.jsx)(`p`,{className:`text-xs text-error`,children:$(s.reason===`empty`?`panel.frp.empty`:`panel.frp.badFormat`)}):null,a?(0,U.jsx)(`p`,{className:`text-xs text-error`,children:a}):null]}),(0,U.jsxs)(xD,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(Q,{variant:`outline`,onClick:()=>t(!1),children:$(`panel.common.cancel`)}),(0,U.jsx)(Q,{variant:`primary`,disabled:!s.ok,onClick:c,children:$(`panel.frp.fill`)})]})]})})}var yM=.7,bM=2;function xM(e){let t=Number.isFinite(e)&&e>0?e:0;return t>=600?1:t<=100?t/100*yM:yM+(t-100)/500*.30000000000000004}function SM(e,t,n){let r=e.map(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0?e:null);if(!r.some(e=>e!==null))return``;let i=r.length>1?t/(r.length-1):0,a=Math.max(1,n-4),o=[],s=!1;return r.forEach((e,n)=>{if(e===null){s=!1;return}let c=r.length>1?n*i:t/2,l=bM+xM(e)*a;o.push(`${s?`L`:`M`}${c.toFixed(1)} ${l.toFixed(1)}`),s=!0}),o.join(` `)}function CM(e){return typeof e!=`number`||!Number.isFinite(e)?`none`:e<=100?`fast`:e<=600?`ok`:`slow`}var wM=5e3,TM=132,EM=28;function DM(e){return e===`fast`?`text-success`:e===`ok`?`text-warning`:e===`slow`?`text-destructive`:`text-foreground-muted`}function OM(e){return e===`fast`?`#16a34a`:e===`ok`?`#d97706`:e===`slow`?`#dc2626`:`#9ca3af`}function kM(e){return typeof e!=`number`||!Number.isFinite(e)?`—`:`${Math.round(e)} ms`}function AM({open:e,onOpenChange:t,activeUrl:n}){let[r,i]=(0,g.useState)({}),[a,o]=(0,g.useState)(``),s=(0,g.useRef)(!1),c=n.trim().replace(/\/+$/,``),l=[...new Set([...aA.map(e=>e.url),.../^https?:\/\//i.test(c)?[c]:[]])],u=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(!e){u.current!==null&&(clearInterval(u.current),u.current=null);return}let t=!0;o(``);let n=[...new Set([...aA.map(e=>e.url),.../^https?:\/\//i.test(c)?[c]:[]])];i(Object.fromEntries(n.map(e=>[e,[null]])));async function r(){if(t&&!s.current){s.current=!0;try{let e=await iO(`/api/relay/probe-relays`,{urls:n});if(!t)return;let r=new Map((e.results||[]).map(e=>[e.url,e.ms]));i(e=>{let t={};for(let i of n)t[i]=[...e[i]||[],r.get(i)??null].slice(-14);return t}),o(``)}catch(e){t&&(i(e=>Object.fromEntries(n.map(t=>[t,[...e[t]||[],null].slice(-14)]))),o(cO(e)))}finally{s.current=!1}}}return r(),u.current=setInterval(()=>{r()},wM),()=>{t=!1,u.current!==null&&(clearInterval(u.current),u.current=null)}},[e,c]),(0,U.jsx)(hD,{open:e,onOpenChange:t,children:(0,U.jsxs)(gD,{children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.relay.panelTitle`)})}),(0,U.jsxs)(bD,{className:`flex max-h-[60vh] flex-col gap-1 overflow-y-auto`,children:[(0,U.jsx)(`p`,{className:`mb-2 text-xs text-foreground-muted`,children:$(`panel.relay.panelHint`)}),l.map(e=>{let t={url:e},i=r[t.url]||[null],a=i[i.length-1]??null,o=CM(a),s=SM(i,TM,EM),c=t.url===n;return(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border-muted px-3 py-2`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,U.jsx)(`span`,{className:`truncate font-mono text-sm`,children:t.url}),c?(0,U.jsx)(`span`,{className:`text-xs text-primary`,children:$(`panel.relay.selected`)}):null]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3`,children:[s?(0,U.jsx)(`svg`,{width:TM,height:EM,"aria-hidden":`true`,children:(0,U.jsx)(`path`,{d:s,stroke:OM(o),strokeWidth:1.5,fill:`none`})}):null,(0,U.jsx)(`span`,{className:`w-16 text-right text-sm tabular-nums ${DM(o)}`,children:kM(a)})]})]},t.url)}),a?(0,U.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:a}):null]}),(0,U.jsx)(xD,{children:(0,U.jsx)(Q,{variant:`outline`,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}function jM({id:e,value:t,placeholder:n,ariaLabel:r,options:i,emptyText:a,onChange:o}){return(0,U.jsx)(Zj,{inputProps:{id:e,className:`font-mono`},value:t,placeholder:n,onChange:e=>o(e.target.value),endSlot:(0,U.jsxs)(kh,{children:[(0,U.jsx)(Ah,{"aria-label":r,className:`-mr-1 flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded text-foreground-muted hover:text-foreground-strong focus-visible:outline-none`,children:(0,U.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`size-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,U.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}),(0,U.jsx)(Nh,{align:`end`,style:{width:`auto`,minWidth:`18rem`,maxWidth:`32rem`},children:i.length===0?(0,U.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground-muted`,children:a}):i.map(e=>(0,U.jsx)(Ih,{onClick:()=>o(e.value),children:(0,U.jsx)(`span`,{className:`font-mono text-xs break-all`,children:e.label})},e.value))})]})})}function MM({open:e,onOpenChange:t,status:n,addressBook:r,addressError:i=``,onRetryAddresses:a,lanUrls:o,busy:s,onSave:c,onSavePreferred:l}){let[u,d]=(0,g.useState)(n.relayUrl),[f,p]=(0,g.useState)(n.publicRelayDisabled===!0),[m,h]=(0,g.useState)(``),[_,v]=(0,g.useState)(``),[y,b]=(0,g.useState)(``),[x,S]=(0,g.useState)(``),[C,w]=(0,g.useState)(``),[T,E]=(0,g.useState)(!1),[D,O]=(0,g.useState)(!1),[k,A]=(0,g.useState)(),[j,M]=(0,g.useState)(!1),N=(0,g.useRef)(null),P=(0,g.useRef)(null),F=(0,g.useRef)(!1),I=(0,g.useRef)(!1),L=(0,g.useRef)(!1),R=(0,g.useRef)(!1),z=r?r.lan.length>0?r.lan:r.public:[];(0,g.useEffect)(()=>{e&&(d(n.relayUrl),p(n.publicRelayDisabled===!0))},[e]),(0,g.useEffect)(()=>{e||(E(!1),O(!1),A(void 0))},[e]),(0,g.useEffect)(()=>{if(!e){F.current=!1,I.current=!1,L.current=!1,R.current=!1,w(``);return}if(F.current||h(r?.manual??``),I.current||v(r?.manualIpv6||r?.ipv6?.[0]?.url||``),L.current||b(r?.manualTcp??``),!R.current){let e=r?r.lan.length>0?r.lan:r.public:[];S((r?.preferred||``).trim()||(e[0]?.address??``))}},[e,r]);let B=s===``,V=aA.find(e=>e.url===u.trim())??null,H=n.publicRelayBlocked===!0,ee=!!V&&!f&&!H,te=H||f,ne=e=>e.trim().replace(/\/+$/,``);function W(){if(!B)return;let e={};V?e.relayUrls=aA.map(e=>e.url):u.trim()!==n.relayUrl&&(e.relayUrl=u.trim()),f!==(n.publicRelayDisabled===!0)&&(e.publicRelayDisabled=f);let t=ne(m);t!==ne(r?.manual??``)&&(e.manualLanUrl=t);let i=ne(_);i!==ne(r?.manualIpv6||r?.ipv6?.[0]?.url||``)&&(e.manualIpv6Url=i);let a=ne(y);a!==ne(r?.manualTcp??``)&&(e.manualTcpUrl=a);let o=x.trim();if(R.current&&o!==(r?.preferred??``).trim()){if(o&&!z.some(e=>e.address===o)){w($(`panel.address.lanUnknown`));return}e.preferredLanAddress=o}c(e,k)}return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(hD,{open:e,onOpenChange:e=>{s!==`config`&&t(e)},children:(0,U.jsxs)(gD,{className:`w-[min(1100px,92vw)]`,initialFocus:P,children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.pairing.openConfig`)})}),(0,U.jsx)(`div`,{ref:P,tabIndex:-1,className:`outline-none`,children:(0,U.jsxs)(bD,{className:`grid max-h-[calc(100vh-13rem)] grid-cols-2 items-start gap-x-8 gap-y-4 overflow-y-auto`,children:[(0,U.jsxs)(Kj,{children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,U.jsx)(qj,{children:$(`panel.relay.publicKind`)}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>M(!0),children:$(`panel.relay.viewPanel`)}),(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:!B||H,onClick:()=>{ee?(p(!0),d(``)):(p(!1),d(aA[0].url))},children:$(ee?`panel.relay.disablePublic`:`panel.relay.enablePublic`)})]})]}),te?(0,U.jsx)(Zj,{inputProps:{className:`text-foreground-muted`,readOnly:!0,"aria-label":$(`panel.relay.publicKind`)},value:$(`panel.relay.publicDisabled`)}):(0,U.jsx)(`div`,{className:`flex flex-col gap-1`,children:aA.map(e=>(0,U.jsx)(Zj,{inputProps:{className:`font-mono`,readOnly:!0,"aria-label":$(`panel.relay.publicKind`)},value:e.url},e.url))})]}),(0,U.jsxs)(Kj,{children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,U.jsx)(qj,{htmlFor:`relay-url`,children:$(`panel.relay.selfKind`)}),(0,U.jsx)(`a`,{href:nA,target:`_blank`,rel:`noreferrer noopener`,className:Gu({variant:`ghost`,size:`sm`}),children:$(`panel.relay.selfRepo`)})]}),(0,U.jsx)(Zj,{inputProps:{id:`relay-url`,className:`font-mono`},value:V?``:u,placeholder:`https://example.com`,onChange:e=>d(e.target.value)})]}),(0,U.jsxs)(Kj,{children:[(0,U.jsx)(qj,{htmlFor:`relay-manual-lan`,children:$(`panel.address.direct`)}),(0,U.jsx)(Zj,{inputProps:{id:`relay-manual-lan`,className:`font-mono`},value:m,placeholder:$(`panel.address.directPlaceholder`),onChange:e=>{F.current=!0,h(e.target.value)}})]}),(0,U.jsxs)(Kj,{children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,U.jsx)(qj,{htmlFor:`relay-manual-tcp`,children:$(`panel.address.tcp`)}),(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>O(!0),children:$(`panel.address.frpImport`)})]}),(0,U.jsx)(Zj,{inputProps:{id:`relay-manual-tcp`,className:`font-mono`},value:y,placeholder:$(`panel.address.tcpPlaceholder`),onChange:e=>{L.current=!0,b(e.target.value)}})]}),(0,U.jsxs)(Kj,{children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,U.jsx)(qj,{htmlFor:`relay-preferred-lan`,children:$(`panel.address.lan`)}),(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>E(!0),children:$(`panel.onboarding.chooseAddress`)})]}),(0,U.jsx)(jM,{id:`relay-preferred-lan`,value:x,placeholder:$(`panel.address.lanPlaceholder`),ariaLabel:$(`panel.address.lan`),options:z.map(e=>({value:e.address,label:e.url})),emptyText:$(`panel.address.empty`),onChange:e=>{R.current=!0,w(``),S(e)}}),C?(0,U.jsx)(`p`,{className:`text-xs text-error`,children:C}):null,i?(0,U.jsxs)(`p`,{className:`text-xs text-error`,children:[$(`panel.address.loadFailed`),(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:a,children:$(`panel.address.retry`)})]}):null]}),(0,U.jsxs)(Kj,{children:[(0,U.jsx)(qj,{htmlFor:`relay-manual-ipv6`,children:$(`panel.address.ipv6Url`)}),(0,U.jsx)(jM,{id:`relay-manual-ipv6`,value:_,placeholder:$(`panel.address.ipv6Placeholder`),ariaLabel:$(`panel.address.ipv6Url`),options:(r?.ipv6??[]).map(e=>({value:e.url,label:e.interface?`${e.url} · ${e.interface}`:e.url})),emptyText:$(`panel.address.empty`),onChange:e=>{I.current=!0,v(e)}})]})]})}),(0,U.jsxs)(xD,{className:`flex justify-end gap-2`,children:[(0,U.jsx)(Q,{variant:`outline`,disabled:s===`config`,onClick:()=>t(!1),children:$(`panel.common.cancel`)}),(0,U.jsx)(Q,{variant:`primary`,disabled:!B,onClick:W,children:$(`panel.relay.saveConfig`)})]})]})}),(0,U.jsx)(hD,{open:T,onOpenChange:E,children:(0,U.jsxs)(gD,{className:`w-[min(560px,92vw)]`,initialFocus:N,children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.address.lan`)})}),(0,U.jsx)(`div`,{ref:N,tabIndex:-1,className:`outline-none`,children:(0,U.jsx)(bD,{className:`max-h-[60vh] overflow-y-auto px-1 py-2`,children:(0,U.jsx)(Oj,{align:`start`,book:r,error:i,onRetry:a,port:n.lan.port,value:r?.preferred??``,busy:s!==``,fallbackUrls:o,onChange:e=>{l(e),E(!1)}})})}),(0,U.jsx)(xD,{className:`flex justify-end`,children:(0,U.jsx)(Q,{variant:`outline`,onClick:()=>E(!1),children:$(`panel.common.close`)})})]})}),(0,U.jsx)(vM,{open:D,onOpenChange:O,onImport:e=>{A(e.config?{config:e.config,field:e.field,value:e.value}:void 0),e.field===`tcp`?(L.current=!0,b(e.value)):(F.current=!0,h(e.value))}}),(0,U.jsx)(AM,{open:j,onOpenChange:M,activeUrl:n.relayUrl})]})}function NM(e){return e.available?e.enabled?e.error?`panel.tailcat.error`:e.ready?`panel.tailcat.ready`:`panel.tailcat.starting`:`panel.tailcat.disabled`:`panel.tailcat.unavailable`}function PM(e){return e.length>16?`${e.slice(0,12)}…${e.slice(-4)}`:e}function FM({open:e,onOpenChange:t,onChanged:n}){let r=uO(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``),u=(0,g.useCallback)(async()=>{try{a(await rO(`/api/relay/tailcat`)),s(``)}catch(e){s(cO(e))}},[]);(0,g.useEffect)(()=>{if(!e)return;let t=()=>{c_()&&u()};t();let n=window.setInterval(t,2e3);return document.addEventListener(`visibilitychange`,t),()=>{window.clearInterval(n),document.removeEventListener(`visibilitychange`,t)}},[e,u]);let d=(0,g.useCallback)(async(e,t,i)=>{l(e);try{a(await t()),r(`soft`,i),n?.()}catch(e){r(`error`,cO(e))}finally{l(``)}},[r,n]),f=e=>void d(`toggle`,()=>iO(`/api/relay/tailcat/enabled`,{enabled:e}),$(e?`panel.tailcat.enabledToast`:`panel.tailcat.disabledToast`)),p=e=>{window.confirm($(`panel.tailcat.revokeConfirm`))&&d(`revoke`,()=>iO(`/api/relay/tailcat/revoke`,{client:e}),$(`panel.tailcat.revokedToast`))},m=i?.status??null,h=i?.allowedClients??[];return(0,U.jsx)(hD,{open:e,onOpenChange:t,children:(0,U.jsxs)(gD,{className:`max-w-md`,children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.tailcat.title`)})}),(0,U.jsxs)(bD,{className:`flex flex-col gap-3`,children:[(0,U.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.tailcat.hint`)}),o?(0,U.jsx)(`p`,{className:`text-xs text-error`,children:o}):null,i===null?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,U.jsx)(BE,{}),$(`panel.shell.readingStatus`)]}):m===null?(0,U.jsx)(`p`,{className:`text-sm text-foreground-muted`,children:$(`panel.tailcat.unavailable`)}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.tailcat.title`)}),(0,U.jsxs)(`span`,{className:`min-w-0 text-right text-sm break-all`,children:[$(NM(m)),m.error?(0,U.jsx)(`span`,{className:`ml-1 text-xs text-foreground-muted`,children:m.error}):null]})]}),(0,U.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.tailcat.addressLabel`)}),(0,U.jsx)(`span`,{className:`min-w-0 text-right font-mono text-xs break-all text-foreground-strong`,children:m.address||$(`panel.tailcat.noAddress`)})]}),(0,U.jsxs)(`label`,{className:`flex items-center justify-between gap-4 border-b border-border-muted py-2`,children:[(0,U.jsx)(`span`,{className:`text-sm text-foreground-muted`,children:$(`panel.tailcat.enableLabel`)}),(0,U.jsx)(ZD,{size:`md`,checked:m.enabled,disabled:!m.available||c!==``,onCheckedChange:e=>f(e),"aria-label":$(`panel.tailcat.enableLabel`)})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,U.jsxs)(`span`,{className:`text-sm text-foreground-muted`,children:[$(`panel.tailcat.pairedLabel`),` (`,m.paired,`)`]}),h.length===0?(0,U.jsx)(`span`,{className:`text-xs text-foreground-muted`,children:$(`panel.tailcat.noClients`)}):(0,U.jsx)(`ul`,{className:`flex flex-col`,children:h.map(e=>(0,U.jsxs)(`li`,{className:`flex items-center justify-between gap-3 border-b border-border-muted py-1.5 last:border-b-0`,children:[(0,U.jsx)(`span`,{className:`min-w-0 font-mono text-xs break-all text-foreground-strong`,children:PM(e)}),(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:c!==``,onClick:()=>p(e),children:$(`panel.tailcat.revoke`)})]},e))})]})]})]}),(0,U.jsx)(xD,{className:`flex justify-end gap-2`,children:(0,U.jsx)(Q,{variant:`outline`,disabled:c!==``,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}var IM=`/dsh-market/api/v1`,LM=`dsh-mobile-plugin`,RM=class extends Error{constructor(e,t,n){super(n),G(this,`status`,void 0),G(this,`code`,void 0),this.name=`MarketError`,this.status=e,this.code=t}},zM=e=>e&&typeof e==`object`?e:{},BM=e=>typeof e==`string`&&e!==``?e:null;async function VM(e,t){let n;try{n=await fetch(`${IM}${e}`,{credentials:`same-origin`,...t})}catch(e){throw new RM(0,`market_unreachable`,$(`panel.net.marketUnreachable`,{message:String(e?.message||e)}))}let r=await n.json().catch(()=>null);if(!n.ok){let e=zM(r),t=zM(e.failure),i=BM(t.code)??(typeof e.error==`string`?e.error:`HTTP ${n.status}`),a=BM(t.message)??BM(e.error)??$(`panel.net.marketHttp`,{status:n.status});throw new RM(n.status,i,a)}return r}async function HM(){try{return{available:!0,restartSupported:zM(zM(await VM(`/capabilities`)).restart).supported===!0}}catch{return{available:!1,restartSupported:!1}}}async function UM(e=LM,t=!1){let n=zM(await VM(`/updates${`?name=${encodeURIComponent(e)}${t?`&force=1`:``}`}`)),r=zM(n.package??n);return{installedVersion:BM(r.installedVersion),latestVersion:BM(r.latestVersion),updateAvailable:r.updateAvailable===!0,source:BM(r.source)}}var WM=new Set([`OPERATION_BUSY`,`RELEASE_TOO_FRESH`,`VERSION_UNCHANGED`,`PLUGIN_NOT_INSTALLED`,`AGENTS_RUNNING`]);function GM(e){let t=e.installedVersion??e.beforeVersion;return e.failure?{text:$(`panel.update.applyFailed`,{message:e.failure.message}),ok:!1}:e.installed===!1?e.skipped?{text:t?$(`panel.update.applyUpToDate`,{version:t}):$(`panel.update.applyUpToDatePlain`),ok:!0}:{text:t?$(`panel.update.applyDiskUnchanged`,{version:t}):$(`panel.update.applyFailedRetry`),ok:!1}:{text:t?$(`panel.update.applySwitched`,{version:t}):$(`panel.update.applySwitchedPlain`),ok:!0}}function KM({version:e,busy:t,onRestartSidecar:n,extraActions:r,onIssues:i,bare:a=!1}){let[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(null),[_,v]=(0,g.useState)(``),y=uO(),b=(0,g.useCallback)(e=>{e&&s(t=>({...e,available:e.available===!0||t?.available===!0}))},[]),x=o!==null&&o.available&&!u,S=t!==``||_!==``,C=(0,g.useCallback)(async()=>{try{let e=await SO();s(e),d(e.available!==!0)}catch(e){s(null),d(vO(e))}finally{l(!0)}},[]);(0,g.useEffect)(()=>{C()},[C]),(0,g.useEffect)(()=>{if(!c)return;let e=!0;return CO().then(t=>{e&&(t.update&&h(t.update),t.status&&b(t.status))}).catch(()=>{}),()=>{e=!1}},[c]);let w=o?.swapping===!0;(0,g.useEffect)(()=>{if(!w)return;let e=window.setInterval(()=>void C(),1500);return()=>window.clearInterval(e)},[w,C]),(0,g.useEffect)(()=>{if(x||!c)return;let e=!0;return HM().then(t=>{e&&p(t)}),()=>{e=!1}},[x,c]);let T=(0,g.useCallback)(e=>{if(e instanceof RM&&WM.has(e.code)){y(`soft`,`${e.message}(${e.code})`);return}y(`error`,cO(e))},[]),E=(0,g.useCallback)(async()=>{v(`check`);try{let e=await CO();e.status&&b(e.status),e.update&&h(e.update)}catch(e){_O(e)||vO(e)?await C():y(`error`,cO(e))}finally{v(``)}},[C]),D=(0,g.useCallback)(async e=>{v(`apply`);try{let t=await wO(e);t.status&&b(t.status);let n=GM(t),r=t.failure!==null&&WM.has(t.failure.code);n.ok||r?y(`soft`,n.text):y(`error`,n.text)}catch(e){_O(e)||vO(e)?await C():y(`error`,cO(e))}finally{v(``)}},[C]),O=(0,g.useCallback)(async()=>{v(`check`);try{let e=await CO();e.status&&b(e.status),h(e.update)}catch(e){if(!_O(e))h(null),y(`error`,cO(e));else try{h(await UM(void 0,!0))}catch(e){h(null),T(e)}}finally{v(``)}},[T]),k=m?.source??o?.marketResult?.source??null,A=k===`linked`||k===`file`||k===`workspace`,j=m?.updateAvailable??o?.marketResult?.updateAvailable??!1,M=o?.lastApply?GM(o.lastApply):null,N=o?.version??null,P=x&&!!N&&!!e&&N!==e,F=o?.installedVersion??null,I=x&&!!F&&!!e&&F!==e;(0,g.useEffect)(()=>{if(!i)return;let t=[];P&&t.push({title:$(`panel.update.runningVersion`),detail:$(`panel.update.versionDrift`,{version:e??``,shell:N??``})}),I&&t.push({title:$(`panel.update.diskVersion`),detail:$(`panel.update.diskDrift`,{disk:F??``,running:e??``})}),i(t)},[i,P,I,e,N,F]);let L=(0,U.jsxs)(U.Fragment,{children:[c?null:(0,U.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,U.jsx)(BE,{}),$(`panel.update.reading`)]}),u?(0,U.jsx)(U.Fragment,{children:(0,U.jsxs)(`p`,{className:`mt-3 text-xs text-foreground-muted`,children:[j?$(`panel.update.hasNew`):``,$(`panel.update.nothingToInstall`)]})}):null,c&&!x&&!u&&f!==null&&!f.available?(0,U.jsxs)(JE,{variant:`info`,className:`mt-3`,children:[(0,U.jsx)(XE,{}),(0,U.jsx)(ZE,{children:$(`panel.update.noMarketTitle`)}),(0,U.jsx)(QE,{children:$(`panel.update.noMarketBody`)})]}):null,x&&o?(0,U.jsxs)(U.Fragment,{children:[o.lastError?(0,U.jsx)(`p`,{className:`mt-2 text-xs text-foreground-muted`,children:$(`panel.update.lastErrorLine`,{message:o.lastError})}):null,(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1 lg:flex-nowrap`,children:[r,(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:S,onClick:n,children:$(`panel.update.restartSidecar`)}),(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:S,onClick:()=>void E(),children:$(_===`check`?`panel.update.checking`:`panel.update.check`)}),A?null:(0,U.jsx)(Q,{variant:`primary`,size:`sm`,disabled:S,onClick:()=>void D(!1),children:$(_===`apply`?`panel.update.updating`:`panel.update.updateNow`)})]}),!A&&(j||M!==null&&!M.ok)?(0,U.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:S,onClick:()=>void D(!0),children:$(`panel.update.forceHint`)})}):null]}):null,c&&!x&&!u&&f?.available?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rk,{className:tk,children:(0,U.jsx)(ek,{label:$(`panel.update.checkResult`),children:$(j?`panel.update.resultHasNew`:`panel.update.resultUpToDate`)})}),(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1 lg:flex-nowrap`,children:[r,(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:S,onClick:n,children:$(`panel.update.restartSidecar`)}),(0,U.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:S,onClick:()=>void O(),children:$(_===`check`?`panel.update.checking`:`panel.update.check`)}),o!==null&&!A?(0,U.jsx)(Q,{variant:`primary`,size:`sm`,disabled:S,onClick:()=>void D(!1),children:$(_===`apply`?`panel.update.updating`:`panel.update.updateNow`)}):null]})]}):null]});return a?L:(0,U.jsxs)(cD,{frame:`solid`,children:[(0,U.jsx)(lD,{className:`px-4 py-3`,children:(0,U.jsxs)(uD,{className:`flex items-center gap-2 text-base lg:text-lg`,children:[(0,U.jsx)(`span`,{children:$(`panel.update.title`)}),(0,U.jsx)(nD,{variant:`soft`,size:`sm`,children:e||$(`panel.update.unknownVersion`)})]})}),L]})}function qM({webAccess:e,busy:t,onToggle:n}){let r=e?.enabled===!0,i=typeof e?.expiresAt==`number`?e.expiresAt:0;return(0,U.jsxs)(cD,{frame:`solid`,children:[(0,U.jsx)(lD,{className:`px-4 py-3`,children:(0,U.jsx)(uD,{className:`text-base lg:text-lg`,children:$(`panel.webAccess.title`)})}),(0,U.jsx)(rk,{children:(0,U.jsx)(ek,{label:$(`panel.webAccess.state`),tone:r?`ok`:`off`,children:r?$(`panel.webAccess.expires`,{time:hg(i)}):$(`panel.webAccess.closed`)})}),(0,U.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-foreground-muted`,children:$(`panel.webAccess.hint`)}),(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:r?(0,U.jsx)(Q,{variant:`outline`,size:`sm`,disabled:t===`webAccess`,onClick:()=>n(!1),children:$(`panel.webAccess.close`)}):(0,U.jsx)(Q,{variant:`outline`,size:`sm`,disabled:t===`webAccess`,onClick:()=>n(!0),children:$(`panel.webAccess.open`)})})]})}function JM(e,t=``){let n=document.documentElement;n.setAttribute(`data-dshm-panel-state`,e),t?n.setAttribute(`data-dshm-panel-error`,t):n.removeAttribute(`data-dshm-panel-error`),window.parent!==window&&window.parent.postMessage({type:`dsh-mobile-plugin:panel-state`,state:e,message:t},`*`)}var YM=1500,XM=600;function ZM(){return(0,U.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,className:`size-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,U.jsx)(`path`,{d:`M4 7h16`}),(0,U.jsx)(`path`,{d:`M9 7V4.5A1.5 1.5 0 0 1 10.5 3h3A1.5 1.5 0 0 1 15 4.5V7`}),(0,U.jsx)(`path`,{d:`M6 7l1 12.5A2 2 0 0 0 9 21h6a2 2 0 0 0 2-1.5L18 7`}),(0,U.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})}function QM(){let[e,t]=(0,g.useState)(null),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(``),[m,h]=(0,g.useState)([]),[_,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(!1),D=uO();(0,g.useEffect)(()=>{e?JM(`ready`):n&&JM(`error`,n)},[e,n]);let O=(0,g.useRef)(null),[k,A]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=O.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>A(e.getBoundingClientRect().height);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e]);let j=(0,g.useCallback)(async()=>{try{t(await rO(`/api/relay/status`)),r(``)}catch(e){r(cO(e))}},[]),M=(0,g.useCallback)(async()=>{l(``);try{s(await rO(`/api/relay/pairing`)),l(``)}catch(e){s(null),l(cO(e))}},[]),N=(0,g.useCallback)(async()=>{try{d(await rO(`/api/relay/addresses`)),p(``)}catch(e){d(null),p(cO(e))}},[]);(0,g.useEffect)(()=>{let e=()=>{c_()&&j()};e();let t=0,n=window.setTimeout(()=>{t=window.setInterval(e,3e3)},YM);return document.addEventListener(`visibilitychange`,e),()=>{window.clearTimeout(n),t&&window.clearInterval(t),document.removeEventListener(`visibilitychange`,e)}},[j]),(0,g.useEffect)(()=>{if(!e?.enabled)return;let t=window.setTimeout(()=>void M(),XM);return()=>window.clearTimeout(t)},[e?.enabled,M]),(0,g.useEffect)(()=>{e?.enabled&&o&&e.pairingCode&&o.pairingCode!==e.pairingCode&&M()},[e?.pairingCode,e?.enabled,o,M]);let P=(0,g.useCallback)(async()=>{try{s(await rO(`/api/relay/pairing`)),l(``)}catch{}},[]);(0,g.useEffect)(()=>{if(!e?.enabled)return;let t=eO(o);if(t===null)return;let n=window.setTimeout(()=>void P(),t);return()=>window.clearTimeout(n)},[o,e?.enabled,P]),(0,g.useEffect)(()=>{if(!e?.enabled)return;let t=window.setTimeout(()=>void N(),XM);return()=>window.clearTimeout(t)},[e?.enabled,o,N]),(0,g.useEffect)(()=>{_&&e?.enabled&&(M(),N())},[_,e?.enabled,M,N]);let F=(0,g.useCallback)(async(e,t)=>{a(e);try{await t()}catch(e){D(`error`,cO(e))}finally{a(``)}},[D]),I=e=>F(`toggle`,async()=>{t(await iO(`/api/relay/toggle`,{enabled:e})),e?await M():(s(null),l(``)),D(`soft`,$(e?`panel.shell.remoteEnabled`:`panel.shell.remoteDisabled`))}),L=()=>F(`restart`,async()=>{let e=await iO(`/api/relay/restart-sidecar`);t(e.status),D(`soft`,$(`panel.shell.sidecarRestarted`))}),R=e=>F(`webAccess`,async()=>{let n=await iO(`/api/relay/web-access`,{enabled:e});t(e=>e&&{...e,webAccess:n.webAccess}),D(`soft`,$(e?`panel.webAccess.opened`:`panel.webAccess.closedNotice`))}),z=(e,n)=>F(`config`,async()=>{let r={...e};if(n){let e=await oO(n.config);if(!e.ok||!e.status?.running||e.status.error)throw await j(),Error(e.status?.error||$(`panel.connection.tcpFailed`));n.field===`tcp`&&(r.manualTcpUrl===void 0||r.manualTcpUrl===n.value)&&(r.manualTcpUrl=e.status.remoteAddress||n.value)}t(await iO(`/api/relay/config`,r)),v(!1),await Promise.all([M(),N()]),D(`soft`,$(`panel.shell.configSaved`))}),B=()=>{window.confirm($(`panel.frp.stopConfirm`))&&F(`frp`,async()=>{await sO(),await Promise.all([j(),N(),M()])})},V=(e,n)=>F(`config`,async()=>{let r=await iO(`/api/relay/config`,e,{keepApplyError:!0});t(r),r.applyError?D(`error`,$(`panel.shell.applyFailed`,{message:r.applyError})):D(`soft`,$(n))}),H=e=>V({pairingPolicy:e},e===`code`?`panel.shell.deviceAllowed`:`panel.shell.deviceDenied`),ee=e=>V({controlReportEnabled:e},`panel.shell.configSaved`),te=(e,n)=>F(`lan`,async()=>{t(await iO(`/api/relay/config`,{lanPort:e,lanPortFixed:n})),b(!1),await M(),D(`soft`,$(`panel.shell.lanSaved`))}),ne=e=>F(`lan`,async()=>{t(await iO(`/api/relay/config`,{preferredLanAddress:e})),await Promise.all([M(),N()]),D(`soft`,e?$(`panel.shell.preferredAddress`,{address:e}):$(`panel.shell.preferredAuto`))}),W=e?e.tunnel.state===`connected`||e.lan.state===`listening`?`ok`:e.enabled?`warn`:`off`:null;return e?(0,U.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[1200px] flex-col gap-3 p-4 sm:p-5`,children:[(0,U.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[W?(0,U.jsx)($O,{tone:W}):null,(0,U.jsx)(nD,{variant:`soft`,size:`sm`,children:e.appVersion||$(`panel.shell.unknownVersion`)}),(0,U.jsx)(LA,{compact:!0})]}),i?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-foreground-muted`,children:[(0,U.jsx)(BE,{}),$(`panel.shell.busy`)]}):null,(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,U.jsx)(Eg,{}),(0,U.jsx)(i_,{}),(0,U.jsx)(Q,{variant:`ghost`,size:`icon-md`,"aria-label":$(`panel.inbox.title`),title:$(`panel.inbox.title`),onClick:()=>E(!0),children:(0,U.jsx)(ZM,{})}),(0,U.jsx)(Ik,{})]})]}),n?(0,U.jsxs)(JE,{variant:`error`,children:[(0,U.jsx)(XE,{}),(0,U.jsx)(ZE,{children:$(`panel.shell.statusFailed`)}),(0,U.jsx)(QE,{children:n})]}):null,(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-3`,children:[(0,U.jsxs)(cD,{frame:`solid`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 p-4 lg:grid-cols-10 lg:gap-6`,children:[(0,U.jsx)(`div`,{className:`lg:col-span-6`,children:(0,U.jsx)(jj,{bare:!0,status:e,pairing:o,addressBook:u,addressError:f,onRetryAddresses:()=>void N(),version:e.appVersion||``,versionIssues:m,busy:i,error:c,onRetryPairing:()=>void M(),onSavePreferred:e=>void ne(e),onEditPort:()=>b(!0)})}),(0,U.jsxs)(`div`,{className:`lg:col-span-4`,children:[(0,U.jsx)(rk,{className:nk,children:(0,U.jsx)(Mj,{status:e,busy:i,onChangePolicy:e=>void H(e),onToggleRemote:e=>void I(e),onChangeControlReport:e=>void ee(e)})}),(0,U.jsx)(DO,{})]})]}),(0,U.jsx)(`div`,{className:`mt-4 flex h-12 items-center justify-end border-t border-border-muted`,children:(0,U.jsx)(KM,{bare:!0,version:e.appVersion||``,busy:i,onRestartSidecar:()=>void L(),onIssues:h,extraActions:(0,U.jsx)(U.Fragment,{children:(0,U.jsx)(Q,{variant:`primary`,size:`sm`,onClick:()=>v(!0),children:$(`panel.pairing.openConfig`)})})})})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,U.jsx)(`div`,{ref:O,children:(0,U.jsx)(kk,{status:e,addressBook:u,busy:i,onStopFrp:B,onManageTailcat:()=>S(!0),onManageP2P:()=>w(!0),restartError:e.sidecar.restartError})}),(0,U.jsx)(`div`,{className:`min-h-0`,style:k>0?{height:`${k}px`}:void 0,children:(0,U.jsx)(eA,{busy:i,fill:!0})})]}),(0,U.jsx)(`div`,{className:`columns-1 gap-3 md:columns-2 xl:columns-3 [&>*]:mb-3 [&>*]:break-inside-avoid`,children:e.webAccess?.enabled&&e.panelScope!==`loopback`?(0,U.jsx)(qM,{webAccess:e.webAccess,busy:i,onToggle:e=>void R(e)}):null})]}),(0,U.jsx)(MM,{open:_,onOpenChange:v,status:e,addressBook:u,addressError:f,onRetryAddresses:()=>void N(),lanUrls:o?.lanUrls??[],busy:i,onSave:(e,t)=>void z(e,t),onSavePreferred:e=>void ne(e)}),(0,U.jsx)(FM,{open:x,onOpenChange:S,onChanged:()=>void j()}),(0,U.jsx)(Ij,{open:C,onOpenChange:w,onChanged:()=>void j()}),(0,U.jsx)(eM,{open:y,onOpenChange:b,port:o?.lanPort??e.lan.requestedPort??e.lan.port,busy:i,fixed:e.lanPortFixed===!0,forwarding:e.lanPortLockReason===`forwarding`,onSave:(e,t)=>void te(e,t)}),(0,U.jsx)(hD,{open:T,onOpenChange:E,children:(0,U.jsxs)(gD,{className:`max-w-md`,children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.inbox.title`)})}),(0,U.jsx)(bD,{children:(0,U.jsx)(BA,{framed:!1})})]})}),(0,U.jsx)(tM,{visible:oA(e.relayUrl),onOpenConfig:()=>v(!0)})]}):(0,U.jsx)(`main`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-3 p-5`,children:n?(0,U.jsx)(`p`,{className:`text-sm text-error`,children:n}):(0,U.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-foreground-muted`,children:[(0,U.jsx)(BE,{}),$(`panel.shell.readingStatus`)]})})}var $M=[{textKey:`panel.onboarding.linuxStep1`},{text:`systemctl status firewalld`,cmd:!0},{text:`sudo ufw status`,cmd:!0},{textKey:`panel.onboarding.linuxStep2`},{text:`sudo firewall-cmd --permanent --add-port={port}/tcp
108
108
  sudo firewall-cmd --reload`,cmd:!0},{text:`sudo ufw allow {port}/tcp`,cmd:!0},{textKey:`panel.onboarding.linuxStep3`}],eN=[{textKey:`panel.onboarding.macStep1`},{text:`/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate`,cmd:!0},{textKey:`panel.onboarding.macStep2`},{text:`sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off`,cmd:!0},{textKey:`panel.onboarding.macStep3`}],tN=[{textKey:`panel.onboarding.winStep1`},{text:`Get-NetFirewallProfile | Select-Object Name, Enabled`,cmd:!0},{textKey:`panel.onboarding.winStep2`},{text:`New-NetFirewallRule -DisplayName "DSH Mobile {port}" -Direction Inbound -LocalPort {port} -Protocol TCP -Action Allow`,cmd:!0},{textKey:`panel.onboarding.winStep3`}];function nN(){return[$(`panel.onboarding.prompt.intro`),``,$(`panel.onboarding.prompt.situation`),$(`panel.onboarding.prompt.address`),$(`panel.onboarding.prompt.guess`),``,$(`panel.onboarding.prompt.ask`),$(`panel.onboarding.prompt.ask1`),$(`panel.onboarding.prompt.ask2`),$(`panel.onboarding.prompt.ask3`),$(`panel.onboarding.prompt.ask4`),``,$(`panel.onboarding.prompt.extra`)].join(`
109
109
  `)}function rN({title:e,steps:t,port:n,onCopied:r}){async function i(){try{await navigator.clipboard.writeText(nN()),r(!0)}catch{r(!1)}}return(0,U.jsxs)(`section`,{className:`flex flex-col gap-1.5 rounded-lg border border-border-muted bg-background-muted p-3`,children:[(0,U.jsx)(`h3`,{className:`text-center text-sm font-semibold text-foreground-intense`,children:e}),t.map(e=>{let t=(e.text??(e.textKey?$(e.textKey):``)).replace(/\{port\}/g,n);return e.cmd?(0,U.jsx)(`pre`,{className:`rounded bg-background-subtle px-2 py-1.5 font-mono text-[11px] leading-5 break-words whitespace-pre-wrap text-foreground-strong`,children:t},t):(0,U.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:t},t)}),(0,U.jsx)(Q,{className:`mt-auto`,variant:`outline`,size:`sm`,onClick:()=>void i(),children:$(`panel.onboarding.copyPromptHint`)})]})}function iN({open:e,onOpenChange:t,port:n}){let[r,i]=(0,g.useState)(``),a=e=>i(e?`ok`:`failed`);return(0,U.jsx)(hD,{open:e,onOpenChange:e=>{e||i(``),t(e)},children:(0,U.jsxs)(gD,{className:`w-[min(1200px,92vw)] max-w-none`,backdropProps:{className:`z-[80]`},viewportProps:{className:`z-[80]`},children:[(0,U.jsx)(_D,{children:(0,U.jsx)(vD,{children:$(`panel.onboarding.firewallTitle`)})}),(0,U.jsxs)(bD,{className:`flex flex-col gap-4`,children:[(0,U.jsxs)(`p`,{className:`text-sm text-foreground-muted`,children:[$(`panel.onboarding.firewallIntro`),` `,(0,U.jsx)(`span`,{className:`font-mono`,children:n}),$(`panel.onboarding.firewallIntroTail`)]}),(0,U.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,U.jsx)(rN,{title:`Linux`,steps:$M,port:n,onCopied:a}),(0,U.jsx)(rN,{title:`Mac`,steps:eN,port:n,onCopied:a}),(0,U.jsx)(rN,{title:`Windows`,steps:tN,port:n,onCopied:a})]})]}),r?(0,U.jsx)(xD,{className:`flex justify-end`,children:(0,U.jsx)(`span`,{className:`text-xs text-foreground-muted`,children:$(r===`ok`?`panel.onboarding.copiedOk`:`panel.onboarding.copiedFailed`)})}):null]})})}var aN=18e5,oN=3e5,sN=15e3,cN=null,lN=0,uN=0,dN=null;function fN(e){return typeof e!=`number`||!Number.isFinite(e)?!1:e===0||Date.now()-e>aN}function pN(e){if(!e&&dN)return dN;let t=(async()=>{let t=await rO(e?`/api/relay/selfcheck?force=1`:`/api/relay/selfcheck`);return cN=t,lN=Date.now(),t})();return e||(dN=t,t.finally(()=>{dN===t&&(dN=null)})),t}function mN(e,t=``){let[n,r]=(0,g.useState)(cN),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(!1),u=(0,g.useRef)(!0);(0,g.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let d=(0,g.useCallback)(async e=>{if(!e&&cN&&Date.now()-lN<sN){r(cN);return}a(!0);try{let t=await pN(e);if(!u.current)return;r(t),s(``),l(!1)}catch(e){if(!u.current)return;l(e instanceof tO&&e.status===404),s(cO(e))}finally{u.current&&a(!1)}},[]);(0,g.useEffect)(()=>{e&&(Date.now()-uN<oN||cN&&Date.now()-lN<sN||(uN=Date.now(),d(!1)))},[e,d]);let f=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(t){if(f.current===null){f.current=t;return}f.current!==t&&(f.current=t,d(!0))}},[t,d]),{data:n,checking:i,error:o,missing:c,ensure:(0,g.useCallback)(()=>void d(!1),[d]),refresh:(0,g.useCallback)(()=>void d(!0),[d])}}function hN(e){return e===`ok`?`ok`:e===`unknown`?`warn`:`error`}var gN={ok:{long:`panel.selfcheck.verdict.ok`,short:`panel.selfcheck.short.ok`},"not-listening":{long:`panel.selfcheck.verdict.notListening`,short:`panel.selfcheck.short.notListening`},"firewall-blocked":{long:`panel.selfcheck.verdict.firewallBlocked`,short:`panel.selfcheck.short.firewallBlocked`},unknown:{long:`panel.selfcheck.verdict.unknown`,short:`panel.selfcheck.short.unknown`},network:{long:`panel.selfcheck.verdict.network`,short:`panel.selfcheck.short.network`}};function _N(e){return $(gN[e]?.long??`panel.selfcheck.verdict.unknown`)}function vN(e){if(!e)return{tone:`off`,text:$(`panel.selfcheck.notChecked`)};let t=e.firewall,n=yN(t.appPath);return!t.supported||t.enabled===null?{tone:`warn`,text:$(`panel.selfcheck.unknown`)}:t.enabled===!1?{tone:`ok`,text:$(`panel.selfcheck.firewallOff`),...n?{detail:n}:{}}:t.allowsApp===!1?{tone:`error`,text:$(`panel.selfcheck.blocked`),...n?{detail:n}:{}}:t.allowsApp===!0?{tone:`ok`,text:$(`panel.selfcheck.allowed`),...n?{detail:n}:{}}:{tone:`warn`,text:$(`panel.selfcheck.unknown`)}}function yN(e){let t=String(e??``).trim();if(!t)return``;let n=t.split(/[\\/]/);return n[n.length-1]??``}function bN(e){let t=(e.preferred||``).trim();return t&&e.lan.some(e=>e.address===t)?t:e.lan[0]?.address??``}function xN({onDone:e}){let[t,n]=(0,g.useState)(null),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(null),[h,_]=(0,g.useState)(``),[v,y]=(0,g.useState)(``),[b,x]=(0,g.useState)(!1),[S,C]=(0,g.useState)(!1),[w,T]=(0,g.useState)(!1),[E,D]=(0,g.useState)(``),[O,k]=(0,g.useState)({}),[A,j]=(0,g.useState)({}),[M,N]=(0,g.useState)({}),P=mN(fN(t?.lastMobileAt),t?`${+!!t.enabled}|${+!!t.lan.enabled}|${t.lan.state}|${t.tunnel.state}|${+((t.lastMobileAt??0)>0)}`:``),F=vN(P.data),I=P.data?.verdict??``,L=(0,g.useRef)(!0);(0,g.useEffect)(()=>(L.current=!0,()=>{L.current=!1}),[]),(0,g.useEffect)(()=>{let e=!0,t=async()=>{if(c_())try{let t=await rO(`/api/relay/status`);e&&n(t)}catch{}},r=window.setInterval(()=>void t(),3e3);return document.addEventListener(`visibilitychange`,t),()=>{e=!1,window.clearInterval(r),document.removeEventListener(`visibilitychange`,t)}},[]),VA(t?.lastPairingAt,()=>{C(!1),W()}),(0,g.useEffect)(()=>{(async()=>{try{let e=await rO(`/api/relay/addresses`);f(e),y(bN(e))}catch{f(null),u(!0)}})()},[]),(0,g.useEffect)(()=>{(async()=>{try{let e=await rO(`/api/relay/status`);n(e),e.enabled&&u(!0)}catch(e){i(cO(e))}await z()})()},[]);let R=(0,g.useRef)(!1);(0,g.useEffect)(()=>{R.current||d!==null&&(R.current=!0,!(t&&t.enabled)&&ne())},[d,t]);async function z(){_(``);try{m(await rO(`/api/relay/pairing`))}catch(e){_(cO(e))}}(0,g.useEffect)(()=>{let e=eO(p);if(e===null)return;let t=window.setTimeout(()=>{L.current&&z()},e);return()=>window.clearTimeout(t)},[p]);let B=String(t?.lan.port||d?.port||18787),V=t!==null&&(t.lan.state===`listening`||t.tunnel.state===`connected`),H=t!==null&&l&&!P.checking&&I!==`ok`&&!(I===`not-listening`&&V);async function ee(){let e=Date.now();for(;L.current&&Date.now()-e<2e4;){if(await new Promise(e=>window.setTimeout(e,1500)),!L.current)return;let e;try{e=await rO(`/api/relay/status`)}catch{continue}if(n(e),e.lan.state===`listening`||e.tunnel.state===`connected`||e.lan.state===`error`&&e.tunnel.state===`error`)return}}async function te(e){if(s)return;c(!0),e&&u(!1),o(``);let t={relayUrls:aA.map(e=>e.url),lanEnabled:!0,pairingPolicy:`code`};v&&(t.preferredLanAddress=v);try{n(await iO(`/api/relay/config`,t)),e&&(n(await iO(`/api/relay/toggle`,{enabled:!0})),await iO(`/api/relay/onboarded`,{}).catch(()=>void 0)),await z(),e&&ee().finally(()=>{L.current&&u(!0)})}catch(t){e&&L.current&&u(!0),o(cO(t))}finally{c(!1)}}async function ne(){await te(!0)}function W(){e?e():window.location.assign(`/`)}async function re(){let e=[$(`panel.onboarding.tailcatPrompt.intro`),``,$(`panel.onboarding.tailcatPrompt.situation`),$(`panel.onboarding.tailcatPrompt.state`,{state:se}),$(`panel.onboarding.tailcatPrompt.guess`),``,$(`panel.onboarding.tailcatPrompt.ask`),$(`panel.onboarding.tailcatPrompt.ask1`),$(`panel.onboarding.tailcatPrompt.ask2`),$(`panel.onboarding.tailcatPrompt.ask3`)].join(`
110
110
  `);try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}async function G(e,n,r){if(O[e])return;k(t=>({...t,[e]:!0})),j(t=>({...t,[e]:``})),N(t=>({...t,[e]:``}));let i=[`title=${n}`,`error=${r}`,`lan=${t?.lan.state??``}`,`tunnel=${t?.tunnel.state??``}`,`tailcat=${se||``}`,`firewall=${F.text||``}`,`verdict=${I||``}`].join(`
@@ -9,6 +9,8 @@ const pairingApproval = require('./pairing-policy.js');
9
9
  const RemoteControlSettingsSchema = z.object({
10
10
  enabled: z.boolean().default(false),
11
11
  relayUrl: z.string().default(''),
12
+ // 用户显式「停用公用中转」(issue #27):为真时保存与读盘都不再补回公用地址,允许只走直连 / 局域网。
13
+ publicRelayDisabled: z.boolean().default(false),
12
14
  // 完整的中转地址列表,`relayUrls[0]` 恒等于 `relayUrl`(见 docs/relay-multi-address.md)。
13
15
  // 宿主从列表选择并注册一条线路,中选地址写回首项;手机只跟随当前注册线路。
14
16
  relayUrls: z.array(z.string()).default([]),
@@ -54,6 +56,8 @@ function configOf(state) {
54
56
  enabled: Boolean(state.enabled),
55
57
  relayUrl: relay.relayUrl,
56
58
  relayUrls: relay.relayUrls,
59
+ // 只有明确写成 true 才是「用户显式停用公用中转」;老状态文件没这一格时按未停用处理。
60
+ publicRelayDisabled: state.publicRelayDisabled === true,
57
61
  lanEnabled: Boolean(state.lanEnabled),
58
62
  lanPort: Number.isInteger(state.lanPort) ? state.lanPort : 18787,
59
63
  lanPortFixed: state.lanPortFixed === true,
package/lib/relay/core.js CHANGED
@@ -53,6 +53,10 @@ function genHistoryKey() { return crypto.randomBytes(32).toString('base64url');
53
53
  function defaultState() {
54
54
  return {
55
55
  instanceId: genInstanceId(), pairingCode: genPairingCode(), pairingTicket: genPairingTicket(), relayUrl: '', relayUrls: [], name: os.hostname(),
56
+ // 用户显式「停用公用中转」(只走直连/局域网时也能关,issue #27)。为真时保存与读盘都不再把
57
+ // 公用地址补回。与 publicRelayBlocked(配了自建中转时的强制停用)是两回事:那条是「有替代」,
58
+ // 这条是「显式不要」。
59
+ publicRelayDisabled: false,
56
60
  // 新配对设备的权限档位(只读 / 可答审批 / 全权)。缺省 full = 与单 token 全给等价;
57
61
  // 老状态文件没这一格时靠这里兜底,别在别处再判一次「没有就拒绝」。
58
62
  pairingTier: 'full',
@@ -401,6 +405,16 @@ function stripPublicRelay(next) {
401
405
  */
402
406
  function expandDefaultPublicRelays(state) {
403
407
  if (!state || typeof state !== 'object') return false;
408
+ // 用户显式停用公用中转(issue #27):把列表里还残留的公用地址剔掉,并且不再补回 ——
409
+ // 保存与读盘都经过这里,所以「停用」能跨重启持久,不会被空列表回补成公用那条。
410
+ if (state.publicRelayDisabled === true) {
411
+ const relay = relayAddressesOf(state);
412
+ const kept = relay.relayUrls.filter((url) => !isPublicRelayUrl(url));
413
+ if (kept.length === relay.relayUrls.length) return false;
414
+ state.relayUrls = kept;
415
+ state.relayUrl = kept.length ? kept[0] : '';
416
+ return true;
417
+ }
404
418
  const urls = relayAddressesOf(state).relayUrls;
405
419
  if (!urls.length && state.enabled !== true) return false;
406
420
  if (!urls.every((url) => isPublicRelayUrl(url))) return false;
@@ -349,7 +349,7 @@ function registerControlPlaneRoutes(deps) {
349
349
  * 包在这一层而不是 `createStatusView` 里:那份 JSON 手机端也在读,给它加字段是另一个决定。
350
350
  * 所有 `status()` 调用点(面板页、config / toggle 等写操作回包)都自动带上这一格。
351
351
  */
352
- const status = () => ({ ...rawStatus(), publicRelayBlocked: core.publicRelayBlocked(state), controlReportTargetUrl: getControlTargetUrl() });
352
+ const status = () => ({ ...rawStatus(), publicRelayBlocked: core.publicRelayBlocked(state), publicRelayDisabled: state.publicRelayDisabled === true, controlReportTargetUrl: getControlTargetUrl() });
353
353
  /**
354
354
  * 宿主发布的包管理器调用方式(`profileContext.packageManager`)。
355
355
  *
@@ -982,6 +982,9 @@ function registerControlPlaneRoutes(deps) {
982
982
  if (Array.isArray(body?.relayUrls)) {
983
983
  patch.relayUrls = body.relayUrls.filter(url => typeof url === 'string' && url.length <= 500).map(url => url.trim())
984
984
  }
985
+ // 显式「停用公用中转」(issue #27):只认布尔值。为真时保存与读盘都不再补回公用地址,
986
+ // 从而允许用户只走直连 / 局域网而不用公用中转。
987
+ if (typeof body?.publicRelayDisabled === 'boolean') patch.publicRelayDisabled = body.publicRelayDisabled
985
988
  if (typeof body?.lanEnabled === 'boolean') patch.lanEnabled = body.lanEnabled
986
989
  if (typeof body?.lanPortFixed === 'boolean') patch.lanPortFixed = body.lanPortFixed
987
990
  if (Number.isInteger(body?.lanPort) && body.lanPort >= 1024 && body.lanPort <= 65535) patch.lanPort = body.lanPort
@@ -239,6 +239,8 @@ function registerMobileRoutes(deps) {
239
239
  // 连接地址里仍列公用中转地址、线路检测仍测它、当前地址里仍写它。判据只有
240
240
  // `core.publicRelayBlocked` 那一处,这里只如实转述,不另算一套。
241
241
  publicRelayBlocked: publicRelayBlocked(state),
242
+ // 用户显式停用了公用中转(issue #27):手机按这一格不再把公用中转当可用线路画。
243
+ publicRelayDisabled: state.publicRelayDisabled === true,
242
244
  // 这一代运行时少挂了什么(见 lib/host-capabilities.cjs)。
243
245
  //
244
246
  // 这一格存在的理由,是那类故障的形状:宿主起来、手机连上、会话能开,唯独某个工具
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mobile-plugin",
3
- "version": "0.5.87",
3
+ "version": "0.5.88",
4
4
  "description": "Mobile API (/api/mobile/v1) and relay client for the DSH mobile app — desktop profile build (dsh 0.2.x, peers resolved by the host)",
5
5
  "license": "MIT",
6
6
  "icon": "./icon.png",