makethisbetter 1.0.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.
Files changed (168) hide show
  1. package/LICENSE +62 -0
  2. package/README.md +113 -0
  3. package/dist/annotate/draw.d.ts +21 -0
  4. package/dist/annotate/draw.d.ts.map +1 -0
  5. package/dist/annotate/draw.test.d.ts +2 -0
  6. package/dist/annotate/draw.test.d.ts.map +1 -0
  7. package/dist/annotate/highlighter.d.ts +11 -0
  8. package/dist/annotate/highlighter.d.ts.map +1 -0
  9. package/dist/annotate/highlighter.test.d.ts +2 -0
  10. package/dist/annotate/highlighter.test.d.ts.map +1 -0
  11. package/dist/annotate/overlay.d.ts +17 -0
  12. package/dist/annotate/overlay.d.ts.map +1 -0
  13. package/dist/annotate/overlay.test.d.ts +2 -0
  14. package/dist/annotate/overlay.test.d.ts.map +1 -0
  15. package/dist/annotate/pin.d.ts +10 -0
  16. package/dist/annotate/pin.d.ts.map +1 -0
  17. package/dist/annotate/pin.test.d.ts +2 -0
  18. package/dist/annotate/pin.test.d.ts.map +1 -0
  19. package/dist/annotate/session.d.ts +20 -0
  20. package/dist/annotate/session.d.ts.map +1 -0
  21. package/dist/annotate/session.test.d.ts +2 -0
  22. package/dist/annotate/session.test.d.ts.map +1 -0
  23. package/dist/annotate/toolbar.d.ts +17 -0
  24. package/dist/annotate/toolbar.d.ts.map +1 -0
  25. package/dist/annotate/toolbar.test.d.ts +2 -0
  26. package/dist/annotate/toolbar.test.d.ts.map +1 -0
  27. package/dist/api/client.d.ts +10 -0
  28. package/dist/api/client.d.ts.map +1 -0
  29. package/dist/api/client.test.d.ts +2 -0
  30. package/dist/api/client.test.d.ts.map +1 -0
  31. package/dist/context/collector.d.ts +10 -0
  32. package/dist/context/collector.d.ts.map +1 -0
  33. package/dist/context/collector.test.d.ts +2 -0
  34. package/dist/context/collector.test.d.ts.map +1 -0
  35. package/dist/context/console.d.ts +10 -0
  36. package/dist/context/console.d.ts.map +1 -0
  37. package/dist/context/console.test.d.ts +2 -0
  38. package/dist/context/console.test.d.ts.map +1 -0
  39. package/dist/context/error-source.d.ts +21 -0
  40. package/dist/context/error-source.d.ts.map +1 -0
  41. package/dist/context/error-source.test.d.ts +2 -0
  42. package/dist/context/error-source.test.d.ts.map +1 -0
  43. package/dist/context/frustration.d.ts +27 -0
  44. package/dist/context/frustration.d.ts.map +1 -0
  45. package/dist/context/frustration.test.d.ts +2 -0
  46. package/dist/context/frustration.test.d.ts.map +1 -0
  47. package/dist/global.d.ts +3 -0
  48. package/dist/global.d.ts.map +1 -0
  49. package/dist/i18n/en.d.ts +47 -0
  50. package/dist/i18n/en.d.ts.map +1 -0
  51. package/dist/i18n/index.d.ts +4 -0
  52. package/dist/i18n/index.d.ts.map +1 -0
  53. package/dist/i18n/index.test.d.ts +2 -0
  54. package/dist/i18n/index.test.d.ts.map +1 -0
  55. package/dist/i18n/zh-CN.d.ts +47 -0
  56. package/dist/i18n/zh-CN.d.ts.map +1 -0
  57. package/dist/index.d.mts +8 -0
  58. package/dist/index.d.ts +8 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/makethisbetter.cjs.js +84 -0
  61. package/dist/makethisbetter.cjs.js.map +1 -0
  62. package/dist/makethisbetter.esm.js +1433 -0
  63. package/dist/makethisbetter.esm.js.map +1 -0
  64. package/dist/makethisbetter.js +84 -0
  65. package/dist/makethisbetter.js.map +1 -0
  66. package/dist/popup/comment.d.ts +31 -0
  67. package/dist/popup/comment.d.ts.map +1 -0
  68. package/dist/popup/comment.test.d.ts +2 -0
  69. package/dist/popup/comment.test.d.ts.map +1 -0
  70. package/dist/popup/success.d.ts +8 -0
  71. package/dist/popup/success.d.ts.map +1 -0
  72. package/dist/popup/success.test.d.ts +2 -0
  73. package/dist/popup/success.test.d.ts.map +1 -0
  74. package/dist/record/control-bar.d.ts +12 -0
  75. package/dist/record/control-bar.d.ts.map +1 -0
  76. package/dist/record/control-bar.test.d.ts +2 -0
  77. package/dist/record/control-bar.test.d.ts.map +1 -0
  78. package/dist/record/session.d.ts +26 -0
  79. package/dist/record/session.d.ts.map +1 -0
  80. package/dist/record/session.test.d.ts +2 -0
  81. package/dist/record/session.test.d.ts.map +1 -0
  82. package/dist/screenshot/capture.d.ts +3 -0
  83. package/dist/screenshot/capture.d.ts.map +1 -0
  84. package/dist/screenshot/capture.test.d.ts +2 -0
  85. package/dist/screenshot/capture.test.d.ts.map +1 -0
  86. package/dist/styles.d.ts +9 -0
  87. package/dist/styles.d.ts.map +1 -0
  88. package/dist/types.d.ts +45 -0
  89. package/dist/types.d.ts.map +1 -0
  90. package/dist/widget/controller.d.ts +37 -0
  91. package/dist/widget/controller.d.ts.map +1 -0
  92. package/dist/widget/controller.test.d.ts +2 -0
  93. package/dist/widget/controller.test.d.ts.map +1 -0
  94. package/dist/widget/frustration-prompt.d.ts +11 -0
  95. package/dist/widget/frustration-prompt.d.ts.map +1 -0
  96. package/dist/widget/frustration-prompt.test.d.ts +2 -0
  97. package/dist/widget/frustration-prompt.test.d.ts.map +1 -0
  98. package/dist/widget/payload.d.ts +5 -0
  99. package/dist/widget/payload.d.ts.map +1 -0
  100. package/dist/widget/payload.test.d.ts +2 -0
  101. package/dist/widget/payload.test.d.ts.map +1 -0
  102. package/dist/widget/pet.d.ts +12 -0
  103. package/dist/widget/pet.d.ts.map +1 -0
  104. package/dist/widget/pet.test.d.ts +2 -0
  105. package/dist/widget/pet.test.d.ts.map +1 -0
  106. package/dist/widget/shadow.d.ts +11 -0
  107. package/dist/widget/shadow.d.ts.map +1 -0
  108. package/dist/widget/shadow.test.d.ts +2 -0
  109. package/dist/widget/shadow.test.d.ts.map +1 -0
  110. package/dist/widget/tab.d.ts +10 -0
  111. package/dist/widget/tab.d.ts.map +1 -0
  112. package/dist/widget/tab.test.d.ts +2 -0
  113. package/dist/widget/tab.test.d.ts.map +1 -0
  114. package/package.json +64 -0
  115. package/src/annotate/draw.test.ts +168 -0
  116. package/src/annotate/draw.ts +108 -0
  117. package/src/annotate/highlighter.test.ts +47 -0
  118. package/src/annotate/highlighter.ts +84 -0
  119. package/src/annotate/overlay.test.ts +91 -0
  120. package/src/annotate/overlay.ts +44 -0
  121. package/src/annotate/pin.test.ts +87 -0
  122. package/src/annotate/pin.ts +28 -0
  123. package/src/annotate/session.test.ts +219 -0
  124. package/src/annotate/session.ts +104 -0
  125. package/src/annotate/toolbar.test.ts +132 -0
  126. package/src/annotate/toolbar.ts +81 -0
  127. package/src/api/client.test.ts +75 -0
  128. package/src/api/client.ts +77 -0
  129. package/src/context/collector.test.ts +14 -0
  130. package/src/context/collector.ts +41 -0
  131. package/src/context/console.test.ts +44 -0
  132. package/src/context/console.ts +34 -0
  133. package/src/context/error-source.test.ts +115 -0
  134. package/src/context/error-source.ts +62 -0
  135. package/src/context/frustration.test.ts +134 -0
  136. package/src/context/frustration.ts +145 -0
  137. package/src/global.ts +3 -0
  138. package/src/i18n/en.ts +47 -0
  139. package/src/i18n/index.test.ts +24 -0
  140. package/src/i18n/index.ts +16 -0
  141. package/src/i18n/zh-CN.ts +47 -0
  142. package/src/index.ts +32 -0
  143. package/src/popup/comment.test.ts +73 -0
  144. package/src/popup/comment.ts +177 -0
  145. package/src/popup/success.test.ts +75 -0
  146. package/src/popup/success.ts +33 -0
  147. package/src/record/control-bar.test.ts +110 -0
  148. package/src/record/control-bar.ts +46 -0
  149. package/src/record/session.test.ts +153 -0
  150. package/src/record/session.ts +139 -0
  151. package/src/screenshot/capture.test.ts +68 -0
  152. package/src/screenshot/capture.ts +96 -0
  153. package/src/styles/widget.css +847 -0
  154. package/src/styles.ts +9 -0
  155. package/src/types.ts +46 -0
  156. package/src/vite-env.d.ts +6 -0
  157. package/src/widget/controller.test.ts +62 -0
  158. package/src/widget/controller.ts +249 -0
  159. package/src/widget/frustration-prompt.test.ts +86 -0
  160. package/src/widget/frustration-prompt.ts +34 -0
  161. package/src/widget/payload.test.ts +167 -0
  162. package/src/widget/payload.ts +31 -0
  163. package/src/widget/pet.test.ts +63 -0
  164. package/src/widget/pet.ts +67 -0
  165. package/src/widget/shadow.test.ts +25 -0
  166. package/src/widget/shadow.ts +41 -0
  167. package/src/widget/tab.test.ts +92 -0
  168. package/src/widget/tab.ts +31 -0
@@ -0,0 +1,8 @@
1
+ import type { MakeThisBetterConfig } from './types';
2
+ declare const MakeThisBetter: {
3
+ init(config: MakeThisBetterConfig): void;
4
+ destroy(): void;
5
+ };
6
+ export { MakeThisBetter };
7
+ export type { MakeThisBetterConfig };
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAInD,QAAA,MAAM,cAAc;iBACL,oBAAoB,GAAG,IAAI;eAc7B,IAAI;CAIhB,CAAA;AAED,OAAO,EAAE,cAAc,EAAE,CAAA;AACzB,YAAY,EAAE,oBAAoB,EAAE,CAAA"}
@@ -0,0 +1,84 @@
1
+ "use strict";var rt=Object.create;var $=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var ot=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty;var lt=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of nt(t))!at.call(e,s)&&s!==i&&$(e,s,{get:()=>t[s],enumerable:!(r=st(t,s))||r.enumerable});return e};var ct=(e,t,i)=>(i=e!=null?rt(ot(e)):{},lt(t||!e||!e.__esModule?$(i,"default",{value:e,enumerable:!0}):i,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ht='*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}:host{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;font-size:14px;line-height:1.5;color:#191a1c;-webkit-font-smoothing:antialiased}:host([data-mtb-theme="dark"]) .mtb-popup,:host([data-mtb-theme="dark"]) .mtb-success{background:#151719;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-popup-header{border-bottom-color:#ffffff1a}:host([data-mtb-theme="dark"]) .mtb-popup-title,:host([data-mtb-theme="dark"]) .mtb-success-title{color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-quick-option,:host([data-mtb-theme="dark"]) .mtb-textarea{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-popup-close,:host([data-mtb-theme="dark"]) .mtb-success-msg,:host([data-mtb-theme="dark"]) .mtb-close-link{color:#ffffffad}@media (prefers-color-scheme: dark){:host([data-mtb-theme="auto"]) .mtb-popup,:host([data-mtb-theme="auto"]) .mtb-success{background:#151719;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-popup-header{border-bottom-color:#ffffff1a}:host([data-mtb-theme="auto"]) .mtb-popup-title,:host([data-mtb-theme="auto"]) .mtb-success-title{color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-quick-option,:host([data-mtb-theme="auto"]) .mtb-textarea{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-popup-close,:host([data-mtb-theme="auto"]) .mtb-success-msg,:host([data-mtb-theme="auto"]) .mtb-close-link{color:#ffffffad}}.mtb-tab{position:fixed;top:50%;right:0;transform:translateY(-50%);z-index:2147483646;display:flex;align-items:center;justify-content:center;width:32px;padding:14px 0;background:#059669;color:#fff;border-radius:8px 0 0 8px;cursor:pointer;box-shadow:-2px 0 14px #05966959;transition:background .15s,box-shadow .15s,width .15s;writing-mode:vertical-lr;text-orientation:mixed;font-size:12px;font-weight:600;letter-spacing:.04em;user-select:none;border:none;outline:none}.mtb-tab.left{right:auto;left:0;border-radius:0 8px 8px 0;box-shadow:2px 0 14px #05966959}.mtb-tab:hover{background:#047857;box-shadow:-3px 0 20px #05966980}.mtb-tab.active{background:#065f46}.mtb-toolbar{position:fixed;top:18px;left:50%;transform:translate(-50%);z-index:2147483647;display:flex;align-items:center;gap:11px;height:46px;padding:0 7px;border-radius:13px;background:linear-gradient(120deg,#10b981,#059669);box-shadow:0 10px 26px #0f172a38;animation:mtbBarIn .2s ease;white-space:nowrap}@keyframes mtbBarIn{0%{transform:translate(-50%,12px);opacity:0}to{transform:translate(-50%);opacity:1}}.mtb-toolbar-modes{display:flex;align-items:center;gap:3px;background:#ffffff29;border-radius:9px;padding:3px}.mtb-toolbar-mode-btn{display:inline-flex;align-items:center;gap:6px;height:30px;padding:0 12px;border-radius:7px;border:none;cursor:pointer;font-family:inherit;font-size:12px;font-weight:550;white-space:nowrap;background:transparent;color:#fffffff2;transition:all .12s}.mtb-toolbar-mode-btn.active{background:#fff;color:#047857}.mtb-toolbar-hint{font-size:12px;color:#fffffff2;white-space:nowrap}.mtb-toolbar-sep{width:1px;height:20px;background:#ffffff38}.mtb-exit-btn{display:inline-flex;align-items:center;gap:5px;height:30px;padding:0 12px;border-radius:8px;font-size:11.5px;font-weight:500;color:#fff;cursor:pointer;background:#ffffff29;border:none;font-family:inherit;transition:background .12s}.mtb-exit-btn:hover{background:#ffffff47}.mtb-overlay{position:fixed;inset:0;z-index:2147483640;cursor:crosshair}.mtb-dim{position:fixed;inset:0;z-index:2147483639;background:#00000014}.mtb-highlight{position:fixed;z-index:2147483641;pointer-events:none;border:2px solid #10b981;border-radius:6px;background:#10b9810f;transition:all .08s ease}.mtb-highlight-tooltip{position:fixed;z-index:2147483642;pointer-events:none;transform:translate(-50%);background:#064e3b;color:#fff;padding:4px 10px;border-radius:6px;font-size:11px;font-weight:500;white-space:nowrap;box-shadow:0 4px 12px #0000002e}.mtb-highlight-tooltip:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);border:4px solid transparent;border-top-color:#064e3b}.mtb-draw-svg{position:fixed;inset:0;z-index:2147483643;pointer-events:none;width:100%;height:100%;overflow:visible}.mtb-pin{position:fixed;z-index:2147483644;pointer-events:none;width:22px;height:22px;border-radius:50% 50% 50% 2px;background:#059669;border:2px solid #fff;display:flex;align-items:center;justify-content:center;font-size:10px;color:#fff;font-weight:700;box-shadow:0 2px 8px #05966973;animation:mtbPinPop .25s cubic-bezier(.34,1.56,.64,1);transform:translate(-50%,-50%)}@keyframes mtbPinPop{0%{transform:translate(-50%,-50%) scale(.4)}to{transform:translate(-50%,-50%) scale(1)}}.mtb-popup{position:fixed;z-index:2147483645;width:320px;background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:14px;box-shadow:0 12px 40px #00000029;overflow:hidden;animation:mtbSlideUp .28s cubic-bezier(.34,1.56,.64,1);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif}@keyframes mtbSlideUp{0%{transform:translateY(14px) scale(.97);opacity:0}to{transform:translateY(0) scale(1);opacity:1}}.mtb-popup-header{padding:11px 13px 11px 14px;border-bottom:1px solid rgba(0,0,0,.06);display:flex;align-items:center;gap:8px}.mtb-popup-icon{width:20px;height:20px;border-radius:5px;background:#10b9811a;display:flex;align-items:center;justify-content:center;flex-shrink:0}.mtb-popup-title{flex:1;font-size:12.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#191a1c}.mtb-popup-close{background:none;border:none;cursor:pointer;padding:3px;color:#00000061;display:flex;align-items:center;border-radius:4px;transition:color .12s}.mtb-popup-close:hover{color:#000000b3}.mtb-popup-body{padding:13px}.mtb-quick-options{display:flex;flex-direction:column;gap:6px;margin-bottom:12px}.mtb-quick-option{display:flex;align-items:center;gap:10px;width:100%;padding:10px 12px;border:1px solid rgba(0,0,0,.09);border-radius:10px;background:#fafafa;cursor:pointer;font-family:inherit;font-size:13px;color:#191a1c;text-align:left;transition:all .12s}.mtb-quick-option:hover{background:#10b9810f;border-color:#10b9814d}.mtb-quick-option-emoji{font-size:15px;flex-shrink:0;line-height:1}.mtb-textarea-wrap{position:relative}.mtb-textarea{width:100%;height:64px;padding:9px 11px;border:1px solid rgba(0,0,0,.12);border-radius:9px;font-family:inherit;font-size:12.5px;line-height:1.5;color:#191a1c;outline:none;background:#fff;resize:none;transition:border-color .12s,box-shadow .12s}.mtb-textarea:focus{border-color:#10b981;box-shadow:0 0 0 3px #10b9811f}.mtb-textarea::placeholder{color:#00000057}.mtb-popup-error{margin-top:8px;color:#b91c1c;font-size:11.5px}.mtb-popup-error:empty,.mtb-popup-error[hidden]{display:none}.mtb-popup-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:12px}.mtb-cancel-btn,.mtb-submit-btn{min-width:72px;height:30px;border:none;border-radius:7px;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0 12px;font-family:inherit;font-size:12px;font-weight:600;transition:background .12s}.mtb-cancel-btn{background:#f3f4f6;color:#000000ad}.mtb-cancel-btn:hover{background:#e5e7eb}.mtb-submit-btn{background:#d1d5db;color:#fff}.mtb-submit-btn.ready{background:#059669}.mtb-submit-btn.ready:hover{background:#047857}.mtb-submit-btn.loading{background:#059669;opacity:.7;cursor:wait}.mtb-submit-btn:disabled{cursor:not-allowed}.mtb-success{position:fixed;z-index:2147483645;width:300px;background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:16px;box-shadow:0 20px 60px #0000001f;padding:26px 22px;text-align:center;animation:mtbSlideUp .35s cubic-bezier(.34,1.56,.64,1);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif}.mtb-success-icon{width:44px;height:44px;border-radius:50%;background:#05966914;display:flex;align-items:center;justify-content:center;margin:0 auto 12px}.mtb-success-title{font-size:16px;font-weight:700;margin-bottom:6px;color:#191a1c}.mtb-success-msg{font-size:13px;color:#0000008c;margin-bottom:16px;line-height:1.6}.mtb-close-link{background:none;border:none;cursor:pointer;font-size:12px;color:#00000073;font-family:inherit;transition:color .12s}.mtb-close-link:hover{color:#000000b3}.mtb-pet{position:fixed;bottom:20px;right:20px;z-index:2147483646;cursor:pointer;width:52px;height:52px;display:flex;align-items:center;justify-content:center;border-radius:50%;background:transparent;animation:mtbPetBounce 3s ease-in-out infinite;transition:transform .2s;user-select:none;outline:none;filter:drop-shadow(0 4px 12px rgba(5,150,105,.35))}.mtb-pet:hover{transform:scale(1.12);animation-play-state:paused}.mtb-pet:hover .mtb-pet-bubble{opacity:1;transform:translate(-50%) translateY(0);pointer-events:auto}.mtb-pet.active{animation:none;opacity:.6}.mtb-pet-svg{display:block}@keyframes mtbPetBounce{0%,to{transform:translateY(0)}50%{transform:translateY(-6px)}}.mtb-pet-bubble{position:absolute;bottom:100%;left:50%;transform:translate(-50%) translateY(4px);margin-bottom:8px;background:#064e3b;color:#fff;padding:6px 12px;border-radius:8px;font-size:12px;font-weight:500;white-space:nowrap;box-shadow:0 4px 14px #0000002e;opacity:0;pointer-events:none;transition:opacity .2s,transform .2s}.mtb-pet-bubble.visible{opacity:1;transform:translate(-50%) translateY(0);pointer-events:auto}.mtb-pet-bubble.hidden{opacity:0;pointer-events:none}.mtb-pet-bubble:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);border:5px solid transparent;border-top-color:#064e3b}.mtb-frustration-prompt{position:fixed;bottom:20px;right:20px;z-index:2147483645;display:flex;align-items:center;gap:10px;padding:12px 16px;background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:12px;box-shadow:0 8px 30px #0000001f;animation:mtbSlideUp .35s cubic-bezier(.34,1.56,.64,1);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif}:host([data-mtb-theme="dark"]) .mtb-frustration-prompt{background:#151719;border-color:#ffffff1f;color:#f9fafb}@media (prefers-color-scheme: dark){:host([data-mtb-theme="auto"]) .mtb-frustration-prompt{background:#151719;border-color:#ffffff1f;color:#f9fafb}}.mtb-frustration-icon{width:32px;height:32px;border-radius:50%;background:#eab3081a;display:flex;align-items:center;justify-content:center;flex-shrink:0;font-size:16px;line-height:1}.mtb-frustration-text{font-size:13px;font-weight:500;color:inherit;line-height:1.4}.mtb-frustration-actions{display:flex;gap:6px;flex-shrink:0}.mtb-frustration-tell{height:28px;padding:0 12px;border:none;border-radius:7px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12px;font-weight:600;transition:background .12s}.mtb-frustration-tell:hover{background:#047857}.mtb-frustration-dismiss{height:28px;padding:0 8px;border:none;border-radius:7px;background:transparent;color:#0006;cursor:pointer;font-family:inherit;font-size:12px;transition:color .12s}.mtb-frustration-dismiss:hover{color:#000000b3}:host([data-mtb-theme="dark"]) .mtb-frustration-dismiss{color:#fff6}:host([data-mtb-theme="dark"]) .mtb-frustration-dismiss:hover{color:#ffffffb3}@media (prefers-color-scheme: dark){:host([data-mtb-theme="auto"]) .mtb-frustration-dismiss{color:#fff6}:host([data-mtb-theme="auto"]) .mtb-frustration-dismiss:hover{color:#ffffffb3}}.mtb-record-bar{position:fixed;bottom:24px;left:50%;transform:translate(-50%);z-index:2147483647;display:flex;align-items:center;gap:12px;height:42px;padding:0 8px 0 14px;border-radius:12px;background:#0f172aeb;box-shadow:0 8px 24px #00000040;animation:mtbBarIn .2s ease}.mtb-record-dot{width:8px;height:8px;border-radius:50%;background:#ef4444;animation:mtbRecordPulse 1.2s ease-in-out infinite;flex-shrink:0}@keyframes mtbRecordPulse{0%,to{opacity:1}50%{opacity:.3}}.mtb-record-timer{font-family:JetBrains Mono,SF Mono,Fira Code,Cascadia Code,monospace;font-size:13px;font-weight:500;color:#fff;font-variant-numeric:tabular-nums;letter-spacing:.02em;min-width:38px}.mtb-record-stop{height:28px;padding:0 14px;border:none;border-radius:7px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12px;font-weight:600;transition:background .12s}.mtb-record-stop:hover{background:#047857}.mtb-click-ripple{position:fixed;z-index:2147483644;width:24px;height:24px;border-radius:50%;border:2px solid #10b981;background:#10b98133;pointer-events:none;transform:translate(-50%,-50%) scale(.5);animation:mtbClickRipple .3s ease-out forwards}@keyframes mtbClickRipple{0%{transform:translate(-50%,-50%) scale(.5);opacity:1}to{transform:translate(-50%,-50%) scale(2);opacity:0}}.mtb-dot{display:inline-block;width:4px;height:4px;border-radius:50%;background:#fff;animation:mtbDot 1.2s infinite}.mtb-dot:nth-child(2){animation-delay:.2s}.mtb-dot:nth-child(3){animation-delay:.4s}@keyframes mtbDot{0%,80%,to{opacity:.3;transform:translateY(0)}40%{opacity:1;transform:translateY(-3px)}}';class dt{constructor(t="auto"){this.host=document.createElement("div"),this.host.id="mtb-widget-host",this.host.style.cssText="position:fixed;top:0;left:0;width:0;height:0;overflow:visible;z-index:2147483646;",this.host.setAttribute("data-mtb-theme",t),document.body.appendChild(this.host),this.root=this.host.attachShadow({mode:"open"});const i=document.createElement("style");i.textContent=ht,this.root.appendChild(i)}el(t,i){const r=document.createElement(t);return i&&(r.className=i),r}append(...t){for(const i of t)this.root.appendChild(i)}remove(...t){for(const i of t)i.parentNode===this.root&&this.root.removeChild(i)}destroy(){document.body.removeChild(this.host)}}class ut{constructor(t,i,r,s){this.onClick=s,this.el=t.el("button","mtb-tab"),r==="left"&&this.el.classList.add("left"),this.el.textContent=i.tab,this.el.setAttribute("aria-label",i.tab),this.el.addEventListener("click",s),t.append(this.el)}setActive(t){this.el.classList.toggle("active",t)}destroy(){this.el.removeEventListener("click",this.onClick),this.el.remove()}}const y="#059669",x={color:y,width:"3.5",linecap:"round",linejoin:"round",filter:"drop-shadow(0 1px 2px rgba(5,150,105,0.35))"};class pt{constructor(t,i,r){this.onClick=r,this.el=t.el("div","mtb-pet"),this.el.innerHTML=this.buildSVG(),this.el.setAttribute("role","button"),this.el.setAttribute("aria-label",i.tab),this.el.tabIndex=0,this.bubble=t.el("div","mtb-pet-bubble"),this.bubble.textContent=i.pet.bubble,this.el.appendChild(this.bubble),this.el.addEventListener("click",this.onClick),this.el.addEventListener("keydown",s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),this.onClick())}),t.append(this.el)}buildSVG(){return`<svg class="mtb-pet-svg" width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <circle cx="24" cy="28" r="16" fill="${y}"/>
3
+ <circle cx="24" cy="28" r="14" fill="#10b981"/>
4
+ <circle cx="19" cy="25" r="3" fill="#fff"/>
5
+ <circle cx="29" cy="25" r="3" fill="#fff"/>
6
+ <circle cx="20" cy="24.5" r="1.5" fill="#064e3b"/>
7
+ <circle cx="30" cy="24.5" r="1.5" fill="#064e3b"/>
8
+ <ellipse cx="19.5" cy="23.5" rx="0.8" ry="0.6" fill="#fff" opacity="0.7"/>
9
+ <ellipse cx="29.5" cy="23.5" rx="0.8" ry="0.6" fill="#fff" opacity="0.7"/>
10
+ <path d="M20 31 Q24 34 28 31" stroke="#064e3b" stroke-width="1.5" stroke-linecap="round" fill="none"/>
11
+ <circle cx="15" cy="30" r="2.5" fill="${y}" opacity="0.4"/>
12
+ <circle cx="33" cy="30" r="2.5" fill="${y}" opacity="0.4"/>
13
+ <path d="M14 17 Q16 12 20 15" stroke="#10b981" stroke-width="2" stroke-linecap="round" fill="none"/>
14
+ <path d="M34 17 Q32 12 28 15" stroke="#10b981" stroke-width="2" stroke-linecap="round" fill="none"/>
15
+ </svg>`}setActive(t){this.el.classList.toggle("active",t),t&&this.bubble.classList.add("hidden")}destroy(){this.el.removeEventListener("click",this.onClick),this.el.remove()}}const ft=8e3;class mt{constructor(t,i,r){this.el=t.el("div","mtb-frustration-prompt"),this.el.innerHTML=`
16
+ <div class="mtb-frustration-icon">&#9888;&#65039;</div>
17
+ <span class="mtb-frustration-text">${i.frustration.prompt}</span>
18
+ <div class="mtb-frustration-actions">
19
+ <button class="mtb-frustration-tell">${i.frustration.action}</button>
20
+ <button class="mtb-frustration-dismiss">${i.frustration.dismiss}</button>
21
+ </div>
22
+ `,this.el.querySelector(".mtb-frustration-tell").addEventListener("click",r.onTell),this.el.querySelector(".mtb-frustration-dismiss").addEventListener("click",r.onDismiss),t.append(this.el),setTimeout(r.onDismiss,ft)}destroy(){this.el.remove()}}class bt{constructor(t,i,r,s){this.currentMode="markup",this.messages=i,this.el=t.el("div","mtb-toolbar"),this.el.innerHTML=this.buildHTML(i),t.append(this.el),this.hintEl=this.el.querySelector(".mtb-toolbar-hint"),this.markupBtn=this.el.querySelector(".mtb-toolbar-mode-markup"),this.recordBtn=this.el.querySelector(".mtb-toolbar-mode-record"),this.markupBtn.addEventListener("click",()=>{this.setMode("markup"),s?.("markup")}),this.recordBtn.addEventListener("click",()=>{this.setMode("record"),s?.("record")}),this.el.querySelector(".mtb-exit-btn").addEventListener("click",r)}buildHTML(t){return`
23
+ <div class="mtb-toolbar-modes">
24
+ <button class="mtb-toolbar-mode-btn mtb-toolbar-mode-markup active">
25
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><line x1="12" y1="3" x2="12" y2="7"/><line x1="12" y1="17" x2="12" y2="21"/><line x1="3" y1="12" x2="7" y2="12"/><line x1="17" y1="12" x2="21" y2="12"/></svg>${t.toolbar.markup}
26
+ </button>
27
+ <button class="mtb-toolbar-mode-btn mtb-toolbar-mode-record">
28
+ <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="9"/><circle cx="12" cy="12" r="4" fill="currentColor" stroke="none"/></svg>${t.toolbar.record}
29
+ </button>
30
+ </div>
31
+ <span class="mtb-toolbar-hint">${t.toolbar.hint}</span>
32
+ <span class="mtb-toolbar-sep"></span>
33
+ <button class="mtb-exit-btn">
34
+ <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">
35
+ <path d="M18 6L6 18M6 6l12 12"/>
36
+ </svg>${t.toolbar.exit}
37
+ </button>
38
+ `}setMode(t){this.currentMode=t,t==="markup"?(this.markupBtn.classList.add("active"),this.recordBtn.classList.remove("active"),this.hintEl.textContent=this.messages.toolbar.hint):(this.markupBtn.classList.remove("active"),this.recordBtn.classList.add("active"),this.hintEl.textContent=this.messages.toolbar.hintRecord)}getMode(){return this.currentMode}destroy(){this.el.remove()}}class gt{constructor(t,i){this.onMouseDown=i.onMouseDown,this.onMouseMove=i.onMouseMove,this.onMouseUp=i.onMouseUp,this.onMouseLeave=i.onMouseLeave,this.overlayEl=t.el("div","mtb-overlay"),this.overlayEl.addEventListener("mousedown",this.onMouseDown),this.overlayEl.addEventListener("mousemove",this.onMouseMove),this.overlayEl.addEventListener("mouseup",this.onMouseUp),this.overlayEl.addEventListener("mouseleave",this.onMouseLeave),t.append(this.overlayEl),this.dimEl=t.el("div","mtb-dim"),t.append(this.dimEl)}destroy(){this.overlayEl.removeEventListener("mousedown",this.onMouseDown),this.overlayEl.removeEventListener("mousemove",this.onMouseMove),this.overlayEl.removeEventListener("mouseup",this.onMouseUp),this.overlayEl.removeEventListener("mouseleave",this.onMouseLeave),this.overlayEl.remove(),this.dimEl.remove()}}class xt{constructor(t){this.highlightEl=t.el("div","mtb-highlight"),this.hide(),t.append(this.highlightEl)}highlight(t){const i=t.getBoundingClientRect();this.highlightEl.style.top=`${i.top-2}px`,this.highlightEl.style.left=`${i.left-2}px`,this.highlightEl.style.width=`${i.width+4}px`,this.highlightEl.style.height=`${i.height+4}px`,this.highlightEl.style.display="block"}hide(){this.highlightEl.style.display="none"}destroy(){this.highlightEl.remove()}}function wt(e){if(e instanceof HTMLElement){const t=e.getAttribute("aria-label");if(t)return t;const i=e.getAttribute("title");if(i)return i;const r=e.textContent?.trim().slice(0,40);if(r)return r;const s=e.placeholder;if(s)return s;const n=e.alt;if(n)return n;const o=e.getAttribute("data-mark");if(o)return o}return e.tagName.toLowerCase()}function yt(e){const t=[];let i=e;for(;i&&i!==document.body&&t.length<5;){let r=i.tagName.toLowerCase();if(i.id){r=`#${i.id}`,t.unshift(r);break}const s=Array.from(i.classList).filter(o=>!o.startsWith("mtb-")).slice(0,2).join(".");s&&(r+=`.${s}`);const n=i.parentElement;if(n){const o=Array.from(n.children).filter(a=>a.tagName===i.tagName);if(o.length>1){const a=o.indexOf(i)+1;r+=`:nth-child(${a})`}}t.unshift(r),i=i.parentElement}return t.join(" > ")}class kt{constructor(t){this.pins=[],this.shadow=t}addPin(t,i,r){const s=this.shadow.el("div","mtb-pin");s.textContent=String(r),s.style.top=`${i}px`,s.style.left=`${t}px`,this.shadow.append(s),this.pins.push(s)}clearAll(){for(const t of this.pins)t.remove();this.pins=[]}destroy(){this.clearAll()}}class vt{constructor(t,i){this.path=null,this.points=[],this.isDrawing=!1,this.onDrawComplete=i,this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svg.setAttribute("class","mtb-draw-svg"),t.append(this.svg)}startDraw(t,i){this.isDrawing=!0,this.points=[[t,i]],this.path=document.createElementNS("http://www.w3.org/2000/svg","path"),this.path.setAttribute("fill","none"),this.path.setAttribute("stroke",x.color),this.path.setAttribute("stroke-width",x.width),this.path.setAttribute("stroke-linecap",x.linecap),this.path.setAttribute("stroke-linejoin",x.linejoin),this.path.setAttribute("style",`filter:${x.filter}`),this.svg.appendChild(this.path)}continueDraw(t,i){!this.isDrawing||!this.path||(this.points.push([t,i]),this.path.setAttribute("d",this.buildPathD()))}endDraw(){if(!this.isDrawing||this.points.length<2){this.isDrawing=!1,this.path&&(this.path.remove(),this.path=null);return}this.isDrawing=!1;const t=this.getCenter(),i=this.buildPathD(),r={type:"draw",x:t[0],y:t[1],drawPath:i};this.onDrawComplete(r)}buildPathD(){if(this.points.length===0)return"";const[t,i]=this.points[0];let r=`M ${t} ${i}`;for(let s=1;s<this.points.length;s++){const[n,o]=this.points[s];r+=` L ${n} ${o}`}return r}getCenter(){const t=this.points.map(n=>n[0]),i=this.points.map(n=>n[1]),r=(Math.min(...t)+Math.max(...t))/2,s=(Math.min(...i)+Math.max(...i))/2;return[r,s]}clearAll(){for(;this.svg.firstChild;)this.svg.removeChild(this.svg.firstChild);this.path=null,this.isDrawing=!1,this.points=[]}cancelCurrentDraw(){this.path?.remove(),this.path=null,this.isDrawing=!1,this.points=[]}isCurrentlyDrawing(){return this.isDrawing}getPointCount(){return this.points.length}destroy(){this.svg.remove()}}const St=5;class D{constructor(t,i,r){this.messages=i,this.onReady=r,this.pinCount=0,this.interactionActive=!0,this.highlighter=new xt(t),this.pinMarker=new kt(t),this.drawLayer=new vt(t,s=>{this.onReady(s,this.messages.annotation.drawing)}),this.overlay=new gt(t,{onMouseDown:s=>this.handleMouseDown(s),onMouseMove:s=>this.handleMouseMove(s),onMouseUp:s=>this.handleMouseUp(s),onMouseLeave:()=>{this.drawLayer.isCurrentlyDrawing()&&this.drawLayer.endDraw(),this.highlighter.hide()}})}handleMouseDown(t){t.preventDefault(),this.drawLayer.startDraw(t.clientX,t.clientY)}handleMouseMove(t){if(this.drawLayer.isCurrentlyDrawing()){this.drawLayer.continueDraw(t.clientX,t.clientY),this.highlighter.hide();return}const i=_(t.clientX,t.clientY);i?this.highlighter.highlight(i):this.highlighter.hide()}handleMouseUp(t){if(!this.drawLayer.isCurrentlyDrawing())return;if(this.drawLayer.getPointCount()>=St){this.drawLayer.endDraw();return}this.drawLayer.cancelCurrentDraw();const i=_(t.clientX,t.clientY),r=i?wt(i):this.messages.annotation.element,s={type:"pin",x:t.clientX,y:t.clientY,targetSelector:i?yt(i):void 0,targetText:i?.textContent?.trim().slice(0,200)??"",targetName:r};this.pinMarker.addPin(t.clientX,t.clientY,++this.pinCount),this.drawLayer.clearAll(),this.highlighter.hide(),this.onReady(s,r)}dismissInteraction(){this.interactionActive&&(this.interactionActive=!1,this.overlay.destroy(),this.highlighter.destroy())}destroy(){this.dismissInteraction(),this.pinMarker.destroy(),this.drawLayer.destroy()}}function _(e,t){const i=document.getElementById("mtb-widget-host");i&&(i.style.display="none");const r=document.elementFromPoint(e,t);return i&&(i.style.display=""),r}class Et{constructor(t,i){this.loading=!1,this.onSubmit=i.onSubmit,this.onClose=i.onClose,this.submitLabel=i.messages.popup.submit,this.el=t.el("div","mtb-popup"),this.el.innerHTML=this.buildHTML(i),t.append(this.el),this.textarea=this.el.querySelector(".mtb-textarea"),this.submitBtn=this.el.querySelector(".mtb-submit-btn"),this.positionPopup(i.x,i.y),this.bindEvents(i.messages),this.textarea.focus()}buildHTML(t){const i=t.messages,r=i.popup.quickOptions.map(s=>`
39
+ <button class="mtb-quick-option" data-quick="${m(s.label)}">
40
+ <span class="mtb-quick-option-emoji">${s.emoji}</span>
41
+ <span>${m(s.label)}</span>
42
+ </button>`).join("");return`
43
+ <div class="mtb-popup-header">
44
+ <div class="mtb-popup-icon">
45
+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="#059669" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
46
+ <path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/><circle cx="12" cy="10" r="3"/>
47
+ </svg>
48
+ </div>
49
+ <span class="mtb-popup-title">${i.popup.about} "${m(t.targetName)}"</span>
50
+ <button class="mtb-popup-close" aria-label="Close">
51
+ <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
52
+ <path d="M18 6L6 18M6 6l12 12"/>
53
+ </svg>
54
+ </button>
55
+ </div>
56
+ <div class="mtb-popup-body">
57
+ <div class="mtb-quick-options">
58
+ ${r}
59
+ </div>
60
+ <div class="mtb-textarea-wrap">
61
+ <textarea class="mtb-textarea" placeholder="${m(i.popup.placeholder)}"></textarea>
62
+ </div>
63
+ <div class="mtb-popup-error" role="alert"></div>
64
+ <div class="mtb-popup-actions">
65
+ <button class="mtb-cancel-btn" type="button">${m(i.popup.cancel)}</button>
66
+ <button class="mtb-submit-btn" type="button" disabled>${m(i.popup.submit)}</button>
67
+ </div>
68
+ </div>
69
+ `}positionPopup(t,i){const n=window.innerWidth,o=window.innerHeight,a=12;let l=t+12,c=i+12;l+320>n-a&&(l=t-320-12),l<a&&(l=a),c+260>o-a&&(c=o-260-a),c<a&&(c=a),this.el.style.left=`${l}px`,this.el.style.top=`${c}px`}bindEvents(t){this.el.querySelector(".mtb-popup-close").addEventListener("click",()=>this.onClose()),this.el.querySelector(".mtb-cancel-btn").addEventListener("click",()=>this.onClose()),this.errorEl=this.el.querySelector(".mtb-popup-error"),this.el.querySelectorAll(".mtb-quick-option").forEach(i=>{i.addEventListener("click",()=>{const r=i.dataset.quick??"";this.textarea.value=r,this.updateSubmitState(),this.textarea.focus()})}),this.textarea.addEventListener("input",()=>this.updateSubmitState()),this.textarea.addEventListener("keydown",i=>{i.key==="Enter"&&(i.metaKey||i.ctrlKey)&&(i.preventDefault(),this.submit())}),this.submitBtn.addEventListener("click",()=>this.submit())}updateSubmitState(){const t=this.textarea.value.trim().length>0;this.submitBtn.classList.toggle("ready",t&&!this.loading),this.submitBtn.disabled=!t||this.loading,this.errorEl.hidden=!0,this.errorEl.textContent=""}submit(){const t=this.textarea.value.trim();!t||this.loading||this.onSubmit(t)}setLoading(t){this.loading=t,t?(this.submitBtn.classList.add("loading"),this.submitBtn.innerHTML='<span class="mtb-dot"></span><span class="mtb-dot"></span><span class="mtb-dot"></span>',this.textarea.disabled=!0):(this.submitBtn.classList.remove("loading"),this.submitBtn.textContent=this.submitLabel,this.textarea.disabled=!1),this.updateSubmitState()}setError(t){this.errorEl.textContent=t,this.errorEl.hidden=!1}destroy(){this.el.remove()}}function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const Ct=5e3;class Lt{constructor(t,i,r){this.el=t.el("div","mtb-success"),this.el.style.right="20px",this.el.style.bottom="20px",this.el.innerHTML=`
70
+ <div class="mtb-success-icon">
71
+ <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="${y}" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
72
+ <polyline points="20 6 9 17 4 12"/>
73
+ </svg>
74
+ </div>
75
+ <div class="mtb-success-title">${i.success.title}</div>
76
+ <div class="mtb-success-msg">${i.success.message}</div>
77
+ <button class="mtb-close-link">${i.success.close}</button>
78
+ `,t.append(this.el),this.el.querySelector(".mtb-close-link").addEventListener("click",r),setTimeout(()=>r(),Ct)}destroy(){this.el.remove()}}function Mt(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const i=document.implementation.createHTMLDocument(),r=i.createElement("base"),s=i.createElement("a");return i.head.appendChild(r),i.body.appendChild(s),t&&(r.href=t),s.href=e,s.href}const Rt=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function p(e){const t=[];for(let i=0,r=e.length;i<r;i++)t.push(e[i]);return t}let b=null;function V(e={}){return b||(e.includeStyleProperties?(b=e.includeStyleProperties,b):(b=p(window.getComputedStyle(document.documentElement)),b))}function S(e,t){const r=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function At(e){const t=S(e,"border-left-width"),i=S(e,"border-right-width");return e.clientWidth+t+i}function Tt(e){const t=S(e,"border-top-width"),i=S(e,"border-bottom-width");return e.clientHeight+t+i}function N(e,t={}){const i=t.width||At(e),r=t.height||Tt(e);return{width:i,height:r}}function Pt(){let e,t;try{t=process}catch{}const i=t&&t.env?t.env.devicePixelRatio:null;return i&&(e=parseInt(i,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const d=16384;function $t(e){(e.width>d||e.height>d)&&(e.width>d&&e.height>d?e.width>e.height?(e.height*=d/e.width,e.width=d):(e.width*=d/e.height,e.height=d):e.width>d?(e.height*=d/e.width,e.width=d):(e.width*=d/e.height,e.height=d))}function E(e){return new Promise((t,i)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=i,r.crossOrigin="anonymous",r.decoding="async",r.src=e})}async function Dt(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function _t(e,t,i){const r="http://www.w3.org/2000/svg",s=document.createElementNS(r,"svg"),n=document.createElementNS(r,"foreignObject");return s.setAttribute("width",`${t}`),s.setAttribute("height",`${i}`),s.setAttribute("viewBox",`0 0 ${t} ${i}`),n.setAttribute("width","100%"),n.setAttribute("height","100%"),n.setAttribute("x","0"),n.setAttribute("y","0"),n.setAttribute("externalResourcesRequired","true"),s.appendChild(n),n.appendChild(e),Dt(s)}const h=(e,t)=>{if(e instanceof t)return!0;const i=Object.getPrototypeOf(e);return i===null?!1:i.constructor.name===t.name||h(i,t)};function It(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function Ht(e,t){return V(t).map(i=>{const r=e.getPropertyValue(i),s=e.getPropertyPriority(i);return`${i}: ${r}${s?" !important":""};`}).join(" ")}function Ft(e,t,i,r){const s=`.${e}:${t}`,n=i.cssText?It(i):Ht(i,r);return document.createTextNode(`${s}{${n}}`)}function I(e,t,i,r){const s=window.getComputedStyle(e,i),n=s.getPropertyValue("content");if(n===""||n==="none")return;const o=Rt();try{t.className=`${t.className} ${o}`}catch{return}const a=document.createElement("style");a.appendChild(Ft(o,i,s,r)),t.appendChild(a)}function Ot(e,t,i){I(e,t,":before",i),I(e,t,":after",i)}const H="application/font-woff",F="image/jpeg",Bt={woff:H,woff2:H,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:F,jpeg:F,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function Ut(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function T(e){const t=Ut(e).toLowerCase();return Bt[t]||""}function jt(e){return e.split(/,/)[1]}function R(e){return e.search(/^(data:)/)!==-1}function zt(e,t){return`data:${t};base64,${e}`}async function Y(e,t,i){const r=await fetch(e,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const s=await r.blob();return new Promise((n,o)=>{const a=new FileReader;a.onerror=o,a.onloadend=()=>{try{n(i({res:r,result:a.result}))}catch(l){o(l)}},a.readAsDataURL(s)})}const M={};function qt(e,t,i){let r=e.replace(/\?.*/,"");return i&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function P(e,t,i){const r=qt(e,t,i.includeQueryParams);if(M[r]!=null)return M[r];i.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let s;try{const n=await Y(e,i.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),jt(a)));s=zt(n,t)}catch(n){s=i.imagePlaceholder||"";let o=`Failed to fetch resource: ${e}`;n&&(o=typeof n=="string"?n:n.message),o&&console.warn(o)}return M[r]=s,s}async function Wt(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):E(t)}async function Vt(e,t){if(e.currentSrc){const n=document.createElement("canvas"),o=n.getContext("2d");n.width=e.clientWidth,n.height=e.clientHeight,o?.drawImage(e,0,0,n.width,n.height);const a=n.toDataURL();return E(a)}const i=e.poster,r=T(i),s=await P(i,r,t);return E(s)}async function Nt(e,t){var i;try{if(!((i=e?.contentDocument)===null||i===void 0)&&i.body)return await C(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function Yt(e,t){return h(e,HTMLCanvasElement)?Wt(e):h(e,HTMLVideoElement)?Vt(e,t):h(e,HTMLIFrameElement)?Nt(e,t):e.cloneNode(X(e))}const Xt=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",X=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function Gt(e,t,i){var r,s;if(X(t))return t;let n=[];return Xt(e)&&e.assignedNodes?n=p(e.assignedNodes()):h(e,HTMLIFrameElement)&&(!((r=e.contentDocument)===null||r===void 0)&&r.body)?n=p(e.contentDocument.body.childNodes):n=p(((s=e.shadowRoot)!==null&&s!==void 0?s:e).childNodes),n.length===0||h(e,HTMLVideoElement)||await n.reduce((o,a)=>o.then(()=>C(a,i)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function Kt(e,t,i){const r=t.style;if(!r)return;const s=window.getComputedStyle(e);s.cssText?(r.cssText=s.cssText,r.transformOrigin=s.transformOrigin):V(i).forEach(n=>{let o=s.getPropertyValue(n);n==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),h(e,HTMLIFrameElement)&&n==="display"&&o==="inline"&&(o="block"),n==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(n,o,s.getPropertyPriority(n))})}function Jt(e,t){h(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),h(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function Qt(e,t){if(h(e,HTMLSelectElement)){const i=t,r=Array.from(i.children).find(s=>e.value===s.getAttribute("value"));r&&r.setAttribute("selected","")}}function Zt(e,t,i){return h(t,Element)&&(Kt(e,t,i),Ot(e,t,i),Jt(e,t),Qt(e,t)),t}async function te(e,t){const i=e.querySelectorAll?e.querySelectorAll("use"):[];if(i.length===0)return e;const r={};for(let n=0;n<i.length;n++){const a=i[n].getAttribute("xlink:href");if(a){const l=e.querySelector(a),c=document.querySelector(a);!l&&c&&!r[a]&&(r[a]=await C(c,t,!0))}}const s=Object.values(r);if(s.length){const n="http://www.w3.org/1999/xhtml",o=document.createElementNS(n,"svg");o.setAttribute("xmlns",n),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const a=document.createElementNS(n,"defs");o.appendChild(a);for(let l=0;l<s.length;l++)a.appendChild(s[l]);e.appendChild(o)}return e}async function C(e,t,i){return!i&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(r=>Yt(r,t)).then(r=>Gt(e,r,t)).then(r=>Zt(e,r,t)).then(r=>te(r,t))}const G=/url\((['"]?)([^'"]+?)\1\)/g,ee=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,ie=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function re(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function se(e){const t=[];return e.replace(G,(i,r,s)=>(t.push(s),i)),t.filter(i=>!R(i))}async function ne(e,t,i,r,s){try{const n=i?Mt(t,i):t,o=T(t);let a;return s||(a=await P(n,o,r)),e.replace(re(t),`$1${a}$3`)}catch{}return e}function oe(e,{preferredFontFormat:t}){return t?e.replace(ie,i=>{for(;;){const[r,,s]=ee.exec(i)||[];if(!s)return"";if(s===t)return`src: ${r};`}}):e}function K(e){return e.search(G)!==-1}async function J(e,t,i){if(!K(e))return e;const r=oe(e,i);return se(r).reduce((n,o)=>n.then(a=>ne(a,o,t,i)),Promise.resolve(r))}async function g(e,t,i){var r;const s=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(e);if(s){const n=await J(s,null,i);return t.style.setProperty(e,n,t.style.getPropertyPriority(e)),!0}return!1}async function ae(e,t){await g("background",e,t)||await g("background-image",e,t),await g("mask",e,t)||await g("-webkit-mask",e,t)||await g("mask-image",e,t)||await g("-webkit-mask-image",e,t)}async function le(e,t){const i=h(e,HTMLImageElement);if(!(i&&!R(e.src))&&!(h(e,SVGImageElement)&&!R(e.href.baseVal)))return;const r=i?e.src:e.href.baseVal,s=await P(r,T(r),t);await new Promise((n,o)=>{e.onload=n,e.onerror=t.onImageErrorHandler?(...l)=>{try{n(t.onImageErrorHandler(...l))}catch(c){o(c)}}:o;const a=e;a.decode&&(a.decode=n),a.loading==="lazy"&&(a.loading="eager"),i?(e.srcset="",e.src=s):e.href.baseVal=s})}async function ce(e,t){const r=p(e.childNodes).map(s=>Q(s,t));await Promise.all(r).then(()=>e)}async function Q(e,t){h(e,Element)&&(await ae(e,t),await le(e,t),await ce(e,t))}function he(e,t){const{style:i}=e;t.backgroundColor&&(i.backgroundColor=t.backgroundColor),t.width&&(i.width=`${t.width}px`),t.height&&(i.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(s=>{i[s]=r[s]}),e}const O={};async function B(e){let t=O[e];if(t!=null)return t;const r=await(await fetch(e)).text();return t={url:e,cssText:r},O[e]=t,t}async function U(e,t){let i=e.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,n=(i.match(/url\([^)]+\)/g)||[]).map(async o=>{let a=o.replace(r,"$1");return a.startsWith("https://")||(a=new URL(a,e.url).href),Y(a,t.fetchRequestInit,({result:l})=>(i=i.replace(o,`url(${l})`),[o,l]))});return Promise.all(n).then(()=>i)}function j(e){if(e==null)return[];const t=[],i=/(\/\*[\s\S]*?\*\/)/gi;let r=e.replace(i,"");const s=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=s.exec(r);if(l===null)break;t.push(l[0])}r=r.replace(s,"");const n=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",a=new RegExp(o,"gi");for(;;){let l=n.exec(r);if(l===null){if(l=a.exec(r),l===null)break;n.lastIndex=a.lastIndex}else a.lastIndex=n.lastIndex;t.push(l[0])}return t}async function de(e,t){const i=[],r=[];return e.forEach(s=>{if("cssRules"in s)try{p(s.cssRules||[]).forEach((n,o)=>{if(n.type===CSSRule.IMPORT_RULE){let a=o+1;const l=n.href,c=B(l).then(u=>U(u,t)).then(u=>j(u).forEach(L=>{try{s.insertRule(L,L.startsWith("@import")?a+=1:s.cssRules.length)}catch(it){console.error("Error inserting rule from remote css",{rule:L,error:it})}})).catch(u=>{console.error("Error loading remote css",u.toString())});r.push(c)}})}catch(n){const o=e.find(a=>a.href==null)||document.styleSheets[0];s.href!=null&&r.push(B(s.href).then(a=>U(a,t)).then(a=>j(a).forEach(l=>{o.insertRule(l,o.cssRules.length)})).catch(a=>{console.error("Error loading remote stylesheet",a)})),console.error("Error inlining remote css file",n)}}),Promise.all(r).then(()=>(e.forEach(s=>{if("cssRules"in s)try{p(s.cssRules||[]).forEach(n=>{i.push(n)})}catch(n){console.error(`Error while reading CSS rules from ${s.href}`,n)}}),i))}function ue(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>K(t.style.getPropertyValue("src")))}async function pe(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const i=p(e.ownerDocument.styleSheets),r=await de(i,t);return ue(r)}function Z(e){return e.trim().replace(/["']/g,"")}function fe(e){const t=new Set;function i(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(n=>{t.add(Z(n))}),Array.from(r.children).forEach(n=>{n instanceof HTMLElement&&i(n)})}return i(e),t}async function me(e,t){const i=await pe(e,t),r=fe(e);return(await Promise.all(i.filter(n=>r.has(Z(n.style.fontFamily))).map(n=>{const o=n.parentStyleSheet?n.parentStyleSheet.href:null;return J(n.cssText,o,t)}))).join(`
79
+ `)}async function be(e,t){const i=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await me(e,t);if(i){const r=document.createElement("style"),s=document.createTextNode(i);r.appendChild(s),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function ge(e,t={}){const{width:i,height:r}=N(e,t),s=await C(e,t,!0);return await be(s,t),await Q(s,t),he(s,t),await _t(s,i,r)}async function xe(e,t={}){const{width:i,height:r}=N(e,t),s=await ge(e,t),n=await E(s),o=document.createElement("canvas"),a=o.getContext("2d"),l=t.pixelRatio||Pt(),c=t.canvasWidth||i,u=t.canvasHeight||r;return o.width=c*l,o.height=u*l,t.skipAutoScale||$t(o),o.style.width=`${c}`,o.style.height=`${u}`,t.backgroundColor&&(a.fillStyle=t.backgroundColor,a.fillRect(0,0,o.width,o.height)),a.drawImage(n,0,0,o.width,o.height),o}async function we(e,t={}){return(await xe(e,t)).toDataURL()}async function ye(e=[]){const t=ke(e);try{const i=await we(document.body,{cacheBust:!0,skipAutoScale:!1,filter:r=>!(r instanceof HTMLElement&&r.id==="mtb-widget-host")});return Ee(i)}catch{return null}finally{t?.remove()}}function ke(e){if(e.length===0)return null;const t=document.createElement("div");t.setAttribute("data-mtb-capture-annotations","true"),t.setAttribute("aria-hidden","true"),t.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:2147483645;";for(const[i,r]of e.entries())r.type==="pin"?t.appendChild(ve(r,i+1)):r.type==="draw"&&r.drawPath&&t.appendChild(Se(r.drawPath));return document.body.appendChild(t),t}function ve(e,t){const i=document.createElement("div");return i.textContent=String(t),i.style.cssText=["position:fixed",`left:${e.x}px`,`top:${e.y}px`,"width:22px","height:22px","border-radius:50% 50% 50% 2px","background:#059669","border:2px solid #fff","display:flex","align-items:center","justify-content:center",'font:700 10px -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',"color:#fff","box-shadow:0 2px 8px rgba(5,150,105,0.45)","transform:translate(-50%,-50%)"].join(";"),i}function Se(e){const t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("width","100%"),t.setAttribute("height","100%"),t.setAttribute("viewBox",`0 0 ${window.innerWidth} ${window.innerHeight}`),t.style.cssText="position:fixed;inset:0;width:100%;height:100%;overflow:visible;";const i=document.createElementNS("http://www.w3.org/2000/svg","path");return i.setAttribute("d",e),i.setAttribute("fill","none"),i.setAttribute("stroke","#059669"),i.setAttribute("stroke-width","3.5"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),i.setAttribute("filter","drop-shadow(0 1px 2px rgba(5,150,105,0.35))"),t.appendChild(i),t}function Ee(e){const[t,i]=e.split(","),r=t.match(/:(.*?);/)?.[1]??"image/png",s=atob(i),n=new Uint8Array(s.length);for(let o=0;o<s.length;o++)n[o]=s.charCodeAt(o);return new Blob([n],{type:r})}class Ce{constructor(){this.listeners=new Set,this.originalOnError=null,this.rejectionHandler=null,this.hooked=!1}subscribe(t){return this.listeners.add(t),this.hook(),()=>{this.listeners.delete(t),this.listeners.size===0&&this.unhook()}}hook(){this.hooked||(this.hooked=!0,this.originalOnError=window.onerror,window.onerror=(t,i,r,s,n)=>(this.emit({message:String(t),source:i,line:r,col:s,error:n}),this.originalOnError?this.originalOnError.call(window,t,i,r,s,n):!1),this.rejectionHandler=t=>{const i=t.reason instanceof Error?t.reason.message:String(t.reason);this.emit({message:`Unhandled rejection: ${i}`})},window.addEventListener("unhandledrejection",this.rejectionHandler))}unhook(){this.hooked&&(this.hooked=!1,window.onerror=this.originalOnError,this.originalOnError=null,this.rejectionHandler&&(window.removeEventListener("unhandledrejection",this.rejectionHandler),this.rejectionHandler=null))}emit(t){for(const i of this.listeners)i(t)}}const tt=new Ce,Le=20;class Me{constructor(){this.errors=[],this.unsubscribe=null}start(){this.unsubscribe||(this.unsubscribe=tt.subscribe(t=>this.record(t)))}record(t){const i=t.line!=null?` (${t.line}:${t.col??0})`:"";this.addError(`${t.message}${i}`)}addError(t){this.errors.length>=Le||this.errors.includes(t)||this.errors.push(t)}getErrors(){return[...this.errors]}stop(){this.unsubscribe?.(),this.unsubscribe=null}}const Re=3,Ae=1e3,Te=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","LABEL","SUMMARY","DETAILS"]),Pe=new Set(["button","link","checkbox","radio","tab","menuitem","option","switch","textbox","combobox","listbox","slider","spinbutton"]),k=class k{constructor(t){this.clickHistory=[],this.unsubscribeErrors=null,this.active=!1,this.errorCount=0,this.deadClickCount=0,this.cooldownUntil=0,this.onFrustration=t,this.boundClickHandler=i=>this.handleClick(i)}start(){this.active||(this.active=!0,document.addEventListener("click",this.boundClickHandler,!0),this.unsubscribeErrors=tt.subscribe(t=>{this.errorCount++}))}stop(){this.active&&(this.active=!1,document.removeEventListener("click",this.boundClickHandler,!0),this.unsubscribeErrors?.(),this.unsubscribeErrors=null,this.clickHistory=[])}handleClick(t){const i=t.target;if(!i||this.isWidgetElement(i))return;const r=Date.now();this.clickHistory.push({target:i,time:r});const s=r-Ae;if(this.clickHistory=this.clickHistory.filter(o=>o.time>s),this.clickHistory.filter(o=>o.target===i).length>=Re){this.clickHistory=[],this.emitHighPriority({signal:"rage_click",target:z(i),timestamp:r});return}this.isInteractive(i)||(this.deadClickCount++,this.deadClickCount>=3&&this.errorCount>0&&(this.deadClickCount=0,this.errorCount=0,this.emitIfReady({signal:"dead_click",target:z(i),timestamp:r})))}isInteractive(t){if(Te.has(t.tagName))return!0;const i=t.getAttribute("role");return!!(i&&Pe.has(i)||t.hasAttribute("onclick")||t.hasAttribute("tabindex")||t.contentEditable==="true"||window.getComputedStyle(t).cursor==="pointer"||t.closest('a, button, [role="button"], [role="link"], label'))}isWidgetElement(t){const i=document.getElementById("mtb-widget-host");return i?i===t||i.contains(t):!1}emitIfReady(t){const i=Date.now();i<this.cooldownUntil||(this.cooldownUntil=i+k.COOLDOWN_MS,this.onFrustration(t))}emitHighPriority(t){this.cooldownUntil=Date.now()+k.COOLDOWN_MS,this.onFrustration(t)}};k.COOLDOWN_MS=6e4;let A=k;function z(e){const t=e.tagName.toLowerCase(),i=e.id?`#${e.id}`:"",r=e.className&&typeof e.className=="string"?"."+e.className.trim().split(/\s+/).slice(0,2).join("."):"",s=e.textContent?.trim().slice(0,30)??"";return`<${t}${i}${r}>${s?` "${s}"`:""}`}function $e(){return{page_url:window.location.href,user_agent:navigator.userAgent,browser:De(),os:_e(),screen_width:window.screen.width,screen_height:window.screen.height}}function De(){const e=navigator.userAgent;return/Edg\//.test(e)?`Edge ${e.match(/Edg\/(\S+)/)?.[1]??""}`:/OPR\//.test(e)?`Opera ${e.match(/OPR\/(\S+)/)?.[1]??""}`:/Chrome\//.test(e)?`Chrome ${e.match(/Chrome\/(\S+)/)?.[1]??""}`:/Safari\//.test(e)&&/Version\//.test(e)?`Safari ${e.match(/Version\/(\S+)/)?.[1]??""}`:/Firefox\//.test(e)?`Firefox ${e.match(/Firefox\/(\S+)/)?.[1]??""}`:"Unknown"}function _e(){const e=navigator.userAgent;return/Windows NT 10/.test(e)?"Windows 10/11":/Windows NT/.test(e)?"Windows":/Mac OS X 10_15|macOS 1[56789]/.test(e)||/Mac OS X/.test(e)?"macOS":/Android/.test(e)?`Android ${e.match(/Android (\d+)/)?.[1]??""}`:/iPhone|iPad|iPod/.test(e)?"iOS":/Linux/.test(e)?"Linux":"Unknown"}const Ie="https://makethisbetter.dev/api/v1";class He{constructor(t,i,r=1e3){this.projectKey=t,this.apiUrl=(i??Ie).replace(/\/$/,""),this.retryDelayMs=r}async submitFeedback(t,i){const r=new FormData;if(r.append("feedback[description]",t.description),r.append("feedback[page_url]",t.page_url),r.append("feedback[user_agent]",t.user_agent),r.append("feedback[browser]",t.browser),r.append("feedback[os]",t.os),r.append("feedback[screen_width]",String(t.screen_width)),r.append("feedback[screen_height]",String(t.screen_height)),r.append("feedback[console_errors]",JSON.stringify(t.console_errors)),r.append("feedback[annotations]",JSON.stringify(t.annotations)),t.target_element&&r.append("feedback[target_element]",JSON.stringify(t.target_element)),t.user_id&&r.append("feedback[user_id]",t.user_id),t.user_email&&r.append("feedback[user_email]",t.user_email),t.user_name&&r.append("feedback[user_name]",t.user_name),t.recording_events&&t.recording_events.length>0){const s=JSON.stringify(t.recording_events),n=new Blob([s],{type:"application/json"});r.append("feedback[recording]",n,"recording.json"),r.append("feedback[recording_duration]",String(t.recording_duration??0))}i&&r.append("feedback[screenshot]",i,"screenshot.png"),await this.fetchWithRetry(`${this.apiUrl}/widget/feedbacks`,{method:"POST",headers:{"X-Project-Key":this.projectKey},body:r})}async fetchWithRetry(t,i,r=1){let s;try{s=await fetch(t,i)}catch(n){if(r>0)return await q(this.retryDelayMs),this.fetchWithRetry(t,i,r-1);throw n}if(s.ok)return s;if(s.status>=500&&r>0)return await q(this.retryDelayMs),this.fetchWithRetry(t,i,r-1);throw new Error(`HTTP ${s.status}`)}}function q(e){return e<=0?Promise.resolve():new Promise(t=>setTimeout(t,e))}function Fe(e,t,i,r,s,n){return{description:e,...t,console_errors:i,annotations:r?[r]:[],target_element:r?.targetSelector?{selector:r.targetSelector,text:r.targetText??"",name:r.targetName??""}:void 0,user_id:s?.id,user_email:s?.email,user_name:s?.name,recording_events:n?.events,recording_duration:n?.duration}}const Oe={tab:"Feedback",toolbar:{markup:"Mark up",record:"Record",hint:"Click any element to annotate · drag to draw",hintRecord:"Recording your screen",exit:"Exit"},popup:{about:"About",placeholder:"Describe the issue or suggestion...",submit:"Submit",cancel:"Cancel",quickOptions:[{emoji:"🐛",label:"Something is broken"},{emoji:"💡",label:"I wish this worked differently"},{emoji:"🤔",label:"I don't understand this"},{emoji:"✨",label:"I have an idea"}]},success:{title:"Thanks!",message:"Your feedback has been received.",close:"Close"},error:{submit:"Failed to submit. Please try again."},pet:{bubble:"Need help?"},frustration:{prompt:"Something not working? Tell us.",action:"Annotate",dismiss:"Dismiss"},annotation:{drawing:"Drawing",element:"element"},record:{stop:"Stop",timer_label:"Recording",max_reached:"Maximum recording time reached"}},Be={tab:"反馈",toolbar:{markup:"标注",record:"录屏",hint:"点击任意元素进行标注 · 拖拽可自由绘制",hintRecord:"正在录制屏幕",exit:"退出"},popup:{about:"关于",placeholder:"描述问题或建议...",submit:"提交",cancel:"取消",quickOptions:[{emoji:"🐛",label:"这里有问题"},{emoji:"💡",label:"我希望它能更好用"},{emoji:"🤔",label:"我看不懂这里"},{emoji:"✨",label:"我有个想法"}]},success:{title:"感谢!",message:"您的反馈已收到。",close:"关闭"},error:{submit:"提交失败,请重试。"},pet:{bubble:"需要帮助吗?"},frustration:{prompt:"遇到问题了?告诉我们。",action:"标注",dismiss:"关闭"},annotation:{drawing:"绘制",element:"元素"},record:{stop:"停止",timer_label:"录制中",max_reached:"已达到最大录制时长"}},w={en:Oe,"zh-CN":Be};function Ue(e){if(w[e])return w[e];const t=e.split("-")[0];return w[t]?w[t]:w.en}const je=60,ze="https://cdn.jsdelivr.net/npm/rrweb@2/dist/rrweb.min.js";let v=null;function qe(){return v||(v=We().catch(()=>Ve()),v)}async function We(){return(await import("rrweb")).record}function Ve(){return new Promise((e,t)=>{const i=globalThis;if(i.rrweb?.record){e(i.rrweb.record);return}const r=document.createElement("script");r.src=ze,r.onload=()=>{const s=globalThis;s.rrweb?.record?e(s.rrweb.record):t(new Error("rrweb global not found after script load"))},r.onerror=()=>t(new Error("Failed to load rrweb from CDN")),document.head.appendChild(r)})}class Ne{constructor(t,i){this.events=[],this.stopFn=null,this.startedAt=0,this.timer=null,this.clickHandler=null,this.stopped=!1,this.shadow=t,this.onMaxReached=i}async start(){const t=await qe();this.startedAt=Date.now(),this.stopped=!1,this.stopFn=t({emit:i=>{this.stopped||this.events.push(i)}}),this.clickHandler=i=>{this.showClickRipple(i.clientX,i.clientY),t.addCustomEvent?.("mtb-click",{x:i.clientX,y:i.clientY,target:i.target instanceof HTMLElement?i.target.tagName:""})},document.addEventListener("click",this.clickHandler,!0),this.timer=setTimeout(()=>{this.onMaxReached?.()},je*1e3)}stop(){return this.stopped=!0,this.stopFn?.(),this.stopFn=null,this.cleanupTimer(),this.cleanupClickHandler(),{events:this.events,duration:this.getDuration()}}getDuration(){return this.startedAt===0?0:Math.round((Date.now()-this.startedAt)/1e3)}destroy(){this.stopped=!0,this.stopFn?.(),this.stopFn=null,this.cleanupTimer(),this.cleanupClickHandler(),this.events=[],this.startedAt=0}cleanupTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null)}cleanupClickHandler(){this.clickHandler&&(document.removeEventListener("click",this.clickHandler,!0),this.clickHandler=null)}showClickRipple(t,i){const r=this.shadow.el("div","mtb-click-ripple");r.style.left=`${t}px`,r.style.top=`${i}px`,this.shadow.append(r),r.addEventListener("animationend",()=>r.remove())}}class Ye{constructor(t,i,r,s){this.intervalId=null,this.getDuration=r,this.el=t.el("div","mtb-record-bar"),this.el.innerHTML=`
80
+ <span class="mtb-record-dot"></span>
81
+ <span class="mtb-record-timer">00:00</span>
82
+ <button class="mtb-record-stop" type="button">${i.record.stop}</button>
83
+ `,t.append(this.el),this.timerEl=this.el.querySelector(".mtb-record-timer"),this.el.querySelector(".mtb-record-stop").addEventListener("click",s),this.intervalId=setInterval(()=>this.updateTimer(),1e3)}updateTimer(){const t=this.getDuration(),i=String(Math.floor(t/60)).padStart(2,"0"),r=String(t%60).padStart(2,"0");this.timerEl.textContent=`${i}:${r}`}destroy(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.el.remove()}}class W{constructor(t){this.tab=null,this.pet=null,this.toolbar=null,this.session=null,this.popup=null,this.success=null,this.frustrationPrompt=null,this.frustrationDetector=null,this.mode="idle",this.currentAnnotation=null,this.recordSession=null,this.recordBar=null,this.currentRecording=null,this.config=t,this.messages=Ue(t.locale??"en"),this.apiClient=new He(t.projectKey,t.apiUrl),this.consoleCollector=new Me,this.consoleCollector.start(),this.buildUI(),t.frustrationDetection!==!1&&(this.frustrationDetector=new A(()=>this.handleFrustration()),this.frustrationDetector.start())}buildUI(){this.shadow=new dt(this.config.theme??"auto"),(this.config.entryMode??"button")==="pet"?this.pet=new pt(this.shadow,this.messages,()=>this.handleTabClick()):this.tab=new ut(this.shadow,this.messages,this.config.position??"right",()=>this.handleTabClick())}handleTabClick(){this.mode==="idle"?(this.dismissFrustrationPrompt(),this.enterAnnotationMode()):this.exitAll()}handleFrustration(){this.mode!=="idle"||this.frustrationPrompt||(this.frustrationPrompt=new mt(this.shadow,this.messages,{onTell:()=>{this.dismissFrustrationPrompt(),this.enterAnnotationMode()},onDismiss:()=>this.dismissFrustrationPrompt()}))}dismissFrustrationPrompt(){this.frustrationPrompt?.destroy(),this.frustrationPrompt=null}enterAnnotationMode(){this.mode="annotating",this.tab?.setActive(!0),this.pet?.setActive(!0),this.toolbar=new bt(this.shadow,this.messages,()=>this.exitAll(),t=>this.handleToolbarModeChange(t)),this.session=new D(this.shadow,this.messages,(t,i)=>{this.currentAnnotation=t,this.showPopup(t.x,t.y,i)})}handleToolbarModeChange(t){t==="record"?this.enterRecordingMode():(this.exitRecordingMode(),this.session||(this.session=new D(this.shadow,this.messages,(i,r)=>{this.currentAnnotation=i,this.showPopup(i.x,i.y,r)})),this.mode="annotating")}async enterRecordingMode(){this.mode="recording",this.session?.destroy(),this.session=null,this.recordSession=new Ne(this.shadow,()=>this.stopRecording()),this.recordBar=new Ye(this.shadow,this.messages,()=>this.recordSession?.getDuration()??0,()=>this.stopRecording()),await this.recordSession.start()}stopRecording(){this.recordSession&&(this.currentRecording=this.recordSession.stop(),this.exitRecordingMode(),this.showPopup(window.innerWidth/2,window.innerHeight/2,this.messages.record.timer_label))}exitRecordingMode(){this.recordSession?.destroy(),this.recordSession=null,this.recordBar?.destroy(),this.recordBar=null}showPopup(t,i,r){this.mode="popup",this.session?.dismissInteraction(),this.popup=new Et(this.shadow,{targetName:r,x:t,y:i,messages:this.messages,onSubmit:s=>this.handleSubmit(s),onClose:()=>this.exitAll()})}async handleSubmit(t){if(!this.popup)return;this.popup.setLoading(!0);const i=this.currentAnnotation,r=this.currentRecording??void 0,[s,n]=await Promise.all([ye(i?[i]:[]),Promise.resolve($e())]),o=Fe(t,n,this.consoleCollector.getErrors(),i,this.config.user,r);try{await this.apiClient.submitFeedback(o,s),this.popup?.destroy(),this.popup=null,this.session?.destroy(),this.session=null,this.currentRecording=null,this.showSuccess()}catch{this.popup?.setLoading(!1),this.popup?.setError(this.messages.error.submit)}}showSuccess(){this.mode="idle",this.tab?.setActive(!1),this.pet?.setActive(!1),this.success=new Lt(this.shadow,this.messages,()=>{this.success?.destroy(),this.success=null})}exitAll(){this.mode="idle",this.tab?.setActive(!1),this.pet?.setActive(!1),this.toolbar?.destroy(),this.toolbar=null,this.session?.destroy(),this.session=null,this.popup?.destroy(),this.popup=null,this.currentAnnotation=null,this.currentRecording=null,this.exitRecordingMode()}destroy(){this.exitAll(),this.consoleCollector.stop(),this.frustrationDetector?.stop(),this.dismissFrustrationPrompt(),this.success?.destroy(),this.tab?.destroy(),this.pet?.destroy(),this.exitRecordingMode(),this.shadow.destroy()}}let f=null;const et={init(e){f&&(f.destroy(),f=null),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{f=new W(e)}):f=new W(e)},destroy(){f?.destroy(),f=null}};typeof window<"u"&&(window.MakeThisBetter=et);exports.MakeThisBetter=et;
84
+ //# sourceMappingURL=makethisbetter.cjs.js.map