review-lens-react 1.0.2 → 1.0.3

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.
@@ -1,5 +1,5 @@
1
1
  import { jsx as i, jsxs as s, Fragment as ae } from "react/jsx-runtime";
2
- import { createContext as gt, useMemo as oe, useState as x, useCallback as D, useEffect as P, useContext as ft, useRef as re, useLayoutEffect as wt } from "react";
2
+ import { createContext as gt, useMemo as oe, useState as x, useCallback as W, useEffect as P, useContext as ft, useRef as re, useLayoutEffect as wt } from "react";
3
3
  const Be = [
4
4
  "https://www.googleapis.com/auth/spreadsheets",
5
5
  "https://www.googleapis.com/auth/userinfo.email"
@@ -28,7 +28,7 @@ function St(e) {
28
28
  }
29
29
  );
30
30
  if (l.status === 401) {
31
- De(c), u = void 0;
31
+ We(c), u = void 0;
32
32
  const C = await g(), f = await fetch(
33
33
  `https://sheets.googleapis.com/v4/spreadsheets/${p}${v}`,
34
34
  {
@@ -165,7 +165,7 @@ function St(e) {
165
165
  headers: { Authorization: `Bearer ${await g()}` }
166
166
  });
167
167
  if (p.status === 401) {
168
- De(c), u = void 0;
168
+ We(c), u = void 0;
169
169
  const h = await fetch(Pe, {
170
170
  headers: { Authorization: `Bearer ${await g()}` }
171
171
  });
@@ -264,8 +264,8 @@ function Ue(e) {
264
264
  width: 0,
265
265
  height: 0
266
266
  }),
267
- createdCssSnapshot: We(e.createdCssSnapshotJson),
268
- fixedCssSnapshot: e.fixedCssSnapshotJson ? We(e.fixedCssSnapshotJson) : void 0,
267
+ createdCssSnapshot: De(e.createdCssSnapshotJson),
268
+ fixedCssSnapshot: e.fixedCssSnapshotJson ? De(e.fixedCssSnapshotJson) : void 0,
269
269
  comment: e.comment,
270
270
  status: Lt(e.status),
271
271
  severity: At(e.severity),
@@ -302,7 +302,7 @@ function fe(e, t) {
302
302
  return t;
303
303
  }
304
304
  }
305
- function We(e) {
305
+ function De(e) {
306
306
  const t = fe(e, {});
307
307
  return {
308
308
  margin: t.margin ?? "",
@@ -398,7 +398,7 @@ function Bt(e, t) {
398
398
  } catch {
399
399
  }
400
400
  }
401
- function De(e) {
401
+ function We(e) {
402
402
  try {
403
403
  window.localStorage.removeItem(e);
404
404
  } catch {
@@ -457,7 +457,7 @@ function xn({ config: e, children: t }) {
457
457
  e.googleClientId,
458
458
  e.sheetName,
459
459
  e.usersSpreadsheetId
460
- ]), r = e.currentUrl ?? window.location.href, o = (e.normalizeUrl ?? Ut)(r), [c, u] = x(), [w, g] = x([]), [b, A] = x([]), L = D(async () => {
460
+ ]), r = e.currentUrl ?? window.location.href, o = (e.normalizeUrl ?? Ut)(r), [c, u] = x(), [w, g] = x([]), [b, A] = x([]), L = W(async () => {
461
461
  const f = await n.listFeedback({
462
462
  projectKey: e.projectKey,
463
463
  contentId: e.contentId,
@@ -478,7 +478,7 @@ function xn({ config: e, children: t }) {
478
478
  f = !1;
479
479
  };
480
480
  }, [n, e.projectKey, L]);
481
- const p = D(
481
+ const p = W(
482
482
  async (f) => {
483
483
  const y = await n.createFeedback(f);
484
484
  return A((N) => [y, ...N]), pe(e, n, {
@@ -488,7 +488,7 @@ function xn({ config: e, children: t }) {
488
488
  }), y;
489
489
  },
490
490
  [n, e, c == null ? void 0 : c.email]
491
- ), v = D(
491
+ ), v = W(
492
492
  async (f, y) => {
493
493
  const N = b.find((M) => M.id === f), F = await n.updateFeedback(f, y);
494
494
  return A(
@@ -496,15 +496,15 @@ function xn({ config: e, children: t }) {
496
496
  ), pe(e, n, {
497
497
  actorEmail: c == null ? void 0 : c.email,
498
498
  item: F,
499
- kind: Dt(y),
499
+ kind: Wt(y),
500
500
  previousItem: N
501
501
  }), F;
502
502
  },
503
503
  [n, e, c == null ? void 0 : c.email, b]
504
- ), h = D(
504
+ ), h = W(
505
505
  (f) => n.listMessages(f),
506
506
  [n]
507
- ), k = D(
507
+ ), k = W(
508
508
  async (f) => {
509
509
  const y = await n.createMessage(f), N = b.find((F) => F.id === f.feedbackId);
510
510
  return N && pe(e, n, {
@@ -515,7 +515,7 @@ function xn({ config: e, children: t }) {
515
515
  }), y;
516
516
  },
517
517
  [n, e, b]
518
- ), l = D(
518
+ ), l = W(
519
519
  async (f, y) => {
520
520
  const N = e.uploadAttachment ?? n.uploadAttachment;
521
521
  if (!N)
@@ -555,7 +555,7 @@ function xn({ config: e, children: t }) {
555
555
  );
556
556
  return /* @__PURE__ */ i(Ge.Provider, { value: C, children: t });
557
557
  }
558
- function Wt() {
558
+ function Dt() {
559
559
  const e = ft(Ge);
560
560
  if (!e)
561
561
  throw new Error("useReviewLens must be used inside ReviewLensProvider");
@@ -569,7 +569,7 @@ function me(e, t) {
569
569
  function qe(e) {
570
570
  return typeof e.emailNotifications == "object" ? e.emailNotifications.enabled !== !1 : !!e.emailNotifications;
571
571
  }
572
- function Dt(e) {
572
+ function Wt(e) {
573
573
  return e.status === "resolved" ? "resolved" : e.status === "fixed" || e.fixedAt || e.fixedBy ? "fixed" : e.status ? "status" : "assigneeEmail" in e ? "assigned" : "updated";
574
574
  }
575
575
  async function pe(e, t, n) {
@@ -741,28 +741,37 @@ function Qt({ className: e, title: t = "Review Lens logo" }) {
741
741
  fill: "none",
742
742
  xmlns: "http://www.w3.org/2000/svg",
743
743
  children: [
744
- /* @__PURE__ */ i("rect", { x: "4", y: "6", width: "28", height: "28", rx: "8", fill: "#171717" }),
744
+ /* @__PURE__ */ i("rect", { x: "5", y: "5", width: "30", height: "30", rx: "9", fill: "#111827" }),
745
745
  /* @__PURE__ */ i(
746
746
  "path",
747
747
  {
748
- d: "M13 15.5C14.5 13.4 17.1 12 20 12C23.9 12 27.3 14.5 28.7 18C27.3 21.5 23.9 24 20 24C17.1 24 14.5 22.6 13 20.5",
749
- stroke: "#FFFFFF",
750
- strokeWidth: "2.2",
748
+ d: "M11.5 20C14.2 15.7 17.4 13.6 20 13.6C22.6 13.6 25.8 15.7 28.5 20C25.8 24.3 22.6 26.4 20 26.4C17.4 26.4 14.2 24.3 11.5 20Z",
749
+ stroke: "#F8FAFC",
750
+ strokeWidth: "2.4",
751
751
  strokeLinecap: "round",
752
752
  strokeLinejoin: "round"
753
753
  }
754
754
  ),
755
- /* @__PURE__ */ i("circle", { cx: "20", cy: "18", r: "3.4", fill: "#F97316" }),
756
755
  /* @__PURE__ */ i(
757
756
  "path",
758
757
  {
759
- d: "M28.5 26.5L34.5 32.5",
760
- stroke: "#2563EB",
761
- strokeWidth: "4",
758
+ d: "M24.7 24.7L31.5 31.5",
759
+ stroke: "#22D3EE",
760
+ strokeWidth: "3.6",
762
761
  strokeLinecap: "round"
763
762
  }
764
763
  ),
765
- /* @__PURE__ */ i("circle", { cx: "31.8", cy: "29.8", r: "2.1", fill: "#FACC15", stroke: "#171717", strokeWidth: "1.4" })
764
+ /* @__PURE__ */ i("circle", { cx: "20", cy: "20", r: "4.6", fill: "#F8FAFC" }),
765
+ /* @__PURE__ */ i("circle", { cx: "20", cy: "20", r: "2.2", fill: "#2563EB" }),
766
+ /* @__PURE__ */ i(
767
+ "path",
768
+ {
769
+ d: "M14.2 11.6L17 11.6M11.6 14.2L11.6 17M28.4 14.2L28.4 17",
770
+ stroke: "#A7F3D0",
771
+ strokeWidth: "2",
772
+ strokeLinecap: "round"
773
+ }
774
+ )
766
775
  ]
767
776
  }
768
777
  );
@@ -817,7 +826,7 @@ function Nn({
817
826
  listMessages: h,
818
827
  createMessage: k,
819
828
  uploadAttachment: l
820
- } = Wt(), [C, f] = x(), [y, N] = x(), [F, M] = x(""), [j, tt] = x("medium"), [we, nt] = x("visual"), [ve, be] = x(""), [ye, it] = x(
829
+ } = Dt(), [C, f] = x(), [y, N] = x(), [F, M] = x(""), [j, tt] = x("medium"), [we, nt] = x("visual"), [ve, be] = x(""), [ye, it] = x(
821
830
  ((Me = c[0]) == null ? void 0 : Me.value) ?? "desktop"
822
831
  ), [S, K] = x(), [T, _] = x("review"), [rt, ke] = x(!1), [J, Se] = x("all"), [O, xe] = x("all"), [G, Ne] = x("all"), [q, Ce] = x("all"), [V, Ee] = x("all"), [at, ot] = x(!1), [st, Le] = x({}), [le, ce] = x(""), te = re(null), Ae = re(e), de = re(
823
832
  o ? new URL(window.location.href).searchParams.get("reviewLensFeedback") : null
@@ -895,7 +904,7 @@ function Nn({
895
904
  window.removeEventListener("keydown", a), window.removeEventListener("keyup", m);
896
905
  };
897
906
  });
898
- const he = D((a) => {
907
+ const he = W((a) => {
899
908
  const m = a.target instanceof Element ? a.target : null;
900
909
  if (m)
901
910
  return m.closest("[data-review-lens-ui]") ? null : m;
@@ -1759,9 +1768,9 @@ function un(e) {
1759
1768
  }
1760
1769
  function mn(e, t = {}) {
1761
1770
  const n = [];
1762
- return W("Padding", e.padding, t.spacing, n, { allowComposite: !0 }), W("Margin", e.margin, t.spacing, n, { allowComposite: !0 }), W("Font size", e.fontSize, t.fontSize, n), W("Line height", e.lineHeight, t.lineHeight, n), W("Text color", e.color, t.color, n), W("Background", e.backgroundColor, t.color, n), W("Radius", e.borderRadius, t.radius, n, { allowComposite: !0 }), n;
1771
+ return D("Padding", e.padding, t.spacing, n, { allowComposite: !0 }), D("Margin", e.margin, t.spacing, n, { allowComposite: !0 }), D("Font size", e.fontSize, t.fontSize, n), D("Line height", e.lineHeight, t.lineHeight, n), D("Text color", e.color, t.color, n), D("Background", e.backgroundColor, t.color, n), D("Radius", e.borderRadius, t.radius, n, { allowComposite: !0 }), n;
1763
1772
  }
1764
- function W(e, t, n, r, o = {}) {
1773
+ function D(e, t, n, r, o = {}) {
1765
1774
  !n || n.length === 0 || !t || pn(t, n, o) || r.push(`${e} ${t} is outside configured tokens.`);
1766
1775
  }
1767
1776
  function pn(e, t, n = {}) {
@@ -1900,5 +1909,5 @@ export {
1900
1909
  Q as buildElementTarget,
1901
1910
  St as createGoogleSheetsAdapter,
1902
1911
  Ut as normalizeReviewUrl,
1903
- Wt as useReviewLens
1912
+ Dt as useReviewLens
1904
1913
  };
@@ -1,3 +1,3 @@
1
1
  (function(L,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],n):(L=typeof globalThis<"u"?globalThis:L||self,n(L.ReviewLensReact={},L.jsxRuntime,L.React))})(this,(function(L,n,h){"use strict";const ue=["https://www.googleapis.com/auth/spreadsheets","https://www.googleapis.com/auth/userinfo.email"],et="https://www.googleapis.com/auth/gmail.send",pe="https://www.googleapis.com/oauth2/v3/userinfo",tt="https://gmail.googleapis.com/gmail/v1/users/me/messages/send",rt="review-lens-google-token";function fe(e){const t=e.feedbackSheetName??"Feedback",r=e.messagesSheetName??"Messages",s=e.usersSheetName??"Users",a=e.enableEmailNotifications?[...ue,et].join(" "):ue.join(" "),l=pt(e.googleClientId,a);let u,m;async function g(){const f=ft(l);if(f)return f.accessToken;u??(u=ut(e.googleClientId,a).then(c=>(gt(l,c),c)));const v=await u;return Date.now()>=v.expiresAt?(u=void 0,g()):v.accessToken}async function b(f,v,c){const S=await g(),o=await fetch(`https://sheets.googleapis.com/v4/spreadsheets/${f}${v}`,{...c,headers:{Authorization:`Bearer ${S}`,"Content-Type":"application/json",...c==null?void 0:c.headers}});if(o.status===401){ye(l),u=void 0;const C=await g(),w=await fetch(`https://sheets.googleapis.com/v4/spreadsheets/${f}${v}`,{...c,headers:{Authorization:`Bearer ${C}`,"Content-Type":"application/json",...c==null?void 0:c.headers}});if(!w.ok)throw new Error(`Google Sheets request failed with ${w.status}`);return w.json()}if(!o.ok)throw new Error(`Google Sheets request failed with ${o.status}`);return o.json()}async function A(f,v){return(await b(f,`/values/${encodeURIComponent(v)}`)).values??[]}return{async getCurrentUser(){if(m||(m=await x()),!m)throw new Error("Google account did not return an email address");return{email:m}},async getPermissions(f){const[{email:v},c]=await Promise.all([this.getCurrentUser(),A(e.usersSpreadsheetId,s)]),S=ne(c),o=v.toLowerCase(),C=S.find(w=>{var y;return((y=w.email)==null?void 0:y.toLowerCase())===o&&w.active!=="false"&&(!w.projectKey||w.projectKey===f)});return at((C==null?void 0:C.role)??"designer")},async listFeedback(f){return ne(await A(e.contentSpreadsheetId,t)).map(ve).filter(c=>c!==null).filter(c=>c.projectKey===f.projectKey&&c.contentId===f.contentId&&c.normalizedPath===f.normalizedPath).sort((c,S)=>S.createdAt.localeCompare(c.createdAt))},async createFeedback(f){const v=new Date().toISOString(),c={...f,id:crypto.randomUUID(),attachments:[],createdAt:v,updatedAt:v};return await b(e.contentSpreadsheetId,`/values/${encodeURIComponent(t)}:append?valueInputOption=RAW`,{method:"POST",body:JSON.stringify({values:[we(c)]})}),c},async updateFeedback(f,v){const c=await A(e.contentSpreadsheetId,t),S=c[0]??ge,o=S.indexOf("id");if(o===-1)throw new Error(`Sheet ${t} is missing an id column`);const C=c.findIndex((B,U)=>U>0&&B[o]===f);if(C<1)throw new Error(`Feedback ${f} was not found`);const w=new Date().toISOString(),y=ve(me(S,c[C]));if(!y)throw new Error(`Feedback ${f} could not be parsed before updating`);const E={...y,...v,updatedAt:w},F=we(E);return await b(e.contentSpreadsheetId,`/values/${encodeURIComponent(t)}!A${C+1}:${ht(ge.length)}${C+1}?valueInputOption=RAW`,{method:"PUT",body:JSON.stringify({values:[F]})}),E},async listMessages(f){return ne(await A(e.contentSpreadsheetId,r)).map(it).filter(c=>c!==null).filter(c=>c.feedbackId===f).sort((c,S)=>c.createdAt.localeCompare(S.createdAt))},async createMessage(f){const v={...f,id:crypto.randomUUID(),createdAt:new Date().toISOString()};return await b(e.contentSpreadsheetId,`/values/${encodeURIComponent(r)}:append?valueInputOption=RAW`,{method:"POST",body:JSON.stringify({values:[st(v)]})}),v},async sendEmail(f){if(!e.enableEmailNotifications||f.to.length===0)return;const v=await g(),c=await this.getCurrentUser(),S=await fetch(tt,{method:"POST",headers:{Authorization:`Bearer ${v}`,"Content-Type":"application/json"},body:JSON.stringify({raw:mt({from:c.email,to:f.to,subject:f.subject,text:f.text})})});if(!S.ok)throw new Error(`Gmail send request failed with ${S.status}`)}};async function x(){const f=await fetch(pe,{headers:{Authorization:`Bearer ${await g()}`}});if(f.status===401){ye(l),u=void 0;const c=await fetch(pe,{headers:{Authorization:`Bearer ${await g()}`}});if(!c.ok)throw new Error(`Google userinfo request failed with ${c.status}`);return(await c.json()).email}if(!f.ok)throw new Error(`Google userinfo request failed with ${f.status}`);return(await f.json()).email}}const ge=["id","projectKey","contentId","normalizedPath","originalUrl","selector","selectorStrategy","elementFingerprintJson","createdCssSnapshotJson","comment","status","severity","category","assigneeEmail","viewportWidth","viewportHeight","viewportPreset","screenshotUrl","screenshotThumbnailUrl","attachmentJson","authorEmail","createdAt","updatedAt","fixedCssSnapshotJson","fixedAt","fixedBy","resolvedAt","resolvedBy"],nt=["id","feedbackId","body","authorEmail","createdAt"];function we(e){return[e.id,e.projectKey,e.contentId,e.normalizedPath,e.originalUrl,e.selector,e.selectorStrategy,JSON.stringify(e.elementFingerprint),JSON.stringify(e.createdCssSnapshot),e.comment,e.status,e.severity,e.category,e.assigneeEmail??"",String(e.viewportWidth),String(e.viewportHeight),e.viewportPreset,e.screenshotUrl??"",e.screenshotThumbnailUrl??"",JSON.stringify(e.attachments),e.authorEmail,e.createdAt,e.updatedAt,e.fixedCssSnapshot?JSON.stringify(e.fixedCssSnapshot):"",e.fixedAt??"",e.fixedBy??"",e.resolvedAt??"",e.resolvedBy??""]}function st(e){return nt.map(t=>e[t])}function ne(e){const[t,...r]=e;return t?r.map(s=>me(t,s)):[]}function me(e,t){return Object.fromEntries(e.map((r,s)=>[r,t[s]??""]))}function ve(e){return e.id?{id:e.id,projectKey:e.projectKey,contentId:e.contentId,normalizedPath:e.normalizedPath,originalUrl:e.originalUrl,selector:e.selector,selectorStrategy:e.selectorStrategy==="stable-attribute"?"stable-attribute":"css-path",elementFingerprint:se(e.elementFingerprintJson,{tagName:"",width:0,height:0}),createdCssSnapshot:be(e.createdCssSnapshotJson),fixedCssSnapshot:e.fixedCssSnapshotJson?be(e.fixedCssSnapshotJson):void 0,comment:e.comment,status:ot(e.status),severity:lt(e.severity),category:dt(e.category),assigneeEmail:e.assigneeEmail||void 0,viewportWidth:Number(e.viewportWidth)||0,viewportHeight:Number(e.viewportHeight)||0,viewportPreset:ct(e.viewportPreset),screenshotUrl:e.screenshotUrl||void 0,screenshotThumbnailUrl:e.screenshotThumbnailUrl||void 0,attachments:se(e.attachmentJson,[]),authorEmail:e.authorEmail,createdAt:e.createdAt,updatedAt:e.updatedAt,fixedAt:e.fixedAt||void 0,fixedBy:e.fixedBy||void 0,resolvedAt:e.resolvedAt||void 0,resolvedBy:e.resolvedBy||void 0}:null}function it(e){return!e.id||!e.feedbackId?null:{id:e.id,feedbackId:e.feedbackId,body:e.body,authorEmail:e.authorEmail,createdAt:e.createdAt}}function se(e,t){try{return e?JSON.parse(e):t}catch{return t}}function be(e){const t=se(e,{});return{margin:t.margin??"",marginTop:t.marginTop??"",marginRight:t.marginRight??"",marginBottom:t.marginBottom??"",marginLeft:t.marginLeft??"",padding:t.padding??"",paddingTop:t.paddingTop??"",paddingRight:t.paddingRight??"",paddingBottom:t.paddingBottom??"",paddingLeft:t.paddingLeft??"",border:t.border??"",borderTopWidth:t.borderTopWidth??"",borderRightWidth:t.borderRightWidth??"",borderBottomWidth:t.borderBottomWidth??"",borderLeftWidth:t.borderLeftWidth??"",fontFamily:t.fontFamily??"",fontSize:t.fontSize??"",lineHeight:t.lineHeight??"",color:t.color??"",backgroundColor:t.backgroundColor??"",borderRadius:t.borderRadius??"",width:t.width??0,height:t.height??0}}function at(e){return e==="admin"?["create","read","reply","update","assign"]:e==="developer"?["read","reply","update","assign"]:["create","read","reply"]}function ot(e){return e==="in_progress"||e==="needs_clarification"||e==="fixed"||e==="wontfix"||e==="resolved"?e:"open"}function lt(e){return e==="low"||e==="high"?e:"medium"}function dt(e){return e==="visual"||e==="copy"||e==="accessibility"||e==="responsive"?e:"bug"}function ct(e){return e==="mobile"||e==="tablet"||e==="desktop"?e:"custom"}function ht(e){let t=e,r="";for(;t>0;){const s=(t-1)%26;r=String.fromCharCode(65+s)+r,t=Math.floor((t-s)/26)}return r}async function ut(e,t){return await wt(),new Promise((r,s)=>{var l;const a=(l=window.google)==null?void 0:l.accounts.oauth2.initTokenClient({client_id:e,scope:t,callback:u=>{if(u.error||!u.access_token){s(new Error(u.error??"Google OAuth did not return an access token"));return}const m=u.expires_in??3600;r({accessToken:u.access_token,expiresAt:Date.now()+m*1e3})}});a==null||a.requestAccessToken({prompt:""})})}function pt(e,t){return`${rt}:${e}:${t}`}function ft(e){try{const t=window.localStorage.getItem(e);if(!t)return;const r=JSON.parse(t);if(typeof r.accessToken!="string"||typeof r.expiresAt!="number"||Date.now()>=r.expiresAt-6e4){window.localStorage.removeItem(e);return}return r}catch{return}}function gt(e,t){try{window.localStorage.setItem(e,JSON.stringify(t))}catch{}}function ye(e){try{window.localStorage.removeItem(e)}catch{}}function wt(){var e;return(e=window.google)!=null&&e.accounts.oauth2?Promise.resolve():new Promise((t,r)=>{const s=document.querySelector('script[src="https://accounts.google.com/gsi/client"]');if(s){s.addEventListener("load",()=>t(),{once:!0}),s.addEventListener("error",()=>r(new Error("Google Identity failed to load")),{once:!0});return}const a=document.createElement("script");a.src="https://accounts.google.com/gsi/client",a.async=!0,a.defer=!0,a.onload=()=>t(),a.onerror=()=>r(new Error("Google Identity failed to load")),document.head.append(a)})}function mt(e){const t=[`From: ${e.from}`,`To: ${e.to.join(", ")}`,`Subject: ${e.subject}`,"Content-Type: text/plain; charset=UTF-8","",e.text].join(`\r
2
2
  `);return vt(t)}function vt(e){const t=new TextEncoder().encode(e);let r="";return t.forEach(s=>{r+=String.fromCharCode(s)}),btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function Se(e){return new URL(e,window.location.href).pathname.replace(/\/+$/,"")||"/"}const ke=h.createContext(null);function bt({config:e,children:t}){const r=h.useMemo(()=>e.adapter?e.adapter:fe({googleClientId:ie(e.googleClientId,"googleClientId"),contentSpreadsheetId:ie(e.contentSpreadsheetId,"contentSpreadsheetId"),usersSpreadsheetId:ie(e.usersSpreadsheetId,"usersSpreadsheetId"),feedbackSheetName:e.sheetName??"Feedback",enableEmailNotifications:Ce(e)}),[e.adapter,e.contentSpreadsheetId,e.emailNotifications,e.googleClientId,e.sheetName,e.usersSpreadsheetId]),s=e.currentUrl??window.location.href,a=(e.normalizeUrl??Se)(s),[l,u]=h.useState(),[m,g]=h.useState([]),[b,A]=h.useState([]),x=h.useCallback(async()=>{const w=await r.listFeedback({projectKey:e.projectKey,contentId:e.contentId,normalizedPath:a});A(w)},[r,e.contentId,e.projectKey,a]);h.useEffect(()=>{let w=!0;async function y(){const[E,F]=await Promise.all([r.getCurrentUser(),r.getPermissions(e.projectKey)]);w&&(u(E),g(F),await x())}return y(),()=>{w=!1}},[r,e.projectKey,x]);const f=h.useCallback(async w=>{const y=await r.createFeedback(w);return A(E=>[y,...E]),ae(e,r,{actorEmail:(l==null?void 0:l.email)??w.authorEmail,item:y,kind:"created"}),y},[r,e,l==null?void 0:l.email]),v=h.useCallback(async(w,y)=>{const E=b.find(B=>B.id===w),F=await r.updateFeedback(w,y);return A(B=>B.map(U=>U.id===w?F:U)),ae(e,r,{actorEmail:l==null?void 0:l.email,item:F,kind:yt(y),previousItem:E}),F},[r,e,l==null?void 0:l.email,b]),c=h.useCallback(w=>r.listMessages(w),[r]),S=h.useCallback(async w=>{const y=await r.createMessage(w),E=b.find(F=>F.id===w.feedbackId);return E&&ae(e,r,{actorEmail:w.authorEmail,item:E,kind:"reply",replyBody:w.body}),y},[r,e,b]),o=h.useCallback(async(w,y)=>{const E=e.uploadAttachment??r.uploadAttachment;if(!E)throw new Error("Review Lens attachment upload is not configured");return E(w,y)},[r,e]),C=h.useMemo(()=>({config:e,adapter:r,currentUser:l,permissions:m,feedback:b,normalizedPath:a,refreshFeedback:x,createFeedback:f,updateFeedback:v,listMessages:c,createMessage:S,uploadAttachment:o}),[r,e,f,l,b,a,m,x,v,c,S,o]);return n.jsx(ke.Provider,{value:C,children:t})}function Ee(){const e=h.useContext(ke);if(!e)throw new Error("useReviewLens must be used inside ReviewLensProvider");return e}function ie(e,t){if(!e)throw new Error(`review-lens-react requires config.${t} when no adapter is provided`);return e}function Ce(e){return typeof e.emailNotifications=="object"?e.emailNotifications.enabled!==!1:!!e.emailNotifications}function yt(e){return e.status==="resolved"?"resolved":e.status==="fixed"||e.fixedAt||e.fixedBy?"fixed":e.status?"status":"assigneeEmail"in e?"assigned":"updated"}async function ae(e,t,r){if(!Ce(e)||!t.sendEmail)return;const s=St(r);if(s.length!==0)try{await t.sendEmail({to:s,subject:kt(e,r),text:Et(r)})}catch(a){console.warn("Review Lens email notification failed",a)}}function St(e){var r;const t=new Set;return t.add(e.item.authorEmail),(r=e.previousItem)!=null&&r.assigneeEmail&&t.add(e.previousItem.assigneeEmail),e.item.assigneeEmail&&t.add(e.item.assigneeEmail),[...t].filter(s=>{var a;return s?s.toLowerCase()!==((a=e.actorEmail)==null?void 0:a.toLowerCase()):!1})}function kt(e,t){return`${(typeof e.emailNotifications=="object"?e.emailNotifications:{}).subjectPrefix??"Review Lens"}: ${Ne(t)}`}function Et(e){const t=["[Review Lens]",Ne(e),Ct(e),"",`Review: ${e.item.comment}`,`Status: ${xe(e.item.status)}`,`Author: ${e.item.authorEmail}`,`Assignee: ${e.item.assigneeEmail??"Unassigned"}`,`Link: ${Nt(e.item)}`];return e.replyBody&&t.splice(2,0,`Reply: ${e.replyBody}`,""),t.join(`
3
- `)}function Ct(e){return e.actorEmail?`Sent by Review Lens on behalf of ${e.actorEmail}.`:"Sent by Review Lens on behalf of the signed-in Google user."}function Ne(e){return e.kind==="created"?"New review feedback":e.kind==="assigned"?`Review assignment changed to ${e.item.assigneeEmail??"unassigned"}`:e.kind==="status"?`Review status changed to ${xe(e.item.status)}`:e.kind==="fixed"?"Review marked fixed":e.kind==="resolved"?"Review resolved":e.kind==="reply"?"New review reply":"Review updated"}function Nt(e){try{const t=new URL(e.originalUrl);return t.searchParams.set("reviewLensFeedback",e.id),t.toString()}catch{return e.originalUrl}}function xe(e){return e.replace(/_/g," ")}const xt=["data-review-id","data-testid","data-test-id","aria-label","name"];function D(e){const t=e.getBoundingClientRect(),r=Lt(e);return{selector:r.selector,selectorStrategy:r.strategy,fingerprint:Ft(e,t),cssSnapshot:It(e,t),rect:t}}function Lt(e){for(const t of xt){const r=e.getAttribute(t);if(r)return{selector:`[${t}="${Le(r)}"]`,strategy:"stable-attribute"}}return e.id?{selector:`#${Le(e.id)}`,strategy:"stable-attribute"}:{selector:At(e),strategy:"css-path"}}function At(e){const t=[];let r=e;for(;r&&r.nodeType===Node.ELEMENT_NODE&&r!==document.body;){const s=r.parentElement,a=r.tagName.toLowerCase();if(!s){t.unshift(a);break}const l=r.tagName,u=Array.from(s.children).filter(g=>g.tagName===l),m=u.indexOf(r)+1;t.unshift(u.length>1?`${a}:nth-of-type(${m})`:a),r=s}return t.join(" > ")}function Ft(e,t){var r;return{tagName:e.tagName.toLowerCase(),id:e.id||void 0,className:e.getAttribute("class")||void 0,textSnippet:((r=e.textContent)==null?void 0:r.trim().slice(0,80))||void 0,ariaLabel:e.getAttribute("aria-label")||void 0,width:Math.round(t.width),height:Math.round(t.height)}}function It(e,t){const r=window.getComputedStyle(e);return{margin:oe(r.marginTop,r.marginRight,r.marginBottom,r.marginLeft),marginTop:r.marginTop,marginRight:r.marginRight,marginBottom:r.marginBottom,marginLeft:r.marginLeft,padding:oe(r.paddingTop,r.paddingRight,r.paddingBottom,r.paddingLeft),paddingTop:r.paddingTop,paddingRight:r.paddingRight,paddingBottom:r.paddingBottom,paddingLeft:r.paddingLeft,border:oe(r.borderTopWidth,r.borderRightWidth,r.borderBottomWidth,r.borderLeftWidth),borderTopWidth:r.borderTopWidth,borderRightWidth:r.borderRightWidth,borderBottomWidth:r.borderBottomWidth,borderLeftWidth:r.borderLeftWidth,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight,color:r.color,backgroundColor:r.backgroundColor,borderRadius:r.borderRadius,width:Math.round(t.width),height:Math.round(t.height)}}function oe(e,t,r,s){return e===t&&t===r&&r===s?e:`${e} ${t} ${r} ${s}`}function Le(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}function Ae({className:e,title:t="Review Lens logo"}){return n.jsxs("svg",{className:e,role:"img","aria-label":t,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("rect",{x:"4",y:"6",width:"28",height:"28",rx:"8",fill:"#171717"}),n.jsx("path",{d:"M13 15.5C14.5 13.4 17.1 12 20 12C23.9 12 27.3 14.5 28.7 18C27.3 21.5 23.9 24 20 24C17.1 24 14.5 22.6 13 20.5",stroke:"#FFFFFF",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("circle",{cx:"20",cy:"18",r:"3.4",fill:"#F97316"}),n.jsx("path",{d:"M28.5 26.5L34.5 32.5",stroke:"#2563EB",strokeWidth:"4",strokeLinecap:"round"}),n.jsx("circle",{cx:"31.8",cy:"29.8",r:"2.1",fill:"#FACC15",stroke:"#171717",strokeWidth:"1.4"})]})}const Tt=[{label:"Desktop",value:"desktop"},{label:"Tablet",value:"tablet"},{label:"Mobile",value:"mobile"}],Fe=["open","in_progress","needs_clarification","fixed","wontfix","resolved"],Ie=["low","medium","high"],Te=["bug","visual","copy","accessibility","responsive"],R={open:"Open",in_progress:"In progress",needs_clarification:"Needs clarification",fixed:"Fixed",wontfix:"Won't fix",resolved:"Resolved"},O={low:"Low",medium:"Medium",high:"High"},K={bug:"Bug",visual:"Visual",copy:"Copy",accessibility:"Accessibility",responsive:"Responsive"};function Mt({open:e,onOpenChange:t,placement:r="top-right",showResolved:s=!1,syncSelectionToUrl:a=!1,responsivePresets:l=Tt}){var Re;const{adapter:u,config:m,currentUser:g,feedback:b,normalizedPath:A,permissions:x,createFeedback:f,updateFeedback:v,listMessages:c,createMessage:S,uploadAttachment:o}=Ee(),[C,w]=h.useState(),[y,E]=h.useState(),[F,B]=h.useState(""),[U,Rt]=h.useState("medium"),[_e,er]=h.useState("visual"),[je,Ue]=h.useState(""),[We,tr]=h.useState(((Re=l[0])==null?void 0:Re.value)??"desktop"),[k,q]=h.useState(),[M,_]=h.useState("review"),[rr,De]=h.useState(!1),[V,ze]=h.useState("all"),[Y,He]=h.useState("all"),[X,Oe]=h.useState("all"),[Q,Ke]=h.useState("all"),[Z,Je]=h.useState("all"),[nr,sr]=h.useState(!1),[ir,Ge]=h.useState({}),[le,de]=h.useState(""),te=h.useRef(null),qe=h.useRef(e),ce=h.useRef(a?new URL(window.location.href).searchParams.get("reviewLensFeedback"):null),$=!!g,P=x.includes("create"),Ve=x.includes("reply"),Ye=x.includes("update"),ar=x.includes("assign"),W=C??y,or=!!y,lr=!!(m.captureScreenshot&&(m.uploadAttachment||u.uploadAttachment)),dr=h.useMemo(()=>{const i=b.map(p=>p.assigneeEmail).filter(p=>!!p);return g!=null&&g.email&&i.push(g.email),Array.from(new Set(i)).sort((p,d)=>p.localeCompare(d))},[g==null?void 0:g.email,b]),T=h.useMemo(()=>b.filter(i=>s||i.status!=="resolved").filter(i=>V==="all"||i.status===V).filter(i=>Y==="all"||i.severity===Y).filter(i=>X==="all"||i.category===X).filter(i=>Q==="all"||i.assigneeEmail===Q).filter(i=>Z==="all"||i.viewportPreset===Z),[Q,X,b,Y,s,V,Z]),cr=[V,Y,X,Q,Z].filter(i=>i!=="all").length;h.useEffect(()=>{if(e){qe.current=!0;return}if(w(void 0),E(void 0),B(""),de(""),_("review"),a&&qe.current){const i=new URL(window.location.href);i.searchParams.has("reviewLensFeedback")&&(i.searchParams.delete("reviewLensFeedback"),window.history.replaceState({},"",i))}},[e,a]),h.useEffect(()=>{$||(w(void 0),E(void 0))},[$]),h.useEffect(()=>{!y||M!=="review"||window.requestAnimationFrame(()=>{var i,p,d;(p=(i=te.current)==null?void 0:i.scrollIntoView)==null||p.call(i,{block:"nearest"}),(d=te.current)==null||d.focus()})},[y,M]),h.useEffect(()=>{if(!k)return;let i=!0;return c(k.id).then(p=>{i&&Ge(d=>({...d,[k.id]:p}))}),()=>{i=!1}},[c,k]),h.useEffect(()=>{if(!a||!ce.current||b.length===0)return;const i=b.find(p=>p.id===ce.current);i&&(ce.current=null,t==null||t(!0),H(i,{syncUrl:!1}))},[b,a]),h.useEffect(()=>{if(!e||!a||k||b.length===0)return;const i=new URL(window.location.href).searchParams.get("reviewLensFeedback"),p=b.find(d=>d.id===i);p&&H(p,{syncUrl:!1})},[b,e,k,a]),h.useEffect(()=>{if(!e)return;function i(d){var N;if(d.key==="Shift"&&De(!0),d.key==="Escape"){d.preventDefault(),t==null||t(!1);return}Yt(d.target)||((d.key==="n"||d.key==="ArrowDown")&&(d.preventDefault(),Xe(1)),(d.key==="p"||d.key==="ArrowUp")&&(d.preventDefault(),Xe(-1)),d.key==="c"&&(d.preventDefault(),_("review"),(N=te.current)==null||N.focus()),d.key==="f"&&k&&Ye&&(d.preventDefault(),Ze(k)))}function p(d){d.key==="Shift"&&De(!1)}return window.addEventListener("keydown",i),window.addEventListener("keyup",p),()=>{window.removeEventListener("keydown",i),window.removeEventListener("keyup",p)}});const he=h.useCallback(i=>{const p=i.target instanceof Element?i.target:null;if(p)return p.closest("[data-review-lens-ui]")?null:p;const d=document.elementFromPoint(i.clientX,i.clientY);return!d||d.closest("[data-review-lens-ui]")?null:d},[]);if(h.useEffect(()=>{if(!e||!$)return;function i(d){const N=he(d);w(N?D(N):void 0)}function p(d){const N=he(d);N&&(d.preventDefault(),d.stopPropagation(),E(D(N)),_("review"))}return window.addEventListener("mousemove",i,!0),window.addEventListener("click",p,!0),()=>{window.removeEventListener("mousemove",i,!0),window.removeEventListener("click",p,!0)}},[$,he,e]),!e)return null;function H(i,p={syncUrl:!0}){var N;if(q(i),E(void 0),_("feedback"),a&&p.syncUrl!==!1){const re=new URL(window.location.href);re.searchParams.set("reviewLensFeedback",i.id),window.history.replaceState({},"",re)}const d=z(i.selector);if(!d){w(void 0);return}(N=d.scrollIntoView)==null||N.call(d,{behavior:"smooth",block:"center",inline:"center"}),window.requestAnimationFrame(()=>{w(D(d))})}function Xe(i){if(T.length===0)return;const p=k?T.findIndex(N=>N.id===k.id):-1,d=p<0?i>0?0:T.length-1:(p+i+T.length)%T.length;H(T[d])}async function Qe(){if(!y||!F.trim()||!g||!P)return;let i=await f({projectKey:m.projectKey,contentId:m.contentId,normalizedPath:A,originalUrl:m.currentUrl??window.location.href,selector:y.selector,selectorStrategy:y.selectorStrategy,elementFingerprint:y.fingerprint,createdCssSnapshot:y.cssSnapshot,comment:F.trim(),status:"open",severity:U,category:_e,assigneeEmail:je.trim()||void 0,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,viewportPreset:We,screenshotUrl:void 0,screenshotThumbnailUrl:void 0,authorEmail:g.email});if(m.captureScreenshot)try{const p=await m.captureScreenshot(y),d=await o(i.id,{type:"screenshot",data:p,createdBy:g.email});i=await v(i.id,{attachments:[d],screenshotUrl:d.url,screenshotThumbnailUrl:d.thumbnailUrl})}catch{}if(B(""),Ue(""),E(void 0),w(void 0),_("feedback"),q(i),a){const p=new URL(window.location.href);p.searchParams.set("reviewLensFeedback",i.id),window.history.replaceState({},"",p)}}async function hr(i,p){const d=new Date().toISOString(),N=p==="resolved"?{status:p,resolvedAt:d,resolvedBy:g==null?void 0:g.email}:{status:p},re=await v(i.id,N);q(re)}async function Ze(i){const p=z(i.selector);if(!p||!g)return;const d=D(p),N=await v(i.id,{status:"fixed",fixedCssSnapshot:d.cssSnapshot,fixedAt:new Date().toISOString(),fixedBy:g.email});q(N)}async function ur(i){if(!le.trim()||!g||!Ve)return;const p=await S({feedbackId:i.id,body:le.trim(),authorEmail:g.email});Ge(d=>({...d,[i.id]:[...d[i.id]??[],p]})),de("")}return n.jsxs("div",{className:"review-lens-root","data-review-lens-ui":!0,children:[$&&W?n.jsx(Ut,{target:W,locked:!!y}):null,$&&y&&C&&rr?n.jsx(Wt,{from:y,to:C}):null,$?n.jsxs(n.Fragment,{children:[n.jsx(Dt,{feedback:T,selectedFeedback:k,onSelect:H}),n.jsx(Ht,{feedback:T,selectedFeedback:k,onSelect:H})]}):null,n.jsxs("aside",{className:`review-lens-panel review-lens-panel--${r}`,"data-review-lens-ui":!0,children:[n.jsxs("header",{className:"review-lens-panel__header",children:[n.jsxs("div",{className:"review-lens-brand",children:[n.jsx(Ae,{className:"review-lens-brand__mark"}),n.jsxs("div",{children:[n.jsx("p",{className:"review-lens-kicker",children:"Review Lens"}),n.jsx("h2",{children:M==="summary"?"Summary":M==="feedback"?"Feedback":y?"Element locked":"Inspecting"})]})]}),n.jsx("button",{type:"button",onClick:()=>t==null?void 0:t(!1),children:"Close"})]}),n.jsxs("div",{className:"review-lens-panel__body",children:[n.jsxs("div",{className:"review-lens-mode-switch",role:"tablist","aria-label":"Review Lens mode",children:[n.jsx("button",{type:"button",role:"tab","aria-selected":M==="review",onClick:()=>_("review"),children:"Review"}),n.jsxs("button",{type:"button",role:"tab","aria-selected":M==="feedback",onClick:()=>_("feedback"),children:["Feedback ",n.jsx("span",{children:T.length})]}),n.jsx("button",{type:"button",role:"tab","aria-selected":M==="summary",onClick:()=>_("summary"),children:"Summary"})]}),M==="review"?n.jsxs("div",{className:"review-lens-review-pane",role:"tabpanel",children:[n.jsxs("div",{className:"review-lens-inspection",children:[$?null:n.jsx("p",{children:"Authenticate with Google to inspect this page."}),$&&W?n.jsxs(n.Fragment,{children:[n.jsx(Ot,{target:W}),n.jsx(Me,{title:"Accessibility",items:Kt(W)}),n.jsx(Me,{title:"Design tokens",items:Jt(W.cssSnapshot,m.designTokens)})]}):null,$&&!W?n.jsx("p",{children:"Move over the app to inspect."}):null]}),or?n.jsx("div",{className:"review-lens-composer-panel",children:n.jsxs("form",{className:"review-lens-feedback-form",onSubmit:i=>{i.preventDefault(),Qe()},children:[n.jsx("label",{htmlFor:"review-lens-comment",children:"New feedback"}),n.jsx("textarea",{ref:te,id:"review-lens-comment",value:F,disabled:!P,onChange:i=>B(i.target.value),onKeyDown:i=>{i.key==="Enter"&&i.metaKey&&(i.preventDefault(),Qe())},placeholder:P?"Describe the UX issue...":"You do not have permission to comment."}),n.jsxs("div",{className:"review-lens-form-grid",children:[n.jsxs("label",{children:["Severity",n.jsx("select",{value:U,onChange:i=>Rt(i.target.value),disabled:!P,children:Ie.map(i=>n.jsx("option",{value:i,children:O[i]},i))})]}),n.jsxs("label",{children:["Type",n.jsx("select",{value:_e,onChange:i=>er(i.target.value),disabled:!P,children:Te.map(i=>n.jsx("option",{value:i,children:K[i]},i))})]}),n.jsxs("label",{children:["Assignee",n.jsx("input",{value:je,onChange:i=>Ue(i.target.value),disabled:!P,placeholder:"optional@email.com"})]}),n.jsxs("label",{children:["Viewport",n.jsx("select",{value:We,onChange:i=>tr(i.target.value),disabled:!P,children:l.map(i=>n.jsx("option",{value:i.value,children:i.label},i.value))})]})]}),P?n.jsxs("p",{className:"review-lens-feedback-form__hint",children:["Press ",n.jsx("kbd",{children:"Command"})," + ",n.jsx("kbd",{children:"Enter"})," to submit.",lr?" Screenshot capture runs after save.":""]}):null,n.jsx("div",{className:"review-lens-actions",children:n.jsx("button",{type:"submit",disabled:!F.trim()||!P,children:"Save feedback"})})]})}):null]}):null,M==="feedback"?n.jsxs("div",{className:"review-lens-comments",children:[n.jsx($t,{open:nr,activeCount:cr,statusFilter:V,severityFilter:Y,categoryFilter:X,assigneeFilter:Q,viewportFilter:Z,assignees:dr,responsivePresets:l,onStatusChange:ze,onSeverityChange:He,onCategoryChange:Oe,onAssigneeChange:Ke,onViewportChange:Je,onToggle:()=>sr(i=>!i),onClear:()=>{ze("all"),He("all"),Oe("all"),Ke("all"),Je("all")}}),n.jsxs("div",{className:"review-lens-list-panel",children:[n.jsxs("div",{className:"review-lens-comments__header",children:[n.jsx("h3",{children:"All feedback"}),n.jsx("span",{children:T.length})]}),n.jsxs("div",{className:"review-lens-comments__list",children:[T.length===0?n.jsx("p",{children:"No feedback for this view."}):null,T.map(i=>n.jsx(Bt,{item:i,selected:(k==null?void 0:k.id)===i.id,onSelect:H},i.id))]})]}),k?n.jsxs("div",{className:"review-lens-selected-panel",children:[n.jsx("div",{className:"review-lens-selected-panel__label",children:"Selected feedback"}),n.jsx(Pt,{item:k,messages:ir[k.id]??[],messageDraft:le,canReply:Ve,canUpdate:Ye,canAssign:ar,syncSelectionToUrl:a,onMessageDraftChange:de,onSubmitMessage:()=>void ur(k),onStatusChange:i=>void hr(k,i),onAssigneeChange:i=>void v(k.id,{assigneeEmail:i.trim()||void 0}).then(q),onMarkFixed:()=>void Ze(k)},k.id)]}):n.jsxs("div",{className:"review-lens-selected-panel review-lens-selected-panel--empty",children:[n.jsx("div",{className:"review-lens-selected-panel__label",children:"Selected feedback"}),n.jsx("p",{children:"Select a feedback item above to review status, assignment, drift, and replies."})]})]}):null,M==="summary"?n.jsx(jt,{feedback:b}):null]})]})]})}function $t({open:e,activeCount:t,statusFilter:r,severityFilter:s,categoryFilter:a,assigneeFilter:l,viewportFilter:u,assignees:m,responsivePresets:g,onStatusChange:b,onSeverityChange:A,onCategoryChange:x,onAssigneeChange:f,onViewportChange:v,onToggle:c,onClear:S}){return n.jsxs("div",{className:"review-lens-filter-shell",children:[n.jsxs("div",{className:"review-lens-filter-bar",children:[n.jsxs("button",{type:"button","aria-expanded":e,onClick:c,children:["Filters",t>0?n.jsx("span",{children:t}):null]}),t>0?n.jsx("button",{type:"button",onClick:S,children:"Clear"}):null]}),e?n.jsxs("div",{className:"review-lens-filters",children:[n.jsxs("label",{children:["Status",n.jsxs("select",{"aria-label":"Filter status",value:r,onChange:o=>b(o.target.value),children:[n.jsx("option",{value:"all",children:"All statuses"}),Fe.map(o=>n.jsx("option",{value:o,children:R[o]},o))]})]}),n.jsxs("label",{children:["Priority",n.jsxs("select",{"aria-label":"Filter severity",value:s,onChange:o=>A(o.target.value),children:[n.jsx("option",{value:"all",children:"All priorities"}),Ie.map(o=>n.jsx("option",{value:o,children:O[o]},o))]})]}),n.jsxs("label",{children:["Type",n.jsxs("select",{"aria-label":"Filter type",value:a,onChange:o=>x(o.target.value),children:[n.jsx("option",{value:"all",children:"All types"}),Te.map(o=>n.jsx("option",{value:o,children:K[o]},o))]})]}),n.jsxs("label",{children:["Assignee",n.jsxs("select",{"aria-label":"Filter assignee",value:l,onChange:o=>f(o.target.value),children:[n.jsx("option",{value:"all",children:"All assignees"}),m.map(o=>n.jsx("option",{value:o,children:o},o))]})]}),n.jsxs("label",{children:["Viewport",n.jsxs("select",{"aria-label":"Filter viewport",value:u,onChange:o=>v(o.target.value),children:[n.jsx("option",{value:"all",children:"All viewports"}),g.map(o=>n.jsx("option",{value:o.value,children:o.label},o.value))]})]})]}):null]})}function Bt({item:e,selected:t,onSelect:r}){const s=$e(e);return n.jsxs("article",{tabIndex:0,className:["review-lens-comment",`review-lens-comment--${e.severity}`,t?"review-lens-comment--selected":""].filter(Boolean).join(" "),onClick:()=>r(e),onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),r(e))},children:[n.jsxs("div",{className:"review-lens-comment__header",children:[n.jsx("span",{children:R[e.status]}),n.jsx("strong",{children:O[e.severity]})]}),n.jsxs("div",{className:"review-lens-comment__content",children:[n.jsx("p",{children:e.comment}),n.jsxs("span",{children:[e.authorEmail,e.assigneeEmail?` -> ${e.assigneeEmail}`:""]})]}),n.jsxs("div",{className:"review-lens-tags",children:[n.jsx("span",{children:K[e.category]}),n.jsx("span",{children:e.viewportPreset}),n.jsx("span",{children:s.label})]})]})}function Pt({item:e,messages:t,messageDraft:r,canReply:s,canUpdate:a,canAssign:l,syncSelectionToUrl:u,onMessageDraftChange:m,onSubmitMessage:g,onStatusChange:b,onAssigneeChange:A,onMarkFixed:x}){const[f,v]=h.useState(!1),c=$e(e);function S(){const o=new URL(window.location.href);o.searchParams.set("reviewLensFeedback",e.id),_t(o.toString()).then(C=>{C&&(v(!0),setTimeout(()=>v(!1),2e3))})}return n.jsxs("section",{className:"review-lens-detail","aria-label":"Selected feedback detail",children:[n.jsxs("div",{className:"review-lens-detail__header",children:[n.jsxs("h3",{children:[K[e.category]," feedback"]}),n.jsxs("div",{className:"review-lens-detail__header-actions",children:[u?n.jsx("button",{type:"button",className:"review-lens-copy-link",onClick:S,"aria-label":"Copy link to this feedback",children:f?"Copied!":"Copy link"}):null,n.jsx("strong",{children:O[e.severity]})]})]}),n.jsx("blockquote",{children:e.comment}),n.jsxs("dl",{className:"review-lens-detail-meta",children:[n.jsxs("div",{children:[n.jsx("dt",{children:"Target"}),n.jsx("dd",{children:c.label})]}),n.jsxs("div",{children:[n.jsx("dt",{children:"Viewport"}),n.jsx("dd",{children:e.viewportPreset})]}),e.screenshotUrl?n.jsxs("div",{children:[n.jsx("dt",{children:"Evidence"}),n.jsx("dd",{children:n.jsx("a",{href:e.screenshotUrl,target:"_blank",rel:"noreferrer",children:"Screenshot"})})]}):null]}),n.jsxs("div",{className:"review-lens-form-grid",children:[n.jsxs("label",{children:["Status",n.jsx("select",{value:e.status,disabled:!a,onChange:o=>b(o.target.value),children:Fe.map(o=>n.jsx("option",{value:o,children:R[o]},o))})]}),n.jsxs("label",{children:["Assignee",n.jsx("input",{defaultValue:e.assigneeEmail??"",disabled:!l,onBlur:o=>A(o.target.value),placeholder:"optional@email.com"})]})]}),n.jsxs("div",{className:"review-lens-status-actions",children:[n.jsx("button",{type:"button",className:"review-lens-button-secondary",disabled:!a,onClick:x,children:"Mark fixed"}),n.jsx("button",{type:"button",className:"review-lens-button-primary",disabled:!a,onClick:()=>b("resolved"),children:"Resolve"})]}),n.jsxs("div",{className:"review-lens-thread",children:[n.jsxs("div",{className:"review-lens-thread__header",children:[n.jsx("h3",{children:"Thread"}),n.jsx("span",{children:t.length})]}),t.length===0?n.jsx("p",{children:"No replies yet."}):null,t.map(o=>n.jsxs("div",{className:"review-lens-thread__message",children:[n.jsx("p",{children:o.body}),n.jsx("span",{children:o.authorEmail})]},o.id)),n.jsx("textarea",{"aria-label":"Reply",value:r,disabled:!s,onChange:o=>m(o.target.value),placeholder:s?"Reply...":"You do not have permission to reply."}),n.jsx("div",{className:"review-lens-actions",children:n.jsx("button",{type:"button",disabled:!r.trim()||!s,onClick:g,children:"Reply"})})]})]})}async function _t(e){var r;if((r=navigator.clipboard)!=null&&r.writeText)return await navigator.clipboard.writeText(e),!0;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.opacity="0",document.body.append(t),t.select();try{return document.execCommand("copy")}finally{t.remove()}}function jt({feedback:e}){return n.jsxs("div",{className:"review-lens-summary",role:"tabpanel",children:[n.jsx(J,{title:"Status",values:G(e,t=>R[t.status])}),n.jsx(J,{title:"Severity",values:G(e,t=>O[t.severity])}),n.jsx(J,{title:"Type",values:G(e,t=>K[t.category])}),n.jsx(J,{title:"Assignee",values:G(e,t=>t.assigneeEmail??"Unassigned")}),n.jsx(J,{title:"Viewport",values:G(e,t=>t.viewportPreset)})]})}function J({title:e,values:t}){return n.jsxs("section",{children:[n.jsx("h3",{children:e}),n.jsx("dl",{children:t.map(([r,s])=>n.jsxs("div",{children:[n.jsx("dt",{children:r}),n.jsx("dd",{children:s})]},r))})]})}function Ut({target:e,locked:t}){const r=Zt(e),s=qt(e.fingerprint);return n.jsxs("div",{className:t?"review-lens-highlight review-lens-highlight--locked":"review-lens-highlight",style:{top:r.margin.top,left:r.margin.left,width:r.margin.width,height:r.margin.height},children:[n.jsx("div",{className:"review-lens-highlight__border",style:{top:r.border.top-r.margin.top,left:r.border.left-r.margin.left,width:r.border.width,height:r.border.height}}),n.jsx("div",{className:"review-lens-highlight__padding",style:{top:r.padding.top-r.margin.top,left:r.padding.left-r.margin.left,width:r.padding.width,height:r.padding.height}}),n.jsx("div",{className:"review-lens-highlight__content",style:{top:r.content.top-r.margin.top,left:r.content.left-r.margin.left,width:r.content.width,height:r.content.height}}),n.jsxs("div",{className:"review-lens-highlight__label",children:[n.jsx("strong",{children:s}),n.jsxs("span",{children:[Math.round(e.rect.width)," x ",Math.round(e.rect.height)]})]})]})}function Wt({from:e,to:t}){const r=Vt(e.rect,t.rect);return r.length===0?null:n.jsx(n.Fragment,{children:r.map(s=>n.jsx("div",{className:`review-lens-distance review-lens-distance--${s.axis}`,style:{top:s.top,left:s.left,width:s.width,height:s.height},children:n.jsx("span",{children:s.label})},s.key))})}function Dt({feedback:e,selectedFeedback:t,onSelect:r}){return n.jsx(n.Fragment,{children:e.map(s=>n.jsx(zt,{feedback:s,selected:(t==null?void 0:t.id)===s.id,onSelect:r},s.id))})}function zt({feedback:e,selected:t,onSelect:r}){const s=h.useRef(null);return h.useLayoutEffect(()=>{let a=0;const l=()=>{a=0;const m=s.current,g=z(e.selector),b=g==null?void 0:g.getBoundingClientRect();!m||!b||(m.style.top=`${b.top}px`,m.style.left=`${b.right}px`,m.hidden=b.bottom<0||b.top>window.innerHeight)},u=()=>{a||(a=window.requestAnimationFrame(l))};return l(),window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{a&&window.cancelAnimationFrame(a),window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u)}},[e.selector]),n.jsx("button",{ref:s,type:"button",className:t?"review-lens-marker review-lens-marker--selected":"review-lens-marker",onClick:()=>r(e),"aria-label":`Open feedback from ${e.authorEmail}`})}function Ht({feedback:e,selectedFeedback:t,onSelect:r}){const s=e.map(a=>{const l=z(a.selector),u=l==null?void 0:l.getBoundingClientRect(),m=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,window.innerHeight);return!u||m<=0?null:{item:a,top:Math.min(100,Math.max(0,(u.top+window.scrollY)/m*100))}}).filter(a=>a!==null);return s.length===0?null:n.jsx("div",{className:"review-lens-minimap","data-review-lens-ui":!0,"aria-label":"Feedback map",children:s.map(a=>n.jsx("button",{type:"button",className:(t==null?void 0:t.id)===a.item.id?"review-lens-minimap__point review-lens-minimap__point--selected":"review-lens-minimap__point",style:{top:`${a.top}%`},onClick:()=>r(a.item),"aria-label":`Jump to feedback from ${a.item.authorEmail}`},a.item.id))})}function Ot({target:e}){const t=[["Selector",e.selector],["Size",`${e.cssSnapshot.width} x ${e.cssSnapshot.height}`],["Margin",e.cssSnapshot.margin],["Padding",e.cssSnapshot.padding],["Border",e.cssSnapshot.border],["Radius",e.cssSnapshot.borderRadius],["Font",`${e.cssSnapshot.fontSize} / ${e.cssSnapshot.lineHeight}`],["Family",e.cssSnapshot.fontFamily],["Color",e.cssSnapshot.color],["Background",e.cssSnapshot.backgroundColor]];return n.jsx("dl",{className:"review-lens-metrics",children:t.map(([r,s])=>n.jsxs("div",{children:[n.jsx("dt",{children:r}),n.jsx("dd",{children:s})]},r))})}function Me({title:e,items:t}){return n.jsxs("section",{className:"review-lens-insights",children:[n.jsx("h3",{children:e}),t.length===0?n.jsx("p",{children:"No issues detected."}):null,t.length>0?n.jsx("ul",{children:t.map(r=>n.jsx("li",{children:r},r))}):null]})}function z(e){try{return document.querySelector(e)}catch{return null}}function $e(e){const t=z(e.selector);if(!t)return{label:"Target missing",level:"warning"};const r=D(t);return r.fingerprint.tagName!==e.elementFingerprint.tagName?{label:"Element changed",level:"warning"}:Math.abs(r.fingerprint.width-e.elementFingerprint.width)>2||Math.abs(r.fingerprint.height-e.elementFingerprint.height)>2?{label:"Size changed",level:"warning"}:r.cssSnapshot.fontSize!==e.createdCssSnapshot.fontSize||r.cssSnapshot.color!==e.createdCssSnapshot.color||r.cssSnapshot.padding!==e.createdCssSnapshot.padding?{label:"Style changed",level:"warning"}:{label:"Target unchanged",level:"ok"}}function Kt(e){var g;const t=z(e.selector);if(!t)return["Selected element is no longer available."];const r=[],s=t.tagName.toLowerCase(),a=t.getAttribute("role"),l=["button","a","input","select","textarea"].includes(s)||a==="button"||a==="link",u=t.getAttribute("aria-label")||t.getAttribute("title")||((g=t.textContent)==null?void 0:g.trim());l&&!u&&r.push("Interactive element has no accessible name."),l&&(e.rect.width<44||e.rect.height<44)&&r.push("Tap target is smaller than 44 x 44."),s==="img"&&!t.getAttribute("alt")&&r.push("Image is missing alt text.");const m=/^h[1-6]$/.test(s)?Number(s.slice(1)):0;return m>1&&!document.querySelector(`h${m-1}`)&&r.push("Heading may skip the previous level."),Xt(e.cssSnapshot.color,e.cssSnapshot.backgroundColor)&&r.push("Text contrast may be low."),r}function Jt(e,t={}){const r=[];return j("Padding",e.padding,t.spacing,r,{allowComposite:!0}),j("Margin",e.margin,t.spacing,r,{allowComposite:!0}),j("Font size",e.fontSize,t.fontSize,r),j("Line height",e.lineHeight,t.lineHeight,r),j("Text color",e.color,t.color,r),j("Background",e.backgroundColor,t.color,r),j("Radius",e.borderRadius,t.radius,r,{allowComposite:!0}),r}function j(e,t,r,s,a={}){!r||r.length===0||!t||Gt(t,r,a)||s.push(`${e} ${t} is outside configured tokens.`)}function Gt(e,t,r={}){if(t.includes(e))return!0;if(!r.allowComposite)return!1;const s=e.trim().split(/\s+/);return s.length>1&&s.every(a=>t.includes(a))}function qt(e){const t=e.id?`#${e.id}`:"",r=e.className?`.${e.className.split(/\s+/).filter(Boolean).slice(0,2).join(".")}`:"",s=e.ariaLabel?`[aria-label="${e.ariaLabel}"]`:"";return`${e.tagName}${t}${r}${s}`||e.tagName}function Vt(e,t){const r=[],s=(Math.max(e.left,t.left)+Math.min(e.right,t.right))/2,a=(Math.max(e.top,t.top)+Math.min(e.bottom,t.bottom))/2;if(e.right<=t.left||t.right<=e.left){const l=e.right<=t.left?e.right:t.right,u=e.right<=t.left?t.left:e.left;r.push({key:"horizontal",axis:"horizontal",top:Be(a,0,window.innerHeight),left:l,width:Math.max(u-l,1),height:1,label:`${Math.round(u-l)}px`})}if(e.bottom<=t.top||t.bottom<=e.top){const l=e.bottom<=t.top?e.bottom:t.bottom,u=e.bottom<=t.top?t.top:e.top;r.push({key:"vertical",axis:"vertical",top:l,left:Be(s,0,window.innerWidth),width:1,height:Math.max(u-l,1),label:`${Math.round(u-l)}px`})}return r}function Be(e,t,r){return Math.min(Math.max(e,t),r)}function G(e,t){const r=new Map;for(const s of e){const a=t(s);r.set(a,(r.get(a)??0)+1)}return Array.from(r.entries()).sort((s,a)=>a[1]-s[1]||s[0].localeCompare(a[0]))}function Yt(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable}function Xt(e,t){const r=Pe(e),s=Pe(t);return!r||!s||s.alpha===0?!1:Qt(r,s)<4.5}function Pe(e){const t=e.match(/rgba?\(([^)]+)\)/);if(!t)return null;const[r,s,a,l="1"]=t[1].split(",").map(u=>u.trim());return{red:Number(r),green:Number(s),blue:Number(a),alpha:Number(l)}}function Qt(e,t){const r=Math.max(ee(e),ee(t)),s=Math.min(ee(e),ee(t));return(r+.05)/(s+.05)}function ee(e){const t=[e.red,e.green,e.blue].map(r=>{const s=r/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4});return t[0]*.2126+t[1]*.7152+t[2]*.0722}function Zt(e){const t={top:I(e.cssSnapshot.marginTop),right:I(e.cssSnapshot.marginRight),bottom:I(e.cssSnapshot.marginBottom),left:I(e.cssSnapshot.marginLeft)},r={top:I(e.cssSnapshot.borderTopWidth),right:I(e.cssSnapshot.borderRightWidth),bottom:I(e.cssSnapshot.borderBottomWidth),left:I(e.cssSnapshot.borderLeftWidth)},s={top:I(e.cssSnapshot.paddingTop),right:I(e.cssSnapshot.paddingRight),bottom:I(e.cssSnapshot.paddingBottom),left:I(e.cssSnapshot.paddingLeft)},a={top:e.rect.top,left:e.rect.left,width:Math.max(e.rect.width,0),height:Math.max(e.rect.height,0)},l={top:a.top-t.top,left:a.left-t.left,width:a.width+t.left+t.right,height:a.height+t.top+t.bottom},u={top:a.top+r.top,left:a.left+r.left,width:Math.max(a.width-r.left-r.right,0),height:Math.max(a.height-r.top-r.bottom,0)},m={top:u.top+s.top,left:u.left+s.left,width:Math.max(u.width-s.left-s.right,0),height:Math.max(u.height-s.top-s.bottom,0)};return{margin:l,border:a,padding:u,content:m}}function I(e){const t=Number.parseFloat(e);return Number.isFinite(t)?t:0}L.ReviewLensLogo=Ae,L.ReviewLensOverlay=Mt,L.ReviewLensProvider=bt,L.buildElementTarget=D,L.createGoogleSheetsAdapter=fe,L.normalizeReviewUrl=Se,L.useReviewLens=Ee,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})}));
3
+ `)}function Ct(e){return e.actorEmail?`Sent by Review Lens on behalf of ${e.actorEmail}.`:"Sent by Review Lens on behalf of the signed-in Google user."}function Ne(e){return e.kind==="created"?"New review feedback":e.kind==="assigned"?`Review assignment changed to ${e.item.assigneeEmail??"unassigned"}`:e.kind==="status"?`Review status changed to ${xe(e.item.status)}`:e.kind==="fixed"?"Review marked fixed":e.kind==="resolved"?"Review resolved":e.kind==="reply"?"New review reply":"Review updated"}function Nt(e){try{const t=new URL(e.originalUrl);return t.searchParams.set("reviewLensFeedback",e.id),t.toString()}catch{return e.originalUrl}}function xe(e){return e.replace(/_/g," ")}const xt=["data-review-id","data-testid","data-test-id","aria-label","name"];function W(e){const t=e.getBoundingClientRect(),r=Lt(e);return{selector:r.selector,selectorStrategy:r.strategy,fingerprint:Ft(e,t),cssSnapshot:It(e,t),rect:t}}function Lt(e){for(const t of xt){const r=e.getAttribute(t);if(r)return{selector:`[${t}="${Le(r)}"]`,strategy:"stable-attribute"}}return e.id?{selector:`#${Le(e.id)}`,strategy:"stable-attribute"}:{selector:At(e),strategy:"css-path"}}function At(e){const t=[];let r=e;for(;r&&r.nodeType===Node.ELEMENT_NODE&&r!==document.body;){const s=r.parentElement,a=r.tagName.toLowerCase();if(!s){t.unshift(a);break}const l=r.tagName,u=Array.from(s.children).filter(g=>g.tagName===l),m=u.indexOf(r)+1;t.unshift(u.length>1?`${a}:nth-of-type(${m})`:a),r=s}return t.join(" > ")}function Ft(e,t){var r;return{tagName:e.tagName.toLowerCase(),id:e.id||void 0,className:e.getAttribute("class")||void 0,textSnippet:((r=e.textContent)==null?void 0:r.trim().slice(0,80))||void 0,ariaLabel:e.getAttribute("aria-label")||void 0,width:Math.round(t.width),height:Math.round(t.height)}}function It(e,t){const r=window.getComputedStyle(e);return{margin:oe(r.marginTop,r.marginRight,r.marginBottom,r.marginLeft),marginTop:r.marginTop,marginRight:r.marginRight,marginBottom:r.marginBottom,marginLeft:r.marginLeft,padding:oe(r.paddingTop,r.paddingRight,r.paddingBottom,r.paddingLeft),paddingTop:r.paddingTop,paddingRight:r.paddingRight,paddingBottom:r.paddingBottom,paddingLeft:r.paddingLeft,border:oe(r.borderTopWidth,r.borderRightWidth,r.borderBottomWidth,r.borderLeftWidth),borderTopWidth:r.borderTopWidth,borderRightWidth:r.borderRightWidth,borderBottomWidth:r.borderBottomWidth,borderLeftWidth:r.borderLeftWidth,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight,color:r.color,backgroundColor:r.backgroundColor,borderRadius:r.borderRadius,width:Math.round(t.width),height:Math.round(t.height)}}function oe(e,t,r,s){return e===t&&t===r&&r===s?e:`${e} ${t} ${r} ${s}`}function Le(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/["\\]/g,"\\$&")}function Ae({className:e,title:t="Review Lens logo"}){return n.jsxs("svg",{className:e,role:"img","aria-label":t,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("rect",{x:"5",y:"5",width:"30",height:"30",rx:"9",fill:"#111827"}),n.jsx("path",{d:"M11.5 20C14.2 15.7 17.4 13.6 20 13.6C22.6 13.6 25.8 15.7 28.5 20C25.8 24.3 22.6 26.4 20 26.4C17.4 26.4 14.2 24.3 11.5 20Z",stroke:"#F8FAFC",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"}),n.jsx("path",{d:"M24.7 24.7L31.5 31.5",stroke:"#22D3EE",strokeWidth:"3.6",strokeLinecap:"round"}),n.jsx("circle",{cx:"20",cy:"20",r:"4.6",fill:"#F8FAFC"}),n.jsx("circle",{cx:"20",cy:"20",r:"2.2",fill:"#2563EB"}),n.jsx("path",{d:"M14.2 11.6L17 11.6M11.6 14.2L11.6 17M28.4 14.2L28.4 17",stroke:"#A7F3D0",strokeWidth:"2",strokeLinecap:"round"})]})}const Tt=[{label:"Desktop",value:"desktop"},{label:"Tablet",value:"tablet"},{label:"Mobile",value:"mobile"}],Fe=["open","in_progress","needs_clarification","fixed","wontfix","resolved"],Ie=["low","medium","high"],Te=["bug","visual","copy","accessibility","responsive"],R={open:"Open",in_progress:"In progress",needs_clarification:"Needs clarification",fixed:"Fixed",wontfix:"Won't fix",resolved:"Resolved"},O={low:"Low",medium:"Medium",high:"High"},K={bug:"Bug",visual:"Visual",copy:"Copy",accessibility:"Accessibility",responsive:"Responsive"};function Mt({open:e,onOpenChange:t,placement:r="top-right",showResolved:s=!1,syncSelectionToUrl:a=!1,responsivePresets:l=Tt}){var Re;const{adapter:u,config:m,currentUser:g,feedback:b,normalizedPath:A,permissions:x,createFeedback:f,updateFeedback:v,listMessages:c,createMessage:S,uploadAttachment:o}=Ee(),[C,w]=h.useState(),[y,E]=h.useState(),[F,B]=h.useState(""),[U,Rt]=h.useState("medium"),[_e,er]=h.useState("visual"),[je,Ue]=h.useState(""),[De,tr]=h.useState(((Re=l[0])==null?void 0:Re.value)??"desktop"),[k,q]=h.useState(),[M,_]=h.useState("review"),[rr,We]=h.useState(!1),[V,ze]=h.useState("all"),[Y,He]=h.useState("all"),[X,Oe]=h.useState("all"),[Q,Ke]=h.useState("all"),[Z,Je]=h.useState("all"),[nr,sr]=h.useState(!1),[ir,Ge]=h.useState({}),[le,de]=h.useState(""),te=h.useRef(null),qe=h.useRef(e),ce=h.useRef(a?new URL(window.location.href).searchParams.get("reviewLensFeedback"):null),$=!!g,P=x.includes("create"),Ve=x.includes("reply"),Ye=x.includes("update"),ar=x.includes("assign"),D=C??y,or=!!y,lr=!!(m.captureScreenshot&&(m.uploadAttachment||u.uploadAttachment)),dr=h.useMemo(()=>{const i=b.map(p=>p.assigneeEmail).filter(p=>!!p);return g!=null&&g.email&&i.push(g.email),Array.from(new Set(i)).sort((p,d)=>p.localeCompare(d))},[g==null?void 0:g.email,b]),T=h.useMemo(()=>b.filter(i=>s||i.status!=="resolved").filter(i=>V==="all"||i.status===V).filter(i=>Y==="all"||i.severity===Y).filter(i=>X==="all"||i.category===X).filter(i=>Q==="all"||i.assigneeEmail===Q).filter(i=>Z==="all"||i.viewportPreset===Z),[Q,X,b,Y,s,V,Z]),cr=[V,Y,X,Q,Z].filter(i=>i!=="all").length;h.useEffect(()=>{if(e){qe.current=!0;return}if(w(void 0),E(void 0),B(""),de(""),_("review"),a&&qe.current){const i=new URL(window.location.href);i.searchParams.has("reviewLensFeedback")&&(i.searchParams.delete("reviewLensFeedback"),window.history.replaceState({},"",i))}},[e,a]),h.useEffect(()=>{$||(w(void 0),E(void 0))},[$]),h.useEffect(()=>{!y||M!=="review"||window.requestAnimationFrame(()=>{var i,p,d;(p=(i=te.current)==null?void 0:i.scrollIntoView)==null||p.call(i,{block:"nearest"}),(d=te.current)==null||d.focus()})},[y,M]),h.useEffect(()=>{if(!k)return;let i=!0;return c(k.id).then(p=>{i&&Ge(d=>({...d,[k.id]:p}))}),()=>{i=!1}},[c,k]),h.useEffect(()=>{if(!a||!ce.current||b.length===0)return;const i=b.find(p=>p.id===ce.current);i&&(ce.current=null,t==null||t(!0),H(i,{syncUrl:!1}))},[b,a]),h.useEffect(()=>{if(!e||!a||k||b.length===0)return;const i=new URL(window.location.href).searchParams.get("reviewLensFeedback"),p=b.find(d=>d.id===i);p&&H(p,{syncUrl:!1})},[b,e,k,a]),h.useEffect(()=>{if(!e)return;function i(d){var N;if(d.key==="Shift"&&We(!0),d.key==="Escape"){d.preventDefault(),t==null||t(!1);return}Yt(d.target)||((d.key==="n"||d.key==="ArrowDown")&&(d.preventDefault(),Xe(1)),(d.key==="p"||d.key==="ArrowUp")&&(d.preventDefault(),Xe(-1)),d.key==="c"&&(d.preventDefault(),_("review"),(N=te.current)==null||N.focus()),d.key==="f"&&k&&Ye&&(d.preventDefault(),Ze(k)))}function p(d){d.key==="Shift"&&We(!1)}return window.addEventListener("keydown",i),window.addEventListener("keyup",p),()=>{window.removeEventListener("keydown",i),window.removeEventListener("keyup",p)}});const he=h.useCallback(i=>{const p=i.target instanceof Element?i.target:null;if(p)return p.closest("[data-review-lens-ui]")?null:p;const d=document.elementFromPoint(i.clientX,i.clientY);return!d||d.closest("[data-review-lens-ui]")?null:d},[]);if(h.useEffect(()=>{if(!e||!$)return;function i(d){const N=he(d);w(N?W(N):void 0)}function p(d){const N=he(d);N&&(d.preventDefault(),d.stopPropagation(),E(W(N)),_("review"))}return window.addEventListener("mousemove",i,!0),window.addEventListener("click",p,!0),()=>{window.removeEventListener("mousemove",i,!0),window.removeEventListener("click",p,!0)}},[$,he,e]),!e)return null;function H(i,p={syncUrl:!0}){var N;if(q(i),E(void 0),_("feedback"),a&&p.syncUrl!==!1){const re=new URL(window.location.href);re.searchParams.set("reviewLensFeedback",i.id),window.history.replaceState({},"",re)}const d=z(i.selector);if(!d){w(void 0);return}(N=d.scrollIntoView)==null||N.call(d,{behavior:"smooth",block:"center",inline:"center"}),window.requestAnimationFrame(()=>{w(W(d))})}function Xe(i){if(T.length===0)return;const p=k?T.findIndex(N=>N.id===k.id):-1,d=p<0?i>0?0:T.length-1:(p+i+T.length)%T.length;H(T[d])}async function Qe(){if(!y||!F.trim()||!g||!P)return;let i=await f({projectKey:m.projectKey,contentId:m.contentId,normalizedPath:A,originalUrl:m.currentUrl??window.location.href,selector:y.selector,selectorStrategy:y.selectorStrategy,elementFingerprint:y.fingerprint,createdCssSnapshot:y.cssSnapshot,comment:F.trim(),status:"open",severity:U,category:_e,assigneeEmail:je.trim()||void 0,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,viewportPreset:De,screenshotUrl:void 0,screenshotThumbnailUrl:void 0,authorEmail:g.email});if(m.captureScreenshot)try{const p=await m.captureScreenshot(y),d=await o(i.id,{type:"screenshot",data:p,createdBy:g.email});i=await v(i.id,{attachments:[d],screenshotUrl:d.url,screenshotThumbnailUrl:d.thumbnailUrl})}catch{}if(B(""),Ue(""),E(void 0),w(void 0),_("feedback"),q(i),a){const p=new URL(window.location.href);p.searchParams.set("reviewLensFeedback",i.id),window.history.replaceState({},"",p)}}async function hr(i,p){const d=new Date().toISOString(),N=p==="resolved"?{status:p,resolvedAt:d,resolvedBy:g==null?void 0:g.email}:{status:p},re=await v(i.id,N);q(re)}async function Ze(i){const p=z(i.selector);if(!p||!g)return;const d=W(p),N=await v(i.id,{status:"fixed",fixedCssSnapshot:d.cssSnapshot,fixedAt:new Date().toISOString(),fixedBy:g.email});q(N)}async function ur(i){if(!le.trim()||!g||!Ve)return;const p=await S({feedbackId:i.id,body:le.trim(),authorEmail:g.email});Ge(d=>({...d,[i.id]:[...d[i.id]??[],p]})),de("")}return n.jsxs("div",{className:"review-lens-root","data-review-lens-ui":!0,children:[$&&D?n.jsx(Ut,{target:D,locked:!!y}):null,$&&y&&C&&rr?n.jsx(Dt,{from:y,to:C}):null,$?n.jsxs(n.Fragment,{children:[n.jsx(Wt,{feedback:T,selectedFeedback:k,onSelect:H}),n.jsx(Ht,{feedback:T,selectedFeedback:k,onSelect:H})]}):null,n.jsxs("aside",{className:`review-lens-panel review-lens-panel--${r}`,"data-review-lens-ui":!0,children:[n.jsxs("header",{className:"review-lens-panel__header",children:[n.jsxs("div",{className:"review-lens-brand",children:[n.jsx(Ae,{className:"review-lens-brand__mark"}),n.jsxs("div",{children:[n.jsx("p",{className:"review-lens-kicker",children:"Review Lens"}),n.jsx("h2",{children:M==="summary"?"Summary":M==="feedback"?"Feedback":y?"Element locked":"Inspecting"})]})]}),n.jsx("button",{type:"button",onClick:()=>t==null?void 0:t(!1),children:"Close"})]}),n.jsxs("div",{className:"review-lens-panel__body",children:[n.jsxs("div",{className:"review-lens-mode-switch",role:"tablist","aria-label":"Review Lens mode",children:[n.jsx("button",{type:"button",role:"tab","aria-selected":M==="review",onClick:()=>_("review"),children:"Review"}),n.jsxs("button",{type:"button",role:"tab","aria-selected":M==="feedback",onClick:()=>_("feedback"),children:["Feedback ",n.jsx("span",{children:T.length})]}),n.jsx("button",{type:"button",role:"tab","aria-selected":M==="summary",onClick:()=>_("summary"),children:"Summary"})]}),M==="review"?n.jsxs("div",{className:"review-lens-review-pane",role:"tabpanel",children:[n.jsxs("div",{className:"review-lens-inspection",children:[$?null:n.jsx("p",{children:"Authenticate with Google to inspect this page."}),$&&D?n.jsxs(n.Fragment,{children:[n.jsx(Ot,{target:D}),n.jsx(Me,{title:"Accessibility",items:Kt(D)}),n.jsx(Me,{title:"Design tokens",items:Jt(D.cssSnapshot,m.designTokens)})]}):null,$&&!D?n.jsx("p",{children:"Move over the app to inspect."}):null]}),or?n.jsx("div",{className:"review-lens-composer-panel",children:n.jsxs("form",{className:"review-lens-feedback-form",onSubmit:i=>{i.preventDefault(),Qe()},children:[n.jsx("label",{htmlFor:"review-lens-comment",children:"New feedback"}),n.jsx("textarea",{ref:te,id:"review-lens-comment",value:F,disabled:!P,onChange:i=>B(i.target.value),onKeyDown:i=>{i.key==="Enter"&&i.metaKey&&(i.preventDefault(),Qe())},placeholder:P?"Describe the UX issue...":"You do not have permission to comment."}),n.jsxs("div",{className:"review-lens-form-grid",children:[n.jsxs("label",{children:["Severity",n.jsx("select",{value:U,onChange:i=>Rt(i.target.value),disabled:!P,children:Ie.map(i=>n.jsx("option",{value:i,children:O[i]},i))})]}),n.jsxs("label",{children:["Type",n.jsx("select",{value:_e,onChange:i=>er(i.target.value),disabled:!P,children:Te.map(i=>n.jsx("option",{value:i,children:K[i]},i))})]}),n.jsxs("label",{children:["Assignee",n.jsx("input",{value:je,onChange:i=>Ue(i.target.value),disabled:!P,placeholder:"optional@email.com"})]}),n.jsxs("label",{children:["Viewport",n.jsx("select",{value:De,onChange:i=>tr(i.target.value),disabled:!P,children:l.map(i=>n.jsx("option",{value:i.value,children:i.label},i.value))})]})]}),P?n.jsxs("p",{className:"review-lens-feedback-form__hint",children:["Press ",n.jsx("kbd",{children:"Command"})," + ",n.jsx("kbd",{children:"Enter"})," to submit.",lr?" Screenshot capture runs after save.":""]}):null,n.jsx("div",{className:"review-lens-actions",children:n.jsx("button",{type:"submit",disabled:!F.trim()||!P,children:"Save feedback"})})]})}):null]}):null,M==="feedback"?n.jsxs("div",{className:"review-lens-comments",children:[n.jsx($t,{open:nr,activeCount:cr,statusFilter:V,severityFilter:Y,categoryFilter:X,assigneeFilter:Q,viewportFilter:Z,assignees:dr,responsivePresets:l,onStatusChange:ze,onSeverityChange:He,onCategoryChange:Oe,onAssigneeChange:Ke,onViewportChange:Je,onToggle:()=>sr(i=>!i),onClear:()=>{ze("all"),He("all"),Oe("all"),Ke("all"),Je("all")}}),n.jsxs("div",{className:"review-lens-list-panel",children:[n.jsxs("div",{className:"review-lens-comments__header",children:[n.jsx("h3",{children:"All feedback"}),n.jsx("span",{children:T.length})]}),n.jsxs("div",{className:"review-lens-comments__list",children:[T.length===0?n.jsx("p",{children:"No feedback for this view."}):null,T.map(i=>n.jsx(Bt,{item:i,selected:(k==null?void 0:k.id)===i.id,onSelect:H},i.id))]})]}),k?n.jsxs("div",{className:"review-lens-selected-panel",children:[n.jsx("div",{className:"review-lens-selected-panel__label",children:"Selected feedback"}),n.jsx(Pt,{item:k,messages:ir[k.id]??[],messageDraft:le,canReply:Ve,canUpdate:Ye,canAssign:ar,syncSelectionToUrl:a,onMessageDraftChange:de,onSubmitMessage:()=>void ur(k),onStatusChange:i=>void hr(k,i),onAssigneeChange:i=>void v(k.id,{assigneeEmail:i.trim()||void 0}).then(q),onMarkFixed:()=>void Ze(k)},k.id)]}):n.jsxs("div",{className:"review-lens-selected-panel review-lens-selected-panel--empty",children:[n.jsx("div",{className:"review-lens-selected-panel__label",children:"Selected feedback"}),n.jsx("p",{children:"Select a feedback item above to review status, assignment, drift, and replies."})]})]}):null,M==="summary"?n.jsx(jt,{feedback:b}):null]})]})]})}function $t({open:e,activeCount:t,statusFilter:r,severityFilter:s,categoryFilter:a,assigneeFilter:l,viewportFilter:u,assignees:m,responsivePresets:g,onStatusChange:b,onSeverityChange:A,onCategoryChange:x,onAssigneeChange:f,onViewportChange:v,onToggle:c,onClear:S}){return n.jsxs("div",{className:"review-lens-filter-shell",children:[n.jsxs("div",{className:"review-lens-filter-bar",children:[n.jsxs("button",{type:"button","aria-expanded":e,onClick:c,children:["Filters",t>0?n.jsx("span",{children:t}):null]}),t>0?n.jsx("button",{type:"button",onClick:S,children:"Clear"}):null]}),e?n.jsxs("div",{className:"review-lens-filters",children:[n.jsxs("label",{children:["Status",n.jsxs("select",{"aria-label":"Filter status",value:r,onChange:o=>b(o.target.value),children:[n.jsx("option",{value:"all",children:"All statuses"}),Fe.map(o=>n.jsx("option",{value:o,children:R[o]},o))]})]}),n.jsxs("label",{children:["Priority",n.jsxs("select",{"aria-label":"Filter severity",value:s,onChange:o=>A(o.target.value),children:[n.jsx("option",{value:"all",children:"All priorities"}),Ie.map(o=>n.jsx("option",{value:o,children:O[o]},o))]})]}),n.jsxs("label",{children:["Type",n.jsxs("select",{"aria-label":"Filter type",value:a,onChange:o=>x(o.target.value),children:[n.jsx("option",{value:"all",children:"All types"}),Te.map(o=>n.jsx("option",{value:o,children:K[o]},o))]})]}),n.jsxs("label",{children:["Assignee",n.jsxs("select",{"aria-label":"Filter assignee",value:l,onChange:o=>f(o.target.value),children:[n.jsx("option",{value:"all",children:"All assignees"}),m.map(o=>n.jsx("option",{value:o,children:o},o))]})]}),n.jsxs("label",{children:["Viewport",n.jsxs("select",{"aria-label":"Filter viewport",value:u,onChange:o=>v(o.target.value),children:[n.jsx("option",{value:"all",children:"All viewports"}),g.map(o=>n.jsx("option",{value:o.value,children:o.label},o.value))]})]})]}):null]})}function Bt({item:e,selected:t,onSelect:r}){const s=$e(e);return n.jsxs("article",{tabIndex:0,className:["review-lens-comment",`review-lens-comment--${e.severity}`,t?"review-lens-comment--selected":""].filter(Boolean).join(" "),onClick:()=>r(e),onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),r(e))},children:[n.jsxs("div",{className:"review-lens-comment__header",children:[n.jsx("span",{children:R[e.status]}),n.jsx("strong",{children:O[e.severity]})]}),n.jsxs("div",{className:"review-lens-comment__content",children:[n.jsx("p",{children:e.comment}),n.jsxs("span",{children:[e.authorEmail,e.assigneeEmail?` -> ${e.assigneeEmail}`:""]})]}),n.jsxs("div",{className:"review-lens-tags",children:[n.jsx("span",{children:K[e.category]}),n.jsx("span",{children:e.viewportPreset}),n.jsx("span",{children:s.label})]})]})}function Pt({item:e,messages:t,messageDraft:r,canReply:s,canUpdate:a,canAssign:l,syncSelectionToUrl:u,onMessageDraftChange:m,onSubmitMessage:g,onStatusChange:b,onAssigneeChange:A,onMarkFixed:x}){const[f,v]=h.useState(!1),c=$e(e);function S(){const o=new URL(window.location.href);o.searchParams.set("reviewLensFeedback",e.id),_t(o.toString()).then(C=>{C&&(v(!0),setTimeout(()=>v(!1),2e3))})}return n.jsxs("section",{className:"review-lens-detail","aria-label":"Selected feedback detail",children:[n.jsxs("div",{className:"review-lens-detail__header",children:[n.jsxs("h3",{children:[K[e.category]," feedback"]}),n.jsxs("div",{className:"review-lens-detail__header-actions",children:[u?n.jsx("button",{type:"button",className:"review-lens-copy-link",onClick:S,"aria-label":"Copy link to this feedback",children:f?"Copied!":"Copy link"}):null,n.jsx("strong",{children:O[e.severity]})]})]}),n.jsx("blockquote",{children:e.comment}),n.jsxs("dl",{className:"review-lens-detail-meta",children:[n.jsxs("div",{children:[n.jsx("dt",{children:"Target"}),n.jsx("dd",{children:c.label})]}),n.jsxs("div",{children:[n.jsx("dt",{children:"Viewport"}),n.jsx("dd",{children:e.viewportPreset})]}),e.screenshotUrl?n.jsxs("div",{children:[n.jsx("dt",{children:"Evidence"}),n.jsx("dd",{children:n.jsx("a",{href:e.screenshotUrl,target:"_blank",rel:"noreferrer",children:"Screenshot"})})]}):null]}),n.jsxs("div",{className:"review-lens-form-grid",children:[n.jsxs("label",{children:["Status",n.jsx("select",{value:e.status,disabled:!a,onChange:o=>b(o.target.value),children:Fe.map(o=>n.jsx("option",{value:o,children:R[o]},o))})]}),n.jsxs("label",{children:["Assignee",n.jsx("input",{defaultValue:e.assigneeEmail??"",disabled:!l,onBlur:o=>A(o.target.value),placeholder:"optional@email.com"})]})]}),n.jsxs("div",{className:"review-lens-status-actions",children:[n.jsx("button",{type:"button",className:"review-lens-button-secondary",disabled:!a,onClick:x,children:"Mark fixed"}),n.jsx("button",{type:"button",className:"review-lens-button-primary",disabled:!a,onClick:()=>b("resolved"),children:"Resolve"})]}),n.jsxs("div",{className:"review-lens-thread",children:[n.jsxs("div",{className:"review-lens-thread__header",children:[n.jsx("h3",{children:"Thread"}),n.jsx("span",{children:t.length})]}),t.length===0?n.jsx("p",{children:"No replies yet."}):null,t.map(o=>n.jsxs("div",{className:"review-lens-thread__message",children:[n.jsx("p",{children:o.body}),n.jsx("span",{children:o.authorEmail})]},o.id)),n.jsx("textarea",{"aria-label":"Reply",value:r,disabled:!s,onChange:o=>m(o.target.value),placeholder:s?"Reply...":"You do not have permission to reply."}),n.jsx("div",{className:"review-lens-actions",children:n.jsx("button",{type:"button",disabled:!r.trim()||!s,onClick:g,children:"Reply"})})]})]})}async function _t(e){var r;if((r=navigator.clipboard)!=null&&r.writeText)return await navigator.clipboard.writeText(e),!0;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.opacity="0",document.body.append(t),t.select();try{return document.execCommand("copy")}finally{t.remove()}}function jt({feedback:e}){return n.jsxs("div",{className:"review-lens-summary",role:"tabpanel",children:[n.jsx(J,{title:"Status",values:G(e,t=>R[t.status])}),n.jsx(J,{title:"Severity",values:G(e,t=>O[t.severity])}),n.jsx(J,{title:"Type",values:G(e,t=>K[t.category])}),n.jsx(J,{title:"Assignee",values:G(e,t=>t.assigneeEmail??"Unassigned")}),n.jsx(J,{title:"Viewport",values:G(e,t=>t.viewportPreset)})]})}function J({title:e,values:t}){return n.jsxs("section",{children:[n.jsx("h3",{children:e}),n.jsx("dl",{children:t.map(([r,s])=>n.jsxs("div",{children:[n.jsx("dt",{children:r}),n.jsx("dd",{children:s})]},r))})]})}function Ut({target:e,locked:t}){const r=Zt(e),s=qt(e.fingerprint);return n.jsxs("div",{className:t?"review-lens-highlight review-lens-highlight--locked":"review-lens-highlight",style:{top:r.margin.top,left:r.margin.left,width:r.margin.width,height:r.margin.height},children:[n.jsx("div",{className:"review-lens-highlight__border",style:{top:r.border.top-r.margin.top,left:r.border.left-r.margin.left,width:r.border.width,height:r.border.height}}),n.jsx("div",{className:"review-lens-highlight__padding",style:{top:r.padding.top-r.margin.top,left:r.padding.left-r.margin.left,width:r.padding.width,height:r.padding.height}}),n.jsx("div",{className:"review-lens-highlight__content",style:{top:r.content.top-r.margin.top,left:r.content.left-r.margin.left,width:r.content.width,height:r.content.height}}),n.jsxs("div",{className:"review-lens-highlight__label",children:[n.jsx("strong",{children:s}),n.jsxs("span",{children:[Math.round(e.rect.width)," x ",Math.round(e.rect.height)]})]})]})}function Dt({from:e,to:t}){const r=Vt(e.rect,t.rect);return r.length===0?null:n.jsx(n.Fragment,{children:r.map(s=>n.jsx("div",{className:`review-lens-distance review-lens-distance--${s.axis}`,style:{top:s.top,left:s.left,width:s.width,height:s.height},children:n.jsx("span",{children:s.label})},s.key))})}function Wt({feedback:e,selectedFeedback:t,onSelect:r}){return n.jsx(n.Fragment,{children:e.map(s=>n.jsx(zt,{feedback:s,selected:(t==null?void 0:t.id)===s.id,onSelect:r},s.id))})}function zt({feedback:e,selected:t,onSelect:r}){const s=h.useRef(null);return h.useLayoutEffect(()=>{let a=0;const l=()=>{a=0;const m=s.current,g=z(e.selector),b=g==null?void 0:g.getBoundingClientRect();!m||!b||(m.style.top=`${b.top}px`,m.style.left=`${b.right}px`,m.hidden=b.bottom<0||b.top>window.innerHeight)},u=()=>{a||(a=window.requestAnimationFrame(l))};return l(),window.addEventListener("scroll",u,!0),window.addEventListener("resize",u),()=>{a&&window.cancelAnimationFrame(a),window.removeEventListener("scroll",u,!0),window.removeEventListener("resize",u)}},[e.selector]),n.jsx("button",{ref:s,type:"button",className:t?"review-lens-marker review-lens-marker--selected":"review-lens-marker",onClick:()=>r(e),"aria-label":`Open feedback from ${e.authorEmail}`})}function Ht({feedback:e,selectedFeedback:t,onSelect:r}){const s=e.map(a=>{const l=z(a.selector),u=l==null?void 0:l.getBoundingClientRect(),m=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,window.innerHeight);return!u||m<=0?null:{item:a,top:Math.min(100,Math.max(0,(u.top+window.scrollY)/m*100))}}).filter(a=>a!==null);return s.length===0?null:n.jsx("div",{className:"review-lens-minimap","data-review-lens-ui":!0,"aria-label":"Feedback map",children:s.map(a=>n.jsx("button",{type:"button",className:(t==null?void 0:t.id)===a.item.id?"review-lens-minimap__point review-lens-minimap__point--selected":"review-lens-minimap__point",style:{top:`${a.top}%`},onClick:()=>r(a.item),"aria-label":`Jump to feedback from ${a.item.authorEmail}`},a.item.id))})}function Ot({target:e}){const t=[["Selector",e.selector],["Size",`${e.cssSnapshot.width} x ${e.cssSnapshot.height}`],["Margin",e.cssSnapshot.margin],["Padding",e.cssSnapshot.padding],["Border",e.cssSnapshot.border],["Radius",e.cssSnapshot.borderRadius],["Font",`${e.cssSnapshot.fontSize} / ${e.cssSnapshot.lineHeight}`],["Family",e.cssSnapshot.fontFamily],["Color",e.cssSnapshot.color],["Background",e.cssSnapshot.backgroundColor]];return n.jsx("dl",{className:"review-lens-metrics",children:t.map(([r,s])=>n.jsxs("div",{children:[n.jsx("dt",{children:r}),n.jsx("dd",{children:s})]},r))})}function Me({title:e,items:t}){return n.jsxs("section",{className:"review-lens-insights",children:[n.jsx("h3",{children:e}),t.length===0?n.jsx("p",{children:"No issues detected."}):null,t.length>0?n.jsx("ul",{children:t.map(r=>n.jsx("li",{children:r},r))}):null]})}function z(e){try{return document.querySelector(e)}catch{return null}}function $e(e){const t=z(e.selector);if(!t)return{label:"Target missing",level:"warning"};const r=W(t);return r.fingerprint.tagName!==e.elementFingerprint.tagName?{label:"Element changed",level:"warning"}:Math.abs(r.fingerprint.width-e.elementFingerprint.width)>2||Math.abs(r.fingerprint.height-e.elementFingerprint.height)>2?{label:"Size changed",level:"warning"}:r.cssSnapshot.fontSize!==e.createdCssSnapshot.fontSize||r.cssSnapshot.color!==e.createdCssSnapshot.color||r.cssSnapshot.padding!==e.createdCssSnapshot.padding?{label:"Style changed",level:"warning"}:{label:"Target unchanged",level:"ok"}}function Kt(e){var g;const t=z(e.selector);if(!t)return["Selected element is no longer available."];const r=[],s=t.tagName.toLowerCase(),a=t.getAttribute("role"),l=["button","a","input","select","textarea"].includes(s)||a==="button"||a==="link",u=t.getAttribute("aria-label")||t.getAttribute("title")||((g=t.textContent)==null?void 0:g.trim());l&&!u&&r.push("Interactive element has no accessible name."),l&&(e.rect.width<44||e.rect.height<44)&&r.push("Tap target is smaller than 44 x 44."),s==="img"&&!t.getAttribute("alt")&&r.push("Image is missing alt text.");const m=/^h[1-6]$/.test(s)?Number(s.slice(1)):0;return m>1&&!document.querySelector(`h${m-1}`)&&r.push("Heading may skip the previous level."),Xt(e.cssSnapshot.color,e.cssSnapshot.backgroundColor)&&r.push("Text contrast may be low."),r}function Jt(e,t={}){const r=[];return j("Padding",e.padding,t.spacing,r,{allowComposite:!0}),j("Margin",e.margin,t.spacing,r,{allowComposite:!0}),j("Font size",e.fontSize,t.fontSize,r),j("Line height",e.lineHeight,t.lineHeight,r),j("Text color",e.color,t.color,r),j("Background",e.backgroundColor,t.color,r),j("Radius",e.borderRadius,t.radius,r,{allowComposite:!0}),r}function j(e,t,r,s,a={}){!r||r.length===0||!t||Gt(t,r,a)||s.push(`${e} ${t} is outside configured tokens.`)}function Gt(e,t,r={}){if(t.includes(e))return!0;if(!r.allowComposite)return!1;const s=e.trim().split(/\s+/);return s.length>1&&s.every(a=>t.includes(a))}function qt(e){const t=e.id?`#${e.id}`:"",r=e.className?`.${e.className.split(/\s+/).filter(Boolean).slice(0,2).join(".")}`:"",s=e.ariaLabel?`[aria-label="${e.ariaLabel}"]`:"";return`${e.tagName}${t}${r}${s}`||e.tagName}function Vt(e,t){const r=[],s=(Math.max(e.left,t.left)+Math.min(e.right,t.right))/2,a=(Math.max(e.top,t.top)+Math.min(e.bottom,t.bottom))/2;if(e.right<=t.left||t.right<=e.left){const l=e.right<=t.left?e.right:t.right,u=e.right<=t.left?t.left:e.left;r.push({key:"horizontal",axis:"horizontal",top:Be(a,0,window.innerHeight),left:l,width:Math.max(u-l,1),height:1,label:`${Math.round(u-l)}px`})}if(e.bottom<=t.top||t.bottom<=e.top){const l=e.bottom<=t.top?e.bottom:t.bottom,u=e.bottom<=t.top?t.top:e.top;r.push({key:"vertical",axis:"vertical",top:l,left:Be(s,0,window.innerWidth),width:1,height:Math.max(u-l,1),label:`${Math.round(u-l)}px`})}return r}function Be(e,t,r){return Math.min(Math.max(e,t),r)}function G(e,t){const r=new Map;for(const s of e){const a=t(s);r.set(a,(r.get(a)??0)+1)}return Array.from(r.entries()).sort((s,a)=>a[1]-s[1]||s[0].localeCompare(a[0]))}function Yt(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||e instanceof HTMLElement&&e.isContentEditable}function Xt(e,t){const r=Pe(e),s=Pe(t);return!r||!s||s.alpha===0?!1:Qt(r,s)<4.5}function Pe(e){const t=e.match(/rgba?\(([^)]+)\)/);if(!t)return null;const[r,s,a,l="1"]=t[1].split(",").map(u=>u.trim());return{red:Number(r),green:Number(s),blue:Number(a),alpha:Number(l)}}function Qt(e,t){const r=Math.max(ee(e),ee(t)),s=Math.min(ee(e),ee(t));return(r+.05)/(s+.05)}function ee(e){const t=[e.red,e.green,e.blue].map(r=>{const s=r/255;return s<=.03928?s/12.92:((s+.055)/1.055)**2.4});return t[0]*.2126+t[1]*.7152+t[2]*.0722}function Zt(e){const t={top:I(e.cssSnapshot.marginTop),right:I(e.cssSnapshot.marginRight),bottom:I(e.cssSnapshot.marginBottom),left:I(e.cssSnapshot.marginLeft)},r={top:I(e.cssSnapshot.borderTopWidth),right:I(e.cssSnapshot.borderRightWidth),bottom:I(e.cssSnapshot.borderBottomWidth),left:I(e.cssSnapshot.borderLeftWidth)},s={top:I(e.cssSnapshot.paddingTop),right:I(e.cssSnapshot.paddingRight),bottom:I(e.cssSnapshot.paddingBottom),left:I(e.cssSnapshot.paddingLeft)},a={top:e.rect.top,left:e.rect.left,width:Math.max(e.rect.width,0),height:Math.max(e.rect.height,0)},l={top:a.top-t.top,left:a.left-t.left,width:a.width+t.left+t.right,height:a.height+t.top+t.bottom},u={top:a.top+r.top,left:a.left+r.left,width:Math.max(a.width-r.left-r.right,0),height:Math.max(a.height-r.top-r.bottom,0)},m={top:u.top+s.top,left:u.left+s.left,width:Math.max(u.width-s.left-s.right,0),height:Math.max(u.height-s.top-s.bottom,0)};return{margin:l,border:a,padding:u,content:m}}function I(e){const t=Number.parseFloat(e);return Number.isFinite(t)?t:0}L.ReviewLensLogo=Ae,L.ReviewLensOverlay=Mt,L.ReviewLensProvider=bt,L.buildElementTarget=W,L.createGoogleSheetsAdapter=fe,L.normalizeReviewUrl=Se,L.useReviewLens=Ee,Object.defineProperty(L,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "review-lens-react",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "React overlay for UX review feedback backed by Google Sheets.",
5
5
  "repository": {
6
6
  "type": "git",