@spencerboucher/switchyard 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/bridge/lines.js +33 -0
- package/dist/bridge/switchyard-terminal.js +155 -23
- package/dist/switchyard.mjs +3879 -2658
- package/dist/terminal/holder.js +142 -51
- package/package.json +1 -1
- package/web-dist/apple-touch-icon.png +0 -0
- package/web-dist/assets/AutomationView-D7Syv1En.js +2 -0
- package/web-dist/assets/AutomationView-D7Syv1En.js.map +1 -0
- package/web-dist/assets/Checkbox-D6tRfEeI.js +2 -0
- package/web-dist/assets/Checkbox-D6tRfEeI.js.map +1 -0
- package/web-dist/assets/Copy-B6XSAIUd.js +2 -0
- package/web-dist/assets/Copy-B6XSAIUd.js.map +1 -0
- package/web-dist/assets/DangerZone-DfYlxDC1.js +2 -0
- package/web-dist/assets/DangerZone-DfYlxDC1.js.map +1 -0
- package/web-dist/assets/Field-D-Ty7fKT.js +2 -0
- package/web-dist/assets/Field-D-Ty7fKT.js.map +1 -0
- package/web-dist/assets/InteractionCard-DF1EcSpm.js +6 -0
- package/web-dist/assets/InteractionCard-DF1EcSpm.js.map +1 -0
- package/web-dist/assets/Menu-BfOszNC4.js +2 -0
- package/web-dist/assets/Menu-BfOszNC4.js.map +1 -0
- package/web-dist/assets/Overlay-DUQwh6_b.js +2 -0
- package/web-dist/assets/Overlay-DUQwh6_b.js.map +1 -0
- package/web-dist/assets/Priority-CHmzfoHg.js +2 -0
- package/web-dist/assets/Priority-CHmzfoHg.js.map +1 -0
- package/web-dist/assets/{SegmentedControl-D-2BCZzd.js → SegmentedControl-C_hEVQMB.js} +2 -2
- package/web-dist/assets/{SegmentedControl-D-2BCZzd.js.map → SegmentedControl-C_hEVQMB.js.map} +1 -1
- package/web-dist/assets/Select-Cfql4Nwu.js +2 -0
- package/web-dist/assets/Select-Cfql4Nwu.js.map +1 -0
- package/web-dist/assets/Switch-DBfzmqkm.js +2 -0
- package/web-dist/assets/Switch-DBfzmqkm.js.map +1 -0
- package/web-dist/assets/Tabs-BNuL3_Et.js +184 -0
- package/web-dist/assets/Tabs-BNuL3_Et.js.map +1 -0
- package/web-dist/assets/TextArea-CKybrQyn.js +2 -0
- package/web-dist/assets/TextArea-CKybrQyn.js.map +1 -0
- package/web-dist/assets/TextLink-OzzyP2-p.js +2 -0
- package/web-dist/assets/TextLink-OzzyP2-p.js.map +1 -0
- package/web-dist/assets/arrow-down-C-iLrN8I.js +2 -0
- package/web-dist/assets/arrow-down-C-iLrN8I.js.map +1 -0
- package/web-dist/assets/arrow-up-Dj-VTKx4.js +2 -0
- package/web-dist/assets/arrow-up-Dj-VTKx4.js.map +1 -0
- package/web-dist/assets/attention-V86Gye3I.js +2 -0
- package/web-dist/assets/attention-V86Gye3I.js.map +1 -0
- package/web-dist/assets/automations-Cw5Gacgm.js +2 -0
- package/web-dist/assets/automations-Cw5Gacgm.js.map +1 -0
- package/web-dist/assets/board-B8X7TYYR.js +10 -0
- package/web-dist/assets/board-B8X7TYYR.js.map +1 -0
- package/web-dist/assets/code-BKroYJmR.js +12 -0
- package/web-dist/assets/code-BKroYJmR.js.map +1 -0
- package/web-dist/assets/describe-D6KLGKWa.js +5 -0
- package/web-dist/assets/describe-D6KLGKWa.js.map +1 -0
- package/web-dist/assets/enroll-DwT7AcuS.js +2 -0
- package/web-dist/assets/enroll-DwT7AcuS.js.map +1 -0
- package/web-dist/assets/index-B3F7WcYf.css +2 -0
- package/web-dist/assets/index-hxvDvCS7.js +12 -0
- package/web-dist/assets/index-hxvDvCS7.js.map +1 -0
- package/web-dist/assets/logic-B46fwD-8.js +2 -0
- package/web-dist/assets/logic-B46fwD-8.js.map +1 -0
- package/web-dist/assets/more-DQR5uu1c.js +2 -0
- package/web-dist/assets/more-DQR5uu1c.js.map +1 -0
- package/web-dist/assets/queue-DUg1rS8t.js +2 -0
- package/web-dist/assets/queue-DUg1rS8t.js.map +1 -0
- package/web-dist/assets/repo-XzzzEI0d.js +2 -0
- package/web-dist/assets/repo-XzzzEI0d.js.map +1 -0
- package/web-dist/assets/server-BqZ-w6M8.js +2 -0
- package/web-dist/assets/server-BqZ-w6M8.js.map +1 -0
- package/web-dist/assets/settings-DyUu0tJM.js +8 -0
- package/web-dist/assets/settings-DyUu0tJM.js.map +1 -0
- package/web-dist/assets/states-ZhrxQa3K.js +56 -0
- package/web-dist/assets/states-ZhrxQa3K.js.map +1 -0
- package/web-dist/assets/terminal-BOV_MXPZ.js +2 -0
- package/web-dist/assets/terminal-BOV_MXPZ.js.map +1 -0
- package/web-dist/assets/terminal-login-S5CAd5xA.js +2 -0
- package/web-dist/assets/terminal-login-S5CAd5xA.js.map +1 -0
- package/web-dist/assets/useBackTo-BIrCq3W2.js +2 -0
- package/web-dist/assets/useBackTo-BIrCq3W2.js.map +1 -0
- package/web-dist/assets/useNow-Dj7oEiwn.js +2 -0
- package/web-dist/assets/useNow-Dj7oEiwn.js.map +1 -0
- package/web-dist/assets/useResource-CDGSq2At.js +2 -0
- package/web-dist/assets/useResource-CDGSq2At.js.map +1 -0
- package/web-dist/icon-192.png +0 -0
- package/web-dist/icon-512.png +0 -0
- package/web-dist/icon.svg +20 -8
- package/web-dist/index.html +3 -4
- package/web-dist/manifest.webmanifest +1 -1
- package/web-dist/maskable-512.png +0 -0
- package/web-dist/sw.js +1 -1
- package/web-dist/sw.js.map +1 -1
- package/web-dist/assets/AutomationView-BIW_pO0M.js +0 -2
- package/web-dist/assets/AutomationView-BIW_pO0M.js.map +0 -1
- package/web-dist/assets/Badge-BiDp7NKI.js +0 -2
- package/web-dist/assets/Badge-BiDp7NKI.js.map +0 -1
- package/web-dist/assets/InteractionCard-CWxyDv81.js +0 -6
- package/web-dist/assets/InteractionCard-CWxyDv81.js.map +0 -1
- package/web-dist/assets/Menu-BDt1bxwz.js +0 -2
- package/web-dist/assets/Menu-BDt1bxwz.js.map +0 -1
- package/web-dist/assets/Tabs-ByiPklAw.js +0 -184
- package/web-dist/assets/Tabs-ByiPklAw.js.map +0 -1
- package/web-dist/assets/TextArea-BYr88SnV.js +0 -2
- package/web-dist/assets/TextArea-BYr88SnV.js.map +0 -1
- package/web-dist/assets/arrow-left-C6YWM6y6.js +0 -2
- package/web-dist/assets/arrow-left-C6YWM6y6.js.map +0 -1
- package/web-dist/assets/attention-Bya8XHKI.js +0 -2
- package/web-dist/assets/attention-Bya8XHKI.js.map +0 -1
- package/web-dist/assets/automations-DiXKRcnE.js +0 -2
- package/web-dist/assets/automations-DiXKRcnE.js.map +0 -1
- package/web-dist/assets/board-BrLaJwLJ.js +0 -10
- package/web-dist/assets/board-BrLaJwLJ.js.map +0 -1
- package/web-dist/assets/code-DKLO8bzz.js +0 -11
- package/web-dist/assets/code-DKLO8bzz.js.map +0 -1
- package/web-dist/assets/copy-oWgGHmkS.js +0 -2
- package/web-dist/assets/copy-oWgGHmkS.js.map +0 -1
- package/web-dist/assets/describe-DnvH6_fl.js +0 -5
- package/web-dist/assets/describe-DnvH6_fl.js.map +0 -1
- package/web-dist/assets/dist-BE_V9dwJ.js +0 -56
- package/web-dist/assets/dist-BE_V9dwJ.js.map +0 -1
- package/web-dist/assets/enroll-DUDpbJoB.js +0 -2
- package/web-dist/assets/enroll-DUDpbJoB.js.map +0 -1
- package/web-dist/assets/index-DvRcMGEe.css +0 -2
- package/web-dist/assets/index-vIzH1m8u.js +0 -11
- package/web-dist/assets/index-vIzH1m8u.js.map +0 -1
- package/web-dist/assets/logic-xb-QF00E.js +0 -2
- package/web-dist/assets/logic-xb-QF00E.js.map +0 -1
- package/web-dist/assets/more-BP5x45cs.js +0 -2
- package/web-dist/assets/more-BP5x45cs.js.map +0 -1
- package/web-dist/assets/now--XjJC37b.js +0 -2
- package/web-dist/assets/now--XjJC37b.js.map +0 -1
- package/web-dist/assets/plus-BLP-wIYD.js +0 -2
- package/web-dist/assets/plus-BLP-wIYD.js.map +0 -1
- package/web-dist/assets/save-DEvZPWlS.js +0 -2
- package/web-dist/assets/save-DEvZPWlS.js.map +0 -1
- package/web-dist/assets/send-BKjswHxB.js +0 -2
- package/web-dist/assets/send-BKjswHxB.js.map +0 -1
- package/web-dist/assets/server-SxFxIScj.js +0 -2
- package/web-dist/assets/server-SxFxIScj.js.map +0 -1
- package/web-dist/assets/settings-D8T1esWq.js +0 -7
- package/web-dist/assets/settings-D8T1esWq.js.map +0 -1
- package/web-dist/assets/shared-CZ7fcu_B.js +0 -3
- package/web-dist/assets/shared-CZ7fcu_B.js.map +0 -1
- package/web-dist/assets/sliders-horizontal-DAoirila.js +0 -2
- package/web-dist/assets/sliders-horizontal-DAoirila.js.map +0 -1
- package/web-dist/assets/states--geW2Ntl.js +0 -2
- package/web-dist/assets/states--geW2Ntl.js.map +0 -1
- package/web-dist/assets/terminal-login-BJxV78au.js +0 -2
- package/web-dist/assets/terminal-login-BJxV78au.js.map +0 -1
- package/web-dist/assets/trash-C6X2OLrI.js +0 -2
- package/web-dist/assets/trash-C6X2OLrI.js.map +0 -1
- package/web-dist/assets/useNow-jxdoOC_1.js +0 -2
- package/web-dist/assets/useNow-jxdoOC_1.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as e,m as t}from"./jsx-runtime-D13aM9HY.js";function n(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function r(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function i(){return a.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var a={stubThis:e=>e};function o(e){let{id:t}=e;return{...e,id:r(t),transports:e.transports,type:e.type}}function s(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var c=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function l({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new c({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new c({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new c({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new c({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new c({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new c({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new c({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new c({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!s(t))return new c({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new c({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new c({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new c({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var u=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},d=[`cross-platform`,`platform`];function f(e){if(e&&!(d.indexOf(e)<0))return e}async function p(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:a=!1}=e;if(!i())throw Error(`WebAuthn is not supported in this browser`);let s={...t,challenge:r(t.challenge),user:{...t.user,id:r(t.user.id)},excludeCredentials:t.excludeCredentials?.map(o)},c={};a&&(c.mediation=`conditional`),c.publicKey=s,c.signal=u.createNewAbortSignal();let d;try{d=await navigator.credentials.create(c)}catch(e){throw l({error:e,options:c})}if(!d)throw Error(`Registration was not completed`);let{id:p,rawId:h,response:g,type:_}=d,v;typeof g.getTransports==`function`&&(v=g.getTransports());let y;if(typeof g.getPublicKeyAlgorithm==`function`)try{y=g.getPublicKeyAlgorithm()}catch(e){m(`getPublicKeyAlgorithm()`,e)}let b;if(typeof g.getPublicKey==`function`)try{let e=g.getPublicKey();e!==null&&(b=n(e))}catch(e){m(`getPublicKey()`,e)}let x;if(typeof g.getAuthenticatorData==`function`)try{x=n(g.getAuthenticatorData())}catch(e){m(`getAuthenticatorData()`,e)}return{id:p,rawId:n(h),response:{attestationObject:n(g.attestationObject),clientDataJSON:n(g.clientDataJSON),transports:v,publicKeyAlgorithm:y,publicKey:b,authenticatorData:x},type:_,clientExtensionResults:d.getClientExtensionResults(),authenticatorAttachment:f(d.authenticatorAttachment)}}function m(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function h(){if(!i())return g.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?g.stubThis(new Promise(e=>e(!1))):g.stubThis(e.isConditionalMediationAvailable())}var g={stubThis:e=>e};function _({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new c({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new c({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!s(t))return new c({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new c({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new c({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function v(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:a=!1,verifyBrowserAutofillInput:s=!0}=e;if(!i())throw Error(`WebAuthn is not supported in this browser`);let c;t.allowCredentials?.length!==0&&(c=t.allowCredentials?.map(o));let l={...t,challenge:r(t.challenge),allowCredentials:c},d={};if(a){if(!await h())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&s)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');d.mediation=`conditional`,l.allowCredentials=[]}d.publicKey=l,d.signal=u.createNewAbortSignal();let p;try{p=await navigator.credentials.get(d)}catch(e){throw _({error:e,options:d})}if(!p)throw Error(`Authentication was not completed`);let{id:m,rawId:g,response:v,type:y}=p,b;return v.userHandle&&(b=n(v.userHandle)),{id:m,rawId:n(g),response:{authenticatorData:n(v.authenticatorData),clientDataJSON:n(v.clientDataJSON),signature:n(v.signature),userHandle:b},type:y,clientExtensionResults:p.getClientExtensionResults(),authenticatorAttachment:f(p.authenticatorAttachment)}}var y=e(t(),1);function b(e){return e instanceof Error&&(e.name===`NotAllowedError`||e.name===`AbortError`)}function x(){let[e,t]=(0,y.useState)(!1),n=(0,y.useRef)(0),r=(0,y.useRef)(!1),i=(0,y.useCallback)(e=>{r.current=e,t(e)},[]),a=(0,y.useCallback)(()=>{n.current++,u.cancelCeremony(),r.current=!1,t(!1)},[]),o=(0,y.useCallback)(async e=>{let t=++n.current;i(!0);try{let r=await e();return n.current===t?(i(!1),{ok:!0,value:r}):{ok:!1,canceled:!0}}catch(e){if(n.current!==t||(i(!1),b(e)))return{ok:!1,canceled:!0};throw e}},[i]);return(0,y.useEffect)(()=>()=>{r.current&&(n.current++,u.cancelCeremony())},[]),{waiting:e,run:o,cancel:a}}var S=2e3;function C(e){return{phase:`waiting`,startedAt:e,message:null}}function w(e,t){if(e.phase!==`waiting`)return e;if(t.type===`cancel`)return{...e,phase:`canceled`};if(t.now-e.startedAt>=6e5&&t.type!==`claim`)return{...e,phase:`timeout`};switch(t.type){case`tick`:return e;case`claim`:return t.result.status===`done`?{...e,phase:`done`}:t.now-e.startedAt>=6e5?{...e,phase:`timeout`}:e;case`claim_error`:return t.code===`unauthorized`||t.code===`invalid_request`?{...e,phase:`failed`,message:t.message}:e}}function T(e,t){return e.phase===`waiting`&&t}var E=`This account is not allowed to sign in to this server.`,D={enrollment_expired:"This sign-in link has expired. Links are valid for 10 minutes. Run `switchyard pair` on the server for a new one.",enrollment_used:"This sign-in link was already used. Each link signs in one browser. Run `switchyard pair` on the server for a new one.",invalid_request:`The sign-in request was rejected. Try again.`,network:`Could not reach the coordinator. Check your connection and try again.`,rate_limited:`Too many attempts. Wait a minute and try again.`,unsupported_capability:`This sign-in method is not available on this server.`,unauthorized:`That sign-in was not accepted. Try again, or use another sign-in method.`};function O(e,t){let n=t?.trim()||null;switch(e){case`forbidden`:return n??E;case`oidc_failed`:return`Single sign-on failed: ${n??`the identity provider returned an error.`}`;case`unsupported_capability`:return n??D.unsupported_capability;default:return D[e]??n??`Sign-in failed (${e}).`}}function k(e){switch(e){case`enrollment_expired`:return`Sign-in link expired`;case`enrollment_used`:return`Sign-in link already used`;case`forbidden`:return`Not allowed`;case`oidc_failed`:return`Single sign-on failed`;case`rate_limited`:return`Too many attempts`;default:return`Sign-in failed`}}function A(e=navigator.userAgent){let t=/iPhone/.test(e)?`iPhone`:/iPad/.test(e)||/Macintosh/.test(e)&&navigator.maxTouchPoints>1?`iPad`:/Android/.test(e)?`Android`:/Macintosh|Mac OS X/.test(e)?`Mac`:/Windows/.test(e)?`Windows`:/Linux/.test(e)?`Linux`:`device`;return`${/Edg\//.test(e)?`Edge`:/Firefox\/|FxiOS/.test(e)?`Firefox`:/Chrome\/|CriOS/.test(e)?`Chrome`:/Safari\//.test(e)?`Safari`:`Browser`} on ${t}`}export{k as a,C as c,p as d,i as f,O as i,x as l,S as n,w as o,A as r,T as s,D as t,v as u};
|
|
2
|
+
//# sourceMappingURL=logic-B46fwD-8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logic-B46fwD-8.js","names":["useState","useRef","useCallback","__toESM","require_react","bufferToBase64URLString","bytes","buffer","str","charCode","base64URLStringToBuffer","base64","base64URLString","padLength","padded","binary","i","browserSupportsWebAuthn","_browserSupportsWebAuthnInternals","value","toPublicKeyCredentialDescriptor","descriptor","id","isValidDomain","hostname","WebAuthnError","message","name","cause","code","identifyRegistrationError","options","publicKey","error","param","effectiveDomain","WebAuthnAbortService","abortError","newController","attachments","toAuthenticatorAttachment","attachment","startRegistration","optionsJSON","createOptions","useAutoRegister","credential","err","transports","response","responsePublicKeyAlgorithm","warnOnBrokenImplementation","responsePublicKey","_publicKey","responseAuthenticatorData","rawId","methodName","browserSupportsWebAuthnAutofill","_browserSupportsWebAuthnAutofillInternals","resolve","globalPublicKeyCredential","identifyAuthenticationError","startAuthentication","allowCredentials","getOptions","useBrowserAutofill","verifyBrowserAutofillInput","userHandle","import_react","isCanceledCeremony","usePasskeyCeremony","waiting","setWaiting","token","waitingRef","set","v","cancel","run","mine","fn","HANDOFF_POLL_MS","startHandoff","now","handoffReduce","state","event","shouldPoll","visible","GENERIC_FORBIDDEN","ERROR_TEXT","enrollErrorText","d","detail","enrollErrorTitle","defaultDeviceName","device","ua"],"sources":["../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/bufferToBase64URLString.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/base64URLStringToBuffer.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthn.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/toPublicKeyCredentialDescriptor.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/isValidDomain.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/webAuthnError.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/identifyRegistrationError.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/webAuthnAbortService.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/toAuthenticatorAttachment.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/methods/startRegistration.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/browserSupportsWebAuthnAutofill.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/helpers/identifyAuthenticationError.js","../../../../node_modules/.pnpm/@simplewebauthn+browser@14.0.0/node_modules/@simplewebauthn/browser/esm/methods/startAuthentication.js","../../src/app/passkeyCeremony.ts","../../src/features/enroll/logic.ts"],"sourcesContent":["/**\n * Convert the given array buffer into a Base64URL-encoded string. Ideal for converting various\n * credential response ArrayBuffers to string for sending back to the server as JSON.\n *\n * Helper method to compliment `base64URLStringToBuffer`\n */\nexport function bufferToBase64URLString(buffer) {\n const bytes = new Uint8Array(buffer);\n let str = '';\n for (const charCode of bytes) {\n str += String.fromCharCode(charCode);\n }\n const base64String = btoa(str);\n return base64String.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '');\n}\n","/**\n * Convert from a Base64URL-encoded string to an Array Buffer. Best used when converting a\n * credential ID from a JSON string to an ArrayBuffer, like in allowCredentials or\n * excludeCredentials\n *\n * Helper method to compliment `bufferToBase64URLString`\n */\nexport function base64URLStringToBuffer(base64URLString) {\n // Convert from Base64URL to Base64\n const base64 = base64URLString.replace(/-/g, '+').replace(/_/g, '/');\n /**\n * Pad with '=' until it's a multiple of four\n * (4 - (85 % 4 = 1) = 3) % 4 = 3 padding\n * (4 - (86 % 4 = 2) = 2) % 4 = 2 padding\n * (4 - (87 % 4 = 3) = 1) % 4 = 1 padding\n * (4 - (88 % 4 = 0) = 4) % 4 = 0 padding\n */\n const padLength = (4 - (base64.length % 4)) % 4;\n const padded = base64.padEnd(base64.length + padLength, '=');\n // Convert to a binary string\n const binary = atob(padded);\n // Convert binary string to buffer\n const buffer = new ArrayBuffer(binary.length);\n const bytes = new Uint8Array(buffer);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return buffer;\n}\n","/**\n * Determine if the browser is capable of Webauthn\n */\nexport function browserSupportsWebAuthn() {\n return _browserSupportsWebAuthnInternals.stubThis(globalThis?.PublicKeyCredential !== undefined &&\n typeof globalThis.PublicKeyCredential === 'function');\n}\n/**\n * Make it possible to stub the return value during testing\n * @ignore Don't include this in docs output\n */\nexport const _browserSupportsWebAuthnInternals = {\n stubThis: (value) => value,\n};\n","import { base64URLStringToBuffer } from './base64URLStringToBuffer.js';\nexport function toPublicKeyCredentialDescriptor(descriptor) {\n const { id } = descriptor;\n return {\n ...descriptor,\n id: base64URLStringToBuffer(id),\n transports: descriptor.transports,\n type: descriptor.type,\n };\n}\n","/**\n * A simple test to determine if a hostname is a properly-formatted domain name\n *\n * A \"valid domain\" is defined here: https://url.spec.whatwg.org/#valid-domain\n *\n * Regex was originally sourced from here, then remixed to add punycode support:\n * https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch08s15.html\n */\nexport function isValidDomain(hostname) {\n return (\n // Consider localhost valid as well since it's okay wrt Secure Contexts\n hostname === 'localhost' ||\n // Support punycode (ACE) or ascii labels and domains\n /^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(hostname));\n}\n","/**\n * A custom Error used to return a more nuanced error detailing _why_ one of the eight documented\n * errors in the spec was raised after calling `navigator.credentials.create()` or\n * `navigator.credentials.get()`:\n *\n * - `AbortError`\n * - `ConstraintError`\n * - `InvalidStateError`\n * - `NotAllowedError`\n * - `NotSupportedError`\n * - `SecurityError`\n * - `TypeError`\n * - `UnknownError`\n *\n * Error messages were determined through investigation of the spec to determine under which\n * scenarios a given error would be raised.\n */\nexport class WebAuthnError extends Error {\n constructor({ message, code, cause, name, }) {\n // @ts-ignore: help Rollup understand that `cause` is okay to set\n super(message, { cause });\n Object.defineProperty(this, \"code\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n this.name = name ?? cause.name;\n this.code = code;\n }\n}\n","import { isValidDomain } from './isValidDomain.js';\nimport { WebAuthnError } from './webAuthnError.js';\n/**\n * Attempt to intuit _why_ an error was raised after calling `navigator.credentials.create()`\n */\nexport function identifyRegistrationError({ error, options, }) {\n const { publicKey } = options;\n if (!publicKey) {\n throw Error('options was missing required publicKey property');\n }\n if (error.name === 'AbortError') {\n if (options.signal instanceof AbortSignal) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 16)\n return new WebAuthnError({\n message: 'Registration ceremony was sent an abort signal',\n code: 'ERROR_CEREMONY_ABORTED',\n cause: error,\n });\n }\n }\n else if (error.name === 'ConstraintError') {\n if (publicKey.authenticatorSelection?.requireResidentKey === true) {\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 4)\n return new WebAuthnError({\n message: 'Discoverable credentials were required but no available authenticator supported it',\n code: 'ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT',\n cause: error,\n });\n }\n else if (\n // @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024\n options.mediation === 'conditional' &&\n publicKey.authenticatorSelection?.userVerification === 'required') {\n // https://w3c.github.io/webauthn/#sctn-createCredential (Step 22.4)\n return new WebAuthnError({\n message: 'User verification was required during automatic registration but it could not be performed',\n code: 'ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE',\n cause: error,\n });\n }\n else if (publicKey.authenticatorSelection?.userVerification === 'required') {\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 5)\n return new WebAuthnError({\n message: 'User verification was required but no available authenticator supported it',\n code: 'ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT',\n cause: error,\n });\n }\n }\n else if (error.name === 'InvalidStateError') {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 20)\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 3)\n return new WebAuthnError({\n message: 'The authenticator was previously registered',\n code: 'ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED',\n cause: error,\n });\n }\n else if (error.name === 'NotAllowedError') {\n /**\n * Pass the error directly through. Platforms are overloading this error beyond what the spec\n * defines and we don't want to overwrite potentially useful error messages.\n */\n return new WebAuthnError({\n message: error.message,\n code: 'ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY',\n cause: error,\n });\n }\n else if (error.name === 'NotSupportedError') {\n const validPubKeyCredParams = publicKey.pubKeyCredParams.filter((param) => param.type === 'public-key');\n if (validPubKeyCredParams.length === 0) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 10)\n return new WebAuthnError({\n message: 'No entry in pubKeyCredParams was of type \"public-key\"',\n code: 'ERROR_MALFORMED_PUBKEYCREDPARAMS',\n cause: error,\n });\n }\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 2)\n return new WebAuthnError({\n message: 'No available authenticator supported any of the specified pubKeyCredParams algorithms',\n code: 'ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG',\n cause: error,\n });\n }\n else if (error.name === 'SecurityError') {\n const effectiveDomain = globalThis.location.hostname;\n if (!isValidDomain(effectiveDomain)) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 7)\n return new WebAuthnError({\n message: `${globalThis.location.hostname} is an invalid domain`,\n code: 'ERROR_INVALID_DOMAIN',\n cause: error,\n });\n }\n else if (publicKey.rp.id !== effectiveDomain) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 8)\n return new WebAuthnError({\n message: `The RP ID \"${publicKey.rp.id}\" is invalid for this domain`,\n code: 'ERROR_INVALID_RP_ID',\n cause: error,\n });\n }\n }\n else if (error.name === 'TypeError') {\n if (publicKey.user.id.byteLength < 1 || publicKey.user.id.byteLength > 64) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 5)\n return new WebAuthnError({\n message: 'User ID was not between 1 and 64 characters',\n code: 'ERROR_INVALID_USER_ID_LENGTH',\n cause: error,\n });\n }\n }\n else if (error.name === 'UnknownError') {\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 1)\n // https://www.w3.org/TR/webauthn-2/#sctn-op-make-cred (Step 8)\n return new WebAuthnError({\n message: 'The authenticator was unable to process the specified options, or could not create a new credential',\n code: 'ERROR_AUTHENTICATOR_GENERAL_ERROR',\n cause: error,\n });\n }\n return error;\n}\n","class BaseWebAuthnAbortService {\n constructor() {\n Object.defineProperty(this, \"controller\", {\n enumerable: true,\n configurable: true,\n writable: true,\n value: void 0\n });\n }\n createNewAbortSignal() {\n // Abort any existing calls to navigator.credentials.create() or navigator.credentials.get()\n if (this.controller) {\n const abortError = new Error('Cancelling existing WebAuthn API call for new one');\n abortError.name = 'AbortError';\n this.controller.abort(abortError);\n }\n const newController = new AbortController();\n this.controller = newController;\n return newController.signal;\n }\n cancelCeremony() {\n if (this.controller) {\n const abortError = new Error('Manually cancelling existing WebAuthn API call');\n abortError.name = 'AbortError';\n this.controller.abort(abortError);\n this.controller = undefined;\n }\n }\n}\n/**\n * A service singleton to help ensure that only a single WebAuthn ceremony is active at a time.\n *\n * Users of **@simplewebauthn/browser** shouldn't typically need to use this, but it can help e.g.\n * developers building projects that use client-side routing to better control the behavior of\n * their UX in response to router navigation events.\n */\nexport const WebAuthnAbortService = new BaseWebAuthnAbortService();\n","const attachments = ['cross-platform', 'platform'];\n/**\n * If possible coerce a `string` value into a known `AuthenticatorAttachment`\n */\nexport function toAuthenticatorAttachment(attachment) {\n if (!attachment) {\n return;\n }\n if (attachments.indexOf(attachment) < 0) {\n return;\n }\n return attachment;\n}\n","import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString.js';\nimport { base64URLStringToBuffer } from '../helpers/base64URLStringToBuffer.js';\nimport { browserSupportsWebAuthn } from '../helpers/browserSupportsWebAuthn.js';\nimport { toPublicKeyCredentialDescriptor } from '../helpers/toPublicKeyCredentialDescriptor.js';\nimport { identifyRegistrationError } from '../helpers/identifyRegistrationError.js';\nimport { WebAuthnAbortService } from '../helpers/webAuthnAbortService.js';\nimport { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment.js';\n/**\n * Begin authenticator \"registration\" via WebAuthn attestation\n *\n * @param optionsJSON Output from **@simplewebauthn/server**'s `generateRegistrationOptions()`\n * @param useAutoRegister (Optional) Try to silently create a passkey with the password manager that the user just signed in with. Defaults to `false`.\n */\nexport async function startRegistration(options) {\n // @ts-ignore: Intentionally check for old call structure to warn about improper API call\n if (!options.optionsJSON && options.challenge) {\n console.warn('startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.');\n // @ts-ignore: Reassign the options, passed in as a positional argument, to the expected variable\n options = { optionsJSON: options };\n }\n const { optionsJSON, useAutoRegister = false } = options;\n if (!browserSupportsWebAuthn()) {\n throw new Error('WebAuthn is not supported in this browser');\n }\n // We need to convert some values to Uint8Arrays before passing the credentials to the navigator\n const publicKey = {\n ...optionsJSON,\n challenge: base64URLStringToBuffer(optionsJSON.challenge),\n user: {\n ...optionsJSON.user,\n id: base64URLStringToBuffer(optionsJSON.user.id),\n },\n excludeCredentials: optionsJSON.excludeCredentials?.map(toPublicKeyCredentialDescriptor),\n };\n // Prepare options for `.create()`\n const createOptions = {};\n /**\n * Try to use conditional create to register a passkey for the user with the password manager\n * the user just used to authenticate with. The user won't be shown any prominent UI by the\n * browser.\n */\n if (useAutoRegister) {\n // @ts-ignore: `mediation` doesn't yet exist on CredentialCreationOptions but it's possible as of Sept 2024\n createOptions.mediation = 'conditional';\n }\n // Finalize options\n createOptions.publicKey = publicKey;\n // Set up the ability to cancel this request if the user attempts another\n createOptions.signal = WebAuthnAbortService.createNewAbortSignal();\n // Wait for the user to complete attestation\n let credential;\n try {\n credential = (await navigator.credentials.create(\n // TODO: Newer versions of Deno require this casting, revisit once we're using Deno 2.6+\n createOptions));\n }\n catch (err) {\n throw identifyRegistrationError({ error: err, options: createOptions });\n }\n if (!credential) {\n throw new Error('Registration was not completed');\n }\n const { id, rawId, response, type } = credential;\n // Continue to play it safe with `getTransports()` for now, even when L3 types say it's required\n let transports = undefined;\n if (typeof response.getTransports === 'function') {\n transports = response.getTransports();\n }\n // L3 says this is required, but browser and webview support are still not guaranteed.\n let responsePublicKeyAlgorithm = undefined;\n if (typeof response.getPublicKeyAlgorithm === 'function') {\n try {\n responsePublicKeyAlgorithm = response.getPublicKeyAlgorithm();\n }\n catch (error) {\n warnOnBrokenImplementation('getPublicKeyAlgorithm()', error);\n }\n }\n let responsePublicKey = undefined;\n if (typeof response.getPublicKey === 'function') {\n try {\n const _publicKey = response.getPublicKey();\n if (_publicKey !== null) {\n responsePublicKey = bufferToBase64URLString(_publicKey);\n }\n }\n catch (error) {\n warnOnBrokenImplementation('getPublicKey()', error);\n }\n }\n // L3 says this is required, but browser and webview support are still not guaranteed.\n let responseAuthenticatorData;\n if (typeof response.getAuthenticatorData === 'function') {\n try {\n responseAuthenticatorData = bufferToBase64URLString(response.getAuthenticatorData());\n }\n catch (error) {\n warnOnBrokenImplementation('getAuthenticatorData()', error);\n }\n }\n return {\n id,\n rawId: bufferToBase64URLString(rawId),\n response: {\n attestationObject: bufferToBase64URLString(response.attestationObject),\n clientDataJSON: bufferToBase64URLString(response.clientDataJSON),\n transports,\n publicKeyAlgorithm: responsePublicKeyAlgorithm,\n publicKey: responsePublicKey,\n authenticatorData: responseAuthenticatorData,\n },\n type,\n clientExtensionResults: credential.getClientExtensionResults(),\n authenticatorAttachment: toAuthenticatorAttachment(credential.authenticatorAttachment),\n };\n}\n/**\n * Visibly warn when we detect an issue related to a passkey provider intercepting WebAuthn API\n * calls\n */\nfunction warnOnBrokenImplementation(methodName, cause) {\n console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${methodName}. You should report this error to them.\\n`, cause);\n}\n","import { browserSupportsWebAuthn } from './browserSupportsWebAuthn.js';\n/**\n * Determine if the browser supports conditional UI, so that WebAuthn credentials can\n * be shown to the user in the browser's typical password autofill popup.\n */\nexport function browserSupportsWebAuthnAutofill() {\n if (!browserSupportsWebAuthn()) {\n return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));\n }\n /**\n * I don't like the `as unknown` here but there's a `declare var PublicKeyCredential` in\n * TS' DOM lib that's making it difficult for me to just go `as PublicKeyCredentialFuture` as I\n * want. I think I'm fine with this for now since it's _supposed_ to be temporary, until TS types\n * have a chance to catch up.\n */\n const globalPublicKeyCredential = globalThis\n .PublicKeyCredential;\n if (globalPublicKeyCredential?.isConditionalMediationAvailable === undefined) {\n return _browserSupportsWebAuthnAutofillInternals.stubThis(new Promise((resolve) => resolve(false)));\n }\n return _browserSupportsWebAuthnAutofillInternals.stubThis(globalPublicKeyCredential.isConditionalMediationAvailable());\n}\n// Make it possible to stub the return value during testing\nexport const _browserSupportsWebAuthnAutofillInternals = {\n stubThis: (value) => value,\n};\n","import { isValidDomain } from './isValidDomain.js';\nimport { WebAuthnError } from './webAuthnError.js';\n/**\n * Attempt to intuit _why_ an error was raised after calling `navigator.credentials.get()`\n */\nexport function identifyAuthenticationError({ error, options, }) {\n const { publicKey } = options;\n if (!publicKey) {\n throw Error('options was missing required publicKey property');\n }\n if (error.name === 'AbortError') {\n if (options.signal instanceof AbortSignal) {\n // https://www.w3.org/TR/webauthn-2/#sctn-createCredential (Step 16)\n return new WebAuthnError({\n message: 'Authentication ceremony was sent an abort signal',\n code: 'ERROR_CEREMONY_ABORTED',\n cause: error,\n });\n }\n }\n else if (error.name === 'NotAllowedError') {\n /**\n * Pass the error directly through. Platforms are overloading this error beyond what the spec\n * defines and we don't want to overwrite potentially useful error messages.\n */\n return new WebAuthnError({\n message: error.message,\n code: 'ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY',\n cause: error,\n });\n }\n else if (error.name === 'SecurityError') {\n const effectiveDomain = globalThis.location.hostname;\n if (!isValidDomain(effectiveDomain)) {\n // https://www.w3.org/TR/webauthn-2/#sctn-discover-from-external-source (Step 5)\n return new WebAuthnError({\n message: `${globalThis.location.hostname} is an invalid domain`,\n code: 'ERROR_INVALID_DOMAIN',\n cause: error,\n });\n }\n else if (publicKey.rpId !== effectiveDomain) {\n // https://www.w3.org/TR/webauthn-2/#sctn-discover-from-external-source (Step 6)\n return new WebAuthnError({\n message: `The RP ID \"${publicKey.rpId}\" is invalid for this domain`,\n code: 'ERROR_INVALID_RP_ID',\n cause: error,\n });\n }\n }\n else if (error.name === 'UnknownError') {\n // https://www.w3.org/TR/webauthn-2/#sctn-op-get-assertion (Step 1)\n // https://www.w3.org/TR/webauthn-2/#sctn-op-get-assertion (Step 12)\n return new WebAuthnError({\n message: 'The authenticator was unable to process the specified options, or could not create a new assertion signature',\n code: 'ERROR_AUTHENTICATOR_GENERAL_ERROR',\n cause: error,\n });\n }\n return error;\n}\n","import { bufferToBase64URLString } from '../helpers/bufferToBase64URLString.js';\nimport { base64URLStringToBuffer } from '../helpers/base64URLStringToBuffer.js';\nimport { browserSupportsWebAuthn } from '../helpers/browserSupportsWebAuthn.js';\nimport { browserSupportsWebAuthnAutofill } from '../helpers/browserSupportsWebAuthnAutofill.js';\nimport { toPublicKeyCredentialDescriptor } from '../helpers/toPublicKeyCredentialDescriptor.js';\nimport { identifyAuthenticationError } from '../helpers/identifyAuthenticationError.js';\nimport { WebAuthnAbortService } from '../helpers/webAuthnAbortService.js';\nimport { toAuthenticatorAttachment } from '../helpers/toAuthenticatorAttachment.js';\n/**\n * Begin authenticator \"login\" via WebAuthn assertion\n *\n * @param optionsJSON Output from **@simplewebauthn/server**'s `generateAuthenticationOptions()`\n * @param useBrowserAutofill (Optional) Initialize conditional UI to enable logging in via browser autofill prompts. Defaults to `false`.\n * @param verifyBrowserAutofillInput (Optional) Ensure a suitable `<input>` element is present when `useBrowserAutofill` is `true`. Defaults to `true`.\n */\nexport async function startAuthentication(options) {\n // @ts-ignore: Intentionally check for old call structure to warn about improper API call\n if (!options.optionsJSON && options.challenge) {\n console.warn('startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.');\n // @ts-ignore: Reassign the options, passed in as a positional argument, to the expected variable\n options = { optionsJSON: options };\n }\n const { optionsJSON, useBrowserAutofill = false, verifyBrowserAutofillInput = true, } = options;\n if (!browserSupportsWebAuthn()) {\n throw new Error('WebAuthn is not supported in this browser');\n }\n // We need to avoid passing empty array to avoid blocking retrieval\n // of public key\n let allowCredentials;\n if (optionsJSON.allowCredentials?.length !== 0) {\n allowCredentials = optionsJSON.allowCredentials?.map(toPublicKeyCredentialDescriptor);\n }\n // We need to convert some values to Uint8Arrays before passing the credentials to the navigator\n const publicKey = {\n ...optionsJSON,\n challenge: base64URLStringToBuffer(optionsJSON.challenge),\n allowCredentials,\n };\n // Prepare options for `.get()`\n const getOptions = {};\n /**\n * Set up the page to prompt the user to select a credential for authentication via the browser's\n * input autofill mechanism.\n */\n if (useBrowserAutofill) {\n if (!(await browserSupportsWebAuthnAutofill())) {\n throw Error('Browser does not support WebAuthn autofill');\n }\n // Check for an <input> with \"webauthn\" in its `autocomplete` attribute\n const eligibleInputs = document.querySelectorAll(\"input[autocomplete$='webauthn']\");\n // WebAuthn autofill requires at least one valid input\n if (eligibleInputs.length < 1 && verifyBrowserAutofillInput) {\n throw Error('No <input> with \"webauthn\" as the only or last value in its `autocomplete` attribute was detected');\n }\n // `CredentialMediationRequirement` doesn't know about \"conditional\" yet as of\n // typescript@4.6.3\n getOptions.mediation = 'conditional';\n // Conditional UI requires an empty allow list\n publicKey.allowCredentials = [];\n }\n // Finalize options\n getOptions.publicKey = publicKey;\n // Set up the ability to cancel this request if the user attempts another\n getOptions.signal = WebAuthnAbortService.createNewAbortSignal();\n // Wait for the user to complete assertion\n let credential;\n try {\n credential = (await navigator.credentials.get(\n // TODO: Newer versions of Deno require this casting, revisit once we're using Deno 2.6+\n getOptions));\n }\n catch (err) {\n throw identifyAuthenticationError({ error: err, options: getOptions });\n }\n if (!credential) {\n throw new Error('Authentication was not completed');\n }\n const { id, rawId, response, type } = credential;\n let userHandle = undefined;\n if (response.userHandle) {\n userHandle = bufferToBase64URLString(response.userHandle);\n }\n // Convert values to base64 to make it easier to send back to the server\n return {\n id,\n rawId: bufferToBase64URLString(rawId),\n response: {\n authenticatorData: bufferToBase64URLString(response.authenticatorData),\n clientDataJSON: bufferToBase64URLString(response.clientDataJSON),\n signature: bufferToBase64URLString(response.signature),\n userHandle,\n },\n type,\n clientExtensionResults: credential.getClientExtensionResults(),\n authenticatorAttachment: toAuthenticatorAttachment(credential.authenticatorAttachment),\n };\n}\n","import { WebAuthnAbortService } from \"@simplewebauthn/browser\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\n/** A dismissed or aborted passkey prompt. */\nexport function isCanceledCeremony(err: unknown): boolean {\n return err instanceof Error && (err.name === \"NotAllowedError\" || err.name === \"AbortError\");\n}\n\n/**\n * Runs a WebAuthn ceremony the user can cancel at once. Some authenticator UIs never reject when\n * their popup closes, so Cancel does not wait for the browser: it resets and ignores the late result.\n */\nexport function usePasskeyCeremony() {\n const [waiting, setWaiting] = useState(false);\n const token = useRef(0);\n const waitingRef = useRef(false);\n\n const set = useCallback((v: boolean) => {\n waitingRef.current = v;\n setWaiting(v);\n }, []);\n\n const cancel = useCallback(() => {\n token.current++;\n WebAuthnAbortService.cancelCeremony();\n waitingRef.current = false;\n setWaiting(false);\n }, []);\n\n const run = useCallback(\n async <T>(\n fn: () => Promise<T>,\n ): Promise<{ ok: true; value: T } | { ok: false; canceled: true }> => {\n const mine = ++token.current;\n set(true);\n try {\n const value = await fn();\n if (token.current !== mine) return { ok: false, canceled: true };\n set(false);\n return { ok: true, value };\n } catch (err) {\n if (token.current !== mine) return { ok: false, canceled: true };\n set(false);\n if (isCanceledCeremony(err)) return { ok: false, canceled: true };\n throw err;\n }\n },\n [set],\n );\n\n useEffect(\n () => () => {\n if (waitingRef.current) {\n token.current++;\n WebAuthnAbortService.cancelCeremony();\n }\n },\n [],\n );\n\n return { waiting, run, cancel };\n}\n","import type { OidcClaimResponse } from \"@switchyard/protocol\";\n\n/** How often the PWA polls `POST /api/auth/oidc/claim` while the screen is visible. */\nexport const HANDOFF_POLL_MS = 2000;\n/** How long a handoff waits before giving up (the coordinator flow lives 10 minutes). */\nexport const HANDOFF_TIMEOUT_MS = 10 * 60 * 1000;\n\nexport type HandoffPhase = \"waiting\" | \"done\" | \"timeout\" | \"failed\" | \"canceled\";\n\nexport interface HandoffState {\n phase: HandoffPhase;\n startedAt: number;\n /** Set when `phase` is `failed`. */\n message: string | null;\n}\n\nexport type HandoffEvent =\n | { type: \"claim\"; result: OidcClaimResponse; now: number }\n | { type: \"claim_error\"; code: string; message: string; now: number }\n | { type: \"tick\"; now: number }\n | { type: \"cancel\" };\n\nexport function startHandoff(now: number): HandoffState {\n return { phase: \"waiting\", startedAt: now, message: null };\n}\n\n/**\n * Pure state machine for the PWA single sign-on handoff. Terminal phases\n * never change. A transient error (network, server hiccup) keeps waiting;\n * an expired or unknown flow (`unauthorized`, `invalid_request`) fails.\n */\nexport function handoffReduce(state: HandoffState, event: HandoffEvent): HandoffState {\n if (state.phase !== \"waiting\") return state;\n if (event.type === \"cancel\") return { ...state, phase: \"canceled\" };\n if (event.now - state.startedAt >= HANDOFF_TIMEOUT_MS && event.type !== \"claim\") {\n return { ...state, phase: \"timeout\" };\n }\n switch (event.type) {\n case \"tick\":\n return state;\n case \"claim\":\n if (event.result.status === \"done\") return { ...state, phase: \"done\" };\n return event.now - state.startedAt >= HANDOFF_TIMEOUT_MS\n ? { ...state, phase: \"timeout\" }\n : state;\n case \"claim_error\":\n if (event.code === \"unauthorized\" || event.code === \"invalid_request\") {\n return { ...state, phase: \"failed\", message: event.message };\n }\n return state;\n }\n}\n\n/** Whether a poll should run now: still waiting and the page is visible. */\nexport function shouldPoll(state: HandoffState, visible: boolean): boolean {\n return state.phase === \"waiting\" && visible;\n}\n\nconst GENERIC_FORBIDDEN = \"This account is not allowed to sign in to this server.\";\n\n/** Static texts for coordinator error codes shown on /sign-in. */\nexport const ERROR_TEXT: Record<string, string> = {\n enrollment_expired:\n \"This sign-in link has expired. Links are valid for 10 minutes. Run `switchyard pair` on the server for a new one.\",\n enrollment_used:\n \"This sign-in link was already used. Each link signs in one browser. Run `switchyard pair` on the server for a new one.\",\n invalid_request: \"The sign-in request was rejected. Try again.\",\n network: \"Could not reach the coordinator. Check your connection and try again.\",\n rate_limited: \"Too many attempts. Wait a minute and try again.\",\n unsupported_capability: \"This sign-in method is not available on this server.\",\n unauthorized: \"That sign-in was not accepted. Try again, or use another sign-in method.\",\n};\n\n/**\n * Message for an error code, with the coordinator's `detail` where it is the\n * useful part (`/sign-in?error=forbidden&detail=Signed in as ...`).\n */\nexport function enrollErrorText(code: string, detail?: string | null): string {\n const d = detail?.trim() || null;\n switch (code) {\n case \"forbidden\":\n return d ?? GENERIC_FORBIDDEN;\n case \"oidc_failed\":\n return `Single sign-on failed: ${d ?? \"the identity provider returned an error.\"}`;\n case \"unsupported_capability\":\n return d ?? (ERROR_TEXT.unsupported_capability as string);\n default:\n return ERROR_TEXT[code] ?? d ?? `Sign-in failed (${code}).`;\n }\n}\n\n/** Short heading for an error alert. */\nexport function enrollErrorTitle(code: string): string {\n switch (code) {\n case \"enrollment_expired\":\n return \"Sign-in link expired\";\n case \"enrollment_used\":\n return \"Sign-in link already used\";\n case \"forbidden\":\n return \"Not allowed\";\n case \"oidc_failed\":\n return \"Single sign-on failed\";\n case \"rate_limited\":\n return \"Too many attempts\";\n default:\n return \"Sign-in failed\";\n }\n}\n\n/** A readable default device name from the user agent, e.g. \"Safari on iPhone\". */\nexport function defaultDeviceName(ua: string = navigator.userAgent): string {\n const device = /iPhone/.test(ua)\n ? \"iPhone\"\n : /iPad/.test(ua) || (/Macintosh/.test(ua) && navigator.maxTouchPoints > 1)\n ? \"iPad\"\n : /Android/.test(ua)\n ? \"Android\"\n : /Macintosh|Mac OS X/.test(ua)\n ? \"Mac\"\n : /Windows/.test(ua)\n ? \"Windows\"\n : /Linux/.test(ua)\n ? \"Linux\"\n : \"device\";\n const browser = /Edg\\//.test(ua)\n ? \"Edge\"\n : /Firefox\\/|FxiOS/.test(ua)\n ? \"Firefox\"\n : /Chrome\\/|CriOS/.test(ua)\n ? \"Chrome\"\n : /Safari\\//.test(ua)\n ? \"Safari\"\n : \"Browser\";\n return `${browser} on ${device}`;\n}\n"],"ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12],"mappings":"A,qDAMA,SAAgBK,EAAwB,EAAQ,CAC5C,IAAMC,EAAQ,IAAI,WAAWC,CAAM,EAC/BC,EAAM,GACV,IAAK,IAAMC,KAAYH,EACnB,GAAO,OAAO,aAAaG,CAAQ,EAGvC,OADqB,KAAKD,CACR,CAAC,CAAC,QAAQ,MAAO,GAAG,CAAC,CAAC,QAAQ,MAAO,GAAG,CAAC,CAAC,QAAQ,KAAM,EAAE,CAChF,CCPA,SAAgBE,EAAwB,EAAiB,CAErD,IAAMC,EAASC,EAAgB,QAAQ,KAAM,GAAG,CAAC,CAAC,QAAQ,KAAM,GAAG,EAQ7DC,GAAa,EAAKF,EAAO,OAAS,GAAM,EACxCG,EAASH,EAAO,OAAOA,EAAO,OAASE,EAAW,G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EAAa,UAAU,UAAmB,CAC1E,IAAMC,EAAS,SAAS,KAAKC,CAAE,EAC3B,SACA,OAAO,KAAKA,CAAE,GAAM,YAAY,KAAKA,CAAE,GAAK,UAAU,eAAiB,EACrE,OACA,UAAU,KAAKA,CAAE,EACf,UACA,qBAAqB,KAAKA,CAAE,EAC1B,MACA,UAAU,KAAKA,CAAE,EACf,UACA,QAAQ,KAAKA,CAAE,EACb,QACA,SAUd,MAAO,GATS,QAAQ,KAAKA,CAAE,EAC3B,OACA,kBAAkB,KAAKA,CAAE,EACvB,UACA,iBAAiB,KAAKA,CAAE,EACtB,SACA,WAAW,KAAKA,CAAE,EAChB,SACA,UACQ,MAAMD,GAC1B,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{i as e,t}from"./jsx-runtime-D13aM9HY.js";import{t as n}from"./chevron-right-evVLS6hq.js";import{L as r,M as i,P as a}from"./index-hxvDvCS7.js";var o=t(),s=[{to:`/queue`,label:`Queue`,description:`Running and queued runs`,icon:a},{to:`/automations`,label:`Automations`,description:`Schedules, webhooks and history`,icon:i},{to:`/settings`,label:`Settings`,description:`Hosts, devices, projects, notifications`,icon:r}];function c(){return(0,o.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col gap-3 px-4 pb-4 safe-pt-4`,children:[(0,o.jsx)(`h1`,{className:`text-lg font-semibold`,children:`More`}),(0,o.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:s.map(({to:t,label:r,description:i,icon:a})=>(0,o.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,o.jsxs)(e,{to:t,className:`tap flex min-h-14 items-center gap-3 px-4 py-2 hover:bg-surface-2`,children:[(0,o.jsx)(a,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,o.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,o.jsx)(`span`,{className:`block font-medium`,children:r}),(0,o.jsx)(`span`,{className:`block truncate text-sm text-muted`,children:i})]}),(0,o.jsx)(n,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})},t))})]})}export{c as default};
|
|
2
|
+
//# sourceMappingURL=more-DQR5uu1c.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"more-DQR5uu1c.js","names":["Link","ChevronRight","Settings","Workflow","Timer","import_jsx_runtime","require_jsx_runtime","ITEMS","MoreView","Icon","label","description","to"],"sources":["../../src/features/more/index.tsx"],"sourcesContent":["import { ChevronRight, type LucideIcon, Settings, Timer, Workflow } from \"lucide-react\";\nimport { Link } from \"react-router\";\n\nconst ITEMS: { to: string; label: string; description: string; icon: LucideIcon }[] = [\n { to: \"/queue\", label: \"Queue\", description: \"Running and queued runs\", icon: Timer },\n {\n to: \"/automations\",\n label: \"Automations\",\n description: \"Schedules, webhooks and history\",\n icon: Workflow,\n },\n {\n to: \"/settings\",\n label: \"Settings\",\n description: \"Hosts, devices, projects, notifications\",\n icon: Settings,\n },\n];\n\n/** Mobile \"More\": Queue, Automations and Settings (spec 10). */\nexport default function MoreView() {\n return (\n <div className=\"mx-auto flex w-full max-w-xl flex-col gap-3 px-4 pb-4 safe-pt-4\">\n <h1 className=\"text-lg font-semibold\">More</h1>\n <ul className=\"overflow-hidden rounded-lg border border-border bg-surface\">\n {ITEMS.map(({ to, label, description, icon: Icon }) => (\n <li key={to} className=\"border-b border-border last:border-b-0\">\n <Link\n to={to}\n className=\"tap flex min-h-14 items-center gap-3 px-4 py-2 hover:bg-surface-2\"\n >\n <Icon aria-hidden className=\"size-5 shrink-0 text-muted\" />\n <span className=\"min-w-0 flex-1\">\n <span className=\"block font-medium\">{label}</span>\n <span className=\"block truncate text-sm text-muted\">{description}</span>\n </span>\n <ChevronRight aria-hidden className=\"size-4 shrink-0 text-subtle\" />\n </Link>\n </li>\n ))}\n </ul>\n </div>\n );\n}\n"],"mappings":"A,gKAGMO,EAAgF,CACpF,CAAE,GAAI,SAAU,MAAO,QAAS,YAAa,0BAA2B,KAAMH,CAAM,EACpF,CACE,GAAI,eACJ,MAAO,cACP,YAAa,kCACb,KAAMD,CACR,EACA,CACE,GAAI,YACJ,MAAO,WACP,YAAa,0CACb,KAAMD,CACR,CACF,EAGA,SAAwBM,GAAW,CACjC,OACE,EAAAH,EAAA,KAAA,CAAC,MAAD,CAAK,UAAU,kEAAf,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,KAAD,CAAI,UAAU,wBAAwB,SAAA,MAAQ,CAAA,GAC9C,EAAAA,EAAA,IAAA,CAAC,KAAD,CAAI,UAAU,6DACX,SAAAE,EAAM,KAAK,CAAE,KAAI,QAAO,cAAa,KAAME,MAC1C,EAAAJ,EAAA,IAAA,CAAC,KAAD,CAAa,UAAU,yCACrB,UAAA,EAAAA,EAAA,KAAA,CAACL,EAAD,CACM,KACJ,UAAU,oEAFZ,SAAA,EAIE,EAAAK,EAAA,IAAA,CAACI,EAAD,CAAM,cAAA,GAAY,UAAU,4BAA8B,CAAA,GAC1D,EAAAJ,EAAA,KAAA,CAAC,OAAD,CAAM,UAAU,iBAAhB,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,oBAAqB,SAAAK,CAAY,CAAA,GACjD,EAAAL,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,oCAAqC,SAAAM,CAAkB,CAAA,CACnE,C,IACN,EAAAN,EAAA,IAAA,CAACJ,EAAD,CAAc,cAAA,GAAY,UAAU,6BAA+B,CAAA,CAC/D,C,EACJ,EAZKW,CAYL,CACL,CACC,CAAA,CACD,C,EAET,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{_ as e,i as t,m as n,n as r,t as i}from"./jsx-runtime-D13aM9HY.js";import{bt as a,c as o,f as s,h as c,i as l,lt as u,n as d,p as f,r as p,s as m,t as h,u as g,v as _,w as v,yt as y,z as b}from"./states-ZhrxQa3K.js";import{t as x}from"./calendar-clock-B8zE4JsX.js";import{r as S}from"./Priority-CHmzfoHg.js";import{t as C}from"./external-link-3jjTxo92.js";import{I as w,a as T,m as E,t as D,v as O}from"./useNow-Dj7oEiwn.js";import{t as k}from"./link-2-CaMlUDRG.js";import{N as A,P as j,R as M,T as N,X as P,b as F,c as I,q as L}from"./index-hxvDvCS7.js";var R={name:`folder-lock`,size:24,node:[[`rect`,{width:`8`,height:`5`,x:`14`,y:`17`,rx:`1`,key:`19aais`}],[`path`,{d:`M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5`,key:`1w6v7t`}],[`path`,{d:`M20 17v-2a2 2 0 1 0-4 0v2`,key:`pwaxnr`}]]};R.node;var z=r(R),B={name:`gauge`,size:24,node:[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]};B.node;var V=r(B),H={name:`power-off`,size:24,node:[[`path`,{d:`M18.36 6.64A9 9 0 0 1 20.77 15`,key:`dxknvb`}],[`path`,{d:`M6.16 6.16a9 9 0 1 0 12.68 12.68`,key:`1x7qb5`}],[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};H.node;var U=r(H),W={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};W.node;var G=r(W),K=e(n(),1),q=i(),J={dependency:k,host_offline:A,project_limit:V,workspace_occupied:z,scheduled_time:x,invalid_configuration:_,dispatch_paused:L,project_automation_disabled:U,not_ready:v,already_dispatched:M,retry_backoff:G};function Y(){let e=D(),t=b(e=>e.tasks),n=b(e=>e.runs),r=b(e=>e.hydrated),i=a(e.error)&&e.error.status===404,s=!!e.data&&(!Array.isArray(e.data.running)||!Array.isArray(e.data.queued)),c=(0,K.useMemo)(()=>e.data&&!s?e.data.running.map(e=>({taskId:e.taskId,runId:e.runId,sessionId:e.sessionId})):Object.values(n).filter(e=>O(e)&&e.state!==`queued`).map(e=>({taskId:e.taskId,runId:e.id,sessionId:e.sessionId})),[e.data,n,s]),l=(0,K.useMemo)(()=>e.data&&!s?e.data.queued.map(e=>({taskId:e.taskId,eligibility:e.eligibility})):Object.values(t).filter(e=>e.state===`ready`&&!e.hiddenFromBoard).sort((e,t)=>e.priority-t.priority||e.position-t.position).map(e=>({taskId:e.id,eligibility:void 0})),[e.data,t,s]),u=!e.data&&e.loading&&!e.error||!r,f=!!e.error&&!i&&!e.data;return s?(0,q.jsx)(p,{title:`The coordinator sent a queue this version cannot read`,error:`GET /api/now returned an unexpected shape. Check that the web app and coordinator versions match.`}):(0,q.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-4 px-4 pb-4 safe-pt-4 md:px-6`,children:[(0,q.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3`,children:[(0,q.jsx)(`h1`,{className:`flex-1 text-lg font-semibold`,children:`Queue`}),(0,q.jsx)(T,{})]}),(0,q.jsx)(`p`,{className:`text-sm text-muted`,children:`Pausing stops new work from starting. Runs already in progress keep going.`}),(0,q.jsx)(m,{subject:`queue`,show:!!e.data}),i&&(0,q.jsx)(g,{capability:`Queue explanations`,reason:`This coordinator does not report why queued tasks are waiting. The list below comes from local data.`}),e.error!=null&&!i&&(0,q.jsx)(d,{compact:!0,title:`Could not refresh running and queued work`,error:y(e.error),onRetry:e.reload}),u?(0,q.jsx)(o,{label:`Loading running and queued work…`}):f&&c.length===0&&l.length===0?null:c.length===0&&l.length===0?(0,q.jsx)(h,{icon:(0,q.jsx)(j,{className:`size-8`}),title:`Nothing running or queued`,description:`Move a task to Ready on the board and the dispatcher starts it when it is eligible.`,action:{label:`Go to Board`,to:I.board}}):(0,q.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-4 xl:grid-cols-2 xl:items-start`,children:[(0,q.jsxs)(`section`,{"aria-labelledby":`now-running`,className:`flex min-w-0 flex-col gap-2`,children:[(0,q.jsxs)(`h2`,{id:`now-running`,className:`text-base font-semibold`,children:[`Running `,(0,q.jsxs)(`span`,{className:`text-sm font-normal text-muted`,children:[`(`,c.length,`)`]})]}),c.length===0?(0,q.jsx)(`p`,{className:`text-sm text-muted`,children:`Nothing is running.`}):(0,q.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:c.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsx)(X,{taskId:e.taskId,runId:e.runId,sessionId:e.sessionId})},e.runId))})]}),(0,q.jsxs)(`section`,{"aria-labelledby":`now-queued`,className:`flex min-w-0 flex-col gap-2`,children:[(0,q.jsxs)(`h2`,{id:`now-queued`,className:`text-base font-semibold`,children:[`Queued `,(0,q.jsxs)(`span`,{className:`text-sm font-normal text-muted`,children:[`(`,l.length,`)`]})]}),l.length===0?(0,q.jsx)(`p`,{className:`text-sm text-muted`,children:`No Ready tasks are waiting.`}):(0,q.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:l.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsx)(Z,{task:t[e.taskId],taskId:e.taskId,eligibility:e.eligibility})},e.taskId))})]})]})]})}function X({taskId:e,runId:n,sessionId:r}){let i=b(t=>t.tasks[e]),a=b(e=>e.runs[n]),o=b(e=>a?.hostId?e.hosts[a.hostId]:void 0),u=b(e=>i?e.projects[i.projectId]:void 0),d=!!o&&o.connectivity!==`connected`;return(0,q.jsxs)(`article`,{className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-start gap-2`,children:[a?(0,q.jsx)(N,{kind:`run`,value:a.state,size:`sm`}):(0,q.jsx)(N,{kind:`task`,value:`in_progress`,size:`sm`}),(0,q.jsx)(t,{to:I.task(e),className:`min-w-0 flex-1 basis-48 font-medium break-words hover:underline`,children:i?.title??`Task`}),(r??i?.sessionId)&&(0,q.jsxs)(t,{to:I.session(r??i?.sessionId),className:s(`secondary`,`sm`),children:[(0,q.jsx)(C,{"aria-hidden":!0,className:`size-3.5`}),`Open session`]})]}),(0,q.jsx)(`p`,{className:`text-xs text-muted`,children:[u?.name,o?`on ${o.name}`:null,a?.attempt&&a.attempt>1?`attempt ${a.attempt}`:null,a?.startedAt?`started ${c(a.startedAt)}`:null,a?.controlMode===`human`?`you have control`:`automation`].filter(Boolean).join(` · `)}),a?.state===`uncertain`&&o&&(0,q.jsx)(`p`,{className:`text-sm text-warning`,children:(0,q.jsxs)(`span`,{className:`text-text`,children:[`Waiting for host `,o.name,` to confirm launch. It is never started elsewhere.`]})}),d&&o&&(0,q.jsx)(l,{compact:!0,hostName:o.name,connectivity:o.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:o.lastSeenAt})]})}function Z({task:e,taskId:n,eligibility:r}){let i=b(t=>e?t.projects[e.projectId]:void 0),[a,o]=(0,K.useState)(!1),s=(0,K.useId)(),c=r?r.eligible?P:J[r.wait]:j,l=r?r.eligible?`Starting on ${r.hostName}`:E[r.wait]:`Waiting for dispatch`,d=r&&!r.eligible?r.message:null;return(0,q.jsxs)(`article`,{"data-testid":`now-queued-row`,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3 sm:flex-row sm:items-center`,children:[(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,q.jsx)(t,{to:I.task(n),className:`min-w-0 font-medium break-words hover:underline`,children:e?.title??`Task`}),i&&(0,q.jsx)(`span`,{className:`text-xs text-muted`,children:i.name}),(0,q.jsxs)(`p`,{className:`flex min-w-0 items-start gap-1.5 text-sm`,children:[(0,q.jsx)(c,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 ${r?.eligible?`text-success`:`text-warning`}`}),(0,q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,q.jsx)(`span`,{className:`font-medium`,children:l}),d&&d!==l?(0,q.jsxs)(`span`,{className:`text-muted`,children:[`: `,d]}):null]})]})]}),e&&(0,q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,q.jsx)(`label`,{htmlFor:s,className:`text-sm text-muted`,children:`Priority`}),(0,q.jsx)(S,{id:s,width:`auto`,value:e.priority,disabled:a,onChange:async t=>{o(!0);try{await w(e.id,{priority:t}),F.success(`"${e.title}" is now ${u[t]} priority`)}catch(e){F.error(`Could not change priority: ${y(e)}`)}finally{o(!1)}}}),a&&(0,q.jsx)(f,{label:`Saving priority`})]})]})}export{Y as default};
|
|
2
|
+
//# sourceMappingURL=queue-DUg1rS8t.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue-DUg1rS8t.js","names":["__iconData","__iconData","__iconData","useMemo","useState","useId","__toESM","Link","require_react","createLucideIcon","require_jsx_runtime","isApiError","LoadingState","buttonClasses","formatRelative","HostUnavailable","PRIORITY_LABELS","ErrorState","Spinner","FatalError","LastKnownNote","EmptyState","UnsupportedCapability","TriangleAlert","Inbox","errorMessage","useSyncStore","CalendarClock","PrioritySelect","ExternalLink","updateTask","DispatchToggle","WAIT_LABELS","useNow","isRunActive","Link2","WifiOff","Timer","LoaderCircle","StatusChip","CircleCheck","toast","ROUTES","CirclePause","__iconData$3","FolderLock","__iconData$2","Gauge","__iconData$1","PowerOff","__iconData","RotateCw","import_react","import_jsx_runtime","WAIT_ICONS","QueueView","now","tasks","s","runs","hydrated","unsupported","malformed","running","r","queued","q","t","a","b","loading","fatal","RunningRow","QueuedRow","task","taskId","run","runId","host","project","offline","sessionId","busy","setBusy","id","Icon","eligibility","waitLabel","detail","p","err"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/folder-lock.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/gauge.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/power-off.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.mjs","../../src/features/queue/index.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"folder-lock\",\n size: 24,\n node: [\n [\"rect\", { width: \"8\", height: \"5\", x: \"14\", y: \"17\", rx: \"1\", key: \"19aais\" }],\n [\n \"path\",\n {\n d: \"M10 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v2.5\",\n key: \"1w6v7t\"\n }\n ],\n [\"path\", { d: \"M20 17v-2a2 2 0 1 0-4 0v2\", key: \"pwaxnr\" }]\n ]\n};\n__iconData.node;\nconst FolderLock = createLucideIcon(__iconData);\n\nexport { __iconData, FolderLock as default };\n//# sourceMappingURL=folder-lock.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"gauge\",\n size: 24,\n node: [\n [\"path\", { d: \"m12 14 4-4\", key: \"9kzdfg\" }],\n [\"path\", { d: \"M3.34 19a10 10 0 1 1 17.32 0\", key: \"19p75a\" }]\n ]\n};\n__iconData.node;\nconst Gauge = createLucideIcon(__iconData);\n\nexport { __iconData, Gauge as default };\n//# sourceMappingURL=gauge.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"power-off\",\n size: 24,\n node: [\n [\"path\", { d: \"M18.36 6.64A9 9 0 0 1 20.77 15\", key: \"dxknvb\" }],\n [\"path\", { d: \"M6.16 6.16a9 9 0 1 0 12.68 12.68\", key: \"1x7qb5\" }],\n [\"path\", { d: \"M12 2v4\", key: \"3427ic\" }],\n [\"path\", { d: \"m2 2 20 20\", key: \"1ooewy\" }]\n ]\n};\n__iconData.node;\nconst PowerOff = createLucideIcon(__iconData);\n\nexport { __iconData, PowerOff as default };\n//# sourceMappingURL=power-off.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"rotate-cw\",\n size: 24,\n node: [\n [\"path\", { d: \"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8\", key: \"1p45f6\" }],\n [\"path\", { d: \"M21 3v5h-5\", key: \"1q7to0\" }]\n ]\n};\n__iconData.node;\nconst RotateCw = createLucideIcon(__iconData);\n\nexport { __iconData, RotateCw as default };\n//# sourceMappingURL=rotate-cw.mjs.map\n","import type { Eligibility, Task } from \"@switchyard/protocol\";\nimport { PRIORITY_LABELS } from \"@switchyard/protocol\";\nimport {\n CalendarClock,\n CircleCheck,\n CirclePause,\n ExternalLink,\n FolderLock,\n Gauge,\n Inbox,\n Link2,\n LoaderCircle,\n type LucideIcon,\n PowerOff,\n RotateCw,\n Timer,\n TriangleAlert,\n WifiOff,\n} from \"lucide-react\";\nimport { useId, useMemo, useState } from \"react\";\nimport { Link } from \"react-router\";\nimport { ROUTES } from \"../../app/routes\";\nimport { buttonClasses } from \"../../components/ui/Button\";\nimport { PrioritySelect } from \"../../components/ui/Priority\";\nimport { Spinner } from \"../../components/ui/Spinner\";\nimport { StatusChip } from \"../../components/ui/StatusChip\";\nimport {\n EmptyState,\n ErrorState,\n FatalError,\n HostUnavailable,\n LastKnownNote,\n LoadingState,\n UnsupportedCapability,\n} from \"../../components/ui/states\";\nimport { toast } from \"../../components/ui/Toast\";\nimport { formatRelative } from \"../../lib/time\";\nimport { errorMessage, isApiError } from \"../../sync/api\";\nimport { useSyncStore } from \"../../sync/store\";\nimport { updateTask } from \"../board/api\";\nimport { DispatchToggle } from \"../board/BoardChrome\";\nimport { isRunActive, WAIT_LABELS, type WaitReason } from \"../board/logic\";\nimport { useNow } from \"./useNow\";\n\nconst WAIT_ICONS: Record<WaitReason, LucideIcon> = {\n dependency: Link2,\n host_offline: WifiOff,\n project_limit: Gauge,\n workspace_occupied: FolderLock,\n scheduled_time: CalendarClock,\n invalid_configuration: TriangleAlert,\n dispatch_paused: CirclePause,\n project_automation_disabled: PowerOff,\n not_ready: Inbox,\n already_dispatched: LoaderCircle,\n retry_backoff: RotateCw,\n};\n\n/** /queue: running and queued work, each queued row explaining its wait. */\nexport default function QueueView() {\n const now = useNow();\n const tasks = useSyncStore((s) => s.tasks);\n const runs = useSyncStore((s) => s.runs);\n const hydrated = useSyncStore((s) => s.hydrated);\n const unsupported = isApiError(now.error) && now.error.status === 404;\n const malformed =\n !!now.data && (!Array.isArray(now.data.running) || !Array.isArray(now.data.queued));\n\n // Running from the server, or from the store when the endpoint is unavailable.\n const running = useMemo(() => {\n if (now.data && !malformed)\n return now.data.running.map((r) => ({\n taskId: r.taskId,\n runId: r.runId,\n sessionId: r.sessionId,\n }));\n return Object.values(runs)\n .filter((r) => isRunActive(r) && r.state !== \"queued\")\n .map((r) => ({ taskId: r.taskId, runId: r.id, sessionId: r.sessionId }));\n }, [now.data, runs, malformed]);\n const queued = useMemo(() => {\n if (now.data && !malformed)\n return now.data.queued.map((q) => ({\n taskId: q.taskId,\n eligibility: q.eligibility as Eligibility | undefined,\n }));\n return Object.values(tasks)\n .filter((t) => t.state === \"ready\" && !t.hiddenFromBoard)\n .sort((a, b) => a.priority - b.priority || a.position - b.position)\n .map((t) => ({ taskId: t.id, eligibility: undefined as Eligibility | undefined }));\n }, [now.data, tasks, malformed]);\n\n const loading = (!now.data && now.loading && !now.error) || !hydrated;\n const fatal = !!now.error && !unsupported && !now.data;\n if (malformed)\n return (\n <FatalError\n title=\"The coordinator sent a queue this version cannot read\"\n error=\"GET /api/now returned an unexpected shape. Check that the web app and coordinator versions match.\"\n />\n );\n\n return (\n <div className=\"flex w-full min-w-0 flex-col gap-4 px-4 pb-4 safe-pt-4 md:px-6\">\n <header className=\"flex min-w-0 flex-wrap items-center gap-3\">\n <h1 className=\"flex-1 text-lg font-semibold\">Queue</h1>\n <DispatchToggle />\n </header>\n <p className=\"text-sm text-muted\">\n Pausing stops new work from starting. Runs already in progress keep going.\n </p>\n <LastKnownNote subject=\"queue\" show={!!now.data} />\n {unsupported && (\n <UnsupportedCapability\n capability=\"Queue explanations\"\n reason=\"This coordinator does not report why queued tasks are waiting. The list below comes from local data.\"\n />\n )}\n {now.error != null && !unsupported && (\n <ErrorState\n compact\n title=\"Could not refresh running and queued work\"\n error={errorMessage(now.error)}\n onRetry={now.reload}\n />\n )}\n\n {loading ? (\n <LoadingState label=\"Loading running and queued work…\" />\n ) : fatal && running.length === 0 && queued.length === 0 ? null : running.length === 0 &&\n queued.length === 0 ? (\n <EmptyState\n icon={<Timer className=\"size-8\" />}\n title=\"Nothing running or queued\"\n description=\"Move a task to Ready on the board and the dispatcher starts it when it is eligible.\"\n action={{ label: \"Go to Board\", to: ROUTES.board }}\n />\n ) : (\n <div className=\"grid min-w-0 grid-cols-1 gap-4 xl:grid-cols-2 xl:items-start\">\n <section aria-labelledby=\"now-running\" className=\"flex min-w-0 flex-col gap-2\">\n <h2 id=\"now-running\" className=\"text-base font-semibold\">\n Running <span className=\"text-sm font-normal text-muted\">({running.length})</span>\n </h2>\n {running.length === 0 ? (\n <p className=\"text-sm text-muted\">Nothing is running.</p>\n ) : (\n <ul className=\"flex min-w-0 flex-col gap-2\">\n {running.map((r) => (\n <li key={r.runId}>\n <RunningRow taskId={r.taskId} runId={r.runId} sessionId={r.sessionId} />\n </li>\n ))}\n </ul>\n )}\n </section>\n <section aria-labelledby=\"now-queued\" className=\"flex min-w-0 flex-col gap-2\">\n <h2 id=\"now-queued\" className=\"text-base font-semibold\">\n Queued <span className=\"text-sm font-normal text-muted\">({queued.length})</span>\n </h2>\n {queued.length === 0 ? (\n <p className=\"text-sm text-muted\">No Ready tasks are waiting.</p>\n ) : (\n <ul className=\"flex min-w-0 flex-col gap-2\">\n {queued.map((q) => (\n <li key={q.taskId}>\n <QueuedRow\n task={tasks[q.taskId]}\n taskId={q.taskId}\n eligibility={q.eligibility}\n />\n </li>\n ))}\n </ul>\n )}\n </section>\n </div>\n )}\n </div>\n );\n}\n\nfunction RunningRow({\n taskId,\n runId,\n sessionId,\n}: {\n taskId: string;\n runId: string;\n sessionId: string | null;\n}) {\n const task = useSyncStore((s) => s.tasks[taskId]);\n const run = useSyncStore((s) => s.runs[runId]);\n const host = useSyncStore((s) => (run?.hostId ? s.hosts[run.hostId] : undefined));\n const project = useSyncStore((s) => (task ? s.projects[task.projectId] : undefined));\n const offline = !!host && host.connectivity !== \"connected\";\n return (\n <article className=\"flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3\">\n <div className=\"flex min-w-0 flex-wrap items-start gap-2\">\n {run ? (\n <StatusChip kind=\"run\" value={run.state} size=\"sm\" />\n ) : (\n <StatusChip kind=\"task\" value=\"in_progress\" size=\"sm\" />\n )}\n <Link\n to={ROUTES.task(taskId)}\n className=\"min-w-0 flex-1 basis-48 font-medium break-words hover:underline\"\n >\n {task?.title ?? \"Task\"}\n </Link>\n {(sessionId ?? task?.sessionId) && (\n <Link\n to={ROUTES.session((sessionId ?? task?.sessionId) as string)}\n className={buttonClasses(\"secondary\", \"sm\")}\n >\n <ExternalLink aria-hidden className=\"size-3.5\" />\n Open session\n </Link>\n )}\n </div>\n <p className=\"text-xs text-muted\">\n {[\n project?.name,\n host ? `on ${host.name}` : null,\n run?.attempt && run.attempt > 1 ? `attempt ${run.attempt}` : null,\n run?.startedAt ? `started ${formatRelative(run.startedAt)}` : null,\n run?.controlMode === \"human\" ? \"you have control\" : \"automation\",\n ]\n .filter(Boolean)\n .join(\" · \")}\n </p>\n {run?.state === \"uncertain\" && host && (\n <p className=\"text-sm text-warning\">\n <span className=\"text-text\">\n Waiting for host {host.name} to confirm launch. It is never started elsewhere.\n </span>\n </p>\n )}\n {offline && host && (\n <HostUnavailable\n compact\n hostName={host.name}\n connectivity={host.connectivity === \"reconnecting\" ? \"reconnecting\" : \"unreachable\"}\n lastSeenAt={host.lastSeenAt}\n />\n )}\n </article>\n );\n}\n\nfunction QueuedRow({\n task,\n taskId,\n eligibility,\n}: {\n task: Task | undefined;\n taskId: string;\n eligibility?: Eligibility;\n}) {\n const project = useSyncStore((s) => (task ? s.projects[task.projectId] : undefined));\n const [busy, setBusy] = useState(false);\n const id = useId();\n const Icon = eligibility\n ? eligibility.eligible\n ? CircleCheck\n : WAIT_ICONS[eligibility.wait]\n : Timer;\n const waitLabel = eligibility\n ? eligibility.eligible\n ? `Starting on ${eligibility.hostName}`\n : WAIT_LABELS[eligibility.wait]\n : \"Waiting for dispatch\";\n const detail = eligibility && !eligibility.eligible ? eligibility.message : null;\n return (\n <article\n data-testid=\"now-queued-row\"\n className=\"flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3 sm:flex-row sm:items-center\"\n >\n <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n <Link to={ROUTES.task(taskId)} className=\"min-w-0 font-medium break-words hover:underline\">\n {task?.title ?? \"Task\"}\n </Link>\n {project && <span className=\"text-xs text-muted\">{project.name}</span>}\n <p className=\"flex min-w-0 items-start gap-1.5 text-sm\">\n <Icon\n aria-hidden\n className={`mt-0.5 size-4 shrink-0 ${eligibility?.eligible ? \"text-success\" : \"text-warning\"}`}\n />\n <span className=\"min-w-0 break-words\">\n <span className=\"font-medium\">{waitLabel}</span>\n {detail && detail !== waitLabel ? <span className=\"text-muted\">: {detail}</span> : null}\n </span>\n </p>\n </div>\n {task && (\n <div className=\"flex shrink-0 items-center gap-2\">\n <label htmlFor={id} className=\"text-sm text-muted\">\n Priority\n </label>\n <PrioritySelect\n id={id}\n width=\"auto\"\n value={task.priority}\n disabled={busy}\n onChange={async (p) => {\n setBusy(true);\n try {\n await updateTask(task.id, { priority: p });\n toast.success(`\"${task.title}\" is now ${PRIORITY_LABELS[p]} priority`);\n } catch (err) {\n toast.error(`Could not change priority: ${errorMessage(err)}`);\n } finally {\n setBusy(false);\n }\n }}\n />\n {busy && <Spinner label=\"Saving priority\" />}\n </div>\n )}\n </article>\n );\n}\n"],"ignoreList":[0,1,2,3],"mappings":"A,kjBASA,IAAMA,EAAa,CACjB,KAAM,cACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,MAAO,IAAK,OAAQ,IAAK,EAAG,KAAM,EAAG,KAAM,GAAI,IAAK,IAAK,QAAS,CAAC,EAC9E,CACE,OACA,CACE,EAAG,4GACH,IAAK,QACP,CACF,EACA,CAAC,OAAQ,CAAE,EAAG,4BAA6B,IAAK,QAAS,CAAC,CAC5D,CACF,EACAA,EAAW,KACX,IAAM6C,EAAapC,EAAiBT,CAAU,EChBxCC,EAAa,CACjB,KAAM,QACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,aAAc,IAAK,QAAS,CAAC,EAC3C,CAAC,OAAQ,CAAE,EAAG,+BAAgC,IAAK,QAAS,CAAC,CAC/D,CACF,EACAA,EAAW,KACX,IAAM8C,EAAQtC,EAAiBR,CAAU,ECTnCC,EAAa,CACjB,KAAM,YACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,iCAAkC,IAAK,QAAS,CAAC,EAC/D,CAAC,OAAQ,CAAE,EAAG,mCAAoC,IAAK,QAAS,CAAC,EACjE,CAAC,OAAQ,CAAE,EAAG,UAAW,IAAK,QAAS,CAAC,EACxC,CAAC,OAAQ,CAAE,EAAG,aAAc,IAAK,QA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AAf,SAAA,EACE,EAAAA,EAAA,IAAA,CAAC,QAAD,CAAO,QAAS+B,EAAI,UAAU,qBAAqB,SAAA,UAE5C,CAAA,GACP,EAAA/B,EAAA,IAAA,CAACzB,EAAD,CACM,KACJ,MAAM,OACN,MAAO8C,EAAK,SACZ,SAAUQ,EACV,SAAU,KAAO,IAAM,CACrBC,EAAQ,EAAI,EACZ,GAAI,CACF,MAAMrD,EAAW4C,EAAK,GAAI,CAAE,SAAUe,CAAE,CAAC,EACzChD,EAAM,QAAQ,IAAIiC,EAAK,MAAM,WAAW1D,EAAgByE,GAAG,UAAU,CACvE,OAASC,EAAK,CACZjD,EAAM,MAAM,8BAA8BhB,EAAaiE,CAAG,GAAG,CAC/D,QAAU,CACRP,EAAQ,EAAK,CACf,CACF,CACD,CAAA,EACAD,IAAQ,EAAA7B,EAAA,IAAA,CAACnC,EAAD,CAAS,MAAM,iBAAmB,CAAA,CACxC,CAEA,CAAA,CAAA,C,EAEb,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e}from"./jsx-runtime-D13aM9HY.js";var t={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};t.node;var n=e(t),r={name:`folder-git-2`,size:24,node:[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]};r.node;var i=e(r),a={name:`send`,size:24,node:[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]};a.node;var o=e(a),s={name:`sliders-horizontal`,size:24,node:[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]};s.node;var c=e(s);function l(e){return e.startsWith(`local:`)?`Local only`:e.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``)}function u(e,t){let n=t.trim().toLowerCase();return!n||e.name.toLowerCase().includes(n)||e.repoIdentity.toLowerCase().includes(n)}export{i as a,o as i,l as n,n as o,c as r,u as t};
|
|
2
|
+
//# sourceMappingURL=repo-XzzzEI0d.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repo-XzzzEI0d.js","names":["__iconData","__iconData","__iconData","createLucideIcon","__iconData$3","ChevronLeft","__iconData$2","FolderGit2","__iconData$1","Send","__iconData","SlidersHorizontal","repoLabel","identity","matchesProject","q","query","p"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/chevron-left.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/folder-git-2.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/send.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/sliders-horizontal.mjs","../../src/lib/repo.ts"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"chevron-left\",\n size: 24,\n node: [[\"path\", { d: \"m15 18-6-6 6-6\", key: \"1wnfg3\" }]]\n};\n__iconData.node;\nconst ChevronLeft = createLucideIcon(__iconData);\n\nexport { __iconData, ChevronLeft as default };\n//# sourceMappingURL=chevron-left.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"folder-git-2\",\n size: 24,\n node: [\n [\"path\", { d: \"M18 19a5 5 0 0 1-5-5v8\", key: \"sz5oeg\" }],\n [\n \"path\",\n {\n d: \"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5\",\n key: \"1w6njk\"\n }\n ],\n [\"circle\", { cx: \"13\", cy: \"12\", r: \"2\", key: \"1j92g6\" }],\n [\"circle\", { cx: \"20\", cy: \"19\", r: \"2\", key: \"1obnsp\" }]\n ]\n};\n__iconData.node;\nconst FolderGit2 = createLucideIcon(__iconData);\n\nexport { __iconData, FolderGit2 as default };\n//# sourceMappingURL=folder-git-2.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"send\",\n size: 24,\n node: [\n [\n \"path\",\n {\n d: \"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z\",\n key: \"1ffxy3\"\n }\n ],\n [\"path\", { d: \"m21.854 2.147-10.94 10.939\", key: \"12cjpa\" }]\n ]\n};\n__iconData.node;\nconst Send = createLucideIcon(__iconData);\n\nexport { __iconData, Send as default };\n//# sourceMappingURL=send.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"sliders-horizontal\",\n size: 24,\n node: [\n [\"path\", { d: \"M10 5H3\", key: \"1qgfaw\" }],\n [\"path\", { d: \"M12 19H3\", key: \"yhmn1j\" }],\n [\"path\", { d: \"M14 3v4\", key: \"1sua03\" }],\n [\"path\", { d: \"M16 17v4\", key: \"1q0r14\" }],\n [\"path\", { d: \"M21 12h-9\", key: \"1o4lsq\" }],\n [\"path\", { d: \"M21 19h-5\", key: \"1rlt1p\" }],\n [\"path\", { d: \"M21 5h-7\", key: \"1oszz2\" }],\n [\"path\", { d: \"M8 10v4\", key: \"tgpxqk\" }],\n [\"path\", { d: \"M8 12H3\", key: \"a7s4jb\" }]\n ]\n};\n__iconData.node;\nconst SlidersHorizontal = createLucideIcon(__iconData);\n\nexport { __iconData, SlidersHorizontal as default };\n//# sourceMappingURL=sliders-horizontal.mjs.map\n","import type { Project } from \"@switchyard/protocol\";\n\n/** \"Local only\" for repositories without a remote (`local:<sha|path>`), else the remote without its scheme. */\nexport function repoLabel(identity: string): string {\n if (identity.startsWith(\"local:\")) return \"Local only\";\n return identity.replace(/^[a-z][a-z0-9+.-]*:\\/\\//i, \"\");\n}\n\n/** Case-insensitive match on project name or remote. */\nexport function matchesProject(p: Pick<Project, \"name\" | \"repoIdentity\">, query: string): boolean {\n const q = query.trim().toLowerCase();\n if (!q) return true;\n return p.name.toLowerCase().includes(q) || p.repoIdentity.toLowerCase().includes(q);\n}\n"],"ignoreList":[0,1,2,3],"mappings":"A,8CASA,IAAMA,EAAa,CACjB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AQ,CAAE,EAAG,UAAW,IAAK,QAAS,CAAC,CAC1C,CACF,EACAA,EAAW,KACX,IAAMC,EAAoBR,EAAiBO,CAAU,ECtBrD,SAAgBE,EAAU,EAA0B,CAElD,OADIC,EAAS,WAAW,QAAQ,EAAU,aACnCA,EAAS,QAAQ,2BAA4B,EAAE,CACxD,CAGA,SAAgBC,EAAe,EAA2C,EAAwB,CAChG,IAAMC,EAAIC,EAAM,KAAK,CAAC,CAAC,YAAY,EAEnC,MADA,CAAKD,GACEE,EAAE,KAAK,YAAY,CAAC,CAAC,SAASF,CAAC,GAAKE,EAAE,aAAa,YAAY,CAAC,CAAC,SAASF,CAAC,CACpF,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e}from"./jsx-runtime-D13aM9HY.js";var t={name:`server`,size:24,node:[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]};t.node;var n=e(t);export{n as t};
|
|
2
|
+
//# sourceMappingURL=server-BqZ-w6M8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-BqZ-w6M8.js","names":["createLucideIcon","__iconData","Server"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/server.mjs"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"server\",\n size: 24,\n node: [\n [\"rect\", { width: \"20\", height: \"8\", x: \"2\", y: \"2\", rx: \"2\", ry: \"2\", key: \"ngkwjq\" }],\n [\"rect\", { width: \"20\", height: \"8\", x: \"2\", y: \"14\", rx: \"2\", ry: \"2\", key: \"iecqi9\" }],\n [\"line\", { x1: \"6\", x2: \"6.01\", y1: \"6\", y2: \"6\", key: \"16zg32\" }],\n [\"line\", { x1: \"6\", x2: \"6.01\", y1: \"18\", y2: \"18\", key: \"nzw8ys\" }]\n ]\n};\n__iconData.node;\nconst Server = createLucideIcon(__iconData);\n\nexport { __iconData, Server as default };\n//# sourceMappingURL=server.mjs.map\n"],"ignoreList":[0],"mappings":"A,8CASA,IAAMC,EAAa,CACjB,KAAM,SACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,MAAO,KAAM,OAAQ,IAAK,EAAG,IAAK,EAAG,IAAK,GAAI,IAAK,GAAI,IAAK,IAAK,QAAS,CAAC,EACtF,CAAC,OAAQ,CAAE,MAAO,KAAM,OAAQ,IAAK,EAAG,IAAK,EAAG,KAAM,GAAI,IAAK,GAAI,IAAK,IAAK,QAAS,CAAC,EACvF,CAAC,OAAQ,CAAE,GAAI,IAAK,GAAI,OAAQ,GAAI,IAAK,GAAI,IAAK,IAAK,QAAS,CAAC,EACjE,CAAC,OAAQ,CAAE,GAAI,IAAK,GAAI,OAAQ,GAAI,KAAM,GAAI,KAAM,IAAK,QAAS,CAAC,CACrE,CACF,EACAA,EAAW,KACX,IAAMC,EAASF,EAAiBC,CAAU,E"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{_ as e,c as t,f as n,i as r,l as i,m as a,n as o,o as s,p as c,t as l,u}from"./jsx-runtime-D13aM9HY.js";import{A as d,P as f,S as p,X as m,_ as h,_t as g,a as _,at as v,bt as y,c as b,d as x,dt as S,f as C,g as w,h as T,ht as E,i as D,n as O,ot as ee,p as k,pt as A,r as j,rt as M,s as N,st as te,t as P,u as ne,ut as re,v as F,vt as I,x as ie,y as ae,yt as oe,z as L}from"./states-ZhrxQa3K.js";import{a as se,i as ce,r as R,t as z}from"./Field-D-Ty7fKT.js";import{n as le,r as ue,t as de}from"./Copy-B6XSAIUd.js";import{a as fe,i as pe,n as me,o as he,r as ge,t as _e}from"./repo-XzzzEI0d.js";import{t as ve}from"./chevron-right-evVLS6hq.js";import{n as ye,t as be}from"./pencil-DI8QbCN8.js";import{t as xe}from"./key-round-VDbE9E4X.js";import{i as Se,n as Ce,r as we,t as Te}from"./useBackTo-BIrCq3W2.js";import{n as B,r as Ee,t as De}from"./DangerZone-DfYlxDC1.js";import{t as Oe}from"./search-C6cn5WOo.js";import{t as ke}from"./server-BqZ-w6M8.js";import{t as Ae}from"./terminal-BOV_MXPZ.js";import{$ as je,B as Me,G as Ne,R as Pe,S as V,T as Fe,U as Ie,W as Le,X as H,Y as Re,Z as ze,a as Be,b as U,et as Ve,h as He,i as Ue,m as We,n as Ge,nt as Ke,o as qe,r as Je,s as Ye,t as Xe,y as Ze}from"./index-hxvDvCS7.js";import{n as Qe,t as W}from"./Overlay-DUQwh6_b.js";import{n as $e,r as G}from"./TextArea-CKybrQyn.js";import{t as et}from"./TextLink-OzzyP2-p.js";import{n as tt,t as K}from"./useResource-CDGSq2At.js";import{t as q}from"./Select-Cfql4Nwu.js";import{n as nt}from"./Switch-DBfzmqkm.js";import{t as rt}from"./Checkbox-D6tRfEeI.js";import{d as it,f as at,l as ot,r as st}from"./logic-B46fwD-8.js";var ct={name:`bell-off`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]};ct.node;var lt=o(ct),ut={name:`bell-ring`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]};ut.node;var dt=o(ut),ft={name:`database-backup`,size:24,node:[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 12a9 3 0 0 0 5 2.69`,key:`1ui2ym`}],[`path`,{d:`M21 9.3V5`,key:`6k6cib`}],[`path`,{d:`M3 5v14a9 3 0 0 0 6.47 2.88`,key:`i62tjy`}],[`path`,{d:`M12 12v4h4`,key:`1bxaet`}],[`path`,{d:`M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16`,key:`1f4ei9`}]]};ft.node;var pt=o(ft),mt={name:`folder-plus`,size:24,node:[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]};mt.node;var ht=o(mt),gt={name:`folder-search`,size:24,node:[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]};gt.node;var _t=o(gt),vt={name:`keyboard`,size:24,node:[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]};vt.node;var yt=o(vt),bt={name:`laptop`,size:24,node:[[`path`,{d:`M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z`,key:`1pdavp`}],[`path`,{d:`M20.054 15.987H3.946`,key:`14rxg9`}]]};bt.node;var xt=o(bt),St={name:`log-out`,size:24,node:[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]};St.node;var Ct=o(St),wt={name:`monitor-smartphone`,size:24,node:[[`path`,{d:`M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8`,key:`10dyio`}],[`path`,{d:`M10 19v-3.96 3.15`,key:`1irgej`}],[`path`,{d:`M7 19h5`,key:`qswx4l`}],[`rect`,{width:`6`,height:`10`,x:`16`,y:`12`,rx:`2`,key:`1egngj`}]]};wt.node;var Tt=o(wt),Et={name:`shield-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]};Et.node;var Dt=o(Et),Ot={name:`smartphone`,size:24,node:[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]};Ot.node;var kt=o(Ot),At={name:`star`,size:24,node:[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]};At.node;var jt=o(At),Mt={name:`stethoscope`,size:24,node:[[`path`,{d:`M11 2v2`,key:`1539x4`}],[`path`,{d:`M5 2v2`,key:`1yf1q8`}],[`path`,{d:`M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1`,key:`rb5t3r`}],[`path`,{d:`M8 15a6 6 0 0 0 12 0v-3`,key:`x18d4x`}],[`circle`,{cx:`20`,cy:`10`,r:`2`,key:`ts1r5v`}]]};Mt.node;var Nt=o(Mt),J=e(a(),1),Y=l(),Pt=[{path:`projects`,label:`Projects`,description:`Repositories, checkouts and workspaces`,icon:fe,group:`Workspace`},{path:`profiles`,label:`Pi profiles`,description:`Provider, model and thinking presets`,icon:ge,group:`Workspace`},{path:`hosts`,label:`Hosts`,description:`Execution hosts, capabilities and versions`,icon:ke,group:`Infrastructure`},{path:`adapters`,label:`Adapters`,description:`Extension adapters on each host`,icon:p,group:`Infrastructure`},{path:`backups`,label:`Backups`,description:`Back up and restore the coordinator`,icon:pt,group:`Infrastructure`},{path:`diagnostics`,label:`Diagnostics`,description:`Versions, migrations, events and recent problems`,icon:Nt,group:`Infrastructure`},{path:`sign-in`,label:`Sign-in`,description:`Passkeys, single sign-on and signing out`,icon:xe,group:`Access`},{path:`devices`,label:`Devices`,description:`Signed-in browsers, apps and terminals`,icon:Tt,group:`Access`},{path:`notifications`,label:`Notifications`,description:`Push, quiet hours and previews`,icon:ze,group:`This device`},{path:`device`,label:`This device`,description:`Preferences stored on this device`,icon:yt,group:`This device`}],Ft=[`Workspace`,`Infrastructure`,`Access`,`This device`].map(e=>({label:e,sections:Pt.filter(t=>t.group===e)})),X=e=>e?`/settings/${e}`:`/settings`;function Z({title:e,description:t,actions:n,back:i,testId:a,children:o}){let s=We()===`mobile`,c=i??(s?{to:X(),label:`Settings`}:null),l=we(c?.to??X()),u=s&&!!c;return(0,Y.jsxs)(`section`,{"data-testid":a,className:`flex w-full min-w-0 flex-col gap-4 px-4 py-4 md:px-6`,children:[u&&c?(0,Y.jsxs)(`header`,{className:`sticky top-0 z-20 -mx-4 -mt-4 flex min-w-0 items-center gap-1 border-b border-border bg-surface px-1 pb-1 safe-pt-1`,children:[(0,Y.jsx)(r,{to:c.to,onClick:Ce(l),"aria-label":`Back to ${c.label}`,title:`Back to ${c.label}`,className:C(`ghost`,`md`,`size-11 px-0`),children:(0,Y.jsx)(se,{"aria-hidden":!0,className:`size-5`})}),(0,Y.jsx)(`h1`,{className:`min-w-0 flex-1 truncate text-base font-semibold`,children:e})]}):c&&(0,Y.jsxs)(r,{to:c.to,onClick:Ce(l),className:`tap -ml-2 inline-flex w-fit items-center gap-1 rounded-md px-2 py-1 text-sm font-medium text-accent hover:bg-surface-2`,children:[(0,Y.jsx)(he,{"aria-hidden":!0,className:`size-4`}),`Back to `,c.label]}),(!u||t||n)&&(0,Y.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-start gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-[1_1_15rem]`,children:[!u&&(0,Y.jsx)(`h1`,{className:`break-words text-lg font-semibold`,children:e}),t&&(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:t})]}),n&&(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:n})]}),o]})}function It({items:e}){return(0,Y.jsx)(`dl`,{className:`grid min-w-0 gap-x-4 gap-y-1 text-sm sm:grid-cols-[minmax(8rem,12rem)_minmax(0,1fr)]`,children:e.map(([e,t],n)=>(0,Y.jsxs)(`div`,{className:`contents`,children:[(0,Y.jsx)(`dt`,{className:`text-muted`,children:e}),(0,Y.jsx)(`dd`,{className:`mb-1 min-w-0 break-words sm:mb-0`,children:t})]},n))})}function Q(){return L(e=>e.hydrated)}var Lt={darwin:`macOS`,linux:`Linux`};function Rt({host:e}){return e.piVersion?e.piCompatible?(0,Y.jsx)(V,{icon:H,tone:`success`,label:`Pi ${e.piVersion} (compatible)`}):(0,Y.jsx)(V,{icon:F,tone:`danger`,label:`Pi ${e.piVersion} (incompatible, needs ${m})`}):(0,Y.jsx)(V,{icon:F,tone:`warning`,label:`Pi not detected (incompatible)`})}function zt(e){let t=e.trim();return t?t.startsWith(`/`)?null:`Use an absolute path that starts with /, e.g. /Users/me/src/app.`:`Enter the path of the checkout on the host.`}function Bt(e){if(typeof e!=`object`||!e)return!1;let t=e;return Array.isArray(t.passkeys)&&typeof t.passkeyAvailability==`object`}function Vt(e){return e.split(`
|
|
2
|
+
`).map(e=>e.trim()).filter(Boolean)}function Ht(e){let[t,n]=(0,J.useState)(()=>Date.now());if((0,J.useEffect)(()=>{if(!e)return;n(Date.now());let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),!e)return null;let r=Date.parse(e);return Number.isNaN(r)?null:Math.max(0,r-t)}function Ut(e){let t=Math.ceil(e/1e3);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}var Wt={active:{icon:H,label:`Active`,tone:`success`},disabled:{icon:Ne,label:`Disabled`,tone:`neutral`},error:{icon:Le,label:`Error`,tone:`danger`}};function Gt({status:e}){let t=Wt[e]??Wt.error;return(0,Y.jsx)(V,{icon:t.icon,label:t.label,tone:t.tone})}var Kt={project:`Project`,owner:`Owner`,plugin:`Plugin`,bundled:`Bundled`},qt={info:{icon:Me,label:`Info`,tone:`info`},warning:{icon:F,label:`Warning`,tone:`warning`},error:{icon:Le,label:`Error`,tone:`danger`}};function Jt({level:e}){let t=qt[e]??qt.info;return(0,Y.jsx)(V,{icon:t.icon,label:t.label,tone:t.tone})}function Yt(e){let t=L(e=>e.diagnostics);return(0,J.useMemo)(()=>{let n=new Set,r=[];for(let i of[...e??[],...t]){let e=`${i.at}|${i.adapterId??``}|${i.sessionId??``}|${i.message}`;n.has(e)||(n.add(e),r.push(i))}return r.sort((e,t)=>t.at.localeCompare(e.at))},[e,t])}function Xt(){let e=Q(),t=L(e=>e.adapters),n=L(e=>e.hosts),i=tt(`/api/diagnostics`,K),a=Yt(Array.isArray(i.data?.diagnostics)?i.data.diagnostics:void 0),o=(0,J.useMemo)(()=>Object.entries(t).filter(([,e])=>e.length>0).map(([e,t])=>({hostId:e,hostName:n[e]?.name??`Removed host`,adapters:[...t].sort((e,t)=>e.id.localeCompare(t.id))})).sort((e,t)=>e.hostName.localeCompare(t.hostName)),[t,n]);return(0,Y.jsxs)(Z,{title:`Adapters`,description:`Adapters translate Pi extensions into Switchyard cards, panels and interactions. Each host reports its own.`,children:[(0,Y.jsx)(N,{}),i.error!==null&&!i.loading&&!i.fatal&&(0,Y.jsx)(O,{compact:!0,title:`Could not load adapter diagnostics history`,error:i.error,onRetry:i.reload}),e?o.length===0?(0,Y.jsx)(P,{icon:(0,Y.jsx)(p,{className:`size-8`}),title:`No adapters reported`,description:`Hosts report adapters when their agent connects. Check that your hosts are connected.`,action:{label:`Open hosts`,to:X(`hosts`)}}):o.map(e=>(0,Y.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:(0,Y.jsx)(r,{to:X(`hosts/${encodeURIComponent(e.hostId)}`),className:`hover:underline`,children:e.hostName})}),e.adapters.map(e=>(0,Y.jsx)(Zt,{adapter:e,diagnostics:a.filter(t=>t.adapterId===e.id)},e.id))]},e.hostId)):(0,Y.jsx)(b,{label:`Loading adapters…`})]})}function Zt({adapter:e,diagnostics:t}){return(0,Y.jsxs)(B,{title:(0,Y.jsx)(`span`,{className:`break-all font-mono`,children:e.id}),actions:(0,Y.jsx)(Gt,{status:e.status}),children:[(0,Y.jsx)(It,{items:[[`Version`,e.version],[`Tier`,Kt[e.tier]??e.tier],[`Target extension`,(0,Y.jsx)(`span`,{className:`break-all font-mono`,children:e.target.extension},`t`)],[`Version range`,(0,Y.jsx)(`span`,{className:`font-mono`,children:e.target.versionRange},`r`)],[`Tested versions`,e.target.testedVersions.length?e.target.testedVersions.join(`, `):`None recorded`],[`Capabilities`,e.capabilities.length?e.capabilities.join(`, `):`None`],[`Web renderer`,e.webRenderer?`Yes (runs in a sandboxed frame; mobile uses a fallback)`:`No (native cards only)`],...e.detail?[[`Detail`,e.detail]]:[]]}),(0,Y.jsx)(`h3`,{className:`mt-3 mb-1 text-sm font-semibold`,children:`Recent diagnostics`}),t.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No diagnostics for this adapter.`}):(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:t.slice(0,10).map(e=>(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-2 text-sm`,children:[(0,Y.jsx)(Jt,{level:e.level}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:e.message}),(0,Y.jsx)(`time`,{dateTime:e.at,className:`text-xs text-muted`,children:w(e.at)})]},`${e.at}-${e.message}`))})]})}function Qt(e){return K(e)&&K(e.versions)}var $t=`/api/diagnostics`,en=`switchyard coordinator backup <file>`,tn=`switchyard coordinator restore <file>`;function nn(e){let t=e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/_/g,` `);return t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function rn(e,t){return t==null?`None`:typeof t==`string`&&/At$|time|date/i.test(e)?w(t):typeof t==`object`?JSON.stringify(t):String(t)}function an(){let e=tt($t,Qt),t=e.data&&K(e.data.backup)?e.data.backup:null;return(0,Y.jsxs)(Z,{title:`Backups`,description:`The coordinator keeps all state in one SQLite database. Back it up from the machine that runs the coordinator.`,children:[(0,Y.jsxs)(B,{title:`Back up`,children:[(0,Y.jsx)(`p`,{className:`mb-2 text-sm`,children:`Writes a consistent copy of the database to a file while the coordinator keeps running.`}),(0,Y.jsx)(de,{text:en,label:`Backup command`,copyLabel:`Copy command`})]}),(0,Y.jsxs)(B,{title:`Restore`,children:[(0,Y.jsxs)(`p`,{className:`mb-2 text-sm`,children:[`Restore refuses to run while the coordinator is running: stop it first. The current database is kept next to it as`,` `,(0,Y.jsx)(`code`,{className:`break-all`,children:`coordinator.db.bak-<ts>`}),`.`]}),(0,Y.jsx)(de,{text:tn,label:`Restore command`,copyLabel:`Copy command`}),(0,Y.jsx)(`p`,{className:`mt-2 text-sm text-muted`,children:`Hosts keep running sessions during a coordinator restart and replay their events when it comes back.`})]}),(0,Y.jsx)(B,{title:`Last backup`,children:e.fatal?(0,Y.jsx)(j,{error:e.error}):e.error&&!e.loading&&!e.data?(0,Y.jsx)(O,{compact:!0,title:`Could not load backup info`,error:e.error,onRetry:e.reload}):e.data?t&&Object.keys(t).length>0?(0,Y.jsx)(It,{items:Object.entries(t).map(([e,t])=>[nn(e),rn(e,t)])}):(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No backup info is recorded by the coordinator. Keep track of your backup files yourself, or schedule the backup command with cron or launchd.`}):(0,Y.jsx)(b,{label:`Loading backup info…`})})]})}var on={browser:`Browser`,pwa:`Home Screen app`,terminal:`Terminal`,cli:`CLI`},sn={granted:`allowed`,denied:`blocked`,default:`not requested`,unknown:`unknown`};function cn({kind:e}){return(0,Y.jsx)(e===`pwa`?kt:e===`browser`?xt:Ae,{"aria-hidden":!0,className:`mt-0.5 size-5 shrink-0 text-muted`})}function ln(){let e=Q(),t=L(e=>e.devices);Ke(e=>e.me);let n=je(),r=(0,J.useMemo)(()=>Object.values(t).filter(e=>e.revokedAt===null).sort((e,t)=>Number(t.id===n)-Number(e.id===n)||(t.lastSeenAt??``).localeCompare(e.lastSeenAt??``)),[t,n]),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(null),[m,h]=(0,J.useState)(!1),[_,v]=(0,J.useState)(null),[y,S]=(0,J.useState)(null),C=async()=>{if(f){h(!0),v(null);try{await I(`/api/devices/${encodeURIComponent(f.id)}/revoke`),U.success(`${f.name} revoked`),p(null)}catch(e){v(e)}finally{h(!1)}}},w=async e=>{S(e.id);try{await g(`/api/devices/${encodeURIComponent(e.id)}`,{preferredMobile:!0}),U.success(`${e.name} is now the preferred mobile device`)}catch(e){U.error(`Could not set the preferred device: ${oe(e)}`)}finally{S(null)}},E=async()=>{if(!i)return;let e=o.trim();if(e){l(!0),d(null);try{await g(`/api/devices/${encodeURIComponent(i.id)}`,{name:e}),U.success(`Renamed to ${e}`),a(null)}catch(e){d(e)}finally{l(!1)}}};return(0,Y.jsxs)(Z,{testId:`settings-devices`,title:`Devices`,description:`Browsers, Home Screen apps and terminals signed in to this coordinator. Revoke one to sign it out.`,children:[(0,Y.jsx)(N,{}),e?r.length===0?(0,Y.jsx)(P,{icon:(0,Y.jsx)(Tt,{className:`size-8`}),title:`No devices`,description:`Browsers and terminals appear here once they sign in.`}):(0,Y.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:r.map(e=>{let t=e.id===n;return(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-3 border-b border-border px-4 py-3 last:border-b-0`,children:[(0,Y.jsx)(cn,{kind:e.kind}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.name}),t&&(0,Y.jsx)(V,{icon:xt,tone:`info`,label:`This device`}),e.preferredMobile&&(0,Y.jsx)(V,{icon:jt,tone:`success`,label:`Preferred mobile`})]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-muted`,children:[(0,Y.jsx)(`span`,{children:on[e.kind]}),(0,Y.jsxs)(`span`,{children:[`Last seen `,T(e.lastSeenAt)]}),(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e.push.subscribed?(0,Y.jsx)(dt,{"aria-hidden":!0,className:`size-4 shrink-0`}):(0,Y.jsx)(lt,{"aria-hidden":!0,className:`size-4 shrink-0`}),e.push.subscribed?`Push subscribed`:`No push subscription`,`, permission`,` `,sn[e.push.permission]]})]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[!e.preferredMobile&&(0,Y.jsx)(x,{size:`sm`,icon:(0,Y.jsx)(jt,{className:`size-4`}),busy:y===e.id,onClick:()=>w(e),children:`Set as preferred mobile device`}),(0,Y.jsx)(x,{size:`sm`,variant:`ghost`,"data-testid":`device-rename`,icon:(0,Y.jsx)(be,{className:`size-4`}),onClick:()=>{d(null),s(e.name),a(e)},children:`Rename`}),(0,Y.jsx)(x,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Y.jsx)(Dt,{className:`size-4`}),onClick:()=>{v(null),p(e)},children:`Revoke`})]})]},e.id)})}):(0,Y.jsx)(b,{label:`Loading devices…`}),(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`The preferred mobile device receives push notifications when no desktop was recently active.`}),(0,Y.jsx)(W,{open:i!==null,onClose:()=>a(null),title:`Rename device`,confirmLabel:`Save`,danger:!1,busy:c,error:u,confirmDisabled:!o.trim(),onConfirm:E,children:(0,Y.jsx)(G,{"aria-label":`Device name`,maxLength:80,value:o,autoComplete:`off`,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&o.trim()&&!c&&E()}})}),(0,Y.jsxs)(W,{open:f!==null,onClose:()=>p(null),title:f?`Revoke ${f.name}?`:`Revoke device`,confirmLabel:`Revoke device`,busy:m,error:_,onConfirm:C,children:[(0,Y.jsx)(`p`,{className:`text-sm`,children:`Its credential stops working immediately and its push subscription is removed. To use it again, sign in on it again.`}),f?.id===n&&(0,Y.jsx)(`p`,{className:`text-sm font-medium text-danger`,children:`This is the device you are using now. Revoking it signs you out here.`})]})]})}function un(){let e=Ze(e=>e.sendWithEnter),t=Ze(e=>e.set),n=We(),r=He();Ke(e=>e.me);let i=je(),a=L(e=>i?e.devices[i]:void 0);return(0,Y.jsxs)(Z,{title:`This device`,description:`These preferences are stored in this browser only; your other devices keep their own.`,children:[(0,Y.jsx)(B,{title:`Composer`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsx)(nt,{label:`Send with Enter`,description:`On desktop, Enter sends the message and Shift+Enter inserts a newline. When off, Enter inserts a newline; send with the Send button.`,checked:e,onChange:e=>t(`sendWithEnter`,e)}),(0,Y.jsxs)(`p`,{className:`text-sm text-muted`,children:[`On mobile, Return always inserts a newline and messages are sent with the Send button.`,n===`mobile`||r?` That applies on this device now.`:``]})]})}),(0,Y.jsx)(B,{title:`Identity`,children:(0,Y.jsx)(It,{items:[[`Name`,a?.name??`Unknown`],[`Kind`,a?on[a.kind]:`Unknown`],[`Device ID`,(0,Y.jsx)(`span`,{className:`break-all font-mono`,children:i??`Unknown`},`id`)]]})})]})}var $=e=>e==null||e===``?`Unknown`:String(e);function dn(){let e=tt($t,Qt),t=e.data,n=Yt(Array.isArray(t?.diagnostics)?t.diagnostics:void 0),r=L(e=>e.hosts),i=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{icon:(0,Y.jsx)(ue,{className:`size-4`}),disabled:!t,onClick:()=>t&&le(JSON.stringify(t,null,2),`Diagnostics JSON copied`),children:`Copy diagnostics JSON`}),(0,Y.jsx)(x,{busy:e.loading&&!!t,icon:(0,Y.jsx)(ie,{className:`size-4`}),onClick:e.reload,children:`Refresh`})]}),a;if(e.fatal)a=(0,Y.jsx)(j,{error:e.error,diagnosticsHref:`/settings/diagnostics`});else if(e.error&&!e.loading&&!t)a=(0,Y.jsx)(O,{title:`Could not load diagnostics`,error:e.error,onRetry:e.reload});else if(!t)a=(0,Y.jsx)(b,{label:`Loading diagnostics…`});else{let i=t.migrationLevel!==void 0&&t.latestMigration!==void 0&&t.migrationLevel>=t.latestMigration,o=(t.hosts??[]).filter(e=>!e.revokedAt);a=(0,Y.jsxs)(Y.Fragment,{children:[e.error&&!e.loading?(0,Y.jsx)(O,{compact:!0,title:`Refresh failed`,error:e.error,onRetry:e.reload}):null,(0,Y.jsx)(B,{title:`Versions`,children:(0,Y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Y.jsxs)(`table`,{className:`w-full min-w-0 text-left text-sm`,children:[(0,Y.jsx)(`thead`,{children:(0,Y.jsxs)(`tr`,{className:`border-b border-border text-muted`,children:[(0,Y.jsx)(`th`,{scope:`col`,className:`py-1 pr-4 font-medium`,children:`Component`}),(0,Y.jsx)(`th`,{scope:`col`,className:`py-1 font-medium`,children:`Version`})]})}),(0,Y.jsxs)(`tbody`,{children:[Object.entries(t.versions).map(([e,t])=>(0,Y.jsxs)(`tr`,{className:`border-b border-border last:border-b-0`,children:[(0,Y.jsx)(`th`,{scope:`row`,className:`py-1 pr-4 font-normal capitalize`,children:e}),(0,Y.jsx)(`td`,{className:`py-1 font-mono break-all`,children:$(t)})]},e)),(0,Y.jsxs)(`tr`,{children:[(0,Y.jsx)(`th`,{scope:`row`,className:`py-1 pr-4 font-normal`,children:`Supported Pi`}),(0,Y.jsx)(`td`,{className:`py-1 font-mono`,children:m})]})]})]})})}),(0,Y.jsx)(B,{title:`Coordinator`,children:(0,Y.jsx)(It,{items:[[`Database migration`,(0,Y.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`span`,{children:[`Level `,$(t.migrationLevel),` of `,$(t.latestMigration)]}),i?(0,Y.jsx)(V,{icon:H,tone:`success`,label:`Up to date`}):(0,Y.jsx)(V,{icon:F,tone:`warning`,label:`Behind latest`})]},`m`)],[`Public URL`,(0,Y.jsx)(`span`,{className:`break-all`,children:$(t.publicUrl)},`u`)],[`Events`,t.events?`Seq ${$(t.events.minSeq)} to ${$(t.events.maxSeq)} stored (current ${$(t.events.currentSeq)}, oldest retained ${$(t.events.minRetainedSeq)})`:`Unknown`],[`Event retention`,t.events?.retentionDays==null?`Unknown`:`${t.events.retentionDays} days`],[`Push`,t.push?`${t.push.vapidConfigured?`VAPID keys configured`:`VAPID keys not configured`}, ${$(t.push.subscriptions)} subscription(s)`:`Unknown`],[`Connected clients`,`${$(t.clients?.connectedDevices)} device(s)`]]})}),(0,Y.jsx)(B,{title:`Hosts`,children:o.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No hosts enrolled.`}):(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:o.map(e=>{let t=r[e.id];return(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1 py-2 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,Y.jsx)(Fe,{kind:`host`,value:t?.connectivity??e.connectivity}),(0,Y.jsx)(Rt,{host:e})]}),(0,Y.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Agent `,$(e.agentVersion),` · Last seen `,T(e.lastSeenAt)]}),e.unsupported&&e.unsupported.length>0&&(0,Y.jsx)(`ul`,{className:`list-disc pl-5 text-xs text-muted`,children:e.unsupported.map(e=>(0,Y.jsxs)(`li`,{className:`break-words`,children:[e.capability,`: `,e.reason]},e.capability))})]},e.id)})})}),(0,Y.jsx)(B,{title:`Recent diagnostics`,children:n.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No diagnostics recorded.`}):(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:n.slice(0,100).map((e,t)=>(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-2 text-sm`,children:[(0,Y.jsx)(Jt,{level:e.level}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[e.message,e.adapterId&&(0,Y.jsxs)(`span`,{className:`block text-xs text-muted`,children:[`Adapter `,e.adapterId]})]}),(0,Y.jsx)(`time`,{dateTime:e.at,className:`text-xs text-muted`,children:w(e.at)})]},`${e.at}-${t}`))})})]})}return(0,Y.jsxs)(Z,{title:`Diagnostics`,description:`Versions, database state, hosts and recent problems. Copy the JSON when reporting a problem.`,actions:i,children:[(0,Y.jsx)(N,{}),a]})}function fn(e){return I(`/api/enrollments`,{kind:e})}function pn({expiresAt:e,onRenew:t,busy:n}){let r=Ht(e);return r!==null&&r<=0?(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,role:`status`,children:[(0,Y.jsx)(F,{"aria-hidden":!0,className:`size-4 shrink-0 text-warning`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:`Expired: create a new link`}),(0,Y.jsx)(x,{size:`sm`,busy:n,icon:(0,Y.jsx)(ie,{className:`size-4`}),onClick:t,children:`Create new link`})]}):(0,Y.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-muted`,children:[(0,Y.jsx)(Ie,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,Y.jsxs)(`span`,{children:[`Expires in`,` `,(0,Y.jsx)(`span`,{className:`font-mono tabular-nums`,children:r===null?`unknown`:Ut(r)}),`. Single use.`]})]})}function mn({busy:e,error:t,onRetry:n}){return e?(0,Y.jsx)(b,{label:`Creating a single-use link…`}):t?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(_,{error:t}),(0,Y.jsx)(x,{icon:(0,Y.jsx)(ie,{className:`size-4`}),onClick:n,children:`Retry`})]}):null}function hn(e){let t=Vt(e),n=t.find(e=>!M(e));return n?{folders:t,problem:`"${n}" is not an absolute path or a ~/ path.`}:t.length>20?{folders:t,problem:`Use at most 20 folders.`}:{folders:t,problem:null}}function gn(e,t=Date.now()){return e?e.state===`running`?`Scanning…`:e.state===`failed`?`Last scan failed ${T(e.finishedAt??e.startedAt,t)}: ${e.errors.at(-1)??`unknown error`}`:`Last scanned ${T(e.finishedAt,t)}: ${e.repositories} repositories, ${e.checkoutsAdded} new checkouts, ${e.projectsCreated} new projects.`:`Not scanned yet.`}function _n({host:e}){let t=(0,J.useId)(),n=(e.projectFolders??[]).join(`
|
|
3
|
+
`),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(null),d=r??n,f=r!==null&&r!==n,{folders:p,problem:m}=hn(d),h=e.projectScan,v=s||h?.state===`running`,y=e.connectivity===`connected`,b=n?y?v?`A scan is running`:null:`${e.name} is offline`:`Save a folder first`,S=async()=>{o(!0),u(null);try{await g(`/api/hosts/${encodeURIComponent(e.id)}`,{projectFolders:p}),U.success(`Project folders saved`),i(null)}catch(e){u(e)}finally{o(!1)}},C=async()=>{c(!0),u(null);try{let t=await I(`/api/hosts/${encodeURIComponent(e.id)}/scan-projects`);U.success(`Found ${t.repositories} repositories; ${t.projectsCreated} new projects`)}catch(e){u(e)}finally{c(!1)}},w=f?m:null;return(0,Y.jsx)(B,{title:`Project folders`,description:`Every Git repository directly inside these folders becomes a project, or another checkout of the project with the same remote. Folders are rescanned when the host connects and every 10 minutes; nothing is removed automatically.`,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsx)(z,{id:`${t}-folders`,label:`Folders on this host`,hint:`One per line: an absolute path or ~/..., e.g. ~/Projects.`,error:w,children:(0,Y.jsx)($e,{id:`${t}-folders`,value:d,onChange:e=>i(e.target.value),minRows:3,placeholder:`~/Projects`,className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,...R(`${t}-folders`,{hint:!0,error:w})})}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(x,{variant:`primary`,icon:(0,Y.jsx)(Ee,{className:`size-4`}),busy:a,disabled:!f||!!m,onClick:S,children:`Save folders`}),(0,Y.jsx)(x,{icon:(0,Y.jsx)(_t,{className:`size-4`}),busy:s,disabled:!!b,title:b??void 0,onClick:C,children:`Scan now`})]}),(0,Y.jsx)(`p`,{"aria-live":`polite`,className:`text-sm text-muted`,children:s?`Scanning…`:gn(h)}),h&&h.state!==`running`&&h.errors.length>0&&(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-0.5 text-xs text-muted`,children:h.errors.map(e=>(0,Y.jsx)(`li`,{className:`break-words`,children:e},e))}),(0,Y.jsx)(_,{error:l})]})})}var vn={prompt:`Prompt`,steer:`Steer a running turn`,followUp:`Queue follow-up`,abort:`Abort`,resume:`Resume`,rename:`Rename session`,importInactive:`Import inactive sessions`,extensionDialogs:`Extension dialogs`,customUi:`Custom extension UI`,widgetsText:`Text widgets`,widgetsComponent:`Component widgets`,tokenAccounting:`Token accounting`,costAccounting:`Cost accounting`};function yn(){let e=Q(),t=d(),[n,r]=(0,J.useState)(!1),i=t.filter(e=>e.connectivity!==`connected`);return(0,Y.jsxs)(Z,{testId:`settings-hosts`,title:`Hosts`,description:`Machines that run Pi sessions through the Switchyard host agent.`,actions:(0,Y.jsx)(x,{variant:`primary`,icon:(0,Y.jsx)(Se,{className:`size-4`}),onClick:()=>r(!0),children:`Add host`}),children:[(0,Y.jsx)(N,{}),e?t.length===0?(0,Y.jsx)(P,{icon:(0,Y.jsx)(ke,{className:`size-8`}),title:`No hosts yet`,description:`Add a host to run Pi sessions. You will get a command to run on that machine.`,action:{label:`Add host`,onClick:()=>r(!0)}}):(0,Y.jsxs)(Y.Fragment,{children:[i.length===1&&(0,Y.jsx)(D,{compact:!0,hostName:i[0].name,connectivity:i[0].connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:i[0].lastSeenAt}),i.length>1&&(0,Y.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border border-border bg-danger-soft px-3 py-2 text-sm`,children:[(0,Y.jsx)(ae,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-danger`}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`font-medium`,children:bn(i.map(e=>e.name))}),(0,Y.jsx)(`div`,{className:`text-muted`,children:`Work on them keeps its last known state; nothing is restarted elsewhere.`})]})]}),(0,Y.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:t.map(e=>(0,Y.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,Y.jsx)(xn,{host:e})},e.id))})]}):(0,Y.jsx)(b,{label:`Loading hosts…`}),(0,Y.jsx)(wn,{open:n,onClose:()=>r(!1)})]})}function bn(e){return`${e.length} hosts are not connected: ${e.join(`, `)}`}function xn({host:e}){return(0,Y.jsxs)(r,{to:X(`hosts/${encodeURIComponent(e.id)}`),state:Te,className:`tap flex min-w-0 items-center gap-3 px-4 py-3 hover:bg-surface-2`,children:[(0,Y.jsx)(ke,{"aria-hidden":!0,className:`size-5 shrink-0 self-center text-muted`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 break-words font-medium`,children:e.name}),(0,Y.jsx)(`span`,{className:`text-sm text-muted`,children:Lt[e.platform]})]}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(Fe,{kind:`host`,value:e.connectivity}),(0,Y.jsx)(Rt,{host:e}),e.connectivity!==`connected`&&(0,Y.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Last seen `,T(e.lastSeenAt)]})]})]}),(0,Y.jsx)(ve,{"aria-hidden":!0,className:`size-4 shrink-0 self-center text-subtle`})]})}var Sn=`@spencerboucher/switchyard`;function Cn(e){return[`npm install -g ${Sn}`,e,`switchyard host install-service`].join(`
|
|
4
|
+
`)}function wn({open:e,onClose:t}){let[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(null),c=async()=>{a(!0),s(null);try{r(await fn(`host`))}catch(e){s(e)}finally{a(!1)}},l=()=>{r(null),s(null),t()};return(0,Y.jsx)(Qe,{open:e,onClose:l,title:`Add host`,description:`Enroll a machine that runs Pi. Provider credentials stay on that machine.`,footer:(0,Y.jsx)(x,{onClick:l,children:`Done`}),children:(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[!n&&!i&&!o&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`text-sm`,children:`Create a single-use enrollment, then run the command it shows on the new host. The host appears here once its agent connects.`}),(0,Y.jsx)(x,{variant:`primary`,onClick:c,children:`Create enrollment command`})]}),(0,Y.jsx)(mn,{busy:i,error:o,onRetry:c}),n&&!i&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`text-sm`,children:`Run this on the host, as the user that should run Pi (it needs Node 24 or newer, git and Pi):`}),(0,Y.jsx)(de,{text:n.command?Cn(n.command):n.url,label:n.command?`Host setup commands`:`Host enrollment link`,copyLabel:`Copy commands`}),(0,Y.jsx)(pn,{expiresAt:n.expiresAt,onRenew:c,busy:i})]})]})})}function Tn(){let{hostId:e=``}=c(),t=Q(),r=L(t=>t.hosts[e]),i=L(t=>t.adapters[e]),a=L(e=>e.checkouts),o=L(e=>e.projects),s=n(),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(null),h=(0,J.useMemo)(()=>Object.values(a).filter(t=>t.hostId===e).sort((e,t)=>e.path.localeCompare(t.path)),[a,e]),g={to:X(`hosts`),label:`Hosts`};if(!t)return(0,Y.jsx)(Z,{title:`Host`,back:g,children:(0,Y.jsx)(b,{label:`Loading host…`})});if(!r||r.revokedAt)return(0,Y.jsx)(Z,{title:`Host`,back:g,children:(0,Y.jsx)(P,{icon:(0,Y.jsx)(ke,{className:`size-8`}),title:r?`This host was revoked`:`Host not found`,description:r?`${r.name} was revoked ${T(r.revokedAt)}. Add it again to use it.`:`It may have been revoked or never enrolled with this coordinator.`,action:{label:`Back to hosts`,to:X(`hosts`)}})});let _=async()=>{f(!0),m(null);try{await I(`/api/hosts/${encodeURIComponent(r.id)}/revoke`),U.success(`Host ${r.name} revoked`),u(!1),s(X(`hosts`))}catch(e){m(e)}finally{f(!1)}},y=r.capabilities,S=e=>y?.unsupported.find(t=>t.capability===e)?.reason,C=y?.unsupported.filter(e=>!v.includes(e.capability))??[];return(0,Y.jsxs)(Z,{title:r.name,description:`${Lt[r.platform]} host`,back:g,children:[(0,Y.jsx)(N,{}),r.connectivity!==`connected`&&(0,Y.jsx)(D,{compact:!0,hostName:r.name,connectivity:r.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:r.lastSeenAt}),(0,Y.jsx)(B,{title:`Connectivity and versions`,children:(0,Y.jsx)(It,{items:[[`Status`,(0,Y.jsx)(Fe,{kind:`host`,value:r.connectivity},`s`)],[`Last seen`,r.lastSeenAt?`${T(r.lastSeenAt)} (${w(r.lastSeenAt)})`:`Never`],[`Platform`,Lt[r.platform]],[`Agent version`,(0,Y.jsx)(`span`,{className:`font-mono`,children:r.agentVersion},`a`)],[`Pi`,(0,Y.jsx)(Rt,{host:r},`p`)],[`Enrolled`,w(r.createdAt)]]})}),(0,Y.jsx)(B,{title:`Capabilities`,description:`What Pi on this host supports. Unsupported features are hidden or explained in sessions.`,children:y?(0,Y.jsxs)(`ul`,{className:`grid min-w-0 gap-2 sm:grid-cols-2`,children:[v.map(e=>{let t=y[e],n=S(e);return(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[t?(0,Y.jsx)(H,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-success`}):(0,Y.jsx)(Ne,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:vn[e]}),(0,Y.jsxs)(`span`,{className:`text-muted`,children:[`: `,t?`Supported`:`Not supported`]}),!t&&n&&(0,Y.jsx)(`span`,{className:`block break-words text-xs text-muted`,children:n})]})]},e)}),C.map(e=>(0,Y.jsxs)(`li`,{className:`flex min-w-0 items-start gap-2 text-sm`,children:[(0,Y.jsx)(Ne,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0 text-muted`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`font-medium break-words`,children:e.capability}),(0,Y.jsx)(`span`,{className:`text-muted`,children:`: Not supported`}),(0,Y.jsx)(`span`,{className:`block break-words text-xs text-muted`,children:e.reason})]})]},e.capability))]}):(0,Y.jsx)(ne,{capability:`Capability report`,reason:`This host has not reported its Pi capabilities yet. It may be offline, or Pi may be missing or incompatible.`})}),(0,Y.jsx)(_n,{host:r}),(0,Y.jsx)(B,{title:`Checkout mappings`,description:`Project clones on this host. Sessions and runs for a project use these paths.`,children:h.length===0?(0,Y.jsx)(P,{className:`py-4`,title:`No checkouts on this host`,description:`Create a project or add a checkout to an existing project.`,action:{label:`Open projects`,to:X(`projects`)}}):(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:h.map(e=>(0,Y.jsxs)(`li`,{className:`min-w-0 py-2 text-sm`,children:[(0,Y.jsx)(et,{to:X(`projects/${encodeURIComponent(e.projectId)}`),variant:`action`,children:o[e.projectId]?.name??`Unknown project`}),(0,Y.jsx)(`div`,{className:`break-all font-mono text-xs`,children:e.path}),(0,Y.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Default branch: `,e.defaultBranch]})]},e.id))})}),(0,Y.jsx)(B,{title:`Adapters`,actions:(0,Y.jsx)(et,{to:X(`adapters`),size:`sm`,variant:`action`,children:`All adapters`}),children:!i||i.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No adapters reported by this host.`}):(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:i.map(e=>(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-center gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`break-all font-mono`,children:e.id}),(0,Y.jsx)(`span`,{className:`text-muted`,children:e.version}),(0,Y.jsx)(Gt,{status:e.status})]},e.id))})}),(0,Y.jsx)(De,{description:`Revoking disconnects the host agent and invalidates its credential. Sessions on it are not moved elsewhere.`,children:(0,Y.jsx)(x,{variant:`danger`,icon:(0,Y.jsx)(Dt,{className:`size-4`}),onClick:()=>{m(null),u(!0)},children:`Revoke host`})}),(0,Y.jsx)(W,{open:l,onClose:()=>u(!1),title:`Revoke ${r.name}?`,confirmLabel:`Revoke host`,busy:d,error:p,onConfirm:_,children:(0,Y.jsx)(`p`,{className:`text-sm`,children:`The host agent is disconnected and its credential stops working. Sessions on it are not moved or restarted elsewhere. To use this machine again, add it as a new host.`})})]})}var En={granted:{icon:dt,label:`Allowed`,tone:`success`,guidance:`This device can show Switchyard notifications.`},denied:{icon:lt,label:`Blocked`,tone:`danger`,guidance:`Notifications are blocked for this site. Allow them in your browser's site settings (or the system notification settings for the Home Screen app), then reload.`},default:{icon:ze,label:`Not requested yet`,tone:`neutral`,guidance:`Enable notifications to hear about sessions that need input, failed, or are ready for review.`},unknown:{icon:ze,label:`Unknown`,tone:`neutral`,guidance:`The browser did not report a permission state. Try enabling notifications.`},unsupported:{icon:Ne,label:`Not supported`,tone:`warning`,guidance:`This browser cannot receive web push here. On iPhone and iPad, add Switchyard to the Home Screen first.`}};function Dn(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{return`UTC`}}function On(e){let t=K(e)&&K(e.settings)?e.settings:e;return!K(t)||typeof t.privatePreviews!=`boolean`?null:{quietHours:K(t.quietHours)?t.quietHours:null,privatePreviews:t.privatePreviews,preferredDeviceId:typeof t.preferredDeviceId==`string`?t.preferredDeviceId:null}}function kn(){let[e,t]=(0,J.useState)(()=>Ue()),[n,r]=(0,J.useState)(null),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),c=Ge()&&!Je();(0,J.useEffect)(()=>{let e=!0;Xe().then(t=>e&&r(t!==null)).catch(()=>e&&r(!1));let n=()=>{document.visibilityState===`visible`&&t(Ue())};return document.addEventListener(`visibilitychange`,n),()=>{e=!1,document.removeEventListener(`visibilitychange`,n)}},[]);let l=()=>{a(`enable`),s(null),qe().then(e=>{t(e),e===`granted`?(r(!0),U.success(`Notifications enabled on this device`)):e===`denied`&&U.error(`Notifications were blocked. Allow them in your browser settings.`)}).catch(e=>{s(e),t(Ue())}).finally(()=>a(null))},u=async()=>{a(`disable`),s(null);try{await Ye(),r(!1),U.success(`Notifications disabled on this device`)}catch(e){s(e)}finally{a(null)}},d=async()=>{a(`test`),s(null);try{await Be(),U.success(`Test notification sent. It can take a few seconds to arrive.`)}catch(e){s(e),U.error(`Test notification failed: ${oe(e)}`)}finally{a(null)}},f=En[e]??En.unknown;return(0,Y.jsxs)(Z,{testId:`settings-notifications`,title:`Notifications`,description:`Push notifications for sessions that need input, failed, or are ready for review.`,children:[(0,Y.jsx)(B,{title:`This device`,children:(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:`Permission:`}),(0,Y.jsx)(V,{icon:f.icon,label:f.label,tone:f.tone}),n!==null&&e===`granted`&&(0,Y.jsx)(`span`,{className:`text-muted`,children:n?`Subscribed to push`:`Not subscribed to push`})]}),(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:f.guidance}),c&&(0,Y.jsxs)(`div`,{className:`rounded-md border border-border bg-surface-2 p-3 text-sm`,children:[(0,Y.jsxs)(`p`,{className:`mb-2 flex items-center gap-2 font-medium`,children:[(0,Y.jsx)(kt,{"aria-hidden":!0,className:`size-4 shrink-0`}),`On iPhone and iPad, notifications need the Home Screen app`]}),(0,Y.jsxs)(`ol`,{className:`list-decimal space-y-1 pl-5`,children:[(0,Y.jsx)(`li`,{children:`Tap Share`}),(0,Y.jsx)(`li`,{children:`Add to Home Screen`}),(0,Y.jsx)(`li`,{children:`Open Switchyard from the Home Screen`}),(0,Y.jsx)(`li`,{children:`Enable notifications here`})]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e!==`unsupported`&&!(e===`granted`&&n)&&(0,Y.jsx)(x,{variant:`primary`,icon:(0,Y.jsx)(dt,{className:`size-4`}),busy:i===`enable`,disabled:i!==null&&i!==`enable`,onClick:l,children:`Enable notifications`}),n&&(0,Y.jsx)(x,{icon:(0,Y.jsx)(lt,{className:`size-4`}),busy:i===`disable`,disabled:i!==null&&i!==`disable`,onClick:u,children:`Disable on this device`}),(0,Y.jsx)(x,{icon:(0,Y.jsx)(pe,{className:`size-4`}),busy:i===`test`,disabled:i!==null&&i!==`test`,onClick:d,children:`Send test notification`})]}),e===`unsupported`&&(0,Y.jsx)(`p`,{className:`text-xs text-muted`,children:`Enabling is not possible in this browser. A test notification still goes to your other subscribed devices.`}),(0,Y.jsx)(_,{error:o}),(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`Delivery and clearing are best effort: browsers and operating systems may delay, group or keep notifications even after you answer elsewhere.`})]})}),(0,Y.jsx)(An,{})]})}function An(){let e=tt(`/api/me/notification-settings`,e=>!!On(e)),t=(0,J.useMemo)(()=>e.data?On(e.data):null,[e.data]),n=e.error instanceof A&&e.error.status===404;return(0,Y.jsx)(B,{title:`Delivery preferences`,description:`Shared by all your devices. Attention items in Switchyard are unaffected.`,children:n?(0,Y.jsx)(ne,{capability:`Notification settings`,reason:`This coordinator does not expose notification settings yet`}):e.fatal?(0,Y.jsx)(j,{error:e.error}):e.error&&!e.loading&&!t?(0,Y.jsx)(O,{compact:!0,title:`Could not load notification settings`,error:e.error,onRetry:e.reload}):t?(0,Y.jsx)(Mn,{settings:t,onSaved:t=>e.setData(t)}):(0,Y.jsx)(b,{label:`Loading notification settings…`})})}var jn=/^\d{2}:\d{2}$/;function Mn({settings:e,onSaved:t}){let n=(0,J.useId)(),r=L(e=>e.devices),i=(0,J.useMemo)(()=>Object.values(r).filter(e=>e.revokedAt===null).sort((e,t)=>e.name.localeCompare(t.name)),[r]),[a,o]=(0,J.useState)(e.quietHours!==null),[s,c]=(0,J.useState)(e.quietHours?.start??`22:00`),[l,u]=(0,J.useState)(e.quietHours?.end??`07:00`),[d,f]=(0,J.useState)(e.quietHours?.timezone??Dn()),[p,m]=(0,J.useState)(e.privatePreviews),[h,v]=(0,J.useState)(e.preferredDeviceId??``),[y,b]=(0,J.useState)(!1),[S,C]=(0,J.useState)(null),w=a&&!jn.test(s)?`Use a time like 22:00.`:null,T=a&&!jn.test(l)?`Use a time like 07:00.`:null,E=a&&!d.trim()?`Enter a time zone, e.g. Europe/Berlin.`:null,D=!h||i.some(e=>e.id===h);return(0,Y.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:async e=>{if(e.preventDefault(),w||T||E)return;let n={quietHours:a?{start:s,end:l,timezone:d.trim()}:null,privatePreviews:p,preferredDeviceId:h||null};b(!0),C(null);try{t(On(await g(`/api/me/notification-settings`,n))??n),U.success(`Notification preferences saved`)}catch(e){C(e)}finally{b(!1)}},noValidate:!0,children:[(0,Y.jsx)(nt,{label:`Quiet hours`,description:`No push notifications during these hours. Attention items still collect in Switchyard.`,checked:a,onChange:o}),a&&(0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-3`,children:[(0,Y.jsx)(z,{id:`${n}-start`,label:`From`,error:w,children:(0,Y.jsx)(G,{id:`${n}-start`,type:`time`,value:s,onChange:e=>c(e.target.value),...R(`${n}-start`,{error:w})})}),(0,Y.jsx)(z,{id:`${n}-end`,label:`Until`,error:T,children:(0,Y.jsx)(G,{id:`${n}-end`,type:`time`,value:l,onChange:e=>u(e.target.value),...R(`${n}-end`,{error:T})})}),(0,Y.jsx)(z,{id:`${n}-tz`,label:`Time zone`,error:E,children:(0,Y.jsx)(G,{id:`${n}-tz`,value:d,onChange:e=>f(e.target.value),autoCapitalize:`off`,spellCheck:!1,...R(`${n}-tz`,{error:E})})})]}),(0,Y.jsx)(nt,{label:`Private previews`,description:`Hide task and session text in notifications; show only the status, e.g. Needs input.`,checked:p,onChange:m}),(0,Y.jsx)(z,{id:`${n}-device`,label:`Preferred device`,hint:`Receives push when no desktop was recently active.`,children:(0,Y.jsxs)(q,{id:`${n}-device`,value:h,onChange:e=>v(e.target.value),...R(`${n}-device`,{hint:!0}),children:[(0,Y.jsx)(`option`,{value:``,children:`Automatic (the preferred mobile device)`}),i.map(e=>(0,Y.jsxs)(`option`,{value:e.id,children:[e.name,e.push.subscribed?``:` (no push subscription)`]},e.id)),!D&&(0,Y.jsxs)(`option`,{value:h,children:[`Unknown device (`,h,`)`]})]})}),(0,Y.jsx)(_,{error:S}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(x,{type:`submit`,variant:`primary`,busy:y,icon:(0,Y.jsx)(Ee,{className:`size-4`}),children:`Save preferences`})})]})}var Nn={ask:`Ask`,approve:`Approve`,ignore:`Ignore`},Pn={ask:`Ask before trusting project-local Pi settings and extensions.`,approve:`Trust project-local Pi settings and extensions automatically.`,ignore:`Never load project-local Pi settings or extensions.`},Fn=re.options,In={all:`Loads your extensions, skills and prompt templates.`,vanilla:`Starts Pi with --no-extensions --no-skills --no-prompt-templates (also no built-in MCP). Your logins, default model and AGENTS.md still apply, and Switchyard's model, effort, context and command controls keep working.`};function Ln(e){let t=[];return e.forEach((e,n)=>{let r=te.safeParse(e);r.success||t.push(`Line ${n+1} (${e}): ${r.error.issues[0]?.message??`invalid argument`}`)}),t}function Rn(){let e=Q(),t=L(e=>e.profiles),n=L(e=>e.projects),r=(0,J.useMemo)(()=>Object.values(t).sort((e,t)=>e.name.localeCompare(t.name)),[t]),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(null),f=async()=>{if(o){l(!0),d(null);try{await E(`/api/profiles/${encodeURIComponent(o.id)}`),U.success(`Profile ${o.name} deleted`),s(null)}catch(e){d(e)}finally{l(!1)}}},p=e=>Object.values(n).filter(t=>t.defaultProfileId===e).map(e=>e.name);return(0,Y.jsxs)(Z,{title:`Pi profiles`,description:`Presets for provider, model, thinking level and Pi flags. Sessions keep a snapshot of the profile they started with.`,actions:(0,Y.jsx)(x,{variant:`primary`,icon:(0,Y.jsx)(Se,{className:`size-4`}),onClick:()=>a(`new`),children:`New profile`}),children:[(0,Y.jsx)(N,{}),e?r.length===0?(0,Y.jsx)(P,{icon:(0,Y.jsx)(ge,{className:`size-8`}),title:`No profiles`,description:`Create a profile to choose a provider and model for sessions.`,action:{label:`New profile`,onClick:()=>a(`new`)}}):(0,Y.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:r.map(e=>{let t=p(e.id);return(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-wrap items-start gap-3 border-b border-border px-4 py-3 last:border-b-0`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 text-sm`,children:[(0,Y.jsx)(`span`,{className:`break-words font-medium`,children:e.name}),(0,Y.jsxs)(`span`,{className:`break-words text-muted`,children:[e.provider??`Default provider`,` / `,e.model??`default model`,` · Thinking`,` `,e.thinking??`default`,` · Project trust `,Nn[e.projectTrust],e.resources===`vanilla`&&` · Vanilla Pi`]}),e.extraArgs.length>0&&(0,Y.jsx)(`span`,{className:`break-all font-mono text-xs text-muted`,children:e.extraArgs.join(` `)}),t.length>0&&(0,Y.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Default for `,t.join(`, `)]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(x,{size:`sm`,icon:(0,Y.jsx)(be,{className:`size-4`}),onClick:()=>a(e),children:`Edit`}),(0,Y.jsx)(x,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Y.jsx)(ce,{className:`size-4`}),onClick:()=>{d(null),s(e)},children:`Delete`})]})]},e.id)})}):(0,Y.jsx)(b,{label:`Loading profiles…`}),i&&(0,Y.jsx)(zn,{profile:i===`new`?null:i,onClose:()=>a(null)},i===`new`?`new`:i.id),(0,Y.jsx)(W,{open:o!==null,onClose:()=>s(null),title:o?`Delete ${o.name}?`:`Delete profile`,confirmLabel:`Delete profile`,busy:c,error:u,onConfirm:f,children:(0,Y.jsx)(`p`,{className:`text-sm`,children:`Existing sessions keep their snapshot of this profile. Projects that use it as their default must be changed first.`})})]})}function zn({profile:e,onClose:t}){let n=(0,J.useId)(),[r,i]=(0,J.useState)(e?.name??``),[a,o]=(0,J.useState)(e?.provider??``),[s,c]=(0,J.useState)(e?.model??``),[l,u]=(0,J.useState)(e?.thinking??``),[d,f]=(0,J.useState)(e?.projectTrust??`ask`),[p,m]=(0,J.useState)(e?.resources??`all`),[h,v]=(0,J.useState)((e?.extraArgs??[]).join(`
|
|
5
|
+
`)),[y,b]=(0,J.useState)(!1),[S,C]=(0,J.useState)(!1),[w,T]=(0,J.useState)(null),E=Vt(h),D=Ln(E),O=y&&!r.trim()?`Enter a profile name.`:null,ee=D.length?D.join(`
|
|
6
|
+
`):null,k=async n=>{if(n.preventDefault(),b(!0),!r.trim()||D.length)return;let i={name:r.trim(),provider:a.trim()||null,model:s.trim()||null,thinking:l||null,projectTrust:d,resources:p,extraArgs:E};C(!0),T(null);try{e?(await g(`/api/profiles/${encodeURIComponent(e.id)}`,i),U.success(`Profile ${i.name} saved`)):(await I(`/api/profiles`,i),U.success(`Profile ${i.name} created`)),t()}catch(e){T(e)}finally{C(!1)}},A=`${n}-form`;return(0,Y.jsx)(Qe,{open:!0,onClose:S?()=>void 0:t,dismissOnBackdrop:!S,title:e?`Edit ${e.name}`:`New profile`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{onClick:t,disabled:S,children:`Cancel`}),(0,Y.jsx)(x,{type:`submit`,form:A,variant:`primary`,busy:S,children:e?`Save profile`:`Create profile`})]}),children:(0,Y.jsxs)(`form`,{id:A,className:`flex min-w-0 flex-col gap-4`,onSubmit:k,noValidate:!0,children:[(0,Y.jsx)(z,{id:`${n}-name`,label:`Name`,error:O,children:(0,Y.jsx)(G,{id:`${n}-name`,value:r,onChange:e=>i(e.target.value),...R(`${n}-name`,{error:O})})}),(0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,Y.jsx)(z,{id:`${n}-provider`,label:`Provider`,hint:`Empty uses Pi's default.`,children:(0,Y.jsx)(G,{id:`${n}-provider`,value:a,onChange:e=>o(e.target.value),placeholder:`anthropic`,autoCapitalize:`off`,spellCheck:!1,...R(`${n}-provider`,{hint:!0})})}),(0,Y.jsx)(z,{id:`${n}-model`,label:`Model`,hint:`Empty uses Pi's default.`,children:(0,Y.jsx)(G,{id:`${n}-model`,value:s,onChange:e=>c(e.target.value),autoCapitalize:`off`,spellCheck:!1,...R(`${n}-model`,{hint:!0})})})]}),(0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,Y.jsx)(z,{id:`${n}-thinking`,label:`Thinking`,children:(0,Y.jsxs)(q,{id:`${n}-thinking`,value:l,onChange:e=>u(e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:`Default (none)`}),Fn.map(e=>(0,Y.jsx)(`option`,{value:e,children:e},e))]})}),(0,Y.jsx)(z,{id:`${n}-trust`,label:`Project trust`,hint:Pn[d],children:(0,Y.jsx)(q,{id:`${n}-trust`,value:d,onChange:e=>f(e.target.value),...R(`${n}-trust`,{hint:!0}),children:Object.keys(Nn).map(e=>(0,Y.jsx)(`option`,{value:e,children:Nn[e]},e))})})]}),(0,Y.jsx)(z,{id:`${n}-resources`,label:`Resources`,hint:In[p],children:(0,Y.jsxs)(q,{id:`${n}-resources`,value:p,onChange:e=>m(e.target.value),...R(`${n}-resources`,{hint:!0}),children:[(0,Y.jsx)(`option`,{value:`all`,children:`Your Pi setup`}),(0,Y.jsx)(`option`,{value:`vanilla`,children:`Vanilla Pi`})]})}),(0,Y.jsx)(z,{id:`${n}-extra`,label:`Extra Pi arguments`,hint:`One long flag per line, e.g. --max-turns=40. Session, mode and extension flags are managed by Switchyard.`,error:ee,children:(0,Y.jsx)($e,{id:`${n}-extra`,value:h,minRows:3,onChange:e=>v(e.target.value),className:`font-mono`,autoCapitalize:`off`,spellCheck:!1,...R(`${n}-extra`,{hint:!0,error:ee})})}),(0,Y.jsx)(_,{error:w})]})})}var Bn={managed:`Managed by Switchyard`,discovered:`Discovered worktree`,main:`Main checkout`},Vn={none:{icon:Re,label:`No setup`,tone:`neutral`},running:{icon:Pe,label:`Setup running`,tone:`info`},succeeded:{icon:H,label:`Setup succeeded`,tone:`success`},failed:{icon:Le,label:`Setup failed`,tone:`danger`}};function Hn(e){let t=[e.dirty?`Uncommitted changes (${e.changedFiles} file${e.changedFiles===1?``:`s`})`:`Clean`];return(e.ahead||e.behind)&&t.push(`${e.ahead} ahead, ${e.behind} behind`),t.push(e.unmerged?`Not merged into base`:`Merged`),t.join(` · `)}function Un({project:e}){let t=L(e=>e.workspaces),n=L(e=>e.hosts),r=(0,J.useMemo)(()=>Object.values(t).filter(t=>t.projectId===e.id&&t.archivedAt===null).sort((e,t)=>Number(t.provenance===`main`)-Number(e.provenance===`main`)||(e.branch??``).localeCompare(t.branch??``)),[t,e.id]),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),c=async e=>{s(e.id);try{await I(`/api/workspaces/${encodeURIComponent(e.id)}/refresh`),U.success(`Workspace status refreshed`)}catch(e){U.error(`Could not refresh: ${oe(e)}`)}finally{s(null)}};return(0,Y.jsxs)(B,{title:`Workspaces`,description:`Worktrees where sessions and runs work. Removing one never deletes its branch.`,children:[r.length===0?(0,Y.jsx)(P,{className:`py-4`,title:`No workspaces`,description:`Workspaces appear after a checkout is discovered. Use Refresh to discover them again.`}):(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:r.map(e=>{let t=n[e.hostId],r=t?.connectivity!==`connected`,i=Vn[e.setup.state]??Vn.none;return(0,Y.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1.5 py-3 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(ye,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),(0,Y.jsx)(`span`,{className:`min-w-0 break-all font-mono font-medium`,children:e.branch??`(detached HEAD)`}),(0,Y.jsx)(`span`,{className:`text-xs text-muted`,children:Bn[e.provenance]})]}),(0,Y.jsxs)(`div`,{className:`break-all font-mono text-xs text-muted`,children:[t?.name?`${t.name}: `:``,e.path]}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{children:Hn(e.git)}),(0,Y.jsx)(V,{icon:i.icon,label:i.label,tone:i.tone,spin:e.setup.state===`running`})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(x,{size:`sm`,icon:(0,Y.jsx)(ie,{className:`size-4`}),busy:o===e.id,disabled:r,onClick:()=>c(e),children:`Refresh status`}),e.provenance!==`main`&&(0,Y.jsx)(x,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Y.jsx)(ce,{className:`size-4`}),disabled:r,onClick:()=>a(e),children:`Remove`}),e.provenance===`main`&&(0,Y.jsx)(`span`,{className:`text-xs text-muted`,children:`The main checkout cannot be removed; remove the project's checkout instead.`}),r&&(0,Y.jsxs)(`span`,{className:`text-xs text-muted`,children:[`Host `,t?.name??`unknown`,` is `,t?.connectivity??`unknown`,`: refresh and removal need it online.`]})]})]},e.id)})}),i&&(0,Y.jsx)(Wn,{workspace:t[i.id]??i,onClose:()=>a(null)},i.id)]})}function Wn({workspace:e,onClose:t}){let[n,r]=(0,J.useState)(e.git.dirty),[i,a]=(0,J.useState)(e.git.unmerged),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(null),m=n&&!o||i&&!c;return(0,Y.jsxs)(W,{open:!0,onClose:t,title:`Remove workspace?`,description:(0,Y.jsx)(`span`,{className:`break-all font-mono`,children:e.branch??e.path}),confirmLabel:`Remove workspace`,busy:u,error:f,onConfirm:async()=>{d(!0),p(null);try{await I(`/api/workspaces/${encodeURIComponent(e.id)}/remove`,{force:{dirty:o,unmerged:c}}),U.success(`Workspace ${e.branch??e.path} removed`),t()}catch(e){y(e,`workspace_dirty`)&&r(!0),y(e,`workspace_unmerged`)&&a(!0),p(e)}finally{d(!1)}},confirmDisabled:m,disabledReason:`Check the boxes above to confirm what will be lost.`,children:[(0,Y.jsxs)(`p`,{className:`text-sm`,children:[`The worktree at `,(0,Y.jsx)(`span`,{className:`break-all font-mono`,children:e.path}),` is deleted from the host. The branch is kept.`]}),n&&(0,Y.jsx)(rt,{label:`Discard uncommitted changes`,description:e.git.dirty?`${e.git.changedFiles} changed file${e.git.changedFiles===1?``:`s`} will be lost.`:`The host reported uncommitted changes; they will be lost.`,checked:o,onChange:s}),i&&(0,Y.jsx)(rt,{label:`Remove although the branch is not merged`,description:`Commits stay on the branch, but the workspace is gone.`,checked:c,onChange:l})]})}var Gn=`Inside the repository, for example .worktrees or .git/worktrees-switchyard`;function Kn(e){let t=e.trim();return t?t.startsWith(`/`)||/^[A-Za-z]:/.test(t)||t.includes(`\\`)?`Use a relative path inside the repository, e.g. .worktrees.`:t.split(`/`).includes(`..`)?`The folder must stay inside the repository (no ..).`:S.safeParse(t).success?null:`Use a plain relative path such as .worktrees (no empty or . segments).`:`Enter a folder inside the repository, e.g. .worktrees.`}function qn(){let{projectId:e=``}=c(),t=Q(),n=L(t=>t.projects[e]),r=L(e=>e.hosts),i=L(e=>e.profiles),[a,o]=(0,J.useState)(!1),[s,l]=(0,J.useState)([]),u=d(),f=(0,J.useMemo)(()=>Object.values(i).sort((e,t)=>e.name.localeCompare(t.name)),[i]),p={to:X(`projects`),label:`Projects`};return t?n?(0,Y.jsxs)(Z,{title:n.name,description:(0,Y.jsx)(`span`,{className:`break-all`,title:n.repoIdentity,children:me(n.repoIdentity)}),back:p,actions:(0,Y.jsx)(x,{busy:a,icon:(0,Y.jsx)(ie,{className:`size-4`}),onClick:async()=>{o(!0);try{let e=await I(`/api/projects/${encodeURIComponent(n.id)}/refresh`),t=Array.isArray(e?.errors)?e.errors:[];l(t),t.length?U.error(`Refreshed with ${t.length} checkout error(s)`):U.success(`Workspaces refreshed`)}catch(e){U.error(`Refresh failed: ${oe(e)}`)}finally{o(!1)}},children:`Refresh`}),children:[(0,Y.jsx)(N,{}),s&&s.length>0&&(0,Y.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-border bg-danger-soft px-3 py-2 text-sm`,children:[(0,Y.jsx)(`p`,{className:`font-medium`,children:`Some checkouts could not be refreshed`}),(0,Y.jsx)(`ul`,{className:`list-disc pl-5`,children:s.map(e=>(0,Y.jsx)(`li`,{className:`break-words`,children:e.message},e.checkoutId))})]}),(0,Y.jsx)(Jn,{project:n,hosts:u,profiles:f},n.id),(0,Y.jsx)(Yn,{project:n,hosts:u,hostsById:r}),(0,Y.jsx)(Un,{project:n})]}):(0,Y.jsx)(Z,{title:`Project`,back:p,children:(0,Y.jsx)(P,{icon:(0,Y.jsx)(fe,{className:`size-8`}),title:`Project not found`,description:`It may have been removed, or this link is from another coordinator.`,action:{label:`Back to projects`,to:X(`projects`)}})}):(0,Y.jsx)(Z,{title:`Project`,back:p,children:(0,Y.jsx)(b,{label:`Loading project…`})})}function Jn({project:e,hosts:t,profiles:n}){let r=(0,J.useId)(),[i,a]=(0,J.useState)(e.name),[o,s]=(0,J.useState)(e.setupCommand??``),[c,l]=(0,J.useState)(e.checks.join(`
|
|
7
|
+
`)),[u,d]=(0,J.useState)(String(e.maxConcurrentRuns)),[f,p]=(0,J.useState)(e.automationEnabled),[m,h]=(0,J.useState)(e.workspaceSharing),[v,y]=(0,J.useState)(e.defaultProfileId??``),[b,S]=(0,J.useState)(e.defaultHostId??``),[C,w]=(0,J.useState)(e.worktreeDir??`.worktrees`),[T,E]=(0,J.useState)(!1),[D,O]=(0,J.useState)(null),k=Number(u),A=i.trim()?null:`Enter a project name.`,j=Number.isInteger(k)&&k>=1&&k<=32?null:`Use a whole number from 1 to 32.`,M=Kn(C),N=async t=>{if(t.preventDefault(),!(A||j||M)){E(!0),O(null);try{await g(`/api/projects/${encodeURIComponent(e.id)}`,{name:i.trim(),setupCommand:o.trim()||null,checks:Vt(c),maxConcurrentRuns:k,automationEnabled:f,workspaceSharing:m,defaultProfileId:v||null,defaultHostId:b||null,worktreeDir:C.trim()}),U.success(`Project settings saved`)}catch(e){O(e)}finally{E(!1)}}},te=!b||t.some(e=>e.id===b),P=!v||n.some(e=>e.id===v);return(0,Y.jsx)(B,{title:`Project settings`,children:(0,Y.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:N,noValidate:!0,children:[(0,Y.jsx)(z,{id:`${r}-name`,label:`Name`,error:A,children:(0,Y.jsx)(G,{id:`${r}-name`,value:i,onChange:e=>a(e.target.value),...R(`${r}-name`,{error:A})})}),(0,Y.jsx)(z,{id:`${r}-setup`,label:`Setup command`,hint:`Runs in each new workspace before the first session, e.g. pnpm install. Leave empty for none.`,children:(0,Y.jsx)(G,{id:`${r}-setup`,value:o,onChange:e=>s(e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,...R(`${r}-setup`,{hint:!0})})}),(0,Y.jsx)(z,{id:`${r}-checks`,label:`Checks`,hint:`One command per line. Runs must pass these before review.`,children:(0,Y.jsx)($e,{id:`${r}-checks`,value:c,minRows:3,onChange:e=>l(e.target.value),className:`font-mono`,spellCheck:!1,autoCapitalize:`off`,...R(`${r}-checks`,{hint:!0})})}),(0,Y.jsx)(z,{id:`${r}-runs`,label:`Max concurrent runs`,hint:`Between 1 and 32.`,error:j,children:(0,Y.jsx)(G,{id:`${r}-runs`,type:`number`,inputMode:`numeric`,min:1,max:32,step:1,value:u,onChange:e=>d(e.target.value),className:`max-w-32`,...R(`${r}-runs`,{hint:!0,error:j})})}),(0,Y.jsx)(z,{id:`${r}-worktree`,label:`Worktree folder`,hint:Gn,error:M,children:(0,Y.jsx)(G,{id:`${r}-worktree`,"data-testid":`project-worktree-dir`,value:C,onChange:e=>w(e.target.value),placeholder:ee,className:`font-mono`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,...R(`${r}-worktree`,{hint:!0,error:M})})}),(0,Y.jsx)(nt,{label:`Auto-start Ready tasks`,description:`When off, Ready tasks in this project wait instead of starting automatically.`,checked:f,onChange:p}),(0,Y.jsxs)(`fieldset`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,Y.jsx)(`legend`,{className:`mb-1 text-sm font-medium`,children:`Workspace sharing`}),[[`single_writer`,`Single writer`,`Only one run or session writes in a workspace at a time; others wait. Safest.`],[`shared`,`Shared`,`Several sessions may write in the same workspace at once. Their changes can interleave.`]].map(([e,t,n])=>(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(`input`,{id:`${r}-sharing-${e}`,type:`radio`,name:`${r}-sharing`,value:e,checked:m===e,onChange:()=>h(e),"aria-describedby":`${r}-sharing-${e}-desc`,className:`tap mt-0.5 size-5 shrink-0 accent-[var(--sy-accent)]`}),(0,Y.jsxs)(`label`,{htmlFor:`${r}-sharing-${e}`,className:`min-w-0 text-sm`,children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:t}),(0,Y.jsx)(`span`,{id:`${r}-sharing-${e}-desc`,className:`block text-muted`,children:n})]})]},e))]}),(0,Y.jsxs)(`div`,{className:`grid min-w-0 gap-4 sm:grid-cols-2`,children:[(0,Y.jsx)(z,{id:`${r}-profile`,label:`Default Pi profile`,children:(0,Y.jsxs)(q,{id:`${r}-profile`,value:v,onChange:e=>y(e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:`None (use the coordinator default)`}),n.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id)),!P&&(0,Y.jsx)(`option`,{value:v,children:`Removed profile`})]})}),(0,Y.jsx)(z,{id:`${r}-host`,label:`Default host`,hint:`Runs start here when the task does not choose a host.`,children:(0,Y.jsxs)(q,{id:`${r}-host`,value:b,onChange:e=>S(e.target.value),...R(`${r}-host`,{hint:!0}),children:[(0,Y.jsx)(`option`,{value:``,children:`None (any host with a checkout)`}),t.map(e=>(0,Y.jsxs)(`option`,{value:e.id,children:[e.name,e.connectivity===`connected`?``:` (${e.connectivity})`]},e.id)),!te&&(0,Y.jsx)(`option`,{value:b,children:`Removed host`})]})})]}),(0,Y.jsx)(_,{error:D}),(0,Y.jsx)(`div`,{children:(0,Y.jsx)(x,{type:`submit`,variant:`primary`,busy:T,icon:(0,Y.jsx)(Ee,{className:`size-4`}),children:`Save project`})})]})})}function Yn({project:e,hosts:t,hostsById:n}){let r=L(e=>e.checkouts),i=(0,J.useMemo)(()=>Object.values(r).filter(t=>t.projectId===e.id).sort((e,t)=>e.createdAt.localeCompare(t.createdAt)),[r,e.id]),[a,o]=(0,J.useState)(!1);return(0,Y.jsxs)(B,{title:`Checkouts`,description:`Clones of this repository. Add one per host that should run this project.`,actions:(0,Y.jsx)(x,{size:`sm`,icon:(0,Y.jsx)(Se,{className:`size-4`}),onClick:()=>o(!0),children:`Add checkout`}),children:[i.length===0?(0,Y.jsx)(P,{className:`py-4`,title:`No checkouts`,description:`Add a checkout so sessions and runs have somewhere to work.`,action:{label:`Add checkout`,onClick:()=>o(!0)}}):(0,Y.jsx)(`ul`,{className:`flex min-w-0 flex-col divide-y divide-border`,children:i.map(e=>{let t=n[e.hostId];return(0,Y.jsxs)(`li`,{className:`min-w-0 py-2 text-sm`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`font-medium`,children:t?.name??`Unknown host`}),t&&t.connectivity!==`connected`&&(0,Y.jsxs)(`span`,{className:`text-xs text-muted`,children:[`(`,t.connectivity,`)`]})]}),(0,Y.jsx)(`div`,{className:`break-all font-mono text-xs`,children:e.path}),(0,Y.jsxs)(`div`,{className:`text-xs text-muted`,children:[`Default branch: `,e.defaultBranch]})]},e.id)})}),(0,Y.jsx)(Xn,{open:a,onClose:()=>o(!1),project:e,hosts:t})]})}function Xn({open:e,onClose:t,project:n,hosts:r}){let i=(0,J.useId)(),a=r.filter(e=>e.connectivity===`connected`),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(null),g=o||a[0]?.id||``,v=u||c?zt(c):null,y=()=>{f||(d(!1),h(null),t())},b=async e=>{if(e.preventDefault(),d(!0),g&&!zt(c)){p(!0),h(null);try{await I(`/api/projects/${encodeURIComponent(n.id)}/checkouts`,{hostId:g,path:c.trim()}),U.success(`Checkout added`),l(``),d(!1),t()}catch(e){h(e)}finally{p(!1)}}},S=`${i}-form`;return(0,Y.jsx)(Qe,{open:e,onClose:y,dismissOnBackdrop:!f,title:`Add checkout`,description:`Another clone of ${n.repoIdentity}.`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{onClick:y,disabled:f,children:`Cancel`}),(0,Y.jsx)(x,{type:`submit`,form:S,variant:`primary`,busy:f,disabled:a.length===0,children:`Add checkout`})]}),children:(0,Y.jsxs)(`form`,{id:S,className:`flex min-w-0 flex-col gap-4`,onSubmit:b,noValidate:!0,children:[a.length===0&&(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No host is connected. The checkout is inspected on its host, so the host must be online.`}),(0,Y.jsx)(z,{id:`${i}-host`,label:`Host`,hint:`Only connected hosts are listed.`,children:(0,Y.jsxs)(q,{id:`${i}-host`,value:g,onChange:e=>s(e.target.value),disabled:a.length===0,...R(`${i}-host`,{hint:!0}),children:[a.length===0&&(0,Y.jsx)(`option`,{value:``,children:`No connected hosts`}),a.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Y.jsx)(z,{id:`${i}-path`,label:`Checkout path on the host`,hint:`Absolute path of an existing clone of this repository.`,error:v,children:(0,Y.jsx)(G,{id:`${i}-path`,value:c,onChange:e=>l(e.target.value),placeholder:`/Users/me/src/app`,className:`font-mono`,autoCapitalize:`off`,autoComplete:`off`,spellCheck:!1,...R(`${i}-path`,{hint:!0,error:v})})}),(0,Y.jsx)(_,{error:m})]})})}var Zn=e=>X(`projects/${encodeURIComponent(e)}`);function Qn(){let e=Q(),t=f(),[n,i]=(0,J.useState)(``),a=t.filter(e=>_e(e,n)),o=L(e=>e.checkouts),s=L(e=>e.workspaces),c=(0,J.useMemo)(()=>{let e={},t=t=>(e[t]??={checkouts:0,workspaces:0},e[t]);for(let e of Object.values(o))t(e.projectId).checkouts++;for(let e of Object.values(s))e.archivedAt||t(e.projectId).workspaces++;return e},[o,s]);return(0,Y.jsxs)(Z,{testId:`settings-projects`,title:`Projects`,description:`A project is one repository. It can have checkouts on several hosts. Repositories in a host's project folders are added automatically.`,actions:(0,Y.jsxs)(r,{to:X(`projects/new`),state:Te,className:C(`primary`),children:[(0,Y.jsx)(Se,{"aria-hidden":!0,className:`size-4`}),`New project`]}),children:[(0,Y.jsx)(N,{}),e?t.length===0?(0,Y.jsx)(P,{icon:(0,Y.jsx)(fe,{className:`size-8`}),title:`No projects yet`,description:`Create a project from a Git checkout on one of your hosts.`,action:{label:`New project`,to:X(`projects/new`)}}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`relative max-w-md`,children:[(0,Y.jsx)(Oe,{"aria-hidden":!0,className:`pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-subtle`}),(0,Y.jsx)(G,{type:`search`,"aria-label":`Search projects`,placeholder:`Search projects by name or remote`,value:n,onChange:e=>i(e.target.value),className:`pl-8`})]}),a.length===0?(0,Y.jsx)(P,{className:`py-4`,title:`No matches`,description:`No project matches "${n.trim()}".`,action:{label:`Clear search`,onClick:()=>i(``)}}):(0,Y.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:a.map(e=>(0,Y.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,Y.jsx)($n,{project:e,counts:c[e.id]})},e.id))})]}):(0,Y.jsx)(b,{label:`Loading projects…`})]})}function $n({project:e,counts:t}){let n=t??{checkouts:0,workspaces:0};return(0,Y.jsxs)(r,{to:Zn(e.id),state:Te,className:`tap flex min-w-0 items-center gap-3 px-4 py-2 hover:bg-surface-2`,children:[(0,Y.jsx)(fe,{"aria-hidden":!0,className:`size-4 shrink-0 text-muted`}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),(0,Y.jsx)(`span`,{className:`truncate text-xs text-muted`,title:e.repoIdentity,children:me(e.repoIdentity)}),(0,Y.jsxs)(`span`,{className:`flex flex-wrap gap-x-2 text-xs text-subtle`,children:[(0,Y.jsxs)(`span`,{children:[n.checkouts,` checkout`,n.checkouts===1?``:`s`]}),(0,Y.jsxs)(`span`,{children:[n.workspaces,` workspace`,n.workspaces===1?``:`s`]}),!e.automationEnabled&&(0,Y.jsx)(`span`,{children:`Auto-start off`})]})]}),(0,Y.jsx)(ve,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})}function er(){let e=Q(),t=d(),r=L(e=>e.profiles),i=(0,J.useMemo)(()=>Object.values(r).sort((e,t)=>e.name.localeCompare(t.name)),[r]),a=t.filter(e=>e.connectivity===`connected`),o=n(),s=(0,J.useId)(),[c,l]=(0,J.useState)(``),[u,f]=(0,J.useState)(``),[p,m]=(0,J.useState)(``),[h,g]=(0,J.useState)(``),[v,y]=(0,J.useState)(ee),[S,C]=(0,J.useState)(!1),[w,T]=(0,J.useState)(!1),[E,D]=(0,J.useState)(null),O=u||a[0]?.id||``,k=S&&!c.trim()?`Enter a project name.`:null,A=S&&!O?`Choose a connected host.`:null,j=S||p?zt(p):null,M=Kn(v),N=async e=>{if(e.preventDefault(),C(!0),c.trim()&&O&&!zt(p)&&!M){T(!0),D(null);try{let e=await I(`/api/projects`,{name:c.trim(),hostId:O,path:p.trim(),defaultProfileId:h||null,worktreeDir:v.trim()});U.success(`Project ${c.trim()} created`),o(e?.id?Zn(e.id):X(`projects`),{replace:!0})}catch(e){D(e)}finally{T(!1)}}},te={to:X(`projects`),label:`Projects`};return e?(0,Y.jsxs)(Z,{title:`New project`,description:`Switchyard inspects the checkout on the host, then discovers its worktrees.`,back:te,children:[a.length===0&&(0,Y.jsx)(ne,{capability:`Creating a project`,reason:t.length===0?`No hosts are enrolled. Add a host first.`:`No host is connected. The checkout is inspected on its host, so the host must be online.`,fallback:(0,Y.jsx)(et,{to:X(`hosts`),variant:`action`,children:`Open hosts`})}),(0,Y.jsx)(B,{children:(0,Y.jsxs)(`form`,{className:`flex min-w-0 flex-col gap-4`,onSubmit:N,noValidate:!0,children:[(0,Y.jsx)(z,{id:`${s}-name`,label:`Name`,error:k,children:(0,Y.jsx)(G,{id:`${s}-name`,value:c,onChange:e=>l(e.target.value),autoComplete:`off`,...R(`${s}-name`,{error:k})})}),(0,Y.jsx)(z,{id:`${s}-host`,label:`Host`,hint:`Only connected hosts are listed.`,error:A,children:(0,Y.jsxs)(q,{id:`${s}-host`,value:O,onChange:e=>f(e.target.value),disabled:a.length===0,...R(`${s}-host`,{hint:!0,error:A}),children:[a.length===0&&(0,Y.jsx)(`option`,{value:``,children:`No connected hosts`}),a.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Y.jsx)(z,{id:`${s}-path`,label:`Checkout path on the host`,hint:`Absolute path of an existing Git checkout, e.g. /Users/me/src/app.`,error:j,children:(0,Y.jsx)(G,{id:`${s}-path`,value:p,onChange:e=>m(e.target.value),placeholder:`/Users/me/src/app`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,className:`font-mono`,...R(`${s}-path`,{hint:!0,error:j})})}),(0,Y.jsx)(z,{id:`${s}-worktree`,label:`Worktree folder`,hint:Gn,error:M,children:(0,Y.jsx)(G,{id:`${s}-worktree`,value:v,onChange:e=>y(e.target.value),placeholder:ee,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,className:`font-mono`,...R(`${s}-worktree`,{hint:!0,error:M})})}),(0,Y.jsx)(z,{id:`${s}-profile`,label:`Default Pi profile (optional)`,children:(0,Y.jsxs)(q,{id:`${s}-profile`,value:h,onChange:e=>g(e.target.value),children:[(0,Y.jsx)(`option`,{value:``,children:`None`}),i.map(e=>(0,Y.jsx)(`option`,{value:e.id,children:e.name},e.id))]})}),(0,Y.jsx)(_,{error:E}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Y.jsx)(x,{type:`submit`,variant:`primary`,busy:w,icon:(0,Y.jsx)(ht,{className:`size-4`}),disabled:a.length===0,children:`Create project`}),a.length===0&&(0,Y.jsx)(V,{icon:ht,label:`Needs a connected host`})]})]})})]}):(0,Y.jsx)(Z,{title:`New project`,back:te,children:(0,Y.jsx)(b,{})})}function tr(){let e=tt(`/api/auth/methods`,Bt),[t,n]=(0,J.useState)(!1),[r,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(null),h=async()=>{if(r){o(!0),c(null);try{await E(`/api/auth/passkeys/${encodeURIComponent(r.id)}`),U.success(`Passkey ${r.name} removed`),i(null),e.reload()}catch(e){c(e)}finally{o(!1)}}},g=async()=>{f(!0),m(null);try{await I(`/api/logout`),u(!1),Ve(null)}catch(e){m(e)}finally{f(!1)}},_=e.data,v=_?.passkeyAvailability,y=at(),S=_?v?.available?y?null:`This browser does not support passkeys.`:v?.reason??`Passkeys are not available on this server.`:null;return(0,Y.jsxs)(Z,{testId:`settings-signin`,title:`Sign-in`,description:`How you sign in to Switchyard on new devices. Each signed-in device keeps its own revocable credential.`,children:[(0,Y.jsx)(N,{}),e.loading&&!_?(0,Y.jsx)(b,{label:`Loading sign-in methods…`}):e.error&&!_?(0,Y.jsx)(O,{title:`Could not load sign-in methods`,error:e.error,onRetry:e.reload}):_?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(B,{title:`Passkeys`,description:`Sign in on any device with its fingerprint, face or screen lock. Passkeys are stored on this server only as public keys.`,actions:(0,Y.jsx)(x,{"data-testid":`passkey-add`,variant:`primary`,icon:(0,Y.jsx)(Se,{className:`size-4`}),disabled:S!==null,onClick:()=>n(!0),children:`Add a passkey`}),children:[S&&(0,Y.jsxs)(`p`,{role:`status`,className:`mb-3 flex items-start gap-2 rounded-md bg-warning-soft px-3 py-2 text-sm`,children:[(0,Y.jsx)(F,{"aria-hidden":!0,className:`mt-0.5 size-4 shrink-0`}),(0,Y.jsxs)(`span`,{className:`min-w-0 break-words`,children:[`Adding a passkey is unavailable: `,S]})]}),_.passkeys.length===0?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No passkeys yet. Add one as a backup to single sign-on, or to sign in without it.`}):(0,Y.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border`,children:_.passkeys.map(e=>(0,Y.jsxs)(`li`,{"data-testid":`passkey-row`,className:`flex min-w-0 flex-wrap items-center gap-3 border-b border-border px-3 py-2 last:border-b-0`,children:[(0,Y.jsx)(xe,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`break-words font-medium`,children:e.name}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 text-sm text-muted`,children:[(0,Y.jsxs)(`span`,{children:[`Added `,T(e.createdAt)]}),(0,Y.jsxs)(`span`,{children:[`Last used `,T(e.lastUsedAt)]})]})]}),(0,Y.jsx)(x,{size:`sm`,variant:`ghost`,className:`text-danger`,icon:(0,Y.jsx)(ce,{className:`size-4`}),"aria-label":`Remove passkey ${e.name}`,onClick:()=>{c(null),i(e)},children:`Remove`})]},e.id))})]}),(0,Y.jsx)(B,{title:`Single sign-on`,description:`Configured on the server`,children:_.oidc?(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(It,{items:[[`Button label`,_.oidc.label],[`Provider`,(0,Y.jsx)(`span`,{className:`break-all`,children:_.oidc.issuer},`i`)],[`Allowed account`,_.oidc.ownerMatch],[`Status`,_.oidc.status===`ready`?(0,Y.jsx)(V,{icon:H,tone:`success`,label:`Ready`},`s`):(0,Y.jsx)(V,{icon:F,tone:`danger`,label:`Error`},`s`)]]}),_.oidc.status===`error`&&_.oidc.error&&(0,Y.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-danger`,children:_.oidc.error})]}):(0,Y.jsxs)(`p`,{"data-testid":`signin-oidc-status`,className:`text-sm text-muted`,children:[`Not configured. Set the `,(0,Y.jsx)(`code`,{children:`SWITCHYARD_OIDC_*`}),` variables on the server to sign in with an identity provider.`]})})]}):null,(0,Y.jsx)(B,{title:`This device`,description:`Signing out removes this device's credential here. Other devices stay signed in; revoke a device in Settings › Devices to cut it off.`,children:(0,Y.jsx)(x,{icon:(0,Y.jsx)(Ct,{className:`size-4`}),onClick:()=>{m(null),u(!0)},children:`Sign out of this device`})}),(0,Y.jsx)(nr,{open:t,onClose:()=>n(!1),onAdded:()=>{n(!1),e.reload()}}),(0,Y.jsx)(W,{open:r!==null,onClose:()=>i(null),title:r?`Remove passkey ${r.name}?`:`Remove passkey`,confirmLabel:`Remove passkey`,busy:a,error:s,onConfirm:h,children:(0,Y.jsxs)(`p`,{className:`text-sm`,children:[`Devices already signed in stay signed in. This passkey can no longer sign in new devices.`,_&&_.passkeys.length===1&&!_.oidc?` It is your only passkey and no single sign-on is set up: afterwards new browsers need switchyard pair run on the server.`:``]})}),(0,Y.jsx)(W,{open:l,onClose:()=>u(!1),title:`Sign out of this device?`,confirmLabel:`Sign out`,busy:d,error:p,onConfirm:g,children:(0,Y.jsxs)(`p`,{className:`text-sm`,children:[`You will need single sign-on, a passkey or `,(0,Y.jsx)(`code`,{children:`switchyard pair`}),` on the server to sign in here again.`]})})]})}function nr({open:e,onClose:t,onAdded:n}){let r=(0,J.useId)(),[i,a]=(0,J.useState)(()=>st()),[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(null),u=ot(),d=i.trim()?null:`Enter a name for this passkey.`,f=()=>{if(u.waiting)u.cancel();else if(o)return;l(null),t()},p=async e=>{if(e.preventDefault(),!d){s(!0),l(null);try{let{challengeId:e,options:t}=await I(`/api/auth/passkeys/register/options`),r=await u.run(()=>it({optionsJSON:t}));if(!r.ok){s(!1);return}let a=r.value;await I(`/api/auth/passkeys/register/verify`,{challengeId:e,name:i.trim().slice(0,80),response:a}),U.success(`Passkey added`),n()}catch(e){l(e instanceof Error&&e.name===`NotAllowedError`?Error(`The passkey prompt was canceled or timed out. Try again.`):e instanceof Error?e:Error(oe(e)))}finally{s(!1)}}},m=`${r}-form`;return(0,Y.jsx)(Qe,{open:e,onClose:f,dismissOnBackdrop:!o||u.waiting,title:`Add a passkey`,description:`Name it after where it is stored, then confirm with your device.`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(x,{onClick:f,disabled:o&&!u.waiting,children:`Cancel`}),(0,Y.jsx)(x,{type:`submit`,form:m,variant:`primary`,busy:o,children:`Create passkey`})]}),children:(0,Y.jsxs)(`form`,{id:m,className:`flex min-w-0 flex-col gap-4`,onSubmit:p,noValidate:!0,children:[(0,Y.jsx)(z,{id:`${r}-name`,label:`Passkey name`,error:d,children:(0,Y.jsx)(G,{id:`${r}-name`,value:i,maxLength:80,autoComplete:`off`,onChange:e=>a(e.target.value),...R(`${r}-name`,{error:d})})}),u.waiting&&(0,Y.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-muted`,children:[(0,Y.jsx)(k,{}),` Waiting for your passkey… Cancel stops it.`]}),(0,Y.jsx)(_,{error:c})]})})}function rr(){let e=We(),n=e===`mobile`,r=(0,Y.jsxs)(i,{children:[(0,Y.jsx)(t,{index:!0,element:n?(0,Y.jsx)(sr,{}):(0,Y.jsx)(s,{to:X(`hosts`),replace:!0})}),(0,Y.jsx)(t,{path:`hosts`,element:(0,Y.jsx)(yn,{})}),(0,Y.jsx)(t,{path:`hosts/:hostId`,element:(0,Y.jsx)(Tn,{})}),(0,Y.jsx)(t,{path:`devices`,element:(0,Y.jsx)(ln,{})}),(0,Y.jsx)(t,{path:`sign-in`,element:(0,Y.jsx)(tr,{})}),(0,Y.jsx)(t,{path:`projects`,element:(0,Y.jsx)(Qn,{})}),(0,Y.jsx)(t,{path:`projects/new`,element:(0,Y.jsx)(er,{})}),(0,Y.jsx)(t,{path:`projects/:projectId`,element:(0,Y.jsx)(qn,{})}),(0,Y.jsx)(t,{path:`profiles`,element:(0,Y.jsx)(Rn,{})}),(0,Y.jsx)(t,{path:`adapters`,element:(0,Y.jsx)(Xt,{})}),(0,Y.jsx)(t,{path:`notifications`,element:(0,Y.jsx)(kn,{})}),(0,Y.jsx)(t,{path:`backups`,element:(0,Y.jsx)(an,{})}),(0,Y.jsx)(t,{path:`diagnostics`,element:(0,Y.jsx)(dn,{})}),(0,Y.jsx)(t,{path:`device`,element:(0,Y.jsx)(un,{})}),(0,Y.jsx)(t,{path:`*`,element:(0,Y.jsx)(cr,{})})]});return n?(0,Y.jsx)(`div`,{className:`min-w-0`,children:r}):(0,Y.jsxs)(`div`,{className:`flex min-h-full min-w-0`,children:[(0,Y.jsx)(ar,{compact:e===`compact`}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:r})]})}function ir(){let{pathname:e}=u(),t=e.split(`/`),n=t.indexOf(`settings`);return n>=0&&(t[n+1]??null)||null}function ar({compact:e}){let t=ir();return(0,Y.jsx)(`div`,{className:h(`shrink-0 border-r border-border`,e?`w-52`:`w-60`),children:(0,Y.jsxs)(`nav`,{"aria-label":`Settings sections`,"data-testid":`settings-nav`,className:`sticky top-0 flex max-h-dvh flex-col gap-1 overflow-y-auto px-2 py-4`,children:[(0,Y.jsx)(`h2`,{className:`mb-1 px-3 py-1 text-base font-semibold`,children:`Settings`}),Ft.map(e=>(0,Y.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Y.jsx)(`h3`,{className:`px-3 pt-3 pb-1 text-xs font-semibold tracking-wide text-muted uppercase`,children:e.label}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:e.sections.map(({path:e,label:n,icon:i})=>{let a=t===e;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(r,{to:X(e),"aria-current":a?`page`:void 0,className:h(`tap flex h-10 items-center gap-3 rounded-md px-3 text-sm font-medium`,a?`bg-accent-soft text-text`:`text-muted hover:bg-surface-2 hover:text-text`),children:[(0,Y.jsx)(i,{"aria-hidden":!0,className:`size-4 shrink-0`}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:n})]})},e)})})]},e.label))]})})}function or(){let e=L(e=>e.hosts),t=L(e=>e.devices),n=L(e=>e.projects),r=L(e=>e.profiles),i=L(e=>e.adapters),a=L(e=>e.hydrated);return(0,J.useMemo)(()=>{if(!a)return{};let o=Object.values(e).filter(e=>e.revokedAt===null),s=o.filter(e=>e.connectivity===`connected`).length,c=Object.values(i).reduce((e,t)=>e+t.length,0),l=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return{hosts:`${l(o.length,`host`)}, ${s} connected`,devices:l(Object.values(t).filter(e=>e.revokedAt===null).length,`device`),projects:l(Object.keys(n).length,`project`),profiles:l(Object.keys(r).length,`profile`),adapters:l(c,`adapter`)}},[e,t,n,r,i,a])}function sr(){let e=or();return(0,Y.jsxs)(`div`,{className:`mx-auto flex w-full min-w-0 max-w-xl flex-col gap-3 px-4 py-4`,children:[(0,Y.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Settings`}),(0,Y.jsx)(N,{}),(0,Y.jsx)(`nav`,{"aria-label":`Settings sections`,"data-testid":`settings-nav`,children:Ft.map(t=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h2`,{className:`px-1 pt-3 pb-1 text-xs font-semibold tracking-wide text-muted uppercase`,children:t.label}),(0,Y.jsx)(`ul`,{className:`overflow-hidden rounded-lg border border-border bg-surface`,children:t.sections.map(({path:t,label:n,description:i,icon:a})=>(0,Y.jsx)(`li`,{className:`border-b border-border last:border-b-0`,children:(0,Y.jsxs)(r,{to:X(t),state:Te,className:`tap flex min-h-14 items-center gap-3 px-4 py-2 hover:bg-surface-2`,children:[(0,Y.jsx)(a,{"aria-hidden":!0,className:`size-5 shrink-0 text-muted`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block font-medium`,children:n}),(0,Y.jsx)(`span`,{className:`block truncate text-sm text-muted`,children:e[t]??i})]}),(0,Y.jsx)(ve,{"aria-hidden":!0,className:`size-4 shrink-0 text-subtle`})]})},t))})]},t.label))})]})}function cr(){return(0,Y.jsx)(P,{title:`Settings page not found`,description:`This link does not match a settings section.`,action:{label:`Open Settings`,to:X()}})}export{rr as default};
|
|
8
|
+
//# sourceMappingURL=settings-DyUu0tJM.js.map
|