use-chisel 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -50,9 +50,8 @@ app layout, and saves the project's public ID in `.chisel.json`. It does not
50
50
  overwrite an existing `/chisel` route. Restart your development server and open
51
51
  `/chisel` to sign in and review the site. Shared comments are stored by Chisel's
52
52
  hosted service; project credentials and Supabase service keys are not required
53
- in the client project. The hosted workspace currently supports text comments,
54
- replies, resolution, and review links; rich text, attachments, presence, and
55
- unread indicators are not yet available there.
53
+ in the client project. The hosted workspace supports rich text, attachments,
54
+ replies, resolution, review links, reviewer presence, and unread indicators.
56
55
 
57
56
  The generated route defaults off in production. To use it on a deployed review
58
57
  site, set `CHISEL_ENABLED=1` for that deployment and redeploy. Hosted connections
@@ -1 +1,134 @@
1
- "use client";import{jsx as i,jsxs as l,Fragment as L}from"react/jsx-runtime";import{useCallback as R,useEffect as b,useMemo as j,useRef as w,useState as f}from"react";import{ChiselWorkspace as I,ChiselWorkspaceStyles as E}from"use-chisel/workspace";var u="https://chisel-review.vercel.app";function N({projectId:h}){let a=`chisel:session:${h}`,r=w(""),[c,C]=f(null),[P,d]=f(!0),[v,p]=f(""),[x,y]=f(!1),S=w(null);S.current=c;let m=w(null),g=w(""),o=R(async(t,e)=>{let n=await fetch(`${u}/chisel/api/hosted/comments`,{method:t,headers:{Authorization:`Bearer ${r.current}`,...e?{"Content-Type":"application/json","X-Chisel-Protocol":"2"}:{}},...e?{body:JSON.stringify(e)}:{}}),s=await n.json();if(!n.ok)throw n.status===401&&S.current&&y(!0),Object.assign(new Error(s.error||"Chisel is unavailable. Please try again."),{status:n.status});if(s.siteId&&s.siteId!==h)throw new Error("This session belongs to another project.");return s},[h]),T=j(()=>({async list(){return(await o("GET")).comments},async mutate(t){return(await o("POST",t)).comment},async delete(t){await o("POST",{type:"delete",id:t})}}),[o]);b(()=>{if(r.current=sessionStorage.getItem(a)||"",!r.current){d(!1);return}let t=!0;return o("GET").then(e=>{t&&C(e)}).catch(()=>{t&&(r.current="",sessionStorage.removeItem(a))}).finally(()=>{t&&d(!1)}),()=>{t=!1}},[a,o]),b(()=>{let t=e=>{e.origin!==u||e.source!==m.current||e.data?.type!=="chisel:session"||e.data.state!==g.current||!/^[0-9a-f]{64}$/.test(e.data.token)||(r.current=e.data.token,sessionStorage.setItem(a,r.current),g.current="",m.current=null,S.current||d(!0),p(""),o("GET").then(n=>{C(n),y(!1);let s=new URL(window.location.href);s.searchParams.delete("invite"),window.history.replaceState(window.history.state,"",s)}).catch(n=>{r.current="",sessionStorage.removeItem(a),p(n instanceof Error?n.message:"Could not connect to Chisel.")}).finally(()=>d(!1)))};return window.addEventListener("message",t),()=>window.removeEventListener("message",t)},[a,o]);function k(){let t=crypto.getRandomValues(new Uint8Array(32));g.current=Array.from(t,s=>s.toString(16).padStart(2,"0")).join("");let e=new URL("/chisel/connect",u);e.searchParams.set("site",h),e.searchParams.set("origin",window.location.origin),e.searchParams.set("state",g.current);let n=new URLSearchParams(window.location.search).get("invite");n&&e.searchParams.set("invite",n),m.current=window.open(e.toString(),"chisel-sign-in","popup,width=520,height=700"),m.current||p("Allow pop-ups for this site, then try again.")}return P?l("main",{className:"chisel-sign-in",children:[i(E,{}),i("section",{children:i("p",{children:"Connecting to Chisel\u2026"})})]}):c?l(L,{children:[i(I,{user:c.user,commentStore:T,canManageComments:c.role==="owner",getReviewLink:c.role==="owner"?async(t=!1)=>{let e=await fetch(`${u}/chisel/api/hosted/invite`,{method:"POST",headers:{Authorization:`Bearer ${r.current}`,"Content-Type":"application/json","X-Chisel-Protocol":"2"},body:JSON.stringify({rotate:t})}),n=await e.json();if(e.status===401&&y(!0),!e.ok||typeof n.invite!="string")throw new Error(n.error||"Could not create a review link.");let s=new URL("/chisel",window.location.origin);return s.searchParams.set("mode","comment"),s.searchParams.set("invite",n.invite),s.toString()}:void 0,validateSession:async()=>!!r.current,signOut:async()=>{let t=await fetch(`${u}/chisel/api/hosted/logout`,{method:"DELETE",headers:{Authorization:`Bearer ${r.current}`,"X-Chisel-Protocol":"2"}});if(!t.ok&&t.status!==401)throw new Error("Sign out failed.");r.current="",sessionStorage.removeItem(a)}}),x&&l("div",{role:"alert",style:{position:"fixed",bottom:16,right:16,zIndex:999999,background:"white",color:"black",padding:12,borderRadius:8,boxShadow:"0 2px 12px #0003"},children:["Your Chisel session expired. ",i("button",{type:"button",onClick:k,children:"Sign in again"})]})]}):l("main",{className:"chisel-sign-in",children:[i(E,{}),l("section",{children:[i("strong",{className:"chisel-sign-in-brand",children:"chisel"}),i("h1",{children:"Sign in to review"}),i("p",{children:"Connect this website to your Chisel account."}),i("button",{onClick:k,children:"Continue with Chisel"}),v&&i("p",{role:"alert",children:v})]})]})}export{N as HostedChisel};
1
+ "use client";import{jsx as s,jsxs as g,Fragment as me}from"react/jsx-runtime";import{useCallback as x,useEffect as O,useMemo as U,useRef as w,useState as h}from"react";import{ChiselWorkspace as ue,ChiselWorkspaceStyles as _}from"use-chisel/workspace";import{ReviewComposer as ve,ReviewThread as xe,useReviewAttachments as we,useReadQueue as ge}from"use-chisel/review";var W=`.chisel-review{font-family:var(--chisel-ui-font);-webkit-font-smoothing:antialiased}
2
+ .chisel-review .comment-thread[data-native-ui=true]{padding:0;gap:0;border:0;border-radius:16px;background:var(--chisel-ui-surface);box-shadow:0 0 0 1px var(--chisel-ui-border),0 8px 32px #00000014;font-size:14px}
3
+ .chisel-review .comment-thread[data-native-ui=true] .feedback-preview{margin:4px 12px 0;border-radius:8px}
4
+ .chisel-review .comment-thread[data-native-ui=true] form{width:100%}
5
+ .chisel-review-thread-content{width:100%;min-width:0}
6
+ .chisel-review-message{display:flex;gap:12px;padding:16px}
7
+ .chisel-review-message-content{min-width:0;flex:1}
8
+ .chisel-review-avatar{width:32px;height:32px;flex-shrink:0}
9
+ .chisel-review-avatar img,.chisel-review .feedback-reply-avatar img{width:100%;height:100%;object-fit:cover;border-radius:inherit}
10
+ .chisel-review-byline{display:flex;gap:8px;flex-wrap:wrap;align-items:baseline;line-height:1.5}
11
+ .chisel-review-byline strong{font-weight:500}
12
+ .chisel-review-byline time{color:var(--chisel-ui-secondary);font-size:12px;font-variant-numeric:tabular-nums}
13
+ .chisel-rich-body{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.5;color:var(--chisel-ui-text)}
14
+ .chisel-rich-body p,.chisel-rich-editor p{margin:0;min-height:1.5em}
15
+ .chisel-rich-body a,.chisel-rich-editor a{color:var(--chisel-ui-accent-text);text-decoration:underline;text-underline-offset:2px}
16
+ .chisel-rich-body code,.chisel-rich-editor code{font:0.9em ui-monospace,monospace;background:var(--chisel-ui-inset);padding:1px 3px;border-radius:4px}
17
+ .chisel-review .chisel-expand-thread{margin:0 16px 12px 60px;min-height:40px;padding:0;background:transparent;color:var(--chisel-ui-accent-text)}
18
+ .chisel-review-reply{display:flex;align-items:flex-start;gap:12px;padding:16px;border-top:1px solid var(--chisel-ui-border)}
19
+ .chisel-rich-editor{min-width:0;min-height:40px;max-height:min(180px,30dvh);overflow-y:auto;padding:8px;font-size:14px;line-height:1.5;outline:none;overflow-wrap:anywhere}
20
+ .chisel-review-reply .chisel-rich-editor{padding:12px 14px;min-height:44px}
21
+ .chisel-review .comment-box-native{border:0;border-radius:var(--chisel-ui-radius);box-shadow:0 0 0 1px var(--chisel-ui-border),0 8px 32px #00000014;font:inherit}
22
+ .chisel-review .comment-box-native>form{display:flex;flex-direction:column;min-height:0;height:100%;flex:1}
23
+ .chisel-review .comment-box-native .comment-box-prompt{align-items:flex-start;padding:8px;gap:0}
24
+ .chisel-review .comment-box-native .comment-box-symbol{margin-top:0;background:transparent;border-radius:8px}
25
+ .chisel-review .comment-box-native .comment-box-footer{background:var(--chisel-ui-surface);border-top:1px solid var(--chisel-ui-border)}
26
+ .chisel-review .comment-box-native .comment-box-cancel{border:0;border-radius:8px;background:transparent;font:inherit}
27
+ .chisel-review .comment-box-native .comment-box-submit{border-radius:8px;background:var(--chisel-ui-action);color:var(--chisel-ui-action-text)}
28
+ .chisel-review .comment-box-native .comment-box-element{background:var(--chisel-ui-inset)}
29
+ .chisel-review .comment-box-native .comment-box-properties{background:var(--chisel-ui-surface)}
30
+ .chisel-review .feedback-comment{border-radius:var(--chisel-ui-radius)}
31
+ .chisel-review .comment-thread[data-expanded=false] .chisel-rich-body{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;max-height:4.5em;overflow:hidden}
32
+ .chisel-review [data-slate-placeholder]{color:var(--chisel-ui-secondary);opacity:1!important}
33
+ .chisel-review .chisel-reply-field{position:relative;flex:1;min-width:0;border:1px solid var(--chisel-ui-border);border-radius:16px;background:var(--chisel-ui-raised)}
34
+ .chisel-review .chisel-reply-submit{position:absolute;right:4px;bottom:4px;display:grid;place-items:center;width:40px;height:40px;padding:0;border:0;border-radius:50%;background:var(--chisel-ui-action);color:var(--chisel-ui-action-text)}
35
+ .chisel-review .feedback-reply-avatar{width:32px;height:32px;margin-top:8px}
36
+ .chisel-composer-input{flex:1;min-width:0;max-height:min(320px,42dvh);overflow:auto}
37
+ .chisel-attachment-controls{display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:0 8px;font-size:12px;color:var(--chisel-ui-secondary)}
38
+ .chisel-review-reply .chisel-attachment-controls{padding-right:48px}
39
+ .chisel-formatting-tools button{display:grid;place-items:center;width:40px;height:40px;flex-shrink:0;padding:0;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-secondary);transition:background 150ms,scale 150ms}
40
+ .chisel-formatting-tools button:hover{background:var(--chisel-ui-hover)}
41
+ .chisel-formatting-tools button[aria-pressed=true]{color:var(--chisel-ui-accent-text);background:var(--chisel-ui-accent-surface)}
42
+ .chisel-formatting-tools{display:flex;gap:0;flex-wrap:wrap;padding:0 4px}
43
+ .chisel-formatting-tools button:active{scale:0.96}
44
+ .chisel-link-dialog{display:flex;flex-wrap:wrap;gap:6px;padding:8px;border-top:1px solid var(--chisel-ui-border);background:var(--chisel-ui-surface)}
45
+ .chisel-link-dialog label{flex:1;min-width:120px;font-size:12px;color:var(--chisel-ui-secondary)}
46
+ .chisel-link-dialog input{display:block;width:100%;height:40px;background:var(--chisel-ui-inset);border:1px solid var(--chisel-ui-border);border-radius:6px;color:var(--chisel-ui-text);padding:6px}
47
+ .chisel-link-dialog button{align-self:flex-end;min-height:40px;min-width:40px;padding:6px;border:0;border-radius:6px;background:var(--chisel-ui-hover);color:var(--chisel-ui-text)}
48
+ .chisel-link-dialog [role=alert]{width:100%;color:var(--chisel-ui-danger);font-size:12px}
49
+ .chisel-attachment-error{color:var(--chisel-ui-danger);line-height:1.5}
50
+ .chisel-attachment-previews{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding:8px;max-height:240px;overflow:auto}
51
+ .chisel-attachment-preview{position:relative;min-width:0;overflow:hidden;border:1px solid var(--chisel-ui-border);border-radius:8px;background:var(--chisel-ui-surface)}
52
+ .chisel-attachment-preview>img,.chisel-attachment-preview>a>img,.chisel-attachment-preview>video{display:block;width:100%;height:100px;object-fit:contain;background:var(--chisel-ui-inset);outline:1px solid #0000001a;outline-offset:-1px}
53
+ .chisel-attachment-preview>span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:8px;font-size:12px}
54
+ .chisel-attachment-preview>button:not(.review-media-thumbnail){position:absolute;top:0;right:0;display:grid;place-items:center;width:40px;height:40px;padding:0;border:0;border-radius:0 8px;background:var(--chisel-ui-surface);color:var(--chisel-ui-text)}
55
+ .chisel-attachment-preview>.chisel-attachment-retry{right:40px;border-radius:0 0 0 8px}
56
+ .chisel-attachment-preview>.chisel-attachment-load{position:static;width:100%;height:auto;min-height:100px;padding:8px}
57
+ .comment-thread .feedback-thread-header{position:sticky;top:0;z-index:1;background:var(--chisel-ui-surface)}
58
+ .chisel-review .comment-thread[data-native-ui=true][data-expanded=false]{border-radius:16px 16px 16px 0}
59
+ @media(prefers-color-scheme:dark){.chisel-attachment-preview>img,.chisel-attachment-preview>a>img,.chisel-attachment-preview>video{outline-color:#ffffff1a}}
60
+ @media(prefers-reduced-motion:reduce){.chisel-formatting-tools button{transition:none}}
61
+ `;var X=`/* Shared presentation for the owned review UI. */
62
+ .feedback-shell.chisel-review .comment-thread[data-native-ui=true],.feedback-shell.chisel-review .comment-box-native{border:0;border-radius:16px;background:var(--chisel-ui-surface);box-shadow:var(--chisel-ui-popover-shadow)}
63
+ .feedback-shell.chisel-review .comment-thread[data-expanded=false]{border-radius:16px 16px 16px 0}
64
+ .chisel-review-thread-content,.review-thread,.review-comment-content{width:100%;min-width:0}
65
+ .review-comment,.feedback-shell.chisel-review .chisel-review-message{display:flex;align-items:flex-start;gap:12px;padding:12px 20px}
66
+ .review-comment-content,.chisel-review-message-content{flex:1;min-width:0}
67
+ .review-comment-avatar{display:grid;place-items:center;flex-shrink:0;width:28px;height:28px;border-radius:50%;overflow:hidden;background:var(--chisel-ui-avatar);color:var(--chisel-ui-avatar-text);font-size:12px}
68
+ .review-comment-avatar img{width:100%;height:100%;object-fit:cover}
69
+ .review-comment-header,.chisel-review-byline{display:flex;align-items:baseline;flex-wrap:wrap;gap:8px;line-height:20px;margin-bottom:4px}
70
+ .review-comment-author{font-size:13px;font-weight:500;overflow-wrap:anywhere}
71
+ .review-comment-time{font-size:12px;color:var(--chisel-ui-muted);font-variant-numeric:tabular-nums;white-space:nowrap}
72
+ .review-comment-header{position:relative;padding-right:32px}
73
+ .review-comment-edit{position:absolute;right:-8px;top:-10px;display:grid;place-items:center;width:40px;height:40px;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-muted);opacity:0;transition:opacity 120ms,background 120ms}
74
+ .review-comment:hover .review-comment-edit,.review-comment:focus-within .review-comment-edit,.review-comment-edit:focus-visible{opacity:1}
75
+ .review-comment-edit:hover{background:var(--chisel-ui-hover);color:var(--chisel-ui-text)}
76
+ @media(hover:none){.review-comment-edit{opacity:1}}
77
+ .review-inline-edit{border:1px solid var(--chisel-ui-border);border-radius:10px;padding:8px}
78
+ .review-inline-edit-actions{display:flex;justify-content:flex-end;gap:6px;margin-top:8px}
79
+ .review-inline-edit-actions button{min-height:32px;padding:0 10px;border:0;border-radius:6px;background:var(--chisel-ui-hover);color:var(--chisel-ui-text)}
80
+ .review-comment-body,.chisel-rich-body{font-size:14px;line-height:21px;white-space:pre-wrap;overflow-wrap:anywhere}
81
+ .review-comment-body p{margin:0;min-height:21px}.review-comment-body p+p{margin-top:8px}
82
+ .review-comment-body a{color:var(--chisel-ui-accent-text);text-decoration:underline;text-underline-offset:3px}
83
+ .review-comment-body code{font:12px/1.5 ui-monospace,SFMono-Regular,monospace;background:var(--chisel-ui-inset);border-radius:4px;padding:2px 4px}
84
+ .review-composer{margin:0}
85
+ .feedback-shell.chisel-review .chisel-review-reply{display:flex;align-items:flex-start;gap:12px;border:0;padding:20px}
86
+ .feedback-shell.chisel-review .chisel-review-reply[hidden]{display:none}
87
+ .feedback-shell.chisel-review .feedback-reply-avatar{width:28px;height:28px;margin-top:8px}
88
+ .feedback-shell.chisel-review .chisel-reply-field{position:relative;flex:1;min-width:0;min-height:48px;border:0;border-radius:12px;background:var(--chisel-ui-raised)}
89
+ .review-composer-editor{min-width:0;min-height:40px;max-height:min(180px,30dvh);overflow:auto;padding:10px 12px;font-size:14px;line-height:21px;overflow-wrap:anywhere;outline:none}
90
+ .review-composer-editor p{margin:0}
91
+ .review-composer-editor>p,.chisel-rich-editor>p{position:relative}
92
+ .feedback-shell.chisel-review .chisel-review-reply :is(.review-composer-editor,.chisel-rich-editor){padding-right:56px}
93
+ .feedback-shell.chisel-review .chisel-reply-submit{position:absolute;right:4px;bottom:4px;display:grid;place-items:center;width:40px;height:40px;min-height:40px;padding:0;border:0;border-radius:8px;background:var(--chisel-ui-action);color:var(--chisel-ui-action-text)}
94
+ .chisel-reply-submit:disabled{opacity:.35}
95
+ .feedback-shell.chisel-review .comment-box-native>form{display:flex;flex-direction:column;flex:1;min-height:0;height:100%}
96
+ .feedback-shell.chisel-review .comment-box-native .comment-box-prompt{align-items:flex-start;padding:8px;gap:0}
97
+ .feedback-shell.chisel-review .comment-box-native .comment-box-footer{border:0;background:var(--chisel-ui-surface)}
98
+ .feedback-shell.chisel-review .comment-box-native .comment-box-element{background:var(--chisel-ui-raised)}
99
+ .feedback-shell.chisel-review .comment-box-native .comment-box-cancel{border:0;border-radius:8px;background:transparent}
100
+ .feedback-shell.chisel-review .comment-box-native .comment-box-cancel:hover{background:var(--chisel-ui-hover)}
101
+ .feedback-shell.chisel-review .comment-box-native .comment-box-submit{border-radius:8px}
102
+ .chisel-composer-input{flex:1;min-width:0;max-height:min(320px,42dvh);overflow:auto}
103
+ .chisel-attachment-controls{display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:0 8px;color:var(--chisel-ui-secondary);font-size:12px;line-height:18px}
104
+ .chisel-review-reply .chisel-attachment-controls{padding-right:48px}
105
+ .chisel-attachment-error{color:var(--chisel-ui-danger);line-height:1.5}
106
+ .chisel-attachment-previews,.review-attachments{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding:8px;max-height:240px;overflow:auto}
107
+ .review-attachments{padding:12px 0 0;max-height:none}
108
+ .feedback-shell.chisel-review .chisel-attachment-preview,.review-attachment{position:relative;min-width:0;margin:0;overflow:hidden;border:0;border-radius:8px;background:var(--chisel-ui-raised)}
109
+ .chisel-attachment-preview>img,.chisel-attachment-preview>video,.review-media-thumbnail img,.review-media-thumbnail video{display:block;width:100%;height:120px;object-fit:contain;background:var(--chisel-ui-inset)}
110
+ .review-attachment figcaption{padding:8px;font-size:12px;line-height:18px;overflow-wrap:anywhere}
111
+ .review-attachment-placeholder{min-height:100px;display:grid;place-items:center;padding:12px;color:var(--chisel-ui-secondary);font-size:12px}
112
+ .chisel-attachment-preview>button:not(.review-media-thumbnail){position:absolute;top:0;right:0;display:grid;place-items:center;width:40px;height:40px;padding:0;border:0;border-radius:0 8px;background:var(--chisel-ui-surface);color:var(--chisel-ui-text)}
113
+ .review-retry-upload{display:inline-flex;align-items:center;gap:6px;min-height:40px;padding:0 8px;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-text);font:inherit}
114
+ .review-retry-upload:hover{background:var(--chisel-ui-hover)}
115
+ .chisel-attachment-preview>span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:8px;font-size:12px}
116
+ .feedback-shell.chisel-review .chisel-expand-thread{display:inline-flex;align-items:center;margin:0 20px 8px 60px;min-height:40px;padding:0;border:0;background:transparent;color:var(--chisel-ui-secondary);font-size:13px}
117
+ .chisel-review [data-slate-placeholder]{opacity:1!important;color:var(--chisel-ui-secondary)}
118
+ @media(pointer:coarse){.feedback-shell.chisel-review .chisel-reply-submit{width:44px;height:44px}.chisel-review-reply .chisel-attachment-controls{padding-right:52px}.feedback-shell.chisel-review .chisel-reply-field{min-height:52px}.feedback-shell.chisel-review .chisel-review-reply :is(.review-composer-editor,.chisel-rich-editor){padding-right:60px}}
119
+ @media(forced-colors:active){.feedback-shell.chisel-review .comment-thread[data-native-ui=true],.feedback-shell.chisel-review .comment-box-native,.feedback-shell.chisel-review .chisel-reply-field{border:1px solid CanvasText;box-shadow:none}.review-comment-avatar{border:1px solid CanvasText}}
120
+ .review-media-thumbnail{position:relative;display:block;width:100%;padding:0;border:0;background:var(--chisel-ui-inset);cursor:pointer}
121
+ .review-media-thumbnail img,.review-media-thumbnail video{display:block;width:100%;height:120px;object-fit:contain}
122
+ .review-media-play{position:absolute;inset:50% auto auto 50%;display:grid;place-items:center;width:40px;height:40px;border-radius:50%;background:#0009;color:white;transform:translate(-50%,-50%)}
123
+ .review-media-lightbox{position:fixed;inset:0;width:100vw;height:100dvh;max-width:none;max-height:none;margin:0;padding:24px;border:0;background:transparent;color:var(--chisel-ui-text)}
124
+ .review-media-lightbox::backdrop{background:#000b}
125
+ .review-media-lightbox-content{display:flex;flex-direction:column;width:min(100%,1000px);max-height:100%;margin:auto;border-radius:12px;overflow:hidden;background:var(--chisel-ui-surface);box-shadow:0 16px 48px #0006}
126
+ .review-media-lightbox-content header{display:flex;align-items:center;gap:12px;min-height:56px;padding:8px 12px 8px 16px}
127
+ .review-media-lightbox-content header span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
128
+ .review-media-lightbox-content header a{color:var(--chisel-ui-text);font-size:13px}
129
+ .review-media-lightbox-content header button{display:grid;place-items:center;flex-shrink:0;width:40px;height:40px;padding:0;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-text)}
130
+ .review-media-lightbox-content header button:hover{background:var(--chisel-ui-hover)}
131
+ .review-media-lightbox-content>img,.review-media-lightbox-content>video{display:block;min-height:0;max-width:100%;max-height:calc(100dvh - 104px);margin:auto;object-fit:contain;background:#000}
132
+ `;var b="https://chisel-review.vercel.app";function H(p){return Array.isArray(p)?p.filter(o=>o&&typeof o.id=="string"&&typeof o.name=="string"&&typeof o.path=="string").map(o=>({id:o.id,name:o.name.slice(0,100),path:o.path.slice(0,2048),image:typeof o.image=="string"&&/^https?:\/\//.test(o.image)?o.image:null})):[]}function Pe({projectId:p}){let o=`chisel:session:${p}`,c=w(""),[m,N]=h(null),[q,y]=h(!0),[B,I]=h(""),[Q,k]=h(!1),[M,S]=h([]),[Y,G]=h([]),[K,L]=h("connecting"),C=w("/"),T=w(!1),[Z,ee]=h(0),j=w(new Set),u=x(()=>{for(let e of j.current)e()},[]),E=w(null);E.current=m;let P=w(null),z=w(""),d=x(async(e,i,t,r,a=!1)=>{let n=await fetch(`${b}/chisel/api/hosted/${e}`,{method:i,headers:{Authorization:`Bearer ${c.current}`,...t?{"Content-Type":"application/json","X-Chisel-Protocol":"2"}:{}},...t?{body:JSON.stringify(t)}:{},signal:r,keepalive:a}),v=await n.json();if(!n.ok)throw n.status===401&&E.current&&k(!0),Object.assign(new Error(v.error||"Chisel is unavailable. Please try again."),{status:n.status});if(v.siteId&&v.siteId!==p)throw new Error("This session belongs to another project.");return v},[p]),l=x((e,i)=>d(e==="GET"?`comments?path=${encodeURIComponent(C.current)}`:"comments",e,i),[d]),ie=U(()=>{let e=0;return{async list(){let i=++e;try{let t=await l("GET");return i===e&&(S(t.comments),T.current||G(H(t.participants))),t.comments}catch(t){throw t}},async mutate(i){++e;let t=(await l("POST",i)).comment;return++e,S(r=>r.some(a=>a.id===t.id)?r.map(a=>a.id===t.id?t:a):[...r,t]),window.setTimeout(u,0),t},async delete(i){++e,await l("POST",{type:"delete",id:i}),++e,S(t=>t.filter(r=>r.id!==i)),window.setTimeout(u,0)},subscribe(i){return j.current.add(i),()=>{j.current.delete(i)}}}},[l,u]),te=x(async(e,i)=>{await l("POST",{type:"read",id:e,activity:i})},[l]),re=x((e,i)=>{S(t=>t.map(r=>r.id===e?{...r,readActivity:Math.max(r.readActivity??0,i)}:r))},[]),{flush:D,markDisplayed:ae}=ge(te,re);O(()=>{if(!m)return;let e=!0,i,t,r=new AbortController,a=()=>{document.visibilityState==="visible"&&(clearTimeout(t),t=setTimeout(()=>{u(),D()},40))};async function n(){try{let R=await fetch(`${b}/chisel/api/hosted/events?path=${encodeURIComponent(C.current)}`,{headers:{Authorization:`Bearer ${c.current}`},signal:r.signal});if(R.status===401&&k(!0),!R.ok||!R.body)throw new Error("Live updates unavailable");let se=R.body.getReader(),ce=new TextDecoder,f="";for(;e;){let{value:le,done:de}=await se.read();if(de)break;f+=ce.decode(le,{stream:!0});let $;for(;($=f.indexOf(`
133
+
134
+ `))>=0;){let A=f.slice(0,$);if(f=f.slice($+2),A==="data: ready")L("connected"),a();else if(A==="data: change")a();else if(A.startsWith("data: presence:"))try{T.current=!0,G(H(JSON.parse(A.slice(15))))}catch{}}}}catch{}e&&(T.current=!1,L("reconnecting"),i=setTimeout(()=>{n()},2e3))}L("connecting"),n();let v=window.setInterval(a,1e4);return window.addEventListener("focus",a),window.addEventListener("online",a),document.addEventListener("visibilitychange",a),()=>{e=!1,T.current=!1,r.abort(),clearTimeout(i),clearTimeout(t),window.clearInterval(v),window.removeEventListener("focus",a),window.removeEventListener("online",a),document.removeEventListener("visibilitychange",a)}},[m,Z,u,D]);let oe=x(e=>{C.current!==e&&(C.current=e,ee(i=>i+1),u())},[u]),F=U(()=>({async userId(){return E.current?.user.id??""},async discard(e){await d("attachments","POST",{action:"cancel",id:e.id},void 0,!0)},async send(e,i,t){let r=async()=>{let n=await d("attachments","POST",{action:"confirm",id:e.id});if(n.attachment?.id!==e.id||n.attachment.token!==e.id)throw new Error("The upload confirmation was incomplete. Please retry.");return e.id};if(i){if(!t())return"";try{return await r()}catch(n){if(![404,503].includes(n.status??0))throw n}}let a=await d("attachments","POST",{action:"prepare",id:e.id,name:e.name,mimeType:e.mimeType,size:e.size});if(a.attachment?.id===e.id&&a.attachment.token===e.id)return e.id;if(typeof a.url!="string"||typeof a.key!="string")throw new Error("The upload could not be started. Please retry.");if(!t())return"";if(!e.stored){let n=new FormData;n.append("cacheControl","3600"),n.append("",e.file);try{(await fetch(a.url,{method:"PUT",headers:{apikey:a.key,"x-upsert":"false"},body:n})).ok&&(e.stored=!0)}catch{}}return t()?r():""}}),[d]),J=U(()=>function(i=!1,t=0){return we(i,t,F)},[F]),ne=x(async(e,i)=>{let t=await d(`attachments?id=${encodeURIComponent(e)}`,"GET",void 0,i);if(typeof t.url!="string")throw new Error("Attachment unavailable");return t.url},[d]);O(()=>{if(c.current=sessionStorage.getItem(o)||"",!c.current){y(!1);return}let e=!0;return l("GET").then(i=>{e&&N(i)}).catch(()=>{e&&(c.current="",sessionStorage.removeItem(o))}).finally(()=>{e&&y(!1)}),()=>{e=!1}},[o,l]),O(()=>{let e=i=>{i.origin!==b||i.source!==P.current||i.data?.type!=="chisel:session"||i.data.state!==z.current||!/^[0-9a-f]{64}$/.test(i.data.token)||(c.current=i.data.token,sessionStorage.setItem(o,c.current),z.current="",P.current=null,E.current||y(!0),I(""),l("GET").then(t=>{N(t),k(!1);let r=new URL(window.location.href);r.searchParams.delete("invite"),window.history.replaceState(window.history.state,"",r)}).catch(t=>{c.current="",sessionStorage.removeItem(o),I(t instanceof Error?t.message:"Could not connect to Chisel.")}).finally(()=>y(!1)))};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[o,l]);function V(){let e=crypto.getRandomValues(new Uint8Array(32));z.current=Array.from(e,r=>r.toString(16).padStart(2,"0")).join("");let i=new URL("/chisel/connect",b);i.searchParams.set("site",p),i.searchParams.set("origin",window.location.origin),i.searchParams.set("state",z.current);let t=new URLSearchParams(window.location.search).get("invite");t&&i.searchParams.set("invite",t),P.current=window.open(i.toString(),"chisel-sign-in","popup,width=520,height=700"),P.current||I("Allow pop-ups for this site, then try again.")}return q?g("main",{className:"chisel-sign-in",children:[s(_,{}),s("section",{children:s("p",{children:"Connecting to Chisel\u2026"})})]}):m?g(me,{children:[g("style",{children:[W,X]}),s(ue,{user:m.user,commentStore:ie,canManageComments:m.role==="owner",commentUI:{className:"chisel-review",renderComposer:e=>{let i=M.find(t=>t.id===e.commentId);return s(ve,{...e,defaultBody:i?.body,existingAttachments:i?.attachments,useAttachments:J})},renderThread:e=>s(xe,{...e,onRead:ae,useAttachments:J,loadMedia:ne},e.comment.id)},collaboration:{status:K,participants:Y,setPage:oe,markRead(){},unreadThreadIds:M.filter(e=>e.readActivity!==null&&e.readActivity<e.activity).map(e=>e.id)},getReviewLink:m.role==="owner"?async(e=!1)=>{let i=await fetch(`${b}/chisel/api/hosted/invite`,{method:"POST",headers:{Authorization:`Bearer ${c.current}`,"Content-Type":"application/json","X-Chisel-Protocol":"2"},body:JSON.stringify({rotate:e})}),t=await i.json();if(i.status===401&&k(!0),!i.ok||typeof t.invite!="string")throw new Error(t.error||"Could not create a review link.");let r=new URL("/chisel",window.location.origin);return r.searchParams.set("mode","comment"),r.searchParams.set("invite",t.invite),r.toString()}:void 0,validateSession:async()=>!!c.current,signOut:async()=>{let e=await fetch(`${b}/chisel/api/hosted/logout`,{method:"DELETE",headers:{Authorization:`Bearer ${c.current}`,"X-Chisel-Protocol":"2"}});if(!e.ok&&e.status!==401)throw new Error("Sign out failed.");c.current="",sessionStorage.removeItem(o)}}),Q&&g("div",{role:"alert",style:{position:"fixed",bottom:16,right:16,zIndex:999999,background:"white",color:"black",padding:12,borderRadius:8,boxShadow:"0 2px 12px #0003"},children:["Your Chisel session expired. ",s("button",{type:"button",onClick:V,children:"Sign in again"})]})]}):g("main",{className:"chisel-sign-in",children:[s(_,{}),g("section",{children:[s("strong",{className:"chisel-sign-in-brand",children:"chisel"}),s("h1",{children:"Sign in to review"}),s("p",{children:"Connect this website to your Chisel account."}),s("button",{onClick:V,children:"Continue with Chisel"}),B&&s("p",{role:"alert",children:B})]})]})}export{Pe as HostedChisel};
@@ -0,0 +1,35 @@
1
+ export type Upload = {
2
+ id: string;
3
+ name: string;
4
+ mimeType: string;
5
+ size: number;
6
+ token?: string;
7
+ preview: string;
8
+ bucket: string;
9
+ path: string;
10
+ file: File;
11
+ stored: boolean;
12
+ status: "uploading" | "ready" | "failed";
13
+ };
14
+ export type AttachmentTransport = {
15
+ userId(): Promise<string>;
16
+ send(file: Upload, retrying: boolean, isActive: () => boolean): Promise<string>;
17
+ discard(file: Upload): Promise<void>;
18
+ };
19
+ export declare function useReviewAttachments(disabled: boolean | undefined, existingCount: number | undefined, transport: AttachmentTransport): {
20
+ attachments: Upload[];
21
+ uploading: boolean;
22
+ blocked: boolean;
23
+ controls: import("react").JSX.Element;
24
+ previewsUI: false | import("react").JSX.Element;
25
+ clear: () => void;
26
+ upload: (selectedFiles: FileList | null) => Promise<void>;
27
+ previews: {
28
+ id: string;
29
+ name: string;
30
+ mimeType: string;
31
+ size: number;
32
+ previewUrl: string;
33
+ }[];
34
+ tokens: string[];
35
+ };
@@ -0,0 +1,36 @@
1
+ import { type ReactNode } from "react";
2
+ import type { WorkspaceComposerProps, WorkspaceThreadProps } from "use-chisel/workspace";
3
+ import { type ReviewBody as CommentBody } from "./content";
4
+ import type { ReviewAttachment } from "./types";
5
+ export type ReviewAttachments = {
6
+ attachments: readonly unknown[];
7
+ uploading: boolean;
8
+ blocked: boolean;
9
+ controls: ReactNode;
10
+ previewsUI: ReactNode;
11
+ clear(): void;
12
+ upload(files: FileList | null): Promise<void>;
13
+ previews: {
14
+ id: string;
15
+ name: string;
16
+ mimeType: string;
17
+ size: number;
18
+ previewUrl?: string;
19
+ }[];
20
+ tokens: string[];
21
+ };
22
+ export type UseReviewAttachments = (disabled?: boolean, existingCount?: number) => ReviewAttachments;
23
+ export type LoadReviewMedia = (id: string, signal: AbortSignal) => Promise<string>;
24
+ export declare function ReviewBody({ body }: {
25
+ body: CommentBody;
26
+ }): import("react").JSX.Element;
27
+ export declare function ReviewComposer(props: WorkspaceComposerProps & {
28
+ defaultBody?: CommentBody;
29
+ existingAttachments?: ReviewAttachment[];
30
+ useAttachments: UseReviewAttachments;
31
+ }): import("react").JSX.Element;
32
+ export declare function ReviewThread(props: WorkspaceThreadProps & {
33
+ onRead(id: string, activity: number): void;
34
+ useAttachments: UseReviewAttachments;
35
+ loadMedia: LoadReviewMedia;
36
+ }): import("react").JSX.Element;
@@ -0,0 +1,24 @@
1
+ export type ReviewText = {
2
+ text: string;
3
+ bold?: boolean;
4
+ italic?: boolean;
5
+ strikethrough?: boolean;
6
+ code?: boolean;
7
+ };
8
+ export type ReviewLink = {
9
+ type: "link";
10
+ url: string;
11
+ text?: string;
12
+ };
13
+ export type ReviewBody = {
14
+ version: 1;
15
+ content: {
16
+ type: "paragraph";
17
+ children: (ReviewText | ReviewLink)[];
18
+ }[];
19
+ };
20
+ type CommentBody = ReviewBody;
21
+ export declare function commentBody(text: string): CommentBody;
22
+ export declare function bodyText(body: CommentBody): string;
23
+ export declare function trimCommentBody(body: CommentBody): CommentBody;
24
+ export {};
@@ -0,0 +1,44 @@
1
+ import { type BaseEditor, type Descendant } from "slate";
2
+ import { type HistoryEditor } from "slate-history";
3
+ import { ReactEditor } from "slate-react";
4
+ import { type ReviewBody as CommentBody } from "./content";
5
+ type Mark = "bold" | "italic" | "strikethrough" | "code";
6
+ type ReviewText = {
7
+ text: string;
8
+ } & Partial<Record<Mark, boolean>>;
9
+ type LinkElement = {
10
+ type: "link";
11
+ url: string;
12
+ children: ReviewText[];
13
+ };
14
+ type ParagraphElement = {
15
+ type: "paragraph";
16
+ children: (ReviewText | LinkElement)[];
17
+ };
18
+ declare module "slate" {
19
+ interface CustomTypes {
20
+ Editor: BaseEditor & ReactEditor & HistoryEditor;
21
+ Element: ParagraphElement | LinkElement;
22
+ Text: ReviewText;
23
+ }
24
+ }
25
+ export declare function bodyToEditor(body: CommentBody): Descendant[];
26
+ export declare function editorToBody(value: Descendant[]): CommentBody;
27
+ export declare function createReviewEditor(): BaseEditor & ReactEditor & HistoryEditor;
28
+ export declare function ReviewAttachmentButton({ onFiles, disabled }: {
29
+ onFiles(files: FileList | null): Promise<void>;
30
+ disabled?: boolean;
31
+ }): import("react").JSX.Element;
32
+ export declare function ReviewEditor({ text, defaultBody, disabled, label, placeholder, autoFocus, onChange, onSubmit, onFiles, uploading }: {
33
+ text: string;
34
+ defaultBody?: CommentBody;
35
+ disabled?: boolean;
36
+ label: string;
37
+ placeholder: string;
38
+ autoFocus?: boolean;
39
+ onChange(text: string, body: CommentBody): void;
40
+ onSubmit(): void;
41
+ onFiles?(files: FileList | null): Promise<void>;
42
+ uploading?: boolean;
43
+ }): import("react").JSX.Element;
44
+ export {};
@@ -0,0 +1,8 @@
1
+ type Media = {
2
+ src: string;
3
+ name: string;
4
+ mimeType: string;
5
+ onError?(): void;
6
+ };
7
+ export declare function MediaPreview({ src, name, mimeType, onError }: Media): import("react").JSX.Element;
8
+ export {};
@@ -0,0 +1,9 @@
1
+ export declare const imageLimit: number;
2
+ export declare const videoLimit: number;
3
+ export declare const imageTypes: string[];
4
+ export declare const videoTypes: string[];
5
+ export declare const mediaAccept: string;
6
+ export declare function mediaFileError(file: {
7
+ type: string;
8
+ size: number;
9
+ }): string | null;
@@ -0,0 +1,4 @@
1
+ export declare function useReadQueue(send: (id: string, activity: number) => Promise<unknown>, apply: (id: string, activity: number) => void): {
2
+ flush: () => Promise<void>;
3
+ markDisplayed: (id: string, activity: number) => void;
4
+ };
@@ -0,0 +1 @@
1
+ export declare function displayedActivity(readActivity: number, activities: readonly number[], displayed: ReadonlySet<number>): number;
@@ -0,0 +1,21 @@
1
+ import type { WorkspaceAttachment, WorkspaceComment, WorkspaceReply } from "use-chisel/workspace";
2
+ import type { ReviewBody } from "./content";
3
+ export type ReviewAttachment = WorkspaceAttachment & {
4
+ bucket: string;
5
+ path: string;
6
+ };
7
+ export type ReviewReply = Omit<WorkspaceReply, "attachments"> & {
8
+ id: string;
9
+ body: ReviewBody;
10
+ date: string;
11
+ activity: number;
12
+ attachments: ReviewAttachment[];
13
+ };
14
+ export type ReviewComment = Omit<WorkspaceComment, "replies" | "attachments"> & {
15
+ attachments: ReviewAttachment[];
16
+ body: ReviewBody;
17
+ rootActivity: number;
18
+ activity: number;
19
+ readActivity: number | null;
20
+ replies: ReviewReply[];
21
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./review/content";
2
+ export * from "./review/media-limits";
@@ -0,0 +1,3 @@
1
+ function s(t){return{version:1,content:t.split(`
2
+ `).map(e=>({type:"paragraph",children:[{text:e}]}))}}function a(t){return t.content.map(e=>e.children.map(i=>"type"in i?i.text||i.url:i.text).join("")).join(`
3
+ `)}function g(t){let e=t.content.slice();for(;e.length;){let i=e[e.length-1],n=i.children.slice();for(;n.length;){let o=n[n.length-1],m="type"in o?o.text||o.url:o.text,r=m.trimEnd();if(r)return n[n.length-1]=r===m?o:{...o,text:r},e[e.length-1]={...i,children:n},{...t,content:e};n.pop()}e.pop()}return s("")}var u=5242880,d=20971520,p=["image/jpeg","image/png","image/gif","image/webp","image/avif","image/bmp"],c=["video/mp4","video/webm","video/quicktime"],x=[...p,...c].join(",");function h(t){let e=p.includes(t.type);return!e&&!c.includes(t.type)?"Choose a JPG, PNG, GIF, WebP, AVIF, BMP, MP4, WebM, or MOV file.":!Number.isSafeInteger(t.size)||t.size<=0?"This file is empty or invalid.":t.size>(e?5242880:20971520)?`${e?"Images must be 5 MB":"Videos must be 20 MB"} or smaller.`:null}export{a as bodyText,s as commentBody,u as imageLimit,p as imageTypes,x as mediaAccept,h as mediaFileError,g as trimCommentBody,d as videoLimit,c as videoTypes};
@@ -0,0 +1,8 @@
1
+ export { ReviewComposer, ReviewThread, ReviewBody } from "./review/comment-ui";
2
+ export type { UseReviewAttachments, ReviewAttachments, LoadReviewMedia } from "./review/comment-ui";
3
+ export { ReviewEditor, ReviewAttachmentButton, bodyToEditor, editorToBody, createReviewEditor } from "./review/editor";
4
+ export { displayedActivity } from "./review/read-state";
5
+ export { useReadQueue } from "./review/read-queue";
6
+ export type { ReviewComment, ReviewReply, ReviewAttachment } from "./review/types";
7
+ export { useReviewAttachments } from "./review/attachments";
8
+ export type { Upload, AttachmentTransport } from "./review/attachments";
@@ -0,0 +1,31 @@
1
+ "use client";import{jsx as n,Fragment as fa,jsxs as M}from"react/jsx-runtime";import{forwardRef as Xe,createElement as Ke}from"react";var ne=e=>e?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function pe(e,a,o=[]){if(a==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:ne(e),size:24,node:a,...o.length>0?{aliases:o}:{}}}var me=e=>{let a="",o=!1;for(let t of e){if(t==="-"||t==="_"||t<=" "){o=a.length>0;continue}a.length===0?a+=t.toLowerCase():a+=o?t.toUpperCase():t,o=!1}return a};var Le=e=>{let a=me(e);return a.charAt(0).toUpperCase()+a.slice(1)};import{forwardRef as Ne,createElement as ge}from"react";var O=(...e)=>e.filter((a,o,t)=>!!a&&a.trim()!==""&&t.indexOf(a)===o).join(" ").trim();var R={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function te(e){return e!=null}function Ie(e,a={}){let o=a.attributeNames??{},t=d=>o[d]??d,l=e.size??e.width??R.width,u=e.size??e.height??R.height,f=e.aliases?.filter(d=>typeof d=="string"&&d.trim()!=="").map(d=>`lucide-${d}`)??[],c=[...e.name?[`lucide-${e.name}`]:[],...f],i=a.className?.split(" ").filter(Boolean)??[],p=a.includeDefaultClasses===!1?O(...i):O("lucide",...c,...i),r=a.absoluteStrokeWidth?Number(a.strokeWidth??R["stroke-width"])*Number(e.size??e.width??R.width)/Number(a.size??a.width??R.width):a.strokeWidth??R["stroke-width"];return["svg",{...Object.entries(R).reduce((d,[s,m])=>(d[t(s)]=m,d),{}),..."color"in a&&a.color&&{[t("stroke")]:a.color},..."size"in a&&te(a.size)&&{[t("width")]:a.size,[t("height")]:a.size},..."width"in a&&te(a.width)&&{[t("width")]:a.width},..."height"in a&&te(a.height)&&{[t("height")]:a.height},[t("stroke-width")]:r,...p&&{[t("class")]:p},[t("viewBox")]:`0 0 ${l} ${u}`,...a.hasA11yProp===!1?{[t("aria-hidden")]:"true"}:{},..."attributes"in a&&a.attributes},e.node.map(d=>{let[s,m,x]=d,C=a.nonScalingStroke?{[t("vector-effect")]:"non-scaling-stroke",...m}:m;return x?[s,C,x]:[s,C]})]}function xe(e,a={}){return Ie(e,{...a,attributeNames:{...a.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}var Ce=e=>{for(let a in e)if(a.startsWith("aria-")||a==="role"||a==="title")return!0;return!1};import{createContext as We,useContext as Ve,useMemo as va,createElement as qa}from"react";var ze=We({});var he=()=>Ve(ze);var Se=Ne(({color:e,size:a,width:o,height:t,strokeWidth:l,absoluteStrokeWidth:u,nonScalingStroke:f,className:c="",children:i,iconNode:p=[],icon:r={node:p,aliases:[],size:24},...I},d)=>{let{size:s=24,strokeWidth:m=2,absoluteStrokeWidth:x=!1,nonScalingStroke:C=!1,color:F="currentColor",className:_=""}=he()??{},X=!!i||Ce(I),[$,Y,L=[]]=xe(r,{color:e??F,width:o??a??s,height:t??a??s,strokeWidth:l??m,absoluteStrokeWidth:u??x,nonScalingStroke:f??C,className:O(_,c),hasA11yProp:X,attributes:I});return ge($,{ref:d,...Y},[...L.map(([g,y])=>ge(g,y)),...Array.isArray(i)?i:[i]])});function P(e,a=[],o=[]){let t=typeof e=="string"?pe(e,a,o):e,l=Xe(({className:u,...f},c)=>Ke(Se,{ref:c,icon:t,className:u,...f}));return t.name&&(l.displayName=Le(t.name)),l}var ke={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};ke.node;var H=P(ke);var we={name:"paperclip",size:24,node:[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]};we.node;var E=P(we);var Pe={name:"pencil",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]};Pe.node;var G=P(Pe);var Ae={name:"play",size:24,node:[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]};Ae.node;var W=P(Ae);var Be={name:"rotate-cw",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]};Be.node;var V=P(Be);var De={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};De.node;var T=P(De);import{useEffect as U,useRef as D,useState as N}from"react";function A(e){return{version:1,content:e.split(`
2
+ `).map(a=>({type:"paragraph",children:[{text:a}]}))}}function ye(e){return e.content.map(a=>a.children.map(o=>"type"in o?o.text||o.url:o.text).join("")).join(`
3
+ `)}function K(e){let a=e.content.slice();for(;a.length;){let o=a[a.length-1],t=o.children.slice();for(;t.length;){let l=t[t.length-1],u="type"in l?l.text||l.url:l.text,f=u.trimEnd();if(f)return t[t.length-1]=f===u?l:{...l,text:f},a[a.length-1]={...o,children:t},{...e,content:a};t.pop()}a.pop()}return A("")}function oe(e,a,o){let t=e;for(let l of[...a].sort((u,f)=>u-f))if(!(l<=t)){if(!o.has(l))break;t=l}return t}import{jsx as S,Fragment as be,jsxs as Te}from"react/jsx-runtime";var Z=["image/jpeg","image/png","image/gif","image/webp","image/avif","image/bmp"],Me=["video/mp4","video/webm","video/quicktime"],Fe=[...Z,...Me].join(",");function Re(e){let a=Z.includes(e.type);return!a&&!Me.includes(e.type)?"Choose a JPG, PNG, GIF, WebP, AVIF, BMP, MP4, WebM, or MOV file.":!Number.isSafeInteger(e.size)||e.size<=0?"This file is empty or invalid.":e.size>(a?5242880:20971520)?`${a?"Images must be 5 MB":"Videos must be 20 MB"} or smaller.`:null}import{useEffect as Ze,useRef as de,useState as Je}from"react";import{createEditor as Qe,Editor as h,Element as q,Node as je,Path as _e,Range as ue,Transforms as B}from"slate";import{withHistory as $e}from"slate-history";import{Editable as Ye,Slate as ea,withReact as aa,ReactEditor as ve}from"slate-react";function le(e){return e.content.length?e.content.map(a=>({type:"paragraph",children:a.children.length?a.children.map(o=>"type"in o&&o.type==="link"?{type:"link",url:o.url,children:[{text:o.text||o.url}]}:{...o}):[{text:""}]})):[{type:"paragraph",children:[{text:""}]}]}function qe(e){return{version:1,content:e.map(a=>({type:"paragraph",children:q.isElement(a)?a.children.map(o=>q.isElement(o)?{type:"link",url:o.url,text:je.string(o)}:{...o}):[{text:a.text}]}))}}function re(e){return/^(https?:\/\/|mailto:)[^\s]+$/i.test(e)}function ta(e,a){if(!e.selection){let o=window.getSelection(),t=o&&ve.toSlateRange(e,o,{exactMatch:!1,suppressThrow:!0});B.select(e,t??h.end(e,[]))}h.marks(e)?.[a]?h.removeMark(e,a):h.addMark(e,a,!0)}function Ue(){let e=aa($e(Qe()),"application/x-chisel-review-fragment"),{isInline:a,insertText:o,insertData:t,insertBreak:l}=e;e.isInline=c=>c.type==="link"||a(c);function u(c,i){h.above(e,{at:c,match:p=>q.isElement(p)&&p.type==="link"})||(B.wrapNodes(e,{type:"link",url:i,children:[]},{at:c,split:!0}),B.collapse(e,{edge:"end"}))}function f(){if(!e.selection||!ue.isCollapsed(e.selection))return;let c=h.above(e,{match:d=>q.isElement(d)&&d.type==="paragraph"});if(!c)return;let i=e.selection.anchor,r=h.string(e,{anchor:h.start(e,c[1]),focus:i}).match(/\S+$/)?.[0];if(!r||!re(r))return;let I=h.before(e,i,{distance:r.length,unit:"offset"});if(I){u({anchor:I,focus:i},r);let d=h.above(e,{match:s=>q.isElement(s)&&s.type==="link"});d&&e.selection&&h.isEnd(e,e.selection.anchor,d[1])&&B.select(e,h.start(e,_e.next(d[1])))}}return e.insertText=c=>{if(ve.isComposing(e)){o(c);return}c===" "&&f();let i={"*":"bold",_:"italic","~":"strikethrough","`":"code"}[c];if(i&&e.selection&&ue.isCollapsed(e.selection)){let p=h.above(e,{match:r=>q.isElement(r)&&r.type==="paragraph"});if(p){let r=e.selection.anchor,I=h.string(e,{anchor:h.start(e,p[1]),focus:r}),d=I.lastIndexOf(c),s=I.slice(d+1);if(d>=0&&(!d||/[\s*_~`]/.test(I[d-1]))&&s&&s.trim()===s){let m=h.before(e,r,{distance:s.length,unit:"offset"}),x=m&&h.before(e,m,{unit:"offset"});if(m&&x){B.select(e,{anchor:m,focus:r}),h.addMark(e,i,!0),B.collapse(e,{edge:"end"}),B.delete(e,{at:{anchor:x,focus:m}}),h.removeMark(e,i);return}}}}o(c)},e.insertBreak=()=>{f(),l()},e.insertData=c=>{let i=c.getData("text/plain");re(i)?e.selection&&!ue.isCollapsed(e.selection)?u(e.selection,i):B.insertNodes(e,[{type:"link",url:i,children:[{text:i}]},{text:""}]):t(c)},e}function oa({attributes:e,children:a,element:o}){return o.type==="link"?S("a",{...e,href:re(o.url)?o.url:void 0,onClick:t=>t.preventDefault(),children:a}):S("p",{...e,children:a})}function ua({attributes:e,children:a,leaf:o}){let t=S(be,{children:a});return o.bold&&(t=S("strong",{children:t})),o.italic&&(t=S("em",{children:t})),o.strikethrough&&(t=S("s",{children:t})),o.code&&(t=S("code",{children:t})),S("span",{...e,children:t})}function J({onFiles:e,disabled:a}){let o=de(null);return Te(be,{children:[S("input",{ref:o,type:"file",accept:Fe,multiple:!0,hidden:!0,onChange:t=>{e(t.target.files),t.target.value=""}}),S("button",{type:"button",className:"review-retry-upload","aria-label":"Attach image or video",title:"Images up to 5 MB \xB7 Videos up to 20 MB",disabled:a,onClick:()=>o.current?.click(),children:S(E,{size:16,strokeWidth:1.75})})]})}function z({text:e,defaultBody:a,disabled:o,label:t,placeholder:l,autoFocus:u,onChange:f,onSubmit:c,onFiles:i,uploading:p}){let[r]=Je(Ue),I=de(le(a??A(e))),d=de(e);return Ze(()=>{if(e===d.current)return;let s=d.current;d.current=e,s&&e.startsWith(s)?B.insertText(r,e.slice(s.length),{at:h.end(r,[])}):(h.withoutNormalizing(r,()=>{B.removeNodes(r,{at:[],match:(m,x)=>x.length===1}),B.insertNodes(r,le(A(e)),{at:[0]}),B.deselect(r)}),e||(r.history={undos:[],redos:[]}))},[r,e]),Te(ea,{editor:r,initialValue:I.current,onChange:s=>{if(!r.operations.some(x=>x.type!=="set_selection"))return;let m=qe(s);d.current=ye(m),f(d.current,m)},children:[S(Ye,{className:"review-composer-editor",role:"textbox","aria-multiline":"true","aria-label":t,placeholder:l,readOnly:o,autoFocus:u,renderElement:oa,renderLeaf:ua,onKeyDown:s=>{if(s.nativeEvent.isComposing)return;let m=s.metaKey||s.ctrlKey;if(s.key==="Enter"){s.preventDefault(),m?r.insertBreak():c();return}let x=m?{b:"bold",i:"italic",e:"code",...s.shiftKey?{s:"strikethrough"}:{}}[s.key.toLowerCase()]:void 0;x&&(s.preventDefault(),ta(r,x))}}),i&&S("div",{className:"chisel-attachment-controls",children:S(J,{onFiles:i,disabled:o||p})})]})}import{jsx as k,jsxs as Q,Fragment as Oe}from"react/jsx-runtime";import{useEffect as da,useRef as la,useState as ra}from"react";function sa({src:e,name:a,mimeType:o,onError:t,close:l}){let u=la(null);return da(()=>{u.current?.showModal()},[]),k("dialog",{ref:u,className:"review-media-lightbox","aria-label":`Preview ${a}`,onCancel:f=>{f.preventDefault(),l()},onClick:f=>{f.target===f.currentTarget&&l()},children:Q("div",{className:"review-media-lightbox-content",children:[Q("header",{children:[k("span",{children:a}),k("a",{href:e,download:a,"aria-label":`Download ${a}`,children:"Download"}),k("button",{type:"button","aria-label":"Close preview",onClick:l,children:k(T,{size:20})})]}),o.startsWith("image/")?k("img",{src:e,alt:a,onError:t}):k("video",{src:e,controls:!0,autoPlay:!0,playsInline:!0,"aria-label":a,onError:t})]})})}function j({src:e,name:a,mimeType:o,onError:t}){let[l,u]=ra(!1);return Q(Oe,{children:[k("button",{type:"button",className:"review-media-thumbnail","aria-label":`Preview ${a}`,onClick:()=>u(!0),children:o.startsWith("image/")?k("img",{src:e,alt:a,loading:"lazy",onError:t}):Q(Oe,{children:[k("video",{src:e,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true",onError:t}),k("span",{className:"review-media-play","aria-hidden":"true",children:k(W,{size:20,fill:"currentColor"})})]})}),l&&k(sa,{src:e,name:a,mimeType:o,onError:t,close:()=>u(!1)})]})}function He({body:e}){return n("div",{className:"review-comment-body",children:e.content.map((a,o)=>n("p",{children:a.children.map((t,l)=>{if("type"in t&&t.type==="link")return n("a",{href:/^(https?:|mailto:)/i.test(t.url)?t.url:void 0,target:"_blank",rel:"noopener noreferrer",children:t.text||t.url},l);if(!("text"in t))return null;let u=n(fa,{children:t.text});return"bold"in t&&t.bold&&(u=n("strong",{children:u})),"italic"in t&&t.italic&&(u=n("em",{children:u})),"strikethrough"in t&&t.strikethrough&&(u=n("s",{children:u})),"code"in t&&t.code&&(u=n("code",{children:u})),n("span",{children:u},l)})},o))})}function ia({attachment:e,loadMedia:a}){let[o,t]=N(e.previewUrl??""),[l,u]=N(!1),[f,c]=N(0),i=D(0);U(()=>{if(e.previewUrl){t(e.previewUrl);return}t("");let r=!0,I=!1,d=new AbortController;async function s(){if(!(I||document.visibilityState==="hidden")){I=!0;try{let C=await a(e.id,d.signal);r&&(t(C),u(!1),i.current=Date.now()+240*1e3)}catch{r&&u(!0)}finally{I=!1}}}function m(){Date.now()>=i.current&&s()}s();let x=window.setInterval(m,60*1e3);return window.addEventListener("focus",m),document.addEventListener("visibilitychange",m),()=>{r=!1,d.abort(),window.clearInterval(x),window.removeEventListener("focus",m),document.removeEventListener("visibilitychange",m)}},[e.id,e.previewUrl,f,a]);function p(){u(!0),Date.now()>=i.current&&c(r=>r+1)}return M("figure",{className:"review-attachment",children:[o&&!l?n(j,{src:o,name:e.name,mimeType:e.mimeType,onError:p}):n("div",{className:"review-attachment-placeholder",role:"status",children:l?n("button",{type:"button",className:"review-retry-upload",onClick:()=>c(r=>r+1),children:"Retry attachment"}):"Loading attachment\u2026"}),n("figcaption",{children:e.name})]})}function ca(e){let a=Math.max(0,Math.floor((Date.now()-Date.parse(e))/6e4));return a<1?"Just now":a<60?`${a}m`:a<1440?`${Math.floor(a/60)}h`:new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function na({comment:e,activity:a,loadMedia:o,editable:t,editing:l,saving:u,onStartEdit:f,onCancelEdit:c,onSaveEdit:i,onDraftChange:p,onEditStyles:r}){let[I,d]=N(e.text),s=D(e.body??A(e.text)),m=D(!1);U(()=>{l||(d(e.text),s.current=e.body??A(e.text))},[l,e.text,e.body]);async function x(){if(!(u||m.current||!I.trim()&&!e.attachments?.length)){m.current=!0;try{await i(I.trimEnd(),K(s.current))&&p(!1)}finally{m.current=!1}}}return M("article",{className:"review-comment","data-activity":a,children:[n("span",{className:"review-comment-avatar",children:e.authorImage?n("img",{src:e.authorImage,alt:""}):e.author.slice(0,1).toUpperCase()}),M("div",{className:"review-comment-content",children:[M("header",{className:"review-comment-header",children:[n("span",{className:"review-comment-author",children:e.author}),e.pending?n("span",{className:"review-comment-time",role:"status",children:"Sending\u2026"}):n("time",{className:"review-comment-time",dateTime:e.date,title:new Date(e.date).toLocaleString(),children:ca(e.date)}),t&&!l&&n("button",{type:"button",className:"review-comment-edit","aria-label":"Edit comment",title:"Edit comment",disabled:u,onClick:f,children:n(G,{size:16})})]}),l?M("form",{className:"review-inline-edit",onSubmit:C=>{C.preventDefault(),x()},children:[n(z,{text:I,defaultBody:s.current,disabled:u,label:"Edit comment",placeholder:"Edit comment\u2026",autoFocus:!0,onSubmit:()=>{x()},onChange:(C,F)=>{d(C),s.current=F,p(C!==e.text||JSON.stringify(F)!==JSON.stringify(e.body??A(e.text)))}}),M("div",{className:"review-inline-edit-actions",children:[r&&n("button",{type:"button",disabled:u,onClick:r,children:"Edit styles"}),n("button",{type:"button",disabled:u,onClick:c,children:"Cancel"}),n("button",{type:"submit",disabled:u||!I.trim()&&!e.attachments?.length,children:"Save"})]})]}):n(He,{body:e.body??A(e.text)}),e.attachments?.length>0&&n("div",{className:"review-attachments",children:e.attachments.map(C=>n(ia,{attachment:C,loadMedia:o},C.id))})]})]})}function pa(e){let a=e.useAttachments(e.disabled,e.existingAttachments?.length??0),o=D(e.defaultBody??A(e.text)),t=D(!1);U(()=>(e.onAttachmentDraftChange?.(a.uploading||a.attachments.length>0),()=>e.onAttachmentDraftChange?.(!1)),[a.uploading,a.attachments.length,e.onAttachmentDraftChange]);async function l(){if(!(e.disabled||a.blocked||t.current||!e.text.trim()&&!a.attachments.length&&!e.existingAttachments?.length)){t.current=!0;try{await e.onSubmit(e.text.trimEnd(),K(o.current),a.tokens,a.previews)&&a.clear()}finally{t.current=!1}}}return n("form",{className:"review-composer chisel-review-composer","aria-label":e.commentId?"Edit comment":"New comment",onSubmit:u=>{u.preventDefault(),l()},onPasteCapture:u=>{u.clipboardData.files.length&&(u.preventDefault(),u.stopPropagation(),a.upload(u.clipboardData.files))},onDragOver:u=>{u.dataTransfer.types.includes("Files")&&u.preventDefault()},onDropCapture:u=>{u.dataTransfer.files.length&&(u.preventDefault(),u.stopPropagation(),a.upload(u.dataTransfer.files))},children:e.renderContent(M("div",{className:"chisel-composer-input",children:[n(z,{text:e.text,defaultBody:e.defaultBody,disabled:e.disabled,label:"Comment",placeholder:"Leave a comment\u2026",autoFocus:!0,onSubmit:()=>{l()},onChange:(u,f)=>{o.current=f,e.onText(u)}}),a.previewsUI,a.controls]}),a.attachments.length>0||!!e.existingAttachments?.length,a.blocked,n(J,{onFiles:a.upload,disabled:e.disabled||a.uploading}))})}function ma(e){let a=e.useAttachments(e.saving),o=D(A(e.reply)),t=D(!1);U(()=>(e.onAttachmentDraftChange?.(a.uploading||a.attachments.length>0),()=>e.onAttachmentDraftChange?.(!1)),[a.uploading,a.attachments.length,e.onAttachmentDraftChange]);async function l(){if(!(e.saving||a.blocked||t.current||!e.reply.trim()&&!a.attachments.length)){t.current=!0;try{await e.onReply(e.reply.trimEnd(),K(o.current),a.tokens,a.previews)&&(o.current=A(""),a.clear())}finally{t.current=!1}}}return M("form",{className:"review-composer chisel-review-reply","aria-label":"Reply to thread",hidden:e.submittingReply,onSubmit:u=>{u.preventDefault(),l()},onPasteCapture:u=>{u.clipboardData.files.length&&(u.preventDefault(),u.stopPropagation(),a.upload(u.clipboardData.files))},onDragOver:u=>{u.dataTransfer.types.includes("Files")&&u.preventDefault()},onDropCapture:u=>{u.dataTransfer.files.length&&(u.preventDefault(),u.stopPropagation(),a.upload(u.dataTransfer.files))},children:[n("span",{className:"feedback-avatar feedback-reply-avatar",children:e.replyAuthor?.image?n("img",{src:e.replyAuthor.image,alt:""}):(e.replyAuthor?.name||"You").slice(0,1).toUpperCase()}),M("div",{className:"chisel-reply-field",children:[n(z,{text:e.reply,disabled:e.saving,label:"Reply",placeholder:"Write a reply\u2026",onFiles:a.upload,uploading:a.uploading,onSubmit:()=>{l()},onChange:(u,f)=>{o.current=f,e.onReplyText(u)}}),a.previewsUI,a.controls,n("button",{type:"submit",className:"chisel-reply-submit","aria-label":"Reply",disabled:e.saving||a.blocked||!e.reply.trim()&&!a.attachments.length,children:n(H,{size:16,strokeWidth:1.75})})]})]})}function La(e){let a=e.comment,[o,t]=N(null),l=D(!1),u=D(e.onEditDraftChange);u.current=e.onEditDraftChange,U(()=>()=>{u.current?.(!1)},[]);function f(d){l.current=d,e.onEditDraftChange?.(d)}async function c(d){d&&e.onBeginEdit&&!await e.onBeginEdit()||!d&&l.current&&e.onDiscardEdit&&!await e.onDiscardEdit()||(f(!1),t(d))}function i(d,s){return n(na,{comment:d,activity:s?a.rootActivity:d.activity,loadMedia:e.loadMedia,editable:!!(e.expanded&&e.onEdit&&e.userId&&d.authorId===e.userId&&!d.pending),editing:o===d.id,saving:e.saving,onEditStyles:s?e.onEditStyles:void 0,onStartEdit:()=>{c(d.id)},onCancelEdit:()=>{c(null)},onDraftChange:f,onSaveEdit:async(m,x)=>{let C=await e.onEdit?.(s?null:d.id,m,x);return C&&(f(!1),t(null)),!!C}},d.id)}let p=D(null),r=D(new Set),I=D(a.readActivity??0);return U(()=>{if(!e.expanded||!p.current||a.pending||a.readActivity===null)return;let d=[a.rootActivity,...a.replies.map(x=>x.activity)],s=new IntersectionObserver(x=>{if(document.visibilityState!=="visible")return;for(let F of x)F.isIntersecting&&F.intersectionRatio>0&&r.current.add(Number(F.target.dataset.activity));let C=oe(Math.max(I.current,a.readActivity??0),d,r.current);C>I.current&&(I.current=C,e.onRead(a.id,C))},{threshold:0});function m(){if(s.disconnect(),document.visibilityState==="visible")for(let x of p.current?.querySelectorAll("[data-activity]")??[])s.observe(x)}return m(),document.addEventListener("visibilitychange",m),()=>{s.disconnect(),document.removeEventListener("visibilitychange",m)}},[a,e.expanded,e.onRead]),M("div",{className:"chisel-review-thread-content",children:[M("div",{ref:p,className:"review-thread",children:[i(a,!0),e.expanded&&a.replies.map(d=>i(d,!1))]}),e.expanded?!o&&n(ma,{...e}):n("button",{type:"button",className:"chisel-expand-thread",onClick:e.onExpand,children:a.replies.length?`${a.replies.length} ${a.replies.length===1?"reply":"replies"}`:"Reply\u2026"})]})}import{useCallback as Ee,useRef as Ge}from"react";function Ia(e,a){let o=Ge(new Map),t=Ge(!1),l=Ee(async()=>{if(!t.current){t.current=!0;try{for(;o.current.size;){let[f,c]=o.current.entries().next().value;try{await e(f,c)}catch(i){if([400,403,404].includes(i.status??0)){o.current.delete(f);continue}throw i}o.current.get(f)===c&&o.current.delete(f),a(f,c)}}catch{}finally{t.current=!1}}},[e,a]),u=Ee((f,c)=>{o.current.set(f,Math.max(c,o.current.get(f)??0)),l()},[l]);return{flush:l,markDisplayed:u}}import{jsx as b,jsxs as se}from"react/jsx-runtime";import{useEffect as xa,useRef as fe,useState as ie}from"react";function Ca(e=!1,a=0,o){let[t,l]=ie([]),[u,f]=ie(!1),[c,i]=ie(""),p=fe(!0),r=fe(!1),I=fe(new Map),d=L=>o.discard(L);xa(()=>(p.current=!0,()=>{p.current=!1;for(let L of I.current.values())URL.revokeObjectURL(L.preview),d(L).catch(()=>{})}),[]);function s(){p.current&&l([...I.current.values()].map(L=>({...L})))}function m(){for(let L of I.current.values())URL.revokeObjectURL(L.preview);I.current.clear(),p.current&&(l([]),i(""))}async function x(L){let g=I.current.get(L);if(!(!g||r.current||e)){r.current=!0,f(!0);try{await d(g),I.current.delete(L),URL.revokeObjectURL(g.preview),s(),i("")}catch(y){p.current&&i(y instanceof Error?y.message:"The attachment could not be removed.")}finally{r.current=!1,p.current&&f(!1)}}}async function C(L){for(let g of L){if(!p.current)return;let y=g.status==="failed";g.status="uploading",s();try{g.token=await o.send(g,y,()=>p.current),g.status="ready"}catch(w){g.status="failed",p.current&&i(w instanceof Error?w.message:"The upload failed. Your comment is still here.")}finally{p.current||await d(g).catch(()=>{})}s()}}async function F(L){if(!L?.length||r.current||e)return;let g=Array.from(L),y=g.map(w=>Re(w)).find(Boolean);if(y){i(y);return}if(a+I.current.size+g.length>20){i("Attach up to 20 files per comment.");return}r.current=!0,f(!0),i("");try{let w=await o.userId();if(!w)throw new Error("Sign in again to attach files.");if(!p.current)return;let ee=g.map(v=>{let ae=crypto.randomUUID(),ce={id:ae,name:v.name,mimeType:v.type,size:v.size,file:v,bucket:Z.includes(v.type)?"chisel-review-images":"chisel-review-videos",path:`${w}/${ae}`,preview:URL.createObjectURL(v),stored:!1,status:"uploading"};return I.current.set(ae,ce),ce});s(),await C(ee)}catch(w){p.current&&i(w instanceof Error?w.message:"The upload failed. Your comment is still here.")}finally{r.current=!1,p.current&&f(!1)}}async function _(){if(!(r.current||e)){r.current=!0,f(!0),i("");try{await C([...I.current.values()].filter(L=>L.status==="failed"))}finally{r.current=!1,p.current&&f(!1)}}}let X=t.some(L=>L.status==="failed"),$=se("div",{className:"chisel-attachment-controls",children:[u&&b("span",{role:"status",children:"Uploading\u2026"}),X&&se("button",{type:"button",className:"review-retry-upload",disabled:u||e,onClick:()=>{_()},children:[b(V,{size:16,strokeWidth:1.75}),"Retry upload"]}),c&&b("span",{className:"chisel-attachment-error",role:"alert",children:c})]}),Y=t.length>0&&b("div",{className:"chisel-attachment-previews",children:t.map(L=>se("div",{className:"chisel-attachment-preview","data-state":L.status,children:[b(j,{src:L.preview,name:L.name,mimeType:L.mimeType}),b("span",{title:L.name,children:L.name}),b("button",{type:"button","aria-label":`Remove ${L.name}`,disabled:u||e,onClick:()=>{x(L.id)},children:b(T,{size:16,strokeWidth:1.75})})]},L.id))});return{attachments:t,uploading:u,blocked:u||X,controls:$,previewsUI:Y,clear:m,upload:F,previews:t.map(({id:L,name:g,mimeType:y,size:w,preview:ee})=>({id:L,name:g,mimeType:y,size:w,previewUrl:ee})),tokens:t.flatMap(L=>L.token?[L.token]:[])}}export{J as ReviewAttachmentButton,He as ReviewBody,pa as ReviewComposer,z as ReviewEditor,La as ReviewThread,le as bodyToEditor,Ue as createReviewEditor,oe as displayedActivity,qe as editorToBody,Ia as useReadQueue,Ca as useReviewAttachments};
4
+ /*! Bundled license information:
5
+
6
+ lucide-react/dist/esm/shared/src/utils/toKebabCase.mjs:
7
+ lucide-react/dist/esm/shared/src/utils/toLucideIconData.mjs:
8
+ lucide-react/dist/esm/shared/src/utils/toCamelCase.mjs:
9
+ lucide-react/dist/esm/shared/src/utils/toPascalCase.mjs:
10
+ lucide-react/dist/esm/shared/src/utils/mergeClasses.mjs:
11
+ lucide-react/dist/esm/shared/src/build/defaultAttributes.mjs:
12
+ lucide-react/dist/esm/shared/src/build/buildLucideIconNode.mjs:
13
+ lucide-react/dist/esm/shared/src/build/buildLucideIconForReact.mjs:
14
+ lucide-react/dist/esm/shared/src/utils/hasA11yProp.mjs:
15
+ lucide-react/dist/esm/context.mjs:
16
+ lucide-react/dist/esm/Icon.mjs:
17
+ lucide-react/dist/esm/createLucideIcon.mjs:
18
+ lucide-react/dist/esm/icons/arrow-up.mjs:
19
+ lucide-react/dist/esm/icons/paperclip.mjs:
20
+ lucide-react/dist/esm/icons/pencil.mjs:
21
+ lucide-react/dist/esm/icons/play.mjs:
22
+ lucide-react/dist/esm/icons/rotate-cw.mjs:
23
+ lucide-react/dist/esm/icons/x.mjs:
24
+ lucide-react/dist/esm/lucide-react.mjs:
25
+ (**
26
+ * @license lucide-react v1.61.0 - ISC
27
+ *
28
+ * This source code is licensed under the ISC license.
29
+ * See the LICENSE file in the root directory of this source tree.
30
+ *)
31
+ */
@@ -52,6 +52,12 @@ export type CommentMutation = {
52
52
  changes: StyleChange[];
53
53
  body?: unknown;
54
54
  attachmentTokens?: string[];
55
+ } | {
56
+ type: "edit_reply";
57
+ id: string;
58
+ replyId: string;
59
+ text: string;
60
+ body?: unknown;
55
61
  } | {
56
62
  type: "reply";
57
63
  id: string;
@@ -26,6 +26,12 @@ export type WorkspaceThreadProps = {
26
26
  saving: boolean;
27
27
  canResolve: boolean;
28
28
  submittingReply?: boolean;
29
+ userId?: string;
30
+ onEdit?(replyId: string | null, text: string, body: unknown): Promise<boolean>;
31
+ onEditDraftChange?(hasDraft: boolean): void;
32
+ onDiscardEdit?(): Promise<boolean>;
33
+ onBeginEdit?(): Promise<boolean>;
34
+ onEditStyles?(): void;
29
35
  onReplyText(text: string): void;
30
36
  onReply(text: string, body?: unknown, attachmentTokens?: string[], attachments?: WorkspaceAttachment[]): Promise<boolean>;
31
37
  onResolve(): void;
@@ -1,4 +1,4 @@
1
- "use client";import{jsx as u,jsxs as x,Fragment as sa}from"react/jsx-runtime";import{useEffect as Se,useLayoutEffect as Da,useRef as z,useState as T}from"react";import{forwardRef as bo,createElement as ko}from"react";var lt=a=>a?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function ut(a,t,r=[]){if(t==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:lt(a),size:24,node:t,...r.length>0?{aliases:r}:{}}}var st=a=>{let t="",r=!1;for(let o of a){if(o==="-"||o==="_"||o<=" "){r=t.length>0;continue}t.length===0?t+=o.toLowerCase():t+=r?o.toUpperCase():o,r=!1}return t};var it=a=>{let t=st(a);return t.charAt(0).toUpperCase()+t.slice(1)};import{forwardRef as Co,createElement as mt}from"react";var Ge=(...a)=>a.filter((t,r,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===r).join(" ").trim();var Ie={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function Ua(a){return a!=null}function ft(a,t={}){let r=t.attributeNames??{},o=b=>r[b]??b,l=a.size??a.width??Ie.width,f=a.size??a.height??Ie.height,s=a.aliases?.filter(b=>typeof b=="string"&&b.trim()!=="").map(b=>`lucide-${b}`)??[],p=[...a.name?[`lucide-${a.name}`]:[],...s],L=t.className?.split(" ").filter(Boolean)??[],S=t.includeDefaultClasses===!1?Ge(...L):Ge("lucide",...p,...L),k=t.absoluteStrokeWidth?Number(t.strokeWidth??Ie["stroke-width"])*Number(a.size??a.width??Ie.width)/Number(t.size??t.width??Ie.width):t.strokeWidth??Ie["stroke-width"];return["svg",{...Object.entries(Ie).reduce((b,[g,M])=>(b[o(g)]=M,b),{}),..."color"in t&&t.color&&{[o("stroke")]:t.color},..."size"in t&&Ua(t.size)&&{[o("width")]:t.size,[o("height")]:t.size},..."width"in t&&Ua(t.width)&&{[o("width")]:t.width},..."height"in t&&Ua(t.height)&&{[o("height")]:t.height},[o("stroke-width")]:k,...S&&{[o("class")]:S},[o("viewBox")]:`0 0 ${l} ${f}`,...t.hasA11yProp===!1?{[o("aria-hidden")]:"true"}:{},..."attributes"in t&&t.attributes},a.node.map(b=>{let[g,M,F]=b,G=t.nonScalingStroke?{[o("vector-effect")]:"non-scaling-stroke",...M}:M;return F?[g,G,F]:[g,G]})]}function nt(a,t={}){return ft(a,{...t,attributeNames:{...t.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}var ct=a=>{for(let t in a)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};import{createContext as Lo,useContext as go,useMemo as or,createElement as rr}from"react";var Io=Lo({});var pt=()=>go(Io);var ht=Co(({color:a,size:t,width:r,height:o,strokeWidth:l,absoluteStrokeWidth:f,nonScalingStroke:s,className:p="",children:L,iconNode:S=[],icon:k={node:S,aliases:[],size:24},...w},b)=>{let{size:g=24,strokeWidth:M=2,absoluteStrokeWidth:F=!1,nonScalingStroke:G=!1,color:V="currentColor",className:J=""}=pt()??{},D=!!L||ct(w),[H,i,m=[]]=nt(k,{color:a??V,width:r??t??g,height:o??t??g,strokeWidth:l??M,absoluteStrokeWidth:f??F,nonScalingStroke:s??G,className:Ge(J,p),hasA11yProp:D,attributes:w});return mt(H,{ref:b,...i},[...m.map(([W,q])=>mt(W,q)),...Array.isArray(L)?L:[L]])});function I(a,t=[],r=[]){let o=typeof a=="string"?ut(a,t,r):a,l=bo(({className:f,...s},p)=>ko(ht,{ref:p,icon:o,className:f,...s}));return o.name&&(l.displayName=it(o.name)),l}var xt={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};xt.node;var We=I(xt);var Lt={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};Lt.node;var Ve=I(Lt);var gt={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};gt.node;var Pe=I(gt);var It={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};It.node;var Xe=I(It);var Ct={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};Ct.node;var Ae=I(Ct);var bt={name:"circle-check",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 9-5.5 5.5L8 12",key:"xofnsj"}]],aliases:["check-circle-2"]};bt.node;var Ce=I(bt);var kt={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"}]]};kt.node;var Ke=I(kt);var St={name:"globe",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]};St.node;var $e=I(St);var wt={name:"grip-horizontal",size:24,node:[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]};wt.node;var Ze=I(wt);var yt={name:"link-2",size:24,node:[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]};yt.node;var je=I(yt);var vt={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};vt.node;var be=I(vt);var Pt={name:"log-out",size:24,node:[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]};Pt.node;var _e=I(Pt);var At={name:"message-circle",size:24,node:[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]]};At.node;var Ue=I(At);var Dt={name:"mouse-pointer-2",size:24,node:[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]};Dt.node;var Je=I(Dt);var Bt={name:"pencil",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]};Bt.node;var Qe=I(Bt);var Mt={name:"pipette",size:24,node:[["path",{d:"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12",key:"1y3wsu"}],["path",{d:"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z",key:"110lr1"}],["path",{d:"m2 22 .414-.414",key:"jhxm08"}]]};Mt.node;var Ye=I(Mt);var Ft={name:"rotate-ccw",size:24,node:[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]};Ft.node;var ea=I(Ft);var Rt={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};Rt.node;var aa=I(Rt);var Tt={name:"sliders-horizontal",size:24,node:[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]};Tt.node;var De=I(Tt);var qt={name:"trash",size:24,node:[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],aliases:["trash-2"]};qt.node;var ke=I(qt);var Ut={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};Ut.node;var ta=I(Ut);import{jsx as B,jsxs as _,Fragment as vo}from"react/jsx-runtime";import{useEffect as Wt,useId as Po,useState as he}from"react";import{jsx as se,jsxs as oa}from"react/jsx-runtime";import{useEffect as So,useRef as Ot,useState as He}from"react";import{createPortal as wo}from"react-dom";function Ht(a,t,r,o=1){a/=255,t/=255,r/=255;let l=Math.max(a,t,r),f=Math.min(a,t,r),s=l-f;return{h:(s?l===a?((t-r)/s+6)%6:l===t?(r-a)/s+2:(a-t)/s+4:0)*60,s:l?s/l:0,v:l,a:o}}function Ca({h:a,s:t,v:r,a:o}){let l=f=>{let s=(f+a/60)%6;return Math.round(255*r*(1-t*Math.max(0,Math.min(s,4-s,1)))).toString(16).padStart(2,"0")};return`#${l(5)}${l(3)}${l(1)}${o<1?Math.round(o*255).toString(16).padStart(2,"0"):""}`}function ba(a){if(typeof document<"u"){let t=document.createElement("canvas");t.width=t.height=1;let r=t.getContext("2d");if(r){r.fillStyle=a,r.fillRect(0,0,1,1);let[o,l,f,s]=r.getImageData(0,0,1,1).data;return Ht(o,l,f,s/255)}}return Ht(0,0,0)}function Ha({label:a,value:t,onChange:r,disabled:o}){let l=Ot(null),f=Ot(null),[s,p]=He(null),[L,S]=He({h:0,s:0,v:0,a:1}),[k,w]=He(""),[b,g]=He(!1),[M,F]=He(!1),[G,V]=He(!1);function J(){p(null)}So(()=>{if(!s)return;let i=O=>{!f.current?.contains(O.target)&&!l.current?.contains(O.target)&&J()},m=O=>{O.key==="Escape"&&(O.preventDefault(),O.stopPropagation(),J(),l.current?.focus())},W=l.current?.getBoundingClientRect(),q=O=>{if(f.current?.contains(O.target))return;let ae=l.current?.getBoundingClientRect();(ae?.top!==W?.top||ae?.left!==W?.left)&&J()};return document.addEventListener("pointerdown",i),document.addEventListener("keydown",m,!0),window.addEventListener("resize",J),document.addEventListener("scroll",q,!0),f.current?.querySelector("input")?.focus({preventScroll:!0}),()=>{document.removeEventListener("pointerdown",i),document.removeEventListener("keydown",m,!0),window.removeEventListener("resize",J),document.removeEventListener("scroll",q,!0)}},[s]);function D(i){i.a===0&&(i={...i,a:1}),S(i);let m=Ca(i);w(m.slice(1).toUpperCase()),g(!1),r(m)}function H(i){let m=i.currentTarget.getBoundingClientRect();D({...L,s:Math.max(0,Math.min(1,(i.clientX-m.left)/m.width)),v:1-Math.max(0,Math.min(1,(i.clientY-m.top)/m.height))})}return oa("div",{className:"comment-box-color",children:[se("button",{ref:l,className:"comment-color-trigger",type:"button","aria-label":`${a} picker`,"aria-haspopup":"dialog","aria-expanded":!!s,disabled:o,onClick:()=>{if(s){J();return}let i=ba(t);S(i),w(Ca(i).slice(1).toUpperCase()),g(!1),F("EyeDropper"in window);let m=l.current.getBoundingClientRect();p({left:Math.max(8,Math.min(m.right-256,window.innerWidth-264)),top:Math.max(8,Math.min(m.bottom+8,window.innerHeight-330))})},children:se("span",{style:{background:t}})}),se("span",{className:"comment-color-value",title:t,children:t}),s&&wo(oa("div",{ref:f,className:"chisel-color-picker",role:"dialog","aria-label":`${a} color picker`,style:s,onKeyDown:i=>{if(i.key!=="Tab")return;let m=Array.from(f.current.querySelectorAll("button:not(:disabled), input:not(:disabled)"));i.shiftKey&&document.activeElement===m[0]?(i.preventDefault(),m[m.length-1]?.focus()):!i.shiftKey&&document.activeElement===m[m.length-1]&&(i.preventDefault(),m[0]?.focus())},children:[oa("div",{className:"chisel-color-plane",style:{backgroundColor:`hsl(${L.h} 100% 50%)`},onPointerDown:i=>{i.currentTarget.setPointerCapture(i.pointerId),H(i)},onPointerMove:i=>{i.currentTarget.hasPointerCapture(i.pointerId)&&H(i)},children:[se("span",{className:"chisel-color-thumb",style:{left:`${L.s*100}%`,top:`${(1-L.v)*100}%`,background:Ca({...L,a:1})}}),se("input",{className:"chisel-color-accessible",type:"range","aria-label":`${a} saturation`,min:0,max:100,value:Math.round(L.s*100),onChange:i=>D({...L,s:Number(i.target.value)/100})}),se("input",{className:"chisel-color-accessible",type:"range","aria-label":`${a} brightness`,min:0,max:100,value:Math.round(L.v*100),onChange:i=>D({...L,v:Number(i.target.value)/100})})]}),oa("div",{className:"chisel-color-tools",children:[se("input",{className:"chisel-color-hue",type:"range","aria-label":`${a} hue`,min:0,max:360,value:Math.round(L.h),style:{"--hue":`hsl(${L.h} 100% 50%)`},onChange:i=>D({...L,h:Number(i.target.value)})}),se("button",{type:"button","aria-label":`Pick ${a.toLowerCase()} from screen`,title:M?"Pick a color from the screen":"Screen color picker is not supported in this browser",disabled:!M||G,onClick:async()=>{let i=window.EyeDropper;if(i){V(!0);try{let m=await new i().open();f.current&&D(ba(m.sRGBHex))}catch{}finally{V(!1)}}},children:se(Ye,{size:18})})]}),oa("label",{className:"chisel-color-hex",children:["HEX",se("input",{"aria-label":`${a} hex`,value:k,maxLength:9,spellCheck:!1,"aria-invalid":b,onChange:i=>{let m=i.target.value.replace(/^#/,"");w(m);let W=/^(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(m);if(g(!W),W){let q=ba(`#${m}`);S(q),r(`#${m}`)}}})]}),b&&se("span",{className:"chisel-color-error",role:"status",children:"Enter a valid hex color."})]}),document.body)]})}import{jsx as Et}from"react/jsx-runtime";import{useRef as yo}from"react";function ra({onMoveStart:a}){let t=yo(null);function r(o,l,f){let s=o.closest(".comment-box,.comment-thread"),p=s?.closest(".feedback-viewport");if(!s||!p)return;let L=p.getBoundingClientRect(),S=s.getBoundingClientRect();for(let[k,w]of[["x",Math.max(L.left+8-S.left,Math.min(l,L.right-8-S.right))],["y",Math.max(L.top+8-S.top,Math.min(f,L.bottom-8-S.bottom))]]){let b=`--comment-drag-${k}`;s.style.setProperty(b,`${(parseFloat(s.style.getPropertyValue(b))||0)+w}px`)}}return Et("button",{type:"button",className:"comment-window-drag","aria-label":"Move comment window",title:"Drag to move \xB7 Arrow keys to nudge",onPointerDown:o=>{!o.isPrimary||o.button!==0||(o.preventDefault(),a?.(),o.currentTarget.closest(".comment-box,.comment-thread")?.getAnimations().forEach(l=>l.cancel()),o.currentTarget.setPointerCapture(o.pointerId),t.current={id:o.pointerId,x:o.clientX,y:o.clientY},o.currentTarget.dataset.dragging="true")},onPointerMove:o=>{let l=t.current;!l||l.id!==o.pointerId||(r(o.currentTarget,o.clientX-l.x,o.clientY-l.y),l.x=o.clientX,l.y=o.clientY)},onPointerUp:o=>{o.currentTarget.hasPointerCapture(o.pointerId)&&o.currentTarget.releasePointerCapture(o.pointerId)},onLostPointerCapture:o=>{t.current=null,delete o.currentTarget.dataset.dragging},onKeyDown:o=>{let l={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[o.key];if(!l)return;o.preventDefault(),o.stopPropagation(),a?.();let f=o.shiftKey?40:10;r(o.currentTarget,l[0]*f,l[1]*f)},children:Et(Ze,{size:16,"aria-hidden":"true"})})}function zt(a,t,r,o){let l={[a]:t},f=r.find(s=>s!==a);if(!f||!r.includes(a))return l;if(r.includes("width")){let s=parseFloat(o.width)/parseFloat(o.height),p=parseFloat(t);if(!Number.isFinite(s)||s<=0||!Number.isFinite(p))return l;l[f]=`${a==="width"?p/s:p*s}px`}else l[f]=t;return l}var Nt=new Set(["color","background-color","opacity","font-family","font-size","font-weight","border-color","border-width","width","height",...["padding","margin"].flatMap(a=>["top","right","bottom","left"].map(t=>`${a}-${t}`))]);function Gt(a,t){let r={...a},o={...a};for(let l of Array.isArray(t)?t:[])!l||!Object.prototype.hasOwnProperty.call(a,l.property)||typeof l.before!="string"||typeof l.after!="string"||l.property!=="text"&&(!Nt.has(l.property)||!CSS.supports(l.property,l.after))||(r[l.property]=l.before,o[l.property]=l.after);return{initial:r,values:o}}function ka(a,t){if(!Array.isArray(t))return()=>{};let r=a.style,o=a.getAttribute("style"),l=a.textContent,f=!1;for(let p of t)!p||typeof p.after!="string"||(p.property==="text"&&!a.children.length?(a.textContent=p.after,f=!0):r&&Nt.has(p.property)&&CSS.supports(p.property,p.after)&&r.setProperty(p.property,p.after,"important"));let s=!1;return()=>{s||(s=!0,o===null?a.removeAttribute("style"):a.setAttribute("style",o),f&&!a.children.length&&(a.textContent=l))}}var Xt=[["Text color","color","color"],["Background","background-color","color"],["Opacity","opacity","number"],["Font","font-family","font"],["Font size","font-size","number"],["Font weight","font-weight","weight"],["Border color","border-color","color"],["Border width","border-width","number"]],Ao=["top","bottom","left","right"],Vt=[{label:"Size",pairs:[["width","height"]]},...["padding","margin"].map(a=>({label:a[0].toUpperCase()+a.slice(1),pairs:[[`${a}-top`,`${a}-bottom`],[`${a}-left`,`${a}-right`]]}))];function Do(a){let t=a.ownerDocument.defaultView.getComputedStyle(a);return Object.fromEntries([["text",a.children.length?"":a.textContent??""],...["width","height"].map(r=>[r,t.getPropertyValue(r)]),...Xt.map(([,r])=>[r,t.getPropertyValue(r)]),...["padding","margin"].flatMap(r=>Ao.map(o=>[`${r}-${o}`,t.getPropertyValue(`${r}-${o}`)]))])}function Oa({target:a,text:t,onText:r,onCancel:o,onPost:l,style:f,changes:s=[],editing:p=!1,commentId:L,renderComposer:S,hasExistingAttachments:k=!1,onDraftChange:w,hidden:b=!1}){let[g]=he(()=>Gt(Do(a),s)),M=g.initial,[F,G]=he(g.values),[V]=he(()=>({style:a.getAttribute("style"),text:a.textContent})),[J,D]=he({}),[H,i]=he(!1),[m]=he(t),[W,q]=he(!1),[ee,O]=he(""),[ae,xe]=he(!1),te=Po();function N(){V.style===null?a.removeAttribute("style"):a.setAttribute("style",V.style),a.children.length||a.replaceChildren(a.ownerDocument.createTextNode(V.text??""))}function we(){N(),o()}Wt(()=>(ka(a,s),N),[a,V]);function le(R,j){if(R==="text"){G(v=>({...v,text:j})),a.children.length||a.replaceChildren(a.ownerDocument.createTextNode(j));return}let X=Vt.flatMap(v=>v.pairs).find(v=>v.includes(R)&&J[v.join(":")]),re=X?zt(R,j,X,M):{[R]:j};G(v=>({...v,...re}));for(let[v,h]of Object.entries(re))CSS.supports(v,h)&&a.style.setProperty(v,h,"important")}let Me=Object.entries(F).some(([R,j])=>j!==M[R]),Z=!!(t.trim()||Me||W||p&&t!==m);Wt(()=>(w?.(Z),()=>w?.(!1)),[Z,w]);async function Oe(R=t,j,X,re){if(H||!R.trim()&&!X?.length&&!k)return!1;let v=Object.entries(F).filter(([h,y])=>y!==M[h]).map(([h,y])=>({property:h,before:M[h],after:y}));if(v.some(h=>h.property!=="text"&&!CSS.supports(h.property,h.after)))return O("Check the style values before posting."),!1;i(!0),O("");try{let h=await l(v,R.trimEnd(),j,X,re);return h?we():O("Could not post. Your changes are still here; please try again."),h}catch{return O("Could not post. Please try again."),!1}finally{i(!1)}}let Q=(R,j=!1,X=!1,re)=>_(vo,{children:[_("div",{className:"comment-box-prompt",children:[B("button",{type:"button",className:"comment-box-symbol","aria-label":"Comment settings",title:"Comment settings","aria-expanded":ae,"aria-controls":te,disabled:H,onClick:()=>xe(v=>!v),children:B(De,{})}),R]}),_("div",{className:"comment-box-settings",id:te,hidden:!ae,children:[_("div",{className:"comment-box-element",children:[_("code",{children:["<",a.tagName.toLowerCase(),">"]}),Me&&B("span",{className:"comment-box-preview-status",role:"status",children:"Unsaved preview"}),B(ra,{})]}),_("fieldset",{className:"comment-box-properties",disabled:H||!ae,children:[_("label",{className:"comment-box-row",children:[B("span",{children:"Text"}),B("input",{"aria-label":"Element text",value:F.text,disabled:!!a.children.length,title:a.children.length?"Select a text-only element to change its text":void 0,onChange:v=>le("text",v.target.value)})]}),["Typography","Appearance"].map(v=>_("div",{className:"comment-box-control-group",children:[B("h3",{children:v}),Xt.filter(([,h])=>v==="Typography"===["color","font-family","font-size","font-weight"].includes(h)).map(([h,y,ne])=>_("div",{className:"comment-box-row",children:[B("span",{children:h}),ne==="color"?ae&&B(Ha,{label:h,value:F[y],disabled:H,onChange:P=>le(y,P)}):ne==="font"?B("select",{"aria-label":h,value:F[y],onChange:P=>le(y,P.target.value),children:Array.from(new Set([M[y],"Arial, sans-serif","Georgia, serif","system-ui","monospace"])).map(P=>B("option",{value:P,children:P},P))}):ne==="weight"?B("select",{"aria-label":h,value:F[y],onChange:P=>le(y,P.target.value),children:Array.from(new Set([M[y],...[100,200,300,400,500,600,700,800,900].map(String)])).map(P=>B("option",{children:P},P))}):_("div",{className:"comment-box-number",children:[B("input",{type:"number","aria-label":h,value:Number.isFinite(parseFloat(F[y]))?parseFloat(F[y]):"",min:0,max:y==="opacity"?1:void 0,step:"any",onChange:P=>le(y,P.target.value+(y==="opacity"?"":"px"))}),y!=="opacity"&&B("span",{children:"px"})]})]},y))]},v)),Vt.map(v=>_("details",{className:"comment-box-group",open:!0,children:[_("summary",{children:[v.label,B(Ae,{size:12,"aria-hidden":"true"})]}),v.pairs.map(h=>{let y=h.join(":"),ne=v.label==="Size"?"Lock aspect ratio":`Link ${v.label.toLowerCase()} ${h[0].split("-")[1]} and ${h[1].split("-")[1]}`;return _("div",{className:"comment-box-pair",children:[B("button",{className:"comment-box-link",type:"button","aria-label":ne,title:ne,"aria-pressed":!!J[y],onClick:()=>D(P=>({...P,[y]:!P[y]})),children:B(je,{size:12})}),h.map(P=>{let ia=P.includes("-")?P.split("-")[1]:P;return _("label",{className:"comment-box-row",children:[B("span",{children:ia[0].toUpperCase()+ia.slice(1)}),_("span",{className:"comment-box-number",children:[B("input",{type:"number",step:"any",min:P.startsWith("margin-")?void 0:0,"aria-label":P.replace("-"," ").replace(/^width$/,"Width").replace(/^height$/,"Height"),value:Number.isFinite(parseFloat(F[P]))?parseFloat(F[P]):"",onChange:ue=>le(P,`${ue.target.value}px`)}),B("span",{children:"px"})]})]},P)})]},y)})]},v.label))]})]}),ee&&B("p",{className:"comment-box-error",role:"alert",children:ee}),_("footer",{className:"comment-box-footer",children:[B("button",{type:"button",className:"comment-box-cancel",onClick:we,disabled:H,children:"Cancel"}),B("span",{}),re,B("button",{type:"submit",className:"comment-box-submit","aria-label":p?"Save comment":"Post comment",title:p?"Save comment":"Post comment",disabled:H||X||!t.trim()&&!j&&!k,children:H?B("span",{className:"comment-box-saving"}):B(Pe,{})})]})]}),Ee=`comment-box${S?" comment-box-native":""}`,ye=R=>{R.key==="Escape"&&!H&&(R.preventDefault(),R.stopPropagation(),we())};return S?B("div",{className:Ee,hidden:b,"data-settings-open":ae,style:f,onKeyDown:ye,children:S({text:t,onText:r,disabled:H,commentId:L,onAttachmentDraftChange:q,onSubmit:Oe,renderContent:Q})}):B("form",{className:Ee,hidden:b,"data-settings-open":ae,style:f,"aria-label":p?"Edit comment":"New comment",onKeyDown:ye,onSubmit:R=>{R.preventDefault(),Oe()},children:Q(B("input",{"aria-label":"Comment",placeholder:"Leave a comment\u2026",value:t,onChange:R=>r(R.target.value),autoFocus:!0,maxLength:4e3,required:!0,disabled:H}))})}import{jsx as fe,jsxs as da}from"react/jsx-runtime";import{useEffect as Bo,useLayoutEffect as Mo,useRef as Sa,useState as wa}from"react";function Be(a,t,r="/"){if(!a.trim())return null;try{let o=new URL(a.trim(),new URL(r,t)),l=decodeURIComponent(o.pathname);return!/^https?:$/.test(o.protocol)||o.origin!==t||o.username||o.password||/^\/(chisel|feedback)(\/|$)/.test(l)?null:o.pathname+o.search+o.hash}catch{return null}}function Ea(a){return a.split(/[?#]/,1)[0]}function za(a){try{let{pathname:t,search:r,hash:o}=a.location;return t.startsWith("/")?t+r+o:null}catch{return null}}function Kt(a,t){let r;try{r=a.history}catch{return()=>{}}let o=r.pushState,l=r.replaceState,f=!0,s=()=>{let S=za(a);f&&S!==null&&t(S)},p=function(...S){o.apply(this,S),s()},L=function(...S){l.apply(this,S),s()};return r.pushState=p,r.replaceState=L,a.addEventListener("popstate",s),a.addEventListener("hashchange",s),s(),()=>{f=!1,r.pushState===p&&(r.pushState=o),r.replaceState===L&&(r.replaceState=l),a.removeEventListener("popstate",s),a.removeEventListener("hashchange",s)}}function Na({path:a,routes:t,disabled:r,onNavigate:o,onOpen:l}){let f=Sa(null),s=Sa(null),p=Sa(null),L=Sa(!1),[S,k]=wa(!1),[w,b]=wa(a),[g,M]=wa(!1),[F,G]=wa(""),V=Ea(a),J=[...new Set([a,...t].map(Ea))];function D(i=!1){f.current&&(f.current.open=!1),k(!1),i&&s.current?.focus({preventScroll:!0})}Mo(()=>{if(!S)return;let i=()=>{let m=f.current,W=m?.closest(".feedback-sidebar-panel");m&&W&&m.style.setProperty("--feedback-page-space",`${Math.max(0,m.getBoundingClientRect().top-W.getBoundingClientRect().top-12)}px`)};return i(),p.current?.focus(),p.current?.select(),window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[S]),Bo(()=>{if(!S)return;let i=q=>{!L.current&&!f.current?.contains(q.target)&&D()},m=q=>{q.key!=="Escape"||L.current||(q.preventDefault(),q.stopPropagation(),D(!0))},W=()=>{L.current||D()};return document.addEventListener("pointerdown",i),document.addEventListener("keydown",m,!0),window.addEventListener("blur",W),()=>{document.removeEventListener("pointerdown",i),document.removeEventListener("keydown",m,!0),window.removeEventListener("blur",W)}},[S]);async function H(i){if(!(r||L.current)){L.current=!0,M(!0),G("");try{await o(i)&&D(!0)}catch(m){G(m instanceof Error&&m.message?m.message:"This page could not be opened. Try again.")}finally{L.current=!1,M(!1)}}}return da("details",{ref:f,className:"feedback-page-control",onToggle:i=>k(i.currentTarget.open),children:[da("summary",{ref:s,"aria-label":`Current page: ${a}`,"aria-disabled":r||g,tabIndex:r||g?-1:0,onClick:i=>{i.preventDefault(),!(r||g||!f.current)&&(f.current.open?D():(b(a),G(""),l?.(),f.current.open=!0,k(!0)))},children:[fe($e,{"aria-hidden":"true"}),fe("span",{title:a,children:a}),fe(Xe,{className:"feedback-page-chevron","aria-hidden":"true"})]}),da("div",{className:"feedback-page-popover",children:[da("form",{className:"feedback-page-form",onSubmit:i=>{i.preventDefault(),H(w)},children:[fe("input",{ref:p,"aria-label":"Page URL or path",value:w,placeholder:"Enter a URL or path",autoComplete:"off",autoCapitalize:"off",spellCheck:!1,disabled:r||g,onChange:i=>{b(i.target.value),G("")}}),fe("button",{type:"submit","aria-label":"Go to page",title:"Go to page","aria-busy":g,disabled:r||g||!w.trim(),children:fe(We,{"aria-hidden":"true"})})]}),F&&fe("p",{className:"feedback-page-error",role:"alert",children:F}),fe("nav",{className:"feedback-page-routes","aria-label":"Known pages",children:J.map(i=>da("button",{type:"button",title:i,"aria-current":i===V?"page":void 0,disabled:r||g,onClick:()=>{i===V?D(!0):H(i)},children:[fe("span",{children:i}),i===V&&fe(Pe,{"aria-hidden":"true"})]},i))})]})]})}import{jsx as la,jsxs as $t}from"react/jsx-runtime";import{useEffect as Zt,useRef as Ga,useState as Fo}from"react";function Ro({request:a,finish:t,returnFocus:r}){let o=Ga(null);return Zt(()=>(o.current?.showModal(),()=>r?.focus({preventScroll:!0})),[]),$t("dialog",{ref:o,className:"feedback-confirmation","aria-labelledby":"feedback-confirmation-title","aria-describedby":"feedback-confirmation-description",onCancel:l=>{l.preventDefault(),t(!1)},children:[la("h2",{id:"feedback-confirmation-title",children:a.title}),la("p",{id:"feedback-confirmation-description",children:a.description}),$t("div",{children:[la("button",{type:"button",autoFocus:!0,onClick:()=>t(!1),children:"Cancel"}),la("button",{type:"button","data-danger":a.danger,onClick:()=>t(!0),children:a.action})]})]})}function jt(){let[a,t]=Fo(null),r=Ga(null),o=Ga(null);Zt(()=>()=>o.current?.(!1),[]);function l(s){o.current?.(s),o.current=null,t(null)}function f(s){return o.current?Promise.resolve(!1):(r.current=document.activeElement,t(s),new Promise(p=>{o.current=p}))}return{confirm:f,dialog:a&&la(Ro,{request:a,finish:l,returnFocus:r.current})}}function _t(a){if(!(a.defaultPrevented||a.repeat||a.isComposing||a.ctrlKey||a.metaKey||a.altKey||a.composedPath().some(r=>{let o=r;return o.nodeType===1&&(o.isContentEditable||o.closest('input,textarea,select,[role="textbox"],[role="combobox"],[contenteditable]:not([contenteditable="false"])'))})))switch(a.key.toLowerCase()){case"c":return a.shiftKey?"toggle-comments":"comment";case"e":return"edit";case"v":return"view"}}function Jt(a){let t,r=()=>clearTimeout(t);return{cancel:r,schedule(){r(),t=setTimeout(a,70)}}}function Qt(a,t,r){let p=(G,V)=>Math.max(8,Math.min(G,V)),L=a.x+36+8,S=a.x+-4-8-t.width,k=r.width-t.width-8,w=Math.max(0,r.height-16);if(L<=k||S>=8)return{left:p(L<=k?L:S,k),top:p(a.y,r.height-Math.min(t.height,w)-8),maxHeight:w};let b=p(a.y+36+8,r.height-8),g=p(a.y+-4-8,r.height-8),M=r.height-b-8,F=g-8;return M>=F?{left:p(a.x+-4,k),top:b,maxHeight:M}:{left:p(a.x+-4,k),top:g-Math.min(t.height,F),maxHeight:F}}var ya=new WeakMap;function va(a,t=!1,r){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches||!a.animate)return r?.cancel(),null;let o=r?.playState==="running",l=window.getComputedStyle(a);if(a.dataset.expanded==="true"){let b={opacity:0,transform:"translateY(4px)"},g={opacity:1,transform:"translateY(0px)"},M=o?{opacity:l.opacity,transform:l.transform}:t?g:b;return r?.cancel(),a.animate([M,t?b:g],{duration:t?100:140,easing:"cubic-bezier(.4,0,.2,1)"})}let f=a.querySelector(".feedback-hover-preview"),s=ya.get(a)??{width:a.offsetWidth,height:a.offsetHeight,content:f,contentWidth:f?.style.width??""},p={width:`${(Number(a.dataset.pinWidth)||40)-8}px`,height:"32px",opacity:0,transform:`translate(${Number(a.dataset.pinX)-a.offsetLeft}px, ${Number(a.dataset.pinY)-a.offsetTop}px)`,borderRadius:"16px 16px 16px 0px"},L={width:`${s.width}px`,height:`${s.height}px`,opacity:1,transform:"translate(0px, 0px)",borderRadius:l.borderRadius},S=o?{width:l.width,height:l.height,opacity:l.opacity,transform:l.transform,borderRadius:l.borderRadius}:t?L:p;f&&(f.style.width=`${s.width-(parseFloat(l.borderLeftWidth)||0)-(parseFloat(l.borderRightWidth)||0)}px`),r?.cancel();let k=a.animate([{...S,overflow:"hidden"},{...t?p:L,overflow:"hidden"}],{duration:t?120:140,easing:"cubic-bezier(.4,0,.2,1)",fill:t?"forwards":"none"});s.animation=k,ya.set(a,s);let w=()=>{ya.get(a)?.animation===k&&(s.content&&(s.content.style.width=s.contentWidth),ya.delete(a))};return k.finished.then(()=>{t||w()},w),k}import{jsx as To}from"react/jsx-runtime";var Yt=`
1
+ "use client";import{jsx as u,jsxs as h,Fragment as na}from"react/jsx-runtime";import{useEffect as ke,useLayoutEffect as Fa,useRef as z,useState as F}from"react";import{forwardRef as Po,createElement as Do}from"react";var pt=a=>a?.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();function mt(a,t,r=[]){if(t==null)throw new Error("[lucide]: iconNode is required when icon name is used");return{name:pt(a),size:24,node:t,...r.length>0?{aliases:r}:{}}}var ht=a=>{let t="",r=!1;for(let o of a){if(o==="-"||o==="_"||o<=" "){r=t.length>0;continue}t.length===0?t+=o.toLowerCase():t+=r?o.toUpperCase():o,r=!1}return t};var xt=a=>{let t=ht(a);return t.charAt(0).toUpperCase()+t.slice(1)};import{forwardRef as vo,createElement as bt}from"react";var $e=(...a)=>a.filter((t,r,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===r).join(" ").trim();var Pe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};function Ga(a){return a!=null}function Lt(a,t={}){let r=t.attributeNames??{},o=k=>r[k]??k,l=a.size??a.width??Pe.width,n=a.size??a.height??Pe.height,s=a.aliases?.filter(k=>typeof k=="string"&&k.trim()!=="").map(k=>`lucide-${k}`)??[],c=[...a.name?[`lucide-${a.name}`]:[],...s],g=t.className?.split(" ").filter(Boolean)??[],w=t.includeDefaultClasses===!1?$e(...g):$e("lucide",...c,...g),S=t.absoluteStrokeWidth?Number(t.strokeWidth??Pe["stroke-width"])*Number(a.size??a.width??Pe.width)/Number(t.size??t.width??Pe.width):t.strokeWidth??Pe["stroke-width"];return["svg",{...Object.entries(Pe).reduce((k,[I,R])=>(k[o(I)]=R,k),{}),..."color"in t&&t.color&&{[o("stroke")]:t.color},..."size"in t&&Ga(t.size)&&{[o("width")]:t.size,[o("height")]:t.size},..."width"in t&&Ga(t.width)&&{[o("width")]:t.width},..."height"in t&&Ga(t.height)&&{[o("height")]:t.height},[o("stroke-width")]:S,...w&&{[o("class")]:w},[o("viewBox")]:`0 0 ${l} ${n}`,...t.hasA11yProp===!1?{[o("aria-hidden")]:"true"}:{},..."attributes"in t&&t.attributes},a.node.map(k=>{let[I,R,q]=k,X=t.nonScalingStroke?{[o("vector-effect")]:"non-scaling-stroke",...R}:R;return q?[I,X,q]:[I,X]})]}function gt(a,t={}){return Lt(a,{...t,attributeNames:{...t.attributeNames,class:"className","stroke-width":"strokeWidth","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","vector-effect":"vectorEffect"}})}var It=a=>{for(let t in a)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1};import{createContext as So,useContext as wo,useMemo as fr,createElement as nr}from"react";var yo=So({});var Ct=()=>wo(yo);var kt=vo(({color:a,size:t,width:r,height:o,strokeWidth:l,absoluteStrokeWidth:n,nonScalingStroke:s,className:c="",children:g,iconNode:w=[],icon:S={node:w,aliases:[],size:24},...y},k)=>{let{size:I=24,strokeWidth:R=2,absoluteStrokeWidth:q=!1,nonScalingStroke:X=!1,color:K="currentColor",className:ae=""}=Ct()??{},P=!!g||It(y),[H,p,x=[]]=gt(S,{color:a??K,width:r??t??I,height:o??t??I,strokeWidth:l??R,absoluteStrokeWidth:n??q,nonScalingStroke:s??X,className:$e(ae,c),hasA11yProp:P,attributes:y});return bt(H,{ref:k,...p},[...x.map(([te,m])=>bt(te,m)),...Array.isArray(g)?g:[g]])});function C(a,t=[],r=[]){let o=typeof a=="string"?mt(a,t,r):a,l=Po(({className:n,...s},c)=>Do(kt,{ref:c,icon:o,className:n,...s}));return o.name&&(l.displayName=xt(o.name)),l}var St={name:"arrow-right",size:24,node:[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]};St.node;var Ze=C(St);var wt={name:"arrow-up",size:24,node:[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]};wt.node;var je=C(wt);var yt={name:"check",size:24,node:[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]};yt.node;var Fe=C(yt);var vt={name:"chevron-down",size:24,node:[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]};vt.node;var _e=C(vt);var Pt={name:"chevron-right",size:24,node:[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]};Pt.node;var Re=C(Pt);var Dt={name:"circle-check",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 9-5.5 5.5L8 12",key:"xofnsj"}]],aliases:["check-circle-2"]};Dt.node;var De=C(Dt);var At={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"}]]};At.node;var Je=C(At);var Bt={name:"globe",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]};Bt.node;var Qe=C(Bt);var Mt={name:"grip-horizontal",size:24,node:[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]};Mt.node;var Ye=C(Mt);var Ft={name:"link-2",size:24,node:[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]};Ft.node;var ea=C(Ft);var Rt={name:"loader-circle",size:24,node:[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],aliases:["loader-2"]};Rt.node;var Ae=C(Rt);var Tt={name:"log-out",size:24,node:[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]};Tt.node;var aa=C(Tt);var qt={name:"message-circle",size:24,node:[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]]};qt.node;var ze=C(qt);var Ut={name:"mouse-pointer-2",size:24,node:[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]};Ut.node;var ta=C(Ut);var Ht={name:"pencil",size:24,node:[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]};Ht.node;var Ne=C(Ht);var Ot={name:"pipette",size:24,node:[["path",{d:"m12 9-8.414 8.414A2 2 0 0 0 3 18.828v1.344a2 2 0 0 1-.586 1.414A2 2 0 0 1 3.828 21h1.344a2 2 0 0 0 1.414-.586L15 12",key:"1y3wsu"}],["path",{d:"m18 9 .4.4a1 1 0 1 1-3 3l-3.8-3.8a1 1 0 1 1 3-3l.4.4 3.4-3.4a1 1 0 1 1 3 3z",key:"110lr1"}],["path",{d:"m2 22 .414-.414",key:"jhxm08"}]]};Ot.node;var oa=C(Ot);var Et={name:"rotate-ccw",size:24,node:[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]};Et.node;var ra=C(Et);var zt={name:"search",size:24,node:[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]};zt.node;var da=C(zt);var Nt={name:"sliders-horizontal",size:24,node:[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]};Nt.node;var Te=C(Nt);var Gt={name:"trash",size:24,node:[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],aliases:["trash-2"]};Gt.node;var Be=C(Gt);var Wt={name:"x",size:24,node:[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]};Wt.node;var la=C(Wt);import{jsx as M,jsxs as ee,Fragment as Fo}from"react/jsx-runtime";import{useEffect as _t,useId as Ro,useState as be}from"react";import{jsx as ne,jsxs as ua}from"react/jsx-runtime";import{useEffect as Ao,useRef as Xt,useState as Ge}from"react";import{createPortal as Bo}from"react-dom";function Vt(a,t,r,o=1){a/=255,t/=255,r/=255;let l=Math.max(a,t,r),n=Math.min(a,t,r),s=l-n;return{h:(s?l===a?((t-r)/s+6)%6:l===t?(r-a)/s+2:(a-t)/s+4:0)*60,s:l?s/l:0,v:l,a:o}}function ka({h:a,s:t,v:r,a:o}){let l=n=>{let s=(n+a/60)%6;return Math.round(255*r*(1-t*Math.max(0,Math.min(s,4-s,1)))).toString(16).padStart(2,"0")};return`#${l(5)}${l(3)}${l(1)}${o<1?Math.round(o*255).toString(16).padStart(2,"0"):""}`}function Sa(a){if(typeof document<"u"){let t=document.createElement("canvas");t.width=t.height=1;let r=t.getContext("2d");if(r){r.fillStyle=a,r.fillRect(0,0,1,1);let[o,l,n,s]=r.getImageData(0,0,1,1).data;return Vt(o,l,n,s/255)}}return Vt(0,0,0)}function Wa({label:a,value:t,onChange:r,disabled:o}){let l=Xt(null),n=Xt(null),[s,c]=Ge(null),[g,w]=Ge({h:0,s:0,v:0,a:1}),[S,y]=Ge(""),[k,I]=Ge(!1),[R,q]=Ge(!1),[X,K]=Ge(!1);function ae(){c(null)}Ao(()=>{if(!s)return;let p=T=>{!n.current?.contains(T.target)&&!l.current?.contains(T.target)&&ae()},x=T=>{T.key==="Escape"&&(T.preventDefault(),T.stopPropagation(),ae(),l.current?.focus())},te=l.current?.getBoundingClientRect(),m=T=>{if(n.current?.contains(T.target))return;let G=l.current?.getBoundingClientRect();(G?.top!==te?.top||G?.left!==te?.left)&&ae()};return document.addEventListener("pointerdown",p),document.addEventListener("keydown",x,!0),window.addEventListener("resize",ae),document.addEventListener("scroll",m,!0),n.current?.querySelector("input")?.focus({preventScroll:!0}),()=>{document.removeEventListener("pointerdown",p),document.removeEventListener("keydown",x,!0),window.removeEventListener("resize",ae),document.removeEventListener("scroll",m,!0)}},[s]);function P(p){p.a===0&&(p={...p,a:1}),w(p);let x=ka(p);y(x.slice(1).toUpperCase()),I(!1),r(x)}function H(p){let x=p.currentTarget.getBoundingClientRect();P({...g,s:Math.max(0,Math.min(1,(p.clientX-x.left)/x.width)),v:1-Math.max(0,Math.min(1,(p.clientY-x.top)/x.height))})}return ua("div",{className:"comment-box-color",children:[ne("button",{ref:l,className:"comment-color-trigger",type:"button","aria-label":`${a} picker`,"aria-haspopup":"dialog","aria-expanded":!!s,disabled:o,onClick:()=>{if(s){ae();return}let p=Sa(t);w(p),y(ka(p).slice(1).toUpperCase()),I(!1),q("EyeDropper"in window);let x=l.current.getBoundingClientRect();c({left:Math.max(8,Math.min(x.right-256,window.innerWidth-264)),top:Math.max(8,Math.min(x.bottom+8,window.innerHeight-330))})},children:ne("span",{style:{background:t}})}),ne("span",{className:"comment-color-value",title:t,children:t}),s&&Bo(ua("div",{ref:n,className:"chisel-color-picker",role:"dialog","aria-label":`${a} color picker`,style:s,onKeyDown:p=>{if(p.key!=="Tab")return;let x=Array.from(n.current.querySelectorAll("button:not(:disabled), input:not(:disabled)"));p.shiftKey&&document.activeElement===x[0]?(p.preventDefault(),x[x.length-1]?.focus()):!p.shiftKey&&document.activeElement===x[x.length-1]&&(p.preventDefault(),x[0]?.focus())},children:[ua("div",{className:"chisel-color-plane",style:{backgroundColor:`hsl(${g.h} 100% 50%)`},onPointerDown:p=>{p.currentTarget.setPointerCapture(p.pointerId),H(p)},onPointerMove:p=>{p.currentTarget.hasPointerCapture(p.pointerId)&&H(p)},children:[ne("span",{className:"chisel-color-thumb",style:{left:`${g.s*100}%`,top:`${(1-g.v)*100}%`,background:ka({...g,a:1})}}),ne("input",{className:"chisel-color-accessible",type:"range","aria-label":`${a} saturation`,min:0,max:100,value:Math.round(g.s*100),onChange:p=>P({...g,s:Number(p.target.value)/100})}),ne("input",{className:"chisel-color-accessible",type:"range","aria-label":`${a} brightness`,min:0,max:100,value:Math.round(g.v*100),onChange:p=>P({...g,v:Number(p.target.value)/100})})]}),ua("div",{className:"chisel-color-tools",children:[ne("input",{className:"chisel-color-hue",type:"range","aria-label":`${a} hue`,min:0,max:360,value:Math.round(g.h),style:{"--hue":`hsl(${g.h} 100% 50%)`},onChange:p=>P({...g,h:Number(p.target.value)})}),ne("button",{type:"button","aria-label":`Pick ${a.toLowerCase()} from screen`,title:R?"Pick a color from the screen":"Screen color picker is not supported in this browser",disabled:!R||X,onClick:async()=>{let p=window.EyeDropper;if(p){K(!0);try{let x=await new p().open();n.current&&P(Sa(x.sRGBHex))}catch{}finally{K(!1)}}},children:ne(oa,{size:18})})]}),ua("label",{className:"chisel-color-hex",children:["HEX",ne("input",{"aria-label":`${a} hex`,value:S,maxLength:9,spellCheck:!1,"aria-invalid":k,onChange:p=>{let x=p.target.value.replace(/^#/,"");y(x);let te=/^(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(x);if(I(!te),te){let m=Sa(`#${x}`);w(m),r(`#${x}`)}}})]}),k&&ne("span",{className:"chisel-color-error",role:"status",children:"Enter a valid hex color."})]}),document.body)]})}import{jsx as Kt}from"react/jsx-runtime";import{useRef as Mo}from"react";function sa({onMoveStart:a}){let t=Mo(null);function r(o,l,n){let s=o.closest(".comment-box,.comment-thread"),c=s?.closest(".feedback-viewport");if(!s||!c)return;let g=c.getBoundingClientRect(),w=s.getBoundingClientRect();for(let[S,y]of[["x",Math.max(g.left+8-w.left,Math.min(l,g.right-8-w.right))],["y",Math.max(g.top+8-w.top,Math.min(n,g.bottom-8-w.bottom))]]){let k=`--comment-drag-${S}`;s.style.setProperty(k,`${(parseFloat(s.style.getPropertyValue(k))||0)+y}px`)}}return Kt("button",{type:"button",className:"comment-window-drag","aria-label":"Move comment window",title:"Drag to move \xB7 Arrow keys to nudge",onPointerDown:o=>{!o.isPrimary||o.button!==0||(o.preventDefault(),a?.(),o.currentTarget.closest(".comment-box,.comment-thread")?.getAnimations().forEach(l=>l.cancel()),o.currentTarget.setPointerCapture(o.pointerId),t.current={id:o.pointerId,x:o.clientX,y:o.clientY},o.currentTarget.dataset.dragging="true")},onPointerMove:o=>{let l=t.current;!l||l.id!==o.pointerId||(r(o.currentTarget,o.clientX-l.x,o.clientY-l.y),l.x=o.clientX,l.y=o.clientY)},onPointerUp:o=>{o.currentTarget.hasPointerCapture(o.pointerId)&&o.currentTarget.releasePointerCapture(o.pointerId)},onLostPointerCapture:o=>{t.current=null,delete o.currentTarget.dataset.dragging},onKeyDown:o=>{let l={ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1],ArrowDown:[0,1]}[o.key];if(!l)return;o.preventDefault(),o.stopPropagation(),a?.();let n=o.shiftKey?40:10;r(o.currentTarget,l[0]*n,l[1]*n)},children:Kt(Ye,{size:16,"aria-hidden":"true"})})}function $t(a,t,r,o){let l={[a]:t},n=r.find(s=>s!==a);if(!n||!r.includes(a))return l;if(r.includes("width")){let s=parseFloat(o.width)/parseFloat(o.height),c=parseFloat(t);if(!Number.isFinite(s)||s<=0||!Number.isFinite(c))return l;l[n]=`${a==="width"?c/s:c*s}px`}else l[n]=t;return l}var Zt=new Set(["color","background-color","opacity","font-family","font-size","font-weight","border-color","border-width","width","height",...["padding","margin"].flatMap(a=>["top","right","bottom","left"].map(t=>`${a}-${t}`))]);function jt(a,t){let r={...a},o={...a};for(let l of Array.isArray(t)?t:[])!l||!Object.prototype.hasOwnProperty.call(a,l.property)||typeof l.before!="string"||typeof l.after!="string"||l.property!=="text"&&(!Zt.has(l.property)||!CSS.supports(l.property,l.after))||(r[l.property]=l.before,o[l.property]=l.after);return{initial:r,values:o}}function wa(a,t){if(!Array.isArray(t))return()=>{};let r=a.style,o=a.getAttribute("style"),l=a.textContent,n=!1;for(let c of t)!c||typeof c.after!="string"||(c.property==="text"&&!a.children.length?(a.textContent=c.after,n=!0):r&&Zt.has(c.property)&&CSS.supports(c.property,c.after)&&r.setProperty(c.property,c.after,"important"));let s=!1;return()=>{s||(s=!0,o===null?a.removeAttribute("style"):a.setAttribute("style",o),n&&!a.children.length&&(a.textContent=l))}}var Qt=[["Text color","color","color"],["Background","background-color","color"],["Opacity","opacity","number"],["Font","font-family","font"],["Font size","font-size","number"],["Font weight","font-weight","weight"],["Border color","border-color","color"],["Border width","border-width","number"]],To=["top","bottom","left","right"],Jt=[{label:"Size",pairs:[["width","height"]]},...["padding","margin"].map(a=>({label:a[0].toUpperCase()+a.slice(1),pairs:[[`${a}-top`,`${a}-bottom`],[`${a}-left`,`${a}-right`]]}))];function qo(a){let t=a.ownerDocument.defaultView.getComputedStyle(a);return Object.fromEntries([["text",a.children.length?"":a.textContent??""],...["width","height"].map(r=>[r,t.getPropertyValue(r)]),...Qt.map(([,r])=>[r,t.getPropertyValue(r)]),...["padding","margin"].flatMap(r=>To.map(o=>[`${r}-${o}`,t.getPropertyValue(`${r}-${o}`)]))])}function Va({target:a,text:t,onText:r,onCancel:o,onPost:l,style:n,changes:s=[],editing:c=!1,commentId:g,renderComposer:w,hasExistingAttachments:S=!1,onDraftChange:y,hidden:k=!1}){let[I]=be(()=>jt(qo(a),s)),R=I.initial,[q,X]=be(I.values),[K]=be(()=>({style:a.getAttribute("style"),text:a.textContent})),[ae,P]=be({}),[H,p]=be(!1),[x]=be(t),[te,m]=be(!1),[U,T]=be(""),[G,Se]=be(!1),V=Ro();function oe(){K.style===null?a.removeAttribute("style"):a.setAttribute("style",K.style),a.children.length||a.replaceChildren(a.ownerDocument.createTextNode(K.text??""))}function W(){oe(),o()}_t(()=>(wa(a,s),oe),[a,K]);function pe(E,$){if(E==="text"){X(v=>({...v,text:$})),a.children.length||a.replaceChildren(a.ownerDocument.createTextNode($));return}let ue=Jt.flatMap(v=>v.pairs).find(v=>v.includes(E)&&ae[v.join(":")]),Z=ue?$t(E,$,ue,R):{[E]:$};X(v=>({...v,...Z}));for(let[v,A]of Object.entries(Z))CSS.supports(v,A)&&a.style.setProperty(v,A,"important")}let we=Object.entries(q).some(([E,$])=>$!==R[E]),He=!!(t.trim()||we||te||c&&t!==x);_t(()=>(y?.(He),()=>y?.(!1)),[He,y]);async function Q(E=t,$,ue,Z){if(H||!E.trim()&&!ue?.length&&!S)return!1;let v=Object.entries(q).filter(([A,L])=>L!==R[A]).map(([A,L])=>({property:A,before:R[A],after:L}));if(v.some(A=>A.property!=="text"&&!CSS.supports(A.property,A.after)))return T("Check the style values before posting."),!1;p(!0),T("");try{let A=await l(v,E.trimEnd(),$,ue,Z);return A?W():T("Could not post. Your changes are still here; please try again."),A}catch{return T("Could not post. Please try again."),!1}finally{p(!1)}}let We=(E,$=!1,ue=!1,Z)=>ee(Fo,{children:[ee("div",{className:"comment-box-prompt",children:[M("button",{type:"button",className:"comment-box-symbol","aria-label":"Comment settings",title:"Comment settings","aria-expanded":G,"aria-controls":V,disabled:H,onClick:()=>Se(v=>!v),children:M(Te,{})}),E]}),ee("div",{className:"comment-box-settings",id:V,hidden:!G,children:[ee("div",{className:"comment-box-element",children:[ee("code",{children:["<",a.tagName.toLowerCase(),">"]}),we&&M("span",{className:"comment-box-preview-status",role:"status",children:"Unsaved preview"}),M(sa,{})]}),ee("fieldset",{className:"comment-box-properties",disabled:H||!G,children:[ee("label",{className:"comment-box-row",children:[M("span",{children:"Text"}),M("input",{"aria-label":"Element text",value:q.text,disabled:!!a.children.length,title:a.children.length?"Select a text-only element to change its text":void 0,onChange:v=>pe("text",v.target.value)})]}),["Typography","Appearance"].map(v=>ee("div",{className:"comment-box-control-group",children:[M("h3",{children:v}),Qt.filter(([,A])=>v==="Typography"===["color","font-family","font-size","font-weight"].includes(A)).map(([A,L,de])=>ee("div",{className:"comment-box-row",children:[M("span",{children:A}),de==="color"?G&&M(Wa,{label:A,value:q[L],disabled:H,onChange:B=>pe(L,B)}):de==="font"?M("select",{"aria-label":A,value:q[L],onChange:B=>pe(L,B.target.value),children:Array.from(new Set([R[L],"Arial, sans-serif","Georgia, serif","system-ui","monospace"])).map(B=>M("option",{value:B,children:B},B))}):de==="weight"?M("select",{"aria-label":A,value:q[L],onChange:B=>pe(L,B.target.value),children:Array.from(new Set([R[L],...[100,200,300,400,500,600,700,800,900].map(String)])).map(B=>M("option",{children:B},B))}):ee("div",{className:"comment-box-number",children:[M("input",{type:"number","aria-label":A,value:Number.isFinite(parseFloat(q[L]))?parseFloat(q[L]):"",min:0,max:L==="opacity"?1:void 0,step:"any",onChange:B=>pe(L,B.target.value+(L==="opacity"?"":"px"))}),L!=="opacity"&&M("span",{children:"px"})]})]},L))]},v)),Jt.map(v=>ee("details",{className:"comment-box-group",open:!0,children:[ee("summary",{children:[v.label,M(Re,{size:12,"aria-hidden":"true"})]}),v.pairs.map(A=>{let L=A.join(":"),de=v.label==="Size"?"Lock aspect ratio":`Link ${v.label.toLowerCase()} ${A[0].split("-")[1]} and ${A[1].split("-")[1]}`;return ee("div",{className:"comment-box-pair",children:[M("button",{className:"comment-box-link",type:"button","aria-label":de,title:de,"aria-pressed":!!ae[L],onClick:()=>P(B=>({...B,[L]:!B[L]})),children:M(ea,{size:12})}),A.map(B=>{let Oe=B.includes("-")?B.split("-")[1]:B;return ee("label",{className:"comment-box-row",children:[M("span",{children:Oe[0].toUpperCase()+Oe.slice(1)}),ee("span",{className:"comment-box-number",children:[M("input",{type:"number",step:"any",min:B.startsWith("margin-")?void 0:0,"aria-label":B.replace("-"," ").replace(/^width$/,"Width").replace(/^height$/,"Height"),value:Number.isFinite(parseFloat(q[B]))?parseFloat(q[B]):"",onChange:Ta=>pe(B,`${Ta.target.value}px`)}),M("span",{children:"px"})]})]},B)})]},L)})]},v.label))]})]}),U&&M("p",{className:"comment-box-error",role:"alert",children:U}),ee("footer",{className:"comment-box-footer",children:[M("button",{type:"button",className:"comment-box-cancel",onClick:W,disabled:H,children:"Cancel"}),M("span",{}),Z,M("button",{type:"submit",className:"comment-box-submit","aria-label":c?"Save comment":"Post comment",title:c?"Save comment":"Post comment",disabled:H||ue||!t.trim()&&!$&&!S,children:H?M("span",{className:"comment-box-saving"}):M(Fe,{})})]})]}),re=`comment-box${w?" comment-box-native":""}`,Ve=E=>{E.key==="Escape"&&!H&&(E.preventDefault(),E.stopPropagation(),W())};return w?M("div",{className:re,hidden:k,"data-settings-open":G,style:n,onKeyDown:Ve,children:w({text:t,onText:r,disabled:H,commentId:g,onAttachmentDraftChange:m,onSubmit:Q,renderContent:We})}):M("form",{className:re,hidden:k,"data-settings-open":G,style:n,"aria-label":c?"Edit comment":"New comment",onKeyDown:Ve,onSubmit:E=>{E.preventDefault(),Q()},children:We(M("input",{"aria-label":"Comment",placeholder:"Leave a comment\u2026",value:t,onChange:E=>r(E.target.value),autoFocus:!0,maxLength:4e3,required:!0,disabled:H}))})}import{jsx as ce,jsxs as Ue,Fragment as Uo}from"react/jsx-runtime";import{useEffect as Ho,useLayoutEffect as Oo,useRef as va,useState as Pa}from"react";function qe(a,t,r="/"){if(!a.trim())return null;try{let o=new URL(a.trim(),new URL(r,t)),l=decodeURIComponent(o.pathname);return!/^https?:$/.test(o.protocol)||o.origin!==t||o.username||o.password||/^\/(chisel|feedback)(\/|$)/.test(l)?null:o.pathname+o.search+o.hash}catch{return null}}function ya(a){return a.split(/[?#]/,1)[0]}function Xa(a){try{let{pathname:t,search:r,hash:o}=a.location;return t.startsWith("/")?t+r+o:null}catch{return null}}function Yt(a,t){let r;try{r=a.history}catch{return()=>{}}let o=r.pushState,l=r.replaceState,n=!0,s=()=>{let w=Xa(a);n&&w!==null&&t(w)},c=function(...w){o.apply(this,w),s()},g=function(...w){l.apply(this,w),s()};return r.pushState=c,r.replaceState=g,a.addEventListener("popstate",s),a.addEventListener("hashchange",s),s(),()=>{n=!1,r.pushState===c&&(r.pushState=o),r.replaceState===g&&(r.replaceState=l),a.removeEventListener("popstate",s),a.removeEventListener("hashchange",s)}}function Ka({path:a,routes:t,disabled:r,onNavigate:o,onOpen:l}){let n=va(null),s=va(null),c=va(null),g=va(!1),[w,S]=Pa(!1),[y,k]=Pa(""),[I,R]=Pa(!1),[q,X]=Pa(""),K=ya(a),ae=[...new Set([a,...t].map(ya))],P=y.trim();if(/^https?:\/\//i.test(P))try{let m=new URL(P);m.origin===window.location.origin&&(P=m.pathname)}catch{}else P=ya(P);let H=P.toLocaleLowerCase(),p=ae.filter(m=>m.toLocaleLowerCase().includes(H));function x(m=!1){n.current&&(n.current.open=!1),S(!1),m&&s.current?.focus({preventScroll:!0})}Oo(()=>{if(!w)return;let m=()=>{let U=n.current,T=U?.closest(".feedback-sidebar-panel");U&&T&&U.style.setProperty("--feedback-page-space",`${Math.max(0,U.getBoundingClientRect().top-T.getBoundingClientRect().top-12)}px`)};return m(),c.current?.focus(),c.current?.select(),window.addEventListener("resize",m),()=>window.removeEventListener("resize",m)},[w]),Ho(()=>{if(!w)return;let m=G=>{!g.current&&!n.current?.contains(G.target)&&x()},U=G=>{G.key!=="Escape"||g.current||(G.preventDefault(),G.stopPropagation(),x(!0))},T=()=>{g.current||x()};return document.addEventListener("pointerdown",m),document.addEventListener("keydown",U,!0),window.addEventListener("blur",T),()=>{document.removeEventListener("pointerdown",m),document.removeEventListener("keydown",U,!0),window.removeEventListener("blur",T)}},[w]);async function te(m){if(!(r||g.current)){g.current=!0,R(!0),X("");try{await o(m)&&x(!0)}catch(U){X(U instanceof Error&&U.message?U.message:"This page could not be opened. Try again.")}finally{g.current=!1,R(!1)}}}return Ue("details",{ref:n,className:"feedback-page-control",onToggle:m=>S(m.currentTarget.open),children:[Ue("summary",{ref:s,"aria-label":`Current page: ${a}`,"aria-disabled":r||I,tabIndex:r||I?-1:0,onClick:m=>{m.preventDefault(),!(r||I||!n.current)&&(n.current.open?x():(k(""),X(""),l?.(),n.current.open=!0,S(!0)))},children:[ce(Qe,{"aria-hidden":"true"}),ce("span",{title:a,children:a}),ce(_e,{className:"feedback-page-chevron","aria-hidden":"true"})]}),Ue("div",{className:"feedback-page-popover",children:[Ue("form",{className:"feedback-page-form",onSubmit:m=>{m.preventDefault(),te(y)},children:[ce("input",{ref:c,"aria-label":"Page URL or path",value:y,placeholder:"Enter a URL or path",autoComplete:"off",autoCapitalize:"off",spellCheck:!1,disabled:r||I,onChange:m=>{k(m.target.value),X("")}}),ce("button",{type:"submit","aria-label":"Go to page",title:"Go to page","aria-busy":I,disabled:r||I||!y.trim(),children:ce(Ze,{"aria-hidden":"true"})})]}),q&&ce("p",{className:"feedback-page-error",role:"alert",children:q}),Ue("nav",{className:"feedback-page-routes","aria-label":"Known pages",children:[p.map(m=>Ue("button",{type:"button",title:m,"aria-current":m===K?"page":void 0,disabled:r||I,onClick:()=>{m===K?x(!0):te(m)},children:[ce("span",{children:H?Ue(Uo,{children:[m.slice(0,m.toLocaleLowerCase().indexOf(H)),ce("mark",{children:m.slice(m.toLocaleLowerCase().indexOf(H),m.toLocaleLowerCase().indexOf(H)+P.length)}),m.slice(m.toLocaleLowerCase().indexOf(H)+P.length)]}):m}),m===K&&ce(Fe,{"aria-hidden":"true"})]},m)),!p.length&&ce("p",{className:"feedback-page-empty",children:"No matching pages"})]})]})]})}import{jsx as ia,jsxs as eo}from"react/jsx-runtime";import{useEffect as ao,useRef as $a,useState as Eo}from"react";function zo({request:a,finish:t,returnFocus:r}){let o=$a(null);return ao(()=>(o.current?.showModal(),()=>r?.focus({preventScroll:!0})),[]),eo("dialog",{ref:o,className:"feedback-confirmation","aria-labelledby":"feedback-confirmation-title","aria-describedby":"feedback-confirmation-description",onCancel:l=>{l.preventDefault(),t(!1)},children:[ia("h2",{id:"feedback-confirmation-title",children:a.title}),ia("p",{id:"feedback-confirmation-description",children:a.description}),eo("div",{children:[ia("button",{type:"button",autoFocus:!0,onClick:()=>t(!1),children:"Cancel"}),ia("button",{type:"button","data-danger":a.danger,onClick:()=>t(!0),children:a.action})]})]})}function to(){let[a,t]=Eo(null),r=$a(null),o=$a(null);ao(()=>()=>o.current?.(!1),[]);function l(s){o.current?.(s),o.current=null,t(null)}function n(s){return o.current?Promise.resolve(!1):(r.current=document.activeElement,t(s),new Promise(c=>{o.current=c}))}return{confirm:n,dialog:a&&ia(zo,{request:a,finish:l,returnFocus:r.current})}}function oo(a){if(!(a.defaultPrevented||a.repeat||a.isComposing||a.ctrlKey||a.metaKey||a.altKey||a.composedPath().some(r=>{let o=r;return o.nodeType===1&&(o.isContentEditable||o.closest('input,textarea,select,[role="textbox"],[role="combobox"],[contenteditable]:not([contenteditable="false"])'))})))switch(a.key.toLowerCase()){case"c":return a.shiftKey?"toggle-comments":"comment";case"e":return"edit";case"v":return"view"}}function ro(a){let t,r=()=>clearTimeout(t);return{cancel:r,schedule(){r(),t=setTimeout(a,70)}}}function lo(a,t,r){let c=(X,K)=>Math.max(8,Math.min(X,K)),g=a.x+36+8,w=a.x+-4-8-t.width,S=r.width-t.width-8,y=Math.max(0,r.height-16);if(g<=S||w>=8)return{left:c(g<=S?g:w,S),top:c(a.y,r.height-Math.min(t.height,y)-8),maxHeight:y};let k=c(a.y+36+8,r.height-8),I=c(a.y+-4-8,r.height-8),R=r.height-k-8,q=I-8;return R>=q?{left:c(a.x+-4,S),top:k,maxHeight:R}:{left:c(a.x+-4,S),top:I-Math.min(t.height,q),maxHeight:q}}var Da=new WeakMap;function Aa(a,t=!1,r){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches||!a.animate)return r?.cancel(),null;let o=r?.playState==="running",l=window.getComputedStyle(a);if(a.dataset.expanded==="true"){let k={opacity:0,transform:"translateY(4px)"},I={opacity:1,transform:"translateY(0px)"},R=o?{opacity:l.opacity,transform:l.transform}:t?I:k;return r?.cancel(),a.animate([R,t?k:I],{duration:t?100:140,easing:"cubic-bezier(.4,0,.2,1)"})}let n=a.querySelector(".feedback-hover-preview"),s=Da.get(a)??{width:a.offsetWidth,height:a.offsetHeight,content:n,contentWidth:n?.style.width??""},c={width:`${(Number(a.dataset.pinWidth)||40)-8}px`,height:"32px",opacity:0,transform:`translate(${Number(a.dataset.pinX)-a.offsetLeft}px, ${Number(a.dataset.pinY)-a.offsetTop}px)`,borderRadius:"16px 16px 16px 0px"},g={width:`${s.width}px`,height:`${s.height}px`,opacity:1,transform:"translate(0px, 0px)",borderRadius:l.borderRadius},w=o?{width:l.width,height:l.height,opacity:l.opacity,transform:l.transform,borderRadius:l.borderRadius}:t?g:c;n&&(n.style.width=`${s.width-(parseFloat(l.borderLeftWidth)||0)-(parseFloat(l.borderRightWidth)||0)}px`),r?.cancel();let S=a.animate([{...w,overflow:"hidden"},{...t?c:g,overflow:"hidden"}],{duration:t?120:140,easing:"cubic-bezier(.4,0,.2,1)",fill:t?"forwards":"none"});s.animation=S,Da.set(a,s);let y=()=>{Da.get(a)?.animation===S&&(s.content&&(s.content.style.width=s.contentWidth),Da.delete(a))};return S.finished.then(()=>{t||y()},y),S}import{jsx as No}from"react/jsx-runtime";var uo=`
2
2
  :is(.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box) :focus{outline:none}
3
3
  .chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box{color-scheme:light;--chisel-ui-panel-shadow:0 4px 20px rgba(0,0,0,.08);--chisel-ui-canvas:#f7f7f7;--chisel-ui-surface:#ffffff;--chisel-ui-raised:#f5f5f5;--chisel-ui-inset:#eeeeee;--chisel-ui-hover:#f0f0f0;--chisel-ui-selected:#eaeaea;--chisel-ui-border:#e2e2e2;--chisel-ui-border-strong:#c4c4c4;--chisel-ui-text:#242424;--chisel-ui-secondary:#626262;--chisel-ui-muted:#686868;--chisel-ui-focus:#2468d3;--chisel-ui-accent-text:#2468d3;--chisel-ui-accent-surface:#edf4ff;--chisel-ui-action:#242424;--chisel-ui-action-text:#ffffff;--chisel-ui-danger:#b33737;--chisel-ui-avatar:#ededed;--chisel-ui-avatar-text:#565656;--chisel-ui-scrollbar:#c2c2c2;--chisel-ui-checker-light:#e5e5e5;--chisel-ui-checker-dark:#c7c7c7;}
4
4
  @media(prefers-color-scheme:dark){.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box{color-scheme:dark;--chisel-ui-panel-shadow:0 4px 20px #0003;--chisel-ui-canvas:#171717;--chisel-ui-surface:#222222;--chisel-ui-raised:#2a2a2a;--chisel-ui-inset:#191919;--chisel-ui-hover:#303030;--chisel-ui-selected:#383838;--chisel-ui-border:#3c3c3c;--chisel-ui-border-strong:#555555;--chisel-ui-text:#ededed;--chisel-ui-secondary:#b7b7b7;--chisel-ui-muted:#a5a5a5;--chisel-ui-focus:#8bb9ff;--chisel-ui-accent-text:#8bb9ff;--chisel-ui-accent-surface:#253447;--chisel-ui-action:#ededed;--chisel-ui-action-text:#111111;--chisel-ui-danger:#ffa5a5;--chisel-ui-avatar:#383838;--chisel-ui-avatar-text:#cccccc;--chisel-ui-scrollbar:#50504d;--chisel-ui-checker-light:#555555;--chisel-ui-checker-dark:#333333;}
@@ -6,7 +6,7 @@
6
6
 
7
7
  .chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box{--chisel-ui-font:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;--chisel-ui-space:4px;--chisel-ui-control:40px;--chisel-ui-radius:8px;--chisel-ui-text-size:13px;--chisel-ui-small:12px;--chisel-ui-motion:120ms cubic-bezier(.2,0,0,1);--chisel-ui-popover-shadow:0 2px 6px #0000000f,0 12px 36px #0000001f;}
8
8
  @media(prefers-color-scheme:dark){.chisel-root,.feedback-shell,.chisel-sign-in,.chisel-color-picker,.comment-box{--chisel-ui-popover-shadow:0 0 0 1px #ffffff0d,0 4px 12px #0003,0 16px 40px #0004;}}
9
- `;var qo=`
9
+ `;var Go=`
10
10
  .feedback-confirmation{width:360px;max-width:calc(100vw - 32px);padding:24px;border:0;border-radius:16px;background:var(--chisel-ui-surface);color:var(--chisel-ui-text);box-shadow:var(--chisel-ui-popover-shadow);font:14px var(--chisel-ui-font)}
11
11
  .feedback-confirmation::backdrop{background:#0005}
12
12
  .feedback-confirmation h2{margin:0 0 8px;font-size:16px;font-weight:600}
@@ -15,7 +15,7 @@
15
15
  .feedback-confirmation button{min-height:40px;padding:0 16px;border:0;border-radius:8px;background:var(--chisel-ui-raised);color:var(--chisel-ui-text)}
16
16
  .feedback-confirmation button[data-danger=true]{background:var(--chisel-ui-danger);color:var(--chisel-ui-surface)}
17
17
 
18
- ${Yt}
18
+ ${uo}
19
19
  .feedback-shell,.feedback-shell *{box-sizing:border-box}
20
20
  .feedback-shell{font-synthesis:none;-webkit-font-smoothing:antialiased;position:fixed;inset:0;background:var(--chisel-ui-canvas);color:var(--chisel-ui-text);z-index:999999;font-family:var(--chisel-ui-font);font-size:13px;letter-spacing:0}
21
21
  .feedback-avatar{overflow:hidden}
@@ -50,6 +50,7 @@ ${Yt}
50
50
  .feedback-element-box{position:absolute;pointer-events:none;z-index:1;border:1px solid var(--chisel-ui-focus);background:color-mix(in srgb,var(--chisel-ui-focus) 4%,transparent);box-sizing:border-box}
51
51
  .feedback-element-box.is-selected{border-width:2px;background:color-mix(in srgb,var(--chisel-ui-focus) 6%,transparent)}
52
52
  .feedback-thread-popup{max-height:calc(100% - 16px);overflow:auto}
53
+ .feedback-thread-popup[hidden]{display:none}
53
54
  .feedback-thread-message,.feedback-thread-replies{overflow-wrap:anywhere;line-height:1.6;margin:0}
54
55
  .feedback-thread-replies{max-height:140px;overflow:auto}
55
56
  .feedback-thread-actions{display:flex;justify-content:space-between;align-items:center;margin-top:8px;gap:8px}
@@ -115,6 +116,8 @@ ${Yt}
115
116
  .feedback-page-routes{display:flex;flex-direction:column;gap:2px;min-height:0;max-height:min(240px,30dvh);overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:var(--chisel-ui-scrollbar) transparent}
116
117
  .feedback-page-routes button{display:flex;align-items:center;gap:8px;width:100%;min-height:40px;padding:0 8px;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-secondary)}
117
118
  .feedback-page-routes button[aria-current=page]{background:var(--chisel-ui-selected);color:var(--chisel-ui-text)}
119
+ .feedback-page-routes mark{background:var(--chisel-ui-selected);color:var(--chisel-ui-text);border-radius:2px;font-weight:700}
120
+ .feedback-page-empty{margin:0;padding:10px 8px;color:var(--chisel-ui-secondary);font-size:12px}
118
121
  .feedback-page-control button:hover{background:var(--chisel-ui-hover);color:var(--chisel-ui-text)}
119
122
  .feedback-page-control button:disabled{opacity:.5}
120
123
  .feedback-page-control button:active{transform:scale(.96)}
@@ -290,6 +293,11 @@ ${Yt}
290
293
  .comment-thread .feedback-thread-summary,.comment-thread .feedback-thread-replies,.comment-thread form{width:100%;flex-shrink:0}
291
294
  .comment-thread .feedback-preview{white-space:nowrap}
292
295
  .feedback-thread-summary{display:flex;align-items:flex-start;gap:8px;flex-shrink:0}
296
+ .feedback-thread-summary,.feedback-thread-reply{position:relative}
297
+ .feedback-message-edit{display:grid;place-items:center;width:40px;height:40px;flex-shrink:0;padding:0;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-secondary);opacity:0;transition:opacity 120ms,background 120ms}
298
+ .feedback-thread-summary:hover .feedback-message-edit,.feedback-thread-reply:hover .feedback-message-edit,.feedback-message-edit:focus-visible{opacity:1}
299
+ .feedback-message-edit:hover{background:var(--chisel-ui-hover)}
300
+ @media(hover:none){.feedback-message-edit{opacity:1}}
293
301
  .feedback-thread-summary-button{display:flex;align-items:flex-start;gap:10px;flex:1;min-width:0;border:0;padding:0;text-align:left;background:transparent;color:inherit}
294
302
  .feedback-thread-summary-button>.feedback-avatar{width:26px;height:26px;flex-shrink:0;margin-top:1px;font-size:10px}
295
303
  .feedback-thread-summary-copy{display:flex;flex-direction:column;gap:4px;min-width:0;flex:1}
@@ -331,12 +339,12 @@ ${Yt}
331
339
  @media(pointer:coarse){.feedback-toolbar button{height:44px}.feedback-tabs button,.feedback-account summary{min-width:44px}.feedback-review-invite summary{min-height:44px}.feedback-pin:after{content:"";position:absolute;inset:-2px;border-radius:inherit}.feedback-account summary,.feedback-review-invite button,.feedback-shell .feedback-primary{min-height:44px}.feedback-shell .comment-window-drag,.feedback-thread-header-actions .feedback-thread-close{width:44px;height:44px}.comment-box-footer{height:60px;min-height:60px}.comment-box-footer button{height:44px;width:44px}.comment-box-footer .comment-box-submit{width:44px}}
332
340
  @media(forced-colors:active){.feedback-sidebar-panel,.comment-box,.feedback-composer.comment-thread,.feedback-confirmation,.feedback-account>div{border:1px solid CanvasText;box-shadow:none;background:Canvas;color:CanvasText}.feedback-shell button[aria-pressed=true]{outline:1px solid Highlight;outline-offset:-2px}.feedback-shell input,.feedback-shell textarea,.comment-box-number{border:1px solid CanvasText}.feedback-avatar{border:1px solid CanvasText}}
333
341
 
334
- `;function Wa(){return To("style",{children:qo})}function Va(a,t){if(t.type==="create")return t.comment;let r=a.find(o=>o.id===t.id);if(!r)throw new Error("This comment no longer exists. Reload and try again.");switch(t.type){case"edit":return{...r,text:t.text,changes:t.changes};case"resolve":return{...r,resolved:t.resolved};case"reply":return{...r,replies:[...r.replies,t.reply]}}}function ua(a,t){return a.some(r=>r.id===t.id)?a.map(r=>r.id===t.id?t:r):[...a,t]}function Pa(a,t){return a.filter(r=>r.id!==t)}function Aa(a){let t=new Map;for(let r of[a,...a.replies]){if(typeof r=="string")continue;let o=r.authorId?`id:${r.authorId}`:`name:${r.author}`;t.has(o)||t.set(o,{author:r.author,authorImage:r.authorImage})}return[...t.values()]}function eo(a,t,r){let o=r.trim().toLocaleLowerCase();return a.filter(l=>(t==="all"||l.resolved===(t==="resolved"))&&[l.text,l.author,l.path,...(l.attachments??[]).map(f=>f.name),...l.replies.map(f=>typeof f=="string"?f:`${f.author} ${f.text}`)].some(f=>f.toLocaleLowerCase().includes(o)))}function ao(a,t=Date.now()){let r=Math.max(0,t-Date.parse(a));if(!Number.isFinite(r))return"";if(r<6e4)return"Just now";let[o,l]=r<36e5?["minute",6e4]:r<864e5?["hour",36e5]:["day",864e5];return new Intl.RelativeTimeFormat(void 0,{numeric:"always"}).format(-Math.floor(r/l),o)}var Xa="chisel-feedback-v1",Ba=process.env.NODE_ENV!=="production";function to(a,t){let r=`<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 40 40"><defs><filter id="shadow" x="-25%" y="-25%" width="150%" height="150%"><feDropShadow dx="0" dy="2" stdDeviation="2" flood-opacity=".16"/></filter></defs><path d="M4 20a16 16 0 1 1 16 16H4Z" fill="${a}" stroke="${t}" filter="url(#shadow)"/></svg>`;return`url("data:image/svg+xml,${encodeURIComponent(r)}") 3 3, crosshair`}function oo(a){for(let r of["data-chisel-id","data-ai-edit","data-component","id"]){let o=a.getAttribute(r);if(o){let l=`[${r}="${CSS.escape(o)}"]`,f=a.ownerDocument.querySelectorAll(l);if(f.length===1&&f[0]===a)return l}}let t=a.parentElement;return t?`${oo(t)} > :nth-child(${Array.from(t.children).indexOf(a)+1})`:a.tagName.toLowerCase()}function ro({user:a,validateSession:t,signOut:r,commentStore:o,canManageComments:l=!1,getReviewLink:f,collaboration:s,commentUI:p}){let{confirm:L,dialog:S}=jt(),k=z(null),[w,b]=T([]),[g,M]=T("/"),[F,G]=T(["/"]),[V,J]=T([]),[D,H]=T(Ba?"edit":"comment"),i=z(D),m=z(null),W=z(null),q=z(null),ee=z(!1),O=z(null),ae=z(""),xe=z(!1),te=z(null),N=z(null),we=z(null),[le,Me]=T(null),[Z,Oe]=T(!1),[Q,Ee]=T(!1),ye=z(Q);ye.current=Q;let[R,j]=T(null),[X,re]=T(null),v=z(X);v.current=X;let[h,y]=T(null),ne=z(h),P=z(!1);ne.current=h;let[ia,ue]=T(null),[K,uo]=T(null),[so,Fe]=T(null),[io,ze]=T(""),[Le,ce]=T(""),[Ne,fo]=T("open"),[fa,no]=T(""),[Ka,Y]=T(""),[$a,na]=T(!!o),[Re,ca]=T(!1),[pe,Za]=T(null),[ja,co]=T(""),[pa,_a]=T(!1),[Ja,ma]=T(""),ie=z(!1),ve=z(0),ha=z(null),Qa=z(!1),Ma=z(null),[Fa,Ya]=T({x:0,y:0});ae.current=Le,N.current||(N.current=Jt(()=>{let e=document.activeElement,d=m.current?.contains(e)&&e?.matches('input,textarea,[contenteditable="true"]');!O.current||ae.current.trim()||xe.current||d||tt()}));let n=w.find(e=>e.id===X),xa=pe?.type==="resolve"&&pe.id===n?.id?pe:null,et=xa?xa.resolved?"Resolving thread\u2026":"Reopening thread\u2026":n?.resolved?"Reopen thread":"Resolve thread";async function at(e=!1){if(!(!f||pa)){_a(!0),ma("");try{let d=await f(e);co(d);try{await navigator.clipboard.writeText(d),ma(e?"New link copied. The previous link no longer accepts new reviewers.":"Link copied. Your client can sign in with any Google account.")}catch{ma("Select and copy the review link below.")}}catch{ma("The review link could not be created. Please try again.")}finally{_a(!1)}}}async function tt(){if((ae.current.trim()||xe.current)&&!await Te()||(N.current?.cancel(),O.current=null,ee.current))return;ee.current=!0;let e=m.current?va(m.current,!0,q.current):null;q.current=e;let d=()=>{!ee.current||q.current!==e||(ee.current=!1,ge(),re(null),ce(""))};e?e.finished.then(d,()=>{}):d()}function Ra(){N.current?.cancel(),ee.current&&(ee.current=!1,q.current=m.current?va(m.current,!1,q.current):null)}function La(){q.current?.cancel(),q.current=null,ee.current=!1,Oe(!0)}async function po(e){if(!await Te()||ie.current)return;let d=null;try{d=e.selector?K?.querySelector(e.selector)??null:null}catch{}if(!d){Y("This element is no longer on the page. Its changes cannot be edited.");return}ge(),N.current?.cancel(),ce(""),te.current=null,j(e.id),ze(e.text),y(e)}function ot(e){N.current?.cancel(),!(h||e.path!==g||(Le.trim()||xe.current)&&X!==e.id)&&(X===e.id&&Z||(O.current=e.id,Ia(e,!0)))}function ge(){we.current?.(),we.current=null,Me(null)}async function Te(){return!ie.current&&(!(ne.current&&P.current)&&!ae.current.trim()&&!xe.current||await L({title:"Discard this draft?",description:"Your comment and unsaved preview changes will be discarded.",action:"Discard draft",danger:!0}))}async function ga(e){if(e===i.current||!await Te())return;N.current?.cancel(),O.current=null,ge(),H(e),i.current=e,y(null),j(null),ue(null),e==="comment"&&Ee(!1);let d=k.current?.contentDocument;d?.documentElement&&(d.documentElement.dataset.chiselMode=e,k.current?.contentWindow?.dispatchEvent(new Event("chisel:mode")));let c=new URL(window.location.href);c.searchParams.set("mode",e),window.history.replaceState(window.history.state,"",c)}function mo(){let e=k.current?.contentDocument;if(!e)return;let d=Array.from(e.querySelectorAll("a[href]:not([download])"),c=>Be(c.href,window.location.origin));J([...new Set(d.filter(c=>c!==null))])}async function ho(e){let d=Be(e,window.location.origin,g);if(!d)throw new Error("Enter a page path or URL from this site.");if(d===g)return!0;if(!await Te())return!1;let c=k.current?.contentWindow;return c?(N.current?.cancel(),O.current=null,ge(),y(null),j(null),re(null),ue(null),Fe(null),ze(""),ce(""),ha.current=null,te.current=null,P.current=!1,xe.current=!1,c.location.assign(d),!0):!1}function de(e){let d=null;try{d=e.selector?K?.querySelector(e.selector)??null:null}catch{}let c=d?.getBoundingClientRect();return{rect:c,x:c?c.left+c.width*(e.offsetX??0):e.x-Fa.x,y:c?c.top+c.height*(e.offsetY??0):e.y-Fa.y}}async function Ia(e,d=!1){let c=Be(e.path,window.location.origin);if(!c){Y("This comment's page cannot be opened in the preview.");return}if(!d&&!await Te()||(Ra(),d||s?.markRead(e.id),d||(La(),O.current=null),X===e.id&&g===e.path))return;Oe(!d),ge(),re(e.id),y(null),ue(null),Fe(e),ce(""),te.current=null;let C=k.current?.contentDocument;if(C?.documentElement&&e.selector&&(C.documentElement.dataset.chiselSelection=e.selector),g!==c){k.current?.contentWindow?.location.assign(c);return}let E=de(e);d||k.current?.contentWindow?.scrollTo({top:Math.max(0,E.y+Fa.y-180),behavior:"smooth"})}async function qe(e,d=[]){if(ie.current)return!1;ie.current=!0,ca(!0),Za(e),++ve.current;let c=e.type==="create"?e.comment.id:e.id,C=w.find($=>$.id===c),E=!1;try{if(e.type==="create"||e.type==="reply"){let A=e.type==="create"?{...e.comment,body:e.body,attachments:d,pending:!0}:Va(w,{...e,reply:{...e.reply,body:e.body,attachments:d,date:new Date().toISOString(),pending:!0}});b(U=>ua(U,{...A,pending:!0})),na(!1),Y(""),E=!0}if(!await t())throw new Error("Your session has expired. Reload this page to sign in again.");let $=o?await o.mutate(e):Va(w,e);return++ve.current,o||localStorage.setItem(Xa,JSON.stringify(ua(w,$))),b(A=>ua(A,$)),na(!1),Y(""),!0}catch($){return E&&b(A=>C?ua(A,C):Pa(A,c)),Y($ instanceof Error?$.message:"Your comment could not be saved. Your draft is still here; please try again."),!1}finally{ie.current=!1,ca(!1),Za(null)}}async function xo(e){if(!(ie.current||!await L({title:"Delete this comment?",description:"The comment and all its replies will be permanently deleted.",action:"Delete comment",danger:!0}))){ie.current=!0,ca(!0),++ve.current;try{if(!await t()){Y("Your session has expired. Reload this page to sign in again.");return}if(o){if(!o.delete)throw new Error("Comment deletion is unavailable");await o.delete(e.id)}else localStorage.setItem(Xa,JSON.stringify(Pa(w,e.id)));++ve.current,v.current===e.id&&(ge(),re(null),ce(""),Fe(null)),b(d=>Pa(d,e.id)),Y("")}catch{Y("The comment could not be deleted. Please try again.")}finally{ie.current=!1,ca(!1)}}}function Ta(){let e=k.current?.contentDocument,d=k.current?.contentWindow;if(!e?.documentElement||!d)return;let c=za(d);if(c===null||e===Ma.current)return;if(Ma.current=null,!Qa.current){if(Qa.current=!0,!o)try{let oe=JSON.parse(localStorage.getItem(Xa)||"[]");if(!Array.isArray(oe)||oe.some(qa=>typeof qa.id!="string"||typeof qa.text!="string"||!Array.isArray(qa.replies)))throw Error();b(oe)}catch{Y("Saved comments could not be loaded.")}let A=new URLSearchParams(window.location.search).get("mode"),U=A==="browse"?"view":A;U&&["edit","comment","view"].includes(U)&&(U!=="edit"||Ba)&&(H(U),i.current=U);let me=new URLSearchParams(window.location.search).get("path");if(me){let oe=Be(me,window.location.origin);if(!oe)Y("That preview page is invalid. Enter a URL from this site.");else if(oe!==c){if(oe.split("#")[0]!==c.split("#")[0]){Ma.current=e,d.location.replace(oe);return}d.location.replace(oe),c=oe}}}if(M(c),uo(e),!d.chiselReady){e.addEventListener("chisel:ready",Ta,{once:!0});return}let C=e.documentElement;if(C.dataset.feedbackBound)return;C.dataset.feedbackBound="true";let E=e.createElement("style");E.textContent=`
335
- html[data-chisel-mode="comment"]:not([data-chisel-comments-hidden="true"]) { --chisel-comment-cursor:${to("#ffffff","#e2e2e2")};cursor:var(--chisel-comment-cursor) !important; }
342
+ `;function Za(){return No("style",{children:Go})}function ja(a,t){if(t.type==="create")return t.comment;let r=a.find(o=>o.id===t.id);if(!r)throw new Error("This comment no longer exists. Reload and try again.");switch(t.type){case"edit":return{...r,text:t.text,changes:t.changes,...t.body===void 0?{}:{body:t.body}};case"edit_reply":return{...r,replies:r.replies.map(o=>typeof o!="string"&&o.id===t.replyId?{...o,text:t.text,body:t.body}:o)};case"resolve":return{...r,resolved:t.resolved};case"reply":return{...r,replies:[...r.replies,t.reply]}}}function fa(a,t){return a.some(r=>r.id===t.id)?a.map(r=>r.id===t.id?t:r):[...a,t]}function Ba(a,t){return a.filter(r=>r.id!==t)}function Ma(a){let t=new Map;for(let r of[a,...a.replies]){if(typeof r=="string")continue;let o=r.authorId?`id:${r.authorId}`:`name:${r.author}`;t.has(o)||t.set(o,{author:r.author,authorImage:r.authorImage})}return[...t.values()]}function so(a,t,r){let o=r.trim().toLocaleLowerCase();return a.filter(l=>(t==="all"||l.resolved===(t==="resolved"))&&[l.text,l.author,l.path,...(l.attachments??[]).map(n=>n.name),...l.replies.map(n=>typeof n=="string"?n:`${n.author} ${n.text}`)].some(n=>n.toLocaleLowerCase().includes(o)))}function io(a,t=Date.now()){let r=Math.max(0,t-Date.parse(a));if(!Number.isFinite(r))return"";if(r<6e4)return"Just now";let[o,l]=r<36e5?["minute",6e4]:r<864e5?["hour",36e5]:["day",864e5];return new Intl.RelativeTimeFormat(void 0,{numeric:"always"}).format(-Math.floor(r/l),o)}var _a="chisel-feedback-v1",Ra=process.env.NODE_ENV!=="production";function fo(a,t){let r=`<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 40 40"><defs><filter id="shadow" x="-25%" y="-25%" width="150%" height="150%"><feDropShadow dx="0" dy="2" stdDeviation="2" flood-opacity=".16"/></filter></defs><path d="M4 20a16 16 0 1 1 16 16H4Z" fill="${a}" stroke="${t}" filter="url(#shadow)"/></svg>`;return`url("data:image/svg+xml,${encodeURIComponent(r)}") 3 3, crosshair`}function no(a){for(let r of["data-chisel-id","data-ai-edit","data-component","id"]){let o=a.getAttribute(r);if(o){let l=`[${r}="${CSS.escape(o)}"]`,n=a.ownerDocument.querySelectorAll(l);if(n.length===1&&n[0]===a)return l}}let t=a.parentElement;return t?`${no(t)} > :nth-child(${Array.from(t.children).indexOf(a)+1})`:a.tagName.toLowerCase()}function co({user:a,validateSession:t,signOut:r,commentStore:o,canManageComments:l=!1,getReviewLink:n,collaboration:s,commentUI:c}){let{confirm:g,dialog:w}=to(),S=z(null),[y,k]=F([]),[I,R]=F("/"),[q,X]=F(["/"]),[K,ae]=F([]),[P,H]=F(Ra?"edit":"comment"),p=z(P),x=z(null),te=z(null),m=z(null),U=z(!1),T=z(null),G=z(""),Se=z(!1),V=z(!1),oe=z(null),W=z(null),pe=z(null),[we,He]=F(null),[Q,We]=F(!1),[re,Ve]=F(!1),E=z(re);E.current=re;let[$,ue]=F(null),[Z,v]=F(null),A=z(Z);A.current=Z;let[L,de]=F(null),B=z(L),Oe=z(!1);B.current=L;let[Ta,Le]=F(null),[j,mo]=F(null),[ho,Ee]=F(null),[xo,Xe]=F(""),[ye,ie]=F(""),[_,ge]=F(null);ke(()=>{ge(null),V.current=!1},[Z]);let[Ke,Lo]=F("open"),[ca,go]=F(""),[Ja,Y]=F(""),[Qa,pa]=F(!!o),[me,ma]=F(!1),[Ie,Ya]=F(null),[qa,et]=F(null),[at,Io]=F(""),[ha,tt]=F(!1),[ot,xa]=F(""),he=z(!1),Me=z(0),La=z(null),rt=z(!1),Ua=z(null),[Ha,dt]=F({x:0,y:0});G.current=ye,W.current||(W.current=ro(()=>{let e=document.activeElement,d=x.current?.contains(e)&&e?.matches('input,textarea,[contenteditable="true"]');!T.current||G.current.trim()||Se.current||V.current||d||st()}));let i=y.find(e=>e.id===Z),ga=Ie?.type==="resolve"&&Ie.id===i?.id?Ie:null,lt=ga?ga.resolved?"Resolving thread\u2026":"Reopening thread\u2026":i?.resolved?"Reopen thread":"Resolve thread";async function ut(e=!1){if(!(!n||ha)){tt(!0),xa("");try{let d=await n(e);Io(d);try{await navigator.clipboard.writeText(d),xa(e?"New link copied. The previous link no longer accepts new reviewers.":"Link copied. Your client can sign in with any Google account.")}catch{xa("Select and copy the review link below.")}}catch{xa("The review link could not be created. Please try again.")}finally{tt(!1)}}}async function st(){if((G.current.trim()||Se.current||V.current)&&!await fe()||(W.current?.cancel(),T.current=null,U.current))return;U.current=!0;let e=x.current?Aa(x.current,!0,m.current):null;m.current=e;let d=()=>{!U.current||m.current!==e||(U.current=!1,ve(),v(null),ie(""))};e?e.finished.then(d,()=>{}):d()}function Oa(){W.current?.cancel(),U.current&&(U.current=!1,m.current=x.current?Aa(x.current,!1,m.current):null)}function Ia(){m.current?.cancel(),m.current=null,U.current=!1,We(!0)}async function it(e){if(!await fe()||he.current)return;let d=null;try{d=e.selector?j?.querySelector(e.selector)??null:null}catch{}if(!d){Y("This element is no longer on the page. Its changes cannot be edited.");return}ve(),W.current?.cancel(),ie(""),oe.current=null,ue(e.id),Xe(e.text),de(e)}function ft(e){W.current?.cancel(),!(L||e.path!==I||(ye.trim()||Se.current||V.current)&&Z!==e.id)&&(Z===e.id&&Q||(T.current=e.id,ba(e,!0)))}function ve(){pe.current?.(),pe.current=null,He(null)}async function fe(){return!he.current&&(!(B.current&&Oe.current)&&!G.current.trim()&&!Se.current&&!V.current||await g({title:"Discard this draft?",description:"Your comment and unsaved preview changes will be discarded.",action:"Discard draft",danger:!0}))}async function Ca(e){if(e===p.current||!await fe())return;W.current?.cancel(),T.current=null,ve(),H(e),p.current=e,de(null),ue(null),Le(null),e==="comment"&&Ve(!1);let d=S.current?.contentDocument;d?.documentElement&&(d.documentElement.dataset.chiselMode=e,S.current?.contentWindow?.dispatchEvent(new Event("chisel:mode")));let f=new URL(window.location.href);f.searchParams.set("mode",e),window.history.replaceState(window.history.state,"",f)}function Co(){let e=S.current?.contentDocument;if(!e)return;let d=Array.from(e.querySelectorAll("a[href]:not([download])"),f=>qe(f.href,window.location.origin));ae([...new Set(d.filter(f=>f!==null))])}async function bo(e){let d=qe(e,window.location.origin,I);if(!d)throw new Error("Enter a page path or URL from this site.");if(d===I)return!0;if(!await fe())return!1;let f=S.current?.contentWindow;return f?(W.current?.cancel(),T.current=null,ve(),de(null),ue(null),v(null),Le(null),Ee(null),Xe(""),ie(""),La.current=null,oe.current=null,Oe.current=!1,Se.current=!1,f.location.assign(d),!0):!1}function se(e){let d=null;try{d=e.selector?j?.querySelector(e.selector)??null:null}catch{}let f=d?.getBoundingClientRect();return{rect:f,x:f?f.left+f.width*(e.offsetX??0):e.x-Ha.x,y:f?f.top+f.height*(e.offsetY??0):e.y-Ha.y}}async function ba(e,d=!1){let f=qe(e.path,window.location.origin);if(!f){Y("This comment's page cannot be opened in the preview.");return}if(!d&&!await fe()||(Oa(),d||s?.markRead(e.id),d||(Ia(),T.current=null),Z===e.id&&I===e.path))return;We(!d),ve(),v(e.id),de(null),Le(null),Ee(e),ie(""),oe.current=null;let b=S.current?.contentDocument;if(b?.documentElement&&e.selector&&(b.documentElement.dataset.chiselSelection=e.selector),I!==f){S.current?.contentWindow?.location.assign(f);return}let N=se(e);d||S.current?.contentWindow?.scrollTo({top:Math.max(0,N.y+Ha.y-180),behavior:"smooth"})}async function xe(e,d=[]){if(he.current)return!1;he.current=!0,ma(!0),Ya(e),++Me.current;let f=e.type==="create"?e.comment.id:e.id,b=y.find(J=>J.id===f),N=!1;try{if(e.type==="create"||e.type==="reply"){let D=e.type==="create"?{...e.comment,body:e.body,attachments:d,pending:!0}:ja(y,{...e,reply:{...e.reply,body:e.body,attachments:d,date:new Date().toISOString(),pending:!0}});k(O=>fa(O,{...D,pending:!0})),pa(!1),Y(""),N=!0}if(!await t())throw new Error("Your session has expired. Reload this page to sign in again.");let J=o?await o.mutate(e):ja(y,e);return++Me.current,o||localStorage.setItem(_a,JSON.stringify(fa(y,J))),k(D=>fa(D,J)),pa(!1),Y(""),!0}catch(J){return N&&k(D=>b?fa(D,b):Ba(D,f)),Y(J instanceof Error?J.message:"Your comment could not be saved. Your draft is still here; please try again."),!1}finally{he.current=!1,ma(!1),Ya(null)}}async function ko(e){if(!(he.current||!await g({title:"Delete this comment?",description:"The comment and all its replies will be permanently deleted.",action:"Delete comment",danger:!0}))){he.current=!0,ma(!0),et(e.id),Y(""),++Me.current;try{if(!await t()){Y("Your session has expired. Reload this page to sign in again.");return}if(o){if(!o.delete)throw new Error("Comment deletion is unavailable");await o.delete(e.id)}else localStorage.setItem(_a,JSON.stringify(Ba(y,e.id)));++Me.current,A.current===e.id&&(ve(),v(null),ie(""),Ee(null)),k(d=>Ba(d,e.id)),Y("")}catch{Y("The comment could not be deleted. Please try again.")}finally{he.current=!1,ma(!1),et(null)}}}function Ea(){let e=S.current?.contentDocument,d=S.current?.contentWindow;if(!e?.documentElement||!d)return;let f=Xa(d);if(f===null||e===Ua.current)return;if(Ua.current=null,!rt.current){if(rt.current=!0,!o)try{let le=JSON.parse(localStorage.getItem(_a)||"[]");if(!Array.isArray(le)||le.some(Na=>typeof Na.id!="string"||typeof Na.text!="string"||!Array.isArray(Na.replies)))throw Error();k(le)}catch{Y("Saved comments could not be loaded.")}let D=new URLSearchParams(window.location.search).get("mode"),O=D==="browse"?"view":D;O&&["edit","comment","view"].includes(O)&&(O!=="edit"||Ra)&&(H(O),p.current=O);let Ce=new URLSearchParams(window.location.search).get("path");if(Ce){let le=qe(Ce,window.location.origin);if(!le)Y("That preview page is invalid. Enter a URL from this site.");else if(le!==f){if(le.split("#")[0]!==f.split("#")[0]){Ua.current=e,d.location.replace(le);return}d.location.replace(le),f=le}}}if(R(f),mo(e),!d.chiselReady){e.addEventListener("chisel:ready",Ea,{once:!0});return}let b=e.documentElement;if(b.dataset.feedbackBound)return;b.dataset.feedbackBound="true";let N=e.createElement("style");N.textContent=`
343
+ html[data-chisel-mode="comment"]:not([data-chisel-comments-hidden="true"]) { --chisel-comment-cursor:${fo("#ffffff","#e2e2e2")};cursor:var(--chisel-comment-cursor) !important; }
336
344
  html[data-chisel-mode="comment"]:not([data-chisel-comments-hidden="true"]) :not([data-chisel-root], [data-chisel-root] *) { cursor:var(--chisel-comment-cursor) !important; }
337
345
  html[data-chisel-mode="comment"] [data-chisel-root] { cursor:auto; }
338
346
  @media(prefers-color-scheme:dark) {
339
- html[data-chisel-mode="comment"]:not([data-chisel-comments-hidden="true"]) { --chisel-comment-cursor:${to("#222222","#3c3c3c")}; }
347
+ html[data-chisel-mode="comment"]:not([data-chisel-comments-hidden="true"]) { --chisel-comment-cursor:${fo("#222222","#3c3c3c")}; }
340
348
  }
341
349
  html[data-chisel-mode="edit"] .chisel-panel-inner { border-radius:0;box-shadow:none; }
342
350
  @media(min-width:761px) {
@@ -348,7 +356,7 @@ ${Yt}
348
356
  @media(max-width:760px) {
349
357
  html[data-chisel-mode="edit"] .chisel-panel { left:0;right:0;bottom:0; }
350
358
  }
351
- `,e.head.append(E),C.dataset.chiselMode=i.current,C.dataset.chiselCommentsHidden=String(ye.current),d.dispatchEvent(new Event("chisel:mode")),d.addEventListener("chisel:selection",A=>{let U=A.detail;Fe(U),U.selector&&(C.dataset.chiselSelection=U.selector)});let $=()=>Ya({x:d.scrollX,y:d.scrollY});$(),d.addEventListener("scroll",$),d.addEventListener("resize",()=>{ue(null),$()}),e.addEventListener("scroll",()=>{ue(null),$()},!0),e.addEventListener("mousemove",A=>{let U=A.target;ue(i.current==="comment"&&!ye.current&&U?.nodeType===1?U.getBoundingClientRect():null)},!0),e.addEventListener("mouseleave",()=>ue(null)),e.addEventListener("keydown",A=>{A.key==="Escape"&&!ie.current&&(y(null),re(null),ue(null),Fe(null),delete C.dataset.chiselSelection)}),e.addEventListener("click",async A=>{let U=A.target;if(!U||U.nodeType!==1||U.closest("[data-chisel-root]")||i.current==="view"||i.current==="comment"&&ye.current||i.current==="comment"&&(A.preventDefault(),A.stopImmediatePropagation(),!await Te()))return;ge();let me=U.getBoundingClientRect(),oe={x:A.clientX+d.scrollX,y:A.clientY+d.scrollY,selector:oo(U),tag:U.tagName.toLowerCase(),offsetX:me.width?(A.clientX-me.left)/me.width:0,offsetY:me.height?(A.clientY-me.top)/me.height:0};Fe(oe),C.dataset.chiselSelection=oe.selector,i.current!=="edit"&&(A.preventDefault(),A.stopImmediatePropagation(),re(null),ze(""),ue(null),j(null),ha.current=crypto.randomUUID(),y(oe))},!0)}Se(()=>{let e=K?.defaultView;if(e)return Kt(e,d=>{if(!Be(d,window.location.origin))return;M(d),G(C=>C.includes(d)?C:[...C,d]);let c=new URL(window.location.href);d==="/"?c.searchParams.delete("path"):c.searchParams.set("path",d),window.history.replaceState(window.history.state,"",c)})},[K]),Se(()=>{K&&(K.documentElement.dataset.chiselCommentsHidden=String(Q))},[Q,K]),Se(()=>()=>N.current?.cancel(),[]),Se(()=>{if(!o)return;let e=!1,d,c=()=>{clearTimeout(d),d=setTimeout(()=>{d=void 0,C()},1e4)},C=async()=>{if(e||document.visibilityState==="hidden")return;if(ie.current){c();return}clearTimeout(d),d=void 0;let A=++ve.current;try{let U=await o.list();!e&&A===ve.current&&(clearTimeout(d),d=void 0,b(U),na(!1),Y(""))}catch{!e&&A===ve.current&&(na(!1),Y("Shared comments could not be loaded. Check your connection; retrying automatically."),c())}};C();let E=o.subscribe?.(()=>{C()}),$=o.subscribe?void 0:window.setInterval(()=>{C()},1e4);return window.addEventListener("focus",C),document.addEventListener("visibilitychange",C),()=>{e=!0,clearTimeout(d),E?.(),window.clearInterval($),window.removeEventListener("focus",C),document.removeEventListener("visibilitychange",C)}},[o]);let rt=s?.setPage;Se(()=>{rt?.(g)},[g,rt]),Da(()=>{let e=W.current;e&&(e.style.height="auto",e.style.height=`${e.scrollHeight+e.offsetHeight-e.clientHeight}px`)},[Le,Z,n?.id,Q,D,g]),Da(()=>{let e=k.current?.parentElement,d=e?.querySelector(".comment-box");if(!h||!e||!d||Q)return;let c=()=>{let E=Qt(de(h),{width:d.offsetWidth,height:d.offsetHeight},{width:e.clientWidth,height:e.clientHeight});d.style.left=`${E.left}px`,d.style.top=`${E.top}px`,d.style.maxHeight=`${E.maxHeight}px`};c();let C=new ResizeObserver(c);return C.observe(d),C.observe(e),()=>C.disconnect()}),Da(()=>{let e=m.current;if(!e||Q||q.current?.playState==="running")return;let d=e.parentElement?.parentElement,c=d?.clientHeight??356,C=d?.clientWidth??416,E=Number(e.dataset.pinX),$=Number(e.dataset.pinY),A=Z?Math.max(8,Math.min($-40,c-Math.min(340,c-16)-8)):Math.max(8,Math.min($+32-e.offsetHeight,c-e.offsetHeight-8)),U=Z?E+44:E;e.style.left=`${Math.max(8,Math.min(U,C-e.offsetWidth-8))}px`,e.style.top=`${A}px`,e.style.maxHeight=`${c-A-8}px`}),Da(()=>(ee.current=!1,q.current=m.current&&!Q?va(m.current):null,()=>{ee.current=!1,q.current?.cancel()}),[n?.id,!!h,D,Q,g]),Se(()=>{k.current?.contentDocument?.readyState==="complete"&&Ta()},[]),Se(()=>{let e=d=>{if(document.querySelector('dialog[open], [aria-modal="true"]'))return;let c=_t(d);if(!(!c||c===i.current||c==="edit"&&!Ba)){if(d.preventDefault(),d.stopPropagation(),c==="toggle-comments"){N.current?.cancel(),ge(),Ee(C=>!C);return}ga(c)}};return document.addEventListener("keydown",e,!0),K?.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0),K?.removeEventListener("keydown",e,!0)}},[K]),Se(()=>{if(!n||le!==n.id||h||D==="edit"||n.path!==g||!n.selector||!K)return;let e;try{e=K.querySelector(n.selector)}catch{e=null}if(!e){Me(null),Y("This element is no longer on the page. Its saved changes cannot be previewed.");return}let d=ka(e,n.changes??[]);return we.current=d,Ya({x:e.ownerDocument.defaultView.scrollX,y:e.ownerDocument.defaultView.scrollY}),d},[le,n,h,D,g,K]);let dt=eo(w,Ne,fa);return x("main",{"aria-label":"Chisel workspace",className:`feedback-shell ${p?.className??""} ${D==="edit"?"is-editing":""} ${Q?"comments-hidden":""}`,children:[u(Wa,{}),S,x("div",{className:"feedback-workspace",children:[x("section",{className:"feedback-canvas","aria-label":"Website preview",children:[x("div",{className:"feedback-viewport",children:[u("iframe",{ref:k,src:"/",title:"Website for feedback",onLoad:Ta}),x("div",{className:"feedback-comment-layer","data-hover-preview":!!(n&&!Z&&!h),hidden:Q,children:[h&&pe?.type!=="create"&&u("span",{className:"feedback-pin comment-box-draft-pin","aria-hidden":"true",style:{left:de(h).x,top:de(h).y}}),n&&!h&&D!=="edit"&&n.path===g&&x("section",{ref:m,"data-pin-x":de(n).x,"data-pin-y":de(n).y,"data-pin-width":40+(Math.min(Aa(n).length,4)-1)*20,"data-expanded":Z,onPointerEnter:()=>{ee.current||N.current?.cancel()},onPointerMove:Ra,onPointerLeave:()=>N.current?.schedule(),onFocus:Ra,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||N.current?.schedule()},"data-native-ui":!!p,className:"feedback-composer feedback-thread-popup comment-thread",role:"dialog","aria-label":"Comment thread",style:{left:`clamp(8px, ${de(n).x-4}px, calc(100% - 408px))`,top:`clamp(8px, ${de(n).y-4}px, calc(100% - ${Z?340:128}px))`},children:[!Z&&x("button",{type:"button",className:"feedback-hover-preview","aria-label":`Expand comment: ${n.text||n.attachments?.map(e=>e.name).join(", ")}`,onClick:()=>{Ia(n)},children:[u("span",{className:"feedback-avatar",children:n.authorImage?u("img",{src:n.authorImage,alt:"",width:24,height:24}):n.author.slice(0,1).toUpperCase()}),x("span",{className:"feedback-hover-copy",children:[x("span",{className:"feedback-hover-byline",children:[u("strong",{children:n.author}),u("time",{dateTime:n.date,children:ao(n.date)})]}),u("span",{className:"feedback-hover-message",children:n.text||n.attachments?.map(e=>e.name).join(", ")})]})]}),x("div",{className:"feedback-thread-content",hidden:!Z,children:[x("header",{className:"feedback-thread-header",children:[u(ra,{onMoveStart:()=>{O.current=null,N.current?.cancel(),La()}}),x("div",{className:"feedback-thread-header-actions",children:[n.authorId===a.id&&u("button",{className:"feedback-thread-close",type:"button",title:"Edit comment","aria-label":"Edit comment",disabled:!n.selector,onClick:()=>{po(n)},children:u(Qe,{size:16})}),u("button",{className:"feedback-thread-close",type:"button",title:et,"aria-label":et,"aria-busy":!!xa,disabled:Re||!!o&&!l&&n.authorId!==a.id,onClick:()=>{qe({type:"resolve",id:n.id,resolved:!n.resolved})},children:xa?u(be,{size:18,className:"chisel-spin"}):n.resolved?u(ea,{size:18}):u(Ce,{size:18})}),(!o||o.delete)&&(!o||n.authorId===a.id||l)&&u("button",{className:"feedback-thread-close feedback-thread-delete",type:"button",title:"Delete comment","aria-label":"Delete comment",disabled:Re,onClick:()=>{xo(n)},children:u(ke,{size:16})}),u("button",{className:"feedback-thread-close",type:"button",title:"Close thread","aria-label":"Close thread",onClick:tt,children:u(ta,{size:18})})]})]}),u("div",{className:"feedback-thread-summary",children:!p&&x("button",{type:"button",className:"feedback-thread-summary-button","aria-label":`Expand comment: ${n.text}`,"aria-expanded":Z,onClick:La,children:[u("span",{className:"feedback-avatar",children:n.authorImage?u("img",{src:n.authorImage,alt:"",width:27,height:27}):n.author.slice(0,1).toUpperCase()}),x("span",{className:"feedback-thread-summary-copy",children:[x("span",{className:"feedback-thread-byline",children:[u("strong",{children:n.author}),u("time",{dateTime:n.date,children:new Date(n.date).toLocaleDateString(void 0,{month:"short",day:"numeric"})})]}),u("span",{className:"feedback-thread-message",children:n.text}),!Z&&u("span",{className:"feedback-thread-reply-count",children:n.replies.length?`${n.replies.length} ${n.replies.length===1?"reply":"replies"}`:"Reply\u2026"})]})]})}),!!n.changes?.length&&u("div",{className:"feedback-proposal-actions",children:x("button",{type:"button",className:"feedback-preview","aria-pressed":le===n.id,disabled:!n.selector,onClick:()=>{Y(""),Me(le===n.id?null:n.id)},children:[u(Ke,{size:16}),le===n.id?"Exit preview":"Preview changes"]})}),(Z||p)&&u(sa,{children:p?p.renderThread({comment:n,expanded:Z,reply:Le,saving:Re,submittingReply:pe?.type==="reply"&&pe.id===n.id,canResolve:!o||l||n.authorId===a.id,replyAuthor:a,onAttachmentDraftChange:e=>{xe.current=e},onReplyText:e=>{ce(e),te.current=null},onReply:async(e,d,c,C)=>{if(!e.trim()&&!c?.length)return!1;let E=await qe({type:"reply",id:n.id,body:d,attachmentTokens:c,reply:{id:te.current??(te.current=crypto.randomUUID()),text:e.trimEnd(),author:a.name,authorId:a.id,authorImage:a.image}},C);return E&&(ce(""),te.current=null),E},onResolve:()=>{qe({type:"resolve",id:n.id,resolved:!n.resolved})},onExpand:La}):x(sa,{children:[u("div",{className:"feedback-thread-replies",children:n.replies.map((e,d)=>x("div",{className:"feedback-thread-reply",children:[u("span",{className:"feedback-avatar","aria-hidden":"true",children:(typeof e=="string"?"?":e.author.slice(0,1)).toUpperCase()}),x("div",{children:[typeof e!="string"&&u("strong",{children:e.author}),u("p",{children:typeof e=="string"?e:e.text})]})]},d))}),x("form",{hidden:pe?.type==="reply"&&pe.id===n.id,onSubmit:async e=>{e.preventDefault(),Le.trim()&&await qe({type:"reply",id:n.id,reply:{id:te.current??(te.current=crypto.randomUUID()),text:Le.trimEnd(),author:a.name,authorId:a.id,authorImage:a.image}})&&(ce(""),te.current=null)},children:[u("textarea",{ref:W,"aria-label":"Reply",rows:1,placeholder:"Write a reply\u2026",value:Le,maxLength:4e3,onChange:e=>{ce(e.target.value),te.current=null},disabled:Re,required:!0}),u("div",{className:"feedback-thread-actions",children:x("button",{type:"submit",className:"feedback-primary",disabled:Re||!Le.trim(),"aria-label":"Reply",children:["Reply ",u(Ve,{})]})})]})]})})]})]},n.id),D==="comment"&&[ia,de(h??n??so??{x:0,y:0}).rect].map((e,d)=>e&&u("div",{"data-testid":d===0?"element-hover":"element-selection",className:`feedback-element-box ${d===1?"is-selected":""}`,style:{left:e.left,top:e.top,width:e.width,height:e.height}},d)),D!=="edit"&&w.filter(e=>e.path===g&&!e.resolved).map(e=>{let d=Aa(e);return x("button",{"aria-label":`Open comment: ${e.text}`,title:d.map(c=>c.author).join(", "),className:`feedback-pin ${d.length>1?"feedback-pin-group":""} ${X===e.id?"selected":""}`,onPointerEnter:c=>{c.pointerType!=="touch"&&ot(e)},onPointerLeave:()=>N.current?.schedule(),style:{left:de(e).x,top:de(e).y},onClick:()=>Ia(e),children:[d.slice(0,3).map((c,C)=>u("span",{className:"feedback-avatar","aria-hidden":"true",children:c.authorImage?u("img",{src:c.authorImage,alt:"",width:24,height:24}):c.author.slice(0,1).toUpperCase()},C)),d.length>3&&x("span",{className:"feedback-avatar feedback-pin-more","aria-hidden":"true",children:["+",d.length-3]})]},e.id)}),h?.selector&&K?.querySelector(h.selector)&&u(Oa,{target:K.querySelector(h.selector),text:io,onText:ze,onDraftChange:e=>{P.current=e},hidden:pe?.type==="create",editing:!!R,commentId:R??void 0,renderComposer:p?.renderComposer,changes:w.find(e=>e.id===R)?.changes,hasExistingAttachments:!!w.find(e=>e.id===R)?.attachments?.length,onCancel:()=>{y(null),ze(""),j(null)},onPost:(e,d,c,C,E)=>R?qe({type:"edit",id:R,text:d,changes:e,body:c,attachmentTokens:C}):qe({type:"create",body:c,attachmentTokens:C,comment:{id:ha.current??(ha.current=crypto.randomUUID()),path:g,...h,text:d,author:a.name,authorId:a.id,authorImage:a.image,date:new Date().toISOString(),resolved:!1,replies:[],changes:e}},E),style:{left:de(h).x+44,top:de(h).y}},`${h.selector}:${h.x}:${h.y}`)]})]}),x("div",{className:"feedback-toolbar","aria-label":"Preview mode",children:[Ba&&x("button",{title:"Edit styles","aria-keyshortcuts":"E","aria-pressed":D==="edit",onClick:()=>ga("edit"),children:[u(De,{}),u("span",{children:"Edit"})]}),x("button",{title:"Add comments","aria-keyshortcuts":"C","aria-pressed":D==="comment",onClick:()=>ga("comment"),children:[u(Ue,{}),u("span",{children:"Comment"})]}),x("button",{title:"View website","aria-keyshortcuts":"V","aria-pressed":D==="view",onClick:()=>ga("view"),children:[u(Je,{}),u("span",{children:"View"})]})]})]}),u("aside",{className:"feedback-sidebar",hidden:D==="edit"||Q,children:x("div",{className:"feedback-sidebar-panel",children:[x("div",{className:"feedback-sidebar-title",children:[x("h1",{children:["Comments ",u("span",{children:w.length})]}),x("details",{className:"feedback-account",children:[u("summary",{title:`Signed in as ${a.name}`,"aria-label":`Account: ${a.name}`,children:u("span",{className:"feedback-avatar",children:a.image?u("img",{src:a.image,alt:"",width:27,height:27}):a.name.slice(0,1).toUpperCase()})}),x("div",{children:[u("strong",{children:a.name}),u("span",{children:a.email}),x("button",{onClick:async()=>{try{await r(),window.location.reload()}catch{Y("Sign out failed. Please try again.")}},children:[u(_e,{}),"Sign out"]})]})]})]}),x("label",{className:"feedback-search",children:[u(aa,{"aria-hidden":"true",size:18}),u("input",{type:"search","aria-label":"Search comments",placeholder:"Search",value:fa,onChange:e=>no(e.target.value)})]}),s&&(s.status!=="connected"||s.participants.length>0||s.unreadThreadIds.length>0)&&x("div",{className:"feedback-collaboration","aria-label":"Review activity",children:[s.status!=="connected"&&u("span",{role:"status",children:s.status==="connecting"||s.status==="initial"?"Connecting\u2026":"Reconnecting\u2026"}),u("div",{className:"feedback-reviewers",children:s.participants.map(e=>u("span",{className:"feedback-avatar",title:`${e.name} \xB7 ${e.path}`,"aria-label":`${e.name} is reviewing ${e.path}`,children:e.image?u("img",{src:e.image,alt:"",width:24,height:24}):e.name.slice(0,1).toUpperCase()},e.id))}),s.unreadThreadIds.length>0&&x("span",{className:"feedback-unread-count",children:[s.unreadThreadIds.length," unread"]})]}),u("div",{className:"feedback-tabs",role:"group","aria-label":"Filter comments",children:["open","resolved","all"].map(e=>u("button",{"aria-pressed":Ne===e,onClick:()=>fo(e),children:e[0].toUpperCase()+e.slice(1)},e))}),Ka&&u("p",{role:"alert",className:"feedback-error",children:Ka}),x("div",{className:"feedback-comment-list",children:[dt.map(e=>u("article",{onPointerEnter:d=>{d.pointerType!=="touch"&&ot(e)},onPointerLeave:()=>N.current?.schedule(),className:`feedback-comment ${X===e.id?"active":""}`,children:x("button",{className:"feedback-comment-main","aria-pressed":X===e.id,onClick:()=>Ia(e),children:[x("span",{className:"feedback-comment-heading",children:[u("span",{className:"feedback-avatar",children:e.authorImage?u("img",{src:e.authorImage,alt:"",width:28,height:28}):e.author.slice(0,1).toUpperCase()}),x("span",{className:"feedback-comment-identity",children:[x("span",{className:"feedback-comment-meta",children:[u("strong",{children:e.author}),e.pending?u("span",{role:"status",children:"Sending\u2026"}):u("time",{dateTime:e.date,children:new Date(e.date).toLocaleDateString(void 0,{month:"short",day:"numeric"})})]}),x("span",{className:"feedback-comment-status",children:[Ne==="all"&&x(sa,{children:[e.resolved?"Resolved":"Open",u("span",{"aria-hidden":"true",children:" \xB7 "})]}),u("span",{className:"feedback-comment-path",title:e.path,children:e.path})]})]}),s?.unreadThreadIds.includes(e.id)&&u("span",{className:"feedback-comment-unread-dot","aria-hidden":"true"})]}),u("span",{className:"feedback-comment-body",children:e.text||e.attachments?.map(d=>d.name).join(", ")}),(e.replies.length>0||s?.unreadThreadIds.includes(e.id))&&x("span",{className:"feedback-comment-activity",children:[e.replies.length>0&&x(sa,{children:[u("span",{className:"feedback-comment-avatars",children:Aa(e).slice(1,4).map((d,c)=>u("span",{className:"feedback-avatar",title:d.author,children:d.authorImage?u("img",{src:d.authorImage,alt:"",width:20,height:20}):d.author.slice(0,1).toUpperCase()},c))}),x("span",{className:"feedback-comment-reply-count",children:[e.replies.length," ",e.replies.length===1?"reply":"replies"]})]}),s?.unreadThreadIds.includes(e.id)&&u("span",{className:"feedback-unread-label",children:e.replies.length?"New replies":"Unread"})]})]})},e.id)),$a&&u("p",{role:"status",children:"Loading shared comments\u2026"}),!$a&&!dt.length&&x("div",{className:"feedback-empty",children:[u("span",{children:u(Ue,{size:30})}),u("h2",{children:fa.trim()?"No matching comments":Ne==="resolved"?"Nothing resolved yet":"No comments yet"}),u("p",{children:fa.trim()?"Try another name, phrase, or page.":Ne==="resolved"?"Resolved threads will appear here.":"Click anywhere on the page to leave your first comment."})]})]}),u(Na,{path:g,disabled:Re||!K,onNavigate:ho,onOpen:mo,routes:[...new Set([g,...F,...V,...w.map(e=>e.path)])].filter(e=>K&&Be(e,window.location.origin)).sort((e,d)=>e.localeCompare(d))}),f&&l&&x("details",{className:"feedback-review-invite",children:[x("summary",{children:[u(Ae,{"aria-hidden":"true"}),"Share review link"]}),x("form",{onSubmit:e=>{e.preventDefault(),at()},children:[u("p",{children:"Anyone with this link can sign in and review this website."}),u("button",{type:"submit",className:"feedback-primary",disabled:pa,children:pa?"Preparing link\u2026":"Copy review link"}),ja&&x(sa,{children:[u("input",{"aria-label":"Review link",value:ja,readOnly:!0,onFocus:e=>e.currentTarget.select()}),u("button",{type:"button",onClick:()=>{at(!0)},disabled:pa,children:"Replace invitation link"}),u("p",{children:"Replacing the link blocks new joins through the old link. Existing reviewers keep access."})]}),Ja&&u("p",{role:"status",children:Ja})]})]})]})})]})]})}import{jsx as Uo}from"react/jsx-runtime";import{useEffect as lo,useSyncExternalStore as Ho}from"react";import{Chisel as Oo}from"use-chisel";function Eo(a){return window.addEventListener("chisel:mode",a),()=>window.removeEventListener("chisel:mode",a)}function zo(){try{return window.self!==window.top&&window.parent.location.origin===window.location.origin&&window.parent.location.pathname==="/chisel"?document.documentElement.dataset.chiselMode??"view":"site"}catch{return"site"}}function No({projectName:a="Chisel"}){let t=Ho(Eo,zo,()=>"site");return lo(()=>{process.env.NEXT_PUBLIC_CHISEL_ENABLED!=="0"&&(window.chiselReady=!0,document.dispatchEvent(new Event("chisel:ready")))},[]),lo(()=>{if(t!=="edit")return;let r=window.setTimeout(()=>window.dispatchEvent(new Event("chisel:select")),50);return()=>window.clearTimeout(r)},[t]),t==="site"||process.env.NODE_ENV==="production"||process.env.NEXT_PUBLIC_CHISEL_ENABLED==="0"?null:Uo(Oo,{embedded:!0,enabled:t==="edit",projectName:a})}export{No as ChiselPreview,ro as ChiselWorkspace,Wa as ChiselWorkspaceStyles};
359
+ `,e.head.append(N),b.dataset.chiselMode=p.current,b.dataset.chiselCommentsHidden=String(E.current),d.dispatchEvent(new Event("chisel:mode")),d.addEventListener("chisel:selection",D=>{let O=D.detail;Ee(O),O.selector&&(b.dataset.chiselSelection=O.selector)});let J=()=>dt({x:d.scrollX,y:d.scrollY});J(),d.addEventListener("scroll",J),d.addEventListener("resize",()=>{Le(null),J()}),e.addEventListener("scroll",()=>{Le(null),J()},!0),e.addEventListener("mousemove",D=>{let O=D.target;Le(p.current==="comment"&&!E.current&&O?.nodeType===1?O.getBoundingClientRect():null)},!0),e.addEventListener("mouseleave",()=>Le(null)),e.addEventListener("keydown",D=>{D.key==="Escape"&&!he.current&&(de(null),v(null),Le(null),Ee(null),delete b.dataset.chiselSelection)}),e.addEventListener("click",async D=>{let O=D.target;if(!O||O.nodeType!==1||O.closest("[data-chisel-root]")||p.current==="view"||p.current==="comment"&&E.current||p.current==="comment"&&(D.preventDefault(),D.stopImmediatePropagation(),!await fe()))return;ve();let Ce=O.getBoundingClientRect(),le={x:D.clientX+d.scrollX,y:D.clientY+d.scrollY,selector:no(O),tag:O.tagName.toLowerCase(),offsetX:Ce.width?(D.clientX-Ce.left)/Ce.width:0,offsetY:Ce.height?(D.clientY-Ce.top)/Ce.height:0};Ee(le),b.dataset.chiselSelection=le.selector,p.current!=="edit"&&(D.preventDefault(),D.stopImmediatePropagation(),v(null),Xe(""),Le(null),ue(null),La.current=crypto.randomUUID(),de(le))},!0)}ke(()=>{let e=j?.defaultView;if(e)return Yt(e,d=>{if(!qe(d,window.location.origin))return;R(d),X(b=>b.includes(d)?b:[...b,d]);let f=new URL(window.location.href);d==="/"?f.searchParams.delete("path"):f.searchParams.set("path",d),window.history.replaceState(window.history.state,"",f)})},[j]),ke(()=>{j&&(j.documentElement.dataset.chiselCommentsHidden=String(re))},[re,j]),ke(()=>()=>W.current?.cancel(),[]),ke(()=>{if(!o)return;let e=!1,d,f=()=>{clearTimeout(d),d=setTimeout(()=>{d=void 0,b()},1e4)},b=async()=>{if(e||document.visibilityState==="hidden")return;if(he.current){f();return}clearTimeout(d),d=void 0;let D=++Me.current;try{let O=await o.list();!e&&D===Me.current&&(clearTimeout(d),d=void 0,k(O),pa(!1),Y(""))}catch{!e&&D===Me.current&&(pa(!1),Y("Shared comments could not be loaded. Check your connection; retrying automatically."),f())}};b();let N=o.subscribe?.(()=>{b()}),J=o.subscribe?void 0:window.setInterval(()=>{b()},1e4);return window.addEventListener("focus",b),document.addEventListener("visibilitychange",b),()=>{e=!0,clearTimeout(d),N?.(),window.clearInterval(J),window.removeEventListener("focus",b),document.removeEventListener("visibilitychange",b)}},[o]);let nt=s?.setPage;ke(()=>{nt?.(I)},[I,nt]),Fa(()=>{let e=te.current;e&&(e.style.height="auto",e.style.height=`${e.scrollHeight+e.offsetHeight-e.clientHeight}px`)},[ye,Q,i?.id,re,P,I]),Fa(()=>{let e=S.current?.parentElement,d=e?.querySelector(".comment-box");if(!L||!e||!d||re)return;let f=()=>{let N=lo(se(L),{width:d.offsetWidth,height:d.offsetHeight},{width:e.clientWidth,height:e.clientHeight});d.style.left=`${N.left}px`,d.style.top=`${N.top}px`,d.style.maxHeight=`${N.maxHeight}px`};f();let b=new ResizeObserver(f);return b.observe(d),b.observe(e),()=>b.disconnect()}),Fa(()=>{let e=x.current;if(!e||re||m.current?.playState==="running")return;let d=e.parentElement?.parentElement,f=d?.clientHeight??356,b=d?.clientWidth??416,N=Number(e.dataset.pinX),J=Number(e.dataset.pinY),D=Q?Math.max(8,Math.min(J-40,f-Math.min(340,f-16)-8)):Math.max(8,Math.min(J+32-e.offsetHeight,f-e.offsetHeight-8)),O=Q?N+44:N;e.style.left=`${Math.max(8,Math.min(O,b-e.offsetWidth-8))}px`,e.style.top=`${D}px`,e.style.maxHeight=`${f-D-8}px`}),Fa(()=>(U.current=!1,m.current=x.current&&!re?Aa(x.current):null,()=>{U.current=!1,m.current?.cancel()}),[i?.id,!!L,P,re,I]),ke(()=>{S.current?.contentDocument?.readyState==="complete"&&Ea()},[]),ke(()=>{let e=d=>{if(document.querySelector('dialog[open], [aria-modal="true"]'))return;let f=oo(d);if(!(!f||f===p.current||f==="edit"&&!Ra)){if(d.preventDefault(),d.stopPropagation(),f==="toggle-comments"){W.current?.cancel(),ve(),Ve(b=>!b);return}Ca(f)}};return document.addEventListener("keydown",e,!0),j?.addEventListener("keydown",e,!0),()=>{document.removeEventListener("keydown",e,!0),j?.removeEventListener("keydown",e,!0)}},[j]),ke(()=>{if(!i||we!==i.id||L||P==="edit"||i.path!==I||!i.selector||!j)return;let e;try{e=j.querySelector(i.selector)}catch{e=null}if(!e){He(null),Y("This element is no longer on the page. Its saved changes cannot be previewed.");return}let d=wa(e,i.changes??[]);return pe.current=d,dt({x:e.ownerDocument.defaultView.scrollX,y:e.ownerDocument.defaultView.scrollY}),d},[we,i,L,P,I,j]);let za=qa?y.filter(e=>e.id!==qa):y,ct=so(za,Ke,ca);return h("main",{"aria-label":"Chisel workspace",className:`feedback-shell ${c?.className??""} ${P==="edit"?"is-editing":""} ${re?"comments-hidden":""}`,children:[u(Za,{}),w,h("div",{className:"feedback-workspace",children:[h("section",{className:"feedback-canvas","aria-label":"Website preview",children:[h("div",{className:"feedback-viewport",children:[u("iframe",{ref:S,src:"/",title:"Website for feedback",onLoad:Ea}),h("div",{className:"feedback-comment-layer","data-hover-preview":!!(i&&!Q&&!L),hidden:re,children:[L&&Ie?.type!=="create"&&u("span",{className:"feedback-pin comment-box-draft-pin","aria-hidden":"true",style:{left:se(L).x,top:se(L).y}}),i&&!L&&P!=="edit"&&i.path===I&&h("section",{ref:x,hidden:qa===i.id,"data-pin-x":se(i).x,"data-pin-y":se(i).y,"data-pin-width":40+(Math.min(Ma(i).length,4)-1)*20,"data-expanded":Q,onPointerEnter:()=>{U.current||W.current?.cancel()},onPointerMove:Oa,onPointerLeave:()=>W.current?.schedule(),onFocus:Oa,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||W.current?.schedule()},"data-native-ui":!!c,className:"feedback-composer feedback-thread-popup comment-thread",role:"dialog","aria-label":"Comment thread",style:{left:`clamp(8px, ${se(i).x-4}px, calc(100% - 408px))`,top:`clamp(8px, ${se(i).y-4}px, calc(100% - ${Q?340:128}px))`},children:[!Q&&h("button",{type:"button",className:"feedback-hover-preview","aria-label":`Expand comment: ${i.text||i.attachments?.map(e=>e.name).join(", ")}`,onClick:()=>{ba(i)},children:[u("span",{className:"feedback-avatar",children:i.authorImage?u("img",{src:i.authorImage,alt:"",width:24,height:24}):i.author.slice(0,1).toUpperCase()}),h("span",{className:"feedback-hover-copy",children:[h("span",{className:"feedback-hover-byline",children:[u("strong",{children:i.author}),u("time",{dateTime:i.date,children:io(i.date)})]}),u("span",{className:"feedback-hover-message",children:i.text||i.attachments?.map(e=>e.name).join(", ")})]})]}),h("div",{className:"feedback-thread-content",hidden:!Q,children:[h("header",{className:"feedback-thread-header",children:[u(sa,{onMoveStart:()=>{T.current=null,W.current?.cancel(),Ia()}}),h("div",{className:"feedback-thread-header-actions",children:[u("button",{className:"feedback-thread-close",type:"button",title:lt,"aria-label":lt,"aria-busy":!!ga,disabled:me||!!o&&!l&&i.authorId!==a.id,onClick:()=>{xe({type:"resolve",id:i.id,resolved:!i.resolved})},children:ga?u(Ae,{size:18,className:"chisel-spin"}):i.resolved?u(ra,{size:18}):u(De,{size:18})}),(!o||o.delete)&&(!o||i.authorId===a.id||l)&&u("button",{className:"feedback-thread-close feedback-thread-delete",type:"button",title:"Delete comment","aria-label":"Delete comment",disabled:me,onClick:()=>{ko(i)},children:u(Be,{size:16})}),u("button",{className:"feedback-thread-close",type:"button",title:"Close thread","aria-label":"Close thread",onClick:st,children:u(la,{size:18})})]})]}),h("div",{className:"feedback-thread-summary",children:[!c&&_&&_.id===i.id?h("form",{onSubmit:async e=>{e.preventDefault(),await xe({type:"edit",id:i.id,text:_.text.trimEnd(),changes:i.changes??[]})&&(V.current=!1,ge(null))},children:[u("textarea",{"aria-label":"Edit comment",value:_.text,onChange:e=>{V.current=e.target.value!==_.original,ge({..._,text:e.target.value})}}),u("button",{type:"button",onClick:async()=>{V.current&&!await fe()||(V.current=!1,ge(null))},children:"Cancel"}),i.selector&&u("button",{type:"button",onClick:()=>{it(i)},children:"Edit styles"}),u("button",{type:"submit",disabled:me||!_.text.trim()&&!i.attachments?.length,children:"Save"})]}):!c&&h("button",{type:"button",className:"feedback-thread-summary-button","aria-label":`Expand comment: ${i.text}`,"aria-expanded":Q,onClick:Ia,children:[u("span",{className:"feedback-avatar",children:i.authorImage?u("img",{src:i.authorImage,alt:"",width:27,height:27}):i.author.slice(0,1).toUpperCase()}),h("span",{className:"feedback-thread-summary-copy",children:[h("span",{className:"feedback-thread-byline",children:[u("strong",{children:i.author}),u("time",{dateTime:i.date,children:new Date(i.date).toLocaleDateString(void 0,{month:"short",day:"numeric"})})]}),u("span",{className:"feedback-thread-message",children:i.text}),!Q&&u("span",{className:"feedback-thread-reply-count",children:i.replies.length?`${i.replies.length} ${i.replies.length===1?"reply":"replies"}`:"Reply\u2026"})]})]}),!c&&i.authorId===a.id&&_?.id!==i.id&&u("button",{className:"feedback-message-edit",type:"button",title:"Edit comment","aria-label":"Edit comment",disabled:me,onClick:async()=>{await fe()&&(ie(""),V.current=!1,ge({id:i.id,text:i.text,original:i.text}))},children:u(Ne,{size:16})})]}),!!i.changes?.length&&u("div",{className:"feedback-proposal-actions",children:h("button",{type:"button",className:"feedback-preview","aria-pressed":we===i.id,disabled:!i.selector,onClick:()=>{Y(""),He(we===i.id?null:i.id)},children:[u(Je,{size:16}),we===i.id?"Exit preview":"Preview changes"]})}),(Q||c)&&u(na,{children:c?c.renderThread({comment:i,expanded:Q,reply:ye,saving:me,submittingReply:Ie?.type==="reply"&&Ie.id===i.id,userId:a.id,onEditDraftChange:e=>{V.current=e},onDiscardEdit:fe,onBeginEdit:async()=>await fe()?(ie(""),oe.current=null,!0):!1,onEditStyles:i.selector?()=>{it(i)}:void 0,onEdit:(e,d,f)=>xe(e?{type:"edit_reply",id:i.id,replyId:e,text:d,body:f}:{type:"edit",id:i.id,text:d,changes:i.changes??[],body:f}),canResolve:!o||l||i.authorId===a.id,replyAuthor:a,onAttachmentDraftChange:e=>{Se.current=e},onReplyText:e=>{ie(e),oe.current=null},onReply:async(e,d,f,b)=>{if(!e.trim()&&!f?.length)return!1;let N=await xe({type:"reply",id:i.id,body:d,attachmentTokens:f,reply:{id:oe.current??(oe.current=crypto.randomUUID()),text:e.trimEnd(),author:a.name,authorId:a.id,authorImage:a.image}},b);return N&&(ie(""),oe.current=null),N},onResolve:()=>{xe({type:"resolve",id:i.id,resolved:!i.resolved})},onExpand:Ia}):h(na,{children:[u("div",{className:"feedback-thread-replies",children:i.replies.map((e,d)=>h("div",{className:"feedback-thread-reply",children:[u("span",{className:"feedback-avatar","aria-hidden":"true",children:(typeof e=="string"?"?":e.author.slice(0,1)).toUpperCase()}),h("div",{children:[typeof e!="string"&&u("strong",{children:e.author}),typeof e!="string"&&_&&_.id===e.id?h("form",{onSubmit:async f=>{f.preventDefault(),await xe({type:"edit_reply",id:i.id,replyId:_.id,text:_.text.trimEnd()})&&(V.current=!1,ge(null))},children:[u("textarea",{"aria-label":"Edit comment",value:_.text,onChange:f=>{V.current=f.target.value!==_.original,ge({..._,text:f.target.value})}}),u("button",{type:"button",onClick:async()=>{V.current&&!await fe()||(V.current=!1,ge(null))},children:"Cancel"}),u("button",{type:"submit",disabled:me||!_.text.trim()&&!e.attachments?.length,children:"Save"})]}):u("p",{children:typeof e=="string"?e:e.text})]}),typeof e!="string"&&e.id&&e.authorId===a.id&&_?.id!==e.id&&u("button",{className:"feedback-message-edit",type:"button",title:"Edit comment","aria-label":"Edit comment",disabled:me,onClick:async()=>{await fe()&&(ie(""),V.current=!1,ge({id:e.id,text:e.text,original:e.text}))},children:u(Ne,{size:16})})]},d))}),h("form",{hidden:Ie?.type==="reply"&&Ie.id===i.id,onSubmit:async e=>{e.preventDefault(),ye.trim()&&await xe({type:"reply",id:i.id,reply:{id:oe.current??(oe.current=crypto.randomUUID()),text:ye.trimEnd(),author:a.name,authorId:a.id,authorImage:a.image}})&&(ie(""),oe.current=null)},children:[u("textarea",{ref:te,"aria-label":"Reply",rows:1,placeholder:"Write a reply\u2026",value:ye,maxLength:4e3,onChange:e=>{ie(e.target.value),oe.current=null},disabled:me,required:!0}),u("div",{className:"feedback-thread-actions",children:h("button",{type:"submit",className:"feedback-primary",disabled:me||!ye.trim(),"aria-label":"Reply",children:["Reply ",u(je,{})]})})]})]})})]})]},i.id),P==="comment"&&[Ta,se(L??i??ho??{x:0,y:0}).rect].map((e,d)=>e&&u("div",{"data-testid":d===0?"element-hover":"element-selection",className:`feedback-element-box ${d===1?"is-selected":""}`,style:{left:e.left,top:e.top,width:e.width,height:e.height}},d)),P!=="edit"&&za.filter(e=>e.path===I&&!e.resolved).map(e=>{let d=Ma(e);return h("button",{"aria-label":`Open comment: ${e.text}`,title:d.map(f=>f.author).join(", "),className:`feedback-pin ${d.length>1?"feedback-pin-group":""} ${Z===e.id?"selected":""}`,onPointerEnter:f=>{f.pointerType!=="touch"&&ft(e)},onPointerLeave:()=>W.current?.schedule(),style:{left:se(e).x,top:se(e).y},onClick:()=>ba(e),children:[d.slice(0,3).map((f,b)=>u("span",{className:"feedback-avatar","aria-hidden":"true",children:f.authorImage?u("img",{src:f.authorImage,alt:"",width:24,height:24}):f.author.slice(0,1).toUpperCase()},b)),d.length>3&&h("span",{className:"feedback-avatar feedback-pin-more","aria-hidden":"true",children:["+",d.length-3]})]},e.id)}),L?.selector&&j?.querySelector(L.selector)&&u(Va,{target:j.querySelector(L.selector),text:xo,onText:Xe,onDraftChange:e=>{Oe.current=e},hidden:Ie?.type==="create",editing:!!$,commentId:$??void 0,renderComposer:c?.renderComposer,changes:y.find(e=>e.id===$)?.changes,hasExistingAttachments:!!y.find(e=>e.id===$)?.attachments?.length,onCancel:()=>{de(null),Xe(""),ue(null)},onPost:(e,d,f,b,N)=>$?xe({type:"edit",id:$,text:d,changes:e,body:f,attachmentTokens:b}):xe({type:"create",body:f,attachmentTokens:b,comment:{id:La.current??(La.current=crypto.randomUUID()),path:I,...L,text:d,author:a.name,authorId:a.id,authorImage:a.image,date:new Date().toISOString(),resolved:!1,replies:[],changes:e}},N),style:{left:se(L).x+44,top:se(L).y}},`${L.selector}:${L.x}:${L.y}`)]})]}),h("div",{className:"feedback-toolbar","aria-label":"Preview mode",children:[Ra&&h("button",{title:"Edit styles","aria-keyshortcuts":"E","aria-pressed":P==="edit",onClick:()=>Ca("edit"),children:[u(Te,{}),u("span",{children:"Edit"})]}),h("button",{title:"Add comments","aria-keyshortcuts":"C","aria-pressed":P==="comment",onClick:()=>Ca("comment"),children:[u(ze,{}),u("span",{children:"Comment"})]}),h("button",{title:"View website","aria-keyshortcuts":"V","aria-pressed":P==="view",onClick:()=>Ca("view"),children:[u(ta,{}),u("span",{children:"View"})]})]})]}),u("aside",{className:"feedback-sidebar",hidden:P==="edit"||re,children:h("div",{className:"feedback-sidebar-panel",children:[h("div",{className:"feedback-sidebar-title",children:[h("h1",{children:["Comments ",u("span",{children:za.length})]}),h("details",{className:"feedback-account",children:[u("summary",{title:`Signed in as ${a.name}`,"aria-label":`Account: ${a.name}`,children:u("span",{className:"feedback-avatar",children:a.image?u("img",{src:a.image,alt:"",width:27,height:27}):a.name.slice(0,1).toUpperCase()})}),h("div",{children:[u("strong",{children:a.name}),u("span",{children:a.email}),h("button",{onClick:async()=>{try{await r(),window.location.reload()}catch{Y("Sign out failed. Please try again.")}},children:[u(aa,{}),"Sign out"]})]})]})]}),h("label",{className:"feedback-search",children:[u(da,{"aria-hidden":"true",size:18}),u("input",{type:"search","aria-label":"Search comments",placeholder:"Search",value:ca,onChange:e=>go(e.target.value)})]}),s&&(s.status!=="connected"||s.participants.length>0||s.unreadThreadIds.length>0)&&h("div",{className:"feedback-collaboration","aria-label":"Review activity",children:[s.status!=="connected"&&u("span",{role:"status",children:s.status==="connecting"||s.status==="initial"?"Connecting\u2026":"Reconnecting\u2026"}),u("div",{className:"feedback-reviewers",children:s.participants.map(e=>u("span",{className:"feedback-avatar",title:`${e.name} \xB7 ${e.path}`,"aria-label":`${e.name} is reviewing ${e.path}`,children:e.image?u("img",{src:e.image,alt:"",width:24,height:24}):e.name.slice(0,1).toUpperCase()},e.id))}),s.unreadThreadIds.length>0&&h("span",{className:"feedback-unread-count",children:[s.unreadThreadIds.length," unread"]})]}),u("div",{className:"feedback-tabs",role:"group","aria-label":"Filter comments",children:["open","resolved","all"].map(e=>u("button",{"aria-pressed":Ke===e,onClick:()=>Lo(e),children:e[0].toUpperCase()+e.slice(1)},e))}),Ja&&u("p",{role:"alert",className:"feedback-error",children:Ja}),h("div",{className:"feedback-comment-list",children:[ct.map(e=>u("article",{onPointerEnter:d=>{d.pointerType!=="touch"&&ft(e)},onPointerLeave:()=>W.current?.schedule(),className:`feedback-comment ${Z===e.id?"active":""}`,children:h("button",{className:"feedback-comment-main","aria-pressed":Z===e.id,onClick:()=>ba(e),children:[h("span",{className:"feedback-comment-heading",children:[u("span",{className:"feedback-avatar",children:e.authorImage?u("img",{src:e.authorImage,alt:"",width:28,height:28}):e.author.slice(0,1).toUpperCase()}),h("span",{className:"feedback-comment-identity",children:[h("span",{className:"feedback-comment-meta",children:[u("strong",{children:e.author}),e.pending?u("span",{role:"status",children:"Sending\u2026"}):u("time",{dateTime:e.date,children:new Date(e.date).toLocaleDateString(void 0,{month:"short",day:"numeric"})})]}),h("span",{className:"feedback-comment-status",children:[Ke==="all"&&h(na,{children:[e.resolved?"Resolved":"Open",u("span",{"aria-hidden":"true",children:" \xB7 "})]}),u("span",{className:"feedback-comment-path",title:e.path,children:e.path})]})]}),s?.unreadThreadIds.includes(e.id)&&u("span",{className:"feedback-comment-unread-dot","aria-hidden":"true"})]}),u("span",{className:"feedback-comment-body",children:e.text||e.attachments?.map(d=>d.name).join(", ")}),(e.replies.length>0||s?.unreadThreadIds.includes(e.id))&&h("span",{className:"feedback-comment-activity",children:[e.replies.length>0&&h(na,{children:[u("span",{className:"feedback-comment-avatars",children:Ma(e).slice(1,4).map((d,f)=>u("span",{className:"feedback-avatar",title:d.author,children:d.authorImage?u("img",{src:d.authorImage,alt:"",width:20,height:20}):d.author.slice(0,1).toUpperCase()},f))}),h("span",{className:"feedback-comment-reply-count",children:[e.replies.length," ",e.replies.length===1?"reply":"replies"]})]}),s?.unreadThreadIds.includes(e.id)&&u("span",{className:"feedback-unread-label",children:e.replies.length?"New replies":"Unread"})]})]})},e.id)),Qa&&u("p",{role:"status",children:"Loading shared comments\u2026"}),!Qa&&!ct.length&&h("div",{className:"feedback-empty",children:[u("span",{children:u(ze,{size:30})}),u("h2",{children:ca.trim()?"No matching comments":Ke==="resolved"?"Nothing resolved yet":"No comments yet"}),u("p",{children:ca.trim()?"Try another name, phrase, or page.":Ke==="resolved"?"Resolved threads will appear here.":"Click anywhere on the page to leave your first comment."})]})]}),u(Ka,{path:I,disabled:me||!j,onNavigate:bo,onOpen:Co,routes:[...new Set([I,...q,...K,...y.map(e=>e.path)])].filter(e=>j&&qe(e,window.location.origin)).sort((e,d)=>e.localeCompare(d))}),n&&l&&h("details",{className:"feedback-review-invite",children:[h("summary",{children:[u(Re,{"aria-hidden":"true"}),"Share review link"]}),h("form",{onSubmit:e=>{e.preventDefault(),ut()},children:[u("p",{children:"Anyone with this link can sign in and review this website."}),u("button",{type:"submit",className:"feedback-primary",disabled:ha,children:ha?"Preparing link\u2026":"Copy review link"}),at&&h(na,{children:[u("input",{"aria-label":"Review link",value:at,readOnly:!0,onFocus:e=>e.currentTarget.select()}),u("button",{type:"button",onClick:()=>{ut(!0)},disabled:ha,children:"Replace invitation link"}),u("p",{children:"Replacing the link blocks new joins through the old link. Existing reviewers keep access."})]}),ot&&u("p",{role:"status",children:ot})]})]})]})})]})]})}import{jsx as Wo}from"react/jsx-runtime";import{useEffect as po,useSyncExternalStore as Vo}from"react";import{Chisel as Xo}from"use-chisel";function Ko(a){return window.addEventListener("chisel:mode",a),()=>window.removeEventListener("chisel:mode",a)}function $o(){try{return window.self!==window.top&&window.parent.location.origin===window.location.origin&&window.parent.location.pathname==="/chisel"?document.documentElement.dataset.chiselMode??"view":"site"}catch{return"site"}}function Zo({projectName:a="Chisel"}){let t=Vo(Ko,$o,()=>"site");return po(()=>{process.env.NEXT_PUBLIC_CHISEL_ENABLED!=="0"&&(window.chiselReady=!0,document.dispatchEvent(new Event("chisel:ready")))},[]),po(()=>{if(t!=="edit")return;let r=window.setTimeout(()=>window.dispatchEvent(new Event("chisel:select")),50);return()=>window.clearTimeout(r)},[t]),t==="site"||process.env.NODE_ENV==="production"||process.env.NEXT_PUBLIC_CHISEL_ENABLED==="0"?null:Wo(Xo,{embedded:!0,enabled:t==="edit",projectName:a})}export{Zo as ChiselPreview,co as ChiselWorkspace,Za as ChiselWorkspaceStyles};
352
360
  /*! Bundled license information:
353
361
 
354
362
  lucide-react/dist/esm/shared/src/utils/toKebabCase.mjs:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "use-chisel",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Dev-only visual editing layer for Next.js apps.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -25,6 +25,16 @@
25
25
  "chisel": "./bin/chisel.js"
26
26
  },
27
27
  "exports": {
28
+ "./review-ui.css": "./src/review/review-ui.css",
29
+ "./workspace-design.css": "./src/review/workspace-design.css",
30
+ "./review": {
31
+ "types": "./dist/review-entry.d.ts",
32
+ "import": "./dist/review-entry.js"
33
+ },
34
+ "./review-content": {
35
+ "types": "./dist/review-content-entry.d.ts",
36
+ "import": "./dist/review-content-entry.js"
37
+ },
28
38
  "./hosted": {
29
39
  "types": "./dist/hosted-entry.d.ts",
30
40
  "import": "./dist/hosted-entry.js"
@@ -43,6 +53,9 @@
43
53
  "dist/index.js",
44
54
  "dist/workspace-entry.js",
45
55
  "dist/hosted-entry.js",
56
+ "dist/review-entry.js",
57
+ "dist/review-content-entry.js",
58
+ "src/review/*.css",
46
59
  "dist/**/*.d.ts",
47
60
  "README.md"
48
61
  ],
@@ -50,7 +63,7 @@
50
63
  "access": "public"
51
64
  },
52
65
  "scripts": {
53
- "build": "tsc -p tsconfig.json && esbuild dist/index.js dist/workspace-entry.js dist/hosted-entry.js --bundle --minify --format=esm --platform=browser --external:react --external:react/jsx-runtime --external:react-dom --external:use-chisel --define:process.env.NODE_ENV=process.env.NODE_ENV --outdir=dist --allow-overwrite",
66
+ "build": "tsc -p tsconfig.json && node -e \"const fs=require('node:fs');for(const f of ['review-ui.css','workspace-design.css'])fs.copyFileSync('src/review/'+f,'dist/review/'+f)\" && esbuild dist/index.js dist/workspace-entry.js dist/hosted-entry.js dist/review-entry.js dist/review-content-entry.js --bundle --minify --format=esm --platform=browser --loader:.css=text --external:react --external:react/jsx-runtime --external:react-dom --external:use-chisel --external:slate --external:slate-history --external:slate-react --define:process.env.NODE_ENV=process.env.NODE_ENV --outdir=dist --allow-overwrite",
54
67
  "prepack": "npm run build",
55
68
  "test": "vitest run",
56
69
  "typecheck": "tsc -p tsconfig.json --noEmit"
@@ -61,7 +74,10 @@
61
74
  "react-dom": ">=18 <20"
62
75
  },
63
76
  "dependencies": {
64
- "lucide-react": "^1.61.0"
77
+ "lucide-react": "^1.61.0",
78
+ "slate": "^0.110.2",
79
+ "slate-history": "^0.110.3",
80
+ "slate-react": "^0.110.3"
65
81
  },
66
82
  "devDependencies": {
67
83
  "@types/react": "^18.3.3",
@@ -0,0 +1,60 @@
1
+ .chisel-review{font-family:var(--chisel-ui-font);-webkit-font-smoothing:antialiased}
2
+ .chisel-review .comment-thread[data-native-ui=true]{padding:0;gap:0;border:0;border-radius:16px;background:var(--chisel-ui-surface);box-shadow:0 0 0 1px var(--chisel-ui-border),0 8px 32px #00000014;font-size:14px}
3
+ .chisel-review .comment-thread[data-native-ui=true] .feedback-preview{margin:4px 12px 0;border-radius:8px}
4
+ .chisel-review .comment-thread[data-native-ui=true] form{width:100%}
5
+ .chisel-review-thread-content{width:100%;min-width:0}
6
+ .chisel-review-message{display:flex;gap:12px;padding:16px}
7
+ .chisel-review-message-content{min-width:0;flex:1}
8
+ .chisel-review-avatar{width:32px;height:32px;flex-shrink:0}
9
+ .chisel-review-avatar img,.chisel-review .feedback-reply-avatar img{width:100%;height:100%;object-fit:cover;border-radius:inherit}
10
+ .chisel-review-byline{display:flex;gap:8px;flex-wrap:wrap;align-items:baseline;line-height:1.5}
11
+ .chisel-review-byline strong{font-weight:500}
12
+ .chisel-review-byline time{color:var(--chisel-ui-secondary);font-size:12px;font-variant-numeric:tabular-nums}
13
+ .chisel-rich-body{white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.5;color:var(--chisel-ui-text)}
14
+ .chisel-rich-body p,.chisel-rich-editor p{margin:0;min-height:1.5em}
15
+ .chisel-rich-body a,.chisel-rich-editor a{color:var(--chisel-ui-accent-text);text-decoration:underline;text-underline-offset:2px}
16
+ .chisel-rich-body code,.chisel-rich-editor code{font:0.9em ui-monospace,monospace;background:var(--chisel-ui-inset);padding:1px 3px;border-radius:4px}
17
+ .chisel-review .chisel-expand-thread{margin:0 16px 12px 60px;min-height:40px;padding:0;background:transparent;color:var(--chisel-ui-accent-text)}
18
+ .chisel-review-reply{display:flex;align-items:flex-start;gap:12px;padding:16px;border-top:1px solid var(--chisel-ui-border)}
19
+ .chisel-rich-editor{min-width:0;min-height:40px;max-height:min(180px,30dvh);overflow-y:auto;padding:8px;font-size:14px;line-height:1.5;outline:none;overflow-wrap:anywhere}
20
+ .chisel-review-reply .chisel-rich-editor{padding:12px 14px;min-height:44px}
21
+ .chisel-review .comment-box-native{border:0;border-radius:var(--chisel-ui-radius);box-shadow:0 0 0 1px var(--chisel-ui-border),0 8px 32px #00000014;font:inherit}
22
+ .chisel-review .comment-box-native>form{display:flex;flex-direction:column;min-height:0;height:100%;flex:1}
23
+ .chisel-review .comment-box-native .comment-box-prompt{align-items:flex-start;padding:8px;gap:0}
24
+ .chisel-review .comment-box-native .comment-box-symbol{margin-top:0;background:transparent;border-radius:8px}
25
+ .chisel-review .comment-box-native .comment-box-footer{background:var(--chisel-ui-surface);border-top:1px solid var(--chisel-ui-border)}
26
+ .chisel-review .comment-box-native .comment-box-cancel{border:0;border-radius:8px;background:transparent;font:inherit}
27
+ .chisel-review .comment-box-native .comment-box-submit{border-radius:8px;background:var(--chisel-ui-action);color:var(--chisel-ui-action-text)}
28
+ .chisel-review .comment-box-native .comment-box-element{background:var(--chisel-ui-inset)}
29
+ .chisel-review .comment-box-native .comment-box-properties{background:var(--chisel-ui-surface)}
30
+ .chisel-review .feedback-comment{border-radius:var(--chisel-ui-radius)}
31
+ .chisel-review .comment-thread[data-expanded=false] .chisel-rich-body{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:3;max-height:4.5em;overflow:hidden}
32
+ .chisel-review [data-slate-placeholder]{color:var(--chisel-ui-secondary);opacity:1!important}
33
+ .chisel-review .chisel-reply-field{position:relative;flex:1;min-width:0;border:1px solid var(--chisel-ui-border);border-radius:16px;background:var(--chisel-ui-raised)}
34
+ .chisel-review .chisel-reply-submit{position:absolute;right:4px;bottom:4px;display:grid;place-items:center;width:40px;height:40px;padding:0;border:0;border-radius:50%;background:var(--chisel-ui-action);color:var(--chisel-ui-action-text)}
35
+ .chisel-review .feedback-reply-avatar{width:32px;height:32px;margin-top:8px}
36
+ .chisel-composer-input{flex:1;min-width:0;max-height:min(320px,42dvh);overflow:auto}
37
+ .chisel-attachment-controls{display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:0 8px;font-size:12px;color:var(--chisel-ui-secondary)}
38
+ .chisel-review-reply .chisel-attachment-controls{padding-right:48px}
39
+ .chisel-formatting-tools button{display:grid;place-items:center;width:40px;height:40px;flex-shrink:0;padding:0;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-secondary);transition:background 150ms,scale 150ms}
40
+ .chisel-formatting-tools button:hover{background:var(--chisel-ui-hover)}
41
+ .chisel-formatting-tools button[aria-pressed=true]{color:var(--chisel-ui-accent-text);background:var(--chisel-ui-accent-surface)}
42
+ .chisel-formatting-tools{display:flex;gap:0;flex-wrap:wrap;padding:0 4px}
43
+ .chisel-formatting-tools button:active{scale:0.96}
44
+ .chisel-link-dialog{display:flex;flex-wrap:wrap;gap:6px;padding:8px;border-top:1px solid var(--chisel-ui-border);background:var(--chisel-ui-surface)}
45
+ .chisel-link-dialog label{flex:1;min-width:120px;font-size:12px;color:var(--chisel-ui-secondary)}
46
+ .chisel-link-dialog input{display:block;width:100%;height:40px;background:var(--chisel-ui-inset);border:1px solid var(--chisel-ui-border);border-radius:6px;color:var(--chisel-ui-text);padding:6px}
47
+ .chisel-link-dialog button{align-self:flex-end;min-height:40px;min-width:40px;padding:6px;border:0;border-radius:6px;background:var(--chisel-ui-hover);color:var(--chisel-ui-text)}
48
+ .chisel-link-dialog [role=alert]{width:100%;color:var(--chisel-ui-danger);font-size:12px}
49
+ .chisel-attachment-error{color:var(--chisel-ui-danger);line-height:1.5}
50
+ .chisel-attachment-previews{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding:8px;max-height:240px;overflow:auto}
51
+ .chisel-attachment-preview{position:relative;min-width:0;overflow:hidden;border:1px solid var(--chisel-ui-border);border-radius:8px;background:var(--chisel-ui-surface)}
52
+ .chisel-attachment-preview>img,.chisel-attachment-preview>a>img,.chisel-attachment-preview>video{display:block;width:100%;height:100px;object-fit:contain;background:var(--chisel-ui-inset);outline:1px solid #0000001a;outline-offset:-1px}
53
+ .chisel-attachment-preview>span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:8px;font-size:12px}
54
+ .chisel-attachment-preview>button:not(.review-media-thumbnail){position:absolute;top:0;right:0;display:grid;place-items:center;width:40px;height:40px;padding:0;border:0;border-radius:0 8px;background:var(--chisel-ui-surface);color:var(--chisel-ui-text)}
55
+ .chisel-attachment-preview>.chisel-attachment-retry{right:40px;border-radius:0 0 0 8px}
56
+ .chisel-attachment-preview>.chisel-attachment-load{position:static;width:100%;height:auto;min-height:100px;padding:8px}
57
+ .comment-thread .feedback-thread-header{position:sticky;top:0;z-index:1;background:var(--chisel-ui-surface)}
58
+ .chisel-review .comment-thread[data-native-ui=true][data-expanded=false]{border-radius:16px 16px 16px 0}
59
+ @media(prefers-color-scheme:dark){.chisel-attachment-preview>img,.chisel-attachment-preview>a>img,.chisel-attachment-preview>video{outline-color:#ffffff1a}}
60
+ @media(prefers-reduced-motion:reduce){.chisel-formatting-tools button{transition:none}}
@@ -0,0 +1,71 @@
1
+ /* Shared presentation for the owned review UI. */
2
+ .feedback-shell.chisel-review .comment-thread[data-native-ui=true],.feedback-shell.chisel-review .comment-box-native{border:0;border-radius:16px;background:var(--chisel-ui-surface);box-shadow:var(--chisel-ui-popover-shadow)}
3
+ .feedback-shell.chisel-review .comment-thread[data-expanded=false]{border-radius:16px 16px 16px 0}
4
+ .chisel-review-thread-content,.review-thread,.review-comment-content{width:100%;min-width:0}
5
+ .review-comment,.feedback-shell.chisel-review .chisel-review-message{display:flex;align-items:flex-start;gap:12px;padding:12px 20px}
6
+ .review-comment-content,.chisel-review-message-content{flex:1;min-width:0}
7
+ .review-comment-avatar{display:grid;place-items:center;flex-shrink:0;width:28px;height:28px;border-radius:50%;overflow:hidden;background:var(--chisel-ui-avatar);color:var(--chisel-ui-avatar-text);font-size:12px}
8
+ .review-comment-avatar img{width:100%;height:100%;object-fit:cover}
9
+ .review-comment-header,.chisel-review-byline{display:flex;align-items:baseline;flex-wrap:wrap;gap:8px;line-height:20px;margin-bottom:4px}
10
+ .review-comment-author{font-size:13px;font-weight:500;overflow-wrap:anywhere}
11
+ .review-comment-time{font-size:12px;color:var(--chisel-ui-muted);font-variant-numeric:tabular-nums;white-space:nowrap}
12
+ .review-comment-header{position:relative;padding-right:32px}
13
+ .review-comment-edit{position:absolute;right:-8px;top:-10px;display:grid;place-items:center;width:40px;height:40px;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-muted);opacity:0;transition:opacity 120ms,background 120ms}
14
+ .review-comment:hover .review-comment-edit,.review-comment:focus-within .review-comment-edit,.review-comment-edit:focus-visible{opacity:1}
15
+ .review-comment-edit:hover{background:var(--chisel-ui-hover);color:var(--chisel-ui-text)}
16
+ @media(hover:none){.review-comment-edit{opacity:1}}
17
+ .review-inline-edit{border:1px solid var(--chisel-ui-border);border-radius:10px;padding:8px}
18
+ .review-inline-edit-actions{display:flex;justify-content:flex-end;gap:6px;margin-top:8px}
19
+ .review-inline-edit-actions button{min-height:32px;padding:0 10px;border:0;border-radius:6px;background:var(--chisel-ui-hover);color:var(--chisel-ui-text)}
20
+ .review-comment-body,.chisel-rich-body{font-size:14px;line-height:21px;white-space:pre-wrap;overflow-wrap:anywhere}
21
+ .review-comment-body p{margin:0;min-height:21px}.review-comment-body p+p{margin-top:8px}
22
+ .review-comment-body a{color:var(--chisel-ui-accent-text);text-decoration:underline;text-underline-offset:3px}
23
+ .review-comment-body code{font:12px/1.5 ui-monospace,SFMono-Regular,monospace;background:var(--chisel-ui-inset);border-radius:4px;padding:2px 4px}
24
+ .review-composer{margin:0}
25
+ .feedback-shell.chisel-review .chisel-review-reply{display:flex;align-items:flex-start;gap:12px;border:0;padding:20px}
26
+ .feedback-shell.chisel-review .chisel-review-reply[hidden]{display:none}
27
+ .feedback-shell.chisel-review .feedback-reply-avatar{width:28px;height:28px;margin-top:8px}
28
+ .feedback-shell.chisel-review .chisel-reply-field{position:relative;flex:1;min-width:0;min-height:48px;border:0;border-radius:12px;background:var(--chisel-ui-raised)}
29
+ .review-composer-editor{min-width:0;min-height:40px;max-height:min(180px,30dvh);overflow:auto;padding:10px 12px;font-size:14px;line-height:21px;overflow-wrap:anywhere;outline:none}
30
+ .review-composer-editor p{margin:0}
31
+ .review-composer-editor>p,.chisel-rich-editor>p{position:relative}
32
+ .feedback-shell.chisel-review .chisel-review-reply :is(.review-composer-editor,.chisel-rich-editor){padding-right:56px}
33
+ .feedback-shell.chisel-review .chisel-reply-submit{position:absolute;right:4px;bottom:4px;display:grid;place-items:center;width:40px;height:40px;min-height:40px;padding:0;border:0;border-radius:8px;background:var(--chisel-ui-action);color:var(--chisel-ui-action-text)}
34
+ .chisel-reply-submit:disabled{opacity:.35}
35
+ .feedback-shell.chisel-review .comment-box-native>form{display:flex;flex-direction:column;flex:1;min-height:0;height:100%}
36
+ .feedback-shell.chisel-review .comment-box-native .comment-box-prompt{align-items:flex-start;padding:8px;gap:0}
37
+ .feedback-shell.chisel-review .comment-box-native .comment-box-footer{border:0;background:var(--chisel-ui-surface)}
38
+ .feedback-shell.chisel-review .comment-box-native .comment-box-element{background:var(--chisel-ui-raised)}
39
+ .feedback-shell.chisel-review .comment-box-native .comment-box-cancel{border:0;border-radius:8px;background:transparent}
40
+ .feedback-shell.chisel-review .comment-box-native .comment-box-cancel:hover{background:var(--chisel-ui-hover)}
41
+ .feedback-shell.chisel-review .comment-box-native .comment-box-submit{border-radius:8px}
42
+ .chisel-composer-input{flex:1;min-width:0;max-height:min(320px,42dvh);overflow:auto}
43
+ .chisel-attachment-controls{display:flex;align-items:center;flex-wrap:wrap;gap:8px;padding:0 8px;color:var(--chisel-ui-secondary);font-size:12px;line-height:18px}
44
+ .chisel-review-reply .chisel-attachment-controls{padding-right:48px}
45
+ .chisel-attachment-error{color:var(--chisel-ui-danger);line-height:1.5}
46
+ .chisel-attachment-previews,.review-attachments{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;padding:8px;max-height:240px;overflow:auto}
47
+ .review-attachments{padding:12px 0 0;max-height:none}
48
+ .feedback-shell.chisel-review .chisel-attachment-preview,.review-attachment{position:relative;min-width:0;margin:0;overflow:hidden;border:0;border-radius:8px;background:var(--chisel-ui-raised)}
49
+ .chisel-attachment-preview>img,.chisel-attachment-preview>video,.review-media-thumbnail img,.review-media-thumbnail video{display:block;width:100%;height:120px;object-fit:contain;background:var(--chisel-ui-inset)}
50
+ .review-attachment figcaption{padding:8px;font-size:12px;line-height:18px;overflow-wrap:anywhere}
51
+ .review-attachment-placeholder{min-height:100px;display:grid;place-items:center;padding:12px;color:var(--chisel-ui-secondary);font-size:12px}
52
+ .chisel-attachment-preview>button:not(.review-media-thumbnail){position:absolute;top:0;right:0;display:grid;place-items:center;width:40px;height:40px;padding:0;border:0;border-radius:0 8px;background:var(--chisel-ui-surface);color:var(--chisel-ui-text)}
53
+ .review-retry-upload{display:inline-flex;align-items:center;gap:6px;min-height:40px;padding:0 8px;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-text);font:inherit}
54
+ .review-retry-upload:hover{background:var(--chisel-ui-hover)}
55
+ .chisel-attachment-preview>span{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:8px;font-size:12px}
56
+ .feedback-shell.chisel-review .chisel-expand-thread{display:inline-flex;align-items:center;margin:0 20px 8px 60px;min-height:40px;padding:0;border:0;background:transparent;color:var(--chisel-ui-secondary);font-size:13px}
57
+ .chisel-review [data-slate-placeholder]{opacity:1!important;color:var(--chisel-ui-secondary)}
58
+ @media(pointer:coarse){.feedback-shell.chisel-review .chisel-reply-submit{width:44px;height:44px}.chisel-review-reply .chisel-attachment-controls{padding-right:52px}.feedback-shell.chisel-review .chisel-reply-field{min-height:52px}.feedback-shell.chisel-review .chisel-review-reply :is(.review-composer-editor,.chisel-rich-editor){padding-right:60px}}
59
+ @media(forced-colors:active){.feedback-shell.chisel-review .comment-thread[data-native-ui=true],.feedback-shell.chisel-review .comment-box-native,.feedback-shell.chisel-review .chisel-reply-field{border:1px solid CanvasText;box-shadow:none}.review-comment-avatar{border:1px solid CanvasText}}
60
+ .review-media-thumbnail{position:relative;display:block;width:100%;padding:0;border:0;background:var(--chisel-ui-inset);cursor:pointer}
61
+ .review-media-thumbnail img,.review-media-thumbnail video{display:block;width:100%;height:120px;object-fit:contain}
62
+ .review-media-play{position:absolute;inset:50% auto auto 50%;display:grid;place-items:center;width:40px;height:40px;border-radius:50%;background:#0009;color:white;transform:translate(-50%,-50%)}
63
+ .review-media-lightbox{position:fixed;inset:0;width:100vw;height:100dvh;max-width:none;max-height:none;margin:0;padding:24px;border:0;background:transparent;color:var(--chisel-ui-text)}
64
+ .review-media-lightbox::backdrop{background:#000b}
65
+ .review-media-lightbox-content{display:flex;flex-direction:column;width:min(100%,1000px);max-height:100%;margin:auto;border-radius:12px;overflow:hidden;background:var(--chisel-ui-surface);box-shadow:0 16px 48px #0006}
66
+ .review-media-lightbox-content header{display:flex;align-items:center;gap:12px;min-height:56px;padding:8px 12px 8px 16px}
67
+ .review-media-lightbox-content header span{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
68
+ .review-media-lightbox-content header a{color:var(--chisel-ui-text);font-size:13px}
69
+ .review-media-lightbox-content header button{display:grid;place-items:center;flex-shrink:0;width:40px;height:40px;padding:0;border:0;border-radius:8px;background:transparent;color:var(--chisel-ui-text)}
70
+ .review-media-lightbox-content header button:hover{background:var(--chisel-ui-hover)}
71
+ .review-media-lightbox-content>img,.review-media-lightbox-content>video{display:block;min-height:0;max-width:100%;max-height:calc(100dvh - 104px);margin:auto;object-fit:contain;background:#000}