notemend 0.1.14 → 0.1.16
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/.claude-plugin/plugin.json +1 -1
- package/bin/notemend.mjs +15 -15
- package/package.json +1 -1
- package/src/client/canvas.js +1 -0
- package/src/client/field-menu.js +1 -1
- package/src/client/markup.js +14 -14
- package/src/client/notemend.css +1 -1
- package/src/client/panel.js +39 -0
- package/src/client/review.js +8 -0
- package/src/client/run.js +52 -100
- package/src/client/turbo.js +1 -0
- package/src/server/middleware.mjs +1 -1
- package/src/store/categories.mjs +1 -1
- package/src/store/comments.mjs +3 -3
- package/src/store/thread.mjs +1 -1
- package/store.d.ts +3 -1
- package/thread.d.ts +17 -0
package/src/client/run.js
CHANGED
|
@@ -1,121 +1,73 @@
|
|
|
1
|
-
import{categoryOf as Te}from"../store/categories.mjs";import{stateOf as q,STATE_LABEL as ba}from"../store/status.mjs";import{AI_BOX as ya,AI_RAYS as va,agentLabel as $a,agentName as Us,agentOwner as Me,handleOf as wa,held as Ea,stageOf as te,threadOf as Sa,toAgent as W,workingOn as Vs}from"../store/thread.mjs";import{api as A,canvasCopy as La,host as Ta,imageUrl as Ma}from"./api";import{DEVTOOLS_DEVICES as Ys}from"../devtools-devices.mjs";import{drawDevice as xa,pageTints as ka,inkFor as Js}from"./devices";import{recentLogs as Ha}from"./logs";import{inspectors as Aa}from"./inspect";import{anchors as Na,clean as Lt}from"./anchor";import{bars as Ca,fieldMenus as Ba}from"./field-menu";import{esc as g}from"./markup";function Ua(p){const I=p.breakpoints,$n=p.categories,xe=(I.find(t=>!Number.isFinite(t.max))??I[0]).id,Bt=t=>I.find(e=>t>=e.min&&t<=e.max)?.id??xe,at=t=>t.breakpoint||xe,ee=t=>p.devices.find(e=>e.id===t),E=La,X=(t,e)=>{E||localStorage.setItem(t,e)},ke=t=>t.replace(/\/+$/,"")||"/";let z=ke(location.pathname);for(const t of document.querySelectorAll(".devtools .dt-icon[title]"))t.dataset.tip=t.title,t.getAttribute("aria-label")||t.setAttribute("aria-label",t.title),t.removeAttribute("title");const wn=document.querySelector(".dt-grid-btn"),ne=document.querySelector(".dt-grid-overlay"),En="dt-grid",He=t=>{ne.hidden=!t,wn.setAttribute("aria-pressed",String(t)),X(En,t?"1":"0"),P({grid:t})};wn.addEventListener("click",()=>He(ne.hidden===!0));const Sn=document.querySelector(".dt-pages-name"),Ln=()=>{let t=null;for(const s of document.querySelectorAll(".dt-pages a"))ke(new URL(s.href).pathname)===z?(s.setAttribute("aria-current","page"),t=s):s.removeAttribute("aria-current");const e=document.title.split("\u2014").pop()?.trim(),n=t?.querySelector(".dt-menu-label")?.textContent?.trim();Sn.textContent=n||e||Sn.textContent};Ln();const Tn=[...document.querySelectorAll(".devtools details")];let Ae=!1;const Rt=()=>{const t=Tn.filter(e=>e.open);for(const e of t)e.open=!1;return t};document.addEventListener("keydown",t=>{if(t.key!=="Escape")return;const[e]=Rt();e&&(e.querySelector("summary")?.focus(),t.preventDefault(),t.stopImmediatePropagation())},!0),document.addEventListener("pointerdown",t=>{Ae=Tn.some(e=>e.open&&!e.contains(t.target))&&Rt().length>0},!0),addEventListener("blur",Rt);const Tt=document.querySelector(".dt-pad-overlay"),Mn="dt-inspect",Xs=[".devtools",".dt-pad-overlay",".dt-grid-overlay",".dt-frame",".dt-history",".dt-review",".dt-field-menu",...p.ignore].join(", "),Ne=[".devtools",".dt-notes-overlay",".dt-history",".dt-frame",".dt-review",".dt-field-menu",'[aria-modal="true"]',...p.ignore].join(", "),Ce={pads:document.querySelector(".dt-pad-btn"),sizes:document.querySelector(".dt-size-btn"),type:document.querySelector(".dt-type-btn"),color:document.querySelector(".dt-color-btn"),border:document.querySelector(".dt-border-btn")};let it="",Be=0;const{spacer:Gs,drawPads:Zs,drawSize:Qs,drawType:to,drawColor:eo,drawBorder:no}=Aa(Tt),xn=t=>{Be||(Be=requestAnimationFrame(()=>{Be=0,Tt.hidden=!0;let e=document.elementFromPoint(t.clientX,t.clientY);if(Tt.hidden=!1,!e||e.closest(Xs)){Tt.innerHTML="";return}t.altKey&&e.parentElement&&e.parentElement!==document.body&&(e=e.parentElement),it==="sizes"?Qs(e):it==="type"?to(e):it==="color"?eo(e):it==="border"?no(e):Zs(t.altKey?e:Gs(e))}))},se=t=>{it=t;for(const[e,n]of Object.entries(Ce))n.setAttribute("aria-pressed",String(e===t));X(Mn,t),P({inspect:t}),Tt.hidden=!t,Tt.innerHTML="",t?document.addEventListener("mousemove",xn):document.removeEventListener("mousemove",xn)};for(const[t,e]of Object.entries(Ce))e.addEventListener("click",()=>{t!==it&&pt(!1),se(it===t?"":t)});const kn=document.querySelector(".dt-notes-btn"),Re=[...document.querySelectorAll(".dt-bp")],oe=document.querySelector(".dt-history-btn"),K=document.querySelector(".dt-history"),qe=document.querySelector(".dt-studio-btn"),L=document.querySelector(".dt-device"),Hn=document.querySelector(".dt-shell"),qt=document.querySelector('.dt-chrome[data-at="top"]'),ae=document.querySelector('.dt-chrome[data-at="bottom"]'),It=document.querySelector(".dt-ruler"),G=document.querySelector(".dt-devices"),ht=document.querySelector(".dt-notes-hi"),so=ht.querySelector(".dt-hi-box"),An=ht.querySelector(".dt-hi-tag"),oo=[...document.querySelectorAll(".dt-frame-handle")],Nn=document.querySelector(".dt-frame-size"),Ie=document.querySelector(".dt-frame-rotate"),Dt=document.querySelector(".dt-frame-bars"),B=document.querySelector(".dt-frame"),T=B.querySelector("iframe"),De=document.querySelector(".dt-notes-count"),b=document.querySelector(".dt-notes-overlay"),Cn=".devtools, .dt-tab, .dt-notes-overlay, .dt-history, .dt-frame",Bn=t=>{for(const e of["pointerdown","mousedown","pointerup","mouseup","touchstart","touchend","click","focusin","focusout"])t.addEventListener(e,n=>n.stopPropagation())};document.querySelectorAll(Cn).forEach(Bn);const Rn="dt-notes";let v=[],N=!1,w=null,d=null,Oe=0,U="",V=[],M=null,D=[];const ie=(t=d)=>!!(t&&(t.text?.trim()||t.images?.length)),Y=()=>{d&&ie()&&D.push(d),d=null};let Ot=null,rt=null;const qn=()=>`dt-draft:${z}${E?":canvas":""}`;let Mt=qn(),re=0;const Pe=()=>{if(!d&&!D.length&&!U){localStorage.removeItem(Mt);return}const t={draft:d,parked:D,reply:U?{for:Ot,text:U}:null};try{localStorage.setItem(Mt,JSON.stringify(t))}catch{const e=n=>({...n,images:void 0});try{localStorage.setItem(Mt,JSON.stringify({...t,draft:d&&e(d),parked:D.map(e)}))}catch{}}},ft=()=>{clearTimeout(re),re=setTimeout(Pe,200)};addEventListener("pagehide",()=>{clearTimeout(re),Pe()});let Z=localStorage.getItem("dt-resolved")!=="0";const ao=[[/Edg\/(\d+)/,"Edge"],[/OPR\/(\d+)/,"Opera"],[/Firefox\/(\d+)/,"Firefox"],[/Chrome\/(\d+)/,"Chrome"],[/Version\/(\d+).*Safari/,"Safari"]],io=[[/iPhone|iPad/,"iOS"],[/Android/,"Android"],[/Mac OS X/,"macOS"],[/Windows/,"Windows"],[/Linux/,"Linux"]],ro=()=>{const t=navigator.userAgent,e=a=>a.find(([r])=>r.test(t)),n=e(ao),s=e(io),o=n?n[0].exec(t)?.[1]:null;return[n?`${n[1]}${o?" "+o:""}`:"unknown browser",s?.[1]].filter(Boolean).join(" \xB7 ")},dt=()=>Bt(innerWidth),le=()=>rt??dt(),Pt=()=>{const t=le();for(const e of Re)e.setAttribute("aria-pressed",String(e.dataset.bp===t))},{cssPath:lo,poolOf:co,contextOf:uo,resolveEl:Q,anchorOf:mo}=Na(),de=new Map,tt=t=>{de.size||requestAnimationFrame(()=>de.clear());let e=de.get(t);return e===void 0&&(e=mo(t),de.set(t,e)),e},In=t=>{for(let e=t;e&&e!==document.body;e=e.parentElement)if(e.getAnimations().some(n=>n.playState==="running"))return!0;return!1};let ce=[];const Fe=t=>{for(const e of ce)e.play();ce=[];for(let e=t;e&&e!==document.body;e=e.parentElement)for(const n of e.getAnimations())n.playState==="running"&&(n.pause(),ce.push(n))},Dn=()=>{if(d)return Q(d);const t=w!=null?v.find(n=>n.id===w):null;if(!t)return null;const e=tt(t);return e&&!e.off?Q(t):null},On=t=>t?new Date(t).toLocaleString(void 0,{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}):"",xt='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M4 6h12M8 6V4.2h4V6M6.6 6l.55 9.8h5.7L13.4 6"/></svg>',Ft='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M4.8 10.4 8.2 13.8l7-7.6" stroke-linejoin="round"/></svg>',je='<svg viewBox="0 0 20 20" width="12" height="12" aria-hidden="true"><path d="M12.6 4.4l3 3-8.4 8.4H4.2v-3z" stroke-linejoin="round"/></svg>',ue='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M5.4 5.4l9.2 9.2M14.6 5.4l-9.2 9.2"/></svg>',po='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M12 5l-5 5 5 5" stroke-linejoin="round"/></svg>',go='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M8 5l5 5-5 5" stroke-linejoin="round"/></svg>',ho='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M4.5 8.5h7.5a3.5 3.5 0 0 1 0 7H8.5M7.5 5.5l-3 3 3 3" stroke-linejoin="round"/></svg>',ct=t=>`<svg viewBox="${ya}" width="${t}" height="${t}" aria-hidden="true" class="dt-claude"><path d="${va}" stroke-width="1.15" stroke-linecap="round"/></svg>`,jt=()=>p.me?`agent:${p.me.email}`:"claude",fo=()=>(p.team??[]).filter(t=>t.email!==p.me?.email),_e=()=>[...p.me?(p.team??[]).filter(t=>t.email===p.me.email):[],...fo()],Pn=(t,e,n=!1)=>{const s=W(t)?"agent":t?"person":"",o=[..._e().length||s==="person"?[["person",Qn,"A person"]]:[],["agent",ct(12),n?"Waits for the studio to approve it":"An agent \u2014 approves it for AI"]],a=bt(Fn());return a&&(o[0]=["person",me(a.avatar_url,a.name||a.email),`${a.name||a.email}`]),`<span class="dt-hand" role="radiogroup" aria-label="Who takes it">${o.map(([r,u,m])=>r===s?`<span class="dt-hand-stop dt-hand-stop--${r} is-on" role="radio" aria-checked="true" title="${g(m)}">${$o(t,e,r)}</span>`:`<button type="button" class="dt-hand-stop dt-hand-stop--${r}" role="radio" aria-checked="false" data-act="hand" data-v="${r}"${e?` data-id="${e}"`:""} title="${g(m)}"${r==="agent"&&n?" disabled":""}>${u}</button>`).join("")}</span>`},Fn=()=>{const t=_t();return t&&!W(t)&&_e().some(e=>e.email===t)?t:_e()[0]?.email??""},bo=()=>{const t=b.querySelector(".dt-hand .dt-hand-stop.is-on");return t?{rect:t.getBoundingClientRect(),ghost:t.cloneNode(!0)}:void 0},jn="cubic-bezier(0.32, 0.72, 0, 1)",_n=t=>{const e=b.querySelector(".dt-hand .dt-hand-stop.is-on");if(!t||!e||matchMedia("(prefers-reduced-motion: reduce)").matches)return;const n=e.getBoundingClientRect(),s=document.createElement("span");s.className="dt-hand dt-hand-ghost",s.style.cssText=`left:${t.rect.left}px;top:${t.rect.top}px;width:${t.rect.width}px;height:${t.rect.height}px`,t.ghost.querySelectorAll("select").forEach(o=>o.tabIndex=-1),s.append(t.ghost),b.append(s),s.animate([{opacity:1,filter:"blur(0)"},{opacity:0,filter:"blur(2px)"}],{duration:120,easing:"ease-out",fill:"forwards"}).finished.then(()=>s.remove(),()=>s.remove()),Je=performance.now()+480,e.animate([{transform:`translateX(${t.rect.left-n.left}px)`,width:`${t.rect.width}px`},{transform:"none",width:`${n.width}px`}],{duration:460,easing:jn});for(const o of e.children)o.animate([{opacity:0,transform:"scale(0.92)",filter:"blur(3px)"},{opacity:0,transform:"scale(0.92)",filter:"blur(3px)",offset:.4},{opacity:1,transform:"none",filter:"blur(0)"}],{duration:460,easing:jn});for(const o of e.parentElement?.querySelectorAll("button.dt-hand-stop")??[])o.animate([{opacity:0},{opacity:1}],{duration:300,delay:140,easing:"ease-out",fill:"backwards"})},yo=(t,e)=>{const n=_t(),s=Je>performance.now()?void 0:bo(),o=e==="agent"?W(n)?n:jt():e==="person"?Fn():"";if(!t){if(!d)return;d.assignee=o,d.stage=W(o)?"approved":!d.stage||d.stage==="approved"?"new":d.stage;try{localStorage.setItem("nm-for",o)}catch{}ft(),h(),_n(s);return}const a=v.find(m=>m.id===t),r=a?te(a):"new",u=W(o)?"approved":r==="approved"?"new":r;et(m=>m.map(i=>i.id===t?{...i,assignee:o||void 0,stage:u}:i),()=>A("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:t,assignee:o||null,stage:u})}),W(o)?"Approving it for the agent":"Reassigning"),_n(s)},_t=()=>{try{return localStorage.getItem("nm-for")??jt()}catch{return jt()}},Kt=t=>W(t)?"#d97757":t?"#0d99ff":"#717171",Ke=t=>t===p.me?.email?"you":p.team?.find(e=>e.email===t)?.name||t.split("@")[0],bt=t=>t?p.team?.find(e=>e.email===t):void 0,Kn=t=>{const e=Lt(t??"").split(/\s+/).filter(Boolean);return g(((e[0]?.[0]??"?")+(e.length>1?e[e.length-1][0]:"")).toUpperCase())},me=(t,e,n="dt-face")=>t?`<img class="${n}" src="${g(t)}" alt="">`:`<b class="${n}" aria-hidden="true">${Kn(e)}</b>`,vo=t=>{const e=bt(t.by);return e||t.byName?me(e?.avatar_url,e?.name||t.byName||t.by):""},Wn=t=>{const e=bt(t);return e?` data-face="${g(e.avatar_url??"")}" data-initial="${Kn(e.name||e.email)}"`:""},ut=(t,e)=>bt(e)?.agent_name||$a(t,e,Ke),zn=t=>{const e=bt(t);return e?me(e.avatar_url,e.name||e.email):""},Un=t=>{const e=bt(t)?.agent_avatar_url;return e?`<img class="dt-face" src="${g(e)}" alt="">`:`<b class="dt-face dt-face--ai" aria-hidden="true">${ct(12)}</b>`},$o=(t,e,n)=>{const s=(c,y,l=!1)=>`<option value="${g(c)}" data-c="${Kt(c)}"${W(c)?` data-icon="${g(Un(Me(c)))}"`:Wn(c||null)}${l?" data-sep":""}${t===c?" selected":""}>${g(y)}</option>`,o=(p.team??[]).filter(c=>c.email!==p.me?.email),a=n!=="person",r=n!=="agent",u=o.filter(c=>!p.studio||p.studio.includes(c.email)),m=Me(t)&&t!==jt()&&!u.some(c=>`agent:${c.email}`===t)?s(t,`${Ke(Me(t))}'s agent`):"",i=W(t)?Un(Me(t)):zn(t||null);return`<label class="dt-field" title="Who it is for"><span class="dt-field-box${i?" dt-field-box--face":""}" style="--cat:${Kt(t)}">${i}<select class="dt-for-select"${e?` data-id="${e}"`:""} aria-label="Who this is for">
|
|
2
|
-
${
|
|
3
|
-
${
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
${
|
|
7
|
-
${
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
aria-pressed="${!!t}" title="${t?"Shared with the client \u2014 click to keep it to the team":"Team only \u2014 click to share it with the client"}">${t?
|
|
11
|
-
${n.map(o=>`<option value="${
|
|
12
|
-
</select></span></label>`},es='<svg viewBox="0 0 20 20" width="9" height="9" aria-hidden="true"><path d="M5.5 5.5l9 9M14.5 5.5l-9 9"/></svg>',xo=!1,ko=!1,ns='<svg viewBox="0 0 12 12" width="10" height="10" aria-hidden="true"><path d="M3 1.8v8.4L10 6z"/></svg>',Ho='<svg viewBox="0 0 12 12" width="10" height="10" aria-hidden="true"><path d="M2.5 1.5h2.5v9H2.5zM7 1.5h2.5v9H7z"/></svg>',Ao=t=>`${Math.floor(t/60)}:${String(Math.floor(t%60)).padStart(2,"0")}`,No=(t,e)=>{const n=t.closest(".dt-voice"),s=n.querySelector("audio"),o=n.querySelector(".dt-voice-play");if(!s.dataset.wired){s.dataset.wired="1";const u=n.querySelector(".dt-voice-track i"),m=n.querySelector(".dt-voice-time"),i=()=>Number.isFinite(s.duration)?s.duration:0;s.addEventListener("timeupdate",()=>{u.style.transform=`scaleX(${i()?Math.min(1,s.currentTime/i()):0})`,m.textContent=Ao(s.currentTime)}),s.addEventListener("play",()=>{o.innerHTML=Ho,o.setAttribute("aria-label","Pause"),n.classList.add("is-playing")}),s.addEventListener("pause",()=>{o.innerHTML=ns,o.setAttribute("aria-label","Play the voice note"),n.classList.remove("is-playing")}),s.addEventListener("ended",()=>{s.currentTime=0})}const a=()=>{if(e){const u=n.querySelector(".dt-voice-track").getBoundingClientRect();Number.isFinite(s.duration)&&(s.currentTime=Math.max(0,Math.min(1,(e.clientX-u.left)/u.width))*s.duration);return}if(!s.paused){s.pause();return}b.querySelectorAll(".dt-voice audio").forEach(u=>{u!==s&&u.pause()}),s.play().catch(()=>{})};if(Number.isFinite(s.duration)||s.readyState<1){s.readyState<1?s.addEventListener("loadedmetadata",()=>Number.isFinite(s.duration)?a():r(),{once:!0}):a();return}r();function r(){s.addEventListener("timeupdate",()=>{s.currentTime=0,a()},{once:!0}),s.currentTime=1e9}},ze=t=>t.startsWith("data:audio/")||/(^|\/)voice-[^/?]*\.(webm|m4a)(\?|$)/i.test(t),ss=t=>t.startsWith("data:video/")||/\.webm(\?|$)/i.test(t),Wt=new Map,Co=t=>{if(!t.startsWith("data:"))return t;let e=Wt.get(t);if(!e){const[n,s]=t.split(",",2);if(e=URL.createObjectURL(new Blob([Uint8Array.from(atob(s),o=>o.charCodeAt(0))],{type:n.slice(5).split(";")[0]})),Wt.set(t,e),Wt.size>8){const[o,a]=Wt.entries().next().value;URL.revokeObjectURL(a),Wt.delete(o)}}return e},Bo=(t,e)=>`<span class="dt-voice"><button type="button" class="dt-voice-play" data-act="voice" aria-label="Play the voice note">${ns}</button><button type="button" class="dt-voice-track" data-act="voice-seek" aria-label="Jump"><i></i></button><span class="dt-voice-time">0:00</span><audio src="${Co(t)}" preload="metadata"></audio>${e===void 0?"":`<button class="dt-voice-rm" data-act="voice-write" ${e} aria-label="Write it out" title="Write it out \u2014 its words go in the box">${Ko}</button>`}${e===void 0?"":`<button class="dt-voice-rm" data-act="unshot" ${e} aria-label="Remove the recording" title="Remove the recording">${es}</button>`}</span>`,os=(t,e,n=t)=>ze(n)?Bo(t,e):`<span class="dt-shot${ss(n)?" dt-shot--video":""}">${ss(n)?`<video src="${t}" controls preload="metadata" playsinline></video>`:`<a href="${t}" target="_blank"><img src="${t}" alt="" loading="lazy" /></a>`}${e===void 0?"":`<button class="dt-shot-rm" data-act="unshot" ${e} aria-label="Remove">${es}</button>`}</span>`,as=(t=[],e)=>t.length?`<div class="dt-note-shots">${t.map(n=>{const s=n.split("/").pop(),o=Ma(s);return os(o,e===void 0?void 0:`data-id="${e}" data-img="${g(s)}"`,s)}).join("")}</div>`:"",is=(t=[])=>t.length?`<div class="dt-note-shots">${t.map((e,n)=>os(e,`data-i="${n}"`)).join("")}</div>`:"",Ro='<svg viewBox="0 0 20 20" width="15" height="15" aria-hidden="true"><rect x="2.5" y="5.5" width="11" height="9" rx="2"/><path d="m13.5 9 4-2.5v7l-4-2.5"/></svg>',qo='<svg viewBox="0 0 20 20" width="15" height="15" aria-hidden="true"><path d="M3.5 5.5h8M7.5 5.5v10M11 15.5l5-5 1.5 1.5-5 5H11z" stroke-linejoin="round"/></svg>',Io=!!navigator.mediaDevices?.getDisplayMedia&&typeof MediaRecorder<"u";let yt=null;const Do=async t=>{if(yt){yt.stop();return}let e;try{e=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:12},audio:!1})}catch{return}const n=await navigator.mediaDevices.getUserMedia({audio:!0}).catch(()=>null),s=new MediaStream([...e.getVideoTracks(),...n?.getAudioTracks()??[]]),o=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm"].find(i=>MediaRecorder.isTypeSupported(i));if(!o){for(const i of e.getTracks())i.stop();O("This browser cannot record WebM video.");return}const a=new MediaRecorder(s,{mimeType:o,videoBitsPerSecond:6e5,audioBitsPerSecond:32e3}),r=[],u=!!Number(t?.dataset.id);a.ondataavailable=i=>{i.data.size&&r.push(i.data)};const m=setTimeout(()=>{a.state!=="inactive"&&a.stop()},3e4);a.onstop=async()=>{clearTimeout(m);for(const y of[...e.getTracks(),...n?.getTracks()??[]])y.stop();yt=null;const i=new Blob(r,{type:"video/webm"});if(i.size>32e5){O("That recording is too big to send \u2014 keep it shorter."),h();return}const c=await new Promise(y=>{const l=new FileReader;l.onload=()=>y(String(l.result)),l.readAsDataURL(i)});u?V.push(c):d&&(d.images??=[]).push(c),h()},e.getVideoTracks()[0]?.addEventListener("ended",()=>{a.state!=="inactive"&&a.stop()}),yt=a,a.start(1e3),h()},Oo='<svg viewBox="0 0 20 20" width="15" height="15" aria-hidden="true"><rect x="7.5" y="3" width="5" height="9" rx="2.5"/><path d="M5 9.5a5 5 0 0 0 10 0M10 14.5V17"/></svg>',Po='<svg viewBox="0 0 20 20" width="14" height="14" aria-hidden="true"><path d="m5 10.5 3.2 3L15 6.5"/></svg>',Fo=90,Ue=32,jo=()=>!!p.voice&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<"u";let ge=!1;const _o=async(t,e)=>{if(ge||!t)return;const n=Number(t.dataset.id)||0;ge=!0,e.classList.add("is-asking"),e.title="Waiting for the microphone \u2014 allow it in the browser";let s;try{s=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(f){ge=!1,e.classList.remove("is-asking");const k=f?.name;O(k==="NotAllowedError"?"The microphone is blocked for this site \u2014 allow it from the icon left of the address, then try again.":k==="NotFoundError"?"No microphone found \u2014 plug one in or pick it in the system settings.":k==="NotReadableError"?"The microphone is busy in another app \u2014 close it there and try again.":`The microphone did not start: ${f?.message||k||"unknown error"}`);return}e.classList.remove("is-asking");const o=()=>b.querySelector(n?`.dt-note[data-id="${n}"] .dt-compose`:".dt-note[data-draft] .dt-compose"),a=document.createElement("div");a.className="dt-rec",a.innerHTML=`<button type="button" class="dt-rec-x" title="Discard (Esc)" aria-label="Discard">${xt}</button><span class="dt-rec-time"><i></i><b>0:00</b></span><span class="dt-rec-wave">${"<i></i>".repeat(Ue)}</span><button type="button" class="dt-rec-done" title="Done \u2014 write it out" aria-label="Done">${Po}</button>`;const r=a.querySelector("b"),u=[...a.querySelectorAll(".dt-rec-wave i")],m=new AudioContext,i=m.createAnalyser();i.fftSize=512,m.createMediaStreamSource(s).connect(i);const c=new Uint8Array(i.fftSize),y=[],l=new MediaRecorder(s,{audioBitsPerSecond:32e3}),$=[],x=Date.now();let j=!0;const H=setInterval(()=>{const f=o();f&&a.parentElement!==f&&f.appendChild(a),i.getByteTimeDomainData(c);let k=0;for(const Et of c)k+=((Et-128)/128)**2;y.push(Math.min(1,Math.sqrt(k/c.length)*4));const _=y.slice(-Ue);u.forEach((Et,St)=>{const Le=_[St-(Ue-_.length)];Et.style.transform=`scaleY(${Math.max(.1,Le??0).toFixed(2)})`,Et.classList.toggle("is-empty",Le===void 0)});const J=Math.floor((Date.now()-x)/1e3);r.textContent=`${Math.floor(J/60)}:${String(J%60).padStart(2,"0")}`,J>=Fo&&l.state!=="inactive"&&l.stop()},90),ot=f=>{j=f,l.state!=="inactive"&&l.stop()};a.querySelector(".dt-rec-x").addEventListener("click",f=>{f.stopPropagation(),ot(!1)}),a.querySelector(".dt-rec-done").addEventListener("click",f=>{f.stopPropagation(),ot(!0)}),a.addEventListener("keydown",f=>{f.key==="Escape"&&(f.stopPropagation(),ot(!1))}),l.ondataavailable=f=>{f.data.size&&$.push(f.data)},l.onstop=async()=>{if(clearInterval(H),s.getTracks().forEach(_=>_.stop()),m.close().catch(()=>{}),a.remove(),ge=!1,!j)return;const f=new Blob($,{type:l.mimeType||"audio/webm"}),k=await new Promise(_=>{const J=new FileReader;J.onload=()=>_(String(J.result)),J.readAsDataURL(f)});n?V.push(k):d&&(d.images??=[]).push(k),h(),o()?.querySelector("textarea")?.focus()},l.start(1e3),o()?.appendChild(a),a.querySelector(".dt-rec-done").focus()},rs="\u{1F3A4} Voice note",Ko='<svg viewBox="0 0 20 20" width="12" height="12" aria-hidden="true"><rect x="2.5" y="4.5" width="15" height="11" rx="2"/><path d="M6 11.5h3M11 11.5h3M6 8.5h8"/></svg>',Wo=async t=>{const e=t.closest(".dt-note"),s=(e?.hasAttribute("data-draft")?d?.images??[]:V)[Number(t.dataset.i)];if(!s||t.classList.contains("is-asking"))return;t.classList.add("is-asking");const o=await A("transcribe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({audio:s})}).catch(()=>null),a=o?await o.json().catch(()=>({})):{};if(t.classList.remove("is-asking"),!o?.ok||!a.text){O(a.error||(o?.ok?"Didn't hear any words in it.":"Could not make out the words \u2014 try again, or type it."));return}const r=e?.querySelector("textarea.dt-note-input, textarea.dt-note-reply-input");r&&(r.value=r.value.trim()?`${r.value.trimEnd()} ${a.text}`:a.text,r.dispatchEvent(new Event("input",{bubbles:!0})),r.focus())},zo='<svg viewBox="0 0 20 20" width="15" height="15" aria-hidden="true"><rect x="3" y="4" width="14" height="12" rx="2"/><circle cx="7.5" cy="8.5" r="1.4"/><path d="m3.5 14.5 4-4 3 3 2-2 4 4"/></svg>',ls=(t,e,n,s,o="",a="")=>`<div class="dt-note-foot"><div class="dt-compose">
|
|
13
|
-
<textarea class="${t}" rows="1" placeholder="${e}">${
|
|
1
|
+
import{categoryIcon as cs,categoryOf as Ie}from"../store/categories.mjs";import{stateOf as rt}from"../store/status.mjs";import{DOCS as Lt,STEP_RAYS as Vo,agentHandles as us,agentMentioned as ps,agentName as Jo,agentOwner as Go,agentStep as Jt,docOf as ms,docSlug as Xo,handleOf as Qo,held as Zo,stageOf as lt,threadOf as gs,toAgent as D,workingOn as Pe}from"../store/thread.mjs";import{api as L,canvasCopy as ta,host as ea,imageUrl as na}from"./api";import{recentLogs as sa}from"./logs";import{inspectors as oa}from"./inspect";import{anchors as aa,clean as ht}from"./anchor";import{bars as ia,fieldMenus as ra}from"./field-menu";import{AGENT_MARK as fs,CLAUDE_MARK as kt,CROSS as Fe,PENCIL as hs,TICK as Gt,TRASH as je,UNDO as bs,esc as m,stamp as la}from"./markup";import{canvas as da}from"./canvas";import{historyHtml as ca}from"./panel";import{review as ua}from"./review";import{turbo as pa}from"./turbo";function Ha(c){const dt=c.breakpoints,_e=c.categories,Xt=(dt.find(t=>!Number.isFinite(t.max))??dt[0]).id,Ke=t=>dt.find(e=>t>=e.min&&t<=e.max)?.id??Xt,J=t=>t.breakpoint||Xt,ys=t=>c.devices.find(e=>e.id===t),E=ta,G=(t,e)=>{E||localStorage.setItem(t,e)},Qt=t=>t.replace(/\/+$/,"")||"/";let j=Qt(location.pathname);for(const t of document.querySelectorAll(".devtools .dt-icon[title]"))t.dataset.tip=t.title,t.getAttribute("aria-label")||t.setAttribute("aria-label",t.title),t.removeAttribute("title");const We=document.querySelector(".dt-grid-btn"),xt=document.querySelector(".dt-grid-overlay"),Ue="dt-grid",Zt=t=>{xt.hidden=!t,We.setAttribute("aria-pressed",String(t)),G(Ue,t?"1":"0"),B({grid:t})};We.addEventListener("click",()=>Zt(xt.hidden===!0));const ze=document.querySelector(".dt-pages-name"),Ye=()=>{let t=null;for(const s of document.querySelectorAll(".dt-pages a"))Qt(new URL(s.href).pathname)===j?(s.setAttribute("aria-current","page"),t=s):s.removeAttribute("aria-current");const e=document.title.split("\u2014").pop()?.trim(),n=t?.querySelector(".dt-menu-label")?.textContent?.trim();ze.textContent=n||e||ze.textContent};Ye();const Ve=[...document.querySelectorAll(".devtools details")];let te=!1;const bt=()=>{const t=Ve.filter(e=>e.open);for(const e of t)e.open=!1;return t};document.addEventListener("keydown",t=>{if(t.key!=="Escape")return;const[e]=bt();e&&(e.querySelector("summary")?.focus(),t.preventDefault(),t.stopImmediatePropagation())},!0),document.addEventListener("pointerdown",t=>{te=Ve.some(e=>e.open&&!e.contains(t.target))&&bt().length>0},!0),addEventListener("blur",bt);const ct=document.querySelector(".dt-pad-overlay"),Je="dt-inspect",vs=[".devtools",".dt-pad-overlay",".dt-grid-overlay",".dt-frame",".dt-history",".dt-review",".dt-field-menu",...c.ignore].join(", "),ee=[".devtools",".dt-notes-overlay",".dt-history",".dt-frame",".dt-review",".dt-field-menu",'[aria-modal="true"]',...c.ignore].join(", "),ne={pads:document.querySelector(".dt-pad-btn"),sizes:document.querySelector(".dt-size-btn"),type:document.querySelector(".dt-type-btn"),color:document.querySelector(".dt-color-btn"),border:document.querySelector(".dt-border-btn")};let _="",se=0;const{spacer:$s,drawPads:ws,drawSize:Es,drawType:Ss,drawColor:Ts,drawBorder:Ms}=oa(ct),Ge=t=>{se||(se=requestAnimationFrame(()=>{se=0,ct.hidden=!0;let e=document.elementFromPoint(t.clientX,t.clientY);if(ct.hidden=!1,!e||e.closest(vs)){ct.innerHTML="";return}t.altKey&&e.parentElement&&e.parentElement!==document.body&&(e=e.parentElement),_==="sizes"?Es(e):_==="type"?Ss(e):_==="color"?Ts(e):_==="border"?Ms(e):ws(t.altKey?e:$s(e))}))},At=t=>{_=t;for(const[e,n]of Object.entries(ne))n.setAttribute("aria-pressed",String(e===t));G(Je,t),B({inspect:t}),ct.hidden=!t,ct.innerHTML="",t?document.addEventListener("mousemove",Ge):document.removeEventListener("mousemove",Ge)};for(const[t,e]of Object.entries(ne))e.addEventListener("click",()=>{t!==_&&Q(!1),At(_===t?"":t)});const Xe=document.querySelector(".dt-notes-btn"),oe=[...document.querySelectorAll(".dt-bp")],Ht=document.querySelector(".dt-history-btn"),H=document.querySelector(".dt-history"),ae=document.querySelector(".dt-studio-btn"),ie=document.querySelector(".dt-devices"),nt=document.querySelector(".dt-notes-hi"),Ls=nt.querySelector(".dt-hi-box"),Qe=nt.querySelector(".dt-hi-tag"),st=document.querySelector(".dt-frame"),Nt=st.querySelector("iframe"),re=document.querySelector(".dt-notes-count"),h=document.querySelector(".dt-notes-overlay"),Ze=".devtools, .dt-tab, .dt-notes-overlay, .dt-history, .dt-frame",tn=t=>{for(const e of["pointerdown","mousedown","pointerup","mouseup","touchstart","touchend","click","focusin","focusout"])t.addEventListener(e,n=>n.stopPropagation())};document.querySelectorAll(Ze).forEach(tn);const en="dt-notes";let b=[],x=!1,$=null,l=null,le=0,R="",O=[],T=null,A=[];const Ct=(t=l)=>!!(t&&(t.text?.trim()||t.images?.length)),K=()=>{l&&Ct()&&A.push(l),l=null};let yt=null,de=null;const nn=()=>`dt-draft:${j}${E?":canvas":""}`;let ut=nn(),Rt=0;const ce=()=>{if(!l&&!A.length&&!R){localStorage.removeItem(ut);return}const t={draft:l,parked:A,reply:R?{for:yt,text:R}:null};try{localStorage.setItem(ut,JSON.stringify(t))}catch{const e=n=>({...n,images:void 0});try{localStorage.setItem(ut,JSON.stringify({...t,draft:l&&e(l),parked:A.map(e)}))}catch{}}},ot=()=>{clearTimeout(Rt),Rt=setTimeout(ce,200)};addEventListener("pagehide",()=>{clearTimeout(Rt),ce()});let W=localStorage.getItem("dt-resolved")!=="0";const ks=[[/Edg\/(\d+)/,"Edge"],[/OPR\/(\d+)/,"Opera"],[/Firefox\/(\d+)/,"Firefox"],[/Chrome\/(\d+)/,"Chrome"],[/Version\/(\d+).*Safari/,"Safari"]],xs=[[/iPhone|iPad/,"iOS"],[/Android/,"Android"],[/Mac OS X/,"macOS"],[/Windows/,"Windows"],[/Linux/,"Linux"]],As=()=>{const t=navigator.userAgent,e=a=>a.find(([i])=>i.test(t)),n=e(ks),s=e(xs),o=n?n[0].exec(t)?.[1]:null;return[n?`${n[1]}${o?" "+o:""}`:"unknown browser",s?.[1]].filter(Boolean).join(" \xB7 ")},ue=()=>Ke(innerWidth),Ot=()=>de??ue(),sn=()=>{const t=Ot();for(const e of oe)e.setAttribute("aria-pressed",String(e.dataset.bp===t))},{cssPath:Hs,poolOf:Ns,contextOf:Cs,resolveEl:q,anchorOf:Rs}=aa(),Bt=new Map,I=t=>{Bt.size||requestAnimationFrame(()=>Bt.clear());let e=Bt.get(t);return e===void 0&&(e=Rs(t),Bt.set(t,e)),e},on=t=>{for(let e=t;e&&e!==document.body;e=e.parentElement)if(e.getAnimations().some(n=>n.playState==="running"))return!0;return!1};let Dt=[];const pe=t=>{for(const e of Dt)e.play();Dt=[];for(let e=t;e&&e!==document.body;e=e.parentElement)for(const n of e.getAnimations())n.playState==="running"&&(n.pause(),Dt.push(n))},an=()=>{if(l)return q(l);const t=$!=null?b.find(n=>n.id===$):null;if(!t)return null;const e=I(t);return e&&!e.off?q(t):null},Os="claude",Bs=()=>(c.team??[]).filter(t=>t.email!==c.me?.email),qt=()=>[...c.me?(c.team??[]).filter(t=>t.email===c.me.email):[],...Bs()],Ds='<svg viewBox="0 0 20 20" width="14" height="14" aria-hidden="true"><circle cx="10" cy="10" r="6.5" stroke-dasharray="2.4 2.4"/></svg>',qs=(t,e,n=!1)=>{const s=D(t)?"agent":t?"person":"nobody",o=$t(s==="person"?t:rn());return`<span class="dt-hand" role="radiogroup" aria-label="Who takes it">${[["person",o?Pt(o.avatar_url,o.name||o.email):wt,s==="person"?`${It(t)==="you"?"You":It(t)} \u2014 pick someone else`:o?`Give it to ${o.email===c.me?.email?"me":o.name||o.email}`:"A person"],["nobody",Ds,"Nobody \u2014 not anyone's yet"],["agent",kt(12),n?"Waits for the studio to approve it":s==="agent"?"Claude does it":"Give it to Claude"]].map(([i,d,u])=>i===s?`<span class="dt-hand-stop dt-hand-stop--${i} is-on" role="radio" aria-checked="true" data-tip="${m(u)}" aria-label="${m(u)}">${i==="person"?Ks(t,e):d}</span>`:`<button type="button" class="dt-hand-stop dt-hand-stop--${i}" role="radio" aria-checked="false" data-act="hand" data-v="${i}"${e?` data-id="${e}"`:""} data-tip="${m(u)}" aria-label="${m(u)}"${i==="agent"&&n?" disabled":""}>${d}</button>`).join("")}</span>`},rn=()=>{const t=Fs();return t&&!D(t)&&qt().some(e=>e.email===t)?t:qt()[0]?.email??""},Is=()=>{const t=h.querySelector(".dt-hand .dt-hand-stop.is-on");return t?{rect:t.getBoundingClientRect(),ghost:t.cloneNode(!0)}:void 0},ln="cubic-bezier(0.32, 0.72, 0, 1)",dn=t=>{const e=h.querySelector(".dt-hand .dt-hand-stop.is-on");if(!t||!e||matchMedia("(prefers-reduced-motion: reduce)").matches)return;const n=e.getBoundingClientRect(),s=document.createElement("span");s.className="dt-hand dt-hand-ghost",s.style.cssText=`left:${t.rect.left}px;top:${t.rect.top}px;width:${t.rect.width}px;height:${t.rect.height}px`,t.ghost.querySelectorAll("select").forEach(o=>o.tabIndex=-1),s.append(t.ghost),h.append(s),s.animate([{opacity:1,filter:"blur(0)"},{opacity:0,filter:"blur(2px)"}],{duration:120,easing:"ease-out",fill:"forwards"}).finished.then(()=>s.remove(),()=>s.remove()),Se=performance.now()+480,e.animate([{transform:`translateX(${t.rect.left-n.left}px)`,width:`${t.rect.width}px`},{transform:"none",width:`${n.width}px`}],{duration:460,easing:ln});for(const o of e.children)o.animate([{opacity:0,transform:"scale(0.92)",filter:"blur(3px)"},{opacity:0,transform:"scale(0.92)",filter:"blur(3px)",offset:.4},{opacity:1,transform:"none",filter:"blur(0)"}],{duration:460,easing:ln});for(const o of e.parentElement?.querySelectorAll("button.dt-hand-stop")??[])o.animate([{opacity:0},{opacity:1}],{duration:300,delay:140,easing:"ease-out",fill:"backwards"})},Ps=(t,e)=>{const n=Se>performance.now()?void 0:Is(),s=e==="agent"?Os:e==="person"?rn():e==="me"?c.me?.email??"":"";if(!t){if(!l)return;if(l.assignee=s,l.stage=D(s)?"approved":!l.stage||l.stage==="approved"?"new":l.stage,e==="person")try{localStorage.setItem("nm-for",s)}catch{}ot(),f(),dn(n);return}const o=b.find(d=>d.id===t);if(o&&Pe(o)&&!D(s)&&!confirm("Claude is still working on this \u2014 it may finish its changes after you take it. Take it anyway?"))return;const a=o?lt(o):"new",i=D(s)?"approved":a==="approved"?"new":a;P(d=>d.map(u=>u.id===t?{...u,assignee:s||void 0,stage:i}:u),()=>L("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:t,assignee:s||null,stage:i})}),D(s)?"Approving it for the agent":"Reassigning"),dn(n)},Fs=()=>{try{return localStorage.getItem("nm-for")??""}catch{return""}},vt=t=>D(t)?"#d97757":t?"#0d99ff":"#717171",It=t=>t===c.me?.email?"you":c.team?.find(e=>e.email===t)?.name||t.split("@")[0],$t=t=>t?c.team?.find(e=>e.email===t):void 0,cn=t=>{const e=ht(t??"").split(/\s+/).filter(Boolean);return m(((e[0]?.[0]??"?")+(e.length>1?e[e.length-1][0]:"")).toUpperCase())},Pt=(t,e,n="dt-face")=>t?`<img class="${n}" src="${m(t)}" alt="">`:`<b class="${n}" aria-hidden="true">${cn(e)}</b>`,js=t=>{const e=$t(t.by);return e||t.byName?Pt(e?.avatar_url,e?.name||t.byName||t.by):""},un=t=>{const e=$t(t);return e?` data-face="${m(e.avatar_url??"")}" data-initial="${cn(e.name||e.email)}"`:""},at=(t,e)=>Jo(t),pn=t=>{const e=$t(t);return e?Pt(e.avatar_url,e.name||e.email):""},_s=t=>{const e=$t(t)?.agent_avatar_url;return e?`<img class="dt-face" src="${m(e)}" alt="">`:`<b class="dt-face dt-face--ai" aria-hidden="true">${kt(12)}</b>`},Ks=(t,e)=>{const n=(o,a)=>`<option value="${m(o)}" data-c="${vt(o)}"${un(o||null)}${t===o?" selected":""}>${m(a)}</option>`,s=(c.team??[]).filter(o=>o.email!==c.me?.email);return`<label class="dt-field dt-field--knob"><span class="dt-field-box dt-field-box--face" style="--cat:${vt(t)}">${pn(t||null)||wt}<select class="dt-for-select"${e?` data-id="${e}"`:""} aria-label="Who does it">
|
|
2
|
+
${c.me?n(c.me.email,`Me \xB7 ${c.me.name||c.me.email}`):""}
|
|
3
|
+
${s.map(o=>n(o.email,o.name||o.email)).join("")}${t&&t!==c.me?.email&&!s.some(o=>o.email===t)?n(t,It(t)):""}
|
|
4
|
+
</select></span></label>`},mn=t=>{const e=ht(t?.textContent).replace(/\s+/g," ");return e&&e.length<=2e3?e:""},Ws=t=>`<div class="dt-suggest dt-suggest--read"><del>${m(t.from)}</del><ins>${m(t.to)}</ins></div>`,gn=(t,e)=>{const n=String(t??"").replace(/\s*>\s*/g," \u203A ").slice(-160);return m([n,ht(e??"")&&`\u201C${ht(e).slice(0,80)}\u201D`].filter(Boolean).join(" \xB7 "))},Us='<svg class="dt-chev" viewBox="0 0 12 12" width="9" height="9" aria-hidden="true"><path d="M3 4.5 6 7.5 9 4.5"/></svg>',zs=(t,e)=>{const n=Ie(t);return`<label class="dt-field dt-field--bare" data-tip="Type: ${m(n.label)}"><span class="dt-field-box">${cs(n)}<span class="dt-field-label">${m(n.label)}</span>${Us}<select class="dt-cat-select"${e?` data-id="${e}"`:""} aria-label="Type">${_e.map(s=>`<option value="${s.id}" data-c="${s.color}" data-icon="${m(cs(s))}"${s.id===t?" selected":""}>${s.label}</option>`).join("")}</select></span></label>`},me=[["new","New","#0d99ff",.25],["progress","In progress","#f5a623",.5],["review","Needs review","#8e4ec6",.75],["waiting","Waiting","#e93d82",.875]],ge=(t,e)=>{const s=2*Math.PI*e,o=8+3.3*Math.sin(s),a=8-3.3*Math.cos(s),i=`<path d="M8 8V${8-3.3}A${3.3} ${3.3} 0 ${e>.5?1:0} 1 ${o.toFixed(2)} ${a.toFixed(2)}Z" fill="${t}"/>`;return`<svg class="dt-stage-icon" viewBox="0 0 16 16" width="14" height="14" aria-hidden="true"><rect x="3.2" y="3.2" width="9.6" height="9.6" rx="2.4" transform="rotate(45 8 8)" fill="none" stroke="${t}" stroke-width="1.5"/>${i}</svg>`},fn=t=>Pe(t)||lt(t)==="progress"?"progress":lt(t)==="review"?"review":lt(t)==="waiting"?"waiting":"new",fe={queued:"new",working:"progress",stuck:"progress",asks:"waiting",review:"review",held:"new"},ma=(t,e)=>{const[,,n,s]=me.find(o=>o[0]===t)??["","","#30a46c",1];return`<span class="dt-status-chip" style="--cat:${n}" data-tip="${t==="done"?"Resolved":"Set by Claude's step"}">${ge(n,s)}<span>${e}</span></span>`},hn=[...me,["done","Resolved","#30a46c",1]],Ys=t=>{const e=Jt(t),n=t.status==="done"&&e!=="review"?"done":e&&fe[e]?fe[e]:fn(t),[,,s,o]=hn.find(a=>a[0]===n);return`<label class="dt-field" data-tip="${e&&fe[e]?"Follows Claude \u2014 or pick one":"Status"}"><span class="dt-field-box dt-field-box--icon" style="--cat:${s}">${ge(s,o)}<select class="dt-status-select" data-id="${t.id}" aria-label="Status">${hn.map(([a,i,d,u])=>`<option value="${a}" data-c="${d}" data-icon="${m(ge(d,u))}"${a===n?" selected":""}>${i}</option>`).join("")}</select></span></label>`},Vs=(t,e)=>{const n=b.find(a=>a.id===t);if(!n)return;if(e==="done"){pt(t,!0);return}const s=e==="new"?D(n.assignee)?"approved":"new":e,o=n.status==="done"?{status:"open",doneBy:null}:{};P(a=>a.map(i=>i.id===t?{...i,...o,stage:s}:i),()=>L("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:t,...o,stage:s})}),"Setting the status")},Ft=[["low","Low","#30a46c",1],["normal","Mid","#f5c451",2],["high","High","#ff5a00",3],["urgent","Urgent","#e5484d",4]],Js=(t,e)=>{const n=Math.max(0,Ft.findIndex(d=>d[0]===t)),[,s,o,a]=Ft[n],i=Ft[(n+1)%Ft.length];return`<button type="button" class="dt-prio" style="--cat:${o}" data-act="prio" data-v="${i[0]}"${e?` data-id="${e}"`:""} data-tip="Priority: ${s} \u2014 click for ${i[1]}" aria-label="Priority ${s}">${ia(a,o)}<span>${s}</span></button>`},he=()=>!!c.me&&/@guest\.notemend\.com$/i.test(c.me.email),bn=(t,e,n,s,o=!1)=>`<div class="dt-prio-row"><span class="dt-meta">${c.client?"":Js(t,n)}${zs(Ie(e).id,n)}</span>${c.client||he()?"":qs(s,n,o)}</div>`,wt='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><circle cx="10" cy="6.8" r="3"/><path d="M4.2 16.5c.6-3 3-4.8 5.8-4.8s5.2 1.8 5.8 4.8" stroke-linejoin="round"/></svg>',yn='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><circle cx="10" cy="6.8" r="3"/><path d="M4.2 16.5c.6-3 3-4.8 5.8-4.8s5.2 1.8 5.8 4.8" stroke-linejoin="round"/><path d="M3.5 3.5l13 13"/></svg>',Gs='<svg viewBox="0 0 20 20" width="14" height="14" aria-hidden="true"><circle cx="5" cy="10" r="1.1" fill="currentColor" stroke="none"/><circle cx="10" cy="10" r="1.1" fill="currentColor" stroke="none"/><circle cx="15" cy="10" r="1.1" fill="currentColor" stroke="none"/></svg>',vn=(t,e)=>`<label class="dt-more" data-tip="More"><span aria-hidden="true">${Gs}</span><select class="dt-more-select"${e?` data-id="${e}"`:""} aria-label="More">
|
|
5
|
+
<option value="" hidden selected></option>
|
|
6
|
+
${c.client?"":`<option value="team" data-icon="${m(yn)}"${t?"":" data-on"}>Team only</option>
|
|
7
|
+
<option value="client" data-icon="${m(wt)}"${t?" data-on":""}>Team and client</option>`}
|
|
8
|
+
<option value="${e?"rm":"discard"}" data-icon="${m(je)}" data-danger${c.client?"":" data-sep"}>${e?"Delete thread":"Discard draft"}</option>
|
|
9
|
+
</select></label>`,$n='<svg viewBox="0 0 20 20" width="14" height="14" aria-hidden="true"><path d="M2 10s3-5.5 8-5.5S18 10 18 10s-3 5.5-8 5.5S2 10 2 10z"/><circle cx="10" cy="10" r="2.3"/></svg>',ga=(t,e)=>`<button type="button" class="dt-share${t?" is-on":""}" data-act="share" data-v="${t?"":"1"}"${e?` data-id="${e}"`:""}
|
|
10
|
+
aria-pressed="${!!t}" title="${t?"Shared with the client \u2014 click to keep it to the team":"Team only \u2014 click to share it with the client"}">${t?wt:yn}</button>`,Xs=()=>(c.team??[]).filter(t=>!c.studio||c.studio.includes(t.email)),Qs=t=>{const e=t||c.lead||"",n=Xs();if(!n.length)return"";const s=pn(e);return`<label class="dt-field" title="Who it is for"><span class="dt-field-box${s?" dt-field-box--face":""}" style="--cat:${vt(e||"x@x")}">${s}<select class="dt-for-select" aria-label="Who this is for">
|
|
11
|
+
${n.map(o=>`<option value="${m(o.email)}" data-c="${vt(o.email)}"${un(o.email)}${e===o.email?" selected":""}>${m(o.name||o.email)}</option>`).join("")}
|
|
12
|
+
</select></span></label>`},be='<svg viewBox="0 0 20 20" width="9" height="9" aria-hidden="true"><path d="M5.5 5.5l9 9M14.5 5.5l-9 9"/></svg>',Zs=!1,to=!1,wn='<svg viewBox="0 0 12 12" width="10" height="10" aria-hidden="true"><path d="M3 1.8v8.4L10 6z"/></svg>',eo='<svg viewBox="0 0 12 12" width="10" height="10" aria-hidden="true"><path d="M2.5 1.5h2.5v9H2.5zM7 1.5h2.5v9H7z"/></svg>',no=t=>`${Math.floor(t/60)}:${String(Math.floor(t%60)).padStart(2,"0")}`,so=(t,e)=>{const n=t.closest(".dt-voice"),s=n.querySelector("audio"),o=n.querySelector(".dt-voice-play");if(!s.dataset.wired){s.dataset.wired="1";const d=n.querySelector(".dt-voice-track i"),u=n.querySelector(".dt-voice-time"),p=()=>Number.isFinite(s.duration)?s.duration:0;s.addEventListener("timeupdate",()=>{d.style.transform=`scaleX(${p()?Math.min(1,s.currentTime/p()):0})`,u.textContent=no(s.currentTime)}),s.addEventListener("play",()=>{o.innerHTML=eo,o.setAttribute("aria-label","Pause"),n.classList.add("is-playing")}),s.addEventListener("pause",()=>{o.innerHTML=wn,o.setAttribute("aria-label","Play the voice note"),n.classList.remove("is-playing")}),s.addEventListener("ended",()=>{s.currentTime=0})}const a=()=>{if(e){const d=n.querySelector(".dt-voice-track").getBoundingClientRect();Number.isFinite(s.duration)&&(s.currentTime=Math.max(0,Math.min(1,(e.clientX-d.left)/d.width))*s.duration);return}if(!s.paused){s.pause();return}h.querySelectorAll(".dt-voice audio").forEach(d=>{d!==s&&d.pause()}),s.play().catch(()=>{})};if(Number.isFinite(s.duration)||s.readyState<1){s.readyState<1?s.addEventListener("loadedmetadata",()=>Number.isFinite(s.duration)?a():i(),{once:!0}):a();return}i();function i(){s.addEventListener("timeupdate",()=>{s.currentTime=0,a()},{once:!0}),s.currentTime=1e9}},ye=t=>t.startsWith("data:audio/")||/(^|\/)voice-[^/?]*\.(webm|m4a)(\?|$)/i.test(t),En=t=>t.startsWith("data:video/")||/\.webm(\?|$)/i.test(t),Et=new Map,oo=t=>{if(!t.startsWith("data:"))return t;let e=Et.get(t);if(!e){const[n,s]=t.split(",",2);if(e=URL.createObjectURL(new Blob([Uint8Array.from(atob(s),o=>o.charCodeAt(0))],{type:n.slice(5).split(";")[0]})),Et.set(t,e),Et.size>8){const[o,a]=Et.entries().next().value;URL.revokeObjectURL(a),Et.delete(o)}}return e},ao=(t,e)=>`<span class="dt-voice"><button type="button" class="dt-voice-play" data-act="voice" aria-label="Play the voice note">${wn}</button><button type="button" class="dt-voice-track" data-act="voice-seek" aria-label="Jump"><i></i></button><span class="dt-voice-time">0:00</span><audio src="${oo(t)}" preload="metadata"></audio>${e===void 0?"":`<button class="dt-voice-rm" data-act="voice-write" ${e} aria-label="Write it out" title="Write it out \u2014 its words go in the box">${bo}</button>`}${e===void 0?"":`<button class="dt-voice-rm" data-act="unshot" ${e} aria-label="Remove the recording" title="Remove the recording">${be}</button>`}</span>`,io=(t,e,n)=>`<span class="dt-shot dt-doc">${t.startsWith("data:")?`<span class="dt-doc-name">${Ln}${m(e)}</span>`:`<a class="dt-doc-name" href="${t}" target="_blank" rel="noreferrer">${Ln}${m(e)}</a>`}${n===void 0?"":`<button class="dt-shot-rm" data-act="unshot" ${n} aria-label="Remove">${be}</button>`}</span>`,Sn=(t,e,n=t)=>ms(n)?io(t,ms(n),e):ye(n)?ao(t,e):`<span class="dt-shot${En(n)?" dt-shot--video":""}">${En(n)?`<video src="${t}" controls preload="metadata" playsinline></video>`:`<a href="${t}" target="_blank"><img src="${t}" alt="" loading="lazy" /></a>`}${e===void 0?"":`<button class="dt-shot-rm" data-act="unshot" ${e} aria-label="Remove">${be}</button>`}</span>`,Tn=(t=[],e)=>t.length?`<div class="dt-note-shots">${t.map(n=>{const s=n.split("/").pop(),o=na(s);return Sn(o,e===void 0?void 0:`data-id="${e}" data-img="${m(s)}"`,s)}).join("")}</div>`:"",Mn=(t=[])=>t.length?`<div class="dt-note-shots">${t.map((e,n)=>Sn(e,`data-i="${n}"`)).join("")}</div>`:"",Ln='<svg viewBox="0 0 20 20" width="14" height="14" aria-hidden="true"><path d="M11.5 2.5H6a1.5 1.5 0 0 0-1.5 1.5v12A1.5 1.5 0 0 0 6 17.5h8a1.5 1.5 0 0 0 1.5-1.5V6.5z"/><path d="M11.5 2.5v4h4"/></svg>',ro='<svg viewBox="0 0 20 20" width="15" height="15" aria-hidden="true"><rect x="2.5" y="5.5" width="11" height="9" rx="2"/><path d="m13.5 9 4-2.5v7l-4-2.5"/></svg>',lo='<svg viewBox="0 0 20 20" width="15" height="15" aria-hidden="true"><path d="M3.5 5.5h8M7.5 5.5v10M11 15.5l5-5 1.5 1.5-5 5H11z" stroke-linejoin="round"/></svg>',co=!!navigator.mediaDevices?.getDisplayMedia&&typeof MediaRecorder<"u";let it=null;const uo=async t=>{if(it){it.stop();return}let e;try{e=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:12},audio:!1})}catch{return}const n=await navigator.mediaDevices.getUserMedia({audio:!0}).catch(()=>null),s=new MediaStream([...e.getVideoTracks(),...n?.getAudioTracks()??[]]),o=["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm"].find(p=>MediaRecorder.isTypeSupported(p));if(!o){for(const p of e.getTracks())p.stop();k("This browser cannot record WebM video.");return}const a=new MediaRecorder(s,{mimeType:o,videoBitsPerSecond:6e5,audioBitsPerSecond:32e3}),i=[],d=!!Number(t?.dataset.id);a.ondataavailable=p=>{p.data.size&&i.push(p.data)};const u=setTimeout(()=>{a.state!=="inactive"&&a.stop()},3e4);a.onstop=async()=>{clearTimeout(u);for(const y of[...e.getTracks(),...n?.getTracks()??[]])y.stop();it=null;const p=new Blob(i,{type:"video/webm"});if(p.size>32e5){k("That recording is too big to send \u2014 keep it shorter."),f();return}const r=await new Promise(y=>{const g=new FileReader;g.onload=()=>y(String(g.result)),g.readAsDataURL(p)});d?O.push(r):l&&(l.images??=[]).push(r),f()},e.getVideoTracks()[0]?.addEventListener("ended",()=>{a.state!=="inactive"&&a.stop()}),it=a,a.start(1e3),f()},po='<svg viewBox="0 0 20 20" width="15" height="15" aria-hidden="true"><rect x="7.5" y="3" width="5" height="9" rx="2.5"/><path d="M5 9.5a5 5 0 0 0 10 0M10 14.5V17"/></svg>',mo='<svg viewBox="0 0 20 20" width="14" height="14" aria-hidden="true"><path d="m5 10.5 3.2 3L15 6.5"/></svg>',go=90,ve=32,fo=()=>!!c.voice&&!!navigator.mediaDevices?.getUserMedia&&typeof MediaRecorder<"u";let jt=!1;const ho=async(t,e)=>{if(jt||!t)return;const n=Number(t.dataset.id)||0;jt=!0,e.classList.add("is-asking"),e.title="Waiting for the microphone \u2014 allow it in the browser";let s;try{s=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(S){jt=!1,e.classList.remove("is-asking");const v=S?.name;k(v==="NotAllowedError"?"The microphone is blocked for this site \u2014 allow it from the icon left of the address, then try again.":v==="NotFoundError"?"No microphone found \u2014 plug one in or pick it in the system settings.":v==="NotReadableError"?"The microphone is busy in another app \u2014 close it there and try again.":`The microphone did not start: ${S?.message||v||"unknown error"}`);return}e.classList.remove("is-asking");const o=()=>h.querySelector(n?`.dt-note[data-id="${n}"] .dt-compose`:".dt-note[data-draft] .dt-compose"),a=document.createElement("div");a.className="dt-rec",a.innerHTML=`<button type="button" class="dt-rec-x" title="Discard (Esc)" aria-label="Discard">${je}</button><span class="dt-rec-time"><i></i><b>0:00</b></span><span class="dt-rec-wave">${"<i></i>".repeat(ve)}</span><button type="button" class="dt-rec-done" title="Done \u2014 write it out" aria-label="Done">${mo}</button>`;const i=a.querySelector("b"),d=[...a.querySelectorAll(".dt-rec-wave i")],u=new AudioContext,p=u.createAnalyser();p.fftSize=512,u.createMediaStreamSource(s).connect(p);const r=new Uint8Array(p.fftSize),y=[],g=new MediaRecorder(s,{audioBitsPerSecond:32e3}),w=[],M=Date.now();let N=!0;const Z=setInterval(()=>{const S=o();S&&a.parentElement!==S&&S.appendChild(a),p.getByteTimeDomainData(r);let v=0;for(const V of r)v+=((V-128)/128)**2;y.push(Math.min(1,Math.sqrt(v/r.length)*4));const Y=y.slice(-ve);d.forEach((V,Vt)=>{const et=Y[Vt-(ve-Y.length)];V.style.transform=`scaleY(${Math.max(.1,et??0).toFixed(2)})`,V.classList.toggle("is-empty",et===void 0)});const C=Math.floor((Date.now()-M)/1e3);i.textContent=`${Math.floor(C/60)}:${String(C%60).padStart(2,"0")}`,C>=go&&g.state!=="inactive"&&g.stop()},90),tt=S=>{N=S,g.state!=="inactive"&&g.stop()};a.querySelector(".dt-rec-x").addEventListener("click",S=>{S.stopPropagation(),tt(!1)}),a.querySelector(".dt-rec-done").addEventListener("click",S=>{S.stopPropagation(),tt(!0)}),a.addEventListener("keydown",S=>{S.key==="Escape"&&(S.stopPropagation(),tt(!1))}),g.ondataavailable=S=>{S.data.size&&w.push(S.data)},g.onstop=async()=>{if(clearInterval(Z),s.getTracks().forEach(Y=>Y.stop()),u.close().catch(()=>{}),a.remove(),jt=!1,!N)return;const S=new Blob(w,{type:g.mimeType||"audio/webm"}),v=await new Promise(Y=>{const C=new FileReader;C.onload=()=>Y(String(C.result)),C.readAsDataURL(S)});n?O.push(v):l&&(l.images??=[]).push(v),f(),o()?.querySelector("textarea")?.focus()},g.start(1e3),o()?.appendChild(a),a.querySelector(".dt-rec-done").focus()},kn="\u{1F3A4} Voice note",bo='<svg viewBox="0 0 20 20" width="12" height="12" aria-hidden="true"><rect x="2.5" y="4.5" width="15" height="11" rx="2"/><path d="M6 11.5h3M11 11.5h3M6 8.5h8"/></svg>',yo=async t=>{const e=t.closest(".dt-note"),s=(e?.hasAttribute("data-draft")?l?.images??[]:O)[Number(t.dataset.i)];if(!s||t.classList.contains("is-asking"))return;t.classList.add("is-asking");const o=await L("transcribe",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({audio:s})}).catch(()=>null),a=o?await o.json().catch(()=>({})):{};if(t.classList.remove("is-asking"),!o?.ok||!a.text){k(a.error||(o?.ok?"Didn't hear any words in it.":"Could not make out the words \u2014 try again, or type it."));return}const i=e?.querySelector("textarea.dt-note-input, textarea.dt-note-reply-input");i&&(i.value=i.value.trim()?`${i.value.trimEnd()} ${a.text}`:a.text,i.dispatchEvent(new Event("input",{bubbles:!0})),i.focus())},U=new Map,vo=async(t,e)=>{const n=`${t}:${e}`;if(U.has(n)){U.delete(n),f();return}const s=b.find(d=>d.id===t),o=s&&gs(s).find(d=>(d.at??"0")===e);if(!o?.text)return;U.set(n,null),f();const a=await L("translate",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({text:o.text,to:navigator.language||"en"})}).catch(()=>null),i=a?await a.json().catch(()=>({})):{};U.has(n)&&(a?.ok&&i.text?U.set(n,i.text):(U.delete(n),k(i.error||"Could not translate it \u2014 try again.")),f())},$o='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M3 5h8M7 3v2m2 0c-.6 3.2-2.8 6-6 7.5M5.5 8.5c.8 1.6 2.2 2.9 4 3.8M10.5 17l3.25-7.5L17 17m-5.5-2h4.5"/></svg>',wo='<svg viewBox="0 0 20 20" width="15" height="15" aria-hidden="true"><rect x="3" y="4" width="14" height="12" rx="2"/><circle cx="7.5" cy="8.5" r="1.4"/><path d="m3.5 14.5 4-4 3 3 2-2 4 4"/></svg>',xn=(t,e,n,s,o="",a="")=>`<div class="dt-note-foot"><div class="dt-compose">
|
|
13
|
+
<textarea class="${t}" rows="1" placeholder="${e}">${m(n)}</textarea>
|
|
14
14
|
${o}
|
|
15
15
|
<div class="dt-compose-bar">
|
|
16
|
-
<span class="dt-compose-tools"><button class="dt-attach" data-act="attach" title="Attach a screenshot \u2014 or paste or drop one">${
|
|
17
|
-
${a}${
|
|
16
|
+
<span class="dt-compose-tools"><button class="dt-attach" data-act="attach" title="Attach a screenshot, a PDF or a Word file \u2014 or paste or drop one">${wo}</button>
|
|
17
|
+
${a}${to&&co?`<button class="dt-record${it?" is-on":""}" data-act="record" title="${it?"Stop recording":"Record the screen, up to 30 seconds"}">${it?"Stop":ro}</button>`:""}${fo()?`<button class="dt-attach" data-act="speak" title="Speak \u2014 sent with its words as a voice note">${po}</button>`:""}</span>
|
|
18
18
|
<button class="dt-send${n.trim()?" is-ready":""}" ${s} title="Send (Enter)"
|
|
19
19
|
><svg viewBox="0 0 20 20" width="14" height="14" aria-hidden="true"><path d="M10 15.5v-11M5.5 9 10 4.5 14.5 9"/></svg></button>
|
|
20
20
|
</div>
|
|
21
|
-
</div></div
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
style="left:${x.x}px;top:${x.y}px">
|
|
21
|
+
</div></div>`,$e=(t,e)=>(t||"element")+(e?.[0]?"."+e[0]:""),An=()=>A.map((t,e)=>({i:e,el:$e(t.tag,t.classes),text:ht(t.text??""),shots:t.images?.length??0,orphan:!I(t)}));let we=[],Hn="";const z=t=>{const e=t.working;return at(e?.agent,e?.by??Go(t.assignee))},Nn=t=>{const e=Math.max(1,Math.round((Date.now()-Date.parse(t??""))/6e4)||1);return e<60?`${e} min`:`${Math.round(e/60)} h`},_t=(t,e)=>{const n=t.working;return{held:"From a guest \u2014 waits for the studio to approve it",queued:`Queued for ${z(t)} \u2014 it takes it on its next run`,asks:`${z(t)} is waiting for your answer`,working:`${z(t)} is on it \xB7 ${Nn(n?.at)}`,stuck:`${z(t)} went quiet \u2014 its next run takes it again`,review:`Resolved by ${at(t.doneAgent,t.doneFor)} \u2014 click to clear`,done:"Resolved"}[e]},Eo=t=>{const e=Jt(t);if(!e)return c.client||he()||t.status==="done"?"":`<button class="dt-note-state dt-step--none" data-act="hand" data-v="agent" data-id="${t.id}" data-tip="Hand to Claude" aria-label="Hand to Claude">${fs(13,0)}</button>`;const n=fs(13,Vo[e]);return e==="review"?`<button class="dt-note-state dt-step--review" data-act="reopen" data-id="${t.id}" data-tip="${m(_t(t,e))}" aria-label="${m(_t(t,e))}">${n}</button>`:`<span class="dt-note-state dt-step--${e}" data-tip="${m(_t(t,e))}" role="img" aria-label="${m(_t(t,e))}">${n}</span>`},Cn=t=>{const e=rt(t),n=e==="done";return`${Eo(t)}<button data-act="${n?"reopen":"done"}" data-id="${t.id}"
|
|
22
|
+
class="dt-note-resolve${n?" is-on":""}" title="${n?"Reopen":e==="claude"?"Looks right \u2014 mark it resolved":"Resolve"}">${Gt}</button>`},fa='<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M4.5 10h11M11 5.5l4.5 4.5-4.5 4.5" stroke-linejoin="round"/></svg>',So=t=>t?new Date(t).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}):"",To=t=>{if(c.client)return"";const e=Jt(t),n={act:"hand",v:"me",icon:wt,tip:c.me?"Take it myself":"Take it off Claude"},s={act:"reopen",icon:bs,tip:"Reopen"},o=[{act:"done",icon:Gt,tip:"Looks right \u2014 resolve it",main:!0},{act:"sendback",icon:bs,tip:"Send it back \u2014 say what is wrong below"}],a=t.working,i=!D(t.assignee)&&t.assignee?t.assignee===c.me?.email?"You":It(t.assignee):"",d=e==="queued"?{step:e,title:`Queued for ${z(t)}`,acts:[n]}:e==="working"?{step:e,title:`${z(t)} is working`,acts:[n],live:!0}:e==="asks"?{step:e,title:`${z(t)} asks`,acts:[]}:e==="stuck"?{step:e,title:`${z(t)} silent for ${Nn(a?.at)}`,acts:[n]}:e==="review"?{step:e,title:"Done \u2014 check it",acts:o}:t.status==="done"?{step:"done",title:`Accepted${t.confirmedAt?` \xB7 ${So(t.confirmedAt)}`:""}`,acts:[s]}:lt(t)==="review"&&i?{step:"review",title:`${i} ${i==="You"?"say":"says"} done \u2014 check it`,acts:o}:null;return d?`<div class="dt-step dt-step--${d.step}"><span class="dt-step-text"><b>${m(d.title)}</b></span>${d.acts.map(u=>`<button type="button" class="dt-step-act${u.main?" is-main":""}" data-act="${u.act}" data-id="${t.id}"${u.v?` data-v="${u.v}"`:""} data-tip="${m(u.tip)}" aria-label="${m(u.tip)}">${u.icon}</button>`).join("")}${d.live?'<i class="dt-step-live" aria-hidden="true"></i>':""}</div>`:""},Mo=async(t,e)=>{const n=e?b.find(o=>o.id===t):void 0,s=n?await Ce(q(n)):null;return L("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify(e?{id:t,status:"done",doneBy:"you",...s?{after:s}:{}}:{id:t,status:"open",doneBy:null,stage:Rn(b.find(o=>o.id===t))})})},P=async(t,e,n)=>{const s=b,o=mt;b=t(b),mt=t(mt),f();const a=await e().catch(()=>null);if(!a?.ok){b=s,mt=o,f(),k(`${n} did not go through${a?` (${a.status})`:""}.`);return}zt()},Rn=t=>t?D(t.assignee)?"approved":t.assignee?"progress":"new":"new",pt=(t,e)=>P(n=>n.map(s=>s.id===t?{...s,status:e?"done":"open",doneBy:e?"you":null,...e?{}:{stage:Rn(s),reopenedAt:new Date().toISOString()}}:s),()=>Mo(t,e),e?"Resolving":"Reopening"),Ee=t=>P(e=>e.filter(n=>n.id!==t),()=>L(`comments?id=${t}`,{method:"DELETE"}),"Deleting"),Lo=t=>{const e=b.filter(o=>J(o)===t),n=e.filter(o=>rt(o)==="open").length,s=e.filter(o=>rt(o)==="claude").length;re.innerHTML=n?String(n):s?kt(9):"\u2713",re.dataset.state=n?"open":s?"claude":"done",re.hidden=e.length===0};let Se=0,On;const f=()=>{const t=Se-performance.now();if(t>0){clearTimeout(On),On=setTimeout(f,t);return}if(ot(),E){const r=An(),y=JSON.stringify(r);y!==Hn&&(Hn=y,parent.postMessage({dt:!0,drafts:r},location.origin))}sn(),$!==yt&&(R="",O=[],yt=$),T&&T.id!==$&&(T=null);const e=Ot();if(Lo(e),!x){h.innerHTML="",pe(null);return}const n=e;let s="";const o=b.filter(r=>J(r)===n&&(W||rt(r)!=="done"||r.id===$));for(const r of o){const y=I(r);if(!y&&$!==r.id)continue;const g=rt(r),w=g==="done",M=!y,N=y??{x:0,y:0},Z=Ie(r.category),tt=Pe(r);if(M||(s+=`<button class="dt-pin dt-pin--${g}${tt?" dt-pin--working":""}${g==="open"&<(r)==="review"?" dt-pin--review":""}" data-id="${r.id}"${y?.off?` data-off="${y.off}"`:""} aria-label="Comment ${r.id}, ${g==="open"?"open":g==="claude"?`resolved by ${m(at(r.doneAgent,r.doneFor))}`:"resolved"}" aria-expanded="${$===r.id}"
|
|
23
|
+
style="left:${N.x}px;top:${N.y}px;--cat:${Z.color};--ring:${me.find(S=>S[0]===fn(r))[2]}"
|
|
24
|
+
title="${m(r.text.slice(0,80))} \xB7 ${Z.label}${tt?` \xB7 ${m(at(tt.agent,tt.by))} is on it`:""}${g==="claude"?` \xB7 resolved by ${m(at(r.doneAgent,r.doneFor))} \u2014 tick to confirm`:g==="done"?" \xB7 resolved":""}">${g==="done"?"\u2713":g==="claude"?kt(11):js(r)}</button>`),$===r.id){const S=gs(r);s+=`<div class="dt-note${M?" dt-note--orphan":""}" data-id="${r.id}" role="dialog" aria-label="Comment ${r.id}"
|
|
25
|
+
style="left:${N.x}px;top:${N.y}px">
|
|
27
26
|
<div class="dt-note-bar">
|
|
28
|
-
<span class="dt-note-el">${
|
|
29
|
-
${Yn(i.label)}
|
|
27
|
+
<span class="dt-note-el"${c.client?"":` data-tip="${gn(r.selector,r.label)}"`}>${c.client?`Comment #${xo(r)}`:m($e(r.tag,r.classes))}</span>
|
|
30
28
|
<span class="dt-note-tools">
|
|
31
|
-
${
|
|
29
|
+
${!c.client&&r.shared?`<span class="dt-note-eye" data-tip="The client sees this thread" role="img" aria-label="The client sees this thread">${$n}</span>`:""}
|
|
30
|
+
${Cn(r)}
|
|
32
31
|
<i class="dt-note-sep"></i>
|
|
33
|
-
${
|
|
34
|
-
<button data-act="
|
|
35
|
-
<button data-act="close" data-id="${i.id}" title="Close">${ue}</button>
|
|
32
|
+
${vn(r.shared,r.id)}
|
|
33
|
+
<button data-act="close" data-id="${r.id}" data-tip="Close" aria-label="Close">${Fe}</button>
|
|
36
34
|
</span>
|
|
37
35
|
</div>
|
|
38
|
-
${
|
|
39
|
-
${
|
|
40
|
-
${(()=>{const f=Jn(Te(i.category).id,i.id)+(p.client?"":Eo(i))+(i.host&&i.host!==location.host?`<span class="dt-note-host" title="Written on ${g(i.host)}">${g(i.host)}</span>`:"");return f?`<div class="dt-note-meta">${f}</div>`:""})()}
|
|
36
|
+
${M?'<p class="dt-note-orphan">The element this was pinned to is not on the page right now.</p>':""}
|
|
37
|
+
${(()=>{const v=(c.client?"":Ys(r))+(r.host&&r.host!==location.host?`<span class="dt-note-host" title="Written on ${m(r.host)}">${m(r.host)}</span>`:"");return v?`<div class="dt-note-meta">${v}</div>`:""})()}
|
|
41
38
|
<div class="dt-note-thread">
|
|
42
|
-
${
|
|
43
|
-
<textarea class="dt-note-edit-input" rows="1">${
|
|
44
|
-
${
|
|
39
|
+
${S.map((v,Y)=>{const C=Y===0?null:v.at??null,V=v.author==="you"&&(!v.by||v.by===c.me?.email),Vt=V&&T?.id===r.id&&T.at===C,et=c.team?.find(qe=>qe.email===v.by),Uo=v.author==="claude"?at(v.agent,v.by):V?"You":et?.name||v.byName||v.by||"You",zo=v.author==="claude"?et?.agent_avatar_url?`<img class="dt-msg-face" src="${m(et.agent_avatar_url)}" alt="">`:`<span class="dt-msg-face dt-msg-ai">${kt(11)}</span>`:et?.avatar_url?`<img class="dt-msg-face" src="${m(et.avatar_url)}" alt="">`:"",De=`${r.id}:${v.at??"0"}`,ls=U.get(De),Yo=!V&&c.voice&&v.text?`<button class="dt-msg-edit${U.has(De)?" is-on":""}" data-act="translate" data-id="${r.id}" data-at="${m(v.at??"0")}" title="${U.has(De)?"Show the original":"Translate into your language"}">${$o}</button>`:"",ds=`<div class="dt-msg-head">${zo}<b>${m(Uo)}</b><time>${la(v.at)}</time>${Yo}${V&&!Vt?`<button class="dt-msg-edit" data-act="edit" data-id="${r.id}" data-at="${m(C??"")}" title="Edit">${hs}</button>${C?`<button class="dt-msg-edit" data-act="unsay" data-id="${r.id}" data-at="${m(C)}" title="Delete">${je}</button>`:""}`:""}</div>`;return Vt?`<div class="dt-msg">${ds}<div class="dt-compose">
|
|
40
|
+
<textarea class="dt-note-edit-input" rows="1">${m(T.text)}</textarea>
|
|
41
|
+
${Tn(v.images.filter(qe=>!T.drop.includes(qe.split("/").pop())),r.id)}
|
|
45
42
|
<div class="dt-compose-bar">
|
|
46
43
|
<button class="dt-edit-cancel" data-act="edit-cancel">Cancel</button>
|
|
47
|
-
<button class="dt-send${
|
|
44
|
+
<button class="dt-send${T.text.trim()?" is-ready":""}" data-act="edit-save" title="Save (Enter)">${Gt}</button>
|
|
48
45
|
</div>
|
|
49
|
-
</div></div>`:`<div class="dt-msg" data-msg="${
|
|
46
|
+
</div></div>`:`<div class="dt-msg" data-msg="${r.id}:${m(v.at??"0")}">${ds}<p${ls===null?' class="is-asking"':""}>${Fo(ls||v.text)}</p>${Y===0&&r.suggest?Ws(r.suggest):""}${Tn(v.images)}</div>`}).join("")}
|
|
50
47
|
</div>
|
|
51
|
-
${
|
|
52
|
-
${
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
${To(r)}
|
|
49
|
+
${xn("dt-note-reply-input",Jt(r)==="asks"?`Answer ${m(z(r))}`:"Reply",R,`data-act="reply" data-id="${r.id}"`,Mn(O))}
|
|
50
|
+
${bn(r.priority,r.category,r.id,r.assignee??"",Zo(r))}
|
|
51
|
+
</div>`}}A.forEach((r,y)=>{const g=I(r);g&&(s+=`<button class="dt-pin dt-pin--draft" data-parked="${y}" data-act="draft-open" data-i="${y}"
|
|
52
|
+
style="left:${g.x}px;top:${g.y}px" title="Draft, not sent \u2014 click to finish it">${hs}</button>`)});const a=l&&I(l);if(l){const r=a?.x??0,y=a?.y??0;s+=`${a?`<span class="dt-pin dt-pin--draft" data-draft style="left:${r}px;top:${y}px"></span>`:""}
|
|
53
|
+
<div class="dt-note${a?"":" dt-note--orphan"}" data-draft style="left:${r}px;top:${y}px">
|
|
56
54
|
<div class="dt-note-bar">
|
|
57
|
-
<span class="dt-note-el">${
|
|
58
|
-
${
|
|
59
|
-
${ie()?'<span class="dt-note-draft">Draft</span>':""}
|
|
55
|
+
<span class="dt-note-el"${c.client?"":` data-tip="${gn(l.selector,l.label)}"`}>${c.client?"New comment":m($e(l.tag,l.classes))}</span>
|
|
56
|
+
${Ct()?'<span class="dt-note-draft">Draft</span>':""}
|
|
60
57
|
<span class="dt-note-tools">
|
|
61
|
-
${
|
|
62
|
-
|
|
63
|
-
<button data-act="cancel"
|
|
58
|
+
${!c.client&&l.shared?`<span class="dt-note-eye" data-tip="The client will see this thread" role="img" aria-label="The client will see this thread">${$n}</span>`:""}
|
|
59
|
+
${vn(l.shared)}
|
|
60
|
+
<button data-act="cancel" data-tip="Close \u2014 the draft stays" aria-label="Close">${Fe}</button>
|
|
64
61
|
</span>
|
|
65
62
|
</div>
|
|
66
63
|
${a?"":'<p class="dt-note-orphan">The element this was pinned to is not on the page right now.</p>'}
|
|
67
|
-
${(()=>{const
|
|
68
|
-
|
|
69
|
-
${
|
|
70
|
-
<span class="dt-suggest-was">Now: <del>${
|
|
71
|
-
<textarea class="dt-suggest-input" rows="2" placeholder="Type how it should read" aria-label="How it should read">${
|
|
64
|
+
${(()=>{const g=a?q(l):null,w=g&&b.find(M=>M.id>0&&rt(M)==="open"&&q(M)===g);return w?`<p class="dt-note-twin">Already open here: \u201C${m(w.text.slice(0,60))}${w.text.length>60?"\u2026":""}\u201D <button data-act="twin" data-id="${w.id}">Open it</button></p>`:""})()}
|
|
65
|
+
${c.client?`<div class="dt-note-meta">${Qs(l.assignee)}</div>`:""}
|
|
66
|
+
${l.suggest?`<div class="dt-suggest"><span class="dt-suggest-head">New wording for this text<button data-act="unsuggest" title="Keep the text as it is">${Fe}</button></span>
|
|
67
|
+
<span class="dt-suggest-was">Now: <del>${m(l.suggest.from.slice(0,160))}${l.suggest.from.length>160?"\u2026":""}</del></span>
|
|
68
|
+
<textarea class="dt-suggest-input" rows="2" placeholder="Type how it should read" aria-label="How it should read">${m(l.suggest.to)}</textarea>
|
|
72
69
|
<span class="dt-suggest-hint">Change the words in the box \u2014 the agent puts in exactly what you write.</span></div>`:""}
|
|
73
|
-
${
|
|
74
|
-
${
|
|
75
|
-
</div>`}const
|
|
76
|
-
<button class="dt-hist-go" data-go="${l.id}">
|
|
77
|
-
<span class="dt-hist-n" style="--cat:${j.color}">${ot?ct(8):""}</span>
|
|
78
|
-
<span class="dt-hist-body">
|
|
79
|
-
<span class="dt-hist-id">#${n.get(l.id)}<em>${j.label}</em>${ot?`<b class="dt-hist-claude" data-unmark="${l.id}" role="button" tabindex="0" title="Resolved by ${g(ut(l.doneAgent,l.doneFor))} \u2014 click to clear: back to open">${ct(9)}${g(Us(l.doneAgent))}<i aria-hidden="true">\xD7</i></b>`:""}${f?'<b class="dt-hist-orphan" title="The element this was pinned to is not on the page right now">no pin</b>':""}</span>
|
|
80
|
-
<span class="dt-hist-text">${k.author==="claude"?`<b>${g(ut(k.agent,k.by))}:</b> `:""}${g(k.text)}</span>
|
|
81
|
-
<span class="dt-hist-meta">${On(l.updatedAt||l.createdAt)}${l.device?` \xB7 ${g(l.device)}`:l.browser?` \xB7 ${g(l.browser)}`:""}${x?` \xB7 ${x} repl${x===1?"y":"ies"}`:""}</span>
|
|
82
|
-
</span>
|
|
83
|
-
</button>
|
|
84
|
-
<span class="dt-note-tools dt-hist-tools">${us(H,l.id)}<i class="dt-note-sep"></i
|
|
85
|
-
><button data-rm="${l.id}" title="Delete this comment">${xt}</button></span>
|
|
86
|
-
</div>`},a=I.find(l=>l.id===t),r=I.map(l=>{const $=v.filter(x=>at(x)===l.id&&q(x)!=="done");return{band:l,open:$.filter(x=>q(x)==="open").length,total:$.length}}).filter(l=>l.total&&l.band.id!==t),u=r.length?`<i class="dt-hist-sep"></i><div class="dt-hist-bands">${r.map(({band:l,open:$,total:x})=>`<button data-bp="${l.id}" data-state="${$?"open":"claude"}"
|
|
87
|
-
title="${l.label}: ${$} open \xB7 ${x-$} to check"
|
|
88
|
-
><svg viewBox="0 0 20 20" width="11" height="11" aria-hidden="true">${l.icon}</svg><i>${x}</i></button>`).join("")}</div>`:"",i=["open","claude","done"].filter(l=>s[l].length&&(l!=="done"||Z)),c=B.hidden?ds():Ye,y=l=>`<div class="dt-hist-row is-draft">
|
|
89
|
-
<button class="dt-hist-go" data-draft-go="${l.i}">
|
|
90
|
-
<span class="dt-hist-n">${je}</span>
|
|
91
|
-
<span class="dt-hist-body">
|
|
92
|
-
<span class="dt-hist-id">${g(l.el)}${l.orphan?'<b class="dt-hist-orphan" title="The element this was pinned to is not on the page right now">no pin</b>':""}</span>
|
|
93
|
-
<span class="dt-hist-text">${l.text?g(l.text):`${l.shots} screenshot${l.shots===1?"":"s"}`}</span>
|
|
94
|
-
</span>
|
|
95
|
-
</button>
|
|
96
|
-
<span class="dt-note-tools dt-hist-tools"><button data-draft-rm="${l.i}" title="Discard this draft">${xt}</button></span>
|
|
97
|
-
</div>`;K.innerHTML=`<div class="dt-hist-head">
|
|
98
|
-
<span class="dt-hist-here" title="${a?.label??t}"
|
|
99
|
-
><svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true">${a?.icon??""}</svg></span>
|
|
100
|
-
<span class="dt-hist-title">Comments</span>
|
|
101
|
-
${u}
|
|
102
|
-
${vt().length&&!E?`<button class="dt-review-btn" data-review aria-label="Check all ${vt().length} ${vt().length===1?"fix":"fixes"}" data-tip="${vt().length} ${vt().length===1?"fix waits":"fixes wait"} for a look across every page \u2014 walk through them">${Ft}${vt().length}</button>`:""}
|
|
103
|
-
<button class="dt-hist-refresh" data-refresh aria-label="Reload comments from the file">
|
|
104
|
-
<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M16 10a6 6 0 1 1-1.8-4.3"/><path d="M16.3 3.4v3.4h-3.4"/></svg>
|
|
105
|
-
</button>
|
|
106
|
-
<button class="dt-hist-fold" data-fold aria-label="Collapse or expand the panel">
|
|
107
|
-
<svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><path d="M5.5 8.5 10 12.5l4.5-4"/></svg>
|
|
108
|
-
</button>
|
|
109
|
-
</div>`+(i.length||c.length?`<div class="dt-hist-list">${c.length?`<p class="dt-hist-group">Drafts<em>${c.length}</em></p>${c.map(y).join("")}`:""}${i.map(l=>`<p class="dt-hist-group">${ba[l]}<em>${s[l].length}</em></p>`+s[l].map(o).join("")).join("")}</div>`:`<p class="dt-hist-empty">${s.done.length?"Everything here is resolved.":"No comments at this breakpoint yet. Click anything on the page to leave one."}</p>`)+`<div class="dt-hist-foot">
|
|
110
|
-
<button class="dt-hist-resolved" data-resolved role="switch" aria-checked="${Z}"
|
|
111
|
-
><svg viewBox="0 0 20 20" width="13" height="13" aria-hidden="true"><circle cx="10" cy="10" r="7.5"/><path d="M6.8 10.2 9 12.4l4-4.4" stroke-linejoin="round"/></svg
|
|
112
|
-
><span>Show resolved</span><kbd>R</kbd><i class="dt-hist-switch" aria-hidden="true"></i></button>
|
|
113
|
-
</div>`},Xe=t=>K.toggleAttribute("data-collapsed",t);K.addEventListener("click",async t=>{const e=t.target.closest("[data-refresh]");if(e){e.dataset.spin="1",await ve(),setTimeout(()=>delete e.dataset.spin,500);return}if(K.hasAttribute("data-collapsed")&&t.target.closest(".dt-hist-head")){Xe(!1);return}if(t.target.closest("[data-fold]")){Xe(!K.hasAttribute("data-collapsed"));return}const n=t.target.closest(".dt-hist-bands [data-bp]");if(n){gn(n.dataset.bp);return}const s=t.target.closest("[data-draft-go], [data-draft-rm]");if(s){const i=s.dataset.draftRm!==void 0,c=Number(i?s.dataset.draftRm:s.dataset.draftGo);B.hidden?i?hs(c):Ze(c):P(i?{dropDraft:c}:{openDraft:c});return}const o=t.target.closest("[data-unmark]");if(o){t.stopPropagation(),await zt(Number(o.dataset.unmark),!1);return}const a=t.target.closest(".dt-hist-tools [data-act]");if(a){await zt(Number(a.dataset.id),a.dataset.act==="done");return}const r=t.target.closest("[data-rm]");if(r){w=null,await ms(Number(r.dataset.rm));return}if(t.target.closest("[data-review]")){Go();return}if(t.target.closest("[data-resolved]")){en(!Z);return}const u=t.target.closest("[data-go]");if(!u)return;const m=Number(u.dataset.go);if(!B.hidden){P({open:m});return}Ge(m)});const Ge=t=>{w=t,Y(),h();const e=v.find(s=>s.id===t),n=e&&tt(e);n?scrollTo({top:scrollY+n.y-innerHeight/2,behavior:"smooth"}):e&&Q(e)?.scrollIntoView({block:"center",behavior:"smooth"}),matchMedia("(prefers-reduced-motion: reduce)").matches||b.querySelector(`.dt-pin[data-id="${t}"]`)?.animate([{transform:"scale(1)"},{transform:"scale(1.5)"},{transform:"scale(1)"}],400)},Ze=t=>{const[e]=D.splice(t,1);if(!e)return;Y(),d=e,w=null;const n=tt(e);n&&(n.y<0||n.y>innerHeight)&&scrollTo({top:scrollY+n.y-innerHeight/3,behavior:"instant"}),h()},hs=t=>{D.splice(t,1),h()},Qe="nm-review",he=()=>{try{return JSON.parse(sessionStorage.getItem(Qe)||"null")}catch{return null}},kt=t=>{try{t?sessionStorage.setItem(Qe,JSON.stringify(t)):sessionStorage.removeItem(Qe)}catch{}},R=document.createElement("div");R.className="dt-review",R.setAttribute("role","region"),R.setAttribute("aria-label","Checking fixes"),R.hidden=!0,Bn(R),E||document.body.append(R);const vt=()=>nt.filter(t=>q(t)==="claude"),Go=()=>{const t=vt().sort((e,n)=>+(n.route===z)-+(e.route===z)||String(e.route).localeCompare(String(n.route))||e.id-n.id).map(e=>e.id);t.length&&(kt({ids:t,i:0}),fe())},fe=()=>{const t=he();if(!t||E){R.hidden=!0;return}for(;t.i<t.ids.length&&q(nt.find(s=>s.id===t.ids[t.i])??{status:"done"})!=="claude";)t.i++;if(t.i>=t.ids.length){kt(null),R.hidden=!0,O("Every fix is checked.");return}kt(t);const e=nt.find(s=>s.id===t.ids[t.i]);if(e.route&&e.route!==z){location.assign(e.route+location.search);return}if(N||pt(!0),at(e)!==le()){gn(at(e));for(const s of[600,1500])setTimeout(()=>P({open:e.id}),s)}else Ge(e.id);const n=t.ids.slice(0,t.i).some(s=>q(nt.find(o=>o.id===s)??{status:"done"})==="claude");R.innerHTML=`<b><span class="dt-review-dot" aria-hidden="true"></span>Check fixes</b>
|
|
114
|
-
<span class="dt-review-nav"><button data-r="prev" aria-label="Previous fix" data-tip="Previous \xB7 \u2190"${n?"":" disabled"}>${po}</button>
|
|
115
|
-
<span class="dt-review-n">${t.i+1} of ${t.ids.length}</span>
|
|
116
|
-
<button data-r="skip" aria-label="Next fix" data-tip="Next \xB7 \u2192">${go}</button></span>
|
|
117
|
-
<span class="dt-review-text">${g(Lt(e.text).slice(0,90))}</span>
|
|
118
|
-
<button data-r="ok" class="dt-review-ok" aria-label="Looks right \u2014 mark it resolved" data-tip="Looks right \u2014 resolve it">${Ft}</button>
|
|
119
|
-
<button data-r="no" aria-label="Reopen" data-tip="Not yet \u2014 reopen it">${ho}</button>
|
|
120
|
-
<button data-r="stop" aria-label="Stop checking" data-tip="Stop checking">${ue}</button>`,R.hidden=!1};R.addEventListener("click",async t=>{const e=t.target.closest("[data-r]"),n=he();if(!e||!n)return;if(e.dataset.r==="stop"){kt(null),R.hidden=!0;return}if(e.dataset.r==="prev"){fs();return}const s=n.ids[n.i];kt({...n,i:n.i+1});const o=e.dataset.r==="ok"?zt(s,!0):e.dataset.r==="no"?zt(s,!1):null;fe(),await o});const fs=()=>{const t=he();if(t){for(let e=t.i-1;e>=0;e--)if(q(nt.find(n=>n.id===t.ids[e])??{status:"done"})==="claude"){kt({...t,i:e}),fe();return}}};document.addEventListener("keydown",t=>{R.hidden||t.metaKey||t.ctrlKey||t.altKey||t.key!=="ArrowLeft"&&t.key!=="ArrowRight"||t.target.closest?.("input, textarea, select, [contenteditable]")||(t.preventDefault(),t.key==="ArrowLeft"?fs():R.querySelector('[data-r="skip"]')?.click())});const Zo=t=>{K.hidden=!t,oe.setAttribute("aria-pressed",String(t)),X("dt-history",t?"1":"0"),h()},tn=document.querySelector(".dt-resolved-btn"),en=t=>{Z=t,tn.setAttribute("aria-pressed",String(t)),X("dt-resolved",t?"1":"0"),P({resolved:t}),h(),be()};tn.addEventListener("click",()=>en(!Z)),tn.setAttribute("aria-pressed",String(Z)),oe.addEventListener("click",()=>{const t=K.hidden===!0;t&&!N&&pt(!0),t&&Xe(!1),Zo(t)});const mt=()=>{Oe||!N||(Oe=requestAnimationFrame(()=>{Oe=0,Jo()}))},bs=new MutationObserver(t=>{t.every(e=>e.target.closest?.(".dt-notes-overlay"))||mt()}),ys=new ResizeObserver(()=>mt());let nt=[];const vs=t=>{nt=t;const e=()=>({open:0,claude:0,done:0}),n={};for(const u of t){const m=q(u),i=n[u.route??""]??={...e(),bands:{}};i[m]++;const c=at(u);(i.bands[c]??=e())[m]++}const s=["open","claude","done"],o={open:"open",claude:"resolved by an agent, to check",done:"resolved"},a=u=>s.map(m=>[m,m==="done"&&!Z?0:u[m]]),r=u=>a(u).reduce((m,[,i])=>m+i,0);for(const u of document.querySelectorAll(".dt-pages a")){const m=u.querySelector(".dt-pages-n");if(!m)continue;const i=n[new URL(u.href).pathname.replace(/\/+$/,"")||"/"];for(const l of I){const $=i?.bands[l.id];for(const[x,j]of a($??e())){const H=m.querySelector(`[data-bp="${l.id}"][data-state="${x}"]`);H.hidden=!j,j&&(H.querySelector("i").textContent=String(j),H.title=`${l.label}: ${j} ${o[x]}`)}}const c=i?r(i):0;m.hidden=!c;const y=i?I.filter(l=>i.bands[l.id]&&r(i.bands[l.id])).map(l=>`${l.label} ${r(i.bands[l.id])}`).join(" \xB7 "):"";m.title=c?`${i.open} open \xB7 ${i.claude} resolved by an agent, to check \xB7 ${i.done} resolved
|
|
121
|
-
${y}`:""}},Ut=t=>(Array.isArray(t)?t:[]).filter(e=>e&&Number.isInteger(Number(e.id))&&typeof e.text=="string").map(e=>({...e,id:Number(e.id),rx:Number(e.rx)||0,ry:Number(e.ry)||0,route:typeof e.route=="string"&&/^\/(?![\/\\])/.test(e.route)?e.route:"/",replies:Array.isArray(e.replies)?e.replies.filter(n=>typeof n?.text=="string"):[],images:Array.isArray(e.images)?e.images.filter(n=>typeof n=="string"):[]})),be=async()=>{try{vs(Ut((await(await A("comments")).json()).comments)),!K.hidden&&!E&&h()}catch{}};let Vt=null,Yt=null;const $t=document.querySelector(".dt-turbo"),nn="/notemend:turbo",Jt=()=>{const t=!!Vt&&Date.now()-Date.parse(Vt.at)<18e4,e=t?Yt?.paused?"paused":"on":"none",n=t?Us(Vt.agent):"",s=e==="none"?`Turbo is off. Run ${nn} in Claude Code and comments for the agent are taken as they land \u2014 click to copy it`:e==="on"?`Turbo on: ${n} takes comments for the agent as they land \u2014 click to pause`:`Turbo paused: ${n} is listening but waits \u2014 click to resume`;$t.dataset.state=e,$t.dataset.tip=s,$t.setAttribute("aria-label",s),$t.setAttribute("aria-checked",String(e==="on")),E&&($t.hidden=!0)};setInterval(Jt,3e4),$t.addEventListener("click",async()=>{const t=$t.dataset.state;if(t==="none"){await navigator.clipboard?.writeText(nn).catch(()=>{}),O(`Copied ${nn} \u2014 paste it in Claude Code`);return}const e=t==="on"?"off":"on";Yt={paused:e==="off"},Jt();try{const n=await A("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({turbo:e})});if(!n.ok)throw new Error(String(n.status));O(e==="off"?"Turbo paused":"Turbo on")}catch{Yt={paused:e==="on"},Jt(),O("Could not switch turbo \u2014 try again")}});let ye="",sn=!1;const Xt=async()=>{if(!(document.hidden||sn)){sn=!0;try{const t=await A(`comments${ye?`?since=${ye}`:""}`);if(t.status!==200)return;const e=await t.json();ye=e.version??"",Vt=e.listening??null,Yt=e.turbo??null,Jt();const n=Ut(e.comments);vs(n);const s=n.filter(o=>o.route===z);if(JSON.stringify(s)===JSON.stringify(v))return;if(b.contains(document.activeElement)&&document.activeElement.matches("textarea, input")){ye="",setTimeout(Xt,5e3);return}v=s,h(),P({reload:!0})}catch{}finally{sn=!1}}},wt=async()=>{try{const e=await(await A(`comments?route=${encodeURIComponent(z)}`)).json();v=Ut(e.comments),Vt=e.listening??null,Yt=e.turbo??null,Jt()}catch{v=[]}h()};let on=0;const $s=t=>{on||(on=requestAnimationFrame(()=>{on=0;const e=t.target;if(!N||e.closest(Ne)){ht.hidden=!0;return}ht.hidden=!0;const n=document.elementFromPoint(t.clientX,t.clientY);if(ht.hidden=!1,!n)return;const s=n.getBoundingClientRect();so.style.cssText=`left:${s.left}px;top:${s.top}px;width:${s.width}px;height:${s.height}px`,An.textContent=n.tagName.toLowerCase()+([...n.classList].find(o=>!/^(astro|svelte)-/.test(o))?"."+[...n.classList].find(o=>!/^(astro|svelte)-/.test(o)):"")+` ${Math.round(s.width)}\xD7${Math.round(s.height)}`,An.style.cssText=`left:${s.left}px;top:${Math.max(2,s.top-20)}px`}))},ws=t=>{if(!(t.key!=="Escape"||t.isComposing)){if(t.preventDefault(),M){M=null,h();return}if(d){Y(),h();return}if(w!==null){w=null,h();return}pt(!1)}},Es=["pointerdown","mousedown","pointerup","mouseup","touchstart","touchend"],Ss=t=>{t.target.closest?.(Ne)||t.stopPropagation()},Ls=t=>{if(t.target.closest(Ne))return;if(t.preventDefault(),t.stopPropagation(),Ae){Ae=!1;return}if(!getSelection()?.isCollapsed)return;b.hidden=!0;const n=document.elementFromPoint(t.clientX,t.clientY);if(b.hidden=!1,!n)return;Y();const s=n.getBoundingClientRect(),o=n.tagName.toLowerCase(),a=[...n.classList].filter(r=>!/^(astro|svelte|css)-/.test(r)).slice(0,2);d={selector:lo(n),tag:o,classes:a,nth:co({tag:o,classes:a}).indexOf(n),rx:s.width?(t.clientX-s.left)/s.width:.5,ry:s.height?(t.clientY-s.top)/s.height:.5,label:Lt(n.textContent||"").slice(0,60),ctx:uo(n),category:$n[0].id},Ms.set(d,an(n)),w=null,ht.hidden=!0,h()},Qo=2200,ta=900*1024,Ts=8*1024*1024,ea=1200,na=1600,an=async t=>{let e=t instanceof HTMLElement?t:null;for(let o=0;e&&o<4&&e.parentElement&&e.parentElement!==document.body;o++){const a=e.getBoundingClientRect();if(a.width>=360&&a.height>=140)break;e=e.parentElement}const n=e?.getBoundingClientRect();if(!e||!n?.width||!n.height)return null;let s="";for(let o=e;o&&!s;o=o.parentElement){const a=getComputedStyle(o).backgroundColor;a&&a!=="transparent"&&!/rgba\(.*,\s*0\)$/.test(a)&&(s=a)}if(!s){const[o,a,r]=(getComputedStyle(e).color.match(/[\d.]+/g)??["0","0","0"]).map(Number);s=.299*o+.587*a+.114*r>140?"#111":"#fff"}try{const{domToWebp:o}=await import("modern-screenshot"),a=Math.min(devicePixelRatio||1,2,ea/n.width,na/n.height),r=await Promise.race([o(e,{scale:a,quality:.8,timeout:4e3,backgroundColor:s,filter:u=>!(u instanceof Element&&u.closest(Cn))}),new Promise(u=>setTimeout(()=>u(null),8e3))]);return r&&r.length<Ts?r:null}catch{return null}},Ms=new WeakMap,O=t=>{const e=document.createElement("div");e.className="dt-toast",e.textContent=t,document.body.append(e),setTimeout(()=>e.remove(),2800)},sa=t=>new Promise(e=>{const n=new FileReader;n.onload=()=>e(String(n.result)),n.readAsDataURL(t)}),oa=async t=>{const e=await createImageBitmap(t),n=Math.min(1,Qo/Math.max(e.width,e.height));if(n===1&&t.size<=ta)return e.close(),sa(t);const s=document.createElement("canvas");return s.width=Math.round(e.width*n),s.height=Math.round(e.height*n),s.getContext("2d").drawImage(e,0,0,s.width,s.height),e.close(),s.toDataURL("image/jpeg",.85)},rn=async(t,e)=>{const n=[];for(const s of t){let o;try{o=await oa(s)}catch{O("That image could not be read.");continue}if(o.length>Ts){O("Screenshot is too large even after shrinking.");continue}n.push(o)}if(n.length){if(!Number(e?.dataset.id)){d&&((d.images??=[]).push(...n),h());return}V.push(...n),h(),ks(".dt-note-reply-input")}},xs=t=>[...t??[]].filter(e=>e.kind==="file"&&e.type.startsWith("image/")).map(e=>e.getAsFile()).filter(Boolean);b.addEventListener("paste",t=>{const e=xs(t.clipboardData?.items);e.length&&(t.preventDefault(),rn(e,t.target.closest(".dt-note")))}),b.addEventListener("dragover",t=>{t.target.closest(".dt-note")&&(t.preventDefault(),t.target.closest(".dt-note").querySelector(".dt-compose")?.setAttribute("data-drop",""))}),b.addEventListener("dragleave",t=>{t.target.closest(".dt-note")?.querySelector(".dt-compose")?.removeAttribute("data-drop")}),b.addEventListener("drop",t=>{const e=t.target.closest(".dt-note");if(!e)return;t.preventDefault(),e.querySelector(".dt-compose")?.removeAttribute("data-drop");const n=xs(t.dataTransfer?.items);n.length&&rn(n,e)});const ks=t=>{const e=b.querySelector(t);e?.focus(),e?.setSelectionRange(e.value.length,e.value.length)},Hs=()=>{ks(".dt-note-edit-input"),b.querySelector(".dt-msg .dt-compose")?.scrollIntoView({block:"nearest"})},ln=t=>{t.style.overflowY="hidden",t.style.height="auto",t.style.height=`${t.scrollHeight}px`,t.style.overflowY=t.scrollHeight>t.clientHeight?"auto":"hidden"},aa=t=>/(?:^|\s)@([^\s@]*)$/.exec(t.value.slice(0,t.selectionStart??t.value.length)),ia=t=>{t.closest(".dt-compose").querySelector(".dt-mentions")?.remove();const n=aa(t);if(!n||!p.team?.length)return;const s=n[1].toLowerCase(),o=p.team.filter(a=>[a.name,a.nickname,a.email].some(r=>r?.toLowerCase().startsWith(s))).slice(0,5);o.length&&t.insertAdjacentHTML("afterend",`<div class="dt-mentions" role="listbox" aria-label="Mention someone">${o.map((a,r)=>`<button type="button" role="option" aria-selected="${r===0}" data-act="mention" data-handle="${g(wa(a))}">${me(a.avatar_url,a.name||a.email)}<span class="dt-mention-who"><b>${g(a.name||a.email)}</b>${a.name?`<span>${g(a.email)}</span>`:""}</span></button>`).join("")}</div>`)},ra=t=>{const e=(p.team??[]).flatMap(s=>[s.name,s.nickname,s.email]).filter(s=>!!s).sort((s,o)=>o.length-s.length).map(s=>g(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),n=g(t);return e.length?n.replace(new RegExp(`@(?:${e.join("|")})(?![\\p{L}\\p{N}_.-])`,"giu"),s=>`<span class="dt-at">${s}</span>`):n},As=(t,e)=>{const n=t.selectionStart??t.value.length,s=t.value.slice(0,n).lastIndexOf("@");t.value=`${t.value.slice(0,s)}@${e} ${t.value.slice(n)}`,t.selectionStart=t.selectionEnd=s+e.length+2,t.closest(".dt-compose")?.querySelector(".dt-mentions")?.remove(),t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()},la=(t,e)=>{if(!t){d&&(d.category=e),h();return}et(n=>n.map(s=>s.id===t?{...s,category:e}:s),()=>A("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:t,category:e})}),"Changing the type")};Ba(b,g,Ft),b.addEventListener("change",t=>{const e=t.target.closest(".dt-cat-select");if(e){la(Number(e.dataset.id)||0,e.value);return}const n=t.target.closest(".dt-status-select");if(n){So(Number(n.dataset.id),n.value);return}const s=t.target.closest(".dt-for-select");if(!s)return;s.parentElement?.style.setProperty("--cat",Kt(s.value));const o=Number(s.dataset.id);if(o){const a=s.value||null;et(r=>r.map(u=>u.id===o?{...u,assignee:a??void 0}:u),()=>A("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:o,assignee:a})}),"Reassigning");return}if(d){d.assignee=s.value;try{localStorage.setItem("nm-for",s.value)}catch{}ft()}}),b.addEventListener("input",t=>{const e=t.target.closest(".dt-suggest-input");if(e&&d?.suggest){d.suggest.to=e.value,ft(),ln(e);return}const n=t.target.closest(".dt-note-input, .dt-note-reply-input, .dt-note-edit-input");n&&(ia(n),n.classList.contains("dt-note-input")?d&&(d.text=n.value):n.classList.contains("dt-note-edit-input")?M&&(M.text=n.value):U=n.value,ft(),n.closest(".dt-compose")?.querySelector(".dt-send")?.classList.toggle("is-ready",n.value.trim()!==""),ln(n))}),b.addEventListener("keydown",t=>{const e=t.target.closest(".dt-note-input, .dt-note-reply-input, .dt-note-edit-input");if(!e)return;const n=e.closest(".dt-compose")?.querySelector(".dt-mentions button");if(n&&(t.key==="Enter"||t.key==="Tab")&&!t.isComposing){t.preventDefault(),As(e,n.dataset.handle);return}if(n&&t.key==="Escape"){t.stopPropagation(),n.parentElement.remove();return}t.key!=="Enter"||t.shiftKey||t.isComposing||(t.preventDefault(),e.closest(".dt-compose")?.querySelector(".dt-send")?.click())}),b.addEventListener("click",async t=>{const e=t.target.closest("button");if(!e)return;const n=e.dataset.act,s=Number(e.dataset.id);if(n==="share"){const o=e.dataset.v==="1";s?et(a=>a.map(r=>r.id===s?{...r,shared:o||void 0}:r),()=>A("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:s,shared:o})}),o?"Sharing with the client":"Keeping it to the team"):d&&(d.shared=o||void 0,ft(),h());return}if(n==="prio"){const o=e.dataset.v||null;s?et(a=>a.map(r=>r.id===s?{...r,priority:o??void 0}:r),()=>A("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:s,priority:o})}),"Setting the priority"):d&&(d.priority=o??void 0,ft(),h());return}if(n==="mention"){const o=e.closest(".dt-compose")?.querySelector("textarea");o&&As(o,e.dataset.handle);return}if(!n){if(w=w===s?null:s,w!=null&&e.dataset.off){const o=v.find(r=>r.id===s);(o&&Q(o))?.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})}Y(),h();return}if(n==="record"){Do(e.closest(".dt-note"));return}if(n==="speak"){_o(e.closest(".dt-note"),e);return}if(n==="voice-write"){Wo(e);return}if(n==="voice"||n==="voice-seek"){No(e,n==="voice-seek"?t:null);return}if(n==="attach"){const o=Object.assign(document.createElement("input"),{type:"file",accept:"image/*",multiple:!0}),a=e.closest(".dt-note");o.addEventListener("change",()=>{o.files?.length&&rn([...o.files],a)}),o.click();return}if(n==="unshot"){s?M&&M.drop.push(e.dataset.img):(e.closest("[data-draft]")?d?.images??[]:V).splice(Number(e.dataset.i),1),h(),M&&Hs();return}if(n==="edit"){const o=v.find(u=>u.id===s),a=e.dataset.at||null,r=a?o?.replies?.find(u=>u.at===a)?.text:o?.text;if(r===void 0)return;M={id:s,at:a,text:r,drop:[]},h(),Hs();return}if(n==="edit-cancel"){M=null,h();return}if(n==="unsay"){const o=e.dataset.at;if(!confirm("Delete this reply?"))return;await et(a=>a.map(r=>r.id!==s?r:{...r,replies:(r.replies??[]).map(u=>u.at===o?{...u,text:"",deleted:!0}:u)}),()=>A("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:s,unsay:o})}),"Deleting the reply");return}if(n==="edit-save"){const o=M;if(!o)return;const a=o.text.trim();if(!a){b.querySelector(".dt-note-edit-input")?.focus();return}M=null;const r=u=>o.drop.includes(u.split("/").pop());await et(u=>u.map(m=>m.id!==o.id?m:{...m,...o.at==null?{text:a}:{replies:(m.replies??[]).map(i=>i.at===o.at?{...i,text:a}:i)},images:(m.images??[]).filter(i=>!r(i))}),()=>A("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:o.id,edit:{at:o.at,text:a},...o.drop.length?{removeImage:o.drop}:{}})}).then(u=>(u.ok||(M=o),u)),"Saving the edit");return}if(n==="cancel"){Y(),h();return}if(n==="twin"){Y(),w=Number(e.dataset.id),h();return}if(n==="discard"){d=null,h();return}if(n==="draft-open"){Ze(Number(e.dataset.i));return}if(n==="close"){w=null,h();return}if(n==="suggest"&&d){const o=Vn(Q(d));d.suggest={from:o,to:o},h();const a=b.querySelector(".dt-suggest-input");a?.focus(),a?.select();return}if(n==="unsuggest"&&d){d.suggest=null,h();return}if(n==="save"){if(!d)return;const o=d.suggest&&d.suggest.to.trim()!==d.suggest.from?{from:d.suggest.from,to:d.suggest.to.trim()}:null,a=b.querySelector(".dt-note-input").value.trim()||(o?"Change the text":"")||(d.images?.some(ze)?rs:"");if(!a){b.querySelector(".dt-note-input")?.focus();return}const r=d,u=Ms.get(r)??an(Q(r)),m={...r,route:z,text:a,suggest:o,assignee:p.client?r.assignee||p.lead||void 0:r.assignee??_t(),shared:p.client?!0:r.shared===!0,stage:p.client?"new":r.stage??(W(r.assignee??_t())?"approved":"new"),breakpoint:dt(),browser:ro(),device:E?Ns:"",viewport:{w:innerWidth,h:innerHeight},logs:Ha(),host:location.host},i={...r,id:-Date.now(),text:a,route:z,status:"open",note:"",doneBy:null,breakpoint:m.breakpoint,replies:[],images:[],createdAt:new Date().toISOString(),...o?{suggest:o}:{},by:p.me?.email,byName:p.me?.name};v=[...v,i],d=null,h();const c=await u,y=await A("comments",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...m,...c?{before:c}:{}})});if(!y.ok){v=v.filter($=>$!==i),d=r,h(),O(`Comment was not saved (${y.status}).`);return}const l=Ut([await y.json().catch(()=>null)])[0];v=v.map($=>$===i&&l?l:$),h(),ve();return}if(n==="reply"){const o=b.querySelector(".dt-note-reply-input"),a=o.value.trim()||(V.some(ze)?rs:"");if(!a){o.focus();return}const r=V;U="",V=[];const u=v;v=v.map(c=>c.id===s?{...c,replies:[...c.replies??[],{author:"you",text:a,at:new Date().toISOString(),by:p.me?.email}]}:c),h();const m=await A("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:s,reply:a,images:r})});if(!m.ok){v=u,U=a,V=r,h(),O(`Reply was not sent (${m.status}).`);return}const i=Ut([await m.json().catch(()=>null)])[0];i&&(v=v.map(c=>c.id===i.id?i:c),h()),ve();return}if(n==="hand"){yo(s,e.dataset.v);return}w=null,n==="rm"?await ms(s):await zt(s,n==="done")});let Gt="overlay",Ht="",Ns="";const P=t=>{B.hidden||T.contentWindow?.postMessage({dt:!0,...t},location.origin)},da=()=>({notes:N,grid:!ne.hidden,inspect:it,resolved:Z,scrollbar:Gt,device:Ht});addEventListener("message",t=>{if(t.origin!==location.origin||!t.data?.dt)return;const e=t.data;if(!E&&t.source===T.contentWindow){if(e.key){_s(e.key[0],e.key[1])?.run();return}if(e.closeMenus){Rt();return}if(e.drafts){Ye=e.drafts,gs(le());return}}if(E&&typeof e.openDraft=="number"){Ze(e.openDraft);return}if(E&&typeof e.dropDraft=="number"){hs(e.dropDraft);return}if(E&&typeof e.device=="string"&&(Ns=e.device),E&&e.scrollbar&&document.documentElement.classList.toggle("dt-sb-classic",e.scrollbar==="classic"),e.hello&&t.source===T.contentWindow){P(da());return}typeof e.notes=="boolean"&&e.notes!==N&&pt(e.notes,!1),typeof e.open=="number"&&Ge(e.open),typeof e.grid=="boolean"&&e.grid===ne.hidden&&He(e.grid),typeof e.inspect=="string"&&e.inspect!==it&&se(e.inspect),typeof e.resolved=="boolean"&&e.resolved!==Z&&en(e.resolved),e.reload&&(wt(),be())});const ve=async()=>{await wt(),be(),P({reload:!0}),E&&parent.postMessage({dt:!0,reload:!0},location.origin)},pt=(t,e=!0)=>{if(N=t,kn.setAttribute("aria-pressed",String(t)),t?!E&&K.hidden&&localStorage.getItem("dt-history")!=="0"&&(K.hidden=!1,oe.setAttribute("aria-pressed","true")):(K.hidden=!0,oe.setAttribute("aria-pressed","false")),X(Rn,t?"1":"0"),P({notes:t}),E&&e&&parent.postMessage({dt:!0,notes:t},location.origin),b.hidden=!t||!B.hidden,document.documentElement.classList.toggle("dt-noting",t),t){se(""),document.addEventListener("click",Ls,!0);for(const n of Es)document.addEventListener(n,Ss,!0);document.addEventListener("keydown",ws),document.addEventListener("mousemove",$s),addEventListener("scroll",mt,!0),addEventListener("resize",mt),bs.observe(document.body,{childList:!0,subtree:!0,characterData:!0}),ys.observe(document.body),wt()}else{Y(),w=null,document.removeEventListener("click",Ls,!0);for(const n of Es)document.removeEventListener(n,Ss,!0);document.removeEventListener("keydown",ws),document.removeEventListener("mousemove",$s),ht.hidden=!0,removeEventListener("scroll",mt,!0),removeEventListener("resize",mt),bs.disconnect(),ys.disconnect(),b.innerHTML=""}},$e="dt-w",dn="dt-canvas",At="dt-device";let gt=localStorage.getItem(dn)==="1",S=localStorage.getItem(At)||"";S&&!ee(S)&&(S="",localStorage.setItem(At,""));let C=Number(localStorage.getItem($e))||0;const Cs="dt-emu";let F=(()=>{try{return JSON.parse(localStorage.getItem(Cs)||"null")}catch{return null}})();const we=()=>F?Ys.find(t=>t.id===F.id)??null:null,ca=()=>{const t=we();return t?F.turned?{w:t.h,h:t.w}:{w:t.w,h:t.h}:null};let Zt=localStorage.getItem("dt-bars-min")==="1";const Nt=t=>{F=t,X(Cs,t?JSON.stringify(t):"")},cn=t=>{Nn.textContent=t,B.style.setProperty("--dt-badge-w",`${Nn.offsetWidth}px`)},Bs=t=>{if(!t){It.innerHTML="";return}let e="";for(let n=0;n<=t;n+=50)e+=`<span class="dt-tick${n%200===0?" is-major":""}" style="left:${n}px"></span>`;for(const n of I)for(const s of[n.min,n.max])s>0&&Number.isFinite(s)&&s<=t&&(e+=`<span class="dt-edge" style="left:${s}px" title="${n.label} edge"></span>`);It.innerHTML=e,It.style.width=`${t}px`},un=()=>{const t=parseFloat(L.style.width)||0,e=parseFloat(L.style.height)||0;if(!t||!e){L.style.transform="",delete L.dataset.scaled;return}const n=S||F?Math.min(1,(innerWidth-80)/t,(innerHeight-120)/e):Math.min(1,(innerWidth-80)/t);L.style.transform=n<1?`scale(${n})`:"",L.dataset.scaled=n<1?String(Math.round(n*100)):""},ua=t=>Ys.find(e=>e.w===t.w&&e.h===t.h&&e.cutout?.shape==="pill")?.cutout,Ee=()=>{try{return T.contentDocument}catch{return null}},Rs=()=>Ee()?.title.split("\u2014").pop()?.trim()||"",mn=()=>{const t=Ee(),e=S?ee(S):null;if(!t?.body||!e)return;const n=ka(t),s=e.browser==="chrome-android"?n.theme||"rgb(255, 255, 255)":n.top,o=e.browser==="chrome-android"?"rgb(255, 255, 255)":n.bottom;L.style.setProperty("--dt-top",s),L.style.setProperty("--dt-top-ink",Js(s)),L.style.setProperty("--dt-bottom",o),L.style.setProperty("--dt-bottom-ink",Js(o));const a=qt.querySelector(".dt-win-tab > span");a&&(a.textContent=Rs()||location.host)};let pn=0;T.addEventListener("load",()=>{Ee()&&(mn(),T.contentWindow?.addEventListener("scroll",()=>{pn||(pn=requestAnimationFrame(()=>{pn=0,mn()}))},{passive:!0}))});for(const t of[qt,ae])t.addEventListener("click",e=>{const n=e.target.closest("[data-nav]")?.dataset.nav;if(n)try{const s=T.contentWindow?.navigation;if(!Ee()||!s)throw new Error("foreign");n==="back"?s.canGoBack&&s.back():n==="fwd"?s.canGoForward&&s.forward():s.reload()}catch{(n==="reload"||n==="back")&&(T.src=location.href)}});Dt.addEventListener("click",()=>{Zt=!Zt,X("dt-bars-min",Zt?"1":"0"),lt()});const lt=()=>{if(E)return;const t=S?ee(S)??null:null;if(S&&!t&&(S="",localStorage.setItem(At,"")),!t&&!gt){B.hidden=!0,T.removeAttribute("src"),document.documentElement.classList.remove("dt-framing"),b.hidden=!N,It.innerHTML="",Pt(),Ie.hidden=!0,Dt.hidden=!0,rt=null,Ht="",Ye=[],Pt(),fn(),N?wt():h();return}if(B.hidden=!1,document.documentElement.classList.add("dt-framing"),b.hidden=!0,T.src||(T.src=location.href),t){const e=xa(t,{host:location.host,title:Rs(),now:new Date,min:Zt,cutout:ua(t)}),{screen:n}=e;B.dataset.mode="device",L.dataset.shell=t.shell,L.dataset.browser=t.browser,L.style.width=`${e.footprint.w}px`,L.style.height=`${e.footprint.h}px`,L.style.setProperty("--dt-r",`${n.r}px`),L.style.setProperty("--dt-rb",`${n.rb}px`),Hn.innerHTML=e.shell;const s=(r,u,m,i)=>{r.innerHTML=i,r.style.cssText=`left:${n.x}px;top:${u}px;width:${n.w}px;height:${m}px`};s(qt,n.y,e.topH,e.top),s(ae,n.y+n.h-e.bottomH,e.bottomH,e.bottom);const o=n.h-e.topH-e.bottomH;T.style.position="absolute",T.style.left=`${n.x}px`,T.style.top=`${n.y+e.topH}px`,T.style.width=`${n.w}px`,T.style.height=`${o}px`,It.innerHTML="";const a=Zt&&e.canMinimize;Gt=e.scrollbar,Ht=`${t.label}${a?" \xB7 bars folded":""}`,rt=Bt(t.w),P({notes:N,scrollbar:Gt,device:Ht}),Dt.hidden=!e.canMinimize,Dt.setAttribute("aria-pressed",String(a)),cn(`${t.label} \xB7 page ${t.w}\xD7${o} of ${t.w}\xD7${t.h}${a?" \xB7 bars folded":""} \xB7 ${I.find(r=>r.id===rt)?.label??""}`),mn()}else{const e=ca();e||Nt(null);const n=e?.w||C||I.find(a=>a.id===dt()).ideal;C=n,B.dataset.mode="canvas",delete L.dataset.shell,delete L.dataset.browser,Hn.innerHTML=qt.innerHTML=ae.innerHTML="",qt.style.cssText=ae.style.cssText="",Dt.hidden=!0,Gt="overlay",L.style.width=`${n}px`,L.style.height=`${e?.h??innerHeight-84}px`,T.style.position="",T.style.left=T.style.top="",T.style.width="100%",T.style.height="100%",Bs(n),P({notes:N});const s=I.find(a=>a.id===Bt(n)),o=we();Ht=o?`${o.label}${F?.turned?" \xB7 landscape":""}`:"",P({scrollbar:Gt,device:Ht}),cn(o&&e?`${o.label} \xB7 ${e.w}\xD7${e.h} \xB7 ${s.label}`:`${n}px \xB7 ${s.label}`),rt=Bt(n)}Ie.hidden=!(we()?.rotates&&!t),fn(),un(),Pt(),N?wt():h()},gn=t=>{const e=I.find(n=>n.id===t);S="",localStorage.setItem(At,""),Nt(null),gt=t!==xe,C=gt?e.ideal:0,rt=gt?t:null,localStorage.setItem(dn,gt?"1":"0"),localStorage.setItem($e,String(C)),w=null,Y(),lt()};for(const t of Re)t.addEventListener("click",()=>gn(t.dataset.bp));for(const t of document.querySelectorAll("[data-device]"))t.addEventListener("click",()=>{S=t.dataset.device===S?"":t.dataset.device,localStorage.setItem(At,S),G.open=!1,lt()});for(const t of document.querySelectorAll("[data-emu]"))t.addEventListener("click",()=>{const e=F?.id===t.dataset.emu&&!S;S="",localStorage.setItem(At,""),Nt(e?null:{id:t.dataset.emu,turned:!1}),gt=!e,C=0,localStorage.setItem(dn,gt?"1":"0"),rt=null,w=null,Y(),G.open=!1,lt()});Ie.addEventListener("click",()=>{F&&(Nt({...F,turned:!F.turned}),w=null,Y(),lt())});const qs=[...G.querySelectorAll("[data-tab]")],ma=[...G.querySelectorAll("[data-panel]")],Is=t=>{for(const e of qs)e.setAttribute("aria-selected",String(e.dataset.tab===t));for(const e of ma)e.hidden=e.dataset.panel!==t;X("dt-devices-tab",t)};for(const t of qs)t.addEventListener("click",()=>Is(t.dataset.tab));Is(localStorage.getItem("dt-devices-tab")==="devtools"?"devtools":"preview");const hn=G.querySelector(".dt-emu-search");hn.addEventListener("input",()=>{const t=hn.value.trim().toLowerCase();let e=null,n=!1;const s=()=>{e&&(e.hidden=!n)};for(const o of hn.parentElement.children){if(o.classList.contains("dt-devices-group")){s(),e=o,n=!1;continue}o.dataset.emu&&(o.hidden=!!t&&!o.textContent.toLowerCase().includes(t),n||=!o.hidden)}s()});const pa=G.querySelector(".dt-devices-name");function fn(){for(const e of G.querySelectorAll("[data-device]"))e.setAttribute("aria-pressed",String(e.dataset.device===S));const t=!S&&!B.hidden?F?.id:void 0;for(const e of G.querySelectorAll("[data-emu]"))e.setAttribute("aria-pressed",String(e.dataset.emu===t));pa.textContent=S&&ee(S)?.label||t&&we()?.label||"Device"}const bn=t=>I.find(e=>e.id===t),ga=t=>{const e=bn(rt??dt());return Math.max(e.min||320,Math.min(Number.isFinite(e.max)?e.max:2560,Math.round(t)))};for(const t of oo){const e=t.dataset.edge==="l"?-1:1;t.addEventListener("pointerdown",n=>{if(S)return;n.preventDefault(),F&&(Nt(null),lt()),t.setPointerCapture(n.pointerId);const s=n.clientX,o=C,a=Number(L.dataset.scaled||100)/100;B.dataset.dragging="1";const r=m=>{C=ga(o+e*(m.clientX-s)*2/a),L.style.width=`${C}px`,Bs(C),cn(`${C}px \xB7 ${bn(Bt(C)).label}`),un()},u=()=>{t.removeEventListener("pointermove",r),t.removeEventListener("pointerup",u),delete B.dataset.dragging,localStorage.setItem($e,String(C)),lt()};t.addEventListener("pointermove",r),t.addEventListener("pointerup",u)}),t.addEventListener("dblclick",()=>{if(S)return;Nt(null);const n=bn(rt??dt()),s=[n.min||320,Number.isFinite(n.max)?n.max:n.ideal];C=Math.abs(C-s[0])<Math.abs(C-s[1])?s[0]:s[1],localStorage.setItem($e,String(C)),lt()})}let Ds=dt();addEventListener("resize",()=>{Pt(),dt()!==Ds&&(Ds=dt(),h()),B.hidden||(!S&&!F&&(L.style.height=`${innerHeight-84}px`),un())});const Os="dt-studio",Ps=t=>{qe.setAttribute("aria-pressed",String(t)),document.documentElement.classList.toggle("dt-no-studio",!t),X(Os,t?"1":"0")};qe.addEventListener("click",()=>Ps(qe.getAttribute("aria-pressed")!=="true")),Ps(localStorage.getItem(Os)!=="0"),kn.addEventListener("click",()=>pt(!N));const Ct=document.querySelector(".devtools"),Qt=document.querySelector(".dt-tab"),Fs=t=>{Ct.toggleAttribute("data-collapsed",t),Qt.toggleAttribute("data-collapsed",t),Qt.setAttribute("aria-expanded",String(!t)),Qt.setAttribute("aria-label",t?"Show the bar":"Hide the bar");for(const e of Ct.querySelectorAll(".dt-group"))e.inert=t;t&&Rt(),X("dt-collapsed",t?"1":"0")};Qt.addEventListener("click",()=>Fs(!Ct.hasAttribute("data-collapsed")));const yn=document.querySelector(".dt-keys"),st=t=>()=>Ct.querySelector(t)?.click(),js=t=>()=>{const e=[...document.querySelectorAll(".dt-pages a")];e[e.findIndex(n=>n.hasAttribute("aria-current"))+t]?.click()},Se=[{group:"Comments",code:"KeyC",hint:"C",label:"Comment mode",el:".dt-notes-btn",run:st(".dt-notes-btn")},{group:"Comments",code:"KeyC",shift:!0,hint:"\u21E7C",label:"Comments panel",el:".dt-history-btn",run:st(".dt-history-btn")},{group:"Comments",code:"KeyR",hint:"R",label:"Show resolved",el:".dt-resolved-btn",run:st(".dt-resolved-btn")},{group:"Inspect",code:"KeyG",hint:"G",label:"Grid",el:".dt-grid-btn",run:st(".dt-grid-btn")},{group:"Inspect",code:"KeyP",hint:"P",label:"Spacing",el:".dt-pad-btn",run:st(".dt-pad-btn")},{group:"Inspect",code:"KeyS",hint:"S",label:"Size",el:".dt-size-btn",run:st(".dt-size-btn")},{group:"Inspect",code:"KeyT",hint:"T",label:"Typography",el:".dt-type-btn",run:st(".dt-type-btn")},{group:"Inspect",code:"KeyO",hint:"O",label:"Color",el:".dt-color-btn",run:st(".dt-color-btn")},{group:"Inspect",code:"KeyB",hint:"B",label:"Border & radius",el:".dt-border-btn",run:st(".dt-border-btn")},...p.sanity?[{group:"Inspect",code:"KeyE",hint:"E",label:"Sanity overlay",el:".dt-studio-btn",run:st(".dt-studio-btn")}]:[],...Re.slice(0,9).map((t,e)=>({group:"Breakpoints",code:`Digit${e+1}`,hint:String(e+1),label:t.dataset.tip??t.title,el:`.dt-bp[data-bp="${t.dataset.bp}"]`,run:()=>t.click()})),{group:"View",code:"KeyD",hint:"D",label:"Devices",run:()=>{G.open=!G.open}},{group:"View",code:"BracketLeft",hint:"[",label:"Previous page",run:js(-1)},{group:"View",code:"BracketRight",hint:"]",label:"Next page",run:js(1)},{group:"View",code:"Backslash",hint:"\\",label:"Hide the bar",run:()=>Qt.click()},{group:"View",code:"Slash",shift:!0,hint:"?",label:"This list",el:".dt-keys summary",run:()=>{yn.open=!yn.open}}].filter(t=>!p.client||t.group!=="Inspect"),_s=(t,e)=>Se.find(n=>n.code===t&&!n.shift==!e),ha=t=>t instanceof HTMLElement&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)||!!t.closest('[role="menu"], [role="listbox"], [role="dialog"][aria-modal="true"], [role="combobox"]'));if(p.shortcuts){for(const e of Se){const n=e.el&&Ct.querySelector(e.el);n&&(n.dataset.tip=`${n.dataset.tip??e.label} \xB7 ${e.hint}`,n.setAttribute("aria-keyshortcuts",e.hint.startsWith("\u21E7")?`Shift+${e.hint.slice(1)}`:e.hint))}const t=(e,n)=>`<div class="dt-key-row"><span>${g(e)}</span><kbd>${g(n)}</kbd></div>`;if(yn.querySelector(".dt-keys-menu").innerHTML='<p class="dt-menu-note">One key, no modifier, in any keyboard layout. Not while you type.</p>'+[...new Set(Se.map(e=>e.group))].map(e=>`<p class="dt-devices-group">${e}</p>`+Se.filter(n=>n.group===e).map(n=>t(n.label,n.hint)).join("")).join("")+'<p class="dt-devices-group">In a comment</p>'+t("Send","Enter")+t("New line","\u21E7Enter")+t("Close, cancel, back out","Esc"),document.addEventListener("keydown",e=>{if(e.repeat||e.isComposing||e.metaKey||e.ctrlKey||e.altKey||e.defaultPrevented||ha(e.target))return;const n=_s(e.code,e.shiftKey);n&&(e.preventDefault(),E?parent.postMessage({dt:!0,key:[e.code,e.shiftKey]},location.origin):n.run())}),E){const e=()=>parent.postMessage({dt:!0,closeMenus:!0},location.origin);document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",n=>{n.key==="Escape"&&e()})}}if(!E){Fs(localStorage.getItem("dt-collapsed")==="1"),requestAnimationFrame(()=>requestAnimationFrame(()=>Ct.setAttribute("data-ready",""))),gt||S?lt():fn(),He(localStorage.getItem(En)==="1");const t=localStorage.getItem(Mn);t&&t in Ce&&se(t),pt(localStorage.getItem(Rn)==="1")}const Ks=()=>{try{const t=JSON.parse(localStorage.getItem(Mt)||"null");D=(t?.parked??[]).filter(e=>ie(e)),t?.draft&&document.querySelector(t.draft.selector)?(d=t.draft,!N&&!E&&pt(!0)):ie(t?.draft)&&D.push(t.draft),t?.reply?.text&&(U=t.reply.text,Ot=w=t.reply.for??null),(d||D.length||U)&&h()}catch{localStorage.removeItem(Mt)}};Ks();const Ws=()=>setTimeout(()=>{const t=ke(location.pathname);t!==z&&(clearTimeout(re),Pe(),z=t,Mt=qn(),d=null,D=[],U="",Ot=null,w=null,M=null,v=[],Ln(),Ks(),wt())});for(const t of["pushState","replaceState"]){const e=window.history[t];window.history[t]=function(...n){e.apply(this,n),Ws()}}addEventListener("popstate",Ws),N||wt(),be().then(()=>{he()&&fe()}),document.addEventListener("visibilitychange",()=>{document.hidden||Xt()}),addEventListener("focus",Xt),addEventListener("notemend:changed",()=>{E||Xt()});let fa=0;E||setInterval(()=>{(!Ta.live||++fa%6===0)&&Xt()},2e4),E&&parent.postMessage({dt:!0,hello:!0},location.origin)}export{Ua as run};
|
|
70
|
+
${xn("dt-note-input",l.suggest?"Why (optional)":"Comment",l.text??"",'data-act="save"',Mn(l.images),Zs&&!l.suggest&&mn(a?q(l):null)?`<button class="dt-attach" data-act="suggest" title="Rewrite this text: start from its current words and change them">${lo}</button>`:"")}
|
|
71
|
+
${bn(l.priority,l.category,void 0,l.assignee??"")}
|
|
72
|
+
</div>`}const i=new Map([...h.querySelectorAll(".dt-note[data-id] .dt-note-thread")].map(r=>[r.closest(".dt-note").dataset.id,{top:r.scrollTop,end:r.scrollTop+r.clientHeight>=r.scrollHeight-4}])),d=new Set([...h.querySelectorAll("[data-msg]")].map(r=>r.dataset.msg)),u=h.contains(document.activeElement)&&document.activeElement.matches(".dt-note-reply-input");h.innerHTML=s,u&&Ut(".dt-note-reply-input");for(const r of h.querySelectorAll(".dt-note[data-id] .dt-note-thread")){const y=r.closest(".dt-note").dataset.id,g=i.get(y);if(!g)continue;const w=[...r.querySelectorAll("[data-msg]")].filter(M=>!d.has(M.dataset.msg));for(const M of w)M.classList.add("dt-msg--new");r.scrollTop=g.end&&w.length?r.scrollHeight:g.top}for(const r of h.querySelectorAll(".dt-note")){const y=r.getBoundingClientRect();y.bottom>innerHeight-8&&(r.dataset.flip="1"),y.right>innerWidth-8&&(r.dataset.flipx="1")}Bn(n),pe(an()),X();for(const r of h.querySelectorAll(".dt-note-input, .dt-note-reply-input, .dt-note-edit-input"))Oe(r);const p=h.querySelector(".dt-note-input");p&&(p.focus(),p.setSelectionRange(p.value.length,p.value.length))},ko=()=>{let t=!1;for(const e of h.querySelectorAll(".dt-pin[data-id], .dt-note[data-id]")){if(e.classList.contains("dt-note--orphan"))continue;const n=b.find(o=>o.id===Number(e.dataset.id)),s=n&&I(n);if(!s){e.style.visibility="hidden";continue}e.style.visibility="",e.style.left=`${s.x}px`,e.style.top=`${s.y}px`,e.classList.contains("dt-pin")&&(s.off?e.dataset.off=s.off:delete e.dataset.off),on(s.el)&&(t=!0)}for(const e of h.querySelectorAll("[data-draft], [data-parked]")){if(e.classList.contains("dt-note--orphan"))continue;const n=e.dataset.parked?A[Number(e.dataset.parked)]:l,s=n&&I(n);if(!s){e.style.visibility="hidden";continue}e.style.visibility="",e.style.left=`${s.x}px`,e.style.top=`${s.y}px`}if(!Dt.length&&(l||$!=null)){const e=an();e&&on(e)&&pe(e)}t&&X()},xo=t=>b.filter(e=>J(e)===J(t)).findIndex(e=>e.id===t.id)+1,Bn=t=>{H.hidden||(H.innerHTML=ca({bp:t,notes:b,breakpoints:dt,bandOfNote:J,orphan:e=>!I(e),whoseAgent:at,statusTools:Cn,showResolved:W,drafts:st.hidden?An():we,checks:E?0:ke.toCheck().length}))},Te=t=>H.toggleAttribute("data-collapsed",t);H.addEventListener("click",async t=>{const e=t.target.closest("[data-refresh]");if(e){e.dataset.spin="1",await zt(),setTimeout(()=>delete e.dataset.spin,500);return}if(H.hasAttribute("data-collapsed")&&t.target.closest(".dt-hist-head")){Te(!1);return}if(t.target.closest("[data-fold]")){Te(!H.hasAttribute("data-collapsed"));return}const n=t.target.closest(".dt-hist-bands [data-bp]");if(n){Zn(n.dataset.bp);return}const s=t.target.closest("[data-draft-go], [data-draft-rm]");if(s){const p=s.dataset.draftRm!==void 0,r=Number(p?s.dataset.draftRm:s.dataset.draftGo);st.hidden?p?Dn(r):Le(r):B(p?{dropDraft:r}:{openDraft:r});return}const o=t.target.closest("[data-unmark]");if(o){t.stopPropagation(),await pt(Number(o.dataset.unmark),!1);return}const a=t.target.closest(".dt-hist-tools [data-act]");if(a){await pt(Number(a.dataset.id),a.dataset.act==="done");return}const i=t.target.closest("[data-rm]");if(i){$=null,await Ee(Number(i.dataset.rm));return}if(t.target.closest("[data-review]")){ke.start();return}if(t.target.closest("[data-resolved]")){Ae(!W);return}const d=t.target.closest("[data-go]");if(!d)return;const u=Number(d.dataset.go);if(!st.hidden){B({open:u});return}Me(u)});const Me=t=>{$=t,K(),f();const e=b.find(s=>s.id===t),n=e&&I(e);n?scrollTo({top:scrollY+n.y-innerHeight/2,behavior:"smooth"}):e&&q(e)?.scrollIntoView({block:"center",behavior:"smooth"}),matchMedia("(prefers-reduced-motion: reduce)").matches||h.querySelector(`.dt-pin[data-id="${t}"]`)?.animate([{transform:"scale(1)"},{transform:"scale(1.5)"},{transform:"scale(1)"}],400)},Le=t=>{const[e]=A.splice(t,1);if(!e)return;K(),l=e,$=null;const n=I(e);n&&(n.y<0||n.y>innerHeight)&&scrollTo({top:scrollY+n.y-innerHeight/3,behavior:"instant"}),f()},Dn=t=>{A.splice(t,1),f()},ke=ua({inFrame:E,everything:()=>mt,route:()=>j,settle:pt,keepIn:tn,toast:t=>k(t),open:t=>{if(x||Q(!0),J(t)!==Ot()){Zn(J(t));for(const e of[600,1500])setTimeout(()=>B({open:t.id}),e)}else Me(t.id)}}),Ao=t=>{H.hidden=!t,Ht.setAttribute("aria-pressed",String(t)),G("dt-history",t?"1":"0"),f()},xe=document.querySelector(".dt-resolved-btn"),Ae=t=>{W=t,xe.setAttribute("aria-pressed",String(t)),G("dt-resolved",t?"1":"0"),B({resolved:t}),f(),Kt()};xe.addEventListener("click",()=>Ae(!W)),xe.setAttribute("aria-pressed",String(W)),Ht.addEventListener("click",()=>{const t=H.hidden===!0;t&&!x&&Q(!0),t&&Te(!1),Ao(t)});const X=()=>{le||!x||(le=requestAnimationFrame(()=>{le=0,ko()}))},qn=new MutationObserver(t=>{t.every(e=>e.target.closest?.(".dt-notes-overlay"))||X()}),In=new ResizeObserver(()=>X());let mt=[];const Pn=t=>{mt=t;const e=()=>({open:0,claude:0,done:0}),n={};for(const d of t){const u=rt(d),p=n[d.route??""]??={...e(),bands:{}};p[u]++;const r=J(d);(p.bands[r]??=e())[u]++}const s=["open","claude","done"],o={open:"open",claude:"resolved by an agent, to check",done:"resolved"},a=d=>s.map(u=>[u,u==="done"&&!W?0:d[u]]),i=d=>a(d).reduce((u,[,p])=>u+p,0);for(const d of document.querySelectorAll(".dt-pages a")){const u=d.querySelector(".dt-pages-n");if(!u)continue;const p=n[new URL(d.href).pathname.replace(/\/+$/,"")||"/"];for(const g of dt){const w=p?.bands[g.id];for(const[M,N]of a(w??e())){const Z=u.querySelector(`[data-bp="${g.id}"][data-state="${M}"]`);Z.hidden=!N,N&&(Z.querySelector("i").textContent=String(N),Z.title=`${g.label}: ${N} ${o[M]}`)}}const r=p?i(p):0;u.hidden=!r;const y=p?dt.filter(g=>p.bands[g.id]&&i(p.bands[g.id])).map(g=>`${g.label} ${i(p.bands[g.id])}`).join(" \xB7 "):"";u.title=r?`${p.open} open \xB7 ${p.claude} resolved by an agent, to check \xB7 ${p.done} resolved
|
|
73
|
+
${y}`:""}},St=t=>(Array.isArray(t)?t:[]).filter(e=>e&&Number.isInteger(Number(e.id))&&typeof e.text=="string").map(e=>({...e,id:Number(e.id),rx:Number(e.rx)||0,ry:Number(e.ry)||0,route:typeof e.route=="string"&&/^\/(?![\/\\])/.test(e.route)?e.route:"/",replies:Array.isArray(e.replies)?e.replies.filter(n=>typeof n?.text=="string"):[],images:Array.isArray(e.images)?e.images.filter(n=>typeof n=="string"):[]})),Kt=async()=>{try{Pn(St((await(await L("comments")).json()).comments)),!H.hidden&&!E&&f()}catch{}},Fn=pa(E,t=>k(t));let Wt="",He=!1;const Tt=async()=>{if(!(document.hidden||He)){He=!0;try{const t=await L(`comments${Wt?`?since=${Wt}`:""}`);if(t.status!==200)return;const e=await t.json();Wt=e.version??"",Fn(e);const n=St(e.comments);Pn(n);const s=n.filter(o=>o.route===j);if(JSON.stringify(s)===JSON.stringify(b))return;if(h.contains(document.activeElement)&&document.activeElement.matches("textarea, input")){Wt="",setTimeout(Tt,5e3);return}b=s,f(),B({reload:!0})}catch{}finally{He=!1}}},gt=async()=>{try{const e=await(await L(`comments?route=${encodeURIComponent(j)}`)).json();b=St(e.comments),Fn(e)}catch{b=[]}f()};let Ne=0;const jn=t=>{Ne||(Ne=requestAnimationFrame(()=>{Ne=0;const e=t.target;if(!x||e.closest(ee)){nt.hidden=!0;return}nt.hidden=!0;const n=document.elementFromPoint(t.clientX,t.clientY);if(nt.hidden=!1,!n)return;const s=n.getBoundingClientRect();Ls.style.cssText=`left:${s.left}px;top:${s.top}px;width:${s.width}px;height:${s.height}px`,Qe.textContent=n.tagName.toLowerCase()+([...n.classList].find(o=>!/^(astro|svelte)-/.test(o))?"."+[...n.classList].find(o=>!/^(astro|svelte)-/.test(o)):"")+` ${Math.round(s.width)}\xD7${Math.round(s.height)}`,Qe.style.cssText=`left:${s.left}px;top:${Math.max(2,s.top-20)}px`}))},_n=t=>{if(!(t.key!=="Escape"||t.isComposing)){if(t.preventDefault(),T){T=null,f();return}if(l){K(),f();return}if($!==null){$=null,f();return}Q(!1)}},Kn=["pointerdown","mousedown","pointerup","mouseup","touchstart","touchend"],Wn=t=>{t.target.closest?.(ee)||t.stopPropagation()},Un=t=>{if(t.target.closest(ee))return;if(t.preventDefault(),t.stopPropagation(),te){te=!1;return}if(!getSelection()?.isCollapsed)return;h.hidden=!0;const n=document.elementFromPoint(t.clientX,t.clientY);if(h.hidden=!1,!n)return;K();const s=n.getBoundingClientRect(),o=n.tagName.toLowerCase(),a=[...n.classList].filter(i=>!/^(astro|svelte|css)-/.test(i)).slice(0,2);l={selector:Hs(n),tag:o,classes:a,nth:Ns({tag:o,classes:a}).indexOf(n),rx:s.width?(t.clientX-s.left)/s.width:.5,ry:s.height?(t.clientY-s.top)/s.height:.5,label:ht(n.textContent||"").slice(0,60),ctx:Cs(n),category:_e[0].id},Yn.set(l,Ce(n)),$=null,nt.hidden=!0,f()},Ho=2200,No=900*1024,zn=8*1024*1024,Co=3*1024*1024,Ro=1200,Oo=1600,Ce=async t=>{let e=t instanceof HTMLElement?t:null;for(let o=0;e&&o<4&&e.parentElement&&e.parentElement!==document.body;o++){const a=e.getBoundingClientRect();if(a.width>=360&&a.height>=140)break;e=e.parentElement}const n=e?.getBoundingClientRect();if(!e||!n?.width||!n.height)return null;let s="";for(let o=e;o&&!s;o=o.parentElement){const a=getComputedStyle(o).backgroundColor;a&&a!=="transparent"&&!/rgba\(.*,\s*0\)$/.test(a)&&(s=a)}if(!s){const[o,a,i]=(getComputedStyle(e).color.match(/[\d.]+/g)??["0","0","0"]).map(Number);s=.299*o+.587*a+.114*i>140?"#111":"#fff"}try{const{domToWebp:o}=await import("modern-screenshot"),a=Math.min(devicePixelRatio||1,2,Ro/n.width,Oo/n.height),i=await Promise.race([o(e,{scale:a,quality:.8,timeout:4e3,backgroundColor:s,filter:d=>!(d instanceof Element&&d.closest(Ze))}),new Promise(d=>setTimeout(()=>d(null),8e3))]);return i&&i.length<zn?i:null}catch{return null}},Yn=new WeakMap,k=t=>{const e=document.createElement("div");e.className="dt-toast",e.textContent=t,document.body.append(e),setTimeout(()=>e.remove(),2800)},Bo=t=>new Promise(e=>{const n=new FileReader;n.onload=()=>e(String(n.result)),n.readAsDataURL(t)}),Do=async t=>{const e=await createImageBitmap(t),n=Math.min(1,Ho/Math.max(e.width,e.height));if(n===1&&t.size<=No)return e.close(),Bo(t);const s=document.createElement("canvas");return s.width=Math.round(e.width*n),s.height=Math.round(e.height*n),s.getContext("2d").drawImage(e,0,0,s.width,s.height),e.close(),s.toDataURL("image/jpeg",.85)},Re=async(t,e)=>{const n=[];for(const s of t){let o;const a=Object.keys(Lt).find(i=>Lt[i]===s.type||s.name.toLowerCase().endsWith(`.${i}`));if(a){if(s.size>Co){k(`${s.name} is over 3 MB \u2014 send a link to it instead.`);continue}const i=await new Promise((d,u)=>{const p=new FileReader;p.onload=()=>d(String(p.result).split(",")[1]),p.onerror=u,p.readAsDataURL(s)}).catch(()=>"");i?n.push(`data:${Lt[a]};name=${Xo(s.name)||"document"};base64,${i}`):k(`${s.name} could not be read.`);continue}try{o=await Do(s)}catch{k("That image could not be read.");continue}if(o.length>zn){k("Screenshot is too large even after shrinking.");continue}n.push(o)}if(n.length){if(!Number(e?.dataset.id)){l&&((l.images??=[]).push(...n),f());return}O.push(...n),f(),Ut(".dt-note-reply-input")}},Vn=t=>[...t??[]].filter(e=>e.kind==="file"&&(e.type.startsWith("image/")||Object.values(Lt).includes(e.type))).map(e=>e.getAsFile()).filter(Boolean);h.addEventListener("paste",t=>{const e=Vn(t.clipboardData?.items);e.length&&(t.preventDefault(),Re(e,t.target.closest(".dt-note")))}),h.addEventListener("dragover",t=>{t.target.closest(".dt-note")&&(t.preventDefault(),t.target.closest(".dt-note").querySelector(".dt-compose")?.setAttribute("data-drop",""))}),h.addEventListener("dragleave",t=>{t.target.closest(".dt-note")?.querySelector(".dt-compose")?.removeAttribute("data-drop")}),h.addEventListener("drop",t=>{const e=t.target.closest(".dt-note");if(!e)return;t.preventDefault(),e.querySelector(".dt-compose")?.removeAttribute("data-drop");const n=Vn(t.dataTransfer?.items);n.length&&Re(n,e)});const Ut=t=>{const e=h.querySelector(t);e?.focus(),e?.setSelectionRange(e.value.length,e.value.length)},Jn=()=>{Ut(".dt-note-edit-input"),h.querySelector(".dt-msg .dt-compose")?.scrollIntoView({block:"nearest"})},Oe=t=>{t.style.overflowY="hidden",t.style.height="auto",t.style.height=`${t.scrollHeight}px`,t.style.overflowY=t.scrollHeight>t.clientHeight?"auto":"hidden"},qo=t=>/(?:^|\s)@([^\s@]*)$/.exec(t.value.slice(0,t.selectionStart??t.value.length)),Io=()=>c.client||he()?[]:us(),Po=t=>{t.closest(".dt-compose").querySelector(".dt-mentions")?.remove();const n=qo(t);if(!n)return;const s=n[1].toLowerCase(),o=(c.team??[]).filter(i=>[i.name,i.nickname,i.email].some(d=>d?.toLowerCase().startsWith(s))).slice(0,5),a=Io().filter(i=>i.handle.toLowerCase().startsWith(s)||!!s&&"agent".startsWith(s)||!!s&&"claude".startsWith(s)).slice(0,4);!o.length&&!a.length||t.insertAdjacentHTML("afterend",`<div class="dt-mentions" role="listbox" aria-label="Mention someone">${[...o.map(i=>`<button type="button" role="option" data-act="mention" data-handle="${m(Qo(i))}">${Pt(i.avatar_url,i.name||i.email)}<span class="dt-mention-who"><b>${m(i.name||i.email)}</b>${i.name?`<span>${m(i.email)}</span>`:""}</span></button>`),...a.map(i=>`<button type="button" role="option" data-act="mention" data-handle="${m(i.handle)}">${_s(i.owner)}<span class="dt-mention-who"><b>${m(i.handle)}</b><span>${i.owner?"Hands it to this agent":"The shared queue \u2014 any agent takes it"}</span></span></button>`)].map((i,d)=>i.replace('role="option"',`role="option" aria-selected="${d===0}"`)).join("")}</div>`)},Fo=t=>{const e=[...(c.team??[]).flatMap(s=>[s.name,s.nickname,s.email]),...us().map(s=>s.handle)].filter(s=>!!s).sort((s,o)=>o.length-s.length).map(s=>m(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),n=m(t);return e.length?n.replace(new RegExp(`@(?:${e.join("|")})(?![\\p{L}\\p{N}_.-])`,"giu"),s=>`<span class="dt-at">${s}</span>`):n},Gn=(t,e)=>{const n=t.selectionStart??t.value.length,s=t.value.slice(0,n).lastIndexOf("@");t.value=`${t.value.slice(0,s)}@${e} ${t.value.slice(n)}`,t.selectionStart=t.selectionEnd=s+e.length+2,t.closest(".dt-compose")?.querySelector(".dt-mentions")?.remove(),t.dispatchEvent(new Event("input",{bubbles:!0})),t.focus()},jo=(t,e)=>{if(!t){l&&(l.category=e),f();return}P(n=>n.map(s=>s.id===t?{...s,category:e}:s),()=>L("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:t,category:e})}),"Changing the type")};ra(h,m,Gt);const Xn=(t,e)=>{t?P(n=>n.map(s=>s.id===t?{...s,shared:e||void 0}:s),()=>L("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:t,shared:e})}),e?"Sharing with the client":"Keeping it to the team"):l&&(l.shared=e||void 0,ot(),f())};h.addEventListener("change",t=>{const e=t.target.closest(".dt-more-select");if(e){const i=e.value,d=Number(e.dataset.id)||0;e.value="",i==="team"||i==="client"?Xn(d,i==="client"):i==="rm"&&confirm("Delete this thread and its replies? This cannot be undone.")?($=null,Ee(d)):i==="discard"&&(l=null,f());return}const n=t.target.closest(".dt-cat-select");if(n){jo(Number(n.dataset.id)||0,n.value);return}const s=t.target.closest(".dt-status-select");if(s){Vs(Number(s.dataset.id),s.value);return}const o=t.target.closest(".dt-for-select");if(!o)return;o.parentElement?.style.setProperty("--cat",vt(o.value));const a=Number(o.dataset.id);if(a){const i=o.value||null;P(d=>d.map(u=>u.id===a?{...u,assignee:i??void 0}:u),()=>L("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:a,assignee:i})}),"Reassigning");return}if(l){l.assignee=o.value;try{localStorage.setItem("nm-for",o.value)}catch{}ot()}}),h.addEventListener("input",t=>{const e=t.target.closest(".dt-suggest-input");if(e&&l?.suggest){l.suggest.to=e.value,ot(),Oe(e);return}const n=t.target.closest(".dt-note-input, .dt-note-reply-input, .dt-note-edit-input");n&&(Po(n),n.classList.contains("dt-note-input")?l&&(l.text=n.value):n.classList.contains("dt-note-edit-input")?T&&(T.text=n.value):R=n.value,ot(),n.closest(".dt-compose")?.querySelector(".dt-send")?.classList.toggle("is-ready",n.value.trim()!==""),Oe(n))}),h.addEventListener("keydown",t=>{const e=t.target.closest(".dt-note-input, .dt-note-reply-input, .dt-note-edit-input");if(!e)return;const n=e.closest(".dt-compose")?.querySelector(".dt-mentions button");if(n&&(t.key==="Enter"||t.key==="Tab")&&!t.isComposing){t.preventDefault(),Gn(e,n.dataset.handle);return}if(n&&t.key==="Escape"){t.stopPropagation(),n.parentElement.remove();return}t.key!=="Enter"||t.shiftKey||t.isComposing||(t.preventDefault(),e.closest(".dt-compose")?.querySelector(".dt-send")?.click())}),h.addEventListener("click",async t=>{const e=t.target.closest("button");if(!e)return;const n=e.dataset.act,s=Number(e.dataset.id);if(n==="share"){Xn(s,e.dataset.v==="1");return}if(n==="prio"){const o=e.dataset.v||null;s?P(a=>a.map(i=>i.id===s?{...i,priority:o??void 0}:i),()=>L("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:s,priority:o})}),"Setting the priority"):l&&(l.priority=o??void 0,ot(),f());return}if(n==="mention"){const o=e.closest(".dt-compose")?.querySelector("textarea");o&&Gn(o,e.dataset.handle);return}if(!n){if($=$===s?null:s,$!=null&&e.dataset.off){const o=b.find(i=>i.id===s);(o&&q(o))?.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})}K(),f();return}if(n==="record"){uo(e.closest(".dt-note"));return}if(n==="speak"){ho(e.closest(".dt-note"),e);return}if(n==="voice-write"){yo(e);return}if(n==="voice"||n==="voice-seek"){so(e,n==="voice-seek"?t:null);return}if(n==="attach"){const o=Object.assign(document.createElement("input"),{type:"file",accept:`image/*,.pdf,.doc,.docx,${Object.values(Lt)}`,multiple:!0}),a=e.closest(".dt-note");o.addEventListener("change",()=>{o.files?.length&&Re([...o.files],a)}),o.click();return}if(n==="unshot"){s?T&&T.drop.push(e.dataset.img):(e.closest("[data-draft]")?l?.images??[]:O).splice(Number(e.dataset.i),1),f(),T&&Jn();return}if(n==="edit"){const o=b.find(d=>d.id===s),a=e.dataset.at||null,i=a?o?.replies?.find(d=>d.at===a)?.text:o?.text;if(i===void 0)return;T={id:s,at:a,text:i,drop:[]},f(),Jn();return}if(n==="edit-cancel"){T=null,f();return}if(n==="translate"){vo(s,e.dataset.at);return}if(n==="unsay"){const o=e.dataset.at;if(!confirm("Delete this reply?"))return;await P(a=>a.map(i=>i.id!==s?i:{...i,replies:(i.replies??[]).map(d=>d.at===o?{...d,text:"",deleted:!0}:d)}),()=>L("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:s,unsay:o})}),"Deleting the reply");return}if(n==="edit-save"){const o=T;if(!o)return;const a=o.text.trim();if(!a){h.querySelector(".dt-note-edit-input")?.focus();return}T=null;const i=d=>o.drop.includes(d.split("/").pop());await P(d=>d.map(u=>u.id!==o.id?u:{...u,...o.at==null?{text:a}:{replies:(u.replies??[]).map(p=>p.at===o.at?{...p,text:a}:p)},images:(u.images??[]).filter(p=>!i(p))}),()=>L("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:o.id,edit:{at:o.at,text:a},...o.drop.length?{removeImage:o.drop}:{}})}).then(d=>(d.ok||(T=o),d)),"Saving the edit");return}if(n==="cancel"){K(),f();return}if(n==="twin"){K(),$=Number(e.dataset.id),f();return}if(n==="discard"){l=null,f();return}if(n==="draft-open"){Le(Number(e.dataset.i));return}if(n==="close"){$=null,f();return}if(n==="suggest"&&l){const o=mn(q(l));l.suggest={from:o,to:o},f();const a=h.querySelector(".dt-suggest-input");a?.focus(),a?.select();return}if(n==="unsuggest"&&l){l.suggest=null,f();return}if(n==="save"){if(!l)return;const o=l.suggest&&l.suggest.to.trim()!==l.suggest.from?{from:l.suggest.from,to:l.suggest.to.trim()}:null,a=h.querySelector(".dt-note-input").value.trim()||(o?"Change the text":"")||(l.images?.some(ye)?kn:"");if(!a){h.querySelector(".dt-note-input")?.focus();return}const i=l,d=c.client?null:ps(a,qt()),u=Yn.get(i)??Ce(q(i)),p={...i,route:j,text:a,suggest:o,assignee:c.client?i.assignee||c.lead||void 0:d??(i.assignee||void 0),shared:c.client?!0:i.shared===!0,stage:c.client?"new":d?"approved":i.stage??(D(i.assignee)?"approved":"new"),breakpoint:ue(),browser:As(),device:E?Qn:"",viewport:{w:innerWidth,h:innerHeight},logs:sa(),host:location.host},r={...i,id:-Date.now(),text:a,route:j,status:"open",note:"",doneBy:null,breakpoint:p.breakpoint,replies:[],images:[],createdAt:new Date().toISOString(),...o?{suggest:o}:{},by:c.me?.email,byName:c.me?.name};b=[...b,r],l=null,f();const y=await u,g=await L("comments",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...p,...y?{before:y}:{}})});if(!g.ok){b=b.filter(M=>M!==r),l=i,f(),k(`Comment was not saved (${g.status}).`);return}const w=St([await g.json().catch(()=>null)])[0];b=b.map(M=>M===r&&w?w:M),f(),zt();return}if(n==="reply"){const o=h.querySelector(".dt-note-reply-input"),a=o.value.trim()||(O.some(ye)?kn:"");if(!a){o.focus();return}const i=O;R="",O=[];const d=b,u=c.client?null:ps(a,qt()),p=b.find(w=>w.id===s),r=u&&p&&(u!==p.assignee||lt(p)!=="approved"||p.status==="done")?{assignee:u,stage:"approved",...p.status==="done"?{status:"open",doneBy:null}:{}}:{};b=b.map(w=>w.id===s?{...w,...r,replies:[...w.replies??[],{author:"you",text:a,at:new Date().toISOString(),by:c.me?.email}]}:w),f();const y=await L("comments",{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({id:s,reply:a,images:i,...r})});if(!y.ok){b=d,R=a,O=i,f(),k(`Reply was not sent (${y.status}).`);return}const g=St([await y.json().catch(()=>null)])[0];g&&(b=b.map(w=>w.id===g.id?g:w),f()),zt();return}if(n==="hand"){Ps(s,e.dataset.v);return}if(n==="sendback"){await pt(s,!1),Ut(".dt-note-reply-input");return}e.classList.contains("dt-step-act")||($=null),n==="rm"?await Ee(s):await pt(s,n==="done")});let Qn="";const B=t=>{st.hidden||Nt.contentWindow?.postMessage({dt:!0,...t},location.origin)},_o=()=>({notes:x,grid:!xt.hidden,inspect:_,resolved:W,...ts.look()});addEventListener("message",t=>{if(t.origin!==location.origin||!t.data?.dt)return;const e=t.data;if(!E&&t.source===Nt.contentWindow){if(e.key){as(e.key[0],e.key[1])?.run();return}if(e.closeMenus){bt();return}if(e.drafts){we=e.drafts,Bn(Ot());return}}if(E&&typeof e.openDraft=="number"){Le(e.openDraft);return}if(E&&typeof e.dropDraft=="number"){Dn(e.dropDraft);return}if(E&&typeof e.device=="string"&&(Qn=e.device),E&&e.scrollbar&&document.documentElement.classList.toggle("dt-sb-classic",e.scrollbar==="classic"),e.hello&&t.source===Nt.contentWindow){B(_o());return}typeof e.notes=="boolean"&&e.notes!==x&&Q(e.notes,!1),typeof e.open=="number"&&Me(e.open),typeof e.grid=="boolean"&&e.grid===xt.hidden&&Zt(e.grid),typeof e.inspect=="string"&&e.inspect!==_&&At(e.inspect),typeof e.resolved=="boolean"&&e.resolved!==W&&Ae(e.resolved),e.reload&&(gt(),Kt())});const zt=async()=>{await gt(),Kt(),B({reload:!0}),E&&parent.postMessage({dt:!0,reload:!0},location.origin)},Q=(t,e=!0)=>{if(x=t,Xe.setAttribute("aria-pressed",String(t)),t?!E&&H.hidden&&localStorage.getItem("dt-history")!=="0"&&(H.hidden=!1,Ht.setAttribute("aria-pressed","true")):(H.hidden=!0,Ht.setAttribute("aria-pressed","false")),G(en,t?"1":"0"),B({notes:t}),E&&e&&parent.postMessage({dt:!0,notes:t},location.origin),h.hidden=!t||!st.hidden,document.documentElement.classList.toggle("dt-noting",t),t){At(""),document.addEventListener("click",Un,!0);for(const n of Kn)document.addEventListener(n,Wn,!0);document.addEventListener("keydown",_n),document.addEventListener("mousemove",jn),addEventListener("scroll",X,!0),addEventListener("resize",X),qn.observe(document.body,{childList:!0,subtree:!0,characterData:!0}),In.observe(document.body),gt()}else{K(),$=null,document.removeEventListener("click",Un,!0);for(const n of Kn)document.removeEventListener(n,Wn,!0);document.removeEventListener("keydown",_n),document.removeEventListener("mousemove",jn),nt.hidden=!0,removeEventListener("scroll",X,!0),removeEventListener("resize",X),qn.disconnect(),In.disconnect(),h.innerHTML=""}},{pickBp:Zn,...ts}=da({cfg:c,inFrame:E,persist:G,frame:st,frameEl:Nt,devicesMenu:ie,bpBtns:oe,notesOverlay:h,WIDE:Xt,bpOf:Ke,currentBp:ue,deviceById:ys,notesOn:()=>x,filter:()=>de,filterTo:t=>{de=t},dropFrameDrafts:()=>{we=[]},putAway:()=>{$=null,K()},tellFrame:B,syncBpButtons:sn,render:()=>f(),reread:()=>{x?gt():f()}}),es="dt-studio",ns=t=>{ae.setAttribute("aria-pressed",String(t)),document.documentElement.classList.toggle("dt-no-studio",!t),G(es,t?"1":"0")};ae.addEventListener("click",()=>ns(ae.getAttribute("aria-pressed")!=="true")),ns(localStorage.getItem(es)!=="0"),Xe.addEventListener("click",()=>Q(!x));const ft=document.querySelector(".devtools"),Mt=document.querySelector(".dt-tab"),ss=t=>{ft.toggleAttribute("data-collapsed",t),Mt.toggleAttribute("data-collapsed",t),Mt.setAttribute("aria-expanded",String(!t)),Mt.setAttribute("aria-label",t?"Show the bar":"Hide the bar");for(const e of ft.querySelectorAll(".dt-group"))e.inert=t;t&&bt(),G("dt-collapsed",t?"1":"0")};Mt.addEventListener("click",()=>ss(!ft.hasAttribute("data-collapsed")));const Be=document.querySelector(".dt-keys"),F=t=>()=>ft.querySelector(t)?.click(),os=t=>()=>{const e=[...document.querySelectorAll(".dt-pages a")];e[e.findIndex(n=>n.hasAttribute("aria-current"))+t]?.click()},Yt=[{group:"Comments",code:"KeyC",hint:"C",label:"Comment mode",el:".dt-notes-btn",run:F(".dt-notes-btn")},{group:"Comments",code:"KeyC",shift:!0,hint:"\u21E7C",label:"Comments panel",el:".dt-history-btn",run:F(".dt-history-btn")},{group:"Comments",code:"KeyR",hint:"R",label:"Show resolved",el:".dt-resolved-btn",run:F(".dt-resolved-btn")},{group:"Inspect",code:"KeyG",hint:"G",label:"Grid",el:".dt-grid-btn",run:F(".dt-grid-btn")},{group:"Inspect",code:"KeyP",hint:"P",label:"Spacing",el:".dt-pad-btn",run:F(".dt-pad-btn")},{group:"Inspect",code:"KeyS",hint:"S",label:"Size",el:".dt-size-btn",run:F(".dt-size-btn")},{group:"Inspect",code:"KeyT",hint:"T",label:"Typography",el:".dt-type-btn",run:F(".dt-type-btn")},{group:"Inspect",code:"KeyO",hint:"O",label:"Color",el:".dt-color-btn",run:F(".dt-color-btn")},{group:"Inspect",code:"KeyB",hint:"B",label:"Border & radius",el:".dt-border-btn",run:F(".dt-border-btn")},...c.sanity?[{group:"Inspect",code:"KeyE",hint:"E",label:"Sanity overlay",el:".dt-studio-btn",run:F(".dt-studio-btn")}]:[],...oe.slice(0,9).map((t,e)=>({group:"Breakpoints",code:`Digit${e+1}`,hint:String(e+1),label:t.dataset.tip??t.title,el:`.dt-bp[data-bp="${t.dataset.bp}"]`,run:()=>t.click()})),{group:"View",code:"KeyD",hint:"D",label:"Devices",run:()=>{ie.open=!ie.open}},{group:"View",code:"BracketLeft",hint:"[",label:"Previous page",run:os(-1)},{group:"View",code:"BracketRight",hint:"]",label:"Next page",run:os(1)},{group:"View",code:"Backslash",hint:"\\",label:"Hide the bar",run:()=>Mt.click()},{group:"View",code:"Slash",shift:!0,hint:"?",label:"This list",el:".dt-keys summary",run:()=>{Be.open=!Be.open}}].filter(t=>!c.client||t.group!=="Inspect"),as=(t,e)=>Yt.find(n=>n.code===t&&!n.shift==!e),Ko=t=>t instanceof HTMLElement&&(t.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName)||!!t.closest('[role="menu"], [role="listbox"], [role="dialog"][aria-modal="true"], [role="combobox"]'));if(c.shortcuts){for(const e of Yt){const n=e.el&&ft.querySelector(e.el);n&&(n.dataset.tip=`${n.dataset.tip??e.label} \xB7 ${e.hint}`,n.setAttribute("aria-keyshortcuts",e.hint.startsWith("\u21E7")?`Shift+${e.hint.slice(1)}`:e.hint))}const t=(e,n)=>`<div class="dt-key-row"><span>${m(e)}</span><kbd>${m(n)}</kbd></div>`;if(Be.querySelector(".dt-keys-menu").innerHTML='<p class="dt-menu-note">One key, no modifier, in any keyboard layout. Not while you type.</p>'+[...new Set(Yt.map(e=>e.group))].map(e=>`<p class="dt-devices-group">${e}</p>`+Yt.filter(n=>n.group===e).map(n=>t(n.label,n.hint)).join("")).join("")+'<p class="dt-devices-group">In a comment</p>'+t("Send","Enter")+t("New line","\u21E7Enter")+t("Close, cancel, back out","Esc"),document.addEventListener("keydown",e=>{if(e.repeat||e.isComposing||e.metaKey||e.ctrlKey||e.altKey||e.defaultPrevented||Ko(e.target))return;const n=as(e.code,e.shiftKey);n&&(e.preventDefault(),E?parent.postMessage({dt:!0,key:[e.code,e.shiftKey]},location.origin):n.run())}),E){const e=()=>parent.postMessage({dt:!0,closeMenus:!0},location.origin);document.addEventListener("pointerdown",e,!0),document.addEventListener("keydown",n=>{n.key==="Escape"&&e()})}}if(!E){ss(localStorage.getItem("dt-collapsed")==="1"),requestAnimationFrame(()=>requestAnimationFrame(()=>ft.setAttribute("data-ready",""))),ts.restore(),Zt(localStorage.getItem(Ue)==="1");const t=localStorage.getItem(Je);t&&t in ne&&At(t),Q(localStorage.getItem(en)==="1")}const is=()=>{try{const t=JSON.parse(localStorage.getItem(ut)||"null");A=(t?.parked??[]).filter(e=>Ct(e)),t?.draft&&document.querySelector(t.draft.selector)?(l=t.draft,!x&&!E&&Q(!0)):Ct(t?.draft)&&A.push(t.draft),t?.reply?.text&&(R=t.reply.text,yt=$=t.reply.for??null),(l||A.length||R)&&f()}catch{localStorage.removeItem(ut)}};is();const rs=()=>setTimeout(()=>{const t=Qt(location.pathname);t!==j&&(clearTimeout(Rt),ce(),j=t,ut=nn(),l=null,A=[],R="",yt=null,$=null,T=null,b=[],Ye(),is(),gt())});for(const t of["pushState","replaceState"]){const e=window.history[t];window.history[t]=function(...n){e.apply(this,n),rs()}}addEventListener("popstate",rs),x||gt(),Kt().then(ke.resume),document.addEventListener("visibilitychange",()=>{document.hidden||Tt()}),addEventListener("focus",Tt),addEventListener("notemend:changed",()=>{E||Tt()});let Wo=0;E||setInterval(()=>{(!ea.live||++Wo%6===0)&&Tt()},2e4),E&&parent.postMessage({dt:!0,hello:!0},location.origin)}export{Ha as run};
|