shapewall 0.3.0 → 0.3.1
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/CHANGELOG.md +9 -0
- package/dist/agent/package-lock.json +2 -2
- package/dist/client/assets/{BoardChat-CupOxioV.js → BoardChat-V1BCXdDB.js} +1 -1
- package/dist/client/assets/{ChecksPanel-BqrS02Ih.js → ChecksPanel-Cm22bCdQ.js} +1 -1
- package/dist/client/assets/{History-CQG3NQOC.js → History-U0bD1BjA.js} +1 -1
- package/dist/client/assets/{LocalSettings-CSNMhNyV.js → LocalSettings-DOSuW7VC.js} +1 -1
- package/dist/client/assets/{Management-CJVNAqAW.js → Management-BFcKFdbp.js} +1 -1
- package/dist/client/assets/{QuickConnect-B-4pUgXH.js → QuickConnect-DyfPSWbV.js} +1 -1
- package/dist/client/assets/{app-update-dialog-rhaw0MRk.js → app-update-dialog-DH2Mgby8.js} +1 -1
- package/dist/client/assets/{index-DKOCIQiq.js → index-C9S7HL_o.js} +3 -3
- package/dist/client/build-info.json +1 -1
- package/dist/client/index.html +1 -1
- package/dist/client/sw.js +2 -2
- package/dist/console/assets/{LocalAccountsApp-DOKZI6Lt.js → LocalAccountsApp-lJjkhUcH.js} +1 -1
- package/dist/console/assets/{LocalConsole-DXzldLW9.js → LocalConsole-BZHqYKnt.js} +1 -1
- package/dist/console/assets/{app-update-dialog-CrqIMEwN.js → app-update-dialog-DCM9sYE3.js} +1 -1
- package/dist/console/assets/{console-76WovHlh.js → console-C2LsvEco.js} +3 -3
- package/dist/console/build-info.json +1 -1
- package/dist/console/console.html +1 -1
- package/docs/pull-requests.md +3 -2
- package/package.json +1 -1
- package/src/agent/starter/worktree.js +32 -4
- package/src/ci/workflow.js +14 -3
- package/src/cli/init.js +8 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./app-update-dialog-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./app-update-dialog-DH2Mgby8.js","./ui-Cg4TTrec.js","./refresh-cw-aeOBDuGQ.js","./ChecksPanel-Cm22bCdQ.js","./shield-check-DuPBJ6H_.js","./circle-x-PRxj7kPi.js","./BoardChat-V1BCXdDB.js","./QuickConnect-DyfPSWbV.js","./History-U0bD1BjA.js","./ShareDialog-BouvNraR.js","./LocalSettings-DOSuW7VC.js","./BuzzDialog-Ds7Thpfe.js","./Management-BFcKFdbp.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{$t as e,A as t,At as n,B as r,Bt as i,C as a,Ct as o,D as s,Dt as c,E as l,Et as u,F as d,Ft as f,G as p,Gt as m,H as h,Ht as g,I as _,It as v,J as y,Jt as b,K as x,Kt as S,L as C,Lt as w,M as T,Mt as E,N as D,Nt as O,O as k,P as A,Pt as j,R as M,Rt as N,S as P,St as F,T as ee,Tt as I,U as L,Ut as R,V as z,Vt as B,W as V,Wt as H,X as U,Xt as te,Y as ne,Yt as re,Z as ie,Zt as ae,_ as W,_t as G,a as oe,at as se,b as ce,bt as le,c as ue,ct as K,d as de,dt as fe,f as pe,ft as me,g as he,gt as ge,h as _e,ht as ve,i as ye,it as be,j as xe,jt as Se,k as Ce,kt as we,l as Te,lt as Ee,m as De,mt as Oe,n as ke,o as Ae,ot as je,p as Me,pt as Ne,q as Pe,qt as q,r as Fe,rt as Ie,s as Le,st as Re,t as ze,tt as Be,u as Ve,ut as He,v as Ue,vt as We,w as Ge,wt as Ke,x as qe,xt as Je,y as Ye,yt as Xe,z as Ze,zt as Qe}from"./ui-Cg4TTrec.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var $e=ae((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),et=ae(((e,t)=>{t.exports=$e()})),tt=ae((e=>{var t=et(),n=te(),r=re();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function S(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function C(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var w=Object.assign,T=Symbol.for(`react.element`),E=Symbol.for(`react.transitional.element`),D=Symbol.for(`react.portal`),O=Symbol.for(`react.fragment`),k=Symbol.for(`react.strict_mode`),A=Symbol.for(`react.profiler`),j=Symbol.for(`react.consumer`),M=Symbol.for(`react.context`),N=Symbol.for(`react.forward_ref`),P=Symbol.for(`react.suspense`),F=Symbol.for(`react.suspense_list`),ee=Symbol.for(`react.memo`),I=Symbol.for(`react.lazy`),L=Symbol.for(`react.activity`),R=Symbol.for(`react.legacy_hidden`),z=Symbol.for(`react.memo_cache_sentinel`),B=Symbol.for(`react.view_transition`),V=Symbol.for(`react.recoverable`),H=Symbol.iterator;function U(e){return typeof e!=`object`||!e?null:(e=H&&e[H]||e[`@@iterator`],typeof e==`function`?e:null)}var ne=Symbol.for(`react.client.reference`);function ie(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ne?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case O:return`Fragment`;case A:return`Profiler`;case k:return`StrictMode`;case P:return`Suspense`;case F:return`SuspenseList`;case L:return`Activity`;case B:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case D:return`Portal`;case M:return e.displayName||`Context`;case j:return(e._context.displayName||`Context`)+`.Consumer`;case N:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ee:return t=e.displayName||null,t===null?ie(e.type)||`Memo`:t;case I:t=e._payload,e=e._init;try{return ie(e(t))}catch{}}return null}var ae=Array.isArray,W=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oe={pending:!1,data:null,method:null,action:null},se=[],ce=-1;function le(e){return{current:e}}function ue(e){0>ce||(e.current=se[ce],se[ce]=null,ce--)}function K(e,t){ce++,se[ce]=e.current,e.current=t}var de=le(null),fe=le(null),pe=le(null),me=le(null);function he(e,t){switch(K(pe,t),K(fe,e),K(de,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ue(de),K(de,e)}function ge(){ue(de),ue(fe),ue(pe)}function _e(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,K(me,e)),t=de.current;var n=dp(t,e.type);t!==n&&(K(fe,e),K(de,n))}function ve(e){fe.current===e&&(ue(de),ue(fe)),me.current===e&&(ue(me),sh._currentValue=oe)}var ye,be;function xe(e){if(ye===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ye=t&&t[1]||``,be=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+ye+e+be}var Se=!1;function Ce(e,t){if(!e||Se)return``;Se=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -29,9 +29,9 @@ Error generating stack: `+e.message+`
|
|
|
29
29
|
`).map(e=>`> ${e}`.trimEnd()).join(`
|
|
30
30
|
`);function Pw({title:e,threadId:t,messages:n,comment:r=null,boardTitle:i=null,exportedAt:a=new Date}){let o=[`# ${e||Mw(t,r)}`,``],s=[i?`Board: ${i}`:null,r?`About comment #${r.id}`:null].filter(Boolean);o.push(`_Exported from Shapewall on ${a.toISOString().slice(0,10)}.${s.length?` ${s.join(`. `)}.`:``}_`,``),r?.body&&o.push(Nw(r.body),``);for(let e of n||[]){let t=e.createdAt?` (${String(e.createdAt).slice(0,16).replace(`T`,` `)} UTC)`:``;if(e.role===`user`){o.push(`## You${t}`,``,e.text||`_(images only)_`,``);let n=(e.attachments||[]).map(e=>e.name).filter(Boolean);n.length&&o.push(`Images: ${n.join(`, `)}`,``)}else{o.push(`## Agent${t}`,``);let n=(e.cards||[]).filter(e=>e.label).map(e=>`- ${e.label}${e.detail?`: ${e.detail}`:``}`);n.length&&o.push(`Steps:`,``,...n,``),e.text&&o.push(e.text,``),e.status===`stopped`&&o.push(`_Stopped._`,``),e.error?.message&&o.push(`_Error: ${e.error.message}_`,``)}}return`${o.join(`
|
|
31
31
|
`).trimEnd()}\n`}function Fw(e){return`${String(e||`chat`).toLowerCase().normalize(`NFKD`).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,60)||`chat`}.md`}function Iw(e){let t=AS(e.id);return t?.state===`waiting`?`waiting`:t?.state===`working`||[`queued`,`working`].includes(e.agentStatus)?`working`:null}function Lw({comment:e,onFix:t,onOpenChat:n=null,busy:i,touch:a,className:o}){let s=Iw(e),c=(0,J.useContext)(vv)?.boardId||null,l=!!t&&e.status===`open`,u=Xe(l?`/api/agent/status`:null);eC(u.refetch,l);let[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(null);if(!l)return null;if(!s&&e.agentStatus===`branch-ready`)return n?(0,Y.jsxs)(r,{size:a?`touch`:`xs`,variant:`default`,className:K(`rounded-full pr-3 pl-2.5`,o),onClick:()=>n(e),"data-sw-fix-agent-open":e.id,"data-sw-fix-agent-state":`branch`,children:[(0,Y.jsx)(Mh,{size:13,"aria-hidden":`true`}),` Review branch`]}):null;if(s)return(0,Y.jsxs)(`span`,{className:K(`inline-flex min-w-0 items-center gap-1.5`,o),"data-sw-fix-agent-state":s,children:[(0,Y.jsxs)(`span`,{className:K(`inline-flex h-7 min-w-0 items-center gap-1.5 rounded-full px-2.5 text-xs font-medium`,s===`waiting`?`bg-warn/15 text-fg`:`bg-accent/10 text-accent`),role:`status`,children:[s===`waiting`?(0,Y.jsx)(u_,{size:13,className:`shrink-0 text-warn`,"aria-hidden":`true`}):(0,Y.jsx)(ug,{size:13,className:`shrink-0 motion-safe:animate-spin`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:s===`waiting`?`Agent needs your OK`:`Agent working`})]}),n?(0,Y.jsx)(r,{size:a?`touch`:`xs`,variant:s===`waiting`?`default`:`ghost`,onClick:()=>n(e),"data-sw-fix-agent-open":e.id,children:s===`waiting`?`Review`:`View`}):null]});let{name:h,options:g,defaultId:_}=fw(u.data),v=e.agentStatus===`done`,y=v?`secondary`:`default`,b=a?`touch`:`xs`,x=async n=>{if(m(null),g.length&&c){f(!0);try{let t=nC(c,vw(e.id)),r=pw({threadProfile:(await Ke.get(t))?.profileId,wanted:n,defaultId:_});r&&await Ke.post(`${t}/profile`,{profileId:r})}catch(e){m(e.message);return}finally{f(!1)}}t(e)},S=g.length>0,C=(0,Y.jsxs)(r,{size:b,variant:y,className:K(S?`rounded-l-full rounded-r-none pr-2.5 pl-2.5`:`rounded-full pr-3 pl-2.5`,!S&&o),disabled:i||d,onClick:()=>x(`default`),"data-sw-fix-agent":e.id,"data-sw-fix-agent-name":h||void 0,children:[d?(0,Y.jsx)(ug,{size:13,className:`motion-safe:animate-spin`,"aria-hidden":`true`}):(0,Y.jsx)(m_,{size:13,"aria-hidden":`true`}),` `,mw({again:v,name:h})]}),w=p?(0,Y.jsx)(`span`,{className:`min-w-0 text-xs text-bad`,role:`alert`,children:p}):null;return S?(0,Y.jsxs)(`span`,{className:K(`inline-flex min-w-0 flex-wrap items-center justify-end gap-1.5`,o),"data-sw-fix-agent-split":e.id,children:[w,(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0`,children:[C,(0,Y.jsx)(_w,{options:g,value:null,onChoose:e=>x(e===_?`default`:e),heading:`Run this fix once with`,align:`end`,touch:a,children:(0,Y.jsx)(r,{size:a?`icon`:`icon-xs`,variant:y,className:K(`rounded-l-none rounded-r-full`,v?`-ml-px`:`border-l border-accent-fg/30`),disabled:i||d,"aria-label":`Fix with another agent`,"data-sw-fix-agent-choose":e.id,children:(0,Y.jsx)(H,{size:13,"aria-hidden":`true`})})})]})]}):w?(0,Y.jsxs)(`span`,{className:`inline-flex min-w-0 flex-wrap items-center justify-end gap-1.5`,children:[w,C]}):C}var Rw=(e,t)=>t?`${e}, ${t}`:e;function zw(e){return e===`viewer`?`Viewers can't reply -- ask an admin for access.`:e===`guest`?`This share link can't reply -- ask the board owner.`:`Replies are off on this board.`}function Bw({at:e,editedAt:t}){return(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-baseline gap-1 text-xs text-faint`,children:[(0,Y.jsx)(h,{content:rb(e),children:(0,Y.jsx)(`time`,{dateTime:e,children:Ee(e)})}),t?(0,Y.jsx)(h,{content:`Edited ${rb(t)}`,children:(0,Y.jsx)(`span`,{"data-sw-edited":`true`,children:`(edited)`})}):null]})}function Vw({author:e,at:t,editedAt:n,children:r,reactions:i,canReact:a,me:o,onReact:s,touch:c,...l}){return(0,Y.jsxs)(`li`,{className:`group/message flex gap-2.5 py-2`,...l,children:[(0,Y.jsx)(Zy,{...e,size:c?`lg`:`md`,className:`mt-0.5`}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`p`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-ui`,children:[(0,Y.jsx)(Yy,{...e}),(0,Y.jsx)(Bw,{at:t,editedAt:n})]}),r,(0,Y.jsx)(nw,{reactions:i,canReact:a,me:o,onToggle:s,touch:c})]})]})}function Hw({comment:e,busy:t,onSave:n,onCancel:i,touch:a,people:o}){let[s,c]=(0,J.useState)(e.body),l=async t=>{t?.preventDefault();let r=s.trim();if(!r||r===e.body)return i();await n(e,r)&&i()};return(0,Y.jsxs)(`form`,{className:`mt-1 space-y-1.5`,onSubmit:l,"data-sw-edit-form":e.id,children:[(0,Y.jsxs)(`label`,{className:`block`,children:[(0,Y.jsxs)(`span`,{className:`sr-only`,children:[`Edit comment `,e.id]}),(0,Y.jsx)(sb,{rows:3,size:a?`touch`:`sm`,value:s,maxLength:HC,onChange:c,people:o,onKeyDown:e=>{UC(e,a)&&(e.preventDefault(),l())},autoFocus:!0})]}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(r,{size:a?`touch`:`xs`,variant:`ghost`,onClick:i,disabled:t,"data-sw-edit-cancel":e.id,children:`Cancel`}),(0,Y.jsx)(r,{size:a?`touch`:`xs`,variant:`default`,type:`submit`,disabled:t||!s.trim(),"data-sw-edit-save":e.id,children:`Save`})]})]})}function Uw({comment:e,busy:t,onReply:n,touch:i,people:a,autoFocus:o,askName:s=!1,onSaveName:c=null,media:l=null}){let[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(()=>s&&!fe()),[m,h]=(0,J.useState)(``),[g,_]=(0,J.useState)(!1),v=!!l?.attach,y=!!l?.draw,b=Jb({enabled:v}),x=`reply-${e.id}`,S=`${e.pageId}|${e.viewport}`,C=cx(e=>e?.owner===x?e.shapes.length:0);(0,J.useEffect)(()=>{if(y)return sx.start(S,x),()=>sx.end(x)},[y,S,x]);let w=y&&i?l.pageImage?.(e.pageId,e.viewport):null,T=async r=>{r?.preventDefault();let i=u.trim();if(!i||t||b.reading)return;let a=f?m.trim():``;a&&(He(a),c?.(a));let o=sx.get(),s=o?.owner===x?o.shapes:[],l=qb(b.images);await n(e,i,{...l.length?{images:l}:{},...s.length?{drawing:lx(s)}:{},onImageError:b.setError})&&(d(``),b.clear(),sx.set({shapes:[],tool:null}),a&&p(!1))},E=Math.min(6,Math.max(1,u.split(`
|
|
32
|
-
`).length)),D=`sw-reply-image-error-${e.id}`;return(0,Y.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2 border-t border-line px-3 py-2`,onSubmit:T,...jx(b,v),"data-sw-reply-form":e.id,children:[f?(0,Y.jsxs)(`label`,{className:`flex w-full items-center gap-2 text-xs text-muted`,children:[(0,Y.jsx)(`span`,{className:`shrink-0`,children:`Your name`}),(0,Y.jsx)(Ge,{size:i?`touch`:`xs`,value:m,onChange:e=>h(e.target.value.slice(0,60)),placeholder:`shown on your reply`,className:`flex-1`,"data-sw-reply-author":e.id})]}):null,(0,Y.jsxs)(`label`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`sr-only`,children:[`Reply to comment `,e.id]}),(0,Y.jsx)(sb,{rows:E,size:i?`touch`:`sm`,value:u,maxLength:HC,onChange:d,people:a,className:`resize-none`,placeholder:i?`Reply`:`Reply, @ to mention`,onKeyDown:e=>{UC(e,i)&&(e.preventDefault(),T())},autoFocus:o,"aria-describedby":b.error?D:void 0,"data-sw-reply-input":e.id})]}),(0,Y.jsx)(z,{type:`submit`,variant:`default`,size:i?`icon`:`icon-sm`,className:`rounded-full`,disabled:t||b.reading||!u.trim(),label:t&&b.images.length?`Uploading the reply`:`Send reply`,"data-sw-reply-send":e.id,children:(0,Y.jsx)(Wm,{size:16,"aria-hidden":`true`})}),v?(0,Y.jsx)(`div`,{className:`w-full`,children:(0,Y.jsx)(Mx,{draft:b,touch:i,id:D})}):null,v||y||l?.attachNote?(0,Y.jsxs)(`div`,{className:`-mt-1 -ml-1 flex w-full flex-wrap items-center gap-0.5`,"data-sw-reply-media":e.id,children:[y&&!i?(0,Y.jsx)(Ex,{owner:x,touch:!1,compact:!0,className:`flex-1`,leading:v?(0,Y.jsx)(Ax,{draft:b,touch:!1,disabled:t}):null}):v?(0,Y.jsx)(Ax,{draft:b,touch:i,disabled:t}):null,y&&i&&w?(0,Y.jsxs)(r,{size:`touch`,variant:`ghost`,onClick:()=>_(!0),"data-sw-draw-open":`true`,children:[(0,Y.jsx)(Km,{size:16,"aria-hidden":`true`}),` `,C?`Drawing (${C})`:`Draw on the page`]}):null,l?.attachNote?(0,Y.jsx)(`p`,{className:`w-full px-1 text-caption text-faint`,"data-sw-attach-note":`true`,children:l.attachNote}):null]}):null,y&&i&&w?(0,Y.jsx)(kx,{open:g,onClose:()=>_(!1),owner:x,src:w.src,native:w.native,title:l.pageTitle}):null]})}function Ww({item:e,currentVersion:t,onShow:n}){if(!e?.drawing?.shapes?.length)return null;let r=!!(e.drawing.captureVersion&&t&&e.drawing.captureVersion!==t),i=e.drawing.shapes.length;return(0,Y.jsxs)(`p`,{className:`mt-1.5 text-xs text-muted`,"data-sw-message-drawing":r?`previous`:`current`,children:[(0,Y.jsx)(Km,{size:11,className:`mr-1 inline-block align-[-1px]`,"aria-hidden":`true`}),r?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{children:[`Drawn on the previous capture (`,i===1?`one shape`:`${i} shapes`,`).`]}),` `,n?(0,Y.jsx)(`button`,{type:`button`,className:`rounded text-accent underline-offset-2 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-accent`,onClick:n,"data-sw-show-drawing":`true`,children:`View it on Before`}):null]}):(0,Y.jsxs)(`span`,{children:[`Drawn on the page (`,i===1?`one shape`:`${i} shapes`,`), shown over the frame.`]})]})}function Gw({comment:e,page:n,title:i,people:a,touch:o,me:s,can:c,busy:l,actions:u,nav:d,beforeAfter:f,onClose:p=null,editingRef:v=null,denial:y=null,role:b=null,hosted:x=null,onSaveName:w=null,media:E=null}){let[D,O]=(0,J.useState)(!1),[k,A]=(0,J.useState)(!1),j=(0,J.useRef)(null);(0,J.useEffect)(()=>{O(!1),A(!1)},[e.id]),v&&(v.current=D?()=>O(!1):null);let M=e.replies?.length||0;(0,J.useEffect)(()=>{let e=j.current;e&&(e.scrollTop=e.scrollHeight)},[e.id,M]);let N=e.status===`resolved`,P=N&&e.agentStatus!==`done`?null:e.agentStatus,F=o?`icon`:`icon-sm`,ee=fv(e.viewport,null),I=!!u.onFixAgent&&e.status===`open`,L=e.reopenCount>0&&!N||!!P,B=e.github?.issue?Vy(e.github.issue.url):null,V=E?.currentVersion?.(e)||null,H=()=>{let e=j.current?.querySelector(`[data-sw-before-after]`);e?.scrollIntoView?.({block:`nearest`}),e?.querySelector(`[data-sw-compare-handle], [role="tab"]`)?.focus?.()},U=[u.onCopyLink?{id:`link`,label:`Copy link`,icon:og,run:()=>u.onCopyLink(e),hook:`data-sw-copy-link`}:null,c.edit?{id:`edit`,label:`Edit`,icon:Bg,run:()=>O(!0),hook:`data-sw-edit`}:null,u.onAskAgent?{id:`agent`,label:`Ask agent`,icon:S,run:()=>u.onAskAgent(e),hook:`data-sw-ask-agent`}:null,B?{id:`issue`,label:`Open issue #${e.github.issue.number} on GitHub`,icon:nh,href:B,hook:`data-sw-github-open`}:u.onGithubIssue&&c.resolve?{id:`issue`,label:`Create a GitHub issue`,icon:nh,run:()=>u.onGithubIssue(e),hook:`data-sw-github-issue`}:null,u.onHistory&&n?{id:`history`,label:`Page history`,icon:Kg,run:()=>u.onHistory(e),hook:`data-sw-comment-history`}:null,n?.url?{id:`page`,label:`Open the page`,icon:bh,href:n.url,hook:`data-sw-open-page`}:null].filter(Boolean);return(0,Y.jsxs)(`div`,{className:`flex max-h-[inherit] min-h-0 flex-col`,"data-sw-selected-comment":e.id,"data-sw-thread":e.id,children:[(0,Y.jsxs)(`div`,{className:K(`flex shrink-0 items-center gap-0.5 border-b border-line`,o?`px-2 py-1`:`py-1 pr-1 pl-3`),children:[(0,Y.jsx)(`p`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-xs text-muted`,"data-sw-thread-title":`true`,children:p?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`shrink-0 font-semibold text-fg tabular`,children:[`#`,e.id]}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-fg/80`,children:i}),ee?(0,Y.jsx)(h,{content:`${e.viewport[0].toUpperCase()}${e.viewport.slice(1)} capture`,children:(0,Y.jsx)(`span`,{className:`inline-flex shrink-0 text-faint`,"aria-label":`${e.viewport} capture`,role:`img`,children:(0,Y.jsx)(ee,{size:12,"aria-hidden":`true`})})}):(0,Y.jsxs)(`span`,{className:`shrink-0 text-faint`,children:[`· `,e.viewport]})]}):d?.total>1?(0,Y.jsxs)(`span`,{className:`tabular`,children:[d.index+1,` of `,d.total]}):null}),d?.total>1?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(z,{size:F,onClick:d.onPrev,label:Rw(`Previous thread`,d.prevNote),tooltip:Rw(`Previous thread (Left arrow)`,d.prevNote),"data-sw-thread-prev":`true`,"data-sw-thread-note":d.prevNote||void 0,children:(0,Y.jsx)(eh,{size:16,"aria-hidden":`true`})}),(0,Y.jsx)(z,{size:F,onClick:d.onNext,label:Rw(`Next thread`,d.nextNote),tooltip:Rw(`Next thread (Right arrow)`,d.nextNote),"data-sw-thread-next":`true`,"data-sw-thread-note":d.nextNote||void 0,children:(0,Y.jsx)(R,{size:16,"aria-hidden":`true`})})]}):null,c.resolve?(0,Y.jsx)(z,{size:F,variant:N?`default`:`ghost`,className:K(`rounded-full`,N&&`bg-ok text-ok-fg hover:bg-ok/90`),disabled:l,"aria-pressed":N,onClick:()=>u.onStatus(e,N?`reopen`:`resolve`),label:N?`Reopen the thread`:`Resolve the thread`,tooltip:N?`Resolved: reopen`:`Resolve`,...N?{"data-sw-reopen":e.id}:{"data-sw-resolve":e.id},children:(0,Y.jsx)(m,{size:16,strokeWidth:2.5,"aria-hidden":`true`})}):N?(0,Y.jsxs)(`span`,{className:`mx-1 inline-flex items-center gap-1 rounded-full bg-ok/15 px-2 text-xs leading-6 font-medium text-fg`,children:[(0,Y.jsx)(m,{size:12,"aria-hidden":`true`}),` Resolved`]}):null,U.length||c.delete?(0,Y.jsxs)(Ce,{children:[(0,Y.jsx)(h,{content:`More`,children:(0,Y.jsx)(C,{asChild:!0,children:(0,Y.jsx)(r,{variant:`ghost`,size:F,"aria-label":`More for comment ${e.id}`,"data-sw-thread-menu":e.id,children:(0,Y.jsx)(vh,{size:16,"aria-hidden":`true`})})})}),(0,Y.jsxs)(t,{align:`end`,children:[U.map(t=>t.href?(0,Y.jsx)(T,{asChild:!0,[t.hook]:e.id,children:(0,Y.jsxs)(`a`,{href:t.href,target:`_blank`,rel:`noreferrer noopener`,children:[(0,Y.jsx)(t.icon,{size:14,"aria-hidden":`true`}),` `,t.label]})},t.id):(0,Y.jsxs)(T,{onSelect:t.run,[t.hook]:e.id,children:[(0,Y.jsx)(t.icon,{size:14,"aria-hidden":`true`}),` `,t.label]},t.id)),c.delete?(0,Y.jsxs)(Y.Fragment,{children:[U.length?(0,Y.jsx)(_,{}):null,(0,Y.jsxs)(T,{tone:`danger`,onSelect:()=>A(!0),"data-sw-delete":e.id,children:[(0,Y.jsx)(E_,{size:14,"aria-hidden":`true`}),` Delete thread`]})]}):null]})]}):null,p?(0,Y.jsx)(z,{size:F,onClick:p,label:`Close the thread`,tooltip:`Close (Esc)`,"data-sw-thread-close":`true`,children:(0,Y.jsx)(g,{size:16,"aria-hidden":`true`})}):null]}),I||L?(0,Y.jsxs)(`div`,{className:`flex min-h-10 shrink-0 flex-wrap items-center gap-1.5 border-b border-line px-3 py-1.5`,"data-sw-thread-agent":`true`,children:[(0,Y.jsx)(qy,{comment:e}),I&&[`queued`,`working`].includes(P)?null:(0,Y.jsx)(Ky,{status:P,at:e.agentStatusAt,branch:e.agentBranch||null}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1`}),I?(0,Y.jsx)(Lw,{comment:e,onFix:u.onFixAgent,onOpenChat:u.onAskAgent,busy:l,touch:o}):null]}):null,(0,Y.jsxs)(`div`,{ref:j,className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[e.orphanReason?(0,Y.jsx)(`p`,{className:`pt-2 text-xs text-muted`,children:e.orphanReason}):null,e.imported&&e.agentStatus?(0,Y.jsx)(`p`,{className:`pt-2 text-xs text-muted`,children:`Imported agent status (history)`}):null,u.onSendToAgent&&e.status===`open`?(0,Y.jsx)(`div`,{className:`py-2`,children:(0,Y.jsx)(r,{size:o?`touch`:`sm`,disabled:l||e.dispatchable||e.needsRunApproval&&![`admin`,`owner`].includes(b),onClick:()=>u.onSendToAgent(e),children:e.dispatchable?`Sent to agent`:e.needsRunApproval?[`admin`,`owner`].includes(b)?`Approve agent run`:`Awaiting run approval`:`Send to agent`})}):null,(0,Y.jsxs)(`ol`,{className:`divide-y divide-line/60`,"aria-label":`Comment ${e.id} and replies`,children:[(0,Y.jsxs)(Vw,{author:Qy(e),at:e.createdAt,editedAt:e.editedAt,reactions:e.reactions,canReact:c.react,me:s,onReact:t=>u.onReact(e,t,null),touch:o,"data-sw-message":`comment`,children:[D?(0,Y.jsx)(Hw,{comment:e,busy:l,onSave:u.onEdit,onCancel:()=>O(!1),touch:o,people:a}):(0,Y.jsx)(ab,{text:e.body,plain:!!e.authorGuest,className:`block text-ui break-words whitespace-pre-wrap text-fg`}),(0,Y.jsx)(Nx,{boardId:E?.boardId,images:e.images,touch:o,label:`Comment ${e.id}`}),(0,Y.jsx)(Ww,{item:e,currentVersion:V,onShow:H}),e.anchor?(0,Y.jsx)(h,{content:(0,Y.jsx)(`span`,{className:`font-mono text-[11px] break-all`,children:e.anchor.selector}),children:(0,Y.jsxs)(`p`,{className:`mt-1.5 inline-flex max-w-full min-w-0 items-center gap-1 rounded-full bg-surface-2 px-2 py-0.5 text-[11px] text-muted`,"data-sw-thread-anchor":`true`,tabIndex:0,children:[(0,Y.jsx)(mh,{size:11,className:`shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`shrink-0`,children:`Pinned to`}),(0,Y.jsx)(`span`,{className:`truncate text-fg`,children:nb(e.anchor)})]})}):null,n?.note?(0,Y.jsxs)(`p`,{className:`mt-1 flex items-start gap-1 text-xs text-faint`,"data-sw-page-note":`true`,children:[(0,Y.jsx)(Xh,{size:11,className:`mt-0.5 shrink-0`,"aria-hidden":`true`}),` `,n.note]}):null,e.resolution?(0,Y.jsxs)(`p`,{className:`mt-1.5 rounded bg-ok/10 px-2 py-1 text-xs text-fg`,children:[`Fix: `,e.resolution]}):null,(0,Y.jsx)(Hy,{value:e.fixRef,touch:o}),(0,Y.jsx)(Wy,{github:e.github,touch:o}),f?(0,Y.jsx)($C,{comment:e,pair:f.pairFor(e),native:f.nativeFor(e),urlFor:f.urlFor,onImageError:f.onImageError,touch:o}):null]}),(e.replies||[]).length?(0,Y.jsx)(`li`,{"data-sw-replies":`true`,children:(0,Y.jsx)(`ol`,{className:`divide-y divide-line/60`,"aria-label":`Replies`,children:e.replies.map(t=>(0,Y.jsxs)(Vw,{author:$y(t),at:t.createdAt,reactions:t.reactions,canReact:c.react,me:s,onReact:n=>u.onReact(e,n,t.id),touch:o,"data-sw-reply":t.id,children:[(0,Y.jsx)(ab,{text:t.body,plain:!!t.guest,className:`block text-ui break-words whitespace-pre-wrap text-fg`}),(0,Y.jsx)(Nx,{boardId:E?.boardId,images:t.images,touch:o,label:`Reply ${t.id}`}),(0,Y.jsx)(Ww,{item:t,currentVersion:V,onShow:H})]},t.id))})}):null]})]}),k?(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-line bg-bad/10 px-3 py-2 text-xs text-fg`,role:`alert`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Delete this thread and its replies for good?`}),(0,Y.jsx)(r,{size:o?`touch`:`xs`,variant:`ghost`,onClick:()=>A(!1),disabled:l,children:`Cancel`}),(0,Y.jsxs)(r,{size:o?`touch`:`xs`,variant:`secondary`,className:`text-bad`,onClick:()=>u.onDelete(e),disabled:l,"data-sw-delete-confirm":e.id,children:[(0,Y.jsx)(E_,{size:13,"aria-hidden":`true`}),` Delete`]})]}):null,c.reply?(0,Y.jsx)(Uw,{comment:e,busy:l,onReply:u.onReply,touch:o,people:a,askName:x===!1,onSaveName:w,media:E},e.id):(0,Y.jsx)(`p`,{className:`shrink-0 border-t border-line px-3 py-2 text-xs text-muted`,"data-sw-reply-denied":b||`true`,children:y||zw(b)})]})}var Kw=`input, textarea, select, [contenteditable="true"]`,qw={top:10,right:10,bottom:60,left:10};function Jw(e,t){let n=Uu(),r=(0,J.useRef)(null),i=(0,J.useRef)({selector:e,point:t});return i.current={selector:e,point:t},r.current||={getBoundingClientRect(){let{domNode:e,transform:t}=n.getState(),{selector:r,point:a}=i.current,o=r?e?.querySelector(r):null;if(o)return o.getBoundingClientRect();let s=e?.getBoundingClientRect();if(!s||!a)return new DOMRect(-1e4,-1e4,0,0);let[c,l,u]=t;return new DOMRect(s.left+a.x*u+c,s.top+a.y*u+l,0,0)}},r}function Yw(e,t,n){let r=Uu(),[i,a]=(0,J.useState)(`right`);return(0,J.useEffect)(()=>{if(!e)return;let i=()=>{let e=r.getState().domNode?.getBoundingClientRect(),i=t.current.getBoundingClientRect();if(!e)return;let o=(n.current?.offsetWidth||360)+20;a(e.right-i.right>=o?`right`:i.left-e.left>=o?`left`:`bottom`)};i();let o=r.subscribe(i),s=new ResizeObserver(i),c=r.getState().domNode;return c&&s.observe(c),()=>{o(),s.disconnect()}},[e,r,t,n]),i}function Xw({open:e,onClose:t,selector:n,point:r,children:i,label:a,onKeyDown:o,onEscape:s,focusContent:c,stowed:l,className:u,...d}){let f=Uu(),p=Jw(n,r),m=(0,J.useRef)(null),h=Yw(e,p,m);return(0,Y.jsxs)(Ye,{open:e,onOpenChange:e=>e?null:t(),children:[(0,Y.jsx)(ce,{virtualRef:p}),(0,Y.jsx)(qe,{ref:m,side:h,align:`start`,sideOffset:10,alignOffset:-6,collisionBoundary:f.getState().domNode,collisionPadding:qw,hideWhenDetached:!0,updatePositionStrategy:`always`,"aria-label":a,className:K(`z-30`,u,l&&`invisible`),"data-sw-stowed":l?`true`:void 0,onOpenAutoFocus:e=>{c&&(e.preventDefault(),m.current?.focus({preventScroll:!0}))},onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>{s?.(e)===!1&&e.preventDefault()},onKeyDown:e=>{m.current?.contains(e.target)&&!e.target?.closest?.(Kw)&&o?.(e)},tabIndex:-1,...d,children:i})]})}function Zw(e){(document.querySelector(`[data-sw-pin="${CSS.escape(e)}"]`)||[...document.querySelectorAll(`[data-sw-pin-cluster]`)].find(t=>t.getAttribute(`data-sw-pin-cluster`).split(`,`).includes(e)))?.focus({preventScroll:!0})}function Qw(e,t,n){e.altKey||e.ctrlKey||e.metaKey||(e.key===`ArrowLeft`||e.key===`ArrowUp`?(e.preventDefault(),t?.()):(e.key===`ArrowRight`||e.key===`ArrowDown`)&&(e.preventDefault(),n?.()))}function $w({comment:e,point:t,onClose:n,onPrev:r,onNext:i,editingRef:a,stowed:o,children:s}){let c=(0,J.useRef)({onPrev:r,onNext:i});return c.current={onPrev:r,onNext:i},(0,J.useEffect)(()=>{let e=e=>{e.defaultPrevented||document.activeElement!==document.body||document.querySelector(`[role="menu"], [role="listbox"], [role="dialog"]:not([data-sw-thread-popover])`)||Qw(e,c.current.onPrev,c.current.onNext)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,J.useEffect)(()=>{let t=window.setTimeout(()=>{document.activeElement===document.body&&document.querySelector(`[data-sw-thread-popover="${e.id}"]`)?.focus({preventScroll:!0})},450);return()=>window.clearTimeout(t)},[e.id]),(0,Y.jsx)(Xw,{open:!0,onClose:n,selector:`[data-sw-pin="${e.id}"]`,point:t,label:`Comment ${e.id}`,focusContent:!0,stowed:o,className:`flex max-h-[min(560px,var(--radix-popover-content-available-height))] w-[360px] flex-col overflow-hidden p-0 outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onEscape:()=>{if(a?.current&&document.activeElement?.closest?.(`[data-sw-edit-form]`))return a.current(),!1;let t=String(e.id);return window.setTimeout(()=>Zw(t),0),!0},onKeyDown:e=>Qw(e,r,i),"data-sw-thread-popover":e.id,children:s})}function eT({point:e,onClose:t,stowed:n,children:r}){return(0,Y.jsx)(Xw,{open:!0,onClose:t,selector:`[data-sw-draft-pin]`,point:e,label:`New comment`,stowed:n,className:`w-[340px] p-3`,"data-sw-composer-popover":`true`,children:r})}var tT=600,nT=e=>`shapewall.seen:${typeof window>`u`?``:window.location.pathname}:${e}`;function rT(e){try{let t=JSON.parse(window.localStorage.getItem(nT(e))||`{}`);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}function iT(e,t){try{let n=Object.entries(t).sort((e,t)=>String(t[1]).localeCompare(String(e[1]))).slice(0,tT);window.localStorage.setItem(nT(e),JSON.stringify(Object.fromEntries(n)))}catch{}}function aT(e){let t={at:e.createdAt||``,author:e.author,handle:e.authorHandle||null};for(let n of e.replies||[])String(n.createdAt)>String(t.at)&&(t={at:n.createdAt,author:n.author,handle:n.handle||null});return t}function oT(e,t){return t?t.handle&&e.handle?e.handle===t.handle:!!t.name&&String(e.author||``).toLowerCase()===String(t.name).toLowerCase():!1}function sT(e,t,n){let r=aT(e);return!r.at||oT(r,n)?!1:!t[e.id]||String(t[e.id])<String(r.at)}function cT(e){let[t,n]=(0,J.useState)(()=>rT(e));(0,J.useEffect)(()=>{n(rT(e));let t=t=>{t.key===nT(e)&&n(rT(e))};return window.addEventListener(`storage`,t),()=>window.removeEventListener(`storage`,t)},[e]);let r=(0,J.useCallback)(t=>{n(n=>{let r=!1,i={...n};for(let e of t){let t=aT(e).at;t&&String(i[e.id]||``)<String(t)&&(i[e.id]=t,r=!0)}return r?(iT(e,i),i):n})},[e]);return{seen:t,markSeen:(0,J.useCallback)(e=>r([e]),[r]),markAllSeen:r}}var lT=[`viewer`,`member`,`admin`,`owner`],uT=(e,t)=>lT.indexOf(e)>=lT.indexOf(t)&&lT.includes(e),dT=({isAuthor:e})=>!!e,fT=({role:e,isAuthor:t})=>uT(e,`member`)&&(!!t||uT(e,`admin`)),pT=`https://shapewall.com/contact`,mT={version:`0.3.0`,revision:`c34ececf96613a351c6811f5b6ee7e932d65e65b`},hT=e=>`v${e?.version||mT.version}${e?.revision?` · ${e.revision.slice(0,7)}`:``}`,gT=`modulepreload`,_T=function(e,t){return new URL(e,t).href},vT={},yT=function(e){return e.pathname.endsWith(`.css`)},bT=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},xT=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=_T(t,n);let r=s(t),i=yT(r);return bT(vT,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:gT,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},ST=(0,J.lazy)(()=>xT(()=>import(`./app-update-dialog-rhaw0MRk.js`),__vite__mapDeps([0,1,2]),import.meta.url)),CT=`shapewall:open-about`;function wT(e=null){window.dispatchEvent(new CustomEvent(CT,{detail:{opener:e}}))}function TT({transport:e,className:t,placement:n=`menu`,ref:i}){let[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),l=(0,J.useRef)(null),u=(0,J.useRef)(null),d=e=>{u.current=e||null,c(!0),o(!0)};(0,J.useImperativeHandle)(i,()=>({open:()=>d(document.activeElement)}),[]),(0,J.useEffect)(()=>{let e=e=>d(e.detail?.opener||null);return window.addEventListener(CT,e),()=>window.removeEventListener(CT,e)},[]);let f=()=>o(!1),p=e=>{e.preventDefault(),[u.current,l.current,document.querySelector(`[data-sw-profile-menu]`)].find(e=>e?.isConnected&&e!==document.body)?.focus()},m=`About Shapewall and updates, ${hT(mT)}, created by Dan Baruch`;return(0,Y.jsxs)(Y.Fragment,{children:[n===`footer`?(0,Y.jsx)(`footer`,{className:K(`flex shrink-0 justify-center border-t border-line bg-surface text-muted`,t),style:{paddingBottom:`env(safe-area-inset-bottom, 0px)`},children:(0,Y.jsxs)(r,{variant:`ghost`,size:`touch`,className:`gap-2 rounded-none px-3 text-[10px] font-normal lg:h-6`,onClick:()=>d(l.current),"aria-label":m,"data-sw-app-about":`footer`,ref:l,children:[(0,Y.jsx)(`span`,{children:`Created by Dan Baruch`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Y.jsx)(`span`,{"data-sw-app-version":!0,children:hT(mT)})]})}):n===`link`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,Y.jsx)(r,{asChild:!0,variant:`ghost`,size:`touch`,className:`px-2 text-caption font-normal text-faint hover:text-fg lg:h-8`,"data-sw-app-contact":`link`,children:(0,Y.jsx)(`a`,{href:pT,target:`_blank`,rel:`noopener noreferrer`,children:`Contact`})}),(0,Y.jsxs)(r,{variant:`ghost`,size:`touch`,className:K(`gap-1.5 px-2 text-caption font-normal text-faint hover:text-fg lg:h-8`,t),onClick:()=>d(l.current),"aria-label":m,"data-sw-app-about":`link`,ref:l,children:[(0,Y.jsx)(`span`,{children:`About Shapewall`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,"data-sw-app-version":!0,children:[`v`,mT.version]})]})]}):null,s?(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`span`,{role:`status`,className:`sr-only`,children:`Opening About & Updates…`}),children:(0,Y.jsx)(ST,{open:a,onClose:f,onCloseAutoFocus:p,transport:e})}):null]})}function ET({demo:e,className:n,children:r,align:i=`start`}){return e.viewAs?(0,Y.jsxs)(Ce,{children:[(0,Y.jsx)(C,{asChild:!0,children:r}),(0,Y.jsxs)(t,{align:i,className:K(`w-64`,n),children:[(0,Y.jsx)(D,{children:`View as (demo)`}),(0,Y.jsx)(A,{value:e.viewAs.value,onValueChange:e.viewAs.onChange,children:e.viewAs.options.map(e=>(0,Y.jsxs)(d,{value:e.id,"data-sw-view-as":e.id,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.hint?(0,Y.jsx)(`span`,{className:`truncate text-xs text-faint`,children:e.hint}):null]},e.id))})]})]}):r}var DT=()=>(0,Y.jsxs)(`span`,{className:`inline-flex h-5 shrink-0 items-center gap-1.5 rounded-full bg-accent/12 px-2 text-caption font-semibold text-accent`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent`,"aria-hidden":`true`}),`Demo`]});function OT({variant:e=`strip`,className:t}){let n=j();return n?e===`chip`?(0,Y.jsxs)(`div`,{className:K(`flex shrink-0 items-center gap-0.5 rounded-full border border-line bg-surface-2/60 p-0.5`,t),role:`region`,"aria-label":`Demo`,"data-sw-demo-banner":n.role,children:[(0,Y.jsx)(ET,{demo:n,align:`end`,children:(0,Y.jsxs)(r,{variant:`ghost`,size:`touch`,className:`h-11 gap-1.5 rounded-full px-2 text-ui text-fg lg:h-8`,"aria-label":`Demo, viewing as `+n.roleLabel+`. Change who you view as`,"data-sw-demo-view-as":!0,children:[(0,Y.jsx)(DT,{}),(0,Y.jsx)(`span`,{className:`hidden max-w-28 truncate font-medium sm:inline`,children:n.roleLabel}),(0,Y.jsx)(H,{size:13,className:`text-faint`,"aria-hidden":`true`})]})}),(0,Y.jsx)(z,{label:`Reset the demo`,size:`icon`,className:`rounded-full text-muted max-lg:hidden lg:h-8 lg:w-8`,onClick:n.reset,"data-sw-demo-reset":!0,children:(0,Y.jsx)(Jg,{size:14,"aria-hidden":`true`})}),(0,Y.jsx)(kT,{})]}):(0,Y.jsxs)(`div`,{className:K(`flex shrink-0 items-center gap-2 border-b border-line bg-surface px-2 text-ui text-muted sm:px-3 lg:h-9`,t),role:`region`,"aria-label":`Demo`,"data-sw-demo-banner":n.role,children:[(0,Y.jsx)(DT,{}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`hidden shrink-0 sm:inline`,children:`Viewing as`}),(0,Y.jsx)(ET,{demo:n,children:(0,Y.jsxs)(r,{variant:`ghost`,size:`touch`,className:`min-w-0 gap-1 px-1.5 text-ui text-fg lg:h-7`,"aria-label":`Viewing as `+n.roleLabel+`. Change who you view as`,"data-sw-demo-view-as":!0,children:[(0,Y.jsx)(`span`,{className:`truncate font-semibold`,children:n.roleLabel}),(0,Y.jsxs)(`span`,{className:`hidden truncate font-normal text-muted sm:inline`,children:[`(`,n.personaName,`)`]}),(0,Y.jsx)(H,{size:13,className:`shrink-0 text-faint`,"aria-hidden":`true`})]})}),(0,Y.jsx)(`span`,{className:`hidden truncate text-faint md:inline`,children:`· Changes stay in this browser`})]}),(0,Y.jsxs)(r,{variant:`ghost`,size:`touch`,className:`shrink-0 gap-1.5 px-2 text-ui text-muted lg:h-7`,onClick:n.reset,"data-sw-demo-reset":!0,children:[(0,Y.jsx)(Jg,{size:13,"aria-hidden":`true`}),` Reset`]}),(0,Y.jsx)(kT,{})]}):null}function kT(){let e=j();return e?(0,Y.jsx)(M,{open:!!e.resetAsked,onClose:e.cancelReset,title:`Reset the demo?`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{size:`touch`,variant:`ghost`,onClick:e.cancelReset,className:`lg:h-10`,"data-sw-demo-reset-cancel":!0,children:`Cancel`}),(0,Y.jsxs)(r,{size:`touch`,className:`border-bad/50 bg-bad text-bad-fg hover:bg-bad/90 lg:h-10`,onClick:e.resetNow,"data-sw-demo-reset-confirm":!0,children:[(0,Y.jsx)(Jg,{size:14,"aria-hidden":`true`}),` Reset`]})]}),children:(0,Y.jsx)(`p`,{className:`px-5 py-4 text-sm text-muted`,children:`Your comments, invites and changes in this browser go back to the start.`})}):null}var AT={unknown:{title:`This share link is not valid`,text:`Check that you have the whole link, or ask whoever shared it for a new one.`},revoked:{title:`This share link was revoked`,text:`Whoever shared it turned it off. Ask them for a new link.`},expired:{title:`This share link has expired`,text:`Share links work for a set time. Ask whoever shared it for a new one.`},off:{title:`This share link is turned off`,text:`The workspace no longer allows share links, or the person who made it can no longer share. Ask them for a new link.`}};function jT({problem:e,onLeave:t}){let n=AT[e?.status]||AT.unknown,i=e?.at?new Date(e.at):null;return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Y.jsx)(OT,{}),(0,Y.jsx)(`main`,{className:`flex flex-1 items-center justify-center p-4`,children:(0,Y.jsxs)(`div`,{className:`w-full max-w-md rounded-xl border border-line bg-surface p-6 text-center shadow-card sm:p-8`,role:`alert`,"data-sw-share-problem":e?.status||`unknown`,children:[(0,Y.jsx)(`span`,{className:`inline-flex h-11 w-11 items-center justify-center rounded-xl bg-bad/10 text-bad`,children:(0,Y.jsx)(ig,{size:20,"aria-hidden":`true`})}),(0,Y.jsx)(`h1`,{className:`mt-4 text-xl font-semibold text-fg`,children:n.title}),(0,Y.jsxs)(`p`,{className:`mt-2 text-sm text-muted`,children:[n.text,i&&Number.isFinite(i.getTime())?(0,Y.jsxs)(Y.Fragment,{children:[` `,e.status===`revoked`?`Revoked`:`Expired`,` `,i.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),`.`]}):null]}),(0,Y.jsx)(`p`,{className:`mt-4 text-xs text-muted`,children:`In the demo, share links are made on a project's page in the console.`}),(0,Y.jsx)(r,{size:`touch`,variant:`default`,className:`mt-5 lg:h-10`,onClick:t,"data-sw-share-problem-leave":!0,children:`Open the demo board`})]})})]})}async function MT(e,t,n){let r;try{r=await fetch(t,{method:e,credentials:`same-origin`,headers:{...n===void 0?{Accept:`application/json`}:{Accept:`application/json`,"Content-Type":`application/json`},...typeof document<`u`&&document.querySelector(`meta[name="shapewall-local-accounts"]`)&&t.startsWith(`/auth/`)?Se():{}},body:n===void 0?void 0:JSON.stringify(n),cache:`no-store`})}catch{throw new Je(0,`offline`,`Could not reach the server. Check your connection and try again.`)}let i=null;try{i=await r.json()}catch{i=null}if(!r.ok){let e=Number(r.headers.get(`Retry-After`)),t=i?.error?.message||`Request failed (${r.status})`;throw new Je(r.status,i?.error?.code||`error`,r.status===429&&e>0?PT(t,e):t,{retryAfter:r.status===429&&e>0?e:null})}return i}function NT(e){return e>=5400?`${Math.ceil(e/3600)} hours`:e>=90?`${Math.ceil(e/60)} minutes`:e>60?`2 minutes`:e===1?`1 second`:`${e} seconds`}var PT=(e,t)=>`${e.replace(/\s*Wait (a while|a moment) and try again\.?\s*$/i,``)} Try again in ${NT(t)}.`,FT={get:e=>MT(`GET`,e),post:(e,t={})=>MT(`POST`,e,t),patch:(e,t={})=>MT(`PATCH`,e,t),put:(e,t={})=>MT(`PUT`,e,t),delete:(e,t)=>MT(`DELETE`,e,t)},IT=e=>{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t+`===`.slice((t.length+3)%4));return Uint8Array.from(n,e=>e.charCodeAt(0)).buffer},LT=e=>btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);async function RT(e,{mediation:t,signal:n}={}){let r={...e,challenge:IT(e.challenge),allowCredentials:(e.allowCredentials||[]).map(e=>({...e,id:IT(e.id)}))},i=await navigator.credentials.get({publicKey:r,...t?{mediation:t}:{},...n?{signal:n}:{}}),a=i.response;return{id:i.id,rawId:LT(i.rawId),type:i.type,authenticatorAttachment:i.authenticatorAttachment||void 0,clientExtensionResults:i.getClientExtensionResults(),response:{clientDataJSON:LT(a.clientDataJSON),authenticatorData:LT(a.authenticatorData),signature:LT(a.signature),userHandle:a.userHandle?LT(a.userHandle):void 0}}}async function zT(){let{options:e}=await FT.post(`/auth/reauth/options`,{}),t=await RT(e);await FT.post(`/auth/reauth/verify`,{response:t})}function BT({boardId:e}){let[t,n]=(0,J.useState)([]),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!1),u=`/api/boards/${encodeURIComponent(e)}/approvals`;(0,J.useEffect)(()=>{let t=!0,r=()=>Ke.get(`/api/boards/${encodeURIComponent(e)}/agent-budget`).then(e=>{t&&a(e)}).catch(()=>{}),i=()=>Ke.get(u).then(e=>{t&&n(e.approvals)}).catch(()=>{});i(),r();let o=()=>{document.visibilityState===`visible`&&(i(),r())},s=setInterval(o,3e3);return document.addEventListener(`visibilitychange`,o),()=>{t=!1,clearInterval(s),document.removeEventListener(`visibilitychange`,o)}},[u,e]);let d=async(e,t)=>{l(!0),s(null);try{await zT(),await Ke.post(`${u}/${e.id}`,{state:t,hash:e.command_hash}),n(t=>t.filter(t=>t.id!==e.id))}catch(e){s(e.message)}finally{l(!1)}};return!t.length&&!o&&!i?.exhausted?null:(0,Y.jsxs)(`section`,{"aria-label":`Agent command approvals`,className:`max-h-64 shrink-0 overflow-auto border-b border-line bg-surface p-3 text-sm`,children:[i?.exhausted?(0,Y.jsxs)(`p`,{role:`status`,className:`pb-2`,children:[`The agent hit today’s limit: `,i.claims,`/`,i.dailyLimit,` runs, `,i.open,`/`,i.openLimit,` in progress. Change limits in Agent policy in the console.`]}):null,t.map(e=>(0,Y.jsxs)(`article`,{className:`space-y-2 pb-3`,children:[(0,Y.jsxs)(`p`,{className:`font-semibold`,children:[`Agent asks to run a command for comment #`,e.comment_number]}),(0,Y.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap break-words rounded bg-surface-2 p-2`,children:e.command.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}),(0,Y.jsx)(`p`,{children:e.reason}),(0,Y.jsx)(r,{size:`touch`,variant:`default`,className:`lg:h-8`,disabled:c,onClick:()=>d(e,`approved`),children:`Approve once with passkey`}),` `,(0,Y.jsx)(r,{size:`touch`,variant:`danger`,className:`lg:h-8`,disabled:c,onClick:()=>d(e,`denied`),children:`Deny`})]},e.id)),o?(0,Y.jsx)(`p`,{role:`alert`,className:`text-bad`,children:o}):null]})}var VT={share:{title:`This link was revoked`,body:`Or it expired. The board stops updating and you cannot comment. Ask whoever shared it for a new link.`,href:null},signed_out:{title:`You were signed out`,body:`Sign in again to keep working on this board.`,href:`signin`},removed:{title:`You don't have access to this board any more`,body:`You may have been removed from the workspace. Ask an admin to invite you again.`,href:`home`}};function HT(){let[e,t]=(0,J.useState)(null);if((0,J.useEffect)(()=>{let e=e=>t(t=>t||e.detail?.kind||null);return window.addEventListener(le,e),()=>window.removeEventListener(le,e)},[]),!e)return null;let n=VT[e],r=encodeURIComponent(window.location.pathname+window.location.search);return(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-bad/30 bg-bad/10 px-4 py-2 text-sm text-fg`,role:`alert`,"data-sw-access-lost":e,children:[e===`share`?(0,Y.jsx)(ig,{size:15,className:`shrink-0 text-bad`,"aria-hidden":`true`}):(0,Y.jsx)(mg,{size:15,className:`shrink-0 text-bad`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:n.title}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 text-muted`,children:n.body}),n.href===`signin`?(0,Y.jsx)(`a`,{href:`/signin?next=${r}`,className:`inline-flex h-11 items-center font-medium text-accent underline-offset-2 hover:underline lg:h-auto`,children:`Sign in`}):n.href===`home`?(0,Y.jsx)(`a`,{href:`/`,className:`inline-flex h-11 items-center font-medium text-accent underline-offset-2 hover:underline lg:h-auto`,children:`Your workspaces`}):null]})}var UT=`You're a viewer. Ask an admin for member access to comment.`;function WT({compact:e=!1}){return(0,Y.jsx)(h,{content:UT,side:`bottom`,children:(0,Y.jsxs)(`span`,{role:`note`,tabIndex:0,"aria-label":UT,className:K(`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-line bg-surface-2 text-xs font-medium whitespace-nowrap text-muted outline-none focus-visible:outline-2 focus-visible:outline-accent`,e?`h-11 px-2.5`:`h-8 px-2.5`),"data-sw-viewer-note":!0,children:[(0,Y.jsx)(Sh,{size:14,"aria-hidden":`true`}),` Viewer`]})})}function GT({project:e}){return(0,Y.jsx)(h,{content:`Back to ${e.name}`,side:`bottom`,align:`start`,children:(0,Y.jsx)(`a`,{href:e.url,className:`block max-w-full min-w-0 truncate rounded-sm px-2.5 text-[11px] leading-3.5 font-medium text-muted outline-none hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,"data-sw-project-crumb":!0,children:e.name})})}var KT={includes:e=>typeof e==`string`&&(e===`all`||/^[a-z][a-z0-9-]{0,31}$/.test(e))};function qT({enabled:e,boardId:t,canvasRef:n,flow:r,selection:i,mode:a,onMode:o,onInvalidate:s}){let[c,l]=(0,J.useState)([]),[u,d]=(0,J.useState)(0),[f,p]=(0,J.useState)(`offline`),[m,h]=(0,J.useState)(null),g=(0,J.useRef)({cursor:null});g.current={...g.current,selection:i,mode:a,onMode:o,onInvalidate:s};let _=(0,J.useRef)(null);return em({onChange:e?()=>_.current?.():void 0}),(0,J.useEffect)(()=>{_.current?.()},[i,a]),(0,J.useEffect)(()=>{if(!e){l([]),d(0),h(null);return}let i=!1,a;return xT(async()=>{let{connectPresence:e}=await import(`./runtime-Bft6x_6E.js`);return{connectPresence:e}},[],import.meta.url).then(({connectPresence:e})=>{i||(a=e({boardId:t,canvasRef:n,flow:r,latest:g,sendRef:_,setPeers:l,setCount:d,setFollowing:h,setStatus:p}))}).catch(()=>{i||p(`offline`)}),()=>{i=!0,a?.()}},[e,t,n,r]),(0,J.useEffect)(()=>{if(m===null)return;let e=c.find(e=>e.id===m);if(!e){h(null);return}let t=e.viewport;if(!t||![t.x,t.y,t.zoom].every(Number.isFinite)||!KT.includes(e.mode))return;g.current.mode!==e.mode&&g.current.onMode?.(e.mode);let n=window.requestAnimationFrame(()=>{let e=r.getViewport();(Math.abs(e.x-t.x)>.01||Math.abs(e.y-t.y)>.01||Math.abs(e.zoom-t.zoom)>.001)&&r.setViewport(t,{duration:0})});return()=>window.cancelAnimationFrame(n)},[m,c,r]),{peers:c,count:u,status:f,following:m,follow:h,stopFollowing:()=>h(null)}}function JT({touch:e,...t}){let n=qT(t);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(QT,{presence:n}),(0,Y.jsx)(ZT,{presence:n,touch:e})]})}var YT=e=>`${e.id}|${e.name}|${e.color}|${+!!e.viewport}`;function XT(e,t){let n=e.presence,r=t.presence;return e.touch===t.touch&&n.status===r.status&&n.count===r.count&&n.following===r.following&&n.peers.length===r.peers.length&&n.peers.every((e,t)=>YT(e)===YT(r.peers[t]))}var ZT=(0,J.memo)(function({presence:e,touch:t}){if(e.status!==`online`)return null;let n=e.peers.find(t=>t.id===e.following);return(0,Y.jsxs)(`div`,{className:`absolute top-14 right-2 z-30 flex max-w-[calc(100%-1rem)] flex-wrap items-center justify-end gap-1 rounded-xl border border-line bg-surface/95 p-1 shadow-pop`,"aria-label":`Who is viewing`,"data-sw-presence":`true`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 text-xs text-muted`,"data-sw-presence-count":e.count,children:[(0,Y.jsx)(P_,{size:13,"aria-hidden":`true`}),e.count,` viewing`]}),e.peers.slice(0,5).map(n=>(0,Y.jsx)(h,{content:`${n.name}${n.viewport?`: follow their view`:``}`,children:(0,Y.jsx)(r,{size:t?`icon`:`icon-sm`,variant:e.following===n.id?`default`:`ghost`,"aria-label":`Follow ${n.name}`,"aria-pressed":e.following===n.id,disabled:!n.viewport,"data-sw-presence-peer":n.id,onClick:()=>e.follow(e.following===n.id?null:n.id),children:(0,Y.jsx)(se,{person:!0,name:n.name,color:n.color,size:`sm`})})},n.id)),e.peers.length>5?(0,Y.jsxs)(`span`,{className:`px-1 text-xs text-muted`,children:[`+`,e.peers.length-5]}):null,n?(0,Y.jsxs)(r,{size:t?`touch`:`xs`,variant:`secondary`,onClick:e.stopFollowing,"data-sw-stop-follow":`true`,children:[`Stop following `,n.name]}):null]})},XT);function QT({presence:e}){let t=e.peers.filter(e=>e.cursor&&Number.isFinite(e.cursor.x)&&Number.isFinite(e.cursor.y));return(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-20 overflow-hidden`,"aria-hidden":`true`,"data-sw-presence-cursors":`true`,children:t.length?(0,Y.jsx)($T,{peers:t}):null})}function $T({peers:e}){let{x:t,y:n,zoom:r}=Qp();return e.map(e=>(0,Y.jsxs)(`div`,{className:`absolute top-0 left-0`,style:{transform:`translate(${e.cursor.x*r+t}px, ${e.cursor.y*r+n}px)`,color:e.color},"data-sw-presence-cursor":e.id,"data-sw-cursor-x":e.cursor.x,"data-sw-cursor-y":e.cursor.y,children:[(0,Y.jsx)(Pg,{size:18,fill:`currentColor`,stroke:`white`,strokeWidth:1.5}),(0,Y.jsx)(`span`,{className:`ml-3 block max-w-36 truncate rounded px-1.5 py-0.5 text-[10px] text-white shadow-sm`,style:{background:e.color},children:e.name})]},e.id))}var eE=`shapewall.appearance`,tE=[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}],nE=[{id:`default`,label:`Default`},{id:`ocean`,label:`Ocean`},{id:`forest`,label:`Forest`},{id:`contrast`,label:`High contrast`}],rE={mode:`system`,theme:`default`};function iE(e){return{mode:tE.some(t=>t.id===e?.mode)?e.mode:rE.mode,theme:nE.some(t=>t.id===e?.theme)?e.theme:rE.theme}}var aE=(e,t)=>e===`system`?t?`dark`:`light`:e,oE=typeof window<`u`,sE=()=>oE&&window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`):null;function cE(){try{return iE(JSON.parse(window.localStorage.getItem(`shapewall.appearance`)||`null`))}catch{return{...rE}}}var lE=oE?cE():{...rE},uE=new Set;function dE(){let e=getComputedStyle(document.documentElement).getPropertyValue(`--surface`).trim();if(e)for(let t of document.querySelectorAll(`meta[name="theme-color"]`))t.removeAttribute(`media`),t.setAttribute(`content`,e)}function fE(e=lE){if(!oE)return;let t=document.documentElement;t.setAttribute(`data-mode`,aE(e.mode,!!sE()?.matches)),t.setAttribute(`data-theme`,e.theme),dE()}function pE(){return lE}function mE(e){lE=iE({...lE,...e});try{window.localStorage.setItem(eE,JSON.stringify(lE))}catch{}fE(),uE.forEach(e=>e())}oE&&(fE(),sE()?.addEventListener?.(`change`,()=>{lE.mode===`system`&&(fE(),uE.forEach(e=>e()))}),window.addEventListener(`storage`,e=>{e.key===`shapewall.appearance`&&(lE=cE(),fE(),uE.forEach(e=>e()))}));var hE=e=>(uE.add(e),()=>uE.delete(e));function gE(){return[(0,J.useSyncExternalStore)(hE,pE,pE),mE]}var _E=()=>oE?aE(lE.mode,!!sE()?.matches):`light`;function vE(){return(0,J.useSyncExternalStore)(hE,_E,_E)}var yE=`shapewall.demo.try`;function bE(){try{return window.localStorage.getItem(yE)===`1`}catch{return!1}}function xE(e){let[t,n]=(0,J.useState)(()=>e&&!bE());return[e&&t,()=>{n(!1);try{window.localStorage.setItem(yE,`1`)}catch{}}]}function SE({touch:e,done:t,onOpenComment:n,onComment:i,onAgent:a,onClose:o}){let[s,c]=(0,J.useState)(!0),l=[{id:`open`,icon:wg,label:`Open a comment`,hint:e?`Tap a pin on a page`:`Click a pin on a page`,run:n},i&&{id:`comment`,icon:Sg,label:e?`Pin your own comment`:`Press C to comment`,hint:e?`The comment button, then a page`:`Then click anywhere on a page`,run:i},a?{id:`agent`,icon:S,label:`Ask the agent`,hint:e?`In the ... menu`:`It reads the open comments`,run:a}:null].filter(Boolean),u=l.filter(e=>t.has(e.id)).length,d=e?`bottom-16 left-2`:`bottom-16 left-3`;return s?(0,Y.jsxs)(`button`,{type:`button`,className:K(`pointer-events-auto absolute z-30 inline-flex items-center gap-2 rounded-full border border-line bg-surface/95 pr-3 pl-2 text-[13px] font-medium text-fg shadow-pop backdrop-blur outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent`,e?`h-11`:`h-9`,d),onClick:()=>c(!1),"aria-expanded":`false`,"aria-label":`Try this: ${u} of ${l.length} done. Show the tips`,"data-sw-try-this":`folded`,children:[(0,Y.jsx)(m_,{size:15,className:`text-accent`,"aria-hidden":`true`}),` Try this`,(0,Y.jsxs)(`span`,{className:`tabular text-xs text-muted`,children:[u,`/`,l.length]})]}):(0,Y.jsxs)(`section`,{className:K(`pointer-events-auto absolute z-30 animate-pop-in rounded-xl border border-line bg-surface/95 p-3 text-fg shadow-pop backdrop-blur`,e?`inset-x-2 bottom-16`:`bottom-16 left-3 w-72`),"aria-label":`Try this`,"data-sw-try-this":`true`,children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,Y.jsx)(m_,{size:15,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsxs)(`h2`,{className:`min-w-0 flex-1 text-sm font-semibold`,children:[`Try this`,` `,(0,Y.jsxs)(`span`,{className:`tabular text-xs font-medium text-muted`,children:[u,`/`,l.length]})]}),(0,Y.jsx)(z,{size:e?`icon`:`icon-xs`,onClick:()=>c(!0),label:`Fold the tips away`,"aria-expanded":`true`,"data-sw-try-fold":`true`,children:(0,Y.jsx)(H,{size:14,"aria-hidden":`true`})}),(0,Y.jsx)(z,{size:e?`icon`:`icon-xs`,onClick:o,label:`Close the tips for good`,"data-sw-try-close":`true`,children:(0,Y.jsx)(g,{size:14,"aria-hidden":`true`})})]}),(0,Y.jsx)(`ol`,{className:`flex flex-col gap-1`,children:l.map(n=>{let i=t.has(n.id),a=i?m:n.icon;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(r,{size:e?`touch`:`sm`,variant:`ghost`,className:`h-auto w-full justify-start py-1.5 text-left`,onClick:n.run,"data-sw-try-step":n.id,"data-sw-try-done":i?`true`:void 0,children:[(0,Y.jsx)(`span`,{className:K(`flex h-6 w-6 shrink-0 items-center justify-center rounded-full`,i?`bg-ok/15 text-ok`:`bg-accent/10 text-accent`),"aria-hidden":`true`,children:(0,Y.jsx)(a,{size:13})}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:K(`block text-[13px] font-medium text-fg`,i&&`text-muted line-through decoration-faint`),children:n.label}),(0,Y.jsx)(`span`,{className:`block text-xs font-normal text-muted`,children:n.hint})]})]})},n.id)})}),(0,Y.jsx)(`p`,{className:`mt-2 border-t border-line px-2 pt-2 text-xs text-muted`,"data-sw-try-nav":`true`,children:e?`Drag to move around, pinch to zoom.`:`Scroll to move, Ctrl+scroll or pinch to zoom, Space+drag to pan.`})]})}var CE=new Map,wE=10;function TE(e,t,n,r){let i=n*t*4;for(let n=0;n<t;n+=1){let t=i+n*4;if(Math.abs(e[t]-r[0])>wE||Math.abs(e[t+1]-r[1])>wE||Math.abs(e[t+2]-r[2])>wE)return!0}return!1}function EE(e,t,n){if(!t||!n)return 1;let r=(n-1)*t*4,i=[e[r],e[r+1],e[r+2]];for(let r=n-1;r>=0;--r)if(TE(e,t,r,i))return Math.min(1,(r+1)/n);return 1}function DE(e){if(!e||typeof document>`u`)return Promise.resolve(1);if(CE.has(e))return CE.get(e);let t=new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=Math.min(n.naturalWidth,200),r=Math.round(n.naturalHeight*e/n.naturalWidth),i=document.createElement(`canvas`);i.width=e,i.height=r;let a=i.getContext(`2d`,{willReadFrequently:!0});a.drawImage(n,0,0,e,r),t(EE(a.getImageData(0,0,e,r).data,e,r))}catch{t(1)}},n.onerror=()=>t(1),n.src=e});return CE.set(e,t),t}var OE=()=>typeof window<`u`&&!!window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,kE=e=>OE()?0:e,AE=()=>OE()?`auto`:`smooth`,jE=.02,ME={padding:.16};function NE(e,t,n,r=92){if(!t?.width||!t?.height)return e;let i=Math.min(t.width/e.width,t.height/e.height)/(1+2*n),a=r/Math.max(i,.01);return{...e,y:e.y-a,height:e.height+a}}function PE(e){let t=String(e||``).split(`,`).map(Number);return t.length!==3||t.some(e=>!Number.isFinite(e))||t[2]<=0?null:{x:t[0],y:t[1],zoom:t[2]}}function FE(e,t,n,{phoneCompare:r,shotUrls:i}){let a=t.frames[0];if(r&&a&&n?.width){let r=Math.min(4,(n.width-16)/t.w);e.setViewport({x:8-t.x*r,y:70-(t.y+a.y)*r,zoom:r},{duration:kE(450)});return}let o=r=>e.fitBounds(NE({x:t.x,y:t.y,width:t.w,height:Math.min(t.h,(a?a.y+a.h*r:t.h)+16)},n,.12),{padding:.12,duration:kE(450)});!a||!i.length?o(1):Promise.all(i.map(e=>DE(e))).then(e=>o(Math.max(.2,...e))).catch(()=>o(1))}function IE(e,t,n,r=24){let i=n.map(n=>e.x+t.x+t.w*n.spot.x/100),a=n.map(n=>e.y+t.y+t.h*n.spot.y/100);return{x:Math.min(...i)-r,y:Math.min(...a)-r,width:Math.max(...i)-Math.min(...i)+r*2,height:Math.max(...a)-Math.min(...a)+r*2}}var LE=.34,RE=12,zE=.75,BE=72,VE=40;function HE(e,t,n=ME.padding){if(!t?.width||!t?.height||!e?.length)return null;let r=e.filter(e=>e.type===`groupFrame`),i=UE(r.length?r:e);if(!i)return null;let a=Math.min(t.width/(i.width*(1+2*n)),t.height/(i.height*(1+2*n))),o=e.filter(e=>e.type!==`groupFrame`).length;if(a>=.34||!r.length||o<=RE)return null;let s=[...r].sort((e,t)=>e.position.y-t.position.y||e.position.x-t.position.x)[0],c=s.width??s.style?.width??0,l=s.height??s.style?.height??0,u=Math.min((t.width-80)/c,(t.height-BE-24)/l),d=Math.max(a,LE,Math.min(zE,u));return{x:VE-s.position.x*d,y:BE-s.position.y*d,zoom:d}}function UE(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e){let e=a.width??a.style?.width??0,o=a.height??a.style?.height??0;t=Math.min(t,a.position.x),n=Math.min(n,a.position.y),r=Math.max(r,a.position.x+e),i=Math.max(i,a.position.y+o)}return Number.isFinite(t)?{x:t,y:n,width:r-t,height:i-n}:null}var WE={top:100,bottom:64,side:24},GE=280,KE=2;function qE(e,t,n=.5){if(!t?.width||!t?.height||!e?.width||!e?.height)return null;let{top:r,bottom:i,side:a}=WE,o=Math.max(1,t.width-a*2),s=Math.max(1,t.height-r-i),c=o/e.width,l=Math.min(c,s/e.height),u=Math.min(KE,4,Math.max(l,Math.min(c,GE/e.width))),d=e.width*u,f=e.height*u,p=a+(o-d)/2-e.x*u,m=r+(s-f)/2-e.y*u;if(f>s){m=r-e.y*u;let t=e.y+e.height*Math.min(1,Math.max(0,n));m+t*u>r+s*.8&&(m=Math.max(r+s-(e.y+e.height)*u,r+s/2-t*u))}return{x:p,y:m,zoom:u}}function JE(e){let t=Uu(),[n,r]=(0,J.useState)(null),i=(0,J.useRef)(null),a=(0,J.useCallback)(e=>{i.current=e,r(e)},[]);return(0,J.useEffect)(()=>{if(!e)return;let n=null,r=()=>{window.clearTimeout(n),n=window.setTimeout(()=>a(t.getState().transform[2]),300)};r();let o=t.getState().transform[2],s=t.subscribe(e=>{let t=e.transform[2];t!==o&&(o=t,i.current!==null&&t<i.current*.8&&a(t),r())});return()=>{window.clearTimeout(n),s()}},[e,a,t]),[n,a]}var YE=`shapewall.minimap`;function XE(){try{let e=window.localStorage.getItem(YE);return e===`on`||e!==`off`&&null}catch{return null}}function ZE(e){return e>=30}var QE=`shapewall.tip.board`;function $E(){try{return window.localStorage.getItem(QE)===`1`}catch{return!1}}function eD(e){try{window.localStorage.setItem(YE,e?`on`:`off`)}catch{}}function tD(){try{window.localStorage.setItem(QE,`1`)}catch{}}var nD=`shapewall.rail.`;function rD(e){try{let t=Number(window.localStorage.getItem(nD+e));return Number.isFinite(t)&&t>0?t:null}catch{return null}}function iD(e,t){try{t==null?window.localStorage.removeItem(nD+e):window.localStorage.setItem(nD+e,String(Math.round(t)))}catch{}}var aD=8;function oD({groups:e,onPick:t}){let[n,i]=(0,J.useState)(``),a=n.trim().toLowerCase(),o=e.flatMap(e=>e.pages.map(t=>({...t,group:e.group}))),s=a?o.filter(e=>`${e.title} ${e.path||``} ${e.group}`.toLowerCase().includes(a)):o.slice(0,aD);return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,"data-sw-page-finder":`true`,children:[(0,Y.jsx)(Ge,{size:`touch`,icon:n_,value:n,onChange:e=>i(e.target.value.slice(0,80)),placeholder:`Search ${o.length} pages`,"aria-label":`Search pages`,"data-sw-page-search":`true`}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:s.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(r,{size:`touch`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>t(e.id),"data-sw-page-pick":e.id,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title}),(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-faint`,children:e.group})]})},e.id))}),s.length?null:(0,Y.jsxs)(`p`,{className:`px-1 text-sm text-muted`,children:[`No page matches "`,n.trim(),`".`]}),!a&&o.length>aD?(0,Y.jsxs)(`p`,{className:`px-1 text-xs text-faint`,children:[o.length-aD,` more: type to find them.`]}):null]})}var sD=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent||``),cD=sD?`⌘K`:`Ctrl K`,lD=60,uD=6,dD=e=>String(e||``).toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``);function fD(e,...t){let n=0;for(let[r,i]of t.entries()){let t=dD(i);if(!t)continue;let a=r===0?1:.5;t.startsWith(e)?n=Math.max(n,3*a):t.includes(` ${e}`)||t.includes(`/${e}`)?n=Math.max(n,2*a):t.includes(e)&&(n=Math.max(n,1*a))}return n}var pD=e=>e.filter(e=>e.score>0).sort((e,t)=>t.score-e.score).map(e=>e.entry);function mD({query:e,groups:t,journeys:n,canEditJourneys:r,comments:i,actions:a,titleOf:o}){let s=dD(e.trim()),c=t.flatMap(e=>e.pages.map(t=>({id:t.id,kind:`page`,icon:Eh,title:t.title,detail:t.path||``,meta:e.group,run:{type:`page`,id:t.id}}))),l=n.map(e=>({id:`journey:${e.id}`,kind:`journey`,icon:Qg,title:e.name,detail:e.description||``,meta:e.branching?`${e.paths?.length||2} paths`:`${e.steps.length} steps`,run:{type:`journey`,id:e.id}}));r&&l.push({id:`journey:__new`,kind:`journey`,icon:Hg,title:`New journey`,detail:`Click pages in the order people visit them`,meta:``,run:{type:`new-journey`}});let u=a.map(e=>({id:`action:${e.id}`,kind:`action`,icon:e.icon||R_,title:e.label,detail:e.detail||``,meta:e.keys||``,run:{type:`action`,run:e.run}}));if(!s)return[l.length?{id:`journeys`,label:`Journeys`,items:l}:null,{id:`pages`,label:`Pages`,items:c.slice(0,lD),more:Math.max(0,c.length-lD)},u.length?{id:`actions`,label:`Actions`,items:u}:null].filter(Boolean);let d=/^#?(\d{1,7})$/.exec(s)?.[1],f=e=>({id:`comment:${e.id}`,kind:`comment`,icon:wg,title:`#${e.id} ${String(e.body||``).split(`
|
|
32
|
+
`).length)),D=`sw-reply-image-error-${e.id}`;return(0,Y.jsxs)(`form`,{className:`flex flex-wrap items-end gap-2 border-t border-line px-3 py-2`,onSubmit:T,...jx(b,v),"data-sw-reply-form":e.id,children:[f?(0,Y.jsxs)(`label`,{className:`flex w-full items-center gap-2 text-xs text-muted`,children:[(0,Y.jsx)(`span`,{className:`shrink-0`,children:`Your name`}),(0,Y.jsx)(Ge,{size:i?`touch`:`xs`,value:m,onChange:e=>h(e.target.value.slice(0,60)),placeholder:`shown on your reply`,className:`flex-1`,"data-sw-reply-author":e.id})]}):null,(0,Y.jsxs)(`label`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`span`,{className:`sr-only`,children:[`Reply to comment `,e.id]}),(0,Y.jsx)(sb,{rows:E,size:i?`touch`:`sm`,value:u,maxLength:HC,onChange:d,people:a,className:`resize-none`,placeholder:i?`Reply`:`Reply, @ to mention`,onKeyDown:e=>{UC(e,i)&&(e.preventDefault(),T())},autoFocus:o,"aria-describedby":b.error?D:void 0,"data-sw-reply-input":e.id})]}),(0,Y.jsx)(z,{type:`submit`,variant:`default`,size:i?`icon`:`icon-sm`,className:`rounded-full`,disabled:t||b.reading||!u.trim(),label:t&&b.images.length?`Uploading the reply`:`Send reply`,"data-sw-reply-send":e.id,children:(0,Y.jsx)(Wm,{size:16,"aria-hidden":`true`})}),v?(0,Y.jsx)(`div`,{className:`w-full`,children:(0,Y.jsx)(Mx,{draft:b,touch:i,id:D})}):null,v||y||l?.attachNote?(0,Y.jsxs)(`div`,{className:`-mt-1 -ml-1 flex w-full flex-wrap items-center gap-0.5`,"data-sw-reply-media":e.id,children:[y&&!i?(0,Y.jsx)(Ex,{owner:x,touch:!1,compact:!0,className:`flex-1`,leading:v?(0,Y.jsx)(Ax,{draft:b,touch:!1,disabled:t}):null}):v?(0,Y.jsx)(Ax,{draft:b,touch:i,disabled:t}):null,y&&i&&w?(0,Y.jsxs)(r,{size:`touch`,variant:`ghost`,onClick:()=>_(!0),"data-sw-draw-open":`true`,children:[(0,Y.jsx)(Km,{size:16,"aria-hidden":`true`}),` `,C?`Drawing (${C})`:`Draw on the page`]}):null,l?.attachNote?(0,Y.jsx)(`p`,{className:`w-full px-1 text-caption text-faint`,"data-sw-attach-note":`true`,children:l.attachNote}):null]}):null,y&&i&&w?(0,Y.jsx)(kx,{open:g,onClose:()=>_(!1),owner:x,src:w.src,native:w.native,title:l.pageTitle}):null]})}function Ww({item:e,currentVersion:t,onShow:n}){if(!e?.drawing?.shapes?.length)return null;let r=!!(e.drawing.captureVersion&&t&&e.drawing.captureVersion!==t),i=e.drawing.shapes.length;return(0,Y.jsxs)(`p`,{className:`mt-1.5 text-xs text-muted`,"data-sw-message-drawing":r?`previous`:`current`,children:[(0,Y.jsx)(Km,{size:11,className:`mr-1 inline-block align-[-1px]`,"aria-hidden":`true`}),r?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{children:[`Drawn on the previous capture (`,i===1?`one shape`:`${i} shapes`,`).`]}),` `,n?(0,Y.jsx)(`button`,{type:`button`,className:`rounded text-accent underline-offset-2 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-accent`,onClick:n,"data-sw-show-drawing":`true`,children:`View it on Before`}):null]}):(0,Y.jsxs)(`span`,{children:[`Drawn on the page (`,i===1?`one shape`:`${i} shapes`,`), shown over the frame.`]})]})}function Gw({comment:e,page:n,title:i,people:a,touch:o,me:s,can:c,busy:l,actions:u,nav:d,beforeAfter:f,onClose:p=null,editingRef:v=null,denial:y=null,role:b=null,hosted:x=null,onSaveName:w=null,media:E=null}){let[D,O]=(0,J.useState)(!1),[k,A]=(0,J.useState)(!1),j=(0,J.useRef)(null);(0,J.useEffect)(()=>{O(!1),A(!1)},[e.id]),v&&(v.current=D?()=>O(!1):null);let M=e.replies?.length||0;(0,J.useEffect)(()=>{let e=j.current;e&&(e.scrollTop=e.scrollHeight)},[e.id,M]);let N=e.status===`resolved`,P=N&&e.agentStatus!==`done`?null:e.agentStatus,F=o?`icon`:`icon-sm`,ee=fv(e.viewport,null),I=!!u.onFixAgent&&e.status===`open`,L=e.reopenCount>0&&!N||!!P,B=e.github?.issue?Vy(e.github.issue.url):null,V=E?.currentVersion?.(e)||null,H=()=>{let e=j.current?.querySelector(`[data-sw-before-after]`);e?.scrollIntoView?.({block:`nearest`}),e?.querySelector(`[data-sw-compare-handle], [role="tab"]`)?.focus?.()},U=[u.onCopyLink?{id:`link`,label:`Copy link`,icon:og,run:()=>u.onCopyLink(e),hook:`data-sw-copy-link`}:null,c.edit?{id:`edit`,label:`Edit`,icon:Bg,run:()=>O(!0),hook:`data-sw-edit`}:null,u.onAskAgent?{id:`agent`,label:`Ask agent`,icon:S,run:()=>u.onAskAgent(e),hook:`data-sw-ask-agent`}:null,B?{id:`issue`,label:`Open issue #${e.github.issue.number} on GitHub`,icon:nh,href:B,hook:`data-sw-github-open`}:u.onGithubIssue&&c.resolve?{id:`issue`,label:`Create a GitHub issue`,icon:nh,run:()=>u.onGithubIssue(e),hook:`data-sw-github-issue`}:null,u.onHistory&&n?{id:`history`,label:`Page history`,icon:Kg,run:()=>u.onHistory(e),hook:`data-sw-comment-history`}:null,n?.url?{id:`page`,label:`Open the page`,icon:bh,href:n.url,hook:`data-sw-open-page`}:null].filter(Boolean);return(0,Y.jsxs)(`div`,{className:`flex max-h-[inherit] min-h-0 flex-col`,"data-sw-selected-comment":e.id,"data-sw-thread":e.id,children:[(0,Y.jsxs)(`div`,{className:K(`flex shrink-0 items-center gap-0.5 border-b border-line`,o?`px-2 py-1`:`py-1 pr-1 pl-3`),children:[(0,Y.jsx)(`p`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-xs text-muted`,"data-sw-thread-title":`true`,children:p?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`shrink-0 font-semibold text-fg tabular`,children:[`#`,e.id]}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-fg/80`,children:i}),ee?(0,Y.jsx)(h,{content:`${e.viewport[0].toUpperCase()}${e.viewport.slice(1)} capture`,children:(0,Y.jsx)(`span`,{className:`inline-flex shrink-0 text-faint`,"aria-label":`${e.viewport} capture`,role:`img`,children:(0,Y.jsx)(ee,{size:12,"aria-hidden":`true`})})}):(0,Y.jsxs)(`span`,{className:`shrink-0 text-faint`,children:[`· `,e.viewport]})]}):d?.total>1?(0,Y.jsxs)(`span`,{className:`tabular`,children:[d.index+1,` of `,d.total]}):null}),d?.total>1?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(z,{size:F,onClick:d.onPrev,label:Rw(`Previous thread`,d.prevNote),tooltip:Rw(`Previous thread (Left arrow)`,d.prevNote),"data-sw-thread-prev":`true`,"data-sw-thread-note":d.prevNote||void 0,children:(0,Y.jsx)(eh,{size:16,"aria-hidden":`true`})}),(0,Y.jsx)(z,{size:F,onClick:d.onNext,label:Rw(`Next thread`,d.nextNote),tooltip:Rw(`Next thread (Right arrow)`,d.nextNote),"data-sw-thread-next":`true`,"data-sw-thread-note":d.nextNote||void 0,children:(0,Y.jsx)(R,{size:16,"aria-hidden":`true`})})]}):null,c.resolve?(0,Y.jsx)(z,{size:F,variant:N?`default`:`ghost`,className:K(`rounded-full`,N&&`bg-ok text-ok-fg hover:bg-ok/90`),disabled:l,"aria-pressed":N,onClick:()=>u.onStatus(e,N?`reopen`:`resolve`),label:N?`Reopen the thread`:`Resolve the thread`,tooltip:N?`Resolved: reopen`:`Resolve`,...N?{"data-sw-reopen":e.id}:{"data-sw-resolve":e.id},children:(0,Y.jsx)(m,{size:16,strokeWidth:2.5,"aria-hidden":`true`})}):N?(0,Y.jsxs)(`span`,{className:`mx-1 inline-flex items-center gap-1 rounded-full bg-ok/15 px-2 text-xs leading-6 font-medium text-fg`,children:[(0,Y.jsx)(m,{size:12,"aria-hidden":`true`}),` Resolved`]}):null,U.length||c.delete?(0,Y.jsxs)(Ce,{children:[(0,Y.jsx)(h,{content:`More`,children:(0,Y.jsx)(C,{asChild:!0,children:(0,Y.jsx)(r,{variant:`ghost`,size:F,"aria-label":`More for comment ${e.id}`,"data-sw-thread-menu":e.id,children:(0,Y.jsx)(vh,{size:16,"aria-hidden":`true`})})})}),(0,Y.jsxs)(t,{align:`end`,children:[U.map(t=>t.href?(0,Y.jsx)(T,{asChild:!0,[t.hook]:e.id,children:(0,Y.jsxs)(`a`,{href:t.href,target:`_blank`,rel:`noreferrer noopener`,children:[(0,Y.jsx)(t.icon,{size:14,"aria-hidden":`true`}),` `,t.label]})},t.id):(0,Y.jsxs)(T,{onSelect:t.run,[t.hook]:e.id,children:[(0,Y.jsx)(t.icon,{size:14,"aria-hidden":`true`}),` `,t.label]},t.id)),c.delete?(0,Y.jsxs)(Y.Fragment,{children:[U.length?(0,Y.jsx)(_,{}):null,(0,Y.jsxs)(T,{tone:`danger`,onSelect:()=>A(!0),"data-sw-delete":e.id,children:[(0,Y.jsx)(E_,{size:14,"aria-hidden":`true`}),` Delete thread`]})]}):null]})]}):null,p?(0,Y.jsx)(z,{size:F,onClick:p,label:`Close the thread`,tooltip:`Close (Esc)`,"data-sw-thread-close":`true`,children:(0,Y.jsx)(g,{size:16,"aria-hidden":`true`})}):null]}),I||L?(0,Y.jsxs)(`div`,{className:`flex min-h-10 shrink-0 flex-wrap items-center gap-1.5 border-b border-line px-3 py-1.5`,"data-sw-thread-agent":`true`,children:[(0,Y.jsx)(qy,{comment:e}),I&&[`queued`,`working`].includes(P)?null:(0,Y.jsx)(Ky,{status:P,at:e.agentStatusAt,branch:e.agentBranch||null}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1`}),I?(0,Y.jsx)(Lw,{comment:e,onFix:u.onFixAgent,onOpenChat:u.onAskAgent,busy:l,touch:o}):null]}):null,(0,Y.jsxs)(`div`,{ref:j,className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[e.orphanReason?(0,Y.jsx)(`p`,{className:`pt-2 text-xs text-muted`,children:e.orphanReason}):null,e.imported&&e.agentStatus?(0,Y.jsx)(`p`,{className:`pt-2 text-xs text-muted`,children:`Imported agent status (history)`}):null,u.onSendToAgent&&e.status===`open`?(0,Y.jsx)(`div`,{className:`py-2`,children:(0,Y.jsx)(r,{size:o?`touch`:`sm`,disabled:l||e.dispatchable||e.needsRunApproval&&![`admin`,`owner`].includes(b),onClick:()=>u.onSendToAgent(e),children:e.dispatchable?`Sent to agent`:e.needsRunApproval?[`admin`,`owner`].includes(b)?`Approve agent run`:`Awaiting run approval`:`Send to agent`})}):null,(0,Y.jsxs)(`ol`,{className:`divide-y divide-line/60`,"aria-label":`Comment ${e.id} and replies`,children:[(0,Y.jsxs)(Vw,{author:Qy(e),at:e.createdAt,editedAt:e.editedAt,reactions:e.reactions,canReact:c.react,me:s,onReact:t=>u.onReact(e,t,null),touch:o,"data-sw-message":`comment`,children:[D?(0,Y.jsx)(Hw,{comment:e,busy:l,onSave:u.onEdit,onCancel:()=>O(!1),touch:o,people:a}):(0,Y.jsx)(ab,{text:e.body,plain:!!e.authorGuest,className:`block text-ui break-words whitespace-pre-wrap text-fg`}),(0,Y.jsx)(Nx,{boardId:E?.boardId,images:e.images,touch:o,label:`Comment ${e.id}`}),(0,Y.jsx)(Ww,{item:e,currentVersion:V,onShow:H}),e.anchor?(0,Y.jsx)(h,{content:(0,Y.jsx)(`span`,{className:`font-mono text-[11px] break-all`,children:e.anchor.selector}),children:(0,Y.jsxs)(`p`,{className:`mt-1.5 inline-flex max-w-full min-w-0 items-center gap-1 rounded-full bg-surface-2 px-2 py-0.5 text-[11px] text-muted`,"data-sw-thread-anchor":`true`,tabIndex:0,children:[(0,Y.jsx)(mh,{size:11,className:`shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`shrink-0`,children:`Pinned to`}),(0,Y.jsx)(`span`,{className:`truncate text-fg`,children:nb(e.anchor)})]})}):null,n?.note?(0,Y.jsxs)(`p`,{className:`mt-1 flex items-start gap-1 text-xs text-faint`,"data-sw-page-note":`true`,children:[(0,Y.jsx)(Xh,{size:11,className:`mt-0.5 shrink-0`,"aria-hidden":`true`}),` `,n.note]}):null,e.resolution?(0,Y.jsxs)(`p`,{className:`mt-1.5 rounded bg-ok/10 px-2 py-1 text-xs text-fg`,children:[`Fix: `,e.resolution]}):null,(0,Y.jsx)(Hy,{value:e.fixRef,touch:o}),(0,Y.jsx)(Wy,{github:e.github,touch:o}),f?(0,Y.jsx)($C,{comment:e,pair:f.pairFor(e),native:f.nativeFor(e),urlFor:f.urlFor,onImageError:f.onImageError,touch:o}):null]}),(e.replies||[]).length?(0,Y.jsx)(`li`,{"data-sw-replies":`true`,children:(0,Y.jsx)(`ol`,{className:`divide-y divide-line/60`,"aria-label":`Replies`,children:e.replies.map(t=>(0,Y.jsxs)(Vw,{author:$y(t),at:t.createdAt,reactions:t.reactions,canReact:c.react,me:s,onReact:n=>u.onReact(e,n,t.id),touch:o,"data-sw-reply":t.id,children:[(0,Y.jsx)(ab,{text:t.body,plain:!!t.guest,className:`block text-ui break-words whitespace-pre-wrap text-fg`}),(0,Y.jsx)(Nx,{boardId:E?.boardId,images:t.images,touch:o,label:`Reply ${t.id}`}),(0,Y.jsx)(Ww,{item:t,currentVersion:V,onShow:H})]},t.id))})}):null]})]}),k?(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-line bg-bad/10 px-3 py-2 text-xs text-fg`,role:`alert`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Delete this thread and its replies for good?`}),(0,Y.jsx)(r,{size:o?`touch`:`xs`,variant:`ghost`,onClick:()=>A(!1),disabled:l,children:`Cancel`}),(0,Y.jsxs)(r,{size:o?`touch`:`xs`,variant:`secondary`,className:`text-bad`,onClick:()=>u.onDelete(e),disabled:l,"data-sw-delete-confirm":e.id,children:[(0,Y.jsx)(E_,{size:13,"aria-hidden":`true`}),` Delete`]})]}):null,c.reply?(0,Y.jsx)(Uw,{comment:e,busy:l,onReply:u.onReply,touch:o,people:a,askName:x===!1,onSaveName:w,media:E},e.id):(0,Y.jsx)(`p`,{className:`shrink-0 border-t border-line px-3 py-2 text-xs text-muted`,"data-sw-reply-denied":b||`true`,children:y||zw(b)})]})}var Kw=`input, textarea, select, [contenteditable="true"]`,qw={top:10,right:10,bottom:60,left:10};function Jw(e,t){let n=Uu(),r=(0,J.useRef)(null),i=(0,J.useRef)({selector:e,point:t});return i.current={selector:e,point:t},r.current||={getBoundingClientRect(){let{domNode:e,transform:t}=n.getState(),{selector:r,point:a}=i.current,o=r?e?.querySelector(r):null;if(o)return o.getBoundingClientRect();let s=e?.getBoundingClientRect();if(!s||!a)return new DOMRect(-1e4,-1e4,0,0);let[c,l,u]=t;return new DOMRect(s.left+a.x*u+c,s.top+a.y*u+l,0,0)}},r}function Yw(e,t,n){let r=Uu(),[i,a]=(0,J.useState)(`right`);return(0,J.useEffect)(()=>{if(!e)return;let i=()=>{let e=r.getState().domNode?.getBoundingClientRect(),i=t.current.getBoundingClientRect();if(!e)return;let o=(n.current?.offsetWidth||360)+20;a(e.right-i.right>=o?`right`:i.left-e.left>=o?`left`:`bottom`)};i();let o=r.subscribe(i),s=new ResizeObserver(i),c=r.getState().domNode;return c&&s.observe(c),()=>{o(),s.disconnect()}},[e,r,t,n]),i}function Xw({open:e,onClose:t,selector:n,point:r,children:i,label:a,onKeyDown:o,onEscape:s,focusContent:c,stowed:l,className:u,...d}){let f=Uu(),p=Jw(n,r),m=(0,J.useRef)(null),h=Yw(e,p,m);return(0,Y.jsxs)(Ye,{open:e,onOpenChange:e=>e?null:t(),children:[(0,Y.jsx)(ce,{virtualRef:p}),(0,Y.jsx)(qe,{ref:m,side:h,align:`start`,sideOffset:10,alignOffset:-6,collisionBoundary:f.getState().domNode,collisionPadding:qw,hideWhenDetached:!0,updatePositionStrategy:`always`,"aria-label":a,className:K(`z-30`,u,l&&`invisible`),"data-sw-stowed":l?`true`:void 0,onOpenAutoFocus:e=>{c&&(e.preventDefault(),m.current?.focus({preventScroll:!0}))},onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>{s?.(e)===!1&&e.preventDefault()},onKeyDown:e=>{m.current?.contains(e.target)&&!e.target?.closest?.(Kw)&&o?.(e)},tabIndex:-1,...d,children:i})]})}function Zw(e){(document.querySelector(`[data-sw-pin="${CSS.escape(e)}"]`)||[...document.querySelectorAll(`[data-sw-pin-cluster]`)].find(t=>t.getAttribute(`data-sw-pin-cluster`).split(`,`).includes(e)))?.focus({preventScroll:!0})}function Qw(e,t,n){e.altKey||e.ctrlKey||e.metaKey||(e.key===`ArrowLeft`||e.key===`ArrowUp`?(e.preventDefault(),t?.()):(e.key===`ArrowRight`||e.key===`ArrowDown`)&&(e.preventDefault(),n?.()))}function $w({comment:e,point:t,onClose:n,onPrev:r,onNext:i,editingRef:a,stowed:o,children:s}){let c=(0,J.useRef)({onPrev:r,onNext:i});return c.current={onPrev:r,onNext:i},(0,J.useEffect)(()=>{let e=e=>{e.defaultPrevented||document.activeElement!==document.body||document.querySelector(`[role="menu"], [role="listbox"], [role="dialog"]:not([data-sw-thread-popover])`)||Qw(e,c.current.onPrev,c.current.onNext)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,J.useEffect)(()=>{let t=window.setTimeout(()=>{document.activeElement===document.body&&document.querySelector(`[data-sw-thread-popover="${e.id}"]`)?.focus({preventScroll:!0})},450);return()=>window.clearTimeout(t)},[e.id]),(0,Y.jsx)(Xw,{open:!0,onClose:n,selector:`[data-sw-pin="${e.id}"]`,point:t,label:`Comment ${e.id}`,focusContent:!0,stowed:o,className:`flex max-h-[min(560px,var(--radix-popover-content-available-height))] w-[360px] flex-col overflow-hidden p-0 outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,onEscape:()=>{if(a?.current&&document.activeElement?.closest?.(`[data-sw-edit-form]`))return a.current(),!1;let t=String(e.id);return window.setTimeout(()=>Zw(t),0),!0},onKeyDown:e=>Qw(e,r,i),"data-sw-thread-popover":e.id,children:s})}function eT({point:e,onClose:t,stowed:n,children:r}){return(0,Y.jsx)(Xw,{open:!0,onClose:t,selector:`[data-sw-draft-pin]`,point:e,label:`New comment`,stowed:n,className:`w-[340px] p-3`,"data-sw-composer-popover":`true`,children:r})}var tT=600,nT=e=>`shapewall.seen:${typeof window>`u`?``:window.location.pathname}:${e}`;function rT(e){try{let t=JSON.parse(window.localStorage.getItem(nT(e))||`{}`);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}function iT(e,t){try{let n=Object.entries(t).sort((e,t)=>String(t[1]).localeCompare(String(e[1]))).slice(0,tT);window.localStorage.setItem(nT(e),JSON.stringify(Object.fromEntries(n)))}catch{}}function aT(e){let t={at:e.createdAt||``,author:e.author,handle:e.authorHandle||null};for(let n of e.replies||[])String(n.createdAt)>String(t.at)&&(t={at:n.createdAt,author:n.author,handle:n.handle||null});return t}function oT(e,t){return t?t.handle&&e.handle?e.handle===t.handle:!!t.name&&String(e.author||``).toLowerCase()===String(t.name).toLowerCase():!1}function sT(e,t,n){let r=aT(e);return!r.at||oT(r,n)?!1:!t[e.id]||String(t[e.id])<String(r.at)}function cT(e){let[t,n]=(0,J.useState)(()=>rT(e));(0,J.useEffect)(()=>{n(rT(e));let t=t=>{t.key===nT(e)&&n(rT(e))};return window.addEventListener(`storage`,t),()=>window.removeEventListener(`storage`,t)},[e]);let r=(0,J.useCallback)(t=>{n(n=>{let r=!1,i={...n};for(let e of t){let t=aT(e).at;t&&String(i[e.id]||``)<String(t)&&(i[e.id]=t,r=!0)}return r?(iT(e,i),i):n})},[e]);return{seen:t,markSeen:(0,J.useCallback)(e=>r([e]),[r]),markAllSeen:r}}var lT=[`viewer`,`member`,`admin`,`owner`],uT=(e,t)=>lT.indexOf(e)>=lT.indexOf(t)&&lT.includes(e),dT=({isAuthor:e})=>!!e,fT=({role:e,isAuthor:t})=>uT(e,`member`)&&(!!t||uT(e,`admin`)),pT=`https://shapewall.com/contact`,mT={version:`0.3.1`,revision:`459470abbee7004bdcfd09dddad08e524d7dee6d`},hT=e=>`v${e?.version||mT.version}${e?.revision?` · ${e.revision.slice(0,7)}`:``}`,gT=`modulepreload`,_T=function(e,t){return new URL(e,t).href},vT={},yT=function(e){return e.pathname.endsWith(`.css`)},bT=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},xT=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=_T(t,n);let r=s(t),i=yT(r);return bT(vT,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:gT,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},ST=(0,J.lazy)(()=>xT(()=>import(`./app-update-dialog-DH2Mgby8.js`),__vite__mapDeps([0,1,2]),import.meta.url)),CT=`shapewall:open-about`;function wT(e=null){window.dispatchEvent(new CustomEvent(CT,{detail:{opener:e}}))}function TT({transport:e,className:t,placement:n=`menu`,ref:i}){let[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),l=(0,J.useRef)(null),u=(0,J.useRef)(null),d=e=>{u.current=e||null,c(!0),o(!0)};(0,J.useImperativeHandle)(i,()=>({open:()=>d(document.activeElement)}),[]),(0,J.useEffect)(()=>{let e=e=>d(e.detail?.opener||null);return window.addEventListener(CT,e),()=>window.removeEventListener(CT,e)},[]);let f=()=>o(!1),p=e=>{e.preventDefault(),[u.current,l.current,document.querySelector(`[data-sw-profile-menu]`)].find(e=>e?.isConnected&&e!==document.body)?.focus()},m=`About Shapewall and updates, ${hT(mT)}, created by Dan Baruch`;return(0,Y.jsxs)(Y.Fragment,{children:[n===`footer`?(0,Y.jsx)(`footer`,{className:K(`flex shrink-0 justify-center border-t border-line bg-surface text-muted`,t),style:{paddingBottom:`env(safe-area-inset-bottom, 0px)`},children:(0,Y.jsxs)(r,{variant:`ghost`,size:`touch`,className:`gap-2 rounded-none px-3 text-[10px] font-normal lg:h-6`,onClick:()=>d(l.current),"aria-label":m,"data-sw-app-about":`footer`,ref:l,children:[(0,Y.jsx)(`span`,{children:`Created by Dan Baruch`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Y.jsx)(`span`,{"data-sw-app-version":!0,children:hT(mT)})]})}):n===`link`?(0,Y.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,Y.jsx)(r,{asChild:!0,variant:`ghost`,size:`touch`,className:`px-2 text-caption font-normal text-faint hover:text-fg lg:h-8`,"data-sw-app-contact":`link`,children:(0,Y.jsx)(`a`,{href:pT,target:`_blank`,rel:`noopener noreferrer`,children:`Contact`})}),(0,Y.jsxs)(r,{variant:`ghost`,size:`touch`,className:K(`gap-1.5 px-2 text-caption font-normal text-faint hover:text-fg lg:h-8`,t),onClick:()=>d(l.current),"aria-label":m,"data-sw-app-about":`link`,ref:l,children:[(0,Y.jsx)(`span`,{children:`About Shapewall`}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Y.jsxs)(`span`,{className:`tabular-nums`,"data-sw-app-version":!0,children:[`v`,mT.version]})]})]}):null,s?(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`span`,{role:`status`,className:`sr-only`,children:`Opening About & Updates…`}),children:(0,Y.jsx)(ST,{open:a,onClose:f,onCloseAutoFocus:p,transport:e})}):null]})}function ET({demo:e,className:n,children:r,align:i=`start`}){return e.viewAs?(0,Y.jsxs)(Ce,{children:[(0,Y.jsx)(C,{asChild:!0,children:r}),(0,Y.jsxs)(t,{align:i,className:K(`w-64`,n),children:[(0,Y.jsx)(D,{children:`View as (demo)`}),(0,Y.jsx)(A,{value:e.viewAs.value,onValueChange:e.viewAs.onChange,children:e.viewAs.options.map(e=>(0,Y.jsxs)(d,{value:e.id,"data-sw-view-as":e.id,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.hint?(0,Y.jsx)(`span`,{className:`truncate text-xs text-faint`,children:e.hint}):null]},e.id))})]})]}):r}var DT=()=>(0,Y.jsxs)(`span`,{className:`inline-flex h-5 shrink-0 items-center gap-1.5 rounded-full bg-accent/12 px-2 text-caption font-semibold text-accent`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent`,"aria-hidden":`true`}),`Demo`]});function OT({variant:e=`strip`,className:t}){let n=j();return n?e===`chip`?(0,Y.jsxs)(`div`,{className:K(`flex shrink-0 items-center gap-0.5 rounded-full border border-line bg-surface-2/60 p-0.5`,t),role:`region`,"aria-label":`Demo`,"data-sw-demo-banner":n.role,children:[(0,Y.jsx)(ET,{demo:n,align:`end`,children:(0,Y.jsxs)(r,{variant:`ghost`,size:`touch`,className:`h-11 gap-1.5 rounded-full px-2 text-ui text-fg lg:h-8`,"aria-label":`Demo, viewing as `+n.roleLabel+`. Change who you view as`,"data-sw-demo-view-as":!0,children:[(0,Y.jsx)(DT,{}),(0,Y.jsx)(`span`,{className:`hidden max-w-28 truncate font-medium sm:inline`,children:n.roleLabel}),(0,Y.jsx)(H,{size:13,className:`text-faint`,"aria-hidden":`true`})]})}),(0,Y.jsx)(z,{label:`Reset the demo`,size:`icon`,className:`rounded-full text-muted max-lg:hidden lg:h-8 lg:w-8`,onClick:n.reset,"data-sw-demo-reset":!0,children:(0,Y.jsx)(Jg,{size:14,"aria-hidden":`true`})}),(0,Y.jsx)(kT,{})]}):(0,Y.jsxs)(`div`,{className:K(`flex shrink-0 items-center gap-2 border-b border-line bg-surface px-2 text-ui text-muted sm:px-3 lg:h-9`,t),role:`region`,"aria-label":`Demo`,"data-sw-demo-banner":n.role,children:[(0,Y.jsx)(DT,{}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`hidden shrink-0 sm:inline`,children:`Viewing as`}),(0,Y.jsx)(ET,{demo:n,children:(0,Y.jsxs)(r,{variant:`ghost`,size:`touch`,className:`min-w-0 gap-1 px-1.5 text-ui text-fg lg:h-7`,"aria-label":`Viewing as `+n.roleLabel+`. Change who you view as`,"data-sw-demo-view-as":!0,children:[(0,Y.jsx)(`span`,{className:`truncate font-semibold`,children:n.roleLabel}),(0,Y.jsxs)(`span`,{className:`hidden truncate font-normal text-muted sm:inline`,children:[`(`,n.personaName,`)`]}),(0,Y.jsx)(H,{size:13,className:`shrink-0 text-faint`,"aria-hidden":`true`})]})}),(0,Y.jsx)(`span`,{className:`hidden truncate text-faint md:inline`,children:`· Changes stay in this browser`})]}),(0,Y.jsxs)(r,{variant:`ghost`,size:`touch`,className:`shrink-0 gap-1.5 px-2 text-ui text-muted lg:h-7`,onClick:n.reset,"data-sw-demo-reset":!0,children:[(0,Y.jsx)(Jg,{size:13,"aria-hidden":`true`}),` Reset`]}),(0,Y.jsx)(kT,{})]}):null}function kT(){let e=j();return e?(0,Y.jsx)(M,{open:!!e.resetAsked,onClose:e.cancelReset,title:`Reset the demo?`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{size:`touch`,variant:`ghost`,onClick:e.cancelReset,className:`lg:h-10`,"data-sw-demo-reset-cancel":!0,children:`Cancel`}),(0,Y.jsxs)(r,{size:`touch`,className:`border-bad/50 bg-bad text-bad-fg hover:bg-bad/90 lg:h-10`,onClick:e.resetNow,"data-sw-demo-reset-confirm":!0,children:[(0,Y.jsx)(Jg,{size:14,"aria-hidden":`true`}),` Reset`]})]}),children:(0,Y.jsx)(`p`,{className:`px-5 py-4 text-sm text-muted`,children:`Your comments, invites and changes in this browser go back to the start.`})}):null}var AT={unknown:{title:`This share link is not valid`,text:`Check that you have the whole link, or ask whoever shared it for a new one.`},revoked:{title:`This share link was revoked`,text:`Whoever shared it turned it off. Ask them for a new link.`},expired:{title:`This share link has expired`,text:`Share links work for a set time. Ask whoever shared it for a new one.`},off:{title:`This share link is turned off`,text:`The workspace no longer allows share links, or the person who made it can no longer share. Ask them for a new link.`}};function jT({problem:e,onLeave:t}){let n=AT[e?.status]||AT.unknown,i=e?.at?new Date(e.at):null;return(0,Y.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Y.jsx)(OT,{}),(0,Y.jsx)(`main`,{className:`flex flex-1 items-center justify-center p-4`,children:(0,Y.jsxs)(`div`,{className:`w-full max-w-md rounded-xl border border-line bg-surface p-6 text-center shadow-card sm:p-8`,role:`alert`,"data-sw-share-problem":e?.status||`unknown`,children:[(0,Y.jsx)(`span`,{className:`inline-flex h-11 w-11 items-center justify-center rounded-xl bg-bad/10 text-bad`,children:(0,Y.jsx)(ig,{size:20,"aria-hidden":`true`})}),(0,Y.jsx)(`h1`,{className:`mt-4 text-xl font-semibold text-fg`,children:n.title}),(0,Y.jsxs)(`p`,{className:`mt-2 text-sm text-muted`,children:[n.text,i&&Number.isFinite(i.getTime())?(0,Y.jsxs)(Y.Fragment,{children:[` `,e.status===`revoked`?`Revoked`:`Expired`,` `,i.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),`.`]}):null]}),(0,Y.jsx)(`p`,{className:`mt-4 text-xs text-muted`,children:`In the demo, share links are made on a project's page in the console.`}),(0,Y.jsx)(r,{size:`touch`,variant:`default`,className:`mt-5 lg:h-10`,onClick:t,"data-sw-share-problem-leave":!0,children:`Open the demo board`})]})})]})}async function MT(e,t,n){let r;try{r=await fetch(t,{method:e,credentials:`same-origin`,headers:{...n===void 0?{Accept:`application/json`}:{Accept:`application/json`,"Content-Type":`application/json`},...typeof document<`u`&&document.querySelector(`meta[name="shapewall-local-accounts"]`)&&t.startsWith(`/auth/`)?Se():{}},body:n===void 0?void 0:JSON.stringify(n),cache:`no-store`})}catch{throw new Je(0,`offline`,`Could not reach the server. Check your connection and try again.`)}let i=null;try{i=await r.json()}catch{i=null}if(!r.ok){let e=Number(r.headers.get(`Retry-After`)),t=i?.error?.message||`Request failed (${r.status})`;throw new Je(r.status,i?.error?.code||`error`,r.status===429&&e>0?PT(t,e):t,{retryAfter:r.status===429&&e>0?e:null})}return i}function NT(e){return e>=5400?`${Math.ceil(e/3600)} hours`:e>=90?`${Math.ceil(e/60)} minutes`:e>60?`2 minutes`:e===1?`1 second`:`${e} seconds`}var PT=(e,t)=>`${e.replace(/\s*Wait (a while|a moment) and try again\.?\s*$/i,``)} Try again in ${NT(t)}.`,FT={get:e=>MT(`GET`,e),post:(e,t={})=>MT(`POST`,e,t),patch:(e,t={})=>MT(`PATCH`,e,t),put:(e,t={})=>MT(`PUT`,e,t),delete:(e,t)=>MT(`DELETE`,e,t)},IT=e=>{let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t+`===`.slice((t.length+3)%4));return Uint8Array.from(n,e=>e.charCodeAt(0)).buffer},LT=e=>btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``);async function RT(e,{mediation:t,signal:n}={}){let r={...e,challenge:IT(e.challenge),allowCredentials:(e.allowCredentials||[]).map(e=>({...e,id:IT(e.id)}))},i=await navigator.credentials.get({publicKey:r,...t?{mediation:t}:{},...n?{signal:n}:{}}),a=i.response;return{id:i.id,rawId:LT(i.rawId),type:i.type,authenticatorAttachment:i.authenticatorAttachment||void 0,clientExtensionResults:i.getClientExtensionResults(),response:{clientDataJSON:LT(a.clientDataJSON),authenticatorData:LT(a.authenticatorData),signature:LT(a.signature),userHandle:a.userHandle?LT(a.userHandle):void 0}}}async function zT(){let{options:e}=await FT.post(`/auth/reauth/options`,{}),t=await RT(e);await FT.post(`/auth/reauth/verify`,{response:t})}function BT({boardId:e}){let[t,n]=(0,J.useState)([]),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!1),u=`/api/boards/${encodeURIComponent(e)}/approvals`;(0,J.useEffect)(()=>{let t=!0,r=()=>Ke.get(`/api/boards/${encodeURIComponent(e)}/agent-budget`).then(e=>{t&&a(e)}).catch(()=>{}),i=()=>Ke.get(u).then(e=>{t&&n(e.approvals)}).catch(()=>{});i(),r();let o=()=>{document.visibilityState===`visible`&&(i(),r())},s=setInterval(o,3e3);return document.addEventListener(`visibilitychange`,o),()=>{t=!1,clearInterval(s),document.removeEventListener(`visibilitychange`,o)}},[u,e]);let d=async(e,t)=>{l(!0),s(null);try{await zT(),await Ke.post(`${u}/${e.id}`,{state:t,hash:e.command_hash}),n(t=>t.filter(t=>t.id!==e.id))}catch(e){s(e.message)}finally{l(!1)}};return!t.length&&!o&&!i?.exhausted?null:(0,Y.jsxs)(`section`,{"aria-label":`Agent command approvals`,className:`max-h-64 shrink-0 overflow-auto border-b border-line bg-surface p-3 text-sm`,children:[i?.exhausted?(0,Y.jsxs)(`p`,{role:`status`,className:`pb-2`,children:[`The agent hit today’s limit: `,i.claims,`/`,i.dailyLimit,` runs, `,i.open,`/`,i.openLimit,` in progress. Change limits in Agent policy in the console.`]}):null,t.map(e=>(0,Y.jsxs)(`article`,{className:`space-y-2 pb-3`,children:[(0,Y.jsxs)(`p`,{className:`font-semibold`,children:[`Agent asks to run a command for comment #`,e.comment_number]}),(0,Y.jsx)(`pre`,{className:`overflow-auto whitespace-pre-wrap break-words rounded bg-surface-2 p-2`,children:e.command.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\u200b-\u200f\u202a-\u202e\u2066-\u2069]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}),(0,Y.jsx)(`p`,{children:e.reason}),(0,Y.jsx)(r,{size:`touch`,variant:`default`,className:`lg:h-8`,disabled:c,onClick:()=>d(e,`approved`),children:`Approve once with passkey`}),` `,(0,Y.jsx)(r,{size:`touch`,variant:`danger`,className:`lg:h-8`,disabled:c,onClick:()=>d(e,`denied`),children:`Deny`})]},e.id)),o?(0,Y.jsx)(`p`,{role:`alert`,className:`text-bad`,children:o}):null]})}var VT={share:{title:`This link was revoked`,body:`Or it expired. The board stops updating and you cannot comment. Ask whoever shared it for a new link.`,href:null},signed_out:{title:`You were signed out`,body:`Sign in again to keep working on this board.`,href:`signin`},removed:{title:`You don't have access to this board any more`,body:`You may have been removed from the workspace. Ask an admin to invite you again.`,href:`home`}};function HT(){let[e,t]=(0,J.useState)(null);if((0,J.useEffect)(()=>{let e=e=>t(t=>t||e.detail?.kind||null);return window.addEventListener(le,e),()=>window.removeEventListener(le,e)},[]),!e)return null;let n=VT[e],r=encodeURIComponent(window.location.pathname+window.location.search);return(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-x-3 gap-y-1 border-b border-bad/30 bg-bad/10 px-4 py-2 text-sm text-fg`,role:`alert`,"data-sw-access-lost":e,children:[e===`share`?(0,Y.jsx)(ig,{size:15,className:`shrink-0 text-bad`,"aria-hidden":`true`}):(0,Y.jsx)(mg,{size:15,className:`shrink-0 text-bad`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`font-medium`,children:n.title}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 text-muted`,children:n.body}),n.href===`signin`?(0,Y.jsx)(`a`,{href:`/signin?next=${r}`,className:`inline-flex h-11 items-center font-medium text-accent underline-offset-2 hover:underline lg:h-auto`,children:`Sign in`}):n.href===`home`?(0,Y.jsx)(`a`,{href:`/`,className:`inline-flex h-11 items-center font-medium text-accent underline-offset-2 hover:underline lg:h-auto`,children:`Your workspaces`}):null]})}var UT=`You're a viewer. Ask an admin for member access to comment.`;function WT({compact:e=!1}){return(0,Y.jsx)(h,{content:UT,side:`bottom`,children:(0,Y.jsxs)(`span`,{role:`note`,tabIndex:0,"aria-label":UT,className:K(`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-line bg-surface-2 text-xs font-medium whitespace-nowrap text-muted outline-none focus-visible:outline-2 focus-visible:outline-accent`,e?`h-11 px-2.5`:`h-8 px-2.5`),"data-sw-viewer-note":!0,children:[(0,Y.jsx)(Sh,{size:14,"aria-hidden":`true`}),` Viewer`]})})}function GT({project:e}){return(0,Y.jsx)(h,{content:`Back to ${e.name}`,side:`bottom`,align:`start`,children:(0,Y.jsx)(`a`,{href:e.url,className:`block max-w-full min-w-0 truncate rounded-sm px-2.5 text-[11px] leading-3.5 font-medium text-muted outline-none hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,"data-sw-project-crumb":!0,children:e.name})})}var KT={includes:e=>typeof e==`string`&&(e===`all`||/^[a-z][a-z0-9-]{0,31}$/.test(e))};function qT({enabled:e,boardId:t,canvasRef:n,flow:r,selection:i,mode:a,onMode:o,onInvalidate:s}){let[c,l]=(0,J.useState)([]),[u,d]=(0,J.useState)(0),[f,p]=(0,J.useState)(`offline`),[m,h]=(0,J.useState)(null),g=(0,J.useRef)({cursor:null});g.current={...g.current,selection:i,mode:a,onMode:o,onInvalidate:s};let _=(0,J.useRef)(null);return em({onChange:e?()=>_.current?.():void 0}),(0,J.useEffect)(()=>{_.current?.()},[i,a]),(0,J.useEffect)(()=>{if(!e){l([]),d(0),h(null);return}let i=!1,a;return xT(async()=>{let{connectPresence:e}=await import(`./runtime-Bft6x_6E.js`);return{connectPresence:e}},[],import.meta.url).then(({connectPresence:e})=>{i||(a=e({boardId:t,canvasRef:n,flow:r,latest:g,sendRef:_,setPeers:l,setCount:d,setFollowing:h,setStatus:p}))}).catch(()=>{i||p(`offline`)}),()=>{i=!0,a?.()}},[e,t,n,r]),(0,J.useEffect)(()=>{if(m===null)return;let e=c.find(e=>e.id===m);if(!e){h(null);return}let t=e.viewport;if(!t||![t.x,t.y,t.zoom].every(Number.isFinite)||!KT.includes(e.mode))return;g.current.mode!==e.mode&&g.current.onMode?.(e.mode);let n=window.requestAnimationFrame(()=>{let e=r.getViewport();(Math.abs(e.x-t.x)>.01||Math.abs(e.y-t.y)>.01||Math.abs(e.zoom-t.zoom)>.001)&&r.setViewport(t,{duration:0})});return()=>window.cancelAnimationFrame(n)},[m,c,r]),{peers:c,count:u,status:f,following:m,follow:h,stopFollowing:()=>h(null)}}function JT({touch:e,...t}){let n=qT(t);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(QT,{presence:n}),(0,Y.jsx)(ZT,{presence:n,touch:e})]})}var YT=e=>`${e.id}|${e.name}|${e.color}|${+!!e.viewport}`;function XT(e,t){let n=e.presence,r=t.presence;return e.touch===t.touch&&n.status===r.status&&n.count===r.count&&n.following===r.following&&n.peers.length===r.peers.length&&n.peers.every((e,t)=>YT(e)===YT(r.peers[t]))}var ZT=(0,J.memo)(function({presence:e,touch:t}){if(e.status!==`online`)return null;let n=e.peers.find(t=>t.id===e.following);return(0,Y.jsxs)(`div`,{className:`absolute top-14 right-2 z-30 flex max-w-[calc(100%-1rem)] flex-wrap items-center justify-end gap-1 rounded-xl border border-line bg-surface/95 p-1 shadow-pop`,"aria-label":`Who is viewing`,"data-sw-presence":`true`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 text-xs text-muted`,"data-sw-presence-count":e.count,children:[(0,Y.jsx)(P_,{size:13,"aria-hidden":`true`}),e.count,` viewing`]}),e.peers.slice(0,5).map(n=>(0,Y.jsx)(h,{content:`${n.name}${n.viewport?`: follow their view`:``}`,children:(0,Y.jsx)(r,{size:t?`icon`:`icon-sm`,variant:e.following===n.id?`default`:`ghost`,"aria-label":`Follow ${n.name}`,"aria-pressed":e.following===n.id,disabled:!n.viewport,"data-sw-presence-peer":n.id,onClick:()=>e.follow(e.following===n.id?null:n.id),children:(0,Y.jsx)(se,{person:!0,name:n.name,color:n.color,size:`sm`})})},n.id)),e.peers.length>5?(0,Y.jsxs)(`span`,{className:`px-1 text-xs text-muted`,children:[`+`,e.peers.length-5]}):null,n?(0,Y.jsxs)(r,{size:t?`touch`:`xs`,variant:`secondary`,onClick:e.stopFollowing,"data-sw-stop-follow":`true`,children:[`Stop following `,n.name]}):null]})},XT);function QT({presence:e}){let t=e.peers.filter(e=>e.cursor&&Number.isFinite(e.cursor.x)&&Number.isFinite(e.cursor.y));return(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-20 overflow-hidden`,"aria-hidden":`true`,"data-sw-presence-cursors":`true`,children:t.length?(0,Y.jsx)($T,{peers:t}):null})}function $T({peers:e}){let{x:t,y:n,zoom:r}=Qp();return e.map(e=>(0,Y.jsxs)(`div`,{className:`absolute top-0 left-0`,style:{transform:`translate(${e.cursor.x*r+t}px, ${e.cursor.y*r+n}px)`,color:e.color},"data-sw-presence-cursor":e.id,"data-sw-cursor-x":e.cursor.x,"data-sw-cursor-y":e.cursor.y,children:[(0,Y.jsx)(Pg,{size:18,fill:`currentColor`,stroke:`white`,strokeWidth:1.5}),(0,Y.jsx)(`span`,{className:`ml-3 block max-w-36 truncate rounded px-1.5 py-0.5 text-[10px] text-white shadow-sm`,style:{background:e.color},children:e.name})]},e.id))}var eE=`shapewall.appearance`,tE=[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`},{id:`system`,label:`System`}],nE=[{id:`default`,label:`Default`},{id:`ocean`,label:`Ocean`},{id:`forest`,label:`Forest`},{id:`contrast`,label:`High contrast`}],rE={mode:`system`,theme:`default`};function iE(e){return{mode:tE.some(t=>t.id===e?.mode)?e.mode:rE.mode,theme:nE.some(t=>t.id===e?.theme)?e.theme:rE.theme}}var aE=(e,t)=>e===`system`?t?`dark`:`light`:e,oE=typeof window<`u`,sE=()=>oE&&window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`):null;function cE(){try{return iE(JSON.parse(window.localStorage.getItem(`shapewall.appearance`)||`null`))}catch{return{...rE}}}var lE=oE?cE():{...rE},uE=new Set;function dE(){let e=getComputedStyle(document.documentElement).getPropertyValue(`--surface`).trim();if(e)for(let t of document.querySelectorAll(`meta[name="theme-color"]`))t.removeAttribute(`media`),t.setAttribute(`content`,e)}function fE(e=lE){if(!oE)return;let t=document.documentElement;t.setAttribute(`data-mode`,aE(e.mode,!!sE()?.matches)),t.setAttribute(`data-theme`,e.theme),dE()}function pE(){return lE}function mE(e){lE=iE({...lE,...e});try{window.localStorage.setItem(eE,JSON.stringify(lE))}catch{}fE(),uE.forEach(e=>e())}oE&&(fE(),sE()?.addEventListener?.(`change`,()=>{lE.mode===`system`&&(fE(),uE.forEach(e=>e()))}),window.addEventListener(`storage`,e=>{e.key===`shapewall.appearance`&&(lE=cE(),fE(),uE.forEach(e=>e()))}));var hE=e=>(uE.add(e),()=>uE.delete(e));function gE(){return[(0,J.useSyncExternalStore)(hE,pE,pE),mE]}var _E=()=>oE?aE(lE.mode,!!sE()?.matches):`light`;function vE(){return(0,J.useSyncExternalStore)(hE,_E,_E)}var yE=`shapewall.demo.try`;function bE(){try{return window.localStorage.getItem(yE)===`1`}catch{return!1}}function xE(e){let[t,n]=(0,J.useState)(()=>e&&!bE());return[e&&t,()=>{n(!1);try{window.localStorage.setItem(yE,`1`)}catch{}}]}function SE({touch:e,done:t,onOpenComment:n,onComment:i,onAgent:a,onClose:o}){let[s,c]=(0,J.useState)(!0),l=[{id:`open`,icon:wg,label:`Open a comment`,hint:e?`Tap a pin on a page`:`Click a pin on a page`,run:n},i&&{id:`comment`,icon:Sg,label:e?`Pin your own comment`:`Press C to comment`,hint:e?`The comment button, then a page`:`Then click anywhere on a page`,run:i},a?{id:`agent`,icon:S,label:`Ask the agent`,hint:e?`In the ... menu`:`It reads the open comments`,run:a}:null].filter(Boolean),u=l.filter(e=>t.has(e.id)).length,d=e?`bottom-16 left-2`:`bottom-16 left-3`;return s?(0,Y.jsxs)(`button`,{type:`button`,className:K(`pointer-events-auto absolute z-30 inline-flex items-center gap-2 rounded-full border border-line bg-surface/95 pr-3 pl-2 text-[13px] font-medium text-fg shadow-pop backdrop-blur outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent`,e?`h-11`:`h-9`,d),onClick:()=>c(!1),"aria-expanded":`false`,"aria-label":`Try this: ${u} of ${l.length} done. Show the tips`,"data-sw-try-this":`folded`,children:[(0,Y.jsx)(m_,{size:15,className:`text-accent`,"aria-hidden":`true`}),` Try this`,(0,Y.jsxs)(`span`,{className:`tabular text-xs text-muted`,children:[u,`/`,l.length]})]}):(0,Y.jsxs)(`section`,{className:K(`pointer-events-auto absolute z-30 animate-pop-in rounded-xl border border-line bg-surface/95 p-3 text-fg shadow-pop backdrop-blur`,e?`inset-x-2 bottom-16`:`bottom-16 left-3 w-72`),"aria-label":`Try this`,"data-sw-try-this":`true`,children:[(0,Y.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,Y.jsx)(m_,{size:15,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsxs)(`h2`,{className:`min-w-0 flex-1 text-sm font-semibold`,children:[`Try this`,` `,(0,Y.jsxs)(`span`,{className:`tabular text-xs font-medium text-muted`,children:[u,`/`,l.length]})]}),(0,Y.jsx)(z,{size:e?`icon`:`icon-xs`,onClick:()=>c(!0),label:`Fold the tips away`,"aria-expanded":`true`,"data-sw-try-fold":`true`,children:(0,Y.jsx)(H,{size:14,"aria-hidden":`true`})}),(0,Y.jsx)(z,{size:e?`icon`:`icon-xs`,onClick:o,label:`Close the tips for good`,"data-sw-try-close":`true`,children:(0,Y.jsx)(g,{size:14,"aria-hidden":`true`})})]}),(0,Y.jsx)(`ol`,{className:`flex flex-col gap-1`,children:l.map(n=>{let i=t.has(n.id),a=i?m:n.icon;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(r,{size:e?`touch`:`sm`,variant:`ghost`,className:`h-auto w-full justify-start py-1.5 text-left`,onClick:n.run,"data-sw-try-step":n.id,"data-sw-try-done":i?`true`:void 0,children:[(0,Y.jsx)(`span`,{className:K(`flex h-6 w-6 shrink-0 items-center justify-center rounded-full`,i?`bg-ok/15 text-ok`:`bg-accent/10 text-accent`),"aria-hidden":`true`,children:(0,Y.jsx)(a,{size:13})}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:K(`block text-[13px] font-medium text-fg`,i&&`text-muted line-through decoration-faint`),children:n.label}),(0,Y.jsx)(`span`,{className:`block text-xs font-normal text-muted`,children:n.hint})]})]})},n.id)})}),(0,Y.jsx)(`p`,{className:`mt-2 border-t border-line px-2 pt-2 text-xs text-muted`,"data-sw-try-nav":`true`,children:e?`Drag to move around, pinch to zoom.`:`Scroll to move, Ctrl+scroll or pinch to zoom, Space+drag to pan.`})]})}var CE=new Map,wE=10;function TE(e,t,n,r){let i=n*t*4;for(let n=0;n<t;n+=1){let t=i+n*4;if(Math.abs(e[t]-r[0])>wE||Math.abs(e[t+1]-r[1])>wE||Math.abs(e[t+2]-r[2])>wE)return!0}return!1}function EE(e,t,n){if(!t||!n)return 1;let r=(n-1)*t*4,i=[e[r],e[r+1],e[r+2]];for(let r=n-1;r>=0;--r)if(TE(e,t,r,i))return Math.min(1,(r+1)/n);return 1}function DE(e){if(!e||typeof document>`u`)return Promise.resolve(1);if(CE.has(e))return CE.get(e);let t=new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=Math.min(n.naturalWidth,200),r=Math.round(n.naturalHeight*e/n.naturalWidth),i=document.createElement(`canvas`);i.width=e,i.height=r;let a=i.getContext(`2d`,{willReadFrequently:!0});a.drawImage(n,0,0,e,r),t(EE(a.getImageData(0,0,e,r).data,e,r))}catch{t(1)}},n.onerror=()=>t(1),n.src=e});return CE.set(e,t),t}var OE=()=>typeof window<`u`&&!!window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches,kE=e=>OE()?0:e,AE=()=>OE()?`auto`:`smooth`,jE=.02,ME={padding:.16};function NE(e,t,n,r=92){if(!t?.width||!t?.height)return e;let i=Math.min(t.width/e.width,t.height/e.height)/(1+2*n),a=r/Math.max(i,.01);return{...e,y:e.y-a,height:e.height+a}}function PE(e){let t=String(e||``).split(`,`).map(Number);return t.length!==3||t.some(e=>!Number.isFinite(e))||t[2]<=0?null:{x:t[0],y:t[1],zoom:t[2]}}function FE(e,t,n,{phoneCompare:r,shotUrls:i}){let a=t.frames[0];if(r&&a&&n?.width){let r=Math.min(4,(n.width-16)/t.w);e.setViewport({x:8-t.x*r,y:70-(t.y+a.y)*r,zoom:r},{duration:kE(450)});return}let o=r=>e.fitBounds(NE({x:t.x,y:t.y,width:t.w,height:Math.min(t.h,(a?a.y+a.h*r:t.h)+16)},n,.12),{padding:.12,duration:kE(450)});!a||!i.length?o(1):Promise.all(i.map(e=>DE(e))).then(e=>o(Math.max(.2,...e))).catch(()=>o(1))}function IE(e,t,n,r=24){let i=n.map(n=>e.x+t.x+t.w*n.spot.x/100),a=n.map(n=>e.y+t.y+t.h*n.spot.y/100);return{x:Math.min(...i)-r,y:Math.min(...a)-r,width:Math.max(...i)-Math.min(...i)+r*2,height:Math.max(...a)-Math.min(...a)+r*2}}var LE=.34,RE=12,zE=.75,BE=72,VE=40;function HE(e,t,n=ME.padding){if(!t?.width||!t?.height||!e?.length)return null;let r=e.filter(e=>e.type===`groupFrame`),i=UE(r.length?r:e);if(!i)return null;let a=Math.min(t.width/(i.width*(1+2*n)),t.height/(i.height*(1+2*n))),o=e.filter(e=>e.type!==`groupFrame`).length;if(a>=.34||!r.length||o<=RE)return null;let s=[...r].sort((e,t)=>e.position.y-t.position.y||e.position.x-t.position.x)[0],c=s.width??s.style?.width??0,l=s.height??s.style?.height??0,u=Math.min((t.width-80)/c,(t.height-BE-24)/l),d=Math.max(a,LE,Math.min(zE,u));return{x:VE-s.position.x*d,y:BE-s.position.y*d,zoom:d}}function UE(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e){let e=a.width??a.style?.width??0,o=a.height??a.style?.height??0;t=Math.min(t,a.position.x),n=Math.min(n,a.position.y),r=Math.max(r,a.position.x+e),i=Math.max(i,a.position.y+o)}return Number.isFinite(t)?{x:t,y:n,width:r-t,height:i-n}:null}var WE={top:100,bottom:64,side:24},GE=280,KE=2;function qE(e,t,n=.5){if(!t?.width||!t?.height||!e?.width||!e?.height)return null;let{top:r,bottom:i,side:a}=WE,o=Math.max(1,t.width-a*2),s=Math.max(1,t.height-r-i),c=o/e.width,l=Math.min(c,s/e.height),u=Math.min(KE,4,Math.max(l,Math.min(c,GE/e.width))),d=e.width*u,f=e.height*u,p=a+(o-d)/2-e.x*u,m=r+(s-f)/2-e.y*u;if(f>s){m=r-e.y*u;let t=e.y+e.height*Math.min(1,Math.max(0,n));m+t*u>r+s*.8&&(m=Math.max(r+s-(e.y+e.height)*u,r+s/2-t*u))}return{x:p,y:m,zoom:u}}function JE(e){let t=Uu(),[n,r]=(0,J.useState)(null),i=(0,J.useRef)(null),a=(0,J.useCallback)(e=>{i.current=e,r(e)},[]);return(0,J.useEffect)(()=>{if(!e)return;let n=null,r=()=>{window.clearTimeout(n),n=window.setTimeout(()=>a(t.getState().transform[2]),300)};r();let o=t.getState().transform[2],s=t.subscribe(e=>{let t=e.transform[2];t!==o&&(o=t,i.current!==null&&t<i.current*.8&&a(t),r())});return()=>{window.clearTimeout(n),s()}},[e,a,t]),[n,a]}var YE=`shapewall.minimap`;function XE(){try{let e=window.localStorage.getItem(YE);return e===`on`||e!==`off`&&null}catch{return null}}function ZE(e){return e>=30}var QE=`shapewall.tip.board`;function $E(){try{return window.localStorage.getItem(QE)===`1`}catch{return!1}}function eD(e){try{window.localStorage.setItem(YE,e?`on`:`off`)}catch{}}function tD(){try{window.localStorage.setItem(QE,`1`)}catch{}}var nD=`shapewall.rail.`;function rD(e){try{let t=Number(window.localStorage.getItem(nD+e));return Number.isFinite(t)&&t>0?t:null}catch{return null}}function iD(e,t){try{t==null?window.localStorage.removeItem(nD+e):window.localStorage.setItem(nD+e,String(Math.round(t)))}catch{}}var aD=8;function oD({groups:e,onPick:t}){let[n,i]=(0,J.useState)(``),a=n.trim().toLowerCase(),o=e.flatMap(e=>e.pages.map(t=>({...t,group:e.group}))),s=a?o.filter(e=>`${e.title} ${e.path||``} ${e.group}`.toLowerCase().includes(a)):o.slice(0,aD);return(0,Y.jsxs)(`div`,{className:`space-y-1.5`,"data-sw-page-finder":`true`,children:[(0,Y.jsx)(Ge,{size:`touch`,icon:n_,value:n,onChange:e=>i(e.target.value.slice(0,80)),placeholder:`Search ${o.length} pages`,"aria-label":`Search pages`,"data-sw-page-search":`true`}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:s.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(r,{size:`touch`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>t(e.id),"data-sw-page-pick":e.id,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title}),(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 text-xs text-faint`,children:e.group})]})},e.id))}),s.length?null:(0,Y.jsxs)(`p`,{className:`px-1 text-sm text-muted`,children:[`No page matches "`,n.trim(),`".`]}),!a&&o.length>aD?(0,Y.jsxs)(`p`,{className:`px-1 text-xs text-faint`,children:[o.length-aD,` more: type to find them.`]}):null]})}var sD=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent||``),cD=sD?`⌘K`:`Ctrl K`,lD=60,uD=6,dD=e=>String(e||``).toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``);function fD(e,...t){let n=0;for(let[r,i]of t.entries()){let t=dD(i);if(!t)continue;let a=r===0?1:.5;t.startsWith(e)?n=Math.max(n,3*a):t.includes(` ${e}`)||t.includes(`/${e}`)?n=Math.max(n,2*a):t.includes(e)&&(n=Math.max(n,1*a))}return n}var pD=e=>e.filter(e=>e.score>0).sort((e,t)=>t.score-e.score).map(e=>e.entry);function mD({query:e,groups:t,journeys:n,canEditJourneys:r,comments:i,actions:a,titleOf:o}){let s=dD(e.trim()),c=t.flatMap(e=>e.pages.map(t=>({id:t.id,kind:`page`,icon:Eh,title:t.title,detail:t.path||``,meta:e.group,run:{type:`page`,id:t.id}}))),l=n.map(e=>({id:`journey:${e.id}`,kind:`journey`,icon:Qg,title:e.name,detail:e.description||``,meta:e.branching?`${e.paths?.length||2} paths`:`${e.steps.length} steps`,run:{type:`journey`,id:e.id}}));r&&l.push({id:`journey:__new`,kind:`journey`,icon:Hg,title:`New journey`,detail:`Click pages in the order people visit them`,meta:``,run:{type:`new-journey`}});let u=a.map(e=>({id:`action:${e.id}`,kind:`action`,icon:e.icon||R_,title:e.label,detail:e.detail||``,meta:e.keys||``,run:{type:`action`,run:e.run}}));if(!s)return[l.length?{id:`journeys`,label:`Journeys`,items:l}:null,{id:`pages`,label:`Pages`,items:c.slice(0,lD),more:Math.max(0,c.length-lD)},u.length?{id:`actions`,label:`Actions`,items:u}:null].filter(Boolean);let d=/^#?(\d{1,7})$/.exec(s)?.[1],f=e=>({id:`comment:${e.id}`,kind:`comment`,icon:wg,title:`#${e.id} ${String(e.body||``).split(`
|
|
33
33
|
`)[0]}`,detail:[o(e.pageId),e.viewport].filter(Boolean).join(` · `),meta:e.status===`resolved`?`Resolved`:``,run:{type:`comment`,comment:e}}),p=d?i.find(e=>String(e.id)===d):null,m=[p,...(s.length>=2&&!d?pD(i.map(e=>({entry:e,score:fD(s,e.body,e.author)}))):[]).filter(e=>e!==p)].filter(Boolean).slice(0,uD).map(f),h=pD(c.map(e=>({entry:e,score:fD(s,e.title,e.detail,e.meta)}))),g=pD(l.map(e=>({entry:e,score:fD(s,e.title,e.detail)}))),_=pD(u.map(e=>({entry:e,score:fD(s,e.title,e.detail)})));return[d&&p?{id:`comments`,label:`Comments`,items:m}:null,h.length?{id:`pages`,label:`Pages`,items:h.slice(0,lD)}:null,g.length?{id:`journeys`,label:`Journeys`,items:g}:null,!d&&m.length?{id:`comments`,label:`Comments`,items:m}:null,_.length?{id:`actions`,label:`Actions`,items:_}:null].filter(Boolean)}function hD({onOpen:e,compact:t=!1,className:n,...r}){return(0,Y.jsxs)(`button`,{type:`button`,...r,onClick:e,className:K(`inline-flex h-8 shrink-0 items-center gap-2 rounded-md border border-line bg-surface-2/60 text-[13px] text-muted outline-none hover:border-faint/40 hover:bg-surface-2 hover:text-fg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,t?`w-8 justify-center`:`w-60 px-2.5`,n),"aria-label":`Go to a page, journey or comment`,"aria-haspopup":`dialog`,"aria-keyshortcuts":sD?`Meta+K`:`Control+K`,"data-sw-page-jump":`true`,"data-sw-palette-trigger":`true`,children:[(0,Y.jsx)(n_,{size:14,"aria-hidden":`true`,className:`shrink-0`}),t?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:`Go to page or journey`}),(0,Y.jsx)(a,{className:`shrink-0`,children:cD})]})]})}function gD({open:e,onOpenChange:t,groups:n,journeys:r=[],canEditJourneys:i=!1,comments:a=[],actions:o=[],titleOf:s=e=>e,onPage:c,onJourney:l,onNewJourney:u,onComment:d,onCloseAutoFocus:f}){return G(e,()=>t(!1)),(0,Y.jsx)(y,{open:e,onOpenChange:t,children:(0,Y.jsxs)(U,{children:[(0,Y.jsx)(Ze,{}),(0,Y.jsxs)(ne,{className:`fixed top-[12dvh] left-1/2 z-50 flex max-h-[min(560px,76dvh)] w-[min(640px,calc(100vw-1.5rem))] -translate-x-1/2 animate-pop-in flex-col overflow-hidden rounded-xl border border-line bg-surface text-fg shadow-pop outline-none`,"aria-describedby":void 0,onCloseAutoFocus:f,"data-sw-palette":`true`,children:[(0,Y.jsx)(ie,{className:`sr-only`,children:`Go to a page, journey or comment`}),e?(0,Y.jsx)(_D,{groups:n,journeys:r,canEditJourneys:i,comments:a,actions:o,titleOf:s,onRun:e=>{t(!1),e.type===`page`?c(e.id):e.type===`journey`?l(e.id):e.type===`new-journey`?u?.():e.type===`comment`?d?.(e.comment):e.type===`action`&&e.run()}}):null]})]})})}function _D({groups:e,journeys:t,canEditJourneys:n,comments:r,actions:i,titleOf:o,onRun:s}){let[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(0),f=(0,J.useRef)(null),p=(0,J.useMemo)(()=>mD({query:c,groups:e,journeys:t,canEditJourneys:n,comments:r,actions:i,titleOf:o}),[c,e,t,n,r,i,o]),m=(0,J.useMemo)(()=>p.flatMap(e=>e.items),[p]),h=m[Math.min(u,m.length-1)]||null;(0,J.useEffect)(()=>d(0),[c]),(0,J.useEffect)(()=>{h&&f.current?.querySelector(`[data-sw-option="${CSS.escape(h.id)}"]`)?.scrollIntoView({block:`nearest`})},[h]);let g=e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),!m.length)return;let t=e.key===`ArrowDown`?1:-1;d(e=>(Math.min(e,m.length-1)+t+m.length)%m.length)}else e.key===`Home`&&e.ctrlKey?d(0):e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),h&&s(h.run))},_=e=>`sw-palette-${e.id.replace(/[^\w-]/g,`_`)}`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5 border-b border-line px-4`,children:[(0,Y.jsx)(n_,{size:17,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,Y.jsx)(`input`,{autoFocus:!0,value:c,onChange:e=>l(e.target.value.slice(0,120)),onKeyDown:g,placeholder:`Go to a page, journey or #comment...`,className:`h-13 min-w-0 flex-1 bg-transparent text-base text-fg outline-none placeholder:text-faint lg:h-12 lg:text-[15px]`,role:`combobox`,"aria-expanded":`true`,"aria-controls":`sw-palette-list`,"aria-activedescendant":h?_(h):void 0,"aria-autocomplete":`list`,"aria-label":`Search the board`,"data-sw-palette-input":`true`}),(0,Y.jsx)(a,{className:`hidden shrink-0 lg:inline-flex`,children:`Esc`})]}),(0,Y.jsxs)(`div`,{ref:f,id:`sw-palette-list`,role:`listbox`,"aria-label":`Results`,className:`min-h-0 flex-1 overflow-y-auto p-1.5`,children:[p.map(e=>(0,Y.jsxs)(`div`,{role:`presentation`,className:`pb-1`,children:[(0,Y.jsx)(`p`,{role:`presentation`,className:`px-2.5 pt-2 pb-1 text-[11px] font-medium tracking-wide text-faint uppercase`,children:e.label}),e.items.map(e=>{let t=e===h,n=e.icon;return(0,Y.jsxs)(`div`,{id:_(e),role:`option`,"aria-selected":t,className:K(`flex min-h-11 cursor-default items-center gap-3 rounded-lg px-2.5 py-1.5 select-none lg:min-h-10`,t?`bg-accent/10 text-fg`:`text-fg`),onMouseMove:()=>{let t=m.indexOf(e);t!==u&&d(t)},onClick:()=>s(e.run),"data-sw-option":e.id,children:[(0,Y.jsx)(`span`,{className:K(`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border`,t?`border-accent/30 bg-surface text-accent`:`border-line bg-surface-2 text-muted`),"aria-hidden":`true`,children:(0,Y.jsx)(n,{size:14})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-sm font-medium`,children:e.title}),e.detail?(0,Y.jsx)(`span`,{className:K(`block truncate text-xs text-muted`,e.kind===`page`&&`font-mono text-[11px]`),children:e.detail}):null]}),e.meta?(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:e.meta}):null,t?(0,Y.jsx)(fh,{size:14,className:`hidden shrink-0 text-muted lg:block`,"aria-hidden":`true`}):null]},e.id)}),e.more?(0,Y.jsxs)(`p`,{role:`presentation`,className:`px-2.5 py-1 text-xs text-faint`,children:[e.more,` more pages: type to find them.`]}):null]},e.id)),m.length?null:(0,Y.jsxs)(`p`,{className:`px-3 py-8 text-center text-sm text-muted`,"data-sw-palette-empty":`true`,children:[`Nothing matches "`,c.trim(),`".`]})]}),(0,Y.jsxs)(`div`,{className:`hidden items-center gap-4 border-t border-line bg-surface-2/50 px-4 py-2 text-xs text-muted lg:flex`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(a,{children:`↑`}),(0,Y.jsx)(a,{children:`↓`}),` to move`]}),(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(a,{children:`↵`}),` to open`]}),(0,Y.jsx)(`span`,{className:`ml-auto`,children:`#12 finds comment 12`})]})]})}var vD=Object.freeze({id:null,pinned:!1,via:null,swap:!1});function yD({onChange:e,openDelay:t=150,closeDelay:n=250,setTimer:r=(e,t)=>setTimeout(e,t),clearTimer:i=e=>clearTimeout(e)}={}){let a=vD,o=null,s=()=>{o!==null&&i(o),o=null},c=(e,t)=>{s(),o=r(()=>{o=null,e()},t)},l=t=>{a=t,e?.(a)},u=()=>{s(),a.id!==null&&l(vD)};return{get state(){return a},enterIcon(e){a.pinned||(s(),a.id!==e&&(a.id===null?c(()=>l({id:e,pinned:!1,via:`hover`,swap:!1}),t):l({id:e,pinned:!1,via:`hover`,swap:!0})))},leave(){a.pinned||(a.id===null?s():c(u,n))},enterPanel(){a.pinned||s()},toggle(e,t=`click`){s(),a.id===e&&a.pinned?u():l({id:e,pinned:!0,via:t,swap:!1})},close:u,dispose:s}}function bD({anchorTop:e,viewportHeight:t,margin:n=8,minHeight:r=320}){let i=Math.max(0,t-n*2),a=t-Math.max(e,n)-n;return Math.round(Math.min(i,Math.max(a,Math.min(r,i))))}var xD=`shapewall.lastBoard`,SD=`shapewall.sidebar`,CD=`shapewall.sidebarWidth`,wD=208,TD=420,ED=16,DD=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent||``)?`⌘B`:`Ctrl B`;function OD(e){try{typeof e==`string`&&e.startsWith(`/`)&&window.localStorage.setItem(xD,e)}catch{}}function kD(e){try{let t=window.localStorage.getItem(SD);return t===`expanded`||t!==`collapsed`&&e}catch{return e}}function AD(e){let t=Math.max(wD,Math.min(TD,Math.floor(window.innerWidth*.4)));return Math.min(t,Math.max(wD,Math.round(e)))}function jD(){try{let e=Number(window.localStorage.getItem(CD));return Number.isFinite(e)&&e>0?AD(e):256}catch{return 256}}function MD(e){try{e===256?window.localStorage.removeItem(CD):window.localStorage.setItem(CD,String(e))}catch{}}function ND(){let[e,t]=(0,J.useState)(jD),[n,r]=(0,J.useState)(!1),i=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=()=>t(e=>AD(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let a=e=>{let n=AD(e);t(n),MD(n)},o={onPointerDown:t=>{t.button===0&&(t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),i.current={x:t.clientX,width:e},r(!0))},onPointerMove:e=>{i.current&&t(AD(i.current.width+e.clientX-i.current.x))},onPointerUp:e=>{i.current&&(a(i.current.width+e.clientX-i.current.x),i.current=null,r(!1))},onDoubleClick:()=>a(256),onKeyDown:t=>{let n=t.shiftKey?64:ED;if(t.key===`ArrowRight`)a(e+n);else if(t.key===`ArrowLeft`)a(e-n);else if(t.key===`Home`)a(256);else return;t.preventDefault()}};return o.onPointerCancel=o.onPointerUp,{width:e,dragging:n,handle:o}}var PD=e=>!!(e&&(e.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(e.tagName)||e.closest?.(`[contenteditable="true"]`)));function FD(e=!0,t=!0){let[n,r]=(0,J.useState)(()=>kD(t)),i=(0,J.useCallback)(()=>r(e=>{try{window.localStorage.setItem(SD,e?`collapsed`:`expanded`)}catch{}return!e}),[]);return(0,J.useEffect)(()=>{if(!e)return;let t=e=>{!(e.metaKey||e.ctrlKey)||e.altKey||e.shiftKey||e.key.toLowerCase()!==`b`||PD(e.target)||document.querySelector(`[role="dialog"]:not([data-sw-rail-flyout])`)||(e.preventDefault(),i())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,i]),[n,i,r]}function ID(e,t){return K(`relative flex items-center rounded-md outline-none transition-colors focus-visible:outline-2 focus-visible:outline-accent`,e?`h-8 w-full gap-2.5 px-2.5 text-left text-[13px] font-medium`:`h-10 w-10 justify-center rounded-lg`,t?`bg-accent/10 text-fg`:`text-muted hover:bg-surface-2 hover:text-fg`)}function LD({item:e,expanded:t,link:n,flyouts:r}){let{id:i,label:o,icon:s,href:c,to:l,onSelect:u,active:d,count:f,shortcut:p,flyout:m,...g}=e;if(!t&&m&&r)return(0,Y.jsx)(VD,{item:e,flyouts:r});let _=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(s,{size:t?16:19,"aria-hidden":`true`,className:K(`shrink-0`,d&&`text-accent`)}),t?(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:o}):null,t&&f?(0,Y.jsx)(`span`,{className:`shrink-0 text-xs font-normal text-faint tabular`,children:f}):null]}),v={className:ID(t,d),"aria-label":t?void 0:o,"aria-current":d?`page`:void 0,"data-sw-rail-item":i,...g},y=l&&n?(0,Y.jsx)(n,{to:l,...v,children:_}):c?(0,Y.jsx)(`a`,{href:c,...v,children:_}):(0,Y.jsx)(`button`,{type:`button`,onClick:u,...v,children:_});return(0,Y.jsx)(`li`,{children:t?y:(0,Y.jsx)(h,{content:p?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[o,(0,Y.jsx)(a,{children:p})]}):o,side:`right`,children:y})})}var RD=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`,zD=e=>[...e.querySelectorAll(RD)].filter(e=>e.getClientRects().length>0);function BD(e,t){let n=zD(document).filter(e=>!t?.contains(e));(n[n.indexOf(e)+1]||e).focus()}function VD({item:e,flyouts:t}){let{id:n,label:r,icon:i,active:a,flyout:o,dot:s}=e,{state:c,intent:l,width:u,disabled:d}=t,f=Object.fromEntries(Object.entries(e).filter(([e])=>e.startsWith(`data-`))),m=(0,J.useId)(),h=(0,J.useRef)(null),g=(0,J.useRef)(null),_=c.id===n,[v,y]=(0,J.useState)(null);(0,J.useLayoutEffect)(()=>{if(!_)return;let e=()=>{let e=h.current?.getBoundingClientRect().top??0;y(bD({anchorTop:e,viewportHeight:window.innerHeight}))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[_]),(0,J.useEffect)(()=>{if(!_)return;let e=e=>{g.current?.contains(e.target)||h.current?.contains(e.target)||l.close()};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[_,l]);let b=_&&c.pinned;(0,J.useEffect)(()=>{if(!b)return;let e=requestAnimationFrame(()=>{let e=g.current;e&&!e.contains(document.activeElement)&&(zD(e)[0]||e).focus({preventScroll:!0})});return()=>cancelAnimationFrame(e)},[b]);let S=(0,J.useCallback)(()=>{let e=!!g.current?.contains(document.activeElement);l.close(),e&&h.current?.focus({preventScroll:!0})},[l]),C=e=>t=>{t.pointerType!==`touch`&&e()},w=e=>{if(e.key!==`Tab`||e.defaultPrevented)return;let t=zD(g.current);t.length&&(e.shiftKey&&document.activeElement===t[0]?(e.preventDefault(),h.current?.focus()):!e.shiftKey&&document.activeElement===t[t.length-1]&&(e.preventDefault(),l.close(),BD(h.current,g.current)))};return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(V,{open:_,onOpenChange:e=>{e||l.close()},children:[(0,Y.jsx)(p,{asChild:!0,children:(0,Y.jsxs)(`button`,{ref:h,type:`button`,className:ID(!1,a||_),"aria-label":r,"aria-haspopup":`dialog`,"aria-expanded":_,"aria-controls":_?m:void 0,"aria-current":a?`page`:void 0,"data-sw-rail-item":n,"data-sw-rail-flyout-trigger":n,"data-state":_?c.pinned?`pinned`:`open`:`closed`,...f,onPointerEnter:C(()=>!d&&l.enterIcon(n)),onPointerLeave:C(()=>l.leave()),onClick:e=>!d&&l.toggle(n,e.detail===0?`key`:`click`),onKeyDown:e=>{e.key!==`ArrowRight`||d||(e.preventDefault(),b||l.toggle(n,`key`))},children:[(0,Y.jsx)(i,{size:19,"aria-hidden":`true`,className:K(`shrink-0`,a&&`text-accent`)}),s?(0,Y.jsx)(`span`,{className:`pointer-events-none absolute top-1.5 right-1.5 h-2 w-2 rounded-full bg-accent ring-2 ring-surface`,"aria-hidden":`true`,"data-sw-rail-dot":n}):null]})}),(0,Y.jsx)(Pe,{children:(0,Y.jsx)(x,{ref:g,id:m,side:`right`,align:`start`,sideOffset:12,collisionPadding:8,"aria-label":r,tabIndex:-1,className:K(`sw-rail-flyout z-40 flex flex-col overflow-y-auto overscroll-contain rounded-lg border border-line bg-surface p-2 text-fg shadow-pop outline-none`,`[&_[data-sw-pages-sidebar]]:border-t-0 [&_[data-sw-pages-sidebar]]:pt-0`,c.swap&&`sw-rail-flyout-swap`),style:{width:u,maxHeight:v??void 0},"data-sw-rail-flyout":n,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onEscapeKeyDown:e=>{e.preventDefault();let t=c.pinned||g.current?.contains(document.activeElement);l.close(),t&&h.current?.focus({preventScroll:!0})},onInteractOutside:e=>{h.current?.contains(e.target)&&e.preventDefault()},onPointerEnter:C(()=>l.enterPanel()),onPointerLeave:C(()=>l.leave()),onKeyDown:w,children:o({close:S})})})]})})}function HD({items:e,expanded:t,link:n,label:r,flyouts:i,flush:a}){return e.length?(0,Y.jsxs)(`div`,{className:K(`w-full`,!a&&`border-t border-line pt-2`),children:[t&&r?(0,Y.jsx)(`p`,{className:`px-2.5 pb-1 text-xs font-semibold text-faint`,children:r}):null,(0,Y.jsx)(`ul`,{className:K(`flex flex-col`,t?`gap-0.5`:`items-center gap-1`),children:e.map(e=>(0,Y.jsx)(LD,{item:e,expanded:t,link:n,flyouts:i},e.id))})]}):null}function UD(e,t,n=!1){let[r,i]=(0,J.useState)(()=>({id:null,pinned:!1,via:null,swap:!1})),a=(0,J.useRef)(null);return a.current||=yD({onChange:i}),(0,J.useEffect)(()=>()=>a.current.dispose(),[]),(0,J.useEffect)(()=>{(e||n)&&a.current.close()},[e,n]),{state:r,intent:a.current,width:t,disabled:n}}function WD({expanded:e,onToggle:t,home:n,homeTo:r,homeLabel:i=`Shapewall`,title:o,logo:s,items:c=[],sections:l=[],sectionsLabel:u,link:d,profile:f,children:p,className:m,flyoutsDisabled:g=!1}){let _=r&&d?d:`a`,v=r&&d?{to:r}:{href:n},y=e?`Collapse sidebar`:`Expand sidebar`,{width:b,dragging:x,handle:S}=ND(),C=UD(e,b,g),w=e?[]:l.filter(e=>!e.flyout),T=w.length?c.find(e=>e.active):null,E=T?c.map(e=>e===T?{...e,flyout:({close:t})=>(0,Y.jsx)(`div`,{onClick:e=>{e.target.closest?.(`[data-sw-rail-item]`)&&setTimeout(t,0)},children:(0,Y.jsx)(HD,{items:w,expanded:!0,link:d,label:u||e.label,flush:!0})})}:e):c,D=T?l.filter(e=>e.flyout):l;return(0,Y.jsxs)(`div`,{className:K(`relative flex shrink-0`,m),children:[(0,Y.jsxs)(`nav`,{"aria-label":`Shapewall`,className:K(`flex flex-col gap-2 overflow-hidden border-r border-line bg-surface py-2`,e?`px-2`:`w-[52px] items-center`),style:e?{width:b}:void 0,"data-sw-app-rail":e?`expanded`:`collapsed`,children:[(0,Y.jsxs)(`div`,{className:K(`flex shrink-0 items-center gap-1`,e?`h-10`:`flex-col`),children:[(0,Y.jsx)(h,{content:e?null:i,side:`right`,children:(0,Y.jsx)(_,{...v,className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent`,"aria-label":i,"data-sw-rail-home":`true`,children:s})}),e?(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-fg`,"data-sw-rail-title":`true`,children:o||`Shapewall`}):null,(0,Y.jsx)(h,{content:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[y,(0,Y.jsx)(a,{children:DD})]}),side:`right`,children:(0,Y.jsx)(`button`,{type:`button`,onClick:t,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted outline-none hover:bg-surface-2 hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,"aria-label":y,"aria-expanded":e,"data-sw-sidebar-toggle":`true`,children:e?(0,Y.jsx)(Ig,{size:17,"aria-hidden":`true`}):(0,Y.jsx)(Rg,{size:17,"aria-hidden":`true`})})})]}),(0,Y.jsx)(HD,{items:E,expanded:e,link:d,flyouts:C}),(0,Y.jsxs)(`div`,{className:K(`flex min-h-0 flex-1 flex-col gap-2`,e?`overflow-y-auto in-[.sw-scrollbars]:mr-[calc(-1*var(--scrollbar-size))]`:`w-full`),children:[(0,Y.jsx)(HD,{items:D,expanded:e,link:d,label:u,flyouts:C}),e?p:null]}),f?(0,Y.jsx)(`div`,{className:K(`w-full shrink-0 border-t border-line pt-2`,!e&&`flex justify-center`),children:f(e)}):null]}),e?(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,"aria-valuenow":b,"aria-valuemin":wD,"aria-valuemax":TD,tabIndex:0,"aria-description":`Drag or use the arrow keys to resize. Double-click or press Home to reset.`,className:`group absolute inset-y-0 -right-1.5 z-20 w-3 cursor-col-resize touch-none outline-none`,"data-sw-sidebar-handle":`true`,...S,children:(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:K(`absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 bg-accent opacity-0 transition-opacity group-hover:opacity-60 group-focus-visible:opacity-100`,x&&`opacity-100`)})}):null,x?(0,Y.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`,"aria-hidden":`true`}):null]})}function GD({count:e,corner:t=!1}){return e?(0,Y.jsxs)(`span`,{className:K(`inline-flex min-w-5 items-center justify-center rounded-full bg-bad px-1.5 text-[11px] leading-5 font-semibold text-bad-fg tabular`,t?`pointer-events-none absolute -top-1.5 -right-1.5`:`ml-1`),"data-sw-broken-links-badge":e,children:[e,(0,Y.jsxs)(`span`,{className:`sr-only`,children:[` broken link`,e===1?``:`s`]})]}):null}var KD=e=>e.status?String(e.status):`No answer`;function qD({items:e,open:t,onOpenChange:n}){let[r,i]=(0,J.useState)(!1),a=t??r,o=n||i,s=e.length;return(0,Y.jsx)(`div`,{className:`absolute top-2 left-2 z-30 max-w-[calc(100%-1rem)] max-lg:top-[4.75rem]`,"data-sw-broken-links":`true`,children:(0,Y.jsxs)(Ye,{open:a,onOpenChange:o,children:[(0,Y.jsx)(P,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,className:K(`inline-flex h-9 max-w-full items-center gap-2 rounded-full border border-bad/40 bg-surface pr-2.5 pl-2 text-xs font-medium text-fg shadow-pop transition-colors hover:bg-surface-2`,`focus-visible:outline-2 focus-visible:outline-accent [@media(pointer:coarse)]:h-11`),"aria-expanded":a,"data-sw-broken-links-toggle":`true`,children:[(0,Y.jsx)(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-bad/10 text-bad`,children:(0,Y.jsx)(ig,{size:12,"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`truncate`,children:[s,` broken link`,s===1?``:`s`]}),(0,Y.jsx)(`span`,{className:`hidden shrink-0 font-normal text-muted sm:inline`,children:`from the last capture`}),(0,Y.jsx)(H,{size:13,className:K(`shrink-0 text-faint transition-transform`,a&&`rotate-180`),"aria-hidden":`true`})]})}),(0,Y.jsxs)(qe,{align:`start`,className:`w-[min(26rem,calc(100vw-1.5rem))] p-0`,"aria-label":`Broken links`,children:[(0,Y.jsxs)(`div`,{className:`border-b border-line px-3 py-2.5`,children:[(0,Y.jsxs)(`p`,{className:`text-[13px] font-semibold text-fg`,children:[s,` link`,s===1?``:`s`,` lead`,s===1?`s`:``,` to an error`]}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:`Found on the pages of the last capture. Fix the link or publish the page.`})]}),(0,Y.jsx)(`ul`,{className:`max-h-72 divide-y divide-line overflow-auto`,children:e.slice(0,100).map(e=>(0,Y.jsxs)(`li`,{className:`flex items-start gap-2.5 px-3 py-2`,"data-sw-broken-link":e.path??e.url,children:[(0,Y.jsx)(`span`,{className:`mt-0.5 inline-flex h-5 shrink-0 items-center rounded bg-bad/10 px-1.5 font-mono text-[11px] font-semibold text-bad tabular`,children:KD(e)}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-mono text-xs text-fg`,children:e.path??e.url}),(e.from||[]).length?(0,Y.jsxs)(`span`,{className:`mt-0.5 block text-[11px] text-muted`,children:[`Linked from `,(e.from||[]).join(`, `)]}):null]})]},e.url))}),s>100?(0,Y.jsx)(`p`,{className:`border-t border-line px-3 py-2 text-[11px] text-faint`,children:`Showing the first 100.`}):null]})]})})}function JD({label:e,keys:t}){return(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[e,t.map(e=>(0,Y.jsx)(a,{children:e},e))]})}var YD=`__none`;function XD(e){if(e.branching)return`${e.paths?.length||2} paths`;let t=e.steps?.length||0;return`${t} ${t===1?`step`:`steps`}`}function ZD({journeys:e=[],journey:n,openJourney:i,closeJourney:o,canEditJourneys:s,startBuilder:c,showLinks:l,toggleLinks:u,linksTip:f,brokenLinks:p,openBrokenLinks:v,canCompare:y,comparePair:b,toggleCompare:x,minimapOn:S,toggleMinimap:w,compact:E,labelMax:O=160}){let[k,j]=(0,J.useState)(``),M=(0,J.useRef)(null),N=[l,!!b].filter(Boolean).length,P=p.length,F=e.length>8,ee=k.trim().toLowerCase(),I=F&&ee?e.filter(e=>e.name.toLowerCase().includes(ee)):e,L=(0,J.useRef)(null),R=`pr-2`,B=e=>(0,Y.jsx)(`span`,{className:K(`ml-auto inline-flex h-4 w-4 items-center justify-center`,e?`!text-accent`:`opacity-0`),children:(0,Y.jsx)(m,{size:14,className:`!text-accent`,"aria-hidden":`true`})}),V=P?`${P} broken link${P===1?``:`s`}`:null,H=[N?`${N} on`:null,V].filter(Boolean).join(`, `),U=n?`Journey: ${n.name}. Views`:H?`Views, ${H}`:`Views`,te=n?(0,Y.jsx)(JD,{label:`Journey: ${n.name}. Open Views to switch`,keys:[`J`]}):e.length?(0,Y.jsx)(JD,{label:`Views: journeys, links between pages, compare, minimap`,keys:[`J`]}):`Views: links between pages, compare, minimap`,ne=!!n,re=(0,Y.jsxs)(r,{variant:ne?`soft`:`ghost`,className:K(`relative h-8 shrink-0 text-[13px]`,E?`w-8 px-0`:`px-2.5`,ne?E?``:`rounded-r-none`:`text-fg`),"aria-label":U,"data-sw-view-menu":`true`,"data-sw-view-journey":n?.id,children:[ne?(0,Y.jsx)(Qg,{size:15,"aria-hidden":`true`}):(0,Y.jsx)(Sh,{size:15,"aria-hidden":`true`}),E?null:ne?(0,Y.jsx)(`span`,{className:`block truncate`,style:{maxWidth:O},"data-sw-view-journey-name":`true`,children:n.name}):`Views`,P?(0,Y.jsx)(`span`,{className:`pointer-events-none absolute -top-1.5 -right-1.5 inline-flex min-w-4 items-center justify-center rounded-full bg-bad px-1 text-[10px] leading-4 font-semibold text-bad-fg tabular`,"aria-hidden":`true`,"data-sw-broken-links-badge":P,children:P}):ne&&E?(0,Y.jsx)(`span`,{className:`absolute top-1 right-1 h-1.5 w-1.5 rounded-full bg-accent ring-2 ring-surface`,"aria-hidden":`true`,"data-sw-view-on":`journey`}):N&&!ne?(0,Y.jsx)(`span`,{className:`absolute top-1 right-1 h-1.5 w-1.5 rounded-full bg-muted ring-2 ring-surface`,"aria-hidden":`true`,"data-sw-view-on":N}):null]});return(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center`,"data-sw-views":`true`,children:[(0,Y.jsxs)(Ce,{onOpenChange:e=>e?null:j(``),children:[(0,Y.jsx)(h,{content:te,side:`bottom`,children:(0,Y.jsx)(C,{asChild:!0,children:re})}),(0,Y.jsxs)(t,{align:`start`,className:`w-80`,onCloseAutoFocus:e=>{e.preventDefault();let t=M.current;M.current=null,t?t():document.querySelector(`[data-sw-canvas]`)?.focus({preventScroll:!0})},"data-sw-views-menu":`true`,children:[e.length||s?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(D,{className:`flex items-center gap-2`,children:[`Journeys`,e.length?(0,Y.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1 font-normal tracking-normal normal-case`,children:[`Next `,(0,Y.jsx)(a,{children:`J`})]}):null]}),F?(0,Y.jsx)(`div`,{className:`px-1 pb-1`,children:(0,Y.jsx)(Ge,{size:`xs`,icon:n_,value:k,onChange:e=>j(e.target.value),placeholder:`Filter journeys`,"aria-label":`Filter journeys`,"data-sw-views-filter":`true`,onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),L.current?.querySelector(`[role="menuitemradio"]`)?.focus()):e.key!==`Escape`&&e.key!==`Tab`&&e.stopPropagation()}})}):null,(0,Y.jsxs)(A,{ref:L,value:n?.id||YD,onValueChange:e=>e===YD?o():i(e),className:F?`max-h-72 overflow-y-auto`:void 0,"aria-label":`Journeys`,"data-sw-views-journeys":e.length,children:[ee?null:(0,Y.jsxs)(d,{value:YD,"data-sw-views-journey":`none`,children:[(0,Y.jsx)(Sh,{size:15,"aria-hidden":`true`}),` None`,(0,Y.jsx)(`span`,{className:`ml-auto text-caption text-faint`,children:`All pages`})]}),I.map(e=>(0,Y.jsxs)(d,{value:e.id,"data-sw-views-journey":e.id,children:[(0,Y.jsx)(Qg,{size:15,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 pl-2 text-caption text-faint tabular-nums`,children:XD(e)})]},e.id)),ee&&!I.length?(0,Y.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-muted`,children:`No journey matches.`}):null]}),s?(0,Y.jsxs)(T,{className:R,onSelect:()=>c(),"data-sw-views-new-journey":`true`,children:[(0,Y.jsx)(Hg,{size:15,"aria-hidden":`true`}),` New journey`]}):null,(0,Y.jsx)(_,{})]}):null,(0,Y.jsx)(D,{children:`Show`}),(0,Y.jsxs)(T,{className:R,role:`menuitemcheckbox`,"aria-checked":l,onSelect:u,"data-sw-links-toggle":`true`,children:[(0,Y.jsx)(I_,{size:15,"aria-hidden":`true`}),`Links between pages`,B(l)]}),y?(0,Y.jsxs)(T,{className:R,role:`menuitemcheckbox`,"aria-checked":!!b,onSelect:x,"data-sw-compare-toggle":`true`,children:[(0,Y.jsx)(Ph,{size:15,"aria-hidden":`true`}),` Compare environments`,B(!!b)]}):null,(0,Y.jsxs)(T,{className:R,role:`menuitemcheckbox`,"aria-checked":S,onSelect:w,children:[(0,Y.jsx)(vg,{size:15,"aria-hidden":`true`}),` Minimap`,B(S)]}),P?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(_,{}),(0,Y.jsxs)(T,{className:R,onSelect:()=>{l||u(),M.current=v},"data-sw-broken-links-open":`true`,children:[(0,Y.jsx)(ig,{size:15,className:`!text-bad`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[(0,Y.jsx)(`span`,{className:`block`,children:`Broken links`}),(0,Y.jsxs)(`span`,{className:`block text-caption text-muted`,children:[P,` `,P===1?`link leads`:`links lead`,` to an error`]})]}),(0,Y.jsx)(`span`,{className:`ml-auto inline-flex min-w-5 items-center justify-center rounded-full bg-bad px-1.5 text-[11px] leading-5 font-semibold text-bad-fg tabular`,children:P})]})]}):null,(0,Y.jsx)(_,{}),(0,Y.jsxs)(`p`,{className:`px-2 py-1.5 text-xs text-muted`,children:[f,`.`]})]})]}),ne&&!E?(0,Y.jsx)(z,{variant:`soft`,className:`h-8 w-7 shrink-0 -ml-px rounded-l-none`,onClick:o,label:`Leave journey`,tooltip:(0,Y.jsx)(JD,{label:`Leave the journey`,keys:[`Esc`]}),side:`bottom`,"data-sw-view-journey-clear":`true`,children:(0,Y.jsx)(g,{size:14,"aria-hidden":`true`})}):null]})}function QD({data:e,capture:t}){let n=e?.manifest?.capturedAt,r=!t?.running&&t?.state===`failed`&&t.error,i=t?.running?`Capturing${t.total?` ${t.done||0} of ${t.total}`:``}`:n?`Captured ${Ee(n)}`:`Not captured yet`;return(0,Y.jsx)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs whitespace-nowrap text-muted`,"data-sw-captured":`true`,children:t?.running?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,role:`status`,children:[(0,Y.jsx)(ue,{size:12}),(0,Y.jsx)(`span`,{className:`tabular`,children:t.total?`${t.done||0}/${t.total}`:`Capturing`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:i})]}):r?(0,Y.jsx)(h,{content:`Last capture failed: ${t.error}`,side:`bottom`,children:(0,Y.jsxs)(`span`,{tabIndex:0,className:`inline-flex h-6 items-center gap-1.5 rounded-full bg-bad/10 px-2 font-medium text-bad outline-none focus-visible:outline-2 focus-visible:outline-accent`,"data-sw-capture-failed":`true`,children:[(0,Y.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-bad`,"aria-hidden":`true`}),` Capture failed`]})}):(0,Y.jsx)(h,{content:i,side:`bottom`,children:(0,Y.jsx)(`span`,{tabIndex:0,role:`img`,"aria-label":i,className:`inline-flex h-6 w-4 items-center justify-center rounded-full outline-none focus-visible:outline-2 focus-visible:outline-accent`,children:(0,Y.jsx)(`span`,{className:K(`h-2 w-2 rounded-full`,n?`bg-ok`:`bg-faint`),"aria-hidden":`true`})})})})}function $D({data:e,capture:t}){let n=e?.manifest?.capturedAt;return(0,Y.jsxs)(`p`,{className:`text-xs whitespace-nowrap text-muted`,"data-sw-captured":`true`,children:[t?.running?(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Y.jsx)(ue,{size:12}),` Capturing`,t.total?` ${t.done||0}/${t.total}`:``]}):n?`Captured ${Ee(n)}`:`Not captured yet`,!t?.running&&t?.state===`failed`&&t.error?(0,Y.jsxs)(`span`,{className:`ml-2 text-bad`,children:[`Last capture failed: `,t.error]}):null]})}var eO=e=>e.preventDefault(),tO={light:S_,dark:Mg,system:Ag},nO=`h-11 justify-center gap-1.5 rounded-md border border-transparent px-1 text-xs lg:h-9 data-[state=checked]:border-accent data-[state=checked]:bg-accent/10 data-[state=checked]:text-fg`;function rO({name:e,avatarUrl:n=null,detail:i=null,items:a=[],workspaces:o=null,viewAs:s=null,showName:c=!1,label:l=`Profile and appearance`,about:u=!0,triggerClassName:f,side:p=`bottom`,align:h=`end`,...g}){let[v,y]=gE(),b=(0,J.useRef)(null);return(0,Y.jsxs)(Ce,{children:[(0,Y.jsx)(C,{asChild:!0,children:(0,Y.jsxs)(r,{ref:b,variant:`ghost`,size:`touch`,className:K(`shrink-0 gap-2 px-1.5 lg:h-10`,f),"aria-label":e?`${l}: ${e}`:l,"data-sw-profile-menu":!0,...g,children:[(0,Y.jsx)(se,{name:e||`?`,src:n,className:`h-8 w-8`}),c&&e?(0,Y.jsx)(`span`,{className:`hidden max-w-40 truncate text-sm text-fg md:inline`,children:e}):null]})}),(0,Y.jsxs)(t,{className:`w-72`,side:p,align:h,"data-sw-profile-content":!0,children:[e||i?(0,Y.jsxs)(D,{className:`normal-case`,children:[e?(0,Y.jsx)(`span`,{className:`block truncate text-[13px] font-medium tracking-normal text-fg`,children:e}):null,i?(0,Y.jsx)(`span`,{className:`block truncate text-xs font-normal tracking-normal text-muted`,children:i}):null]}):null,a.length?(0,Y.jsxs)(Y.Fragment,{children:[e||i?(0,Y.jsx)(_,{}):null,(0,Y.jsx)(xe,{children:a.map(({id:e,label:t,icon:n,onSelect:r,tone:i,hint:a,...o})=>(0,Y.jsxs)(J.Fragment,{children:[(0,Y.jsxs)(T,{onSelect:r,tone:i,"data-sw-profile-item":e,"aria-describedby":a?`sw-profile-hint-`+e:void 0,...o,children:[n?(0,Y.jsx)(n,{size:14,"aria-hidden":`true`}):null,` `,t]}),a?(0,Y.jsx)(`p`,{id:`sw-profile-hint-`+e,className:`px-2 pb-1.5 text-xs text-muted`,"data-sw-profile-hint":e,children:a}):null]},e))})]}):null,o?.list?.length?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(_,{}),(0,Y.jsx)(D,{children:`Workspace`}),o.list.map(e=>(0,Y.jsxs)(T,{onSelect:()=>o.onPick(e.id),"data-sw-profile-workspace":e.id,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.roleLabel?(0,Y.jsx)(`span`,{className:`text-xs text-faint`,children:e.roleLabel}):null,e.id===o.current?(0,Y.jsx)(m,{size:14,className:`!text-accent`,"aria-label":`Current`}):null]},e.id))]}):null,s?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(_,{}),(0,Y.jsx)(D,{children:`View as (demo)`}),(0,Y.jsx)(A,{value:s.value,onValueChange:s.onChange,children:s.options.map(e=>(0,Y.jsxs)(d,{value:e.id,"data-sw-view-as":e.id,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.hint?(0,Y.jsx)(`span`,{className:`truncate text-xs text-faint`,children:e.hint}):null]},e.id))})]}):null,(0,Y.jsx)(_,{}),(0,Y.jsx)(D,{children:`Appearance`}),(0,Y.jsx)(A,{value:v.mode,onValueChange:e=>y({mode:e}),className:`grid grid-cols-3 gap-1 px-1 pb-1`,"aria-label":`Mode`,children:tE.map(e=>{let t=tO[e.id];return(0,Y.jsxs)(d,{value:e.id,indicator:!1,className:nO,onSelect:eO,"data-sw-appearance-mode":e.id,children:[(0,Y.jsx)(t,{size:14,"aria-hidden":`true`}),` `,e.label]},e.id)})}),(0,Y.jsx)(A,{value:v.theme,onValueChange:e=>y({theme:e}),className:`grid grid-cols-2 gap-1 px-1 pb-1`,"aria-label":`Theme`,children:nE.map(e=>(0,Y.jsxs)(d,{value:e.id,indicator:!1,className:K(nO,`justify-start px-2`),onSelect:eO,"data-sw-theme-option":e.id,children:[(0,Y.jsx)(`span`,{className:K(`h-4 w-4 shrink-0 rounded-full ring-1 ring-line`,`sw-swatch-${e.id}`),"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id))}),u?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(_,{}),(0,Y.jsxs)(T,{onSelect:()=>wT(b.current),"data-sw-app-about":`menu`,children:[(0,Y.jsx)(Xh,{size:14,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`About Shapewall and updates`}),(0,Y.jsxs)(`span`,{className:`text-caption text-faint tabular-nums`,"data-sw-app-version":!0,children:[`v`,mT.version]})]}),(0,Y.jsx)(T,{asChild:!0,"data-sw-app-contact":`menu`,children:(0,Y.jsxs)(`a`,{href:pT,target:`_blank`,rel:`noopener noreferrer`,children:[(0,Y.jsx)(gg,{size:14,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Contact`})]})})]}):null]})]})}function iO(e){return e?.public?`Visitor, public board (view only)`:e?.guest?`Guest, through a share link`:e?.hosted?[e.user?.handle?`@${e.user.handle}`:null,aO(e.role)].filter(Boolean).join(` · `):`A board on this machine`}var aO=e=>e?e[0].toUpperCase()+e.slice(1):null;function oO({info:e,localName:t,onOpenBuzz:n,demo:r,localSettingsAvailable:i,settingsAvailable:a,openSettings:o,setShareOpen:s,side:c,align:l,showName:u,triggerClassName:d}){return(0,Y.jsx)(rO,{name:e?.user?.name||t||null,avatarUrl:e?.user?.avatarUrl,detail:iO(e),items:[...e?.buzzAvailable===!0?[{id:`buzz`,label:`Existing Buzz conversation`,icon:o_,onSelect:n,"data-sw-buzz-open":`true`}]:[],...i?[{id:`account`,label:`Account and security`,icon:M_,onSelect:()=>Oe(`/account`)},{id:`console`,label:`Workspace Console`,icon:Jm,onSelect:()=>Oe(`/console`)}]:a?[{id:`settings`,label:`Settings`,icon:o_,onSelect:o,"data-sw-settings-open":`profile`}]:[],...e?.shareEnabled?[{id:`share`,label:`Share with your team...`,icon:Jm,onSelect:()=>s(!0)}]:[],...e?.consoleUrl&&!e?.guest?[{id:`console`,label:`Workspace Console`,icon:Jm,onSelect:()=>Oe(e.consoleUrl)}]:[],...e?.public&&typeof e.reportUrl==`string`&&e.reportUrl.startsWith(`mailto:`)?[{id:`report`,label:`Report this board`,icon:Ah,onSelect:()=>Oe(e.reportUrl)}]:[],...r?[r.resetItem]:[]],viewAs:r?.viewAs||null,side:c,align:l,showName:u,triggerClassName:d})}var sO=[`full`,`search`,`panels`,`view`,`viewport`,`tight`],cO={pad:12,gap:6,zoneGap:20,tightGap:4,tightZoneGap:12,search:{min:240,max:320,icon:32},name:[200,176,152,128,104,104],journey:[160,128,96],journeyMax:280};function lO(e){let t=t=>e>=sO.indexOf(t);return{search:t(`search`),panels:t(`panels`),view:t(`view`),viewport:t(`viewport`),comment:t(`tight`),tight:t(`tight`)}}function uO(e,t,n=lO(t).tight?cO.tightGap:cO.gap){let r=e.filter(Boolean);if(!r.length)return 0;let i=lO(t),a=e=>e.at&&i[e.at]?e.compact:Array.isArray(e.full)?e.full[t]:e.full;return r.reduce((e,t)=>e+a(t),0)+n*(r.length-1)}function dO({text:e,title:t,viewports:n=[],capture:r=!1,status:i={kind:`dot`},viewer:a=!1,comment:o=!1,panels:s={comments:0,agent:!1,checks:!1},settings:c=!1,journey:l=null}){let u=(t,n)=>Math.ceil(e(String(t),n))+1,d={left:[],right:[]};n.length>1&&d.left.push({id:`viewport`,full:6+n.reduce((e,t)=>e+20+u(t,`xs`),0),compact:6+n.length*30,at:`viewport`});let f=l?u(l,`ui`):0,p=e=>Math.min(f,cO.journey[Math.min(e,cO.journey.length-1)]);d.left.push({id:`view`,full:l?sO.map((e,t)=>41+p(t)+27):41+u(`Views`,`ui`),...l?{grow:sO.map((e,t)=>Math.max(0,Math.min(f,cO.journeyMax)-p(t)))}:{},compact:32,at:`view`}),r&&d.left.push({id:`capture`,full:32}),d.left.push({id:`capture-status`,full:i.kind===`running`?18+u(i.progress||`Capturing`,`xs`):i.kind===`failed`?28+u(`Capture failed`,`xs`):16}),a&&d.right.push({id:`viewer`,full:40+u(`Viewer`,`xs`)}),o&&d.right.push({id:`comment`,full:45+u(`Comment`,`ui`),compact:32,at:`comment`});let m=12+u(s.comments,`count`),h=[{full:46+u(`Comments`,`ui`)+m,compact:40+m}];s.agent&&h.push({full:40+u(`Agent`,`ui`),compact:34}),s.checks&&h.push({full:40+u(`Checks`,`ui`),compact:34});let g=2*(h.length-1);return d.right.push({id:`panels`,full:h.reduce((e,t)=>e+t.full,g),compact:h.reduce((e,t)=>e+t.compact,g),at:`panels`}),c&&d.right.push({id:`settings`,full:32}),{name:40+u(t,`name`),left:d.left,right:d.right,searchIcon:!!l}}function fO(e,t,n){let r=e.find(e=>e.id===`view`&&e.grow);return!r||lO(t).view?0:(Array.isArray(r.full)?r.full[t]-41-27:0)+Math.max(0,Math.min(r.grow[t],Math.floor(n)))}function pO({width:e,name:t,left:n=[],right:r=[],searchIcon:i=!1,config:a=cO}){let o=Math.max(0,e-2*a.pad),s=sO.length-1,c=e=>{let i=lO(e).tight,o=i?a.tightGap:a.gap,s=uO(n,e,o);return{left:Math.min(t,a.name[e])+(s?o+s:0),right:uO(r,e,o),zoneGap:i?a.tightZoneGap:a.zoneGap}};for(let e=+!!i;e<=s;e+=1){let t=c(e),r=o-2*(Math.max(t.left,t.right)+t.zoneGap);if(e===0){if(r>=a.search.min)return{step:e,centred:!0,search:Math.min(a.search.max,r),journey:0}}else{if(i){let r=o-t.left-t.right-a.search.icon-2*t.zoneGap;if(r<0)continue;let i=fO(n,e,r),s=(o-a.search.icon)/2-t.zoneGap,c=t.left+i-fO(n,e,0);return{step:e,centred:c<=s&&t.right<=s,search:0,journey:i}}if(r>=a.search.icon)return{step:e,centred:!0,search:0,journey:0}}}return{step:s,centred:!1,search:0,journey:fO(n,s,0)}}var mO={name:`600 14px`,ui:`500 13px`,xs:`500 12px`,count:`600 11px`},hO;function gO(e,t){return typeof document>`u`||(hO||=document.createElement(`canvas`).getContext(`2d`),!hO)?e.length*8:(hO.font=`${mO[t]} ${getComputedStyle(document.body).fontFamily}`,hO.measureText(e).width)}function _O(e,t){let[n,r]=(0,J.useState)(()=>typeof window>`u`?1280:window.innerWidth);return(0,J.useLayoutEffect)(()=>{let n=e.current;if(!t||!n)return;let i=()=>r(Math.round(n.getBoundingClientRect().width));if(i(),typeof ResizeObserver>`u`)return;let a=new ResizeObserver(i);return a.observe(n),()=>a.disconnect()},[e,t]),n}function vO({labels:e,allOpen:t,panelHidden:n,chatAvailable:r,chatThread:i,reopenChat:a,checksOpen:o,canChecks:s,openChecks:c,closeChecks:l,updateParams:u}){let d=!n&&!i&&!o,f=`h-8 text-ui`;return(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,role:`group`,"aria-label":`Side panel`,children:[(0,Y.jsx)(h,{content:`${d?`Hide`:`Show`} comments (${t} open)`,side:`bottom`,children:(0,Y.jsxs)(ke,{variant:`flat`,className:f,pressed:d,onPressedChange:()=>u({panel:n||i||o?null:`off`,chat:null,checks:null,cv:null}),"aria-label":`Comments, ${t} open`,"data-sw-panel-toggle":`true`,children:[(0,Y.jsx)(wg,{size:14,"aria-hidden":`true`}),e?`Comments`:null,(0,Y.jsx)(`span`,{className:`tabular rounded-full bg-fg/[0.07] px-1.5 text-[11px] leading-4 font-semibold text-fg`,"aria-hidden":`true`,children:t})]})}),r?(0,Y.jsx)(h,{content:i?`Close the agent chat`:`Chat with your agent about this board`,side:`bottom`,children:(0,Y.jsxs)(ke,{variant:`flat`,className:f,pressed:!!i,"aria-label":`Agent`,onPressedChange:()=>i?u({chat:null}):a(),"data-sw-chat-toggle":`true`,children:[(0,Y.jsx)(S,{size:14,"aria-hidden":`true`}),e?`Agent`:null]})}):null,s?(0,Y.jsx)(h,{content:o?`Close the checks`:`Page checks: performance, accessibility, SEO`,side:`bottom`,align:`end`,children:(0,Y.jsxs)(ke,{variant:`flat`,className:f,pressed:!!o,"aria-label":`Checks`,onPressedChange:()=>o?l():c(),"data-sw-checks-toggle":`true`,children:[(0,Y.jsx)(Ah,{size:14,"aria-hidden":`true`}),e?`Checks`:null]})}):null]})}function yO({wide:e,info:t,boardId:n,boards:i,data:a,localProjects:o,projectsError:s,localName:c,onPickBoard:l,onOpenBuzz:u,demo:d,localSettingsAvailable:f,settingsAvailable:p,openSettings:m,setShareOpen:g,modes:_,mode:v,setMode:y,viewportNotice:b,canComment:x,comparePair:S,commentMode:C,setCommentMode:w,openPalette:T,setMenuOpen:E,showLinks:D,toggleLinks:O,linksTip:k,brokenLinks:A,canCompare:j,toggleCompare:M,minimapOn:N,toggleMinimap:P,journeys:F=[],journey:ee,openJourney:I,closeJourney:L,canEditJourneys:R,startBuilder:B,openBrokenLinks:V,capture:H,busy:U,canCapture:te,setCaptureConfirm:ne,chatAvailable:re,chatThread:ie,reopenChat:ae,updateParams:G,panelHidden:oe,checksOpen:se,allOpen:ce,canChecks:le,openChecks:ue,closeChecks:fe,setSheetOpen:me,sidebarTitled:ge}){let ve=i.find(e=>e.id===n)?.title||a?.board?.title||n,ye=t?.hosted&&t?.project?.url&&t.role!==`guest`?t.project:null,be=!x&&t?.hosted&&t?.role===`viewer`,xe=x&&!S,Se=(0,J.useRef)(null),Ce=_O(Se,e),we=H?.running?`running`:H?.state===`failed`&&H.error?`failed`:`dot`,Te=H?.running&&H.total?`${H.done||0}/${H.total}`:`Capturing`,Ee=_.map(e=>e.label).join(`
|
|
34
34
|
`),ke=(0,J.useMemo)(()=>pO({width:Ce,...dO({text:gO,title:ve,viewports:Ee?Ee.split(`
|
|
35
35
|
`):[],capture:!!te,status:{kind:we,progress:Te},viewer:be,comment:xe,panels:{comments:ce,agent:!!re,checks:!!le},settings:!!p,journey:ee?.name||null})}),[Ce,ve,Ee,te,we,Te,be,xe,ce,re,le,p,ee?.name]),Ae=lO(ke.step),je=(0,Y.jsx)(oO,{info:t,localName:c,onOpenBuzz:u,demo:d,localSettingsAvailable:f,settingsAvailable:p,openSettings:m,setShareOpen:g}),Ne=(0,Y.jsxs)(Ve,{value:n,onValueChange:e=>{if(!e.startsWith(`project/`))return l(e);let t=o.find(t=>`project/${t.id}`===e);t?.url&&t.running&&Oe(t.url)},children:[(0,Y.jsx)(he,{size:e?`sm`:`touch`,className:e?K(`max-w-72 min-w-0 border-transparent bg-transparent px-2.5 text-sm font-semibold shadow-none hover:bg-surface-2 data-[state=open]:bg-surface-2`,ye&&`h-6`):`min-w-0 flex-1 border-transparent bg-transparent px-2 text-[15px] font-semibold shadow-none`,"aria-label":`Board: ${ve}`,"data-sw-picker":`true`,children:(0,Y.jsx)(W,{children:(0,Y.jsx)(`span`,{className:`block truncate`,children:ve})})}),(0,Y.jsxs)(de,{children:[(0,Y.jsxs)(pe,{children:[o.length>1||ye?(0,Y.jsx)(De,{children:ye?ye.name:`This project`}):null,i.map(t=>(0,Y.jsx)(Me,{value:t.id,children:e?`${t.title} · ${t.pageCount} pages`:t.title},t.id))]}),o.length>1?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(_e,{}),(0,Y.jsxs)(pe,{children:[(0,Y.jsx)(De,{children:`Local projects`}),o.map(e=>(0,Y.jsxs)(Me,{value:`project/${e.id}`,disabled:e.current||!e.running,"data-sw-local-project":e.id,children:[e.title,e.current?` (current)`:e.running?``:` (not running)`]},e.id))]}),o.some(e=>!e.running&&!e.current)?(0,Y.jsx)(`p`,{className:`max-w-72 px-2 py-1.5 text-xs text-muted`,children:`Start a stopped project with shapewall serve in its folder.`}):null]}):null,s?(0,Y.jsx)(`p`,{className:`max-w-72 px-2 py-1.5 text-xs text-bad`,children:`Could not load local projects. Check the terminal for your project index.`}):null]})]});if(!e)return(0,Y.jsxs)(`header`,{className:`flex shrink-0 items-center gap-1 border-b border-line bg-surface px-2 py-1.5`,"data-sw-toolbar":`compact`,children:[(0,Y.jsx)(`h1`,{className:`sr-only`,children:`Shapewall`}),Ne,x&&!S?(0,Y.jsx)(z,{size:`icon`,variant:C?`default`:`soft`,className:`shrink-0`,"aria-pressed":C,onClick:()=>w(e=>!e),label:C?`Stop commenting`:`Comment: tap a page to pin`,"data-sw-comment-mode":`true`,children:(0,Y.jsx)(Sg,{size:19,"aria-hidden":`true`})}):null,be?(0,Y.jsx)(WT,{compact:!0}):null,(0,Y.jsxs)(r,{size:`touch`,variant:`ghost`,className:`shrink-0 gap-1.5 px-2.5 text-fg`,onClick:()=>{fe(),me(!0)},"aria-label":`Comments, ${ce} open`,"data-sw-panel-toggle":`true`,children:[(0,Y.jsx)(wg,{size:18,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`tabular text-[13px] font-semibold`,children:ce})]}),(0,Y.jsx)(z,{size:`icon`,variant:`ghost`,className:`shrink-0 text-fg`,onClick:()=>E(!0),label:re?`More: agent, pages, views, screen size`:`More: pages, views, screen size`,"data-sw-menu":`true`,children:(0,Y.jsx)(vh,{size:19,"aria-hidden":`true`})}),je]});let Pe=_.map(e=>{let t=e.id===`all`?e_:fv(e.id);return{id:e.id,tooltip:Ae.viewport?e.label:null,label:Ae.viewport?(0,Y.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,Y.jsx)(t,{size:14,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:e.label})]}):e.label}}),q=(0,Y.jsx)(QD,{data:a,capture:H}),Fe=Ae.tight?`gap-1`:`gap-1.5`;return(0,Y.jsxs)(`header`,{ref:Se,className:K(`grid h-14 shrink-0 items-center border-b border-line bg-surface px-3`,Ae.tight?`gap-x-3`:`gap-x-5`,ke.centred?`grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]`:`grid-cols-[auto_auto_minmax(0,1fr)]`),"data-sw-toolbar":`full`,"data-sw-toolbar-fit":sO[ke.step],"data-sw-toolbar-centred":ke.centred?`true`:`false`,children:[(0,Y.jsxs)(`h1`,{className:`sr-only`,children:[`Shapewall: `,ve]}),(0,Y.jsxs)(`div`,{className:K(`flex min-w-0 items-center`,Fe),"data-sw-toolbar-zone":`left`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-center`,style:ke.centred?void 0:{maxWidth:cO.name[ke.step]},children:[ye&&!ge?(0,Y.jsx)(GT,{project:ye}):null,Ne]}),te?null:q,_.length>1?(0,Y.jsx)(`span`,{className:K(`shrink-0 rounded-md`,b&&`animate-flash`),"data-sw-viewport-flash":b?b.to:void 0,children:(0,Y.jsx)(ze,{label:`Screen size`,options:Pe,value:v,onChange:y,itemClassName:Ae.viewport?`px-2`:void 0})},b?.at||`still`):null,(0,Y.jsx)(ZD,{journeys:F,journey:ee,openJourney:I,closeJourney:L,canEditJourneys:R,startBuilder:B,showLinks:D,toggleLinks:O,linksTip:k,brokenLinks:A,openBrokenLinks:V,canCompare:j,comparePair:S,toggleCompare:M,minimapOn:N,toggleMinimap:P,compact:Ae.view,labelMax:ke.journey||cO.journey[Math.min(ke.step,cO.journey.length-1)]}),te?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(z,{variant:`ghost`,className:`shrink-0 text-fg`,disabled:H?.running||U,onClick:()=>ne(!0),label:`Capture now`,tooltip:`Recapture every page`,side:`bottom`,"data-sw-capture":`true`,children:(0,Y.jsx)(Xm,{size:16,"aria-hidden":`true`})}),q]}):null]}),(0,Y.jsx)(`div`,{className:`flex shrink-0 items-center justify-center`,"data-sw-toolbar-zone":`center`,children:(0,Y.jsx)(h,{content:(0,Y.jsx)(JD,{label:`Go to a page, journey or comment`,keys:[cD]}),side:`bottom`,children:(0,Y.jsx)(hD,{onOpen:T,compact:Ae.search,style:Ae.search?void 0:{width:ke.search}})})}),(0,Y.jsxs)(`div`,{className:K(`flex min-w-0 items-center justify-end`,Fe),"data-sw-toolbar-zone":`right`,children:[be?(0,Y.jsx)(WT,{}):null,xe?(0,Y.jsx)(h,{content:(0,Y.jsx)(JD,{label:C?`Stop commenting`:`Click a page to pin a comment`,keys:C?[`C`,`Esc`]:[`C`]}),side:`bottom`,children:(0,Y.jsxs)(r,{variant:C?`default`:`soft`,className:K(`h-8 shrink-0 text-[13px]`,Ae.comment?`w-8 px-0`:`px-3`,C&&`ring-2 ring-accent/30`),"aria-pressed":C,onClick:()=>w(e=>!e),"data-sw-comment-mode":`true`,children:[(0,Y.jsx)(Sg,{size:15,"aria-hidden":`true`}),Ae.comment?(0,Y.jsx)(`span`,{className:`sr-only`,children:`Comment`}):`Comment`]})}):null,(0,Y.jsx)(vO,{labels:!Ae.panels,allOpen:ce,panelHidden:oe,chatAvailable:re,chatThread:ie,reopenChat:ae,checksOpen:se,canChecks:le,openChecks:ue,closeChecks:fe,updateParams:G}),p?(0,Y.jsx)(z,{variant:`ghost`,className:`shrink-0 text-fg`,onClick:m,label:`Agent settings`,tooltip:`Agent settings: which agent the chat uses`,side:`bottom`,"data-sw-settings-open":`true`,children:(0,Y.jsx)(o_,{size:16,"aria-hidden":`true`})}):null]})]})}function bO({menuOpen:e,setMenuOpen:t,data:n,chatAvailable:i,chatThread:a,reopenChat:o,groupedPages:s,jumpToPage:c,modes:l,mode:u,setMode:d,journeys:f,journey:p,canEditJourneys:m,openJourney:h,closeJourney:g,startBuilder:_,canChecks:v,openChecks:y,showLinks:b,toggleLinks:x,brokenLinks:C,canCompare:w,comparePair:T,toggleCompare:E,settingsAvailable:D,openSettings:O,capture:k,canCapture:A,busy:j,setCaptureConfirm:N}){let P=`mb-1.5 flex items-center gap-1 text-[11px] font-medium tracking-wide text-faint uppercase`,[F,ee]=(0,J.useState)(``),I=f.length>8,L=I?F.trim().toLowerCase():``,R=L?f.filter(e=>e.name.toLowerCase().includes(L)):f,z=e=>{t(!1),e?h(e):g()};return(0,Y.jsx)(M,{open:e,onClose:()=>t(!1),title:n?.board?.title||`Board`,children:(0,Y.jsxs)(`div`,{className:`space-y-5 p-5`,children:[l.length>1?(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:P,children:`Screen size`}),(0,Y.jsx)(ze,{label:`Screen size`,options:l,value:u,onChange:e=>{d(e),t(!1)},large:!0})]}):null,i?(0,Y.jsxs)(r,{size:`touch`,className:`w-full justify-start`,variant:a?`default`:`secondary`,onClick:()=>{t(!1),o()},"data-sw-chat-toggle":`true`,children:[(0,Y.jsx)(S,{size:16,"aria-hidden":`true`}),` Chat with your agent`]}):null,(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`p`,{className:P,children:[(0,Y.jsx)(fg,{size:12,"aria-hidden":`true`}),` Go to a page`]}),(0,Y.jsx)(oD,{groups:s,onPick:e=>{t(!1),c(e)}})]}),f.length||m?(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:P,children:`Journeys`}),I?(0,Y.jsx)(Ge,{size:`touch`,icon:n_,wrapperClassName:`mb-1.5`,value:F,onChange:e=>ee(e.target.value),placeholder:`Filter journeys`,"aria-label":`Filter journeys`,"data-sw-views-filter":`true`}):null,(0,Y.jsxs)(`div`,{className:I?`flex max-h-80 flex-col gap-1.5 overflow-y-auto`:`flex flex-col gap-1.5`,role:`radiogroup`,"aria-label":`Journeys`,"data-sw-journey-menu":`true`,children:[f.length&&!L?(0,Y.jsxs)(r,{size:`touch`,className:`w-full justify-start`,role:`radio`,"aria-checked":!p,variant:p?`secondary`:`default`,onClick:()=>z(null),"data-sw-journey-open":`none`,children:[(0,Y.jsx)(Sh,{size:15,"aria-hidden":`true`}),` None`,(0,Y.jsx)(`span`,{className:`ml-auto text-xs opacity-70`,children:`All pages`})]}):null,R.map(e=>(0,Y.jsxs)(r,{size:`touch`,className:`w-full justify-start`,role:`radio`,"aria-checked":p?.id===e.id,variant:p?.id===e.id?`default`:`secondary`,onClick:()=>z(e.id),"data-sw-journey-open":e.id,children:[(0,Y.jsx)(Qg,{size:15,"aria-hidden":`true`}),` `,(0,Y.jsx)(`span`,{className:`truncate`,children:e.name}),(0,Y.jsx)(`span`,{className:`ml-auto text-xs tabular-nums opacity-70`,children:XD(e)})]},e.id)),L&&!R.length?(0,Y.jsx)(`p`,{className:`px-1 text-sm text-muted`,children:`No journey matches.`}):null,m?(0,Y.jsxs)(r,{size:`touch`,variant:`ghost`,className:`w-full justify-start`,onClick:()=>{t(!1),_()},children:[(0,Y.jsx)(Hg,{size:15,"aria-hidden":`true`}),` New journey`]}):null]})]}):null,(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(`p`,{className:P,children:`Show`}),v?(0,Y.jsxs)(r,{size:`touch`,className:`w-full justify-start`,variant:`secondary`,onClick:()=>{t(!1),y()},"data-sw-checks-toggle":`true`,children:[(0,Y.jsx)(Ah,{size:16,"aria-hidden":`true`}),`Checks`]}):null,(0,Y.jsxs)(r,{size:`touch`,className:`w-full justify-start`,"aria-pressed":b,variant:b?`default`:`secondary`,onClick:()=>{t(!1),x()},"data-sw-links-toggle":`true`,children:[(0,Y.jsx)(I_,{size:15,"aria-hidden":`true`}),` `,b?`Hide links between pages`:`Show links between pages`,(0,Y.jsx)(GD,{count:C.length})]}),w?(0,Y.jsxs)(r,{size:`touch`,className:`w-full justify-start`,"aria-pressed":!!T,variant:T?`default`:`secondary`,onClick:()=>{t(!1),E()},"data-sw-compare-toggle":`true`,children:[(0,Y.jsx)(Ph,{size:15,"aria-hidden":`true`}),` `,T?`Leave compare mode`:`Compare environments`]}):null,D?(0,Y.jsxs)(r,{size:`touch`,className:`w-full justify-start`,variant:`secondary`,onClick:()=>{t(!1),O()},"data-sw-settings-open":`true`,children:[(0,Y.jsx)(o_,{size:15,"aria-hidden":`true`}),` Agent settings`]}):null]}),(0,Y.jsxs)(`div`,{className:`space-y-2 border-t border-line pt-4`,children:[(0,Y.jsx)($D,{data:n,capture:k}),A?(0,Y.jsxs)(r,{size:`touch`,className:`w-full`,disabled:k?.running||j,onClick:()=>{t(!1),N(!0)},"data-sw-capture":`true`,children:[(0,Y.jsx)(Xm,{size:15,"aria-hidden":`true`}),` Capture now`]}):null]})]})})}function xO({wide:e,commentMode:t,canComment:n,readyKeys:i,setCommentMode:a,showLinks:o,activePage:s,shownSteps:c,data:l,presentPages:u,hiddenLinkTargets:d,showAllLinks:f,targetTitle:p,updateParams:m,tipOpen:h,tryOpen:_,journey:v,builder:y,viewportNotice:b,dismissTip:x,modes:S,setMode:C,comparePair:w}){let T=e=>S.find(t=>t.id===e)?.label||e,E=e?`Scroll or drag to move, Ctrl+scroll or pinch to zoom. Click a page for its actions${n&&!w?`, or press C to comment`:``}.`:`Pinch to zoom. Tap a page for its actions${n&&!w?`, or the comment button to pin a note`:``}.`;return(0,Y.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-0 top-3 z-30 flex flex-col items-center gap-1.5 px-2`,"data-sw-canvas-notes":`true`,children:[t&&n?(0,Y.jsxs)(`div`,{className:`pointer-events-auto flex w-max max-w-full items-center gap-2 rounded-full bg-accent py-0.5 pr-0.5 pl-3 text-xs font-medium text-accent-fg shadow-pop`,role:`status`,"data-sw-comment-hint":i.size?`element`:`page`,children:[(0,Y.jsx)(Sg,{size:13,className:`shrink-0`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0`,children:i.size?e?`Click an element on the live page to comment on it.`:`Tap an element on the live page to comment on it.`:e?`Click a page to comment. Zoom in until the page goes live to pin it to an element.`:`Tap a page to pin a comment.`}),(0,Y.jsxs)(r,{size:e?`xs`:`touch`,variant:`inverse`,className:`shrink-0 rounded-full`,onClick:()=>a(!1),"data-sw-comment-hint-done":`true`,children:[`Done`,e?` (Esc)`:``]})]}):null,o&&!s&&!c&&G_(l?.links,u,d)>150?(0,Y.jsx)(`p`,{className:`w-max max-w-full rounded-full bg-surface px-3 py-1 text-xs font-medium text-muted shadow-pop`,"data-sw-links-hint":`true`,children:e?`Hover or select a page to see its links`:`Tap a page to see its links`}):null,o&&(d?.size||f)?(0,Y.jsxs)(`div`,{className:`pointer-events-auto flex w-max max-w-full items-center gap-2 rounded-full border border-line bg-surface py-0.5 pr-0.5 pl-3 text-xs text-muted shadow-pop`,"data-sw-links-global":f?`shown`:`hidden`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:f?`Showing every link, the nav and footer ones too.`:`Hiding the nav and footer links (to ${[...d].slice(0,3).map(e=>p(e)).join(`, `)}${d.size>3?` and ${d.size-3} more`:``}).`}),(0,Y.jsx)(r,{size:e?`xs`:`touch`,variant:`ghost`,className:`shrink-0 rounded-full`,onClick:()=>m({la:f?null:`1`}),"data-sw-links-global-toggle":`true`,children:f?`Hide them`:`Show them`})]}):null,h&&!_&&l&&!t&&!o&&!v&&!y&&!b?(0,Y.jsxs)(`div`,{className:`pointer-events-auto flex w-max max-w-full items-center gap-1.5 rounded-full border border-line bg-surface py-0.5 pr-0.5 pl-3 text-xs text-fg shadow-pop`,role:`note`,"data-sw-tip":`true`,children:[(0,Y.jsx)(ng,{size:13,className:`shrink-0 text-accent`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`min-w-0`,children:E}),(0,Y.jsx)(z,{size:e?`icon-xs`:`icon`,variant:`ghost`,className:`shrink-0 rounded-full shadow-none`,onClick:x,label:`Dismiss the tip`,"data-sw-tip-dismiss":`true`,children:(0,Y.jsx)(g,{size:14,"aria-hidden":`true`})})]}):null,b?(0,Y.jsxs)(`div`,{className:`pointer-events-auto flex w-max max-w-full items-center gap-2 rounded-lg border border-line bg-surface py-1 pr-1 pl-3 text-xs text-fg shadow-pop`,role:`status`,"data-sw-viewport-notice":b.to,children:[(0,Y.jsxs)(`span`,{className:`min-w-0`,children:[`Showing `,T(b.to),`: comment #`,b.id,` is on the `,b.to,` capture.`]}),(0,Y.jsxs)(r,{size:e?`xs`:`touch`,variant:`secondary`,className:`shrink-0`,onClick:()=>C(b.from),"data-sw-viewport-notice-back":`true`,children:[`Back to `,T(b.from)]})]}):null]})}var SO=e=>e?.tool?`${e.owner}\n${e.key}`:``;function CO(e){let t=cx(SO);return e&&!!t}function wO({flow:e,canvasRef:t,targets:n,focusFor:r,shotFor:i}){let a=cx(SO),o=(0,J.useRef)(null),s=(0,J.useRef)({targets:n,focusFor:r,shotFor:i,active:a});return s.current={targets:n,focusFor:r,shotFor:i,active:a},(0,J.useEffect)(()=>{if(!a){o.current&&e.setViewport(o.current,{duration:kE(400)}),o.current=null;return}let[n,r]=a.split(`
|
|
36
36
|
`),i=r.lastIndexOf(`|`),[c,l]=[r.slice(0,i),r.slice(i+1)],u=s.current.targets?.[c],d=u?.frames.find(e=>e.viewport===l);if(!d)return;o.current||=e.getViewport();let f=!1;return DE(s.current.shotFor(c,l)).catch(()=>1).then(r=>{if(f||s.current.active!==a)return;let i=Math.min(1,Math.max(0,s.current.focusFor(n))),o=Math.min(1,Math.max(.25,r,i+.08)),c=qE({x:u.x+d.x,y:u.y+d.y,width:d.w,height:d.h*o},t.current?.getBoundingClientRect(),i/o);c&&e.setViewport(c,{duration:kE(450)})}),()=>{f=!0}},[a,e,t]),a?(0,Y.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 top-3 z-30 flex justify-center px-2`,"data-sw-drawing-mode":`true`,children:(0,Y.jsx)(Ox,{owner:a.split(`
|
|
37
|
-
`)[0]})}):null}function TO(){let[e,t]=(0,J.useState)(null),[n,r]=(0,J.useState)(!1);return(0,J.useEffect)(()=>{e||r(!1)},[e]),(0,J.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>t(t=>t===e?null:t),6e3);return()=>window.clearTimeout(r)},[e,n]),[e,t,r]}function EO(e,t){let n=!!e?.untilSheet;(0,J.useEffect)(()=>{if(!n)return;let e=()=>{document.querySelector(`[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)&&t(e=>e?.untilSheet?null:e)};e();let r=new MutationObserver(e);return r.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-state`]}),()=>r.disconnect()},[n,t])}function DO({toast:e,setToast:t,onHold:n,wide:i,raised:a}){return EO(e,t),e?(0,Y.jsxs)(`div`,{onMouseEnter:()=>n?.(!0),onMouseLeave:()=>n?.(!1),onFocus:()=>n?.(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||n?.(!1)},className:K(`absolute inset-x-0 z-[80] mx-auto flex w-max max-w-[calc(100%-1rem)] animate-pop-in items-center gap-2 rounded-lg bg-fg py-1 pr-1 pl-3 text-xs font-medium text-surface shadow-pop`,a?i?`bottom-28`:`bottom-44`:i?`bottom-4`:`bottom-16`),role:`status`,"data-sw-toast":`true`,children:[(0,Y.jsx)(`span`,{className:`min-w-0`,children:e.text}),e.undo?(0,Y.jsx)(r,{size:i?`xs`:`touch`,variant:`inverse`,onClick:()=>{e.undo(),t(null)},"data-sw-toast-undo":`true`,children:`Undo`}):null,(0,Y.jsx)(z,{size:i?`icon-xs`:`icon`,variant:`inverse`,onClick:()=>t(null),label:`Dismiss`,children:(0,Y.jsx)(g,{size:13,"aria-hidden":`true`})})]},e.at):null}function OO({notice:e,setNotice:t,wide:n}){return e?(0,Y.jsxs)(`div`,{className:K(`flex shrink-0 items-center gap-3 border-b border-line px-4 py-2 text-xs`,e.tone===`bad`?`bg-bad/10 text-bad`:`bg-accent/10 text-fg`),role:e.tone===`bad`?`alert`:`status`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.text}),(0,Y.jsx)(r,{variant:`ghost`,size:n?`xs`:`touch`,onClick:()=>t(null),children:`Dismiss`})]}):null}var kO=(0,J.lazy)(()=>xT(()=>import(`./ChecksPanel-BqrS02Ih.js`),__vite__mapDeps([3,1,2,4,5]),import.meta.url)),AO=(0,J.lazy)(()=>xT(()=>import(`./BoardChat-CupOxioV.js`),__vite__mapDeps([6,1,7,5,2,4]),import.meta.url));function jO({wide:e,checksOpen:t,checksProps:n,chatThread:r,chatProps:i,panelHidden:a,panelProps:o,updateParams:s}){return e&&t?(0,Y.jsx)(LO,{panel:`checks`,defaultWidth:384,"aria-label":`Checks`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`p`,{className:`p-4 text-sm text-muted`,children:`Loading checks…`}),children:(0,Y.jsx)(kO,{...n})})},`checks`):e&&r?(0,Y.jsx)(LO,{panel:`agent`,defaultWidth:384,"aria-label":`Agent`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(V_,{}),children:(0,Y.jsx)(AO,{...i,onClose:()=>s({chat:null})})})},`agent`):e&&!a?(0,Y.jsx)(LO,{panel:`comments`,defaultWidth:384,id:`sw-comments`,tabIndex:-1,className:`outline-none`,"aria-label":`Comments`,children:(0,Y.jsx)(MC,{...o,onClose:()=>s({panel:`off`})})},`comments`):null}var MO=280,NO=.6,PO=16,FO=`side`;function IO(e){let t=Math.max(MO,Math.floor(window.innerWidth*NO));return Math.min(t,Math.max(MO,Math.round(e)))}function LO({panel:e,defaultWidth:t,className:n,children:r,...i}){let[a,o]=(0,J.useState)(()=>IO(rD(FO)??t)),[s,c]=(0,J.useState)(!1),l=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=()=>o(e=>IO(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let u=e=>{let n=IO(e);o(n),iD(FO,n===t?null:n)},d=e=>{e.button===0&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),l.current={x:e.clientX,width:a},c(!0))},f=e=>{l.current&&o(IO(l.current.width+l.current.x-e.clientX))},p=e=>{l.current&&(u(l.current.width+l.current.x-e.clientX),l.current=null,c(!1))},m=e=>{let n=e.shiftKey?64:PO;if(e.key===`ArrowLeft`)u(a+n);else if(e.key===`ArrowRight`)u(a-n);else if(e.key===`Home`)u(t);else return;e.preventDefault()};return(0,Y.jsxs)(`aside`,{className:K(`relative flex shrink-0 flex-col border-l border-line bg-surface`,n),style:{width:a},"data-sw-rail":e,...i,children:[(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize panel`,"aria-valuenow":a,"aria-valuemin":MO,"aria-valuemax":Math.max(MO,Math.floor(window.innerWidth*NO)),"aria-description":`Drag or use the arrow keys to resize. Double-click or press Home to reset.`,tabIndex:0,className:`group absolute inset-y-0 -left-1.5 z-20 w-3 cursor-col-resize touch-none outline-none`,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onDoubleClick:()=>u(t),onKeyDown:m,"data-sw-rail-handle":`true`,children:(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:K(`absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 bg-accent opacity-0 transition-opacity group-hover:opacity-60 group-focus-visible:opacity-100`,s&&`opacity-100`)})}),s?(0,Y.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`,"aria-hidden":`true`}):null,r]})}function RO({checksOpen:e,closeChecks:t,checksProps:n,chatAvailable:r,chatThread:i,chatProps:a,updateParams:o,sheetOpen:s,setSheetOpen:c,panelProps:l,threadSheet:u,threadProps:d,closeThread:f,selectedComment:p,targetTitle:m,draft:h,busy:g,setDraft:_,draftDescription:v,composerProps:y}){return(0,Y.jsxs)(Y.Fragment,{children:[e?(0,Y.jsx)(M,{open:!0,onClose:t,title:`Checks`,size:`md`,children:(0,Y.jsx)(`div`,{className:`flex h-[78dvh] min-h-0 flex-col`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`p`,{children:`Loading checks…`}),children:(0,Y.jsx)(kO,{...n})})})}):null,r?(0,Y.jsx)(M,{open:!!i,onClose:()=>o({chat:null}),title:`Agent`,size:`md`,children:(0,Y.jsx)(`div`,{className:`flex h-[78dvh] flex-col`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(V_,{heading:!1}),children:(0,Y.jsx)(AO,{...a,heading:!1})})})}):null,(0,Y.jsx)(M,{open:s&&!e,onClose:()=>c(!1),title:`Comments`,size:`md`,children:(0,Y.jsx)(`div`,{className:`flex max-h-[70dvh] flex-col`,children:(0,Y.jsx)(MC,{...l,heading:!1})})}),(0,Y.jsx)(M,{open:u&&!!d&&!e,onClose:f,title:p?`#${p.id} · ${m(p.pageId)}`:`Comment`,description:p?`${p.viewport} capture`:void 0,size:`md`,children:d?(0,Y.jsx)(`div`,{className:`flex max-h-[72dvh] flex-col outline-none`,tabIndex:-1,"data-autofocus":!0,"data-sw-thread-sheet":p.id,children:(0,Y.jsx)(Gw,{...d})}):null}),(0,Y.jsx)(M,{open:!!h&&!e,onClose:()=>g?null:_(null),title:`New comment`,description:v,children:(0,Y.jsx)(`div`,{className:`p-4`,children:(0,Y.jsx)(WC,{...y,touch:!0})})})]})}var zO=e=>String(e).replace(/\/w\/[^/#?]+.*$/,`/account`),BO=`flex h-8 w-full items-center gap-2 rounded-md px-2.5 text-left text-[13px] outline-none focus-visible:outline-2 focus-visible:outline-accent`;function VO({journeys:e=[],journeyId:t=null,onJourney:n,canEditJourneys:r=!1,onNewJourney:i=null,bare:a=!1}){let[o,s]=(0,J.useState)(``),c=e.length>8,l=c?o.trim().toLowerCase():``,u=l?e.filter(e=>String(e.name||e.id).toLowerCase().includes(l)):e,d=e=>K(BO,e?`bg-accent/10 text-fg`:`text-fg/90 hover:bg-surface-2`),f=e=>K(`shrink-0`,e?`text-accent`:`text-faint`);return(0,Y.jsxs)(`div`,{className:K(`flex w-full flex-col`,!a&&`border-t border-line pt-2`),"data-sw-journeys-sidebar":`true`,children:[a?null:(0,Y.jsxs)(`p`,{className:`flex items-center px-2.5 pb-1 text-xs font-semibold text-faint`,children:[`Journeys `,(0,Y.jsx)(`span`,{className:`ml-1 font-normal tabular`,children:e.length})]}),c?(0,Y.jsx)(`div`,{className:`pb-2`,children:(0,Y.jsx)(Ge,{size:`sm`,icon:n_,value:o,onChange:e=>s(e.target.value.slice(0,80)),placeholder:`Filter journeys`,"aria-label":`Filter journeys`,"data-sw-journeys-filter":`true`})}):null,(0,Y.jsxs)(`ul`,{className:`pb-2`,"aria-label":`Journeys`,children:[e.length&&!l?(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,className:d(!t),"aria-current":t?void 0:`true`,onClick:()=>n(null),"data-sw-pages-journey":`none`,children:[(0,Y.jsx)(Sh,{size:14,"aria-hidden":`true`,className:f(!t)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`None`}),(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:`Show all pages`})]})}):null,u.map(e=>{let r=e.id===t;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,className:d(r),"aria-current":r?`true`:void 0,onClick:()=>n(r?null:e.id),"data-sw-pages-journey":e.id,children:[(0,Y.jsx)(Qg,{size:14,"aria-hidden":`true`,className:f(r)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name||e.id}),(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-faint tabular`,children:XD(e)})]})},e.id)}),l&&!u.length?(0,Y.jsxs)(`li`,{className:`px-2.5 py-3 text-sm text-muted`,children:[`No journey matches "`,o.trim(),`".`]}):null,e.length?null:(0,Y.jsx)(`li`,{className:`px-2.5 py-2 text-xs text-muted`,children:`No journeys yet.`}),r&&i?(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,className:K(BO,`text-muted hover:bg-surface-2 hover:text-fg`),onClick:i,"data-sw-journeys-new":`true`,children:[(0,Y.jsx)(Hg,{size:14,"aria-hidden":`true`,className:`shrink-0`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`New journey`})]})}):null]})]})}function HO({groups:e,comments:t,activePage:n,onPage:r,bare:i=!1}){let[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(()=>new Set),l=a.trim().toLowerCase(),u=(0,J.useMemo)(()=>{let e=new Map;for(let n of t||[])n.status===`open`&&e.set(n.pageId,(e.get(n.pageId)||0)+1);return e},[t]),d=e.map(e=>({...e,pages:l?e.pages.filter(t=>`${t.title} ${t.path||``} ${e.group}`.toLowerCase().includes(l)):e.pages})).filter(e=>e.pages.length),f=e=>c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),p=e.reduce((e,t)=>e+t.pages.length,0);return(0,Y.jsxs)(`div`,{className:K(`flex w-full flex-col`,!i&&`border-t border-line pt-2`),"data-sw-pages-sidebar":`true`,children:[i?null:(0,Y.jsxs)(`p`,{className:`flex items-center px-2.5 pb-1 text-xs font-semibold text-faint`,children:[`Pages `,(0,Y.jsx)(`span`,{className:`ml-1 font-normal tabular`,children:p})]}),(0,Y.jsx)(`div`,{className:`pb-2`,children:(0,Y.jsx)(Ge,{size:`sm`,icon:n_,value:a,onChange:e=>o(e.target.value.slice(0,80)),placeholder:`Filter pages`,"aria-label":`Filter pages`,"data-sw-pages-filter":`true`})}),(0,Y.jsxs)(`div`,{className:`pb-2`,children:[d.map(e=>{let t=s.has(e.group)&&!l;return(0,Y.jsxs)(`section`,{className:`mb-1`,"data-sw-pages-group":e.group,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center gap-1 rounded-md px-2.5 text-xs font-semibold text-muted outline-none hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,"aria-expanded":!t,onClick:()=>f(e.group),children:[(0,Y.jsx)(H,{size:13,"aria-hidden":`true`,className:K(`transition-transform`,t&&`-rotate-90`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:e.group}),(0,Y.jsx)(`span`,{className:`ml-auto font-normal text-faint tabular`,children:e.pages.length})]}),t?null:(0,Y.jsx)(`ul`,{className:`ml-4`,children:e.pages.map((t,i)=>{let a=u.get(t.id)||0,o=t.id===n,s=i===e.pages.length-1;return(0,Y.jsx)(`li`,{className:K(`relative pl-3 before:pointer-events-none before:absolute before:top-0 before:left-0 before:h-4 before:w-2.5 before:rounded-bl-md before:border-b before:border-l`,o?`before:border-accent/60`:`before:border-line-strong/70`,!s&&`after:pointer-events-none after:absolute after:inset-y-0 after:left-0 after:border-l after:border-line-strong/70`),"data-sw-pages-wire":`true`,children:(0,Y.jsxs)(`button`,{type:`button`,className:K(`flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-[13px] outline-none focus-visible:outline-2 focus-visible:outline-accent`,o?`bg-accent/10 text-fg`:`text-fg/90 hover:bg-surface-2`),"aria-current":o?`true`:void 0,onClick:()=>r(t.id),"data-sw-pages-item":t.id,children:[(0,Y.jsx)(Eh,{size:14,"aria-hidden":`true`,className:K(`shrink-0`,o?`text-accent`:`text-faint`)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.title}),a?(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-muted tabular`,"aria-label":`${a} open`,children:a}):null]})},t.id)})})]},e.group)}),l&&!d.length?(0,Y.jsxs)(`p`,{className:`px-2.5 py-3 text-sm text-muted`,children:[`Nothing matches "`,a.trim(),`".`]}):null]})]})}var UO=`shapewall.sidebar.nav`,WO=[`pages`,`journeys`];function GO(){try{let e=window.localStorage.getItem(UO);return WO.includes(e)?e:`pages`}catch{return`pages`}}function KO({className:e=``}){return(0,Y.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-accent ${e}`,"aria-hidden":`true`,"data-sw-journey-dot":`true`})}function qO({groups:e,journeys:t=[],comments:n,activePage:r,journeyId:i,onPage:a,onJourney:o,canEditJourneys:s,onNewJourney:c}){let[l,u]=(0,J.useState)(GO),d=e.reduce((e,t)=>e+t.pages.length,0);if(!t.length&&!s)return(0,Y.jsx)(HO,{groups:e,comments:n,activePage:r,onPage:a});let f=e=>{u(e);try{window.localStorage.setItem(UO,e)}catch{}},p=`gap-1`;return(0,Y.jsxs)(ye,{value:l,onValueChange:f,className:`flex w-full flex-col border-t border-line pt-2`,"data-sw-sidebar-nav":l,children:[(0,Y.jsxs)(Ae,{"aria-label":`Pages and journeys`,className:`mb-2`,children:[(0,Y.jsxs)(Le,{value:`pages`,className:p,"data-sw-sidebar-tab":`pages`,children:[`Pages `,(0,Y.jsx)(`span`,{className:`font-normal text-faint tabular`,children:d})]}),(0,Y.jsxs)(Le,{value:`journeys`,className:p,"data-sw-sidebar-tab":`journeys`,children:[`Journeys `,(0,Y.jsx)(`span`,{className:`font-normal text-faint tabular`,children:t.length}),i?(0,Y.jsx)(KO,{className:`ml-0.5`}):null]})]}),(0,Y.jsx)(oe,{value:`pages`,tabIndex:-1,children:(0,Y.jsx)(HO,{bare:!0,groups:e,comments:n,activePage:r,onPage:a})}),(0,Y.jsx)(oe,{value:`journeys`,tabIndex:-1,children:(0,Y.jsx)(VO,{bare:!0,journeys:t,journeyId:i,onJourney:o,canEditJourneys:s,onNewJourney:c})})]})}function JO({info:e,localSettingsAvailable:t,setShareOpen:n}){let r=[{id:`board`,label:`Board`,icon:eg,href:`./`,active:!0}],i=e?.consoleUrl&&!e?.guest?e.consoleUrl:null;return i?(r.push({id:`workspace`,label:`Workspace`,icon:Jm,href:i}),r.push({id:`account`,label:`Account and security`,icon:M_,href:zO(i)})):t&&(r.push({id:`workspace`,label:`Workspace`,icon:Jm,href:`/console`}),r.push({id:`account`,label:`Account and security`,icon:M_,href:`/account`})),e?.shareEnabled&&r.push({id:`share`,label:`Share with your team`,icon:c_,onSelect:()=>n(!0)}),r}function YO({info:e,localName:t,onOpenBuzz:n,demo:r,localSettingsAvailable:i,settingsAvailable:a,openSettings:o,setShareOpen:s,expanded:c,onToggle:l,pages:u,quiet:d=!1}){let f=!!e&&!e.guest&&!e.public&&!e.share,p=typeof window>`u`?null:new URLSearchParams(window.location.search).get(`board`);(0,J.useEffect)(()=>{f&&OD(window.location.pathname+(p?`?board=`+encodeURIComponent(p):``))},[f,p]);let m=JO({info:e,localSettingsAvailable:i,setShareOpen:s}),h=!!u&&(u.journeys?.length>0||u.canEditJourneys),g=(e,t)=>n=>{e(),t?.(n)},_=!c&&u?[{id:`pages`,label:`Pages`,icon:Oh,flyout:({close:e})=>(0,Y.jsx)(HO,{groups:u.groups,comments:u.comments,activePage:u.activePage,onPage:g(e,u.onPage)})},...h?[{id:`journeys`,label:`Journeys`,icon:Qg,dot:!!u.journeyId,"data-sw-rail-journeys":u.journeyId||`none`,flyout:({close:e})=>(0,Y.jsx)(VO,{journeys:u.journeys,journeyId:u.journeyId,onJourney:g(e,u.onJourney),canEditJourneys:u.canEditJourneys,onNewJourney:u.onNewJourney?()=>g(e,u.onNewJourney)():null})}]:[]]:[];return(0,Y.jsx)(WD,{expanded:c,onToggle:l,home:`./`,homeLabel:`Shapewall`,title:e?.project?.name||e?.title,logo:(0,Y.jsx)(`img`,{src:`./favicon.svg`,alt:``,className:`h-7 w-7`}),items:m,sections:_,flyoutsDisabled:d,profile:c=>(0,Y.jsx)(oO,{info:e,localName:t,onOpenBuzz:n,demo:r,localSettingsAvailable:i,settingsAvailable:a,openSettings:o,setShareOpen:s,side:`right`,align:`end`,showName:c,triggerClassName:c?`w-full justify-start`:`w-10 min-w-10 px-0`}),children:u?(0,Y.jsx)(qO,{...u}):null})}var XO=(0,J.lazy)(()=>xT(()=>import(`./QuickConnect-B-4pUgXH.js`).then(e=>e.a).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([7,1,5,2]),import.meta.url)),ZO=(0,J.lazy)(()=>xT(()=>import(`./History-CQG3NQOC.js`),__vite__mapDeps([8,1]),import.meta.url)),QO=(0,J.lazy)(()=>xT(()=>import(`./ShareDialog-BouvNraR.js`).then(e=>({default:e.ShareDialog})),__vite__mapDeps([9,1]),import.meta.url)),$O=(0,J.lazy)(()=>xT(()=>import(`./LocalSettings-CSNMhNyV.js`),__vite__mapDeps([10,1,7,5,2]),import.meta.url));function ek({info:e,boardId:t,boards:n,wide:i,shareOpen:a,setShareOpen:o,refetchView:s,settingsAvailable:l,settingsOpen:u,updateParams:d,onInfoChanged:f,generalSettingsOpen:p,updates:m,historyPage:h,closeHistory:g,historyViewport:_,historyPageId:v,data:y,comments:b,filter:x,focusComment:S,onImageError:C,captureConfirm:w,setCaptureConfirm:T,busy:E,focusedPage:D,findPage:O,startCapture:k}){let A=ge(a),j=ge(u);return(0,Y.jsxs)(Y.Fragment,{children:[e?.shareEnabled&&A?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(QO,{open:a,onClose:()=>o(!1),boardId:t,onMoved:s})}):null,l&&j?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(XO,{open:u,onClose:()=>d({settings:null}),onSaved:f,touch:!i,buzz:e?.buzzAvailable===!0})}):null,p?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)($O,{open:!0,onClose:()=>d({settings:null}),info:e,boardCount:n.length,onSaved:f,touch:!i,onOpenUpdates:()=>{d({settings:null}),m.current?.open()}})}):null,h?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(ZO,{open:!!h,onClose:g,page:h,viewport:_,data:y,comments:b.filter(e=>e.pageId===v&&e.viewport===_),urlFor:(e,n)=>c(t,e.kind,n?e.thumb:e.file,e.version),onPickComment:e=>{g(),d({filter:e.status===`resolved`&&x===`open`?`all`:null}),S(e)},touch:!i,onImageError:C})}):null,(0,Y.jsx)(M,{open:w,onClose:()=>E?null:T(!1),title:`Capture every page now?`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{size:i?`md`:`touch`,onClick:()=>T(!1),disabled:E,children:`Cancel`}),D&&O(D)?(0,Y.jsxs)(r,{size:i?`md`:`touch`,onClick:()=>k(null,[D]),disabled:E,"data-sw-capture-only":D,children:[`Only `,O(D).title]}):null,(0,Y.jsx)(r,{size:i?`md`:`touch`,variant:`default`,onClick:()=>k(),disabled:E,"data-sw-capture-confirm":`true`,children:`Capture all`})]}),children:(0,Y.jsxs)(`p`,{className:`p-5 text-sm text-muted`,children:[`Shapewall captures all `,y?.board?.pages.length||``,` pages at every viewport`,D&&O(D)?` (or only ${O(D).title}, the selected page)`:``,`. Comments stay where they are; pins on live pages follow their elements. The board updates when it finishes.`]})})]})}var tk=2;function nk(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function rk({canvasRef:e,flow:t,targets:n,viewports:r,settledZoom:i,setSettledZoom:a,comparePair:o,captures:s,variantsById:c}){let l=(0,J.useRef)(null),[u,d]=(0,J.useState)(()=>new Set),[f,p]=(0,J.useState)(()=>new Set),m=(0,J.useCallback)((e,t)=>{p(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),h=(0,J.useCallback)((e,t)=>o?null:e.startsWith(`variant:`)?c.get(e)?.files?.[t]?.live||null:s?.[e]?.[t]?.live||null,[o,s,c]),g=(0,J.useCallback)(()=>{let a=e.current?.getBoundingClientRect();if(!a?.width||!i){d(e=>e.size?new Set:e);return}let{x:o,y:s,zoom:c}=t.getViewport(),u=[];for(let[e,t]of Object.entries(n))for(let n of t.frames){if(!h(e,n.viewport))continue;let i=(t.x+n.x)*c+o,d=(t.y+n.y)*c+s,f=n.w*c,p=n.h*c;if(i>a.width||d>a.height||i+f<0||d+p<0)continue;let m=`${e}|${n.viewport}`,g=l.current===m,_=Math.min((r[n.viewport]?.width||1440)*.4,a.width*.5);f<(g?_/2:_)||u.push({key:m,rank:g?-1:Math.hypot(i+f/2-a.width/2,d+p/2-a.height/2)})}u.sort((e,t)=>e.rank-t.rank);let f=new Set(u.slice(0,tk).map(e=>e.key));l.current&&!f.has(l.current)&&(l.current=null),d(e=>nk(e,f)?e:f)},[e,t,n,h,i,r]);return(0,J.useEffect)(()=>{g()},[g]),{liveKeys:u,readyKeys:f,setLiveReady:m,liveFileFor:h,recomputeLive:g,openLive:(0,J.useCallback)((r,i)=>{let o=n[r],s=o?.frames.find(e=>e.viewport===i),c=e.current?.getBoundingClientRect();s&&c?.width&&(l.current=`${r}|${i}`,a(null),t.fitBounds({x:o.x+s.x,y:o.y+s.y,width:s.w,height:Math.min(s.h,s.w*(c.height/c.width))},{padding:.04,duration:kE(450)}))},[e,t,n,a])}}function ik({journey:e,builder:t,goStep:n,step:r,closeJourney:i}){(0,J.useEffect)(()=>{if(!e||t)return;let a=e=>{if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||document.querySelector(`[role="dialog"]`))return;let t=e.target;t?.isContentEditable||[`INPUT`,`TEXTAREA`,`SELECT`].includes(t?.tagName)||t?.closest?.(`[role="listbox"], [role="menu"]`)||((e.key===`ArrowRight`||e.key===`ArrowLeft`)&&(e.preventDefault(),n(r+(e.key===`ArrowRight`?1:-1))),e.key===`Escape`&&!document.querySelector(`[data-sw-thread-popover], [data-sw-composer-popover]`)&&(e.preventDefault(),i()))};return window.addEventListener(`keydown`,a),()=>window.removeEventListener(`keydown`,a)},[t,i,n,e,r])}function ak({commentMode:e,setCommentMode:t,canComment:n,comparePair:r,setDraft:i}){(0,J.useEffect)(()=>{if(!e)return;let n=e=>{e.key!==`Escape`||vS(e.target)||document.querySelector(`[role="dialog"], [role="menu"], [role="listbox"]`)||t(!1)};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t]),(0,J.useEffect)(()=>{if(!n||r)return;let e=e=>{if(e.defaultPrevented&&!Ue(e)||e.altKey||e.ctrlKey||e.metaKey||e.repeat||e.key!==`c`&&e.key!==`C`)return;let n=e.target;n?.isContentEditable||[`INPUT`,`TEXTAREA`,`SELECT`].includes(n?.tagName)||document.querySelector(`[role="dialog"]:not([data-sw-thread-popover]), [role="menu"], [role="listbox"]`)||(e.preventDefault(),i(null),t(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,r,t,i])}function ok({journeys:e,journey:t,builder:n,openJourney:r,closeJourney:i}){(0,J.useEffect)(()=>{if(!e.length||n)return;let a=n=>{if(n.defaultPrevented&&!Ue(n)||n.altKey||n.ctrlKey||n.metaKey||n.repeat||n.key!==`j`&&n.key!==`J`||vS(n.target)||document.querySelector(`[role="dialog"]:not([data-sw-thread-popover]), [role="menu"], [role="listbox"]`))return;n.preventDefault();let a=t?e.findIndex(e=>e.id===t.id):-1,o=e.length+1,s=(a+1+(n.shiftKey?-1:1)+o)%o-1;s<0?i():r(e[s].id)};return window.addEventListener(`keydown`,a),()=>window.removeEventListener(`keydown`,a)},[n,i,t,e,r])}function sk(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&Array.isArray(e.branches)}function ck(e){let t=new Set,n=e=>{for(let r of e||[])if(typeof r==`string`)t.add(r);else if(sk(r))for(let e of r.branches)n(e.steps)};return n(e),[...t]}function lk(e){let t=[],n=[],r=(e,i,a)=>{let o=a;return e.forEach((e,a)=>{let s=i?`${i}:${a}`:String(a);if(typeof e==`string`){t.push({key:s,pageId:e});for(let e of o)n.push({from:e.key,to:s,label:e.label||null,branch:e.branch||null});o=[{key:s}];return}if(!sk(e))return;let c=[];e.branches.forEach((e,t)=>{let n=o.map(t=>({key:t.key,label:e.label,branch:e.id})),i=r(e.steps,`${s}:${t}`,n);e.end||c.push(...i)}),o=c}),o};return r(e||[],``,[]),{nodes:t,edges:n}}function uk(e,t=[]){let n=[],r=[],i=!1,a=(e,o,s)=>{for(let c=0;c<e.length;c+=1){if(i)return;let l=e[c],u=o?`${o}:${c}`:String(c);if(typeof l==`string`){n.push({key:u,pageId:l,branch:s});continue}if(!sk(l)||!l.branches.length)continue;let d=t[r.length],f=Math.max(0,l.branches.findIndex(e=>e.id===d)),p=l.branches[f];r.push({afterStep:n.length,options:l.branches.map(e=>({id:e.id,label:e.label,end:!!e.end})),chosen:p.id}),a(p.steps,`${u}:${f}`,p.label),p.end&&(i=!0)}};return a(e||[],``,null),{steps:n,forks:r,ended:i}}function dk(e,t,n){return[...e.forks.slice(0,t).map(e=>e.chosen),n]}function fk({boardId:e,view:t,updateParams:n,clearFocus:r,setCommentMode:i,journey:a,route:o,routePages:s,step:c,builder:l,setBuilder:u,busy:d,setBusy:f,setNotice:p,flow:m,targets:h,nodesReady:g,mode:_,comparePair:v,setSettledZoom:y}){let b=(0,J.useCallback)(e=>{r(),n({j:e||null,step:e?1:null,jc:null,jb:null})},[r,n]),x=(0,J.useCallback)(()=>n({j:null,step:null,jc:null,jb:null}),[n]),S=(0,J.useCallback)(e=>{s&&n({step:J_(e,s.length)})},[s,n]),C=(0,J.useCallback)((e,t)=>{o&&n({jb:dk(o,e,t).join(`,`)})},[o,n]),w=(0,J.useRef)(null);(0,J.useEffect)(()=>{if(!a||!g||l){a||(w.current=null);return}let e=s[c-1],t=`${a.id}:${c}:${e}:${_}:${v}`;if(w.current===t)return;let n=h[e];n&&(w.current=t,y(null),m.fitBounds({x:n.x,y:n.y-48,width:n.w,height:n.h+48},{padding:.18,duration:kE(450)}))},[l,v,m,a,h,_,g,s,y,c]),ik({journey:a,builder:l,goStep:S,step:c,closeJourney:x});let T=(0,J.useCallback)((e=null)=>{i(!1),r(),u(e?{id:e.id,name:e.name,steps:structuredClone(e.steps),into:null}:{id:null,name:``,steps:[],into:null})},[r,u,i]),E=(0,J.useCallback)(e=>{u(t=>{if(!t||ck(t.steps).length>=50)return t;let n=structuredClone(t.steps),r=(t.into?n[t.into.fork]:null)?.branches?.[t.into.branch]?.steps||n;return r[r.length-1]===e?t:(r.push(e),{...t,steps:n})})},[u]),D=`/api/boards/${encodeURIComponent(e)}/journeys`;return{openJourney:b,closeJourney:x,goStep:S,chooseJourneyBranch:C,startBuilder:T,addBuilderStep:E,saveBuilder:async()=>{if(l&&!d){f(!0);try{let e={name:l.name,steps:l.steps},n=l.id?await Ke.patch(`${D}/${encodeURIComponent(l.id)}`,e):await Ke.post(D,e);await t.refetch(),u(null),w.current=null,b(n.journey.id)}catch(e){p({tone:`bad`,text:e.message||`The journey was not saved.`})}finally{f(!1)}}},removeJourney:async()=>{if(a&&!d){f(!0);try{await Ke.delete(`${D}/${encodeURIComponent(a.id)}`),x(),t.refetch()}catch(e){p({tone:`bad`,text:e.message||`The journey was not deleted.`})}finally{f(!1)}}}}}function pk({boardId:e,commentsQuery:t,view:n,info:r,localName:i,authorName:a,setBusy:o,setNotice:s,setToast:c,setDeletingIds:l,selectedCommentId:u,closeThread:d,wide:f,filter:p,allowed:m}){let h=(0,J.useRef)(new Map),g=(e,r=!1,{counts:i=!0}={})=>{t.setData(t=>{let n=Array.isArray(t?.comments)?t.comments:[];return r?{comments:n.filter(t=>t.id!==e.id)}:{comments:n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n]}}),i&&n.refetch()},_=`/api/boards/${encodeURIComponent(e)}/comments`,v=async(e,t)=>{o(!0);try{let n=await Ke.post(`${_}/${e.id}/${t}`,{author:a()||void 0});g(n.comment),f&&t===`resolve`&&p===`open`&&d(),t===`resolve`&&m(`resolve`)&&c({at:Date.now(),text:`Resolved comment #${e.id}.`,undo:()=>v(n.comment,`reopen`)})}catch(e){s({tone:`bad`,text:e.message||`That did not save.`})}finally{o(!1)}},y=async(e,t,n={})=>{let{onImageError:r,images:i,drawing:c}=n;o(!0);try{let n=await Ke.post(`${_}/${e.id}/replies`,{body:t,author:a()||void 0,...i?.length?{images:i}:{},...c?{drawing:c}:{}});return g(n.comment),!0}catch(e){return r&&/image/.test(e.code||``)?r(e.message||`An image was not accepted.`):s({tone:`bad`,text:e.message||`That reply did not save.`}),!1}finally{o(!1)}},b=async(e,t)=>{o(!0);try{let n=await Ke.patch(`${_}/${e.id}`,{body:t});return g(n.comment),!0}catch(e){return s({tone:`bad`,text:e.message||`That edit did not save.`}),!1}finally{o(!1)}},x=async(e,t,n=null)=>{try{let a=await Ke.post(`${_}/${e.id}/reactions`,{emoji:t,...n?{replyId:n}:{},...r?.hosted?{}:{author:i||void 0}});g(a.comment,!1,{counts:!1})}catch(e){s({tone:`bad`,text:e.message||`That reaction did not save.`})}},S=async e=>{let t=new URL(window.location.href);t.searchParams.set(`c`,String(e.id)),t.searchParams.delete(`v`);try{await navigator.clipboard.writeText(t.href),s({tone:`info`,text:`Copied the link to comment #${e.id}.`})}catch{s({tone:`info`,text:`Link to comment #${e.id}: ${t.href}`})}},C=async e=>{o(!0);try{let t=await Ke.post(`${_}/${e.id}/github/issue`,{});g(t.comment),s({tone:`info`,text:`${t.created?`Opened`:`Already has`} GitHub issue #${t.issue.number}.`})}catch(e){s({tone:`bad`,text:e.message||`The GitHub issue was not created.`})}finally{o(!1)}},w=e=>{h.current.delete(e),l(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},T=async e=>{let t=h.current.get(e.id);if(t){window.clearTimeout(t.timer);try{await Ke.delete(`${_}/${e.id}`),g(e,!0)}catch(e){s({tone:`bad`,text:e.message||`That did not delete.`})}finally{w(e.id)}}},E=(0,J.useRef)(T);return E.current=T,(0,J.useEffect)(()=>{let e=()=>{for(let{comment:e}of[...h.current.values()])E.current(e)};return window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`pagehide`,e),e()}},[]),{commentsUrl:_,applyComment:g,setStatus:v,replyTo:y,editComment:b,reactTo:x,copyLink:S,githubIssue:C,removeComment:async e=>{u===e.id&&d(),l(t=>new Set(t).add(e.id));let t=window.setTimeout(()=>E.current(e),6e3);h.current.set(e.id,{comment:e,timer:t}),c({at:Date.now(),text:`Deleted comment #${e.id}.`,undo:()=>{window.clearTimeout(t),w(e.id)}})},sendToAgent:async e=>{let{dispatchHash:n}=e,i=!!(e.needsRunApproval&&[`admin`,`owner`].includes(r.role));o(!0);try{i&&await zT();let t=await Ke.post(`${_}/${e.id}/send-to-agent`,{dispatchHash:n,approve:i});g(t.comment)}catch(e){e.code===`comment_changed`?(t.refetch(),s({tone:`bad`,text:`This comment changed while you were approving it. Read it again, then send it.`})):s({tone:`bad`,text:e.message})}finally{o(!1)}}}}function mk(e){let[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(!1),[a,s]=(0,J.useState)(()=>new Set),c=Xe(`/api/boards/${encodeURIComponent(e)}`,{pollMs:r||t?2e3:o?0:3e4}),l=Xe(`/api/boards/${encodeURIComponent(e)}/comments`,{pollMs:o?0:t?1e3:2e4}),u=c.data,d=u?.capture;return(0,J.useEffect)(()=>{i(!!d?.running)},[d?.running]),{view:c,commentsQuery:l,data:u,capture:d,comments:(0,J.useMemo)(()=>{let e=Array.isArray(l.data?.comments)?l.data.comments:[];return a.size?e.filter(e=>!a.has(e.id)):e},[l.data,a]),fixRequest:t,setFixRequest:n,setPolling:i,deletingIds:a,setDeletingIds:s}}function hk({params:e,data:t,builder:n}){let r=(0,J.useMemo)(()=>Array.isArray(t?.journeys)?t.journeys:[],[t?.journeys]),i=n?null:r.find(t=>t.id===e.get(`j`))||null,a=e.get(`jb`)||``,o=(0,J.useMemo)(()=>i?uk(i.steps,a.split(`,`).filter(Boolean)):null,[i,a]),s=(0,J.useMemo)(()=>i?lk(i.steps):null,[i]),c=(0,J.useMemo)(()=>o?o.steps.map(e=>e.pageId):null,[o]);return{journeys:r,journey:i,route:o,routeGraph:s,routePages:c,step:J_(e.get(`step`),c?.length||0),journeyComments:!!i&&e.get(`jc`)===`1`}}var gk=40;function _k({pendingFocus:e,setPendingFocus:t,targets:n,viewports:r,flow:i,canvasRef:a,wide:o,setSettledZoom:s}){(0,J.useEffect)(()=>{if(!e)return;let c=Bv(n,e);if(!c){n[e.pageId]&&r[e.viewport]||t(null);return}t(null),s(null);let l=Math.max(i.getZoom(),1.2),u=a.current?.getBoundingClientRect(),d=n[e.pageId];if(o||!u?.width||!d){i.setCenter(c.x,c.y,{zoom:l,duration:kE(450)});return}let f=u.height*.28-c.y*l;d.y*l+f<gk&&(f=Math.min(gk-d.y*l,u.height*.45-c.y*l)),i.setViewport({x:u.width/2-c.x*l,y:f,zoom:l},{duration:kE(450)})},[a,i,n,e,t,s,r,o])}function vk({wide:e,nodesReady:t,initialCamera:n,selectedCommentId:r,canvasRef:i,nodes:a,flow:o,setSettledZoom:s}){let c=(0,J.useRef)(!1);(0,J.useEffect)(()=>{if(e||c.current||!t||(c.current=!0,n.current||r))return;let l=i.current?.getBoundingClientRect(),u=a.find(e=>e.type===`groupFrame`),d=u&&a.find(e=>e.type===`page`&&e.data?.page?.group===u.data.group);if(!l?.width||!u||!d){o.fitView(ME);return}let f=Math.min(u.width,d.width*2+72+2*(d.position.x-u.position.x)),p=Math.min(1.5,Math.max(.05,(l.width-16)/f)),m=12+44*Math.max(p,.45);s(null),o.setViewport({x:8-u.position.x*p,y:m-u.position.y*p,zoom:p})},[i,o,n,a,t,r,s,e])}function yk({mode:e,pendingFocus:t,shapeKey:n,clearFocus:r,fitBoard:i}){let a=(0,J.useRef)(e);(0,J.useEffect)(()=>{if(a.current===e||(a.current=e,r(),t))return;let n=window.setTimeout(i,60);return()=>window.clearTimeout(n)},[r,i,e,t]);let o=(0,J.useRef)(n);(0,J.useEffect)(()=>{if(o.current===n)return;o.current=n,r();let e=window.setTimeout(i,60);return()=>window.clearTimeout(e)},[r,i,n])}function bk({nodesReady:e,data:t,commentsLoaded:n,selectedCommentId:r,selectedComment:i,initialCamera:a,focusComment:o,deletingIds:s,setNotice:c,updateParams:l}){let u=(0,J.useRef)(!1);(0,J.useEffect)(()=>{!u.current&&e&&t&&(!r||n)&&(u.current=!0,i&&!a.current&&o(i))},[n,t,o,a,e,i,r]);let d=(0,J.useRef)(null);(0,J.useEffect)(()=>{r&&n&&!i&&!s.has(r)&&d.current!==r&&(d.current=r,c({tone:`bad`,text:`Comment #${r} was not found on this board. It may have been deleted.`}),l({c:null}))},[n,s,i,r,c,l])}function xk({selectedComment:e,visibleComments:t,focusComment:n,mode:r,viewports:i,modes:a}){let o=(0,J.useMemo)(()=>e&&!t.some(t=>t.id===e.id)?[e,...t]:t,[e,t]),s=e?o.findIndex(t=>t.id===e.id):-1;return{threadList:o,threadIndex:s,stepThread:e=>{o.length<2||s<0||n(o[(s+e+o.length)%o.length])},neighborNote:e=>{if(o.length<2||s<0||r===`all`)return null;let t=o[(s+e+o.length)%o.length];return t.viewport===r||!i[t.viewport]?null:`switches to ${a.find(e=>e.id===t.viewport)?.label||t.viewport}`}}}var Sk=[`issues`,`pages`,`seo`,`performance`,`history`],Ck=e=>Sk.includes(e)&&e!==`issues`?e:null;function wk({boardId:e,info:t,params:n,updateParams:r,pages:i}){let a=!!t?.checksAvailable,s=a&&!!n.get(`checks`),c=i?.some(e=>e.id===n.get(`checks`))?n.get(`checks`):null,l=n.get(`cv`)||null,u=Sk.includes(n.get(`ct`))?n.get(`ct`):`issues`,d=/^[a-z0-9][a-z0-9-]{0,63}$/.test(n.get(`ce`)||``)?n.get(`ce`):null,f=`/api/boards/${encodeURIComponent(e)}/checks`,p=d?`?env=${encodeURIComponent(d)}`:``,m=Xe(a?`${f}${p}`:null,{pollMs:o?0:3e4}),h=Xe(a&&s&&!o?`${f}/seo${p}`:null),g=a&&!o&&!t?.hosted,[_,v]=(0,J.useState)(!1),y=Xe(g&&s?`${f}/run`:null,{pollMs:_?1500:0}),b=y.data?.run||null,x=b?.state===`running`;(0,J.useEffect)(()=>v(x),[x]);let S=(0,J.useRef)(!1),{refetch:C}=m,{refetch:w}=h;(0,J.useEffect)(()=>{S.current&&!x&&(C(),w()),S.current=x},[x,C,w]);let[T,E]=(0,J.useState)(null),[D,O]=(0,J.useState)(!1),k=(0,J.useCallback)(async({pages:e=null,seo:t=!0}={})=>{O(!0),E(null);try{return await Ke.post(`${f}/run`,{seo:t,...e?{pages:e}:{},...d?{env:d}:{}}),v(!0),await y.refetch(),!0}catch(e){return E(e.message||`The checks run did not start.`),y.refetch(),!1}finally{O(!1)}},[f,d,y]),[A,j]=(0,J.useState)(!1),M=(0,J.useCallback)(async()=>{j(!0),E(null);try{await Ke.delete(`${f}/run`)}catch(e){E(e.message||`The checks run could not be stopped.`)}finally{j(!1),y.refetch()}},[f,y]),N=(0,J.useCallback)((e=null,t=null,n=null)=>r({checks:e||`all`,cv:t,chat:null,...n?{ct:Ck(n)}:{}}),[r]),P=(0,J.useCallback)(e=>r({ct:Ck(e)}),[r]),F=(0,J.useCallback)(()=>r({checks:null,cv:null,ct:null}),[r]),ee=(0,J.useMemo)(()=>{let e=new Map;for(let t of m.data?.views||[]){if([`stale`,`failed`].includes(t.state))continue;let n=t.runs?.reduce((e,t)=>e+(t.state===`stale`?0:t.actionable),0)??t.actionable;e.set(t.pageId,(e.get(t.pageId)||0)+n)}return e},[m.data]),I=g?{loading:y.loading,canRun:!!y.data?.canRun,reason:y.data?.reason||null,limit:y.data?.limit||100,privatePages:y.data?.privatePages||[],seoDefault:y.data?.seoDefault!==!1,run:b,starting:D,error:T,start:k,stop:M,stopping:A}:null,L=[`shapewall checks run`,`--board ${e}`,c?`--only ${c}`:null,d?`--env ${d}`:null,u===`seo`?`--seo`:null,`--limit 100`].filter(Boolean).join(` `);return{canChecks:a,checksOpen:s,checksPage:c,checksViewport:l,checksEnvironment:d,checksTab:u,setChecksTab:P,checksQuery:m,seoQuery:h,checksRun:I,checksPanelProps:{tab:u,onTab:P,seo:h.error?null:h.data,run:I,command:L},openChecks:N,closeChecks:F,checksCounts:ee}}function Tk({boardId:e,info:t,params:n,updateParams:r}){let i=!o&&!!t?.agent&&!(t?.remote?.noRemoteChat&&t?.remote?.kind!==`host`),a=n.get(`chat`)||``,s=i?ww(a):null,c=!!(t?.agent?.settingsEditable||t?.agent?.settingsReadonly),l=!o&&!E&&!t?.consoleUrl&&!t?.workspace&&!t?.hosted&&!t?.guest,u=l&&n.get(`settings`)===`general`,d=c&&n.get(`settings`)===`agent`,f=(0,J.useCallback)(()=>r({settings:`agent`}),[r]);return(0,J.useEffect)(()=>{s&&Dw(e,Cw(s))},[e,s]),{chatAvailable:i,chatThread:s,reopenChat:(0,J.useCallback)(()=>r({chat:Ow(e),checks:null,cv:null}),[e,r]),settingsAvailable:c,localSettingsAvailable:l,generalSettingsOpen:u,settingsOpen:d,openSettings:f,openChat:(0,J.useCallback)(e=>{r({chat:Cw(e),checks:null,cv:null})},[r])}}function Ek({boardId:e,params:t,updateParams:n,environmentList:r,setCommentMode:i,pageCount:a=0}){let o=(0,J.useMemo)(()=>Array.isArray(r)?r:[],[r]),s=(0,J.useMemo)(()=>{let[e,n]=String(t.get(`cmp`)||``).split(`_`),r=o.map(e=>e.id);return e&&n&&e!==n&&r.includes(e)&&r.includes(n)?[e,n]:null},[t.get(`cmp`),o]),c=t.get(`changed`),l=a>=30,u=!!s&&(c===`1`||c!==`0`&&l),d=e=>n({changed:e===l?null:e?`1`:`0`}),f=t.get(`diff`)!==`off`,p=Xe(s?`/api/boards/${encodeURIComponent(e)}/compare?a=${s[0]}&b=${s[1]}`:null),m=s&&p.data?.a===s[0]&&p.data?.b===s[1]?p.data:null,h=(0,J.useMemo)(()=>{if(!s)return null;let[e,t]=s,n=new Map(o.map(e=>[e.id,e])),r=o.find(e=>e.default)?.id;return{a:e,b:t,files:m?.files||{},failures:m?.failures||{},pages:m?.pages||{},showDiff:f,kindOf:e=>e===r?`captures`:`envs/${e}`,versionOf:e=>n.get(e)?.capturedAt||`none`,titleOf:e=>n.get(e)?.title||e,diffKind:`diffs/${e}_${t}`,diffVersion:`${n.get(e)?.capturedAt}|${n.get(t)?.capturedAt}`}},[m,s,o,f]),g=e=>{i(!1),n({cmp:e?e.join(`_`):null,changed:e?t.get(`changed`):null,diff:e?t.get(`diff`):null})};return{environments:o,comparePair:s,changedOnly:u,setChangedOnly:d,showDiff:f,compareQuery:p,compareData:m,compareView:h,setCompare:g,canCompare:o.length>1,toggleCompare:()=>g(s?null:[o[0].id,o[1].id])}}function Dk({comments:e,query:t,stateFilter:n,mentionFilter:r,titleOfPage:i,filter:a,journey:o,journeyComments:s}){let c=(0,J.useMemo)(()=>sv(e,{query:t,state:n,mention:r,titleOf:i}),[e,r,t,n,i]),l=(0,J.useMemo)(()=>{let e=s?new Set(o.pages||ck(o.steps)):null;return c.filter(t=>(a===`all`||t.status===a)&&(!e||e.has(t.pageId)))},[c,a,o,s]);return{narrowedComments:c,visibleComments:l,pinsByTarget:(0,J.useMemo)(()=>{let e=new Map;for(let t of l){let n=`${t.pageId}|${t.viewport}`;e.has(n)||e.set(n,[]),e.get(n).push(t)}return e},[l]),counts:{open:c.filter(e=>e.status===`open`).length,resolved:c.filter(e=>e.status===`resolved`).length}}}function Ok({targets:e,layoutEdges:t,links:n,showLinks:r,showAllLinks:i,activePage:a,builder:o,route:s,routeGraph:c,routePages:l,step:u,journey:d,targetTitle:f}){let p=(0,J.useMemo)(()=>new Set(Object.keys(e).filter(e=>!e.startsWith(`variant:`))),[e]),m=(0,J.useMemo)(()=>o?uk(o.steps).steps.map(e=>e.pageId):null,[o]),h=o?m:l,g=(0,J.useMemo)(()=>r&&!i?K_(n,p):null,[n,p,i,r]),_=(0,J.useMemo)(()=>o||!s?null:{graph:c,path:s.steps.map(e=>e.key)},[o,s,c]),v=(0,J.useMemo)(()=>[...t,...q_({links:n||{},showLinks:r,activePage:a,journeySteps:o?m:null,journeyRoute:_,currentStep:o?0:u,present:p,hideTargets:g}).map(e=>({...e,ariaLabel:e.id.startsWith(`link:`)?`Link from ${f(e.source)} to ${f(e.target)}`:`Journey${e.data?.label?` step ${e.data.label}`:``}: ${f(e.source)} to ${f(e.target)}`}))],[a,o,m,n,g,_,t,p,r,u,f]),y=(0,J.useMemo)(()=>{if(o||!d||!l)return null;let e=new Set(l);return new Set((d.pages||ck(d.steps)).filter(t=>!e.has(t)))},[o,d,l]);return{presentPages:p,shownSteps:h,hiddenLinkTargets:g,edges:v,journeyView:(0,J.useMemo)(()=>h?{steps:W_(h),offPath:y,currentStep:o?null:u,currentPage:o?null:h[u-1]}:null,[o,y,h,u])}}var kk=[];function Ak(e){let t=(0,J.useRef)(e);t.current=e;let{boardId:n,data:r,viewports:i,journeyView:a,compareView:s,commentMode:l,canComment:d,wide:f,hosted:p,imageVersion:m,pinsByTarget:h,me:g,checksCounts:_,canChecks:v,agentFocus:y,agentWorkingPages:b,setLiveReady:x,focusedKey:S,selectingKey:C,settledZoom:w,selectedComment:T,draftSpot:D,unread:O,liveKeys:k}=e,[A]=(0,J.useState)(()=>wb({focusedKey:S,selectingKey:C,settledZoom:w,selectedComment:T,draftSpot:D,unread:O,liveKeys:k}));(0,J.useLayoutEffect)(()=>{A.set({focusedKey:S,selectingKey:C,settledZoom:w,selectedComment:T,draftSpot:D,unread:O,liveKeys:k})},[A,S,C,w,T,D,O,k]);let j=(0,J.useMemo)(()=>{let e=()=>t.current;return{onFocusFrame:(t,n)=>{let{selectedCommentId:r,closeThread:i,builder:a,addBuilderStep:o,layout:s,flow:c,setSettledZoom:l,canvasRef:u,setFocusedKey:d}=e();if(r&&i(),a){t.startsWith(`variant:`)||o(t);return}let f=s.targets[t],p=f?.frames.find(e=>e.viewport===n);f&&p&&Av(p,c.getZoom())&&(l(null),c.fitBounds(NE({x:f.x+p.x,y:f.y,width:p.w,height:p.y+p.h},u.current?.getBoundingClientRect(),.08),{padding:.08,duration:kE(450)})),d(`${t}|${n}`)},onPin:t=>{let n=e(),{layout:r,flow:i,canvasRef:a}=n;n.selectedCommentId&&n.closeThread();let o=r.targets[t.pageId],s=o?.frames.find(e=>e.viewport===t.viewport),c=a.current?.getBoundingClientRect();if(!n.wide&&s&&c?.width&&s.w*i.getZoom()<c.width*.6){n.setSettledZoom(null);let e=Math.min(4,(c.width-16)/s.w),r=o.y+s.y+s.h*t.y/100;i.setViewport({x:8-(o.x+s.x)*e,y:c.height*.35-r*e,zoom:e},{duration:kE(450)}),n.setToast({at:Date.now(),text:`Zoomed in: tap the spot again to pin your comment.`,untilSheet:!0})}else n.setDraft(e=>({...t,body:e?.body||n.checkDraft||``,author:e?.author??n.authorName()})),n.setCheckDraft(``)},onSelectComment:t=>e().selectComment(t),onHoverComment:e=>A.set({hoveredId:e}),onOpenCluster:(t,n,r)=>e().openCluster(t,n,r),onChecks:(...t)=>e().openChecks(...t),onHistory:(t,n=null)=>e().openHistory(t,n),onShowViewport:t=>e().updateParams({vp:t===e().defaultMode?null:t}),onImageError:()=>e().onImageError()}},[A]);return{board:(0,J.useMemo)(()=>({boardId:n,captures:r?.captures||{},manifest:r?.manifest||null,counts:r?.commentCounts||{},viewports:i,journey:a,compare:s,commentMode:l&&d&&!s,touch:!f,imageUrl:(e,t,r)=>c(n,e,t,r||m),liveUrl:(e,t,r)=>we(n,e,t,r||m),elementsUrl:(e,t,r)=>u(n,e,t,r||m),domFallback:!o&&!E&&!p,setLiveReady:x,pinsFor:(e,t)=>s?kk:h.get(`${e}|${t}`)||kk,me:g,checksCount:e=>_.get(e)||0,historyCount:e=>iv(r?.versions,e),agentWorking:y,agentWorkingPages:b,onFocusFrame:j.onFocusFrame,onPin:j.onPin,onSelectComment:j.onSelectComment,onHoverComment:f?j.onHoverComment:null,onOpenCluster:j.onOpenCluster,onChecks:v?j.onChecks:null,onHistory:j.onHistory,onShowViewport:j.onShowViewport,onImageError:j.onImageError}),[j,y,b,n,v,d,_,l,s,r?.captures,r?.commentCounts,r?.manifest,r?.versions,p,m,a,g,h,x,i,f]),view:A}}function jk({boardId:e,view:t,setBusy:n,setNotice:r,setPolling:i}){let[a,o]=(0,J.useState)(!1);return{captureConfirm:a,setCaptureConfirm:o,startCapture:async(a=null,s=null)=>{n(!0);try{r({tone:`info`,text:(await Ke.post(`/api/boards/${encodeURIComponent(e)}/capture`,{...a?{env:a}:{},...s?{pages:s}:{}})).message||`Capture started.`}),i(!0),t.refetch()}catch(e){r({tone:`bad`,text:e.message||`The capture did not start.`})}finally{n(!1),o(!1)}}}}function Mk({draft:e,setDraft:t,busy:n,setBusy:r,commentsUrl:i,applyComment:a,markSeen:o,setLocalName:s,setNotice:c,updateParams:l,wide:u,filter:d,targetTitle:f,people:p,info:m,media:h={attach:!1,draw:!1,attachNote:null},pageImage:g=()=>null}){let _=Jb({enabled:h.attach}),v=e?`${e.pageId}|${e.viewport}`:null;(0,J.useEffect)(()=>{!v||!h.draw?sx.end(`composer`):sx.get()?.owner===`composer`?sx.moveTo(v,`composer`):sx.start(v,`composer`)},[v,h.draw]);let{clear:y}=_;return(0,J.useEffect)(()=>{e||y()},[e,y]),(0,J.useEffect)(()=>()=>sx.end(`composer`),[]),{draftDescription:e?`${f(e.pageId)} · ${e.viewport} · ${e.anchor?`on "${e.anchor.text||e.anchor.selector.split(` > `).pop()}"`:`${Math.round(e.x)}% across, ${Math.round(e.y)}% down`}`:``,composerProps:{draft:e,onChange:e=>t(t=>t&&{...t,...e}),onSubmit:async()=>{if(!(!e?.body.trim()||n||_.reading)){r(!0);try{let n=(e.author||``).trim();He(n);let r=sx.get(),c=r?.owner===`composer`&&r.key===v?r.shapes:[],f=qb(_.images),{comment:p}=await Ke.post(i,{pageId:e.pageId,viewport:e.viewport,x:e.x,y:e.y,body:e.body,author:n,...e.anchor?{anchor:e.anchor}:{},...f.length?{images:f}:{},...c.length?{drawing:lx(c)}:{}});sx.end(`composer`),t(null),s(n),a(p),o(p),l({c:u?p.id:null,filter:d===`all`?`all`:null})}catch(e){/image/.test(e.code||``)?_.setError(e.message||`An image was not accepted.`):c({tone:`bad`,text:e.message||`The comment was not saved.`})}finally{r(!1)}}},onCancel:()=>t(null),busy:n,people:p,hosted:!!m?.hosted,signedInAs:m?.user?.name||null,media:{...h,images:_,owner:`composer`,page:e&&h.draw?g(e.pageId,e.viewport):null,pageTitle:e?f(e.pageId):``}}}}function Nk({canComment:e,comparePair:t,commentMode:n,markPicked:r,setDraft:i,setCommentMode:a,showLinks:o,toggleLinks:s,canCompare:c,toggleCompare:l,wide:u,fitBoard:d,minimapOn:f,toggleMinimap:p,chatAvailable:m,reopenChat:h,canChecks:g,openChecks:_}){return[e&&!t?{id:`comment`,label:n?`Stop commenting`:`Comment on a page`,icon:Sg,keys:`C`,run:()=>{r(),i(null),a(e=>!e)}}:null,{id:`links`,label:o?`Hide links between pages`:`Show links between pages`,icon:I_,run:s},c?{id:`compare`,label:t?`Leave compare mode`:`Compare environments`,icon:Ph,run:l}:null,u?{id:`fit`,label:`Fit the whole board`,icon:bg,keys:`Shift 1`,run:d}:null,u?{id:`minimap`,label:f?`Hide the minimap`:`Show the minimap`,icon:vg,run:p}:null,m?{id:`agent`,label:`Chat with your agent`,icon:S,run:h}:null,g?{id:`checks`,label:`Open page checks`,icon:Ah,run:()=>_()}:null].filter(Boolean)}var Pk=30,Fk=28,Ik=240;function Lk(e){let t=1/e;return{"--sw-zoom":e.toFixed(4),"--sw-inv":t.toFixed(4),"--sw-title-scale":Math.min(t,96/Pk).toFixed(4),"--sw-title-fade":Math.max(0,Math.min(1,(e-.16)*25)).toFixed(3),"--sw-group-scale":Math.min(t,Ik/Fk).toFixed(4),"--sw-label-scale":Math.min(t,1.6).toFixed(4),"--sw-chip-scale":Math.min(t,1).toFixed(4)}}function Rk(){let e=Uu();return(0,J.useEffect)(()=>{let t=null,n=e=>{let n=e.transform[2],r=e.domNode;if(r&&n!==t){t=n;for(let[e,t]of Object.entries(Lk(n)))r.style.setProperty(e,t)}};return n(e.getState()),e.subscribe(n)},[e]),null}function zk({fitBoard:e,zoomTo:t}){let n=Vd();(0,J.useEffect)(()=>{let r=r=>{if(!(r.defaultPrevented||r.altKey||r.ctrlKey||r.metaKey||vS(r.target))&&!document.querySelector(`[role="dialog"], [role="menu"], [role="listbox"]`)){if(r.shiftKey&&r.code===`Digit1`)e();else if(r.shiftKey&&r.code===`Digit0`)t(1);else if(!r.shiftKey&&(r.key===`=`||r.key===`+`))n.zoomIn({duration:kE(200)});else if(!r.shiftKey&&r.key===`-`)n.zoomOut({duration:kE(200)});else return;r.preventDefault()}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,n,t])}function Bk({wide:e,clearFocus:n,setSettledZoom:r,minimapOn:i,liveKeys:o,toggleMinimap:s,hideFit:c,hideMinimap:l=!1,fitBoard:u}){let d=Vd(),f=$(e=>Math.round(e.transform[2]*100)),p=e=>{n(),r(null);let{x:t,y:i,zoom:a}=d.getViewport(),o=document.querySelector(`[data-sw-canvas]`)?.getBoundingClientRect(),s=(o?.width||0)/2,c=(o?.height||0)/2,l=e/a;d.setViewport({x:s-(s-t)*l,y:c-(c-i)*l,zoom:e},{duration:kE(250)})};if(zk({fitBoard:u,zoomTo:p}),!e)return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Rk,{}),(0,Y.jsx)($u,{position:`bottom-left`,className:K(`!m-2`,c&&`hidden`),children:(0,Y.jsx)(z,{size:`icon`,variant:`secondary`,className:`bg-surface/95 shadow-pop backdrop-blur`,onClick:u,label:`Fit the whole board`,"data-sw-fit":`true`,children:(0,Y.jsx)(bg,{size:17,"aria-hidden":`true`})})})]});let m=i&&!o.size&&!l,g=i&&o.size?`Minimap: hidden while a page is live`:i?`Hide the minimap`:`Show the minimap`,v=`h-8 w-8 rounded-md text-muted shadow-none hover:bg-surface-2 hover:text-fg`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Rk,{}),(0,Y.jsx)($u,{position:`bottom-left`,className:`!m-3`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-0.5 rounded-lg border border-line bg-surface/95 p-0.5 shadow-pop backdrop-blur`,role:`group`,"aria-label":`Zoom`,"data-sw-zoom-controls":`true`,children:[(0,Y.jsx)(z,{className:K(v,`react-flow__controls-zoomout`),onClick:()=>d.zoomOut({duration:kE(200)}),label:`Zoom out`,tooltip:(0,Y.jsx)(JD,{label:`Zoom out`,keys:[`-`]}),children:(0,Y.jsx)(Eg,{size:15,"aria-hidden":`true`})}),(0,Y.jsxs)(Ce,{children:[(0,Y.jsx)(h,{content:`Zoom level`,children:(0,Y.jsxs)(C,{className:`tabular h-8 min-w-12 rounded-md px-1.5 text-xs font-medium text-fg outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent`,"aria-label":`Zoom ${f}%`,"data-sw-zoom-level":f,children:[f,`%`]})}),(0,Y.jsxs)(t,{side:`top`,align:`start`,className:`min-w-52`,children:[(0,Y.jsxs)(T,{onSelect:()=>d.zoomIn({duration:kE(200)}),children:[`Zoom in `,(0,Y.jsx)(a,{className:`ml-auto`,children:`+`})]}),(0,Y.jsxs)(T,{onSelect:()=>d.zoomOut({duration:kE(200)}),children:[`Zoom out `,(0,Y.jsx)(a,{className:`ml-auto`,children:`-`})]}),(0,Y.jsx)(_,{}),(0,Y.jsx)(T,{onSelect:()=>p(.5),children:`Zoom to 50%`}),(0,Y.jsxs)(T,{onSelect:()=>p(1),children:[`Zoom to 100% `,(0,Y.jsx)(a,{className:`ml-auto`,children:`Shift 0`})]}),(0,Y.jsx)(T,{onSelect:()=>p(2),children:`Zoom to 200%`}),(0,Y.jsx)(_,{}),(0,Y.jsxs)(T,{onSelect:u,children:[`Fit the whole board `,(0,Y.jsx)(a,{className:`ml-auto`,children:`Shift 1`})]})]})]}),(0,Y.jsx)(z,{className:K(v,`react-flow__controls-zoomin`),onClick:()=>d.zoomIn({duration:kE(200)}),label:`Zoom in`,tooltip:(0,Y.jsx)(JD,{label:`Zoom in`,keys:[`+`]}),children:(0,Y.jsx)(Hg,{size:15,"aria-hidden":`true`})}),(0,Y.jsx)(`span`,{className:`mx-0.5 h-5 w-px bg-line`,"aria-hidden":`true`}),(0,Y.jsx)(z,{className:K(v,`react-flow__controls-fitview`),onClick:u,label:`Fit the whole board`,tooltip:(0,Y.jsx)(JD,{label:`Fit the whole board`,keys:[`Shift`,`1`]}),children:(0,Y.jsx)(bg,{size:14,"aria-hidden":`true`})}),(0,Y.jsx)(z,{className:K(v,i&&`text-accent hover:text-accent`),"aria-pressed":i,onClick:s,label:i?`Hide the minimap`:`Show the minimap`,tooltip:g,"data-sw-minimap-toggle":i?o.size?`auto-hidden`:`on`:`off`,children:(0,Y.jsx)(vg,{size:14,"aria-hidden":`true`})})]})}),m?(0,Y.jsx)(Fm,{pannable:!0,zoomable:!0,position:`bottom-right`,className:`!m-3 overflow-hidden !rounded-lg shadow-pop`,style:{width:168,height:104},bgColor:`color-mix(in srgb, var(--surface) 88%, transparent)`,maskColor:`color-mix(in srgb, var(--sunken) 55%, transparent)`,maskStrokeColor:`var(--accent)`,maskStrokeWidth:2,nodeBorderRadius:6,nodeColor:e=>e.type===`groupFrame`?`color-mix(in srgb, var(--fg) 5%, transparent)`:`color-mix(in srgb, var(--fg) 28%, transparent)`,nodeStrokeWidth:0,ariaLabel:`Minimap`,"data-sw-minimap":`true`}):null]})}function Vk(e,t,n=8){return t?e.left<t.right+n&&e.left+e.width>t.left-n&&e.top<t.bottom+n&&e.top+e.height>t.top-n:!1}function Hk(e,t){let n=null;for(let r of e||[]){if(!r||r.width<=0||r.height<=0)continue;let e=r.left-t.left,i=r.top-t.top,a=e+r.width,o=i+r.height;n=n?{left:Math.min(n.left,e),top:Math.min(n.top,i),right:Math.max(n.right,a),bottom:Math.max(n.bottom,o)}:{left:e,top:i,right:a,bottom:o}}return n}function Uk({card:e,canvas:t,bar:n,avoid:r=null,gap:i=8,zoom:a=1,toggleSize:o=44}){let{width:s,height:c}=t,l=r?r.bottom+i:i,u=e=>Math.max(i,Math.min(c-n.height-i,e)),d=(e,t=n)=>!Vk({...e,width:t.width,height:t.height},r,i),f=t=>{let r={left:t,top:u(e.top)};if(d(r))return r;let a={left:t,top:l};return a.top+n.height+i<=c?a:null},p=null;if(e.titleTop-n.height-i>=i){let t={left:Math.max(i,Math.min(e.right-n.width,s-n.width-i)),top:e.titleTop-n.height-i};d(t)&&(p=t)}!p&&e.right+i+n.width<=s-i&&(p=f(e.right+i)),!p&&e.left-i-n.width>=i&&(p=f(e.left-i-n.width));let m=e.titleTop>=i&&a>.2?{top:Math.max(i,e.titleTop-7),left:Math.max(i,Math.min(s-52,e.right-44-Math.min(140,(e.right-e.left)*.3)))}:{top:i,left:i};d(m,{width:o,height:o})||(m={...m,top:l});let h={left:i,top:d({left:i,top:i})?i:l};return{place:p,toggle:m,fallback:h}}var Wk=30;function Gk({focused:e,target:t,frame:n,title:i,hasLive:a,live:o,ready:s,selecting:c,touch:l,href:u,onOpenLive:d,onToggleSelect:f,onClose:p,history:m=0,onHistory:_=null,onChecks:v=null,onCapture:y=null,captureBusy:b=!1}){let x=$(e=>e.transform),S=$(e=>e.width),C=$(e=>e.height),w=$(e=>e.domNode),[T,E]=(0,J.useState)(null),D=T===e;(0,J.useEffect)(()=>{e||E(null)},[e]);let[O,k]=(0,J.useState)(null);if((0,J.useLayoutEffect)(()=>{let t=e&&w?w.closest(`[data-sw-canvas]`)?.querySelector(`[data-sw-canvas-notes]`):null,n=()=>{let e=t?Hk(Array.from(t.children).map(e=>e.getBoundingClientRect()),w.getBoundingClientRect()):null;k(t=>JSON.stringify(t)===JSON.stringify(e)?t:e)};if(n(),!t)return;let r=new MutationObserver(n);r.observe(t,{childList:!0,subtree:!0,characterData:!0});let i=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return i?.observe(t),()=>{r.disconnect(),i?.disconnect()}},[e,w,S,C]),!e||!t||!n)return null;let[A,j,M]=x,N=(t.x+n.x)*M+A,P=(t.y+n.y)*M+j,F=t.y*M+j-(M>.2?Wk:0),ee=N+n.w*M,I=P+n.h*M;if(ee<0||N>S||I<0||P>C||Av(n,M))return null;let L=l?54:40,R=(l?236:340)+(_?l?56:90:0)+(y?l?56:120:0)+(v?l?48:90:0),{place:B,toggle:V,fallback:H}=Uk({card:{left:N,top:P,right:ee,bottom:I,titleTop:F},canvas:{width:S,height:C},bar:{width:R,height:L},avoid:O,gap:8,zoom:M}),U=l?`touch`:`sm`,te=`text-fg shadow-none`,ne=l&&`text-[13px]`;if(!B&&!D)return(0,Y.jsx)(z,{size:`icon`,variant:`secondary`,style:V,className:`nodrag nopan absolute z-20 rounded-full bg-surface/95 text-fg shadow-pop`,onClick:t=>{t.stopPropagation(),E(e)},label:`${i} actions`,side:`bottom`,"data-sw-frame-bar-toggle":e,children:(0,Y.jsx)(vh,{size:18,"aria-hidden":`true`})});let re=B?{left:B.left,top:B.top,width:Math.min(R,S-16)}:{left:H.left,top:H.top,width:Math.min(R,S-16)};return(0,Y.jsxs)(`div`,{className:`nodrag nopan nowheel absolute z-20 flex items-center flex-wrap justify-end gap-1 rounded-lg border border-line bg-surface/95 p-1 shadow-pop backdrop-blur`,style:re,role:`toolbar`,"aria-label":`${i} actions`,"data-sw-frame-bar":e,onClick:e=>e.stopPropagation(),children:[l?null:(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate px-1.5 text-xs font-medium text-muted`,children:[i,` · `,n.viewport]}),a&&!o?(0,Y.jsxs)(r,{size:U,variant:`default`,className:K(`shadow-none`,ne),onClick:d,"data-sw-open-live":e,children:[(0,Y.jsx)(Og,{size:15,"aria-hidden":`true`}),` Open live`]}):null,o?(0,Y.jsxs)(r,{size:U,variant:c?`default`:`ghost`,className:K(`shadow-none`,ne,!c&&`text-fg`),"aria-pressed":c,disabled:!s,onClick:f,"data-sw-select-text":e,children:[(0,Y.jsx)(g_,{size:15,"aria-hidden":`true`}),` `,c?`Done`:`Select text`]}):null,v?(0,Y.jsxs)(r,{size:U,variant:`ghost`,className:te,onClick:v,"aria-label":`Page checks`,"data-sw-frame-checks":e,children:[(0,Y.jsx)(Ah,{size:15,"aria-hidden":`true`}),l?null:`Checks`]}):null,_?(0,Y.jsx)(h,{content:`Page history: ${m+1} captures`,children:(0,Y.jsxs)(r,{size:U,variant:`ghost`,className:te,onClick:_,"aria-label":`Page history: ${m+1} captures`,"data-sw-frame-history":e,children:[(0,Y.jsx)(Kg,{size:15,"aria-hidden":`true`}),` `,l?null:`History`]})}):null,y?(0,Y.jsx)(h,{content:`Recapture this page at every screen size`,children:(0,Y.jsxs)(r,{size:U,variant:`ghost`,className:te,disabled:b,onClick:y,"aria-label":`Capture this page`,"data-sw-frame-capture":e,children:[(0,Y.jsx)(Xm,{size:15,"aria-hidden":`true`}),` `,l?null:`Capture`]})}):null,u?(0,Y.jsx)(z,{asChild:!0,size:l?`icon`:`icon-sm`,className:te,label:`Open the page in a new tab`,children:(0,Y.jsx)(`a`,{href:u,target:`_blank`,rel:`noreferrer`,children:(0,Y.jsx)(bh,{size:15,"aria-hidden":`true`})})}):null,(0,Y.jsx)(z,{size:l?`icon`:`icon-sm`,onClick:B?p:()=>E(null),label:B?`Close`:`Collapse`,"data-sw-frame-bar-close":`true`,children:(0,Y.jsx)(g,{size:15,"aria-hidden":`true`})})]})}function Kk({onChecks:e,onHistory:t,historyCountFor:n,focusedKey:r,layout:i,data:a,liveKeys:o,readyKeys:s,selectingKey:c,touch:l,liveFileFor:u,onOpenLive:d,onToggleSelect:f,onClose:p,onCapture:m,captureBusy:h}){if(!r)return null;let g=r.lastIndexOf(`|`),_=r.slice(0,g),v=r.slice(g+1),y=i.targets[_],b=y?.frames.find(e=>e.viewport===v);if(!b)return null;let x=_.startsWith(`variant:`)?a?.variants?.find(e=>`variant:${e.id}`===_):null,S=x?null:a?.board?.pages.find(e=>e.id===_);return(0,Y.jsx)(Gk,{focused:r,target:y,frame:b,title:x?x.title:S?.title||_,hasLive:!!u(_,v),live:o.has(r),ready:s.has(r),selecting:c===r,touch:l,href:S?.url||(x?.source&&/^https?:/.test(x.source)?x.source:null),onOpenLive:()=>d(_,v),onToggleSelect:()=>f(r),onClose:p,history:S&&a?.versions?.[S.id]?.[v]?.length||0,onChecks:S&&e?()=>e(S.id,v):null,onHistory:S&&n(S.id)?()=>t(S.id,v):null,onCapture:S&&m?()=>m(S.id):null,captureBusy:h})}var qk=(0,J.lazy)(()=>xT(()=>import(`./ShareDialog-BouvNraR.js`).then(e=>({default:e.MigrationBanner})),__vite__mapDeps([9,1]),import.meta.url)),Jk=()=>{},Yk=new Set;function Xk(e,t){let n=new Map;for(let r of e||[])n.has(t(r))||n.set(t(r),r);return n}function Zk({boardId:e,boards:t,info:n,onPickBoard:r,onInfoChanged:i,onOpenBuzz:a}){let s=ve(`(min-width: 1024px)`),l=ve(`(max-width: 640px)`),u=Vd(),d=j(),p=vE(),[m,h]=We(),[g,_]=(0,J.useState)(!1),v=!n?.readOnly&&(!o||F),y=v&&!o&&!n?.hosted,b=v&&n?.allowCapture,x=e=>n?.permissions?.[e]!==!1,{view:S,commentsQuery:C,data:w,capture:T,comments:D,fixRequest:O,setFixRequest:k,setPolling:A,deletingIds:M,setDeletingIds:P}=mk(e),ee=Xe(n?.localProjectsEnabled?`/api/local-projects`:null,{pollMs:3e4}),I=ee.data?.projects||[],L=(0,J.useMemo)(()=>w?.viewports||{},[w?.viewports]),R=Object.keys(L),z=(0,J.useMemo)(()=>{let e=R.map(e=>({id:e,label:pv(e)}));return e.length>1&&e.push({id:`all`,label:e.length===2?`Both`:`All`}),e},[R.join(`,`)]),B=l&&R.includes(`phone`)?`phone`:R[0]||`desktop`,V=z.some(e=>e.id===m.get(`vp`))?m.get(`vp`):B,H=OC.some(e=>e.id===m.get(`filter`))?m.get(`filter`):`open`,U=Number(m.get(`c`))||null,te=(m.get(`q`)||``).slice(0,120),ne=av.some(e=>e.id===m.get(`st`))?m.get(`st`):null,re=/^[a-z][\w.-]{0,39}$/.test(m.get(`m`)||``)?m.get(`m`):null,ie=m.get(`panel`)===`off`,{canChecks:ae,checksOpen:W,checksPage:oe,checksViewport:se,checksQuery:ce,openChecks:le,closeChecks:de,checksCounts:pe,checksPanelProps:me,checksRun:he}=wk({boardId:e,info:n,params:m,updateParams:h,pages:w?.board?.pages}),[ge,_e]=(0,J.useState)(``),{chatAvailable:ye,chatThread:be,settingsAvailable:xe,localSettingsAvailable:Se,generalSettingsOpen:Ce,settingsOpen:we,openSettings:Te,openChat:Ee,reopenChat:De}=Tk({boardId:e,info:n,params:m,updateParams:h}),Oe=(0,J.useRef)(null),ke=(0,J.useRef)(PE(m.get(`v`))),Ae=(0,J.useRef)(null),[je,Me]=(0,J.useState)(!1),[Ne,Pe]=(0,J.useState)(null),[q,Fe]=(0,J.useState)(!1),[Ie,Le]=(0,J.useState)(!1),Re=n?.localUser?.name||``,[ze,Be]=(0,J.useState)(()=>fe()),Ve=ze||Re,He=(0,J.useCallback)(()=>fe()||Re,[Re]),Ue=(0,J.useRef)(null),[Ge,Ke]=(0,J.useState)(!1),[qe,Je]=(0,J.useState)(null),[Ye,Ze,Qe]=TO(),[$e,et]=(0,J.useState)(()=>XE()),tt=$e??ZE(w?.board?.pages?.length||0),[nt,rt]=(0,J.useState)(!1),it=jS(e),at=it&&[`working`,`waiting`].includes(it.state)&&Number(it.commentId)||null,ot=(0,J.useMemo)(()=>at?new Set([at]):Yk,[at]),[st,ct]=(0,J.useState)(!1),[lt,ut]=(0,J.useState)(null),[dt,ft]=(0,J.useState)(null),[pt,mt]=(0,J.useState)(null),[ht,gt]=(0,J.useState)(null),[_t,vt]=(0,J.useState)(()=>!$E()),[yt,bt]=xE(!!d),[xt,St]=(0,J.useState)(()=>new Set),Ct=(0,J.useCallback)(e=>St(t=>t.has(e)?t:new Set(t).add(e)),[]),wt=(0,J.useCallback)(()=>{vt(!1),tD()},[]),Tt=()=>{bt(),wt()},Et=m.get(`hist`),Dt=m.get(`hv`),{journeys:Ot,journey:kt,route:At,routeGraph:jt,routePages:Mt,step:Nt,journeyComments:Pt}=hk({params:m,data:w,builder:pt}),X=m.get(`links`)===`1`,[Ft,It]=(0,J.useState)(!1);(0,J.useEffect)(()=>{X||It(!1)},[X]);let Lt=Array.isArray(w?.brokenLinks)?w.brokenLinks:[],Rt=Lt.length?`Arrows for the links between pages; ${Lt.length} ${Lt.length===1?`link leads`:`links lead`} to an error`:`Arrows for the links between pages`,{environments:zt,comparePair:Bt,changedOnly:Vt,showDiff:Ht,compareQuery:Ut,compareData:Wt,compareView:Gt,setCompare:Kt,canCompare:qt,toggleCompare:Jt,setChangedOnly:Yt}=Ek({boardId:e,params:m,updateParams:h,environmentList:w?.environments,setCommentMode:Me,pageCount:w?.board?.pages?.length||0}),Xt=(0,J.useMemo)(()=>{let e=w?.board?.pages||[];return!Vt||!Wt?e:e.filter(e=>(ev(Wt,e.id)||0)>0)},[Vt,Wt,w?.board?.pages]),Zt=(0,J.useMemo)(()=>w?.board&&R.length?Iv({pages:Xt,groups:w.board.groups,variants:Bt?[]:w.variants,viewports:L,mode:V,compare:Bt}):{nodes:[],edges:[],targets:{}},[w?.board,w?.variants,Xt,L,V,Bt]),[Qt,$t,en]=$p(Zt.nodes);(0,J.useEffect)(()=>{$t(Zt.nodes)},[Zt.nodes,$t]);let tn=nm(),[nn,rn]=JE(tn),[an,on]=(0,J.useState)(null),[sn,cn]=(0,J.useState)(null),ln=(0,J.useCallback)(()=>{on(null),cn(null)},[]),un=(0,J.useCallback)(()=>{ln(),rn(null),u.fitView({...ME,duration:kE(400)})},[ln,u,rn]);yk({mode:V,pendingFocus:lt,shapeKey:`${Bt?.join(`_`)||``}|${Vt&&Wt?Xt.length:`all`}`,clearFocus:ln,fitBoard:un});let dn=(0,J.useMemo)(()=>Xk(w?.board?.pages,e=>e.id),[w?.board?.pages]),fn=(0,J.useMemo)(()=>Xk(w?.variants,e=>`variant:${e.id}`),[w?.variants]),{visibleComments:pn,pinsByTarget:mn,counts:hn}=Dk({comments:D,query:te,stateFilter:ne,mentionFilter:re,titleOfPage:(0,J.useCallback)(e=>String(e).startsWith(`variant:`)?fn.get(e)?.title||``:dn.get(e)?.title||``,[dn,fn]),filter:H,journey:kt,journeyComments:Pt}),gn=(0,J.useMemo)(()=>N(D),[D]),_n=(0,J.useMemo)(()=>({name:n?.user?.name||Ve||``,handle:n?.user?.handle||null}),[n?.user?.name,n?.user?.handle,Ve]),vn=v&&!w?.migratedTo?.readOnly&&x(`comment`),yn=e=>{let t=!!_n.handle&&e.authorHandle===_n.handle;return{reply:v&&!w?.migratedTo?.readOnly&&x(`reply`),resolve:v&&!w?.migratedTo?.readOnly&&x(`resolve`),react:v&&!w?.migratedTo?.readOnly&&x(`react`),edit:v&&!w?.migratedTo?.readOnly&&x(`edit`)&&(!n?.hosted||dT({isAuthor:t})),delete:v&&!w?.migratedTo?.readOnly&&x(`delete`)&&(!n?.hosted||fT({role:n.role,isAuthor:t}))}},{seen:bn,markSeen:xn,markAllSeen:Sn}=cT(e),Cn=(0,J.useMemo)(()=>new Set(D.filter(e=>sT(e,bn,_n)).map(e=>e.id)),[D,_n,bn]),wn=D.find(e=>e.id===U)||null,Tn=CO(s),En=(0,J.useMemo)(()=>{let e=new Set;for(let t of D)t.status!==`resolved`&&(t.agentStatus===`working`||ot.has(t.id))&&e.add(t.pageId);return e},[ot,D]),Dn=(0,J.useCallback)(e=>dn.get(e)||null,[dn]),On=(0,J.useCallback)(e=>{if(e.startsWith(`variant:`)){let t=fn.get(e);return t?`Variant: ${t.title}`:`Removed variant`}return Dn(e)?.title||e},[fn,Dn]),kn=w?.manifest?.capturedAt||`none`,An=(0,J.useRef)(null),{refetch:jn}=S,{refetch:Mn}=C,{refetch:Nn}=Ut,Pn=(0,J.useCallback)(()=>{let e=`${kn}|${w?.environments?.map(e=>e.capturedAt).join(`,`)||``}`;An.current!==e&&(An.current=e,jn(),Mn(),Nn())},[w?.environments,kn,Mn,Nn,jn]),Fn=(0,J.useRef)(!1),In=(0,J.useCallback)(e=>{Fn.current=!1,Pe(null),h({c:e.id}),s||(Fe(!1),Le(!0))},[h,s]),Ln=(0,J.useCallback)(()=>{Le(!1),h({c:null}),Fn.current&&!s&&Fe(!0),Fn.current=!1},[h,s]),Rn=(0,J.useCallback)(e=>{let t=V!==`all`&&e.viewport!==V&&!!L[e.viewport];Pe(null),ut(e),h({c:e.id,...t?{vp:e.viewport===B?null:e.viewport}:{}}),t&>({from:V,to:e.viewport,id:e.id,at:Date.now()}),s||(Fe(!1),Le(!0))},[B,V,h,L,s]);(0,J.useEffect)(()=>{if(!ht)return;let e=window.setTimeout(()=>gt(null),6e3);return()=>window.clearTimeout(e)},[ht]),_k({pendingFocus:lt,setPendingFocus:ut,targets:Zt.targets,viewports:L,flow:u,canvasRef:Ae,wide:s,setSettledZoom:rn}),vk({wide:s,nodesReady:tn,initialCamera:ke,selectedCommentId:U,canvasRef:Ae,nodes:Zt.nodes,flow:u,setSettledZoom:rn});let zn=(0,J.useRef)(!ke.current&&!U&&!m.get(`j`)),Bn=(0,J.useRef)(!ke.current&&!!U),[Vn,Hn]=(0,J.useState)(()=>!s||!zn.current);(0,J.useEffect)(()=>{if(!zn.current||!tn||!Zt.nodes.length)return;if(zn.current=!1,!s){Hn(!0);return}let e=HE(Zt.nodes,Ae.current?.getBoundingClientRect());rn(null);let t=e?u.setViewport(e):u.fitView(ME);Promise.resolve(t).finally(()=>Hn(!0))},[u,Zt.nodes,tn,rn,s]);let Un=(0,J.useRef)(!1),Wn=()=>{Un.current=!0},Gn=(0,J.useCallback)(e=>{Un.current&&(Un.current=!1,e.preventDefault(),Ae.current?.focus({preventScroll:!0}))},[]),{liveKeys:Kn,readyKeys:qn,setLiveReady:Jn,liveFileFor:Yn,recomputeLive:Xn,openLive:Zn}=rk({canvasRef:Ae,flow:u,targets:Zt.targets,viewports:L,settledZoom:nn,setSettledZoom:rn,comparePair:Bt,captures:w?.captures,variantsById:fn});(0,J.useEffect)(()=>{sn&&!Kn.has(sn)&&cn(null)},[Kn,sn]);let{openJourney:Qn,closeJourney:$n,goStep:er,chooseJourneyBranch:tr,startBuilder:nr,addBuilderStep:rr,saveBuilder:ir,removeJourney:ar}=fk({boardId:e,view:S,updateParams:h,clearFocus:ln,setCommentMode:Me,journey:kt,route:At,routePages:Mt,step:Nt,builder:pt,setBuilder:mt,busy:st,setBusy:ct,setNotice:Je,flow:u,targets:Zt.targets,nodesReady:tn,mode:V,comparePair:Bt,setSettledZoom:rn}),or=an&&!an.startsWith(`variant:`)?mv(an):null,sr=or?.targetId||null,cr=dt||sr,lr=m.get(`la`)===`1`,{presentPages:ur,shownSteps:dr,hiddenLinkTargets:fr,edges:pr,journeyView:mr}=Ok({targets:Zt.targets,layoutEdges:Zt.edges,links:w?.links,showLinks:X,showAllLinks:lr,activePage:cr,builder:pt,route:At,routeGraph:jt,routePages:Mt,step:Nt,journey:kt,targetTitle:On}),hr=(0,J.useCallback)((e,t=null)=>{if(!e||String(e).startsWith(`variant:`))return;let n=V===`all`?R[0]:V;h({hist:e,hv:t&&t!==n?t:null})},[V,h,R.join(`,`)]),gr=Et&&w?.board?.pages.find(e=>e.id===Et)||null,_r=Dt&&L[Dt]?Dt:V===`all`?R[0]:V,vr=(0,J.useCallback)(()=>h({hist:null,hv:null}),[h]),yr=t=>{let n=Zt.targets[t];if(!n)return;rn(null);let r=n.frames[0],i=n.frames.map(e=>w?.captures?.[t]?.[e.viewport]).filter(e=>e?.thumb||e?.file);FE(u,n,Ae.current?.getBoundingClientRect(),{phoneCompare:!!Bt&&!s,shotUrls:i.map(t=>c(e,`captures`,t.thumb||t.file,kn))}),r&&on(`${t}|${r.viewport}`)},br=(0,J.useMemo)(()=>{let e=Xt;return[...new Set(e.map(e=>e.group))].map(t=>({group:t,pages:e.filter(e=>e.group===t)}))},[Xt]),xr=(0,J.useMemo)(()=>Ne?{pageId:Ne.pageId,viewport:Ne.viewport,x:Ne.x,y:Ne.y,anchor:Ne.anchor}:null,[Ne?.pageId,Ne?.viewport,Ne?.x,Ne?.y,Ne?.anchor]),Sr=(0,J.useCallback)((e,t,n)=>{let r=Zt.targets[e],i=r?.frames.find(e=>e.viewport===t);i&&(u.getZoom()>=3.9?In(n[0].comment):(rn(null),u.fitBounds(IE(r,i,n),{padding:.3,duration:kE(450)})))},[u,Zt.targets,In,rn]),{board:Cr,view:wr}=Ak({boardId:e,data:w,viewports:L,journeyView:mr,compareView:Gt,commentMode:je,canComment:vn,wide:s,hosted:n?.hosted,imageVersion:kn,pinsByTarget:mn,me:_n,checksCounts:pe,canChecks:ae,agentFocus:ot,agentWorkingPages:En,setLiveReady:Jn,focusedKey:an,selectingKey:sn,settledZoom:nn,selectedComment:wn,draftSpot:xr,unread:Cn,liveKeys:Kn,selectedCommentId:U,closeThread:Ln,builder:pt,addBuilderStep:rr,layout:Zt,flow:u,canvasRef:Ae,setSettledZoom:rn,setFocusedKey:on,setToast:Ze,setDraft:Pe,checkDraft:ge,setCheckDraft:_e,authorName:He,selectComment:In,openCluster:Sr,openChecks:le,openHistory:hr,updateParams:h,defaultMode:B,onImageError:Pn}),{commentsUrl:Tr,applyComment:Er,setStatus:Dr,replyTo:Or,editComment:kr,reactTo:Ar,copyLink:jr,githubIssue:Mr,removeComment:Nr,sendToAgent:Pr}=pk({boardId:e,commentsQuery:C,view:S,info:n,localName:Ve,authorName:He,setBusy:ct,setNotice:Je,setToast:Ze,setDeletingIds:P,selectedCommentId:U,closeThread:Ln,wide:s,filter:H,allowed:x}),Fr=(0,J.useMemo)(()=>({attach:vn&&!o&&!n?.guest,draw:vn&&!o,attachNote:vn&&!o&&n?.guest?`Guests on a share link cannot attach images. You can still draw on the page.`:null}),[vn,n?.guest]),Ir=(0,J.useCallback)((t,n)=>{let r=w?.captures?.[t]?.[n];if(!r?.file)return null;let i=String(t).startsWith(`variant:`)?fn.get(t):null,a=dn.get(i?i.pageId:t),o=Nv(L,n,a?.frameHeight);return o?{src:c(e,`captures`,r.file,kn),native:o}:null},[e,w?.captures,kn,dn,fn,L]),{draftDescription:Lr,composerProps:Rr}=Mk({draft:Ne,setDraft:Pe,busy:st,setBusy:ct,commentsUrl:Tr,applyComment:Er,markSeen:xn,setLocalName:Be,setNotice:Je,updateParams:h,wide:s,filter:H,targetTitle:On,people:gn,info:n,media:Fr,pageImage:Ir}),{captureConfirm:zr,setCaptureConfirm:Br,startCapture:Vr}=jk({boardId:e,view:S,setBusy:ct,setNotice:Je,setPolling:A}),Hr=(0,J.useCallback)(e=>{h({v:`${Math.round(e.x)},${Math.round(e.y)},${e.zoom.toFixed(3)}`}),rn(e.zoom),Xn()},[Xn,rn,h]),Ur=bS({canvasRef:Ae,flow:u,minZoom:jE,maxZoom:4,onRest:Hr}),Wr=(0,J.useCallback)((e,t)=>{Ur.moving()||Hr(t)},[Hr,Ur]);G(!!an,ln),(0,J.useEffect)(()=>{an&&_t&&wt()},[wt,an,_t]),G(je,()=>Me(!1)),G(!!kt,$n),G(!!pt,()=>mt(null)),ak({commentMode:je,setCommentMode:Me,canComment:vn,comparePair:Bt,setDraft:Pe}),ok({journeys:Ot,journey:kt,builder:pt,openJourney:Qn,closeJourney:$n});let[Gr,Kr]=FD(s,!1);(0,J.useEffect)(()=>{let e=e=>{!(e.metaKey||e.ctrlKey)||e.altKey||e.shiftKey||e.key.toLowerCase()!==`k`||document.querySelector(`[role="dialog"]:not([data-sw-thread-popover]):not([data-sw-palette])`)||(e.preventDefault(),rt(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,J.useEffect)(()=>{je||Pe(e=>e&&!e.body.trim()?null:e)},[je]),(0,J.useEffect)(()=>{wn&&xn(wn)},[xn,wn]),(0,J.useEffect)(()=>{wn&&Ct(`open`),je&&Ct(`comment`),be&&Ct(`agent`)},[be,je,Ct,wn]),bk({nodesReady:tn,data:w,commentsLoaded:C.data,selectedCommentId:U,selectedComment:wn,initialCamera:ke,focusComment:Rn,deletingIds:M,setNotice:Je,updateParams:h});let{threadList:qr,threadIndex:Jr,stepThread:Yr,neighborNote:Xr}=xk({selectedComment:wn,visibleComments:pn,focusComment:Rn,mode:V,viewports:L,modes:z});(0,J.useEffect)(()=>{let e=null,t=wr.subscribe(()=>{let{hoveredId:t}=wr.get(),n=t===null?null:Ae.current?.querySelector(`[data-sw-pin="${t}"]`)||null;n!==e&&(e?.removeAttribute(`data-sw-pin-hover`),n?.setAttribute(`data-sw-pin-hover`,`true`),e=n)});return()=>{t(),e?.removeAttribute(`data-sw-pin-hover`)}},[wr]);let Zr=e=>{gt(null),h({vp:e===B?null:e})},Qr=D.filter(e=>e.status===`open`).length,$r=bC({boardId:e,enabled:!(!ye||w?.migratedTo?.readOnly||!n?.agent?.fixWithAgent||!n?.agent?.configured||n?.hosted&&!E),onProgress:()=>{C.refetch(),S.refetch()}}),[ei,ti]=(0,J.useState)(null),ni=e=>{let t=D.find(t=>t.id===e);t?Rn(t):Ee(vw(e))},ri={...$r,agentName:n?.agent?.label||`agent`,boardId:e,onOpenThread:ni,onConfirm:e=>ti(e)},ii={batch:ri,comments:pn,filter:H,counts:hn,onFilter:e=>h({filter:e===`open`?null:e}),selectedId:U,onHover:Cr.onHoverComment,onFocus:e=>{Fn.current=!s,Rn(e)},unread:Cn,onMarkAllRead:()=>Sn(D),people:gn,narrow:{query:te,state:ne,mention:re,onQuery:e=>h({q:e||null}),onState:e=>h({st:e}),onMention:e=>h({m:e}),onClear:()=>h({q:null,st:null,m:null})},canAct:vn,targetTitle:On,touch:!s,onResetBrowserComments:F?()=>{f(e),h({c:null}),C.refetch(),S.refetch()}:null,journeyFilter:kt?{name:kt.name,on:Pt,onToggle:()=>h({jc:Pt?null:`1`})}:null},ai=wn?{comment:wn,page:Dn(wn.pageId),title:On(wn.pageId),people:gn,me:_n,can:yn(wn),role:n?.guest?`guest`:n?.role||null,hosted:!!n?.hosted,onSaveName:Be,media:{...Fr,boardId:e,pageImage:Ir,pageTitle:On(wn.pageId),currentVersion:e=>String(e.pageId).startsWith(`variant:`)?null:Y_(w?.manifest?.pages?.[e.pageId]?.[e.viewport],w?.manifest)},busy:st,touch:!s,editingRef:Ue,actions:{onReply:Or,onSendToAgent:n?.hosted&&w?.agentDispatch&&!wn.authorGuest&&!wn.authorAgent?Pr:null,onStatus:Dr,onEdit:kr,onDelete:Nr,onReact:Ar,onCopyLink:jr,onFixAgent:ye&&!w?.migratedTo?.readOnly&&n?.agent?.fixWithAgent&&n?.agent?.configured?e=>{k({commentId:e.id,nonce:Date.now()}),s||Le(!1),Ee(vw(e.id))}:null,onAskAgent:ye?e=>{s||Le(!1),Ee(vw(e.id))}:null,onGithubIssue:!o&&n?.github?.ready?Mr:null,onHistory:e=>{s||Le(!1),hr(e.pageId,e.viewport)}},nav:{index:Jr,total:qr.length,onPrev:()=>Yr(-1),onNext:()=>Yr(1),prevNote:Xr(-1),nextNote:Xr(1)},beforeAfter:w?{pairFor:e=>Q_(e,{manifest:w.manifest,captures:w.captures,versions:w.versions}),nativeFor:e=>{let t=String(e.pageId).startsWith(`variant:`)?fn.get(e.pageId):null,n=dn.get(t?t.pageId:e.pageId);return Nv(L,e.viewport,n?.frameHeight)||null},urlFor:t=>c(e,t.kind,t.file,t.version),onImageError:Pn}:null}:null,oi={boardId:e,batch:ri,fixRequest:O,onFixDone:()=>{k(null),S.refetch(),C.refetch()},agent:n?.agent,threadId:be||`board`,onThread:Ee,comments:D,pages:w?.board?.pages||[],captures:w?.captures||{},imageVersion:kn,defaultViewport:V===`all`?B:V,focused:or?{pageId:or.targetId,viewport:or.viewport}:null,touch:!s,onOpenSettings:xe?Te:null,settingsLocked:!!(ye&&!xe&&n?.agent?.settingsLocked),onAgentChanged:i,people:gn,onRunChecks:he?async()=>{let e=await he.start({seo:he.seoDefault});return le(),e}:null,journeys:Ot,checksCounts:ae?pe:null,onBoardChanged:()=>{S.refetch(),C.refetch()},onNavigate:e=>{if(!s&&e.kind!==`check`&&h({chat:null}),e.kind===`comment`){let t=D.find(t=>t.id===e.id);t&&Rn(t)}else e.kind===`page`?yr(e.id):e.kind===`journey`?Qn(e.id):e.kind===`check`&&le(e.id)},onRecapture:b&&!Bt?e=>e?Vr(null,Array.isArray(e)?e:[e]):Br(!0):E?()=>Je({tone:`info`,text:`The demo does not take new captures. On your own board this recaptures the changed pages.`}):null},si=()=>h({links:X?null:`1`}),ci=()=>{let e=!tt;et(e),eD(e)},li=!!gr||we||Ce||zr||!s&&W,ui={data:ce.data,error:ce.error,loading:ce.loading,pages:w?.board?.pages||[],pageId:oe,viewport:se,onSelect:le,onClose:de,onRefresh:ce.refetch,onEnvironment:e=>h({ce:e}),canComment:vn,local:!o&&!n?.hosted,onView:(e,t)=>{de(),h({vp:t,page:e}),ut({pageId:e,viewport:t,x:50,y:50})},onDraft:(e,t,n)=>{_e(`${n.title}\n\n${n.observation}\n${n.nextAction}\n\nCheck report ${t.id} (${e.viewport}, ${t.auditedAt}). Separately sampled; review before sending to an agent.`.slice(0,1800)),de(),h({vp:e.viewport}),ut({pageId:e.pageId,viewport:e.viewport,x:50,y:50}),Fe(!1),Me(!0),Ze({at:Date.now(),text:`Choose a pin on the page, then review and save your comment.`})},...me},di=e=>{e.preventDefault(),de(),s?((ie||be)&&h({panel:null,chat:null}),window.requestAnimationFrame(()=>window.requestAnimationFrame(()=>document.getElementById(`sw-comments`)?.focus()))):Fe(!0)},fi=e=>xS(e,e=>{let t=Zt.targets[e]?.frames[0];t&&Cr.onFocusFrame(e,t.viewport)}),pi=Nk({canComment:vn,comparePair:Bt,commentMode:je,markPicked:Wn,setDraft:Pe,setCommentMode:Me,showLinks:X,toggleLinks:si,canCompare:qt,toggleCompare:Jt,wide:s,fitBoard:un,minimapOn:tt,toggleMinimap:ci,chatAvailable:ye,reopenChat:De,canChecks:ae,openChecks:le}),mi={setMenuOpen:Ke,data:w,chatAvailable:ye,chatThread:be,reopenChat:De,updateParams:h,groupedPages:br,jumpToPage:yr,modes:z,mode:V,setMode:Zr,journeys:Ot,journey:kt,canEditJourneys:y,openJourney:Qn,closeJourney:$n,startBuilder:nr,openBrokenLinks:()=>It(!0),canChecks:ae,openChecks:le,showLinks:X,toggleLinks:si,brokenLinks:Lt,canCompare:qt,comparePair:Bt,toggleCompare:Jt,settingsAvailable:xe,openSettings:Te,capture:T,canCapture:b,busy:st,setCaptureConfirm:Br};return(0,Y.jsxs)(Qk,{board:Cr,view:wr,people:gn,children:[(0,Y.jsxs)(`div`,{className:`flex h-full flex-col`,"data-sw-board":e,style:{paddingTop:`env(safe-area-inset-top, 0px)`},children:[(0,Y.jsx)(OT,{}),(0,Y.jsx)(HT,{}),n?.hosted&&w?.agentApprove?(0,Y.jsx)(BT,{boardId:e}):null,(0,Y.jsx)(`a`,{href:`#sw-comments`,className:`sr-only z-[80] rounded-md bg-accent px-3 py-2 text-sm font-medium text-accent-fg focus:not-sr-only focus:absolute focus:top-2 focus:left-2`,onClick:di,"data-sw-skip-comments":`true`,children:`Skip to comments`}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[s?(0,Y.jsx)(YO,{...mi,info:n,localName:Ve,onOpenBuzz:a,demo:d,localSettingsAvailable:Se,setShareOpen:_,expanded:Gr,onToggle:Kr,quiet:Tn,pages:w?{groups:br,journeys:Ot,comments:D,activePage:cr,journeyId:kt?.id||null,onPage:yr,onJourney:Qn,canEditJourneys:y,onNewJourney:()=>nr()}:null}):null,(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(yO,{...mi,wide:s,info:n,boardId:e,boards:t,localProjects:I,projectsError:ee.error,localName:Ve,onPickBoard:r,onOpenBuzz:a,demo:d,localSettingsAvailable:Se,setShareOpen:_,viewportNotice:ht,canComment:vn,commentMode:je,setCommentMode:Me,openPalette:()=>rt(!0),minimapOn:tt,toggleMinimap:ci,linksTip:Rt,panelHidden:ie,checksOpen:W,allOpen:Qr,closeChecks:de,setSheetOpen:Fe,sidebarTitled:s&&Gr}),!n?.hosted&&w?.migratedTo?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(qk,{marker:w.migratedTo,boardId:e,editable:!!n?.shareEnabled,onChange:S.refetch})}):null,(0,Y.jsx)(OO,{notice:qe,setNotice:Je,wide:s}),Bt?(0,Y.jsx)(VC,{environments:zt,pair:Bt,loading:Ut.loading||!Wt,error:Ut.error?Ut.error.message:null,changedPages:Wt?.changedPages??0,totalPages:w?.board?.pages?.length||0,changedOnly:Vt,showDiff:Ht,canCapture:b,captureBusy:st||!!T?.running,touch:!s,onPair:e=>Kt(e),onChangedOnly:Yt,onShowDiff:e=>h({diff:e?null:`off`}),onCapture:e=>Vr(e),onClose:()=>Kt(null)}):null,(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,Y.jsxs)(`div`,{ref:Ae,tabIndex:-1,className:K(`relative min-w-0 flex-1 outline-none`,je&&vn&&`sw-commenting`),onKeyDown:fi,"data-sw-canvas":`true`,children:[X&&Lt.length?(0,Y.jsx)(qD,{items:Lt,open:Ft,onOpenChange:It}):null,s&&w?(0,Y.jsx)(wO,{flow:u,canvasRef:Ae,targets:Zt.targets,focusFor:e=>((e===`composer`?Ne?.y:wn?.y)??50)/100,shotFor:(t,n)=>{let r=w.captures?.[t]?.[n];return r?.file?c(e,`captures`,r.thumb||r.file,kn):null}}):null,Tn?null:(0,Y.jsx)(xO,{wide:s,commentMode:je,canComment:vn,readyKeys:qn,setCommentMode:Me,showLinks:X,activePage:cr,shownSteps:dr,data:w,presentPages:ur,hiddenLinkTargets:fr,showAllLinks:lr,targetTitle:On,updateParams:h,tipOpen:_t,tryOpen:yt,journey:kt,builder:pt,viewportNotice:ht,dismissTip:wt,modes:z,setMode:Zr,comparePair:Bt}),!w&&S.error?(0,Y.jsx)(U_,{error:S.error,onRetry:S.refetch}):w?(0,Y.jsxs)(Jp,{nodes:Qt,edges:pr,edgeTypes:cS,onNodeMouseEnter:X?(e,t)=>ft(t.type===`page`?t.id:null):void 0,onNodeMouseLeave:X?()=>ft(null):void 0,onNodesChange:en,onNodeClick:Jk,nodeTypes:rS,colorMode:p,defaultViewport:ke.current||void 0,fitView:Bn.current,style:Vn?void 0:{opacity:0},edgesFocusable:!1,fitViewOptions:ME,minZoom:jE,maxZoom:4,panOnScroll:!1,zoomOnScroll:!1,panActivationKeyCode:null,zoomActivationKeyCode:null,onlyRenderVisibleElements:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,zoomOnDoubleClick:!je,onMoveEnd:Wr,onPaneClick:()=>{ln(),U&&Ln()},proOptions:{hideAttribution:!0},children:[(0,Y.jsx)(um,{gap:40,size:1}),(0,Y.jsx)(Kk,{onChecks:ae?le:null,onHistory:hr,historyCountFor:e=>iv(w?.versions,e),focusedKey:Tn?null:an,layout:Zt,data:w,liveKeys:Kn,readyKeys:qn,selectingKey:sn,touch:!s,liveFileFor:Yn,onOpenLive:Zn,onToggleSelect:e=>cn(t=>t===e?null:e),onClose:ln,onCapture:b&&!Bt?e=>Vr(null,[e]):null,captureBusy:st||!!T?.running}),s&&Ne&&!li?(0,Y.jsx)(eT,{point:Bv(Zt.targets,Ne),stowed:Tn,onClose:()=>st?null:Pe(null),children:(0,Y.jsx)(WC,{...Rr,touch:!1,description:Lr})}):null,s&&ai&&!Ne&&!li?(0,Y.jsx)($w,{comment:wn,point:Bv(Zt.targets,wn),onClose:Ln,stowed:Tn,onPrev:()=>Yr(-1),onNext:()=>Yr(1),editingRef:Ue,children:(0,Y.jsx)(Gw,{...ai,onClose:Ln})}):null,(0,Y.jsx)(Bk,{wide:s,clearFocus:ln,setSettledZoom:rn,minimapOn:tt,liveKeys:Kn,toggleMinimap:ci,hideFit:!!(kt||pt),hideMinimap:!!(kt||pt),fitBoard:un})]}):(0,Y.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted`,children:[(0,Y.jsx)(ue,{}),` Loading board`]}),n?.hosted&&!E?(0,Y.jsx)(JT,{touch:!s,enabled:!!w&&!o,boardId:e,canvasRef:Ae,flow:u,selection:U,mode:V,onMode:e=>h({vp:e}),onInvalidate:()=>{C.refetch(),S.refetch()}}):null,yt&&w&&!kt&&!pt&&!Tn&&(!je||s)?(0,Y.jsx)(SE,{touch:!s,done:xt,onOpenComment:()=>{let e=pn.filter(e=>e.status===`open`),t=e.find(e=>V===`all`||e.viewport===V)||e[0]||pn[0];t&&Rn(t)},onComment:vn&&!Bt?()=>{Pe(null),Me(!0)}:null,onAgent:ye?De:null,onClose:Tt}):null,(0,Y.jsx)(DO,{toast:Ye,setToast:Ze,onHold:Qe,wide:s,raised:!!(kt||pt)}),Bt&&Vt&&Wt&&!Xt.length?(0,Y.jsx)(`p`,{className:`absolute inset-x-0 top-1/3 mx-auto w-max max-w-[90%] rounded-lg bg-surface px-4 py-3 text-sm text-muted shadow-pop`,children:`No visual changes between these two environments.`}):null,pt?(0,Y.jsx)(IC,{draft:pt,pages:w?.board?.pages||[],onChange:mt,onSave:ir,onCancel:()=>mt(null),pageTitle:e=>Dn(e)?.title||e,busy:st,touch:!s}):kt&&!Tn?(0,Y.jsx)(FC,{journey:kt,route:At,step:Nt,pageTitle:e=>Dn(e)?.title||e,onStep:er,onChoose:tr,onClose:$n,onEdit:()=>nr(kt),onDelete:ar,canEdit:y&&kt.source===`board`,busy:st,touch:!s},kt.id):null]}),(0,Y.jsx)(jO,{wide:s,checksOpen:W,checksProps:ui,chatThread:be,chatProps:oi,panelHidden:ie,panelProps:ii,updateParams:h})]})]})]}),(0,Y.jsx)(TT,{ref:Oe})]}),s?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(RO,{checksOpen:W,closeChecks:de,checksProps:ui,chatAvailable:ye,chatThread:be,chatProps:oi,updateParams:h,sheetOpen:q,setSheetOpen:Fe,panelProps:ii,threadSheet:Ie,threadProps:ai,closeThread:Ln,selectedComment:wn,targetTitle:On,draft:Ne,busy:st,setDraft:Pe,draftDescription:Lr,composerProps:Rr}),(0,Y.jsx)(bO,{...mi,menuOpen:Ge})]}),$r.offered?(0,Y.jsx)(CC,{open:!!ei,onClose:()=>{ti(null),$r.setError(null)},ids:ei||[],comments:D,max:$r.max,agentName:ri.agentName,targetTitle:On,busy:$r.busy,error:$r.error,touch:!s,onStart:async e=>{await $r.start(e)&&ti(null)}}):null,(0,Y.jsx)(ek,{info:n,boardId:e,boards:t,wide:s,shareOpen:g,setShareOpen:_,refetchView:jn,settingsAvailable:xe,settingsOpen:we,updateParams:h,onInfoChanged:i,generalSettingsOpen:Ce,updates:Oe,historyPage:gr,closeHistory:vr,historyViewport:_r,historyPageId:Et,data:w,comments:D,filter:H,focusComment:Rn,onImageError:Pn,captureConfirm:zr,setCaptureConfirm:Br,busy:st,focusedPage:sr,findPage:Dn,startCapture:Vr}),(0,Y.jsx)(gD,{open:nt,onOpenChange:rt,groups:br,journeys:Ot,canEditJourneys:y,comments:D,titleOf:On,actions:pi,onPage:e=>{Wn(),yr(e)},onJourney:e=>{Wn(),Qn(e)},onNewJourney:()=>{Wn(),nr()},onComment:e=>{Wn(),Rn(e)},onCloseAutoFocus:Gn})]})}function Qk({board:e,view:t,people:n,children:r}){return(0,Y.jsx)(vv.Provider,{value:e,children:(0,Y.jsx)(Eb.Provider,{value:t,children:(0,Y.jsx)(ib.Provider,{value:n,children:r})})})}function $k(){let[e,t]=(0,J.useState)(``),[n,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(``);(0,J.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await Ke.get(`/api/pairing`);if(!e)return;i(t),(t.pairing.state===`approved`||[`host`,`device`,`identity`].includes(t.access))&&window.location.reload()}catch(t){e&&o(t.message)}};t();let n=setInterval(t,2e3);return()=>{e=!1,clearInterval(n)}},[]);let s=async t=>{t.preventDefault(),o(``);try{let t=await Ke.post(`/api/pairing`,{name:e});i(e=>({...e,pairing:t}))}catch(e){o(e.message)}},c=n?.pairing,l=c?.code,u=/iPad|iPhone|iPod/.test(navigator.userAgent),d=window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone;return(0,Y.jsxs)(`main`,{className:`mx-auto flex min-h-dvh max-w-lg flex-col justify-center gap-5 p-6`,"data-sw-pairing":!0,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-accent`,children:`Shapewall`}),(0,Y.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold text-fg`,children:`Pair this device`})]}),(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`This board belongs to the person running Shapewall. Match the code and approve this device on that computer.`}),c?.state===`pending`?(0,Y.jsxs)(`section`,{className:`space-y-3 rounded-lg border border-line p-4`,"aria-live":`polite`,children:[(0,Y.jsxs)(`p`,{className:`text-sm text-fg`,children:[`Waiting for approval: `,c.name]}),(0,Y.jsxs)(`p`,{className:`font-mono text-3xl tracking-widest text-fg`,"data-sw-pairing-code":!0,children:[l.slice(0,4),`-`,l.slice(4)]}),(0,Y.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Expires in five minutes. On the host, open Devices or run `,(0,Y.jsxs)(`code`,{children:[`shapewall devices approve `,l]}),`.`]})]}):(0,Y.jsxs)(`form`,{className:`space-y-3`,onSubmit:s,children:[[`denied`,`expired`].includes(c?.state)?(0,Y.jsxs)(`p`,{className:`text-sm text-warn`,role:`status`,children:[c.state===`denied`?`The host denied this request.`:`This request expired.`,` You can request again.`]}):null,(0,Y.jsx)(`label`,{htmlFor:`device-name`,className:`block text-sm text-fg`,children:`Device name`}),(0,Y.jsx)(Ge,{id:`device-name`,required:!0,maxLength:80,placeholder:`My phone`,value:e,onChange:e=>t(e.target.value)}),(0,Y.jsx)(r,{type:`submit`,children:`Request pairing`})]}),a?(0,Y.jsx)(`p`,{className:`text-sm text-bad`,role:`alert`,children:a}):null,n?.secure?null:(0,Y.jsx)(`p`,{className:`rounded-lg border border-warn/30 p-3 text-xs text-warn`,children:`Plain HTTP on Wi-Fi exposes your device cookie to sniffing and replay. Use Tailscale for private HTTPS, or configure a TLS certificate. Without HTTPS this board installs only as a bookmark.`}),u&&!d?(0,Y.jsx)(`p`,{className:`text-xs text-muted`,children:`Installing on your iPhone? Add the board to your Home Screen first, then pair from inside that app. Its cookies are separate from Safari.`}):null]})}function eA({info:e}){let[t,n]=(0,J.useState)(!1),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(``),c=e?.remote,l=!!c?.manage;(0,J.useEffect)(()=>{if(!l)return;let e=!0,t=async()=>{try{let t=await Ke.get(`/api/devices`);e&&a(t)}catch(t){e&&s(t.message)}};t();let n=setInterval(t,4e3);return()=>{e=!1,clearInterval(n)}},[l]);let u=async(e,t)=>{try{await Ke[e](t),l?a(await Ke.get(`/api/devices`)):window.location.reload()}catch(e){s(e.message)}};if(!c||!l&&!c.device)return null;let d=i?.pending||[];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`fixed bottom-3 left-3 z-30 rounded-lg border border-line bg-surface p-1 shadow-lg lg:bottom-16 lg:left-[64px]`,children:(0,Y.jsx)(r,{size:`sm`,variant:`ghost`,onClick:()=>n(!0),"data-sw-devices-open":!0,children:l?`Devices${d.length?` (${d.length} waiting)`:``}`:c.device.name})}),(0,Y.jsx)(M,{open:t,onClose:()=>n(!1),title:l?`Your devices`:`This device`,children:(0,Y.jsxs)(`div`,{className:`max-h-[70dvh] space-y-4 overflow-auto p-5`,"data-sw-devices":!0,children:[o?(0,Y.jsx)(`p`,{role:`alert`,className:`text-sm text-bad`,children:o}):null,l?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`Approve only your own devices, after matching the code shown on them. Paired devices can comment, capture and drive your connected agent.`}),d.map(e=>(0,Y.jsxs)(`section`,{className:`space-y-2 rounded border border-line p-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,Y.jsxs)(`p`,{className:`break-all text-xs text-muted`,children:[e.browser,` · `,e.ip]}),(0,Y.jsxs)(`p`,{className:`font-mono text-lg text-fg`,children:[e.code.slice(0,4),`-`,e.code.slice(4)]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(r,{size:`sm`,onClick:()=>u(`post`,`/api/devices/${e.code}/approve`),children:`Approve`}),(0,Y.jsx)(r,{size:`sm`,variant:`secondary`,onClick:()=>u(`post`,`/api/devices/${e.code}/deny`),children:`Deny`})]})]},e.id)),(i?.devices||[]).map(e=>(0,Y.jsxs)(`section`,{className:`flex items-center justify-between gap-2 rounded border border-line p-3`,children:[(0,Y.jsxs)(`p`,{className:`min-w-0 break-words text-sm text-fg`,children:[e.name,(0,Y.jsxs)(`span`,{className:`block text-xs text-muted`,children:[`Last seen `,new Date(e.lastSeenAt).toLocaleDateString()]})]}),(0,Y.jsx)(r,{size:`sm`,variant:`secondary`,onClick:()=>u(`delete`,`/api/devices/${e.id}`),children:`Revoke`})]},e.id)),!d.length&&!i?.devices?.length?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No paired devices or requests yet.`}):null]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Paired as `,c.device.name,`. Settings and other devices are managed on the host computer.`]}),(0,Y.jsx)(r,{variant:`secondary`,onClick:()=>u(`delete`,`/api/devices/${c.device.id}`),children:`Revoke this device`})]})]})})]})}var tA=(0,J.lazy)(()=>xT(()=>import(`./BuzzDialog-Ds7Thpfe.js`),__vite__mapDeps([11,1]),import.meta.url)),nA=!E&&typeof document<`u`&&!!document.querySelector(`meta[name="shapewall-remote"]`);function rA(){let[e,t]=(0,J.useState)(!1),[n,i]=(0,J.useState)(!1),a=ge(n);(0,J.useEffect)(()=>{let e=()=>t(!0);return window.addEventListener(`shapewall:pairing-required`,e),()=>window.removeEventListener(`shapewall:pairing-required`,e)},[]);let o=Xe(nA?`/api/pairing`:null),s=!nA||[`host`,`device`,`identity`].includes(o.data?.access),c=Xe(s?`/api/info`:null);eC(c.refetch,!!c.data?.agent);let l=c.data?.agent?.ownerWrites===!0;(0,J.useEffect)(()=>US(l),[l]);let u=j(),d=Xe(s?`/api/boards`:null),[f,p]=We(),m=Array.isArray(d.data?.boards)?d.data.boards:[],h=f.get(`board`),g=m.find(e=>e.id===h)||m[0];me(c.data?.fixturesAt);let _=E?u?.shareProblem:null;iA(_?`Share link`:g?.title);let v=E&&f.has(`share`);return(0,J.useEffect)(()=>{v&&p({share:null})},[v,p]),nA&&!o.loading&&!s||e||c.error?.code===`pairing_required`||d.error?.code===`pairing_required`?(0,Y.jsx)($k,{}):_?(0,Y.jsx)(jT,{problem:_,onLeave:u.leaveShare}):d.loading||c.loading?(0,Y.jsx)(B_,{}):d.error?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(U_,{error:d.error,onRetry:()=>Promise.all([d.refetch(),c.error?c.refetch():null]),extra:E?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{asChild:!0,size:`touch`,variant:`secondary`,className:`lg:h-10`,children:(0,Y.jsx)(`a`,{href:`console.html#/signin`,children:`Sign in to the demo`})}),(0,Y.jsx)(r,{size:`touch`,variant:`ghost`,className:`lg:h-10`,onClick:()=>u?.reset(),children:`Reset the demo`})]}):null}),E?(0,Y.jsx)(kT,{}):null]}):g?(0,Y.jsxs)(L,{children:[(0,Y.jsx)(eA,{info:c.data}),c.data?.buzzAvailable===!0&&a?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(tA,{open:n,onClose:()=>i(!1),boardId:g.id},g.id)}):null,(0,Y.jsx)(Wp,{children:(0,Y.jsx)(Zk,{boardId:g.id,boards:m,info:c.data,onInfoChanged:c.refetch,onOpenBuzz:()=>i(!0),onPickBoard:e=>p({board:e,c:null,v:null})})},g.id)]}):(0,Y.jsx)(`div`,{className:`flex h-full bg-sunken`,children:(0,Y.jsx)(k,{size:`lg`,icon:eg,title:`No boards yet`,children:c.data?.hosted?(0,Y.jsxs)(Y.Fragment,{children:[`Capture your site locally, then run `,(0,Y.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall push`}),` with a project token.`]}):(0,Y.jsxs)(Y.Fragment,{children:[`Add pages to `,(0,Y.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall.config.json`}),`, then run`,` `,(0,Y.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall capture`}),`.`]})})})}function iA(e){(0,J.useEffect)(()=>{if(!E||!e)return;let t=String(e).replace(/\s*\(demo\)$/i,``);document.title=t===`Share link`?`Share link · Shapewall demo`:`${t} board · Shapewall demo`},[e])}function aA(){typeof navigator<`u`&&`serviceWorker`in navigator&&window.isSecureContext&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`./sw.js`,{scope:`./`}).catch(()=>{})})}var oA=900;function sA(){try{let e=document.createElement(`div`);e.style.cssText=`position:absolute;top:-999px;width:100px;height:100px;overflow:scroll;visibility:hidden`,document.documentElement.appendChild(e);let t=e.offsetWidth-e.clientWidth>0;return e.remove(),t}catch{return!1}}function cA(){let e=new WeakMap;document.addEventListener(`scroll`,t=>{let n=t.target===document?document.documentElement:t.target;n instanceof Element&&(n.hasAttribute(`data-scrolling`)||n.setAttribute(`data-scrolling`,``),clearTimeout(e.get(n)),e.set(n,setTimeout(()=>n.removeAttribute(`data-scrolling`),oA)))},{capture:!0,passive:!0})}typeof document<`u`&&sA()&&(document.documentElement.classList.add(`sw-scrollbars`),cA()),document.querySelector(`meta[name="shapewall-agent-settings"]`)?xT(async()=>{let{default:e}=await import(`./Management-CJVNAqAW.js`);return{default:e}},__vite__mapDeps([12,7,1,5,2]),import.meta.url).then(({default:e})=>(0,rt.createRoot)(document.getElementById(`root`)).render((0,Y.jsx)(e,{}))):((0,rt.createRoot)(document.getElementById(`root`)).render((0,Y.jsx)(J.StrictMode,{children:(0,Y.jsx)(rA,{})})),aA());export{Jg as $,lC as A,Vb as B,dw as C,eh as Ct,mC as D,pC as E,eC as F,E_ as G,P_ as H,OS as I,m_ as J,b_ as K,SS as L,sC as M,nC as N,oC as O,cC as P,Qg as Q,Bb as R,lw as S,nh as St,EC as T,A_ as U,rv as V,O_ as W,i_ as X,u_ as Y,n_ as Z,ow as _,bh as _t,mT as a,mg as at,rw as b,uh as bt,jw as c,cg as ct,Sw as d,Wh as dt,Kg as et,xw as f,Hh as ft,sw as g,Eh as gt,_w as h,Ah as ht,gE as i,Sg as it,aC as j,rC as k,bw as l,ng as lt,hw as m,Mh as mt,tE as n,Bg as nt,hT as o,fg as ot,Pw as p,Rh as pt,v_ as q,nE as r,wg as rt,Mw as s,ug as st,AE as t,Wg as tt,Fw as u,Xh as ut,iw as v,vh as vt,GC as w,Wm as wt,cw as x,oh as xt,aw as y,mh as yt,zb as z};
|
|
37
|
+
`)[0]})}):null}function TO(){let[e,t]=(0,J.useState)(null),[n,r]=(0,J.useState)(!1);return(0,J.useEffect)(()=>{e||r(!1)},[e]),(0,J.useEffect)(()=>{if(!e||n)return;let r=window.setTimeout(()=>t(t=>t===e?null:t),6e3);return()=>window.clearTimeout(r)},[e,n]),[e,t,r]}function EO(e,t){let n=!!e?.untilSheet;(0,J.useEffect)(()=>{if(!n)return;let e=()=>{document.querySelector(`[role="dialog"][data-state="open"], [role="alertdialog"][data-state="open"]`)&&t(e=>e?.untilSheet?null:e)};e();let r=new MutationObserver(e);return r.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-state`]}),()=>r.disconnect()},[n,t])}function DO({toast:e,setToast:t,onHold:n,wide:i,raised:a}){return EO(e,t),e?(0,Y.jsxs)(`div`,{onMouseEnter:()=>n?.(!0),onMouseLeave:()=>n?.(!1),onFocus:()=>n?.(!0),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||n?.(!1)},className:K(`absolute inset-x-0 z-[80] mx-auto flex w-max max-w-[calc(100%-1rem)] animate-pop-in items-center gap-2 rounded-lg bg-fg py-1 pr-1 pl-3 text-xs font-medium text-surface shadow-pop`,a?i?`bottom-28`:`bottom-44`:i?`bottom-4`:`bottom-16`),role:`status`,"data-sw-toast":`true`,children:[(0,Y.jsx)(`span`,{className:`min-w-0`,children:e.text}),e.undo?(0,Y.jsx)(r,{size:i?`xs`:`touch`,variant:`inverse`,onClick:()=>{e.undo(),t(null)},"data-sw-toast-undo":`true`,children:`Undo`}):null,(0,Y.jsx)(z,{size:i?`icon-xs`:`icon`,variant:`inverse`,onClick:()=>t(null),label:`Dismiss`,children:(0,Y.jsx)(g,{size:13,"aria-hidden":`true`})})]},e.at):null}function OO({notice:e,setNotice:t,wide:n}){return e?(0,Y.jsxs)(`div`,{className:K(`flex shrink-0 items-center gap-3 border-b border-line px-4 py-2 text-xs`,e.tone===`bad`?`bg-bad/10 text-bad`:`bg-accent/10 text-fg`),role:e.tone===`bad`?`alert`:`status`,children:[(0,Y.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.text}),(0,Y.jsx)(r,{variant:`ghost`,size:n?`xs`:`touch`,onClick:()=>t(null),children:`Dismiss`})]}):null}var kO=(0,J.lazy)(()=>xT(()=>import(`./ChecksPanel-Cm22bCdQ.js`),__vite__mapDeps([3,1,2,4,5]),import.meta.url)),AO=(0,J.lazy)(()=>xT(()=>import(`./BoardChat-V1BCXdDB.js`),__vite__mapDeps([6,1,7,5,2,4]),import.meta.url));function jO({wide:e,checksOpen:t,checksProps:n,chatThread:r,chatProps:i,panelHidden:a,panelProps:o,updateParams:s}){return e&&t?(0,Y.jsx)(LO,{panel:`checks`,defaultWidth:384,"aria-label":`Checks`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`p`,{className:`p-4 text-sm text-muted`,children:`Loading checks…`}),children:(0,Y.jsx)(kO,{...n})})},`checks`):e&&r?(0,Y.jsx)(LO,{panel:`agent`,defaultWidth:384,"aria-label":`Agent`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(V_,{}),children:(0,Y.jsx)(AO,{...i,onClose:()=>s({chat:null})})})},`agent`):e&&!a?(0,Y.jsx)(LO,{panel:`comments`,defaultWidth:384,id:`sw-comments`,tabIndex:-1,className:`outline-none`,"aria-label":`Comments`,children:(0,Y.jsx)(MC,{...o,onClose:()=>s({panel:`off`})})},`comments`):null}var MO=280,NO=.6,PO=16,FO=`side`;function IO(e){let t=Math.max(MO,Math.floor(window.innerWidth*NO));return Math.min(t,Math.max(MO,Math.round(e)))}function LO({panel:e,defaultWidth:t,className:n,children:r,...i}){let[a,o]=(0,J.useState)(()=>IO(rD(FO)??t)),[s,c]=(0,J.useState)(!1),l=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=()=>o(e=>IO(e));return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let u=e=>{let n=IO(e);o(n),iD(FO,n===t?null:n)},d=e=>{e.button===0&&(e.preventDefault(),e.currentTarget.setPointerCapture(e.pointerId),l.current={x:e.clientX,width:a},c(!0))},f=e=>{l.current&&o(IO(l.current.width+l.current.x-e.clientX))},p=e=>{l.current&&(u(l.current.width+l.current.x-e.clientX),l.current=null,c(!1))},m=e=>{let n=e.shiftKey?64:PO;if(e.key===`ArrowLeft`)u(a+n);else if(e.key===`ArrowRight`)u(a-n);else if(e.key===`Home`)u(t);else return;e.preventDefault()};return(0,Y.jsxs)(`aside`,{className:K(`relative flex shrink-0 flex-col border-l border-line bg-surface`,n),style:{width:a},"data-sw-rail":e,...i,children:[(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize panel`,"aria-valuenow":a,"aria-valuemin":MO,"aria-valuemax":Math.max(MO,Math.floor(window.innerWidth*NO)),"aria-description":`Drag or use the arrow keys to resize. Double-click or press Home to reset.`,tabIndex:0,className:`group absolute inset-y-0 -left-1.5 z-20 w-3 cursor-col-resize touch-none outline-none`,onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onDoubleClick:()=>u(t),onKeyDown:m,"data-sw-rail-handle":`true`,children:(0,Y.jsx)(`span`,{"aria-hidden":`true`,className:K(`absolute inset-y-0 left-1/2 w-0.5 -translate-x-1/2 bg-accent opacity-0 transition-opacity group-hover:opacity-60 group-focus-visible:opacity-100`,s&&`opacity-100`)})}),s?(0,Y.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`,"aria-hidden":`true`}):null,r]})}function RO({checksOpen:e,closeChecks:t,checksProps:n,chatAvailable:r,chatThread:i,chatProps:a,updateParams:o,sheetOpen:s,setSheetOpen:c,panelProps:l,threadSheet:u,threadProps:d,closeThread:f,selectedComment:p,targetTitle:m,draft:h,busy:g,setDraft:_,draftDescription:v,composerProps:y}){return(0,Y.jsxs)(Y.Fragment,{children:[e?(0,Y.jsx)(M,{open:!0,onClose:t,title:`Checks`,size:`md`,children:(0,Y.jsx)(`div`,{className:`flex h-[78dvh] min-h-0 flex-col`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(`p`,{children:`Loading checks…`}),children:(0,Y.jsx)(kO,{...n})})})}):null,r?(0,Y.jsx)(M,{open:!!i,onClose:()=>o({chat:null}),title:`Agent`,size:`md`,children:(0,Y.jsx)(`div`,{className:`flex h-[78dvh] flex-col`,children:(0,Y.jsx)(J.Suspense,{fallback:(0,Y.jsx)(V_,{heading:!1}),children:(0,Y.jsx)(AO,{...a,heading:!1})})})}):null,(0,Y.jsx)(M,{open:s&&!e,onClose:()=>c(!1),title:`Comments`,size:`md`,children:(0,Y.jsx)(`div`,{className:`flex max-h-[70dvh] flex-col`,children:(0,Y.jsx)(MC,{...l,heading:!1})})}),(0,Y.jsx)(M,{open:u&&!!d&&!e,onClose:f,title:p?`#${p.id} · ${m(p.pageId)}`:`Comment`,description:p?`${p.viewport} capture`:void 0,size:`md`,children:d?(0,Y.jsx)(`div`,{className:`flex max-h-[72dvh] flex-col outline-none`,tabIndex:-1,"data-autofocus":!0,"data-sw-thread-sheet":p.id,children:(0,Y.jsx)(Gw,{...d})}):null}),(0,Y.jsx)(M,{open:!!h&&!e,onClose:()=>g?null:_(null),title:`New comment`,description:v,children:(0,Y.jsx)(`div`,{className:`p-4`,children:(0,Y.jsx)(WC,{...y,touch:!0})})})]})}var zO=e=>String(e).replace(/\/w\/[^/#?]+.*$/,`/account`),BO=`flex h-8 w-full items-center gap-2 rounded-md px-2.5 text-left text-[13px] outline-none focus-visible:outline-2 focus-visible:outline-accent`;function VO({journeys:e=[],journeyId:t=null,onJourney:n,canEditJourneys:r=!1,onNewJourney:i=null,bare:a=!1}){let[o,s]=(0,J.useState)(``),c=e.length>8,l=c?o.trim().toLowerCase():``,u=l?e.filter(e=>String(e.name||e.id).toLowerCase().includes(l)):e,d=e=>K(BO,e?`bg-accent/10 text-fg`:`text-fg/90 hover:bg-surface-2`),f=e=>K(`shrink-0`,e?`text-accent`:`text-faint`);return(0,Y.jsxs)(`div`,{className:K(`flex w-full flex-col`,!a&&`border-t border-line pt-2`),"data-sw-journeys-sidebar":`true`,children:[a?null:(0,Y.jsxs)(`p`,{className:`flex items-center px-2.5 pb-1 text-xs font-semibold text-faint`,children:[`Journeys `,(0,Y.jsx)(`span`,{className:`ml-1 font-normal tabular`,children:e.length})]}),c?(0,Y.jsx)(`div`,{className:`pb-2`,children:(0,Y.jsx)(Ge,{size:`sm`,icon:n_,value:o,onChange:e=>s(e.target.value.slice(0,80)),placeholder:`Filter journeys`,"aria-label":`Filter journeys`,"data-sw-journeys-filter":`true`})}):null,(0,Y.jsxs)(`ul`,{className:`pb-2`,"aria-label":`Journeys`,children:[e.length&&!l?(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,className:d(!t),"aria-current":t?void 0:`true`,onClick:()=>n(null),"data-sw-pages-journey":`none`,children:[(0,Y.jsx)(Sh,{size:14,"aria-hidden":`true`,className:f(!t)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`None`}),(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:`Show all pages`})]})}):null,u.map(e=>{let r=e.id===t;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,className:d(r),"aria-current":r?`true`:void 0,onClick:()=>n(r?null:e.id),"data-sw-pages-journey":e.id,children:[(0,Y.jsx)(Qg,{size:14,"aria-hidden":`true`,className:f(r)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name||e.id}),(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-faint tabular`,children:XD(e)})]})},e.id)}),l&&!u.length?(0,Y.jsxs)(`li`,{className:`px-2.5 py-3 text-sm text-muted`,children:[`No journey matches "`,o.trim(),`".`]}):null,e.length?null:(0,Y.jsx)(`li`,{className:`px-2.5 py-2 text-xs text-muted`,children:`No journeys yet.`}),r&&i?(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,className:K(BO,`text-muted hover:bg-surface-2 hover:text-fg`),onClick:i,"data-sw-journeys-new":`true`,children:[(0,Y.jsx)(Hg,{size:14,"aria-hidden":`true`,className:`shrink-0`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`New journey`})]})}):null]})]})}function HO({groups:e,comments:t,activePage:n,onPage:r,bare:i=!1}){let[a,o]=(0,J.useState)(``),[s,c]=(0,J.useState)(()=>new Set),l=a.trim().toLowerCase(),u=(0,J.useMemo)(()=>{let e=new Map;for(let n of t||[])n.status===`open`&&e.set(n.pageId,(e.get(n.pageId)||0)+1);return e},[t]),d=e.map(e=>({...e,pages:l?e.pages.filter(t=>`${t.title} ${t.path||``} ${e.group}`.toLowerCase().includes(l)):e.pages})).filter(e=>e.pages.length),f=e=>c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),p=e.reduce((e,t)=>e+t.pages.length,0);return(0,Y.jsxs)(`div`,{className:K(`flex w-full flex-col`,!i&&`border-t border-line pt-2`),"data-sw-pages-sidebar":`true`,children:[i?null:(0,Y.jsxs)(`p`,{className:`flex items-center px-2.5 pb-1 text-xs font-semibold text-faint`,children:[`Pages `,(0,Y.jsx)(`span`,{className:`ml-1 font-normal tabular`,children:p})]}),(0,Y.jsx)(`div`,{className:`pb-2`,children:(0,Y.jsx)(Ge,{size:`sm`,icon:n_,value:a,onChange:e=>o(e.target.value.slice(0,80)),placeholder:`Filter pages`,"aria-label":`Filter pages`,"data-sw-pages-filter":`true`})}),(0,Y.jsxs)(`div`,{className:`pb-2`,children:[d.map(e=>{let t=s.has(e.group)&&!l;return(0,Y.jsxs)(`section`,{className:`mb-1`,"data-sw-pages-group":e.group,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center gap-1 rounded-md px-2.5 text-xs font-semibold text-muted outline-none hover:text-fg focus-visible:outline-2 focus-visible:outline-accent`,"aria-expanded":!t,onClick:()=>f(e.group),children:[(0,Y.jsx)(H,{size:13,"aria-hidden":`true`,className:K(`transition-transform`,t&&`-rotate-90`)}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate`,children:e.group}),(0,Y.jsx)(`span`,{className:`ml-auto font-normal text-faint tabular`,children:e.pages.length})]}),t?null:(0,Y.jsx)(`ul`,{className:`ml-4`,children:e.pages.map((t,i)=>{let a=u.get(t.id)||0,o=t.id===n,s=i===e.pages.length-1;return(0,Y.jsx)(`li`,{className:K(`relative pl-3 before:pointer-events-none before:absolute before:top-0 before:left-0 before:h-4 before:w-2.5 before:rounded-bl-md before:border-b before:border-l`,o?`before:border-accent/60`:`before:border-line-strong/70`,!s&&`after:pointer-events-none after:absolute after:inset-y-0 after:left-0 after:border-l after:border-line-strong/70`),"data-sw-pages-wire":`true`,children:(0,Y.jsxs)(`button`,{type:`button`,className:K(`flex h-8 w-full items-center gap-2 rounded-md px-2 text-left text-[13px] outline-none focus-visible:outline-2 focus-visible:outline-accent`,o?`bg-accent/10 text-fg`:`text-fg/90 hover:bg-surface-2`),"aria-current":o?`true`:void 0,onClick:()=>r(t.id),"data-sw-pages-item":t.id,children:[(0,Y.jsx)(Eh,{size:14,"aria-hidden":`true`,className:K(`shrink-0`,o?`text-accent`:`text-faint`)}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t.title}),a?(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-muted tabular`,"aria-label":`${a} open`,children:a}):null]})},t.id)})})]},e.group)}),l&&!d.length?(0,Y.jsxs)(`p`,{className:`px-2.5 py-3 text-sm text-muted`,children:[`Nothing matches "`,a.trim(),`".`]}):null]})]})}var UO=`shapewall.sidebar.nav`,WO=[`pages`,`journeys`];function GO(){try{let e=window.localStorage.getItem(UO);return WO.includes(e)?e:`pages`}catch{return`pages`}}function KO({className:e=``}){return(0,Y.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-accent ${e}`,"aria-hidden":`true`,"data-sw-journey-dot":`true`})}function qO({groups:e,journeys:t=[],comments:n,activePage:r,journeyId:i,onPage:a,onJourney:o,canEditJourneys:s,onNewJourney:c}){let[l,u]=(0,J.useState)(GO),d=e.reduce((e,t)=>e+t.pages.length,0);if(!t.length&&!s)return(0,Y.jsx)(HO,{groups:e,comments:n,activePage:r,onPage:a});let f=e=>{u(e);try{window.localStorage.setItem(UO,e)}catch{}},p=`gap-1`;return(0,Y.jsxs)(ye,{value:l,onValueChange:f,className:`flex w-full flex-col border-t border-line pt-2`,"data-sw-sidebar-nav":l,children:[(0,Y.jsxs)(Ae,{"aria-label":`Pages and journeys`,className:`mb-2`,children:[(0,Y.jsxs)(Le,{value:`pages`,className:p,"data-sw-sidebar-tab":`pages`,children:[`Pages `,(0,Y.jsx)(`span`,{className:`font-normal text-faint tabular`,children:d})]}),(0,Y.jsxs)(Le,{value:`journeys`,className:p,"data-sw-sidebar-tab":`journeys`,children:[`Journeys `,(0,Y.jsx)(`span`,{className:`font-normal text-faint tabular`,children:t.length}),i?(0,Y.jsx)(KO,{className:`ml-0.5`}):null]})]}),(0,Y.jsx)(oe,{value:`pages`,tabIndex:-1,children:(0,Y.jsx)(HO,{bare:!0,groups:e,comments:n,activePage:r,onPage:a})}),(0,Y.jsx)(oe,{value:`journeys`,tabIndex:-1,children:(0,Y.jsx)(VO,{bare:!0,journeys:t,journeyId:i,onJourney:o,canEditJourneys:s,onNewJourney:c})})]})}function JO({info:e,localSettingsAvailable:t,setShareOpen:n}){let r=[{id:`board`,label:`Board`,icon:eg,href:`./`,active:!0}],i=e?.consoleUrl&&!e?.guest?e.consoleUrl:null;return i?(r.push({id:`workspace`,label:`Workspace`,icon:Jm,href:i}),r.push({id:`account`,label:`Account and security`,icon:M_,href:zO(i)})):t&&(r.push({id:`workspace`,label:`Workspace`,icon:Jm,href:`/console`}),r.push({id:`account`,label:`Account and security`,icon:M_,href:`/account`})),e?.shareEnabled&&r.push({id:`share`,label:`Share with your team`,icon:c_,onSelect:()=>n(!0)}),r}function YO({info:e,localName:t,onOpenBuzz:n,demo:r,localSettingsAvailable:i,settingsAvailable:a,openSettings:o,setShareOpen:s,expanded:c,onToggle:l,pages:u,quiet:d=!1}){let f=!!e&&!e.guest&&!e.public&&!e.share,p=typeof window>`u`?null:new URLSearchParams(window.location.search).get(`board`);(0,J.useEffect)(()=>{f&&OD(window.location.pathname+(p?`?board=`+encodeURIComponent(p):``))},[f,p]);let m=JO({info:e,localSettingsAvailable:i,setShareOpen:s}),h=!!u&&(u.journeys?.length>0||u.canEditJourneys),g=(e,t)=>n=>{e(),t?.(n)},_=!c&&u?[{id:`pages`,label:`Pages`,icon:Oh,flyout:({close:e})=>(0,Y.jsx)(HO,{groups:u.groups,comments:u.comments,activePage:u.activePage,onPage:g(e,u.onPage)})},...h?[{id:`journeys`,label:`Journeys`,icon:Qg,dot:!!u.journeyId,"data-sw-rail-journeys":u.journeyId||`none`,flyout:({close:e})=>(0,Y.jsx)(VO,{journeys:u.journeys,journeyId:u.journeyId,onJourney:g(e,u.onJourney),canEditJourneys:u.canEditJourneys,onNewJourney:u.onNewJourney?()=>g(e,u.onNewJourney)():null})}]:[]]:[];return(0,Y.jsx)(WD,{expanded:c,onToggle:l,home:`./`,homeLabel:`Shapewall`,title:e?.project?.name||e?.title,logo:(0,Y.jsx)(`img`,{src:`./favicon.svg`,alt:``,className:`h-7 w-7`}),items:m,sections:_,flyoutsDisabled:d,profile:c=>(0,Y.jsx)(oO,{info:e,localName:t,onOpenBuzz:n,demo:r,localSettingsAvailable:i,settingsAvailable:a,openSettings:o,setShareOpen:s,side:`right`,align:`end`,showName:c,triggerClassName:c?`w-full justify-start`:`w-10 min-w-10 px-0`}),children:u?(0,Y.jsx)(qO,{...u}):null})}var XO=(0,J.lazy)(()=>xT(()=>import(`./QuickConnect-DyfPSWbV.js`).then(e=>e.a).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([7,1,5,2]),import.meta.url)),ZO=(0,J.lazy)(()=>xT(()=>import(`./History-U0bD1BjA.js`),__vite__mapDeps([8,1]),import.meta.url)),QO=(0,J.lazy)(()=>xT(()=>import(`./ShareDialog-BouvNraR.js`).then(e=>({default:e.ShareDialog})),__vite__mapDeps([9,1]),import.meta.url)),$O=(0,J.lazy)(()=>xT(()=>import(`./LocalSettings-DOSuW7VC.js`),__vite__mapDeps([10,1,7,5,2]),import.meta.url));function ek({info:e,boardId:t,boards:n,wide:i,shareOpen:a,setShareOpen:o,refetchView:s,settingsAvailable:l,settingsOpen:u,updateParams:d,onInfoChanged:f,generalSettingsOpen:p,updates:m,historyPage:h,closeHistory:g,historyViewport:_,historyPageId:v,data:y,comments:b,filter:x,focusComment:S,onImageError:C,captureConfirm:w,setCaptureConfirm:T,busy:E,focusedPage:D,findPage:O,startCapture:k}){let A=ge(a),j=ge(u);return(0,Y.jsxs)(Y.Fragment,{children:[e?.shareEnabled&&A?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(QO,{open:a,onClose:()=>o(!1),boardId:t,onMoved:s})}):null,l&&j?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(XO,{open:u,onClose:()=>d({settings:null}),onSaved:f,touch:!i,buzz:e?.buzzAvailable===!0})}):null,p?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)($O,{open:!0,onClose:()=>d({settings:null}),info:e,boardCount:n.length,onSaved:f,touch:!i,onOpenUpdates:()=>{d({settings:null}),m.current?.open()}})}):null,h?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(ZO,{open:!!h,onClose:g,page:h,viewport:_,data:y,comments:b.filter(e=>e.pageId===v&&e.viewport===_),urlFor:(e,n)=>c(t,e.kind,n?e.thumb:e.file,e.version),onPickComment:e=>{g(),d({filter:e.status===`resolved`&&x===`open`?`all`:null}),S(e)},touch:!i,onImageError:C})}):null,(0,Y.jsx)(M,{open:w,onClose:()=>E?null:T(!1),title:`Capture every page now?`,footer:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{size:i?`md`:`touch`,onClick:()=>T(!1),disabled:E,children:`Cancel`}),D&&O(D)?(0,Y.jsxs)(r,{size:i?`md`:`touch`,onClick:()=>k(null,[D]),disabled:E,"data-sw-capture-only":D,children:[`Only `,O(D).title]}):null,(0,Y.jsx)(r,{size:i?`md`:`touch`,variant:`default`,onClick:()=>k(),disabled:E,"data-sw-capture-confirm":`true`,children:`Capture all`})]}),children:(0,Y.jsxs)(`p`,{className:`p-5 text-sm text-muted`,children:[`Shapewall captures all `,y?.board?.pages.length||``,` pages at every viewport`,D&&O(D)?` (or only ${O(D).title}, the selected page)`:``,`. Comments stay where they are; pins on live pages follow their elements. The board updates when it finishes.`]})})]})}var tk=2;function nk(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function rk({canvasRef:e,flow:t,targets:n,viewports:r,settledZoom:i,setSettledZoom:a,comparePair:o,captures:s,variantsById:c}){let l=(0,J.useRef)(null),[u,d]=(0,J.useState)(()=>new Set),[f,p]=(0,J.useState)(()=>new Set),m=(0,J.useCallback)((e,t)=>{p(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),h=(0,J.useCallback)((e,t)=>o?null:e.startsWith(`variant:`)?c.get(e)?.files?.[t]?.live||null:s?.[e]?.[t]?.live||null,[o,s,c]),g=(0,J.useCallback)(()=>{let a=e.current?.getBoundingClientRect();if(!a?.width||!i){d(e=>e.size?new Set:e);return}let{x:o,y:s,zoom:c}=t.getViewport(),u=[];for(let[e,t]of Object.entries(n))for(let n of t.frames){if(!h(e,n.viewport))continue;let i=(t.x+n.x)*c+o,d=(t.y+n.y)*c+s,f=n.w*c,p=n.h*c;if(i>a.width||d>a.height||i+f<0||d+p<0)continue;let m=`${e}|${n.viewport}`,g=l.current===m,_=Math.min((r[n.viewport]?.width||1440)*.4,a.width*.5);f<(g?_/2:_)||u.push({key:m,rank:g?-1:Math.hypot(i+f/2-a.width/2,d+p/2-a.height/2)})}u.sort((e,t)=>e.rank-t.rank);let f=new Set(u.slice(0,tk).map(e=>e.key));l.current&&!f.has(l.current)&&(l.current=null),d(e=>nk(e,f)?e:f)},[e,t,n,h,i,r]);return(0,J.useEffect)(()=>{g()},[g]),{liveKeys:u,readyKeys:f,setLiveReady:m,liveFileFor:h,recomputeLive:g,openLive:(0,J.useCallback)((r,i)=>{let o=n[r],s=o?.frames.find(e=>e.viewport===i),c=e.current?.getBoundingClientRect();s&&c?.width&&(l.current=`${r}|${i}`,a(null),t.fitBounds({x:o.x+s.x,y:o.y+s.y,width:s.w,height:Math.min(s.h,s.w*(c.height/c.width))},{padding:.04,duration:kE(450)}))},[e,t,n,a])}}function ik({journey:e,builder:t,goStep:n,step:r,closeJourney:i}){(0,J.useEffect)(()=>{if(!e||t)return;let a=e=>{if(e.defaultPrevented||e.altKey||e.ctrlKey||e.metaKey||document.querySelector(`[role="dialog"]`))return;let t=e.target;t?.isContentEditable||[`INPUT`,`TEXTAREA`,`SELECT`].includes(t?.tagName)||t?.closest?.(`[role="listbox"], [role="menu"]`)||((e.key===`ArrowRight`||e.key===`ArrowLeft`)&&(e.preventDefault(),n(r+(e.key===`ArrowRight`?1:-1))),e.key===`Escape`&&!document.querySelector(`[data-sw-thread-popover], [data-sw-composer-popover]`)&&(e.preventDefault(),i()))};return window.addEventListener(`keydown`,a),()=>window.removeEventListener(`keydown`,a)},[t,i,n,e,r])}function ak({commentMode:e,setCommentMode:t,canComment:n,comparePair:r,setDraft:i}){(0,J.useEffect)(()=>{if(!e)return;let n=e=>{e.key!==`Escape`||vS(e.target)||document.querySelector(`[role="dialog"], [role="menu"], [role="listbox"]`)||t(!1)};return window.addEventListener(`keydown`,n,!0),()=>window.removeEventListener(`keydown`,n,!0)},[e,t]),(0,J.useEffect)(()=>{if(!n||r)return;let e=e=>{if(e.defaultPrevented&&!Ue(e)||e.altKey||e.ctrlKey||e.metaKey||e.repeat||e.key!==`c`&&e.key!==`C`)return;let n=e.target;n?.isContentEditable||[`INPUT`,`TEXTAREA`,`SELECT`].includes(n?.tagName)||document.querySelector(`[role="dialog"]:not([data-sw-thread-popover]), [role="menu"], [role="listbox"]`)||(e.preventDefault(),i(null),t(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,r,t,i])}function ok({journeys:e,journey:t,builder:n,openJourney:r,closeJourney:i}){(0,J.useEffect)(()=>{if(!e.length||n)return;let a=n=>{if(n.defaultPrevented&&!Ue(n)||n.altKey||n.ctrlKey||n.metaKey||n.repeat||n.key!==`j`&&n.key!==`J`||vS(n.target)||document.querySelector(`[role="dialog"]:not([data-sw-thread-popover]), [role="menu"], [role="listbox"]`))return;n.preventDefault();let a=t?e.findIndex(e=>e.id===t.id):-1,o=e.length+1,s=(a+1+(n.shiftKey?-1:1)+o)%o-1;s<0?i():r(e[s].id)};return window.addEventListener(`keydown`,a),()=>window.removeEventListener(`keydown`,a)},[n,i,t,e,r])}function sk(e){return!!e&&typeof e==`object`&&!Array.isArray(e)&&Array.isArray(e.branches)}function ck(e){let t=new Set,n=e=>{for(let r of e||[])if(typeof r==`string`)t.add(r);else if(sk(r))for(let e of r.branches)n(e.steps)};return n(e),[...t]}function lk(e){let t=[],n=[],r=(e,i,a)=>{let o=a;return e.forEach((e,a)=>{let s=i?`${i}:${a}`:String(a);if(typeof e==`string`){t.push({key:s,pageId:e});for(let e of o)n.push({from:e.key,to:s,label:e.label||null,branch:e.branch||null});o=[{key:s}];return}if(!sk(e))return;let c=[];e.branches.forEach((e,t)=>{let n=o.map(t=>({key:t.key,label:e.label,branch:e.id})),i=r(e.steps,`${s}:${t}`,n);e.end||c.push(...i)}),o=c}),o};return r(e||[],``,[]),{nodes:t,edges:n}}function uk(e,t=[]){let n=[],r=[],i=!1,a=(e,o,s)=>{for(let c=0;c<e.length;c+=1){if(i)return;let l=e[c],u=o?`${o}:${c}`:String(c);if(typeof l==`string`){n.push({key:u,pageId:l,branch:s});continue}if(!sk(l)||!l.branches.length)continue;let d=t[r.length],f=Math.max(0,l.branches.findIndex(e=>e.id===d)),p=l.branches[f];r.push({afterStep:n.length,options:l.branches.map(e=>({id:e.id,label:e.label,end:!!e.end})),chosen:p.id}),a(p.steps,`${u}:${f}`,p.label),p.end&&(i=!0)}};return a(e||[],``,null),{steps:n,forks:r,ended:i}}function dk(e,t,n){return[...e.forks.slice(0,t).map(e=>e.chosen),n]}function fk({boardId:e,view:t,updateParams:n,clearFocus:r,setCommentMode:i,journey:a,route:o,routePages:s,step:c,builder:l,setBuilder:u,busy:d,setBusy:f,setNotice:p,flow:m,targets:h,nodesReady:g,mode:_,comparePair:v,setSettledZoom:y}){let b=(0,J.useCallback)(e=>{r(),n({j:e||null,step:e?1:null,jc:null,jb:null})},[r,n]),x=(0,J.useCallback)(()=>n({j:null,step:null,jc:null,jb:null}),[n]),S=(0,J.useCallback)(e=>{s&&n({step:J_(e,s.length)})},[s,n]),C=(0,J.useCallback)((e,t)=>{o&&n({jb:dk(o,e,t).join(`,`)})},[o,n]),w=(0,J.useRef)(null);(0,J.useEffect)(()=>{if(!a||!g||l){a||(w.current=null);return}let e=s[c-1],t=`${a.id}:${c}:${e}:${_}:${v}`;if(w.current===t)return;let n=h[e];n&&(w.current=t,y(null),m.fitBounds({x:n.x,y:n.y-48,width:n.w,height:n.h+48},{padding:.18,duration:kE(450)}))},[l,v,m,a,h,_,g,s,y,c]),ik({journey:a,builder:l,goStep:S,step:c,closeJourney:x});let T=(0,J.useCallback)((e=null)=>{i(!1),r(),u(e?{id:e.id,name:e.name,steps:structuredClone(e.steps),into:null}:{id:null,name:``,steps:[],into:null})},[r,u,i]),E=(0,J.useCallback)(e=>{u(t=>{if(!t||ck(t.steps).length>=50)return t;let n=structuredClone(t.steps),r=(t.into?n[t.into.fork]:null)?.branches?.[t.into.branch]?.steps||n;return r[r.length-1]===e?t:(r.push(e),{...t,steps:n})})},[u]),D=`/api/boards/${encodeURIComponent(e)}/journeys`;return{openJourney:b,closeJourney:x,goStep:S,chooseJourneyBranch:C,startBuilder:T,addBuilderStep:E,saveBuilder:async()=>{if(l&&!d){f(!0);try{let e={name:l.name,steps:l.steps},n=l.id?await Ke.patch(`${D}/${encodeURIComponent(l.id)}`,e):await Ke.post(D,e);await t.refetch(),u(null),w.current=null,b(n.journey.id)}catch(e){p({tone:`bad`,text:e.message||`The journey was not saved.`})}finally{f(!1)}}},removeJourney:async()=>{if(a&&!d){f(!0);try{await Ke.delete(`${D}/${encodeURIComponent(a.id)}`),x(),t.refetch()}catch(e){p({tone:`bad`,text:e.message||`The journey was not deleted.`})}finally{f(!1)}}}}}function pk({boardId:e,commentsQuery:t,view:n,info:r,localName:i,authorName:a,setBusy:o,setNotice:s,setToast:c,setDeletingIds:l,selectedCommentId:u,closeThread:d,wide:f,filter:p,allowed:m}){let h=(0,J.useRef)(new Map),g=(e,r=!1,{counts:i=!0}={})=>{t.setData(t=>{let n=Array.isArray(t?.comments)?t.comments:[];return r?{comments:n.filter(t=>t.id!==e.id)}:{comments:n.some(t=>t.id===e.id)?n.map(t=>t.id===e.id?e:t):[e,...n]}}),i&&n.refetch()},_=`/api/boards/${encodeURIComponent(e)}/comments`,v=async(e,t)=>{o(!0);try{let n=await Ke.post(`${_}/${e.id}/${t}`,{author:a()||void 0});g(n.comment),f&&t===`resolve`&&p===`open`&&d(),t===`resolve`&&m(`resolve`)&&c({at:Date.now(),text:`Resolved comment #${e.id}.`,undo:()=>v(n.comment,`reopen`)})}catch(e){s({tone:`bad`,text:e.message||`That did not save.`})}finally{o(!1)}},y=async(e,t,n={})=>{let{onImageError:r,images:i,drawing:c}=n;o(!0);try{let n=await Ke.post(`${_}/${e.id}/replies`,{body:t,author:a()||void 0,...i?.length?{images:i}:{},...c?{drawing:c}:{}});return g(n.comment),!0}catch(e){return r&&/image/.test(e.code||``)?r(e.message||`An image was not accepted.`):s({tone:`bad`,text:e.message||`That reply did not save.`}),!1}finally{o(!1)}},b=async(e,t)=>{o(!0);try{let n=await Ke.patch(`${_}/${e.id}`,{body:t});return g(n.comment),!0}catch(e){return s({tone:`bad`,text:e.message||`That edit did not save.`}),!1}finally{o(!1)}},x=async(e,t,n=null)=>{try{let a=await Ke.post(`${_}/${e.id}/reactions`,{emoji:t,...n?{replyId:n}:{},...r?.hosted?{}:{author:i||void 0}});g(a.comment,!1,{counts:!1})}catch(e){s({tone:`bad`,text:e.message||`That reaction did not save.`})}},S=async e=>{let t=new URL(window.location.href);t.searchParams.set(`c`,String(e.id)),t.searchParams.delete(`v`);try{await navigator.clipboard.writeText(t.href),s({tone:`info`,text:`Copied the link to comment #${e.id}.`})}catch{s({tone:`info`,text:`Link to comment #${e.id}: ${t.href}`})}},C=async e=>{o(!0);try{let t=await Ke.post(`${_}/${e.id}/github/issue`,{});g(t.comment),s({tone:`info`,text:`${t.created?`Opened`:`Already has`} GitHub issue #${t.issue.number}.`})}catch(e){s({tone:`bad`,text:e.message||`The GitHub issue was not created.`})}finally{o(!1)}},w=e=>{h.current.delete(e),l(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},T=async e=>{let t=h.current.get(e.id);if(t){window.clearTimeout(t.timer);try{await Ke.delete(`${_}/${e.id}`),g(e,!0)}catch(e){s({tone:`bad`,text:e.message||`That did not delete.`})}finally{w(e.id)}}},E=(0,J.useRef)(T);return E.current=T,(0,J.useEffect)(()=>{let e=()=>{for(let{comment:e}of[...h.current.values()])E.current(e)};return window.addEventListener(`pagehide`,e),()=>{window.removeEventListener(`pagehide`,e),e()}},[]),{commentsUrl:_,applyComment:g,setStatus:v,replyTo:y,editComment:b,reactTo:x,copyLink:S,githubIssue:C,removeComment:async e=>{u===e.id&&d(),l(t=>new Set(t).add(e.id));let t=window.setTimeout(()=>E.current(e),6e3);h.current.set(e.id,{comment:e,timer:t}),c({at:Date.now(),text:`Deleted comment #${e.id}.`,undo:()=>{window.clearTimeout(t),w(e.id)}})},sendToAgent:async e=>{let{dispatchHash:n}=e,i=!!(e.needsRunApproval&&[`admin`,`owner`].includes(r.role));o(!0);try{i&&await zT();let t=await Ke.post(`${_}/${e.id}/send-to-agent`,{dispatchHash:n,approve:i});g(t.comment)}catch(e){e.code===`comment_changed`?(t.refetch(),s({tone:`bad`,text:`This comment changed while you were approving it. Read it again, then send it.`})):s({tone:`bad`,text:e.message})}finally{o(!1)}}}}function mk(e){let[t,n]=(0,J.useState)(null),[r,i]=(0,J.useState)(!1),[a,s]=(0,J.useState)(()=>new Set),c=Xe(`/api/boards/${encodeURIComponent(e)}`,{pollMs:r||t?2e3:o?0:3e4}),l=Xe(`/api/boards/${encodeURIComponent(e)}/comments`,{pollMs:o?0:t?1e3:2e4}),u=c.data,d=u?.capture;return(0,J.useEffect)(()=>{i(!!d?.running)},[d?.running]),{view:c,commentsQuery:l,data:u,capture:d,comments:(0,J.useMemo)(()=>{let e=Array.isArray(l.data?.comments)?l.data.comments:[];return a.size?e.filter(e=>!a.has(e.id)):e},[l.data,a]),fixRequest:t,setFixRequest:n,setPolling:i,deletingIds:a,setDeletingIds:s}}function hk({params:e,data:t,builder:n}){let r=(0,J.useMemo)(()=>Array.isArray(t?.journeys)?t.journeys:[],[t?.journeys]),i=n?null:r.find(t=>t.id===e.get(`j`))||null,a=e.get(`jb`)||``,o=(0,J.useMemo)(()=>i?uk(i.steps,a.split(`,`).filter(Boolean)):null,[i,a]),s=(0,J.useMemo)(()=>i?lk(i.steps):null,[i]),c=(0,J.useMemo)(()=>o?o.steps.map(e=>e.pageId):null,[o]);return{journeys:r,journey:i,route:o,routeGraph:s,routePages:c,step:J_(e.get(`step`),c?.length||0),journeyComments:!!i&&e.get(`jc`)===`1`}}var gk=40;function _k({pendingFocus:e,setPendingFocus:t,targets:n,viewports:r,flow:i,canvasRef:a,wide:o,setSettledZoom:s}){(0,J.useEffect)(()=>{if(!e)return;let c=Bv(n,e);if(!c){n[e.pageId]&&r[e.viewport]||t(null);return}t(null),s(null);let l=Math.max(i.getZoom(),1.2),u=a.current?.getBoundingClientRect(),d=n[e.pageId];if(o||!u?.width||!d){i.setCenter(c.x,c.y,{zoom:l,duration:kE(450)});return}let f=u.height*.28-c.y*l;d.y*l+f<gk&&(f=Math.min(gk-d.y*l,u.height*.45-c.y*l)),i.setViewport({x:u.width/2-c.x*l,y:f,zoom:l},{duration:kE(450)})},[a,i,n,e,t,s,r,o])}function vk({wide:e,nodesReady:t,initialCamera:n,selectedCommentId:r,canvasRef:i,nodes:a,flow:o,setSettledZoom:s}){let c=(0,J.useRef)(!1);(0,J.useEffect)(()=>{if(e||c.current||!t||(c.current=!0,n.current||r))return;let l=i.current?.getBoundingClientRect(),u=a.find(e=>e.type===`groupFrame`),d=u&&a.find(e=>e.type===`page`&&e.data?.page?.group===u.data.group);if(!l?.width||!u||!d){o.fitView(ME);return}let f=Math.min(u.width,d.width*2+72+2*(d.position.x-u.position.x)),p=Math.min(1.5,Math.max(.05,(l.width-16)/f)),m=12+44*Math.max(p,.45);s(null),o.setViewport({x:8-u.position.x*p,y:m-u.position.y*p,zoom:p})},[i,o,n,a,t,r,s,e])}function yk({mode:e,pendingFocus:t,shapeKey:n,clearFocus:r,fitBoard:i}){let a=(0,J.useRef)(e);(0,J.useEffect)(()=>{if(a.current===e||(a.current=e,r(),t))return;let n=window.setTimeout(i,60);return()=>window.clearTimeout(n)},[r,i,e,t]);let o=(0,J.useRef)(n);(0,J.useEffect)(()=>{if(o.current===n)return;o.current=n,r();let e=window.setTimeout(i,60);return()=>window.clearTimeout(e)},[r,i,n])}function bk({nodesReady:e,data:t,commentsLoaded:n,selectedCommentId:r,selectedComment:i,initialCamera:a,focusComment:o,deletingIds:s,setNotice:c,updateParams:l}){let u=(0,J.useRef)(!1);(0,J.useEffect)(()=>{!u.current&&e&&t&&(!r||n)&&(u.current=!0,i&&!a.current&&o(i))},[n,t,o,a,e,i,r]);let d=(0,J.useRef)(null);(0,J.useEffect)(()=>{r&&n&&!i&&!s.has(r)&&d.current!==r&&(d.current=r,c({tone:`bad`,text:`Comment #${r} was not found on this board. It may have been deleted.`}),l({c:null}))},[n,s,i,r,c,l])}function xk({selectedComment:e,visibleComments:t,focusComment:n,mode:r,viewports:i,modes:a}){let o=(0,J.useMemo)(()=>e&&!t.some(t=>t.id===e.id)?[e,...t]:t,[e,t]),s=e?o.findIndex(t=>t.id===e.id):-1;return{threadList:o,threadIndex:s,stepThread:e=>{o.length<2||s<0||n(o[(s+e+o.length)%o.length])},neighborNote:e=>{if(o.length<2||s<0||r===`all`)return null;let t=o[(s+e+o.length)%o.length];return t.viewport===r||!i[t.viewport]?null:`switches to ${a.find(e=>e.id===t.viewport)?.label||t.viewport}`}}}var Sk=[`issues`,`pages`,`seo`,`performance`,`history`],Ck=e=>Sk.includes(e)&&e!==`issues`?e:null;function wk({boardId:e,info:t,params:n,updateParams:r,pages:i}){let a=!!t?.checksAvailable,s=a&&!!n.get(`checks`),c=i?.some(e=>e.id===n.get(`checks`))?n.get(`checks`):null,l=n.get(`cv`)||null,u=Sk.includes(n.get(`ct`))?n.get(`ct`):`issues`,d=/^[a-z0-9][a-z0-9-]{0,63}$/.test(n.get(`ce`)||``)?n.get(`ce`):null,f=`/api/boards/${encodeURIComponent(e)}/checks`,p=d?`?env=${encodeURIComponent(d)}`:``,m=Xe(a?`${f}${p}`:null,{pollMs:o?0:3e4}),h=Xe(a&&s&&!o?`${f}/seo${p}`:null),g=a&&!o&&!t?.hosted,[_,v]=(0,J.useState)(!1),y=Xe(g&&s?`${f}/run`:null,{pollMs:_?1500:0}),b=y.data?.run||null,x=b?.state===`running`;(0,J.useEffect)(()=>v(x),[x]);let S=(0,J.useRef)(!1),{refetch:C}=m,{refetch:w}=h;(0,J.useEffect)(()=>{S.current&&!x&&(C(),w()),S.current=x},[x,C,w]);let[T,E]=(0,J.useState)(null),[D,O]=(0,J.useState)(!1),k=(0,J.useCallback)(async({pages:e=null,seo:t=!0}={})=>{O(!0),E(null);try{return await Ke.post(`${f}/run`,{seo:t,...e?{pages:e}:{},...d?{env:d}:{}}),v(!0),await y.refetch(),!0}catch(e){return E(e.message||`The checks run did not start.`),y.refetch(),!1}finally{O(!1)}},[f,d,y]),[A,j]=(0,J.useState)(!1),M=(0,J.useCallback)(async()=>{j(!0),E(null);try{await Ke.delete(`${f}/run`)}catch(e){E(e.message||`The checks run could not be stopped.`)}finally{j(!1),y.refetch()}},[f,y]),N=(0,J.useCallback)((e=null,t=null,n=null)=>r({checks:e||`all`,cv:t,chat:null,...n?{ct:Ck(n)}:{}}),[r]),P=(0,J.useCallback)(e=>r({ct:Ck(e)}),[r]),F=(0,J.useCallback)(()=>r({checks:null,cv:null,ct:null}),[r]),ee=(0,J.useMemo)(()=>{let e=new Map;for(let t of m.data?.views||[]){if([`stale`,`failed`].includes(t.state))continue;let n=t.runs?.reduce((e,t)=>e+(t.state===`stale`?0:t.actionable),0)??t.actionable;e.set(t.pageId,(e.get(t.pageId)||0)+n)}return e},[m.data]),I=g?{loading:y.loading,canRun:!!y.data?.canRun,reason:y.data?.reason||null,limit:y.data?.limit||100,privatePages:y.data?.privatePages||[],seoDefault:y.data?.seoDefault!==!1,run:b,starting:D,error:T,start:k,stop:M,stopping:A}:null,L=[`shapewall checks run`,`--board ${e}`,c?`--only ${c}`:null,d?`--env ${d}`:null,u===`seo`?`--seo`:null,`--limit 100`].filter(Boolean).join(` `);return{canChecks:a,checksOpen:s,checksPage:c,checksViewport:l,checksEnvironment:d,checksTab:u,setChecksTab:P,checksQuery:m,seoQuery:h,checksRun:I,checksPanelProps:{tab:u,onTab:P,seo:h.error?null:h.data,run:I,command:L},openChecks:N,closeChecks:F,checksCounts:ee}}function Tk({boardId:e,info:t,params:n,updateParams:r}){let i=!o&&!!t?.agent&&!(t?.remote?.noRemoteChat&&t?.remote?.kind!==`host`),a=n.get(`chat`)||``,s=i?ww(a):null,c=!!(t?.agent?.settingsEditable||t?.agent?.settingsReadonly),l=!o&&!E&&!t?.consoleUrl&&!t?.workspace&&!t?.hosted&&!t?.guest,u=l&&n.get(`settings`)===`general`,d=c&&n.get(`settings`)===`agent`,f=(0,J.useCallback)(()=>r({settings:`agent`}),[r]);return(0,J.useEffect)(()=>{s&&Dw(e,Cw(s))},[e,s]),{chatAvailable:i,chatThread:s,reopenChat:(0,J.useCallback)(()=>r({chat:Ow(e),checks:null,cv:null}),[e,r]),settingsAvailable:c,localSettingsAvailable:l,generalSettingsOpen:u,settingsOpen:d,openSettings:f,openChat:(0,J.useCallback)(e=>{r({chat:Cw(e),checks:null,cv:null})},[r])}}function Ek({boardId:e,params:t,updateParams:n,environmentList:r,setCommentMode:i,pageCount:a=0}){let o=(0,J.useMemo)(()=>Array.isArray(r)?r:[],[r]),s=(0,J.useMemo)(()=>{let[e,n]=String(t.get(`cmp`)||``).split(`_`),r=o.map(e=>e.id);return e&&n&&e!==n&&r.includes(e)&&r.includes(n)?[e,n]:null},[t.get(`cmp`),o]),c=t.get(`changed`),l=a>=30,u=!!s&&(c===`1`||c!==`0`&&l),d=e=>n({changed:e===l?null:e?`1`:`0`}),f=t.get(`diff`)!==`off`,p=Xe(s?`/api/boards/${encodeURIComponent(e)}/compare?a=${s[0]}&b=${s[1]}`:null),m=s&&p.data?.a===s[0]&&p.data?.b===s[1]?p.data:null,h=(0,J.useMemo)(()=>{if(!s)return null;let[e,t]=s,n=new Map(o.map(e=>[e.id,e])),r=o.find(e=>e.default)?.id;return{a:e,b:t,files:m?.files||{},failures:m?.failures||{},pages:m?.pages||{},showDiff:f,kindOf:e=>e===r?`captures`:`envs/${e}`,versionOf:e=>n.get(e)?.capturedAt||`none`,titleOf:e=>n.get(e)?.title||e,diffKind:`diffs/${e}_${t}`,diffVersion:`${n.get(e)?.capturedAt}|${n.get(t)?.capturedAt}`}},[m,s,o,f]),g=e=>{i(!1),n({cmp:e?e.join(`_`):null,changed:e?t.get(`changed`):null,diff:e?t.get(`diff`):null})};return{environments:o,comparePair:s,changedOnly:u,setChangedOnly:d,showDiff:f,compareQuery:p,compareData:m,compareView:h,setCompare:g,canCompare:o.length>1,toggleCompare:()=>g(s?null:[o[0].id,o[1].id])}}function Dk({comments:e,query:t,stateFilter:n,mentionFilter:r,titleOfPage:i,filter:a,journey:o,journeyComments:s}){let c=(0,J.useMemo)(()=>sv(e,{query:t,state:n,mention:r,titleOf:i}),[e,r,t,n,i]),l=(0,J.useMemo)(()=>{let e=s?new Set(o.pages||ck(o.steps)):null;return c.filter(t=>(a===`all`||t.status===a)&&(!e||e.has(t.pageId)))},[c,a,o,s]);return{narrowedComments:c,visibleComments:l,pinsByTarget:(0,J.useMemo)(()=>{let e=new Map;for(let t of l){let n=`${t.pageId}|${t.viewport}`;e.has(n)||e.set(n,[]),e.get(n).push(t)}return e},[l]),counts:{open:c.filter(e=>e.status===`open`).length,resolved:c.filter(e=>e.status===`resolved`).length}}}function Ok({targets:e,layoutEdges:t,links:n,showLinks:r,showAllLinks:i,activePage:a,builder:o,route:s,routeGraph:c,routePages:l,step:u,journey:d,targetTitle:f}){let p=(0,J.useMemo)(()=>new Set(Object.keys(e).filter(e=>!e.startsWith(`variant:`))),[e]),m=(0,J.useMemo)(()=>o?uk(o.steps).steps.map(e=>e.pageId):null,[o]),h=o?m:l,g=(0,J.useMemo)(()=>r&&!i?K_(n,p):null,[n,p,i,r]),_=(0,J.useMemo)(()=>o||!s?null:{graph:c,path:s.steps.map(e=>e.key)},[o,s,c]),v=(0,J.useMemo)(()=>[...t,...q_({links:n||{},showLinks:r,activePage:a,journeySteps:o?m:null,journeyRoute:_,currentStep:o?0:u,present:p,hideTargets:g}).map(e=>({...e,ariaLabel:e.id.startsWith(`link:`)?`Link from ${f(e.source)} to ${f(e.target)}`:`Journey${e.data?.label?` step ${e.data.label}`:``}: ${f(e.source)} to ${f(e.target)}`}))],[a,o,m,n,g,_,t,p,r,u,f]),y=(0,J.useMemo)(()=>{if(o||!d||!l)return null;let e=new Set(l);return new Set((d.pages||ck(d.steps)).filter(t=>!e.has(t)))},[o,d,l]);return{presentPages:p,shownSteps:h,hiddenLinkTargets:g,edges:v,journeyView:(0,J.useMemo)(()=>h?{steps:W_(h),offPath:y,currentStep:o?null:u,currentPage:o?null:h[u-1]}:null,[o,y,h,u])}}var kk=[];function Ak(e){let t=(0,J.useRef)(e);t.current=e;let{boardId:n,data:r,viewports:i,journeyView:a,compareView:s,commentMode:l,canComment:d,wide:f,hosted:p,imageVersion:m,pinsByTarget:h,me:g,checksCounts:_,canChecks:v,agentFocus:y,agentWorkingPages:b,setLiveReady:x,focusedKey:S,selectingKey:C,settledZoom:w,selectedComment:T,draftSpot:D,unread:O,liveKeys:k}=e,[A]=(0,J.useState)(()=>wb({focusedKey:S,selectingKey:C,settledZoom:w,selectedComment:T,draftSpot:D,unread:O,liveKeys:k}));(0,J.useLayoutEffect)(()=>{A.set({focusedKey:S,selectingKey:C,settledZoom:w,selectedComment:T,draftSpot:D,unread:O,liveKeys:k})},[A,S,C,w,T,D,O,k]);let j=(0,J.useMemo)(()=>{let e=()=>t.current;return{onFocusFrame:(t,n)=>{let{selectedCommentId:r,closeThread:i,builder:a,addBuilderStep:o,layout:s,flow:c,setSettledZoom:l,canvasRef:u,setFocusedKey:d}=e();if(r&&i(),a){t.startsWith(`variant:`)||o(t);return}let f=s.targets[t],p=f?.frames.find(e=>e.viewport===n);f&&p&&Av(p,c.getZoom())&&(l(null),c.fitBounds(NE({x:f.x+p.x,y:f.y,width:p.w,height:p.y+p.h},u.current?.getBoundingClientRect(),.08),{padding:.08,duration:kE(450)})),d(`${t}|${n}`)},onPin:t=>{let n=e(),{layout:r,flow:i,canvasRef:a}=n;n.selectedCommentId&&n.closeThread();let o=r.targets[t.pageId],s=o?.frames.find(e=>e.viewport===t.viewport),c=a.current?.getBoundingClientRect();if(!n.wide&&s&&c?.width&&s.w*i.getZoom()<c.width*.6){n.setSettledZoom(null);let e=Math.min(4,(c.width-16)/s.w),r=o.y+s.y+s.h*t.y/100;i.setViewport({x:8-(o.x+s.x)*e,y:c.height*.35-r*e,zoom:e},{duration:kE(450)}),n.setToast({at:Date.now(),text:`Zoomed in: tap the spot again to pin your comment.`,untilSheet:!0})}else n.setDraft(e=>({...t,body:e?.body||n.checkDraft||``,author:e?.author??n.authorName()})),n.setCheckDraft(``)},onSelectComment:t=>e().selectComment(t),onHoverComment:e=>A.set({hoveredId:e}),onOpenCluster:(t,n,r)=>e().openCluster(t,n,r),onChecks:(...t)=>e().openChecks(...t),onHistory:(t,n=null)=>e().openHistory(t,n),onShowViewport:t=>e().updateParams({vp:t===e().defaultMode?null:t}),onImageError:()=>e().onImageError()}},[A]);return{board:(0,J.useMemo)(()=>({boardId:n,captures:r?.captures||{},manifest:r?.manifest||null,counts:r?.commentCounts||{},viewports:i,journey:a,compare:s,commentMode:l&&d&&!s,touch:!f,imageUrl:(e,t,r)=>c(n,e,t,r||m),liveUrl:(e,t,r)=>we(n,e,t,r||m),elementsUrl:(e,t,r)=>u(n,e,t,r||m),domFallback:!o&&!E&&!p,setLiveReady:x,pinsFor:(e,t)=>s?kk:h.get(`${e}|${t}`)||kk,me:g,checksCount:e=>_.get(e)||0,historyCount:e=>iv(r?.versions,e),agentWorking:y,agentWorkingPages:b,onFocusFrame:j.onFocusFrame,onPin:j.onPin,onSelectComment:j.onSelectComment,onHoverComment:f?j.onHoverComment:null,onOpenCluster:j.onOpenCluster,onChecks:v?j.onChecks:null,onHistory:j.onHistory,onShowViewport:j.onShowViewport,onImageError:j.onImageError}),[j,y,b,n,v,d,_,l,s,r?.captures,r?.commentCounts,r?.manifest,r?.versions,p,m,a,g,h,x,i,f]),view:A}}function jk({boardId:e,view:t,setBusy:n,setNotice:r,setPolling:i}){let[a,o]=(0,J.useState)(!1);return{captureConfirm:a,setCaptureConfirm:o,startCapture:async(a=null,s=null)=>{n(!0);try{r({tone:`info`,text:(await Ke.post(`/api/boards/${encodeURIComponent(e)}/capture`,{...a?{env:a}:{},...s?{pages:s}:{}})).message||`Capture started.`}),i(!0),t.refetch()}catch(e){r({tone:`bad`,text:e.message||`The capture did not start.`})}finally{n(!1),o(!1)}}}}function Mk({draft:e,setDraft:t,busy:n,setBusy:r,commentsUrl:i,applyComment:a,markSeen:o,setLocalName:s,setNotice:c,updateParams:l,wide:u,filter:d,targetTitle:f,people:p,info:m,media:h={attach:!1,draw:!1,attachNote:null},pageImage:g=()=>null}){let _=Jb({enabled:h.attach}),v=e?`${e.pageId}|${e.viewport}`:null;(0,J.useEffect)(()=>{!v||!h.draw?sx.end(`composer`):sx.get()?.owner===`composer`?sx.moveTo(v,`composer`):sx.start(v,`composer`)},[v,h.draw]);let{clear:y}=_;return(0,J.useEffect)(()=>{e||y()},[e,y]),(0,J.useEffect)(()=>()=>sx.end(`composer`),[]),{draftDescription:e?`${f(e.pageId)} · ${e.viewport} · ${e.anchor?`on "${e.anchor.text||e.anchor.selector.split(` > `).pop()}"`:`${Math.round(e.x)}% across, ${Math.round(e.y)}% down`}`:``,composerProps:{draft:e,onChange:e=>t(t=>t&&{...t,...e}),onSubmit:async()=>{if(!(!e?.body.trim()||n||_.reading)){r(!0);try{let n=(e.author||``).trim();He(n);let r=sx.get(),c=r?.owner===`composer`&&r.key===v?r.shapes:[],f=qb(_.images),{comment:p}=await Ke.post(i,{pageId:e.pageId,viewport:e.viewport,x:e.x,y:e.y,body:e.body,author:n,...e.anchor?{anchor:e.anchor}:{},...f.length?{images:f}:{},...c.length?{drawing:lx(c)}:{}});sx.end(`composer`),t(null),s(n),a(p),o(p),l({c:u?p.id:null,filter:d===`all`?`all`:null})}catch(e){/image/.test(e.code||``)?_.setError(e.message||`An image was not accepted.`):c({tone:`bad`,text:e.message||`The comment was not saved.`})}finally{r(!1)}}},onCancel:()=>t(null),busy:n,people:p,hosted:!!m?.hosted,signedInAs:m?.user?.name||null,media:{...h,images:_,owner:`composer`,page:e&&h.draw?g(e.pageId,e.viewport):null,pageTitle:e?f(e.pageId):``}}}}function Nk({canComment:e,comparePair:t,commentMode:n,markPicked:r,setDraft:i,setCommentMode:a,showLinks:o,toggleLinks:s,canCompare:c,toggleCompare:l,wide:u,fitBoard:d,minimapOn:f,toggleMinimap:p,chatAvailable:m,reopenChat:h,canChecks:g,openChecks:_}){return[e&&!t?{id:`comment`,label:n?`Stop commenting`:`Comment on a page`,icon:Sg,keys:`C`,run:()=>{r(),i(null),a(e=>!e)}}:null,{id:`links`,label:o?`Hide links between pages`:`Show links between pages`,icon:I_,run:s},c?{id:`compare`,label:t?`Leave compare mode`:`Compare environments`,icon:Ph,run:l}:null,u?{id:`fit`,label:`Fit the whole board`,icon:bg,keys:`Shift 1`,run:d}:null,u?{id:`minimap`,label:f?`Hide the minimap`:`Show the minimap`,icon:vg,run:p}:null,m?{id:`agent`,label:`Chat with your agent`,icon:S,run:h}:null,g?{id:`checks`,label:`Open page checks`,icon:Ah,run:()=>_()}:null].filter(Boolean)}var Pk=30,Fk=28,Ik=240;function Lk(e){let t=1/e;return{"--sw-zoom":e.toFixed(4),"--sw-inv":t.toFixed(4),"--sw-title-scale":Math.min(t,96/Pk).toFixed(4),"--sw-title-fade":Math.max(0,Math.min(1,(e-.16)*25)).toFixed(3),"--sw-group-scale":Math.min(t,Ik/Fk).toFixed(4),"--sw-label-scale":Math.min(t,1.6).toFixed(4),"--sw-chip-scale":Math.min(t,1).toFixed(4)}}function Rk(){let e=Uu();return(0,J.useEffect)(()=>{let t=null,n=e=>{let n=e.transform[2],r=e.domNode;if(r&&n!==t){t=n;for(let[e,t]of Object.entries(Lk(n)))r.style.setProperty(e,t)}};return n(e.getState()),e.subscribe(n)},[e]),null}function zk({fitBoard:e,zoomTo:t}){let n=Vd();(0,J.useEffect)(()=>{let r=r=>{if(!(r.defaultPrevented||r.altKey||r.ctrlKey||r.metaKey||vS(r.target))&&!document.querySelector(`[role="dialog"], [role="menu"], [role="listbox"]`)){if(r.shiftKey&&r.code===`Digit1`)e();else if(r.shiftKey&&r.code===`Digit0`)t(1);else if(!r.shiftKey&&(r.key===`=`||r.key===`+`))n.zoomIn({duration:kE(200)});else if(!r.shiftKey&&r.key===`-`)n.zoomOut({duration:kE(200)});else return;r.preventDefault()}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,n,t])}function Bk({wide:e,clearFocus:n,setSettledZoom:r,minimapOn:i,liveKeys:o,toggleMinimap:s,hideFit:c,hideMinimap:l=!1,fitBoard:u}){let d=Vd(),f=$(e=>Math.round(e.transform[2]*100)),p=e=>{n(),r(null);let{x:t,y:i,zoom:a}=d.getViewport(),o=document.querySelector(`[data-sw-canvas]`)?.getBoundingClientRect(),s=(o?.width||0)/2,c=(o?.height||0)/2,l=e/a;d.setViewport({x:s-(s-t)*l,y:c-(c-i)*l,zoom:e},{duration:kE(250)})};if(zk({fitBoard:u,zoomTo:p}),!e)return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Rk,{}),(0,Y.jsx)($u,{position:`bottom-left`,className:K(`!m-2`,c&&`hidden`),children:(0,Y.jsx)(z,{size:`icon`,variant:`secondary`,className:`bg-surface/95 shadow-pop backdrop-blur`,onClick:u,label:`Fit the whole board`,"data-sw-fit":`true`,children:(0,Y.jsx)(bg,{size:17,"aria-hidden":`true`})})})]});let m=i&&!o.size&&!l,g=i&&o.size?`Minimap: hidden while a page is live`:i?`Hide the minimap`:`Show the minimap`,v=`h-8 w-8 rounded-md text-muted shadow-none hover:bg-surface-2 hover:text-fg`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Rk,{}),(0,Y.jsx)($u,{position:`bottom-left`,className:`!m-3`,children:(0,Y.jsxs)(`div`,{className:`flex items-center gap-0.5 rounded-lg border border-line bg-surface/95 p-0.5 shadow-pop backdrop-blur`,role:`group`,"aria-label":`Zoom`,"data-sw-zoom-controls":`true`,children:[(0,Y.jsx)(z,{className:K(v,`react-flow__controls-zoomout`),onClick:()=>d.zoomOut({duration:kE(200)}),label:`Zoom out`,tooltip:(0,Y.jsx)(JD,{label:`Zoom out`,keys:[`-`]}),children:(0,Y.jsx)(Eg,{size:15,"aria-hidden":`true`})}),(0,Y.jsxs)(Ce,{children:[(0,Y.jsx)(h,{content:`Zoom level`,children:(0,Y.jsxs)(C,{className:`tabular h-8 min-w-12 rounded-md px-1.5 text-xs font-medium text-fg outline-none hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent`,"aria-label":`Zoom ${f}%`,"data-sw-zoom-level":f,children:[f,`%`]})}),(0,Y.jsxs)(t,{side:`top`,align:`start`,className:`min-w-52`,children:[(0,Y.jsxs)(T,{onSelect:()=>d.zoomIn({duration:kE(200)}),children:[`Zoom in `,(0,Y.jsx)(a,{className:`ml-auto`,children:`+`})]}),(0,Y.jsxs)(T,{onSelect:()=>d.zoomOut({duration:kE(200)}),children:[`Zoom out `,(0,Y.jsx)(a,{className:`ml-auto`,children:`-`})]}),(0,Y.jsx)(_,{}),(0,Y.jsx)(T,{onSelect:()=>p(.5),children:`Zoom to 50%`}),(0,Y.jsxs)(T,{onSelect:()=>p(1),children:[`Zoom to 100% `,(0,Y.jsx)(a,{className:`ml-auto`,children:`Shift 0`})]}),(0,Y.jsx)(T,{onSelect:()=>p(2),children:`Zoom to 200%`}),(0,Y.jsx)(_,{}),(0,Y.jsxs)(T,{onSelect:u,children:[`Fit the whole board `,(0,Y.jsx)(a,{className:`ml-auto`,children:`Shift 1`})]})]})]}),(0,Y.jsx)(z,{className:K(v,`react-flow__controls-zoomin`),onClick:()=>d.zoomIn({duration:kE(200)}),label:`Zoom in`,tooltip:(0,Y.jsx)(JD,{label:`Zoom in`,keys:[`+`]}),children:(0,Y.jsx)(Hg,{size:15,"aria-hidden":`true`})}),(0,Y.jsx)(`span`,{className:`mx-0.5 h-5 w-px bg-line`,"aria-hidden":`true`}),(0,Y.jsx)(z,{className:K(v,`react-flow__controls-fitview`),onClick:u,label:`Fit the whole board`,tooltip:(0,Y.jsx)(JD,{label:`Fit the whole board`,keys:[`Shift`,`1`]}),children:(0,Y.jsx)(bg,{size:14,"aria-hidden":`true`})}),(0,Y.jsx)(z,{className:K(v,i&&`text-accent hover:text-accent`),"aria-pressed":i,onClick:s,label:i?`Hide the minimap`:`Show the minimap`,tooltip:g,"data-sw-minimap-toggle":i?o.size?`auto-hidden`:`on`:`off`,children:(0,Y.jsx)(vg,{size:14,"aria-hidden":`true`})})]})}),m?(0,Y.jsx)(Fm,{pannable:!0,zoomable:!0,position:`bottom-right`,className:`!m-3 overflow-hidden !rounded-lg shadow-pop`,style:{width:168,height:104},bgColor:`color-mix(in srgb, var(--surface) 88%, transparent)`,maskColor:`color-mix(in srgb, var(--sunken) 55%, transparent)`,maskStrokeColor:`var(--accent)`,maskStrokeWidth:2,nodeBorderRadius:6,nodeColor:e=>e.type===`groupFrame`?`color-mix(in srgb, var(--fg) 5%, transparent)`:`color-mix(in srgb, var(--fg) 28%, transparent)`,nodeStrokeWidth:0,ariaLabel:`Minimap`,"data-sw-minimap":`true`}):null]})}function Vk(e,t,n=8){return t?e.left<t.right+n&&e.left+e.width>t.left-n&&e.top<t.bottom+n&&e.top+e.height>t.top-n:!1}function Hk(e,t){let n=null;for(let r of e||[]){if(!r||r.width<=0||r.height<=0)continue;let e=r.left-t.left,i=r.top-t.top,a=e+r.width,o=i+r.height;n=n?{left:Math.min(n.left,e),top:Math.min(n.top,i),right:Math.max(n.right,a),bottom:Math.max(n.bottom,o)}:{left:e,top:i,right:a,bottom:o}}return n}function Uk({card:e,canvas:t,bar:n,avoid:r=null,gap:i=8,zoom:a=1,toggleSize:o=44}){let{width:s,height:c}=t,l=r?r.bottom+i:i,u=e=>Math.max(i,Math.min(c-n.height-i,e)),d=(e,t=n)=>!Vk({...e,width:t.width,height:t.height},r,i),f=t=>{let r={left:t,top:u(e.top)};if(d(r))return r;let a={left:t,top:l};return a.top+n.height+i<=c?a:null},p=null;if(e.titleTop-n.height-i>=i){let t={left:Math.max(i,Math.min(e.right-n.width,s-n.width-i)),top:e.titleTop-n.height-i};d(t)&&(p=t)}!p&&e.right+i+n.width<=s-i&&(p=f(e.right+i)),!p&&e.left-i-n.width>=i&&(p=f(e.left-i-n.width));let m=e.titleTop>=i&&a>.2?{top:Math.max(i,e.titleTop-7),left:Math.max(i,Math.min(s-52,e.right-44-Math.min(140,(e.right-e.left)*.3)))}:{top:i,left:i};d(m,{width:o,height:o})||(m={...m,top:l});let h={left:i,top:d({left:i,top:i})?i:l};return{place:p,toggle:m,fallback:h}}var Wk=30;function Gk({focused:e,target:t,frame:n,title:i,hasLive:a,live:o,ready:s,selecting:c,touch:l,href:u,onOpenLive:d,onToggleSelect:f,onClose:p,history:m=0,onHistory:_=null,onChecks:v=null,onCapture:y=null,captureBusy:b=!1}){let x=$(e=>e.transform),S=$(e=>e.width),C=$(e=>e.height),w=$(e=>e.domNode),[T,E]=(0,J.useState)(null),D=T===e;(0,J.useEffect)(()=>{e||E(null)},[e]);let[O,k]=(0,J.useState)(null);if((0,J.useLayoutEffect)(()=>{let t=e&&w?w.closest(`[data-sw-canvas]`)?.querySelector(`[data-sw-canvas-notes]`):null,n=()=>{let e=t?Hk(Array.from(t.children).map(e=>e.getBoundingClientRect()),w.getBoundingClientRect()):null;k(t=>JSON.stringify(t)===JSON.stringify(e)?t:e)};if(n(),!t)return;let r=new MutationObserver(n);r.observe(t,{childList:!0,subtree:!0,characterData:!0});let i=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return i?.observe(t),()=>{r.disconnect(),i?.disconnect()}},[e,w,S,C]),!e||!t||!n)return null;let[A,j,M]=x,N=(t.x+n.x)*M+A,P=(t.y+n.y)*M+j,F=t.y*M+j-(M>.2?Wk:0),ee=N+n.w*M,I=P+n.h*M;if(ee<0||N>S||I<0||P>C||Av(n,M))return null;let L=l?54:40,R=(l?236:340)+(_?l?56:90:0)+(y?l?56:120:0)+(v?l?48:90:0),{place:B,toggle:V,fallback:H}=Uk({card:{left:N,top:P,right:ee,bottom:I,titleTop:F},canvas:{width:S,height:C},bar:{width:R,height:L},avoid:O,gap:8,zoom:M}),U=l?`touch`:`sm`,te=`text-fg shadow-none`,ne=l&&`text-[13px]`;if(!B&&!D)return(0,Y.jsx)(z,{size:`icon`,variant:`secondary`,style:V,className:`nodrag nopan absolute z-20 rounded-full bg-surface/95 text-fg shadow-pop`,onClick:t=>{t.stopPropagation(),E(e)},label:`${i} actions`,side:`bottom`,"data-sw-frame-bar-toggle":e,children:(0,Y.jsx)(vh,{size:18,"aria-hidden":`true`})});let re=B?{left:B.left,top:B.top,width:Math.min(R,S-16)}:{left:H.left,top:H.top,width:Math.min(R,S-16)};return(0,Y.jsxs)(`div`,{className:`nodrag nopan nowheel absolute z-20 flex items-center flex-wrap justify-end gap-1 rounded-lg border border-line bg-surface/95 p-1 shadow-pop backdrop-blur`,style:re,role:`toolbar`,"aria-label":`${i} actions`,"data-sw-frame-bar":e,onClick:e=>e.stopPropagation(),children:[l?null:(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1 truncate px-1.5 text-xs font-medium text-muted`,children:[i,` · `,n.viewport]}),a&&!o?(0,Y.jsxs)(r,{size:U,variant:`default`,className:K(`shadow-none`,ne),onClick:d,"data-sw-open-live":e,children:[(0,Y.jsx)(Og,{size:15,"aria-hidden":`true`}),` Open live`]}):null,o?(0,Y.jsxs)(r,{size:U,variant:c?`default`:`ghost`,className:K(`shadow-none`,ne,!c&&`text-fg`),"aria-pressed":c,disabled:!s,onClick:f,"data-sw-select-text":e,children:[(0,Y.jsx)(g_,{size:15,"aria-hidden":`true`}),` `,c?`Done`:`Select text`]}):null,v?(0,Y.jsxs)(r,{size:U,variant:`ghost`,className:te,onClick:v,"aria-label":`Page checks`,"data-sw-frame-checks":e,children:[(0,Y.jsx)(Ah,{size:15,"aria-hidden":`true`}),l?null:`Checks`]}):null,_?(0,Y.jsx)(h,{content:`Page history: ${m+1} captures`,children:(0,Y.jsxs)(r,{size:U,variant:`ghost`,className:te,onClick:_,"aria-label":`Page history: ${m+1} captures`,"data-sw-frame-history":e,children:[(0,Y.jsx)(Kg,{size:15,"aria-hidden":`true`}),` `,l?null:`History`]})}):null,y?(0,Y.jsx)(h,{content:`Recapture this page at every screen size`,children:(0,Y.jsxs)(r,{size:U,variant:`ghost`,className:te,disabled:b,onClick:y,"aria-label":`Capture this page`,"data-sw-frame-capture":e,children:[(0,Y.jsx)(Xm,{size:15,"aria-hidden":`true`}),` `,l?null:`Capture`]})}):null,u?(0,Y.jsx)(z,{asChild:!0,size:l?`icon`:`icon-sm`,className:te,label:`Open the page in a new tab`,children:(0,Y.jsx)(`a`,{href:u,target:`_blank`,rel:`noreferrer`,children:(0,Y.jsx)(bh,{size:15,"aria-hidden":`true`})})}):null,(0,Y.jsx)(z,{size:l?`icon`:`icon-sm`,onClick:B?p:()=>E(null),label:B?`Close`:`Collapse`,"data-sw-frame-bar-close":`true`,children:(0,Y.jsx)(g,{size:15,"aria-hidden":`true`})})]})}function Kk({onChecks:e,onHistory:t,historyCountFor:n,focusedKey:r,layout:i,data:a,liveKeys:o,readyKeys:s,selectingKey:c,touch:l,liveFileFor:u,onOpenLive:d,onToggleSelect:f,onClose:p,onCapture:m,captureBusy:h}){if(!r)return null;let g=r.lastIndexOf(`|`),_=r.slice(0,g),v=r.slice(g+1),y=i.targets[_],b=y?.frames.find(e=>e.viewport===v);if(!b)return null;let x=_.startsWith(`variant:`)?a?.variants?.find(e=>`variant:${e.id}`===_):null,S=x?null:a?.board?.pages.find(e=>e.id===_);return(0,Y.jsx)(Gk,{focused:r,target:y,frame:b,title:x?x.title:S?.title||_,hasLive:!!u(_,v),live:o.has(r),ready:s.has(r),selecting:c===r,touch:l,href:S?.url||(x?.source&&/^https?:/.test(x.source)?x.source:null),onOpenLive:()=>d(_,v),onToggleSelect:()=>f(r),onClose:p,history:S&&a?.versions?.[S.id]?.[v]?.length||0,onChecks:S&&e?()=>e(S.id,v):null,onHistory:S&&n(S.id)?()=>t(S.id,v):null,onCapture:S&&m?()=>m(S.id):null,captureBusy:h})}var qk=(0,J.lazy)(()=>xT(()=>import(`./ShareDialog-BouvNraR.js`).then(e=>({default:e.MigrationBanner})),__vite__mapDeps([9,1]),import.meta.url)),Jk=()=>{},Yk=new Set;function Xk(e,t){let n=new Map;for(let r of e||[])n.has(t(r))||n.set(t(r),r);return n}function Zk({boardId:e,boards:t,info:n,onPickBoard:r,onInfoChanged:i,onOpenBuzz:a}){let s=ve(`(min-width: 1024px)`),l=ve(`(max-width: 640px)`),u=Vd(),d=j(),p=vE(),[m,h]=We(),[g,_]=(0,J.useState)(!1),v=!n?.readOnly&&(!o||F),y=v&&!o&&!n?.hosted,b=v&&n?.allowCapture,x=e=>n?.permissions?.[e]!==!1,{view:S,commentsQuery:C,data:w,capture:T,comments:D,fixRequest:O,setFixRequest:k,setPolling:A,deletingIds:M,setDeletingIds:P}=mk(e),ee=Xe(n?.localProjectsEnabled?`/api/local-projects`:null,{pollMs:3e4}),I=ee.data?.projects||[],L=(0,J.useMemo)(()=>w?.viewports||{},[w?.viewports]),R=Object.keys(L),z=(0,J.useMemo)(()=>{let e=R.map(e=>({id:e,label:pv(e)}));return e.length>1&&e.push({id:`all`,label:e.length===2?`Both`:`All`}),e},[R.join(`,`)]),B=l&&R.includes(`phone`)?`phone`:R[0]||`desktop`,V=z.some(e=>e.id===m.get(`vp`))?m.get(`vp`):B,H=OC.some(e=>e.id===m.get(`filter`))?m.get(`filter`):`open`,U=Number(m.get(`c`))||null,te=(m.get(`q`)||``).slice(0,120),ne=av.some(e=>e.id===m.get(`st`))?m.get(`st`):null,re=/^[a-z][\w.-]{0,39}$/.test(m.get(`m`)||``)?m.get(`m`):null,ie=m.get(`panel`)===`off`,{canChecks:ae,checksOpen:W,checksPage:oe,checksViewport:se,checksQuery:ce,openChecks:le,closeChecks:de,checksCounts:pe,checksPanelProps:me,checksRun:he}=wk({boardId:e,info:n,params:m,updateParams:h,pages:w?.board?.pages}),[ge,_e]=(0,J.useState)(``),{chatAvailable:ye,chatThread:be,settingsAvailable:xe,localSettingsAvailable:Se,generalSettingsOpen:Ce,settingsOpen:we,openSettings:Te,openChat:Ee,reopenChat:De}=Tk({boardId:e,info:n,params:m,updateParams:h}),Oe=(0,J.useRef)(null),ke=(0,J.useRef)(PE(m.get(`v`))),Ae=(0,J.useRef)(null),[je,Me]=(0,J.useState)(!1),[Ne,Pe]=(0,J.useState)(null),[q,Fe]=(0,J.useState)(!1),[Ie,Le]=(0,J.useState)(!1),Re=n?.localUser?.name||``,[ze,Be]=(0,J.useState)(()=>fe()),Ve=ze||Re,He=(0,J.useCallback)(()=>fe()||Re,[Re]),Ue=(0,J.useRef)(null),[Ge,Ke]=(0,J.useState)(!1),[qe,Je]=(0,J.useState)(null),[Ye,Ze,Qe]=TO(),[$e,et]=(0,J.useState)(()=>XE()),tt=$e??ZE(w?.board?.pages?.length||0),[nt,rt]=(0,J.useState)(!1),it=jS(e),at=it&&[`working`,`waiting`].includes(it.state)&&Number(it.commentId)||null,ot=(0,J.useMemo)(()=>at?new Set([at]):Yk,[at]),[st,ct]=(0,J.useState)(!1),[lt,ut]=(0,J.useState)(null),[dt,ft]=(0,J.useState)(null),[pt,mt]=(0,J.useState)(null),[ht,gt]=(0,J.useState)(null),[_t,vt]=(0,J.useState)(()=>!$E()),[yt,bt]=xE(!!d),[xt,St]=(0,J.useState)(()=>new Set),Ct=(0,J.useCallback)(e=>St(t=>t.has(e)?t:new Set(t).add(e)),[]),wt=(0,J.useCallback)(()=>{vt(!1),tD()},[]),Tt=()=>{bt(),wt()},Et=m.get(`hist`),Dt=m.get(`hv`),{journeys:Ot,journey:kt,route:At,routeGraph:jt,routePages:Mt,step:Nt,journeyComments:Pt}=hk({params:m,data:w,builder:pt}),X=m.get(`links`)===`1`,[Ft,It]=(0,J.useState)(!1);(0,J.useEffect)(()=>{X||It(!1)},[X]);let Lt=Array.isArray(w?.brokenLinks)?w.brokenLinks:[],Rt=Lt.length?`Arrows for the links between pages; ${Lt.length} ${Lt.length===1?`link leads`:`links lead`} to an error`:`Arrows for the links between pages`,{environments:zt,comparePair:Bt,changedOnly:Vt,showDiff:Ht,compareQuery:Ut,compareData:Wt,compareView:Gt,setCompare:Kt,canCompare:qt,toggleCompare:Jt,setChangedOnly:Yt}=Ek({boardId:e,params:m,updateParams:h,environmentList:w?.environments,setCommentMode:Me,pageCount:w?.board?.pages?.length||0}),Xt=(0,J.useMemo)(()=>{let e=w?.board?.pages||[];return!Vt||!Wt?e:e.filter(e=>(ev(Wt,e.id)||0)>0)},[Vt,Wt,w?.board?.pages]),Zt=(0,J.useMemo)(()=>w?.board&&R.length?Iv({pages:Xt,groups:w.board.groups,variants:Bt?[]:w.variants,viewports:L,mode:V,compare:Bt}):{nodes:[],edges:[],targets:{}},[w?.board,w?.variants,Xt,L,V,Bt]),[Qt,$t,en]=$p(Zt.nodes);(0,J.useEffect)(()=>{$t(Zt.nodes)},[Zt.nodes,$t]);let tn=nm(),[nn,rn]=JE(tn),[an,on]=(0,J.useState)(null),[sn,cn]=(0,J.useState)(null),ln=(0,J.useCallback)(()=>{on(null),cn(null)},[]),un=(0,J.useCallback)(()=>{ln(),rn(null),u.fitView({...ME,duration:kE(400)})},[ln,u,rn]);yk({mode:V,pendingFocus:lt,shapeKey:`${Bt?.join(`_`)||``}|${Vt&&Wt?Xt.length:`all`}`,clearFocus:ln,fitBoard:un});let dn=(0,J.useMemo)(()=>Xk(w?.board?.pages,e=>e.id),[w?.board?.pages]),fn=(0,J.useMemo)(()=>Xk(w?.variants,e=>`variant:${e.id}`),[w?.variants]),{visibleComments:pn,pinsByTarget:mn,counts:hn}=Dk({comments:D,query:te,stateFilter:ne,mentionFilter:re,titleOfPage:(0,J.useCallback)(e=>String(e).startsWith(`variant:`)?fn.get(e)?.title||``:dn.get(e)?.title||``,[dn,fn]),filter:H,journey:kt,journeyComments:Pt}),gn=(0,J.useMemo)(()=>N(D),[D]),_n=(0,J.useMemo)(()=>({name:n?.user?.name||Ve||``,handle:n?.user?.handle||null}),[n?.user?.name,n?.user?.handle,Ve]),vn=v&&!w?.migratedTo?.readOnly&&x(`comment`),yn=e=>{let t=!!_n.handle&&e.authorHandle===_n.handle;return{reply:v&&!w?.migratedTo?.readOnly&&x(`reply`),resolve:v&&!w?.migratedTo?.readOnly&&x(`resolve`),react:v&&!w?.migratedTo?.readOnly&&x(`react`),edit:v&&!w?.migratedTo?.readOnly&&x(`edit`)&&(!n?.hosted||dT({isAuthor:t})),delete:v&&!w?.migratedTo?.readOnly&&x(`delete`)&&(!n?.hosted||fT({role:n.role,isAuthor:t}))}},{seen:bn,markSeen:xn,markAllSeen:Sn}=cT(e),Cn=(0,J.useMemo)(()=>new Set(D.filter(e=>sT(e,bn,_n)).map(e=>e.id)),[D,_n,bn]),wn=D.find(e=>e.id===U)||null,Tn=CO(s),En=(0,J.useMemo)(()=>{let e=new Set;for(let t of D)t.status!==`resolved`&&(t.agentStatus===`working`||ot.has(t.id))&&e.add(t.pageId);return e},[ot,D]),Dn=(0,J.useCallback)(e=>dn.get(e)||null,[dn]),On=(0,J.useCallback)(e=>{if(e.startsWith(`variant:`)){let t=fn.get(e);return t?`Variant: ${t.title}`:`Removed variant`}return Dn(e)?.title||e},[fn,Dn]),kn=w?.manifest?.capturedAt||`none`,An=(0,J.useRef)(null),{refetch:jn}=S,{refetch:Mn}=C,{refetch:Nn}=Ut,Pn=(0,J.useCallback)(()=>{let e=`${kn}|${w?.environments?.map(e=>e.capturedAt).join(`,`)||``}`;An.current!==e&&(An.current=e,jn(),Mn(),Nn())},[w?.environments,kn,Mn,Nn,jn]),Fn=(0,J.useRef)(!1),In=(0,J.useCallback)(e=>{Fn.current=!1,Pe(null),h({c:e.id}),s||(Fe(!1),Le(!0))},[h,s]),Ln=(0,J.useCallback)(()=>{Le(!1),h({c:null}),Fn.current&&!s&&Fe(!0),Fn.current=!1},[h,s]),Rn=(0,J.useCallback)(e=>{let t=V!==`all`&&e.viewport!==V&&!!L[e.viewport];Pe(null),ut(e),h({c:e.id,...t?{vp:e.viewport===B?null:e.viewport}:{}}),t&>({from:V,to:e.viewport,id:e.id,at:Date.now()}),s||(Fe(!1),Le(!0))},[B,V,h,L,s]);(0,J.useEffect)(()=>{if(!ht)return;let e=window.setTimeout(()=>gt(null),6e3);return()=>window.clearTimeout(e)},[ht]),_k({pendingFocus:lt,setPendingFocus:ut,targets:Zt.targets,viewports:L,flow:u,canvasRef:Ae,wide:s,setSettledZoom:rn}),vk({wide:s,nodesReady:tn,initialCamera:ke,selectedCommentId:U,canvasRef:Ae,nodes:Zt.nodes,flow:u,setSettledZoom:rn});let zn=(0,J.useRef)(!ke.current&&!U&&!m.get(`j`)),Bn=(0,J.useRef)(!ke.current&&!!U),[Vn,Hn]=(0,J.useState)(()=>!s||!zn.current);(0,J.useEffect)(()=>{if(!zn.current||!tn||!Zt.nodes.length)return;if(zn.current=!1,!s){Hn(!0);return}let e=HE(Zt.nodes,Ae.current?.getBoundingClientRect());rn(null);let t=e?u.setViewport(e):u.fitView(ME);Promise.resolve(t).finally(()=>Hn(!0))},[u,Zt.nodes,tn,rn,s]);let Un=(0,J.useRef)(!1),Wn=()=>{Un.current=!0},Gn=(0,J.useCallback)(e=>{Un.current&&(Un.current=!1,e.preventDefault(),Ae.current?.focus({preventScroll:!0}))},[]),{liveKeys:Kn,readyKeys:qn,setLiveReady:Jn,liveFileFor:Yn,recomputeLive:Xn,openLive:Zn}=rk({canvasRef:Ae,flow:u,targets:Zt.targets,viewports:L,settledZoom:nn,setSettledZoom:rn,comparePair:Bt,captures:w?.captures,variantsById:fn});(0,J.useEffect)(()=>{sn&&!Kn.has(sn)&&cn(null)},[Kn,sn]);let{openJourney:Qn,closeJourney:$n,goStep:er,chooseJourneyBranch:tr,startBuilder:nr,addBuilderStep:rr,saveBuilder:ir,removeJourney:ar}=fk({boardId:e,view:S,updateParams:h,clearFocus:ln,setCommentMode:Me,journey:kt,route:At,routePages:Mt,step:Nt,builder:pt,setBuilder:mt,busy:st,setBusy:ct,setNotice:Je,flow:u,targets:Zt.targets,nodesReady:tn,mode:V,comparePair:Bt,setSettledZoom:rn}),or=an&&!an.startsWith(`variant:`)?mv(an):null,sr=or?.targetId||null,cr=dt||sr,lr=m.get(`la`)===`1`,{presentPages:ur,shownSteps:dr,hiddenLinkTargets:fr,edges:pr,journeyView:mr}=Ok({targets:Zt.targets,layoutEdges:Zt.edges,links:w?.links,showLinks:X,showAllLinks:lr,activePage:cr,builder:pt,route:At,routeGraph:jt,routePages:Mt,step:Nt,journey:kt,targetTitle:On}),hr=(0,J.useCallback)((e,t=null)=>{if(!e||String(e).startsWith(`variant:`))return;let n=V===`all`?R[0]:V;h({hist:e,hv:t&&t!==n?t:null})},[V,h,R.join(`,`)]),gr=Et&&w?.board?.pages.find(e=>e.id===Et)||null,_r=Dt&&L[Dt]?Dt:V===`all`?R[0]:V,vr=(0,J.useCallback)(()=>h({hist:null,hv:null}),[h]),yr=t=>{let n=Zt.targets[t];if(!n)return;rn(null);let r=n.frames[0],i=n.frames.map(e=>w?.captures?.[t]?.[e.viewport]).filter(e=>e?.thumb||e?.file);FE(u,n,Ae.current?.getBoundingClientRect(),{phoneCompare:!!Bt&&!s,shotUrls:i.map(t=>c(e,`captures`,t.thumb||t.file,kn))}),r&&on(`${t}|${r.viewport}`)},br=(0,J.useMemo)(()=>{let e=Xt;return[...new Set(e.map(e=>e.group))].map(t=>({group:t,pages:e.filter(e=>e.group===t)}))},[Xt]),xr=(0,J.useMemo)(()=>Ne?{pageId:Ne.pageId,viewport:Ne.viewport,x:Ne.x,y:Ne.y,anchor:Ne.anchor}:null,[Ne?.pageId,Ne?.viewport,Ne?.x,Ne?.y,Ne?.anchor]),Sr=(0,J.useCallback)((e,t,n)=>{let r=Zt.targets[e],i=r?.frames.find(e=>e.viewport===t);i&&(u.getZoom()>=3.9?In(n[0].comment):(rn(null),u.fitBounds(IE(r,i,n),{padding:.3,duration:kE(450)})))},[u,Zt.targets,In,rn]),{board:Cr,view:wr}=Ak({boardId:e,data:w,viewports:L,journeyView:mr,compareView:Gt,commentMode:je,canComment:vn,wide:s,hosted:n?.hosted,imageVersion:kn,pinsByTarget:mn,me:_n,checksCounts:pe,canChecks:ae,agentFocus:ot,agentWorkingPages:En,setLiveReady:Jn,focusedKey:an,selectingKey:sn,settledZoom:nn,selectedComment:wn,draftSpot:xr,unread:Cn,liveKeys:Kn,selectedCommentId:U,closeThread:Ln,builder:pt,addBuilderStep:rr,layout:Zt,flow:u,canvasRef:Ae,setSettledZoom:rn,setFocusedKey:on,setToast:Ze,setDraft:Pe,checkDraft:ge,setCheckDraft:_e,authorName:He,selectComment:In,openCluster:Sr,openChecks:le,openHistory:hr,updateParams:h,defaultMode:B,onImageError:Pn}),{commentsUrl:Tr,applyComment:Er,setStatus:Dr,replyTo:Or,editComment:kr,reactTo:Ar,copyLink:jr,githubIssue:Mr,removeComment:Nr,sendToAgent:Pr}=pk({boardId:e,commentsQuery:C,view:S,info:n,localName:Ve,authorName:He,setBusy:ct,setNotice:Je,setToast:Ze,setDeletingIds:P,selectedCommentId:U,closeThread:Ln,wide:s,filter:H,allowed:x}),Fr=(0,J.useMemo)(()=>({attach:vn&&!o&&!n?.guest,draw:vn&&!o,attachNote:vn&&!o&&n?.guest?`Guests on a share link cannot attach images. You can still draw on the page.`:null}),[vn,n?.guest]),Ir=(0,J.useCallback)((t,n)=>{let r=w?.captures?.[t]?.[n];if(!r?.file)return null;let i=String(t).startsWith(`variant:`)?fn.get(t):null,a=dn.get(i?i.pageId:t),o=Nv(L,n,a?.frameHeight);return o?{src:c(e,`captures`,r.file,kn),native:o}:null},[e,w?.captures,kn,dn,fn,L]),{draftDescription:Lr,composerProps:Rr}=Mk({draft:Ne,setDraft:Pe,busy:st,setBusy:ct,commentsUrl:Tr,applyComment:Er,markSeen:xn,setLocalName:Be,setNotice:Je,updateParams:h,wide:s,filter:H,targetTitle:On,people:gn,info:n,media:Fr,pageImage:Ir}),{captureConfirm:zr,setCaptureConfirm:Br,startCapture:Vr}=jk({boardId:e,view:S,setBusy:ct,setNotice:Je,setPolling:A}),Hr=(0,J.useCallback)(e=>{h({v:`${Math.round(e.x)},${Math.round(e.y)},${e.zoom.toFixed(3)}`}),rn(e.zoom),Xn()},[Xn,rn,h]),Ur=bS({canvasRef:Ae,flow:u,minZoom:jE,maxZoom:4,onRest:Hr}),Wr=(0,J.useCallback)((e,t)=>{Ur.moving()||Hr(t)},[Hr,Ur]);G(!!an,ln),(0,J.useEffect)(()=>{an&&_t&&wt()},[wt,an,_t]),G(je,()=>Me(!1)),G(!!kt,$n),G(!!pt,()=>mt(null)),ak({commentMode:je,setCommentMode:Me,canComment:vn,comparePair:Bt,setDraft:Pe}),ok({journeys:Ot,journey:kt,builder:pt,openJourney:Qn,closeJourney:$n});let[Gr,Kr]=FD(s,!1);(0,J.useEffect)(()=>{let e=e=>{!(e.metaKey||e.ctrlKey)||e.altKey||e.shiftKey||e.key.toLowerCase()!==`k`||document.querySelector(`[role="dialog"]:not([data-sw-thread-popover]):not([data-sw-palette])`)||(e.preventDefault(),rt(e=>!e))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,J.useEffect)(()=>{je||Pe(e=>e&&!e.body.trim()?null:e)},[je]),(0,J.useEffect)(()=>{wn&&xn(wn)},[xn,wn]),(0,J.useEffect)(()=>{wn&&Ct(`open`),je&&Ct(`comment`),be&&Ct(`agent`)},[be,je,Ct,wn]),bk({nodesReady:tn,data:w,commentsLoaded:C.data,selectedCommentId:U,selectedComment:wn,initialCamera:ke,focusComment:Rn,deletingIds:M,setNotice:Je,updateParams:h});let{threadList:qr,threadIndex:Jr,stepThread:Yr,neighborNote:Xr}=xk({selectedComment:wn,visibleComments:pn,focusComment:Rn,mode:V,viewports:L,modes:z});(0,J.useEffect)(()=>{let e=null,t=wr.subscribe(()=>{let{hoveredId:t}=wr.get(),n=t===null?null:Ae.current?.querySelector(`[data-sw-pin="${t}"]`)||null;n!==e&&(e?.removeAttribute(`data-sw-pin-hover`),n?.setAttribute(`data-sw-pin-hover`,`true`),e=n)});return()=>{t(),e?.removeAttribute(`data-sw-pin-hover`)}},[wr]);let Zr=e=>{gt(null),h({vp:e===B?null:e})},Qr=D.filter(e=>e.status===`open`).length,$r=bC({boardId:e,enabled:!(!ye||w?.migratedTo?.readOnly||!n?.agent?.fixWithAgent||!n?.agent?.configured||n?.hosted&&!E),onProgress:()=>{C.refetch(),S.refetch()}}),[ei,ti]=(0,J.useState)(null),ni=e=>{let t=D.find(t=>t.id===e);t?Rn(t):Ee(vw(e))},ri={...$r,agentName:n?.agent?.label||`agent`,boardId:e,onOpenThread:ni,onConfirm:e=>ti(e)},ii={batch:ri,comments:pn,filter:H,counts:hn,onFilter:e=>h({filter:e===`open`?null:e}),selectedId:U,onHover:Cr.onHoverComment,onFocus:e=>{Fn.current=!s,Rn(e)},unread:Cn,onMarkAllRead:()=>Sn(D),people:gn,narrow:{query:te,state:ne,mention:re,onQuery:e=>h({q:e||null}),onState:e=>h({st:e}),onMention:e=>h({m:e}),onClear:()=>h({q:null,st:null,m:null})},canAct:vn,targetTitle:On,touch:!s,onResetBrowserComments:F?()=>{f(e),h({c:null}),C.refetch(),S.refetch()}:null,journeyFilter:kt?{name:kt.name,on:Pt,onToggle:()=>h({jc:Pt?null:`1`})}:null},ai=wn?{comment:wn,page:Dn(wn.pageId),title:On(wn.pageId),people:gn,me:_n,can:yn(wn),role:n?.guest?`guest`:n?.role||null,hosted:!!n?.hosted,onSaveName:Be,media:{...Fr,boardId:e,pageImage:Ir,pageTitle:On(wn.pageId),currentVersion:e=>String(e.pageId).startsWith(`variant:`)?null:Y_(w?.manifest?.pages?.[e.pageId]?.[e.viewport],w?.manifest)},busy:st,touch:!s,editingRef:Ue,actions:{onReply:Or,onSendToAgent:n?.hosted&&w?.agentDispatch&&!wn.authorGuest&&!wn.authorAgent?Pr:null,onStatus:Dr,onEdit:kr,onDelete:Nr,onReact:Ar,onCopyLink:jr,onFixAgent:ye&&!w?.migratedTo?.readOnly&&n?.agent?.fixWithAgent&&n?.agent?.configured?e=>{k({commentId:e.id,nonce:Date.now()}),s||Le(!1),Ee(vw(e.id))}:null,onAskAgent:ye?e=>{s||Le(!1),Ee(vw(e.id))}:null,onGithubIssue:!o&&n?.github?.ready?Mr:null,onHistory:e=>{s||Le(!1),hr(e.pageId,e.viewport)}},nav:{index:Jr,total:qr.length,onPrev:()=>Yr(-1),onNext:()=>Yr(1),prevNote:Xr(-1),nextNote:Xr(1)},beforeAfter:w?{pairFor:e=>Q_(e,{manifest:w.manifest,captures:w.captures,versions:w.versions}),nativeFor:e=>{let t=String(e.pageId).startsWith(`variant:`)?fn.get(e.pageId):null,n=dn.get(t?t.pageId:e.pageId);return Nv(L,e.viewport,n?.frameHeight)||null},urlFor:t=>c(e,t.kind,t.file,t.version),onImageError:Pn}:null}:null,oi={boardId:e,batch:ri,fixRequest:O,onFixDone:()=>{k(null),S.refetch(),C.refetch()},agent:n?.agent,threadId:be||`board`,onThread:Ee,comments:D,pages:w?.board?.pages||[],captures:w?.captures||{},imageVersion:kn,defaultViewport:V===`all`?B:V,focused:or?{pageId:or.targetId,viewport:or.viewport}:null,touch:!s,onOpenSettings:xe?Te:null,settingsLocked:!!(ye&&!xe&&n?.agent?.settingsLocked),onAgentChanged:i,people:gn,onRunChecks:he?async()=>{let e=await he.start({seo:he.seoDefault});return le(),e}:null,journeys:Ot,checksCounts:ae?pe:null,onBoardChanged:()=>{S.refetch(),C.refetch()},onNavigate:e=>{if(!s&&e.kind!==`check`&&h({chat:null}),e.kind===`comment`){let t=D.find(t=>t.id===e.id);t&&Rn(t)}else e.kind===`page`?yr(e.id):e.kind===`journey`?Qn(e.id):e.kind===`check`&&le(e.id)},onRecapture:b&&!Bt?e=>e?Vr(null,Array.isArray(e)?e:[e]):Br(!0):E?()=>Je({tone:`info`,text:`The demo does not take new captures. On your own board this recaptures the changed pages.`}):null},si=()=>h({links:X?null:`1`}),ci=()=>{let e=!tt;et(e),eD(e)},li=!!gr||we||Ce||zr||!s&&W,ui={data:ce.data,error:ce.error,loading:ce.loading,pages:w?.board?.pages||[],pageId:oe,viewport:se,onSelect:le,onClose:de,onRefresh:ce.refetch,onEnvironment:e=>h({ce:e}),canComment:vn,local:!o&&!n?.hosted,onView:(e,t)=>{de(),h({vp:t,page:e}),ut({pageId:e,viewport:t,x:50,y:50})},onDraft:(e,t,n)=>{_e(`${n.title}\n\n${n.observation}\n${n.nextAction}\n\nCheck report ${t.id} (${e.viewport}, ${t.auditedAt}). Separately sampled; review before sending to an agent.`.slice(0,1800)),de(),h({vp:e.viewport}),ut({pageId:e.pageId,viewport:e.viewport,x:50,y:50}),Fe(!1),Me(!0),Ze({at:Date.now(),text:`Choose a pin on the page, then review and save your comment.`})},...me},di=e=>{e.preventDefault(),de(),s?((ie||be)&&h({panel:null,chat:null}),window.requestAnimationFrame(()=>window.requestAnimationFrame(()=>document.getElementById(`sw-comments`)?.focus()))):Fe(!0)},fi=e=>xS(e,e=>{let t=Zt.targets[e]?.frames[0];t&&Cr.onFocusFrame(e,t.viewport)}),pi=Nk({canComment:vn,comparePair:Bt,commentMode:je,markPicked:Wn,setDraft:Pe,setCommentMode:Me,showLinks:X,toggleLinks:si,canCompare:qt,toggleCompare:Jt,wide:s,fitBoard:un,minimapOn:tt,toggleMinimap:ci,chatAvailable:ye,reopenChat:De,canChecks:ae,openChecks:le}),mi={setMenuOpen:Ke,data:w,chatAvailable:ye,chatThread:be,reopenChat:De,updateParams:h,groupedPages:br,jumpToPage:yr,modes:z,mode:V,setMode:Zr,journeys:Ot,journey:kt,canEditJourneys:y,openJourney:Qn,closeJourney:$n,startBuilder:nr,openBrokenLinks:()=>It(!0),canChecks:ae,openChecks:le,showLinks:X,toggleLinks:si,brokenLinks:Lt,canCompare:qt,comparePair:Bt,toggleCompare:Jt,settingsAvailable:xe,openSettings:Te,capture:T,canCapture:b,busy:st,setCaptureConfirm:Br};return(0,Y.jsxs)(Qk,{board:Cr,view:wr,people:gn,children:[(0,Y.jsxs)(`div`,{className:`flex h-full flex-col`,"data-sw-board":e,style:{paddingTop:`env(safe-area-inset-top, 0px)`},children:[(0,Y.jsx)(OT,{}),(0,Y.jsx)(HT,{}),n?.hosted&&w?.agentApprove?(0,Y.jsx)(BT,{boardId:e}):null,(0,Y.jsx)(`a`,{href:`#sw-comments`,className:`sr-only z-[80] rounded-md bg-accent px-3 py-2 text-sm font-medium text-accent-fg focus:not-sr-only focus:absolute focus:top-2 focus:left-2`,onClick:di,"data-sw-skip-comments":`true`,children:`Skip to comments`}),(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[s?(0,Y.jsx)(YO,{...mi,info:n,localName:Ve,onOpenBuzz:a,demo:d,localSettingsAvailable:Se,setShareOpen:_,expanded:Gr,onToggle:Kr,quiet:Tn,pages:w?{groups:br,journeys:Ot,comments:D,activePage:cr,journeyId:kt?.id||null,onPage:yr,onJourney:Qn,canEditJourneys:y,onNewJourney:()=>nr()}:null}):null,(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(yO,{...mi,wide:s,info:n,boardId:e,boards:t,localProjects:I,projectsError:ee.error,localName:Ve,onPickBoard:r,onOpenBuzz:a,demo:d,localSettingsAvailable:Se,setShareOpen:_,viewportNotice:ht,canComment:vn,commentMode:je,setCommentMode:Me,openPalette:()=>rt(!0),minimapOn:tt,toggleMinimap:ci,linksTip:Rt,panelHidden:ie,checksOpen:W,allOpen:Qr,closeChecks:de,setSheetOpen:Fe,sidebarTitled:s&&Gr}),!n?.hosted&&w?.migratedTo?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(qk,{marker:w.migratedTo,boardId:e,editable:!!n?.shareEnabled,onChange:S.refetch})}):null,(0,Y.jsx)(OO,{notice:qe,setNotice:Je,wide:s}),Bt?(0,Y.jsx)(VC,{environments:zt,pair:Bt,loading:Ut.loading||!Wt,error:Ut.error?Ut.error.message:null,changedPages:Wt?.changedPages??0,totalPages:w?.board?.pages?.length||0,changedOnly:Vt,showDiff:Ht,canCapture:b,captureBusy:st||!!T?.running,touch:!s,onPair:e=>Kt(e),onChangedOnly:Yt,onShowDiff:e=>h({diff:e?null:`off`}),onCapture:e=>Vr(e),onClose:()=>Kt(null)}):null,(0,Y.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,Y.jsxs)(`div`,{ref:Ae,tabIndex:-1,className:K(`relative min-w-0 flex-1 outline-none`,je&&vn&&`sw-commenting`),onKeyDown:fi,"data-sw-canvas":`true`,children:[X&&Lt.length?(0,Y.jsx)(qD,{items:Lt,open:Ft,onOpenChange:It}):null,s&&w?(0,Y.jsx)(wO,{flow:u,canvasRef:Ae,targets:Zt.targets,focusFor:e=>((e===`composer`?Ne?.y:wn?.y)??50)/100,shotFor:(t,n)=>{let r=w.captures?.[t]?.[n];return r?.file?c(e,`captures`,r.thumb||r.file,kn):null}}):null,Tn?null:(0,Y.jsx)(xO,{wide:s,commentMode:je,canComment:vn,readyKeys:qn,setCommentMode:Me,showLinks:X,activePage:cr,shownSteps:dr,data:w,presentPages:ur,hiddenLinkTargets:fr,showAllLinks:lr,targetTitle:On,updateParams:h,tipOpen:_t,tryOpen:yt,journey:kt,builder:pt,viewportNotice:ht,dismissTip:wt,modes:z,setMode:Zr,comparePair:Bt}),!w&&S.error?(0,Y.jsx)(U_,{error:S.error,onRetry:S.refetch}):w?(0,Y.jsxs)(Jp,{nodes:Qt,edges:pr,edgeTypes:cS,onNodeMouseEnter:X?(e,t)=>ft(t.type===`page`?t.id:null):void 0,onNodeMouseLeave:X?()=>ft(null):void 0,onNodesChange:en,onNodeClick:Jk,nodeTypes:rS,colorMode:p,defaultViewport:ke.current||void 0,fitView:Bn.current,style:Vn?void 0:{opacity:0},edgesFocusable:!1,fitViewOptions:ME,minZoom:jE,maxZoom:4,panOnScroll:!1,zoomOnScroll:!1,panActivationKeyCode:null,zoomActivationKeyCode:null,onlyRenderVisibleElements:!0,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,zoomOnDoubleClick:!je,onMoveEnd:Wr,onPaneClick:()=>{ln(),U&&Ln()},proOptions:{hideAttribution:!0},children:[(0,Y.jsx)(um,{gap:40,size:1}),(0,Y.jsx)(Kk,{onChecks:ae?le:null,onHistory:hr,historyCountFor:e=>iv(w?.versions,e),focusedKey:Tn?null:an,layout:Zt,data:w,liveKeys:Kn,readyKeys:qn,selectingKey:sn,touch:!s,liveFileFor:Yn,onOpenLive:Zn,onToggleSelect:e=>cn(t=>t===e?null:e),onClose:ln,onCapture:b&&!Bt?e=>Vr(null,[e]):null,captureBusy:st||!!T?.running}),s&&Ne&&!li?(0,Y.jsx)(eT,{point:Bv(Zt.targets,Ne),stowed:Tn,onClose:()=>st?null:Pe(null),children:(0,Y.jsx)(WC,{...Rr,touch:!1,description:Lr})}):null,s&&ai&&!Ne&&!li?(0,Y.jsx)($w,{comment:wn,point:Bv(Zt.targets,wn),onClose:Ln,stowed:Tn,onPrev:()=>Yr(-1),onNext:()=>Yr(1),editingRef:Ue,children:(0,Y.jsx)(Gw,{...ai,onClose:Ln})}):null,(0,Y.jsx)(Bk,{wide:s,clearFocus:ln,setSettledZoom:rn,minimapOn:tt,liveKeys:Kn,toggleMinimap:ci,hideFit:!!(kt||pt),hideMinimap:!!(kt||pt),fitBoard:un})]}):(0,Y.jsxs)(`div`,{className:`flex h-full items-center justify-center gap-2 text-sm text-muted`,children:[(0,Y.jsx)(ue,{}),` Loading board`]}),n?.hosted&&!E?(0,Y.jsx)(JT,{touch:!s,enabled:!!w&&!o,boardId:e,canvasRef:Ae,flow:u,selection:U,mode:V,onMode:e=>h({vp:e}),onInvalidate:()=>{C.refetch(),S.refetch()}}):null,yt&&w&&!kt&&!pt&&!Tn&&(!je||s)?(0,Y.jsx)(SE,{touch:!s,done:xt,onOpenComment:()=>{let e=pn.filter(e=>e.status===`open`),t=e.find(e=>V===`all`||e.viewport===V)||e[0]||pn[0];t&&Rn(t)},onComment:vn&&!Bt?()=>{Pe(null),Me(!0)}:null,onAgent:ye?De:null,onClose:Tt}):null,(0,Y.jsx)(DO,{toast:Ye,setToast:Ze,onHold:Qe,wide:s,raised:!!(kt||pt)}),Bt&&Vt&&Wt&&!Xt.length?(0,Y.jsx)(`p`,{className:`absolute inset-x-0 top-1/3 mx-auto w-max max-w-[90%] rounded-lg bg-surface px-4 py-3 text-sm text-muted shadow-pop`,children:`No visual changes between these two environments.`}):null,pt?(0,Y.jsx)(IC,{draft:pt,pages:w?.board?.pages||[],onChange:mt,onSave:ir,onCancel:()=>mt(null),pageTitle:e=>Dn(e)?.title||e,busy:st,touch:!s}):kt&&!Tn?(0,Y.jsx)(FC,{journey:kt,route:At,step:Nt,pageTitle:e=>Dn(e)?.title||e,onStep:er,onChoose:tr,onClose:$n,onEdit:()=>nr(kt),onDelete:ar,canEdit:y&&kt.source===`board`,busy:st,touch:!s},kt.id):null]}),(0,Y.jsx)(jO,{wide:s,checksOpen:W,checksProps:ui,chatThread:be,chatProps:oi,panelHidden:ie,panelProps:ii,updateParams:h})]})]})]}),(0,Y.jsx)(TT,{ref:Oe})]}),s?null:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(RO,{checksOpen:W,closeChecks:de,checksProps:ui,chatAvailable:ye,chatThread:be,chatProps:oi,updateParams:h,sheetOpen:q,setSheetOpen:Fe,panelProps:ii,threadSheet:Ie,threadProps:ai,closeThread:Ln,selectedComment:wn,targetTitle:On,draft:Ne,busy:st,setDraft:Pe,draftDescription:Lr,composerProps:Rr}),(0,Y.jsx)(bO,{...mi,menuOpen:Ge})]}),$r.offered?(0,Y.jsx)(CC,{open:!!ei,onClose:()=>{ti(null),$r.setError(null)},ids:ei||[],comments:D,max:$r.max,agentName:ri.agentName,targetTitle:On,busy:$r.busy,error:$r.error,touch:!s,onStart:async e=>{await $r.start(e)&&ti(null)}}):null,(0,Y.jsx)(ek,{info:n,boardId:e,boards:t,wide:s,shareOpen:g,setShareOpen:_,refetchView:jn,settingsAvailable:xe,settingsOpen:we,updateParams:h,onInfoChanged:i,generalSettingsOpen:Ce,updates:Oe,historyPage:gr,closeHistory:vr,historyViewport:_r,historyPageId:Et,data:w,comments:D,filter:H,focusComment:Rn,onImageError:Pn,captureConfirm:zr,setCaptureConfirm:Br,busy:st,focusedPage:sr,findPage:Dn,startCapture:Vr}),(0,Y.jsx)(gD,{open:nt,onOpenChange:rt,groups:br,journeys:Ot,canEditJourneys:y,comments:D,titleOf:On,actions:pi,onPage:e=>{Wn(),yr(e)},onJourney:e=>{Wn(),Qn(e)},onNewJourney:()=>{Wn(),nr()},onComment:e=>{Wn(),Rn(e)},onCloseAutoFocus:Gn})]})}function Qk({board:e,view:t,people:n,children:r}){return(0,Y.jsx)(vv.Provider,{value:e,children:(0,Y.jsx)(Eb.Provider,{value:t,children:(0,Y.jsx)(ib.Provider,{value:n,children:r})})})}function $k(){let[e,t]=(0,J.useState)(``),[n,i]=(0,J.useState)(null),[a,o]=(0,J.useState)(``);(0,J.useEffect)(()=>{let e=!0,t=async()=>{try{let t=await Ke.get(`/api/pairing`);if(!e)return;i(t),(t.pairing.state===`approved`||[`host`,`device`,`identity`].includes(t.access))&&window.location.reload()}catch(t){e&&o(t.message)}};t();let n=setInterval(t,2e3);return()=>{e=!1,clearInterval(n)}},[]);let s=async t=>{t.preventDefault(),o(``);try{let t=await Ke.post(`/api/pairing`,{name:e});i(e=>({...e,pairing:t}))}catch(e){o(e.message)}},c=n?.pairing,l=c?.code,u=/iPad|iPhone|iPod/.test(navigator.userAgent),d=window.matchMedia(`(display-mode: standalone)`).matches||navigator.standalone;return(0,Y.jsxs)(`main`,{className:`mx-auto flex min-h-dvh max-w-lg flex-col justify-center gap-5 p-6`,"data-sw-pairing":!0,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`text-xs font-medium text-accent`,children:`Shapewall`}),(0,Y.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold text-fg`,children:`Pair this device`})]}),(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`This board belongs to the person running Shapewall. Match the code and approve this device on that computer.`}),c?.state===`pending`?(0,Y.jsxs)(`section`,{className:`space-y-3 rounded-lg border border-line p-4`,"aria-live":`polite`,children:[(0,Y.jsxs)(`p`,{className:`text-sm text-fg`,children:[`Waiting for approval: `,c.name]}),(0,Y.jsxs)(`p`,{className:`font-mono text-3xl tracking-widest text-fg`,"data-sw-pairing-code":!0,children:[l.slice(0,4),`-`,l.slice(4)]}),(0,Y.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Expires in five minutes. On the host, open Devices or run `,(0,Y.jsxs)(`code`,{children:[`shapewall devices approve `,l]}),`.`]})]}):(0,Y.jsxs)(`form`,{className:`space-y-3`,onSubmit:s,children:[[`denied`,`expired`].includes(c?.state)?(0,Y.jsxs)(`p`,{className:`text-sm text-warn`,role:`status`,children:[c.state===`denied`?`The host denied this request.`:`This request expired.`,` You can request again.`]}):null,(0,Y.jsx)(`label`,{htmlFor:`device-name`,className:`block text-sm text-fg`,children:`Device name`}),(0,Y.jsx)(Ge,{id:`device-name`,required:!0,maxLength:80,placeholder:`My phone`,value:e,onChange:e=>t(e.target.value)}),(0,Y.jsx)(r,{type:`submit`,children:`Request pairing`})]}),a?(0,Y.jsx)(`p`,{className:`text-sm text-bad`,role:`alert`,children:a}):null,n?.secure?null:(0,Y.jsx)(`p`,{className:`rounded-lg border border-warn/30 p-3 text-xs text-warn`,children:`Plain HTTP on Wi-Fi exposes your device cookie to sniffing and replay. Use Tailscale for private HTTPS, or configure a TLS certificate. Without HTTPS this board installs only as a bookmark.`}),u&&!d?(0,Y.jsx)(`p`,{className:`text-xs text-muted`,children:`Installing on your iPhone? Add the board to your Home Screen first, then pair from inside that app. Its cookies are separate from Safari.`}):null]})}function eA({info:e}){let[t,n]=(0,J.useState)(!1),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(``),c=e?.remote,l=!!c?.manage;(0,J.useEffect)(()=>{if(!l)return;let e=!0,t=async()=>{try{let t=await Ke.get(`/api/devices`);e&&a(t)}catch(t){e&&s(t.message)}};t();let n=setInterval(t,4e3);return()=>{e=!1,clearInterval(n)}},[l]);let u=async(e,t)=>{try{await Ke[e](t),l?a(await Ke.get(`/api/devices`)):window.location.reload()}catch(e){s(e.message)}};if(!c||!l&&!c.device)return null;let d=i?.pending||[];return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`fixed bottom-3 left-3 z-30 rounded-lg border border-line bg-surface p-1 shadow-lg lg:bottom-16 lg:left-[64px]`,children:(0,Y.jsx)(r,{size:`sm`,variant:`ghost`,onClick:()=>n(!0),"data-sw-devices-open":!0,children:l?`Devices${d.length?` (${d.length} waiting)`:``}`:c.device.name})}),(0,Y.jsx)(M,{open:t,onClose:()=>n(!1),title:l?`Your devices`:`This device`,children:(0,Y.jsxs)(`div`,{className:`max-h-[70dvh] space-y-4 overflow-auto p-5`,"data-sw-devices":!0,children:[o?(0,Y.jsx)(`p`,{role:`alert`,className:`text-sm text-bad`,children:o}):null,l?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`Approve only your own devices, after matching the code shown on them. Paired devices can comment, capture and drive your connected agent.`}),d.map(e=>(0,Y.jsxs)(`section`,{className:`space-y-2 rounded border border-line p-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.name}),(0,Y.jsxs)(`p`,{className:`break-all text-xs text-muted`,children:[e.browser,` · `,e.ip]}),(0,Y.jsxs)(`p`,{className:`font-mono text-lg text-fg`,children:[e.code.slice(0,4),`-`,e.code.slice(4)]}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(r,{size:`sm`,onClick:()=>u(`post`,`/api/devices/${e.code}/approve`),children:`Approve`}),(0,Y.jsx)(r,{size:`sm`,variant:`secondary`,onClick:()=>u(`post`,`/api/devices/${e.code}/deny`),children:`Deny`})]})]},e.id)),(i?.devices||[]).map(e=>(0,Y.jsxs)(`section`,{className:`flex items-center justify-between gap-2 rounded border border-line p-3`,children:[(0,Y.jsxs)(`p`,{className:`min-w-0 break-words text-sm text-fg`,children:[e.name,(0,Y.jsxs)(`span`,{className:`block text-xs text-muted`,children:[`Last seen `,new Date(e.lastSeenAt).toLocaleDateString()]})]}),(0,Y.jsx)(r,{size:`sm`,variant:`secondary`,onClick:()=>u(`delete`,`/api/devices/${e.id}`),children:`Revoke`})]},e.id)),!d.length&&!i?.devices?.length?(0,Y.jsx)(`p`,{className:`text-sm text-muted`,children:`No paired devices or requests yet.`}):null]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Paired as `,c.device.name,`. Settings and other devices are managed on the host computer.`]}),(0,Y.jsx)(r,{variant:`secondary`,onClick:()=>u(`delete`,`/api/devices/${c.device.id}`),children:`Revoke this device`})]})]})})]})}var tA=(0,J.lazy)(()=>xT(()=>import(`./BuzzDialog-Ds7Thpfe.js`),__vite__mapDeps([11,1]),import.meta.url)),nA=!E&&typeof document<`u`&&!!document.querySelector(`meta[name="shapewall-remote"]`);function rA(){let[e,t]=(0,J.useState)(!1),[n,i]=(0,J.useState)(!1),a=ge(n);(0,J.useEffect)(()=>{let e=()=>t(!0);return window.addEventListener(`shapewall:pairing-required`,e),()=>window.removeEventListener(`shapewall:pairing-required`,e)},[]);let o=Xe(nA?`/api/pairing`:null),s=!nA||[`host`,`device`,`identity`].includes(o.data?.access),c=Xe(s?`/api/info`:null);eC(c.refetch,!!c.data?.agent);let l=c.data?.agent?.ownerWrites===!0;(0,J.useEffect)(()=>US(l),[l]);let u=j(),d=Xe(s?`/api/boards`:null),[f,p]=We(),m=Array.isArray(d.data?.boards)?d.data.boards:[],h=f.get(`board`),g=m.find(e=>e.id===h)||m[0];me(c.data?.fixturesAt);let _=E?u?.shareProblem:null;iA(_?`Share link`:g?.title);let v=E&&f.has(`share`);return(0,J.useEffect)(()=>{v&&p({share:null})},[v,p]),nA&&!o.loading&&!s||e||c.error?.code===`pairing_required`||d.error?.code===`pairing_required`?(0,Y.jsx)($k,{}):_?(0,Y.jsx)(jT,{problem:_,onLeave:u.leaveShare}):d.loading||c.loading?(0,Y.jsx)(B_,{}):d.error?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(U_,{error:d.error,onRetry:()=>Promise.all([d.refetch(),c.error?c.refetch():null]),extra:E?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(r,{asChild:!0,size:`touch`,variant:`secondary`,className:`lg:h-10`,children:(0,Y.jsx)(`a`,{href:`console.html#/signin`,children:`Sign in to the demo`})}),(0,Y.jsx)(r,{size:`touch`,variant:`ghost`,className:`lg:h-10`,onClick:()=>u?.reset(),children:`Reset the demo`})]}):null}),E?(0,Y.jsx)(kT,{}):null]}):g?(0,Y.jsxs)(L,{children:[(0,Y.jsx)(eA,{info:c.data}),c.data?.buzzAvailable===!0&&a?(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(tA,{open:n,onClose:()=>i(!1),boardId:g.id},g.id)}):null,(0,Y.jsx)(Wp,{children:(0,Y.jsx)(Zk,{boardId:g.id,boards:m,info:c.data,onInfoChanged:c.refetch,onOpenBuzz:()=>i(!0),onPickBoard:e=>p({board:e,c:null,v:null})})},g.id)]}):(0,Y.jsx)(`div`,{className:`flex h-full bg-sunken`,children:(0,Y.jsx)(k,{size:`lg`,icon:eg,title:`No boards yet`,children:c.data?.hosted?(0,Y.jsxs)(Y.Fragment,{children:[`Capture your site locally, then run `,(0,Y.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall push`}),` with a project token.`]}):(0,Y.jsxs)(Y.Fragment,{children:[`Add pages to `,(0,Y.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall.config.json`}),`, then run`,` `,(0,Y.jsx)(`code`,{className:`font-mono text-ui text-fg`,children:`shapewall capture`}),`.`]})})})}function iA(e){(0,J.useEffect)(()=>{if(!E||!e)return;let t=String(e).replace(/\s*\(demo\)$/i,``);document.title=t===`Share link`?`Share link · Shapewall demo`:`${t} board · Shapewall demo`},[e])}function aA(){typeof navigator<`u`&&`serviceWorker`in navigator&&window.isSecureContext&&window.addEventListener(`load`,()=>{navigator.serviceWorker.register(`./sw.js`,{scope:`./`}).catch(()=>{})})}var oA=900;function sA(){try{let e=document.createElement(`div`);e.style.cssText=`position:absolute;top:-999px;width:100px;height:100px;overflow:scroll;visibility:hidden`,document.documentElement.appendChild(e);let t=e.offsetWidth-e.clientWidth>0;return e.remove(),t}catch{return!1}}function cA(){let e=new WeakMap;document.addEventListener(`scroll`,t=>{let n=t.target===document?document.documentElement:t.target;n instanceof Element&&(n.hasAttribute(`data-scrolling`)||n.setAttribute(`data-scrolling`,``),clearTimeout(e.get(n)),e.set(n,setTimeout(()=>n.removeAttribute(`data-scrolling`),oA)))},{capture:!0,passive:!0})}typeof document<`u`&&sA()&&(document.documentElement.classList.add(`sw-scrollbars`),cA()),document.querySelector(`meta[name="shapewall-agent-settings"]`)?xT(async()=>{let{default:e}=await import(`./Management-BFcKFdbp.js`);return{default:e}},__vite__mapDeps([12,7,1,5,2]),import.meta.url).then(({default:e})=>(0,rt.createRoot)(document.getElementById(`root`)).render((0,Y.jsx)(e,{}))):((0,rt.createRoot)(document.getElementById(`root`)).render((0,Y.jsx)(J.StrictMode,{children:(0,Y.jsx)(rA,{})})),aA());export{Jg as $,lC as A,Vb as B,dw as C,eh as Ct,mC as D,pC as E,eC as F,E_ as G,P_ as H,OS as I,m_ as J,b_ as K,SS as L,sC as M,nC as N,oC as O,cC as P,Qg as Q,Bb as R,lw as S,nh as St,EC as T,A_ as U,rv as V,O_ as W,i_ as X,u_ as Y,n_ as Z,ow as _,bh as _t,mT as a,mg as at,rw as b,uh as bt,jw as c,cg as ct,Sw as d,Wh as dt,Kg as et,xw as f,Hh as ft,sw as g,Eh as gt,_w as h,Ah as ht,gE as i,Sg as it,aC as j,rC as k,bw as l,ng as lt,hw as m,Mh as mt,tE as n,Bg as nt,hT as o,fg as ot,Pw as p,Rh as pt,v_ as q,nE as r,wg as rt,Mw as s,ug as st,AE as t,Wg as tt,Fw as u,Xh as ut,iw as v,vh as vt,GC as w,Wm as wt,cw as x,oh as xt,aw as y,mh as yt,zb as z};
|