makethisbetter 1.19.2 → 1.19.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,40 +1,40 @@
1
- "use strict";var Ae=Object.create;var yt=Object.defineProperty;var Le=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var Me=Object.getPrototypeOf,Re=Object.prototype.hasOwnProperty;var Ie=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Pe(t))!Re.call(i,n)&&n!==e&&yt(i,n,{get:()=>t[n],enumerable:!(r=Le(t,n))||r.enumerable});return i};var De=(i,t,e)=>(e=i!=null?Ae(Me(i)):{},Ie(t||!i||!i.__esModule?yt(e,"default",{value:i,enumerable:!0}):e,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const He=`*,*: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{--mtb-panel-bg: #fff;--mtb-panel-border: rgba(0, 0, 0, .1);--mtb-panel-divider: rgba(0, 0, 0, .06);--mtb-fg: #191a1c;--mtb-field-bg: #fff;--mtb-field-bg-subtle: #fafafa;--mtb-field-border: rgba(0, 0, 0, .12);--mtb-field-border-soft: rgba(0, 0, 0, .09);--mtb-placeholder-fg: rgba(0, 0, 0, .34);--mtb-action-bg: #fff;--mtb-action-border: rgba(0, 0, 0, .12);--mtb-action-fg: rgba(0, 0, 0, .55);--mtb-action-hover-bg: rgba(0, 0, 0, .04);--mtb-popup-close-fg: rgba(0, 0, 0, .38);--mtb-success-msg-fg: rgba(0, 0, 0, .45);--mtb-close-link-fg: rgba(0, 0, 0, .4);--mtb-clarify-subtitle-fg: rgba(0, 0, 0, .42);--mtb-clarify-close-fg: rgba(0, 0, 0, .38);--mtb-clarify-close-hover-fg: rgba(0, 0, 0, .7);--mtb-dismiss-fg: rgba(0, 0, 0, .4);--mtb-dismiss-hover-fg: rgba(0, 0, 0, .7);--mtb-quick-hover-bg: rgba(16, 185, 129, .06);--mtb-quick-hover-border: rgba(16, 185, 129, .3);--mtb-quick-selected-bg: rgba(16, 185, 129, .1);--mtb-quick-selected-border: rgba(16, 185, 129, .5);--mtb-field-focus-border: #10b981;--mtb-clarify-input-focus-bg: #fff;--mtb-popup-close-hover-fg: rgba(0, 0, 0, .7);--mtb-close-link-hover-fg: rgba(0, 0, 0, .7)}:host([data-mtb-theme="dark"]){--mtb-panel-bg: #151719;--mtb-panel-border: rgba(255, 255, 255, .12);--mtb-panel-divider: rgba(255, 255, 255, .1);--mtb-fg: #f9fafb;--mtb-field-bg: #1f2327;--mtb-field-bg-subtle: #1f2327;--mtb-field-border: rgba(255, 255, 255, .12);--mtb-field-border-soft: rgba(255, 255, 255, .12);--mtb-placeholder-fg: rgba(255, 255, 255, .4);--mtb-action-bg: #1f2327;--mtb-action-border: rgba(255, 255, 255, .14);--mtb-action-fg: rgba(255, 255, 255, .7);--mtb-action-hover-bg: rgba(255, 255, 255, .06);--mtb-popup-close-fg: rgba(255, 255, 255, .68);--mtb-success-msg-fg: rgba(255, 255, 255, .55);--mtb-close-link-fg: rgba(255, 255, 255, .68);--mtb-clarify-subtitle-fg: rgba(255, 255, 255, .45);--mtb-clarify-close-fg: rgba(255, 255, 255, .45);--mtb-clarify-close-hover-fg: rgba(255, 255, 255, .75);--mtb-dismiss-fg: rgba(255, 255, 255, .4);--mtb-dismiss-hover-fg: rgba(255, 255, 255, .7);--mtb-quick-hover-bg: #1f2327;--mtb-quick-hover-border: rgba(255, 255, 255, .12);--mtb-quick-selected-bg: #1f2327;--mtb-quick-selected-border: rgba(255, 255, 255, .12);--mtb-field-focus-border: rgba(255, 255, 255, .12);--mtb-clarify-input-focus-bg: #1f2327;--mtb-popup-close-hover-fg: rgba(255, 255, 255, .68);--mtb-close-link-hover-fg: rgba(255, 255, 255, .68)}@media (prefers-color-scheme: dark){:host([data-mtb-theme="auto"]){--mtb-panel-bg: #151719;--mtb-panel-border: rgba(255, 255, 255, .12);--mtb-panel-divider: rgba(255, 255, 255, .1);--mtb-fg: #f9fafb;--mtb-field-bg: #1f2327;--mtb-field-bg-subtle: #1f2327;--mtb-field-border: rgba(255, 255, 255, .12);--mtb-field-border-soft: rgba(255, 255, 255, .12);--mtb-placeholder-fg: rgba(255, 255, 255, .4);--mtb-action-bg: #1f2327;--mtb-action-border: rgba(255, 255, 255, .14);--mtb-action-fg: rgba(255, 255, 255, .7);--mtb-action-hover-bg: rgba(255, 255, 255, .06);--mtb-popup-close-fg: rgba(255, 255, 255, .68);--mtb-success-msg-fg: rgba(255, 255, 255, .55);--mtb-close-link-fg: rgba(255, 255, 255, .68);--mtb-clarify-subtitle-fg: rgba(255, 255, 255, .45);--mtb-clarify-close-fg: rgba(255, 255, 255, .45);--mtb-clarify-close-hover-fg: rgba(255, 255, 255, .75);--mtb-dismiss-fg: rgba(255, 255, 255, .4);--mtb-dismiss-hover-fg: rgba(255, 255, 255, .7);--mtb-quick-hover-bg: #1f2327;--mtb-quick-hover-border: rgba(255, 255, 255, .12);--mtb-quick-selected-bg: #1f2327;--mtb-quick-selected-border: rgba(255, 255, 255, .12);--mtb-field-focus-border: rgba(255, 255, 255, .12);--mtb-clarify-input-focus-bg: #1f2327;--mtb-popup-close-hover-fg: rgba(255, 255, 255, .68);--mtb-close-link-hover-fg: rgba(255, 255, 255, .68)}}.mtb-tab{--mtb-tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Ccircle cx='12' cy='12' r='2.4' fill='%23000' stroke='none'/%3E%3Cpath d='M12 1.8v3.4M12 18.8v3.4M1.8 12h3.4M18.8 12h3.4'/%3E%3C/svg%3E");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-hint-bar{position:fixed;top:18px;left:50%;transform:translate(-50%);z-index:2147483647;display:flex;align-items:center;height:38px;padding:0 16px;border-radius:13px;background:linear-gradient(120deg,#10b981,#059669);box-shadow:0 10px 26px #0f172a38;animation:mtbHintIn .2s ease;white-space:nowrap;transition:opacity .15s ease;pointer-events:none}.mtb-hint-bar--under-pointer{opacity:.3}.mtb-hint-bar.mtb-hint-bar--dismissed{display:none}@keyframes mtbHintIn{0%{transform:translate(-50%,12px);opacity:0}to{transform:translate(-50%);opacity:1}}.mtb-toolbar{position:fixed;top:50%;right:8px;transform:translateY(-50%);z-index:2147483647;display:flex;flex-direction:column;align-items:center;gap:6px;width:38px;padding:6px 0;max-height:calc(100vh - 24px);border-radius:19px;background:linear-gradient(160deg,#10b981,#059669);box-shadow:0 8px 22px #0f172a33;animation:mtbEdgeBarIn .2s ease;white-space:nowrap;pointer-events:none}.mtb-toolbar.left{right:auto;left:8px;animation:mtbEdgeBarInLeft .2s ease}@keyframes mtbBarIn{0%{transform:translate(-50%,12px);opacity:0}to{transform:translate(-50%);opacity:1}}@keyframes mtbEdgeBarIn{0%{transform:translate(12px,-50%);opacity:0}to{transform:translateY(-50%);opacity:1}}@keyframes mtbEdgeBarInLeft{0%{transform:translate(-12px,-50%);opacity:0}to{transform:translateY(-50%);opacity:1}}.mtb-toolbar-label{display:none}:host([data-mtb-toolbar]) .mtb-tab{display:none}.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:20px;height:1px;align-self:center;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-toolbar-modes{flex-direction:column;gap:6px;padding:0;background:none;border-radius:0}.mtb-toolbar-mode-btn,.mtb-exit-btn{pointer-events:auto;display:flex;align-items:center;justify-content:center;gap:0;width:30px;height:30px;padding:0;border-radius:50%;background:none;color:#ffffffb8}.mtb-toolbar-mode-btn:hover,.mtb-exit-btn:hover{background:#ffffff29;color:#fff}.mtb-toolbar-mode-btn.active,.mtb-toolbar-mode-btn.active:hover{background:#fff;color:#047857}.mtb-exit-btn{color:#fff}.mtb-toolbar-sep{width:16px;height:1px;margin:1px 0;align-self:center;background:#ffffff47}.mtb-exit-btn:hover{background:#ffffff47}.mtb-overlay{position:fixed;inset:0;z-index:2147483640;cursor:crosshair;touch-action:none}.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.selected{border-color:#2563eb;background:#2563eb0a}.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:min(320px,calc(100vw - 56px));background:var(--mtb-panel-bg);border:1px solid var(--mtb-panel-border);border-radius:16px;color:var(--mtb-fg);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 var(--mtb-panel-divider);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:var(--mtb-fg)}.mtb-popup-close{background:none;border:none;cursor:pointer;padding:3px;color:var(--mtb-popup-close-fg);display:flex;align-items:center;border-radius:4px;transition:color .12s}.mtb-popup-close:hover{color:var(--mtb-popup-close-hover-fg)}.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 var(--mtb-field-border-soft);border-radius:10px;background:var(--mtb-field-bg-subtle);cursor:pointer;font-family:inherit;font-size:13px;color:var(--mtb-fg);text-align:left;transition:all .12s}.mtb-quick-option:hover{background:var(--mtb-quick-hover-bg);border-color:var(--mtb-quick-hover-border)}.mtb-quick-option.selected{background:var(--mtb-quick-selected-bg);border-color:var(--mtb-quick-selected-border)}.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 var(--mtb-field-border);border-radius:10px;font-family:inherit;font-size:12.5px;line-height:1.5;color:var(--mtb-fg);outline:none;background:var(--mtb-field-bg);resize:none;transition:border-color .12s,box-shadow .12s}.mtb-textarea:focus{border-color:var(--mtb-field-focus-border);box-shadow:0 0 0 3px #10b98126}.mtb-textarea::placeholder{color:var(--mtb-placeholder-fg)}.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:1px solid transparent;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:#fff;border-color:#0000001f;color:#191a1c}.mtb-cancel-btn:hover{background:#fafafa}.mtb-submit-btn{background:#f7f7f8;border-color:#0000001a;color:#00000059}.mtb-submit-btn.ready{background:#059669;border-color:#059669;color:#fff}.mtb-submit-btn.ready:hover{background:#047857;border-color:#047857}.mtb-submit-btn:disabled{cursor:not-allowed}.mtb-success{position:fixed;z-index:2147483645;width:332px;background:var(--mtb-panel-bg);border:1px solid var(--mtb-panel-border);border-radius:16px;color:var(--mtb-fg);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:var(--mtb-fg)}.mtb-success-msg{font-size:12px;color:var(--mtb-success-msg-fg);margin-bottom:14px;line-height:1.5}.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:inherit;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:11px;color:var(--mtb-close-link-fg);font-family:inherit;transition:color .12s}.mtb-close-link:hover{color:var(--mtb-close-link-hover-fg)}.mtb-email-capture{margin-bottom:14px;text-align:left}.mtb-email-prompt{font-size:12px;color:var(--mtb-success-msg-fg);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:var(--mtb-panel-bg);border:1px solid var(--mtb-panel-border);border-radius:12px;color:var(--mtb-fg);box-shadow:0 8px 30px #0000001f;animation:mtbSlideUp .35s cubic-bezier(.34,1.56,.64,1);font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif}.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:var(--mtb-dismiss-fg);cursor:pointer;font-family:inherit;font-size:12px;transition:color .12s}.mtb-frustration-dismiss:hover{color:var(--mtb-dismiss-hover-fg)}.mtb-record-bar{position:fixed;bottom:48px;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:#dc2626;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:min(346px,calc(100vw - 56px));min-height:min(270px,calc(100vh - 24px));background:var(--mtb-panel-bg);border:1px solid var(--mtb-panel-border);border-radius:16px;color:var(--mtb-fg);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-continuation{width:min(320px,calc(100vw - 56px));animation:none}.mtb-clarify-header{padding:8px 10px;display:flex;align-items:center;gap:7px;border-bottom:1px solid var(--mtb-panel-divider)}.mtb-clarify-icon{width:20px;height:20px;border-radius:6px;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:12px;font-weight:650;line-height:1.2;color:var(--mtb-fg)}.mtb-clarify-subtitle{font-size:9.5px;color:var(--mtb-clarify-subtitle-fg)}.mtb-clarify-close{background:none;border:none;cursor:pointer;padding:3px;color:var(--mtb-clarify-close-fg);display:flex;transition:color .12s}.mtb-clarify-close:hover{color:var(--mtb-clarify-close-hover-fg)}.mtb-clarify-messages{flex:1;overflow-y:auto;padding:8px 10px 4px;display:flex;flex-direction:column;gap:6px}.mtb-clarify-bubble{max-width:82%;padding:6px 10px;font-size:12px;line-height:1.4;white-space:pre-wrap;word-break:break-word}.mtb-clarify-ai{align-self:flex-start;background:var(--mtb-field-bg);color:var(--mtb-fg);border:1px solid var(--mtb-field-border-soft);border-radius:11px 11px 11px 3px}.mtb-clarify-user{align-self:flex-end;background:#059669;color:#fff;border:1px solid #059669;border-radius:11px 11px 3px}.mtb-clarify-thinking{display:flex;align-items:center;gap:4px;padding:8px 12px}.mtb-clarify-thinking .mtb-dot{width:6px;height:6px;background:#059669b3}.mtb-clarify-footer{padding:3px 10px 10px;display:flex;flex-direction:column}.mtb-clarify-input{width:100%;height:40px;padding:7px 10px;border:1px solid var(--mtb-field-border);border-radius:8px;font-family:inherit;font-size:12px;line-height:1.4;color:var(--mtb-fg);outline:none;background:var(--mtb-field-bg-subtle);resize:none;box-sizing:border-box;transition:border-color .12s,box-shadow .12s,background .12s}.mtb-clarify-input:focus{border-color:var(--mtb-field-focus-border);box-shadow:0 0 0 3px #10b98126;background:var(--mtb-clarify-input-focus-bg)}.mtb-clarify-input::placeholder{color:var(--mtb-placeholder-fg)}.mtb-clarify-actions{display:flex;gap:6px;margin-top:6px}.mtb-clarify-skip,.mtb-clarify-fallback{flex:0 0 auto;height:30px;padding:0 12px;border:1px solid var(--mtb-action-border);border-radius:8px;background:var(--mtb-action-bg);cursor:pointer;font-family:inherit;font-size:12px;font-weight:550;color:var(--mtb-action-fg);white-space:nowrap;transition:background .12s}.mtb-clarify-skip:hover,.mtb-clarify-fallback:hover{background:var(--mtb-action-hover-bg)}.mtb-clarify-send,.mtb-clarify-retry{flex:1;height:30px;display:inline-flex;align-items:center;justify-content:center;gap:5px;border:none;border-radius:8px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12px;font-weight:600;transition:background .12s}.mtb-clarify-send:not(:disabled):hover,.mtb-clarify-retry:not(:disabled):hover{background:#047857}.mtb-clarify-send:disabled,.mtb-clarify-retry:disabled{background:#00000026;cursor:not-allowed}.mtb-clarify-send[aria-busy=true]:disabled{background:#059669;cursor:wait}.mtb-clarify-send-spinner{width:13px;height:13px;display:none;border:2px solid rgba(255,255,255,.45);border-top-color:#fff;border-radius:50%;animation:mtbSpin .7s linear infinite}@keyframes mtbSpin{to{transform:rotate(360deg)}}.mtb-clarify-send[aria-busy=true] svg,.mtb-clarify-send[aria-busy=true] .mtb-clarify-send-label{display:none}.mtb-clarify-send[aria-busy=true] .mtb-clarify-send-spinner{display:block}.mtb-clarify-send-feedback{width:100%;height:34px;display:inline-flex;align-items:center;justify-content:center;gap:6px;border:none;border-radius:9px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:600;transition:background .12s}.mtb-clarify-send-feedback:not(:disabled):hover{background:#047857}.mtb-clarify-send-feedback: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}.mtb-dim-clickable{z-index:2147483643;pointer-events:auto;cursor:default;background:#0000001f}.mtb-draw-bar{position:fixed;bottom:48px;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-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}@media (pointer: coarse){.mtb-tab:after{content:"";position:absolute;inset:-6px 0 -6px -12px}.mtb-tab.left:after{inset:-6px -12px -6px 0}.mtb-toolbar{min-height:56px;border-radius:16px}.mtb-toolbar-mode-btn,.mtb-exit-btn,.mtb-popup-close,.mtb-cancel-btn,.mtb-submit-btn{min-height:44px}.mtb-textarea,.mtb-clarify-input,.mtb-draw-input,.mtb-email-input{font-size:16px}}@media (max-width: 480px){.mtb-tab{width:36px;height:40px;padding:0;font-size:0;writing-mode:horizontal-tb;border-radius:12px 0 0 12px;right:env(safe-area-inset-right,0px)}.mtb-tab.left{left:env(safe-area-inset-left,0px);border-radius:0 12px 12px 0}.mtb-tab:before{content:"";width:18px;height:18px;background:currentColor;-webkit-mask:var(--mtb-tab-icon) center / contain no-repeat;mask:var(--mtb-tab-icon) center / contain no-repeat}.mtb-toolbar{inset:0 0 auto;width:100%;max-width:none;max-height:none;transform:none;flex-direction:row;align-items:center;border-radius:0;gap:8px;justify-content:center;padding:env(safe-area-inset-top,0px) 8px 0;height:calc(44px + env(safe-area-inset-top,0px));min-height:calc(44px + env(safe-area-inset-top,0px));border-bottom:1px solid rgba(60,60,67,.16);background:#f8f8f8f5;box-shadow:0 1px 3px #00000014;-webkit-backdrop-filter:blur(18px);backdrop-filter:blur(18px);animation:none}.mtb-toolbar-modes{flex-direction:row;gap:0;padding:2px;background:#7676801f;border-radius:8px}.mtb-toolbar-sep{display:none}.mtb-hint-bar{top:calc(44px + env(safe-area-inset-top,0px));right:0;bottom:0;left:0;transform:none;justify-content:center;height:auto;padding:0 24px;border-radius:0;background:#0000001a;box-shadow:none;animation:none;white-space:normal;text-align:center;transition:none}.mtb-hint-bar .mtb-toolbar-hint{max-width:280px;color:#fffffff5;font-size:17px;font-weight:600;line-height:1.4;letter-spacing:0;white-space:normal;text-shadow:0 1px 3px rgba(0,0,0,.45)}.mtb-toolbar-mode-btn,.mtb-exit-btn{position:relative;width:auto;height:32px;min-height:32px;gap:6px;border-radius:6px;padding-right:8px;padding-left:8px;color:#3c3c43d1;transition:none}.mtb-toolbar-mode-btn:hover{background:transparent;color:#3c3c43d1}.mtb-toolbar-mode-btn.active,.mtb-toolbar-mode-btn.active:hover{background:#fff;color:#047857;box-shadow:0 1px 3px #0000001f}.mtb-toolbar-mode-btn:after,.mtb-exit-btn:after{content:"";position:absolute;inset:-6px 0}.mtb-exit-btn{width:32px;padding:0;border-radius:50%;background:#7676801f}.mtb-exit-btn:hover{background:#7676801f;color:#3c3c43d1}.mtb-toolbar-label{display:inline}.mtb-exit-btn .mtb-toolbar-label{display:none}.mtb-popup{inset:auto 0 0;width:auto;max-height:85%;border-radius:20px 20px 0 0;animation:none}.mtb-popup-actions{padding-bottom:calc(12px + env(safe-area-inset-bottom,0px))}.mtb-clarify{inset:auto 0 0;width:auto;min-height:min(270px,85vh);max-height:85%;border-radius:20px 20px 0 0}.mtb-clarify-footer{padding-bottom:calc(12px + env(safe-area-inset-bottom,0px))}.mtb-draw-bar{left:0;right:0;bottom:0;transform:none;height:auto;padding:10px 12px calc(10px + env(safe-area-inset-bottom,0px));border-radius:16px 16px 0 0}.mtb-frustration-prompt{left:0;right:0;bottom:0;flex-direction:column;align-items:stretch;gap:12px;padding:16px 16px calc(16px + env(safe-area-inset-bottom,0px));border-radius:16px 16px 0 0;border-width:1px 0 0;animation:none}.mtb-frustration-actions{display:flex;gap:8px}.mtb-frustration-tell,.mtb-frustration-dismiss{flex:1;min-height:44px}}`;class $e{constructor(t="auto"){const e=document.getElementById("mtb-widget-host");this.ownsHost=!e,this.host=e??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),this.ownsHost&&document.body.appendChild(this.host),this.root=this.host.shadowRoot??this.host.attachShadow({mode:"open"}),this.root.replaceChildren();const r=document.createElement("style");r.textContent=He,this.root.appendChild(r)}el(t,e){const r=document.createElement(t);return e&&(r.className=e),r}append(...t){for(const e of t)this.root.appendChild(e)}remove(...t){for(const e of t)e.parentNode===this.root&&this.root.removeChild(e)}destroy(){if(!this.ownsHost){this.root.replaceChildren(),this.host.removeAttribute("data-mtb-toolbar");return}this.host.remove()}}class Fe{constructor(t,e,r,n,s){this.active=!1,this.onClick=n,this.customText=s,this.el=t.el("button","mtb-tab"),r==="left"&&this.el.classList.add("left"),this.idleLabel=s??e.tab,this.activeLabel=e.toolbar.exit,this.setLabel(this.idleLabel),this.el.addEventListener("click",n),t.append(this.el)}setLabel(t){this.el.textContent=t,this.el.setAttribute("aria-label",t)}setMessages(t){this.idleLabel=this.customText??t.tab,this.activeLabel=t.toolbar.exit,this.setLabel(this.active?this.activeLabel:this.idleLabel)}setActive(t){this.active=t,this.el.classList.toggle("active",t),this.setLabel(t?this.activeLabel:this.idleLabel)}destroy(){this.el.removeEventListener("click",this.onClick),this.el.remove()}}const Be=8e3;class Ue{constructor(t,e,r){this.autoHideTimer=null,this.el=t.el("div","mtb-frustration-prompt"),this.el.innerHTML=`
1
+ "use strict";var Ae=Object.create;var yt=Object.defineProperty;var Le=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var Me=Object.getPrototypeOf,Re=Object.prototype.hasOwnProperty;var Ie=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Pe(t))!Re.call(i,n)&&n!==e&&yt(i,n,{get:()=>t[n],enumerable:!(r=Le(t,n))||r.enumerable});return i};var De=(i,t,e)=>(e=i!=null?Ae(Me(i)):{},Ie(t||!i||!i.__esModule?yt(e,"default",{value:i,enumerable:!0}):e,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const He=`*,*: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{--mtb-panel-bg: #fff;--mtb-panel-border: rgba(0, 0, 0, .1);--mtb-panel-divider: rgba(0, 0, 0, .06);--mtb-fg: #191a1c;--mtb-field-bg: #fff;--mtb-field-bg-subtle: #fafafa;--mtb-field-border: rgba(0, 0, 0, .12);--mtb-field-border-soft: rgba(0, 0, 0, .09);--mtb-placeholder-fg: rgba(0, 0, 0, .34);--mtb-action-bg: #fff;--mtb-action-border: rgba(0, 0, 0, .12);--mtb-action-fg: rgba(0, 0, 0, .55);--mtb-action-hover-bg: rgba(0, 0, 0, .04);--mtb-popup-close-fg: rgba(0, 0, 0, .38);--mtb-success-msg-fg: rgba(0, 0, 0, .45);--mtb-close-link-fg: rgba(0, 0, 0, .4);--mtb-clarify-subtitle-fg: rgba(0, 0, 0, .42);--mtb-clarify-close-fg: rgba(0, 0, 0, .38);--mtb-clarify-close-hover-fg: rgba(0, 0, 0, .7);--mtb-dismiss-fg: rgba(0, 0, 0, .4);--mtb-dismiss-hover-fg: rgba(0, 0, 0, .7);--mtb-quick-hover-bg: rgba(16, 185, 129, .06);--mtb-quick-hover-border: rgba(16, 185, 129, .3);--mtb-quick-selected-bg: rgba(16, 185, 129, .1);--mtb-quick-selected-border: rgba(16, 185, 129, .5);--mtb-field-focus-border: #10b981;--mtb-clarify-input-focus-bg: #fff;--mtb-popup-close-hover-fg: rgba(0, 0, 0, .7);--mtb-close-link-hover-fg: rgba(0, 0, 0, .7)}:host([data-mtb-theme="dark"]){--mtb-panel-bg: #151719;--mtb-panel-border: rgba(255, 255, 255, .12);--mtb-panel-divider: rgba(255, 255, 255, .1);--mtb-fg: #f9fafb;--mtb-field-bg: #1f2327;--mtb-field-bg-subtle: #1f2327;--mtb-field-border: rgba(255, 255, 255, .12);--mtb-field-border-soft: rgba(255, 255, 255, .12);--mtb-placeholder-fg: rgba(255, 255, 255, .4);--mtb-action-bg: #1f2327;--mtb-action-border: rgba(255, 255, 255, .14);--mtb-action-fg: rgba(255, 255, 255, .7);--mtb-action-hover-bg: rgba(255, 255, 255, .06);--mtb-popup-close-fg: rgba(255, 255, 255, .68);--mtb-success-msg-fg: rgba(255, 255, 255, .55);--mtb-close-link-fg: rgba(255, 255, 255, .68);--mtb-clarify-subtitle-fg: rgba(255, 255, 255, .45);--mtb-clarify-close-fg: rgba(255, 255, 255, .45);--mtb-clarify-close-hover-fg: rgba(255, 255, 255, .75);--mtb-dismiss-fg: rgba(255, 255, 255, .4);--mtb-dismiss-hover-fg: rgba(255, 255, 255, .7);--mtb-quick-hover-bg: #1f2327;--mtb-quick-hover-border: rgba(255, 255, 255, .12);--mtb-quick-selected-bg: #1f2327;--mtb-quick-selected-border: rgba(255, 255, 255, .12);--mtb-field-focus-border: rgba(255, 255, 255, .12);--mtb-clarify-input-focus-bg: #1f2327;--mtb-popup-close-hover-fg: rgba(255, 255, 255, .68);--mtb-close-link-hover-fg: rgba(255, 255, 255, .68)}@media (prefers-color-scheme: dark){:host([data-mtb-theme="auto"]){--mtb-panel-bg: #151719;--mtb-panel-border: rgba(255, 255, 255, .12);--mtb-panel-divider: rgba(255, 255, 255, .1);--mtb-fg: #f9fafb;--mtb-field-bg: #1f2327;--mtb-field-bg-subtle: #1f2327;--mtb-field-border: rgba(255, 255, 255, .12);--mtb-field-border-soft: rgba(255, 255, 255, .12);--mtb-placeholder-fg: rgba(255, 255, 255, .4);--mtb-action-bg: #1f2327;--mtb-action-border: rgba(255, 255, 255, .14);--mtb-action-fg: rgba(255, 255, 255, .7);--mtb-action-hover-bg: rgba(255, 255, 255, .06);--mtb-popup-close-fg: rgba(255, 255, 255, .68);--mtb-success-msg-fg: rgba(255, 255, 255, .55);--mtb-close-link-fg: rgba(255, 255, 255, .68);--mtb-clarify-subtitle-fg: rgba(255, 255, 255, .45);--mtb-clarify-close-fg: rgba(255, 255, 255, .45);--mtb-clarify-close-hover-fg: rgba(255, 255, 255, .75);--mtb-dismiss-fg: rgba(255, 255, 255, .4);--mtb-dismiss-hover-fg: rgba(255, 255, 255, .7);--mtb-quick-hover-bg: #1f2327;--mtb-quick-hover-border: rgba(255, 255, 255, .12);--mtb-quick-selected-bg: #1f2327;--mtb-quick-selected-border: rgba(255, 255, 255, .12);--mtb-field-focus-border: rgba(255, 255, 255, .12);--mtb-clarify-input-focus-bg: #1f2327;--mtb-popup-close-hover-fg: rgba(255, 255, 255, .68);--mtb-close-link-hover-fg: rgba(255, 255, 255, .68)}}.mtb-tab{--mtb-tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Ccircle cx='12' cy='12' r='2.4' fill='%23000' stroke='none'/%3E%3Cpath d='M12 1.8v3.4M12 18.8v3.4M1.8 12h3.4M18.8 12h3.4'/%3E%3C/svg%3E");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-hint-bar{position:fixed;top:18px;left:50%;transform:translate(-50%);z-index:2147483647;display:flex;align-items:center;height:38px;padding:0 16px;border-radius:13px;background:linear-gradient(120deg,#10b981,#059669);box-shadow:0 10px 26px #0f172a38;animation:mtbHintIn .2s ease;white-space:nowrap;transition:opacity .15s ease;pointer-events:none}.mtb-hint-bar--under-pointer{opacity:.3}.mtb-hint-bar.mtb-hint-bar--dismissed{display:none}@keyframes mtbHintIn{0%{transform:translate(-50%,12px);opacity:0}to{transform:translate(-50%);opacity:1}}.mtb-toolbar{position:fixed;top:50%;right:8px;transform:translateY(-50%);z-index:2147483647;display:flex;flex-direction:column;align-items:center;gap:6px;width:38px;padding:6px 0;max-height:calc(100vh - 24px);border-radius:19px;background:linear-gradient(160deg,#10b981,#059669);box-shadow:0 8px 22px #0f172a33;animation:mtbEdgeBarIn .2s ease;white-space:nowrap;pointer-events:none}.mtb-toolbar.left{right:auto;left:8px;animation:mtbEdgeBarInLeft .2s ease}@keyframes mtbBarIn{0%{transform:translate(-50%,12px);opacity:0}to{transform:translate(-50%);opacity:1}}@keyframes mtbEdgeBarIn{0%{transform:translate(12px,-50%);opacity:0}to{transform:translateY(-50%);opacity:1}}@keyframes mtbEdgeBarInLeft{0%{transform:translate(-12px,-50%);opacity:0}to{transform:translateY(-50%);opacity:1}}.mtb-toolbar-label{display:none}:host([data-mtb-toolbar]) .mtb-tab{display:none}.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:20px;height:1px;align-self:center;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-toolbar-modes{flex-direction:column;gap:6px;padding:0;background:none;border-radius:0}.mtb-toolbar-mode-btn,.mtb-exit-btn{pointer-events:auto;display:flex;align-items:center;justify-content:center;gap:0;width:30px;height:30px;padding:0;border-radius:50%;background:none;color:#ffffffb8}.mtb-toolbar-mode-btn:hover,.mtb-exit-btn:hover{background:#ffffff29;color:#fff}.mtb-toolbar-mode-btn.active,.mtb-toolbar-mode-btn.active:hover{background:#fff;color:#047857}.mtb-exit-btn{color:#fff}.mtb-toolbar-sep{width:16px;height:1px;margin:1px 0;align-self:center;background:#ffffff47}.mtb-exit-btn:hover{background:#ffffff47}.mtb-overlay{position:fixed;inset:0;z-index:2147483640;cursor:crosshair;touch-action:none}.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.selected{border-color:#2563eb;background:#2563eb0a}.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:min(320px,calc(100vw - 56px));background:var(--mtb-panel-bg);border:1px solid var(--mtb-panel-border);border-radius:16px;color:var(--mtb-fg);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 var(--mtb-panel-divider);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:var(--mtb-fg)}.mtb-popup-close{background:none;border:none;cursor:pointer;padding:3px;color:var(--mtb-popup-close-fg);display:flex;align-items:center;border-radius:4px;transition:color .12s}.mtb-popup-close:hover{color:var(--mtb-popup-close-hover-fg)}.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 var(--mtb-field-border-soft);border-radius:10px;background:var(--mtb-field-bg-subtle);cursor:pointer;font-family:inherit;font-size:13px;color:var(--mtb-fg);text-align:left;transition:all .12s}.mtb-quick-option:hover{background:var(--mtb-quick-hover-bg);border-color:var(--mtb-quick-hover-border)}.mtb-quick-option.selected{background:var(--mtb-quick-selected-bg);border-color:var(--mtb-quick-selected-border)}.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 var(--mtb-field-border);border-radius:10px;font-family:inherit;font-size:12.5px;line-height:1.5;color:var(--mtb-fg);outline:none;background:var(--mtb-field-bg);resize:none;transition:border-color .12s,box-shadow .12s}.mtb-textarea:focus{border-color:var(--mtb-field-focus-border);box-shadow:0 0 0 3px #10b98126}.mtb-textarea::placeholder{color:var(--mtb-placeholder-fg)}.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:1px solid transparent;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:#fff;border-color:#0000001f;color:#191a1c}.mtb-cancel-btn:hover{background:#fafafa}.mtb-submit-btn{background:#f7f7f8;border-color:#0000001a;color:#00000059}.mtb-submit-btn.ready{background:#059669;border-color:#059669;color:#fff}.mtb-submit-btn.ready:hover{background:#047857;border-color:#047857}.mtb-submit-btn:disabled{cursor:not-allowed}.mtb-success{position:fixed;z-index:2147483645;width:332px;background:var(--mtb-panel-bg);border:1px solid var(--mtb-panel-border);border-radius:16px;color:var(--mtb-fg);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:var(--mtb-fg)}.mtb-success-msg{font-size:12px;color:var(--mtb-success-msg-fg);margin-bottom:14px;line-height:1.5}.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:inherit;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:11px;color:var(--mtb-close-link-fg);font-family:inherit;transition:color .12s}.mtb-close-link:hover{color:var(--mtb-close-link-hover-fg)}.mtb-email-capture{margin-bottom:14px;text-align:left}.mtb-email-prompt{font-size:12px;color:var(--mtb-success-msg-fg);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:var(--mtb-panel-bg);border:1px solid var(--mtb-panel-border);border-radius:12px;color:var(--mtb-fg);box-shadow:0 8px 30px #0000001f;animation:mtbSlideUp .35s cubic-bezier(.34,1.56,.64,1);font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif}.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:var(--mtb-dismiss-fg);cursor:pointer;font-family:inherit;font-size:12px;transition:color .12s}.mtb-frustration-dismiss:hover{color:var(--mtb-dismiss-hover-fg)}.mtb-record-bar{position:fixed;bottom:48px;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:#dc2626;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:min(346px,calc(100vw - 56px));min-height:min(270px,calc(100vh - 24px));background:var(--mtb-panel-bg);border:1px solid var(--mtb-panel-border);border-radius:16px;color:var(--mtb-fg);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-continuation{width:min(320px,calc(100vw - 56px));animation:none}.mtb-clarify-header{padding:8px 10px;display:flex;align-items:center;gap:7px;border-bottom:1px solid var(--mtb-panel-divider)}.mtb-clarify-icon{width:20px;height:20px;border-radius:6px;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:12px;font-weight:650;line-height:1.2;color:var(--mtb-fg)}.mtb-clarify-subtitle{font-size:9.5px;color:var(--mtb-clarify-subtitle-fg)}.mtb-clarify-close{background:none;border:none;cursor:pointer;padding:3px;color:var(--mtb-clarify-close-fg);display:flex;transition:color .12s}.mtb-clarify-close:hover{color:var(--mtb-clarify-close-hover-fg)}.mtb-clarify-messages{flex:1;overflow-y:auto;padding:8px 10px 4px;display:flex;flex-direction:column;gap:6px}.mtb-clarify-bubble{max-width:82%;padding:6px 10px;font-size:12px;line-height:1.4;white-space:pre-wrap;word-break:break-word}.mtb-clarify-ai{align-self:flex-start;background:var(--mtb-field-bg);color:var(--mtb-fg);border:1px solid var(--mtb-field-border-soft);border-radius:11px 11px 11px 3px}.mtb-clarify-user{align-self:flex-end;background:#059669;color:#fff;border:1px solid #059669;border-radius:11px 11px 3px}.mtb-clarify-thinking{display:flex;align-items:center;gap:4px;padding:8px 12px}.mtb-clarify-thinking .mtb-dot{width:6px;height:6px;background:#059669b3}.mtb-clarify-footer{padding:3px 10px 10px;display:flex;flex-direction:column}.mtb-clarify-input{width:100%;height:40px;padding:7px 10px;border:1px solid var(--mtb-field-border);border-radius:8px;font-family:inherit;font-size:12px;line-height:1.4;color:var(--mtb-fg);outline:none;background:var(--mtb-field-bg-subtle);resize:none;box-sizing:border-box;transition:border-color .12s,box-shadow .12s,background .12s}.mtb-clarify-input:focus{border-color:var(--mtb-field-focus-border);box-shadow:0 0 0 3px #10b98126;background:var(--mtb-clarify-input-focus-bg)}.mtb-clarify-input::placeholder{color:var(--mtb-placeholder-fg)}.mtb-clarify-actions{display:flex;gap:6px;margin-top:6px}.mtb-clarify-skip,.mtb-clarify-fallback{flex:0 0 auto;height:30px;padding:0 12px;border:1px solid var(--mtb-action-border);border-radius:8px;background:var(--mtb-action-bg);cursor:pointer;font-family:inherit;font-size:12px;font-weight:550;color:var(--mtb-action-fg);white-space:nowrap;transition:background .12s}.mtb-clarify-skip:hover,.mtb-clarify-fallback:hover{background:var(--mtb-action-hover-bg)}.mtb-clarify-send,.mtb-clarify-retry{flex:1;height:30px;display:inline-flex;align-items:center;justify-content:center;gap:5px;border:none;border-radius:8px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12px;font-weight:600;transition:background .12s}.mtb-clarify-send:not(:disabled):hover,.mtb-clarify-retry:not(:disabled):hover{background:#047857}.mtb-clarify-send:disabled,.mtb-clarify-retry:disabled{background:#00000026;cursor:not-allowed}.mtb-clarify-send[aria-busy=true]:disabled{background:#059669;cursor:wait}.mtb-clarify-send-spinner{width:13px;height:13px;display:none;border:2px solid rgba(255,255,255,.45);border-top-color:#fff;border-radius:50%;animation:mtbSpin .7s linear infinite}@keyframes mtbSpin{to{transform:rotate(360deg)}}.mtb-clarify-send[aria-busy=true] svg,.mtb-clarify-send[aria-busy=true] .mtb-clarify-send-label{display:none}.mtb-clarify-send[aria-busy=true] .mtb-clarify-send-spinner{display:block}.mtb-clarify-send-feedback{width:100%;height:34px;display:inline-flex;align-items:center;justify-content:center;gap:6px;border:none;border-radius:9px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:600;transition:background .12s}.mtb-clarify-send-feedback:not(:disabled):hover{background:#047857}.mtb-clarify-send-feedback: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}.mtb-dim-clickable{z-index:2147483643;pointer-events:auto;cursor:default;background:#0000001f}.mtb-draw-bar{position:fixed;bottom:48px;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-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}@media (pointer: coarse){.mtb-tab:after{content:"";position:absolute;inset:-6px 0 -6px -12px}.mtb-tab.left:after{inset:-6px -12px -6px 0}.mtb-toolbar{min-height:56px;border-radius:16px}.mtb-toolbar-mode-btn,.mtb-exit-btn,.mtb-popup-close,.mtb-cancel-btn,.mtb-submit-btn{min-height:44px}.mtb-textarea,.mtb-clarify-input,.mtb-draw-input,.mtb-email-input{font-size:16px}}@media (max-width: 480px){.mtb-tab{width:36px;height:40px;padding:0;font-size:0;writing-mode:horizontal-tb;border-radius:12px 0 0 12px;right:env(safe-area-inset-right,0px)}.mtb-tab.left{left:env(safe-area-inset-left,0px);border-radius:0 12px 12px 0}.mtb-tab:before{content:"";width:18px;height:18px;background:currentColor;-webkit-mask:var(--mtb-tab-icon) center / contain no-repeat;mask:var(--mtb-tab-icon) center / contain no-repeat}.mtb-toolbar{inset:0 0 auto;width:100%;max-width:none;max-height:none;transform:none;flex-direction:row;align-items:center;border-radius:0;gap:8px;justify-content:center;padding:env(safe-area-inset-top,0px) 8px 0;height:calc(44px + env(safe-area-inset-top,0px));min-height:calc(44px + env(safe-area-inset-top,0px));border-bottom:1px solid rgba(60,60,67,.16);background:#f8f8f8f5;box-shadow:0 1px 3px #00000014;-webkit-backdrop-filter:blur(18px);backdrop-filter:blur(18px);animation:none}.mtb-toolbar-modes{flex-direction:row;gap:0;padding:2px;background:#7676801f;border-radius:8px}.mtb-toolbar-sep{display:none}.mtb-hint-bar{top:calc(44px + env(safe-area-inset-top,0px));right:0;bottom:0;left:0;transform:none;justify-content:center;height:auto;padding:0 24px;border-radius:0;background:#0000001a;box-shadow:none;animation:none;white-space:normal;text-align:center;transition:none}.mtb-hint-bar .mtb-toolbar-hint{max-width:280px;color:#fffffff5;font-size:17px;font-weight:600;line-height:1.4;letter-spacing:0;white-space:normal;text-shadow:0 1px 3px rgba(0,0,0,.45)}.mtb-toolbar-mode-btn,.mtb-exit-btn{position:relative;width:auto;height:32px;min-height:32px;gap:6px;border-radius:6px;padding-right:8px;padding-left:8px;color:#3c3c43d1;transition:none}.mtb-toolbar-mode-btn:hover{background:transparent;color:#3c3c43d1}.mtb-toolbar-mode-btn.active,.mtb-toolbar-mode-btn.active:hover{background:#fff;color:#047857;box-shadow:0 1px 3px #0000001f}.mtb-toolbar-mode-btn:after,.mtb-exit-btn:after{content:"";position:absolute;inset:-6px 0}.mtb-exit-btn{width:32px;padding:0;border-radius:50%;background:#7676801f}.mtb-exit-btn:hover{background:#7676801f;color:#3c3c43d1}.mtb-toolbar-label{display:inline}.mtb-exit-btn .mtb-toolbar-label{display:none}.mtb-popup{inset:auto 0 0;width:auto;max-height:85%;border-radius:20px 20px 0 0;animation:none}.mtb-popup-actions{padding-bottom:calc(12px + env(safe-area-inset-bottom,0px))}.mtb-clarify{inset:auto 0 0;width:auto;min-height:min(270px,85vh);max-height:85%;border-radius:20px 20px 0 0}.mtb-clarify-footer{padding-bottom:calc(12px + env(safe-area-inset-bottom,0px))}.mtb-draw-bar{left:0;right:0;bottom:0;transform:none;height:auto;padding:10px 12px calc(10px + env(safe-area-inset-bottom,0px));border-radius:16px 16px 0 0}.mtb-frustration-prompt{left:0;right:0;bottom:0;flex-direction:column;align-items:stretch;gap:12px;padding:16px 16px calc(16px + env(safe-area-inset-bottom,0px));border-radius:16px 16px 0 0;border-width:1px 0 0;animation:none}.mtb-frustration-actions{display:flex;gap:8px}.mtb-frustration-tell,.mtb-frustration-dismiss{flex:1;min-height:44px}}`;class $e{constructor(t="auto"){const e=document.getElementById("mtb-widget-host");this.ownsHost=!e,this.host=e??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),this.ownsHost&&document.body.appendChild(this.host),this.root=this.host.shadowRoot??this.host.attachShadow({mode:"open"}),this.root.replaceChildren();const r=document.createElement("style");r.textContent=He,this.root.appendChild(r)}el(t,e){const r=document.createElement(t);return e&&(r.className=e),r}append(...t){for(const e of t)this.root.appendChild(e)}remove(...t){for(const e of t)e.parentNode===this.root&&this.root.removeChild(e)}destroy(){if(!this.ownsHost){this.root.replaceChildren(),this.host.removeAttribute("data-mtb-toolbar");return}this.host.remove()}}class Fe{constructor(t,e,r,n,s){this.active=!1,this.onClick=n,this.customText=s,this.el=t.el("button","mtb-tab"),r==="left"&&this.el.classList.add("left"),this.idleLabel=s??e.tab,this.activeLabel=e.toolbar.exit,this.setLabel(this.idleLabel),this.el.addEventListener("click",n),t.append(this.el)}setLabel(t){this.el.textContent=t,this.el.setAttribute("aria-label",t)}setMessages(t){this.idleLabel=this.customText??t.tab,this.activeLabel=t.toolbar.exit,this.setLabel(this.active?this.activeLabel:this.idleLabel)}setActive(t){this.active=t,this.el.classList.toggle("active",t),this.setLabel(t?this.activeLabel:this.idleLabel)}destroy(){this.el.removeEventListener("click",this.onClick),this.el.remove()}}const Be="mtb-widget-host";function C(i){const t=document.getElementById(Be);return t?t===i||t.contains(i):!1}function c(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const Ue=8e3;class ze{constructor(t,e,r){this.autoHideTimer=null,this.el=t.el("div","mtb-frustration-prompt"),this.el.innerHTML=`
2
2
  <div class="mtb-frustration-icon">&#9888;&#65039;</div>
3
- <span class="mtb-frustration-text">${e.frustration.prompt}</span>
3
+ <span class="mtb-frustration-text">${c(e.frustration.prompt)}</span>
4
4
  <div class="mtb-frustration-actions">
5
- <button class="mtb-frustration-tell">${e.frustration.action}</button>
6
- <button class="mtb-frustration-dismiss">${e.frustration.dismiss}</button>
5
+ <button class="mtb-frustration-tell">${c(e.frustration.action)}</button>
6
+ <button class="mtb-frustration-dismiss">${c(e.frustration.dismiss)}</button>
7
7
  </div>
8
- `,this.el.querySelector(".mtb-frustration-tell").addEventListener("click",r.onTell),this.el.querySelector(".mtb-frustration-dismiss").addEventListener("click",r.onDismiss),t.append(this.el),this.autoHideTimer=setTimeout(r.onAutoHide,Be)}destroy(){this.autoHideTimer&&(clearTimeout(this.autoHideTimer),this.autoHideTimer=null),this.el.remove()}}const ze=400;class Oe{constructor(t,e,r=()=>Date.now()){this.bornAt=Date.now(),this.bornAt=r(),this.onClick=()=>{r()-this.bornAt<ze||e()},this.el=t.el("div","mtb-dim mtb-dim-clickable"),this.el.addEventListener("click",this.onClick),t.append(this.el)}destroy(){this.el.removeEventListener("click",this.onClick),this.el.remove()}}function x(){return window.matchMedia?.("(pointer: coarse)").matches??!1}class Ne{constructor(){this.applied=!1,this.previousPadding="",this.previousTransition=""}reserve(t){if(this.applied||t<=0)return;this.applied=!0;const e=document.body.style;this.previousPadding=e.paddingTop,this.previousTransition=e.transition;const r=parseFloat(getComputedStyle(document.body).paddingTop)||0;e.transition="none",e.paddingTop=`${r+t}px`}release(){if(!this.applied)return;this.applied=!1;const t=document.body.style;t.paddingTop=this.previousPadding,t.transition=this.previousTransition}isApplied(){return this.applied}}const qe=44;class je{constructor(t,e,r,n,s="right",o=!0){this.currentMode="markup",this.handlePointerMove=a=>{if(a.pointerType!=="mouse")return;const l=this.hintBarEl.getBoundingClientRect(),c=a.clientX>=l.left&&a.clientX<=l.right&&a.clientY>=l.top&&a.clientY<=l.bottom;this.hintBarEl.classList.toggle("mtb-hint-bar--under-pointer",c)},this.dismissTouchHint=()=>{this.hintBarEl.classList.add("mtb-hint-bar--dismissed"),document.removeEventListener("pointerdown",this.dismissTouchHint,!0)},this.messages=e,this.touch=x(),this.hintBarEl=t.el("div","mtb-hint-bar"),this.hintBarEl.innerHTML=`<span class="mtb-toolbar-hint">${this.idleHint()}</span>`,this.touch&&!o&&this.hintBarEl.classList.add("mtb-hint-bar--dismissed"),this.el=t.el("div","mtb-toolbar"),s==="left"&&this.el.classList.add("left"),this.el.innerHTML=this.buildHTML(e),t.append(this.hintBarEl,this.el),this.host=t.host,this.host.setAttribute("data-mtb-toolbar",""),this.hintTextEl=this.hintBarEl.querySelector(".mtb-toolbar-hint"),this.markupBtn=this.el.querySelector(".mtb-toolbar-mode-markup"),this.recordBtn=this.el.querySelector(".mtb-toolbar-mode-record"),this.markupBtn.addEventListener("click",()=>{this.setMode("markup"),n?.("markup")}),this.recordBtn.addEventListener("click",()=>{this.setMode("record"),n?.("record")}),this.el.querySelector(".mtb-exit-btn").addEventListener("click",r),document.addEventListener("pointermove",this.handlePointerMove),this.touch&&o&&document.addEventListener("pointerdown",this.dismissTouchHint,!0)}buildHTML(t){return`
8
+ `,this.el.querySelector(".mtb-frustration-tell").addEventListener("click",r.onTell),this.el.querySelector(".mtb-frustration-dismiss").addEventListener("click",r.onDismiss),t.append(this.el),this.autoHideTimer=setTimeout(r.onAutoHide,Ue)}destroy(){this.autoHideTimer&&(clearTimeout(this.autoHideTimer),this.autoHideTimer=null),this.el.remove()}}const Oe=400;class Ne{constructor(t,e,r=()=>Date.now()){this.bornAt=Date.now(),this.bornAt=r(),this.onClick=()=>{r()-this.bornAt<Oe||e()},this.el=t.el("div","mtb-dim mtb-dim-clickable"),this.el.addEventListener("click",this.onClick),t.append(this.el)}destroy(){this.el.removeEventListener("click",this.onClick),this.el.remove()}}function x(){return window.matchMedia?.("(pointer: coarse)").matches??!1}class qe{constructor(){this.applied=!1,this.previousPadding="",this.previousTransition=""}reserve(t){if(this.applied||t<=0)return;this.applied=!0;const e=document.body.style;this.previousPadding=e.paddingTop,this.previousTransition=e.transition;const r=parseFloat(getComputedStyle(document.body).paddingTop)||0;e.transition="none",e.paddingTop=`${r+t}px`}release(){if(!this.applied)return;this.applied=!1;const t=document.body.style;t.paddingTop=this.previousPadding,t.transition=this.previousTransition}isApplied(){return this.applied}}const je=44;class We{constructor(t,e,r,n,s="right",o=!0){this.currentMode="markup",this.handlePointerMove=a=>{if(a.pointerType!=="mouse")return;const l=this.hintBarEl.getBoundingClientRect(),d=a.clientX>=l.left&&a.clientX<=l.right&&a.clientY>=l.top&&a.clientY<=l.bottom;this.hintBarEl.classList.toggle("mtb-hint-bar--under-pointer",d)},this.dismissTouchHint=()=>{this.hintBarEl.classList.add("mtb-hint-bar--dismissed"),document.removeEventListener("pointerdown",this.dismissTouchHint,!0)},this.messages=e,this.touch=x(),this.hintBarEl=t.el("div","mtb-hint-bar"),this.hintBarEl.innerHTML=`<span class="mtb-toolbar-hint">${c(this.idleHint())}</span>`,this.touch&&!o&&this.hintBarEl.classList.add("mtb-hint-bar--dismissed"),this.el=t.el("div","mtb-toolbar"),s==="left"&&this.el.classList.add("left"),this.el.innerHTML=this.buildHTML(e),t.append(this.hintBarEl,this.el),this.host=t.host,this.host.setAttribute("data-mtb-toolbar",""),this.hintTextEl=this.hintBarEl.querySelector(".mtb-toolbar-hint"),this.markupBtn=this.el.querySelector(".mtb-toolbar-mode-markup"),this.recordBtn=this.el.querySelector(".mtb-toolbar-mode-record"),this.markupBtn.addEventListener("click",()=>{this.setMode("markup"),n?.("markup")}),this.recordBtn.addEventListener("click",()=>{this.setMode("record"),n?.("record")}),this.el.querySelector(".mtb-exit-btn").addEventListener("click",r),document.addEventListener("pointermove",this.handlePointerMove),this.touch&&o&&document.addEventListener("pointerdown",this.dismissTouchHint,!0)}buildHTML(t){return`
9
9
  <div class="mtb-toolbar-modes">
10
- <button class="mtb-toolbar-mode-btn mtb-toolbar-mode-markup active" aria-label="${t.toolbar.markup}" title="${t.toolbar.markup}">
11
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><line x1="12" y1="3" x2="12" y2="7"/><line x1="12" y1="17" x2="12" y2="21"/><line x1="3" y1="12" x2="7" y2="12"/><line x1="17" y1="12" x2="21" y2="12"/></svg><span class="mtb-toolbar-label">${t.toolbar.markup}</span>
10
+ <button class="mtb-toolbar-mode-btn mtb-toolbar-mode-markup active" aria-label="${c(t.toolbar.markup)}" title="${c(t.toolbar.markup)}">
11
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><line x1="12" y1="3" x2="12" y2="7"/><line x1="12" y1="17" x2="12" y2="21"/><line x1="3" y1="12" x2="7" y2="12"/><line x1="17" y1="12" x2="21" y2="12"/></svg><span class="mtb-toolbar-label">${c(t.toolbar.markup)}</span>
12
12
  </button>
13
- <button class="mtb-toolbar-mode-btn mtb-toolbar-mode-record" aria-label="${t.toolbar.record}" title="${t.toolbar.record}">
14
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="6" width="13" height="12" rx="2.5"/><path d="M15 10.5 21.2 7.4a.6.6 0 0 1 .8.5v8.2a.6.6 0 0 1-.8.5L15 13.5z"/></svg><span class="mtb-toolbar-label">${t.toolbar.record}</span>
13
+ <button class="mtb-toolbar-mode-btn mtb-toolbar-mode-record" aria-label="${c(t.toolbar.record)}" title="${c(t.toolbar.record)}">
14
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="6" width="13" height="12" rx="2.5"/><path d="M15 10.5 21.2 7.4a.6.6 0 0 1 .8.5v8.2a.6.6 0 0 1-.8.5L15 13.5z"/></svg><span class="mtb-toolbar-label">${c(t.toolbar.record)}</span>
15
15
  </button>
16
16
  </div>
17
17
  <span class="mtb-toolbar-sep"></span>
18
- <button class="mtb-exit-btn" aria-label="${t.toolbar.exit}" title="${t.toolbar.exit}">
18
+ <button class="mtb-exit-btn" aria-label="${c(t.toolbar.exit)}" title="${c(t.toolbar.exit)}">
19
19
  <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">
20
20
  <path d="M18 6L6 18M6 6l12 12"/>
21
- </svg><span class="mtb-toolbar-label">${t.toolbar.exit}</span>
21
+ </svg><span class="mtb-toolbar-label">${c(t.toolbar.exit)}</span>
22
22
  </button>
23
- `}idleHint(){return this.touch?this.messages.toolbar.hintTouch:this.messages.toolbar.hint}setMode(t){this.currentMode=t,t==="markup"?(this.markupBtn.classList.add("active"),this.recordBtn.classList.remove("active"),this.hintTextEl.textContent=this.idleHint()):(this.markupBtn.classList.remove("active"),this.recordBtn.classList.add("active"),this.hintTextEl.textContent=this.messages.toolbar.hintRecord)}getMode(){return this.currentMode}height(){return this.el.getBoundingClientRect().height||qe}destroy(){document.removeEventListener("pointermove",this.handlePointerMove),document.removeEventListener("pointerdown",this.dismissTouchHint,!0),this.host.removeAttribute("data-mtb-toolbar"),this.hintBarEl.remove(),this.el.remove()}}class We{constructor(t,e){this.handlers=e,this.overlayEl=t.el("div","mtb-overlay"),this.onPointerDown=r=>{const n=r;if(n.isPrimary){try{this.overlayEl.setPointerCapture(n.pointerId)}catch{}this.handlers.onPointerDown(n)}},this.onPointerMove=r=>{const n=r;n.isPrimary&&this.handlers.onPointerMove(n)},this.onPointerUp=r=>{const n=r;n.isPrimary&&(this.releaseCapture(n.pointerId),this.handlers.onPointerUp(n))},this.onPointerCancel=r=>{const n=r;n.isPrimary&&(this.releaseCapture(n.pointerId),this.handlers.onPointerCancel(n))},this.overlayEl.addEventListener("pointerdown",this.onPointerDown),this.overlayEl.addEventListener("pointermove",this.onPointerMove),this.overlayEl.addEventListener("pointerup",this.onPointerUp),this.overlayEl.addEventListener("pointercancel",this.onPointerCancel),t.append(this.overlayEl),this.dimEl=t.el("div","mtb-dim"),t.append(this.dimEl)}releaseCapture(t){try{this.overlayEl.releasePointerCapture(t)}catch{}}destroy(){this.overlayEl.removeEventListener("pointerdown",this.onPointerDown),this.overlayEl.removeEventListener("pointermove",this.onPointerMove),this.overlayEl.removeEventListener("pointerup",this.onPointerUp),this.overlayEl.removeEventListener("pointercancel",this.onPointerCancel),this.overlayEl.remove(),this.dimEl.remove()}}class Ve{constructor(t){this.highlightEl=t.el("div","mtb-highlight"),this.tooltipEl=t.el("div","mtb-highlight-tooltip"),this.hide(),t.append(this.highlightEl,this.tooltipEl)}highlight(t){const e=t.getBoundingClientRect();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)}showTooltip(t,e){this.tooltipEl.textContent=ht(t);const r=e.top<30;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"}select(){this.highlightEl.classList.add("selected"),this.tooltipEl.style.display="none"}hide(){this.highlightEl.style.display="none",this.highlightEl.classList.remove("selected"),this.tooltipEl.style.display="none"}destroy(){this.highlightEl.remove(),this.tooltipEl.remove()}}const Ye=/^(script|style|noscript|template)$/i;function Jt(i,t=80){let e="";for(const r of Array.from(i.childNodes)){if(e.length>=t)break;r.nodeType===3?e+=r.nodeValue??"":r instanceof Element&&!Ye.test(r.tagName)&&(e+=Jt(r,t-e.length))}return e}function ht(i){if(i instanceof HTMLElement){const t=i.getAttribute("aria-label");if(t)return t;const e=i.getAttribute("title");if(e)return e;const r=Jt(i).trim().slice(0,40);if(r)return r;const n=i.placeholder;if(n)return n;const s=i.alt;if(s)return s;const o=i.getAttribute("data-mark");if(o)return o}return i.tagName.toLowerCase()}function Zt(i){const t=[];let e=i;for(;e&&e!==document.body&&t.length<5;){let r=e.tagName.toLowerCase();if(e.id){r=`#${e.id}`,t.unshift(r);break}const n=Array.from(e.classList).filter(o=>!o.startsWith("mtb-")).slice(0,2).join(".");n&&(r+=`.${n}`);const s=e.parentElement;if(s){const o=Array.from(s.children).filter(a=>a.tagName===e.tagName);if(o.length>1){const a=o.indexOf(e)+1;r+=`:nth-of-type(${a})`}}t.unshift(r),e=e.parentElement}return t.join(" > ")}class Xe{constructor(t){this.pins=[],this.shadow=t}addPin(t,e){const r=this.shadow.el("div","mtb-pin");r.style.top=`${e}px`,r.style.left=`${t}px`,this.shadow.append(r),this.pins.push(r)}clearAll(){for(const t of this.pins)t.remove();this.pins=[]}destroy(){this.clearAll()}}const G="#059669",Ke="5,150,105";function ut(i){return`rgba(${Ke},${i})`}const Ge='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',L={color:G,width:"3.5",linecap:"round",linejoin:"round",filter:`drop-shadow(0 1px 2px ${ut(.35)})`};class Je{constructor(t){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)}startDraw(t,e){this.isDrawing=!0,this.currentPoints=[[t,e]],this.currentPath=this.createPath(),this.svg.appendChild(this.currentPath)}continueDraw(t,e){!this.isDrawing||!this.currentPath||(this.currentPoints.push([t,e]),this.currentPath.setAttribute("d",wt(this.currentPoints)))}getCurrentSpan(){const[t]=this.currentPoints;if(!t)return 0;let e=0;for(const[r,n]of this.currentPoints)e=Math.max(e,Math.hypot(r-t[0],n-t[1]));return e}commitStroke(){return!this.isDrawing||!this.currentPath?!1:(this.isDrawing=!1,this.committed.push({path:this.currentPath,d:wt(this.currentPoints),points:this.currentPoints}),this.redoStack=[],this.currentPath=null,this.currentPoints=[],!0)}cancelCurrentDraw(){this.currentPath?.remove(),this.currentPath=null,this.isDrawing=!1,this.currentPoints=[]}undo(){const t=this.committed.pop();return t?(t.path.remove(),this.redoStack.push({d:t.d,points:t.points}),!0):!1}redo(){const t=this.redoStack.pop();if(!t)return!1;const e=this.createPath();return e.setAttribute("d",t.d),this.svg.appendChild(e),this.committed.push({path:e,d:t.d,points:t.points}),!0}canUndo(){return this.committed.length>0}canRedo(){return this.redoStack.length>0}hasStrokes(){return this.committed.length>0}getAnnotation(){if(this.committed.length===0)return null;const t=this.committed.flatMap(n=>n.points),[e,r]=Ze(t);return{type:"draw",x:e,y:r,drawPath:this.committed.map(n=>n.d).join(" ")}}clearAll(){for(;this.svg.firstChild;)this.svg.removeChild(this.svg.firstChild);this.currentPath=null,this.isDrawing=!1,this.currentPoints=[],this.committed=[],this.redoStack=[]}isCurrentlyDrawing(){return this.isDrawing}destroy(){this.svg.remove()}createPath(){const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("fill","none"),t.setAttribute("stroke",L.color),t.setAttribute("stroke-width",L.width),t.setAttribute("stroke-linecap",L.linecap),t.setAttribute("stroke-linejoin",L.linejoin),t.setAttribute("style",`filter:${L.filter}`),t}}function wt(i){if(i.length===0)return"";const[t,e]=i[0];let r=`M ${t} ${e}`;for(let n=1;n<i.length;n++){const[s,o]=i[n];r+=` L ${s} ${o}`}return r}function Ze(i){const t=i.map(s=>s[0]),e=i.map(s=>s[1]),r=(Math.min(...t)+Math.max(...t))/2,n=(Math.min(...e)+Math.max(...e))/2;return[r,n]}const g="[Filtered]",Qe=/-----BEGIN ((?:[A-Z0-9]+ )*PRIVATE KEY)-----[\s\S]*?-----END \1-----/g,ti=/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g,ei=[/\bsk-(?:proj-)?[A-Za-z0-9_-]{20,}\b/g,/\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{20,}\b/g,/\bgh[pousr]_[A-Za-z0-9]{30,}\b/g,/\bAKIA[0-9A-Z]{16}\b/g,/\bxox[baprs]-[A-Za-z0-9-]{20,}\b/g],ii=/\b(?:\d[ -]?){12,18}\d\b/g,ri=/\bhttps?:\/\/[^\s<>"']+/gi,ni=new Set(["type","autocomplete","name","id","aria_label","placeholder"]),si=new Set(["value","content"]),oi=new Set(["password","hidden","file"]),ai=new Set(["current_password","new_password","one_time_code","cc_number","cc_csc","cc_exp","cc_exp_month","cc_exp_year"]),li=/(?:^|_)(?:password|passwd|passcode|card_(?:number|no)(?:_[0-9]+)?|credit_card|cc_(?:number|num|csc|cvv|cvc|exp|expiry)|cvv|cvc|csc|security_code|one_time_(?:code|password)|otp(?:_code)?|verification_code|auth(?:entication)?_token|access_token|refresh_token|id_token|token|api_key|client_secret|secret|authorization|cookie|set_cookie|credential|private_key|hidden_value|file_name|filename)(?:$|_(?:value|field|input|confirmation|confirm|header|data|pem)$)/;function A(i){let t=i.replace(Qe,g).replace(ti,g);for(const e of ei)t=t.replace(e,g);return t=t.replace(ii,e=>ci(e)?g:e),t.replace(ri,e=>B(e)||g)}function B(i){try{const t=new URL(i);return`${t.origin}${t.pathname}`}catch{return""}}function j(i,t){if(t&&Qt(t)&&i!=null)return g;if(typeof i=="string")return A(i);if(Array.isArray(i))return i.map(e=>j(e));if(i&&typeof i=="object"){const e=te(i);return Object.fromEntries(Object.entries(i).map(([n,s])=>{const o=e&&si.has(R(n))&&s!=null?g:j(s,n);return[A(n),o]}))}return i}function Qt(i){return li.test(R(i))}function te(i){return Object.entries(i).some(([t,e])=>{if(typeof e!="string")return!1;const r=R(t);return ni.has(r)?r==="type"?oi.has(R(e)):r==="autocomplete"?e.split(/\s+/).some(n=>ai.has(R(n))):Qt(e):!1})}function R(i){return i.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function ci(i){const t=i.replace(/\D/g,"");if(t.length<13||t.length>19)return!1;let e=0,r=!1;for(let n=t.length-1;n>=0;n-=1){let s=Number(t[n]);r&&(s*=2,s>9&&(s-=9)),e+=s,r=!r}return e%10===0}function ee(i){return te({type:i.getAttribute("type"),autocomplete:i.getAttribute("autocomplete"),name:i.getAttribute("name"),id:i.id,"aria-label":i.getAttribute("aria-label"),placeholder:i.getAttribute("placeholder")})}function W(i,t){return i&&(ee(t)?g:A(i))}const di=512;function ie(){return new WeakMap}function re(i,t){let e=i.parentElement;for(;e&&e!==document.body&&e!==document.documentElement;){const r=ne(e,t);if(r==="sensitive")return!0;if(r==="contains-sensitive-child"||r==="too-large")return!1;e=e.parentElement}return!1}function ne(i,t){const e=t.get(i);if(e)return e;const r=i.textContent??"";let n="none";return r.length>di?n="too-large":A(r)!==r&&(n=Array.from(i.children).some(o=>{const a=ne(o,t);return a==="sensitive"||a==="contains-sensitive-child"})?"contains-sensitive-child":"sensitive"),t.set(i,n),n}const hi=60,vt=["value","content"],ui=Object.fromEntries(["button","checkbox","color","date","datetime-local","email","file","hidden","image","month","number","password","radio","range","reset","search","select","submit","tel","text","textarea","time","url","week"].map(i=>[i,!0])),J="rr-block",U="rr-mask",mi="https://cdn.jsdelivr.net/npm/@rrweb/record@2.1.0/umd/record.min.js",bi="sha384-MrD66HBNSykaP2N95+6hQCFlF5oH2tvL3TD/zyvHNkP/sAFWZx98DX9MEDy8MdVT";let z=null;function pi(){return z||(z=gi().catch(()=>yi()),z)}function fi(i,t){const e=j(i);return ot(e,t,ie()),e}function ot(i,t,e){if(Array.isArray(i)){i.forEach(a=>ot(a,t,e));return}if(!xt(i))return;const r=xt(i.attributes)?i.attributes:null,n=r&&vt.some(a=>typeof r[a]=="string"),o=(typeof i.text=="string"||typeof i.textContent=="string"||typeof i.value=="string"||n)&&typeof i.id=="number"?t.mirror.getNode(i.id):null;if(o instanceof Element){if(typeof i.text=="string"&&(i.text=W(i.text,o)),r)for(const a of vt){const l=r[a];typeof l=="string"&&(r[a]=W(l,o))}}else o?.nodeType===Node.TEXT_NODE&&re(o,e)&&(typeof i.textContent=="string"&&(i.textContent=g),typeof i.value=="string"&&(i.value=g));Object.values(i).forEach(a=>ot(a,t,e))}function xt(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}async function gi(){return(await import("@rrweb/record")).record}function kt(){const i=globalThis;return i.rrwebRecord?.record??i.rrweb?.record}function yi(){return new Promise((i,t)=>{const e=kt();if(e){i(e);return}const r=document.createElement("script");r.src=mi,r.integrity=bi,r.crossOrigin="anonymous",r.onload=()=>{const n=kt();n?i(n):t(new Error("rrweb record global not found after script load"))},r.onerror=()=>t(new Error("Failed to load rrweb from CDN")),document.head.appendChild(r)})}class wi{constructor(t,e){this.events=[],this.stopFn=null,this.startedAt=0,this.timer=null,this.clickHandler=null,this.stopped=!1,this.destroyed=!1,this.shadow=t,this.onMaxReached=e}async start(){const t=await pi();this.destroyed||(this.startedAt=Date.now(),this.stopped=!1,this.stopFn=t({emit:e=>{if(!this.stopped)try{this.events.push(fi(e,t))}catch{}},maskAllInputs:!1,maskInputOptions:ui,maskInputFn:(e,r)=>r.closest(`.${U}`)?g:W(e,r),maskTextFn:()=>g,blockClass:J,maskTextClass:U}),this.clickHandler=e=>{this.showClickRipple(e.clientX,e.clientY),t.addCustomEvent?.("mtb-click",{x:e.clientX,y:e.clientY,target:e.target instanceof HTMLElement?e.target.tagName:""})},document.addEventListener("click",this.clickHandler,!0),this.timer=setTimeout(()=>{this.onMaxReached?.()},hi*1e3))}stop(){return this.stopped=!0,this.stopFn?.(),this.stopFn=null,this.cleanupTimer(),this.cleanupClickHandler(),{events:this.events,duration:this.getDuration()}}getDuration(){return this.startedAt===0?0:Math.max(1,Math.round((Date.now()-this.startedAt)/1e3))}destroy(){this.destroyed=!0,this.stopped=!0,this.stopFn?.(),this.stopFn=null,this.cleanupTimer(),this.cleanupClickHandler(),this.events=[],this.startedAt=0}cleanupTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null)}cleanupClickHandler(){this.clickHandler&&(document.removeEventListener("click",this.clickHandler,!0),this.clickHandler=null)}showClickRipple(t,e){const r=this.shadow.el("div","mtb-click-ripple");r.style.left=`${t}px`,r.style.top=`${e}px`,this.shadow.append(r),r.addEventListener("animationend",()=>r.remove())}}const vi=`.${J}, .${U}`;function Z(i){return i.closest(vi)!==null}function mt(i){const t=i.getAttribute("role")?.trim().split(/\s+/)[0];return t&&/^[a-z][a-z0-9-]*$/i.test(t)?t:i.tagName.toLowerCase()}function se(i){return i.tagName.toLowerCase()}const xi=10;function St(i){return Z(i)?{name:mt(i),text:"",selector:se(i)}:{name:ht(i),text:i.textContent?.trim().slice(0,200)??"",selector:Zt(i)}}class ki{constructor(t,e,r){this.messages=e,this.handlers=r,this.interactionActive=!0,this.pendingHighlightFrame=null,this.lastMoveX=0,this.lastMoveY=0,this.touch=x(),this.highlighter=new Ve(t),this.pinMarker=new Xe(t),this.drawLayer=new Je(t),this.overlay=new We(t,{onPointerDown:n=>this.handlePointerDown(n),onPointerMove:n=>this.handlePointerMove(n),onPointerUp:n=>this.handlePointerUp(n),onPointerCancel:()=>{this.drawLayer.isCurrentlyDrawing()&&this.finishStroke(),this.cancelPendingHighlight(),this.highlighter.hide()}})}handlePointerDown(t){t.preventDefault(),this.drawLayer.startDraw(t.clientX,t.clientY)}handlePointerMove(t){if(this.drawLayer.isCurrentlyDrawing()){this.cancelPendingHighlight(),this.drawLayer.continueDraw(t.clientX,t.clientY),this.highlighter.hide();return}this.lastMoveX=t.clientX,this.lastMoveY=t.clientY,this.pendingHighlightFrame===null&&(this.pendingHighlightFrame=requestAnimationFrame(()=>{this.pendingHighlightFrame=null,this.updateHighlight()}))}updateHighlight(){if(!this.interactionActive||this.drawLayer.isCurrentlyDrawing()||this.drawSessionActive())return;const t=tt(this.lastMoveX,this.lastMoveY);t?this.highlighter.highlight(t):this.highlighter.hide()}cancelPendingHighlight(){this.pendingHighlightFrame!==null&&(cancelAnimationFrame(this.pendingHighlightFrame),this.pendingHighlightFrame=null)}handlePointerUp(t){this.drawLayer.isCurrentlyDrawing()&&this.finishStroke(t)}finishStroke(t){if(this.drawLayer.getCurrentSpan()>=xi){this.drawLayer.commitStroke(),this.highlighter.hide(),this.handlers.onDrawStroke();return}if(this.drawLayer.cancelCurrentDraw(),this.touch||this.drawLayer.hasStrokes()||!t)return;const e=tt(t.clientX,t.clientY),r=e?St(e):null,n=r?.name??this.messages.annotation.element,s=e?.getBoundingClientRect(),o={type:"pin",x:t.clientX,y:t.clientY,targetSelector:r?.selector,targetText:r?.text??"",targetName:n,targetRect:s?{top:s.top,left:s.left,width:s.width,height:s.height,bottom:s.bottom}:void 0};this.pinMarker.addPin(t.clientX,t.clientY),this.highlighter.select(),this.handlers.onPin(o,n)}undoDraw(){this.drawLayer.undo()}redoDraw(){this.drawLayer.redo()}canUndoDraw(){return this.drawLayer.canUndo()}canRedoDraw(){return this.drawLayer.canRedo()}hasDrawStrokes(){return this.drawLayer.hasStrokes()}drawSessionActive(){return this.drawLayer.hasStrokes()||this.drawLayer.canRedo()}getDrawAnnotation(){const t=this.drawLayer.getAnnotation();if(!t)return null;const e=tt(t.x,t.y);if(!e)return t;const r=e.getBoundingClientRect(),n=St(e);return{...t,targetSelector:n.selector,targetText:n.text,targetName:n.name,targetRect:{top:r.top,left:r.left,width:r.width,height:r.height,bottom:r.bottom}}}clearDraw(){this.drawLayer.clearAll()}dismissInteraction(){this.interactionActive&&(this.interactionActive=!1,this.cancelPendingHighlight(),this.overlay.destroy())}hideHighlight(){this.highlighter.hide()}destroy(){this.dismissInteraction(),this.highlighter.destroy(),this.pinMarker.destroy(),this.drawLayer.destroy()}}function tt(i,t){return document.elementsFromPoint(i,t).find(e=>e.id!=="mtb-widget-host")??null}const Si="mtb-widget-host";function C(i){const t=document.getElementById(Si);return t?t===i||t.contains(i):!1}function h(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}const Ei=140;class Ci{constructor(){this.onChange=null,this.timer=null,this.lastReading=null,this.handler=()=>{this.timer!==null&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=null;const t=this.current();if(t===this.lastReading){this.lastReading=null,this.onChange?.(t);return}this.lastReading=t,this.handler()},Ei)}}current(){const t=window.visualViewport;if(!t||t.height<=0)return 0;const e=Math.round(window.innerHeight-(t.height+t.offsetTop));return Math.min(Math.max(0,e),window.innerHeight)}observe(t){const e=window.visualViewport;e&&(this.onChange=t,e.addEventListener("resize",this.handler),e.addEventListener("scroll",this.handler))}stop(){const t=window.visualViewport;this.onChange=null,this.lastReading=null,this.timer!==null&&(clearTimeout(this.timer),this.timer=null),t&&(t.removeEventListener("resize",this.handler),t.removeEventListener("scroll",this.handler))}}const _i=480;function Ti(){return window.innerWidth<=_i}class bt{constructor(t){this.el=t,this.inset=new Ci}apply(){return Ti()?(this.el.style.left="",this.el.style.top="",this.el.style.maxHeight="",this.lift(this.inset.current()),this.inset.observe(t=>this.lift(t)),!0):!1}release(){this.inset.stop()}lift(t){const e=Math.max(0,window.innerHeight-this.el.offsetHeight),r=Math.min(t,e);this.el.style.bottom=r>0?`${r}px`:""}}class Ai{constructor(t,e){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.sheet=new bt(this.el),this.sheet.apply(),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.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=>{r.isComposing||r.keyCode===229||r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),this.submit())}),this.input.focus({preventScroll:!0})}buildHTML(t){return`
24
- <input class="mtb-draw-input" type="text" placeholder="${h(t.draw.note_placeholder)}" />
25
- <button class="mtb-draw-icon-btn mtb-draw-undo" type="button" title="${h(t.draw.undo)}" aria-label="${h(t.draw.undo)}" disabled>
23
+ `}idleHint(){return this.touch?this.messages.toolbar.hintTouch:this.messages.toolbar.hint}setMode(t){this.currentMode=t,t==="markup"?(this.markupBtn.classList.add("active"),this.recordBtn.classList.remove("active"),this.hintTextEl.textContent=this.idleHint()):(this.markupBtn.classList.remove("active"),this.recordBtn.classList.add("active"),this.hintTextEl.textContent=this.messages.toolbar.hintRecord)}getMode(){return this.currentMode}height(){return this.el.getBoundingClientRect().height||je}destroy(){document.removeEventListener("pointermove",this.handlePointerMove),document.removeEventListener("pointerdown",this.dismissTouchHint,!0),this.host.removeAttribute("data-mtb-toolbar"),this.hintBarEl.remove(),this.el.remove()}}class Ve{constructor(t,e){this.handlers=e,this.overlayEl=t.el("div","mtb-overlay"),this.onPointerDown=r=>{const n=r;if(n.isPrimary){try{this.overlayEl.setPointerCapture(n.pointerId)}catch{}this.handlers.onPointerDown(n)}},this.onPointerMove=r=>{const n=r;n.isPrimary&&this.handlers.onPointerMove(n)},this.onPointerUp=r=>{const n=r;n.isPrimary&&(this.releaseCapture(n.pointerId),this.handlers.onPointerUp(n))},this.onPointerCancel=r=>{const n=r;n.isPrimary&&(this.releaseCapture(n.pointerId),this.handlers.onPointerCancel(n))},this.overlayEl.addEventListener("pointerdown",this.onPointerDown),this.overlayEl.addEventListener("pointermove",this.onPointerMove),this.overlayEl.addEventListener("pointerup",this.onPointerUp),this.overlayEl.addEventListener("pointercancel",this.onPointerCancel),t.append(this.overlayEl),this.dimEl=t.el("div","mtb-dim"),t.append(this.dimEl)}releaseCapture(t){try{this.overlayEl.releasePointerCapture(t)}catch{}}destroy(){this.overlayEl.removeEventListener("pointerdown",this.onPointerDown),this.overlayEl.removeEventListener("pointermove",this.onPointerMove),this.overlayEl.removeEventListener("pointerup",this.onPointerUp),this.overlayEl.removeEventListener("pointercancel",this.onPointerCancel),this.overlayEl.remove(),this.dimEl.remove()}}class Ye{constructor(t){this.highlightEl=t.el("div","mtb-highlight"),this.tooltipEl=t.el("div","mtb-highlight-tooltip"),this.hide(),t.append(this.highlightEl,this.tooltipEl)}highlight(t){const e=t.getBoundingClientRect();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)}showTooltip(t,e){this.tooltipEl.textContent=ht(t);const r=e.top<30;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"}select(){this.highlightEl.classList.add("selected"),this.tooltipEl.style.display="none"}hide(){this.highlightEl.style.display="none",this.highlightEl.classList.remove("selected"),this.tooltipEl.style.display="none"}destroy(){this.highlightEl.remove(),this.tooltipEl.remove()}}const Xe=/^(script|style|noscript|template)$/i;function Jt(i,t=80){let e="";for(const r of Array.from(i.childNodes)){if(e.length>=t)break;r.nodeType===3?e+=r.nodeValue??"":r instanceof Element&&!Xe.test(r.tagName)&&(e+=Jt(r,t-e.length))}return e}function ht(i){if(i instanceof HTMLElement){const t=i.getAttribute("aria-label");if(t)return t;const e=i.getAttribute("title");if(e)return e;const r=Jt(i).trim().slice(0,40);if(r)return r;const n=i.placeholder;if(n)return n;const s=i.alt;if(s)return s;const o=i.getAttribute("data-mark");if(o)return o}return i.tagName.toLowerCase()}function Zt(i){const t=[];let e=i;for(;e&&e!==document.body&&t.length<5;){let r=e.tagName.toLowerCase();if(e.id){r=`#${e.id}`,t.unshift(r);break}const n=Array.from(e.classList).filter(o=>!o.startsWith("mtb-")).slice(0,2).join(".");n&&(r+=`.${n}`);const s=e.parentElement;if(s){const o=Array.from(s.children).filter(a=>a.tagName===e.tagName);if(o.length>1){const a=o.indexOf(e)+1;r+=`:nth-of-type(${a})`}}t.unshift(r),e=e.parentElement}return t.join(" > ")}class Ke{constructor(t){this.pins=[],this.shadow=t}addPin(t,e){const r=this.shadow.el("div","mtb-pin");r.style.top=`${e}px`,r.style.left=`${t}px`,this.shadow.append(r),this.pins.push(r)}clearAll(){for(const t of this.pins)t.remove();this.pins=[]}destroy(){this.clearAll()}}const G="#059669",Ge="5,150,105";function ut(i){return`rgba(${Ge},${i})`}const Je='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',L={color:G,width:"3.5",linecap:"round",linejoin:"round",filter:`drop-shadow(0 1px 2px ${ut(.35)})`};class Ze{constructor(t){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)}startDraw(t,e){this.isDrawing=!0,this.currentPoints=[[t,e]],this.currentPath=this.createPath(),this.svg.appendChild(this.currentPath)}continueDraw(t,e){!this.isDrawing||!this.currentPath||(this.currentPoints.push([t,e]),this.currentPath.setAttribute("d",wt(this.currentPoints)))}getCurrentSpan(){const[t]=this.currentPoints;if(!t)return 0;let e=0;for(const[r,n]of this.currentPoints)e=Math.max(e,Math.hypot(r-t[0],n-t[1]));return e}commitStroke(){return!this.isDrawing||!this.currentPath?!1:(this.isDrawing=!1,this.committed.push({path:this.currentPath,d:wt(this.currentPoints),points:this.currentPoints}),this.redoStack=[],this.currentPath=null,this.currentPoints=[],!0)}cancelCurrentDraw(){this.currentPath?.remove(),this.currentPath=null,this.isDrawing=!1,this.currentPoints=[]}undo(){const t=this.committed.pop();return t?(t.path.remove(),this.redoStack.push({d:t.d,points:t.points}),!0):!1}redo(){const t=this.redoStack.pop();if(!t)return!1;const e=this.createPath();return e.setAttribute("d",t.d),this.svg.appendChild(e),this.committed.push({path:e,d:t.d,points:t.points}),!0}canUndo(){return this.committed.length>0}canRedo(){return this.redoStack.length>0}hasStrokes(){return this.committed.length>0}getAnnotation(){if(this.committed.length===0)return null;const t=this.committed.flatMap(n=>n.points),[e,r]=Qe(t);return{type:"draw",x:e,y:r,drawPath:this.committed.map(n=>n.d).join(" ")}}clearAll(){for(;this.svg.firstChild;)this.svg.removeChild(this.svg.firstChild);this.currentPath=null,this.isDrawing=!1,this.currentPoints=[],this.committed=[],this.redoStack=[]}isCurrentlyDrawing(){return this.isDrawing}destroy(){this.svg.remove()}createPath(){const t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.setAttribute("fill","none"),t.setAttribute("stroke",L.color),t.setAttribute("stroke-width",L.width),t.setAttribute("stroke-linecap",L.linecap),t.setAttribute("stroke-linejoin",L.linejoin),t.setAttribute("style",`filter:${L.filter}`),t}}function wt(i){if(i.length===0)return"";const[t,e]=i[0];let r=`M ${t} ${e}`;for(let n=1;n<i.length;n++){const[s,o]=i[n];r+=` L ${s} ${o}`}return r}function Qe(i){const t=i.map(s=>s[0]),e=i.map(s=>s[1]),r=(Math.min(...t)+Math.max(...t))/2,n=(Math.min(...e)+Math.max(...e))/2;return[r,n]}const g="[Filtered]",ti=/-----BEGIN ((?:[A-Z0-9]+ )*PRIVATE KEY)-----[\s\S]*?-----END \1-----/g,ei=/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g,ii=[/\bsk-(?:proj-)?[A-Za-z0-9_-]{20,}\b/g,/\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{20,}\b/g,/\bgh[pousr]_[A-Za-z0-9]{30,}\b/g,/\bAKIA[0-9A-Z]{16}\b/g,/\bxox[baprs]-[A-Za-z0-9-]{20,}\b/g],ri=/\b(?:\d[ -]?){12,18}\d\b/g,ni=/\bhttps?:\/\/[^\s<>"']+/gi,si=new Set(["type","autocomplete","name","id","aria_label","placeholder"]),oi=new Set(["value","content"]),ai=new Set(["password","hidden","file"]),li=new Set(["current_password","new_password","one_time_code","cc_number","cc_csc","cc_exp","cc_exp_month","cc_exp_year"]),ci=/(?:^|_)(?:password|passwd|passcode|card_(?:number|no)(?:_[0-9]+)?|credit_card|cc_(?:number|num|csc|cvv|cvc|exp|expiry)|cvv|cvc|csc|security_code|one_time_(?:code|password)|otp(?:_code)?|verification_code|auth(?:entication)?_token|access_token|refresh_token|id_token|token|api_key|client_secret|secret|authorization|cookie|set_cookie|credential|private_key|hidden_value|file_name|filename)(?:$|_(?:value|field|input|confirmation|confirm|header|data|pem)$)/;function A(i){let t=i.replace(ti,g).replace(ei,g);for(const e of ii)t=t.replace(e,g);return t=t.replace(ri,e=>di(e)?g:e),t.replace(ni,e=>B(e)||g)}function B(i){try{const t=new URL(i);return`${t.origin}${t.pathname}`}catch{return""}}function j(i,t){if(t&&Qt(t)&&i!=null)return g;if(typeof i=="string")return A(i);if(Array.isArray(i))return i.map(e=>j(e));if(i&&typeof i=="object"){const e=te(i);return Object.fromEntries(Object.entries(i).map(([n,s])=>{const o=e&&oi.has(R(n))&&s!=null?g:j(s,n);return[A(n),o]}))}return i}function Qt(i){return ci.test(R(i))}function te(i){return Object.entries(i).some(([t,e])=>{if(typeof e!="string")return!1;const r=R(t);return si.has(r)?r==="type"?ai.has(R(e)):r==="autocomplete"?e.split(/\s+/).some(n=>li.has(R(n))):Qt(e):!1})}function R(i){return i.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}function di(i){const t=i.replace(/\D/g,"");if(t.length<13||t.length>19)return!1;let e=0,r=!1;for(let n=t.length-1;n>=0;n-=1){let s=Number(t[n]);r&&(s*=2,s>9&&(s-=9)),e+=s,r=!r}return e%10===0}function ee(i){return te({type:i.getAttribute("type"),autocomplete:i.getAttribute("autocomplete"),name:i.getAttribute("name"),id:i.id,"aria-label":i.getAttribute("aria-label"),placeholder:i.getAttribute("placeholder")})}function W(i,t){return i&&(ee(t)?g:A(i))}const hi=512;function ie(){return new WeakMap}function re(i,t){let e=i.parentElement;for(;e&&e!==document.body&&e!==document.documentElement;){const r=ne(e,t);if(r==="sensitive")return!0;if(r==="contains-sensitive-child"||r==="too-large")return!1;e=e.parentElement}return!1}function ne(i,t){const e=t.get(i);if(e)return e;const r=i.textContent??"";let n="none";return r.length>hi?n="too-large":A(r)!==r&&(n=Array.from(i.children).some(o=>{const a=ne(o,t);return a==="sensitive"||a==="contains-sensitive-child"})?"contains-sensitive-child":"sensitive"),t.set(i,n),n}const ui=60,vt=["value","content"],mi=Object.fromEntries(["button","checkbox","color","date","datetime-local","email","file","hidden","image","month","number","password","radio","range","reset","search","select","submit","tel","text","textarea","time","url","week"].map(i=>[i,!0])),J="rr-block",U="rr-mask",bi="https://cdn.jsdelivr.net/npm/@rrweb/record@2.1.0/umd/record.min.js",pi="sha384-MrD66HBNSykaP2N95+6hQCFlF5oH2tvL3TD/zyvHNkP/sAFWZx98DX9MEDy8MdVT";let z=null;function fi(){return z||(z=yi().catch(()=>wi()),z)}function gi(i,t){const e=j(i);return ot(e,t,ie()),e}function ot(i,t,e){if(Array.isArray(i)){i.forEach(a=>ot(a,t,e));return}if(!xt(i))return;const r=xt(i.attributes)?i.attributes:null,n=r&&vt.some(a=>typeof r[a]=="string"),o=(typeof i.text=="string"||typeof i.textContent=="string"||typeof i.value=="string"||n)&&typeof i.id=="number"?t.mirror.getNode(i.id):null;if(o instanceof Element){if(typeof i.text=="string"&&(i.text=W(i.text,o)),r)for(const a of vt){const l=r[a];typeof l=="string"&&(r[a]=W(l,o))}}else o?.nodeType===Node.TEXT_NODE&&re(o,e)&&(typeof i.textContent=="string"&&(i.textContent=g),typeof i.value=="string"&&(i.value=g));Object.values(i).forEach(a=>ot(a,t,e))}function xt(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}async function yi(){return(await import("@rrweb/record")).record}function kt(){const i=globalThis;return i.rrwebRecord?.record??i.rrweb?.record}function wi(){return new Promise((i,t)=>{const e=kt();if(e){i(e);return}const r=document.createElement("script");r.src=bi,r.integrity=pi,r.crossOrigin="anonymous",r.onload=()=>{const n=kt();n?i(n):t(new Error("rrweb record global not found after script load"))},r.onerror=()=>t(new Error("Failed to load rrweb from CDN")),document.head.appendChild(r)})}class vi{constructor(t,e){this.events=[],this.stopFn=null,this.startedAt=0,this.timer=null,this.clickHandler=null,this.stopped=!1,this.destroyed=!1,this.shadow=t,this.onMaxReached=e}async start(){const t=await fi();this.destroyed||(this.startedAt=Date.now(),this.stopped=!1,this.stopFn=t({emit:e=>{if(!this.stopped)try{this.events.push(gi(e,t))}catch{}},maskAllInputs:!1,maskInputOptions:mi,maskInputFn:(e,r)=>r.closest(`.${U}`)?g:W(e,r),maskTextFn:()=>g,blockClass:J,maskTextClass:U}),this.clickHandler=e=>{this.showClickRipple(e.clientX,e.clientY),t.addCustomEvent?.("mtb-click",{x:e.clientX,y:e.clientY,target:e.target instanceof HTMLElement?e.target.tagName:""})},document.addEventListener("click",this.clickHandler,!0),this.timer=setTimeout(()=>{this.onMaxReached?.()},ui*1e3))}stop(){return this.stopped=!0,this.stopFn?.(),this.stopFn=null,this.cleanupTimer(),this.cleanupClickHandler(),{events:this.events,duration:this.getDuration()}}getDuration(){return this.startedAt===0?0:Math.max(1,Math.round((Date.now()-this.startedAt)/1e3))}destroy(){this.destroyed=!0,this.stopped=!0,this.stopFn?.(),this.stopFn=null,this.cleanupTimer(),this.cleanupClickHandler(),this.events=[],this.startedAt=0}cleanupTimer(){this.timer&&(clearTimeout(this.timer),this.timer=null)}cleanupClickHandler(){this.clickHandler&&(document.removeEventListener("click",this.clickHandler,!0),this.clickHandler=null)}showClickRipple(t,e){const r=this.shadow.el("div","mtb-click-ripple");r.style.left=`${t}px`,r.style.top=`${e}px`,this.shadow.append(r),r.addEventListener("animationend",()=>r.remove())}}const xi=`.${J}, .${U}`;function Z(i){return i.closest(xi)!==null}function mt(i){const t=i.getAttribute("role")?.trim().split(/\s+/)[0];return t&&/^[a-z][a-z0-9-]*$/i.test(t)?t:i.tagName.toLowerCase()}function se(i){return i.tagName.toLowerCase()}const ki=10;function St(i){return Z(i)?{name:mt(i),text:"",selector:se(i)}:{name:ht(i),text:i.textContent?.trim().slice(0,200)??"",selector:Zt(i)}}class Si{constructor(t,e,r){this.messages=e,this.handlers=r,this.interactionActive=!0,this.pendingHighlightFrame=null,this.lastMoveX=0,this.lastMoveY=0,this.touch=x(),this.highlighter=new Ye(t),this.pinMarker=new Ke(t),this.drawLayer=new Ze(t),this.overlay=new Ve(t,{onPointerDown:n=>this.handlePointerDown(n),onPointerMove:n=>this.handlePointerMove(n),onPointerUp:n=>this.handlePointerUp(n),onPointerCancel:()=>{this.drawLayer.isCurrentlyDrawing()&&this.finishStroke(),this.cancelPendingHighlight(),this.highlighter.hide()}})}handlePointerDown(t){t.preventDefault(),this.drawLayer.startDraw(t.clientX,t.clientY)}handlePointerMove(t){if(this.drawLayer.isCurrentlyDrawing()){this.cancelPendingHighlight(),this.drawLayer.continueDraw(t.clientX,t.clientY),this.highlighter.hide();return}this.lastMoveX=t.clientX,this.lastMoveY=t.clientY,this.pendingHighlightFrame===null&&(this.pendingHighlightFrame=requestAnimationFrame(()=>{this.pendingHighlightFrame=null,this.updateHighlight()}))}updateHighlight(){if(!this.interactionActive||this.drawLayer.isCurrentlyDrawing()||this.drawSessionActive())return;const t=tt(this.lastMoveX,this.lastMoveY);t?this.highlighter.highlight(t):this.highlighter.hide()}cancelPendingHighlight(){this.pendingHighlightFrame!==null&&(cancelAnimationFrame(this.pendingHighlightFrame),this.pendingHighlightFrame=null)}handlePointerUp(t){this.drawLayer.isCurrentlyDrawing()&&this.finishStroke(t)}finishStroke(t){if(this.drawLayer.getCurrentSpan()>=ki){this.drawLayer.commitStroke(),this.highlighter.hide(),this.handlers.onDrawStroke();return}if(this.drawLayer.cancelCurrentDraw(),this.touch||this.drawLayer.hasStrokes()||!t)return;const e=tt(t.clientX,t.clientY),r=e?St(e):null,n=r?.name??this.messages.annotation.element,s=e?.getBoundingClientRect(),o={type:"pin",x:t.clientX,y:t.clientY,targetSelector:r?.selector,targetText:r?.text??"",targetName:n,targetRect:s?{top:s.top,left:s.left,width:s.width,height:s.height,bottom:s.bottom}:void 0};this.pinMarker.addPin(t.clientX,t.clientY),this.highlighter.select(),this.handlers.onPin(o,n)}undoDraw(){this.drawLayer.undo()}redoDraw(){this.drawLayer.redo()}canUndoDraw(){return this.drawLayer.canUndo()}canRedoDraw(){return this.drawLayer.canRedo()}hasDrawStrokes(){return this.drawLayer.hasStrokes()}drawSessionActive(){return this.drawLayer.hasStrokes()||this.drawLayer.canRedo()}getDrawAnnotation(){const t=this.drawLayer.getAnnotation();if(!t)return null;const e=tt(t.x,t.y);if(!e)return t;const r=e.getBoundingClientRect(),n=St(e);return{...t,targetSelector:n.selector,targetText:n.text,targetName:n.name,targetRect:{top:r.top,left:r.left,width:r.width,height:r.height,bottom:r.bottom}}}clearDraw(){this.drawLayer.clearAll()}dismissInteraction(){this.interactionActive&&(this.interactionActive=!1,this.cancelPendingHighlight(),this.overlay.destroy())}hideHighlight(){this.highlighter.hide()}destroy(){this.dismissInteraction(),this.highlighter.destroy(),this.pinMarker.destroy(),this.drawLayer.destroy()}}function tt(i,t){return document.elementsFromPoint(i,t).find(e=>e.id!=="mtb-widget-host")??null}const Ei=140;class Ci{constructor(){this.onChange=null,this.timer=null,this.lastReading=null,this.handler=()=>{this.timer!==null&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=null;const t=this.current();if(t===this.lastReading){this.lastReading=null,this.onChange?.(t);return}this.lastReading=t,this.handler()},Ei)}}current(){const t=window.visualViewport;if(!t||t.height<=0)return 0;const e=Math.round(window.innerHeight-(t.height+t.offsetTop));return Math.min(Math.max(0,e),window.innerHeight)}observe(t){const e=window.visualViewport;e&&(this.onChange=t,e.addEventListener("resize",this.handler),e.addEventListener("scroll",this.handler))}stop(){const t=window.visualViewport;this.onChange=null,this.lastReading=null,this.timer!==null&&(clearTimeout(this.timer),this.timer=null),t&&(t.removeEventListener("resize",this.handler),t.removeEventListener("scroll",this.handler))}}const _i=480;function Ti(){return window.innerWidth<=_i}class bt{constructor(t){this.el=t,this.inset=new Ci}apply(){return Ti()?(this.el.style.left="",this.el.style.top="",this.el.style.maxHeight="",this.lift(this.inset.current()),this.inset.observe(t=>this.lift(t)),!0):!1}release(){this.inset.stop()}lift(t){const e=Math.max(0,window.innerHeight-this.el.offsetHeight),r=Math.min(t,e);this.el.style.bottom=r>0?`${r}px`:""}}class Ai{constructor(t,e){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.sheet=new bt(this.el),this.sheet.apply(),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.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=>{r.isComposing||r.keyCode===229||r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),this.submit())}),this.input.focus({preventScroll:!0})}buildHTML(t){return`
24
+ <input class="mtb-draw-input" type="text" placeholder="${c(t.draw.note_placeholder)}" />
25
+ <button class="mtb-draw-icon-btn mtb-draw-undo" type="button" title="${c(t.draw.undo)}" aria-label="${c(t.draw.undo)}" disabled>
26
26
  <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>
27
27
  </button>
28
- <button class="mtb-draw-icon-btn mtb-draw-redo" type="button" title="${h(t.draw.redo)}" aria-label="${h(t.draw.redo)}" disabled>
28
+ <button class="mtb-draw-icon-btn mtb-draw-redo" type="button" title="${c(t.draw.redo)}" aria-label="${c(t.draw.redo)}" disabled>
29
29
  <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>
30
30
  </button>
31
31
  <span class="mtb-draw-sep"></span>
32
- <button class="mtb-draw-cancel" type="button">${h(t.draw.cancel)}</button>
33
- <button class="mtb-draw-submit" type="button">${h(t.draw.submit)}</button>
32
+ <button class="mtb-draw-cancel" type="button">${c(t.draw.cancel)}</button>
33
+ <button class="mtb-draw-submit" type="button">${c(t.draw.submit)}</button>
34
34
  `}setUndoRedo(t,e){this.undoBtn.disabled=!t,this.redoBtn.disabled=!e}submit(){this.onSubmit(this.input.value.trim())}destroy(){this.sheet.release(),this.el.remove()}}function Li(i){let t=!1;const e=()=>{t=!0},r=n=>{n.detail>0&&!t&&(n.stopPropagation(),n.preventDefault()),t=!1};return i.addEventListener("pointerdown",e,!0),i.addEventListener("click",r,!0),()=>{i.removeEventListener("pointerdown",e,!0),i.removeEventListener("click",r,!0)}}class Et{constructor(t,e){this.releaseGuard=null,this.selectedQuickOption=null,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.sheet=new bt(this.el),x()&&(this.releaseGuard=Li(this.el)),this.textarea=this.el.querySelector(".mtb-textarea"),this.submitBtn=this.el.querySelector(".mtb-submit-btn"),this.positionPopup(e.x,e.y,e.targetRect,e.position??"right"),this.bindEvents(e.messages),e.onMyFeedback&&this.el.querySelector(".mtb-my-feedback").addEventListener("click",e.onMyFeedback),x()||this.textarea.focus({preventScroll:!0})}buildHTML(t){const e=t.messages,r=e.popup.quickOptions.map(n=>`
35
- <button class="mtb-quick-option" data-quick="${h(n.label)}">
36
- <span class="mtb-quick-option-emoji">${n.emoji}</span>
37
- <span>${h(n.label)}</span>
35
+ <button class="mtb-quick-option" data-quick="${c(n.label)}">
36
+ <span class="mtb-quick-option-emoji">${c(n.emoji)}</span>
37
+ <span>${c(n.label)}</span>
38
38
  </button>`).join("");return`
39
39
  <div class="mtb-popup-header">
40
40
  <div class="mtb-popup-icon">
@@ -42,7 +42,7 @@
42
42
  <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"/>
43
43
  </svg>
44
44
  </div>
45
- <span class="mtb-popup-title">${e.popup.about} "${h(t.targetName)}"</span>
45
+ <span class="mtb-popup-title">${c(e.popup.about)} "${c(t.targetName)}"</span>
46
46
  <button class="mtb-popup-close" aria-label="Close">
47
47
  <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
48
48
  <path d="M18 6L6 18M6 6l12 12"/>
@@ -54,19 +54,19 @@
54
54
  ${r}
55
55
  </div>
56
56
  <div class="mtb-textarea-wrap">
57
- <textarea class="mtb-textarea" placeholder="${h(e.popup.placeholder)}"></textarea>
57
+ <textarea class="mtb-textarea" placeholder="${c(e.popup.placeholder)}"></textarea>
58
58
  </div>
59
59
  <div class="mtb-popup-actions">
60
- <button class="mtb-cancel-btn" type="button">${h(e.popup.cancel)}</button>
61
- <button class="mtb-submit-btn" type="button" disabled>${h(e.popup.submit)}</button>
60
+ <button class="mtb-cancel-btn" type="button">${c(e.popup.cancel)}</button>
61
+ <button class="mtb-submit-btn" type="button" disabled>${c(e.popup.submit)}</button>
62
62
  </div>
63
- ${t.onMyFeedback?`<button class="mtb-my-feedback" type="button">${h(e.popup.my_feedback)}</button>`:""}
63
+ ${t.onMyFeedback?`<button class="mtb-my-feedback" type="button">${c(e.popup.my_feedback)}</button>`:""}
64
64
  </div>
65
- `}positionPopup(t,e,r,n){if(this.sheet.apply())return;const s=window.innerWidth,o=window.innerHeight,a=12,l=8,c=32,u=Math.min(320,s-2*a-c),d=this.el.offsetHeight||260,m=a+(n==="left"?c:0),w=s-a-(n==="right"?c:0);let v,y;const Te=r&&r.width<s*.6&&r.height<o*.6;r&&Te?(v=r.left,y=r.bottom+l,y+d>o-a&&(y=r.top-d-l),y<a&&(y=Math.min(r.bottom+l,o-d-a))):(v=t+12,y=e+12),v+u>w&&(v=w-u),v<m&&(v=m),y<a&&(y=a),this.el.style.left=`${v}px`,this.el.style.top=`${y}px`,this.el.style.maxHeight=`${o-y-a}px`}bindEvents(t){this.el.querySelector(".mtb-popup-close").addEventListener("click",()=>this.onClose()),this.el.querySelector(".mtb-cancel-btn").addEventListener("click",()=>this.onClose()),this.el.querySelectorAll(".mtb-quick-option").forEach(e=>{e.addEventListener("click",()=>{const r=e.dataset.quick??"";if(this.textarea.value.trim().length===0){this.textarea.value=r,this.updateSubmitState(),this.submit();return}this.selectedQuickOption=r,this.el.querySelectorAll(".mtb-quick-option").forEach(n=>{n.classList.toggle("selected",n===e)})})}),this.textarea.addEventListener("input",()=>this.updateSubmitState()),this.textarea.addEventListener("keydown",e=>{e.isComposing||e.keyCode===229||e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.submit())}),this.submitBtn.addEventListener("click",()=>this.submit())}updateSubmitState(){const t=this.textarea.value.trim().length>0;this.submitBtn.classList.toggle("ready",t),this.submitBtn.disabled=!t}submit(){const t=this.textarea.value.trim();if(!t)return;const e=this.selectedQuickOption?`[${this.selectedQuickOption}] ${t}`:t;this.onSubmit(e)}releaseElement(){return this.releaseGuard?.(),this.releaseGuard=null,this.sheet.release(),this.el}destroy(){this.releaseGuard?.(),this.releaseGuard=null,this.sheet.release(),this.el.remove()}}class oe extends Error{constructor(t){super(`HTTP ${t}`),this.name="ApiError",this.status=t}}function Pi(i){return i instanceof oe&&i.status===409}const Mi="https://makethisbetter.dev/api/v1",Ri="sensitive-data-v1";class Ii{constructor(t,e,r=1e3,n,s){this.projectKey=t,this.apiUrl=(e??Mi).replace(/\/$/,""),this.retryDelayMs=r,this.userToken=n,this.userTokenFn=s}async resolveUserToken(){return this.userTokenFn?this.userTokenFn():this.userToken}async authHeaders(t){const e={"X-Project-Key":this.projectKey},r=await this.resolveUserToken();return r&&(e["X-User-Token"]=r),t&&(e["Content-Type"]=t),e}async submissionHeaders(t,e){const r=await this.authHeaders(e);return r["X-Submission-Token"]=t,r}async createSubmissionSession(t,e){const r=$i(),n=new FormData;if(n.append("feedback[description]",t.description),n.append("feedback[page_url]",t.page_url),n.append("feedback[user_agent]",t.user_agent),n.append("feedback[browser]",t.browser),n.append("feedback[os]",t.os),n.append("feedback[screen_width]",String(t.screen_width)),n.append("feedback[screen_height]",String(t.screen_height)),n.append("feedback[console_errors]",JSON.stringify(t.console_errors)),n.append("feedback[annotations]",JSON.stringify(t.annotations)),t.target_element&&n.append("feedback[target_element]",JSON.stringify(t.target_element)),t.user_id&&n.append("feedback[user_id]",t.user_id),t.reporter_external_id&&n.append("feedback[reporter_external_id]",t.reporter_external_id),t.reporter_email&&n.append("feedback[reporter_email]",t.reporter_email),t.user_email&&n.append("feedback[user_email]",t.user_email),t.user_name&&n.append("feedback[user_name]",t.user_name),t.breadcrumbs&&t.breadcrumbs.length>0&&n.append("feedback[breadcrumbs]",JSON.stringify(t.breadcrumbs)),t.recording_events&&t.recording_events.length>0){const l=JSON.stringify(t.recording_events),c=new Blob([l],{type:"application/json"});n.append("feedback[recording]",c,"interaction-replay.json"),n.append("feedback[recording_duration]",String(t.recording_duration??0))}if(e){const l=e.type==="image/jpeg"?"jpg":"png";n.append("feedback[screenshot]",e,`screenshot.${l}`)}const s=await this.authHeaders();return s["X-Submission-Token"]=r,s["X-MTB-Capture-Policy"]=Ri,s["X-Idempotency-Key"]=Hi(),{...(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions`,{method:"POST",headers:s,body:n})).json()).submission_session,token:r}}async createIdentityToken(t){const e=await this.authHeaders("application/json");try{return await(await this.fetchWithRetry(`${this.apiUrl}/widget/identity_tokens`,{method:"POST",headers:e,body:JSON.stringify({reporter_external_id:t})})).json()}catch{return null}}async updateReporter(t,e,r){const n=await this.authHeaders("application/json");n["X-Identity-Token"]=r;try{return await this.fetchWithRetry(`${this.apiUrl}/widget/feedbacks/${t}/reporter`,{method:"PATCH",headers:n,body:JSON.stringify({reporter:{email:e}})}),!0}catch{return!1}}async startClarification(t,e,r){const n={};return r&&(n.message=A(r)),this.requestClarification(t,e,n)}async retryClarification(t,e){return this.requestClarification(t,e,{retry:!0})}async requestClarification(t,e,r){const n=await this.submissionHeaders(e,"application/json");return(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/clarification`,{method:"POST",headers:n,body:JSON.stringify(r)})).json()).clarification}async getClarification(t,e){const r=await this.submissionHeaders(e);return(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/clarification`,{method:"GET",headers:r})).json()).clarification}async streamClarification(t,e,r,n){const s=await this.submissionHeaders(e,"application/json");s.Accept="text/event-stream";const o=await fetch(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/clarification`,{method:"POST",headers:s,body:JSON.stringify({}),signal:n}),a=o.headers.get("Content-Type")??"";if(!o.ok||!o.body||!a.includes("text/event-stream"))throw new Error("clarify stream unavailable");return Di(o.body,r)}async finalizeSubmissionSession(t,e){const r=await this.submissionHeaders(e);return(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/feedback`,{method:"POST",headers:r})).json()).feedback}async abandonSubmissionSession(t,e){const r=await this.submissionHeaders(e);await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}`,{method:"DELETE",headers:r})}async fetchWithRetry(t,e,r=1){let n;try{n=await fetch(t,e)}catch(s){if(r>0)return await Ct(this.retryDelayMs),this.fetchWithRetry(t,e,r-1);throw s}if(n.ok)return n;if(n.status>=500&&r>0)return await Ct(this.retryDelayMs),this.fetchWithRetry(t,e,r-1);throw new oe(n.status)}}function Ct(i){return i<=0?Promise.resolve():new Promise(t=>setTimeout(t,i))}async function Di(i,t){const e=i.getReader(),r=new TextDecoder;let n="",s=null;const o=a=>{const l=a.split(`
66
- `).find(m=>m.startsWith("event:")),c=a.split(`
67
- `).find(m=>m.startsWith("data:"));if(!c)return;const u=l?.slice(6).trim(),d=JSON.parse(c.slice(5).trim());u==="delta"&&typeof d.text=="string"?t(d.text):u==="done"&&(s={messages:Array.isArray(d.messages)?d.messages:[],done:d.done!==!1,failed:d.error===!0})};for(;;){const{done:a,value:l}=await e.read();if(a)break;n+=r.decode(l,{stream:!0});let c;for(;(c=n.indexOf(`
65
+ `}positionPopup(t,e,r,n){if(this.sheet.apply())return;const s=window.innerWidth,o=window.innerHeight,a=12,l=8,d=32,u=Math.min(320,s-2*a-d),h=this.el.offsetHeight||260,m=a+(n==="left"?d:0),w=s-a-(n==="right"?d:0);let v,y;const Te=r&&r.width<s*.6&&r.height<o*.6;r&&Te?(v=r.left,y=r.bottom+l,y+h>o-a&&(y=r.top-h-l),y<a&&(y=Math.min(r.bottom+l,o-h-a))):(v=t+12,y=e+12),v+u>w&&(v=w-u),v<m&&(v=m),y<a&&(y=a),this.el.style.left=`${v}px`,this.el.style.top=`${y}px`,this.el.style.maxHeight=`${o-y-a}px`}bindEvents(t){this.el.querySelector(".mtb-popup-close").addEventListener("click",()=>this.onClose()),this.el.querySelector(".mtb-cancel-btn").addEventListener("click",()=>this.onClose()),this.el.querySelectorAll(".mtb-quick-option").forEach(e=>{e.addEventListener("click",()=>{const r=e.dataset.quick??"";if(this.textarea.value.trim().length===0){this.textarea.value=r,this.updateSubmitState(),this.submit();return}this.selectedQuickOption=r,this.el.querySelectorAll(".mtb-quick-option").forEach(n=>{n.classList.toggle("selected",n===e)})})}),this.textarea.addEventListener("input",()=>this.updateSubmitState()),this.textarea.addEventListener("keydown",e=>{e.isComposing||e.keyCode===229||e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.submit())}),this.submitBtn.addEventListener("click",()=>this.submit())}updateSubmitState(){const t=this.textarea.value.trim().length>0;this.submitBtn.classList.toggle("ready",t),this.submitBtn.disabled=!t}submit(){const t=this.textarea.value.trim();if(!t)return;const e=this.selectedQuickOption?`[${this.selectedQuickOption}] ${t}`:t;this.onSubmit(e)}releaseElement(){return this.releaseGuard?.(),this.releaseGuard=null,this.sheet.release(),this.el}destroy(){this.releaseGuard?.(),this.releaseGuard=null,this.sheet.release(),this.el.remove()}}class oe extends Error{constructor(t){super(`HTTP ${t}`),this.name="ApiError",this.status=t}}function Pi(i){return i instanceof oe&&i.status===409}const Mi="https://makethisbetter.dev/api/v1",Ri="sensitive-data-v1";class Ii{constructor(t,e,r=1e3,n,s){this.projectKey=t,this.apiUrl=(e??Mi).replace(/\/$/,""),this.retryDelayMs=r,this.userToken=n,this.userTokenFn=s}async resolveUserToken(){return this.userTokenFn?this.userTokenFn():this.userToken}async authHeaders(t){const e={"X-Project-Key":this.projectKey},r=await this.resolveUserToken();return r&&(e["X-User-Token"]=r),t&&(e["Content-Type"]=t),e}async submissionHeaders(t,e){const r=await this.authHeaders(e);return r["X-Submission-Token"]=t,r}async createSubmissionSession(t,e){const r=$i(),n=new FormData;if(n.append("feedback[description]",t.description),n.append("feedback[page_url]",t.page_url),n.append("feedback[user_agent]",t.user_agent),n.append("feedback[browser]",t.browser),n.append("feedback[os]",t.os),n.append("feedback[screen_width]",String(t.screen_width)),n.append("feedback[screen_height]",String(t.screen_height)),n.append("feedback[console_errors]",JSON.stringify(t.console_errors)),n.append("feedback[annotations]",JSON.stringify(t.annotations)),t.target_element&&n.append("feedback[target_element]",JSON.stringify(t.target_element)),t.user_id&&n.append("feedback[user_id]",t.user_id),t.reporter_external_id&&n.append("feedback[reporter_external_id]",t.reporter_external_id),t.reporter_email&&n.append("feedback[reporter_email]",t.reporter_email),t.user_email&&n.append("feedback[user_email]",t.user_email),t.user_name&&n.append("feedback[user_name]",t.user_name),t.breadcrumbs&&t.breadcrumbs.length>0&&n.append("feedback[breadcrumbs]",JSON.stringify(t.breadcrumbs)),t.recording_events&&t.recording_events.length>0){const l=JSON.stringify(t.recording_events),d=new Blob([l],{type:"application/json"});n.append("feedback[recording]",d,"interaction-replay.json"),n.append("feedback[recording_duration]",String(t.recording_duration??0))}if(e){const l=e.type==="image/jpeg"?"jpg":"png";n.append("feedback[screenshot]",e,`screenshot.${l}`)}const s=await this.authHeaders();return s["X-Submission-Token"]=r,s["X-MTB-Capture-Policy"]=Ri,s["X-Idempotency-Key"]=Hi(),{...(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions`,{method:"POST",headers:s,body:n})).json()).submission_session,token:r}}async createIdentityToken(t){const e=await this.authHeaders("application/json");try{return await(await this.fetchWithRetry(`${this.apiUrl}/widget/identity_tokens`,{method:"POST",headers:e,body:JSON.stringify({reporter_external_id:t})})).json()}catch{return null}}async updateReporter(t,e,r){const n=await this.authHeaders("application/json");n["X-Identity-Token"]=r;try{return await this.fetchWithRetry(`${this.apiUrl}/widget/feedbacks/${t}/reporter`,{method:"PATCH",headers:n,body:JSON.stringify({reporter:{email:e}})}),!0}catch{return!1}}async startClarification(t,e,r){const n={};return r&&(n.message=A(r)),this.requestClarification(t,e,n)}async retryClarification(t,e){return this.requestClarification(t,e,{retry:!0})}async requestClarification(t,e,r){const n=await this.submissionHeaders(e,"application/json");return(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/clarification`,{method:"POST",headers:n,body:JSON.stringify(r)})).json()).clarification}async getClarification(t,e){const r=await this.submissionHeaders(e);return(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/clarification`,{method:"GET",headers:r})).json()).clarification}async streamClarification(t,e,r,n){const s=await this.submissionHeaders(e,"application/json");s.Accept="text/event-stream";const o=await fetch(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/clarification`,{method:"POST",headers:s,body:JSON.stringify({}),signal:n}),a=o.headers.get("Content-Type")??"";if(!o.ok||!o.body||!a.includes("text/event-stream"))throw new Error("clarify stream unavailable");return Di(o.body,r)}async finalizeSubmissionSession(t,e){const r=await this.submissionHeaders(e);return(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/feedback`,{method:"POST",headers:r})).json()).feedback}async abandonSubmissionSession(t,e){const r=await this.submissionHeaders(e);await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}`,{method:"DELETE",headers:r})}async fetchWithRetry(t,e,r=1){let n;try{n=await fetch(t,e)}catch(s){if(r>0)return await Ct(this.retryDelayMs),this.fetchWithRetry(t,e,r-1);throw s}if(n.ok)return n;if(n.status>=500&&r>0)return await Ct(this.retryDelayMs),this.fetchWithRetry(t,e,r-1);throw new oe(n.status)}}function Ct(i){return i<=0?Promise.resolve():new Promise(t=>setTimeout(t,i))}async function Di(i,t){const e=i.getReader(),r=new TextDecoder;let n="",s=null;const o=a=>{const l=a.split(`
66
+ `).find(m=>m.startsWith("event:")),d=a.split(`
67
+ `).find(m=>m.startsWith("data:"));if(!d)return;const u=l?.slice(6).trim(),h=JSON.parse(d.slice(5).trim());u==="delta"&&typeof h.text=="string"?t(h.text):u==="done"&&(s={messages:Array.isArray(h.messages)?h.messages:[],done:h.done!==!1,failed:h.error===!0})};for(;;){const{done:a,value:l}=await e.read();if(a)break;n+=r.decode(l,{stream:!0});let d;for(;(d=n.indexOf(`
68
68
 
69
- `))!==-1;){const u=n.slice(0,c);n=n.slice(c+2);try{o(u)}catch{}}}if(n+=r.decode(),n.trim())try{o(n)}catch{}if(!s)throw new Error("clarify stream ended before done");return s}function Hi(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function $i(){if(typeof crypto>"u"||typeof crypto.getRandomValues!="function")throw new Error("Secure random generation is unavailable");const i=crypto.getRandomValues(new Uint8Array(32));return Array.from(i,t=>t.toString(16).padStart(2,"0")).join("")}const Fi=2e3,Bi=45e3,_t=12e3,Ui=346,zi=270;class Oi{constructor(t,e){this.pollTimer=null,this.pollDeadline=0,this.streamingBubble=null,this.lastMessages=[],this.done=!1,this.sending=!1,this.finalSubmissionStarted=!1,this.finalizing=!1,this.destroyed=!1,this.streamAbort=null,this.unrecoverable=!1,this.submissionFailed=!1,this.submissionSessionId=e.submissionSessionId??"",this.submissionToken=e.submissionToken??"",this.apiClient=e.apiClient,this.onFinalize=e.onFinalize,this.onCancel=e.onCancel,this.i18n=e.messages,this.pendingSession=e.pendingSession,this.onRetrySubmission=e.onRetrySubmission;const r=e.element;this.el=r??t.el("div","mtb-clarify"),this.el.className=r?"mtb-clarify mtb-clarify-continuation":"mtb-clarify",this.el.innerHTML=this.buildHTML(e.messages),this.sheet=new bt(this.el),r?this.sheet.apply():(t.append(this.el),this.positionCard(e.x,e.y,e.position??"right")),this.messagesEl=this.el.querySelector(".mtb-clarify-messages"),this.bindEvents(),r&&!x()&&this.el.querySelector(".mtb-clarify-skip").focus({preventScroll:!0}),this.startConversation()}positionCard(t,e,r){if(this.sheet.apply())return;const n=window.innerWidth,s=window.innerHeight,o=12,a=32,l=Math.min(Ui,n-2*o-a),c=this.el.offsetHeight||zi,u=o+(r==="left"?a:0),d=n-o-(r==="right"?a:0);if(t===void 0||e===void 0){const v=Math.max(u,(n-l)/2);this.el.style.left=`${Math.min(v,d-l)}px`,this.el.style.top=`${Math.max(o,(s-c)/2)}px`,this.el.style.maxHeight=`${s-2*o}px`;return}let m=t+12,w=e+12;m+l>d&&(m=t-l-12),m+l>d&&(m=d-l),m<u&&(m=u),w+c>s-o&&(w=s-c-o),w<o&&(w=o),this.el.style.left=`${m}px`,this.el.style.top=`${w}px`,this.el.style.maxHeight=`${s-w-o}px`}buildHTML(t){return`
69
+ `))!==-1;){const u=n.slice(0,d);n=n.slice(d+2);try{o(u)}catch{}}}if(n+=r.decode(),n.trim())try{o(n)}catch{}if(!s)throw new Error("clarify stream ended before done");return s}function Hi(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function $i(){if(typeof crypto>"u"||typeof crypto.getRandomValues!="function")throw new Error("Secure random generation is unavailable");const i=crypto.getRandomValues(new Uint8Array(32));return Array.from(i,t=>t.toString(16).padStart(2,"0")).join("")}const Fi=2e3,Bi=45e3,_t=12e3,Ui=346,zi=270;class Oi{constructor(t,e){this.pollTimer=null,this.pollDeadline=0,this.streamingBubble=null,this.lastMessages=[],this.done=!1,this.sending=!1,this.finalSubmissionStarted=!1,this.finalizing=!1,this.destroyed=!1,this.streamAbort=null,this.unrecoverable=!1,this.submissionFailed=!1,this.submissionSessionId=e.submissionSessionId??"",this.submissionToken=e.submissionToken??"",this.apiClient=e.apiClient,this.onFinalize=e.onFinalize,this.onCancel=e.onCancel,this.i18n=e.messages,this.pendingSession=e.pendingSession,this.onRetrySubmission=e.onRetrySubmission;const r=e.element;this.el=r??t.el("div","mtb-clarify"),this.el.className=r?"mtb-clarify mtb-clarify-continuation":"mtb-clarify",this.el.innerHTML=this.buildHTML(e.messages),this.sheet=new bt(this.el),r?this.sheet.apply():(t.append(this.el),this.positionCard(e.x,e.y,e.position??"right")),this.messagesEl=this.el.querySelector(".mtb-clarify-messages"),this.bindEvents(),r&&!x()&&this.el.querySelector(".mtb-clarify-skip").focus({preventScroll:!0}),this.startConversation()}positionCard(t,e,r){if(this.sheet.apply())return;const n=window.innerWidth,s=window.innerHeight,o=12,a=32,l=Math.min(Ui,n-2*o-a),d=this.el.offsetHeight||zi,u=o+(r==="left"?a:0),h=n-o-(r==="right"?a:0);if(t===void 0||e===void 0){const v=Math.max(u,(n-l)/2);this.el.style.left=`${Math.min(v,h-l)}px`,this.el.style.top=`${Math.max(o,(s-d)/2)}px`,this.el.style.maxHeight=`${s-2*o}px`;return}let m=t+12,w=e+12;m+l>h&&(m=t-l-12),m+l>h&&(m=h-l),m<u&&(m=u),w+d>s-o&&(w=s-d-o),w<o&&(w=o),this.el.style.left=`${m}px`,this.el.style.top=`${w}px`,this.el.style.maxHeight=`${s-w-o}px`}buildHTML(t){return`
70
70
  <div class="mtb-clarify-header">
71
71
  <span class="mtb-clarify-icon">
72
72
  <svg width="11" height="11" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round">
@@ -74,10 +74,10 @@
74
74
  </svg>
75
75
  </span>
76
76
  <div class="mtb-clarify-titles">
77
- <div class="mtb-clarify-title">${h(t.clarify.title)}</div>
78
- <div class="mtb-clarify-subtitle">${h(t.clarify.subtitle)}</div>
77
+ <div class="mtb-clarify-title">${c(t.clarify.title)}</div>
78
+ <div class="mtb-clarify-subtitle">${c(t.clarify.subtitle)}</div>
79
79
  </div>
80
- <button class="mtb-clarify-close" type="button" title="${h(t.clarify.skip)}" aria-label="${h(t.clarify.skip)}">
80
+ <button class="mtb-clarify-close" type="button" title="${c(t.clarify.skip)}" aria-label="${c(t.clarify.skip)}">
81
81
  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round">
82
82
  <path d="M18 6L6 18M6 6l12 12"/>
83
83
  </svg>
@@ -86,26 +86,26 @@
86
86
  <div class="mtb-clarify-messages"></div>
87
87
  <div class="mtb-clarify-footer">${this.buildConversationControls(t)}</div>
88
88
  `}buildConversationControls(t){return`
89
- <textarea class="mtb-clarify-input" rows="1" placeholder="${h(t.clarify.placeholder)}"></textarea>
89
+ <textarea class="mtb-clarify-input" rows="1" placeholder="${c(t.clarify.placeholder)}"></textarea>
90
90
  <div class="mtb-clarify-actions">
91
- <button class="mtb-clarify-skip" type="button">${h(t.clarify.skip)}</button>
92
- <button class="mtb-clarify-send" type="button" aria-label="${h(t.clarify.send)}" disabled>
91
+ <button class="mtb-clarify-skip" type="button">${c(t.clarify.skip)}</button>
92
+ <button class="mtb-clarify-send" type="button" aria-label="${c(t.clarify.send)}" disabled>
93
93
  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
94
94
  <line x1="22" y1="2" x2="11" y2="13"/>
95
95
  <polygon points="22 2 15 22 11 13 2 9 22 2"/>
96
96
  </svg>
97
- <span class="mtb-clarify-send-label">${h(t.clarify.send)}</span>
97
+ <span class="mtb-clarify-send-label">${c(t.clarify.send)}</span>
98
98
  <span class="mtb-clarify-send-spinner" aria-hidden="true"></span>
99
99
  </button>
100
100
  </div>
101
101
  `}bindEvents(){this.el.querySelector(".mtb-clarify-close").addEventListener("click",()=>this.skipAndFinalize()),this.bindConversationControls()}bindConversationControls(){this.inputEl=this.el.querySelector(".mtb-clarify-input"),this.sendBtn=this.el.querySelector(".mtb-clarify-send"),this.el.querySelector(".mtb-clarify-skip").addEventListener("click",()=>this.skipAndFinalize()),this.inputEl.addEventListener("input",()=>{this.sendBtn.disabled=!this.inputEl.value.trim()}),this.inputEl.addEventListener("keydown",t=>{t.isComposing||t.keyCode===229||t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),this.sendMessage())}),this.sendBtn.addEventListener("click",()=>this.sendMessage())}skipAndFinalize(){if(this.submissionFailed){this.onCancel?.();return}this.stopPolling(),this.finalize()}async startConversation(){if(this.showThinking(),this.pendingSession){this.inputEl.disabled=!0,await this.adoptSession(this.pendingSession);return}await this.runInitialTurn()}async adoptSession(t){let e;try{e=await t}catch{e=null}if(!this.destroyed){if(!e){this.showSubmissionFailure();return}if(this.submissionSessionId=e.id,this.submissionToken=e.token,this.inputEl.disabled=!1,!e.ai_clarify_available){this.applyResult({messages:[],done:!0});return}await this.runInitialTurn()}}showSubmissionFailure(){this.submissionFailed=!0,this.stopPolling(),this.removeThinking();const t=this.el.querySelector(".mtb-clarify-footer");t.innerHTML=`
102
- <div class="mtb-clarify-error">${h(this.i18n.error.submit)}</div>
103
- <button class="mtb-clarify-send-feedback mtb-clarify-retry" type="button">${h(this.i18n.clarify.retry)}</button>
102
+ <div class="mtb-clarify-error">${c(this.i18n.error.submit)}</div>
103
+ <button class="mtb-clarify-send-feedback mtb-clarify-retry" type="button">${c(this.i18n.clarify.retry)}</button>
104
104
  `,t.querySelector(".mtb-clarify-retry").addEventListener("click",()=>{this.destroyed||this.retrySubmission()})}async retrySubmission(){!this.onRetrySubmission||this.sending||(this.submissionFailed=!1,this.showConversationControls(),this.inputEl.disabled=!0,this.showThinking(),await this.adoptSession(this.onRetrySubmission()))}async sendMessage(){const t=this.inputEl.value.trim();if(!(!t||this.sending||!this.submissionSessionId)){this.sending=!0,this.inputEl.disabled=!0,this.sendBtn.disabled=!0,this.sendBtn.setAttribute("aria-busy","true"),this.stopPolling(),this.finalSubmissionStarted=!0,this.appendMessage({role:"user",content:t}),this.inputEl.value="",this.clearError();try{await this.runAnswerTurn(t)}catch{if(this.destroyed)return;this.finalSubmissionStarted=!1,this.sending=!1,this.renderConversation(this.lastMessages,!1),this.inputEl.value=t,this.showError(),this.sendBtn.removeAttribute("aria-busy"),this.inputEl.disabled=!1,this.sendBtn.disabled=!this.inputEl.value.trim(),this.inputEl.focus({preventScroll:!0})}}}async runInitialTurn(){const t=new AbortController;this.streamAbort=t;let e=setTimeout(()=>t.abort(),_t);try{const r=await this.apiClient.streamClarification(this.submissionSessionId,this.submissionToken,n=>{clearTimeout(e),e=setTimeout(()=>t.abort(),_t),this.appendStreamDelta(n)},t.signal);if(this.destroyed)return;this.endStreamingBubble(),this.applyResult(r)||this.startPolling()}catch{if(this.destroyed)return;this.endStreamingBubble(),await this.runInitialTurnViaPolling()}finally{clearTimeout(e),this.streamAbort===t&&(this.streamAbort=null)}}async runInitialTurnViaPolling(){try{const t=await this.apiClient.startClarification(this.submissionSessionId,this.submissionToken);if(this.destroyed)return;this.applyResult(t)||this.startPolling()}catch{if(this.destroyed)return;this.handleFailure()}}async runAnswerTurn(t){const e=await this.apiClient.startClarification(this.submissionSessionId,this.submissionToken,t);this.destroyed||this.applyFinalSubmissionResult(e)||this.startPolling()}showError(){const t=this.el.querySelector(".mtb-clarify-footer"),e=document.createElement("div");e.className="mtb-clarify-error",e.textContent=this.i18n.error.submit,t.prepend(e)}clearError(){this.el.querySelector(".mtb-clarify-error")?.remove()}appendStreamDelta(t){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}endStreamingBubble(){this.streamingBubble=null}startPolling(){this.stopPolling(),this.pollDeadline=Date.now()+Bi,this.pollTimer=setInterval(()=>this.poll(),Fi)}stopPolling(){this.pollTimer!==null&&(clearInterval(this.pollTimer),this.pollTimer=null)}async poll(){if(Date.now()>this.pollDeadline){this.stopPolling(),this.handleFailure();return}try{const t=await this.apiClient.getClarification(this.submissionSessionId,this.submissionToken);if(this.destroyed)return;(this.finalSubmissionStarted?this.applyFinalSubmissionResult(t):this.applyResult(t))&&this.stopPolling()}catch{if(this.destroyed)return;this.stopPolling(),this.handleFailure()}}handleDone(t){if(!this.done){if(this.done=!0,this.stopPolling(),this.removeThinking(),t){this.finalize();return}this.showFinalizeButton()}}handleFailure(){this.done||(this.done=!0,this.sending=!1,this.finalSubmissionStarted=!1,this.stopPolling(),this.removeThinking(),this.showClarificationFailureActions())}showClarificationFailureActions(){const t=this.el.querySelector(".mtb-clarify-footer");t.innerHTML=`
105
- <div class="mtb-clarify-error">${h(this.i18n.clarify.error)}</div>
105
+ <div class="mtb-clarify-error">${c(this.i18n.clarify.error)}</div>
106
106
  <div class="mtb-clarify-actions">
107
- <button class="mtb-clarify-fallback" type="button">${h(this.i18n.clarify.send_feedback)}</button>
108
- <button class="mtb-clarify-retry" type="button">${h(this.i18n.clarify.retry)}</button>
107
+ <button class="mtb-clarify-fallback" type="button">${c(this.i18n.clarify.send_feedback)}</button>
108
+ <button class="mtb-clarify-retry" type="button">${c(this.i18n.clarify.retry)}</button>
109
109
  </div>
110
110
  `,t.querySelector(".mtb-clarify-fallback").addEventListener("click",()=>this.skipAndFinalize()),t.querySelector(".mtb-clarify-retry").addEventListener("click",()=>{this.destroyed||this.retryClarification()})}async retryClarification(){if(!(this.sending||this.destroyed)){this.sending=!0,this.done=!1,this.showConversationControls(),this.inputEl.disabled=!0,this.sendBtn.disabled=!0,this.renderConversation(this.lastMessages,!1);try{const t=await this.apiClient.getClarification(this.submissionSessionId,this.submissionToken);if(this.destroyed)return;let e=t;if(t.status==="failed"?e=await this.apiClient.retryClarification(this.submissionSessionId,this.submissionToken):t.status==="idle"&&(e=await this.apiClient.startClarification(this.submissionSessionId,this.submissionToken)),this.destroyed)return;this.applyResult(e)||(this.showConversationControls(),this.startPolling())}catch{if(this.destroyed)return;this.handleFailure()}finally{this.sending=!1}}}showConversationControls(){const t=this.el.querySelector(".mtb-clarify-footer");t.innerHTML=this.buildConversationControls(this.i18n),this.bindConversationControls()}applyFinalSubmissionResult(t){return t.status==="failed"?(this.handleFailure(),!0):t.done?(this.handleDone(!0),!0):!1}applyResult(t){this.renderConversation(t.messages,t.done);const e="status"in t?t.status:void 0;return("status"in t?t.status==="failed":t.failed===!0)?(this.handleFailure(),!0):t.done?(this.handleDone(t.messages.some(n=>n.role==="assistant")),!0):e==="awaiting_response"?(this.stopPolling(),this.removeThinking(),this.enableInput(),!0):!1}enableInput(){this.el.contains(this.inputEl)||this.showConversationControls(),this.inputEl.disabled=!1,this.sendBtn.disabled=!this.inputEl.value.trim()}showFinalizeButton(){const t=this.el.querySelector(".mtb-clarify-footer");t.innerHTML=`
111
111
  <button class="mtb-clarify-send-feedback" type="button">
@@ -113,34 +113,34 @@
113
113
  <line x1="22" y1="2" x2="11" y2="13"/>
114
114
  <polygon points="22 2 15 22 11 13 2 9 22 2"/>
115
115
  </svg>
116
- <span>${h(this.i18n.clarify.send_feedback)}</span>
116
+ <span>${c(this.i18n.clarify.send_feedback)}</span>
117
117
  </button>
118
- `,t.querySelector(".mtb-clarify-send-feedback").addEventListener("click",()=>{this.destroyed||this.finalize()})}async finalize(){if(!(this.finalizing||this.destroyed||this.unrecoverable)){this.finalizing=!0,this.el.querySelectorAll("button").forEach(t=>{t.disabled=!0});try{await this.onFinalize()}catch(t){if(this.destroyed)return;if(this.finalizing=!1,this.clearError(),Pi(t)){this.showUnrecoverable();return}this.showFinalizeRetry()}}}showUnrecoverable(){this.unrecoverable=!0,this.stopPolling();const t=this.el.querySelector(".mtb-clarify-footer");t.innerHTML=`<div class="mtb-clarify-error">${h(this.i18n.clarify.expired)}</div>`}showFinalizeRetry(){const t=this.el.querySelector(".mtb-clarify-footer");t.innerHTML=`
119
- <div class="mtb-clarify-error">${h(this.i18n.error.submit)}</div>
120
- <button class="mtb-clarify-send-feedback mtb-clarify-retry" type="button">${h(this.i18n.clarify.retry)}</button>
121
- `,t.querySelector(".mtb-clarify-retry").addEventListener("click",()=>{this.destroyed||this.finalize()})}renderConversation(t,e){this.lastMessages=t,this.renderMessages(t);const r=t[t.length-1];!e&&(!r||r.role==="user")&&this.showThinking()}renderMessages(t){this.messagesEl.innerHTML="";for(const e of t)this.appendMessage(e);this.messagesEl.scrollTop=this.messagesEl.scrollHeight}appendMessage(t){const e=document.createElement("div");e.className=t.role==="user"?"mtb-clarify-bubble mtb-clarify-user":"mtb-clarify-bubble mtb-clarify-ai",e.textContent=t.content,this.messagesEl.appendChild(e),this.messagesEl.scrollTop=this.messagesEl.scrollHeight}showThinking(){if(this.messagesEl.querySelector(".mtb-clarify-thinking"))return;const t=document.createElement("div");t.className="mtb-clarify-bubble mtb-clarify-ai mtb-clarify-thinking",t.innerHTML='<span class="mtb-dot"></span><span class="mtb-dot"></span><span class="mtb-dot"></span>',this.messagesEl.appendChild(t),this.messagesEl.scrollTop=this.messagesEl.scrollHeight}removeThinking(){this.messagesEl.querySelector(".mtb-clarify-thinking")?.remove()}destroy(){this.destroyed=!0,this.streamAbort?.abort(),this.streamAbort=null,this.stopPolling(),this.sheet.release(),this.el.remove()}}const Ni=5e3,qi=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;class ji{constructor(t,e,r,n,s){this.messages=e,this.el=t.el("div","mtb-success"),this.el.style.right="20px",this.el.style.bottom="20px";const o=s?.skipFollowup?e.success.title_no_ai:e.success.title,a=s?.skipFollowup?e.success.message_no_ai:e.success.message,l=n?`<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=s?.emailCapture?`
118
+ `,t.querySelector(".mtb-clarify-send-feedback").addEventListener("click",()=>{this.destroyed||this.finalize()})}async finalize(){if(!(this.finalizing||this.destroyed||this.unrecoverable)){this.finalizing=!0,this.el.querySelectorAll("button").forEach(t=>{t.disabled=!0});try{await this.onFinalize()}catch(t){if(this.destroyed)return;if(this.finalizing=!1,this.clearError(),Pi(t)){this.showUnrecoverable();return}this.showFinalizeRetry()}}}showUnrecoverable(){this.unrecoverable=!0,this.stopPolling();const t=this.el.querySelector(".mtb-clarify-footer");t.innerHTML=`<div class="mtb-clarify-error">${c(this.i18n.clarify.expired)}</div>`}showFinalizeRetry(){const t=this.el.querySelector(".mtb-clarify-footer");t.innerHTML=`
119
+ <div class="mtb-clarify-error">${c(this.i18n.error.submit)}</div>
120
+ <button class="mtb-clarify-send-feedback mtb-clarify-retry" type="button">${c(this.i18n.clarify.retry)}</button>
121
+ `,t.querySelector(".mtb-clarify-retry").addEventListener("click",()=>{this.destroyed||this.finalize()})}renderConversation(t,e){this.lastMessages=t,this.renderMessages(t);const r=t[t.length-1];!e&&(!r||r.role==="user")&&this.showThinking()}renderMessages(t){this.messagesEl.innerHTML="";for(const e of t)this.appendMessage(e);this.messagesEl.scrollTop=this.messagesEl.scrollHeight}appendMessage(t){const e=document.createElement("div");e.className=t.role==="user"?"mtb-clarify-bubble mtb-clarify-user":"mtb-clarify-bubble mtb-clarify-ai",e.textContent=t.content,this.messagesEl.appendChild(e),this.messagesEl.scrollTop=this.messagesEl.scrollHeight}showThinking(){if(this.messagesEl.querySelector(".mtb-clarify-thinking"))return;const t=document.createElement("div");t.className="mtb-clarify-bubble mtb-clarify-ai mtb-clarify-thinking",t.innerHTML='<span class="mtb-dot"></span><span class="mtb-dot"></span><span class="mtb-dot"></span>',this.messagesEl.appendChild(t),this.messagesEl.scrollTop=this.messagesEl.scrollHeight}removeThinking(){this.messagesEl.querySelector(".mtb-clarify-thinking")?.remove()}destroy(){this.destroyed=!0,this.streamAbort?.abort(),this.streamAbort=null,this.stopPolling(),this.sheet.release(),this.el.remove()}}const Ni=5e3,qi=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;class ji{constructor(t,e,r,n,s){this.messages=e,this.el=t.el("div","mtb-success"),this.el.style.right="20px",this.el.style.bottom="20px";const o=s?.skipFollowup?e.success.title_no_ai:e.success.title,a=s?.skipFollowup?e.success.message_no_ai:e.success.message,l=n?`<button class="mtb-view-feedback-link">${c(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>`:"",d=s?.emailCapture?`
122
122
  <div class="mtb-email-capture">
123
- <div class="mtb-email-prompt">${e.success.email_prompt}</div>
123
+ <div class="mtb-email-prompt">${c(e.success.email_prompt)}</div>
124
124
  <div class="mtb-email-row">
125
- <input class="mtb-email-input" type="email" placeholder="${e.success.email_placeholder}">
126
- <button class="mtb-email-submit">${e.success.email_submit}</button>
125
+ <input class="mtb-email-input" type="email" placeholder="${c(e.success.email_placeholder)}">
126
+ <button class="mtb-email-submit">${c(e.success.email_submit)}</button>
127
127
  </div>
128
- <div class="mtb-email-error" hidden>${e.success.email_error}</div>
128
+ <div class="mtb-email-error" hidden>${c(e.success.email_error)}</div>
129
129
  </div>`:"";this.el.innerHTML=`
130
130
  <div class="mtb-success-icon">
131
131
  <svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="${G}" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">
132
132
  <polyline points="20 6 9 17 4 12"/>
133
133
  </svg>
134
134
  </div>
135
- <div class="mtb-success-title">${o}</div>
136
- <div class="mtb-success-msg">${a}</div>
137
- ${c}
135
+ <div class="mtb-success-title">${c(o)}</div>
136
+ <div class="mtb-success-msg">${c(a)}</div>
137
+ ${d}
138
138
  ${l}
139
- <button class="mtb-close-link">${e.success.close}</button>
140
- `,t.append(this.el),this.el.querySelector(".mtb-close-link").addEventListener("click",r),n&&this.el.querySelector(".mtb-view-feedback-link").addEventListener("click",n),s?.emailCapture?this.bindEmailCapture(s.emailCapture.onSubmit):setTimeout(()=>r(),Ni)}bindEmailCapture(t){const e=this.el.querySelector(".mtb-email-input"),r=this.el.querySelector(".mtb-email-submit"),n=this.el.querySelector(".mtb-email-error"),s=async()=>{const o=e.value.trim();if(!qi.test(o)){e.classList.add("mtb-email-invalid");return}e.classList.remove("mtb-email-invalid"),n.hidden=!0,r.disabled=!0,await t(o)?this.el.querySelector(".mtb-email-capture").innerHTML=`<div class="mtb-email-saved">${this.messages.success.email_saved}</div>`:(n.hidden=!1,r.disabled=!1)};r.addEventListener("click",s),e.addEventListener("keydown",o=>{o.key==="Enter"&&s()})}destroy(){this.el.remove()}}function Wi(i,t){if(i.match(/^[a-z]+:\/\//i))return i;if(i.match(/^\/\//))return window.location.protocol+i;if(i.match(/^[a-z]+:/i))return i;const e=document.implementation.createHTMLDocument(),r=e.createElement("base"),n=e.createElement("a");return e.head.appendChild(r),e.body.appendChild(n),t&&(r.href=t),n.href=i,n.href}const Vi=(()=>{let i=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(i+=1,`u${t()}${i}`)})();function k(i){const t=[];for(let e=0,r=i.length;e<r;e++)t.push(i[e]);return t}let S=null;function ae(i={}){return S||(i.includeStyleProperties?(S=i.includeStyleProperties,S):(S=k(window.getComputedStyle(document.documentElement)),S))}function V(i,t){const r=(i.ownerDocument.defaultView||window).getComputedStyle(i).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function Yi(i){const t=V(i,"border-left-width"),e=V(i,"border-right-width");return i.clientWidth+t+e}function Xi(i){const t=V(i,"border-top-width"),e=V(i,"border-bottom-width");return i.clientHeight+t+e}function le(i,t={}){const e=t.width||Yi(i),r=t.height||Xi(i);return{width:e,height:r}}function Ki(){let i,t;try{t=process}catch{}const e=t&&t.env?t.env.devicePixelRatio:null;return e&&(i=parseInt(e,10),Number.isNaN(i)&&(i=1)),i||window.devicePixelRatio||1}const f=16384;function Gi(i){(i.width>f||i.height>f)&&(i.width>f&&i.height>f?i.width>i.height?(i.height*=f/i.width,i.width=f):(i.width*=f/i.height,i.height=f):i.width>f?(i.height*=f/i.width,i.width=f):(i.width*=f/i.height,i.height=f))}function Y(i){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=e,r.crossOrigin="anonymous",r.decoding="async",r.src=i})}async function Ji(i){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(i)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Zi(i,t,e){const r="http://www.w3.org/2000/svg",n=document.createElementNS(r,"svg"),s=document.createElementNS(r,"foreignObject");return n.setAttribute("width",`${t}`),n.setAttribute("height",`${e}`),n.setAttribute("viewBox",`0 0 ${t} ${e}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),n.appendChild(s),s.appendChild(i),Ji(n)}const p=(i,t)=>{if(i instanceof t)return!0;const e=Object.getPrototypeOf(i);return e===null?!1:e.constructor.name===t.name||p(e,t)};function Qi(i){const t=i.getPropertyValue("content");return`${i.cssText} content: '${t.replace(/'|"/g,"")}';`}function tr(i,t){return ae(t).map(e=>{const r=i.getPropertyValue(e),n=i.getPropertyPriority(e);return`${e}: ${r}${n?" !important":""};`}).join(" ")}function er(i,t,e,r){const n=`.${i}:${t}`,s=e.cssText?Qi(e):tr(e,r);return document.createTextNode(`${n}{${s}}`)}function Tt(i,t,e,r){const n=window.getComputedStyle(i,e),s=n.getPropertyValue("content");if(s===""||s==="none")return;const o=Vi();try{t.className=`${t.className} ${o}`}catch{return}const a=document.createElement("style");a.appendChild(er(o,e,n,r)),t.appendChild(a)}function ir(i,t,e){Tt(i,t,":before",e),Tt(i,t,":after",e)}const At="application/font-woff",Lt="image/jpeg",rr={woff:At,woff2:At,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Lt,jpeg:Lt,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function nr(i){const t=/\.([^./]*?)$/g.exec(i);return t?t[1]:""}function pt(i){const t=nr(i).toLowerCase();return rr[t]||""}function sr(i){return i.split(/,/)[1]}function at(i){return i.search(/^(data:)/)!==-1}function or(i,t){return`data:${t};base64,${i}`}async function ce(i,t,e){const r=await fetch(i,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const n=await r.blob();return new Promise((s,o)=>{const a=new FileReader;a.onerror=o,a.onloadend=()=>{try{s(e({res:r,result:a.result}))}catch(l){o(l)}},a.readAsDataURL(n)})}const et={};function ar(i,t,e){let r=i.replace(/\?.*/,"");return e&&(r=i),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function ft(i,t,e){const r=ar(i,t,e.includeQueryParams);if(et[r]!=null)return et[r];e.cacheBust&&(i+=(/\?/.test(i)?"&":"?")+new Date().getTime());let n;try{const s=await ce(i,e.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),sr(a)));n=or(s,t)}catch(s){n=e.imagePlaceholder||"";let o=`Failed to fetch resource: ${i}`;s&&(o=typeof s=="string"?s:s.message),o&&console.warn(o)}return et[r]=n,n}async function lr(i){const t=i.toDataURL();return t==="data:,"?i.cloneNode(!1):Y(t)}async function cr(i,t){if(i.currentSrc){const s=document.createElement("canvas"),o=s.getContext("2d");s.width=i.clientWidth,s.height=i.clientHeight,o?.drawImage(i,0,0,s.width,s.height);const a=s.toDataURL();return Y(a)}const e=i.poster,r=pt(e),n=await ft(e,r,t);return Y(n)}async function dr(i,t){var e;try{if(!((e=i?.contentDocument)===null||e===void 0)&&e.body)return await Q(i.contentDocument.body,t,!0)}catch{}return i.cloneNode(!1)}async function hr(i,t){return p(i,HTMLCanvasElement)?lr(i):p(i,HTMLVideoElement)?cr(i,t):p(i,HTMLIFrameElement)?dr(i,t):i.cloneNode(de(i))}const ur=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SLOT",de=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SVG";async function mr(i,t,e){var r,n;if(de(t))return t;let s=[];return ur(i)&&i.assignedNodes?s=k(i.assignedNodes()):p(i,HTMLIFrameElement)&&(!((r=i.contentDocument)===null||r===void 0)&&r.body)?s=k(i.contentDocument.body.childNodes):s=k(((n=i.shadowRoot)!==null&&n!==void 0?n:i).childNodes),s.length===0||p(i,HTMLVideoElement)||await s.reduce((o,a)=>o.then(()=>Q(a,e)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function br(i,t,e){const r=t.style;if(!r)return;const n=window.getComputedStyle(i);n.cssText?(r.cssText=n.cssText,r.transformOrigin=n.transformOrigin):ae(e).forEach(s=>{let o=n.getPropertyValue(s);s==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),p(i,HTMLIFrameElement)&&s==="display"&&o==="inline"&&(o="block"),s==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(s,o,n.getPropertyPriority(s))})}function pr(i,t){p(i,HTMLTextAreaElement)&&(t.innerHTML=i.value),p(i,HTMLInputElement)&&t.setAttribute("value",i.value)}function fr(i,t){if(p(i,HTMLSelectElement)){const e=t,r=Array.from(e.children).find(n=>i.value===n.getAttribute("value"));r&&r.setAttribute("selected","")}}function gr(i,t,e){return p(t,Element)&&(br(i,t,e),ir(i,t,e),pr(i,t),fr(i,t)),t}async function yr(i,t){const e=i.querySelectorAll?i.querySelectorAll("use"):[];if(e.length===0)return i;const r={};for(let s=0;s<e.length;s++){const a=e[s].getAttribute("xlink:href");if(a){const l=i.querySelector(a),c=document.querySelector(a);!l&&c&&!r[a]&&(r[a]=await Q(c,t,!0))}}const n=Object.values(r);if(n.length){const s="http://www.w3.org/1999/xhtml",o=document.createElementNS(s,"svg");o.setAttribute("xmlns",s),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const a=document.createElementNS(s,"defs");o.appendChild(a);for(let l=0;l<n.length;l++)a.appendChild(n[l]);i.appendChild(o)}return i}async function Q(i,t,e){return!e&&t.filter&&!t.filter(i)?null:Promise.resolve(i).then(r=>hr(r,t)).then(r=>mr(i,r,t)).then(r=>gr(i,r,t)).then(r=>yr(r,t))}const he=/url\((['"]?)([^'"]+?)\1\)/g,wr=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,vr=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function xr(i){const t=i.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function kr(i){const t=[];return i.replace(he,(e,r,n)=>(t.push(n),e)),t.filter(e=>!at(e))}async function Sr(i,t,e,r,n){try{const s=e?Wi(t,e):t,o=pt(t);let a;return n||(a=await ft(s,o,r)),i.replace(xr(t),`$1${a}$3`)}catch{}return i}function Er(i,{preferredFontFormat:t}){return t?i.replace(vr,e=>{for(;;){const[r,,n]=wr.exec(e)||[];if(!n)return"";if(n===t)return`src: ${r};`}}):i}function ue(i){return i.search(he)!==-1}async function me(i,t,e){if(!ue(i))return i;const r=Er(i,e);return kr(r).reduce((s,o)=>s.then(a=>Sr(a,o,t,e)),Promise.resolve(r))}async function E(i,t,e){var r;const n=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(i);if(n){const s=await me(n,null,e);return t.style.setProperty(i,s,t.style.getPropertyPriority(i)),!0}return!1}async function Cr(i,t){await E("background",i,t)||await E("background-image",i,t),await E("mask",i,t)||await E("-webkit-mask",i,t)||await E("mask-image",i,t)||await E("-webkit-mask-image",i,t)}async function _r(i,t){const e=p(i,HTMLImageElement);if(!(e&&!at(i.src))&&!(p(i,SVGImageElement)&&!at(i.href.baseVal)))return;const r=e?i.src:i.href.baseVal,n=await ft(r,pt(r),t);await new Promise((s,o)=>{i.onload=s,i.onerror=t.onImageErrorHandler?(...l)=>{try{s(t.onImageErrorHandler(...l))}catch(c){o(c)}}:o;const a=i;a.decode&&(a.decode=s),a.loading==="lazy"&&(a.loading="eager"),e?(i.srcset="",i.src=n):i.href.baseVal=n})}async function Tr(i,t){const r=k(i.childNodes).map(n=>be(n,t));await Promise.all(r).then(()=>i)}async function be(i,t){p(i,Element)&&(await Cr(i,t),await _r(i,t),await Tr(i,t))}function Ar(i,t){const{style:e}=i;t.backgroundColor&&(e.backgroundColor=t.backgroundColor),t.width&&(e.width=`${t.width}px`),t.height&&(e.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(n=>{e[n]=r[n]}),i}const Pt={};async function Mt(i){let t=Pt[i];if(t!=null)return t;const r=await(await fetch(i)).text();return t={url:i,cssText:r},Pt[i]=t,t}async function Rt(i,t){let e=i.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,s=(e.match(/url\([^)]+\)/g)||[]).map(async o=>{let a=o.replace(r,"$1");return a.startsWith("https://")||(a=new URL(a,i.url).href),ce(a,t.fetchRequestInit,({result:l})=>(e=e.replace(o,`url(${l})`),[o,l]))});return Promise.all(s).then(()=>e)}function It(i){if(i==null)return[];const t=[],e=/(\/\*[\s\S]*?\*\/)/gi;let r=i.replace(e,"");const n=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=n.exec(r);if(l===null)break;t.push(l[0])}r=r.replace(n,"");const s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",a=new RegExp(o,"gi");for(;;){let l=s.exec(r);if(l===null){if(l=a.exec(r),l===null)break;s.lastIndex=a.lastIndex}else a.lastIndex=s.lastIndex;t.push(l[0])}return t}async function Lr(i,t){const e=[],r=[];return i.forEach(n=>{if("cssRules"in n)try{k(n.cssRules||[]).forEach((s,o)=>{if(s.type===CSSRule.IMPORT_RULE){let a=o+1;const l=s.href,c=Mt(l).then(u=>Rt(u,t)).then(u=>It(u).forEach(d=>{try{n.insertRule(d,d.startsWith("@import")?a+=1:n.cssRules.length)}catch(m){console.error("Error inserting rule from remote css",{rule:d,error:m})}})).catch(u=>{console.error("Error loading remote css",u.toString())});r.push(c)}})}catch(s){const o=i.find(a=>a.href==null)||document.styleSheets[0];n.href!=null&&r.push(Mt(n.href).then(a=>Rt(a,t)).then(a=>It(a).forEach(l=>{o.insertRule(l,o.cssRules.length)})).catch(a=>{console.error("Error loading remote stylesheet",a)})),console.error("Error inlining remote css file",s)}}),Promise.all(r).then(()=>(i.forEach(n=>{if("cssRules"in n)try{k(n.cssRules||[]).forEach(s=>{e.push(s)})}catch(s){console.error(`Error while reading CSS rules from ${n.href}`,s)}}),e))}function Pr(i){return i.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>ue(t.style.getPropertyValue("src")))}async function Mr(i,t){if(i.ownerDocument==null)throw new Error("Provided element is not within a Document");const e=k(i.ownerDocument.styleSheets),r=await Lr(e,t);return Pr(r)}function pe(i){return i.trim().replace(/["']/g,"")}function Rr(i){const t=new Set;function e(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(s=>{t.add(pe(s))}),Array.from(r.children).forEach(s=>{s instanceof HTMLElement&&e(s)})}return e(i),t}async function Ir(i,t){const e=await Mr(i,t),r=Rr(i);return(await Promise.all(e.filter(s=>r.has(pe(s.style.fontFamily))).map(s=>{const o=s.parentStyleSheet?s.parentStyleSheet.href:null;return me(s.cssText,o,t)}))).join(`
141
- `)}async function Dr(i,t){const e=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Ir(i,t);if(e){const r=document.createElement("style"),n=document.createTextNode(e);r.appendChild(n),i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r)}}async function Hr(i,t={}){const{width:e,height:r}=le(i,t),n=await Q(i,t,!0);return await Dr(n,t),await be(n,t),Ar(n,t),await Zi(n,e,r)}async function $r(i,t={}){const{width:e,height:r}=le(i,t),n=await Hr(i,t),s=await Y(n),o=document.createElement("canvas"),a=o.getContext("2d"),l=t.pixelRatio||Ki(),c=t.canvasWidth||e,u=t.canvasHeight||r;return o.width=c*l,o.height=u*l,t.skipAutoScale||Gi(o),o.style.width=`${c}`,o.style.height=`${u}`,t.backgroundColor&&(a.fillStyle=t.backgroundColor,a.fillRect(0,0,o.width,o.height)),a.drawImage(s,0,0,o.width,o.height),o}async function Fr(i,t={}){return(await $r(i,t)).toDataURL("image/jpeg",t.quality||1)}const it=400,rt=300,Dt=150,Ht=.3,$t=.85;function fe(i){let t=1/0,e=1/0,r=-1/0,n=-1/0;for(const s of i)if(s.type==="pin"){if(t=Math.min(t,s.x),e=Math.min(e,s.y),r=Math.max(r,s.x),n=Math.max(n,s.y),s.targetRect){const o=s.targetRect;t=Math.min(t,o.left),e=Math.min(e,o.top),r=Math.max(r,o.left+o.width),n=Math.max(n,o.bottom)}}else if(s.type==="draw"&&s.drawPath)for(const o of ge(s.drawPath))for(const[a,l]of o)t=Math.min(t,a),e=Math.min(e,l),r=Math.max(r,a),n=Math.max(n,l);return!isFinite(t)||!isFinite(e)?null:{minX:t,minY:e,maxX:r,maxY:n}}function Br(i,t,e){const r=fe(i);if(!r)return null;const n=Math.max(Dt,t*Ht),s=Math.max(Dt,e*Ht);let o=r.minX-n,a=r.minY-s,l=r.maxX-r.minX+n*2,c=r.maxY-r.minY+s*2;return l<it&&(o-=(it-l)/2,l=it),c<rt&&(a-=(rt-c)/2,c=rt),l=Math.min(l,t),c=Math.min(c,e),o=Math.min(Math.max(0,o),t-l),a=Math.min(Math.max(0,a),e-c),l>=t*$t&&c>=e*$t?null:{x:Math.round(o),y:Math.round(a),width:Math.round(l),height:Math.round(c)}}function Ur(i,t){const e=document.createElement("canvas");e.width=t.width,e.height=t.height;const r=e.getContext("2d");return r&&r.drawImage(i,t.x,t.y,t.width,t.height,0,0,t.width,t.height),e}async function zr(i=[]){try{const t=Qr(document.body),e=i.map(Or),r=Kr(document.body),n=await Fr(document.body,{quality:.85,width:t.width,height:t.height,pixelRatio:Zr(t),backgroundColor:"#ffffff",skipFonts:!1,skipAutoScale:!1,filter:s=>!(s instanceof HTMLElement&&s.id==="mtb-widget-host")});return await Vr(n,e,t,r)}catch{return null}}function Or(i){const t=qr(Nr(i));return t.x===0&&t.y===0?i:{...i,x:i.x+t.x,y:i.y+t.y,targetRect:i.targetRect&&{...i.targetRect,top:i.targetRect.top+t.y,left:i.targetRect.left+t.x,bottom:i.targetRect.bottom+t.y},drawPath:i.drawPath&&Wr(i.drawPath,t)}}function Nr(i){if(i.targetSelector)try{const t=document.querySelector(i.targetSelector);if(t)return t}catch{}return document.elementsFromPoint?.(i.x,i.y)[0]??null}function qr(i){let t=0,e=0,r=i;for(;r&&r!==document.body;)r instanceof HTMLElement&&(t+=r.scrollLeft,e+=r.scrollTop),r=jr(r);return{x:t,y:e}}function jr(i){if(i.parentElement)return i.parentElement;const t=i.getRootNode();return t instanceof ShadowRoot?t.host:null}function Wr(i,t){return i.replace(/([ML])\s*(-?(?:\d+\.?\d*|\.\d+))\s+(-?(?:\d+\.?\d*|\.\d+))/g,(e,r,n,s)=>`${r} ${Number(n)+t.x} ${Number(s)+t.y}`)}async function Vr(i,t,e,r){const n=document.createElement("canvas"),s=n.getContext("2d");if(!s)return null;const o=await en(i);if(!o)return null;n.width=o.naturalWidth||window.innerWidth,n.height=o.naturalHeight||window.innerHeight,s.drawImage(o,0,0);const a=n.width/e.width,l=n.height/e.height;s.fillStyle="#e5e7eb";for(const d of r)s.fillRect((d.left-e.left)*a,(d.top-e.top)*l,d.width*a,d.height*l);let c=0;for(const d of t)d.type==="draw"&&d.drawPath?Jr(s,d.drawPath,e,a,l):d.type==="pin"&&tn(s,(d.x-e.left)*a,(d.y-e.top)*l,++c);if(!Yr(t,e,a,l,n))return O(n);const u=Br(t,window.innerWidth,window.innerHeight);if(u){const d=Xr(u,e,a,l,n);return O(d?Ur(n,d):n)}return O(n)}function Yr(i,t,e,r,n){const s=fe(i);if(!s)return!0;const o=(s.minX-t.left)*e,a=(s.minY-t.top)*r,l=(s.maxX-t.left)*e,c=(s.maxY-t.top)*r;return o>=0&&a>=0&&l<=n.width&&c<=n.height}function Xr(i,t,e,r,n){const s=Math.min(n.width,Math.round(i.width*e)),o=Math.min(n.height,Math.round(i.height*r));if(s<=0||o<=0)return null;const a=Math.round((i.x-t.left)*e),l=Math.round((i.y-t.top)*r);return{x:Math.min(Math.max(0,a),n.width-s),y:Math.min(Math.max(0,l),n.height-o),width:s,height:o}}function Kr(i){const t=[];for(const s of Gr(i,`.${J}`))nt(t,s.getBoundingClientRect());for(const s of i.querySelectorAll("input, textarea, select")){if(Ft(s))continue;const o=s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement?s.value:"",a=s.closest(`.${U}`)!==null,l=ee(s)||W(o,s)!==o;!a&&!l||nt(t,s.getBoundingClientRect(),Ut)}const e=document.createTreeWalker(i,NodeFilter.SHOW_TEXT),r=ie();let n=e.nextNode();for(;n;){const s=n.parentElement,o=n.textContent??"",a=s?.closest(`.${U}`)!==null,l=A(o)!==o||re(n,r);if(s&&!Ft(s)&&(a||l)){const c=document.createRange();c.selectNodeContents(n);for(const u of Array.from(c.getClientRects()))nt(t,u,Ut)}n=e.nextNode()}return t}function Gr(i,t){const e=Array.from(i.querySelectorAll(t));return i.matches(t)?[i,...e]:e}function Ft(i){return i.closest("#mtb-widget-host")!==null||i.closest(`.${J}`)!==null}function nt(i,t,e=0){if(![t.left,t.top,t.width,t.height].every(Number.isFinite))throw new Error("Invalid privacy redaction geometry");t.width<=0||t.height<=0||i.push({left:t.left-e,top:t.top-e,width:t.width+e*2,height:t.height+e*2})}function Jr(i,t,e,r,n){i.save(),i.strokeStyle=G,i.lineWidth=3.5,i.lineCap="round",i.lineJoin="round",i.shadowColor=ut(.35),i.shadowOffsetY=1,i.shadowBlur=2;for(const s of ge(t))if(s.length!==0){i.beginPath(),i.moveTo((s[0][0]-e.left)*r,(s[0][1]-e.top)*n);for(let o=1;o<s.length;o++)i.lineTo((s[o][0]-e.left)*r,(s[o][1]-e.top)*n);i.stroke()}i.restore()}const Bt=16e6,Ut=2;function Zr(i){const t=i.width*i.height;return!Number.isFinite(t)||t<=Bt?1:Math.sqrt(Bt/t)}function Qr(i){const t=i.getBoundingClientRect(),e=window.getComputedStyle(i),r=parseFloat(e.borderLeftWidth)+parseFloat(e.borderRightWidth),n=parseFloat(e.borderTopWidth)+parseFloat(e.borderBottomWidth),s=document.documentElement,o=Math.max(i.clientWidth,i.scrollWidth,s.clientWidth,s.scrollWidth),a=Math.max(i.clientHeight,i.scrollHeight,s.clientHeight,s.scrollHeight);return{left:t.left,top:t.top,width:o+(Number.isFinite(r)?r:0)||window.innerWidth,height:a+(Number.isFinite(n)?n:0)||window.innerHeight}}function tn(i,t,e,r){i.save(),i.shadowColor=ut(.45),i.shadowOffsetY=2,i.shadowBlur=8,i.fillStyle=G,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 ${Ge}`,i.textAlign="center",i.textBaseline="middle",i.fillText(String(r),t,e),i.restore()}function ge(i){const t=[];let e=null;const r=i.match(/[ML]\s*[-\d.]+\s+[-\d.]+/g)??[];for(const n of r){const[s,o]=n.slice(1).trim().split(/\s+/).map(Number);Number.isNaN(s)||Number.isNaN(o)||(n[0]==="M"?(e=[[s,o]],t.push(e)):e&&e.push([s,o]))}return t}function en(i){return new Promise(t=>{const e=new Image;e.onload=()=>t(e),e.onerror=()=>t(null),e.src=i})}function O(i){return new Promise(t=>{try{i.toBlob(e=>t(e),"image/jpeg",.85)}catch{t(null)}})}class rn{constructor(){this.listeners=new Set,this.originalOnError=null,this.installedOnError=null,this.rejectionHandler=null,this.hooked=!1}subscribe(t){return this.listeners.add(t),this.hook(),()=>{this.listeners.delete(t),this.listeners.size===0&&this.unhook()}}hook(){this.hooked||(this.hooked=!0,this.originalOnError=window.onerror,this.installedOnError=(t,e,r,n,s)=>(this.emit({name:nn(s),message:String(t),source:e,line:r,col:n,error:s}),this.originalOnError?this.originalOnError.call(window,t,e,r,n,s):!1),window.onerror=this.installedOnError,this.rejectionHandler=t=>{const e=t.reason instanceof Error?t.reason.message:String(t.reason),r=t.reason instanceof Error?t.reason.name:"UnhandledRejection";this.emit({name:r,message:`Unhandled rejection: ${e}`})},window.addEventListener("unhandledrejection",this.rejectionHandler))}unhook(){this.hooked&&(this.hooked=!1,window.onerror===this.installedOnError&&(window.onerror=this.originalOnError),this.installedOnError=null,this.originalOnError=null,this.rejectionHandler&&(window.removeEventListener("unhandledrejection",this.rejectionHandler),this.rejectionHandler=null))}emit(t){for(const e of this.listeners)e(t)}}const gt=new rn;function nn(i){return!i||typeof i!="object"||!("name"in i)?void 0:String(i.name)||void 0}function ye(i){const t=sn(i.name)||on(i.message),e=an(i);return e?`${t} (${e})`:t}function sn(i){return i&&/^[A-Za-z][A-Za-z0-9]*(?:Error|Exception|Rejection)$/.test(i)?i:""}function on(i){return i.match(/^([A-Za-z][A-Za-z0-9]*(?:Error|Exception))\b/)?.[1]??"Error"}function an(i){if(!i.source)return"";try{const t=new URL(i.source,window.location.href).pathname;return i.line==null?t:`${t}:${i.line}:${i.col??0}`}catch{return""}}const ln=20;class cn{constructor(){this.errors=[],this.unsubscribe=null}start(){this.unsubscribe||(this.unsubscribe=gt.subscribe(t=>this.record(t)))}record(t){this.addError(ye(t))}addError(t){this.errors.length>=ln||this.errors.includes(t)||this.errors.push(t)}getErrors(){return[...this.errors]}stop(){this.unsubscribe?.(),this.unsubscribe=null}}const N=new Set;let I=null,D=null,H=null,X=null,$=null;function we(i){N.add(i),dn();let t=!1;return()=>{t||(t=!0,N.delete(i),N.size===0&&hn())}}function st(){for(const i of[...N])try{i()}catch{}}function dn(){if(H)return;$=()=>st(),window.addEventListener("popstate",$),I=history.pushState,D=history.replaceState;const i=I,t=D;H=function(e,r,n){i.call(history,e,r,n),st()},X=function(e,r,n){t.call(history,e,r,n),st()},history.pushState=H,history.replaceState=X}function hn(){$&&(window.removeEventListener("popstate",$),$=null),I&&history.pushState===H&&(history.pushState=I),D&&history.replaceState===X&&(history.replaceState=D),I=null,D=null,H=null,X=null}const un=20;function mn(i){return Z(i)?mt(i):ht(i)}function bn(i){return Z(i)?se(i):Zt(i)}class pn{constructor(){this.breadcrumbs=[],this.active=!1,this.unsubscribeErrors=null,this.unsubscribeNavigation=null,this.lastUrl="",this.boundClickHandler=t=>this.handleClick(t),this.boundChangeHandler=t=>this.handleChange(t)}start(){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=gt.subscribe(t=>this.recordError(t)),this.unsubscribeNavigation=we(()=>this.handleNavigation()))}stop(){this.active&&(this.active=!1,document.removeEventListener("click",this.boundClickHandler,!0),document.removeEventListener("change",this.boundChangeHandler,!0),this.unsubscribeErrors?.(),this.unsubscribeErrors=null,this.unsubscribeNavigation?.(),this.unsubscribeNavigation=null)}getBreadcrumbs(){return[...this.breadcrumbs]}add(t){this.breadcrumbs.push(t),this.breadcrumbs.length>un&&this.breadcrumbs.shift()}handleClick(t){const e=t.target;if(e&&!C(e))try{this.add({type:"ui",category:"ui.click",timestamp:Date.now(),message:mn(e),data:{selector:bn(e)}})}catch{}}handleChange(t){const e=t.target;if(e&&!C(e))try{const r=e,n=Z(e)?mt(e):r.name||r.placeholder||e.getAttribute("aria-label")||e.tagName;this.add({type:"ui",category:"ui.input",timestamp:Date.now(),message:n,data:{field:n}})}catch{}}recordError(t){const e=ye(t);this.add({type:"console",category:"console.error",timestamp:Date.now(),message:e,data:{message:e}})}handleNavigation(){if(!this.active)return;const t=this.lastUrl,e=location.href;if(t===e)return;this.lastUrl=e;const r=B(t),n=B(e);this.add({type:"navigation",category:"navigation",timestamp:Date.now(),message:`${r} → ${n}`,data:{from:r,to:n}})}}const ve="mtb_frustration_state";let lt=null;function K(){try{const i=window.sessionStorage.getItem(ve);return q(i?JSON.parse(i):lt)}catch{return q(lt)}}function xe(i){const t=q(i);lt=t;try{window.sessionStorage.setItem(ve,JSON.stringify(t))}catch{}}function fn(){return K().dismissedByUser}function gn(){xe({...K(),dismissedByUser:!0})}function q(i){const t=i??{};return{navTimestamps:Array.isArray(t.navTimestamps)?t.navTimestamps.filter(e=>typeof e=="number"):[],cooldownUntil:typeof t.cooldownUntil=="number"?t.cooldownUntil:0,errorPageUrls:Array.isArray(t.errorPageUrls)?t.errorPageUrls.filter(e=>typeof e=="string").slice(-20):[],dismissedByUser:t.dismissedByUser===!0}}const yn=3,wn=1e3,vn=3,xn=5e3,zt=500,kn=500,Sn=300,En=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","LABEL","SUMMARY","DETAILS"]),Cn=new Set(["button","link","checkbox","radio","tab","menuitem","option","switch","textbox","combobox","listbox","slider","spinbutton"]),Ot=[/\bnot found\b/,/\bserver error\b/,/^\s*(?:http\s*)?[45]\d{2}\s*$/,/\b(?:error|http|status)\s*[:-]?\s*[45]\d{2}\b/,/\b[45]\d{2}\s*[:-]?\s*error\b/],F=class F{constructor(t){this.clickHistory=[],this.unsubscribeErrors=null,this.active=!1,this.errorCount=0,this.deadClickCount=0,this.cooldownUntil=0,this.navTimestamps=[],this.unsubscribeNavigation=null,this.boundPageLeaveHandler=null,this.lastNavigationAt=-1,this.boundSubmitHandler=null,this.boundInvalidHandler=null,this.recentSubmitForms=new WeakSet,this.errorPageUrls=new Set,this.domObserver=null,this.pendingDomChecks=0,this.lastMutationAt=-1,this.onFrustration=t,this.boundClickHandler=e=>this.handleClick(e)}start(){this.active||(this.active=!0,this.restoreState(),document.addEventListener("click",this.boundClickHandler,!0),this.unsubscribeErrors=gt.subscribe(t=>{this.errorCount++}),this.startNavigationTracking(),this.startFormTracking(),this.checkErrorPage())}stop(){this.active&&(this.active=!1,document.removeEventListener("click",this.boundClickHandler,!0),this.unsubscribeErrors?.(),this.unsubscribeErrors=null,this.clickHistory=[],this.stopNavigationTracking(),this.stopFormTracking(),this.errorPageUrls.clear(),this.disconnectDomObserver())}startNavigationTracking(){this.unsubscribeNavigation=we(()=>this.handleNavigation()),this.boundPageLeaveHandler=()=>this.noteNavigationStarted(),window.addEventListener("beforeunload",this.boundPageLeaveHandler),window.addEventListener("pagehide",this.boundPageLeaveHandler)}stopNavigationTracking(){this.unsubscribeNavigation?.(),this.unsubscribeNavigation=null,this.navTimestamps=[],this.boundPageLeaveHandler&&(window.removeEventListener("beforeunload",this.boundPageLeaveHandler),window.removeEventListener("pagehide",this.boundPageLeaveHandler),this.boundPageLeaveHandler=null),this.lastNavigationAt=-1}noteNavigationStarted(){this.lastNavigationAt=Date.now()}restoreState(){const t=K();this.navTimestamps=t.navTimestamps,this.cooldownUntil=t.cooldownUntil,this.errorPageUrls=new Set(t.errorPageUrls)}persistState(){const t=K();xe({...t,navTimestamps:this.navTimestamps,cooldownUntil:this.cooldownUntil,errorPageUrls:[...this.errorPageUrls]})}startFormTracking(){this.boundSubmitHandler=t=>this.handleFormSubmit(t),this.boundInvalidHandler=t=>this.handleFormInvalid(t),document.addEventListener("submit",this.boundSubmitHandler,!0),document.addEventListener("invalid",this.boundInvalidHandler,!0)}stopFormTracking(){this.boundSubmitHandler&&(document.removeEventListener("submit",this.boundSubmitHandler,!0),this.boundSubmitHandler=null),this.boundInvalidHandler&&(document.removeEventListener("invalid",this.boundInvalidHandler,!0),this.boundInvalidHandler=null)}handleClick(t){const e=t.target;if(!e||C(e))return;this.trackFormSubmitIntent(e);const r=Date.now();this.clickHistory.push({target:e,time:r});const n=r-wn;if(this.clickHistory=this.clickHistory.filter(o=>o.time>n),this.clickHistory.filter(o=>o.target===e).length>=yn){this.clickHistory=[],this.emitHighPriority({signal:"rage_click",target:P(e),timestamp:r});return}this.isInteractive(e)||(this.deadClickCount++,this.deadClickCount>=3&&this.errorCount>0&&(this.deadClickCount=0,this.errorCount=0,this.emitIfReady({signal:"dead_click",target:P(e),timestamp:r}))),this.checkDeadClickDom(e,r)}handleNavigation(){const t=Date.now();this.noteNavigationStarted(),this.navTimestamps.push(t);const e=t-xn;this.navTimestamps=this.navTimestamps.filter(r=>r>e),this.navTimestamps.length>=vn&&(this.navTimestamps=[],this.emitIfReady({signal:"rapid_navigation",timestamp:t})),this.persistState(),setTimeout(()=>{this.active&&this.checkErrorPage()},Sn)}handleFormSubmit(t){const e=t.target;e instanceof HTMLFormElement&&(C(e)||(this.rememberSubmitAttempt(e),setTimeout(()=>{this.active&&e.querySelector('[aria-invalid="true"], .is-invalid')&&this.emitIfReady({signal:"form_failure",target:P(e),timestamp:Date.now()})},zt)))}trackFormSubmitIntent(t){const e=t.closest("button, input");(e instanceof HTMLButtonElement||e instanceof HTMLInputElement)&&(e.type!=="submit"&&e.type!=="image"||!e.form||C(e.form)||this.rememberSubmitAttempt(e.form))}rememberSubmitAttempt(t){this.recentSubmitForms.add(t),setTimeout(()=>{this.recentSubmitForms.delete(t)},zt)}handleFormInvalid(t){const e=t.target;if(!e||C(e))return;const r=e.closest("form");!r||!this.recentSubmitForms.has(r)||this.emitIfReady({signal:"form_failure",target:P(r),timestamp:Date.now()})}checkErrorPage(){const t=location.href;if(this.errorPageUrls.has(t))return;const e=document.title.toLowerCase();if(Ot.some(n=>n.test(e))){this.errorPageUrls.add(t),this.emitHighPriority({signal:"error_page",detail:document.title,timestamp:Date.now()});return}const r=document.querySelectorAll('h1, h2, [class*="error"], [class*="not-found"], [id*="error"], [id*="not-found"]');for(const n of r){const s=n.textContent??"";if(s.length<200&&Ot.some(o=>o.test(s.toLowerCase()))){this.errorPageUrls.add(t),this.emitHighPriority({signal:"error_page",detail:s.trim().slice(0,60),timestamp:Date.now()});return}}}checkDeadClickDom(t,e){this.looksInteractive(t)&&(this.pendingDomChecks++,this.ensureDomObserver(),setTimeout(()=>{this.pendingDomChecks--;const r=this.lastMutationAt>=e,n=this.lastNavigationAt>=e;this.pendingDomChecks===0&&this.disconnectDomObserver(),!r&&!n&&this.active&&this.emitIfReady({signal:"dead_click_dom",target:P(t),timestamp:e})},kn))}ensureDomObserver(){this.domObserver||(this.domObserver=new MutationObserver(()=>{this.lastMutationAt=Date.now()}),this.domObserver.observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0}))}disconnectDomObserver(){this.domObserver?.disconnect(),this.domObserver=null}looksInteractive(t){if(window.getComputedStyle(t).cursor==="pointer")return!0;if(t.classList)for(const r of t.classList){const n=r.toLowerCase();if(n.includes("btn")||n.includes("button"))return!0}return!1}isInteractive(t){if(En.has(t.tagName))return!0;const e=t.getAttribute("role");return!!(e&&Cn.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'))}emitIfReady(t){const e=Date.now();e<this.cooldownUntil||(this.cooldownUntil=e+F.COOLDOWN_MS,this.persistState(),this.onFrustration(t))}emitHighPriority(t){this.cooldownUntil=Date.now()+F.COOLDOWN_MS,this.persistState(),this.onFrustration(t)}};F.COOLDOWN_MS=6e4;let ct=F;function P(i){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("."):"",n=i.textContent?.trim().slice(0,30)??"";return`<${t}${e}${r}>${n?` "${n}"`:""}`}function _n(){return{page_url:B(window.location.href),user_agent:navigator.userAgent,browser:Tn(),os:An(),screen_width:window.screen.width,screen_height:window.screen.height}}function Tn(){const i=navigator.userAgent;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"}function An(){const i=navigator.userAgent;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"}function Ln(i,t,e,r,n,s,o,a,l){return{...j({description:i,...t,page_url:B(t.page_url),console_errors:e,annotations:r?[r]:[],target_element:r?.targetSelector?{selector:r.targetSelector,text:r.targetText??"",name:r.targetName??""}:void 0,recording_events:s?.events,recording_duration:s?.duration,breadcrumbs:l}),user_id:n?.id,user_email:n?.email,user_name:n?.name,reporter_external_id:n?void 0:o,reporter_email:n?void 0:a}}const Nt="mtb_anon_id",ke="mtb_reporter_email",Se="mtb_board_url";let qt=null,Ee=null,Ce=null;function jt(){try{const i=window.localStorage.getItem(Nt);if(i?.startsWith("anon_"))return i;const t=Yt();return window.localStorage.setItem(Nt,t),t}catch{return qt??(qt=Yt()),qt}}function Wt(){try{return window.localStorage.getItem(ke)??void 0}catch{return Ee??void 0}}function Pn(i){Ee=i;try{window.localStorage.setItem(ke,i)}catch{}}function Mn(){try{return window.localStorage.getItem(Se)??void 0}catch{return Ce??void 0}}function Vt(i){Ce=i;try{window.localStorage.setItem(Se,i)}catch{}}function Yt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`anon_${crypto.randomUUID()}`:`anon_${`${Date.now().toString(16)}-${Math.random().toString(16).slice(2,10)}`}`}const Rn={tab:"Feedback",toolbar:{markup:"Mark up",record:"Record",hint:"Click to comment, drag to draw",hintTouch:"Drag to mark what's wrong",hintRecord:"Recording your screen",exit:"Exit"},popup:{about:"About",placeholder:"Describe the issue or suggestion...",submit:"Submit",cancel:"Cancel",my_feedback:"My feedback",quickOptions:[{emoji:"🐛",label:"Something's broken"},{emoji:"💡",label:"I have a suggestion"},{emoji:"🤔",label:"I'm confused"}]},success:{title:"Sent — thanks!",message:"Your note and captured technical context are on their way to the team. You’ll hear back when it’s resolved.",title_no_ai:"Thanks! We've received your feedback.",message_no_ai:"The team will take it from here. You'll hear back when it's resolved.",view_feedback:"View my feedback",close:"Close",email_prompt:"Want updates? Leave your email and we'll let you know when it's resolved.",email_placeholder:"you@example.com",email_submit:"Notify me",email_saved:"You'll get an email when it's resolved.",email_error:"Couldn't save your email. Please try again."},error:{submit:"Failed to submit. Please try again."},pet:{bubble:"Need help?"},frustration:{prompt:"Something not working? Tell us.",action:"Annotate",dismiss:"Dismiss"},annotation:{drawing:"Drawing",element:"element"},draw:{note_placeholder:"Add a note to your drawing",undo:"Undo",redo:"Redo",cancel:"Cancel",submit:"Submit"},record:{stop:"Stop",timer_label:"Recording",max_reached:"Maximum recording time reached",replay_label:"screen-recording.json",play:"Play recording",close:"Close",preview_unavailable:"Preview unavailable"},clarify:{title:"Make This Better AI",subtitle:"Sharpening your feedback",thinking:"Thinking...",placeholder:"Type your answer — or skip the question",send:"Send",send_feedback:"Send feedback",skip:"Skip & send",retry:"Retry",error:"AI clarification failed. Please try again.",expired:"This feedback session expired before it could be sent. Please close the widget and submit again."}},In={tab:"反馈",toolbar:{markup:"标注",record:"录屏",hint:"点击标注,拖动绘制",hintTouch:"用手指圈出问题",hintRecord:"正在录制屏幕",exit:"退出"},popup:{about:"关于",placeholder:"描述问题或建议...",submit:"提交",cancel:"取消",my_feedback:"我的反馈",quickOptions:[{emoji:"🐛",label:"出问题了"},{emoji:"💡",label:"我有一个建议"},{emoji:"🤔",label:"我有点困惑"}]},success:{title:"已发送,感谢!",message:"您的反馈和采集到的技术上下文正在发送给团队。问题解决后,您会收到通知。",title_no_ai:"感谢!我们已收到您的反馈。",message_no_ai:"接下来由团队处理。问题解决后,您会收到通知。",view_feedback:"查看我的反馈",close:"关闭",email_prompt:"想了解进展?留下邮箱,问题解决后我们会通知您。",email_placeholder:"you@example.com",email_submit:"通知我",email_saved:"问题解决后您会收到邮件通知。",email_error:"邮箱保存失败,请重试。"},error:{submit:"提交失败,请重试。"},pet:{bubble:"需要帮助吗?"},frustration:{prompt:"遇到问题了?告诉我们。",action:"标注",dismiss:"关闭"},annotation:{drawing:"绘制",element:"元素"},draw:{note_placeholder:"给你的绘制添加说明",undo:"撤销",redo:"重做",cancel:"取消",submit:"提交"},record:{stop:"停止",timer_label:"录制中",max_reached:"已达到最长录制时间",replay_label:"screen-recording.json",play:"播放录屏",close:"关闭",preview_unavailable:"暂无法预览"},clarify:{title:"Make This Better AI",subtitle:"正在完善你的反馈",thinking:"思考中...",placeholder:"输入回答,或跳过问题",send:"发送",send_feedback:"发送反馈",skip:"跳过并发送",retry:"重试",error:"AI 澄清失败,请重试。",expired:"这条反馈在发送前已过期。请关闭组件后重新提交。"}},Dn={tab:"フィードバック",toolbar:{markup:"マークアップ",record:"録画",hint:"クリックでコメント、ドラッグで描画",hintTouch:"ドラッグして問題箇所を囲んでください",hintRecord:"画面を録画中",exit:"終了"},popup:{about:"概要",placeholder:"問題や提案を入力してください...",submit:"送信",cancel:"キャンセル",my_feedback:"自分のフィードバック",quickOptions:[{emoji:"🐛",label:"不具合があります"},{emoji:"💡",label:"提案があります"},{emoji:"🤔",label:"わかりにくいです"}]},success:{title:"送信しました。ありがとうございます!",message:"ご意見と取得した技術情報をチームに送信しました。解決次第お知らせします。",title_no_ai:"ありがとうございます!フィードバックを受け付けました。",message_no_ai:"チームが対応します。解決次第お知らせします。",view_feedback:"フィードバックを確認",close:"閉じる",email_prompt:"進捗を知りたい場合は、メールアドレスをご記入ください。解決次第お知らせします。",email_placeholder:"you@example.com",email_submit:"通知を受け取る",email_saved:"解決次第メールでお知らせします。",email_error:"メールアドレスを保存できませんでした。もう一度お試しください。"},error:{submit:"送信に失敗しました。もう一度お試しください。"},pet:{bubble:"お困りですか?"},frustration:{prompt:"うまくいかないことがありますか?お知らせください。",action:"注釈",dismiss:"閉じる"},annotation:{drawing:"描画",element:"要素"},draw:{note_placeholder:"描画にメモを追加",undo:"元に戻す",redo:"やり直す",cancel:"キャンセル",submit:"送信"},record:{stop:"停止",timer_label:"録画中",max_reached:"最大記録時間に達しました",replay_label:"screen-recording.json",play:"録画を再生",close:"閉じる",preview_unavailable:"プレビューは利用できません"},clarify:{title:"Make This Better AI",subtitle:"フィードバックを整えています",thinking:"考え中...",placeholder:"回答を入力、または質問をスキップ",send:"送信",send_feedback:"フィードバックを送信",skip:"スキップして送信",retry:"再試行",error:"AIによる確認に失敗しました。もう一度お試しください。",expired:"このフィードバックは送信される前に有効期限が切れました。ウィジェットを閉じて、もう一度送信してください。"}},Hn={tab:"피드백",toolbar:{markup:"마크업",record:"녹화",hint:"클릭하여 댓글, 드래그하여 그리기",hintTouch:"드래그해서 문제가 있는 곳을 표시하세요",hintRecord:"화면 녹화 중",exit:"나가기"},popup:{about:"정보",placeholder:"문제 또는 제안 사항을 설명해 주세요...",submit:"제출",cancel:"취소",my_feedback:"내 피드백",quickOptions:[{emoji:"🐛",label:"문제가 있어요"},{emoji:"💡",label:"제안이 있어요"},{emoji:"🤔",label:"헷갈려요"}]},success:{title:"전송되었습니다. 감사합니다!",message:"피드백과 수집된 기술 정보가 팀에 전달되었습니다. 해결되면 알려드리겠습니다.",title_no_ai:"감사합니다! 피드백을 접수했습니다.",message_no_ai:"팀에서 처리합니다. 해결되면 알려드리겠습니다.",view_feedback:"내 피드백 보기",close:"닫기",email_prompt:"진행 상황이 궁금하신가요? 이메일을 남겨주시면 해결 시 알려드립니다.",email_placeholder:"you@example.com",email_submit:"알림 받기",email_saved:"해결되면 이메일로 알려드립니다.",email_error:"이메일을 저장하지 못했습니다. 다시 시도해 주세요."},error:{submit:"제출에 실패했습니다. 다시 시도해 주세요."},pet:{bubble:"도움이 필요하신가요?"},frustration:{prompt:"문제가 있으신가요? 알려 주세요.",action:"주석",dismiss:"닫기"},annotation:{drawing:"그리기",element:"요소"},draw:{note_placeholder:"그림에 메모 추가",undo:"실행 취소",redo:"다시 실행",cancel:"취소",submit:"보내기"},record:{stop:"중지",timer_label:"녹화 중",max_reached:"최대 녹화 시간에 도달했습니다",replay_label:"screen-recording.json",play:"녹화 재생",close:"닫기",preview_unavailable:"미리보기를 사용할 수 없습니다"},clarify:{title:"Make This Better AI",subtitle:"피드백을 다듬는 중",thinking:"생각 중...",placeholder:"답변을 입력하거나 질문을 건너뛰세요",send:"보내기",send_feedback:"피드백 보내기",skip:"건너뛰고 보내기",retry:"재시도",error:"AI 확인에 실패했습니다. 다시 시도해 주세요.",expired:"이 피드백 세션은 전송되기 전에 만료되었습니다. 위젯을 닫고 다시 보내 주세요."}},$n={tab:"Comentarios",toolbar:{markup:"Anotar",record:"Grabar",hint:"Clic para comentar, arrastrar para dibujar",hintTouch:"Arrastra para marcar el problema",hintRecord:"Grabando pantalla",exit:"Salir"},popup:{about:"Acerca de",placeholder:"Describe el problema o sugerencia...",submit:"Enviar",cancel:"Cancelar",my_feedback:"Mis comentarios",quickOptions:[{emoji:"🐛",label:"Algo no funciona"},{emoji:"💡",label:"Tengo una sugerencia"},{emoji:"🤔",label:"Estoy confundido"}]},success:{title:"Enviado, ¡gracias!",message:"Tu nota y el contexto técnico capturado se han enviado al equipo. Te avisaremos cuando se resuelva.",title_no_ai:"¡Gracias! Hemos recibido tu comentario.",message_no_ai:"El equipo se encargará a partir de aquí. Te avisaremos cuando se resuelva.",view_feedback:"Ver mis comentarios",close:"Cerrar",email_prompt:"¿Quieres novedades? Deja tu correo y te avisaremos cuando se resuelva.",email_placeholder:"tu@ejemplo.com",email_submit:"Avisarme",email_saved:"Recibirás un correo cuando se resuelva.",email_error:"No se pudo guardar tu correo. Inténtalo de nuevo."},error:{submit:"Error al enviar. Por favor, inténtalo de nuevo."},pet:{bubble:"¿Necesitas ayuda?"},frustration:{prompt:"¿Algo no funciona? Cuéntanos.",action:"Anotar",dismiss:"Cerrar"},annotation:{drawing:"Dibujo",element:"elemento"},draw:{note_placeholder:"Añade una nota a tu dibujo",undo:"Deshacer",redo:"Rehacer",cancel:"Cancelar",submit:"Enviar"},record:{stop:"Detener",timer_label:"Grabando",max_reached:"Tiempo máximo de grabación alcanzado",replay_label:"screen-recording.json",play:"Reproducir grabación",close:"Cerrar",preview_unavailable:"Vista previa no disponible"},clarify:{title:"Make This Better AI",subtitle:"Afinando tus comentarios",thinking:"Pensando...",placeholder:"Escribe tu respuesta — u omite la pregunta",send:"Enviar",send_feedback:"Enviar comentario",skip:"Omitir y enviar",retry:"Reintentar",error:"No se pudo completar la aclaración con IA. Inténtalo de nuevo.",expired:"Esta sesión de comentarios caducó antes de poder enviarse. Cierra el widget y envíalo de nuevo."}},Fn={tab:"Avis",toolbar:{markup:"Annoter",record:"Enregistrer",hint:"Cliquer pour commenter, glisser pour dessiner",hintTouch:"Faites glisser pour marquer le problème",hintRecord:"Enregistrement de l'écran",exit:"Quitter"},popup:{about:"À propos",placeholder:"Décrivez le problème ou votre suggestion...",submit:"Envoyer",cancel:"Annuler",my_feedback:"Mes avis",quickOptions:[{emoji:"🐛",label:"Quelque chose ne fonctionne pas"},{emoji:"💡",label:"J'ai une suggestion"},{emoji:"🤔",label:"Je suis perplexe"}]},success:{title:"Envoyé, merci !",message:"Votre message et le contexte technique collecté ont été transmis à l’équipe. Vous serez informé(e) dès que ce sera résolu.",title_no_ai:"Merci ! Nous avons bien reçu votre avis.",message_no_ai:"L’équipe prend le relais. Vous serez informé(e) dès que ce sera résolu.",view_feedback:"Voir mes avis",close:"Fermer",email_prompt:"Envie de suivre l'avancement ? Laissez votre e-mail et nous vous préviendrons une fois résolu.",email_placeholder:"vous@exemple.com",email_submit:"Me prévenir",email_saved:"Vous recevrez un e-mail une fois résolu.",email_error:"Impossible d'enregistrer votre e-mail. Veuillez réessayer."},error:{submit:"Échec de l'envoi. Veuillez réessayer."},pet:{bubble:"Besoin d'aide ?"},frustration:{prompt:"Un problème ? Dites-le-nous.",action:"Annoter",dismiss:"Fermer"},annotation:{drawing:"Dessin",element:"élément"},draw:{note_placeholder:"Ajoutez une note à votre dessin",undo:"Annuler",redo:"Rétablir",cancel:"Annuler",submit:"Envoyer"},record:{stop:"Arrêter",timer_label:"Enregistrement",max_reached:"Durée maximale d'enregistrement atteinte",replay_label:"screen-recording.json",play:"Lire l'enregistrement",close:"Fermer",preview_unavailable:"Aperçu indisponible"},clarify:{title:"Make This Better AI",subtitle:"Affinement de votre retour",thinking:"Réflexion...",placeholder:"Saisissez votre réponse — ou ignorez la question",send:"Envoyer",send_feedback:"Envoyer le retour",skip:"Ignorer et envoyer",retry:"Réessayer",error:"La clarification par IA a échoué. Réessayez.",expired:"Cette session de retour a expiré avant d'avoir pu être envoyée. Fermez le widget et renvoyez-la."}},Bn={tab:"Feedback",toolbar:{markup:"Markieren",record:"Aufnehmen",hint:"Klicken zum Kommentieren, ziehen zum Zeichnen",hintTouch:"Ziehen, um das Problem zu markieren",hintRecord:"Bildschirm wird aufgenommen",exit:"Beenden"},popup:{about:"Info",placeholder:"Beschreiben Sie das Problem oder Ihren Vorschlag...",submit:"Absenden",cancel:"Abbrechen",my_feedback:"Mein Feedback",quickOptions:[{emoji:"🐛",label:"Etwas funktioniert nicht"},{emoji:"💡",label:"Ich habe einen Vorschlag"},{emoji:"🤔",label:"Ich bin verwirrt"}]},success:{title:"Gesendet, vielen Dank!",message:"Ihre Nachricht und der erfasste technische Kontext wurden an das Team gesendet. Sie werden benachrichtigt, sobald das Problem gelöst ist.",title_no_ai:"Vielen Dank! Wir haben Ihr Feedback erhalten.",message_no_ai:"Das Team übernimmt ab hier. Sie werden benachrichtigt, sobald das Problem gelöst ist.",view_feedback:"Mein Feedback ansehen",close:"Schließen",email_prompt:"Updates gewünscht? Hinterlassen Sie Ihre E-Mail und wir melden uns, sobald es gelöst ist.",email_placeholder:"sie@beispiel.de",email_submit:"Benachrichtigen",email_saved:"Sie erhalten eine E-Mail, sobald es gelöst ist.",email_error:"E-Mail konnte nicht gespeichert werden. Bitte versuchen Sie es erneut."},error:{submit:"Senden fehlgeschlagen. Bitte versuchen Sie es erneut."},pet:{bubble:"Brauchen Sie Hilfe?"},frustration:{prompt:"Etwas funktioniert nicht? Sagen Sie es uns.",action:"Kommentieren",dismiss:"Schließen"},annotation:{drawing:"Zeichnung",element:"Element"},draw:{note_placeholder:"Fügen Sie Ihrer Zeichnung eine Notiz hinzu",undo:"Rückgängig",redo:"Wiederholen",cancel:"Abbrechen",submit:"Absenden"},record:{stop:"Stopp",timer_label:"Aufnahme",max_reached:"Maximale Aufnahmedauer erreicht",replay_label:"screen-recording.json",play:"Aufnahme abspielen",close:"Schließen",preview_unavailable:"Vorschau nicht verfügbar"},clarify:{title:"Make This Better AI",subtitle:"Wir schärfen dein Feedback",thinking:"Einen Moment...",placeholder:"Antwort eingeben — oder Frage überspringen",send:"Senden",send_feedback:"Feedback senden",skip:"Überspringen & senden",retry:"Erneut versuchen",error:"Die KI-Klärung ist fehlgeschlagen. Bitte erneut versuchen.",expired:"Diese Feedback-Sitzung ist abgelaufen, bevor sie gesendet werden konnte. Bitte schließe das Widget und sende erneut."}},M={en:Rn,"zh-CN":In,ja:Dn,ko:Hn,es:$n,fr:Fn,de:Bn};function Xt(i){if(M[i])return M[i];const t=i.split("-")[0];return M[t]?M[t]:M.en}class Un{constructor(t,e,r,n){this.intervalId=null,this.getDuration=r,this.el=t.el("div","mtb-record-bar"),this.el.innerHTML=`
139
+ <button class="mtb-close-link">${c(e.success.close)}</button>
140
+ `,t.append(this.el),this.el.querySelector(".mtb-close-link").addEventListener("click",r),n&&this.el.querySelector(".mtb-view-feedback-link").addEventListener("click",n),s?.emailCapture?this.bindEmailCapture(s.emailCapture.onSubmit):setTimeout(()=>r(),Ni)}bindEmailCapture(t){const e=this.el.querySelector(".mtb-email-input"),r=this.el.querySelector(".mtb-email-submit"),n=this.el.querySelector(".mtb-email-error"),s=async()=>{const o=e.value.trim();if(!qi.test(o)){e.classList.add("mtb-email-invalid");return}e.classList.remove("mtb-email-invalid"),n.hidden=!0,r.disabled=!0,await t(o)?this.el.querySelector(".mtb-email-capture").innerHTML=`<div class="mtb-email-saved">${c(this.messages.success.email_saved)}</div>`:(n.hidden=!1,r.disabled=!1)};r.addEventListener("click",s),e.addEventListener("keydown",o=>{o.key==="Enter"&&s()})}destroy(){this.el.remove()}}function Wi(i,t){if(i.match(/^[a-z]+:\/\//i))return i;if(i.match(/^\/\//))return window.location.protocol+i;if(i.match(/^[a-z]+:/i))return i;const e=document.implementation.createHTMLDocument(),r=e.createElement("base"),n=e.createElement("a");return e.head.appendChild(r),e.body.appendChild(n),t&&(r.href=t),n.href=i,n.href}const Vi=(()=>{let i=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(i+=1,`u${t()}${i}`)})();function k(i){const t=[];for(let e=0,r=i.length;e<r;e++)t.push(i[e]);return t}let S=null;function ae(i={}){return S||(i.includeStyleProperties?(S=i.includeStyleProperties,S):(S=k(window.getComputedStyle(document.documentElement)),S))}function V(i,t){const r=(i.ownerDocument.defaultView||window).getComputedStyle(i).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function Yi(i){const t=V(i,"border-left-width"),e=V(i,"border-right-width");return i.clientWidth+t+e}function Xi(i){const t=V(i,"border-top-width"),e=V(i,"border-bottom-width");return i.clientHeight+t+e}function le(i,t={}){const e=t.width||Yi(i),r=t.height||Xi(i);return{width:e,height:r}}function Ki(){let i,t;try{t=process}catch{}const e=t&&t.env?t.env.devicePixelRatio:null;return e&&(i=parseInt(e,10),Number.isNaN(i)&&(i=1)),i||window.devicePixelRatio||1}const f=16384;function Gi(i){(i.width>f||i.height>f)&&(i.width>f&&i.height>f?i.width>i.height?(i.height*=f/i.width,i.width=f):(i.width*=f/i.height,i.height=f):i.width>f?(i.height*=f/i.width,i.width=f):(i.width*=f/i.height,i.height=f))}function Y(i){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=e,r.crossOrigin="anonymous",r.decoding="async",r.src=i})}async function Ji(i){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(i)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function Zi(i,t,e){const r="http://www.w3.org/2000/svg",n=document.createElementNS(r,"svg"),s=document.createElementNS(r,"foreignObject");return n.setAttribute("width",`${t}`),n.setAttribute("height",`${e}`),n.setAttribute("viewBox",`0 0 ${t} ${e}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),n.appendChild(s),s.appendChild(i),Ji(n)}const p=(i,t)=>{if(i instanceof t)return!0;const e=Object.getPrototypeOf(i);return e===null?!1:e.constructor.name===t.name||p(e,t)};function Qi(i){const t=i.getPropertyValue("content");return`${i.cssText} content: '${t.replace(/'|"/g,"")}';`}function tr(i,t){return ae(t).map(e=>{const r=i.getPropertyValue(e),n=i.getPropertyPriority(e);return`${e}: ${r}${n?" !important":""};`}).join(" ")}function er(i,t,e,r){const n=`.${i}:${t}`,s=e.cssText?Qi(e):tr(e,r);return document.createTextNode(`${n}{${s}}`)}function Tt(i,t,e,r){const n=window.getComputedStyle(i,e),s=n.getPropertyValue("content");if(s===""||s==="none")return;const o=Vi();try{t.className=`${t.className} ${o}`}catch{return}const a=document.createElement("style");a.appendChild(er(o,e,n,r)),t.appendChild(a)}function ir(i,t,e){Tt(i,t,":before",e),Tt(i,t,":after",e)}const At="application/font-woff",Lt="image/jpeg",rr={woff:At,woff2:At,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Lt,jpeg:Lt,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function nr(i){const t=/\.([^./]*?)$/g.exec(i);return t?t[1]:""}function pt(i){const t=nr(i).toLowerCase();return rr[t]||""}function sr(i){return i.split(/,/)[1]}function at(i){return i.search(/^(data:)/)!==-1}function or(i,t){return`data:${t};base64,${i}`}async function ce(i,t,e){const r=await fetch(i,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const n=await r.blob();return new Promise((s,o)=>{const a=new FileReader;a.onerror=o,a.onloadend=()=>{try{s(e({res:r,result:a.result}))}catch(l){o(l)}},a.readAsDataURL(n)})}const et={};function ar(i,t,e){let r=i.replace(/\?.*/,"");return e&&(r=i),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function ft(i,t,e){const r=ar(i,t,e.includeQueryParams);if(et[r]!=null)return et[r];e.cacheBust&&(i+=(/\?/.test(i)?"&":"?")+new Date().getTime());let n;try{const s=await ce(i,e.fetchRequestInit,({res:o,result:a})=>(t||(t=o.headers.get("Content-Type")||""),sr(a)));n=or(s,t)}catch(s){n=e.imagePlaceholder||"";let o=`Failed to fetch resource: ${i}`;s&&(o=typeof s=="string"?s:s.message),o&&console.warn(o)}return et[r]=n,n}async function lr(i){const t=i.toDataURL();return t==="data:,"?i.cloneNode(!1):Y(t)}async function cr(i,t){if(i.currentSrc){const s=document.createElement("canvas"),o=s.getContext("2d");s.width=i.clientWidth,s.height=i.clientHeight,o?.drawImage(i,0,0,s.width,s.height);const a=s.toDataURL();return Y(a)}const e=i.poster,r=pt(e),n=await ft(e,r,t);return Y(n)}async function dr(i,t){var e;try{if(!((e=i?.contentDocument)===null||e===void 0)&&e.body)return await Q(i.contentDocument.body,t,!0)}catch{}return i.cloneNode(!1)}async function hr(i,t){return p(i,HTMLCanvasElement)?lr(i):p(i,HTMLVideoElement)?cr(i,t):p(i,HTMLIFrameElement)?dr(i,t):i.cloneNode(de(i))}const ur=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SLOT",de=i=>i.tagName!=null&&i.tagName.toUpperCase()==="SVG";async function mr(i,t,e){var r,n;if(de(t))return t;let s=[];return ur(i)&&i.assignedNodes?s=k(i.assignedNodes()):p(i,HTMLIFrameElement)&&(!((r=i.contentDocument)===null||r===void 0)&&r.body)?s=k(i.contentDocument.body.childNodes):s=k(((n=i.shadowRoot)!==null&&n!==void 0?n:i).childNodes),s.length===0||p(i,HTMLVideoElement)||await s.reduce((o,a)=>o.then(()=>Q(a,e)).then(l=>{l&&t.appendChild(l)}),Promise.resolve()),t}function br(i,t,e){const r=t.style;if(!r)return;const n=window.getComputedStyle(i);n.cssText?(r.cssText=n.cssText,r.transformOrigin=n.transformOrigin):ae(e).forEach(s=>{let o=n.getPropertyValue(s);s==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),p(i,HTMLIFrameElement)&&s==="display"&&o==="inline"&&(o="block"),s==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(s,o,n.getPropertyPriority(s))})}function pr(i,t){p(i,HTMLTextAreaElement)&&(t.innerHTML=i.value),p(i,HTMLInputElement)&&t.setAttribute("value",i.value)}function fr(i,t){if(p(i,HTMLSelectElement)){const e=t,r=Array.from(e.children).find(n=>i.value===n.getAttribute("value"));r&&r.setAttribute("selected","")}}function gr(i,t,e){return p(t,Element)&&(br(i,t,e),ir(i,t,e),pr(i,t),fr(i,t)),t}async function yr(i,t){const e=i.querySelectorAll?i.querySelectorAll("use"):[];if(e.length===0)return i;const r={};for(let s=0;s<e.length;s++){const a=e[s].getAttribute("xlink:href");if(a){const l=i.querySelector(a),d=document.querySelector(a);!l&&d&&!r[a]&&(r[a]=await Q(d,t,!0))}}const n=Object.values(r);if(n.length){const s="http://www.w3.org/1999/xhtml",o=document.createElementNS(s,"svg");o.setAttribute("xmlns",s),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const a=document.createElementNS(s,"defs");o.appendChild(a);for(let l=0;l<n.length;l++)a.appendChild(n[l]);i.appendChild(o)}return i}async function Q(i,t,e){return!e&&t.filter&&!t.filter(i)?null:Promise.resolve(i).then(r=>hr(r,t)).then(r=>mr(i,r,t)).then(r=>gr(i,r,t)).then(r=>yr(r,t))}const he=/url\((['"]?)([^'"]+?)\1\)/g,wr=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,vr=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function xr(i){const t=i.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function kr(i){const t=[];return i.replace(he,(e,r,n)=>(t.push(n),e)),t.filter(e=>!at(e))}async function Sr(i,t,e,r,n){try{const s=e?Wi(t,e):t,o=pt(t);let a;return n||(a=await ft(s,o,r)),i.replace(xr(t),`$1${a}$3`)}catch{}return i}function Er(i,{preferredFontFormat:t}){return t?i.replace(vr,e=>{for(;;){const[r,,n]=wr.exec(e)||[];if(!n)return"";if(n===t)return`src: ${r};`}}):i}function ue(i){return i.search(he)!==-1}async function me(i,t,e){if(!ue(i))return i;const r=Er(i,e);return kr(r).reduce((s,o)=>s.then(a=>Sr(a,o,t,e)),Promise.resolve(r))}async function E(i,t,e){var r;const n=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(i);if(n){const s=await me(n,null,e);return t.style.setProperty(i,s,t.style.getPropertyPriority(i)),!0}return!1}async function Cr(i,t){await E("background",i,t)||await E("background-image",i,t),await E("mask",i,t)||await E("-webkit-mask",i,t)||await E("mask-image",i,t)||await E("-webkit-mask-image",i,t)}async function _r(i,t){const e=p(i,HTMLImageElement);if(!(e&&!at(i.src))&&!(p(i,SVGImageElement)&&!at(i.href.baseVal)))return;const r=e?i.src:i.href.baseVal,n=await ft(r,pt(r),t);await new Promise((s,o)=>{i.onload=s,i.onerror=t.onImageErrorHandler?(...l)=>{try{s(t.onImageErrorHandler(...l))}catch(d){o(d)}}:o;const a=i;a.decode&&(a.decode=s),a.loading==="lazy"&&(a.loading="eager"),e?(i.srcset="",i.src=n):i.href.baseVal=n})}async function Tr(i,t){const r=k(i.childNodes).map(n=>be(n,t));await Promise.all(r).then(()=>i)}async function be(i,t){p(i,Element)&&(await Cr(i,t),await _r(i,t),await Tr(i,t))}function Ar(i,t){const{style:e}=i;t.backgroundColor&&(e.backgroundColor=t.backgroundColor),t.width&&(e.width=`${t.width}px`),t.height&&(e.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(n=>{e[n]=r[n]}),i}const Pt={};async function Mt(i){let t=Pt[i];if(t!=null)return t;const r=await(await fetch(i)).text();return t={url:i,cssText:r},Pt[i]=t,t}async function Rt(i,t){let e=i.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,s=(e.match(/url\([^)]+\)/g)||[]).map(async o=>{let a=o.replace(r,"$1");return a.startsWith("https://")||(a=new URL(a,i.url).href),ce(a,t.fetchRequestInit,({result:l})=>(e=e.replace(o,`url(${l})`),[o,l]))});return Promise.all(s).then(()=>e)}function It(i){if(i==null)return[];const t=[],e=/(\/\*[\s\S]*?\*\/)/gi;let r=i.replace(e,"");const n=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const l=n.exec(r);if(l===null)break;t.push(l[0])}r=r.replace(n,"");const s=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",a=new RegExp(o,"gi");for(;;){let l=s.exec(r);if(l===null){if(l=a.exec(r),l===null)break;s.lastIndex=a.lastIndex}else a.lastIndex=s.lastIndex;t.push(l[0])}return t}async function Lr(i,t){const e=[],r=[];return i.forEach(n=>{if("cssRules"in n)try{k(n.cssRules||[]).forEach((s,o)=>{if(s.type===CSSRule.IMPORT_RULE){let a=o+1;const l=s.href,d=Mt(l).then(u=>Rt(u,t)).then(u=>It(u).forEach(h=>{try{n.insertRule(h,h.startsWith("@import")?a+=1:n.cssRules.length)}catch(m){console.error("Error inserting rule from remote css",{rule:h,error:m})}})).catch(u=>{console.error("Error loading remote css",u.toString())});r.push(d)}})}catch(s){const o=i.find(a=>a.href==null)||document.styleSheets[0];n.href!=null&&r.push(Mt(n.href).then(a=>Rt(a,t)).then(a=>It(a).forEach(l=>{o.insertRule(l,o.cssRules.length)})).catch(a=>{console.error("Error loading remote stylesheet",a)})),console.error("Error inlining remote css file",s)}}),Promise.all(r).then(()=>(i.forEach(n=>{if("cssRules"in n)try{k(n.cssRules||[]).forEach(s=>{e.push(s)})}catch(s){console.error(`Error while reading CSS rules from ${n.href}`,s)}}),e))}function Pr(i){return i.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>ue(t.style.getPropertyValue("src")))}async function Mr(i,t){if(i.ownerDocument==null)throw new Error("Provided element is not within a Document");const e=k(i.ownerDocument.styleSheets),r=await Lr(e,t);return Pr(r)}function pe(i){return i.trim().replace(/["']/g,"")}function Rr(i){const t=new Set;function e(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(s=>{t.add(pe(s))}),Array.from(r.children).forEach(s=>{s instanceof HTMLElement&&e(s)})}return e(i),t}async function Ir(i,t){const e=await Mr(i,t),r=Rr(i);return(await Promise.all(e.filter(s=>r.has(pe(s.style.fontFamily))).map(s=>{const o=s.parentStyleSheet?s.parentStyleSheet.href:null;return me(s.cssText,o,t)}))).join(`
141
+ `)}async function Dr(i,t){const e=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await Ir(i,t);if(e){const r=document.createElement("style"),n=document.createTextNode(e);r.appendChild(n),i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r)}}async function Hr(i,t={}){const{width:e,height:r}=le(i,t),n=await Q(i,t,!0);return await Dr(n,t),await be(n,t),Ar(n,t),await Zi(n,e,r)}async function $r(i,t={}){const{width:e,height:r}=le(i,t),n=await Hr(i,t),s=await Y(n),o=document.createElement("canvas"),a=o.getContext("2d"),l=t.pixelRatio||Ki(),d=t.canvasWidth||e,u=t.canvasHeight||r;return o.width=d*l,o.height=u*l,t.skipAutoScale||Gi(o),o.style.width=`${d}`,o.style.height=`${u}`,t.backgroundColor&&(a.fillStyle=t.backgroundColor,a.fillRect(0,0,o.width,o.height)),a.drawImage(s,0,0,o.width,o.height),o}async function Fr(i,t={}){return(await $r(i,t)).toDataURL("image/jpeg",t.quality||1)}const it=400,rt=300,Dt=150,Ht=.3,$t=.85;function fe(i){let t=1/0,e=1/0,r=-1/0,n=-1/0;for(const s of i)if(s.type==="pin"){if(t=Math.min(t,s.x),e=Math.min(e,s.y),r=Math.max(r,s.x),n=Math.max(n,s.y),s.targetRect){const o=s.targetRect;t=Math.min(t,o.left),e=Math.min(e,o.top),r=Math.max(r,o.left+o.width),n=Math.max(n,o.bottom)}}else if(s.type==="draw"&&s.drawPath)for(const o of ge(s.drawPath))for(const[a,l]of o)t=Math.min(t,a),e=Math.min(e,l),r=Math.max(r,a),n=Math.max(n,l);return!isFinite(t)||!isFinite(e)?null:{minX:t,minY:e,maxX:r,maxY:n}}function Br(i,t,e){const r=fe(i);if(!r)return null;const n=Math.max(Dt,t*Ht),s=Math.max(Dt,e*Ht);let o=r.minX-n,a=r.minY-s,l=r.maxX-r.minX+n*2,d=r.maxY-r.minY+s*2;return l<it&&(o-=(it-l)/2,l=it),d<rt&&(a-=(rt-d)/2,d=rt),l=Math.min(l,t),d=Math.min(d,e),o=Math.min(Math.max(0,o),t-l),a=Math.min(Math.max(0,a),e-d),l>=t*$t&&d>=e*$t?null:{x:Math.round(o),y:Math.round(a),width:Math.round(l),height:Math.round(d)}}function Ur(i,t){const e=document.createElement("canvas");e.width=t.width,e.height=t.height;const r=e.getContext("2d");return r&&r.drawImage(i,t.x,t.y,t.width,t.height,0,0,t.width,t.height),e}async function zr(i=[]){try{const t=Qr(document.body),e=i.map(Or),r=Kr(document.body),n=await Fr(document.body,{quality:.85,width:t.width,height:t.height,pixelRatio:Zr(t),backgroundColor:"#ffffff",skipFonts:!1,skipAutoScale:!1,filter:s=>!(s instanceof HTMLElement&&s.id==="mtb-widget-host")});return await Vr(n,e,t,r)}catch{return null}}function Or(i){const t=qr(Nr(i));return t.x===0&&t.y===0?i:{...i,x:i.x+t.x,y:i.y+t.y,targetRect:i.targetRect&&{...i.targetRect,top:i.targetRect.top+t.y,left:i.targetRect.left+t.x,bottom:i.targetRect.bottom+t.y},drawPath:i.drawPath&&Wr(i.drawPath,t)}}function Nr(i){if(i.targetSelector)try{const t=document.querySelector(i.targetSelector);if(t)return t}catch{}return document.elementsFromPoint?.(i.x,i.y)[0]??null}function qr(i){let t=0,e=0,r=i;for(;r&&r!==document.body;)r instanceof HTMLElement&&(t+=r.scrollLeft,e+=r.scrollTop),r=jr(r);return{x:t,y:e}}function jr(i){if(i.parentElement)return i.parentElement;const t=i.getRootNode();return t instanceof ShadowRoot?t.host:null}function Wr(i,t){return i.replace(/([ML])\s*(-?(?:\d+\.?\d*|\.\d+))\s+(-?(?:\d+\.?\d*|\.\d+))/g,(e,r,n,s)=>`${r} ${Number(n)+t.x} ${Number(s)+t.y}`)}async function Vr(i,t,e,r){const n=document.createElement("canvas"),s=n.getContext("2d");if(!s)return null;const o=await en(i);if(!o)return null;n.width=o.naturalWidth||window.innerWidth,n.height=o.naturalHeight||window.innerHeight,s.drawImage(o,0,0);const a=n.width/e.width,l=n.height/e.height;s.fillStyle="#e5e7eb";for(const h of r)s.fillRect((h.left-e.left)*a,(h.top-e.top)*l,h.width*a,h.height*l);let d=0;for(const h of t)h.type==="draw"&&h.drawPath?Jr(s,h.drawPath,e,a,l):h.type==="pin"&&tn(s,(h.x-e.left)*a,(h.y-e.top)*l,++d);if(!Yr(t,e,a,l,n))return O(n);const u=Br(t,window.innerWidth,window.innerHeight);if(u){const h=Xr(u,e,a,l,n);return O(h?Ur(n,h):n)}return O(n)}function Yr(i,t,e,r,n){const s=fe(i);if(!s)return!0;const o=(s.minX-t.left)*e,a=(s.minY-t.top)*r,l=(s.maxX-t.left)*e,d=(s.maxY-t.top)*r;return o>=0&&a>=0&&l<=n.width&&d<=n.height}function Xr(i,t,e,r,n){const s=Math.min(n.width,Math.round(i.width*e)),o=Math.min(n.height,Math.round(i.height*r));if(s<=0||o<=0)return null;const a=Math.round((i.x-t.left)*e),l=Math.round((i.y-t.top)*r);return{x:Math.min(Math.max(0,a),n.width-s),y:Math.min(Math.max(0,l),n.height-o),width:s,height:o}}function Kr(i){const t=[];for(const s of Gr(i,`.${J}`))nt(t,s.getBoundingClientRect());for(const s of i.querySelectorAll("input, textarea, select")){if(Ft(s))continue;const o=s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement?s.value:"",a=s.closest(`.${U}`)!==null,l=ee(s)||W(o,s)!==o;!a&&!l||nt(t,s.getBoundingClientRect(),Ut)}const e=document.createTreeWalker(i,NodeFilter.SHOW_TEXT),r=ie();let n=e.nextNode();for(;n;){const s=n.parentElement,o=n.textContent??"",a=s?.closest(`.${U}`)!==null,l=A(o)!==o||re(n,r);if(s&&!Ft(s)&&(a||l)){const d=document.createRange();d.selectNodeContents(n);for(const u of Array.from(d.getClientRects()))nt(t,u,Ut)}n=e.nextNode()}return t}function Gr(i,t){const e=Array.from(i.querySelectorAll(t));return i.matches(t)?[i,...e]:e}function Ft(i){return i.closest("#mtb-widget-host")!==null||i.closest(`.${J}`)!==null}function nt(i,t,e=0){if(![t.left,t.top,t.width,t.height].every(Number.isFinite))throw new Error("Invalid privacy redaction geometry");t.width<=0||t.height<=0||i.push({left:t.left-e,top:t.top-e,width:t.width+e*2,height:t.height+e*2})}function Jr(i,t,e,r,n){i.save(),i.strokeStyle=G,i.lineWidth=3.5,i.lineCap="round",i.lineJoin="round",i.shadowColor=ut(.35),i.shadowOffsetY=1,i.shadowBlur=2;for(const s of ge(t))if(s.length!==0){i.beginPath(),i.moveTo((s[0][0]-e.left)*r,(s[0][1]-e.top)*n);for(let o=1;o<s.length;o++)i.lineTo((s[o][0]-e.left)*r,(s[o][1]-e.top)*n);i.stroke()}i.restore()}const Bt=16e6,Ut=2;function Zr(i){const t=i.width*i.height;return!Number.isFinite(t)||t<=Bt?1:Math.sqrt(Bt/t)}function Qr(i){const t=i.getBoundingClientRect(),e=window.getComputedStyle(i),r=parseFloat(e.borderLeftWidth)+parseFloat(e.borderRightWidth),n=parseFloat(e.borderTopWidth)+parseFloat(e.borderBottomWidth),s=document.documentElement,o=Math.max(i.clientWidth,i.scrollWidth,s.clientWidth,s.scrollWidth),a=Math.max(i.clientHeight,i.scrollHeight,s.clientHeight,s.scrollHeight);return{left:t.left,top:t.top,width:o+(Number.isFinite(r)?r:0)||window.innerWidth,height:a+(Number.isFinite(n)?n:0)||window.innerHeight}}function tn(i,t,e,r){i.save(),i.shadowColor=ut(.45),i.shadowOffsetY=2,i.shadowBlur=8,i.fillStyle=G,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 ${Je}`,i.textAlign="center",i.textBaseline="middle",i.fillText(String(r),t,e),i.restore()}function ge(i){const t=[];let e=null;const r=i.match(/[ML]\s*[-\d.]+\s+[-\d.]+/g)??[];for(const n of r){const[s,o]=n.slice(1).trim().split(/\s+/).map(Number);Number.isNaN(s)||Number.isNaN(o)||(n[0]==="M"?(e=[[s,o]],t.push(e)):e&&e.push([s,o]))}return t}function en(i){return new Promise(t=>{const e=new Image;e.onload=()=>t(e),e.onerror=()=>t(null),e.src=i})}function O(i){return new Promise(t=>{try{i.toBlob(e=>t(e),"image/jpeg",.85)}catch{t(null)}})}class rn{constructor(){this.listeners=new Set,this.originalOnError=null,this.installedOnError=null,this.rejectionHandler=null,this.hooked=!1}subscribe(t){return this.listeners.add(t),this.hook(),()=>{this.listeners.delete(t),this.listeners.size===0&&this.unhook()}}hook(){this.hooked||(this.hooked=!0,this.originalOnError=window.onerror,this.installedOnError=(t,e,r,n,s)=>(this.emit({name:nn(s),message:String(t),source:e,line:r,col:n,error:s}),this.originalOnError?this.originalOnError.call(window,t,e,r,n,s):!1),window.onerror=this.installedOnError,this.rejectionHandler=t=>{const e=t.reason instanceof Error?t.reason.message:String(t.reason),r=t.reason instanceof Error?t.reason.name:"UnhandledRejection";this.emit({name:r,message:`Unhandled rejection: ${e}`})},window.addEventListener("unhandledrejection",this.rejectionHandler))}unhook(){this.hooked&&(this.hooked=!1,window.onerror===this.installedOnError&&(window.onerror=this.originalOnError),this.installedOnError=null,this.originalOnError=null,this.rejectionHandler&&(window.removeEventListener("unhandledrejection",this.rejectionHandler),this.rejectionHandler=null))}emit(t){for(const e of this.listeners)e(t)}}const gt=new rn;function nn(i){return!i||typeof i!="object"||!("name"in i)?void 0:String(i.name)||void 0}function ye(i){const t=sn(i.name)||on(i.message),e=an(i);return e?`${t} (${e})`:t}function sn(i){return i&&/^[A-Za-z][A-Za-z0-9]*(?:Error|Exception|Rejection)$/.test(i)?i:""}function on(i){return i.match(/^([A-Za-z][A-Za-z0-9]*(?:Error|Exception))\b/)?.[1]??"Error"}function an(i){if(!i.source)return"";try{const t=new URL(i.source,window.location.href).pathname;return i.line==null?t:`${t}:${i.line}:${i.col??0}`}catch{return""}}const ln=20;class cn{constructor(){this.errors=[],this.unsubscribe=null}start(){this.unsubscribe||(this.unsubscribe=gt.subscribe(t=>this.record(t)))}record(t){this.addError(ye(t))}addError(t){this.errors.length>=ln||this.errors.includes(t)||this.errors.push(t)}getErrors(){return[...this.errors]}stop(){this.unsubscribe?.(),this.unsubscribe=null}}const N=new Set;let I=null,D=null,H=null,X=null,$=null;function we(i){N.add(i),dn();let t=!1;return()=>{t||(t=!0,N.delete(i),N.size===0&&hn())}}function st(){for(const i of[...N])try{i()}catch{}}function dn(){if(H)return;$=()=>st(),window.addEventListener("popstate",$),I=history.pushState,D=history.replaceState;const i=I,t=D;H=function(e,r,n){i.call(history,e,r,n),st()},X=function(e,r,n){t.call(history,e,r,n),st()},history.pushState=H,history.replaceState=X}function hn(){$&&(window.removeEventListener("popstate",$),$=null),I&&history.pushState===H&&(history.pushState=I),D&&history.replaceState===X&&(history.replaceState=D),I=null,D=null,H=null,X=null}const un=20;function mn(i){return Z(i)?mt(i):ht(i)}function bn(i){return Z(i)?se(i):Zt(i)}class pn{constructor(){this.breadcrumbs=[],this.active=!1,this.unsubscribeErrors=null,this.unsubscribeNavigation=null,this.lastUrl="",this.boundClickHandler=t=>this.handleClick(t),this.boundChangeHandler=t=>this.handleChange(t)}start(){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=gt.subscribe(t=>this.recordError(t)),this.unsubscribeNavigation=we(()=>this.handleNavigation()))}stop(){this.active&&(this.active=!1,document.removeEventListener("click",this.boundClickHandler,!0),document.removeEventListener("change",this.boundChangeHandler,!0),this.unsubscribeErrors?.(),this.unsubscribeErrors=null,this.unsubscribeNavigation?.(),this.unsubscribeNavigation=null)}getBreadcrumbs(){return[...this.breadcrumbs]}add(t){this.breadcrumbs.push(t),this.breadcrumbs.length>un&&this.breadcrumbs.shift()}handleClick(t){const e=t.target;if(e&&!C(e))try{this.add({type:"ui",category:"ui.click",timestamp:Date.now(),message:mn(e),data:{selector:bn(e)}})}catch{}}handleChange(t){const e=t.target;if(e&&!C(e))try{const r=e,n=Z(e)?mt(e):r.name||r.placeholder||e.getAttribute("aria-label")||e.tagName;this.add({type:"ui",category:"ui.input",timestamp:Date.now(),message:n,data:{field:n}})}catch{}}recordError(t){const e=ye(t);this.add({type:"console",category:"console.error",timestamp:Date.now(),message:e,data:{message:e}})}handleNavigation(){if(!this.active)return;const t=this.lastUrl,e=location.href;if(t===e)return;this.lastUrl=e;const r=B(t),n=B(e);this.add({type:"navigation",category:"navigation",timestamp:Date.now(),message:`${r} → ${n}`,data:{from:r,to:n}})}}const ve="mtb_frustration_state";let lt=null;function K(){try{const i=window.sessionStorage.getItem(ve);return q(i?JSON.parse(i):lt)}catch{return q(lt)}}function xe(i){const t=q(i);lt=t;try{window.sessionStorage.setItem(ve,JSON.stringify(t))}catch{}}function fn(){return K().dismissedByUser}function gn(){xe({...K(),dismissedByUser:!0})}function q(i){const t=i??{};return{navTimestamps:Array.isArray(t.navTimestamps)?t.navTimestamps.filter(e=>typeof e=="number"):[],cooldownUntil:typeof t.cooldownUntil=="number"?t.cooldownUntil:0,errorPageUrls:Array.isArray(t.errorPageUrls)?t.errorPageUrls.filter(e=>typeof e=="string").slice(-20):[],dismissedByUser:t.dismissedByUser===!0}}const yn=3,wn=1e3,vn=3,xn=5e3,zt=500,kn=500,Sn=300,En=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","LABEL","SUMMARY","DETAILS"]),Cn=new Set(["button","link","checkbox","radio","tab","menuitem","option","switch","textbox","combobox","listbox","slider","spinbutton"]),Ot=[/\bnot found\b/,/\bserver error\b/,/^\s*(?:http\s*)?[45]\d{2}\s*$/,/\b(?:error|http|status)\s*[:-]?\s*[45]\d{2}\b/,/\b[45]\d{2}\s*[:-]?\s*error\b/],F=class F{constructor(t){this.clickHistory=[],this.unsubscribeErrors=null,this.active=!1,this.errorCount=0,this.deadClickCount=0,this.cooldownUntil=0,this.navTimestamps=[],this.unsubscribeNavigation=null,this.boundPageLeaveHandler=null,this.lastNavigationAt=-1,this.boundSubmitHandler=null,this.boundInvalidHandler=null,this.recentSubmitForms=new WeakSet,this.errorPageUrls=new Set,this.domObserver=null,this.pendingDomChecks=0,this.lastMutationAt=-1,this.onFrustration=t,this.boundClickHandler=e=>this.handleClick(e)}start(){this.active||(this.active=!0,this.restoreState(),document.addEventListener("click",this.boundClickHandler,!0),this.unsubscribeErrors=gt.subscribe(t=>{this.errorCount++}),this.startNavigationTracking(),this.startFormTracking(),this.checkErrorPage())}stop(){this.active&&(this.active=!1,document.removeEventListener("click",this.boundClickHandler,!0),this.unsubscribeErrors?.(),this.unsubscribeErrors=null,this.clickHistory=[],this.stopNavigationTracking(),this.stopFormTracking(),this.errorPageUrls.clear(),this.disconnectDomObserver())}startNavigationTracking(){this.unsubscribeNavigation=we(()=>this.handleNavigation()),this.boundPageLeaveHandler=()=>this.noteNavigationStarted(),window.addEventListener("beforeunload",this.boundPageLeaveHandler),window.addEventListener("pagehide",this.boundPageLeaveHandler)}stopNavigationTracking(){this.unsubscribeNavigation?.(),this.unsubscribeNavigation=null,this.navTimestamps=[],this.boundPageLeaveHandler&&(window.removeEventListener("beforeunload",this.boundPageLeaveHandler),window.removeEventListener("pagehide",this.boundPageLeaveHandler),this.boundPageLeaveHandler=null),this.lastNavigationAt=-1}noteNavigationStarted(){this.lastNavigationAt=Date.now()}restoreState(){const t=K();this.navTimestamps=t.navTimestamps,this.cooldownUntil=t.cooldownUntil,this.errorPageUrls=new Set(t.errorPageUrls)}persistState(){const t=K();xe({...t,navTimestamps:this.navTimestamps,cooldownUntil:this.cooldownUntil,errorPageUrls:[...this.errorPageUrls]})}startFormTracking(){this.boundSubmitHandler=t=>this.handleFormSubmit(t),this.boundInvalidHandler=t=>this.handleFormInvalid(t),document.addEventListener("submit",this.boundSubmitHandler,!0),document.addEventListener("invalid",this.boundInvalidHandler,!0)}stopFormTracking(){this.boundSubmitHandler&&(document.removeEventListener("submit",this.boundSubmitHandler,!0),this.boundSubmitHandler=null),this.boundInvalidHandler&&(document.removeEventListener("invalid",this.boundInvalidHandler,!0),this.boundInvalidHandler=null)}handleClick(t){const e=t.target;if(!e||C(e))return;this.trackFormSubmitIntent(e);const r=Date.now();this.clickHistory.push({target:e,time:r});const n=r-wn;if(this.clickHistory=this.clickHistory.filter(o=>o.time>n),this.clickHistory.filter(o=>o.target===e).length>=yn){this.clickHistory=[],this.emitHighPriority({signal:"rage_click",target:P(e),timestamp:r});return}this.isInteractive(e)||(this.deadClickCount++,this.deadClickCount>=3&&this.errorCount>0&&(this.deadClickCount=0,this.errorCount=0,this.emitIfReady({signal:"dead_click",target:P(e),timestamp:r}))),this.checkDeadClickDom(e,r)}handleNavigation(){const t=Date.now();this.noteNavigationStarted(),this.navTimestamps.push(t);const e=t-xn;this.navTimestamps=this.navTimestamps.filter(r=>r>e),this.navTimestamps.length>=vn&&(this.navTimestamps=[],this.emitIfReady({signal:"rapid_navigation",timestamp:t})),this.persistState(),setTimeout(()=>{this.active&&this.checkErrorPage()},Sn)}handleFormSubmit(t){const e=t.target;e instanceof HTMLFormElement&&(C(e)||(this.rememberSubmitAttempt(e),setTimeout(()=>{this.active&&e.querySelector('[aria-invalid="true"], .is-invalid')&&this.emitIfReady({signal:"form_failure",target:P(e),timestamp:Date.now()})},zt)))}trackFormSubmitIntent(t){const e=t.closest("button, input");(e instanceof HTMLButtonElement||e instanceof HTMLInputElement)&&(e.type!=="submit"&&e.type!=="image"||!e.form||C(e.form)||this.rememberSubmitAttempt(e.form))}rememberSubmitAttempt(t){this.recentSubmitForms.add(t),setTimeout(()=>{this.recentSubmitForms.delete(t)},zt)}handleFormInvalid(t){const e=t.target;if(!e||C(e))return;const r=e.closest("form");!r||!this.recentSubmitForms.has(r)||this.emitIfReady({signal:"form_failure",target:P(r),timestamp:Date.now()})}checkErrorPage(){const t=location.href;if(this.errorPageUrls.has(t))return;const e=document.title.toLowerCase();if(Ot.some(n=>n.test(e))){this.errorPageUrls.add(t),this.emitHighPriority({signal:"error_page",detail:document.title,timestamp:Date.now()});return}const r=document.querySelectorAll('h1, h2, [class*="error"], [class*="not-found"], [id*="error"], [id*="not-found"]');for(const n of r){const s=n.textContent??"";if(s.length<200&&Ot.some(o=>o.test(s.toLowerCase()))){this.errorPageUrls.add(t),this.emitHighPriority({signal:"error_page",detail:s.trim().slice(0,60),timestamp:Date.now()});return}}}checkDeadClickDom(t,e){this.looksInteractive(t)&&(this.pendingDomChecks++,this.ensureDomObserver(),setTimeout(()=>{this.pendingDomChecks--;const r=this.lastMutationAt>=e,n=this.lastNavigationAt>=e;this.pendingDomChecks===0&&this.disconnectDomObserver(),!r&&!n&&this.active&&this.emitIfReady({signal:"dead_click_dom",target:P(t),timestamp:e})},kn))}ensureDomObserver(){this.domObserver||(this.domObserver=new MutationObserver(()=>{this.lastMutationAt=Date.now()}),this.domObserver.observe(document.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0}))}disconnectDomObserver(){this.domObserver?.disconnect(),this.domObserver=null}looksInteractive(t){if(window.getComputedStyle(t).cursor==="pointer")return!0;if(t.classList)for(const r of t.classList){const n=r.toLowerCase();if(n.includes("btn")||n.includes("button"))return!0}return!1}isInteractive(t){if(En.has(t.tagName))return!0;const e=t.getAttribute("role");return!!(e&&Cn.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'))}emitIfReady(t){const e=Date.now();e<this.cooldownUntil||(this.cooldownUntil=e+F.COOLDOWN_MS,this.persistState(),this.onFrustration(t))}emitHighPriority(t){this.cooldownUntil=Date.now()+F.COOLDOWN_MS,this.persistState(),this.onFrustration(t)}};F.COOLDOWN_MS=6e4;let ct=F;function P(i){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("."):"",n=i.textContent?.trim().slice(0,30)??"";return`<${t}${e}${r}>${n?` "${n}"`:""}`}function _n(){return{page_url:B(window.location.href),user_agent:navigator.userAgent,browser:Tn(),os:An(),screen_width:window.screen.width,screen_height:window.screen.height}}function Tn(){const i=navigator.userAgent;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"}function An(){const i=navigator.userAgent;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"}function Ln(i,t,e,r,n,s,o,a,l){return{...j({description:i,...t,page_url:B(t.page_url),console_errors:e,annotations:r?[r]:[],target_element:r?.targetSelector?{selector:r.targetSelector,text:r.targetText??"",name:r.targetName??""}:void 0,recording_events:s?.events,recording_duration:s?.duration,breadcrumbs:l}),user_id:n?.id,user_email:n?.email,user_name:n?.name,reporter_external_id:n?void 0:o,reporter_email:n?void 0:a}}const Nt="mtb_anon_id",ke="mtb_reporter_email",Se="mtb_board_url";let qt=null,Ee=null,Ce=null;function jt(){try{const i=window.localStorage.getItem(Nt);if(i?.startsWith("anon_"))return i;const t=Yt();return window.localStorage.setItem(Nt,t),t}catch{return qt??(qt=Yt()),qt}}function Wt(){try{return window.localStorage.getItem(ke)??void 0}catch{return Ee??void 0}}function Pn(i){Ee=i;try{window.localStorage.setItem(ke,i)}catch{}}function Mn(){try{return window.localStorage.getItem(Se)??void 0}catch{return Ce??void 0}}function Vt(i){Ce=i;try{window.localStorage.setItem(Se,i)}catch{}}function Yt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`anon_${crypto.randomUUID()}`:`anon_${`${Date.now().toString(16)}-${Math.random().toString(16).slice(2,10)}`}`}const Rn={tab:"Feedback",toolbar:{markup:"Mark up",record:"Record",hint:"Click to comment, drag to draw",hintTouch:"Drag to mark what's wrong",hintRecord:"Recording your screen",exit:"Exit"},popup:{about:"About",placeholder:"Describe the issue or suggestion...",submit:"Submit",cancel:"Cancel",my_feedback:"My feedback",quickOptions:[{emoji:"🐛",label:"Something's broken"},{emoji:"💡",label:"I have a suggestion"},{emoji:"🤔",label:"I'm confused"}]},success:{title:"Sent — thanks!",message:"Your note and captured technical context are on their way to the team. You’ll hear back when it’s resolved.",title_no_ai:"Thanks! We've received your feedback.",message_no_ai:"The team will take it from here. You'll hear back when it's resolved.",view_feedback:"View my feedback",close:"Close",email_prompt:"Want updates? Leave your email and we'll let you know when it's resolved.",email_placeholder:"you@example.com",email_submit:"Notify me",email_saved:"You'll get an email when it's resolved.",email_error:"Couldn't save your email. Please try again."},error:{submit:"Failed to submit. Please try again."},pet:{bubble:"Need help?"},frustration:{prompt:"Something not working? Tell us.",action:"Annotate",dismiss:"Dismiss"},annotation:{drawing:"Drawing",element:"element"},draw:{note_placeholder:"Add a note to your drawing",undo:"Undo",redo:"Redo",cancel:"Cancel",submit:"Submit"},record:{stop:"Stop",timer_label:"Recording",max_reached:"Maximum recording time reached",replay_label:"screen-recording.json",play:"Play recording",close:"Close",preview_unavailable:"Preview unavailable"},clarify:{title:"Make This Better AI",subtitle:"Sharpening your feedback",thinking:"Thinking...",placeholder:"Type your answer — or skip the question",send:"Send",send_feedback:"Send feedback",skip:"Skip & send",retry:"Retry",error:"AI clarification failed. Please try again.",expired:"This feedback session expired before it could be sent. Please close the widget and submit again."}},In={tab:"反馈",toolbar:{markup:"标注",record:"录屏",hint:"点击标注,拖动绘制",hintTouch:"用手指圈出问题",hintRecord:"正在录制屏幕",exit:"退出"},popup:{about:"关于",placeholder:"描述问题或建议...",submit:"提交",cancel:"取消",my_feedback:"我的反馈",quickOptions:[{emoji:"🐛",label:"出问题了"},{emoji:"💡",label:"我有一个建议"},{emoji:"🤔",label:"我有点困惑"}]},success:{title:"已发送,感谢!",message:"您的反馈和采集到的技术上下文正在发送给团队。问题解决后,您会收到通知。",title_no_ai:"感谢!我们已收到您的反馈。",message_no_ai:"接下来由团队处理。问题解决后,您会收到通知。",view_feedback:"查看我的反馈",close:"关闭",email_prompt:"想了解进展?留下邮箱,问题解决后我们会通知您。",email_placeholder:"you@example.com",email_submit:"通知我",email_saved:"问题解决后您会收到邮件通知。",email_error:"邮箱保存失败,请重试。"},error:{submit:"提交失败,请重试。"},pet:{bubble:"需要帮助吗?"},frustration:{prompt:"遇到问题了?告诉我们。",action:"标注",dismiss:"关闭"},annotation:{drawing:"绘制",element:"元素"},draw:{note_placeholder:"给你的绘制添加说明",undo:"撤销",redo:"重做",cancel:"取消",submit:"提交"},record:{stop:"停止",timer_label:"录制中",max_reached:"已达到最长录制时间",replay_label:"screen-recording.json",play:"播放录屏",close:"关闭",preview_unavailable:"暂无法预览"},clarify:{title:"Make This Better AI",subtitle:"正在完善你的反馈",thinking:"思考中...",placeholder:"输入回答,或跳过问题",send:"发送",send_feedback:"发送反馈",skip:"跳过并发送",retry:"重试",error:"AI 澄清失败,请重试。",expired:"这条反馈在发送前已过期。请关闭组件后重新提交。"}},Dn={tab:"フィードバック",toolbar:{markup:"マークアップ",record:"録画",hint:"クリックでコメント、ドラッグで描画",hintTouch:"ドラッグして問題箇所を囲んでください",hintRecord:"画面を録画中",exit:"終了"},popup:{about:"概要",placeholder:"問題や提案を入力してください...",submit:"送信",cancel:"キャンセル",my_feedback:"自分のフィードバック",quickOptions:[{emoji:"🐛",label:"不具合があります"},{emoji:"💡",label:"提案があります"},{emoji:"🤔",label:"わかりにくいです"}]},success:{title:"送信しました。ありがとうございます!",message:"ご意見と取得した技術情報をチームに送信しました。解決次第お知らせします。",title_no_ai:"ありがとうございます!フィードバックを受け付けました。",message_no_ai:"チームが対応します。解決次第お知らせします。",view_feedback:"フィードバックを確認",close:"閉じる",email_prompt:"進捗を知りたい場合は、メールアドレスをご記入ください。解決次第お知らせします。",email_placeholder:"you@example.com",email_submit:"通知を受け取る",email_saved:"解決次第メールでお知らせします。",email_error:"メールアドレスを保存できませんでした。もう一度お試しください。"},error:{submit:"送信に失敗しました。もう一度お試しください。"},pet:{bubble:"お困りですか?"},frustration:{prompt:"うまくいかないことがありますか?お知らせください。",action:"注釈",dismiss:"閉じる"},annotation:{drawing:"描画",element:"要素"},draw:{note_placeholder:"描画にメモを追加",undo:"元に戻す",redo:"やり直す",cancel:"キャンセル",submit:"送信"},record:{stop:"停止",timer_label:"録画中",max_reached:"最大記録時間に達しました",replay_label:"screen-recording.json",play:"録画を再生",close:"閉じる",preview_unavailable:"プレビューは利用できません"},clarify:{title:"Make This Better AI",subtitle:"フィードバックを整えています",thinking:"考え中...",placeholder:"回答を入力、または質問をスキップ",send:"送信",send_feedback:"フィードバックを送信",skip:"スキップして送信",retry:"再試行",error:"AIによる確認に失敗しました。もう一度お試しください。",expired:"このフィードバックは送信される前に有効期限が切れました。ウィジェットを閉じて、もう一度送信してください。"}},Hn={tab:"피드백",toolbar:{markup:"마크업",record:"녹화",hint:"클릭하여 댓글, 드래그하여 그리기",hintTouch:"드래그해서 문제가 있는 곳을 표시하세요",hintRecord:"화면 녹화 중",exit:"나가기"},popup:{about:"정보",placeholder:"문제 또는 제안 사항을 설명해 주세요...",submit:"제출",cancel:"취소",my_feedback:"내 피드백",quickOptions:[{emoji:"🐛",label:"문제가 있어요"},{emoji:"💡",label:"제안이 있어요"},{emoji:"🤔",label:"헷갈려요"}]},success:{title:"전송되었습니다. 감사합니다!",message:"피드백과 수집된 기술 정보가 팀에 전달되었습니다. 해결되면 알려드리겠습니다.",title_no_ai:"감사합니다! 피드백을 접수했습니다.",message_no_ai:"팀에서 처리합니다. 해결되면 알려드리겠습니다.",view_feedback:"내 피드백 보기",close:"닫기",email_prompt:"진행 상황이 궁금하신가요? 이메일을 남겨주시면 해결 시 알려드립니다.",email_placeholder:"you@example.com",email_submit:"알림 받기",email_saved:"해결되면 이메일로 알려드립니다.",email_error:"이메일을 저장하지 못했습니다. 다시 시도해 주세요."},error:{submit:"제출에 실패했습니다. 다시 시도해 주세요."},pet:{bubble:"도움이 필요하신가요?"},frustration:{prompt:"문제가 있으신가요? 알려 주세요.",action:"주석",dismiss:"닫기"},annotation:{drawing:"그리기",element:"요소"},draw:{note_placeholder:"그림에 메모 추가",undo:"실행 취소",redo:"다시 실행",cancel:"취소",submit:"보내기"},record:{stop:"중지",timer_label:"녹화 중",max_reached:"최대 녹화 시간에 도달했습니다",replay_label:"screen-recording.json",play:"녹화 재생",close:"닫기",preview_unavailable:"미리보기를 사용할 수 없습니다"},clarify:{title:"Make This Better AI",subtitle:"피드백을 다듬는 중",thinking:"생각 중...",placeholder:"답변을 입력하거나 질문을 건너뛰세요",send:"보내기",send_feedback:"피드백 보내기",skip:"건너뛰고 보내기",retry:"재시도",error:"AI 확인에 실패했습니다. 다시 시도해 주세요.",expired:"이 피드백 세션은 전송되기 전에 만료되었습니다. 위젯을 닫고 다시 보내 주세요."}},$n={tab:"Comentarios",toolbar:{markup:"Anotar",record:"Grabar",hint:"Clic para comentar, arrastrar para dibujar",hintTouch:"Arrastra para marcar el problema",hintRecord:"Grabando pantalla",exit:"Salir"},popup:{about:"Acerca de",placeholder:"Describe el problema o sugerencia...",submit:"Enviar",cancel:"Cancelar",my_feedback:"Mis comentarios",quickOptions:[{emoji:"🐛",label:"Algo no funciona"},{emoji:"💡",label:"Tengo una sugerencia"},{emoji:"🤔",label:"Estoy confundido"}]},success:{title:"Enviado, ¡gracias!",message:"Tu nota y el contexto técnico capturado se han enviado al equipo. Te avisaremos cuando se resuelva.",title_no_ai:"¡Gracias! Hemos recibido tu comentario.",message_no_ai:"El equipo se encargará a partir de aquí. Te avisaremos cuando se resuelva.",view_feedback:"Ver mis comentarios",close:"Cerrar",email_prompt:"¿Quieres novedades? Deja tu correo y te avisaremos cuando se resuelva.",email_placeholder:"tu@ejemplo.com",email_submit:"Avisarme",email_saved:"Recibirás un correo cuando se resuelva.",email_error:"No se pudo guardar tu correo. Inténtalo de nuevo."},error:{submit:"Error al enviar. Por favor, inténtalo de nuevo."},pet:{bubble:"¿Necesitas ayuda?"},frustration:{prompt:"¿Algo no funciona? Cuéntanos.",action:"Anotar",dismiss:"Cerrar"},annotation:{drawing:"Dibujo",element:"elemento"},draw:{note_placeholder:"Añade una nota a tu dibujo",undo:"Deshacer",redo:"Rehacer",cancel:"Cancelar",submit:"Enviar"},record:{stop:"Detener",timer_label:"Grabando",max_reached:"Tiempo máximo de grabación alcanzado",replay_label:"screen-recording.json",play:"Reproducir grabación",close:"Cerrar",preview_unavailable:"Vista previa no disponible"},clarify:{title:"Make This Better AI",subtitle:"Afinando tus comentarios",thinking:"Pensando...",placeholder:"Escribe tu respuesta — u omite la pregunta",send:"Enviar",send_feedback:"Enviar comentario",skip:"Omitir y enviar",retry:"Reintentar",error:"No se pudo completar la aclaración con IA. Inténtalo de nuevo.",expired:"Esta sesión de comentarios caducó antes de poder enviarse. Cierra el widget y envíalo de nuevo."}},Fn={tab:"Avis",toolbar:{markup:"Annoter",record:"Enregistrer",hint:"Cliquer pour commenter, glisser pour dessiner",hintTouch:"Faites glisser pour marquer le problème",hintRecord:"Enregistrement de l'écran",exit:"Quitter"},popup:{about:"À propos",placeholder:"Décrivez le problème ou votre suggestion...",submit:"Envoyer",cancel:"Annuler",my_feedback:"Mes avis",quickOptions:[{emoji:"🐛",label:"Quelque chose ne fonctionne pas"},{emoji:"💡",label:"J'ai une suggestion"},{emoji:"🤔",label:"Je suis perplexe"}]},success:{title:"Envoyé, merci !",message:"Votre message et le contexte technique collecté ont été transmis à l’équipe. Vous serez informé(e) dès que ce sera résolu.",title_no_ai:"Merci ! Nous avons bien reçu votre avis.",message_no_ai:"L’équipe prend le relais. Vous serez informé(e) dès que ce sera résolu.",view_feedback:"Voir mes avis",close:"Fermer",email_prompt:"Envie de suivre l'avancement ? Laissez votre e-mail et nous vous préviendrons une fois résolu.",email_placeholder:"vous@exemple.com",email_submit:"Me prévenir",email_saved:"Vous recevrez un e-mail une fois résolu.",email_error:"Impossible d'enregistrer votre e-mail. Veuillez réessayer."},error:{submit:"Échec de l'envoi. Veuillez réessayer."},pet:{bubble:"Besoin d'aide ?"},frustration:{prompt:"Un problème ? Dites-le-nous.",action:"Annoter",dismiss:"Fermer"},annotation:{drawing:"Dessin",element:"élément"},draw:{note_placeholder:"Ajoutez une note à votre dessin",undo:"Annuler",redo:"Rétablir",cancel:"Annuler",submit:"Envoyer"},record:{stop:"Arrêter",timer_label:"Enregistrement",max_reached:"Durée maximale d'enregistrement atteinte",replay_label:"screen-recording.json",play:"Lire l'enregistrement",close:"Fermer",preview_unavailable:"Aperçu indisponible"},clarify:{title:"Make This Better AI",subtitle:"Affinement de votre retour",thinking:"Réflexion...",placeholder:"Saisissez votre réponse — ou ignorez la question",send:"Envoyer",send_feedback:"Envoyer le retour",skip:"Ignorer et envoyer",retry:"Réessayer",error:"La clarification par IA a échoué. Réessayez.",expired:"Cette session de retour a expiré avant d'avoir pu être envoyée. Fermez le widget et renvoyez-la."}},Bn={tab:"Feedback",toolbar:{markup:"Markieren",record:"Aufnehmen",hint:"Klicken zum Kommentieren, ziehen zum Zeichnen",hintTouch:"Ziehen, um das Problem zu markieren",hintRecord:"Bildschirm wird aufgenommen",exit:"Beenden"},popup:{about:"Info",placeholder:"Beschreiben Sie das Problem oder Ihren Vorschlag...",submit:"Absenden",cancel:"Abbrechen",my_feedback:"Mein Feedback",quickOptions:[{emoji:"🐛",label:"Etwas funktioniert nicht"},{emoji:"💡",label:"Ich habe einen Vorschlag"},{emoji:"🤔",label:"Ich bin verwirrt"}]},success:{title:"Gesendet, vielen Dank!",message:"Ihre Nachricht und der erfasste technische Kontext wurden an das Team gesendet. Sie werden benachrichtigt, sobald das Problem gelöst ist.",title_no_ai:"Vielen Dank! Wir haben Ihr Feedback erhalten.",message_no_ai:"Das Team übernimmt ab hier. Sie werden benachrichtigt, sobald das Problem gelöst ist.",view_feedback:"Mein Feedback ansehen",close:"Schließen",email_prompt:"Updates gewünscht? Hinterlassen Sie Ihre E-Mail und wir melden uns, sobald es gelöst ist.",email_placeholder:"sie@beispiel.de",email_submit:"Benachrichtigen",email_saved:"Sie erhalten eine E-Mail, sobald es gelöst ist.",email_error:"E-Mail konnte nicht gespeichert werden. Bitte versuchen Sie es erneut."},error:{submit:"Senden fehlgeschlagen. Bitte versuchen Sie es erneut."},pet:{bubble:"Brauchen Sie Hilfe?"},frustration:{prompt:"Etwas funktioniert nicht? Sagen Sie es uns.",action:"Kommentieren",dismiss:"Schließen"},annotation:{drawing:"Zeichnung",element:"Element"},draw:{note_placeholder:"Fügen Sie Ihrer Zeichnung eine Notiz hinzu",undo:"Rückgängig",redo:"Wiederholen",cancel:"Abbrechen",submit:"Absenden"},record:{stop:"Stopp",timer_label:"Aufnahme",max_reached:"Maximale Aufnahmedauer erreicht",replay_label:"screen-recording.json",play:"Aufnahme abspielen",close:"Schließen",preview_unavailable:"Vorschau nicht verfügbar"},clarify:{title:"Make This Better AI",subtitle:"Wir schärfen dein Feedback",thinking:"Einen Moment...",placeholder:"Antwort eingeben — oder Frage überspringen",send:"Senden",send_feedback:"Feedback senden",skip:"Überspringen & senden",retry:"Erneut versuchen",error:"Die KI-Klärung ist fehlgeschlagen. Bitte erneut versuchen.",expired:"Diese Feedback-Sitzung ist abgelaufen, bevor sie gesendet werden konnte. Bitte schließe das Widget und sende erneut."}},M={en:Rn,"zh-CN":In,ja:Dn,ko:Hn,es:$n,fr:Fn,de:Bn};function Xt(i){if(M[i])return M[i];const t=i.split("-")[0];return M[t]?M[t]:M.en}class Un{constructor(t,e,r,n){this.intervalId=null,this.getDuration=r,this.el=t.el("div","mtb-record-bar"),this.el.innerHTML=`
142
142
  <span class="mtb-record-dot"></span>
143
143
  <span class="mtb-record-timer">00:00</span>
144
- <button class="mtb-record-stop" type="button">${e.record.stop}</button>
145
- `,t.append(this.el),this.timerEl=this.el.querySelector(".mtb-record-timer"),this.el.querySelector(".mtb-record-stop").addEventListener("click",n),this.intervalId=setInterval(()=>this.updateTimer(),1e3)}updateTimer(){const t=this.getDuration(),e=String(Math.floor(t/60)).padStart(2,"0"),r=String(t%60).padStart(2,"0");this.timerEl.textContent=`${e}:${r}`}destroy(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.el.remove()}}class zn{constructor(){this.session=null,this.bar=null,this.result=null}async start(t,e,r){this.session=new wi(t,r),this.bar=new Un(t,e,()=>this.session?.getDuration()??0,r),await this.session.start()}stop(){return this.session?(this.result=this.session.stop(),this.teardownUI(),this.result):null}getRecording(){return this.result}destroy(){this.teardownUI(),this.result=null}teardownUI(){this.session?.destroy(),this.session=null,this.bar?.destroy(),this.bar=null}}function Kt(){const{hostname:i}=window.location;return i==="localhost"||i==="127.0.0.1"||i==="[::1]"||i.endsWith(".localhost")||i.endsWith(".local")||i.endsWith(".test")}class dt{constructor(t){this.tab=null,this.toolbar=null,this.session=null,this.drawBar=null,this.dim=null,this.pageOffset=new Ne,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.pendingSubmissionRequest=null,this.submissionAttempt=0,this.touchHintShown=!1,this.lastHandoff={},this.handleKeydown=e=>{if(e.key==="Escape"&&!(e.isComposing||e.keyCode===229))switch(this.mode){case"annotating":case"popup":e.preventDefault(),e.stopPropagation(),this.exitAll();break;case"drawing":e.preventDefault(),e.stopPropagation(),this.cancelDraw();break;case"recording":e.preventDefault(),e.stopPropagation(),this.handleRecordStop();break}},this.handleRecordStop=()=>{this.recordingManager&&(this.recordingManager.stop(),this.via="record",this.showPopup(window.innerWidth/2,window.innerHeight/2,this.messages.record.timer_label))},this.config=t,this.messages=Xt(t.locale??document.documentElement.lang??"en"),this.apiClient=new Ii(t.projectKey,t.apiUrl,void 0,t.userToken,t.userTokenFn),this.consoleCollector=new cn,this.consoleCollector.start(),this.breadcrumbCollector=new pn,this.breadcrumbCollector.start(),this.buildUI(),t.frustrationDetection!==!1&&(this.frustrationDetector=new ct(()=>this.handleFrustration()),this.frustrationDetector.start()),document.addEventListener("keydown",this.handleKeydown,!0)}buildUI(){if(this.shadow=new $e(this.config.theme??"auto"),this.config.entryMode==="api"){Kt()&&console.warn('[MakeThisBetter] entryMode: "api" renders no launcher. Call MakeThisBetter.open() from your own UI.');return}if(x()){Kt()&&console.warn("[MakeThisBetter] No launcher is rendered on touch devices. Call MakeThisBetter.open() from your own mobile UI.");return}this.mountTab()}mountTab(){this.tab||(this.tab=new Fe(this.shadow,this.messages,this.config.position??"right",()=>this.handleTabClick(),this.config.tabText))}open(){this.mode==="idle"&&(this.dismissFrustrationPrompt(),this.enterAnnotationMode())}close(){this.mode!=="idle"&&this.exitAll()}showLauncher(){x()||(this.mountTab(),this.tab?.setActive(this.mode!=="idle"))}hideLauncher(){this.tab?.destroy(),this.tab=null}setLocale(t){this.config.locale=t,this.messages=Xt(t),this.tab?.setMessages(this.messages)}handleTabClick(){this.mode==="idle"?(this.dismissFrustrationPrompt(),this.enterAnnotationMode()):this.exitAll()}handleFrustration(){this.mode!=="idle"||this.frustrationPrompt||fn()||(this.frustrationPrompt=new Ue(this.shadow,this.messages,{onTell:()=>{this.dismissFrustrationPrompt(),this.enterAnnotationMode()},onDismiss:()=>{gn(),this.dismissFrustrationPrompt()},onAutoHide:()=>this.dismissFrustrationPrompt()}))}dismissFrustrationPrompt(){this.frustrationPrompt?.destroy(),this.frustrationPrompt=null}enterAnnotationMode(){this.mode="annotating",this.tab?.setActive(!0);const t=x();this.toolbar=new je(this.shadow,this.messages,()=>this.exitAll(),e=>this.handleToolbarModeChange(e),this.config.position??"right",!t||!this.touchHintShown),t&&(this.touchHintShown=!0),this.session=this.createSession(),t&&this.toolbar&&this.pageOffset.reserve(this.toolbar.height())}createSession(){return new ki(this.shadow,this.messages,{onPin:(t,e)=>{this.currentAnnotation=t,this.via="pin",this.showPopup(t.x,t.y,e,t.targetRect)},onDrawStroke:()=>this.handleDrawStroke()})}handleToolbarModeChange(t){if(this.mode==="clarifying"){this.toolbar?.setMode(this.via==="record"?"record":"markup");return}if(t==="record"){if(this.mode==="recording")return;this.mode="recording",this.currentAnnotation=null,this.teardownDraw(),this.session?.destroy(),this.session=null,this.recordingManager=new zn,this.recordingManager.start(this.shadow,this.messages,this.handleRecordStop).catch(e=>{console.warn("[MakeThisBetter] Interaction replay unavailable, falling back to markup:",e),this.mode==="recording"&&(this.toolbar?.setMode("markup"),this.handleToolbarModeChange("markup"))})}else this.recordingManager?.destroy(),this.recordingManager=null,this.teardownDraw(),this.session||(this.session=this.createSession()),this.mode="annotating"}handleDrawStroke(){if(x()){this.showDrawSheet();return}this.mode!=="drawing"&&(this.mode="drawing",this.drawBar=new Ai(this.shadow,{messages:this.messages,onUndo:()=>this.handleDrawUndoRedo("undo"),onRedo:()=>this.handleDrawUndoRedo("redo"),onCancel:()=>this.cancelDraw(),onSubmit:t=>this.handleDrawSubmit(t)})),this.refreshDrawBar()}showDrawSheet(){this.mode!=="drawing"&&(this.mode="drawing",this.popup=new Et(this.shadow,{targetName:this.messages.annotation.drawing,x:window.innerWidth/2,y:window.innerHeight/2,messages:this.messages,onSubmit:t=>this.handleDrawSubmit(t),onClose:()=>this.cancelDraw(),position:this.config.position??"right"}),this.submittingUi=this.popup)}handleDrawUndoRedo(t){t==="undo"?this.session?.undoDraw():this.session?.redoDraw(),this.refreshDrawBar()}refreshDrawBar(){this.session&&this.drawBar?.setUndoRedo(this.session.canUndoDraw(),this.session.canRedoDraw())}cancelDraw(){this.session?.clearDraw(),this.teardownDraw(),this.popup?.destroy(),this.popup=null,this.dim?.destroy(),this.dim=null,this.submittingUi=null,this.mode="annotating"}teardownDraw(){this.drawBar?.destroy(),this.drawBar=null}handleDrawSubmit(t){const e=this.session?.getDrawAnnotation();if(!e){this.cancelDraw();return}this.currentAnnotation=e,this.via="draw",this.session?.dismissInteraction(),this.submittingUi=this.drawBar??this.popup,this.handleSubmit(t||this.messages.annotation.drawing)}showPopup(t,e,r,n){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 Oe(this.shadow,()=>this.exitAll()),this.popup=new Et(this.shadow,{targetName:r,x:t,y:e,targetRect:n,messages:this.messages,onSubmit:s=>this.handleSubmit(s),onClose:()=>this.exitAll(),onMyFeedback:this.buildMyFeedbackHandler(),position:this.config.position??"right"}),this.submittingUi=this.popup}buildMyFeedbackHandler(){if(!this.config.user&&Mn())return async()=>{const t=await this.apiClient.createIdentityToken(jt());!t?.identity_token||!t.board_url||(Vt(t.board_url),window.open(`${t.board_url}?identity=${encodeURIComponent(t.identity_token)}`,"_blank"))}}handleSubmit(t){if(!this.submittingUi)return;const e=this.currentAnnotation,r=this.recordingManager?.getRecording()??void 0,n=this.teardownSubmittingUi(!0),s=()=>this.startSubmissionRequest(t,e,r);this.showClarify(this.lastPopupPos,{element:n,pendingSession:s(),onRetrySubmission:s})}startSubmissionRequest(t,e,r){const n=++this.submissionAttempt,s=this.createSubmission(t,e,r,n);return this.pendingSubmissionRequest=s,s}async createSubmission(t,e,r,n){await On();const[s,o]=await Promise.all([zr(e?[e]:[]),Promise.resolve(_n())]),a=Ln(t,o,this.consoleCollector.getErrors(),e,this.config.user,r,this.config.user?void 0:jt(),this.config.user?void 0:Wt(),this.breadcrumbCollector.getBreadcrumbs());try{const l=await this.apiClient.createSubmissionSession(a,s);return n!==this.submissionAttempt?(await this.apiClient.abandonSubmissionSession(l.id,l.token).catch(()=>{}),null):(this.activeSubmission=l,l)}catch{return null}}teardownSubmittingUi(t=!1){const e=t?this.popup?.releaseElement():void 0;return this.teardownDraw(),e||this.popup?.destroy(),this.popup=null,this.dim?.destroy(),this.dim=null,this.session?.hideHighlight(),this.session?.destroy(),this.session=null,this.recordingManager?.destroy(),this.recordingManager=null,this.submittingUi=null,e}showClarify(t,e){this.mode="clarifying",this.tab?.setActive(!0),this.clarify=new Oi(this.shadow,{apiClient:this.apiClient,messages:this.messages,element:e.element,position:this.config.position??"right",x:t?.x,y:t?.y,onFinalize:()=>this.finalizeSubmission(),onCancel:()=>this.exitAll(),pendingSession:e.pendingSession,onRetrySubmission:e.onRetrySubmission})}async finalizeSubmission(){const t=this.submissionAttempt,e=this.activeSubmission??await(this.pendingSubmissionRequest??Promise.resolve(null));if(t!==this.submissionAttempt)return;if(!e)throw new Error("No active submission session");const r=await this.apiClient.finalizeSubmissionSession(e.id,e.token);t!==this.submissionAttempt||this.activeSubmission!==e||(this.activeSubmission=null,this.pendingSubmissionRequest=null,this.lastHandoff={feedbackId:r.id,boardUrl:r.board_url,identityToken:r.identity_token},r.board_url&&Vt(r.board_url),this.clarify?.destroy(),this.clarify=null,this.teardownToolbar(),this.showSuccess({skipFollowup:e.ai_clarify_available===!1}))}showSuccess(t){this.mode="idle",this.tab?.setActive(!1),this.success=new ji(this.shadow,this.messages,()=>{this.success?.destroy(),this.success=null},this.buildViewFeedbackHandler(),{...t,emailCapture:this.buildEmailCapture()})}buildEmailCapture(){if(this.config.user)return;const{feedbackId:t,identityToken:e}=this.lastHandoff;if(!(!t||!e)&&!Wt())return{onSubmit:async r=>{const n=await this.apiClient.updateReporter(t,r,e);return n&&Pn(r),n}}}buildViewFeedbackHandler(){const{boardUrl:t,identityToken:e}=this.lastHandoff;if(t){if(e)return()=>{window.open(`${t}?identity=${encodeURIComponent(e)}`,"_blank")};if(this.config.userToken||this.config.userTokenFn)return async()=>{const r=await this.apiClient.resolveUserToken();r&&window.open(`${t}?identity=${encodeURIComponent(r)}`,"_blank")}}}teardownToolbar(){this.pageOffset.release(),this.toolbar?.destroy(),this.toolbar=null}exitAll(){this.submissionAttempt+=1;const t=this.activeSubmission;this.activeSubmission=null,this.pendingSubmissionRequest=null,t&&this.apiClient.abandonSubmissionSession(t.id,t.token).catch(()=>{}),this.mode="idle",this.via="pin",this.tab?.setActive(!1),this.teardownToolbar(),this.teardownDraw(),this.session?.hideHighlight(),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}destroy(){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()}}function On(){return new Promise(i=>requestAnimationFrame(()=>setTimeout(i,0)))}let b=null,_=null,T=null;function Gt(){T&&(document.removeEventListener("DOMContentLoaded",T),T=null)}const _e={init(i){Gt(),b&&(b.destroy(),b=null),_=i,document.readyState==="loading"?(T=()=>{T=null,b=new dt(i)},document.addEventListener("DOMContentLoaded",T,{once:!0})):b=new dt(i)},destroy(){Gt(),b?.destroy(),b=null,_=null},setLocale(i){_&&(_.locale=i),b?.setLocale(i)},open(){b?.open()},close(){b?.close()},showLauncher(){b?.showLauncher()},hideLauncher(){b?.hideLauncher()}};typeof window<"u"&&(window.MakeThisBetter=_e,document.addEventListener("turbo:load",()=>{const i=document.getElementById("mtb-widget-host");_&&(!i||!i.shadowRoot)&&(b?.destroy(),i?.remove(),b=new dt(_))}));exports.MakeThisBetter=_e;
144
+ <button class="mtb-record-stop" type="button">${c(e.record.stop)}</button>
145
+ `,t.append(this.el),this.timerEl=this.el.querySelector(".mtb-record-timer"),this.el.querySelector(".mtb-record-stop").addEventListener("click",n),this.intervalId=setInterval(()=>this.updateTimer(),1e3)}updateTimer(){const t=this.getDuration(),e=String(Math.floor(t/60)).padStart(2,"0"),r=String(t%60).padStart(2,"0");this.timerEl.textContent=`${e}:${r}`}destroy(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.el.remove()}}class zn{constructor(){this.session=null,this.bar=null,this.result=null}async start(t,e,r){this.session=new vi(t,r),this.bar=new Un(t,e,()=>this.session?.getDuration()??0,r),await this.session.start()}stop(){return this.session?(this.result=this.session.stop(),this.teardownUI(),this.result):null}getRecording(){return this.result}destroy(){this.teardownUI(),this.result=null}teardownUI(){this.session?.destroy(),this.session=null,this.bar?.destroy(),this.bar=null}}function Kt(){const{hostname:i}=window.location;return i==="localhost"||i==="127.0.0.1"||i==="[::1]"||i.endsWith(".localhost")||i.endsWith(".local")||i.endsWith(".test")}class dt{constructor(t){this.tab=null,this.toolbar=null,this.session=null,this.drawBar=null,this.dim=null,this.pageOffset=new qe,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.pendingSubmissionRequest=null,this.submissionAttempt=0,this.touchHintShown=!1,this.lastHandoff={},this.handleKeydown=e=>{if(e.key==="Escape"&&!(e.isComposing||e.keyCode===229))switch(this.mode){case"annotating":case"popup":e.preventDefault(),e.stopPropagation(),this.exitAll();break;case"drawing":e.preventDefault(),e.stopPropagation(),this.cancelDraw();break;case"recording":e.preventDefault(),e.stopPropagation(),this.handleRecordStop();break}},this.handleRecordStop=()=>{this.recordingManager&&(this.recordingManager.stop(),this.via="record",this.showPopup(window.innerWidth/2,window.innerHeight/2,this.messages.record.timer_label))},this.config=t,this.messages=Xt(t.locale??document.documentElement.lang??"en"),this.apiClient=new Ii(t.projectKey,t.apiUrl,void 0,t.userToken,t.userTokenFn),this.consoleCollector=new cn,this.consoleCollector.start(),this.breadcrumbCollector=new pn,this.breadcrumbCollector.start(),this.buildUI(),t.frustrationDetection!==!1&&(this.frustrationDetector=new ct(()=>this.handleFrustration()),this.frustrationDetector.start()),document.addEventListener("keydown",this.handleKeydown,!0)}buildUI(){if(this.shadow=new $e(this.config.theme??"auto"),this.config.entryMode==="api"){Kt()&&console.warn('[MakeThisBetter] entryMode: "api" renders no launcher. Call MakeThisBetter.open() from your own UI.');return}if(x()){Kt()&&console.warn("[MakeThisBetter] No launcher is rendered on touch devices. Call MakeThisBetter.open() from your own mobile UI.");return}this.mountTab()}mountTab(){this.tab||(this.tab=new Fe(this.shadow,this.messages,this.config.position??"right",()=>this.handleTabClick(),this.config.tabText))}open(){this.mode==="idle"&&(this.dismissFrustrationPrompt(),this.enterAnnotationMode())}close(){this.mode!=="idle"&&this.exitAll()}showLauncher(){x()||(this.mountTab(),this.tab?.setActive(this.mode!=="idle"))}hideLauncher(){this.tab?.destroy(),this.tab=null}setLocale(t){this.config.locale=t,this.messages=Xt(t),this.tab?.setMessages(this.messages)}handleTabClick(){this.mode==="idle"?(this.dismissFrustrationPrompt(),this.enterAnnotationMode()):this.exitAll()}handleFrustration(){this.mode!=="idle"||this.frustrationPrompt||fn()||(this.frustrationPrompt=new ze(this.shadow,this.messages,{onTell:()=>{this.dismissFrustrationPrompt(),this.enterAnnotationMode()},onDismiss:()=>{gn(),this.dismissFrustrationPrompt()},onAutoHide:()=>this.dismissFrustrationPrompt()}))}dismissFrustrationPrompt(){this.frustrationPrompt?.destroy(),this.frustrationPrompt=null}enterAnnotationMode(){this.mode="annotating",this.tab?.setActive(!0);const t=x();this.toolbar=new We(this.shadow,this.messages,()=>this.exitAll(),e=>this.handleToolbarModeChange(e),this.config.position??"right",!t||!this.touchHintShown),t&&(this.touchHintShown=!0),this.session=this.createSession(),t&&this.toolbar&&this.pageOffset.reserve(this.toolbar.height())}createSession(){return new Si(this.shadow,this.messages,{onPin:(t,e)=>{this.currentAnnotation=t,this.via="pin",this.showPopup(t.x,t.y,e,t.targetRect)},onDrawStroke:()=>this.handleDrawStroke()})}handleToolbarModeChange(t){if(this.mode==="clarifying"){this.toolbar?.setMode(this.via==="record"?"record":"markup");return}if(t==="record"){if(this.mode==="recording")return;this.mode="recording",this.currentAnnotation=null,this.teardownDraw(),this.session?.destroy(),this.session=null,this.recordingManager=new zn,this.recordingManager.start(this.shadow,this.messages,this.handleRecordStop).catch(e=>{console.warn("[MakeThisBetter] Interaction replay unavailable, falling back to markup:",e),this.mode==="recording"&&(this.toolbar?.setMode("markup"),this.handleToolbarModeChange("markup"))})}else this.recordingManager?.destroy(),this.recordingManager=null,this.teardownDraw(),this.session||(this.session=this.createSession()),this.mode="annotating"}handleDrawStroke(){if(x()){this.showDrawSheet();return}this.mode!=="drawing"&&(this.mode="drawing",this.drawBar=new Ai(this.shadow,{messages:this.messages,onUndo:()=>this.handleDrawUndoRedo("undo"),onRedo:()=>this.handleDrawUndoRedo("redo"),onCancel:()=>this.cancelDraw(),onSubmit:t=>this.handleDrawSubmit(t)})),this.refreshDrawBar()}showDrawSheet(){this.mode!=="drawing"&&(this.mode="drawing",this.popup=new Et(this.shadow,{targetName:this.messages.annotation.drawing,x:window.innerWidth/2,y:window.innerHeight/2,messages:this.messages,onSubmit:t=>this.handleDrawSubmit(t),onClose:()=>this.cancelDraw(),position:this.config.position??"right"}),this.submittingUi=this.popup)}handleDrawUndoRedo(t){t==="undo"?this.session?.undoDraw():this.session?.redoDraw(),this.refreshDrawBar()}refreshDrawBar(){this.session&&this.drawBar?.setUndoRedo(this.session.canUndoDraw(),this.session.canRedoDraw())}cancelDraw(){this.session?.clearDraw(),this.teardownDraw(),this.popup?.destroy(),this.popup=null,this.dim?.destroy(),this.dim=null,this.submittingUi=null,this.mode="annotating"}teardownDraw(){this.drawBar?.destroy(),this.drawBar=null}handleDrawSubmit(t){const e=this.session?.getDrawAnnotation();if(!e){this.cancelDraw();return}this.currentAnnotation=e,this.via="draw",this.session?.dismissInteraction(),this.submittingUi=this.drawBar??this.popup,this.handleSubmit(t||this.messages.annotation.drawing)}showPopup(t,e,r,n){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 Ne(this.shadow,()=>this.exitAll()),this.popup=new Et(this.shadow,{targetName:r,x:t,y:e,targetRect:n,messages:this.messages,onSubmit:s=>this.handleSubmit(s),onClose:()=>this.exitAll(),onMyFeedback:this.buildMyFeedbackHandler(),position:this.config.position??"right"}),this.submittingUi=this.popup}buildMyFeedbackHandler(){if(!this.config.user&&Mn())return async()=>{const t=await this.apiClient.createIdentityToken(jt());!t?.identity_token||!t.board_url||(Vt(t.board_url),window.open(`${t.board_url}?identity=${encodeURIComponent(t.identity_token)}`,"_blank"))}}handleSubmit(t){if(!this.submittingUi)return;const e=this.currentAnnotation,r=this.recordingManager?.getRecording()??void 0,n=this.teardownSubmittingUi(!0),s=()=>this.startSubmissionRequest(t,e,r);this.showClarify(this.lastPopupPos,{element:n,pendingSession:s(),onRetrySubmission:s})}startSubmissionRequest(t,e,r){const n=++this.submissionAttempt,s=this.createSubmission(t,e,r,n);return this.pendingSubmissionRequest=s,s}async createSubmission(t,e,r,n){await On();const[s,o]=await Promise.all([zr(e?[e]:[]),Promise.resolve(_n())]),a=Ln(t,o,this.consoleCollector.getErrors(),e,this.config.user,r,this.config.user?void 0:jt(),this.config.user?void 0:Wt(),this.breadcrumbCollector.getBreadcrumbs());try{const l=await this.apiClient.createSubmissionSession(a,s);return n!==this.submissionAttempt?(await this.apiClient.abandonSubmissionSession(l.id,l.token).catch(()=>{}),null):(this.activeSubmission=l,l)}catch{return null}}teardownSubmittingUi(t=!1){const e=t?this.popup?.releaseElement():void 0;return this.teardownDraw(),e||this.popup?.destroy(),this.popup=null,this.dim?.destroy(),this.dim=null,this.session?.hideHighlight(),this.session?.destroy(),this.session=null,this.recordingManager?.destroy(),this.recordingManager=null,this.submittingUi=null,e}showClarify(t,e){this.mode="clarifying",this.tab?.setActive(!0),this.clarify=new Oi(this.shadow,{apiClient:this.apiClient,messages:this.messages,element:e.element,position:this.config.position??"right",x:t?.x,y:t?.y,onFinalize:()=>this.finalizeSubmission(),onCancel:()=>this.exitAll(),pendingSession:e.pendingSession,onRetrySubmission:e.onRetrySubmission})}async finalizeSubmission(){const t=this.submissionAttempt,e=this.activeSubmission??await(this.pendingSubmissionRequest??Promise.resolve(null));if(t!==this.submissionAttempt)return;if(!e)throw new Error("No active submission session");const r=await this.apiClient.finalizeSubmissionSession(e.id,e.token);t!==this.submissionAttempt||this.activeSubmission!==e||(this.activeSubmission=null,this.pendingSubmissionRequest=null,this.lastHandoff={feedbackId:r.id,boardUrl:r.board_url,identityToken:r.identity_token},r.board_url&&Vt(r.board_url),this.clarify?.destroy(),this.clarify=null,this.teardownToolbar(),this.showSuccess({skipFollowup:e.ai_clarify_available===!1}))}showSuccess(t){this.mode="idle",this.tab?.setActive(!1),this.success=new ji(this.shadow,this.messages,()=>{this.success?.destroy(),this.success=null},this.buildViewFeedbackHandler(),{...t,emailCapture:this.buildEmailCapture()})}buildEmailCapture(){if(this.config.user)return;const{feedbackId:t,identityToken:e}=this.lastHandoff;if(!(!t||!e)&&!Wt())return{onSubmit:async r=>{const n=await this.apiClient.updateReporter(t,r,e);return n&&Pn(r),n}}}buildViewFeedbackHandler(){const{boardUrl:t,identityToken:e}=this.lastHandoff;if(t){if(e)return()=>{window.open(`${t}?identity=${encodeURIComponent(e)}`,"_blank")};if(this.config.userToken||this.config.userTokenFn)return async()=>{const r=await this.apiClient.resolveUserToken();r&&window.open(`${t}?identity=${encodeURIComponent(r)}`,"_blank")}}}teardownToolbar(){this.pageOffset.release(),this.toolbar?.destroy(),this.toolbar=null}exitAll(){this.submissionAttempt+=1;const t=this.activeSubmission;this.activeSubmission=null,this.pendingSubmissionRequest=null,t&&this.apiClient.abandonSubmissionSession(t.id,t.token).catch(()=>{}),this.mode="idle",this.via="pin",this.tab?.setActive(!1),this.teardownToolbar(),this.teardownDraw(),this.session?.hideHighlight(),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}destroy(){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()}}function On(){return new Promise(i=>requestAnimationFrame(()=>setTimeout(i,0)))}let b=null,_=null,T=null;function Gt(){T&&(document.removeEventListener("DOMContentLoaded",T),T=null)}const _e={init(i){Gt(),b&&(b.destroy(),b=null),_=i,document.readyState==="loading"?(T=()=>{T=null,b=new dt(i)},document.addEventListener("DOMContentLoaded",T,{once:!0})):b=new dt(i)},destroy(){Gt(),b?.destroy(),b=null,_=null},setLocale(i){_&&(_.locale=i),b?.setLocale(i)},open(){b?.open()},close(){b?.close()},showLauncher(){b?.showLauncher()},hideLauncher(){b?.hideLauncher()}};typeof window<"u"&&(window.MakeThisBetter=_e,document.addEventListener("turbo:load",()=>{const i=document.getElementById("mtb-widget-host");_&&(!i||!i.shadowRoot)&&(b?.destroy(),i?.remove(),b=new dt(_))}));exports.MakeThisBetter=_e;
146
146
  //# sourceMappingURL=makethisbetter.cjs.map