makethisbetter 1.5.3 → 1.6.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 (109) hide show
  1. package/README.md +10 -10
  2. package/dist/annotate/draw-note-bar.d.ts +29 -0
  3. package/dist/annotate/draw-note-bar.d.ts.map +1 -0
  4. package/dist/annotate/draw-note-bar.test.d.ts +2 -0
  5. package/dist/annotate/draw-note-bar.test.d.ts.map +1 -0
  6. package/dist/annotate/draw.d.ts +15 -9
  7. package/dist/annotate/draw.d.ts.map +1 -1
  8. package/dist/annotate/highlighter.d.ts +2 -0
  9. package/dist/annotate/highlighter.d.ts.map +1 -1
  10. package/dist/annotate/session.d.ts +16 -2
  11. package/dist/annotate/session.d.ts.map +1 -1
  12. package/dist/api/client.d.ts +8 -5
  13. package/dist/api/client.d.ts.map +1 -1
  14. package/dist/context/breadcrumbs.d.ts +26 -0
  15. package/dist/context/breadcrumbs.d.ts.map +1 -0
  16. package/dist/context/breadcrumbs.test.d.ts +2 -0
  17. package/dist/context/breadcrumbs.test.d.ts.map +1 -0
  18. package/dist/context/dom-utils.d.ts +3 -0
  19. package/dist/context/dom-utils.d.ts.map +1 -0
  20. package/dist/context/frustration.d.ts +0 -1
  21. package/dist/context/frustration.d.ts.map +1 -1
  22. package/dist/i18n/de.d.ts +24 -0
  23. package/dist/i18n/de.d.ts.map +1 -1
  24. package/dist/i18n/en.d.ts +24 -0
  25. package/dist/i18n/en.d.ts.map +1 -1
  26. package/dist/i18n/es.d.ts +24 -0
  27. package/dist/i18n/es.d.ts.map +1 -1
  28. package/dist/i18n/fr.d.ts +24 -0
  29. package/dist/i18n/fr.d.ts.map +1 -1
  30. package/dist/i18n/ja.d.ts +24 -0
  31. package/dist/i18n/ja.d.ts.map +1 -1
  32. package/dist/i18n/ko.d.ts +24 -0
  33. package/dist/i18n/ko.d.ts.map +1 -1
  34. package/dist/i18n/zh-CN.d.ts +24 -0
  35. package/dist/i18n/zh-CN.d.ts.map +1 -1
  36. package/dist/makethisbetter.cjs +51 -26
  37. package/dist/makethisbetter.cjs.map +1 -1
  38. package/dist/makethisbetter.esm.js +1124 -591
  39. package/dist/makethisbetter.esm.js.map +1 -1
  40. package/dist/makethisbetter.js +50 -25
  41. package/dist/makethisbetter.js.map +1 -1
  42. package/dist/popup/clarify.d.ts +28 -7
  43. package/dist/popup/clarify.d.ts.map +1 -1
  44. package/dist/popup/comment.d.ts +1 -0
  45. package/dist/popup/comment.d.ts.map +1 -1
  46. package/dist/record/replay.d.ts +7 -0
  47. package/dist/record/replay.d.ts.map +1 -0
  48. package/dist/screenshot/capture.d.ts +1 -0
  49. package/dist/screenshot/capture.d.ts.map +1 -1
  50. package/dist/styles.d.ts +1 -0
  51. package/dist/styles.d.ts.map +1 -1
  52. package/dist/types.d.ts +13 -0
  53. package/dist/types.d.ts.map +1 -1
  54. package/dist/widget/controller.d.ts +16 -0
  55. package/dist/widget/controller.d.ts.map +1 -1
  56. package/dist/widget/dim-overlay.d.ts +8 -0
  57. package/dist/widget/dim-overlay.d.ts.map +1 -0
  58. package/dist/widget/dim-overlay.test.d.ts +2 -0
  59. package/dist/widget/dim-overlay.test.d.ts.map +1 -0
  60. package/dist/widget/payload.d.ts +2 -2
  61. package/dist/widget/payload.d.ts.map +1 -1
  62. package/dist/widget/tab.d.ts +3 -0
  63. package/dist/widget/tab.d.ts.map +1 -1
  64. package/package.json +2 -2
  65. package/src/annotate/draw-note-bar.test.ts +90 -0
  66. package/src/annotate/draw-note-bar.ts +105 -0
  67. package/src/annotate/draw.test.ts +74 -84
  68. package/src/annotate/draw.ts +108 -65
  69. package/src/annotate/highlighter.test.ts +24 -1
  70. package/src/annotate/highlighter.ts +16 -2
  71. package/src/annotate/session.test.ts +112 -96
  72. package/src/annotate/session.ts +54 -10
  73. package/src/api/client.test.ts +69 -30
  74. package/src/api/client.ts +68 -20
  75. package/src/context/breadcrumbs.test.ts +154 -0
  76. package/src/context/breadcrumbs.ts +157 -0
  77. package/src/context/dom-utils.ts +16 -0
  78. package/src/context/frustration.ts +4 -8
  79. package/src/i18n/de.ts +34 -11
  80. package/src/i18n/en.ts +33 -10
  81. package/src/i18n/es.ts +34 -11
  82. package/src/i18n/fr.ts +33 -10
  83. package/src/i18n/index.test.ts +12 -0
  84. package/src/i18n/ja.ts +32 -9
  85. package/src/i18n/ko.ts +34 -11
  86. package/src/i18n/zh-CN.ts +35 -12
  87. package/src/popup/clarify.test.ts +143 -43
  88. package/src/popup/clarify.ts +160 -46
  89. package/src/popup/comment.test.ts +57 -0
  90. package/src/popup/comment.ts +15 -9
  91. package/src/record/replay.ts +115 -0
  92. package/src/record/session.test.ts +8 -1
  93. package/src/record/session.ts +1 -1
  94. package/src/screenshot/capture.test.ts +51 -23
  95. package/src/screenshot/capture.ts +101 -55
  96. package/src/styles/widget.css +347 -1
  97. package/src/styles.ts +2 -0
  98. package/src/types.ts +15 -0
  99. package/src/widget/controller.test.ts +335 -65
  100. package/src/widget/controller.ts +187 -35
  101. package/src/widget/dim-overlay.test.ts +27 -0
  102. package/src/widget/dim-overlay.ts +20 -0
  103. package/src/widget/payload.test.ts +26 -1
  104. package/src/widget/payload.ts +3 -1
  105. package/src/widget/pet.test.ts +2 -2
  106. package/src/widget/tab.test.ts +15 -0
  107. package/src/widget/tab.ts +11 -3
  108. package/dist/index.d.cts +0 -8
  109. package/dist/index.d.mts +0 -8
@@ -1,9 +1,9 @@
1
- const bt = '*,*: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:332px;background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:16px;box-shadow:0 20px 60px #00000029;padding:24px 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:46px;height:46px;border-radius:50%;background:#05966917;display:flex;align-items:center;justify-content:center;margin:0 auto 12px}.mtb-success-title{font-size:16px;font-weight:700;margin-bottom:5px;letter-spacing:-.01em;color:#191a1c}.mtb-success-msg{font-size:13px;color:#0000008c;margin-bottom:16px;line-height:1.6}.mtb-view-feedback-link{display:inline-flex;align-items:center;gap:5px;color:#047857;text-decoration:none;font-size:13px;font-weight:500;font-family:JetBrains Mono,monospace;background:none;border:none;cursor:pointer;transition:text-decoration .12s}.mtb-view-feedback-link:hover{text-decoration:underline}.mtb-close-link{margin-top:13px;background:none;border:none;cursor:pointer;font-size:12px;color:#0006;font-family:inherit;transition:color .12s}.mtb-close-link:hover{color:#000000b3}.mtb-email-capture{margin-bottom:14px;text-align:left}.mtb-email-prompt{font-size:12px;color:#0000008c;line-height:1.5;margin-bottom:8px}.mtb-email-row{display:flex;gap:6px}.mtb-email-input{flex:1;min-width:0;font-size:12.5px;font-family:inherit;padding:7px 10px;border:1px solid rgba(0,0,0,.14);border-radius:8px;outline:none}.mtb-email-input:focus{border-color:#059669}.mtb-email-input.mtb-email-invalid{border-color:#dc2626}.mtb-email-submit{font-size:12px;font-weight:600;font-family:inherit;color:#fff;background:#059669;border:none;border-radius:8px;padding:7px 12px;cursor:pointer;white-space:nowrap}.mtb-email-submit:disabled{opacity:.6;cursor:default}.mtb-email-error{font-size:11.5px;color:#dc2626;margin-top:6px}.mtb-email-saved{font-size:12px;color:#059669;line-height:1.5}.mtb-my-feedback{display:block;margin:8px auto 0;background:none;border:none;cursor:pointer;font-size:11.5px;font-family:inherit;color:#0006;text-decoration:underline;text-underline-offset:2px;transition:color .12s}.mtb-my-feedback:hover{color:#059669}.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)}}.mtb-clarify{position:fixed;z-index:2147483645;width:346px;background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:14px;box-shadow:0 12px 40px #00000029;display:flex;flex-direction:column;animation:mtbSlideUp .28s cubic-bezier(.34,1.56,.64,1);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;overflow:hidden}.mtb-clarify-header{padding:11px 13px 11px 14px;display:flex;align-items:center;gap:9px;border-bottom:1px solid rgba(0,0,0,.06)}.mtb-clarify-icon{width:24px;height:24px;border-radius:7px;background:linear-gradient(140deg,#10b981,#059669);box-shadow:0 1px 3px #05966966;display:flex;align-items:center;justify-content:center;flex-shrink:0}.mtb-clarify-titles{flex:1;min-width:0}.mtb-clarify-title{font-size:12.5px;font-weight:650;line-height:1.2;color:#191a1c}.mtb-clarify-subtitle{font-size:10px;color:#0000006b}.mtb-clarify-close{background:none;border:none;cursor:pointer;padding:3px;color:#00000061;display:flex;transition:color .12s}.mtb-clarify-close:hover{color:#000000b3}.mtb-clarify-messages{flex:1;max-height:250px;overflow-y:auto;padding:13px 13px 5px;display:flex;flex-direction:column;gap:9px}.mtb-clarify-bubble{max-width:82%;padding:9px 12px;font-size:12.5px;line-height:1.5;white-space:pre-wrap;word-break:break-word}.mtb-clarify-ai{align-self:flex-start;background:#fff;color:#191a1c;border:1px solid rgba(0,0,0,.09);border-radius:13px 13px 13px 4px}.mtb-clarify-user{align-self:flex-end;background:#059669;color:#fff;border:1px solid #059669;border-radius:13px 13px 4px}.mtb-clarify-thinking{display:flex;align-items:center;gap:4px;padding:11px 14px}.mtb-clarify-thinking .mtb-dot{width:6px;height:6px;background:#059669b3}.mtb-clarify-footer{padding:3px 13px 13px;display:flex;flex-direction:column}.mtb-clarify-input{width:100%;height:52px;padding:9px 11px;border:1px solid rgba(0,0,0,.12);border-radius:9px;font-family:inherit;font-size:13px;line-height:1.5;color:#191a1c;outline:none;background:#fafafa;resize:none;box-sizing:border-box;transition:border-color .12s,box-shadow .12s,background .12s}.mtb-clarify-input:focus{border-color:#10b981;box-shadow:0 0 0 3px #10b9811f;background:#fff}.mtb-clarify-input::placeholder{color:#00000057}.mtb-clarify-actions{display:flex;gap:8px;margin-top:9px}.mtb-clarify-skip{flex:0 0 auto;height:34px;padding:0 14px;border:1px solid rgba(0,0,0,.12);border-radius:9px;background:#fff;cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:550;color:#0000008c;transition:background .12s}.mtb-clarify-skip:hover{background:#0000000a}.mtb-clarify-send{flex:1;height:34px;display:inline-flex;align-items:center;justify-content:center;gap:6px;border:none;border-radius:9px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:600;transition:background .12s}.mtb-clarify-send:not(:disabled):hover{background:#047857}.mtb-clarify-send:disabled{background:#00000026;cursor:not-allowed}:host([data-mtb-theme="dark"]) .mtb-clarify{background:#151719;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-clarify-header{border-bottom-color:#ffffff1a}:host([data-mtb-theme="dark"]) .mtb-clarify-title{color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-clarify-subtitle{color:#ffffff73}:host([data-mtb-theme="dark"]) .mtb-clarify-close{color:#ffffff73}:host([data-mtb-theme="dark"]) .mtb-clarify-close:hover{color:#ffffffbf}:host([data-mtb-theme="dark"]) .mtb-clarify-skip{background:#1f2327;border-color:#ffffff24;color:#ffffffb3}:host([data-mtb-theme="dark"]) .mtb-clarify-skip:hover{background:#ffffff0f}:host([data-mtb-theme="dark"]) .mtb-clarify-ai{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-clarify-input{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}@media (prefers-color-scheme: dark){:host([data-mtb-theme="auto"]) .mtb-clarify{background:#151719;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-clarify-header{border-bottom-color:#ffffff1a}:host([data-mtb-theme="auto"]) .mtb-clarify-title{color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-clarify-subtitle{color:#ffffff73}:host([data-mtb-theme="auto"]) .mtb-clarify-close{color:#ffffff73}:host([data-mtb-theme="auto"]) .mtb-clarify-close:hover{color:#ffffffbf}:host([data-mtb-theme="auto"]) .mtb-clarify-skip{background:#1f2327;border-color:#ffffff24;color:#ffffffb3}:host([data-mtb-theme="auto"]) .mtb-clarify-skip:hover{background:#ffffff0f}:host([data-mtb-theme="auto"]) .mtb-clarify-ai{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-clarify-input{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}}';
2
- class gt {
1
+ const yt = '*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}:host{all:initial;font-family:Inter,-apple-system,BlinkMacSystemFont,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 #05966973}.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}@media (max-width: 480px){.mtb-toolbar{max-width:calc(100vw - 16px);gap:6px}.mtb-toolbar-hint,.mtb-toolbar-sep{display:none}.mtb-toolbar-mode-btn,.mtb-exit-btn{padding-right:10px;padding-left:10px}}.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%,-100%);max-width:240px;overflow:hidden;text-overflow:ellipsis;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;font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif}.mtb-highlight-tooltip.below{transform:translate(-50%)}.mtb-highlight-tooltip:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);border:4px solid transparent;border-top-color:#064e3b}.mtb-highlight-tooltip.below:after{top:auto;bottom:100%;border-top-color:transparent;border-bottom-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;display:flex;flex-direction:column;width:320px;background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:16px;box-shadow:0 24px 64px #0000003d;overflow:hidden;animation:mtbSlideUp .28s cubic-bezier(.34,1.56,.64,1);font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif}@keyframes mtbSlideUp{0%{transform:translateY(14px) scale(.97);opacity:0}to{transform:translateY(0) scale(1);opacity:1}}.mtb-popup-header{flex-shrink:0;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{min-height:0;padding:13px;overflow-y:auto;overscroll-behavior:contain}.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:10px;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 #10b98126}.mtb-textarea::placeholder{color:#00000057}.mtb-popup-error{margin-top:8px;color:#dc2626;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:32px;border:none;border-radius:8px;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0 12px;font-family:inherit;font-size:12.5px;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:332px;background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:16px;box-shadow:0 24px 64px #0000003d;padding:24px 22px;text-align:center;animation:mtbSlideUp .35s cubic-bezier(.34,1.56,.64,1);font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif}.mtb-success-icon{width:46px;height:46px;border-radius:50%;background:#05966917;display:flex;align-items:center;justify-content:center;margin:0 auto 12px}.mtb-success-title{font-size:16px;font-weight:700;margin-bottom:5px;letter-spacing:-.01em;color:#191a1c}.mtb-success-msg{font-size:13px;color:#0000008c;margin-bottom:16px;line-height:1.6}.mtb-view-feedback-link{display:inline-flex;align-items:center;gap:5px;color:#047857;text-decoration:none;font-size:13px;font-weight:500;font-family:JetBrains Mono,monospace;background:none;border:none;cursor:pointer;transition:text-decoration .12s}.mtb-view-feedback-link:hover{text-decoration:underline}.mtb-close-link{margin-top:13px;background:none;border:none;cursor:pointer;font-size:12px;color:#0006;font-family:inherit;transition:color .12s}.mtb-close-link:hover{color:#000000b3}.mtb-email-capture{margin-bottom:14px;text-align:left}.mtb-email-prompt{font-size:12px;color:#0000008c;line-height:1.5;margin-bottom:8px}.mtb-email-row{display:flex;gap:6px}.mtb-email-input{flex:1;min-width:0;font-size:12.5px;font-family:inherit;padding:7px 10px;border:1px solid rgba(0,0,0,.14);border-radius:8px;outline:none}.mtb-email-input:focus{border-color:#059669}.mtb-email-input.mtb-email-invalid{border-color:#dc2626}.mtb-email-submit{font-size:12px;font-weight:600;font-family:inherit;color:#fff;background:#059669;border:none;border-radius:8px;padding:7px 12px;cursor:pointer;white-space:nowrap}.mtb-email-submit:disabled{opacity:.6;cursor:default}.mtb-email-error{font-size:11.5px;color:#dc2626;margin-top:6px}.mtb-email-saved{font-size:12px;color:#059669;line-height:1.5}.mtb-my-feedback{display:block;margin:8px auto 0;background:none;border:none;cursor:pointer;font-size:11.5px;font-family:inherit;color:#0006;text-decoration:underline;text-underline-offset:2px;transition:color .12s}.mtb-my-feedback:hover{color:#059669}.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:Inter,-apple-system,BlinkMacSystemFont,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)}}.mtb-clarify{position:fixed;z-index:2147483645;width:346px;background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:16px;box-shadow:0 24px 64px #0000003d;display:flex;flex-direction:column;animation:mtbSlideUp .28s cubic-bezier(.34,1.56,.64,1);font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif;overflow:hidden}.mtb-clarify-header{padding:11px 13px 11px 14px;display:flex;align-items:center;gap:9px;border-bottom:1px solid rgba(0,0,0,.06)}.mtb-clarify-icon{width:24px;height:24px;border-radius:7px;background:linear-gradient(140deg,#10b981,#059669);box-shadow:0 1px 3px #05966966;display:flex;align-items:center;justify-content:center;flex-shrink:0}.mtb-clarify-titles{flex:1;min-width:0}.mtb-clarify-title{font-size:12.5px;font-weight:650;line-height:1.2;color:#191a1c}.mtb-clarify-subtitle{font-size:10px;color:#0000006b}.mtb-clarify-close{background:none;border:none;cursor:pointer;padding:3px;color:#00000061;display:flex;transition:color .12s}.mtb-clarify-close:hover{color:#000000b3}.mtb-clarify-messages{flex:1;max-height:250px;overflow-y:auto;padding:13px 13px 5px;display:flex;flex-direction:column;gap:9px}.mtb-clarify-bubble{max-width:82%;padding:9px 12px;font-size:12.5px;line-height:1.5;white-space:pre-wrap;word-break:break-word}.mtb-clarify-ai{align-self:flex-start;background:#fff;color:#191a1c;border:1px solid rgba(0,0,0,.09);border-radius:13px 13px 13px 4px}.mtb-clarify-user{align-self:flex-end;background:#059669;color:#fff;border:1px solid #059669;border-radius:13px 13px 4px}.mtb-clarify-thinking{display:flex;align-items:center;gap:4px;padding:11px 14px}.mtb-clarify-thinking .mtb-dot{width:6px;height:6px;background:#059669b3}.mtb-clarify-footer{padding:3px 13px 13px;display:flex;flex-direction:column}.mtb-clarify-input{width:100%;height:52px;padding:9px 11px;border:1px solid rgba(0,0,0,.12);border-radius:10px;font-family:inherit;font-size:13px;line-height:1.5;color:#191a1c;outline:none;background:#fafafa;resize:none;box-sizing:border-box;transition:border-color .12s,box-shadow .12s,background .12s}.mtb-clarify-input:focus{border-color:#10b981;box-shadow:0 0 0 3px #10b98126;background:#fff}.mtb-clarify-input::placeholder{color:#00000057}.mtb-clarify-actions{display:flex;gap:8px;margin-top:9px}.mtb-clarify-skip{flex:0 0 auto;height:34px;padding:0 14px;border:1px solid rgba(0,0,0,.12);border-radius:10px;background:#fff;cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:550;color:#0000008c;white-space:nowrap;transition:background .12s}.mtb-clarify-skip:hover{background:#0000000a}.mtb-clarify-send{flex:1;height:34px;display:inline-flex;align-items:center;justify-content:center;gap:6px;border:none;border-radius:10px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:600;transition:background .12s}.mtb-clarify-send:not(:disabled):hover{background:#047857}.mtb-clarify-send:disabled{background:#00000026;cursor:not-allowed}.mtb-clarify-error{margin-bottom:8px;color:#dc2626;font-size:11.5px;line-height:1.4;text-align:center}:host([data-mtb-theme="dark"]) .mtb-clarify{background:#151719;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-clarify-header{border-bottom-color:#ffffff1a}:host([data-mtb-theme="dark"]) .mtb-clarify-title{color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-clarify-subtitle{color:#ffffff73}:host([data-mtb-theme="dark"]) .mtb-clarify-close{color:#ffffff73}:host([data-mtb-theme="dark"]) .mtb-clarify-close:hover{color:#ffffffbf}:host([data-mtb-theme="dark"]) .mtb-clarify-skip{background:#1f2327;border-color:#ffffff24;color:#ffffffb3}:host([data-mtb-theme="dark"]) .mtb-clarify-skip:hover{background:#ffffff0f}:host([data-mtb-theme="dark"]) .mtb-clarify-ai{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-clarify-input{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}@media (prefers-color-scheme: dark){:host([data-mtb-theme="auto"]) .mtb-clarify{background:#151719;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-clarify-header{border-bottom-color:#ffffff1a}:host([data-mtb-theme="auto"]) .mtb-clarify-title{color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-clarify-subtitle{color:#ffffff73}:host([data-mtb-theme="auto"]) .mtb-clarify-close{color:#ffffff73}:host([data-mtb-theme="auto"]) .mtb-clarify-close:hover{color:#ffffffbf}:host([data-mtb-theme="auto"]) .mtb-clarify-skip{background:#1f2327;border-color:#ffffff24;color:#ffffffb3}:host([data-mtb-theme="auto"]) .mtb-clarify-skip:hover{background:#ffffff0f}:host([data-mtb-theme="auto"]) .mtb-clarify-ai{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-clarify-input{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}}.mtb-dim-clickable{z-index:2147483643;pointer-events:auto;cursor:default;background:#0000001f}.mtb-draw-bar{position:fixed;bottom:24px;left:50%;transform:translate(-50%);z-index:2147483647;display:flex;align-items:center;gap:8px;height:46px;padding:0 8px 0 12px;border-radius:13px;background:#fff;border:1px solid rgba(0,0,0,.08);box-shadow:0 10px 30px #0f172a38;animation:mtbBarIn .2s ease;font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif}.mtb-draw-input{width:220px;height:32px;padding:0 10px;border:1px solid rgba(0,0,0,.12);border-radius:8px;font-family:inherit;font-size:13px;color:#191a1c;outline:none;background:#fafafa;transition:border-color .12s,box-shadow .12s,background .12s}.mtb-draw-input:focus{border-color:#10b981;box-shadow:0 0 0 3px #10b98126;background:#fff}.mtb-draw-input::placeholder{color:#00000057}.mtb-draw-icon-btn{width:30px;height:30px;display:inline-flex;align-items:center;justify-content:center;border:none;border-radius:8px;background:transparent;color:#374151;cursor:pointer;transition:background .12s,color .12s}.mtb-draw-icon-btn:hover:not(:disabled){background:#0000000f}.mtb-draw-icon-btn:disabled{color:#00000038;cursor:default}.mtb-draw-sep{width:1px;height:22px;background:#0000001a}.mtb-draw-cancel{height:32px;padding:0 12px;border:1px solid rgba(0,0,0,.12);border-radius:8px;background:#fff;color:#0000008c;cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:550;transition:background .12s}.mtb-draw-cancel:hover{background:#0000000a}.mtb-draw-submit{height:32px;padding:0 14px;border:none;border-radius:8px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:600;transition:background .12s}.mtb-draw-submit:hover:not(:disabled){background:#047857}.mtb-draw-submit:disabled{opacity:.6;cursor:default}.mtb-draw-error{position:absolute;bottom:100%;left:12px;margin-bottom:6px;color:#dc2626;font-size:11.5px}.mtb-record-preview{margin-bottom:12px}.mtb-record-preview-stage{position:relative;width:100%;height:132px;border-radius:10px;overflow:hidden;background:#0f172a;display:flex;align-items:center;justify-content:center}.mtb-record-preview-stage.playing{align-items:flex-start;justify-content:flex-start}.mtb-record-preview-play{width:44px;height:44px;border-radius:50%;border:none;background:#ffffffeb;color:#059669;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:transform .12s,background .12s}.mtb-record-preview-play:hover:not(:disabled){transform:scale(1.06);background:#fff}.mtb-record-preview-play:disabled{cursor:default;opacity:.6}.mtb-record-preview-badge{position:absolute;right:8px;bottom:8px;padding:2px 7px;border-radius:6px;background:#0009;color:#fff;font-size:11px;font-variant-numeric:tabular-nums;font-family:JetBrains Mono,SF Mono,monospace}.mtb-record-preview-fallback{color:#ffffffd9;font-size:12px}.mtb-record-preview-name{display:block;margin-top:5px;font-size:11px;color:#0000006b}.mtb-clarify-summary{align-self:stretch;border:1px solid rgba(5,150,105,.28);background:#0596690d;border-radius:12px;padding:11px 12px;display:flex;flex-direction:column;gap:9px}.mtb-summary-head{display:flex;align-items:center;gap:6px;color:#059669;font-size:12.5px;font-weight:650}.mtb-summary-section{display:flex;flex-direction:column;gap:3px}.mtb-summary-label{font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:.04em;color:#0006}.mtb-summary-quote{font-size:12.5px;color:#191a1c;line-height:1.45}.mtb-summary-qa{display:flex;flex-direction:column;gap:1px;font-size:12px;line-height:1.4}.mtb-summary-q{color:#00000080}.mtb-summary-a{color:#191a1c;font-weight:550}.mtb-summary-ctx{display:flex;justify-content:space-between;gap:10px;font-size:11.5px}.mtb-summary-ctx>span:first-child{color:#00000073}.mtb-summary-ctx>span:last-child{color:#191a1c;text-align:right;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:210px}.mtb-clarify-send-feedback{width:100%;height:36px;border:none;border-radius:10px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:13px;font-weight:600;transition:background .12s}.mtb-clarify-send-feedback:hover{background:#047857}';
2
+ class wt {
3
3
  constructor(t = "auto") {
4
4
  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" });
5
5
  const e = document.createElement("style");
6
- e.textContent = bt, this.root.appendChild(e);
6
+ e.textContent = yt, this.root.appendChild(e);
7
7
  }
8
8
  el(t, e) {
9
9
  const r = document.createElement(t);
@@ -20,21 +20,22 @@ class gt {
20
20
  this.host.remove();
21
21
  }
22
22
  }
23
- class yt {
23
+ class xt {
24
24
  constructor(t, e, r, s, n) {
25
- this.onClick = s, this.el = t.el("button", "mtb-tab"), r === "left" && this.el.classList.add("left");
26
- const o = n ?? e.tab;
27
- this.el.textContent = o, this.el.setAttribute("aria-label", o), this.el.addEventListener("click", s), t.append(this.el);
25
+ this.onClick = s, this.el = t.el("button", "mtb-tab"), r === "left" && this.el.classList.add("left"), this.idleLabel = n ?? e.tab, this.activeLabel = e.toolbar.exit, this.setLabel(this.idleLabel), this.el.addEventListener("click", s), t.append(this.el);
26
+ }
27
+ setLabel(t) {
28
+ this.el.textContent = t, this.el.setAttribute("aria-label", t);
28
29
  }
29
30
  setActive(t) {
30
- this.el.classList.toggle("active", t);
31
+ this.el.classList.toggle("active", t), this.setLabel(t ? this.activeLabel : this.idleLabel);
31
32
  }
32
33
  destroy() {
33
34
  this.el.removeEventListener("click", this.onClick), this.el.remove();
34
35
  }
35
36
  }
36
- const xt = 8e3;
37
- class wt {
37
+ const vt = 8e3;
38
+ class kt {
38
39
  constructor(t, e, r) {
39
40
  this.el = t.el("div", "mtb-frustration-prompt"), this.el.innerHTML = `
40
41
  <div class="mtb-frustration-icon">&#9888;&#65039;</div>
@@ -43,13 +44,21 @@ class wt {
43
44
  <button class="mtb-frustration-tell">${e.frustration.action}</button>
44
45
  <button class="mtb-frustration-dismiss">${e.frustration.dismiss}</button>
45
46
  </div>
46
- `, 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, xt);
47
+ `, 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, vt);
47
48
  }
48
49
  destroy() {
49
50
  this.el.remove();
50
51
  }
51
52
  }
52
- class kt {
53
+ class St {
54
+ constructor(t, e) {
55
+ this.onClick = e, this.el = t.el("div", "mtb-dim mtb-dim-clickable"), this.el.addEventListener("click", this.onClick), t.append(this.el);
56
+ }
57
+ destroy() {
58
+ this.el.removeEventListener("click", this.onClick), this.el.remove();
59
+ }
60
+ }
61
+ class Et {
53
62
  constructor(t, e, r, s) {
54
63
  this.currentMode = "markup", this.messages = e, this.el = t.el("div", "mtb-toolbar"), this.el.innerHTML = this.buildHTML(e), 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", () => {
55
64
  this.setMode("markup"), s?.("markup");
@@ -86,7 +95,7 @@ class kt {
86
95
  this.el.remove();
87
96
  }
88
97
  }
89
- class vt {
98
+ class Ct {
90
99
  constructor(t, e) {
91
100
  this.onMouseDown = e.onMouseDown, this.onMouseMove = e.onMouseMove, this.onMouseUp = e.onMouseUp, this.onMouseLeave = e.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);
92
101
  }
@@ -94,22 +103,27 @@ class vt {
94
103
  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();
95
104
  }
96
105
  }
97
- class St {
106
+ class _t {
98
107
  constructor(t) {
99
- this.highlightEl = t.el("div", "mtb-highlight"), this.hide(), t.append(this.highlightEl);
108
+ this.highlightEl = t.el("div", "mtb-highlight"), this.tooltipEl = t.el("div", "mtb-highlight-tooltip"), this.hide(), t.append(this.highlightEl, this.tooltipEl);
100
109
  }
101
110
  highlight(t) {
102
111
  const e = t.getBoundingClientRect();
103
- this.highlightEl.style.top = `${e.top - 2}px`, this.highlightEl.style.left = `${e.left - 2}px`, this.highlightEl.style.width = `${e.width + 4}px`, this.highlightEl.style.height = `${e.height + 4}px`, this.highlightEl.style.display = "block";
112
+ this.highlightEl.style.top = `${e.top - 2}px`, this.highlightEl.style.left = `${e.left - 2}px`, this.highlightEl.style.width = `${e.width + 4}px`, this.highlightEl.style.height = `${e.height + 4}px`, this.highlightEl.style.display = "block", this.showTooltip(t, e);
113
+ }
114
+ showTooltip(t, e) {
115
+ this.tooltipEl.textContent = H(t);
116
+ const r = e.top < 30;
117
+ this.tooltipEl.classList.toggle("below", r), this.tooltipEl.style.left = `${e.left + e.width / 2}px`, this.tooltipEl.style.top = r ? `${e.bottom + 8}px` : `${e.top - 8}px`, this.tooltipEl.style.display = "block";
104
118
  }
105
119
  hide() {
106
- this.highlightEl.style.display = "none";
120
+ this.highlightEl.style.display = "none", this.tooltipEl.style.display = "none";
107
121
  }
108
122
  destroy() {
109
- this.highlightEl.remove();
123
+ this.highlightEl.remove(), this.tooltipEl.remove();
110
124
  }
111
125
  }
112
- function Et(i) {
126
+ function H(i) {
113
127
  if (i instanceof HTMLElement) {
114
128
  const t = i.getAttribute("aria-label");
115
129
  if (t) return t;
@@ -126,7 +140,7 @@ function Et(i) {
126
140
  }
127
141
  return i.tagName.toLowerCase();
128
142
  }
129
- function Ct(i) {
143
+ function st(i) {
130
144
  const t = [];
131
145
  let e = i;
132
146
  for (; e && e !== document.body && t.length < 5; ) {
@@ -144,14 +158,14 @@ function Ct(i) {
144
158
  );
145
159
  if (o.length > 1) {
146
160
  const a = o.indexOf(e) + 1;
147
- r += `:nth-child(${a})`;
161
+ r += `:nth-of-type(${a})`;
148
162
  }
149
163
  }
150
164
  t.unshift(r), e = e.parentElement;
151
165
  }
152
166
  return t.join(" > ");
153
167
  }
154
- class _t {
168
+ class Tt {
155
169
  constructor(t) {
156
170
  this.pins = [], this.shadow = t;
157
171
  }
@@ -167,79 +181,101 @@ class _t {
167
181
  this.clearAll();
168
182
  }
169
183
  }
170
- const et = "#059669", v = {
171
- color: et,
184
+ const M = "#059669", Mt = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', v = {
185
+ color: M,
172
186
  width: "3.5",
173
187
  linecap: "round",
174
188
  linejoin: "round",
175
189
  filter: "drop-shadow(0 1px 2px rgba(5,150,105,0.35))"
176
190
  };
177
- class Mt {
178
- constructor(t, e) {
179
- this.path = null, this.points = [], this.isDrawing = !1, this.onDrawComplete = e, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.setAttribute("class", "mtb-draw-svg"), t.append(this.svg);
191
+ class Lt {
192
+ constructor(t) {
193
+ this.currentPath = null, this.currentPoints = [], this.isDrawing = !1, this.committed = [], this.redoStack = [], this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.setAttribute("class", "mtb-draw-svg"), t.append(this.svg);
180
194
  }
181
195
  startDraw(t, e) {
182
- this.isDrawing = !0, this.points = [[t, e]], this.path = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.path.setAttribute("fill", "none"), this.path.setAttribute("stroke", v.color), this.path.setAttribute("stroke-width", v.width), this.path.setAttribute("stroke-linecap", v.linecap), this.path.setAttribute("stroke-linejoin", v.linejoin), this.path.setAttribute("style", `filter:${v.filter}`), this.svg.appendChild(this.path);
196
+ this.isDrawing = !0, this.currentPoints = [[t, e]], this.currentPath = this.createPath(), this.svg.appendChild(this.currentPath);
183
197
  }
184
198
  continueDraw(t, e) {
185
- !this.isDrawing || !this.path || (this.points.push([t, e]), this.path.setAttribute("d", this.buildPathD()));
199
+ !this.isDrawing || !this.currentPath || (this.currentPoints.push([t, e]), this.currentPath.setAttribute("d", z(this.currentPoints)));
186
200
  }
187
- endDraw() {
188
- if (!this.isDrawing || this.points.length < 2) {
189
- this.isDrawing = !1, this.path && (this.path.remove(), this.path = null);
190
- return;
191
- }
192
- this.isDrawing = !1;
193
- const t = this.getCenter(), e = this.buildPathD(), r = {
201
+ // Commits the in-progress stroke to the undo stack and clears the redo stack.
202
+ // Callers decide whether the stroke has enough points before committing.
203
+ commitStroke() {
204
+ return !this.isDrawing || !this.currentPath ? !1 : (this.isDrawing = !1, this.committed.push({ path: this.currentPath, d: z(this.currentPoints), points: this.currentPoints }), this.redoStack = [], this.currentPath = null, this.currentPoints = [], !0);
205
+ }
206
+ cancelCurrentDraw() {
207
+ this.currentPath?.remove(), this.currentPath = null, this.isDrawing = !1, this.currentPoints = [];
208
+ }
209
+ undo() {
210
+ const t = this.committed.pop();
211
+ return t ? (t.path.remove(), this.redoStack.push({ d: t.d, points: t.points }), !0) : !1;
212
+ }
213
+ redo() {
214
+ const t = this.redoStack.pop();
215
+ if (!t) return !1;
216
+ const e = this.createPath();
217
+ return e.setAttribute("d", t.d), this.svg.appendChild(e), this.committed.push({ path: e, d: t.d, points: t.points }), !0;
218
+ }
219
+ canUndo() {
220
+ return this.committed.length > 0;
221
+ }
222
+ canRedo() {
223
+ return this.redoStack.length > 0;
224
+ }
225
+ hasStrokes() {
226
+ return this.committed.length > 0;
227
+ }
228
+ getAnnotation() {
229
+ if (this.committed.length === 0) return null;
230
+ const t = this.committed.flatMap((s) => s.points), [e, r] = Pt(t);
231
+ return {
194
232
  type: "draw",
195
- x: t[0],
196
- y: t[1],
197
- drawPath: e
233
+ x: e,
234
+ y: r,
235
+ drawPath: this.committed.map((s) => s.d).join(" ")
198
236
  };
199
- this.onDrawComplete(r);
200
- }
201
- buildPathD() {
202
- if (this.points.length === 0) return "";
203
- const [t, e] = this.points[0];
204
- let r = `M ${t} ${e}`;
205
- for (let s = 1; s < this.points.length; s++) {
206
- const [n, o] = this.points[s];
207
- r += ` L ${n} ${o}`;
208
- }
209
- return r;
210
- }
211
- getCenter() {
212
- const t = this.points.map((n) => n[0]), e = this.points.map((n) => n[1]), r = (Math.min(...t) + Math.max(...t)) / 2, s = (Math.min(...e) + Math.max(...e)) / 2;
213
- return [r, s];
214
237
  }
215
238
  clearAll() {
216
239
  for (; this.svg.firstChild; ) this.svg.removeChild(this.svg.firstChild);
217
- this.path = null, this.isDrawing = !1, this.points = [];
218
- }
219
- cancelCurrentDraw() {
220
- this.path?.remove(), this.path = null, this.isDrawing = !1, this.points = [];
240
+ this.currentPath = null, this.isDrawing = !1, this.currentPoints = [], this.committed = [], this.redoStack = [];
221
241
  }
222
242
  isCurrentlyDrawing() {
223
243
  return this.isDrawing;
224
244
  }
225
- getPointCount() {
226
- return this.points.length;
245
+ getCurrentPointCount() {
246
+ return this.currentPoints.length;
227
247
  }
228
248
  destroy() {
229
249
  this.svg.remove();
230
250
  }
251
+ createPath() {
252
+ const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
253
+ return t.setAttribute("fill", "none"), t.setAttribute("stroke", v.color), t.setAttribute("stroke-width", v.width), t.setAttribute("stroke-linecap", v.linecap), t.setAttribute("stroke-linejoin", v.linejoin), t.setAttribute("style", `filter:${v.filter}`), t;
254
+ }
255
+ }
256
+ function z(i) {
257
+ if (i.length === 0) return "";
258
+ const [t, e] = i[0];
259
+ let r = `M ${t} ${e}`;
260
+ for (let s = 1; s < i.length; s++) {
261
+ const [n, o] = i[s];
262
+ r += ` L ${n} ${o}`;
263
+ }
264
+ return r;
265
+ }
266
+ function Pt(i) {
267
+ const t = i.map((n) => n[0]), e = i.map((n) => n[1]), r = (Math.min(...t) + Math.max(...t)) / 2, s = (Math.min(...e) + Math.max(...e)) / 2;
268
+ return [r, s];
231
269
  }
232
- const Tt = 5;
233
- class H {
270
+ const At = 5;
271
+ class Dt {
234
272
  constructor(t, e, r) {
235
- this.messages = e, this.onReady = r, this.pinCount = 0, this.interactionActive = !0, this.pendingHighlightFrame = null, this.lastMoveX = 0, this.lastMoveY = 0, this.highlighter = new St(t), this.pinMarker = new _t(t), this.drawLayer = new Mt(t, (s) => {
236
- this.onReady(s, this.messages.annotation.drawing);
237
- }), this.overlay = new vt(t, {
273
+ this.messages = e, this.handlers = r, this.pinCount = 0, this.interactionActive = !0, this.pendingHighlightFrame = null, this.lastMoveX = 0, this.lastMoveY = 0, this.highlighter = new _t(t), this.pinMarker = new Tt(t), this.drawLayer = new Lt(t), this.overlay = new Ct(t, {
238
274
  onMouseDown: (s) => this.handleMouseDown(s),
239
275
  onMouseMove: (s) => this.handleMouseMove(s),
240
276
  onMouseUp: (s) => this.handleMouseUp(s),
241
277
  onMouseLeave: () => {
242
- this.drawLayer.isCurrentlyDrawing() && this.drawLayer.endDraw(), this.cancelPendingHighlight(), this.highlighter.hide();
278
+ this.drawLayer.isCurrentlyDrawing() && this.finishStroke(), this.cancelPendingHighlight(), this.highlighter.hide();
243
279
  }
244
280
  });
245
281
  }
@@ -256,7 +292,7 @@ class H {
256
292
  }));
257
293
  }
258
294
  updateHighlight() {
259
- if (!this.interactionActive || this.drawLayer.isCurrentlyDrawing()) return;
295
+ if (!this.interactionActive || this.drawLayer.isCurrentlyDrawing() || this.drawSessionActive()) return;
260
296
  const t = O(this.lastMoveX, this.lastMoveY);
261
297
  t ? this.highlighter.highlight(t) : this.highlighter.hide();
262
298
  }
@@ -264,21 +300,50 @@ class H {
264
300
  this.pendingHighlightFrame !== null && (cancelAnimationFrame(this.pendingHighlightFrame), this.pendingHighlightFrame = null);
265
301
  }
266
302
  handleMouseUp(t) {
267
- if (!this.drawLayer.isCurrentlyDrawing()) return;
268
- if (this.drawLayer.getPointCount() >= Tt) {
269
- this.drawLayer.endDraw();
303
+ this.drawLayer.isCurrentlyDrawing() && this.finishStroke(t);
304
+ }
305
+ // A drag past the point threshold becomes a freehand stroke and opens the
306
+ // draw note bar; a tap on an element becomes a pin. Stray taps while a
307
+ // drawing already exists are ignored so they don't hijack the draw flow.
308
+ finishStroke(t) {
309
+ if (this.drawLayer.getCurrentPointCount() >= At) {
310
+ this.drawLayer.commitStroke(), this.highlighter.hide(), this.handlers.onDrawStroke();
270
311
  return;
271
312
  }
272
- this.drawLayer.cancelCurrentDraw();
273
- const e = O(t.clientX, t.clientY), r = e ? Et(e) : this.messages.annotation.element, s = {
313
+ if (this.drawLayer.cancelCurrentDraw(), this.drawLayer.hasStrokes() || !t) return;
314
+ const e = O(t.clientX, t.clientY), r = e ? H(e) : this.messages.annotation.element, s = {
274
315
  type: "pin",
275
316
  x: t.clientX,
276
317
  y: t.clientY,
277
- targetSelector: e ? Ct(e) : void 0,
318
+ targetSelector: e ? st(e) : void 0,
278
319
  targetText: e?.textContent?.trim().slice(0, 200) ?? "",
279
320
  targetName: r
280
321
  };
281
- this.pinMarker.addPin(t.clientX, t.clientY, ++this.pinCount), this.drawLayer.clearAll(), this.highlighter.hide(), this.onReady(s, r);
322
+ this.pinMarker.addPin(t.clientX, t.clientY, ++this.pinCount), this.highlighter.hide(), this.handlers.onPin(s, r);
323
+ }
324
+ undoDraw() {
325
+ this.drawLayer.undo();
326
+ }
327
+ redoDraw() {
328
+ this.drawLayer.redo();
329
+ }
330
+ canUndoDraw() {
331
+ return this.drawLayer.canUndo();
332
+ }
333
+ canRedoDraw() {
334
+ return this.drawLayer.canRedo();
335
+ }
336
+ hasDrawStrokes() {
337
+ return this.drawLayer.hasStrokes();
338
+ }
339
+ drawSessionActive() {
340
+ return this.drawLayer.hasStrokes() || this.drawLayer.canRedo();
341
+ }
342
+ getDrawAnnotation() {
343
+ return this.drawLayer.getAnnotation();
344
+ }
345
+ clearDraw() {
346
+ this.drawLayer.clearAll();
282
347
  }
283
348
  dismissInteraction() {
284
349
  this.interactionActive && (this.interactionActive = !1, this.cancelPendingHighlight(), this.overlay.destroy(), this.highlighter.destroy());
@@ -290,16 +355,61 @@ class H {
290
355
  function O(i, t) {
291
356
  return document.elementsFromPoint(i, t).find((e) => e.id !== "mtb-widget-host") ?? null;
292
357
  }
293
- class Lt {
358
+ const Rt = "mtb-widget-host";
359
+ function S(i) {
360
+ const t = document.getElementById(Rt);
361
+ return t ? t === i || t.contains(i) : !1;
362
+ }
363
+ function d(i) {
364
+ return i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
365
+ }
366
+ class It {
294
367
  constructor(t, e) {
295
- this.loading = !1, this.onSubmit = e.onSubmit, this.onClose = e.onClose, this.submitLabel = e.messages.popup.submit, this.el = t.el("div", "mtb-popup"), this.el.innerHTML = this.buildHTML(e), t.append(this.el), this.textarea = this.el.querySelector(".mtb-textarea"), this.submitBtn = this.el.querySelector(".mtb-submit-btn"), this.positionPopup(e.x, e.y), this.bindEvents(e.messages), e.onMyFeedback && this.el.querySelector(".mtb-my-feedback").addEventListener("click", e.onMyFeedback), this.textarea.focus();
368
+ this.loading = !1, this.onSubmit = e.onSubmit, this.submitLabel = e.messages.draw.submit, this.el = t.el("div", "mtb-draw-bar"), this.el.innerHTML = this.buildHTML(e.messages), t.append(this.el), this.input = this.el.querySelector(".mtb-draw-input"), this.undoBtn = this.el.querySelector(".mtb-draw-undo"), this.redoBtn = this.el.querySelector(".mtb-draw-redo"), this.submitBtn = this.el.querySelector(".mtb-draw-submit"), this.errorEl = this.el.querySelector(".mtb-draw-error"), this.undoBtn.addEventListener("click", e.onUndo), this.redoBtn.addEventListener("click", e.onRedo), this.el.querySelector(".mtb-draw-cancel").addEventListener("click", e.onCancel), this.submitBtn.addEventListener("click", () => this.submit()), this.input.addEventListener("keydown", (r) => {
369
+ r.isComposing || r.keyCode === 229 || r.key === "Enter" && !r.shiftKey && (r.preventDefault(), this.submit());
370
+ }), this.input.focus();
371
+ }
372
+ buildHTML(t) {
373
+ return `
374
+ <input class="mtb-draw-input" type="text" placeholder="${d(t.draw.note_placeholder)}" />
375
+ <button class="mtb-draw-icon-btn mtb-draw-undo" type="button" title="${d(t.draw.undo)}" aria-label="${d(t.draw.undo)}" disabled>
376
+ <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 14L4 9l5-5"/><path d="M4 9h11a5 5 0 0 1 0 10h-1"/></svg>
377
+ </button>
378
+ <button class="mtb-draw-icon-btn mtb-draw-redo" type="button" title="${d(t.draw.redo)}" aria-label="${d(t.draw.redo)}" disabled>
379
+ <svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 14l5-5-5-5"/><path d="M20 9H9a5 5 0 0 0 0 10h1"/></svg>
380
+ </button>
381
+ <span class="mtb-draw-sep"></span>
382
+ <button class="mtb-draw-cancel" type="button">${d(t.draw.cancel)}</button>
383
+ <button class="mtb-draw-submit" type="button">${d(t.draw.submit)}</button>
384
+ <div class="mtb-draw-error" role="alert" hidden></div>
385
+ `;
386
+ }
387
+ setUndoRedo(t, e) {
388
+ this.undoBtn.disabled = !t || this.loading, this.redoBtn.disabled = !e || this.loading;
389
+ }
390
+ setLoading(t) {
391
+ this.loading = t, this.input.disabled = t, this.submitBtn.disabled = t, this.undoBtn.disabled = t || this.undoBtn.disabled, this.redoBtn.disabled = t || this.redoBtn.disabled, 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.errorEl.hidden = !0, this.errorEl.textContent = "") : (this.submitBtn.classList.remove("loading"), this.submitBtn.textContent = this.submitLabel);
392
+ }
393
+ setError(t) {
394
+ this.errorEl.textContent = t, this.errorEl.hidden = !1;
395
+ }
396
+ submit() {
397
+ this.loading || this.onSubmit(this.input.value.trim());
398
+ }
399
+ destroy() {
400
+ this.el.remove();
401
+ }
402
+ }
403
+ class Ht {
404
+ constructor(t, e) {
405
+ this.loading = !1, this.onSubmit = e.onSubmit, this.onClose = e.onClose, this.submitLabel = e.messages.popup.submit, this.messages = e.messages, this.el = t.el("div", "mtb-popup"), this.el.innerHTML = this.buildHTML(e), t.append(this.el), this.textarea = this.el.querySelector(".mtb-textarea"), this.submitBtn = this.el.querySelector(".mtb-submit-btn"), this.positionPopup(e.x, e.y), this.bindEvents(e.messages), e.onMyFeedback && this.el.querySelector(".mtb-my-feedback").addEventListener("click", e.onMyFeedback), this.textarea.focus();
296
406
  }
297
407
  buildHTML(t) {
298
408
  const e = t.messages, r = e.popup.quickOptions.map(
299
409
  (s) => `
300
- <button class="mtb-quick-option" data-quick="${p(s.label)}">
410
+ <button class="mtb-quick-option" data-quick="${d(s.label)}">
301
411
  <span class="mtb-quick-option-emoji">${s.emoji}</span>
302
- <span>${p(s.label)}</span>
412
+ <span>${d(s.label)}</span>
303
413
  </button>`
304
414
  ).join("");
305
415
  return `
@@ -309,7 +419,7 @@ class Lt {
309
419
  <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"/>
310
420
  </svg>
311
421
  </div>
312
- <span class="mtb-popup-title">${e.popup.about} "${p(t.targetName)}"</span>
422
+ <span class="mtb-popup-title">${e.popup.about} "${d(t.targetName)}"</span>
313
423
  <button class="mtb-popup-close" aria-label="Close">
314
424
  <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
315
425
  <path d="M18 6L6 18M6 6l12 12"/>
@@ -321,30 +431,30 @@ class Lt {
321
431
  ${r}
322
432
  </div>
323
433
  <div class="mtb-textarea-wrap">
324
- <textarea class="mtb-textarea" placeholder="${p(e.popup.placeholder)}"></textarea>
434
+ <textarea class="mtb-textarea" placeholder="${d(e.popup.placeholder)}"></textarea>
325
435
  </div>
326
436
  <div class="mtb-popup-error" role="alert"></div>
327
437
  <div class="mtb-popup-actions">
328
- <button class="mtb-cancel-btn" type="button">${p(e.popup.cancel)}</button>
329
- <button class="mtb-submit-btn" type="button" disabled>${p(e.popup.submit)}</button>
438
+ <button class="mtb-cancel-btn" type="button">${d(e.popup.cancel)}</button>
439
+ <button class="mtb-submit-btn" type="button" disabled>${d(e.popup.submit)}</button>
330
440
  </div>
331
- ${t.onMyFeedback ? `<button class="mtb-my-feedback" type="button">${p(e.popup.my_feedback)}</button>` : ""}
441
+ ${t.onMyFeedback ? `<button class="mtb-my-feedback" type="button">${d(e.popup.my_feedback)}</button>` : ""}
332
442
  </div>
333
443
  `;
334
444
  }
335
445
  positionPopup(t, e) {
336
446
  const n = window.innerWidth, o = window.innerHeight, a = 12;
337
447
  let l = t + 12, c = e + 12;
338
- 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`;
448
+ 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`, this.el.style.maxHeight = `${o - c - a}px`;
339
449
  }
340
450
  bindEvents(t) {
341
451
  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((e) => {
342
452
  e.addEventListener("click", () => {
343
453
  const r = e.dataset.quick ?? "";
344
- this.textarea.value = r, this.updateSubmitState(), this.textarea.focus();
454
+ this.textarea.value = r, this.updateSubmitState(), this.submit();
345
455
  });
346
456
  }), this.textarea.addEventListener("input", () => this.updateSubmitState()), this.textarea.addEventListener("keydown", (e) => {
347
- e.key === "Enter" && (e.metaKey || e.ctrlKey) && (e.preventDefault(), this.submit());
457
+ e.isComposing || e.keyCode === 229 || e.key === "Enter" && !e.shiftKey && (e.preventDefault(), this.submit());
348
458
  }), this.submitBtn.addEventListener("click", () => this.submit());
349
459
  }
350
460
  updateSubmitState() {
@@ -365,24 +475,21 @@ class Lt {
365
475
  this.el.remove();
366
476
  }
367
477
  }
368
- function p(i) {
369
- return i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
370
- }
371
- const At = 2e3, Dt = 2e3, Rt = 45e3, L = 346, A = 320;
372
- class Pt {
478
+ const $t = 2e3, Bt = 45e3, P = 346, A = 320;
479
+ class Ft {
373
480
  constructor(t, e) {
374
- this.pollTimer = null, this.pollDeadline = 0, this.doneTimer = null, this.streamingBubble = null, this.sending = !1, this.destroyed = !1, this.feedbackId = e.feedbackId, this.apiClient = e.apiClient, this.onDone = e.onDone, this.el = t.el("div", "mtb-clarify"), this.el.innerHTML = this.buildHTML(e.messages), this.positionCard(e.x, e.y), t.append(this.el), this.messagesEl = this.el.querySelector(".mtb-clarify-messages"), this.inputEl = this.el.querySelector(".mtb-clarify-input"), this.sendBtn = this.el.querySelector(".mtb-clarify-send"), this.bindEvents(e.messages), this.startConversation();
481
+ this.pollTimer = null, this.pollDeadline = 0, this.streamingBubble = null, this.lastMessages = [], this.done = !1, this.sending = !1, this.finalizing = !1, this.destroyed = !1, this.submissionSessionId = e.submissionSessionId, this.submissionToken = e.submissionToken, this.apiClient = e.apiClient, this.onFinalize = e.onFinalize, this.i18n = e.messages, this.summaryCtx = e.summary, this.el = t.el("div", "mtb-clarify"), this.el.innerHTML = this.buildHTML(e.messages), this.positionCard(e.x, e.y), t.append(this.el), this.messagesEl = this.el.querySelector(".mtb-clarify-messages"), this.inputEl = this.el.querySelector(".mtb-clarify-input"), this.sendBtn = this.el.querySelector(".mtb-clarify-send"), this.bindEvents(), this.startConversation();
375
482
  }
376
483
  // Anchors the card near the annotation point, clamped to the viewport so it
377
484
  // never overflows a screen edge (mirrors CommentPopup.positionPopup).
378
485
  positionCard(t, e) {
379
486
  const r = window.innerWidth, s = window.innerHeight, n = 12;
380
487
  if (t === void 0 || e === void 0) {
381
- this.el.style.left = `${Math.max(n, (r - L) / 2)}px`, this.el.style.top = `${Math.max(n, (s - A) / 2)}px`;
488
+ this.el.style.left = `${Math.max(n, (r - P) / 2)}px`, this.el.style.top = `${Math.max(n, (s - A) / 2)}px`;
382
489
  return;
383
490
  }
384
491
  let o = t + 12, a = e + 12;
385
- o + L > r - n && (o = t - L - 12), o < n && (o = n), a + A > s - n && (a = s - A - n), a < n && (a = n), this.el.style.left = `${o}px`, this.el.style.top = `${a}px`;
492
+ o + P > r - n && (o = t - P - 12), o < n && (o = n), a + A > s - n && (a = s - A - n), a < n && (a = n), this.el.style.left = `${o}px`, this.el.style.top = `${a}px`;
386
493
  }
387
494
  buildHTML(t) {
388
495
  return `
@@ -393,10 +500,10 @@ class Pt {
393
500
  </svg>
394
501
  </span>
395
502
  <div class="mtb-clarify-titles">
396
- <div class="mtb-clarify-title">${b(t.clarify.title)}</div>
397
- <div class="mtb-clarify-subtitle">${b(t.clarify.subtitle)}</div>
503
+ <div class="mtb-clarify-title">${d(t.clarify.title)}</div>
504
+ <div class="mtb-clarify-subtitle">${d(t.clarify.subtitle)}</div>
398
505
  </div>
399
- <button class="mtb-clarify-close" type="button" title="${b(t.clarify.skip)}" aria-label="${b(t.clarify.skip)}">
506
+ <button class="mtb-clarify-close" type="button" title="${d(t.clarify.skip)}" aria-label="${d(t.clarify.skip)}">
400
507
  <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
401
508
  <path d="M18 6L6 18M6 6l12 12"/>
402
509
  </svg>
@@ -404,68 +511,91 @@ class Pt {
404
511
  </div>
405
512
  <div class="mtb-clarify-messages"></div>
406
513
  <div class="mtb-clarify-footer">
407
- <textarea class="mtb-clarify-input" rows="2" placeholder="${b(t.clarify.placeholder)}"></textarea>
514
+ <textarea class="mtb-clarify-input" rows="2" placeholder="${d(t.clarify.placeholder)}"></textarea>
408
515
  <div class="mtb-clarify-actions">
409
- <button class="mtb-clarify-skip" type="button">${b(t.clarify.skip)}</button>
410
- <button class="mtb-clarify-send" type="button">
516
+ <button class="mtb-clarify-skip" type="button">${d(t.clarify.skip)}</button>
517
+ <button class="mtb-clarify-send" type="button" disabled>
411
518
  <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
412
519
  <line x1="22" y1="2" x2="11" y2="13"/>
413
520
  <polygon points="22 2 15 22 11 13 2 9 22 2"/>
414
521
  </svg>
415
- <span>${b(t.clarify.send)}</span>
522
+ <span>${d(t.clarify.send)}</span>
416
523
  </button>
417
524
  </div>
418
525
  </div>
419
526
  `;
420
527
  }
421
- bindEvents(t) {
422
- const e = () => {
423
- this.stopPolling(), this.onDone();
528
+ bindEvents() {
529
+ const t = () => {
530
+ this.stopPolling(), this.finalize();
424
531
  };
425
- this.el.querySelector(".mtb-clarify-skip").addEventListener("click", e), this.el.querySelector(".mtb-clarify-close").addEventListener("click", e), this.inputEl.addEventListener("keydown", (r) => {
426
- r.isComposing || r.keyCode === 229 || r.key === "Enter" && !r.shiftKey && (r.preventDefault(), this.sendMessage(t));
427
- }), this.sendBtn.addEventListener("click", () => this.sendMessage(t));
532
+ this.el.querySelector(".mtb-clarify-skip").addEventListener("click", t), this.el.querySelector(".mtb-clarify-close").addEventListener("click", t), this.inputEl.addEventListener("input", () => {
533
+ this.sendBtn.disabled = !this.inputEl.value.trim();
534
+ }), this.inputEl.addEventListener("keydown", (e) => {
535
+ e.isComposing || e.keyCode === 229 || e.key === "Enter" && !e.shiftKey && (e.preventDefault(), this.sendMessage());
536
+ }), this.sendBtn.addEventListener("click", () => this.sendMessage());
428
537
  }
429
538
  async startConversation() {
430
- this.showThinking(), await this.runTurn(void 0);
539
+ this.showThinking(), await this.runInitialTurn();
431
540
  }
432
- async sendMessage(t) {
433
- const e = this.inputEl.value.trim();
434
- if (!(!e || this.sending)) {
435
- this.sending = !0, this.inputEl.disabled = !0, this.sendBtn.disabled = !0, this.stopPolling(), this.appendMessage({ role: "user", content: e }), this.inputEl.value = "", this.showThinking();
541
+ async sendMessage() {
542
+ const t = this.inputEl.value.trim();
543
+ if (!(!t || this.sending)) {
544
+ this.sending = !0, this.inputEl.disabled = !0, this.sendBtn.disabled = !0, this.stopPolling(), this.appendMessage({ role: "user", content: t }), this.inputEl.value = "", this.showThinking(), this.clearError();
436
545
  try {
437
- await this.runTurn(e);
546
+ await this.runAnswerTurn(t);
547
+ } catch {
548
+ if (this.destroyed) return;
549
+ this.renderConversation(this.lastMessages, !1), this.inputEl.value = t, this.showError();
438
550
  } finally {
439
- this.sending = !1, this.inputEl.disabled = !1, this.sendBtn.disabled = !1, this.inputEl.focus();
551
+ this.sending = !1, this.inputEl.disabled = !1, this.sendBtn.disabled = !this.inputEl.value.trim(), this.inputEl.focus();
440
552
  }
441
553
  }
442
554
  }
443
555
  // Streams the assistant reply; falls back to POST + polling if the backend
444
556
  // doesn't support SSE (older server) or the stream errors mid-flight.
445
- async runTurn(t) {
557
+ async runInitialTurn() {
446
558
  try {
447
- const e = await this.apiClient.streamClarification(
448
- this.feedbackId,
449
- t,
450
- (r) => this.appendStreamDelta(r)
559
+ const t = await this.apiClient.streamClarification(
560
+ this.submissionSessionId,
561
+ this.submissionToken,
562
+ (e) => this.appendStreamDelta(e)
451
563
  );
452
564
  if (this.destroyed) return;
453
- this.endStreamingBubble(), this.renderConversation(e.messages, e.done), e.done ? this.handleDone() : this.startPolling();
565
+ this.endStreamingBubble(), this.renderConversation(t.messages, t.done), t.done ? this.handleDone() : this.startPolling();
454
566
  } catch {
455
567
  if (this.destroyed) return;
456
- this.endStreamingBubble(), await this.runTurnViaPolling(t);
568
+ this.endStreamingBubble(), await this.runInitialTurnViaPolling();
457
569
  }
458
570
  }
459
- async runTurnViaPolling(t) {
571
+ async runInitialTurnViaPolling() {
460
572
  try {
461
- const e = await this.apiClient.startClarification(this.feedbackId, t);
573
+ const t = await this.apiClient.startClarification(
574
+ this.submissionSessionId,
575
+ this.submissionToken
576
+ );
462
577
  if (this.destroyed) return;
463
- this.renderConversation(e.messages, e.done), e.done ? this.handleDone() : this.startPolling();
578
+ this.renderConversation(t.messages, t.done), t.done ? this.handleDone() : this.startPolling();
464
579
  } catch {
465
580
  if (this.destroyed) return;
466
- this.onDone();
581
+ this.handleDone();
467
582
  }
468
583
  }
584
+ async runAnswerTurn(t) {
585
+ const e = await this.apiClient.startClarification(
586
+ this.submissionSessionId,
587
+ this.submissionToken,
588
+ t
589
+ );
590
+ this.destroyed || (this.renderConversation(e.messages, e.done), e.done ? this.handleDone() : this.startPolling());
591
+ }
592
+ showError() {
593
+ const t = this.el.querySelector(".mtb-clarify-footer"), e = document.createElement("div");
594
+ e.className = "mtb-clarify-error", e.textContent = this.i18n.error.submit, t.prepend(e);
595
+ }
596
+ clearError() {
597
+ this.el.querySelector(".mtb-clarify-error")?.remove();
598
+ }
469
599
  appendStreamDelta(t) {
470
600
  this.streamingBubble || (this.removeThinking(), this.streamingBubble = document.createElement("div"), this.streamingBubble.className = "mtb-clarify-bubble mtb-clarify-ai", this.messagesEl.appendChild(this.streamingBubble)), this.streamingBubble.textContent = (this.streamingBubble.textContent ?? "") + t, this.messagesEl.scrollTop = this.messagesEl.scrollHeight;
471
601
  }
@@ -473,7 +603,7 @@ class Pt {
473
603
  this.streamingBubble = null;
474
604
  }
475
605
  startPolling() {
476
- this.stopPolling(), this.pollDeadline = Date.now() + Rt, this.pollTimer = setInterval(() => this.poll(), At);
606
+ this.stopPolling(), this.pollDeadline = Date.now() + Bt, this.pollTimer = setInterval(() => this.poll(), $t);
477
607
  }
478
608
  stopPolling() {
479
609
  this.pollTimer !== null && (clearInterval(this.pollTimer), this.pollTimer = null);
@@ -484,21 +614,70 @@ class Pt {
484
614
  return;
485
615
  }
486
616
  try {
487
- const t = await this.apiClient.getClarification(this.feedbackId);
617
+ const t = await this.apiClient.getClarification(
618
+ this.submissionSessionId,
619
+ this.submissionToken
620
+ );
488
621
  if (this.destroyed) return;
489
622
  this.renderConversation(t.messages, t.done), t.done && (this.stopPolling(), this.handleDone());
490
623
  } catch {
491
624
  if (this.destroyed) return;
492
- this.stopPolling();
625
+ this.stopPolling(), this.handleDone();
493
626
  }
494
627
  }
495
628
  handleDone() {
496
- this.inputEl.disabled = !0, this.sendBtn.disabled = !0, this.doneTimer = setTimeout(() => {
497
- this.destroyed || this.onDone();
498
- }, Dt);
629
+ this.done || (this.done = !0, this.stopPolling(), this.removeThinking(), this.renderSummary());
630
+ }
631
+ renderSummary() {
632
+ const t = this.i18n.clarify.summary, e = document.createElement("div");
633
+ e.className = "mtb-clarify-summary", e.innerHTML = this.buildSummaryHTML(t), this.messagesEl.appendChild(e), this.messagesEl.scrollTop = this.messagesEl.scrollHeight;
634
+ const r = this.el.querySelector(".mtb-clarify-footer");
635
+ r.innerHTML = `<button class="mtb-clarify-send-feedback" type="button">${d(t.send_feedback)}</button>`, r.querySelector(".mtb-clarify-send-feedback").addEventListener("click", () => {
636
+ this.destroyed || this.finalize();
637
+ });
638
+ }
639
+ async finalize() {
640
+ if (!(this.finalizing || this.destroyed)) {
641
+ this.finalizing = !0, this.el.querySelectorAll("button").forEach((t) => {
642
+ t.disabled = !0;
643
+ });
644
+ try {
645
+ await this.onFinalize();
646
+ } catch {
647
+ if (this.destroyed) return;
648
+ this.finalizing = !1, this.handleDone(), this.el.querySelectorAll("button").forEach((t) => {
649
+ t.disabled = !1;
650
+ }), this.clearError(), this.showError();
651
+ }
652
+ }
653
+ }
654
+ buildSummaryHTML(t) {
655
+ const e = this.summaryCtx?.originalDescription?.trim(), r = e ? `<div class="mtb-summary-section">
656
+ <div class="mtb-summary-label">${d(t.what_you_said)}</div>
657
+ <div class="mtb-summary-quote">${d(e)}</div>
658
+ </div>` : "", s = this.clarifiedPairs(), n = s.length ? `<div class="mtb-summary-section">
659
+ <div class="mtb-summary-label">${d(t.clarified)}</div>
660
+ ${s.map((o) => `<div class="mtb-summary-qa"><span class="mtb-summary-q">${d(o.q)}</span><span class="mtb-summary-a">${d(o.a)}</span></div>`).join("")}
661
+ </div>` : "";
662
+ return `
663
+ <div class="mtb-summary-head">
664
+ <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
665
+ <span>${d(t.ready)}</span>
666
+ </div>
667
+ ${r}
668
+ ${n}
669
+ `;
670
+ }
671
+ clarifiedPairs() {
672
+ const t = [];
673
+ for (let e = 0; e < this.lastMessages.length - 1; e++) {
674
+ const r = this.lastMessages[e], s = this.lastMessages[e + 1];
675
+ r.role !== "user" && s.role === "user" && t.push({ q: r.content, a: s.content });
676
+ }
677
+ return t;
499
678
  }
500
679
  renderConversation(t, e) {
501
- this.renderMessages(t);
680
+ this.lastMessages = t, this.renderMessages(t);
502
681
  const r = t[t.length - 1];
503
682
  !e && (!r || r.role === "user") && this.showThinking();
504
683
  }
@@ -521,14 +700,11 @@ class Pt {
521
700
  this.messagesEl.querySelector(".mtb-clarify-thinking")?.remove();
522
701
  }
523
702
  destroy() {
524
- this.destroyed = !0, this.stopPolling(), this.doneTimer !== null && (clearTimeout(this.doneTimer), this.doneTimer = null), this.el.remove();
703
+ this.destroyed = !0, this.stopPolling(), this.el.remove();
525
704
  }
526
705
  }
527
- function b(i) {
528
- return i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
529
- }
530
- const It = 5e3, $t = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
531
- class Ht {
706
+ const zt = 5e3, Ot = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
707
+ class Ut {
532
708
  constructor(t, e, r, s, n) {
533
709
  this.messages = e, this.el = t.el("div", "mtb-success"), this.el.style.right = "20px", this.el.style.bottom = "20px";
534
710
  const o = n?.skipFollowup ? e.success.title_no_ai : e.success.title, a = n?.skipFollowup ? e.success.message_no_ai : e.success.message, l = s ? `<button class="mtb-view-feedback-link">${e.success.view_feedback} <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12h14M12 5l7 7-7 7"/></svg></button>` : "", c = n?.emailCapture ? `
@@ -542,7 +718,7 @@ class Ht {
542
718
  </div>` : "";
543
719
  this.el.innerHTML = `
544
720
  <div class="mtb-success-icon">
545
- <svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="${et}" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">
721
+ <svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="${M}" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">
546
722
  <polyline points="20 6 9 17 4 12"/>
547
723
  </svg>
548
724
  </div>
@@ -551,12 +727,12 @@ class Ht {
551
727
  ${c}
552
728
  ${l}
553
729
  <button class="mtb-close-link">${e.success.close}</button>
554
- `, t.append(this.el), this.el.querySelector(".mtb-close-link").addEventListener("click", r), s && this.el.querySelector(".mtb-view-feedback-link").addEventListener("click", s), n?.emailCapture ? this.bindEmailCapture(n.emailCapture.onSubmit) : setTimeout(() => r(), It);
730
+ `, t.append(this.el), this.el.querySelector(".mtb-close-link").addEventListener("click", r), s && this.el.querySelector(".mtb-view-feedback-link").addEventListener("click", s), n?.emailCapture ? this.bindEmailCapture(n.emailCapture.onSubmit) : setTimeout(() => r(), zt);
555
731
  }
556
732
  bindEmailCapture(t) {
557
733
  const e = this.el.querySelector(".mtb-email-input"), r = this.el.querySelector(".mtb-email-submit"), s = this.el.querySelector(".mtb-email-error"), n = async () => {
558
734
  const o = e.value.trim();
559
- if (!$t.test(o)) {
735
+ if (!Ot.test(o)) {
560
736
  e.classList.add("mtb-email-invalid");
561
737
  return;
562
738
  }
@@ -570,7 +746,7 @@ class Ht {
570
746
  this.el.remove();
571
747
  }
572
748
  }
573
- function Ot(i, t) {
749
+ function jt(i, t) {
574
750
  if (i.match(/^[a-z]+:\/\//i))
575
751
  return i;
576
752
  if (i.match(/^\/\//))
@@ -580,7 +756,7 @@ function Ot(i, t) {
580
756
  const e = document.implementation.createHTMLDocument(), r = e.createElement("base"), s = e.createElement("a");
581
757
  return e.head.appendChild(r), e.body.appendChild(s), t && (r.href = t), s.href = i, s.href;
582
758
  }
583
- const Ft = /* @__PURE__ */ (() => {
759
+ const qt = /* @__PURE__ */ (() => {
584
760
  let i = 0;
585
761
  const t = () => (
586
762
  // eslint-disable-next-line no-bitwise
@@ -594,27 +770,27 @@ function f(i) {
594
770
  t.push(i[e]);
595
771
  return t;
596
772
  }
597
- let y = null;
598
- function it(i = {}) {
599
- return y || (i.includeStyleProperties ? (y = i.includeStyleProperties, y) : (y = f(window.getComputedStyle(document.documentElement)), y));
773
+ let g = null;
774
+ function nt(i = {}) {
775
+ return g || (i.includeStyleProperties ? (g = i.includeStyleProperties, g) : (g = f(window.getComputedStyle(document.documentElement)), g));
600
776
  }
601
777
  function _(i, t) {
602
778
  const r = (i.ownerDocument.defaultView || window).getComputedStyle(i).getPropertyValue(t);
603
779
  return r ? parseFloat(r.replace("px", "")) : 0;
604
780
  }
605
- function jt(i) {
781
+ function Nt(i) {
606
782
  const t = _(i, "border-left-width"), e = _(i, "border-right-width");
607
783
  return i.clientWidth + t + e;
608
784
  }
609
- function Ut(i) {
785
+ function Wt(i) {
610
786
  const t = _(i, "border-top-width"), e = _(i, "border-bottom-width");
611
787
  return i.clientHeight + t + e;
612
788
  }
613
- function rt(i, t = {}) {
614
- const e = t.width || jt(i), r = t.height || Ut(i);
789
+ function ot(i, t = {}) {
790
+ const e = t.width || Nt(i), r = t.height || Wt(i);
615
791
  return { width: e, height: r };
616
792
  }
617
- function Bt() {
793
+ function Vt() {
618
794
  let i, t;
619
795
  try {
620
796
  t = process;
@@ -623,11 +799,11 @@ function Bt() {
623
799
  const e = t && t.env ? t.env.devicePixelRatio : null;
624
800
  return e && (i = parseInt(e, 10), Number.isNaN(i) && (i = 1)), i || window.devicePixelRatio || 1;
625
801
  }
626
- const u = 16384;
627
- function zt(i) {
628
- (i.width > u || i.height > u) && (i.width > u && i.height > u ? i.width > i.height ? (i.height *= u / i.width, i.width = u) : (i.width *= u / i.height, i.height = u) : i.width > u ? (i.height *= u / i.width, i.width = u) : (i.width *= u / i.height, i.height = u));
802
+ const m = 16384;
803
+ function Yt(i) {
804
+ (i.width > m || i.height > m) && (i.width > m && i.height > m ? i.width > i.height ? (i.height *= m / i.width, i.width = m) : (i.width *= m / i.height, i.height = m) : i.width > m ? (i.height *= m / i.width, i.width = m) : (i.width *= m / i.height, i.height = m));
629
805
  }
630
- function M(i) {
806
+ function T(i) {
631
807
  return new Promise((t, e) => {
632
808
  const r = new Image();
633
809
  r.onload = () => {
@@ -637,80 +813,80 @@ function M(i) {
637
813
  }, r.onerror = e, r.crossOrigin = "anonymous", r.decoding = "async", r.src = i;
638
814
  });
639
815
  }
640
- async function qt(i) {
816
+ async function Xt(i) {
641
817
  return Promise.resolve().then(() => new XMLSerializer().serializeToString(i)).then(encodeURIComponent).then((t) => `data:image/svg+xml;charset=utf-8,${t}`);
642
818
  }
643
- async function Wt(i, t, e) {
819
+ async function Kt(i, t, e) {
644
820
  const r = "http://www.w3.org/2000/svg", s = document.createElementNS(r, "svg"), n = document.createElementNS(r, "foreignObject");
645
- return s.setAttribute("width", `${t}`), s.setAttribute("height", `${e}`), s.setAttribute("viewBox", `0 0 ${t} ${e}`), 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(i), qt(s);
821
+ return s.setAttribute("width", `${t}`), s.setAttribute("height", `${e}`), s.setAttribute("viewBox", `0 0 ${t} ${e}`), 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(i), Xt(s);
646
822
  }
647
- const d = (i, t) => {
823
+ const u = (i, t) => {
648
824
  if (i instanceof t)
649
825
  return !0;
650
826
  const e = Object.getPrototypeOf(i);
651
- return e === null ? !1 : e.constructor.name === t.name || d(e, t);
827
+ return e === null ? !1 : e.constructor.name === t.name || u(e, t);
652
828
  };
653
- function Nt(i) {
829
+ function Gt(i) {
654
830
  const t = i.getPropertyValue("content");
655
831
  return `${i.cssText} content: '${t.replace(/'|"/g, "")}';`;
656
832
  }
657
- function Vt(i, t) {
658
- return it(t).map((e) => {
833
+ function Jt(i, t) {
834
+ return nt(t).map((e) => {
659
835
  const r = i.getPropertyValue(e), s = i.getPropertyPriority(e);
660
836
  return `${e}: ${r}${s ? " !important" : ""};`;
661
837
  }).join(" ");
662
838
  }
663
- function Yt(i, t, e, r) {
664
- const s = `.${i}:${t}`, n = e.cssText ? Nt(e) : Vt(e, r);
839
+ function Qt(i, t, e, r) {
840
+ const s = `.${i}:${t}`, n = e.cssText ? Gt(e) : Jt(e, r);
665
841
  return document.createTextNode(`${s}{${n}}`);
666
842
  }
667
- function F(i, t, e, r) {
843
+ function U(i, t, e, r) {
668
844
  const s = window.getComputedStyle(i, e), n = s.getPropertyValue("content");
669
845
  if (n === "" || n === "none")
670
846
  return;
671
- const o = Ft();
847
+ const o = qt();
672
848
  try {
673
849
  t.className = `${t.className} ${o}`;
674
850
  } catch {
675
851
  return;
676
852
  }
677
853
  const a = document.createElement("style");
678
- a.appendChild(Yt(o, e, s, r)), t.appendChild(a);
854
+ a.appendChild(Qt(o, e, s, r)), t.appendChild(a);
679
855
  }
680
- function Xt(i, t, e) {
681
- F(i, t, ":before", e), F(i, t, ":after", e);
856
+ function Zt(i, t, e) {
857
+ U(i, t, ":before", e), U(i, t, ":after", e);
682
858
  }
683
- const j = "application/font-woff", U = "image/jpeg", Gt = {
859
+ const j = "application/font-woff", q = "image/jpeg", te = {
684
860
  woff: j,
685
861
  woff2: j,
686
862
  ttf: "application/font-truetype",
687
863
  eot: "application/vnd.ms-fontobject",
688
864
  png: "image/png",
689
- jpg: U,
690
- jpeg: U,
865
+ jpg: q,
866
+ jpeg: q,
691
867
  gif: "image/gif",
692
868
  tiff: "image/tiff",
693
869
  svg: "image/svg+xml",
694
870
  webp: "image/webp"
695
871
  };
696
- function Kt(i) {
872
+ function ee(i) {
697
873
  const t = /\.([^./]*?)$/g.exec(i);
698
874
  return t ? t[1] : "";
699
875
  }
700
- function I(i) {
701
- const t = Kt(i).toLowerCase();
702
- return Gt[t] || "";
876
+ function $(i) {
877
+ const t = ee(i).toLowerCase();
878
+ return te[t] || "";
703
879
  }
704
- function Jt(i) {
880
+ function ie(i) {
705
881
  return i.split(/,/)[1];
706
882
  }
707
883
  function R(i) {
708
884
  return i.search(/^(data:)/) !== -1;
709
885
  }
710
- function Qt(i, t) {
886
+ function re(i, t) {
711
887
  return `data:${t};base64,${i}`;
712
888
  }
713
- async function st(i, t, e) {
889
+ async function at(i, t, e) {
714
890
  const r = await fetch(i, t);
715
891
  if (r.status === 404)
716
892
  throw new Error(`Resource "${r.url}" not found`);
@@ -727,19 +903,19 @@ async function st(i, t, e) {
727
903
  });
728
904
  }
729
905
  const D = {};
730
- function Zt(i, t, e) {
906
+ function se(i, t, e) {
731
907
  let r = i.replace(/\?.*/, "");
732
908
  return e && (r = i), /ttf|otf|eot|woff2?/i.test(r) && (r = r.replace(/.*\//, "")), t ? `[${t}]${r}` : r;
733
909
  }
734
- async function $(i, t, e) {
735
- const r = Zt(i, t, e.includeQueryParams);
910
+ async function B(i, t, e) {
911
+ const r = se(i, t, e.includeQueryParams);
736
912
  if (D[r] != null)
737
913
  return D[r];
738
914
  e.cacheBust && (i += (/\?/.test(i) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime());
739
915
  let s;
740
916
  try {
741
- const n = await st(i, e.fetchRequestInit, ({ res: o, result: a }) => (t || (t = o.headers.get("Content-Type") || ""), Jt(a)));
742
- s = Qt(n, t);
917
+ const n = await at(i, e.fetchRequestInit, ({ res: o, result: a }) => (t || (t = o.headers.get("Content-Type") || ""), ie(a)));
918
+ s = re(n, t);
743
919
  } catch (n) {
744
920
  s = e.imagePlaceholder || "";
745
921
  let o = `Failed to fetch resource: ${i}`;
@@ -747,65 +923,65 @@ async function $(i, t, e) {
747
923
  }
748
924
  return D[r] = s, s;
749
925
  }
750
- async function te(i) {
926
+ async function ne(i) {
751
927
  const t = i.toDataURL();
752
- return t === "data:," ? i.cloneNode(!1) : M(t);
928
+ return t === "data:," ? i.cloneNode(!1) : T(t);
753
929
  }
754
- async function ee(i, t) {
930
+ async function oe(i, t) {
755
931
  if (i.currentSrc) {
756
932
  const n = document.createElement("canvas"), o = n.getContext("2d");
757
933
  n.width = i.clientWidth, n.height = i.clientHeight, o?.drawImage(i, 0, 0, n.width, n.height);
758
934
  const a = n.toDataURL();
759
- return M(a);
935
+ return T(a);
760
936
  }
761
- const e = i.poster, r = I(e), s = await $(e, r, t);
762
- return M(s);
937
+ const e = i.poster, r = $(e), s = await B(e, r, t);
938
+ return T(s);
763
939
  }
764
- async function ie(i, t) {
940
+ async function ae(i, t) {
765
941
  var e;
766
942
  try {
767
943
  if (!((e = i?.contentDocument) === null || e === void 0) && e.body)
768
- return await T(i.contentDocument.body, t, !0);
944
+ return await L(i.contentDocument.body, t, !0);
769
945
  } catch {
770
946
  }
771
947
  return i.cloneNode(!1);
772
948
  }
773
- async function re(i, t) {
774
- return d(i, HTMLCanvasElement) ? te(i) : d(i, HTMLVideoElement) ? ee(i, t) : d(i, HTMLIFrameElement) ? ie(i, t) : i.cloneNode(nt(i));
949
+ async function le(i, t) {
950
+ return u(i, HTMLCanvasElement) ? ne(i) : u(i, HTMLVideoElement) ? oe(i, t) : u(i, HTMLIFrameElement) ? ae(i, t) : i.cloneNode(lt(i));
775
951
  }
776
- const se = (i) => i.tagName != null && i.tagName.toUpperCase() === "SLOT", nt = (i) => i.tagName != null && i.tagName.toUpperCase() === "SVG";
777
- async function ne(i, t, e) {
952
+ const ce = (i) => i.tagName != null && i.tagName.toUpperCase() === "SLOT", lt = (i) => i.tagName != null && i.tagName.toUpperCase() === "SVG";
953
+ async function de(i, t, e) {
778
954
  var r, s;
779
- if (nt(t))
955
+ if (lt(t))
780
956
  return t;
781
957
  let n = [];
782
- return se(i) && i.assignedNodes ? n = f(i.assignedNodes()) : d(i, HTMLIFrameElement) && (!((r = i.contentDocument) === null || r === void 0) && r.body) ? n = f(i.contentDocument.body.childNodes) : n = f(((s = i.shadowRoot) !== null && s !== void 0 ? s : i).childNodes), n.length === 0 || d(i, HTMLVideoElement) || await n.reduce((o, a) => o.then(() => T(a, e)).then((l) => {
958
+ return ce(i) && i.assignedNodes ? n = f(i.assignedNodes()) : u(i, HTMLIFrameElement) && (!((r = i.contentDocument) === null || r === void 0) && r.body) ? n = f(i.contentDocument.body.childNodes) : n = f(((s = i.shadowRoot) !== null && s !== void 0 ? s : i).childNodes), n.length === 0 || u(i, HTMLVideoElement) || await n.reduce((o, a) => o.then(() => L(a, e)).then((l) => {
783
959
  l && t.appendChild(l);
784
960
  }), Promise.resolve()), t;
785
961
  }
786
- function oe(i, t, e) {
962
+ function he(i, t, e) {
787
963
  const r = t.style;
788
964
  if (!r)
789
965
  return;
790
966
  const s = window.getComputedStyle(i);
791
- s.cssText ? (r.cssText = s.cssText, r.transformOrigin = s.transformOrigin) : it(e).forEach((n) => {
967
+ s.cssText ? (r.cssText = s.cssText, r.transformOrigin = s.transformOrigin) : nt(e).forEach((n) => {
792
968
  let o = s.getPropertyValue(n);
793
- n === "font-size" && o.endsWith("px") && (o = `${Math.floor(parseFloat(o.substring(0, o.length - 2))) - 0.1}px`), d(i, HTMLIFrameElement) && n === "display" && o === "inline" && (o = "block"), n === "d" && t.getAttribute("d") && (o = `path(${t.getAttribute("d")})`), r.setProperty(n, o, s.getPropertyPriority(n));
969
+ n === "font-size" && o.endsWith("px") && (o = `${Math.floor(parseFloat(o.substring(0, o.length - 2))) - 0.1}px`), u(i, HTMLIFrameElement) && n === "display" && o === "inline" && (o = "block"), n === "d" && t.getAttribute("d") && (o = `path(${t.getAttribute("d")})`), r.setProperty(n, o, s.getPropertyPriority(n));
794
970
  });
795
971
  }
796
- function ae(i, t) {
797
- d(i, HTMLTextAreaElement) && (t.innerHTML = i.value), d(i, HTMLInputElement) && t.setAttribute("value", i.value);
972
+ function ue(i, t) {
973
+ u(i, HTMLTextAreaElement) && (t.innerHTML = i.value), u(i, HTMLInputElement) && t.setAttribute("value", i.value);
798
974
  }
799
- function le(i, t) {
800
- if (d(i, HTMLSelectElement)) {
975
+ function me(i, t) {
976
+ if (u(i, HTMLSelectElement)) {
801
977
  const e = t, r = Array.from(e.children).find((s) => i.value === s.getAttribute("value"));
802
978
  r && r.setAttribute("selected", "");
803
979
  }
804
980
  }
805
- function ce(i, t, e) {
806
- return d(t, Element) && (oe(i, t, e), Xt(i, t, e), ae(i, t), le(i, t)), t;
981
+ function pe(i, t, e) {
982
+ return u(t, Element) && (he(i, t, e), Zt(i, t, e), ue(i, t), me(i, t)), t;
807
983
  }
808
- async function de(i, t) {
984
+ async function fe(i, t) {
809
985
  const e = i.querySelectorAll ? i.querySelectorAll("use") : [];
810
986
  if (e.length === 0)
811
987
  return i;
@@ -814,7 +990,7 @@ async function de(i, t) {
814
990
  const a = e[n].getAttribute("xlink:href");
815
991
  if (a) {
816
992
  const l = i.querySelector(a), c = document.querySelector(a);
817
- !l && c && !r[a] && (r[a] = await T(c, t, !0));
993
+ !l && c && !r[a] && (r[a] = await L(c, t, !0));
818
994
  }
819
995
  }
820
996
  const s = Object.values(r);
@@ -829,31 +1005,31 @@ async function de(i, t) {
829
1005
  }
830
1006
  return i;
831
1007
  }
832
- async function T(i, t, e) {
833
- return !e && t.filter && !t.filter(i) ? null : Promise.resolve(i).then((r) => re(r, t)).then((r) => ne(i, r, t)).then((r) => ce(i, r, t)).then((r) => de(r, t));
1008
+ async function L(i, t, e) {
1009
+ return !e && t.filter && !t.filter(i) ? null : Promise.resolve(i).then((r) => le(r, t)).then((r) => de(i, r, t)).then((r) => pe(i, r, t)).then((r) => fe(r, t));
834
1010
  }
835
- const ot = /url\((['"]?)([^'"]+?)\1\)/g, he = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, ue = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
836
- function me(i) {
1011
+ const ct = /url\((['"]?)([^'"]+?)\1\)/g, be = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, ge = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
1012
+ function ye(i) {
837
1013
  const t = i.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
838
1014
  return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`, "g");
839
1015
  }
840
- function fe(i) {
1016
+ function we(i) {
841
1017
  const t = [];
842
- return i.replace(ot, (e, r, s) => (t.push(s), e)), t.filter((e) => !R(e));
1018
+ return i.replace(ct, (e, r, s) => (t.push(s), e)), t.filter((e) => !R(e));
843
1019
  }
844
- async function pe(i, t, e, r, s) {
1020
+ async function xe(i, t, e, r, s) {
845
1021
  try {
846
- const n = e ? Ot(t, e) : t, o = I(t);
1022
+ const n = e ? jt(t, e) : t, o = $(t);
847
1023
  let a;
848
- return s || (a = await $(n, o, r)), i.replace(me(t), `$1${a}$3`);
1024
+ return s || (a = await B(n, o, r)), i.replace(ye(t), `$1${a}$3`);
849
1025
  } catch {
850
1026
  }
851
1027
  return i;
852
1028
  }
853
- function be(i, { preferredFontFormat: t }) {
854
- return t ? i.replace(ue, (e) => {
1029
+ function ve(i, { preferredFontFormat: t }) {
1030
+ return t ? i.replace(ge, (e) => {
855
1031
  for (; ; ) {
856
- const [r, , s] = he.exec(e) || [];
1032
+ const [r, , s] = be.exec(e) || [];
857
1033
  if (!s)
858
1034
  return "";
859
1035
  if (s === t)
@@ -861,32 +1037,32 @@ function be(i, { preferredFontFormat: t }) {
861
1037
  }
862
1038
  }) : i;
863
1039
  }
864
- function at(i) {
865
- return i.search(ot) !== -1;
1040
+ function dt(i) {
1041
+ return i.search(ct) !== -1;
866
1042
  }
867
- async function lt(i, t, e) {
868
- if (!at(i))
1043
+ async function ht(i, t, e) {
1044
+ if (!dt(i))
869
1045
  return i;
870
- const r = be(i, e);
871
- return fe(r).reduce((n, o) => n.then((a) => pe(a, o, t, e)), Promise.resolve(r));
1046
+ const r = ve(i, e);
1047
+ return we(r).reduce((n, o) => n.then((a) => xe(a, o, t, e)), Promise.resolve(r));
872
1048
  }
873
- async function x(i, t, e) {
1049
+ async function y(i, t, e) {
874
1050
  var r;
875
1051
  const s = (r = t.style) === null || r === void 0 ? void 0 : r.getPropertyValue(i);
876
1052
  if (s) {
877
- const n = await lt(s, null, e);
1053
+ const n = await ht(s, null, e);
878
1054
  return t.style.setProperty(i, n, t.style.getPropertyPriority(i)), !0;
879
1055
  }
880
1056
  return !1;
881
1057
  }
882
- async function ge(i, t) {
883
- await x("background", i, t) || await x("background-image", i, t), await x("mask", i, t) || await x("-webkit-mask", i, t) || await x("mask-image", i, t) || await x("-webkit-mask-image", i, t);
1058
+ async function ke(i, t) {
1059
+ await y("background", i, t) || await y("background-image", i, t), await y("mask", i, t) || await y("-webkit-mask", i, t) || await y("mask-image", i, t) || await y("-webkit-mask-image", i, t);
884
1060
  }
885
- async function ye(i, t) {
886
- const e = d(i, HTMLImageElement);
887
- if (!(e && !R(i.src)) && !(d(i, SVGImageElement) && !R(i.href.baseVal)))
1061
+ async function Se(i, t) {
1062
+ const e = u(i, HTMLImageElement);
1063
+ if (!(e && !R(i.src)) && !(u(i, SVGImageElement) && !R(i.href.baseVal)))
888
1064
  return;
889
- const r = e ? i.src : i.href.baseVal, s = await $(r, I(r), t);
1065
+ const r = e ? i.src : i.href.baseVal, s = await B(r, $(r), t);
890
1066
  await new Promise((n, o) => {
891
1067
  i.onload = n, i.onerror = t.onImageErrorHandler ? (...l) => {
892
1068
  try {
@@ -899,14 +1075,14 @@ async function ye(i, t) {
899
1075
  a.decode && (a.decode = n), a.loading === "lazy" && (a.loading = "eager"), e ? (i.srcset = "", i.src = s) : i.href.baseVal = s;
900
1076
  });
901
1077
  }
902
- async function xe(i, t) {
903
- const r = f(i.childNodes).map((s) => ct(s, t));
1078
+ async function Ee(i, t) {
1079
+ const r = f(i.childNodes).map((s) => ut(s, t));
904
1080
  await Promise.all(r).then(() => i);
905
1081
  }
906
- async function ct(i, t) {
907
- d(i, Element) && (await ge(i, t), await ye(i, t), await xe(i, t));
1082
+ async function ut(i, t) {
1083
+ u(i, Element) && (await ke(i, t), await Se(i, t), await Ee(i, t));
908
1084
  }
909
- function we(i, t) {
1085
+ function Ce(i, t) {
910
1086
  const { style: e } = i;
911
1087
  t.backgroundColor && (e.backgroundColor = t.backgroundColor), t.width && (e.width = `${t.width}px`), t.height && (e.height = `${t.height}px`);
912
1088
  const r = t.style;
@@ -914,23 +1090,23 @@ function we(i, t) {
914
1090
  e[s] = r[s];
915
1091
  }), i;
916
1092
  }
917
- const B = {};
918
- async function z(i) {
919
- let t = B[i];
1093
+ const N = {};
1094
+ async function W(i) {
1095
+ let t = N[i];
920
1096
  if (t != null)
921
1097
  return t;
922
1098
  const r = await (await fetch(i)).text();
923
- return t = { url: i, cssText: r }, B[i] = t, t;
1099
+ return t = { url: i, cssText: r }, N[i] = t, t;
924
1100
  }
925
- async function q(i, t) {
1101
+ async function V(i, t) {
926
1102
  let e = i.cssText;
927
1103
  const r = /url\(["']?([^"')]+)["']?\)/g, n = (e.match(/url\([^)]+\)/g) || []).map(async (o) => {
928
1104
  let a = o.replace(r, "$1");
929
- return a.startsWith("https://") || (a = new URL(a, i.url).href), st(a, t.fetchRequestInit, ({ result: l }) => (e = e.replace(o, `url(${l})`), [o, l]));
1105
+ return a.startsWith("https://") || (a = new URL(a, i.url).href), at(a, t.fetchRequestInit, ({ result: l }) => (e = e.replace(o, `url(${l})`), [o, l]));
930
1106
  });
931
1107
  return Promise.all(n).then(() => e);
932
1108
  }
933
- function W(i) {
1109
+ function Y(i) {
934
1110
  if (i == null)
935
1111
  return [];
936
1112
  const t = [], e = /(\/\*[\s\S]*?\*\/)/gi;
@@ -956,7 +1132,7 @@ function W(i) {
956
1132
  }
957
1133
  return t;
958
1134
  }
959
- async function ke(i, t) {
1135
+ async function _e(i, t) {
960
1136
  const e = [], r = [];
961
1137
  return i.forEach((s) => {
962
1138
  if ("cssRules" in s)
@@ -964,13 +1140,13 @@ async function ke(i, t) {
964
1140
  f(s.cssRules || []).forEach((n, o) => {
965
1141
  if (n.type === CSSRule.IMPORT_RULE) {
966
1142
  let a = o + 1;
967
- const l = n.href, c = z(l).then((h) => q(h, t)).then((h) => W(h).forEach((m) => {
1143
+ const l = n.href, c = W(l).then((h) => V(h, t)).then((h) => Y(h).forEach((p) => {
968
1144
  try {
969
- s.insertRule(m, m.startsWith("@import") ? a += 1 : s.cssRules.length);
970
- } catch (k) {
1145
+ s.insertRule(p, p.startsWith("@import") ? a += 1 : s.cssRules.length);
1146
+ } catch (x) {
971
1147
  console.error("Error inserting rule from remote css", {
972
- rule: m,
973
- error: k
1148
+ rule: p,
1149
+ error: x
974
1150
  });
975
1151
  }
976
1152
  })).catch((h) => {
@@ -981,7 +1157,7 @@ async function ke(i, t) {
981
1157
  });
982
1158
  } catch (n) {
983
1159
  const o = i.find((a) => a.href == null) || document.styleSheets[0];
984
- s.href != null && r.push(z(s.href).then((a) => q(a, t)).then((a) => W(a).forEach((l) => {
1160
+ s.href != null && r.push(W(s.href).then((a) => V(a, t)).then((a) => Y(a).forEach((l) => {
985
1161
  o.insertRule(l, o.cssRules.length);
986
1162
  })).catch((a) => {
987
1163
  console.error("Error loading remote stylesheet", a);
@@ -998,114 +1174,131 @@ async function ke(i, t) {
998
1174
  }
999
1175
  }), e));
1000
1176
  }
1001
- function ve(i) {
1002
- return i.filter((t) => t.type === CSSRule.FONT_FACE_RULE).filter((t) => at(t.style.getPropertyValue("src")));
1177
+ function Te(i) {
1178
+ return i.filter((t) => t.type === CSSRule.FONT_FACE_RULE).filter((t) => dt(t.style.getPropertyValue("src")));
1003
1179
  }
1004
- async function Se(i, t) {
1180
+ async function Me(i, t) {
1005
1181
  if (i.ownerDocument == null)
1006
1182
  throw new Error("Provided element is not within a Document");
1007
- const e = f(i.ownerDocument.styleSheets), r = await ke(e, t);
1008
- return ve(r);
1183
+ const e = f(i.ownerDocument.styleSheets), r = await _e(e, t);
1184
+ return Te(r);
1009
1185
  }
1010
- function dt(i) {
1186
+ function mt(i) {
1011
1187
  return i.trim().replace(/["']/g, "");
1012
1188
  }
1013
- function Ee(i) {
1189
+ function Le(i) {
1014
1190
  const t = /* @__PURE__ */ new Set();
1015
1191
  function e(r) {
1016
1192
  (r.style.fontFamily || getComputedStyle(r).fontFamily).split(",").forEach((n) => {
1017
- t.add(dt(n));
1193
+ t.add(mt(n));
1018
1194
  }), Array.from(r.children).forEach((n) => {
1019
1195
  n instanceof HTMLElement && e(n);
1020
1196
  });
1021
1197
  }
1022
1198
  return e(i), t;
1023
1199
  }
1024
- async function Ce(i, t) {
1025
- const e = await Se(i, t), r = Ee(i);
1026
- return (await Promise.all(e.filter((n) => r.has(dt(n.style.fontFamily))).map((n) => {
1200
+ async function Pe(i, t) {
1201
+ const e = await Me(i, t), r = Le(i);
1202
+ return (await Promise.all(e.filter((n) => r.has(mt(n.style.fontFamily))).map((n) => {
1027
1203
  const o = n.parentStyleSheet ? n.parentStyleSheet.href : null;
1028
- return lt(n.cssText, o, t);
1204
+ return ht(n.cssText, o, t);
1029
1205
  }))).join(`
1030
1206
  `);
1031
1207
  }
1032
- async function _e(i, t) {
1033
- const e = t.fontEmbedCSS != null ? t.fontEmbedCSS : t.skipFonts ? null : await Ce(i, t);
1208
+ async function Ae(i, t) {
1209
+ const e = t.fontEmbedCSS != null ? t.fontEmbedCSS : t.skipFonts ? null : await Pe(i, t);
1034
1210
  if (e) {
1035
1211
  const r = document.createElement("style"), s = document.createTextNode(e);
1036
1212
  r.appendChild(s), i.firstChild ? i.insertBefore(r, i.firstChild) : i.appendChild(r);
1037
1213
  }
1038
1214
  }
1039
- async function Me(i, t = {}) {
1040
- const { width: e, height: r } = rt(i, t), s = await T(i, t, !0);
1041
- return await _e(s, t), await ct(s, t), we(s, t), await Wt(s, e, r);
1215
+ async function De(i, t = {}) {
1216
+ const { width: e, height: r } = ot(i, t), s = await L(i, t, !0);
1217
+ return await Ae(s, t), await ut(s, t), Ce(s, t), await Kt(s, e, r);
1042
1218
  }
1043
- async function Te(i, t = {}) {
1044
- const { width: e, height: r } = rt(i, t), s = await Me(i, t), n = await M(s), o = document.createElement("canvas"), a = o.getContext("2d"), l = t.pixelRatio || Bt(), c = t.canvasWidth || e, h = t.canvasHeight || r;
1045
- return o.width = c * l, o.height = h * l, t.skipAutoScale || zt(o), o.style.width = `${c}`, o.style.height = `${h}`, t.backgroundColor && (a.fillStyle = t.backgroundColor, a.fillRect(0, 0, o.width, o.height)), a.drawImage(n, 0, 0, o.width, o.height), o;
1219
+ async function Re(i, t = {}) {
1220
+ const { width: e, height: r } = ot(i, t), s = await De(i, t), n = await T(s), o = document.createElement("canvas"), a = o.getContext("2d"), l = t.pixelRatio || Vt(), c = t.canvasWidth || e, h = t.canvasHeight || r;
1221
+ return o.width = c * l, o.height = h * l, t.skipAutoScale || Yt(o), o.style.width = `${c}`, o.style.height = `${h}`, t.backgroundColor && (a.fillStyle = t.backgroundColor, a.fillRect(0, 0, o.width, o.height)), a.drawImage(n, 0, 0, o.width, o.height), o;
1046
1222
  }
1047
- async function Le(i, t = {}) {
1048
- return (await Te(i, t)).toDataURL("image/jpeg", t.quality || 1);
1223
+ async function Ie(i, t = {}) {
1224
+ return (await Re(i, t)).toDataURL("image/jpeg", t.quality || 1);
1049
1225
  }
1050
- async function Ae(i = []) {
1051
- const t = De(i);
1226
+ async function He(i = []) {
1052
1227
  try {
1053
- const e = await Le(document.body, {
1228
+ const t = await Ie(document.body, {
1054
1229
  quality: 0.85,
1055
1230
  pixelRatio: 1,
1056
1231
  backgroundColor: "#ffffff",
1057
- cacheBust: !0,
1232
+ skipFonts: !0,
1058
1233
  skipAutoScale: !1,
1059
- filter: (r) => !(r instanceof HTMLElement && r.id === "mtb-widget-host")
1234
+ filter: (e) => !(e instanceof HTMLElement && e.id === "mtb-widget-host")
1060
1235
  });
1061
- return Ie(e);
1236
+ if (i.length > 0) {
1237
+ const e = await $e(t, i);
1238
+ if (e) return e;
1239
+ }
1240
+ return je(t);
1062
1241
  } catch {
1063
1242
  return null;
1064
- } finally {
1065
- t?.remove();
1066
- }
1067
- }
1068
- function De(i) {
1069
- if (i.length === 0) return null;
1070
- const t = document.createElement("div");
1071
- 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;";
1072
- for (const [e, r] of i.entries())
1073
- r.type === "pin" ? t.appendChild(Re(r, e + 1)) : r.type === "draw" && r.drawPath && t.appendChild(Pe(r.drawPath));
1074
- return document.body.appendChild(t), t;
1075
- }
1076
- function Re(i, t) {
1077
- const e = document.createElement("div");
1078
- return e.textContent = String(t), e.style.cssText = [
1079
- "position:fixed",
1080
- `left:${i.x}px`,
1081
- `top:${i.y}px`,
1082
- "width:22px",
1083
- "height:22px",
1084
- "border-radius:50% 50% 50% 2px",
1085
- "background:#059669",
1086
- "border:2px solid #fff",
1087
- "display:flex",
1088
- "align-items:center",
1089
- "justify-content:center",
1090
- 'font:700 10px -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',
1091
- "color:#fff",
1092
- "box-shadow:0 2px 8px rgba(5,150,105,0.45)",
1093
- "transform:translate(-50%,-50%)"
1094
- ].join(";"), e;
1095
- }
1096
- function Pe(i) {
1097
- const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1098
- 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;";
1099
- const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1100
- return e.setAttribute("d", i), e.setAttribute("fill", "none"), e.setAttribute("stroke", "#059669"), e.setAttribute("stroke-width", "3.5"), e.setAttribute("stroke-linecap", "round"), e.setAttribute("stroke-linejoin", "round"), e.setAttribute("filter", "drop-shadow(0 1px 2px rgba(5,150,105,0.35))"), t.appendChild(e), t;
1101
- }
1102
- function Ie(i) {
1243
+ }
1244
+ }
1245
+ async function $e(i, t) {
1246
+ const e = document.createElement("canvas"), r = e.getContext("2d");
1247
+ if (!r) return null;
1248
+ const s = await Oe(i);
1249
+ if (!s) return null;
1250
+ e.width = s.naturalWidth || window.innerWidth, e.height = s.naturalHeight || window.innerHeight, r.drawImage(s, 0, 0);
1251
+ const n = e.width / window.innerWidth, o = e.height / window.innerHeight;
1252
+ let a = 0;
1253
+ for (const l of t)
1254
+ l.type === "draw" && l.drawPath ? Be(r, l.drawPath, n, o) : l.type === "pin" && Fe(r, l.x * n, l.y * o, ++a);
1255
+ return Ue(e);
1256
+ }
1257
+ function Be(i, t, e, r) {
1258
+ i.save(), i.strokeStyle = M, i.lineWidth = 3.5, i.lineCap = "round", i.lineJoin = "round", i.shadowColor = "rgba(5,150,105,0.35)", i.shadowOffsetY = 1, i.shadowBlur = 2;
1259
+ for (const s of ze(t))
1260
+ if (s.length !== 0) {
1261
+ i.beginPath(), i.moveTo(s[0][0] * e, s[0][1] * r);
1262
+ for (let n = 1; n < s.length; n++) i.lineTo(s[n][0] * e, s[n][1] * r);
1263
+ i.stroke();
1264
+ }
1265
+ i.restore();
1266
+ }
1267
+ function Fe(i, t, e, r) {
1268
+ i.save(), i.shadowColor = "rgba(5,150,105,0.45)", i.shadowOffsetY = 2, i.shadowBlur = 8, i.fillStyle = M, i.beginPath(), i.arc(t, e, 11, 0, Math.PI * 2), i.fill(), i.shadowColor = "transparent", i.lineWidth = 2, i.strokeStyle = "#ffffff", i.stroke(), i.fillStyle = "#ffffff", i.font = `700 10px ${Mt}`, i.textAlign = "center", i.textBaseline = "middle", i.fillText(String(r), t, e), i.restore();
1269
+ }
1270
+ function ze(i) {
1271
+ const t = [];
1272
+ let e = null;
1273
+ const r = i.match(/[ML]\s*[-\d.]+\s+[-\d.]+/g) ?? [];
1274
+ for (const s of r) {
1275
+ const [n, o] = s.slice(1).trim().split(/\s+/).map(Number);
1276
+ Number.isNaN(n) || Number.isNaN(o) || (s[0] === "M" ? (e = [[n, o]], t.push(e)) : e && e.push([n, o]));
1277
+ }
1278
+ return t;
1279
+ }
1280
+ function Oe(i) {
1281
+ return new Promise((t) => {
1282
+ const e = new Image();
1283
+ e.onload = () => t(e), e.onerror = () => t(null), e.src = i;
1284
+ });
1285
+ }
1286
+ function Ue(i) {
1287
+ return new Promise((t) => {
1288
+ try {
1289
+ i.toBlob((e) => t(e), "image/jpeg", 0.85);
1290
+ } catch {
1291
+ t(null);
1292
+ }
1293
+ });
1294
+ }
1295
+ function je(i) {
1103
1296
  const [t, e] = i.split(","), r = t.match(/:(.*?);/)?.[1] ?? "image/png", s = atob(e), n = new Uint8Array(s.length);
1104
1297
  for (let o = 0; o < s.length; o++)
1105
1298
  n[o] = s.charCodeAt(o);
1106
1299
  return new Blob([n], { type: r });
1107
1300
  }
1108
- class $e {
1301
+ class qe {
1109
1302
  constructor() {
1110
1303
  this.listeners = /* @__PURE__ */ new Set(), this.originalOnError = null, this.installedOnError = null, this.rejectionHandler = null, this.hooked = !1;
1111
1304
  }
@@ -1127,20 +1320,20 @@ class $e {
1127
1320
  for (const e of this.listeners) e(t);
1128
1321
  }
1129
1322
  }
1130
- const ht = new $e(), He = 20;
1131
- class Oe {
1323
+ const F = new qe(), Ne = 20;
1324
+ class We {
1132
1325
  constructor() {
1133
1326
  this.errors = [], this.unsubscribe = null;
1134
1327
  }
1135
1328
  start() {
1136
- this.unsubscribe || (this.unsubscribe = ht.subscribe((t) => this.record(t)));
1329
+ this.unsubscribe || (this.unsubscribe = F.subscribe((t) => this.record(t)));
1137
1330
  }
1138
1331
  record(t) {
1139
1332
  const e = t.line != null ? ` (${t.line}:${t.col ?? 0})` : "";
1140
1333
  this.addError(`${t.message}${e}`);
1141
1334
  }
1142
1335
  addError(t) {
1143
- this.errors.length >= He || this.errors.includes(t) || this.errors.push(t);
1336
+ this.errors.length >= Ne || this.errors.includes(t) || this.errors.push(t);
1144
1337
  }
1145
1338
  getErrors() {
1146
1339
  return [...this.errors];
@@ -1149,7 +1342,86 @@ class Oe {
1149
1342
  this.unsubscribe?.(), this.unsubscribe = null;
1150
1343
  }
1151
1344
  }
1152
- const Fe = 3, je = 1e3, Ue = 3, Be = 5e3, ze = 500, qe = 500, We = 300, Ne = /* @__PURE__ */ new Set([
1345
+ const Ve = 20;
1346
+ class Ye {
1347
+ constructor() {
1348
+ this.breadcrumbs = [], this.active = !1, this.unsubscribeErrors = null, this.boundPopstateHandler = null, this.originalPushState = null, this.originalReplaceState = null, this.installedPushState = null, this.installedReplaceState = null, this.lastUrl = "", this.boundClickHandler = (t) => this.handleClick(t), this.boundChangeHandler = (t) => this.handleChange(t);
1349
+ }
1350
+ start() {
1351
+ this.active || (this.active = !0, this.lastUrl = location.href, document.addEventListener("click", this.boundClickHandler, { capture: !0, passive: !0 }), document.addEventListener("change", this.boundChangeHandler, { capture: !0, passive: !0 }), this.unsubscribeErrors = F.subscribe((t) => this.recordError(t)), this.startNavigationTracking());
1352
+ }
1353
+ stop() {
1354
+ this.active && (this.active = !1, document.removeEventListener("click", this.boundClickHandler, !0), document.removeEventListener("change", this.boundChangeHandler, !0), this.unsubscribeErrors?.(), this.unsubscribeErrors = null, this.stopNavigationTracking());
1355
+ }
1356
+ getBreadcrumbs() {
1357
+ return [...this.breadcrumbs];
1358
+ }
1359
+ add(t) {
1360
+ this.breadcrumbs.push(t), this.breadcrumbs.length > Ve && this.breadcrumbs.shift();
1361
+ }
1362
+ handleClick(t) {
1363
+ const e = t.target;
1364
+ if (e && !S(e))
1365
+ try {
1366
+ this.add({
1367
+ type: "ui",
1368
+ category: "ui.click",
1369
+ timestamp: Date.now(),
1370
+ message: H(e),
1371
+ data: { selector: st(e) }
1372
+ });
1373
+ } catch {
1374
+ }
1375
+ }
1376
+ handleChange(t) {
1377
+ const e = t.target;
1378
+ if (e && !S(e))
1379
+ try {
1380
+ const r = e, s = r.name || r.placeholder || e.getAttribute("aria-label") || e.tagName;
1381
+ this.add({
1382
+ type: "ui",
1383
+ category: "ui.input",
1384
+ timestamp: Date.now(),
1385
+ message: s,
1386
+ data: { field: s }
1387
+ });
1388
+ } catch {
1389
+ }
1390
+ }
1391
+ recordError(t) {
1392
+ this.add({
1393
+ type: "console",
1394
+ category: "console.error",
1395
+ timestamp: Date.now(),
1396
+ message: t.message,
1397
+ data: { message: t.message }
1398
+ });
1399
+ }
1400
+ startNavigationTracking() {
1401
+ this.boundPopstateHandler = () => this.handleNavigation(), window.addEventListener("popstate", this.boundPopstateHandler), this.originalPushState = history.pushState.bind(history), this.originalReplaceState = history.replaceState.bind(history);
1402
+ const t = this.originalPushState, e = this.originalReplaceState, r = () => this.handleNavigation();
1403
+ this.installedPushState = function(s, n, o) {
1404
+ t(s, n, o), r();
1405
+ }, this.installedReplaceState = function(s, n, o) {
1406
+ e(s, n, o), r();
1407
+ }, history.pushState = this.installedPushState, history.replaceState = this.installedReplaceState;
1408
+ }
1409
+ stopNavigationTracking() {
1410
+ this.boundPopstateHandler && (window.removeEventListener("popstate", this.boundPopstateHandler), this.boundPopstateHandler = null), this.originalPushState && history.pushState === this.installedPushState && (history.pushState = this.originalPushState), this.originalReplaceState && history.replaceState === this.installedReplaceState && (history.replaceState = this.originalReplaceState), this.originalPushState = null, this.originalReplaceState = null, this.installedPushState = null, this.installedReplaceState = null;
1411
+ }
1412
+ handleNavigation() {
1413
+ if (!this.active) return;
1414
+ const t = this.lastUrl, e = location.href;
1415
+ t !== e && (this.lastUrl = e, this.add({
1416
+ type: "navigation",
1417
+ category: "navigation",
1418
+ timestamp: Date.now(),
1419
+ message: `${t} → ${e}`,
1420
+ data: { from: t, to: e }
1421
+ }));
1422
+ }
1423
+ }
1424
+ const Xe = 3, Ke = 1e3, Ge = 3, Je = 5e3, Qe = 500, Ze = 500, ti = 300, ei = /* @__PURE__ */ new Set([
1153
1425
  "A",
1154
1426
  "BUTTON",
1155
1427
  "INPUT",
@@ -1158,7 +1430,7 @@ const Fe = 3, je = 1e3, Ue = 3, Be = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1158
1430
  "LABEL",
1159
1431
  "SUMMARY",
1160
1432
  "DETAILS"
1161
- ]), Ve = /* @__PURE__ */ new Set([
1433
+ ]), ii = /* @__PURE__ */ new Set([
1162
1434
  "button",
1163
1435
  "link",
1164
1436
  "checkbox",
@@ -1172,7 +1444,7 @@ const Fe = 3, je = 1e3, Ue = 3, Be = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1172
1444
  "listbox",
1173
1445
  "slider",
1174
1446
  "spinbutton"
1175
- ]), N = [
1447
+ ]), X = [
1176
1448
  "404",
1177
1449
  "500",
1178
1450
  "not found",
@@ -1184,7 +1456,7 @@ const Fe = 3, je = 1e3, Ue = 3, Be = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1184
1456
  this.clickHistory = [], this.unsubscribeErrors = null, this.active = !1, this.errorCount = 0, this.deadClickCount = 0, this.cooldownUntil = 0, this.navTimestamps = [], this.boundPopstateHandler = null, this.originalPushState = null, this.originalReplaceState = null, this.installedPushState = null, this.installedReplaceState = null, this.boundSubmitHandler = null, this.boundInvalidHandler = null, this.errorPageUrls = /* @__PURE__ */ new Set(), this.domObserver = null, this.pendingDomChecks = 0, this.lastMutationAt = -1, this.onFrustration = t, this.boundClickHandler = (e) => this.handleClick(e);
1185
1457
  }
1186
1458
  start() {
1187
- this.active || (this.active = !0, document.addEventListener("click", this.boundClickHandler, !0), this.unsubscribeErrors = ht.subscribe((t) => {
1459
+ this.active || (this.active = !0, document.addEventListener("click", this.boundClickHandler, !0), this.unsubscribeErrors = F.subscribe((t) => {
1188
1460
  this.errorCount++;
1189
1461
  }), this.startNavigationTracking(), this.startFormTracking(), this.checkErrorPage());
1190
1462
  }
@@ -1211,11 +1483,11 @@ const Fe = 3, je = 1e3, Ue = 3, Be = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1211
1483
  }
1212
1484
  handleClick(t) {
1213
1485
  const e = t.target;
1214
- if (!e || this.isWidgetElement(e)) return;
1486
+ if (!e || S(e)) return;
1215
1487
  const r = Date.now();
1216
1488
  this.clickHistory.push({ target: e, time: r });
1217
- const s = r - je;
1218
- if (this.clickHistory = this.clickHistory.filter((o) => o.time > s), this.clickHistory.filter((o) => o.target === e).length >= Fe) {
1489
+ const s = r - Ke;
1490
+ if (this.clickHistory = this.clickHistory.filter((o) => o.time > s), this.clickHistory.filter((o) => o.target === e).length >= Xe) {
1219
1491
  this.clickHistory = [], this.emitHighPriority({
1220
1492
  signal: "rage_click",
1221
1493
  target: w(e),
@@ -1232,27 +1504,27 @@ const Fe = 3, je = 1e3, Ue = 3, Be = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1232
1504
  handleNavigation() {
1233
1505
  const t = Date.now();
1234
1506
  this.navTimestamps.push(t);
1235
- const e = t - Be;
1236
- this.navTimestamps = this.navTimestamps.filter((r) => r > e), this.navTimestamps.length >= Ue && (this.navTimestamps = [], this.emitIfReady({
1507
+ const e = t - Je;
1508
+ this.navTimestamps = this.navTimestamps.filter((r) => r > e), this.navTimestamps.length >= Ge && (this.navTimestamps = [], this.emitIfReady({
1237
1509
  signal: "rapid_navigation",
1238
1510
  timestamp: t
1239
1511
  })), setTimeout(() => {
1240
1512
  this.active && this.checkErrorPage();
1241
- }, We);
1513
+ }, ti);
1242
1514
  }
1243
1515
  handleFormSubmit(t) {
1244
1516
  const e = t.target;
1245
- e instanceof HTMLFormElement && (this.isWidgetElement(e) || setTimeout(() => {
1517
+ e instanceof HTMLFormElement && (S(e) || setTimeout(() => {
1246
1518
  this.active && e.querySelector('[aria-invalid="true"], .is-invalid') && this.emitIfReady({
1247
1519
  signal: "form_failure",
1248
1520
  target: w(e),
1249
1521
  timestamp: Date.now()
1250
1522
  });
1251
- }, ze));
1523
+ }, Qe));
1252
1524
  }
1253
1525
  handleFormInvalid(t) {
1254
1526
  const e = t.target;
1255
- if (!e || this.isWidgetElement(e)) return;
1527
+ if (!e || S(e)) return;
1256
1528
  const r = e.closest("form");
1257
1529
  this.emitIfReady({
1258
1530
  signal: "form_failure",
@@ -1264,7 +1536,7 @@ const Fe = 3, je = 1e3, Ue = 3, Be = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1264
1536
  const t = location.href;
1265
1537
  if (this.errorPageUrls.has(t)) return;
1266
1538
  const e = document.title.toLowerCase();
1267
- if (N.some((s) => e.includes(s))) {
1539
+ if (X.some((s) => e.includes(s))) {
1268
1540
  this.errorPageUrls.add(t), this.emitHighPriority({
1269
1541
  signal: "error_page",
1270
1542
  detail: document.title,
@@ -1277,7 +1549,7 @@ const Fe = 3, je = 1e3, Ue = 3, Be = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1277
1549
  );
1278
1550
  for (const s of r) {
1279
1551
  const n = s.textContent ?? "";
1280
- if (n.length < 200 && N.some((o) => n.toLowerCase().includes(o))) {
1552
+ if (n.length < 200 && X.some((o) => n.toLowerCase().includes(o))) {
1281
1553
  this.errorPageUrls.add(t), this.emitHighPriority({
1282
1554
  signal: "error_page",
1283
1555
  detail: n.trim().slice(0, 60),
@@ -1299,7 +1571,7 @@ const Fe = 3, je = 1e3, Ue = 3, Be = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1299
1571
  target: w(t),
1300
1572
  timestamp: e
1301
1573
  });
1302
- }, qe));
1574
+ }, Ze));
1303
1575
  }
1304
1576
  ensureDomObserver() {
1305
1577
  this.domObserver || (this.domObserver = new MutationObserver(() => {
@@ -1324,13 +1596,9 @@ const Fe = 3, je = 1e3, Ue = 3, Be = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1324
1596
  return !1;
1325
1597
  }
1326
1598
  isInteractive(t) {
1327
- if (Ne.has(t.tagName)) return !0;
1599
+ if (ei.has(t.tagName)) return !0;
1328
1600
  const e = t.getAttribute("role");
1329
- return !!(e && Ve.has(e) || t.hasAttribute("onclick") || t.hasAttribute("tabindex") || t.contentEditable === "true" || window.getComputedStyle(t).cursor === "pointer" || t.closest('a, button, [role="button"], [role="link"], label'));
1330
- }
1331
- isWidgetElement(t) {
1332
- const e = document.getElementById("mtb-widget-host");
1333
- return e ? e === t || e.contains(t) : !1;
1601
+ return !!(e && ii.has(e) || t.hasAttribute("onclick") || t.hasAttribute("tabindex") || t.contentEditable === "true" || window.getComputedStyle(t).cursor === "pointer" || t.closest('a, button, [role="button"], [role="link"], label'));
1334
1602
  }
1335
1603
  emitIfReady(t) {
1336
1604
  const e = Date.now();
@@ -1341,33 +1609,33 @@ const Fe = 3, je = 1e3, Ue = 3, Be = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1341
1609
  }
1342
1610
  };
1343
1611
  E.COOLDOWN_MS = 6e4;
1344
- let P = E;
1612
+ let I = E;
1345
1613
  function w(i) {
1346
1614
  const t = i.tagName.toLowerCase(), e = i.id ? `#${i.id}` : "", r = i.className && typeof i.className == "string" ? "." + i.className.trim().split(/\s+/).slice(0, 2).join(".") : "", s = i.textContent?.trim().slice(0, 30) ?? "";
1347
1615
  return `<${t}${e}${r}>${s ? ` "${s}"` : ""}`;
1348
1616
  }
1349
- function Ye() {
1617
+ function ri() {
1350
1618
  return {
1351
1619
  page_url: window.location.href,
1352
1620
  user_agent: navigator.userAgent,
1353
- browser: Xe(),
1354
- os: Ge(),
1621
+ browser: si(),
1622
+ os: ni(),
1355
1623
  screen_width: window.screen.width,
1356
1624
  screen_height: window.screen.height
1357
1625
  };
1358
1626
  }
1359
- function Xe() {
1627
+ function si() {
1360
1628
  const i = navigator.userAgent;
1361
1629
  return /Edg\//.test(i) ? `Edge ${i.match(/Edg\/(\S+)/)?.[1] ?? ""}` : /OPR\//.test(i) ? `Opera ${i.match(/OPR\/(\S+)/)?.[1] ?? ""}` : /Chrome\//.test(i) ? `Chrome ${i.match(/Chrome\/(\S+)/)?.[1] ?? ""}` : /Safari\//.test(i) && /Version\//.test(i) ? `Safari ${i.match(/Version\/(\S+)/)?.[1] ?? ""}` : /Firefox\//.test(i) ? `Firefox ${i.match(/Firefox\/(\S+)/)?.[1] ?? ""}` : "Unknown";
1362
1630
  }
1363
- function Ge() {
1631
+ function ni() {
1364
1632
  const i = navigator.userAgent;
1365
1633
  return /Windows NT 10/.test(i) ? "Windows 10/11" : /Windows NT/.test(i) ? "Windows" : /Mac OS X 10_15|macOS 1[56789]/.test(i) || /Mac OS X/.test(i) ? "macOS" : /Android/.test(i) ? `Android ${i.match(/Android (\d+)/)?.[1] ?? ""}` : /iPhone|iPad|iPod/.test(i) ? "iOS" : /Linux/.test(i) ? "Linux" : "Unknown";
1366
1634
  }
1367
- const Ke = "https://makethisbetter.dev/api/v1";
1368
- class Je {
1635
+ const oi = "https://makethisbetter.dev/api/v1";
1636
+ class ai {
1369
1637
  constructor(t, e, r = 1e3, s, n) {
1370
- this.projectKey = t, this.apiUrl = (e ?? Ke).replace(/\/$/, ""), this.retryDelayMs = r, this.userToken = s, this.userTokenFn = n;
1638
+ this.projectKey = t, this.apiUrl = (e ?? oi).replace(/\/$/, ""), this.retryDelayMs = r, this.userToken = s, this.userTokenFn = n;
1371
1639
  }
1372
1640
  async resolveUserToken() {
1373
1641
  return this.userTokenFn ? this.userTokenFn() : this.userToken;
@@ -1376,22 +1644,26 @@ class Je {
1376
1644
  const e = { "X-Project-Key": this.projectKey }, r = await this.resolveUserToken();
1377
1645
  return r && (e["X-User-Token"] = r), t && (e["Content-Type"] = t), e;
1378
1646
  }
1379
- async submitFeedback(t, e) {
1380
- const r = new FormData();
1381
- 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.reporter_external_id && r.append("feedback[reporter_external_id]", t.reporter_external_id), t.reporter_email && r.append("feedback[reporter_email]", t.reporter_email), 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) {
1382
- const o = JSON.stringify(t.recording_events), a = new Blob([o], { type: "application/json" });
1383
- r.append("feedback[recording]", a, "recording.json"), r.append("feedback[recording_duration]", String(t.recording_duration ?? 0));
1647
+ async submissionHeaders(t, e) {
1648
+ const r = await this.authHeaders(e);
1649
+ return r["X-Submission-Token"] = t, r;
1650
+ }
1651
+ async createSubmissionSession(t, e) {
1652
+ const r = di(), s = new FormData();
1653
+ if (s.append("feedback[description]", t.description), s.append("feedback[page_url]", t.page_url), s.append("feedback[user_agent]", t.user_agent), s.append("feedback[browser]", t.browser), s.append("feedback[os]", t.os), s.append("feedback[screen_width]", String(t.screen_width)), s.append("feedback[screen_height]", String(t.screen_height)), s.append("feedback[console_errors]", JSON.stringify(t.console_errors)), s.append("feedback[annotations]", JSON.stringify(t.annotations)), t.target_element && s.append("feedback[target_element]", JSON.stringify(t.target_element)), t.user_id && s.append("feedback[user_id]", t.user_id), t.reporter_external_id && s.append("feedback[reporter_external_id]", t.reporter_external_id), t.reporter_email && s.append("feedback[reporter_email]", t.reporter_email), t.user_email && s.append("feedback[user_email]", t.user_email), t.user_name && s.append("feedback[user_name]", t.user_name), t.breadcrumbs && t.breadcrumbs.length > 0 && s.append("feedback[breadcrumbs]", JSON.stringify(t.breadcrumbs)), t.recording_events && t.recording_events.length > 0) {
1654
+ const l = JSON.stringify(t.recording_events), c = new Blob([l], { type: "application/json" });
1655
+ s.append("feedback[recording]", c, "interaction-replay.json"), s.append("feedback[recording_duration]", String(t.recording_duration ?? 0));
1384
1656
  }
1385
1657
  if (e) {
1386
- const o = e.type === "image/jpeg" ? "jpg" : "png";
1387
- r.append("feedback[screenshot]", e, `screenshot.${o}`);
1658
+ const l = e.type === "image/jpeg" ? "jpg" : "png";
1659
+ s.append("feedback[screenshot]", e, `screenshot.${l}`);
1388
1660
  }
1389
- const s = await this.authHeaders();
1390
- return s["X-Idempotency-Key"] = Ze(), (await this.fetchWithRetry(`${this.apiUrl}/widget/feedbacks`, {
1661
+ const n = await this.authHeaders();
1662
+ return n["X-Submission-Token"] = r, n["X-Idempotency-Key"] = ci(), { ...(await (await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions`, {
1391
1663
  method: "POST",
1392
- headers: s,
1393
- body: r
1394
- })).json();
1664
+ headers: n,
1665
+ body: s
1666
+ })).json()).submission_session, token: r };
1395
1667
  }
1396
1668
  async createIdentityToken(t) {
1397
1669
  const e = await this.authHeaders("application/json");
@@ -1418,39 +1690,51 @@ class Je {
1418
1690
  return !1;
1419
1691
  }
1420
1692
  }
1421
- async startClarification(t, e) {
1422
- const r = {};
1423
- e && (r.message = e);
1424
- const s = await this.authHeaders("application/json");
1425
- return (await this.fetchWithRetry(`${this.apiUrl}/widget/feedbacks/${t}/clarify`, {
1693
+ async startClarification(t, e, r) {
1694
+ const s = {};
1695
+ r && (s.message = r);
1696
+ const n = await this.submissionHeaders(e, "application/json");
1697
+ return (await (await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/clarification`, {
1426
1698
  method: "POST",
1427
- headers: s,
1428
- body: JSON.stringify(r)
1429
- })).json();
1699
+ headers: n,
1700
+ body: JSON.stringify(s)
1701
+ })).json()).clarification;
1430
1702
  }
1431
- async getClarification(t) {
1432
- const e = await this.authHeaders();
1433
- return (await this.fetchWithRetry(`${this.apiUrl}/widget/feedbacks/${t}/clarify`, {
1703
+ async getClarification(t, e) {
1704
+ const r = await this.submissionHeaders(e);
1705
+ return (await (await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/clarification`, {
1434
1706
  method: "GET",
1435
- headers: e
1436
- })).json();
1707
+ headers: r
1708
+ })).json()).clarification;
1437
1709
  }
1438
1710
  // Streams a clarification turn over SSE. Calls onDelta for each token and
1439
1711
  // resolves with the committed result. Throws if the server doesn't stream
1440
1712
  // (e.g. old backend returns JSON) so the caller can fall back to polling.
1441
1713
  async streamClarification(t, e, r) {
1442
- const s = {};
1443
- e && (s.message = e);
1444
- const n = await this.authHeaders("application/json");
1445
- n.Accept = "text/event-stream";
1446
- const o = await fetch(`${this.apiUrl}/widget/feedbacks/${t}/clarify`, {
1714
+ const s = await this.submissionHeaders(e, "application/json");
1715
+ s.Accept = "text/event-stream";
1716
+ const n = await fetch(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/clarification`, {
1447
1717
  method: "POST",
1448
- headers: n,
1449
- body: JSON.stringify(s)
1450
- }), a = o.headers.get("Content-Type") ?? "";
1451
- if (!o.ok || !o.body || !a.includes("text/event-stream"))
1718
+ headers: s,
1719
+ body: JSON.stringify({})
1720
+ }), o = n.headers.get("Content-Type") ?? "";
1721
+ if (!n.ok || !n.body || !o.includes("text/event-stream"))
1452
1722
  throw new Error("clarify stream unavailable");
1453
- return Qe(o.body, r);
1723
+ return li(n.body, r);
1724
+ }
1725
+ async finalizeSubmissionSession(t, e) {
1726
+ const r = await this.submissionHeaders(e);
1727
+ return (await (await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/feedback`, {
1728
+ method: "POST",
1729
+ headers: r
1730
+ })).json()).feedback;
1731
+ }
1732
+ async abandonSubmissionSession(t, e) {
1733
+ const r = await this.submissionHeaders(e);
1734
+ await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}`, {
1735
+ method: "DELETE",
1736
+ headers: r
1737
+ });
1454
1738
  }
1455
1739
  async fetchWithRetry(t, e, r = 1) {
1456
1740
  let s;
@@ -1458,30 +1742,30 @@ class Je {
1458
1742
  s = await fetch(t, e);
1459
1743
  } catch (n) {
1460
1744
  if (r > 0)
1461
- return await V(this.retryDelayMs), this.fetchWithRetry(t, e, r - 1);
1745
+ return await K(this.retryDelayMs), this.fetchWithRetry(t, e, r - 1);
1462
1746
  throw n;
1463
1747
  }
1464
1748
  if (s.ok) return s;
1465
1749
  if (s.status >= 500 && r > 0)
1466
- return await V(this.retryDelayMs), this.fetchWithRetry(t, e, r - 1);
1750
+ return await K(this.retryDelayMs), this.fetchWithRetry(t, e, r - 1);
1467
1751
  throw new Error(`HTTP ${s.status}`);
1468
1752
  }
1469
1753
  }
1470
- function V(i) {
1754
+ function K(i) {
1471
1755
  return i <= 0 ? Promise.resolve() : new Promise((t) => setTimeout(t, i));
1472
1756
  }
1473
- async function Qe(i, t) {
1757
+ async function li(i, t) {
1474
1758
  const e = i.getReader(), r = new TextDecoder();
1475
1759
  let s = "", n = { messages: [], done: !0 };
1476
1760
  const o = (a) => {
1477
1761
  const l = a.split(`
1478
- `).find((k) => k.startsWith("event:")), c = a.split(`
1479
- `).find((k) => k.startsWith("data:"));
1762
+ `).find((x) => x.startsWith("event:")), c = a.split(`
1763
+ `).find((x) => x.startsWith("data:"));
1480
1764
  if (!c) return;
1481
- const h = l?.slice(6).trim(), m = JSON.parse(c.slice(5).trim());
1482
- h === "delta" && typeof m.text == "string" ? t(m.text) : h === "done" && (n = {
1483
- messages: Array.isArray(m.messages) ? m.messages : [],
1484
- done: m.done !== !1
1765
+ const h = l?.slice(6).trim(), p = JSON.parse(c.slice(5).trim());
1766
+ h === "delta" && typeof p.text == "string" ? t(p.text) : h === "done" && (n = {
1767
+ messages: Array.isArray(p.messages) ? p.messages : [],
1768
+ done: p.done !== !1
1485
1769
  });
1486
1770
  };
1487
1771
  for (; ; ) {
@@ -1502,10 +1786,16 @@ async function Qe(i, t) {
1502
1786
  }
1503
1787
  return n;
1504
1788
  }
1505
- function Ze() {
1789
+ function ci() {
1506
1790
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
1507
1791
  }
1508
- function ti(i, t, e, r, s, n, o, a) {
1792
+ function di() {
1793
+ if (typeof crypto > "u" || typeof crypto.getRandomValues != "function")
1794
+ throw new Error("Secure random generation is unavailable");
1795
+ const i = crypto.getRandomValues(new Uint8Array(32));
1796
+ return Array.from(i, (t) => t.toString(16).padStart(2, "0")).join("");
1797
+ }
1798
+ function hi(i, t, e, r, s, n, o, a, l) {
1509
1799
  return {
1510
1800
  description: i,
1511
1801
  ...t,
@@ -1522,53 +1812,54 @@ function ti(i, t, e, r, s, n, o, a) {
1522
1812
  reporter_external_id: s ? void 0 : o,
1523
1813
  reporter_email: s ? void 0 : a,
1524
1814
  recording_events: n?.events,
1525
- recording_duration: n?.duration
1815
+ recording_duration: n?.duration,
1816
+ breadcrumbs: l
1526
1817
  };
1527
1818
  }
1528
- const Y = "mtb_anon_id", ut = "mtb_reporter_email", mt = "mtb_board_url";
1529
- let X = null, ft = null, pt = null;
1530
- function G() {
1819
+ const G = "mtb_anon_id", pt = "mtb_reporter_email", ft = "mtb_board_url";
1820
+ let J = null, bt = null, gt = null;
1821
+ function Q() {
1531
1822
  try {
1532
- const i = window.localStorage.getItem(Y);
1823
+ const i = window.localStorage.getItem(G);
1533
1824
  if (i?.startsWith("anon_")) return i;
1534
- const t = Q();
1535
- return window.localStorage.setItem(Y, t), t;
1825
+ const t = et();
1826
+ return window.localStorage.setItem(G, t), t;
1536
1827
  } catch {
1537
- return X ?? (X = Q()), X;
1828
+ return J ?? (J = et()), J;
1538
1829
  }
1539
1830
  }
1540
- function K() {
1831
+ function Z() {
1541
1832
  try {
1542
- return window.localStorage.getItem(ut) ?? void 0;
1833
+ return window.localStorage.getItem(pt) ?? void 0;
1543
1834
  } catch {
1544
- return ft ?? void 0;
1835
+ return bt ?? void 0;
1545
1836
  }
1546
1837
  }
1547
- function ei(i) {
1548
- ft = i;
1838
+ function ui(i) {
1839
+ bt = i;
1549
1840
  try {
1550
- window.localStorage.setItem(ut, i);
1841
+ window.localStorage.setItem(pt, i);
1551
1842
  } catch {
1552
1843
  }
1553
1844
  }
1554
- function ii() {
1845
+ function mi() {
1555
1846
  try {
1556
- return window.localStorage.getItem(mt) ?? void 0;
1847
+ return window.localStorage.getItem(ft) ?? void 0;
1557
1848
  } catch {
1558
- return pt ?? void 0;
1849
+ return gt ?? void 0;
1559
1850
  }
1560
1851
  }
1561
- function J(i) {
1562
- pt = i;
1852
+ function tt(i) {
1853
+ gt = i;
1563
1854
  try {
1564
- window.localStorage.setItem(mt, i);
1855
+ window.localStorage.setItem(ft, i);
1565
1856
  } catch {
1566
1857
  }
1567
1858
  }
1568
- function Q() {
1859
+ function et() {
1569
1860
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? `anon_${crypto.randomUUID()}` : `anon_${`${Date.now().toString(16)}-${Math.random().toString(16).slice(2, 10)}`}`;
1570
1861
  }
1571
- const ri = {
1862
+ const pi = {
1572
1863
  tab: "Feedback",
1573
1864
  toolbar: {
1574
1865
  markup: "Mark up",
@@ -1584,17 +1875,16 @@ const ri = {
1584
1875
  cancel: "Cancel",
1585
1876
  my_feedback: "My feedback",
1586
1877
  quickOptions: [
1587
- { emoji: "🐛", label: "Something is broken" },
1588
- { emoji: "💡", label: "I wish this worked differently" },
1589
- { emoji: "🤔", label: "I don't understand this" },
1590
- { emoji: "✨", label: "I have an idea" }
1878
+ { emoji: "🐛", label: "Something's broken" },
1879
+ { emoji: "💡", label: "I have a suggestion" },
1880
+ { emoji: "🤔", label: "I'm confused" }
1591
1881
  ]
1592
1882
  },
1593
1883
  success: {
1594
- title: "Thanks!",
1595
- message: "Your feedback has been received.",
1596
- title_no_ai: "Sent — thanks!",
1597
- message_no_ai: "We'll take it from here. You'll hear back when it's resolved.",
1884
+ title: "Sent — thanks!",
1885
+ message: "Your note and captured technical context are on their way to the team. You’ll hear back when it’s resolved.",
1886
+ title_no_ai: "Thanks! We've received your feedback.",
1887
+ message_no_ai: "The team will take it from here. You'll hear back when it's resolved.",
1598
1888
  view_feedback: "View my feedback",
1599
1889
  close: "Close",
1600
1890
  email_prompt: "Want updates? Leave your email and we'll let you know when it's resolved.",
@@ -1618,20 +1908,44 @@ const ri = {
1618
1908
  drawing: "Drawing",
1619
1909
  element: "element"
1620
1910
  },
1911
+ draw: {
1912
+ note_placeholder: "Add a note to your drawing",
1913
+ undo: "Undo",
1914
+ redo: "Redo",
1915
+ cancel: "Cancel",
1916
+ submit: "Submit"
1917
+ },
1621
1918
  record: {
1622
1919
  stop: "Stop",
1623
1920
  timer_label: "Recording",
1624
- max_reached: "Maximum recording time reached"
1921
+ max_reached: "Maximum recording time reached",
1922
+ replay_label: "screen-recording.json",
1923
+ play: "Play recording",
1924
+ close: "Close",
1925
+ preview_unavailable: "Preview unavailable"
1625
1926
  },
1626
1927
  clarify: {
1627
1928
  title: "Make This Better AI",
1628
1929
  subtitle: "Sharpening your feedback",
1629
1930
  thinking: "Thinking...",
1630
- placeholder: "Type your answer — or Skip",
1931
+ placeholder: "Type your answer — or skip the question",
1631
1932
  send: "Send",
1632
- skip: "Skip"
1933
+ skip: "Skip & send",
1934
+ summary: {
1935
+ ready: "Ready to send",
1936
+ what_you_said: "What you said",
1937
+ clarified: "Clarified with AI",
1938
+ auto_captured: "Auto-captured",
1939
+ element: "Element",
1940
+ page: "Page",
1941
+ browser: "Browser",
1942
+ captured: "Captured",
1943
+ send_feedback: "Send feedback",
1944
+ screenshot: "Screenshot",
1945
+ recording: "Interaction replay"
1946
+ }
1633
1947
  }
1634
- }, si = {
1948
+ }, fi = {
1635
1949
  tab: "反馈",
1636
1950
  toolbar: {
1637
1951
  markup: "标注",
@@ -1647,17 +1961,16 @@ const ri = {
1647
1961
  cancel: "取消",
1648
1962
  my_feedback: "我的反馈",
1649
1963
  quickOptions: [
1650
- { emoji: "🐛", label: "这里有问题" },
1651
- { emoji: "💡", label: "我希望它能更好用" },
1652
- { emoji: "🤔", label: "我看不懂这里" },
1653
- { emoji: "✨", label: "我有个想法" }
1964
+ { emoji: "🐛", label: "出问题了" },
1965
+ { emoji: "💡", label: "我有一个建议" },
1966
+ { emoji: "🤔", label: "我有点困惑" }
1654
1967
  ]
1655
1968
  },
1656
1969
  success: {
1657
- title: "感谢!",
1658
- message: "您的反馈已收到。",
1659
- title_no_ai: "已发送,感谢!",
1660
- message_no_ai: "我们会跟进处理,解决后会通知您。",
1970
+ title: "已发送,感谢!",
1971
+ message: "您的反馈和采集到的技术上下文正在发送给团队。问题解决后,您会收到通知。",
1972
+ title_no_ai: "感谢!我们已收到您的反馈。",
1973
+ message_no_ai: "接下来由团队处理。问题解决后,您会收到通知。",
1661
1974
  view_feedback: "查看我的反馈",
1662
1975
  close: "关闭",
1663
1976
  email_prompt: "想了解进展?留下邮箱,问题解决后我们会通知您。",
@@ -1681,20 +1994,44 @@ const ri = {
1681
1994
  drawing: "绘制",
1682
1995
  element: "元素"
1683
1996
  },
1997
+ draw: {
1998
+ note_placeholder: "给你的绘制添加说明",
1999
+ undo: "撤销",
2000
+ redo: "重做",
2001
+ cancel: "取消",
2002
+ submit: "提交"
2003
+ },
1684
2004
  record: {
1685
2005
  stop: "停止",
1686
2006
  timer_label: "录制中",
1687
- max_reached: "已达到最大录制时长"
2007
+ max_reached: "已达到最长录制时间",
2008
+ replay_label: "screen-recording.json",
2009
+ play: "播放录屏",
2010
+ close: "关闭",
2011
+ preview_unavailable: "暂无法预览"
1688
2012
  },
1689
2013
  clarify: {
1690
- title: "让它更好 AI",
2014
+ title: "Make This Better AI",
1691
2015
  subtitle: "正在完善你的反馈",
1692
2016
  thinking: "思考中...",
1693
- placeholder: "输入你的回答 —— 或跳过",
2017
+ placeholder: "输入回答,或跳过问题",
1694
2018
  send: "发送",
1695
- skip: "跳过"
2019
+ skip: "跳过并发送",
2020
+ summary: {
2021
+ ready: "准备发送",
2022
+ what_you_said: "你的描述",
2023
+ clarified: "AI 追问澄清",
2024
+ auto_captured: "自动采集",
2025
+ element: "元素",
2026
+ page: "页面",
2027
+ browser: "浏览器",
2028
+ captured: "已采集",
2029
+ send_feedback: "发送反馈",
2030
+ screenshot: "截图",
2031
+ recording: "交互回放"
2032
+ }
1696
2033
  }
1697
- }, ni = {
2034
+ }, bi = {
1698
2035
  tab: "フィードバック",
1699
2036
  toolbar: {
1700
2037
  markup: "マークアップ",
@@ -1711,15 +2048,14 @@ const ri = {
1711
2048
  my_feedback: "自分のフィードバック",
1712
2049
  quickOptions: [
1713
2050
  { emoji: "🐛", label: "不具合があります" },
1714
- { emoji: "💡", label: "もっと使いやすくしてほしい" },
1715
- { emoji: "🤔", label: "ここがわかりにくい" },
1716
- { emoji: "✨", label: "アイデアがあります" }
2051
+ { emoji: "💡", label: "提案があります" },
2052
+ { emoji: "🤔", label: "わかりにくいです" }
1717
2053
  ]
1718
2054
  },
1719
2055
  success: {
1720
- title: "ありがとうございます!",
1721
- message: "フィードバックを受け付けました。",
1722
- title_no_ai: "送信しました!",
2056
+ title: "送信しました。ありがとうございます!",
2057
+ message: "ご意見と取得した技術情報をチームに送信しました。解決次第お知らせします。",
2058
+ title_no_ai: "ありがとうございます!フィードバックを受け付けました。",
1723
2059
  message_no_ai: "チームが対応します。解決次第お知らせします。",
1724
2060
  view_feedback: "フィードバックを確認",
1725
2061
  close: "閉じる",
@@ -1744,26 +2080,50 @@ const ri = {
1744
2080
  drawing: "描画",
1745
2081
  element: "要素"
1746
2082
  },
2083
+ draw: {
2084
+ note_placeholder: "描画にメモを追加",
2085
+ undo: "元に戻す",
2086
+ redo: "やり直す",
2087
+ cancel: "キャンセル",
2088
+ submit: "送信"
2089
+ },
1747
2090
  record: {
1748
2091
  stop: "停止",
1749
2092
  timer_label: "録画中",
1750
- max_reached: "最大録画時間に達しました"
2093
+ max_reached: "最大記録時間に達しました",
2094
+ replay_label: "screen-recording.json",
2095
+ play: "録画を再生",
2096
+ close: "閉じる",
2097
+ preview_unavailable: "プレビューは利用できません"
1751
2098
  },
1752
2099
  clarify: {
1753
2100
  title: "Make This Better AI",
1754
2101
  subtitle: "フィードバックを整えています",
1755
2102
  thinking: "考え中...",
1756
- placeholder: "回答を入力 — またはスキップ",
2103
+ placeholder: "回答を入力、または質問をスキップ",
1757
2104
  send: "送信",
1758
- skip: "スキップ"
2105
+ skip: "スキップして送信",
2106
+ summary: {
2107
+ ready: "送信の準備ができました",
2108
+ what_you_said: "あなたの入力",
2109
+ clarified: "AI で明確化",
2110
+ auto_captured: "自動取得",
2111
+ element: "要素",
2112
+ page: "ページ",
2113
+ browser: "ブラウザ",
2114
+ captured: "取得済み",
2115
+ send_feedback: "フィードバックを送信",
2116
+ screenshot: "スクリーンショット",
2117
+ recording: "操作リプレイ"
2118
+ }
1759
2119
  }
1760
- }, oi = {
2120
+ }, gi = {
1761
2121
  tab: "피드백",
1762
2122
  toolbar: {
1763
2123
  markup: "마크업",
1764
2124
  record: "녹화",
1765
2125
  hint: "요소를 클릭하여 주석 · 드래그하여 그리기",
1766
- hintRecord: "화면을 녹화 중입니다",
2126
+ hintRecord: "화면 녹화 중",
1767
2127
  exit: "나가기"
1768
2128
  },
1769
2129
  popup: {
@@ -1773,17 +2133,16 @@ const ri = {
1773
2133
  cancel: "취소",
1774
2134
  my_feedback: "내 피드백",
1775
2135
  quickOptions: [
1776
- { emoji: "🐛", label: "오류가 있어요" },
1777
- { emoji: "💡", label: "이 기능을 개선해 주세요" },
1778
- { emoji: "🤔", label: "이 부분을 모르겠어요" },
1779
- { emoji: "✨", label: "아이디어가 있어요" }
2136
+ { emoji: "🐛", label: "문제가 있어요" },
2137
+ { emoji: "💡", label: "제안이 있어요" },
2138
+ { emoji: "🤔", label: "헷갈려요" }
1780
2139
  ]
1781
2140
  },
1782
2141
  success: {
1783
- title: "감사합니다!",
1784
- message: "피드백이 접수되었습니다.",
1785
- title_no_ai: "전송 완료!",
1786
- message_no_ai: "팀에서 처리 후 알려드리겠습니다.",
2142
+ title: "전송되었습니다. 감사합니다!",
2143
+ message: "피드백과 수집된 기술 정보가 팀에 전달되었습니다. 해결되면 알려드리겠습니다.",
2144
+ title_no_ai: "감사합니다! 피드백을 접수했습니다.",
2145
+ message_no_ai: "팀에서 처리합니다. 해결되면 알려드리겠습니다.",
1787
2146
  view_feedback: "내 피드백 보기",
1788
2147
  close: "닫기",
1789
2148
  email_prompt: "진행 상황이 궁금하신가요? 이메일을 남겨주시면 해결 시 알려드립니다.",
@@ -1807,26 +2166,50 @@ const ri = {
1807
2166
  drawing: "그리기",
1808
2167
  element: "요소"
1809
2168
  },
2169
+ draw: {
2170
+ note_placeholder: "그림에 메모 추가",
2171
+ undo: "실행 취소",
2172
+ redo: "다시 실행",
2173
+ cancel: "취소",
2174
+ submit: "보내기"
2175
+ },
1810
2176
  record: {
1811
2177
  stop: "중지",
1812
2178
  timer_label: "녹화 중",
1813
- max_reached: "최대 녹화 시간에 도달했습니다"
2179
+ max_reached: "최대 녹화 시간에 도달했습니다",
2180
+ replay_label: "screen-recording.json",
2181
+ play: "녹화 재생",
2182
+ close: "닫기",
2183
+ preview_unavailable: "미리보기를 사용할 수 없습니다"
1814
2184
  },
1815
2185
  clarify: {
1816
2186
  title: "Make This Better AI",
1817
2187
  subtitle: "피드백을 다듬는 중",
1818
2188
  thinking: "생각 중...",
1819
- placeholder: "답변 입력 — 또는 건너뛰기",
2189
+ placeholder: "답변을 입력하거나 질문을 건너뛰세요",
1820
2190
  send: "보내기",
1821
- skip: "건너뛰기"
2191
+ skip: "건너뛰고 보내기",
2192
+ summary: {
2193
+ ready: "보낼 준비 완료",
2194
+ what_you_said: "입력한 내용",
2195
+ clarified: "AI로 명확화",
2196
+ auto_captured: "자동 수집",
2197
+ element: "요소",
2198
+ page: "페이지",
2199
+ browser: "브라우저",
2200
+ captured: "수집됨",
2201
+ send_feedback: "피드백 보내기",
2202
+ screenshot: "스크린샷",
2203
+ recording: "상호작용 리플레이"
2204
+ }
1822
2205
  }
1823
- }, ai = {
2206
+ }, yi = {
1824
2207
  tab: "Comentarios",
1825
2208
  toolbar: {
1826
2209
  markup: "Anotar",
1827
2210
  record: "Grabar",
1828
2211
  hint: "Haz clic en cualquier elemento para anotar · arrastra para dibujar",
1829
- hintRecord: "Grabando tu pantalla",
2212
+ hintRecord: "Grabando pantalla",
1830
2213
  exit: "Salir"
1831
2214
  },
1832
2215
  popup: {
@@ -1837,16 +2220,15 @@ const ri = {
1837
2220
  my_feedback: "Mis comentarios",
1838
2221
  quickOptions: [
1839
2222
  { emoji: "🐛", label: "Algo no funciona" },
1840
- { emoji: "💡", label: "Me gustaría que funcionara diferente" },
1841
- { emoji: "🤔", label: "No entiendo esto" },
1842
- { emoji: "✨", label: "Tengo una idea" }
2223
+ { emoji: "💡", label: "Tengo una sugerencia" },
2224
+ { emoji: "🤔", label: "Estoy confundido" }
1843
2225
  ]
1844
2226
  },
1845
2227
  success: {
1846
- title: "¡Gracias!",
1847
- message: "Tu comentario ha sido recibido.",
1848
- title_no_ai: "¡Enviado!",
1849
- message_no_ai: "Nos encargamos. Te avisaremos cuando se resuelva.",
2228
+ title: "Enviado, ¡gracias!",
2229
+ message: "Tu nota y el contexto técnico capturado se han enviado al equipo. Te avisaremos cuando se resuelva.",
2230
+ title_no_ai: "¡Gracias! Hemos recibido tu comentario.",
2231
+ message_no_ai: "El equipo se encargará a partir de aquí. Te avisaremos cuando se resuelva.",
1850
2232
  view_feedback: "Ver mis comentarios",
1851
2233
  close: "Cerrar",
1852
2234
  email_prompt: "¿Quieres novedades? Deja tu correo y te avisaremos cuando se resuelva.",
@@ -1870,26 +2252,50 @@ const ri = {
1870
2252
  drawing: "Dibujo",
1871
2253
  element: "elemento"
1872
2254
  },
2255
+ draw: {
2256
+ note_placeholder: "Añade una nota a tu dibujo",
2257
+ undo: "Deshacer",
2258
+ redo: "Rehacer",
2259
+ cancel: "Cancelar",
2260
+ submit: "Enviar"
2261
+ },
1873
2262
  record: {
1874
2263
  stop: "Detener",
1875
2264
  timer_label: "Grabando",
1876
- max_reached: "Se alcanzó el tiempo máximo de grabación"
2265
+ max_reached: "Tiempo máximo de grabación alcanzado",
2266
+ replay_label: "screen-recording.json",
2267
+ play: "Reproducir grabación",
2268
+ close: "Cerrar",
2269
+ preview_unavailable: "Vista previa no disponible"
1877
2270
  },
1878
2271
  clarify: {
1879
2272
  title: "Make This Better AI",
1880
2273
  subtitle: "Afinando tus comentarios",
1881
2274
  thinking: "Pensando...",
1882
- placeholder: "Escribe tu respuesta — o Omitir",
2275
+ placeholder: "Escribe tu respuesta — u omite la pregunta",
1883
2276
  send: "Enviar",
1884
- skip: "Omitir"
2277
+ skip: "Omitir y enviar",
2278
+ summary: {
2279
+ ready: "Listo para enviar",
2280
+ what_you_said: "Lo que dijiste",
2281
+ clarified: "Aclarado con IA",
2282
+ auto_captured: "Capturado automáticamente",
2283
+ element: "Elemento",
2284
+ page: "Página",
2285
+ browser: "Navegador",
2286
+ captured: "Capturado",
2287
+ send_feedback: "Enviar comentario",
2288
+ screenshot: "Captura de pantalla",
2289
+ recording: "Repetición de interacción"
2290
+ }
1885
2291
  }
1886
- }, li = {
2292
+ }, wi = {
1887
2293
  tab: "Avis",
1888
2294
  toolbar: {
1889
2295
  markup: "Annoter",
1890
2296
  record: "Enregistrer",
1891
2297
  hint: "Cliquez sur un élément pour l'annoter · glissez pour dessiner",
1892
- hintRecord: "Enregistrement de l'écran en cours",
2298
+ hintRecord: "Enregistrement de l'écran",
1893
2299
  exit: "Quitter"
1894
2300
  },
1895
2301
  popup: {
@@ -1900,16 +2306,15 @@ const ri = {
1900
2306
  my_feedback: "Mes avis",
1901
2307
  quickOptions: [
1902
2308
  { emoji: "🐛", label: "Quelque chose ne fonctionne pas" },
1903
- { emoji: "💡", label: "J'aimerais que cela fonctionne autrement" },
1904
- { emoji: "🤔", label: "Je ne comprends pas ceci" },
1905
- { emoji: "✨", label: "J'ai une idée" }
2309
+ { emoji: "💡", label: "J'ai une suggestion" },
2310
+ { emoji: "🤔", label: "Je suis perplexe" }
1906
2311
  ]
1907
2312
  },
1908
2313
  success: {
1909
- title: "Merci !",
1910
- message: "Votre avis a bien été reçu.",
1911
- title_no_ai: "Envoyé !",
1912
- message_no_ai: "On s'en occupe. Vous serez informé(e) dès que ce sera résolu.",
2314
+ title: "Envoyé, merci !",
2315
+ message: "Votre message et le contexte technique collecté ont été transmis à l’équipe. Vous serez informé(e) dès que ce sera résolu.",
2316
+ title_no_ai: "Merci ! Nous avons bien reçu votre avis.",
2317
+ message_no_ai: "L’équipe prend le relais. Vous serez informé(e) dès que ce sera résolu.",
1913
2318
  view_feedback: "Voir mes avis",
1914
2319
  close: "Fermer",
1915
2320
  email_prompt: "Envie de suivre l'avancement ? Laissez votre e-mail et nous vous préviendrons une fois résolu.",
@@ -1933,26 +2338,50 @@ const ri = {
1933
2338
  drawing: "Dessin",
1934
2339
  element: "élément"
1935
2340
  },
2341
+ draw: {
2342
+ note_placeholder: "Ajoutez une note à votre dessin",
2343
+ undo: "Annuler",
2344
+ redo: "Rétablir",
2345
+ cancel: "Annuler",
2346
+ submit: "Envoyer"
2347
+ },
1936
2348
  record: {
1937
2349
  stop: "Arrêter",
1938
2350
  timer_label: "Enregistrement",
1939
- max_reached: "Durée maximale d'enregistrement atteinte"
2351
+ max_reached: "Durée maximale d'enregistrement atteinte",
2352
+ replay_label: "screen-recording.json",
2353
+ play: "Lire l'enregistrement",
2354
+ close: "Fermer",
2355
+ preview_unavailable: "Aperçu indisponible"
1940
2356
  },
1941
2357
  clarify: {
1942
2358
  title: "Make This Better AI",
1943
2359
  subtitle: "Affinement de votre retour",
1944
2360
  thinking: "Réflexion...",
1945
- placeholder: "Saisissez votre réponse — ou Ignorer",
2361
+ placeholder: "Saisissez votre réponse — ou ignorez la question",
1946
2362
  send: "Envoyer",
1947
- skip: "Passer"
2363
+ skip: "Ignorer et envoyer",
2364
+ summary: {
2365
+ ready: "Prêt à envoyer",
2366
+ what_you_said: "Ce que vous avez dit",
2367
+ clarified: "Clarifié avec l'IA",
2368
+ auto_captured: "Capturé automatiquement",
2369
+ element: "Élément",
2370
+ page: "Page",
2371
+ browser: "Navigateur",
2372
+ captured: "Capturé",
2373
+ send_feedback: "Envoyer le retour",
2374
+ screenshot: "Capture d'écran",
2375
+ recording: "Relecture des interactions"
2376
+ }
1948
2377
  }
1949
- }, ci = {
2378
+ }, xi = {
1950
2379
  tab: "Feedback",
1951
2380
  toolbar: {
1952
2381
  markup: "Markieren",
1953
2382
  record: "Aufnehmen",
1954
2383
  hint: "Klicken Sie auf ein Element zum Kommentieren · ziehen Sie zum Zeichnen",
1955
- hintRecord: "Bildschirmaufnahme läuft",
2384
+ hintRecord: "Bildschirm wird aufgenommen",
1956
2385
  exit: "Beenden"
1957
2386
  },
1958
2387
  popup: {
@@ -1963,16 +2392,15 @@ const ri = {
1963
2392
  my_feedback: "Mein Feedback",
1964
2393
  quickOptions: [
1965
2394
  { emoji: "🐛", label: "Etwas funktioniert nicht" },
1966
- { emoji: "💡", label: "Ich wünsche mir das anders" },
1967
- { emoji: "🤔", label: "Das verstehe ich nicht" },
1968
- { emoji: "✨", label: "Ich habe eine Idee" }
2395
+ { emoji: "💡", label: "Ich habe einen Vorschlag" },
2396
+ { emoji: "🤔", label: "Ich bin verwirrt" }
1969
2397
  ]
1970
2398
  },
1971
2399
  success: {
1972
- title: "Vielen Dank!",
1973
- message: "Ihr Feedback wurde empfangen.",
1974
- title_no_ai: "Gesendet!",
1975
- message_no_ai: "Wir kümmern uns darum. Sie werden benachrichtigt, sobald es gelöst ist.",
2400
+ title: "Gesendet, vielen Dank!",
2401
+ message: "Ihre Nachricht und der erfasste technische Kontext wurden an das Team gesendet. Sie werden benachrichtigt, sobald das Problem gelöst ist.",
2402
+ title_no_ai: "Vielen Dank! Wir haben Ihr Feedback erhalten.",
2403
+ message_no_ai: "Das Team übernimmt ab hier. Sie werden benachrichtigt, sobald das Problem gelöst ist.",
1976
2404
  view_feedback: "Mein Feedback ansehen",
1977
2405
  close: "Schließen",
1978
2406
  email_prompt: "Updates gewünscht? Hinterlassen Sie Ihre E-Mail und wir melden uns, sobald es gelöst ist.",
@@ -1996,65 +2424,89 @@ const ri = {
1996
2424
  drawing: "Zeichnung",
1997
2425
  element: "Element"
1998
2426
  },
2427
+ draw: {
2428
+ note_placeholder: "Fügen Sie Ihrer Zeichnung eine Notiz hinzu",
2429
+ undo: "Rückgängig",
2430
+ redo: "Wiederholen",
2431
+ cancel: "Abbrechen",
2432
+ submit: "Absenden"
2433
+ },
1999
2434
  record: {
2000
2435
  stop: "Stopp",
2001
2436
  timer_label: "Aufnahme",
2002
- max_reached: "Maximale Aufnahmezeit erreicht"
2437
+ max_reached: "Maximale Aufnahmedauer erreicht",
2438
+ replay_label: "screen-recording.json",
2439
+ play: "Aufnahme abspielen",
2440
+ close: "Schließen",
2441
+ preview_unavailable: "Vorschau nicht verfügbar"
2003
2442
  },
2004
2443
  clarify: {
2005
2444
  title: "Make This Better AI",
2006
2445
  subtitle: "Wir schärfen dein Feedback",
2007
2446
  thinking: "Einen Moment...",
2008
- placeholder: "Gib deine Antwort ein — oder Überspringen",
2447
+ placeholder: "Antwort eingeben — oder Frage überspringen",
2009
2448
  send: "Senden",
2010
- skip: "Überspringen"
2011
- }
2012
- }, S = {
2013
- en: ri,
2014
- "zh-CN": si,
2015
- ja: ni,
2016
- ko: oi,
2017
- es: ai,
2018
- fr: li,
2019
- de: ci
2449
+ skip: "Überspringen & senden",
2450
+ summary: {
2451
+ ready: "Bereit zum Senden",
2452
+ what_you_said: "Was Sie gesagt haben",
2453
+ clarified: "Mit KI geklärt",
2454
+ auto_captured: "Automatisch erfasst",
2455
+ element: "Element",
2456
+ page: "Seite",
2457
+ browser: "Browser",
2458
+ captured: "Erfasst",
2459
+ send_feedback: "Feedback senden",
2460
+ screenshot: "Screenshot",
2461
+ recording: "Interaktions-Replay"
2462
+ }
2463
+ }
2464
+ }, k = {
2465
+ en: pi,
2466
+ "zh-CN": fi,
2467
+ ja: bi,
2468
+ ko: gi,
2469
+ es: yi,
2470
+ fr: wi,
2471
+ de: xi
2020
2472
  };
2021
- function di(i) {
2022
- if (S[i]) return S[i];
2473
+ function vi(i) {
2474
+ if (k[i]) return k[i];
2023
2475
  const t = i.split("-")[0];
2024
- return S[t] ? S[t] : S.en;
2476
+ return k[t] ? k[t] : k.en;
2025
2477
  }
2026
- const hi = 60, ui = "https://cdn.jsdelivr.net/npm/@rrweb/record@2.1.0/umd/record.min.js", mi = "sha384-MrD66HBNSykaP2N95+6hQCFlF5oH2tvL3TD/zyvHNkP/sAFWZx98DX9MEDy8MdVT";
2478
+ const ki = 60, Si = "https://cdn.jsdelivr.net/npm/@rrweb/record@2.1.0/umd/record.min.js", Ei = "sha384-MrD66HBNSykaP2N95+6hQCFlF5oH2tvL3TD/zyvHNkP/sAFWZx98DX9MEDy8MdVT";
2027
2479
  let C = null;
2028
- function fi() {
2029
- return C || (C = pi().catch(() => bi()), C);
2480
+ function Ci() {
2481
+ return C || (C = _i().catch(() => Ti()), C);
2030
2482
  }
2031
- async function pi() {
2483
+ async function _i() {
2032
2484
  return (await import("@rrweb/record")).record;
2033
2485
  }
2034
- function Z() {
2486
+ function it() {
2035
2487
  const i = globalThis;
2036
2488
  return i.rrwebRecord?.record ?? i.rrweb?.record;
2037
2489
  }
2038
- function bi() {
2490
+ function Ti() {
2039
2491
  return new Promise((i, t) => {
2040
- const e = Z();
2492
+ const e = it();
2041
2493
  if (e) {
2042
2494
  i(e);
2043
2495
  return;
2044
2496
  }
2045
2497
  const r = document.createElement("script");
2046
- r.src = ui, r.integrity = mi, r.crossOrigin = "anonymous", r.onload = () => {
2047
- const s = Z();
2498
+ r.src = Si, r.integrity = Ei, r.crossOrigin = "anonymous", r.onload = () => {
2499
+ const s = it();
2048
2500
  s ? i(s) : t(new Error("rrweb record global not found after script load"));
2049
2501
  }, r.onerror = () => t(new Error("Failed to load rrweb from CDN")), document.head.appendChild(r);
2050
2502
  });
2051
2503
  }
2052
- class gi {
2504
+ class Mi {
2053
2505
  constructor(t, e) {
2054
2506
  this.events = [], this.stopFn = null, this.startedAt = 0, this.timer = null, this.clickHandler = null, this.stopped = !1, this.shadow = t, this.onMaxReached = e;
2055
2507
  }
2056
2508
  async start() {
2057
- const t = await fi();
2509
+ const t = await Ci();
2058
2510
  this.startedAt = Date.now(), this.stopped = !1, this.stopFn = t({
2059
2511
  emit: (e) => {
2060
2512
  this.stopped || this.events.push(e);
@@ -2067,7 +2519,7 @@ class gi {
2067
2519
  });
2068
2520
  }, document.addEventListener("click", this.clickHandler, !0), this.timer = setTimeout(() => {
2069
2521
  this.onMaxReached?.();
2070
- }, hi * 1e3);
2522
+ }, ki * 1e3);
2071
2523
  }
2072
2524
  stop() {
2073
2525
  return this.stopped = !0, this.stopFn?.(), this.stopFn = null, this.cleanupTimer(), this.cleanupClickHandler(), {
@@ -2076,7 +2528,7 @@ class gi {
2076
2528
  };
2077
2529
  }
2078
2530
  getDuration() {
2079
- return this.startedAt === 0 ? 0 : Math.round((Date.now() - this.startedAt) / 1e3);
2531
+ return this.startedAt === 0 ? 0 : Math.max(1, Math.round((Date.now() - this.startedAt) / 1e3));
2080
2532
  }
2081
2533
  destroy() {
2082
2534
  this.stopped = !0, this.stopFn?.(), this.stopFn = null, this.cleanupTimer(), this.cleanupClickHandler(), this.events = [], this.startedAt = 0;
@@ -2092,7 +2544,7 @@ class gi {
2092
2544
  r.style.left = `${t}px`, r.style.top = `${e}px`, this.shadow.append(r), r.addEventListener("animationend", () => r.remove());
2093
2545
  }
2094
2546
  }
2095
- class yi {
2547
+ class Li {
2096
2548
  constructor(t, e, r, s) {
2097
2549
  this.intervalId = null, this.getDuration = r, this.el = t.el("div", "mtb-record-bar"), this.el.innerHTML = `
2098
2550
  <span class="mtb-record-dot"></span>
@@ -2108,12 +2560,12 @@ class yi {
2108
2560
  this.intervalId && (clearInterval(this.intervalId), this.intervalId = null), this.el.remove();
2109
2561
  }
2110
2562
  }
2111
- class xi {
2563
+ class Pi {
2112
2564
  constructor() {
2113
2565
  this.session = null, this.bar = null, this.result = null;
2114
2566
  }
2115
2567
  async start(t, e, r) {
2116
- this.session = new gi(t, r), this.bar = new yi(
2568
+ this.session = new Mi(t, r), this.bar = new Li(
2117
2569
  t,
2118
2570
  e,
2119
2571
  () => this.session?.getDuration() ?? 0,
@@ -2133,12 +2585,12 @@ class xi {
2133
2585
  this.session?.destroy(), this.session = null, this.bar?.destroy(), this.bar = null;
2134
2586
  }
2135
2587
  }
2136
- class tt {
2588
+ class rt {
2137
2589
  constructor(t) {
2138
- this.tab = null, this.toolbar = null, this.session = null, this.popup = null, this.clarify = null, this.success = null, this.frustrationPrompt = null, this.frustrationDetector = null, this.mode = "idle", this.currentAnnotation = null, this.lastPopupPos = null, this.recordingManager = null, this.lastHandoff = {}, this.config = t, this.messages = di(t.locale ?? "en"), this.apiClient = new Je(t.projectKey, t.apiUrl, void 0, t.userToken, t.userTokenFn), this.consoleCollector = new Oe(), this.consoleCollector.start(), this.buildUI(), t.frustrationDetection !== !1 && (this.frustrationDetector = new P(() => this.handleFrustration()), this.frustrationDetector.start());
2590
+ this.tab = null, this.toolbar = null, this.session = null, this.drawBar = null, this.dim = null, this.popup = null, this.clarify = null, this.success = null, this.frustrationPrompt = null, this.frustrationDetector = null, this.mode = "idle", this.via = "pin", this.currentAnnotation = null, this.submittingUi = null, this.lastPopupPos = null, this.recordingManager = null, this.activeSubmission = null, this.submissionAttempt = 0, this.lastHandoff = {}, this.config = t, this.messages = vi(t.locale ?? "en"), this.apiClient = new ai(t.projectKey, t.apiUrl, void 0, t.userToken, t.userTokenFn), this.consoleCollector = new We(), this.consoleCollector.start(), this.breadcrumbCollector = new Ye(), this.breadcrumbCollector.start(), this.buildUI(), t.frustrationDetection !== !1 && (this.frustrationDetector = new I(() => this.handleFrustration()), this.frustrationDetector.start());
2139
2591
  }
2140
2592
  buildUI() {
2141
- this.shadow = new gt(this.config.theme ?? "auto"), this.tab = new yt(
2593
+ this.shadow = new wt(this.config.theme ?? "auto"), this.tab = new xt(
2142
2594
  this.shadow,
2143
2595
  this.messages,
2144
2596
  this.config.position ?? "right",
@@ -2150,7 +2602,7 @@ class tt {
2150
2602
  this.mode === "idle" ? (this.dismissFrustrationPrompt(), this.enterAnnotationMode()) : this.exitAll();
2151
2603
  }
2152
2604
  handleFrustration() {
2153
- this.mode !== "idle" || this.frustrationPrompt || (this.frustrationPrompt = new wt(this.shadow, this.messages, {
2605
+ this.mode !== "idle" || this.frustrationPrompt || (this.frustrationPrompt = new kt(this.shadow, this.messages, {
2154
2606
  onTell: () => {
2155
2607
  this.dismissFrustrationPrompt(), this.enterAnnotationMode();
2156
2608
  },
@@ -2161,89 +2613,164 @@ class tt {
2161
2613
  this.frustrationPrompt?.destroy(), this.frustrationPrompt = null;
2162
2614
  }
2163
2615
  enterAnnotationMode() {
2164
- this.mode = "annotating", this.tab?.setActive(!0), this.toolbar = new kt(
2616
+ this.mode = "annotating", this.tab?.setActive(!0), this.toolbar = new Et(
2165
2617
  this.shadow,
2166
2618
  this.messages,
2167
2619
  () => this.exitAll(),
2168
2620
  (t) => this.handleToolbarModeChange(t)
2169
- ), this.session = new H(this.shadow, this.messages, (t, e) => {
2170
- this.currentAnnotation = t, this.showPopup(t.x, t.y, e);
2621
+ ), this.session = this.createSession();
2622
+ }
2623
+ createSession() {
2624
+ return new Dt(this.shadow, this.messages, {
2625
+ onPin: (t, e) => {
2626
+ this.currentAnnotation = t, this.via = "pin", this.showPopup(t.x, t.y, e);
2627
+ },
2628
+ onDrawStroke: () => this.handleDrawStroke()
2171
2629
  });
2172
2630
  }
2173
2631
  handleToolbarModeChange(t) {
2174
- t === "record" ? (this.mode = "recording", this.session?.destroy(), this.session = null, this.recordingManager = new xi(), this.recordingManager.start(this.shadow, this.messages, () => {
2175
- this.recordingManager && (this.recordingManager.stop(), this.showPopup(window.innerWidth / 2, window.innerHeight / 2, this.messages.record.timer_label));
2176
- }).catch((e) => {
2177
- console.warn("[MakeThisBetter] Screen recording unavailable, falling back to markup:", e), this.mode === "recording" && (this.toolbar?.setMode("markup"), this.handleToolbarModeChange("markup"));
2178
- })) : (this.recordingManager?.destroy(), this.recordingManager = null, this.session || (this.session = new H(this.shadow, this.messages, (e, r) => {
2179
- this.currentAnnotation = e, this.showPopup(e.x, e.y, r);
2180
- })), this.mode = "annotating");
2632
+ if (this.mode === "clarifying") {
2633
+ this.toolbar?.setMode(this.via === "record" ? "record" : "markup");
2634
+ return;
2635
+ }
2636
+ if (t === "record") {
2637
+ if (this.mode === "recording") return;
2638
+ this.mode = "recording", this.currentAnnotation = null, this.teardownDraw(), this.session?.destroy(), this.session = null, this.recordingManager = new Pi(), this.recordingManager.start(this.shadow, this.messages, () => {
2639
+ this.recordingManager && (this.recordingManager.stop(), this.via = "record", this.showPopup(window.innerWidth / 2, window.innerHeight / 2, this.messages.record.timer_label));
2640
+ }).catch((e) => {
2641
+ console.warn("[MakeThisBetter] Interaction replay unavailable, falling back to markup:", e), this.mode === "recording" && (this.toolbar?.setMode("markup"), this.handleToolbarModeChange("markup"));
2642
+ });
2643
+ } else
2644
+ this.recordingManager?.destroy(), this.recordingManager = null, this.teardownDraw(), this.session || (this.session = this.createSession()), this.mode = "annotating";
2645
+ }
2646
+ handleDrawStroke() {
2647
+ this.mode !== "drawing" && (this.mode = "drawing", this.drawBar = new It(this.shadow, {
2648
+ messages: this.messages,
2649
+ onUndo: () => this.handleDrawUndoRedo("undo"),
2650
+ onRedo: () => this.handleDrawUndoRedo("redo"),
2651
+ onCancel: () => this.cancelDraw(),
2652
+ onSubmit: (t) => this.handleDrawSubmit(t)
2653
+ })), this.refreshDrawBar();
2654
+ }
2655
+ handleDrawUndoRedo(t) {
2656
+ t === "undo" ? this.session?.undoDraw() : this.session?.redoDraw(), this.refreshDrawBar();
2657
+ }
2658
+ refreshDrawBar() {
2659
+ this.session && this.drawBar?.setUndoRedo(this.session.canUndoDraw(), this.session.canRedoDraw());
2660
+ }
2661
+ cancelDraw() {
2662
+ this.session?.clearDraw(), this.teardownDraw(), this.mode = "annotating";
2663
+ }
2664
+ teardownDraw() {
2665
+ this.drawBar?.destroy(), this.drawBar = null;
2666
+ }
2667
+ handleDrawSubmit(t) {
2668
+ const e = this.session?.getDrawAnnotation();
2669
+ if (!e) {
2670
+ this.cancelDraw();
2671
+ return;
2672
+ }
2673
+ this.currentAnnotation = e, this.via = "draw", this.session?.dismissInteraction(), this.submittingUi = this.drawBar, this.handleSubmit(t || this.messages.annotation.drawing);
2181
2674
  }
2182
2675
  showPopup(t, e, r) {
2183
- this.mode = "popup", this.lastPopupPos = { x: t, y: e }, this.session?.dismissInteraction(), this.popup = new Lt(this.shadow, {
2676
+ this.mode = "popup", this.lastPopupPos = { x: t, y: e }, this.teardownDraw(), this.session?.dismissInteraction(), this.popup?.destroy(), this.popup = null, this.dim?.destroy(), this.dim = null, this.dim = new St(this.shadow, () => this.exitAll());
2677
+ const s = this.via === "record" ? this.recordingManager?.getRecording() ?? void 0 : void 0;
2678
+ this.popup = new Ht(this.shadow, {
2184
2679
  targetName: r,
2185
2680
  x: t,
2186
2681
  y: e,
2187
2682
  messages: this.messages,
2188
- onSubmit: (s) => this.handleSubmit(s),
2683
+ recording: s ? { events: s.events, duration: s.duration } : void 0,
2684
+ onSubmit: (n) => this.handleSubmit(n),
2189
2685
  onClose: () => this.exitAll(),
2190
2686
  onMyFeedback: this.buildMyFeedbackHandler()
2191
- });
2687
+ }), this.submittingUi = this.popup;
2192
2688
  }
2193
2689
  buildMyFeedbackHandler() {
2194
- if (!this.config.user && ii())
2690
+ if (!this.config.user && mi())
2195
2691
  return async () => {
2196
- const t = await this.apiClient.createIdentityToken(G());
2197
- !t?.identity_token || !t.board_url || (J(t.board_url), window.open(`${t.board_url}?identity=${encodeURIComponent(t.identity_token)}`, "_blank"));
2692
+ const t = await this.apiClient.createIdentityToken(Q());
2693
+ !t?.identity_token || !t.board_url || (tt(t.board_url), window.open(`${t.board_url}?identity=${encodeURIComponent(t.identity_token)}`, "_blank"));
2198
2694
  };
2199
2695
  }
2200
2696
  async handleSubmit(t) {
2201
- if (!this.popup) return;
2202
- this.popup.setLoading(!0), await new Promise((a) => requestAnimationFrame(() => setTimeout(a, 0)));
2203
- const e = this.currentAnnotation, r = this.recordingManager?.getRecording() ?? void 0, [s, n] = await Promise.all([
2204
- Ae(e ? [e] : []),
2205
- Promise.resolve(Ye())
2206
- ]), o = ti(
2697
+ const e = this.submittingUi;
2698
+ if (!e) return;
2699
+ const r = ++this.submissionAttempt;
2700
+ e.setLoading(!0), await Ai();
2701
+ const s = this.currentAnnotation, n = this.recordingManager?.getRecording() ?? void 0, [o, a] = await Promise.all([
2702
+ He(s ? [s] : []),
2703
+ Promise.resolve(ri())
2704
+ ]), l = hi(
2207
2705
  t,
2208
- n,
2706
+ a,
2209
2707
  this.consoleCollector.getErrors(),
2210
- e,
2708
+ s,
2211
2709
  this.config.user,
2212
- r,
2213
- this.config.user ? void 0 : G(),
2214
- this.config.user ? void 0 : K()
2710
+ n,
2711
+ this.config.user ? void 0 : Q(),
2712
+ this.config.user ? void 0 : Z(),
2713
+ this.breadcrumbCollector.getBreadcrumbs()
2215
2714
  );
2216
2715
  try {
2217
- const a = await this.apiClient.submitFeedback(o, s);
2218
- this.lastHandoff = { feedbackId: a.id, boardUrl: a.board_url, identityToken: a.identity_token }, a.board_url && J(a.board_url), this.popup?.destroy(), this.popup = null, this.session?.destroy(), this.session = null, this.toolbar?.destroy(), this.toolbar = null, this.recordingManager?.destroy(), this.recordingManager = null, a.skip_followup === !0 || a.ai_clarify_available === !1 ? this.showSuccess({ skipFollowup: !0 }) : this.showClarify(a.id, this.lastPopupPos);
2716
+ const c = await this.apiClient.createSubmissionSession(l, o);
2717
+ if (r !== this.submissionAttempt) {
2718
+ await this.apiClient.abandonSubmissionSession(c.id, c.token).catch(() => {
2719
+ });
2720
+ return;
2721
+ }
2722
+ this.activeSubmission = c;
2723
+ const h = this.buildSummaryContext(t, a, s);
2724
+ this.teardownDraw(), this.popup?.destroy(), this.popup = null, this.dim?.destroy(), this.dim = null, this.session?.destroy(), this.session = null, this.recordingManager?.destroy(), this.recordingManager = null, this.submittingUi = null, this.showClarify(c, this.lastPopupPos, h);
2219
2725
  } catch {
2220
- this.popup?.setLoading(!1), this.popup?.setError(this.messages.error.submit);
2726
+ if (r !== this.submissionAttempt) return;
2727
+ e.setLoading(!1), e.setError(this.messages.error.submit);
2221
2728
  }
2222
2729
  }
2223
- showClarify(t, e) {
2224
- this.mode = "clarifying", this.tab?.setActive(!0), this.clarify = new Pt(this.shadow, {
2225
- feedbackId: t,
2730
+ buildSummaryContext(t, e, r) {
2731
+ const s = this.messages.clarify.summary;
2732
+ return {
2733
+ originalDescription: t,
2734
+ element: r?.targetName ?? this.messages.annotation.element,
2735
+ page: e.page_url,
2736
+ browser: `${e.browser} · ${e.os}`,
2737
+ captured: this.via === "record" ? s.recording : s.screenshot
2738
+ };
2739
+ }
2740
+ showClarify(t, e, r) {
2741
+ this.mode = "clarifying", this.tab?.setActive(!0), this.clarify = new Ft(this.shadow, {
2742
+ submissionSessionId: t.id,
2743
+ submissionToken: t.token,
2226
2744
  apiClient: this.apiClient,
2227
2745
  messages: this.messages,
2746
+ summary: r,
2228
2747
  x: e?.x,
2229
2748
  y: e?.y,
2230
- onDone: () => {
2231
- this.clarify?.destroy(), this.clarify = null, this.showSuccess();
2232
- }
2749
+ onFinalize: () => this.finalizeSubmission()
2233
2750
  });
2234
2751
  }
2752
+ async finalizeSubmission() {
2753
+ const t = this.activeSubmission;
2754
+ if (!t) throw new Error("No active submission session");
2755
+ const e = this.submissionAttempt, r = await this.apiClient.finalizeSubmissionSession(t.id, t.token);
2756
+ e !== this.submissionAttempt || this.activeSubmission !== t || (this.activeSubmission = null, this.lastHandoff = {
2757
+ feedbackId: r.id,
2758
+ boardUrl: r.board_url,
2759
+ identityToken: r.identity_token
2760
+ }, r.board_url && tt(r.board_url), this.clarify?.destroy(), this.clarify = null, this.toolbar?.destroy(), this.toolbar = null, this.showSuccess({ skipFollowup: t.ai_clarify_available === !1 }));
2761
+ }
2235
2762
  showSuccess(t) {
2236
- this.mode = "idle", this.tab?.setActive(!1), this.success = new Ht(this.shadow, this.messages, () => {
2763
+ this.mode = "idle", this.tab?.setActive(!1), this.success = new Ut(this.shadow, this.messages, () => {
2237
2764
  this.success?.destroy(), this.success = null;
2238
2765
  }, this.buildViewFeedbackHandler(), { ...t, emailCapture: this.buildEmailCapture() });
2239
2766
  }
2240
2767
  buildEmailCapture() {
2241
2768
  const { feedbackId: t, identityToken: e } = this.lastHandoff;
2242
- if (!(!t || !e) && !K())
2769
+ if (!(!t || !e) && !Z())
2243
2770
  return {
2244
2771
  onSubmit: async (r) => {
2245
2772
  const s = await this.apiClient.updateReporter(t, r, e);
2246
- return s && ei(r), s;
2773
+ return s && ui(r), s;
2247
2774
  }
2248
2775
  };
2249
2776
  }
@@ -2262,25 +2789,31 @@ class tt {
2262
2789
  }
2263
2790
  }
2264
2791
  exitAll() {
2265
- this.mode = "idle", this.tab?.setActive(!1), this.toolbar?.destroy(), this.toolbar = null, this.session?.destroy(), this.session = null, this.popup?.destroy(), this.popup = null, this.clarify?.destroy(), this.clarify = null, this.currentAnnotation = null, this.recordingManager?.destroy(), this.recordingManager = null;
2792
+ this.submissionAttempt += 1;
2793
+ const t = this.activeSubmission;
2794
+ this.activeSubmission = null, t && this.apiClient.abandonSubmissionSession(t.id, t.token).catch(() => {
2795
+ }), this.mode = "idle", this.via = "pin", this.tab?.setActive(!1), this.teardownDraw(), this.toolbar?.destroy(), this.toolbar = null, this.session?.destroy(), this.session = null, this.dim?.destroy(), this.dim = null, this.popup?.destroy(), this.popup = null, this.clarify?.destroy(), this.clarify = null, this.currentAnnotation = null, this.submittingUi = null, this.recordingManager?.destroy(), this.recordingManager = null;
2266
2796
  }
2267
2797
  destroy() {
2268
- this.exitAll(), this.consoleCollector.stop(), this.frustrationDetector?.stop(), this.dismissFrustrationPrompt(), this.clarify?.destroy(), this.success?.destroy(), this.tab?.destroy(), this.recordingManager?.destroy(), this.shadow.destroy();
2798
+ this.exitAll(), this.consoleCollector.stop(), this.breadcrumbCollector.stop(), this.frustrationDetector?.stop(), this.dismissFrustrationPrompt(), this.clarify?.destroy(), this.success?.destroy(), this.tab?.destroy(), this.recordingManager?.destroy(), this.shadow.destroy();
2269
2799
  }
2270
2800
  }
2271
- let g = null;
2272
- const wi = {
2801
+ function Ai() {
2802
+ return new Promise((i) => requestAnimationFrame(() => setTimeout(i, 0)));
2803
+ }
2804
+ let b = null;
2805
+ const Di = {
2273
2806
  init(i) {
2274
- g && (g.destroy(), g = null), document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", () => {
2275
- g = new tt(i);
2276
- }) : g = new tt(i);
2807
+ b && (b.destroy(), b = null), document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", () => {
2808
+ b = new rt(i);
2809
+ }) : b = new rt(i);
2277
2810
  },
2278
2811
  destroy() {
2279
- g?.destroy(), g = null;
2812
+ b?.destroy(), b = null;
2280
2813
  }
2281
2814
  };
2282
- typeof window < "u" && (window.MakeThisBetter = wi);
2815
+ typeof window < "u" && (window.MakeThisBetter = Di);
2283
2816
  export {
2284
- wi as MakeThisBetter
2817
+ Di as MakeThisBetter
2285
2818
  };
2286
2819
  //# sourceMappingURL=makethisbetter.esm.js.map