makethisbetter 1.5.4 → 1.7.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 (107) 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 +50 -25
  37. package/dist/makethisbetter.cjs.map +1 -1
  38. package/dist/makethisbetter.esm.js +1132 -590
  39. package/dist/makethisbetter.esm.js.map +1 -1
  40. package/dist/makethisbetter.js +49 -24
  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 +18 -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 +1 -1
  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 +132 -40
  88. package/src/popup/clarify.ts +154 -42
  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 +476 -65
  100. package/src/widget/controller.ts +222 -40
  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
@@ -1,9 +1,9 @@
1
- const bt = '*,*: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}.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: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{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: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;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}: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, Pt = 45e3, L = 346, A = 320;
372
- class Rt {
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 Rt {
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,39 +511,42 @@ class Rt {
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>
516
+ <button class="mtb-clarify-skip" type="button">${d(t.clarify.skip)}</button>
410
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("input", () => {
532
+ this.el.querySelector(".mtb-clarify-skip").addEventListener("click", t), this.el.querySelector(".mtb-clarify-close").addEventListener("click", t), this.inputEl.addEventListener("input", () => {
426
533
  this.sendBtn.disabled = !this.inputEl.value.trim();
427
- }), this.inputEl.addEventListener("keydown", (r) => {
428
- r.isComposing || r.keyCode === 229 || r.key === "Enter" && !r.shiftKey && (r.preventDefault(), this.sendMessage(t));
429
- }), this.sendBtn.addEventListener("click", () => this.sendMessage(t));
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());
430
537
  }
431
538
  async startConversation() {
432
- this.showThinking(), await this.runTurn(void 0);
539
+ this.showThinking(), await this.runInitialTurn();
433
540
  }
434
- async sendMessage(t) {
435
- const e = this.inputEl.value.trim();
436
- if (!(!e || this.sending)) {
437
- 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();
438
545
  try {
439
- 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();
440
550
  } finally {
441
551
  this.sending = !1, this.inputEl.disabled = !1, this.sendBtn.disabled = !this.inputEl.value.trim(), this.inputEl.focus();
442
552
  }
@@ -444,30 +554,48 @@ class Rt {
444
554
  }
445
555
  // Streams the assistant reply; falls back to POST + polling if the backend
446
556
  // doesn't support SSE (older server) or the stream errors mid-flight.
447
- async runTurn(t) {
557
+ async runInitialTurn() {
448
558
  try {
449
- const e = await this.apiClient.streamClarification(
450
- this.feedbackId,
451
- t,
452
- (r) => this.appendStreamDelta(r)
559
+ const t = await this.apiClient.streamClarification(
560
+ this.submissionSessionId,
561
+ this.submissionToken,
562
+ (e) => this.appendStreamDelta(e)
453
563
  );
454
564
  if (this.destroyed) return;
455
- 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();
456
566
  } catch {
457
567
  if (this.destroyed) return;
458
- this.endStreamingBubble(), await this.runTurnViaPolling(t);
568
+ this.endStreamingBubble(), await this.runInitialTurnViaPolling();
459
569
  }
460
570
  }
461
- async runTurnViaPolling(t) {
571
+ async runInitialTurnViaPolling() {
462
572
  try {
463
- const e = await this.apiClient.startClarification(this.feedbackId, t);
573
+ const t = await this.apiClient.startClarification(
574
+ this.submissionSessionId,
575
+ this.submissionToken
576
+ );
464
577
  if (this.destroyed) return;
465
- 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();
466
579
  } catch {
467
580
  if (this.destroyed) return;
468
- this.onDone();
581
+ this.handleDone();
469
582
  }
470
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
+ }
471
599
  appendStreamDelta(t) {
472
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;
473
601
  }
@@ -475,7 +603,7 @@ class Rt {
475
603
  this.streamingBubble = null;
476
604
  }
477
605
  startPolling() {
478
- this.stopPolling(), this.pollDeadline = Date.now() + Pt, this.pollTimer = setInterval(() => this.poll(), At);
606
+ this.stopPolling(), this.pollDeadline = Date.now() + Bt, this.pollTimer = setInterval(() => this.poll(), $t);
479
607
  }
480
608
  stopPolling() {
481
609
  this.pollTimer !== null && (clearInterval(this.pollTimer), this.pollTimer = null);
@@ -486,21 +614,70 @@ class Rt {
486
614
  return;
487
615
  }
488
616
  try {
489
- const t = await this.apiClient.getClarification(this.feedbackId);
617
+ const t = await this.apiClient.getClarification(
618
+ this.submissionSessionId,
619
+ this.submissionToken
620
+ );
490
621
  if (this.destroyed) return;
491
622
  this.renderConversation(t.messages, t.done), t.done && (this.stopPolling(), this.handleDone());
492
623
  } catch {
493
624
  if (this.destroyed) return;
494
- this.stopPolling();
625
+ this.stopPolling(), this.handleDone();
495
626
  }
496
627
  }
497
628
  handleDone() {
498
- this.inputEl.disabled = !0, this.sendBtn.disabled = !0, this.doneTimer = setTimeout(() => {
499
- this.destroyed || this.onDone();
500
- }, 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;
501
678
  }
502
679
  renderConversation(t, e) {
503
- this.renderMessages(t);
680
+ this.lastMessages = t, this.renderMessages(t);
504
681
  const r = t[t.length - 1];
505
682
  !e && (!r || r.role === "user") && this.showThinking();
506
683
  }
@@ -523,14 +700,11 @@ class Rt {
523
700
  this.messagesEl.querySelector(".mtb-clarify-thinking")?.remove();
524
701
  }
525
702
  destroy() {
526
- 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();
527
704
  }
528
705
  }
529
- function b(i) {
530
- return i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
531
- }
532
- const It = 5e3, $t = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
533
- class Ht {
706
+ const zt = 5e3, Ot = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
707
+ class Ut {
534
708
  constructor(t, e, r, s, n) {
535
709
  this.messages = e, this.el = t.el("div", "mtb-success"), this.el.style.right = "20px", this.el.style.bottom = "20px";
536
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 ? `
@@ -544,7 +718,7 @@ class Ht {
544
718
  </div>` : "";
545
719
  this.el.innerHTML = `
546
720
  <div class="mtb-success-icon">
547
- <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">
548
722
  <polyline points="20 6 9 17 4 12"/>
549
723
  </svg>
550
724
  </div>
@@ -553,12 +727,12 @@ class Ht {
553
727
  ${c}
554
728
  ${l}
555
729
  <button class="mtb-close-link">${e.success.close}</button>
556
- `, 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);
557
731
  }
558
732
  bindEmailCapture(t) {
559
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 () => {
560
734
  const o = e.value.trim();
561
- if (!$t.test(o)) {
735
+ if (!Ot.test(o)) {
562
736
  e.classList.add("mtb-email-invalid");
563
737
  return;
564
738
  }
@@ -572,7 +746,7 @@ class Ht {
572
746
  this.el.remove();
573
747
  }
574
748
  }
575
- function Ot(i, t) {
749
+ function jt(i, t) {
576
750
  if (i.match(/^[a-z]+:\/\//i))
577
751
  return i;
578
752
  if (i.match(/^\/\//))
@@ -582,7 +756,7 @@ function Ot(i, t) {
582
756
  const e = document.implementation.createHTMLDocument(), r = e.createElement("base"), s = e.createElement("a");
583
757
  return e.head.appendChild(r), e.body.appendChild(s), t && (r.href = t), s.href = i, s.href;
584
758
  }
585
- const Ft = /* @__PURE__ */ (() => {
759
+ const qt = /* @__PURE__ */ (() => {
586
760
  let i = 0;
587
761
  const t = () => (
588
762
  // eslint-disable-next-line no-bitwise
@@ -596,27 +770,27 @@ function f(i) {
596
770
  t.push(i[e]);
597
771
  return t;
598
772
  }
599
- let y = null;
600
- function it(i = {}) {
601
- 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));
602
776
  }
603
777
  function _(i, t) {
604
778
  const r = (i.ownerDocument.defaultView || window).getComputedStyle(i).getPropertyValue(t);
605
779
  return r ? parseFloat(r.replace("px", "")) : 0;
606
780
  }
607
- function jt(i) {
781
+ function Nt(i) {
608
782
  const t = _(i, "border-left-width"), e = _(i, "border-right-width");
609
783
  return i.clientWidth + t + e;
610
784
  }
611
- function Bt(i) {
785
+ function Wt(i) {
612
786
  const t = _(i, "border-top-width"), e = _(i, "border-bottom-width");
613
787
  return i.clientHeight + t + e;
614
788
  }
615
- function rt(i, t = {}) {
616
- const e = t.width || jt(i), r = t.height || Bt(i);
789
+ function ot(i, t = {}) {
790
+ const e = t.width || Nt(i), r = t.height || Wt(i);
617
791
  return { width: e, height: r };
618
792
  }
619
- function Ut() {
793
+ function Vt() {
620
794
  let i, t;
621
795
  try {
622
796
  t = process;
@@ -625,11 +799,11 @@ function Ut() {
625
799
  const e = t && t.env ? t.env.devicePixelRatio : null;
626
800
  return e && (i = parseInt(e, 10), Number.isNaN(i) && (i = 1)), i || window.devicePixelRatio || 1;
627
801
  }
628
- const u = 16384;
629
- function zt(i) {
630
- (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));
631
805
  }
632
- function M(i) {
806
+ function T(i) {
633
807
  return new Promise((t, e) => {
634
808
  const r = new Image();
635
809
  r.onload = () => {
@@ -639,80 +813,80 @@ function M(i) {
639
813
  }, r.onerror = e, r.crossOrigin = "anonymous", r.decoding = "async", r.src = i;
640
814
  });
641
815
  }
642
- async function qt(i) {
816
+ async function Kt(i) {
643
817
  return Promise.resolve().then(() => new XMLSerializer().serializeToString(i)).then(encodeURIComponent).then((t) => `data:image/svg+xml;charset=utf-8,${t}`);
644
818
  }
645
- async function Wt(i, t, e) {
819
+ async function Xt(i, t, e) {
646
820
  const r = "http://www.w3.org/2000/svg", s = document.createElementNS(r, "svg"), n = document.createElementNS(r, "foreignObject");
647
- 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), Kt(s);
648
822
  }
649
- const d = (i, t) => {
823
+ const u = (i, t) => {
650
824
  if (i instanceof t)
651
825
  return !0;
652
826
  const e = Object.getPrototypeOf(i);
653
- 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);
654
828
  };
655
- function Nt(i) {
829
+ function Gt(i) {
656
830
  const t = i.getPropertyValue("content");
657
831
  return `${i.cssText} content: '${t.replace(/'|"/g, "")}';`;
658
832
  }
659
- function Vt(i, t) {
660
- return it(t).map((e) => {
833
+ function Jt(i, t) {
834
+ return nt(t).map((e) => {
661
835
  const r = i.getPropertyValue(e), s = i.getPropertyPriority(e);
662
836
  return `${e}: ${r}${s ? " !important" : ""};`;
663
837
  }).join(" ");
664
838
  }
665
- function Yt(i, t, e, r) {
666
- 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);
667
841
  return document.createTextNode(`${s}{${n}}`);
668
842
  }
669
- function F(i, t, e, r) {
843
+ function U(i, t, e, r) {
670
844
  const s = window.getComputedStyle(i, e), n = s.getPropertyValue("content");
671
845
  if (n === "" || n === "none")
672
846
  return;
673
- const o = Ft();
847
+ const o = qt();
674
848
  try {
675
849
  t.className = `${t.className} ${o}`;
676
850
  } catch {
677
851
  return;
678
852
  }
679
853
  const a = document.createElement("style");
680
- a.appendChild(Yt(o, e, s, r)), t.appendChild(a);
854
+ a.appendChild(Qt(o, e, s, r)), t.appendChild(a);
681
855
  }
682
- function Xt(i, t, e) {
683
- 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);
684
858
  }
685
- const j = "application/font-woff", B = "image/jpeg", Gt = {
859
+ const j = "application/font-woff", q = "image/jpeg", te = {
686
860
  woff: j,
687
861
  woff2: j,
688
862
  ttf: "application/font-truetype",
689
863
  eot: "application/vnd.ms-fontobject",
690
864
  png: "image/png",
691
- jpg: B,
692
- jpeg: B,
865
+ jpg: q,
866
+ jpeg: q,
693
867
  gif: "image/gif",
694
868
  tiff: "image/tiff",
695
869
  svg: "image/svg+xml",
696
870
  webp: "image/webp"
697
871
  };
698
- function Kt(i) {
872
+ function ee(i) {
699
873
  const t = /\.([^./]*?)$/g.exec(i);
700
874
  return t ? t[1] : "";
701
875
  }
702
- function I(i) {
703
- const t = Kt(i).toLowerCase();
704
- return Gt[t] || "";
876
+ function $(i) {
877
+ const t = ee(i).toLowerCase();
878
+ return te[t] || "";
705
879
  }
706
- function Jt(i) {
880
+ function ie(i) {
707
881
  return i.split(/,/)[1];
708
882
  }
709
- function P(i) {
883
+ function R(i) {
710
884
  return i.search(/^(data:)/) !== -1;
711
885
  }
712
- function Qt(i, t) {
886
+ function re(i, t) {
713
887
  return `data:${t};base64,${i}`;
714
888
  }
715
- async function st(i, t, e) {
889
+ async function at(i, t, e) {
716
890
  const r = await fetch(i, t);
717
891
  if (r.status === 404)
718
892
  throw new Error(`Resource "${r.url}" not found`);
@@ -729,19 +903,19 @@ async function st(i, t, e) {
729
903
  });
730
904
  }
731
905
  const D = {};
732
- function Zt(i, t, e) {
906
+ function se(i, t, e) {
733
907
  let r = i.replace(/\?.*/, "");
734
908
  return e && (r = i), /ttf|otf|eot|woff2?/i.test(r) && (r = r.replace(/.*\//, "")), t ? `[${t}]${r}` : r;
735
909
  }
736
- async function $(i, t, e) {
737
- const r = Zt(i, t, e.includeQueryParams);
910
+ async function B(i, t, e) {
911
+ const r = se(i, t, e.includeQueryParams);
738
912
  if (D[r] != null)
739
913
  return D[r];
740
914
  e.cacheBust && (i += (/\?/.test(i) ? "&" : "?") + (/* @__PURE__ */ new Date()).getTime());
741
915
  let s;
742
916
  try {
743
- const n = await st(i, e.fetchRequestInit, ({ res: o, result: a }) => (t || (t = o.headers.get("Content-Type") || ""), Jt(a)));
744
- 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);
745
919
  } catch (n) {
746
920
  s = e.imagePlaceholder || "";
747
921
  let o = `Failed to fetch resource: ${i}`;
@@ -749,65 +923,65 @@ async function $(i, t, e) {
749
923
  }
750
924
  return D[r] = s, s;
751
925
  }
752
- async function te(i) {
926
+ async function ne(i) {
753
927
  const t = i.toDataURL();
754
- return t === "data:," ? i.cloneNode(!1) : M(t);
928
+ return t === "data:," ? i.cloneNode(!1) : T(t);
755
929
  }
756
- async function ee(i, t) {
930
+ async function oe(i, t) {
757
931
  if (i.currentSrc) {
758
932
  const n = document.createElement("canvas"), o = n.getContext("2d");
759
933
  n.width = i.clientWidth, n.height = i.clientHeight, o?.drawImage(i, 0, 0, n.width, n.height);
760
934
  const a = n.toDataURL();
761
- return M(a);
935
+ return T(a);
762
936
  }
763
- const e = i.poster, r = I(e), s = await $(e, r, t);
764
- return M(s);
937
+ const e = i.poster, r = $(e), s = await B(e, r, t);
938
+ return T(s);
765
939
  }
766
- async function ie(i, t) {
940
+ async function ae(i, t) {
767
941
  var e;
768
942
  try {
769
943
  if (!((e = i?.contentDocument) === null || e === void 0) && e.body)
770
- return await T(i.contentDocument.body, t, !0);
944
+ return await L(i.contentDocument.body, t, !0);
771
945
  } catch {
772
946
  }
773
947
  return i.cloneNode(!1);
774
948
  }
775
- async function re(i, t) {
776
- 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));
777
951
  }
778
- const se = (i) => i.tagName != null && i.tagName.toUpperCase() === "SLOT", nt = (i) => i.tagName != null && i.tagName.toUpperCase() === "SVG";
779
- 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) {
780
954
  var r, s;
781
- if (nt(t))
955
+ if (lt(t))
782
956
  return t;
783
957
  let n = [];
784
- 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) => {
785
959
  l && t.appendChild(l);
786
960
  }), Promise.resolve()), t;
787
961
  }
788
- function oe(i, t, e) {
962
+ function he(i, t, e) {
789
963
  const r = t.style;
790
964
  if (!r)
791
965
  return;
792
966
  const s = window.getComputedStyle(i);
793
- 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) => {
794
968
  let o = s.getPropertyValue(n);
795
- 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));
796
970
  });
797
971
  }
798
- function ae(i, t) {
799
- 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);
800
974
  }
801
- function le(i, t) {
802
- if (d(i, HTMLSelectElement)) {
975
+ function me(i, t) {
976
+ if (u(i, HTMLSelectElement)) {
803
977
  const e = t, r = Array.from(e.children).find((s) => i.value === s.getAttribute("value"));
804
978
  r && r.setAttribute("selected", "");
805
979
  }
806
980
  }
807
- function ce(i, t, e) {
808
- 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;
809
983
  }
810
- async function de(i, t) {
984
+ async function fe(i, t) {
811
985
  const e = i.querySelectorAll ? i.querySelectorAll("use") : [];
812
986
  if (e.length === 0)
813
987
  return i;
@@ -816,7 +990,7 @@ async function de(i, t) {
816
990
  const a = e[n].getAttribute("xlink:href");
817
991
  if (a) {
818
992
  const l = i.querySelector(a), c = document.querySelector(a);
819
- !l && c && !r[a] && (r[a] = await T(c, t, !0));
993
+ !l && c && !r[a] && (r[a] = await L(c, t, !0));
820
994
  }
821
995
  }
822
996
  const s = Object.values(r);
@@ -831,31 +1005,31 @@ async function de(i, t) {
831
1005
  }
832
1006
  return i;
833
1007
  }
834
- async function T(i, t, e) {
835
- 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));
836
1010
  }
837
- const ot = /url\((['"]?)([^'"]+?)\1\)/g, he = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g, ue = /src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;
838
- 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) {
839
1013
  const t = i.replace(/([.*+?^${}()|\[\]\/\\])/g, "\\$1");
840
1014
  return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`, "g");
841
1015
  }
842
- function fe(i) {
1016
+ function we(i) {
843
1017
  const t = [];
844
- return i.replace(ot, (e, r, s) => (t.push(s), e)), t.filter((e) => !P(e));
1018
+ return i.replace(ct, (e, r, s) => (t.push(s), e)), t.filter((e) => !R(e));
845
1019
  }
846
- async function pe(i, t, e, r, s) {
1020
+ async function xe(i, t, e, r, s) {
847
1021
  try {
848
- const n = e ? Ot(t, e) : t, o = I(t);
1022
+ const n = e ? jt(t, e) : t, o = $(t);
849
1023
  let a;
850
- 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`);
851
1025
  } catch {
852
1026
  }
853
1027
  return i;
854
1028
  }
855
- function be(i, { preferredFontFormat: t }) {
856
- return t ? i.replace(ue, (e) => {
1029
+ function ve(i, { preferredFontFormat: t }) {
1030
+ return t ? i.replace(ge, (e) => {
857
1031
  for (; ; ) {
858
- const [r, , s] = he.exec(e) || [];
1032
+ const [r, , s] = be.exec(e) || [];
859
1033
  if (!s)
860
1034
  return "";
861
1035
  if (s === t)
@@ -863,32 +1037,32 @@ function be(i, { preferredFontFormat: t }) {
863
1037
  }
864
1038
  }) : i;
865
1039
  }
866
- function at(i) {
867
- return i.search(ot) !== -1;
1040
+ function dt(i) {
1041
+ return i.search(ct) !== -1;
868
1042
  }
869
- async function lt(i, t, e) {
870
- if (!at(i))
1043
+ async function ht(i, t, e) {
1044
+ if (!dt(i))
871
1045
  return i;
872
- const r = be(i, e);
873
- 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));
874
1048
  }
875
- async function x(i, t, e) {
1049
+ async function y(i, t, e) {
876
1050
  var r;
877
1051
  const s = (r = t.style) === null || r === void 0 ? void 0 : r.getPropertyValue(i);
878
1052
  if (s) {
879
- const n = await lt(s, null, e);
1053
+ const n = await ht(s, null, e);
880
1054
  return t.style.setProperty(i, n, t.style.getPropertyPriority(i)), !0;
881
1055
  }
882
1056
  return !1;
883
1057
  }
884
- async function ge(i, t) {
885
- 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);
886
1060
  }
887
- async function ye(i, t) {
888
- const e = d(i, HTMLImageElement);
889
- if (!(e && !P(i.src)) && !(d(i, SVGImageElement) && !P(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)))
890
1064
  return;
891
- 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);
892
1066
  await new Promise((n, o) => {
893
1067
  i.onload = n, i.onerror = t.onImageErrorHandler ? (...l) => {
894
1068
  try {
@@ -901,14 +1075,14 @@ async function ye(i, t) {
901
1075
  a.decode && (a.decode = n), a.loading === "lazy" && (a.loading = "eager"), e ? (i.srcset = "", i.src = s) : i.href.baseVal = s;
902
1076
  });
903
1077
  }
904
- async function xe(i, t) {
905
- 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));
906
1080
  await Promise.all(r).then(() => i);
907
1081
  }
908
- async function ct(i, t) {
909
- 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));
910
1084
  }
911
- function we(i, t) {
1085
+ function Ce(i, t) {
912
1086
  const { style: e } = i;
913
1087
  t.backgroundColor && (e.backgroundColor = t.backgroundColor), t.width && (e.width = `${t.width}px`), t.height && (e.height = `${t.height}px`);
914
1088
  const r = t.style;
@@ -916,23 +1090,23 @@ function we(i, t) {
916
1090
  e[s] = r[s];
917
1091
  }), i;
918
1092
  }
919
- const U = {};
920
- async function z(i) {
921
- let t = U[i];
1093
+ const N = {};
1094
+ async function W(i) {
1095
+ let t = N[i];
922
1096
  if (t != null)
923
1097
  return t;
924
1098
  const r = await (await fetch(i)).text();
925
- return t = { url: i, cssText: r }, U[i] = t, t;
1099
+ return t = { url: i, cssText: r }, N[i] = t, t;
926
1100
  }
927
- async function q(i, t) {
1101
+ async function V(i, t) {
928
1102
  let e = i.cssText;
929
1103
  const r = /url\(["']?([^"')]+)["']?\)/g, n = (e.match(/url\([^)]+\)/g) || []).map(async (o) => {
930
1104
  let a = o.replace(r, "$1");
931
- 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]));
932
1106
  });
933
1107
  return Promise.all(n).then(() => e);
934
1108
  }
935
- function W(i) {
1109
+ function Y(i) {
936
1110
  if (i == null)
937
1111
  return [];
938
1112
  const t = [], e = /(\/\*[\s\S]*?\*\/)/gi;
@@ -958,7 +1132,7 @@ function W(i) {
958
1132
  }
959
1133
  return t;
960
1134
  }
961
- async function ke(i, t) {
1135
+ async function _e(i, t) {
962
1136
  const e = [], r = [];
963
1137
  return i.forEach((s) => {
964
1138
  if ("cssRules" in s)
@@ -966,13 +1140,13 @@ async function ke(i, t) {
966
1140
  f(s.cssRules || []).forEach((n, o) => {
967
1141
  if (n.type === CSSRule.IMPORT_RULE) {
968
1142
  let a = o + 1;
969
- 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) => {
970
1144
  try {
971
- s.insertRule(m, m.startsWith("@import") ? a += 1 : s.cssRules.length);
972
- } catch (k) {
1145
+ s.insertRule(p, p.startsWith("@import") ? a += 1 : s.cssRules.length);
1146
+ } catch (x) {
973
1147
  console.error("Error inserting rule from remote css", {
974
- rule: m,
975
- error: k
1148
+ rule: p,
1149
+ error: x
976
1150
  });
977
1151
  }
978
1152
  })).catch((h) => {
@@ -983,7 +1157,7 @@ async function ke(i, t) {
983
1157
  });
984
1158
  } catch (n) {
985
1159
  const o = i.find((a) => a.href == null) || document.styleSheets[0];
986
- 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) => {
987
1161
  o.insertRule(l, o.cssRules.length);
988
1162
  })).catch((a) => {
989
1163
  console.error("Error loading remote stylesheet", a);
@@ -1000,114 +1174,131 @@ async function ke(i, t) {
1000
1174
  }
1001
1175
  }), e));
1002
1176
  }
1003
- function ve(i) {
1004
- 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")));
1005
1179
  }
1006
- async function Se(i, t) {
1180
+ async function Me(i, t) {
1007
1181
  if (i.ownerDocument == null)
1008
1182
  throw new Error("Provided element is not within a Document");
1009
- const e = f(i.ownerDocument.styleSheets), r = await ke(e, t);
1010
- return ve(r);
1183
+ const e = f(i.ownerDocument.styleSheets), r = await _e(e, t);
1184
+ return Te(r);
1011
1185
  }
1012
- function dt(i) {
1186
+ function mt(i) {
1013
1187
  return i.trim().replace(/["']/g, "");
1014
1188
  }
1015
- function Ee(i) {
1189
+ function Le(i) {
1016
1190
  const t = /* @__PURE__ */ new Set();
1017
1191
  function e(r) {
1018
1192
  (r.style.fontFamily || getComputedStyle(r).fontFamily).split(",").forEach((n) => {
1019
- t.add(dt(n));
1193
+ t.add(mt(n));
1020
1194
  }), Array.from(r.children).forEach((n) => {
1021
1195
  n instanceof HTMLElement && e(n);
1022
1196
  });
1023
1197
  }
1024
1198
  return e(i), t;
1025
1199
  }
1026
- async function Ce(i, t) {
1027
- const e = await Se(i, t), r = Ee(i);
1028
- 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) => {
1029
1203
  const o = n.parentStyleSheet ? n.parentStyleSheet.href : null;
1030
- return lt(n.cssText, o, t);
1204
+ return ht(n.cssText, o, t);
1031
1205
  }))).join(`
1032
1206
  `);
1033
1207
  }
1034
- async function _e(i, t) {
1035
- 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);
1036
1210
  if (e) {
1037
1211
  const r = document.createElement("style"), s = document.createTextNode(e);
1038
1212
  r.appendChild(s), i.firstChild ? i.insertBefore(r, i.firstChild) : i.appendChild(r);
1039
1213
  }
1040
1214
  }
1041
- async function Me(i, t = {}) {
1042
- const { width: e, height: r } = rt(i, t), s = await T(i, t, !0);
1043
- 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 Xt(s, e, r);
1044
1218
  }
1045
- async function Te(i, t = {}) {
1046
- 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 || Ut(), c = t.canvasWidth || e, h = t.canvasHeight || r;
1047
- 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;
1048
1222
  }
1049
- async function Le(i, t = {}) {
1050
- 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);
1051
1225
  }
1052
- async function Ae(i = []) {
1053
- const t = De(i);
1226
+ async function He(i = []) {
1054
1227
  try {
1055
- const e = await Le(document.body, {
1228
+ const t = await Ie(document.body, {
1056
1229
  quality: 0.85,
1057
1230
  pixelRatio: 1,
1058
1231
  backgroundColor: "#ffffff",
1059
- cacheBust: !0,
1232
+ skipFonts: !0,
1060
1233
  skipAutoScale: !1,
1061
- filter: (r) => !(r instanceof HTMLElement && r.id === "mtb-widget-host")
1234
+ filter: (e) => !(e instanceof HTMLElement && e.id === "mtb-widget-host")
1062
1235
  });
1063
- 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);
1064
1241
  } catch {
1065
1242
  return null;
1066
- } finally {
1067
- t?.remove();
1068
- }
1069
- }
1070
- function De(i) {
1071
- if (i.length === 0) return null;
1072
- const t = document.createElement("div");
1073
- 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;";
1074
- for (const [e, r] of i.entries())
1075
- r.type === "pin" ? t.appendChild(Pe(r, e + 1)) : r.type === "draw" && r.drawPath && t.appendChild(Re(r.drawPath));
1076
- return document.body.appendChild(t), t;
1077
- }
1078
- function Pe(i, t) {
1079
- const e = document.createElement("div");
1080
- return e.textContent = String(t), e.style.cssText = [
1081
- "position:fixed",
1082
- `left:${i.x}px`,
1083
- `top:${i.y}px`,
1084
- "width:22px",
1085
- "height:22px",
1086
- "border-radius:50% 50% 50% 2px",
1087
- "background:#059669",
1088
- "border:2px solid #fff",
1089
- "display:flex",
1090
- "align-items:center",
1091
- "justify-content:center",
1092
- 'font:700 10px -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif',
1093
- "color:#fff",
1094
- "box-shadow:0 2px 8px rgba(5,150,105,0.45)",
1095
- "transform:translate(-50%,-50%)"
1096
- ].join(";"), e;
1097
- }
1098
- function Re(i) {
1099
- const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1100
- 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;";
1101
- const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1102
- 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;
1103
- }
1104
- 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) {
1105
1296
  const [t, e] = i.split(","), r = t.match(/:(.*?);/)?.[1] ?? "image/png", s = atob(e), n = new Uint8Array(s.length);
1106
1297
  for (let o = 0; o < s.length; o++)
1107
1298
  n[o] = s.charCodeAt(o);
1108
1299
  return new Blob([n], { type: r });
1109
1300
  }
1110
- class $e {
1301
+ class qe {
1111
1302
  constructor() {
1112
1303
  this.listeners = /* @__PURE__ */ new Set(), this.originalOnError = null, this.installedOnError = null, this.rejectionHandler = null, this.hooked = !1;
1113
1304
  }
@@ -1129,20 +1320,20 @@ class $e {
1129
1320
  for (const e of this.listeners) e(t);
1130
1321
  }
1131
1322
  }
1132
- const ht = new $e(), He = 20;
1133
- class Oe {
1323
+ const F = new qe(), Ne = 20;
1324
+ class We {
1134
1325
  constructor() {
1135
1326
  this.errors = [], this.unsubscribe = null;
1136
1327
  }
1137
1328
  start() {
1138
- this.unsubscribe || (this.unsubscribe = ht.subscribe((t) => this.record(t)));
1329
+ this.unsubscribe || (this.unsubscribe = F.subscribe((t) => this.record(t)));
1139
1330
  }
1140
1331
  record(t) {
1141
1332
  const e = t.line != null ? ` (${t.line}:${t.col ?? 0})` : "";
1142
1333
  this.addError(`${t.message}${e}`);
1143
1334
  }
1144
1335
  addError(t) {
1145
- 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);
1146
1337
  }
1147
1338
  getErrors() {
1148
1339
  return [...this.errors];
@@ -1151,7 +1342,86 @@ class Oe {
1151
1342
  this.unsubscribe?.(), this.unsubscribe = null;
1152
1343
  }
1153
1344
  }
1154
- const Fe = 3, je = 1e3, Be = 3, Ue = 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 Ke = 3, Xe = 1e3, Ge = 3, Je = 5e3, Qe = 500, Ze = 500, ti = 300, ei = /* @__PURE__ */ new Set([
1155
1425
  "A",
1156
1426
  "BUTTON",
1157
1427
  "INPUT",
@@ -1160,7 +1430,7 @@ const Fe = 3, je = 1e3, Be = 3, Ue = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1160
1430
  "LABEL",
1161
1431
  "SUMMARY",
1162
1432
  "DETAILS"
1163
- ]), Ve = /* @__PURE__ */ new Set([
1433
+ ]), ii = /* @__PURE__ */ new Set([
1164
1434
  "button",
1165
1435
  "link",
1166
1436
  "checkbox",
@@ -1174,7 +1444,7 @@ const Fe = 3, je = 1e3, Be = 3, Ue = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1174
1444
  "listbox",
1175
1445
  "slider",
1176
1446
  "spinbutton"
1177
- ]), N = [
1447
+ ]), K = [
1178
1448
  "404",
1179
1449
  "500",
1180
1450
  "not found",
@@ -1186,7 +1456,7 @@ const Fe = 3, je = 1e3, Be = 3, Ue = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1186
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);
1187
1457
  }
1188
1458
  start() {
1189
- 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) => {
1190
1460
  this.errorCount++;
1191
1461
  }), this.startNavigationTracking(), this.startFormTracking(), this.checkErrorPage());
1192
1462
  }
@@ -1213,11 +1483,11 @@ const Fe = 3, je = 1e3, Be = 3, Ue = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1213
1483
  }
1214
1484
  handleClick(t) {
1215
1485
  const e = t.target;
1216
- if (!e || this.isWidgetElement(e)) return;
1486
+ if (!e || S(e)) return;
1217
1487
  const r = Date.now();
1218
1488
  this.clickHistory.push({ target: e, time: r });
1219
- const s = r - je;
1220
- if (this.clickHistory = this.clickHistory.filter((o) => o.time > s), this.clickHistory.filter((o) => o.target === e).length >= Fe) {
1489
+ const s = r - Xe;
1490
+ if (this.clickHistory = this.clickHistory.filter((o) => o.time > s), this.clickHistory.filter((o) => o.target === e).length >= Ke) {
1221
1491
  this.clickHistory = [], this.emitHighPriority({
1222
1492
  signal: "rage_click",
1223
1493
  target: w(e),
@@ -1234,27 +1504,27 @@ const Fe = 3, je = 1e3, Be = 3, Ue = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1234
1504
  handleNavigation() {
1235
1505
  const t = Date.now();
1236
1506
  this.navTimestamps.push(t);
1237
- const e = t - Ue;
1238
- this.navTimestamps = this.navTimestamps.filter((r) => r > e), this.navTimestamps.length >= Be && (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({
1239
1509
  signal: "rapid_navigation",
1240
1510
  timestamp: t
1241
1511
  })), setTimeout(() => {
1242
1512
  this.active && this.checkErrorPage();
1243
- }, We);
1513
+ }, ti);
1244
1514
  }
1245
1515
  handleFormSubmit(t) {
1246
1516
  const e = t.target;
1247
- e instanceof HTMLFormElement && (this.isWidgetElement(e) || setTimeout(() => {
1517
+ e instanceof HTMLFormElement && (S(e) || setTimeout(() => {
1248
1518
  this.active && e.querySelector('[aria-invalid="true"], .is-invalid') && this.emitIfReady({
1249
1519
  signal: "form_failure",
1250
1520
  target: w(e),
1251
1521
  timestamp: Date.now()
1252
1522
  });
1253
- }, ze));
1523
+ }, Qe));
1254
1524
  }
1255
1525
  handleFormInvalid(t) {
1256
1526
  const e = t.target;
1257
- if (!e || this.isWidgetElement(e)) return;
1527
+ if (!e || S(e)) return;
1258
1528
  const r = e.closest("form");
1259
1529
  this.emitIfReady({
1260
1530
  signal: "form_failure",
@@ -1266,7 +1536,7 @@ const Fe = 3, je = 1e3, Be = 3, Ue = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1266
1536
  const t = location.href;
1267
1537
  if (this.errorPageUrls.has(t)) return;
1268
1538
  const e = document.title.toLowerCase();
1269
- if (N.some((s) => e.includes(s))) {
1539
+ if (K.some((s) => e.includes(s))) {
1270
1540
  this.errorPageUrls.add(t), this.emitHighPriority({
1271
1541
  signal: "error_page",
1272
1542
  detail: document.title,
@@ -1279,7 +1549,7 @@ const Fe = 3, je = 1e3, Be = 3, Ue = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1279
1549
  );
1280
1550
  for (const s of r) {
1281
1551
  const n = s.textContent ?? "";
1282
- if (n.length < 200 && N.some((o) => n.toLowerCase().includes(o))) {
1552
+ if (n.length < 200 && K.some((o) => n.toLowerCase().includes(o))) {
1283
1553
  this.errorPageUrls.add(t), this.emitHighPriority({
1284
1554
  signal: "error_page",
1285
1555
  detail: n.trim().slice(0, 60),
@@ -1301,7 +1571,7 @@ const Fe = 3, je = 1e3, Be = 3, Ue = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1301
1571
  target: w(t),
1302
1572
  timestamp: e
1303
1573
  });
1304
- }, qe));
1574
+ }, Ze));
1305
1575
  }
1306
1576
  ensureDomObserver() {
1307
1577
  this.domObserver || (this.domObserver = new MutationObserver(() => {
@@ -1326,13 +1596,9 @@ const Fe = 3, je = 1e3, Be = 3, Ue = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1326
1596
  return !1;
1327
1597
  }
1328
1598
  isInteractive(t) {
1329
- if (Ne.has(t.tagName)) return !0;
1599
+ if (ei.has(t.tagName)) return !0;
1330
1600
  const e = t.getAttribute("role");
1331
- 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'));
1332
- }
1333
- isWidgetElement(t) {
1334
- const e = document.getElementById("mtb-widget-host");
1335
- 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'));
1336
1602
  }
1337
1603
  emitIfReady(t) {
1338
1604
  const e = Date.now();
@@ -1343,33 +1609,33 @@ const Fe = 3, je = 1e3, Be = 3, Ue = 5e3, ze = 500, qe = 500, We = 300, Ne = /*
1343
1609
  }
1344
1610
  };
1345
1611
  E.COOLDOWN_MS = 6e4;
1346
- let R = E;
1612
+ let I = E;
1347
1613
  function w(i) {
1348
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) ?? "";
1349
1615
  return `<${t}${e}${r}>${s ? ` "${s}"` : ""}`;
1350
1616
  }
1351
- function Ye() {
1617
+ function ri() {
1352
1618
  return {
1353
1619
  page_url: window.location.href,
1354
1620
  user_agent: navigator.userAgent,
1355
- browser: Xe(),
1356
- os: Ge(),
1621
+ browser: si(),
1622
+ os: ni(),
1357
1623
  screen_width: window.screen.width,
1358
1624
  screen_height: window.screen.height
1359
1625
  };
1360
1626
  }
1361
- function Xe() {
1627
+ function si() {
1362
1628
  const i = navigator.userAgent;
1363
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";
1364
1630
  }
1365
- function Ge() {
1631
+ function ni() {
1366
1632
  const i = navigator.userAgent;
1367
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";
1368
1634
  }
1369
- const Ke = "https://makethisbetter.dev/api/v1";
1370
- class Je {
1635
+ const oi = "https://makethisbetter.dev/api/v1";
1636
+ class ai {
1371
1637
  constructor(t, e, r = 1e3, s, n) {
1372
- 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;
1373
1639
  }
1374
1640
  async resolveUserToken() {
1375
1641
  return this.userTokenFn ? this.userTokenFn() : this.userToken;
@@ -1378,22 +1644,26 @@ class Je {
1378
1644
  const e = { "X-Project-Key": this.projectKey }, r = await this.resolveUserToken();
1379
1645
  return r && (e["X-User-Token"] = r), t && (e["Content-Type"] = t), e;
1380
1646
  }
1381
- async submitFeedback(t, e) {
1382
- const r = new FormData();
1383
- 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) {
1384
- const o = JSON.stringify(t.recording_events), a = new Blob([o], { type: "application/json" });
1385
- 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));
1386
1656
  }
1387
1657
  if (e) {
1388
- const o = e.type === "image/jpeg" ? "jpg" : "png";
1389
- r.append("feedback[screenshot]", e, `screenshot.${o}`);
1658
+ const l = e.type === "image/jpeg" ? "jpg" : "png";
1659
+ s.append("feedback[screenshot]", e, `screenshot.${l}`);
1390
1660
  }
1391
- const s = await this.authHeaders();
1392
- 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`, {
1393
1663
  method: "POST",
1394
- headers: s,
1395
- body: r
1396
- })).json();
1664
+ headers: n,
1665
+ body: s
1666
+ })).json()).submission_session, token: r };
1397
1667
  }
1398
1668
  async createIdentityToken(t) {
1399
1669
  const e = await this.authHeaders("application/json");
@@ -1420,39 +1690,51 @@ class Je {
1420
1690
  return !1;
1421
1691
  }
1422
1692
  }
1423
- async startClarification(t, e) {
1424
- const r = {};
1425
- e && (r.message = e);
1426
- const s = await this.authHeaders("application/json");
1427
- 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`, {
1428
1698
  method: "POST",
1429
- headers: s,
1430
- body: JSON.stringify(r)
1431
- })).json();
1699
+ headers: n,
1700
+ body: JSON.stringify(s)
1701
+ })).json()).clarification;
1432
1702
  }
1433
- async getClarification(t) {
1434
- const e = await this.authHeaders();
1435
- 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`, {
1436
1706
  method: "GET",
1437
- headers: e
1438
- })).json();
1707
+ headers: r
1708
+ })).json()).clarification;
1439
1709
  }
1440
1710
  // Streams a clarification turn over SSE. Calls onDelta for each token and
1441
1711
  // resolves with the committed result. Throws if the server doesn't stream
1442
1712
  // (e.g. old backend returns JSON) so the caller can fall back to polling.
1443
1713
  async streamClarification(t, e, r) {
1444
- const s = {};
1445
- e && (s.message = e);
1446
- const n = await this.authHeaders("application/json");
1447
- n.Accept = "text/event-stream";
1448
- 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`, {
1449
1717
  method: "POST",
1450
- headers: n,
1451
- body: JSON.stringify(s)
1452
- }), a = o.headers.get("Content-Type") ?? "";
1453
- 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"))
1454
1722
  throw new Error("clarify stream unavailable");
1455
- 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
+ });
1456
1738
  }
1457
1739
  async fetchWithRetry(t, e, r = 1) {
1458
1740
  let s;
@@ -1460,30 +1742,30 @@ class Je {
1460
1742
  s = await fetch(t, e);
1461
1743
  } catch (n) {
1462
1744
  if (r > 0)
1463
- return await V(this.retryDelayMs), this.fetchWithRetry(t, e, r - 1);
1745
+ return await X(this.retryDelayMs), this.fetchWithRetry(t, e, r - 1);
1464
1746
  throw n;
1465
1747
  }
1466
1748
  if (s.ok) return s;
1467
1749
  if (s.status >= 500 && r > 0)
1468
- return await V(this.retryDelayMs), this.fetchWithRetry(t, e, r - 1);
1750
+ return await X(this.retryDelayMs), this.fetchWithRetry(t, e, r - 1);
1469
1751
  throw new Error(`HTTP ${s.status}`);
1470
1752
  }
1471
1753
  }
1472
- function V(i) {
1754
+ function X(i) {
1473
1755
  return i <= 0 ? Promise.resolve() : new Promise((t) => setTimeout(t, i));
1474
1756
  }
1475
- async function Qe(i, t) {
1757
+ async function li(i, t) {
1476
1758
  const e = i.getReader(), r = new TextDecoder();
1477
1759
  let s = "", n = { messages: [], done: !0 };
1478
1760
  const o = (a) => {
1479
1761
  const l = a.split(`
1480
- `).find((k) => k.startsWith("event:")), c = a.split(`
1481
- `).find((k) => k.startsWith("data:"));
1762
+ `).find((x) => x.startsWith("event:")), c = a.split(`
1763
+ `).find((x) => x.startsWith("data:"));
1482
1764
  if (!c) return;
1483
- const h = l?.slice(6).trim(), m = JSON.parse(c.slice(5).trim());
1484
- h === "delta" && typeof m.text == "string" ? t(m.text) : h === "done" && (n = {
1485
- messages: Array.isArray(m.messages) ? m.messages : [],
1486
- 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
1487
1769
  });
1488
1770
  };
1489
1771
  for (; ; ) {
@@ -1504,10 +1786,16 @@ async function Qe(i, t) {
1504
1786
  }
1505
1787
  return n;
1506
1788
  }
1507
- function Ze() {
1789
+ function ci() {
1508
1790
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
1509
1791
  }
1510
- 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) {
1511
1799
  return {
1512
1800
  description: i,
1513
1801
  ...t,
@@ -1524,53 +1812,54 @@ function ti(i, t, e, r, s, n, o, a) {
1524
1812
  reporter_external_id: s ? void 0 : o,
1525
1813
  reporter_email: s ? void 0 : a,
1526
1814
  recording_events: n?.events,
1527
- recording_duration: n?.duration
1815
+ recording_duration: n?.duration,
1816
+ breadcrumbs: l
1528
1817
  };
1529
1818
  }
1530
- const Y = "mtb_anon_id", ut = "mtb_reporter_email", mt = "mtb_board_url";
1531
- let X = null, ft = null, pt = null;
1532
- 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() {
1533
1822
  try {
1534
- const i = window.localStorage.getItem(Y);
1823
+ const i = window.localStorage.getItem(G);
1535
1824
  if (i?.startsWith("anon_")) return i;
1536
- const t = Q();
1537
- return window.localStorage.setItem(Y, t), t;
1825
+ const t = et();
1826
+ return window.localStorage.setItem(G, t), t;
1538
1827
  } catch {
1539
- return X ?? (X = Q()), X;
1828
+ return J ?? (J = et()), J;
1540
1829
  }
1541
1830
  }
1542
- function K() {
1831
+ function Z() {
1543
1832
  try {
1544
- return window.localStorage.getItem(ut) ?? void 0;
1833
+ return window.localStorage.getItem(pt) ?? void 0;
1545
1834
  } catch {
1546
- return ft ?? void 0;
1835
+ return bt ?? void 0;
1547
1836
  }
1548
1837
  }
1549
- function ei(i) {
1550
- ft = i;
1838
+ function ui(i) {
1839
+ bt = i;
1551
1840
  try {
1552
- window.localStorage.setItem(ut, i);
1841
+ window.localStorage.setItem(pt, i);
1553
1842
  } catch {
1554
1843
  }
1555
1844
  }
1556
- function ii() {
1845
+ function mi() {
1557
1846
  try {
1558
- return window.localStorage.getItem(mt) ?? void 0;
1847
+ return window.localStorage.getItem(ft) ?? void 0;
1559
1848
  } catch {
1560
- return pt ?? void 0;
1849
+ return gt ?? void 0;
1561
1850
  }
1562
1851
  }
1563
- function J(i) {
1564
- pt = i;
1852
+ function tt(i) {
1853
+ gt = i;
1565
1854
  try {
1566
- window.localStorage.setItem(mt, i);
1855
+ window.localStorage.setItem(ft, i);
1567
1856
  } catch {
1568
1857
  }
1569
1858
  }
1570
- function Q() {
1859
+ function et() {
1571
1860
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? `anon_${crypto.randomUUID()}` : `anon_${`${Date.now().toString(16)}-${Math.random().toString(16).slice(2, 10)}`}`;
1572
1861
  }
1573
- const ri = {
1862
+ const pi = {
1574
1863
  tab: "Feedback",
1575
1864
  toolbar: {
1576
1865
  markup: "Mark up",
@@ -1586,17 +1875,16 @@ const ri = {
1586
1875
  cancel: "Cancel",
1587
1876
  my_feedback: "My feedback",
1588
1877
  quickOptions: [
1589
- { emoji: "🐛", label: "Something is broken" },
1590
- { emoji: "💡", label: "I wish this worked differently" },
1591
- { emoji: "🤔", label: "I don't understand this" },
1592
- { 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" }
1593
1881
  ]
1594
1882
  },
1595
1883
  success: {
1596
- title: "Thanks!",
1597
- message: "Your feedback has been received.",
1598
- title_no_ai: "Sent — thanks!",
1599
- 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.",
1600
1888
  view_feedback: "View my feedback",
1601
1889
  close: "Close",
1602
1890
  email_prompt: "Want updates? Leave your email and we'll let you know when it's resolved.",
@@ -1620,20 +1908,44 @@ const ri = {
1620
1908
  drawing: "Drawing",
1621
1909
  element: "element"
1622
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
+ },
1623
1918
  record: {
1624
1919
  stop: "Stop",
1625
1920
  timer_label: "Recording",
1626
- 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"
1627
1926
  },
1628
1927
  clarify: {
1629
1928
  title: "Make This Better AI",
1630
1929
  subtitle: "Sharpening your feedback",
1631
1930
  thinking: "Thinking...",
1632
- placeholder: "Type your answer — or Skip",
1931
+ placeholder: "Type your answer — or skip the question",
1633
1932
  send: "Send",
1634
- 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
+ }
1635
1947
  }
1636
- }, si = {
1948
+ }, fi = {
1637
1949
  tab: "反馈",
1638
1950
  toolbar: {
1639
1951
  markup: "标注",
@@ -1649,17 +1961,16 @@ const ri = {
1649
1961
  cancel: "取消",
1650
1962
  my_feedback: "我的反馈",
1651
1963
  quickOptions: [
1652
- { emoji: "🐛", label: "这里有问题" },
1653
- { emoji: "💡", label: "我希望它能更好用" },
1654
- { emoji: "🤔", label: "我看不懂这里" },
1655
- { emoji: "✨", label: "我有个想法" }
1964
+ { emoji: "🐛", label: "出问题了" },
1965
+ { emoji: "💡", label: "我有一个建议" },
1966
+ { emoji: "🤔", label: "我有点困惑" }
1656
1967
  ]
1657
1968
  },
1658
1969
  success: {
1659
- title: "感谢!",
1660
- message: "您的反馈已收到。",
1661
- title_no_ai: "已发送,感谢!",
1662
- message_no_ai: "我们会跟进处理,解决后会通知您。",
1970
+ title: "已发送,感谢!",
1971
+ message: "您的反馈和采集到的技术上下文正在发送给团队。问题解决后,您会收到通知。",
1972
+ title_no_ai: "感谢!我们已收到您的反馈。",
1973
+ message_no_ai: "接下来由团队处理。问题解决后,您会收到通知。",
1663
1974
  view_feedback: "查看我的反馈",
1664
1975
  close: "关闭",
1665
1976
  email_prompt: "想了解进展?留下邮箱,问题解决后我们会通知您。",
@@ -1683,20 +1994,44 @@ const ri = {
1683
1994
  drawing: "绘制",
1684
1995
  element: "元素"
1685
1996
  },
1997
+ draw: {
1998
+ note_placeholder: "给你的绘制添加说明",
1999
+ undo: "撤销",
2000
+ redo: "重做",
2001
+ cancel: "取消",
2002
+ submit: "提交"
2003
+ },
1686
2004
  record: {
1687
2005
  stop: "停止",
1688
2006
  timer_label: "录制中",
1689
- max_reached: "已达到最大录制时长"
2007
+ max_reached: "已达到最长录制时间",
2008
+ replay_label: "screen-recording.json",
2009
+ play: "播放录屏",
2010
+ close: "关闭",
2011
+ preview_unavailable: "暂无法预览"
1690
2012
  },
1691
2013
  clarify: {
1692
- title: "让它更好 AI",
2014
+ title: "Make This Better AI",
1693
2015
  subtitle: "正在完善你的反馈",
1694
2016
  thinking: "思考中...",
1695
- placeholder: "输入你的回答 —— 或跳过",
2017
+ placeholder: "输入回答,或跳过问题",
1696
2018
  send: "发送",
1697
- 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
+ }
1698
2033
  }
1699
- }, ni = {
2034
+ }, bi = {
1700
2035
  tab: "フィードバック",
1701
2036
  toolbar: {
1702
2037
  markup: "マークアップ",
@@ -1713,15 +2048,14 @@ const ri = {
1713
2048
  my_feedback: "自分のフィードバック",
1714
2049
  quickOptions: [
1715
2050
  { emoji: "🐛", label: "不具合があります" },
1716
- { emoji: "💡", label: "もっと使いやすくしてほしい" },
1717
- { emoji: "🤔", label: "ここがわかりにくい" },
1718
- { emoji: "✨", label: "アイデアがあります" }
2051
+ { emoji: "💡", label: "提案があります" },
2052
+ { emoji: "🤔", label: "わかりにくいです" }
1719
2053
  ]
1720
2054
  },
1721
2055
  success: {
1722
- title: "ありがとうございます!",
1723
- message: "フィードバックを受け付けました。",
1724
- title_no_ai: "送信しました!",
2056
+ title: "送信しました。ありがとうございます!",
2057
+ message: "ご意見と取得した技術情報をチームに送信しました。解決次第お知らせします。",
2058
+ title_no_ai: "ありがとうございます!フィードバックを受け付けました。",
1725
2059
  message_no_ai: "チームが対応します。解決次第お知らせします。",
1726
2060
  view_feedback: "フィードバックを確認",
1727
2061
  close: "閉じる",
@@ -1746,26 +2080,50 @@ const ri = {
1746
2080
  drawing: "描画",
1747
2081
  element: "要素"
1748
2082
  },
2083
+ draw: {
2084
+ note_placeholder: "描画にメモを追加",
2085
+ undo: "元に戻す",
2086
+ redo: "やり直す",
2087
+ cancel: "キャンセル",
2088
+ submit: "送信"
2089
+ },
1749
2090
  record: {
1750
2091
  stop: "停止",
1751
2092
  timer_label: "録画中",
1752
- max_reached: "最大録画時間に達しました"
2093
+ max_reached: "最大記録時間に達しました",
2094
+ replay_label: "screen-recording.json",
2095
+ play: "録画を再生",
2096
+ close: "閉じる",
2097
+ preview_unavailable: "プレビューは利用できません"
1753
2098
  },
1754
2099
  clarify: {
1755
2100
  title: "Make This Better AI",
1756
2101
  subtitle: "フィードバックを整えています",
1757
2102
  thinking: "考え中...",
1758
- placeholder: "回答を入力 — またはスキップ",
2103
+ placeholder: "回答を入力、または質問をスキップ",
1759
2104
  send: "送信",
1760
- 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
+ }
1761
2119
  }
1762
- }, oi = {
2120
+ }, gi = {
1763
2121
  tab: "피드백",
1764
2122
  toolbar: {
1765
2123
  markup: "마크업",
1766
2124
  record: "녹화",
1767
2125
  hint: "요소를 클릭하여 주석 · 드래그하여 그리기",
1768
- hintRecord: "화면을 녹화 중입니다",
2126
+ hintRecord: "화면 녹화 중",
1769
2127
  exit: "나가기"
1770
2128
  },
1771
2129
  popup: {
@@ -1775,17 +2133,16 @@ const ri = {
1775
2133
  cancel: "취소",
1776
2134
  my_feedback: "내 피드백",
1777
2135
  quickOptions: [
1778
- { emoji: "🐛", label: "오류가 있어요" },
1779
- { emoji: "💡", label: "이 기능을 개선해 주세요" },
1780
- { emoji: "🤔", label: "이 부분을 모르겠어요" },
1781
- { emoji: "✨", label: "아이디어가 있어요" }
2136
+ { emoji: "🐛", label: "문제가 있어요" },
2137
+ { emoji: "💡", label: "제안이 있어요" },
2138
+ { emoji: "🤔", label: "헷갈려요" }
1782
2139
  ]
1783
2140
  },
1784
2141
  success: {
1785
- title: "감사합니다!",
1786
- message: "피드백이 접수되었습니다.",
1787
- title_no_ai: "전송 완료!",
1788
- message_no_ai: "팀에서 처리 후 알려드리겠습니다.",
2142
+ title: "전송되었습니다. 감사합니다!",
2143
+ message: "피드백과 수집된 기술 정보가 팀에 전달되었습니다. 해결되면 알려드리겠습니다.",
2144
+ title_no_ai: "감사합니다! 피드백을 접수했습니다.",
2145
+ message_no_ai: "팀에서 처리합니다. 해결되면 알려드리겠습니다.",
1789
2146
  view_feedback: "내 피드백 보기",
1790
2147
  close: "닫기",
1791
2148
  email_prompt: "진행 상황이 궁금하신가요? 이메일을 남겨주시면 해결 시 알려드립니다.",
@@ -1809,26 +2166,50 @@ const ri = {
1809
2166
  drawing: "그리기",
1810
2167
  element: "요소"
1811
2168
  },
2169
+ draw: {
2170
+ note_placeholder: "그림에 메모 추가",
2171
+ undo: "실행 취소",
2172
+ redo: "다시 실행",
2173
+ cancel: "취소",
2174
+ submit: "보내기"
2175
+ },
1812
2176
  record: {
1813
2177
  stop: "중지",
1814
2178
  timer_label: "녹화 중",
1815
- max_reached: "최대 녹화 시간에 도달했습니다"
2179
+ max_reached: "최대 녹화 시간에 도달했습니다",
2180
+ replay_label: "screen-recording.json",
2181
+ play: "녹화 재생",
2182
+ close: "닫기",
2183
+ preview_unavailable: "미리보기를 사용할 수 없습니다"
1816
2184
  },
1817
2185
  clarify: {
1818
2186
  title: "Make This Better AI",
1819
2187
  subtitle: "피드백을 다듬는 중",
1820
2188
  thinking: "생각 중...",
1821
- placeholder: "답변 입력 — 또는 건너뛰기",
2189
+ placeholder: "답변을 입력하거나 질문을 건너뛰세요",
1822
2190
  send: "보내기",
1823
- 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
+ }
1824
2205
  }
1825
- }, ai = {
2206
+ }, yi = {
1826
2207
  tab: "Comentarios",
1827
2208
  toolbar: {
1828
2209
  markup: "Anotar",
1829
2210
  record: "Grabar",
1830
2211
  hint: "Haz clic en cualquier elemento para anotar · arrastra para dibujar",
1831
- hintRecord: "Grabando tu pantalla",
2212
+ hintRecord: "Grabando pantalla",
1832
2213
  exit: "Salir"
1833
2214
  },
1834
2215
  popup: {
@@ -1839,16 +2220,15 @@ const ri = {
1839
2220
  my_feedback: "Mis comentarios",
1840
2221
  quickOptions: [
1841
2222
  { emoji: "🐛", label: "Algo no funciona" },
1842
- { emoji: "💡", label: "Me gustaría que funcionara diferente" },
1843
- { emoji: "🤔", label: "No entiendo esto" },
1844
- { emoji: "✨", label: "Tengo una idea" }
2223
+ { emoji: "💡", label: "Tengo una sugerencia" },
2224
+ { emoji: "🤔", label: "Estoy confundido" }
1845
2225
  ]
1846
2226
  },
1847
2227
  success: {
1848
- title: "¡Gracias!",
1849
- message: "Tu comentario ha sido recibido.",
1850
- title_no_ai: "¡Enviado!",
1851
- 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.",
1852
2232
  view_feedback: "Ver mis comentarios",
1853
2233
  close: "Cerrar",
1854
2234
  email_prompt: "¿Quieres novedades? Deja tu correo y te avisaremos cuando se resuelva.",
@@ -1872,26 +2252,50 @@ const ri = {
1872
2252
  drawing: "Dibujo",
1873
2253
  element: "elemento"
1874
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
+ },
1875
2262
  record: {
1876
2263
  stop: "Detener",
1877
2264
  timer_label: "Grabando",
1878
- 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"
1879
2270
  },
1880
2271
  clarify: {
1881
2272
  title: "Make This Better AI",
1882
2273
  subtitle: "Afinando tus comentarios",
1883
2274
  thinking: "Pensando...",
1884
- placeholder: "Escribe tu respuesta — o Omitir",
2275
+ placeholder: "Escribe tu respuesta — u omite la pregunta",
1885
2276
  send: "Enviar",
1886
- 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
+ }
1887
2291
  }
1888
- }, li = {
2292
+ }, wi = {
1889
2293
  tab: "Avis",
1890
2294
  toolbar: {
1891
2295
  markup: "Annoter",
1892
2296
  record: "Enregistrer",
1893
2297
  hint: "Cliquez sur un élément pour l'annoter · glissez pour dessiner",
1894
- hintRecord: "Enregistrement de l'écran en cours",
2298
+ hintRecord: "Enregistrement de l'écran",
1895
2299
  exit: "Quitter"
1896
2300
  },
1897
2301
  popup: {
@@ -1902,16 +2306,15 @@ const ri = {
1902
2306
  my_feedback: "Mes avis",
1903
2307
  quickOptions: [
1904
2308
  { emoji: "🐛", label: "Quelque chose ne fonctionne pas" },
1905
- { emoji: "💡", label: "J'aimerais que cela fonctionne autrement" },
1906
- { emoji: "🤔", label: "Je ne comprends pas ceci" },
1907
- { emoji: "✨", label: "J'ai une idée" }
2309
+ { emoji: "💡", label: "J'ai une suggestion" },
2310
+ { emoji: "🤔", label: "Je suis perplexe" }
1908
2311
  ]
1909
2312
  },
1910
2313
  success: {
1911
- title: "Merci !",
1912
- message: "Votre avis a bien été reçu.",
1913
- title_no_ai: "Envoyé !",
1914
- 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.",
1915
2318
  view_feedback: "Voir mes avis",
1916
2319
  close: "Fermer",
1917
2320
  email_prompt: "Envie de suivre l'avancement ? Laissez votre e-mail et nous vous préviendrons une fois résolu.",
@@ -1935,26 +2338,50 @@ const ri = {
1935
2338
  drawing: "Dessin",
1936
2339
  element: "élément"
1937
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
+ },
1938
2348
  record: {
1939
2349
  stop: "Arrêter",
1940
2350
  timer_label: "Enregistrement",
1941
- 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"
1942
2356
  },
1943
2357
  clarify: {
1944
2358
  title: "Make This Better AI",
1945
2359
  subtitle: "Affinement de votre retour",
1946
2360
  thinking: "Réflexion...",
1947
- placeholder: "Saisissez votre réponse — ou Ignorer",
2361
+ placeholder: "Saisissez votre réponse — ou ignorez la question",
1948
2362
  send: "Envoyer",
1949
- 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
+ }
1950
2377
  }
1951
- }, ci = {
2378
+ }, xi = {
1952
2379
  tab: "Feedback",
1953
2380
  toolbar: {
1954
2381
  markup: "Markieren",
1955
2382
  record: "Aufnehmen",
1956
2383
  hint: "Klicken Sie auf ein Element zum Kommentieren · ziehen Sie zum Zeichnen",
1957
- hintRecord: "Bildschirmaufnahme läuft",
2384
+ hintRecord: "Bildschirm wird aufgenommen",
1958
2385
  exit: "Beenden"
1959
2386
  },
1960
2387
  popup: {
@@ -1965,16 +2392,15 @@ const ri = {
1965
2392
  my_feedback: "Mein Feedback",
1966
2393
  quickOptions: [
1967
2394
  { emoji: "🐛", label: "Etwas funktioniert nicht" },
1968
- { emoji: "💡", label: "Ich wünsche mir das anders" },
1969
- { emoji: "🤔", label: "Das verstehe ich nicht" },
1970
- { emoji: "✨", label: "Ich habe eine Idee" }
2395
+ { emoji: "💡", label: "Ich habe einen Vorschlag" },
2396
+ { emoji: "🤔", label: "Ich bin verwirrt" }
1971
2397
  ]
1972
2398
  },
1973
2399
  success: {
1974
- title: "Vielen Dank!",
1975
- message: "Ihr Feedback wurde empfangen.",
1976
- title_no_ai: "Gesendet!",
1977
- 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.",
1978
2404
  view_feedback: "Mein Feedback ansehen",
1979
2405
  close: "Schließen",
1980
2406
  email_prompt: "Updates gewünscht? Hinterlassen Sie Ihre E-Mail und wir melden uns, sobald es gelöst ist.",
@@ -1998,65 +2424,89 @@ const ri = {
1998
2424
  drawing: "Zeichnung",
1999
2425
  element: "Element"
2000
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
+ },
2001
2434
  record: {
2002
2435
  stop: "Stopp",
2003
2436
  timer_label: "Aufnahme",
2004
- 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"
2005
2442
  },
2006
2443
  clarify: {
2007
2444
  title: "Make This Better AI",
2008
2445
  subtitle: "Wir schärfen dein Feedback",
2009
2446
  thinking: "Einen Moment...",
2010
- placeholder: "Gib deine Antwort ein — oder Überspringen",
2447
+ placeholder: "Antwort eingeben — oder Frage überspringen",
2011
2448
  send: "Senden",
2012
- skip: "Überspringen"
2013
- }
2014
- }, S = {
2015
- en: ri,
2016
- "zh-CN": si,
2017
- ja: ni,
2018
- ko: oi,
2019
- es: ai,
2020
- fr: li,
2021
- 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
2022
2472
  };
2023
- function di(i) {
2024
- if (S[i]) return S[i];
2473
+ function vi(i) {
2474
+ if (k[i]) return k[i];
2025
2475
  const t = i.split("-")[0];
2026
- return S[t] ? S[t] : S.en;
2476
+ return k[t] ? k[t] : k.en;
2027
2477
  }
2028
- 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";
2029
2479
  let C = null;
2030
- function fi() {
2031
- return C || (C = pi().catch(() => bi()), C);
2480
+ function Ci() {
2481
+ return C || (C = _i().catch(() => Ti()), C);
2032
2482
  }
2033
- async function pi() {
2483
+ async function _i() {
2034
2484
  return (await import("@rrweb/record")).record;
2035
2485
  }
2036
- function Z() {
2486
+ function it() {
2037
2487
  const i = globalThis;
2038
2488
  return i.rrwebRecord?.record ?? i.rrweb?.record;
2039
2489
  }
2040
- function bi() {
2490
+ function Ti() {
2041
2491
  return new Promise((i, t) => {
2042
- const e = Z();
2492
+ const e = it();
2043
2493
  if (e) {
2044
2494
  i(e);
2045
2495
  return;
2046
2496
  }
2047
2497
  const r = document.createElement("script");
2048
- r.src = ui, r.integrity = mi, r.crossOrigin = "anonymous", r.onload = () => {
2049
- const s = Z();
2498
+ r.src = Si, r.integrity = Ei, r.crossOrigin = "anonymous", r.onload = () => {
2499
+ const s = it();
2050
2500
  s ? i(s) : t(new Error("rrweb record global not found after script load"));
2051
2501
  }, r.onerror = () => t(new Error("Failed to load rrweb from CDN")), document.head.appendChild(r);
2052
2502
  });
2053
2503
  }
2054
- class gi {
2504
+ class Mi {
2055
2505
  constructor(t, e) {
2056
2506
  this.events = [], this.stopFn = null, this.startedAt = 0, this.timer = null, this.clickHandler = null, this.stopped = !1, this.shadow = t, this.onMaxReached = e;
2057
2507
  }
2058
2508
  async start() {
2059
- const t = await fi();
2509
+ const t = await Ci();
2060
2510
  this.startedAt = Date.now(), this.stopped = !1, this.stopFn = t({
2061
2511
  emit: (e) => {
2062
2512
  this.stopped || this.events.push(e);
@@ -2069,7 +2519,7 @@ class gi {
2069
2519
  });
2070
2520
  }, document.addEventListener("click", this.clickHandler, !0), this.timer = setTimeout(() => {
2071
2521
  this.onMaxReached?.();
2072
- }, hi * 1e3);
2522
+ }, ki * 1e3);
2073
2523
  }
2074
2524
  stop() {
2075
2525
  return this.stopped = !0, this.stopFn?.(), this.stopFn = null, this.cleanupTimer(), this.cleanupClickHandler(), {
@@ -2078,7 +2528,7 @@ class gi {
2078
2528
  };
2079
2529
  }
2080
2530
  getDuration() {
2081
- 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));
2082
2532
  }
2083
2533
  destroy() {
2084
2534
  this.stopped = !0, this.stopFn?.(), this.stopFn = null, this.cleanupTimer(), this.cleanupClickHandler(), this.events = [], this.startedAt = 0;
@@ -2094,7 +2544,7 @@ class gi {
2094
2544
  r.style.left = `${t}px`, r.style.top = `${e}px`, this.shadow.append(r), r.addEventListener("animationend", () => r.remove());
2095
2545
  }
2096
2546
  }
2097
- class yi {
2547
+ class Li {
2098
2548
  constructor(t, e, r, s) {
2099
2549
  this.intervalId = null, this.getDuration = r, this.el = t.el("div", "mtb-record-bar"), this.el.innerHTML = `
2100
2550
  <span class="mtb-record-dot"></span>
@@ -2110,12 +2560,12 @@ class yi {
2110
2560
  this.intervalId && (clearInterval(this.intervalId), this.intervalId = null), this.el.remove();
2111
2561
  }
2112
2562
  }
2113
- class xi {
2563
+ class Pi {
2114
2564
  constructor() {
2115
2565
  this.session = null, this.bar = null, this.result = null;
2116
2566
  }
2117
2567
  async start(t, e, r) {
2118
- this.session = new gi(t, r), this.bar = new yi(
2568
+ this.session = new Mi(t, r), this.bar = new Li(
2119
2569
  t,
2120
2570
  e,
2121
2571
  () => this.session?.getDuration() ?? 0,
@@ -2135,12 +2585,28 @@ class xi {
2135
2585
  this.session?.destroy(), this.session = null, this.bar?.destroy(), this.bar = null;
2136
2586
  }
2137
2587
  }
2138
- class tt {
2588
+ class rt {
2139
2589
  constructor(t) {
2140
- 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 R(() => 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.handleKeydown = (e) => {
2591
+ if (e.key === "Escape")
2592
+ switch (this.mode) {
2593
+ case "annotating":
2594
+ case "popup":
2595
+ e.preventDefault(), e.stopPropagation(), this.exitAll();
2596
+ break;
2597
+ case "drawing":
2598
+ e.preventDefault(), e.stopPropagation(), this.cancelDraw();
2599
+ break;
2600
+ case "recording":
2601
+ e.preventDefault(), e.stopPropagation(), this.handleRecordStop();
2602
+ break;
2603
+ }
2604
+ }, this.handleRecordStop = () => {
2605
+ this.recordingManager && (this.recordingManager.stop(), this.via = "record", this.showPopup(window.innerWidth / 2, window.innerHeight / 2, this.messages.record.timer_label));
2606
+ }, 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()), document.addEventListener("keydown", this.handleKeydown, !0);
2141
2607
  }
2142
2608
  buildUI() {
2143
- this.shadow = new gt(this.config.theme ?? "auto"), this.tab = new yt(
2609
+ this.shadow = new wt(this.config.theme ?? "auto"), this.tab = new xt(
2144
2610
  this.shadow,
2145
2611
  this.messages,
2146
2612
  this.config.position ?? "right",
@@ -2152,7 +2618,7 @@ class tt {
2152
2618
  this.mode === "idle" ? (this.dismissFrustrationPrompt(), this.enterAnnotationMode()) : this.exitAll();
2153
2619
  }
2154
2620
  handleFrustration() {
2155
- this.mode !== "idle" || this.frustrationPrompt || (this.frustrationPrompt = new wt(this.shadow, this.messages, {
2621
+ this.mode !== "idle" || this.frustrationPrompt || (this.frustrationPrompt = new kt(this.shadow, this.messages, {
2156
2622
  onTell: () => {
2157
2623
  this.dismissFrustrationPrompt(), this.enterAnnotationMode();
2158
2624
  },
@@ -2163,26 +2629,65 @@ class tt {
2163
2629
  this.frustrationPrompt?.destroy(), this.frustrationPrompt = null;
2164
2630
  }
2165
2631
  enterAnnotationMode() {
2166
- this.mode = "annotating", this.tab?.setActive(!0), this.toolbar = new kt(
2632
+ this.mode = "annotating", this.tab?.setActive(!0), this.toolbar = new Et(
2167
2633
  this.shadow,
2168
2634
  this.messages,
2169
2635
  () => this.exitAll(),
2170
2636
  (t) => this.handleToolbarModeChange(t)
2171
- ), this.session = new H(this.shadow, this.messages, (t, e) => {
2172
- this.currentAnnotation = t, this.showPopup(t.x, t.y, e);
2637
+ ), this.session = this.createSession();
2638
+ }
2639
+ createSession() {
2640
+ return new Dt(this.shadow, this.messages, {
2641
+ onPin: (t, e) => {
2642
+ this.currentAnnotation = t, this.via = "pin", this.showPopup(t.x, t.y, e);
2643
+ },
2644
+ onDrawStroke: () => this.handleDrawStroke()
2173
2645
  });
2174
2646
  }
2175
2647
  handleToolbarModeChange(t) {
2176
- t === "record" ? (this.mode = "recording", this.session?.destroy(), this.session = null, this.recordingManager = new xi(), this.recordingManager.start(this.shadow, this.messages, () => {
2177
- this.recordingManager && (this.recordingManager.stop(), this.showPopup(window.innerWidth / 2, window.innerHeight / 2, this.messages.record.timer_label));
2178
- }).catch((e) => {
2179
- console.warn("[MakeThisBetter] Screen recording unavailable, falling back to markup:", e), this.mode === "recording" && (this.toolbar?.setMode("markup"), this.handleToolbarModeChange("markup"));
2180
- })) : (this.recordingManager?.destroy(), this.recordingManager = null, this.session || (this.session = new H(this.shadow, this.messages, (e, r) => {
2181
- this.currentAnnotation = e, this.showPopup(e.x, e.y, r);
2182
- })), this.mode = "annotating");
2648
+ if (this.mode === "clarifying") {
2649
+ this.toolbar?.setMode(this.via === "record" ? "record" : "markup");
2650
+ return;
2651
+ }
2652
+ if (t === "record") {
2653
+ if (this.mode === "recording") return;
2654
+ 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, this.handleRecordStop).catch((e) => {
2655
+ console.warn("[MakeThisBetter] Interaction replay unavailable, falling back to markup:", e), this.mode === "recording" && (this.toolbar?.setMode("markup"), this.handleToolbarModeChange("markup"));
2656
+ });
2657
+ } else
2658
+ this.recordingManager?.destroy(), this.recordingManager = null, this.teardownDraw(), this.session || (this.session = this.createSession()), this.mode = "annotating";
2659
+ }
2660
+ handleDrawStroke() {
2661
+ this.mode !== "drawing" && (this.mode = "drawing", this.drawBar = new It(this.shadow, {
2662
+ messages: this.messages,
2663
+ onUndo: () => this.handleDrawUndoRedo("undo"),
2664
+ onRedo: () => this.handleDrawUndoRedo("redo"),
2665
+ onCancel: () => this.cancelDraw(),
2666
+ onSubmit: (t) => this.handleDrawSubmit(t)
2667
+ })), this.refreshDrawBar();
2668
+ }
2669
+ handleDrawUndoRedo(t) {
2670
+ t === "undo" ? this.session?.undoDraw() : this.session?.redoDraw(), this.refreshDrawBar();
2671
+ }
2672
+ refreshDrawBar() {
2673
+ this.session && this.drawBar?.setUndoRedo(this.session.canUndoDraw(), this.session.canRedoDraw());
2674
+ }
2675
+ cancelDraw() {
2676
+ this.session?.clearDraw(), this.teardownDraw(), this.mode = "annotating";
2677
+ }
2678
+ teardownDraw() {
2679
+ this.drawBar?.destroy(), this.drawBar = null;
2680
+ }
2681
+ handleDrawSubmit(t) {
2682
+ const e = this.session?.getDrawAnnotation();
2683
+ if (!e) {
2684
+ this.cancelDraw();
2685
+ return;
2686
+ }
2687
+ this.currentAnnotation = e, this.via = "draw", this.session?.dismissInteraction(), this.submittingUi = this.drawBar, this.handleSubmit(t || this.messages.annotation.drawing);
2183
2688
  }
2184
2689
  showPopup(t, e, r) {
2185
- this.mode = "popup", this.lastPopupPos = { x: t, y: e }, this.session?.dismissInteraction(), this.popup = new Lt(this.shadow, {
2690
+ 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()), this.popup = new Ht(this.shadow, {
2186
2691
  targetName: r,
2187
2692
  x: t,
2188
2693
  y: e,
@@ -2190,62 +2695,93 @@ class tt {
2190
2695
  onSubmit: (s) => this.handleSubmit(s),
2191
2696
  onClose: () => this.exitAll(),
2192
2697
  onMyFeedback: this.buildMyFeedbackHandler()
2193
- });
2698
+ }), this.submittingUi = this.popup;
2194
2699
  }
2195
2700
  buildMyFeedbackHandler() {
2196
- if (!this.config.user && ii())
2701
+ if (!this.config.user && mi())
2197
2702
  return async () => {
2198
- const t = await this.apiClient.createIdentityToken(G());
2199
- !t?.identity_token || !t.board_url || (J(t.board_url), window.open(`${t.board_url}?identity=${encodeURIComponent(t.identity_token)}`, "_blank"));
2703
+ const t = await this.apiClient.createIdentityToken(Q());
2704
+ !t?.identity_token || !t.board_url || (tt(t.board_url), window.open(`${t.board_url}?identity=${encodeURIComponent(t.identity_token)}`, "_blank"));
2200
2705
  };
2201
2706
  }
2202
2707
  async handleSubmit(t) {
2203
- if (!this.popup) return;
2204
- this.popup.setLoading(!0), await new Promise((a) => requestAnimationFrame(() => setTimeout(a, 0)));
2205
- const e = this.currentAnnotation, r = this.recordingManager?.getRecording() ?? void 0, [s, n] = await Promise.all([
2206
- Ae(e ? [e] : []),
2207
- Promise.resolve(Ye())
2208
- ]), o = ti(
2708
+ const e = this.submittingUi;
2709
+ if (!e) return;
2710
+ const r = ++this.submissionAttempt;
2711
+ e.setLoading(!0), await Ai();
2712
+ const s = this.currentAnnotation, n = this.recordingManager?.getRecording() ?? void 0, [o, a] = await Promise.all([
2713
+ He(s ? [s] : []),
2714
+ Promise.resolve(ri())
2715
+ ]), l = hi(
2209
2716
  t,
2210
- n,
2717
+ a,
2211
2718
  this.consoleCollector.getErrors(),
2212
- e,
2719
+ s,
2213
2720
  this.config.user,
2214
- r,
2215
- this.config.user ? void 0 : G(),
2216
- this.config.user ? void 0 : K()
2721
+ n,
2722
+ this.config.user ? void 0 : Q(),
2723
+ this.config.user ? void 0 : Z(),
2724
+ this.breadcrumbCollector.getBreadcrumbs()
2217
2725
  );
2218
2726
  try {
2219
- const a = await this.apiClient.submitFeedback(o, s);
2220
- 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);
2727
+ const c = await this.apiClient.createSubmissionSession(l, o);
2728
+ if (r !== this.submissionAttempt) {
2729
+ await this.apiClient.abandonSubmissionSession(c.id, c.token).catch(() => {
2730
+ });
2731
+ return;
2732
+ }
2733
+ this.activeSubmission = c;
2734
+ const h = this.buildSummaryContext(t, a, s);
2735
+ 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);
2221
2736
  } catch {
2222
- this.popup?.setLoading(!1), this.popup?.setError(this.messages.error.submit);
2737
+ if (r !== this.submissionAttempt) return;
2738
+ e.setLoading(!1), e.setError(this.messages.error.submit);
2223
2739
  }
2224
2740
  }
2225
- showClarify(t, e) {
2226
- this.mode = "clarifying", this.tab?.setActive(!0), this.clarify = new Rt(this.shadow, {
2227
- feedbackId: t,
2741
+ buildSummaryContext(t, e, r) {
2742
+ const s = this.messages.clarify.summary;
2743
+ return {
2744
+ originalDescription: t,
2745
+ element: r?.targetName ?? this.messages.annotation.element,
2746
+ page: e.page_url,
2747
+ browser: `${e.browser} · ${e.os}`,
2748
+ captured: this.via === "record" ? s.recording : s.screenshot
2749
+ };
2750
+ }
2751
+ showClarify(t, e, r) {
2752
+ this.mode = "clarifying", this.tab?.setActive(!0), this.clarify = new Ft(this.shadow, {
2753
+ submissionSessionId: t.id,
2754
+ submissionToken: t.token,
2228
2755
  apiClient: this.apiClient,
2229
2756
  messages: this.messages,
2757
+ summary: r,
2230
2758
  x: e?.x,
2231
2759
  y: e?.y,
2232
- onDone: () => {
2233
- this.clarify?.destroy(), this.clarify = null, this.showSuccess();
2234
- }
2760
+ onFinalize: () => this.finalizeSubmission()
2235
2761
  });
2236
2762
  }
2763
+ async finalizeSubmission() {
2764
+ const t = this.activeSubmission;
2765
+ if (!t) throw new Error("No active submission session");
2766
+ const e = this.submissionAttempt, r = await this.apiClient.finalizeSubmissionSession(t.id, t.token);
2767
+ e !== this.submissionAttempt || this.activeSubmission !== t || (this.activeSubmission = null, this.lastHandoff = {
2768
+ feedbackId: r.id,
2769
+ boardUrl: r.board_url,
2770
+ identityToken: r.identity_token
2771
+ }, 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 }));
2772
+ }
2237
2773
  showSuccess(t) {
2238
- this.mode = "idle", this.tab?.setActive(!1), this.success = new Ht(this.shadow, this.messages, () => {
2774
+ this.mode = "idle", this.tab?.setActive(!1), this.success = new Ut(this.shadow, this.messages, () => {
2239
2775
  this.success?.destroy(), this.success = null;
2240
2776
  }, this.buildViewFeedbackHandler(), { ...t, emailCapture: this.buildEmailCapture() });
2241
2777
  }
2242
2778
  buildEmailCapture() {
2243
2779
  const { feedbackId: t, identityToken: e } = this.lastHandoff;
2244
- if (!(!t || !e) && !K())
2780
+ if (!(!t || !e) && !Z())
2245
2781
  return {
2246
2782
  onSubmit: async (r) => {
2247
2783
  const s = await this.apiClient.updateReporter(t, r, e);
2248
- return s && ei(r), s;
2784
+ return s && ui(r), s;
2249
2785
  }
2250
2786
  };
2251
2787
  }
@@ -2264,25 +2800,31 @@ class tt {
2264
2800
  }
2265
2801
  }
2266
2802
  exitAll() {
2267
- 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;
2803
+ this.submissionAttempt += 1;
2804
+ const t = this.activeSubmission;
2805
+ this.activeSubmission = null, t && this.apiClient.abandonSubmissionSession(t.id, t.token).catch(() => {
2806
+ }), 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;
2268
2807
  }
2269
2808
  destroy() {
2270
- 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();
2809
+ document.removeEventListener("keydown", this.handleKeydown, !0), 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();
2271
2810
  }
2272
2811
  }
2273
- let g = null;
2274
- const wi = {
2812
+ function Ai() {
2813
+ return new Promise((i) => requestAnimationFrame(() => setTimeout(i, 0)));
2814
+ }
2815
+ let b = null;
2816
+ const Di = {
2275
2817
  init(i) {
2276
- g && (g.destroy(), g = null), document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", () => {
2277
- g = new tt(i);
2278
- }) : g = new tt(i);
2818
+ b && (b.destroy(), b = null), document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", () => {
2819
+ b = new rt(i);
2820
+ }) : b = new rt(i);
2279
2821
  },
2280
2822
  destroy() {
2281
- g?.destroy(), g = null;
2823
+ b?.destroy(), b = null;
2282
2824
  }
2283
2825
  };
2284
- typeof window < "u" && (window.MakeThisBetter = wi);
2826
+ typeof window < "u" && (window.MakeThisBetter = Di);
2285
2827
  export {
2286
- wi as MakeThisBetter
2828
+ Di as MakeThisBetter
2287
2829
  };
2288
2830
  //# sourceMappingURL=makethisbetter.esm.js.map