@eliya-oss/agent-diff 0.1.0-alpha.210 → 0.1.0-alpha.211
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 +6 -0
- package/dist/main.js +1 -1
- package/dist/web/nitro.json +1 -1
- package/dist/web/public/assets/{_deck-bHyYGFMC.js → _deck-DC3R9ZRW.js} +1 -1
- package/dist/web/public/assets/{_point-Df5RE6M6.js → _point-DGd-d-fN.js} +1 -1
- package/dist/web/public/assets/{index-Dv2OX9bH.js → index-CNzMZ6k6.js} +2 -2
- package/dist/web/public/assets/{review-Bu_bWLB8.js → review-CHVb5xmC.js} +1 -1
- package/dist/web/public/assets/{review-block-CSU8TP-U.js → review-block-DYenwozF.js} +2 -2
- package/dist/web/public/assets/{routes-uxQf-w7c.js → routes-5aZJQX_G.js} +1 -1
- package/dist/web/public/assets/{viewed-store-B-45NTVY.js → viewed-store-Eo50afbB.js} +1 -1
- package/dist/web/server/{_deck-BrcrkCE2.mjs → _deck-B4JFpoe9.mjs} +3 -3
- package/dist/web/server/{_point-BsiN7JGn.mjs → _point-NTPxvKqQ.mjs} +4 -4
- package/dist/web/server/_ssr/{review-CwlsS5m4.mjs → review-CVYUVoDD.mjs} +3 -3
- package/dist/web/server/_ssr/{review-block-BkiLFX6y.mjs → review-block-Ceno7nop.mjs} +40 -45
- package/dist/web/server/_ssr/{review-parts.server-BvMVQd9C.mjs → review-parts.server-DW9heP1l.mjs} +4 -3
- package/dist/web/server/_ssr/{review.functions-CifSVeZt.mjs → review.functions-Z_X3Jo2Z.mjs} +2 -2
- package/dist/web/server/_ssr/{router-sHH4eQWZ.mjs → router-jY5mnS6O.mjs} +8 -8
- package/dist/web/server/_ssr/{routes-V4kZPRI3.mjs → routes-tQi6ASvp.mjs} +2 -2
- package/dist/web/server/_ssr/shortcuts-B7llaLLc.mjs +1 -1
- package/dist/web/server/_ssr/ssr.mjs +14 -14
- package/dist/web/server/_ssr/{viewed-store-auFKz1vA.mjs → viewed-store-9-at5rDS.mjs} +2 -2
- package/dist/web/server/{_tanstack-start-manifest_v-emcOJdhD.mjs → _tanstack-start-manifest_v-CVU4En5c.mjs} +8 -8
- package/dist/web/server/index.mjs +52 -52
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @eliya-oss/agent-diff
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.211
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix(page): the page reads what is read again when the agent writes new layers, so a layer's read mark and the count of layers read follow the new order. The keys for switching the middle and for showing a thread in the diff now show in the hover tip the rest of the page uses.
|
|
8
|
+
|
|
3
9
|
## 0.1.0-alpha.210
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/main.js
CHANGED
|
@@ -10119,7 +10119,7 @@ var init_config = __esmMin((() => {
|
|
|
10119
10119
|
//#region package.json
|
|
10120
10120
|
init_pane();
|
|
10121
10121
|
init_config();
|
|
10122
|
-
var version$2 = "0.1.0-alpha.
|
|
10122
|
+
var version$2 = "0.1.0-alpha.211";
|
|
10123
10123
|
//#endregion
|
|
10124
10124
|
//#region src/cli/error.ts
|
|
10125
10125
|
var UnknownCommand, MissingOption, UnknownField, UnknownOption, RemovedOption, UnexpectedArgument, SeveralIds, IdGivenTwice, BadOption, RegistryUnanswered, NotServed, BadRequest, PageNotShipped, PageStopped;
|
package/dist/web/nitro.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{k as t,t as n}from"./index-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{k as t,t as n}from"./index-CNzMZ6k6.js";import{a as r,n as i,o as a,r as o,s,t as c}from"./viewed-store-Eo50afbB.js";import{A as l,B as u,O as d,R as f,Y as p,h as m,j as h,kt as g}from"./decks.functions-tXNTG2sC.js";import{E as _,T as v,_ as y,a as b,c as x,d as ee,f as te,h as ne,i as re,l as ie,m as ae,n as oe,o as S,p as C,r as w,s as T,t as E,u as D,v as O,x as k}from"./shortcuts-BsNWbUaT.js";import{t as A,xn as j,yn as M}from"./use-window-event-BDUVK1pJ.js";var N=e(g(),1),P=`review-deck-open-groups`,F={now:!0,yours:!0,mine:!0,done:!1},I=new Set,L=null,R=()=>{try{let e=l(d(h(),m()),JSON.parse(localStorage.getItem(P)??`null`));return e.success?e.output:null}catch{return null}},z=()=>(L??={...F,...R()},L),B=(e,t)=>{L={...z(),[e]:t};try{localStorage.setItem(P,JSON.stringify(L))}catch{L={...L}}I.forEach(e=>{e()})},V=e=>(I.add(e),()=>{I.delete(e)}),H=()=>z(),U=()=>F,W=()=>(0,N.useSyncExternalStore)(V,H,U),G=p(),K=te(),q=()=>{K.close()},se=e=>e instanceof HTMLElement?e.querySelector(`.marquee`)?.dataset.overflow===`true`||e.dataset.message===`true`:!1,ce=({last:e})=>{let t=S();return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1 border-t border-border pt-2 text-xs`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-subtle`,children:[(0,G.jsx)(`span`,{children:e.author===`claude`?`Agent`:`You`}),(0,G.jsx)(`span`,{className:`ms-auto tabular-nums`,children:t===0?``:x(e.at,t)})]}),(0,G.jsx)(`p`,{className:`m-0 line-clamp-2 text-sm/5 text-muted-foreground`,children:e.body})]})},le=({point:e,last:t})=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(`p`,{className:`m-0 text-base/6 font-medium text-foreground`,children:e.title}),t===null?null:(0,G.jsx)(ce,{last:t})]}),ue=()=>{let e=(0,N.useRef)(void 0);return(0,G.jsx)(ie,{handle:K,onOpenChange:(e,t)=>{e&&!se(t.trigger)&&(t.cancel(),q())},children:({payload:t})=>(e.current=t??e.current,e.current===void 0?null:(0,G.jsx)(D,{children:(0,G.jsx)(le,{...e.current})}))})},de=40,J=e=>{let t=e.parentElement;if(!t||t.clientWidth===0)return;let n=Math.max(0,e.scrollWidth-t.clientWidth),r=Math.round(n/de*T);t.dataset.overflow=String(n>0),t.style.setProperty(`--marquee-shift`,`${String(-n)}px`),t.style.setProperty(`--marquee-duration`,`${String(r)}ms`)},fe=async e=>{e&&(J(e),await document.fonts.ready,J(e))},Y=e=>{let t=e.currentTarget.querySelector(`.marquee > span`);t&&J(t)},pe=({activity:e})=>(0,G.jsx)(`span`,{"aria-label":e.title,className:j(`shrink-0 animate-enter text-xs text-subtle`,e.kind===`new`&&`text-accent`,e.kind===`seen`&&`text-success`),children:e.text}),me=({row:e,deck:t,isCurrent:n})=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(ee,{closeDelay:80,delay:400,handle:K,payload:e,render:(0,G.jsx)(f,{"aria-current":n?`page`:void 0,className:j(`group/row flex min-w-0 items-center gap-2 rounded-lg px-2.5 py-2 text-sm text-muted-foreground transition-colors duration-150 ease-out hover:bg-secondary hover:text-foreground focus-visible:bg-secondary focus-visible:text-foreground`,n&&`bg-secondary text-foreground`),"data-message":e.last!==null,onFocus:Y,onPointerEnter:Y,params:{deck:t,point:e.point.id},to:`/decks/$deck/$point`}),children:[(0,G.jsx)(`span`,{className:`marquee min-w-0 flex-1`,children:(0,G.jsx)(`span`,{ref:e=>{fe(e)},children:e.point.short})}),e.activity?(0,G.jsx)(pe,{activity:e.activity}):null]})}),he=e=>e.reduce((e,t)=>{let n=e.at(-1);return n?.domain===t.point.domain?n.rows.push(t):e.push({domain:t.point.domain,rows:[t]}),e},[]),ge=({count:e})=>(0,G.jsx)(`span`,{className:`rounded-full bg-secondary px-1.5 text-xs/4 font-medium text-muted-foreground tabular-nums`,children:e}),X=({rows:e,deck:t,current:n})=>(0,G.jsx)(`ol`,{className:`flex flex-col gap-0.5`,children:e.map(e=>(0,G.jsx)(me,{deck:t,isCurrent:e.point.id===n,row:e},e.point.id))}),_e=({rows:e,deck:t,current:n})=>he(e).map(e=>(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`h3`,{className:`sticky top-12 z-1 bg-background px-2.5 pt-3 pb-2 text-xs font-medium text-subtle`,"data-sticky":!0,children:e.domain}),(0,G.jsx)(X,{current:n,deck:t,rows:e.rows})]},e.domain)),ve=({heading:e,rows:t,state:n,task:r,deck:i,current:a,isOpen:o})=>(0,G.jsxs)(C,{onOpenChange:e=>{B(n,e)},open:o,render:(0,G.jsx)(`section`,{}),children:[(0,G.jsx)(`h2`,{className:`sticky top-0 z-2 bg-background pt-1`,"data-sticky":!0,children:(0,G.jsxs)(ne,{children:[(0,G.jsx)(_,{className:`size-3.5 text-subtle transition-transform group-data-panel-open/trigger:rotate-90`}),(0,G.jsx)(`span`,{className:`flex-1`,children:e}),(0,G.jsx)(ge,{count:t.length+(r===``?0:1)})]})}),(0,G.jsx)(ae,{children:(0,G.jsxs)(`div`,{className:`pb-3`,children:[r===``?null:(0,G.jsx)(`p`,{className:`m-0 truncate px-2.5 py-2 text-sm text-foreground`,children:r}),n===`yours`?(0,G.jsx)(_e,{current:a,deck:i,rows:t}):(0,G.jsx)(X,{current:a,deck:i,rows:t})]})})]}),ye=/[^\p{L}\p{N}]+/u,Z=e=>e.toLowerCase().split(ye).filter(e=>e!==``),be=(e,t)=>e.some((n,r)=>t.every((t,n)=>e[r+n]?.startsWith(t)===!0)),xe=(e,t)=>{let n=Z(t);return n.length===0||[e.short,e.title,e.num,e.domain].some(e=>be(Z(e),n))},Se=({query:e,onQuery:t})=>{let n=(0,N.useRef)(null);return A(`keydown`,e=>{let t=document.activeElement?.closest(`[data-owns-keys]`)!==null;w(e.target)||oe()||t||!re(e,E.search)||(e.preventDefault(),n.current?.focus())}),(0,G.jsxs)(`label`,{className:`flex h-9 cursor-text items-center gap-2 rounded-lg border border-border bg-composer px-2.5 text-sm transition-colors duration-150 ease-out focus-within:border-muted-foreground hover:border-subtle`,children:[(0,G.jsx)(v,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-subtle`}),(0,G.jsx)(`span`,{className:`sr-only`,children:`Search points`}),(0,G.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-subtle [&::-webkit-search-cancel-button]:hidden`,onChange:e=>{t(e.target.value)},onKeyDown:e=>{e.key===`Escape`&&(t(``),e.currentTarget.blur())},onPaste:b,placeholder:`Search`,ref:n,type:`search`,value:e}),e===``?(0,G.jsx)(M,{children:E.search.keys[0]}):null]})},Ce=e=>{let[t,n]=(0,N.useState)(``);return{query:t,setQuery:n,isSearching:t.trim()!==``,visible:e.filter(e=>xe(e.point,t))}},we=()=>(0,N.useSyncExternalStore)(r,o,c),Te=/!\[[^\]]*\]\([^)]*\)/gu,Ee=e=>{if(e===void 0)return null;let t=e.body.replaceAll(Te,`[screenshot]`).trim();return{author:e.author,body:t,at:e.at}},De=({live:e,summary:t,current:n})=>{let r=we();return t.points.map(t=>({point:t,state:k(e,t).state,last:Ee(e.comments.findLast(e=>e.point===t.id)),activity:t.id===n?null:O(e,{id:t.id,viewedAt:i(r,t.id)})}))},Q=1,Oe=e=>{let{top:t}=e.getBoundingClientRect();return[...e.querySelectorAll(`[data-sticky]`)].reduce((e,n)=>{let r=n.getBoundingClientRect(),i=Number(getComputedStyle(n).top.replace(`px`,``))||0;return r.top-t>i+Q?e:Math.max(e,r.bottom-t)},0)},$=e=>{if(e===null)return;let t=e.scrollHeight-e.scrollTop-e.clientHeight;e.style.setProperty(`--fade-start`,`${String(Oe(e))}px`),e.dataset.fadeTop=String(e.scrollTop>0),e.dataset.fadeBottom=String(t>Q)},ke=({live:e,summary:t})=>{let{point:n}=u({strict:!1}),r=W(),{query:i,setQuery:o,isSearching:s,visible:c}=Ce(De({live:e,summary:t,current:n}));return(0,G.jsxs)(`div`,{className:`fixed inset-y-0 inset-s-0 hidden w-70 flex-col border-e border-border xl:flex`,children:[(0,G.jsx)(`div`,{className:`px-3 pt-3 pb-1`,children:(0,G.jsx)(Se,{onQuery:o,query:i})}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,G.jsx)(a,{onScroll:e=>{q(),$(e.currentTarget)},variant:`queue`,viewportRef:$,children:(0,G.jsxs)(`nav`,{"aria-label":`Review points`,className:`flex flex-col px-3 pb-6`,children:[s&&c.length===0?(0,G.jsx)(`p`,{className:`m-0 px-2.5 py-3 text-sm text-subtle`,children:`No matches`}):null,y.map(([i,a])=>{let o=c.filter(e=>e.state===i),l=i===`now`&&!s?e.task:``;return(i===`now`||s)&&o.length===0&&l===``?null:(0,G.jsx)(ve,{current:n,deck:t.name,heading:a,isOpen:s||(r[i]??!0),rows:o,state:i,task:l},i)})]})})}),(0,G.jsx)(ue,{})]})};function Ae(){let{summary:e,live:r}=n.useLoaderData(),i=s(e.name,r);return(0,G.jsxs)(`div`,{className:`min-h-dvh safe-page`,children:[(0,G.jsx)(ke,{live:i,summary:e}),(0,G.jsx)(t,{})]})}export{Ae as component};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{L as t,Y as n,d as r,kt as i,u as a,z as o}from"./decks.functions-tXNTG2sC.js";import{c as s,d as c,i as l,l as u,o as d,u as f}from"./viewed-store-B-45NTVY.js";import{b as p,g as m,i as h,n as g,r as _,t as v,y}from"./shortcuts-BsNWbUaT.js";import{A as b,B as x,C as S,D as C,E as w,F as T,G as E,H as D,J as O,K as k,L as A,M as ee,N as j,O as M,P as N,R as P,S as F,T as I,U as L,V as R,W as z,Y as B,_ as V,a as H,b as U,c as W,d as te,f as ne,g as re,h as ie,i as G,j as ae,k as oe,l as se,m as ce,n as le,o as ue,p as de,q as fe,r as pe,s as me,t as he,u as ge,v as _e,w as ve,x as ye,y as be,z as xe}from"./review-block-CSU8TP-U.js";import{An as Se,At as Ce,Cn as we,Dn as K,En as Te,Fn as Ee,Jn as q,Ln as J,Nn as De,Rn as Y,Sn as Oe,Tn as ke,Xt as Ae,a as je,an as Me,ct as Ne,dt as Pe,ft as Fe,ht as Ie,in as Le,j as Re,jn as ze,k as Be,kn as Ve,lt as He,mt as Ue,s as We,st as Ge,t as Ke,xn as X,xt as qe,zn as Je}from"./use-window-event-BDUVK1pJ.js";import{S as Z,u as Ye,x as Xe,y as Ze}from"./index-Dv2OX9bH.js";var Qe={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};Qe.node;var $e=q(Qe),et={name:`chevrons-right`,size:24,node:[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]]};et.node;var tt=q(et),nt={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};nt.node;var rt=q(nt),it={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};it.node;var at=q(it),ot={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};ot.node;var st=q(ot),ct={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};ct.node;var lt=q(ct),Q=e(i(),1),ut=(e,t)=>{(0,Q.useEffect)(()=>{l(e,t)},[e,t])},$=n(),dt=1,ft=24,pt=e=>e.scrollHeight-e.scrollTop-e.clientHeight,mt=e=>{e.dataset.fadeTop=String(e.scrollTop>0),e.dataset.fadeBottom=String(pt(e)>dt)},ht=(e,t)=>e.comments.filter(e=>e.point===t&&e.path===null&&typeof e.media!=`string`).toSorted((e,t)=>e.at.localeCompare(t.at)),gt=({deck:e,view:t,live:n})=>{let r=(0,Q.useRef)(!0),i=p(n,t.id),o=ht(n,t.id),s=e=>{e!==null&&(r.current&&(e.scrollTop=e.scrollHeight),mt(e))};return(0,$.jsxs)(`section`,{"aria-label":`Conversation`,className:`flex min-h-0 flex-1 flex-col gap-2.5 pt-2`,children:[(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(d,{onScroll:e=>{r.current=pt(e.currentTarget)<ft,mt(e.currentTarget)},variant:`fade`,viewportRef:s,children:(0,$.jsxs)(`div`,{className:`flex min-h-full flex-col gap-2`,children:[(0,$.jsx)(`div`,{className:`mt-auto`}),o.length===0?(0,$.jsx)(`p`,{className:`m-0 text-sm text-subtle`,children:`No messages yet.`}):null,o.map((t,r)=>(0,$.jsx)(ve,{comment:t,deck:e,isBubble:!0,isLatest:r===o.length-1,live:n,revision:i},t.id)),(0,$.jsx)(`div`,{ref:e=>{s(e?.closest(`[data-slot="scroll-area-viewport"]`)??null)}},o.length)]})})}),(0,$.jsx)(R,{deck:e,onSubmit:async n=>{await a({data:{deck:e,point:t.id,revision:i,path:null,side:`new`,start:null,end:null,code:``,body:n,parent:null}}),r.current=!0,await f(e)},placeholder:`Message the agent about this point`,submitLabel:`Send`})]})},_t=`data-valid`,vt=`data-invalid`,yt={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},bt={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},xt={valid(e){return e===null?null:e?{[_t]:``}:{[vt]:``}}},St=`data-checked`,Ct=`data-unchecked`,wt={checked(e){return e?{[St]:``}:{[Ct]:``}},...Ae,...xt},Tt=`data-composite-item-active`,Et={invalid:void 0,name:void 0,validityData:{state:yt,errors:[],error:``,value:``,initialValue:null},setValidityData:K,disabled:void 0,setTouched:K,setDirty:K,setFilled:K,setFocused:K,validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:bt,registerFieldControl:K,validation:{getValidationProps:(e,t=Te)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:K,getInputControl:()=>null,commit:async()=>{},change:K}},Dt=Q.createContext(Et);function Ot(e=!0){let t=Q.useContext(Dt);if(t.setValidityData===K&&!e)throw Error(Ee(28));return t}var kt=Q.createContext({disabled:!1});function At(){return Q.useContext(kt)}var jt=Q.createContext({controlId:void 0,registerControlId:K,resetControlId:K,labelId:void 0,setLabelId:K,messageIds:[],setMessageIds:K,getDescriptionProps:e=>e});function Mt(){return Q.useContext(jt)}function Nt(e,t,n,r=!0,i){let[a,o]=Q.useState(),s=We(i?`${i}-label`:void 0),c=e??t??a;return J(()=>{let i=e||t||!r?void 0:Pt(n.current,s);a!==i&&o(i)}),c}function Pt(e,t){let n=Ft(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function Ft(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}function It(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=Mt(),o=We(),s=Je(()=>Symbol()),c=Q.useRef(!1),l=Q.useRef(!1),u=Y(()=>{c.current&&i!==K&&(c.current=!1,i(s.current,void 0))});return J(()=>{if(!n||i===K){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}e===void 0?u():(c.current=!0,i(s.current,e))},[t,n,i,a,o,s,u]),J(()=>u,[u]),(n?r:void 0)??t??o}var Lt=Q.createContext(void 0);function Rt(){return Q.useContext(Lt)}function zt(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}var Bt=Q.createContext(void 0);function Vt(){let e=Q.useContext(Bt);if(e===void 0)throw Error(Ee(52));return e}var Ht=Q.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,readOnly:a=!1,required:o=!1,"aria-labelledby":s,value:c,inputRef:l,nativeButton:u=!1,id:d,style:f,...p}=e,m=Rt(),{disabled:h,readOnly:g,required:_,form:v,checkedValue:y,touched:b=!1,validation:x,name:C,setCheckedValue:w=K,setTouched:T=K,registerInputRef:E=K}=m??{},{setTouched:D,setFilled:O,state:k,disabled:A}=Ot(),ee=At(),{labelId:j,getDescriptionProps:M}=Mt(),N=A||ee.disabled||h||i,P=g||a,F=_||o,I=v,L=m?y===c:c===``,R=Q.useRef(null),z=Q.useRef(null),B=x?.registerInput,V=Q.useCallback(e=>B?.(e,{controlRef:R,value:void 0}),[B]),H=Ve(l,z,E,V);J(()=>{z.current?.checked&&O(!0)},[O]),J(()=>{z.current&&E(N&&L?null:z.current)},[L,N,E]);let U=We(),W=It({id:d}),te=u?void 0:W,ne={role:`radio`,"aria-checked":L,"aria-labelledby":Nt(s,j,z,!u,te),[Tt]:L?``:void 0,id:u?W:U,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){if(e.defaultPrevented||N||P)return;e.preventDefault();let t=z.current;t&&ze(t,e)},onFocus(e){e.defaultPrevented||N||P||!b||(z.current?.click(),T(!1))}},{getButtonProps:re,buttonRef:ie}=Se({disabled:N,native:u,composite:!1}),G={type:`radio`,ref:H,form:I,id:te,name:C,tabIndex:-1,style:C?Ie:Ue,"aria-hidden":!0,...c===void 0?Te:{value:zt(c)},disabled:N,checked:L,required:F,readOnly:P,onChange(e){if(e.nativeEvent.defaultPrevented||N||P||c===void 0)return;let t=qe(Ce,e.nativeEvent);w(c,t),t.isCanceled||D(!0)},onClick(e){e.stopPropagation()},onFocus(){R.current?.focus()}},ae=Q.useMemo(()=>({...k,required:F,disabled:N,readOnly:P,checked:L}),[k,N,P,L,F]),oe=ae,se=m!==void 0,ce=[t,R,ie],le=[ne,p,re,M,x?e=>x.getValidationProps(N,e):Te],ue=we(`span`,e,{enabled:!se,state:ae,ref:ce,props:le,stateAttributesMapping:wt});return(0,$.jsxs)(Bt.Provider,{value:oe,children:[se?(0,$.jsx)(S,{tag:`span`,render:n,className:r,style:f,state:ae,refs:ce,props:le,stateAttributesMapping:wt}):ue,(0,$.jsx)(`input`,{...G,suppressHydrationWarning:!0})]})}),Ut=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Vt(),c=s.checked,{mounted:l,transitionStatus:u,setMounted:d}=Re(c),f={...s,transitionStatus:u},p=Q.useRef(null),m=a||l,h=we(`span`,e,{ref:[t,p],state:f,props:o,stateAttributesMapping:wt});return Be({batch:!0,enabled:!c,open:c,ref:p,onComplete(){c||d(!1)}}),m?h:null});function Wt(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}function Gt(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:f=ke}=e,[p,m]=Q.useState(0),h=r!=null,g=Q.useRef(null),_=Ve(g,c),v=Q.useRef([]),y=Q.useRef(!1),b=Q.useRef(null),S=o??p,C=Y((e,t=!1)=>{if(b.current=v.current[e]??null,(s??m)(e),t){let t=v.current[e];x(g.current,t,a,n)}}),w=Y(e=>{if(e.size===0)return;if(y.current){let e=v.current,t=e.indexOf(b.current);if(t===-1){let t=e[S];!t||Fe(e,S,d)?C(Kt(e,d)):b.current=t}else t!==S&&C(t);return}y.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)C(i);else if(Fe(t,S,d)){let e=Ge(t,{disabledIndices:d});Pe(t,e)||C(e)}x(g.current,r,a,n)});J(()=>{if(d==null||o!=null||!y.current)return;let e=v.current;if(Fe(e,S,d)){let t=Ge(e,{disabledIndices:d});Pe(e,t)||C(t)}},[d,o,S,v,C]);let E=Y((e,t,n)=>i?i(e,t,n,v):n),D=Y(e=>{let o=e.key===`Home`||e.key===`End`;if(!T.has(e.key)||!l&&o||qt(e,f)||!g.current)return;let s=a===`rtl`,c=s?ee:j,p=s?j:ee,m=n===`vertical`?ae:c,_=n===`vertical`?N:p,y=Me(e.nativeEvent);if(y!=null&&xe(y)&&!Wt(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value;if(t==null||e.shiftKey||t!==n||e.key!==_&&t<r.length||e.key!==m&&t>0)return}let b=S,x=He(v,d),w=Ne(v,d);r!=null&&(b=r({disabledIndices:d,elementsRef:v,event:e,highlightedIndex:S,loopFocus:t,maxIndex:w,minIndex:x,onLoop:E,orientation:n,rtl:s}));let D=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,O=n!==`vertical`&&e.key===p||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?b=x:e.key===`End`&&(b=w)),b===S&&(D||O)&&(t&&b===w&&D?(b=x,i&&(b=i(e,S,b,v))):t&&b===x&&O?(b=w,i&&(b=i(e,S,b,v))):b=Ge(v.current,{startingIndex:b,decrement:O,disabledIndices:d})),b!==S&&!Pe(v.current,b)&&(u&&e.stopPropagation(),(h||o||D||O)&&e.preventDefault(),C(b,!0),queueMicrotask(()=>{v.current[b]?.focus()}))});return{props:{ref:_,onFocus(e){let t=g.current,n=Me(e.nativeEvent);t&&n!=null&&xe(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:D},highlightedIndex:S,onHighlightedIndexChange:C,elementsRef:v,onMapChange:w,relayKeyboardEvent:D}}function Kt(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i&&!Fe(e,r,t)){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function qt(e,t){for(let n of A)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function Jt(e){let{render:t,className:n,style:r,refs:i=ke,props:a=ke,state:o=Te,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:y,highlightItemOnHover:b=!1,tag:x=`div`,...S}=e,{props:C,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:E,onMapChange:D,relayKeyboardEvent:O}=Gt({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:je(),disabledIndices:v,modifierKeys:y}),k=we(x,e,{state:o,ref:i,props:[C,...a,S],stateAttributesMapping:s}),A=Q.useMemo(()=>({highlightedIndex:w,onHighlightedIndexChange:T,highlightItemOnHover:b,relayKeyboardEvent:O}),[w,T,b,O]);return(0,$.jsx)(De.Provider,{value:A,children:(0,$.jsx)(F,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}function Yt(e,t,n,r,i=!0,a){let{registerFieldControl:o}=Ot(),s=Je(()=>Symbol());J(()=>{let c=s.current;i?o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}):o(c,void 0)},[e,i,r,t,a,o,s,n]),J(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var Xt=Q.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:K,validationMode:`onSubmit`,submitCountRef:{current:0}});function Zt(){return Q.useContext(Xt)}Object.keys(yt);function Qt(e,t){return e.matches(`:disabled`)?!1:!t||e.form===t||e.form===null&&!e.hasAttribute(`form`)}var $t=Q.createContext(void 0);function en(e=!1){let t=Q.useContext($t);if(!t&&!e)throw Error(Ee(86));return t}var tn=[P],nn=Q.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,form:u,name:d,inputRef:f,id:p,style:h,...g}=e,{setTouched:_,setFocused:v,validationMode:y,name:x,disabled:S,state:C,validation:w,setDirty:T,setFilled:E,validityData:D}=Ot(),{labelId:O}=Mt(),{clearErrors:k,elementRef:A}=Zt(),ee=en(!0),j=S||i,M=x??d,N=We(p),[P,F]=m({controlled:c,default:l,name:`RadioGroup`,state:`value`}),[I,L]=Q.useState(!1),R=Y((e,t)=>{s?.(e,t),t.isCanceled||F(e)}),z=w.getInputControl,B=Q.useMemo(()=>({get current(){return z()}}),[z]),V=Q.useRef(null),H=Q.useRef(null);function U(e){let t;return f&&(typeof f==`function`?t=f(e):f.current=e),V.current=e,t}let W=Y(e=>{if(!e||e.disabled)return;H.current||=e;let t=V.current,n=e.checked||t==null||t.disabled?U(e):void 0;return()=>{H.current===e&&(H.current=null),V.current===e?n?(n(),V.current=null):U(null):n?.()}}),te=Y(()=>{let e=A.current;if(!e)return P??null;for(let t of w.registeredInputs.keys())if(t.checked&&Qt(t,e))return P??null;return null});Yt(B,N,P??null,te,!j,d),b(P,()=>{k(M),T(P!==D.initialValue),E(P!=null),w.change(P);let e=H.current;P==null&&e&&!e.disabled&&U(e)});let ne=O??ee?.legendId,re={...C,disabled:j??!1,required:o??!1,readOnly:a??!1},ie=Q.useMemo(()=>({checkedValue:P,disabled:j,form:u,validation:w,name:M,readOnly:a,registerInputRef:W,required:o,setCheckedValue:R,setTouched:L,touched:I}),[P,j,u,w,M,a,W,o,R,L,I]),G={id:p,role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":j||void 0,"aria-readonly":a||void 0,"aria-labelledby":ne,onFocus(){v(!0)},onBlur(e){Le(e.currentTarget,e.relatedTarget)||(_(!0),v(!1),y===`onBlur`&&w.commit(P))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&(L(!0),v(!0))}};return(0,$.jsx)(Lt.Provider,{value:ie,children:(0,$.jsx)(Jt,{render:n,className:r,style:h,state:re,props:[G,g,e=>w.getValidationProps(j??!1,e)],refs:[t],stateAttributesMapping:xt,enableHomeAndEndKeys:!1,modifierKeys:tn})})}),rn=Oe(`group/option relative flex touch-none items-start gap-2.5 overflow-hidden rounded-md border p-3 text-start transition-[border-color,background-color] duration-150 ease-out outline-none select-none hover:bg-secondary/50 focus-visible:bg-secondary/50 focus-visible:ring-3 focus-visible:ring-ring/50 data-checked:border-foreground`,{variants:{variant:{default:`border-border hover:border-subtle`,sent:`border-muted-foreground hover:border-foreground`}},defaultVariants:{variant:`default`}});function an({className:e,...t}){return(0,$.jsx)(nn,{className:X(`grid w-full gap-2`,e),"data-slot":`radio-group`,...t})}function on({className:e,variant:t,children:n,...r}){return(0,$.jsxs)(Ht,{className:X(rn({variant:t,className:e})),"data-slot":`radio-group-item`,...r,children:[(0,$.jsx)(`span`,{className:`mt-1 grid size-3.5 shrink-0 place-items-center rounded-full border border-muted-foreground group-data-checked/option:border-foreground`,children:(0,$.jsx)(Ut,{className:`size-1.5 rounded-full bg-foreground`})}),n]})}var sn=500,cn=new Set([` `,`Enter`]),ln=({hasJustSent:e})=>(0,$.jsxs)(`span`,{className:X(`inline-flex items-center gap-1 rounded-sm border border-border px-1.5 text-xs font-normal text-muted-foreground`,e&&`animate-settle border-success text-success`),children:[e?(0,$.jsx)(O,{className:`size-3`}):null,`Sent`]}),un=({isShown:e})=>(0,$.jsxs)(`span`,{className:X(`ms-auto inline-flex text-subtle transition-colors duration-150 ease-out`,e&&`text-foreground`),children:[(0,$.jsx)(at,{"aria-hidden":!0,className:`size-3.5`}),(0,$.jsx)(`span`,{className:`sr-only`,children:e?`On the slide`:`Click to preview on the slide`})]}),dn=({option:e,isSent:t,isDraft:n,isShown:r,isHolding:i,hasJustSent:a,onHoldStart:o,onHoldEnd:s})=>(0,$.jsxs)(on,{onKeyDown:t=>{cn.has(t.key)&&!t.repeat&&o(e.value)},onKeyUp:e=>{cn.has(e.key)&&s()},onPointerCancel:s,onPointerDown:()=>{o(e.value)},onPointerLeave:s,onPointerUp:s,value:e.value,variant:t?`sent`:`default`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 hold-fill bg-foreground/10`,"data-holding":i}),(0,$.jsxs)(`span`,{className:`relative grid min-w-0 flex-1 gap-0.5`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[e.label,t?(0,$.jsx)(ln,{hasJustSent:a}):null,e.blocks===void 0?null:(0,$.jsx)(un,{isShown:r})]}),e.recommended===!0?(0,$.jsx)(`span`,{className:`text-xs text-success`,children:`Recommended`}):null,e.hint===void 0?null:(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.hint}),n?(0,$.jsx)(`span`,{className:`animate-enter text-xs text-subtle`,children:`Hold to send · ⌘↵`}):null]})]}),fn=e=>{let t=(0,Q.useRef)(null),[n,r]=(0,Q.useState)(null),i=()=>{t.current!==null&&(clearTimeout(t.current),t.current=null),r(null)};return{holding:n,handleStart:n=>{i(),r(n),t.current=setTimeout(()=>{t.current=null,r(null),e(n)},sn)},handleEnd:i}},pn=({deck:e,view:t,live:n,draft:r,shown:i,onDraft:a})=>{let o=n.answers[t.id]?.choice??null,[s,l]=(0,Q.useState)(null),u=async r=>{await c(e,t.id,{choice:r,note:n.answers[t.id]?.note??``}),a(null),l(r)},d=fn(u);return Ke(`keydown`,e=>{h(e,v.submit)&&r!==null&&(e.preventDefault(),u(r))}),(0,$.jsx)(an,{"aria-label":`Your call`,onValueChange:e=>{let t=typeof e==`string`?e:null;a(t===o?null:t)},value:r??o??``,children:t.options.map(e=>(0,$.jsx)(dn,{hasJustSent:s===e.value,isDraft:r===e.value,isHolding:d.holding===e.value&&o!==e.value,isSent:o===e.value,isShown:i===e.value,onHoldEnd:d.handleEnd,onHoldStart:e=>{e!==o&&d.handleStart(e)},option:e},e.value))})},mn=({deck:e,view:t,live:n,draft:r,shown:i,onDraft:a})=>(0,$.jsxs)(`aside`,{className:`flex flex-col gap-4 border-t border-border p-4 xl:fixed xl:inset-y-0 xl:inset-e-0 xl:w-85 xl:overflow-hidden xl:border-s xl:border-t-0 xl:bg-background`,"data-gallery-scope":!0,children:[t.options.length>0?(0,$.jsx)(pn,{deck:e,draft:r,live:n,onDraft:a,shown:i,view:t}):null,(0,$.jsx)(gt,{deck:e,live:n,view:t})]}),hn=(e,t)=>({...t,handleReply:async(t,n)=>{await a({data:{deck:e,point:t.point,revision:t.revision,path:t.path,side:t.side,start:t.start,end:t.end,code:t.code,body:n,parent:t.id,media:t.media??null,time:t.time??null,pinX:t.pinX??null,pinY:t.pinY??null}}),await f(e)},handleResolve:async(t,n)=>{await r({data:{deck:e,id:t.id,resolved:n}}),await f(e)}}),gn=({deck:e,point:t,live:n})=>{let r=W(),i=se(n.comments),o=p(n,t);return{revision:o,actions:hn(e,i),forFile:(n,i,s)=>{let c=r.forFile(n,s);return{...c,handlePost:async n=>{let l=c.selected?be(s,c.selected):null;if(l===null)return;let u={...ye(l),code:l.code};await a({data:{deck:e,point:t,revision:o,path:i,...u,body:n,parent:null}}),await f(e),r.clear()}}}}},_n=({deck:e,view:t,live:n,block:r,blockIndex:i})=>{let{revision:a,actions:o,forFile:s}=gn({deck:e,point:t.id,live:n});return(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-3`,children:[r.title===void 0?null:(0,$.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:r.title}),r.files.map(t=>{let r=`${String(i)}:${t.path}`;return(0,$.jsx)(ge,{actions:o,deck:e,file:t,live:n,revision:a,selection:s(r,t.path,t.rows)},r)})]})},vn=2,yn=50,bn=e=>e.length===vn&&/^before/iu.test(e[0]?.label??``)&&/^after/iu.test(e[1]?.label??``),xn=({url:e})=>(0,$.jsx)(Z,{label:`Open in Storybook`,nativeButton:!1,render:(0,$.jsx)(`a`,{"aria-label":`Open in Storybook`,href:e,rel:`noreferrer`,target:`_blank`}),size:`icon-xs`,children:(0,$.jsx)(rt,{})}),Sn=({shot:e,src:t,onOpen:n})=>(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col overflow-hidden rounded-md border border-border`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-9 items-center justify-between gap-2 border-b border-border bg-wash px-3 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:e.label}),e.story===void 0?null:(0,$.jsx)(xn,{url:e.story})]}),(0,$.jsx)(`div`,{className:`grid place-items-center bg-shot p-3`,children:(0,$.jsx)(`button`,{className:`cursor-zoom-in hover-outline`,onClick:n,type:`button`,children:(0,$.jsx)(`img`,{alt:e.alt,className:`block h-auto max-w-full`,src:t})})})]}),Cn=({before:e,after:t,story:n,onOpen:r})=>{let i=(0,Q.useRef)(null);return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col overflow-hidden rounded-md border border-border`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-9 items-center justify-between gap-4 border-b border-border bg-wash px-3 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:e.label}),n===void 0?null:(0,$.jsx)(xn,{url:n}),(0,$.jsx)(`span`,{children:t.label})]}),(0,$.jsx)(`div`,{className:`grid place-items-center bg-shot p-3`,children:(0,$.jsxs)(`div`,{className:`group/compare relative grid w-fit`,ref:i,children:[(0,$.jsx)(`img`,{alt:e.label,className:`col-start-1 row-start-1 block h-auto max-w-full`,src:e.src}),(0,$.jsx)(`img`,{alt:t.label,className:`col-start-1 row-start-1 block h-auto max-w-full compare-after`,src:t.src}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 compare-divider w-0.5 bg-accent group-hover/compare:w-1`}),(0,$.jsx)(`input`,{"aria-label":`Drag to compare before and after`,className:`absolute inset-0 m-0 size-full cursor-ew-resize opacity-0`,defaultValue:yn,max:100,min:0,onInput:e=>i.current?.style.setProperty(`--split`,`${e.currentTarget.value}%`),type:`range`})]})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border px-3 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:`Before`}),(0,$.jsx)(Z,{label:`Full size`,onClick:r,size:`icon-xs`,children:(0,$.jsx)(z,{})}),(0,$.jsx)(`span`,{children:`After`})]})]})},wn=()=>{let[e,t]=(0,Q.useState)({});return{isSame:e[0]!==void 0&&e[0]===e[1],onLoad:e=>n=>{let{naturalWidth:r,naturalHeight:i}=n.currentTarget;t(t=>({...t,[e]:`${String(r)}x${String(i)}`}))}}},Tn=({deck:e,block:t})=>{let n=oe(),r=t.shots.map(t=>({src:w(e,t.src),label:t.label})),{isSame:i,onLoad:a}=wn(),[o,s]=r,c=bn(t.shots);return(0,$.jsxs)(`figure`,{className:`m-0 grid grid-cols-1 gap-2`,children:[t.title===void 0?null:(0,$.jsx)(`figcaption`,{className:`text-sm text-muted-foreground`,children:t.title}),c&&i&&o&&s?(0,$.jsx)(Cn,{after:s,before:o,onOpen:()=>{n([r],0)},story:t.shots.find(e=>e.story!==void 0)?.story}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:t.shots.map((e,t)=>(0,$.jsx)(Sn,{onOpen:()=>{n(r.map(e=>[e]),t)},shot:e,src:r[t]?.src??``},e.src))}),c?(0,$.jsx)(`span`,{className:`hidden`,children:r.map((e,t)=>(0,$.jsx)(`img`,{alt:``,onLoad:a(t),src:e.src},e.src))}):null]})},En=(e,t)=>e.filter(e=>e.parent===null&&e.media===t).toSorted((e,t)=>(e.time??0)-(t.time??0)||e.at.localeCompare(t.at)).map(t=>({root:t,replies:e.filter(e=>e.parent===t.id),isOutdated:!1})),Dn=({deck:e,point:t,live:n,media:r,placeholder:i,getAnchor:o,onPosted:s,onSelect:c})=>{let l=p(n,t),u=En(n.comments,r),d=hn(e,se(n.comments));return(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[u.map((t,r)=>(0,$.jsxs)(`div`,{className:`grid gap-1`,children:[c===void 0?null:(0,$.jsx)(Xe,{label:`Show this spot on the snapshot`,children:(0,$.jsx)(`button`,{className:`w-fit text-xs hover-text`,onClick:()=>{c(t.root)},type:`button`,children:`#${String(r+1)} · show`})}),(0,$.jsx)(ce,{actions:d,deck:e,live:n,revision:l,thread:t})]},t.root.id)),(0,$.jsx)(R,{deck:e,onSubmit:async n=>{await a({data:{deck:e,point:t,revision:l,path:null,side:`new`,start:null,end:null,code:``,body:n,parent:null,media:r,...o()}}),s?.(),await f(e)},placeholder:i,submitLabel:`Comment`})]})},On=({rows:e,offset:t,selection:n,byRow:r,...i})=>e.map((e,a)=>{let o=t+a;return(0,$.jsxs)(`div`,{className:`contents`,children:[(0,$.jsx)(te,{index:o,row:e,selection:n,children:(0,$.jsx)(`span`,{className:`diff-sticky diff-at-old pe-3 text-end text-subtle tabular-nums select-none`,children:e.new})}),(0,$.jsx)(de,{index:o,selection:n,threads:r.get(o)??[],...i})]},`${String(e.new)}-${e.code}`)}),kn=({rows:e,...t})=>(0,$.jsx)(`div`,{className:`min-w-0 overflow-x-auto overscroll-x-contain py-2 font-mono text-xs/relaxed sm:text-sm/relaxed`,children:(0,$.jsx)(`div`,{className:`grid w-max min-w-full source-rows`,children:(0,$.jsx)(On,{...t,offset:0,rows:e})})}),An=({deck:e,point:t,live:n,source:r})=>{let{revision:i,actions:a,forFile:o}=gn({deck:e,point:t,live:n}),s=r.path.split(`/`).at(-1)??r.path,{byRow:c,loose:l}=U(r.rows,{comments:n.comments.filter(e=>e.point===t),path:r.path,revision:i}),u={deck:e,live:n,revision:i,actions:a};return(0,$.jsxs)(`section`,{"aria-label":`Test source`,className:`grid grid-cols-1 border-y border-border`,children:[(0,$.jsx)(`div`,{className:`flex border-b border-border bg-wash px-3 py-2 font-mono text-xs text-subtle`,children:(0,$.jsx)(Xe,{label:r.path,children:(0,$.jsx)(`span`,{className:`min-w-0 truncate tabular-nums`,children:`${s}:${String(r.start)}`})})}),(0,$.jsx)(kn,{byRow:c,rows:r.rows,selection:o(r.path,r.path,r.rows),...u}),(0,$.jsx)(ne,{threads:l,...u})]})},jn=10,Mn=async(e,t)=>{e.currentTime=t;try{await e.play()}catch{e.pause()}},Nn=({deck:e,point:t,live:n,media:r,video:i})=>(0,$.jsx)(Dn,{deck:e,getAnchor:()=>({time:Math.round((i.current?.currentTime??0)*jn)/jn,pinX:null,pinY:null}),live:n,media:r,onSelect:e=>{i.current&&typeof e.time==`number`&&Mn(i.current,e.time)},placeholder:`Pause where something looks off, then comment on that moment`,point:t}),Pn=({deck:e,point:t,live:n,block:r})=>{let i=(0,Q.useRef)(null);return(0,$.jsxs)(`figure`,{className:`m-0 grid grid-cols-1 gap-2 rounded-md border border-border`,children:[(0,$.jsxs)(`figcaption`,{className:`grid gap-0.5 border-b border-border bg-wash px-3 py-2`,children:[(0,$.jsx)(`span`,{className:`text-sm text-foreground`,children:r.title}),(0,$.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:`${r.spec} · ${r.pr}`})]}),(0,$.jsx)(`div`,{className:`grid place-items-center bg-black`,children:(0,$.jsx)(`video`,{className:`block h-auto video-height w-full`,controls:!0,poster:r.poster===void 0?void 0:w(e,r.poster),preload:`metadata`,ref:i,src:w(e,r.video),children:(0,$.jsx)(`track`,{kind:`captions`})})}),r.source===null?null:(0,$.jsx)(An,{deck:e,live:n,point:t,source:r.source}),(0,$.jsx)(`div`,{className:`px-3 pb-3`,children:(0,$.jsx)(Nn,{deck:e,live:n,media:r.video,point:t,video:i})})]})},Fn=` > `,In=/^(?<when>when\s.+?)\s+(?<then>then\s.+)$/isu,Ln=/^then\s/iu,Rn=e=>{let t=e.split(Fn).map(e=>e.trim()),n=t.at(-1)??``,r=t.slice(0,-1).join(` › `);return t.length>1&&Ln.test(n)&&r!==``?{whenLine:r,thenLine:n}:null},zn=e=>{let t=In.exec(e)?.groups;return t?.when===void 0||t.then===void 0?null:{whenLine:t.when,thenLine:t.then}},Bn=e=>{let t=e.trim();return Rn(t)??zn(t)??{whenLine:null,thenLine:t}},Vn=({block:e})=>{let{editor:t}=Ye(),n=e.source?.start??1,r=re({worktree:e.worktree,path:e.file,isDeleted:!1,editor:t},n);if(r===null)return null;let i=`Open ${e.spec}:${String(n)} in ${ie[t]}`;return(0,$.jsx)(Z,{label:i,nativeButton:!1,render:(0,$.jsx)(`a`,{"aria-label":i,href:r,onClick:n=>{n.preventDefault(),_e(r,V(e.worktree,t))},rel:`noopener`}),size:`icon-xs`,children:(0,$.jsx)(D,{})})},Hn=({deck:e,point:t,live:n,block:r,video:i})=>{let{whenLine:a,thenLine:o}=Bn(r.title);return(0,$.jsxs)(`aside`,{"aria-label":`Recording`,className:`pointer-events-auto flex recording-panel flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3 bg-wash py-3 ps-4 pe-3`,children:[(0,$.jsxs)(`div`,{className:`grid min-w-0 flex-1 gap-1`,children:[a===null?null:(0,$.jsx)(`p`,{className:`m-0 text-xs/5 text-muted-foreground`,children:a}),(0,$.jsx)(`p`,{className:`m-0 text-sm/5 font-medium text-foreground`,children:o}),(0,$.jsx)(`p`,{className:`m-0 truncate pt-1 font-mono text-xs text-subtle`,children:r.source===null?`${r.spec} · ${r.pr}`:r.pr})]}),(0,$.jsx)(Vn,{block:r})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto overscroll-contain`,children:[r.source===null?null:(0,$.jsx)(An,{deck:e,live:n,point:t,source:r.source}),(0,$.jsx)(`div`,{className:X(`px-4 py-3`,r.source===null&&`border-t border-border`),children:(0,$.jsx)(Nn,{deck:e,live:n,media:r.video,point:t,video:i})})]})]})},Un=({deck:e,point:t,live:n,blocks:r,index:i,onIndex:a,onClose:o})=>{let s=(0,Q.useRef)(null),c=r[i];return c===void 0?null:(0,$.jsx)(C,{count:r.length,index:i,noun:`recording`,onClose:o,onIndex:a,title:c.title,children:(0,$.jsxs)(`div`,{className:`pointer-events-none relative recording-stage`,children:[(0,$.jsx)(`div`,{className:`pointer-events-auto grid place-items-center overflow-hidden rounded-md border border-border bg-black`,children:(0,$.jsx)(`video`,{autoPlay:!0,className:`block h-auto recording-fit w-full`,controls:!0,"data-recording-video":!0,muted:!0,playsInline:!0,poster:c.poster===void 0?void 0:w(e,c.poster),preload:`auto`,ref:s,src:w(e,c.video),children:(0,$.jsx)(`track`,{kind:`captions`})},c.video)}),(0,$.jsx)(Hn,{block:c,deck:e,live:n,point:t,video:s})]})})},Wn=60,Gn=2,Kn=e=>{let t=Math.max(1,Math.floor(e));return`${String(Math.floor(t/Wn))}:${String(t%Wn).padStart(Gn,`0`)}`},qn=(e,t)=>{let n=t.source?.start??0,r=n+(t.source?.rows.length??0)-1,i=e.start??n-1;return(e.media??null)===null&&e.path===t.file&&i>=n&&i<=r},Jn=(e,t,n)=>e.comments.filter(e=>e.parent===null&&e.point===t&&e.resolved!==!0&&(e.media===n.video||qn(e,n))).length,Yn=(e,t)=>t.title.whenLine!==null&&e?.title.whenLine===t.title.whenLine,Xn=e=>{let t=[];for(let n of e){let e=t.at(-1);e!==void 0&&Yn(e.entries.at(-1),n)?e.entries.push(n):t.push({when:n.title.whenLine,entries:[n]})}return t},Zn=e=>{let t=[];for(let n of Xn(e)){let e=t.at(-1);n.entries.length>1?t.push(n):e?.when===null?e.entries.push(...n.entries):t.push({when:null,entries:n.entries})}return t},Qn=({deck:e,block:t})=>(0,$.jsxs)(`span`,{className:`relative block aspect-16/10 overflow-hidden rounded-md border border-border bg-wash hover-outline-group`,children:[t.poster===void 0?null:(0,$.jsx)(`img`,{alt:``,className:`block size-full object-cover`,decoding:`async`,loading:`lazy`,src:w(e,t.poster)}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-0 grid place-items-center opacity-80 transition-opacity duration-150 ease-out group-hover:opacity-100 group-focus-visible:opacity-100`,children:(0,$.jsx)(`span`,{className:`grid size-9 place-items-center rounded-full border border-border bg-overlay text-foreground`,children:(0,$.jsx)(L,{className:`size-3.5 translate-x-px fill-current`})})}),t.seconds===null?null:(0,$.jsx)(`span`,{className:`absolute inset-e-1.5 bottom-1.5 rounded-sm bg-overlay px-1.5 font-mono text-xs/5 text-foreground tabular-nums`,children:Kn(t.seconds)})]}),$n=({deck:e,entry:t,isGrouped:n,onOpen:r})=>{let{block:i,title:a,comments:o}=t,s=`${String(o)} ${o===1?`comment`:`comments`}`;return(0,$.jsx)(`li`,{className:`min-w-0`,children:(0,$.jsxs)(`button`,{"aria-label":`Play ${i.title}${o===0?``:`, ${s}`}`,className:`group grid w-full gap-2 rounded-md text-start outline-none`,"data-recording-thumb":!0,onClick:()=>{r(t.index)},type:`button`,children:[(0,$.jsx)(Qn,{block:i,deck:e}),(0,$.jsxs)(`span`,{className:`grid gap-0.5 px-0.5`,children:[n||a.whenLine===null?null:(0,$.jsx)(`span`,{className:`line-clamp-2 text-xs/4 text-muted-foreground`,children:a.whenLine}),(0,$.jsx)(`span`,{className:`line-clamp-3 text-sm/5 text-foreground`,children:a.thenLine}),o===0?null:(0,$.jsxs)(`span`,{className:`flex items-center gap-1 pt-0.5 text-xs text-subtle tabular-nums`,children:[(0,$.jsx)(lt,{"aria-hidden":!0,className:`size-3`}),o]})]})]})})},er=({deck:e,entries:t,isGrouped:n,onOpen:r})=>(0,$.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-x-4 gap-y-5 p-0 @sm:grid-cols-2 @xl:grid-cols-3 @4xl:grid-cols-4`,children:t.map(t=>(0,$.jsx)($n,{deck:e,entry:t,isGrouped:n,onOpen:r},t.block.video))}),tr=e=>[...new Set(e.map(e=>e.spec))].join(` · `),nr=e=>[...new Set(e.map(e=>e.pr))].join(` · `),rr=({deck:e,point:t,live:n,blocks:r})=>{let[i,a]=(0,Q.useState)(null),o=r.map((e,r)=>({block:e,index:r,title:Bn(e.title),comments:Jn(n,t,e)}));return(0,$.jsxs)(`section`,{"aria-label":`Recordings`,className:`@container grid grid-cols-1 rounded-md border border-border`,"data-recording-grid":!0,children:[(0,$.jsxs)(`header`,{className:`flex min-w-0 items-center gap-2 border-b border-border bg-wash px-3 py-2`,children:[(0,$.jsx)(`span`,{className:`text-sm text-foreground`,children:`Recordings`}),(0,$.jsx)(`span`,{className:`rounded-full bg-secondary px-1.5 text-xs/5 text-muted-foreground tabular-nums`,children:r.length}),(0,$.jsx)(`span`,{className:`ms-auto min-w-0 truncate font-mono text-xs text-muted-foreground`,children:`${tr(r)} · ${nr(r)}`})]}),(0,$.jsx)(`div`,{className:`grid gap-5 p-3`,children:Zn(o).map(t=>(0,$.jsxs)(`div`,{className:`grid gap-2.5`,children:[t.when===null?null:(0,$.jsx)(`h3`,{className:`m-0 text-xs font-medium text-muted-foreground`,children:t.when}),(0,$.jsx)(er,{deck:e,entries:t.entries,isGrouped:t.when!==null,onOpen:a})]},t.entries[0]?.block.video))}),i===null?null:(0,$.jsx)(Un,{blocks:r,deck:e,index:i,live:n,onClose:()=>{a(null)},onIndex:a,point:t})]})},ir=100,ar=(e,t)=>Math.min(1,Math.max(0,e/t)),or=e=>{let t=e.currentTarget.getBoundingClientRect();return{pinX:ar(e.clientX-t.left,t.width),pinY:ar(e.clientY-t.top,t.height)}},sr=({pinX:e,pinY:t})=>n=>{n?.style.setProperty(`--pin-left`,`${String(e*ir)}%`),n?.style.setProperty(`--pin-top`,`${String(t*ir)}%`)},cr=({pin:e,label:t,isDraft:n=!1})=>(0,$.jsx)(`span`,{"aria-hidden":!0,className:n?`pointer-events-none absolute inset-s-(--pin-left) top-(--pin-top) grid size-6 -translate-1/2 place-items-center rounded-full border-2 border-accent bg-background text-xs text-foreground`:`pointer-events-none absolute inset-s-(--pin-left) top-(--pin-top) grid size-6 -translate-1/2 place-items-center rounded-full bg-accent text-xs text-white`,ref:sr(e),children:t}),lr=({deck:e,point:t,live:n,block:r})=>{let[i,a]=(0,Q.useState)(null),o=oe(),s=w(e,r.image),c=En(n.comments,r.image).flatMap((e,t)=>typeof e.root.pinX==`number`&&typeof e.root.pinY==`number`?[{pin:{pinX:e.root.pinX,pinY:e.root.pinY},label:String(t+1)}]:[]);return(0,$.jsxs)(`figure`,{className:`m-0 grid grid-cols-1 gap-2 rounded-md border border-border`,children:[(0,$.jsxs)(`figcaption`,{className:`flex items-center justify-between gap-3 border-b border-border bg-wash px-3 py-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:`${r.component} · ${r.title}`}),(0,$.jsxs)(`span`,{className:`-my-1 flex shrink-0 gap-0.5`,children:[(0,$.jsx)(Z,{label:`Full size`,onClick:()=>{o([[{src:s,label:r.title}]],0)},size:`icon-xs`,children:(0,$.jsx)(z,{})}),(0,$.jsx)(Z,{label:`Open in Storybook`,nativeButton:!1,render:(0,$.jsx)(`a`,{"aria-label":`Open in Storybook`,href:r.url,rel:`noreferrer`,target:`_blank`}),size:`icon-xs`,children:(0,$.jsx)(rt,{})})]})]}),(0,$.jsx)(`div`,{className:`grid place-items-center bg-shot p-3`,children:(0,$.jsxs)(`button`,{"aria-label":`Pin a comment on this snapshot`,className:`relative block cursor-crosshair hover-outline`,onClick:e=>{a(or(e))},type:`button`,children:[(0,$.jsx)(`img`,{alt:`${r.component}, ${r.title}`,className:`block h-auto max-w-full`,src:s}),c.map(e=>(0,$.jsx)(cr,{label:e.label,pin:e.pin},e.label)),i===null?null:(0,$.jsx)(cr,{isDraft:!0,label:`+`,pin:i})]})}),r.source===void 0?null:(0,$.jsx)(`p`,{className:`m-0 px-3 text-xs text-subtle`,children:r.source}),(0,$.jsx)(`div`,{className:`px-3 pb-3`,children:(0,$.jsx)(Dn,{deck:e,getAnchor:()=>({time:null,pinX:i?.pinX??null,pinY:i?.pinY??null}),live:n,media:r.image,onPosted:()=>{a(null)},placeholder:i===null?`Comment on this snapshot, or click it to pin a spot`:`Comment on the pinned spot`,point:t})})]})},ur=({segment:e})=>e.op===`del`?(0,$.jsx)(`del`,{className:`text-sign-del decoration-sign-del`,children:e.text}):e.op===`add`?(0,$.jsx)(`ins`,{className:`rounded-sm bg-line-add px-0.5 text-sign-add no-underline`,children:e.text}):(0,$.jsx)(`span`,{className:`text-subtle`,children:e.text}),dr=({block:e})=>(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-3`,children:[e.title===void 0?null:(0,$.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:e.title}),(0,$.jsx)(`ul`,{className:`m-0 list-none overflow-hidden rounded-md border border-border p-0`,children:e.rows.map((e,t)=>(0,$.jsxs)(`li`,{className:`flex flex-col gap-0.5 border-b border-border px-3 py-2 transition-colors duration-150 ease-out last:border-b-0 hover:bg-row-hover sm:flex-row sm:gap-3`,children:[e.label===void 0?null:(0,$.jsx)(`span`,{className:`shrink-0 text-xs/6 text-subtle tabular-nums sm:w-20`,children:e.label}),(0,$.jsx)(`p`,{className:`m-0 min-w-0 text-sm/6 wrap-break-word`,children:e.segments.map((e,t)=>(0,$.jsx)(ur,{segment:e},`${String(t)}-${e.op}`))})]},`${String(t)}-${e.label??``}`))})]}),fr=({deck:e,block:t})=>t.kind===`media`?(0,$.jsx)(Tn,{block:t,deck:e}):t.kind===`wording`?(0,$.jsx)(dr,{block:t}):(0,$.jsx)(I,{className:`border-s-2 border-foreground ps-3`,deck:e,text:t.markdown}),pr=3,mr=e=>e.kind===`recording`,hr=e=>{let t=e.filter(e=>mr(e)).length>=pr;return e.reduce((e,n,r)=>{let i=e.at(-1);return!t||!mr(n)?[...e,{block:n,index:r}]:i!==void 0&&`recordings`in i&&i.index+i.recordings.length===r?(i.recordings.push(n),e):[...e,{recordings:[n],index:r}]},[])},gr=({deck:e,view:t,live:n,block:r,index:i})=>r.kind===`code`?(0,$.jsx)(_n,{block:r,blockIndex:i,deck:e,live:n,view:t}):r.kind===`review`?(0,$.jsx)(he,{stub:r,blockIndex:i,deck:e,live:n,view:t}):r.kind===`story`?(0,$.jsx)(lr,{block:r,deck:e,live:n,point:t.id}):r.kind===`recording`?(0,$.jsx)(Pn,{block:r,deck:e,live:n,point:t.id}):(0,$.jsx)(fr,{block:r,deck:e}),_r=(e,t)=>e.kind===`review`?`review-${e.branch}`:e.kind===`story`?`story-${e.storyId}`:e.kind===`recording`?`recording-${e.video}`:`${e.kind}-${String(t)}`,vr=({deck:e,view:t,live:n,blocks:r})=>hr(r).map(r=>`recordings`in r?(0,$.jsx)(rr,{blocks:r.recordings,deck:e,live:n,point:t.id},`recordings-${r.recordings[0]?.video??String(r.index)}`):(0,$.jsx)(gr,{block:r.block,deck:e,index:r.index,live:n,view:t},_r(r.block,r.index))),yr=(e,t)=>t?.blocks===void 0?{key:``,label:null,blocks:e.blocks}:{key:t.value,label:t.label,blocks:[...e.blocks.filter(e=>e.kind!==`code`&&e.kind!==`review`),...t.blocks]},br=e=>{let[t,n]=(0,Q.useState)(e),[r,i]=(0,Q.useState)(null);return t.key!==e.key&&(i(t),n(e)),{leaving:r,handleLeft:()=>{i(null)}}},xr=({deck:e,view:t,live:n,showing:r})=>(0,$.jsxs)($.Fragment,{children:[r.label===null?null:(0,$.jsxs)(`p`,{className:`m-0 text-xs text-subtle`,children:[`Showing: `,(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:r.label})]}),(0,$.jsx)(vr,{blocks:r.blocks,deck:e,live:n,view:t})]}),Sr=e=>{let{leaving:t,handleLeft:n}=br(e.showing);return(0,$.jsxs)(`div`,{className:`grid grid-cols-1`,children:[t===null?null:(0,$.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none col-start-1 row-start-1 grid animate-fade-out grid-cols-1 content-start gap-4`,inert:!0,onAnimationEnd:e=>{e.target===e.currentTarget&&n()},children:(0,$.jsx)(xr,{...e,showing:t})},`leaving-${t.key}`),(0,$.jsx)(`div`,{className:X(`col-start-1 row-start-1 grid grid-cols-1 content-start gap-4`,t!==null&&`animate-fade-in`),children:(0,$.jsx)(xr,{...e})},`shown-${e.showing.key}`)]})},Cr=({deck:e,view:t,live:n,shown:r})=>(0,$.jsxs)(`article`,{className:`mx-auto grid max-w-228 animate-enter grid-cols-1 gap-4`,"data-gallery-scope":!0,children:[(0,$.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:t.sectionTitle}),(0,$.jsx)(`h1`,{className:`m-0 text-2xl/tight font-semibold tracking-tight`,children:t.title}),(0,$.jsx)(I,{className:`[&>*:not(.deck-table-scroll)]:max-w-prose`,deck:e,text:t.prose}),(0,$.jsx)(Sr,{deck:e,live:n,showing:yr(t,r),view:t})]});function wr({className:e,orientation:t=`horizontal`,...n}){return(0,$.jsx)(me,{"data-slot":`separator`,orientation:t,className:X(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...n})}var Tr=({deck:e,point:t,onCopyLink:n})=>{let r=Ze(),i=async(e,t)=>{await navigator.clipboard.writeText(e),r.add({title:t})};return(0,$.jsxs)(le,{children:[(0,$.jsx)(ue,{render:(0,$.jsx)(Z,{label:`More actions`,variant:`ghost`}),children:(0,$.jsx)(k,{})}),(0,$.jsxs)(pe,{children:[(0,$.jsxs)(G,{onClick:()=>{n()},children:[(0,$.jsx)(st,{}),`Copy link`,(0,$.jsx)(H,{children:v.copyLink.keys.join(``)})]}),(0,$.jsxs)(G,{onClick:()=>{i(t,`Point id copied`)},children:[(0,$.jsx)(fe,{}),`Copy point id`]}),(0,$.jsxs)(G,{onClick:()=>{i(`~/review-decks/${e}/points/${t}.md`,`File path copied`)},children:[(0,$.jsx)(E,{}),`Copy point file path`]})]})]})},Er=({summary:e,view:t,live:n,index:r,hasNextOpen:i,onStep:a,onNextOpen:o,onCopyLink:s})=>{let c=e.points.filter(e=>!!n.answers[e.id]?.choice).length;return(0,$.jsxs)(`header`,{className:`sticky top-0 z-10 flex h-14 items-center gap-1 border-b border-border bg-background px-3 xl:ms-70 xl:me-85`,children:[(0,$.jsx)(Z,{disabled:r<=0,label:`Previous point`,onClick:()=>{a(-1)},shortcut:v.previous,children:(0,$.jsx)($e,{})}),(0,$.jsxs)(`span`,{className:`min-w-16 text-center text-sm text-muted-foreground tabular-nums`,children:[r+1,` / `,e.points.length]}),(0,$.jsx)(Z,{disabled:r>=e.points.length-1,label:`Next point`,onClick:()=>{a(1)},shortcut:v.next,children:(0,$.jsx)(B,{})}),(0,$.jsx)(`span`,{className:`mx-1 flex h-5`,children:(0,$.jsx)(wr,{orientation:`vertical`})}),(0,$.jsx)(Z,{disabled:!i,label:`Next point waiting for you`,onClick:o,shortcut:v.nextOpen,children:(0,$.jsx)(tt,{})}),(0,$.jsxs)(`span`,{className:`ms-auto me-2 text-sm text-muted-foreground tabular-nums`,children:[c,` of `,e.points.length,` answered`]}),(0,$.jsx)(Tr,{deck:e.name,onCopyLink:s,point:t.id})]})},Dr=e=>{let[t,n]=(0,Q.useState)(null);return t!==null&&t.point!==e&&n(null),{draft:t?.point===e?t.value:null,handleDraft:t=>{n(t===null?null:{point:e,value:t})}}},Or=(e,t,n)=>{let r=t??n;return e.options.find(e=>e.value===r)??e.options.find(e=>e.recommended===!0)??null},kr=()=>{let e=Ze();return async()=>{await navigator.clipboard.writeText(globalThis.location.href),e.add({title:`Link copied`})}},Ar=(e,t,n)=>{let r=o(),i=kr(),a=e.points.findIndex(e=>e.id===t),s=y(e.points,n,t),c=t=>{t!==void 0&&r({to:`/decks/$deck/$point`,params:{deck:e.name,point:t}})},l=t=>{c(e.points[a+t]?.id)};return Ke(`keydown`,e=>{_(e.target)||g()||((h(e,v.previous)||h(e,v.next))&&l(e.key===`ArrowLeft`?-1:1),h(e,v.nextOpen)&&c(s?.id),h(e,v.copyLink)&&i())}),{index:a,hasNextOpen:s!==void 0,handleStep:l,handleNextOpen:()=>{c(s?.id)},handleCopyLink:i}},jr=t(`/decks/$deck`),Mr=t(`/decks/$deck/$point`),Nr=()=>{let e=Mr.useLoaderData(),{summary:t,live:n}=jr.useLoaderData(),r=s(t.name,n),{index:i,hasNextOpen:a,handleStep:o,handleNextOpen:c,handleCopyLink:l}=Ar(t,e.id,r),{draft:d,handleDraft:f}=Dr(e.id),p=Or(e,d,r.answers[e.id]?.choice??null);return ut(e.id,r.comments.findLast(t=>t.point===e.id)?.at??``),u(t.name,e),(0,$.jsxs)(M,{children:[(0,$.jsx)(Er,{hasNextOpen:a,index:i,live:r,onCopyLink:l,onNextOpen:c,onStep:o,summary:t,view:e}),(0,$.jsx)(`main`,{className:`px-6 pt-6 pb-20 xl:ms-70 xl:me-85`,children:(0,$.jsx)(Cr,{deck:t.name,live:r,shown:p,view:e},e.id)}),(0,$.jsx)(mn,{deck:t.name,draft:d,live:r,onDraft:f,shown:p?.value??null,view:e},`answer-${e.id}`)]})};export{Nr as component};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{L as t,Y as n,d as r,kt as i,u as a,z as o}from"./decks.functions-tXNTG2sC.js";import{c as s,d as c,i as l,l as u,o as d,u as f}from"./viewed-store-Eo50afbB.js";import{b as p,g as m,i as h,n as g,r as _,t as v,y}from"./shortcuts-BsNWbUaT.js";import{A as b,B as x,C as S,D as C,E as w,F as T,G as E,H as D,J as O,K as k,L as A,M as ee,N as j,O as M,P as N,R as P,S as F,T as I,U as L,V as R,W as z,Y as B,_ as V,a as H,b as U,c as W,d as te,f as ne,g as re,h as ie,i as G,j as ae,k as oe,l as se,m as ce,n as le,o as ue,p as de,q as fe,r as pe,s as me,t as he,u as ge,v as _e,w as ve,x as ye,y as be,z as xe}from"./review-block-DYenwozF.js";import{An as Se,At as Ce,Cn as we,Dn as K,En as Te,Fn as Ee,Jn as q,Ln as J,Nn as De,Rn as Y,Sn as Oe,Tn as ke,Xt as Ae,a as je,an as Me,ct as Ne,dt as Pe,ft as Fe,ht as Ie,in as Le,j as Re,jn as ze,k as Be,kn as Ve,lt as He,mt as Ue,s as We,st as Ge,t as Ke,xn as X,xt as qe,zn as Je}from"./use-window-event-BDUVK1pJ.js";import{S as Z,u as Ye,x as Xe,y as Ze}from"./index-CNzMZ6k6.js";var Qe={name:`arrow-left`,size:24,node:[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]};Qe.node;var $e=q(Qe),et={name:`chevrons-right`,size:24,node:[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]]};et.node;var tt=q(et),nt={name:`external-link`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]};nt.node;var rt=q(nt),it={name:`eye`,size:24,node:[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]};it.node;var at=q(it),ot={name:`link`,size:24,node:[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]};ot.node;var st=q(ot),ct={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};ct.node;var lt=q(ct),Q=e(i(),1),ut=(e,t)=>{(0,Q.useEffect)(()=>{l(e,t)},[e,t])},$=n(),dt=1,ft=24,pt=e=>e.scrollHeight-e.scrollTop-e.clientHeight,mt=e=>{e.dataset.fadeTop=String(e.scrollTop>0),e.dataset.fadeBottom=String(pt(e)>dt)},ht=(e,t)=>e.comments.filter(e=>e.point===t&&e.path===null&&typeof e.media!=`string`).toSorted((e,t)=>e.at.localeCompare(t.at)),gt=({deck:e,view:t,live:n})=>{let r=(0,Q.useRef)(!0),i=p(n,t.id),o=ht(n,t.id),s=e=>{e!==null&&(r.current&&(e.scrollTop=e.scrollHeight),mt(e))};return(0,$.jsxs)(`section`,{"aria-label":`Conversation`,className:`flex min-h-0 flex-1 flex-col gap-2.5 pt-2`,children:[(0,$.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,$.jsx)(d,{onScroll:e=>{r.current=pt(e.currentTarget)<ft,mt(e.currentTarget)},variant:`fade`,viewportRef:s,children:(0,$.jsxs)(`div`,{className:`flex min-h-full flex-col gap-2`,children:[(0,$.jsx)(`div`,{className:`mt-auto`}),o.length===0?(0,$.jsx)(`p`,{className:`m-0 text-sm text-subtle`,children:`No messages yet.`}):null,o.map((t,r)=>(0,$.jsx)(ve,{comment:t,deck:e,isBubble:!0,isLatest:r===o.length-1,live:n,revision:i},t.id)),(0,$.jsx)(`div`,{ref:e=>{s(e?.closest(`[data-slot="scroll-area-viewport"]`)??null)}},o.length)]})})}),(0,$.jsx)(R,{deck:e,onSubmit:async n=>{await a({data:{deck:e,point:t.id,revision:i,path:null,side:`new`,start:null,end:null,code:``,body:n,parent:null}}),r.current=!0,await f(e)},placeholder:`Message the agent about this point`,submitLabel:`Send`})]})},_t=`data-valid`,vt=`data-invalid`,yt={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},bt={disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},xt={valid(e){return e===null?null:e?{[_t]:``}:{[vt]:``}}},St=`data-checked`,Ct=`data-unchecked`,wt={checked(e){return e?{[St]:``}:{[Ct]:``}},...Ae,...xt},Tt=`data-composite-item-active`,Et={invalid:void 0,name:void 0,validityData:{state:yt,errors:[],error:``,value:``,initialValue:null},setValidityData:K,disabled:void 0,setTouched:K,setDirty:K,setFilled:K,setFocused:K,validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:bt,registerFieldControl:K,validation:{getValidationProps:(e,t=Te)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:K,getInputControl:()=>null,commit:async()=>{},change:K}},Dt=Q.createContext(Et);function Ot(e=!0){let t=Q.useContext(Dt);if(t.setValidityData===K&&!e)throw Error(Ee(28));return t}var kt=Q.createContext({disabled:!1});function At(){return Q.useContext(kt)}var jt=Q.createContext({controlId:void 0,registerControlId:K,resetControlId:K,labelId:void 0,setLabelId:K,messageIds:[],setMessageIds:K,getDescriptionProps:e=>e});function Mt(){return Q.useContext(jt)}function Nt(e,t,n,r=!0,i){let[a,o]=Q.useState(),s=We(i?`${i}-label`:void 0),c=e??t??a;return J(()=>{let i=e||t||!r?void 0:Pt(n.current,s);a!==i&&o(i)}),c}function Pt(e,t){let n=Ft(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function Ft(e){if(!e)return;let t=e.parentElement;if(t&&t.tagName===`LABEL`)return t;let n=e.id;if(n){let t=e.nextElementSibling;if(t&&t.htmlFor===n)return t}let r=e.labels;return r&&r[0]}function It(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=Mt(),o=We(),s=Je(()=>Symbol()),c=Q.useRef(!1),l=Q.useRef(!1),u=Y(()=>{c.current&&i!==K&&(c.current=!1,i(s.current,void 0))});return J(()=>{if(!n||i===K){u();return}let e;if(t!==void 0)l.current=!0,e=t;else if(l.current)e=o;else{a();return}e===void 0?u():(c.current=!0,i(s.current,e))},[t,n,i,a,o,s,u]),J(()=>u,[u]),(n?r:void 0)??t??o}var Lt=Q.createContext(void 0);function Rt(){return Q.useContext(Lt)}function zt(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}var Bt=Q.createContext(void 0);function Vt(){let e=Q.useContext(Bt);if(e===void 0)throw Error(Ee(52));return e}var Ht=Q.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,readOnly:a=!1,required:o=!1,"aria-labelledby":s,value:c,inputRef:l,nativeButton:u=!1,id:d,style:f,...p}=e,m=Rt(),{disabled:h,readOnly:g,required:_,form:v,checkedValue:y,touched:b=!1,validation:x,name:C,setCheckedValue:w=K,setTouched:T=K,registerInputRef:E=K}=m??{},{setTouched:D,setFilled:O,state:k,disabled:A}=Ot(),ee=At(),{labelId:j,getDescriptionProps:M}=Mt(),N=A||ee.disabled||h||i,P=g||a,F=_||o,I=v,L=m?y===c:c===``,R=Q.useRef(null),z=Q.useRef(null),B=x?.registerInput,V=Q.useCallback(e=>B?.(e,{controlRef:R,value:void 0}),[B]),H=Ve(l,z,E,V);J(()=>{z.current?.checked&&O(!0)},[O]),J(()=>{z.current&&E(N&&L?null:z.current)},[L,N,E]);let U=We(),W=It({id:d}),te=u?void 0:W,ne={role:`radio`,"aria-checked":L,"aria-labelledby":Nt(s,j,z,!u,te),[Tt]:L?``:void 0,id:u?W:U,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){if(e.defaultPrevented||N||P)return;e.preventDefault();let t=z.current;t&&ze(t,e)},onFocus(e){e.defaultPrevented||N||P||!b||(z.current?.click(),T(!1))}},{getButtonProps:re,buttonRef:ie}=Se({disabled:N,native:u,composite:!1}),G={type:`radio`,ref:H,form:I,id:te,name:C,tabIndex:-1,style:C?Ie:Ue,"aria-hidden":!0,...c===void 0?Te:{value:zt(c)},disabled:N,checked:L,required:F,readOnly:P,onChange(e){if(e.nativeEvent.defaultPrevented||N||P||c===void 0)return;let t=qe(Ce,e.nativeEvent);w(c,t),t.isCanceled||D(!0)},onClick(e){e.stopPropagation()},onFocus(){R.current?.focus()}},ae=Q.useMemo(()=>({...k,required:F,disabled:N,readOnly:P,checked:L}),[k,N,P,L,F]),oe=ae,se=m!==void 0,ce=[t,R,ie],le=[ne,p,re,M,x?e=>x.getValidationProps(N,e):Te],ue=we(`span`,e,{enabled:!se,state:ae,ref:ce,props:le,stateAttributesMapping:wt});return(0,$.jsxs)(Bt.Provider,{value:oe,children:[se?(0,$.jsx)(S,{tag:`span`,render:n,className:r,style:f,state:ae,refs:ce,props:le,stateAttributesMapping:wt}):ue,(0,$.jsx)(`input`,{...G,suppressHydrationWarning:!0})]})}),Ut=Q.forwardRef(function(e,t){let{render:n,className:r,style:i,keepMounted:a=!1,...o}=e,s=Vt(),c=s.checked,{mounted:l,transitionStatus:u,setMounted:d}=Re(c),f={...s,transitionStatus:u},p=Q.useRef(null),m=a||l,h=we(`span`,e,{ref:[t,p],state:f,props:o,stateAttributesMapping:wt});return Be({batch:!0,enabled:!c,open:c,ref:p,onComplete(){c||d(!1)}}),m?h:null});function Wt(e){return e==null||e.hasAttribute(`disabled`)||e.getAttribute(`aria-disabled`)===`true`}function Gt(e){let{loopFocus:t=!0,orientation:n=`both`,grid:r,onLoop:i,direction:a,highlightedIndex:o,onHighlightedIndexChange:s,rootRef:c,enableHomeAndEndKeys:l=!1,stopEventPropagation:u,disabledIndices:d,modifierKeys:f=ke}=e,[p,m]=Q.useState(0),h=r!=null,g=Q.useRef(null),_=Ve(g,c),v=Q.useRef([]),y=Q.useRef(!1),b=Q.useRef(null),S=o??p,C=Y((e,t=!1)=>{if(b.current=v.current[e]??null,(s??m)(e),t){let t=v.current[e];x(g.current,t,a,n)}}),w=Y(e=>{if(e.size===0)return;if(y.current){let e=v.current,t=e.indexOf(b.current);if(t===-1){let t=e[S];!t||Fe(e,S,d)?C(Kt(e,d)):b.current=t}else t!==S&&C(t);return}y.current=!0;let t=Array.from(e.keys()),r=t.find(e=>e?.hasAttribute(`data-composite-item-active`))??null,i=r?e.get(r)?.index??-1:-1;if(i!==-1)C(i);else if(Fe(t,S,d)){let e=Ge(t,{disabledIndices:d});Pe(t,e)||C(e)}x(g.current,r,a,n)});J(()=>{if(d==null||o!=null||!y.current)return;let e=v.current;if(Fe(e,S,d)){let t=Ge(e,{disabledIndices:d});Pe(e,t)||C(t)}},[d,o,S,v,C]);let E=Y((e,t,n)=>i?i(e,t,n,v):n),D=Y(e=>{let o=e.key===`Home`||e.key===`End`;if(!T.has(e.key)||!l&&o||qt(e,f)||!g.current)return;let s=a===`rtl`,c=s?ee:j,p=s?j:ee,m=n===`vertical`?ae:c,_=n===`vertical`?N:p,y=Me(e.nativeEvent);if(y!=null&&xe(y)&&!Wt(y)){let t=y.selectionStart,n=y.selectionEnd,r=y.value;if(t==null||e.shiftKey||t!==n||e.key!==_&&t<r.length||e.key!==m&&t>0)return}let b=S,x=He(v,d),w=Ne(v,d);r!=null&&(b=r({disabledIndices:d,elementsRef:v,event:e,highlightedIndex:S,loopFocus:t,maxIndex:w,minIndex:x,onLoop:E,orientation:n,rtl:s}));let D=n!==`vertical`&&e.key===c||n!==`horizontal`&&e.key===`ArrowDown`,O=n!==`vertical`&&e.key===p||n!==`horizontal`&&e.key===`ArrowUp`;l&&(e.key===`Home`?b=x:e.key===`End`&&(b=w)),b===S&&(D||O)&&(t&&b===w&&D?(b=x,i&&(b=i(e,S,b,v))):t&&b===x&&O?(b=w,i&&(b=i(e,S,b,v))):b=Ge(v.current,{startingIndex:b,decrement:O,disabledIndices:d})),b!==S&&!Pe(v.current,b)&&(u&&e.stopPropagation(),(h||o||D||O)&&e.preventDefault(),C(b,!0),queueMicrotask(()=>{v.current[b]?.focus()}))});return{props:{ref:_,onFocus(e){let t=g.current,n=Me(e.nativeEvent);t&&n!=null&&xe(n)&&n.setSelectionRange(0,n.value.length)},onKeyDown:D},highlightedIndex:S,onHighlightedIndexChange:C,elementsRef:v,onMapChange:w,relayKeyboardEvent:D}}function Kt(e,t){let n=-1;for(let r=0;r<e.length;r+=1){let i=e[r];if(i&&!Fe(e,r,t)){if(i.hasAttribute(`data-composite-item-active`))return r;n===-1&&(n=r)}}return Math.max(n,0)}function qt(e,t){for(let n of A)if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}function Jt(e){let{render:t,className:n,style:r,refs:i=ke,props:a=ke,state:o=Te,stateAttributesMapping:s,highlightedIndex:c,onHighlightedIndexChange:l,orientation:u,grid:d,loopFocus:f,onLoop:p,enableHomeAndEndKeys:m,onMapChange:h,stopEventPropagation:g=!0,rootRef:_,disabledIndices:v,modifierKeys:y,highlightItemOnHover:b=!1,tag:x=`div`,...S}=e,{props:C,highlightedIndex:w,onHighlightedIndexChange:T,elementsRef:E,onMapChange:D,relayKeyboardEvent:O}=Gt({grid:d,loopFocus:f,onLoop:p,orientation:u,highlightedIndex:c,onHighlightedIndexChange:l,rootRef:_,stopEventPropagation:g,enableHomeAndEndKeys:m,direction:je(),disabledIndices:v,modifierKeys:y}),k=we(x,e,{state:o,ref:i,props:[C,...a,S],stateAttributesMapping:s}),A=Q.useMemo(()=>({highlightedIndex:w,onHighlightedIndexChange:T,highlightItemOnHover:b,relayKeyboardEvent:O}),[w,T,b,O]);return(0,$.jsx)(De.Provider,{value:A,children:(0,$.jsx)(F,{elementsRef:E,onMapChange:e=>{h?.(e),D(e)},children:k})})}function Yt(e,t,n,r,i=!0,a){let{registerFieldControl:o}=Ot(),s=Je(()=>Symbol());J(()=>{let c=s.current;i?o(c,{controlRef:e,getValue:r,id:t,name:a,value:n}):o(c,void 0)},[e,i,r,t,a,o,s,n]),J(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var Xt=Q.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:K,validationMode:`onSubmit`,submitCountRef:{current:0}});function Zt(){return Q.useContext(Xt)}Object.keys(yt);function Qt(e,t){return e.matches(`:disabled`)?!1:!t||e.form===t||e.form===null&&!e.hasAttribute(`form`)}var $t=Q.createContext(void 0);function en(e=!1){let t=Q.useContext($t);if(!t&&!e)throw Error(Ee(86));return t}var tn=[P],nn=Q.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,form:u,name:d,inputRef:f,id:p,style:h,...g}=e,{setTouched:_,setFocused:v,validationMode:y,name:x,disabled:S,state:C,validation:w,setDirty:T,setFilled:E,validityData:D}=Ot(),{labelId:O}=Mt(),{clearErrors:k,elementRef:A}=Zt(),ee=en(!0),j=S||i,M=x??d,N=We(p),[P,F]=m({controlled:c,default:l,name:`RadioGroup`,state:`value`}),[I,L]=Q.useState(!1),R=Y((e,t)=>{s?.(e,t),t.isCanceled||F(e)}),z=w.getInputControl,B=Q.useMemo(()=>({get current(){return z()}}),[z]),V=Q.useRef(null),H=Q.useRef(null);function U(e){let t;return f&&(typeof f==`function`?t=f(e):f.current=e),V.current=e,t}let W=Y(e=>{if(!e||e.disabled)return;H.current||=e;let t=V.current,n=e.checked||t==null||t.disabled?U(e):void 0;return()=>{H.current===e&&(H.current=null),V.current===e?n?(n(),V.current=null):U(null):n?.()}}),te=Y(()=>{let e=A.current;if(!e)return P??null;for(let t of w.registeredInputs.keys())if(t.checked&&Qt(t,e))return P??null;return null});Yt(B,N,P??null,te,!j,d),b(P,()=>{k(M),T(P!==D.initialValue),E(P!=null),w.change(P);let e=H.current;P==null&&e&&!e.disabled&&U(e)});let ne=O??ee?.legendId,re={...C,disabled:j??!1,required:o??!1,readOnly:a??!1},ie=Q.useMemo(()=>({checkedValue:P,disabled:j,form:u,validation:w,name:M,readOnly:a,registerInputRef:W,required:o,setCheckedValue:R,setTouched:L,touched:I}),[P,j,u,w,M,a,W,o,R,L,I]),G={id:p,role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":j||void 0,"aria-readonly":a||void 0,"aria-labelledby":ne,onFocus(){v(!0)},onBlur(e){Le(e.currentTarget,e.relatedTarget)||(_(!0),v(!1),y===`onBlur`&&w.commit(P))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&(L(!0),v(!0))}};return(0,$.jsx)(Lt.Provider,{value:ie,children:(0,$.jsx)(Jt,{render:n,className:r,style:h,state:re,props:[G,g,e=>w.getValidationProps(j??!1,e)],refs:[t],stateAttributesMapping:xt,enableHomeAndEndKeys:!1,modifierKeys:tn})})}),rn=Oe(`group/option relative flex touch-none items-start gap-2.5 overflow-hidden rounded-md border p-3 text-start transition-[border-color,background-color] duration-150 ease-out outline-none select-none hover:bg-secondary/50 focus-visible:bg-secondary/50 focus-visible:ring-3 focus-visible:ring-ring/50 data-checked:border-foreground`,{variants:{variant:{default:`border-border hover:border-subtle`,sent:`border-muted-foreground hover:border-foreground`}},defaultVariants:{variant:`default`}});function an({className:e,...t}){return(0,$.jsx)(nn,{className:X(`grid w-full gap-2`,e),"data-slot":`radio-group`,...t})}function on({className:e,variant:t,children:n,...r}){return(0,$.jsxs)(Ht,{className:X(rn({variant:t,className:e})),"data-slot":`radio-group-item`,...r,children:[(0,$.jsx)(`span`,{className:`mt-1 grid size-3.5 shrink-0 place-items-center rounded-full border border-muted-foreground group-data-checked/option:border-foreground`,children:(0,$.jsx)(Ut,{className:`size-1.5 rounded-full bg-foreground`})}),n]})}var sn=500,cn=new Set([` `,`Enter`]),ln=({hasJustSent:e})=>(0,$.jsxs)(`span`,{className:X(`inline-flex items-center gap-1 rounded-sm border border-border px-1.5 text-xs font-normal text-muted-foreground`,e&&`animate-settle border-success text-success`),children:[e?(0,$.jsx)(O,{className:`size-3`}):null,`Sent`]}),un=({isShown:e})=>(0,$.jsxs)(`span`,{className:X(`ms-auto inline-flex text-subtle transition-colors duration-150 ease-out`,e&&`text-foreground`),children:[(0,$.jsx)(at,{"aria-hidden":!0,className:`size-3.5`}),(0,$.jsx)(`span`,{className:`sr-only`,children:e?`On the slide`:`Click to preview on the slide`})]}),dn=({option:e,isSent:t,isDraft:n,isShown:r,isHolding:i,hasJustSent:a,onHoldStart:o,onHoldEnd:s})=>(0,$.jsxs)(on,{onKeyDown:t=>{cn.has(t.key)&&!t.repeat&&o(e.value)},onKeyUp:e=>{cn.has(e.key)&&s()},onPointerCancel:s,onPointerDown:()=>{o(e.value)},onPointerLeave:s,onPointerUp:s,value:e.value,variant:t?`sent`:`default`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 hold-fill bg-foreground/10`,"data-holding":i}),(0,$.jsxs)(`span`,{className:`relative grid min-w-0 flex-1 gap-0.5`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 font-medium`,children:[e.label,t?(0,$.jsx)(ln,{hasJustSent:a}):null,e.blocks===void 0?null:(0,$.jsx)(un,{isShown:r})]}),e.recommended===!0?(0,$.jsx)(`span`,{className:`text-xs text-success`,children:`Recommended`}):null,e.hint===void 0?null:(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e.hint}),n?(0,$.jsx)(`span`,{className:`animate-enter text-xs text-subtle`,children:`Hold to send · ⌘↵`}):null]})]}),fn=e=>{let t=(0,Q.useRef)(null),[n,r]=(0,Q.useState)(null),i=()=>{t.current!==null&&(clearTimeout(t.current),t.current=null),r(null)};return{holding:n,handleStart:n=>{i(),r(n),t.current=setTimeout(()=>{t.current=null,r(null),e(n)},sn)},handleEnd:i}},pn=({deck:e,view:t,live:n,draft:r,shown:i,onDraft:a})=>{let o=n.answers[t.id]?.choice??null,[s,l]=(0,Q.useState)(null),u=async r=>{await c(e,t.id,{choice:r,note:n.answers[t.id]?.note??``}),a(null),l(r)},d=fn(u);return Ke(`keydown`,e=>{h(e,v.submit)&&r!==null&&(e.preventDefault(),u(r))}),(0,$.jsx)(an,{"aria-label":`Your call`,onValueChange:e=>{let t=typeof e==`string`?e:null;a(t===o?null:t)},value:r??o??``,children:t.options.map(e=>(0,$.jsx)(dn,{hasJustSent:s===e.value,isDraft:r===e.value,isHolding:d.holding===e.value&&o!==e.value,isSent:o===e.value,isShown:i===e.value,onHoldEnd:d.handleEnd,onHoldStart:e=>{e!==o&&d.handleStart(e)},option:e},e.value))})},mn=({deck:e,view:t,live:n,draft:r,shown:i,onDraft:a})=>(0,$.jsxs)(`aside`,{className:`flex flex-col gap-4 border-t border-border p-4 xl:fixed xl:inset-y-0 xl:inset-e-0 xl:w-85 xl:overflow-hidden xl:border-s xl:border-t-0 xl:bg-background`,"data-gallery-scope":!0,children:[t.options.length>0?(0,$.jsx)(pn,{deck:e,draft:r,live:n,onDraft:a,shown:i,view:t}):null,(0,$.jsx)(gt,{deck:e,live:n,view:t})]}),hn=(e,t)=>({...t,handleReply:async(t,n)=>{await a({data:{deck:e,point:t.point,revision:t.revision,path:t.path,side:t.side,start:t.start,end:t.end,code:t.code,body:n,parent:t.id,media:t.media??null,time:t.time??null,pinX:t.pinX??null,pinY:t.pinY??null}}),await f(e)},handleResolve:async(t,n)=>{await r({data:{deck:e,id:t.id,resolved:n}}),await f(e)}}),gn=({deck:e,point:t,live:n})=>{let r=W(),i=se(n.comments),o=p(n,t);return{revision:o,actions:hn(e,i),forFile:(n,i,s)=>{let c=r.forFile(n,s);return{...c,handlePost:async n=>{let l=c.selected?be(s,c.selected):null;if(l===null)return;let u={...ye(l),code:l.code};await a({data:{deck:e,point:t,revision:o,path:i,...u,body:n,parent:null}}),await f(e),r.clear()}}}}},_n=({deck:e,view:t,live:n,block:r,blockIndex:i})=>{let{revision:a,actions:o,forFile:s}=gn({deck:e,point:t.id,live:n});return(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-3`,children:[r.title===void 0?null:(0,$.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:r.title}),r.files.map(t=>{let r=`${String(i)}:${t.path}`;return(0,$.jsx)(ge,{actions:o,deck:e,file:t,live:n,revision:a,selection:s(r,t.path,t.rows)},r)})]})},vn=2,yn=50,bn=e=>e.length===vn&&/^before/iu.test(e[0]?.label??``)&&/^after/iu.test(e[1]?.label??``),xn=({url:e})=>(0,$.jsx)(Z,{label:`Open in Storybook`,nativeButton:!1,render:(0,$.jsx)(`a`,{"aria-label":`Open in Storybook`,href:e,rel:`noreferrer`,target:`_blank`}),size:`icon-xs`,children:(0,$.jsx)(rt,{})}),Sn=({shot:e,src:t,onOpen:n})=>(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col overflow-hidden rounded-md border border-border`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-9 items-center justify-between gap-2 border-b border-border bg-wash px-3 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:e.label}),e.story===void 0?null:(0,$.jsx)(xn,{url:e.story})]}),(0,$.jsx)(`div`,{className:`grid place-items-center bg-shot p-3`,children:(0,$.jsx)(`button`,{className:`cursor-zoom-in hover-outline`,onClick:n,type:`button`,children:(0,$.jsx)(`img`,{alt:e.alt,className:`block h-auto max-w-full`,src:t})})})]}),Cn=({before:e,after:t,story:n,onOpen:r})=>{let i=(0,Q.useRef)(null);return(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col overflow-hidden rounded-md border border-border`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-9 items-center justify-between gap-4 border-b border-border bg-wash px-3 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:e.label}),n===void 0?null:(0,$.jsx)(xn,{url:n}),(0,$.jsx)(`span`,{children:t.label})]}),(0,$.jsx)(`div`,{className:`grid place-items-center bg-shot p-3`,children:(0,$.jsxs)(`div`,{className:`group/compare relative grid w-fit`,ref:i,children:[(0,$.jsx)(`img`,{alt:e.label,className:`col-start-1 row-start-1 block h-auto max-w-full`,src:e.src}),(0,$.jsx)(`img`,{alt:t.label,className:`col-start-1 row-start-1 block h-auto max-w-full compare-after`,src:t.src}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 compare-divider w-0.5 bg-accent group-hover/compare:w-1`}),(0,$.jsx)(`input`,{"aria-label":`Drag to compare before and after`,className:`absolute inset-0 m-0 size-full cursor-ew-resize opacity-0`,defaultValue:yn,max:100,min:0,onInput:e=>i.current?.style.setProperty(`--split`,`${e.currentTarget.value}%`),type:`range`})]})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border px-3 py-1 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:`Before`}),(0,$.jsx)(Z,{label:`Full size`,onClick:r,size:`icon-xs`,children:(0,$.jsx)(z,{})}),(0,$.jsx)(`span`,{children:`After`})]})]})},wn=()=>{let[e,t]=(0,Q.useState)({});return{isSame:e[0]!==void 0&&e[0]===e[1],onLoad:e=>n=>{let{naturalWidth:r,naturalHeight:i}=n.currentTarget;t(t=>({...t,[e]:`${String(r)}x${String(i)}`}))}}},Tn=({deck:e,block:t})=>{let n=oe(),r=t.shots.map(t=>({src:w(e,t.src),label:t.label})),{isSame:i,onLoad:a}=wn(),[o,s]=r,c=bn(t.shots);return(0,$.jsxs)(`figure`,{className:`m-0 grid grid-cols-1 gap-2`,children:[t.title===void 0?null:(0,$.jsx)(`figcaption`,{className:`text-sm text-muted-foreground`,children:t.title}),c&&i&&o&&s?(0,$.jsx)(Cn,{after:s,before:o,onOpen:()=>{n([r],0)},story:t.shots.find(e=>e.story!==void 0)?.story}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:t.shots.map((e,t)=>(0,$.jsx)(Sn,{onOpen:()=>{n(r.map(e=>[e]),t)},shot:e,src:r[t]?.src??``},e.src))}),c?(0,$.jsx)(`span`,{className:`hidden`,children:r.map((e,t)=>(0,$.jsx)(`img`,{alt:``,onLoad:a(t),src:e.src},e.src))}):null]})},En=(e,t)=>e.filter(e=>e.parent===null&&e.media===t).toSorted((e,t)=>(e.time??0)-(t.time??0)||e.at.localeCompare(t.at)).map(t=>({root:t,replies:e.filter(e=>e.parent===t.id),isOutdated:!1})),Dn=({deck:e,point:t,live:n,media:r,placeholder:i,getAnchor:o,onPosted:s,onSelect:c})=>{let l=p(n,t),u=En(n.comments,r),d=hn(e,se(n.comments));return(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[u.map((t,r)=>(0,$.jsxs)(`div`,{className:`grid gap-1`,children:[c===void 0?null:(0,$.jsx)(Xe,{label:`Show this spot on the snapshot`,children:(0,$.jsx)(`button`,{className:`w-fit text-xs hover-text`,onClick:()=>{c(t.root)},type:`button`,children:`#${String(r+1)} · show`})}),(0,$.jsx)(ce,{actions:d,deck:e,live:n,revision:l,thread:t})]},t.root.id)),(0,$.jsx)(R,{deck:e,onSubmit:async n=>{await a({data:{deck:e,point:t,revision:l,path:null,side:`new`,start:null,end:null,code:``,body:n,parent:null,media:r,...o()}}),s?.(),await f(e)},placeholder:i,submitLabel:`Comment`})]})},On=({rows:e,offset:t,selection:n,byRow:r,...i})=>e.map((e,a)=>{let o=t+a;return(0,$.jsxs)(`div`,{className:`contents`,children:[(0,$.jsx)(te,{index:o,row:e,selection:n,children:(0,$.jsx)(`span`,{className:`diff-sticky diff-at-old pe-3 text-end text-subtle tabular-nums select-none`,children:e.new})}),(0,$.jsx)(de,{index:o,selection:n,threads:r.get(o)??[],...i})]},`${String(e.new)}-${e.code}`)}),kn=({rows:e,...t})=>(0,$.jsx)(`div`,{className:`min-w-0 overflow-x-auto overscroll-x-contain py-2 font-mono text-xs/relaxed sm:text-sm/relaxed`,children:(0,$.jsx)(`div`,{className:`grid w-max min-w-full source-rows`,children:(0,$.jsx)(On,{...t,offset:0,rows:e})})}),An=({deck:e,point:t,live:n,source:r})=>{let{revision:i,actions:a,forFile:o}=gn({deck:e,point:t,live:n}),s=r.path.split(`/`).at(-1)??r.path,{byRow:c,loose:l}=U(r.rows,{comments:n.comments.filter(e=>e.point===t),path:r.path,revision:i}),u={deck:e,live:n,revision:i,actions:a};return(0,$.jsxs)(`section`,{"aria-label":`Test source`,className:`grid grid-cols-1 border-y border-border`,children:[(0,$.jsx)(`div`,{className:`flex border-b border-border bg-wash px-3 py-2 font-mono text-xs text-subtle`,children:(0,$.jsx)(Xe,{label:r.path,children:(0,$.jsx)(`span`,{className:`min-w-0 truncate tabular-nums`,children:`${s}:${String(r.start)}`})})}),(0,$.jsx)(kn,{byRow:c,rows:r.rows,selection:o(r.path,r.path,r.rows),...u}),(0,$.jsx)(ne,{threads:l,...u})]})},jn=10,Mn=async(e,t)=>{e.currentTime=t;try{await e.play()}catch{e.pause()}},Nn=({deck:e,point:t,live:n,media:r,video:i})=>(0,$.jsx)(Dn,{deck:e,getAnchor:()=>({time:Math.round((i.current?.currentTime??0)*jn)/jn,pinX:null,pinY:null}),live:n,media:r,onSelect:e=>{i.current&&typeof e.time==`number`&&Mn(i.current,e.time)},placeholder:`Pause where something looks off, then comment on that moment`,point:t}),Pn=({deck:e,point:t,live:n,block:r})=>{let i=(0,Q.useRef)(null);return(0,$.jsxs)(`figure`,{className:`m-0 grid grid-cols-1 gap-2 rounded-md border border-border`,children:[(0,$.jsxs)(`figcaption`,{className:`grid gap-0.5 border-b border-border bg-wash px-3 py-2`,children:[(0,$.jsx)(`span`,{className:`text-sm text-foreground`,children:r.title}),(0,$.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:`${r.spec} · ${r.pr}`})]}),(0,$.jsx)(`div`,{className:`grid place-items-center bg-black`,children:(0,$.jsx)(`video`,{className:`block h-auto video-height w-full`,controls:!0,poster:r.poster===void 0?void 0:w(e,r.poster),preload:`metadata`,ref:i,src:w(e,r.video),children:(0,$.jsx)(`track`,{kind:`captions`})})}),r.source===null?null:(0,$.jsx)(An,{deck:e,live:n,point:t,source:r.source}),(0,$.jsx)(`div`,{className:`px-3 pb-3`,children:(0,$.jsx)(Nn,{deck:e,live:n,media:r.video,point:t,video:i})})]})},Fn=` > `,In=/^(?<when>when\s.+?)\s+(?<then>then\s.+)$/isu,Ln=/^then\s/iu,Rn=e=>{let t=e.split(Fn).map(e=>e.trim()),n=t.at(-1)??``,r=t.slice(0,-1).join(` › `);return t.length>1&&Ln.test(n)&&r!==``?{whenLine:r,thenLine:n}:null},zn=e=>{let t=In.exec(e)?.groups;return t?.when===void 0||t.then===void 0?null:{whenLine:t.when,thenLine:t.then}},Bn=e=>{let t=e.trim();return Rn(t)??zn(t)??{whenLine:null,thenLine:t}},Vn=({block:e})=>{let{editor:t}=Ye(),n=e.source?.start??1,r=re({worktree:e.worktree,path:e.file,isDeleted:!1,editor:t},n);if(r===null)return null;let i=`Open ${e.spec}:${String(n)} in ${ie[t]}`;return(0,$.jsx)(Z,{label:i,nativeButton:!1,render:(0,$.jsx)(`a`,{"aria-label":i,href:r,onClick:n=>{n.preventDefault(),_e(r,V(e.worktree,t))},rel:`noopener`}),size:`icon-xs`,children:(0,$.jsx)(D,{})})},Hn=({deck:e,point:t,live:n,block:r,video:i})=>{let{whenLine:a,thenLine:o}=Bn(r.title);return(0,$.jsxs)(`aside`,{"aria-label":`Recording`,className:`pointer-events-auto flex recording-panel flex-col overflow-hidden rounded-md border border-border bg-background`,children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start gap-3 bg-wash py-3 ps-4 pe-3`,children:[(0,$.jsxs)(`div`,{className:`grid min-w-0 flex-1 gap-1`,children:[a===null?null:(0,$.jsx)(`p`,{className:`m-0 text-xs/5 text-muted-foreground`,children:a}),(0,$.jsx)(`p`,{className:`m-0 text-sm/5 font-medium text-foreground`,children:o}),(0,$.jsx)(`p`,{className:`m-0 truncate pt-1 font-mono text-xs text-subtle`,children:r.source===null?`${r.spec} · ${r.pr}`:r.pr})]}),(0,$.jsx)(Vn,{block:r})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto overscroll-contain`,children:[r.source===null?null:(0,$.jsx)(An,{deck:e,live:n,point:t,source:r.source}),(0,$.jsx)(`div`,{className:X(`px-4 py-3`,r.source===null&&`border-t border-border`),children:(0,$.jsx)(Nn,{deck:e,live:n,media:r.video,point:t,video:i})})]})]})},Un=({deck:e,point:t,live:n,blocks:r,index:i,onIndex:a,onClose:o})=>{let s=(0,Q.useRef)(null),c=r[i];return c===void 0?null:(0,$.jsx)(C,{count:r.length,index:i,noun:`recording`,onClose:o,onIndex:a,title:c.title,children:(0,$.jsxs)(`div`,{className:`pointer-events-none relative recording-stage`,children:[(0,$.jsx)(`div`,{className:`pointer-events-auto grid place-items-center overflow-hidden rounded-md border border-border bg-black`,children:(0,$.jsx)(`video`,{autoPlay:!0,className:`block h-auto recording-fit w-full`,controls:!0,"data-recording-video":!0,muted:!0,playsInline:!0,poster:c.poster===void 0?void 0:w(e,c.poster),preload:`auto`,ref:s,src:w(e,c.video),children:(0,$.jsx)(`track`,{kind:`captions`})},c.video)}),(0,$.jsx)(Hn,{block:c,deck:e,live:n,point:t,video:s})]})})},Wn=60,Gn=2,Kn=e=>{let t=Math.max(1,Math.floor(e));return`${String(Math.floor(t/Wn))}:${String(t%Wn).padStart(Gn,`0`)}`},qn=(e,t)=>{let n=t.source?.start??0,r=n+(t.source?.rows.length??0)-1,i=e.start??n-1;return(e.media??null)===null&&e.path===t.file&&i>=n&&i<=r},Jn=(e,t,n)=>e.comments.filter(e=>e.parent===null&&e.point===t&&e.resolved!==!0&&(e.media===n.video||qn(e,n))).length,Yn=(e,t)=>t.title.whenLine!==null&&e?.title.whenLine===t.title.whenLine,Xn=e=>{let t=[];for(let n of e){let e=t.at(-1);e!==void 0&&Yn(e.entries.at(-1),n)?e.entries.push(n):t.push({when:n.title.whenLine,entries:[n]})}return t},Zn=e=>{let t=[];for(let n of Xn(e)){let e=t.at(-1);n.entries.length>1?t.push(n):e?.when===null?e.entries.push(...n.entries):t.push({when:null,entries:n.entries})}return t},Qn=({deck:e,block:t})=>(0,$.jsxs)(`span`,{className:`relative block aspect-16/10 overflow-hidden rounded-md border border-border bg-wash hover-outline-group`,children:[t.poster===void 0?null:(0,$.jsx)(`img`,{alt:``,className:`block size-full object-cover`,decoding:`async`,loading:`lazy`,src:w(e,t.poster)}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-0 grid place-items-center opacity-80 transition-opacity duration-150 ease-out group-hover:opacity-100 group-focus-visible:opacity-100`,children:(0,$.jsx)(`span`,{className:`grid size-9 place-items-center rounded-full border border-border bg-overlay text-foreground`,children:(0,$.jsx)(L,{className:`size-3.5 translate-x-px fill-current`})})}),t.seconds===null?null:(0,$.jsx)(`span`,{className:`absolute inset-e-1.5 bottom-1.5 rounded-sm bg-overlay px-1.5 font-mono text-xs/5 text-foreground tabular-nums`,children:Kn(t.seconds)})]}),$n=({deck:e,entry:t,isGrouped:n,onOpen:r})=>{let{block:i,title:a,comments:o}=t,s=`${String(o)} ${o===1?`comment`:`comments`}`;return(0,$.jsx)(`li`,{className:`min-w-0`,children:(0,$.jsxs)(`button`,{"aria-label":`Play ${i.title}${o===0?``:`, ${s}`}`,className:`group grid w-full gap-2 rounded-md text-start outline-none`,"data-recording-thumb":!0,onClick:()=>{r(t.index)},type:`button`,children:[(0,$.jsx)(Qn,{block:i,deck:e}),(0,$.jsxs)(`span`,{className:`grid gap-0.5 px-0.5`,children:[n||a.whenLine===null?null:(0,$.jsx)(`span`,{className:`line-clamp-2 text-xs/4 text-muted-foreground`,children:a.whenLine}),(0,$.jsx)(`span`,{className:`line-clamp-3 text-sm/5 text-foreground`,children:a.thenLine}),o===0?null:(0,$.jsxs)(`span`,{className:`flex items-center gap-1 pt-0.5 text-xs text-subtle tabular-nums`,children:[(0,$.jsx)(lt,{"aria-hidden":!0,className:`size-3`}),o]})]})]})})},er=({deck:e,entries:t,isGrouped:n,onOpen:r})=>(0,$.jsx)(`ul`,{className:`m-0 grid list-none grid-cols-1 gap-x-4 gap-y-5 p-0 @sm:grid-cols-2 @xl:grid-cols-3 @4xl:grid-cols-4`,children:t.map(t=>(0,$.jsx)($n,{deck:e,entry:t,isGrouped:n,onOpen:r},t.block.video))}),tr=e=>[...new Set(e.map(e=>e.spec))].join(` · `),nr=e=>[...new Set(e.map(e=>e.pr))].join(` · `),rr=({deck:e,point:t,live:n,blocks:r})=>{let[i,a]=(0,Q.useState)(null),o=r.map((e,r)=>({block:e,index:r,title:Bn(e.title),comments:Jn(n,t,e)}));return(0,$.jsxs)(`section`,{"aria-label":`Recordings`,className:`@container grid grid-cols-1 rounded-md border border-border`,"data-recording-grid":!0,children:[(0,$.jsxs)(`header`,{className:`flex min-w-0 items-center gap-2 border-b border-border bg-wash px-3 py-2`,children:[(0,$.jsx)(`span`,{className:`text-sm text-foreground`,children:`Recordings`}),(0,$.jsx)(`span`,{className:`rounded-full bg-secondary px-1.5 text-xs/5 text-muted-foreground tabular-nums`,children:r.length}),(0,$.jsx)(`span`,{className:`ms-auto min-w-0 truncate font-mono text-xs text-muted-foreground`,children:`${tr(r)} · ${nr(r)}`})]}),(0,$.jsx)(`div`,{className:`grid gap-5 p-3`,children:Zn(o).map(t=>(0,$.jsxs)(`div`,{className:`grid gap-2.5`,children:[t.when===null?null:(0,$.jsx)(`h3`,{className:`m-0 text-xs font-medium text-muted-foreground`,children:t.when}),(0,$.jsx)(er,{deck:e,entries:t.entries,isGrouped:t.when!==null,onOpen:a})]},t.entries[0]?.block.video))}),i===null?null:(0,$.jsx)(Un,{blocks:r,deck:e,index:i,live:n,onClose:()=>{a(null)},onIndex:a,point:t})]})},ir=100,ar=(e,t)=>Math.min(1,Math.max(0,e/t)),or=e=>{let t=e.currentTarget.getBoundingClientRect();return{pinX:ar(e.clientX-t.left,t.width),pinY:ar(e.clientY-t.top,t.height)}},sr=({pinX:e,pinY:t})=>n=>{n?.style.setProperty(`--pin-left`,`${String(e*ir)}%`),n?.style.setProperty(`--pin-top`,`${String(t*ir)}%`)},cr=({pin:e,label:t,isDraft:n=!1})=>(0,$.jsx)(`span`,{"aria-hidden":!0,className:n?`pointer-events-none absolute inset-s-(--pin-left) top-(--pin-top) grid size-6 -translate-1/2 place-items-center rounded-full border-2 border-accent bg-background text-xs text-foreground`:`pointer-events-none absolute inset-s-(--pin-left) top-(--pin-top) grid size-6 -translate-1/2 place-items-center rounded-full bg-accent text-xs text-white`,ref:sr(e),children:t}),lr=({deck:e,point:t,live:n,block:r})=>{let[i,a]=(0,Q.useState)(null),o=oe(),s=w(e,r.image),c=En(n.comments,r.image).flatMap((e,t)=>typeof e.root.pinX==`number`&&typeof e.root.pinY==`number`?[{pin:{pinX:e.root.pinX,pinY:e.root.pinY},label:String(t+1)}]:[]);return(0,$.jsxs)(`figure`,{className:`m-0 grid grid-cols-1 gap-2 rounded-md border border-border`,children:[(0,$.jsxs)(`figcaption`,{className:`flex items-center justify-between gap-3 border-b border-border bg-wash px-3 py-2 text-xs text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:`${r.component} · ${r.title}`}),(0,$.jsxs)(`span`,{className:`-my-1 flex shrink-0 gap-0.5`,children:[(0,$.jsx)(Z,{label:`Full size`,onClick:()=>{o([[{src:s,label:r.title}]],0)},size:`icon-xs`,children:(0,$.jsx)(z,{})}),(0,$.jsx)(Z,{label:`Open in Storybook`,nativeButton:!1,render:(0,$.jsx)(`a`,{"aria-label":`Open in Storybook`,href:r.url,rel:`noreferrer`,target:`_blank`}),size:`icon-xs`,children:(0,$.jsx)(rt,{})})]})]}),(0,$.jsx)(`div`,{className:`grid place-items-center bg-shot p-3`,children:(0,$.jsxs)(`button`,{"aria-label":`Pin a comment on this snapshot`,className:`relative block cursor-crosshair hover-outline`,onClick:e=>{a(or(e))},type:`button`,children:[(0,$.jsx)(`img`,{alt:`${r.component}, ${r.title}`,className:`block h-auto max-w-full`,src:s}),c.map(e=>(0,$.jsx)(cr,{label:e.label,pin:e.pin},e.label)),i===null?null:(0,$.jsx)(cr,{isDraft:!0,label:`+`,pin:i})]})}),r.source===void 0?null:(0,$.jsx)(`p`,{className:`m-0 px-3 text-xs text-subtle`,children:r.source}),(0,$.jsx)(`div`,{className:`px-3 pb-3`,children:(0,$.jsx)(Dn,{deck:e,getAnchor:()=>({time:null,pinX:i?.pinX??null,pinY:i?.pinY??null}),live:n,media:r.image,onPosted:()=>{a(null)},placeholder:i===null?`Comment on this snapshot, or click it to pin a spot`:`Comment on the pinned spot`,point:t})})]})},ur=({segment:e})=>e.op===`del`?(0,$.jsx)(`del`,{className:`text-sign-del decoration-sign-del`,children:e.text}):e.op===`add`?(0,$.jsx)(`ins`,{className:`rounded-sm bg-line-add px-0.5 text-sign-add no-underline`,children:e.text}):(0,$.jsx)(`span`,{className:`text-subtle`,children:e.text}),dr=({block:e})=>(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-3`,children:[e.title===void 0?null:(0,$.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:e.title}),(0,$.jsx)(`ul`,{className:`m-0 list-none overflow-hidden rounded-md border border-border p-0`,children:e.rows.map((e,t)=>(0,$.jsxs)(`li`,{className:`flex flex-col gap-0.5 border-b border-border px-3 py-2 transition-colors duration-150 ease-out last:border-b-0 hover:bg-row-hover sm:flex-row sm:gap-3`,children:[e.label===void 0?null:(0,$.jsx)(`span`,{className:`shrink-0 text-xs/6 text-subtle tabular-nums sm:w-20`,children:e.label}),(0,$.jsx)(`p`,{className:`m-0 min-w-0 text-sm/6 wrap-break-word`,children:e.segments.map((e,t)=>(0,$.jsx)(ur,{segment:e},`${String(t)}-${e.op}`))})]},`${String(t)}-${e.label??``}`))})]}),fr=({deck:e,block:t})=>t.kind===`media`?(0,$.jsx)(Tn,{block:t,deck:e}):t.kind===`wording`?(0,$.jsx)(dr,{block:t}):(0,$.jsx)(I,{className:`border-s-2 border-foreground ps-3`,deck:e,text:t.markdown}),pr=3,mr=e=>e.kind===`recording`,hr=e=>{let t=e.filter(e=>mr(e)).length>=pr;return e.reduce((e,n,r)=>{let i=e.at(-1);return!t||!mr(n)?[...e,{block:n,index:r}]:i!==void 0&&`recordings`in i&&i.index+i.recordings.length===r?(i.recordings.push(n),e):[...e,{recordings:[n],index:r}]},[])},gr=({deck:e,view:t,live:n,block:r,index:i})=>r.kind===`code`?(0,$.jsx)(_n,{block:r,blockIndex:i,deck:e,live:n,view:t}):r.kind===`review`?(0,$.jsx)(he,{stub:r,blockIndex:i,deck:e,live:n,view:t}):r.kind===`story`?(0,$.jsx)(lr,{block:r,deck:e,live:n,point:t.id}):r.kind===`recording`?(0,$.jsx)(Pn,{block:r,deck:e,live:n,point:t.id}):(0,$.jsx)(fr,{block:r,deck:e}),_r=(e,t)=>e.kind===`review`?`review-${e.branch}`:e.kind===`story`?`story-${e.storyId}`:e.kind===`recording`?`recording-${e.video}`:`${e.kind}-${String(t)}`,vr=({deck:e,view:t,live:n,blocks:r})=>hr(r).map(r=>`recordings`in r?(0,$.jsx)(rr,{blocks:r.recordings,deck:e,live:n,point:t.id},`recordings-${r.recordings[0]?.video??String(r.index)}`):(0,$.jsx)(gr,{block:r.block,deck:e,index:r.index,live:n,view:t},_r(r.block,r.index))),yr=(e,t)=>t?.blocks===void 0?{key:``,label:null,blocks:e.blocks}:{key:t.value,label:t.label,blocks:[...e.blocks.filter(e=>e.kind!==`code`&&e.kind!==`review`),...t.blocks]},br=e=>{let[t,n]=(0,Q.useState)(e),[r,i]=(0,Q.useState)(null);return t.key!==e.key&&(i(t),n(e)),{leaving:r,handleLeft:()=>{i(null)}}},xr=({deck:e,view:t,live:n,showing:r})=>(0,$.jsxs)($.Fragment,{children:[r.label===null?null:(0,$.jsxs)(`p`,{className:`m-0 text-xs text-subtle`,children:[`Showing: `,(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:r.label})]}),(0,$.jsx)(vr,{blocks:r.blocks,deck:e,live:n,view:t})]}),Sr=e=>{let{leaving:t,handleLeft:n}=br(e.showing);return(0,$.jsxs)(`div`,{className:`grid grid-cols-1`,children:[t===null?null:(0,$.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none col-start-1 row-start-1 grid animate-fade-out grid-cols-1 content-start gap-4`,inert:!0,onAnimationEnd:e=>{e.target===e.currentTarget&&n()},children:(0,$.jsx)(xr,{...e,showing:t})},`leaving-${t.key}`),(0,$.jsx)(`div`,{className:X(`col-start-1 row-start-1 grid grid-cols-1 content-start gap-4`,t!==null&&`animate-fade-in`),children:(0,$.jsx)(xr,{...e})},`shown-${e.showing.key}`)]})},Cr=({deck:e,view:t,live:n,shown:r})=>(0,$.jsxs)(`article`,{className:`mx-auto grid max-w-228 animate-enter grid-cols-1 gap-4`,"data-gallery-scope":!0,children:[(0,$.jsx)(`p`,{className:`m-0 text-sm text-muted-foreground`,children:t.sectionTitle}),(0,$.jsx)(`h1`,{className:`m-0 text-2xl/tight font-semibold tracking-tight`,children:t.title}),(0,$.jsx)(I,{className:`[&>*:not(.deck-table-scroll)]:max-w-prose`,deck:e,text:t.prose}),(0,$.jsx)(Sr,{deck:e,live:n,showing:yr(t,r),view:t})]});function wr({className:e,orientation:t=`horizontal`,...n}){return(0,$.jsx)(me,{"data-slot":`separator`,orientation:t,className:X(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...n})}var Tr=({deck:e,point:t,onCopyLink:n})=>{let r=Ze(),i=async(e,t)=>{await navigator.clipboard.writeText(e),r.add({title:t})};return(0,$.jsxs)(le,{children:[(0,$.jsx)(ue,{render:(0,$.jsx)(Z,{label:`More actions`,variant:`ghost`}),children:(0,$.jsx)(k,{})}),(0,$.jsxs)(pe,{children:[(0,$.jsxs)(G,{onClick:()=>{n()},children:[(0,$.jsx)(st,{}),`Copy link`,(0,$.jsx)(H,{children:v.copyLink.keys.join(``)})]}),(0,$.jsxs)(G,{onClick:()=>{i(t,`Point id copied`)},children:[(0,$.jsx)(fe,{}),`Copy point id`]}),(0,$.jsxs)(G,{onClick:()=>{i(`~/review-decks/${e}/points/${t}.md`,`File path copied`)},children:[(0,$.jsx)(E,{}),`Copy point file path`]})]})]})},Er=({summary:e,view:t,live:n,index:r,hasNextOpen:i,onStep:a,onNextOpen:o,onCopyLink:s})=>{let c=e.points.filter(e=>!!n.answers[e.id]?.choice).length;return(0,$.jsxs)(`header`,{className:`sticky top-0 z-10 flex h-14 items-center gap-1 border-b border-border bg-background px-3 xl:ms-70 xl:me-85`,children:[(0,$.jsx)(Z,{disabled:r<=0,label:`Previous point`,onClick:()=>{a(-1)},shortcut:v.previous,children:(0,$.jsx)($e,{})}),(0,$.jsxs)(`span`,{className:`min-w-16 text-center text-sm text-muted-foreground tabular-nums`,children:[r+1,` / `,e.points.length]}),(0,$.jsx)(Z,{disabled:r>=e.points.length-1,label:`Next point`,onClick:()=>{a(1)},shortcut:v.next,children:(0,$.jsx)(B,{})}),(0,$.jsx)(`span`,{className:`mx-1 flex h-5`,children:(0,$.jsx)(wr,{orientation:`vertical`})}),(0,$.jsx)(Z,{disabled:!i,label:`Next point waiting for you`,onClick:o,shortcut:v.nextOpen,children:(0,$.jsx)(tt,{})}),(0,$.jsxs)(`span`,{className:`ms-auto me-2 text-sm text-muted-foreground tabular-nums`,children:[c,` of `,e.points.length,` answered`]}),(0,$.jsx)(Tr,{deck:e.name,onCopyLink:s,point:t.id})]})},Dr=e=>{let[t,n]=(0,Q.useState)(null);return t!==null&&t.point!==e&&n(null),{draft:t?.point===e?t.value:null,handleDraft:t=>{n(t===null?null:{point:e,value:t})}}},Or=(e,t,n)=>{let r=t??n;return e.options.find(e=>e.value===r)??e.options.find(e=>e.recommended===!0)??null},kr=()=>{let e=Ze();return async()=>{await navigator.clipboard.writeText(globalThis.location.href),e.add({title:`Link copied`})}},Ar=(e,t,n)=>{let r=o(),i=kr(),a=e.points.findIndex(e=>e.id===t),s=y(e.points,n,t),c=t=>{t!==void 0&&r({to:`/decks/$deck/$point`,params:{deck:e.name,point:t}})},l=t=>{c(e.points[a+t]?.id)};return Ke(`keydown`,e=>{_(e.target)||g()||((h(e,v.previous)||h(e,v.next))&&l(e.key===`ArrowLeft`?-1:1),h(e,v.nextOpen)&&c(s?.id),h(e,v.copyLink)&&i())}),{index:a,hasNextOpen:s!==void 0,handleStep:l,handleNextOpen:()=>{c(s?.id)},handleCopyLink:i}},jr=t(`/decks/$deck`),Mr=t(`/decks/$deck/$point`),Nr=()=>{let e=Mr.useLoaderData(),{summary:t,live:n}=jr.useLoaderData(),r=s(t.name,n),{index:i,hasNextOpen:a,handleStep:o,handleNextOpen:c,handleCopyLink:l}=Ar(t,e.id,r),{draft:d,handleDraft:f}=Dr(e.id),p=Or(e,d,r.answers[e.id]?.choice??null);return ut(e.id,r.comments.findLast(t=>t.point===e.id)?.at??``),u(t.name,e),(0,$.jsxs)(M,{children:[(0,$.jsx)(Er,{hasNextOpen:a,index:i,live:r,onCopyLink:l,onNextOpen:c,onStep:o,summary:t,view:e}),(0,$.jsx)(`main`,{className:`px-6 pt-6 pb-20 xl:ms-70 xl:me-85`,children:(0,$.jsx)(Cr,{deck:t.name,live:r,shown:p,view:e},e.id)}),(0,$.jsx)(mn,{deck:t.name,draft:d,live:r,onDraft:f,shown:p?.value??null,view:e},`answer-${e.id}`)]})};export{Nr as component};
|