makethisbetter 1.13.2 → 1.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/annotate/toolbar.d.ts +1 -1
- package/dist/annotate/toolbar.d.ts.map +1 -1
- package/dist/makethisbetter.cjs +4 -4
- package/dist/makethisbetter.cjs.map +1 -1
- package/dist/makethisbetter.esm.js +56 -52
- package/dist/makethisbetter.esm.js.map +1 -1
- package/dist/makethisbetter.js +4 -4
- package/dist/makethisbetter.js.map +1 -1
- package/dist/widget/controller.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/annotate/toolbar.ts +3 -1
- package/src/styles/widget.css +104 -39
- package/src/widget/controller.ts +4 -0
|
@@ -11,7 +11,7 @@ export declare class AnnotationToolbar {
|
|
|
11
11
|
private messages;
|
|
12
12
|
private currentMode;
|
|
13
13
|
private handlePointerMove;
|
|
14
|
-
constructor(shadow: ShadowContainer, messages: I18nMessages, onExit: () => void, onModeChange?: (mode: ToolbarMode) => void);
|
|
14
|
+
constructor(shadow: ShadowContainer, messages: I18nMessages, onExit: () => void, onModeChange?: (mode: ToolbarMode) => void, position?: 'left' | 'right');
|
|
15
15
|
private buildHTML;
|
|
16
16
|
setMode(mode: ToolbarMode): void;
|
|
17
17
|
getMode(): ToolbarMode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolbar.d.ts","sourceRoot":"","sources":["../../src/annotate/toolbar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAE7C,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,EAAE,CAAgB;IAI1B,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,WAAW,CAAwB;IAS3C,OAAO,CAAC,iBAAiB,CAQxB;gBAGC,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,MAAM,IAAI,EAClB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI;
|
|
1
|
+
{"version":3,"file":"toolbar.d.ts","sourceRoot":"","sources":["../../src/annotate/toolbar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAE7C,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,EAAE,CAAgB;IAI1B,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,IAAI,CAAa;IACzB,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,SAAS,CAAoB;IACrC,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,WAAW,CAAwB;IAS3C,OAAO,CAAC,iBAAiB,CAQxB;gBAGC,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,MAAM,IAAI,EAClB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,EAC1C,QAAQ,GAAE,MAAM,GAAG,OAAiB;IAwCtC,OAAO,CAAC,SAAS;IAmBjB,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAahC,OAAO,IAAI,WAAW;IAItB,OAAO,IAAI,IAAI;CAMhB"}
|
package/dist/makethisbetter.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";var Gt=Object.create;var it=Object.defineProperty;var Jt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var Zt=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var ee=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Qt(t))!te.call(i,n)&&n!==e&&it(i,n,{get:()=>t[n],enumerable:!(r=Jt(t,n))||r.enumerable});return i};var ie=(i,t,e)=>(e=i!=null?Gt(Zt(i)):{},ee(t||!i||!i.__esModule?it(e,"default",{value:i,enumerable:!0}):e,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=`*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}:host{all:initial;font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif;font-size:14px;line-height:1.5;color:#191a1c;-webkit-font-smoothing:antialiased}:host([data-mtb-theme="dark"]) .mtb-popup,:host([data-mtb-theme="dark"]) .mtb-success{background:#151719;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-popup-header{border-bottom-color:#ffffff1a}:host([data-mtb-theme="dark"]) .mtb-popup-title,:host([data-mtb-theme="dark"]) .mtb-success-title{color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-quick-option,:host([data-mtb-theme="dark"]) .mtb-textarea{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-popup-close,:host([data-mtb-theme="dark"]) .mtb-success-msg,:host([data-mtb-theme="dark"]) .mtb-close-link{color:#ffffffad}@media (prefers-color-scheme: dark){:host([data-mtb-theme="auto"]) .mtb-popup,:host([data-mtb-theme="auto"]) .mtb-success{background:#151719;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-popup-header{border-bottom-color:#ffffff1a}:host([data-mtb-theme="auto"]) .mtb-popup-title,:host([data-mtb-theme="auto"]) .mtb-success-title{color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-quick-option,:host([data-mtb-theme="auto"]) .mtb-textarea{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-popup-close,:host([data-mtb-theme="auto"]) .mtb-success-msg,:host([data-mtb-theme="auto"]) .mtb-close-link{color:#ffffffad}}.mtb-tab{--mtb-tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Ccircle cx='12' cy='12' r='2.4' fill='%23000' stroke='none'/%3E%3Cpath d='M12 1.8v3.4M12 18.8v3.4M1.8 12h3.4M18.8 12h3.4'/%3E%3C/svg%3E");position:fixed;top:50%;right:0;transform:translateY(-50%);z-index:2147483646;display:flex;align-items:center;justify-content:center;width:32px;padding:14px 0;background:#059669;color:#fff;border-radius:8px 0 0 8px;cursor:pointer;box-shadow:-2px 0 14px #05966959;transition:background .15s,box-shadow .15s,width .15s;writing-mode:vertical-lr;text-orientation:mixed;font-size:12px;font-weight:600;letter-spacing:.04em;user-select:none;border:none;outline:none}.mtb-tab.left{right:auto;left:0;border-radius:0 8px 8px 0;box-shadow:2px 0 14px #05966959}.mtb-tab:hover{background:#047857;box-shadow:-3px 0 20px #05966973}.mtb-tab.active{background:#065f46}.mtb-hint-bar{position:fixed;top:18px;left:50%;transform:translate(-50%);z-index:2147483647;display:flex;align-items:center;height:38px;padding:0 16px;border-radius:13px;background:linear-gradient(120deg,#10b981,#059669);box-shadow:0 10px 26px #0f172a38;animation:mtbHintIn .2s ease;white-space:nowrap;transition:opacity .15s ease;pointer-events:none}.mtb-hint-bar--under-pointer{opacity:.3}@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:stretch;gap:8px;width:40px;padding:7px 0;max-height:calc(100vh - 24px);border-radius:13px;background:linear-gradient(120deg,#10b981,#059669);box-shadow:0 10px 26px #0f172a38;animation:mtbBarIn .2s ease;white-space:nowrap;pointer-events:none}.mtb-toolbar-modes{flex-direction:column}.mtb-toolbar-mode-btn,.mtb-exit-btn{pointer-events:auto;display:flex;align-items:center;justify-content:center;width:100%;height:34px;padding:0}.mtb-toolbar-label{display:none}@keyframes mtbBarIn{0%{transform:translate(12px,-50%);opacity:0}to{transform:translateY(-50%);opacity:1}}:host([data-mtb-toolbar]) .mtb-tab{display:none}.mtb-toolbar-modes{display:flex;align-items:center;gap:3px;background:#ffffff29;border-radius:9px;padding:3px}.mtb-toolbar-mode-btn{display:inline-flex;align-items:center;gap:6px;height:30px;padding:0 12px;border-radius:7px;border:none;cursor:pointer;font-family:inherit;font-size:12px;font-weight:550;white-space:nowrap;background:transparent;color:#fffffff2;transition:all .12s}.mtb-toolbar-mode-btn.active{background:#fff;color:#047857}.mtb-toolbar-hint{font-size:12px;color:#fffffff2;white-space:nowrap}.mtb-toolbar-sep{width:20px;height:1px;align-self:center;background:#ffffff38}.mtb-exit-btn{display:inline-flex;align-items:center;gap:5px;height:30px;padding:0 12px;border-radius:8px;font-size:11.5px;font-weight:500;color:#fff;cursor:pointer;background:#ffffff29;border:none;font-family:inherit;transition:background .12s}.mtb-exit-btn:hover{background:#ffffff47}.mtb-overlay{position:fixed;inset:0;z-index:2147483640;cursor:crosshair;touch-action:none}.mtb-dim{position:fixed;inset:0;z-index:2147483639;background:#00000014}.mtb-highlight{position:fixed;z-index:2147483641;pointer-events:none;border:2px solid #10b981;border-radius:6px;background:#10b9810f;transition:all .08s ease}.mtb-highlight.selected{border-color:#3b82f6;background:#3b82f60a}.mtb-highlight-tooltip{position:fixed;z-index:2147483642;pointer-events:none;transform:translate(-50%,-100%);max-width:240px;overflow:hidden;text-overflow:ellipsis;background:#064e3b;color:#fff;padding:4px 10px;border-radius:6px;font-size:11px;font-weight:500;white-space:nowrap;box-shadow:0 4px 12px #0000002e;font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif}.mtb-highlight-tooltip.below{transform:translate(-50%)}.mtb-highlight-tooltip:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);border:4px solid transparent;border-top-color:#064e3b}.mtb-highlight-tooltip.below:after{top:auto;bottom:100%;border-top-color:transparent;border-bottom-color:#064e3b}.mtb-draw-svg{position:fixed;inset:0;z-index:2147483643;pointer-events:none;width:100%;height:100%;overflow:visible}.mtb-pin{position:fixed;z-index:2147483644;pointer-events:none;width:22px;height:22px;border-radius:50% 50% 50% 2px;background:#059669;border:2px solid #fff;display:flex;align-items:center;justify-content:center;font-size:10px;color:#fff;font-weight:700;box-shadow:0 2px 8px #05966973;animation:mtbPinPop .25s cubic-bezier(.34,1.56,.64,1);transform:translate(-50%,-50%)}@keyframes mtbPinPop{0%{transform:translate(-50%,-50%) scale(.4)}to{transform:translate(-50%,-50%) scale(1)}}.mtb-popup{position:fixed;z-index:2147483645;display:flex;flex-direction:column;width:min(320px,calc(100vw - 56px));background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:16px;box-shadow:0 24px 64px #0000003d;overflow:hidden;animation:mtbSlideUp .28s cubic-bezier(.34,1.56,.64,1);font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif}@keyframes mtbSlideUp{0%{transform:translateY(14px) scale(.97);opacity:0}to{transform:translateY(0) scale(1);opacity:1}}.mtb-popup-header{flex-shrink:0;padding:11px 13px 11px 14px;border-bottom:1px solid rgba(0,0,0,.06);display:flex;align-items:center;gap:8px}.mtb-popup-icon{width:20px;height:20px;border-radius:5px;background:#10b9811a;display:flex;align-items:center;justify-content:center;flex-shrink:0}.mtb-popup-title{flex:1;font-size:12.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#191a1c}.mtb-popup-close{background:none;border:none;cursor:pointer;padding:3px;color:#00000061;display:flex;align-items:center;border-radius:4px;transition:color .12s}.mtb-popup-close:hover{color:#000000b3}.mtb-popup-body{min-height:0;padding:13px;overflow-y:auto;overscroll-behavior:contain}.mtb-quick-options{display:flex;flex-direction:column;gap:6px;margin-bottom:12px}.mtb-quick-option{display:flex;align-items:center;gap:10px;width:100%;padding:10px 12px;border:1px solid rgba(0,0,0,.09);border-radius:10px;background:#fafafa;cursor:pointer;font-family:inherit;font-size:13px;color:#191a1c;text-align:left;transition:all .12s}.mtb-quick-option:hover{background:#10b9810f;border-color:#10b9814d}.mtb-quick-option.selected{background:#10b9811a;border-color:#10b98180}.mtb-quick-option-emoji{font-size:15px;flex-shrink:0;line-height:1}.mtb-textarea-wrap{position:relative}.mtb-textarea{width:100%;height:64px;padding:9px 11px;border:1px solid rgba(0,0,0,.12);border-radius:10px;font-family:inherit;font-size:12.5px;line-height:1.5;color:#191a1c;outline:none;background:#fff;resize:none;transition:border-color .12s,box-shadow .12s}.mtb-textarea:focus{border-color:#10b981;box-shadow:0 0 0 3px #10b98126}.mtb-textarea::placeholder{color:#00000057}.mtb-popup-error{margin-top:8px;color:#dc2626;font-size:11.5px}.mtb-popup-error:empty,.mtb-popup-error[hidden]{display:none}.mtb-popup-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:12px}.mtb-cancel-btn,.mtb-submit-btn{min-width:72px;height:32px;border:none;border-radius:8px;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0 12px;font-family:inherit;font-size:12.5px;font-weight:600;transition:background .12s}.mtb-cancel-btn{background:#f3f4f6;color:#000000ad}.mtb-cancel-btn:hover{background:#e5e7eb}.mtb-submit-btn{background:#d1d5db;color:#fff}.mtb-submit-btn.ready{background:#059669}.mtb-submit-btn.ready:hover{background:#047857}.mtb-submit-btn.loading{background:#059669;opacity:.7;cursor:wait}.mtb-submit-btn:disabled{cursor:not-allowed}.mtb-success{position:fixed;z-index:2147483645;width:332px;background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:16px;box-shadow:0 24px 64px #0000003d;padding:24px 22px;text-align:center;animation:mtbSlideUp .35s cubic-bezier(.34,1.56,.64,1);font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif}.mtb-success-icon{width:46px;height:46px;border-radius:50%;background:#05966917;display:flex;align-items:center;justify-content:center;margin:0 auto 12px}.mtb-success-title{font-size:16px;font-weight:700;margin-bottom:5px;letter-spacing:-.01em;color:#191a1c}.mtb-success-msg{font-size:13px;color:#0000008c;margin-bottom:16px;line-height:1.6}.mtb-view-feedback-link{display:inline-flex;align-items:center;gap:5px;color:#047857;text-decoration:none;font-size:13px;font-weight:500;font-family:JetBrains Mono,monospace;background:none;border:none;cursor:pointer;transition:text-decoration .12s}.mtb-view-feedback-link:hover{text-decoration:underline}.mtb-close-link{margin-top:13px;background:none;border:none;cursor:pointer;font-size:12px;color:#0006;font-family:inherit;transition:color .12s}.mtb-close-link:hover{color:#000000b3}.mtb-email-capture{margin-bottom:14px;text-align:left}.mtb-email-prompt{font-size:12px;color:#0000008c;line-height:1.5;margin-bottom:8px}.mtb-email-row{display:flex;gap:6px}.mtb-email-input{flex:1;min-width:0;font-size:12.5px;font-family:inherit;padding:7px 10px;border:1px solid rgba(0,0,0,.14);border-radius:8px;outline:none}.mtb-email-input:focus{border-color:#059669}.mtb-email-input.mtb-email-invalid{border-color:#dc2626}.mtb-email-submit{font-size:12px;font-weight:600;font-family:inherit;color:#fff;background:#059669;border:none;border-radius:8px;padding:7px 12px;cursor:pointer;white-space:nowrap}.mtb-email-submit:disabled{opacity:.6;cursor:default}.mtb-email-error{font-size:11.5px;color:#dc2626;margin-top:6px}.mtb-email-saved{font-size:12px;color:#059669;line-height:1.5}.mtb-my-feedback{display:block;margin:8px auto 0;background:none;border:none;cursor:pointer;font-size:11.5px;font-family:inherit;color:#0006;text-decoration:underline;text-underline-offset:2px;transition:color .12s}.mtb-my-feedback:hover{color:#059669}.mtb-pet{position:fixed;bottom:20px;right:20px;z-index:2147483646;cursor:pointer;width:52px;height:52px;display:flex;align-items:center;justify-content:center;border-radius:50%;background:transparent;animation:mtbPetBounce 3s ease-in-out infinite;transition:transform .2s;user-select:none;outline:none;filter:drop-shadow(0 4px 12px rgba(5,150,105,.35))}.mtb-pet:hover{transform:scale(1.12);animation-play-state:paused}.mtb-pet:hover .mtb-pet-bubble{opacity:1;transform:translate(-50%) translateY(0);pointer-events:auto}.mtb-pet.active{animation:none;opacity:.6}.mtb-pet-svg{display:block}@keyframes mtbPetBounce{0%,to{transform:translateY(0)}50%{transform:translateY(-6px)}}.mtb-pet-bubble{position:absolute;bottom:100%;left:50%;transform:translate(-50%) translateY(4px);margin-bottom:8px;background:#064e3b;color:#fff;padding:6px 12px;border-radius:8px;font-size:12px;font-weight:500;white-space:nowrap;box-shadow:0 4px 14px #0000002e;opacity:0;pointer-events:none;transition:opacity .2s,transform .2s}.mtb-pet-bubble.visible{opacity:1;transform:translate(-50%) translateY(0);pointer-events:auto}.mtb-pet-bubble.hidden{opacity:0;pointer-events:none}.mtb-pet-bubble:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);border:5px solid transparent;border-top-color:#064e3b}.mtb-frustration-prompt{position:fixed;bottom:20px;right:20px;z-index:2147483645;display:flex;align-items:center;gap:10px;padding:12px 16px;background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:12px;box-shadow:0 8px 30px #0000001f;animation:mtbSlideUp .35s cubic-bezier(.34,1.56,.64,1);font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif}:host([data-mtb-theme="dark"]) .mtb-frustration-prompt{background:#151719;border-color:#ffffff1f;color:#f9fafb}@media (prefers-color-scheme: dark){:host([data-mtb-theme="auto"]) .mtb-frustration-prompt{background:#151719;border-color:#ffffff1f;color:#f9fafb}}.mtb-frustration-icon{width:32px;height:32px;border-radius:50%;background:#eab3081a;display:flex;align-items:center;justify-content:center;flex-shrink:0;font-size:16px;line-height:1}.mtb-frustration-text{font-size:13px;font-weight:500;color:inherit;line-height:1.4}.mtb-frustration-actions{display:flex;gap:6px;flex-shrink:0}.mtb-frustration-tell{height:28px;padding:0 12px;border:none;border-radius:7px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12px;font-weight:600;transition:background .12s}.mtb-frustration-tell:hover{background:#047857}.mtb-frustration-dismiss{height:28px;padding:0 8px;border:none;border-radius:7px;background:transparent;color:#0006;cursor:pointer;font-family:inherit;font-size:12px;transition:color .12s}.mtb-frustration-dismiss:hover{color:#000000b3}:host([data-mtb-theme="dark"]) .mtb-frustration-dismiss{color:#fff6}:host([data-mtb-theme="dark"]) .mtb-frustration-dismiss:hover{color:#ffffffb3}@media (prefers-color-scheme: dark){:host([data-mtb-theme="auto"]) .mtb-frustration-dismiss{color:#fff6}:host([data-mtb-theme="auto"]) .mtb-frustration-dismiss:hover{color:#ffffffb3}}.mtb-record-bar{position:fixed;bottom: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:#ef4444;animation:mtbRecordPulse 1.2s ease-in-out infinite;flex-shrink:0}@keyframes mtbRecordPulse{0%,to{opacity:1}50%{opacity:.3}}.mtb-record-timer{font-family:JetBrains Mono,SF Mono,Fira Code,Cascadia Code,monospace;font-size:13px;font-weight:500;color:#fff;font-variant-numeric:tabular-nums;letter-spacing:.02em;min-width:38px}.mtb-record-stop{height:28px;padding:0 14px;border:none;border-radius:7px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12px;font-weight:600;transition:background .12s}.mtb-record-stop:hover{background:#047857}.mtb-click-ripple{position:fixed;z-index:2147483644;width:24px;height:24px;border-radius:50%;border:2px solid #10b981;background:#10b98133;pointer-events:none;transform:translate(-50%,-50%) scale(.5);animation:mtbClickRipple .3s ease-out forwards}@keyframes mtbClickRipple{0%{transform:translate(-50%,-50%) scale(.5);opacity:1}to{transform:translate(-50%,-50%) scale(2);opacity:0}}.mtb-dot{display:inline-block;width:4px;height:4px;border-radius:50%;background:#fff;animation:mtbDot 1.2s infinite}.mtb-dot:nth-child(2){animation-delay:.2s}.mtb-dot:nth-child(3){animation-delay:.4s}@keyframes mtbDot{0%,80%,to{opacity:.3;transform:translateY(0)}40%{opacity:1;transform:translateY(-3px)}}.mtb-clarify{position:fixed;z-index:2147483645;width:min(346px,calc(100vw - 56px));background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:16px;box-shadow:0 24px 64px #0000003d;display:flex;flex-direction:column;animation:mtbSlideUp .28s cubic-bezier(.34,1.56,.64,1);font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif;overflow:hidden}.mtb-clarify-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 rgba(0,0,0,.06)}.mtb-clarify-icon{width:20px;height:20px;border-radius:6px;background:linear-gradient(140deg,#10b981,#059669);box-shadow:0 1px 3px #05966966;display:flex;align-items:center;justify-content:center;flex-shrink:0}.mtb-clarify-titles{flex:1;min-width:0}.mtb-clarify-title{font-size:12px;font-weight:650;line-height:1.2;color:#191a1c}.mtb-clarify-subtitle{font-size:9.5px;color:#0000006b}.mtb-clarify-close{background:none;border:none;cursor:pointer;padding:3px;color:#00000061;display:flex;transition:color .12s}.mtb-clarify-close:hover{color:#000000b3}.mtb-clarify-messages{flex:1;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:#fff;color:#191a1c;border:1px solid rgba(0,0,0,.09);border-radius:11px 11px 11px 3px}.mtb-clarify-user{align-self:flex-end;background:#059669;color:#fff;border:1px solid #059669;border-radius:11px 11px 3px}.mtb-clarify-thinking{display:flex;align-items:center;gap:4px;padding:8px 12px}.mtb-clarify-thinking .mtb-dot{width:6px;height:6px;background:#059669b3}.mtb-clarify-footer{padding:3px 10px 10px;display:flex;flex-direction:column}.mtb-clarify-input{width:100%;height:40px;padding:7px 10px;border:1px solid rgba(0,0,0,.12);border-radius:8px;font-family:inherit;font-size:12px;line-height:1.4;color:#191a1c;outline:none;background:#fafafa;resize:none;box-sizing:border-box;transition:border-color .12s,box-shadow .12s,background .12s}.mtb-clarify-input:focus{border-color:#10b981;box-shadow:0 0 0 3px #10b98126;background:#fff}.mtb-clarify-input::placeholder{color:#00000057}.mtb-clarify-actions{display:flex;gap:6px;margin-top:6px}.mtb-clarify-skip,.mtb-clarify-fallback{flex:0 0 auto;height:30px;padding:0 12px;border:1px solid rgba(0,0,0,.12);border-radius:8px;background:#fff;cursor:pointer;font-family:inherit;font-size:12px;font-weight:550;color:#0000008c;white-space:nowrap;transition:background .12s}.mtb-clarify-skip:hover,.mtb-clarify-fallback:hover{background:#0000000a}.mtb-clarify-send,.mtb-clarify-retry{flex:1;height:30px;display:inline-flex;align-items:center;justify-content:center;gap:5px;border:none;border-radius:8px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12px;font-weight:600;transition:background .12s}.mtb-clarify-send:not(:disabled):hover,.mtb-clarify-retry:not(:disabled):hover{background:#047857}.mtb-clarify-send:disabled,.mtb-clarify-retry:disabled{background:#00000026;cursor:not-allowed}.mtb-clarify-send-feedback{width:100%;height:34px;display:inline-flex;align-items:center;justify-content:center;gap:6px;border:none;border-radius:9px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:600;transition:background .12s}.mtb-clarify-send-feedback:not(:disabled):hover{background:#047857}.mtb-clarify-send-feedback:disabled{background:#00000026;cursor:not-allowed}.mtb-clarify-error{margin-bottom:8px;color:#dc2626;font-size:11.5px;line-height:1.4;text-align:center}:host([data-mtb-theme="dark"]) .mtb-clarify{background:#151719;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-clarify-header{border-bottom-color:#ffffff1a}:host([data-mtb-theme="dark"]) .mtb-clarify-title{color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-clarify-subtitle{color:#ffffff73}:host([data-mtb-theme="dark"]) .mtb-clarify-close{color:#ffffff73}:host([data-mtb-theme="dark"]) .mtb-clarify-close:hover{color:#ffffffbf}:host([data-mtb-theme="dark"]) .mtb-clarify-skip,:host([data-mtb-theme="dark"]) .mtb-clarify-fallback{background:#1f2327;border-color:#ffffff24;color:#ffffffb3}:host([data-mtb-theme="dark"]) .mtb-clarify-skip:hover,:host([data-mtb-theme="dark"]) .mtb-clarify-fallback:hover{background:#ffffff0f}:host([data-mtb-theme="dark"]) .mtb-clarify-ai{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-clarify-input{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}@media (prefers-color-scheme: dark){:host([data-mtb-theme="auto"]) .mtb-clarify{background:#151719;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-clarify-header{border-bottom-color:#ffffff1a}:host([data-mtb-theme="auto"]) .mtb-clarify-title{color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-clarify-subtitle{color:#ffffff73}:host([data-mtb-theme="auto"]) .mtb-clarify-close{color:#ffffff73}:host([data-mtb-theme="auto"]) .mtb-clarify-close:hover{color:#ffffffbf}:host([data-mtb-theme="auto"]) .mtb-clarify-skip,:host([data-mtb-theme="auto"]) .mtb-clarify-fallback{background:#1f2327;border-color:#ffffff24;color:#ffffffb3}:host([data-mtb-theme="auto"]) .mtb-clarify-skip:hover,:host([data-mtb-theme="auto"]) .mtb-clarify-fallback:hover{background:#ffffff0f}:host([data-mtb-theme="auto"]) .mtb-clarify-ai{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-clarify-input{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}}.mtb-dim-clickable{z-index:2147483643;pointer-events:auto;cursor:default;background:#0000001f}.mtb-draw-bar{position:fixed;bottom:48px;left:50%;transform:translate(-50%);z-index:2147483647;display:flex;align-items:center;gap:8px;height:46px;padding:0 8px 0 12px;border-radius:13px;background:#fff;border:1px solid rgba(0,0,0,.08);box-shadow:0 10px 30px #0f172a38;animation:mtbBarIn .2s ease;font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif}.mtb-draw-input{width:220px;height:32px;padding:0 10px;border:1px solid rgba(0,0,0,.12);border-radius:8px;font-family:inherit;font-size:13px;color:#191a1c;outline:none;background:#fafafa;transition:border-color .12s,box-shadow .12s,background .12s}.mtb-draw-input:focus{border-color:#10b981;box-shadow:0 0 0 3px #10b98126;background:#fff}.mtb-draw-input::placeholder{color:#00000057}.mtb-draw-icon-btn{width:30px;height:30px;display:inline-flex;align-items:center;justify-content:center;border:none;border-radius:8px;background:transparent;color:#374151;cursor:pointer;transition:background .12s,color .12s}.mtb-draw-icon-btn:hover:not(:disabled){background:#0000000f}.mtb-draw-icon-btn:disabled{color:#00000038;cursor:default}.mtb-draw-sep{width:1px;height:22px;background:#0000001a}.mtb-draw-cancel{height:32px;padding:0 12px;border:1px solid rgba(0,0,0,.12);border-radius:8px;background:#fff;color:#0000008c;cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:550;transition:background .12s}.mtb-draw-cancel:hover{background:#0000000a}.mtb-draw-submit{height:32px;padding:0 14px;border:none;border-radius:8px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:600;transition:background .12s}.mtb-draw-submit:hover:not(:disabled){background:#047857}.mtb-draw-submit:disabled{opacity:.6;cursor:default}.mtb-draw-error{position:absolute;bottom:100%;left:12px;margin-bottom:6px;color:#dc2626;font-size:11.5px}.mtb-record-preview{margin-bottom:12px}.mtb-record-preview-stage{position:relative;width:100%;height:132px;border-radius:10px;overflow:hidden;background:#0f172a;display:flex;align-items:center;justify-content:center}.mtb-record-preview-stage.playing{align-items:flex-start;justify-content:flex-start}.mtb-record-preview-play{width:44px;height:44px;border-radius:50%;border:none;background:#ffffffeb;color:#059669;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:transform .12s,background .12s}.mtb-record-preview-play:hover:not(:disabled){transform:scale(1.06);background:#fff}.mtb-record-preview-play:disabled{cursor:default;opacity:.6}.mtb-record-preview-badge{position:absolute;right:8px;bottom:8px;padding:2px 7px;border-radius:6px;background:#0009;color:#fff;font-size:11px;font-variant-numeric:tabular-nums;font-family:JetBrains Mono,SF Mono,monospace}.mtb-record-preview-fallback{color:#ffffffd9;font-size:12px}.mtb-record-preview-name{display:block;margin-top:5px;font-size:11px;color:#0000006b}@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:6px;justify-content:center;padding:env(safe-area-inset-top,0px) 8px 0;height:calc(56px + env(safe-area-inset-top,0px));animation:mtbBarInMobile .2s ease}.mtb-toolbar-modes{flex-direction:row}.mtb-hint-bar,.mtb-toolbar-sep{display:none}.mtb-toolbar-mode-btn,.mtb-exit-btn{width:auto;height:auto;gap:6px;padding-right:10px;padding-left:10px}.mtb-toolbar-label{display:inline}:host([data-mtb-toolbar]) .mtb-tab{display:flex}.mtb-popup{inset:auto 0 0;width:auto;max-height:85%;border-radius:20px 20px 0 0;animation:mtbSheetUp .28s cubic-bezier(.34,1.56,.64,1)}.mtb-popup-actions{padding-bottom:calc(12px + env(safe-area-inset-bottom,0px))}.mtb-clarify{inset:auto 0 0;width:auto;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}}@keyframes mtbBarInMobile{0%{transform:translateY(-14px);opacity:0}to{transform:translateY(0);opacity:1}}@keyframes mtbSheetUp{0%{transform:translateY(100%)}to{transform:translateY(0)}}`;class ne{constructor(t="auto"){this.host=document.createElement("div"),this.host.id="mtb-widget-host",this.host.style.cssText="position:fixed;top:0;left:0;width:0;height:0;overflow:visible;z-index:2147483646;",this.host.setAttribute("data-mtb-theme",t),document.body.appendChild(this.host),this.root=this.host.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=re,this.root.appendChild(e)}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(){this.host.remove()}}class se{constructor(t,e,r,n,s){this.active=!1,this.onClick=n,this.customText=s,this.el=t.el("button","mtb-tab"),r==="left"&&this.el.classList.add("left"),this.idleLabel=s??e.tab,this.activeLabel=e.toolbar.exit,this.setLabel(this.idleLabel),this.el.addEventListener("click",n),t.append(this.el)}setLabel(t){this.el.textContent=t,this.el.setAttribute("aria-label",t)}setMessages(t){this.idleLabel=this.customText??t.tab,this.activeLabel=t.toolbar.exit,this.setLabel(this.active?this.activeLabel:this.idleLabel)}setActive(t){this.active=t,this.el.classList.toggle("active",t),this.setLabel(t?this.activeLabel:this.idleLabel)}destroy(){this.el.removeEventListener("click",this.onClick),this.el.remove()}}const oe=8e3;class ae{constructor(t,e,r){this.autoHideTimer=null,this.el=t.el("div","mtb-frustration-prompt"),this.el.innerHTML=`
|
|
1
|
+
"use strict";var Gt=Object.create;var it=Object.defineProperty;var Jt=Object.getOwnPropertyDescriptor;var Qt=Object.getOwnPropertyNames;var Zt=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty;var ee=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Qt(t))!te.call(i,n)&&n!==e&&it(i,n,{get:()=>t[n],enumerable:!(r=Jt(t,n))||r.enumerable});return i};var ie=(i,t,e)=>(e=i!=null?Gt(Zt(i)):{},ee(t||!i||!i.__esModule?it(e,"default",{value:i,enumerable:!0}):e,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=`*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}:host{all:initial;font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif;font-size:14px;line-height:1.5;color:#191a1c;-webkit-font-smoothing:antialiased}:host([data-mtb-theme="dark"]) .mtb-popup,:host([data-mtb-theme="dark"]) .mtb-success{background:#151719;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-popup-header{border-bottom-color:#ffffff1a}:host([data-mtb-theme="dark"]) .mtb-popup-title,:host([data-mtb-theme="dark"]) .mtb-success-title{color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-quick-option,:host([data-mtb-theme="dark"]) .mtb-textarea{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-popup-close,:host([data-mtb-theme="dark"]) .mtb-success-msg,:host([data-mtb-theme="dark"]) .mtb-close-link{color:#ffffffad}@media (prefers-color-scheme: dark){:host([data-mtb-theme="auto"]) .mtb-popup,:host([data-mtb-theme="auto"]) .mtb-success{background:#151719;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-popup-header{border-bottom-color:#ffffff1a}:host([data-mtb-theme="auto"]) .mtb-popup-title,:host([data-mtb-theme="auto"]) .mtb-success-title{color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-quick-option,:host([data-mtb-theme="auto"]) .mtb-textarea{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-popup-close,:host([data-mtb-theme="auto"]) .mtb-success-msg,:host([data-mtb-theme="auto"]) .mtb-close-link{color:#ffffffad}}.mtb-tab{--mtb-tab-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Ccircle cx='12' cy='12' r='2.4' fill='%23000' stroke='none'/%3E%3Cpath d='M12 1.8v3.4M12 18.8v3.4M1.8 12h3.4M18.8 12h3.4'/%3E%3C/svg%3E");position:fixed;top:50%;right:0;transform:translateY(-50%);z-index:2147483646;display:flex;align-items:center;justify-content:center;width:32px;padding:14px 0;background:#059669;color:#fff;border-radius:8px 0 0 8px;cursor:pointer;box-shadow:-2px 0 14px #05966959;transition:background .15s,box-shadow .15s,width .15s;writing-mode:vertical-lr;text-orientation:mixed;font-size:12px;font-weight:600;letter-spacing:.04em;user-select:none;border:none;outline:none}.mtb-tab.left{right:auto;left:0;border-radius:0 8px 8px 0;box-shadow:2px 0 14px #05966959}.mtb-tab:hover{background:#047857;box-shadow:-3px 0 20px #05966973}.mtb-tab.active{background:#065f46}.mtb-hint-bar{position:fixed;top:18px;left:50%;transform:translate(-50%);z-index:2147483647;display:flex;align-items:center;height:38px;padding:0 16px;border-radius:13px;background:linear-gradient(120deg,#10b981,#059669);box-shadow:0 10px 26px #0f172a38;animation:mtbHintIn .2s ease;white-space:nowrap;transition:opacity .15s ease;pointer-events:none}.mtb-hint-bar--under-pointer{opacity:.3}@keyframes mtbHintIn{0%{transform:translate(-50%,12px);opacity:0}to{transform:translate(-50%);opacity:1}}.mtb-toolbar{position:fixed;top:50%;right:8px;transform:translateY(-50%);z-index:2147483647;display:flex;flex-direction:column;align-items:center;gap:6px;width:38px;padding:6px 0;max-height:calc(100vh - 24px);border-radius:19px;background:linear-gradient(160deg,#10b981,#059669);box-shadow:0 8px 22px #0f172a33;animation:mtbEdgeBarIn .2s ease;white-space:nowrap;pointer-events:none}.mtb-toolbar.left{right:auto;left:8px;animation:mtbEdgeBarInLeft .2s ease}@keyframes mtbBarIn{0%{transform:translate(-50%,12px);opacity:0}to{transform:translate(-50%);opacity:1}}@keyframes mtbEdgeBarIn{0%{transform:translate(12px,-50%);opacity:0}to{transform:translateY(-50%);opacity:1}}@keyframes mtbEdgeBarInLeft{0%{transform:translate(-12px,-50%);opacity:0}to{transform:translateY(-50%);opacity:1}}.mtb-toolbar-label{display:none}:host([data-mtb-toolbar]) .mtb-tab{display:none}.mtb-toolbar-modes{display:flex;align-items:center;gap:3px;background:#ffffff29;border-radius:9px;padding:3px}.mtb-toolbar-mode-btn{display:inline-flex;align-items:center;gap:6px;height:30px;padding:0 12px;border-radius:7px;border:none;cursor:pointer;font-family:inherit;font-size:12px;font-weight:550;white-space:nowrap;background:transparent;color:#fffffff2;transition:all .12s}.mtb-toolbar-mode-btn.active{background:#fff;color:#047857}.mtb-toolbar-hint{font-size:12px;color:#fffffff2;white-space:nowrap}.mtb-toolbar-sep{width:20px;height:1px;align-self:center;background:#ffffff38}.mtb-exit-btn{display:inline-flex;align-items:center;gap:5px;height:30px;padding:0 12px;border-radius:8px;font-size:11.5px;font-weight:500;color:#fff;cursor:pointer;background:#ffffff29;border:none;font-family:inherit;transition:background .12s}.mtb-toolbar-modes{flex-direction:column;gap:6px;padding:0;background:none;border-radius:0}.mtb-toolbar-mode-btn,.mtb-exit-btn{pointer-events:auto;display:flex;align-items:center;justify-content:center;gap:0;width:30px;height:30px;padding:0;border-radius:50%;background:none;color:#ffffffb8}.mtb-toolbar-mode-btn:hover,.mtb-exit-btn:hover{background:#ffffff29;color:#fff}.mtb-toolbar-mode-btn.active,.mtb-toolbar-mode-btn.active:hover{background:#fff;color:#047857}.mtb-exit-btn{color:#fff}.mtb-toolbar-sep{width:16px;height:1px;margin:1px 0;align-self:center;background:#ffffff47}.mtb-exit-btn:hover{background:#ffffff47}.mtb-overlay{position:fixed;inset:0;z-index:2147483640;cursor:crosshair;touch-action:none}.mtb-dim{position:fixed;inset:0;z-index:2147483639;background:#00000014}.mtb-highlight{position:fixed;z-index:2147483641;pointer-events:none;border:2px solid #10b981;border-radius:6px;background:#10b9810f;transition:all .08s ease}.mtb-highlight.selected{border-color:#3b82f6;background:#3b82f60a}.mtb-highlight-tooltip{position:fixed;z-index:2147483642;pointer-events:none;transform:translate(-50%,-100%);max-width:240px;overflow:hidden;text-overflow:ellipsis;background:#064e3b;color:#fff;padding:4px 10px;border-radius:6px;font-size:11px;font-weight:500;white-space:nowrap;box-shadow:0 4px 12px #0000002e;font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif}.mtb-highlight-tooltip.below{transform:translate(-50%)}.mtb-highlight-tooltip:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);border:4px solid transparent;border-top-color:#064e3b}.mtb-highlight-tooltip.below:after{top:auto;bottom:100%;border-top-color:transparent;border-bottom-color:#064e3b}.mtb-draw-svg{position:fixed;inset:0;z-index:2147483643;pointer-events:none;width:100%;height:100%;overflow:visible}.mtb-pin{position:fixed;z-index:2147483644;pointer-events:none;width:22px;height:22px;border-radius:50% 50% 50% 2px;background:#059669;border:2px solid #fff;display:flex;align-items:center;justify-content:center;font-size:10px;color:#fff;font-weight:700;box-shadow:0 2px 8px #05966973;animation:mtbPinPop .25s cubic-bezier(.34,1.56,.64,1);transform:translate(-50%,-50%)}@keyframes mtbPinPop{0%{transform:translate(-50%,-50%) scale(.4)}to{transform:translate(-50%,-50%) scale(1)}}.mtb-popup{position:fixed;z-index:2147483645;display:flex;flex-direction:column;width:min(320px,calc(100vw - 56px));background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:16px;box-shadow:0 24px 64px #0000003d;overflow:hidden;animation:mtbSlideUp .28s cubic-bezier(.34,1.56,.64,1);font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif}@keyframes mtbSlideUp{0%{transform:translateY(14px) scale(.97);opacity:0}to{transform:translateY(0) scale(1);opacity:1}}.mtb-popup-header{flex-shrink:0;padding:11px 13px 11px 14px;border-bottom:1px solid rgba(0,0,0,.06);display:flex;align-items:center;gap:8px}.mtb-popup-icon{width:20px;height:20px;border-radius:5px;background:#10b9811a;display:flex;align-items:center;justify-content:center;flex-shrink:0}.mtb-popup-title{flex:1;font-size:12.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#191a1c}.mtb-popup-close{background:none;border:none;cursor:pointer;padding:3px;color:#00000061;display:flex;align-items:center;border-radius:4px;transition:color .12s}.mtb-popup-close:hover{color:#000000b3}.mtb-popup-body{min-height:0;padding:13px;overflow-y:auto;overscroll-behavior:contain}.mtb-quick-options{display:flex;flex-direction:column;gap:6px;margin-bottom:12px}.mtb-quick-option{display:flex;align-items:center;gap:10px;width:100%;padding:10px 12px;border:1px solid rgba(0,0,0,.09);border-radius:10px;background:#fafafa;cursor:pointer;font-family:inherit;font-size:13px;color:#191a1c;text-align:left;transition:all .12s}.mtb-quick-option:hover{background:#10b9810f;border-color:#10b9814d}.mtb-quick-option.selected{background:#10b9811a;border-color:#10b98180}.mtb-quick-option-emoji{font-size:15px;flex-shrink:0;line-height:1}.mtb-textarea-wrap{position:relative}.mtb-textarea{width:100%;height:64px;padding:9px 11px;border:1px solid rgba(0,0,0,.12);border-radius:10px;font-family:inherit;font-size:12.5px;line-height:1.5;color:#191a1c;outline:none;background:#fff;resize:none;transition:border-color .12s,box-shadow .12s}.mtb-textarea:focus{border-color:#10b981;box-shadow:0 0 0 3px #10b98126}.mtb-textarea::placeholder{color:#00000057}.mtb-popup-error{margin-top:8px;color:#dc2626;font-size:11.5px}.mtb-popup-error:empty,.mtb-popup-error[hidden]{display:none}.mtb-popup-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:12px}.mtb-cancel-btn,.mtb-submit-btn{min-width:72px;height:32px;border:none;border-radius:8px;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0 12px;font-family:inherit;font-size:12.5px;font-weight:600;transition:background .12s}.mtb-cancel-btn{background:#f3f4f6;color:#000000ad}.mtb-cancel-btn:hover{background:#e5e7eb}.mtb-submit-btn{background:#d1d5db;color:#fff}.mtb-submit-btn.ready{background:#059669}.mtb-submit-btn.ready:hover{background:#047857}.mtb-submit-btn.loading{background:#059669;opacity:.7;cursor:wait}.mtb-submit-btn:disabled{cursor:not-allowed}.mtb-success{position:fixed;z-index:2147483645;width:332px;background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:16px;box-shadow:0 24px 64px #0000003d;padding:24px 22px;text-align:center;animation:mtbSlideUp .35s cubic-bezier(.34,1.56,.64,1);font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif}.mtb-success-icon{width:46px;height:46px;border-radius:50%;background:#05966917;display:flex;align-items:center;justify-content:center;margin:0 auto 12px}.mtb-success-title{font-size:16px;font-weight:700;margin-bottom:5px;letter-spacing:-.01em;color:#191a1c}.mtb-success-msg{font-size:13px;color:#0000008c;margin-bottom:16px;line-height:1.6}.mtb-view-feedback-link{display:inline-flex;align-items:center;gap:5px;color:#047857;text-decoration:none;font-size:13px;font-weight:500;font-family:JetBrains Mono,monospace;background:none;border:none;cursor:pointer;transition:text-decoration .12s}.mtb-view-feedback-link:hover{text-decoration:underline}.mtb-close-link{margin-top:13px;background:none;border:none;cursor:pointer;font-size:12px;color:#0006;font-family:inherit;transition:color .12s}.mtb-close-link:hover{color:#000000b3}.mtb-email-capture{margin-bottom:14px;text-align:left}.mtb-email-prompt{font-size:12px;color:#0000008c;line-height:1.5;margin-bottom:8px}.mtb-email-row{display:flex;gap:6px}.mtb-email-input{flex:1;min-width:0;font-size:12.5px;font-family:inherit;padding:7px 10px;border:1px solid rgba(0,0,0,.14);border-radius:8px;outline:none}.mtb-email-input:focus{border-color:#059669}.mtb-email-input.mtb-email-invalid{border-color:#dc2626}.mtb-email-submit{font-size:12px;font-weight:600;font-family:inherit;color:#fff;background:#059669;border:none;border-radius:8px;padding:7px 12px;cursor:pointer;white-space:nowrap}.mtb-email-submit:disabled{opacity:.6;cursor:default}.mtb-email-error{font-size:11.5px;color:#dc2626;margin-top:6px}.mtb-email-saved{font-size:12px;color:#059669;line-height:1.5}.mtb-my-feedback{display:block;margin:8px auto 0;background:none;border:none;cursor:pointer;font-size:11.5px;font-family:inherit;color:#0006;text-decoration:underline;text-underline-offset:2px;transition:color .12s}.mtb-my-feedback:hover{color:#059669}.mtb-pet{position:fixed;bottom:20px;right:20px;z-index:2147483646;cursor:pointer;width:52px;height:52px;display:flex;align-items:center;justify-content:center;border-radius:50%;background:transparent;animation:mtbPetBounce 3s ease-in-out infinite;transition:transform .2s;user-select:none;outline:none;filter:drop-shadow(0 4px 12px rgba(5,150,105,.35))}.mtb-pet:hover{transform:scale(1.12);animation-play-state:paused}.mtb-pet:hover .mtb-pet-bubble{opacity:1;transform:translate(-50%) translateY(0);pointer-events:auto}.mtb-pet.active{animation:none;opacity:.6}.mtb-pet-svg{display:block}@keyframes mtbPetBounce{0%,to{transform:translateY(0)}50%{transform:translateY(-6px)}}.mtb-pet-bubble{position:absolute;bottom:100%;left:50%;transform:translate(-50%) translateY(4px);margin-bottom:8px;background:#064e3b;color:#fff;padding:6px 12px;border-radius:8px;font-size:12px;font-weight:500;white-space:nowrap;box-shadow:0 4px 14px #0000002e;opacity:0;pointer-events:none;transition:opacity .2s,transform .2s}.mtb-pet-bubble.visible{opacity:1;transform:translate(-50%) translateY(0);pointer-events:auto}.mtb-pet-bubble.hidden{opacity:0;pointer-events:none}.mtb-pet-bubble:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);border:5px solid transparent;border-top-color:#064e3b}.mtb-frustration-prompt{position:fixed;bottom:20px;right:20px;z-index:2147483645;display:flex;align-items:center;gap:10px;padding:12px 16px;background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:12px;box-shadow:0 8px 30px #0000001f;animation:mtbSlideUp .35s cubic-bezier(.34,1.56,.64,1);font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif}:host([data-mtb-theme="dark"]) .mtb-frustration-prompt{background:#151719;border-color:#ffffff1f;color:#f9fafb}@media (prefers-color-scheme: dark){:host([data-mtb-theme="auto"]) .mtb-frustration-prompt{background:#151719;border-color:#ffffff1f;color:#f9fafb}}.mtb-frustration-icon{width:32px;height:32px;border-radius:50%;background:#eab3081a;display:flex;align-items:center;justify-content:center;flex-shrink:0;font-size:16px;line-height:1}.mtb-frustration-text{font-size:13px;font-weight:500;color:inherit;line-height:1.4}.mtb-frustration-actions{display:flex;gap:6px;flex-shrink:0}.mtb-frustration-tell{height:28px;padding:0 12px;border:none;border-radius:7px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12px;font-weight:600;transition:background .12s}.mtb-frustration-tell:hover{background:#047857}.mtb-frustration-dismiss{height:28px;padding:0 8px;border:none;border-radius:7px;background:transparent;color:#0006;cursor:pointer;font-family:inherit;font-size:12px;transition:color .12s}.mtb-frustration-dismiss:hover{color:#000000b3}:host([data-mtb-theme="dark"]) .mtb-frustration-dismiss{color:#fff6}:host([data-mtb-theme="dark"]) .mtb-frustration-dismiss:hover{color:#ffffffb3}@media (prefers-color-scheme: dark){:host([data-mtb-theme="auto"]) .mtb-frustration-dismiss{color:#fff6}:host([data-mtb-theme="auto"]) .mtb-frustration-dismiss:hover{color:#ffffffb3}}.mtb-record-bar{position:fixed;bottom: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:#ef4444;animation:mtbRecordPulse 1.2s ease-in-out infinite;flex-shrink:0}@keyframes mtbRecordPulse{0%,to{opacity:1}50%{opacity:.3}}.mtb-record-timer{font-family:JetBrains Mono,SF Mono,Fira Code,Cascadia Code,monospace;font-size:13px;font-weight:500;color:#fff;font-variant-numeric:tabular-nums;letter-spacing:.02em;min-width:38px}.mtb-record-stop{height:28px;padding:0 14px;border:none;border-radius:7px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12px;font-weight:600;transition:background .12s}.mtb-record-stop:hover{background:#047857}.mtb-click-ripple{position:fixed;z-index:2147483644;width:24px;height:24px;border-radius:50%;border:2px solid #10b981;background:#10b98133;pointer-events:none;transform:translate(-50%,-50%) scale(.5);animation:mtbClickRipple .3s ease-out forwards}@keyframes mtbClickRipple{0%{transform:translate(-50%,-50%) scale(.5);opacity:1}to{transform:translate(-50%,-50%) scale(2);opacity:0}}.mtb-dot{display:inline-block;width:4px;height:4px;border-radius:50%;background:#fff;animation:mtbDot 1.2s infinite}.mtb-dot:nth-child(2){animation-delay:.2s}.mtb-dot:nth-child(3){animation-delay:.4s}@keyframes mtbDot{0%,80%,to{opacity:.3;transform:translateY(0)}40%{opacity:1;transform:translateY(-3px)}}.mtb-clarify{position:fixed;z-index:2147483645;width:min(346px,calc(100vw - 56px));background:#fff;border:1px solid rgba(0,0,0,.1);border-radius:16px;box-shadow:0 24px 64px #0000003d;display:flex;flex-direction:column;animation:mtbSlideUp .28s cubic-bezier(.34,1.56,.64,1);font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif;overflow:hidden}.mtb-clarify-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 rgba(0,0,0,.06)}.mtb-clarify-icon{width:20px;height:20px;border-radius:6px;background:linear-gradient(140deg,#10b981,#059669);box-shadow:0 1px 3px #05966966;display:flex;align-items:center;justify-content:center;flex-shrink:0}.mtb-clarify-titles{flex:1;min-width:0}.mtb-clarify-title{font-size:12px;font-weight:650;line-height:1.2;color:#191a1c}.mtb-clarify-subtitle{font-size:9.5px;color:#0000006b}.mtb-clarify-close{background:none;border:none;cursor:pointer;padding:3px;color:#00000061;display:flex;transition:color .12s}.mtb-clarify-close:hover{color:#000000b3}.mtb-clarify-messages{flex:1;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:#fff;color:#191a1c;border:1px solid rgba(0,0,0,.09);border-radius:11px 11px 11px 3px}.mtb-clarify-user{align-self:flex-end;background:#059669;color:#fff;border:1px solid #059669;border-radius:11px 11px 3px}.mtb-clarify-thinking{display:flex;align-items:center;gap:4px;padding:8px 12px}.mtb-clarify-thinking .mtb-dot{width:6px;height:6px;background:#059669b3}.mtb-clarify-footer{padding:3px 10px 10px;display:flex;flex-direction:column}.mtb-clarify-input{width:100%;height:40px;padding:7px 10px;border:1px solid rgba(0,0,0,.12);border-radius:8px;font-family:inherit;font-size:12px;line-height:1.4;color:#191a1c;outline:none;background:#fafafa;resize:none;box-sizing:border-box;transition:border-color .12s,box-shadow .12s,background .12s}.mtb-clarify-input:focus{border-color:#10b981;box-shadow:0 0 0 3px #10b98126;background:#fff}.mtb-clarify-input::placeholder{color:#00000057}.mtb-clarify-actions{display:flex;gap:6px;margin-top:6px}.mtb-clarify-skip,.mtb-clarify-fallback{flex:0 0 auto;height:30px;padding:0 12px;border:1px solid rgba(0,0,0,.12);border-radius:8px;background:#fff;cursor:pointer;font-family:inherit;font-size:12px;font-weight:550;color:#0000008c;white-space:nowrap;transition:background .12s}.mtb-clarify-skip:hover,.mtb-clarify-fallback:hover{background:#0000000a}.mtb-clarify-send,.mtb-clarify-retry{flex:1;height:30px;display:inline-flex;align-items:center;justify-content:center;gap:5px;border:none;border-radius:8px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12px;font-weight:600;transition:background .12s}.mtb-clarify-send:not(:disabled):hover,.mtb-clarify-retry:not(:disabled):hover{background:#047857}.mtb-clarify-send:disabled,.mtb-clarify-retry:disabled{background:#00000026;cursor:not-allowed}.mtb-clarify-send-feedback{width:100%;height:34px;display:inline-flex;align-items:center;justify-content:center;gap:6px;border:none;border-radius:9px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:600;transition:background .12s}.mtb-clarify-send-feedback:not(:disabled):hover{background:#047857}.mtb-clarify-send-feedback:disabled{background:#00000026;cursor:not-allowed}.mtb-clarify-error{margin-bottom:8px;color:#dc2626;font-size:11.5px;line-height:1.4;text-align:center}:host([data-mtb-theme="dark"]) .mtb-clarify{background:#151719;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-clarify-header{border-bottom-color:#ffffff1a}:host([data-mtb-theme="dark"]) .mtb-clarify-title{color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-clarify-subtitle{color:#ffffff73}:host([data-mtb-theme="dark"]) .mtb-clarify-close{color:#ffffff73}:host([data-mtb-theme="dark"]) .mtb-clarify-close:hover{color:#ffffffbf}:host([data-mtb-theme="dark"]) .mtb-clarify-skip,:host([data-mtb-theme="dark"]) .mtb-clarify-fallback{background:#1f2327;border-color:#ffffff24;color:#ffffffb3}:host([data-mtb-theme="dark"]) .mtb-clarify-skip:hover,:host([data-mtb-theme="dark"]) .mtb-clarify-fallback:hover{background:#ffffff0f}:host([data-mtb-theme="dark"]) .mtb-clarify-ai{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="dark"]) .mtb-clarify-input{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}@media (prefers-color-scheme: dark){:host([data-mtb-theme="auto"]) .mtb-clarify{background:#151719;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-clarify-header{border-bottom-color:#ffffff1a}:host([data-mtb-theme="auto"]) .mtb-clarify-title{color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-clarify-subtitle{color:#ffffff73}:host([data-mtb-theme="auto"]) .mtb-clarify-close{color:#ffffff73}:host([data-mtb-theme="auto"]) .mtb-clarify-close:hover{color:#ffffffbf}:host([data-mtb-theme="auto"]) .mtb-clarify-skip,:host([data-mtb-theme="auto"]) .mtb-clarify-fallback{background:#1f2327;border-color:#ffffff24;color:#ffffffb3}:host([data-mtb-theme="auto"]) .mtb-clarify-skip:hover,:host([data-mtb-theme="auto"]) .mtb-clarify-fallback:hover{background:#ffffff0f}:host([data-mtb-theme="auto"]) .mtb-clarify-ai{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}:host([data-mtb-theme="auto"]) .mtb-clarify-input{background:#1f2327;border-color:#ffffff1f;color:#f9fafb}}.mtb-dim-clickable{z-index:2147483643;pointer-events:auto;cursor:default;background:#0000001f}.mtb-draw-bar{position:fixed;bottom:48px;left:50%;transform:translate(-50%);z-index:2147483647;display:flex;align-items:center;gap:8px;height:46px;padding:0 8px 0 12px;border-radius:13px;background:#fff;border:1px solid rgba(0,0,0,.08);box-shadow:0 10px 30px #0f172a38;animation:mtbBarIn .2s ease;font-family:Inter,-apple-system,BlinkMacSystemFont,sans-serif}.mtb-draw-input{width:220px;height:32px;padding:0 10px;border:1px solid rgba(0,0,0,.12);border-radius:8px;font-family:inherit;font-size:13px;color:#191a1c;outline:none;background:#fafafa;transition:border-color .12s,box-shadow .12s,background .12s}.mtb-draw-input:focus{border-color:#10b981;box-shadow:0 0 0 3px #10b98126;background:#fff}.mtb-draw-input::placeholder{color:#00000057}.mtb-draw-icon-btn{width:30px;height:30px;display:inline-flex;align-items:center;justify-content:center;border:none;border-radius:8px;background:transparent;color:#374151;cursor:pointer;transition:background .12s,color .12s}.mtb-draw-icon-btn:hover:not(:disabled){background:#0000000f}.mtb-draw-icon-btn:disabled{color:#00000038;cursor:default}.mtb-draw-sep{width:1px;height:22px;background:#0000001a}.mtb-draw-cancel{height:32px;padding:0 12px;border:1px solid rgba(0,0,0,.12);border-radius:8px;background:#fff;color:#0000008c;cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:550;transition:background .12s}.mtb-draw-cancel:hover{background:#0000000a}.mtb-draw-submit{height:32px;padding:0 14px;border:none;border-radius:8px;background:#059669;color:#fff;cursor:pointer;font-family:inherit;font-size:12.5px;font-weight:600;transition:background .12s}.mtb-draw-submit:hover:not(:disabled){background:#047857}.mtb-draw-submit:disabled{opacity:.6;cursor:default}.mtb-draw-error{position:absolute;bottom:100%;left:12px;margin-bottom:6px;color:#dc2626;font-size:11.5px}.mtb-record-preview{margin-bottom:12px}.mtb-record-preview-stage{position:relative;width:100%;height:132px;border-radius:10px;overflow:hidden;background:#0f172a;display:flex;align-items:center;justify-content:center}.mtb-record-preview-stage.playing{align-items:flex-start;justify-content:flex-start}.mtb-record-preview-play{width:44px;height:44px;border-radius:50%;border:none;background:#ffffffeb;color:#059669;display:inline-flex;align-items:center;justify-content:center;cursor:pointer;transition:transform .12s,background .12s}.mtb-record-preview-play:hover:not(:disabled){transform:scale(1.06);background:#fff}.mtb-record-preview-play:disabled{cursor:default;opacity:.6}.mtb-record-preview-badge{position:absolute;right:8px;bottom:8px;padding:2px 7px;border-radius:6px;background:#0009;color:#fff;font-size:11px;font-variant-numeric:tabular-nums;font-family:JetBrains Mono,SF Mono,monospace}.mtb-record-preview-fallback{color:#ffffffd9;font-size:12px}.mtb-record-preview-name{display:block;margin-top:5px;font-size:11px;color:#0000006b}@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:6px;justify-content:center;padding:env(safe-area-inset-top,0px) 8px 0;height:calc(56px + env(safe-area-inset-top,0px));animation:mtbBarInMobile .2s ease}.mtb-toolbar-modes{flex-direction:row;gap:3px;padding:3px;background:#ffffff29;border-radius:9px}.mtb-hint-bar,.mtb-toolbar-sep{display:none}.mtb-toolbar-mode-btn,.mtb-exit-btn{width:auto;height:30px;gap:6px;border-radius:7px;padding-right:10px;padding-left:10px;color:#fffffff2}.mtb-exit-btn{border-radius:8px;background:#ffffff29}.mtb-toolbar-label{display:inline}:host([data-mtb-toolbar]) .mtb-tab{display:flex}.mtb-popup{inset:auto 0 0;width:auto;max-height:85%;border-radius:20px 20px 0 0;animation:mtbSheetUp .28s cubic-bezier(.34,1.56,.64,1)}.mtb-popup-actions{padding-bottom:calc(12px + env(safe-area-inset-bottom,0px))}.mtb-clarify{inset:auto 0 0;width:auto;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}}@keyframes mtbBarInMobile{0%{transform:translateY(-14px);opacity:0}to{transform:translateY(0);opacity:1}}@keyframes mtbSheetUp{0%{transform:translateY(100%)}to{transform:translateY(0)}}`;class ne{constructor(t="auto"){this.host=document.createElement("div"),this.host.id="mtb-widget-host",this.host.style.cssText="position:fixed;top:0;left:0;width:0;height:0;overflow:visible;z-index:2147483646;",this.host.setAttribute("data-mtb-theme",t),document.body.appendChild(this.host),this.root=this.host.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=re,this.root.appendChild(e)}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(){this.host.remove()}}class se{constructor(t,e,r,n,s){this.active=!1,this.onClick=n,this.customText=s,this.el=t.el("button","mtb-tab"),r==="left"&&this.el.classList.add("left"),this.idleLabel=s??e.tab,this.activeLabel=e.toolbar.exit,this.setLabel(this.idleLabel),this.el.addEventListener("click",n),t.append(this.el)}setLabel(t){this.el.textContent=t,this.el.setAttribute("aria-label",t)}setMessages(t){this.idleLabel=this.customText??t.tab,this.activeLabel=t.toolbar.exit,this.setLabel(this.active?this.activeLabel:this.idleLabel)}setActive(t){this.active=t,this.el.classList.toggle("active",t),this.setLabel(t?this.activeLabel:this.idleLabel)}destroy(){this.el.removeEventListener("click",this.onClick),this.el.remove()}}const oe=8e3;class ae{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">${e.frustration.prompt}</span>
|
|
4
4
|
<div class="mtb-frustration-actions">
|
|
5
5
|
<button class="mtb-frustration-tell">${e.frustration.action}</button>
|
|
6
6
|
<button class="mtb-frustration-dismiss">${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,oe)}destroy(){this.autoHideTimer&&(clearTimeout(this.autoHideTimer),this.autoHideTimer=null),this.el.remove()}}class le{constructor(t,e){this.onClick=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()}}class ce{constructor(){this.locked=!1,this.prevOverflow="",this.prevTouchAction=""}isTouchPointer(){return window.matchMedia?.("(pointer: coarse)").matches??!1}lock(){this.locked||!this.isTouchPointer()||(this.locked=!0,this.prevOverflow=document.body.style.overflow,this.prevTouchAction=document.body.style.touchAction,document.body.style.overflow="hidden",document.body.style.touchAction="none")}unlock(){this.locked&&(this.locked=!1,document.body.style.overflow=this.prevOverflow,document.body.style.touchAction=this.prevTouchAction)}isLocked(){return this.locked}}class de{constructor(t,e,r,n){this.currentMode="markup",this.handlePointerMove=
|
|
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,oe)}destroy(){this.autoHideTimer&&(clearTimeout(this.autoHideTimer),this.autoHideTimer=null),this.el.remove()}}class le{constructor(t,e){this.onClick=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()}}class ce{constructor(){this.locked=!1,this.prevOverflow="",this.prevTouchAction=""}isTouchPointer(){return window.matchMedia?.("(pointer: coarse)").matches??!1}lock(){this.locked||!this.isTouchPointer()||(this.locked=!0,this.prevOverflow=document.body.style.overflow,this.prevTouchAction=document.body.style.touchAction,document.body.style.overflow="hidden",document.body.style.touchAction="none")}unlock(){this.locked&&(this.locked=!1,document.body.style.overflow=this.prevOverflow,document.body.style.touchAction=this.prevTouchAction)}isLocked(){return this.locked}}class de{constructor(t,e,r,n,s="right"){this.currentMode="markup",this.handlePointerMove=o=>{if(o.pointerType!=="mouse")return;const a=this.hintBarEl.getBoundingClientRect(),l=o.clientX>=a.left&&o.clientX<=a.right&&o.clientY>=a.top&&o.clientY<=a.bottom;this.hintBarEl.classList.toggle("mtb-hint-bar--under-pointer",l)},this.messages=e,this.hintBarEl=t.el("div","mtb-hint-bar"),this.hintBarEl.innerHTML=`<span class="mtb-toolbar-hint">${e.toolbar.hint}</span>`,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)}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="${t.toolbar.markup}" title="${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">${t.toolbar.markup}</span>
|
|
12
12
|
</button>
|
|
13
13
|
<button class="mtb-toolbar-mode-btn mtb-toolbar-mode-record" aria-label="${t.toolbar.record}" title="${t.toolbar.record}">
|
|
14
|
-
<svg width="
|
|
14
|
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="6" width="13" height="12" rx="2.5"/><path d="M15 10.5 21.2 7.4a.6.6 0 0 1 .8.5v8.2a.6.6 0 0 1-.8.5L15 13.5z"/></svg><span class="mtb-toolbar-label">${t.toolbar.record}</span>
|
|
15
15
|
</button>
|
|
16
16
|
</div>
|
|
17
17
|
<span class="mtb-toolbar-sep"></span>
|
|
@@ -140,5 +140,5 @@
|
|
|
140
140
|
<span class="mtb-record-dot"></span>
|
|
141
141
|
<span class="mtb-record-timer">00:00</span>
|
|
142
142
|
<button class="mtb-record-stop" type="button">${e.record.stop}</button>
|
|
143
|
-
`,t.append(this.el),this.timerEl=this.el.querySelector(".mtb-record-timer"),this.el.querySelector(".mtb-record-stop").addEventListener("click",n),this.intervalId=setInterval(()=>this.updateTimer(),1e3)}updateTimer(){const t=this.getDuration(),e=String(Math.floor(t/60)).padStart(2,"0"),r=String(t%60).padStart(2,"0");this.timerEl.textContent=`${e}:${r}`}destroy(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.el.remove()}}class Pr{constructor(){this.session=null,this.bar=null,this.result=null}async start(t,e,r,n={}){this.session=new Lr(t,r,n),this.bar=new Mr(t,e,()=>this.session?.getDuration()??0,r),await this.session.start()}stop(){return this.session?(this.result=this.session.stop(),this.teardownUI(),this.result):null}getRecording(){return this.result}destroy(){this.teardownUI(),this.result=null}teardownUI(){this.session?.destroy(),this.session=null,this.bar?.destroy(),this.bar=null}}const Ar=3e3,Tt=12e3;function Rr(){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 K{constructor(t){this.tab=null,this.toolbar=null,this.session=null,this.scrollLock=new ce,this.drawBar=null,this.dim=null,this.popup=null,this.clarify=null,this.success=null,this.frustrationPrompt=null,this.frustrationDetector=null,this.mode="idle",this.via="pin",this.currentAnnotation=null,this.submittingUi=null,this.lastPopupPos=null,this.recordingManager=null,this.activeSubmission=null,this.submissionAttempt=0,this.lastHandoff={},this.handleKeydown=e=>{if(e.key==="Escape")switch(this.mode){case"annotating":case"popup":e.preventDefault(),e.stopPropagation(),this.exitAll();break;case"drawing":e.preventDefault(),e.stopPropagation(),this.cancelDraw();break;case"recording":e.preventDefault(),e.stopPropagation(),this.handleRecordStop();break}},this.handleRecordStop=()=>{this.recordingManager&&(this.recordingManager.stop(),this.via="record",this.showPopup(window.innerWidth/2,window.innerHeight/2,this.messages.record.timer_label))},this.config=t,this.messages=Ct(t.locale??document.documentElement.lang??"en"),this.apiClient=new Me(t.projectKey,t.apiUrl,void 0,t.userToken,t.userTokenFn),this.consoleCollector=new Vi,this.consoleCollector.start(),this.breadcrumbCollector=new Gi,this.breadcrumbCollector.start(),this.buildUI(),t.frustrationDetection!==!1&&(this.frustrationDetector=new X(()=>this.handleFrustration()),this.frustrationDetector.start()),document.addEventListener("keydown",this.handleKeydown,!0)}buildUI(){if(this.shadow=new ne(this.config.theme??"auto"),this.config.entryMode==="api"){Rr()&&console.warn('[MakeThisBetter] entryMode: "api" renders no launcher. Call MakeThisBetter.open() from your own UI, or use showLauncher().');return}this.mountTab()}mountTab(){this.tab||(this.tab=new se(this.shadow,this.messages,this.config.position??"right",()=>this.handleTabClick(),this.config.tabText))}open(){this.mode==="idle"&&(this.dismissFrustrationPrompt(),this.enterAnnotationMode())}close(){this.mode!=="idle"&&this.exitAll()}showLauncher(){this.mountTab(),this.tab?.setActive(this.mode!=="idle")}hideLauncher(){this.tab?.destroy(),this.tab=null}setLocale(t){this.config.locale=t,this.messages=Ct(t),this.tab?.setMessages(this.messages)}handleTabClick(){this.mode==="idle"?(this.dismissFrustrationPrompt(),this.enterAnnotationMode()):this.exitAll()}handleFrustration(){this.mode!=="idle"||this.frustrationPrompt||Ji()||(this.frustrationPrompt=new ae(this.shadow,this.messages,{onTell:()=>{this.dismissFrustrationPrompt(),this.enterAnnotationMode()},onDismiss:()=>{Qi(),this.dismissFrustrationPrompt()},onAutoHide:()=>this.dismissFrustrationPrompt()}))}dismissFrustrationPrompt(){this.frustrationPrompt?.destroy(),this.frustrationPrompt=null}enterAnnotationMode(){this.mode="annotating",this.tab?.setActive(!0),this.scrollLock.lock(),this.toolbar=new de(this.shadow,this.messages,()=>this.exitAll(),t=>this.handleToolbarModeChange(t)),this.session=this.createSession()}createSession(){return new xe(this.shadow,this.messages,{onPin:(t,e)=>{this.currentAnnotation=t,this.via="pin",this.showPopup(t.x,t.y,e,t.targetRect)},onDrawStroke:()=>this.handleDrawStroke()})}handleToolbarModeChange(t){if(this.mode==="clarifying"){this.toolbar?.setMode(this.via==="record"?"record":"markup");return}if(t==="record"){if(this.mode==="recording")return;this.mode="recording",this.currentAnnotation=null,this.teardownDraw(),this.session?.destroy(),this.session=null,this.scrollLock.unlock(),this.recordingManager=new Pr,this.recordingManager.start(this.shadow,this.messages,this.handleRecordStop,this.config.recording??{}).catch(e=>{console.warn("[MakeThisBetter] Interaction replay unavailable, falling back to markup:",e),this.mode==="recording"&&(this.toolbar?.setMode("markup"),this.handleToolbarModeChange("markup"))})}else this.recordingManager?.destroy(),this.recordingManager=null,this.teardownDraw(),this.session||(this.session=this.createSession()),this.scrollLock.lock(),this.mode="annotating"}handleDrawStroke(){this.mode!=="drawing"&&(this.mode="drawing",this.drawBar=new Ce(this.shadow,{messages:this.messages,onUndo:()=>this.handleDrawUndoRedo("undo"),onRedo:()=>this.handleDrawUndoRedo("redo"),onCancel:()=>this.cancelDraw(),onSubmit:t=>this.handleDrawSubmit(t)})),this.refreshDrawBar()}handleDrawUndoRedo(t){t==="undo"?this.session?.undoDraw():this.session?.redoDraw(),this.refreshDrawBar()}refreshDrawBar(){this.session&&this.drawBar?.setUndoRedo(this.session.canUndoDraw(),this.session.canRedoDraw())}cancelDraw(){this.session?.clearDraw(),this.teardownDraw(),this.mode="annotating"}teardownDraw(){this.drawBar?.destroy(),this.drawBar=null}handleDrawSubmit(t){const e=this.session?.getDrawAnnotation();if(!e){this.cancelDraw();return}this.currentAnnotation=e,this.via="draw",this.session?.dismissInteraction(),this.submittingUi=this.drawBar,this.handleSubmit(t||this.messages.annotation.drawing)}showPopup(t,e,r,n){this.mode="popup",this.lastPopupPos={x:t,y:e},this.teardownDraw(),this.session?.dismissInteraction(),this.popup?.destroy(),this.popup=null,this.dim?.destroy(),this.dim=null,this.dim=new le(this.shadow,()=>this.exitAll()),this.popup=new _e(this.shadow,{targetName:r,x:t,y:e,targetRect:n,messages:this.messages,onSubmit:s=>this.handleSubmit(s),onClose:()=>this.exitAll(),onMyFeedback:this.buildMyFeedbackHandler(),position:this.config.position??"right"}),this.submittingUi=this.popup}buildMyFeedbackHandler(){if(!this.config.user&&ur())return async()=>{const t=await this.apiClient.createIdentityToken(vt());!t?.identity_token||!t.board_url||(St(t.board_url),window.open(`${t.board_url}?identity=${encodeURIComponent(t.identity_token)}`,"_blank"))}}async handleSubmit(t){const e=this.submittingUi;if(!e)return;const r=++this.submissionAttempt;e.setLoading(!0),await Ir();const n=this.currentAnnotation,s=this.recordingManager?.getRecording()??void 0,[o,a]=await Promise.all([Bi(n?[n]:[]),Promise.resolve(ar())]),l=dr(t,a,this.consoleCollector.getErrors(),n,this.config.user,s,this.config.user?void 0:vt(),this.config.user?void 0:kt(),this.breadcrumbCollector.getBreadcrumbs());try{const c=await this.apiClient.createSubmissionSession(l,o);if(r!==this.submissionAttempt){await this.apiClient.abandonSubmissionSession(c.id,c.token).catch(()=>{});return}this.activeSubmission=c,await this.speculativeClarify(c,this.lastPopupPos,r)}catch{if(r!==this.submissionAttempt)return;e.setLoading(!1),e.setError(this.messages.error.submit)}}async speculativeClarify(t,e,r){if(!t.ai_clarify_available){const u=this.teardownSubmittingUi(!0);this.showClarify(t,e,{element:u,preloadedResult:{messages:[],done:!0}});return}const n=new AbortController;let s=setTimeout(()=>n.abort(),Tt);const o=()=>{clearTimeout(s),s=setTimeout(()=>n.abort(),Tt)},a=this.apiClient.streamClarification(t.id,t.token,o,n.signal).catch(()=>null).finally(()=>clearTimeout(s)),l=new Promise(u=>setTimeout(()=>u(null),Ar)),c=await Promise.race([a,l]);if(r!==this.submissionAttempt)return;const d=this.teardownSubmittingUi(!0);c?this.showClarify(t,e,{element:d,preloadedResult:c}):this.showClarify(t,e,{element:d,pendingClarification:a})}teardownSubmittingUi(t=!1){const e=t?this.popup?.releaseElement():void 0;return this.scrollLock.unlock(),this.teardownDraw(),e||this.popup?.destroy(),this.popup=null,this.dim?.destroy(),this.dim=null,this.session?.hideHighlight(),this.session?.destroy(),this.session=null,this.recordingManager?.destroy(),this.recordingManager=null,this.submittingUi=null,e}showClarify(t,e,r){this.mode="clarifying",this.tab?.setActive(!0),this.clarify=new Be(this.shadow,{submissionSessionId:t.id,submissionToken:t.token,apiClient:this.apiClient,messages:this.messages,element:r?.element,position:this.config.position??"right",x:e?.x,y:e?.y,onFinalize:()=>this.finalizeSubmission(),preloadedResult:r?.preloadedResult,pendingClarification:r?.pendingClarification})}async finalizeSubmission(){const t=this.activeSubmission;if(!t)throw new Error("No active submission session");const e=this.submissionAttempt,r=await this.apiClient.finalizeSubmissionSession(t.id,t.token);e!==this.submissionAttempt||this.activeSubmission!==t||(this.activeSubmission=null,this.lastHandoff={feedbackId:r.id,boardUrl:r.board_url,identityToken:r.identity_token},r.board_url&&St(r.board_url),this.clarify?.destroy(),this.clarify=null,this.toolbar?.destroy(),this.toolbar=null,this.showSuccess({skipFollowup:t.ai_clarify_available===!1}))}showSuccess(t){this.mode="idle",this.tab?.setActive(!1),this.success=new Oe(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)&&!kt())return{onSubmit:async r=>{const n=await this.apiClient.updateReporter(t,r,e);return n&&hr(r),n}}}buildViewFeedbackHandler(){const{boardUrl:t,identityToken:e}=this.lastHandoff;if(t){if(e)return()=>{window.open(`${t}?identity=${encodeURIComponent(e)}`,"_blank")};if(this.config.userToken||this.config.userTokenFn)return async()=>{const r=await this.apiClient.resolveUserToken();r&&window.open(`${t}?identity=${encodeURIComponent(r)}`,"_blank")}}}exitAll(){this.submissionAttempt+=1;const t=this.activeSubmission;this.activeSubmission=null,t&&this.apiClient.abandonSubmissionSession(t.id,t.token).catch(()=>{}),this.mode="idle",this.via="pin",this.tab?.setActive(!1),this.scrollLock.unlock(),this.teardownDraw(),this.toolbar?.destroy(),this.toolbar=null,this.session?.hideHighlight(),this.session?.destroy(),this.session=null,this.dim?.destroy(),this.dim=null,this.popup?.destroy(),this.popup=null,this.clarify?.destroy(),this.clarify=null,this.currentAnnotation=null,this.submittingUi=null,this.recordingManager?.destroy(),this.recordingManager=null}destroy(){document.removeEventListener("keydown",this.handleKeydown,!0),this.exitAll(),this.consoleCollector.stop(),this.breadcrumbCollector.stop(),this.frustrationDetector?.stop(),this.dismissFrustrationPrompt(),this.clarify?.destroy(),this.success?.destroy(),this.tab?.destroy(),this.recordingManager?.destroy(),this.shadow.destroy()}}function Ir(){return new Promise(i=>requestAnimationFrame(()=>setTimeout(i,0)))}let f=null,E=null;const Xt={init(i){f&&(f.destroy(),f=null),E=i,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{f=new K(i)}):f=new K(i)},destroy(){f?.destroy(),f=null,E=null},setLocale(i){E&&(E.locale=i),f?.setLocale(i)},open(){f?.open()},close(){f?.close()},showLauncher(){f?.showLauncher()},hideLauncher(){f?.hideLauncher()}};typeof window<"u"&&(window.MakeThisBetter=Xt,document.addEventListener("turbo:load",()=>{const i=document.getElementById("mtb-widget-host");E&&(!i||!i.shadowRoot)&&(f?.destroy(),i?.remove(),f=new K(E))}));exports.MakeThisBetter=Xt;
|
|
143
|
+
`,t.append(this.el),this.timerEl=this.el.querySelector(".mtb-record-timer"),this.el.querySelector(".mtb-record-stop").addEventListener("click",n),this.intervalId=setInterval(()=>this.updateTimer(),1e3)}updateTimer(){const t=this.getDuration(),e=String(Math.floor(t/60)).padStart(2,"0"),r=String(t%60).padStart(2,"0");this.timerEl.textContent=`${e}:${r}`}destroy(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.el.remove()}}class Pr{constructor(){this.session=null,this.bar=null,this.result=null}async start(t,e,r,n={}){this.session=new Lr(t,r,n),this.bar=new Mr(t,e,()=>this.session?.getDuration()??0,r),await this.session.start()}stop(){return this.session?(this.result=this.session.stop(),this.teardownUI(),this.result):null}getRecording(){return this.result}destroy(){this.teardownUI(),this.result=null}teardownUI(){this.session?.destroy(),this.session=null,this.bar?.destroy(),this.bar=null}}const Ar=3e3,Tt=12e3;function Rr(){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 K{constructor(t){this.tab=null,this.toolbar=null,this.session=null,this.scrollLock=new ce,this.drawBar=null,this.dim=null,this.popup=null,this.clarify=null,this.success=null,this.frustrationPrompt=null,this.frustrationDetector=null,this.mode="idle",this.via="pin",this.currentAnnotation=null,this.submittingUi=null,this.lastPopupPos=null,this.recordingManager=null,this.activeSubmission=null,this.submissionAttempt=0,this.lastHandoff={},this.handleKeydown=e=>{if(e.key==="Escape")switch(this.mode){case"annotating":case"popup":e.preventDefault(),e.stopPropagation(),this.exitAll();break;case"drawing":e.preventDefault(),e.stopPropagation(),this.cancelDraw();break;case"recording":e.preventDefault(),e.stopPropagation(),this.handleRecordStop();break}},this.handleRecordStop=()=>{this.recordingManager&&(this.recordingManager.stop(),this.via="record",this.showPopup(window.innerWidth/2,window.innerHeight/2,this.messages.record.timer_label))},this.config=t,this.messages=Ct(t.locale??document.documentElement.lang??"en"),this.apiClient=new Me(t.projectKey,t.apiUrl,void 0,t.userToken,t.userTokenFn),this.consoleCollector=new Vi,this.consoleCollector.start(),this.breadcrumbCollector=new Gi,this.breadcrumbCollector.start(),this.buildUI(),t.frustrationDetection!==!1&&(this.frustrationDetector=new X(()=>this.handleFrustration()),this.frustrationDetector.start()),document.addEventListener("keydown",this.handleKeydown,!0)}buildUI(){if(this.shadow=new ne(this.config.theme??"auto"),this.config.entryMode==="api"){Rr()&&console.warn('[MakeThisBetter] entryMode: "api" renders no launcher. Call MakeThisBetter.open() from your own UI, or use showLauncher().');return}this.mountTab()}mountTab(){this.tab||(this.tab=new se(this.shadow,this.messages,this.config.position??"right",()=>this.handleTabClick(),this.config.tabText))}open(){this.mode==="idle"&&(this.dismissFrustrationPrompt(),this.enterAnnotationMode())}close(){this.mode!=="idle"&&this.exitAll()}showLauncher(){this.mountTab(),this.tab?.setActive(this.mode!=="idle")}hideLauncher(){this.tab?.destroy(),this.tab=null}setLocale(t){this.config.locale=t,this.messages=Ct(t),this.tab?.setMessages(this.messages)}handleTabClick(){this.mode==="idle"?(this.dismissFrustrationPrompt(),this.enterAnnotationMode()):this.exitAll()}handleFrustration(){this.mode!=="idle"||this.frustrationPrompt||Ji()||(this.frustrationPrompt=new ae(this.shadow,this.messages,{onTell:()=>{this.dismissFrustrationPrompt(),this.enterAnnotationMode()},onDismiss:()=>{Qi(),this.dismissFrustrationPrompt()},onAutoHide:()=>this.dismissFrustrationPrompt()}))}dismissFrustrationPrompt(){this.frustrationPrompt?.destroy(),this.frustrationPrompt=null}enterAnnotationMode(){this.mode="annotating",this.tab?.setActive(!0),this.scrollLock.lock(),this.toolbar=new de(this.shadow,this.messages,()=>this.exitAll(),t=>this.handleToolbarModeChange(t),this.config.position??"right"),this.session=this.createSession()}createSession(){return new xe(this.shadow,this.messages,{onPin:(t,e)=>{this.currentAnnotation=t,this.via="pin",this.showPopup(t.x,t.y,e,t.targetRect)},onDrawStroke:()=>this.handleDrawStroke()})}handleToolbarModeChange(t){if(this.mode==="clarifying"){this.toolbar?.setMode(this.via==="record"?"record":"markup");return}if(t==="record"){if(this.mode==="recording")return;this.mode="recording",this.currentAnnotation=null,this.teardownDraw(),this.session?.destroy(),this.session=null,this.scrollLock.unlock(),this.recordingManager=new Pr,this.recordingManager.start(this.shadow,this.messages,this.handleRecordStop,this.config.recording??{}).catch(e=>{console.warn("[MakeThisBetter] Interaction replay unavailable, falling back to markup:",e),this.mode==="recording"&&(this.toolbar?.setMode("markup"),this.handleToolbarModeChange("markup"))})}else this.recordingManager?.destroy(),this.recordingManager=null,this.teardownDraw(),this.session||(this.session=this.createSession()),this.scrollLock.lock(),this.mode="annotating"}handleDrawStroke(){this.mode!=="drawing"&&(this.mode="drawing",this.drawBar=new Ce(this.shadow,{messages:this.messages,onUndo:()=>this.handleDrawUndoRedo("undo"),onRedo:()=>this.handleDrawUndoRedo("redo"),onCancel:()=>this.cancelDraw(),onSubmit:t=>this.handleDrawSubmit(t)})),this.refreshDrawBar()}handleDrawUndoRedo(t){t==="undo"?this.session?.undoDraw():this.session?.redoDraw(),this.refreshDrawBar()}refreshDrawBar(){this.session&&this.drawBar?.setUndoRedo(this.session.canUndoDraw(),this.session.canRedoDraw())}cancelDraw(){this.session?.clearDraw(),this.teardownDraw(),this.mode="annotating"}teardownDraw(){this.drawBar?.destroy(),this.drawBar=null}handleDrawSubmit(t){const e=this.session?.getDrawAnnotation();if(!e){this.cancelDraw();return}this.currentAnnotation=e,this.via="draw",this.session?.dismissInteraction(),this.submittingUi=this.drawBar,this.handleSubmit(t||this.messages.annotation.drawing)}showPopup(t,e,r,n){this.mode="popup",this.lastPopupPos={x:t,y:e},this.teardownDraw(),this.session?.dismissInteraction(),this.popup?.destroy(),this.popup=null,this.dim?.destroy(),this.dim=null,this.dim=new le(this.shadow,()=>this.exitAll()),this.popup=new _e(this.shadow,{targetName:r,x:t,y:e,targetRect:n,messages:this.messages,onSubmit:s=>this.handleSubmit(s),onClose:()=>this.exitAll(),onMyFeedback:this.buildMyFeedbackHandler(),position:this.config.position??"right"}),this.submittingUi=this.popup}buildMyFeedbackHandler(){if(!this.config.user&&ur())return async()=>{const t=await this.apiClient.createIdentityToken(vt());!t?.identity_token||!t.board_url||(St(t.board_url),window.open(`${t.board_url}?identity=${encodeURIComponent(t.identity_token)}`,"_blank"))}}async handleSubmit(t){const e=this.submittingUi;if(!e)return;const r=++this.submissionAttempt;e.setLoading(!0),await Ir();const n=this.currentAnnotation,s=this.recordingManager?.getRecording()??void 0,[o,a]=await Promise.all([Bi(n?[n]:[]),Promise.resolve(ar())]),l=dr(t,a,this.consoleCollector.getErrors(),n,this.config.user,s,this.config.user?void 0:vt(),this.config.user?void 0:kt(),this.breadcrumbCollector.getBreadcrumbs());try{const c=await this.apiClient.createSubmissionSession(l,o);if(r!==this.submissionAttempt){await this.apiClient.abandonSubmissionSession(c.id,c.token).catch(()=>{});return}this.activeSubmission=c,await this.speculativeClarify(c,this.lastPopupPos,r)}catch{if(r!==this.submissionAttempt)return;e.setLoading(!1),e.setError(this.messages.error.submit)}}async speculativeClarify(t,e,r){if(!t.ai_clarify_available){const u=this.teardownSubmittingUi(!0);this.showClarify(t,e,{element:u,preloadedResult:{messages:[],done:!0}});return}const n=new AbortController;let s=setTimeout(()=>n.abort(),Tt);const o=()=>{clearTimeout(s),s=setTimeout(()=>n.abort(),Tt)},a=this.apiClient.streamClarification(t.id,t.token,o,n.signal).catch(()=>null).finally(()=>clearTimeout(s)),l=new Promise(u=>setTimeout(()=>u(null),Ar)),c=await Promise.race([a,l]);if(r!==this.submissionAttempt)return;const d=this.teardownSubmittingUi(!0);c?this.showClarify(t,e,{element:d,preloadedResult:c}):this.showClarify(t,e,{element:d,pendingClarification:a})}teardownSubmittingUi(t=!1){const e=t?this.popup?.releaseElement():void 0;return this.scrollLock.unlock(),this.teardownDraw(),e||this.popup?.destroy(),this.popup=null,this.dim?.destroy(),this.dim=null,this.session?.hideHighlight(),this.session?.destroy(),this.session=null,this.recordingManager?.destroy(),this.recordingManager=null,this.submittingUi=null,e}showClarify(t,e,r){this.mode="clarifying",this.tab?.setActive(!0),this.clarify=new Be(this.shadow,{submissionSessionId:t.id,submissionToken:t.token,apiClient:this.apiClient,messages:this.messages,element:r?.element,position:this.config.position??"right",x:e?.x,y:e?.y,onFinalize:()=>this.finalizeSubmission(),preloadedResult:r?.preloadedResult,pendingClarification:r?.pendingClarification})}async finalizeSubmission(){const t=this.activeSubmission;if(!t)throw new Error("No active submission session");const e=this.submissionAttempt,r=await this.apiClient.finalizeSubmissionSession(t.id,t.token);e!==this.submissionAttempt||this.activeSubmission!==t||(this.activeSubmission=null,this.lastHandoff={feedbackId:r.id,boardUrl:r.board_url,identityToken:r.identity_token},r.board_url&&St(r.board_url),this.clarify?.destroy(),this.clarify=null,this.toolbar?.destroy(),this.toolbar=null,this.showSuccess({skipFollowup:t.ai_clarify_available===!1}))}showSuccess(t){this.mode="idle",this.tab?.setActive(!1),this.success=new Oe(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)&&!kt())return{onSubmit:async r=>{const n=await this.apiClient.updateReporter(t,r,e);return n&&hr(r),n}}}buildViewFeedbackHandler(){const{boardUrl:t,identityToken:e}=this.lastHandoff;if(t){if(e)return()=>{window.open(`${t}?identity=${encodeURIComponent(e)}`,"_blank")};if(this.config.userToken||this.config.userTokenFn)return async()=>{const r=await this.apiClient.resolveUserToken();r&&window.open(`${t}?identity=${encodeURIComponent(r)}`,"_blank")}}}exitAll(){this.submissionAttempt+=1;const t=this.activeSubmission;this.activeSubmission=null,t&&this.apiClient.abandonSubmissionSession(t.id,t.token).catch(()=>{}),this.mode="idle",this.via="pin",this.tab?.setActive(!1),this.scrollLock.unlock(),this.teardownDraw(),this.toolbar?.destroy(),this.toolbar=null,this.session?.hideHighlight(),this.session?.destroy(),this.session=null,this.dim?.destroy(),this.dim=null,this.popup?.destroy(),this.popup=null,this.clarify?.destroy(),this.clarify=null,this.currentAnnotation=null,this.submittingUi=null,this.recordingManager?.destroy(),this.recordingManager=null}destroy(){document.removeEventListener("keydown",this.handleKeydown,!0),this.exitAll(),this.consoleCollector.stop(),this.breadcrumbCollector.stop(),this.frustrationDetector?.stop(),this.dismissFrustrationPrompt(),this.clarify?.destroy(),this.success?.destroy(),this.tab?.destroy(),this.recordingManager?.destroy(),this.shadow.destroy()}}function Ir(){return new Promise(i=>requestAnimationFrame(()=>setTimeout(i,0)))}let f=null,E=null;const Xt={init(i){f&&(f.destroy(),f=null),E=i,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{f=new K(i)}):f=new K(i)},destroy(){f?.destroy(),f=null,E=null},setLocale(i){E&&(E.locale=i),f?.setLocale(i)},open(){f?.open()},close(){f?.close()},showLauncher(){f?.showLauncher()},hideLauncher(){f?.hideLauncher()}};typeof window<"u"&&(window.MakeThisBetter=Xt,document.addEventListener("turbo:load",()=>{const i=document.getElementById("mtb-widget-host");E&&(!i||!i.shadowRoot)&&(f?.destroy(),i?.remove(),f=new K(E))}));exports.MakeThisBetter=Xt;
|
|
144
144
|
//# sourceMappingURL=makethisbetter.cjs.map
|