commerce-kit 0.40.0 → 0.42.0
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 +29 -0
- package/dist/api-types.d.ts +13 -40
- package/dist/browser.js +3 -3
- package/dist/browser.js.map +1 -1
- package/dist/feedback-toolbar.js +3 -3
- package/dist/feedback-toolbar.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -71,6 +71,35 @@ const { data, meta } = await commerce.orderBrowse({
|
|
|
71
71
|
const order = await commerce.orderGet({ id: 'order_789' });
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
+
## Events
|
|
75
|
+
|
|
76
|
+
An event is a product flagged as an event (with a date, location, and capacity) plus a single
|
|
77
|
+
non-shippable ticket variant. Requires the store's **Events tool** to be enabled.
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
// List events (with live ticketsSold counts)
|
|
81
|
+
const { data, total } = await commerce.eventBrowse({ limit: 10, offset: 0 });
|
|
82
|
+
|
|
83
|
+
// Get one event by id or slug
|
|
84
|
+
const { event } = await commerce.eventGet({ idOrSlug: 'summer-fest' });
|
|
85
|
+
|
|
86
|
+
// Create an event (ticket price is a decimal string)
|
|
87
|
+
const { event } = await commerce.eventCreate({
|
|
88
|
+
name: 'Summer Fest',
|
|
89
|
+
price: '29.99',
|
|
90
|
+
startsAt: '2026-07-01T18:00:00Z',
|
|
91
|
+
location: 'Berlin',
|
|
92
|
+
capacity: 500,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
// Update event metadata (partial; send null to clear a field).
|
|
96
|
+
// Does not change the ticket price/variants — use the products API for those.
|
|
97
|
+
await commerce.eventUpdate({ idOrSlug: 'summer-fest' }, { capacity: 600, status: 'published' });
|
|
98
|
+
|
|
99
|
+
// Attendee rollup (buyers and ticket quantities, from paid orders)
|
|
100
|
+
const { attendees, totalTickets } = await commerce.eventAttendeesBrowse({ idOrSlug: 'summer-fest' });
|
|
101
|
+
```
|
|
102
|
+
|
|
74
103
|
## Raw API Requests
|
|
75
104
|
|
|
76
105
|
For endpoints not yet implemented in the SDK, use the `request()` method:
|
package/dist/api-types.d.ts
CHANGED
|
@@ -3042,9 +3042,7 @@ type APIProductGetByIdResult = ({
|
|
|
3042
3042
|
}) & {
|
|
3043
3043
|
lang?: string;
|
|
3044
3044
|
});
|
|
3045
|
-
type APIProductGetByIdParams =
|
|
3046
|
-
idOrSlug: string;
|
|
3047
|
-
};
|
|
3045
|
+
type APIProductGetByIdParams = any;
|
|
3048
3046
|
type APIProductGetByIdQueryParams = {
|
|
3049
3047
|
lang?: string;
|
|
3050
3048
|
currency?: string;
|
|
@@ -6062,9 +6060,7 @@ type APIOrderGetByIdResult = {
|
|
|
6062
6060
|
}[] | null;
|
|
6063
6061
|
};
|
|
6064
6062
|
};
|
|
6065
|
-
type APIOrderGetByIdParams =
|
|
6066
|
-
id: string;
|
|
6067
|
-
};
|
|
6063
|
+
type APIOrderGetByIdParams = any;
|
|
6068
6064
|
type APICategoriesBrowseResult = Omit<{
|
|
6069
6065
|
data: {
|
|
6070
6066
|
id: string;
|
|
@@ -6344,9 +6340,7 @@ type APICategoryGetByIdResult = ({
|
|
|
6344
6340
|
}) & {
|
|
6345
6341
|
lang?: string;
|
|
6346
6342
|
};
|
|
6347
|
-
type APICategoryGetByIdParams =
|
|
6348
|
-
idOrSlug: string;
|
|
6349
|
-
};
|
|
6343
|
+
type APICategoryGetByIdParams = any;
|
|
6350
6344
|
type APICategoryGetByIdQueryParams = {
|
|
6351
6345
|
lang?: string;
|
|
6352
6346
|
};
|
|
@@ -6509,9 +6503,7 @@ type APICollectionGetByIdResult = ({
|
|
|
6509
6503
|
}) & {
|
|
6510
6504
|
lang?: string;
|
|
6511
6505
|
};
|
|
6512
|
-
type APICollectionGetByIdParams =
|
|
6513
|
-
idOrSlug: string;
|
|
6514
|
-
};
|
|
6506
|
+
type APICollectionGetByIdParams = any;
|
|
6515
6507
|
type APICollectionGetByIdQueryParams = {
|
|
6516
6508
|
lang?: string;
|
|
6517
6509
|
};
|
|
@@ -6921,9 +6913,7 @@ type APIPostGetByIdResult = {
|
|
|
6921
6913
|
filters: unknown;
|
|
6922
6914
|
publishedAt: string | null;
|
|
6923
6915
|
} | null | undefined;
|
|
6924
|
-
type APIPostGetByIdParams =
|
|
6925
|
-
idOrSlug: string;
|
|
6926
|
-
};
|
|
6916
|
+
type APIPostGetByIdParams = any;
|
|
6927
6917
|
type APIPostCreateBody = {
|
|
6928
6918
|
title: string;
|
|
6929
6919
|
slug: string;
|
|
@@ -7043,9 +7033,7 @@ type APIBlogCategoryGetByIdResult = {
|
|
|
7043
7033
|
canonical?: string | null | undefined;
|
|
7044
7034
|
} | null;
|
|
7045
7035
|
};
|
|
7046
|
-
type APIBlogCategoryGetByIdParams =
|
|
7047
|
-
idOrSlug: string;
|
|
7048
|
-
};
|
|
7036
|
+
type APIBlogCategoryGetByIdParams = any;
|
|
7049
7037
|
type APIPostCommentsBrowseResult = {
|
|
7050
7038
|
data: Array<{
|
|
7051
7039
|
id: string;
|
|
@@ -7112,9 +7100,7 @@ type APICustomerGetByIdResult = {
|
|
|
7112
7100
|
}>;
|
|
7113
7101
|
createdAt: string;
|
|
7114
7102
|
};
|
|
7115
|
-
type APICustomerGetByIdParams =
|
|
7116
|
-
id: string;
|
|
7117
|
-
};
|
|
7103
|
+
type APICustomerGetByIdParams = any;
|
|
7118
7104
|
type APICustomerUpdateBody = {
|
|
7119
7105
|
name?: string;
|
|
7120
7106
|
phone?: string;
|
|
@@ -7210,9 +7196,7 @@ type APIVariantGetByIdResult = {
|
|
|
7210
7196
|
images: string[];
|
|
7211
7197
|
};
|
|
7212
7198
|
};
|
|
7213
|
-
type APIVariantGetByIdParams =
|
|
7214
|
-
idOrSku: string;
|
|
7215
|
-
};
|
|
7199
|
+
type APIVariantGetByIdParams = any;
|
|
7216
7200
|
type APIVariantGetByIdQueryParams = {
|
|
7217
7201
|
currency?: string;
|
|
7218
7202
|
};
|
|
@@ -7520,9 +7504,7 @@ type APIInstaviewImagesBrowseResult = {
|
|
|
7520
7504
|
}>;
|
|
7521
7505
|
nextCursor: string | null;
|
|
7522
7506
|
};
|
|
7523
|
-
type APIInstaviewImagesBrowseParams =
|
|
7524
|
-
handle: string;
|
|
7525
|
-
};
|
|
7507
|
+
type APIInstaviewImagesBrowseParams = any;
|
|
7526
7508
|
type APIInstaviewImagesBrowseQueryParams = {
|
|
7527
7509
|
limit?: number;
|
|
7528
7510
|
cursor?: string;
|
|
@@ -7552,9 +7534,7 @@ type APIEventsBrowseResult = {
|
|
|
7552
7534
|
}[];
|
|
7553
7535
|
total: number;
|
|
7554
7536
|
};
|
|
7555
|
-
type APIEventGetByIdParams =
|
|
7556
|
-
idOrSlug: string;
|
|
7557
|
-
};
|
|
7537
|
+
type APIEventGetByIdParams = any;
|
|
7558
7538
|
type APIEventGetByIdResult = {
|
|
7559
7539
|
event: {
|
|
7560
7540
|
id: string;
|
|
@@ -7690,9 +7670,7 @@ type APIBrandsBrowseQueryParams = {
|
|
|
7690
7670
|
active?: boolean | undefined;
|
|
7691
7671
|
lang?: string | undefined;
|
|
7692
7672
|
};
|
|
7693
|
-
type APIBrandGetByIdParams =
|
|
7694
|
-
idOrSlug: string;
|
|
7695
|
-
};
|
|
7673
|
+
type APIBrandGetByIdParams = any;
|
|
7696
7674
|
type APIBrandGetByIdResult = {
|
|
7697
7675
|
id: string;
|
|
7698
7676
|
name: string;
|
|
@@ -7850,9 +7828,7 @@ type APIBrandAssignProductsResult = {
|
|
|
7850
7828
|
assigned: number;
|
|
7851
7829
|
notFound: string[];
|
|
7852
7830
|
};
|
|
7853
|
-
type APIOrderRefundsParams =
|
|
7854
|
-
id: string;
|
|
7855
|
-
};
|
|
7831
|
+
type APIOrderRefundsParams = any;
|
|
7856
7832
|
type APIOrderRefundsBrowseResult = {
|
|
7857
7833
|
data: {
|
|
7858
7834
|
createdAt: string;
|
|
@@ -7888,10 +7864,7 @@ type APIOrderRefundsBrowseQueryParams = {
|
|
|
7888
7864
|
offset?: number | undefined;
|
|
7889
7865
|
limit?: number | undefined;
|
|
7890
7866
|
};
|
|
7891
|
-
type APIOrderRefundGetParams =
|
|
7892
|
-
id: string;
|
|
7893
|
-
refundId: string;
|
|
7894
|
-
};
|
|
7867
|
+
type APIOrderRefundGetParams = any;
|
|
7895
7868
|
type APIOrderRefundGetResult = {
|
|
7896
7869
|
id: string;
|
|
7897
7870
|
createdAt: string;
|
package/dist/browser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{useEffect as
|
|
2
|
-
`)},te=e=>{let n=e;for(;n;){if(n instanceof HTMLElement&&n.dataset.ynsFeedbackUi==="true")return!0;n=n.parentElement}return!1},ve=new Set(["HTML","HEAD","SCRIPT","STYLE","NOSCRIPT"]),we=1e4,xe=3e4,Ce=e=>typeof e=="object"&&e!==null&&"viewer"in e&&(e.viewer==="anonymous"||e.viewer==="non-member"||e.viewer==="member"),ke=e=>{let n=new Date(e),t=n.getTime()-Date.now(),o=n.toLocaleString(void 0,{weekday:"short",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});if(t<=0)return`Any moment now (estimated by ${o})`;let r=Math.ceil(t/6e4);if(r<60)return`~${r} minutes (by ${o})`;let s=Math.round(t/36e5);if(s<24)return`~${s} ${s===1?"hour":"hours"} (by ${o})`;let c=Math.round(t/864e5);return`~${c} ${c===1?"day":"days"} (by ${o})`};async function ne(e,n){try{let t=await fetch(`${e}/api/auth/sign-out`,{method:"POST",credentials:"include"});t.ok||console.warn("[YNS Feedback Toolbar] sign-out responded non-OK",t.status)}catch(t){console.warn("[YNS Feedback Toolbar] sign-out fetch failed",t)}n()}function Ee(){let[e,n]=P(null),[t,o]=P(!0),[r,s]=P(!1),[c,a]=P(null),[u,g]=P(null),[w,C]=P(!1),[L,y]=P(!1),m=z(null),f=z(()=>{});I(()=>{if(m.current=be(),!m.current){o(!1);return}let d=!1,p=null,S=0,b=null,$=null,k=()=>{b!==null&&(window.clearTimeout(b),b=null)},E=(F,M)=>{d||M<S||($=F?.viewer??null,n(F),o(!1))},T=()=>{if(d)return;let F=$==="member"?we:xe;b=window.setTimeout(()=>{D()},F)},D=async()=>{if(d)return;p?.abort();let F=new AbortController;p=F;let M=++S;try{let N=await fetch(`${m.current}/api/feedback-comments?host=${encodeURIComponent(window.location.host)}`,{credentials:"include",signal:F.signal});if(d||M<S)return;if(N.status===404||!N.ok){E(null,M),T();return}let Z=await N.json();if(d||M<S)return;if(!Ce(Z)){E(null,M),T();return}E(Z,M),T()}catch(N){if(N?.name==="AbortError"||d)return;E(null,M),T()}},J=()=>{d||(k(),D())};f.current=J;let Q=()=>{document.hidden?(p?.abort(),k()):J()};return document.addEventListener("visibilitychange",Q),D(),()=>{d=!0,document.removeEventListener("visibilitychange",Q),p?.abort(),k(),f.current=()=>{}}},[]);let l=e?.viewer==="member"?e:null;I(()=>{!l||l.canComment||(s(!1),a(null),C(!1),g(null))},[l]),I(()=>{if(r)return document.body.style.cursor="crosshair",()=>{document.body.style.cursor=""}},[r]),I(()=>{if(!r)return;let d=document.createElement("div");d.dataset.ynsFeedbackUi="true",d.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483644","border: 2px dashed #10b981","background: rgba(16, 185, 129, 0.08)","border-radius: 3px","display: none","transition: top 0.05s, left 0.05s, width 0.05s, height 0.05s"].join(";");let p=document.createElement("div");p.dataset.ynsFeedbackUi="true",p.textContent="Click to comment",p.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483645","background: #059669","color: #fff","font-size: 11px","font-family: ui-sans-serif, system-ui, sans-serif","padding: 3px 8px","border-radius: 4px","white-space: nowrap","display: none","box-shadow: 0 2px 6px rgba(0,0,0,0.15)"].join(";"),document.documentElement.appendChild(d),document.documentElement.appendChild(p);let S=null,b=k=>{let E=document.elementFromPoint(k.clientX,k.clientY);if(!E||ve.has(E.tagName)||te(E)){d.style.display="none",p.style.display="none",S=null;return}S=E,requestAnimationFrame(()=>{if(S!==E)return;let T=E.getBoundingClientRect();d.style.top=`${T.top}px`,d.style.left=`${T.left}px`,d.style.width=`${T.width}px`,d.style.height=`${T.height}px`,d.style.display="block",p.style.left=`${k.clientX+14}px`,p.style.top=`${k.clientY+14}px`,p.style.display="block"})},$=()=>{d.style.display="none",p.style.display="none",S=null};return document.addEventListener("mousemove",b,!0),document.addEventListener("mouseleave",$),()=>{document.removeEventListener("mousemove",b,!0),document.removeEventListener("mouseleave",$),d.remove(),p.remove()}},[r]),I(()=>{if(!r)return;let d=p=>{let S=p.target;if(!(S instanceof Element)||te(S))return;p.preventDefault(),p.stopPropagation();let b=S.getBoundingClientRect(),$=b.width>0?(p.clientX-b.left)/b.width:.5,k=b.height>0?(p.clientY-b.top)/b.height:.5;a({cssSelector:ye(S),pagePath:window.location.pathname,surroundingHtml:Se(S),rect:{top:b.top+window.scrollY,left:b.left+window.scrollX,width:b.width,height:b.height},clickX:p.clientX+window.scrollX,clickY:p.clientY+window.scrollY,offsetXRatio:Math.min(1,Math.max(0,$)),offsetYRatio:Math.min(1,Math.max(0,k))}),s(!1)};return document.addEventListener("click",d,{capture:!0}),()=>document.removeEventListener("click",d,{capture:!0})},[r]);let x=()=>{f.current()},R=async(d,p)=>{!m.current||!l||!c||!(await fetch(`${m.current}/api/feedback-comments`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedbackSessionId:l.feedbackSessionId,content:d,pagePath:c.pagePath,cssSelector:c.cssSelector,surroundingHtml:c.surroundingHtml,offsetXRatio:c.offsetXRatio,offsetYRatio:c.offsetYRatio,...p.length>0?{attachments:p}:{}})})).ok||(a(null),s(!0),x())},O=async(d,p,S)=>{!m.current||!(await fetch(`${m.current}/api/feedback-comments/${d}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:p,attachments:S})})).ok||(g(null),x())},Y=async d=>{!m.current||!(await fetch(`${m.current}/api/feedback-comments/${d}`,{method:"DELETE",credentials:"include"})).ok||x()},X=async()=>{if(!(!m.current||!l)&&window.confirm(nt(l))){y(!0);try{let d=await fetch(`${m.current}/api/feedback-sessions/${l.feedbackSessionId}/finalize`,{method:"POST",credentials:"include"});if(!d.ok)return;let S=(await d.json().catch(()=>null))?.status??"processing";n(b=>b?.viewer==="member"?{...b,canComment:!1,sessionStatus:S}:b)}finally{y(!1)}}},v=d=>{if(d.pagePath!==window.location.pathname){window.location.assign(d.pagePath);return}let p=null;try{p=document.querySelector(d.cssSelector)}catch{p=null}p&&(p.scrollIntoView({behavior:"smooth",block:"center"}),g(d.id))};if(t||!e)return null;if(e.viewer==="anonymous")return i(it,{loginUrl:e.loginUrl});if(e.viewer==="non-member")return i(rt,{user:e.user,onSignOut:()=>{m.current&&ne(m.current,()=>f.current())}});if(!l)return null;if(!l.canComment)return l.sessionStatus!=="processing"&&l.sessionStatus!=="in_review"?null:i("div",{"data-yns-feedback-ui":"true",children:i(Pe,{progress:l.progress,eta:l.eta,status:l.sessionStatus})});let A=l.comments.filter(d=>d.pagePath===window.location.pathname&&d.status!=="done");return h("div",{"data-yns-feedback-ui":"true",children:[A.map((d,p)=>i(Le,{pin:d,number:p+1,editing:u===d.id,feedbackSessionId:l.feedbackSessionId,apiBase:m.current,onStartEdit:()=>g(d.id),onCancelEdit:()=>g(null),onSave:(S,b)=>O(d.id,S,b),onRemove:()=>Y(d.id)},d.id)),c&&i($e,{pending:c,feedbackSessionId:l.feedbackSessionId,apiBase:m.current,onCancel:()=>{a(null),s(!0)},onSave:(d,p)=>R(d,p)}),w&&i(Te,{comments:l.comments,currentPath:window.location.pathname,onClose:()=>C(!1),onSelect:v}),h("div",{style:q,children:[i("button",{type:"button",onClick:()=>s(d=>!d),style:r?ze:_,children:r?"Cancel":"Add comment"}),i("button",{type:"button",onClick:()=>C(d=>!d),style:Be,children:w?"Hide list":`List (${l.comments.length})`}),i("button",{type:"button",onClick:X,disabled:L,style:_e,children:L?"Finalizing\u2026":"Finalize"}),i("span",{style:G,children:r?"Click any element to comment":`${A.length} on this page`}),i(ot,{authors:l.authors,viewerId:l.user.id}),i(st,{user:l.user,onSignOut:()=>{m.current&&ne(m.current,()=>f.current())}})]})]})}function Pe({progress:e,eta:n,status:t}){let[,o]=P(0);I(()=>{let a=window.setInterval(()=>o(u=>u+1),6e4);return()=>window.clearInterval(a)},[]);let r=ke(n);return h("div",{style:Ct,children:[i("style",{children:Re}),h("div",{style:kt,children:[i(Ae,{}),i("span",{style:Et,children:"Submitted"}),i("strong",{style:{fontSize:13},children:t==="in_review"?"Feedback under review":"Applying feedback"})]}),h("div",{style:Pt,children:[i("span",{children:"Review progress"}),i("span",{style:{opacity:.7},children:e.label})]}),i("div",{style:Rt,children:i("div",{style:{...At,width:`${e.fillPct}%`}})}),h("p",{style:Lt,children:["Estimated delivery: ",i("span",{style:{fontWeight:600},children:r})]})]})}var Re="@keyframes yns-feedback-spin { to { transform: rotate(360deg); } }";function Ae({size:e=14}){return i("span",{"aria-hidden":!0,style:{display:"inline-block",width:e,height:e,border:"2px solid rgba(16, 185, 129, 0.25)",borderTopColor:"#10b981",borderRadius:999,animation:"yns-feedback-spin 0.9s linear infinite"}})}function Le({pin:e,number:n,editing:t,feedbackSessionId:o,apiBase:r,onStartEdit:s,onCancelEdit:c,onSave:a,onRemove:u}){let g=Ne(e.cssSelector,e.offsetXRatio,e.offsetYRatio);if(!g)return null;let w=e.canMutate!==!1;return h("div",{style:{position:"absolute",top:g.top,left:g.left,zIndex:2147483600,pointerEvents:"auto"},children:[i("button",{type:"button",onClick:s,style:re,title:e.content,children:n}),e.author&&i("span",{style:Ye,title:e.author.name||e.author.email,children:i(B,{user:e.author,size:16})}),t&&(w?i(ie,{initial:e.content,initialAttachments:e.attachments,feedbackSessionId:o,apiBase:r,onCancel:c,onSave:a,onRemove:u}):i(Ie,{comment:e,onClose:c}))]})}function Ie({comment:e,onClose:n}){return h("div",{style:se,children:[e.author&&h("div",{style:Xe,children:[i(B,{user:e.author,size:20}),i("span",{style:De,children:e.author.name||e.author.email})]}),i("div",{style:We,children:e.content}),e.attachments.length>0&&i("div",{style:le,children:e.attachments.map(t=>i("a",{href:t.url,target:"_blank",rel:"noreferrer",style:de,children:i("img",{src:t.url,alt:"",style:ce})},t.url))}),h("div",{style:ae,children:[i("span",{style:{flex:1,fontSize:12,color:"#6b7280"},children:"Only the author can edit"}),i("button",{type:"button",onClick:n,style:K,children:"Close"})]})]})}function $e({pending:e,feedbackSessionId:n,apiBase:t,onCancel:o,onSave:r}){return h(pe,{children:[i("div",{style:{position:"absolute",top:e.rect.top+e.rect.height*e.offsetYRatio-12,left:e.rect.left+e.rect.width*e.offsetXRatio-12,zIndex:2147483600,pointerEvents:"none"},children:i("div",{style:re,children:"\u2022"})}),i("div",{style:{position:"absolute",top:e.clickY+10,left:e.clickX+10,zIndex:2147483647},children:i(ie,{initial:"",initialAttachments:[],feedbackSessionId:n,apiBase:t,onCancel:o,onSave:r})})]})}function Te({comments:e,currentPath:n,onClose:t,onSelect:o}){let r=new Map;for(let c of e){let a=r.get(c.pagePath)??[];a.push(c),r.set(c.pagePath,a)}let s=Array.from(r.keys()).sort((c,a)=>c===n?-1:a===n?1:c.localeCompare(a));return h("div",{style:mt,children:[h("div",{style:ft,children:[h("strong",{style:{fontSize:14},children:["Comments (",e.length,")"]}),i("button",{type:"button",onClick:t,style:K,children:"Close"})]}),i("div",{style:gt,children:e.length===0?i("div",{style:bt,children:"No comments yet. Click \u201CAdd comment\u201D to leave one."}):s.map(c=>h("div",{style:{marginBottom:12},children:[i("div",{style:yt,children:c===n?`${c} \xB7 current`:c}),(r.get(c)??[]).map((a,u)=>h("button",{type:"button",onClick:()=>o(a),style:ht,disabled:a.status==="done"&&!1,children:[i("span",{style:St,children:u+1}),h("span",{style:vt,children:[a.author&&i("span",{style:wt,children:a.author.name||a.author.email}),a.content.length>140?`${a.content.slice(0,140)}\u2026`:a.content]}),a.status==="done"&&i("span",{style:xt,children:"done"})]},a.id))]},c))})]})}var V=5,Me=5*1024*1024,Fe=e=>new Promise(n=>{let t=URL.createObjectURL(e),o=new window.Image;o.onload=()=>{URL.revokeObjectURL(t),n({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=()=>{URL.revokeObjectURL(t),n(null)},o.src=t});function ie({initial:e,initialAttachments:n,feedbackSessionId:t,apiBase:o,onCancel:r,onSave:s,onRemove:c}){let[a,u]=P(e),[g,w]=P(n),[C,L]=P(!1),[y,m]=P(!1),[f,l]=P(null),x=z(null),R=z(null);I(()=>{let v=x.current;if(!v)return;v.focus();let A=v.value.length;v.setSelectionRange(A,A)},[]);let O=async v=>{v.preventDefault();let A=a.trim();if(A){L(!0);try{await s(A,g)}finally{L(!1)}}},Y=async v=>{if(!v||v.length===0||!o)return;l(null);let A=V-g.length;if(A<=0){l(`Max ${V} images per comment`);return}let d=Array.from(v).slice(0,A);for(let p of d){if(!p.type.startsWith("image/")){l(`"${p.name}" is not an image`);return}if(p.size>Me){l(`"${p.name}" exceeds 5 MB`);return}}m(!0);try{let p=await Promise.all(d.map(Fe)),S=new FormData;d.forEach((k,E)=>{S.append("file",k),S.append("width",p[E]?.width?String(p[E]?.width):""),S.append("height",p[E]?.height?String(p[E]?.height):"")});let b=await fetch(`${o}/api/feedback-comments/uploads?feedbackSessionId=${encodeURIComponent(t)}`,{method:"POST",credentials:"include",body:S});if(!b.ok){let k=await b.json().catch(()=>null);l(k?.error??"Upload failed");return}let $=await b.json();w(k=>[...k,...$.uploads])}catch{l("Upload failed")}finally{m(!1),R.current&&(R.current.value="")}},X=v=>{w(A=>A.filter(d=>d.url!==v))};return h("form",{onSubmit:O,style:se,children:[i("textarea",{ref:x,value:a,onChange:v=>u(v.target.value),placeholder:"Leave a comment\u2026",style:He,rows:3}),g.length>0&&i("div",{style:le,children:g.map(v=>h("div",{style:de,children:[i("img",{src:v.url,alt:"",style:ce}),i("button",{type:"button",onClick:()=>X(v.url),style:Ge,disabled:C||y,"aria-label":"Remove attachment",children:"\xD7"})]},v.url))}),f&&i("div",{style:Ke,children:f}),i("input",{ref:R,type:"file",accept:"image/*",multiple:!0,onChange:v=>void Y(v.target.files),style:{display:"none"}}),h("div",{style:ae,children:[c&&i("button",{type:"button",onClick:()=>c(),style:qe,disabled:C,children:"Delete"}),i("button",{type:"button",onClick:()=>R.current?.click(),style:Je,disabled:C||y||g.length>=V,"aria-label":y?"Uploading\u2026":"Attach image",title:y?"Uploading\u2026":"Attach image",children:y?i(Ze,{}):i(Qe,{})}),i("div",{style:{flex:1}}),i("button",{type:"button",onClick:r,style:K,disabled:C,children:"Cancel"}),i("button",{type:"submit",style:Ve,disabled:C||y||!a.trim(),children:C?"Saving\u2026":"Save"})]})]})}function Ne(e,n,t){let[o,r]=P(null);return I(()=>{let s=()=>{let a=null;try{a=document.querySelector(e)}catch{a=null}if(!a){r(null);return}let u=a.getBoundingClientRect();r({top:u.top+window.scrollY+u.height*t-12,left:u.left+window.scrollX+u.width*n-12})};s();let c=new ResizeObserver(s);try{let a=document.querySelector(e);a&&c.observe(a)}catch{}return window.addEventListener("scroll",s,!0),window.addEventListener("resize",s),()=>{c.disconnect(),window.removeEventListener("scroll",s,!0),window.removeEventListener("resize",s)}},[e,n,t]),o}var q={position:"fixed",bottom:16,left:"50%",transform:"translateX(-50%)",zIndex:2147483646,display:"flex",alignItems:"center",gap:8,padding:"8px 12px",background:"rgba(17, 17, 17, 0.92)",color:"white",borderRadius:999,boxShadow:"0 8px 24px rgba(0,0,0,0.25)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,pointerEvents:"auto"},_={border:"none",background:"white",color:"#111",padding:"6px 12px",borderRadius:999,cursor:"pointer",fontWeight:600,fontSize:13},ze={..._,background:"#ef4444",color:"white"},Be={border:"1px solid rgba(255,255,255,0.4)",background:"transparent",color:"white",padding:"6px 12px",borderRadius:999,cursor:"pointer",fontWeight:500,fontSize:13},_e={border:"none",background:"#10b981",color:"white",padding:"6px 12px",borderRadius:999,cursor:"pointer",fontWeight:600,fontSize:13},G={opacity:.8,fontSize:12},je={display:"inline-flex",alignItems:"center",paddingLeft:4},Ue={marginLeft:-6,display:"inline-flex",borderRadius:999,boxShadow:"0 0 0 2px rgba(17, 17, 17, 0.92)"},Oe={marginLeft:-2,padding:"0 6px",height:18,minWidth:18,borderRadius:999,background:"rgba(255,255,255,0.18)",color:"white",fontSize:10,fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center"},re={width:24,height:24,borderRadius:999,background:"#10b981",color:"white",border:"2px solid white",cursor:"pointer",fontSize:12,fontWeight:700,boxShadow:"0 2px 6px rgba(0,0,0,0.3)",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0},Ye={position:"absolute",bottom:-6,right:-6,width:20,height:20,borderRadius:999,border:"2px solid white",background:"#111",display:"inline-flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 3px rgba(0,0,0,0.3)",pointerEvents:"none"},Xe={display:"flex",alignItems:"center",gap:8},De={fontSize:13,fontWeight:600,color:"#111"},We={fontSize:14,color:"#111",whiteSpace:"pre-wrap",wordBreak:"break-word"},se={background:"white",border:"1px solid #e5e7eb",borderRadius:8,padding:12,width:280,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',display:"flex",flexDirection:"column",gap:8,color:"#111"},He={width:"100%",border:"1px solid #d1d5db",borderRadius:6,padding:8,fontSize:14,resize:"vertical",fontFamily:"inherit",color:"#111",background:"white",boxSizing:"border-box"},ae={display:"flex",alignItems:"center",gap:6},j={border:"1px solid transparent",borderRadius:6,padding:"6px 10px",fontSize:13,cursor:"pointer",fontWeight:500},Ve={...j,background:"#111",color:"white"},K={...j,background:"transparent",color:"#374151",borderColor:"#d1d5db"},qe={...j,background:"transparent",color:"#b91c1c",borderColor:"#fecaca"},le={display:"flex",flexWrap:"wrap",gap:6},de={position:"relative",width:56,height:56,borderRadius:6,overflow:"hidden",border:"1px solid #e5e7eb",background:"#f9fafb"},ce={width:"100%",height:"100%",objectFit:"cover",display:"block"},Ge={position:"absolute",top:2,right:2,width:18,height:18,borderRadius:999,border:"none",background:"rgba(17, 17, 17, 0.85)",color:"white",fontSize:13,lineHeight:"16px",cursor:"pointer",padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center"},Ke={color:"#b91c1c",fontSize:12,margin:0},Je={...j,background:"transparent",color:"#374151",borderColor:"#d1d5db",width:30,height:30,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0};function Qe(){return h("svg",{role:"img","aria-label":"Attach image",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("title",{children:"Attach image"}),i("path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 17.93 8.83l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"})]})}function Ze(){return h(pe,{children:[i("style",{children:"@keyframes yns-attach-spin { to { transform: rotate(360deg); } }"}),i("span",{"aria-hidden":!0,style:{display:"inline-block",width:12,height:12,border:"2px solid rgba(55, 65, 81, 0.25)",borderTopColor:"#374151",borderRadius:999,animation:"yns-attach-spin 0.9s linear infinite"}})]})}var et=480;function ue(){let[e,n]=P(!1);return I(()=>{let t=window.matchMedia(`(max-width: ${et}px)`),o=()=>n(t.matches);return o(),t.addEventListener("change",o),()=>t.removeEventListener("change",o)},[]),e}var tt=e=>{let n=e.name?.trim();return n?n.split(/\s+/).filter(Boolean).slice(0,2).map(o=>o[0]?.toUpperCase()??"").join(""):e.email[0]?.toUpperCase()??"?"};function B({user:e,size:n=22}){return e.image?i("img",{src:e.image,alt:"",width:n,height:n,style:{width:n,height:n,borderRadius:999,objectFit:"cover",display:"block",flexShrink:0}}):i("span",{"aria-hidden":!0,style:{width:n,height:n,borderRadius:999,background:"rgba(255,255,255,0.18)",color:"white",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:Math.max(10,Math.round(n*.45)),fontWeight:600,flexShrink:0},children:tt(e)})}function nt(e){let n=e.authors??[],t=e.anonymousCount??0,o=e.commentTotal;if(o===0)return"Finalize this feedback session with zero comments? It will be canceled instead of submitted.";if(n.length===0&&t===0)return`Finalize this feedback session with ${o} comment${o===1?"":"s"}? You won't be able to add more.`;let r=n.length+(t>0?1:0),s=n.map(a=>a.name||a.email);t>0&&s.push(`${t} anonymous`);let c=s.length===1?s[0]:`${s.slice(0,-1).join(", ")} and ${s.at(-1)}`;return`Submit ${o} comment${o===1?"":"s"} from ${r} reviewer${r===1?"":"s"} (${c})?
|
|
1
|
+
import{useEffect as $,useRef as B,useState as C}from"react";import{createRoot as we}from"react-dom/client";import{Fragment as he,jsx as i,jsxs as b}from"react/jsx-runtime";var V="yns-feedback-toolbar-root",ne={todo:"Open",in_progress:"In progress",done:"Resolved",wont_fix:"Won't fix"},xe=()=>{if(typeof window>"u")return null;let e=(process.env.NEXT_PUBLIC_YNS_API_BASE??"").trim();if(e)return e.replace(/\/$/,"");let n=window.location.hostname,t=window.location.protocol;return n.endsWith(".yns.store")?`${t}//yns.store`:n.endsWith(".yns.cx")?`${t}//yns.cx`:window.location.origin},Ce=e=>{if(e.id)return`#${CSS.escape(e.id)}`;let n=[],t=e;for(;t&&t.nodeType===Node.ELEMENT_NODE&&n.length<6;){let o=t.tagName.toLowerCase(),s=t.getAttribute("class");if(s){let l=s.split(/\s+/).filter(Boolean).slice(0,2).map(c=>`.${CSS.escape(c)}`).join("");o+=l}let a=t.parentElement,d=t.tagName;if(a){let l=Array.from(a.children).filter(c=>c.tagName===d);if(l.length>1){let c=l.indexOf(t)+1;o+=`:nth-of-type(${c})`}}n.unshift(o),t=a}return n.join(" > ")},ke=["id","class","data-testid","aria-label","role","name","href","src"],K=e=>{let n=[];for(let t of ke){let o=e.getAttribute(t);if(!o)continue;let s=o.length>80?`${o.slice(0,80)}\u2026`:o;n.push(` ${t}="${s.replace(/"/g,""")}"`)}return n.join("")},oe=e=>{let n=(e.textContent??"").replace(/\s+/g," ").trim();return n?n.length>100?`${n.slice(0,100)}\u2026`:n:""},Ee=e=>{let n=[],t=e;for(;t&&t!==document.documentElement&&n.length<5;){let c=t.parentElement;if(!c)break;n.unshift(c),t=c}let o=[],s=0;for(let c of n){let m=" ".repeat(s);o.push(`${m}<${c.tagName.toLowerCase()}${K(c)}>`),s++}let a=" ".repeat(s),d=e.tagName.toLowerCase(),l=oe(e);if(o.push(`${a}<${d}${K(e)}>${l?`${l}</${d}>`:""} \u2190 TARGET`),!l){let c=" ".repeat(s+1),m=Array.from(e.children).slice(0,6);for(let v of m){let k=oe(v);o.push(`${c}<${v.tagName.toLowerCase()}${K(v)}>${k?`${k}</${v.tagName.toLowerCase()}>`:""}`)}e.children.length>6&&o.push(`${c}\u2026 (${e.children.length-6} more children)`),o.push(`${a}</${d}>`)}for(let c=n.length-1;c>=0;c--){let m=" ".repeat(c),v=n[c];v&&o.push(`${m}</${v.tagName.toLowerCase()}>`)}return o.join(`
|
|
2
|
+
`)},ie=e=>{let n=e;for(;n;){if(n instanceof HTMLElement&&n.dataset.ynsFeedbackUi==="true")return!0;n=n.parentElement}return!1},Pe=new Set(["HTML","HEAD","SCRIPT","STYLE","NOSCRIPT"]),Re=1e4,Ae=3e4,Le=e=>typeof e=="object"&&e!==null&&"viewer"in e&&(e.viewer==="anonymous"||e.viewer==="non-member"||e.viewer==="member"),Ie=e=>{let n=new Date(e),t=n.getTime()-Date.now(),o=n.toLocaleString(void 0,{weekday:"short",month:"short",day:"numeric",hour:"numeric",minute:"2-digit"});if(t<=0)return`Any moment now (estimated by ${o})`;let s=Math.ceil(t/6e4);if(s<60)return`~${s} minutes (by ${o})`;let a=Math.round(t/36e5);if(a<24)return`~${a} ${a===1?"hour":"hours"} (by ${o})`;let d=Math.round(t/864e5);return`~${d} ${d===1?"day":"days"} (by ${o})`};async function se(e,n){try{let t=await fetch(`${e}/api/auth/sign-out`,{method:"POST",credentials:"include"});t.ok||console.warn("[YNS Feedback Toolbar] sign-out responded non-OK",t.status)}catch(t){console.warn("[YNS Feedback Toolbar] sign-out fetch failed",t)}n()}function $e(){let[e,n]=C(null),[t,o]=C(!0),[s,a]=C(!1),[d,l]=C(null),[c,m]=C(null),[v,k]=C(!1),[E,w]=C(!1),u=B(null),g=B(()=>{});$(()=>{if(u.current=xe(),!u.current){o(!1);return}let r=!1,f=null,y=0,S=null,A=null,P=()=>{S!==null&&(window.clearTimeout(S),S=null)},I=(N,F)=>{r||F<y||(A=N?.viewer??null,n(N),o(!1))},T=()=>{if(r)return;let N=A==="member"?Re:Ae;S=window.setTimeout(()=>{H()},N)},H=async()=>{if(r)return;f?.abort();let N=new AbortController;f=N;let F=++y;try{let _=await fetch(`${u.current}/api/feedback-comments?host=${encodeURIComponent(window.location.host)}`,{credentials:"include",signal:N.signal});if(r||F<y)return;if(_.status===404||!_.ok){I(null,F),T();return}let te=await _.json();if(r||F<y)return;if(!Le(te)){I(null,F),T();return}I(te,F),T()}catch(_){if(_?.name==="AbortError"||r)return;I(null,F),T()}},Z=()=>{r||(P(),H())};g.current=Z;let ee=()=>{document.hidden?(f?.abort(),P()):Z()};return document.addEventListener("visibilitychange",ee),H(),()=>{r=!0,document.removeEventListener("visibilitychange",ee),f?.abort(),P(),g.current=()=>{}}},[]);let p=e?.viewer==="member"?e:null;$(()=>{!p||p.canComment||(a(!1),l(null),k(!1),m(null))},[p]),$(()=>{if(s)return document.body.style.cursor="crosshair",()=>{document.body.style.cursor=""}},[s]),$(()=>{if(!s)return;let r=document.createElement("div");r.dataset.ynsFeedbackUi="true",r.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483644","border: 2px dashed #10b981","background: rgba(16, 185, 129, 0.08)","border-radius: 3px","display: none","transition: top 0.05s, left 0.05s, width 0.05s, height 0.05s"].join(";");let f=document.createElement("div");f.dataset.ynsFeedbackUi="true",f.textContent="Click to comment",f.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483645","background: #059669","color: #fff","font-size: 11px","font-family: ui-sans-serif, system-ui, sans-serif","padding: 3px 8px","border-radius: 4px","white-space: nowrap","display: none","box-shadow: 0 2px 6px rgba(0,0,0,0.15)"].join(";"),document.documentElement.appendChild(r),document.documentElement.appendChild(f);let y=null,S=P=>{let I=document.elementFromPoint(P.clientX,P.clientY);if(!I||Pe.has(I.tagName)||ie(I)){r.style.display="none",f.style.display="none",y=null;return}y=I,requestAnimationFrame(()=>{if(y!==I)return;let T=I.getBoundingClientRect();r.style.top=`${T.top}px`,r.style.left=`${T.left}px`,r.style.width=`${T.width}px`,r.style.height=`${T.height}px`,r.style.display="block",f.style.left=`${P.clientX+14}px`,f.style.top=`${P.clientY+14}px`,f.style.display="block"})},A=()=>{r.style.display="none",f.style.display="none",y=null};return document.addEventListener("mousemove",S,!0),document.addEventListener("mouseleave",A),()=>{document.removeEventListener("mousemove",S,!0),document.removeEventListener("mouseleave",A),r.remove(),f.remove()}},[s]),$(()=>{if(!s)return;let r=f=>{let y=f.target;if(!(y instanceof Element)||ie(y))return;f.preventDefault(),f.stopPropagation();let S=y.getBoundingClientRect(),A=S.width>0?(f.clientX-S.left)/S.width:.5,P=S.height>0?(f.clientY-S.top)/S.height:.5;l({cssSelector:Ce(y),pagePath:window.location.pathname,surroundingHtml:Ee(y),rect:{top:S.top+window.scrollY,left:S.left+window.scrollX,width:S.width,height:S.height},clickX:f.clientX+window.scrollX,clickY:f.clientY+window.scrollY,offsetXRatio:Math.min(1,Math.max(0,A)),offsetYRatio:Math.min(1,Math.max(0,P))}),a(!1)};return document.addEventListener("click",r,{capture:!0}),()=>document.removeEventListener("click",r,{capture:!0})},[s]);let h=()=>{g.current()},R=async(r,f)=>{!u.current||!p||!d||!(await fetch(`${u.current}/api/feedback-comments`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({feedbackSessionId:p.feedbackSessionId,content:r,pagePath:d.pagePath,cssSelector:d.cssSelector,surroundingHtml:d.surroundingHtml,offsetXRatio:d.offsetXRatio,offsetYRatio:d.offsetYRatio,...f.length>0?{attachments:f}:{}})})).ok||(l(null),a(!0),h())},z=async(r,f,y)=>{!u.current||!(await fetch(`${u.current}/api/feedback-comments/${r}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:f,attachments:y})})).ok||(m(null),h())},W=async r=>{!u.current||!(await fetch(`${u.current}/api/feedback-comments/${r}`,{method:"DELETE",credentials:"include"})).ok||h()},Y=async(r,f)=>{!u.current||!(await fetch(`${u.current}/api/feedback-comments/${r}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:f})})).ok||h()},X=async(r,f)=>{!u.current||!(await fetch(`${u.current}/api/feedback-comments/${r}/replies`,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:f})})).ok||h()},x=async()=>{if(!(!u.current||!p)&&window.confirm(rt(p))){w(!0);try{let r=await fetch(`${u.current}/api/feedback-sessions/${p.feedbackSessionId}/finalize`,{method:"POST",credentials:"include"});if(!r.ok)return;let y=(await r.json().catch(()=>null))?.status??"processing";n(S=>S?.viewer==="member"?{...S,canComment:!1,sessionStatus:y}:S)}finally{w(!1)}}},L=r=>{if(r.pagePath!==window.location.pathname){window.location.assign(r.pagePath);return}let f=null;try{f=document.querySelector(r.cssSelector)}catch{f=null}f&&(f.scrollIntoView({behavior:"smooth",block:"center"}),m(r.id))};if(t||!e)return null;if(e.viewer==="anonymous")return i(lt,{loginUrl:e.loginUrl});if(e.viewer==="non-member")return i(dt,{user:e.user,onSignOut:()=>{u.current&&se(u.current,()=>g.current())}});if(!p)return null;if(!p.canComment)return p.sessionStatus!=="processing"&&p.sessionStatus!=="in_review"?null:i("div",{"data-yns-feedback-ui":"true",children:i(Te,{progress:p.progress,eta:p.eta,status:p.sessionStatus})});let M=p.comments.filter(r=>r.pagePath===window.location.pathname&&r.status!=="done"&&r.status!=="wont_fix");return b("div",{"data-yns-feedback-ui":"true",children:[M.map((r,f)=>i(Ne,{pin:r,number:f+1,editing:c===r.id,feedbackSessionId:p.feedbackSessionId,apiBase:u.current,onStartEdit:()=>m(r.id),onCancelEdit:()=>m(null),onSave:(y,S)=>z(r.id,y,S),onRemove:()=>W(r.id),onReply:y=>X(r.id,y),onStatusChange:y=>Y(r.id,y)},r.id)),d&&i(_e,{pending:d,feedbackSessionId:p.feedbackSessionId,apiBase:u.current,onCancel:()=>{l(null),a(!0)},onSave:(r,f)=>R(r,f)}),v&&i(Be,{comments:p.comments,currentPath:window.location.pathname,onClose:()=>k(!1),onSelect:L}),b("div",{style:G,children:[i("button",{type:"button",onClick:()=>a(r=>!r),style:s?De:j,children:s?"Cancel":"Add comment"}),i("button",{type:"button",onClick:()=>k(r=>!r),style:We,children:v?"Hide list":`List (${p.comments.length})`}),i("button",{type:"button",onClick:x,disabled:E,style:Ye,children:E?"Finalizing\u2026":"Finalize"}),i("span",{style:J,children:s?"Click any element to comment":`${M.length} on this page`}),i(at,{authors:p.authors,viewerId:p.user.id}),i(ct,{user:p.user,onSignOut:()=>{u.current&&se(u.current,()=>g.current())}})]})]})}function Te({progress:e,eta:n,status:t}){let[,o]=C(0);$(()=>{let l=window.setInterval(()=>o(c=>c+1),6e4);return()=>window.clearInterval(l)},[]);let s=Ie(n);return b("div",{style:Rt,children:[i("style",{children:Me}),b("div",{style:At,children:[i(Fe,{}),i("span",{style:Lt,children:"Submitted"}),i("strong",{style:{fontSize:13},children:t==="in_review"?"Feedback under review":"Applying feedback"})]}),b("div",{style:It,children:[i("span",{children:"Review progress"}),i("span",{style:{opacity:.7},children:e.label})]}),i("div",{style:$t,children:i("div",{style:{...Tt,width:`${e.fillPct}%`}})}),b("p",{style:Mt,children:["Estimated delivery: ",i("span",{style:{fontWeight:600},children:s})]})]})}var Me="@keyframes yns-feedback-spin { to { transform: rotate(360deg); } }";function Fe({size:e=14}){return i("span",{"aria-hidden":!0,style:{display:"inline-block",width:e,height:e,border:"2px solid rgba(16, 185, 129, 0.25)",borderTopColor:"#10b981",borderRadius:999,animation:"yns-feedback-spin 0.9s linear infinite"}})}function re({comment:e,onReply:n,onStatusChange:t}){let[o,s]=C(""),[a,d]=C(!1),l=e.replies??[],c=async()=>{let m=o.trim();if(!(!m||a)){d(!0);try{await n(m),s("")}finally{d(!1)}}};return b("div",{style:Ft,children:[t&&b("div",{style:Nt,children:[i("span",{style:zt,children:"Status"}),i("select",{value:e.status,onChange:m=>void t(m.target.value),style:_t,children:Object.keys(ne).map(m=>i("option",{value:m,children:ne[m]},m))})]}),l.length>0&&i("div",{style:Bt,children:l.map(m=>b("div",{style:Ot,children:[i("span",{style:jt,children:m.authorKind==="system"?"System":m.author?.name||m.author?.email||"Reviewer"}),i("span",{style:Ut,children:m.content})]},m.id))}),b("div",{style:Dt,children:[i("textarea",{value:o,onChange:m=>s(m.target.value),placeholder:"Reply\u2026",rows:2,style:ue,onKeyDown:m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),c())}}),i("button",{type:"button",onClick:()=>void c(),style:me,disabled:a||!o.trim(),children:a?"\u2026":"Reply"})]})]})}function Ne({pin:e,number:n,editing:t,feedbackSessionId:o,apiBase:s,onStartEdit:a,onCancelEdit:d,onSave:l,onRemove:c,onReply:m,onStatusChange:v}){let k=Ue(e.cssSelector,e.offsetXRatio,e.offsetYRatio);if(!k)return null;let E=e.canMutate!==!1;return b("div",{style:{position:"absolute",top:k.top,left:k.left,zIndex:2147483600,pointerEvents:"auto"},children:[i("button",{type:"button",onClick:a,style:de,title:e.content,children:n}),e.author&&i("span",{style:Ke,title:e.author.name||e.author.email,children:i(O,{user:e.author,size:16})}),t&&(E?i(le,{initial:e.content,initialAttachments:e.attachments,feedbackSessionId:o,apiBase:s,onCancel:d,onSave:l,onRemove:c,thread:i(re,{comment:e,onReply:m,onStatusChange:v})}):i(ze,{comment:e,onClose:d,thread:i(re,{comment:e,onReply:m})}))]})}function ze({comment:e,onClose:n,thread:t}){return b("div",{style:ce,children:[e.author&&b("div",{style:qe,children:[i(O,{user:e.author,size:20}),i("span",{style:Ge,children:e.author.name||e.author.email})]}),i("div",{style:Je,children:e.content}),e.attachments.length>0&&i("div",{style:fe,children:e.attachments.map(o=>i("a",{href:o.url,target:"_blank",rel:"noreferrer",style:ge,children:i("img",{src:o.url,alt:"",style:ye})},o.url))}),t,b("div",{style:pe,children:[i("span",{style:{flex:1,fontSize:12,color:"#6b7280"},children:"Only the author can edit"}),i("button",{type:"button",onClick:n,style:Q,children:"Close"})]})]})}function _e({pending:e,feedbackSessionId:n,apiBase:t,onCancel:o,onSave:s}){return b(he,{children:[i("div",{style:{position:"absolute",top:e.rect.top+e.rect.height*e.offsetYRatio-12,left:e.rect.left+e.rect.width*e.offsetXRatio-12,zIndex:2147483600,pointerEvents:"none"},children:i("div",{style:de,children:"\u2022"})}),i("div",{style:{position:"absolute",top:e.clickY+10,left:e.clickX+10,zIndex:2147483647},children:i(le,{initial:"",initialAttachments:[],feedbackSessionId:n,apiBase:t,onCancel:o,onSave:s})})]})}function Be({comments:e,currentPath:n,onClose:t,onSelect:o}){let s=new Map;for(let d of e){let l=s.get(d.pagePath)??[];l.push(d),s.set(d.pagePath,l)}let a=Array.from(s.keys()).sort((d,l)=>d===n?-1:l===n?1:d.localeCompare(l));return b("div",{style:bt,children:[b("div",{style:ht,children:[b("strong",{style:{fontSize:14},children:["Comments (",e.length,")"]}),i("button",{type:"button",onClick:t,style:Q,children:"Close"})]}),i("div",{style:St,children:e.length===0?i("div",{style:vt,children:"No comments yet. Click \u201CAdd comment\u201D to leave one."}):a.map(d=>b("div",{style:{marginBottom:12},children:[i("div",{style:wt,children:d===n?`${d} \xB7 current`:d}),(s.get(d)??[]).map((l,c)=>b("button",{type:"button",onClick:()=>o(l),style:xt,disabled:l.status==="done"&&!1,children:[i("span",{style:Ct,children:c+1}),b("span",{style:kt,children:[l.author&&i("span",{style:Et,children:l.author.name||l.author.email}),l.content.length>140?`${l.content.slice(0,140)}\u2026`:l.content]}),l.status==="done"&&i("span",{style:Pt,children:"done"})]},l.id))]},d))})]})}var q=5,Oe=5*1024*1024,je=e=>new Promise(n=>{let t=URL.createObjectURL(e),o=new window.Image;o.onload=()=>{URL.revokeObjectURL(t),n({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=()=>{URL.revokeObjectURL(t),n(null)},o.src=t});function le({initial:e,initialAttachments:n,feedbackSessionId:t,apiBase:o,onCancel:s,onSave:a,onRemove:d,thread:l}){let[c,m]=C(e),[v,k]=C(n),[E,w]=C(!1),[u,g]=C(!1),[p,h]=C(null),R=B(null),z=B(null);$(()=>{let x=R.current;if(!x)return;x.focus();let L=x.value.length;x.setSelectionRange(L,L)},[]);let W=async x=>{x.preventDefault();let L=c.trim();if(L){w(!0);try{await a(L,v)}finally{w(!1)}}},Y=async x=>{if(!x||x.length===0||!o)return;h(null);let L=q-v.length;if(L<=0){h(`Max ${q} images per comment`);return}let M=Array.from(x).slice(0,L);for(let r of M){if(!r.type.startsWith("image/")){h(`"${r.name}" is not an image`);return}if(r.size>Oe){h(`"${r.name}" exceeds 5 MB`);return}}g(!0);try{let r=await Promise.all(M.map(je)),f=new FormData;M.forEach((A,P)=>{f.append("file",A),f.append("width",r[P]?.width?String(r[P]?.width):""),f.append("height",r[P]?.height?String(r[P]?.height):"")});let y=await fetch(`${o}/api/feedback-comments/uploads?feedbackSessionId=${encodeURIComponent(t)}`,{method:"POST",credentials:"include",body:f});if(!y.ok){let A=await y.json().catch(()=>null);h(A?.error??"Upload failed");return}let S=await y.json();k(A=>[...A,...S.uploads])}catch{h("Upload failed")}finally{g(!1),z.current&&(z.current.value="")}},X=x=>{k(L=>L.filter(M=>M.url!==x))};return b("form",{onSubmit:W,style:ce,children:[i("textarea",{ref:R,value:c,onChange:x=>m(x.target.value),placeholder:"Leave a comment\u2026",style:ue,rows:3}),v.length>0&&i("div",{style:fe,children:v.map(x=>b("div",{style:ge,children:[i("img",{src:x.url,alt:"",style:ye}),i("button",{type:"button",onClick:()=>X(x.url),style:Ze,disabled:E||u,"aria-label":"Remove attachment",children:"\xD7"})]},x.url))}),p&&i("div",{style:et,children:p}),i("input",{ref:z,type:"file",accept:"image/*",multiple:!0,onChange:x=>void Y(x.target.files),style:{display:"none"}}),b("div",{style:pe,children:[d&&i("button",{type:"button",onClick:()=>d(),style:Qe,disabled:E,children:"Delete"}),i("button",{type:"button",onClick:()=>z.current?.click(),style:tt,disabled:E||u||v.length>=q,"aria-label":u?"Uploading\u2026":"Attach image",title:u?"Uploading\u2026":"Attach image",children:u?i(ot,{}):i(nt,{})}),i("div",{style:{flex:1}}),i("button",{type:"button",onClick:s,style:Q,disabled:E,children:"Cancel"}),i("button",{type:"submit",style:me,disabled:E||u||!c.trim(),children:E?"Saving\u2026":"Save"})]}),l]})}function Ue(e,n,t){let[o,s]=C(null);return $(()=>{let a=()=>{let l=null;try{l=document.querySelector(e)}catch{l=null}if(!l){s(null);return}let c=l.getBoundingClientRect();s({top:c.top+window.scrollY+c.height*t-12,left:c.left+window.scrollX+c.width*n-12})};a();let d=new ResizeObserver(a);try{let l=document.querySelector(e);l&&d.observe(l)}catch{}return window.addEventListener("scroll",a,!0),window.addEventListener("resize",a),()=>{d.disconnect(),window.removeEventListener("scroll",a,!0),window.removeEventListener("resize",a)}},[e,n,t]),o}var G={position:"fixed",bottom:16,left:"50%",transform:"translateX(-50%)",zIndex:2147483646,display:"flex",alignItems:"center",gap:8,padding:"8px 12px",background:"rgba(17, 17, 17, 0.92)",color:"white",borderRadius:999,boxShadow:"0 8px 24px rgba(0,0,0,0.25)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,pointerEvents:"auto"},j={border:"none",background:"white",color:"#111",padding:"6px 12px",borderRadius:999,cursor:"pointer",fontWeight:600,fontSize:13},De={...j,background:"#ef4444",color:"white"},We={border:"1px solid rgba(255,255,255,0.4)",background:"transparent",color:"white",padding:"6px 12px",borderRadius:999,cursor:"pointer",fontWeight:500,fontSize:13},Ye={border:"none",background:"#10b981",color:"white",padding:"6px 12px",borderRadius:999,cursor:"pointer",fontWeight:600,fontSize:13},J={opacity:.8,fontSize:12},Xe={display:"inline-flex",alignItems:"center",paddingLeft:4},He={marginLeft:-6,display:"inline-flex",borderRadius:999,boxShadow:"0 0 0 2px rgba(17, 17, 17, 0.92)"},Ve={marginLeft:-2,padding:"0 6px",height:18,minWidth:18,borderRadius:999,background:"rgba(255,255,255,0.18)",color:"white",fontSize:10,fontWeight:600,display:"inline-flex",alignItems:"center",justifyContent:"center"},de={width:24,height:24,borderRadius:999,background:"#10b981",color:"white",border:"2px solid white",cursor:"pointer",fontSize:12,fontWeight:700,boxShadow:"0 2px 6px rgba(0,0,0,0.3)",display:"inline-flex",alignItems:"center",justifyContent:"center",padding:0},Ke={position:"absolute",bottom:-6,right:-6,width:20,height:20,borderRadius:999,border:"2px solid white",background:"#111",display:"inline-flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 3px rgba(0,0,0,0.3)",pointerEvents:"none"},qe={display:"flex",alignItems:"center",gap:8},Ge={fontSize:13,fontWeight:600,color:"#111"},Je={fontSize:14,color:"#111",whiteSpace:"pre-wrap",wordBreak:"break-word"},ce={background:"white",border:"1px solid #e5e7eb",borderRadius:8,padding:12,width:280,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',display:"flex",flexDirection:"column",gap:8,color:"#111"},ue={width:"100%",border:"1px solid #d1d5db",borderRadius:6,padding:8,fontSize:14,resize:"vertical",fontFamily:"inherit",color:"#111",background:"white",boxSizing:"border-box"},pe={display:"flex",alignItems:"center",gap:6},U={border:"1px solid transparent",borderRadius:6,padding:"6px 10px",fontSize:13,cursor:"pointer",fontWeight:500},me={...U,background:"#111",color:"white"},Q={...U,background:"transparent",color:"#374151",borderColor:"#d1d5db"},Qe={...U,background:"transparent",color:"#b91c1c",borderColor:"#fecaca"},fe={display:"flex",flexWrap:"wrap",gap:6},ge={position:"relative",width:56,height:56,borderRadius:6,overflow:"hidden",border:"1px solid #e5e7eb",background:"#f9fafb"},ye={width:"100%",height:"100%",objectFit:"cover",display:"block"},Ze={position:"absolute",top:2,right:2,width:18,height:18,borderRadius:999,border:"none",background:"rgba(17, 17, 17, 0.85)",color:"white",fontSize:13,lineHeight:"16px",cursor:"pointer",padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center"},et={color:"#b91c1c",fontSize:12,margin:0},tt={...U,background:"transparent",color:"#374151",borderColor:"#d1d5db",width:30,height:30,padding:0,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0};function nt(){return b("svg",{role:"img","aria-label":"Attach image",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i("title",{children:"Attach image"}),i("path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 17.93 8.83l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"})]})}function ot(){return b(he,{children:[i("style",{children:"@keyframes yns-attach-spin { to { transform: rotate(360deg); } }"}),i("span",{"aria-hidden":!0,style:{display:"inline-block",width:12,height:12,border:"2px solid rgba(55, 65, 81, 0.25)",borderTopColor:"#374151",borderRadius:999,animation:"yns-attach-spin 0.9s linear infinite"}})]})}var it=480;function be(){let[e,n]=C(!1);return $(()=>{let t=window.matchMedia(`(max-width: ${it}px)`),o=()=>n(t.matches);return o(),t.addEventListener("change",o),()=>t.removeEventListener("change",o)},[]),e}var st=e=>{let n=e.name?.trim();return n?n.split(/\s+/).filter(Boolean).slice(0,2).map(o=>o[0]?.toUpperCase()??"").join(""):e.email[0]?.toUpperCase()??"?"};function O({user:e,size:n=22}){return e.image?i("img",{src:e.image,alt:"",width:n,height:n,style:{width:n,height:n,borderRadius:999,objectFit:"cover",display:"block",flexShrink:0}}):i("span",{"aria-hidden":!0,style:{width:n,height:n,borderRadius:999,background:"rgba(255,255,255,0.18)",color:"white",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:Math.max(10,Math.round(n*.45)),fontWeight:600,flexShrink:0},children:st(e)})}function rt(e){let n=e.authors??[],t=e.anonymousCount??0,o=e.commentTotal;if(o===0)return"Finalize this feedback session with zero comments? It will be canceled instead of submitted.";if(n.length===0&&t===0)return`Finalize this feedback session with ${o} comment${o===1?"":"s"}? You won't be able to add more.`;let s=n.length+(t>0?1:0),a=n.map(l=>l.name||l.email);t>0&&a.push(`${t} anonymous`);let d=a.length===1?a[0]:`${a.slice(0,-1).join(", ")} and ${a.at(-1)}`;return`Submit ${o} comment${o===1?"":"s"} from ${s} reviewer${s===1?"":"s"} (${d})?
|
|
3
3
|
|
|
4
|
-
This sends ALL comments \u2014 including those from other reviewers \u2014 for AI processing. You won't be able to add more comments after finalizing.`}function ot({authors:e,viewerId:n}){if(!e||e.length===0)return null;let t=e.filter(s=>s.id!==n);if(t.length===0)return null;let o=t.slice(0,3),r=t.length-o.length;return h("div",{style:je,title:`Also commenting: ${t.map(s=>`${s.name||s.email} (${s.commentCount})`).join(", ")}`,children:[o.map(s=>i("span",{style:Ue,children:i(B,{user:s,size:18})},s.id)),r>0&&h("span",{style:Oe,children:["+",r]})]})}function it({loginUrl:e}){return i("div",{"data-yns-feedback-ui":"true",children:h("div",{style:q,children:[i("span",{style:G,children:"Log in to provide feedback"}),i("button",{type:"button",onClick:()=>window.location.assign(e),style:_,children:"Log in"})]})})}function rt({user:e,onSignOut:n}){let t=ue();return i("div",{"data-yns-feedback-ui":"true",children:h("div",{style:q,children:[i(B,{user:e}),!t&&i("span",{style:at,children:e.email}),i("span",{style:G,children:"You don't have access to this store"}),i("button",{type:"button",onClick:n,style:_,children:"Sign out"})]})})}function st({user:e,onSignOut:n}){let[t,o]=P(!1),r=z(null),s=ue();I(()=>{if(!t)return;let u=g=>{r.current&&(g.target instanceof Node&&r.current.contains(g.target)||o(!1))};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[t]);let c=e.name?.trim()||e.email,a=c.length>16?`${c.slice(0,16)}\u2026`:c;return h("div",{ref:r,style:{position:"relative"},children:[h("button",{type:"button",onClick:()=>o(u=>!u),style:lt,"aria-haspopup":"menu","aria-expanded":t,title:c,children:[i(B,{user:e,size:20}),!s&&i("span",{style:dt,children:a}),i("span",{"aria-hidden":!0,style:ct,children:"\u25BE"})]}),t&&i("div",{role:"menu",style:ut,children:i("button",{type:"button",role:"menuitem",onClick:()=>{o(!1),n()},style:pt,children:"Sign out"})})]})}var at={fontSize:13,color:"white",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:200},lt={display:"inline-flex",alignItems:"center",gap:6,background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.16)",color:"white",padding:"4px 8px 4px 4px",borderRadius:999,cursor:"pointer",fontSize:12,fontWeight:500,fontFamily:"inherit"},dt={maxWidth:"16ch",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},ct={opacity:.7,fontSize:10},ut={position:"absolute",right:0,bottom:"calc(100% + 8px)",background:"white",color:"#111",border:"1px solid #e5e7eb",borderRadius:8,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",minWidth:140,padding:4,zIndex:2147483647},pt={display:"block",width:"100%",textAlign:"left",background:"transparent",border:"none",padding:"6px 10px",fontSize:13,color:"#111",cursor:"pointer",borderRadius:6},mt={position:"fixed",top:0,right:0,bottom:0,width:360,maxWidth:"92vw",background:"white",borderLeft:"1px solid #e5e7eb",boxShadow:"-12px 0 32px rgba(0,0,0,0.12)",zIndex:2147483646,display:"flex",flexDirection:"column",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',color:"#111"},ft={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid #e5e7eb"},gt={flex:1,overflow:"auto",padding:"12px 12px 24px"},bt={color:"#6b7280",fontSize:13,padding:"24px 8px",textAlign:"center"},yt={fontSize:11,textTransform:"uppercase",letterSpacing:.5,color:"#6b7280",padding:"4px 4px 6px",wordBreak:"break-all"},ht={display:"flex",alignItems:"flex-start",gap:8,width:"100%",textAlign:"left",background:"white",border:"1px solid #e5e7eb",borderRadius:6,padding:"8px 10px",cursor:"pointer",fontSize:13,marginBottom:6,color:"#111"},St={flexShrink:0,width:22,height:22,borderRadius:999,background:"#10b981",color:"white",fontWeight:700,fontSize:11,display:"inline-flex",alignItems:"center",justifyContent:"center"},vt={flex:1,whiteSpace:"pre-wrap",wordBreak:"break-word"},wt={display:"block",fontSize:11,fontWeight:600,color:"#6b7280",marginBottom:2},xt={flexShrink:0,background:"#d1fae5",color:"#065f46",fontSize:11,fontWeight:600,padding:"2px 6px",borderRadius:4,alignSelf:"center"},Ct={position:"fixed",bottom:16,left:"50%",transform:"translateX(-50%)",zIndex:2147483646,display:"flex",flexDirection:"column",gap:8,padding:"12px 16px",width:"min(420px, calc(100vw - 32px))",background:"white",border:"1px solid #e5e7eb",borderRadius:12,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',color:"#111",pointerEvents:"auto"},kt={display:"flex",alignItems:"center",gap:8},Et={background:"#d1fae5",color:"#065f46",fontSize:11,fontWeight:700,padding:"2px 8px",borderRadius:999,textTransform:"uppercase",letterSpacing:.5},Pt={display:"flex",justifyContent:"space-between",fontSize:12},Rt={width:"100%",height:6,background:"#f3f4f6",borderRadius:999,overflow:"hidden"},At={height:"100%",background:"#10b981",borderRadius:999,transition:"width 500ms"},Lt={margin:0,fontSize:12,color:"#6b7280"};function oe(){if(console.log("[YNS Feedback Toolbar] mountFeedbackToolbar() called",{isWindow:typeof window<"u",vercelEnv:process.env.NEXT_PUBLIC_VERCEL_ENV,alreadyMounted:typeof document<"u"&&!!document.getElementById(W)}),typeof window>"u")return null;if(process.env.NEXT_PUBLIC_VERCEL_ENV!=="preview")return console.log("[YNS Feedback Toolbar] gate failed \u2014 NEXT_PUBLIC_VERCEL_ENV is",process.env.NEXT_PUBLIC_VERCEL_ENV),null;if(document.getElementById(W))return null;let e=document.createElement("div");e.id=W,e.dataset.ynsFeedbackUi="true",document.body.appendChild(e);let n=ge(e);return n.render(i(Ee,{})),{unmount:()=>{n.unmount(),e.remove()}}}typeof window<"u"&&console.log("[YNS Feedback Toolbar] module evaluated",{vercelEnv:process.env.NEXT_PUBLIC_VERCEL_ENV,readyState:document.readyState,willAutoMount:process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"});typeof window<"u"&&process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{oe()}):oe());function me(){typeof window>"u"||(console.log("[YNS Sandbox Inspectors] module evaluated"),Tt(),Mt())}me();var It=new Set(["HEAD","SCRIPT","STYLE","NOSCRIPT","HTML"]);function $t(e){if(e.id)return`${e.tagName.toLowerCase()}#${CSS.escape(e.id)}`;let n=[],t=e;for(;t&&t!==document.body&&t!==document.documentElement;){let o=t.tagName.toLowerCase();if(t.id){n.unshift(`${o}#${CSS.escape(t.id)}`);break}let r=Array.from(t.classList).filter(a=>!a.startsWith("data-yns-"));r.length>0&&(o+=`.${r.map(a=>CSS.escape(a)).join(".")}`);let s=t.parentElement,c=t.tagName;if(s&&Array.from(s.children).filter(u=>u.tagName===c&&(r.length===0||r.every(g=>u.classList.contains(g)))).length>1){let u=Array.from(s.children).indexOf(t)+1;o+=`:nth-child(${u})`}n.unshift(o),t=t.parentElement}return n.join(" > ")}function fe(e,n){let t=e.getBoundingClientRect(),o=window.getComputedStyle(e),r=(e.textContent??"").trim();return{tag:e.tagName.toLowerCase(),id:e.id||void 0,classes:Array.from(e.classList).filter(s=>!s.startsWith("data-yns-")),textContent:r.length>n?`${r.slice(0,n)}\u2026`:r,cssSelector:$t(e),boundingRect:{top:t.top,left:t.left,width:t.width,height:t.height},computedStyles:{color:o.color,backgroundColor:o.backgroundColor,fontSize:o.fontSize,fontFamily:o.fontFamily,padding:o.padding,margin:o.margin}}}function U(e,n){if(!e?.tagName||It.has(e.tagName))return!0;for(let t of n)if(e.hasAttribute?.(t))return!0;return!1}function Tt(){let e=!1,n=null,t=null,o=document.createElement("div");o.setAttribute("data-yns-design-overlay","hover"),o.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483646","border: 2px solid #3b82f6","background: rgba(59, 130, 246, 0.08)","border-radius: 3px","display: none","transition: top 0.05s, left 0.05s, width 0.05s, height 0.05s"].join(";");let r=document.createElement("div");r.setAttribute("data-yns-design-overlay","label"),r.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483647","background: #3b82f6","color: #fff","font-size: 11px","font-family: ui-monospace, monospace","padding: 2px 6px","border-radius: 3px","white-space: nowrap","display: none"].join(";"),document.documentElement.appendChild(o),document.documentElement.appendChild(r);let s=document.createElement("style");s.setAttribute("data-yns-design-overlay","style"),s.textContent="[data-yns-selected] { outline: 2px solid #3b82f6 !important; outline-offset: 1px; }",document.head.appendChild(s);function c(y){let m=y.getBoundingClientRect();o.style.top=`${m.top}px`,o.style.left=`${m.left}px`,o.style.width=`${m.width}px`,o.style.height=`${m.height}px`,o.style.display="block";let f=Array.from(y.classList).filter(x=>!x.startsWith("data-yns-")),l=y.tagName.toLowerCase()+(f.length?`.${f[0]}`:"");r.textContent=l,r.style.left=`${m.left}px`,r.style.top=`${Math.max(0,m.top-22)}px`,r.style.display="block"}let a=y=>{let m=document.elementFromPoint(y.clientX,y.clientY);if(U(m,["data-yns-design-overlay"])){o.style.display="none",r.style.display="none",n=null;return}n=m,requestAnimationFrame(()=>{n===m&&e&&m&&c(m)})},u=()=>{o.style.display="none",r.style.display="none",n=null},g=y=>{if(!e||!n)return;y.preventDefault(),y.stopPropagation(),y.stopImmediatePropagation();let m=n;if(U(m,["data-yns-design-overlay"]))return;let f=fe(m,120),l=f.cssSelector;t&&t.el.removeAttribute("data-yns-selected"),t&&t.cssSelector===l?(t=null,window.parent.postMessage({type:"element-deselected",data:f},"*")):(t={el:m,cssSelector:l},m.setAttribute("data-yns-selected",""),window.parent.postMessage({type:"element-selected",data:f},"*"))},w=y=>{y.key==="Escape"&&e&&(L(),window.parent.postMessage({type:"design-mode-cleared"},"*"))};function C(){e=!0,document.addEventListener("mousemove",a,!0),document.addEventListener("mouseleave",u),document.addEventListener("click",g,!0),document.addEventListener("keydown",w,!0)}function L(){e=!1,document.removeEventListener("mousemove",a,!0),document.removeEventListener("mouseleave",u),document.removeEventListener("click",g,!0),document.removeEventListener("keydown",w,!0),o.style.display="none",r.style.display="none",n=null,t&&(t.el.removeAttribute("data-yns-selected"),t=null)}window.addEventListener("message",y=>{let m=y.data;!m||typeof m!="object"||(m.type==="design-mode-toggle"&&(m.enabled?C():(L(),window.parent.postMessage({type:"design-mode-cleared"},"*"))),m.type==="design-mode-deselect"&&t&&(t.el.removeAttribute("data-yns-selected"),t=null))})}function Mt(){let e=!1,n=null,t=[],o=document.createElement("div");o.setAttribute("data-yns-comment-overlay","hover"),o.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483644","border: 2px dashed #10b981","background: rgba(16, 185, 129, 0.06)","border-radius: 3px","display: none","transition: top 0.05s, left 0.05s, width 0.05s, height 0.05s"].join(";");let r=document.createElement("div");r.setAttribute("data-yns-comment-overlay","cursor-label"),r.textContent="Click to comment",r.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483645","background: #059669","color: #fff","font-size: 11px","font-family: ui-sans-serif, system-ui, sans-serif","padding: 3px 8px","border-radius: 4px","white-space: nowrap","display: none","box-shadow: 0 2px 6px rgba(0,0,0,0.15)"].join(";");let s=document.createElement("div");s.setAttribute("data-yns-comment-overlay","pins"),s.style.cssText="position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2147483643;",document.documentElement.appendChild(o),document.documentElement.appendChild(r),document.documentElement.appendChild(s);function c(){s.innerHTML="";for(let f of t){let l=null;try{l=document.querySelector(f.selector)}catch{l=null}if(!l)continue;let x=l.getBoundingClientRect(),R=document.createElement("div");R.style.cssText=["position: fixed",`top: ${x.top-12}px`,`left: ${x.left+x.width/2-12}px`,"width: 24px","height: 24px","border-radius: 50%","background: #059669","color: #fff","display: flex","align-items: center","justify-content: center","font-size: 12px","font-weight: 600","font-family: ui-sans-serif, system-ui, sans-serif","box-shadow: 0 2px 8px rgba(0,0,0,0.2)","pointer-events: none"].join(";"),R.textContent=String(f.number),s.appendChild(R)}}let a=f=>{let l=document.elementFromPoint(f.clientX,f.clientY);if(U(l,["data-yns-comment-overlay","data-yns-design-overlay"])){o.style.display="none",r.style.display="none",n=null;return}n=l,requestAnimationFrame(()=>{if(n===l&&e&&l){let x=l.getBoundingClientRect();o.style.top=`${x.top}px`,o.style.left=`${x.left}px`,o.style.width=`${x.width}px`,o.style.height=`${x.height}px`,o.style.display="block",r.style.left=`${f.clientX+14}px`,r.style.top=`${f.clientY+14}px`,r.style.display="block"}})},u=()=>{o.style.display="none",r.style.display="none",n=null},g=f=>{if(!e||!n)return;f.preventDefault(),f.stopPropagation(),f.stopImmediatePropagation();let l=n;if(U(l,["data-yns-comment-overlay","data-yns-design-overlay"]))return;let x=fe(l,200),R=l.getBoundingClientRect();window.parent.postMessage({type:"comment-click",data:{element:x,clickPosition:{x:f.clientX,y:f.clientY},elementRect:{top:R.top,left:R.left,width:R.width,height:R.height},pagePath:window.location.pathname}},"*")},w=f=>{f.key==="Escape"&&e&&(L(),window.parent.postMessage({type:"comment-mode-cleared"},"*"))};function C(){e=!0,document.body.style.cursor="crosshair",document.addEventListener("mousemove",a,!0),document.addEventListener("mouseleave",u),document.addEventListener("click",g,!0),document.addEventListener("keydown",w,!0)}function L(){e=!1,document.body.style.cursor="",document.removeEventListener("mousemove",a,!0),document.removeEventListener("mouseleave",u),document.removeEventListener("click",g,!0),document.removeEventListener("keydown",w,!0),o.style.display="none",r.style.display="none",n=null}let y=!1,m=()=>{y||(y=!0,requestAnimationFrame(()=>{y=!1,c()}))};window.addEventListener("scroll",m,{passive:!0}),window.addEventListener("resize",m,{passive:!0}),window.addEventListener("message",f=>{let l=f.data;!l||typeof l!="object"||(l.type==="comment-mode-toggle"&&(l.enabled?C():L()),l.type==="comment-pins-update"&&(t=l.pins??[],c()),l.type==="comment-pin-remove"&&(t=t.filter(x=>x.id!==l.pinId),c()))})}export{oe as mountFeedbackToolbar,me as startSandboxInspectors};
|
|
4
|
+
This sends ALL comments \u2014 including those from other reviewers \u2014 for AI processing. You won't be able to add more comments after finalizing.`}function at({authors:e,viewerId:n}){if(!e||e.length===0)return null;let t=e.filter(a=>a.id!==n);if(t.length===0)return null;let o=t.slice(0,3),s=t.length-o.length;return b("div",{style:Xe,title:`Also commenting: ${t.map(a=>`${a.name||a.email} (${a.commentCount})`).join(", ")}`,children:[o.map(a=>i("span",{style:He,children:i(O,{user:a,size:18})},a.id)),s>0&&b("span",{style:Ve,children:["+",s]})]})}function lt({loginUrl:e}){return i("div",{"data-yns-feedback-ui":"true",children:b("div",{style:G,children:[i("span",{style:J,children:"Log in to provide feedback"}),i("button",{type:"button",onClick:()=>window.location.assign(e),style:j,children:"Log in"})]})})}function dt({user:e,onSignOut:n}){let t=be();return i("div",{"data-yns-feedback-ui":"true",children:b("div",{style:G,children:[i(O,{user:e}),!t&&i("span",{style:ut,children:e.email}),i("span",{style:J,children:"You don't have access to this store"}),i("button",{type:"button",onClick:n,style:j,children:"Sign out"})]})})}function ct({user:e,onSignOut:n}){let[t,o]=C(!1),s=B(null),a=be();$(()=>{if(!t)return;let c=m=>{s.current&&(m.target instanceof Node&&s.current.contains(m.target)||o(!1))};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[t]);let d=e.name?.trim()||e.email,l=d.length>16?`${d.slice(0,16)}\u2026`:d;return b("div",{ref:s,style:{position:"relative"},children:[b("button",{type:"button",onClick:()=>o(c=>!c),style:pt,"aria-haspopup":"menu","aria-expanded":t,title:d,children:[i(O,{user:e,size:20}),!a&&i("span",{style:mt,children:l}),i("span",{"aria-hidden":!0,style:ft,children:"\u25BE"})]}),t&&i("div",{role:"menu",style:gt,children:i("button",{type:"button",role:"menuitem",onClick:()=>{o(!1),n()},style:yt,children:"Sign out"})})]})}var ut={fontSize:13,color:"white",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:200},pt={display:"inline-flex",alignItems:"center",gap:6,background:"rgba(255,255,255,0.08)",border:"1px solid rgba(255,255,255,0.16)",color:"white",padding:"4px 8px 4px 4px",borderRadius:999,cursor:"pointer",fontSize:12,fontWeight:500,fontFamily:"inherit"},mt={maxWidth:"16ch",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},ft={opacity:.7,fontSize:10},gt={position:"absolute",right:0,bottom:"calc(100% + 8px)",background:"white",color:"#111",border:"1px solid #e5e7eb",borderRadius:8,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",minWidth:140,padding:4,zIndex:2147483647},yt={display:"block",width:"100%",textAlign:"left",background:"transparent",border:"none",padding:"6px 10px",fontSize:13,color:"#111",cursor:"pointer",borderRadius:6},bt={position:"fixed",top:0,right:0,bottom:0,width:360,maxWidth:"92vw",background:"white",borderLeft:"1px solid #e5e7eb",boxShadow:"-12px 0 32px rgba(0,0,0,0.12)",zIndex:2147483646,display:"flex",flexDirection:"column",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',color:"#111"},ht={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid #e5e7eb"},St={flex:1,overflow:"auto",padding:"12px 12px 24px"},vt={color:"#6b7280",fontSize:13,padding:"24px 8px",textAlign:"center"},wt={fontSize:11,textTransform:"uppercase",letterSpacing:.5,color:"#6b7280",padding:"4px 4px 6px",wordBreak:"break-all"},xt={display:"flex",alignItems:"flex-start",gap:8,width:"100%",textAlign:"left",background:"white",border:"1px solid #e5e7eb",borderRadius:6,padding:"8px 10px",cursor:"pointer",fontSize:13,marginBottom:6,color:"#111"},Ct={flexShrink:0,width:22,height:22,borderRadius:999,background:"#10b981",color:"white",fontWeight:700,fontSize:11,display:"inline-flex",alignItems:"center",justifyContent:"center"},kt={flex:1,whiteSpace:"pre-wrap",wordBreak:"break-word"},Et={display:"block",fontSize:11,fontWeight:600,color:"#6b7280",marginBottom:2},Pt={flexShrink:0,background:"#d1fae5",color:"#065f46",fontSize:11,fontWeight:600,padding:"2px 6px",borderRadius:4,alignSelf:"center"},Rt={position:"fixed",bottom:16,left:"50%",transform:"translateX(-50%)",zIndex:2147483646,display:"flex",flexDirection:"column",gap:8,padding:"12px 16px",width:"min(420px, calc(100vw - 32px))",background:"white",border:"1px solid #e5e7eb",borderRadius:12,boxShadow:"0 12px 32px rgba(0,0,0,0.18)",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',color:"#111",pointerEvents:"auto"},At={display:"flex",alignItems:"center",gap:8},Lt={background:"#d1fae5",color:"#065f46",fontSize:11,fontWeight:700,padding:"2px 8px",borderRadius:999,textTransform:"uppercase",letterSpacing:.5},It={display:"flex",justifyContent:"space-between",fontSize:12},$t={width:"100%",height:6,background:"#f3f4f6",borderRadius:999,overflow:"hidden"},Tt={height:"100%",background:"#10b981",borderRadius:999,transition:"width 500ms"},Mt={margin:0,fontSize:12,color:"#6b7280"},Ft={display:"flex",flexDirection:"column",gap:8,borderTop:"1px solid #e5e7eb",paddingTop:8,marginTop:2},Nt={display:"flex",alignItems:"center",gap:8},zt={fontSize:12,fontWeight:600,color:"#6b7280"},_t={flex:1,border:"1px solid #d1d5db",borderRadius:6,padding:"4px 8px",fontSize:13,color:"#111",background:"white",fontFamily:"inherit"},Bt={display:"flex",flexDirection:"column",gap:6,maxHeight:160,overflowY:"auto"},Ot={display:"flex",flexDirection:"column",gap:1,borderLeft:"2px solid #e5e7eb",paddingLeft:8},jt={fontSize:11,fontWeight:600,color:"#6b7280"},Ut={fontSize:13,color:"#111",whiteSpace:"pre-wrap",wordBreak:"break-word"},Dt={display:"flex",alignItems:"flex-end",gap:6};function ae(){if(console.log("[YNS Feedback Toolbar] mountFeedbackToolbar() called",{isWindow:typeof window<"u",vercelEnv:process.env.NEXT_PUBLIC_VERCEL_ENV,alreadyMounted:typeof document<"u"&&!!document.getElementById(V)}),typeof window>"u")return null;if(process.env.NEXT_PUBLIC_VERCEL_ENV!=="preview")return console.log("[YNS Feedback Toolbar] gate failed \u2014 NEXT_PUBLIC_VERCEL_ENV is",process.env.NEXT_PUBLIC_VERCEL_ENV),null;if(document.getElementById(V))return null;let e=document.createElement("div");e.id=V,e.dataset.ynsFeedbackUi="true",document.body.appendChild(e);let n=we(e);return n.render(i($e,{})),{unmount:()=>{n.unmount(),e.remove()}}}typeof window<"u"&&console.log("[YNS Feedback Toolbar] module evaluated",{vercelEnv:process.env.NEXT_PUBLIC_VERCEL_ENV,readyState:document.readyState,willAutoMount:process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"});typeof window<"u"&&process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{ae()}):ae());function Se(){typeof window>"u"||(console.log("[YNS Sandbox Inspectors] module evaluated"),Xt(),Ht())}Se();var Wt=new Set(["HEAD","SCRIPT","STYLE","NOSCRIPT","HTML"]);function Yt(e){if(e.id)return`${e.tagName.toLowerCase()}#${CSS.escape(e.id)}`;let n=[],t=e;for(;t&&t!==document.body&&t!==document.documentElement;){let o=t.tagName.toLowerCase();if(t.id){n.unshift(`${o}#${CSS.escape(t.id)}`);break}let s=Array.from(t.classList).filter(l=>!l.startsWith("data-yns-"));s.length>0&&(o+=`.${s.map(l=>CSS.escape(l)).join(".")}`);let a=t.parentElement,d=t.tagName;if(a&&Array.from(a.children).filter(c=>c.tagName===d&&(s.length===0||s.every(m=>c.classList.contains(m)))).length>1){let c=Array.from(a.children).indexOf(t)+1;o+=`:nth-child(${c})`}n.unshift(o),t=t.parentElement}return n.join(" > ")}function ve(e,n){let t=e.getBoundingClientRect(),o=window.getComputedStyle(e),s=(e.textContent??"").trim();return{tag:e.tagName.toLowerCase(),id:e.id||void 0,classes:Array.from(e.classList).filter(a=>!a.startsWith("data-yns-")),textContent:s.length>n?`${s.slice(0,n)}\u2026`:s,cssSelector:Yt(e),boundingRect:{top:t.top,left:t.left,width:t.width,height:t.height},computedStyles:{color:o.color,backgroundColor:o.backgroundColor,fontSize:o.fontSize,fontFamily:o.fontFamily,padding:o.padding,margin:o.margin}}}function D(e,n){if(!e?.tagName||Wt.has(e.tagName))return!0;for(let t of n)if(e.hasAttribute?.(t))return!0;return!1}function Xt(){let e=!1,n=null,t=null,o=document.createElement("div");o.setAttribute("data-yns-design-overlay","hover"),o.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483646","border: 2px solid #3b82f6","background: rgba(59, 130, 246, 0.08)","border-radius: 3px","display: none","transition: top 0.05s, left 0.05s, width 0.05s, height 0.05s"].join(";");let s=document.createElement("div");s.setAttribute("data-yns-design-overlay","label"),s.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483647","background: #3b82f6","color: #fff","font-size: 11px","font-family: ui-monospace, monospace","padding: 2px 6px","border-radius: 3px","white-space: nowrap","display: none"].join(";"),document.documentElement.appendChild(o),document.documentElement.appendChild(s);let a=document.createElement("style");a.setAttribute("data-yns-design-overlay","style"),a.textContent="[data-yns-selected] { outline: 2px solid #3b82f6 !important; outline-offset: 1px; }",document.head.appendChild(a);function d(w){let u=w.getBoundingClientRect();o.style.top=`${u.top}px`,o.style.left=`${u.left}px`,o.style.width=`${u.width}px`,o.style.height=`${u.height}px`,o.style.display="block";let g=Array.from(w.classList).filter(h=>!h.startsWith("data-yns-")),p=w.tagName.toLowerCase()+(g.length?`.${g[0]}`:"");s.textContent=p,s.style.left=`${u.left}px`,s.style.top=`${Math.max(0,u.top-22)}px`,s.style.display="block"}let l=w=>{let u=document.elementFromPoint(w.clientX,w.clientY);if(D(u,["data-yns-design-overlay"])){o.style.display="none",s.style.display="none",n=null;return}n=u,requestAnimationFrame(()=>{n===u&&e&&u&&d(u)})},c=()=>{o.style.display="none",s.style.display="none",n=null},m=w=>{if(!e||!n)return;w.preventDefault(),w.stopPropagation(),w.stopImmediatePropagation();let u=n;if(D(u,["data-yns-design-overlay"]))return;let g=ve(u,120),p=g.cssSelector;t&&t.el.removeAttribute("data-yns-selected"),t&&t.cssSelector===p?(t=null,window.parent.postMessage({type:"element-deselected",data:g},"*")):(t={el:u,cssSelector:p},u.setAttribute("data-yns-selected",""),window.parent.postMessage({type:"element-selected",data:g},"*"))},v=w=>{w.key==="Escape"&&e&&(E(),window.parent.postMessage({type:"design-mode-cleared"},"*"))};function k(){e=!0,document.addEventListener("mousemove",l,!0),document.addEventListener("mouseleave",c),document.addEventListener("click",m,!0),document.addEventListener("keydown",v,!0)}function E(){e=!1,document.removeEventListener("mousemove",l,!0),document.removeEventListener("mouseleave",c),document.removeEventListener("click",m,!0),document.removeEventListener("keydown",v,!0),o.style.display="none",s.style.display="none",n=null,t&&(t.el.removeAttribute("data-yns-selected"),t=null)}window.addEventListener("message",w=>{let u=w.data;!u||typeof u!="object"||(u.type==="design-mode-toggle"&&(u.enabled?k():(E(),window.parent.postMessage({type:"design-mode-cleared"},"*"))),u.type==="design-mode-deselect"&&t&&(t.el.removeAttribute("data-yns-selected"),t=null))})}function Ht(){let e=!1,n=null,t=[],o=document.createElement("div");o.setAttribute("data-yns-comment-overlay","hover"),o.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483644","border: 2px dashed #10b981","background: rgba(16, 185, 129, 0.06)","border-radius: 3px","display: none","transition: top 0.05s, left 0.05s, width 0.05s, height 0.05s"].join(";");let s=document.createElement("div");s.setAttribute("data-yns-comment-overlay","cursor-label"),s.textContent="Click to comment",s.style.cssText=["position: fixed","pointer-events: none","z-index: 2147483645","background: #059669","color: #fff","font-size: 11px","font-family: ui-sans-serif, system-ui, sans-serif","padding: 3px 8px","border-radius: 4px","white-space: nowrap","display: none","box-shadow: 0 2px 6px rgba(0,0,0,0.15)"].join(";");let a=document.createElement("div");a.setAttribute("data-yns-comment-overlay","pins"),a.style.cssText="position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2147483643;",document.documentElement.appendChild(o),document.documentElement.appendChild(s),document.documentElement.appendChild(a);function d(){a.innerHTML="";for(let g of t){let p=null;try{p=document.querySelector(g.selector)}catch{p=null}if(!p)continue;let h=p.getBoundingClientRect(),R=document.createElement("div");R.style.cssText=["position: fixed",`top: ${h.top-12}px`,`left: ${h.left+h.width/2-12}px`,"width: 24px","height: 24px","border-radius: 50%","background: #059669","color: #fff","display: flex","align-items: center","justify-content: center","font-size: 12px","font-weight: 600","font-family: ui-sans-serif, system-ui, sans-serif","box-shadow: 0 2px 8px rgba(0,0,0,0.2)","pointer-events: none"].join(";"),R.textContent=String(g.number),a.appendChild(R)}}let l=g=>{let p=document.elementFromPoint(g.clientX,g.clientY);if(D(p,["data-yns-comment-overlay","data-yns-design-overlay"])){o.style.display="none",s.style.display="none",n=null;return}n=p,requestAnimationFrame(()=>{if(n===p&&e&&p){let h=p.getBoundingClientRect();o.style.top=`${h.top}px`,o.style.left=`${h.left}px`,o.style.width=`${h.width}px`,o.style.height=`${h.height}px`,o.style.display="block",s.style.left=`${g.clientX+14}px`,s.style.top=`${g.clientY+14}px`,s.style.display="block"}})},c=()=>{o.style.display="none",s.style.display="none",n=null},m=g=>{if(!e||!n)return;g.preventDefault(),g.stopPropagation(),g.stopImmediatePropagation();let p=n;if(D(p,["data-yns-comment-overlay","data-yns-design-overlay"]))return;let h=ve(p,200),R=p.getBoundingClientRect();window.parent.postMessage({type:"comment-click",data:{element:h,clickPosition:{x:g.clientX,y:g.clientY},elementRect:{top:R.top,left:R.left,width:R.width,height:R.height},pagePath:window.location.pathname}},"*")},v=g=>{g.key==="Escape"&&e&&(E(),window.parent.postMessage({type:"comment-mode-cleared"},"*"))};function k(){e=!0,document.body.style.cursor="crosshair",document.addEventListener("mousemove",l,!0),document.addEventListener("mouseleave",c),document.addEventListener("click",m,!0),document.addEventListener("keydown",v,!0)}function E(){e=!1,document.body.style.cursor="",document.removeEventListener("mousemove",l,!0),document.removeEventListener("mouseleave",c),document.removeEventListener("click",m,!0),document.removeEventListener("keydown",v,!0),o.style.display="none",s.style.display="none",n=null}let w=!1,u=()=>{w||(w=!0,requestAnimationFrame(()=>{w=!1,d()}))};window.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u,{passive:!0}),window.addEventListener("message",g=>{let p=g.data;!p||typeof p!="object"||(p.type==="comment-mode-toggle"&&(p.enabled?k():E()),p.type==="comment-pins-update"&&(t=p.pins??[],d()),p.type==="comment-pin-remove"&&(t=t.filter(h=>h.id!==p.pinId),d()))})}export{ae as mountFeedbackToolbar,Se as startSandboxInspectors};
|
|
5
5
|
//# sourceMappingURL=browser.js.map
|