@hazem3500/palette 0.9.109 → 0.9.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -22
- package/cli/agent.mjs +7 -6
- package/cli/index.mjs +9 -5
- package/dist/chunk-U55ASP2Y.js +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/node.mjs +1 -1
- package/dist/{onboarding-YZ2MJBS5.js → onboarding-6OSADOWE.js} +1 -1
- package/dist/react.js +1 -1
- package/dist/server.js +1 -1
- package/dist/setup.js +1 -1
- package/package.json +1 -1
- package/server/setup-client.txt +2 -2
- package/dist/chunk-ZIEPA67C.js +0 -1
package/dist/setup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n,d as o}from"./chunk-
|
|
1
|
+
import{a as n,d as o}from"./chunk-U55ASP2Y.js";import"./chunk-KLPQTFVH.js";import"./chunk-RBHY7UDS.js";import"./chunk-LMXFSXO6.js";import"./chunk-DU7H4TEX.js";import"./chunk-5HZI7HRR.js";import"./chunk-2BS2OWWH.js";import"./chunk-J47R52WX.js";import"./chunk-VX6XCU4E.js";import"./chunk-4HBBEVFK.js";function r(r){return(t={})=>o(n({...r,...t}))}var t=r;export{t as defineKomo,r as definePalette};
|
package/package.json
CHANGED
package/server/setup-client.txt
CHANGED
|
@@ -146,7 +146,7 @@ Unsaved changes in the app are lost${n?", and so are design changes you haven't
|
|
|
146
146
|
.api-tokens-warning svg{flex:none;width:13px;height:13px;margin-top:2px;color:#f1b77d}
|
|
147
147
|
.api-tokens-skeleton{height:84px;border-radius:14px;background:linear-gradient(90deg,#ffffff05,#ffffff0d,#ffffff05) 0 0/200% 100%;animation:api-tokens-shimmer 1.4s linear infinite}
|
|
148
148
|
@keyframes api-tokens-shimmer{to{background-position:-200% 0}}
|
|
149
|
-
@media (prefers-reduced-motion:reduce){.api-tokens-skeleton{animation:none}}`,HK=0});function OK(e){let t=e.trim().replace(/\/$/,"").toLowerCase();if(/^http:\/\/(localhost|127\.0\.0\.1)(:(\d+|\*))?$/.test(t))return t;let n=/^https:\/\/([^/?#@\s:]+)(:(\d+|\*))?$/.exec(t.includes("://")?t:`https://${t}`),[o="",...i]=(n?.[1]??"").split(".");if(!n||i.length<1||i.join(".").includes("*")||o.split("*").length>2||o.includes("*")&&i.length<2)throw new Error("That doesn\u2019t look like a site. Try your-site.com or *-preview.your-site.com.");return`https://${n[1]}${n[2]??""}`}async function Xz(e,t=""){let n;try{let h=await e.request(`project/sites${t}`);n=[...h.fixed,...h.sites]}catch{return null}let o=w("div","approved-sites-editor");o.dataset.open="false";let i=w("span","approved-sites-count"),r=Oe("Sites with comments",()=>{let h=o.dataset.open!=="true";o.dataset.open=String(h),r.setAttribute("aria-expanded",String(h)),a.inert=!h},"approved-sites-toggle");r.replaceChildren(w("span","","Sites with comments"),i,bt("chevron")),r.setAttribute("aria-expanded","false");let a=w("div","approved-sites-reveal");a.id=`approved-sites-${crypto.randomUUID()}`,a.inert=!0,r.setAttribute("aria-controls",a.id);let s=w("div","approved-sites-body"),l=w("ul","approved-site-list"),c=w("p","account-usage-status");c.setAttribute("role","status");let u=w("div","approved-site-add"),d=w("input");d.type="text",d.inputMode="url",d.spellcheck=!1,d.placeholder="your-site.com",d.setAttribute("aria-label","Site to approve"),d.setAttribute("autocomplete","off");let p=w("div","account-usage-note account-sites-note");p.append(bt("info"),w("span","","Only these sites can show comments. Add * to cover preview links."));let g=async h=>{let m=n;n=h,x(),c.textContent="";try{let b=await e.request(`project/sites${t}`,"PATCH",{sites:h});return n=[...b.fixed,...b.sites],x(),!0}catch(b){return n=m,x(),c.textContent=b instanceof Error?b.message:"Try again.",!1}},y=Oe("Add",async()=>{let h;try{h=OK(d.value)}catch(b){c.textContent=b.message;return}if(n.includes(h)){d.value="",c.textContent="Already on the list.";return}let m=d.value;d.value="",y.disabled=!0,await g([...n,h])||(d.value||=m),y.disabled=!1,d.focus()},"secondary");d.addEventListener("keydown",h=>{h.key==="Enter"&&(h.preventDefault(),y.click())}),u.append(d,y);let v=h=>{let m=w("li","approved-site"),b=w("span","",h.replace(/^https:\/\//,""));return b.title=h,m.append(b,Oe(`Remove ${h}`,()=>{g(n.filter(E=>E!==h))},"icon","close")),m},x=()=>{i.textContent=String(n.length),l.replaceChildren(...n.map(v))};return x(),s.append(l,u,p,c),a.append(s),o.append(r,a),o}var Wz=O(()=>{"use strict";It()});function lm(e,t="usage",n=!0,o=!1){let i=w("section","account-usage");i.setAttribute("aria-label","Account usage");let r=(x="")=>{let h=w("span",`usage-skeleton ${x}`);return h.setAttribute("aria-hidden","true"),h},a=()=>{let x=w("div","usage-skeleton-heading");x.append(r("usage-skeleton-title"));let h=w("div","account-usage-label account-comments"),m=w("span","account-comment-count");m.append(r("usage-skeleton-count"),r("usage-skeleton-ring")),h.append(r("usage-skeleton-label"),m);let b=w("div","account-projects"),E=w("div","account-usage-label");E.append(r("usage-skeleton-label"),r("usage-skeleton-count"));let S=w("div","account-project-slots");S.setAttribute("aria-hidden","true"),S.append(w("span"),w("span"),w("span")),b.append(E,S);let A=w("span","sr-only","Loading account usage");A.setAttribute("role","status"),i.setAttribute("aria-busy","true"),i.replaceChildren(x,h,b,A)},s=e.user?.id,l=e.token,c=()=>e.user?.id===s&&e.token===l,u=Zz.get(e);u||Zz.set(e,u=new Map);let d=JSON.stringify([s,l,t]),p=u.get(d);p||u.set(d,p={});let g=async()=>{let x=t.includes("?")?t.slice(t.indexOf("?")):"",h=await Xz(e,x);h&&p.value&&i.isConnected&&c()&&i.append(h)},y=x=>{i.setAttribute("aria-busy","false"),i.replaceChildren(w("h3","",`${x.hosted?"Starter plan":"Self-hosted"}${o?" \xB7 Local":""}`));let{used:h,limit:m}=x.comments,b=w("div","account-usage-label account-comments"),E=w("span","account-comment-count");if(E.append(w("span","",m===null?`${h.toLocaleString()} / Unlimited`:`${h.toLocaleString()} / ${m.toLocaleString()}`)),b.title="Includes replies and deleted comments.",m!==null){let S=w("span","account-usage-ring");S.setAttribute("role","meter"),S.setAttribute("aria-label","Project comments"),S.setAttribute("aria-valuemin","0"),S.setAttribute("aria-valuemax",String(m)),S.setAttribute("aria-valuenow",String(Math.min(h,m))),S.setAttribute("aria-valuetext",`${h} of ${m} comments used, including replies and deleted comments`),S.style.setProperty("--usage",`${m>0?Math.min(h/m,1)*100:0}%`),S.dataset.full=String(h>=m),E.append(S)}if(b.append(w("span","","Project comments"),E),i.append(b),x.projects){let{used:S,limit:A}=x.projects;if(A===null){let z=w("div","account-usage-label");z.append(w("span","","Projects"),w("span","",`${S.toLocaleString()} / Unlimited`)),i.append(z);return}let _=w("div","account-projects"),T=w("div","account-usage-label"),H=w("span","account-project-count");H.append(w("strong","",String(S)),w("span","",`of ${A}`)),T.append(w("span","","Projects"),H);let D=w("div","account-project-slots");D.setAttribute("role","meter"),D.setAttribute("aria-label","Projects"),D.setAttribute("aria-valuemin","0"),D.setAttribute("aria-valuemax",String(A)),D.setAttribute("aria-valuenow",String(S)),D.setAttribute("aria-valuetext",`${S} of ${A} projects used`);for(let z=0;z<A;z++){let F=w("span");F.dataset.used=String(z<S),D.append(F)}_.append(T,D),i.append(_)}},v=async()=>{if(!c()){i.replaceChildren(),i.setAttribute("aria-busy","false");return}p.value?y(p.value):a(),i.setAttribute("aria-busy","true");try{let x=p.pending??=e.request(t),h;try{h=await x}finally{p.pending===x&&(p.pending=void 0)}if(!c()){delete p.value,i.replaceChildren(),i.setAttribute("aria-busy","false");return}if(p.value=h,!i.isConnected)return;y(h),n&&e.user?.verified&&g().catch(()=>{})}catch(x){if(x instanceof eo&&(x.status===401||x.status===403)&&delete p.value,!c()){delete p.value,i.replaceChildren(),i.setAttribute("aria-busy","false");return}if(!i.isConnected)return;p.value?y(p.value):i.replaceChildren(),i.setAttribute("aria-busy","false");let h=w("span","account-usage-status",p.value?"Couldn\u2019t refresh usage":"Usage unavailable");h.setAttribute("role","status"),i.append(h,Oe("Retry",()=>{v()},"secondary"))}};return v(),i}var Zz,Qz=O(()=>{"use strict";Ff();It();Wz();Zz=new WeakMap});function Jz(e,t,n){let o=w("section","account-sites project-management");o.dataset.open="false";let i=Oe("Project settings",()=>{let v=o.dataset.open!=="true";o.dataset.open=String(v),i.setAttribute("aria-expanded",String(v)),r.inert=!v,r.setAttribute("aria-hidden",String(!v))},"account-sites-summary");i.append(bt("chevron")),i.setAttribute("aria-expanded","false");let r=w("div","account-sites-reveal");r.id=`project-settings-${crypto.randomUUID()}`,i.setAttribute("aria-controls",r.id),r.inert=!0,r.setAttribute("aria-hidden","true");let a=w("div","account-sites-clip");r.append(a);let s=w("div","account-sites-content"),l=w("p","account-usage-status");l.setAttribute("role","status");let c=t?`?workspace=${encodeURIComponent(t)}`:"",u=(v,x="GET",h)=>e.request(`project${v}${c}`,x,h);o.hidden=!0,a.append(s,l),o.append(i,r);let d=async v=>{let x=Array.from(o.querySelectorAll("button"));x.forEach(h=>h.disabled=!0),l.textContent="";try{await v()}catch(h){l.textContent=h instanceof Error?h.message:"Try again."}finally{x.forEach(h=>h.disabled=!1)}},p=async()=>{let v={format:"komo-export",version:1,project:g.project,exportedAt:new Date().toISOString(),tables:{}},x;for(let b of["threads","comments","reactions","users","snapshots"]){v.tables[b]=[];let E=0;for(;E!==null;){let S=await e.request(`project/export?table=${b}&offset=${E}${x===void 0?"":`&revision=${x}`}${t?`&workspace=${encodeURIComponent(t)}`:""}`).catch(A=>{if(b==="snapshots"&&!E&&A.status===400)return null;throw A});if(!S){delete v.tables[b];break}x=S.revision,v.tables[b].push(...S.rows),E=S.next}}let h=URL.createObjectURL(new Blob([JSON.stringify(v,null,2)],{type:"application/json"})),m=w("a");m.href=h,m.download=`${g.project}-comments.json`,m.click(),setTimeout(()=>URL.revokeObjectURL(h),1e3),l.textContent="Export downloaded."},g,y=async()=>{g=await u(""),o.hidden=!1,s.replaceChildren();let v=w("div","account-name-label");v.append(w("span","","Access"));let x=[["public","Anyone with the link"],["private","Invited Google accounts"]],h,m=()=>{let W=ec("Project access",x,g.access,L=>{d(async()=>{let U=g.access;g.access=L,m();try{await u("","PATCH",{access:L}),l.textContent="Access updated."}catch(I){throw g.access=U,m(),I}})});h?h.replaceWith(W):v.append(W),h=W};m(),s.append(v);let b=await u("/webhook"),E=w("details","project-webhook");E.append(w("summary","","Comment webhooks"));let S=w("p","project-help","Send signed events to your HTTPS endpoint. Signing secrets are encrypted and shown only when entered.");E.append(S),b.deliveryAvailable||(S.textContent="Secure webhook delivery is not available on this server yet.");let A=w("label","account-name-label","HTTPS endpoint"),_=w("input");_.type="url",_.autocomplete="off",_.placeholder="https://example.com/palette-webhook",_.value=b.url,A.append(_),E.append(A);let T=w("label","account-name-label",b.secretConfigured?"Replace signing secret":"Signing secret"),H=w("input");H.type="password",H.autocomplete="new-password",H.minLength=32,H.maxLength=256,T.append(H),E.append(T);let D=new Map;for(let W of b.supportedEvents){let L=w("label","account-name-label",W),U=w("input");U.type="checkbox",U.checked=b.events.includes(W),D.set(W,U),L.prepend(U),E.append(L)}let z=w("label","account-name-label","Enable delivery"),F=w("input");F.type="checkbox",F.checked=b.enabled,F.disabled=!b.deliveryAvailable&&!b.enabled,z.prepend(F),E.append(z),E.append(Oe("Save webhook settings",()=>{d(async()=>{await u("/webhook","PATCH",{url:_.value,secret:H.value,events:[...D].filter(([,W])=>W.checked).map(([W])=>W),enabled:F.checked}),H.value="",l.textContent="Webhook settings saved."})},"secondary")),s.append(E);let B=w("label","account-name-label","Invite someone"),le=w("input");le.type="email",le.placeholder="name@example.com",le.autocomplete="email",B.append(le);let J=w("input");J.readOnly=!0,J.hidden=!0,J.setAttribute("aria-label","Invitation link");let V=Oe("Create invitation",()=>{d(async()=>{if(!le.checkValidity()||!le.value)throw Error("Enter an email address.");let W=await u("/invites","POST",{email:le.value});J.value=W.url,J.hidden=!1,oe.hidden=!1,l.textContent="Share this link. It expires in 7 days."})},"secondary"),oe=Oe("Copy invitation",()=>{d(async()=>{await navigator.clipboard.writeText(J.value),l.textContent="Invitation copied."})},"secondary");oe.hidden=!0,s.append(B,V,J,oe);for(let W of g.members){let L=w("div","project-member");L.append(w("span","",W.name),Oe(`Remove ${W.name}`,()=>{d(async()=>{await u("/members","DELETE",{user:W.id}),await y(),l.textContent="Member removed."})},"secondary")),s.append(L)}for(let W of g.invites){let L=w("div","project-member");L.append(w("span","",W.email),Oe("Revoke invitation",()=>{d(async()=>{await u("/invites","DELETE",{email:W.email}),await y(),l.textContent="Invitation revoked."})},"secondary")),s.append(L)}s.append(Oe("Download comments",()=>{d(p)},"secondary"));let pe=w("a","project-help","Move to self-hosting");pe.href="https://komo.offbr.co/hosting/#migration",pe.target="_blank",pe.rel="noopener noreferrer",s.append(pe);let q=w("details","project-danger");q.append(w("summary","","Free space or delete project")),q.append(w("p","",`Export first. These actions permanently remove comments. Type ${g.project} to confirm.`));let Y=w("input");Y.placeholder=g.project,Y.setAttribute("aria-label","Confirm project key"),q.append(Y),q.append(Oe("Delete resolved threads",()=>{d(async()=>{await u("/clear-resolved","POST",{confirm:Y.value}),n?.(!1),l.textContent="Resolved threads deleted.",Y.value=""})},"secondary destructive")),g.hosted&&q.append(Oe("Delete project",()=>{d(async()=>{await u("","DELETE",{confirm:Y.value}),n?.(!0),s.replaceChildren(),l.textContent="Project deleted. Its project slot is available again."})},"secondary destructive")),s.append(q)};return y().catch(v=>{v?.status!==403&&(o.hidden=!1,l.textContent="Project settings unavailable.",s.append(Oe("Retry",()=>{d(y)},"secondary")))}),o}var eO=O(()=>{"use strict";KS();It()});var e0={};Yt(e0,{accountUsage:()=>lm,onboardingPanel:()=>$K,projectManagement:()=>Jz});function $K(e,t){let n=w("section","onboarding-panel"),o=w("p","account-usage-status");o.setAttribute("role","status");let i=a=>{o.textContent=a instanceof Error?a.message:"Try again."},r=async()=>{let a=encodeURIComponent(t.workspace),s=w("div","account-sites"),l=w("div","account-sites-summary");l.append(w("span","","Approved sites"),bt("chevron")),s.append(l),s.setAttribute("aria-busy","true"),o.textContent="",n.replaceChildren(lm(e,`usage?workspace=${a}`,!1),s,o);try{let c=await e.request(`workspace?workspace=${a}`);if(!n.isConnected)return;o.textContent="";let u=w("section","account-sites");u.dataset.open="false";let d=Oe("",()=>{let A=u.dataset.open!=="true";u.dataset.open=String(A),d.setAttribute("aria-expanded",String(A)),p.inert=!A,p.setAttribute("aria-hidden",String(!A))},"account-sites-summary");d.setAttribute("aria-expanded","false");let p=w("div","account-sites-reveal");p.id=`approved-sites-${crypto.randomUUID()}`,p.inert=!0,p.setAttribute("aria-hidden","true"),d.setAttribute("aria-controls",p.id);let g=w("div","account-sites-clip"),y=w("span","account-sites-count");d.append(w("span","","Approved sites"),y,bt("chevron"));let v=w("div","account-sites-content"),x=w("div","approved-sites"),h=()=>{y.textContent=String(c.sites.length),x.replaceChildren(...c.sites.map(A=>w("span","",new URL(A).host)))};h();let m=w("label","account-name-label","Website"),b=w("input");b.type="url",b.placeholder="https://your-site.com",b.setAttribute("autocomplete","url"),b.value=t.site||c.suggested.find(A=>!c.sites.includes(A))||"",m.append(b);let E=Oe("Approve site",async()=>{let A;try{let H=new URL(b.value.trim());if(H.protocol!=="https:"||H.username||H.password)throw Error("Enter an HTTPS website address.");A=H.origin}catch(H){i(H);return}let _=[...c.sites],T=b.value;c.sites.includes(A)||c.sites.push(A),h(),b.value="",E.disabled=!0;try{await e.request("workspace/sites","POST",{project:t.workspace,origin:A}),t.site=void 0,o.textContent="Site approved"}catch(H){c.sites=_,h(),b.value||(b.value=T),i(H)}finally{E.disabled=!1}},"secondary");b.addEventListener("keydown",A=>{A.key==="Enter"&&(A.preventDefault(),E.click())});let S=w("div","account-usage-note account-sites-note");S.append(bt("info"),w("span","","Approved sites can show and share comments. Localhost comments are visible by default.")),v.append(x,m,E,S),g.append(v),p.append(g),u.append(d,p),s.replaceWith(u)}catch(c){i(c),n.append(Oe("Retry",()=>{r()},"secondary"))}};if(t.invite){let a=Oe("Accept invitation",async()=>{a.disabled=!0;try{await e.request("project/join","POST",{invite:t.invite}),t.invite=void 0,n.replaceChildren(w("p","","You\u2019re in. Return to the website to leave comments."))}catch(s){i(s),a.disabled=!1}},"primary");n.append(a,o)}else if(t.workspace)r();else if(t.code||t.claimKey){let a=Oe(t.code?"Create project":"Enable comments",async()=>{a.disabled=!0;let s=a.textContent;a.textContent=t.code?"Creating project\u2026":"Enabling comments\u2026";try{if(t.code){let l=await e.request("setup/complete","POST",{code:t.code});t.workspace=l.project,t.code=void 0,history.replaceState(null,"",`?workspace=${encodeURIComponent(l.project)}`),await r(),o.textContent="Project ready. Return to your terminal."}else await e.request("owner/claim","POST",{key:t.claimKey}),t.claimKey=void 0,n.replaceChildren(lm(e),o),o.textContent="Comments are ready."}catch(l){i(l),a.disabled=!1,a.textContent=s}},"primary");n.append(a,o)}else n.append(lm(e));return n}var t0=O(()=>{"use strict";Qz();eO();It()});function tO(){return[An("Post comment","Enter","Comments"),An("New line","Enter","Comments",{shift:!0})]}function oO(e=po(),t,n=Jd()){let o="Design canvas",i="Experimental geometry",r="Text editing",a="Compare",s=(u,d,p)=>({label:u,group:d,shortcut:p}),c=n.child?.key==="enter"&&!n.child.alt&&!n.child.shift&&!n.child.ctrl&&!n.child.meta?null:n.child;return[s("Next sibling",o,n.next),s("Previous sibling",o,n.prev),s("Parent element",o,n.parent),An("Post comment","Enter",o),...c?[s("First child",o,c)]:[],An(c?"First child (alternative)":"First child","ArrowDown",o,{alt:!0}),An("Parent element (alternative)","ArrowUp",o,{alt:!0}),An("Exit Design mode","Escape",o),An("Undo last preview","z",o,e?{meta:!0}:{ctrl:!0}),An("Redo last undo","z",o,e?{meta:!0,shift:!0}:{ctrl:!0,shift:!0}),...e?[]:[An("Redo last undo","y",o,{ctrl:!0})],An("Focus selection to move or resize","M",o),An("Move before previous sibling","ArrowUp",i,{alt:!0}),An("Move after next sibling","ArrowDown",i,{alt:!0}),An("Move out, after its parent","ArrowUp",i,{alt:!0,shift:!0}),An("Move into previous sibling","ArrowDown",i,{alt:!0,shift:!0}),An("Resize width","ArrowRight",i,e?{meta:!0}:{ctrl:!0}),An("Resize height","ArrowDown",i,e?{meta:!0}:{ctrl:!0}),An("Resize by 10px","ArrowRight",i,e?{meta:!0,shift:!0}:{ctrl:!0,shift:!0}),An("Back to the canvas","Escape",i),...t?[{label:"Hide or show selection \xB7 hold to peek",group:o,shortcut:t}]:[],An("Commit text","Enter",r),An("New line","Enter",r,{shift:!0}),An("Cancel text edit","Escape",r),An("Toggle before and after","B",a),s("Show before",a,n.before),s("Show after",a,n.after)]}function iO(e=po()){let t="Design canvas";return[{label:"Inspect element",group:t,keys:[],gesture:"Click",aria:"Click"},{label:"Select inner element",group:t,keys:[e?"\u2318":"Ctrl"],gesture:"Click",aria:`${e?"Command":"Control"} + Click`},{label:"Edit text",group:t,keys:[],gesture:"Double-click",aria:"Double-click"},{label:"Keyboard shortcuts",group:t,keys:["?"],aria:"?"}]}var An,nO,rO=O(()=>{"use strict";ea();Ey();An=(e,t,n,o={})=>({label:e,group:n,shortcut:{key:t,label:t,alt:!1,shift:!1,ctrl:!1,meta:!1,...o}});nO=()=>[An("Zoom to fit","1","Frame",{shift:!0}),An("Zoom to 100%","0","Frame",{shift:!0})]});var aO={};Yt(aO,{showShortcutHelp:()=>jK});function jK(e,t,n=!1,o,i,r=!1){let a=e.querySelector("dialog.palette-shortcuts");if(a)return a.querySelector("[autofocus]")?.focus();let s=e.activeElement??document.activeElement,l=s?.closest(".morphing-menu__panel")?e.querySelector('[data-menu-item="more"]'):s,c=w("dialog","palette-shortcuts");c.setAttribute("aria-modal","true"),c.setAttribute("aria-labelledby","palette-shortcuts-title");let u=w("h2","","Keyboard shortcuts");u.id="palette-shortcuts-title";let d=Oe("Close",()=>T(),"icon palette-shortcuts__close","close");d.removeAttribute("title");let p=w("span","morphing-menu__tooltip palette-shortcuts__tip","Close");p.setAttribute("aria-hidden","true"),p.append(Zd(["Esc"],"Escape"));let g=w("header");g.append(u,d,p);let y=w("input");y.type="search",y.placeholder="Filter shortcuts",y.setAttribute("aria-label","Filter shortcuts"),y.autocomplete="off",y.spellcheck=!1;let v=w("div","palette-shortcuts__body");v.tabIndex=0,v.setAttribute("autofocus",""),v.setAttribute("role","region"),v.setAttribute("aria-label","Shortcuts");let x=n?[...iO(),...oO(void 0,t.find(z=>/^(Hide|Show) comments$/.test(z.label))?.shortcut,i)]:[],h=[...t,...tO(),...r?nO():[]],m=(o==="design"?[...x,...h]:[...h,...x]).filter(z=>z.shortcut||z.keys?.length||z.gesture),b=[...new Set(m.map(z=>z.group??"General"))].sort((z,F)=>+(o==="comment"&&F==="Comments")-+(o==="comment"&&z==="Comments")),E=[];for(let z of b){let F=w("section");F.append(w("h3","",z));for(let B of m.filter(le=>(le.group??"General")===z)){let le=w("div","palette-shortcuts__row"),J=B.shortcut?Jr(B.shortcut):void 0;J&&le.setAttribute("aria-keyshortcuts",J.aria);let V=B.shortcut?Wd(B.shortcut):Zd(B.keys,B.aria??B.keys.join(" + "));B.gesture&&V.append(w("span","",B.gesture)),le.append(w("span","",B.label),V),F.append(le),E.push([le,`${B.label} ${V.getAttribute("aria-label")} ${V.textContent}`.toLowerCase()])}v.append(F)}let S=w("p","","No matching shortcuts");S.setAttribute("role","status"),S.hidden=!0,v.append(S,w("p","","Shortcuts pause while typing in a text field.")),y.addEventListener("input",()=>{let z=y.value.toLowerCase().split(/\s+/).filter(Boolean);for(let[F,B]of E)F.hidden=!z.every(le=>B.includes(le));for(let F of v.querySelectorAll("section"))F.hidden=!F.querySelector(".palette-shortcuts__row:not([hidden])");S.hidden=E.some(([F])=>!F.hidden)}),c.append(Object.assign(w("style"),{textContent:NK}),g,y,v);let A=new AbortController,{signal:_}=A,T=()=>{_.aborted||(A.abort(),c.close(),c.remove(),l?.isConnected&&l.focus({preventScroll:!0}))};c.addEventListener("close",T,{signal:_}),window.addEventListener("keydown",z=>{let F=z.composedPath().find(le=>le instanceof HTMLDialogElement&&le.open);if(F&&F!==c||(z.stopImmediatePropagation(),z.isComposing))return;let B=e.activeElement===y;if(z.key==="Escape"||z.key==="?"&&!B&&!z.ctrlKey&&!z.metaKey&&!z.altKey)z.preventDefault(),T();else if(z.key==="Tab"){let le=[d,y,v],J=le.indexOf(e.activeElement);z.preventDefault(),le[J<0?z.shiftKey?2:0:(J+(z.shiftKey?2:1))%3].focus()}},{capture:!0,signal:_});let H=!1,D=z=>{let F=c.getBoundingClientRect();return z.target===c&&(z.clientX<F.left||z.clientX>F.right||z.clientY<F.top||z.clientY>F.bottom)};c.addEventListener("pointerdown",z=>{H=D(z)},{signal:_}),c.addEventListener("click",z=>{H&&D(z)&&T()},{signal:_}),e.append(c),c.showModal()}var NK,sO=O(()=>{"use strict";rO();It();ea();NK=`.palette-shortcuts{box-sizing:border-box;width:min(720px,calc(100vw - 32px));max-width:none;max-height:min(680px,calc(100dvh - 32px));margin:auto;padding:0;overflow:hidden;border:0;border-radius:16px;background:var(--mm-surface);color:var(--mm-ink);box-shadow:inset 0 0 0 1px color-mix(in oklab,var(--mm-ink) 12%,transparent),0 24px 64px -16px rgb(0 0 0/55%);font:12px/1.4 -apple-system,BlinkMacSystemFont,"Inter","Segoe UI",sans-serif;pointer-events:auto;color-scheme:dark}
|
|
149
|
+
@media (prefers-reduced-motion:reduce){.api-tokens-skeleton{animation:none}}`,HK=0});function OK(e){let t=e.trim().replace(/\/$/,"").toLowerCase();if(/^http:\/\/(localhost|127\.0\.0\.1)(:(\d+|\*))?$/.test(t))return t;let n=/^https:\/\/([^/?#@\s:]+)(:(\d+|\*))?$/.exec(t.includes("://")?t:`https://${t}`),[o="",...i]=(n?.[1]??"").split(".");if(!n||i.length<1||i.join(".").includes("*")||o.split("*").length>2||o.includes("*")&&i.length<2)throw new Error("That doesn\u2019t look like a site. Try your-site.com or *-preview.your-site.com.");return`https://${n[1]}${n[2]??""}`}async function Xz(e,t=""){let n;try{let h=await e.request(`project/sites${t}`);n=[...h.fixed,...h.sites]}catch{return null}let o=w("div","approved-sites-editor");o.dataset.open="false";let i=w("span","approved-sites-count"),r=Oe("Sites with comments",()=>{let h=o.dataset.open!=="true";o.dataset.open=String(h),r.setAttribute("aria-expanded",String(h)),a.inert=!h},"approved-sites-toggle");r.replaceChildren(w("span","","Sites with comments"),i,bt("chevron")),r.setAttribute("aria-expanded","false");let a=w("div","approved-sites-reveal");a.id=`approved-sites-${crypto.randomUUID()}`,a.inert=!0,r.setAttribute("aria-controls",a.id);let s=w("div","approved-sites-body"),l=w("ul","approved-site-list"),c=w("p","account-usage-status");c.setAttribute("role","status");let u=w("div","approved-site-add"),d=w("input");d.type="text",d.inputMode="url",d.spellcheck=!1,d.placeholder="your-site.com",d.setAttribute("aria-label","Site to approve"),d.setAttribute("autocomplete","off");let p=w("div","account-usage-note account-sites-note");p.append(bt("info"),w("span","","Only these sites can show comments. Add * to cover preview links."));let g=async h=>{let m=n;n=h,x(),c.textContent="";try{let b=await e.request(`project/sites${t}`,"PATCH",{sites:h});return n=[...b.fixed,...b.sites],x(),!0}catch(b){return n=m,x(),c.textContent=b instanceof Error?b.message:"Try again.",!1}},y=Oe("Add",async()=>{let h;try{h=OK(d.value)}catch(b){c.textContent=b.message;return}if(n.includes(h)){d.value="",c.textContent="Already on the list.";return}let m=d.value;d.value="",y.disabled=!0,await g([...n,h])||(d.value||=m),y.disabled=!1,d.focus()},"secondary");d.addEventListener("keydown",h=>{h.key==="Enter"&&(h.preventDefault(),y.click())}),u.append(d,y);let v=h=>{let m=w("li","approved-site"),b=w("span","",h.replace(/^https:\/\//,""));return b.title=h,m.append(b,Oe(`Remove ${h}`,()=>{g(n.filter(E=>E!==h))},"icon","close")),m},x=()=>{i.textContent=String(n.length),l.replaceChildren(...n.map(v))};return x(),s.append(l,u,p,c),a.append(s),o.append(r,a),o}var Wz=O(()=>{"use strict";It()});function lm(e,t="usage",n=!0,o=!1){let i=w("section","account-usage");i.setAttribute("aria-label","Account usage");let r=(x="")=>{let h=w("span",`usage-skeleton ${x}`);return h.setAttribute("aria-hidden","true"),h},a=()=>{let x=w("div","usage-skeleton-heading");x.append(r("usage-skeleton-title"));let h=w("div","account-usage-label account-comments"),m=w("span","account-comment-count");m.append(r("usage-skeleton-count"),r("usage-skeleton-ring")),h.append(r("usage-skeleton-label"),m);let b=w("div","account-projects"),E=w("div","account-usage-label");E.append(r("usage-skeleton-label"),r("usage-skeleton-count"));let S=w("div","account-project-slots");S.setAttribute("aria-hidden","true"),S.append(w("span"),w("span"),w("span")),b.append(E,S);let A=w("span","sr-only","Loading account usage");A.setAttribute("role","status"),i.setAttribute("aria-busy","true"),i.replaceChildren(x,h,b,A)},s=e.user?.id,l=e.token,c=()=>e.user?.id===s&&e.token===l,u=Zz.get(e);u||Zz.set(e,u=new Map);let d=JSON.stringify([s,l,t]),p=u.get(d);p||u.set(d,p={});let g=async()=>{let x=t.includes("?")?t.slice(t.indexOf("?")):"",h=await Xz(e,x);h&&p.value&&i.isConnected&&c()&&i.append(h)},y=x=>{i.setAttribute("aria-busy","false"),i.replaceChildren(w("h3","",`${x.hosted?"Starter plan":"Self-hosted"}${o?" \xB7 Local":""}`));let{used:h,limit:m}=x.comments,b=w("div","account-usage-label account-comments"),E=w("span","account-comment-count");if(E.append(w("span","",m===null?`${h.toLocaleString()} / Unlimited`:`${h.toLocaleString()} / ${m.toLocaleString()}`)),b.title="Includes replies and deleted comments.",m!==null){let S=w("span","account-usage-ring");S.setAttribute("role","meter"),S.setAttribute("aria-label","Project comments"),S.setAttribute("aria-valuemin","0"),S.setAttribute("aria-valuemax",String(m)),S.setAttribute("aria-valuenow",String(Math.min(h,m))),S.setAttribute("aria-valuetext",`${h} of ${m} comments used, including replies and deleted comments`),S.style.setProperty("--usage",`${m>0?Math.min(h/m,1)*100:0}%`),S.dataset.full=String(h>=m),E.append(S)}if(b.append(w("span","","Project comments"),E),i.append(b),x.projects){let{used:S,limit:A}=x.projects;if(A===null){let z=w("div","account-usage-label");z.append(w("span","","Projects"),w("span","",`${S.toLocaleString()} / Unlimited`)),i.append(z);return}let _=w("div","account-projects"),T=w("div","account-usage-label"),H=w("span","account-project-count");H.append(w("strong","",String(S)),w("span","",`of ${A}`)),T.append(w("span","","Projects"),H);let D=w("div","account-project-slots");D.setAttribute("role","meter"),D.setAttribute("aria-label","Projects"),D.setAttribute("aria-valuemin","0"),D.setAttribute("aria-valuemax",String(A)),D.setAttribute("aria-valuenow",String(S)),D.setAttribute("aria-valuetext",`${S} of ${A} projects used`);for(let z=0;z<A;z++){let F=w("span");F.dataset.used=String(z<S),D.append(F)}_.append(T,D),i.append(_)}},v=async()=>{if(!c()){i.replaceChildren(),i.setAttribute("aria-busy","false");return}p.value?y(p.value):a(),i.setAttribute("aria-busy","true");try{let x=p.pending??=e.request(t),h;try{h=await x}finally{p.pending===x&&(p.pending=void 0)}if(!c()){delete p.value,i.replaceChildren(),i.setAttribute("aria-busy","false");return}if(p.value=h,!i.isConnected)return;y(h),n&&e.user?.verified&&g().catch(()=>{})}catch(x){if(x instanceof eo&&(x.status===401||x.status===403)&&delete p.value,!c()){delete p.value,i.replaceChildren(),i.setAttribute("aria-busy","false");return}if(!i.isConnected)return;p.value?y(p.value):i.replaceChildren(),i.setAttribute("aria-busy","false");let h=w("span","account-usage-status",p.value?"Couldn\u2019t refresh usage":"Usage unavailable");h.setAttribute("role","status"),i.append(h,Oe("Retry",()=>{v()},"secondary"))}};return v(),i}var Zz,Qz=O(()=>{"use strict";Ff();It();Wz();Zz=new WeakMap});function Jz(e,t,n){let o=w("section","account-sites project-management");o.dataset.open="false";let i=Oe("Project settings",()=>{let v=o.dataset.open!=="true";o.dataset.open=String(v),i.setAttribute("aria-expanded",String(v)),r.inert=!v,r.setAttribute("aria-hidden",String(!v))},"account-sites-summary");i.append(bt("chevron")),i.setAttribute("aria-expanded","false");let r=w("div","account-sites-reveal");r.id=`project-settings-${crypto.randomUUID()}`,i.setAttribute("aria-controls",r.id),r.inert=!0,r.setAttribute("aria-hidden","true");let a=w("div","account-sites-clip");r.append(a);let s=w("div","account-sites-content"),l=w("p","account-usage-status");l.setAttribute("role","status");let c=t?`?workspace=${encodeURIComponent(t)}`:"",u=(v,x="GET",h)=>e.request(`project${v}${c}`,x,h);o.hidden=!0,a.append(s,l),o.append(i,r);let d=async v=>{let x=Array.from(o.querySelectorAll("button"));x.forEach(h=>h.disabled=!0),l.textContent="";try{await v()}catch(h){l.textContent=h instanceof Error?h.message:"Try again."}finally{x.forEach(h=>h.disabled=!1)}},p=async()=>{let v={format:"komo-export",version:1,project:g.project,exportedAt:new Date().toISOString(),tables:{}},x;for(let b of["threads","comments","reactions","users","snapshots"]){v.tables[b]=[];let E=0;for(;E!==null;){let S=await e.request(`project/export?table=${b}&offset=${E}${x===void 0?"":`&revision=${x}`}${t?`&workspace=${encodeURIComponent(t)}`:""}`).catch(A=>{if(b==="snapshots"&&!E&&A.status===400)return null;throw A});if(!S){delete v.tables[b];break}x=S.revision,v.tables[b].push(...S.rows),E=S.next}}let h=URL.createObjectURL(new Blob([JSON.stringify(v,null,2)],{type:"application/json"})),m=w("a");m.href=h,m.download=`${g.project}-comments.json`,m.click(),setTimeout(()=>URL.revokeObjectURL(h),1e3),l.textContent="Export downloaded."},g,y=async()=>{g=await u(""),o.hidden=!1,s.replaceChildren();let v=w("div","account-name-label");v.append(w("span","","Access"));let x=[["public","Anyone with the link"],["private","Invited Google accounts"]],h,m=()=>{let W=ec("Project access",x,g.access,L=>{d(async()=>{let U=g.access;g.access=L,m();try{await u("","PATCH",{access:L}),l.textContent="Access updated."}catch(I){throw g.access=U,m(),I}})});h?h.replaceWith(W):v.append(W),h=W};m(),s.append(v);let b=await u("/webhook"),E=w("details","project-webhook");E.append(w("summary","","Comment webhooks"));let S=w("p","project-help","Send signed events to your HTTPS endpoint. Signing secrets are encrypted and shown only when entered.");E.append(S),b.deliveryAvailable||(S.textContent="Secure webhook delivery is not available on this server yet.");let A=w("label","account-name-label","HTTPS endpoint"),_=w("input");_.type="url",_.autocomplete="off",_.placeholder="https://example.com/palette-webhook",_.value=b.url,A.append(_),E.append(A);let T=w("label","account-name-label",b.secretConfigured?"Replace signing secret":"Signing secret"),H=w("input");H.type="password",H.autocomplete="new-password",H.minLength=32,H.maxLength=256,T.append(H),E.append(T);let D=new Map;for(let W of b.supportedEvents){let L=w("label","account-name-label",W),U=w("input");U.type="checkbox",U.checked=b.events.includes(W),D.set(W,U),L.prepend(U),E.append(L)}let z=w("label","account-name-label","Enable delivery"),F=w("input");F.type="checkbox",F.checked=b.enabled,F.disabled=!b.deliveryAvailable&&!b.enabled,z.prepend(F),E.append(z),E.append(Oe("Save webhook settings",()=>{d(async()=>{await u("/webhook","PATCH",{url:_.value,secret:H.value,events:[...D].filter(([,W])=>W.checked).map(([W])=>W),enabled:F.checked}),H.value="",l.textContent="Webhook settings saved."})},"secondary")),s.append(E);let B=w("label","account-name-label","Invite someone"),le=w("input");le.type="email",le.placeholder="name@example.com",le.autocomplete="email",B.append(le);let J=w("input");J.readOnly=!0,J.hidden=!0,J.setAttribute("aria-label","Invitation link");let V=Oe("Create invitation",()=>{d(async()=>{if(!le.checkValidity()||!le.value)throw Error("Enter an email address.");let W=await u("/invites","POST",{email:le.value});J.value=W.url,J.hidden=!1,oe.hidden=!1,l.textContent="Share this link. It expires in 7 days."})},"secondary"),oe=Oe("Copy invitation",()=>{d(async()=>{await navigator.clipboard.writeText(J.value),l.textContent="Invitation copied."})},"secondary");oe.hidden=!0,s.append(B,V,J,oe);for(let W of g.members){let L=w("div","project-member");L.append(w("span","",W.name),Oe(`Remove ${W.name}`,()=>{d(async()=>{await u("/members","DELETE",{user:W.id}),await y(),l.textContent="Member removed."})},"secondary")),s.append(L)}for(let W of g.invites){let L=w("div","project-member");L.append(w("span","",W.email),Oe("Revoke invitation",()=>{d(async()=>{await u("/invites","DELETE",{email:W.email}),await y(),l.textContent="Invitation revoked."})},"secondary")),s.append(L)}s.append(Oe("Download comments",()=>{d(p)},"secondary"));let pe=w("a","project-help","Move to self-hosting");pe.href="https://github.com/hazem3500/palette#quota-recovery-and-migration",pe.target="_blank",pe.rel="noopener noreferrer",s.append(pe);let q=w("details","project-danger");q.append(w("summary","","Free space or delete project")),q.append(w("p","",`Export first. These actions permanently remove comments. Type ${g.project} to confirm.`));let Y=w("input");Y.placeholder=g.project,Y.setAttribute("aria-label","Confirm project key"),q.append(Y),q.append(Oe("Delete resolved threads",()=>{d(async()=>{await u("/clear-resolved","POST",{confirm:Y.value}),n?.(!1),l.textContent="Resolved threads deleted.",Y.value=""})},"secondary destructive")),g.hosted&&q.append(Oe("Delete project",()=>{d(async()=>{await u("","DELETE",{confirm:Y.value}),n?.(!0),s.replaceChildren(),l.textContent="Project deleted. Its project slot is available again."})},"secondary destructive")),s.append(q)};return y().catch(v=>{v?.status!==403&&(o.hidden=!1,l.textContent="Project settings unavailable.",s.append(Oe("Retry",()=>{d(y)},"secondary")))}),o}var eO=O(()=>{"use strict";KS();It()});var e0={};Yt(e0,{accountUsage:()=>lm,onboardingPanel:()=>$K,projectManagement:()=>Jz});function $K(e,t){let n=w("section","onboarding-panel"),o=w("p","account-usage-status");o.setAttribute("role","status");let i=a=>{o.textContent=a instanceof Error?a.message:"Try again."},r=async()=>{let a=encodeURIComponent(t.workspace),s=w("div","account-sites"),l=w("div","account-sites-summary");l.append(w("span","","Approved sites"),bt("chevron")),s.append(l),s.setAttribute("aria-busy","true"),o.textContent="",n.replaceChildren(lm(e,`usage?workspace=${a}`,!1),s,o);try{let c=await e.request(`workspace?workspace=${a}`);if(!n.isConnected)return;o.textContent="";let u=w("section","account-sites");u.dataset.open="false";let d=Oe("",()=>{let A=u.dataset.open!=="true";u.dataset.open=String(A),d.setAttribute("aria-expanded",String(A)),p.inert=!A,p.setAttribute("aria-hidden",String(!A))},"account-sites-summary");d.setAttribute("aria-expanded","false");let p=w("div","account-sites-reveal");p.id=`approved-sites-${crypto.randomUUID()}`,p.inert=!0,p.setAttribute("aria-hidden","true"),d.setAttribute("aria-controls",p.id);let g=w("div","account-sites-clip"),y=w("span","account-sites-count");d.append(w("span","","Approved sites"),y,bt("chevron"));let v=w("div","account-sites-content"),x=w("div","approved-sites"),h=()=>{y.textContent=String(c.sites.length),x.replaceChildren(...c.sites.map(A=>w("span","",new URL(A).host)))};h();let m=w("label","account-name-label","Website"),b=w("input");b.type="url",b.placeholder="https://your-site.com",b.setAttribute("autocomplete","url"),b.value=t.site||c.suggested.find(A=>!c.sites.includes(A))||"",m.append(b);let E=Oe("Approve site",async()=>{let A;try{let H=new URL(b.value.trim());if(H.protocol!=="https:"||H.username||H.password)throw Error("Enter an HTTPS website address.");A=H.origin}catch(H){i(H);return}let _=[...c.sites],T=b.value;c.sites.includes(A)||c.sites.push(A),h(),b.value="",E.disabled=!0;try{await e.request("workspace/sites","POST",{project:t.workspace,origin:A}),t.site=void 0,o.textContent="Site approved"}catch(H){c.sites=_,h(),b.value||(b.value=T),i(H)}finally{E.disabled=!1}},"secondary");b.addEventListener("keydown",A=>{A.key==="Enter"&&(A.preventDefault(),E.click())});let S=w("div","account-usage-note account-sites-note");S.append(bt("info"),w("span","","Approved sites can show and share comments. Localhost comments are visible by default.")),v.append(x,m,E,S),g.append(v),p.append(g),u.append(d,p),s.replaceWith(u)}catch(c){i(c),n.append(Oe("Retry",()=>{r()},"secondary"))}};if(t.invite){let a=Oe("Accept invitation",async()=>{a.disabled=!0;try{await e.request("project/join","POST",{invite:t.invite}),t.invite=void 0,n.replaceChildren(w("p","","You\u2019re in. Return to the website to leave comments."))}catch(s){i(s),a.disabled=!1}},"primary");n.append(a,o)}else if(t.workspace)r();else if(t.code||t.claimKey){let a=Oe(t.code?"Create project":"Enable comments",async()=>{a.disabled=!0;let s=a.textContent;a.textContent=t.code?"Creating project\u2026":"Enabling comments\u2026";try{if(t.code){let l=await e.request("setup/complete","POST",{code:t.code});t.workspace=l.project,t.code=void 0,history.replaceState(null,"",`?workspace=${encodeURIComponent(l.project)}`),await r(),o.textContent="Project ready. Return to your terminal."}else await e.request("owner/claim","POST",{key:t.claimKey}),t.claimKey=void 0,n.replaceChildren(lm(e),o),o.textContent="Comments are ready."}catch(l){i(l),a.disabled=!1,a.textContent=s}},"primary");n.append(a,o)}else n.append(lm(e));return n}var t0=O(()=>{"use strict";Qz();eO();It()});function tO(){return[An("Post comment","Enter","Comments"),An("New line","Enter","Comments",{shift:!0})]}function oO(e=po(),t,n=Jd()){let o="Design canvas",i="Experimental geometry",r="Text editing",a="Compare",s=(u,d,p)=>({label:u,group:d,shortcut:p}),c=n.child?.key==="enter"&&!n.child.alt&&!n.child.shift&&!n.child.ctrl&&!n.child.meta?null:n.child;return[s("Next sibling",o,n.next),s("Previous sibling",o,n.prev),s("Parent element",o,n.parent),An("Post comment","Enter",o),...c?[s("First child",o,c)]:[],An(c?"First child (alternative)":"First child","ArrowDown",o,{alt:!0}),An("Parent element (alternative)","ArrowUp",o,{alt:!0}),An("Exit Design mode","Escape",o),An("Undo last preview","z",o,e?{meta:!0}:{ctrl:!0}),An("Redo last undo","z",o,e?{meta:!0,shift:!0}:{ctrl:!0,shift:!0}),...e?[]:[An("Redo last undo","y",o,{ctrl:!0})],An("Focus selection to move or resize","M",o),An("Move before previous sibling","ArrowUp",i,{alt:!0}),An("Move after next sibling","ArrowDown",i,{alt:!0}),An("Move out, after its parent","ArrowUp",i,{alt:!0,shift:!0}),An("Move into previous sibling","ArrowDown",i,{alt:!0,shift:!0}),An("Resize width","ArrowRight",i,e?{meta:!0}:{ctrl:!0}),An("Resize height","ArrowDown",i,e?{meta:!0}:{ctrl:!0}),An("Resize by 10px","ArrowRight",i,e?{meta:!0,shift:!0}:{ctrl:!0,shift:!0}),An("Back to the canvas","Escape",i),...t?[{label:"Hide or show selection \xB7 hold to peek",group:o,shortcut:t}]:[],An("Commit text","Enter",r),An("New line","Enter",r,{shift:!0}),An("Cancel text edit","Escape",r),An("Toggle before and after","B",a),s("Show before",a,n.before),s("Show after",a,n.after)]}function iO(e=po()){let t="Design canvas";return[{label:"Inspect element",group:t,keys:[],gesture:"Click",aria:"Click"},{label:"Select inner element",group:t,keys:[e?"\u2318":"Ctrl"],gesture:"Click",aria:`${e?"Command":"Control"} + Click`},{label:"Edit text",group:t,keys:[],gesture:"Double-click",aria:"Double-click"},{label:"Keyboard shortcuts",group:t,keys:["?"],aria:"?"}]}var An,nO,rO=O(()=>{"use strict";ea();Ey();An=(e,t,n,o={})=>({label:e,group:n,shortcut:{key:t,label:t,alt:!1,shift:!1,ctrl:!1,meta:!1,...o}});nO=()=>[An("Zoom to fit","1","Frame",{shift:!0}),An("Zoom to 100%","0","Frame",{shift:!0})]});var aO={};Yt(aO,{showShortcutHelp:()=>jK});function jK(e,t,n=!1,o,i,r=!1){let a=e.querySelector("dialog.palette-shortcuts");if(a)return a.querySelector("[autofocus]")?.focus();let s=e.activeElement??document.activeElement,l=s?.closest(".morphing-menu__panel")?e.querySelector('[data-menu-item="more"]'):s,c=w("dialog","palette-shortcuts");c.setAttribute("aria-modal","true"),c.setAttribute("aria-labelledby","palette-shortcuts-title");let u=w("h2","","Keyboard shortcuts");u.id="palette-shortcuts-title";let d=Oe("Close",()=>T(),"icon palette-shortcuts__close","close");d.removeAttribute("title");let p=w("span","morphing-menu__tooltip palette-shortcuts__tip","Close");p.setAttribute("aria-hidden","true"),p.append(Zd(["Esc"],"Escape"));let g=w("header");g.append(u,d,p);let y=w("input");y.type="search",y.placeholder="Filter shortcuts",y.setAttribute("aria-label","Filter shortcuts"),y.autocomplete="off",y.spellcheck=!1;let v=w("div","palette-shortcuts__body");v.tabIndex=0,v.setAttribute("autofocus",""),v.setAttribute("role","region"),v.setAttribute("aria-label","Shortcuts");let x=n?[...iO(),...oO(void 0,t.find(z=>/^(Hide|Show) comments$/.test(z.label))?.shortcut,i)]:[],h=[...t,...tO(),...r?nO():[]],m=(o==="design"?[...x,...h]:[...h,...x]).filter(z=>z.shortcut||z.keys?.length||z.gesture),b=[...new Set(m.map(z=>z.group??"General"))].sort((z,F)=>+(o==="comment"&&F==="Comments")-+(o==="comment"&&z==="Comments")),E=[];for(let z of b){let F=w("section");F.append(w("h3","",z));for(let B of m.filter(le=>(le.group??"General")===z)){let le=w("div","palette-shortcuts__row"),J=B.shortcut?Jr(B.shortcut):void 0;J&&le.setAttribute("aria-keyshortcuts",J.aria);let V=B.shortcut?Wd(B.shortcut):Zd(B.keys,B.aria??B.keys.join(" + "));B.gesture&&V.append(w("span","",B.gesture)),le.append(w("span","",B.label),V),F.append(le),E.push([le,`${B.label} ${V.getAttribute("aria-label")} ${V.textContent}`.toLowerCase()])}v.append(F)}let S=w("p","","No matching shortcuts");S.setAttribute("role","status"),S.hidden=!0,v.append(S,w("p","","Shortcuts pause while typing in a text field.")),y.addEventListener("input",()=>{let z=y.value.toLowerCase().split(/\s+/).filter(Boolean);for(let[F,B]of E)F.hidden=!z.every(le=>B.includes(le));for(let F of v.querySelectorAll("section"))F.hidden=!F.querySelector(".palette-shortcuts__row:not([hidden])");S.hidden=E.some(([F])=>!F.hidden)}),c.append(Object.assign(w("style"),{textContent:NK}),g,y,v);let A=new AbortController,{signal:_}=A,T=()=>{_.aborted||(A.abort(),c.close(),c.remove(),l?.isConnected&&l.focus({preventScroll:!0}))};c.addEventListener("close",T,{signal:_}),window.addEventListener("keydown",z=>{let F=z.composedPath().find(le=>le instanceof HTMLDialogElement&&le.open);if(F&&F!==c||(z.stopImmediatePropagation(),z.isComposing))return;let B=e.activeElement===y;if(z.key==="Escape"||z.key==="?"&&!B&&!z.ctrlKey&&!z.metaKey&&!z.altKey)z.preventDefault(),T();else if(z.key==="Tab"){let le=[d,y,v],J=le.indexOf(e.activeElement);z.preventDefault(),le[J<0?z.shiftKey?2:0:(J+(z.shiftKey?2:1))%3].focus()}},{capture:!0,signal:_});let H=!1,D=z=>{let F=c.getBoundingClientRect();return z.target===c&&(z.clientX<F.left||z.clientX>F.right||z.clientY<F.top||z.clientY>F.bottom)};c.addEventListener("pointerdown",z=>{H=D(z)},{signal:_}),c.addEventListener("click",z=>{H&&D(z)&&T()},{signal:_}),e.append(c),c.showModal()}var NK,sO=O(()=>{"use strict";rO();It();ea();NK=`.palette-shortcuts{box-sizing:border-box;width:min(720px,calc(100vw - 32px));max-width:none;max-height:min(680px,calc(100dvh - 32px));margin:auto;padding:0;overflow:hidden;border:0;border-radius:16px;background:var(--mm-surface);color:var(--mm-ink);box-shadow:inset 0 0 0 1px color-mix(in oklab,var(--mm-ink) 12%,transparent),0 24px 64px -16px rgb(0 0 0/55%);font:12px/1.4 -apple-system,BlinkMacSystemFont,"Inter","Segoe UI",sans-serif;pointer-events:auto;color-scheme:dark}
|
|
150
150
|
.palette-shortcuts[open]{display:flex;flex-direction:column;animation:palette-help-in var(--duration-fast) var(--ease-smooth-out)}
|
|
151
151
|
.palette-shortcuts::backdrop{background:rgb(0 0 0/40%);pointer-events:auto}
|
|
152
152
|
@keyframes palette-help-in{from{opacity:0;scale:.98;translate:0 4px}}
|
|
@@ -3016,7 +3016,7 @@ ${eu} .avatar img { display: none; }
|
|
|
3016
3016
|
.new-comment-composer .draft-proposal { margin-right: calc(var(--palette-action) + var(--palette-gutter)); max-height: min(45dvh, 360px); min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
|
|
3017
3017
|
.thread-navigation { margin: 0 var(--palette-inset) 12px; padding: 10px 12px; border: 1px solid #8883; border-radius: 8px; color: #aaa; }
|
|
3018
3018
|
.account-layer .account-dialog { --palette-inset: 24px; }
|
|
3019
|
-
`;var D2=["full","compact","dot","auto"],R2={full:"Full",compact:"Compact",dot:"Dot",auto:"Auto"},H2=new WeakMap;function zN(e){let t={destroy(){},open(){},close(){},comment(){},async refresh(){}};if(typeof document>"u"||e.enabled===!1||Vx())return t;if(_M(),!e.
|
|
3019
|
+
`;var D2=["full","compact","dot","auto"],R2={full:"Full",compact:"Compact",dot:"Dot",auto:"Auto"},H2=new WeakMap;function zN(e){let t={destroy(){},open(){},close(){},comment(){},async refresh(){}};if(typeof document>"u"||e.enabled===!1||Vx())return t;if(!e.endpoint)return console.error("Palette: set `endpoint` to your Palette server (see the self-hosting guide)."),t;if(_M(),!e.repo||!e.branch||!e.project)throw new Error("Comments require repo, branch, and project.");if(e.pageRoot&&(e.pageRoot===document.body||!document.body.contains(e.pageRoot)))throw new Error("pageRoot must be mounted inside body.");let n=new URL(e.endpoint);if(n.username||n.password||n.protocol!=="https:"&&!(n.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(n.hostname)))throw new Error("Use an HTTPS API endpoint without credentials; HTTP is allowed on localhost.");wC(e.avatar);let o=yH(e.shortcuts),i=Jd(e.shortcuts),r=e.pins?.size??"full";if(!D2.includes(r))throw new Error(`Invalid Palette pins.size: "${r}".`);let a=e.features?.designMode!==!1,s=[],l=BR(e.toolbar?.items),c=e.features?.tags!==!1,u=JSON.stringify([n.href,e.project,e.repo,e.branch]),d=H2.get(document);if(d){if(d.scope!==u)throw new Error("Destroy the current Palette instance before changing projects or branches.");return d.controller}e={...dM(e)};let p=[...document.body.childNodes].filter(f=>f instanceof Element?!f.matches("script,style,link,meta,template,noscript"):f.nodeType===3&&f.textContent?.trim()),g=e.pageRoot??(p.length===1&&p[0]instanceof HTMLElement?p[0]:document.body),y=getComputedStyle(g).display==="contents"?document.body:g,v=y!==document.body,x=e.frame?.mode==="iframe"&&e.frame.scale!==!0&&e.frame.shell===!0,h=x?AM(e.project):"",m=`palette:sidebar-mode:${e.project}:${e.repo}`,b=(()=>{if(!v)return"edge";if(h)return"background";try{let f=localStorage.getItem(m);if(f==="edge"||f==="background")return f}catch{}return e.sidebar==="background"?"background":"edge"})(),E=`palette:pin-size:${e.project}:${e.repo}`,S=r;try{let f=localStorage.getItem(E);f&&D2.includes(f)&&(S=f)}catch{}let A=`palette:read:${e.project}:${e.repo}`,_={};try{let f=JSON.parse(localStorage.getItem(A)??"{}");f&&typeof f=="object"&&(_=f)}catch{}let T=f=>{let k=f.comments.at(-1);return!!k&&k.author.id!==q.user?.id&&!(_[f.id]>=k.createdAt)};function H(f){let k=f.comments.at(-1)?.createdAt??0;if(_[f.id]>=k)return;delete _[f.id],_[f.id]=k;let M=Object.keys(_);for(let j of M.slice(0,Math.max(0,M.length-500)))delete _[j];try{localStorage.setItem(A,JSON.stringify(_))}catch{}}let D=Mr(window.innerWidth,window.innerHeight),z=!D&&b==="edge",F=!1,B=!1,le=!1,J=["localhost","127.0.0.1","[::1]"].includes(location.hostname),V=e.branch,oe=`palette:channel:${e.project}:${e.repo}`,pe="local";try{localStorage.getItem(oe)==="shared"&&(pe="shared")}catch{}J&&pe==="local"&&(e={...e,branch:"local"});let q=new tc(e),Y=new AbortController,W=!1,L=!!e.onboarding,U=!1,I=!1,G=e.showToolbar===!1,te=e.showToolbar===!1,ie=!1,fe=!1,ye=0,C=!!e.onboarding,Q=!1,Z=!1,ae=!!e.onboarding,xe=0,ke=null,$=[],R=null,P=null,X=null,de=new Set;function Se(){X&&!X.opened&&de.add(X.id),X=null}let ze=(f,k=Mi,M=Ni())=>rH(f,M,k);function Le(f){return ze(f)&&!(X?.id===f.id&&(X.pending||X.rejected))}let Pe=null,Ne=null,Me=new mg([],f=>{if(!W){if(R){let k=Me.id(R);k!==R&&(ci.has(R)&&(ci.set(k,ci.get(R)),ci.delete(R)),Ln===R&&(Ln=k),R=k)}Ri&&(Ri=Me.id(Ri)),$=f,fa="",mr(),ui(),Ho(),C||gr()}},(f,k)=>f.map(M=>({...M,id:k(M.id),comments:M.comments.map(j=>({...j,id:k(j.id)}))})));function Ke(f,k){return(M,j)=>M.flatMap(ee=>{if(ee.id!==j(f))return[ee];let se=k(ee);return se?[se]:[]})}async function vt(f,k,M){let j=q,ee=q.token,se=xe,ge=()=>W||q!==j||se!==xe||q.token!==ee;try{await Me.submit(f,async re=>{if(ge())throw new DOMException("Session changed","AbortError");return k(re)})}catch(re){throw ge()?new DOMException("Session changed","AbortError"):(M?.(),$t(),new Error(`Couldn't save. Your change was reverted. ${re instanceof Error?re.message:"Try again."}`,{cause:re}))}if(ge())throw new DOMException("Session changed","AbortError");Me.busy||Ot(fr)}let ct="open",ue="",Ae=!0,ve="",De="Connecting",Fe="",Ye=null,$e,ot=0,rn=0,Qt=null,Ht=Promise.resolve(),ut=null;function Jt(){clearTimeout(ot);let f=ut;return ut=null,f&&(Ht=Ht.catch(()=>{}).then(async()=>{if(q.token===f.token)try{let k=await q.request("me","PATCH",{name:f.name,avatarUrl:f.avatarUrl,accentColor:f.accentColor});if(q.token!==f.token)return;Qt=k.user,rn===f.revision&&q.save({token:f.token,user:k.user}),W||(Ho(),Ot(fr))}catch(k){throw q.token===f.token&&rn===f.revision&&(q.user=Qt,Ye=null,$t()),new Error(`Couldn't save your profile. ${k instanceof Error?k.message:"Try again."}`,{cause:k})}})),Ht}function Mn(f,k=!1){!q.token||!f.name.trim()||((!Qt||Qt.id!==q.user?.id)&&(Qt=q.user?{...q.user}:null),ut={...f,name:f.name.trim(),token:q.token,revision:++rn},q.user&&(q.user={...q.user,...f,name:f.name.trim()}),Ho(),clearTimeout(ot),k?Ot(Jt):ot=window.setTimeout(()=>Ot(Jt),500))}function K(){let f=Oe("Continue with Google",()=>Ot(()=>Sx("google")),"google-signin secondary");return f.prepend(Gv()),f}let ce="",_e=null,et=!1,Ve=!1,mt=!1,Ct=e.onboarding?.sites?.filter(f=>f.startsWith("https://")&&f!==location.origin).join(`
|
|
3020
3020
|
`)??"",gt=!1,Gt=null,wt=null,jn=0,Ze=!1,Et=!1,Pn=!1,ir=!1,_i,li,rr,Di,_o=null,ar=[],Ln=null,nl=null,yc=new Map,ca=f6(()=>pa()),sr=null,vn,Am=`palette:drawer:${e.project}:${e.repo}`,N;try{let f=JSON.parse(localStorage.getItem(Am)??"null");f&&Number.isFinite(f.x)&&Number.isFinite(f.y)&&(N={x:f.x,y:f.y,edgeX:["left","right"].includes(f.edgeX)?f.edgeX:void 0,edgeY:["top","bottom"].includes(f.edgeY)?f.edgeY:void 0},vn=N)}catch{}let Ce=`palette:sidebar:${e.project}:${e.repo}`,Re,Je,cn=!1,dt=x6,Bn=null;try{let f=JSON.parse(localStorage.getItem(Ce)??"null");Number.isFinite(f?.width)&&(dt=f.width),Number.isFinite(f?.height)&&(Bn=f.height),f&&Number.isFinite(f.x)&&Number.isFinite(f.y)&&(Re={x:f.x,y:f.y,edgeX:["left","right"].includes(f.edgeX)?f.edgeX:void 0,edgeY:["top","bottom"].includes(f.edgeY)?f.edgeY:void 0},Je=Re)}catch{}let Vn=new Map,mo=/^Proposed .+ \(preview only\)$/m,xu,vu,ol,wu=()=>xu??=Promise.resolve().then(()=>(ZH(),WH)).then(f=>(ol=f,vu=f.summarizeDesignComment,W||(fa="",mr(!0)),f)),_0=f=>k=>{let M=Mi(f),j=[];try{k&&(j=[...Yn().querySelectorAll(k)])}catch{}return j.length!==1||M&&j.includes(M)?M??j[0]??null:j[0]},z2=(f,k)=>e.snapshots&&_i&&q.user&&(q.user.verified||_i.guests)?Promise.resolve().then(()=>(hz(),gz)).then(M=>M.snapshotFor(f,Mi,e.snapshots,_i,k),()=>null):void 0,O2,$2=()=>O2??=Promise.resolve().then(()=>(Mz(),Az)),D0=new WeakSet,Eu=(f,k,M)=>{let j=w("div");return $2().then(ee=>W||ee.mountSnapshot(j,B2,f,k,M),()=>{}),j},N2=f=>mo.test(f)?vu?.(f)??(wu(),"Design change"):f,j2=f=>N2(f).trim().split(`
|
|
3021
3021
|
`)[0].slice(0,100),Do="",lr="",_r=[],da="",Ri=null,ku="",Su,Tu=null,R0=!1,P2=Ni(),Mm=0,Cm=0,Lm=0,H0=0,ci=new Map,_m=new Map,lt=w("div");lt.dataset.branchComments=e.project,lt.dataset.sidebar=D?"mobile":z?"edge":"background",Object.assign(lt.style,{position:"fixed",inset:"0",pointerEvents:"none",zIndex:"2147483647",isolation:"isolate"});let it=lt.attachShadow({mode:"open"}),B2={root:it,token:()=>q.token,origin:()=>new URL(e.endpoint).origin,dropped:D0,go:f=>{Hx(f)},notify:Dn,remove:f=>Ot(()=>vt(Ke(f.id,({snapshot:k,...M})=>M),async k=>{for(let M in f.snapshot)await q.request(`threads/${k(f.id)}/snapshot/${M}`,"DELETE")}))},V2=w("style");V2.textContent=vH;let di=w("div","catch");di.hidden=!0;let ht=w("div","pins"),zt=w("div"),Xe=w("div","toolbar"),he=w("div"),U2=w("div");he.tabIndex=-1,z&&he.classList.add("edge-sidebar");let Dr=w("div","edge-sidebar-sensor");Dr.hidden=!0,Object.assign(ht.style,{position:"fixed",inset:"0"});let Fn=w("div","pin-preview");Fn.hidden=!0;let Dm=0,xc=!1,Rm=!1,Au=null,vc=null,wc=null,z0="",Hi=(f=!1)=>{if(window.clearTimeout(Dm),Fn.hidden||Rm&&!f)return;if(ol?.resetDesignPreviews(new Set([...$.find(M=>M.id===R&&Le(M))?.comments.map(M=>M.id)??[],"draft"])),Rm=!0,vc?.cancel(),f||En()){Fn.hidden=!0,Au=null;return}let k=Fn.animate([{opacity:1,transform:"scale(1)"},{opacity:0,transform:"translateY(3px) scale(.99)"}],{duration:150,easing:"cubic-bezier(.22,1,.36,1)",fill:"forwards"});vc=k,k.finished.then(()=>{vc===k&&(Fn.hidden=!0,Au=null)}).catch(()=>{})};Fn.addEventListener("pointerenter",()=>{xc||Gt||sr||(Rm=!1,window.clearTimeout(Dm),vc?.cancel())}),Fn.addEventListener("pointerleave",()=>Hi());let zi=w("div","component-hover");zi.setAttribute("aria-hidden","true");let Ko=null,Qa=null,Hm=0,Ja=w("div","sr-only");Ja.setAttribute("aria-live","polite");let q2=nH(Xe,f=>{if(f==="account"){if(!q.user)return bt("person");let k=yr(q.user);return k.classList.add("review-avatar"),k}return bt(f)});it.append(V2,di,zi,ht,he,Dr,zt,Fn,U2,Xe,Ja),document.body.append(lt);let K2=0,I2=0,G2=new MutationObserver(f=>{if(Date.now()-I2>1e3&&([K2,I2]=[0,Date.now()]),++K2<20)for(let k of f)lt.removeAttribute(k.attributeName)});G2.observe(lt,{attributeFilter:["aria-hidden","inert"]});let Un=document.documentElement;function O0(f,k){return Object.fromEntries(k.map(M=>[M,f.style[M]]))}let il=O0(y,["width","boxSizing","zoom","transformOrigin","transform","position","left","top","height","minHeight","paddingBottom","overflow","borderRadius","background","borderRight","borderBottom","clipPath"]),NN=Object.keys(il).map(f=>f.replace(/[A-Z]/g,k=>`-${k.toLowerCase()}`)),jN=Yu(y,NN),PN=O0(document.body,["overflow","background"]),BN=Yu(document.body,["overflow","background"]),VN=Yu(Un,["overflow","background"]),zm=new Map,UN=Un.style.background,$0=SM(y,lt,e.frame?.include,Fo),F2=TM(lt),_n={left:0,top:0,width:0,height:0,logical:[0,0],pan:!1},N0=`palette:frame-size:${e.project}:${e.repo}`,to,Y2=!1,cr=null,X2=e.frame?.mode==="iframe"&&e.frame.scale!==!0,ao,Om=!1,es=!1,ts=!1,Mu="",W2=e.frame?.defaultMode==="transform";try{let f=JSON.parse(localStorage.getItem(N0)??"{}");W2=f.v===2&&typeof f.inPlace=="boolean"?f.inPlace:e.frame?.defaultMode==="transform"}catch{}let Z2=()=>X2&&!Mu&&(to?to.separate:!W2),j0=!1,Cu=!1,Lu=!1;try{Lu=!!sessionStorage.getItem(Qx)}catch{Lu=!0}let qN,P0=()=>qN??=Promise.resolve().then(()=>(Dz(),_z));function KN(){if(Cu)return;Cu=!0,to?.status({active:!1,loading:!0});let f=!Go;P0().then(({enterShell:k})=>!W&&k(e.project,f,!!Pe?.edited,()=>{Cu=!1,Lu=!0,W||$m()}))}function _u(f=""){if(Cu)return;Cu=!0;let k=location.href;try{let M=ao?.iframe.contentWindow?.location.href;M?.startsWith(location.origin)&&(k=M)}catch{}P0().then(({leaveShellPage:M})=>M(k,f))}let Q2=()=>{P0().then(({syncShell:f})=>f(ao?.iframe.contentWindow,h))};function B0(){ao&&(ao.destroy(),ao=void 0,es=!1,to?.status({active:!1}),J2())}function J2(){let f=Pe?.selected;if(!f||f.ownerDocument===Yn())return;let k=ul(f,Yn());Pe.clearSelection(),k&&Pe.select(k)}let $m=()=>{Cc="",ji(),Hc(),Fo()};function IN(){if(ao||Om)return;Om=!0,to?.status({active:!1,loading:!0});let f=en&&!ts?y.scrollTop:window.scrollY/pr();Promise.resolve().then(()=>($z(),Oz)).then(({openFrameViewport:k})=>{if(Om=!1,W||!en||ao||!Z2())return;let M=ao=k({parent:it,before:di,url:GN(),background:rl,scroll:f,ready(){ao===M&&(es=!0,h&&Q2(),J2(),to?.status({active:!0}),$m())},failed(j){if(ao===M){if(h)return _u(j);Mu=j,B0(),to?.status({active:!1,reason:j}),$m()}},changed(){h&&Q2(),Hc(),Fo()}});$m()})}function GN(){let f=new URL(e.frame?.iframeUrl?.(location)??location.href,location.href);if(h)for(let k of[Wx,Zx])f.searchParams.delete(k);return f.href}let Du=()=>(es&&ao?ao.port:y).getBoundingClientRect(),V0=f=>es?f.ownerDocument===Yn():y.contains(f),Nm=()=>{let f=Yn();return f===document?y:v&&ul(y,f)||f.body};function eA(){Y2||(Y2=!0,Promise.resolve().then(()=>(Kz(),qz)).then(({mountFrameSize:f})=>{W||(to=f(it,()=>es&&ao?ao.port:y,N0,k=>{if(k){Mu="",Lu=!1;try{zo(sessionStorage,Qx)}catch{}}Cc="",ji(),Fo()},GS,X2&&(e.frame?.defaultMode==="transform"?"transform":"iframe"),{pan:FN,onFrame:so,shortcuts:o,textEntry:br,shell:x,anchor(){let k=$.find(ee=>ee.id===R),M=P??(k&&Le(k)?k.anchor:null),j=M&&ga(M);return j&&j.attached?{x:j.x/pr(),y:j.y/pr()}:null}}),to.status(es?{active:!0}:Mu?{active:!1,reason:Mu}:{active:!1,loading:!!ao||Om}),to.sized?(Cc="",ji()):to.update(cr,pr()))}))}try{localStorage.getItem(N0)&&eA()}catch{}let jm=0,U0=!1,tA=()=>{U0=!0,document.dispatchEvent(new Event("scroll",{bubbles:!0})),U0=!1};function FN(){jm||(jm=requestAnimationFrame(YN),tA())}function YN(){if(jm=0,!en||!cr||!to||W||ts)return;let f=pr(),k=to.view({left:cr.left/f,top:cr.top/f,width:cr.width/f,height:cr.height/f},[window.innerWidth/f,window.innerHeight/f]);_n.left=k.left,_n.top=k.top,y.style.left=`${k.left}px`,y.style.top=`${k.top}px`,Rr(),to.update(cr,f),mr(!0),pi(),pa(),dl(),tA()}function Rr(){let f=pr(),k=_n.left,M=_n.top,{width:j,height:ee}=_n,se=en&&!W&&!ts,ge=se&&e.frame?.scale!==!0;ge&&F2.update(_n.logical),$0.update(se?{scale:Ro,left:k,top:M,zoom:f,bounds:{left:k,top:M,right:k+j,bottom:M+ee,width:j,height:ee}}:null),ge||F2.update(null)}function nA(){let f=en||dr,k=[document.body.style.background,Un.style.background];f&&(document.body.style.background=PN.background,Un.style.background=UN);let M=[document.body,Un].map(j=>getComputedStyle(j).backgroundColor).find(j=>j!=="rgba(0, 0, 0, 0)")??"#fff";return f&&([document.body.style.background,Un.style.background]=k,K0.takeRecords()),M}let q0=0,K0=new MutationObserver(()=>{q0||=requestAnimationFrame(()=>{q0=0,rl=nA(),oA(),(en||dr)&&(y.style.background=rl)})});function oA(){let[f,k,M]=/^rgb/.test(rl)?rl.match(/[\d.]+/g).map(Number):[255,255,255];ht.dataset.page=.2126*f+.7152*k+.0722*M<128?"dark":"light"}let en=!1,dr=!1,rl=nA();oA();for(let f of[Un,document.body])K0.observe(f,{attributes:!0});let Io=0,Oi;function iA(){let f=Number(getComputedStyle(y).opacity);return y.animate([{opacity:f*.94},{opacity:f}],{duration:250,easing:"cubic-bezier(0.22, 1, 0.36, 1)"})}let Go=!1,rA=aH(`palette:open:${e.project}:${e.repo}`,e.restoreOpen),I0=`palette:toolbar-dismissed:${e.project}:${e.repo}`;try{sessionStorage.getItem(I0)==="1"&&(te=!0,G=!0)}catch{}let G0=`palette:comments-hidden:${e.project}:${e.repo}`,go=!1,Pm=!1,F0=0;try{go=!e.onboarding&&sessionStorage.getItem(G0)==="1"}catch{}let Ec=!1,ns,Y0=[],kc=0,$i=!1,aA=null,Sc,Bm;function Vm(f){!Xe.offsetWidth||!Xe.offsetHeight||(vn=Pa(f,Xe.offsetWidth,Xe.offsetHeight,Un.clientWidth,window.innerHeight),Xe.style.left=`${vn.x+Xe.offsetWidth/2}px`,vn.edgeY==="bottom"&&!D?(Xe.style.top="auto",Xe.style.bottom="calc(16px + env(safe-area-inset-bottom,0px))"):(Xe.style.top=`${vn.y}px`,Xe.style.bottom="auto"))}function sA(f){if(he.dataset.dragging==="true"){Je=f,he.style.left=`${f.x}px`,he.style.top=`${f.y}px`;return}he.offsetWidth&&(Je=Pa(f,he.offsetWidth,he.offsetHeight,Un.clientWidth,window.innerHeight),ua())}function lA(){he.style.width=`${dt}px`,he.style.height=Bn==null?"":`${Bn}px`,wx()}function cA(){Re=Je;try{localStorage.setItem(Ce,JSON.stringify({...Re,width:dt,height:Bn}))}catch{}}function dA(){let f=Un.clientWidth,k=window.innerHeight;dt=Math.min(Math.max(dt,af),Math.max(af,f-2*Ji)),Bn!=null&&(Bn=Math.min(Math.max(Bn,sf),Math.max(sf,Math.min(k-2*Ji,eb)))),lA()}function ua(){if(D||!z)return;dA();let f=he.offsetHeight||Math.min(window.innerHeight-2*Ji,eb),k=w6(Je,dt,f,Un.clientWidth,window.innerHeight),M=E6(k,Un.clientWidth);he.style.left=`${k.x}px`,he.style.top=`${k.y}px`,he.style.setProperty("--edge-account-max-height",`${Math.max(0,window.innerHeight-k.y-28)}px`),he.style.right="auto",he.style.bottom="auto",he.style.transformOrigin=k.side==="left"?"left center":"right center",he.style.setProperty("--edge-park-x",`${M.parked}px`),he.style.setProperty("--edge-peek-x",`${M.peek}px`),Dr.style.left=k.side==="left"?"0px":"",Dr.style.right=k.side==="right"?"0px":"",L?(delete he.dataset.collapsed,delete he.dataset.peek,Dr.hidden=!0):(he.dataset.collapsed="true",cn?he.dataset.peek="true":delete he.dataset.peek,Dr.hidden=!1)}function X0(){lt.dataset.sidebar=D?"mobile":z?"edge":"background",he.classList.toggle("edge-sidebar",z),he.style.transition="none",he.style.translate="",he.style.opacity="",Ou(!0),z?Hr.isConnected||he.prepend(Hr):(Hr.remove(),delete he.dataset.collapsed,delete he.dataset.peek,Dr.hidden=!0),he.offsetWidth,he.style.transition=""}let al=[],W0=!1;function Ru(){for(let f of al)f.cancel();al=[],dr=!1,ht.style.opacity=""}function Z0(f,k){if(D||f===b||W||!v&&f==="background")return;let M=()=>[y,he.querySelector(".panel"),Xe,zt.querySelector(".account-dialog")],j=M().map(se=>se?.getBoundingClientRect());if(Ru(),Oi?.cancel(),Oi=void 0,ns?.stop(),ns=void 0,Ou(!0),Gm(),Lc(),Xe.style.translate="",Sc=void 0,W0=!0,b=f,z=f==="edge",!k){F=!1,e={...e,sidebar:f};try{localStorage.setItem(m,f)}catch{}}if(X0(),ji(),$t(),W0=!1,En())return;M().forEach((se,ge)=>{let re=j[ge];if(!se?.isConnected||!re?.width)return;if(se===y&&e.frame?.scale!==!0){al.push(iA());return}se!==y&&se.getAnimations().forEach(rt=>rt.cancel());let be=se.getBoundingClientRect();if(!be.width)return;let je=be.width/se.offsetWidth,We=getComputedStyle(se).transform;al.push(se.animate([{transform:`${We==="none"?"":We} translate(${(re.left-be.left)/je}px, ${(re.top-be.top)/je}px) scale(${re.width/be.width})`,transformOrigin:"top left"},{transform:We,transformOrigin:"top left"}],{duration:250,easing:"cubic-bezier(0.22, 1, 0.36, 1)"}))});let ee=al;dr=!0,ht.style.opacity="0",Promise.all(ee.map(se=>se.finished)).then(()=>{W||ee!==al||(al=[],dr=!1,ht.style.opacity="",Rr(),$0.reposition(),Fo())}).catch(()=>{})}function Q0(f,k,M,j,ee){let se=w("div","account-setting"),ge=w("span","account-setting-label",k),re=ec(k,M,j,be=>ee(be));return re.querySelector("summary").dataset.focusKey=`setting-${f}`,se.append(ge,re),se}function XN(){return D?Q0("sidebar","Sidebar",[["mobile","Floating sidebar"]],"mobile",()=>{}):v?Q0("sidebar","Sidebar",[["edge","Floating"],["background","Frame"]],b,Z0):w("p","muted","Floating sidebar \xB7 Set pageRoot for Frame.")}function WN(){let f=Q0("channel","Comments",[["local","Local development"],["shared","Site comments"]],pe,ZN);return f.append(w("p","muted","Separate channels, both saved to this project.")),f}function ZN(f){if(!(f===pe||W)){if(Q||Me.busy){Dn("Wait for your changes to save.");return}pe=f;try{localStorage.setItem(oe,f)}catch{}e={...e,branch:f==="local"?"local":V},q.cancelReads(),q=new tc(e),Z=et=!1,Hu=void 0,ce="",_e=null,De="Connecting",gt=Ze=Et=Pn=Ve=ir=!1,R=null,P=null,_o=null,sl(),$t(),Km()}}function sl(){Se(),xe++,Z=!1,ce="",R=null,Hu=void 0;let f=q.cached();ae=f!==null,Me.reset(ix(f??[]))}let Hr=w("div","edge-sidebar-grip");Hr.setAttribute("aria-hidden","true");let uA=f=>Qh(he,f,sA,Y.signal,()=>{B=!1,le=!0,ur.show()},()=>{cA(),ur.update()},()=>L&&z&&!$i);uA(Hr),he.prepend(Hr);let QN=["n","s","e","w","ne","nw","se","sw"];for(let f of QN){let k=w("div",`edge-sidebar-resize edge-sidebar-resize-${f}`);k.addEventListener("pointerdown",M=>{if(M.button!==0||!L||!z||$i)return;M.preventDefault(),M.stopPropagation();for(let be of he.getAnimations())be.cancel();he.style.transition="none";let j=he.getBoundingClientRect(),ee=M.clientX,se=M.clientY,ge=be=>{if(be.pointerId!==M.pointerId)return;let je=v6(f,j,be.clientX-ee,be.clientY-se,Un.clientWidth,window.innerHeight);dt=je.width,(f.includes("n")||f.includes("s"))&&(Bn=je.height),Je={x:je.left,y:je.top},he.style.left=`${je.left}px`,he.style.top=`${je.top}px`,lA()},re=be=>{be.pointerId===M.pointerId&&(window.removeEventListener("pointermove",ge,!0),window.removeEventListener("pointerup",re,!0),window.removeEventListener("pointercancel",re,!0),he.style.transition="",cA(),ua())};window.addEventListener("pointermove",ge,{capture:!0,passive:!1}),window.addEventListener("pointerup",re,!0),window.addEventListener("pointercancel",re,!0)},{signal:Y.signal}),he.append(k)}for(let f of["left","right","top","bottom"])he.append(w("div",`edge-sidebar-snap edge-sidebar-snap-${f}`));let Um=f=>{cn=f,!L&&z&&!$i&&ua()};Dr.addEventListener("pointerenter",()=>Um(!0)),Dr.addEventListener("pointerleave",()=>Um(!1)),Dr.addEventListener("pointerup",f=>{f.button===0&&!L&&wn(!0)}),he.addEventListener("pointerenter",()=>Um(!0)),he.addEventListener("pointerleave",()=>Um(!1)),window.addEventListener("resize",()=>{W||!z||$i||(dA(),ua())},{signal:Y.signal,passive:!0}),X0();let ur=m6(Xe,()=>L||U||C||!!P||!!R,Y.signal,e.autoHideDrawer);Qh(Xe,Xe,Vm,Y.signal,()=>{ur.show(),ns?.stop(),Xe.style.translate="0px 0px"},()=>{N=vn;try{localStorage.setItem(Am,JSON.stringify(N))}catch{}Ho(),ur.update()},()=>!L,f=>!!f.closest(".morphing-menu__shortcut"));let J0=new ResizeObserver(()=>{Xe.dataset.edgeTabs!=="true"&&(vn?Vm(vn):e.drawerContainer&&Ho())});J0.observe(Xe),e.drawerContainer&&J0.observe(e.drawerContainer);let pr=()=>Un.currentCSSZoom??1;function Ni(){let f=as()?.contentWindow?.location??location;return oH(e.page?.(f)??f.pathname)}let pA=new WeakMap,ll=null,ex=0,tx=new WeakMap;function fA(){cancelAnimationFrame(ex),!(W||!it.querySelector(".floating-notice"))&&(pa(),ex=requestAnimationFrame(fA))}function nx(f=P??$.find(k=>k.id===R)?.anchor){let k=zt.firstElementChild?.getBoundingClientRect();if(!k||C)return;let M=f?ga(f):null;return{cardKey:Ln,left:k.left,top:k.top,anchor:f,offsetX:k.left-(M?.x??0),offsetY:k.top-(M?.y??0),scrollX:window.scrollX,scrollY:window.scrollY}}function qm(f){if(f.dataset.closing)return;if(f.dataset.closing="true",f.inert=!0,f.setAttribute("aria-hidden","true"),ll===f&&(ll=null,clearTimeout(Mm)),En()){f.remove();return}f.animate([{opacity:getComputedStyle(f).opacity,translate:"0px 0px",scale:1},{opacity:0,translate:f.dataset.attached==="true"?`0px ${(f.dataset.placement==="above"?1:-1)*(f.offsetHeight/2+10)}px`:"0px 3px",scale:f.dataset.attached==="true"?.94:.99}],{duration:150,easing:"cubic-bezier(.22,1,.36,1)",fill:"forwards"}).finished.catch(()=>{}).finally(()=>f.remove())}function Dn(f,k,M=nx()){Ja.textContent=f,ll&&qm(ll);let j=w("div","toast floating-notice");ll=j,M&&pA.set(j,M),j.setAttribute("role",k?"alertdialog":"status"),j.setAttribute("aria-label",f),j.append(bt("info"),w("span","",f)),k&&j.append(Oe(k.label,()=>{qm(j),k.run()},"notice-action")),j.append(Oe("Dismiss notice",()=>qm(j),"icon","close")),it.append(j),pa(),fA(),En()||j.animate([{opacity:0,translate:j.dataset.attached==="true"?`0px ${(j.dataset.placement==="above"?1:-1)*(j.offsetHeight/2+10)}px`:"0px 6px",scale:j.dataset.attached==="true"?.94:.97},{opacity:1,translate:"0px 0px",scale:1}],{duration:250,easing:"cubic-bezier(.22,1,.36,1)"}),clearTimeout(Mm),Mm=window.setTimeout(()=>qm(j),5e3)}function pa(){for(let f of it.querySelectorAll(".floating-notice")){let k=pA.get(f);if(!k)continue;let M=k.anchor?ga(k.anchor):null,ee=(!C&&Ln===k.cardKey?zt.firstElementChild:null)?.getBoundingClientRect();ee&&(f.style.maxWidth=`${Math.min(360,ee.width,innerWidth-24)}px`,k.left=ee.left,k.top=ee.top,k.offsetX=ee.left-(M?.x??0),k.offsetY=ee.top-(M?.y??0),k.scrollX=window.scrollX,k.scrollY=window.scrollY);let se=ee?ee.left+(ee.width-f.offsetWidth)/2:M?M.x+k.offsetX:k.left+k.scrollX-window.scrollX,ge=!!ee&&ee.bottom+10+f.offsetHeight>innerHeight-12;f.dataset.placement=ge?"above":"below";let re=ee?ge?ee.top-f.offsetHeight-10:ee.bottom+10:M?M.y+k.offsetY:k.top+k.scrollY-window.scrollY,be=String(!!ee),je=f.dataset.attached!==void 0&&f.dataset.attached!==be,We=je?f.getBoundingClientRect():null,rt=tx.get(f);if(rt&&(je||Math.abs(rt.left-se)>.5||Math.abs(rt.top-re)>.5)&&(rt.animation.cancel(),tx.delete(f)),f.dataset.attached=be,Object.assign(f.style,{left:`${se}px`,top:`${re}px`,bottom:"auto",transform:"none",transformOrigin:ee?ge?"50% 100%":"50% 0%":"0% 0%"}),We&&!f.dataset.closing&&!En()){let tt=f.animate([{left:`${We.left}px`,top:`${We.top}px`},{left:`${se}px`,top:`${re}px`}],{duration:250,easing:"cubic-bezier(.22,1,.36,1)"});tx.set(f,{animation:tt,left:se,top:re})}}}function mA(f){W||f instanceof DOMException&&f.name==="AbortError"||(Fe=f instanceof Error?f.message:"Something went wrong. Try again.",Dn(Fe))}function Ot(f){f().catch(mA)}function ox(f,k){return k.then(M=>{f.isConnected&&f.replaceWith(M)}).catch(mA),f}let gA=()=>C&&ir&&!e.onboarding&&!!q.user?.verified&&q.user.id.startsWith("google:");function hA(){li?.dispose(),li=rr=Di=void 0}function JN(){Di=q,gr(),zt.querySelector(".account-dialog").scrollTop=0}function ej(){if(li)return li;let f=q;return rr??=Promise.resolve().then(()=>(Yz(),Fz)).then(({accountTokens:k})=>Di!==f?w("div"):(li=k(f,e.project,()=>{hA(),gr(),zt.querySelector('[data-focus-key="account-tokens"]')?.focus()}),li.focusStart(),li),k=>{throw rr=Di=void 0,gr(),k}),ox(w("p","account account-usage-status","Loading API tokens\u2026"),rr)}function bA(f){return ox(w("section","account-usage"),Promise.resolve().then(()=>(t0(),e0)).then(({accountUsage:k})=>k(q,f,!0,J&&pe==="local")))}function Km(){Ot(et?fr:Gu)}async function tj(f){if(!Q){Q=!0,Fe="",gr();try{for(await f();Z&&!W;)await new Promise(k=>setTimeout(k,20));await fr()}finally{Q=!1,$t()}}}let ix=f=>f.map(k=>({...k,comments:k.comments.filter(M=>M.body!=="[Comment deleted]")})).filter(k=>k.comments.length>0),zr,Hu,yA=-1;async function fr(){if(W||Z||Me.busy||e.onboarding)return;let f=Me.revision,k=q,M=k.token,j=xe;Z=!0;try{let ee=await k.list();if(W||k!==q||j!==xe||M!==k.token||Me.busy||f!==Me.revision)return;if(ee===Hu&&f===yA&&De==="Live")return!1;Hu=ee,yA=f,ae=!0;let se=ix(ee),ge=JSON.stringify(se)!==JSON.stringify($),re=De!=="Live";return ce="",et&&(_e=null),De=_e?"Offline":"Live",R&&!se.some(be=>be.id===R)&&(R=null),ge?Me.replace(se,f):re&&(ui(),Ho()),ge}catch(ee){if(W||k!==q||j!==xe||ee instanceof DOMException&&ee.name==="AbortError")return;throw M!==k.token&&sl(),ee instanceof eo&&(ee.status===401||ee.status===403)&&ee.code!=="site_not_approved"&&(ce=ee.message,R=null,Hu=void 0,Me.replace([],f)),_e=ce?null:eT(ee),De="Offline",ui(),Ho(),ee}finally{k===q&&j===xe&&(Z=!1)}}function Tc(){!ie&&B&&(B=!1,Je=Re,ua()),!(F===ie||ie&&(!v||D||b!=="edge"))&&(F=ie,D?b="edge":Z0(ie?"background":"edge",!0))}let Im=()=>L&&!z&&!D&&!F;function Ac(f){if(Se(),$r(),e.onboarding)return;ie&&(ie=!1,Pe?.setActive(!1),Tc()),I=f,f&&$u(),L&&!Im()&&wn(!1);let k=f?_o??ar.shift():null;if(k){P=k.anchor,Do=k.text,_o=null,R=null,C=!1,U=!1,$t(),zt.querySelector("textarea")?.focus();return}U=f,zr?.wake(!1),G=!1,C=!1,f&&(R=null,P=null),$t()}function xA(){fe&&(fe=!1,wn(ke??!0),ke=null,requestAnimationFrame(()=>{let f=he.querySelector(".list");f&&(f.scrollTop=ye),(it.querySelector('.dialog [aria-label="Comment actions"]')??it.querySelector('[data-menu-item="design"]'))?.focus({preventScroll:!0})}))}function Mc(f){e.onboarding||P||f&&!a||(f&&(ke=null,R||Pe?.setReturnAction(null),fe=!0,L&&(ye=he.querySelector(".list")?.scrollTop??0),Ac(!1),ie=!0,le=!1,Tc(),L||wn(!0),C=!1,he.querySelector(".panel")?.contains(it.activeElement)&&he.focus({preventScroll:!0})),ie=f,f?KA().then(k=>k?.setActive(ie)):(Pe?.setActive(!1),Tc(),xA()),$t())}let rx=0;function nj(){let f=Mr(window.innerWidth,window.innerHeight);f!==D&&(it.append(he),Ru(),Ou(!0),Gm(),Lc(),D=f,f||(Xe.style.translate="",vn||(Xe.style.bottom="")),z=!f&&b==="edge",he.removeAttribute("style"),X0(),Cc="",$t())}let Ro=1,Cc="",vA=()=>(window.visualViewport?.offsetTop??0)+Math.min(window.innerHeight,window.visualViewport?.height??window.innerHeight)-window.innerHeight;function oj(){let f=Math.max(1,Math.min(window.innerHeight,window.visualViewport?.height??window.innerHeight)*.9),k=vA(),M=cx().getBoundingClientRect();lt.style.setProperty("--mobile-pill-x",`${M.left+M.width/2-window.innerWidth/2}px`),lt.style.setProperty("--mobile-pill-y",`${M.bottom-(window.innerHeight+k-6)}px`),lt.style.setProperty("--mobile-pill-scale-x",String(Math.max(.01,M.width/Math.max(1,window.innerWidth-24)))),lt.style.setProperty("--mobile-pill-scale-y",String(Math.max(.01,M.height/f)))}function zu(){for(let f of zm.values())f();zm.clear(),jN(),BN(),VN()}function ji(){let f=pr(),k=Mr(window.innerWidth,window.innerHeight)?Math.min(window.innerHeight,window.visualViewport?.height??window.innerHeight):window.innerHeight,M=`${window.innerWidth}:${window.innerHeight}:${k}:${f}:${L}:${C}:${b}:${ie}:${window.visualViewport?.offsetTop??0}`;if(Cc===M)return;if(D||Ru(),Cc=M,lt.style.zoom=String(1/f),lt.style.width=`${window.innerWidth}px`,ht.style.opacity="",z||D){if(h&&j0)return _u();Oi?.cancel(),dr=!1;let me=en?y.scrollTop*f:null;if(en&&(zu(),Ro=1),me!==null&&window.scrollTo({top:me,behavior:"instant"}),lt.style.height=D?`${window.innerHeight}px`:"",lt.style.top=D?"":"0px",D){let ne=vA();Xe.style.translate=`0 ${ne}px`,lt.style.setProperty("--mobile-panel-height",`${Math.max(1,k*.9)}px`),lt.style.setProperty("--mobile-panel-bottom",`${-ne}px`)}lt.classList.toggle("review-open",L),en=!1,Rr(),to?.update(null),ht.style.clipPath="",Object.assign(di.style,{left:"",top:"",width:"",height:""});return}let j=en&&!ts?y.scrollTop:window.scrollY/(f*Ro),ee=en,se=en?y.getBoundingClientRect():{left:0,top:0,width:window.innerWidth};Oi?.cancel(),dr=!1;let ge=IS(window.innerWidth,k,L,window.innerHeight,C,!0,e.frame?.scale===!0),re=ge.framed,be=e.frame?.scale===!0,je={left:ge.left,top:ge.top,width:ge.visibleWidth,height:ge.height},We={left:je.left/f,top:je.top/f,width:je.width/f,height:je.height/f},rt=[window.innerWidth/f,window.innerHeight/f],tt=be?{...We,scale:1,pan:!1}:to?.view(We,rt)??GS(We,rt,!1);if(re&&!be&&Z2())x&&!h&&!Lu?KN():IN();else{if(h&&j0)return _u();ao&&B0()}let Ft=re&&!be&&es,qt=re&&!be&&tt.pan&&!Ft;if(cr=re&&!be?je:null,lt.style.setProperty("--review-viewport-height",`${k}px`),lt.style.height=`${k}px`,lt.style.top="",lt.classList.toggle("review-open",L),lt.classList.toggle("design-active",ie),Ft&&ao)ee&&!ts&&(zu(),window.scrollTo({left:_n.pan?0:window.scrollX,top:j*f,behavior:"instant"})),Un.style.overflow="hidden",Ro=1,_n={left:tt.left,top:tt.top,width:Math.min(We.width,tt.width*tt.scale),height:Math.min(We.height,tt.height*tt.scale),logical:[tt.width,tt.height],pan:!1},ao.place({left:_n.left*f,top:_n.top*f,width:_n.width*f,height:_n.height*f,logical:_n.logical,scale:tt.scale,pan:tt.pan});else if(re){Ro=be?ge.scale:tt.scale;let me=Ro*f;_n=be?{left:ge.left/f,top:ge.top/f,width:window.innerWidth/f*Ro,height:ge.height/f,logical:[window.innerWidth/f,ge.height/me],pan:!1}:{left:tt.left,top:tt.top,width:tt.width*tt.scale,height:tt.height*tt.scale,logical:[tt.width,tt.height],pan:qt},Object.assign(y.style,{position:"fixed",transform:Ro!==1?`scale(${Ro})`:il.transform,transformOrigin:"top left",left:`${_n.left}px`,top:`${_n.top}px`,width:`${be?window.innerWidth/f:tt.width}px`,boxSizing:"border-box",height:`${be?ge.height/me:tt.height}px`,paddingBottom:il.paddingBottom,zoom:il.zoom,overflow:be?"hidden auto":"auto",borderRadius:`${12/me}px`,background:rl,borderRight:il.borderRight,borderBottom:il.borderBottom,clipPath:il.clipPath});for(let ne of y.querySelectorAll("header"))!zm.has(ne)&&getComputedStyle(ne).position==="fixed"&&(zm.set(ne,Yu(ne,["position","margin-bottom"])),ne.style.position="sticky",ne.style.marginBottom=`-${ne.offsetHeight}px`);Un.style.overflow="hidden",document.body.style.overflow="hidden",Un.style.background=document.body.style.background="#080808",y.scrollTop=j}else zu(),en&&!ts&&window.scrollTo({left:window.scrollX,top:j*f,behavior:"instant"}),Ro=1,_n.pan=!1;if(ts=Ft,en=re,Rr(),cr&&eA(),to?.update(cr,f),!re&&e.drawerContainer?.isConnected){let me=e.drawerContainer.getBoundingClientRect();Bm=me.width?me.left+me.width/2:void 0}if(re!==ee&&!W0&&!Go&&!En()){if(ht.style.opacity="0",dr=!0,e.frame?.scale===!0){let ne=re?y.getBoundingClientRect():{left:0,top:0,width:window.innerWidth},we=`translate(${(se.left-ne.left)/f}px, ${(se.top-ne.top)/f}px) scale(${Ro*se.width/ne.width})`;if(y.style.transformOrigin=re?"top left":`0 ${j}px`,!re){Un.style.background=document.body.style.background="#080808",y.style.background=rl;let He=getComputedStyle(y).minHeight;y.style.minHeight=`max(${He==="auto"?"0px":He}, ${window.innerHeight/f}px)`}Oi=y.animate([{transform:we},{transform:`translate(0px, 0px) scale(${Ro})`}],{duration:250,easing:"cubic-bezier(0.32, 0.72, 0, 1)"})}else Oi=iA();let me=Oi;me.finished.then(()=>{W||Oi!==me||(me.cancel(),Oi=void 0,dr=!1,en||zu(),ht.style.opacity="",Rr(),$0.reposition(),Fo())}).catch(()=>{})}let Ie=(me,ne,we,He)=>{let Be=Math.max(me,we);return[Be,Math.max(0,Math.min(me+ne,we+He)-Be)]},[an,nt]=Ie(_n.left*f,_n.width*f,je.left,je.width),[qe,Te]=Ie(_n.top*f,_n.height*f,je.top,je.height),Ue=be?{left:ge.visibleLeft,top:ge.visibleTop,width:ge.visibleWidth,height:ge.visibleHeight}:{left:an,top:qe,width:nt,height:Te};ht.style.clipPath=re?`inset(${Ue.top}px ${window.innerWidth-Ue.left-Ue.width}px ${k-Ue.top-Ue.height}px ${Ue.left}px)`:"",Object.assign(di.style,re?{left:`${Ue.left}px`,top:`${Ue.top}px`,width:`${Ue.width}px`,height:`${Ue.height}px`}:{left:"",top:"",width:"",height:""})}let ax;function sx(){Xe.dataset.edgeTabs!=="true"&&(ax=O0(Xe,["left","top","bottom","transform"])),Object.assign(Xe.style,{left:"",top:"",bottom:"",transform:""}),Xe.parentElement!==he&&he.append(Xe),Xe.dataset.edgeTabs="true",L?Xe.dataset.edgeOrient="horizontal":delete Xe.dataset.edgeOrient}function Lc(){Xe.dataset.edgeTabs==="true"&&(Object.assign(Xe.style,ax),ax=void 0),delete Xe.dataset.edgeTabs,delete Xe.dataset.edgeOrient,Xe.parentElement===he&&Ja.before(Xe)}function lx(){return R&&!C&&!P&&L&&!D&&!ie&&!e.onboarding?he.querySelector(".panel"):null}function ij(f){let k=f??(z&&C?he:it);zt.parentNode!==k&&(k===it?Fn.before(zt):k.append(zt)),zt.classList.toggle("thread-pane",!!f),he.querySelector(".panel")?.toggleAttribute("data-thread",!!f)}function cx(){return Xe.querySelector(".morphing-menu__shell")??Xe}function dx(){return Xe.querySelector(".morphing-menu")}function rj(){return Xe.querySelector(".morphing-menu__bar")}function ux(){return[...he.querySelectorAll(".panel-head, .panel .empty, .thread-card")]}function cl(f){return Y0.push(f),f}function Gm(){for(let f of ux())Object.assign(f.style,{opacity:"",transform:"",filter:""});Hr.style.opacity=""}function Fm(f,k){for(let M of he.getAnimations())M.cancel();Object.assign(he.style,{transition:"none",transform:"none",translate:"none",opacity:"1",left:`${f.left}px`,top:`${f.top}px`,width:`${f.width}px`,height:`${f.height}px`,borderRadius:k})}function wA(){Object.assign(he.style,{width:"",height:"",borderRadius:"",transform:"",opacity:""}),z&&ua(),he.offsetWidth,he.style.transition=""}function EA(f=dx()){delete he.dataset.morphing,delete Xe.dataset.edgeSurface,delete Xe.dataset.edgeMorph,delete Xe.dataset.hidden,f&&(f.style.transition="")}function Ou(f=!1){kc+=1;for(let M of Y0)M.stop();Y0=[];let k=$i;$i=!1,f&&he.toggleAttribute("data-tips-ready",L),!(!f||!k)&&(EA(),Lc(),Gm(),wA())}function aj(f,k,M){let j=he.getBoundingClientRect(),ee=f?null:{left:j.left,top:j.top,width:j.width,height:j.height,radius:he.style.borderRadius||"16px"};Ou(!1),ee&&Fm(ee,ee.radius);let se=kc;$i=!0;let ge=dx();ge&&(ge.style.transition="none");let re=rj(),be=cx(),je=!1,We=()=>{je||se!==kc||W||(je=!0,$i=!1,EA(ge),f||(Gm(),he.style.opacity="0",Lc()),wA(),f&&(he.dataset.tipsReady=""))},rt=Go||En();if(f){let nt=k?he.getBoundingClientRect():null,qe=he.style.borderRadius||"16px";he.style.transition="none",he.style.width="",he.style.height="",he.style.borderRadius="",he.style.transform="none";let Te=be.getBoundingClientRect(),Ue=!k&&M&&M.width>0?M:Te;!k&&Ue.width>0&&(aA={left:Ue.left,top:Ue.top,width:Ue.width,height:Ue.height}),sx(),delete he.dataset.morphing,ua();let me=he.getBoundingClientRect();if(he.dataset.morphing="true",rt||Ue.width<=0||me.width<=0||k&&!nt){We();return}let ne=`${Ue.height/2}px`;k&&nt?Fm(nt,qe):Fm(Ue,ne),ux().forEach((yt,Kt)=>{yt.style.opacity="0",yt.style.transform="translateY(48px)",yt.style.filter="blur(4px)",cl(Qr(yt,{opacity:1,y:0,filter:"blur(0px)"},{...RE,delay:zE+Kt*k6}))}),Hr.style.opacity="0",cl(Qr(Hr,{opacity:1},{...RE,delay:zE}));let we=()=>{if(se!==kc||W)return;delete he.dataset.morphing;let yt=he.getBoundingClientRect();cl(Qr(he,{left:[`${yt.left}px`,`${me.left}px`],top:[`${yt.top}px`,`${me.top}px`],width:[`${yt.width}px`,`${me.width}px`],height:[`${yt.height}px`,`${me.height}px`],borderRadius:[he.style.borderRadius||"16px","16px"]},Ol)).finished.then(We).catch(()=>{se===kc&&We()})};if(k||Ue.height>Ue.width+8){we();return}let He=S6(re?.offsetWidth||Ue.width,re?.offsetHeight||Ue.height),Be=T6(Ue.left+Ue.width/2,Ue.top+Ue.height,He.width,He.height),Qe=he.getBoundingClientRect();cl(Qr(he,{left:[`${Qe.left}px`,`${Be.left}px`],top:[`${Qe.top}px`,`${Be.top}px`],width:[`${Qe.width}px`,`${Be.width}px`],height:[`${Qe.height}px`,`${Be.height}px`]},tb)).finished.then(we).catch(()=>{});return}let tt=ee??he.getBoundingClientRect(),Ft=ee?.radius||he.style.borderRadius||"16px";delete Xe.dataset.hidden,he.dataset.morphing="true",sx();let qt=Xe.getBoundingClientRect(),Ie=aA??{left:(window.innerWidth-(qt.width||228))/2,top:window.innerHeight-24-(qt.height||52),width:qt.width||228,height:qt.height||52};if(rt||Ie.width<=0||tt.width<=0){We();return}Fm(tt,Ft);for(let nt of ux())cl(Qr(nt,{opacity:0,y:16,filter:"blur(2px)"},HE));cl(Qr(Hr,{opacity:0},HE)),cl(Qr(he,{left:[`${tt.left}px`,`${Ie.left}px`],top:[`${tt.top}px`,`${Ie.top}px`],width:[`${tt.width}px`,`${Ie.width}px`],height:[`${tt.height}px`,`${Ie.height}px`],borderRadius:[Ft,`${Ie.height/2}px`]},nb)).finished.then(We).catch(()=>{se===kc&&We()})}function wn(f,k=!1){!f&&X&&!X.opened&&Se(),f!==L&&$r(),f&&$u(),Ru();let M=f&&!L;if(L=f,Go||zr?.wake(M),delete he.dataset.tipsReady,he.toggleAttribute("data-tips-restored",Go),!e.onboarding&&!k&&rA.set(f),f&&(U=!1),f||(clearTimeout(Io),Io=0,C=!1,Uu=qu="",Ku()),D){cancelAnimationFrame(rx),oj(),M&&!Go&&!En()?lt.dataset.mobileEntering="":delete lt.dataset.mobileEntering,G=!1,ji(),$t(),ur.show(),ur.update(),lt.dataset.mobileEntering!==void 0&&(rx=requestAnimationFrame(()=>{delete lt.dataset.mobileEntering}));return}if(z){let se=$i,ge=f?cx().getBoundingClientRect():null;f||delete Xe.dataset.edgeOrient,vn=f?vn:N,Sc=void 0,G=!1,$i=!0;let re=dx();re&&(re.style.transition="none"),ur.show(),ji(),$t(),aj(f,se,ge),ur.update();return}let j=Xe.getBoundingClientRect();vn=f?void 0:N,Sc=void 0,G=!1,ji(),$t(),ns?.stop(),Xe.style.translate="0px 0px";let ee=Xe.getBoundingClientRect();!Go&&!En()&&(ns=Qr(Xe,{translate:[`${j.left-ee.left}px ${j.top-ee.top}px`,"0px 0px"]},{type:"spring",stiffness:680,damping:32,mass:.55})),ur.show(),ur.update()}function Or(){if(Se(),$r(),I=!1,clearTimeout(Io),Io=0,C){Ot(Jt),Tu=null,C=!1,$t();return}R=null,P=null,C=!1,Ri=null,Fe="",U=!1,$t()}function sj(){fe=!1,ie=!1,Pe?.setActive(!1),Tc(),Or(),L&&wn(!1),U=!1,I=!1,G=!0,te=!0;try{sessionStorage.setItem(I0,"1")}catch{}$t()}function $u(){if(!go)return;go=!1,Pm=!1;try{zo(sessionStorage,G0)}catch{}Ja.textContent="Comments shown";let f=F0;F0=0,f&&requestAnimationFrame(()=>{let k=he.querySelector(".list");k&&(k.scrollTop=f)})}function kA(f){if(f===go||W||e.onboarding||f&&ie)return;if(!f){let M=Pm&&!L;$u(),M?wn(!0):$t();return}$r(),go=!0;try{sessionStorage.setItem(G0,"1")}catch{}Ja.textContent="Comments hidden",U=I=!1,clearTimeout(Io),Io=0,C=!1;let k=L;k?(F0=he.querySelector(".list")?.scrollTop??0,wn(!1,!0)):$t(),Pm=k}function SA(){te=!1,G=!1;try{zo(sessionStorage,I0)}catch{}$t()}function os(f,k=!1){if(k||Se(),$r(),$u(),R0=!!it.activeElement?.matches(":focus-visible")&&he.contains(it.activeElement),I=!1,clearTimeout(Io),Io=0,!k&&!ze(f)){let ee=new URL(f.page,location.origin);ee.searchParams.set("comment",f.id),Hx(ee);return}k||(de.delete(f.id),X={id:f.id,inspect:!1,pending:!1,rejected:!1,opened:!0}),wc=Au===f.id&&!Fn.hidden?Fn.getBoundingClientRect():null,wc&&Hi(!0),R=f.id,P=null,C=!1,Ri=null,Fe="",U=!1;let M=D&&L;M&&wn(!1);let j=Le(f)?ga(f.anchor):null;j?.attached&&!wc&&(M||!D)&&(en?y:window).scrollBy({top:(j.y-(M?Math.min(window.innerHeight,window.visualViewport?.height??window.innerHeight):window.innerHeight)*.35)/(en?Ro*pr():1),behavior:M&&!En()?"smooth":"instant"}),$t()}function px(){let f=rT(),k=Ni();return $.filter(M=>(ct==="all"||M.resolved===(ct==="resolved"))&&(!ue||!!M.tags?.includes(ue))&&(!ve||M.comments.some(j=>`${j.body} ${j.author.name}`.toLowerCase().includes(ve.toLowerCase()))||M.page.toLowerCase().includes(ve.toLowerCase()))&&(Ae||ze(M,f.resolve,k))).sort((M,j)=>j.updatedAt-M.updatedAt)}function TA(){Promise.resolve().then(()=>(sO(),aO)).then(({showShortcutHelp:f})=>f(it,[...s.map(({label:k,shortcut:M,group:j})=>({label:k,shortcut:M,group:j==="Comments & view"?"Comments":"General"})),{label:"Restore feedback",shortcut:o.restore,group:"General"}],a,ie?"design":I?"comment":void 0,i,v))}function Ho(){Xe.style.display=te?"none":"",ur.update();let{dockCenter:f}=IS(window.innerWidth,window.innerHeight,L);if(D)Lc(),Object.assign(Xe.style,{left:"50%",top:"auto",bottom:"calc(16px + env(safe-area-inset-bottom,0px))",transform:"translateX(-50%)"});else if(z)$i||(delete Xe.dataset.hidden,L?sx():(Lc(),vn&&Vm(vn)),ua());else{delete Xe.dataset.hidden;let se=!L&&e.drawerContainer?.isConnected?e.drawerContainer.getBoundingClientRect():void 0;se?.width&&!dr&&(Bm=se.left+se.width/2);let ge=Xe.offsetWidth/2,re=se?.width&&Bm!==void 0?Math.max(16+ge,Math.min(window.innerWidth-16-ge,Bm)):f;if(vn)Vm(vn);else if(re!==Sc){let be=Xe.getBoundingClientRect(),je=be.left+be.width/2;ns?.stop(),Xe.style.top="",Xe.style.bottom="",Xe.style.left=`${re}px`,Xe.style.translate="0px 0px",Sc!==void 0&&!En()&&(ns=Qr(Xe,{translate:[`${je-re}px ${be.top-Xe.getBoundingClientRect().top}px`,"0px 0px"]},{type:"spring",stiffness:680,damping:32,mass:.55})),Sc=re}}let k=se=>({glyph:se}),M=[{id:"browse",label:"Browse website",group:"Modes",shortcut:o.browse,icon:k("pointer"),onSelect:()=>Ac(!1)},{id:"comment",label:"Add comment",group:"Modes",shortcut:o.comment,icon:k("comment"),onSelect:()=>Ac(!I)},...a?[{id:"design",label:"Design mode",group:"Modes",shortcut:o.design,icon:k("design"),onSelect:()=>Mc(!ie)}]:[],{id:"comments",group:"Comments & view",label:e.onboarding?L?"Close project panel":"Project settings":L?"Close comments panel":"All comments",shortcut:e.onboarding?null:o.comments,count:e.onboarding||L?void 0:$.filter(se=>!se.resolved).length,icon:k("expand"),onSelect:()=>wn(!L)},{id:"account",group:"Account & help",label:q.user?`${q.user.name} \xB7 Account`:e.onboarding?.inProject?"Set up inline feedback":"Enter your name",icon:{user:q.user},onSelect:()=>{C||Io?(clearTimeout(Io),Io=0,C=!1,$t()):ma()}},{id:"copy-prompts",group:"Comments & view",keepOpenOnSelect:!0,label:_c==="all"?"Copied prompt":"Copy comments for agent",icon:k(_c==="all"?"check":"copy"),showInBar:!1,onSelect:()=>Ot(()=>DA("all"))},...v&&!D&&!ie?[{id:"layout",group:"Comments & view",label:b==="edge"?"Frame view":"Floating view",icon:k("expand"),showInBar:!1,onSelect:()=>Z0(b==="edge"?"background":"edge")}]:[],{id:"dismiss",group:"Feedback",label:"Dismiss feedback",icon:k("close"),onSelect:sj},{id:"visibility",group:"Comments & view",label:go?"Show comments":"Hide comments",shortcut:o.visibility,icon:k("comment"),showInBar:!1,onSelect:()=>kA(!go)},{id:"pin-size",group:"Comments & view",label:`Pin size: ${R2[S]}`,icon:k("pointer"),showInBar:!1,children:D2.map(se=>({id:`pin-size-${se}`,label:R2[se],icon:k("check"),checked:se===S,onSelect:()=>lj(se)}))}];M.push({id:"shortcuts",group:"Account & help",label:"Keyboard shortcuts",icon:k("info"),showInBar:!1,onSelect:TA}),s=M,De==="Offline"&&M.push({id:"retry",label:`${_e?.title??"Offline"} \xB7 Retry`,icon:k("info"),showInBar:!1,onSelect:Km});let j=e.onboarding?M.filter(se=>se.id==="account"||se.id==="comments"):M,ee=VR(e.onboarding?my:l,se=>se==="more"||j.some(ge=>ge.id===se));ee.length||(Xe.style.display="none"),q2.render({items:j,bar:ee,alignEnd:L&&z?!1:!!vn&&vn.y>window.innerHeight/2,edge:L&&z?"bottom":vn?.edgeX??vn?.edgeY??(vn&&vn.y<window.innerHeight/2?"top":"bottom"),activeId:ie?"design":I?"comment":"browse",label:"Website review",moreLabel:"More review tools"})}function lj(f){if(!(f===S||W)){S=f;try{localStorage.setItem(E,f)}catch{}Ja.textContent=`Pin size: ${R2[f]}`,fa="",mr(),Ho()}}let cj=()=>S==="auto"?U||I||L?"full":"dot":S,is=null,fx=0;function mx(){fx=0;for(let f of ht.querySelectorAll(":scope > .pin")){let k=f.getBoundingClientRect(),M=!!is&&Math.hypot(Math.max(k.left-is.x,0,is.x-k.right),Math.max(k.top-is.y,0,is.y-k.bottom))<=24;f.toggleAttribute("data-near",M)}}let AA=new Set,MA=0,gx=0;function dj(f){let k=!1;for(let M of f)T(M)&&!AA.has(M.id)&&(k=!!AA.add(M.id));!k||En()||(MA=performance.now(),ht.style.setProperty("--pin-breathe-delay","0ms"),ht.dataset.breathe="",clearTimeout(gx),gx=window.setTimeout(()=>delete ht.dataset.breathe,5400))}let fa="",Ym=new Set,CA=new Map;function hx(f,k){let M=f.querySelector(".page");if(!M)return;let j=new URL(k.page,location.origin).href,ee=Qd(k),se=k.page===Ni();M.href=j,M.title=j,M.setAttribute("aria-label",`Open page: ${j}`);let ge=M.closest(".card-page-row");ge.hidden=se&&!ee,ge.querySelector(".card-page-url").textContent=j;let re=ee?"":j;if(M.dataset.url!==re){M.dataset.url=re;let je=ee?"All pages":sM(new URL(j));if(M.textContent=je,e.pageLabel&&!ee){let We=CA.get(j);We||(We=Promise.resolve().then(()=>e.pageLabel(new URL(j))).then(rt=>rt?.trim()||je,()=>je),CA.set(j,We)),We.then(rt=>{!W&&M.dataset.url===j&&(M.textContent=rt)})}}let be=f.querySelector(".card-status");be.textContent=k.resolved?"Resolved":Ym.has(k.id)&&se?"Not found on page":"",be.hidden=!be.textContent,f.classList.toggle("resolved",k.resolved),f.classList.toggle("active",R===k.id),f.querySelector(".thread-card").setAttribute("aria-description",[ee&&"All pages",j,be.textContent].filter(Boolean).join(" \xB7 "))}let bx=!1,yx=0,xx=e.pins?.cluster!==!1,Xm,LA=!1;function uj(){LA||(LA=!0,Promise.resolve().then(()=>(uO(),dO)).then(f=>Xm=f,()=>xx=!1).then(()=>{fa="",mr()}))}let _A=()=>en?Du():{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight};function mr(f=!1){let k=G||go;if(k&&$r(),Gt||bx&&!f)return;if(k){fa="",Hi(),ht.replaceChildren();return}let M=cj();M==="full"?delete ht.dataset.size:ht.dataset.size=M;let j=$.find(Te=>Te.id===R);j&&H(j);let ee=rT(),se=Ni(),ge=$.filter(Te=>!Te.resolved&&(!ue||!!Te.tags?.includes(ue))&&ze(Te,ee.resolve,se));M==="dot"&&dj(ge);let re=new Map,be=xx?mM(ge,Te=>{let Ue=ee.resolve(Te.anchor),me=Ue&&Xf(Ue,y,e.anchorTarget);return!me||me===y||me===document.body?null:(re.set(Te.id,me),me)}):new Map,je=ge.map(Te=>{let Ue=ee.locate(Te.anchor);if(Ue.y<-Ue.height-40||Ue.y>window.innerHeight+40)return{thread:Te,rect:Ue,blocked:!1};let me=ee.resolve(Te.anchor),ne=Lx(Ue.x+8,Ue.y-10),we=!!(me&&ne&&!me.contains(ne)&&!ne.contains(me));return{thread:Te,rect:Ue,blocked:we}});for(let{thread:Te,rect:Ue}of je){if(Ym.has(Te.id)===!Ue.attached)continue;Ue.attached?Ym.delete(Te.id):Ym.add(Te.id);let me=it.querySelector(`.thread-item[data-thread="${CSS.escape(Te.id)}"]`);me&&hx(me,Te)}let We=JSON.stringify([R,M,P&&ee.locate(P),je.map(({thread:Te,rect:Ue,blocked:me})=>[Te.id,Ue,me,ag(Ue,window.innerWidth),be.get(Te.id)?.[0].id])]);if(We===fa)return;fa=We,ol?.isPreviewing(z0)||Hi();let rt=it.activeElement?.matches(".pins :focus-visible")?it.activeElement.dataset:void 0,tt=ht.querySelector(".pin-cluster[open]")?.dataset.cluster;ht.replaceChildren(),"breathe"in ht.dataset&&ht.style.setProperty("--pin-breathe-delay",`${(MA-performance.now())%1800}ms`);let Ft=new Map(je.map(Te=>[Te.thread.id,Te])),qt=_A(),Ie=[],an=new Set;for(let{thread:Te,rect:Ue,blocked:me}of je){if(!Ue.attached)continue;let ne=be.get(Te.id),we=ne&&Ft.get(ne[0].id),He=we?.rect.attached?we:{rect:Ue,blocked:me};if(He.rect.y<-He.rect.height-40||He.rect.y>window.innerHeight+40||He.blocked)continue;if(Ue.width&&Ue.height){let yt=w("div","area");Object.assign(yt.style,{left:`${Ue.x}px`,top:`${Ue.y}px`,width:`${Ue.width}px`,height:`${Ue.height}px`,opacity:Te.id===R?"1":".45"}),ht.append(yt)}let Be=we?.rect.attached?ne:null;if(Be&&an.has(Be))continue;let Qe=He.rect,Nt=Be?Qe.x-9+Math.min(Be.length,6)*38>qt.right:ag(Qe,window.innerWidth)==="right";Be&&an.add(Be),Ie.push({threads:Be??[Te],rect:Qe,right:Nt,owner:Be?re.get(Be[0].id):void 0,box:Te.anchor.unstacked||Te.id===R?null:hM(Qe.x,Qe.y,Nt,Be?gM(Be.length,M==="dot"?12:20):24)})}let nt=(Te,Ue)=>{let me=$.indexOf(Te)+1,ne=Te.comments[0],we=Oe(ne?`Comment ${me} by ${ne.author.name}: ${j2(ne.body)}`:`Comment ${me}`,()=>os(Te),`pin${Te.id===R?" active":""}${Te.id===Vu?" hot":""}${Te.resolved?" resolved":""}${Ue.attached?"":" detached"}`);if(we.textContent="",we.title="",we.toggleAttribute("data-read",!T(Te)),ne){let Be=ne.author;Wu(we,Be.accentColor);let Qe=yr(Be);Qe.dataset.initial=tp(Be.name).slice(0,1),we.append(Qe);let Nt=we.querySelector("img");Nt&&(Nt.draggable=!1)}if(Te.resolved){let Be=w("span","pin-check");Be.append(bt("check")),we.append(Be)}let He=()=>{if(R||P||U||Gt||sr||xc)return;Rm=!1,window.clearTimeout(Dm);let Be=Fn.hidden||Au!==Te.id;vc?.cancel(),Au=Te.id,Fn.replaceChildren();let Qe=Te.comments[0];if(!Qe)return;let Nt=Oe("Open comment",()=>os(Te),"pin-preview-open");Nt.textContent="";let yt=mo.test(Qe.body),Kt=w(yt?"div":"p","hover-message",N2(Qe.body));yt&&wu().then(({renderDesignComment:jt})=>jt(Kt,Qe.body,{key:z0=`hover:${Qe.id}`,resolve:Rn=>Le(Te)?_0(Te.anchor)(Rn):null,note:(Rn,Yo)=>Rn.textContent=Yo,compact:!0,design:e.design})),Nt.append($A(Qe)),yt?(Kt.classList.add("pin-preview-card"),Kt.addEventListener("click",jt=>{jt.target.closest(".design-toggle")||os(Te)})):Nt.append(Kt);let Bi=Oe(Te.resolved?"Reopen comment":"Resolve comment",()=>{Hi(),kx(Te)},"icon pin-preview-resolve","check");Bi.disabled=!Qm(),Fn.append(Nt,...yt?[Kt]:[],Bi),Fn.hidden=!1;let fi=_x(we,Ue),xt=L&&!D?396:12,Bt=FS(GA(we),Fn.offsetWidth||320,Fn.offsetHeight,{left:12,top:12,right:window.innerWidth-xt,bottom:en?Math.min(window.innerHeight,Du().bottom)-12:window.innerHeight-92});Object.assign(Fn.style,{left:`${Bt.x}px`,transformOrigin:fi.x<Bt.x+160?"top left":"top right",top:`${Bt.y}px`}),Be&&!En()&&(vc=Fn.animate([{opacity:0,transform:"translateY(6px) scale(.97)"},{opacity:1,transform:"none"}],{duration:250,easing:"cubic-bezier(.22,1,.36,1)"}))};return we.addEventListener("pointerenter",He),we.addEventListener("pointermove",Be=>{xc&&!Gt&&!sr&&Be.buttons===0&&(Be.movementX||Be.movementY)&&(xc=!1,He())}),we.addEventListener("focus",He),we.addEventListener("blur",()=>Hi()),we.addEventListener("pointerleave",()=>{Dm=window.setTimeout(Hi,120)}),we.dataset.thread=Te.id,we},qe={root:it,bounds:qt,pin:Te=>nt(Te,Ft.get(Te.id).rect),summary:Te=>j2(Te.comments[0]?.body??""),open:Te=>os(Te),menu:Kf};for(let Te of xx?bM(Ie.map(Ue=>Ue.box)):Ie.map((Ue,me)=>[me])){let Ue=Ie[Te[0]];if(Te.length>1||Ue.threads.length>1)Xm?ht.append(Te.length>1?Xm.bubble(Te.map(me=>Ie[me]),Te.flatMap(me=>Ie[me].threads).sort(Px),qe):Xm.stack(Ue,qe)):uj();else{let me=qe.pin(Ue.threads[0]);me.dataset.pointer=Ue.right?"right":"left",Object.assign(me.style,{left:`${Ue.rect.x}px`,top:`${Ue.rect.y}px`}),ht.append(me)}}if((rt?.thread||rt?.cluster)&&ht.querySelector(rt.thread?`.pin[data-thread="${CSS.escape(rt.thread)}"]`:`[data-cluster="${CSS.escape(rt.cluster)}"]`)?.focus({preventScroll:!0}),tt&&ht.querySelector(`[data-cluster="${CSS.escape(tt)}"]`)?.setAttribute("open",""),ht.dataset.size&&is&&mx(),P&&P.width>0&&P.height>0){let Te=ga(P),Ue=w("div","area");Object.assign(Ue.style,{left:`${Te.x}px`,top:`${Te.y}px`,width:`${Math.max(8,Te.width)}px`,height:`${Math.max(8,Te.height)}px`}),ht.append(Ue)}}let _c=null,vx=0;async function DA(f){let k=RM(f==="page"?$.filter(M=>ze(M)):$,{...e,origin:location.origin,page:f==="page"?Ni():void 0});if(!k){Dn(f==="page"?"No open comments on this page":"No open comments to copy");return}await navigator.clipboard.writeText(k),!W&&(_c=f,Ja.textContent="Agent prompt copied",clearTimeout(vx),Ho(),ui(),vx=window.setTimeout(()=>{_c=null,Ho(),ui()},2e3))}let Nu,ju,Wm=f=>{f.removeAttribute("title"),f.addEventListener("pointerenter",k=>{k.pointerType==="mouse"&&ju?.show(f)}),f.addEventListener("focus",()=>ju?.show(f));for(let k of["pointerleave","blur","pointerdown"])f.addEventListener(k,()=>ju?.hide())},Zm=new Set,RA="palette:dismissed-tips",HA=[["copy","Copy comments for your agent."]];o.comment&&HA.push(["shortcut",`Press ${o.comment.label} to comment.`]);function pj(f){try{let k=JSON.parse(localStorage.getItem(RA)??"[]");if(Array.isArray(k))for(let M of k)typeof M=="string"&&Zm.add(M)}catch{}for(let[k,M]of HA){let j=he.querySelector(`[data-tip="${k}"]`);if(!f||Zm.has(k)){j?.remove();continue}if(j)continue;j=w("div","morphing-menu__tooltip sidebar-tip"),j.dataset.tip=k;let ee=j;j.append(w("p","",M),Oe("Dismiss tip",()=>{Zm.add(k);try{localStorage.setItem(RA,JSON.stringify([...Zm]))}catch{}ee.dataset.leaving="",setTimeout(()=>ee.remove(),150)},"icon","close")),he.append(j)}wx()}function wx(){let f=he.getBoundingClientRect();for(let k of he.querySelectorAll(".sidebar-tip")){let M=k.dataset.tip==="copy",j=he.querySelector(M?".copy-page-prompt":'.toolbar [aria-label^="Add comment"]')?.getBoundingClientRect();if(k.hidden=!j?.width,!j?.width)continue;let ee=j.left+j.width/2-f.left,se=Math.max(12,Math.min(f.width-12-k.offsetWidth,ee-k.offsetWidth/2));k.style.left=`${se}px`,k.style.top=M?`${j.bottom-f.top+10}px`:`${j.top-f.top-10-k.offsetHeight}px`,k.style.setProperty("--caret-x",`${ee-se}px`)}}let Ex,Pu=!1;function fj(f){if(!Pu||Me.busy)return;let k=px().filter(ge=>ge.resolved).map(ge=>ge.id);if(!k.length)return;let M=w("div","cleanup-confirm");M.popover="auto",M.setAttribute("role","alertdialog"),M.setAttribute("aria-label","Delete resolved comments permanently"),M.append(w("strong","",`Delete ${k.length} resolved ${k.length===1?"thread":"threads"}?`),w("p","","Their replies will be deleted too. This can\u2019t be undone."));let j=w("div","cleanup-actions"),ee=()=>{M.hidePopover(),f.focus({preventScroll:!0})};j.append(Oe("Cancel",ee,"secondary"),Oe("Delete permanently",()=>{ee(),Ot(async()=>{try{for(let ge=0;ge<k.length;ge+=250){let re=k.slice(ge,ge+250),be=new Set(re);await Me.submit(je=>je.filter(We=>!be.has(We.id)),async()=>{await q.request("project/clear-resolved","POST",{confirm:e.project,threadIds:re})})}}finally{await fr()}})},"secondary destructive")),M.append(j),he.append(M),M.addEventListener("toggle",()=>{M.matches(":popover-open")||M.remove()}),M.showPopover();let se=f.getBoundingClientRect();M.style.left=`${Math.max(12,Math.min(se.right-M.offsetWidth,innerWidth-M.offsetWidth-12))}px`,M.style.top=`${Math.max(12,Math.min(se.bottom+8,innerHeight-M.offsetHeight-12))}px`,j.querySelector("button")?.focus()}let Qm=()=>!Q&&(Pn||!!q.user?.verified);function kx(f,k){if(!q.user&&(!Et||!da.trim())){ma();return}let M=R===f.id,j=ee=>{let se=R;return M&&(R=ee?null:f.id),vt(Ke(f.id,ge=>({...ge,resolved:ee,resolvedBy:ee?q.user:null})),async ge=>{q.user||await q.guest(da),await q.request(`threads/${ge(f.id)}`,"PATCH",{resolved:ee})},()=>{R||(R=se)})};Ot(()=>j(!f.resolved)),Dn(f.resolved?"Comment reopened":"Comment resolved",{label:"Undo",run:()=>Ot(()=>j(f.resolved))},k)}let zA=new WeakMap,Dc=new Set;function OA(f,k){return f.textContent=k,mo.test(k)&&(f.textContent="Design change",wu().then(({summarizeDesignComment:M})=>{f.textContent=M(k)})),f}function ui(){if(e.onboarding){if(Nu?.(),he.replaceChildren(),e.onboarding.inProject)return;if(L){let ne=w("aside","panel");ne.setAttribute("aria-label","Project settings");let we=w("div","panel-head","Project settings"),He=w("div","empty");He.append(w("p","","Leave comments on your connected website."),Oe("Manage project",()=>{ma()},"secondary")),ne.append(we,He),he.append(ne)}return}if(!L&&(z||D))return;let f=he.querySelector(".list"),k=f?.scrollTop??0,M=it.activeElement?.closest(".thread-item"),j=M?.querySelector(".reply-composer")?.contains(it.activeElement)?M:null,ee=w("div"),se=it.activeElement?.getAttribute("aria-label")==="Search comments",ge=se?it.activeElement.selectionStart:null;if(!L&&!z&&!D){Nu?.(),he.replaceChildren();return}let re=he.querySelector(".panel");if(!re){re=w("aside","panel"),re.setAttribute("aria-label","All comments");let ne=w("div","panel-head"),we=w("div","row between sidebar-title"),He=w("div","filter-slot"),Be=w("div","row"),Qe=Hn=>{let qn=re.querySelector(".sidebar-search-field"),hr=Be.querySelector('[aria-label="Search comments"]'),un=(Hn?hr:qn).getBoundingClientRect();Ec=Hn,Hn||(ve="",qn.querySelector("input").value=""),ui();let ba=(Hn?qn:hr).getBoundingClientRect();En()||qn.animate(Hn?[{transform:`translate(${un.left-ba.left}px, ${un.top-ba.top}px)`,width:`${un.width}px`,height:`${un.height}px`,borderRadius:"50%",opacity:.4},{transform:"none",width:`${ba.width}px`,height:`${ba.height}px`,borderRadius:"10px",opacity:1}]:[{transform:"none",opacity:1},{transform:`translate(${ba.left-un.left}px, ${ba.top-un.top}px) scale(.2)`,opacity:0}],{duration:280,easing:"cubic-bezier(.22,1,.36,1)"}),Hn?qn.querySelector("input")?.focus():hr.focus()};Be.append(Oe("Copy page comments",()=>ct==="resolved"?fj(re.querySelector(".copy-page-prompt")):Ot(()=>DA("page")),"icon copy-page-prompt","copy"),w("div","tag-filter-slot"),Oe("Search comments",()=>Qe(!0),"icon sidebar-search-trigger","search"),Oe("Close sidebar",()=>wn(!1),"icon","close"));let Nt=w("div","sidebar-selector");Nt.append(He,w("div","scope-slot")),we.append(Nt,Be);let yt=w("div","sidebar-search"),Kt=w("div","sidebar-search-inner"),Bi=w("div","sidebar-search-row"),fi=w("div","sidebar-search-field"),xt=w("input");xt.type="search",xt.placeholder="Search",xt.setAttribute("aria-label","Search comments"),xt.addEventListener("input",()=>{ve=xt.value,ui()}),xt.addEventListener("keydown",Hn=>{Hn.key==="Escape"&&(Hn.stopPropagation(),Bt())}),fi.append(bt("search"),xt);let Bt=()=>Qe(!1);fi.append(Oe("Close search",Bt,"icon search-cancel","close")),Bi.append(fi),Kt.append(Bi),yt.append(Kt),ne.append(we,yt);let jt=w("div","morphing-menu__tooltip sidebar-tooltip");jt.setAttribute("aria-hidden","true"),it.append(jt);let Rn=0,Yo=0,ha=()=>{clearTimeout(Rn),jt.dataset.open&&(delete jt.dataset.open,Yo=Date.now()+300)};Nu=()=>{clearTimeout(Rn),jt.remove(),Nu=void 0,ju=void 0};let dn=Hn=>{clearTimeout(Rn);let qn=()=>{if(!Hn.isConnected)return;let hr=Hn.getBoundingClientRect();jt.textContent=Hn.ariaLabel;let un=jt.offsetWidth/2;jt.style.left=`${Math.max(8+un,Math.min(innerWidth-8-un,hr.left+hr.width/2))}px`,jt.style.top=`${hr.bottom+8}px`,jt.dataset.open="true"};jt.dataset.open||Date.now()<Yo?qn():Rn=window.setTimeout(qn,400)};Be.querySelectorAll("button").forEach(Wm),ju={show:dn,hide:ha},re.append(ne),he.append(re)}let be=re.querySelector(".copy-page-prompt");if(ct==="resolved"&&Ex!==q.token){Ex=q.token,Pu=!1;let ne=Ex;ne&&q.request("project").then(()=>{q.token===ne&&(Pu=!0,ui())}).catch(()=>{})}let je=ct==="resolved";be.disabled=je&&(!Pu||Me.busy||!px().length),be.classList.toggle("destructive",je);let We=je?"trash":_c==="page"?"check":"copy";if(be.dataset.glyph!==We){let ne=be.querySelector("svg:not([data-leaving])"),we=bt(We),He=be.dataset.glyph!==void 0&&!En();if(be.dataset.glyph=We,He&&ne){ne.setAttribute("data-leaving","true"),be.append(we);let Be={duration:200,easing:"cubic-bezier(.22,1,.36,1)"},Qe={opacity:0,transform:"scale(.7)",filter:"blur(2px)"},Nt={opacity:1,transform:"scale(1)",filter:"blur(0px)"};ne.animate([Nt,Qe],{...Be,fill:"forwards"}).finished.then(()=>ne.remove()).catch(()=>ne.remove()),we.animate([Qe,Nt],Be)}else be.replaceChildren(we)}be.setAttribute("aria-label",je?Pu?"Delete resolved comments permanently":"Project owner only":_c==="page"?"Copied prompt":"Copy page comments"),re.dataset.search=String(Ec),re.querySelector(".filter-slot").inert=Ec,re.querySelector(".scope-slot").inert=!Ec,re.querySelector(".sidebar-search-trigger").inert=Ec;let rt=re.querySelector(".sidebar-search");rt.inert=!Ec;let tt=re.querySelector(".filter-slot"),Ft=c?[...new Set($.flatMap(ne=>ne.tags??[]))].sort():[];ue&&!Ft.includes(ue)&&(ue=""),tt.dataset.value!==ct&&(tt.dataset.value=ct,tt.replaceChildren(ec("Filter comments",[["open","Comments"],["all","All comments"],["resolved","Resolved"]],ct,ne=>{ct=ne,ui(),mr()})));let qt=re.querySelector(".tag-filter-slot"),Ie=`${ue} ${Ft}`;if(qt&&qt.dataset.value!==Ie&&(qt.dataset.value=Ie,qt.replaceChildren(),Ft.length)){let ne=ue?`Filtered by #${ue}`:"Filter by tag",we=ec(ne,[["","All tags"],...Ft.map(Be=>[Be,`#${Be}`])],ue,Be=>{ue=Be,ui(),mr()}),He=we.querySelector("summary");He.className=`icon tag-filter-trigger${ue?" active":""}`,He.setAttribute("aria-label",ne),He.title=ne,He.replaceChildren(bt("tag")),qt.append(we)}let an=re.querySelector(".scope-slot");an.dataset.value!==String(Ae)&&(an.dataset.value=String(Ae),an.replaceChildren(ec("Comment pages",[["page","This page"],["all","All pages"]],Ae?"all":"page",ne=>{Ae=ne==="all",ui()})));let nt=!D&&!Go&&!En(),qe=new Map;if(nt&&f){let ne=f.getBoundingClientRect();for(let we of f.querySelectorAll("[data-thread]")){let He=we.getBoundingClientRect();He.bottom>=ne.top&&He.top<=ne.bottom&&qe.set(we.dataset.thread,He.top)}}let Te=w("div","list"),Ue=px();Ue.length>40&&(Te.dataset.long="");let me=!ae&&De==="Connecting";Te.setAttribute("aria-busy",String(me)),clearTimeout(Cm),Te.addEventListener("scroll",()=>{Te.dataset.scrolling="true",clearTimeout(Cm),Cm=window.setTimeout(()=>{delete Te.dataset.scrolling},800)},{passive:!0});for(let ne of Ue){let we=ne.comments[0];if(!we)continue;let He=zA.get(ne);if(He){He.querySelector(".thread-card").classList.toggle("active",R===ne.id),He.querySelector(".card-resolve").disabled=!Qm(),He.querySelector("small").textContent=Pc(we.createdAt),He.querySelectorAll(".reply-meta small").forEach((Hn,qn)=>{Hn.textContent=Pc(ne.comments[qn+1].createdAt)}),hx(He,ne);let dn=He.querySelector("textarea");dn&&it.activeElement!==dn&&requestAnimationFrame(()=>dn.dispatchEvent(new Event("palette-sync-reply"))),Te.append(He===j?ee:He);continue}let Be=Oe(`Open comment by ${we.author.name}`,()=>os(ne),`thread-card${R===ne.id?" active":""}`);Be.replaceChildren(),Be.removeAttribute("title");let Qe=w("div","row"),Nt=w("span","card-status");Qe.append(yr(we.author),w("span","author",we.author.name),Nt,w("small","",Pc(we.createdAt)));let yt=w("div","card-page-row"),Kt=w("a","page","Page link");Kt.addEventListener("click",dn=>{dn.preventDefault(),os(ne)});let Bi=Oe("Copy page URL",()=>Ot(async()=>{await navigator.clipboard.writeText(new URL(ne.page,location.origin).href),Dn("Page URL copied")}),"icon card-page-copy","copy"),fi=w("span","card-page-url");yt.append(bt("link"),Kt,Bi,fi);let xt=OA(w("p","preview"),we.body);if(Be.append(Qe,xt),c&&ne.tags?.length){let dn=w("div","card-tags");dn.setAttribute("role","group"),dn.setAttribute("aria-label","Tags");for(let Hn of ne.tags){let qn=w("span","card-tag",`#${Hn}`);qn.title=Hn,dn.append(qn)}Be.append(dn)}let Bt=j?.dataset.thread===ne.id?j:null,jt=Bt??w("div","thread-item"),Rn=Bt?.querySelector(".sidebar-replies"),Yo=Rn?.querySelector(".reply-composer");if(Bt)for(let dn of[...Bt.children])dn!==Rn&&dn.remove();jt.dataset.thread=ne.id;let ha=Oe(ne.resolved?"Reopen comment":"Resolve comment",()=>kx(ne),"icon card-resolve","check");ha.disabled=!Qm(),Wm(ha),jt.insertBefore(Be,Rn??null),jt.insertBefore(ha,Rn??null),ne.snapshot?.image&&jt.insertBefore(Eu(0,ne),Rn??null),jt.insertBefore(yt,Rn??null),hx(jt,ne);{let dn=Rn??w("div","sidebar-replies");if(Yo)for(let un of[...dn.children])un!==Yo&&un.remove();dn.id=`replies-${ne.id}`,dn.setAttribute("role","group"),dn.setAttribute("aria-label",`Replies to ${we.author.name}`);let Hn=ne.comments.length===1?"Reply":`${ne.comments.length-1} ${ne.comments.length===2?"reply":"replies"}`,qn=Oe(Hn,()=>{Dc.has(ne.id)?Dc.delete(ne.id):Dc.add(ne.id),hr()},"card-reply-toggle");qn.replaceChildren(bt("comment"),w("span","",Hn),bt("chevron")),qn.removeAttribute("title"),qn.setAttribute("aria-controls",dn.id);let hr=()=>{let un=Dc.has(ne.id);dn.hidden=!un,qn.setAttribute("aria-expanded",String(un)),qn.setAttribute("aria-label",`${un?"Hide":"Show"} ${Hn}`),un&&requestAnimationFrame(()=>dn.querySelector("textarea")?.dispatchEvent(new Event("palette-sync-reply")))};hr();for(let un of ne.comments.slice(1)){let ba=w("div","sidebar-reply"),aM=w("div","row reply-meta");aM.append(yr(un.author),w("span","author",un.author.name),w("small","",Pc(un.createdAt))),ba.append(aM,w("p","",un.body)),dn.insertBefore(ba,Yo??null)}Yo||dn.append(Ax(ne)),jt.insertBefore(qn,Rn??null),Rn||jt.append(dn),jt.onkeydown=un=>{un.key!=="Escape"||!Dc.has(ne.id)||(un.preventDefault(),un.stopPropagation(),Dc.delete(ne.id),hr(),qn.focus({preventScroll:!0}))}}zA.set(ne,jt),Te.append(Bt?ee:jt)}if(!Te.childElementCount){let ne=w("div","empty");if(me&&ne.setAttribute("role","status"),ne.append(bt("comment"),w("strong","",ce?Ve?"Private project":"Sign in required":De==="Offline"&&_e?_e.title:me?"Loading comments\u2026":ve?"No matching comments":ct==="resolved"?"Nothing resolved yet":"No comments yet")),ce)ne.append(w("p","",ce)),q.user?.verified||ne.append(Oe("Sign in",ma,"secondary"));else if(De==="Offline"&&_e){ne.append(w("p","",_e.detail));let we=w("div","empty-actions");_e.kind==="site"&&we.append(Oe("Turn on comments",()=>{let He=new URL("setup",e.endpoint.replace(/\/?$/,"/"));He.searchParams.set("workspace",e.project),He.searchParams.set("site",location.origin),window.open(He,"_blank","noopener")},"primary"),Oe("Copy link",()=>{navigator.clipboard.writeText(location.origin).then(()=>Dn("Link copied")).catch(()=>Dn(location.origin))},"secondary")),_e.kind!=="site"&&we.append(Oe("Try again",Km,"secondary")),ne.append(we)}else ae&&!ve&&ct!=="resolved"&&ne.append(Oe("Add a comment",()=>{Mr(window.innerWidth,window.innerHeight)&&wn(!1),Ac(!0)},"secondary"));Te.append(ne),Te.dataset.empty=""}if($.length&&De==="Offline"&&Te.prepend(Oe("Saved comments \xB7 Try again",Km,"secondary")),f&&j&&ee.parentNode===Te){for(let ne of[...f.children])ne!==j&&ne.remove();for(let ne of[...Te.children]){if(ne===ee)break;f.insertBefore(ne,j)}ee.remove(),f.append(...Te.childNodes),f.setAttribute("aria-busy",String(me)),Ue.length>40?f.dataset.long="":delete f.dataset.long,Te=f}else f?f.replaceWith(Te):re.append(Te);if(pj(!!Te.querySelector(".empty [aria-label='Add a comment']")),requestAnimationFrame(wx),Te.scrollTop=k,Te.style.setProperty("--palette-scrollbar",`${Te.offsetWidth-Te.clientWidth}px`),nt){let ne=0,we=Te.getBoundingClientRect();for(let He of Te.querySelectorAll("[data-thread]")){let Be=He.getBoundingClientRect();if(Be.bottom<we.top||Be.top>we.bottom)continue;let Qe=qe.get(He.dataset.thread),Nt=Qe===void 0?8:Qe-Be.top;Math.abs(Nt)>.5&&He.animate([{opacity:Qe===void 0?0:1,transform:`translateY(${Math.max(-40,Math.min(40,Nt))}px)`},{opacity:1,transform:"translateY(0)"}],{duration:250,delay:Qe===void 0?Math.min(ne++,5)*40:0,easing:"cubic-bezier(0.22, 1, 0.36, 1)",fill:"backwards"})}Te.querySelector("[data-thread]")||Te.animate([{opacity:0},{opacity:1}],{duration:150})}if(se){let ne=re.querySelector('input[type="search"]');ne.focus(),ge!==null&&ne.setSelectionRange(ge,ge)}}function $A(f){let k=w("div","row");return k.append(yr(f.author),w("span","author",f.author.name),w("small","",Pc(f.createdAt))),k.title=f.author.verified?"Verified":"Guest",k}function NA(f,k){return q.user?.id!==f.author.id||f.body==="[Comment deleted]"?[]:[{label:"Edit",icon:"edit",onSelect:()=>{Ri=f.id,ku=f.body,gr()}},{label:"Delete",icon:"trash",destructive:!0,onSelect:()=>{let M=nx(k.anchor);Dn("Delete this comment?",{label:"Delete",run:()=>{let j=R;k.comments.length===1&&(R=null),Ot(()=>vt(Ke(k.id,ee=>{let se=ee.comments.filter(ge=>ge.id!==Me.id(f.id));return se.length?{...ee,comments:se}:null}),async ee=>{await q.request(`threads/${ee(k.id)}/comments/${ee(f.id)}`,"DELETE")},()=>{R||(R=j)})),Dn("Comment deleted",void 0,M)}})}}]}function mj(f,k){let M=w("article","message");if(M.dataset.comment=f.id,M.append($A(f)),Ri===f.id){let re=w("div","message-content message-edit"),be=w("textarea","message-editor");be.value=ku,be.rows=1,be.maxLength=4e3,be.setAttribute("aria-label","Edit comment"),be.dataset.focusKey="edit";let je=()=>{be.style.height="auto",be.style.height=`${be.scrollHeight+be.offsetHeight-be.clientHeight}px`};be.addEventListener("input",()=>{ku=be.value,je()}),requestAnimationFrame(()=>be.isConnected&&je());let We=()=>{Ri=null,gr()},rt=Oe("Save changes",()=>{let Ie=ku;Ri=null,Ot(()=>vt(Ke(k.id,an=>({...an,comments:an.comments.map(nt=>nt.id===Me.id(f.id)?{...nt,body:Ie,editedAt:Date.now()}:nt)})),async an=>{await q.request(`threads/${an(k.id)}/comments/${an(f.id)}`,"PATCH",{body:Ie})},()=>{Ri||(Ri=Me.id(f.id),ku=Ie)}))},"primary");rt.disabled=Q;let tt=po(),Ft=(Ie,an,nt,qe=!1)=>(Ie.replaceChildren(an,Wd({key:nt,ctrl:qe&&!tt,meta:qe&&tt},tt)),Ie.removeAttribute("title"),Ie);be.addEventListener("keydown",Ie=>{Ie.isComposing||(Ie.key==="Escape"?(Ie.preventDefault(),Ie.stopPropagation(),We()):Ie.key==="Enter"&&(tt?Ie.metaKey:Ie.ctrlKey)&&!rt.disabled&&(Ie.preventDefault(),rt.click()))});let qt=w("div","edit-actions");return qt.append(Ft(Oe("Cancel",We,"secondary"),"Cancel","Escape"),Ft(rt,"Save","Enter",!0)),re.append(be,qt),M.append(re),M}let j=w("div","message-content"),ee=mo.test(f.body),se=w(ee?"div":"p","message-text");if(ik(se,f.body),ee){let re=({renderDesignComment:be})=>be(se,f.body,{key:f.id,resolve:je=>Le(k)?_0(k.anchor)(je):null,note:ik,sourceHref:og,design:e.design,tip:Wm,onSwitch:()=>pi(),blocked:()=>Le(k)?ie&&it.querySelector(".design-inspector__compare")?.hidden===!1?"Send or reset your Design mode edits first":void 0:"Proposed on another page"});ol?re(ol):wu().then(re)}if(j.append(se),f.body!=="[Comment deleted]"){let re=Oe("Add reaction",()=>{Su?.(!0),Su=sD(it,re,je=>gj(f,k,je,!(q.user&&f.reactions[je]?.includes(q.user.id))),Object.entries(f.reactions).find(([,je])=>q.user&&je.includes(q.user.id))?.[0],`palette:emoji:${e.project}:${q.user?.id??"guest"}`,e.emojiDataSource)},"icon message-reaction","smile"),be=Object.entries(f.reactions).filter(([,je])=>je.length>0);if(re.dataset.reactions=JSON.stringify(be),be.length){re.replaceChildren(),re.classList.add("has-reactions");for(let[je,We]of be)re.append(w("span","reaction-value",`${je}${We.length>1?` ${We.length}`:""}`));re.setAttribute("aria-label","Change reactions")}re.setAttribute("aria-haspopup","menu"),re.setAttribute("aria-expanded","false"),j.append(re)}M.append(j);let ge=w("div","actions");if(q.user?.id===f.author.id&&f.body!=="[Comment deleted]"){let re=Kf("Message actions",NA(f,k));k.comments[0]?.id!==f.id&&M.firstElementChild?.append(re)}return f.editedAt&&ge.append(w("small","","Edited")),ge.childElementCount&&M.append(ge),M}function gj(f,k,M,j){if(!q.user&&(!Et||!da.trim())){ma();return}Ot(async()=>{q.user||await q.guest(da);let ee=q.user;await vt(Ke(k.id,se=>({...se,comments:se.comments.map(ge=>{if(ge.id!==Me.id(f.id))return ge;let re=Object.fromEntries(Object.entries(ge.reactions).map(([be,je])=>[be,je.filter(We=>We!==ee.id)]));return j&&(re[M]=[...re[M]??[],ee.id]),{...ge,reactions:re}})})),async se=>{await q.request(`threads/${se(k.id)}/comments/${se(f.id)}/reactions`,"POST",{emoji:M,active:j})}),j&&M6(`palette:emoji:${e.project}:${ee.id}`,M)})}async function Sx(f="github"){let k=window.open("about:blank","branch-comments-signin","popup,width=600,height=720");if(!k)throw new Error("Allow popups to sign in.");try{let M=await q.request(`auth/${f}/start`,"POST",{}),j=new URL(M.url).origin,ee=se=>{if(se.origin!==j||se.source!==k||se.data?.type!=="branch-comments:auth")return;let{token:ge,user:re}=se.data;typeof ge!="string"||!re?.id||!re?.name||re.verified!==!0||(q.save({token:ge,user:re}),sl(),Ye=null,window.removeEventListener("message",ee),clearTimeout(H0),k.close(),C=!!e.onboarding,$t(),!e.onboarding&&(Tu?Ot(VA):(Ot(fr),Dn(`Signed in as ${re.name}`))))};window.addEventListener("message",ee,{signal:Y.signal}),H0=window.setTimeout(()=>{window.removeEventListener("message",ee)},6e5),k.location.href=M.url}catch(M){throw k.close(),M}}let Tx;function jA(f,k,M,j){let ee=w("div","tag-slot");ee.hidden=!!j&&!f.length;let se=({tagEditor:ge})=>ge(ee,{tags:f,suggestions:[...new Set($.flatMap(re=>re.tags??[]))].sort(),onAdd:k,onRemove:M,trigger:j});if(Tx)se(Tx);else{let ge=!1;j&&(j.onclick=()=>{ge=!0}),Promise.resolve().then(()=>(mO(),fO)).then(re=>{Tx=re,se(re),ge&&j?.isConnected&&j.click(),pi()})}return ee}function PA(f,k){if(!q.user){ma();return}Ot(async()=>{let{tags:M}=await q.request(`threads/${Me.id(f.id)}`,"PATCH",k);$=$.map(j=>j.id===f.id?{...j,tags:M}:j),ui()})}function Ax(f){let k=w("form",`composer ${f?"reply-composer":"new-comment-composer"}`),M=w("textarea"),j=f?"":lr;if(M.placeholder=f?"Reply\u2026":j?"Add a note\u2026":"Add a comment\u2026",M.rows=1,M.maxLength=4e3,M.required=!!f||!lr,M.value=f?ci.get(f.id)??"":Do,M.setAttribute("aria-label",f?"Reply":"Comment"),M.dataset.focusKey="body",f){let re=_m.get(f.id);re&&M.setSelectionRange(...re);let be=()=>_m.set(f.id,[M.selectionStart,M.selectionEnd,M.selectionDirection]);M.addEventListener("select",be),M.addEventListener("keyup",be),M.addEventListener("pointerup",be)}let ee=()=>{M.style.height="auto",M.style.height=`${Math.min(128,Math.max(f?34:28,M.scrollHeight))}px`,M.style.overflowY=M.scrollHeight>128?"auto":"hidden",pi()};M.addEventListener("input",ee),M.addEventListener("input",()=>{f?ci.set(f.id,M.value):Do=M.value}),M.addEventListener("keydown",re=>{re.key==="Enter"&&!re.shiftKey&&!re.isComposing&&(re.preventDefault(),k.requestSubmit())});let se=Oe(f?"Send reply":"Post comment",()=>{},"send","arrow");if(se.type="submit",se.disabled=Q,f)q.user&&k.append(yr(q.user)),k.append(M,se);else{let re=w("div","draft-body");q.user&&re.append(yr(q.user)),re.append(M,se),c&&re.append(jA(_r,be=>_r=[..._r,be],be=>_r=_r.filter(je=>je!==be))),k.append(re)}M.addEventListener("input",()=>{se.disabled=Q||!M.value.trim()&&!j}),se.disabled||=!M.value.trim()&&!j,M.addEventListener("palette-sync-reply",()=>{if(!f||!M.isConnected||it.activeElement===M&&ci.has(f.id))return;M.value=ci.get(f.id)??"";let re=_m.get(f.id);re&&M.setSelectionRange(...re),se.disabled=Q||!M.value.trim(),M.closest(".sidebar-replies")?.hidden||ee()});let ge=!f&&P&&!D0.has(P)&&z2(P);if(ge&&k.append(Eu(3,{anchor:P,page:"",id:""},ge)),j){let re=w("div","draft-proposal");re.textContent=j;let be=P?_0(P):()=>null;wu().then(({renderDraftProposal:je})=>{if(!re.isConnected||lr!==j)return;let We=P;return Promise.resolve(je(re,j,be,{design:e.design,sourceHref:og,tip:Wm,onUpdate(rt){P===We&&lr&&(lr=rt)}})).then(pi)}),k.prepend(re)}return k.addEventListener("submit",re=>{if(re.preventDefault(),!(!M.value.trim()&&!j||Q)){if(!q.user){Tu=()=>BA(f),ma();return}Ot(()=>BA(f))}}),requestAnimationFrame(()=>{M.isConnected&&ee()}),k}async function BA(f){if(e.onboarding)throw new Error("Open your connected website to leave a comment.");if(!q.user)throw new Error("Enter your name to leave a comment.");let k=Date.now(),M={id:`pending-${crypto.randomUUID()}`,body:f?ci.get(f.id)??"":[Do.trim(),lr].filter(Boolean).join(`
|
|
3022
3022
|
|