@pixelmatters/markup 1.0.1 → 1.1.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/dist/react.js CHANGED
@@ -2752,14 +2752,22 @@ function Ar(e) {
2752
2752
  ...r.headers ?? {}
2753
2753
  }, a = e.getToken?.() ?? null, o = a != null && a.token.length > 0 && a.expiresAt > Date.now();
2754
2754
  o && a && (i.authorization = `Bearer ${a.token}`);
2755
- let s = await fetch(`${t}${n}`, {
2755
+ let s = e.getAnonToken?.() ?? null;
2756
+ s && (i["x-markup-anon-token"] = s);
2757
+ let c = await fetch(`${t}${n}`, {
2756
2758
  ...r,
2757
2759
  headers: i
2758
- }), c = await s.text(), l = c ? jr(c) : null;
2759
- if (!s.ok) throw s.status === 401 && o && e.onUnauthorized?.(), new kr((l && typeof l == "object" && "error" in l && typeof l.error == "string" ? l.error : null) ?? `Request failed with ${s.status}`, s.status);
2760
- return l;
2760
+ }), l = await c.text(), u = l ? jr(l) : null;
2761
+ if (!c.ok) throw c.status === 401 && o && e.onUnauthorized?.(), new kr((u && typeof u == "object" && "error" in u && typeof u.error == "string" ? u.error : null) ?? `Request failed with ${c.status}`, c.status);
2762
+ return u;
2761
2763
  }
2762
2764
  return {
2765
+ mintAnonIdentity() {
2766
+ return n("/widget/anon-identity", { method: "POST" });
2767
+ },
2768
+ getSubscriptionToken() {
2769
+ return n("/widget/subscription-token", { method: "POST" });
2770
+ },
2763
2771
  getScreenshotUploadUrl() {
2764
2772
  return n("/widget/screenshots/upload-url", { method: "POST" });
2765
2773
  },
@@ -2793,11 +2801,8 @@ function Ar(e) {
2793
2801
  body: JSON.stringify(r)
2794
2802
  });
2795
2803
  },
2796
- deleteComment(e, t, r = {}) {
2797
- return n(`/widget/threads/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`, {
2798
- method: "DELETE",
2799
- body: JSON.stringify(r)
2800
- });
2804
+ deleteComment(e, t) {
2805
+ return n(`/widget/threads/${encodeURIComponent(e)}/comments/${encodeURIComponent(t)}`, { method: "DELETE" });
2801
2806
  },
2802
2807
  toggleReaction(e, t) {
2803
2808
  return n(`/widget/comments/${encodeURIComponent(e)}/reactions`, {
@@ -2832,20 +2837,26 @@ function Pr(e) {
2832
2837
  localStorage.setItem(Mr, JSON.stringify(e));
2833
2838
  } catch {}
2834
2839
  }
2835
- function Fr() {
2836
- let e = crypto;
2837
- if ("randomUUID" in e && typeof e.randomUUID == "function") return e.randomUUID();
2838
- let t = new Uint8Array(16);
2839
- e.getRandomValues(t), t[6] = t[6] & 15 | 64, t[8] = t[8] & 63 | 128;
2840
- let n = Array.from(t, (e) => e.toString(16).padStart(2, "0")).join("");
2841
- return `${n.slice(0, 8)}-${n.slice(8, 12)}-${n.slice(12, 16)}-${n.slice(16, 20)}-${n.slice(20)}`;
2842
- }
2843
2840
  //#endregion
2844
2841
  //#region src/runtime/popup-auth.ts
2845
- function Ir(e, t) {
2846
- let n = new URL(e).origin, r = new URL("/widget/auth", e);
2847
- r.searchParams.set("apiKey", t), r.searchParams.set("origin", window.location.origin);
2848
- let i = Math.max(0, window.screenX + (window.outerWidth - 420) / 2), a = Math.max(0, window.screenY + (window.outerHeight - 560) / 2), o = window.open(r.toString(), "markup-auth", `width=420,height=560,left=${i},top=${a}`);
2842
+ async function Fr(e, t) {
2843
+ let n = new URL(e).origin, r;
2844
+ try {
2845
+ let n = await fetch(`${e.replace(/\/+$/, "")}/widget/popup-exchange`, {
2846
+ method: "POST",
2847
+ headers: {
2848
+ "content-type": "application/json",
2849
+ "x-markup-api-key": t
2850
+ },
2851
+ body: "{}"
2852
+ });
2853
+ if (!n.ok) throw Error(`popup-exchange responded with ${n.status}`);
2854
+ let { code: i } = await n.json(), a = new URL("/widget/auth", e);
2855
+ a.searchParams.set("code", i), r = a.toString();
2856
+ } catch (e) {
2857
+ return Promise.reject(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to start popup exchange"));
2858
+ }
2859
+ let i = Math.max(0, window.screenX + (window.outerWidth - 420) / 2), a = Math.max(0, window.screenY + (window.outerHeight - 560) / 2), o = window.open(r, "markup-auth", `width=420,height=560,left=${i},top=${a}`);
2849
2860
  return o ? new Promise((e, t) => {
2850
2861
  function r() {
2851
2862
  window.removeEventListener("message", i), clearInterval(a);
@@ -2867,14 +2878,14 @@ function Ir(e, t) {
2867
2878
  }
2868
2879
  //#endregion
2869
2880
  //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/util.js
2870
- function Lr(e, t) {
2881
+ function Ir(e, t) {
2871
2882
  if (e.match(/^[a-z]+:\/\//i)) return e;
2872
2883
  if (e.match(/^\/\//)) return window.location.protocol + e;
2873
2884
  if (e.match(/^[a-z]+:/i)) return e;
2874
2885
  let n = document.implementation.createHTMLDocument(), r = n.createElement("base"), i = n.createElement("a");
2875
2886
  return n.head.appendChild(r), n.body.appendChild(i), t && (r.href = t), i.href = e, i.href;
2876
2887
  }
2877
- var Rr = (() => {
2888
+ var Lr = (() => {
2878
2889
  let e = 0, t = () => `0000${(Math.random() * 36 ** 4 << 0).toString(36)}`.slice(-4);
2879
2890
  return () => (e += 1, `u${t()}${e}`);
2880
2891
  })();
@@ -2883,29 +2894,29 @@ function Y(e) {
2883
2894
  for (let n = 0, r = e.length; n < r; n++) t.push(e[n]);
2884
2895
  return t;
2885
2896
  }
2886
- var zr = null;
2887
- function Br(e = {}) {
2888
- return zr || (e.includeStyleProperties ? (zr = e.includeStyleProperties, zr) : (zr = Y(window.getComputedStyle(document.documentElement)), zr));
2897
+ var Rr = null;
2898
+ function zr(e = {}) {
2899
+ return Rr || (e.includeStyleProperties ? (Rr = e.includeStyleProperties, Rr) : (Rr = Y(window.getComputedStyle(document.documentElement)), Rr));
2889
2900
  }
2890
- function Vr(e, t) {
2901
+ function Br(e, t) {
2891
2902
  let n = (e.ownerDocument.defaultView || window).getComputedStyle(e).getPropertyValue(t);
2892
2903
  return n ? parseFloat(n.replace("px", "")) : 0;
2893
2904
  }
2894
- function Hr(e) {
2895
- let t = Vr(e, "border-left-width"), n = Vr(e, "border-right-width");
2905
+ function Vr(e) {
2906
+ let t = Br(e, "border-left-width"), n = Br(e, "border-right-width");
2896
2907
  return e.clientWidth + t + n;
2897
2908
  }
2898
- function Ur(e) {
2899
- let t = Vr(e, "border-top-width"), n = Vr(e, "border-bottom-width");
2909
+ function Hr(e) {
2910
+ let t = Br(e, "border-top-width"), n = Br(e, "border-bottom-width");
2900
2911
  return e.clientHeight + t + n;
2901
2912
  }
2902
- function Wr(e, t = {}) {
2913
+ function Ur(e, t = {}) {
2903
2914
  return {
2904
- width: t.width || Hr(e),
2905
- height: t.height || Ur(e)
2915
+ width: t.width || Vr(e),
2916
+ height: t.height || Hr(e)
2906
2917
  };
2907
2918
  }
2908
- function Gr() {
2919
+ function Wr() {
2909
2920
  let e, t;
2910
2921
  try {
2911
2922
  t = process;
@@ -2914,10 +2925,10 @@ function Gr() {
2914
2925
  return n && (e = parseInt(n, 10), Number.isNaN(e) && (e = 1)), e || window.devicePixelRatio || 1;
2915
2926
  }
2916
2927
  var X = 16384;
2917
- function Kr(e) {
2928
+ function Gr(e) {
2918
2929
  (e.width > X || e.height > X) && (e.width > X && e.height > X ? e.width > e.height ? (e.height *= X / e.width, e.width = X) : (e.width *= X / e.height, e.height = X) : e.width > X ? (e.height *= X / e.width, e.width = X) : (e.width *= X / e.height, e.height = X));
2919
2930
  }
2920
- function qr(e) {
2931
+ function Kr(e) {
2921
2932
  return new Promise((t, n) => {
2922
2933
  let r = new Image();
2923
2934
  r.onload = () => {
@@ -2927,12 +2938,12 @@ function qr(e) {
2927
2938
  }, r.onerror = n, r.crossOrigin = "anonymous", r.decoding = "async", r.src = e;
2928
2939
  });
2929
2940
  }
2930
- async function Jr(e) {
2941
+ async function qr(e) {
2931
2942
  return Promise.resolve().then(() => new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then((e) => `data:image/svg+xml;charset=utf-8,${e}`);
2932
2943
  }
2933
- async function Yr(e, t, n) {
2944
+ async function Jr(e, t, n) {
2934
2945
  let r = "http://www.w3.org/2000/svg", i = document.createElementNS(r, "svg"), a = document.createElementNS(r, "foreignObject");
2935
- return i.setAttribute("width", `${t}`), i.setAttribute("height", `${n}`), i.setAttribute("viewBox", `0 0 ${t} ${n}`), a.setAttribute("width", "100%"), a.setAttribute("height", "100%"), a.setAttribute("x", "0"), a.setAttribute("y", "0"), a.setAttribute("externalResourcesRequired", "true"), i.appendChild(a), a.appendChild(e), Jr(i);
2946
+ return i.setAttribute("width", `${t}`), i.setAttribute("height", `${n}`), i.setAttribute("viewBox", `0 0 ${t} ${n}`), a.setAttribute("width", "100%"), a.setAttribute("height", "100%"), a.setAttribute("x", "0"), a.setAttribute("y", "0"), a.setAttribute("externalResourcesRequired", "true"), i.appendChild(a), a.appendChild(e), qr(i);
2936
2947
  }
2937
2948
  var Z = (e, t) => {
2938
2949
  if (e instanceof t) return !0;
@@ -2941,66 +2952,66 @@ var Z = (e, t) => {
2941
2952
  };
2942
2953
  //#endregion
2943
2954
  //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/clone-pseudos.js
2944
- function Xr(e) {
2955
+ function Yr(e) {
2945
2956
  let t = e.getPropertyValue("content");
2946
2957
  return `${e.cssText} content: '${t.replace(/'|"/g, "")}';`;
2947
2958
  }
2948
- function Zr(e, t) {
2949
- return Br(t).map((t) => `${t}: ${e.getPropertyValue(t)}${e.getPropertyPriority(t) ? " !important" : ""};`).join(" ");
2959
+ function Xr(e, t) {
2960
+ return zr(t).map((t) => `${t}: ${e.getPropertyValue(t)}${e.getPropertyPriority(t) ? " !important" : ""};`).join(" ");
2950
2961
  }
2951
- function Qr(e, t, n, r) {
2952
- let i = `.${e}:${t}`, a = n.cssText ? Xr(n) : Zr(n, r);
2962
+ function Zr(e, t, n, r) {
2963
+ let i = `.${e}:${t}`, a = n.cssText ? Yr(n) : Xr(n, r);
2953
2964
  return document.createTextNode(`${i}{${a}}`);
2954
2965
  }
2955
- function $r(e, t, n, r) {
2966
+ function Qr(e, t, n, r) {
2956
2967
  let i = window.getComputedStyle(e, n), a = i.getPropertyValue("content");
2957
2968
  if (a === "" || a === "none") return;
2958
- let o = Rr();
2969
+ let o = Lr();
2959
2970
  try {
2960
2971
  t.className = `${t.className} ${o}`;
2961
2972
  } catch {
2962
2973
  return;
2963
2974
  }
2964
2975
  let s = document.createElement("style");
2965
- s.appendChild(Qr(o, n, i, r)), t.appendChild(s);
2976
+ s.appendChild(Zr(o, n, i, r)), t.appendChild(s);
2966
2977
  }
2967
- function ei(e, t, n) {
2968
- $r(e, t, ":before", n), $r(e, t, ":after", n);
2978
+ function $r(e, t, n) {
2979
+ Qr(e, t, ":before", n), Qr(e, t, ":after", n);
2969
2980
  }
2970
2981
  //#endregion
2971
2982
  //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/mimes.js
2972
- var ti = "application/font-woff", ni = "image/jpeg", ri = {
2973
- woff: ti,
2974
- woff2: ti,
2983
+ var ei = "application/font-woff", ti = "image/jpeg", ni = {
2984
+ woff: ei,
2985
+ woff2: ei,
2975
2986
  ttf: "application/font-truetype",
2976
2987
  eot: "application/vnd.ms-fontobject",
2977
2988
  png: "image/png",
2978
- jpg: ni,
2979
- jpeg: ni,
2989
+ jpg: ti,
2990
+ jpeg: ti,
2980
2991
  gif: "image/gif",
2981
2992
  tiff: "image/tiff",
2982
2993
  svg: "image/svg+xml",
2983
2994
  webp: "image/webp"
2984
2995
  };
2985
- function ii(e) {
2996
+ function ri(e) {
2986
2997
  let t = /\.([^./]*?)$/g.exec(e);
2987
2998
  return t ? t[1] : "";
2988
2999
  }
2989
- function ai(e) {
2990
- return ri[ii(e).toLowerCase()] || "";
3000
+ function ii(e) {
3001
+ return ni[ri(e).toLowerCase()] || "";
2991
3002
  }
2992
3003
  //#endregion
2993
3004
  //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/dataurl.js
2994
- function oi(e) {
3005
+ function ai(e) {
2995
3006
  return e.split(/,/)[1];
2996
3007
  }
2997
- function si(e) {
3008
+ function oi(e) {
2998
3009
  return e.search(/^(data:)/) !== -1;
2999
3010
  }
3000
- function ci(e, t) {
3011
+ function si(e, t) {
3001
3012
  return `data:${t};base64,${e}`;
3002
3013
  }
3003
- async function li(e, t, n) {
3014
+ async function ci(e, t, n) {
3004
3015
  let r = await fetch(e, t);
3005
3016
  if (r.status === 404) throw Error(`Resource "${r.url}" not found`);
3006
3017
  let i = await r.blob();
@@ -3018,78 +3029,78 @@ async function li(e, t, n) {
3018
3029
  }, a.readAsDataURL(i);
3019
3030
  });
3020
3031
  }
3021
- var ui = {};
3022
- function di(e, t, n) {
3032
+ var li = {};
3033
+ function ui(e, t, n) {
3023
3034
  let r = e.replace(/\?.*/, "");
3024
3035
  return n && (r = e), /ttf|otf|eot|woff2?/i.test(r) && (r = r.replace(/.*\//, "")), t ? `[${t}]${r}` : r;
3025
3036
  }
3026
- async function fi(e, t, n) {
3027
- let r = di(e, t, n.includeQueryParams);
3028
- if (ui[r] != null) return ui[r];
3037
+ async function di(e, t, n) {
3038
+ let r = ui(e, t, n.includeQueryParams);
3039
+ if (li[r] != null) return li[r];
3029
3040
  n.cacheBust && (e += (/\?/.test(e) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime());
3030
3041
  let i;
3031
3042
  try {
3032
- i = ci(await li(e, n.fetchRequestInit, ({ res: e, result: n }) => (t ||= e.headers.get("Content-Type") || "", oi(n))), t);
3043
+ i = si(await ci(e, n.fetchRequestInit, ({ res: e, result: n }) => (t ||= e.headers.get("Content-Type") || "", ai(n))), t);
3033
3044
  } catch (t) {
3034
3045
  i = n.imagePlaceholder || "";
3035
3046
  let r = `Failed to fetch resource: ${e}`;
3036
3047
  t && (r = typeof t == "string" ? t : t.message), r && console.warn(r);
3037
3048
  }
3038
- return ui[r] = i, i;
3049
+ return li[r] = i, i;
3039
3050
  }
3040
3051
  //#endregion
3041
3052
  //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/clone-node.js
3042
- async function pi(e) {
3053
+ async function fi(e) {
3043
3054
  let t = e.toDataURL();
3044
- return t === "data:," ? e.cloneNode(!1) : qr(t);
3055
+ return t === "data:," ? e.cloneNode(!1) : Kr(t);
3045
3056
  }
3046
- async function mi(e, t) {
3057
+ async function pi(e, t) {
3047
3058
  if (e.currentSrc) {
3048
3059
  let t = document.createElement("canvas"), n = t.getContext("2d");
3049
- return t.width = e.clientWidth, t.height = e.clientHeight, n?.drawImage(e, 0, 0, t.width, t.height), qr(t.toDataURL());
3060
+ return t.width = e.clientWidth, t.height = e.clientHeight, n?.drawImage(e, 0, 0, t.width, t.height), Kr(t.toDataURL());
3050
3061
  }
3051
3062
  let n = e.poster;
3052
- return qr(await fi(n, ai(n), t));
3063
+ return Kr(await di(n, ii(n), t));
3053
3064
  }
3054
- async function hi(e, t) {
3065
+ async function mi(e, t) {
3055
3066
  try {
3056
- if (e?.contentDocument?.body) return await Ti(e.contentDocument.body, t, !0);
3067
+ if (e?.contentDocument?.body) return await wi(e.contentDocument.body, t, !0);
3057
3068
  } catch {}
3058
3069
  return e.cloneNode(!1);
3059
3070
  }
3060
- async function gi(e, t) {
3061
- return Z(e, HTMLCanvasElement) ? pi(e) : Z(e, HTMLVideoElement) ? mi(e, t) : Z(e, HTMLIFrameElement) ? hi(e, t) : e.cloneNode(vi(e));
3071
+ async function hi(e, t) {
3072
+ return Z(e, HTMLCanvasElement) ? fi(e) : Z(e, HTMLVideoElement) ? pi(e, t) : Z(e, HTMLIFrameElement) ? mi(e, t) : e.cloneNode(_i(e));
3062
3073
  }
3063
- var _i = (e) => e.tagName != null && e.tagName.toUpperCase() === "SLOT", vi = (e) => e.tagName != null && e.tagName.toUpperCase() === "SVG";
3064
- async function yi(e, t, n) {
3065
- if (vi(t)) return t;
3074
+ var gi = (e) => e.tagName != null && e.tagName.toUpperCase() === "SLOT", _i = (e) => e.tagName != null && e.tagName.toUpperCase() === "SVG";
3075
+ async function vi(e, t, n) {
3076
+ if (_i(t)) return t;
3066
3077
  let r = [];
3067
- return r = _i(e) && e.assignedNodes ? Y(e.assignedNodes()) : Z(e, HTMLIFrameElement) && e.contentDocument?.body ? Y(e.contentDocument.body.childNodes) : Y((e.shadowRoot ?? e).childNodes), r.length === 0 || Z(e, HTMLVideoElement) || await r.reduce((e, r) => e.then(() => Ti(r, n)).then((e) => {
3078
+ return r = gi(e) && e.assignedNodes ? Y(e.assignedNodes()) : Z(e, HTMLIFrameElement) && e.contentDocument?.body ? Y(e.contentDocument.body.childNodes) : Y((e.shadowRoot ?? e).childNodes), r.length === 0 || Z(e, HTMLVideoElement) || await r.reduce((e, r) => e.then(() => wi(r, n)).then((e) => {
3068
3079
  e && t.appendChild(e);
3069
3080
  }), Promise.resolve()), t;
3070
3081
  }
3071
- function bi(e, t, n) {
3082
+ function yi(e, t, n) {
3072
3083
  let r = t.style;
3073
3084
  if (!r) return;
3074
3085
  let i = window.getComputedStyle(e);
3075
- i.cssText ? (r.cssText = i.cssText, r.transformOrigin = i.transformOrigin) : Br(n).forEach((n) => {
3086
+ i.cssText ? (r.cssText = i.cssText, r.transformOrigin = i.transformOrigin) : zr(n).forEach((n) => {
3076
3087
  let a = i.getPropertyValue(n);
3077
3088
  n === "font-size" && a.endsWith("px") && (a = `${Math.floor(parseFloat(a.substring(0, a.length - 2))) - .1}px`), Z(e, HTMLIFrameElement) && n === "display" && a === "inline" && (a = "block"), n === "d" && t.getAttribute("d") && (a = `path(${t.getAttribute("d")})`), r.setProperty(n, a, i.getPropertyPriority(n));
3078
3089
  });
3079
3090
  }
3080
- function xi(e, t) {
3091
+ function bi(e, t) {
3081
3092
  Z(e, HTMLTextAreaElement) && (t.innerHTML = e.value), Z(e, HTMLInputElement) && t.setAttribute("value", e.value);
3082
3093
  }
3083
- function Si(e, t) {
3094
+ function xi(e, t) {
3084
3095
  if (Z(e, HTMLSelectElement)) {
3085
3096
  let n = t, r = Array.from(n.children).find((t) => e.value === t.getAttribute("value"));
3086
3097
  r && r.setAttribute("selected", "");
3087
3098
  }
3088
3099
  }
3089
- function Ci(e, t, n) {
3090
- return Z(t, Element) && (bi(e, t, n), ei(e, t, n), xi(e, t), Si(e, t)), t;
3100
+ function Si(e, t, n) {
3101
+ return Z(t, Element) && (yi(e, t, n), $r(e, t, n), bi(e, t), xi(e, t)), t;
3091
3102
  }
3092
- async function wi(e, t) {
3103
+ async function Ci(e, t) {
3093
3104
  let n = e.querySelectorAll ? e.querySelectorAll("use") : [];
3094
3105
  if (n.length === 0) return e;
3095
3106
  let r = {};
@@ -3097,7 +3108,7 @@ async function wi(e, t) {
3097
3108
  let a = n[i].getAttribute("xlink:href");
3098
3109
  if (a) {
3099
3110
  let n = e.querySelector(a), i = document.querySelector(a);
3100
- !n && i && !r[a] && (r[a] = await Ti(i, t, !0));
3111
+ !n && i && !r[a] && (r[a] = await wi(i, t, !0));
3101
3112
  }
3102
3113
  }
3103
3114
  let i = Object.values(r);
@@ -3111,61 +3122,61 @@ async function wi(e, t) {
3111
3122
  }
3112
3123
  return e;
3113
3124
  }
3114
- async function Ti(e, t, n) {
3115
- return !n && t.filter && !t.filter(e) ? null : Promise.resolve(e).then((e) => gi(e, t)).then((n) => yi(e, n, t)).then((n) => Ci(e, n, t)).then((e) => wi(e, t));
3125
+ async function wi(e, t, n) {
3126
+ return !n && t.filter && !t.filter(e) ? null : Promise.resolve(e).then((e) => hi(e, t)).then((n) => vi(e, n, t)).then((n) => Si(e, n, t)).then((e) => Ci(e, t));
3116
3127
  }
3117
3128
  //#endregion
3118
3129
  //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/embed-resources.js
3119
- var Ei = /url\((['"]?)([^'"]+?)\1\)/g, Di = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, Oi = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
3120
- function ki(e) {
3130
+ var Ti = /url\((['"]?)([^'"]+?)\1\)/g, Ei = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, Di = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
3131
+ function Oi(e) {
3121
3132
  let t = e.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
3122
3133
  return RegExp(`(url\\(['"]?)(${t})(['"]?\\))`, "g");
3123
3134
  }
3124
- function Ai(e) {
3135
+ function ki(e) {
3125
3136
  let t = [];
3126
- return e.replace(Ei, (e, n, r) => (t.push(r), e)), t.filter((e) => !si(e));
3137
+ return e.replace(Ti, (e, n, r) => (t.push(r), e)), t.filter((e) => !oi(e));
3127
3138
  }
3128
- async function ji(e, t, n, r, i) {
3139
+ async function Ai(e, t, n, r, i) {
3129
3140
  try {
3130
- let a = n ? Lr(t, n) : t, o = ai(t), s;
3131
- return s = i ? ci(await i(a), o) : await fi(a, o, r), e.replace(ki(t), `$1${s}$3`);
3141
+ let a = n ? Ir(t, n) : t, o = ii(t), s;
3142
+ return s = i ? si(await i(a), o) : await di(a, o, r), e.replace(Oi(t), `$1${s}$3`);
3132
3143
  } catch {}
3133
3144
  return e;
3134
3145
  }
3135
- function Mi(e, { preferredFontFormat: t }) {
3136
- return t ? e.replace(Oi, (e) => {
3146
+ function ji(e, { preferredFontFormat: t }) {
3147
+ return t ? e.replace(Di, (e) => {
3137
3148
  for (;;) {
3138
- let [n, , r] = Di.exec(e) || [];
3149
+ let [n, , r] = Ei.exec(e) || [];
3139
3150
  if (!r) return "";
3140
3151
  if (r === t) return `src: ${n};`;
3141
3152
  }
3142
3153
  }) : e;
3143
3154
  }
3144
- function Ni(e) {
3145
- return e.search(Ei) !== -1;
3155
+ function Mi(e) {
3156
+ return e.search(Ti) !== -1;
3146
3157
  }
3147
- async function Pi(e, t, n) {
3148
- if (!Ni(e)) return e;
3149
- let r = Mi(e, n);
3150
- return Ai(r).reduce((e, r) => e.then((e) => ji(e, r, t, n)), Promise.resolve(r));
3158
+ async function Ni(e, t, n) {
3159
+ if (!Mi(e)) return e;
3160
+ let r = ji(e, n);
3161
+ return ki(r).reduce((e, r) => e.then((e) => Ai(e, r, t, n)), Promise.resolve(r));
3151
3162
  }
3152
3163
  //#endregion
3153
3164
  //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/embed-images.js
3154
- async function Fi(e, t, n) {
3165
+ async function Pi(e, t, n) {
3155
3166
  let r = t.style?.getPropertyValue(e);
3156
3167
  if (r) {
3157
- let i = await Pi(r, null, n);
3168
+ let i = await Ni(r, null, n);
3158
3169
  return t.style.setProperty(e, i, t.style.getPropertyPriority(e)), !0;
3159
3170
  }
3160
3171
  return !1;
3161
3172
  }
3162
- async function Ii(e, t) {
3163
- await Fi("background", e, t) || await Fi("background-image", e, t), await Fi("mask", e, t) || await Fi("-webkit-mask", e, t) || await Fi("mask-image", e, t) || await Fi("-webkit-mask-image", e, t);
3173
+ async function Fi(e, t) {
3174
+ await Pi("background", e, t) || await Pi("background-image", e, t), await Pi("mask", e, t) || await Pi("-webkit-mask", e, t) || await Pi("mask-image", e, t) || await Pi("-webkit-mask-image", e, t);
3164
3175
  }
3165
- async function Li(e, t) {
3176
+ async function Ii(e, t) {
3166
3177
  let n = Z(e, HTMLImageElement);
3167
- if (!(n && !si(e.src)) && !(Z(e, SVGImageElement) && !si(e.href.baseVal))) return;
3168
- let r = n ? e.src : e.href.baseVal, i = await fi(r, ai(r), t);
3178
+ if (!(n && !oi(e.src)) && !(Z(e, SVGImageElement) && !oi(e.href.baseVal))) return;
3179
+ let r = n ? e.src : e.href.baseVal, i = await di(r, ii(r), t);
3169
3180
  await new Promise((r, a) => {
3170
3181
  e.onload = r, e.onerror = t.onImageErrorHandler ? (...e) => {
3171
3182
  try {
@@ -3178,16 +3189,16 @@ async function Li(e, t) {
3178
3189
  o.decode &&= r, o.loading === "lazy" && (o.loading = "eager"), n ? (e.srcset = "", e.src = i) : e.href.baseVal = i;
3179
3190
  });
3180
3191
  }
3181
- async function Ri(e, t) {
3182
- let n = Y(e.childNodes).map((e) => zi(e, t));
3192
+ async function Li(e, t) {
3193
+ let n = Y(e.childNodes).map((e) => Ri(e, t));
3183
3194
  await Promise.all(n).then(() => e);
3184
3195
  }
3185
- async function zi(e, t) {
3186
- Z(e, Element) && (await Ii(e, t), await Li(e, t), await Ri(e, t));
3196
+ async function Ri(e, t) {
3197
+ Z(e, Element) && (await Fi(e, t), await Ii(e, t), await Li(e, t));
3187
3198
  }
3188
3199
  //#endregion
3189
3200
  //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/apply-style.js
3190
- function Bi(e, t) {
3201
+ function zi(e, t) {
3191
3202
  let { style: n } = e;
3192
3203
  t.backgroundColor && (n.backgroundColor = t.backgroundColor), t.width && (n.width = `${t.width}px`), t.height && (n.height = `${t.height}px`);
3193
3204
  let r = t.style;
@@ -3197,22 +3208,22 @@ function Bi(e, t) {
3197
3208
  }
3198
3209
  //#endregion
3199
3210
  //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/embed-webfonts.js
3200
- var Vi = {};
3201
- async function Hi(e) {
3202
- let t = Vi[e];
3211
+ var Bi = {};
3212
+ async function Vi(e) {
3213
+ let t = Bi[e];
3203
3214
  return t ?? (t = {
3204
3215
  url: e,
3205
3216
  cssText: await (await fetch(e)).text()
3206
- }, Vi[e] = t, t);
3217
+ }, Bi[e] = t, t);
3207
3218
  }
3208
- async function Ui(e, t) {
3219
+ async function Hi(e, t) {
3209
3220
  let n = e.cssText, r = /url\(["']?([^"')]+)["']?\)/g, i = (n.match(/url\([^)]+\)/g) || []).map(async (i) => {
3210
3221
  let a = i.replace(r, "$1");
3211
- return a.startsWith("https://") || (a = new URL(a, e.url).href), li(a, t.fetchRequestInit, ({ result: e }) => (n = n.replace(i, `url(${e})`), [i, e]));
3222
+ return a.startsWith("https://") || (a = new URL(a, e.url).href), ci(a, t.fetchRequestInit, ({ result: e }) => (n = n.replace(i, `url(${e})`), [i, e]));
3212
3223
  });
3213
3224
  return Promise.all(i).then(() => n);
3214
3225
  }
3215
- function Wi(e) {
3226
+ function Ui(e) {
3216
3227
  if (e == null) return [];
3217
3228
  let t = [], n = e.replace(/(\/\*[\s\S]*?\*\/)/gi, ""), r = /* @__PURE__ */ RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})", "gi");
3218
3229
  for (;;) {
@@ -3232,13 +3243,13 @@ function Wi(e) {
3232
3243
  }
3233
3244
  return t;
3234
3245
  }
3235
- async function Gi(e, t) {
3246
+ async function Wi(e, t) {
3236
3247
  let n = [], r = [];
3237
3248
  return e.forEach((n) => {
3238
3249
  if ("cssRules" in n) try {
3239
3250
  Y(n.cssRules || []).forEach((e, i) => {
3240
3251
  if (e.type === CSSRule.IMPORT_RULE) {
3241
- let a = i + 1, o = e.href, s = Hi(o).then((e) => Ui(e, t)).then((e) => Wi(e).forEach((e) => {
3252
+ let a = i + 1, o = e.href, s = Vi(o).then((e) => Hi(e, t)).then((e) => Ui(e).forEach((e) => {
3242
3253
  try {
3243
3254
  n.insertRule(e, e.startsWith("@import") ? a += 1 : n.cssRules.length);
3244
3255
  } catch (t) {
@@ -3255,7 +3266,7 @@ async function Gi(e, t) {
3255
3266
  });
3256
3267
  } catch (i) {
3257
3268
  let a = e.find((e) => e.href == null) || document.styleSheets[0];
3258
- n.href != null && r.push(Hi(n.href).then((e) => Ui(e, t)).then((e) => Wi(e).forEach((e) => {
3269
+ n.href != null && r.push(Vi(n.href).then((e) => Hi(e, t)).then((e) => Ui(e).forEach((e) => {
3259
3270
  a.insertRule(e, a.cssRules.length);
3260
3271
  })).catch((e) => {
3261
3272
  console.error("Error loading remote stylesheet", e);
@@ -3271,36 +3282,36 @@ async function Gi(e, t) {
3271
3282
  }
3272
3283
  }), n));
3273
3284
  }
3274
- function Ki(e) {
3275
- return e.filter((e) => e.type === CSSRule.FONT_FACE_RULE).filter((e) => Ni(e.style.getPropertyValue("src")));
3285
+ function Gi(e) {
3286
+ return e.filter((e) => e.type === CSSRule.FONT_FACE_RULE).filter((e) => Mi(e.style.getPropertyValue("src")));
3276
3287
  }
3277
- async function qi(e, t) {
3288
+ async function Ki(e, t) {
3278
3289
  if (e.ownerDocument == null) throw Error("Provided element is not within a Document");
3279
- return Ki(await Gi(Y(e.ownerDocument.styleSheets), t));
3290
+ return Gi(await Wi(Y(e.ownerDocument.styleSheets), t));
3280
3291
  }
3281
- function Ji(e) {
3292
+ function qi(e) {
3282
3293
  return e.trim().replace(/["']/g, "");
3283
3294
  }
3284
- function Yi(e) {
3295
+ function Ji(e) {
3285
3296
  let t = /* @__PURE__ */ new Set();
3286
3297
  function n(e) {
3287
3298
  (e.style.fontFamily || getComputedStyle(e).fontFamily).split(",").forEach((e) => {
3288
- t.add(Ji(e));
3299
+ t.add(qi(e));
3289
3300
  }), Array.from(e.children).forEach((e) => {
3290
3301
  e instanceof HTMLElement && n(e);
3291
3302
  });
3292
3303
  }
3293
3304
  return n(e), t;
3294
3305
  }
3295
- async function Xi(e, t) {
3296
- let n = await qi(e, t), r = Yi(e);
3297
- return (await Promise.all(n.filter((e) => r.has(Ji(e.style.fontFamily))).map((e) => {
3306
+ async function Yi(e, t) {
3307
+ let n = await Ki(e, t), r = Ji(e);
3308
+ return (await Promise.all(n.filter((e) => r.has(qi(e.style.fontFamily))).map((e) => {
3298
3309
  let n = e.parentStyleSheet ? e.parentStyleSheet.href : null;
3299
- return Pi(e.cssText, n, t);
3310
+ return Ni(e.cssText, n, t);
3300
3311
  }))).join("\n");
3301
3312
  }
3302
- async function Zi(e, t) {
3303
- let n = t.fontEmbedCSS == null ? t.skipFonts ? null : await Xi(e, t) : t.fontEmbedCSS;
3313
+ async function Xi(e, t) {
3314
+ let n = t.fontEmbedCSS == null ? t.skipFonts ? null : await Yi(e, t) : t.fontEmbedCSS;
3304
3315
  if (n) {
3305
3316
  let t = document.createElement("style"), r = document.createTextNode(n);
3306
3317
  t.appendChild(r), e.firstChild ? e.insertBefore(t, e.firstChild) : e.appendChild(t);
@@ -3308,23 +3319,23 @@ async function Zi(e, t) {
3308
3319
  }
3309
3320
  //#endregion
3310
3321
  //#region ../../node_modules/.pnpm/html-to-image@1.11.13/node_modules/html-to-image/es/index.js
3311
- async function Qi(e, t = {}) {
3312
- let { width: n, height: r } = Wr(e, t), i = await Ti(e, t, !0);
3313
- return await Zi(i, t), await zi(i, t), Bi(i, t), await Yr(i, n, r);
3322
+ async function Zi(e, t = {}) {
3323
+ let { width: n, height: r } = Ur(e, t), i = await wi(e, t, !0);
3324
+ return await Xi(i, t), await Ri(i, t), zi(i, t), await Jr(i, n, r);
3314
3325
  }
3315
- async function $i(e, t = {}) {
3316
- let { width: n, height: r } = Wr(e, t), i = await qr(await Qi(e, t)), a = document.createElement("canvas"), o = a.getContext("2d"), s = t.pixelRatio || Gr(), c = t.canvasWidth || n, l = t.canvasHeight || r;
3317
- return a.width = c * s, a.height = l * s, t.skipAutoScale || Kr(a), a.style.width = `${c}`, a.style.height = `${l}`, t.backgroundColor && (o.fillStyle = t.backgroundColor, o.fillRect(0, 0, a.width, a.height)), o.drawImage(i, 0, 0, a.width, a.height), a;
3326
+ async function Qi(e, t = {}) {
3327
+ let { width: n, height: r } = Ur(e, t), i = await Kr(await Zi(e, t)), a = document.createElement("canvas"), o = a.getContext("2d"), s = t.pixelRatio || Wr(), c = t.canvasWidth || n, l = t.canvasHeight || r;
3328
+ return a.width = c * s, a.height = l * s, t.skipAutoScale || Gr(a), a.style.width = `${c}`, a.style.height = `${l}`, t.backgroundColor && (o.fillStyle = t.backgroundColor, o.fillRect(0, 0, a.width, a.height)), o.drawImage(i, 0, 0, a.width, a.height), a;
3318
3329
  }
3319
3330
  //#endregion
3320
3331
  //#region src/runtime/screenshot.ts
3321
- var ea = 2 * 1024 * 1024;
3322
- async function ta(e, t) {
3332
+ var $i = 2 * 1024 * 1024;
3333
+ async function ea(e, t) {
3323
3334
  try {
3324
3335
  function n(t) {
3325
3336
  return !(e && (t === e || e.contains(t)));
3326
3337
  }
3327
- let r = window.innerWidth, i = window.innerHeight, a = Math.min(window.devicePixelRatio, 2), o = await $i(document.documentElement, {
3338
+ let r = window.innerWidth, i = window.innerHeight, a = Math.min(window.devicePixelRatio, 2), o = await Qi(document.documentElement, {
3328
3339
  width: r,
3329
3340
  height: i,
3330
3341
  cacheBust: !0,
@@ -3338,21 +3349,21 @@ async function ta(e, t) {
3338
3349
  });
3339
3350
  if (t) {
3340
3351
  let e = o.getContext("2d");
3341
- e && ra(e, t.x, t.y, a);
3352
+ e && na(e, t.x, t.y, a);
3342
3353
  }
3343
- let s = await na(o, .85);
3354
+ let s = await ta(o, .85);
3344
3355
  if (!s) return null;
3345
- if (s.size <= ea) return s;
3346
- let c = await na(o, .5);
3347
- return !c || c.size > ea ? null : c;
3356
+ if (s.size <= $i) return s;
3357
+ let c = await ta(o, .5);
3358
+ return !c || c.size > $i ? null : c;
3348
3359
  } catch {
3349
3360
  return null;
3350
3361
  }
3351
3362
  }
3352
- function na(e, t) {
3363
+ function ta(e, t) {
3353
3364
  return new Promise((n) => e.toBlob(n, "image/jpeg", t));
3354
3365
  }
3355
- function ra(e, t, n, r) {
3366
+ function na(e, t, n, r) {
3356
3367
  let i = r, a = 28 * i, o = a / 2, s = t * i, c = n * i;
3357
3368
  e.save(), e.translate(s, c), e.rotate(-Math.PI / 4);
3358
3369
  let l = 2 * i;
@@ -3375,7 +3386,7 @@ function Q(...e) {
3375
3386
  }
3376
3387
  //#endregion
3377
3388
  //#region ../../node_modules/.pnpm/preact@10.29.1/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
3378
- var ia = 0;
3389
+ var ra = 0;
3379
3390
  Array.isArray;
3380
3391
  function $(e, t, r, i, a, o) {
3381
3392
  t ||= {};
@@ -3392,7 +3403,7 @@ function $(e, t, r, i, a, o) {
3392
3403
  __e: null,
3393
3404
  __c: null,
3394
3405
  constructor: void 0,
3395
- __v: --ia,
3406
+ __v: --ra,
3396
3407
  __i: -1,
3397
3408
  __u: 0,
3398
3409
  __source: a,
@@ -3403,7 +3414,7 @@ function $(e, t, r, i, a, o) {
3403
3414
  }
3404
3415
  //#endregion
3405
3416
  //#region src/runtime/ui/icons.tsx
3406
- function aa({ size: e = 16 }) {
3417
+ function ia({ size: e = 16 }) {
3407
3418
  return /* @__PURE__ */ $("svg", {
3408
3419
  width: e,
3409
3420
  height: e,
@@ -3413,7 +3424,7 @@ function aa({ size: e = 16 }) {
3413
3424
  children: /* @__PURE__ */ $("path", { d: "M63.4561 0.00557731C70.6277 -0.0175584 76.9025 1.04088 83.5898 3.71066C97.7952 9.43043 109.186 20.5001 115.311 34.5359C119.708 44.8002 120.746 54.7869 119.156 65.8171C116.857 82.7956 105.129 98.8382 90.0566 106.846C83.4394 110.362 74.7336 113.029 67.2051 113.271C62.4204 113.425 61.1274 113.32 56.6807 115.204C50.2035 117.858 43.6874 120.417 37.1348 122.879C34.8442 123.763 32.3203 124.902 29.9404 125.51C29.4023 125.648 28.1978 125.009 27.7598 124.646C26.9046 123.951 27.0582 122.505 27.0264 121.484C26.8123 114.646 27.3302 107.458 26.8604 100.656C25.1578 98.6714 22.4026 96.603 20.3086 94.1989C12.1853 84.8731 7.05334 73.9949 6.18164 61.6101C4.95583 46.292 9.97176 31.1285 20.0908 19.5632C29.989 8.13202 44.0369 1.11921 59.1221 0.0788195C60.2694 -0.0356049 62.2637 0.00944821 63.4561 0.00557731ZM92.2676 55.7497C91.5754 39.5314 77.8207 26.9725 61.6064 27.7536C45.5175 28.5287 33.0758 42.1537 33.7627 58.2468C34.4496 74.3398 48.007 86.8553 64.1035 86.2566C80.3254 85.6533 92.9599 71.968 92.2676 55.7497Z" })
3414
3425
  });
3415
3426
  }
3416
- function oa({ size: e = 16 }) {
3427
+ function aa({ size: e = 16 }) {
3417
3428
  return /* @__PURE__ */ $("svg", {
3418
3429
  width: e,
3419
3430
  height: e,
@@ -3422,7 +3433,7 @@ function oa({ size: e = 16 }) {
3422
3433
  children: /* @__PURE__ */ $("path", { d: "M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z" })
3423
3434
  });
3424
3435
  }
3425
- function sa({ size: e = 16 }) {
3436
+ function oa({ size: e = 16 }) {
3426
3437
  return /* @__PURE__ */ $("svg", {
3427
3438
  width: e,
3428
3439
  height: e,
@@ -3431,7 +3442,7 @@ function sa({ size: e = 16 }) {
3431
3442
  children: /* @__PURE__ */ $("path", { d: "M3 10a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM8.5 10a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM15.5 8.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Z" })
3432
3443
  });
3433
3444
  }
3434
- function ca({ size: e = 16 }) {
3445
+ function sa({ size: e = 16 }) {
3435
3446
  return /* @__PURE__ */ $("svg", {
3436
3447
  width: e,
3437
3448
  height: e,
@@ -3444,7 +3455,7 @@ function ca({ size: e = 16 }) {
3444
3455
  })
3445
3456
  });
3446
3457
  }
3447
- function la({ size: e = 16 }) {
3458
+ function ca({ size: e = 16 }) {
3448
3459
  return /* @__PURE__ */ $("svg", {
3449
3460
  width: e,
3450
3461
  height: e,
@@ -3458,7 +3469,7 @@ function la({ size: e = 16 }) {
3458
3469
  })
3459
3470
  });
3460
3471
  }
3461
- function ua({ size: e = 16 }) {
3472
+ function la({ size: e = 16 }) {
3462
3473
  return /* @__PURE__ */ $("svg", {
3463
3474
  width: e,
3464
3475
  height: e,
@@ -3467,7 +3478,7 @@ function ua({ size: e = 16 }) {
3467
3478
  children: /* @__PURE__ */ $("path", { d: "M2.87 2.298a.75.75 0 0 0-.812 1.021L3.39 6.624a1 1 0 0 0 .928.626H8.25a.75.75 0 0 1 0 1.5H4.318a1 1 0 0 0-.927.626l-1.333 3.305a.75.75 0 0 0 .811 1.022 24.89 24.89 0 0 0 11.668-5.115.75.75 0 0 0 0-1.175A24.89 24.89 0 0 0 2.869 2.298Z" })
3468
3479
  });
3469
3480
  }
3470
- function da({ size: e = 16 }) {
3481
+ function ua({ size: e = 16 }) {
3471
3482
  return /* @__PURE__ */ $("svg", {
3472
3483
  width: e,
3473
3484
  height: e,
@@ -3479,7 +3490,7 @@ function da({ size: e = 16 }) {
3479
3490
  }
3480
3491
  //#endregion
3481
3492
  //#region src/runtime/ui/fab.tsx
3482
- function fa({ active: e, onToggle: t, onHide: n, position: r = "bottom-right" }) {
3493
+ function da({ active: e, onToggle: t, onHide: n, position: r = "bottom-right" }) {
3483
3494
  return /* @__PURE__ */ $("button", {
3484
3495
  type: "button",
3485
3496
  class: Q("markup-fab", r === "bottom-left" ? "markup-fab-left" : "markup-fab-right", e && "is-active"),
@@ -3497,7 +3508,7 @@ function fa({ active: e, onToggle: t, onHide: n, position: r = "bottom-right" })
3497
3508
  "aria-pressed": e,
3498
3509
  children: [/* @__PURE__ */ $("span", {
3499
3510
  class: "markup-fab-icon",
3500
- children: $(e ? oa : aa, { size: 16 })
3511
+ children: $(e ? aa : ia, { size: 16 })
3501
3512
  }), /* @__PURE__ */ $("span", {
3502
3513
  class: "markup-fab-label",
3503
3514
  children: e ? "Cancel" : "Markup"
@@ -3506,7 +3517,7 @@ function fa({ active: e, onToggle: t, onHide: n, position: r = "bottom-right" })
3506
3517
  }
3507
3518
  //#endregion
3508
3519
  //#region src/runtime/use-focus-trap.ts
3509
- var pa = [
3520
+ var fa = [
3510
3521
  "a[href]",
3511
3522
  "button:not([disabled])",
3512
3523
  "input:not([disabled])",
@@ -3514,14 +3525,14 @@ var pa = [
3514
3525
  "textarea:not([disabled])",
3515
3526
  "[tabindex]:not([tabindex=\"-1\"])"
3516
3527
  ].join(",");
3517
- function ma(e, t) {
3528
+ function pa(e, t) {
3518
3529
  R(() => {
3519
3530
  if (!t) return;
3520
3531
  let n = e.current;
3521
3532
  if (!n) return;
3522
3533
  function r(e) {
3523
3534
  if (e.key !== "Tab") return;
3524
- let t = Array.from(n.querySelectorAll(pa)), r = t[0], i = t[t.length - 1];
3535
+ let t = Array.from(n.querySelectorAll(fa)), r = t[0], i = t[t.length - 1];
3525
3536
  if (!r || !i) return;
3526
3537
  let a = n.getRootNode(), o = a instanceof ShadowRoot ? a.activeElement : document.activeElement;
3527
3538
  (e.shiftKey ? o === r : o === i) && (e.preventDefault(), (e.shiftKey ? i : r).focus());
@@ -3531,7 +3542,7 @@ function ma(e, t) {
3531
3542
  }
3532
3543
  //#endregion
3533
3544
  //#region src/runtime/ui/author-prompt.tsx
3534
- function ha({ pending: e, onSubmit: t, onCancel: n, onSignIn: r }) {
3545
+ function ma({ pending: e, onSubmit: t, onCancel: n, onSignIn: r }) {
3535
3546
  let [i, a] = L(""), [o, s] = L(""), c = z(null);
3536
3547
  R(() => {
3537
3548
  c.current?.focus();
@@ -3603,8 +3614,8 @@ function ha({ pending: e, onSubmit: t, onCancel: n, onSignIn: r }) {
3603
3614
  }
3604
3615
  //#endregion
3605
3616
  //#region src/runtime/ui/composer.tsx
3606
- var ga = 4e3;
3607
- function _a({ label: e, placeholder: t = "Leave feedback…", submitLabel: n = "Post", initialFocus: r = !0, pending: i, error: a, onSubmit: o }) {
3617
+ var ha = 4e3;
3618
+ function ga({ label: e, placeholder: t = "Leave feedback…", submitLabel: n = "Post", initialFocus: r = !0, pending: i, error: a, onSubmit: o }) {
3608
3619
  let [s, c] = L(""), l = z(null), u = z(!1);
3609
3620
  R(() => {
3610
3621
  r && l.current?.focus();
@@ -3622,7 +3633,7 @@ function _a({ label: e, placeholder: t = "Leave feedback…", submitLabel: n = "
3622
3633
  function f(e) {
3623
3634
  (e.metaKey || e.ctrlKey) && e.key === "Enter" && d(e);
3624
3635
  }
3625
- let p = ga - s.length, m = p < 0, h = s.length > 0;
3636
+ let p = ha - s.length, m = p < 0, h = s.length > 0;
3626
3637
  function g(e) {
3627
3638
  return /* @__PURE__ */ $("button", {
3628
3639
  type: "submit",
@@ -3631,7 +3642,7 @@ function _a({ label: e, placeholder: t = "Leave feedback…", submitLabel: n = "
3631
3642
  "aria-label": i ? "Sending…" : n,
3632
3643
  title: i ? "Sending…" : n,
3633
3644
  tabIndex: e,
3634
- children: /* @__PURE__ */ $(ua, { size: 14 })
3645
+ children: /* @__PURE__ */ $(la, { size: 14 })
3635
3646
  });
3636
3647
  }
3637
3648
  return /* @__PURE__ */ $("form", {
@@ -3644,7 +3655,7 @@ function _a({ label: e, placeholder: t = "Leave feedback…", submitLabel: n = "
3644
3655
  class: "markup-composer-input",
3645
3656
  placeholder: t,
3646
3657
  rows: h ? 2 : 1,
3647
- maxLength: ga + 100,
3658
+ maxLength: ha + 100,
3648
3659
  value: s,
3649
3660
  onInput: (e) => c(e.currentTarget.value),
3650
3661
  onKeyDown: f,
@@ -3680,9 +3691,9 @@ function _a({ label: e, placeholder: t = "Leave feedback…", submitLabel: n = "
3680
3691
  }
3681
3692
  //#endregion
3682
3693
  //#region src/runtime/ui/new-thread-popover.tsx
3683
- function va({ pageX: e, pageY: t, authorName: n, isVerified: r, pending: i, error: a, screenshot: o, screenshotCapturing: s, onAuthor: c, onSignIn: l, onSubmit: u, onClose: d }) {
3694
+ function _a({ pageX: e, pageY: t, authorName: n, isVerified: r, pending: i, error: a, screenshot: o, screenshotCapturing: s, onAuthor: c, onSignIn: l, onSubmit: u, onClose: d }) {
3684
3695
  let f = z(null);
3685
- ma(f, !0);
3696
+ pa(f, !0);
3686
3697
  let [p, m] = L(!1), [h, g] = L(null);
3687
3698
  R(() => {
3688
3699
  if (!o) return;
@@ -3699,7 +3710,7 @@ function va({ pageX: e, pageY: t, authorName: n, isVerified: r, pending: i, erro
3699
3710
  }
3700
3711
  return e.addEventListener("toggle", t), () => e.removeEventListener("toggle", t);
3701
3712
  }, [d]);
3702
- let _ = ya(e - window.scrollX + 16, 12, window.innerWidth - 320 - 12), v = ya(t - window.scrollY - 16, 12, window.innerHeight - 220), y = o != null, b = s || y;
3713
+ let _ = va(e - window.scrollX + 16, 12, window.innerWidth - 320 - 12), v = va(t - window.scrollY - 16, 12, window.innerHeight - 220), y = o != null, b = s || y;
3703
3714
  return /* @__PURE__ */ $("div", {
3704
3715
  ref: f,
3705
3716
  class: "markup-popover",
@@ -3720,9 +3731,9 @@ function va({ pageX: e, pageY: t, authorName: n, isVerified: r, pending: i, erro
3720
3731
  class: "markup-icon-btn",
3721
3732
  "aria-label": "Discard pin",
3722
3733
  onClick: d,
3723
- children: /* @__PURE__ */ $(oa, { size: 16 })
3734
+ children: /* @__PURE__ */ $(aa, { size: 16 })
3724
3735
  })]
3725
- }), n == null ? /* @__PURE__ */ $(ha, {
3736
+ }), n == null ? /* @__PURE__ */ $(ma, {
3726
3737
  pending: i,
3727
3738
  onSubmit: c,
3728
3739
  onCancel: d,
@@ -3744,7 +3755,7 @@ function va({ pageX: e, pageY: t, authorName: n, isVerified: r, pending: i, erro
3744
3755
  }) : null
3745
3756
  ]
3746
3757
  }),
3747
- /* @__PURE__ */ $(_a, {
3758
+ /* @__PURE__ */ $(ga, {
3748
3759
  label: "Feedback",
3749
3760
  placeholder: "What's wrong, missing, or worth noting?",
3750
3761
  submitLabel: "Post markup",
@@ -3762,7 +3773,7 @@ function va({ pageX: e, pageY: t, authorName: n, isVerified: r, pending: i, erro
3762
3773
  class: "markup-screenshot-checkbox",
3763
3774
  disabled: !0
3764
3775
  }),
3765
- /* @__PURE__ */ $(la, { size: 12 }),
3776
+ /* @__PURE__ */ $(ca, { size: 12 }),
3766
3777
  /* @__PURE__ */ $("span", { children: "Capturing…" })
3767
3778
  ]
3768
3779
  }) : /* @__PURE__ */ $("label", {
@@ -3774,7 +3785,7 @@ function va({ pageX: e, pageY: t, authorName: n, isVerified: r, pending: i, erro
3774
3785
  checked: p,
3775
3786
  onChange: (e) => m(e.currentTarget.checked)
3776
3787
  }),
3777
- /* @__PURE__ */ $(la, { size: 12 }),
3788
+ /* @__PURE__ */ $(ca, { size: 12 }),
3778
3789
  /* @__PURE__ */ $("span", { children: "Attach screenshot" }),
3779
3790
  h && p ? /* @__PURE__ */ $("img", {
3780
3791
  class: "markup-screenshot-thumb",
@@ -3788,12 +3799,12 @@ function va({ pageX: e, pageY: t, authorName: n, isVerified: r, pending: i, erro
3788
3799
  })]
3789
3800
  });
3790
3801
  }
3791
- function ya(e, t, n) {
3802
+ function va(e, t, n) {
3792
3803
  return Math.max(t, Math.min(n, e));
3793
3804
  }
3794
3805
  //#endregion
3795
3806
  //#region src/runtime/ui/pin.tsx
3796
- function ba({ pageX: e, pageY: t, count: n, active: r, onClick: i }) {
3807
+ function ya({ pageX: e, pageY: t, count: n, active: r, onClick: i }) {
3797
3808
  let a = t - window.scrollY, o = e - window.scrollX;
3798
3809
  return /* @__PURE__ */ $("button", {
3799
3810
  type: "button",
@@ -3816,7 +3827,7 @@ function ba({ pageX: e, pageY: t, count: n, active: r, onClick: i }) {
3816
3827
  }) : null]
3817
3828
  });
3818
3829
  }
3819
- function xa({ pageX: e, pageY: t }) {
3830
+ function ba({ pageX: e, pageY: t }) {
3820
3831
  let n = t - window.scrollY, r = e - window.scrollX;
3821
3832
  return /* @__PURE__ */ $("div", {
3822
3833
  class: "markup-pin markup-pin-ghost is-anchor",
@@ -3832,7 +3843,7 @@ function xa({ pageX: e, pageY: t }) {
3832
3843
  }
3833
3844
  //#endregion
3834
3845
  //#region src/runtime/ui/placement-overlay.tsx
3835
- function Sa({ onPlace: e, onCancel: t }) {
3846
+ function xa({ onPlace: e, onCancel: t }) {
3836
3847
  R(() => {
3837
3848
  function e(e) {
3838
3849
  e.key === "Escape" && t();
@@ -3858,7 +3869,7 @@ function Sa({ onPlace: e, onCancel: t }) {
3858
3869
  }
3859
3870
  //#endregion
3860
3871
  //#region src/runtime/ui/thread-popover.tsx
3861
- var Ca = [
3872
+ var Sa = [
3862
3873
  "👍",
3863
3874
  "❤️",
3864
3875
  "🎉",
@@ -3866,9 +3877,9 @@ var Ca = [
3866
3877
  "😄",
3867
3878
  "❓"
3868
3879
  ];
3869
- function wa({ thread: e, authorName: t, currentClientId: n, isVerified: r, canDelete: i, pending: a, error: o, onAuthor: s, onSignIn: c, onClose: l, onReply: u, onEditComment: d, onDeleteComment: f, onToggleReaction: p, onResolve: m, onDelete: h }) {
3880
+ function Ca({ thread: e, authorName: t, currentClientId: n, isVerified: r, canDelete: i, pending: a, error: o, onAuthor: s, onSignIn: c, onClose: l, onReply: u, onEditComment: d, onDeleteComment: f, onToggleReaction: p, onResolve: m, onDelete: h }) {
3870
3881
  let g = z(null), _ = z(null), v = z(null), y = z(null), b = z(null), [x, S] = L(!1), [C, w] = L(!1), [T, E] = L(null), [D, O] = L(""), [k, A] = L(null), [ee, j] = L("down"), [M, te] = L(null), [N, ne] = L(null), [re, ie] = L("down"), ae = z(null);
3871
- ma(g, !0);
3882
+ pa(g, !0);
3872
3883
  let oe = e.resolvedAt != null, P = Te(() => e.comments.filter((e) => !e.deleted), [e.comments]);
3873
3884
  function se(e, t) {
3874
3885
  E(e), O(t);
@@ -3933,8 +3944,8 @@ function wa({ thread: e, authorName: t, currentClientId: n, isVerified: r, canDe
3933
3944
  anchorSelector: e.anchorSelector
3934
3945
  });
3935
3946
  return {
3936
- left: Oa(t.pageX - window.scrollX + 16, 12, window.innerWidth - 320 - 12),
3937
- top: Oa(t.pageY - window.scrollY - 16, 12, window.innerHeight - 200)
3947
+ left: Da(t.pageX - window.scrollX + 16, 12, window.innerWidth - 320 - 12),
3948
+ top: Da(t.pageY - window.scrollY - 16, 12, window.innerHeight - 200)
3938
3949
  };
3939
3950
  }, [
3940
3951
  e.anchorX,
@@ -3974,7 +3985,7 @@ function wa({ thread: e, authorName: t, currentClientId: n, isVerified: r, canDe
3974
3985
  class: Q("markup-icon-btn", x && "is-open"),
3975
3986
  title: "More options",
3976
3987
  onClick: () => S((e) => !e),
3977
- children: /* @__PURE__ */ $(sa, { size: 16 })
3988
+ children: /* @__PURE__ */ $(oa, { size: 16 })
3978
3989
  }), x ? /* @__PURE__ */ $("div", {
3979
3990
  class: "markup-thread-menu-list",
3980
3991
  children: [/* @__PURE__ */ $("button", {
@@ -4002,14 +4013,14 @@ function wa({ thread: e, authorName: t, currentClientId: n, isVerified: r, canDe
4002
4013
  title: "Mark as resolved",
4003
4014
  disabled: a,
4004
4015
  onClick: m,
4005
- children: /* @__PURE__ */ $(ca, { size: 16 })
4016
+ children: /* @__PURE__ */ $(sa, { size: 16 })
4006
4017
  }) : null,
4007
4018
  /* @__PURE__ */ $("button", {
4008
4019
  type: "button",
4009
4020
  class: "markup-icon-btn",
4010
4021
  title: "Close thread",
4011
4022
  onClick: l,
4012
- children: /* @__PURE__ */ $(oa, { size: 16 })
4023
+ children: /* @__PURE__ */ $(aa, { size: 16 })
4013
4024
  })
4014
4025
  ]
4015
4026
  })]
@@ -4036,12 +4047,12 @@ function wa({ thread: e, authorName: t, currentClientId: n, isVerified: r, canDe
4036
4047
  /* @__PURE__ */ $("time", {
4037
4048
  class: "markup-comment-time",
4038
4049
  datetime: new Date(t.createdAt).toISOString(),
4039
- title: Aa(t.createdAt),
4040
- children: ka(t.createdAt)
4050
+ title: ka(t.createdAt),
4051
+ children: Oa(t.createdAt)
4041
4052
  }),
4042
4053
  /* @__PURE__ */ $("div", {
4043
4054
  class: "markup-thread-actions",
4044
- children: [!oe && !l ? /* @__PURE__ */ $(Ta, {
4055
+ children: [!oe && !l ? /* @__PURE__ */ $(wa, {
4045
4056
  comment: t,
4046
4057
  pickerOpen: N === t._id,
4047
4058
  pickerDirection: re,
@@ -4076,7 +4087,7 @@ function wa({ thread: e, authorName: t, currentClientId: n, isVerified: r, canDe
4076
4087
  let n = e.currentTarget.getBoundingClientRect(), r = y.current?.getBoundingClientRect(), i = (+!!s + +!!c) * 32 + 8 + 6;
4077
4088
  j((r ? r.bottom - n.bottom : Infinity) < i ? "up" : "down"), A(t._id);
4078
4089
  },
4079
- children: /* @__PURE__ */ $(sa, { size: 16 })
4090
+ children: /* @__PURE__ */ $(oa, { size: 16 })
4080
4091
  }), m ? /* @__PURE__ */ $("div", {
4081
4092
  class: "markup-thread-menu-list",
4082
4093
  children: [s ? /* @__PURE__ */ $("button", {
@@ -4139,11 +4150,11 @@ function wa({ thread: e, authorName: t, currentClientId: n, isVerified: r, canDe
4139
4150
  children: [t.body, t.editedAt == null ? null : /* @__PURE__ */ $("time", {
4140
4151
  class: "markup-comment-edited",
4141
4152
  datetime: new Date(t.editedAt).toISOString(),
4142
- title: Aa(t.editedAt),
4153
+ title: ka(t.editedAt),
4143
4154
  children: [" ", "(edited)"]
4144
4155
  })]
4145
4156
  }),
4146
- !l && t.reactions.length > 0 ? /* @__PURE__ */ $(Ea, {
4157
+ !l && t.reactions.length > 0 ? /* @__PURE__ */ $(Ta, {
4147
4158
  comment: t,
4148
4159
  isResolved: oe,
4149
4160
  onToggle: (e) => p(t._id, e)
@@ -4172,7 +4183,7 @@ function wa({ thread: e, authorName: t, currentClientId: n, isVerified: r, canDe
4172
4183
  onClick: (e) => {
4173
4184
  e.stopPropagation(), b.current?.close();
4174
4185
  },
4175
- children: /* @__PURE__ */ $(oa, { size: 16 })
4186
+ children: /* @__PURE__ */ $(aa, { size: 16 })
4176
4187
  }), /* @__PURE__ */ $("img", {
4177
4188
  class: "markup-lightbox-img",
4178
4189
  src: e.screenshotUrl,
@@ -4180,7 +4191,7 @@ function wa({ thread: e, authorName: t, currentClientId: n, isVerified: r, canDe
4180
4191
  onClick: (e) => e.stopPropagation()
4181
4192
  })]
4182
4193
  }) : null,
4183
- t == null ? /* @__PURE__ */ $(ha, {
4194
+ t == null ? /* @__PURE__ */ $(ma, {
4184
4195
  pending: a,
4185
4196
  onSubmit: s,
4186
4197
  onCancel: l,
@@ -4200,7 +4211,7 @@ function wa({ thread: e, authorName: t, currentClientId: n, isVerified: r, canDe
4200
4211
  children: "team"
4201
4212
  }) : null
4202
4213
  ]
4203
- }), /* @__PURE__ */ $(_a, {
4214
+ }), /* @__PURE__ */ $(ga, {
4204
4215
  label: "Reply",
4205
4216
  placeholder: "Write a reply…",
4206
4217
  submitLabel: "Reply",
@@ -4213,7 +4224,7 @@ function wa({ thread: e, authorName: t, currentClientId: n, isVerified: r, canDe
4213
4224
  ]
4214
4225
  });
4215
4226
  }
4216
- function Ta({ comment: e, pickerOpen: t, pickerDirection: n, pickerRef: r, onPickerClick: i, onPickerSelect: a }) {
4227
+ function wa({ comment: e, pickerOpen: t, pickerDirection: n, pickerRef: r, onPickerClick: i, onPickerSelect: a }) {
4217
4228
  return /* @__PURE__ */ $("div", {
4218
4229
  class: Q("markup-reaction-picker-wrap", t && "is-open", t && n === "up" && "is-up"),
4219
4230
  ref: r,
@@ -4223,11 +4234,11 @@ function Ta({ comment: e, pickerOpen: t, pickerDirection: n, pickerRef: r, onPic
4223
4234
  title: "Add reaction",
4224
4235
  "aria-label": "Add reaction",
4225
4236
  onClick: i,
4226
- children: /* @__PURE__ */ $(da, { size: 16 })
4237
+ children: /* @__PURE__ */ $(ua, { size: 16 })
4227
4238
  }), t ? /* @__PURE__ */ $("div", {
4228
4239
  class: "markup-reaction-picker",
4229
4240
  role: "menu",
4230
- children: Ca.map((t) => /* @__PURE__ */ $("button", {
4241
+ children: Sa.map((t) => /* @__PURE__ */ $("button", {
4231
4242
  type: "button",
4232
4243
  role: "menuitem",
4233
4244
  class: Q("markup-reaction-picker-item", (e.reactions.find((e) => e.emoji === t)?.mine ?? !1) && "is-mine"),
@@ -4237,11 +4248,11 @@ function Ta({ comment: e, pickerOpen: t, pickerDirection: n, pickerRef: r, onPic
4237
4248
  }) : null]
4238
4249
  });
4239
4250
  }
4240
- function Ea({ comment: e, isResolved: t, onToggle: n }) {
4251
+ function Ta({ comment: e, isResolved: t, onToggle: n }) {
4241
4252
  return /* @__PURE__ */ $("div", {
4242
4253
  class: "markup-reactions",
4243
4254
  children: e.reactions.map((e) => {
4244
- let r = Da(e.reactors, e.mine, e.count, e.emoji);
4255
+ let r = Ea(e.reactors, e.mine, e.count, e.emoji);
4245
4256
  return /* @__PURE__ */ $("button", {
4246
4257
  type: "button",
4247
4258
  class: Q("markup-reaction-chip", e.mine && "is-mine"),
@@ -4262,14 +4273,14 @@ function Ea({ comment: e, isResolved: t, onToggle: n }) {
4262
4273
  })
4263
4274
  });
4264
4275
  }
4265
- function Da(e, t, n, r) {
4276
+ function Ea(e, t, n, r) {
4266
4277
  let i = e.slice(), a = i.length + +!!t, o = Math.max(0, n - a);
4267
4278
  return o > 0 && i.push(`${o} other${o === 1 ? "" : "s"}`), t && i.push("you"), i.length === 0 ? `${n} reacted with ${r}` : `${i.length === 1 ? i[0] : `${i.slice(0, -1).join(", ")} and ${i[i.length - 1]}`} reacted with ${r}`;
4268
4279
  }
4269
- function Oa(e, t, n) {
4280
+ function Da(e, t, n) {
4270
4281
  return Math.max(t, Math.min(n, e));
4271
4282
  }
4272
- function ka(e) {
4283
+ function Oa(e) {
4273
4284
  let t = Date.now() - e, n = Math.floor(t / 1e3);
4274
4285
  if (n < 60) return "just now";
4275
4286
  let r = Math.floor(n / 60);
@@ -4286,7 +4297,7 @@ function ka(e) {
4286
4297
  year: "numeric"
4287
4298
  });
4288
4299
  }
4289
- function Aa(e) {
4300
+ function ka(e) {
4290
4301
  return new Date(e).toLocaleDateString([], {
4291
4302
  month: "long",
4292
4303
  day: "numeric",
@@ -4297,7 +4308,7 @@ function Aa(e) {
4297
4308
  }
4298
4309
  //#endregion
4299
4310
  //#region src/runtime/ui/app.tsx
4300
- function ja(e) {
4311
+ function Aa(e) {
4301
4312
  return {
4302
4313
  clientId: `markup_user_${e.identity.id}`,
4303
4314
  name: e.identity.name,
@@ -4307,7 +4318,7 @@ function ja(e) {
4307
4318
  tokenExpiresAt: e.tokenExpiresAt ?? void 0
4308
4319
  };
4309
4320
  }
4310
- function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4321
+ function ja({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4311
4322
  let [r, i] = L(() => window.location.pathname), [a, o] = L([]), [s, c] = L(null), l = z(null);
4312
4323
  l.current = s;
4313
4324
  let u = Te(() => Ar({
@@ -4320,30 +4331,65 @@ function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4320
4331
  expiresAt: e.tokenExpiresAt
4321
4332
  } : null;
4322
4333
  },
4334
+ getAnonToken: () => {
4335
+ let e = l.current;
4336
+ return e?.token && e.tokenExpiresAt ? null : e?.anonToken ?? null;
4337
+ },
4323
4338
  onUnauthorized: () => {
4324
4339
  let e = l.current;
4325
4340
  if (!e) return;
4326
4341
  let t = {
4327
4342
  clientId: e.clientId,
4328
4343
  name: e.name,
4329
- email: e.email
4344
+ email: e.email,
4345
+ anonToken: e.anonToken
4330
4346
  };
4331
4347
  l.current = t, c(t), Pr(t);
4332
4348
  }
4333
4349
  }), [e, t]), [d, f] = L({ kind: "idle" }), [p, m] = L(!1), [h, g] = L(null), [_, v] = L(!1), [y, b] = L(!1), [, x] = L(0), S = z(null), C = s?.name ?? null, w = s?.isVerified ?? !1;
4334
4350
  R(() => {
4335
4351
  let e = Nr();
4336
- if (e) {
4352
+ if (e?.anonToken || e?.isVerified) {
4337
4353
  c(e);
4338
4354
  return;
4339
4355
  }
4340
- let t = { clientId: Fr() };
4341
- Pr(t), c(t);
4342
- }, []);
4356
+ let t = !1, n = null, r = 1e3;
4357
+ function i() {
4358
+ u.mintAnonIdentity().then(({ clientId: n, token: r }) => {
4359
+ if (t) return;
4360
+ let i = {
4361
+ ...e ?? {},
4362
+ clientId: n,
4363
+ anonToken: r
4364
+ };
4365
+ Pr(i), c(i);
4366
+ }).catch(() => {
4367
+ t || (n = setTimeout(i, Math.min(r, 3e4)), r = Math.min(r * 2, 3e4));
4368
+ });
4369
+ }
4370
+ return i(), () => {
4371
+ t = !0, n && clearTimeout(n);
4372
+ };
4373
+ }, [u]);
4343
4374
  let [T, E] = L(null);
4344
4375
  R(() => {
4345
- Pa(t).then(E).catch(() => {});
4346
- }, [t]);
4376
+ let e = !1, t = null;
4377
+ async function n() {
4378
+ try {
4379
+ let r = await u.getSubscriptionToken();
4380
+ if (e) return;
4381
+ E(r.token);
4382
+ let i = Math.max(6e4, r.expiresAt - Date.now() - 30 * 6e4);
4383
+ t = setTimeout(n, i);
4384
+ } catch {
4385
+ if (e) return;
4386
+ t = setTimeout(n, 6e4);
4387
+ }
4388
+ }
4389
+ return n(), () => {
4390
+ e = !0, t && clearTimeout(t);
4391
+ };
4392
+ }, [u]);
4347
4393
  let D = z(null);
4348
4394
  R(() => {
4349
4395
  let t = new ar(e.replace(/\.convex\.site(\/.*)?$/, ".convex.cloud"));
@@ -4355,7 +4401,7 @@ function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4355
4401
  R(() => {
4356
4402
  let e = D.current;
4357
4403
  if (!(!e || !T)) return O.current = !1, g(null), e.onUpdate(Yt("widget/queries:subscribeThreadsForRoute"), {
4358
- apiKeyHash: T,
4404
+ subscriptionToken: T,
4359
4405
  route: r,
4360
4406
  viewerClientId: s?.clientId ?? void 0
4361
4407
  }, (e) => {
@@ -4425,7 +4471,7 @@ function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4425
4471
  pageY: n + window.scrollY,
4426
4472
  screenshot: null,
4427
4473
  screenshotCapturing: !0
4428
- }), ta(S.current != null && S.current.getRootNode() instanceof ShadowRoot ? S.current.getRootNode().host : null, {
4474
+ }), ea(S.current != null && S.current.getRootNode() instanceof ShadowRoot ? S.current.getRootNode().host : null, {
4429
4475
  x: t,
4430
4476
  y: n
4431
4477
  }).then((e) => {
@@ -4436,8 +4482,9 @@ function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4436
4482
  } : t);
4437
4483
  });
4438
4484
  }, []), j = B((e, t) => {
4485
+ if (!s) return;
4439
4486
  let n = {
4440
- clientId: s?.clientId ?? Fr(),
4487
+ ...s,
4441
4488
  name: e,
4442
4489
  email: t
4443
4490
  };
@@ -4445,7 +4492,7 @@ function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4445
4492
  }, [s]), M = B(async () => {
4446
4493
  g(null);
4447
4494
  try {
4448
- let n = ja(await Ir(e, t));
4495
+ let n = Aa(await Fr(e, t));
4449
4496
  Pr(n), c(n);
4450
4497
  } catch (e) {
4451
4498
  g(e instanceof Error ? e.message : "Sign-in failed");
@@ -4479,7 +4526,6 @@ function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4479
4526
  userAgent: navigator.userAgent,
4480
4527
  authorName: s.name,
4481
4528
  authorEmail: s.email,
4482
- authorClientId: s.clientId,
4483
4529
  body: e,
4484
4530
  screenshotStorageId: n
4485
4531
  });
@@ -4532,8 +4578,7 @@ function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4532
4578
  let n = await u.addComment(t, {
4533
4579
  body: e,
4534
4580
  authorName: s.name,
4535
- authorEmail: s.email,
4536
- authorClientId: s.clientId
4581
+ authorEmail: s.email
4537
4582
  });
4538
4583
  o((e) => e.map((e) => e._id === t ? n.thread : e));
4539
4584
  } catch (e) {
@@ -4550,10 +4595,7 @@ function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4550
4595
  let n = d.threadId;
4551
4596
  m(!0), g(null);
4552
4597
  try {
4553
- let r = await u.editComment(n, e, {
4554
- body: t,
4555
- authorClientId: s.clientId
4556
- });
4598
+ let r = await u.editComment(n, e, { body: t });
4557
4599
  o((e) => e.map((e) => e._id === n ? r.thread : e));
4558
4600
  } catch (e) {
4559
4601
  throw g(e instanceof Error ? e.message : "Failed to edit"), e;
@@ -4569,7 +4611,7 @@ function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4569
4611
  let t = d.threadId;
4570
4612
  m(!0), g(null);
4571
4613
  try {
4572
- let n = await u.deleteComment(t, e, { authorClientId: s.clientId });
4614
+ let n = await u.deleteComment(t, e);
4573
4615
  o((e) => e.map((e) => e._id === t ? n.thread : e));
4574
4616
  } catch (e) {
4575
4617
  g(e instanceof Error ? e.message : "Failed to delete");
@@ -4587,7 +4629,6 @@ function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4587
4629
  try {
4588
4630
  let r = await u.toggleReaction(e, {
4589
4631
  emoji: t,
4590
- authorClientId: s.clientId,
4591
4632
  authorName: s.name
4592
4633
  });
4593
4634
  o((e) => e.map((e) => e._id === n ? r.thread : e));
@@ -4613,7 +4654,7 @@ function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4613
4654
  anchorOffsetX: e.anchorOffsetX,
4614
4655
  anchorOffsetY: e.anchorOffsetY
4615
4656
  }), r = e.comments.reduce((e, t) => e + +!t.deleted, 0);
4616
- return /* @__PURE__ */ $(ba, {
4657
+ return /* @__PURE__ */ $(ya, {
4617
4658
  pageX: n.pageX,
4618
4659
  pageY: n.pageY,
4619
4660
  count: r,
@@ -4623,16 +4664,16 @@ function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4623
4664
  threadId: e._id
4624
4665
  })
4625
4666
  }, e._id);
4626
- }), d.kind === "composing-new" ? /* @__PURE__ */ $(xa, {
4667
+ }), d.kind === "composing-new" ? /* @__PURE__ */ $(ba, {
4627
4668
  pageX: d.pageX,
4628
4669
  pageY: d.pageY
4629
4670
  }) : null]
4630
4671
  }),
4631
- d.kind === "placing" ? /* @__PURE__ */ $(Sa, {
4672
+ d.kind === "placing" ? /* @__PURE__ */ $(xa, {
4632
4673
  onPlace: ee,
4633
4674
  onCancel: A
4634
4675
  }) : null,
4635
- d.kind === "thread" && P && !_ ? /* @__PURE__ */ $(wa, {
4676
+ d.kind === "thread" && P && !_ ? /* @__PURE__ */ $(Ca, {
4636
4677
  thread: P,
4637
4678
  authorName: C,
4638
4679
  currentClientId: s?.clientId ?? null,
@@ -4650,7 +4691,7 @@ function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4650
4691
  onDelete: N,
4651
4692
  onResolve: ne
4652
4693
  }) : null,
4653
- d.kind === "composing-new" ? /* @__PURE__ */ $(va, {
4694
+ d.kind === "composing-new" ? /* @__PURE__ */ $(_a, {
4654
4695
  pageX: d.pageX,
4655
4696
  pageY: d.pageY,
4656
4697
  authorName: C,
@@ -4664,7 +4705,7 @@ function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4664
4705
  onSubmit: te,
4665
4706
  onClose: A
4666
4707
  }) : null,
4667
- !_ || d.kind === "placing" || d.kind === "composing-new" ? /* @__PURE__ */ $(fa, {
4708
+ !_ || d.kind === "placing" || d.kind === "composing-new" ? /* @__PURE__ */ $(da, {
4668
4709
  active: d.kind === "placing",
4669
4710
  onToggle: () => d.kind === "placing" ? A() : k(),
4670
4711
  onHide: () => {
@@ -4672,11 +4713,11 @@ function Ma({ apiUrl: e, apiKey: t, position: n = "bottom-right" }) {
4672
4713
  },
4673
4714
  position: n
4674
4715
  }) : null,
4675
- _ && y ? /* @__PURE__ */ $(Na, { position: n }) : null
4716
+ _ && y ? /* @__PURE__ */ $(Ma, { position: n }) : null
4676
4717
  ]
4677
4718
  });
4678
4719
  }
4679
- function Na({ position: e }) {
4720
+ function Ma({ position: e }) {
4680
4721
  let t = /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent) ? "⌘" : "Ctrl";
4681
4722
  return /* @__PURE__ */ $("div", {
4682
4723
  class: Q("markup-hud-hidden-toast", e === "bottom-left" ? "markup-hud-hidden-toast-left" : "markup-hud-hidden-toast-right"),
@@ -4696,13 +4737,9 @@ function Na({ position: e }) {
4696
4737
  ]
4697
4738
  });
4698
4739
  }
4699
- async function Pa(e) {
4700
- let t = new TextEncoder().encode(e), n = await crypto.subtle.digest("SHA-256", t);
4701
- return Array.from(new Uint8Array(n)).map((e) => e.toString(16).padStart(2, "0")).join("");
4702
- }
4703
4740
  //#endregion
4704
4741
  //#region src/runtime/mount.tsx
4705
- function Fa(e, t) {
4742
+ function Na(e, t) {
4706
4743
  e.style.position = "fixed", e.style.inset = "0", e.style.zIndex = "2147483647", e.style.pointerEvents = "none";
4707
4744
  let n = t.theme ?? "auto";
4708
4745
  n !== "auto" && (e.dataset.theme = n);
@@ -4711,23 +4748,23 @@ function Fa(e, t) {
4711
4748
  let a = document.createElement("div");
4712
4749
  a.className = "markup-shadow-root", r.appendChild(a);
4713
4750
  let { theme: o, ...s } = t;
4714
- return ue(/* @__PURE__ */ $(Ma, { ...s }), a), () => ue(null, a);
4751
+ return ue(/* @__PURE__ */ $(ja, { ...s }), a), () => ue(null, a);
4715
4752
  }
4716
4753
  //#endregion
4717
4754
  //#region src/widget.ts
4718
- var Ia = null, La = null;
4719
- function Ra(e) {
4720
- za();
4755
+ var Pa = null, Fa = null;
4756
+ function Ia(e) {
4757
+ La();
4721
4758
  let t = document.createElement("div");
4722
- return t.id = "markup-widget", document.body.appendChild(t), La = t, Ia = Fa(t, e), za;
4759
+ return t.id = "markup-widget", document.body.appendChild(t), Fa = t, Pa = Na(t, e), La;
4723
4760
  }
4724
- function za() {
4725
- Ia &&= (Ia(), null), La?.parentNode && La.parentNode.removeChild(La), La = null;
4761
+ function La() {
4762
+ Pa &&= (Pa(), null), Fa?.parentNode && Fa.parentNode.removeChild(Fa), Fa = null;
4726
4763
  }
4727
4764
  if (typeof document < "u") {
4728
4765
  let e = document.currentScript ?? document.querySelector("script[data-markup-widget=\"true\"]"), t = e?.dataset.apiUrl, n = e?.dataset.apiKey;
4729
4766
  if (t && n) {
4730
- let r = e?.dataset.position, i = e?.dataset.theme, a = () => Ra({
4767
+ let r = e?.dataset.position, i = e?.dataset.theme, a = () => Ia({
4731
4768
  apiUrl: t,
4732
4769
  apiKey: n,
4733
4770
  position: r,
@@ -4738,13 +4775,13 @@ if (typeof document < "u") {
4738
4775
  }
4739
4776
  //#endregion
4740
4777
  //#region src/react.tsx
4741
- function Ba(t) {
4742
- return e(() => (Ra({
4778
+ function Ra(t) {
4779
+ return e(() => (Ia({
4743
4780
  apiUrl: t.apiUrl,
4744
4781
  apiKey: t.apiKey,
4745
4782
  position: t.position,
4746
4783
  theme: t.theme
4747
- }), () => za()), [
4784
+ }), () => La()), [
4748
4785
  t.apiUrl,
4749
4786
  t.apiKey,
4750
4787
  t.position,
@@ -4752,4 +4789,4 @@ function Ba(t) {
4752
4789
  ]), null;
4753
4790
  }
4754
4791
  //#endregion
4755
- export { Ba as MarkupWidget };
4792
+ export { Ra as MarkupWidget };