makethisbetter 1.24.0 → 1.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/makethisbetter.cjs +10 -10
- package/dist/makethisbetter.cjs.map +1 -1
- package/dist/makethisbetter.esm.js +100 -100
- package/dist/makethisbetter.esm.js.map +1 -1
- package/dist/makethisbetter.js +9 -9
- package/dist/makethisbetter.js.map +1 -1
- package/dist/makethisbetter.standalone.js +125 -125
- package/dist/makethisbetter.standalone.js.map +1 -1
- package/dist/popup/success.d.ts.map +1 -1
- package/dist/styles/brand-color-guard.test.d.ts +2 -0
- package/dist/styles/brand-color-guard.test.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/popup/success.ts +1 -2
- package/src/styles/widget.css +10 -5
- package/src/widget/pet.ts +6 -7
package/dist/makethisbetter.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";var Ee=Object.create;var St=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Ce=Object.getPrototypeOf,Ae=Object.prototype.hasOwnProperty;var Le=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of _e(t))!Ae.call(i,n)&&n!==e&&St(i,n,{get:()=>t[n],enumerable:!(r=Te(t,n))||r.enumerable});return i};var Pe=(i,t,e)=>(e=i!=null?Ee(Ce(i)):{},Le(t||!i||!i.__esModule?St(e,"default",{value:i,enumerable:!0}):e,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Me=`*,*: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-brand-primary: #059669;--mtb-brand-hover: #047857;--mtb-brand-active: #065f46;--mtb-brand-on-primary: #fff;--mtb-brand-rgb: 5, 150, 105;--mtb-brand-on-primary-rgb: 255, 255, 255;--mtb-brand-emphasis: #10b981;--mtb-brand-emphasis-rgb: 16, 185, 129;--mtb-brand-gradient-start: #10b981;--mtb-brand-gradient-end: #059669;--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(var(--mtb-brand-emphasis-rgb), .06);--mtb-quick-hover-border: rgba(var(--mtb-brand-emphasis-rgb), .3);--mtb-quick-selected-bg: rgba(var(--mtb-brand-emphasis-rgb), .1);--mtb-quick-selected-border: rgba(var(--mtb-brand-emphasis-rgb), .5);--mtb-field-focus-border: var(--mtb-brand-emphasis);--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: rgba(var(--mtb-brand-emphasis-rgb), .12);--mtb-quick-hover-border: rgba(var(--mtb-brand-emphasis-rgb), .45);--mtb-quick-selected-bg: rgba(var(--mtb-brand-emphasis-rgb), .18);--mtb-quick-selected-border: var(--mtb-brand-primary);--mtb-field-focus-border: var(--mtb-brand-emphasis);--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: rgba(var(--mtb-brand-emphasis-rgb), .12);--mtb-quick-hover-border: rgba(var(--mtb-brand-emphasis-rgb), .45);--mtb-quick-selected-bg: rgba(var(--mtb-brand-emphasis-rgb), .18);--mtb-quick-selected-border: var(--mtb-brand-primary);--mtb-field-focus-border: var(--mtb-brand-emphasis);--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");--mtb-tab-bg: var(--mtb-brand-primary);--mtb-tab-hover-bg: var(--mtb-brand-hover);--mtb-tab-active-bg: var(--mtb-brand-active);--mtb-tab-shadow-color: var(--mtb-brand-rgb);--mtb-tab-fg: var(--mtb-brand-on-primary);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:var(--mtb-tab-bg);color:var(--mtb-tab-fg);border-radius:8px 0 0 8px;cursor:pointer;box-shadow:-2px 0 14px rgba(var(--mtb-tab-shadow-color),.35);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 rgba(var(--mtb-tab-shadow-color),.35)}.mtb-tab:hover{background:var(--mtb-tab-hover-bg);box-shadow:-3px 0 20px rgba(var(--mtb-tab-shadow-color),.45)}.mtb-tab.active{background:var(--mtb-tab-active-bg)}.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,var(--mtb-brand-gradient-start),var(--mtb-brand-gradient-end));color:var(--mtb-brand-on-primary);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,var(--mtb-brand-gradient-start),var(--mtb-brand-gradient-end));color:var(--mtb-brand-on-primary);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:rgba(var(--mtb-brand-on-primary-rgb),.16);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:var(--mtb-brand-on-primary);transition:all .12s}.mtb-toolbar-mode-btn.active{background:#fff;color:var(--mtb-brand-active)}.mtb-toolbar-hint{font-size:12px;color:var(--mtb-brand-on-primary);white-space:nowrap}.mtb-toolbar-sep{width:20px;height:1px;align-self:center;background:rgba(var(--mtb-brand-on-primary-rgb),.22)}.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:var(--mtb-brand-on-primary);cursor:pointer;background:rgba(var(--mtb-brand-on-primary-rgb),.16);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:var(--mtb-brand-on-primary)}.mtb-toolbar-mode-btn{opacity:.72}.mtb-exit-btn{opacity:1}.mtb-toolbar-mode-btn:hover,.mtb-exit-btn:hover{background:rgba(var(--mtb-brand-on-primary-rgb),.16);color:var(--mtb-brand-on-primary);opacity:1}.mtb-toolbar-mode-btn.active,.mtb-toolbar-mode-btn.active:hover{background:var(--mtb-brand-on-primary);color:var(--mtb-brand-hover);opacity:1}.mtb-exit-btn{color:var(--mtb-brand-on-primary)}.mtb-toolbar-sep{width:16px;height:1px;margin:1px 0;align-self:center;background:rgba(var(--mtb-brand-on-primary-rgb),.28)}.mtb-exit-btn:hover{background:rgba(var(--mtb-brand-on-primary-rgb),.28)}.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 var(--mtb-brand-emphasis);border-radius:6px;background:rgba(var(--mtb-brand-emphasis-rgb),.06);transition:all .08s ease}.mtb-highlight.selected{border-color:var(--mtb-brand-active);background:rgba(var(--mtb-brand-emphasis-rgb),.1)}.mtb-highlight-tooltip{position:fixed;z-index:2147483642;pointer-events:none;transform:translate(-50%,-100%);max-width:240px;overflow:hidden;text-overflow:ellipsis;background:var(--mtb-brand-active);color:var(--mtb-brand-on-primary);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:var(--mtb-brand-active)}.mtb-highlight-tooltip.below:after{top:auto;bottom:100%;border-top-color:transparent;border-bottom-color:var(--mtb-brand-active)}.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:var(--mtb-brand-primary);border:2px solid #fff;display:flex;align-items:center;justify-content:center;font-size:10px;color:var(--mtb-brand-on-primary);font-weight:700;box-shadow:0 0 0 1px #0f172aad,0 2px 8px rgba(var(--mtb-brand-rgb),.45);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:rgba(var(--mtb-brand-emphasis-rgb),.1);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 rgba(var(--mtb-brand-emphasis-rgb),.15)}.mtb-textarea::placeholder{color:var(--mtb-placeholder-fg)}.mtb-screenshot-opt{display:flex;align-items:center;gap:7px;margin-top:10px;padding:0 2px;color:var(--mtb-action-fg);font-size:12px;cursor:pointer;user-select:none}.mtb-screenshot-opt input{width:13px;height:13px;margin:0;flex-shrink:0;accent-color:var(--mtb-brand-primary);cursor:pointer}.mtb-screenshot-opt--locked,.mtb-screenshot-opt--locked input{cursor:default}.mtb-screenshot-opt--locked input:disabled,.mtb-draw-shot input:disabled{appearance:none;-webkit-appearance:none;border:none;border-radius:4px;background-color:var(--mtb-placeholder-fg);background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5l3 3 6-6'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:center;background-size:contain;opacity:1}.mtb-draw-shot input:disabled{background-color:#0000004d}.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:var(--mtb-brand-primary);border-color:var(--mtb-brand-primary);color:var(--mtb-brand-on-primary)}.mtb-submit-btn.ready:hover{background:var(--mtb-brand-hover);border-color:var(--mtb-brand-hover)}.mtb-submit-btn.ready:active{background:var(--mtb-brand-active);border-color:var(--mtb-brand-active)}.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-failure{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-failure-icon{width:46px;height:46px;border-radius:50%;background:#dc262617;display:flex;align-items:center;justify-content:center;margin:0 auto 12px}.mtb-failure-title{font-size:15px;font-weight:600;margin-bottom:14px;letter-spacing:-.01em;line-height:1.45;color:var(--mtb-fg)}.mtb-failure-title:last-child{margin-bottom:0}.mtb-failure-actions{display:flex;align-items:center;justify-content:center}.mtb-failure-close{position:absolute;top:12px;right:12px;background:none;border:none;cursor:pointer;padding:3px;color:var(--mtb-clarify-close-fg);display:flex;transition:color .12s}.mtb-failure-close:hover{color:var(--mtb-clarify-close-hover-fg)}.mtb-view-feedback-link{display:inline-flex;align-items:center;gap:5px;color:var(--mtb-brand-active);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:var(--mtb-brand-primary)}.mtb-email-input.mtb-email-invalid{border-color:#dc2626}.mtb-email-submit{font-size:12px;font-weight:600;font-family:inherit;color:var(--mtb-brand-on-primary);background:var(--mtb-brand-primary);border:none;border-radius:8px;padding:7px 12px;cursor:pointer;white-space:nowrap}.mtb-email-submit:disabled{opacity:.6;cursor:default}.mtb-email-submit:hover:not(:disabled){background:var(--mtb-brand-hover)}.mtb-email-submit:active:not(:disabled){background:var(--mtb-brand-active)}.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:var(--mtb-brand-primary)}.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:var(--mtb-brand-primary);color:var(--mtb-brand-on-primary);cursor:pointer;font-family:inherit;font-size:12px;font-weight:600;transition:background .12s}.mtb-frustration-tell:hover{background:var(--mtb-brand-hover)}.mtb-frustration-tell:active{background:var(--mtb-brand-active)}.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:var(--mtb-brand-primary);color:var(--mtb-brand-on-primary);cursor:pointer;font-family:inherit;font-size:12px;font-weight:600;transition:background .12s}.mtb-record-stop:hover{background:var(--mtb-brand-hover)}.mtb-record-stop:active{background:var(--mtb-brand-active)}.mtb-click-ripple{position:fixed;z-index:2147483644;width:24px;height:24px;border-radius:50%;border:2px solid var(--mtb-brand-emphasis);background:rgba(var(--mtb-brand-emphasis-rgb),.2);box-shadow:0 0 0 1px #ffffffeb,0 0 0 2px #0f172aad;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,var(--mtb-brand-gradient-start),var(--mtb-brand-gradient-end));box-shadow:0 1px 3px rgba(var(--mtb-brand-rgb),.4);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:var(--mtb-brand-primary);color:var(--mtb-brand-on-primary);border:1px solid var(--mtb-brand-primary);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:rgba(var(--mtb-brand-rgb),.7)}.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 rgba(var(--mtb-brand-emphasis-rgb),.15);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:var(--mtb-brand-primary);color:var(--mtb-brand-on-primary);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:var(--mtb-brand-hover)}.mtb-clarify-send:not(:disabled):active,.mtb-clarify-retry:not(:disabled):active{background:var(--mtb-brand-active)}.mtb-clarify-send:disabled,.mtb-clarify-retry:disabled{background:#00000026;cursor:not-allowed}.mtb-clarify-send[aria-busy=true]:disabled{background:var(--mtb-brand-primary);cursor:wait}.mtb-clarify-send-spinner{width:13px;height:13px;display:none;border:2px solid rgba(var(--mtb-brand-on-primary-rgb),.45);border-top-color:var(--mtb-brand-on-primary);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:var(--mtb-brand-primary);color:var(--mtb-brand-on-primary);cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:600;transition:background .12s}.mtb-clarify-send-feedback:not(:disabled):hover{background:var(--mtb-brand-hover)}.mtb-clarify-send-feedback:not(:disabled):active{background:var(--mtb-brand-active)}.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:var(--mtb-brand-emphasis);box-shadow:0 0 0 3px rgba(var(--mtb-brand-emphasis-rgb),.15);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-shot{display:inline-flex;align-items:center;gap:6px;font-size:12.5px;color:#0000008c;white-space:nowrap;cursor:default;user-select:none}.mtb-draw-shot input{width:14px;height:14px;margin:0;accent-color:var(--mtb-brand-primary);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:var(--mtb-brand-primary);color:var(--mtb-brand-on-primary);cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:600;transition:background .12s}.mtb-draw-submit:hover:not(:disabled){background:var(--mtb-brand-hover)}.mtb-draw-submit:active:not(:disabled){background:var(--mtb-brand-active)}.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:var(--mtb-brand-primary);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:var(--mtb-brand-on-primary);color:var(--mtb-brand-hover);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}}`,w="mtb-widget-host";function S(i){const t=document.getElementById(w);return t?t===i||t.contains(i):!1}function Y(i,t){return document.elementsFromPoint?.(i,t).find(e=>e.id!==w)??null}function l(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function $(i){return i.isComposing||i.keyCode===229}const Ie=/^(script|style|noscript|template)$/i;function Gt(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&&!Ie.test(r.tagName)&&(e+=Gt(r,t-e.length))}return e}function ft(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=Gt(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(" > ")}const B=class B{constructor(t="auto",e){this.stopHostInteraction=s=>{s.stopPropagation()};const r=document.getElementById(w);if(this.ownsHost=!r,this.host=r??document.createElement("div"),this.root=this.host.shadowRoot??this.host.attachShadow({mode:"open"}),this.root.replaceChildren(),this.originalInlineStyle=this.host.getAttribute("style"),this.originalTheme=this.host.getAttribute("data-mtb-theme"),this.host.id=w,this.host.style.cssText="position:fixed;top:0;left:0;width:0;height:0;overflow:visible;z-index:2147483646;",e){const s=[1,3,5].map(a=>parseInt(e.primary.slice(a,a+2),16)),o=[1,3,5].map(a=>parseInt(e.onPrimary.slice(a,a+2),16));this.host.style.setProperty("--mtb-brand-primary",e.primary.toLowerCase()),this.host.style.setProperty("--mtb-brand-hover",e.hover.toLowerCase()),this.host.style.setProperty("--mtb-brand-active",e.active.toLowerCase()),this.host.style.setProperty("--mtb-brand-on-primary",e.onPrimary.toLowerCase()),this.host.style.setProperty("--mtb-brand-rgb",s.join(", ")),this.host.style.setProperty("--mtb-brand-on-primary-rgb",o.join(", ")),this.host.style.setProperty("--mtb-brand-emphasis",e.primary.toLowerCase()),this.host.style.setProperty("--mtb-brand-emphasis-rgb",s.join(", ")),this.host.style.setProperty("--mtb-brand-gradient-start",e.primary.toLowerCase()),this.host.style.setProperty("--mtb-brand-gradient-end",e.hover.toLowerCase())}this.host.setAttribute("data-mtb-theme",t),this.ownsHost&&document.body.appendChild(this.host);for(const s of B.HOST_INTERACTION_EVENTS)this.root.addEventListener(s,this.stopHostInteraction);const n=document.createElement("style");n.textContent=Me,this.root.appendChild(n)}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(){for(const t of B.HOST_INTERACTION_EVENTS)this.root.removeEventListener(t,this.stopHostInteraction);if(!this.ownsHost){this.root.replaceChildren(),this.host.removeAttribute("data-mtb-toolbar"),this.originalInlineStyle===null?this.host.removeAttribute("style"):this.host.setAttribute("style",this.originalInlineStyle),this.originalTheme===null?this.host.removeAttribute("data-mtb-theme"):this.host.setAttribute("data-mtb-theme",this.originalTheme);return}this.host.remove()}};B.HOST_INTERACTION_EVENTS=["pointerdown","pointerup","pointercancel","mousedown","mouseup","touchstart","touchend","touchcancel","click"];let ht=B;class Re{constructor(t,e,r,n,s,o){this.active=!1,this.onClick=n,this.customText=s,this.el=t.el("button","mtb-tab"),r==="left"&&this.el.classList.add("left"),this.setCustomColor(o),this.idleLabel=s??e.tab,this.activeLabel=e.toolbar.exit,this.setLabel(this.idleLabel),this.el.addEventListener("click",n),t.append(this.el)}setCustomColor(t){if(!t||!/^#[0-9a-f]{6}$/i.test(t))return;const e=[1,3,5].map(n=>parseInt(t.slice(n,n+2),16)),r=n=>`#${e.map(o=>Math.round(o*(1-n))).map(o=>o.toString(16).padStart(2,"0")).join("")}`;this.el.style.setProperty("--mtb-tab-bg",t.toLowerCase()),this.el.style.setProperty("--mtb-tab-hover-bg",r(.15)),this.el.style.setProperty("--mtb-tab-active-bg",r(.28)),this.el.style.setProperty("--mtb-tab-shadow-color",e.join(", ")),this.el.style.setProperty("--mtb-tab-fg",this.foregroundFor(e))}foregroundFor(t){const e=t.map(n=>{const s=n/255;return s<=.04045?s/12.92:((s+.055)/1.055)**2.4});return .2126*e[0]+.7152*e[1]+.0722*e[2]>.179?"#191a1c":"#fff"}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 De=8e3;class Fe{constructor(t,e,r){this.autoHideTimer=null,this.el=t.el("div","mtb-frustration-prompt"),this.el.innerHTML=`
|
|
1
|
+
"use strict";var Ee=Object.create;var kt=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Ce=Object.getPrototypeOf,Ae=Object.prototype.hasOwnProperty;var Le=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of _e(t))!Ae.call(i,n)&&n!==e&&kt(i,n,{get:()=>t[n],enumerable:!(r=Te(t,n))||r.enumerable});return i};var Pe=(i,t,e)=>(e=i!=null?Ee(Ce(i)):{},Le(t||!i||!i.__esModule?kt(e,"default",{value:i,enumerable:!0}):e,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Me=`*,*: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-brand-primary: #059669;--mtb-brand-hover: #047857;--mtb-brand-active: #065f46;--mtb-brand-on-primary: #fff;--mtb-brand-rgb: 5, 150, 105;--mtb-brand-on-primary-rgb: 255, 255, 255;--mtb-brand-emphasis: #10b981;--mtb-brand-emphasis-rgb: 16, 185, 129;--mtb-brand-gradient-start: #10b981;--mtb-brand-gradient-end: #059669;--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(var(--mtb-brand-emphasis-rgb), .06);--mtb-quick-hover-border: rgba(var(--mtb-brand-emphasis-rgb), .3);--mtb-quick-selected-bg: rgba(var(--mtb-brand-emphasis-rgb), .1);--mtb-quick-selected-border: rgba(var(--mtb-brand-emphasis-rgb), .5);--mtb-field-focus-border: var(--mtb-brand-emphasis);--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: rgba(var(--mtb-brand-emphasis-rgb), .12);--mtb-quick-hover-border: rgba(var(--mtb-brand-emphasis-rgb), .45);--mtb-quick-selected-bg: rgba(var(--mtb-brand-emphasis-rgb), .18);--mtb-quick-selected-border: var(--mtb-brand-primary);--mtb-field-focus-border: var(--mtb-brand-emphasis);--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: rgba(var(--mtb-brand-emphasis-rgb), .12);--mtb-quick-hover-border: rgba(var(--mtb-brand-emphasis-rgb), .45);--mtb-quick-selected-bg: rgba(var(--mtb-brand-emphasis-rgb), .18);--mtb-quick-selected-border: var(--mtb-brand-primary);--mtb-field-focus-border: var(--mtb-brand-emphasis);--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");--mtb-tab-bg: var(--mtb-brand-primary);--mtb-tab-hover-bg: var(--mtb-brand-hover);--mtb-tab-active-bg: var(--mtb-brand-active);--mtb-tab-shadow-color: var(--mtb-brand-rgb);--mtb-tab-fg: var(--mtb-brand-on-primary);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:var(--mtb-tab-bg);color:var(--mtb-tab-fg);border-radius:8px 0 0 8px;cursor:pointer;box-shadow:-2px 0 14px rgba(var(--mtb-tab-shadow-color),.35);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 rgba(var(--mtb-tab-shadow-color),.35)}.mtb-tab:hover{background:var(--mtb-tab-hover-bg);box-shadow:-3px 0 20px rgba(var(--mtb-tab-shadow-color),.45)}.mtb-tab.active{background:var(--mtb-tab-active-bg)}.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,var(--mtb-brand-gradient-start),var(--mtb-brand-gradient-end));color:var(--mtb-brand-on-primary);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,var(--mtb-brand-gradient-start),var(--mtb-brand-gradient-end));color:var(--mtb-brand-on-primary);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:rgba(var(--mtb-brand-on-primary-rgb),.16);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:var(--mtb-brand-on-primary);transition:all .12s}.mtb-toolbar-mode-btn.active{background:#fff;color:var(--mtb-brand-active)}.mtb-toolbar-hint{font-size:12px;color:var(--mtb-brand-on-primary);white-space:nowrap}.mtb-toolbar-sep{width:20px;height:1px;align-self:center;background:rgba(var(--mtb-brand-on-primary-rgb),.22)}.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:var(--mtb-brand-on-primary);cursor:pointer;background:rgba(var(--mtb-brand-on-primary-rgb),.16);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:var(--mtb-brand-on-primary)}.mtb-toolbar-mode-btn{opacity:.72}.mtb-exit-btn{opacity:1}.mtb-toolbar-mode-btn:hover,.mtb-exit-btn:hover{background:rgba(var(--mtb-brand-on-primary-rgb),.16);color:var(--mtb-brand-on-primary);opacity:1}.mtb-toolbar-mode-btn.active,.mtb-toolbar-mode-btn.active:hover{background:var(--mtb-brand-on-primary);color:var(--mtb-brand-hover);opacity:1}.mtb-exit-btn{color:var(--mtb-brand-on-primary)}.mtb-toolbar-sep{width:16px;height:1px;margin:1px 0;align-self:center;background:rgba(var(--mtb-brand-on-primary-rgb),.28)}.mtb-exit-btn:hover{background:rgba(var(--mtb-brand-on-primary-rgb),.28)}.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 var(--mtb-brand-emphasis);border-radius:6px;background:rgba(var(--mtb-brand-emphasis-rgb),.06);transition:all .08s ease}.mtb-highlight.selected{border-color:var(--mtb-brand-active);background:rgba(var(--mtb-brand-emphasis-rgb),.1)}.mtb-highlight-tooltip{position:fixed;z-index:2147483642;pointer-events:none;transform:translate(-50%,-100%);max-width:240px;overflow:hidden;text-overflow:ellipsis;background:var(--mtb-brand-active);color:var(--mtb-brand-on-primary);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:var(--mtb-brand-active)}.mtb-highlight-tooltip.below:after{top:auto;bottom:100%;border-top-color:transparent;border-bottom-color:var(--mtb-brand-active)}.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:var(--mtb-brand-primary);border:2px solid #fff;display:flex;align-items:center;justify-content:center;font-size:10px;color:var(--mtb-brand-on-primary);font-weight:700;box-shadow:0 0 0 1px #0f172aad,0 2px 8px rgba(var(--mtb-brand-rgb),.45);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:rgba(var(--mtb-brand-emphasis-rgb),.1);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 rgba(var(--mtb-brand-emphasis-rgb),.15)}.mtb-textarea::placeholder{color:var(--mtb-placeholder-fg)}.mtb-screenshot-opt{display:flex;align-items:center;gap:7px;margin-top:10px;padding:0 2px;color:var(--mtb-action-fg);font-size:12px;cursor:pointer;user-select:none}.mtb-screenshot-opt input{width:13px;height:13px;margin:0;flex-shrink:0;accent-color:var(--mtb-brand-primary);cursor:pointer}.mtb-screenshot-opt--locked,.mtb-screenshot-opt--locked input{cursor:default}.mtb-screenshot-opt--locked input:disabled,.mtb-draw-shot input:disabled{appearance:none;-webkit-appearance:none;border:none;border-radius:4px;background-color:var(--mtb-placeholder-fg);background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' d='M3.5 8.5l3 3 6-6'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:center;background-size:contain;opacity:1}.mtb-draw-shot input:disabled{background-color:#0000004d}.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:var(--mtb-brand-primary);border-color:var(--mtb-brand-primary);color:var(--mtb-brand-on-primary)}.mtb-submit-btn.ready:hover{background:var(--mtb-brand-hover);border-color:var(--mtb-brand-hover)}.mtb-submit-btn.ready:active{background:var(--mtb-brand-active);border-color:var(--mtb-brand-active)}.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:rgba(var(--mtb-brand-rgb),.09);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-failure{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-failure-icon{width:46px;height:46px;border-radius:50%;background:#dc262617;display:flex;align-items:center;justify-content:center;margin:0 auto 12px}.mtb-failure-title{font-size:15px;font-weight:600;margin-bottom:14px;letter-spacing:-.01em;line-height:1.45;color:var(--mtb-fg)}.mtb-failure-title:last-child{margin-bottom:0}.mtb-failure-actions{display:flex;align-items:center;justify-content:center}.mtb-failure-close{position:absolute;top:12px;right:12px;background:none;border:none;cursor:pointer;padding:3px;color:var(--mtb-clarify-close-fg);display:flex;transition:color .12s}.mtb-failure-close:hover{color:var(--mtb-clarify-close-hover-fg)}.mtb-view-feedback-link{display:inline-flex;align-items:center;gap:5px;color:var(--mtb-brand-active);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:var(--mtb-brand-primary)}.mtb-email-input.mtb-email-invalid{border-color:#dc2626}.mtb-email-submit{font-size:12px;font-weight:600;font-family:inherit;color:var(--mtb-brand-on-primary);background:var(--mtb-brand-primary);border:none;border-radius:8px;padding:7px 12px;cursor:pointer;white-space:nowrap}.mtb-email-submit:disabled{opacity:.6;cursor:default}.mtb-email-submit:hover:not(:disabled){background:var(--mtb-brand-hover)}.mtb-email-submit:active:not(:disabled){background:var(--mtb-brand-active)}.mtb-email-error{font-size:11.5px;color:#dc2626;margin-top:6px}.mtb-email-saved{font-size:12px;color:var(--mtb-brand-primary);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:var(--mtb-brand-primary)}.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(var(--mtb-brand-rgb),.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:var(--mtb-brand-primary);color:var(--mtb-brand-on-primary);cursor:pointer;font-family:inherit;font-size:12px;font-weight:600;transition:background .12s}.mtb-frustration-tell:hover{background:var(--mtb-brand-hover)}.mtb-frustration-tell:active{background:var(--mtb-brand-active)}.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:var(--mtb-brand-primary);color:var(--mtb-brand-on-primary);cursor:pointer;font-family:inherit;font-size:12px;font-weight:600;transition:background .12s}.mtb-record-stop:hover{background:var(--mtb-brand-hover)}.mtb-record-stop:active{background:var(--mtb-brand-active)}.mtb-click-ripple{position:fixed;z-index:2147483644;width:24px;height:24px;border-radius:50%;border:2px solid var(--mtb-brand-emphasis);background:rgba(var(--mtb-brand-emphasis-rgb),.25);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,var(--mtb-brand-gradient-start),var(--mtb-brand-gradient-end));box-shadow:0 1px 3px rgba(var(--mtb-brand-rgb),.4);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:var(--mtb-brand-primary);color:var(--mtb-brand-on-primary);border:1px solid var(--mtb-brand-primary);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:rgba(var(--mtb-brand-rgb),.7)}.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 rgba(var(--mtb-brand-emphasis-rgb),.15);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:var(--mtb-brand-primary);color:var(--mtb-brand-on-primary);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:var(--mtb-brand-hover)}.mtb-clarify-send:not(:disabled):active,.mtb-clarify-retry:not(:disabled):active{background:var(--mtb-brand-active)}.mtb-clarify-send:disabled,.mtb-clarify-retry:disabled{background:#00000026;cursor:not-allowed}.mtb-clarify-send[aria-busy=true]:disabled{background:var(--mtb-brand-primary);cursor:wait}.mtb-clarify-send-spinner{width:13px;height:13px;display:none;border:2px solid rgba(var(--mtb-brand-on-primary-rgb),.45);border-top-color:var(--mtb-brand-on-primary);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:var(--mtb-brand-primary);color:var(--mtb-brand-on-primary);cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:600;transition:background .12s}.mtb-clarify-send-feedback:not(:disabled):hover{background:var(--mtb-brand-hover)}.mtb-clarify-send-feedback:not(:disabled):active{background:var(--mtb-brand-active)}.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:var(--mtb-brand-emphasis);box-shadow:0 0 0 3px rgba(var(--mtb-brand-emphasis-rgb),.15);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-shot{display:inline-flex;align-items:center;gap:6px;font-size:12.5px;color:#0000008c;white-space:nowrap;cursor:default;user-select:none}.mtb-draw-shot input{width:14px;height:14px;margin:0;accent-color:var(--mtb-brand-primary);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:var(--mtb-brand-primary);color:var(--mtb-brand-on-primary);cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:600;transition:background .12s}.mtb-draw-submit:hover:not(:disabled){background:var(--mtb-brand-hover)}.mtb-draw-submit:active:not(:disabled){background:var(--mtb-brand-active)}.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:var(--mtb-brand-primary);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:var(--mtb-brand-on-primary);color:var(--mtb-brand-hover);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}}`,w="mtb-widget-host";function S(i){const t=document.getElementById(w);return t?t===i||t.contains(i):!1}function Y(i,t){return document.elementsFromPoint?.(i,t).find(e=>e.id!==w)??null}function l(i){return i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function $(i){return i.isComposing||i.keyCode===229}const Ie=/^(script|style|noscript|template)$/i;function Xt(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&&!Ie.test(r.tagName)&&(e+=Xt(r,t-e.length))}return e}function ft(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=Xt(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 Gt(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(" > ")}const B=class B{constructor(t="auto",e){this.stopHostInteraction=s=>{s.stopPropagation()};const r=document.getElementById(w);if(this.ownsHost=!r,this.host=r??document.createElement("div"),this.root=this.host.shadowRoot??this.host.attachShadow({mode:"open"}),this.root.replaceChildren(),this.originalInlineStyle=this.host.getAttribute("style"),this.originalTheme=this.host.getAttribute("data-mtb-theme"),this.host.id=w,this.host.style.cssText="position:fixed;top:0;left:0;width:0;height:0;overflow:visible;z-index:2147483646;",e){const s=[1,3,5].map(a=>parseInt(e.primary.slice(a,a+2),16)),o=[1,3,5].map(a=>parseInt(e.onPrimary.slice(a,a+2),16));this.host.style.setProperty("--mtb-brand-primary",e.primary.toLowerCase()),this.host.style.setProperty("--mtb-brand-hover",e.hover.toLowerCase()),this.host.style.setProperty("--mtb-brand-active",e.active.toLowerCase()),this.host.style.setProperty("--mtb-brand-on-primary",e.onPrimary.toLowerCase()),this.host.style.setProperty("--mtb-brand-rgb",s.join(", ")),this.host.style.setProperty("--mtb-brand-on-primary-rgb",o.join(", ")),this.host.style.setProperty("--mtb-brand-emphasis",e.primary.toLowerCase()),this.host.style.setProperty("--mtb-brand-emphasis-rgb",s.join(", ")),this.host.style.setProperty("--mtb-brand-gradient-start",e.primary.toLowerCase()),this.host.style.setProperty("--mtb-brand-gradient-end",e.hover.toLowerCase())}this.host.setAttribute("data-mtb-theme",t),this.ownsHost&&document.body.appendChild(this.host);for(const s of B.HOST_INTERACTION_EVENTS)this.root.addEventListener(s,this.stopHostInteraction);const n=document.createElement("style");n.textContent=Me,this.root.appendChild(n)}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(){for(const t of B.HOST_INTERACTION_EVENTS)this.root.removeEventListener(t,this.stopHostInteraction);if(!this.ownsHost){this.root.replaceChildren(),this.host.removeAttribute("data-mtb-toolbar"),this.originalInlineStyle===null?this.host.removeAttribute("style"):this.host.setAttribute("style",this.originalInlineStyle),this.originalTheme===null?this.host.removeAttribute("data-mtb-theme"):this.host.setAttribute("data-mtb-theme",this.originalTheme);return}this.host.remove()}};B.HOST_INTERACTION_EVENTS=["pointerdown","pointerup","pointercancel","mousedown","mouseup","touchstart","touchend","touchcancel","click"];let ht=B;class Re{constructor(t,e,r,n,s,o){this.active=!1,this.onClick=n,this.customText=s,this.el=t.el("button","mtb-tab"),r==="left"&&this.el.classList.add("left"),this.setCustomColor(o),this.idleLabel=s??e.tab,this.activeLabel=e.toolbar.exit,this.setLabel(this.idleLabel),this.el.addEventListener("click",n),t.append(this.el)}setCustomColor(t){if(!t||!/^#[0-9a-f]{6}$/i.test(t))return;const e=[1,3,5].map(n=>parseInt(t.slice(n,n+2),16)),r=n=>`#${e.map(o=>Math.round(o*(1-n))).map(o=>o.toString(16).padStart(2,"0")).join("")}`;this.el.style.setProperty("--mtb-tab-bg",t.toLowerCase()),this.el.style.setProperty("--mtb-tab-hover-bg",r(.15)),this.el.style.setProperty("--mtb-tab-active-bg",r(.28)),this.el.style.setProperty("--mtb-tab-shadow-color",e.join(", ")),this.el.style.setProperty("--mtb-tab-fg",this.foregroundFor(e))}foregroundFor(t){const e=t.map(n=>{const s=n/255;return s<=.04045?s/12.92:((s+.055)/1.055)**2.4});return .2126*e[0]+.7152*e[1]+.0722*e[2]>.179?"#191a1c":"#fff"}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 De=8e3;class Fe{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">⚠️</div>
|
|
3
3
|
<span class="mtb-frustration-text">${l(e.frustration.prompt)}</span>
|
|
4
4
|
<div class="mtb-frustration-actions">
|
|
5
5
|
<button class="mtb-frustration-tell">${l(e.frustration.action)}</button>
|
|
6
6
|
<button class="mtb-frustration-dismiss">${l(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,De)}destroy(){this.autoHideTimer&&(clearTimeout(this.autoHideTimer),this.autoHideTimer=null),this.el.remove()}}const He=400;class Be{constructor(t,e,r=()=>Date.now()){this.bornAt=Date.now(),this.bornAt=r(),this.onClick=()=>{r()-this.bornAt<He||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 y(){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
|
|
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,De)}destroy(){this.autoHideTimer&&(clearTimeout(this.autoHideTimer),this.autoHideTimer=null),this.el.remove()}}const He=400;class Be{constructor(t,e,r=()=>Date.now()){this.bornAt=Date.now(),this.bornAt=r(),this.onClick=()=>{r()-this.bornAt<He||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 y(){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 St=["wheel","touchmove"];function $e(i){for(const t of i.composedPath()){if(!(t instanceof Element))continue;const e=getComputedStyle(t);if(/auto|scroll/.test(`${e.overflowY} ${e.overflowX}`)&&(t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth))return!0}return!1}function ze(){const i=t=>{$e(t)||t.cancelable&&t.preventDefault()};for(const t of St)window.addEventListener(t,i,{capture:!0,passive:!1});return{release(){for(const t of St)window.removeEventListener(t,i,{capture:!0})}}}const Oe=44;class Ue{constructor(t,e,r,n,s="right",o=!0){this.currentMode="markup",this.handlePointerMove=a=>{if(a.pointerType!=="mouse")return;const c=this.hintBarEl.getBoundingClientRect(),d=a.clientX>=c.left&&a.clientX<=c.right&&a.clientY>=c.top&&a.clientY<=c.bottom;this.hintBarEl.classList.toggle("mtb-hint-bar--under-pointer",d)},this.touchHintDismissListening=!1,this.dismissTouchHint=()=>{this.hintBarEl.classList.add("mtb-hint-bar--dismissed"),this.stopTouchHintDismissListening()},this.messages=e,this.touch=y(),this.hintBarEl=t.el("div","mtb-hint-bar"),this.hintBarEl.innerHTML=`<span class="mtb-toolbar-hint">${l(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),this.touchHintDismissListening=!0)}stopTouchHintDismissListening(){this.touchHintDismissListening&&(this.touchHintDismissListening=!1,document.removeEventListener("pointerdown",this.dismissTouchHint,!0))}buildHTML(t){return`
|
|
9
9
|
<div class="mtb-toolbar-modes">
|
|
10
10
|
<button class="mtb-toolbar-mode-btn mtb-toolbar-mode-markup active" aria-label="${l(t.toolbar.markup)}" title="${l(t.toolbar.markup)}">
|
|
11
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">${l(t.toolbar.markup)}</span>
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
<path d="M18 6L6 18M6 6l12 12"/>
|
|
21
21
|
</svg><span class="mtb-toolbar-label">${l(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||Oe}destroy(){document.removeEventListener("pointermove",this.handlePointerMove),this.stopTouchHintDismissListening(),this.host.removeAttribute("data-mtb-toolbar"),this.hintBarEl.remove(),this.el.remove()}}class je{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 qe{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=ft(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()}}function We(i,t,e){return{left:i.left,top:i.top,scaleX:t/i.width,scaleY:e/i.height}}function X(i,t){return(t-i.left)*i.scaleX}function G(i,t){return(t-i.top)*i.scaleY}function Ye(i,t){return{left:X(i,t.left),top:G(i,t.top),width:t.width*i.scaleX,height:t.height*i.scaleY}}function Ve(){return{left:0,top:0,width:window.innerWidth,height:window.innerHeight}}function Ke(i,t){return{x:i.x-t.x,y:i.y-t.y}}function j(i){let t=0,e=0,r=i;for(;r&&r!==document.body;)r instanceof HTMLElement&&(t+=r.scrollLeft,e+=r.scrollTop),r=Jt(r);return{x:t,y:e}}function Jt(i){if(i.parentElement)return i.parentElement;const t=i.getRootNode();return t instanceof ShadowRoot?t.host:null}function Tt(i){const t=j(i);return{x:t.x+window.scrollX,y:t.y+window.scrollY}}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 gt="#059669",C={color:"var(--mtb-brand-primary)",width:"3.5",linecap:"round",linejoin:"round",filter:"drop-shadow(0 0 1px rgba(255, 255, 255, 0.95)) drop-shadow(0 1px 2px rgba(15, 23, 42, 0.72))"};class Ge{constructor(t){this.currentPath=null,this.currentPoints=[],this.currentAnchor=Ze(),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.currentAnchor=Je(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",st(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:st(this.currentPoints),points:this.currentPoints,anchor:this.currentAnchor}),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,anchor:t.anchor}),!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,anchor:t.anchor}),!0}canUndo(){return this.committed.length>0}canRedo(){return this.redoStack.length>0}hasStrokes(){return this.committed.length>0}getAnnotation(){const[t]=this.committed;if(!t)return null;const e=this.committed.map(s=>Qe(s.points,{x:s.anchor.offset.x-t.anchor.offset.x,y:s.anchor.offset.y-t.anchor.offset.y})),[r,n]=ti(e.flat());return{type:"draw",x:r,y:n,drawPath:e.map(st).join(" "),captureOffsetX:t.anchor.offset.x,captureOffsetY:t.anchor.offset.y}}viewportDrift(){const[t]=this.committed;return t?{x:window.scrollX-t.anchor.pageScroll.x,y:window.scrollY-t.anchor.pageScroll.y}:{x:0,y:0}}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",C.color),t.setAttribute("stroke-width",C.width),t.setAttribute("stroke-linecap",C.linecap),t.setAttribute("stroke-linejoin",C.linejoin),t.setAttribute("style",`filter:${C.filter}`),t}}function st(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(){return{offset:{x:0,y:0},pageScroll:{x:0,y:0}}}function Je(i,t){const e={x:window.scrollX,y:window.scrollY},r=j(Y(i,t));return{offset:{x:r.x+e.x,y:r.y+e.y},pageScroll:e}}function Qe(i,t){return t.x===0&&t.y===0?i:i.map(([e,r])=>[e+t.x,r+t.y])}function ti(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 it="rr-block",z="rr-mask",ei=`.${it}, .${z}`;function rt(i){return i.closest(ei)!==null}function yt(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 Qt(i){return i.tagName.toLowerCase()}const ii=10;function _t(i){return rt(i)?{name:yt(i),text:"",selector:Qt(i)}:{name:ft(i),text:i.textContent?.trim().slice(0,200)??"",selector:Zt(i)}}class ri{constructor(t,e,r){this.messages=e,this.handlers=r,this.interactionActive=!0,this.pendingHighlightFrame=null,this.lastMoveX=0,this.lastMoveY=0,this.touch=y(),this.highlighter=new qe(t),this.pinMarker=new Xe(t),this.drawLayer=new Ge(t),this.overlay=new je(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=Y(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()>=ii){this.drawLayer.commitStroke(),this.highlighter.hide(),this.handlers.onDrawStroke();return}if(this.drawLayer.cancelCurrentDraw(),this.touch||this.drawLayer.hasStrokes()||!t)return;const e=Y(t.clientX,t.clientY),r=e?_t(e):null,n=r?.name??this.messages.annotation.element,s=e?.getBoundingClientRect(),o=Tt(e),a={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,captureOffsetX:o.x,captureOffsetY:o.y};this.pinMarker.addPin(t.clientX,t.clientY),this.highlighter.select(),this.handlers.onPin(a,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=this.drawLayer.viewportDrift(),r=Y(t.x-e.x,t.y-e.y);if(!r)return t;const n=r.getBoundingClientRect(),s=Tt(r),o=s.x-(t.captureOffsetX??0),a=s.y-(t.captureOffsetY??0),c=_t(r);return{...t,targetSelector:c.selector,targetText:c.text,targetName:c.name,targetRect:{top:n.top+a,left:n.left+o,width:n.width,height:n.height,bottom:n.bottom+a}}}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()}}const ni=140;class si{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()},ni)}}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 oi=480;function ai(){return window.innerWidth<=oi}class vt{constructor(t){this.el=t,this.inset=new si}apply(){return ai()?(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 li{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 vt(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()),e.onActivity&&this.input.addEventListener("input",e.onActivity),this.input.addEventListener("keydown",r=>{$(r)||r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),this.submit())}),this.input.focus({preventScroll:!0})}buildHTML(t){return`
|
|
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||Oe}destroy(){document.removeEventListener("pointermove",this.handlePointerMove),this.stopTouchHintDismissListening(),this.host.removeAttribute("data-mtb-toolbar"),this.hintBarEl.remove(),this.el.remove()}}class je{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 qe{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=ft(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()}}function We(i,t,e){return{left:i.left,top:i.top,scaleX:t/i.width,scaleY:e/i.height}}function X(i,t){return(t-i.left)*i.scaleX}function G(i,t){return(t-i.top)*i.scaleY}function Ye(i,t){return{left:X(i,t.left),top:G(i,t.top),width:t.width*i.scaleX,height:t.height*i.scaleY}}function Ve(){return{left:0,top:0,width:window.innerWidth,height:window.innerHeight}}function Ke(i,t){return{x:i.x-t.x,y:i.y-t.y}}function j(i){let t=0,e=0,r=i;for(;r&&r!==document.body;)r instanceof HTMLElement&&(t+=r.scrollLeft,e+=r.scrollTop),r=Zt(r);return{x:t,y:e}}function Zt(i){if(i.parentElement)return i.parentElement;const t=i.getRootNode();return t instanceof ShadowRoot?t.host:null}function Et(i){const t=j(i);return{x:t.x+window.scrollX,y:t.y+window.scrollY}}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 Jt="#059669",C={color:"var(--mtb-brand-primary)",width:"3.5",linecap:"round",linejoin:"round",filter:"drop-shadow(0 0 1px rgba(255, 255, 255, 0.95)) drop-shadow(0 1px 2px rgba(15, 23, 42, 0.72))"};class Ge{constructor(t){this.currentPath=null,this.currentPoints=[],this.currentAnchor=Ze(),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.currentAnchor=Je(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",st(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:st(this.currentPoints),points:this.currentPoints,anchor:this.currentAnchor}),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,anchor:t.anchor}),!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,anchor:t.anchor}),!0}canUndo(){return this.committed.length>0}canRedo(){return this.redoStack.length>0}hasStrokes(){return this.committed.length>0}getAnnotation(){const[t]=this.committed;if(!t)return null;const e=this.committed.map(s=>Qe(s.points,{x:s.anchor.offset.x-t.anchor.offset.x,y:s.anchor.offset.y-t.anchor.offset.y})),[r,n]=ti(e.flat());return{type:"draw",x:r,y:n,drawPath:e.map(st).join(" "),captureOffsetX:t.anchor.offset.x,captureOffsetY:t.anchor.offset.y}}viewportDrift(){const[t]=this.committed;return t?{x:window.scrollX-t.anchor.pageScroll.x,y:window.scrollY-t.anchor.pageScroll.y}:{x:0,y:0}}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",C.color),t.setAttribute("stroke-width",C.width),t.setAttribute("stroke-linecap",C.linecap),t.setAttribute("stroke-linejoin",C.linejoin),t.setAttribute("style",`filter:${C.filter}`),t}}function st(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(){return{offset:{x:0,y:0},pageScroll:{x:0,y:0}}}function Je(i,t){const e={x:window.scrollX,y:window.scrollY},r=j(Y(i,t));return{offset:{x:r.x+e.x,y:r.y+e.y},pageScroll:e}}function Qe(i,t){return t.x===0&&t.y===0?i:i.map(([e,r])=>[e+t.x,r+t.y])}function ti(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 it="rr-block",z="rr-mask",ei=`.${it}, .${z}`;function rt(i){return i.closest(ei)!==null}function gt(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 Qt(i){return i.tagName.toLowerCase()}const ii=10;function Tt(i){return rt(i)?{name:gt(i),text:"",selector:Qt(i)}:{name:ft(i),text:i.textContent?.trim().slice(0,200)??"",selector:Gt(i)}}class ri{constructor(t,e,r){this.messages=e,this.handlers=r,this.interactionActive=!0,this.pendingHighlightFrame=null,this.lastMoveX=0,this.lastMoveY=0,this.touch=y(),this.highlighter=new qe(t),this.pinMarker=new Xe(t),this.drawLayer=new Ge(t),this.overlay=new je(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=Y(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()>=ii){this.drawLayer.commitStroke(),this.highlighter.hide(),this.handlers.onDrawStroke();return}if(this.drawLayer.cancelCurrentDraw(),this.touch||this.drawLayer.hasStrokes()||!t)return;const e=Y(t.clientX,t.clientY),r=e?Tt(e):null,n=r?.name??this.messages.annotation.element,s=e?.getBoundingClientRect(),o=Et(e),a={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,captureOffsetX:o.x,captureOffsetY:o.y};this.pinMarker.addPin(t.clientX,t.clientY),this.highlighter.select(),this.handlers.onPin(a,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=this.drawLayer.viewportDrift(),r=Y(t.x-e.x,t.y-e.y);if(!r)return t;const n=r.getBoundingClientRect(),s=Et(r),o=s.x-(t.captureOffsetX??0),a=s.y-(t.captureOffsetY??0),c=Tt(r);return{...t,targetSelector:c.selector,targetText:c.text,targetName:c.name,targetRect:{top:n.top+a,left:n.left+o,width:n.width,height:n.height,bottom:n.bottom+a}}}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()}}const ni=140;class si{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()},ni)}}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 oi=480;function ai(){return window.innerWidth<=oi}class yt{constructor(t){this.el=t,this.inset=new si}apply(){return ai()?(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 li{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 yt(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()),e.onActivity&&this.input.addEventListener("input",e.onActivity),this.input.addEventListener("keydown",r=>{$(r)||r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),this.submit())}),this.input.focus({preventScroll:!0})}buildHTML(t){return`
|
|
24
24
|
<input class="mtb-draw-input" type="text" placeholder="${l(t.draw.note_placeholder)}" />
|
|
25
25
|
<button class="mtb-draw-icon-btn mtb-draw-undo" type="button" title="${l(t.draw.undo)}" aria-label="${l(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>
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
<span class="mtb-draw-sep"></span>
|
|
35
35
|
<button class="mtb-draw-cancel" type="button">${l(t.draw.cancel)}</button>
|
|
36
36
|
<button class="mtb-draw-submit" type="button">${l(t.draw.submit)}</button>
|
|
37
|
-
`}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()}}const O=12,ut=32;function te(i){const t=window.innerWidth,e=window.innerHeight;return{vw:t,vh:e,minLeft:O+(i==="left"?ut:0),maxRight:t-O-(i==="right"?ut:0)}}function ee(i,t){return Math.min(i,t.vw-2*O-ut)}function ci(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)}}const di=["button:not([disabled])","input:not([disabled])","textarea:not([disabled])","select:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");function
|
|
37
|
+
`}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()}}const O=12,ut=32;function te(i){const t=window.innerWidth,e=window.innerHeight;return{vw:t,vh:e,minLeft:O+(i==="left"?ut:0),maxRight:t-O-(i==="right"?ut:0)}}function ee(i,t){return Math.min(i,t.vw-2*O-ut)}function ci(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)}}const di=["button:not([disabled])","input:not([disabled])","textarea:not([disabled])","select:not([disabled])","a[href]",'[tabindex]:not([tabindex="-1"])'].join(", ");function vt(i){const t=document.activeElement instanceof HTMLElement?document.activeElement:null,e=r=>{if(r.key!=="Tab")return;const n=Array.from(i.querySelectorAll(di)).filter(d=>!d.hidden);if(n.length===0)return;const s=n[0],o=n[n.length-1],c=i.getRootNode().activeElement??document.activeElement;r.shiftKey?(c===s||!i.contains(c))&&(r.preventDefault(),o.focus({preventScroll:!0})):(c===o||!i.contains(c))&&(r.preventDefault(),s.focus({preventScroll:!0}))};return i.addEventListener("keydown",e),{release(){i.removeEventListener("keydown",e)},restoreFocus(){t?.isConnected&&t.focus({preventScroll:!0})}}}class _t{constructor(t,e){if(this.releaseGuard=null,this.selectedQuickOption=null,this.onSubmit=e.onSubmit,this.onClose=e.onClose,this.onActivity=e.onActivity,this.submitLabel=e.messages.popup.submit,this.messages=e.messages,this.el=t.el("div","mtb-popup"),this.el.setAttribute("role","dialog"),this.el.setAttribute("aria-modal","true"),this.el.setAttribute("aria-label",`${e.messages.popup.about} "${e.targetName}"`),this.el.innerHTML=this.buildHTML(e),t.append(this.el),this.focusTrap=vt(this.el),this.sheet=new yt(this.el),y()&&(this.releaseGuard=ci(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.onScreenshotToggle){const r=this.el.querySelector(".mtb-screenshot-opt input");r.addEventListener("change",()=>e.onScreenshotToggle(r.checked))}e.onMyFeedback&&this.el.querySelector(".mtb-my-feedback").addEventListener("click",e.onMyFeedback),y()||this.textarea.focus({preventScroll:!0})}buildHTML(t){const e=t.messages,r=e.popup.quickOptions.map(n=>`
|
|
38
38
|
<button class="mtb-quick-option" data-quick="${l(n.label)}">
|
|
39
39
|
<span class="mtb-quick-option-emoji">${l(n.emoji)}</span>
|
|
40
40
|
<span>${l(n.label)}</span>
|
|
@@ -78,11 +78,11 @@
|
|
|
78
78
|
<label class="mtb-screenshot-opt mtb-screenshot-opt--locked" title="${l(e.popup.screenshot_locked_hint)}">
|
|
79
79
|
<input type="checkbox" checked disabled>
|
|
80
80
|
<span>${l(e.popup.screenshot_label)}</span>
|
|
81
|
-
</label>`}positionPopup(t,e,r,n){if(this.sheet.apply())return;const s=te(n),{vw:o,vh:a,minLeft:c,maxRight:d}=s,h=O,u=8,b=ee(320,s),p=this.el.offsetHeight||260;let g,f;const Se=r&&r.width<o*.6&&r.height<a*.6;r&&Se?(g=r.left,f=r.bottom+u,f+p>a-h&&(f=r.top-p-u),f<h&&(f=Math.min(r.bottom+u,a-p-h))):(g=t+12,f=e+12),g+b>d&&(g=d-b),g<c&&(g=c),f<h&&(f=h),this.el.style.left=`${g}px`,this.el.style.top=`${f}px`,this.el.style.maxHeight=`${a-f-h}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.onActivity?.()}),this.textarea.addEventListener("keydown",e=>{$(e)||e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.submit(e))}),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(t){const e=this.textarea.value.trim();if(!e)return;const r=this.selectedQuickOption?`[${this.selectedQuickOption}] ${e}`:e;t?this.onSubmit(r,t):this.onSubmit(r)}releaseElement(){return this.releaseGuard?.(),this.releaseGuard=null,this.sheet.release(),this.focusTrap.release(),this.el}destroy(){this.releaseGuard?.(),this.releaseGuard=null,this.sheet.release(),this.focusTrap.release(),this.el.remove(),this.focusTrap.restoreFocus()}}const m="[Filtered]",hi=/-----BEGIN ((?:[A-Z0-9]+ )*PRIVATE KEY)-----[\s\S]*?-----END \1-----/g,ui=/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g,bi=[/\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],mi=/\b(?:\d[ -]?){12,18}\d\b/g,pi=/\bhttps?:\/\/[^\s<>"']+/gi,fi=new Set(["type","autocomplete","name","id","aria_label","placeholder"]),gi=new Set(["value","content"]),yi=new Set(["password","hidden","file"]),vi=new Set(["current_password","new_password","one_time_code","cc_number","cc_csc","cc_exp","cc_exp_month","cc_exp_year"]),wi=/(?:^|_)(?: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 _(i){let t=i.replace(hi,m).replace(ui,m);for(const e of bi)t=t.replace(e,m);return t=t.replace(mi,e=>xi(e)?m:e),t.replace(pi,e=>U(e)||m)}function U(i){try{const t=new URL(i);return`${t.origin}${t.pathname}`}catch{return""}}function Z(i,t){if(t&&ie(t)&&i!=null)return m;if(typeof i=="string")return _(i);if(Array.isArray(i))return i.map(e=>Z(e));if(i&&typeof i=="object"){const e=re(i);return Object.fromEntries(Object.entries(i).map(([n,s])=>{const o=e&&gi.has(I(n))&&s!=null?m:Z(s,n);return[_(n),o]}))}return i}function ie(i){return wi.test(I(i))}function re(i){return Object.entries(i).some(([t,e])=>{if(typeof e!="string")return!1;const r=I(t);return fi.has(r)?r==="type"?yi.has(I(e)):r==="autocomplete"?e.split(/\s+/).some(n=>vi.has(I(n))):ie(e):!1})}function I(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 xi(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}class ne extends Error{constructor(t){super(`HTTP ${t}`),this.name="ApiError",this.status=t}}function ki(i){return i instanceof ne&&i.status===409}const Si=25e3,Ei="https://makethisbetter.dev/api/v1",Ti="sensitive-data-v1";class _i{constructor(t){this.projectKey=t.projectKey,this.apiUrl=(t.apiUrl??Ei).replace(/\/$/,""),this.retryDelayMs=t.retryDelayMs??1e3,this.userToken=t.userToken,this.userTokenFn=t.userTokenFn}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=Li(),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 c=JSON.stringify(t.recording_events),d=new Blob([c],{type:"application/json"});n.append("feedback[recording]",d,"interaction-replay.json"),n.append("feedback[recording_duration]",String(t.recording_duration??0))}if(e){const c=e.type==="image/jpeg"?"jpg":"png";n.append("feedback[screenshot]",e,`screenshot.${c}`)}const s=await this.authHeaders();return s["X-Submission-Token"]=r,s["X-MTB-Capture-Policy"]=Ti,s["X-Idempotency-Key"]=Ai(),{...(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=_(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 Ci(o.body,r)}async finalizeSubmissionSession(t,e){const r=await this.submissionHeaders(e),n=new AbortController,s=setTimeout(()=>n.abort(),Si);try{return(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/feedback`,{method:"POST",headers:r,signal:n.signal})).json()).feedback}finally{clearTimeout(s)}}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&&!e.signal?.aborted)return await
|
|
81
|
+
</label>`}positionPopup(t,e,r,n){if(this.sheet.apply())return;const s=te(n),{vw:o,vh:a,minLeft:c,maxRight:d}=s,h=O,u=8,b=ee(320,s),p=this.el.offsetHeight||260;let g,f;const Se=r&&r.width<o*.6&&r.height<a*.6;r&&Se?(g=r.left,f=r.bottom+u,f+p>a-h&&(f=r.top-p-u),f<h&&(f=Math.min(r.bottom+u,a-p-h))):(g=t+12,f=e+12),g+b>d&&(g=d-b),g<c&&(g=c),f<h&&(f=h),this.el.style.left=`${g}px`,this.el.style.top=`${f}px`,this.el.style.maxHeight=`${a-f-h}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.onActivity?.()}),this.textarea.addEventListener("keydown",e=>{$(e)||e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this.submit(e))}),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(t){const e=this.textarea.value.trim();if(!e)return;const r=this.selectedQuickOption?`[${this.selectedQuickOption}] ${e}`:e;t?this.onSubmit(r,t):this.onSubmit(r)}releaseElement(){return this.releaseGuard?.(),this.releaseGuard=null,this.sheet.release(),this.focusTrap.release(),this.el}destroy(){this.releaseGuard?.(),this.releaseGuard=null,this.sheet.release(),this.focusTrap.release(),this.el.remove(),this.focusTrap.restoreFocus()}}const m="[Filtered]",hi=/-----BEGIN ((?:[A-Z0-9]+ )*PRIVATE KEY)-----[\s\S]*?-----END \1-----/g,ui=/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g,bi=[/\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],mi=/\b(?:\d[ -]?){12,18}\d\b/g,pi=/\bhttps?:\/\/[^\s<>"']+/gi,fi=new Set(["type","autocomplete","name","id","aria_label","placeholder"]),gi=new Set(["value","content"]),yi=new Set(["password","hidden","file"]),vi=new Set(["current_password","new_password","one_time_code","cc_number","cc_csc","cc_exp","cc_exp_month","cc_exp_year"]),wi=/(?:^|_)(?: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 _(i){let t=i.replace(hi,m).replace(ui,m);for(const e of bi)t=t.replace(e,m);return t=t.replace(mi,e=>xi(e)?m:e),t.replace(pi,e=>U(e)||m)}function U(i){try{const t=new URL(i);return`${t.origin}${t.pathname}`}catch{return""}}function Z(i,t){if(t&&ie(t)&&i!=null)return m;if(typeof i=="string")return _(i);if(Array.isArray(i))return i.map(e=>Z(e));if(i&&typeof i=="object"){const e=re(i);return Object.fromEntries(Object.entries(i).map(([n,s])=>{const o=e&&gi.has(I(n))&&s!=null?m:Z(s,n);return[_(n),o]}))}return i}function ie(i){return wi.test(I(i))}function re(i){return Object.entries(i).some(([t,e])=>{if(typeof e!="string")return!1;const r=I(t);return fi.has(r)?r==="type"?yi.has(I(e)):r==="autocomplete"?e.split(/\s+/).some(n=>vi.has(I(n))):ie(e):!1})}function I(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 xi(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}class ne extends Error{constructor(t){super(`HTTP ${t}`),this.name="ApiError",this.status=t}}function ki(i){return i instanceof ne&&i.status===409}const Si=25e3,Ei="https://makethisbetter.dev/api/v1",Ti="sensitive-data-v1";class _i{constructor(t){this.projectKey=t.projectKey,this.apiUrl=(t.apiUrl??Ei).replace(/\/$/,""),this.retryDelayMs=t.retryDelayMs??1e3,this.userToken=t.userToken,this.userTokenFn=t.userTokenFn}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=Li(),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 c=JSON.stringify(t.recording_events),d=new Blob([c],{type:"application/json"});n.append("feedback[recording]",d,"interaction-replay.json"),n.append("feedback[recording_duration]",String(t.recording_duration??0))}if(e){const c=e.type==="image/jpeg"?"jpg":"png";n.append("feedback[screenshot]",e,`screenshot.${c}`)}const s=await this.authHeaders();return s["X-Submission-Token"]=r,s["X-MTB-Capture-Policy"]=Ti,s["X-Idempotency-Key"]=Ai(),{...(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=_(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 Ci(o.body,r)}async finalizeSubmissionSession(t,e){const r=await this.submissionHeaders(e),n=new AbortController,s=setTimeout(()=>n.abort(),Si);try{return(await(await this.fetchWithRetry(`${this.apiUrl}/widget/feedback_submission_sessions/${t}/feedback`,{method:"POST",headers:r,signal:n.signal})).json()).feedback}finally{clearTimeout(s)}}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&&!e.signal?.aborted)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 ne(n.status)}}function Ct(i){return i<=0?Promise.resolve():new Promise(t=>setTimeout(t,i))}async function Ci(i,t){const e=i.getReader(),r=new TextDecoder;let n="",s=null;const o=a=>{const c=a.split(`
|
|
82
82
|
`).find(b=>b.startsWith("event:")),d=a.split(`
|
|
83
83
|
`).find(b=>b.startsWith("data:"));if(!d)return;const h=c?.slice(6).trim(),u=JSON.parse(d.slice(5).trim());h==="delta"&&typeof u.text=="string"?t(u.text):h==="done"&&(s={messages:Array.isArray(u.messages)?u.messages:[],done:u.done!==!1,failed:u.error===!0})};for(;;){const{done:a,value:c}=await e.read();if(a)break;n+=r.decode(c,{stream:!0});let d;for(;(d=n.indexOf(`
|
|
84
84
|
|
|
85
|
-
`))!==-1;){const h=n.slice(0,d);n=n.slice(d+2);try{o(h)}catch{}}}if(n+=r.decode(),n.trim())try{o(n)}catch{}if(!s)throw new Error("clarify stream ended before done");return s}function Ai(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function Li(){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 Pi=2e3,Mi=45e3,
|
|
85
|
+
`))!==-1;){const h=n.slice(0,d);n=n.slice(d+2);try{o(h)}catch{}}}if(n+=r.decode(),n.trim())try{o(n)}catch{}if(!s)throw new Error("clarify stream ended before done");return s}function Ai(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function Li(){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 Pi=2e3,Mi=45e3,At=12e3,Ii={"adopting-session":["conversing","submission-failed","finalizing"],"submission-failed":["adopting-session"],conversing:["adopting-session","answering","settled","clarify-failed","finalizing"],answering:["conversing","settled","clarify-failed","finalizing"],retrying:["conversing","settled","clarify-failed","finalizing"],"clarify-failed":["retrying","finalizing"],settled:["finalizing","unrecoverable"],finalizing:["settled"],unrecoverable:[]};class Ri{constructor(t,e){this.host=e,this.state="conversing",this.destroyed=!1,this.lastMessages=[],this.pollTimer=null,this.pollDeadline=0,this.streamAbort=null,this.submissionSessionId=t.submissionSessionId??"",this.submissionToken=t.submissionToken??"",this.apiClient=t.apiClient,this.onFinalize=t.onFinalize,this.onSkip=t.onSkip,this.onCancel=t.onCancel,this.pendingSession=t.pendingSession,this.onRetrySubmission=t.onRetrySubmission}setState(t){if(!Ii[this.state].includes(t))throw new Error(`Illegal clarify transition: ${this.state} -> ${t}`);this.state=t}hasSettled(){return this.state==="clarify-failed"||this.state==="settled"||this.state==="finalizing"||this.state==="unrecoverable"}isRequestInFlight(){return this.state==="answering"||this.state==="retrying"}abandoned(){return this.destroyed||this.state==="finalizing"}gone(){return this.destroyed}async start(){if(this.host.showThinking(),this.pendingSession){this.setState("adopting-session"),this.host.setInputDisabled(!0),await this.adoptSession(this.pendingSession);return}await this.runInitialTurn()}async adoptSession(t){let e;try{e=await t}catch{e=null}if(!this.gone()){if(!e){this.showSubmissionFailure();return}if(this.submissionSessionId=e.id,this.submissionToken=e.token,this.state!=="finalizing"){if(this.setState("conversing"),this.host.setInputDisabled(!1),!e.ai_clarify_available){this.applyResult({messages:[],done:!0});return}await this.runInitialTurn()}}}showSubmissionFailure(){this.setState("submission-failed"),this.stopPolling(),this.host.removeThinking(),this.host.renderSubmissionFailureFooter()}async retrySubmission(){!this.onRetrySubmission||this.isRequestInFlight()||this.gone()||(this.setState("adopting-session"),this.host.showConversationControls(),this.host.setInputDisabled(!0),this.host.showThinking(),await this.adoptSession(this.onRetrySubmission()))}async sendAnswer(t){if(!(!t||this.isRequestInFlight()||!this.submissionSessionId)){this.setState("answering"),this.host.onAnswerTurnStarted(t),this.stopPolling();try{await this.runAnswerTurn(t)}catch{if(this.gone())return;this.setState("conversing"),this.host.onAnswerTurnFailed(this.lastMessages,t)}}}async runInitialTurn(){const t=new AbortController;this.streamAbort=t;let e=setTimeout(()=>t.abort(),At);try{const r=await this.apiClient.streamClarification(this.submissionSessionId,this.submissionToken,n=>{clearTimeout(e),e=setTimeout(()=>t.abort(),At),this.host.appendStreamDelta(n)},t.signal);if(this.abandoned())return;this.host.endStreamingBubble(),this.applyResult(r)||this.startPolling()}catch{if(this.abandoned())return;this.host.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.abandoned())return;this.applyResult(t)||this.startPolling()}catch{if(this.abandoned())return;this.handleFailure()}}async runAnswerTurn(t){const e=await this.apiClient.startClarification(this.submissionSessionId,this.submissionToken,t);this.gone()||this.applyFinalSubmissionResult(e)||this.startPolling()}startPolling(){this.stopPolling(),this.pollDeadline=Date.now()+Mi,this.pollTimer=setInterval(()=>this.poll(),Pi)}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.gone())return;(this.state==="answering"?this.applyFinalSubmissionResult(t):this.applyResult(t))&&this.stopPolling()}catch{if(this.gone())return;this.stopPolling(),this.handleFailure()}}handleDone(t){if(!this.hasSettled()){if(this.setState("settled"),this.stopPolling(),this.host.removeThinking(),t){this.finalize();return}this.host.renderFinalizeButton()}}handleFailure(){this.hasSettled()||(this.setState("clarify-failed"),this.stopPolling(),this.host.removeThinking(),this.host.renderClarifyFailureFooter())}async retryClarification(){if(!(this.isRequestInFlight()||this.gone())){this.setState("retrying"),this.host.onRetryStarted(this.lastMessages);try{const t=await this.apiClient.getClarification(this.submissionSessionId,this.submissionToken);if(this.gone())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.gone())return;this.applyResult(e)||(this.host.showConversationControls(),this.startPolling())}catch{if(this.gone())return;this.handleFailure()}finally{this.state==="retrying"&&this.setState("conversing")}}}applyFinalSubmissionResult(t){return t.status==="failed"?(this.handleFailure(),!0):t.done?(this.handleDone(!0),!0):!1}applyResult(t){this.lastMessages=t.messages,this.host.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.host.removeThinking(),this.host.enableInput(),!0):!1}async finalize(){if(!(this.state==="finalizing"||this.state==="unrecoverable"||this.gone())){this.setState("finalizing"),this.host.onFinalizeStarted();try{await this.onFinalize()}catch(t){if(this.gone())return;if(this.setState("settled"),this.host.clearError(),ki(t)){this.showUnrecoverable();return}this.host.renderFinalizeRetryFooter()}}}showUnrecoverable(){this.setState("unrecoverable"),this.stopPolling(),this.host.renderUnrecoverableFooter()}skip(){if(this.state==="submission-failed"){this.onCancel?.();return}this.onSkip?.(),this.finalize(),this.host.dismiss()}close(){if(this.state==="finalizing"){this.onSkip?.(),this.host.dismiss();return}this.onCancel?.(),this.host.dismiss()}dispose(){this.destroyed=!0,this.streamAbort?.abort(),this.streamAbort=null,this.stopPolling()}}const Di=346,Fi=270;class Hi{constructor(t,e){this.streamingBubble=null,this.handleKeydown=n=>{if(n===this.initiatingKeydown){this.initiatingKeydown=void 0;return}$(n)||n.key!=="Enter"||n.shiftKey||n.composedPath().includes(this.inputEl)||(n.preventDefault(),this.session.skip())},this.initiatingKeydown=e.initiatingKeydown,this.i18n=e.messages;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.setAttribute("role","dialog"),this.el.setAttribute("aria-modal","true"),this.el.setAttribute("aria-label",e.messages.clarify.title),this.el.innerHTML=this.buildHTML(e.messages),this.sheet=new yt(this.el),r?this.sheet.apply():(t.append(this.el),this.positionCard(e.x,e.y,e.position??"right")),this.focusTrap=vt(this.el),this.messagesEl=this.el.querySelector(".mtb-clarify-messages"),this.session=new Ri({submissionSessionId:e.submissionSessionId,submissionToken:e.submissionToken,pendingSession:e.pendingSession,onRetrySubmission:e.onRetrySubmission,apiClient:e.apiClient,onFinalize:e.onFinalize,onSkip:e.onSkip,onCancel:e.onCancel},this),this.bindEvents(),window.addEventListener("keydown",this.handleKeydown),this.session.start()}positionCard(t,e,r){if(this.sheet.apply())return;const n=te(r),{vw:s,vh:o,minLeft:a,maxRight:c}=n,d=O,h=ee(Di,n),u=this.el.offsetHeight||Fi;if(t===void 0||e===void 0){const g=Math.max(a,(s-h)/2);this.el.style.left=`${Math.min(g,c-h)}px`,this.el.style.top=`${Math.max(d,(o-u)/2)}px`,this.el.style.maxHeight=`${o-2*d}px`;return}let b=t+12,p=e+12;b+h>c&&(b=t-h-12),b+h>c&&(b=c-h),b<a&&(b=a),p+u>o-d&&(p=o-u-d),p<d&&(p=d),this.el.style.left=`${b}px`,this.el.style.top=`${p}px`,this.el.style.maxHeight=`${o-p-d}px`}buildHTML(t){return`
|
|
86
86
|
<div class="mtb-clarify-header">
|
|
87
87
|
<span class="mtb-clarify-icon">
|
|
88
88
|
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="var(--mtb-brand-on-primary)" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round">
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
</svg>
|
|
130
130
|
<span>${l(this.i18n.clarify.send_feedback)}</span>
|
|
131
131
|
</button>
|
|
132
|
-
`,bind:t=>{t.querySelector(".mtb-clarify-send-feedback").addEventListener("click",()=>{this.session.finalize()})}})}renderFinalizeRetryFooter(){this.renderFooter({error:this.i18n.error.submit,controls:`<button class="mtb-clarify-send-feedback mtb-clarify-retry" type="button">${l(this.i18n.clarify.retry)}</button>`,bind:t=>{t.querySelector(".mtb-clarify-retry").addEventListener("click",()=>{this.session.finalize()})}})}renderUnrecoverableFooter(){this.renderFooter({error:this.i18n.clarify.expired})}showConversationControls(){this.renderFooter({controls:this.buildConversationControls(this.i18n),bind:()=>this.bindConversationControls()})}enableInput(){this.el.contains(this.inputEl)||this.showConversationControls(),this.inputEl.disabled=!1,this.sendBtn.disabled=!this.inputEl.value.trim()}clearError(){this.el.querySelector(".mtb-clarify-error")?.remove()}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)}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}renderFooter(t){const e=this.el.querySelector(".mtb-clarify-footer"),r=t.error?`<div class="mtb-clarify-error">${l(t.error)}</div>`:"";e.innerHTML=`${r}${t.controls??""}`,t.bind?.(e)}renderConversation(t,e){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()}dismiss(){this.destroy()}destroy(){this.session.dispose(),window.removeEventListener("keydown",this.handleKeydown),this.sheet.release(),this.focusTrap.release(),this.el.remove(),this.focusTrap.restoreFocus()}}const
|
|
132
|
+
`,bind:t=>{t.querySelector(".mtb-clarify-send-feedback").addEventListener("click",()=>{this.session.finalize()})}})}renderFinalizeRetryFooter(){this.renderFooter({error:this.i18n.error.submit,controls:`<button class="mtb-clarify-send-feedback mtb-clarify-retry" type="button">${l(this.i18n.clarify.retry)}</button>`,bind:t=>{t.querySelector(".mtb-clarify-retry").addEventListener("click",()=>{this.session.finalize()})}})}renderUnrecoverableFooter(){this.renderFooter({error:this.i18n.clarify.expired})}showConversationControls(){this.renderFooter({controls:this.buildConversationControls(this.i18n),bind:()=>this.bindConversationControls()})}enableInput(){this.el.contains(this.inputEl)||this.showConversationControls(),this.inputEl.disabled=!1,this.sendBtn.disabled=!this.inputEl.value.trim()}clearError(){this.el.querySelector(".mtb-clarify-error")?.remove()}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)}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}renderFooter(t){const e=this.el.querySelector(".mtb-clarify-footer"),r=t.error?`<div class="mtb-clarify-error">${l(t.error)}</div>`:"";e.innerHTML=`${r}${t.controls??""}`,t.bind?.(e)}renderConversation(t,e){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()}dismiss(){this.destroy()}destroy(){this.session.dispose(),window.removeEventListener("keydown",this.handleKeydown),this.sheet.release(),this.focusTrap.release(),this.el.remove(),this.focusTrap.restoreFocus()}}const Lt=5e3,Bi=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;class Ni{constructor(t,e,r,n,s){this.autoCloseTimer=null,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;this.el.setAttribute("role","dialog"),this.el.setAttribute("aria-modal","true"),this.el.setAttribute("aria-label",o);const c=n?`<button class="mtb-view-feedback-link">${l(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?`
|
|
133
133
|
<div class="mtb-email-capture">
|
|
134
134
|
<div class="mtb-email-prompt">${l(e.success.email_prompt)}</div>
|
|
135
135
|
<div class="mtb-email-row">
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
<div class="mtb-email-error" hidden>${l(e.success.email_error)}</div>
|
|
140
140
|
</div>`:"";this.el.innerHTML=`
|
|
141
141
|
<div class="mtb-success-icon">
|
|
142
|
-
<svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="
|
|
142
|
+
<svg width="23" height="23" viewBox="0 0 24 24" fill="none" stroke="var(--mtb-brand-primary)" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">
|
|
143
143
|
<polyline points="20 6 9 17 4 12"/>
|
|
144
144
|
</svg>
|
|
145
145
|
</div>
|
|
@@ -148,7 +148,7 @@
|
|
|
148
148
|
${d}
|
|
149
149
|
${c}
|
|
150
150
|
<button class="mtb-close-link">${l(e.success.close)}</button>
|
|
151
|
-
`,t.append(this.el),this.focusTrap=wt(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,r):this.autoCloseTimer=setTimeout(()=>r(),Pt)}bindEmailCapture(t,e){const r=this.el.querySelector(".mtb-email-input"),n=this.el.querySelector(".mtb-email-submit"),s=this.el.querySelector(".mtb-email-error"),o=async()=>{const a=r.value.trim();if(!Bi.test(a)){r.classList.add("mtb-email-invalid");return}r.classList.remove("mtb-email-invalid"),s.hidden=!0,n.disabled=!0,await t(a)?(this.el.querySelector(".mtb-email-capture").innerHTML=`<div class="mtb-email-saved">${l(this.messages.success.email_saved)}</div>`,this.autoCloseTimer=setTimeout(()=>e(),Pt)):(s.hidden=!1,n.disabled=!1)};n.addEventListener("click",o),r.addEventListener("keydown",a=>{a.key==="Enter"&&o()})}destroy(){this.autoCloseTimer&&(clearTimeout(this.autoCloseTimer),this.autoCloseTimer=null),this.focusTrap.release(),this.el.remove(),this.focusTrap.restoreFocus()}}function se(i){return re({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 J(i,t){return i&&(se(t)?m:_(i))}const $i=512;function oe(){return new WeakMap}function ae(i,t){let e=i.parentElement;for(;e&&e!==document.body&&e!==document.documentElement;){const r=le(e,t);if(r==="sensitive")return!0;if(r==="contains-sensitive-child"||r==="too-large")return!1;e=e.parentElement}return!1}function le(i,t){const e=t.get(i);if(e)return e;const r=i.textContent??"";let n="none";return r.length>$i?n="too-large":_(r)!==r&&(n=Array.from(i.children).some(o=>{const a=le(o,t);return a==="sensitive"||a==="contains-sensitive-child"})?"contains-sensitive-child":"sensitive"),t.set(i,n),n}function zi(i){return new Promise(t=>{const e=new Image;e.onload=()=>t(e),e.onerror=()=>t(null),e.src=i})}function ce(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 Oi(i,t,e){return ce(i).map(r=>r.map(([n,s],o)=>`${o===0?"M":"L"} ${n+t} ${s+e}`).join(" ")).join(" ")}let A=null;function de(){return A||(A=Promise.resolve().then(()=>require("./html-to-image.cjs")).catch(i=>{throw A=null,i}),A)}let ot,at=null;function he(){return ot!==void 0?Promise.resolve(ot):(at??(at=de().then(({getFontEmbedCSS:i})=>i(document.body)).then(i=>(ot=i,i)).catch(()=>{at=null})),at)}const Ui=200;async function Mt(){try{const[{toJpeg:i},t]=await Promise.all([de(),he()]),e=document.body.getBoundingClientRect(),r=Ve(),n={x:window.scrollX,y:window.scrollY},s=Ki(document.body);return{dataUrl:await i(document.body,{quality:.85,width:r.width,height:r.height,pixelRatio:Zi(r),backgroundColor:"#ffffff",skipFonts:!1,skipAutoScale:!1,fontEmbedCSS:t,style:{transform:`translate(${e.left}px, ${e.top}px)`,transformOrigin:"top left"},filter:a=>{if(a instanceof HTMLElement&&a.id===w)return!1;if(!(a instanceof Element))return!0;const c=a.getBoundingClientRect();return c.width===0&&c.height===0?!0:c.top+window.scrollY-n.y<=r.height+Ui}}),metrics:r,redactions:s,pageScroll:n}}catch{return null}}async function ji(i,t=[],e){try{const r=t.map(n=>qi(n,i.pageScroll));return await Vi(i.dataUrl,r,i.metrics,i.redactions,e)}catch{return null}}function qi(i,t){const e=Wi(i,t);return e.x===0&&e.y===0?i:{...i,x:i.x+e.x,y:i.y+e.y,targetRect:i.targetRect&&{...i.targetRect,top:i.targetRect.top+e.y,left:i.targetRect.left+e.x,bottom:i.targetRect.bottom+e.y},drawPath:i.drawPath&&Oi(i.drawPath,e.x,e.y)}}function Wi(i,t){return i.captureOffsetX!==void 0&&i.captureOffsetY!==void 0?Ke({x:i.captureOffsetX,y:i.captureOffsetY},t):j(Yi(i))}function Yi(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}async function Vi(i,t,e,r,n){const s=document.createElement("canvas"),o=s.getContext("2d");if(!o)return null;const a=await zi(i);if(!a)return null;s.width=a.naturalWidth||window.innerWidth,s.height=a.naturalHeight||window.innerHeight,o.drawImage(a,0,0);const c=We(e,s.width,s.height);o.fillStyle="#e5e7eb";for(const d of r){const h=Ye(c,d);o.fillRect(h.left,h.top,h.width,h.height)}for(const d of t)d.type==="draw"&&d.drawPath?Gi(o,d.drawPath,c,n?.primary):d.type==="pin"&&Ji(o,X(c,d.x),G(c,d.y),n);return Qi(s)}function Ki(i){const t=[];for(const s of Xi(i,`.${it}`))lt(t,s.getBoundingClientRect(),It(s));for(const s of i.querySelectorAll("input, textarea, select")){if(Rt(s))continue;const o=s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement?s.value:"",a=s.closest(`.${z}`)!==null,c=se(s)||J(o,s)!==o;!a&&!c||lt(t,s.getBoundingClientRect(),It(s),Ft)}const e=document.createTreeWalker(i,NodeFilter.SHOW_TEXT),r=oe();let n=e.nextNode();for(;n;){const s=n.parentElement,o=n.textContent??"",a=s?.closest(`.${z}`)!==null,c=_(o)!==o||ae(n,r);if(s&&!Rt(s)&&(a||c)){const d=j(s),h=document.createRange();h.selectNodeContents(n);for(const u of Array.from(h.getClientRects()))lt(t,u,d,Ft)}n=e.nextNode()}return t}function It(i){return j(Jt(i))}function Xi(i,t){const e=Array.from(i.querySelectorAll(t));return i.matches(t)?[i,...e]:e}function Rt(i){return i.closest(`#${w}`)!==null||i.closest(`.${it}`)!==null}function lt(i,t,e,r=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.x-r,top:t.top+e.y-r,width:t.width+r*2,height:t.height+r*2})}function Gi(i,t,e,r=gt){i.save(),i.lineCap="round",i.lineJoin="round";for(const n of ce(t))if(n.length!==0){i.beginPath(),i.moveTo(X(e,n[0][0]),G(e,n[0][1]));for(let s=1;s<n.length;s++)i.lineTo(X(e,n[s][0]),G(e,n[s][1]));i.shadowColor="transparent",i.strokeStyle="rgba(15, 23, 42, 0.72)",i.lineWidth=7,i.stroke(),i.strokeStyle="#ffffff",i.lineWidth=5.5,i.stroke(),i.strokeStyle=r,i.lineWidth=3.5,i.stroke()}i.restore()}const Dt=16e6,Ft=2;function Zi(i){const t=i.width*i.height;return!Number.isFinite(t)||t<=Dt?1:Math.sqrt(Dt/t)}function Ji(i,t,e,r){const n=r?.primary??gt;i.save(),i.shadowColor="rgba(15, 23, 42, 0.68)",i.shadowOffsetY=2,i.shadowBlur=8,i.fillStyle=n,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.restore()}function Qi(i){return new Promise(t=>{try{i.toBlob(e=>t(e),"image/jpeg",.85)}catch{t(null)}})}class tr{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:er(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 xt=new tr;function er(i){return!i||typeof i!="object"||!("name"in i)?void 0:String(i.name)||void 0}function ue(i){const t=ir(i.name)||rr(i.message),e=nr(i);return e?`${t} (${e})`:t}function ir(i){return i&&/^[A-Za-z][A-Za-z0-9]*(?:Error|Exception|Rejection)$/.test(i)?i:""}function rr(i){return i.match(/^([A-Za-z][A-Za-z0-9]*(?:Error|Exception))\b/)?.[1]??"Error"}function nr(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 sr=20;class or{constructor(){this.errors=[],this.unsubscribe=null}start(){this.unsubscribe||(this.unsubscribe=xt.subscribe(t=>this.record(t)))}record(t){this.addError(ue(t))}addError(t){this.errors.length>=sr||this.errors.includes(t)||this.errors.push(t)}getErrors(){return[...this.errors]}stop(){this.unsubscribe?.(),this.unsubscribe=null}}const V=new Set;let R=null,D=null,F=null,Q=null,H=null,tt=null;function be(i){V.add(i),ar();let t=!1;return()=>{t||(t=!0,V.delete(i),V.size===0&&lr())}}function ct(i,t){const e={type:i,fromUrl:t,toUrl:location.href};tt=e.toUrl;for(const r of[...V])try{r(e)}catch{}}function ar(){if(F)return;tt=location.href,H=()=>ct("pop",tt??location.href),window.addEventListener("popstate",H),R=history.pushState,D=history.replaceState;const i=R,t=D;F=function(e,r,n){const s=location.href;i.call(history,e,r,n),ct("push",s)},Q=function(e,r,n){const s=location.href;t.call(history,e,r,n),ct("replace",s)},history.pushState=F,history.replaceState=Q}function lr(){H&&(window.removeEventListener("popstate",H),H=null),R&&history.pushState===F&&(history.pushState=R),D&&history.replaceState===Q&&(history.replaceState=D),R=null,D=null,F=null,Q=null,tt=null}const cr=20;function dr(i){return rt(i)?yt(i):ft(i)}function hr(i){return rt(i)?Qt(i):Zt(i)}class ur{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=xt.subscribe(t=>this.recordError(t)),this.unsubscribeNavigation=be(()=>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>cr&&this.breadcrumbs.shift()}handleClick(t){const e=t.target;if(e&&!S(e))try{this.add({type:"ui",category:"ui.click",timestamp:Date.now(),message:dr(e),data:{selector:hr(e)}})}catch{}}handleChange(t){const e=t.target;if(e&&!S(e))try{const r=e,n=rt(e)?yt(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=ue(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=U(t),n=U(e);this.add({type:"navigation",category:"navigation",timestamp:Date.now(),message:`${r} → ${n}`,data:{from:r,to:n}})}}const me="mtb_frustration_state";let bt=null;function et(){try{const i=window.sessionStorage.getItem(me);return K(i?JSON.parse(i):bt)}catch{return K(bt)}}function pe(i){const t=K(i);bt=t;try{window.sessionStorage.setItem(me,JSON.stringify(t))}catch{}}function br(){return et().dismissedByUser}function mr(){pe({...et(),dismissedByUser:!0})}function K(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 pr=4,fr=1500,gr=3,yr=5e3,dt=500,vr=2,wr=3e4,xr=2e3,kr=1e3,Sr=300,Er=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","LABEL","SUMMARY","DETAILS"]),Tr=new Set(["button","link","checkbox","radio","tab","menuitem","option","switch","textbox","combobox","listbox","slider","spinbutton"]),_r=new Set(["A","BUTTON","SUMMARY"]),Cr=new Set(["button","link","tab","menuitem"]),Ht=[/\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/],N=class N{constructor(t){this.clickHistory=[],this.unsubscribeErrors=null,this.active=!1,this.lastInteraction=null,this.cooldownUntil=0,this.navTimestamps=[],this.unsubscribeNavigation=null,this.boundPageLeaveHandler=null,this.boundTurboNavigationHandler=null,this.lastNavigationAt=-1,this.boundSubmitHandler=null,this.boundInvalidHandler=null,this.recentSubmitForms=new WeakSet,this.recentFailedForms=new WeakSet,this.formFailureTimestamps=new WeakMap,this.errorPageUrls=new Set,this.domObserver=null,this.pendingDomChecks=0,this.lastMutationAt=-1,this.pendingTimers=new Set,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=xt.subscribe(()=>{const t=Date.now();if(!this.lastInteraction||t-this.lastInteraction.time>xr)return;const e=this.lastInteraction;this.lastInteraction=null,this.emitIfReady({signal:"dead_click",target:q(e.target),detail:"Uncaught error after interaction",timestamp:t})}),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.lastInteraction=null,this.stopNavigationTracking(),this.stopFormTracking(),this.errorPageUrls.clear(),this.clearPendingTimers(),this.pendingDomChecks=0,this.disconnectDomObserver())}schedule(t,e){const r=setTimeout(()=>{this.pendingTimers.delete(r),t()},e);this.pendingTimers.add(r)}clearPendingTimers(){for(const t of this.pendingTimers)clearTimeout(t);this.pendingTimers.clear()}startNavigationTracking(){this.unsubscribeNavigation=be(t=>this.handleNavigation(t)),this.boundPageLeaveHandler=()=>this.noteNavigationStarted(),window.addEventListener("beforeunload",this.boundPageLeaveHandler),window.addEventListener("pagehide",this.boundPageLeaveHandler),this.boundTurboNavigationHandler=()=>this.noteNavigationStarted(),document.addEventListener("turbo:before-visit",this.boundTurboNavigationHandler),document.addEventListener("turbo:submit-start",this.boundTurboNavigationHandler),document.addEventListener("turbo:before-fetch-request",this.boundTurboNavigationHandler)}stopNavigationTracking(){this.unsubscribeNavigation?.(),this.unsubscribeNavigation=null,this.navTimestamps=[],this.boundPageLeaveHandler&&(window.removeEventListener("beforeunload",this.boundPageLeaveHandler),window.removeEventListener("pagehide",this.boundPageLeaveHandler),this.boundPageLeaveHandler=null),this.boundTurboNavigationHandler&&(document.removeEventListener("turbo:before-visit",this.boundTurboNavigationHandler),document.removeEventListener("turbo:submit-start",this.boundTurboNavigationHandler),document.removeEventListener("turbo:before-fetch-request",this.boundTurboNavigationHandler),this.boundTurboNavigationHandler=null),this.lastNavigationAt=-1}noteNavigationStarted(){this.lastNavigationAt=Date.now()}restoreState(){const t=et();this.navTimestamps=t.navTimestamps,this.cooldownUntil=t.cooldownUntil,this.errorPageUrls=new Set(t.errorPageUrls)}persistState(){const t=et();pe({...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),this.recentSubmitForms=new WeakSet,this.recentFailedForms=new WeakSet}handleClick(t){const e=t.target;if(!e||S(e))return;this.trackFormSubmitIntent(e),this.trackNativeNavigationIntent(t,e);const r=this.interactionTarget(e),n=Date.now();this.lastInteraction={target:r,time:n},this.clickHistory.push({target:r,time:n});const s=n-fr;if(this.clickHistory=this.clickHistory.filter(a=>a.time>s),this.clickHistory.filter(a=>a.target===r).length>=pr){this.clickHistory=[],this.emitHighPriority({signal:"rage_click",target:q(r),timestamp:n});return}this.checkDeadClickDom(r,n)}handleNavigation(t){const e=Date.now();if(this.noteNavigationStarted(),t.type!=="replace"&&t.fromUrl!==t.toUrl&&t.type==="pop"){this.navTimestamps.push(e);const n=e-yr;this.navTimestamps=this.navTimestamps.filter(s=>s>n),this.navTimestamps.length>=gr&&(this.navTimestamps=[],this.emitIfReady({signal:"rapid_navigation",timestamp:e}))}this.persistState(),this.schedule(()=>{this.active&&this.checkErrorPage()},Sr)}handleFormSubmit(t){const e=t.target;e instanceof HTMLFormElement&&(S(e)||(this.rememberSubmitAttempt(e),this.schedule(()=>{this.active&&e.querySelector('[aria-invalid="true"], .is-invalid')&&this.recordFormFailure(e)},dt)))}trackFormSubmitIntent(t){const e=t.closest("button, input");(e instanceof HTMLButtonElement||e instanceof HTMLInputElement)&&(e.type!=="submit"&&e.type!=="image"||!e.form||S(e.form)||this.rememberSubmitAttempt(e.form))}trackNativeNavigationIntent(t,e){e.closest("a[href]")&&queueMicrotask(()=>{this.active&&!t.defaultPrevented&&this.noteNavigationStarted()})}rememberSubmitAttempt(t){this.recentSubmitForms.add(t),this.schedule(()=>{this.recentSubmitForms.delete(t)},dt)}recordFormFailure(t){if(this.recentFailedForms.has(t))return;this.recentFailedForms.add(t),this.schedule(()=>this.recentFailedForms.delete(t),dt);const e=Date.now(),r=e-wr,n=(this.formFailureTimestamps.get(t)??[]).filter(s=>s>r);n.push(e),this.formFailureTimestamps.set(t,n),!(n.length<vr)&&(this.formFailureTimestamps.set(t,[]),this.emitIfReady({signal:"form_failure",target:q(t),timestamp:e}))}handleFormInvalid(t){const e=t.target;if(!e||S(e))return;const r=e.closest("form");!r||!this.recentSubmitForms.has(r)||this.recordFormFailure(r)}checkErrorPage(){const t=location.href;if(this.errorPageUrls.has(t))return;const e=document.title.toLowerCase();if(Ht.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&&Ht.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(),this.schedule(()=>{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:q(t),timestamp:e})},kr))}ensureDomObserver(){this.domObserver||(this.domObserver=new MutationObserver(()=>{this.lastMutationAt=Date.now()}),this.domObserver.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0}))}disconnectDomObserver(){this.domObserver?.disconnect(),this.domObserver=null}looksInteractive(t){if(_r.has(t.tagName)||t.hasAttribute("onclick"))return!0;const e=t.getAttribute("role");if(e&&Cr.has(e)||window.getComputedStyle(t).cursor==="pointer")return!0;if(t.classList)for(const n of t.classList){const s=n.toLowerCase();if(s.includes("btn")||s.includes("button"))return!0}return!1}interactionTarget(t){let e=t;for(;e&&e!==document.body;){if(this.isIntrinsicInteractive(e))return e;e=e.parentElement}let r=t;for(e=t.parentElement;e&&e!==document.body&&this.looksInteractive(e);)r=e,e=e.parentElement;return r}isIntrinsicInteractive(t){if(Er.has(t.tagName))return!0;const e=t.getAttribute("role");return e&&Tr.has(e)||t.hasAttribute("onclick")||t.hasAttribute("tabindex")?!0:t.contentEditable==="true"}emitIfReady(t){const e=Date.now();e<this.cooldownUntil||(this.cooldownUntil=e+N.COOLDOWN_MS,this.persistState(),this.onFrustration(t))}emitHighPriority(t){this.cooldownUntil=Date.now()+N.COOLDOWN_MS,this.persistState(),this.onFrustration(t)}};N.COOLDOWN_MS=6e4;let mt=N;function q(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}"`:""}`}const Bt="mtb_anon_id",fe="mtb_reporter_email",ge="mtb_board_url";let Nt=null,ye=null,ve=null;function we(){try{const i=window.localStorage.getItem(Bt);if(i?.startsWith("anon_"))return i;const t=zt();return window.localStorage.setItem(Bt,t),t}catch{return Nt??(Nt=zt()),Nt}}function xe(){try{return window.localStorage.getItem(fe)??void 0}catch{return ye??void 0}}function Ar(i){ye=i;try{window.localStorage.setItem(fe,i)}catch{}}function Lr(){try{return window.localStorage.getItem(ge)??void 0}catch{return ve??void 0}}function $t(i){ve=i;try{window.localStorage.setItem(ge,i)}catch{}}function zt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`anon_${crypto.randomUUID()}`:`anon_${`${Date.now().toString(16)}-${Math.random().toString(16).slice(2,10)}`}`}const Pr={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",close:"Close",my_feedback:"My feedback",screenshot_label:"Attach screenshot",screenshot_hint:"Passwords and other sensitive fields are covered automatically.",screenshot_short:"Screenshot",screenshot_locked_hint:"Your drawing is baked onto the screenshot, so it is always attached. Sensitive fields are covered automatically.",recording_label:"Recording",recording_locked_hint:"A replay of what the page showed and how it was used — always included with a recording. No camera or microphone. Sensitive fields are covered automatically.",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",cancel:"Cancel — don't send feedback",retry:"Retry",error:"Couldn't load the question. Send your feedback as is.",expired:"This feedback session expired before it could be sent. Please close the widget and submit again."}},Mr={tab:"反馈",toolbar:{markup:"标注",record:"录屏",hint:"点击标注,拖动绘制",hintTouch:"用手指圈出问题",hintRecord:"正在录制屏幕",exit:"退出"},popup:{about:"关于",placeholder:"描述问题或建议...",submit:"提交",cancel:"取消",close:"关闭",my_feedback:"我的反馈",screenshot_label:"附带页面截图",screenshot_hint:"密码等敏感字段会自动打码。",screenshot_short:"截图",screenshot_locked_hint:"圈画会画在截图上,所以必定附带。敏感字段会自动打码。",recording_label:"录制",recording_locked_hint:"页面画面与操作过程的回放,录制内容必定随反馈提交。不含摄像头和麦克风,敏感字段会自动打码。",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:"跳过并发送",cancel:"取消并不发送",retry:"重试",error:"追问加载失败,可以直接发送反馈。",expired:"这条反馈在发送前已过期。请关闭组件后重新提交。"}},Ir={tab:"フィードバック",toolbar:{markup:"マークアップ",record:"録画",hint:"クリックでコメント、ドラッグで描画",hintTouch:"ドラッグして問題箇所を囲んでください",hintRecord:"画面を録画中",exit:"終了"},popup:{about:"概要",placeholder:"問題や提案を入力してください...",submit:"送信",cancel:"キャンセル",close:"閉じる",my_feedback:"自分のフィードバック",screenshot_label:"スクリーンショットを添付",screenshot_hint:"パスワードなどの機密項目は自動的に隠されます。",screenshot_short:"スクリーンショット",screenshot_locked_hint:"描き込みはスクリーンショット上に焼き込まれるため、必ず添付されます。機密項目は自動的に隠されます。",recording_label:"記録",recording_locked_hint:"ページの表示と操作の再現記録で、必ず添付されます。カメラやマイクは含まれず、機密項目は自動的に隠されます。",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:"スキップして送信",cancel:"キャンセル — 送信しない",retry:"再試行",error:"質問を読み込めませんでした。そのままフィードバックを送信できます。",expired:"このフィードバックは送信される前に有効期限が切れました。ウィジェットを閉じて、もう一度送信してください。"}},Rr={tab:"피드백",toolbar:{markup:"마크업",record:"녹화",hint:"클릭하여 댓글, 드래그하여 그리기",hintTouch:"드래그해서 문제가 있는 곳을 표시하세요",hintRecord:"화면 녹화 중",exit:"나가기"},popup:{about:"정보",placeholder:"문제 또는 제안 사항을 설명해 주세요...",submit:"제출",cancel:"취소",close:"닫기",my_feedback:"내 피드백",screenshot_label:"스크린샷 첨부",screenshot_hint:"비밀번호 등 민감한 입력란은 자동으로 가려집니다.",screenshot_short:"스크린샷",screenshot_locked_hint:"그린 표시는 스크린샷 위에 합쳐지므로 항상 첨부됩니다. 민감한 입력란은 자동으로 가려집니다.",recording_label:"기록",recording_locked_hint:"페이지 화면과 조작 과정의 재현 기록으로, 항상 첨부됩니다. 카메라와 마이크는 포함되지 않으며 민감한 입력란은 자동으로 가려집니다.",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:"건너뛰고 보내기",cancel:"취소 — 보내지 않기",retry:"재시도",error:"질문을 불러오지 못했습니다. 피드백을 그대로 보내세요.",expired:"이 피드백 세션은 전송되기 전에 만료되었습니다. 위젯을 닫고 다시 보내 주세요."}},Dr={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",close:"Cerrar",my_feedback:"Mis comentarios",screenshot_label:"Adjuntar captura de pantalla",screenshot_hint:"Las contraseñas y otros campos sensibles se ocultan automáticamente.",screenshot_short:"Captura",screenshot_locked_hint:"Tu dibujo se integra en la captura, por eso siempre se adjunta. Los campos sensibles se ocultan automáticamente.",recording_label:"Grabación",recording_locked_hint:"Una reproducción de lo que mostraba la página y cómo se usó; siempre se adjunta. Sin cámara ni micrófono. Los campos sensibles se ocultan automáticamente.",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",cancel:"Cancelar — no enviar",retry:"Reintentar",error:"No se pudo cargar la pregunta. Envía tus comentarios tal cual.",expired:"Esta sesión de comentarios caducó antes de poder enviarse. Cierra el widget y envíalo de nuevo."}},Fr={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",close:"Fermer",my_feedback:"Mes avis",screenshot_label:"Joindre une capture d'écran",screenshot_hint:"Les mots de passe et autres champs sensibles sont masqués automatiquement.",screenshot_short:"Capture",screenshot_locked_hint:"Votre dessin est intégré à la capture, elle est donc toujours jointe. Les champs sensibles sont masqués automatiquement.",recording_label:"Enregistrement",recording_locked_hint:"Une relecture de ce que la page affichait et de son utilisation — toujours jointe. Ni caméra ni micro. Les champs sensibles sont masqués automatiquement.",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",cancel:"Annuler — ne pas envoyer",retry:"Réessayer",error:"Impossible de charger la question. Envoyez votre avis tel quel.",expired:"Cette session de retour a expiré avant d'avoir pu être envoyée. Fermez le widget et renvoyez-la."}},Hr={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",close:"Schließen",my_feedback:"Mein Feedback",screenshot_label:"Screenshot anhängen",screenshot_hint:"Passwörter und andere sensible Felder werden automatisch abgedeckt.",screenshot_short:"Screenshot",screenshot_locked_hint:"Deine Zeichnung wird in den Screenshot eingebrannt, daher wird er immer angehängt. Sensible Felder werden automatisch abgedeckt.",recording_label:"Aufzeichnung",recording_locked_hint:"Eine Wiedergabe dessen, was die Seite zeigte und wie sie bedient wurde — immer angehängt. Keine Kamera, kein Mikrofon. Sensible Felder werden automatisch abgedeckt.",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",cancel:"Abbrechen — nicht senden",retry:"Erneut versuchen",error:"Die Frage konnte nicht geladen werden. Senden Sie Ihr Feedback einfach so.",expired:"Diese Feedback-Sitzung ist abgelaufen, bevor sie gesendet werden konnte. Bitte schließe das Widget und sende erneut."}},L={en:Pr,"zh-CN":Mr,ja:Ir,ko:Rr,es:Dr,fr:Fr,de:Hr};function Ot(i){if(L[i])return L[i];const t=i.split("-")[0];return L[t]?L[t]:L.en}const Br=60,Ut=["value","content"],Nr=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])),$r="https://cdn.jsdelivr.net/npm/@rrweb/record@2.1.0/umd/record.min.js",zr="sha384-MrD66HBNSykaP2N95+6hQCFlF5oH2tvL3TD/zyvHNkP/sAFWZx98DX9MEDy8MdVT";let P=null;function Or(){return P||(P=jr().catch(()=>qr()).catch(t=>{throw P=null,t}),P)}function Ur(i,t){const e=Z(i);return pt(e,t,oe()),e}function pt(i,t,e){if(Array.isArray(i)){i.forEach(a=>pt(a,t,e));return}if(!jt(i))return;const r=jt(i.attributes)?i.attributes:null,n=r&&Ut.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=J(i.text,o)),r)for(const a of Ut){const c=r[a];typeof c=="string"&&(r[a]=J(c,o))}}else o?.nodeType===Node.TEXT_NODE&&ae(o,e)&&(typeof i.textContent=="string"&&(i.textContent=m),typeof i.value=="string"&&(i.value=m));Object.values(i).forEach(a=>pt(a,t,e))}function jt(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}async function jr(){return(await import("@rrweb/record")).record}function qt(){const i=globalThis;return i.rrwebRecord?.record??i.rrweb?.record}function qr(){return new Promise((i,t)=>{const e=qt();if(e){i(e);return}const r=document.createElement("script");r.src=$r,r.integrity=zr,r.crossOrigin="anonymous",r.onload=()=>{const n=qt();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 Wr{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 Or();this.destroyed||(this.startedAt=Date.now(),this.stopped=!1,this.stopFn=t({emit:e=>{if(!this.stopped)try{this.events.push(Ur(e,t))}catch{}},maskAllInputs:!1,maskInputOptions:Nr,maskInputFn:(e,r)=>r.closest(`.${z}`)?m:J(e,r),maskTextFn:()=>m,blockClass:it,maskTextClass:z}),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?.()},Br*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())}}class Yr{constructor(t,e,r,n){this.intervalId=null,this.getDuration=r,this.el=t.el("div","mtb-record-bar"),this.el.innerHTML=`
|
|
151
|
+
`,t.append(this.el),this.focusTrap=vt(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,r):this.autoCloseTimer=setTimeout(()=>r(),Lt)}bindEmailCapture(t,e){const r=this.el.querySelector(".mtb-email-input"),n=this.el.querySelector(".mtb-email-submit"),s=this.el.querySelector(".mtb-email-error"),o=async()=>{const a=r.value.trim();if(!Bi.test(a)){r.classList.add("mtb-email-invalid");return}r.classList.remove("mtb-email-invalid"),s.hidden=!0,n.disabled=!0,await t(a)?(this.el.querySelector(".mtb-email-capture").innerHTML=`<div class="mtb-email-saved">${l(this.messages.success.email_saved)}</div>`,this.autoCloseTimer=setTimeout(()=>e(),Lt)):(s.hidden=!1,n.disabled=!1)};n.addEventListener("click",o),r.addEventListener("keydown",a=>{a.key==="Enter"&&o()})}destroy(){this.autoCloseTimer&&(clearTimeout(this.autoCloseTimer),this.autoCloseTimer=null),this.focusTrap.release(),this.el.remove(),this.focusTrap.restoreFocus()}}function se(i){return re({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 J(i,t){return i&&(se(t)?m:_(i))}const $i=512;function oe(){return new WeakMap}function ae(i,t){let e=i.parentElement;for(;e&&e!==document.body&&e!==document.documentElement;){const r=le(e,t);if(r==="sensitive")return!0;if(r==="contains-sensitive-child"||r==="too-large")return!1;e=e.parentElement}return!1}function le(i,t){const e=t.get(i);if(e)return e;const r=i.textContent??"";let n="none";return r.length>$i?n="too-large":_(r)!==r&&(n=Array.from(i.children).some(o=>{const a=le(o,t);return a==="sensitive"||a==="contains-sensitive-child"})?"contains-sensitive-child":"sensitive"),t.set(i,n),n}function zi(i){return new Promise(t=>{const e=new Image;e.onload=()=>t(e),e.onerror=()=>t(null),e.src=i})}function ce(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 Oi(i,t,e){return ce(i).map(r=>r.map(([n,s],o)=>`${o===0?"M":"L"} ${n+t} ${s+e}`).join(" ")).join(" ")}let A=null;function de(){return A||(A=Promise.resolve().then(()=>require("./html-to-image.cjs")).catch(i=>{throw A=null,i}),A)}let ot,at=null;function he(){return ot!==void 0?Promise.resolve(ot):(at??(at=de().then(({getFontEmbedCSS:i})=>i(document.body)).then(i=>(ot=i,i)).catch(()=>{at=null})),at)}const Ui=200;async function Pt(){try{const[{toJpeg:i},t]=await Promise.all([de(),he()]),e=document.body.getBoundingClientRect(),r=Ve(),n={x:window.scrollX,y:window.scrollY},s=Ki(document.body);return{dataUrl:await i(document.body,{quality:.85,width:r.width,height:r.height,pixelRatio:Zi(r),backgroundColor:"#ffffff",skipFonts:!1,skipAutoScale:!1,fontEmbedCSS:t,style:{transform:`translate(${e.left}px, ${e.top}px)`,transformOrigin:"top left"},filter:a=>{if(a instanceof HTMLElement&&a.id===w)return!1;if(!(a instanceof Element))return!0;const c=a.getBoundingClientRect();return c.width===0&&c.height===0?!0:c.top+window.scrollY-n.y<=r.height+Ui}}),metrics:r,redactions:s,pageScroll:n}}catch{return null}}async function ji(i,t=[],e){try{const r=t.map(n=>qi(n,i.pageScroll));return await Vi(i.dataUrl,r,i.metrics,i.redactions,e)}catch{return null}}function qi(i,t){const e=Wi(i,t);return e.x===0&&e.y===0?i:{...i,x:i.x+e.x,y:i.y+e.y,targetRect:i.targetRect&&{...i.targetRect,top:i.targetRect.top+e.y,left:i.targetRect.left+e.x,bottom:i.targetRect.bottom+e.y},drawPath:i.drawPath&&Oi(i.drawPath,e.x,e.y)}}function Wi(i,t){return i.captureOffsetX!==void 0&&i.captureOffsetY!==void 0?Ke({x:i.captureOffsetX,y:i.captureOffsetY},t):j(Yi(i))}function Yi(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}async function Vi(i,t,e,r,n){const s=document.createElement("canvas"),o=s.getContext("2d");if(!o)return null;const a=await zi(i);if(!a)return null;s.width=a.naturalWidth||window.innerWidth,s.height=a.naturalHeight||window.innerHeight,o.drawImage(a,0,0);const c=We(e,s.width,s.height);o.fillStyle="#e5e7eb";for(const d of r){const h=Ye(c,d);o.fillRect(h.left,h.top,h.width,h.height)}for(const d of t)d.type==="draw"&&d.drawPath?Gi(o,d.drawPath,c,n?.primary):d.type==="pin"&&Ji(o,X(c,d.x),G(c,d.y),n);return Qi(s)}function Ki(i){const t=[];for(const s of Xi(i,`.${it}`))lt(t,s.getBoundingClientRect(),Mt(s));for(const s of i.querySelectorAll("input, textarea, select")){if(It(s))continue;const o=s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement?s.value:"",a=s.closest(`.${z}`)!==null,c=se(s)||J(o,s)!==o;!a&&!c||lt(t,s.getBoundingClientRect(),Mt(s),Dt)}const e=document.createTreeWalker(i,NodeFilter.SHOW_TEXT),r=oe();let n=e.nextNode();for(;n;){const s=n.parentElement,o=n.textContent??"",a=s?.closest(`.${z}`)!==null,c=_(o)!==o||ae(n,r);if(s&&!It(s)&&(a||c)){const d=j(s),h=document.createRange();h.selectNodeContents(n);for(const u of Array.from(h.getClientRects()))lt(t,u,d,Dt)}n=e.nextNode()}return t}function Mt(i){return j(Zt(i))}function Xi(i,t){const e=Array.from(i.querySelectorAll(t));return i.matches(t)?[i,...e]:e}function It(i){return i.closest(`#${w}`)!==null||i.closest(`.${it}`)!==null}function lt(i,t,e,r=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.x-r,top:t.top+e.y-r,width:t.width+r*2,height:t.height+r*2})}function Gi(i,t,e,r=Jt){i.save(),i.lineCap="round",i.lineJoin="round";for(const n of ce(t))if(n.length!==0){i.beginPath(),i.moveTo(X(e,n[0][0]),G(e,n[0][1]));for(let s=1;s<n.length;s++)i.lineTo(X(e,n[s][0]),G(e,n[s][1]));i.shadowColor="transparent",i.strokeStyle="rgba(15, 23, 42, 0.72)",i.lineWidth=7,i.stroke(),i.strokeStyle="#ffffff",i.lineWidth=5.5,i.stroke(),i.strokeStyle=r,i.lineWidth=3.5,i.stroke()}i.restore()}const Rt=16e6,Dt=2;function Zi(i){const t=i.width*i.height;return!Number.isFinite(t)||t<=Rt?1:Math.sqrt(Rt/t)}function Ji(i,t,e,r){const n=r?.primary??Jt;i.save(),i.shadowColor="rgba(15, 23, 42, 0.68)",i.shadowOffsetY=2,i.shadowBlur=8,i.fillStyle=n,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.restore()}function Qi(i){return new Promise(t=>{try{i.toBlob(e=>t(e),"image/jpeg",.85)}catch{t(null)}})}class tr{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:er(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 wt=new tr;function er(i){return!i||typeof i!="object"||!("name"in i)?void 0:String(i.name)||void 0}function ue(i){const t=ir(i.name)||rr(i.message),e=nr(i);return e?`${t} (${e})`:t}function ir(i){return i&&/^[A-Za-z][A-Za-z0-9]*(?:Error|Exception|Rejection)$/.test(i)?i:""}function rr(i){return i.match(/^([A-Za-z][A-Za-z0-9]*(?:Error|Exception))\b/)?.[1]??"Error"}function nr(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 sr=20;class or{constructor(){this.errors=[],this.unsubscribe=null}start(){this.unsubscribe||(this.unsubscribe=wt.subscribe(t=>this.record(t)))}record(t){this.addError(ue(t))}addError(t){this.errors.length>=sr||this.errors.includes(t)||this.errors.push(t)}getErrors(){return[...this.errors]}stop(){this.unsubscribe?.(),this.unsubscribe=null}}const V=new Set;let R=null,D=null,F=null,Q=null,H=null,tt=null;function be(i){V.add(i),ar();let t=!1;return()=>{t||(t=!0,V.delete(i),V.size===0&&lr())}}function ct(i,t){const e={type:i,fromUrl:t,toUrl:location.href};tt=e.toUrl;for(const r of[...V])try{r(e)}catch{}}function ar(){if(F)return;tt=location.href,H=()=>ct("pop",tt??location.href),window.addEventListener("popstate",H),R=history.pushState,D=history.replaceState;const i=R,t=D;F=function(e,r,n){const s=location.href;i.call(history,e,r,n),ct("push",s)},Q=function(e,r,n){const s=location.href;t.call(history,e,r,n),ct("replace",s)},history.pushState=F,history.replaceState=Q}function lr(){H&&(window.removeEventListener("popstate",H),H=null),R&&history.pushState===F&&(history.pushState=R),D&&history.replaceState===Q&&(history.replaceState=D),R=null,D=null,F=null,Q=null,tt=null}const cr=20;function dr(i){return rt(i)?gt(i):ft(i)}function hr(i){return rt(i)?Qt(i):Gt(i)}class ur{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=wt.subscribe(t=>this.recordError(t)),this.unsubscribeNavigation=be(()=>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>cr&&this.breadcrumbs.shift()}handleClick(t){const e=t.target;if(e&&!S(e))try{this.add({type:"ui",category:"ui.click",timestamp:Date.now(),message:dr(e),data:{selector:hr(e)}})}catch{}}handleChange(t){const e=t.target;if(e&&!S(e))try{const r=e,n=rt(e)?gt(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=ue(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=U(t),n=U(e);this.add({type:"navigation",category:"navigation",timestamp:Date.now(),message:`${r} → ${n}`,data:{from:r,to:n}})}}const me="mtb_frustration_state";let bt=null;function et(){try{const i=window.sessionStorage.getItem(me);return K(i?JSON.parse(i):bt)}catch{return K(bt)}}function pe(i){const t=K(i);bt=t;try{window.sessionStorage.setItem(me,JSON.stringify(t))}catch{}}function br(){return et().dismissedByUser}function mr(){pe({...et(),dismissedByUser:!0})}function K(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 pr=4,fr=1500,gr=3,yr=5e3,dt=500,vr=2,wr=3e4,xr=2e3,kr=1e3,Sr=300,Er=new Set(["A","BUTTON","INPUT","SELECT","TEXTAREA","LABEL","SUMMARY","DETAILS"]),Tr=new Set(["button","link","checkbox","radio","tab","menuitem","option","switch","textbox","combobox","listbox","slider","spinbutton"]),_r=new Set(["A","BUTTON","SUMMARY"]),Cr=new Set(["button","link","tab","menuitem"]),Ft=[/\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/],N=class N{constructor(t){this.clickHistory=[],this.unsubscribeErrors=null,this.active=!1,this.lastInteraction=null,this.cooldownUntil=0,this.navTimestamps=[],this.unsubscribeNavigation=null,this.boundPageLeaveHandler=null,this.boundTurboNavigationHandler=null,this.lastNavigationAt=-1,this.boundSubmitHandler=null,this.boundInvalidHandler=null,this.recentSubmitForms=new WeakSet,this.recentFailedForms=new WeakSet,this.formFailureTimestamps=new WeakMap,this.errorPageUrls=new Set,this.domObserver=null,this.pendingDomChecks=0,this.lastMutationAt=-1,this.pendingTimers=new Set,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=wt.subscribe(()=>{const t=Date.now();if(!this.lastInteraction||t-this.lastInteraction.time>xr)return;const e=this.lastInteraction;this.lastInteraction=null,this.emitIfReady({signal:"dead_click",target:q(e.target),detail:"Uncaught error after interaction",timestamp:t})}),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.lastInteraction=null,this.stopNavigationTracking(),this.stopFormTracking(),this.errorPageUrls.clear(),this.clearPendingTimers(),this.pendingDomChecks=0,this.disconnectDomObserver())}schedule(t,e){const r=setTimeout(()=>{this.pendingTimers.delete(r),t()},e);this.pendingTimers.add(r)}clearPendingTimers(){for(const t of this.pendingTimers)clearTimeout(t);this.pendingTimers.clear()}startNavigationTracking(){this.unsubscribeNavigation=be(t=>this.handleNavigation(t)),this.boundPageLeaveHandler=()=>this.noteNavigationStarted(),window.addEventListener("beforeunload",this.boundPageLeaveHandler),window.addEventListener("pagehide",this.boundPageLeaveHandler),this.boundTurboNavigationHandler=()=>this.noteNavigationStarted(),document.addEventListener("turbo:before-visit",this.boundTurboNavigationHandler),document.addEventListener("turbo:submit-start",this.boundTurboNavigationHandler),document.addEventListener("turbo:before-fetch-request",this.boundTurboNavigationHandler)}stopNavigationTracking(){this.unsubscribeNavigation?.(),this.unsubscribeNavigation=null,this.navTimestamps=[],this.boundPageLeaveHandler&&(window.removeEventListener("beforeunload",this.boundPageLeaveHandler),window.removeEventListener("pagehide",this.boundPageLeaveHandler),this.boundPageLeaveHandler=null),this.boundTurboNavigationHandler&&(document.removeEventListener("turbo:before-visit",this.boundTurboNavigationHandler),document.removeEventListener("turbo:submit-start",this.boundTurboNavigationHandler),document.removeEventListener("turbo:before-fetch-request",this.boundTurboNavigationHandler),this.boundTurboNavigationHandler=null),this.lastNavigationAt=-1}noteNavigationStarted(){this.lastNavigationAt=Date.now()}restoreState(){const t=et();this.navTimestamps=t.navTimestamps,this.cooldownUntil=t.cooldownUntil,this.errorPageUrls=new Set(t.errorPageUrls)}persistState(){const t=et();pe({...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),this.recentSubmitForms=new WeakSet,this.recentFailedForms=new WeakSet}handleClick(t){const e=t.target;if(!e||S(e))return;this.trackFormSubmitIntent(e),this.trackNativeNavigationIntent(t,e);const r=this.interactionTarget(e),n=Date.now();this.lastInteraction={target:r,time:n},this.clickHistory.push({target:r,time:n});const s=n-fr;if(this.clickHistory=this.clickHistory.filter(a=>a.time>s),this.clickHistory.filter(a=>a.target===r).length>=pr){this.clickHistory=[],this.emitHighPriority({signal:"rage_click",target:q(r),timestamp:n});return}this.checkDeadClickDom(r,n)}handleNavigation(t){const e=Date.now();if(this.noteNavigationStarted(),t.type!=="replace"&&t.fromUrl!==t.toUrl&&t.type==="pop"){this.navTimestamps.push(e);const n=e-yr;this.navTimestamps=this.navTimestamps.filter(s=>s>n),this.navTimestamps.length>=gr&&(this.navTimestamps=[],this.emitIfReady({signal:"rapid_navigation",timestamp:e}))}this.persistState(),this.schedule(()=>{this.active&&this.checkErrorPage()},Sr)}handleFormSubmit(t){const e=t.target;e instanceof HTMLFormElement&&(S(e)||(this.rememberSubmitAttempt(e),this.schedule(()=>{this.active&&e.querySelector('[aria-invalid="true"], .is-invalid')&&this.recordFormFailure(e)},dt)))}trackFormSubmitIntent(t){const e=t.closest("button, input");(e instanceof HTMLButtonElement||e instanceof HTMLInputElement)&&(e.type!=="submit"&&e.type!=="image"||!e.form||S(e.form)||this.rememberSubmitAttempt(e.form))}trackNativeNavigationIntent(t,e){e.closest("a[href]")&&queueMicrotask(()=>{this.active&&!t.defaultPrevented&&this.noteNavigationStarted()})}rememberSubmitAttempt(t){this.recentSubmitForms.add(t),this.schedule(()=>{this.recentSubmitForms.delete(t)},dt)}recordFormFailure(t){if(this.recentFailedForms.has(t))return;this.recentFailedForms.add(t),this.schedule(()=>this.recentFailedForms.delete(t),dt);const e=Date.now(),r=e-wr,n=(this.formFailureTimestamps.get(t)??[]).filter(s=>s>r);n.push(e),this.formFailureTimestamps.set(t,n),!(n.length<vr)&&(this.formFailureTimestamps.set(t,[]),this.emitIfReady({signal:"form_failure",target:q(t),timestamp:e}))}handleFormInvalid(t){const e=t.target;if(!e||S(e))return;const r=e.closest("form");!r||!this.recentSubmitForms.has(r)||this.recordFormFailure(r)}checkErrorPage(){const t=location.href;if(this.errorPageUrls.has(t))return;const e=document.title.toLowerCase();if(Ft.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&&Ft.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(),this.schedule(()=>{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:q(t),timestamp:e})},kr))}ensureDomObserver(){this.domObserver||(this.domObserver=new MutationObserver(()=>{this.lastMutationAt=Date.now()}),this.domObserver.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,characterData:!0}))}disconnectDomObserver(){this.domObserver?.disconnect(),this.domObserver=null}looksInteractive(t){if(_r.has(t.tagName)||t.hasAttribute("onclick"))return!0;const e=t.getAttribute("role");if(e&&Cr.has(e)||window.getComputedStyle(t).cursor==="pointer")return!0;if(t.classList)for(const n of t.classList){const s=n.toLowerCase();if(s.includes("btn")||s.includes("button"))return!0}return!1}interactionTarget(t){let e=t;for(;e&&e!==document.body;){if(this.isIntrinsicInteractive(e))return e;e=e.parentElement}let r=t;for(e=t.parentElement;e&&e!==document.body&&this.looksInteractive(e);)r=e,e=e.parentElement;return r}isIntrinsicInteractive(t){if(Er.has(t.tagName))return!0;const e=t.getAttribute("role");return e&&Tr.has(e)||t.hasAttribute("onclick")||t.hasAttribute("tabindex")?!0:t.contentEditable==="true"}emitIfReady(t){const e=Date.now();e<this.cooldownUntil||(this.cooldownUntil=e+N.COOLDOWN_MS,this.persistState(),this.onFrustration(t))}emitHighPriority(t){this.cooldownUntil=Date.now()+N.COOLDOWN_MS,this.persistState(),this.onFrustration(t)}};N.COOLDOWN_MS=6e4;let mt=N;function q(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}"`:""}`}const Ht="mtb_anon_id",fe="mtb_reporter_email",ge="mtb_board_url";let Bt=null,ye=null,ve=null;function we(){try{const i=window.localStorage.getItem(Ht);if(i?.startsWith("anon_"))return i;const t=$t();return window.localStorage.setItem(Ht,t),t}catch{return Bt??(Bt=$t()),Bt}}function xe(){try{return window.localStorage.getItem(fe)??void 0}catch{return ye??void 0}}function Ar(i){ye=i;try{window.localStorage.setItem(fe,i)}catch{}}function Lr(){try{return window.localStorage.getItem(ge)??void 0}catch{return ve??void 0}}function Nt(i){ve=i;try{window.localStorage.setItem(ge,i)}catch{}}function $t(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`anon_${crypto.randomUUID()}`:`anon_${`${Date.now().toString(16)}-${Math.random().toString(16).slice(2,10)}`}`}const Pr={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",close:"Close",my_feedback:"My feedback",screenshot_label:"Attach screenshot",screenshot_hint:"Passwords and other sensitive fields are covered automatically.",screenshot_short:"Screenshot",screenshot_locked_hint:"Your drawing is baked onto the screenshot, so it is always attached. Sensitive fields are covered automatically.",recording_label:"Recording",recording_locked_hint:"A replay of what the page showed and how it was used — always included with a recording. No camera or microphone. Sensitive fields are covered automatically.",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",cancel:"Cancel — don't send feedback",retry:"Retry",error:"Couldn't load the question. Send your feedback as is.",expired:"This feedback session expired before it could be sent. Please close the widget and submit again."}},Mr={tab:"反馈",toolbar:{markup:"标注",record:"录屏",hint:"点击标注,拖动绘制",hintTouch:"用手指圈出问题",hintRecord:"正在录制屏幕",exit:"退出"},popup:{about:"关于",placeholder:"描述问题或建议...",submit:"提交",cancel:"取消",close:"关闭",my_feedback:"我的反馈",screenshot_label:"附带页面截图",screenshot_hint:"密码等敏感字段会自动打码。",screenshot_short:"截图",screenshot_locked_hint:"圈画会画在截图上,所以必定附带。敏感字段会自动打码。",recording_label:"录制",recording_locked_hint:"页面画面与操作过程的回放,录制内容必定随反馈提交。不含摄像头和麦克风,敏感字段会自动打码。",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:"跳过并发送",cancel:"取消并不发送",retry:"重试",error:"追问加载失败,可以直接发送反馈。",expired:"这条反馈在发送前已过期。请关闭组件后重新提交。"}},Ir={tab:"フィードバック",toolbar:{markup:"マークアップ",record:"録画",hint:"クリックでコメント、ドラッグで描画",hintTouch:"ドラッグして問題箇所を囲んでください",hintRecord:"画面を録画中",exit:"終了"},popup:{about:"概要",placeholder:"問題や提案を入力してください...",submit:"送信",cancel:"キャンセル",close:"閉じる",my_feedback:"自分のフィードバック",screenshot_label:"スクリーンショットを添付",screenshot_hint:"パスワードなどの機密項目は自動的に隠されます。",screenshot_short:"スクリーンショット",screenshot_locked_hint:"描き込みはスクリーンショット上に焼き込まれるため、必ず添付されます。機密項目は自動的に隠されます。",recording_label:"記録",recording_locked_hint:"ページの表示と操作の再現記録で、必ず添付されます。カメラやマイクは含まれず、機密項目は自動的に隠されます。",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:"スキップして送信",cancel:"キャンセル — 送信しない",retry:"再試行",error:"質問を読み込めませんでした。そのままフィードバックを送信できます。",expired:"このフィードバックは送信される前に有効期限が切れました。ウィジェットを閉じて、もう一度送信してください。"}},Rr={tab:"피드백",toolbar:{markup:"마크업",record:"녹화",hint:"클릭하여 댓글, 드래그하여 그리기",hintTouch:"드래그해서 문제가 있는 곳을 표시하세요",hintRecord:"화면 녹화 중",exit:"나가기"},popup:{about:"정보",placeholder:"문제 또는 제안 사항을 설명해 주세요...",submit:"제출",cancel:"취소",close:"닫기",my_feedback:"내 피드백",screenshot_label:"스크린샷 첨부",screenshot_hint:"비밀번호 등 민감한 입력란은 자동으로 가려집니다.",screenshot_short:"스크린샷",screenshot_locked_hint:"그린 표시는 스크린샷 위에 합쳐지므로 항상 첨부됩니다. 민감한 입력란은 자동으로 가려집니다.",recording_label:"기록",recording_locked_hint:"페이지 화면과 조작 과정의 재현 기록으로, 항상 첨부됩니다. 카메라와 마이크는 포함되지 않으며 민감한 입력란은 자동으로 가려집니다.",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:"건너뛰고 보내기",cancel:"취소 — 보내지 않기",retry:"재시도",error:"질문을 불러오지 못했습니다. 피드백을 그대로 보내세요.",expired:"이 피드백 세션은 전송되기 전에 만료되었습니다. 위젯을 닫고 다시 보내 주세요."}},Dr={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",close:"Cerrar",my_feedback:"Mis comentarios",screenshot_label:"Adjuntar captura de pantalla",screenshot_hint:"Las contraseñas y otros campos sensibles se ocultan automáticamente.",screenshot_short:"Captura",screenshot_locked_hint:"Tu dibujo se integra en la captura, por eso siempre se adjunta. Los campos sensibles se ocultan automáticamente.",recording_label:"Grabación",recording_locked_hint:"Una reproducción de lo que mostraba la página y cómo se usó; siempre se adjunta. Sin cámara ni micrófono. Los campos sensibles se ocultan automáticamente.",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",cancel:"Cancelar — no enviar",retry:"Reintentar",error:"No se pudo cargar la pregunta. Envía tus comentarios tal cual.",expired:"Esta sesión de comentarios caducó antes de poder enviarse. Cierra el widget y envíalo de nuevo."}},Fr={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",close:"Fermer",my_feedback:"Mes avis",screenshot_label:"Joindre une capture d'écran",screenshot_hint:"Les mots de passe et autres champs sensibles sont masqués automatiquement.",screenshot_short:"Capture",screenshot_locked_hint:"Votre dessin est intégré à la capture, elle est donc toujours jointe. Les champs sensibles sont masqués automatiquement.",recording_label:"Enregistrement",recording_locked_hint:"Une relecture de ce que la page affichait et de son utilisation — toujours jointe. Ni caméra ni micro. Les champs sensibles sont masqués automatiquement.",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",cancel:"Annuler — ne pas envoyer",retry:"Réessayer",error:"Impossible de charger la question. Envoyez votre avis tel quel.",expired:"Cette session de retour a expiré avant d'avoir pu être envoyée. Fermez le widget et renvoyez-la."}},Hr={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",close:"Schließen",my_feedback:"Mein Feedback",screenshot_label:"Screenshot anhängen",screenshot_hint:"Passwörter und andere sensible Felder werden automatisch abgedeckt.",screenshot_short:"Screenshot",screenshot_locked_hint:"Deine Zeichnung wird in den Screenshot eingebrannt, daher wird er immer angehängt. Sensible Felder werden automatisch abgedeckt.",recording_label:"Aufzeichnung",recording_locked_hint:"Eine Wiedergabe dessen, was die Seite zeigte und wie sie bedient wurde — immer angehängt. Keine Kamera, kein Mikrofon. Sensible Felder werden automatisch abgedeckt.",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",cancel:"Abbrechen — nicht senden",retry:"Erneut versuchen",error:"Die Frage konnte nicht geladen werden. Senden Sie Ihr Feedback einfach so.",expired:"Diese Feedback-Sitzung ist abgelaufen, bevor sie gesendet werden konnte. Bitte schließe das Widget und sende erneut."}},L={en:Pr,"zh-CN":Mr,ja:Ir,ko:Rr,es:Dr,fr:Fr,de:Hr};function zt(i){if(L[i])return L[i];const t=i.split("-")[0];return L[t]?L[t]:L.en}const Br=60,Ot=["value","content"],Nr=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])),$r="https://cdn.jsdelivr.net/npm/@rrweb/record@2.1.0/umd/record.min.js",zr="sha384-MrD66HBNSykaP2N95+6hQCFlF5oH2tvL3TD/zyvHNkP/sAFWZx98DX9MEDy8MdVT";let P=null;function Or(){return P||(P=jr().catch(()=>qr()).catch(t=>{throw P=null,t}),P)}function Ur(i,t){const e=Z(i);return pt(e,t,oe()),e}function pt(i,t,e){if(Array.isArray(i)){i.forEach(a=>pt(a,t,e));return}if(!Ut(i))return;const r=Ut(i.attributes)?i.attributes:null,n=r&&Ot.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=J(i.text,o)),r)for(const a of Ot){const c=r[a];typeof c=="string"&&(r[a]=J(c,o))}}else o?.nodeType===Node.TEXT_NODE&&ae(o,e)&&(typeof i.textContent=="string"&&(i.textContent=m),typeof i.value=="string"&&(i.value=m));Object.values(i).forEach(a=>pt(a,t,e))}function Ut(i){return!!i&&typeof i=="object"&&!Array.isArray(i)}async function jr(){return(await import("@rrweb/record")).record}function jt(){const i=globalThis;return i.rrwebRecord?.record??i.rrweb?.record}function qr(){return new Promise((i,t)=>{const e=jt();if(e){i(e);return}const r=document.createElement("script");r.src=$r,r.integrity=zr,r.crossOrigin="anonymous",r.onload=()=>{const n=jt();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 Wr{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 Or();this.destroyed||(this.startedAt=Date.now(),this.stopped=!1,this.stopFn=t({emit:e=>{if(!this.stopped)try{this.events.push(Ur(e,t))}catch{}},maskAllInputs:!1,maskInputOptions:Nr,maskInputFn:(e,r)=>r.closest(`.${z}`)?m:J(e,r),maskTextFn:()=>m,blockClass:it,maskTextClass:z}),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?.()},Br*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())}}class Yr{constructor(t,e,r,n){this.intervalId=null,this.getDuration=r,this.el=t.el("div","mtb-record-bar"),this.el.innerHTML=`
|
|
152
152
|
<span class="mtb-record-dot"></span>
|
|
153
153
|
<span class="mtb-record-timer">00:00</span>
|
|
154
154
|
<button class="mtb-record-stop" type="button">${l(e.record.stop)}</button>
|
|
@@ -169,5 +169,5 @@
|
|
|
169
169
|
</div>
|
|
170
170
|
<div class="mtb-failure-title">${l(e.error.submit)}</div>
|
|
171
171
|
${n}
|
|
172
|
-
`,t.append(this.el),r.onRetry&&this.el.querySelector(".mtb-failure-retry").addEventListener("click",r.onRetry),this.el.querySelector(".mtb-failure-close").addEventListener("click",r.onClose)}destroy(){this.el.remove()}}function Xr(){return{page_url:U(window.location.href),user_agent:navigator.userAgent,browser:Gr(),os:Zr(),screen_width:window.screen.width,screen_height:window.screen.height}}function Gr(){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 Zr(){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 Jr(i){const{description:t,pageContext:e,consoleErrors:r,annotation:n,user:s,recording:o,anonId:a,anonEmail:c,breadcrumbs:d}=i;return{...Z({description:t,...e,page_url:U(e.page_url),console_errors:r,annotations:n?[n]:[],target_element:n?.targetSelector?{selector:n.targetSelector,text:n.targetText??"",name:n.targetName??""}:void 0,recording_events:o?.events,recording_duration:o?.duration,breadcrumbs:d}),user_id:s?.id,user_email:s?.email,user_name:s?.name,reporter_external_id:s?void 0:a,reporter_email:s?void 0:c}}const Qr=300,tn=900;class en{constructor(t,e){this.deps=t,this.host=e,this.activeSubmission=null,this.pendingSubmissionRequest=null,this.submissionAttempt=0,this.pendingBaseCapture=null,this.idleCaptureTimer=null,this.failure=null,this.screenshotEnabled=!0}isScreenshotEnabled(){return this.screenshotEnabled}resetScreenshotConsent(){this.screenshotEnabled=!0}setScreenshotEnabled(t){if(this.screenshotEnabled=t,t){this.beginBaseCapture();return}this.clearIdleCaptureTimer(),this.pendingBaseCapture=null}beginBaseCapture(){this.screenshotEnabled&&(this.pendingBaseCapture||(this.clearIdleCaptureTimer(),this.idleCaptureTimer=setTimeout(()=>{this.idleCaptureTimer=null,this.pendingBaseCapture??(this.pendingBaseCapture=Mt())},tn)))}clearIdleCaptureTimer(){this.idleCaptureTimer!==null&&(clearTimeout(this.idleCaptureTimer),this.idleCaptureTimer=null)}start(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){if(await Wt(),n!==this.submissionAttempt)return null;this.clearIdleCaptureTimer();const s=this.screenshotEnabled?this.pendingBaseCapture??Mt():null;this.pendingBaseCapture=null;const o=Xr(),a=await s;if(n!==this.submissionAttempt)return null;const c=a?await ji(a,e?[e]:[],this.deps.brandColors):null;if(n!==this.submissionAttempt)return null;const d=Jr({description:t,pageContext:o,consoleErrors:this.deps.consoleCollector.getErrors(),annotation:e,user:this.deps.user(),recording:r,anonId:we(),anonEmail:xe(),breadcrumbs:this.deps.breadcrumbCollector.getBreadcrumbs()});try{const h=await this.deps.apiClient.createSubmissionSession(d,c);return n!==this.submissionAttempt?(await this.deps.apiClient.abandonSubmissionSession(h.id,h.token).catch(()=>{}),null):(this.activeSubmission=h,h)}catch{return null}}async finalize(){const t=this.submissionAttempt,e=this.host.isBackground(),r=this.activeSubmission??await(this.pendingSubmissionRequest??Promise.resolve(null));if(t!==this.submissionAttempt)return;if(!r){if(e)return this.showFinalizeFailure({canRetry:!1});throw new Error("No active submission session")}const n=e?Promise.resolve():new Promise(o=>setTimeout(o,Qr));let s;try{s=await this.deps.apiClient.finalizeSubmissionSession(r.id,r.token)}catch(o){if(e)return this.showFinalizeFailure({canRetry:!0});throw o}await Promise.all([n,Wt()]),!(t!==this.submissionAttempt||this.activeSubmission!==r)&&(this.activeSubmission=null,this.pendingSubmissionRequest=null,this.host.onFinalized(s,r))}showFinalizeFailure(t){this.host.onReleaseForFailureCard(),this.failure?.destroy(),this.failure=new Kr(this.deps.shadow(),this.deps.messages(),{onRetry:t.canRetry?()=>this.retryBackgroundFinalization():void 0,onClose:()=>this.dismissFinalizeFailure()})}retryBackgroundFinalization(){this.dismissFinalizeFailure(),this.host.onReenterBackground(),this.finalize().catch(()=>this.showFinalizeFailure({canRetry:!0}))}dismissFinalizeFailure(){this.failure?.destroy(),this.failure=null}abandon(){this.submissionAttempt+=1,this.clearIdleCaptureTimer(),this.pendingBaseCapture=null,this.resetScreenshotConsent();const t=this.activeSubmission;this.activeSubmission=null,this.pendingSubmissionRequest=null,t&&this.deps.apiClient.abandonSubmissionSession(t.id,t.token).catch(()=>{})}}function Wt(){return new Promise(i=>requestAnimationFrame(()=>setTimeout(i,0)))}function nt(i){i.preventDefault(),i.stopPropagation()}class x{constructor(t){this.host=t,this.launcherLit=!0,this.acceptsFrustrationPrompt=!1}enter(){}exit(){}handleOpen(){}handleClose(){this.host.exitAll()}handleEscape(t){}handleTabClick(){this.host.exitAll()}handleToolbarModeChange(t){}handleDrawStroke(){}}class W extends x{constructor(){super(...arguments),this.kind="idle",this.launcherLit=!1,this.acceptsFrustrationPrompt=!0}handleOpen(){this.host.dismissFrustrationPrompt(),this.host.transitionTo(new k(this.host))}handleClose(){}handleTabClick(){this.handleOpen()}}class k extends x{constructor(){super(...arguments),this.kind="annotating"}enter(){if(!this.host.hasAnnotationChrome()){this.host.mountAnnotationChrome();return}this.host.destroyRecordingManager(),this.host.teardownDrawBar(),this.host.ensureSession()}handleEscape(t){nt(t),this.host.exitAll()}handleToolbarModeChange(t){t==="record"?this.host.transitionTo(new kt(this.host)):this.host.transitionTo(new k(this.host))}handleDrawStroke(){this.host.transitionTo(new rn(this.host,y()?"sheet":"bar"))}}class kt extends x{constructor(){super(...arguments),this.kind="recording"}enter(){this.host.clearCurrentAnnotation(),this.host.teardownDrawBar(),this.host.destroySession(),this.host.startRecorder()}handleEscape(t){nt(t),this.host.stopRecordingIntoNote()}handleToolbarModeChange(t){t!=="record"&&this.host.transitionTo(new k(this.host))}}class rn extends x{constructor(t,e){super(t),this.surface=e,this.kind="drawing"}enter(){this.surface==="sheet"?this.host.mountDrawSheet():(this.host.mountDrawBar(),this.host.refreshDrawBar())}handleEscape(t){nt(t),this.host.cancelDraw()}handleToolbarModeChange(t){t==="record"?this.host.transitionTo(new kt(this.host)):this.host.transitionTo(new k(this.host))}handleDrawStroke(){this.surface==="bar"&&this.host.refreshDrawBar()}}class Yt extends x{constructor(t,e){super(t),this.opts=e,this.kind="popup"}enter(){this.host.mountNotePopup(this.opts)}handleEscape(t){nt(t),this.host.exitAll()}handleToolbarModeChange(t){t==="record"?this.host.transitionTo(new kt(this.host)):(this.host.dismissNotePopup(),this.host.transitionTo(new k(this.host)))}}class nn extends x{constructor(t,e,r){super(t),this.pos=e,this.opts=r,this.kind="clarifying"}enter(){this.host.mountClarifyCard(this.pos,this.opts)}handleEscape(t){}handleToolbarModeChange(t){this.host.revertToolbarDuringClarify()}}class Vt extends x{constructor(){super(...arguments),this.kind="submitting",this.launcherLit=!1}enter(){this.host.releaseClarifyUi()}handleTabClick(){}}const sn=/^#[0-9a-f]{6}$/i;function on(i){return i===void 0?void 0:typeof i!="object"||i===null||![i.primary,i.hover,i.active,i.onPrimary].every(e=>typeof e=="string"&&sn.test(e))?Kt():{primary:i.primary.toLowerCase(),hover:i.hover.toLowerCase(),active:i.active.toLowerCase(),onPrimary:i.onPrimary.toLowerCase()}}function Kt(){console.warn("[MakeThisBetter] brandColors requires primary, hover, active, and onPrimary as six-digit hex colors.")}function Xt(){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 an{constructor(t){this.tab=null,this.toolbar=null,this.session=null,this.drawBar=null,this.dim=null,this.pageOffset=new Ne,this.pinPopup=null,this.scrollLock=null,this.drawSheet=null,this.clarify=null,this.success=null,this.frustrationPrompt=null,this.frustrationDetector=null,this.state=new W(this),this.via="pin",this.currentAnnotation=null,this.submittingUi=null,this.lastPopupPos=null,this.recordingManager=null,this.touchHintShown=!1,this.lastHandoff={},this.handleKeydown=e=>{e.key==="Escape"&&($(e)||this.state.handleEscape(e))},this.stopRecordingIntoNote=()=>{this.recordingManager&&(this.recordingManager.stop(),this.via="record",this.transitionTo(new Yt(this,{x:window.innerWidth/2,y:window.innerHeight/2,targetName:this.messages.record.timer_label})))},this.config=t,t.projectKey||console.warn("[MakeThisBetter] projectKey is missing. Feedback submission will be rejected."),this.brandColors=on(t.brandColors),this.messages=Ot(t.locale??document.documentElement.lang??"en"),this.apiClient=new _i({projectKey:t.projectKey,apiUrl:t.apiUrl,userToken:t.userToken,userTokenFn:t.userTokenFn}),this.consoleCollector=new or,this.consoleCollector.start(),this.breadcrumbCollector=new ur,this.breadcrumbCollector.start(),this.lifecycle=new en({apiClient:this.apiClient,consoleCollector:this.consoleCollector,breadcrumbCollector:this.breadcrumbCollector,brandColors:this.brandColors,shadow:()=>this.shadow,messages:()=>this.messages,user:()=>this.config.user},{isBackground:()=>this.state.kind==="submitting",onReleaseForFailureCard:()=>this.transitionTo(new W(this)),onReenterBackground:()=>this.transitionTo(new Vt(this)),onFinalized:(e,r)=>this.handleFinalized(e,r)});try{this.buildUI()}catch(e){this.consoleCollector.stop(),this.breadcrumbCollector.stop(),console.warn("[MakeThisBetter] Widget failed to start:",e);return}t.frustrationDetection!==!1&&(this.frustrationDetector=new mt(()=>this.handleFrustration()),this.frustrationDetector.start()),document.addEventListener("keydown",this.handleKeydown,!0)}transitionTo(t){const e=this.state;this.state=t,e.exit(),t.enter(),this.tab?.setActive(t.launcherLit)}buildUI(){if(this.shadow=new ht(this.config.theme??"auto",this.brandColors),this.config.entryMode==="api"){Xt()&&console.warn('[MakeThisBetter] entryMode: "api" renders no launcher. Call MakeThisBetter.open() from your own UI.');return}if(y()){Xt()&&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.shadow||(this.tab=new Re(this.shadow,this.messages,this.config.position??"right",()=>this.state.handleTabClick(),this.config.tabText,this.brandColors?void 0:this.config.tabColor))}open(){this.shadow&&this.state.handleOpen()}close(){this.state.handleClose()}showLauncher(){y()||(this.mountTab(),this.tab?.setActive(this.state.launcherLit))}hideLauncher(){this.tab?.destroy(),this.tab=null}setLocale(t){this.config.locale=t,this.messages=Ot(t),this.tab?.setMessages(this.messages)}handleFrustration(){!this.state.acceptsFrustrationPrompt||this.frustrationPrompt||br()||(this.frustrationPrompt=new Fe(this.shadow,this.messages,{onTell:()=>{this.dismissFrustrationPrompt(),this.state.handleOpen()},onDismiss:()=>{mr(),this.dismissFrustrationPrompt()},onAutoHide:()=>this.dismissFrustrationPrompt()}))}dismissFrustrationPrompt(){this.frustrationPrompt?.destroy(),this.frustrationPrompt=null}hasAnnotationChrome(){return this.toolbar!==null}mountAnnotationChrome(){he();const t=y();this.toolbar=new Ue(this.shadow,this.messages,()=>this.exitAll(),e=>this.state.handleToolbarModeChange(e),this.config.position??"right",!t||!this.touchHintShown),t&&(this.touchHintShown=!0),this.ensureSession(),t&&this.toolbar&&this.pageOffset.reserve(this.toolbar.height())}ensureSession(){this.session||(this.session=new ri(this.shadow,this.messages,{onPin:(t,e)=>{this.currentAnnotation=t,this.via="pin",this.transitionTo(new Yt(this,{x:t.x,y:t.y,targetName:e,targetRect:t.targetRect}))},onDrawStroke:()=>this.state.handleDrawStroke()}))}destroySession(){this.session?.destroy(),this.session=null}clearCurrentAnnotation(){this.currentAnnotation=null}startRecorder(){this.recordingManager=new Vr,this.recordingManager.start(this.shadow,this.messages,this.stopRecordingIntoNote).catch(t=>{console.warn("[MakeThisBetter] Interaction replay unavailable, falling back to markup:",t),this.state.kind==="recording"&&(this.toolbar?.setMode("markup"),this.state.handleToolbarModeChange("markup"))})}destroyRecordingManager(){this.recordingManager?.destroy(),this.recordingManager=null}mountDrawBar(){this.drawBar=new li(this.shadow,{messages:this.messages,onUndo:()=>this.handleDrawUndoRedo("undo"),onRedo:()=>this.handleDrawUndoRedo("redo"),onCancel:()=>this.cancelDraw(),onSubmit:t=>this.handleDrawSubmit(t),onActivity:()=>this.lifecycle.beginBaseCapture()}),this.lifecycle.setScreenshotEnabled(!0),this.lifecycle.beginBaseCapture()}mountDrawSheet(){this.drawSheet=new Ct(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(),onActivity:()=>this.lifecycle.beginBaseCapture(),position:this.config.position??"right"}),this.submittingUi=this.drawSheet,this.lifecycle.setScreenshotEnabled(!0),this.lifecycle.beginBaseCapture()}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.teardownDrawBar(),this.drawSheet?.destroy(),this.drawSheet=null,this.dim?.destroy(),this.dim=null,this.submittingUi=null,this.transitionTo(new k(this))}teardownDrawBar(){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.drawSheet,this.handleSubmit(t||this.messages.annotation.drawing)}mountNotePopup({x:t,y:e,targetName:r,targetRect:n}){this.lastPopupPos={x:t,y:e},this.teardownDrawBar(),this.session?.dismissInteraction(),this.pinPopup?.destroy(),this.pinPopup=null,this.dim?.destroy(),this.dim=null,this.dim=new Be(this.shadow,()=>this.exitAll());const s=this.recordingManager?.getRecording();s&&this.lifecycle.setScreenshotEnabled(!0),this.pinPopup=new Ct(this.shadow,{targetName:r,x:t,y:e,targetRect:n,messages:this.messages,onSubmit:(o,a)=>this.handleSubmit(o,a),onClose:()=>this.exitAll(),onActivity:()=>this.lifecycle.beginBaseCapture(),onMyFeedback:this.buildMyFeedbackHandler(),...s?{recordingSeconds:s.duration}:{onScreenshotToggle:o=>this.lifecycle.setScreenshotEnabled(o),screenshotEnabled:this.lifecycle.isScreenshotEnabled()},position:this.config.position??"right"}),this.submittingUi=this.pinPopup,this.engageScrollLock(),this.lifecycle.beginBaseCapture()}dismissNotePopup(){this.pinPopup?.destroy(),this.pinPopup=null,this.dim?.destroy(),this.dim=null,this.releaseScrollLock(),this.submittingUi=null,this.clearCurrentAnnotation(),this.destroySession()}engageScrollLock(){this.scrollLock||(this.scrollLock=ze())}releaseScrollLock(){this.scrollLock?.release(),this.scrollLock=null}buildMyFeedbackHandler(){if(!this.config.user&&Lr())return async()=>{const t=await this.apiClient.createIdentityToken(we());!t?.identity_token||!t.board_url||($t(t.board_url),window.open(`${t.board_url}?identity=${encodeURIComponent(t.identity_token)}`,"_blank"))}}handleSubmit(t,e){if(!this.submittingUi)return;const r=this.currentAnnotation,n=this.recordingManager?.getRecording()??void 0,s=this.teardownSubmittingUi(!0),o=()=>this.lifecycle.start(t,r,n);this.transitionTo(new nn(this,this.lastPopupPos,{element:s,pendingSession:o(),onRetrySubmission:o,initiatingKeydown:e}))}teardownSubmittingUi(t=!1){const e=this.pinPopup??this.drawSheet,r=t?e?.releaseElement():void 0;return this.teardownDrawBar(),r||e?.destroy(),this.releaseScrollLock(),this.pinPopup=null,this.drawSheet=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,r}mountClarifyCard(t,e){this.clarify=new Hi(this.shadow,{apiClient:this.apiClient,messages:this.messages,element:e.element,position:this.config.position??"right",x:t?.x,y:t?.y,onFinalize:()=>this.lifecycle.finalize(),initiatingKeydown:e.initiatingKeydown,onSkip:()=>this.transitionTo(new Vt(this)),onCancel:()=>this.exitAll(),pendingSession:e.pendingSession,onRetrySubmission:e.onRetrySubmission})}revertToolbarDuringClarify(){this.toolbar?.setMode(this.via==="record"?"record":"markup")}releaseClarifyUi(){this.teardownToolbar(),this.currentAnnotation=null,this.clarify=null}handleFinalized(t,e){this.lastHandoff={feedbackId:t.id,boardUrl:t.board_url,identityToken:t.identity_token},t.board_url&&$t(t.board_url),this.clarify?.destroy(),this.clarify=null,this.teardownToolbar(),this.lifecycle.resetScreenshotConsent(),this.showSuccess({skipFollowup:e.ai_clarify_available===!1})}showSuccess(t){this.lifecycle.dismissFinalizeFailure(),this.transitionTo(new W(this)),this.success=new Ni(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)&&!xe())return{onSubmit:async r=>{const n=await this.apiClient.updateReporter(t,r,e);return n&&Ar(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()=>{try{const r=await this.apiClient.resolveUserToken();r&&window.open(`${t}?identity=${encodeURIComponent(r)}`,"_blank")}catch{}}}}teardownToolbar(){this.pageOffset.release(),this.toolbar?.destroy(),this.toolbar=null}exitAll(){this.lifecycle.abandon(),this.via="pin",this.transitionTo(new W(this)),this.teardownToolbar(),this.teardownDrawBar(),this.releaseScrollLock(),this.session?.hideHighlight(),this.session?.destroy(),this.session=null,this.dim?.destroy(),this.dim=null,this.pinPopup?.destroy(),this.pinPopup=null,this.drawSheet?.destroy(),this.drawSheet=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.lifecycle.dismissFinalizeFailure(),this.tab?.destroy(),this.recordingManager?.destroy(),this.shadow?.destroy()}}let v=null,E=null,T=null;function ln(){T&&(document.removeEventListener("DOMContentLoaded",T),T=null)}function M(i){ln(),v?.destroy(),v=i?new an(i):null}const ke={init(i){typeof document>"u"||(M(),E=i,document.readyState==="loading"?(T=()=>{T=null,M(i)},document.addEventListener("DOMContentLoaded",T,{once:!0})):M(i))},destroy(){M(),E=null},setLocale(i){E&&(E.locale=i),v?.setLocale(i)},open(){v?.open()},close(){v?.close()},showLauncher(){v?.showLauncher()},hideLauncher(){v?.hideLauncher()}};typeof window<"u"&&(window.MakeThisBetter=ke,document.addEventListener("turbo:load",()=>{const i=document.getElementById(w);E&&(!i||!i.shadowRoot)&&(i?.remove(),M(E))}));exports.MakeThisBetter=ke;
|
|
172
|
+
`,t.append(this.el),r.onRetry&&this.el.querySelector(".mtb-failure-retry").addEventListener("click",r.onRetry),this.el.querySelector(".mtb-failure-close").addEventListener("click",r.onClose)}destroy(){this.el.remove()}}function Xr(){return{page_url:U(window.location.href),user_agent:navigator.userAgent,browser:Gr(),os:Zr(),screen_width:window.screen.width,screen_height:window.screen.height}}function Gr(){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 Zr(){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 Jr(i){const{description:t,pageContext:e,consoleErrors:r,annotation:n,user:s,recording:o,anonId:a,anonEmail:c,breadcrumbs:d}=i;return{...Z({description:t,...e,page_url:U(e.page_url),console_errors:r,annotations:n?[n]:[],target_element:n?.targetSelector?{selector:n.targetSelector,text:n.targetText??"",name:n.targetName??""}:void 0,recording_events:o?.events,recording_duration:o?.duration,breadcrumbs:d}),user_id:s?.id,user_email:s?.email,user_name:s?.name,reporter_external_id:s?void 0:a,reporter_email:s?void 0:c}}const Qr=300,tn=900;class en{constructor(t,e){this.deps=t,this.host=e,this.activeSubmission=null,this.pendingSubmissionRequest=null,this.submissionAttempt=0,this.pendingBaseCapture=null,this.idleCaptureTimer=null,this.failure=null,this.screenshotEnabled=!0}isScreenshotEnabled(){return this.screenshotEnabled}resetScreenshotConsent(){this.screenshotEnabled=!0}setScreenshotEnabled(t){if(this.screenshotEnabled=t,t){this.beginBaseCapture();return}this.clearIdleCaptureTimer(),this.pendingBaseCapture=null}beginBaseCapture(){this.screenshotEnabled&&(this.pendingBaseCapture||(this.clearIdleCaptureTimer(),this.idleCaptureTimer=setTimeout(()=>{this.idleCaptureTimer=null,this.pendingBaseCapture??(this.pendingBaseCapture=Pt())},tn)))}clearIdleCaptureTimer(){this.idleCaptureTimer!==null&&(clearTimeout(this.idleCaptureTimer),this.idleCaptureTimer=null)}start(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){if(await qt(),n!==this.submissionAttempt)return null;this.clearIdleCaptureTimer();const s=this.screenshotEnabled?this.pendingBaseCapture??Pt():null;this.pendingBaseCapture=null;const o=Xr(),a=await s;if(n!==this.submissionAttempt)return null;const c=a?await ji(a,e?[e]:[],this.deps.brandColors):null;if(n!==this.submissionAttempt)return null;const d=Jr({description:t,pageContext:o,consoleErrors:this.deps.consoleCollector.getErrors(),annotation:e,user:this.deps.user(),recording:r,anonId:we(),anonEmail:xe(),breadcrumbs:this.deps.breadcrumbCollector.getBreadcrumbs()});try{const h=await this.deps.apiClient.createSubmissionSession(d,c);return n!==this.submissionAttempt?(await this.deps.apiClient.abandonSubmissionSession(h.id,h.token).catch(()=>{}),null):(this.activeSubmission=h,h)}catch{return null}}async finalize(){const t=this.submissionAttempt,e=this.host.isBackground(),r=this.activeSubmission??await(this.pendingSubmissionRequest??Promise.resolve(null));if(t!==this.submissionAttempt)return;if(!r){if(e)return this.showFinalizeFailure({canRetry:!1});throw new Error("No active submission session")}const n=e?Promise.resolve():new Promise(o=>setTimeout(o,Qr));let s;try{s=await this.deps.apiClient.finalizeSubmissionSession(r.id,r.token)}catch(o){if(e)return this.showFinalizeFailure({canRetry:!0});throw o}await Promise.all([n,qt()]),!(t!==this.submissionAttempt||this.activeSubmission!==r)&&(this.activeSubmission=null,this.pendingSubmissionRequest=null,this.host.onFinalized(s,r))}showFinalizeFailure(t){this.host.onReleaseForFailureCard(),this.failure?.destroy(),this.failure=new Kr(this.deps.shadow(),this.deps.messages(),{onRetry:t.canRetry?()=>this.retryBackgroundFinalization():void 0,onClose:()=>this.dismissFinalizeFailure()})}retryBackgroundFinalization(){this.dismissFinalizeFailure(),this.host.onReenterBackground(),this.finalize().catch(()=>this.showFinalizeFailure({canRetry:!0}))}dismissFinalizeFailure(){this.failure?.destroy(),this.failure=null}abandon(){this.submissionAttempt+=1,this.clearIdleCaptureTimer(),this.pendingBaseCapture=null,this.resetScreenshotConsent();const t=this.activeSubmission;this.activeSubmission=null,this.pendingSubmissionRequest=null,t&&this.deps.apiClient.abandonSubmissionSession(t.id,t.token).catch(()=>{})}}function qt(){return new Promise(i=>requestAnimationFrame(()=>setTimeout(i,0)))}function nt(i){i.preventDefault(),i.stopPropagation()}class x{constructor(t){this.host=t,this.launcherLit=!0,this.acceptsFrustrationPrompt=!1}enter(){}exit(){}handleOpen(){}handleClose(){this.host.exitAll()}handleEscape(t){}handleTabClick(){this.host.exitAll()}handleToolbarModeChange(t){}handleDrawStroke(){}}class W extends x{constructor(){super(...arguments),this.kind="idle",this.launcherLit=!1,this.acceptsFrustrationPrompt=!0}handleOpen(){this.host.dismissFrustrationPrompt(),this.host.transitionTo(new k(this.host))}handleClose(){}handleTabClick(){this.handleOpen()}}class k extends x{constructor(){super(...arguments),this.kind="annotating"}enter(){if(!this.host.hasAnnotationChrome()){this.host.mountAnnotationChrome();return}this.host.destroyRecordingManager(),this.host.teardownDrawBar(),this.host.ensureSession()}handleEscape(t){nt(t),this.host.exitAll()}handleToolbarModeChange(t){t==="record"?this.host.transitionTo(new xt(this.host)):this.host.transitionTo(new k(this.host))}handleDrawStroke(){this.host.transitionTo(new rn(this.host,y()?"sheet":"bar"))}}class xt extends x{constructor(){super(...arguments),this.kind="recording"}enter(){this.host.clearCurrentAnnotation(),this.host.teardownDrawBar(),this.host.destroySession(),this.host.startRecorder()}handleEscape(t){nt(t),this.host.stopRecordingIntoNote()}handleToolbarModeChange(t){t!=="record"&&this.host.transitionTo(new k(this.host))}}class rn extends x{constructor(t,e){super(t),this.surface=e,this.kind="drawing"}enter(){this.surface==="sheet"?this.host.mountDrawSheet():(this.host.mountDrawBar(),this.host.refreshDrawBar())}handleEscape(t){nt(t),this.host.cancelDraw()}handleToolbarModeChange(t){t==="record"?this.host.transitionTo(new xt(this.host)):this.host.transitionTo(new k(this.host))}handleDrawStroke(){this.surface==="bar"&&this.host.refreshDrawBar()}}class Wt extends x{constructor(t,e){super(t),this.opts=e,this.kind="popup"}enter(){this.host.mountNotePopup(this.opts)}handleEscape(t){nt(t),this.host.exitAll()}handleToolbarModeChange(t){t==="record"?this.host.transitionTo(new xt(this.host)):(this.host.dismissNotePopup(),this.host.transitionTo(new k(this.host)))}}class nn extends x{constructor(t,e,r){super(t),this.pos=e,this.opts=r,this.kind="clarifying"}enter(){this.host.mountClarifyCard(this.pos,this.opts)}handleEscape(t){}handleToolbarModeChange(t){this.host.revertToolbarDuringClarify()}}class Yt extends x{constructor(){super(...arguments),this.kind="submitting",this.launcherLit=!1}enter(){this.host.releaseClarifyUi()}handleTabClick(){}}const sn=/^#[0-9a-f]{6}$/i;function on(i){return i===void 0?void 0:typeof i!="object"||i===null||![i.primary,i.hover,i.active,i.onPrimary].every(e=>typeof e=="string"&&sn.test(e))?Vt():{primary:i.primary.toLowerCase(),hover:i.hover.toLowerCase(),active:i.active.toLowerCase(),onPrimary:i.onPrimary.toLowerCase()}}function Vt(){console.warn("[MakeThisBetter] brandColors requires primary, hover, active, and onPrimary as six-digit hex colors.")}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 an{constructor(t){this.tab=null,this.toolbar=null,this.session=null,this.drawBar=null,this.dim=null,this.pageOffset=new Ne,this.pinPopup=null,this.scrollLock=null,this.drawSheet=null,this.clarify=null,this.success=null,this.frustrationPrompt=null,this.frustrationDetector=null,this.state=new W(this),this.via="pin",this.currentAnnotation=null,this.submittingUi=null,this.lastPopupPos=null,this.recordingManager=null,this.touchHintShown=!1,this.lastHandoff={},this.handleKeydown=e=>{e.key==="Escape"&&($(e)||this.state.handleEscape(e))},this.stopRecordingIntoNote=()=>{this.recordingManager&&(this.recordingManager.stop(),this.via="record",this.transitionTo(new Wt(this,{x:window.innerWidth/2,y:window.innerHeight/2,targetName:this.messages.record.timer_label})))},this.config=t,t.projectKey||console.warn("[MakeThisBetter] projectKey is missing. Feedback submission will be rejected."),this.brandColors=on(t.brandColors),this.messages=zt(t.locale??document.documentElement.lang??"en"),this.apiClient=new _i({projectKey:t.projectKey,apiUrl:t.apiUrl,userToken:t.userToken,userTokenFn:t.userTokenFn}),this.consoleCollector=new or,this.consoleCollector.start(),this.breadcrumbCollector=new ur,this.breadcrumbCollector.start(),this.lifecycle=new en({apiClient:this.apiClient,consoleCollector:this.consoleCollector,breadcrumbCollector:this.breadcrumbCollector,brandColors:this.brandColors,shadow:()=>this.shadow,messages:()=>this.messages,user:()=>this.config.user},{isBackground:()=>this.state.kind==="submitting",onReleaseForFailureCard:()=>this.transitionTo(new W(this)),onReenterBackground:()=>this.transitionTo(new Yt(this)),onFinalized:(e,r)=>this.handleFinalized(e,r)});try{this.buildUI()}catch(e){this.consoleCollector.stop(),this.breadcrumbCollector.stop(),console.warn("[MakeThisBetter] Widget failed to start:",e);return}t.frustrationDetection!==!1&&(this.frustrationDetector=new mt(()=>this.handleFrustration()),this.frustrationDetector.start()),document.addEventListener("keydown",this.handleKeydown,!0)}transitionTo(t){const e=this.state;this.state=t,e.exit(),t.enter(),this.tab?.setActive(t.launcherLit)}buildUI(){if(this.shadow=new ht(this.config.theme??"auto",this.brandColors),this.config.entryMode==="api"){Kt()&&console.warn('[MakeThisBetter] entryMode: "api" renders no launcher. Call MakeThisBetter.open() from your own UI.');return}if(y()){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.shadow||(this.tab=new Re(this.shadow,this.messages,this.config.position??"right",()=>this.state.handleTabClick(),this.config.tabText,this.brandColors?void 0:this.config.tabColor))}open(){this.shadow&&this.state.handleOpen()}close(){this.state.handleClose()}showLauncher(){y()||(this.mountTab(),this.tab?.setActive(this.state.launcherLit))}hideLauncher(){this.tab?.destroy(),this.tab=null}setLocale(t){this.config.locale=t,this.messages=zt(t),this.tab?.setMessages(this.messages)}handleFrustration(){!this.state.acceptsFrustrationPrompt||this.frustrationPrompt||br()||(this.frustrationPrompt=new Fe(this.shadow,this.messages,{onTell:()=>{this.dismissFrustrationPrompt(),this.state.handleOpen()},onDismiss:()=>{mr(),this.dismissFrustrationPrompt()},onAutoHide:()=>this.dismissFrustrationPrompt()}))}dismissFrustrationPrompt(){this.frustrationPrompt?.destroy(),this.frustrationPrompt=null}hasAnnotationChrome(){return this.toolbar!==null}mountAnnotationChrome(){he();const t=y();this.toolbar=new Ue(this.shadow,this.messages,()=>this.exitAll(),e=>this.state.handleToolbarModeChange(e),this.config.position??"right",!t||!this.touchHintShown),t&&(this.touchHintShown=!0),this.ensureSession(),t&&this.toolbar&&this.pageOffset.reserve(this.toolbar.height())}ensureSession(){this.session||(this.session=new ri(this.shadow,this.messages,{onPin:(t,e)=>{this.currentAnnotation=t,this.via="pin",this.transitionTo(new Wt(this,{x:t.x,y:t.y,targetName:e,targetRect:t.targetRect}))},onDrawStroke:()=>this.state.handleDrawStroke()}))}destroySession(){this.session?.destroy(),this.session=null}clearCurrentAnnotation(){this.currentAnnotation=null}startRecorder(){this.recordingManager=new Vr,this.recordingManager.start(this.shadow,this.messages,this.stopRecordingIntoNote).catch(t=>{console.warn("[MakeThisBetter] Interaction replay unavailable, falling back to markup:",t),this.state.kind==="recording"&&(this.toolbar?.setMode("markup"),this.state.handleToolbarModeChange("markup"))})}destroyRecordingManager(){this.recordingManager?.destroy(),this.recordingManager=null}mountDrawBar(){this.drawBar=new li(this.shadow,{messages:this.messages,onUndo:()=>this.handleDrawUndoRedo("undo"),onRedo:()=>this.handleDrawUndoRedo("redo"),onCancel:()=>this.cancelDraw(),onSubmit:t=>this.handleDrawSubmit(t),onActivity:()=>this.lifecycle.beginBaseCapture()}),this.lifecycle.setScreenshotEnabled(!0),this.lifecycle.beginBaseCapture()}mountDrawSheet(){this.drawSheet=new _t(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(),onActivity:()=>this.lifecycle.beginBaseCapture(),position:this.config.position??"right"}),this.submittingUi=this.drawSheet,this.lifecycle.setScreenshotEnabled(!0),this.lifecycle.beginBaseCapture()}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.teardownDrawBar(),this.drawSheet?.destroy(),this.drawSheet=null,this.dim?.destroy(),this.dim=null,this.submittingUi=null,this.transitionTo(new k(this))}teardownDrawBar(){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.drawSheet,this.handleSubmit(t||this.messages.annotation.drawing)}mountNotePopup({x:t,y:e,targetName:r,targetRect:n}){this.lastPopupPos={x:t,y:e},this.teardownDrawBar(),this.session?.dismissInteraction(),this.pinPopup?.destroy(),this.pinPopup=null,this.dim?.destroy(),this.dim=null,this.dim=new Be(this.shadow,()=>this.exitAll());const s=this.recordingManager?.getRecording();s&&this.lifecycle.setScreenshotEnabled(!0),this.pinPopup=new _t(this.shadow,{targetName:r,x:t,y:e,targetRect:n,messages:this.messages,onSubmit:(o,a)=>this.handleSubmit(o,a),onClose:()=>this.exitAll(),onActivity:()=>this.lifecycle.beginBaseCapture(),onMyFeedback:this.buildMyFeedbackHandler(),...s?{recordingSeconds:s.duration}:{onScreenshotToggle:o=>this.lifecycle.setScreenshotEnabled(o),screenshotEnabled:this.lifecycle.isScreenshotEnabled()},position:this.config.position??"right"}),this.submittingUi=this.pinPopup,this.engageScrollLock(),this.lifecycle.beginBaseCapture()}dismissNotePopup(){this.pinPopup?.destroy(),this.pinPopup=null,this.dim?.destroy(),this.dim=null,this.releaseScrollLock(),this.submittingUi=null,this.clearCurrentAnnotation(),this.destroySession()}engageScrollLock(){this.scrollLock||(this.scrollLock=ze())}releaseScrollLock(){this.scrollLock?.release(),this.scrollLock=null}buildMyFeedbackHandler(){if(!this.config.user&&Lr())return async()=>{const t=await this.apiClient.createIdentityToken(we());!t?.identity_token||!t.board_url||(Nt(t.board_url),window.open(`${t.board_url}?identity=${encodeURIComponent(t.identity_token)}`,"_blank"))}}handleSubmit(t,e){if(!this.submittingUi)return;const r=this.currentAnnotation,n=this.recordingManager?.getRecording()??void 0,s=this.teardownSubmittingUi(!0),o=()=>this.lifecycle.start(t,r,n);this.transitionTo(new nn(this,this.lastPopupPos,{element:s,pendingSession:o(),onRetrySubmission:o,initiatingKeydown:e}))}teardownSubmittingUi(t=!1){const e=this.pinPopup??this.drawSheet,r=t?e?.releaseElement():void 0;return this.teardownDrawBar(),r||e?.destroy(),this.releaseScrollLock(),this.pinPopup=null,this.drawSheet=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,r}mountClarifyCard(t,e){this.clarify=new Hi(this.shadow,{apiClient:this.apiClient,messages:this.messages,element:e.element,position:this.config.position??"right",x:t?.x,y:t?.y,onFinalize:()=>this.lifecycle.finalize(),initiatingKeydown:e.initiatingKeydown,onSkip:()=>this.transitionTo(new Yt(this)),onCancel:()=>this.exitAll(),pendingSession:e.pendingSession,onRetrySubmission:e.onRetrySubmission})}revertToolbarDuringClarify(){this.toolbar?.setMode(this.via==="record"?"record":"markup")}releaseClarifyUi(){this.teardownToolbar(),this.currentAnnotation=null,this.clarify=null}handleFinalized(t,e){this.lastHandoff={feedbackId:t.id,boardUrl:t.board_url,identityToken:t.identity_token},t.board_url&&Nt(t.board_url),this.clarify?.destroy(),this.clarify=null,this.teardownToolbar(),this.lifecycle.resetScreenshotConsent(),this.showSuccess({skipFollowup:e.ai_clarify_available===!1})}showSuccess(t){this.lifecycle.dismissFinalizeFailure(),this.transitionTo(new W(this)),this.success=new Ni(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)&&!xe())return{onSubmit:async r=>{const n=await this.apiClient.updateReporter(t,r,e);return n&&Ar(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()=>{try{const r=await this.apiClient.resolveUserToken();r&&window.open(`${t}?identity=${encodeURIComponent(r)}`,"_blank")}catch{}}}}teardownToolbar(){this.pageOffset.release(),this.toolbar?.destroy(),this.toolbar=null}exitAll(){this.lifecycle.abandon(),this.via="pin",this.transitionTo(new W(this)),this.teardownToolbar(),this.teardownDrawBar(),this.releaseScrollLock(),this.session?.hideHighlight(),this.session?.destroy(),this.session=null,this.dim?.destroy(),this.dim=null,this.pinPopup?.destroy(),this.pinPopup=null,this.drawSheet?.destroy(),this.drawSheet=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.lifecycle.dismissFinalizeFailure(),this.tab?.destroy(),this.recordingManager?.destroy(),this.shadow?.destroy()}}let v=null,E=null,T=null;function ln(){T&&(document.removeEventListener("DOMContentLoaded",T),T=null)}function M(i){ln(),v?.destroy(),v=i?new an(i):null}const ke={init(i){typeof document>"u"||(M(),E=i,document.readyState==="loading"?(T=()=>{T=null,M(i)},document.addEventListener("DOMContentLoaded",T,{once:!0})):M(i))},destroy(){M(),E=null},setLocale(i){E&&(E.locale=i),v?.setLocale(i)},open(){v?.open()},close(){v?.close()},showLauncher(){v?.showLauncher()},hideLauncher(){v?.hideLauncher()}};typeof window<"u"&&(window.MakeThisBetter=ke,document.addEventListener("turbo:load",()=>{const i=document.getElementById(w);E&&(!i||!i.shadowRoot)&&(i?.remove(),M(E))}));exports.MakeThisBetter=ke;
|
|
173
173
|
//# sourceMappingURL=makethisbetter.cjs.map
|