export const WIDGET_BUNDLE_DIGEST: string | null = "df6fa08aaf79";
export const WIDGET_BUNDLE: string | null = "\n!function(){try{var e=\"undefined\"!=typeof window?window:\"undefined\"!=typeof global?global:\"undefined\"!=typeof globalThis?globalThis:\"undefined\"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=\"7c9adb98-4d54-5a40-93c5-d13143314c38\")}catch(e){}}();\nvar SupportWidget=function(){\"use strict\";function e(e){return e<=0?Promise.resolve():new Promise(t=>{const n=performance.now(),i=new MessageChannel;i.port1.onmessage=()=>{performance.now()-n>=e?(i.port1.close(),t()):i.port2.postMessage(null)},i.port2.postMessage(null)})}function t(){return document.hidden}class n extends Error{}function i(e,t,i){return new Promise((s,r)=>{let o=!1;const a=setTimeout(()=>{o||(o=!0,r(new n(i)))},t);Promise.resolve(e()).then(e=>{o||(o=!0,clearTimeout(a),s(e))},e=>{o||(o=!0,clearTimeout(a),r(e))})})}function s(){return(new Date).getTime()}function r(e){if(\"number\"==typeof e)return Number.isFinite(e)?e:null;if(\"string\"==typeof e){const t=Date.parse(e);return Number.isNaN(t)?null:t}return null}const o=\"#4593F8\",a=\"#FFFFFF\",l=\"#000000\",c={POSITION:\"bottom-right\",PRIMARY_COLOR:o,AUTO_OPEN:!1,AUTO_RESPONSE_MESSAGE:\"\",UNREAD_ANIMATION:\"bounce\",TEST_AGENT_MODE:!1,START_HIDDEN:!1,DISPLAY_MODE:\"floating\",SIDE_PANEL_SIDE:\"right\",SIDE_PANEL_BEHAVIOR:\"push\",COLOR_SCHEME:\"light\"},d=600,u=480,p=768,h=420,g=[\"#__next\",\"#root\",\"#app\",\"body\"],m=new Map;function f(e){return Math.max(0,Math.min(255,Math.round(e)))}function b(e){const t=e.trim().replace(/^#/,\"\");if(!/^(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t))return null;const n=t.length<=4?t.slice(0,3).replace(/./g,e=>e+e):t.slice(0,6);return{r:parseInt(n.slice(0,2),16),g:parseInt(n.slice(2,4),16),b:parseInt(n.slice(4,6),16)}}function y(e){const t=/^rgba?\\(([^)]*)\\)$/i.exec(e.trim());if(!t)return null;const n=t[1].split(/[\\s,/]+/).filter(Boolean).slice(0,3);if(n.length<3)return null;const i=n.map(e=>{const t=parseFloat(e);return e.includes(\"%\")?t/100*255:t});return i.some(e=>Number.isNaN(e))?null:{r:f(i[0]),g:f(i[1]),b:f(i[2])}}const v=b(o)??{r:0,g:0,b:0};function w(e){if(\"string\"!=typeof e)return v;const t=m.get(e);if(t)return t;const n=b(e)??y(e)??function(e){try{const t=document.createElement(\"canvas\").getContext(\"2d\");if(!t)return null;t.fillStyle=\"#000000\",t.fillStyle=e;const n=t.fillStyle;if(t.fillStyle=\"#ffffff\",t.fillStyle=e,\"string\"!=typeof n||t.fillStyle!==n)return null;const i=b(n)??y(n);if(i)return i;t.fillRect(0,0,1,1);const[s,r,o]=t.getImageData(0,0,1,1).data;return{r:s,g:r,b:o}}catch{return null}}(e)??v;return m.set(e,n),n}function x(e,t){const{r:n,g:i,b:s}=w(e);return function({r:e,g:t,b:n}){return`#${[e,t,n].map(e=>e.toString(16).padStart(2,\"0\")).join(\"\")}`}({r:f(n+t),g:f(i+t),b:f(s+t)})}function k(e,t=1){const{r:n,g:i,b:s}=w(e);return`rgba(${n}, ${i}, ${s}, ${t})`}function S(e){const{r:t,g:n,b:i}=w(e);return`${t}, ${n}, ${i}`}function C(e,t=20){return x(e,-Math.round(2.55*t))}function E(e,t=20){return x(e,Math.round(2.55*t))}function M(e){const{r:t,g:n,b:i}=w(e),[s,r,o]=[t/255,n/255,i/255].map(e=>e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4));return.2126*s+.7152*r+.0722*o}function A(e){return M(e)>.5?l:a}const _={blar:o,blue:\"#007BFF\",green:\"#28A745\",purple:\"#6F42C1\",red:\"#DC3545\",orange:\"#FD7E14\",teal:\"#20C997\",indigo:\"#6610F2\"},T=\"Blar\",I='\\n<svg width=\"16\" height=\"16\" viewBox=\"0 0 215 215\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\\n<path d=\"M103.617 107.018C103.75 107.002 103.885 107.002 104.018 107.018C104.338 107.058 104.639 107.193 104.882 107.406L105.559 107.999L106.587 108.77C106.912 109.014 107.255 109.232 107.613 109.423L108.468 109.879C108.719 110.013 108.991 110.073 109.257 110.066C109.523 110.073 109.795 110.013 110.046 109.879L110.901 109.423C111.259 109.232 111.602 109.014 111.927 108.77L112.955 107.999L113.632 107.406C113.875 107.193 114.176 107.058 114.496 107.018C114.629 107.002 114.764 107.002 114.897 107.018L115.332 107.073C115.493 107.093 115.649 107.143 115.792 107.22L115.854 107.253C116.003 107.333 116.129 107.448 116.222 107.588C116.306 107.714 116.361 107.857 116.384 108.006L116.554 109.143C116.684 110.01 117.492 110.607 118.358 110.477C119.224 110.347 119.821 109.539 119.691 108.672L119.521 107.535C119.429 106.925 119.204 106.342 118.862 105.828C118.48 105.255 117.964 104.785 117.358 104.459L117.296 104.425C116.808 104.163 116.276 103.992 115.726 103.924L115.29 103.869C114.896 103.82 114.497 103.82 114.102 103.869C113.154 103.988 112.263 104.388 111.543 105.017L110.956 105.532L110.024 106.231C109.829 106.377 109.623 106.508 109.408 106.623L109.257 106.704L109.106 106.623C108.891 106.508 108.685 106.377 108.49 106.231L107.558 105.532L106.971 105.017C106.251 104.388 105.36 103.988 104.412 103.869C104.017 103.82 103.618 103.82 103.224 103.869L102.788 103.924C102.238 103.992 101.706 104.163 101.218 104.425L101.156 104.459C100.55 104.785 100.034 105.255 99.6521 105.828C99.3097 106.342 99.0847 106.925 98.9932 107.535L98.8227 108.672C98.6928 109.539 99.2897 110.347 100.156 110.477C101.022 110.607 101.83 110.01 101.96 109.143L102.13 108.006C102.153 107.857 102.208 107.714 102.292 107.588C102.385 107.448 102.511 107.333 102.66 107.253L102.722 107.22C102.865 107.143 103.021 107.093 103.181 107.073L103.617 107.018Z\" fill=\"#4593F8\"/>\\n<path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M53.8877 88.3235V87.4514C53.8877 85.3777 54.1418 83.3117 54.6441 81.2998L54.7973 80.6863L54.8121 80.6356C55.4074 78.592 56.1852 76.606 57.1362 74.7017L57.4088 74.2798C58.1782 73.0892 59.0571 71.9732 60.034 70.9461L60.4065 70.5546C60.911 70.0242 61.4529 69.5308 62.0282 69.0782C62.6639 68.5781 63.3384 68.1294 64.0452 67.7362L65.3222 67.0259L65.9529 66.7101C67.0856 66.1431 68.295 65.7446 69.5428 65.5273C70.2793 65.3991 71.0254 65.3346 71.773 65.3346H72.2009C72.9845 65.3346 73.7666 65.3994 74.5395 65.5284C75.838 65.7451 77.1001 66.1412 78.2897 66.7054L78.9655 67.0259L80.0167 67.6574C81.0461 68.2758 82.0145 68.9904 82.909 69.7917L83.1501 70.0077C83.7378 70.5343 84.2828 71.1066 84.7801 71.7193C85.4066 72.4914 85.9544 73.3242 86.4154 74.2053L86.5147 74.3953C86.9386 75.2054 87.2966 76.0483 87.5854 76.9158L88.191 78.7348L88.3395 79.3296C88.7593 81.0106 89.0141 82.7286 89.1006 84.4592V87.8417L88.7108 90.9641L88.6206 91.31C88.162 93.0704 87.5396 94.784 86.7617 96.4283L86.4267 97.0033C85.4396 98.6975 84.2898 100.291 82.9935 101.762L82.9272 101.829C81.5042 103.254 79.9119 104.498 78.1859 105.535C76.2041 106.398 74.0948 106.969 71.9489 107.226H71.8037C70.0044 107.226 68.2148 106.964 66.4916 106.446L64.8825 105.787C64.0513 105.446 63.2536 105.029 62.4997 104.541C61.784 104.077 61.1107 103.551 60.4876 102.969L59.475 102.023L57.6559 99.8108L56.2266 97.5992L56.079 97.2889C55.3131 95.6784 54.7096 93.9954 54.2775 92.2651C54.0183 90.9673 53.8877 89.647 53.8877 88.3235ZM60.2324 87.6111V87.0434C60.2324 85.6924 60.3994 84.3466 60.7296 83.0366L60.8306 82.6358L60.8396 82.6051C61.2316 81.2721 61.7434 79.9774 62.3687 78.7368L62.5457 78.4654C63.0533 77.6874 63.6325 76.9586 64.2758 76.2886L64.5181 76.0363C64.8508 75.6898 65.208 75.3676 65.5869 75.0723C66.0044 74.7469 66.4471 74.4551 66.9107 74.1996L67.7523 73.7358L68.1646 73.5314C68.9113 73.1611 69.7076 72.901 70.5288 72.7594C71.0127 72.6759 71.5028 72.6339 71.9938 72.6339H72.2771C72.7918 72.6339 73.3056 72.6761 73.8134 72.7601C74.668 72.9013 75.499 73.1598 76.2829 73.5281L76.725 73.7358L77.4195 74.1492C78.0944 74.5508 78.7297 75.0154 79.3171 75.5367L79.4789 75.6803C79.8641 76.0222 80.2217 76.3941 80.5481 76.7926C80.9607 77.2963 81.3218 77.8402 81.6259 78.416L81.6891 78.5359C81.9683 79.0645 82.2043 79.6148 82.3947 80.1815L82.7922 81.3644L82.8901 81.7528C83.166 82.8474 83.3335 83.9665 83.3904 85.0939V87.2977L83.134 89.332L83.0753 89.5554C82.7733 90.7036 82.3638 91.8207 81.8522 92.8919L81.6336 93.2637C80.9833 94.3694 80.2265 95.4088 79.374 96.3672L79.3335 96.4074C78.3956 97.3377 77.3474 98.1497 76.2123 98.8252C74.9088 99.3874 73.5199 99.7594 72.1105 99.9271H72.0136C70.8311 99.9271 69.6548 99.7558 68.5214 99.4186L67.4608 98.9882C66.9157 98.767 66.3923 98.4958 65.8972 98.1781C65.4258 97.8755 64.982 97.5319 64.5709 97.1514L63.9069 96.5367L62.7106 95.0957L61.7706 93.6548L61.6726 93.4508C61.1695 92.4028 60.7729 91.3069 60.4888 90.1796C60.3183 89.3341 60.2324 88.4737 60.2324 87.6111Z\" fill=\"#4593F8\"/>\\n<path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M128.249 81.9604L128.636 79.7349C129.151 77.9932 129.827 76.3033 130.655 74.6869L131.087 73.8439L131.891 72.5524C132.386 71.7569 132.954 71.0095 133.588 70.3199C134.155 69.703 134.773 69.1346 135.435 68.6208L135.603 68.4908C136.288 67.9586 137.018 67.4845 137.782 67.0736L137.915 67.0021C138.522 66.6764 139.152 66.3971 139.8 66.1668C140.866 65.788 141.976 65.5438 143.102 65.4399L144.243 65.3346C145.956 65.3346 147.663 65.5477 149.323 65.9691L149.403 65.9892L151.255 66.7052C151.825 66.9257 152.378 67.1887 152.909 67.4919C153.75 67.9721 154.531 68.5503 155.236 69.2146L155.981 69.9165L156.214 70.153C157.261 71.2154 158.218 72.3623 159.077 73.5821L160.237 75.5457L161.269 77.6403L161.361 77.867C161.901 79.1978 162.345 80.5659 162.688 81.9604L163.075 84.3169L163.333 86.6733V89.1606L163.075 91.517C162.647 93.3413 162.085 95.1412 161.398 96.8844L160.237 98.979L158.561 101.335L157.549 102.435C157.02 103.01 156.45 103.546 155.844 104.039L155.666 104.183C155.103 104.64 154.503 105.051 153.873 105.41C153.13 105.835 152.348 106.186 151.538 106.461L151.483 106.479C150.785 106.715 150.07 106.895 149.343 107.018L149.306 107.025C148.512 107.159 147.708 107.226 146.903 107.226H145.92L145.143 107.177C144.287 107.123 143.438 106.989 142.607 106.779C141.722 106.554 140.862 106.243 140.038 105.849L139.084 105.394L137.149 104.216L135.214 102.645L134.138 101.552C133.566 100.972 133.037 100.352 132.553 99.6977C132.006 98.9579 131.52 98.1756 131.098 97.3582L130.313 95.8371L130.24 95.6647C129.517 93.9518 128.979 92.1663 128.636 90.3388L128.249 87.5897L128.12 84.8405L128.249 81.9604ZM134.867 83.4659L135.121 82.016C135.46 80.8813 135.904 79.7808 136.448 78.729L136.733 78.1779L137.26 77.339C137.587 76.819 137.961 76.3309 138.379 75.8809C138.751 75.4796 139.157 75.1103 139.591 74.7766L139.701 74.6916C140.153 74.3439 140.634 74.0345 141.137 73.7665L141.222 73.7211C141.622 73.5084 142.037 73.3261 142.464 73.1758C143.165 72.9292 143.893 72.7703 144.633 72.7027L145.386 72.6339C146.512 72.6339 147.635 72.7729 148.728 73.0475L148.779 73.0604L149.998 73.5276C150.372 73.6708 150.735 73.8417 151.084 74.0389C151.637 74.3521 152.152 74.7298 152.617 75.164L153.105 75.6191L153.26 75.7748C153.947 76.4659 154.576 77.2126 155.141 78.0073L155.904 79.2867L156.583 80.6513L156.644 80.8C156.999 81.6664 157.29 82.5574 157.516 83.4659L157.77 85.0012L157.94 86.5364V88.157L157.77 89.6922C157.489 90.8816 157.119 92.0534 156.668 93.1891L155.904 94.5538L154.801 96.089L154.138 96.8041C153.789 97.1798 153.413 97.5297 153.014 97.851L152.9 97.943C152.528 98.2418 152.133 98.5098 151.718 98.7445C151.23 99.0206 150.717 99.2492 150.185 99.4274L150.146 99.4405C149.688 99.5941 149.218 99.7114 148.741 99.7913L148.714 99.7958C148.193 99.8832 147.664 99.9271 147.135 99.9271H146.488L145.976 99.8949C145.414 99.8596 144.856 99.7728 144.31 99.6355C143.728 99.4891 143.161 99.286 142.618 99.0292L141.992 98.7331L140.72 97.9654L139.448 96.942L138.738 96.2284C138.363 95.8516 138.016 95.4488 137.698 95.0229C137.338 94.5404 137.017 94.0297 136.739 93.4957L136.224 92.5068L136.175 92.3926C135.7 91.2779 135.347 90.1152 135.121 88.9246L134.867 87.1335L134.782 85.3423L134.867 83.4659Z\" fill=\"#4593F8\"/>\\n<path fill-rule=\"evenodd\" clip-rule=\"evenodd\" d=\"M13.9373 142.79C-4.64576 124.199 -4.64577 94.0576 13.9373 75.4669L75.4359 13.943C94.019 -4.64766 124.148 -4.64768 142.731 13.943L201.063 72.2985C219.646 90.8892 219.646 121.031 201.063 139.621L156.334 184.369C156.201 183.644 156.048 182.921 155.875 182.202C153.617 172.801 148.247 164.44 140.637 158.479C137.281 155.85 133.552 153.737 129.572 152.21L127.779 151.522L136.051 149.595L146.996 145.469L151.676 143.226C153.628 142.29 155.496 141.188 157.26 139.933L157.972 139.427C160.475 137.646 162.709 135.512 164.602 133.092L167.299 128.966L169.155 125.517C169.363 125.13 169.251 124.649 168.894 124.394C168.602 124.185 168.211 124.177 167.91 124.374L164.543 126.581C164.056 126.9 163.529 127.155 162.977 127.339L160.379 128.206C158.547 128.817 156.655 129.235 154.736 129.455L152.071 129.76L148.557 130.02C145.198 130.269 141.822 130.191 138.478 129.787C135.701 129.452 132.956 128.893 130.27 128.117L127.169 127.221L126.938 127.167C121.275 125.852 115.482 125.178 109.668 125.158C109.661 125.158 109.653 125.158 109.646 125.158H108.799C108.792 125.158 108.785 125.158 108.778 125.158C102.979 125.181 97.2009 125.855 91.5514 127.167L91.3213 127.221L88.22 128.117C85.5334 128.893 82.7886 129.452 80.0123 129.787C76.6679 130.191 73.2921 130.269 69.9326 130.02L66.4185 129.76L63.7536 129.455C61.8344 129.235 59.9432 128.817 58.1106 128.206L55.5129 127.339C54.9606 127.155 54.4343 126.9 53.9473 126.581L50.58 124.374C50.2792 124.177 49.8883 124.185 49.5956 124.394C49.2384 124.649 49.1267 125.13 49.3348 125.517L51.1913 128.966L53.8878 133.092C55.7813 135.512 58.0145 137.646 60.5183 139.427L61.2296 139.933C62.9937 141.188 64.8621 142.29 66.8143 143.226L71.4942 145.469L82.4388 149.595L90.5137 151.476L88.6003 152.21C84.6206 153.737 80.8911 155.85 77.5351 158.479C69.9255 164.44 64.5552 172.801 62.2973 182.202L60.5609 189.432L13.9373 142.79ZM167.929 116.177L168.061 116.036C168.817 115.226 169.264 114.177 169.325 113.071C169.349 112.653 169.316 112.233 169.229 111.823L169.161 111.505C169.035 110.917 168.836 110.347 168.568 109.808L168.064 108.798L167.361 107.033C167.139 106.475 166.877 105.934 166.577 105.414L166.422 105.145C165.878 104.203 165.484 103.182 165.254 102.118L165.174 101.75C165.028 101.073 164.973 100.38 165.011 99.6881C165.059 98.8275 165.25 97.9808 165.577 97.1834L165.99 96.176L166.898 93.7038C167.501 91.5404 167.888 89.3226 168.053 87.0827L168.064 86.9376V83.5545L167.675 80.5618L167.543 79.9416C167.114 77.9301 166.507 75.9605 165.731 74.0558L165.362 73.2133C164.658 71.6089 163.828 70.0632 162.879 68.5908L162.745 68.4025C161.54 66.7093 160.198 65.1185 158.731 63.6463L155.88 61.3042C154.328 60.3522 152.687 59.5534 150.981 58.919L150.047 58.5717C148.065 57.9662 146.02 57.5734 143.954 57.4006C142.056 57.4872 140.166 57.7116 138.3 58.0718L137.733 58.1813L136.714 58.5223C135.581 58.9014 134.483 59.3808 133.435 59.9547C132.585 60.42 131.77 60.9461 130.996 61.5289L129.566 62.6054L127.829 64.1169C127.691 64.2367 127.564 64.3675 127.447 64.5079C126.418 65.7472 124.658 66.0879 123.242 65.3222L122.308 64.8174L119.586 63.7764L117.123 63.1258L114.271 62.7355L111.549 62.6054L108.957 62.4752H106.105L103.253 62.6054L99.883 63.1258L97.0313 63.7764L94.05 64.8174L93.2014 65.2275C91.6345 65.9849 89.7551 65.6043 88.6059 64.2969L86.6616 62.6054L84.8469 61.1741L83.3265 60.2029C82.4407 59.637 81.5061 59.1516 80.5339 58.7523C79.6086 58.3723 78.6527 58.0719 77.6766 57.8541L77.6163 57.8407C76.3052 57.5482 74.9659 57.4006 73.6226 57.4006H73.5005C72.4251 57.4006 71.3516 57.4898 70.2909 57.6673L68.7737 57.9211L68.4937 57.9998C66.5255 58.553 64.6208 59.3117 62.8111 60.2632L60.4779 61.8247C58.9247 63.0373 57.4655 64.366 56.1129 65.7992L55.8115 66.1186L53.9968 68.4607L52.3117 71.3233L50.7563 74.7064C49.9813 76.6944 49.4477 78.7682 49.1667 80.8834L49.0712 81.6027L48.8119 85.3761C48.8119 87.3674 48.9873 89.3548 49.3361 91.3153L49.4601 92.0122L50.3674 94.8748L51.5846 98.4294C51.7235 98.835 51.8334 99.2501 51.9133 99.6713L51.9587 99.9103C52.1908 101.134 52.1342 102.395 51.7933 103.593L50.8859 106.065L49.9785 108.407L49.2707 110.628C49.0526 111.312 48.9416 112.026 48.9416 112.744V113.283C48.9416 113.844 49.0522 114.399 49.2671 114.917C49.4801 115.43 49.7914 115.896 50.1835 116.29L50.727 116.836C51.2624 117.373 51.8701 117.833 52.5326 118.202L53.0767 118.506C53.603 118.799 54.1497 119.055 54.7126 119.27L56.5893 119.988L59.7002 120.768L63.7185 121.679L66.959 122.2L70.5884 122.46H75.3845L78.625 122.2L82.9025 121.419L86.7912 120.508L90.4206 119.597L94.05 118.817C96.9841 118.124 99.9655 117.65 102.97 117.398L103.124 117.385H115.567C119.017 117.385 122.46 117.69 125.856 118.296L126.585 118.426L130.344 119.337L136.048 120.768L140.584 121.809L144.732 122.33H149.528L153.547 121.809L157.694 120.768C160.11 120.076 162.468 119.194 164.746 118.132L164.953 118.036L166.445 117.287C167.002 117.008 167.504 116.632 167.929 116.177Z\" fill=\"#4593F8\"/>\\n</svg>\\n\\n'.trim(),L='<path d=\"M12 8V4H8\"/><rect width=\"16\" height=\"12\" x=\"4\" y=\"8\" rx=\"2\"/><path d=\"M2 14h2\"/><path d=\"M20 14h2\"/><path d=\"M15 13v2\"/><path d=\"M9 13v2\"/>',R='<path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\"/>',$=`(max-height: ${u}px) and (pointer: coarse)`,N=`(max-width: ${u}px), ${$}`,P=()=>window.matchMedia?.(N).matches??!1,F=`\\n  /* ============================================================\\n     Touch ergonomics — any coarse pointer, at any viewport width\\n     ============================================================ */\\n  @media (pointer: coarse) {\\n    /* iOS zooms the whole page when a focused field is under 16px. Every\\n       text entry in the widget is bumped to 16px on touch devices; the\\n       desktop sheet keeps its tighter 13-14px. */\\n    .support-chat-input,\\n    .support-text-input,\\n    .support-prechat-field input {\\n      font-size: 16px;\\n    }\\n\\n    .support-chat-input {\\n      height: 44px;\\n      min-height: 44px;\\n      line-height: 22px;\\n      padding: 11px 16px;\\n    }\\n\\n    /* Header controls ship as 16-20px glyphs with 4-6px of padding, which\\n       is well under the 44px minimum. Grow the hit area, not the glyph. */\\n    .support-close-btn,\\n    .support-test-reconnect-btn,\\n    .support-human-btn,\\n    .support-expand-btn,\\n    .support-menu-btn,\\n    .support-new-chat-btn,\\n    .support-back-to-menu-btn,\\n    .support-attach-btn,\\n    .support-obc-close,\\n    .support-activation-form-close,\\n    .support-nps-close {\\n      min-width: var(--widget-touch-target);\\n      min-height: var(--widget-touch-target);\\n    }\\n\\n    .support-send-btn,\\n    .support-mic-btn,\\n    .support-voice-action {\\n      width: var(--widget-touch-target);\\n      height: var(--widget-touch-target);\\n    }\\n\\n    /* The dismiss badge overhangs the launcher's top-right corner and its\\n       handler stops propagation, so a centred 44px hit area would swallow\\n       taps meant for the launcher itself. Grow it outward into empty space\\n       instead, keeping the overlap to a 2px sliver. */\\n    .support-bubble-close::before {\\n      content: '';\\n      position: absolute;\\n      inset: -12px -12px -2px -2px;\\n    }\\n\\n    .support-onboarding-bubble-card .support-obc-close {\\n      opacity: 1;\\n      visibility: visible;\\n    }\\n\\n    .support-obc-heading {\\n      padding-right: 28px;\\n    }\\n\\n    .support-tab {\\n      min-height: 56px;\\n    }\\n\\n    .support-action-button,\\n    .support-prechat-submit,\\n    .support-activation-form-submit,\\n    .support-ticket-sheet-cta,\\n    .support-home-shortcut-card,\\n    .support-conversation-item,\\n    .support-nudge-cta,\\n    .support-nudge-confirm .support-interactive-button.pill {\\n      min-height: var(--widget-touch-target);\\n    }\\n\\n    .support-nps-score {\\n      height: var(--widget-touch-target);\\n    }\\n\\n    /* Interactive-message controls are 16px boxes; enlarge the whole row\\n       so the label is part of the target instead of a 16px square. */\\n    .support-radio-option,\\n    .support-checkbox-option {\\n      min-height: var(--widget-touch-target);\\n    }\\n\\n    .support-radio-option input[type=\"radio\"],\\n    .support-checkbox-option input[type=\"checkbox\"] {\\n      width: 20px;\\n      height: 20px;\\n    }\\n\\n    /* Accepting a call is the highest-stakes tap in the widget — full\\n       touch-target height and a bigger label than the desktop card. */\\n    .support-voice-call-btn {\\n      height: 48px;\\n      border-radius: 24px;\\n      font-size: 14px;\\n    }\\n\\n    .support-voice-call-btn svg {\\n      width: 17px;\\n      height: 17px;\\n    }\\n\\n    .support-voice-call-pill {\\n      min-height: var(--widget-touch-target);\\n    }\\n\\n    .support-voice-call-pill-body {\\n      min-height: var(--widget-touch-target);\\n    }\\n\\n    /* Grow the hang-up hit area to 44px without inflating the 32px circle —\\n       the overhang lands on the pill body, whose own action is lower-stakes. */\\n    .support-voice-call-hangup::before,\\n    .support-voice-call-stop-share::before,\\n    .support-voice-call-share-here::before {\\n      content: '';\\n      position: absolute;\\n      inset: -6px;\\n    }\\n\\n    /* Hover transforms read as stuck state after a tap on touch. */\\n    .support-bubble:hover,\\n    .support-send-btn:hover,\\n    .support-mic-btn:hover,\\n    .support-attach-btn:hover,\\n    .support-conversation-picker-card:hover {\\n      transform: none;\\n    }\\n  }\\n\\n  /* ============================================================\\n     Tablet and small laptop — keep the floating panel on screen\\n     ============================================================ */\\n  @media (max-width: ${p}px) and (min-width: ${u+1}px) {\\n    .support-widget-container {\\n      --widget-edge-gap: 16px;\\n      --widget-body-pad: 18px;\\n      --widget-hero-pad-x: 24px;\\n    }\\n\\n    .support-chat-window,\\n    .support-chat-window.expanded {\\n      width: min(420px, calc(100vw - 2 * var(--widget-edge-gap) - var(--widget-safe-left) - var(--widget-safe-right)));\\n      height: min(600px, calc(var(--widget-viewport-height) - 140px));\\n    }\\n\\n    .side-panel-mode .support-chat-window,\\n    .side-panel-mode .support-chat-window.expanded {\\n      width: min(420px, 100vw);\\n      height: var(--widget-viewport-height);\\n    }\\n  }\\n\\n  /* ============================================================\\n     Phone — full-screen sheet\\n     ============================================================ */\\n  @media ${N} {\\n    .support-widget-container {\\n      --widget-edge-gap: 12px;\\n      --widget-radius: 0px;\\n      --widget-body-pad: 16px;\\n      --widget-footer-pad: 8px 12px;\\n      --widget-header-pad-x: 12px;\\n      --widget-hero-pad-x: 20px;\\n\\n      /* A tight column cannot spare a 15-22% gutter the way the desktop panel\\n         can, so both bubble types claim more of it. */\\n      --widget-bubble-max-agent: 85%;\\n      --widget-bubble-max-user: 92%;\\n    }\\n\\n    /* Every launch position collapses to the same full-screen sheet, so the\\n       four position variants and side-panel mode are folded together. */\\n    .support-chat-window,\\n    .support-chat-window.expanded,\\n    .position-bottom-left .support-chat-window,\\n    .position-top-left .support-chat-window,\\n    .position-top-right .support-chat-window,\\n    .side-panel-mode .support-chat-window,\\n    .side-panel-mode.side-left .support-chat-window,\\n    .side-panel-mode .support-chat-window.expanded {\\n      top: 0;\\n      right: 0;\\n      bottom: 0;\\n      left: 0;\\n      width: 100%;\\n      max-width: none;\\n      height: var(--widget-viewport-height);\\n      max-height: var(--widget-viewport-height);\\n      box-shadow: none;\\n    }\\n\\n    /* A scale-in pop reads as a dialog; a full-screen surface should slide.\\n       Opacity stays at 1 so the sheet is never a translucent overlay. */\\n    .support-chat-window,\\n    .position-top-left .support-chat-window,\\n    .position-top-right .support-chat-window,\\n    .side-panel-mode .support-chat-window,\\n    .side-panel-mode.side-left .support-chat-window {\\n      opacity: 1;\\n      transform: translateY(100%);\\n      /* The slide alone does not hide it: the sheet's height follows the keyboard,\\n         so translateY(100%) left a closed sheet over half the page (session 24966). */\\n      transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1), visibility 0s linear 0.28s;\\n    }\\n\\n    .support-chat-window.open,\\n    .position-top-left .support-chat-window.open,\\n    .position-top-right .support-chat-window.open,\\n    .side-panel-mode .support-chat-window.open,\\n    .side-panel-mode.side-left .support-chat-window.open {\\n      transform: translateY(0);\\n      transition-delay: 0s;\\n    }\\n\\n    /* Rubber-banding the sheet would expose the host page behind it. */\\n    .support-chat-window {\\n      overscroll-behavior: none;\\n    }\\n\\n    .support-chat-header {\\n      padding-top: calc(var(--widget-header-pad-y) + var(--widget-safe-top));\\n      padding-left: calc(var(--widget-header-pad-x) + var(--widget-safe-left));\\n      padding-right: calc(var(--widget-header-pad-x) + var(--widget-safe-right));\\n    }\\n\\n    /* The composer and the tab bar are the two surfaces that sit against the\\n       home indicator, so both absorb the bottom inset. */\\n    .support-chat-footer {\\n      padding-bottom: calc(8px + var(--widget-safe-bottom));\\n      padding-left: calc(12px + var(--widget-safe-left));\\n      padding-right: calc(12px + var(--widget-safe-right));\\n    }\\n\\n    .support-tab-bar {\\n      height: auto;\\n      min-height: 56px;\\n      padding-bottom: var(--widget-safe-bottom);\\n    }\\n\\n    .support-view {\\n      overflow-x: hidden;\\n      -webkit-overflow-scrolling: touch;\\n    }\\n\\n    .support-chat-body,\\n    .support-view[data-view=\"home\"] {\\n      padding-left: calc(var(--widget-body-pad) + var(--widget-safe-left));\\n      padding-right: calc(var(--widget-body-pad) + var(--widget-safe-right));\\n    }\\n\\n    .support-messages-list-wrap,\\n    .support-releases-list,\\n    .support-messages-subtabs {\\n      padding-left: calc(8px + var(--widget-safe-left));\\n      padding-right: calc(8px + var(--widget-safe-right));\\n    }\\n\\n    .support-welcome-hero {\\n      margin-left: calc(-1 * (var(--widget-body-pad) + var(--widget-safe-left)));\\n      margin-right: calc(-1 * (var(--widget-body-pad) + var(--widget-safe-right)));\\n      padding: 12px var(--widget-hero-pad-x) 40px;\\n    }\\n\\n    .support-welcome-hero-title {\\n      font-size: 20px;\\n    }\\n\\n    .support-welcome-hero-content {\\n      max-width: 100%;\\n    }\\n\\n    .support-message-content {\\n      max-width: 100%;\\n      overflow-wrap: anywhere;\\n    }\\n\\n    /* The centred header title has to give way to the button clusters. */\\n    .support-entity-title {\\n      max-width: min(160px, 100%);\\n    }\\n\\n    /* Cards inside the full-screen panel can fill their parent. */\\n    .support-conversation-picker-card {\\n      width: 100%;\\n      max-width: 100%;\\n      box-sizing: border-box;\\n    }\\n\\n    /* Nudges live beside the 60px launcher, not inside the chat panel. Size\\n       them against the viewport so their text and actions have room to flow. */\\n    .support-awareness-bubble {\\n      max-width: calc(100vw - 2 * var(--widget-edge-gap) - var(--widget-safe-left) - var(--widget-safe-right));\\n      box-sizing: border-box;\\n    }\\n\\n    /* Keep an unusually long teaser on screen. Scrolling the message instead\\n       of the bubble preserves its pointer and leaves × available at the top. */\\n    .support-awareness-bubble:not(.support-nudge-card) {\\n      align-items: flex-start;\\n    }\\n\\n    .support-awareness-message {\\n      min-width: 0;\\n      max-height: calc(var(--widget-viewport-height) - 134px - var(--widget-safe-top) - var(--widget-safe-bottom));\\n      overflow-y: auto;\\n      overflow-wrap: anywhere;\\n    }\\n\\n    .support-awareness-bubble.support-nudge-card {\\n      width: min(360px, calc(100vw - 2 * var(--widget-edge-gap) - var(--widget-safe-left) - var(--widget-safe-right)));\\n      max-width: none;\\n      max-height: calc(var(--widget-viewport-height) - 110px - var(--widget-safe-top) - var(--widget-safe-bottom));\\n      overflow-y: auto;\\n    }\\n\\n    .support-awareness-bubble.support-awareness-bubble--toast {\\n      right: calc(var(--widget-edge-gap) + var(--widget-safe-right));\\n    }\\n\\n    .support-nps-banner,\\n    .support-activation-form-card {\\n      max-width: 100%;\\n    }\\n\\n    .support-nps-banner {\\n      bottom: calc(12px + var(--widget-safe-bottom));\\n      width: calc(100% - 24px - var(--widget-safe-left) - var(--widget-safe-right));\\n    }\\n\\n    /* 11 scores across a phone leaves ~23px per button. Two rows of 6 and 5\\n       keep every score tappable. */\\n    .support-nps-score-row {\\n      grid-template-columns: repeat(6, 1fr);\\n      gap: 6px;\\n    }\\n\\n    .support-activation-form-overlay {\\n      padding: 12px;\\n      padding-bottom: calc(12px + var(--widget-safe-bottom));\\n      align-items: flex-end;\\n    }\\n\\n    .support-activation-form-card {\\n      max-height: calc(var(--widget-viewport-height) - 24px - var(--widget-safe-bottom));\\n    }\\n\\n    /* The bottom sheet is already a mobile pattern — it just needs to clear\\n       the home indicator and use more of the taller screen. */\\n    .support-ticket-sheet {\\n      max-height: 88%;\\n      padding-bottom: calc(8px + var(--widget-safe-bottom));\\n    }\\n\\n    .support-prechat-form-container {\\n      padding: 16px;\\n    }\\n\\n    /* Media must never be the thing that introduces a horizontal scrollbar. */\\n    .support-chat-body img,\\n    .support-chat-body video,\\n    .support-view img,\\n    .support-view video,\\n    .support-message-content img {\\n      max-width: 100%;\\n      height: auto;\\n    }\\n\\n    /* The sheet already fills the screen, so there is no bigger window to expand into. */\\n    .support-expand-toggle {\\n      display: none;\\n    }\\n  }\\n\\n  /* ============================================================\\n     Landscape phones — vertical space is the scarce axis\\n     ============================================================ */\\n  @media ${$} and (orientation: landscape) {\\n    .support-welcome-hero {\\n      padding-top: 8px;\\n      padding-bottom: 20px;\\n    }\\n\\n    .support-welcome-hero-title {\\n      font-size: 17px;\\n    }\\n\\n    .support-welcome-hero-subtitle {\\n      display: none;\\n    }\\n\\n    .support-chat-header {\\n      min-height: 40px;\\n      --widget-header-pad-y: 6px;\\n    }\\n\\n    .support-tab-bar {\\n      min-height: 46px;\\n    }\\n\\n    .support-tab svg {\\n      width: 18px;\\n      height: 18px;\\n    }\\n  }\\n\\n  /* ============================================================\\n     Very narrow phones (iPhone SE and down)\\n     ============================================================ */\\n  @media (max-width: 360px) {\\n    .support-widget-container {\\n      --widget-body-pad: 12px;\\n      --widget-hero-pad-x: 16px;\\n    }\\n\\n    .support-welcome-hero-title {\\n      font-size: 18px;\\n    }\\n\\n    .support-tab-label {\\n      font-size: 10px;\\n    }\\n\\n    /* Header keeps the close control and the title; secondary actions fold\\n       away rather than squeezing the title to an ellipsis. */\\n    .support-test-reconnect-btn,\\n    .support-expand-btn {\\n      display: none;\\n    }\\n  }\\n`,O=\"undefined\"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,q=globalThis,H=\"10.65.0\";function B(){return D(q),q}function D(e){const t=e.__SENTRY__=e.__SENTRY__||{};return t.version=t.version||H,t[H]=t[H]||{}}function z(e,t,n=q){const i=n.__SENTRY__=n.__SENTRY__||{},s=i[H]=i[H]||{};return s[e]||(s[e]=t())}const U={};function j(e){if(!(\"console\"in q))return e();const t=q.console,n={},i=Object.keys(U);i.forEach(e=>{const i=U[e];n[e]=t[e],t[e]=i});try{return e()}finally{i.forEach(e=>{t[e]=n[e]})}}function W(){return G().enabled}function V(e,...t){O&&W()&&j(()=>{q.console[e](`Sentry Logger [${e}]:`,...t)})}function G(){return O?z(\"loggerSettings\",()=>({enabled:!1})):{enabled:!1}}const K={enable:function(){G().enabled=!0},disable:function(){G().enabled=!1},isEnabled:W,log:function(...e){V(\"log\",...e)},warn:function(...e){V(\"warn\",...e)},error:function(...e){V(\"error\",...e)}},Y=\"?\",X=/\\(error: (.*)\\)/,J=/captureMessage|captureException/;function Q(e){return e[e.length-1]||{}}const Z=\"<anonymous>\";function ee(e){const t=e.exception;if(t){const e=[];try{return t.values.forEach(t=>{t.stacktrace.frames&&e.push(...t.stacktrace.frames)}),e}catch{return}}}const te=Object.prototype.toString;function ne(e){switch(te.call(e)){case\"[object Error]\":case\"[object Exception]\":case\"[object DOMException]\":case\"[object WebAssembly.Exception]\":return!0;default:return he(e,Error)}}function ie(e,t){return te.call(e)===`[object ${t}]`}function se(e){return ie(e,\"ErrorEvent\")}function re(e){return ie(e,\"DOMError\")}function oe(e){return ie(e,\"String\")}function ae(e){return\"object\"==typeof e&&null!==e&&\"__sentry_template_string__\"in e&&\"__sentry_template_values__\"in e}function le(e){return null===e||ae(e)||\"object\"!=typeof e&&\"function\"!=typeof e}function ce(e){return ie(e,\"Object\")}function de(e){return\"object\"==typeof e&&null!==e}function ue(e){return\"undefined\"!=typeof Event&&he(e,Event)}function pe(e){return Boolean(e?.then&&\"function\"==typeof e.then)}function he(e,t){try{return e instanceof t}catch{return!1}}function ge(e,t,n){try{Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0})}catch{O&&K.log(`Failed to add non-enumerable property \"${String(t)}\" to object`,e)}}function me(e){if(ne(e))return{message:e.message,name:e.name,stack:e.stack,...fe(e)};if(ue(e)){const{type:t,target:n,currentTarget:i,detail:s}=e;return{type:t,target:n,currentTarget:i,...s?{detail:s}:{},...fe(e)}}return e}function fe(e){return de(e)?Object.fromEntries(Object.entries(e)):{}}let be;function ye(e){if(void 0!==be)return be?be(e):e();const t=Symbol.for(\"__SENTRY_SAFE_RANDOM_ID_WRAPPER__\"),n=q;return t in n&&\"function\"==typeof n[t]?(be=n[t],be(e)):(be=null,e())}function ve(){return ye(()=>Math.random())}function we(){return ye(()=>Date.now())}const xe=Symbol.for(\"sentry.skipNormalization\"),ke=Symbol.for(\"sentry.overrideNormalizationDepth\");let Se;function Ce(e,t=100,n=1/0){try{return Me(\"\",e,t,n)}catch(e){return{ERROR:`**non-serializable** (${e})`}}}function Ee(e,t=3,n=102400){const i=Ce(e,t);return s=i,function(e){return~-encodeURI(e).split(/%..|./).length}(JSON.stringify(s))>n?Ee(e,t-1,n):i;var s}function Me(e,t,n=1/0,i=1/0,s=function(){const e=new WeakSet;function t(t){return!!e.has(t)||(e.add(t),!1)}function n(t){e.delete(t)}return[t,n]}()){const[r,o]=s;if(null==t||[\"boolean\",\"string\"].includes(typeof t)||\"number\"==typeof t&&Number.isFinite(t))return t;const a=function(e,t){try{if(\"undefined\"!=typeof global&&t===global)return\"[Global]\";if(\"number\"==typeof t&&!Number.isFinite(t))return`[${t}]`;if(\"function\"==typeof t)return`[Function: ${function(e){try{return e&&\"function\"==typeof e&&e.name||Z}catch{return Z}}(t)}]`;if(\"symbol\"==typeof t)return`[${String(t)}]`;if(\"bigint\"==typeof t)return`[BigInt: ${String(t)}]`;const e=function(e){const t=Object.getPrototypeOf(e);return t?.constructor?t.constructor.name:\"null prototype\"}(t);return`[object ${e}]`}catch(e){return`**non-serializable** (${e})`}}(0,t);if(!a.startsWith(\"[object \"))return a;if(function(e){return Boolean(e[xe])}(t))return t;const l=function(e){const t=e[ke];return\"number\"==typeof t?t:void 0}(t),c=void 0!==l?l:n;if(0===c)return a.replace(\"object \",\"\");if(r(t))return\"[Circular ~]\";const d=t;if(d&&\"function\"==typeof d.toJSON)try{return Me(\"\",d.toJSON(),c-1,i,s)}catch{}const u=Array.isArray(t)?[]:{};let p=0;const h=me(t);for(const e in h){if(!Object.prototype.hasOwnProperty.call(h,e))continue;if(p>=i){u[e]=\"[MaxProperties ~]\";break}const t=h[e];u[e]=Me(e,t,c-1,i,s),p++}return o(t),u}function Ae(e,t=0){return\"string\"!=typeof e||0===t||e.length<=t?e:`${e.slice(0,t)}...`}function _e(e,t,n=!1){return!!oe(e)&&(ie(t,\"RegExp\")?t.test(e):oe(t)?n?e===t:e.includes(t):\"function\"==typeof t&&t(e))}function Te(e=function(){const e=q;return e.crypto||e.msCrypto}()){try{if(e?.randomUUID)return ye(()=>e.randomUUID()).replace(/-/g,\"\")}catch{}return Se||(Se=\"10000000100040008000100000000000\"),Se.replace(/[018]/g,e=>(e^(16*ve()&15)>>e/4).toString(16))}function Ie(e,t,n){const i=e.exception=e.exception||{},s=i.values=i.values||[],r=s[0]=s[0]||{};r.value||(r.value=t||\"\"),r.type||(r.type=\"Error\")}function Le(e,t){const n=function(e){return e.exception?.values?.[0]}(e);if(!n)return;const i=n.mechanism;if(n.mechanism={type:\"generic\",handled:!0,...i,...t},t&&\"data\"in t){const e={...i?.data,...t.data};n.mechanism.data=e}}function Re(e){if(function(e){try{return e.__sentry_captured__}catch{}}(e))return!0;try{ge(e,\"__sentry_captured__\",!0)}catch{}return!1}function $e(){return we()/1e3}let Ne;function Pe(){return(Ne??(Ne=function(){const{performance:e}=q;if(!e?.now||!e.timeOrigin)return $e;const t=e.timeOrigin;return()=>(t+ye(()=>e.now()))/1e3}()))()}function Fe(e,t={}){if(t.user&&(!e.ipAddress&&t.user.ip_address&&(e.ipAddress=t.user.ip_address),e.did||t.did||(e.did=t.user.id||t.user.email||t.user.username)),e.timestamp=t.timestamp||Pe(),t.abnormal_mechanism&&(e.abnormal_mechanism=t.abnormal_mechanism),t.ignoreDuration&&(e.ignoreDuration=t.ignoreDuration),t.sid&&(e.sid=32===t.sid.length?t.sid:Te()),void 0!==t.init&&(e.init=t.init),!e.did&&t.did&&(e.did=`${t.did}`),\"number\"==typeof t.started&&(e.started=t.started),e.ignoreDuration)e.duration=void 0;else if(\"number\"==typeof t.duration)e.duration=t.duration;else{const t=e.timestamp-e.started;e.duration=t>=0?t:0}t.release&&(e.release=t.release),t.environment&&(e.environment=t.environment),!e.ipAddress&&t.ipAddress&&(e.ipAddress=t.ipAddress),!e.userAgent&&t.userAgent&&(e.userAgent=t.userAgent),\"number\"==typeof t.errors&&(e.errors=t.errors),t.status&&(e.status=t.status)}function Oe(e,t,n=2){if(!t||\"object\"!=typeof t||n<=0)return t;if(e&&0===Object.keys(t).length)return e;const i={...e};for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(i[e]=Oe(i[e],t[e],n-1));return i}function qe(){return Te()}function He(){return Te().substring(16)}function Be(e){if(e){if(\"object\"==typeof e&&\"deref\"in e&&\"function\"==typeof e.deref)try{return e.deref()}catch{return}return e}}const De=\"_sentrySpan\";function ze(e,t){t?ge(e,De,function(e){try{const t=q.WeakRef;if(\"function\"==typeof t)return new t(e)}catch{}return e}(t)):delete e[De]}function Ue(e){return Be(e[De])}class je{constructor(){this._notifyingListeners=!1,this._scopeListeners=[],this._eventProcessors=[],this._breadcrumbs=[],this._attachments=[],this._user={},this._tags={},this._attributes={},this._extra={},this._contexts={},this._sdkProcessingMetadata={},this._propagationContext={traceId:qe(),sampleRand:ve()}}clone(){const e=new je;return e._breadcrumbs=[...this._breadcrumbs],e._tags={...this._tags},e._attributes={...this._attributes},e._extra={...this._extra},e._contexts={...this._contexts},this._contexts.flags&&(e._contexts.flags={values:[...this._contexts.flags.values]}),e._user=this._user,e._level=this._level,e._session=this._session,e._transactionName=this._transactionName,e._fingerprint=this._fingerprint,e._eventProcessors=[...this._eventProcessors],e._attachments=[...this._attachments],e._sdkProcessingMetadata={...this._sdkProcessingMetadata},e._propagationContext={...this._propagationContext},e._client=this._client,e._lastEventId=this._lastEventId,e._conversationId=this._conversationId,ze(e,Ue(this)),e}setClient(e){this._client=e}setLastEventId(e){this._lastEventId=e}getClient(){return this._client}lastEventId(){return this._lastEventId}addScopeListener(e){this._scopeListeners.push(e)}addEventProcessor(e){return this._eventProcessors.push(e),this}setUser(e){return this._user=e||{email:void 0,id:void 0,ip_address:void 0,username:void 0},this._session&&Fe(this._session,{user:e}),this._notifyScopeListeners(),this}getUser(){return this._user}setConversationId(e){return this._conversationId=e||void 0,this._notifyScopeListeners(),this}setTags(e){return this._tags={...this._tags,...e},this._notifyScopeListeners(),this}setTag(e,t){return this.setTags({[e]:t})}setAttributes(e){return this._attributes={...this._attributes,...e},this._notifyScopeListeners(),this}setAttribute(e,t){return this.setAttributes({[e]:t})}removeAttribute(e){return e in this._attributes&&(delete this._attributes[e],this._notifyScopeListeners()),this}setExtras(e){return this._extra={...this._extra,...e},this._notifyScopeListeners(),this}setExtra(e,t){return this._extra={...this._extra,[e]:t},this._notifyScopeListeners(),this}setFingerprint(e){return this._fingerprint=e,this._notifyScopeListeners(),this}setLevel(e){return this._level=e,this._notifyScopeListeners(),this}setTransactionName(e){return this._transactionName=e,this._notifyScopeListeners(),this}setContext(e,t){return null===t?delete this._contexts[e]:this._contexts[e]=t,this._notifyScopeListeners(),this}setSession(e){return e?this._session=e:delete this._session,this._notifyScopeListeners(),this}getSession(){return this._session}update(e){if(!e)return this;const t=\"function\"==typeof e?e(this):e,n=t instanceof je?t.getScopeData():ce(t)?e:void 0,{tags:i,attributes:s,extra:r,user:o,contexts:a,level:l,fingerprint:c=[],propagationContext:d,conversationId:u}=n||{};return this._tags={...this._tags,...i},this._attributes={...this._attributes,...s},this._extra={...this._extra,...r},this._contexts={...this._contexts,...a},o&&Object.keys(o).length&&(this._user=o),l&&(this._level=l),c.length&&(this._fingerprint=c),d&&(this._propagationContext=d),u&&(this._conversationId=u),this}clear(){return this._breadcrumbs=[],this._tags={},this._attributes={},this._extra={},this._user={},this._contexts={},this._level=void 0,this._transactionName=void 0,this._fingerprint=void 0,this._session=void 0,this._conversationId=void 0,ze(this,void 0),this._attachments=[],this.setPropagationContext({traceId:qe(),sampleRand:ve()}),this._notifyScopeListeners(),this}addBreadcrumb(e,t){const n=\"number\"==typeof t?t:100;if(n<=0)return this;const i={timestamp:$e(),...e,message:e.message?Ae(e.message,2048):e.message};return this._breadcrumbs.push(i),this._breadcrumbs.length>n&&(this._breadcrumbs=this._breadcrumbs.slice(-n),this._client?.recordDroppedEvent(\"buffer_overflow\",\"log_item\")),this._notifyScopeListeners(),this}getLastBreadcrumb(){return this._breadcrumbs[this._breadcrumbs.length-1]}clearBreadcrumbs(){return this._breadcrumbs=[],this._notifyScopeListeners(),this}addAttachment(e){return this._attachments.push(e),this}clearAttachments(){return this._attachments=[],this}getScopeData(){return{breadcrumbs:this._breadcrumbs,attachments:this._attachments,contexts:this._contexts,tags:this._tags,attributes:this._attributes,extra:this._extra,user:this._user,level:this._level,fingerprint:this._fingerprint||[],eventProcessors:this._eventProcessors,propagationContext:this._propagationContext,sdkProcessingMetadata:this._sdkProcessingMetadata,transactionName:this._transactionName,span:Ue(this),conversationId:this._conversationId}}setSDKProcessingMetadata(e){return this._sdkProcessingMetadata=Oe(this._sdkProcessingMetadata,e,2),this}setPropagationContext(e){return this._propagationContext=e,this}getPropagationContext(){return this._propagationContext}captureException(e,t){const n=t?.event_id||Te();if(!this._client)return O&&K.warn(\"No client configured on scope - will not capture exception!\"),n;const i=new Error(\"Sentry syntheticException\");return this._client.captureException(e,{originalException:e,syntheticException:i,...t,event_id:n},this),n}captureMessage(e,t,n){const i=n?.event_id||Te();if(!this._client)return O&&K.warn(\"No client configured on scope - will not capture message!\"),i;const s=n?.syntheticException??new Error(e);return this._client.captureMessage(e,t,{originalException:e,syntheticException:s,...n,event_id:i},this),i}captureEvent(e,t){const n=e.event_id||t?.event_id||Te();return this._client?(this._client.captureEvent(e,{...t,event_id:n},this),n):(O&&K.warn(\"No client configured on scope - will not capture event!\"),n)}_notifyScopeListeners(){this._notifyingListeners||(this._notifyingListeners=!0,this._scopeListeners.forEach(e=>{e(this)}),this._notifyingListeners=!1)}}const We=e=>e instanceof Promise&&!e[Ve],Ve=Symbol(\"chained PromiseLike\"),Ge=(e,t)=>{if(!t)return e;let n=!1;for(const i in e){if(i in t)continue;n=!0;const s=e[i];\"function\"==typeof s?Object.defineProperty(t,i,{value:(...t)=>s.apply(e,t),enumerable:!0,configurable:!0,writable:!0}):t[i]=s}return n&&Object.assign(t,{[Ve]:!0}),t};class Ke{constructor(e,t){let n,i;n=e||new je,i=t||new je,this._stack=[{scope:n}],this._isolationScope=i}withScope(e){const t=this._pushScope();let n;try{n=e(t)}catch(e){throw this._popScope(),e}return pe(n)?((e,t,n)=>{const i=e.then(e=>(t(e),e),e=>{throw n(e),e});return We(i)&&We(e)?i:Ge(e,i)})(n,()=>this._popScope(),()=>this._popScope()):(this._popScope(),n)}getClient(){return this.getStackTop().client}getScope(){return this.getStackTop().scope}getIsolationScope(){return this._isolationScope}getStackTop(){return this._stack[this._stack.length-1]}_pushScope(){const e=this.getScope().clone();return this._stack.push({client:this.getClient(),scope:e}),e}_popScope(){return!(this._stack.length<=1)&&!!this._stack.pop()}}function Ye(){const e=D(B());return e.stack=e.stack||new Ke(z(\"defaultCurrentScope\",()=>new je),z(\"defaultIsolationScope\",()=>new je))}function Xe(e){return Ye().withScope(e)}function Je(e,t){const n=Ye();return n.withScope(()=>(n.getStackTop().scope=e,t(e)))}function Qe(e){return Ye().withScope(()=>e(Ye().getIsolationScope()))}function Ze(e){const t=D(e);return t.acs?t.acs:{withIsolationScope:Qe,withScope:Xe,withSetScope:Je,withSetIsolationScope:(e,t)=>Qe(t),getCurrentScope:()=>Ye().getScope(),getIsolationScope:()=>Ye().getIsolationScope()}}function et(e,t){const{value:n,unit:i}=\"object\"==typeof(s=e)&&null!=s&&!Array.isArray(s)&&Object.keys(s).includes(\"value\")?e:{value:e,unit:void 0};var s;const r=function(e){if(Array.isArray(e))return{value:e,type:\"array\"};const t=\"string\"==typeof e?\"string\":\"boolean\"==typeof e?\"boolean\":\"number\"!=typeof e||Number.isNaN(e)?null:Number.isInteger(e)?\"integer\":\"double\";if(t)return{value:e,type:t}}(n),o=i&&\"string\"==typeof i?{unit:i}:{};if(r)return{...r,...o};if(!t||\"skip-undefined\"===t&&void 0===n)return;let a=\"\";try{a=JSON.stringify(n)??\"\"}catch{}return{value:a,type:\"string\",...o}}function tt(e,t=!1){const n={};for(const[i,s]of Object.entries(e??{})){const e=et(s,t);e&&(n[i]=e)}return n}function nt(){return Ze(B()).getCurrentScope()}function it(){return nt().getClient()}function st(e){const t=e.getPropagationContext(),{traceId:n,parentSpanId:i,propagationSpanId:s}=t,r={trace_id:n,span_id:s||He()};return i&&(r.parent_span_id=i),r}const rt=\"sentry.op\",ot=\"sentry.profile_id\",at=\"sentry.exclusive_time\";function lt(e){const t=e;return{scope:t._sentryScope,isolationScope:Be(t._sentryIsolationScope)}}const ct=\"sentry-\";function dt(e){const t=function(e){if(!e||!oe(e)&&!Array.isArray(e))return;if(Array.isArray(e))return e.reduce((e,t)=>{const n=ut(t);return Object.entries(n).forEach(([t,n])=>{e[t]=n}),e},{});return ut(e)}(e);if(!t)return;const n=Object.entries(t).reduce((e,[t,n])=>{if(t.startsWith(ct)){e[t.slice(7)]=n}return e},{});return Object.keys(n).length>0?n:void 0}function ut(e){return e.split(\",\").map(e=>{const t=e.indexOf(\"=\");if(-1===t)return[];return[e.slice(0,t),e.slice(t+1)].map(e=>{try{return decodeURIComponent(e.trim())}catch{return}})}).reduce((e,[t,n])=>(t&&n&&(e[t]=n),e),{})}const pt=/^o(\\d+)\\./,ht=/^(?:(\\w+):)\\/\\/(?:(\\w+)(?::(\\w+)?)?@)((?:\\[[:.%\\w]+\\]|[\\w.-]+))(?::(\\d+))?\\/(.+)/;function gt(e,t=!1){const{host:n,path:i,pass:s,port:r,projectId:o,protocol:a,publicKey:l}=e;return`${a}://${l}${t&&s?`:${s}`:\"\"}@${n}${r?`:${r}`:\"\"}/${i?`${i}/`:i}${o}`}function mt(e){return{protocol:e.protocol,publicKey:e.publicKey||\"\",pass:e.pass||\"\",host:e.host,port:e.port||\"\",path:e.path||\"\",projectId:e.projectId}}function ft(e){const t=e.getOptions(),{host:n}=e.getDsn()||{};let i;return t.orgId?i=String(t.orgId):n&&(i=function(e){const t=e.match(pt);return t?.[1]}(n)),i}function bt(e){const t=\"string\"==typeof e?function(e){const t=ht.exec(e);if(!t)return void j(()=>{console.error(`Invalid Sentry Dsn: ${e}`)});const[n,i,s=\"\",r=\"\",o=\"\",a=\"\"]=t.slice(1);let l=\"\",c=a;const d=c.split(\"/\");if(d.length>1&&(l=d.slice(0,-1).join(\"/\"),c=d.pop()),c){const e=c.match(/^\\d+/);e&&(c=e[0])}return mt({host:r,pass:s,path:l,projectId:c,port:o,protocol:n,publicKey:i})}(e):mt(e);if(t&&function(e){if(!O)return!0;const{port:t,projectId:n,protocol:i}=e;return!([\"protocol\",\"publicKey\",\"host\",\"projectId\"].find(t=>!e[t]&&(K.error(`Invalid Sentry Dsn: ${t} missing`),!0))||(n.match(/^\\d+$/)?function(e){return\"http\"===e||\"https\"===e}(i)?t&&isNaN(parseInt(t,10))&&(K.error(`Invalid Sentry Dsn: Invalid port ${t}`),1):(K.error(`Invalid Sentry Dsn: Invalid protocol ${i}`),1):(K.error(`Invalid Sentry Dsn: Invalid projectId ${n}`),1)))}(t))return t}let yt=!1;function vt(e){const{spanId:t,traceId:n,isRemote:i}=e.spanContext(),s=i?t:St(e).parent_span_id,r=lt(e).scope;return{parent_span_id:s,span_id:i?r?.getPropagationContext().propagationSpanId||He():t,trace_id:n}}function wt(e){return e&&e.length>0?e.map(({context:{spanId:e,traceId:t,traceFlags:n,...i},attributes:s})=>({span_id:e,trace_id:t,sampled:1===n,attributes:s,...i})):void 0}function xt(e){return\"number\"==typeof e?kt(e):Array.isArray(e)?e[0]+e[1]/1e9:e instanceof Date?kt(e.getTime()):Pe()}function kt(e){return e>9999999999?e/1e3:e}function St(e){if(function(e){return\"function\"==typeof e.getSpanJSON}(e))return e.getSpanJSON();const{spanId:t,traceId:n}=e.spanContext();if(function(e){const t=e;return!!(t.attributes&&t.startTime&&t.name&&t.endTime&&t.status)}(e)){const{attributes:i,startTime:s,name:r,endTime:o,status:a,links:l}=e;return{span_id:t,trace_id:n,data:i,description:r,parent_span_id:Ct(e),start_timestamp:xt(s),timestamp:xt(o)||void 0,status:Et(a),op:i[rt],origin:i[\"sentry.origin\"],links:wt(l)}}return{span_id:t,trace_id:n,start_timestamp:0,data:{}}}function Ct(e){return\"parentSpanId\"in e?e.parentSpanId:\"parentSpanContext\"in e?e.parentSpanContext?.spanId:void 0}function Et(e){if(e&&0!==e.code)return 1===e.code?\"ok\":e.message||\"internal_error\"}const Mt=function(e){return e._sentryRootSpan||e};function At(){yt||(j(()=>{console.warn(\"[Sentry] Returning null from `beforeSendSpan` is disallowed. To drop certain spans, configure the respective integrations directly or use `ignoreSpans`.\")}),yt=!0)}function _t(e){if(\"boolean\"==typeof __SENTRY_TRACING__&&!__SENTRY_TRACING__)return!1;const t=e||it()?.getOptions();return!(!t||null==t.tracesSampleRate&&!t.tracesSampler)}function Tt(e){K.log(`Ignoring span ${e.op} - ${e.description} because it matches \\`ignoreSpans\\`.`)}function It(e,t){if(!t?.length)return!1;for(const n of t){if($t(n)){if(e.description&&_e(e.description,n))return O&&Tt(e),!0;continue}const t=!!n.attributes&&Object.keys(n.attributes).length>0;if(!n.name&&!n.op&&!t)continue;const i=!n.name||e.description&&_e(e.description,n.name),s=!n.op||e.op&&_e(e.op,n.op),r=!n.attributes||Object.entries(n.attributes).every(([t,n])=>Lt(e.attributes?.[t],n));if(i&&s&&r)return O&&Tt(e),!0}return!1}function Lt(e,t){return\"string\"==typeof e&&(\"string\"==typeof t||t instanceof RegExp)?_e(e,t):Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,n)=>e===t[n]):e===t}function Rt(e,t){const n=t.parent_span_id,i=t.span_id;if(n)for(const t of e)t.parent_span_id===i&&(t.parent_span_id=n)}function $t(e){return\"string\"==typeof e||e instanceof RegExp}const Nt=Symbol.for(\"sentry.nonRecordingSpan\");const Pt=\"production\";function Ft(e,t){const n=t.getOptions(),{publicKey:i}=t.getDsn()||{},s={environment:n.environment||Pt,release:n.release,public_key:i,trace_id:e,org_id:ft(t)};return t.emit(\"createDsc\",s),s}function Ot(e,t){const n=t.getPropagationContext();return n.dsc||Ft(n.traceId,e)}function qt(e){const t=it();if(!t)return{};const n=Mt(e),i=St(n),s=i.data,r=n.spanContext().traceState,o=r?.get(\"sentry.sample_rate\")??s[\"sentry.sample_rate\"]??s[\"sentry.previous_trace_sample_rate\"];function a(e){return\"number\"!=typeof o&&\"string\"!=typeof o||(e.sample_rate=`${o}`),e}const l=n._frozenDsc;if(l)return a(l);if(function(e){return!!e&&!0===e[Nt]}(n)&&!_t(t.getOptions())){const e=lt(n).scope;if(e)return a({...Ot(t,e)})}const c=r?.get(\"sentry.dsc\"),d=c&&dt(c);if(d)return a(d);const u=Ft(e.spanContext().traceId,t),p=s[\"sentry.source\"]??s[\"sentry.span.source\"],h=i.description;return\"url\"!==p&&h&&(u.transaction=h),_t()&&(u.sampled=String(function(e){const{traceFlags:t}=e.spanContext();return 1===t}(n)),u.sample_rand=r?.get(\"sentry.sample_rand\")??lt(n).scope?.getPropagationContext().sampleRand.toString()),a(u),t.emit(\"createDsc\",u,n),u}function Ht(e,t=[]){return[e,t]}function Bt(e,t){const[n,i]=e;return[n,[...i,t]]}function Dt(e,t){const n=e[1];for(const e of n){if(t(e,e[0].type))return!0}return!1}function zt(e){const t=D(q);return t.encodePolyfill?t.encodePolyfill(e):(new TextEncoder).encode(e)}function Ut(e){const[t,n]=e;let i=JSON.stringify(t);function s(e){\"string\"==typeof i?i=\"string\"==typeof e?i+e:[zt(i),e]:i.push(\"string\"==typeof e?zt(e):e)}for(const e of n){const[t,n]=e;if(s(`\\n${JSON.stringify(t)}\\n`),\"string\"==typeof n||n instanceof Uint8Array)s(n);else{let e;try{e=JSON.stringify(n)}catch{e=JSON.stringify(Ce(n))}s(e)}}return\"string\"==typeof i?i:function(e){const t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t);let i=0;for(const t of e)n.set(t,i),i+=t.length;return n}(i)}function jt(e){const t=\"string\"==typeof e.data?zt(e.data):e.data;return[{type:\"attachment\",length:t.length,filename:e.filename,content_type:e.contentType,attachment_type:e.attachmentType},t]}const Wt={sessions:\"session\",event:\"error\",client_report:\"internal\",user_report:\"default\",profile_chunk:\"profile\",replay_event:\"replay\",replay_recording:\"replay\",check_in:\"monitor\",raw_security:\"security\",log:\"log_item\",trace_metric:\"metric\"};function Vt(e){return function(e){return e in Wt}(e)?Wt[e]:e}function Gt(e){if(!e?.sdk)return;const{name:t,version:n}=e.sdk;return{name:t,version:n}}function Kt(e,t,n,i){const s=Gt(n),r=e.type&&\"replay_event\"!==e.type?e.type:\"event\";!function(e,t){if(!t)return e;const n=e.sdk||{};e.sdk={...n,name:n.name||t.name,version:n.version||t.version,integrations:[...e.sdk?.integrations||[],...t.integrations||[]],packages:[...e.sdk?.packages||[],...t.packages||[]],settings:e.sdk?.settings||t.settings?{...e.sdk?.settings,...t.settings}:void 0}}(e,n?.sdk);const o=function(e,t,n,i){const s=e.sdkProcessingMetadata?.dynamicSamplingContext;return{event_id:e.event_id,sent_at:new Date(we()).toISOString(),...t&&{sdk:t},...!!n&&i&&{dsn:gt(i)},...s&&{trace:s}}}(e,s,i,t);delete e.sdkProcessingMetadata;return Ht(o,[[{type:r},e]])}function Yt(e,t){const{fingerprint:n,span:i,breadcrumbs:s,sdkProcessingMetadata:r}=t;!function(e,t){const{extra:n,tags:i,user:s,contexts:r,level:o,transactionName:a}=t;Object.keys(n).length&&(e.extra={...n,...e.extra});Object.keys(i).length&&(e.tags={...i,...e.tags});Object.keys(s).length&&(e.user={...s,...e.user});Object.keys(r).length&&(e.contexts={...r,...e.contexts});o&&(e.level=o);a&&\"transaction\"!==e.type&&(e.transaction=a)}(e,t),i&&function(e,t){e.contexts={trace:vt(t),...e.contexts},e.sdkProcessingMetadata={dynamicSamplingContext:qt(t),...e.sdkProcessingMetadata};const n=Mt(t),i=St(n).description;i&&!e.transaction&&\"transaction\"===e.type&&(e.transaction=i)}(e,i),function(e,t){e.fingerprint=e.fingerprint?Array.isArray(e.fingerprint)?e.fingerprint:[e.fingerprint]:[],t&&(e.fingerprint=e.fingerprint.concat(t));e.fingerprint.length||delete e.fingerprint}(e,n),function(e,t){const n=[...e.breadcrumbs||[],...t];e.breadcrumbs=n.length?n:void 0}(e,s),function(e,t){e.sdkProcessingMetadata={...e.sdkProcessingMetadata,...t}}(e,r)}function Xt(e,t){const{extra:n,tags:i,attributes:s,user:r,contexts:o,level:a,sdkProcessingMetadata:l,breadcrumbs:c,fingerprint:d,eventProcessors:u,attachments:p,propagationContext:h,transactionName:g,span:m}=t;Jt(e,\"extra\",n),Jt(e,\"tags\",i),Jt(e,\"attributes\",s),Jt(e,\"user\",r),Jt(e,\"contexts\",o),e.sdkProcessingMetadata=Oe(e.sdkProcessingMetadata,l,2),a&&(e.level=a),g&&(e.transactionName=g),m&&(e.span=m),c.length&&(e.breadcrumbs=[...e.breadcrumbs,...c]),d.length&&(e.fingerprint=[...e.fingerprint,...d]),u.length&&(e.eventProcessors=[...e.eventProcessors,...u]),p.length&&(e.attachments=[...e.attachments,...p]),e.propagationContext={...e.propagationContext,...h}}function Jt(e,t,n){e[t]=Oe(e[t],n,1)}function Qt(e,t){const n=z(\"globalScope\",()=>new je).getScopeData();return e&&Xt(n,e.getScopeData()),t&&Xt(n,t.getScopeData()),n}function Zt(e){return new tn(t=>{t(e)})}function en(e){return new tn((t,n)=>{n(e)})}class tn{constructor(e){this._state=0,this._handlers=[],this._runExecutor(e)}then(e,t){return new tn((n,i)=>{this._handlers.push([!1,t=>{if(e)try{n(e(t))}catch(e){i(e)}else n(t)},e=>{if(t)try{n(t(e))}catch(e){i(e)}else i(e)}]),this._executeHandlers()})}catch(e){return this.then(e=>e,e)}finally(e){return new tn((t,n)=>{let i,s;return this.then(t=>{s=!1,i=t,e&&e()},t=>{s=!0,i=t,e&&e()}).then(()=>{s?n(i):t(i)})})}_executeHandlers(){if(0===this._state)return;const e=this._handlers.slice();this._handlers=[],e.forEach(e=>{e[0]||(1===this._state&&e[1](this._value),2===this._state&&e[2](this._value),e[0]=!0)})}_runExecutor(e){const t=(e,t)=>{0===this._state&&(pe(t)?t.then(n,i):(this._state=e,this._value=t,this._executeHandlers()))},n=e=>{t(1,e)},i=e=>{t(2,e)};try{e(n,i)}catch(e){i(e)}}}function nn(e,t,n,i=0){try{const s=sn(t,n,e,i);return pe(s)?s:Zt(s)}catch(e){return en(e)}}function sn(e,t,n,i){const s=n[i];if(!e||!s)return e;const r=s({...e},t);return O&&null===r&&K.log(`Event processor \"${s.id||\"?\"}\" dropped event`),pe(r)?r.then(e=>sn(e,t,n,i+1)):sn(r,t,n,i+1)}let rn,on,an,ln;function cn(e,t,n,i,s,r){const{normalizeDepth:o=3,normalizeMaxBreadth:a=1e3}=e,l={...t,event_id:t.event_id||n.event_id||Te(),timestamp:t.timestamp||$e()},c=n.integrations||e.integrations.map(e=>e.name);!function(e,t){const{environment:n,release:i,dist:s,maxValueLength:r}=t;e.environment=e.environment||n||Pt,!e.release&&i&&(e.release=i);!e.dist&&s&&(e.dist=s);const o=e.request;o?.url&&r&&(o.url=Ae(o.url,r));r&&e.exception?.values?.forEach(e=>{e.value&&(e.value=Ae(e.value,r))})}(l,e),function(e,t){t.length>0&&(e.sdk=e.sdk||{},e.sdk.integrations=[...e.sdk.integrations||[],...t])}(l,c),s&&s.emit(\"applyFrameMetadata\",t),void 0===t.type&&function(e,t){const n=function(e){const t=q._sentryDebugIds,n=q._debugIds;if(!t&&!n)return{};const i=t?Object.keys(t):[],s=n?Object.keys(n):[];if(ln&&i.length===on&&s.length===an)return ln;on=i.length,an=s.length,ln={},rn||(rn={});const r=(t,n)=>{for(const i of t){const t=n[i],s=rn?.[i];if(s&&ln&&t)ln[s[0]]=t,rn&&(rn[i]=[s[0],t]);else if(t){const n=e(i);for(let e=n.length-1;e>=0;e--){const s=n[e],r=s?.filename;if(r&&ln&&rn){ln[r]=t,rn[i]=[r,t];break}}}}};return t&&r(i,t),n&&r(s,n),ln}(t);e.exception?.values?.forEach(e=>{e.stacktrace?.frames?.forEach(e=>{e.filename&&(e.debug_id=n[e.filename])})})}(l,e.stackParser);const d=function(e,t){if(!t)return e;const n=e?e.clone():new je;return n.update(t),n}(i,n.captureContext);n.mechanism&&Le(l,n.mechanism);const u=s?s.getEventProcessors():[],p=Qt(r,d),h=[...n.attachments||[],...p.attachments];h.length&&(n.attachments=h),Yt(l,p);const g=[...u,...p.eventProcessors];return(n.data&&!0===n.data.__sentry__?Zt(l):nn(g,l,n)).then(e=>(e&&function(e){const t={};if(e.exception?.values?.forEach(e=>{e.stacktrace?.frames?.forEach(e=>{e.debug_id&&(e.abs_path?t[e.abs_path]=e.debug_id:e.filename&&(t[e.filename]=e.debug_id),delete e.debug_id)})}),0===Object.keys(t).length)return;e.debug_meta=e.debug_meta||{},e.debug_meta.images=e.debug_meta.images||[];const n=e.debug_meta.images;Object.entries(t).forEach(([e,t])=>{n.push({type:\"sourcemap\",code_file:e,debug_id:t})})}(e),\"number\"==typeof o&&o>0?function(e,t,n){if(!e)return null;const i={...e,...e.breadcrumbs&&{breadcrumbs:e.breadcrumbs.map(e=>({...e,...e.data&&{data:Ce(e.data,t,n)}}))},...e.user&&{user:Ce(e.user,t,n)},...e.contexts&&{contexts:Ce(e.contexts,t,n)},...e.extra&&{extra:Ce(e.extra,t,n)}};e.contexts?.trace&&i.contexts&&(i.contexts.trace=e.contexts.trace,e.contexts.trace.data&&(i.contexts.trace.data=Ce(e.contexts.trace.data,t,n)));e.spans&&(i.spans=e.spans.map(e=>({...e,...e.data&&{data:Ce(e.data,t,n)}})));e.contexts?.flags&&i.contexts&&(i.contexts.flags=Ce(e.contexts.flags,3,n));return i}(e,o,a):e))}function dn(e){return\"object\"==typeof e&&\"function\"==typeof e.unref&&e.unref(),e}function un(e,t,n){return t||`${function(e){return`${function(e){const t=e.protocol?`${e.protocol}:`:\"\",n=e.port?`:${e.port}`:\"\";return`${t}//${e.host}${n}${e.path?`/${e.path}`:\"\"}/api/`}(e)}${e.projectId}/envelope/`}(e)}?${function(e,t){const n={sentry_version:\"7\"};return e.publicKey&&(n.sentry_key=e.publicKey),t&&(n.sentry_client=`${t.name}/${t.version}`),new URLSearchParams(n).toString()}(e,n)}`}const pn=[];function hn(e,t){for(const n of t)n?.afterAllSetup&&n.afterAllSetup(e)}function gn(e,t,n){if(n[t.name])O&&K.log(`Integration skipped because it was already installed: ${t.name}`);else{if(n[t.name]=t,pn.includes(t.name)||\"function\"!=typeof t.setupOnce||(t.setupOnce(),pn.push(t.name)),t.setup&&\"function\"==typeof t.setup&&t.setup(e),\"function\"==typeof t.preprocessEvent){const n=t.preprocessEvent.bind(t);e.on(\"preprocessEvent\",(t,i)=>n(t,i,e))}if(\"function\"==typeof t.processEvent){const n=t.processEvent.bind(t),i=Object.assign((t,i)=>n(t,i,e),{id:t.name});e.addEventProcessor(i)}[\"processSpan\",\"processSegmentSpan\"].forEach(n=>{const i=t[n];\"function\"==typeof i&&e.on(n,n=>i.call(t,n,e))}),O&&K.log(`Integration installed: ${t.name}`)}}function mn(){return!(\"undefined\"!=typeof __SENTRY_BROWSER_BUNDLE__&&__SENTRY_BROWSER_BUNDLE__)&&\"[object process]\"===Object.prototype.toString.call(\"undefined\"!=typeof process?process:0)}function fn(){return\"undefined\"!=typeof window&&(!mn()||function(){const e=q.process;return\"renderer\"===e?.type}())}function bn(e,t){const n=t?\"auto\":\"never\";return[{type:\"log\",item_count:e.length,content_type:\"application/vnd.sentry.items.log+json\"},{version:2,...fn()&&{ingest_settings:{infer_ip:n,infer_user_agent:n}},items:e}]}function yn(e,t){const n=t??function(e){return vn().get(e)}(e)??[];if(0===n.length)return;const i=e.getOptions(),s=function(e,t,n,i,s){const r={};return t?.sdk&&(r.sdk={name:t.sdk.name,version:t.sdk.version}),n&&i&&(r.dsn=gt(i)),Ht(r,[bn(e,s)])}(n,i._metadata,i.tunnel,e.getDsn(),e.getDataCollectionOptions().userInfo);vn().set(e,[]),e.emit(\"flushLogs\"),e.sendEnvelope(s)}function vn(){return z(\"clientToLogBufferMap\",()=>new WeakMap)}function wn(e,t){const n=t?\"auto\":\"never\";return[{type:\"trace_metric\",item_count:e.length,content_type:\"application/vnd.sentry.items.trace-metric+json\"},{version:2,...fn()&&{ingest_settings:{infer_ip:n,infer_user_agent:n}},items:e}]}function xn(e,t){const n=t??function(e){return kn().get(e)}(e)??[];if(0===n.length)return;const i=e.getOptions(),s=function(e,t,n,i,s){const r={};return t?.sdk&&(r.sdk={name:t.sdk.name,version:t.sdk.version}),n&&i&&(r.dsn=gt(i)),Ht(r,[wn(e,s)])}(n,i._metadata,i.tunnel,e.getDsn(),e.getDataCollectionOptions().userInfo);kn().set(e,[]),e.emit(\"flushMetrics\"),e.sendEnvelope(s)}function kn(){return z(\"clientToMetricBufferMap\",()=>new WeakMap)}function Sn(e){const t={trace_id:e.trace_id,span_id:e.span_id,parent_span_id:e.parent_span_id,name:e.description||\"\",start_timestamp:e.start_timestamp,end_timestamp:e.timestamp||e.start_timestamp,status:e.status&&\"ok\"!==e.status&&\"cancelled\"!==e.status?\"error\":\"ok\",is_segment:!1,attributes:{...e.data},links:e.links};return n=t,{...n,attributes:tt(n.attributes),links:n.links?.map(e=>({...e,attributes:tt(e.attributes)}))};var n}const Cn=Symbol.for(\"SentryBufferFullError\");function En(e=100){const t=new Set;function n(e){t.delete(e)}return{get $(){return Array.from(t)},add:function(i){if(!(t.size<e))return en(Cn);const s=i();return t.add(s),s.then(()=>n(s),()=>n(s)),s},drain:function(e){if(!t.size)return Zt(!0);const n=Promise.allSettled(Array.from(t)).then(()=>!0);if(!e)return n;const i=[n,new Promise(t=>dn(setTimeout(()=>t(!1),e)))];return Promise.race(i)}}}function Mn(e,{statusCode:t,headers:n},i=we()){const s={...e},r=n?.[\"x-sentry-rate-limits\"],o=n?.[\"retry-after\"];if(r)for(const e of r.trim().split(\",\")){const[t,n,,,r]=e.split(\":\",5),o=parseInt(t,10),a=1e3*(isNaN(o)?60:o);if(n)for(const e of n.split(\";\"))\"metric_bucket\"===e&&r&&!r.split(\";\").includes(\"custom\")||(s[e]=i+a);else s.all=i+a}else o?s.all=i+function(e,t=we()){const n=parseInt(`${e}`,10);if(!isNaN(n))return 1e3*n;const i=Date.parse(`${e}`);return isNaN(i)?6e4:i-t}(o,i):429===t&&(s.all=i+6e4);return s}function An(e,t,n=En(e.bufferSize||64)){let i={};return{send:function(s){const r=[];if(Dt(s,(t,n)=>{const s=Vt(n);!function(e,t,n=we()){return function(e,t){return e[t]||e.all||0}(e,t)>n}(i,s)?r.push(t):e.recordDroppedEvent(\"ratelimit_backoff\",s)}),0===r.length)return Promise.resolve({});const o=Ht(s[0],r),a=t=>{!function(e,t){return Dt(e,(e,n)=>t.includes(n))}(o,[\"client_report\"])?Dt(o,(n,i)=>{e.recordDroppedEvent(t,Vt(i))}):O&&K.warn(`Dropping client report. Will not send outcomes (reason: ${t}).`)};return n.add(()=>t({body:Ut(o)}).then(e=>413===e.statusCode?(O&&K.error(\"Sentry responded with status code 413. Envelope was discarded due to exceeding size limits.\"),a(\"send_error\"),e):(O&&void 0!==e.statusCode&&(e.statusCode<200||e.statusCode>=300)&&K.warn(`Sentry responded with status code ${e.statusCode} to sent event.`),i=Mn(i,e),e),e=>{throw a(\"network_error\"),O&&K.error(\"Encountered error running transport request:\",e),e})).then(e=>e,e=>{if(e===Cn)return O&&K.error(\"Skipped sending event because buffer is full.\"),a(\"queue_overflow\"),Promise.resolve({});throw e})},flush:e=>n.drain(e)}}const _n=[\"forwarded\",\"-ip\",\"remote-\",\"via\",\"-user\"];const Tn={userInfo:!0,cookies:!0,httpHeaders:{request:!0,response:!0},httpBodies:[\"incomingRequest\",\"outgoingRequest\",\"incomingResponse\",\"outgoingResponse\"],queryParams:!0,genAI:{inputs:!0,outputs:!0},stackFrameVariables:!0,frameContextLines:5};function In(e){const t=null!=e.dataCollection?Tn:!0===e.sendDefaultPii?{userInfo:!0,cookies:!0,httpHeaders:{request:!0,response:!0},httpBodies:[\"incomingRequest\",\"outgoingRequest\",\"incomingResponse\",\"outgoingResponse\"],queryParams:!0,genAI:{inputs:!0,outputs:!0},stackFrameVariables:!0,frameContextLines:7}:{userInfo:!1,cookies:{deny:_n},httpHeaders:{request:{deny:_n},response:{deny:_n}},httpBodies:[],queryParams:{deny:_n},genAI:{inputs:!1,outputs:!1},stackFrameVariables:!0,frameContextLines:7};const n=e.dataCollection??{};return{userInfo:n.userInfo??t.userInfo,cookies:n.cookies??t.cookies,httpHeaders:{request:n.httpHeaders?.request??t.httpHeaders.request,response:n.httpHeaders?.response??t.httpHeaders.response},httpBodies:n.httpBodies??t.httpBodies,queryParams:n.queryParams??t.queryParams,genAI:{inputs:n.genAI?.inputs??t.genAI.inputs,outputs:n.genAI?.outputs??t.genAI.outputs},stackFrameVariables:n.stackFrameVariables??t.stackFrameVariables,frameContextLines:n.frameContextLines??t.frameContextLines}}const Ln=\"Not capturing exception because it's already been captured.\",Rn=\"Discarded session because of missing or non-string release\",$n=Symbol.for(\"SentryInternalError\"),Nn=Symbol.for(\"SentryDoNotSendEventError\");function Pn(e){return{message:e,[$n]:!0}}function Fn(e){return{message:e,[Nn]:!0}}function On(e){return de(e)&&$n in e}function qn(e){return de(e)&&Nn in e}function Hn(e,t,n,i,s){let r,o=0,a=!1;e.on(n,()=>{o=0,clearTimeout(r),a=!1}),e.on(t,t=>{if(o+=i(t),o>=8e5)s(e);else if(!a){const t=e.getOptions()._flushInterval??5e3;t>0&&(a=!0,r=dn(setTimeout(()=>{s(e)},t)))}}),e.on(\"flush\",()=>{s(e)})}class Bn{constructor(e){if(this._options=e,this._integrations={},this._numProcessing=0,this._outcomes={},this._hooks={},this._eventProcessors=[],this._promiseBuffer=En(e.transportOptions?.bufferSize??64),this._dataCollection=In(e),e.dsn?this._dsn=bt(e.dsn):O&&K.warn(\"No DSN provided, client will not send events.\"),this._dsn){const t=un(this._dsn,e.tunnel,e._metadata?e._metadata.sdk:void 0);this._transport=e.transport({tunnel:this._options.tunnel,recordDroppedEvent:this.recordDroppedEvent.bind(this),...e.transportOptions,url:t})}this._options.enableLogs=this._options.enableLogs??this._options._experiments?.enableLogs,this._options.enableLogs&&Hn(this,\"afterCaptureLog\",\"flushLogs\",Wn,yn);(this._options.enableMetrics??this._options._experiments?.enableMetrics??!0)&&Hn(this,\"afterCaptureMetric\",\"flushMetrics\",jn,xn)}captureException(e,t,n){const i=Te();if(Re(e))return O&&K.log(Ln),i;const s={event_id:i,...t};return this._process(()=>this.eventFromException(e,s).then(e=>this._captureEvent(e,s,n)).then(e=>e),\"error\"),s.event_id}captureMessage(e,t,n,i){const s={event_id:Te(),...n},r=ae(e)?e:String(e),o=le(e),a=o?this.eventFromMessage(r,t,s):this.eventFromException(e,s);return this._process(()=>a.then(e=>this._captureEvent(e,s,i)),o?\"unknown\":\"error\"),s.event_id}captureEvent(e,t,n){const i=Te();if(t?.originalException&&Re(t.originalException))return O&&K.log(Ln),i;const s={event_id:i,...t},r=e.sdkProcessingMetadata||{},o=r.capturedSpanScope,a=r.capturedSpanIsolationScope,l=Dn(e.type);return this._process(()=>this._captureEvent(e,s,o||n,a),l),s.event_id}captureSession(e){this.sendSession(e),Fe(e,{init:!1})}getDsn(){return this._dsn}getOptions(){return this._options}getDataCollectionOptions(){return this._dataCollection}getSdkMetadata(){return this._options._metadata}getTransport(){return this._transport}async flush(e){const t=this._transport;if(this.emit(\"flush\"),!t)return!0;const n=await this._isClientDoneProcessing(e),i=await t.flush(e);return n&&i}async close(e){yn(this);const t=await this.flush(e);return this.getOptions().enabled=!1,this.emit(\"close\"),t}getEventProcessors(){return this._eventProcessors}addEventProcessor(e){this._eventProcessors.push(e)}init(){(this._isEnabled()||this._options.integrations.some(({name:e})=>e.startsWith(\"Spotlight\")))&&this._setupIntegrations()}getIntegrationByName(e){return this._integrations[e]}getIntegrationNames(){return Object.keys(this._integrations)}addIntegration(e){const t=this._integrations[e.name];!t&&e.beforeSetup&&e.beforeSetup(this),gn(this,e,this._integrations),t||hn(this,[e])}sendEvent(e,t={}){this.emit(\"beforeSendEvent\",e,t);const n=function(e,t){if(\"transaction\"!==e.type||!e.spans?.length||!e.sdkProcessingMetadata?.hasGenAiSpans||!1===t.getOptions().streamGenAiSpans||function(e){return\"stream\"===e.getOptions().traceLifecycle}(t))return;const n=[],i=[];for(const t of e.spans)t.op?.startsWith(\"gen_ai.\")?n.push(Sn(t)):i.push(t);if(0===n.length)return;e.spans=i;const s=t.getDataCollectionOptions().userInfo?\"auto\":\"never\";return[{type:\"span\",item_count:n.length,content_type:\"application/vnd.sentry.items.span.v2+json\"},{version:2,...fn()&&{ingest_settings:{infer_ip:s,infer_user_agent:s}},items:n}]}(e,this);let i=Kt(e,this._dsn,this._options._metadata,this._options.tunnel);for(const e of t.attachments||[])i=Bt(i,jt(e));n&&(i=Bt(i,n)),this.sendEnvelope(i).then(t=>this.emit(\"afterSendEvent\",e,t))}sendSession(e){const{release:t,environment:n=Pt}=this._options;if(\"aggregates\"in e){const i=e.attrs||{};if(!i.release&&!t)return void(O&&K.warn(Rn));i.release=i.release||t,i.environment=i.environment||n,e.attrs=i}else{if(!e.release&&!t)return void(O&&K.warn(Rn));e.release=e.release||t,e.environment=e.environment||n}this.emit(\"beforeSendSession\",e);const i=function(e,t,n,i){const s=Gt(n);return Ht({sent_at:new Date(we()).toISOString(),...s&&{sdk:s},...!!i&&t&&{dsn:gt(t)}},[\"aggregates\"in e?[{type:\"sessions\"},e]:[{type:\"session\"},e.toJSON()]])}(e,this._dsn,this._options._metadata,this._options.tunnel);this.sendEnvelope(i)}recordDroppedEvent(e,t,n=1){if(this._options.sendClientReports){const i=`${e}:${t}`;O&&K.log(`Recording outcome: \"${i}\"${n>1?` (${n} times)`:\"\"}`),this._outcomes[i]=(this._outcomes[i]||0)+n}}on(e,t){const n=this._hooks[e]=this._hooks[e]||new Set,i=(...e)=>t(...e);return n.add(i),()=>{n.delete(i)}}emit(e,...t){const n=this._hooks[e];n&&n.forEach(e=>e(...t))}async sendEnvelope(e){if(this.emit(\"beforeEnvelope\",e),this._isEnabled()&&this._transport)try{return await this._transport.send(e)}catch(e){return O&&K.error(\"Error while sending envelope:\",e),{}}return O&&K.error(\"Transport disabled\"),{}}registerCleanup(e){}dispose(){}_setupIntegrations(){const{integrations:e}=this._options;this._integrations=function(e,t){const n={};return t.forEach(t=>{t?.beforeSetup&&t.beforeSetup(e)}),t.forEach(t=>{t&&gn(e,t,n)}),n}(this,e),hn(this,e)}_updateSessionFromEvent(e,t){let n=\"fatal\"===t.level,i=!1;const s=t.exception?.values;if(s){i=!0,n=!1;for(const e of s)if(!1===e.mechanism?.handled){n=!0;break}}const r=\"ok\"===e.status;(r&&0===e.errors||r&&n)&&(Fe(e,{...n&&{status:\"crashed\"},errors:e.errors||Number(i||n)}),this.captureSession(e))}async _isClientDoneProcessing(e){let t=0;for(;!e||t<e;){if(await new Promise(e=>setTimeout(e,1)),!this._numProcessing)return!0;t++}return!1}_isEnabled(){return!1!==this.getOptions().enabled&&void 0!==this._transport}_prepareEvent(e,t,n,i){const s=this.getOptions(),r=this.getIntegrationNames();return!t.integrations&&r.length&&(t.integrations=r),this.emit(\"preprocessEvent\",e,t),e.type||i.setLastEventId(e.event_id||t.event_id),cn(s,e,t,n,this,i).then(e=>{if(null===e)return e;this.emit(\"postprocessEvent\",e,t),e.contexts={trace:{...e.contexts?.trace,...st(n)},...e.contexts};const i=Ot(this,n);return e.sdkProcessingMetadata={dynamicSamplingContext:i,...e.sdkProcessingMetadata},e})}_captureEvent(e,t={},n=nt(),i=function(){return Ze(B()).getIsolationScope()}()){return O&&zn(e)&&K.log(`Captured error event \\`${function(e){const t=[];e.message&&t.push(e.message);try{const n=e.exception.values[e.exception.values.length-1];n?.value&&(t.push(n.value),n.type&&t.push(`${n.type}: ${n.value}`))}catch{}return t}(e)[0]||\"<unknown>\"}\\``),this._processEvent(e,t,n,i).then(e=>e.event_id,e=>{O&&(qn(e)?K.log(e.message):On(e)?K.warn(e.message):K.warn(e))})}_processEvent(e,t,n,i){const s=this.getOptions(),{sampleRate:r}=s,o=Un(e),a=zn(e),l=`before send for type \\`${e.type||\"error\"}\\``,c=void 0===r?void 0:function(e){if(\"boolean\"==typeof e)return Number(e);const t=\"string\"==typeof e?parseFloat(e):e;return\"number\"!=typeof t||isNaN(t)||t<0||t>1?void 0:t}(r);if(a&&\"number\"==typeof c&&ve()>c)return this.recordDroppedEvent(\"sample_rate\",\"error\"),en(Fn(`Discarding event because it's not included in the random sample (sampling rate = ${r})`));const d=Dn(e.type);return this._prepareEvent(e,t,n,i).then(e=>{if(null===e)throw this.recordDroppedEvent(\"event_processor\",d),Fn(\"An event processor returned `null`, will not send event.\");if(!0===t.data?.__sentry__)return e;const n=function(e,t,n,i){const{beforeSend:s,beforeSendTransaction:r,ignoreSpans:o}=t,a=(l=t.beforeSendSpan,!(l&&\"function\"==typeof l&&\"_streamed\"in l&&l._streamed)&&t.beforeSendSpan);var l;let c=n;if(zn(c)&&s)return s(c,i);if(Un(c)){if(a||o){const t=function(e){const{trace_id:t,parent_span_id:n,span_id:i,status:s,origin:r,data:o,op:a}=e.contexts?.trace??{};return{data:o??{},description:e.transaction,op:a,parent_span_id:n,span_id:i??\"\",start_timestamp:e.start_timestamp??0,status:s,timestamp:e.timestamp,trace_id:t??\"\",origin:r,profile_id:o?.[ot],exclusive_time:o?.[at],measurements:e.measurements,is_segment:!0}}(c);if(o?.length&&It({description:t.description,op:t.op,attributes:t.data},o))return null;if(a){const e=a(t);e?c=Oe(n,{type:\"transaction\",timestamp:(d=e).timestamp,start_timestamp:d.start_timestamp,transaction:d.description,contexts:{trace:{trace_id:d.trace_id,span_id:d.span_id,parent_span_id:d.parent_span_id,op:d.op,status:d.status,origin:d.origin,data:{...d.data,...d.profile_id&&{[ot]:d.profile_id},...d.exclusive_time&&{[at]:d.exclusive_time}}}},measurements:d.measurements}):At()}if(c.spans){const t=[],n=c.spans;for(const e of n)if(o?.length&&It({description:e.description,op:e.op,attributes:e.data},o))Rt(n,e);else if(a){const n=a(e);n?t.push(n):(At(),t.push(e))}else t.push(e);const i=c.spans.length-t.length;i&&e.recordDroppedEvent(\"before_send\",\"span\",i),c.spans=t}}if(r){if(c.spans){const e=c.spans.length;c.sdkProcessingMetadata={...n.sdkProcessingMetadata,spanCountBeforeProcessing:e}}return r(c,i)}}var d;return c}(this,s,e,t);return function(e,t){const n=`${t} must return \\`null\\` or a valid event.`;if(pe(e))return e.then(e=>{if(!ce(e)&&null!==e)throw Pn(n);return e},e=>{throw Pn(`${t} rejected with ${e}`)});if(!ce(e)&&null!==e)throw Pn(n);return e}(n,l)}).then(s=>{if(null===s){if(this.recordDroppedEvent(\"before_send\",d),o){const t=1+(e.spans||[]).length;this.recordDroppedEvent(\"before_send\",\"span\",t)}throw Fn(`${l} returned \\`null\\`, will not send event.`)}const r=n.getSession()||i.getSession();if(a&&r&&this._updateSessionFromEvent(r,s),o){const e=(s.sdkProcessingMetadata?.spanCountBeforeProcessing||0)-(s.spans?s.spans.length:0);e>0&&this.recordDroppedEvent(\"before_send\",\"span\",e)}const c=s.transaction_info;if(o&&c&&s.transaction!==e.transaction){const e=\"custom\";s.transaction_info={...c,source:e}}return this.sendEvent(s,t),s}).then(null,e=>{if(qn(e)||On(e))throw e;throw this.captureException(e,{mechanism:{handled:!1,type:\"internal\"},data:{__sentry__:!0},originalException:e}),Pn(`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\\nReason: ${e}`)})}_process(e,t){this._numProcessing++,this._promiseBuffer.add(e).then(e=>(this._numProcessing--,e),e=>(this._numProcessing--,e===Cn&&this.recordDroppedEvent(\"queue_overflow\",t),e))}_clearOutcomes(){const e=this._outcomes;return this._outcomes={},Object.entries(e).map(([e,t])=>{const[n,i]=e.split(\":\");return{reason:n,category:i,quantity:t}})}_flushOutcomes(){O&&K.log(\"Flushing outcomes...\");const e=this._clearOutcomes();if(0===e.length)return void(O&&K.log(\"No outcomes to send\"));if(!this._dsn)return void(O&&K.log(\"No dsn provided, will not send outcomes\"));O&&K.log(\"Sending outcomes:\",e);const t=(n=e,Ht((i=this._options.tunnel&&gt(this._dsn))?{dsn:i}:{},[[{type:\"client_report\"},{timestamp:$e(),discarded_events:n}]]));var n,i;this.sendEnvelope(t)}}function Dn(e){return\"replay_event\"===e?\"replay\":e||\"error\"}function zn(e){return void 0===e.type}function Un(e){return\"transaction\"===e.type}function jn(e){let t=0;return e.name&&(t+=2*e.name.length),t+=8,t+Vn(e.attributes)}function Wn(e){let t=0;return e.message&&(t+=2*e.message.length),t+Vn(e.attributes)}function Vn(e){if(!e)return 0;let t=0;return Object.values(e).forEach(e=>{Array.isArray(e)?t+=e.length*Gn(e[0]):le(e)?t+=Gn(e):t+=100}),t}function Gn(e){return\"string\"==typeof e?2*e.length:\"number\"==typeof e?8:\"boolean\"==typeof e?4:0}function Kn(e){\"aggregates\"in e?void 0===e.attrs?.ip_address&&(e.attrs={...e.attrs,ip_address:\"{{auto}}\"}):void 0===e.ipAddress&&(e.ipAddress=\"{{auto}}\")}function Yn(e,t,n,i,s,r){if(!s.exception?.values||!r||!he(r.originalException,Error))return;const o=s.exception.values.length>0?s.exception.values[s.exception.values.length-1]:void 0;o&&(s.exception.values=Xn(e,t,i,r.originalException,n,s.exception.values,o,0))}function Xn(e,t,n,i,s,r,o,a){if(r.length>=n+1)return r;let l=[...r];if(he(i[s],Error)){Qn(o,a,i);const r=e(t,i[s]),c=l.length;Zn(r,s,c,a),l=Xn(e,t,n,i[s],s,[r,...l],r,c)}return Jn(i)&&i.errors.forEach((r,c)=>{if(he(r,Error)){Qn(o,a,i);const d=e(t,r),u=l.length;Zn(d,`errors[${c}]`,u,a),l=Xn(e,t,n,r,s,[d,...l],d,u)}}),l}function Jn(e){return Array.isArray(e.errors)}function Qn(e,t,n){e.mechanism={handled:!0,type:\"auto.core.linked_errors\",...Jn(n)&&{is_exception_group:!0},...e.mechanism,exception_id:t}}function Zn(e,t,n,i){e.mechanism={handled:!0,...e.mechanism,type:\"chained\",source:t,exception_id:n,parent_id:i}}function ei(e){return function(e){return ne(e)&&\"__sentry_fetch_url_host__\"in e&&\"string\"==typeof e.__sentry_fetch_url_host__}(e)?`${e.message} (${e.__sentry_fetch_url_host__})`:e.message}const ti=()=>{let e;return{name:\"Dedupe\",processEvent(t){if(t.type)return t;try{if(function(e,t){if(!t)return!1;if(function(e,t){const n=e.message,i=t.message;if(!n&&!i)return!1;if(n&&!i||!n&&i)return!1;if(n!==i)return!1;if(!ii(e,t))return!1;if(!ni(e,t))return!1;return!0}(e,t))return!0;if(function(e,t){const n=si(t),i=si(e);if(!n||!i)return!1;if(n.type!==i.type||n.value!==i.value)return!1;if(!ii(e,t))return!1;if(!ni(e,t))return!1;return!0}(e,t))return!0;return!1}(t,e))return O&&K.warn(\"Event dropped due to being a duplicate of previously captured event.\"),null}catch{}return e=t}}};function ni(e,t){let n=ee(e),i=ee(t);if(!n&&!i)return!0;if(n&&!i||!n&&i)return!1;if(i.length!==n.length)return!1;for(let e=0;e<i.length;e++){const t=i[e],s=n[e];if(t.filename!==s.filename||t.lineno!==s.lineno||t.colno!==s.colno||t.function!==s.function)return!1}return!0}function ii(e,t){let n=e.fingerprint,i=t.fingerprint;if(!n&&!i)return!0;if(n&&!i||!n&&i)return!1;try{return!(n.join(\"\")!==i.join(\"\"))}catch{return!1}}function si(e){return e.exception?.values?.[0]}const ri=q;const oi=q;function ai(){const e=function(){try{return ri.document.location.href}catch{return\"\"}}(),{referrer:t}=oi.document||{},{userAgent:n}=oi.navigator||{};return{url:e,headers:{...t&&{Referer:t},...n&&{\"User-Agent\":n}}}}function li(e,t){const n=ui(e,t),i={type:gi(t),value:mi(t)};return n.length&&(i.stacktrace={frames:n}),void 0===i.type&&\"\"===i.value&&(i.value=\"Unrecoverable error caught\"),i}function ci(e,t,n,i){const s=it(),r=s?.getOptions().normalizeDepth,o=(a=t,Object.values(a).find(e=>e instanceof Error));var a;const l={__serialized__:Ee(t,r)};if(o)return{exception:{values:[li(e,o)]},extra:l};const c={exception:{values:[{type:ue(t)?t.constructor.name:i?\"UnhandledRejection\":\"Error\",value:yi(t,{isUnhandledRejection:i})}]},extra:l};if(n){const t=ui(e,n);t.length&&(c.exception.values[0].stacktrace={frames:t})}return c}function di(e,t){return{exception:{values:[li(e,t)]}}}function ui(e,t){const n=t.stacktrace||t.stack||\"\",i=function(e){if(e&&pi.test(e.message))return 1;return 0}(t),s=function(e){if(\"number\"==typeof e.framesToPop)return e.framesToPop;return 0}(t);try{return e(n,i,s)}catch{}return[]}const pi=/Minified React error #\\d+;/i;function hi(e){return\"undefined\"!=typeof WebAssembly&&void 0!==WebAssembly.Exception&&e instanceof WebAssembly.Exception}function gi(e){const t=e?.name;if(!t&&hi(e)){return e.message&&Array.isArray(e.message)&&2==e.message.length?e.message[0]:\"WebAssembly.Exception\"}return t}function mi(e){const t=e?.message;return hi(e)?Array.isArray(e.message)&&2==e.message.length?e.message[1]:\"wasm exception\":t?t.error&&\"string\"==typeof t.error.message?ei(t.error):ei(e):\"No error message\"}function fi(e,t,n,i){const s=function(e,t,n,i,s){let r;if(se(t)&&t.error){return di(e,t.error)}if(re(t)||(o=t,ie(o,\"DOMException\"))){const s=t;if(\"stack\"in t){r=di(e,t);const s=r.exception?.values?.[0];if(i&&n&&s&&!s.stacktrace){const t=ui(e,n);t.length&&(s.stacktrace={frames:t},Le(r,{synthetic:!0}))}}else{const t=s.name||(re(s)?\"DOMError\":\"DOMException\"),o=s.message?`${t}: ${s.message}`:t;r=bi(e,o,n,i),Ie(r,o)}return\"code\"in s&&(r.tags={...r.tags,\"DOMException.code\":`${s.code}`}),r}var o;if(ne(t))return di(e,t);if(ce(t)||ue(t)){return r=ci(e,t,n,s),Le(r,{synthetic:!0}),r}return r=bi(e,t,n,i),Ie(r,`${t}`),Le(r,{synthetic:!0}),r}(e,t,n?.syntheticException||void 0,i);return Le(s),s.level=\"error\",n?.event_id&&(s.event_id=n.event_id),Zt(s)}function bi(e,t,n,i){const s={};if(i&&n){const i=ui(e,n);i.length&&(s.exception={values:[{value:t,stacktrace:{frames:i}}]}),Le(s,{synthetic:!0})}if(ae(t)){const{__sentry_template_string__:e,__sentry_template_values__:n}=t;return s.logentry={message:e,params:n},s}return s.message=t,s}function yi(e,{isUnhandledRejection:t}){const n=function(e){const t=Object.keys(me(e));return t.sort(),t[0]?t.join(\", \"):\"[object has no keys]\"}(e),i=\"exception\";if(se(e))return`Event \\`ErrorEvent\\` captured as ${i} with message \\`${e.message}\\``;if(ue(e)){return`Event \\`${function(e){try{const t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{}}(e)}\\` (type=${e.type}) captured as ${i}`}return`Object captured as ${i} with keys: ${n}`}class vi extends Bn{constructor(e){const t=(n=e,{release:\"string\"==typeof __SENTRY_RELEASE__?__SENTRY_RELEASE__:oi.SENTRY_RELEASE?.id,sendClientReports:!0,parentSpanIsAlwaysRootSpan:!0,...n});var n;!function(e,t,n=[t],i=\"npm\"){const s=(e._metadata=e._metadata||{}).sdk=e._metadata.sdk||{};s.name||(s.name=`sentry.javascript.${t}`,s.packages=n.map(e=>({name:`${i}:@sentry/${e}`,version:H})),s.version=H)}(t,\"browser\",[\"browser\"],oi.SENTRY_SDK_SOURCE||\"npm\"),super(t);const{userInfo:i}=this.getDataCollectionOptions();t._metadata?.sdk&&(t._metadata.sdk.settings={infer_ip:i?\"auto\":\"never\",...t._metadata.sdk.settings});const{sendClientReports:s}=this._options;oi.document&&oi.document.addEventListener(\"visibilitychange\",()=>{\"hidden\"===oi.document.visibilityState&&(s&&this._flushOutcomes(),queueMicrotask(()=>{this.flush()}))}),i&&this.on(\"beforeSendSession\",Kn)}eventFromException(e,t){return fi(this._options.stackParser,e,t,this._options.attachStacktrace)}eventFromMessage(e,t=\"info\",n){return function(e,t,n=\"info\",i,s){const r=bi(e,t,i?.syntheticException||void 0,s);return r.level=n,i?.event_id&&(r.event_id=i.event_id),Zt(r)}(this._options.stackParser,e,t,n,this._options.attachStacktrace)}_prepareEvent(e,t,n,i){return e.platform=e.platform||\"javascript\",super._prepareEvent(e,t,n,i)}}const wi=\"undefined\"==typeof __SENTRY_DEBUG__||__SENTRY_DEBUG__,xi=q,ki={};function Si(e,t=function(e){const t=ki[e];if(t)return t;let n=xi[e];if((i=n)&&/^function\\s+\\w+\\(\\)\\s+\\{\\s+\\[native code\\]\\s+\\}$/.test(i.toString()))return ki[e]=n.bind(xi);var i;const s=xi.document;if(s&&\"function\"==typeof s.createElement)try{const t=s.createElement(\"iframe\");t.hidden=!0,s.head.appendChild(t);const i=t.contentWindow;i?.[e]&&(n=i[e]),s.head.removeChild(t)}catch(t){wi&&K.warn(`Could not create sandbox iframe for ${e} check, bailing to window.${e}: `,t)}return n?ki[e]=n.bind(xi):n}(\"fetch\")){let n=0,i=0;return An(e,async function(s){const r=s.body.length;n+=r,i++;const o={body:s.body,method:\"POST\",referrerPolicy:\"strict-origin\",headers:e.headers,keepalive:n<=6e4&&i<15,...e.fetchOptions};try{const n=await t(e.url,o);return{statusCode:n.status,headers:{\"x-sentry-rate-limits\":n.headers.get(\"X-Sentry-Rate-Limits\"),\"retry-after\":n.headers.get(\"Retry-After\")}}}catch(e){throw ki[\"fetch\"]=void 0,e}finally{n-=r,i--}},En(e.bufferSize||40))}function Ci(e,t,n,i){const s={filename:e,function:\"<anonymous>\"===t?Y:t,in_app:!0};return void 0!==n&&(s.lineno=n),void 0!==i&&(s.colno=i),s}const Ei=/^\\s*at (\\S+?)(?::(\\d+))(?::(\\d+))\\s*$/i,Mi=/^\\s*at (?:(.+?\\)(?: \\[.+\\])?|.*?) ?\\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\\/)?.*?)(?::(\\d+))?(?::(\\d+))?\\)?\\s*$/i,Ai=/\\((\\S*)(?::(\\d+))(?::(\\d+))\\)/,_i=/at (.+?) ?\\(data:(.+?),/,Ti=/^\\s*(.*?)(?:\\((.*?)\\))?(?:^|@)?((?:[-a-z]+)?:\\/.*?|\\[native code\\]|[^@]*(?:bundle|\\d+\\.js)|\\/[\\w\\-. /=]+)(?::(\\d+))?(?::(\\d+))?\\s*$/i,Ii=/(\\S+) line (\\d+)(?: > eval line \\d+)* > eval/i,Li=function(...e){const t=e.sort((e,t)=>e[0]-t[0]).map(e=>e[1]);return(e,n=0,i=0)=>{const s=[],r=e.split(\"\\n\");for(let e=n;e<r.length;e++){let n=r[e];n.length>1024&&(n=n.slice(0,1024));const o=X.test(n)?n.replace(X,\"$1\"):n;if(!o.includes(\"Error: \")){for(const e of t){const t=e(o);if(t){s.push(t);break}}if(s.length>=50+i)break}}return function(e){if(!e.length)return[];const t=Array.from(e);/sentryWrapped/.test(Q(t).function||\"\")&&t.pop();t.reverse(),J.test(Q(t).function||\"\")&&(t.pop(),J.test(Q(t).function||\"\")&&t.pop());return t.slice(0,50).map(e=>({...e,filename:e.filename||Q(t).filename,function:e.function||Y}))}(s.slice(i))}}(...[[30,e=>{const t=e.match(_i);if(t)return{filename:`<data:${t[2]}>`,function:t[1]};const n=Ei.exec(e);if(n){const[,e,t,i]=n;return Ci(e,Y,+t,+i)}const i=Mi.exec(e);if(i){if(0===i[2]?.indexOf(\"eval\")){const e=Ai.exec(i[2]);e&&(i[2]=e[1],i[3]=e[2],i[4]=e[3])}const[e,t]=Ri(i[1]||Y,i[2]);return Ci(t,e,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}}],[50,e=>{const t=Ti.exec(e);if(t){if(t[3]&&t[3].indexOf(\" > eval\")>-1){const e=Ii.exec(t[3]);e&&(t[1]=t[1]||\"eval\",t[3]=e[1],t[4]=e[2],t[5]=\"\")}let e=t[3],n=t[1]||Y;return[n,e]=Ri(n,e),Ci(e,n,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}}]]),Ri=(e,t)=>{const n=-1!==e.indexOf(\"safari-extension\"),i=-1!==e.indexOf(\"safari-web-extension\");return n||i?[-1!==e.indexOf(\"@\")?e.split(\"@\")[0]:Y,n?`safari-extension:${t}`:`safari-web-extension:${t}`]:[e,t]},$i=()=>({name:\"HttpContext\",preprocessEvent(e){if(!oi.navigator&&!oi.location&&!oi.document)return;const t=ai(),n={...t.headers,...e.request?.headers};e.request={...t,...e.request,headers:n}},processSegmentSpan(e){const t=e.attributes?.[rt];if(!oi.navigator&&!oi.location&&!oi.document)return;const n=ai();!function(e,t){const n=e.attributes??(e.attributes={});Object.entries(t).forEach(([e,t])=>{null==t||e in n||(n[e]=t)})}(e,{\"url.full\":\"http.client\"!==t?n.url:void 0,\"http.request.header.user_agent\":n.headers[\"User-Agent\"],\"http.request.header.referer\":n.headers.Referer})}}),Ni=(e={})=>{const t=e.limit||5,n=e.key||\"cause\";return{name:\"LinkedErrors\",preprocessEvent(e,i,s){Yn(li,s.getOptions().stackParser,n,t,e,i)}}};class Pi extends Error{constructor(e,t,n,i,s){super(e),this.name=\"ApiRequestError\",this.endpoint=t,this.status=n,this.kind=i,this.code=s}static http(e,t,n,i){return new Pi(`API request failed: ${e} → ${t} ${n}${i?` (${i})`:\"\"}`,e,t,\"http\",i)}static transport(e,t){return new Pi(`API request failed: ${e} → ${t}`,e,0,t)}}function Fi(e){return e instanceof Pi&&(\"http\"===e.kind&&(401===e.status||403===e.status))}const Oi=new Set([\"Failed to fetch\",\"NetworkError when attempting to fetch resource.\",\"Load failed\"]);const qi=\"[SupportWidget]\";let Hi={},Bi=null,Di=null,zi=!1,Ui=0,ji=null,Wi=!1;const Vi=/[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}/g,Gi=/\\bBearer\\s+[A-Za-z0-9._-]+/gi;function Ki(e){return e.replace(Vi,\"[redacted-email]\").replace(Gi,\"Bearer [redacted]\")}function Yi(){if(function(){const e=Hi.publishableKey;return void 0!==e&&!e.startsWith(\"pk_\")}())return null;if(ji||Wi)return ji;try{const e=new vi({dsn:\"https://a8feb37b0161b10ad73d64ff7c9911e0@o4507510402383872.ingest.us.sentry.io/4511661901414400\",transport:Si,stackParser:Li,integrations:[ti(),$i(),Ni()],sendDefaultPii:!1,attachStacktrace:!0,environment:\"production-react-native\",release:\"1.0.0+333a1e0\",beforeSend:e=>{e.message&&(e.message=Ki(e.message));const t=e.exception?.values;if(t)for(const e of t)e.value&&(e.value=Ki(e.value));const n=e.request;if(n&&(n.url&&(n.url=Ki(n.url)),n.headers))for(const e of Object.keys(n.headers))n.headers[e]=Ki(n.headers[e]);return e}}),t=new je;return t.setClient(e),e.init(),ji=t,t}catch{return Wi=!0,null}}function Xi(e,t){if(Ui>=50)return;const n=Yi();if(!n)return;Ui++;const i=t instanceof Error?t:new Error(void 0===t?e:`${e}: ${function(e){if(e instanceof Error)return`${e.name}: ${e.message}`;if(\"string\"==typeof e)return e;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}(t)}`);if(t instanceof Pi?n.setFingerprint([\"api-request-error\",t.endpoint,String(t.status),t.code??\"\"]):n.setFingerprint(t instanceof Error?[\"{{ default }}\"]:[Ki(i.message)]),n.setTags({context:Ki(e),widgetVersion:Hi.widgetVersion??\"1.0.0\",publishableKey:Hi.publishableKey??\"unknown\"}),Di)try{const e=Di();n.setTags({sourceId:e.sourceId??\"unknown\",sessionId:null!==e.sessionId?String(e.sessionId):\"none\",conversationId:null!==e.conversationId?String(e.conversationId):\"none\",companyExternalId:e.companyExternalId??\"none\"}),n.setUser(e.userExternalId?{id:e.userExternalId}:null)}catch{}if(Bi)try{n.setContext(\"widget_state\",Bi())}catch{}n.captureException(i)}function Ji(e,t){if(!zi){zi=!0;try{void 0===t?console.error(`${qi} ${e}`):console.error(`${qi} ${e}`,t);try{!function(e){return e instanceof Pi&&(\"http\"!==e.kind||401===e.status||403===e.status)}(t)?!function(e){return\"AbortError\"===e?.name||e instanceof TypeError&&Oi.has(e.message)}(t)?Xi(e,t):Qi(\"network\",`${e}: ${t.message}`):Qi(\"api\",`${e}: ${t.message}`)}catch{}}catch{}finally{zi=!1}}}function Qi(e,t){try{Yi()?.addBreadcrumb({category:e,message:Ki(t),level:\"info\"})}catch{}}function Zi(e,t){try{if(Qi(e,JSON.stringify(t)),Ui>=50)return;const n=Yi();if(!n)return;Ui++;const i=n.clone();i.setFingerprint([e]),i.setTags({...t,widgetVersion:Hi.widgetVersion??\"1.0.0\",publishableKey:Hi.publishableKey??\"unknown\"}),i.captureMessage(e,\"info\")}catch{}}function es(e,t){return(...n)=>{try{t(...n)}catch(t){Ji(e,t)}}}const ts=new Set([\"constructor\",\"destroy\"]),ns={getMessages:[],getColor:\"\",getSecondaryColor:\"\",getLanguage:\"en\",getUnreadAnimation:\"none\",getDisplayMode:\"floating\",getUser:null,getSessionUuid:null,getTicketId:null,getSessionId:null,getAgentManager:null,getUIManager:null,isMinimized:!1,isBrandingVisible:!1,isWebSocketConnected:!1,isSoundEnabled:!1,shouldBlockInputWhileAIThinking:!1};function is(e){if(!(e in ns))return;const t=ns[e];return Array.isArray(t)?[...t]:t}function ss(e){const t=e?.url;return\"string\"==typeof t?t:String(e)}function rs(e,t){try{e?.()}catch(e){Ji(t,e)}}function os(e){e?.parentNode?.removeChild(e)}function as(e){const t=e.trim().split(/\\s+/).filter(Boolean);if(0===t.length)return\"?\";if(1===t.length){const e=t[0];return e.length>1?e[0].toUpperCase()+e[1].toLowerCase():e.toUpperCase()}return(t[0][0]+t[t.length-1][0]).toUpperCase()}function ls(e){if(!e)return\"\";const t=new Date(e);if(Number.isNaN(t.getTime()))return\"\";const n=s()-t.getTime(),i=Math.floor(n/6e4),r=Math.floor(i/60),o=Math.floor(r/24);return i<1?\"now\":i<60?`${i}m`:r<24?`${r}h`:o<30?`${o}d`:t.toLocaleDateString()}function cs(){return\"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g,function(e){const t=16*Math.random()|0;return(\"x\"===e?t:3&t|8).toString(16)})}class ds{static setSkipCookie(e){ds.skipCookie=e}static set(e,t,n={}){if(ds.skipCookie)return;const i=n.days??365,s=new Date;s.setTime(s.getTime()+24*i*60*60*1e3);let r=`${e}=${t}; ${`expires=${s.toUTCString()}`}; Path=/`;n.sameSite&&(r+=`; SameSite=${n.sameSite}`),n.secure&&(r+=\"; Secure\"),document.cookie=r}static get(e){if(ds.skipCookie)return null;const t=`${e}=`,n=document.cookie.split(\";\");for(let e=0;e<n.length;e++){let i=n[e];for(;\" \"===i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t))return i.substring(t.length,i.length)}return null}static delete(e){ds.skipCookie||(document.cookie=`${e}=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/`)}}function us(e){return new URLSearchParams(window.location.search).get(e)}ds.skipCookie=!1;const ps=\"1.0.0+333a1e0\",hs=document.currentScript;function gs(e){const t=hs;if(!t?.src||ps.endsWith(\"+unknown\"))return()=>{};const n=new URL(t.src,location.href),i=new URL(\"version.js\",n);let r=-1/0,o=null,a=null,l=0,c=!1,d=!1;const u=()=>{d=!0,clearInterval(m),document.removeEventListener(\"visibilitychange\",g)},p=e=>{Qi(\"self-update\",e),o=null,a=null},h=async()=>{if(!(c||d||document.hidden)){c=!0;try{if(null===o&&s()-r>=3e5){r=s();const e=await async function(e,t){const n=new URL(e.href);n.searchParams.set(\"t\",String(Math.round(s()))),delete window.__blarWidgetDeployedRelease;try{os(await ms(n.href,[],t))}catch{return null}const i=window.__blarWidgetDeployedRelease;return\"string\"==typeof i?i:null}(i,t.nonce);e&&e!==ps&&(o=e)}if(null===o)return;if(!e.getSelfUpdateHandoff())return;try{a??(a=await async function(e,t,n){const i=window.SupportWidget,s=new URL(t.href);s.searchParams.set(\"v\",n);const r=Array.from(e.attributes).filter(({name:e})=>e.startsWith(\"data-\"));if(await ms(s.href,r,e.nonce),window.SupportWidget===i)throw new Error(`bundle ${n} loaded but did not register`);return window.SupportWidget}(t,n,o))}catch(e){if(p(`bundle ${o} did not load: ${String(e)}`),++l>=3)throw e;return}if(a.release!==o)return void p(`asked for ${o}, the bucket served ${a.release}`);if(d)return;(function(e,t,n){const i=e.getSelfUpdateHandoff();if(!i)return!1;let s;e.destroy();try{s=new t(i.config)}catch(t){Ji(`self-update: ${n} failed to start`,t),s=new(Object.getPrototypeOf(e).constructor)(i.config)}window.supportWidgetInstance===e&&(window.supportWidgetInstance=s);return s.applySelfUpdateHandoff(i),function(e,t){const n=t,i=e;for(const e of Object.getOwnPropertyNames(Object.getPrototypeOf(t))){if(\"constructor\"===e)continue;const s=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(t),e);\"function\"==typeof s?.value&&(i[e]=(...t)=>n[e](...t))}}(e,s),Qi(\"self-update\",`${ps} → ${n}`),!0})(e,a,o)&&u()}catch(e){Ji(\"self-update: could not move to the deployed widget\",e),u()}finally{c=!1}}},g=()=>{h()},m=setInterval(g,18e5);return document.addEventListener(\"visibilitychange\",g),u}function ms(e,t,n){return new Promise((i,s)=>{const r=document.createElement(\"script\");for(const{name:e,value:n}of t)r.setAttribute(e,n);n&&(r.nonce=n),r.src=e,r.async=!0,r.onload=()=>i(r),r.onerror=()=>{os(r),s(new Error(`could not load ${e}`))},document.head.appendChild(r)})}class fs{constructor(){this.disposers=[],this.disposed=!1}get isDisposed(){return this.disposed}add(e){this.disposed?this.runDisposer(e):this.disposers.push(e)}safeTimeout(e,t,n){const i=setTimeout(es(e,t),n);return this.add(()=>clearTimeout(i)),i}safeInterval(e,t,n){const i=setInterval(es(e,t),n);return this.add(()=>clearInterval(i)),i}safeOn(e,t,n,i,s){const r=es(i,n);e.addEventListener(t,r,s),this.add(()=>e.removeEventListener(t,r,s))}dispose(){if(!this.disposed){this.disposed=!0;for(let e=this.disposers.length-1;e>=0;e--)this.runDisposer(this.disposers[e]);this.disposers=[]}}runDisposer(e){try{e()}catch(e){Ji(\"DisposableStore.dispose\",e)}}}const bs=new class{constructor(){this.primaryColor=\"#4593F8\",this.secondaryColor=\"#FFFFFF\",this.listeners=new Set}getPrimaryColor(){return this.primaryColor}getSecondaryColor(){return this.secondaryColor}setColors(e,t){this.primaryColor=e,this.secondaryColor=t,this.notifyListeners()}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notifyListeners(){this.listeners.forEach(e=>e(this.primaryColor,this.secondaryColor))}};function ys(e){return{header:\"X-Identity-Token\",value:e,protocol:`blar-identity-token.${e}`}}function vs(e){return{header:\"X-Identity-Signature\",value:e,protocol:`blar-identity-signature.${e}`}}function ws(e){try{const t=e.split(\".\")[1];if(!t)return null;const n=t.replace(/-/g,\"+\").replace(/_/g,\"/\"),i=JSON.parse(atob(n.padEnd(4*Math.ceil(n.length/4),\"=\")));return\"number\"==typeof i.exp?1e3*i.exp:null}catch{return null}}class xs{constructor(){this.identity=null,this.cached=null,this.expiresAt=null,this.inFlight=null,this.mintFailure=null}setIdentity(e){this.identity=e,this.cached=null,this.expiresAt=null,this.inFlight=null,this.mintFailure=null}hasIdentity(){return null!==this.identity}getIdentity(){return this.identity}refusalReason(){return this.mintFailure?this.mintFailure:!this.cached&&this.canRefresh()?\"provider_failed\":!this.canRefresh()&&null!==this.expiresAt&&this.expiresAt<=s()?\"static_token_expired\":\"identify_refused\"}canRefresh(){return Boolean(this.identity?.getProof||this.identity?.getIdentityToken||this.identity?.getIdentitySignature)}clear(){this.setIdentity(null)}get(e){if(!this.identity)return Promise.resolve(null);const t=null!==this.expiresAt&&this.expiresAt-s()<=6e4;return!this.cached||e?.refresh||t?this.cached&&!this.canRefresh()?Promise.resolve(this.cached):(this.inFlight||(this.inFlight=this.mint().finally(()=>{this.inFlight=null})),this.inFlight):Promise.resolve(this.cached)}async mint(){const e=this.identity;if(!e)return null;this.mintFailure=null;try{if(e.getProof){const t=await e.getProof();return this.assertSameSubject(t?.externalId),t?.identityToken?(this.cached=ys(t.identityToken),this.expiresAt=ws(t.identityToken),this.cached):(this.cached=t?.identitySignature?vs(t.identitySignature):null,this.expiresAt=null,this.cached)}const t=e.getIdentityToken?await e.getIdentityToken():e.identityToken;if(t)return this.cached=ys(t),this.expiresAt=ws(t),this.cached;const n=e.getIdentitySignature?await e.getIdentitySignature():e.identitySignature;return this.cached=n?vs(n):null,this.expiresAt=null,this.cached}catch(e){return Qi(\"identity\",`proof provider failed: ${e?.message??\"unknown\"}`),this.mintFailure=\"provider_failed\",this.cached}}assertSameSubject(e){const t=this.identity?.externalId;e&&t&&e!==t&&(this.mintFailure=\"subject_mismatch\",Ji(`[Identity] getProof() signed \"${e}\" but the widget was given \"${t}\" — the backend will reject this`))}}const ks=\"/api/tickets/contacts/identify/\";class Ss{constructor(e,t){this.REQUEST_TIMEOUT_MS=1e4,this.CREATE_TICKET_TIMEOUT_MS=3e4,this.sourceId=null,this.adminToken=null,this.onAdminAuthError=null,this.onSourceRejected=null,this.onIdentityRefused=null,this.restoreSource=null,this.onReachable=null,this.identityProof=new xs,this.identityWaiters=[],this.apiBaseUrl=e,this.publishableKey=t}setSourceId(e){this.sourceId=e}getSourceId(){return this.sourceId}setIdentity(e){if(this.identityProof.setIdentity(e),e){const e=this.identityWaiters;this.identityWaiters=[],e.forEach(e=>e())}}waitForIdentity(){return this.identityProof.hasIdentity()?Promise.resolve(!0):new Promise(e=>{const t=()=>{clearTimeout(n),e(!0)},n=setTimeout(()=>{this.identityWaiters=this.identityWaiters.filter(e=>e!==t),e(!1)},2500);this.identityWaiters.push(t)})}getIdentityProof(){return this.identityProof.hasIdentity()?this.identityProof.get():null}refreshIdentityProof(){return this.identityProof.get({refresh:!0})}setAdminToken(e){this.adminToken=e}setOnAdminAuthError(e){this.onAdminAuthError=e}setOnSourceRejected(e){this.onSourceRejected=e}setOnIdentityRefused(e){this.onIdentityRefused=e}setSourceRestorer(e){this.restoreSource=e}getIdentity(){return this.identityProof.getIdentity()}setOnReachable(e){this.onReachable=e}adminHeaders(){return this.adminToken?{\"X-Admin-Widget-Token\":this.adminToken}:{}}hasAdminHeader(e){return\"X-Admin-Widget-Token\"in e}async request(e,t={},n=!0,i=!0){const{timeoutMs:s=this.REQUEST_TIMEOUT_MS,...r}=t,o={\"Content-Type\":\"application/json\",\"X-Publishable-Key\":this.publishableKey,...r.headers||{}};this.sourceId&&(o[\"X-Source-Id\"]=this.sourceId);const a=await this.identityProof.get();a&&(o[a.header]=a.value);const l=new AbortController,c=setTimeout(()=>l.abort(),s);let d;try{d=await fetch(`${this.apiBaseUrl}${e}`,{...r,headers:o,signal:l.signal})}catch(t){const n=\"AbortError\"===t?.name;throw Pi.transport(e,n?\"timeout\":\"network\")}finally{clearTimeout(c)}if(this.onReachable?.(),!d.ok){let s;401!==d.status&&403!==d.status||!this.hasAdminHeader(o)||this.onAdminAuthError?.();try{const e=await d.clone().json();e&&\"string\"==typeof e.code&&(s=e.code)}catch{}const r=Pi.http(e,d.status,d.statusText,s);if(this.hasAdminHeader(o))throw r;if(401===d.status&&!o[\"X-Source-Id\"]){if(i&&this.restoreSource&&await this.restoreSource())return this.request(e,t,n,!1);throw r}if(n&&Fi(r)){if(this.identityProof.canRefresh())return await this.identityProof.get({refresh:!0}),this.request(e,t,!1,i);if(o[\"X-Source-Id\"]&&!this.identityProof.hasIdentity()&&this.onSourceRejected)return await this.waitForIdentity()||this.onSourceRejected(),this.request(e,t,!1,i)}if(\"identity_verification_required\"===r.code&&this.identityProof.hasIdentity()&&(!n||!this.identityProof.canRefresh())&&this.onIdentityRefused&&(this.onIdentityRefused(this.identityProof.refusalReason()),e!==ks))return this.request(e,t,!1,i);throw r}const u=d.headers.get(\"content-type\");if(u&&u.includes(\"application/json\"))try{return await d.json()}catch(t){if(t instanceof SyntaxError)throw t;throw Pi.transport(e,\"network\")}return{}}async loadSession(e){const t={};return e&&(t.source_id=e),this.request(\"/api/tickets/contacts/load/\",{method:\"POST\",body:JSON.stringify(t)},!0,!1)}async identifyUser(e){return this.request(ks,{method:\"POST\",body:JSON.stringify(e)})}async heartbeat(e=!1){return this.request(\"/api/tickets/contacts/heartbeat/\",{method:\"POST\",body:JSON.stringify(e?{intro_presentation_completed:!0}:{}),keepalive:e})}async createTicket(e){return this.request(\"/api/tickets/\",{method:\"POST\",body:JSON.stringify(e),timeoutMs:this.CREATE_TICKET_TIMEOUT_MS})}async sendMessage(e,t){return this.request(`/api/tickets/${e}/widget/messages/`,{method:\"POST\",body:JSON.stringify(t)})}async sendSessionMessage(e,t){return this.request(`/api/ai/contact-sessions/${e}/widget/messages/create/`,{method:\"POST\",body:JSON.stringify(t)})}async requestAssistance(e,t){return this.request(`/api/tickets/${e}/request-assistance/`,{method:\"POST\",body:JSON.stringify({assistance_type:t})})}async prepareUpload(e){return this.request(\"/api/tickets/widget/attachments/prepare/\",{method:\"POST\",body:JSON.stringify(e)})}async uploadToGCS(e,t,n,i){const s=await fetch(t,{method:\"PUT\",headers:{\"Content-Type\":i||e.type,\"x-goog-content-length-range\":`1,${n}`},body:e});if(!s.ok)throw Ji(`[API] GCS upload failed with status ${s.status}`),new Error(`Upload failed with status ${s.status}`)}async verifyUploads(e){return this.request(\"/api/tickets/widget/attachments/verify/\",{method:\"POST\",body:JSON.stringify(e)})}async getAttachmentUrl(e){return this.request(`/api/tickets/widget/attachments/${e}/url/`,{method:\"GET\"})}async getAIConfig(){return this.request(\"/api/ai/config/\",{method:\"GET\"})}async getTour(e){return this.request(`/api/ai/tours/${e}/`,{method:\"GET\"})}async submitPreChatForm(e){return this.request(\"/api/tickets/contacts/submit-info/\",{method:\"POST\",body:JSON.stringify(e)})}async submitNPS(e){return this.request(\"/api/tickets/nps/widget/submit/\",{method:\"POST\",body:JSON.stringify(e)})}async commentNPS(e){return this.request(\"/api/tickets/nps/widget/comment/\",{method:\"PATCH\",body:JSON.stringify(e)})}async dismissNPS(e){return this.request(\"/api/tickets/nps/widget/dismiss/\",{method:\"POST\",body:JSON.stringify(e)})}async submitActivationForm(e){return this.request(\"/api/activation/form/submit/\",{method:\"POST\",body:JSON.stringify(e)})}async skipActivationForm(){return this.request(\"/api/activation/form/skip/\",{method:\"POST\"})}async answerFeatureCheckIn(e,t){return this.request(`/api/activation/feature-check-ins/${e}/answer/`,{method:\"POST\",body:JSON.stringify(t)})}async dismissNudge(e){return this.request(\"/api/activation/nudges/dismiss/\",{method:\"POST\",body:JSON.stringify(e)})}async snoozeNudge(e){return this.request(\"/api/activation/nudges/snooze/\",{method:\"POST\",body:JSON.stringify(e)})}async openNudge(e){return this.request(\"/api/activation/nudges/open/\",{method:\"POST\",body:JSON.stringify({tab_id:e})})}async getChecklist(){return this.request(\"/api/activation/checklist/\",{method:\"GET\"})}async startChecklistObjective(e,t,n){return this.request(\"/api/activation/checklist/start/\",{method:\"POST\",body:JSON.stringify({pipeline_milestone_id:e,feature_id:n,tab_id:t})})}async startChecklistSecondary(e,t){return this.request(\"/api/activation/checklist/secondary/start/\",{method:\"POST\",body:JSON.stringify({feature_id:e,tab_id:t})})}async acceptVoiceCall(e){return this.request(`/api/tickets/voice-calls/widget/${e}/accept/`,{method:\"POST\",body:JSON.stringify({})})}async declineVoiceCall(e){await this.request(`/api/tickets/voice-calls/widget/${e}/decline/`,{method:\"POST\",body:JSON.stringify({})})}async endVoiceCall(e){await this.request(`/api/tickets/voice-calls/widget/${e}/end/`,{method:\"POST\",body:JSON.stringify({})})}async acknowledgeVoiceCallInvite(e){await this.request(`/api/tickets/voice-calls/widget/${e}/invite-delivered/`,{method:\"POST\",body:JSON.stringify({})})}async getActiveVoiceCall(e){const t=e?.rejoin?\"?rejoin=true\":\"\";return this.request(`/api/tickets/voice-calls/widget/active/${t}`,{method:\"GET\"})}async acceptScreenShare(e,t){return this.request(`/api/tickets/screen-shares/widget/${e}/accept/`,{method:\"POST\",body:JSON.stringify({tab_id:t})})}async declineScreenShare(e){await this.request(`/api/tickets/screen-shares/widget/${e}/decline/`,{method:\"POST\",body:JSON.stringify({})})}async acknowledgeScreenShareInvite(e){await this.request(`/api/tickets/screen-shares/widget/${e}/invite-delivered/`,{method:\"POST\",body:JSON.stringify({})})}async getActiveScreenShare(e){const t=`?tab_id=${encodeURIComponent(e)}`;return this.request(`/api/tickets/screen-shares/widget/active/${t}`,{method:\"GET\"})}async startLiveFeedbackSession(e){const t=\"stepUuid\"in e?{step_uuid:e.stepUuid}:{release_uuid:e.releaseUuid};return this.request(\"/api/ai/live-feedback/start/\",{method:\"POST\",body:JSON.stringify(t),headers:this.adminHeaders()})}async triggerPlaybook(e){return this.request(\"/api/sessions/playbook/\",{method:\"POST\",body:JSON.stringify(e)})}async createSession(e){return this.request(\"/api/ai/contact-sessions/widget/create/\",{method:\"POST\",body:JSON.stringify({force_agent_mode:e?.forceAgentMode??!1})})}async getReleases(e=20,t=0){return this.request(`/api/awareness/releases/widget/list/?limit=${e}&offset=${t}`,{method:\"GET\"})}async getReleasePlan(e){return this.request(`/api/awareness/releases/widget/${e}/plan/`,{method:\"GET\",headers:this.adminHeaders()})}async getAdminReleases(e=20,t=0){return this.request(`/api/awareness/releases/widget/admin/list/?limit=${e}&offset=${t}`,{method:\"GET\",headers:this.adminHeaders()})}async recordReleaseImpression(e){await this.request(`/api/awareness/releases/widget/${e}/impression/`,{method:\"POST\",body:JSON.stringify({page_url:this.stripTestParam(window.location?.href||\"\")})})}async markReleaseRead(e){await this.request(`/api/awareness/releases/widget/${e}/read/`,{method:\"POST\",body:JSON.stringify({page_url:this.stripTestParam(window.location?.href||\"\")})})}async clickRelease(e){return this.request(`/api/awareness/releases/widget/${e}/click/`,{method:\"POST\",body:JSON.stringify({page_url:this.stripTestParam(window.location?.href||\"\")})})}async dismissRelease(e){await this.request(`/api/awareness/releases/widget/${e}/dismiss/`,{method:\"POST\",body:JSON.stringify({page_url:this.stripTestParam(window.location?.href||\"\")})})}stripTestParam(e){try{const t=new URL(e);return t.searchParams.delete(\"blar_release_test\"),t.toString()}catch{return e}}async getContactHistory(e=10,t=0){return this.request(`/api/ai/contact-sessions/widget/history/?limit=${e}&offset=${t}`,{method:\"GET\"})}async archiveSession(e){return this.request(`/api/ai/contact-sessions/${e}/widget/archive/`,{method:\"POST\"})}async escalateSession(e){return this.request(`/api/ai/contact-sessions/${e}/widget/escalate/`,{method:\"POST\"})}async awarenessMatch(e){const t=await this.request(\"/api/awareness/widget/match/\",{method:\"POST\",body:JSON.stringify({page_url:e})});return t&&t.uuid?t:null}async awarenessPreview(e){return this.request(`/api/awareness/widget/${e}/preview/`,{method:\"GET\"})}async awarenessImpression(e,t,n=!1){return this.request(`/api/awareness/widget/${e}/impression/`,{method:\"POST\",body:JSON.stringify({page_url:t,...n&&{test:!0}})})}async awarenessClick(e,t,n=!1){return this.request(`/api/awareness/widget/${e}/click/`,{method:\"POST\",body:JSON.stringify({page_url:t,...n&&{test:!0}})})}async awarenessDismiss(e,t=!1){return this.request(`/api/awareness/widget/${e}/dismiss/`,{method:\"POST\",...t&&{body:JSON.stringify({test:!0})}})}async onboardingMatch(){const e=await this.request(\"/api/awareness/onboarding/widget/match/\",{method:\"POST\",body:JSON.stringify({})});return e&&e.uuid?e:null}async onboardingPreview(e){try{const t=await this.request(`/api/awareness/onboarding/widget/admin/?onboarding_type=${e}`,{method:\"GET\",headers:this.adminHeaders()});return t&&t.uuid?t:null}catch(e){if(e instanceof Pi&&404===e.status)return null;throw e}}async getStepPlan(e){return this.request(`/api/awareness/onboarding/widget/steps/${e}/plan/`,{method:\"GET\",headers:this.adminHeaders()})}async onboardingStartStep(e,t=!1){const n=t?\"?preview=true\":\"\";return this.request(`/api/awareness/onboarding/widget/steps/${e}/start/${n}`,{method:\"POST\",headers:this.adminHeaders()})}}function Cs(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,\"0\").substring(0,8)}class Es{constructor(e){this.storageKeyPrefix=\"support_widget_source_id\",this.cookieName=`${this.storageKeyPrefix}_${Cs(e)}`}getSourceId(){try{return ds.get(this.cookieName)}catch(e){return Ji(\"[TokenStorage] Failed to get sourceId from cookie\",e),null}}setSourceId(e){try{const t=\"https:\"===window.location.protocol;ds.set(this.cookieName,e,{days:14,sameSite:\"Lax\",secure:t})}catch(e){Ji(\"[TokenStorage] Failed to set sourceId cookie\",e)}}clearSourceId(){try{ds.delete(this.cookieName)}catch(e){Ji(\"[TokenStorage] Failed to clear sourceId cookie\",e)}}hasSourceId(){return null!==this.getSourceId()}}class Ms{constructor(e){const t=Cs(e);this.sessionCookieName=`support_widget_admin_session_${t}`,this.tokenCookieName=`support_widget_admin_token_${t}`,this.stepUuidStorageKey=`support_widget_admin_step_${t}`,this.entityStorageKey=`support_widget_admin_entity_${t}`,this.releaseUuidStorageKey=`support_widget_admin_release_${t}`}getAdminToken(){try{return ds.get(this.tokenCookieName)}catch(e){return Ji(\"[AdminModeStorage] Failed to get admin token from cookie\",e),null}}setAdminToken(e){try{const t=\"https:\"===window.location.protocol;ds.set(this.tokenCookieName,e,{days:1,sameSite:\"Lax\",secure:t})}catch(e){Ji(\"[AdminModeStorage] Failed to set admin token cookie\",e)}}clearAdminToken(){try{ds.delete(this.tokenCookieName)}catch(e){Ji(\"[AdminModeStorage] Failed to clear admin token cookie\",e)}}getAdminSessionId(){try{const e=ds.get(this.sessionCookieName);if(null===e)return null;const t=Number.parseInt(e,10);return Number.isFinite(t)?t:null}catch(e){return Ji(\"[AdminModeStorage] Failed to get admin session id from cookie\",e),null}}setAdminSessionId(e){try{const t=\"https:\"===window.location.protocol;ds.set(this.sessionCookieName,String(e),{days:14,sameSite:\"Lax\",secure:t})}catch(e){Ji(\"[AdminModeStorage] Failed to set admin session id cookie\",e)}}clearAdminSessionId(){try{ds.delete(this.sessionCookieName)}catch(e){Ji(\"[AdminModeStorage] Failed to clear admin session id cookie\",e)}}getAdminStepUuid(){try{return sessionStorage.getItem(this.stepUuidStorageKey)}catch(e){return Ji(\"[AdminModeStorage] Failed to get admin step uuid from sessionStorage\",e),null}}setAdminStepUuid(e){try{sessionStorage.setItem(this.stepUuidStorageKey,e)}catch(e){Ji(\"[AdminModeStorage] Failed to set admin step uuid in sessionStorage\",e)}}clearAdminStepUuid(){try{sessionStorage.removeItem(this.stepUuidStorageKey)}catch(e){Ji(\"[AdminModeStorage] Failed to clear admin step uuid from sessionStorage\",e)}}getAdminEntity(){try{const e=sessionStorage.getItem(this.entityStorageKey);if(null===e)return null;const t=JSON.parse(e);return null!==t&&\"object\"==typeof t&&\"string\"==typeof t.action&&\"string\"==typeof t.title?{action:t.action,title:t.title}:null}catch(e){return Ji(\"[AdminModeStorage] Failed to get admin entity from sessionStorage\",e),null}}setAdminEntity(e){try{sessionStorage.setItem(this.entityStorageKey,JSON.stringify(e))}catch(e){Ji(\"[AdminModeStorage] Failed to set admin entity in sessionStorage\",e)}}clearAdminEntity(){try{sessionStorage.removeItem(this.entityStorageKey)}catch(e){Ji(\"[AdminModeStorage] Failed to clear admin entity from sessionStorage\",e)}}getAdminReleaseUuid(){try{return sessionStorage.getItem(this.releaseUuidStorageKey)}catch(e){return Ji(\"[AdminModeStorage] Failed to get admin release uuid from sessionStorage\",e),null}}setAdminReleaseUuid(e){try{sessionStorage.setItem(this.releaseUuidStorageKey,e)}catch(e){Ji(\"[AdminModeStorage] Failed to set admin release uuid in sessionStorage\",e)}}clearAdminReleaseUuid(){try{sessionStorage.removeItem(this.releaseUuidStorageKey)}catch(e){Ji(\"[AdminModeStorage] Failed to clear admin release uuid from sessionStorage\",e)}}clearAll(){this.clearAdminSessionId(),this.clearAdminToken(),this.clearAdminStepUuid(),this.clearAdminEntity(),this.clearAdminReleaseUuid()}}class As{constructor(e){this.cookieName=`support_widget_agent_handoff_${Cs(e)}`}getSessionId(){try{const e=ds.get(this.cookieName);if(null===e)return null;const t=Number.parseInt(e,10);return Number.isFinite(t)?t:null}catch(e){return Ji(\"[AgentHandoffStorage] Failed to read handoff cookie\",e),null}}set(e){try{ds.set(this.cookieName,String(e),{days:30/86400,sameSite:\"Lax\",secure:\"https:\"===window.location.protocol})}catch(e){Ji(\"[AgentHandoffStorage] Failed to set handoff cookie\",e)}}clear(){try{ds.delete(this.cookieName)}catch(e){Ji(\"[AgentHandoffStorage] Failed to clear handoff cookie\",e)}}}const _s=\"support_widget_reopen_chat\";var Ts;!function(e){e.PENDING=\"pending\",e.SENDING=\"sending\",e.FAILED=\"failed\",e.SENT=\"sent\"}(Ts||(Ts={}));class Is{constructor(e){this.STORAGE_KEY=\"support_widget_message_queue\",this.MAX_RETRIES=3,this.RETRY_DELAYS=[1e3,3e3,5e3],this.MAX_AGE_MS=864e5,this.queue=new Map,this.retryTimers=new Map,this.callbacks=e,this.loadFromStorage(),this.cleanup()}enqueue(e){const t={...e,status:Ts.PENDING,retryCount:0,createdAt:s(),lastAttemptAt:null};return this.queue.set(e.id,t),this.persist(),e.id}get(e){return this.queue.get(e)}updateStatus(e,t,n){const i=this.queue.get(e);i&&(i.status=t,n&&(i.error=n),i.lastAttemptAt=s(),this.persist(),this.callbacks.onStatusChange(e,t,n))}markSent(e){this.cancelRetry(e),this.queue.delete(e),this.persist(),this.callbacks.onStatusChange(e,Ts.SENT)}markForRetry(e,t){const n=this.queue.get(e);if(!n)return!1;if(n.retryCount++,n.error=t,n.lastAttemptAt=s(),n.retryCount>=this.MAX_RETRIES)return n.status=Ts.FAILED,this.persist(),this.callbacks.onStatusChange(e,Ts.FAILED,t),!1;n.status=Ts.PENDING,this.persist();const i=this.RETRY_DELAYS[n.retryCount-1]||this.RETRY_DELAYS[this.RETRY_DELAYS.length-1];return this.scheduleRetry(e,i),!0}resetForRetry(e){const t=this.queue.get(e);t&&(t.status=Ts.PENDING,t.retryCount=0,t.error=void 0,this.persist(),this.callbacks.onStatusChange(e,Ts.PENDING))}getPendingMessages(){return Array.from(this.queue.values()).filter(e=>e.status===Ts.PENDING)}getFailedMessages(){return Array.from(this.queue.values()).filter(e=>e.status===Ts.FAILED)}remove(e){this.cancelRetry(e),this.queue.delete(e),this.persist()}clearForConversation(e,t){for(const[n,i]of this.queue.entries())i.conversationId===e&&i.conversationType===t&&(this.cancelRetry(n),this.queue.delete(n));this.persist()}persist(){try{const e={version:1,messages:Array.from(this.queue.values())};localStorage.setItem(this.STORAGE_KEY,JSON.stringify(e))}catch(e){Ji(\"[MessageQueue] Failed to persist queue\",e)}}loadFromStorage(){try{const e=localStorage.getItem(this.STORAGE_KEY);if(!e)return;const t=JSON.parse(e);if(1!==t.version)return;for(const e of t.messages)e.status===Ts.SENDING&&(e.status=Ts.PENDING),this.queue.set(e.id,e)}catch(e){Ji(\"[MessageQueue] Failed to load queue from storage\",e)}}scheduleRetry(e,t){this.cancelRetry(e);const n=setTimeout(()=>{this.retryTimers.delete(e);const t=this.queue.get(e);t&&t.status===Ts.PENDING&&this.callbacks.onStatusChange(e,Ts.PENDING)},t);this.retryTimers.set(e,n)}cancelRetry(e){const t=this.retryTimers.get(e);t&&(clearTimeout(t),this.retryTimers.delete(e))}cleanup(){const e=s();for(const[t,n]of this.queue.entries())e-n.createdAt>this.MAX_AGE_MS&&(this.cancelRetry(t),this.queue.delete(t));this.persist()}hasRetryScheduled(e){return this.retryTimers.has(e)}}const Ls=new Set([\"id\",\"name\",\"class\",\"aria-label\",\"aria-labelledby\",\"aria-describedby\",\"aria-placeholder\",\"aria-expanded\",\"aria-selected\",\"aria-checked\",\"aria-disabled\",\"aria-haspopup\",\"aria-controls\",\"aria-owns\",\"role\",\"title\",\"alt\",\"type\",\"value\",\"placeholder\",\"for\",\"href\",\"src\",\"disabled\",\"readonly\",\"required\",\"checked\",\"tabindex\",\"contenteditable\"]),Rs=[\"data-testid\",\"data-test\",\"data-cy\",\"data-id\",\"data-name\",\"data-type\",\"data-field\",\"data-action\",\"data-placeholder\",\"data-value\",\"data-label\",\"data-state\",\"data-selected\",\"data-active\"];function $s(e,t=1500){const n=e.cloneNode(!0);Ns(n);let i=n.outerHTML;return i.length>t&&(i=i.substring(0,t)+\"...\"),i}function Ns(e){const t=Array.from(e.children);for(const e of t){if(\"SVG\"===e.tagName||\"svg\"===e.tagName.toLowerCase()){const t=document.createElement(\"svg\");e.replaceWith(t);continue}[\"SCRIPT\",\"STYLE\",\"NOSCRIPT\",\"IFRAME\"].includes(e.tagName.toUpperCase())?os(e):Ns(e)}!function(e){const t=[];for(const n of Array.from(e.attributes)){const e=n.name.toLowerCase();if(!Ls.has(e)){if(e.startsWith(\"data-\")){if(Rs.some(t=>e===t||e.startsWith(t+\"-\")))continue;t.push(n.name);continue}\"style\"!==e?(e.startsWith(\"on\")||e.startsWith(\"xmlns\")||e.startsWith(\"xml:\"))&&t.push(n.name):t.push(n.name)}}for(const n of t)e.removeAttribute(n)}(e)}function Ps(){if(!document.hidden)return!1;const e=document.body??document.documentElement,t=e?.getBoundingClientRect();return!t||0===t.width&&0===t.height}function Fs(){return document.hidden}function Os(){return{style:e=>window.getComputedStyle(e),rect:e=>e.getBoundingClientRect(),noLayout:Ps(),frozen:Fs()}}const qs=[\"menu\",\"dialog\",\"alertdialog\",\"listbox\",\"tooltip\"].map(e=>`[role=\"${e}\"][data-state=\"closed\"]`).join(\", \");function Hs(e,t,n){if(function(e){return\"function\"==typeof e.getAnimations&&e.getAnimations().some(e=>{if(\"running\"!==e.playState)return!1;const t=e.effect;if(!t||null==t.getComputedTiming().progress)return!1;const n=t.getKeyframes(),i=n[n.length-1]?.opacity;return null!=i&&parseFloat(String(i))>0})}(e))return!0;if(!n.frozen)return!1;const i=t.transitionProperty;return!(!i||!/\\b(opacity|all)\\b/.test(i))||!!e.closest('[role=\"menu\"], [role=\"dialog\"], [role=\"alertdialog\"], [role=\"listbox\"], [role=\"tooltip\"], [class*=\"popover\" i], [class*=\"dropdown\" i], [class*=\"popup\" i]')}function Bs(e,t){const n=t.chainOpaqueCache?.get(e);if(void 0!==n)return n;const i=t.style(e),s=e.parentElement,r=(0!==parseFloat(i.opacity)||Hs(e,i,t))&&(!s||Bs(s,t));return t.chainOpaqueCache?.set(e,r),r}function Ds(e,t=Os()){if(!e.isConnected)return!1;if(e instanceof SVGElement)return function(e,t){const n=t.style(e);if(\"none\"===n.display||\"hidden\"===n.visibility)return!1;for(let n=e.parentElement;n;n=n.parentElement){const e=t.style(n);if(\"none\"===e.display||\"hidden\"===e.visibility)return!1;if(0===parseFloat(e.opacity))return!1}if(t.noLayout)return!0;const i=t.rect(e);return i.width>0||i.height>0}(e,t);if(!(e instanceof HTMLElement))return!1;const n=t.style(e);if(\"none\"===n.display)return!1;if(\"hidden\"===n.visibility)return!1;if(function(e){return!!e.closest(qs)}(e))return!1;if(e.parentElement&&!Bs(e.parentElement,t))return!1;if(\"contents\"===n.display)return!0;if(t.noLayout)return!0;const i=t.rect(e);if(0!==i.width||0!==i.height)return!function(e,t,n){const i=e.ownerDocument.defaultView;if(!i)return!1;const s=t.bottom>0&&t.right>0&&t.top<i.innerHeight&&t.left<i.innerWidth;if(s)return!1;for(let t=e;t;t=t.parentElement){const i=n.style(t);if(t!==e&&/auto|scroll/.test(i.overflow))return!1;if(\"fixed\"===i.position)return!0}return!1}(e,i,t);for(let n=e.parentElement;n;n=n.parentElement){const e=t.style(n);if(\"none\"===e.display||\"hidden\"===e.visibility)return!1;if(\"hidden\"===e.overflow&&0===t.rect(n).height)return!1}return!(!e.isContentEditable&&!e.closest('[contenteditable=\"true\"]'))||\"visible\"===n.overflow&&e.children.length>0}const zs=new Set([\"STYLE\",\"SCRIPT\",\"NOSCRIPT\",\"TEMPLATE\"]);function Us(e,t=e=>window.getComputedStyle(e)){const n=e=>e.trim().replace(/\\s+/g,\" \");if(!e.firstElementChild)return n(e.textContent||\"\");return n(js(e,e=>{const n=t(e);return\"none\"===n.display||\"hidden\"===n.visibility||0===parseFloat(n.opacity)}))||n(js(e,()=>!1))}function js(e,t){let n=\"\";for(const i of Array.from(e.childNodes))i.nodeType===Node.TEXT_NODE?n+=i.nodeValue??\"\":i instanceof Element&&!zs.has(i.tagName)&&!t(i)&&(n+=js(i,t));return n}function Ws(e,t,n){let i=e instanceof HTMLElement?e:e.parentElement;for(let e=0;e<t&&i&&i.parentElement&&(i=i.parentElement,\"BODY\"!==i.tagName&&\"HTML\"!==i.tagName);e++);return i?$s(i,n):\"\"}function Vs(e){const t=e.getAttribute(\"aria-label\");if(t)return t;let n=e.parentElement;for(let e=0;e<6&&n&&(\"BODY\"!==n.tagName&&\"HTML\"!==n.tagName);e++){const e=n.getAttribute(\"aria-label\");if(e)return e;const t=n.querySelector(\"h1, h2, h3, h4, h5, h6, label, legend\");if(t){const e=(t.textContent||\"\").trim();if(e)return e}for(const e of Array.from(n.children)){if(e.children.length>0)continue;const t=(e.textContent||\"\").trim();if(t&&t.length<=50)return t}n=n.parentElement}}function Gs(e){let t=e;const n=[];for(let e=0;e<6&&t;e++){const e=t.parentElement;if(!e||\"BODY\"===e.tagName||\"HTML\"===e.tagName)break;for(const i of Array.from(e.children)){if(i===t)continue;const e=(i.textContent||\"\").trim();e&&e.length<=200&&n.push(e)}if(n.length>=3)break;t=e}return n}const Ks=new Set([\"solid\",\"regular\",\"light\",\"thin\",\"duotone\",\"brands\",\"sharp\",\"fill\",\"dark\",\"inactive\",\"fw\",\"inverse\",\"pull-left\",\"pull-right\",\"stack\",\"stack-1x\",\"stack-2x\",\"li\",\"ul\",\"spin\",\"pulse\",\"spin-pulse\",\"spin-reverse\",\"beat\",\"fade\",\"beat-fade\",\"bounce\",\"shake\"]),Ys=/^(\\d+x|\\d+px|2?xs|2?xl|sm|md|lg|xl|xxl|rotate(-(\\d+|by))?|flip(-(h|v|horizontal|vertical|both))?)$/,Xs=e=>Ks.has(e)||Ys.test(e),Js=e=>e.replace(/^(icon|ic|svg|sprite|glyph)[-_]/i,\"\").split(/[-_]/).filter(Boolean).map((e,t)=>0===t?e.charAt(0).toUpperCase()+e.slice(1):e).join(\" \").trim(),Qs=/^(?:lucide|fa[srlbd]?|glyphicon|icon|heroicon|bi|mdi|tabler|ti|ri|bx[sl]?|ph|gg|carbon|ion|eva)-(.+)$/;function Zs(e){if(e.textContent?.trim())return!1;const t=e.querySelectorAll(\"*\");if(t.length<2||t.length>6)return!1;const n=Os(),i={45:[],135:[]};for(const e of Array.from(t)){if(!(e instanceof HTMLElement))continue;const t=getComputedStyle(e),s=t.transform.match(/^matrix\\(([^,]+),\\s*([^,]+)/);if(!s||\"hidden\"===t.visibility||!Bs(e,n))continue;const r=e.getBoundingClientRect();if(!r.width||!r.height)continue;const o=(180*Math.atan2(Number(s[2]),Number(s[1]))/Math.PI%180+180)%180,a=Math.abs(o-45)<10?45:Math.abs(o-135)<10?135:null;a&&i[a].push({x:r.left+r.width/2,y:r.top+r.height/2,length:Math.max(e.offsetWidth,e.offsetHeight)})}return i[45].some(e=>i[135].some(t=>Math.hypot(e.x-t.x,e.y-t.y)<=.25*Math.min(e.length,t.length)))}function er(e){if(Zs(e)){const t=e.getAttribute(\"aria-label\")?.trim()||e.getAttribute(\"title\")?.trim();return t?`Close (${t})`:\"Close\"}const t=e.getAttribute(\"title\")?.trim();if(t)return t;const n=e.querySelector('svg, i, [class*=\"icon\"]')||e,i=n.getAttribute(\"aria-label\")?.trim()||n.getAttribute(\"title\")?.trim();if(i)return i;const s=n.getAttribute(\"data-icon\")?.trim();if(s)return Js(s);const r=n.querySelector(\"use\")||(\"use\"===n.tagName?n:null),o=r?.getAttribute(\"href\")||r?.getAttribute(\"xlink:href\");if(o){const e=o.split(\"#\")[1]?.trim();if(e)return Js(e)}for(const e of Array.from(n.classList)){const t=e.match(Qs);if(t&&!Xs(t[1]))return Js(t[1])}const a=e.querySelector(\".material-icons, .material-symbols-outlined, .material-symbols-rounded\");if(a?.textContent?.trim())return Js(a.textContent.trim());const l=e instanceof HTMLImageElement?e:e.querySelector(\"img\");if(l){const e=l.getAttribute(\"alt\")?.trim();if(e)return e;const t=l.getAttribute(\"title\")?.trim();if(t)return t}if(null!==e.querySelector(\"svg\")&&\"\"===e.textContent?.trim()){const t=e.getAttribute(\"data-testid\")?.trim();return t?Js(t):\"Icon button\"}}const tr=new Set([\"check-square\",\"check-square-o\",\"square-check\",\"check-circle\",\"check-circle-o\",\"circle-check\",\"checkbox-marked\",\"checkbox-marked-outline\",\"check-box\",\"radiobox-marked\",\"dot-circle\",\"dot-circle-o\",\"radio-button-checked\",\"toggle-on\"]),nr=new Set([\"square-o\",\"square-outline\",\"checkbox-blank\",\"checkbox-blank-outline\",\"check-box-outline-blank\",\"circle-o\",\"circle-outline\",\"radiobox-blank\",\"radio-button-unchecked\",\"unchecked\",\"toggle-off\"]),ir=new Set([...tr,...nr].map(Js));function sr(e){return ir.has(e)}const rr=new Set([\"square\",\"circle\"]),or={\"glyphicon-check\":!0,\"glyphicon-unchecked\":!1};function ar(e){return!!(e.hasAttribute(\"role\")||e.hasAttribute(\"tabindex\")||e.hasAttribute(\"onclick\"))||!!e.closest(\"a, button, label, [role], [onclick]\")}function lr(e){const t=function(e){for(const t of Array.from(e.classList))if(t in or)return or[t];for(const t of function(e){const t=[];for(const n of Array.from(e.classList)){const e=n.match(Qs);e&&!Xs(e[1])&&t.push(e[1].toLowerCase())}return t}(e)){if(tr.has(t))return!0;if(nr.has(t))return!1;if(rr.has(t)&&ar(e))return!1}const t=/^(A|BUTTON|LABEL)$/.test(e.tagName)||e.hasAttribute(\"role\");if(!t||0===e.children.length||e.children.length>2)return null;if((e.textContent||\"\").trim())return null;const n=e.querySelector(\"i, svg, span[class]\");return n?lr(n):null}(e);return null===t?null:dr(e)??t}function cr(e){return dr(e)??e.checked}function dr(e){for(const t of Object.keys(e)){if(!t.startsWith(\"__reactProps$\")&&!t.startsWith(\"__reactEventHandlers$\"))continue;const n=e[t];if(\"boolean\"==typeof n?.value&&void 0===n.checked&&void 0===n.defaultChecked)return n.value}return null}function ur(e){for(const t of[\"aria-checked\",\"aria-pressed\"]){const n=e.getAttribute(t);if(\"true\"===n)return!0;if(\"false\"===n)return!1}const t=pr(e);return t?cr(t):lr(e)}function pr(e){const t=e.querySelectorAll('input[type=\"checkbox\"], input[type=\"radio\"]');return 1===t.length?t[0]:null}function hr(e){const t=e.getAttribute(\"placeholder\")||e.getAttribute(\"data-placeholder\")||e.getAttribute(\"aria-placeholder\");if(t)return t;if(\"true\"===e.getAttribute(\"contenteditable\")){const t=e.querySelector(\"[data-placeholder]\");if(t)return t.getAttribute(\"data-placeholder\")||void 0}}const gr=new Set([\"SCRIPT\",\"STYLE\",\"NOSCRIPT\",\"IFRAME\",\"SVG\",\"BR\",\"HR\",\"LINK\",\"META\",\"TEMPLATE\",\"SLOT\",\"CANVAS\",\"VIDEO\",\"AUDIO\",\"SOURCE\",\"TRACK\",\"MAP\",\"AREA\",\"PICTURE\",\"OBJECT\",\"EMBED\",\"PATH\",\"IMG\",\"HEAD\"]),mr=new Set([\"H1\",\"H2\",\"H3\",\"H4\",\"H5\",\"H6\"]);function fr(){return window.location.pathname+window.location.search+window.location.hash}function br(e){return\"pointer\"===e||\"grab\"===e||\"grabbing\"===e}function yr(e,t=getComputedStyle){const n=e.parentElement,i=t(e).cursor;return!!n&&br(i)&&i!==t(n).cursor}const vr='button, a[href], input, select, textarea, [role=\"button\"], [role=\"link\"], [tabindex]';function wr(e,t){if(!yr(e))return!1;if(e.querySelector(vr))return!1;const n=t();return n.length>0&&n.length<=40}function xr(e){if(\"A\"!==e.tagName)return!1;const t=e.getAttribute(\"href\");return null===t||(\"\"===t||\"#\"===t||t.startsWith(\"javascript:\"))}function kr(e){return\"A\"===e.tagName&&e.hasAttribute(\"href\")&&!xr(e)&&!e.querySelector('button, a[href], input, select, textarea, [role=\"button\"]')}function Sr(e){try{const t=new URL(e.href,window.location.href);return t.origin!==window.location.origin?` → ${t.host}`:` → ${t.pathname}${t.hash}`}catch{return\"\"}}function Cr(e){return e.matches(\":disabled\")||\"true\"===e.getAttribute(\"aria-disabled\")||e.hasAttribute(\"disabled\")||function(e){if(\"none\"!==getComputedStyle(e).pointerEvents)return!1;let t=e;for(;t.parentElement&&\"none\"===getComputedStyle(t.parentElement).pointerEvents;)t=t.parentElement;return t!==e&&t!==document.body&&t!==document.documentElement}(e)}function Er(e){const t=e.firstElementChild,n=1===t?.childElementCount?t.firstElementChild:t;if(!(n instanceof HTMLInputElement)||\"text\"!==n.type||e.childElementCount<2)return null;if(!n.disabled&&!n.readOnly)return null;const i=n.value.trim();return i&&i.length<=80?i:null}function Mr(e){const t=e.parentElement;if(!t||e===t.firstElementChild||!Er(t))return null;const n=Array.prototype.indexOf.call(t.children,e);let i=t;for(let e=0;i&&e<=3;e++,i=i.parentElement)for(let e=i.previousElementSibling;e;e=e.previousElementSibling)for(const i of[e,...Array.from(e.querySelectorAll(\"*\"))]){if(i.childElementCount!==t.childElementCount)continue;const e=Array.from(i.children,Ar);if(e.every(Boolean))return e[n]}return null}function Ar(e){if(e.querySelector(\"input, select, textarea, button\"))return\"\";const t=(e.textContent||\"\").replace(/\\s+/g,\" \").trim();return t.length<=40?t:\"\"}function _r(e){return(e.textContent||\"\").replace(/\\s+/g,\" \").trim()}function Tr(e){let t=e;for(;1===t.children.length&&_r(t)===_r(t.children[0]);)if(t=t.children[0],t.matches('button, [role=\"button\"], [role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"], [role=\"tab\"], [role=\"option\"]'))return t;return null}function Ir(e,t){for(let n=e.parentElement;n;n=n.parentElement){if(Tr(n)!==e)return null;const i=n.getAttribute(t);if(null!==i)return i}return null}const Lr=new Set([\"NAV\",\"MAIN\",\"ASIDE\",\"HEADER\",\"FOOTER\",\"SECTION\",\"ARTICLE\"]),Rr=new Set([\"button\",\"switch\",\"checkbox\",\"menuitemcheckbox\"]);function $r(e){const t=e.getAttribute(\"aria-checked\");if(\"true\"===t)return\"[✓]\";if(\"false\"===t)return\"[ ]\";if(\"mixed\"===t)return\"[~]\";if(\"BUTTON\"===e.tagName||Rr.has(e.getAttribute(\"role\")??\"\")){const t=pr(e);if(t){const e=cr(t);return\"radio\"===t.type?e?\"(●)\":\"( )\":e?\"[✓]\":\"[ ]\"}}const n=lr(e);return null===n?null:n?\"[✓]\":\"[ ]\"}function Nr(e){return e.getAttribute(\"aria-expanded\")??Ir(e,\"aria-expanded\")}function Pr(e){const t=[],n=e.getAttribute(\"aria-pressed\");\"true\"===n?t.push(\"[ON]\"):\"false\"===n&&t.push(\"[OFF]\");const i=Nr(e);return\"true\"===i?t.push(\"[expanded]\"):\"false\"===i&&t.push(\"[collapsed]\"),\"true\"===e.getAttribute(\"aria-selected\")&&t.push(\"[selected]\"),t.length>0?\" \"+t.join(\" \"):\"\"}function Fr(e){const t=[];e.querySelectorAll(\"thead th, thead td\").forEach(e=>{const n=(e.textContent||\"\").trim();n&&t.push(n)});const n=e.querySelectorAll(\"tbody tr\").length||e.rows.length;return`Table: ${t.length>0?`[${t.join(\", \")}]`:\"\"} (${n} rows)`}function Or(e,t,n,i){const s=e=>{const s=[];qr(e,s,t,n,i);return s.join(\" \").replace(/\\s+/g,\" \").trim().replace(/\\|/g,\"\\\\|\")},r=[\"Table:\"],o=e.caption?s(e.caption):\"\";o&&r.push(o);const a=Array.from(e.querySelectorAll(\"thead th, thead td\")).map(s);a.length>0&&r.push(`| ${a.join(\" | \")} |`);const l=Array.from(e.rows).filter(e=>!e.closest(\"thead\"));for(const e of l){const t=Array.from(e.cells).map(s);t.length>0&&r.push(`| ${t.join(\" | \")} |`)}return r.join(\"\\n\")}function qr(e,t,n,i,s){if(e.nodeType===Node.TEXT_NODE){const n=(e.textContent||\"\").trim();return void(n&&t.push(n))}if(e.nodeType!==Node.ELEMENT_NODE)return;const r=e;if(n?.has(r))return;if(i?.(r)){if(function(e,t){if(\"INPUT\"!==e.tagName)return!1;const n=(e.type||\"\").toLowerCase();if(\"checkbox\"!==n&&\"radio\"!==n)return!1;const i=e.parentElement;return!!i&&!t?.(i)}(r,i)){const e=Hr(r);e&&t.push(s?.(r,e)??e)}return}const o=Hr(r);if(null===o)for(const e of Array.from(r.childNodes))qr(e,t,n,i,s);else o&&t.push(s?.(r,o)??o)}function Hr(e){const t=function(e){const t=e.tagName,n=$r(e);if(n)return n;if(\"SELECT\"===t){const t=e,n=t.options[t.selectedIndex];return`[${(n?.textContent||t.value||\"\").trim()||\"—\"} ▾]`}if(\"INPUT\"===t){const t=e,n=(t.type||\"text\").toLowerCase();return\"hidden\"===n||\"submit\"===n||\"button\"===n||\"image\"===n||\"reset\"===n?\"\":\"checkbox\"===n?cr(t)?\"[✓]\":\"[ ]\":\"radio\"===n?cr(t)?\"(●)\":\"( )\":t.value?`[value: \"${t.value}\"]`:\"[empty]\"}if(\"TEXTAREA\"===t){const t=e;if(t.value){return`[value: \"${t.value.length>50?t.value.substring(0,50)+\"...\":t.value}\"]`}return\"[empty]\"}if(xr(e)||\"BUTTON\"===t||wr(e,()=>Us(e))){const t=Us(e)||er(e)||\"\";return t||e.hasAttribute(\"aria-pressed\")?`[button]${t?` ${t}`:\"\"}${Pr(e)}`:null}if(kr(e)){const t=Us(e)||er(e)||\"\";if(t)return`[link] ${t}`}return null}(e);return t&&Cr(e)?`${t} [disabled]`:t}function Br(e){let t=\"\";for(const n of Array.from(e.childNodes))if(n.nodeType===Node.TEXT_NODE){const e=(n.textContent||\"\").trim();e&&(t+=(t?\" \":\"\")+e)}return t.replace(/\\s+/g,\" \").trim()}function Dr(e){const t=e.map(e=>({el:e,rect:e.getBoundingClientRect()}));if(t.some(e=>0===e.rect.width))return null;const n=t[0].rect.top;if(t.some(e=>Math.abs(e.rect.top-n)>2))return null;const i=e[0].parentElement;for(const e of function*(e){for(let t=0;e&&t<=3;t++,e=e.parentElement)for(let t=e.previousElementSibling;t;t=t.previousElementSibling)yield t,yield*Array.from(t.querySelectorAll(\"*\"))}(i)){const i=Array.from(e.children,e=>({el:e,rect:e.getBoundingClientRect()})).filter(e=>e.rect.width>0&&e.rect.bottom<=n+2),s=new Map;for(const e of t){const t=i.find(t=>Ur(t.rect,e.rect)&&Ur(e.rect,t.rect));t&&s.set(e.el,t.el)}if(s.size===t.length)return s}return null}function zr(e){const t=(e.getAttribute(\"aria-label\")||\"\").trim();if(t)return t;const n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=n.nextNode();e;e=n.nextNode()){const t=(e.textContent||\"\").replace(/\\s+/g,\" \").trim();if(!(t.length>50)&&/^[A-Za-zÁÉÍÓÚÑáéíóúñÀ-ÿ]/.test(t)&&(t.match(/[A-Za-zÁÉÍÓÚÑáéíóúñÀ-ÿ]/g)??[]).length>=3)return t}return\"\"}function Ur(e,t){const n=e.left+e.width/2;return n>=t.left&&n<=t.right}const jr=/^on(Click|MouseDown|MouseUp|PointerDown|PointerUp)$/;function Wr(e){if(!e||\"object\"!=typeof e)return!1;for(const t of Object.keys(e))if(jr.test(t)&&e[t])return!0;return!1}function Vr(e){const t=e;if(function(e){if(\"function\"!=typeof e)return!1;const t=Function.prototype.toString.call(e),n=t.indexOf(\"{\");return-1===n||t.slice(n+1,t.lastIndexOf(\"}\")).trim().length>0}(t.onclick))return!0;for(const e of Object.keys(t))if((e.startsWith(\"__reactProps$\")||e.startsWith(\"__reactEventHandlers$\"))&&Wr(t[e]))return!0;return!!Wr(t._vei)||!!Wr(t.__vnode?.props)}const Gr=\"data-blar-slot\",Kr=/^\\d{1,2}(:\\d{2}\\s*(h|hrs|am|pm|a\\.\\s?m\\.|p\\.\\s?m\\.)?|\\s*(h|hrs|am|pm|a\\.\\s?m\\.|p\\.\\s?m\\.))$/i;function Yr(e){if(document.querySelectorAll(`[${Gr}]`).forEach(e=>os(e)),!Ps())for(const t of function(e){const t=new Map;for(const n of Array.from(document.body.querySelectorAll(\"*\"))){if(!n.parentElement||!Array.from(n.attributes).some(e=>e.name.startsWith(\"data-\")))continue;const i=e(n);if(0===i.length)continue;const s=i.map(e=>e.slice(0,e.indexOf(\"=\"))).join(\" \"),r=t.get(n.parentElement)??new Map;r.set(s,[...r.get(s)??[],n]),t.set(n.parentElement,r)}const n=[];for(const i of t.values())for(const t of i.values()){if(t.length<2)continue;const i=e(t[0]).join(\" \");t.every(t=>e(t).join(\" \")===i)||n.push(t)}return n}(e))Xr(t,e)}function Xr(e,t){const n=e.map(e=>e.getBoundingClientRect());if(n.some(e=>0===e.width||e.height<=e.width/2))return;if(n.some(e=>Math.abs(e.top-n[0].top)>2))return;const i=e[0].parentElement;if(!i||!Vr(i)&&!e.every(Vr))return;const s=function(e,t){const n=e[0].parentElement;if(!n)return null;for(const i of Array.from(n.children))if(!e.includes(i))for(const e of[i,...Array.from(i.querySelectorAll(\"*\"))]){const n=Array.from(e.children,e=>({label:(e.textContent||\"\").replace(/\\s+/g,\" \").trim(),rect:e.getBoundingClientRect()}));if(n.length<3)continue;if(n.some(e=>!Kr.test(e.label)||0===e.rect.height))continue;const i=n.every((e,t)=>0===t||e.rect.top>=n[t-1].rect.bottom-2),s=n[0].rect.top<t.bottom&&n[n.length-1].rect.bottom>t.top;if(i&&s)return n}return null}(e,n[0]);if(!s)return;const r=Dr(e),o=t(e[0]).filter(n=>e.every(e=>t(e).includes(n)));e.forEach((e,i)=>{if(Cr(e)||\"true\"===e.getAttribute(\"data-unavailable\"))return;if(\"static\"===getComputedStyle(e).position)return;const a=r?.get(e),l=a&&zr(a)||t(e).filter(e=>!o.includes(e)).join(\" \"),c=n[i],d=Array.from(e.children).map(e=>e.getBoundingClientRect()).filter(e=>e.height>0);for(const t of s){const n=t.rect.top-c.top,i=.25*t.rect.height;if(n<0||n+i>c.height+2)continue;const s=t.rect.top,r=s+i;if(d.some(e=>e.top<r&&e.bottom>s))continue;const o=document.createElement(\"div\");o.setAttribute(Gr,\"\"),o.setAttribute(\"role\",\"button\"),o.setAttribute(\"aria-label\",`${l} ${t.label}`),o.style.cssText=`position:absolute;left:0;right:0;top:${n}px;height:${i}px;pointer-events:none;`,e.appendChild(o)}})}const Jr=new Set([\"listbox\",\"menu\",\"tree\"]),Qr=Array.from(Jr).map(e=>`[role=\"${e}\"]`).join(\",\"),Zr=[\"dropdown-menu\",\"typeahead\",\"tt-menu\",\"ui-autocomplete\",\"autocomplete-results\",\"autocomplete-list\",\"autocomplete-menu\",\"suggestions\",\"react-select__menu\",\"MuiAutocomplete\",\"mat-autocomplete\",\"v-autocomplete__menu\",\"v-list\",\"mention-list\",\"combobox-list\",\"combobox-listbox\",\"option-list\",\"pac-container\"],eo=['[role=\"option\"]','[role=\"menuitem\"]','[role=\"menuitemradio\"]','[role=\"menuitemcheckbox\"]','[role=\"treeitem\"]',\"li\",\".pac-item\",'[class$=\"-option\"]','[class*=\"-option \"]'],to=/(?:^|\\s)css-[a-z0-9]+-menu(?:\\s|$)/i,no='[class*=\"css-\"][class$=\"-menu\"],[class*=\"css-\"][class*=\"-menu \"]',io=[Qr,no,...Zr.map(e=>`[class*=\"${e}\"]`)].join(\",\");function so(e,t){const n=Array.from(e.querySelectorAll(eo.join(\",\"))).filter(t=>t!==e);return n.some(t)?n:Array.from(e.querySelectorAll(\"a[href], button\"))}function ro(e){return e.classList.contains(\"pac-item\")?Array.from(e.children).filter(e=>!e.classList.contains(\"pac-icon\")).map(e=>(e.textContent||\"\").replace(/\\s+/g,\" \").trim()).filter(Boolean).join(\" \"):(e.textContent||\"\").replace(/\\s+/g,\" \").trim()}function oo(e,t){if(!t.isVisible(e))return!1;const n=e.getAttribute(\"role\"),i=!!n&&Jr.has(n),s=(e.getAttribute(\"class\")||\"\").toLowerCase(),r=!!s&&(Zr.some(e=>s.includes(e.toLowerCase()))||to.test(s));if(!i&&!r)return!1;if(!t.isHidden){const t=e.getBoundingClientRect(),n=t.width*t.height,i=window.innerWidth*window.innerHeight;if(i>0&&n/i>.7)return!1}for(const n of so(e,t.isVisible))if(t.isVisible(n))return!0;return!1}function ao(e,t){const n=new Set,i=[e];e!==document.body&&i.push(document.body);const s=io;for(const e of i){const i=e.querySelectorAll(s);for(const e of Array.from(i)){if(n.has(e))continue;if(!oo(e,t))continue;let i=!1;for(const t of n)if(t.contains(e)){i=!0;break}i||n.add(e)}}return n}function lo(e){const t=e.getAttribute(\"aria-labelledby\");if(t){const e=document.getElementById(t);if(e)return e}if(e.id){const t=CSS.escape(e.id),n=document.querySelector(`[aria-controls=\"${t}\"], [aria-owns=\"${t}\"]`);if(n)return n}return null}function co(e){return(e.textContent||\"\").replace(/\\s+/g,\" \").trim().slice(0,80)}function uo(e){const t=e.parentElement?.closest('tr, li, [role=\"row\"], [role=\"listitem\"], [role=\"option\"], [role=\"treeitem\"]');if(!t)return null;const n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);for(let e=n.nextNode();e;e=n.nextNode()){const t=e.textContent?.trim();if(t)return t.slice(0,80)}return null}function po(e){const t=[];for(let n=e;n!==document.body;){const e=n.parentElement;if(!e)return null;t.push(Array.prototype.indexOf.call(e.children,n)),n=e}return{path:t.reverse(),tag:e.tagName,role:e.getAttribute(\"role\"),text:co(e),rowLabel:uo(e)}}const ho='nav, aside, [role=\"navigation\"], [class*=\"drawer\" i], [class*=\"sidebar\" i], [class*=\"menu\" i]',go='[role=\"menu\"], [class*=\"dropdown-menu\" i], [class*=\"submenu\" i], [class*=\"sub-menu\" i], [class*=\"flyout\" i], [class*=\"fly-out\" i]';function mo(e){return!!e.isConnected&&!Ds(e)}function fo(e){const t=new Set;let n=e;for(let e=0;n&&e<6&&n!==document.body;e++){n.matches(go)&&mo(n)&&t.add(n);for(const e of Array.from(n.children))e instanceof HTMLElement&&e.matches(go)&&mo(e)&&t.add(e);n=n.parentElement}return Array.from(t)}function bo(e){const t=function(e){const t=e.getBoundingClientRect(),n=t.left+t.width/2,i=t.top+t.height/2;return{bubbles:!0,cancelable:!0,view:window,clientX:n,clientY:i,screenX:n+window.screenX,screenY:i+window.screenY}}(e);e.dispatchEvent(new MouseEvent(\"mouseenter\",{...t,bubbles:!1})),e.dispatchEvent(new MouseEvent(\"mouseover\",t)),e.dispatchEvent(new PointerEvent(\"pointerenter\",{...t,bubbles:!1})),e.dispatchEvent(new PointerEvent(\"pointerover\",t)),e.dispatchEvent(new MouseEvent(\"mousemove\",t)),e.dispatchEvent(new PointerEvent(\"pointermove\",t))}function yo(e){const t=e.getBoundingClientRect(),n=t.left-1,i=t.top-1,s={bubbles:!0,cancelable:!0,view:window,clientX:n,clientY:i,screenX:n+window.screenX,screenY:i+window.screenY,relatedTarget:document.body};e.dispatchEvent(new MouseEvent(\"mouseout\",s)),e.dispatchEvent(new MouseEvent(\"mouseleave\",{...s,bubbles:!1})),e.dispatchEvent(new PointerEvent(\"pointerout\",s)),e.dispatchEvent(new PointerEvent(\"pointerleave\",{...s,bubbles:!1}))}function vo(e){for(const t of e)t.isConnected&&yo(t)}function wo(){const e=Array.from(document.querySelectorAll(ho));return e.forEach(bo),e}let xo=!1;function ko(e){xo=e}function So(e){if(!xo)for(const t of e)t.isConnected&&bo(t)}const Co=new Set([\"INPUT\",\"BUTTON\",\"SELECT\",\"TEXTAREA\",\"OPTION\",\"LABEL\"]);function Eo(e){const t=function(e){if(!e)return null;const t=e.match(/rgba?\\(([^)]+)\\)/i);if(!t)return null;const n=t[1].split(/[\\s,/]+/).map(e=>parseFloat(e)).filter(e=>!Number.isNaN(e));return n.length<3?null:{r:n[0],g:n[1],b:n[2],a:n.length>=4?n[3]:1}}(e);if(!t)return!1;if(t.a<.4)return!1;const{h:n,s:i,l:s}=function(e,t,n){const i=e/255,s=t/255,r=n/255,o=Math.max(i,s,r),a=Math.min(i,s,r),l=o-a,c=(o+a)/2;let d=0,u=0;return 0!==l&&(u=c>.5?l/(2-o-a):l/(o+a),d=o===i?(s-r)/l+(s<r?6:0):o===s?(r-i)/l+2:(i-s)/l+4,d*=60),{h:d,s:u,l:c}}(t.r,t.g,t.b);return(n>=345||n<=15)&&i>=.35&&s>=.2&&s<=.72}function Mo(e,t){const n=t(e),i=[[n.borderTopWidth,n.borderTopColor],[n.borderRightWidth,n.borderRightColor],[n.borderBottomWidth,n.borderBottomColor],[n.borderLeftWidth,n.borderLeftColor]];for(const[e,t]of i)if(parseFloat(e)>0&&Eo(t))return!0;if(parseFloat(n.outlineWidth)>0&&Eo(n.outlineColor))return!0;if(n.boxShadow&&\"none\"!==n.boxShadow){const e=n.boxShadow.match(/rgba?\\([^)]*\\)/gi);if(e&&e.some(e=>Eo(e)))return!0}return!1}function Ao(e,t,n,i){const s=0===e.children.length?[e]:Array.from(e.querySelectorAll(\"*\"));for(const e of s){if(i.n++>=200)break;if(e===t||e.children.length>0)continue;if(Co.has(e.tagName))continue;const s=(e.textContent||\"\").replace(/\\s+/g,\" \").trim();if(s.length<2)continue;if(!/[\\p{L}\\p{N}]/u.test(s))continue;const r=n(e);if(\"none\"!==r.display&&\"hidden\"!==r.visibility&&Eo(r.color))return s.length>160?`${s.slice(0,159)}…`:s}}function _o(e,t){let n=!1,i=e;for(let e=0;e<3&&i;e++){if(Mo(i,t)){n=!0;break}i=i.parentElement}const s=function(e,t){const n={n:0};let i=e;for(let s=0;s<=6&&i&&n.n<200;s++){let s=i.nextElementSibling;for(;s&&n.n<200;){const i=Ao(s,e,t,n);if(i)return i;s=s.nextElementSibling}i=i.parentElement}}(e,t);return{invalid:n||!!s,message:s}}const To=new Map,Io=new Map,Lo=new Map,Ro=new Map;const $o={},No='input:not([type=\"hidden\"]):not([disabled]):not([type=\"checkbox\"]):not([type=\"radio\"]):not([aria-hidden=\"true\"]), textarea:not([disabled]):not([aria-hidden=\"true\"])',Po=`${No}, select:not([disabled]):not([aria-hidden=\"true\"])`;function Fo(e){return\"readOnly\"in e&&!0===e.readOnly||e.hasAttribute(\"readonly\")||\"true\"===e.getAttribute(\"aria-readonly\")}function Oo(e){const t=To.get(e);if(!t)return null;if(t.isConnected)return t;const n=Ro.get(e),i=n?function(e){if(null===e.rowLabel&&!e.text)return null;let t=document.body;for(const n of e.path)if(t=t.children[n],!t)return null;return t.tagName!==e.tag||t.getAttribute(\"role\")!==e.role||co(t)!==e.text||null!==e.rowLabel&&uo(t)!==e.rowLabel?null:t}(n):null;return i?(To.set(e,i),Io.delete(t),Io.set(i,e),i):null}class qo{constructor(){this.includeHtml=!1,this.twinRegistry=[],this.parentIdByElement=new WeakMap,this.nextParentId=0,this.selectorUniquenessCache=new Map,this.openDropdowns=new Set,this.styleCache=null,this.visibilityCache=null,this.chainOpaqueCache=null,this.rectCache=null,this.visEnv=null,this.tableGridCache=null,this.ancestorLabelCache=null,this.capturedElements=new Set,this.hoverAffordanceMatchSet=new Set}analyze(e={}){const{include_forms:t=!0,include_buttons:n=!0,include_links:i=!0,include_tables:s=!1,include_html:r=!1,focus_container:o}=e;this.includeHtml=r,this.resetCaptureState(),Yr(e=>this.extractSemanticDataAttrList(e));try{const e=o?this.findContainer(o):document.body;if(this.openDropdowns=e?ao(e,{isVisible:e=>this.isVisible(e),isHidden:Ps()}):new Set,!e)return{schema_version:3,url:fr(),title:document.title,active_modal:null,forms:[],buttons:[],links:[],tables:[],inputs:[],selects:[],containers:[],notifications:[]};const r={schema_version:3,url:fr(),title:document.title,active_modal:this.detectActiveModal(e),forms:t?this.detectForms(e):[],buttons:n?this.detectButtons(e):[],links:i?this.detectLinks(e):[],tables:s?this.detectTables(e):[],inputs:this.detectStandaloneInputs(e),selects:this.detectSelects(e),containers:this.detectContainers(e),notifications:this.detectNotifications(e)};return this.populateStructuralTwins(),r.html_snapshot=this.buildHtmlSnapshot(r),r}finally{this.styleCache=null,this.visibilityCache=null,this.chainOpaqueCache=null,this.rectCache=null,this.visEnv=null,this.tableGridCache=null,this.ancestorLabelCache=null}}buildHtmlSnapshot(e){const t=(e,t)=>e.length>t?e.slice(0,t-1)+\"…\":e,n=(e,n=60)=>t((e=>e.replace(/\\s+/g,\" \").replace(/\"/g,\"'\"))(e),n),i=e=>{const t=[];for(const[i,s,r]of e)void 0!==s&&!1!==s&&\"\"!==s&&null!==s&&t.push(!0===s?i:`${i}=${n(String(s),r)}`);return t.length?\" \"+t.join(\" \"):\"\"},s=e=>{if(!e||!e.length)return;const n=e.map(e=>t(e.trim(),40));return t(n.join(\">\"),120)},r=[],o=new Map,a=e=>Lo.get(e)??To.get(e)??null,l=new Map;{const t=new Map,n=e=>{const n=To.get(e);n&&t.set(n,e)};for(const t of e.buttons)n(t.agent_id);for(const t of e.links)n(t.agent_id);for(const t of e.inputs)n(t.agent_id);for(const t of e.selects)n(t.agent_id);for(const e of t.keys())for(let n=e.parentElement;n;n=n.parentElement){const e=t.get(n);if(void 0!==e){l.set(e,(l.get(e)??0)+1);break}}}for(const n of e.buttons){if(!n.visible)continue;const e=(n.text||\"\").trim();if(\"generic\"===n.role&&!e&&!n.icon_description)continue;const s=n.structural_twins?.length??0,c=l.get(n.agent_id)??0,d=void 0!==n.checked&&0===c&&n.icon_description&&sr(n.icon_description)?void 0:n.icon_description,u=d&&(!e||e===d),p=u?\"\":e,h=u||d&&e!==d?d:void 0,g=n.role&&\"button\"!==n.role&&\"generic\"!==n.role?n.role:void 0,m=s>0?`${Math.round(n.bounding_box.x)},${Math.round(n.bounding_box.y)}`:void 0,f=i([[\"role\",g],[\"disabled\",n.disabled],[\"aria-expanded\",void 0===n.expanded?void 0:String(n.expanded)],[\"checked\",void 0===n.checked||c>0?void 0:String(n.checked)],[\"aria-haspopup\",n.has_popup],[\"submenu\",n.has_submenu?\"hover\":void 0],[\"icon\",h],[\"contains\",c>0?c:void 0],[\"twins\",s>0?s:void 0],[\"pos\",m]]),b=p?`>${t(p,80)}`:\"\",y=a(n.agent_id);r.push({element:y,line:`[${n.agent_id}]<${c>0?\"card\":\"button\"}${f}${b} />`}),y&&n.context_path?.length&&o.set(y,n.context_path)}for(const t of e.inputs){const e=i([[\"type\",t.type],[\"name\",t.name],[\"placeholder\",t.placeholder],[\"value\",t.value],[\"disabled\",t.disabled],[\"readonly\",t.readonly],[\"error\",t.error,200],[\"role\",t.accessibility?.role&&\"textbox\"!==t.accessibility.role?t.accessibility.role:void 0],[\"aria-haspopup\",t.accessibility?.has_popup]]),n=a(t.agent_id);r.push({element:n,line:`[${t.agent_id}]<input${e} />`}),n&&t.context_path?.length&&o.set(n,t.context_path)}for(const n of e.selects){const e=i([[\"name\",n.label],[\"disabled\",n.disabled]]),s=n.current_text?`>${t(n.current_text,40)}`:\"\",l=a(n.agent_id);r.push({element:l,line:`[${n.agent_id}]<select${e}${s} />`}),l&&n.context_path?.length&&o.set(l,n.context_path)}for(const n of e.links){if(!n.visible)continue;const e=(n.text||\"\").trim(),s=i([[\"href\",n.href]]),l=e?`>${t(e,60)}`:\"\",c=a(n.agent_id);r.push({element:c,line:`[${n.agent_id}]<a${s}${l} />`}),c&&n.context_path?.length&&o.set(c,n.context_path)}const c=new Map;for(const t of[...e.buttons,...e.inputs,...e.selects]){const e=To.get(t.agent_id);e&&c.set(e,t.agent_id)}for(const n of e.forms){const e=i([[\"id\",n.html?.id],[\"ctx\",s(n.context_path),120]]),o=[`[${n.agent_id}]<form${e}>`];for(const e of n.fields){const t=To.get(e.agent_id),n=i([[\"type\",e.type],[\"name\",e.name],[\"value\",e.value],[\"placeholder\",e.placeholder],[\"required\",e.required],[\"disabled\",e.disabled],[\"readonly\",e.readonly],[\"error\",e.error,200],[\"label\",e.label&&e.label!==e.placeholder?e.label:void 0],[\"same_as\",t&&c.get(t)],[\"ctx\",s(e.context_path),120]]);o.push(`  [${e.agent_id}]<input${n} />`)}if(n.submit_button){const e=i([[\"disabled\",n.submit_button.disabled]]);o.push(`  <button type=submit${e}>${t(n.submit_button.text,40)} />`)}o.push(\"</form>\"),r.push({element:a(n.agent_id),line:o.join(\"\\n\")})}const d=new Map;for(const e of r)e.element&&d.set(e.element,e.line);const u=this.buildStructuralSnapshot(d,o),p=[`url: ${e.url}`,`title: ${e.title}`];return e.active_modal&&p.push(`modal: ${e.active_modal.title||\"open\"}`),p.concat(u).join(\"\\n\")}buildStructuralSnapshot(e,t){const n=this.walkStructural(document.body,e,t),i=n?this.pruneStructural(n):null,s=i?this.hoistCommonContext(i):null,r=[],o=new Set;s&&this.renderStructural(s,0,r,o,new Set);const a=[];for(const[n,i]of e)o.has(n)||a.push(this.appendCtx(i,t.get(n),new Set));if(a.length>0){r.push(\"--OTHER ELEMENTS--\");for(const e of a)r.push(...e.split(\"\\n\"))}return r}walkStructural(e,t,n){if(gr.has(e.tagName))return null;if(\"true\"===e.getAttribute(\"aria-hidden\"))return null;if(!this.isVisible(e))return null;const i=t.get(e);if(i){const s=n.get(e);if(!this.subtreeHasCapture(e,t))return{kind:\"interactable\",element:e,text:i,ctxSegments:s,children:[]};const r=[];for(const i of Array.from(e.children)){if(!(i instanceof HTMLElement))continue;const e=this.walkStructural(i,t,n);e&&r.push(e)}return{kind:\"container\",element:e,children:[{kind:\"interactable\",element:e,text:i,ctxSegments:s,children:[]},...r]}}if(mr.has(e.tagName)){const t=(e.textContent||\"\").trim();return t?{kind:\"heading\",element:e,text:t,headingLevel:parseInt(e.tagName[1],10),children:[]}:null}if(\"TABLE\"===e.tagName){if(!this.tableContainsInteractables(e,t))return{kind:\"table\",element:e,text:Fr(e),children:[]}}const s=[];for(const i of Array.from(e.children)){if(!(i instanceof HTMLElement))continue;const e=this.walkStructural(i,t,n);e&&s.push(e)}const r=Br(e);if(Lr.has(e.tagName)){if(0===s.length&&!r)return null;const t=e.getAttribute(\"aria-label\");return{kind:\"landmark\",element:e,label:t||e.tagName.toLowerCase(),children:this.prependDirectText(r,e,s)}}const o=e.getAttribute(\"role\");if(\"dialog\"===o||\"alertdialog\"===o||\"true\"===e.getAttribute(\"aria-modal\")||\"DIALOG\"===e.tagName){if(0===s.length&&!r)return null;const t=e.getAttribute(\"aria-label\");return{kind:\"dialog\",element:e,label:t||void 0,children:this.prependDirectText(r,e,s)}}if(this.openDropdowns.has(e)&&s.length>0){const t=function(e){const t=e=>(e||\"\").replace(/\\s+/g,\" \").trim(),n=e=>{const n=t(e?.textContent);return n&&n.length<=40?n:\"\"},i=t(e.getAttribute(\"aria-label\"));if(i)return(s=i).length>40?s.substring(0,40):s;var s;const r=n(lo(e));if(r)return r;const o=e.previousElementSibling;if(o&&o.matches('button, a, [role=\"button\"], [data-toggle], [data-bs-toggle]')){const e=n(o);if(e)return e}const a=e.parentElement?.querySelector(':scope > button, :scope > a, :scope > [role=\"button\"]');if(a&&a!==e){const e=n(a);if(e)return e}return\"\"}(e)||\"open dropdown\";return{kind:\"group\",element:e,label:t,labelSegments:[t],children:this.prependDirectText(r,e,s)}}const a=this.getAncestorLabel(e);if(a&&(s.length>0||r)){const t=this.extractSemanticDataAttrList(e);let n=t.length&&t.join(\" \")===a?t:[a];if(!t.length&&(\"TD\"===e.tagName||\"TH\"===e.tagName)){const t=this.resolveColumnHeaderSegments(e);t.length>1&&(n=t)}return{kind:\"group\",element:e,label:a,labelSegments:n,children:this.prependDirectText(r,e,s)}}return r&&0===s.length?{kind:\"text\",element:e,text:r,children:[]}:0!==s.length||r?{kind:\"container\",element:e,children:this.prependDirectText(r,e,s)}:null}tableContainsInteractables(e,t){return this.subtreeHasCapture(e,t)}subtreeHasCapture(e,t){if(0===t.size)return!1;const n=e.querySelectorAll(\"*\");for(let e=0;e<n.length;e++){const i=n[e];if(i instanceof HTMLElement&&t.has(i))return!0}return!1}prependDirectText(e,t,n){return e?[{kind:\"text\",element:t,text:e,children:[]},...n]:n}pruneStructural(e){if(e.children=e.children.map(e=>this.pruneStructural(e)).filter(e=>null!==e),\"container\"===e.kind){if(0===e.children.length)return null;if(1===e.children.length)return e.children[0]}return e}hoistCommonContext(e){return e.children=e.children.map(e=>this.hoistCommonContext(e)),e.children=this.mergeSiblingGroups(e.children),e}mergeSiblingGroups(e){const t=[];let n=0;for(;n<e.length;){if(!this.isMergeableGroup(e[n])){t.push(e[n]),n++;continue}let i=n+1;for(;i<e.length&&this.isMergeableGroup(e[i]);)i++;const s=e.slice(n,i),r=s.length>=2?this.commonLabelSegments(s):[];if(r.length){const e={kind:\"group\",element:s[0].element,label:r.join(\" \"),labelSegments:r,children:[]};for(const t of s){const n=(t.labelSegments??[]).filter(e=>!r.includes(e));for(const i of t.children){if(\"interactable\"===i.kind&&n.length){const e=i.ctxSegments??[];i.ctxSegments=[...n.filter(t=>!e.includes(t)),...e]}e.children.push(i)}}t.push(e)}else for(const e of s)t.push(e);n=i}return t}isMergeableGroup(e){return!(\"group\"!==e.kind||!e.labelSegments?.length)&&e.children.every(e=>\"interactable\"===e.kind||\"text\"===e.kind)}commonLabelSegments(e){return(e[0].labelSegments??[]).filter(t=>e.every(e=>(e.labelSegments??[]).includes(t)))}appendCtx(e,t,n){if(!t?.length)return e;const i=t.filter(e=>!n.has(e));if(!i.length)return e;const s=(e,t)=>e.length>t?e.slice(0,t-1)+\"…\":e,r=`ctx=${s(i.map(e=>s(e.trim(),40)).join(\">\"),120)}`;return e.endsWith(\" />\")?`${e.slice(0,-3)} ${r} />`:`${e} ${r}`}renderStructural(e,t,n,i,s){const r=\"  \".repeat(t);let o=\"\",a=t,l=s;switch(e.kind){case\"interactable\":o=this.appendCtx(e.text||\"\",e.ctxSegments,s).split(\"\\n\").map(e=>r+e).join(\"\\n\"),i.add(e.element);break;case\"heading\":o=`${r}${\"#\".repeat(e.headingLevel||1)} ${e.text}`,a=t+1;break;case\"landmark\":o=`${r}[${e.label}]`,a=t+1;break;case\"dialog\":o=e.label?`${r}[dialog] ${e.label}`:`${r}[dialog]`,a=t+1;break;case\"group\":{const n=e.labelSegments??(e.label?[e.label]:[]),i=n.filter(e=>!s.has(e)).join(\" \");i&&(o=`${r}[group] ${i}`,a=t+1),n.length&&(l=new Set([...s,...n]));break}case\"table\":case\"text\":o=`${r}${e.text}`}o&&n.push(o);for(const t of e.children)this.renderStructural(t,a,n,i,l)}resetCaptureState(){this.twinRegistry=[],this.parentIdByElement=new WeakMap,this.nextParentId=0,this.selectorUniquenessCache=new Map,this.capturedElements=new Set,this.styleCache=new Map,this.visibilityCache=new Map,this.chainOpaqueCache=new Map,this.rectCache=new Map,this.visEnv={style:e=>this.cs(e),rect:e=>this.rect(e),noLayout:Ps(),frozen:Fs(),chainOpaqueCache:this.chainOpaqueCache},this.tableGridCache=new Map,this.ancestorLabelCache=new Map,this.collectHoverAffordanceSelectors(),To.clear(),Io.clear(),Lo.clear(),Ro.clear()}nextAgentId(e){const t=$o[e]??0;return $o[e]=t+1,`${e}-${t}`}parentIdOf(e){if(!e)return\"root\";const t=this.parentIdByElement.get(e);if(void 0!==t)return`p${t}`;const n=this.nextParentId++;return this.parentIdByElement.set(e,n),`p${n}`}decorateEntry(e,t,n,i=\"\"){const s=this.nextAgentId(e),r={...n,agent_id:s,bounding_box:this.computeBoundingBox(t),accessibility:this.computeAccessibility(t)};To.set(s,t),Io.set(t,s);const o=this.computeStructuralSignature(t,e,i);return this.twinRegistry.push({signature:o,entry:r}),r}computeBoundingBox(e){const t=this.rect(e),n=window.innerWidth,i=window.innerHeight,s=t.width>0&&t.height>0&&t.bottom>0&&t.top<i&&t.right>0&&t.left<n;return{x:Math.round(t.left),y:Math.round(t.top),w:Math.round(t.width),h:Math.round(t.height),in_viewport:s}}computeAccessibility(e){let t=\"\",n=null,i=null;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&!e.getAttribute(\"role\")){const s=e.closest('[role=\"combobox\"], [role=\"searchbox\"], [role=\"listbox\"], [role=\"spinbutton\"], [role=\"switch\"]');s&&s!==e&&(t=s.getAttribute(\"role\")||\"\",n=s.getAttribute(\"aria-haspopup\"),i=s.getAttribute(\"aria-expanded\"))}if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||t||e.getAttribute(\"role\"))){const s=e.querySelector('input[role=\"combobox\"], input[role=\"searchbox\"], input[role=\"listbox\"], input[aria-haspopup]');s&&(t=s.getAttribute(\"role\")||t,n||(n=s.getAttribute(\"aria-haspopup\")),i||(i=s.getAttribute(\"aria-expanded\")))}const s={role:e.getAttribute(\"role\")||t||this.implicitRole(e)||\"\",name:e.getAttribute(\"aria-label\")||this.textFromLabelledBy(e)||(e instanceof HTMLElement?this.findLabel(e):\"\")||this.getElementText(e)};e instanceof HTMLInputElement?\"checkbox\"===e.type||\"radio\"===e.type?s.checked=cr(e):s.value=e.value:e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement?s.value=e.value:e.isContentEditable&&(s.value=(e.textContent||\"\").trim());const r=e.getAttribute(\"aria-expanded\")??i??Ir(e,\"aria-expanded\");null!==r&&(s.expanded=\"true\"===r),Cr(e)&&(s.disabled=!0);const o=e.getAttribute(\"aria-haspopup\")??n??Ir(e,\"aria-haspopup\");return o&&\"false\"!==o&&(s.has_popup=\"true\"===o?\"menu\":o),s}implicitRole(e){const t=e.tagName.toLowerCase();if(\"button\"===t)return\"button\";if(\"a\"===t&&e.hasAttribute(\"href\"))return\"link\";if(\"select\"===t)return\"listbox\";if(\"textarea\"===t)return\"textbox\";if(\"form\"===t)return\"form\";if(\"nav\"===t)return\"navigation\";if(\"main\"===t)return\"main\";if(\"input\"===t){const t=e.type;return\"checkbox\"===t?\"checkbox\":\"radio\"===t?\"radio\":\"button\"===t||\"submit\"===t||\"reset\"===t?\"button\":\"search\"===t?\"searchbox\":\"textbox\"}}textFromLabelledBy(e){const t=e.getAttribute(\"aria-labelledby\");if(!t)return;const n=document.getElementById(t);return n?this.getElementText(n):void 0}computeStructuralSignature(e,t,n){return`${t}|${e.tagName.toLowerCase()}|${Array.from(e.classList).sort().join(\",\")}|${n}|${this.parentIdOf(e.parentElement)}`}populateStructuralTwins(){const e=new Map;for(const t of this.twinRegistry){const n=e.get(t.signature);n?n.push(t):e.set(t.signature,[t])}for(const t of e.values()){if(t.length<2)continue;const e=t.map(e=>e.entry.agent_id);for(const n of t)n.entry.structural_twins=e.filter(e=>e!==n.entry.agent_id)}}detectForms(e){const t=e.querySelectorAll('form, [role=\"form\"]'),n=[];return t.forEach(e=>{if(!this.isVisible(e))return;const t=[];if(e.querySelectorAll('input, select, textarea, [contenteditable=\"true\"], [contenteditable=\"\"]').forEach(e=>{if(!(e instanceof HTMLElement))return;if(!this.isVisible(e))return;if(e.hasAttribute(\"contenteditable\")){const n=e.parentElement?.closest('[contenteditable=\"true\"], [contenteditable=\"\"]');if(n&&n!==e)return;const i=e.getAttribute(\"data-placeholder\")||e.getAttribute(\"aria-placeholder\")||e.getAttribute(\"aria-label\")||void 0,s=e.id||e.getAttribute(\"name\")||\"\",r=this.findLabel(e)||i||\"\";return void t.push(this.decorateEntry(\"fld\",e,{name:s||\"contenteditable\",type:\"contenteditable\",label:r,value:e.textContent?.trim()||\"\",required:\"true\"===e.getAttribute(\"aria-required\"),disabled:\"true\"===e.getAttribute(\"aria-disabled\")||\"false\"===e.getAttribute(\"contenteditable\"),placeholder:i,error:this.findValidationError(e),context_path:this.getContextPath(e),html:this.getHTMLContext(e)}))}const n=e;if(n instanceof HTMLInputElement&&(\"hidden\"===n.type||\"submit\"===n.type||\"button\"===n.type))return;const i=n.name||n.id||\"\",s=this.findLabel(n),r=n instanceof HTMLSelectElement?\"select\":n instanceof HTMLTextAreaElement?\"textarea\":n.type||\"text\";let o,a=\"\";n instanceof HTMLSelectElement&&(o=Array.from(n.options).map(e=>({value:e.value,label:e.text||e.value,selected:e.selected})),a=o.map(e=>e.value).join(\"|\"));const l=Cr(n),c=Fo(e),d=this.findValidationError(e);t.push(this.decorateEntry(\"fld\",e,{name:i||`unnamed-${r}`,type:r,label:s,value:String(n instanceof HTMLInputElement&&(\"checkbox\"===n.type||\"radio\"===n.type)?cr(n):n.value),required:n.required||\"true\"===e.getAttribute(\"aria-required\"),disabled:l,...c&&{readonly:c},placeholder:\"placeholder\"in n&&n.placeholder||void 0,options:o,error:d,context_path:this.getContextPath(e),html:this.getHTMLContext(e)},a))}),t.length>0){const i=e instanceof HTMLFormElement?e.action:void 0,s=this.findSubmitButton(e);n.push(this.decorateEntry(\"frm\",e,{id:e.id||void 0,action:i||void 0,context_path:this.getContextPath(e),submit_button:s,fields:t,html:this.getHTMLContext(e)}))}}),n}findSubmitButton(e){const t=['button[type=\"submit\"]','input[type=\"submit\"]',\"button:not([type])\",'[role=\"button\"]'];for(const n of t){const t=e.querySelector(n);if(t&&this.isVisible(t)){return{text:this.getElementText(t)||(t instanceof HTMLInputElement?t.value:\"\")||t.getAttribute(\"aria-label\")||\"Submit\",disabled:Cr(t)}}}const n=e.querySelector('.btn-primary, .button-primary, [class*=\"primary\"]');if(n&&this.isVisible(n)){return{text:this.getElementText(n)||\"Submit\",disabled:Cr(n)}}}findValidationError(e){if(\"true\"===e.getAttribute(\"aria-invalid\")||e.classList.contains(\"error\")||e.classList.contains(\"invalid\")||e.classList.contains(\"is-invalid\"))return this.findAriaOrClassErrorMessage(e)||\"Invalid\";const t=_o(e,e=>this.cs(e));return t.invalid?t.message||\"Invalid\":void 0}findAriaOrClassErrorMessage(e){const t=e.getAttribute(\"aria-describedby\");if(t){const e=t.split(/\\s+/);for(const t of e){const e=document.getElementById(t);if(e){const t=this.getElementText(e);if(t)return t}}}const n=e.getAttribute(\"aria-errormessage\");if(n){const e=document.getElementById(n);if(e){const t=this.getElementText(e);if(t)return t}}const i=[\".error\",\".error-message\",\".invalid-feedback\",\".field-error\",'[class*=\"error\"]','[class*=\"validation\"]','[role=\"alert\"]'];let s=e.nextElementSibling;for(;s;){for(const e of i)if(s.matches(e)){const e=this.getElementText(s);if(e)return e}s=s.nextElementSibling}const r=e.parentElement;if(r)for(const t of i){const n=r.querySelector(t);if(n&&n!==e){const e=this.getElementText(n);if(e)return e}}}detectButtons(e){const t=[],n=this.capturedElements;e.querySelectorAll(\"select.select2-hidden-accessible\").forEach(e=>{if(!(e instanceof HTMLSelectElement))return;const t=this.findReplacedSelectWidget(e);t&&(n.add(t),t.querySelectorAll(\"*\").forEach(e=>n.add(e)))});const i=[\"button\",'input[type=\"button\"]','input[type=\"submit\"]','input[type=\"reset\"]',...[\"button\",\"menuitem\",\"menuitemcheckbox\",\"menuitemradio\",\"option\",\"tab\",\"treeitem\",\"gridcell\",\"switch\",\"radio\",\"checkbox\"].map(e=>`[role=\"${e}\"]`)];this.scanDropdownPortals(n,t);const s=[{selector:\"[tabindex]\"},{selector:\"[onclick]\"},{selector:'[aria-haspopup]:not([aria-haspopup=\"false\"])'},{selector:'[data-toggle=\"dropdown\"]',selfAsserting:!0},{selector:'[data-bs-toggle=\"dropdown\"]',selfAsserting:!0},{selector:\"a\",selfAsserting:!0}];for(const s of i)try{e.querySelectorAll(s).forEach(e=>{n.has(e)||(n.add(e),this.addButtonIfValid(e,t),this.claimSubtree(e,n))})}catch{}for(const{selector:i,selfAsserting:r}of s)try{e.querySelectorAll(i).forEach(e=>{if(n.has(e))return;if(e.matches(\"button, input, select, textarea\"))return;if(e instanceof HTMLAnchorElement&&!xr(e))return;const i=e.getAttribute(\"contenteditable\");if(null!==i&&\"false\"!==i)return;if(this.isContainerRole(e))return;if(!r){const t=e.getAttribute(\"tabindex\");if(null!==t&&parseInt(t,10)<0)return}if(e.querySelector(No))return;if(Tr(e))return;const s=this.getElementText(e)||e.getAttribute(\"aria-label\"),o=s?void 0:this.extractIconLabel(e);(s||o)&&(r||this.isLikelyClickable(e))&&(n.add(e),this.addButtonIfValid(e,t,!0),this.claimSubtree(e,n))})}catch{}e.querySelectorAll(\"a[href]\").forEach(e=>{xr(e)||this.claimSubtree(e,n)});const r=e.querySelectorAll(\"*\"),o=new Set,a=new Set;return r.forEach(e=>{if(e instanceof HTMLElement&&(this.hasPointerAffordance(e)||Vr(e))){o.add(e);for(let t=e.parentElement;t&&!a.has(t);t=t.parentElement)a.add(t)}}),r.forEach(e=>{if(n.has(e))return;if(!(e instanceof HTMLElement))return;if(e.matches(\"button, input, select, textarea, a[href]\"))return;if(e.isContentEditable||\"true\"===e.getAttribute(\"contenteditable\"))return;if(this.isContainerRole(e))return;const i=o.has(e),s=\"none\"===this.cs(e).userSelect;if(!i&&!s)return;if(!this.isVisible(e))return;if(!i&&s&&a.has(e))return;if(e.querySelector(No))return;if(Tr(e))return;const r=this.getElementText(e)||e.getAttribute(\"aria-label\"),l=r?void 0:this.extractIconLabel(e);if(!r&&!l)return;const c=this.findContentRoot(e);n.add(e),n.add(c),this.claimSubtree(e,n),this.addButtonIfValid(c,t,!0)}),this.detectSvgClickables(e,n,t),t}claimSubtree(e,t){const n=e.matches(\"button\");e.querySelectorAll(\"*\").forEach(e=>{e.matches(`input[type=\"checkbox\"], input[type=\"radio\"], ${Po}`)||e.matches('button, input[type=\"button\"], input[type=\"submit\"], input[type=\"reset\"], [role=\"button\"], [role=\"switch\"], [role=\"checkbox\"], [role=\"radio\"], [role=\"tab\"], [role=\"option\"], [role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"], [role=\"treeitem\"], [role=\"gridcell\"]')||Vr(e)||!n&&yr(e,e=>this.cs(e))||t.add(e)})}detectSvgClickables(e,t,n){const i=new Set;e.querySelectorAll(qo.SVG_SHAPE_SELECTOR).forEach(e=>{if(!(e instanceof SVGElement))return;if(t.has(e))return;if(!this.hasPointerAffordance(e))return;if(!this.isVisible(e))return;if(!this.svgOwnName(e))return;const{context:s,owner:r}=this.svgContext(e);s&&r instanceof SVGElement&&!i.has(r)&&this.isVisible(r)&&(i.add(r),this.addButtonIfValid(this.wholeShapeFor(r)??r,n,!0,s)),t.add(e),this.addButtonIfValid(e,n,!0)})}wholeShapeFor(e){const t=e.id;if(!t)return null;const n=e.ownerSVGElement??e.closest(\"svg\");if(!n)return null;let i=null;for(const s of Array.from(n.querySelectorAll(\"g[id]\")))s.id&&s!==e&&(s.contains(e)||e.contains(s)||t.includes(s.id)&&(i&&i.id.length>=s.id.length||this.isVisible(s)&&this.hasPointerAffordance(s)&&(i=s)));return i}ownsNestedControls(e){return!!e.querySelector('button, a[href], input, select, textarea, [role=\"button\"]')}getTextOutsideNestedControls(e){const t=n=>n.nodeType===Node.TEXT_NODE?n.nodeValue??\"\":n instanceof Element?zs.has(n.tagName)||\"true\"===n.getAttribute(\"aria-hidden\")||n!==e&&(n.matches('button, a[href], input, select, textarea, [role=\"button\"], [role=\"switch\"], [role=\"checkbox\"]')||n.matches('[data-testid=\"toggle-switch\"]'))?\"\":Array.from(n.childNodes).map(t).filter(Boolean).join(\" \"):\"\";return t(e).trim().replace(/\\s+/g,\" \")}svgOwnName(e){return(e.querySelector(\":scope > title\")?.textContent||e.getAttribute(\"aria-label\")||e.textContent||\"\").trim().replace(/\\s+/g,\" \")}svgContext(e){for(let t=e.parentElement;t&&\"svg\"!==t.tagName.toLowerCase();t=t.parentElement){const e=t.querySelector(\"text\")?.textContent?.trim().replace(/\\s+/g,\" \");if(e)return{context:e,owner:t}}return{context:\"\",owner:null}}svgClickableLabel(e){const t=this.svgOwnName(e);if(!t)return\"\";const{context:n}=this.svgContext(e);return n&&!t.includes(n)?`${n} ${t}`:t}findContentRoot(e){const t=(e.textContent||\"\").trim();if(!t)return e;let n=e;for(;;){const e=Array.from(n.children).filter(e=>e instanceof HTMLElement&&!!(e.textContent||\"\").trim());if(1!==e.length)break;const i=e[0];if((i.textContent||\"\").trim()!==t)break;n=i}return n}isLikelyClickable(e){if(!(e instanceof HTMLElement))return!1;const t=e.getAttribute(\"role\");if(t&&this.isInteractiveRole(t))return!0;if(e.hasAttribute(\"tabindex\"))return!0;if(this.hasPointerAffordance(e))return!0;if(e.hasAttribute(\"onclick\"))return!0;const n=e.getAttribute(\"aria-haspopup\");if(n&&\"false\"!==n)return!0;const i=e.parentElement?.closest('[role=\"menu\"], [role=\"listbox\"], [role=\"tree\"], [role=\"tablist\"], [role=\"dialog\"], [role=\"alertdialog\"]');return!!i}hasPointerAffordance(e){return!!br(this.cs(e).cursor)||this.matchesHoverAffordance(e)}static hoverAffordance(e){return\"pointer\"===e.cursor||\"grab\"===e.cursor||\"grabbing\"===e.cursor||!!(e.opacity||e.filter||e.transform)}collectHoverAffordanceSelectors(){const e=new Set,t=n=>{for(let i=0;i<n.length;i++){const s=n[i];if(s instanceof CSSStyleRule){if(!qo.hoverAffordance(s.style))continue;if(!s.selectorText.includes(\":hover\"))continue;for(const t of s.selectorText.split(\",\")){const n=t.trim();if(!n.includes(\":hover\"))continue;if(/[\\s>+~]/.test(n.slice(n.lastIndexOf(\":hover\")+6)))continue;const i=n.replace(/:hover\\b/g,\"\").trim();i&&e.add(i)}}else s instanceof CSSGroupingRule&&t(s.cssRules)}};for(const e of Array.from(document.styleSheets))try{t(e.cssRules)}catch{}const n=document.createElement(\"div\"),i=[];for(const t of e)try{n.matches(t),i.push(t)}catch{}if(this.hoverAffordanceMatchSet=new Set,i.length)try{document.querySelectorAll(i.join(\",\")).forEach(e=>this.hoverAffordanceMatchSet.add(e))}catch{for(const e of i)try{document.querySelectorAll(e).forEach(e=>this.hoverAffordanceMatchSet.add(e))}catch{}}}matchesHoverAffordance(e){return this.hoverAffordanceMatchSet.has(e)}isContainerRole(e){const t=e.getAttribute(\"role\");return\"listbox\"===t||\"menu\"===t||\"menubar\"===t||\"grid\"===t||\"tree\"===t||\"tablist\"===t||\"dialog\"===t||\"alertdialog\"===t||\"tabpanel\"===t}isInteractiveRole(e){return new Set([\"button\",\"link\",\"menuitem\",\"menuitemcheckbox\",\"menuitemradio\",\"option\",\"tab\",\"treeitem\",\"gridcell\",\"switch\",\"radio\",\"checkbox\",\"slider\",\"spinbutton\",\"searchbox\",\"textbox\",\"combobox\"]).has(e)}extractIconLabel(e){return er(e)}findAssociatedLabel(e){const t=e.getAttribute(\"aria-labelledby\");if(t){const e=document.getElementById(t);if(e){const t=this.getElementText(e);if(t)return t}}const n=e.previousElementSibling;if(n){const e=this.getElementText(n);if(e&&e.length<50)return e}const i=e.nextElementSibling;if(i){const e=this.getElementText(i);if(e&&e.length<50)return e}const s=e.parentElement;if(s){const e=s.cloneNode(!0),t=e.querySelector('button, [role=\"button\"], input[type=\"button\"]');t&&os(t);const n=this.getElementText(e);if(n&&n.length<50)return n}}addButtonIfValid(e,t,n=!1,i){let s=i??(e.classList.contains(\"pac-item\")?ro(e):e instanceof SVGElement?this.svgClickableLabel(e):\"button\"===e.getAttribute(\"role\")&&e.querySelector('[role=\"button\"]')&&this.getTextOutsideNestedControls(e)||this.getElementText(e)||(e instanceof HTMLInputElement?e.value:\"\")||e.getAttribute(\"aria-label\")||Ir(e,\"aria-label\")||\"\");const r=this.ownsNestedControls(e)?void 0:this.extractIconLabel(e)||void 0;if(!s&&!r&&e instanceof HTMLElement){const t=e.getAttribute(\"aria-haspopup\");t&&\"false\"!==t&&(s=\"menu\"===t?\"Menu\":\"dialog\"===t?\"Dialog\":\"listbox\"===t?\"Options\":\"More options\")}!s&&!r&&e instanceof HTMLElement&&(s=this.findAssociatedLabel(e)||\"\");const o=Cr(e),a=this.isVisible(e),l=e.getAttribute(\"role\")||void 0,c=e.getAttribute(\"aria-haspopup\")??Ir(e,\"aria-haspopup\"),d=Nr(e),u=e.tagName.toLowerCase();let p;p=\"button\"===u?e.type||\"button\":\"input\"===u?e.type:u;const h={...s&&{text:s},type:p,disabled:o,visible:a,...r&&{icon_description:r},context_path:this.getContextPath(e),html:this.getHTMLContext(e)};l?h.role=l:n&&\"button\"!==u&&\"input\"!==u&&(h.role=\"generic\"),c&&\"false\"!==c&&(h.has_popup=\"true\"===c?\"menu\":c),null!==d&&(h.expanded=\"true\"===d);const g=ur(e);null!==g&&(h.checked=g),e instanceof HTMLElement&&function(e){let t=e.parentElement;for(;t&&t!==document.body;){if(t.matches('[role=\"menu\"], [role=\"menubar\"], [class*=\"dropdown-menu\" i], [class*=\"submenu\" i], [class*=\"sub-menu\" i]')&&!mo(t))return!0;t=t.parentElement}return!1}(e)&&fo(e).some(t=>!t.contains(e))&&(h.has_submenu=!0),t.push(this.decorateEntry(\"btn\",e,h))}scanDropdownPortals(e,t){const n=['[class*=\"__menu\"]:not([class*=\"__menu-\"]):has([role=\"listbox\"])','[class*=\"__menu-list\"]',no,'[role=\"listbox\"]','[role=\"menu\"]',\"[data-radix-popper-content-wrapper]\",\"[data-headlessui-state]\",'[class*=\"MuiPopper\"]','[class*=\"MuiMenu-list\"]',\"[data-reach-menu-list]\",\"[data-downshift-menu]\",\".pac-container\"];for(const i of n)try{document.body.querySelectorAll(i).forEach(n=>{if(!(n instanceof HTMLElement))return;if(!this.isVisible(n))return;n.querySelectorAll('[role=\"option\"], [role=\"menuitem\"], [class*=\"__option\"], [class$=\"-option\"], [class*=\"-option \"], .pac-item').forEach(n=>{e.has(n)||(e.add(n),this.addButtonIfValid(n,t),n.querySelectorAll(\"*\").forEach(t=>e.add(t)))})})}catch{}}detectLinks(e){const t=e.querySelectorAll('a[href], [role=\"link\"]'),n=[];return t.forEach(e=>{let t=this.getElementText(e);if(!t){const n=e.querySelector('span, label, [class*=\"label\"], [class*=\"text\"]');n&&(t=this.getElementText(n))}if(t||(t=e.getAttribute(\"aria-label\")||e.getAttribute(\"title\")||\"\"),!t)return;const i=e.getAttribute(\"href\")||\"\";xr(e)||n.push(this.decorateEntry(\"lnk\",e,{text:t,href:i,visible:this.isVisible(e),context_path:this.getContextPath(e),html:this.getHTMLContext(e)}))}),n}detectStandaloneInputs(e){const t=[],n=this.capturedElements;this.detectEditableElements(e,n,t);return e.querySelectorAll(\"input, select, textarea\").forEach(e=>{if(!(e instanceof HTMLElement))return;if(!this.isVisible(e))return;if(n.has(e))return;if(e.closest('form, [role=\"form\"]'))return;n.add(e);const i=e;if(i instanceof HTMLInputElement&&(\"hidden\"===i.type||\"submit\"===i.type||\"button\"===i.type))return;const s=i.name||i.id||\"\",r=this.findLabel(i),o=i instanceof HTMLSelectElement?Array.from(i.options).map(e=>e.value).join(\"|\"):\"\",a=Cr(i)||Cr(e),l=Fo(e),c=this.findValidationError(e);t.push(this.decorateEntry(\"inp\",e,{name:s||`unnamed-${i.type||\"input\"}`,type:i instanceof HTMLSelectElement?\"select\":i instanceof HTMLTextAreaElement?\"textarea\":i.type||\"text\",label:r||void 0,placeholder:\"placeholder\"in i&&i.placeholder||void 0,value:String(i instanceof HTMLInputElement&&(\"checkbox\"===i.type||\"radio\"===i.type)?cr(i):i.value),...a&&{disabled:a},...l&&{readonly:l},...c&&{error:c},context_path:this.getContextPath(e),html:this.getHTMLContext(e)},o))}),this.detectCustomToggles(e,t),t}detectCustomToggles(e,t){const n=this.capturedElements;e.querySelectorAll('input[type=\"checkbox\"], input[type=\"radio\"]').forEach(e=>{if(!(e instanceof HTMLInputElement))return;if(n.has(e))return;if(this.isVisible(e))return;const i=Array.from(e.labels??[]).find(e=>this.isVisible(e));if(!i)return;n.add(e),n.add(i);const s=e.name||e.id||\"\",r=this.findLabel(e),o=this.decorateEntry(\"inp\",e,{name:s||`unnamed-${e.type}`,type:e.type,label:r&&r!==s?r:void 0,value:String(cr(e)),context_path:this.getContextPath(e),html:this.getHTMLContext(e)});Lo.set(o.agent_id,i),o.bounding_box=this.computeBoundingBox(i),t.push(o)})}detectSelects(e){const t=[];return e.querySelectorAll(\"select\").forEach(e=>{if(!(e instanceof HTMLSelectElement))return;const n=this.findReplacedSelectWidget(e),i=n??e;if(!this.isVisible(i))return;const s=this.findLabel(e),r=e.options[e.selectedIndex],o=Array.from(e.options).map(e=>({value:e.value,text:e.textContent?.trim()||e.value,selected:e.selected,disabled:e.disabled||void 0})),a=o.map(e=>e.value).join(\"|\"),l=this.decorateEntry(\"sel\",e,{label:s||void 0,current_value:e.value,current_text:r?.textContent?.trim()||\"\",options:o,disabled:Cr(e),context_path:this.getContextPath(i),html:this.getHTMLContext(e)},a);n&&(Lo.set(l.agent_id,n),l.bounding_box=this.computeBoundingBox(n)),t.push(l)}),t}findReplacedSelectWidget(e){if(!e.classList.contains(\"select2-hidden-accessible\"))return null;const t=e.nextElementSibling;return t instanceof HTMLElement&&t.classList.contains(\"select2-container\")?t:null}detectEditableElements(e,t,n){e.querySelectorAll(\"*\").forEach(e=>{if(!(e instanceof HTMLElement))return;if(t.has(e))return;if(e.matches(\"input, select, textarea\"))return;if(\"true\"===e.getAttribute(\"aria-hidden\"))return;if(e.closest('[aria-hidden=\"true\"]'))return;if(e.closest('form, [role=\"form\"]'))return;if(this.isContainerRole(e))return;const i=this.isEditableElement(e),s=e.querySelector('input[role=\"combobox\"], input[role=\"searchbox\"], input[role=\"listbox\"], input[aria-haspopup]'),r=this.cs(e),o=!!s&&\"pointer\"===r.cursor&&(this.getElementText(e).length>0||e.getAttribute(\"aria-label\")||this.extractIconLabel(e));if(!i&&!o)return;if(this.hasEditableAncestor(e))return;if(\"none\"===r.display||\"hidden\"===r.visibility)return;t.add(e),e.querySelectorAll(\"*\").forEach(e=>t.add(e));const a=this.findEditablePlaceholder(e),l=e.id||e.getAttribute(\"name\")||e.getAttribute(\"data-field\")||e.getAttribute(\"data-name\")||\"\",c=this.findLabel(e)||a,d=this.getEditableType(e);n.push(this.decorateEntry(\"inp\",e,{name:l||d,type:d,label:c||void 0,placeholder:a,value:e.textContent?.trim()||\"\",context_path:this.getContextPath(e),html:this.getHTMLContext(e)}))})}isEditableElement(e){const t=e.getAttribute(\"contenteditable\");if(null!==t&&\"false\"!==t)return!0;if(e.isContentEditable)return!0;const n=e.getAttribute(\"role\");if(n&&[\"textbox\",\"searchbox\",\"spinbutton\",\"combobox\"].includes(n))return!0;const i=this.cs(e);if(\"text\"===i.cursor&&(e.tabIndex>=0||e.hasAttribute(\"tabindex\")))return!0;const s=i.getPropertyValue(\"-webkit-user-modify\")||i.getPropertyValue(\"user-modify\");if(s&&\"read-only\"!==s)return!0;const r=[\"data-editable\",\"data-editor\",\"data-input\",\"data-field\",\"data-slate-editor\",\"data-lexical-editor\",\"data-gramm\",\"data-contents\",\"data-block\"];for(const t of r)if(e.hasAttribute(t))return!0;const o=[/editor/i,/editable/i,/contenteditable/i,/prosemirror/i,/tiptap/i,/quill/i,/slate/i,/codemirror/i,/monaco/i,/ace-editor/i,/ql-editor/i,/sun-editor/i,/cke_editable/i,/mce-content-body/i,/fr-element/i];for(const t of o)if(t.test(e.className))return!0;return!1}hasEditableAncestor(e){let t=e.parentElement;for(;t&&t!==document.body;){const e=t.getAttribute(\"contenteditable\");if(null!==e&&\"false\"!==e)return!0;const n=t.getAttribute(\"role\");if(\"textbox\"===n||\"searchbox\"===n)return!0;t=t.parentElement}return!1}findEditablePlaceholder(e){const t=[\"data-placeholder\",\"aria-placeholder\",\"aria-label\",\"placeholder\",\"data-ph\",\"data-empty-text\"];for(const n of t){const t=e.getAttribute(n);if(t)return t}const n=e.querySelector('input:not([type=\"hidden\"]), textarea'),i=n?.getAttribute(\"placeholder\")||n?.getAttribute(\"aria-label\");if(i)return i;const s=e.querySelector('[data-placeholder], .placeholder, [class*=\"placeholder\"], .ProseMirror-placeholder');if(s){const e=s.getAttribute(\"data-placeholder\")||s.textContent?.trim();if(e)return e}const r=e.parentElement?.querySelector('.placeholder, [class*=\"placeholder\"]:not([contenteditable])');if(r&&r!==e){const e=r.textContent?.trim();if(e)return e}}getEditableType(e){const t=e.getAttribute(\"role\");if(\"searchbox\"===t)return\"searchbox\";if(\"spinbutton\"===t)return\"spinbutton\";if(\"combobox\"===t)return\"combobox\";if(\"listbox\"===t)return\"listbox\";const n=e.querySelector(No);if(n){const e=n.getAttribute(\"role\");return\"combobox\"===e||\"listbox\"===e||\"searchbox\"===e?e:\"combobox\"}if(/codemirror|monaco|ace-editor|code-editor/i.test(e.className)||e.closest(\".monaco-editor, .CodeMirror, .ace_editor\"))return\"code-editor\";return/prosemirror|tiptap|quill|slate|ckeditor|tinymce|froala|sun-editor/i.test(e.className)?\"rich-text-editor\":\"contenteditable\"}detectContainers(e){const t=new Set,n=[],i=[{pattern:/\\bcard\\b/i,role:\"card\"},{pattern:/\\bpanel\\b/i,role:\"panel\"},{pattern:/\\bmodal\\b/i,role:\"dialog\"},{pattern:/\\bsheet\\b/i,role:\"panel\"},{pattern:/\\bdrawer\\b/i,role:\"panel\"}],s=(e,i,s)=>{t.has(e)||s&&this.isVisible(e)&&(t.add(e),n.push({element:e,role:i,label:this.truncate(s,120)}))};e.querySelectorAll(\"table\").forEach(e=>{const t=e.querySelector(\":scope > caption\");if(t)return void s(e,\"table\",this.getElementText(t));const n=e.querySelector(\":scope > thead\");if(n){const t=Array.from(n.querySelectorAll(\"th\")).map(e=>this.getElementText(e)).filter(Boolean);t.length>0&&s(e,\"table\",t.join(\" | \"))}});['[role=\"region\"]','[role=\"group\"]','[role=\"tabpanel\"]','[role=\"dialog\"]'].forEach(t=>{e.querySelectorAll(t).forEach(e=>{const t=e.getAttribute(\"role\")||\"\",n=e.getAttribute(\"aria-label\")||this.textFromLabelledBy(e)||\"\";n&&s(e,t,n)})}),e.querySelectorAll(\"section, article\").forEach(e=>{const t=e.getAttribute(\"aria-label\");if(t)return void s(e,e.tagName.toLowerCase(),t);const n=this.textFromLabelledBy(e);if(n)return void s(e,e.tagName.toLowerCase(),n);const i=e.querySelector(\":scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > h5, :scope > h6\");i&&s(e,e.tagName.toLowerCase(),this.getElementText(i))}),e.querySelectorAll(\"[data-testid]\").forEach(e=>{if(!(e instanceof HTMLElement))return;if(e.matches('button, input, select, textarea, a[href], [role=\"button\"], [role=\"link\"]'))return;const t=e.getAttribute(\"data-testid\")||\"\",n=e.getAttribute(\"aria-label\")||t;n&&s(e,\"region\",n)}),e.querySelectorAll(\"div, section, article, aside\").forEach(e=>{if(t.has(e))return;const n=e.getAttribute(\"class\")||\"\";for(const{pattern:t,role:r}of i){if(!t.test(n))continue;const i=e.getAttribute(\"aria-label\")||this.textFromLabelledBy(e)||this.getContainerHeading(e);i&&s(e,r,i);break}});const r=n.map(e=>{const t=this.computeBoundingBox(e.element);return{...e,bbox:t}});return r.sort((e,t)=>e.bbox.in_viewport!==t.bbox.in_viewport?e.bbox.in_viewport?-1:1:0),r.map(e=>this.decorateEntry(\"ctn\",e.element,{label:e.label,role:e.role,tag:e.element.tagName.toLowerCase(),context_path:this.getContextPath(e.element),html:this.getHTMLContext(e.element)}))}getContainerHeading(e){const t=e.querySelector(\":scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > h5, :scope > h6, header\");if(!t)return;return this.getElementText(t)||void 0}truncate(e,t){return e.length<=t?e:e.slice(0,t-1)+\"…\"}detectTables(e){const t=e.querySelectorAll('table, [role=\"table\"], [role=\"grid\"]'),n=[];return t.forEach(e=>{if(!this.isVisible(e))return;let t=[],i=0;if(\"TABLE\"===e.tagName){const n=e,s=n.querySelectorAll(\"thead th, thead td, tr:first-child th\");t=Array.from(s).map(e=>this.getElementText(e)).filter(Boolean);i=n.querySelectorAll(\"tbody tr, tr\").length,n.querySelector(\"tbody tr th, tr:first-child th\")&&(i=Math.max(0,i-1))}else{const n=e.querySelectorAll('[role=\"columnheader\"], [role=\"rowheader\"]');t=Array.from(n).map(e=>this.getElementText(e)).filter(Boolean);const s=e.querySelectorAll('[role=\"row\"]');i=Math.max(0,s.length-(t.length>0?1:0))}const s=e.id||e.getAttribute(\"aria-label\")||e.closest(\"[id]\")?.id||void 0;n.push({headers:t,row_count:i,container:s})}),n}detectActiveModal(e){const t=['[role=\"dialog\"]:not([aria-hidden=\"true\"])','[role=\"alertdialog\"]:not([aria-hidden=\"true\"])','[aria-modal=\"true\"]:not([aria-hidden=\"true\"])',\"dialog[open]\",\".modal.show\",\".modal.open\",'.modal[style*=\"display: block\"]',\".dialog.open\",'[data-state=\"open\"][role=\"dialog\"]'];for(const n of t)try{const t=e.querySelector(n);if(t&&this.isVisible(t)){const e=this.getModalTitle(t),n=null!==t.querySelector('form, [role=\"form\"]');return{title:e,has_form:n,container:t.id||t.getAttribute(\"aria-labelledby\")||void 0}}}catch{}return this.detectModalByGeometry(e)}detectModalByGeometry(e){const t=window.innerWidth*window.innerHeight;if(0===t)return null;const n=.5*t,i=/rgba?\\([^)]*,\\s*([0-9.]+)\\s*\\)/,s=[];let r=!1;if(e.querySelectorAll(\"*\").forEach(e=>{if(!(e instanceof HTMLElement))return;const t=this.cs(e);if(\"fixed\"!==t.position)return;if(!this.isVisible(e))return;const o=this.rect(e);if(o.width*o.height<n)return;s.push(e);const a=t.backgroundColor.match(i);if(a){const e=parseFloat(a[1]);e>.1&&e<1&&(r=!0)}}),!r||0===s.length)return null;s.sort((e,t)=>{const n=parseInt(this.cs(e).zIndex,10)||0;return(parseInt(this.cs(t).zIndex,10)||0)-n});const o=s[0],a=o.querySelector('button, input, textarea, select, form, a[href], [role=\"button\"], [contenteditable=\"true\"]'),l=this.getElementText(o).length;if(!a&&l<20)return null;return{title:this.getModalTitle(o),has_form:null!==o.querySelector('form, [role=\"form\"]'),container:o.id||o.getAttribute(\"aria-labelledby\")||void 0}}getModalTitle(e){const t=e.getAttribute(\"aria-labelledby\");if(t){const e=document.getElementById(t);if(e)return this.getElementText(e)||void 0}const n=e.getAttribute(\"aria-label\");if(n)return n;const i=['[role=\"heading\"]',\".modal-title\",\".dialog-title\",\"h1\",\"h2\",\"h3\"];for(const t of i){const n=e.querySelector(t);if(n){const e=this.getElementText(n);if(e)return e}}}detectNotifications(e){const t=[],n=['[role=\"alert\"]','[role=\"status\"]',\".toast:not(.hide)\",\".toast.show\",\".notification:not(.hidden)\",\".alert:not(.hidden)\",\"[data-toast]\",\".snackbar:not(.hidden)\"],i=new Set;for(const s of n)try{e.querySelectorAll(s).forEach(e=>{if(i.has(e))return;if(i.add(e),!this.isVisible(e))return;const n=this.getElementText(e);if(!n)return;const s=this.getNotificationType(e);t.push({type:s,message:n})})}catch{}return t}getNotificationType(e){const t=e.classList,n=e.getAttribute(\"role\"),i=e.getAttribute(\"aria-live\");return(t.contains(\"error\")||t.contains(\"danger\")||t.contains(\"alert-error\")||t.contains(\"alert-danger\")||\"alert\"===n)&&!(\"assertive\"!==i&&\"alert\"!==n||t.contains(\"success\")||t.contains(\"alert-success\"))?\"error\":t.contains(\"success\")||t.contains(\"alert-success\")?\"success\":t.contains(\"warning\")||t.contains(\"alert-warning\")?\"warning\":t.contains(\"error\")||t.contains(\"danger\")||t.contains(\"alert-error\")||t.contains(\"alert-danger\")?\"error\":\"info\"}extractSemanticDataAttrs(e){const t=this.extractSemanticDataAttrList(e);return t.length>0?t.join(\" \"):void 0}extractSemanticDataAttrList(e){const t=[];for(const n of Array.from(e.attributes))if(n.name.startsWith(\"data-\")&&this.isSemanticDataAttr(n.name,n.value)&&(t.push(`${n.name.substring(5)}=${n.value}`),t.length>=6))break;return t}nearestSemanticDataAttrs(e){let t=e,n=0;for(;t&&n<4;){const e=this.extractSemanticDataAttrList(t);if(e.length)return e;t=t.parentElement,n++}return[]}isSemanticDataAttr(e,t){if(qo.FRAMEWORK_DATA_ATTR_EXACT.has(e))return!1;for(const t of qo.FRAMEWORK_DATA_ATTR_PREFIXES)if(e.startsWith(t))return!1;if(!t)return!1;if(\"true\"===t||\"false\"===t)return!1;if(t.length>40)return!1;const n=t.charAt(0);return\"{\"!==n&&\"[\"!==n}getContextPath(e){const t=[],n=new Set([\"FORM\",\"MAIN\",\"BODY\"]);let i=e.parentElement;for(;i&&t.length<3&&!n.has(i.tagName);){const e=this.getAncestorLabel(i,!1);e&&!t.includes(e)&&t.push(e),i=i.parentElement}const s=t.reverse();for(const t of this.nearestSemanticDataAttrs(e))s.includes(t)||s.push(t);return s}resolveColumnHeaderSegments(e){const t=e.parentElement;if(!t||\"TR\"!==t.tagName)return[];const n=t.closest(\"table\");if(!n)return[];const{grid:i,colOf:s,headerRows:r,rowCount:o}=this.buildTableGrid(n),a=s.get(e);if(void 0===a)return[];const l=[];for(let t=0;t<o;t++){if(!r.has(t))continue;const n=i[t]?.[a];if(!n||n===e)continue;const s=this.getElementText(n);s&&s.length<=80&&l[l.length-1]!==s&&l.push(s)}return l}buildTableGrid(e){const t=this.tableGridCache?.get(e);if(t)return t;const n=[],i=new Map,s=new Set,r=Array.from(e.rows);for(let e=0;e<r.length;e++){const t=r[e];n[e]||(n[e]=[]),\"THEAD\"===t.parentElement?.tagName&&s.add(e);let o=0;for(const s of Array.from(t.cells)){for(;n[e][o];)o++;const t=s.colSpan||1,r=s.rowSpan||1;for(let i=0;i<r;i++){const r=n[e+i]??(n[e+i]=[]);for(let e=0;e<t;e++)r[o+e]=s}i.set(s,o),o+=t}}const o={grid:n,colOf:i,headerRows:s,rowCount:r.length};return this.tableGridCache?.set(e,o),o}getAncestorLabel(e,t=!0){let n=this.ancestorLabelCache?.get(e);if(n&&n.has(t))return n.get(t);const i=this.computeAncestorLabel(e,t);return this.ancestorLabelCache&&(n||(n=new Map,this.ancestorLabelCache.set(e,n)),n.set(t,i)),i}computeAncestorLabel(e,t=!0){if(\"FIELDSET\"===e.tagName){const t=e.querySelector(\":scope > legend\");if(t){const e=this.getElementText(t);if(e)return e}}const n=e.getAttribute(\"role\");if(\"group\"===n||\"radiogroup\"===n){const t=e.getAttribute(\"aria-label\");if(t)return t;const n=e.getAttribute(\"aria-labelledby\");if(n){const e=document.getElementById(n);if(e){const t=this.getElementText(e);if(t)return t}}}if(\"SECTION\"===e.tagName||\"ARTICLE\"===e.tagName||\"ASIDE\"===e.tagName||\"NAV\"===e.tagName){const t=e.getAttribute(\"aria-label\");if(t)return t;const n=e.getAttribute(\"aria-labelledby\");if(n){const e=document.getElementById(n);if(e){const t=this.getElementText(e);if(t)return t}}}const i=e.querySelector(\":scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > h5, :scope > h6\");if(i){const e=this.getElementText(i);if(e&&e.length<=80)return e}let s=e.querySelector(\":scope > label\");if(!s)for(const t of Array.from(e.children)){if(!(t instanceof HTMLElement)||\"DIV\"!==t.tagName)continue;if(t.querySelector('input, select, textarea, button, a[href], [contenteditable=\"true\"]'))continue;const e=t.querySelector(\":scope > label\");if(e){s=e;break}}if(s){const e=this.getElementText(s);if(e&&e.length<=80)return e}if(\"TR\"===e.tagName){const t=e.querySelector(':scope > th[scope=\"row\"]');if(t){const e=this.getElementText(t);if(e&&e.length<=80)return e}for(const t of Array.from(e.children)){if(\"TH\"!==t.tagName&&\"TD\"!==t.tagName)continue;const e=this.getElementText(t);if(e&&e.length<=80)return e}}if(\"row\"===e.getAttribute(\"role\")){const t=e.querySelector(':scope > [role=\"rowheader\"]');if(t){const e=this.getElementText(t);if(e&&e.length<=80)return e}for(const t of Array.from(e.children)){const e=t.getAttribute(\"role\");if(\"cell\"!==e&&\"gridcell\"!==e)continue;const n=this.getElementText(t);if(n&&n.length<=80)return n}}const r=Er(e)??Mr(e);if(r)return r;if((\"TD\"===e.tagName||\"TH\"===e.tagName)&&\"row\"!==e.getAttribute(\"scope\")){const t=this.resolveColumnHeaderSegments(e);if(t.length)return t.join(\" \")}if(\"cell\"===e.getAttribute(\"role\")||\"gridcell\"===e.getAttribute(\"role\")){const t=e.parentElement;if(t&&\"row\"===t.getAttribute(\"role\")){const n=Array.from(t.children).indexOf(e),i=e.closest('[role=\"table\"], [role=\"grid\"]'),s=i?.querySelectorAll('[role=\"columnheader\"]');if(s&&n>=0&&n<s.length){const e=this.getElementText(s[n]);if(e&&e.length<=80)return e}}}for(const t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;if(Array.from(t.classList).some(e=>qo.BEM_LABEL_SUFFIXES.some(t=>e.endsWith(t)))){const e=this.getElementText(t);if(e&&e.length<=80)return e}}if(new Set([\"ASIDE\",\"NAV\",\"HEADER\",\"FOOTER\",\"MAIN\"]).has(e.tagName))return e.tagName.toLowerCase();const o=this.cs(e).display;if(\"flex\"===o||\"inline-flex\"===o||\"grid\"===o)for(const t of Array.from(e.children)){if(!(t instanceof HTMLElement))continue;const e=this.getElementText(t).trim();if(!e||e.length>20)continue;if(!t.querySelector('input, button, select, textarea, a[href], [role=\"button\"], [role=\"link\"], [role=\"menuitem\"], [role=\"tab\"], [contenteditable=\"true\"]'))return e}const a=e.firstElementChild;if(a instanceof HTMLButtonElement&&a.hasAttribute(\"aria-haspopup\")&&e.children.length>1){const e=this.getElementText(a).trim();if(e&&e.length<=40)return e}if(t){const t=this.extractSemanticDataAttrs(e);if(t)return t}}findContainer(e){const t=document.getElementById(e);if(t)return t;const n=document.querySelector(`.${e}`);if(n instanceof HTMLElement)return n;const i=document.querySelector(`[data-container=\"${e}\"]`);return i instanceof HTMLElement?i:null}findLabel(e){const t=e.getAttribute(\"aria-label\");if(t)return t;const n=e.getAttribute(\"aria-labelledby\");if(n){const e=document.getElementById(n);if(e)return this.getElementText(e)}if(e.id){const t=document.querySelector(`label[for=\"${e.id}\"]`);if(t)return this.getElementText(t)}const i=e.closest(\"label\");if(i){const e=i.cloneNode(!0);return e.querySelectorAll(\"input, select, textarea\").forEach(e=>os(e)),this.getElementText(e)}const s=e.previousElementSibling;if(\"LABEL\"===s?.tagName)return this.getElementText(s);const r=this.findBemSiblingLabel(e);if(r)return r;const o=e.getAttribute(\"placeholder\");return o||(e.getAttribute(\"name\")||\"\")}findBemSiblingLabel(e){let t=e.parentElement;for(let e=0;e<6&&t&&t!==document.body;e++){if(Array.from(t.classList).some(e=>e.includes(\"__\"))&&t.parentElement)for(const e of Array.from(t.parentElement.children)){if(e===t||!(e instanceof HTMLElement))continue;if(Array.from(e.classList).some(e=>qo.BEM_LABEL_SUFFIXES.some(t=>e.endsWith(t)))){const t=this.getElementText(e);if(t&&t.length<=80)return t}}t=t.parentElement}}cs(e){if(!this.styleCache)return window.getComputedStyle(e);let t=this.styleCache.get(e);return void 0===t&&(t=window.getComputedStyle(e),this.styleCache.set(e,t)),t}rect(e){if(!this.rectCache)return e.getBoundingClientRect();let t=this.rectCache.get(e);return void 0===t&&(t=e.getBoundingClientRect(),this.rectCache.set(e,t)),t}isVisible(e){const t=this.visEnv??Os();if(!this.visibilityCache)return Ds(e,t);let n=this.visibilityCache.get(e);return void 0===n&&(n=Ds(e,t),this.visibilityCache.set(e,n)),n}getElementText(e){return Us(e,e=>this.cs(e))}getHTMLContext(e){const t={};this.includeHtml&&e instanceof HTMLElement&&(t.rawHtml=$s(e,1e3)),e.id&&(t.id=e.id);const n=Array.from(e.classList).filter(e=>this.isValidSelectorClass(e));if(n.length>0&&(t.classes=n.slice(0,5)),this.includeHtml){const n={};for(const t of Array.from(e.attributes))t.name.startsWith(\"data-\")&&(n[t.name]=t.value);Object.keys(n).length>0&&(t.dataAttributes=n),t.selectors=this.generateMultipleSelectors(e);const i=this.getParentSelector(e);i&&(t.parentSelector=i)}return t}generateMultipleSelectors(e){const t=[];if(e.id){const n=`#${CSS.escape(e.id)}`;t.push({selector:n,strategy:\"id\",unique:this.isUniqueSelector(n,e)})}for(const n of[\"data-testid\",\"data-test\",\"data-cy\"]){const i=e.getAttribute(n);if(i){const s=`[${n}=\"${CSS.escape(i)}\"]`;t.push({selector:s,strategy:n,unique:this.isUniqueSelector(s,e)})}}const n=e.getAttribute(\"name\");if(n){const i=`${e.tagName.toLowerCase()}[name=\"${CSS.escape(n)}\"]`;t.push({selector:i,strategy:\"name\",unique:this.isUniqueSelector(i,e)})}const i=e.getAttribute(\"aria-label\");if(i){const n=`[aria-label=\"${CSS.escape(i)}\"]`;t.push({selector:n,strategy:\"aria-label\",unique:this.isUniqueSelector(n,e)})}const s=e.getAttribute(\"placeholder\");if(s){const n=`[placeholder=\"${CSS.escape(s)}\"]`;t.push({selector:n,strategy:\"placeholder\",unique:this.isUniqueSelector(n,e)})}const r=e.getAttribute(\"data-placeholder\")||e.querySelector(\"[data-placeholder]\")?.getAttribute(\"data-placeholder\");if(r){const n=`[data-placeholder=\"${CSS.escape(r)}\"]`;t.push({selector:n,strategy:\"placeholder\",unique:this.isUniqueSelector(n,e)})}const o=Array.from(e.classList).filter(e=>this.isValidSelectorClass(e));if(o.length>0){const n=`${e.tagName.toLowerCase()}.${o.slice(0,2).join(\".\")}`;t.push({selector:n,strategy:\"class\",unique:this.isUniqueSelector(n,e)})}const a=this.generateNthSelector(e);return t.push({selector:a,strategy:\"nth-of-type\",unique:this.isUniqueSelector(a,e)}),t}isUniqueSelector(e,t){const n=this.selectorUniquenessCache.get(e);if(void 0!==n){if(!n)return!1;try{return document.querySelectorAll(e)[0]===t}catch{return!1}}try{const n=document.querySelectorAll(e),i=1===n.length;return this.selectorUniquenessCache.set(e,i),i&&n[0]===t}catch{return this.selectorUniquenessCache.set(e,!1),!1}}getParentSelector(e){const t=e.closest('[id], form, [role=\"dialog\"], [role=\"main\"], main, nav, header, footer, aside, section, article');if(t&&t!==e){if(t.id)return`#${t.id}`;if(\"FORM\"===t.tagName)return t.getAttribute(\"name\")?`form[name=\"${t.getAttribute(\"name\")}\"]`:\"form\";const e=t.getAttribute(\"role\");if(e)return`[role=\"${e}\"]`}let n=e.parentElement,i=0;for(;n&&i<6&&n!==document.body;){for(const e of Array.from(n.classList))if(e.includes(\"__\")||e.includes(\"--\"))return`.${CSS.escape(e)}`;n=n.parentElement,i++}if(t&&t!==e)return t.tagName.toLowerCase()}generateNthSelector(e){const t=e.tagName.toLowerCase(),n=e.parentElement;if(!n)return t;const i=Array.from(n.children).filter(t=>t.tagName===e.tagName),s=i.indexOf(e);let r=n,o=0;for(;r&&o<6&&r!==document.body;){if(r.id){const e=`${`#${CSS.escape(r.id)}`} ${t}:nth-of-type(${s+1})`;try{if(1===document.querySelectorAll(e).length)return e}catch{}return e}for(const e of Array.from(r.classList))if(e.includes(\"__\")||e.includes(\"--\")){const n=`${`.${CSS.escape(e)}`} ${t}:nth-of-type(${s+1})`;try{if(1===document.querySelectorAll(n).length)return n}catch{}return n}r=r.parentElement,o++}return n.id?`#${CSS.escape(n.id)} > ${t}:nth-of-type(${s+1})`:i.length>1?`${t}:nth-of-type(${s+1})`:t}isValidSelectorClass(e){if(e.length<2)return!1;if(/[\\/\\[\\]():!@#$%^&*+={}|\\\\<>?,]/.test(e))return!1;const t=[\"w-\",\"h-\",\"p-\",\"m-\",\"px-\",\"py-\",\"pt-\",\"pb-\",\"pl-\",\"pr-\",\"mx-\",\"my-\",\"mt-\",\"mb-\",\"ml-\",\"mr-\",\"text-\",\"bg-\",\"border-\",\"rounded-\",\"shadow-\",\"flex-\",\"grid-\",\"col-\",\"row-\",\"gap-\",\"space-\",\"top-\",\"bottom-\",\"left-\",\"right-\",\"inset-\",\"z-\",\"opacity-\",\"scale-\",\"rotate-\",\"translate-\",\"transition-\",\"duration-\",\"ease-\",\"delay-\",\"hover:\",\"focus:\",\"active:\",\"disabled:\",\"dark:\",\"sm:\",\"md:\",\"lg:\",\"xl:\"];for(const n of t)if(e.startsWith(n))return!1;return![\"flex\",\"grid\",\"block\",\"inline\",\"hidden\",\"visible\",\"fixed\",\"absolute\",\"relative\",\"sticky\",\"static\",\"overflow\",\"truncate\",\"antialiased\",\"uppercase\",\"lowercase\",\"capitalize\",\"italic\",\"underline\",\"cursor-pointer\",\"pointer-events-none\"].includes(e)}}qo.BEM_LABEL_SUFFIXES=[\"__label\",\"__title\",\"__header\",\"__name\",\"__caption\",\"__legend\"],qo.SVG_SHAPE_SELECTOR=\"circle, ellipse, rect, path, line, polygon, polyline\",qo.FRAMEWORK_DATA_ATTR_EXACT=new Set([\"data-toggle\",\"data-target\",\"data-dismiss\",\"data-trigger\",\"data-placement\",\"data-controls\",\"data-slide\",\"data-ride\",\"data-parent\",\"data-spy\",\"data-offset\",\"data-backdrop\",\"data-state\",\"data-side\",\"data-align\",\"data-orientation\",\"data-disabled\",\"data-collapsed\",\"data-expanded\",\"data-open\",\"data-active\",\"data-selected\",\"data-highlighted\",\"data-focus\",\"data-hover\",\"data-busy\",\"data-loading\",\"data-testid\",\"data-test\",\"data-cy\",\"data-qa\",\"data-e2e\",\"data-reactid\",\"data-reactroot\"]),qo.FRAMEWORK_DATA_ATTR_PREFIXES=[\"data-bs-\",\"data-radix-\",\"data-headlessui\",\"data-metrics-\",\"data-track-\",\"data-analytics-\",\"data-gtm-\",\"data-ga-\",\"data-v-\",\"data-svelte-\",\"data-emotion\",\"data-new-gr-\",\"data-gr-\"];const Ho=[\"#support-widget-shadow-host\",\"#blar-campaign-banner\",\"#blar-agent-mode-styles\",\".blar-agent-execution-overlay\",\".blar-agent-status-card\",\".blar-agent-mode-overlay\",\".blar-dot-grid-canvas\",\".blar-border-glow\",\".blar-agent-bubbles-container\",\".blar-agent-click-toast\",\".blar-screenshot-flash\",\".blar-slime-container\",\".blar-slime-filter\",\".blar-activation-flash\",\".blar-laser\",\".blar-laser-outline\",\".agent-confirmation-overlay\",\".agent-confirmation-card\",\".agent-panel\",\".agent-auto-card\",\".agent-cursor\",\".agent-tap-layer\",\".agent-question-overlay\"],Bo=Ho.join(\", \");function Do(e){const t=e.id?`#${e.id}`:\"\",n=\"string\"==typeof e.className?e.className.trim().split(/\\s+/).filter(Boolean).slice(0,2):[],i=n.length?`.${n.join(\".\")}`:\"\",s=e.getAttribute(\"aria-label\")||e.getAttribute(\"title\")||e.getAttribute(\"role\")||e.getAttribute(\"data-testid\");return`${e.tagName.toLowerCase()}${t}${i}${s?` (${s.slice(0,60)})`:\"\"}`}function zo(e,t){let n=e,i=null;for(let s=e;s&&!s.contains(t);s=s.parentElement){const{position:e}=getComputedStyle(s);if(\"fixed\"===e||\"sticky\"===e)return s;\"absolute\"===e&&(i=s),n=s}return i??n}function Uo(e,t){const n=e.ownerDocument;for(let i=e.parentElement;i&&i!==n.body&&i!==n.documentElement;i=i.parentElement){const e=getComputedStyle(i);if(\"visible\"!==e.overflowX||\"visible\"!==e.overflowY){const e=i.getBoundingClientRect();if(t.x<e.left||t.x>e.right||t.y<e.top||t.y>e.bottom)return!0}if(\"fixed\"===e.position)return!1}return!1}function jo(e,t=function(e){const t=e.getBoundingClientRect();return t.width<=0||t.height<=0?null:{x:t.left+t.width/2,y:t.top+t.height/2}}(e)){if(!t)return null;const n=[];let i=e.hasAttribute(Gr)?e.parentElement??e:e,s=e.getRootNode();for(;s.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&\"host\"in s;){const e=s;n.push({root:e,expected:i}),i=e.host,s=i.getRootNode()}if(s.nodeType!==Node.DOCUMENT_NODE)return null;n.push({root:s,expected:i});for(const e of n.reverse()){const n=(e.root.elementsFromPoint?.(t.x,t.y)??[e.root.elementFromPoint?.(t.x,t.y)]).find(e=>e&&!e.closest(Bo));if(n&&!e.expected.contains(n)){if(Uo(e.expected,t))return null;const i=zo(n,e.expected);return{blocker:n,description:Do(n),layer:i,layerDescription:Do(i)}}}const r=e.ownerDocument.defaultView;let o=null;try{o=r?.frameElement??null}catch{}if(o){const e=o.getBoundingClientRect(),n=\"iframe\"===o.tagName.toLowerCase()?o:null,i=e.width/(n?.offsetWidth||e.width||1),s=e.height/(n?.offsetHeight||e.height||1);return jo(o,{x:e.left+((n?.clientLeft??0)+t.x)*i,y:e.top+((n?.clientTop??0)+t.y)*s})}return null}function Wo(e,t){return!(!e||!t)&&(e===t||(!!e.endsWith(\".\"+t)||!!t.endsWith(\".\"+e)))}function Vo(e){try{const t=new URL(e.url,window.location.href);return`${e.method} ${t.hostname}${t.pathname}${t.search}`}catch{return`${e.method} ${e.url}`}}const Go=new Set([\"svg\",\"png\",\"jpg\",\"jpeg\",\"gif\",\"webp\",\"avif\",\"ico\",\"bmp\",\"woff\",\"woff2\",\"ttf\",\"eot\",\"otf\",\"mp4\",\"webm\",\"ogg\",\"mp3\",\"wav\",\"avi\",\"mov\",\"css\"]);function Ko(e){const t=window.location.hostname;return e.filter(e=>{try{const n=new URL(e.url,window.location.href);return Wo(n.hostname,t)&&!function(e){const t=e.lastIndexOf(\".\");return-1!==t&&Go.has(e.slice(t+1).toLowerCase())}(n.pathname)}catch{return!1}})}const Yo=new Set([\"INPUT\",\"SELECT\",\"TEXTAREA\"]),Xo=new Set([\"P\",\"SPAN\",\"DIV\",\"LI\",\"TD\",\"TH\",\"LABEL\",\"LEGEND\",\"FIGCAPTION\",\"BLOCKQUOTE\",\"PRE\",\"CODE\",\"EM\",\"STRONG\",\"A\",\"B\",\"I\",\"U\",\"SMALL\",\"MARK\",\"ABBR\",\"CITE\",\"DT\",\"DD\"]),Jo=new Set([\"SPAN\",\"EM\",\"STRONG\",\"B\",\"I\",\"U\",\"SMALL\",\"MARK\",\"ABBR\",\"CITE\",\"CODE\"]),Qo={max_chars:0,max_depth:24,focus_container:\"\",include_landmarks:!0},Zo=new Set([\"region\",\"group\",\"tabpanel\",\"dialog\",\"alertdialog\"]);let ea=new Map,ta=0;function na(e,t){const n=new Set(Array.from(e.matchAll(/\\[(r\\d+)\\] /g),e=>e[1]));return t.filter(({ref:e})=>n.has(e))}class ia{constructor(e,t){this.domAnalyzer=e,this.networkTracker=t,this.isHidden=!1,this.openPopups=new Set,this.coveringLayers=new Map}analyze(e){const t={...Qo,...e};this.isHidden=Ps(),ea=new Map,this.coveringLayers=new Map;const n=t.focus_container?this.domAnalyzer.findContainer(t.focus_container):document.body;if(!n)return this.errorResponse(\"Focus container not found\");try{Yr(e=>this.domAnalyzer.extractSemanticDataAttrList(e)),this.openPopups=ao(n,{isVisible:e=>this.domAnalyzer.isVisible(e),isHidden:this.isHidden});const e=this.buildTree(n,0,t);for(const i of this.openPopups)n.contains(i)||e.children.push(this.buildTree(i,1,t));this.annotateCoveredControls(e);const i=this.pruneTree(e);this.promoteGroupContainers(i),this.recalculateDepths(i,0),this.applyDepthLimit(i,t);const s=[];let r=ta;const o=[];this.renderNode(i,0,o,s,r,t,e=>{r=e,ta=e}),this.appendPendingNetworkLines(o);const a=fr(),l=document.title,c=[`url: ${a}`,`title: ${l}`],d=this.getOverlayNotice();d&&c.push(d);const u=c.concat(o).join(\"\\n\");if(t.max_chars>0&&u.length>t.max_chars){const e=u.substring(0,t.max_chars)+\"\\n... (truncated)\";return{url:a,title:l,text_tree:e,refs:na(e,s)}}return{url:a,title:l,text_tree:u,refs:s}}catch(e){return this.errorResponse(e instanceof Error?e.message:\"Unknown error\")}}annotateCoveredControls(e){const t=e=>{\"interactable\"===e.role&&(e.text=this.annotateCoveredControl(e.element,e.text));for(const n of e.children)t(n)};t(e)}getOverlayNotice(){if(!this.coveringLayers.size)return null;const e=new Map(Array.from(ea,([e,t])=>[t,e])),t=Array.from(this.coveringLayers,([t,{name:n,count:i}])=>{const s=e.get(t);return`${s?`[${s}] `:\"\"}${n} covers ${i} control${1===i?\"\":\"s\"}`});return`overlay: ${t.slice(0,3).join(\"; \")}${t.length>3?`; ${t.length-3} more`:\"\"}. Covered controls remain available for actions; consider handling the overlay first.`}annotateCoveredControl(e,t){const n=jo(e);if(!n)return t;const{layer:i}=n;let s=this.coveringLayers.get(i);if(!s){const e=this.firstNameText(i);s={name:e?`${n.layerDescription} in \"${e}\"`:n.layerDescription,count:0},this.coveringLayers.set(i,s)}return s.count++,`${t} [covered at click point by ${s.name}]`}buildTree(e,t,n){const i=e.tagName;if(e instanceof HTMLElement){const s=$r(e);if(s){const r=this.getInputLabel(e),o=Cr(e)?\" [disabled]\":\"\";return{tag:i,role:\"interactable\",text:`${s}${r?\" \"+r:\"\"}${Pr(e)}${o}`,children:this.nestedFields(e,t,n),element:e,depth:t}}if(this.isButtonElement(e)){const s=this.getButtonLabel(e),r=Cr(e)?\" [disabled]\":\"\";return{tag:i,role:\"interactable\",text:(s?`[button] ${s}`:\"[button]\")+Pr(e)+r,children:this.nestedFields(e,t,n),element:e,depth:t}}if(this.isLinkElement(e)){const n=Cr(e)?\" [disabled]\":\"\";return{tag:i,role:\"interactable\",text:`[link] ${this.getButtonLabel(e)}${Sr(e)}`+Pr(e)+n,children:[],element:e,depth:t}}const r=Yo.has(i),o=\"switch\"===e.getAttribute(\"role\");if(r||o){const n=o?this.renderToggleState(e):this.renderInteractableState(e);if(n){return{tag:i,role:\"interactable\",text:n+(Cr(e)?\" [disabled]\":\"\"),children:[],element:e,depth:t}}}}if(this.isLoadingElement(e))return{tag:i,role:\"container\",text:\"[loading…]\",children:[],element:e,depth:t};if(this.openPopups.has(e)){const n=this.extractPopupOptionTexts(e);return{tag:i,role:\"popup\",text:\"\",children:n.map(n=>({tag:\"LI\",role:\"text\",text:n,children:[],element:e,depth:t+1})),element:e,depth:t,popupOptionCount:n.length}}const s={tag:i,role:this.classifyRole(e),text:\"\",children:[],element:e,depth:t};mr.has(i)&&(s.headingLevel=parseInt(i[1],10));const r=this.matchAriaContainerRole(e);r&&(s.containerKind=r,s.containerLabel=this.getContainerLabel(e));const o=s.containerKind?null:Er(e)??Mr(e);o&&(s.containerKind=\"group\",s.containerLabel=o);const a=this.getDirectText(e);if(a&&(s.text=Eo(window.getComputedStyle(e).color)?`${a} {red text}`:a),\"TABLE\"===i){s.role=\"table\",s.text=\"Table:\";for(const i of this.openPopups)e.contains(i)&&i!==e&&s.children.push(this.buildTree(i,t+1,n));return s}const l=[];for(const i of Array.from(e.children))this.shouldSkip(i)||l.push(this.buildTree(i,t+1,n));return this.labelDataAttrSiblings(s,l),s.children=l.filter(e=>e.text||e.children.length>0),s}labelDataAttrSiblings(e,t){const n=new Map;for(const e of t){if(\"interactable\"===e.role||e.containerKind)continue;const t=this.domAnalyzer.extractSemanticDataAttrList(e.element);if(0===t.length)continue;if(this.hasHumanName(e.element))continue;const i=t.map(e=>e.slice(0,e.indexOf(\"=\"))).join(\" \");n.set(i,[...n.get(i)??[],{node:e,segs:t}])}for(const t of n.values()){if(t.length<2)continue;const n=t[0].segs.filter(e=>t.every(t=>t.segs.includes(e)));if(n.length===t[0].segs.length)continue;const i=this.isHidden?null:Dr(t.map(e=>e.node.element));for(const{node:e,segs:s}of t){const t=i?.get(e.element),r=[t?zr(t):\"\",s.filter(e=>!n.includes(e)).join(\" \")].filter(Boolean).join(\" · \"),o=1!==e.children.length||e.text?null:e.children[0];if(\"interactable\"===o?.role){o.text+=` (${r})`;continue}e.containerKind=\"group\",e.role=\"container\",e.containerLabel=r;const a=e.element;Cr(a)||\"true\"===a.getAttribute(\"data-unavailable\")?e.text=e.text?`${e.text} [unavailable]`:\"[unavailable]\":e.text||0!==e.children.length||(e.text=\"(empty)\")}!n.length||e.containerKind||this.hasHumanName(e.element)||(e.containerKind=\"group\",e.containerLabel=n.join(\" \"))}}hasHumanName(e){const t=this.getContainerLabel(e);return!!t&&t!==e.getAttribute(\"data-testid\")}extractPopupOptionTexts(e){const t=eo.join(\",\"),n=[],i=new Set,s=so(e,e=>this.domAnalyzer.isVisible(e));for(const r of s){if(!this.domAnalyzer.isVisible(r))continue;const s=Array.from(r.querySelectorAll(t));if(s.some(e=>this.domAnalyzer.isVisible(e)))continue;const o=s.length>0,a=o?this.ownLabelText(r,t):ro(r);if(!a)continue;const l=o?`${a} ▸ (submenu — hover to reveal)`:this.qualifySubmenuLabel(r,e,a);i.has(l)||(i.add(l),n.push(l.length>200?`${l.slice(0,199)}…`:l))}return n}qualifySubmenuLabel(e,t,n){const i=e.closest(Qr);if(i&&i!==t){const e=lo(i);if(e&&t.contains(e)){const t=(e.textContent||\"\").replace(/\\s+/g,\" \").trim();return t?`${t} ▸ ${n}`:`▸ ${n}`}}const s=e.getAttribute(\"aria-haspopup\");return\"menu\"===s||\"true\"===s?\"true\"===e.getAttribute(\"aria-expanded\")?`${n} ▸ (submenu open — its items are listed below)`:`${n} ▸ (submenu — click to open)`:n}ownLabelText(e,t){const n=e.cloneNode(!0);for(const e of Array.from(n.querySelectorAll(t)))os(e);return(n.textContent||\"\").replace(/\\s+/g,\" \").trim()}isLoadingElement(e){if(\"true\"===e.getAttribute(\"aria-busy\"))return!0;if(\"progressbar\"===e.getAttribute(\"role\"))return!0;if(\"skeleton\"===e.getAttribute(\"data-slot\"))return!0;const t=e.getAttribute(\"class\");return!(!t||!/(?:^|[\\s_-])(?:skeleton|shimmer)(?:[\\s_-]|$)/i.test(t))}shouldSkip(e){return!Yo.has(e.tagName)&&(!!gr.has(e.tagName)||(!!this.isBlarUIElement(e)||(\"true\"===e.getAttribute(\"aria-hidden\")||e instanceof HTMLElement&&!this.domAnalyzer.isVisible(e))))}classifyRole(e){const t=e.tagName;return mr.has(t)?\"heading\":Lr.has(t)?\"landmark\":\"TABLE\"===t?\"table\":\"UL\"===t||\"OL\"===t||\"DL\"===t?\"list\":Xo.has(t)?\"text\":\"container\"}renderToggleState(e){return`[${\"true\"===e.getAttribute(\"aria-checked\")?\"ON\":\"OFF\"}] ${this.getInputLabel(e)||e.textContent?.trim()||\"\"}`}renderInteractableState(e){const t=e.tagName;if(\"INPUT\"===t){const t=e,n=t.type.toLowerCase();if(\"hidden\"===n||\"submit\"===n||\"button\"===n)return null;const i=this.getInputLabel(e);if(\"checkbox\"===n){return`[${cr(t)?\"✓\":\" \"}] ${i}`}if(\"radio\"===n){return`(${cr(t)?\"●\":\" \"}) ${i}`}return t.value?`${i?i+\": \":\"\"}[value: \"${t.value}\"]`:`${i?i+\": \":\"\"}${this.renderEmpty(t)}`}if(\"SELECT\"===t){const t=e,n=this.getInputLabel(e),i=t.options[t.selectedIndex];return`${n?n+\": \":\"\"}[${i?.textContent?.trim()||t.value} ▾]`}if(\"TEXTAREA\"===t){const t=e,n=this.getInputLabel(e);if(t.value){return`${n?n+\": \":\"\"}[value: \"${t.value.length>50?t.value.substring(0,50)+\"...\":t.value}\"]`}return`${n?n+\": \":\"\"}${this.renderEmpty(t)}`}return null}renderEmpty(e){const t=e.placeholder.replace(/\\s+/g,\" \").trim();return t?`[empty, placeholder: \"${t}\"]`:\"[empty]\"}nestedFields(e,t,n){return Array.from(e.querySelectorAll(Po)).filter(e=>this.domAnalyzer.isVisible(e)).map(e=>this.buildTree(e,t+1,n)).filter(e=>e.text)}isButtonElement(e){const t=e.tagName;if(\"BUTTON\"===t)return!0;if(\"INPUT\"===t){const t=e.type.toLowerCase();return\"button\"===t||\"submit\"===t||\"reset\"===t}return\"button\"===e.getAttribute(\"role\")||(xr(e)?this.getButtonLabel(e).length>0:wr(e,()=>this.getButtonLabel(e)))}isLinkElement(e){if(!kr(e))return!1;const t=this.getButtonLabel(e);return t.length>0&&t.length<=80}getButtonLabel(e){const t=e=>(e||\"\").replace(/\\s+/g,\" \").trim();if(Zs(e))return t(er(e));const n=t(e.getAttribute(\"aria-label\"));if(n)return n;if(e.hasAttribute(\"aria-pressed\")){const t=this.getInputLabel(e);if(t)return t}if(\"INPUT\"===e.tagName){const n=t(e.value);if(n)return n}const i=this.domAnalyzer.getElementText(e);if(i)return i;const s=t(e.getAttribute(\"title\"));return s||t(er(e))}getInputLabel(e){const t=e.getAttribute(\"aria-label\");if(t?.trim())return t.replace(/\\s+/g,\" \").trim();const n=e.getAttribute(\"aria-labelledby\");if(n){const e=n.trim().split(/\\s+/).map(e=>document.getElementById(e)).filter(e=>!!e).map(e=>this.domAnalyzer.getElementText(e)).filter(Boolean).join(\" \");if(e)return e}if(e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement){const t=Array.from(e.labels??[]).map(e=>this.getLabelText(e)).filter(Boolean);if(t.length)return t.join(\" \")}else if(e.id){const t=Array.from(document.querySelectorAll(\"label[for]\")).find(t=>t.getAttribute(\"for\")===e.id);if(t)return this.getLabelText(t)}const i=e.closest(\"label\");if(i){const e=this.getLabelText(i);if(e)return e}if(this.isCheckable(e)){const t=this.domAnalyzer.getElementText(e);if(t)return t;const n=this.getAdjacentControlLabel(e);if(n)return n}return e.getAttribute(\"name\")||\"\"}getLabelText(e){const t=e.cloneNode(!0);return t.querySelectorAll(\"input, select, textarea\").forEach(e=>os(e)),(t.textContent||\"\").trim().replace(/\\s+/g,\" \")}isCheckable(e){return e instanceof HTMLInputElement&&(\"checkbox\"===e.type||\"radio\"===e.type)||e.hasAttribute(\"aria-pressed\")||e.matches('[role=\"checkbox\"], [role=\"radio\"], [role=\"switch\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"]')||null!==$r(e)}getAdjacentControlLabel(e){const t=`${vr}, [aria-checked], [aria-pressed], [role=\"checkbox\"], [role=\"radio\"], [role=\"switch\"], [role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"]`;let n=e;for(let i=0;i<3;i++){for(const i of[\"nextSibling\",\"previousSibling\"]){if(\"previousSibling\"===i&&!n.matches(\"td, th\")&&Array.from(n.parentElement?.querySelectorAll(t)??[]).some(e=>!n.contains(e)))continue;let s=n[i];for(;s?.nodeType===Node.TEXT_NODE&&!s.textContent?.trim();)s=s[i];if(s?.nodeType===Node.TEXT_NODE){const e=s.textContent?.replace(/\\s+/g,\" \").trim();if(e)return e}if(!(s instanceof HTMLElement)||this.shouldSkip(s))continue;if(s.matches(t)||s.querySelector(t))continue;if(s.matches(\"label[for]\")&&s.getAttribute(\"for\")!==e.id)continue;if(s.querySelector(\"label[for]\"))continue;const r=this.domAnalyzer.getElementText(s);if(r&&r.length<=160)return r}const i=n.parentElement;if(!i||i===document.body||1!==i.children.length||this.getDirectText(i))break;n=i}return\"\"}renderTable(e,t){return Or(e,this.openPopups,e=>\"true\"===e.getAttribute(\"aria-hidden\")||e instanceof HTMLElement&&!this.domAnalyzer.isVisible(e),(e,n)=>{const i=e instanceof HTMLElement&&this.isCheckable(e)?this.getInputLabel(e):\"\",s=i&&!n.includes(i)?`${n} ${i}`:n,r=this.annotateCoveredControl(e,s);return t?.(e,r)??r})}getDirectText(e){return Br(e)}pruneTree(e){return e.children=e.children.map(e=>this.pruneTree(e)).filter(e=>e.text||e.children.length>0),e.text||1!==e.children.length||\"container\"!==e.role||e.containerKind?(e.children.length>1&&\"popup\"!==e.role&&(e.children=this.mergeShortSiblings(e.children)),\"heading\"!==e.role||e.text||1!==e.children.length||\"text\"!==e.children[0].role||0!==e.children[0].children.length||(e.text=e.children[0].text,e.children=[]),e):e.children[0]}recalculateDepths(e,t){e.depth=t;for(const n of e.children)this.recalculateDepths(n,t+1)}applyDepthLimit(e,t){if(e.depth>=t.max_depth&&e.children.length>0)return e.text=this.flattenText(e),void(e.children=[]);for(const n of e.children)this.applyDepthLimit(n,t)}mergeShortSiblings(e){const t=[];let n=[];const i=()=>{if(0!==n.length){if(1===n.length)t.push(n[0]);else{const e=n.map(e=>e.text).filter(Boolean),i={...n[0],text:e.join(\" | \"),children:[]};t.push(i)}n=[]}};for(const s of e){0===s.children.length&&s.text.length>0&&s.text.length<30&&\"text\"===s.role?n.push(s):(i(),t.push(s))}return i(),t}flattenText(e){const t=[];\"table\"===e.role?t.push(this.renderTable(e.element)):e.text&&t.push(e.text);for(const n of e.children){const e=this.flattenText(n);e&&t.push(e)}return t.join(\" \").substring(0,2e3)}renderNode(e,t,n,i,s,r,o){const a=\"\\t\".repeat(t),l=!!e.containerKind,c=this.shouldAssignRef(e);let d=\"\";const u=e=>{s++,o(s);const t=`r${s}`,n=this.generateSelector(e);return i.push({ref:t,selector:n}),e instanceof HTMLElement&&ea.set(t,e),`[${t}] `};c&&(d=u(e.element));let p=\"\";if(l){const t=`[${e.containerKind}]`;p=e.containerLabel?`${a}${d}${t} ${e.containerLabel}`:`${a}${d}${t}`}else if(\"heading\"===e.role&&e.headingLevel){p=`${a}${d}${\"#\".repeat(e.headingLevel)} ${e.text}`}else if(\"landmark\"===e.role&&r.include_landmarks){const t=e.element.getAttribute(\"aria-label\")||e.tag.toLowerCase();e.text?p=`${a}${d}[${t}] ${e.text}`:e.children.length>0&&(p=`${a}${d}[${t}]`)}else{if(\"table\"===e.role){const l=this.renderTable(e.element,(e,t)=>this.isCheckable(e)?`${u(e)}${t}`:t).split(\"\\n\");n.push(`${a}${d}${l[0]}`);const c=\"\\t\".repeat(t+1);for(let e=1;e<l.length;e++)n.push(`${c}${l[e]}`);for(const a of e.children)this.renderNode(a,t+1,n,i,s,r,e=>{s=e,o(e)});return}if(\"popup\"===e.role){const i=e.popupOptionCount??e.children.length,s=1===i?\"1 option\":`${i} options`,r=e.element instanceof HTMLElement&&\"menu\"===e.element.getAttribute(\"role\")?\"[menu open — click one of the options below]\":\"[popup open — select one option to confirm the input above]\";n.push(`${a}${d}${r} (${s})`);const o=\"\\t\".repeat(t+1);for(const t of e.children)t.text&&n.push(`${o}- ${t.text}`);return}e.text&&(p=`${a}${d}${e.text}`)}p&&n.push(p),l&&e.text&&e.text!==e.containerLabel&&n.push(`${\"\\t\".repeat(t+1)}${e.text}`);const h=p?t+1:t;for(const t of e.children)this.renderNode(t,h,n,i,s,r,e=>{s=e,o(e)})}shouldAssignRef(e){return\"interactable\"===e.role||(!!e.containerKind||(\"heading\"===e.role||(\"landmark\"===e.role||(\"table\"===e.role||(\"popup\"===e.role||(\"list\"===e.role&&e.children.length>3||!!e.text))))))}generateSelector(e){const t=this.getSelectorCandidate(e);try{const n=document.querySelectorAll(t);if(1===n.length&&n[0]===e)return t}catch{}const n=[];let i=e;for(;i;){const e=i.tagName,t=e.toLowerCase(),s=i.parentElement?Array.from(i.parentElement.children).filter(t=>t.tagName===e):[i];n.unshift(s.length>1?`${t}:nth-of-type(${s.indexOf(i)+1})`:t),i=i.parentElement}return n.join(\" > \")}getSelectorCandidate(e){if(e.id)return`#${CSS.escape(e.id)}`;const t=e.getAttribute(\"data-testid\");if(t)return`[data-testid=\"${CSS.escape(t)}\"]`;const n=e.tagName.toLowerCase(),i=e.parentElement;if(i){const t=Array.from(i.children).filter(t=>t.tagName===e.tagName);if(1===t.length){const t=this.findNamedAncestor(e);if(t){const i=this.buildChildChain(e,t.depth);return`${t.selector}${i} > ${n}`}return n}const s=t.indexOf(e)+1,r=this.findNamedAncestor(e);if(r){const t=this.buildChildChain(e,r.depth);return`${r.selector}${t} > ${n}:nth-of-type(${s})`}return`${n}:nth-of-type(${s})`}return n}buildChildChain(e,t){if(0===t)return\"\";const n=[];let i=e.parentElement;for(let e=0;e<t&&i;e++)n.unshift(i.tagName.toLowerCase()),i=i.parentElement;return\" > \"+n.join(\" > \")}findNamedAncestor(e){let t=e.parentElement;for(let e=0;e<4&&t;e++){if(t.id)return{selector:`#${CSS.escape(t.id)}`,depth:e};const n=t.getAttribute(\"data-testid\");if(n)return{selector:`[data-testid=\"${CSS.escape(n)}\"]`,depth:e};const i=Array.from(t.classList);for(const t of i){const n=`.${CSS.escape(t)}`;try{if(1===document.querySelectorAll(n).length)return{selector:n,depth:e}}catch{}}t=t.parentElement}return null}promoteGroupContainers(e){for(const t of e.children)this.promoteGroupContainers(t);if(!this.shouldPromoteAsGroup(e))return;const t=this.getContainerLabel(e.element);if(t){if(e.children.find(e=>e.containerKind&&e.containerLabel===t))return}e.containerKind=\"group\",e.containerLabel=t,t&&(e.children=e.children.filter(e=>!(\"text\"===e.role&&0===e.children.length&&e.text===t)))}shouldPromoteAsGroup(e){if(e.containerKind)return!1;if(\"landmark\"===e.role||\"heading\"===e.role||\"table\"===e.role||\"list\"===e.role||\"interactable\"===e.role||\"popup\"===e.role)return!1;if(Jo.has(e.tag))return!1;const t=e.children.filter(e=>e.text||e.children.length>0||e.containerKind);if(t.length<2)return!1;if(0===t.filter(e=>!e.containerKind).length)return!1;if(!this.isHidden&&e.element instanceof HTMLElement){const t=e.element.getBoundingClientRect(),n=t.width*t.height,i=window.innerWidth*window.innerHeight;if(i>0&&n/i>.7)return!1}return!0}matchAriaContainerRole(e){if(\"dialog\"===e.tagName.toLowerCase())return\"dialog\";const t=e.getAttribute(\"role\");return t&&Zo.has(t.toLowerCase())?t.toLowerCase():null}getContainerLabel(e){const t=e=>e.length>80?e.substring(0,80):e,n=e=>(e||\"\").trim().replace(/\\s+/g,\" \"),i=n(e.getAttribute(\"aria-label\"));if(i)return t(i);const s=e.getAttribute(\"aria-labelledby\");if(s){const e=document.getElementById(s),i=n(e?.textContent);if(i)return t(i)}const r=e.querySelector(\"h1, h2, h3, h4, h5, h6\");if(r){const e=n(r.textContent);if(e)return t(e)}const o=e.querySelector('[data-slot*=\"title\" i], [data-slot*=\"header\" i]');if(o){const e=n(o.textContent);if(e)return t(e)}const a=e.getAttribute(\"data-testid\");return a?t(a):this.firstNameText(e)}firstNameText(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null);for(let n=t.nextNode();n;n=t.nextNode()){if(this.isInsideControl(n.parentElement,e))continue;const t=(n.textContent||\"\").trim().replace(/\\s+/g,\" \");if(t.length<2||t.length>50)continue;if(!/^[A-Za-zÁÉÍÓÚÑáéíóúñÀ-ÿ]/.test(t))continue;const i=t.match(/[A-Za-zÁÉÍÓÚÑáéíóúñÀ-ÿ]/g);if(i&&!(i.length<3))return t}return\"\"}isInsideControl(e,t){for(;e&&e!==t;e=e.parentElement)if(e instanceof HTMLElement&&(this.isButtonElement(e)||this.isLinkElement(e)))return!0;return!1}isBlarUIElement(e){try{return Ho.some(t=>e.matches(t))}catch{return!1}}errorResponse(e){throw new Error(e)}appendPendingNetworkLines(e){if(!this.networkTracker)return;const t=Ko(this.networkTracker.getPendingRequestInfo());if(0===t.length)return;const n=t.slice(0,10);e.push(\"\");for(const t of n)e.push(`[network] ${Vo(t)}`);t.length>n.length&&e.push(`[network] … and ${t.length-n.length} more`)}}const sa=[];let ra=null;function oa(){try{return!0===window.__blarAgentDebug||\"1\"===localStorage.getItem(\"blar_agent_debug\")}catch{return!1}}function aa(e){window.__blarAgentDebug=e;try{e?localStorage.setItem(\"blar_agent_debug\",\"1\"):localStorage.removeItem(\"blar_agent_debug\")}catch{}}let la=null;function ca(e,t){la={name:e,t:s()},ra&&oa()&&(ra.marks.length>=60||ra.marks.push({t:s(),name:e,...t&&{data:t}}))}function da(){return sa.map(e=>({...e,marks:[...e.marks]}))}const ua=\"blar_agent_lifecycle\";function pa(){try{const e=sessionStorage.getItem(ua);return e?JSON.parse(e):[]}catch{return[]}}function ha(e,t){if(oa())try{const n=s(),i=pa();for(i.push({t:n,at:new Date(n).toISOString(),url:window.location.pathname+window.location.search+window.location.hash,event:e,...t&&{data:t}});i.length>80;)i.shift();sessionStorage.setItem(ua,JSON.stringify(i))}catch{}}function ga(){return pa()}let ma=null;function fa(){return ma||(ma=cs()),ma}const ba=\"blar_tab_id\";function ya(){try{let e=sessionStorage.getItem(ba);return e||(e=cs(),sessionStorage.setItem(ba,e)),e}catch{return fa()}}function va(e){try{const t=JSON.parse(e),n=r(t?.releasedAt);if(\"string\"==typeof t?.tabId&&null!==n)return{kind:\"released\",tabId:t.tabId,releasedAt:n}}catch{}return{kind:\"claim\",tabId:e}}class wa{constructor(e,t){this.onDeactivated=t,this.serverOwnerTabId=null,this.boundStorageChange=null,this.suppressClaimUntil=0,this.storageKey=`support_widget_active_tab_${e}`,this.tabId=fa(),this.boundBeforeUnload=()=>this.release(),window.addEventListener(\"beforeunload\",this.boundBeforeUnload),window.addEventListener(\"pagehide\",this.boundBeforeUnload),ha(\"tab-lock:init\",{tabId:this.tabId,key:this.storageKey,lock:this.describeLock()}),t&&(this.boundStorageChange=e=>{if(e.key!==this.storageKey||!e.newValue)return;const t=va(e.newValue);\"claim\"===t.kind&&t.tabId!==this.tabId&&this.onDeactivated?.()},window.addEventListener(\"storage\",this.boundStorageChange))}readRaw(){try{return localStorage.getItem(this.storageKey)}catch{return null}}writeRaw(e){try{null===e?localStorage.removeItem(this.storageKey):localStorage.setItem(this.storageKey,e)}catch{}}readLock(){const e=this.readRaw();return e?va(e):null}describeLock(){const e=this.readLock();if(!e)return\"none\";const t=e.tabId===this.tabId?\"self\":`other(${e.tabId.slice(0,8)})`;return\"claim\"===e.kind?`claim:${t}`:`released:${t}+${s()-e.releasedAt}ms`}release(){this.readRaw()===this.tabId?(this.writeRaw(JSON.stringify({tabId:this.tabId,releasedAt:s()})),ha(\"tab-lock:released\",{key:this.storageKey,tabId:this.tabId})):ha(\"tab-lock:release-skipped\",{key:this.storageKey,tabId:this.tabId,lock:this.describeLock()})}setServerOwner(e){const t=this.serverOwnerTabId!==e;this.serverOwnerTabId=e,t&&this.isOwnedByAnotherDevice()&&this.onDeactivated?.()}isOwnedByAnotherDevice(){return null!==this.serverOwnerTabId&&this.serverOwnerTabId!==ya()}claimActiveTab(){return ha(\"tab-lock:claim\",{key:this.storageKey,tabId:this.tabId,was:this.describeLock()}),this.suppressClaimUntil=0,this.writeRaw(this.tabId),!this.isOwnedByAnotherDevice()}isHeldByAnotherTab(){if(this.isOwnedByAnotherDevice())return!0;const e=this.readLock(),t=\"claim\"===e?.kind&&e.tabId!==this.tabId;return t&&ha(\"tab-lock:held-by-other\",{key:this.storageKey,tabId:this.tabId,lock:this.describeLock()}),t}yieldForHandoff(e=1e4){this.suppressClaimUntil=s()+e,this.readRaw()===this.tabId&&this.writeRaw(null)}isActiveTab(){return!this.isOwnedByAnotherDevice()&&this.isLocallyActiveTab()}isLocallyActiveTab(){const e=this.readLock();return\"claim\"===e?.kind?e.tabId===this.tabId:\"released\"===e?.kind&&e.tabId!==this.tabId&&s()-e.releasedAt<1e4?(ha(\"tab-lock:passive\",{key:this.storageKey,reason:\"other-tab-navigating\",lock:this.describeLock()}),!1):s()<this.suppressClaimUntil?(ha(\"tab-lock:passive\",{key:this.storageKey,reason:\"yielding-for-handoff\",lock:this.describeLock()}),!1):(this.claimActiveTab(),!0)}destroy(){window.removeEventListener(\"beforeunload\",this.boundBeforeUnload),window.removeEventListener(\"pagehide\",this.boundBeforeUnload),this.boundStorageChange&&window.removeEventListener(\"storage\",this.boundStorageChange),this.release()}}class xa{constructor(e){this.networkTracker=e}getMetadata(){const e={url:window.location.href,tab_id:ya(),debug_context:this.captureDebugContext()},t=this.captureTextDom();return t&&(e.text_dom=t),e}captureDebugContext(){const e={viewport:{width:window.innerWidth,height:window.innerHeight}},t=this.networkTracker?.getRecentFailures(performance.now());return t&&t.length>0&&(e.recent_failures=t),e}captureTextDom(){try{return this.textDomAnalyzer||(this.textDomAnalyzer=new ia(new qo,this.networkTracker)),this.textDomAnalyzer.analyze({max_chars:1e5})}catch(e){return Ji(\"[MessageMetadataManager] Failed to capture text_dom\",e),null}}}class ka{constructor(e,t,n=new xa){this.metadataManager=n,this.isProcessing=!1,this.processingMessages=new Set,this.apiClient=e,this.callbacks=t,this.queueManager=new Is({onStatusChange:(e,t,n)=>{t!==Ts.PENDING||this.processingMessages.has(e)||this.processQueue(),this.callbacks.onStatusChange(e,t),t===Ts.FAILED&&n&&this.callbacks.onMessageFailed(e,n,!1)}})}sendMessage(e,t,n,i,s,r,o){const a=cs(),l=s?.text_dom?s:{...this.metadataManager.getMetadata(),...s};return this.enqueue({id:a,conversationId:e,conversationType:t,text:n,attachmentIds:i||[],isVoiceNote:r,replyToMessageId:o,metadata:{...l,tab_id:ya()}}),a}sendFirstMessage(e,t,n){this.enqueue({id:n.idempotency_key,conversationId:e,conversationType:t,text:n.body,attachmentIds:n.attachment_ids??[],replyToMessageId:n.reply_to_message_id,metadata:n.metadata})}enqueue(e){this.queueManager.enqueue(e),this.callbacks.onStatusChange(e.id,Ts.SENDING),this.processQueue()}retryMessage(e){this.queueManager.resetForRetry(e),this.callbacks.onStatusChange(e,Ts.SENDING),this.processQueue()}async processQueue(){if(!this.isProcessing){this.isProcessing=!0;try{const e=this.queueManager.getPendingMessages();for(const t of e)this.processingMessages.has(t.id)||this.queueManager.hasRetryScheduled(t.id)||await this.sendSingleMessage(t)}finally{this.isProcessing=!1}}}resumePendingMessages(){const e=this.queueManager.getPendingMessages(),t=this.queueManager.getFailedMessages();for(const t of e)this.callbacks.onStatusChange(t.id,Ts.SENDING);for(const e of t)this.callbacks.onMessageFailed(e.id,e.error||\"Message failed to send\",!1);e.length>0&&this.processQueue()}getQueueManager(){return this.queueManager}async sendSingleMessage(e){this.processingMessages.add(e.id),this.queueManager.updateStatus(e.id,Ts.SENDING),this.callbacks.onStatusChange(e.id,Ts.SENDING);try{const t={body:e.text,idempotency_key:e.id,attachment_ids:e.attachmentIds.length>0?e.attachmentIds:void 0,is_voice_note:e.isVoiceNote||void 0,reply_to_message_id:e.replyToMessageId,metadata:e.metadata},n=t=>\"session\"===e.conversationType?this.apiClient.sendSessionMessage(e.conversationId,t):this.apiClient.sendMessage(e.conversationId,t);let i;try{i=await n(t)}catch(e){if(!(t.reply_to_message_id&&e instanceof Pi&&400===e.status))throw e;i=await n({...t,reply_to_message_id:void 0})}this.queueManager.markSent(e.id),this.callbacks.onMessageSent(e.id,i)}catch(t){const n=t instanceof Error?t.message:\"Unknown error\";this.queueManager.markForRetry(e.id,n)&&this.callbacks.onMessageFailed(e.id,n,!0)}finally{this.processingMessages.delete(e.id)}}clearForConversation(e,t){this.queueManager.clearForConversation(e,t)}}const Sa=[1e3,3e3];function Ca(e){return e instanceof Pi&&\"http\"!==e.kind}function Ea(e){return Ca(e)||e instanceof Pi&&e.status>=500}function Ma(e){return e instanceof Pi?e.kind:\"unknown\"}function Aa(e){return new Promise(t=>setTimeout(t,e))}function _a(e,t,n){const i=(new TextEncoder).encode(JSON.stringify(n)).length;Zi(\"first_message_failed\",{kind:Ma(e),status:String(e instanceof Pi?e.status:0),attempts:String(t),body_kb:String(Math.round(i/1024))})}async function Ta(e,t){try{return await e.createTicket(t)}catch(n){if(!(t.reply_to_message_id&&n instanceof Pi&&400===n.status))throw n;return e.createTicket({...t,reply_to_message_id:void 0})}}const Ia={en:{config:{title:\"Support Chat\"},aria:{openChat:\"Open support chat\",closeChat:\"Close chat\",sendMessage:\"Send message\",stopAI:\"Stop AI\",messageInput:\"Message input\",talkToHuman:\"Talk to a human\",talkToAI:\"Talk to AI\",poweredBy:\"Powered by Blar\",expandChat:\"Expand chat\",collapseChat:\"Collapse chat\",attachFile:\"Attach file\",removeFile:\"Remove file\",avatar:\"Avatar\",moreOptions:\"More options\",openSidePanel:\"Open support chat\",newChat:\"New chat\",viewHistory:\"View history\",backToMenu:\"Back\",minimizeChat:\"Minimize chat widget\",rating:\"Rating\",previous:\"Previous\",next:\"Next\",close:\"Close\",fullSizeImage:\"Full size image\"},tooltips:{requestHuman:\"Request human assistance\",requestAI:\"Request AI assistance\",newAISession:\"New AI session\"},buttons:{startNewConversation:\"Start New Conversation\"},menu:{soundNotifications:\"Sound notifications\",expandWindow:\"Expand window\",collapseWindow:\"Collapse window\"},placeholders:{typeMessage:\"Ask anything...\",aiThinking:\"AI is thinking...\"},branding:{poweredBy:\"Powered by Blar\"},messages:{welcome:\"Hi there! How can we help you today?\",welcomeTitle:\"Hey there, welcome!\",welcomeSubtitle:\"I'm an AI agent that can see your screen and take control to help you. You can stop me anytime, just press ESC or click Stop.\",thinkingSynonyms:[\"Thinking\",\"Pondering\",\"Reasoning\"],readDocument:\"Read\",processing:\"Processing...\",conversationClosed:\"This conversation has been closed by the support team\",newMessages:\"New messages\",and:\"and\",others:\"others\",viewing:\"viewing\",waitingForAgent:\"A member of the Support team will help you.\",talkingToHuman:\"You're now talking to a human\",agentInOtherTab:e=>`${e} is working in another tab`,bringAgentHere:\"Bring it here\",stopAgentInOtherTab:\"Stop\",clickToRetry:\"Failed to send. Click to retry.\",edited:\"edited\"},replies:{reply:\"Reply\",replyingTo:\"Replying to\",cancel:\"Cancel reply\",you:\"You\",assistant:\"Assistant\",supportTeam:\"Support\",deletedMessage:\"Message deleted\",goToMessage:\"Go to the quoted message\"},systemActions:{closeTicket:{heading:\"Issue resolved?\",description:\"We're glad we could help! Would you like to close this conversation?\"},humanAssistance:{heading:\"Would you like to speak with a human?\",description:\"Our AI assistant can help with many things, but if you'd prefer to speak with our support team, we're here for you!\",executiveHeading:e=>`Would you like to speak with ${e}?`,executiveDescription:e=>`${e} is the person responsible for your account and can pick up this conversation from here.`},csatSurvey:{thankYou:\"Thank you for your feedback!\"},apiConfirmation:{approved:\"Approve\",denied:\"Deny\"},interactive:{submit:\"Submit\",skip:\"Skip\",skipped:\"Skipped\",required:\"This field is required\",selectOption:\"Please select an option\",submitted:\"Response submitted\",thankYou:\"Thanks for answering!\",yourResponse:\"Your response:\"}},toasts:{aiEnabled:\"AI assistance enabled! I'll help you now.\",humanRequested:\"Request sent! A team member will assist you shortly.\",assistanceFailed:\"Failed to request assistance. Please try again.\",startConversation:\"Please send a message first to start a conversation.\",creatingTicket:\"Creating ticket first...\",uploadFailed:\"Upload failed\",aiStillResponding:\"AI is still responding. Wait for the reply or stop the agent to send another message.\",messagePending:\"Your previous message is still being sent. Please wait.\",planSaved:\"Plan saved by the agent\"},errors:{ticketCreationFailed:\"Failed to create ticket. Please try again.\",firstMessageConnectionFailed:\"We couldn't reach our servers, so your message wasn't sent. Check your connection and retry it.\",noPublishableKey:\"publishableKey is required to initialize the Support Widget\",noSessionUuid:\"Cannot identify user: No session UUID available\",apiRequestFailed:\"API request failed\",noActiveTicket:\"Cannot request assistance: No active ticket\",noSessionOrTicket:\"Cannot send message: No session UUID or ticket ID\",playbookNotFound:\"Playbook not found\",playbookInactive:\"Playbook is not active\",authFailed:\"Authentication failed\",aiNoResponse:\"AI didn't respond. Please try again.\",aiDisabled:\"AI is disabled for this workspace\",identityVerificationFailed:\"We couldn't verify your identity. You can still chat, but actions using connected account credentials are unavailable.\"},attachments:{loadingImage:\"Loading image...\",loadingVideo:\"Loading video...\",loadingAudio:\"Loading audio...\",attachment:\"Attachment\",videoNotSupported:\"Your browser does not support the video tag.\",audioNotSupported:\"Your browser does not support the audio tag.\",failedToLoad:\"Failed to load\",uploadFailed:\"We couldn't upload your file. Check your internet connection and try again.\"},voiceNotes:{voiceMessage:\"Voice message\",record:\"Record a voice note\",stop:\"Stop recording\",discard:\"Discard recording\",send:\"Send voice note\",playPreview:\"Play preview\",play:\"Play voice message\",pause:\"Pause\",playbackSpeed:\"Playback speed\",sending:\"Sending...\",errors:{unsupported:\"Voice notes aren't supported in this browser. You can type your message instead.\",permission:\"We need microphone access to record. Enable it for this site in your browser settings and try again.\",empty:\"We couldn't hear anything. Check that your microphone isn't muted and try again.\",tooLarge:\"That voice note is too long to send. Try recording a shorter one.\",failed:\"Something interrupted the recording. Check that another app isn't using your microphone and try again.\",sendFailed:\"The voice note couldn't be sent. Your recording is still here — press send to retry.\"}},tour:{startTour:\"Start Tour\",tourStarted:\"Tour Started\",stepsCount:e=>`${e} step${1!==e?\"s\":\"\"} in this tour`,loadError:\"We had an error showing the tour. Please tell us what you were trying to do and we'll help you!\"},validation:{fileTypeNotSupported:e=>`File type ${e} is not supported`,fileSizeExceeds:(e,t)=>`File size exceeds ${e} limit for ${t}s`,fileEmpty:\"File is empty\",noFilesSelected:\"No files selected\",maxFilesExceeded:e=>`Maximum ${e} files allowed`,totalSizeExceeds:e=>`Total file size exceeds ${e}`},agent:{thinking:\"Thinking\",executingAction:\"Executing action...\",scanningPage:\"Scanning page...\",capturingScreenshot:\"Capturing screenshot...\",errorOccurred:\"Error occurred\",tooltipStop:\"Stop the current agent execution\",clickElement:\"Click this element\",typeValue:e=>`Type: \"${e}\"`,selectValue:e=>`Select: \"${e}\"`,checkCheckbox:\"Check this checkbox\",uncheckCheckbox:\"Uncheck this checkbox\",scrollToElement:\"Scroll to this element\",hoverElement:\"Hover over this element\",pressKey:e=>`Press key: ${e}`,performAction:\"Perform action\",clickStopToControl:\"Click Stop or press ESC to take control\",agentModeActivated:\"AI is going to take control\",confirmCancel:\"Cancel\",confirmProceed:\"Confirm\",confirmationTitle:\"Confirmation needed\",confirmDestructive:\"Yes, proceed\",cannotBeUndone:\"This action cannot be undone\",confirmStop:\"Stop\",readingSkip:\"Skip\",answerPlaceholder:\"Type your answer...\",actionsTitle:\"Agent Actions\",actionCount:e=>1===e?\"1 action\":`${e} actions`,moreCount:e=>`+${e} more`,confirmationHint:(e,t)=>`To continue, click the highlighted element or \"${e}\". To stop, click \"${t}\".`,confirmationHintTouch:(e,t)=>`To continue, tap the highlighted element or \"${e}\". To stop, tap \"${t}\".`,timeline:{title:e=>`What ${e} did`,stepCount:e=>1===e?\"1 step\":`${e} steps`,collapse:\"Hide the steps\",expand:\"Show the steps\",actions:{click:\"Clicked\",type:\"Typed into\",select:\"Selected in\",check:\"Toggled\",scroll_to:\"Scrolled to\",scroll_to_text:\"Scrolled to\",hover:\"Hovered over\",highlight:\"Highlighted\",press_key:\"Pressed a key on\",navigate:\"Navigated to\",wait_for:\"Waited for\"},actionsAlone:{press_key:\"Pressed a key\",navigate:\"Navigated\",wait_for:\"Waited\"}}},conversationSelector:{aiConversation:\"AI\",humanConversation:\"Support\",pickerTitle:\"How would you like to get help?\",aiDescription:\"Continue your AI conversation\",humanDescription:\"Continue with our support team\",backToPicker:\"Switch conversation\"},session:{archiveAndNew:\"New conversation\",archiveFailed:\"Failed to start new conversation. Please try again.\",escalated:\"Connecting you with our support team...\",escalatedToExecutive:e=>`Connecting you with ${e}…`},executiveAvailability:{at:e=>`at ${e}`,tomorrow:e=>`tomorrow ${e}`,onDay:(e,t)=>`on ${e} ${t}`,available:e=>`Available ${e}`,reason:{busy:\"Busy\",out_of_office:\"Out of office\"},status:{busy:e=>`Busy · available ${e}`,out_of_office:e=>`Out of office · available ${e}`}},history:{title:\"History\",noHistory:\"No previous conversations\",escalatedBadge:\"Escalated\",newConversation:\"New Conversation\",voiceMessage:\"Voice message\",loading:\"Loading...\",loadMore:\"Load more\",today:\"Today\",yesterday:\"Yesterday\",lastWeek:\"Last week\",older:\"Older\"},engineeringTickets:{heading:\"Issues we're tracking for you\",statuses:{open:\"Filed — we'll look at it\",in_progress:\"We're working on it\",blocked:\"We're looking into this\",resolved:\"Fixed — let us know if you still see this\",closed:\"Closed\"}},ticketDetail:{descriptionLabel:\"Description\",openConversation:\"Open conversation\",noConversation:\"No conversation is linked to this ticket yet.\"},lastTicket:{heading:\"Previous conversation\",subtitle:\"View the conversation and rate your experience\",fallbackTitle:\"Your last conversation\",you:\"You\",statuses:{resolved:\"Resolved\",closed:\"Closed\"}},tabs:{home:\"Home\",messages:\"Messages\",releases:\"Releases\"},messagesView:{subtabSession:\"AI\",subtabTicket:\"Support\"},releases:{comingSoonTitle:\"What's new\",comingSoonSubtitle:\"Product updates will show up here soon.\",configureReleaseLabel:\"Configure release\",testReleaseLabel:\"Test release\",noCtaNotice:\"This release was published without a call to action. You can add one from the Blar dashboard.\",releaseLabel:\"Release\",categories:{announcement:\"ANNOUNCEMENT\",event:\"EVENT\",feature:\"FEATURE\",update:\"UPDATE\"}},home:{resumeSession:\"Continue your AI session\",resumeTicket:\"Continue with support\",resumeHint:\"Tap to resume where you left off\",newMessage:\"You have a new message\"},awareness:{dismiss:\"Dismiss\",clickError:\"Something went wrong. Please try again.\",tipLabel:\"Tip\",cta:\"Finish · 30 sec\",confirmPrompt:\"Want me to show you?\",accept:\"Yes\",decline:\"No\",later:\"Later\"},voiceCalls:{incomingCall:\"Incoming call\",accept:\"Accept\",decline:\"Decline\",callInProgress:\"Call in progress\",returnToCall:\"Return to call\",hangUp:\"Hang up\",callEnded:\"Call ended\",acceptFailed:\"Couldn't start the call — try again\",popupBlocked:\"Pop-up blocked — allow pop-ups, then tap Accept again\"},screenShare:{requestTitle:\"Screen share request\",requestBody:\"Wants to see this page to help you. Only this tab is shared, and passwords and personal details stay hidden.\",accept:\"Share screen\",decline:\"Decline\",sharing:\"Sharing screen\",stop:\"Stop sharing\",sharingElsewhere:\"Sharing another tab\",shareThisTabInstead:\"Share this tab instead\",switching:\"Switching…\",switchFailed:\"Couldn't switch sharing — try again\",busyWithAgent:\"Can't share while the assistant is working on this page\",ended:\"Screen sharing ended\",acceptFailed:\"Couldn't start sharing — try again\"},preChatForm:{defaultTitle:\"Before we chat\",defaultSubtitle:\"Please tell us a bit about yourself\",defaultSubmitButton:\"Start Chat\",labels:{name:\"Name\",email:\"Email\",phone:\"Phone\"},placeholders:{name:\"Enter your name\",email:\"Enter your email\",phone:\"Enter your phone number\"},validation:{required:\"This field is required\",invalidEmail:\"Please enter a valid email address\",invalidPhone:\"Please enter a valid phone number\"},submitting:\"Submitting...\",submitError:\"Failed to submit. Please try again.\"},adminMode:{headerTitle:\"Admin mode\",homeTitle:\"Admin mode\",homeSubtitle:\"Preview each step from a real user's perspective, or jump into the live-feedback chat to refine the AI's instructions.\",placeholder:\"Describe what you want to configure...\",backToHome:\"Back to home\",testingStepN:e=>`Testing step ${e}`,configuringStepN:e=>`Configuring step ${e}`,testingRelease:\"Testing release\",configuringRelease:\"Configuring release\",scopedPlaceholder:e=>`Describe changes for \"${e}\"...`,leaveAdminMode:\"Leave admin mode\",sessionExpired:\"Admin session expired — reopen admin mode from the Blar platform\"},nps:{title:\"How likely are you to recommend us to a friend or colleague?\",subtitle:\"Your feedback helps us improve.\",stepLabel:\"Step 2 of 2\",step2TitlePromoter:\"Glad you liked it! What stood out?\",step2TitlePassive:\"What's the main reason for your score?\",step2TitleDetractor:\"Sorry to hear that. What went wrong?\",step2Subline:\"You rated us a {score}\",submit:\"Send reply\",skip:\"Skip\",commentPlaceholder:\"Tell us what you love (or what we could improve)…\",replyHint:\"This goes to our team — we read every reply.\",lowLabel:\"Not at all likely\",highLabel:\"Extremely likely\",thanksDefault:\"Thanks for your feedback!\",thanksPromoter:\"Glad you're enjoying it!\",thanksDetractor:\"Thanks — what could we do better?\"},activationForm:{title:\"Help us get you set up\",subtitle:\"A couple of quick questions so we can tailor things for you.\",submit:\"Submit\",submitting:\"Submitting...\",skip:\"Skip\",requiredError:\"This field is required\",selectOneError:\"Please select an option\",selectAtLeastOneError:\"Please select at least one option\",submitError:\"Failed to submit. Please try again.\",textPlaceholder:\"Type your answer…\"},featureCheckIn:{yes:\"Keep\",no:\"Skip\",submitting:\"Sending…\",submitError:\"Failed to send. Please try again.\"},progress:{title:\"Your progress\",nextStep:\"Your next step\",doItWithMe:\"Show me how\",doItWithMeShort:\"Show me\",startAmplifier:\"Start\",count:(e,t)=>`${e} of ${t}`,stageOrdinal:(e,t)=>`Stage ${e} of ${t}`,stageCurrent:\"You are here\",stageComplete:\"Complete\",stageUpcoming:\"Later\",stageRemaining:e=>1===e?\"Just 1 step to finish this stage!\":`${e} steps to finish this stage`,justDone:\"Step complete! 🎉\",allDone:\"You finished your onboarding!\",alreadyDone:\"This one is already done\",fullValueTitle:\"Get more out of it\",stages:{hand_off:\"Welcome\",set_up:\"Setup\",first_value:\"First steps\",core_value:\"Everyday use\",repeat_value:\"Habit\"}},onboarding:{title:\"Get started\",typeTabs:{company:\"Company\",user:\"User\"},progressMeta:(e,t)=>`${e} of ${t} done`,ctaLabel:\"See AI explanation\",testStepLabel:\"Test step\",configureStepLabel:\"Configure step\",readyBadge:\"Ready\",needsConfigBadge:\"Setup\",nextStep:\"Next:\",allComplete:\"All steps completed!\",viewPlanLabel:\"See agent plan\",planTitle:\"Agent Plan\",planBack:\"Back\",planStepLabel:e=>`Step ${e}`,planExpectedOutcome:\"Expected outcome\",planEmpty:\"No plan available for this step.\",stepN:e=>`Step ${e}`,goToNextStepButton:\"Go to next step\",completeOnboardingButton:\"Complete Onboarding\"},introPresentation:{steps:[{title:\"Hey, I'm {name} 👋\",body:\"Your built-in AI agent. I'm here to help you get the most out of this app.\"},{title:\"I solve issues & onboard you\",body:\"Ask me anything — I'll answer questions, fix problems, and guide you step by step.\"},{title:\"I can take control 🚀\",body:\"I can see your screen and act for you. Watch — I'll show you around. You're always in charge: press ESC anytime.\"}],executiveStep:{title:\"I work with {executive}\",body:\"{executive} is the person responsible for your account. I'm here 24/7, and whenever you'd rather talk to a person, I'll bring them in.\"},captions:[\"I can click here for you\",\"…fill things in\",\"…and find my way around\"],typeSample:\"How do I get started?\",next:\"Next\",showMe:\"Show me\",skip:\"Skip\",ariaSkip:\"Skip introduction\"}},es:{config:{title:\"Chat de Soporte\"},aria:{openChat:\"Abrir chat de soporte\",closeChat:\"Cerrar chat\",sendMessage:\"Enviar mensaje\",stopAI:\"Detener IA\",messageInput:\"Entrada de mensaje\",talkToHuman:\"Hablar con una persona\",talkToAI:\"Hablar con IA\",poweredBy:\"Desarrollado por Blar\",expandChat:\"Expandir chat\",collapseChat:\"Contraer chat\",attachFile:\"Adjuntar archivo\",removeFile:\"Eliminar archivo\",avatar:\"Avatar\",moreOptions:\"Más opciones\",openSidePanel:\"Abrir chat de soporte\",newChat:\"Nuevo chat\",viewHistory:\"Ver historial\",backToMenu:\"Volver\",minimizeChat:\"Minimizar el chat\",rating:\"Calificación\",previous:\"Anterior\",next:\"Siguiente\",close:\"Cerrar\",fullSizeImage:\"Imagen en tamaño completo\"},tooltips:{requestHuman:\"Solicitar asistencia humana\",requestAI:\"Solicitar asistencia de IA\",newAISession:\"Nueva sesión de IA\"},buttons:{startNewConversation:\"Iniciar Nueva Conversación\"},menu:{soundNotifications:\"Notificaciones de sonido\",expandWindow:\"Expandir ventana\",collapseWindow:\"Contraer ventana\"},placeholders:{typeMessage:\"Pregunta lo que quieras...\",aiThinking:\"La IA está pensando...\"},branding:{poweredBy:\"Desarrollado por Blar\"},messages:{welcome:\"¡Hola! ¿Cómo podemos ayudarte hoy?\",welcomeTitle:\"¡Hola, bienvenido!\",welcomeSubtitle:\"Soy un agente de IA que puede ver tu pantalla y tomar el control para ayudarte. Puedes detenerme en cualquier momento, solo presiona ESC o haz clic en Detener.\",thinkingSynonyms:[\"Pensando\",\"Razonando\",\"Analizando\"],readDocument:\"Leído\",processing:\"Procesando...\",conversationClosed:\"Esta conversación ha sido cerrada por el equipo de soporte\",newMessages:\"Mensajes nuevos\",and:\"y\",others:\"otros\",viewing:\"conectado\",waitingForAgent:\"Un miembro del equipo de soporte te ayudará.\",talkingToHuman:\"Ahora estás hablando con una persona\",agentInOtherTab:e=>`${e} está trabajando en otra pestaña`,bringAgentHere:\"Traerlo aquí\",stopAgentInOtherTab:\"Detener\",clickToRetry:\"Error al enviar. Clic para reintentar.\",edited:\"editado\"},replies:{reply:\"Responder\",replyingTo:\"Respondiendo a\",cancel:\"Cancelar respuesta\",you:\"Tú\",assistant:\"Asistente\",supportTeam:\"Soporte\",deletedMessage:\"Mensaje eliminado\",goToMessage:\"Ir al mensaje citado\"},systemActions:{closeTicket:{heading:\"¿Problema resuelto?\",description:\"¡Nos alegra haber podido ayudar! ¿Te gustaría cerrar esta conversación?\"},humanAssistance:{heading:\"¿Te gustaría hablar con una persona?\",description:\"Nuestro asistente de IA puede ayudar con muchas cosas, pero si prefieres hablar con nuestro equipo de soporte, ¡estamos aquí para ti!\",executiveHeading:e=>`¿Te gustaría hablar con ${e}?`,executiveDescription:e=>`${e} es la persona responsable de tu cuenta y puede continuar esta conversación contigo.`},csatSurvey:{thankYou:\"¡Gracias por tus comentarios!\"},apiConfirmation:{approved:\"Aprobar\",denied:\"Rechazar\"},interactive:{submit:\"Enviar\",skip:\"Omitir\",skipped:\"Omitido\",required:\"Este campo es requerido\",selectOption:\"Por favor selecciona una opción\",submitted:\"Respuesta enviada\",thankYou:\"¡Gracias por responder!\",yourResponse:\"Tu respuesta:\"}},toasts:{aiEnabled:\"¡Asistencia de IA activada! Te ayudaré ahora.\",humanRequested:\"¡Solicitud enviada! Un miembro del equipo te asistirá pronto.\",assistanceFailed:\"Error al solicitar asistencia. Por favor, inténtalo de nuevo.\",startConversation:\"Por favor, envía un mensaje primero para iniciar una conversación.\",creatingTicket:\"Creando ticket primero...\",uploadFailed:\"Error al subir archivo\",aiStillResponding:\"La IA aún está respondiendo. Espera la respuesta o detén al agente para enviar otro mensaje.\",messagePending:\"Tu mensaje anterior aún se está enviando. Por favor, espera.\",planSaved:\"Plan guardado por el agente\"},errors:{ticketCreationFailed:\"Error al crear ticket. Por favor, inténtalo de nuevo.\",firstMessageConnectionFailed:\"No pudimos conectar con nuestros servidores y tu mensaje no se envió. Revisa tu conexión y reintenta enviarlo.\",noPublishableKey:\"publishableKey es requerido para inicializar el Widget de Soporte\",noSessionUuid:\"No se puede identificar al usuario: UUID de sesión no disponible\",apiRequestFailed:\"Falló la solicitud a la API\",noActiveTicket:\"No se puede solicitar asistencia: No hay ticket activo\",noSessionOrTicket:\"No se puede enviar el mensaje: No hay UUID de sesión o ID de ticket\",playbookNotFound:\"Playbook no encontrado\",playbookInactive:\"Playbook no está activo\",authFailed:\"Error de autenticación\",aiNoResponse:\"La IA no respondió. Por favor, inténtalo de nuevo.\",aiDisabled:\"La IA está desactivada para este workspace\",identityVerificationFailed:\"No pudimos verificar tu identidad. Puedes seguir chateando, pero las acciones que usan credenciales de cuentas conectadas no están disponibles.\"},attachments:{loadingImage:\"Cargando imagen...\",loadingVideo:\"Cargando video...\",loadingAudio:\"Cargando audio...\",attachment:\"Adjunto\",videoNotSupported:\"Tu navegador no soporta la etiqueta de video.\",audioNotSupported:\"Tu navegador no soporta la etiqueta de audio.\",failedToLoad:\"Error al cargar\",uploadFailed:\"No pudimos subir tu archivo. Revisa tu conexión a internet e inténtalo de nuevo.\"},voiceNotes:{voiceMessage:\"Mensaje de voz\",record:\"Grabar una nota de voz\",stop:\"Detener grabación\",discard:\"Descartar grabación\",send:\"Enviar nota de voz\",playPreview:\"Reproducir vista previa\",play:\"Reproducir mensaje de voz\",pause:\"Pausar\",playbackSpeed:\"Velocidad de reproducción\",sending:\"Enviando...\",errors:{unsupported:\"Este navegador no soporta notas de voz. Puedes escribir tu mensaje en su lugar.\",permission:\"Necesitamos acceso al micrófono para grabar. Actívalo para este sitio en la configuración de tu navegador e inténtalo de nuevo.\",empty:\"No se escuchó nada. Revisa que tu micrófono no esté silenciado e inténtalo de nuevo.\",tooLarge:\"Esa nota de voz es demasiado larga para enviar. Intenta grabar una más corta.\",failed:\"Algo interrumpió la grabación. Revisa que otra aplicación no esté usando tu micrófono e inténtalo de nuevo.\",sendFailed:\"No se pudo enviar la nota de voz. Tu grabación sigue aquí; presiona enviar para reintentar.\"}},tour:{startTour:\"Iniciar Tour\",tourStarted:\"Tour Iniciado\",stepsCount:e=>`${e} paso${1!==e?\"s\":\"\"} en este tour`,loadError:\"Tuvimos un error al mostrar el tour. ¡Cuéntanos qué intentabas hacer y te ayudaremos!\"},validation:{fileTypeNotSupported:e=>`El tipo de archivo ${e} no está soportado`,fileSizeExceeds:(e,t)=>`El tamaño del archivo excede el límite de ${e} para ${t}s`,fileEmpty:\"El archivo está vacío\",noFilesSelected:\"No se seleccionaron archivos\",maxFilesExceeded:e=>`Máximo ${e} archivos permitidos`,totalSizeExceeds:e=>`El tamaño total de archivos excede ${e}`},agent:{thinking:\"Pensando\",executingAction:\"Ejecutando acción...\",scanningPage:\"Escaneando página...\",capturingScreenshot:\"Capturando pantalla...\",errorOccurred:\"Ocurrió un error\",tooltipStop:\"Detener la ejecución actual del agente\",clickElement:\"Hacer clic en este elemento\",typeValue:e=>`Escribir: \"${e}\"`,selectValue:e=>`Seleccionar: \"${e}\"`,checkCheckbox:\"Marcar esta casilla\",uncheckCheckbox:\"Desmarcar esta casilla\",scrollToElement:\"Desplazarse a este elemento\",hoverElement:\"Pasar el cursor sobre este elemento\",pressKey:e=>`Presionar tecla: ${e}`,performAction:\"Realizar acción\",clickStopToControl:\"Haz clic en Detener o presiona ESC para tomar el control\",agentModeActivated:\"La IA va a tomar el control\",confirmCancel:\"Cancelar\",confirmProceed:\"Confirmar\",confirmationTitle:\"Confirmación pendiente\",confirmDestructive:\"Sí, continuar\",cannotBeUndone:\"Esta acción no se puede deshacer\",confirmStop:\"Detener\",readingSkip:\"Omitir\",answerPlaceholder:\"Escribe tu respuesta...\",actionsTitle:\"Acciones del agente\",actionCount:e=>1===e?\"1 acción\":`${e} acciones`,moreCount:e=>`+${e} más`,confirmationHint:(e,t)=>`Para continuar, haz clic en el elemento destacado o en \"${e}\". Para detener, haz clic en \"${t}\".`,confirmationHintTouch:(e,t)=>`Para continuar, toca el elemento destacado o \"${e}\". Para detener, toca \"${t}\".`,timeline:{title:e=>`Lo que hizo ${e}`,stepCount:e=>1===e?\"1 paso\":`${e} pasos`,collapse:\"Ocultar los pasos\",expand:\"Ver los pasos\",actions:{click:\"Hizo clic en\",type:\"Escribió en\",select:\"Seleccionó en\",check:\"Cambió\",scroll_to:\"Se desplazó a\",scroll_to_text:\"Se desplazó a\",hover:\"Pasó el cursor sobre\",highlight:\"Resaltó\",press_key:\"Presionó una tecla en\",navigate:\"Navegó a\",wait_for:\"Esperó\"},actionsAlone:{press_key:\"Presionó una tecla\",navigate:\"Navegó\",wait_for:\"Esperó\"}}},conversationSelector:{aiConversation:\"IA\",humanConversation:\"Soporte\",pickerTitle:\"¿Cómo te gustaría recibir ayuda?\",aiDescription:\"Continuar tu conversación con IA\",humanDescription:\"Continuar con nuestro equipo de soporte\",backToPicker:\"Cambiar conversación\"},session:{archiveAndNew:\"Nueva conversación\",archiveFailed:\"Error al iniciar nueva conversación. Por favor, inténtalo de nuevo.\",escalated:\"Conectándote con nuestro equipo de soporte...\",escalatedToExecutive:e=>`Conectándote con ${e}…`},executiveAvailability:{at:e=>`${e.startsWith(\"1:\")?\"a la\":\"a las\"} ${e}`,tomorrow:e=>`mañana ${e}`,onDay:(e,t)=>`el ${e} ${t}`,available:e=>`Disponible ${e}`,reason:{busy:\"Agenda ocupada\",out_of_office:\"Fuera de la oficina\"},status:{busy:e=>`Agenda ocupada · disponible ${e}`,out_of_office:e=>`Fuera de la oficina · disponible ${e}`}},history:{title:\"Historial\",noHistory:\"No hay conversaciones anteriores\",escalatedBadge:\"Escalado\",newConversation:\"Nueva Conversación\",voiceMessage:\"Mensaje de voz\",loading:\"Cargando...\",loadMore:\"Cargar más\",today:\"Hoy\",yesterday:\"Ayer\",lastWeek:\"Última semana\",older:\"Anteriores\"},engineeringTickets:{heading:\"Problemas que estamos siguiendo\",statuses:{open:\"Registrado — lo revisaremos\",in_progress:\"Estamos trabajando en ello\",blocked:\"Lo estamos investigando\",resolved:\"Resuelto — avísanos si lo sigues viendo\",closed:\"Cerrado\"}},ticketDetail:{descriptionLabel:\"Descripción\",openConversation:\"Abrir conversación\",noConversation:\"Aún no hay ninguna conversación vinculada a este ticket.\"},lastTicket:{heading:\"Conversación anterior\",subtitle:\"Revisa la conversación y califica tu experiencia\",fallbackTitle:\"Tu última conversación\",you:\"Tú\",statuses:{resolved:\"Resuelto\",closed:\"Cerrado\"}},tabs:{home:\"Inicio\",messages:\"Mensajes\",releases:\"Novedades\"},messagesView:{subtabSession:\"IA\",subtabTicket:\"Soporte\"},releases:{comingSoonTitle:\"Novedades\",comingSoonSubtitle:\"Aquí aparecerán pronto las actualizaciones del producto.\",configureReleaseLabel:\"Configurar novedad\",testReleaseLabel:\"Probar novedad\",noCtaNotice:\"Esta novedad se publicó sin una llamada a la acción. Puedes añadir una desde el panel de Blar.\",releaseLabel:\"Novedad\",categories:{announcement:\"ANUNCIO\",event:\"EVENTO\",feature:\"NOVEDAD\",update:\"ACTUALIZACIÓN\"}},home:{resumeSession:\"Continuar tu sesión con IA\",resumeTicket:\"Continuar con soporte\",resumeHint:\"Toca para retomar donde lo dejaste\",newMessage:\"Tienes un mensaje nuevo\"},awareness:{dismiss:\"Descartar\",clickError:\"Algo salió mal. Por favor, inténtalo de nuevo.\",tipLabel:\"Sugerencia\",cta:\"Terminar · 30 seg\",confirmPrompt:\"¿Quieres que te muestre?\",accept:\"Sí\",decline:\"No\",later:\"Después\"},voiceCalls:{incomingCall:\"Llamada entrante\",accept:\"Contestar\",decline:\"Rechazar\",callInProgress:\"Llamada en curso\",returnToCall:\"Volver a la llamada\",hangUp:\"Colgar\",callEnded:\"Llamada finalizada\",acceptFailed:\"No se pudo iniciar la llamada — inténtalo de nuevo\",popupBlocked:\"Ventana emergente bloqueada — permite las ventanas emergentes y vuelve a tocar Contestar\"},screenShare:{requestTitle:\"Solicitud de pantalla\",requestBody:\"Quiere ver esta página para ayudarte. Solo se comparte esta pestaña; las contraseñas y los datos personales quedan ocultos.\",accept:\"Compartir pantalla\",decline:\"Rechazar\",sharing:\"Compartiendo pantalla\",stop:\"Dejar de compartir\",sharingElsewhere:\"Compartiendo otra pestaña\",shareThisTabInstead:\"Compartir esta pestaña\",switching:\"Cambiando…\",switchFailed:\"No se pudo cambiar la pestaña compartida — inténtalo de nuevo\",busyWithAgent:\"No se puede compartir mientras el asistente trabaja en esta página\",ended:\"Se dejó de compartir la pantalla\",acceptFailed:\"No se pudo compartir la pantalla — inténtalo de nuevo\"},preChatForm:{defaultTitle:\"Antes de chatear\",defaultSubtitle:\"Cuéntanos un poco sobre ti\",defaultSubmitButton:\"Iniciar Chat\",labels:{name:\"Nombre\",email:\"Correo electrónico\",phone:\"Teléfono\"},placeholders:{name:\"Ingresa tu nombre\",email:\"Ingresa tu correo electrónico\",phone:\"Ingresa tu número de teléfono\"},validation:{required:\"Este campo es requerido\",invalidEmail:\"Por favor ingresa un correo electrónico válido\",invalidPhone:\"Por favor ingresa un número de teléfono válido\"},submitting:\"Enviando...\",submitError:\"Error al enviar. Por favor intenta de nuevo.\"},adminMode:{headerTitle:\"Modo administrador\",homeTitle:\"Modo administrador\",homeSubtitle:\"Prueba cada paso desde la perspectiva de un usuario real, o entra al chat de retroalimentación en vivo para refinar las instrucciones de la IA.\",placeholder:\"Describe lo que quieres configurar...\",backToHome:\"Volver al inicio\",testingStepN:e=>`Probando paso ${e}`,configuringStepN:e=>`Configurando paso ${e}`,testingRelease:\"Probando release\",configuringRelease:\"Configurando release\",scopedPlaceholder:e=>`Describe los cambios para \"${e}\"...`,leaveAdminMode:\"Salir del modo admin\",sessionExpired:\"Sesión de administrador expirada — reabre el modo admin desde la plataforma Blar\"},nps:{title:\"¿Qué tan probable es que nos recomiendes a un amigo o colega?\",subtitle:\"Tus comentarios nos ayudan a mejorar.\",stepLabel:\"Paso 2 de 2\",step2TitlePromoter:\"¡Nos alegra! ¿Qué te gustó más?\",step2TitlePassive:\"¿Cuál es la razón principal de tu calificación?\",step2TitleDetractor:\"Lamentamos eso. ¿Qué salió mal?\",step2Subline:\"Nos calificaste con un {score}\",submit:\"Enviar respuesta\",skip:\"Omitir\",commentPlaceholder:\"Cuéntanos qué te gusta (o qué podríamos mejorar)…\",replyHint:\"Esto llega a nuestro equipo — leemos cada respuesta.\",lowLabel:\"Nada probable\",highLabel:\"Muy probable\",thanksDefault:\"¡Gracias por tus comentarios!\",thanksPromoter:\"¡Nos alegra que lo estés disfrutando!\",thanksDetractor:\"Gracias — ¿qué podríamos mejorar?\"},activationForm:{title:\"Ayúdanos a configurar tu experiencia\",subtitle:\"Un par de preguntas rápidas para personalizar todo para ti.\",submit:\"Enviar\",submitting:\"Enviando...\",skip:\"Saltar\",requiredError:\"Este campo es requerido\",selectOneError:\"Por favor selecciona una opción\",selectAtLeastOneError:\"Por favor selecciona al menos una opción\",submitError:\"Error al enviar. Por favor intenta de nuevo.\",textPlaceholder:\"Escribe tu respuesta…\"},featureCheckIn:{yes:\"Mantener\",no:\"Omitir\",submitting:\"Enviando…\",submitError:\"Error al enviar. Por favor intenta de nuevo.\"},progress:{title:\"Tu progreso\",nextStep:\"Tu próximo paso\",doItWithMe:\"Muéstrame cómo\",doItWithMeShort:\"Muéstrame\",startAmplifier:\"Empezar\",count:(e,t)=>`${e} de ${t}`,stageOrdinal:(e,t)=>`Etapa ${e} de ${t}`,stageCurrent:\"Estás aquí\",stageComplete:\"Completada\",stageUpcoming:\"Después\",stageRemaining:e=>1===e?\"¡Solo falta 1 paso para completar esta etapa!\":`${e} pasos para completar esta etapa`,justDone:\"¡Paso completado! 🎉\",allDone:\"¡Completaste tu onboarding!\",alreadyDone:\"Esto ya está completado\",fullValueTitle:\"Sácale más provecho\",stages:{hand_off:\"Bienvenida\",set_up:\"Configuración\",first_value:\"Primeros pasos\",core_value:\"Uso diario\",repeat_value:\"Hábito\"}},onboarding:{title:\"Primeros pasos\",typeTabs:{company:\"Empresa\",user:\"Usuario\"},progressMeta:(e,t)=>`${e} de ${t} completados`,ctaLabel:\"Ver explicación con IA\",testStepLabel:\"Probar paso\",configureStepLabel:\"Configurar paso\",readyBadge:\"Listo\",needsConfigBadge:\"Configurar\",nextStep:\"Siguiente:\",allComplete:\"Todos los pasos completados!\",viewPlanLabel:\"Ver plan del agente\",planTitle:\"Plan Agente\",planBack:\"Volver\",planStepLabel:e=>`Paso ${e}`,planExpectedOutcome:\"Resultado esperado\",planEmpty:\"No hay plan disponible para este paso.\",stepN:e=>`Paso ${e}`,goToNextStepButton:\"Ir al siguiente paso\",completeOnboardingButton:\"Completar Onboarding\"},introPresentation:{steps:[{title:\"Hola, soy {name} 👋\",body:\"Tu agente de IA integrado. Estoy aquí para ayudarte a sacar el máximo provecho de esta app.\"},{title:\"Resuelvo problemas y te oriento\",body:\"Pregúntame lo que sea: respondo dudas, soluciono problemas y te guío paso a paso.\"},{title:\"Puedo tomar el control 🚀\",body:\"Puedo ver tu pantalla y actuar por ti. Mira: te mostraré cómo funciona. Tú siempre mandas: presiona ESC cuando quieras.\"}],executiveStep:{title:\"Trabajo junto a {executive}\",body:\"{executive} es la persona responsable de tu cuenta. Yo estoy disponible 24/7 y, cuando prefieras hablar con una persona, te pongo en contacto.\"},captions:[\"Puedo hacer clic aquí por ti\",\"…completar campos\",\"…y moverme por la app\"],typeSample:\"¿Cómo empiezo?\",next:\"Siguiente\",showMe:\"Muéstrame\",skip:\"Omitir\",ariaSkip:\"Omitir introducción\"}}};let La=\"en\";function Ra(e){e in Ia&&(La=e)}function $a(){return La}function Na(){return Ia[La]}class Pa{constructor(){this.items=[],this.onChange=null}setOnChange(e){this.onChange=e}get length(){return this.items.length}push(...e){const t=this.items.push(...e);return this.onChange?.(),t}splice(e,t){const n=void 0!==t?this.items.splice(e,t):this.items.splice(e);return this.onChange?.(),n}clear(e=!1){this.items=[],e||this.onChange?.()}find(e){return this.items.find(e)}findIndex(e){return this.items.findIndex(e)}slice(e,t){return this.items.slice(e,t)}filter(e){return this.items.filter(e)}map(e){return this.items.map(e)}toArray(){return[...this.items]}[Symbol.iterator](){return this.items[Symbol.iterator]()}}class Fa{constructor(){this.dialog=null,this.slides=[],this.currentIndex=0,this.urlResolver=null,this.resolvedUrls=new Map,this.keydownHandler=null,this.injectStyles()}static getInstance(){return Fa.instance||(Fa.instance=new Fa),Fa.instance}open(e,t,n=0){this.dialog&&this.close(),this.slides=e,this.currentIndex=n,this.urlResolver=t,this.resolvedUrls=new Map,this.dialog=document.createElement(\"dialog\"),this.dialog.className=\"support-carousel-dialog\",this.renderSlide(),this.dialog.addEventListener(\"click\",e=>{e.target===this.dialog&&this.close()}),this.dialog.addEventListener(\"close\",()=>{os(this.dialog),this.dialog=null,this.keydownHandler&&(document.removeEventListener(\"keydown\",this.keydownHandler),this.keydownHandler=null)}),document.body.appendChild(this.dialog),this.dialog.showModal(),this.keydownHandler=e=>{\"ArrowLeft\"===e.key?this.goTo(this.currentIndex-1):\"ArrowRight\"===e.key?this.goTo(this.currentIndex+1):\"Escape\"===e.key&&this.close()},document.addEventListener(\"keydown\",this.keydownHandler)}close(){this.dialog?.close()}goTo(e){e<0||e>=this.slides.length||(this.currentIndex=e,this.renderSlide())}renderSlide(){if(!this.dialog)return;const e=this.slides[this.currentIndex],t=this.slides.length,n=this.currentIndex+1,i=e.url?(()=>{try{return new URL(e.url,window.location.origin).pathname}catch{return\"\"}})():\"\",s=this.slides.map((e,t)=>`<div class=\"support-carousel-dot${t===this.currentIndex?\" active\":\"\"}\"></div>`).join(\"\"),r=this.currentIndex>0?`<button class=\"support-carousel-nav prev\" aria-label=\"${Na().aria.previous}\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"15 18 9 12 15 6\"/></svg></button>`:\"\",o=this.currentIndex<this.slides.length-1?`<button class=\"support-carousel-nav next\" aria-label=\"${Na().aria.next}\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"9 18 15 12 9 6\"/></svg></button>`:\"\";this.dialog.innerHTML=`\\n      <div class=\"support-carousel-inner\">\\n        <div class=\"support-carousel-header\">\\n          <span class=\"support-carousel-counter\">${n} / ${t}</span>\\n          <span class=\"support-carousel-badge\">${e.actionType}</span>\\n          ${i?`<span class=\"support-carousel-url\">${i}</span>`:'<span class=\"support-carousel-url\"></span>'}\\n          <button class=\"support-carousel-close\" aria-label=\"${Na().aria.close}\">\\n            <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"18\" y1=\"6\" x2=\"6\" y2=\"18\"/><line x1=\"6\" y1=\"6\" x2=\"18\" y2=\"18\"/></svg>\\n          </button>\\n        </div>\\n        <div class=\"support-carousel-image-area\">\\n          <div class=\"support-carousel-img-wrapper\" data-attachment-id=\"${e.attachmentId}\">\\n            <span class=\"support-carousel-loading\">Loading…</span>\\n          </div>\\n          ${r}\\n          ${o}\\n        </div>\\n        <div class=\"support-carousel-footer\">\\n          ${e.body?`<p class=\"support-carousel-body\">${e.body}</p>`:\"\"}\\n          <div class=\"support-carousel-dots\">${s}</div>\\n        </div>\\n      </div>\\n    `,this.dialog.querySelector(\".support-carousel-close\")?.addEventListener(\"click\",()=>this.close()),this.dialog.querySelector(\".support-carousel-nav.prev\")?.addEventListener(\"click\",e=>{e.stopPropagation(),this.goTo(this.currentIndex-1)}),this.dialog.querySelector(\".support-carousel-nav.next\")?.addEventListener(\"click\",e=>{e.stopPropagation(),this.goTo(this.currentIndex+1)}),this.loadSlideImage(e)}loadSlideImage(e){if(!this.urlResolver||!this.dialog)return;const t=this.resolvedUrls.get(e.attachmentId);t?this.applyImage(e.attachmentId,t,e.description):this.urlResolver(e.attachmentId).then(t=>{this.resolvedUrls.set(e.attachmentId,t),this.applyImage(e.attachmentId,t,e.description)}).catch(()=>{if(!this.dialog)return;const t=this.dialog.querySelector(`[data-attachment-id=\"${e.attachmentId}\"]`);t&&(t.innerHTML=`<span class=\"support-carousel-error\">${Na().attachments.failedToLoad}</span>`)})}applyImage(e,t,n){if(!this.dialog)return;const i=this.dialog.querySelector(`[data-attachment-id=\"${e}\"]`);i&&(i.innerHTML=`<img class=\"support-carousel-image\" src=\"${t}\" alt=\"${n}\" />`)}injectStyles(){if(document.getElementById(\"support-carousel-styles\"))return;const e=document.createElement(\"style\");e.id=\"support-carousel-styles\",e.textContent=\"\\n      .support-carousel-dialog {\\n        position: fixed;\\n        inset: 0;\\n        margin: auto;\\n        width: 90vw;\\n        max-width: 800px;\\n        height: 88vh;\\n        background: #0f172a;\\n        border: none;\\n        border-radius: 12px;\\n        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);\\n        z-index: 10000000;\\n        overflow: hidden;\\n        padding: 0;\\n        display: flex;\\n        flex-direction: column;\\n        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;\\n      }\\n\\n      .support-carousel-dialog::backdrop {\\n        background: rgba(0, 0, 0, 0.75);\\n      }\\n\\n      .support-carousel-dialog[open] {\\n        animation: support-carousel-in 0.2s ease-out;\\n      }\\n\\n      @keyframes support-carousel-in {\\n        from { opacity: 0; transform: scale(0.96); }\\n        to   { opacity: 1; transform: scale(1); }\\n      }\\n\\n      .support-carousel-inner {\\n        display: flex;\\n        flex-direction: column;\\n        height: 100%;\\n        min-height: 0;\\n      }\\n\\n      .support-carousel-header {\\n        display: flex;\\n        align-items: center;\\n        gap: 10px;\\n        padding: 12px 16px;\\n        background: rgba(0, 0, 0, 0.35);\\n        flex-shrink: 0;\\n        color: white;\\n      }\\n\\n      .support-carousel-counter {\\n        font-size: 13px;\\n        font-weight: 600;\\n        color: rgba(255, 255, 255, 0.65);\\n        white-space: nowrap;\\n      }\\n\\n      .support-carousel-badge {\\n        background: rgba(255, 255, 255, 0.15);\\n        padding: 3px 8px;\\n        border-radius: 4px;\\n        font-size: 11px;\\n        font-weight: 600;\\n        color: white;\\n        text-transform: lowercase;\\n        white-space: nowrap;\\n      }\\n\\n      .support-carousel-url {\\n        flex: 1;\\n        font-size: 11px;\\n        color: rgba(255, 255, 255, 0.4);\\n        overflow: hidden;\\n        text-overflow: ellipsis;\\n        white-space: nowrap;\\n        text-align: right;\\n      }\\n\\n      .support-carousel-close {\\n        background: rgba(255, 255, 255, 0.1);\\n        border: none;\\n        border-radius: 50%;\\n        width: 28px;\\n        height: 28px;\\n        display: flex;\\n        align-items: center;\\n        justify-content: center;\\n        cursor: pointer;\\n        color: rgba(255, 255, 255, 0.8);\\n        flex-shrink: 0;\\n        transition: background 0.15s;\\n        padding: 0;\\n      }\\n\\n      .support-carousel-close:hover {\\n        background: rgba(255, 255, 255, 0.2);\\n      }\\n\\n      .support-carousel-image-area {\\n        position: relative;\\n        flex: 1;\\n        overflow: hidden;\\n        background: #1e293b;\\n        display: flex;\\n        align-items: center;\\n        justify-content: center;\\n        min-height: 0;\\n      }\\n\\n      .support-carousel-img-wrapper {\\n        width: 100%;\\n        height: 100%;\\n        display: flex;\\n        align-items: center;\\n        justify-content: center;\\n      }\\n\\n      .support-carousel-image {\\n        width: 100%;\\n        height: 100%;\\n        object-fit: contain;\\n        display: block;\\n      }\\n\\n      .support-carousel-loading,\\n      .support-carousel-error {\\n        font-size: 13px;\\n        color: rgba(255, 255, 255, 0.4);\\n      }\\n\\n      .support-carousel-error {\\n        color: rgba(255, 100, 100, 0.8);\\n      }\\n\\n      .support-carousel-nav {\\n        position: absolute;\\n        top: 50%;\\n        transform: translateY(-50%);\\n        background: rgba(0, 0, 0, 0.5);\\n        border: none;\\n        border-radius: 50%;\\n        width: 40px;\\n        height: 40px;\\n        display: flex;\\n        align-items: center;\\n        justify-content: center;\\n        cursor: pointer;\\n        color: white;\\n        transition: background 0.15s;\\n        padding: 0;\\n      }\\n\\n      .support-carousel-nav:hover {\\n        background: rgba(0, 0, 0, 0.8);\\n      }\\n\\n      .support-carousel-nav.prev { left: 12px; }\\n      .support-carousel-nav.next { right: 12px; }\\n\\n      .support-carousel-footer {\\n        padding: 12px 16px 14px;\\n        background: rgba(0, 0, 0, 0.3);\\n        flex-shrink: 0;\\n      }\\n\\n      .support-carousel-body {\\n        font-size: 13px;\\n        color: rgba(255, 255, 255, 0.9);\\n        line-height: 1.5;\\n        margin: 0 0 10px 0;\\n      }\\n\\n      .support-carousel-dots {\\n        display: flex;\\n        justify-content: center;\\n        align-items: center;\\n        gap: 6px;\\n      }\\n\\n      .support-carousel-dot {\\n        height: 8px;\\n        width: 8px;\\n        border-radius: 50%;\\n        background: rgba(255, 255, 255, 0.25);\\n        transition: all 0.2s;\\n        flex-shrink: 0;\\n      }\\n\\n      .support-carousel-dot.active {\\n        background: white;\\n        width: 20px;\\n        border-radius: 4px;\\n      }\\n    \",document.head.appendChild(e)}}Fa.instance=null;const Oa={click:'<path d=\"m3 3 7.07 16.97 2.51-7.39 7.39-2.51L3 3z\"/>',type:'<path d=\"M12 20h9\"/><path d=\"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4z\"/>',select:'<path d=\"M3 6h18\"/><path d=\"M7 12h10\"/><path d=\"M10 18h4\"/>',check:'<path d=\"M20 6 9 17l-5-5\"/>',scroll_to:'<path d=\"M12 5v14\"/><path d=\"m19 12-7 7-7-7\"/>',scroll_to_text:'<path d=\"M12 5v14\"/><path d=\"m19 12-7 7-7-7\"/>',hover:'<path d=\"M5 3 19 12 12 13 15.5 20 13 21 9.5 14 5 18z\"/>',highlight:'<circle cx=\"12\" cy=\"12\" r=\"3\"/><path d=\"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z\"/>',press_key:'<path d=\"M9 10V5a3 3 0 0 1 6 0v14\"/><path d=\"M4 15h16\"/>',navigate:'<path d=\"M5 12h14\"/><path d=\"m12 5 7 7-7 7\"/>',wait_for:'<circle cx=\"12\" cy=\"12\" r=\"9\"/><path d=\"M12 7v5l3 2\"/>'};function qa(e,t){return`<svg class=\"${t}\" xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${e}</svg>`}class Ha{constructor(e){this.stepCount=0,this.translations=Na();const t=this.translations.agent.timeline;this.element=document.createElement(\"div\"),this.element.className=\"support-message support-agent-actions-card\",this.element.innerHTML=`\\n      <button type=\"button\" class=\"support-agent-actions-header\" aria-expanded=\"true\">\\n        ${qa(L,\"support-agent-actions-avatar\")}\\n        <span class=\"support-agent-actions-title\"></span>\\n        <span class=\"support-agent-actions-count\"></span>\\n        ${qa('<path d=\"m6 9 6 6 6-6\"/>',\"support-agent-actions-chevron\")}\\n      </button>\\n      <ol class=\"support-agent-actions-list\"></ol>\\n    `,this.headerElement=this.element.querySelector(\".support-agent-actions-header\"),this.listElement=this.element.querySelector(\".support-agent-actions-list\"),this.countElement=this.element.querySelector(\".support-agent-actions-count\");this.element.querySelector(\".support-agent-actions-title\").textContent=t.title(e),this.headerElement.setAttribute(\"aria-label\",t.collapse),this.headerElement.addEventListener(\"click\",()=>this.toggle())}get root(){return this.element}appendStep(e){const t=this.translations.agent.timeline,n=function(e){if(e.description&&e.description!==e.actionType)return e.description;if(\"navigate\"===e.actionType&&e.url)try{return new URL(e.url,window.location.origin).pathname}catch{return e.url}return\"\"}(e),i=(s=e.actionType,r=t,!(\"\"!==n)&&s in r.actionsAlone?r.actionsAlone[s]:s in r.actions?r.actions[s]:s);var s,r;const o=document.createElement(\"li\");o.className=\"support-agent-action\",o.innerHTML=`\\n      <span class=\"support-agent-action-icon\">${qa(Oa[e.actionType]??'<circle cx=\"12\" cy=\"12\" r=\"4\"/>',\"\")}</span>\\n      <div class=\"support-agent-action-text\">\\n        <span class=\"support-agent-action-headline\">\\n          <span class=\"support-agent-action-verb\"></span>\\n          <span class=\"support-agent-action-target\"></span>\\n        </span>\\n        <span class=\"support-agent-action-body\"></span>\\n      </div>\\n    `,o.querySelector(\".support-agent-action-verb\").textContent=i,o.querySelector(\".support-agent-action-target\").textContent=n;const a=o.querySelector(\".support-agent-action-body\");e.body?a.textContent=e.body:os(a),this.listElement.appendChild(o),this.stepCount+=1,this.countElement.textContent=t.stepCount(this.stepCount)}toggle(){const e=this.element.classList.toggle(\"collapsed\"),t=this.translations.agent.timeline;this.headerElement.setAttribute(\"aria-expanded\",e?\"false\":\"true\"),this.headerElement.setAttribute(\"aria-label\",e?t.expand:t.collapse)}}class Ba{constructor(){this.dialog=null,this.injectStyles()}static getInstance(){return Ba.instance||(Ba.instance=new Ba),Ba.instance}injectStyles(){if(document.getElementById(\"support-lightbox-styles\"))return;const e=document.createElement(\"style\");e.id=\"support-lightbox-styles\",e.textContent=\"\\n      .support-lightbox-dialog {\\n        position: fixed;\\n        inset: 0;\\n        margin: auto;\\n        max-width: 672px;\\n        max-height: 90vh;\\n        padding: 16px;\\n        background: rgba(249, 250, 251, 0.95);\\n        border: none;\\n        border-radius: 12px;\\n        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);\\n        z-index: 10000000;\\n      }\\n\\n      .support-lightbox-dialog::backdrop {\\n        background: rgba(0, 0, 0, 0.3);\\n      }\\n\\n      .support-lightbox-dialog[open] {\\n        animation: support-lightbox-fade-in 0.2s ease-out;\\n      }\\n\\n      @keyframes support-lightbox-fade-in {\\n        from {\\n          opacity: 0;\\n          transform: scale(0.95);\\n        }\\n        to {\\n          opacity: 1;\\n          transform: scale(1);\\n        }\\n      }\\n\\n      .support-lightbox-content {\\n        position: relative;\\n      }\\n\\n      .support-lightbox-image {\\n        width: 100%;\\n        height: auto;\\n        max-height: 75vh;\\n        object-fit: contain;\\n        border-radius: 8px;\\n        display: block;\\n      }\\n\\n      .support-lightbox-label {\\n        text-align: center;\\n        font-size: 14px;\\n        font-weight: 500;\\n        margin-top: 12px;\\n        color: rgba(55, 65, 81, 0.8);\\n      }\\n    \",document.head.appendChild(e)}open(e,t){this.dialog&&this.close(),this.dialog=document.createElement(\"dialog\"),this.dialog.className=\"support-lightbox-dialog\";const n=t?`<p class=\"support-lightbox-label\">${this.escapeHtml(t)}</p>`:\"\";this.dialog.innerHTML=`\\n      <div class=\"support-lightbox-content\">\\n        <img src=\"${this.escapeHtml(e)}\" alt=\"${t?this.escapeHtml(t):Na().aria.fullSizeImage}\" class=\"support-lightbox-image\" />\\n        ${n}\\n      </div>\\n    `,this.dialog.addEventListener(\"click\",()=>this.dialog?.close());const i=this.dialog.querySelector(\".support-lightbox-content\");i?.addEventListener(\"click\",e=>e.stopPropagation()),this.dialog.addEventListener(\"close\",()=>{os(this.dialog),this.dialog=null}),document.body.appendChild(this.dialog),this.dialog.showModal()}close(){this.dialog?.close()}escapeHtml(e){const t=document.createElement(\"div\");return t.textContent=e,t.innerHTML}}function Da(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}Ba.instance=null;var za={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function Ua(e){za=e}var ja={exec:()=>null};function Wa(e){let t=[];return n=>{let i=Math.max(0,Math.min(3,n-1)),s=t[i];return s||(s=e(i),t[i]=s),s}}function Va(e,t=\"\"){let n=\"string\"==typeof e?e:e.source,i={replace:(e,t)=>{let s=\"string\"==typeof t?t:t.source;return s=s.replace(Ka.caret,\"$1\"),n=n.replace(e,s),i},getRegex:()=>new RegExp(n,t)};return i}var Ga=((e=\"\")=>{try{return!!new RegExp(\"(?<=1)(?<!1)\"+e)}catch{return!1}})(),Ka={codeRemoveIndent:/^(?: {1,4}| {0,3}\\t)/gm,outputLinkReplace:/\\\\([\\[\\]])/g,indentCodeCompensation:/^(\\s+)(?:```)/,beginningSpace:/^\\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\\n/g,tabCharGlobal:/\\t/g,multipleSpaceGlobal:/\\s+/g,blankLine:/^[ \\t]*$/,doubleBlankLine:/\\n[ \\t]*\\n[ \\t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\\n {0,3}((?:=+|-+) *)(?=\\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \\t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\\[[ xX]\\] +\\S/,listReplaceTask:/^\\[[ xX]\\] +/,listTaskCheckbox:/\\[[ xX]\\]/,anyLine:/\\n.*\\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\\||\\| *$/g,tableRowBlankLine:/\\n[ \\t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\\s|>)/i,endPreScriptTag:/^<\\/(pre|code|kbd|script)(\\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'\"]*[^\\s])\\s+(['\"])(.*)\\2/,unicodeAlphaNumeric:/[\\p{L}\\p{N}]/u,escapeTest:/[&<>\"']/,escapeReplace:/[&<>\"']/g,escapeTestNoEncode:/[<>\"']|&(?!(#\\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\\w+);)/,escapeReplaceNoEncode:/[<>\"']|&(?!(#\\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\\w+);)/g,caret:/(^|[^\\[])\\^/g,percentDecode:/%25/g,findPipe:/\\|/g,splitPipe:/ \\|/,slashPipe:/\\\\\\|/g,carriageReturn:/\\r\\n|\\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\\S*/,endingNewline:/\\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\\t ][^\\\\n]*)?(?:\\\\n|$))`),nextBulletRegex:Wa(e=>new RegExp(`^ {0,${e}}(?:[*+-]|\\\\d{1,9}[.)])((?:[ \\t][^\\\\n]*)?(?:\\\\n|$))`)),hrRegex:Wa(e=>new RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\\\* *){3,})(?:\\\\n+|$)`)),fencesBeginRegex:Wa(e=>new RegExp(`^ {0,${e}}(?:\\`\\`\\`|~~~)`)),headingBeginRegex:Wa(e=>new RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Wa(e=>new RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,\"i\")),blockquoteBeginRegex:Wa(e=>new RegExp(`^ {0,${e}}>`))},Ya=/^ {0,3}((?:-[\\t ]*){3,}|(?:_[ \\t]*){3,}|(?:\\*[ \\t]*){3,})(?:\\n+|$)/,Xa=/ {0,3}(?:[*+-]|\\d{1,9}[.)])/,Ja=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\\n(?!\\s*?\\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,Qa=Va(Ja).replace(/bull/g,Xa).replace(/blockCode/g,/(?: {4}| {0,3}\\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\\n>]+>\\n/).replace(/\\|table/g,\"\").getRegex(),Za=Va(Ja).replace(/bull/g,Xa).replace(/blockCode/g,/(?: {4}| {0,3}\\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\\n>]+>\\n/).replace(/table/g,/ {0,3}\\|?(?:[:\\- ]*\\|)+[\\:\\- ]*\\n/).getRegex(),el=/^([^\\n]+(?:\\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\\n)[^\\n]+)*)/,tl=/(?!\\s*\\])(?:\\\\[\\s\\S]|[^\\[\\]\\\\])+/,nl=Va(/^ {0,3}\\[(label)\\]: *(?:\\n[ \\t]*)?([^<\\s][^\\s]*|<.*?>)(?:(?: +(?:\\n[ \\t]*)?| *\\n[ \\t]*)(title))? *(?:\\n+|$)/).replace(\"label\",tl).replace(\"title\",/(?:\"(?:\\\\\"?|[^\"\\\\])*\"|'[^'\\n]*(?:\\n[^'\\n]+)*\\n?'|\\([^()]*\\))/).getRegex(),il=Va(/^(bull)([ \\t][^\\n]+?)?(?:\\n|$)/).replace(/bull/g,Xa).getRegex(),sl=\"address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul\",rl=/<!--(?:-?>|[\\s\\S]*?(?:-->|$))/,ol=Va(\"^ {0,3}(?:<(script|pre|style|textarea)[\\\\s>][\\\\s\\\\S]*?(?:</\\\\1>[^\\\\n]*\\\\n+|$)|comment[^\\\\n]*(\\\\n+|$)|<\\\\?[\\\\s\\\\S]*?(?:\\\\?>\\\\n*|$)|<![A-Z][\\\\s\\\\S]*?(?:>\\\\n*|$)|<!\\\\[CDATA\\\\[[\\\\s\\\\S]*?(?:\\\\]\\\\]>\\\\n*|$)|</?(tag)(?: +|\\\\n|/?>)[\\\\s\\\\S]*?(?:(?:\\\\n[ \\t]*)+\\\\n|$)|<(?!script|pre|style|textarea)([a-z][\\\\w-]*)(?:attribute)*? */?>(?=[ \\\\t]*(?:\\\\n|$))[\\\\s\\\\S]*?(?:(?:\\\\n[ \\t]*)+\\\\n|$)|</(?!script|pre|style|textarea)[a-z][\\\\w-]*\\\\s*>(?=[ \\\\t]*(?:\\\\n|$))[\\\\s\\\\S]*?(?:(?:\\\\n[ \\t]*)+\\\\n|$))\",\"i\").replace(\"comment\",rl).replace(\"tag\",sl).replace(\"attribute\",/ +[a-zA-Z:_][\\w.:-]*(?: *= *\"[^\"\\n]*\"| *= *'[^'\\n]*'| *= *[^\\s\"'=<>`]+)?/).getRegex(),al=Va(el).replace(\"hr\",Ya).replace(\"heading\",\" {0,3}#{1,6}(?:\\\\s|$)\").replace(\"|lheading\",\"\").replace(\"|table\",\"\").replace(\"blockquote\",\" {0,3}>\").replace(\"fences\",\" {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~{3,})[^\\\\n]*\\\\n\").replace(\"list\",\" {0,3}(?:[*+-]|1[.)])[ \\\\t]\").replace(\"html\",\"</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)\").replace(\"tag\",sl).getRegex(),ll={blockquote:Va(/^( {0,3}> ?(paragraph|[^\\n]*)(?:\\n|$))+/).replace(\"paragraph\",al).getRegex(),code:/^((?: {4}| {0,3}\\t)[^\\n]+(?:\\n(?:[ \\t]*(?:\\n|$))*)?)+/,def:nl,fences:/^ {0,3}(`{3,}(?=[^`\\n]*(?:\\n|$))|~{3,})([^\\n]*)(?:\\n|$)(?:|([\\s\\S]*?)(?:\\n|$))(?: {0,3}\\1[~`]* *(?=\\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\\s|$)(.*)(?:\\n+|$)/,hr:Ya,html:ol,lheading:Qa,list:il,newline:/^(?:[ \\t]*(?:\\n|$))+/,paragraph:al,table:ja,text:/^[^\\n]+/},cl=Va(\"^ *([^\\\\n ].*)\\\\n {0,3}((?:\\\\| *)?:?-+:? *(?:\\\\| *:?-+:? *)*(?:\\\\| *)?)(?:\\\\n((?:(?! *\\\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\\\n|$))*)\\\\n*|$)\").replace(\"hr\",Ya).replace(\"heading\",\" {0,3}#{1,6}(?:\\\\s|$)\").replace(\"blockquote\",\" {0,3}>\").replace(\"code\",\"(?: {4}| {0,3}\\t)[^\\\\n]\").replace(\"fences\",\" {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~{3,})[^\\\\n]*\\\\n\").replace(\"list\",\" {0,3}(?:[*+-]|1[.)])[ \\\\t]\").replace(\"html\",\"</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)\").replace(\"tag\",sl).getRegex(),dl={...ll,lheading:Za,table:cl,paragraph:Va(el).replace(\"hr\",Ya).replace(\"heading\",\" {0,3}#{1,6}(?:\\\\s|$)\").replace(\"|lheading\",\"\").replace(\"table\",cl).replace(\"blockquote\",\" {0,3}>\").replace(\"fences\",\" {0,3}(?:`{3,}(?=[^`\\\\n]*\\\\n)|~{3,})[^\\\\n]*\\\\n\").replace(\"list\",\" {0,3}(?:[*+-]|1[.)])[ \\\\t]\").replace(\"html\",\"</?(?:tag)(?: +|\\\\n|/?>)|<(?:script|pre|style|textarea|!--)\").replace(\"tag\",sl).getRegex()},ul={...ll,html:Va(\"^ *(?:comment *(?:\\\\n|\\\\s*$)|<(tag)[\\\\s\\\\S]+?</\\\\1> *(?:\\\\n{2,}|\\\\s*$)|<tag(?:\\\"[^\\\"]*\\\"|'[^']*'|\\\\s[^'\\\"/>\\\\s]*)*?/?> *(?:\\\\n{2,}|\\\\s*$))\").replace(\"comment\",rl).replace(/tag/g,\"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\\\b)\\\\w+(?!:|[^\\\\w\\\\s@]*@)\\\\b\").getRegex(),def:/^ *\\[([^\\]]+)\\]: *<?([^\\s>]+)>?(?: +([\"(][^\\n]+[\")]))? *(?:\\n+|$)/,heading:/^(#{1,6})(.*)(?:\\n+|$)/,fences:ja,lheading:/^(.+?)\\n {0,3}(=+|-+) *(?:\\n+|$)/,paragraph:Va(el).replace(\"hr\",Ya).replace(\"heading\",\" *#{1,6} *[^\\n]\").replace(\"lheading\",Qa).replace(\"|table\",\"\").replace(\"blockquote\",\" {0,3}>\").replace(\"|fences\",\"\").replace(\"|list\",\"\").replace(\"|html\",\"\").replace(\"|tag\",\"\").getRegex()},pl=/^( {2,}|\\\\)\\n(?!\\s*$)/,hl=/[\\p{P}\\p{S}]/u,gl=/[\\s\\p{P}\\p{S}]/u,ml=/[^\\s\\p{P}\\p{S}]/u,fl=Va(/^((?![*_])punctSpace)/,\"u\").replace(/punctSpace/g,gl).getRegex(),bl=/(?!~)[\\p{P}\\p{S}]/u,yl=Va(/link|precode-code|html/,\"g\").replace(\"link\",/\\[(?:[^\\[\\]`]|(?<a>`+)[^`]+\\k<a>(?!`))*?\\]\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)]|\\((?:\\\\[\\s\\S]|[^\\\\\\(\\)])*\\))*\\)/).replace(\"precode-\",Ga?\"(?<!`)()\":\"(^^|[^`])\").replace(\"code\",/(?<b>`+)[^`]+\\k<b>(?!`)/).replace(\"html\",/<(?! )[^<>]*?>/).getRegex(),vl=/^(?:\\*+(?:((?!\\*)punct)|([^\\s*]))?)|^_+(?:((?!_)punct)|([^\\s_]))?/,wl=Va(vl,\"u\").replace(/punct/g,hl).getRegex(),xl=Va(vl,\"u\").replace(/punct/g,bl).getRegex(),kl=\"^[^_*]*?__[^_*]*?\\\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\\\*)punct(\\\\*+)(?=[\\\\s]|$)|notPunctSpace(\\\\*+)(?!\\\\*)(?=punctSpace|$)|(?!\\\\*)punctSpace(\\\\*+)(?=notPunctSpace)|[\\\\s](\\\\*+)(?!\\\\*)(?=punct)|(?!\\\\*)punct(\\\\*+)(?!\\\\*)(?=punct)|notPunctSpace(\\\\*+)(?=notPunctSpace)\",Sl=Va(kl,\"gu\").replace(/notPunctSpace/g,ml).replace(/punctSpace/g,gl).replace(/punct/g,hl).getRegex(),Cl=Va(kl,\"gu\").replace(/notPunctSpace/g,/(?:[^\\s\\p{P}\\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\\s\\p{P}\\p{S}]/u).replace(/punct/g,bl).getRegex(),El=Va(\"^[^_*]*?\\\\*\\\\*[^_*]*?_[^_*]*?(?=\\\\*\\\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)\",\"gu\").replace(/notPunctSpace/g,ml).replace(/punctSpace/g,gl).replace(/punct/g,hl).getRegex(),Ml=Va(/^~~?(?:((?!~)punct)|[^\\s~])/,\"u\").replace(/punct/g,hl).getRegex(),Al=Va(\"^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)\",\"gu\").replace(/notPunctSpace/g,ml).replace(/punctSpace/g,gl).replace(/punct/g,hl).getRegex(),_l=Va(/\\\\(punct)/,\"gu\").replace(/punct/g,hl).getRegex(),Tl=Va(/^<(scheme:[^\\s\\x00-\\x1f<>]*|email)>/).replace(\"scheme\",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(\"email\",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Il=Va(rl).replace(\"(?:--\\x3e|$)\",\"--\\x3e\").getRegex(),Ll=Va(\"^comment|^</[a-zA-Z][\\\\w:-]*\\\\s*>|^<[a-zA-Z][\\\\w-]*(?:attribute)*?\\\\s*/?>|^<\\\\?[\\\\s\\\\S]*?\\\\?>|^<![a-zA-Z]+\\\\s[\\\\s\\\\S]*?>|^<!\\\\[CDATA\\\\[[\\\\s\\\\S]*?\\\\]\\\\]>\").replace(\"comment\",Il).replace(\"attribute\",/\\s+[a-zA-Z:_][\\w.:-]*(?:\\s*=\\s*\"[^\"]*\"|\\s*=\\s*'[^']*'|\\s*=\\s*[^\\s\"'=<>`]+)?/).getRegex(),Rl=/(?:\\[(?:\\\\[\\s\\S]|[^\\[\\]\\\\])*\\]|\\\\[\\s\\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\\])|[^\\[\\]\\\\`])*?/,$l=Va(/^!?\\[(label)\\]\\(\\s*(href)(?:(?:[ \\t]+(?:\\n[ \\t]*)?|\\n[ \\t]*)(title))?\\s*\\)/).replace(\"label\",Rl).replace(\"href\",/<(?:\\\\.|[^\\n<>\\\\])+>|[^ \\t\\n\\x00-\\x1f]*/).replace(\"title\",/\"(?:\\\\\"?|[^\"\\\\])*\"|'(?:\\\\'?|[^'\\\\])*'|\\((?:\\\\\\)?|[^)\\\\])*\\)/).getRegex(),Nl=Va(/^!?\\[(label)\\]\\[(ref)\\]/).replace(\"label\",Rl).replace(\"ref\",tl).getRegex(),Pl=Va(/^!?\\[(ref)\\](?:\\[\\])?/).replace(\"ref\",tl).getRegex(),Fl=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Ol={_backpedal:ja,anyPunctuation:_l,autolink:Tl,blockSkip:yl,br:pl,code:/^(`+)([^`]|[^`][\\s\\S]*?[^`])\\1(?!`)/,del:ja,delLDelim:ja,delRDelim:ja,emStrongLDelim:wl,emStrongRDelimAst:Sl,emStrongRDelimUnd:El,escape:/^\\\\([!\"#$%&'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~])/,link:$l,nolink:Pl,punctuation:fl,reflink:Nl,reflinkSearch:Va(\"reflink|nolink(?!\\\\()\",\"g\").replace(\"reflink\",Nl).replace(\"nolink\",Pl).getRegex(),tag:Ll,text:/^(`+|[^`])(?:(?= {2,}\\n)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*_]|\\b_|$)|[^ ](?= {2,}\\n)))/,url:ja},ql={...Ol,link:Va(/^!?\\[(label)\\]\\((.*?)\\)/).replace(\"label\",Rl).getRegex(),reflink:Va(/^!?\\[(label)\\]\\s*\\[([^\\]]*)\\]/).replace(\"label\",Rl).getRegex()},Hl={...Ol,emStrongRDelimAst:Cl,emStrongLDelim:xl,delLDelim:Ml,delRDelim:Al,url:Va(/^((?:protocol):\\/\\/|www\\.)(?:[a-zA-Z0-9\\-]+\\.?)+[^\\s<]*|^email/).replace(\"protocol\",Fl).replace(\"email\",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'\"~()&]+|\\([^)]*\\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'\"~)]+(?!$))+/,del:/^(~~?)(?=[^\\s~])((?:\\\\[\\s\\S]|[^\\\\])*?(?:\\\\[\\s\\S]|[^\\s~\\\\]))\\1(?=[^~]|$)/,text:Va(/^([`~]+|[^`~])(?:(?= {2,}\\n)|(?=[a-zA-Z0-9.!#$%&'*+\\/=?_`{\\|}~-]+@)|[\\s\\S]*?(?:(?=[\\\\<!\\[`*~_]|\\b_|protocol:\\/\\/|www\\.|$)|[^ ](?= {2,}\\n)|[^a-zA-Z0-9.!#$%&'*+\\/=?_`{\\|}~-](?=[a-zA-Z0-9.!#$%&'*+\\/=?_`{\\|}~-]+@)))/).replace(\"protocol\",Fl).getRegex()},Bl={...Hl,br:Va(pl).replace(\"{2,}\",\"*\").getRegex(),text:Va(Hl.text).replace(\"\\\\b_\",\"\\\\b_| {2,}\\\\n\").replace(/\\{2,\\}/g,\"*\").getRegex()},Dl={normal:ll,gfm:dl,pedantic:ul},zl={normal:Ol,gfm:Hl,breaks:Bl,pedantic:ql},Ul={\"&\":\"&amp;\",\"<\":\"&lt;\",\">\":\"&gt;\",'\"':\"&quot;\",\"'\":\"&#39;\"},jl=e=>Ul[e];function Wl(e,t){if(t){if(Ka.escapeTest.test(e))return e.replace(Ka.escapeReplace,jl)}else if(Ka.escapeTestNoEncode.test(e))return e.replace(Ka.escapeReplaceNoEncode,jl);return e}function Vl(e){try{e=encodeURI(e).replace(Ka.percentDecode,\"%\")}catch{return null}return e}function Gl(e,t){let n=e.replace(Ka.findPipe,(e,t,n)=>{let i=!1,s=t;for(;--s>=0&&\"\\\\\"===n[s];)i=!i;return i?\"|\":\" |\"}),i=n.split(Ka.splitPipe),s=0;if(i[0].trim()||i.shift(),i.length>0&&!i.at(-1)?.trim()&&i.pop(),t)if(i.length>t)i.splice(t);else for(;i.length<t;)i.push(\"\");for(;s<i.length;s++)i[s]=i[s].trim().replace(Ka.slashPipe,\"|\");return i}function Kl(e,t,n){let i=e.length;if(0===i)return\"\";let s=0;for(;s<i;){if(e.charAt(i-s-1)!==t)break;s++}return e.slice(0,i-s)}function Yl(e){let t=e.split(\"\\n\"),n=t.length-1;for(;n>=0&&Ka.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(\"\\n\")}function Xl(e,t=0){let n=t,i=\"\";for(let t of e)if(\"\\t\"===t){let e=4-n%4;i+=\" \".repeat(e),n+=e}else i+=t,n++;return i}function Jl(e,t,n,i,s){let r=t.href,o=t.title||null,a=e[1].replace(s.other.outputLinkReplace,\"$1\");i.state.inLink=!0;let l={type:\"!\"===e[0].charAt(0)?\"image\":\"link\",raw:n,href:r,title:o,text:a,tokens:i.inlineTokens(a)};return i.state.inLink=!1,l}var Ql=class{options;rules;lexer;constructor(e){this.options=e||za}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:\"space\",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:Yl(t[0]),n=e.replace(this.rules.other.codeRemoveIndent,\"\");return{type:\"code\",raw:e,codeBlockStyle:\"indented\",text:n}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(null===i)return t;let s=i[1];return t.split(\"\\n\").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[i]=t;return i.length>=s.length?e.slice(s.length):e}).join(\"\\n\")}(e,t[3]||\"\",this.rules);return{type:\"code\",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,\"$1\"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=Kl(e,\"#\");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:\"heading\",raw:Kl(t[0],\"\\n\"),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:\"hr\",raw:Kl(t[0],\"\\n\")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Kl(t[0],\"\\n\").split(\"\\n\"),n=\"\",i=\"\",s=[];for(;e.length>0;){let t,r=!1,o=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))o.push(e[t]),r=!0;else{if(r)break;o.push(e[t])}e=e.slice(t);let a=o.join(\"\\n\"),l=a.replace(this.rules.other.blockquoteSetextReplace,\"\\n    $1\").replace(this.rules.other.blockquoteSetextReplace2,\"\");n=n?`${n}\\n${a}`:a,i=i?`${i}\\n${l}`:l;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,s,!0),this.lexer.state.top=c,0===e.length)break;let d=s.at(-1);if(\"code\"===d?.type)break;if(\"blockquote\"===d?.type){let t=d,r=t.raw+\"\\n\"+e.join(\"\\n\"),o=this.blockquote(r);s[s.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,i=i.substring(0,i.length-t.text.length)+o.text;break}if(\"list\"===d?.type){let t=d,r=t.raw+\"\\n\"+e.join(\"\\n\"),o=this.list(r);s[s.length-1]=o,n=n.substring(0,n.length-d.raw.length)+o.raw,i=i.substring(0,i.length-t.raw.length)+o.raw,e=r.substring(s.at(-1).raw.length).split(\"\\n\");continue}}return{type:\"blockquote\",raw:n,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),i=n.length>1,s={type:\"list\",raw:\"\",ordered:i,start:i?+n.slice(0,-1):\"\",loose:!1,items:[]};n=i?`\\\\d{1,9}\\\\${n.slice(-1)}`:`\\\\${n}`,this.options.pedantic&&(n=i?n:\"[*+-]\");let r=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,i=\"\",a=\"\";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;i=t[0],e=e.substring(i.length);let l=Xl(t[2].split(\"\\n\",1)[0],t[1].length),c=e.split(\"\\n\",1)[0],d=!l.trim(),u=0;if(this.options.pedantic?(u=2,a=l.trimStart()):d?u=t[1].length+1:(u=l.search(this.rules.other.nonSpaceChar),u=u>4?1:u,a=l.slice(u),u+=t[1].length),d&&this.rules.other.blankLine.test(c)&&(i+=c+\"\\n\",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(u),n=this.rules.other.hrRegex(u),s=this.rules.other.fencesBeginRegex(u),r=this.rules.other.headingBeginRegex(u),o=this.rules.other.htmlBeginRegex(u),p=this.rules.other.blockquoteBeginRegex(u);for(;e;){let h,g=e.split(\"\\n\",1)[0];if(c=g,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting,\"  \"),h=c):h=c.replace(this.rules.other.tabCharGlobal,\"    \"),s.test(c)||r.test(c)||o.test(c)||p.test(c)||t.test(c)||n.test(c))break;if(h.search(this.rules.other.nonSpaceChar)>=u||!c.trim())a+=\"\\n\"+h.slice(u);else{if(d||l.replace(this.rules.other.tabCharGlobal,\"    \").search(this.rules.other.nonSpaceChar)>=4||s.test(l)||r.test(l)||n.test(l))break;a+=\"\\n\"+c}d=!c.trim(),i+=g+\"\\n\",e=e.substring(g.length+1),l=h.slice(u)}}s.loose||(o?s.loose=!0:this.rules.other.doubleBlankLine.test(i)&&(o=!0)),s.items.push({type:\"list_item\",raw:i,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]}),s.raw+=i}let a=s.items.at(-1);if(!a)return;a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd(),s.raw=s.raw.trimEnd();for(let e of s.items){this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]);let t=e.tokens[0];if(!e.task||\"text\"!==t?.type&&\"paragraph\"!==t?.type)e.task&&(e.task=!1);else{e.text=e.text.replace(this.rules.other.listReplaceTask,\"\"),t.raw=t.raw.replace(this.rules.other.listReplaceTask,\"\"),t.text=t.text.replace(this.rules.other.listReplaceTask,\"\");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,\"\");break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:\"checkbox\",raw:n[0]+\" \",checked:\"[ ]\"!==n[0]};e.checked=t.checked,s.loose?e.tokens[0]&&[\"paragraph\",\"text\"].includes(e.tokens[0].type)&&\"tokens\"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:\"paragraph\",raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}if(!s.loose){let t=e.tokens.filter(e=>\"space\"===e.type),n=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw));s.loose=n}}if(s.loose)for(let e of s.items){e.loose=!0;for(let t of e.tokens)\"text\"===t.type&&(t.type=\"paragraph\")}return s}}html(e){let t=this.rules.block.html.exec(e);if(t){let e=Yl(t[0]);return{type:\"html\",block:!0,raw:e,pre:\"pre\"===t[1]||\"script\"===t[1]||\"style\"===t[1],text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,\" \"),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,\"$1\").replace(this.rules.inline.anyPunctuation,\"$1\"):\"\",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,\"$1\"):t[3];return{type:\"def\",tag:e,raw:Kl(t[0],\"\\n\"),href:n,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Gl(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,\"\").split(\"|\"),s=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,\"\").split(\"\\n\"):[],r={type:\"table\",raw:Kl(t[0],\"\\n\"),header:[],align:[],rows:[]};if(n.length===i.length){for(let e of i)this.rules.other.tableAlignRight.test(e)?r.align.push(\"right\"):this.rules.other.tableAlignCenter.test(e)?r.align.push(\"center\"):this.rules.other.tableAlignLeft.test(e)?r.align.push(\"left\"):r.align.push(null);for(let e=0;e<n.length;e++)r.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:r.align[e]});for(let e of s)r.rows.push(Gl(e,r.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:r.align[t]})));return r}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:\"heading\",raw:Kl(t[0],\"\\n\"),depth:\"=\"===t[2].charAt(0)?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=\"\\n\"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:\"paragraph\",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:\"text\",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:\"escape\",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:\"html\",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=Kl(e.slice(0,-1),\"\\\\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let i=0;i<e.length;i++)if(\"\\\\\"===e[i])i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}(t[2],\"()\");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf(\"!\")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=\"\"}}let n=t[2],i=\"\";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],i=e[3])}else i=t[3]?t[3].slice(1,-1):\"\";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),Jl(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,\"$1\"),title:i&&i.replace(this.rules.inline.anyPunctuation,\"$1\")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,\" \").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:\"text\",raw:e,text:e}}return Jl(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=\"\"){let i=this.rules.inline.emStrongLDelim.exec(e);if(i&&(i[1]||i[2]||i[3]||i[4])&&(!i[4]||!n.match(this.rules.other.unicodeAlphaNumeric))&&(!i[1]&&!i[3]||!n||this.rules.inline.punctuation.exec(n))){let n,s,r=[...i[0]].length-1,o=r,a=0,l=\"*\"===i[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+r);null!==(i=l.exec(t));){if(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!n)continue;if(s=[...n].length,i[3]||i[4]){o+=s;continue}if((i[5]||i[6])&&r%3&&!((r+s)%3)){a+=s;continue}if(o-=s,o>0)continue;s=Math.min(s,s+o+a);let t=[...i[0]][0].length,l=e.slice(0,r+i.index+t+s);if(Math.min(r,s)%2){let e=l.slice(1,-1);return{type:\"em\",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}let c=l.slice(2,-2);return{type:\"strong\",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,\" \"),n=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&i&&(e=e.substring(1,e.length-1)),{type:\"codespan\",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:\"br\",raw:t[0]}}del(e,t,n=\"\"){let i=this.rules.inline.delLDelim.exec(e);if(i&&(!i[1]||!n||this.rules.inline.punctuation.exec(n))){let n,s,r=[...i[0]].length-1,o=r,a=this.rules.inline.delRDelim;for(a.lastIndex=0,t=t.slice(-1*e.length+r);null!==(i=a.exec(t));){if(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!n||(s=[...n].length,s!==r))continue;if(i[3]||i[4]){o+=s;continue}if(o-=s,o>0)continue;s=Math.min(s,s+o);let t=[...i[0]][0].length,a=e.slice(0,r+i.index+t+s),l=a.slice(r,-r);return{type:\"del\",raw:a,text:l,tokens:this.lexer.inlineTokens(l)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return\"@\"===t[2]?(e=t[1],n=\"mailto:\"+e):(e=t[1],n=e),{type:\"link\",raw:t[0],text:e,href:n,tokens:[{type:\"text\",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(\"@\"===t[2])e=t[0],n=\"mailto:\"+e;else{let i;do{i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??\"\"}while(i!==t[0]);e=t[0],n=\"www.\"===t[1]?\"http://\"+t[0]:t[0]}return{type:\"link\",raw:t[0],text:e,href:n,tokens:[{type:\"text\",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:\"text\",raw:t[0],text:t[0],escaped:e}}}},Zl=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||za,this.options.tokenizer=this.options.tokenizer||new Ql,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:Ka,block:Dl.normal,inline:zl.normal};this.options.pedantic?(t.block=Dl.pedantic,t.inline=zl.pedantic):this.options.gfm&&(t.block=Dl.gfm,this.options.breaks?t.inline=zl.breaks:t.inline=zl.gfm),this.tokenizer.rules=t}static get rules(){return{block:Dl,inline:zl}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(Ka.carriageReturn,\"\\n\"),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Ka.tabCharGlobal,\"    \").replace(Ka.spaceLine,\"\"));let i=1/0;for(;e;){if(!(e.length<i)){this.infiniteLoopError(e.charCodeAt(0));break}let s;if(i=e.length,this.options.extensions?.block?.some(n=>!!(s=n.call({lexer:this},e,t))&&(e=e.substring(s.raw.length),t.push(s),!0)))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);let n=t.at(-1);1===s.raw.length&&void 0!==n?n.raw+=\"\\n\":t.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);let n=t.at(-1);\"paragraph\"===n?.type||\"text\"===n?.type?(n.raw+=(n.raw.endsWith(\"\\n\")?\"\":\"\\n\")+s.raw,n.text+=\"\\n\"+s.text,this.inlineQueue.at(-1).src=n.text):t.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);let n=t.at(-1);\"paragraph\"===n?.type||\"text\"===n?.type?(n.raw+=(n.raw.endsWith(\"\\n\")?\"\":\"\\n\")+s.raw,n.text+=\"\\n\"+s.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title},t.push(s));continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),t.push(s);continue}let r=e;if(this.options.extensions?.startBlock){let t,n=1/0,i=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},i),\"number\"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(r=e.substring(0,n+1))}if(this.state.top&&(s=this.tokenizer.paragraph(r))){let i=t.at(-1);n&&\"paragraph\"===i?.type?(i.raw+=(i.raw.endsWith(\"\\n\")?\"\":\"\\n\")+s.raw,i.text+=\"\\n\"+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):t.push(s),n=r.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);let n=t.at(-1);\"text\"===n?.type?(n.raw+=(n.raw.endsWith(\"\\n\")?\"\":\"\\n\")+s.raw,n.text+=\"\\n\"+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(s);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n,i=e,s=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!==(s=this.tokenizer.rules.inline.reflinkSearch.exec(i));)e.includes(s[0].slice(s[0].lastIndexOf(\"[\")+1,-1))&&(i=i.slice(0,s.index)+\"[\"+\"a\".repeat(s[0].length-2)+\"]\"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!==(s=this.tokenizer.rules.inline.anyPunctuation.exec(i));)i=i.slice(0,s.index)+\"++\"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!==(s=this.tokenizer.rules.inline.blockSkip.exec(i));)n=s[2]?s[2].length:0,i=i.slice(0,s.index+n)+\"[\"+\"a\".repeat(s[0].length-n-2)+\"]\"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let r=!1,o=\"\",a=1/0;for(;e;){if(!(e.length<a)){this.infiniteLoopError(e.charCodeAt(0));break}let n;if(a=e.length,r||(o=\"\"),r=!1,this.options.extensions?.inline?.some(i=>!!(n=i.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))continue;if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length);let i=t.at(-1);\"text\"===n.type&&\"text\"===i?.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,i,o)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e,i,o)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}let s=e;if(this.options.extensions?.startInline){let t,n=1/0,i=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},i),\"number\"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(n=this.tokenizer.inlineText(s)){e=e.substring(n.raw.length),\"_\"!==n.raw.slice(-1)&&(o=n.raw.slice(-1)),r=!0;let i=t.at(-1);\"text\"===i?.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return t}infiniteLoopError(e){let t=\"Infinite loop on byte: \"+e;if(!this.options.silent)throw new Error(t);console.error(t)}},ec=class{options;parser;constructor(e){this.options=e||za}space(e){return\"\"}code({text:e,lang:t,escaped:n}){let i=(t||\"\").match(Ka.notSpaceStart)?.[0],s=e.replace(Ka.endingNewline,\"\")+\"\\n\";return i?'<pre><code class=\"language-'+Wl(i)+'\">'+(n?s:Wl(s,!0))+\"</code></pre>\\n\":\"<pre><code>\"+(n?s:Wl(s,!0))+\"</code></pre>\\n\"}blockquote({tokens:e}){return`<blockquote>\\n${this.parser.parse(e)}</blockquote>\\n`}html({text:e}){return e}def(e){return\"\"}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\\n`}hr(e){return\"<hr>\\n\"}list(e){let t=e.ordered,n=e.start,i=\"\";for(let t=0;t<e.items.length;t++){let n=e.items[t];i+=this.listitem(n)}let s=t?\"ol\":\"ul\";return\"<\"+s+(t&&1!==n?' start=\"'+n+'\"':\"\")+\">\\n\"+i+\"</\"+s+\">\\n\"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\\n`}checkbox({checked:e}){return\"<input \"+(e?'checked=\"\" ':\"\")+'disabled=\"\" type=\"checkbox\"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\\n`}table(e){let t=\"\",n=\"\";for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let i=\"\";for(let t=0;t<e.rows.length;t++){let s=e.rows[t];n=\"\";for(let e=0;e<s.length;e++)n+=this.tablecell(s[e]);i+=this.tablerow({text:n})}return i&&(i=`<tbody>${i}</tbody>`),\"<table>\\n<thead>\\n\"+t+\"</thead>\\n\"+i+\"</table>\\n\"}tablerow({text:e}){return`<tr>\\n${e}</tr>\\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?\"th\":\"td\";return(e.align?`<${n} align=\"${e.align}\">`:`<${n}>`)+t+`</${n}>\\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Wl(e,!0)}</code>`}br(e){return\"<br>\"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let i=this.parser.parseInline(n),s=Vl(e);if(null===s)return i;let r='<a href=\"'+(e=s)+'\"';return t&&(r+=' title=\"'+Wl(t)+'\"'),r+=\">\"+i+\"</a>\",r}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=Vl(e);if(null===s)return Wl(n);let r=`<img src=\"${e=s}\" alt=\"${Wl(n)}\"`;return t&&(r+=` title=\"${Wl(t)}\"`),r+=\">\",r}text(e){return\"tokens\"in e&&e.tokens?this.parser.parseInline(e.tokens):\"escaped\"in e&&e.escaped?e.text:Wl(e.text)}},tc=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return\"\"+e}image({text:e}){return\"\"+e}br(){return\"\"}checkbox({raw:e}){return e}},nc=class e{options;renderer;textRenderer;constructor(e){this.options=e||za,this.options.renderer=this.options.renderer||new ec,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new tc}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=\"\";for(let n=0;n<e.length;n++){let i=e[n];if(this.options.extensions?.renderers?.[i.type]){let e=i,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==n||![\"space\",\"hr\",\"heading\",\"code\",\"table\",\"blockquote\",\"list\",\"html\",\"def\",\"paragraph\",\"text\"].includes(e.type)){t+=n||\"\";continue}}let s=i;switch(s.type){case\"space\":t+=this.renderer.space(s);break;case\"hr\":t+=this.renderer.hr(s);break;case\"heading\":t+=this.renderer.heading(s);break;case\"code\":t+=this.renderer.code(s);break;case\"table\":t+=this.renderer.table(s);break;case\"blockquote\":t+=this.renderer.blockquote(s);break;case\"list\":t+=this.renderer.list(s);break;case\"checkbox\":t+=this.renderer.checkbox(s);break;case\"html\":t+=this.renderer.html(s);break;case\"def\":t+=this.renderer.def(s);break;case\"paragraph\":t+=this.renderer.paragraph(s);break;case\"text\":t+=this.renderer.text(s);break;default:{let e='Token with \"'+s.type+'\" type was not found.';if(this.options.silent)return console.error(e),\"\";throw new Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=\"\";for(let i=0;i<e.length;i++){let s=e[i];if(this.options.extensions?.renderers?.[s.type]){let e=this.options.extensions.renderers[s.type].call({parser:this},s);if(!1!==e||![\"escape\",\"html\",\"link\",\"image\",\"strong\",\"em\",\"codespan\",\"br\",\"del\",\"text\"].includes(s.type)){n+=e||\"\";continue}}let r=s;switch(r.type){case\"escape\":case\"text\":n+=t.text(r);break;case\"html\":n+=t.html(r);break;case\"link\":n+=t.link(r);break;case\"image\":n+=t.image(r);break;case\"checkbox\":n+=t.checkbox(r);break;case\"strong\":n+=t.strong(r);break;case\"em\":n+=t.em(r);break;case\"codespan\":n+=t.codespan(r);break;case\"br\":n+=t.br(r);break;case\"del\":n+=t.del(r);break;default:{let e='Token with \"'+r.type+'\" type was not found.';if(this.options.silent)return console.error(e),\"\";throw new Error(e)}}}return n}},ic=class{options;block;constructor(e){this.options=e||za}static passThroughHooks=new Set([\"preprocess\",\"postprocess\",\"processAllTokens\",\"emStrongMask\"]);static passThroughHooksRespectAsync=new Set([\"preprocess\",\"postprocess\",\"processAllTokens\"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?Zl.lex:Zl.lexInline}provideParser(e=this.block){return e?nc.parse:nc.parseInline}},sc=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=nc;Renderer=ec;TextRenderer=tc;Lexer=Zl;Tokenizer=Ql;Hooks=ic;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let i of e)switch(n=n.concat(t.call(this,i)),i.type){case\"table\":{let e=i;for(let i of e.header)n=n.concat(this.walkTokens(i.tokens,t));for(let i of e.rows)for(let e of i)n=n.concat(this.walkTokens(e.tokens,t));break}case\"list\":{let e=i;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=i;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(i=>{let s=e[i].flat(1/0);n=n.concat(this.walkTokens(s,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error(\"extension name required\");if(\"renderer\"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let i=e.renderer.apply(this,t);return!1===i&&(i=n.apply(this,t)),i}:e.renderer}if(\"tokenizer\"in e){if(!e.level||\"block\"!==e.level&&\"inline\"!==e.level)throw new Error(\"extension level must be 'block' or 'inline'\");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(\"block\"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:\"inline\"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}\"childTokens\"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new ec(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if([\"options\",\"parser\"].includes(n))continue;let i=n,s=e.renderer[i],r=t[i];t[i]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n||\"\"}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Ql(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if([\"options\",\"rules\",\"lexer\"].includes(n))continue;let i=n,s=e.tokenizer[i],r=t[i];t[i]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new ic;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if([\"options\",\"block\"].includes(n))continue;let i=n,s=e.hooks[i],r=t[i];ic.passThroughHooks.has(n)?t[i]=e=>{if(this.defaults.async&&ic.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await s.call(t,e);return r.call(t,n)})();let i=s.call(t,e);return r.call(t,i)}:t[i]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await s.apply(t,e);return!1===n&&(n=await r.apply(t,e)),n})();let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,i=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(i.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Zl.lex(e,t??this.defaults)}parser(e,t){return nc.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},s={...this.defaults,...i},r=this.onError(!!s.silent,!!s.async);if(!0===this.defaults.async&&!1===i.async)return r(new Error(\"marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.\"));if(typeof t>\"u\"||null===t)return r(new Error(\"marked(): input parameter is undefined or null\"));if(\"string\"!=typeof t)return r(new Error(\"marked(): input parameter is of type \"+Object.prototype.toString.call(t)+\", string expected\"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let n=s.hooks?await s.hooks.preprocess(t):t,i=await(s.hooks?await s.hooks.provideLexer(e):e?Zl.lex:Zl.lexInline)(n,s),r=s.hooks?await s.hooks.processAllTokens(i):i;s.walkTokens&&await Promise.all(this.walkTokens(r,s.walkTokens));let o=await(s.hooks?await s.hooks.provideParser(e):e?nc.parse:nc.parseInline)(r,s);return s.hooks?await s.hooks.postprocess(o):o})().catch(r);try{s.hooks&&(t=s.hooks.preprocess(t));let n=(s.hooks?s.hooks.provideLexer(e):e?Zl.lex:Zl.lexInline)(t,s);s.hooks&&(n=s.hooks.processAllTokens(n)),s.walkTokens&&this.walkTokens(n,s.walkTokens);let i=(s.hooks?s.hooks.provideParser(e):e?nc.parse:nc.parseInline)(n,s);return s.hooks&&(i=s.hooks.postprocess(i)),i}catch(e){return r(e)}}}onError(e,t){return n=>{if(n.message+=\"\\nPlease report this to https://github.com/markedjs/marked.\",e){let e=\"<p>An error occurred:</p><pre>\"+Wl(n.message+\"\",!0)+\"</pre>\";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function rc(e,t){return sc.parse(e,t)}rc.options=rc.setOptions=function(e){return sc.setOptions(e),rc.defaults=sc.defaults,Ua(rc.defaults),rc},rc.getDefaults=Da,rc.defaults=za,rc.use=function(...e){return sc.use(...e),rc.defaults=sc.defaults,Ua(rc.defaults),rc},rc.walkTokens=function(e,t){return sc.walkTokens(e,t)},rc.parseInline=sc.parseInline,rc.Parser=nc,rc.parser=nc.parse,rc.Renderer=ec,rc.TextRenderer=tc,rc.Lexer=Zl,rc.lexer=Zl.lex,rc.Tokenizer=Ql,rc.Hooks=ic,rc.parse=rc,rc.options,rc.setOptions,rc.use,rc.walkTokens,rc.parseInline,nc.parse,Zl.lex;const oc=new Set([\"http:\",\"https:\",\"mailto:\",\"tel:\",\"ftp:\"]);function ac(e){return e.replace(/[&<>\"']/g,e=>\"&\"===e?\"&amp;\":\"<\"===e?\"&lt;\":\">\"===e?\"&gt;\":'\"'===e?\"&quot;\":\"&#39;\")}function lc(e){try{return oc.has(new URL(e,\"https://markdown.invalid\").protocol)}catch{return!1}}const cc=new rc.Renderer;function dc(e){return rc.parse(e,{async:!1,renderer:cc})}function uc(e){return rc.parseInline(e,{async:!1,renderer:cc})}cc.html=({text:e})=>ac(e),cc.link=({href:e,title:t,tokens:n})=>{const i=cc.parser.parseInline(n);if(!lc(e))return i;const s=t?` title=\"${ac(t)}\"`:\"\";return`<a href=\"${ac(e)}\"${s}>${i}</a>`},cc.image=({href:e,title:t,text:n,tokens:i})=>{const s=i?cc.parser.parseInline(i,cc.parser.textRenderer):n;if(!lc(e))return ac(s);const r=t?` title=\"${ac(t)}\"`:\"\";return`<img src=\"${ac(e)}\" alt=\"${ac(s)}\"${r}>`},rc.setOptions({breaks:!0,gfm:!0});const pc=/<\\/(?:p|li|h[1-6]|blockquote|pre|tr|ul|ol)>|<br\\s*\\/?>/gi;class hc{constructor(e){this.starRating=null,this.cardElement=null,this.translations=e}render(e){const t=document.createElement(\"div\");t.className=\"support-interactive-card\",e.resolved&&t.classList.add(\"resolved\");let n=\"\";e.body&&(n+=`<div class=\"support-interactive-body\">${dc(e.body)}</div>`);const i=this.groupDecisionsByType(e.decisions);if(n+=this.renderDecisionGroups(i,e),e.commentField?.enabled&&!e.resolved&&(n+=this.renderCommentField(e.commentField)),!e.resolved){const t=e.decisions.some(e=>[\"radio\",\"checkbox\",\"multi_select\",\"text_input\",\"star\"].includes(e.input_type)),i=e.decisions.some(e=>[\"checkbox\",\"multi_select\"].includes(e.input_type));(t||e.commentField?.enabled)&&(n+=this.renderSubmitButtons(e,!i))}return t.innerHTML=n,this.cardElement=t,e.resolved&&e.resolvedDecision&&this.markSelectedDecisions(t,e.resolvedDecision),e.resolved||this.attachEventHandlers(t,e),t}showResolved(e,t){e.classList.add(\"resolved\");(Array.isArray(t)?t:t.split(\",\")).forEach(t=>{const n=t.trim(),i=e.querySelector(`.support-image-card[data-immediate-action=\"${n}\"], .support-image-card[data-button-value=\"${n}\"]`);i&&i.classList.add(\"selected\");const s=e.querySelector(`.support-interactive-button[data-immediate-action=\"${n}\"], .support-interactive-button[data-button-value=\"${n}\"]`);s&&s.classList.add(\"selected\");const r=e.querySelector(`input[type=\"radio\"][value=\"${n}\"]`);r&&(r.checked=!0,r.closest(\".support-radio-option\")?.classList.add(\"selected\"));const o=e.querySelector(`[data-checkbox-card=\"${n}\"]`);if(o){o.classList.add(\"selected\");const e=o.querySelector(\"[data-checkbox-input]\");e&&(e.checked=!0)}}),e.querySelectorAll(\".support-interactive-buttons\").forEach(e=>os(e))}markSelectedDecisions(e,t){(Array.isArray(t)?t:t.split(\",\")).forEach(t=>{const n=t.trim(),i=e.querySelector(`.support-image-card[data-immediate-action=\"${n}\"], .support-image-card[data-button-value=\"${n}\"]`);i&&i.classList.add(\"selected\");const s=e.querySelector(`.support-interactive-button[data-immediate-action=\"${n}\"], .support-interactive-button[data-button-value=\"${n}\"]`);s&&s.classList.add(\"selected\");const r=e.querySelector(`input[type=\"radio\"][value=\"${n}\"]`);r&&(r.checked=!0,r.closest(\".support-radio-option\")?.classList.add(\"selected\"));const o=e.querySelector(`[data-checkbox-card=\"${n}\"]`);if(o){o.classList.add(\"selected\");const e=o.querySelector(\"[data-checkbox-input]\");e&&(e.checked=!0)}})}groupDecisionsByType(e){const t=new Map;return e.forEach(e=>{const n=e.input_type,i=t.get(n);i?i.push(e):t.set(n,[e])}),t}renderDecisionGroups(e,t){let n=\"\";const i=e.get(\"button\");i?.length&&(n+=this.renderButtonGroup(i,t));const s=e.get(\"star\");s?.length&&(n+=this.renderStarRating(s));const r=e.get(\"radio\");r?.length&&(n+=this.renderRadioGroup(r));const o=e.get(\"checkbox\");o?.length&&(n+=this.renderCheckboxGroup(o,\"checkbox\"));const a=e.get(\"multi_select\");a?.length&&(n+=this.renderCheckboxGroup(a,\"multi_select\"));const l=e.get(\"text_input\");return l?.length&&(n+=this.renderTextInputs(l)),n}renderButtonGroup(e,t){const n=t.decisions.every(e=>\"button\"===e.input_type),i=e.some(e=>e.image_url),s=n?\"data-immediate-action\":\"data-button-value\";if(i){return`<div class=\"support-interactive-button-group image-grid\">${e.map(e=>{const t=e.image_url?`<div class=\"support-image-card-image\">\\n              <img src=\"${this.escapeHtml(e.image_url)}\" alt=\"${this.escapeHtml(e.label)}\" loading=\"lazy\" />\\n              <button class=\"support-image-card-expand\" data-lightbox-url=\"${this.escapeHtml(e.image_url)}\" data-lightbox-label=\"${this.escapeHtml(e.label)}\" type=\"button\">\\n                <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M21 3h-6v2h3.59l-4.3 4.29 1.42 1.42L20 6.41V10h2V3zM3 21h6v-2H5.41l4.3-4.29-1.42-1.42L4 17.59V14H2v7z\"/></svg>\\n              </button>\\n            </div>`:'<div class=\"support-image-card-image support-image-card-placeholder\"></div>';return`\\n          <div class=\"support-image-card\" ${s}=\"${e.value}\">\\n            ${t}\\n            <div class=\"support-image-card-label\">${this.escapeHtml(e.label)}</div>\\n          </div>\\n        `}).join(\"\")}</div>`}if(e.length>2){return`<div class=\"support-interactive-button-group stacked\">${e.map(e=>`<button class=\"support-interactive-button stacked-button\" ${s}=\"${e.value}\">${this.escapeHtml(e.label)}</button>`).join(\"\")}</div>`}return`<div class=\"support-interactive-button-group horizontal\">${e.map(e=>`<button class=\"support-interactive-button pill ${e.style||\"secondary\"}\" ${s}=\"${e.value}\">${this.escapeHtml(e.label)}</button>`).join(\"\")}</div>`}renderStarRating(e){const t=e.map(e=>`\\n        <button class=\"support-interactive-star\" data-star-value=\"${e.value}\" aria-label=\"Rate ${e.value} star${1!==parseInt(e.value)?\"s\":\"\"}\">\\n          <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n            <path d=\"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z\"/>\\n          </svg>\\n        </button>\\n      `).join(\"\");return`<div class=\"support-interactive-stars\" role=\"radiogroup\" aria-label=\"${this.translations.aria.rating}\">${t}</div>`}renderRadioGroup(e){const t=`radio-${s()}`,n=e.map((e,n)=>{const i=`${t}-${n}`,s=e.required?\"required\":\"\";return`\\n        <div class=\"support-radio-option ${e.image_url?\"has-image\":\"\"}\">\\n          ${e.image_url?this.renderThumbnail(e.image_url,e.label):\"\"}\\n          <div class=\"support-radio-content\">\\n            <input type=\"radio\" id=\"${i}\" name=\"${t}\" value=\"${e.value}\" ${s} data-radio-input>\\n            <label for=\"${i}\">${this.escapeHtml(e.label)}</label>\\n          </div>\\n        </div>\\n      `}).join(\"\");return`<div class=\"support-radio-group\" data-input-group=\"radio\">${n}</div>`}renderCheckboxGroup(e,t){const n=e.some(e=>e.image_url);if(n){return`<div class=\"support-interactive-button-group image-grid\" data-input-group=\"${t}\">${e.map(e=>{const t=e.image_url?`<div class=\"support-image-card-image\">\\n              <img src=\"${this.escapeHtml(e.image_url)}\" alt=\"${this.escapeHtml(e.label)}\" loading=\"lazy\" />\\n              <button class=\"support-image-card-expand\" data-lightbox-url=\"${this.escapeHtml(e.image_url)}\" data-lightbox-label=\"${this.escapeHtml(e.label)}\" type=\"button\">\\n                <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M21 3h-6v2h3.59l-4.3 4.29 1.42 1.42L20 6.41V10h2V3zM3 21h6v-2H5.41l4.3-4.29-1.42-1.42L4 17.59V14H2v7z\"/></svg>\\n              </button>\\n            </div>`:'<div class=\"support-image-card-image support-image-card-placeholder\"></div>';return`\\n          <div class=\"support-image-card\" data-checkbox-card=\"${e.value}\">\\n            <input type=\"checkbox\" value=\"${e.value}\" data-checkbox-input style=\"display: none;\">\\n            ${t}\\n            <div class=\"support-image-card-label\">${this.escapeHtml(e.label)}</div>\\n          </div>\\n        `}).join(\"\")}</div>`}return`<div class=\"support-interactive-button-group stacked\" data-input-group=\"${t}\">${e.map(e=>`\\n        <div class=\"support-interactive-button stacked-button\" data-checkbox-card=\"${e.value}\">\\n          <input type=\"checkbox\" value=\"${e.value}\" data-checkbox-input style=\"display: none;\">\\n          ${this.escapeHtml(e.label)}\\n        </div>\\n      `).join(\"\")}</div>`}renderTextInputs(e){return e.map(e=>{const t=e.required?\"required\":\"\",n=e.placeholder||\"\";return`\\n        <input type=\"text\"\\n          class=\"support-text-input\"\\n          placeholder=\"${this.escapeHtml(n)}\"\\n          data-text-input=\"${e.value}\"\\n          ${t}\\n        >\\n      `}).join(\"\")}renderCommentField(e){const t=e.required?\"required\":\"\",n=e.placeholder||\"\";return`\\n      <textarea\\n        class=\"support-interactive-comment\"\\n        placeholder=\"${this.escapeHtml(n)}\"\\n        data-comment-field\\n        ${t}\\n      ></textarea>\\n    `}renderSubmitButtons(e,t=!0){const n=e.submitLabel||this.translations.systemActions.interactive.submit,i=e.skipLabel||this.translations.systemActions.interactive.skip,s=!1!==e.canDismiss&&t;let r='<div class=\"support-interactive-buttons\">';return r+=`<button class=\"support-interactive-submit\" disabled data-submit-btn>${this.escapeHtml(n)}</button>`,s&&(r+=`<button class=\"support-interactive-skip\" data-skip-btn>${this.escapeHtml(i)}</button>`),r+=\"</div>\",r}attachEventHandlers(e,t){this.attachImmediateButtonHandlers(e,t),this.attachStarHandlers(e),this.attachRadioHandlers(e),this.attachCheckboxHandlers(e),this.attachTextInputHandlers(e),this.attachSubmitHandler(e,t),this.attachSkipHandler(e),this.attachImageLightboxHandlers(e),this.updateSubmitButtonState(e,t)}attachImmediateButtonHandlers(e,t){e.querySelectorAll(\"[data-immediate-action]\").forEach(t=>{t.addEventListener(\"click\",()=>{const n=t.getAttribute(\"data-immediate-action\");n&&(this.showResolved(e,n),this.dispatchSubmit(e,{decision:n}))})})}attachStarHandlers(e){const t=e.querySelectorAll(\".support-interactive-star\"),n=e.querySelector(\".support-interactive-stars\");t.forEach((n,i)=>{const s=n;s.addEventListener(\"mouseenter\",()=>{s.disabled||t.forEach((e,t)=>{t<=i?e.classList.add(\"hovered\"):e.classList.remove(\"hovered\")})}),s.addEventListener(\"click\",()=>{this.starRating=s.getAttribute(\"data-star-value\"),t.forEach((e,t)=>{t<=i?e.classList.add(\"active\"):e.classList.remove(\"active\")}),this.updateSubmitButtonState(e)})}),n?.addEventListener(\"mouseleave\",()=>{t.forEach(e=>e.classList.remove(\"hovered\"))})}attachRadioHandlers(e){e.querySelectorAll(\"[data-radio-input]\").forEach(t=>{t.addEventListener(\"change\",()=>{this.updateSubmitButtonState(e)})})}attachCheckboxHandlers(e){e.querySelectorAll(\"[data-checkbox-card]\").forEach(t=>{t.addEventListener(\"click\",n=>{if(n.target.closest(\"[data-lightbox-url]\"))return;const i=t.querySelector(\"[data-checkbox-input]\");i&&(i.checked=!i.checked,t.classList.toggle(\"selected\",i.checked),this.updateSubmitButtonState(e))})});e.querySelectorAll(\"[data-checkbox-input]:not([data-checkbox-card] [data-checkbox-input])\").forEach(t=>{t.addEventListener(\"change\",()=>{this.updateSubmitButtonState(e)})})}attachTextInputHandlers(e){e.querySelectorAll(\"[data-text-input]\").forEach(t=>{t.addEventListener(\"input\",()=>{this.updateSubmitButtonState(e)})})}attachSubmitHandler(e,t){const n=e.querySelector(\"[data-submit-btn]\");n?.addEventListener(\"click\",()=>{const n=this.collectFormData(e,t);n&&(this.showResolved(e,n.decision),this.dispatchSubmit(e,n))})}attachSkipHandler(e){const t=e.querySelector(\"[data-skip-btn]\");t?.addEventListener(\"click\",()=>{this.showResolved(e,\"skip\"),this.dispatchSubmit(e,{decision:\"skip\"})})}updateSubmitButtonState(e,t){const n=e.querySelector(\"[data-submit-btn]\");if(!n)return;const i=this.hasValidInput(e,t);n.disabled=!i}hasValidInput(e,t){if(this.starRating)return!0;if(e.querySelector(\"[data-radio-input]:checked\"))return!0;if(e.querySelectorAll(\"[data-checkbox-input]:checked\").length>0)return!0;const n=e.querySelectorAll(\"[data-text-input]\");let i=!1;if(n.forEach(e=>{e.value.trim()&&(i=!0)}),i)return!0;return!!e.querySelector(\".support-interactive-button.selected\")}collectFormData(e,t){const n=[];this.starRating&&n.push(this.starRating);const i=e.querySelector(\"[data-radio-input]:checked\");i&&n.push(i.value);e.querySelectorAll(\"[data-checkbox-input]:checked\").forEach(e=>{n.push(e.value)});const s=e.querySelectorAll(\"[data-text-input]\");s.forEach(e=>{e.value.trim()&&n.push(e.value.trim())});let r=!1;if(s.forEach(e=>{e.required&&!e.value.trim()?(e.classList.add(\"error\"),r=!0):e.classList.remove(\"error\")}),r)return null;const o=e.querySelector(\"[data-comment-field]\"),a=o?.value?.trim()||void 0;if(o?.required&&!a)return o.classList.add(\"error\"),null;const l=null!==e.querySelector(\"[data-checkbox-input]\")&&n.length>0?n:n[0]||\"\";return(Array.isArray(l)?0!==l.length:l)?{decision:l,comment:a}:null}disable(e){const t=e||this.cardElement;if(!t)return;t.classList.add(\"resolved\");t.querySelectorAll(\"button\").forEach(e=>{e.disabled=!0});t.querySelectorAll(\"input, textarea\").forEach(e=>{e.disabled=!0})}dispatchSubmit(e,t){const n=new CustomEvent(\"interactive-submit\",{detail:t,bubbles:!0});e.dispatchEvent(n)}escapeHtml(e){const t=document.createElement(\"div\");return t.textContent=e,t.innerHTML}renderThumbnail(e,t){return`\\n      <div class=\"support-interactive-thumbnail\" data-lightbox-url=\"${this.escapeHtml(e)}\">\\n        <img src=\"${this.escapeHtml(e)}\" alt=\"${this.escapeHtml(t)}\" loading=\"lazy\" />\\n      </div>\\n    `}attachImageLightboxHandlers(e){e.querySelectorAll(\"[data-lightbox-url]\").forEach(e=>{e.addEventListener(\"click\",t=>{t.stopPropagation(),t.preventDefault();const n=e.getAttribute(\"data-lightbox-url\"),i=e.getAttribute(\"data-lightbox-label\")||void 0;n&&Ba.getInstance().open(n,i)})})}}const gc=[\"audio/webm;codecs=opus\",\"audio/webm\",\"audio/mp4\",\"audio/ogg;codecs=opus\",\"audio/ogg\"],mc={\"audio/webm\":\"webm\",\"audio/mp4\":\"m4a\",\"audio/ogg\":\"ogg\",\"audio/mpeg\":\"mp3\"};function fc(){return\"undefined\"==typeof MediaRecorder?\"\":gc.find(e=>MediaRecorder.isTypeSupported(e))||\"\"}function bc(){return\"undefined\"!=typeof MediaRecorder&&\"undefined\"!=typeof navigator&&!(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia)}function yc(e){const t=Number.isFinite(e)&&e>0?Math.floor(e):0;return Math.floor(t/60)+\":\"+String(t%60).padStart(2,\"0\")}class vc{constructor(e){this.recorder=null,this.stream=null,this.audioContext=null,this.analyser=null,this.frame=null,this.ticker=null,this.chunks=[],this.peaks=[],this.startedAt=0,this.discarded=!1,this.starting=!1,this.previewUrl=null,this.callbacks=e}isSupported(){return bc()}async start(){if(bc()){if(!(this.starting||this.stream||this.recorder)){this.starting=!0,this.releasePreview(),this.discarded=!1,this.chunks=[],this.peaks=[];try{this.stream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{return this.starting=!1,void this.callbacks.onError(\"permission\")}try{const e=fc();this.recorder=new MediaRecorder(this.stream,e?{mimeType:e,audioBitsPerSecond:64e3}:{audioBitsPerSecond:64e3}),this.audioContext=new AudioContext,this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=1024,this.audioContext.createMediaStreamSource(this.stream).connect(this.analyser),this.recorder.ondataavailable=e=>{e.data.size>0&&this.chunks.push(e.data)},this.recorder.onerror=()=>{this.discarded=!0,this.stopRecorder(),this.releaseCapture(),this.callbacks.onError(\"failed\")},this.recorder.onstop=()=>{if(this.discarded)return this.chunks=[],this.peaks=[],void this.releaseCapture();this.finalize()},this.startedAt=s(),this.recorder.start(250),this.callbacks.onRecordingStart(),this.sampleLevels();let t=-1;this.ticker=window.setInterval(()=>{const e=Math.floor((s()-this.startedAt)/1e3);e!==t&&(t=e,this.callbacks.onTick(e)),e>=300&&this.recorder&&this.recorder.stop()},250)}catch{this.stream&&this.stream.getTracks().forEach(e=>e.stop()),this.releaseCapture(),this.callbacks.onError(\"failed\")}finally{this.starting=!1}}}else this.callbacks.onError(\"unsupported\")}stop(){this.stopRecorder()}cancel(){this.recorder&&\"inactive\"!==this.recorder.state&&(this.discarded=!0,this.recorder.stop()),this.releaseCapture(),this.releasePreview(),this.chunks=[],this.peaks=[],this.callbacks.onIdle()}destroy(){this.recorder&&\"inactive\"!==this.recorder.state&&(this.discarded=!0,this.recorder.stop()),this.releaseCapture(),this.releasePreview()}stopRecorder(){this.recorder&&\"inactive\"!==this.recorder.state&&this.recorder.stop()}releaseCapture(){null!==this.frame&&(cancelAnimationFrame(this.frame),this.frame=null),null!==this.ticker&&(clearInterval(this.ticker),this.ticker=null),this.stream&&(this.stream.getTracks().forEach(e=>e.stop()),this.stream=null),this.analyser=null,this.audioContext&&\"closed\"!==this.audioContext.state&&this.audioContext.close(),this.audioContext=null,this.recorder=null,this.callbacks.onLevel(0)}releasePreview(){this.previewUrl&&(URL.revokeObjectURL(this.previewUrl),this.previewUrl=null)}sampleLevels(){const e=this.analyser;if(!e)return;const t=new Uint8Array(e.fftSize);let n=performance.now(),i=0;const s=()=>{if(!this.analyser)return;this.analyser.getByteTimeDomainData(t);let e=0;for(let n=0;n<t.length;n++){const i=(t[n]-128)/128;e+=i*i}const r=Math.min(1,3.2*Math.sqrt(e/t.length));this.callbacks.onLevel(r),r>i&&(i=r);const o=performance.now();o-n>=90&&(this.peaks.push(i),i=0,n=o),this.frame=requestAnimationFrame(s)};s()}finalize(){const e=function(e){return e.split(\";\")[0].trim().toLowerCase()}(this.recorder&&this.recorder.mimeType||fc()||\"audio/webm\"),t=Math.max(1,Math.round((s()-this.startedAt)/1e3)),n=function(e,t){if(!e.length)return new Array(t).fill(.08);const n=[];for(let i=0;i<t;i++){const s=Math.floor(i*e.length/t),r=Math.max(s+1,Math.floor((i+1)*e.length/t));let o=0;for(let t=s;t<r&&t<e.length;t++)e[t]>o&&(o=e[t]);n.push(Math.max(.08,Math.min(1,o)))}return n}(this.peaks,56),i=new Blob(this.chunks,{type:e});if(this.chunks=[],this.peaks=[],this.releaseCapture(),0===i.size)return void this.callbacks.onError(\"empty\");if(i.size>10485760)return void this.callbacks.onError(\"tooLarge\");const r=mc[e]||\"webm\",o=new File([i],\"voice-note-\"+s()+\".\"+r,{type:e});this.previewUrl=URL.createObjectURL(o),this.callbacks.onReview({file:o,durationSeconds:t,peaks:n,previewUrl:this.previewUrl})}}const wc=[1,1.5,2],xc='<path d=\"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.91-3c-.49 0-.9.36-.98.85C16.52 14.2 14.47 16 12 16s-4.52-1.8-4.93-4.15c-.08-.49-.49-.85-.98-.85-.61 0-1.09.54-1 1.14.49 3 2.89 5.35 5.91 5.78V20c0 .55.45 1 1 1s1-.45 1-1v-2.08c3.02-.43 5.42-2.78 5.91-5.78.1-.6-.39-1.14-1-1.14z\"/>',kc='<path d=\"M8 5.5v13a1 1 0 0 0 1.54.84l10-6.5a1 1 0 0 0 0-1.68l-10-6.5A1 1 0 0 0 8 5.5z\"/>',Sc='<rect x=\"6\" y=\"5\" width=\"4\" height=\"14\" rx=\"1.3\"/><rect x=\"14\" y=\"5\" width=\"4\" height=\"14\" rx=\"1.3\"/>',Cc=new Map;function Ec(e,t){e.innerHTML=\"\";const n=[];for(let i=0;i<t;i++){const t=document.createElement(\"i\");e.appendChild(t),n.push(t)}return n}function Mc(e,t,n){const i=Math.round((n||0)*e.length);for(let n=0;n<e.length;n++)e[n].style.transform=\"scaleY(\"+Math.max(.14,t[n]||.14)+\")\",e[n].classList.toggle(\"is-on\",n<i)}function Ac(e,t){e.querySelectorAll(\".support-voice-note[data-voice-attachment-id]:not([data-voice-mounted])\").forEach(e=>{e.setAttribute(\"data-voice-mounted\",\"true\"),function(e,t){const n=Na(),i=t=>e.querySelector(`[data-el=\"${t}\"]`),s=i(\"audio\"),r=i(\"wave\"),o=e.dataset.voiceAttachmentId||\"\",a=Cc.get(o),l=function(e){const t=String(e);let n=0;for(let e=0;e<t.length;e++)n=(31*n+t.charCodeAt(e))%233280;const i=[];for(let e=0;e<56;e++){n=(9301*n+49297)%233280;const t=.45+.55*Math.sin(e/56*Math.PI*1.7+.6);i.push(.2+n/233280*.8*t)}return i}(o),c=Ec(r,l.length);Mc(c,l,0);let d=1,u=!1;const p=Number(e.dataset.voiceDuration||\"\")||0,h=()=>Number.isFinite(s.duration)&&s.duration>0,g=()=>h()?s.duration:p,m=t=>{const i=e.querySelector('[data-act=\"toggle\"]');i.setAttribute(\"aria-label\",t?n.voiceNotes.pause:n.voiceNotes.play);i.querySelector(\"svg\").innerHTML=t?Sc:kc},f=async()=>{if(a)s.src=URL.createObjectURL(a);else try{s.src=await t(o)}catch{i(\"duration\").textContent=\"--:--\"}};s.addEventListener(\"error\",async()=>{if(!a&&!u&&s.src){u=!0;try{s.src=await t(o)}catch{i(\"duration\").textContent=\"--:--\"}}}),s.addEventListener(\"loadedmetadata\",()=>{g()>0&&(i(\"duration\").textContent=yc(g()))}),s.addEventListener(\"durationchange\",()=>{g()<=0||(i(\"duration\").textContent=yc(g()))}),s.addEventListener(\"timeupdate\",()=>{i(\"elapsed\").textContent=yc(s.currentTime),g()>0&&Mc(c,l,Math.min(1,s.currentTime/g()))}),s.addEventListener(\"play\",()=>m(!0)),s.addEventListener(\"pause\",()=>m(!1)),s.addEventListener(\"ended\",()=>{m(!1),s.currentTime=0,Mc(c,l,0)}),e.addEventListener(\"click\",e=>{const t=e.target.closest(\"[data-act]\");t&&(\"toggle\"===t.dataset.act&&(s.paused?(s.playbackRate=d,s.play()):s.pause()),\"speed\"===t.dataset.act&&(d=wc[(wc.indexOf(d)+1)%wc.length],s.playbackRate=d,t.textContent=d+\"x\"))}),r.addEventListener(\"click\",e=>{if(!h()||g()<=0)return;const t=r.getBoundingClientRect(),n=Math.min(1,Math.max(0,(e.clientX-t.left)/t.width));s.currentTime=n*g(),Mc(c,l,n)}),f()}(e,t)})}const _c='<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"currentColor\"><path d=\"M10 9V5l-7 7 7 7v-4.1c5 0 8.5 1.6 11 5.1-1-5-4-10-11-11z\"/></svg>',Tc=\"support-message-pressing\",Ic=\"support-message-swiping\",Lc=\"support-message-snapping\",Rc=\"support-message-reply-armed\",$c=\"support-message-held\";function Nc(){navigator.vibrate?.(12)}function Pc(e,t){let n=\"idle\",i=-1,s=0,r=0,o=!1,a=null,l=null,c=null,d=null;const u=()=>{null!==l&&(clearTimeout(l),l=null)},p=()=>{null!==c&&(clearTimeout(c),c=null),e.classList.remove(Ic,Lc,Rc),e.style.removeProperty(\"--reply-offset\"),e.style.removeProperty(\"--reply-progress\"),os(a),a=null,o=!1},h=()=>{u(),e.classList.remove(Tc),n=\"idle\",i=-1},g=()=>{n=\"swiping\",u(),p(),e.classList.add(Ic),a=function(){const e=document.createElement(\"span\");return e.className=\"support-reply-swipe-icon\",e.setAttribute(\"aria-hidden\",\"true\"),e.innerHTML=_c,e}(),e.appendChild(a)},m=t=>{e.style.setProperty(\"--reply-offset\",`${function(e){return e<=56?e:Math.min(80,56+.35*(e-56))}(t)}px`),e.style.setProperty(\"--reply-progress\",String(Math.min(1,t/56)));const n=t>=56;n!==o&&(o=n,e.classList.toggle(Rc,n),n&&Nc())},f=()=>{l=null,\"pending\"===n&&(n=\"held\",Nc(),null!==d&&clearTimeout(d),e.classList.remove($c),e.offsetWidth,e.classList.add($c),d=setTimeout(()=>e.classList.remove($c),900),t.onReply())},b=s=>{if(s.pointerId!==i)return;const r=\"pointerup\"===s.type,a=\"swiping\"===n,l=r&&a&&o;\"held\"===n&&(()=>{const t=e=>{e.preventDefault(),e.stopPropagation()};e.addEventListener(\"click\",t,{capture:!0,once:!0}),setTimeout(()=>e.removeEventListener(\"click\",t,{capture:!0}),400)})(),h(),a&&(e.classList.add(Lc),e.classList.remove(Rc),e.style.setProperty(\"--reply-offset\",\"0px\"),e.style.setProperty(\"--reply-progress\",\"0\"),c=setTimeout(p,260)),l&&t.onReply()};e.addEventListener(\"pointerdown\",o=>{if(\"touch\"!==o.pointerType||!o.isPrimary)return;h(),p();const a=o.target;a instanceof Element&&!a.closest('input, textarea, select, audio, video, pre, [role=\"slider\"], .support-message-reply-btn')&&t.isEnabled()&&(n=\"pending\",i=o.pointerId,s=o.clientX,r=o.clientY,e.classList.add(Tc),l=setTimeout(f,450))},{passive:!0}),e.addEventListener(\"pointermove\",e=>{if(e.pointerId!==i)return;const t=e.clientX-s,o=e.clientY-r;\"pending\"===n&&(t>8&&t>1.5*Math.abs(o)?g():(Math.abs(t)>8||Math.abs(o)>8)&&(u(),n=\"ignored\")),\"swiping\"===n&&m(Math.max(0,t-8))},{passive:!0}),e.addEventListener(\"pointerup\",b,{passive:!0}),e.addEventListener(\"pointercancel\",b,{passive:!0}),e.addEventListener(\"contextmenu\",e=>{\"idle\"!==n&&e.preventDefault()})}function Fc(e,t,n,i){let r;const o=()=>{const a=s();t.freeAt<=a?i():(e.textContent=n(function(e,t){const n=$a(),i=Na().executiveAvailability,s=new Date(e),r=i.at(new Intl.DateTimeFormat(n,{hour:\"numeric\",minute:\"2-digit\"}).format(s)),o=Math.round((Oc(e)-Oc(t))/864e5);if(o<=0)return r;if(1===o)return i.tomorrow(r);if(o<7)return i.onDay(new Intl.DateTimeFormat(n,{weekday:\"long\"}).format(s),r);const a=s.getFullYear()===new Date(t).getFullYear(),l=new Intl.DateTimeFormat(n,a?{day:\"numeric\",month:\"long\"}:{day:\"numeric\",month:\"long\",year:\"numeric\"}).format(s);return i.onDay(l,r)}(t.freeAt,a)),r=setTimeout(()=>{e.isConnected&&o()},Math.min(t.freeAt,function(e){const t=new Date(e);return t.setHours(24,0,0,0),t.getTime()}(a))-a))};return o(),()=>clearTimeout(r)}function Oc(e){const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}const qc=new Set([\"busy\",\"out_of_office\"]);function Hc(e){if(!e||\"object\"!=typeof e||Array.isArray(e))return null;const{reason:t,free_at:n}=e;if(\"string\"!=typeof t||!qc.has(t))return null;if(\"string\"!=typeof n)return null;const i=Date.parse(n);return Number.isNaN(i)?null:{reason:t,freeAt:i}}function Bc(e){if(!e||\"object\"!=typeof e)return null;const t=e;return\"number\"!=typeof t.id?null:{id:t.id,seq:\"number\"==typeof t.seq?t.seq:void 0,role:\"string\"==typeof t.role?t.role:void 0,body:\"string\"==typeof t.body?t.body:\"\",author_name:\"string\"==typeof t.author_name?t.author_name:null,is_deleted:!0===t.is_deleted}}function Dc(e,t){const n=e.author_name||(\"contact\"===e.role?t.replies.you:\"ai\"===e.role||\"system\"===e.role?t.replies.assistant:t.replies.supportTeam),i=e.is_deleted?t.replies.deletedMessage:function(e){const t=dc(e).replace(pc,\" \");return((new DOMParser).parseFromString(t,\"text/html\").body.textContent??\"\").replace(/\\s+/g,\" \").trim()}(e.body)||t.attachments.attachment;return{author:n,preview:i}}class zc{constructor(e,t,n){this.messages=new Pa,this.streamingMessageElement=null,this.streamingMessageContent=\"\",this.currentSystemActionElement=null,this.currentThinkingStep=null,this.isShowingThoughts=!1,this.thinkingContent=\"\",this.currentThinkingSynonym=null,this.retryHandlers=new Map,this.getExecutiveName=()=>null,this.onHumanReply=()=>{},this.highlightTimer=null,this.highlightedElement=null,this.HIGHLIGHT_MS=1600,this.aiIconUrl=\"\",this.agentName=T,this.SCREENSHOT_GROUP_THRESHOLD=5,this.DOC_READ_DISMISS_MS=3500,this.DOC_READ_LEAVE_MS=420,this.DOC_READ_STAGGER_MS=120,this.docReadDismissTimers=new Set,this.docReadQueue=[],this.docReadFlushTimer=null,this.screenshotRunStartIndex=-1,this.screenshotRunElements=[],this.activeGroupCardElement=null,this.activeActionTimeline=null,this.liveGoalNudgeElement=null,this.groupCardSlides=new WeakMap,this.container=e,this.onSystemActionCallback=t,this.onTourStartCallback=n,this.translations=Na()}endActionRun(){this.screenshotRunStartIndex=-1,this.screenshotRunElements=[],this.activeGroupCardElement=null,this.activeActionTimeline=null}getScreenshotRunItems(){return this.screenshotRunStartIndex<0?[]:this.messages.slice(this.screenshotRunStartIndex).filter(e=>\"screenshot\"===e.messageType&&void 0!==e.screenshotData).map(e=>e.screenshotData)}setReplyHandler(e){this.onReplyCallback=e}setExecutiveNameProvider(e){this.getExecutiveName=e}setHumanReplyListener(e){this.onHumanReply=e}quoteOf(e){return\"number\"!=typeof e.id?null:{id:e.id,seq:e.seq,role:e.role,body:e.text||e.body||\"\",author_name:e.author_user_name||null,is_deleted:!1}}renderReplyQuote(e){const{author:t,preview:n}=Dc(e,this.translations);return`\\n      <div class=\"support-message-quote${e.is_deleted?\" deleted\":\"\"}\" data-quote-id=\"${e.id}\"\\n           role=\"button\" tabindex=\"0\" aria-label=\"${this.translations.replies.goToMessage}\">\\n        <span class=\"support-quote-author\">${ac(t)}</span>\\n        <span class=\"support-quote-body\">${ac(n)}</span>\\n      </div>\\n    `}scrollToMessage(e){const t=this.container.querySelector(\"#support-chat-messages\"),n=t?.querySelector(`.support-message[data-message-id=\"${e}\"]`);return!!n&&(n.scrollIntoView?.({behavior:\"smooth\",block:\"center\"}),this.clearHighlight(),n.classList.add(\"support-message-highlighted\"),this.highlightedElement=n,this.highlightTimer=setTimeout(()=>this.clearHighlight(),this.HIGHLIGHT_MS),!0)}clearHighlight(){this.highlightTimer&&(clearTimeout(this.highlightTimer),this.highlightTimer=null),this.highlightedElement?.classList.remove(\"support-message-highlighted\"),this.highlightedElement=null}attachQuoteHandler(e,t){const n=e.querySelector(\".support-message-quote\");if(!n)return;const i=()=>{this.scrollToMessage(t.id)||(n.classList.remove(\"not-found\"),n.offsetWidth,n.classList.add(\"not-found\"))};n.addEventListener(\"click\",i),n.addEventListener(\"keydown\",e=>{const t=e.key;\"Enter\"!==t&&\" \"!==t||(e.preventDefault(),i())})}renderReplyButton(e){return this.onReplyCallback&&this.quoteOf(e)?`\\n      <button class=\"support-message-reply-btn\" type=\"button\" aria-label=\"${this.translations.replies.reply}\" title=\"${this.translations.replies.reply}\">\\n        ${_c}\\n      </button>\\n    `:\"\"}attachReplyHandler(e,t){const n=e.querySelector(\".support-message-reply-btn\");n&&n.addEventListener(\"click\",()=>this.replyTo(t))}replyTo(e){const t=this.quoteOf(e);t&&this.onReplyCallback?.(t)}attachReplyGesture(e,t){this.onReplyCallback&&Pc(e,{isEnabled:()=>null!==this.quoteOf(t)&&!this.container.classList.contains(\"conversation-read-only\"),onReply:()=>this.replyTo(t)})}setUrlCache(e){this.urlCache=e}setAiIconUrl(e){this.aiIconUrl=e}setAgentName(e){this.agentName=e}appendEditedLabel(e){if(e.querySelector(\".support-message-edited\"))return;const t=document.createElement(\"span\");t.className=\"support-message-edited\",t.textContent=`(${this.translations.messages.edited})`;const n=e.lastElementChild;n&&\"P\"===n.tagName?n.appendChild(t):e.appendChild(t)}renderAvatar(e){const t=\"ai\"===e.role,n=e.author_user_avatar_url;if(t){const t=e.ai_icon_url||this.aiIconUrl;return t?`\\n          <div class=\"support-avatar ai\" data-avatar-url=\"${ac(t)}\">\\n            <div class=\"support-avatar-loading\">\\n              <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${L}</svg>\\n            </div>\\n          </div>\\n        `:`\\n        <div class=\"support-avatar ai\">\\n          <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${L}</svg>\\n        </div>\\n      `}return n?`\\n        <div class=\"support-avatar\" data-avatar-url=\"${ac(n)}\">\\n          <div class=\"support-avatar-loading\">\\n            <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n              <path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\"/>\\n            </svg>\\n          </div>\\n        </div>\\n      `:'\\n      <div class=\"support-avatar\">\\n        <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n          <path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\"/>\\n        </svg>\\n      </div>\\n    '}loadAvatarImage(e){const t=e.querySelector(\"[data-avatar-url]\");if(!t)return;const n=t.getAttribute(\"data-avatar-url\");if(!n)return;const i=t.querySelector(\".support-avatar-loading\");if(!i)return;const s=document.createElement(\"img\");s.alt=this.translations.aria.avatar,s.className=\"support-avatar-image\",s.onload=()=>i.replaceWith(s),s.src=n}isVoiceNoteMessage(e){return(!0===e.metadata?.is_voice_note||void 0!==this.voiceNoteDuration(e))&&!!e.attachments?.some(e=>e.mime_type.startsWith(\"audio/\"))}voiceNoteDuration(e){const t=e.metadata?.voice_note_duration;return\"number\"==typeof t&&t>0?t:void 0}renderAttachments(e,t=!1,n){if(!e||0===e.length)return\"\";const i=e=>e<1024?e+\" B\":e<1048576?(e/1024).toFixed(1)+\" KB\":(e/1048576).toFixed(1)+\" MB\",s=e.map(e=>{const s=e.mime_type.startsWith(\"image/\"),r=e.mime_type.startsWith(\"video/\"),o=e.mime_type.startsWith(\"audio/\");return t&&o?function(e,t){const n=Na(),i=t&&t>0?t:0;return`\\n    <div class=\"support-voice-note\" data-voice-attachment-id=\"${e}\" data-voice-duration=\"${i}\">\\n      <div class=\"support-voice-top\">\\n        <button type=\"button\" class=\"support-voice-play\" data-act=\"toggle\" aria-label=\"${n.voiceNotes.play}\">\\n          <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">${kc}</svg>\\n        </button>\\n        <div class=\"support-voice-wave\" data-el=\"wave\"></div>\\n        <button type=\"button\" class=\"support-voice-speed\" data-act=\"speed\" aria-label=\"${n.voiceNotes.playbackSpeed}\">1x</button>\\n      </div>\\n      <div class=\"support-voice-foot\">\\n        <span data-el=\"elapsed\">0:00</span>\\n        <span class=\"support-voice-label\">\\n          <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">${xc}</svg>\\n          ${n.voiceNotes.voiceMessage}\\n        </span>\\n        <span data-el=\"duration\">${i>0?yc(i):\"--:--\"}</span>\\n      </div>\\n      <audio data-el=\"audio\" preload=\"metadata\" hidden></audio>\\n    </div>\\n  `}(e.id,n):s?`\\n          <div class=\"support-attachment-card image\" data-attachment-id=\"${e.id}\" data-mime-type=\"${e.mime_type}\">\\n            <div class=\"support-attachment-loading\">${this.translations.attachments.loadingImage}</div>\\n            <div class=\"support-attachment-info\">\\n              <span class=\"support-attachment-name\" title=\"${e.file_name}\">${e.file_name}</span>\\n              <span class=\"support-attachment-size\">${i(e.size_bytes)}</span>\\n            </div>\\n          </div>\\n        `:r?`\\n          <div class=\"support-attachment-card video\" data-attachment-id=\"${e.id}\" data-mime-type=\"${e.mime_type}\">\\n            <div class=\"support-attachment-loading\">${this.translations.attachments.loadingVideo}</div>\\n            <div class=\"support-attachment-info\">\\n              <span class=\"support-attachment-name\" title=\"${e.file_name}\">${e.file_name}</span>\\n              <span class=\"support-attachment-size\">${i(e.size_bytes)}</span>\\n            </div>\\n          </div>\\n        `:o?`\\n          <div class=\"support-attachment-card audio\" data-attachment-id=\"${e.id}\" data-mime-type=\"${e.mime_type}\">\\n            <div class=\"support-attachment-loading\">${this.translations.attachments.loadingAudio}</div>\\n            <div class=\"support-attachment-info\">\\n              <span class=\"support-attachment-name\" title=\"${e.file_name}\">${e.file_name}</span>\\n              <span class=\"support-attachment-size\">${i(e.size_bytes)}</span>\\n            </div>\\n          </div>\\n        `:`\\n        <div class=\"support-attachment-card file\" data-attachment-id=\"${e.id}\">\\n          <div class=\"support-attachment-link\" role=\"button\" tabindex=\"0\">\\n            <svg class=\"support-file-icon\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n              <path d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z\"/>\\n              <path d=\"M14 2v6h6\"/>\\n              <path d=\"M12 18v-6\"/>\\n              <path d=\"m9 15 3 3 3-3\"/>\\n            </svg>\\n            <div class=\"support-attachment-info\">\\n              <span class=\"support-attachment-name\" title=\"${e.file_name}\">${e.file_name}</span>\\n              <span class=\"support-attachment-size\">${i(e.size_bytes)}</span>\\n            </div>\\n          </div>\\n        </div>\\n      `}).join(\"\");return`<div class=\"support-attachments\">${s}</div>`}renderStatusIndicator(e){return\"failed\"===e.sendStatus?`\\n        <div class=\"support-message-status\" title=\"${this.translations.messages.clickToRetry}\">\\n          <svg class=\"support-failed-icon\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n            <path d=\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z\"/>\\n          </svg>\\n        </div>\\n      `:e.isPending||\"sending\"===e.sendStatus?'\\n        <div class=\"support-message-status\">\\n          <svg class=\"support-pending-icon\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n            <path d=\"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm.5-13H11v6l5.2 3.2.8-1.3-4.5-2.7V7z\"/>\\n          </svg>\\n        </div>\\n      ':\"\"}async loadAttachmentUrls(e){const t=this.urlCache;if(!t)return;Ac(e,e=>t.getUrl(e));const n=e.querySelectorAll(\"[data-attachment-id]\");for(const e of Array.from(n)){const n=e.getAttribute(\"data-attachment-id\")||\"\",i=e.getAttribute(\"data-mime-type\")||\"\";try{const s=await t.getUrl(n),r=i.startsWith(\"image/\"),o=i.startsWith(\"video/\"),a=i.startsWith(\"audio/\");if(r){const t=e.querySelector(\".support-attachment-loading\");if(t){const n=this.isScrolledToBottom();t.outerHTML=`\\n              <a href=\"${s}\" target=\"_blank\" rel=\"noopener noreferrer\">\\n                <img src=\"${s}\" alt=\"${this.translations.attachments.attachment}\" loading=\"lazy\" />\\n              </a>\\n            `,n&&this.scrollToBottomOnLoad(e)}}else if(o){const t=e.querySelector(\".support-attachment-loading\");t&&(t.outerHTML=`\\n              <video controls preload=\"metadata\">\\n                <source src=\"${s}\">\\n                ${this.translations.attachments.videoNotSupported}\\n              </video>\\n            `)}else if(a){const t=e.querySelector(\".support-attachment-loading\");t&&(t.outerHTML=`\\n              <audio controls preload=\"metadata\">\\n                <source src=\"${s}\" type=\"${i}\">\\n                ${this.translations.attachments.audioNotSupported}\\n              </audio>\\n            `)}else{const t=e.querySelector(\".support-attachment-link\");t&&(t.style.cursor=\"pointer\",t.onclick=()=>window.open(s,\"_blank\"),t.onkeydown=e=>{\"Enter\"!==e.key&&\" \"!==e.key||window.open(s,\"_blank\")})}}catch(t){Ji(`Failed to load attachment ${n}`,t);const i=e.querySelector(\".support-attachment-loading\");i&&(i.textContent=this.translations.attachments.failedToLoad,i.classList.add(\"error\"))}}}addMessage(e){this.endActionRun(),\"agent\"===e.role&&(this.dropExecutiveAvailability(),this.onHumanReply()),this.messages.push(e);const t=this.container.querySelector(\"#support-chat-messages\"),n=document.createElement(\"div\");if(e.tour)return this.addTourMessage(e,t);if(\"system\"===e.role&&!0===e.metadata?.engineering_handoff)return this.addEngineeringHandoffMessage(e,t);if(\"system\"===e.role&&e.metadata?.suggestion_type)return this.addSystemActionMessage(e,t);n.className=\"support-message \"+(e.isAgent?\"agent\":\"user\"),e.isPending&&n.classList.add(\"pending\"),e.idempotencyKey&&n.setAttribute(\"data-idempotency-key\",e.idempotencyKey),void 0!==e.seq&&e.seq>0&&n.setAttribute(\"data-seq\",e.seq.toString()),void 0!==e.id&&n.setAttribute(\"data-message-id\",String(e.id));const i=e.replyTo?this.renderReplyQuote(e.replyTo):\"\",s=this.renderReplyButton(e),r=this.isVoiceNoteMessage(e),o=r?\"\":e.text||e.body||\"\",a=this.renderAttachments(e.attachments||[],r,this.voiceNoteDuration(e));if(e.isAgent){const t=ac(e.author_user_name||\"\");n.innerHTML=`\\n        ${this.renderAvatar(e)}\\n        <div class=\"support-message-wrapper\">\\n          ${o?`<div class=\"support-message-content\">\\n            ${t?`<div class=\"support-message-author\">${t}</div>`:\"\"}\\n            ${i}\\n            ${dc(o)}\\n          </div>`:i}\\n          ${a}\\n        </div>\\n        ${s}\\n      `}else{const t=this.renderStatusIndicator(e);n.innerHTML=`\\n        ${s}\\n        <div class=\"support-message-wrapper\">\\n          ${o?`<div class=\"support-message-content\">${i}${dc(o)}</div>`:i}\\n          ${a}\\n        </div>\\n        ${t}\\n      `,\"failed\"===e.sendStatus&&e.idempotencyKey&&n.classList.add(\"failed\")}if(t.appendChild(n),t.scrollTop=t.scrollHeight,this.attachReplyHandler(n,e),this.attachReplyGesture(n,e),e.replyTo&&this.attachQuoteHandler(n,e.replyTo),e.edited_at){const e=n.querySelector(\".support-message-content\");e&&this.appendEditedLabel(e)}return e.isAgent&&(e.author_user_avatar_url||\"ai\"===e.role&&(e.ai_icon_url||this.aiIconUrl))&&this.loadAvatarImage(n),e.attachments&&e.attachments.length>0&&this.loadAttachmentUrls(n),n}handleMessageHistory(e,t){if(!e||0===e.length)return;const n=this.container.querySelector(\"#support-chat-messages\");if(0===t||0===this.messages.length){if(n){const e=n.querySelector(\".support-welcome-module\");n.innerHTML=\"\",e&&n.appendChild(e)}this.messages.clear(!0),this.endActionRun(),this.liveGoalNudgeElement=null}const i=e.filter(e=>!e.is_draft),s=new Set;for(const e of this.messages)e.idempotencyKey&&s.add(e.idempotencyKey),void 0!==e.seq&&e.seq>0&&s.add(`seq:${e.seq}`);i.forEach(e=>{if(\"event\"===e.role)return;if(\"system\"===e.role&&!0===e.metadata?.resolved){const t=e.metadata?.suggestion_type;if(\"close_ticket\"===t||\"human_assistance\"===t)return}if(void 0!==e.seq&&e.seq>0&&s.has(`seq:${e.seq}`))return;const t=e.idempotencyKey||e.idempotency_key||e.metadata?.idempotency_key;if(t&&s.has(t))return;if(e.is_ephemeral){const n=e.metadata;if(\"recording\"===n?.type)return;if(\"screenshot\"===n?.type&&e.attachments?.length)return void this.addScreenshotMessage(e.attachments[0].id,{action_type:String(n.action_type??\"\"),element_description:String(n.element_description??\"\"),url:String(n.url??\"\"),body:e.body},t,e.seq);if(\"screenshot\"===n?.type&&(n.action_type||e.body))return void this.addAgentActionStep({action_type:String(n.action_type??\"\"),element_description:String(n.element_description??\"\"),url:String(n.url??\"\"),body:e.body},t,e.seq)}if(!e.body&&\"system\"!==e.role&&!e.attachments?.length)return;const n=\"contact\"!==e.role;this.addMessage({id:e.id,text:e.body,isAgent:n,idempotencyKey:t,seq:e.seq,role:e.role,replyTo:e.replyTo??Bc(e.reply_to),metadata:e.metadata,tour:e.tour,attachments:e.attachments,author_user_name:e.author_user_name,author_user_avatar_url:e.author_user_avatar_url,ai_icon_url:e.ai_icon_url,edited_at:e.edited_at,bubble_message:e.bubble_message})})}removePendingIndicator(e,t,n){const i=this.container.querySelector(\"#support-chat-messages\"),s=i?.querySelector(`[data-idempotency-key=\"${e}\"]`),r=this.messages.find(t=>t.idempotencyKey===e);if(\"number\"==typeof n&&r&&(r.id=n,s&&(s.setAttribute(\"data-message-id\",String(n)),s.querySelector(\".support-message-reply-btn\")||(s.insertAdjacentHTML(\"afterbegin\",this.renderReplyButton(r)),this.attachReplyHandler(s,r)))),s){s.classList.remove(\"pending\");const e=s.querySelector(\".support-message-status\");if(e&&os(e),t&&t.length>0&&!s.querySelector(\".support-voice-note\")){const e=s.querySelector(\".support-attachments\");e&&(e.innerHTML=this.renderAttachments(t),this.loadAttachmentUrls(s))}return!0}return!1}updateMessageStatus(e,t){const n=this.container.querySelector(\"#support-chat-messages\"),i=n?.querySelector(`[data-idempotency-key=\"${e}\"]`);if(!i)return;const s=this.messages.find(t=>t.idempotencyKey===e);if(s&&(s.sendStatus=t),i.classList.remove(\"pending\",\"failed\"),\"sending\"===t)i.classList.add(\"pending\"),this.updateStatusIndicatorElement(i,\"sending\");else if(\"failed\"===t)i.classList.add(\"failed\"),this.updateStatusIndicatorElement(i,\"failed\"),this.attachRetryClickHandler(i,e);else if(\"sent\"===t){const t=i.querySelector(\".support-message-status\");t&&os(t),this.retryHandlers.delete(e)}}setRetryHandler(e,t){this.retryHandlers.set(e,t);const n=this.container.querySelector(\"#support-chat-messages\"),i=n?.querySelector(`[data-idempotency-key=\"${e}\"]`);i&&this.attachRetryClickHandler(i,e)}updateStatusIndicatorElement(e,t){let n=e.querySelector(\".support-message-status\");n||(n=document.createElement(\"div\"),n.className=\"support-message-status\",e.appendChild(n)),\"failed\"===t?(n.title=this.translations.messages.clickToRetry,n.innerHTML='\\n        <svg class=\"support-failed-icon\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n          <path d=\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z\"/>\\n        </svg>\\n      '):(n.title=\"\",n.innerHTML='\\n        <svg class=\"support-pending-icon\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n          <path d=\"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10 10-4.5 10-10S17.5 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm.5-13H11v6l5.2 3.2.8-1.3-4.5-2.7V7z\"/>\\n        </svg>\\n      ')}attachRetryClickHandler(e,t){const n=e.querySelector(\".support-message-status\");n&&(n.style.cursor=\"pointer\",n.onclick=()=>{const e=this.retryHandlers.get(t);e&&e()})}scrollToBottom(){const e=this.container.querySelector(\"#support-chat-messages\");e&&(e.scrollTop=e.scrollHeight)}isScrolledToBottom(){const e=this.getMessagesContainer();return!e||e.scrollHeight-e.scrollTop-e.clientHeight<=48}scrollToBottomOnLoad(e){e.querySelectorAll(\"img\").forEach(e=>e.addEventListener(\"load\",()=>this.scrollToBottom(),{once:!0}))}getMessages(){return this.messages.toArray()}getMessagesContainer(){return this.container.querySelector(\"#support-chat-messages\")}hasMessageWithIdempotencyKey(e){const t=this.container.querySelector(\"#support-chat-messages\"),n=t?.querySelector(`[data-idempotency-key=\"${e}\"]`);return null!==n}hasUnresolvedCSAT(){return this.messages.toArray().some(e=>\"system\"===e.role&&\"csat_survey\"===e.metadata?.suggestion_type&&!e.metadata?.resolved)}resolveSystemMessage(e,t){this.onSystemActionCallback?.({idempotency_key:e,resolved:!0});const n=this.container.querySelector(\"#support-chat-messages\"),i=n?.querySelector(`[data-idempotency-key=\"${e}\"]`);if(!i)return!1;const s=i.querySelector(\".support-api-confirmation\");if(s)return s.classList.contains(\"resolved\")||this.markApiConfirmationResolved(i,t),!0;const r=i.querySelector(\".support-interactive-card\");if(r&&!r.classList.contains(\"resolved\")){return new hc(this.translations).showResolved(r,t),!0}const o=i.querySelector(\".support-csat-survey\");if(o)return o.classList.contains(\"resolved\")||this.markCsatResolved(i,t),!0;return!!i.querySelector(\".support-system-action-card\")&&(os(i),this.currentSystemActionElement===i&&(this.currentSystemActionElement=null),!0)}clearMessages(e=!1){this.clearHighlight(),this.streamingMessageElement=null,this.messages.clear(e),this.streamingMessageContent=\"\",this.isShowingThoughts=!1,this.thinkingContent=\"\",this.currentThinkingStep=null,this.currentThinkingSynonym=null,this.endActionRun(),this.liveGoalNudgeElement=null;const t=this.container.querySelector(\"#support-chat-messages\");if(t){const e=t.querySelector(\".support-welcome-module\");t.innerHTML=\"\",e&&t.appendChild(e)}}removeMessageBySeq(e){const t=this.messages.findIndex(t=>t.seq===e);-1!==t&&this.messages.splice(t,1);const n=this.container.querySelector(\"#support-chat-messages\"),i=n?.querySelector(`[data-seq=\"${e}\"]`);return i?(os(i),!0):-1!==t}updateMessageBodyBySeq(e,t){const n=this.messages.find(t=>t.seq===e);n&&(n.body=t,void 0!==n.text&&(n.text=t));const i=this.container.querySelector(\"#support-chat-messages\"),s=i?.querySelector(`[data-seq=\"${e}\"]`),r=s?.querySelector(\".support-message-wrapper\");if(!r)return void 0!==n;let o=r.querySelector(\".support-message-content\");if(!o){o=document.createElement(\"div\"),o.className=\"support-message-content\";const e=r.querySelector(\".support-message-quote\");r.insertBefore(o,e?e.nextSibling:r.firstChild)}const a=o.querySelector(\".support-message-author\");return o.innerHTML=dc(t),a&&o.insertBefore(a,o.firstChild),this.appendEditedLabel(o),!0}showThinkingBubble(){if(this.streamingMessageElement&&this.streamingMessageElement.isConnected)return;this.streamingMessageElement=null;const e=this.container.querySelector(\"#support-chat-messages\");this.streamingMessageElement=document.createElement(\"div\"),this.streamingMessageElement.className=\"support-message agent streaming thinking\",this.streamingMessageContent=\"\",this.isShowingThoughts=!0,this.thinkingContent=\"\",this.currentThinkingSynonym=this.pickThinkingSynonym();const t=this.aiIconUrl?`<div class=\"support-avatar ai\" data-avatar-url=\"${ac(this.aiIconUrl)}\">\\n          <div class=\"support-avatar-loading\">\\n            <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${L}</svg>\\n          </div>\\n        </div>`:`<div class=\"support-avatar ai\">\\n          <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${L}</svg>\\n        </div>`;this.streamingMessageElement.innerHTML=`\\n      ${t}\\n      <div class=\"support-message-content support-thinking-bubble\">\\n        <div class=\"support-thinking-content\"></div>\\n        <div class=\"support-doc-read-stack\"></div>\\n      </div>\\n    `;const n=this.streamingMessageElement.querySelector(\".support-thinking-content\");n&&(n.textContent=this.currentThinkingSynonym),e.appendChild(this.streamingMessageElement),this.aiIconUrl&&this.loadAvatarImage(this.streamingMessageElement),this.scrollToBottom()}startStreamingMessage(){this.showThinkingBubble()}updateProgressMessage(e){this.streamingMessageElement&&this.streamingMessageElement.isConnected||(this.streamingMessageElement=null,this.showThinkingBubble());const t=this.streamingMessageElement?.querySelector(\".support-thinking-content\");t&&(e.trim().length>0?t.textContent=e:(this.currentThinkingSynonym||(this.currentThinkingSynonym=this.pickThinkingSynonym()),t.textContent=this.currentThinkingSynonym))}appendDocumentReadItem(e){0!==e.trim().length&&(this.docReadQueue.push(e),null===this.docReadFlushTimer&&this.flushNextDocRead())}flushNextDocRead(){const e=this.docReadQueue.shift();void 0!==e?(this.renderDocReadItem(e),this.docReadFlushTimer=setTimeout(()=>{this.docReadFlushTimer=null,this.flushNextDocRead()},this.DOC_READ_STAGGER_MS)):this.docReadFlushTimer=null}renderDocReadItem(e){this.streamingMessageElement&&this.streamingMessageElement.isConnected||(this.streamingMessageElement=null,this.showThinkingBubble());const t=this.streamingMessageElement?.querySelector(\".support-doc-read-stack\");if(!t)return;this.streamingMessageElement?.classList.add(\"has-doc-reads\");const n=document.createElement(\"div\");n.className=\"support-doc-read-item support-doc-read-enter\";const i=document.createElement(\"span\");i.className=\"support-doc-read-check\",i.innerHTML='<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"9\" height=\"9\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"3.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20 6 9 17 4 12\"/></svg>';const s=document.createElement(\"span\");s.className=\"support-doc-read-verb\",s.textContent=this.translations.messages.readDocument;const r=document.createElement(\"span\");r.className=\"support-doc-read-name\",r.textContent=e,n.append(i,s,r),t.appendChild(n),this.scrollToBottom();const o=setTimeout(()=>{this.docReadDismissTimers.delete(o),this.dismissDocReadItem(n)},this.DOC_READ_DISMISS_MS);this.docReadDismissTimers.add(o)}dismissDocReadItem(e){e.classList.remove(\"support-doc-read-enter\"),e.classList.add(\"support-doc-read-leave\");const t=setTimeout(()=>{this.docReadDismissTimers.delete(t),os(e)},this.DOC_READ_LEAVE_MS);this.docReadDismissTimers.add(t)}clearDocReadTimers(){this.docReadDismissTimers.forEach(clearTimeout),this.docReadDismissTimers.clear(),null!==this.docReadFlushTimer&&(clearTimeout(this.docReadFlushTimer),this.docReadFlushTimer=null),this.docReadQueue=[]}appendToStreamingMessage(e,t){if(this.streamingMessageElement&&this.streamingMessageElement.isConnected||(this.streamingMessageElement=null,this.startStreamingMessage()),this.isShowingThoughts)if(void 0!==t&&null!==this.currentThinkingStep&&t!==this.currentThinkingStep&&(this.thinkingContent=\"\"),this.currentThinkingStep=t??null,this.thinkingContent+=e,this.thinkingContent.includes(\"FINAL RESPONSE:\")){const e=this.thinkingContent.split(\"FINAL RESPONSE:\");this.switchToFinalResponse(),e[1]&&(this.streamingMessageContent=e[1],this.updateMessageContent(this.streamingMessageContent))}else this.updateThinkingContent(this.thinkingContent);else this.streamingMessageContent+=e,this.updateMessageContent(this.streamingMessageContent);this.scrollToBottom()}switchToFinalResponse(){if(this.isShowingThoughts=!1,this.thinkingContent=\"\",this.currentThinkingStep=null,this.currentThinkingSynonym=null,this.clearDocReadTimers(),this.streamingMessageElement){this.streamingMessageElement.classList.remove(\"thinking\");const e=this.streamingMessageElement.querySelector(\".support-message-content\");e&&(e.classList.remove(\"support-thinking-bubble\"),e.innerHTML=\"\",e.textContent=\"\")}}pickThinkingSynonym(){const e=this.translations.messages.thinkingSynonyms;return e[Math.floor(Math.random()*e.length)]}updateThinkingContent(e){if(!this.streamingMessageElement)return;const t=this.streamingMessageElement.querySelector(\".support-thinking-content\");t&&(e.trim().length>0?t.innerHTML=dc(e):(this.currentThinkingSynonym||(this.currentThinkingSynonym=this.pickThinkingSynonym()),t.textContent=this.currentThinkingSynonym))}updateMessageContent(e){if(!this.streamingMessageElement)return;const t=this.streamingMessageElement.querySelector(\".support-message-content\");t&&(t.textContent=e)}finalizeStreamingMessage(){this.streamingMessageElement&&(os(this.streamingMessageElement),this.clearDocReadTimers(),this.streamingMessageElement=null,this.streamingMessageContent=\"\",this.isShowingThoughts=!1,this.thinkingContent=\"\",this.currentThinkingStep=null,this.currentThinkingSynonym=null)}hasPendingMessages(){const e=this.container.querySelector(\"#support-chat-messages\");return!!e?.querySelector(\".support-message.user.pending\")}dropExecutiveAvailability(){this.container.querySelectorAll(\".support-executive-availability\").forEach(os)}addEngineeringHandoffMessage(e,t){const n=document.createElement(\"div\");n.className=\"support-message support-engineering-handoff-message\";const i=e.idempotencyKey||e.metadata?.idempotency_key;i&&n.setAttribute(\"data-idempotency-key\",i),void 0!==e.seq&&e.seq>0&&n.setAttribute(\"data-seq\",e.seq.toString());const s=e.text||e.body||\"\";return s?(n.innerHTML=`\\n      <div class=\"support-engineering-handoff-card\">\\n        <div class=\"support-engineering-handoff-icon\" aria-hidden=\"true\">\\n          <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\\n            <circle cx=\"11\" cy=\"11\" r=\"7\"/>\\n            <path d=\"m20 20-3.5-3.5\"/>\\n          </svg>\\n        </div>\\n        <div class=\"support-engineering-handoff-content\">\\n          <div class=\"support-engineering-handoff-body\">${dc(s)}</div>\\n        </div>\\n      </div>\\n    `,t.appendChild(n),t.scrollTop=t.scrollHeight,n):n}addSystemActionMessage(e,t){const n=document.createElement(\"div\");n.className=\"support-message system-action\";const i=e.idempotencyKey||e.metadata?.idempotency_key;i&&n.setAttribute(\"data-idempotency-key\",i),this.onSystemActionCallback&&e.metadata&&this.onSystemActionCallback(e.metadata,i),void 0!==e.seq&&e.seq>0&&n.setAttribute(\"data-seq\",e.seq.toString());const r=e.metadata?.suggestion_type,o=e.metadata?.decisions||[],a=i&&r?{idempotencyKey:i,suggestionType:r}:void 0;if(\"close_ticket\"===r&&o.length>0){const e=o.filter(e=>\"button\"===e.input_type).map(e=>`<button class=\"support-action-button ${e.style||\"secondary\"}\" data-decision=\"${e.value}\">\\n              ${e.label}\\n            </button>`).join(\"\");n.innerHTML=`\\n        <div class=\"support-system-action-card\">\\n          <div class=\"support-system-action-content\">\\n            <h4>${this.translations.systemActions.closeTicket.heading}</h4>\\n            <p>${this.translations.systemActions.closeTicket.description}</p>\\n          </div>\\n          <div class=\"support-system-action-buttons\">\\n            ${e}\\n          </div>\\n        </div>\\n      `;n.querySelectorAll(\"[data-decision]\").forEach(e=>{const t=e,i=t.getAttribute(\"data-decision\");t.addEventListener(\"click\",()=>{this.handleSystemAction(i||\"\",n,a)})})}else if(\"human_assistance\"===r&&o.length>0){const t=o.filter(e=>\"button\"===e.input_type).map(e=>`<button class=\"support-action-button ${e.style||\"secondary\"}\" data-decision=\"${e.value}\">\\n              ${e.label}\\n            </button>`).join(\"\"),i=this.translations.systemActions.humanAssistance,r=this.getExecutiveName(),l=r?ac(r):null;n.innerHTML=`\\n        <div class=\"support-system-action-card\">\\n          <div class=\"support-system-action-content\">\\n            <h4>${l?i.executiveHeading(l):i.heading}</h4>\\n            <p>${l?i.executiveDescription(l):i.description}</p>\\n          </div>\\n          <div class=\"support-system-action-buttons\">\\n            ${t}\\n          </div>\\n        </div>\\n      `;const c=l?Hc(e.metadata?.executive_availability):null,d=c&&function(e,t){if(e.freeAt<=s())return null;const n=document.createElement(\"div\");n.className=\"support-executive-availability\",n.dataset.reason=e.reason;const i=document.createElement(\"span\");i.className=\"support-executive-availability-dot\";const r=document.createElement(\"span\");return n.appendChild(i),n.appendChild(r),Fc(r,e,t,()=>os(n)),n}(c,this.translations.executiveAvailability.status[c.reason]);d&&n.querySelector(\".support-system-action-content\")?.appendChild(d);n.querySelectorAll(\"[data-decision]\").forEach(e=>{const t=e,i=t.getAttribute(\"data-decision\");t.addEventListener(\"click\",()=>{this.handleSystemAction(i||\"\",n,a)})})}else if(\"csat_survey\"===r&&o.length>0){const t=e.metadata?.comment_field,i=e.metadata?.submit_label||this.translations.systemActions.interactive.submit,s=e.metadata?.skip_label||this.translations.systemActions.interactive.skip,r=!1!==e.metadata?.can_dismiss,l=e.text||e.body||\"\",c=!0===e.metadata?.resolved,d=o.filter(e=>\"star\"===e.input_type).map(e=>`\\n            <button class=\"support-csat-star\" data-value=\"${e.value}\" aria-label=\"Rate ${e.value} star${1!==parseInt(e.value)?\"s\":\"\"}\">\\n              <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n                <path d=\"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z\"/>\\n              </svg>\\n            </button>\\n          `).join(\"\"),u=!c&&t?.enabled?`<textarea class=\"support-csat-comment\" placeholder=\"${t.placeholder||\"\"}\"></textarea>`:\"\",p=c?\"\":`\\n        <div class=\"support-csat-buttons\">\\n          <button class=\"support-csat-submit\" disabled>${i}</button>\\n          ${r?`<button class=\"support-csat-skip\">${s}</button>`:\"\"}\\n        </div>\\n      `;n.innerHTML=`\\n        <div class=\"support-system-action-card support-csat-survey${c?\" resolved\":\"\"}\">\\n          <h4 class=\"support-csat-title\">${uc(l)}</h4>\\n          <div class=\"support-csat-stars\" role=\"radiogroup\" aria-label=\"${this.translations.aria.rating}\">\\n            ${d}\\n          </div>\\n          ${u}\\n          ${p}\\n        </div>\\n      `,c?this.markCsatResolved(n,e.metadata?.resolved_decision||\"\"):this.attachCSATHandlers(n,a)}else if(\"api_confirmation\"===r&&o.length>0){const t=e.metadata?.permission_id||\"\",i=e.metadata?.api_call_id||\"\",s=e.text||e.body||\"\";i&&n.setAttribute(\"data-api-call-id\",i);const r=o.filter(e=>\"button\"===e.input_type).map(e=>{const t=e.style||\"secondary\",n=this.translations.systemActions.apiConfirmation;return`<button class=\"support-action-button ${t}\" data-decision=\"${e.value}\">\\n              ${n[e.value]??e.label}\\n            </button>`}).join(\"\");n.innerHTML=`\\n        <div class=\"support-system-action-card support-api-confirmation\">\\n          <div class=\"support-system-action-content\">\\n            <h4 class=\"support-api-confirmation-question\"></h4>\\n          </div>\\n          <div class=\"support-system-action-buttons\">\\n            ${r}\\n          </div>\\n        </div>\\n      `;const a=n.querySelector(\".support-api-confirmation-question\");if(a&&(a.innerHTML=uc(s)),!0===e.metadata?.resolved)this.markApiConfirmationResolved(n,e.metadata?.resolved_decision||\"\");else{n.querySelectorAll(\"[data-decision]\").forEach(e=>{const i=e,s=i.getAttribute(\"data-decision\");i.addEventListener(\"click\",()=>{this.handleApiConfirmation(t,s||\"\",n)})})}}else if(o.length>0){const t=new hc(this.translations),i={suggestionType:r||\"\",body:e.text||e.body,decisions:o,commentField:e.metadata?.comment_field,canDismiss:!1!==e.metadata?.can_dismiss,submitLabel:e.metadata?.submit_label,skipLabel:e.metadata?.skip_label,resolved:e.metadata?.resolved,resolvedDecision:e.metadata?.resolved_decision},s=t.render(i);n.appendChild(s),s.addEventListener(\"interactive-submit\",e=>{const{decision:t,comment:n}=e.detail,i=new CustomEvent(\"system-action\",{detail:{action:t,comment:n,source:a},bubbles:!0});this.container.dispatchEvent(i)})}return\"goal_nudge\"===r&&this.holdGoalNudgeControls(n,e),t.appendChild(n),this.scrollToBottom(),this.currentSystemActionElement=n,n}holdGoalNudgeControls(e,t){this.liveGoalNudgeElement&&this.liveGoalNudgeElement!==e&&(this.retireGoalNudgeCard(this.liveGoalNudgeElement),this.liveGoalNudgeElement=null),!0!==t.metadata?.resolved&&(t.bubble_message?this.liveGoalNudgeElement=e:this.retireGoalNudgeCard(e))}retireGoalNudgeCard(e){const t=e.querySelector(\".support-interactive-card\");t&&!t.classList.contains(\"resolved\")&&(t.classList.add(\"resolved\"),t.querySelectorAll(\".support-interactive-button-group, .support-interactive-buttons, .support-interactive-comment\").forEach(e=>os(e)))}addTourMessage(e,t){const n=document.createElement(\"div\");n.className=\"support-message agent tour-message\",void 0!==e.seq&&e.seq>0&&n.setAttribute(\"data-seq\",e.seq.toString());const i=e.tour;if(!i)return n;n.innerHTML=`\\n      <div class=\"support-avatar\">\\n        <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n          <path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\"/>\\n        </svg>\\n      </div>\\n      <div class=\"support-message-content\">\\n        ${e.text||e.body?`<div>${dc(e.text||e.body||\"\")}</div>`:\"\"}\\n        <div class=\"support-tour-card\">\\n          <div class=\"support-tour-header\">\\n            <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><path d=\"M12 16v-4\"/><path d=\"M12 8h.01\"/></svg>\\n            <strong>${i.tour_name}</strong>\\n          </div>\\n          <p class=\"support-tour-description\">${this.translations.tour.stepsCount(i.steps.length)}</p>\\n          <button class=\"support-tour-button\">${this.translations.tour.startTour}</button>\\n        </div>\\n      </div>\\n    `;const s=n.querySelector(\".support-tour-button\");return s&&s.addEventListener(\"click\",()=>{this.onTourStartCallback&&e.tour&&(s.disabled=!0,s.textContent=this.translations.tour.tourStarted,this.onTourStartCallback(e.tour,()=>{s.disabled=!1,s.textContent=this.translations.tour.startTour}))}),t.appendChild(n),this.scrollToBottom(),n}addAgentActionStep(e,t,n){const i={actionType:e.action_type,description:e.element_description,body:e.body,url:e.url};if(this.messages.push({isAgent:!0,is_ephemeral:!0,messageType:\"agent_action\",actionStep:i,idempotencyKey:t,seq:n}),this.screenshotRunStartIndex=-1,this.screenshotRunElements=[],this.activeGroupCardElement=null,!this.activeActionTimeline){const e=this.container.querySelector(\"#support-chat-messages\");if(!e)return;this.activeActionTimeline=new Ha(this.agentName),e.appendChild(this.activeActionTimeline.root)}this.activeActionTimeline.appendStep(i),this.scrollToBottom()}addScreenshotMessage(e,t,n,i){if(this.activeActionTimeline=null,this.messages.push({isAgent:!0,is_ephemeral:!0,messageType:\"screenshot\",screenshotData:{attachmentId:e,metadata:t},idempotencyKey:n,seq:i}),this.activeGroupCardElement)return void this.updateGroupCard();this.screenshotRunStartIndex<0&&(this.screenshotRunStartIndex=this.messages.length-1);const s=this.renderSingleScreenshot(e,t);this.screenshotRunElements.push(s);const r=this.getScreenshotRunItems();for(const e of this.screenshotRunElements)this.groupCardSlides.set(e,r);if(this.screenshotRunElements.length>=this.SCREENSHOT_GROUP_THRESHOLD){const e=r;for(const e of this.screenshotRunElements)os(e);this.screenshotRunElements=[],this.activeGroupCardElement=this.renderScreenshotGroupCard(e)}}updateGroupCard(){if(!this.activeGroupCardElement)return;const e=this.getScreenshotRunItems(),t=e.length,n=this.activeGroupCardElement.querySelector(\".support-screenshot-group-badge\");n&&(n.textContent=this.translations.agent.actionCount(t));const i=this.activeGroupCardElement.querySelector(\".support-screenshot-group-summary\");i&&(i.textContent=this.buildActionSummary(e.map(e=>e.metadata)));const s=t-3;if(s>0){let e=this.activeGroupCardElement.querySelector(\".support-collage-more\");if(!e){const t=this.activeGroupCardElement.querySelectorAll(\".support-collage-img\"),n=t[t.length-1];n&&(e=document.createElement(\"div\"),e.className=\"support-collage-more\",n.appendChild(e))}e&&(e.textContent=this.translations.agent.moreCount(s))}this.groupCardSlides.set(this.activeGroupCardElement,[...e]),this.scrollToBottom()}buildScreenshotResolver(){return e=>this.urlCache?this.urlCache.getUrl(e):Promise.reject(new Error(\"No URL source\"))}renderSingleScreenshot(e,t){const n=this.container.querySelector(\"#support-chat-messages\"),i=document.createElement(\"div\");i.className=\"support-message screenshot-message\";const s=t.element_description||t.action_type,r=t.url?new URL(t.url,window.location.origin).pathname:\"\";return i.innerHTML=`\\n      <div class=\"support-screenshot-header\">\\n        <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z\"/><circle cx=\"12\" cy=\"13\" r=\"4\"/></svg>\\n        <span class=\"support-screenshot-badge\">${t.action_type}</span>\\n        <span class=\"support-screenshot-desc\">${s}</span>\\n      </div>\\n      ${t.body?`<div class=\"support-screenshot-body\">${t.body}</div>`:\"\"}\\n      ${r?`<div class=\"support-screenshot-url\">${r}</div>`:\"\"}\\n      <div class=\"support-screenshot-image support-attachment-loading\">${this.translations.attachments.loadingImage}</div>\\n    `,n&&(n.appendChild(i),this.scrollToBottom()),this.urlCache&&this.urlCache.getUrl(e).then(e=>{const t=i.querySelector(\".support-screenshot-image\");if(t){const n=this.isScrolledToBottom();t.classList.remove(\"support-attachment-loading\"),t.innerHTML=`<img src=\"${e}\" alt=\"${s}\" />`,n&&this.scrollToBottomOnLoad(t)}}).catch(()=>{const e=i.querySelector(\".support-screenshot-image\");e&&(e.textContent=this.translations.attachments.failedToLoad,e.classList.add(\"error\"))}),i.style.cursor=\"pointer\",i.addEventListener(\"click\",()=>{const t=this.buildScreenshotResolver();if(!t)return;const n=this.groupCardSlides.get(i)??[],s=n.findIndex(t=>t.attachmentId===e),r=n.map(e=>({attachmentId:e.attachmentId,actionType:e.metadata.action_type,description:e.metadata.element_description||e.metadata.action_type,body:e.metadata.body,url:e.metadata.url}));Fa.getInstance().open(r,t,Math.max(s,0))}),i}renderScreenshotGroupCard(e){const t=this.container.querySelector(\"#support-chat-messages\"),n=document.createElement(\"div\");if(!t)return n;const i=e.length,s=this.buildActionSummary(e.map(e=>e.metadata)),r=`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${L}</svg>`,o=e.slice(0,3),a=i-3;let l=\"\";if(1===o.length)l=`\\n        <div class=\"support-screenshot-collage\">\\n          <div class=\"support-collage-img\" data-attachment-id=\"${o[0].attachmentId}\">\\n            <div class=\"support-attachment-loading\">${this.translations.attachments.loadingImage}</div>\\n          </div>\\n        </div>\\n      `;else if(2===o.length)l=`\\n        <div class=\"support-screenshot-collage\">\\n          <div class=\"support-collage-img\" data-attachment-id=\"${o[0].attachmentId}\">\\n            <div class=\"support-attachment-loading\">${this.translations.attachments.loadingImage}</div>\\n          </div>\\n          <div class=\"support-collage-img\" data-attachment-id=\"${o[1].attachmentId}\">\\n            <div class=\"support-attachment-loading\">${this.translations.attachments.loadingImage}</div>\\n          </div>\\n        </div>\\n      `;else{const e=a>0?`<div class=\"support-collage-more\">${this.translations.agent.moreCount(a)}</div>`:\"\";l=`\\n        <div class=\"support-screenshot-collage\">\\n          <div class=\"support-collage-left\">\\n            <div class=\"support-collage-img\" data-attachment-id=\"${o[0].attachmentId}\">\\n              <div class=\"support-attachment-loading\">${this.translations.attachments.loadingImage}</div>\\n            </div>\\n          </div>\\n          <div class=\"support-collage-right\">\\n            <div class=\"support-collage-img\" data-attachment-id=\"${o[1].attachmentId}\">\\n              <div class=\"support-attachment-loading\">${this.translations.attachments.loadingImage}</div>\\n            </div>\\n            <div class=\"support-collage-img\" data-attachment-id=\"${o[2].attachmentId}\">\\n              <div class=\"support-attachment-loading\">${this.translations.attachments.loadingImage}</div>\\n              ${e}\\n            </div>\\n          </div>\\n        </div>\\n      `}n.className=\"support-message support-screenshot-group-card\",n.innerHTML=`\\n      <div class=\"support-screenshot-group-header\">\\n        ${r}\\n        <span class=\"support-screenshot-group-label\">${this.translations.agent.actionsTitle}</span>\\n        <span class=\"support-screenshot-group-badge\">${this.translations.agent.actionCount(i)}</span>\\n      </div>\\n      <div class=\"support-screenshot-group-summary\">${s}</div>\\n      ${l}\\n    `,t.appendChild(n),this.scrollToBottom();for(const e of o){const t=n.querySelector(`[data-attachment-id=\"${e.attachmentId}\"]`);t&&(this.urlCache&&this.urlCache.getUrl(e.attachmentId).then(n=>{const i=t.querySelector(\".support-attachment-loading\");if(i){const s=this.isScrolledToBottom();i.outerHTML=`<img src=\"${n}\" alt=\"${e.metadata.action_type}\" />`,s&&this.scrollToBottomOnLoad(t)}}).catch(()=>{const e=t.querySelector(\".support-attachment-loading\");e&&(e.textContent=this.translations.attachments.failedToLoad)}))}return this.groupCardSlides.set(n,[...e]),n.style.cursor=\"pointer\",n.addEventListener(\"click\",()=>{const e=this.buildScreenshotResolver();if(!e)return;const t=(this.groupCardSlides.get(n)??[]).map(e=>({attachmentId:e.attachmentId,actionType:e.metadata.action_type,description:e.metadata.element_description||e.metadata.action_type,body:e.metadata.body,url:e.metadata.url}));Fa.getInstance().open(t,e,0)}),n}buildActionSummary(e){return e.map(e=>e.element_description?`${e.action_type} ${e.element_description}`:e.action_type).join(\" → \")}handleSystemAction(e,t,n){t.querySelectorAll(\"button\").forEach(e=>{e.disabled=!0,e.style.opacity=\"0.5\",e.style.cursor=\"not-allowed\"});const i=new CustomEvent(\"system-action\",{detail:{action:e,source:n},bubbles:!0});this.container.dispatchEvent(i);const s=t.querySelector(\".support-system-action-card\");if(s){const e=document.createElement(\"div\");e.className=\"support-system-action-feedback\",e.textContent=this.translations.messages.processing,s.appendChild(e)}}handleApiConfirmation(e,t,n){const i=new CustomEvent(\"api-confirmation\",{detail:{permission_id:e,decision:t},bubbles:!0});this.container.dispatchEvent(i),this.markApiConfirmationResolved(n,t)}markApiConfirmationResolved(e,t){const n=e.querySelector(\".support-api-confirmation\");n&&n.classList.add(\"resolved\");e.querySelectorAll(\"[data-decision]\").forEach(e=>{const n=e;n.disabled=!0,n.getAttribute(\"data-decision\")===t&&n.classList.add(\"selected\")})}attachCSATHandlers(e,t){const n=e.querySelectorAll(\".support-csat-star\"),i=e.querySelector(\".support-csat-submit\"),s=e.querySelector(\".support-csat-skip\"),r=e.querySelector(\".support-csat-comment\");let o=null;n.forEach((e,t)=>{const s=e;s.addEventListener(\"mouseenter\",()=>{s.disabled||n.forEach((e,n)=>{n<=t?e.classList.add(\"hover\"):e.classList.remove(\"hover\")})}),s.addEventListener(\"click\",()=>{o=s.getAttribute(\"data-value\"),n.forEach((e,n)=>{n<=t?e.classList.add(\"active\"):e.classList.remove(\"active\")}),i.disabled=!1})});const a=e.querySelector(\".support-csat-stars\");a?.addEventListener(\"mouseleave\",()=>{n.forEach(e=>{e.classList.remove(\"hover\")})}),i.addEventListener(\"click\",()=>{if(!o)return;const n=r?.value?.trim()||void 0;this.disableCSATInputs(e);const i=new CustomEvent(\"system-action\",{detail:{action:o,comment:n,source:t},bubbles:!0});this.container.dispatchEvent(i)}),s?.addEventListener(\"click\",()=>{this.disableCSATInputs(e);const n=new CustomEvent(\"system-action\",{detail:{action:\"skip\",source:t},bubbles:!0});this.container.dispatchEvent(n)})}disableCSATInputs(e){const t=e.querySelectorAll(\".support-csat-star\"),n=e.querySelector(\".support-csat-submit\"),i=e.querySelector(\".support-csat-skip\"),s=e.querySelector(\".support-csat-comment\");t.forEach(e=>{e.disabled=!0}),n&&(n.disabled=!0),i&&(i.disabled=!0),s&&(s.disabled=!0);const r=e.querySelector(\".support-csat-survey\");if(r){const e=document.createElement(\"div\");e.className=\"support-system-action-feedback\",e.textContent=this.translations.systemActions.csatSurvey.thankYou,r.appendChild(e)}}markCsatResolved(e,t){const n=e.querySelector(\".support-csat-survey\");n?.classList.add(\"resolved\");const i=parseInt(t,10);if(e.querySelectorAll(\".support-csat-star\").forEach(e=>{e.disabled=!0;const t=parseInt(e.getAttribute(\"data-value\")||\"0\",10);!Number.isNaN(i)&&i>0&&t<=i&&e.classList.add(\"active\")}),e.querySelectorAll(\".support-csat-submit, .support-csat-skip, .support-csat-comment\").forEach(e=>{e.disabled=!0}),n&&!n.querySelector(\".support-system-action-feedback\")){const e=document.createElement(\"div\");e.className=\"support-system-action-feedback\",e.textContent=this.translations.systemActions.csatSurvey.thankYou,n.appendChild(e)}}removeCurrentSystemAction(){this.currentSystemActionElement&&(os(this.currentSystemActionElement),this.currentSystemActionElement=null)}testThinkingBubble(){this.startStreamingMessage();const e=[\"Analyzing the user question...\",\"Searching knowledge base...\",\"Found relevant information...\",\"Formulating response...\"];let t=0;const n=setInterval(()=>{t<e.length?(this.appendToStreamingMessage(e[t]+\" \",t),t++):(clearInterval(n),setTimeout(()=>{this.appendToStreamingMessage(\"FINAL RESPONSE: Here is the answer to your question!\")},1e3))},1500)}updateLanguage(e){this.translations=e}}class Uc{constructor(e,t){this.lastReadSeq=0,this.lastSeenSeq=0,this.externalUnreadCounts=new Map,this.readTimerId=null,this.isVisible=!0,this.isOpen=!1,this.ticketId=null,this.conversationType=\"ticket\",this.container=e,this.onSendRead=t.onSendRead,this.onGetMaxSeq=t.onGetMaxSeq,this.onApplyBubbleAnimation=t.onApplyBubbleAnimation,this.onRemoveBubbleAnimation=t.onRemoveBubbleAnimation,this.onUnreadChange=t.onUnreadChange,this.translations=Na()}getStorageKey(){return this.ticketId?Uc.storageKey(this.conversationType,this.ticketId):null}static storageKey(e,t){return`${Uc.STORAGE_KEY_PREFIX}${e}_${t}`}static readStoredLastReadSeq(e,t){try{const n=parseInt(localStorage.getItem(Uc.storageKey(e,t))??\"\",10);return!isNaN(n)&&n>0?n:0}catch{return 0}}loadFromStorage(){if(!this.ticketId)return;const e=Uc.readStoredLastReadSeq(this.conversationType,this.ticketId);e>0&&(this.lastReadSeq=e)}saveToStorage(){const e=this.getStorageKey();if(e)try{localStorage.setItem(e,this.lastReadSeq.toString())}catch{}}setTicketId(e){this.ticketId=e,this.conversationType=\"ticket\",e&&this.loadFromStorage()}setConversationId(e,t){this.ticketId=t,this.conversationType=e,t&&this.loadFromStorage()}setVisibility(e){this.isVisible=e,!e&&this.readTimerId&&(clearTimeout(this.readTimerId),this.readTimerId=null)}setChatOpen(e){this.isOpen=e}setLastSeenSeq(e){this.lastSeenSeq=e}getLastReadSeq(){return this.lastReadSeq}setLastReadSeq(e){this.lastReadSeq=e,this.saveToStorage()}getLastSeenSeq(){return this.lastSeenSeq}setExternalUnreadCount(e,t){this.externalUnreadCounts.set(e,Math.max(0,t)),this.updateUnreadIndicator()}getExternalUnreadCount(){let e=0;return this.externalUnreadCounts.forEach(t=>{e+=t}),e}updateUnreadIndicator(){const e=this.container.querySelectorAll(\".support-unread-indicator\"),t=this.lastSeenSeq>this.lastReadSeq,n=this.getUnreadCount(),i=this.getExternalUnreadCount(),s=n+i,r=(t||i>0)&&!this.isOpen;e.forEach(e=>{r?(e.classList.remove(\"hidden\"),s>0&&(e.textContent=s>99?\"99+\":s.toString())):e.classList.add(\"hidden\")}),t&&!this.isOpen?this.onApplyBubbleAnimation?.():this.onRemoveBubbleAnimation?.(),this.onUnreadChange?.()}getUnreadCount(){const e=this.container.querySelector(\"#support-chat-messages\");if(!e)return 0;const t=Array.from(e.querySelectorAll(\".support-message\")).filter(e=>{const t=parseInt(e.getAttribute(\"data-seq\")||\"0\"),n=e.classList.contains(\"user\");return t>0&&t>this.lastReadSeq&&!n});return t.length}showNewMessagesDivider(){const e=this.container.querySelector(\"#support-chat-messages\");if(!e)return;const t=e.querySelector(\".support-new-messages-divider\");t&&os(t);const n=Array.from(e.querySelectorAll(\".support-message\")).find(e=>{const t=parseInt(e.getAttribute(\"data-seq\")||\"0\"),n=e.classList.contains(\"user\");return t>0&&t>this.lastReadSeq&&!n});if(n){const e=document.createElement(\"div\");e.className=\"support-new-messages-divider\",e.innerHTML=`<span class=\"support-new-messages-text\">${this.translations.messages.newMessages}</span>`,n.parentNode?.insertBefore(e,n)}}hideNewMessagesDivider(){const e=this.container.querySelector(\"#support-chat-messages\");if(!e)return;const t=e.querySelector(\".support-new-messages-divider\");t&&os(t)}scheduleReadTimer(){this.readTimerId&&(clearTimeout(this.readTimerId),this.readTimerId=null),this.isVisible&&(this.readTimerId=setTimeout(()=>{this.markMessagesAsRead()},3e3))}markMessagesAsRead(){this.advanceReadSeq(this.onGetMaxSeq())}markReadUpTo(e,t,n){this.conversationType===e&&this.ticketId===t&&this.advanceReadSeq(n)}advanceReadSeq(e){e<=this.lastReadSeq||(this.lastReadSeq=e,this.saveToStorage(),this.sendRead(e))}sendRead(e){this.onSendRead(e),this.updateUnreadIndicator(),this.hideNewMessagesDivider()}hasUnreadMessages(){return this.lastSeenSeq>this.lastReadSeq}reset(){this.ticketId=null,this.lastReadSeq=0,this.lastSeenSeq=0,this.readTimerId&&(clearTimeout(this.readTimerId),this.readTimerId=null)}cleanup(){this.readTimerId&&(clearTimeout(this.readTimerId),this.readTimerId=null)}}Uc.STORAGE_KEY_PREFIX=\"support_widget_last_read_seq_\";const jc=new Set([\"__proto__\",\"constructor\",\"prototype\"]),Wc=/^[A-Za-z0-9-]{1,40}$/,Vc=/^[A-Za-z0-9-]{1,64}$/,Gc=/^[A-Za-z0-9-]{0,40}$/,Kc=/^[A-Za-z0-9_-]+(?:\\.[A-Za-z0-9_-]+)*$/,Yc=new Set([\"bearer\",\"cookie\",\"none\"]),Xc=new Set([\"json\",\"form\"]),Jc=/^https?:\\/\\/[^/?#]/i,Qc=new Set([\"version\",\"authMode\",\"tokenSource\",\"csrfSource\",\"csrfHeader\",\"authHeader\",\"authScheme\",\"bodyEncoding\",\"staticHeaders\",\"attributionEnabled\"]),Zc={localStorage:\"key\",sessionStorage:\"key\",cookie:\"name\",meta:\"name\",callback:\"id\"},ed=new Set([\"localStorage\",\"sessionStorage\"]),td=new Set([\"descriptor\",\"api_base_url\"]);function nd(e){return\"object\"==typeof e&&null!==e&&!Array.isArray(e)}function id(e,t){for(const n of Object.keys(e))if(!t.has(n))return!1;return!0}function sd(e){if(!nd(e))return null;const t=e.kind;if(\"string\"!=typeof t||!(t in Zc))return null;const n=Zc[t],i=ed.has(t),s=new Set([\"kind\",n]);if(i&&s.add(\"path\"),!id(e,s))return null;const r=e[n];if(\"string\"!=typeof r||0===r.length)return null;let o;if(void 0!==e.path){if(\"string\"!=typeof e.path||!Kc.test(e.path))return null;o=e.path}switch(t){case\"localStorage\":return void 0===o?{kind:\"localStorage\",key:r}:{kind:\"localStorage\",key:r,path:o};case\"sessionStorage\":return void 0===o?{kind:\"sessionStorage\",key:r}:{kind:\"sessionStorage\",key:r,path:o};case\"cookie\":return{kind:\"cookie\",name:r};case\"meta\":return{kind:\"meta\",name:r};case\"callback\":return{kind:\"callback\",id:r};default:return null}}function rd(e){if(!nd(e))return null;if(!id(e,Qc))return null;const t=e.version;if(\"number\"!=typeof t||!Number.isFinite(t))return null;const n=e.authMode;if(\"string\"!=typeof n||!Yc.has(n))return null;const i=e.attributionEnabled;if(\"boolean\"!=typeof i)return null;const s={version:t,authMode:n,attributionEnabled:i};if(void 0!==e.tokenSource){const t=sd(e.tokenSource);if(null===t)return null;s.tokenSource=t}if(void 0!==e.csrfSource){const t=sd(e.csrfSource);if(null===t)return null;s.csrfSource=t}if(void 0!==e.csrfHeader){const t=e.csrfHeader;if(\"string\"!=typeof t||!Wc.test(t))return null;s.csrfHeader=t}if(void 0!==e.staticHeaders){const t=function(e){if(!nd(e))return null;const t=Object.create(null);for(const[n,i]of Object.entries(e)){if(jc.has(n))return null;if(\"string\"!=typeof i)return null;if(i.includes(\"${\"))return null;t[n]=i}return t}(e.staticHeaders);if(null===t)return null;s.staticHeaders=t}if(void 0!==e.authHeader){const t=e.authHeader;if(\"string\"!=typeof t||t.includes(\"${\")||!Vc.test(t))return null;s.authHeader=t}if(void 0!==e.authScheme){const t=e.authScheme;if(\"string\"!=typeof t||t.includes(\"${\")||!Gc.test(t))return null;s.authScheme=t}if(void 0!==e.bodyEncoding){const t=e.bodyEncoding;if(\"string\"!=typeof t||!Xc.has(t))return null;s.bodyEncoding=t}return s}function od(e){return e.replace(/\\/+$/,\"\")}function ad(e,t){const n=Array.isArray(e)?e.filter(e=>\"string\"==typeof e&&Jc.test(e)):[];return[...new Set([t,...n].map(od))]}function ld(e){return\"number\"==typeof e.metadata?.feature_check_in_id||\"feature_check_in\"===e.metadata?.suggestion_type||\"feature_check_in\"===e.metadata?.nudge_type}function cd(e){if(!e||\"object\"!=typeof e)return null;const t=e;return null===t.check_in?{check_in:null}:function(e){if(!e||\"object\"!=typeof e)return!1;const t=e;return\"number\"==typeof t.id&&\"string\"==typeof t.prompt&&!0===t.is_required&&function(e){if(!e||\"object\"!=typeof e)return!1;const t=e;return\"number\"==typeof t.id&&\"string\"==typeof t.name&&\"string\"==typeof t.description&&\"number\"==typeof t.position}(t.feature)}(t.check_in)?{check_in:t.check_in}:null}function dd(e){if(\"string\"!=typeof e||!e.trim())return null;try{const t=new URL(e.trim());return\"http:\"===t.protocol||\"https:\"===t.protocol?t.href:null}catch{return null}}function ud(e){return e.toLowerCase().normalize(\"NFD\").replace(/[̀-ͯ]/g,\"\").replace(/[\\s_]/g,\"\")}const pd=[\"country\",\"isocountry\",\"isopais\",\"pais\"];let hd=null;function gd(e){if(\"string\"!=typeof e)return null;const t=e.trim();if(!t)return null;try{if(/^[A-Za-z]{2}$/.test(t)){const e=t.toUpperCase(),n=new Intl.DisplayNames([\"en\"],{type:\"region\",fallback:\"none\"}).of(e);return n&&!/unknown/i.test(n)?e:null}return function(){if(hd)return hd;const e={};for(const t of[\"en\",\"es\"]){const n=new Intl.DisplayNames([t],{type:\"region\",fallback:\"none\"});for(let t=65;t<=90;t++)for(let i=65;i<=90;i++){const s=String.fromCharCode(t)+String.fromCharCode(i),r=n.of(s);r&&r!==s&&!/unknown/i.test(r)&&(e[ud(r)]=s)}}return hd=e,e}()[ud(t)]??null}catch{return null}}const md={refresh:\"refresh_feature_check_in\",snapshot:\"snapshot_feature_check_in\"};class fd{constructor(e){this.onPublish=e,this.current=null,this.transport=null,this.connection=\"down\",this.needsReconcile=!1,this.bypassBackoff=!1,this.failures=0,this.retryTimer=null,this.readinessTimer=null,this.maxAgeTimer=null,this.destroyed=!1,this.waiters=[],this.pending=new Map,this.expired=new Set,this.answered=new Set,this.shown=new Set}getCurrent(){return this.current}setTransport(e){this.transport=e}setConnection(e){this.connection=e,this.clearReadiness(),\"awaiting\"===e&&(this.readinessTimer=setTimeout(es(\"check-in-recovery:readiness\",()=>{this.readinessTimer=null,this.settle(!1)}),1e4)),\"ordered\"!==e&&this.dropPending()&&this.fail(),this.pump(),this.canAnswer()||this.settle(!1)}applyBootstrap(e){e&&(this.needsReconcile=!1,this.bypassBackoff=!1,this.armMaxAge(),this.publish(e.check_in),this.settle(!0))}applyChatFrame(e){\"ordered\"!==this.connection&&this.publish(e)}receive(e,t){if(null===t)return void this.publish(e);const n=this.takePending(t);if(n)return this.publish(e),void(\"refresh\"===n.kind&&this.reconciled());this.expired.delete(t)&&this.publish(e)}receiveUnavailable(e){null===e||this.takePending(e)?this.fail():this.expired.delete(e)}reconcile(){this.needsReconcile=!0,this.isRefreshing()||(this.bypassBackoff=!0),this.pump()}acknowledgeAnswer(e){this.shown.has(e.check_in_id)&&(this.answered.add(e.check_in_id),null!==this.current&&this.current.id!==e.check_in_id||this.publish(cd({check_in:e.next_check_in})?.check_in??null),\"ordered\"===this.connection&&this.send(\"snapshot\"))}async recoverStale(e){this.reconcile();!!this.canAnswer()&&await new Promise(e=>this.waiters.push(e))||this.current?.id!==e.id||this.publish(null)}reset(){const e=null!==this.current;this.current=null,this.needsReconcile=!1,this.bypassBackoff=!1,this.failures=0,this.clearRetry(),this.clearMaxAge(),this.dropPending(),this.expired.clear(),this.answered.clear(),this.shown.clear(),this.settle(!1),e&&this.onPublish(null)}destroy(){this.destroyed=!0,this.reset()}publish(e){e&&this.answered.has(e.id)||(e&&this.shown.add(e.id),this.current=e,this.onPublish(e))}pump(){if(this.needsReconcile&&\"ordered\"===this.connection&&!this.isRefreshing()){if(null!==this.retryTimer){if(!this.bypassBackoff)return;this.clearRetry()}this.bypassBackoff=!1,this.send(\"refresh\")}}send(e){const t=cs();if(!this.transport?.sendCheckInRequest(md[e],t))return;const n=setTimeout(es(\"check-in-recovery:deadline\",()=>this.expire(t)),1e4);this.pending.set(t,{kind:e,timer:n})}expire(e){this.takePending(e)&&(this.expired.add(e),this.fail())}reconciled(){this.needsReconcile=!1,this.bypassBackoff=!1,this.failures=0,this.clearRetry(),this.armMaxAge(),this.settle(!0)}fail(){this.needsReconcile=!0;const e=Math.min(5e3*2**this.failures,3e5);this.failures+=1,this.clearRetry(),this.retryTimer=setTimeout(es(\"check-in-recovery:retry\",()=>{this.retryTimer=null,this.pump()}),e/2+Math.random()*e/2),this.canAnswer()||this.settle(!1)}armMaxAge(){this.clearMaxAge(),this.destroyed||(this.maxAgeTimer=setTimeout(es(\"check-in-recovery:max-age\",()=>{this.maxAgeTimer=null,\"hidden\"!==document.visibilityState&&(this.needsReconcile=!0,this.pump())}),36e5+6e4*Math.random()))}canAnswer(){return this.isRefreshing()||null!==this.readinessTimer}settle(e){const t=this.waiters;this.waiters=[],t.forEach(t=>t(e))}isRefreshing(){return[...this.pending.values()].some(e=>\"refresh\"===e.kind)}takePending(e){const t=this.pending.get(e);return t?(clearTimeout(t.timer),this.pending.delete(e),t):null}dropPending(){const e=this.isRefreshing();return this.pending.forEach(e=>clearTimeout(e.timer)),this.pending.clear(),e}clearMaxAge(){null!==this.maxAgeTimer&&(clearTimeout(this.maxAgeTimer),this.maxAgeTimer=null)}clearReadiness(){null!==this.readinessTimer&&(clearTimeout(this.readinessTimer),this.readinessTimer=null)}clearRetry(){null!==this.retryTimer&&(clearTimeout(this.retryTimer),this.retryTimer=null)}}class bd{constructor(e,t){this.ticketId=null,this.sessionId=null,this.userData=null,this.aiActive=!0,this.contactInfoSubmitted=!1,this.pendingNps=null,this.pendingActivationForm=null,this.shouldPlayIntro=!1,this.introMode=\"widget\",this.introAgentName=null,this.introAgentAvatarUrl=null,this.executive=null,this.agent=null,this.source=null,this.engineeringTickets=[],this.lastTicket=null,this.apiBridge=null,this.restoring=null,this.sourceLoss=null,this.onCampaignBanner=null,this.onAgentPersona=null,this.onFeatureCheckIn=null,this.onContactChange=null,this.onSessionIdChange=null,this.checkIns=new fd(e=>this.onFeatureCheckIn?.(e)),this.apiClient=e,this.tokenStorage=new Es(t);const n=this.tokenStorage.getSourceId();n&&this.apiClient.setSourceId(n),this.apiClient.setOnSourceRejected(()=>this.dropSource(\"source_rejected\")),this.apiClient.setOnIdentityRefused(e=>this.fallBackToAnonymous(e)),this.apiClient.setSourceRestorer(()=>this.restoreSession())}dropSource(e){this.sourceLoss=e,this.checkIns.reset(),this.tokenStorage.clearSourceId(),this.apiClient.setSourceId(null),this.onContactChange?.()}fallBackToAnonymous(e){Zi(\"identity_fallback_anonymous\",{reason:e}),\"static_token_expired\"===e&&Ji(\"[Identity] static identity token expired; use getIdentityToken\"),this.apiClient.setIdentity(null),this.userData=null,this.dropSource(\"source_rejected\")}isRestoring(){return null!==this.restoring}restoreSession(){return this.restoring||(this.restoring=this.restore().finally(()=>{this.restoring=null})),this.restoring}async restore(){const e=this.sourceLoss??\"missing_on_request\",t=this.userData?this.apiClient.getIdentity():null;let n=null;try{this.applyBootstrap(await this.apiClient.loadSession());const e=this.apiClient.getSourceId();if(n=e,e&&t)try{await this.identify(t),n=this.apiClient.getSourceId()}catch(t){Ji(\"[SessionManager] Identify failed while restoring the session\",t),this.apiClient.setIdentity(null),this.userData=null,this.adoptSource(e)}this.sourceLoss=null}catch(e){Ji(\"[SessionManager] Failed to restore the session\",e)}const i={reason:e,identified:String(Boolean(t&&this.userData)),ok:String(null!==n)};return null===n?Zi(\"source_restored\",i):Qi(\"source_restored\",JSON.stringify(i)),n}adoptSource(e){this.apiClient.getSourceId()!==e&&this.checkIns.reset(),this.tokenStorage.setSourceId(e),this.apiClient.setSourceId(e),this.onContactChange?.()}async loadAnonymousSession(){try{const e=this.tokenStorage.getSourceId(),t=await this.apiClient.loadSession(e);return this.applyBootstrap(t),this.sourceLoss=null,{ticketId:this.ticketId??void 0,sessionId:this.sessionId??void 0,contactInfoSubmitted:this.contactInfoSubmitted,source:this.source}}catch(e){return Ji(\"[SessionManager] Failed to load anonymous session\",e),this.apiClient.getSourceId()||(this.sourceLoss=\"boot_failed\"),{contactInfoSubmitted:!1,source:null}}}applyBootstrap(e){e.source_id?this.adoptSource(e.source_id):console.warn(\"[SessionManager] Backend did not return source_id in bootstrap response\"),this.ticketId=e.conversation_id??null,this.assignSessionId(e.session_id??null),this.contactInfoSubmitted=e.contact_info_submitted??this.contactInfoSubmitted,this.aiActive=e.ai_active??this.aiActive,this.pendingNps=e.nps?{campaignId:e.nps.campaign_id,campaignName:e.nps.campaign_name}:null,this.pendingActivationForm=e.activation_form?.questions?.length?e.activation_form:null,this.checkIns.applyBootstrap(cd(e)),this.engineeringTickets=e.tickets??[],this.lastTicket=e.last_ticket??null,this.apiBridge=function(e,t){if(!nd(e))return null;if(!id(e,td))return null;const n=e.api_base_url;if(\"string\"!=typeof n||!Jc.test(n))return null;const i=rd(e.descriptor);return null===i?null:{descriptor:i,apiBaseUrl:n,allowedBaseUrls:ad(t,n)}}(e.api_bridge,e.api_bridge_allowed_base_urls),this.source=e.source??null,this.onCampaignBanner?.(e.campaign_banner??null),this.shouldPlayIntro=!0===e.show_intro,this.introMode=\"takeover\"===e.intro_mode?\"takeover\":\"widget\",this.introAgentName=e.intro_agent_name??null,this.introAgentAvatarUrl=e.intro_agent_avatar_url??null,this.executive=function(e){if(!e||\"object\"!=typeof e||Array.isArray(e))return null;const t=e,n=\"string\"==typeof t.name?t.name.trim():\"\";return n?{name:n,avatar_url:\"string\"==typeof t.avatar_url&&t.avatar_url.trim()?t.avatar_url.trim():null,role_label:\"string\"==typeof t.role_label?t.role_label.trim():\"\"}:null}(e.executive),this.agent=function(e){if(!e||\"object\"!=typeof e||Array.isArray(e))return null;const t=e,n=\"string\"==typeof t.name?t.name.trim():\"\";return n?{name:n,avatar_url:dd(t.avatar_url)}:null}(e.agent),this.onAgentPersona?.(this.agent)}getApiBridge(){return this.apiBridge}async setUser(e){this.apiClient.setIdentity(e);try{await this.identify(e)}catch(e){throw this.apiClient.setIdentity(null),this.apiClient.getSourceId()||await this.restoreSession(),e}}async identify(e){const{country:t,customFields:n}=function(e){if(!e)return{};let t;for(const n of pd){for(const[i,s]of Object.entries(e)){if(ud(i)!==n)continue;const e=gd(s);if(e){t=e;break}}if(t)break}if(!t)return{customFields:e};const n={};for(const[t,i]of Object.entries(e))pd.includes(ud(t))||(n[t]=i);return{country:t,customFields:Object.keys(n).length?n:void 0}}(e.customFields),i=await this.apiClient.identifyUser({external_id:e.externalId,email:e.email,name:e.name,phone:e.phone,contact_company:e.contactCompany,contact_company_external_id:e.contactCompanyExternalId,country:t,custom_fields:n});this.applyBootstrap(i),this.userData={externalId:e.externalId,email:e.email,name:e.name,phone:e.phone,contactCompany:e.contactCompany,contactCompanyExternalId:e.contactCompanyExternalId,isIdentityVerified:!0===i.is_identity_verified,country:t,customFields:n}}getEngineeringTickets(){return this.engineeringTickets}getLastTicket(){return this.lastTicket}getUser(){return this.userData}clearUser(){this.userData=null,this.shouldPlayIntro=!1,this.ticketId=null,this.assignSessionId(null),this.contactInfoSubmitted=!1,this.pendingNps=null,this.pendingActivationForm=null,this.checkIns.reset(),this.engineeringTickets=[],this.lastTicket=null,this.source=null,this.executive=null,this.agent=null,this.onAgentPersona?.(null),this.apiBridge=null,this.onCampaignBanner?.(null),this.tokenStorage.clearSourceId(),this.apiClient.setSourceId(null),this.apiClient.setIdentity(null),this.onContactChange?.()}getIdentityProof(){return this.apiClient.getIdentityProof()}refreshIdentityProof(){return this.apiClient.refreshIdentityProof()}getShouldPlayIntro(){return this.shouldPlayIntro}getIntroMode(){return this.introMode}getIntroAgentName(){return this.introAgentName?.trim()||this.agent?.name||null}getIntroAgentAvatarUrl(){return this.introAgentAvatarUrl?.trim()||this.agent?.avatar_url||null}getAgent(){return this.agent}getAgentName(){return this.agent?.name??T}getExecutive(){return this.executive}getPendingNPS(){return this.pendingNps}clearPendingNPS(){this.pendingNps=null}getFeatureCheckIn(){return this.checkIns.getCurrent()}getPendingActivationForm(){return this.pendingActivationForm}setPendingActivationForm(e){this.pendingActivationForm=e}clearPendingActivationForm(){this.pendingActivationForm=null}getSessionUuid(){return this.tokenStorage.getSourceId()}getSourceId(){return this.tokenStorage.getSourceId()}setTicketId(e){this.ticketId=e}getTicketId(){return this.ticketId}setSessionId(e){this.assignSessionId(e)}assignSessionId(e){this.sessionId!==e&&(this.sessionId=e,this.onSessionIdChange?.(e))}getSessionId(){return this.sessionId}setAiActive(e){this.aiActive=e}getAiActive(){return this.aiActive}isContactInfoSubmitted(){return this.contactInfoSubmitted}setContactInfoSubmitted(e){this.contactInfoSubmitted=e}}class yd{constructor(e){this.cachedTarget=null,this.snapshot=null,this.pendingCleanup=null,this.pushed=!1,this.config=e}updateConfig(e){this.config={...this.config,...e}}isPushed(){return this.pushed}push(e){if(\"push\"!==this.config.behavior)return;if(P())return;null!==this.pendingCleanup&&(clearTimeout(this.pendingCleanup),this.pendingCleanup=null);const t=this.cachedTarget,n=this.resolveTarget();if(!n)return;const i=null!==t&&t!==n;(null===this.snapshot||i)&&(this.snapshot={paddingLeft:n.style.paddingLeft,paddingRight:n.style.paddingRight,overflowX:n.style.overflowX,transition:n.style.transition}),n.style.transition=\"padding 0.3s ease\",\"left\"===this.config.side?n.style.paddingLeft=`${e}px`:n.style.paddingRight=`${e}px`,n.style.overflowX=this.supportsOverflowClip()?\"clip\":\"hidden\";const s=document.documentElement;s.style.setProperty(\"--blar-side-panel-offset\",`${e}px`),s.setAttribute(\"data-blar-push\",this.config.side),this.pushed=!0}unpush(){if(!this.pushed)return;this.pushed=!1;const e=document.documentElement;e.style.removeProperty(\"--blar-side-panel-offset\"),e.removeAttribute(\"data-blar-push\");const t=this.cachedTarget,n=this.snapshot;if(!t||!n)return this.snapshot=null,void(this.cachedTarget=null);t.style.paddingLeft=n.paddingLeft,t.style.paddingRight=n.paddingRight,null!==this.pendingCleanup&&clearTimeout(this.pendingCleanup),this.pendingCleanup=window.setTimeout(()=>{if(this.pendingCleanup=null,this.pushed)return;const e=this.cachedTarget,t=this.snapshot;e&&t&&(e.style.overflowX=t.overflowX,e.style.transition=t.transition,\"\"===e.getAttribute(\"style\")&&e.removeAttribute(\"style\")),this.snapshot=null,this.cachedTarget=null},350)}destroy(){null!==this.pendingCleanup&&(clearTimeout(this.pendingCleanup),this.pendingCleanup=null);const e=document.documentElement;e.style.removeProperty(\"--blar-side-panel-offset\"),e.removeAttribute(\"data-blar-push\");const t=this.cachedTarget,n=this.snapshot;t&&n&&(t.style.paddingLeft=n.paddingLeft,t.style.paddingRight=n.paddingRight,t.style.overflowX=n.overflowX,t.style.transition=n.transition,\"\"===t.getAttribute(\"style\")&&t.removeAttribute(\"style\")),this.snapshot=null,this.cachedTarget=null,this.pushed=!1}supportsOverflowClip(){return\"undefined\"!=typeof CSS&&\"function\"==typeof CSS.supports&&CSS.supports(\"overflow-x\",\"clip\")}resolveTarget(){if(this.cachedTarget&&document.contains(this.cachedTarget))return this.cachedTarget;if(this.cachedTarget=null,this.config.target){const e=document.querySelector(this.config.target);if(e)return this.cachedTarget=e,e;console.warn(`[SupportWidget] pushTarget \"${this.config.target}\" not found — falling back to auto-detect.`)}for(const e of g){const t=document.querySelector(e);if(t&&t.offsetWidth>0)return this.cachedTarget=t,t}return this.cachedTarget=document.body,document.body}}const vd=\"--widget-viewport-height\";class wd{constructor(e,t=null){this.store=new fs,this.overridden=!1,this.pinned=!1,this.container=e,this.host=t}start(){const e=window.visualViewport??void 0;if(e){if(this.store.safeOn(e,\"resize\",()=>this.sync(),\"ViewportManager.resize\"),this.store.safeOn(e,\"scroll\",()=>this.sync(),\"ViewportManager.scroll\"),this.store.safeOn(window,\"orientationchange\",()=>this.sync(),\"ViewportManager.orientation\"),this.host){this.store.safeOn(window,\"resize\",()=>this.sync(),\"ViewportManager.windowResize\"),this.store.safeOn(window,\"scroll\",()=>this.sync(),\"ViewportManager.windowScroll\");const e=new MutationObserver(()=>this.sync());e.observe(this.container,{attributes:!0,attributeFilter:[\"class\"],subtree:!0}),this.store.add(()=>e.disconnect())}this.sync()}}destroy(){this.unpin(),this.clearOverride(),this.store.dispose()}sync(){const e=window.visualViewport??void 0;if(!e)return;if(this.pin(e))return;const t=window.innerWidth<=u,n=window.innerHeight-e.height;!t||n<120?this.clearOverride():(this.container.style.setProperty(vd,`${Math.round(e.height)}px`),this.overridden=!0)}pin(e){if(!this.host)return!1;if(!P()||window.innerWidth-e.width*e.scale<=1)return this.unpin(),!1;const t=Math.min(e.scale,1),n=Math.round(e.height*t);return Object.assign(this.host.style,{left:`${e.offsetLeft}px`,top:`${e.offsetTop}px`,width:`${Math.round(e.width*t)}px`,height:`${n}px`,transform:`scale(${1/t})`,transformOrigin:\"0 0\"}),this.container.style.setProperty(vd,`${n}px`),this.overridden=!0,this.pinned=!0,!0}unpin(){this.pinned&&this.host&&(Object.assign(this.host.style,{left:\"0\",top:\"0\",width:\"\",height:\"\",transform:\"\",transformOrigin:\"\"}),this.pinned=!1)}clearOverride(){this.overridden&&(this.container.style.removeProperty(vd),this.overridden=!1)}}const xd=[\"click\",\"keydown\"];const kd=new class{constructor(){if(this.sentinel=null,this.requesting=!1,this.holders=new Set,this.onVisibilityChange=()=>{\"visible\"===document.visibilityState&&this.request()},this.onGesture=e=>{e.isTrusted&&this.request()},\"wakeLock\"in navigator)for(const e of xd)document.addEventListener(e,this.onGesture,!0)}hold(e){this.holders.has(e)||(this.holders.add(e),this.holders.size>1||(document.addEventListener(\"visibilitychange\",this.onVisibilityChange),this.request()))}release(e){!this.holders.delete(e)||this.holders.size>0||(document.removeEventListener(\"visibilitychange\",this.onVisibilityChange),this.drop())}drop(){this.sentinel?.release().catch(()=>{}),this.sentinel=null}async request(){if(\"wakeLock\"in navigator&&!this.sentinel&&!this.requesting&&\"visible\"===document.visibilityState){this.requesting=!0;try{const e=await navigator.wakeLock.request(\"screen\");for(const e of xd)document.removeEventListener(e,this.onGesture,!0);e.addEventListener(\"release\",()=>{this.sentinel===e&&(this.sentinel=null)}),this.sentinel=e,0===this.holders.size&&this.drop()}catch{}finally{this.requesting=!1}}}};function Sd(){return window.matchMedia?.(\"(pointer: coarse)\").matches??!1}class Cd{constructor(e){this.openChatObserver=null,this.waitingBadgeElement=null,this.apiHidden=!1,this.configHidden=!1,this.agentHidden=!1,this.chatOnly=!1,this.launcherMode=\"bubble\",this.revealedForUnread=!1,this.agentModeContentWasPushed=!1,this.aiThinkingActive=!1,this.toastTimer=null,this.chatLoadingTimeout=null,this.viewportManager=null,this.onAIThinkingChange=null,this.config=e,this.translations=Na(),this.pushContentManager=new yd({side:e.sidePanelSide,behavior:e.sidePanelBehavior,target:e.pushTarget})}init(){return this.createShadowHost(),this.injectStyles(),this.createWidget(),this.keepOpenChatShown(),this.viewportManager=new wd(this.container,this.shadowHost),this.viewportManager.start(),this.resolveLauncherVisibility(),this.container}keepOpenChatShown(){const e=this.container.querySelector(\".support-chat-window\");this.openChatObserver=new MutationObserver(()=>{e.classList.contains(\"open\")?this.shadowHost.style.setProperty(\"display\",\"block\",\"important\"):this.shadowHost.style.removeProperty(\"display\")}),this.openChatObserver.observe(e,{attributes:!0,attributeFilter:[\"class\"]})}createShadowHost(){const e=document.getElementById(\"support-widget-shadow-host\");e&&(Ji(\"[UIManager] Shadow host already present at init; replacing it\"),os(e)),this.shadowHost=document.createElement(\"div\"),this.shadowHost.id=\"support-widget-shadow-host\",this.shadowHost.style.cssText=\"position: fixed; top: 0; left: 0; z-index: 999999; pointer-events: none;\",this.shadowRoot=this.shadowHost.attachShadow({mode:\"open\"})}injectStyles(){const e=document.createElement(\"style\");e.textContent='\\n  .support-widget-container {\\n    /* CSS Custom Properties for theming */\\n    --support-primary-color: #4593F8;\\n    --support-primary-rgb: 69, 147, 248;\\n    --support-primary-dark: #0553B8;\\n    --support-secondary-color: #FFFFFF;\\n    --support-white: #FFFFFF;\\n    --support-gray-light: #F7F7F7;\\n    --support-gray-border: #E0E0E0;\\n\\n    /* Semantic palette tokens (light-mode defaults) */\\n    --widget-bg: #F7F7F7;\\n    --widget-surface: #FFFFFF;\\n    --widget-surface-hover: #F3F4F6;\\n    --widget-border: #E5E7EB;\\n    --widget-text: #111827;\\n    --widget-text-muted: #6B7280;\\n    --widget-text-inverse: #FFFFFF;\\n    --widget-human-banner-bg: #e8f5e9;\\n    --widget-human-banner-text: #2e7d32;\\n    --widget-human-banner-border: #c8e6c9;\\n    --widget-human-banner-strong: #1f5129;\\n    --widget-human-banner-busy: #805300;\\n    --widget-agent-bubble-bg: #FFFFFF;\\n    --widget-agent-bubble-fg: #1F2937;\\n    --widget-user-bubble-bg: var(--support-primary-color);\\n    --widget-user-bubble-fg: var(--support-secondary-color);\\n\\n    /* Safe-area insets. Resolve to 0px unless the host page opts into\\n       viewport-fit=cover, in which case they keep content clear of the\\n       notch and the home indicator. */\\n    --widget-safe-top: env(safe-area-inset-top, 0px);\\n    --widget-safe-right: env(safe-area-inset-right, 0px);\\n    --widget-safe-bottom: env(safe-area-inset-bottom, 0px);\\n    --widget-safe-left: env(safe-area-inset-left, 0px);\\n\\n    /* Responsive layout tokens. Base values target the floating desktop\\n       panel; the breakpoint layer re-declares them for tablet and phone. */\\n    --widget-edge-gap: 20px;\\n    --widget-radius: 12px;\\n    --widget-body-pad: 20px;\\n    --widget-footer-pad: 8px 10px;\\n    --widget-header-pad-y: 12px;\\n    --widget-header-pad-x: 16px;\\n    --widget-hero-pad-x: 28px;\\n    --widget-touch-target: 44px;\\n\\n    /* Bubble width. Agent rows spend ~42px on the avatar + gap, so they get a\\n       smaller share than user rows, which have no gutter to pay for. The line\\n       cap stops a wide-but-short viewport (a phone held sideways) from running\\n       text past a readable measure. */\\n    --widget-bubble-max-agent: 78%;\\n    --widget-bubble-max-user: 85%;\\n    --widget-bubble-max-line: 62ch;\\n\\n    /* Full-viewport height for the mobile takeover. dvh tracks browser\\n       chrome; ViewportManager overrides this with the visual-viewport\\n       height while the on-screen keyboard is open. */\\n    --widget-viewport-height: 100vh;\\n    --widget-viewport-height: 100dvh;\\n\\n    position: fixed;\\n    bottom: calc(var(--widget-edge-gap) + var(--widget-safe-bottom));\\n    right: calc(var(--widget-edge-gap) + var(--widget-safe-right));\\n    font-family: -apple-system, BlinkMacSystemFont, \\'Segoe UI\\', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\\n    z-index: 999999;\\n    pointer-events: auto;\\n  }\\n\\n  .support-widget-container.position-bottom-left {\\n    right: auto;\\n    left: calc(var(--widget-edge-gap) + var(--widget-safe-left));\\n  }\\n\\n  .support-widget-container.position-top-right {\\n    bottom: auto;\\n    top: calc(var(--widget-edge-gap) + var(--widget-safe-top));\\n  }\\n\\n  .support-widget-container.position-top-left {\\n    bottom: auto;\\n    top: calc(var(--widget-edge-gap) + var(--widget-safe-top));\\n    right: auto;\\n    left: calc(var(--widget-edge-gap) + var(--widget-safe-left));\\n  }\\n\\n  .support-widget-container.admin-mode {\\n    --widget-bg: #0C1A2E;\\n    --widget-surface: #0F2038;\\n    --widget-surface-hover: #132640;\\n    --widget-border: #1A2A4A;\\n    --widget-text: #C8DDFB;\\n    --widget-text-muted: #5A7BA8;\\n    --widget-text-inverse: #FFFFFF;\\n    --widget-agent-bubble-bg: #132640;\\n    --widget-agent-bubble-fg: #C8DDFB;\\n    --widget-user-bubble-bg: #2B6CC4;\\n    --widget-user-bubble-fg: #FFFFFF;\\n  }\\n\\n  .support-bubble {\\n    width: 60px;\\n    height: 60px;\\n    border-radius: 50%;\\n    background: var(--support-primary-color);\\n    box-shadow: 0 4px 12px rgba(var(--support-primary-rgb), 0.3);\\n    cursor: pointer;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    transition: all 0.3s ease;\\n    border: none;\\n    position: relative;\\n  }\\n\\n  .support-bubble:hover {\\n    transform: scale(1.1);\\n    box-shadow: 0 6px 20px rgba(var(--support-primary-rgb), 0.4);\\n  }\\n\\n  .support-bubble:hover .support-bubble-close {\\n    opacity: 1;\\n    visibility: visible;\\n  }\\n\\n  .support-bubble svg {\\n    width: 28px;\\n    height: 28px;\\n    fill: var(--support-secondary-color);\\n  }\\n\\n  .support-bubble-close {\\n    position: absolute;\\n    top: -8px;\\n    right: -8px;\\n    width: 24px;\\n    height: 24px;\\n    background: #6b7280;\\n    border-radius: 50%;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    cursor: pointer;\\n    opacity: 0;\\n    visibility: hidden;\\n    transition: all 0.3s ease;\\n    border: 2px solid var(--support-white);\\n    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\\n  }\\n\\n  .support-bubble-close:hover {\\n    background: #4b5563;\\n  }\\n\\n  .support-bubble-close svg {\\n    width: 12px;\\n    height: 12px;\\n    fill: var(--support-white);\\n  }\\n\\n  /* Badge mode styles */\\n  .support-badge {\\n    position: fixed;\\n    bottom: 20px;\\n    right: 0;\\n    width: 45px;\\n    height: 45px;\\n    background: var(--support-primary-color);\\n    border-radius: 50% 0 0 50%;\\n    cursor: grab;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    transition: all 0.3s ease;\\n    box-shadow: -2px 2px 10px rgba(0, 0, 0, 0.2);\\n    border: none;\\n    touch-action: none;\\n    user-select: none;\\n    padding-left: 10px;\\n    transform: translateX(18px);\\n  }\\n\\n  .support-badge.badge-left {\\n    left: 0;\\n    right: auto;\\n    border-radius: 0 50% 50% 0;\\n    padding-left: 0;\\n    padding-right: 10px;\\n    transform: translateX(-18px);\\n    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);\\n  }\\n\\n  .support-badge.badge-right {\\n    right: 0;\\n    left: auto;\\n    border-radius: 50% 0 0 50%;\\n    padding-right: 0;\\n    padding-left: 10px;\\n    transform: translateX(18px);\\n    box-shadow: -2px 2px 10px rgba(0, 0, 0, 0.2);\\n  }\\n\\n  .support-badge:hover {\\n    transform: translateX(5px) !important;\\n    box-shadow: -4px 2px 15px rgba(0, 0, 0, 0.25);\\n  }\\n\\n  .support-badge.badge-left:hover {\\n    transform: translateX(-5px) !important;\\n    box-shadow: 4px 2px 15px rgba(0, 0, 0, 0.25);\\n  }\\n\\n  .support-badge.badge-right:hover {\\n    transform: translateX(5px) !important;\\n    box-shadow: -4px 2px 15px rgba(0, 0, 0, 0.25);\\n  }\\n\\n  .support-badge.dragging {\\n    cursor: grabbing;\\n    transition: none;\\n  }\\n\\n  .support-badge.badge-left.dragging {\\n    transform: scale(1.05) translateX(-18px) !important;\\n  }\\n\\n  .support-badge.badge-right.dragging {\\n    transform: scale(1.05) translateX(18px) !important;\\n  }\\n\\n  .support-badge svg {\\n    width: 20px;\\n    height: 20px;\\n    fill: var(--support-secondary-color);\\n  }\\n\\n  .support-badge .support-unread-indicator {\\n    position: absolute;\\n    top: 2px;\\n    left: 2px;\\n    min-width: 16px;\\n    height: 16px;\\n    background: #ef4444;\\n    border-radius: 8px;\\n    border: 2px solid var(--support-primary-color);\\n    font-size: 10px;\\n    font-weight: 700;\\n    color: white;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    padding: 0 3px;\\n    box-sizing: border-box;\\n    line-height: 1;\\n  }\\n\\n  /* Mobile touch styles */\\n  @media (hover: none) and (pointer: coarse) {\\n    .support-bubble-close {\\n      opacity: 1;\\n      visibility: visible;\\n    }\\n  }\\n\\n  .support-unread-indicator {\\n    position: absolute;\\n    top: -2px;\\n    right: -2px;\\n    min-width: 18px;\\n    height: 18px;\\n    background: #ef4444;\\n    border-radius: 9px;\\n    border: 2px solid white;\\n    font-size: 11px;\\n    font-weight: 700;\\n    color: white;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    padding: 0 4px;\\n    box-sizing: border-box;\\n    line-height: 1;\\n  }\\n\\n  .support-unread-indicator.hidden {\\n    display: none;\\n  }\\n\\n  @keyframes bubble-bounce {\\n    0%, 100% {\\n      transform: translateY(0);\\n    }\\n    15% {\\n      transform: translateY(-12px);\\n    }\\n    30% {\\n      transform: translateY(0);\\n    }\\n    45% {\\n      transform: translateY(-6px);\\n    }\\n    60% {\\n      transform: translateY(0);\\n    }\\n    75% {\\n      transform: translateY(-2px);\\n    }\\n    90% {\\n      transform: translateY(0);\\n    }\\n  }\\n\\n  @keyframes bubble-pulse {\\n    0%, 100% {\\n      transform: scale(1);\\n      box-shadow: 0 4px 12px rgba(var(--support-primary-rgb), 0.3);\\n    }\\n    50% {\\n      transform: scale(1.08);\\n      box-shadow: 0 6px 20px rgba(var(--support-primary-rgb), 0.4);\\n    }\\n  }\\n\\n  .support-bubble.animate-bounce {\\n    animation: bubble-bounce 1.5s cubic-bezier(0.28, 0.84, 0.42, 1) infinite;\\n  }\\n\\n  .support-bubble.animate-pulse {\\n    animation: bubble-pulse 2s ease-in-out infinite;\\n  }\\n\\n  .support-bubble.animate-bounce:hover,\\n  .support-bubble.animate-pulse:hover {\\n    animation: none;\\n  }\\n\\n  .support-chat-window {\\n    position: fixed;\\n    bottom: calc(100px + var(--widget-safe-bottom));\\n    right: calc(var(--widget-edge-gap) + var(--widget-safe-right));\\n    width: min(420px, calc(100vw - 2 * var(--widget-edge-gap) - var(--widget-safe-left) - var(--widget-safe-right)));\\n    height: 600px;\\n    max-height: calc(var(--widget-viewport-height) - 140px - var(--widget-safe-bottom) - var(--widget-safe-top));\\n    background: var(--widget-bg);\\n    border-radius: var(--widget-radius);\\n    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);\\n    display: flex;\\n    flex-direction: column;\\n    opacity: 0;\\n    transform: scale(0.8) translateY(20px);\\n    pointer-events: none;\\n    /* Opacity and transforms only hide it from the eye: a closed window must also\\n       leave the tab order and the accessibility tree, and never paint whatever its\\n       size (session 24966). Visibility flips once the closing transition is over;\\n       every rule that redefines the transition keeps that last entry. */\\n    visibility: hidden;\\n    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55), visibility 0s linear 0.3s;\\n    overflow: hidden;\\n  }\\n\\n  .position-bottom-left .support-chat-window {\\n    right: auto;\\n    left: calc(var(--widget-edge-gap) + var(--widget-safe-left));\\n  }\\n\\n  .position-top-right .support-chat-window {\\n    bottom: auto;\\n    top: calc(100px + var(--widget-safe-top));\\n    transform: scale(0.8) translateY(-20px);\\n  }\\n\\n  .position-top-right .support-chat-window.open {\\n    transform: scale(1) translateY(0);\\n  }\\n\\n  .position-top-left .support-chat-window {\\n    bottom: auto;\\n    top: calc(100px + var(--widget-safe-top));\\n    right: auto;\\n    left: calc(var(--widget-edge-gap) + var(--widget-safe-left));\\n    transform: scale(0.8) translateY(-20px);\\n  }\\n\\n  .position-top-left .support-chat-window.open {\\n    transform: scale(1) translateY(0);\\n  }\\n\\n  .support-chat-window.expanded {\\n    width: min(600px, calc(100vw - 2 * var(--widget-edge-gap) - var(--widget-safe-left) - var(--widget-safe-right)));\\n    height: 700px;\\n  }\\n\\n  .support-chat-window.open {\\n    opacity: 1;\\n    transform: scale(1) translateY(0);\\n    pointer-events: all;\\n    visibility: visible;\\n    transition-delay: 0s;\\n  }\\n\\n  .support-chat-header {\\n    background: var(--support-primary-color);\\n    color: var(--support-secondary-color);\\n    padding: var(--widget-header-pad-y) var(--widget-header-pad-x);\\n    border-radius: var(--widget-radius) var(--widget-radius) 0 0;\\n    display: flex;\\n    justify-content: space-between;\\n    align-items: center;\\n    min-height: 48px;\\n  }\\n\\n  .support-header-left {\\n    display: flex;\\n    align-items: center;\\n    gap: 12px;\\n  }\\n\\n  .support-header-center {\\n    flex: 1;\\n    display: flex;\\n    flex-direction: column;\\n    align-items: center;\\n    gap: 2px;\\n    min-width: 0;\\n    text-align: center;\\n  }\\n\\n  .support-header-center.entity-active {\\n    display: flex;\\n    flex-direction: column;\\n    align-items: center;\\n    gap: 2px;\\n    min-width: 0;\\n  }\\n\\n  .support-header-status {\\n    flex: 1;\\n    display: flex;\\n    justify-content: center;\\n    min-width: 0;\\n    text-align: center;\\n  }\\n\\n  .support-header-status:empty {\\n    display: none;\\n  }\\n\\n  .support-header-status:not(:empty) + .support-header-center:empty {\\n    display: none;\\n  }\\n\\n  .support-executive-status {\\n    display: flex;\\n    justify-content: center;\\n    align-items: flex-start;\\n    gap: 10px;\\n    width: 100%;\\n    max-width: 100%;\\n    min-width: 0;\\n    margin-top: 10px;\\n    padding-top: 10px;\\n    border-top: 1px solid var(--widget-human-banner-border);\\n  }\\n\\n  .support-executive-status-name {\\n    max-width: 100%;\\n    font-size: 14px;\\n    font-weight: 600;\\n    overflow-wrap: anywhere;\\n  }\\n\\n  .support-executive-status-content {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 2px;\\n    min-width: 0;\\n    text-align: left;\\n    overflow-wrap: anywhere;\\n  }\\n\\n  .support-executive-status-reason {\\n    font-size: 12px;\\n    line-height: 1.4;\\n  }\\n\\n  .support-executive-status-line {\\n    display: block;\\n    max-width: 100%;\\n    font-size: 14px;\\n    font-weight: 600;\\n    line-height: 1.4;\\n    color: var(--widget-human-banner-strong);\\n  }\\n\\n  .support-executive-status-icon {\\n    width: 16px;\\n    height: 16px;\\n    margin-top: 1px;\\n    fill: none;\\n    stroke: currentColor;\\n    stroke-width: 1.65;\\n    stroke-linecap: round;\\n    stroke-linejoin: round;\\n  }\\n\\n  .support-executive-status[data-reason=\"busy\"] .support-executive-status-icon {\\n    color: var(--widget-human-banner-busy);\\n  }\\n\\n  .support-entity-action {\\n    font-size: 12px;\\n    font-weight: 500;\\n    text-transform: uppercase;\\n    letter-spacing: 0.04em;\\n    color: var(--support-secondary-color);\\n    opacity: 0.7;\\n    transition: opacity 0.15s ease-out;\\n  }\\n\\n  .support-entity-title {\\n    font-size: 14px;\\n    font-weight: 600;\\n    color: var(--support-secondary-color);\\n    max-width: min(220px, 100%);\\n    overflow: hidden;\\n    text-overflow: ellipsis;\\n    white-space: nowrap;\\n    transition: opacity 0.15s ease-out;\\n  }\\n\\n  .support-entity-skeleton {\\n    display: inline-block;\\n    background: linear-gradient(\\n      90deg,\\n      rgba(255, 255, 255, 0.05) 0%,\\n      rgba(255, 255, 255, 0.15) 50%,\\n      rgba(255, 255, 255, 0.05) 100%\\n    );\\n    background-size: 200% 100%;\\n    animation: entityShimmer 1.2s ease-in-out infinite;\\n    border-radius: 4px;\\n    color: transparent;\\n  }\\n\\n  .support-entity-action.support-entity-skeleton {\\n    width: 90px;\\n    height: 12px;\\n  }\\n\\n  .support-entity-title.support-entity-skeleton {\\n    width: 160px;\\n    height: 14px;\\n    margin-top: 2px;\\n  }\\n\\n  @keyframes entityShimmer {\\n    0% { background-position: 200% 0; }\\n    100% { background-position: -200% 0; }\\n  }\\n\\n  @media (prefers-reduced-motion: reduce) {\\n    .support-entity-action,\\n    .support-entity-title,\\n    .support-entity-skeleton {\\n      transition: none;\\n      animation: none;\\n    }\\n  }\\n\\n  .support-header-right {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n  }\\n\\n  .support-new-chat-btn {\\n    background: none;\\n    border: none;\\n    color: var(--support-secondary-color);\\n    cursor: pointer;\\n    padding: 6px;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    border-radius: 6px;\\n    transition: background 0.2s;\\n    position: relative;\\n  }\\n\\n  .support-new-chat-btn[data-tooltip]:hover::after {\\n    content: attr(data-tooltip);\\n    position: absolute;\\n    bottom: -32px;\\n    left: 0;\\n    background: rgba(0, 0, 0, 0.8);\\n    color: white;\\n    padding: 6px 10px;\\n    border-radius: 4px;\\n    font-size: 13px;\\n    white-space: nowrap;\\n    z-index: 10;\\n  }\\n\\n  .support-new-chat-btn:hover {\\n    background: rgba(255, 255, 255, 0.15);\\n  }\\n\\n  .support-new-chat-btn svg {\\n    width: 26px;\\n    height: 26px;\\n    fill: var(--support-secondary-color);\\n  }\\n\\n  .support-close-btn,\\n  .support-test-reconnect-btn,\\n  .support-human-btn,\\n  .support-expand-btn,\\n  .support-menu-btn {\\n    background: none;\\n    border: none;\\n    color: var(--support-secondary-color);\\n    cursor: pointer;\\n    padding: 4px;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    border-radius: 4px;\\n    transition: background 0.2s;\\n  }\\n\\n  .support-close-btn:hover,\\n  .support-test-reconnect-btn:hover,\\n  .support-human-btn:hover,\\n  .support-expand-btn:hover,\\n  .support-menu-btn:hover {\\n    background: rgba(255, 255, 255, 0.1);\\n  }\\n\\n  .support-close-btn svg,\\n  .support-test-reconnect-btn svg,\\n  .support-human-btn svg,\\n  .support-expand-btn svg {\\n    width: 20px;\\n    height: 20px;\\n    fill: var(--support-secondary-color);\\n  }\\n\\n  .support-human-btn {\\n    position: relative;\\n  }\\n\\n  .support-human-btn:active {\\n    transform: scale(0.95);\\n  }\\n\\n  .support-human-btn.requested {\\n    background: rgba(255, 255, 255, 0.2);\\n    cursor: default;\\n  }\\n\\n  .support-human-btn.requested:hover {\\n    background: rgba(255, 255, 255, 0.2);\\n  }\\n\\n  /* Tooltip for human button */\\n  .support-human-btn[data-tooltip]::before {\\n    content: attr(data-tooltip);\\n    position: absolute;\\n    bottom: -40px;\\n    right: 0;\\n    background: #1f2937;\\n    color: white;\\n    padding: 6px 10px;\\n    border-radius: 6px;\\n    font-size: 12px;\\n    white-space: nowrap;\\n    opacity: 0;\\n    visibility: hidden;\\n    transition: opacity 0.2s, visibility 0.2s;\\n    pointer-events: none;\\n    z-index: 1000;\\n    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\\n  }\\n\\n  .support-human-btn[data-tooltip]::after {\\n    content: \\'\\';\\n    position: absolute;\\n    bottom: -12px;\\n    right: 8px;\\n    width: 0;\\n    height: 0;\\n    border-left: 6px solid transparent;\\n    border-right: 6px solid transparent;\\n    border-bottom: 6px solid #1f2937;\\n    opacity: 0;\\n    visibility: hidden;\\n    transition: opacity 0.2s, visibility 0.2s;\\n    pointer-events: none;\\n    z-index: 1000;\\n  }\\n\\n  .support-human-btn:hover[data-tooltip]::before,\\n  .support-human-btn:hover[data-tooltip]::after {\\n    opacity: 1;\\n    visibility: visible;\\n  }\\n\\n  .support-human-btn.requested[data-tooltip]::before {\\n    content: \\'Human assistance requested\\';\\n  }\\n\\n  .support-test-reconnect-btn {\\n    opacity: 0.8;\\n    background: rgba(255, 255, 255, 0.05);\\n    border: 1px solid rgba(255, 255, 255, 0.2);\\n  }\\n\\n  .support-test-reconnect-btn:hover {\\n    opacity: 1;\\n    background: rgba(255, 255, 255, 0.15);\\n    border-color: rgba(255, 255, 255, 0.3);\\n  }\\n\\n  .support-test-reconnect-btn svg {\\n    width: 18px;\\n    height: 18px;\\n  }\\n\\n  .support-header-actions,\\n  .support-header-right {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n  }\\n\\n  /* Menu styles */\\n  .support-menu-container {\\n    position: relative;\\n  }\\n\\n  .support-menu-btn svg {\\n    width: 20px;\\n    height: 20px;\\n    fill: var(--support-secondary-color);\\n  }\\n\\n  .support-menu-dropdown {\\n    position: absolute;\\n    top: 100%;\\n    right: 0;\\n    margin-top: 8px;\\n    min-width: 200px;\\n    background: #2b2b2b;\\n    border-radius: 8px;\\n    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);\\n    overflow: hidden;\\n    z-index: 1000;\\n    opacity: 0;\\n    transform: translateY(-10px);\\n    transition: all 0.2s ease;\\n    pointer-events: none;\\n  }\\n\\n  .support-menu-dropdown:not(.hidden) {\\n    opacity: 1;\\n    transform: translateY(0);\\n    pointer-events: auto;\\n  }\\n\\n  .support-menu-item {\\n    display: flex;\\n    align-items: center;\\n    gap: 12px;\\n    width: 100%;\\n    padding: 12px 16px;\\n    background: none;\\n    border: none;\\n    color: white;\\n    font-size: 14px;\\n    cursor: pointer;\\n    transition: background 0.2s;\\n    text-align: left;\\n  }\\n\\n  .support-menu-item:hover {\\n    background: rgba(255, 255, 255, 0.1);\\n  }\\n\\n  .support-menu-item svg {\\n    width: 20px;\\n    height: 20px;\\n    fill: white;\\n    flex-shrink: 0;\\n  }\\n\\n  .support-sound-toggle {\\n    border-bottom: 1px solid rgba(255, 255, 255, 0.1);\\n  }\\n\\n  @keyframes pulse {\\n    0%, 100% {\\n      box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);\\n    }\\n    50% {\\n      box-shadow: 0 0 12px rgba(16, 185, 129, 0.8);\\n    }\\n  }\\n\\n  /* Presence indicator styles */\\n  .support-presence-indicator {\\n    display: flex;\\n    align-items: center;\\n    gap: 6px;\\n    font-size: 12px;\\n    color: var(--support-secondary-color);\\n    margin-top: 4px;\\n    opacity: 0.9;\\n  }\\n\\n  .support-presence-indicator.hidden {\\n    display: none;\\n  }\\n\\n  .support-presence-dot {\\n    flex-shrink: 0;\\n    animation: pulse 2s ease-in-out infinite;\\n  }\\n\\n  .support-presence-text {\\n    font-weight: 500;\\n  }\\n\\n  .support-agent-banner {\\n    display: flex;\\n    flex-direction: column;\\n    flex-shrink: 0;\\n    padding: 8px 16px;\\n    background: var(--widget-human-banner-bg);\\n    color: var(--widget-human-banner-text);\\n    font-size: 13px;\\n    font-weight: 500;\\n    border-bottom: 1px solid var(--widget-human-banner-border);\\n  }\\n\\n  .support-agent-banner-content {\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    gap: 6px;\\n    min-width: 0;\\n    text-align: center;\\n  }\\n\\n  .support-agent-banner.hidden {\\n    display: none;\\n  }\\n\\n  /* \"Working in another tab\" variant — informational, not a success state. */\\n  .support-agent-banner.other-tab {\\n    background: #eef2ff;\\n    color: #3730a3;\\n    border-bottom-color: #c7d2fe;\\n  }\\n\\n  .support-agent-banner.other-tab .support-agent-banner-content {\\n    flex-wrap: wrap;\\n  }\\n\\n  .support-agent-banner.other-tab .support-executive-status {\\n    display: none;\\n  }\\n\\n  .support-agent-banner-action {\\n    border: 1px solid currentColor;\\n    background: transparent;\\n    color: inherit;\\n    border-radius: 6px;\\n    padding: 2px 8px;\\n    font: inherit;\\n    font-size: 12px;\\n    cursor: pointer;\\n  }\\n\\n  .support-agent-banner-action:hover {\\n    background: rgba(55, 48, 163, 0.08);\\n  }\\n\\n  .support-agent-banner svg {\\n    flex-shrink: 0;\\n  }\\n\\n  /* \"We\\'re reviewing this\" status card. Neutral gray palette — distinct\\n     enough to read as a status note, no warning/escalation cues. */\\n  .support-engineering-handoff-message {\\n    display: block;\\n    margin: 12px 0;\\n    animation: messageSlideIn 0.3s ease;\\n  }\\n\\n  .support-engineering-handoff-card {\\n    display: flex;\\n    gap: 12px;\\n    padding: 12px 14px;\\n    background: rgb(249, 250, 251);\\n    border: 1px solid rgba(0, 0, 0, 0.08);\\n    border-radius: 10px;\\n    color: #374151;\\n  }\\n\\n  .support-engineering-handoff-icon {\\n    flex-shrink: 0;\\n    width: 24px;\\n    height: 24px;\\n    border-radius: 50%;\\n    background: rgba(0, 0, 0, 0.06);\\n    color: #6b7280;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n  }\\n\\n  .support-engineering-handoff-icon svg {\\n    width: 14px;\\n    height: 14px;\\n  }\\n\\n  .support-engineering-handoff-content {\\n    flex: 1;\\n    min-width: 0;\\n  }\\n\\n  .support-engineering-handoff-body {\\n    font-size: 14px;\\n    line-height: 1.45;\\n    color: #374151;\\n  }\\n\\n  .support-engineering-handoff-body p {\\n    margin: 0;\\n  }\\n\\n  .support-engineering-handoff-body p + p {\\n    margin-top: 8px;\\n  }\\n\\n  .support-chat-body {\\n    flex: 1;\\n    padding: var(--widget-body-pad);\\n    overflow-y: auto;\\n    overflow-x: hidden;\\n    background: var(--widget-bg);\\n    position: relative;\\n    overscroll-behavior: contain;\\n    touch-action: pan-y;\\n    -webkit-overflow-scrolling: touch;\\n  }\\n\\n  .support-welcome-module {\\n    opacity: 1;\\n  }\\n\\n  .support-welcome-hero {\\n    margin: calc(-1 * var(--widget-body-pad)) calc(-1 * var(--widget-body-pad)) 20px;\\n    padding: 16px var(--widget-hero-pad-x) 64px;\\n    background: linear-gradient(180deg,\\n      var(--support-primary-color) 0%,\\n      rgba(var(--support-primary-rgb), 0.85) 40%,\\n      rgba(var(--support-primary-rgb), 0.4) 70%,\\n      rgba(var(--support-primary-rgb), 0.08) 90%,\\n      transparent 100%);\\n    animation: heroFadeIn 0.5s ease-out;\\n  }\\n\\n  .support-welcome-hero-exit {\\n    animation: heroFadeOut 0.35s ease-in forwards;\\n  }\\n\\n  .support-welcome-hero-content {\\n    max-width: 320px;\\n    margin: 0 auto;\\n    text-align: center;\\n  }\\n\\n  .support-welcome-hero-header {\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    gap: 10px;\\n    margin-bottom: 12px;\\n  }\\n\\n  .support-welcome-hero-avatar {\\n    width: 36px;\\n    height: 36px;\\n  }\\n\\n  .support-welcome-hero-title {\\n    margin: 0;\\n    font-size: 22px;\\n    font-weight: 700;\\n    color: var(--support-secondary-color);\\n    line-height: 1.3;\\n  }\\n\\n  .support-welcome-hero-subtitle {\\n    margin: 0;\\n    font-size: 14px;\\n    font-weight: 400;\\n    color: var(--support-secondary-color);\\n    opacity: 0.85;\\n    line-height: 1.6;\\n  }\\n\\n  .support-welcome-hero + .support-message {\\n    animation: messageSlideIn 0.4s ease-out;\\n  }\\n\\n  @keyframes heroFadeIn {\\n    from { opacity: 0; transform: translateY(-8px); }\\n    to { opacity: 1; transform: translateY(0); }\\n  }\\n\\n  @keyframes heroFadeOut {\\n    from { opacity: 1; transform: translateY(0); }\\n    to { opacity: 0; transform: translateY(-12px); }\\n  }\\n\\n  @keyframes messageSlideIn {\\n    from { opacity: 0; transform: translateY(12px); }\\n    to { opacity: 1; transform: translateY(0); }\\n  }\\n\\n  .support-waiting-badge {\\n    position: absolute;\\n    bottom: 20px;\\n    left: 20px;\\n    right: 20px;\\n    background: rgba(255, 255, 255, 0.95);\\n    color: #666;\\n    padding: 10px 20px;\\n    border-radius: 20px;\\n    font-size: 13px;\\n    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\\n    text-align: center;\\n    transition: all 0.3s ease;\\n    animation: slideUp 0.3s ease;\\n  }\\n\\n  .support-waiting-badge.hidden {\\n    opacity: 0;\\n    transform: translateY(10px);\\n    pointer-events: none;\\n  }\\n\\n  @keyframes slideUp {\\n    from {\\n      opacity: 0;\\n      transform: translateY(10px);\\n    }\\n    to {\\n      opacity: 1;\\n      transform: translateY(0);\\n    }\\n  }\\n\\n  .support-message {\\n    margin-bottom: 16px;\\n    animation: slideIn 0.3s ease;\\n  }\\n\\n  @keyframes slideIn {\\n    from {\\n      opacity: 0;\\n      transform: translateY(10px);\\n    }\\n    to {\\n      opacity: 1;\\n      transform: translateY(0);\\n    }\\n  }\\n\\n  .support-message.agent {\\n    display: flex;\\n    gap: 10px;\\n  }\\n\\n  .support-message.user {\\n    display: flex;\\n    justify-content: flex-end;\\n    align-items: flex-end;\\n    gap: 8px;\\n    margin-right: 8px;\\n  }\\n\\n  .support-avatar {\\n    width: 32px;\\n    height: 32px;\\n    border-radius: 50%;\\n    background: var(--support-primary-color);\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    flex-shrink: 0;\\n  }\\n\\n  .support-avatar svg {\\n    width: 18px;\\n    height: 18px;\\n    fill: var(--support-secondary-color);\\n  }\\n\\n  .support-avatar.ai svg {\\n    stroke: black;\\n  }\\n\\n  .support-avatar-loading {\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    width: 100%;\\n    height: 100%;\\n  }\\n\\n  .support-avatar-image {\\n    width: 100%;\\n    height: 100%;\\n    border-radius: 50%;\\n    object-fit: cover;\\n  }\\n\\n  .support-message-author {\\n    font-size: 12px;\\n    font-weight: 600;\\n    color: var(--widget-text-muted);\\n    margin-bottom: 6px;\\n    display: block;\\n  }\\n\\n  .support-message-content {\\n    background: var(--widget-agent-bubble-bg);\\n    padding: 12px 16px;\\n    border-radius: 8px;\\n    max-width: 100%;\\n    box-sizing: border-box;\\n    font-size: 14px;\\n    line-height: 1.5;\\n    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);\\n    color: var(--widget-agent-bubble-fg);\\n    word-wrap: break-word;\\n    overflow-wrap: break-word;\\n  }\\n\\n  .support-message.user .support-message-content {\\n    background: var(--widget-user-bubble-bg);\\n    color: var(--widget-user-bubble-fg);\\n  }\\n\\n  /* Inherits the bubble\\'s own text color so it stays legible on the agent bubble,\\n     on any brand-colored user bubble, and in dark mode. */\\n  .support-message-edited {\\n    margin-left: 4px;\\n    font-size: 0.72em;\\n    line-height: 1;\\n    opacity: 0.7;\\n    white-space: nowrap;\\n    user-select: none;\\n  }\\n\\n  /* Sits on its own line when the body ends in a list or code block. */\\n  .support-message-content > .support-message-edited {\\n    display: inline-block;\\n    margin-left: 0;\\n    margin-top: 4px;\\n  }\\n\\n  /* The brand color already caps contrast on this bubble, so the marker keeps the\\n     bubble\\'s own text contrast and leans on size alone for hierarchy. */\\n  .support-message.user .support-message-edited {\\n    opacity: 1;\\n  }\\n\\n  /* Quoted message — one non-recursive level, riding inside the bubble it answers */\\n  .support-message-quote {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 1px;\\n    padding: 6px 10px;\\n    border-left: 3px solid var(--support-primary-color);\\n    border-radius: 4px;\\n    background: rgba(var(--support-primary-rgb), 0.08);\\n    font-size: 12.5px;\\n    line-height: 1.35;\\n    cursor: pointer;\\n    text-align: left;\\n    overflow: hidden;\\n    transition: background 0.15s ease;\\n  }\\n\\n  .support-message-quote:hover,\\n  .support-message-quote:focus-visible {\\n    background: rgba(var(--support-primary-rgb), 0.16);\\n  }\\n\\n  /* Inside a bubble it is a header: flush to the bubble\\'s edges, tucked under\\n     the padding, with the body text below it. */\\n  .support-message-content > .support-message-quote {\\n    margin: -12px -16px 10px;\\n    border-radius: 8px 8px 0 0;\\n    border-left-width: 4px;\\n    padding: 8px 12px;\\n  }\\n\\n  .support-message-author + .support-message-quote {\\n    margin-top: 0;\\n    border-radius: 0;\\n  }\\n\\n  /* On the brand-colored bubble the quote borrows the bubble\\'s own text color —\\n     a primary-tinted card there would read as a second, competing surface. */\\n  .support-message.user .support-message-content > .support-message-quote {\\n    background: rgba(255, 255, 255, 0.18);\\n    border-left-color: rgba(255, 255, 255, 0.75);\\n  }\\n\\n  .support-message.user .support-message-content > .support-message-quote:hover,\\n  .support-message.user .support-message-content > .support-message-quote:focus-visible {\\n    background: rgba(255, 255, 255, 0.28);\\n  }\\n\\n  .support-message.user .support-message-content > .support-message-quote .support-quote-author {\\n    color: var(--widget-user-bubble-fg);\\n  }\\n\\n  .support-message.user .support-message-content > .support-message-quote .support-quote-body {\\n    color: var(--widget-user-bubble-fg);\\n    opacity: 0.85;\\n  }\\n\\n  /* An attachment-only reply has no bubble to sit in, so the quote is the card. */\\n  .support-message-wrapper > .support-message-quote {\\n    align-self: flex-start;\\n    max-width: 100%;\\n    box-sizing: border-box;\\n  }\\n\\n  .support-message.user .support-message-wrapper > .support-message-quote {\\n    align-self: flex-end;\\n  }\\n\\n  .support-message-quote.deleted .support-quote-body {\\n    font-style: italic;\\n    opacity: 0.7;\\n  }\\n\\n  /* The quoted message is not in this thread — quote scope is the contact\\n     channel, so it may live in a conversation that was never loaded here. */\\n  .support-message-quote.not-found {\\n    animation: support-quote-nudge 0.4s ease;\\n  }\\n\\n  @keyframes support-quote-nudge {\\n    0%, 100% { transform: translateX(0); }\\n    25% { transform: translateX(-3px); }\\n    75% { transform: translateX(3px); }\\n  }\\n\\n  .support-quote-author {\\n    font-weight: 600;\\n    color: var(--support-primary-color);\\n    white-space: nowrap;\\n    overflow: hidden;\\n    text-overflow: ellipsis;\\n  }\\n\\n  .support-quote-body {\\n    color: var(--widget-text-muted);\\n    display: -webkit-box;\\n    -webkit-line-clamp: 2;\\n    -webkit-box-orient: vertical;\\n    overflow: hidden;\\n    word-break: break-word;\\n  }\\n\\n  /* Landing flash after a jump, so the eye finds the message it asked for.\\n     The whole row is tinted rather than the bubble ringed: the contact\\'s own\\n     bubble IS the primary color, and a primary ring around it is invisible. */\\n  .support-message-highlighted {\\n    animation: support-message-flash 1.6s ease;\\n    border-radius: 10px;\\n    /* Padding for the tint to breathe, cancelled by the margins so the row does\\n       not move when it lands. Bottom: 6 padding + 10 margin = the usual 16. */\\n    padding: 6px 8px;\\n    margin: -6px -8px 10px;\\n  }\\n\\n  @keyframes support-message-flash {\\n    0% { background-color: rgba(var(--support-primary-rgb), 0); }\\n    12% { background-color: rgba(var(--support-primary-rgb), 0.16); }\\n    70% { background-color: rgba(var(--support-primary-rgb), 0.16); }\\n    100% { background-color: rgba(var(--support-primary-rgb), 0); }\\n  }\\n\\n  /* Reply affordance — sits beside the bubble, revealed on hover */\\n  .support-message-reply-btn {\\n    align-self: center;\\n    flex-shrink: 0;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    width: 28px;\\n    height: 28px;\\n    padding: 0;\\n    border: none;\\n    border-radius: 50%;\\n    background: transparent;\\n    color: var(--widget-text-muted);\\n    cursor: pointer;\\n    opacity: 0;\\n    transform: scale(0.85);\\n    transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;\\n  }\\n\\n  .support-message-reply-btn svg {\\n    width: 15px;\\n    height: 15px;\\n  }\\n\\n  .support-message:hover .support-message-reply-btn,\\n  .support-message-reply-btn:focus-visible {\\n    opacity: 1;\\n    transform: scale(1);\\n  }\\n\\n  .support-message-reply-btn:hover {\\n    background: rgba(var(--support-primary-rgb), 0.12);\\n    color: var(--support-primary-color);\\n  }\\n\\n  /* No hover on touch: a swipe or a hold replies, so the button only stays for\\n     screen readers instead of taking room beside every bubble. */\\n  @media (hover: none) {\\n    .support-message-reply-btn {\\n      position: absolute;\\n      width: 1px;\\n      height: 1px;\\n      overflow: hidden;\\n      clip-path: inset(50%);\\n      opacity: 0;\\n    }\\n  }\\n\\n  /* Swipe or hold a message to reply to it. The state classes come from\\n     reply-gesture.ts; the row slides right and a reply glyph grows in behind it. */\\n  .support-message-pressing {\\n    -webkit-user-select: none;\\n    user-select: none;\\n    -webkit-touch-callout: none;\\n  }\\n\\n  .support-message-swiping {\\n    position: relative;\\n    animation: none;\\n    transform: translateX(var(--reply-offset, 0px));\\n    will-change: transform;\\n  }\\n\\n  .support-message-snapping {\\n    transition: transform 0.2s ease;\\n  }\\n\\n  .support-reply-swipe-icon {\\n    position: absolute;\\n    top: 50%;\\n    left: -44px;\\n    width: 32px;\\n    height: 32px;\\n    margin-top: -16px;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    border-radius: 50%;\\n    background: rgba(var(--support-primary-rgb), 0.14);\\n    color: var(--support-primary-color);\\n    opacity: var(--reply-progress, 0);\\n    transform: scale(calc(0.6 + 0.4 * var(--reply-progress, 0)));\\n    pointer-events: none;\\n    transition: background 0.12s ease, color 0.12s ease;\\n  }\\n\\n  .support-reply-swipe-icon svg {\\n    width: 16px;\\n    height: 16px;\\n  }\\n\\n  .support-message-reply-armed .support-reply-swipe-icon {\\n    background: var(--support-primary-color);\\n    color: var(--support-secondary-color);\\n    animation: support-reply-pop 0.22s ease;\\n  }\\n\\n  @keyframes support-reply-pop {\\n    0% { transform: scale(1); }\\n    55% { transform: scale(1.28); }\\n    100% { transform: scale(1); }\\n  }\\n\\n  .support-message-held {\\n    animation: support-message-flash 0.9s ease;\\n  }\\n\\n  /* A closed conversation has no composer, so a quote has nowhere to go. */\\n  .conversation-read-only .support-message-reply-btn {\\n    display: none;\\n  }\\n\\n  @media (prefers-reduced-motion: reduce) {\\n    .support-message-highlighted,\\n    .support-message-held,\\n    .support-message-reply-armed .support-reply-swipe-icon,\\n    .support-message-quote.not-found {\\n      animation: none;\\n    }\\n\\n    .support-message-snapping {\\n      transition: none;\\n    }\\n  }\\n\\n  /* Markdown styling within message content */\\n  :is(.support-message-content, .support-interactive-body) p {\\n    margin: 0 0 8px 0;\\n  }\\n\\n  :is(.support-message-content, .support-interactive-body) p:last-child {\\n    margin-bottom: 0;\\n  }\\n\\n  :is(.support-message-content, .support-interactive-body) h1,\\n  :is(.support-message-content, .support-interactive-body) h2,\\n  :is(.support-message-content, .support-interactive-body) h3,\\n  :is(.support-message-content, .support-interactive-body) h4,\\n  :is(.support-message-content, .support-interactive-body) h5,\\n  :is(.support-message-content, .support-interactive-body) h6 {\\n    margin: 12px 0 8px 0;\\n    font-weight: 600;\\n  }\\n\\n  :is(.support-message-content, .support-interactive-body) h1 { font-size: 1.5em; }\\n  :is(.support-message-content, .support-interactive-body) h2 { font-size: 1.3em; }\\n  :is(.support-message-content, .support-interactive-body) h3 { font-size: 1.1em; }\\n\\n  :is(.support-message-content, .support-interactive-body) code {\\n    background: rgba(0, 0, 0, 0.05);\\n    padding: 2px 6px;\\n    border-radius: 3px;\\n    font-family: \\'Monaco\\', \\'Menlo\\', \\'Courier New\\', monospace;\\n    font-size: 0.9em;\\n  }\\n\\n  .support-message.user .support-message-content code {\\n    background: rgba(0, 0, 0, 0.15);\\n    color: var(--support-secondary-color);\\n  }\\n\\n  :is(.support-message-content, .support-interactive-body) pre {\\n    background: rgba(0, 0, 0, 0.05);\\n    padding: 12px;\\n    border-radius: 6px;\\n    overflow-x: auto;\\n    margin: 8px 0;\\n  }\\n\\n  .support-message.user .support-message-content pre {\\n    background: rgba(0, 0, 0, 0.15);\\n  }\\n\\n  .support-message.user .support-message-content pre code {\\n    color: var(--support-secondary-color);\\n  }\\n\\n  :is(.support-message-content, .support-interactive-body) pre code {\\n    background: none;\\n    padding: 0;\\n  }\\n\\n  :is(.support-message-content, .support-interactive-body) ul,\\n  :is(.support-message-content, .support-interactive-body) ol {\\n    margin: 8px 0;\\n    padding-left: 24px;\\n  }\\n\\n  :is(.support-message-content, .support-interactive-body) li {\\n    margin: 4px 0;\\n  }\\n\\n  :is(.support-message-content, .support-interactive-body) blockquote {\\n    border-left: 3px solid rgba(0, 0, 0, 0.2);\\n    padding-left: 12px;\\n    margin: 8px 0;\\n    color: rgba(0, 0, 0, 0.7);\\n  }\\n\\n  .support-message.user .support-message-content blockquote {\\n    border-left-color: var(--support-secondary-color);\\n    opacity: 0.4;\\n    color: var(--support-secondary-color);\\n  }\\n\\n  :is(.support-message-content, .support-interactive-body) a {\\n    color: var(--support-primary-color);\\n    text-decoration: underline;\\n  }\\n\\n  .support-message.user .support-message-content a {\\n    color: var(--support-secondary-color);\\n    text-decoration: underline;\\n  }\\n\\n  :is(.support-message-content, .support-interactive-body) strong {\\n    font-weight: 600;\\n  }\\n\\n  :is(.support-message-content, .support-interactive-body) em {\\n    font-style: italic;\\n  }\\n\\n  :is(.support-message-content, .support-interactive-body) hr {\\n    border: none;\\n    border-top: 1px solid rgba(0, 0, 0, 0.1);\\n    margin: 12px 0;\\n  }\\n\\n  .support-new-messages-divider {\\n    display: flex;\\n    align-items: center;\\n    gap: 12px;\\n    margin: 20px 0;\\n    position: relative;\\n  }\\n\\n  .support-new-messages-divider::before,\\n  .support-new-messages-divider::after {\\n    content: \\'\\';\\n    flex: 1;\\n    height: 1px;\\n    background: var(--support-primary-color);\\n  }\\n\\n  .support-new-messages-text {\\n    color: var(--support-primary-color);\\n    font-size: 12px;\\n    font-weight: 600;\\n    text-transform: uppercase;\\n    letter-spacing: 0.5px;\\n    white-space: nowrap;\\n  }\\n\\n  .support-message-status {\\n    display: flex;\\n    align-items: flex-end;\\n    padding-bottom: 4px;\\n    flex-shrink: 0;\\n  }\\n\\n  .support-pending-icon,\\n  .support-sent-icon {\\n    width: 16px;\\n    height: 16px;\\n    fill: rgba(0, 0, 0, 0.4);\\n  }\\n\\n  .support-message.pending .support-pending-icon {\\n    animation: pulse-pending 1.5s ease-in-out infinite;\\n  }\\n\\n  .support-sent-icon {\\n    fill: rgba(0, 0, 0, 0.3);\\n  }\\n\\n  @keyframes pulse-pending {\\n    0%, 100% {\\n      opacity: 0.4;\\n    }\\n    50% {\\n      opacity: 1;\\n    }\\n  }\\n\\n  /* Failed message styles */\\n  .support-message.failed .support-message-status {\\n    color: #ef4444;\\n    cursor: pointer;\\n  }\\n\\n  .support-message.failed .support-message-status:hover {\\n    opacity: 0.7;\\n  }\\n\\n  .support-failed-icon {\\n    width: 16px;\\n    height: 16px;\\n    fill: #ef4444;\\n  }\\n\\n  /* Streaming indicator styles */\\n  .support-streaming-indicator {\\n    display: flex;\\n    align-items: center;\\n    gap: 4px;\\n  }\\n\\n  .support-streaming-indicator span {\\n    width: 6px;\\n    height: 6px;\\n    border-radius: 50%;\\n    background: rgba(var(--support-primary-rgb), 0.6);\\n    animation: streaming-bounce 1.4s infinite ease-in-out both;\\n  }\\n\\n  .support-streaming-indicator span:nth-child(1) {\\n    animation-delay: -0.32s;\\n  }\\n\\n  .support-streaming-indicator span:nth-child(2) {\\n    animation-delay: -0.16s;\\n  }\\n\\n  @keyframes streaming-bounce {\\n    0%, 80%, 100% {\\n      transform: scale(0.8);\\n      opacity: 0.5;\\n    }\\n    40% {\\n      transform: scale(1.2);\\n      opacity: 1;\\n    }\\n  }\\n\\n  .support-message.streaming .support-message-content {\\n    white-space: pre-wrap;\\n    word-wrap: break-word;\\n  }\\n\\n  /* Thinking bubble styles */\\n  .support-message.thinking {\\n    align-items: center;\\n  }\\n\\n  .support-message.thinking .support-thinking-bubble {\\n    background: transparent;\\n    border: none;\\n    box-shadow: none;\\n    font-style: italic;\\n    font-size: 13px;\\n    padding: 0;\\n    line-height: 1.2;\\n    white-space: normal;\\n  }\\n\\n  .support-thinking-content {\\n    line-height: 1.2;\\n    color: #374151;\\n  }\\n\\n  @supports ((-webkit-background-clip: text) or (background-clip: text)) {\\n    .support-message.thinking .support-thinking-content {\\n      background: linear-gradient(\\n        90deg,\\n        rgba(55, 65, 81, 0.4) 0%,\\n        rgba(55, 65, 81, 0.4) 40%,\\n        rgba(55, 65, 81, 1) 50%,\\n        rgba(55, 65, 81, 0.4) 60%,\\n        rgba(55, 65, 81, 0.4) 100%\\n      );\\n      background-size: 200% 100%;\\n      -webkit-background-clip: text;\\n      background-clip: text;\\n      -webkit-text-fill-color: transparent;\\n      color: transparent;\\n      animation: support-thinking-glow 2.5s linear infinite;\\n    }\\n  }\\n\\n  @keyframes support-thinking-glow {\\n    from { background-position: 200% 0; }\\n    to { background-position: -200% 0; }\\n  }\\n\\n  /* Document-read progress (ai_progress with progress_type \"search_document\") */\\n  .support-message.thinking.has-doc-reads {\\n    align-items: flex-start;\\n  }\\n\\n  /* Keep the shimmer line pinned where centering placed it (avatar 32px vs\\n     ~16px line) so it does not jump up when the first document appears. */\\n  .support-message.thinking.has-doc-reads .support-thinking-bubble {\\n    padding-top: 8px;\\n  }\\n\\n  .support-doc-read-stack {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 5px;\\n    margin-top: 6px;\\n  }\\n\\n  .support-doc-read-stack:empty {\\n    display: none;\\n  }\\n\\n  .support-doc-read-item {\\n    display: flex;\\n    align-items: center;\\n    gap: 7px;\\n    font-size: 12px;\\n    line-height: 1.3;\\n    color: var(--widget-text-muted);\\n    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;\\n    overflow: hidden;\\n  }\\n\\n  .support-doc-read-check {\\n    flex: 0 0 auto;\\n    width: 15px;\\n    height: 15px;\\n    border-radius: 50%;\\n    background: rgba(var(--support-primary-rgb), 0.14);\\n    color: var(--support-primary-color);\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n  }\\n\\n  .support-doc-read-verb {\\n    opacity: 0.7;\\n  }\\n\\n  .support-doc-read-name {\\n    white-space: nowrap;\\n    overflow: hidden;\\n    text-overflow: ellipsis;\\n    min-width: 0;\\n  }\\n\\n  .support-doc-read-enter {\\n    animation: support-doc-read-in 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;\\n  }\\n\\n  .support-doc-read-leave {\\n    animation: support-doc-read-out 0.4s cubic-bezier(0.4, 0, 1, 1) both;\\n  }\\n\\n  @keyframes support-doc-read-in {\\n    from { opacity: 0; transform: translateY(6px); }\\n    to { opacity: 1; transform: translateY(0); }\\n  }\\n\\n  @keyframes support-doc-read-out {\\n    to {\\n      opacity: 0;\\n      transform: translateY(-4px);\\n      max-height: 0;\\n      margin-top: 0;\\n      margin-bottom: 0;\\n    }\\n  }\\n\\n  /* Typing indicator styles */\\n  .support-message.typing-indicator {\\n    animation: fadeIn 0.2s ease-in;\\n  }\\n\\n  .support-typing-bubble {\\n    display: inline-flex;\\n    align-items: center;\\n    gap: 4px;\\n  }\\n\\n  .support-typing-dot {\\n    display: inline-block;\\n    width: 8px;\\n    height: 8px;\\n    border-radius: 50%;\\n    background-color: #9ca3af;\\n    animation: typing-bounce 1.4s infinite;\\n  }\\n\\n  .support-typing-dot:nth-child(2) {\\n    animation-delay: 0.2s;\\n  }\\n\\n  .support-typing-dot:nth-child(3) {\\n    animation-delay: 0.4s;\\n  }\\n\\n  @keyframes typing-bounce {\\n    0%, 60%, 100% {\\n      transform: translateY(0);\\n    }\\n    30% {\\n      transform: translateY(-8px);\\n    }\\n  }\\n\\n  @keyframes fadeIn {\\n    from {\\n      opacity: 0;\\n      transform: translateY(10px);\\n    }\\n    to {\\n      opacity: 1;\\n      transform: translateY(0);\\n    }\\n  }\\n\\n  .support-chat-footer {\\n    padding: var(--widget-footer-pad);\\n    background: var(--widget-surface);\\n    position: relative;\\n    z-index: 2;\\n  }\\n\\n  .support-input-container {\\n    display: flex;\\n    align-items: flex-end;\\n    gap: 8px;\\n    transition: all 0.2s ease;\\n    border-radius: 24px;\\n  }\\n\\n  .support-input-container.drag-over {\\n    background: rgba(var(--support-primary-rgb), 0.1);\\n    outline: 2px dashed var(--support-primary-color);\\n    outline-offset: -2px;\\n  }\\n\\n  .support-chat-input {\\n    flex: 1;\\n    padding: 10px 16px;\\n    border: 1px solid var(--widget-border);\\n    border-radius: 24px;\\n    font-size: 14px;\\n    outline: none;\\n    transition: border-color 0.2s, height 0.1s ease;\\n    font-family: inherit;\\n    background: var(--widget-agent-bubble-bg);\\n    color: var(--widget-text);\\n    resize: none;\\n    height: 40px;\\n    min-height: 40px;\\n    max-height: 120px;\\n    line-height: 20px;\\n    overflow-y: hidden;\\n    box-sizing: border-box;\\n  }\\n\\n  .support-chat-input::placeholder {\\n    color: #9ca3af;\\n    opacity: 0.7;\\n  }\\n\\n  .support-chat-input:focus {\\n    border-color: #000000;\\n  }\\n\\n  .support-chat-input:disabled {\\n    background: #f3f4f6;\\n    color: #9ca3af;\\n    cursor: not-allowed;\\n    border-color: #e5e7eb;\\n  }\\n\\n  .support-chat-input:disabled::placeholder {\\n    color: #9ca3af;\\n    font-style: italic;\\n  }\\n\\n  .support-send-btn {\\n    width: 40px;\\n    height: 40px;\\n    border-radius: 50%;\\n    background: var(--support-primary-color);\\n    border: none;\\n    cursor: pointer;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    transition: all 0.2s;\\n    flex-shrink: 0;\\n    color: var(--support-secondary-color);\\n  }\\n\\n  .support-send-btn:hover {\\n    transform: scale(1.05);\\n  }\\n\\n  .support-send-btn:disabled {\\n    opacity: 0.5;\\n    cursor: not-allowed;\\n    transform: none;\\n  }\\n\\n  .support-send-btn.ai-thinking {\\n    background: rgba(var(--support-primary-rgb), 0.2);\\n    border: none;\\n    border-radius: 8px;\\n    cursor: pointer;\\n  }\\n\\n  .support-send-btn.ai-thinking:hover {\\n    background: rgba(var(--support-primary-rgb), 0.3);\\n    transform: scale(1.05);\\n  }\\n\\n  .support-send-btn svg {\\n    width: 20px;\\n    height: 20px;\\n    fill: var(--support-secondary-color);\\n  }\\n\\n  .support-send-btn.ai-thinking svg {\\n    width: 16px;\\n    height: 16px;\\n    fill: var(--support-primary-color);\\n  }\\n\\n  .support-send-btn.pulse {\\n    animation: support-send-btn-pulse 0.5s ease-in-out 2;\\n  }\\n\\n  @keyframes support-send-btn-pulse {\\n    0%, 100% {\\n      transform: scale(1);\\n      box-shadow: 0 0 0 0 rgba(var(--support-primary-rgb), 0.6);\\n    }\\n    50% {\\n      transform: scale(1.15);\\n      box-shadow: 0 0 0 8px rgba(var(--support-primary-rgb), 0);\\n    }\\n  }\\n\\n  /* === Voice note recorder (composer) === */\\n  .support-mic-btn {\\n    width: 40px;\\n    height: 40px;\\n    border-radius: 50%;\\n    background: var(--support-primary-color);\\n    border: none;\\n    cursor: pointer;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    transition: all 0.2s;\\n    flex-shrink: 0;\\n    color: var(--support-secondary-color);\\n  }\\n\\n  .support-mic-btn:hover {\\n    transform: scale(1.05);\\n  }\\n\\n  .support-mic-btn svg {\\n    width: 20px;\\n    height: 20px;\\n    fill: var(--support-secondary-color);\\n  }\\n\\n  .support-mic-btn[hidden],\\n  .support-send-btn[hidden] {\\n    display: none !important;\\n  }\\n\\n  .support-input-container.voice-active > .support-attach-btn,\\n  .support-input-container.voice-active > .support-chat-input,\\n  .support-input-container.voice-active > .support-send-btn,\\n  .support-input-container.voice-active > .support-mic-btn {\\n    display: none !important;\\n  }\\n\\n  .support-voice-recorder {\\n    flex: 1;\\n    min-width: 0;\\n    display: flex;\\n    flex-direction: column;\\n    gap: 6px;\\n    animation: support-voice-in 0.18s cubic-bezier(0.2, 0.9, 0.3, 1);\\n  }\\n\\n  @keyframes support-voice-in {\\n    from { opacity: 0; transform: translateY(4px); }\\n    to { opacity: 1; transform: none; }\\n  }\\n\\n  .support-voice-row {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n  }\\n\\n  .support-voice-recorder [data-only] {\\n    display: none;\\n  }\\n\\n  .support-voice-recorder[data-state=\"recording\"] [data-only~=\"recording\"],\\n  .support-voice-recorder[data-state=\"review\"] [data-only~=\"review\"],\\n  .support-voice-recorder[data-state=\"uploading\"] [data-only~=\"uploading\"] {\\n    display: inline-flex;\\n  }\\n\\n  .support-voice-recorder[data-state=\"uploading\"] .support-voice-trash,\\n  .support-voice-recorder[data-state=\"uploading\"] .support-voice-bar {\\n    opacity: 0.55;\\n    pointer-events: none;\\n  }\\n\\n  .support-voice-bar {\\n    flex: 1;\\n    min-width: 0;\\n    min-height: 40px;\\n    display: flex;\\n    align-items: center;\\n    gap: 10px;\\n    background: var(--widget-agent-bubble-bg);\\n    border: 1px solid var(--widget-border);\\n    border-radius: 24px;\\n    padding: 4px 14px;\\n    box-sizing: border-box;\\n  }\\n\\n  .support-voice-trash {\\n    width: 36px;\\n    height: 36px;\\n    padding: 0;\\n    border: none;\\n    border-radius: 50%;\\n    background: transparent;\\n    color: #ef4444;\\n    cursor: pointer;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    flex-shrink: 0;\\n    transition: background 0.15s ease;\\n  }\\n\\n  .support-voice-trash:hover {\\n    background: rgba(239, 68, 68, 0.12);\\n  }\\n\\n  .support-voice-trash svg {\\n    width: 18px;\\n    height: 18px;\\n    fill: currentColor;\\n  }\\n\\n  .support-voice-action {\\n    width: 40px;\\n    height: 40px;\\n    border-radius: 50%;\\n    background: var(--support-primary-color);\\n    border: none;\\n    cursor: pointer;\\n    align-items: center;\\n    justify-content: center;\\n    flex-shrink: 0;\\n    color: var(--support-secondary-color);\\n    transition: all 0.2s;\\n  }\\n\\n  .support-voice-action:hover {\\n    transform: scale(1.05);\\n  }\\n\\n  .support-voice-action svg {\\n    width: 18px;\\n    height: 18px;\\n    fill: var(--support-secondary-color);\\n  }\\n\\n  .support-voice-dot {\\n    flex-shrink: 0;\\n    width: 9px;\\n    height: 9px;\\n    border-radius: 50%;\\n    background: #ef4444;\\n    animation: support-voice-pulse 1.4s ease-in-out infinite;\\n  }\\n\\n  @keyframes support-voice-pulse {\\n    0%, 100% { opacity: 1; transform: scale(1); }\\n    50% { opacity: 0.35; transform: scale(0.75); }\\n  }\\n\\n  .support-voice-time {\\n    flex-shrink: 0;\\n    font-size: 13px;\\n    font-weight: 600;\\n    font-variant-numeric: tabular-nums;\\n    color: var(--widget-text);\\n  }\\n\\n  .support-voice-status {\\n    flex: 1;\\n    font-size: 13px;\\n    color: #6b7280;\\n  }\\n\\n  .support-voice-budget {\\n    align-items: center;\\n    gap: 8px;\\n    margin: 0 48px;\\n  }\\n\\n  .support-voice-budget-track {\\n    flex: 1;\\n    height: 3px;\\n    border-radius: 999px;\\n    background: var(--widget-border);\\n    overflow: hidden;\\n  }\\n\\n  .support-voice-budget-fill {\\n    height: 100%;\\n    width: 0%;\\n    border-radius: 999px;\\n    background: var(--support-primary-color);\\n    transition: width 0.25s linear, background 0.3s ease;\\n  }\\n\\n  .support-voice-budget-fill.is-near {\\n    background: #f59e0b;\\n  }\\n\\n  .support-voice-budget-max {\\n    flex-shrink: 0;\\n    font-size: 10px;\\n    color: #6b7280;\\n    font-variant-numeric: tabular-nums;\\n  }\\n\\n  .support-voice-spinner {\\n    width: 16px;\\n    height: 16px;\\n    border-radius: 50%;\\n    border: 2px solid currentColor;\\n    border-right-color: transparent;\\n    animation: support-voice-spin 0.8s linear infinite;\\n  }\\n\\n  @keyframes support-voice-spin {\\n    to { transform: rotate(360deg); }\\n  }\\n\\n  @media (prefers-reduced-motion: reduce) {\\n    .support-voice-dot,\\n    .support-voice-recorder {\\n      animation: none;\\n    }\\n  }\\n\\n  .support-branding {\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    gap: 6px;\\n    padding: 4px;\\n    font-size: 11px;\\n    color: #999;\\n    text-decoration: none;\\n    transition: color 0.2s;\\n  }\\n\\n  .support-branding:hover {\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-branding-logo {\\n    width: 16px;\\n    height: 16px;\\n    color: var(--support-primary-color);\\n    flex-shrink: 0;\\n  }\\n\\n  .support-branding-text {\\n    font-weight: 500;\\n  }\\n\\n  .support-branding.hidden {\\n    display: none;\\n  }\\n\\n  /* Utility classes */\\n  .hidden {\\n    display: none !important;\\n  }\\n\\n  /* System Action Cards */\\n  .support-message.system-action {\\n    padding: 0;\\n    max-width: 100%;\\n    margin: 12px 0;\\n  }\\n\\n  .support-system-action-card {\\n    background: #f9fafb;\\n    border: 1px solid #e5e7eb;\\n    border-radius: 8px;\\n    padding: 12px;\\n    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);\\n  }\\n\\n  .support-system-action-content h4 {\\n    margin: 0 0 4px 0;\\n    font-size: 13px;\\n    font-weight: 600;\\n    color: #374151;\\n  }\\n\\n  .support-system-action-content p {\\n    margin: 0 0 10px 0;\\n    font-size: 12px;\\n    color: #6b7280;\\n    line-height: 1.4;\\n  }\\n\\n  .support-system-action-buttons {\\n    display: flex;\\n    gap: 6px;\\n    margin-top: 10px;\\n  }\\n\\n  .support-executive-availability {\\n    display: flex;\\n    align-items: center;\\n    gap: 6px;\\n    font-size: 12px;\\n    font-weight: 500;\\n    color: #4b5563;\\n    line-height: 1.4;\\n  }\\n\\n  .support-executive-availability-dot {\\n    flex-shrink: 0;\\n    width: 7px;\\n    height: 7px;\\n    border-radius: 50%;\\n    background: #f59e0b;\\n  }\\n\\n  .support-executive-availability[data-reason=\"out_of_office\"] .support-executive-availability-dot {\\n    background: #9ca3af;\\n  }\\n\\n  .support-action-button {\\n    flex: 1;\\n    padding: 7px 12px;\\n    border-radius: 6px;\\n    font-size: 12px;\\n    font-weight: 500;\\n    cursor: pointer;\\n    transition: all 0.2s ease;\\n    border: none;\\n    font-family: inherit;\\n  }\\n\\n  .support-action-button.primary {\\n    background: var(--support-primary-color);\\n    color: var(--support-secondary-color);\\n  }\\n\\n  .support-action-button.primary:hover:not(:disabled) {\\n    background: var(--support-primary-color);\\n    opacity: 0.9;\\n  }\\n\\n  .support-action-button.secondary {\\n    background: white;\\n    color: #6b7280;\\n    border: 1px solid #d1d5db;\\n  }\\n\\n  .support-action-button.secondary:hover:not(:disabled) {\\n    background: #f9fafb;\\n    border-color: #9ca3af;\\n  }\\n\\n  .support-action-button:disabled {\\n    opacity: 0.5;\\n    cursor: not-allowed;\\n  }\\n\\n  .support-system-action-feedback {\\n    margin-top: 8px;\\n    padding: 6px 10px;\\n    background: #f0fdf4;\\n    border: 1px solid #bbf7d0;\\n    border-radius: 4px;\\n    color: #166534;\\n    font-size: 11px;\\n    text-align: center;\\n  }\\n\\n  .support-api-confirmation.resolved .support-action-button {\\n    cursor: default;\\n  }\\n\\n  .support-api-confirmation.resolved .support-action-button:not(.selected) {\\n    opacity: 0.4;\\n  }\\n\\n  .support-api-confirmation.resolved .support-action-button.selected {\\n    opacity: 1;\\n  }\\n\\n  /* CSAT Survey Styles */\\n  .support-csat-survey {\\n    text-align: center;\\n  }\\n\\n  .support-csat-title {\\n    margin: 0 0 12px 0;\\n    font-size: 14px;\\n    font-weight: 600;\\n    color: #374151;\\n  }\\n\\n  .support-csat-stars {\\n    display: flex;\\n    justify-content: center;\\n    gap: 8px;\\n    margin-bottom: 12px;\\n  }\\n\\n  .support-csat-star {\\n    background: none;\\n    border: none;\\n    padding: 4px;\\n    cursor: pointer;\\n    transition: transform 0.2s ease;\\n  }\\n\\n  .support-csat-star:hover:not(:disabled) {\\n    transform: scale(1.2);\\n  }\\n\\n  .support-csat-star svg {\\n    width: 32px;\\n    height: 32px;\\n    fill: #d1d5db;\\n    stroke: #9ca3af;\\n    stroke-width: 1;\\n    transition: fill 0.2s ease, stroke 0.2s ease;\\n  }\\n\\n  .support-csat-star.active svg,\\n  .support-csat-star.hover svg {\\n    fill: #fbbf24;\\n    stroke: #f59e0b;\\n  }\\n\\n  .support-csat-star:focus {\\n    outline: 2px solid var(--support-primary-color);\\n    outline-offset: 2px;\\n    border-radius: 4px;\\n  }\\n\\n  .support-csat-star:disabled {\\n    cursor: not-allowed;\\n  }\\n\\n  .support-csat-star:disabled:hover {\\n    transform: none;\\n  }\\n\\n  .support-csat-comment {\\n    width: 100%;\\n    min-height: 60px;\\n    padding: 10px;\\n    border: 1px solid #d1d5db;\\n    border-radius: 6px;\\n    font-family: inherit;\\n    font-size: 13px;\\n    resize: vertical;\\n    margin-bottom: 12px;\\n    box-sizing: border-box;\\n    transition: border-color 0.2s ease;\\n  }\\n\\n  .support-csat-comment:focus {\\n    outline: none;\\n    border-color: var(--support-primary-color);\\n  }\\n\\n  .support-csat-comment::placeholder {\\n    color: #9ca3af;\\n  }\\n\\n  .support-csat-comment:disabled {\\n    background: #f9fafb;\\n    cursor: not-allowed;\\n  }\\n\\n  .support-csat-buttons {\\n    display: flex;\\n    gap: 8px;\\n  }\\n\\n  .support-csat-submit {\\n    flex: 1;\\n    padding: 10px 16px;\\n    background: var(--support-primary-color);\\n    color: var(--support-secondary-color);\\n    border: none;\\n    border-radius: 6px;\\n    font-size: 13px;\\n    font-weight: 500;\\n    cursor: pointer;\\n    transition: opacity 0.2s ease;\\n    font-family: inherit;\\n  }\\n\\n  .support-csat-submit:hover:not(:disabled) {\\n    opacity: 0.9;\\n  }\\n\\n  .support-csat-submit:disabled {\\n    opacity: 0.5;\\n    cursor: not-allowed;\\n  }\\n\\n  .support-csat-skip {\\n    padding: 10px 16px;\\n    background: white;\\n    color: #6b7280;\\n    border: 1px solid #d1d5db;\\n    border-radius: 6px;\\n    font-size: 13px;\\n    font-weight: 500;\\n    cursor: pointer;\\n    transition: background 0.2s ease, border-color 0.2s ease;\\n    font-family: inherit;\\n  }\\n\\n  .support-csat-skip:hover:not(:disabled) {\\n    background: #f9fafb;\\n    border-color: #9ca3af;\\n  }\\n\\n  .support-csat-skip:disabled {\\n    opacity: 0.5;\\n    cursor: not-allowed;\\n  }\\n\\n  /* Interactive Form Styles */\\n  .support-interactive-card {\\n    background: #f9fafb;\\n    border: 1px solid #e5e7eb;\\n    border-radius: 8px;\\n    padding: 12px;\\n    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);\\n    max-width: 100%;\\n  }\\n\\n  .support-interactive-body {\\n    margin: 0 0 12px 0;\\n    font-size: 13px;\\n    color: #374151;\\n    line-height: 1.5;\\n  }\\n\\n  /* Button Group */\\n  .support-interactive-button-group {\\n    display: flex;\\n    flex-wrap: wrap;\\n    gap: 8px;\\n    margin-bottom: 12px;\\n  }\\n\\n  .support-interactive-button {\\n    padding: 8px 16px;\\n    border-radius: 6px;\\n    font-size: 13px;\\n    font-weight: 500;\\n    cursor: pointer;\\n    transition: all 0.2s ease;\\n    font-family: inherit;\\n    border: 1px solid transparent;\\n  }\\n\\n  .support-interactive-button.primary {\\n    background: var(--support-primary-color);\\n    color: var(--support-secondary-color);\\n    border-color: var(--support-primary-color);\\n  }\\n\\n  .support-interactive-button.primary:hover:not(:disabled) {\\n    opacity: 0.9;\\n  }\\n\\n  .support-interactive-button.secondary {\\n    background: white;\\n    color: #374151;\\n    border-color: #d1d5db;\\n  }\\n\\n  .support-interactive-button.secondary:hover:not(:disabled) {\\n    background: #f9fafb;\\n    border-color: #9ca3af;\\n  }\\n\\n  .support-interactive-button.danger {\\n    background: #ef4444;\\n    color: white;\\n    border-color: #ef4444;\\n  }\\n\\n  .support-interactive-button.danger:hover:not(:disabled) {\\n    background: #dc2626;\\n    border-color: #dc2626;\\n  }\\n\\n  .support-interactive-button:disabled {\\n    opacity: 0.5;\\n    cursor: not-allowed;\\n  }\\n\\n  /* Radio Buttons */\\n  .support-radio-group {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 8px;\\n    margin-bottom: 12px;\\n  }\\n\\n  .support-radio-option {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n    cursor: pointer;\\n  }\\n\\n  .support-radio-option input[type=\"radio\"] {\\n    accent-color: var(--support-primary-color);\\n    width: 16px;\\n    height: 16px;\\n    cursor: pointer;\\n    margin: 0;\\n  }\\n\\n  .support-radio-option label {\\n    font-size: 13px;\\n    color: #374151;\\n    cursor: pointer;\\n    flex: 1;\\n  }\\n\\n  .support-radio-option input:disabled,\\n  .support-radio-option input:disabled + label {\\n    opacity: 0.5;\\n    cursor: not-allowed;\\n  }\\n\\n  /* Checkboxes */\\n  .support-checkbox-group {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 8px;\\n    margin-bottom: 12px;\\n  }\\n\\n  .support-checkbox-option {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n    cursor: pointer;\\n  }\\n\\n  .support-checkbox-option input[type=\"checkbox\"] {\\n    accent-color: var(--support-primary-color);\\n    width: 16px;\\n    height: 16px;\\n    cursor: pointer;\\n    margin: 0;\\n  }\\n\\n  .support-checkbox-option label {\\n    font-size: 13px;\\n    color: #374151;\\n    cursor: pointer;\\n    flex: 1;\\n  }\\n\\n  .support-checkbox-option input:disabled,\\n  .support-checkbox-option input:disabled + label {\\n    opacity: 0.5;\\n    cursor: not-allowed;\\n  }\\n\\n  /* Text Input */\\n  .support-text-input {\\n    width: 100%;\\n    padding: 10px;\\n    border: 1px solid #d1d5db;\\n    border-radius: 6px;\\n    font-family: inherit;\\n    font-size: 13px;\\n    margin-bottom: 12px;\\n    box-sizing: border-box;\\n    transition: border-color 0.2s ease;\\n  }\\n\\n  .support-text-input:focus {\\n    outline: none;\\n    border-color: var(--support-primary-color);\\n  }\\n\\n  .support-text-input::placeholder {\\n    color: #9ca3af;\\n  }\\n\\n  .support-text-input:disabled {\\n    background: #f9fafb;\\n    cursor: not-allowed;\\n  }\\n\\n  .support-text-input.error {\\n    border-color: #ef4444;\\n  }\\n\\n  /* Star Rating (reusing existing CSAT star styles with interactive namespace) */\\n  .support-interactive-stars {\\n    display: flex;\\n    gap: 8px;\\n    margin-bottom: 12px;\\n    justify-content: center;\\n  }\\n\\n  .support-interactive-star {\\n    background: none;\\n    border: none;\\n    padding: 4px;\\n    cursor: pointer;\\n    transition: transform 0.2s ease;\\n  }\\n\\n  .support-interactive-star svg {\\n    width: 32px;\\n    height: 32px;\\n    fill: #d1d5db;\\n    stroke: none;\\n    transition: fill 0.2s ease;\\n  }\\n\\n  .support-interactive-star:hover:not(:disabled) {\\n    transform: scale(1.15);\\n  }\\n\\n  .support-interactive-star.active svg,\\n  .support-interactive-star.hovered svg {\\n    fill: #fbbf24;\\n  }\\n\\n  .support-interactive-star:disabled {\\n    cursor: not-allowed;\\n  }\\n\\n  .support-interactive-star:disabled:hover {\\n    transform: none;\\n  }\\n\\n  /* Comment Field */\\n  .support-interactive-comment {\\n    width: 100%;\\n    min-height: 60px;\\n    padding: 10px;\\n    border: 1px solid #d1d5db;\\n    border-radius: 6px;\\n    font-family: inherit;\\n    font-size: 13px;\\n    resize: vertical;\\n    margin-bottom: 12px;\\n    box-sizing: border-box;\\n    transition: border-color 0.2s ease;\\n  }\\n\\n  .support-interactive-comment:focus {\\n    outline: none;\\n    border-color: var(--support-primary-color);\\n  }\\n\\n  .support-interactive-comment::placeholder {\\n    color: #9ca3af;\\n  }\\n\\n  .support-interactive-comment:disabled {\\n    background: #f9fafb;\\n    cursor: not-allowed;\\n  }\\n\\n  .support-interactive-comment.error {\\n    border-color: #ef4444;\\n  }\\n\\n  /* Validation Errors */\\n  .support-interactive-error {\\n    font-size: 11px;\\n    color: #ef4444;\\n    margin-top: -8px;\\n    margin-bottom: 8px;\\n    display: block;\\n  }\\n\\n  /* Submit/Skip Buttons */\\n  .support-interactive-buttons {\\n    display: flex;\\n    gap: 8px;\\n  }\\n\\n  .support-interactive-submit {\\n    flex: 1;\\n    padding: 10px 16px;\\n    background: var(--support-primary-color);\\n    color: var(--support-secondary-color);\\n    border: none;\\n    border-radius: 6px;\\n    font-size: 13px;\\n    font-weight: 500;\\n    cursor: pointer;\\n    transition: opacity 0.2s ease;\\n    font-family: inherit;\\n  }\\n\\n  .support-interactive-submit:hover:not(:disabled) {\\n    opacity: 0.9;\\n  }\\n\\n  .support-interactive-submit:disabled {\\n    opacity: 0.5;\\n    cursor: not-allowed;\\n  }\\n\\n  .support-interactive-skip {\\n    padding: 10px 16px;\\n    background: white;\\n    color: #6b7280;\\n    border: 1px solid #d1d5db;\\n    border-radius: 6px;\\n    font-size: 13px;\\n    font-weight: 500;\\n    cursor: pointer;\\n    transition: background 0.2s ease, border-color 0.2s ease;\\n    font-family: inherit;\\n  }\\n\\n  .support-interactive-skip:hover:not(:disabled) {\\n    background: #f9fafb;\\n    border-color: #9ca3af;\\n  }\\n\\n  .support-interactive-skip:disabled {\\n    opacity: 0.5;\\n    cursor: not-allowed;\\n  }\\n\\n  /* Resolved State */\\n  .support-interactive-card.resolved {\\n    pointer-events: none;\\n  }\\n\\n  .support-interactive-card.resolved .support-image-card:not(.selected),\\n  .support-interactive-card.resolved .support-interactive-button:not(.selected),\\n  .support-interactive-card.resolved .support-radio-option:not(.selected),\\n  .support-interactive-card.resolved .support-checkbox-option:not(.selected) {\\n    opacity: 0.5;\\n  }\\n\\n  .support-interactive-card.resolved .support-image-card-expand {\\n    display: none;\\n  }\\n\\n  .support-interactive-card.resolved .support-interactive-body:last-child {\\n    margin-bottom: 0;\\n  }\\n\\n  .support-interactive-resolved-indicator {\\n    margin-top: 8px;\\n    padding: 6px 10px;\\n    background: #f0fdf4;\\n    border: 1px solid #bbf7d0;\\n    border-radius: 4px;\\n    color: #166534;\\n    font-size: 11px;\\n    text-align: center;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    gap: 6px;\\n  }\\n\\n  .support-interactive-resolved-indicator svg {\\n    width: 14px;\\n    height: 14px;\\n    fill: currentColor;\\n  }\\n\\n  .support-interactive-resolved-response {\\n    margin-top: 8px;\\n    padding: 8px 10px;\\n    background: #f9fafb;\\n    border: 1px solid #e5e7eb;\\n    border-radius: 4px;\\n    font-size: 12px;\\n    display: flex;\\n    flex-direction: column;\\n    gap: 4px;\\n  }\\n\\n  .support-interactive-resolved-label {\\n    color: #6b7280;\\n    font-weight: 500;\\n  }\\n\\n  .support-interactive-resolved-value {\\n    color: #374151;\\n    font-weight: 600;\\n  }\\n\\n  /* Interactive Thumbnails (for radio/checkbox) */\\n  .support-interactive-thumbnail {\\n    width: 60px;\\n    height: 60px;\\n    border-radius: 6px;\\n    overflow: hidden;\\n    cursor: zoom-in;\\n    flex-shrink: 0;\\n    border: 1px solid #e5e7eb;\\n    background: #f9fafb;\\n  }\\n\\n  .support-interactive-thumbnail img {\\n    width: 100%;\\n    height: 100%;\\n    object-fit: cover;\\n    display: block;\\n  }\\n\\n  .support-interactive-thumbnail:hover {\\n    border-color: var(--support-primary-color);\\n    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\\n  }\\n\\n  /* Button group layouts */\\n  .support-interactive-button-group.horizontal {\\n    display: flex;\\n    flex-wrap: wrap;\\n    gap: 8px;\\n  }\\n\\n  .support-interactive-button-group.stacked {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 8px;\\n  }\\n\\n  .support-interactive-button-group.image-grid {\\n    display: grid;\\n    grid-template-columns: repeat(2, 1fr);\\n    gap: 8px;\\n  }\\n\\n  /* Pill buttons (horizontal, ≤2 options) */\\n  .support-interactive-button.pill {\\n    padding: 8px 20px;\\n    border-radius: 20px;\\n    font-size: 13px;\\n    font-weight: 500;\\n    cursor: pointer;\\n    transition: all 0.2s ease;\\n    font-family: inherit;\\n    border: 1px solid var(--support-primary-color);\\n    background: rgba(var(--support-primary-rgb), 0.1);\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-interactive-button.pill:hover:not(:disabled) {\\n    background: var(--support-primary-color);\\n    color: white;\\n  }\\n\\n  .support-interactive-button.pill.primary {\\n    background: var(--support-primary-color);\\n    color: white;\\n  }\\n\\n  .support-interactive-button.pill.primary:hover:not(:disabled) {\\n    opacity: 0.9;\\n  }\\n\\n  .support-interactive-button.pill.selected {\\n    background: var(--support-primary-color);\\n    color: white;\\n    border-color: var(--support-primary-color);\\n  }\\n\\n  .support-interactive-button.pill.selected::before {\\n    content: \\'✓ \\';\\n  }\\n\\n  /* Stacked buttons (full-width, >2 options) */\\n  .support-interactive-button.stacked-button {\\n    width: 100%;\\n    padding: 12px 16px;\\n    border-radius: 8px;\\n    font-size: 13px;\\n    font-weight: 500;\\n    cursor: pointer;\\n    transition: all 0.2s ease;\\n    font-family: inherit;\\n    border: none;\\n    background: white;\\n    color: #374151;\\n    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);\\n    text-align: left;\\n  }\\n\\n  .support-interactive-button.stacked-button:hover:not(:disabled) {\\n    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);\\n    background: rgba(var(--support-primary-rgb), 0.05);\\n  }\\n\\n  .support-interactive-button.stacked-button.selected {\\n    background: rgba(var(--support-primary-rgb), 0.1);\\n    border: 2px solid var(--support-primary-color);\\n    color: var(--support-primary-color);\\n    font-weight: 600;\\n  }\\n\\n  .support-interactive-button.stacked-button.selected::before {\\n    content: \\'✓ \\';\\n  }\\n\\n  /* Image Cards */\\n  .support-image-card {\\n    border-radius: 12px;\\n    overflow: hidden;\\n    background: rgba(0, 0, 0, 0.03);\\n    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);\\n    cursor: pointer;\\n    transition: all 0.2s ease;\\n  }\\n\\n  .support-image-card:hover {\\n    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);\\n    transform: translateY(-2px);\\n  }\\n\\n  .support-image-card-image {\\n    position: relative;\\n    aspect-ratio: 1;\\n    background: #f3f4f6;\\n    overflow: hidden;\\n  }\\n\\n  .support-image-card-image img {\\n    width: 100%;\\n    height: 100%;\\n    object-fit: cover;\\n    display: block;\\n    transition: transform 0.3s ease;\\n  }\\n\\n  .support-image-card:hover .support-image-card-image img {\\n    transform: scale(1.05);\\n  }\\n\\n  .support-image-card-placeholder {\\n    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);\\n  }\\n\\n  .support-image-card-expand {\\n    position: absolute;\\n    top: 8px;\\n    right: 8px;\\n    width: 28px;\\n    height: 28px;\\n    padding: 0;\\n    border: none;\\n    border-radius: 50%;\\n    background: rgba(0, 0, 0, 0.4);\\n    cursor: pointer;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    opacity: 0;\\n    transition: opacity 0.2s ease, background 0.2s ease;\\n  }\\n\\n  .support-image-card:hover .support-image-card-expand,\\n  .support-image-card-expand:focus-visible {\\n    opacity: 1;\\n  }\\n\\n  .support-image-card-expand:hover {\\n    background: rgba(0, 0, 0, 0.6);\\n  }\\n\\n  .support-image-card-expand svg {\\n    width: 14px;\\n    height: 14px;\\n    fill: white;\\n  }\\n\\n  .support-image-card-label {\\n    padding: 10px 12px;\\n    font-size: 12px;\\n    font-weight: 500;\\n    text-align: center;\\n    color: #374151;\\n    border-top: 1px solid rgba(0, 0, 0, 0.06);\\n    background: white;\\n  }\\n\\n  /* Image card selected state */\\n  .support-image-card.selected {\\n    border: 2px solid var(--support-primary-color);\\n    box-shadow: 0 0 0 3px rgba(var(--support-primary-rgb), 0.2);\\n  }\\n\\n  .support-image-card.selected .support-image-card-label {\\n    background: rgba(var(--support-primary-rgb), 0.1);\\n    color: var(--support-primary-color);\\n    font-weight: 600;\\n  }\\n\\n  .support-image-card.selected .support-image-card-label::before {\\n    content: \\'✓ \\';\\n  }\\n\\n  /* Radio option with image */\\n  .support-radio-option.has-image {\\n    display: flex;\\n    align-items: center;\\n    gap: 12px;\\n    padding: 10px;\\n    background: white;\\n    border: 1px solid #e5e7eb;\\n    border-radius: 8px;\\n    cursor: pointer;\\n    transition: border-color 0.2s ease, background 0.2s ease;\\n  }\\n\\n  .support-radio-option.has-image:hover {\\n    border-color: var(--support-primary-color);\\n    background: #f9fafb;\\n  }\\n\\n  .support-radio-option.has-image:has(input:checked) {\\n    border-color: var(--support-primary-color);\\n    background: rgba(var(--support-primary-rgb), 0.05);\\n  }\\n\\n  .support-radio-content {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n    flex: 1;\\n  }\\n\\n  .support-radio-option.selected {\\n    border: 2px solid var(--support-primary-color);\\n    background: rgba(var(--support-primary-rgb), 0.1);\\n  }\\n\\n  .support-radio-option.selected label {\\n    color: var(--support-primary-color);\\n    font-weight: 600;\\n  }\\n\\n  /* Checkbox option with image */\\n  .support-checkbox-option.has-image {\\n    display: flex;\\n    align-items: center;\\n    gap: 12px;\\n    padding: 10px;\\n    background: white;\\n    border: 1px solid #e5e7eb;\\n    border-radius: 8px;\\n    cursor: pointer;\\n    transition: border-color 0.2s ease, background 0.2s ease;\\n  }\\n\\n  .support-checkbox-option.has-image:hover {\\n    border-color: var(--support-primary-color);\\n    background: #f9fafb;\\n  }\\n\\n  .support-checkbox-option.has-image:has(input:checked) {\\n    border-color: var(--support-primary-color);\\n    background: rgba(var(--support-primary-rgb), 0.05);\\n  }\\n\\n  .support-checkbox-content {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n    flex: 1;\\n  }\\n\\n  .support-checkbox-option.selected {\\n    border: 2px solid var(--support-primary-color);\\n    background: rgba(var(--support-primary-rgb), 0.1);\\n  }\\n\\n  .support-checkbox-option.selected label {\\n    color: var(--support-primary-color);\\n    font-weight: 600;\\n  }\\n\\n  /* Tour Cards */\\n  .support-tour-card {\\n    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\\n    border-radius: 8px;\\n    padding: 14px;\\n    margin-top: 8px;\\n    color: white;\\n    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\\n  }\\n\\n  .support-tour-header {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n    margin-bottom: 6px;\\n  }\\n\\n  .support-tour-header svg {\\n    flex-shrink: 0;\\n  }\\n\\n  .support-tour-header strong {\\n    font-size: 14px;\\n    font-weight: 600;\\n  }\\n\\n  .support-tour-description {\\n    margin: 0 0 12px 0;\\n    font-size: 12px;\\n    opacity: 0.9;\\n  }\\n\\n  .support-tour-button {\\n    width: 100%;\\n    padding: 8px 16px;\\n    background: white;\\n    color: #667eea;\\n    border: none;\\n    border-radius: 6px;\\n    font-size: 13px;\\n    font-weight: 600;\\n    cursor: pointer;\\n    transition: all 0.2s ease;\\n    font-family: inherit;\\n  }\\n\\n  .support-tour-button:hover:not(:disabled) {\\n    transform: translateY(-1px);\\n    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\\n  }\\n\\n  .support-tour-button:disabled {\\n    opacity: 0.6;\\n    cursor: not-allowed;\\n  }\\n\\n  /* Screenshot Cards (guided mode) */\\n  .support-message.screenshot-message {\\n    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);\\n    border-radius: 8px;\\n    padding: 10px;\\n    color: white;\\n    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\\n    font-size: 12px;\\n    max-width: 85%;\\n    display: block;\\n    cursor: pointer;\\n    transition: filter 0.15s ease, box-shadow 0.15s ease;\\n  }\\n\\n  .support-message.screenshot-message:hover {\\n    filter: brightness(1.15);\\n    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);\\n  }\\n\\n  .support-screenshot-header {\\n    display: flex;\\n    align-items: center;\\n    gap: 6px;\\n    margin-bottom: 4px;\\n  }\\n\\n  .support-screenshot-header svg {\\n    flex-shrink: 0;\\n    opacity: 0.7;\\n  }\\n\\n  .support-screenshot-badge {\\n    background: rgba(255, 255, 255, 0.15);\\n    padding: 2px 6px;\\n    border-radius: 4px;\\n    font-size: 11px;\\n    font-weight: 600;\\n    text-transform: lowercase;\\n  }\\n\\n  .support-screenshot-desc {\\n    opacity: 0.85;\\n    font-size: 12px;\\n    overflow: hidden;\\n    text-overflow: ellipsis;\\n    white-space: nowrap;\\n  }\\n\\n  .support-screenshot-body {\\n    font-size: 12px;\\n    line-height: 1.4;\\n    opacity: 0.9;\\n    margin: 6px 0 4px;\\n  }\\n\\n  .support-screenshot-url {\\n    opacity: 0.5;\\n    font-size: 11px;\\n    margin-bottom: 6px;\\n    overflow: hidden;\\n    text-overflow: ellipsis;\\n    white-space: nowrap;\\n  }\\n\\n  .support-screenshot-image {\\n    border-radius: 6px;\\n    overflow: hidden;\\n    border: 1px solid rgba(255, 255, 255, 0.1);\\n  }\\n\\n  .support-screenshot-image img {\\n    display: block;\\n    width: 100%;\\n    height: auto;\\n  }\\n\\n  /* Screenshot Group Card (collage for ≥5 consecutive screenshots) */\\n  .support-message.support-screenshot-group-card {\\n    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);\\n    border-radius: 8px;\\n    padding: 10px;\\n    color: white;\\n    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\\n    font-size: 12px;\\n    max-width: 85%;\\n    display: block;\\n  }\\n\\n  .support-screenshot-group-header {\\n    display: flex;\\n    align-items: center;\\n    gap: 6px;\\n    margin-bottom: 4px;\\n  }\\n\\n  .support-screenshot-group-header svg {\\n    flex-shrink: 0;\\n    opacity: 0.7;\\n  }\\n\\n  .support-screenshot-group-label {\\n    font-weight: 600;\\n    font-size: 12px;\\n  }\\n\\n  .support-screenshot-group-badge {\\n    background: rgba(255, 255, 255, 0.15);\\n    padding: 2px 6px;\\n    border-radius: 4px;\\n    font-size: 11px;\\n    font-weight: 600;\\n    margin-left: auto;\\n  }\\n\\n  .support-screenshot-group-summary {\\n    opacity: 0.9;\\n    font-size: 12px;\\n    line-height: 1.4;\\n    margin: 6px 0 8px;\\n    white-space: normal;\\n    overflow-wrap: break-word;\\n    word-break: break-word;\\n  }\\n\\n  .support-screenshot-collage {\\n    height: 120px;\\n    border-radius: 6px;\\n    overflow: hidden;\\n    border: 1px solid rgba(255, 255, 255, 0.1);\\n    display: flex;\\n    gap: 2px;\\n  }\\n\\n  .support-collage-left {\\n    flex: 55;\\n    display: flex;\\n    flex-direction: column;\\n    overflow: hidden;\\n  }\\n\\n  .support-collage-right {\\n    flex: 45;\\n    display: flex;\\n    flex-direction: column;\\n    gap: 2px;\\n  }\\n\\n  .support-collage-img {\\n    flex: 1;\\n    overflow: hidden;\\n    position: relative;\\n    min-height: 0;\\n    background: rgba(0, 0, 0, 0.2);\\n  }\\n\\n  .support-collage-img img {\\n    position: absolute;\\n    inset: 0;\\n    width: 100%;\\n    height: 100%;\\n    object-fit: cover;\\n    display: block;\\n  }\\n\\n  .support-collage-more {\\n    position: absolute;\\n    inset: 0;\\n    background: rgba(0, 0, 0, 0.6);\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    color: white;\\n    font-size: 14px;\\n    font-weight: 600;\\n  }\\n\\n  /* Agent Action Timeline (recorded sessions carry no per-action screenshot) */\\n  .support-message.support-agent-actions-card {\\n    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);\\n    border-radius: 8px;\\n    padding: 10px;\\n    color: white;\\n    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\\n    font-size: 12px;\\n    max-width: 85%;\\n    display: block;\\n  }\\n\\n  .support-agent-actions-header {\\n    display: flex;\\n    align-items: center;\\n    gap: 6px;\\n    width: 100%;\\n    padding: 0;\\n    border: none;\\n    background: none;\\n    color: inherit;\\n    font: inherit;\\n    text-align: left;\\n    cursor: pointer;\\n  }\\n\\n  .support-agent-actions-avatar {\\n    flex-shrink: 0;\\n    opacity: 0.7;\\n  }\\n\\n  .support-agent-actions-title {\\n    font-weight: 600;\\n    font-size: 12px;\\n  }\\n\\n  .support-agent-actions-count {\\n    background: rgba(255, 255, 255, 0.15);\\n    padding: 2px 6px;\\n    border-radius: 4px;\\n    font-size: 11px;\\n    font-weight: 600;\\n    margin-left: auto;\\n  }\\n\\n  .support-agent-actions-chevron {\\n    flex-shrink: 0;\\n    opacity: 0.6;\\n    transition: transform 0.15s ease;\\n  }\\n\\n  .support-agent-actions-card.collapsed .support-agent-actions-chevron {\\n    transform: rotate(-90deg);\\n  }\\n\\n  .support-agent-actions-card.collapsed .support-agent-actions-list {\\n    display: none;\\n  }\\n\\n  .support-agent-actions-list {\\n    list-style: none;\\n    margin: 8px 0 0;\\n    padding: 0;\\n  }\\n\\n  .support-agent-action {\\n    display: flex;\\n    gap: 8px;\\n    position: relative;\\n    padding-bottom: 10px;\\n  }\\n\\n  .support-agent-action:last-child {\\n    padding-bottom: 0;\\n  }\\n\\n  /* Rail between the step markers, stopping at the last one. */\\n  .support-agent-action:not(:last-child)::before {\\n    content: \\'\\';\\n    position: absolute;\\n    left: 10px;\\n    top: 22px;\\n    bottom: 2px;\\n    width: 1px;\\n    background: rgba(255, 255, 255, 0.18);\\n  }\\n\\n  .support-agent-action-icon {\\n    flex-shrink: 0;\\n    width: 21px;\\n    height: 21px;\\n    border-radius: 50%;\\n    background: rgba(255, 255, 255, 0.12);\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    opacity: 0.9;\\n  }\\n\\n  .support-agent-action-text {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 2px;\\n    min-width: 0;\\n    padding-top: 2px;\\n  }\\n\\n  .support-agent-action-headline {\\n    font-size: 12px;\\n    line-height: 1.35;\\n    overflow-wrap: break-word;\\n    word-break: break-word;\\n  }\\n\\n  .support-agent-action-verb {\\n    font-weight: 600;\\n  }\\n\\n  .support-agent-action-target {\\n    opacity: 0.85;\\n  }\\n\\n  .support-agent-action-body {\\n    font-size: 12px;\\n    line-height: 1.4;\\n    opacity: 0.75;\\n    overflow-wrap: break-word;\\n    word-break: break-word;\\n  }\\n\\n  .support-closed-state {\\n    display: flex;\\n    flex-direction: column;\\n    align-items: center;\\n    gap: 12px;\\n    width: 100%;\\n    padding: 8px 0;\\n  }\\n\\n  .support-closed-message {\\n    margin: 0;\\n    font-size: 13px;\\n    color: #6b7280;\\n    text-align: center;\\n    line-height: 1.4;\\n  }\\n\\n  .support-new-conversation-button {\\n    padding: 10px 24px;\\n    background: var(--support-primary-color);\\n    color: var(--support-secondary-color);\\n    border: none;\\n    border-radius: 20px;\\n    font-size: 14px;\\n    font-weight: 500;\\n    cursor: pointer;\\n    transition: all 0.2s ease;\\n    font-family: inherit;\\n    white-space: nowrap;\\n  }\\n\\n  .support-new-conversation-button:hover {\\n    opacity: 0.9;\\n    transform: translateY(-1px);\\n    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);\\n  }\\n\\n  .support-new-conversation-button:active {\\n    transform: translateY(0);\\n  }\\n\\n  .support-next-step-state {\\n    display: flex;\\n    justify-content: center;\\n    width: 100%;\\n    padding: 8px 0;\\n  }\\n\\n  .support-next-step-button {\\n    animation: support-next-step-pulse 1.8s ease-in-out infinite;\\n  }\\n\\n  @keyframes support-next-step-pulse {\\n    0%, 100% {\\n      box-shadow: 0 0 0 0 rgba(var(--support-primary-rgb), 0.55);\\n    }\\n    50% {\\n      box-shadow: 0 0 0 10px rgba(var(--support-primary-rgb), 0);\\n    }\\n  }\\n\\n  @media (prefers-reduced-motion: reduce) {\\n    .support-next-step-button { animation: none; }\\n  }\\n\\n  /* Toast Notification — slides up from behind the input footer */\\n  .support-toast {\\n    position: absolute;\\n    left: 50%;\\n    bottom: 76px;\\n    transform: translate(-50%, 80px);\\n    background: #1f2937;\\n    color: white;\\n    padding: 10px 16px;\\n    border-radius: 8px;\\n    font-size: 13px;\\n    font-weight: 500;\\n    line-height: 1.4;\\n    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);\\n    z-index: 1;\\n    visibility: hidden;\\n    transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1), visibility 0s linear 0.35s;\\n    pointer-events: none;\\n    width: max-content;\\n    max-width: calc(100% - 24px);\\n    text-align: center;\\n    white-space: normal;\\n    overflow-wrap: break-word;\\n    word-break: break-word;\\n  }\\n\\n  .support-toast.show {\\n    transform: translate(-50%, 0);\\n    /* inherit, not visible: a toast must not show through a closed chat window. */\\n    visibility: inherit;\\n    pointer-events: auto;\\n    transition: transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1), visibility 0s linear 0s;\\n  }\\n\\n  .support-toast.success {\\n    background: #10b981;\\n  }\\n\\n  .support-toast.error {\\n    background: #ef4444;\\n  }\\n\\n  .support-toast.info {\\n    background: var(--support-primary-color);\\n  }\\n\\n  /* Corner surface, used while the chat window is closed — the whole of a call. Beside the\\n     launcher, lifted above the topmost call surface by --support-toast-offset (set per toast). */\\n  .support-toast--corner {\\n    left: auto;\\n    right: 0;\\n    bottom: var(--support-toast-offset, 76px);\\n    transform: translate(0, 12px);\\n    max-width: calc(100vw - 40px);\\n  }\\n\\n  .support-toast--corner.show {\\n    transform: translate(0, 0);\\n  }\\n\\n  .position-bottom-left .support-toast--corner,\\n  .position-top-left .support-toast--corner {\\n    right: auto;\\n    left: 0;\\n  }\\n\\n  .position-top-right .support-toast--corner,\\n  .position-top-left .support-toast--corner {\\n    bottom: auto;\\n    top: var(--support-toast-offset, 76px);\\n    transform: translate(0, -12px);\\n  }\\n\\n  .position-top-right .support-toast--corner.show,\\n  .position-top-left .support-toast--corner.show {\\n    transform: translate(0, 0);\\n  }\\n\\n  /* === Attachment Styles === */\\n\\n  /* Attachment button in input */\\n  .support-attach-btn {\\n    background: none;\\n    border: none;\\n    padding: 8px;\\n    cursor: pointer;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    color: #666;\\n    transition: all 0.2s ease;\\n    margin-right: 4px;\\n  }\\n\\n  .support-attach-btn:hover {\\n    color: black;\\n    transform: scale(1.1);\\n  }\\n\\n  .support-attach-btn:disabled {\\n    opacity: 0.5;\\n    cursor: not-allowed;\\n  }\\n\\n  .support-attach-btn svg {\\n    width: 20px;\\n    height: 20px;\\n    fill: currentColor;\\n  }\\n\\n  /* The message the next send will quote */\\n  .support-reply-preview {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n    padding: 8px 16px;\\n    border-top: 1px solid var(--support-gray-border);\\n    background: var(--support-gray-light);\\n  }\\n\\n  .support-reply-preview.hidden {\\n    display: none;\\n  }\\n\\n  .support-reply-preview-body {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 2px;\\n    min-width: 0;\\n    flex: 1;\\n    border-left: 3px solid var(--support-primary-color);\\n    padding-left: 8px;\\n  }\\n\\n  .support-reply-preview-label {\\n    font-size: 11px;\\n    font-weight: 600;\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-reply-preview-text {\\n    font-size: 12px;\\n    color: var(--widget-text-muted);\\n    white-space: nowrap;\\n    overflow: hidden;\\n    text-overflow: ellipsis;\\n  }\\n\\n  .support-reply-preview-cancel {\\n    flex-shrink: 0;\\n    width: 24px;\\n    height: 24px;\\n    padding: 0;\\n    border: none;\\n    border-radius: 50%;\\n    background: transparent;\\n    cursor: pointer;\\n  }\\n\\n  .support-reply-preview-cancel svg {\\n    width: 16px;\\n    height: 16px;\\n    fill: var(--widget-text-muted);\\n  }\\n\\n  /* Attachment preview in footer */\\n  .support-attachment-preview {\\n    padding: 12px 16px;\\n    border-top: 1px solid var(--support-gray-border);\\n    background: var(--support-gray-light);\\n    display: flex;\\n    flex-direction: column;\\n    gap: 8px;\\n    max-height: 150px;\\n    overflow-y: auto;\\n  }\\n\\n  .support-attachment-preview.hidden {\\n    display: none;\\n  }\\n\\n  .support-preview-item {\\n    display: flex;\\n    align-items: center;\\n    gap: 10px;\\n    padding: 8px;\\n    background: white;\\n    border-radius: 6px;\\n    border: 1px solid var(--support-gray-border);\\n  }\\n\\n  .support-preview-thumbnail {\\n    width: 40px;\\n    height: 40px;\\n    flex-shrink: 0;\\n    border-radius: 4px;\\n    overflow: hidden;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    background: var(--support-gray-light);\\n  }\\n\\n  .support-preview-image {\\n    width: 100%;\\n    height: 100%;\\n    object-fit: cover;\\n  }\\n\\n  .support-preview-icon {\\n    width: 24px;\\n    height: 24px;\\n    fill: #666;\\n  }\\n\\n  .support-preview-info {\\n    flex: 1;\\n    min-width: 0;\\n    display: flex;\\n    flex-direction: column;\\n    gap: 2px;\\n  }\\n\\n  .support-preview-name {\\n    font-size: 13px;\\n    color: #333;\\n    white-space: nowrap;\\n    overflow: hidden;\\n    text-overflow: ellipsis;\\n    cursor: help;\\n  }\\n\\n  .support-preview-size {\\n    font-size: 11px;\\n    color: #666;\\n  }\\n\\n  .support-preview-remove {\\n    background: none;\\n    border: none;\\n    padding: 4px;\\n    cursor: pointer;\\n    color: #999;\\n    transition: color 0.2s ease;\\n    flex-shrink: 0;\\n  }\\n\\n  .support-preview-remove:hover {\\n    color: #ef4444;\\n  }\\n\\n  .support-preview-remove svg {\\n    width: 16px;\\n    height: 16px;\\n    fill: currentColor;\\n  }\\n\\n  /* Attachments in messages */\\n  .support-attachments {\\n    margin-top: 8px;\\n    display: flex;\\n    flex-direction: column;\\n    gap: 8px;\\n    max-width: 100%;\\n    overflow: hidden;\\n  }\\n\\n  .support-attachment-card {\\n    border-radius: 8px;\\n    overflow: hidden;\\n    border: 1px solid var(--support-gray-border);\\n    background: white;\\n    max-width: 100%;\\n  }\\n\\n  /* User attachments match the user message bubble color */\\n  .support-message.user .support-attachment-card {\\n    background: var(--support-primary-color);\\n    border: 1px solid var(--support-primary-color);\\n  }\\n\\n  /* Agent attachments stay white */\\n  .support-message.agent .support-attachment-card {\\n    border: 1px solid var(--support-gray-border);\\n    background: white;\\n  }\\n\\n  .support-attachment-card.image img {\\n    width: 100%;\\n    max-height: 300px;\\n    object-fit: contain;\\n    display: block;\\n    cursor: pointer;\\n  }\\n\\n  .support-attachment-card.video video {\\n    width: 100%;\\n    max-height: 300px;\\n    display: block;\\n  }\\n\\n  .support-attachment-card.audio {\\n    display: flex;\\n    flex-direction: column;\\n  }\\n\\n  .support-attachment-card.audio audio {\\n    width: 100%;\\n    display: block;\\n    border-radius: 8px 8px 0 0;\\n  }\\n\\n  /* Audio/Video attachment info should have white background */\\n  .support-attachment-card.audio .support-attachment-info,\\n  .support-attachment-card.video .support-attachment-info {\\n    background: white;\\n    padding: 8px 12px;\\n    border-radius: 0 0 8px 8px;\\n  }\\n\\n  .support-message.user .support-attachment-card.audio .support-attachment-info,\\n  .support-message.user .support-attachment-card.video .support-attachment-info {\\n    background: white;\\n  }\\n\\n  .support-message.user .support-attachment-card.audio .support-attachment-name,\\n  .support-message.user .support-attachment-card.video .support-attachment-name {\\n    color: #333;\\n  }\\n\\n  .support-message.user .support-attachment-card.audio .support-attachment-size,\\n  .support-message.user .support-attachment-card.video .support-attachment-size {\\n    color: #666;\\n  }\\n\\n  /* === Voice note player === */\\n  /* The card is the message bubble: agent notes take the agent bubble surface,\\n     contact notes take the brand bubble with every inner color derived from the\\n     bubble\\'s own contrast color. */\\n  .support-voice-note {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 6px;\\n    min-width: 210px;\\n    max-width: 100%;\\n    padding: 12px 14px;\\n    border-radius: 8px;\\n    background: var(--widget-agent-bubble-bg);\\n    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);\\n    box-sizing: border-box;\\n  }\\n\\n  .support-message.user .support-voice-note {\\n    background: var(--widget-user-bubble-bg);\\n  }\\n\\n  .support-voice-top {\\n    display: flex;\\n    align-items: center;\\n    gap: 10px;\\n  }\\n\\n  .support-voice-play {\\n    width: 32px;\\n    height: 32px;\\n    border-radius: 50%;\\n    background: var(--support-primary-color);\\n    color: var(--support-secondary-color);\\n    border: none;\\n    cursor: pointer;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    flex-shrink: 0;\\n    transition: transform 0.12s ease, filter 0.15s ease;\\n  }\\n\\n  .support-voice-play:hover {\\n    filter: brightness(1.1);\\n  }\\n\\n  .support-voice-play:active {\\n    transform: scale(0.9);\\n  }\\n\\n  .support-voice-play:focus-visible,\\n  .support-voice-speed:focus-visible {\\n    outline: 2px solid currentColor;\\n    outline-offset: 2px;\\n  }\\n\\n  .support-message.user .support-voice-play {\\n    background: var(--widget-user-bubble-fg);\\n    color: var(--widget-user-bubble-bg);\\n  }\\n\\n  .support-message.user .support-voice-play:hover {\\n    filter: brightness(0.94);\\n  }\\n\\n  .support-voice-play svg {\\n    width: 14px;\\n    height: 14px;\\n    fill: currentColor;\\n  }\\n\\n  .support-voice-wave {\\n    display: flex;\\n    align-items: center;\\n    gap: 2px;\\n    flex: 1;\\n    min-width: 0;\\n    height: 26px;\\n    overflow: hidden;\\n    cursor: pointer;\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-voice-wave i {\\n    display: block;\\n    flex: 1 1 0;\\n    min-width: 2px;\\n    max-width: 3px;\\n    height: 100%;\\n    border-radius: 2px;\\n    background: currentColor;\\n    opacity: 0.25;\\n    transform: scaleY(0.14);\\n    transform-origin: center;\\n    transition: opacity 0.1s linear;\\n  }\\n\\n  .support-voice-wave i.is-on {\\n    opacity: 0.95;\\n  }\\n\\n  .support-message.user .support-voice-wave {\\n    color: var(--widget-user-bubble-fg);\\n  }\\n\\n  .support-message.user .support-voice-wave i {\\n    opacity: 0.4;\\n  }\\n\\n  .support-message.user .support-voice-wave i.is-on {\\n    opacity: 1;\\n  }\\n\\n  .support-voice-speed {\\n    flex-shrink: 0;\\n    border: none;\\n    cursor: pointer;\\n    border-radius: 999px;\\n    padding: 2px 8px;\\n    font-size: 10px;\\n    font-weight: 700;\\n    font-family: inherit;\\n    background: rgba(107, 114, 128, 0.14);\\n    color: var(--widget-text-muted);\\n    transition: color 0.15s ease, background 0.15s ease;\\n  }\\n\\n  .support-voice-speed:hover {\\n    color: var(--widget-agent-bubble-fg);\\n  }\\n\\n  .support-message.user .support-voice-speed {\\n    background: rgba(0, 0, 0, 0.16);\\n    color: var(--widget-user-bubble-fg);\\n  }\\n\\n  .support-message.user .support-voice-speed:hover {\\n    background: rgba(0, 0, 0, 0.26);\\n    color: var(--widget-user-bubble-fg);\\n  }\\n\\n  .support-voice-foot {\\n    display: flex;\\n    align-items: center;\\n    justify-content: space-between;\\n    gap: 8px;\\n    font-size: 10px;\\n    color: var(--widget-text-muted);\\n    font-variant-numeric: tabular-nums;\\n  }\\n\\n  .support-message.user .support-voice-foot {\\n    color: var(--widget-user-bubble-fg);\\n    opacity: 0.9;\\n  }\\n\\n  .support-voice-label {\\n    display: inline-flex;\\n    align-items: center;\\n    gap: 4px;\\n  }\\n\\n  .support-voice-label svg {\\n    width: 11px;\\n    height: 11px;\\n    fill: currentColor;\\n  }\\n\\n  .support-attachment-card.file {\\n    padding: 0;\\n  }\\n\\n  .support-attachment-link {\\n    display: flex;\\n    align-items: center;\\n    gap: 12px;\\n    padding: 12px;\\n    text-decoration: none;\\n    color: inherit;\\n    transition: background 0.2s ease;\\n    max-width: 100%;\\n    overflow: hidden;\\n  }\\n\\n  .support-attachment-link:hover {\\n    background: var(--support-gray-light);\\n  }\\n\\n  .support-message.user .support-attachment-link:hover {\\n    background: rgba(0, 0, 0, 0.1);\\n  }\\n\\n  .support-file-icon {\\n    width: 32px;\\n    height: 32px;\\n    fill: var(--support-primary-color);\\n    flex-shrink: 0;\\n  }\\n\\n  .support-message.user .support-file-icon {\\n    fill: var(--support-secondary-color);\\n  }\\n\\n  .support-attachment-info {\\n    flex: 1;\\n    min-width: 0;\\n    display: flex;\\n    flex-direction: column;\\n    gap: 2px;\\n    padding: 4px 8px;\\n    overflow: hidden;\\n  }\\n\\n  .support-attachment-name {\\n    font-size: 13px;\\n    font-weight: 500;\\n    color: #333;\\n    white-space: nowrap;\\n    overflow: hidden;\\n    text-overflow: ellipsis;\\n    max-width: 100%;\\n    word-break: break-all;\\n    cursor: help;\\n  }\\n\\n  .support-message.user .support-attachment-name {\\n    color: var(--support-secondary-color);\\n  }\\n\\n  .support-attachment-size {\\n    font-size: 11px;\\n    color: #666;\\n    white-space: nowrap;\\n  }\\n\\n  .support-message.user .support-attachment-size {\\n    color: var(--support-secondary-color);\\n    opacity: 0.85;\\n  }\\n\\n  /* Message wrapper for attachments */\\n  .support-message-wrapper {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 4px;\\n    max-width: min(var(--widget-bubble-max-agent), var(--widget-bubble-max-line));\\n    overflow: hidden;\\n  }\\n\\n  .support-message.user .support-message-wrapper {\\n    max-width: min(var(--widget-bubble-max-user), var(--widget-bubble-max-line));\\n  }\\n\\n  /* Uploading state */\\n  .support-send-btn.uploading {\\n    opacity: 0.6;\\n    cursor: wait;\\n  }\\n\\n  .support-send-btn.uploading svg {\\n    animation: spin 1s linear infinite;\\n  }\\n\\n  @keyframes spin {\\n    from { transform: rotate(0deg); }\\n    to { transform: rotate(360deg); }\\n  }\\n\\n  /* Attachment loading state */\\n  .support-attachment-loading {\\n    padding: 40px 20px;\\n    text-align: center;\\n    color: #666;\\n    font-size: 13px;\\n    background: var(--support-gray-light);\\n  }\\n\\n  .support-attachment-loading.error {\\n    color: #ef4444;\\n  }\\n\\n  /* ============ Side Panel Mode Overrides ============ */\\n  .side-panel-mode .support-chat-window {\\n    position: fixed;\\n    top: 0;\\n    right: 0;\\n    height: var(--widget-viewport-height);\\n    width: min(420px, 100vw);\\n    border-radius: 0;\\n    overflow: hidden;\\n    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);\\n    max-height: var(--widget-viewport-height);\\n    bottom: auto;\\n    transform: translateX(100%);\\n    opacity: 1;\\n    pointer-events: none;\\n    transition: transform 0.3s ease, visibility 0s linear 0.3s;\\n  }\\n\\n  .side-panel-mode .support-chat-window.open {\\n    transform: translateX(0);\\n    pointer-events: all;\\n    transition-delay: 0s;\\n  }\\n\\n  .side-panel-mode.side-left .support-chat-window {\\n    left: 0;\\n    right: auto;\\n    transform: translateX(-100%);\\n    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);\\n    border-radius: 0;\\n  }\\n\\n  .side-panel-mode.side-left .support-chat-window.open {\\n    transform: translateX(0);\\n  }\\n\\n  .side-panel-mode .support-chat-header {\\n    border-radius: 0;\\n  }\\n\\n  .side-panel-mode .support-expand-toggle {\\n    display: none;\\n  }\\n\\n  /* Pre-chat form styles */\\n  .support-prechat-form-container {\\n    display: flex;\\n    flex-direction: column;\\n    padding: 12px;\\n    height: 100%;\\n    box-sizing: border-box;\\n  }\\n\\n  .support-prechat-form-header {\\n    text-align: center;\\n    margin-bottom: 8px;\\n  }\\n\\n  .support-prechat-title {\\n    font-size: 15px;\\n    font-weight: 600;\\n    color: var(--widget-text);\\n    margin: 0 0 2px 0;\\n  }\\n\\n  .support-prechat-subtitle {\\n    font-size: 12px;\\n    color: var(--widget-text-muted);\\n    margin: 0;\\n  }\\n\\n  .support-prechat-form {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 6px;\\n  }\\n\\n  .support-prechat-field {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 2px;\\n  }\\n\\n  .support-prechat-field label {\\n    font-size: 12px;\\n    font-weight: 500;\\n    color: #374151;\\n  }\\n\\n  .support-prechat-field label .required-indicator {\\n    color: #ef4444;\\n    margin-left: 2px;\\n  }\\n\\n  .support-prechat-field input {\\n    padding: 8px;\\n    border: 1px solid var(--widget-border);\\n    border-radius: 6px;\\n    font-size: 13px;\\n    transition: border-color 0.2s, box-shadow 0.2s;\\n    outline: none;\\n    font-family: inherit;\\n  }\\n\\n  .support-prechat-field input:focus {\\n    border-color: var(--support-primary-color);\\n    box-shadow: 0 0 0 3px rgba(var(--support-primary-rgb), 0.1);\\n  }\\n\\n  .support-prechat-field input.error {\\n    border-color: #ef4444;\\n  }\\n\\n  .support-prechat-field input.error:focus {\\n    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);\\n  }\\n\\n  .support-prechat-error {\\n    font-size: 11px;\\n    color: #ef4444;\\n    min-height: 0;\\n  }\\n\\n  .support-prechat-submit {\\n    background: var(--support-primary-color);\\n    color: var(--support-secondary-color);\\n    border: none;\\n    padding: 10px;\\n    border-radius: 6px;\\n    font-size: 14px;\\n    font-weight: 600;\\n    cursor: pointer;\\n    transition: opacity 0.2s;\\n    margin-top: 4px;\\n    font-family: inherit;\\n  }\\n\\n  .support-prechat-submit:hover:not(:disabled) {\\n    opacity: 0.9;\\n  }\\n\\n  .support-prechat-submit:disabled {\\n    opacity: 0.6;\\n    cursor: not-allowed;\\n  }\\n\\n  .support-prechat-submit.loading {\\n    position: relative;\\n  }\\n\\n  /* ============ Conversation Selector ============ */\\n  .support-conversation-selector {\\n    display: flex;\\n    align-items: stretch;\\n    height: 36px;\\n    border-bottom: 1px solid var(--widget-border);\\n    background: var(--widget-bg);\\n    flex-shrink: 0;\\n  }\\n\\n  .support-conversation-tab {\\n    flex: 1;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    gap: 6px;\\n    padding: 0 12px;\\n    border: none;\\n    background: transparent;\\n    cursor: pointer;\\n    font-family: inherit;\\n    font-size: 12px;\\n    font-weight: 500;\\n    color: var(--widget-text-muted);\\n    position: relative;\\n    transition: color 0.2s ease, background 0.2s ease;\\n  }\\n\\n  .support-conversation-tab:hover {\\n    color: #374151;\\n    background: rgba(0, 0, 0, 0.03);\\n  }\\n\\n  .support-conversation-tab.active {\\n    color: var(--support-primary-color);\\n    font-weight: 600;\\n  }\\n\\n  .support-conversation-tab.active::after {\\n    content: \\'\\';\\n    position: absolute;\\n    bottom: 0;\\n    left: 8px;\\n    right: 8px;\\n    height: 2px;\\n    background: var(--support-primary-color);\\n    border-radius: 2px 2px 0 0;\\n  }\\n\\n  .support-conversation-tab svg {\\n    width: 14px;\\n    height: 14px;\\n    fill: currentColor;\\n    flex-shrink: 0;\\n  }\\n\\n  .support-conversation-tab-avatar {\\n    width: 20px;\\n    height: 20px;\\n    border-radius: 50%;\\n    background: var(--support-primary-color);\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    flex-shrink: 0;\\n  }\\n\\n  .support-conversation-tab-avatar svg {\\n    width: 12px;\\n    height: 12px;\\n    fill: none;\\n    stroke: white;\\n  }\\n\\n  .support-conversation-tab-badge {\\n    min-width: 16px;\\n    height: 16px;\\n    background: #ef4444;\\n    border-radius: 8px;\\n    font-size: 10px;\\n    font-weight: 700;\\n    color: white;\\n    display: inline-flex;\\n    align-items: center;\\n    justify-content: center;\\n    padding: 0 4px;\\n    margin-left: 4px;\\n    line-height: 1;\\n    box-sizing: border-box;\\n  }\\n\\n  .support-conversation-tab-badge.hidden {\\n    display: none;\\n  }\\n\\n  .support-conversation-selector.hidden {\\n    display: none;\\n  }\\n\\n  /* Conversation Picker (full-body selection screen) */\\n  .support-conversation-picker {\\n    display: flex;\\n    flex-direction: column;\\n    align-items: center;\\n    justify-content: center;\\n    padding: 32px 24px;\\n    gap: 16px;\\n    height: 100%;\\n    box-sizing: border-box;\\n  }\\n\\n  .support-conversation-picker-title {\\n    font-size: 16px;\\n    font-weight: 600;\\n    color: #374151;\\n    text-align: center;\\n    margin: 0 0 8px 0;\\n  }\\n\\n  .support-conversation-picker-card {\\n    display: flex;\\n    align-items: center;\\n    gap: 14px;\\n    width: 100%;\\n    max-width: 280px;\\n    padding: 16px 20px;\\n    background: var(--widget-surface);\\n    border: 1px solid var(--widget-border);\\n    border-radius: 12px;\\n    cursor: pointer;\\n    transition: all 0.2s ease;\\n    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);\\n  }\\n\\n  .support-conversation-picker-card:hover {\\n    border-color: var(--support-primary-color);\\n    box-shadow: 0 4px 12px rgba(var(--support-primary-rgb), 0.15);\\n    transform: translateY(-2px);\\n  }\\n\\n  .support-conversation-picker-icon {\\n    width: 40px;\\n    height: 40px;\\n    border-radius: 50%;\\n    background: rgba(var(--support-primary-rgb), 0.1);\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    flex-shrink: 0;\\n  }\\n\\n  .support-conversation-picker-icon svg {\\n    width: 22px;\\n    height: 22px;\\n  }\\n\\n  .support-conversation-picker-icon.ai svg {\\n    fill: none;\\n    stroke: var(--support-primary-color);\\n  }\\n\\n  .support-conversation-picker-icon.human svg {\\n    fill: var(--support-primary-color);\\n  }\\n\\n  .support-conversation-picker-text {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 2px;\\n  }\\n\\n  .support-conversation-picker-label {\\n    font-size: 14px;\\n    font-weight: 600;\\n    color: var(--widget-text);\\n  }\\n\\n  .support-conversation-picker-desc {\\n    font-size: 12px;\\n    color: var(--widget-text-muted);\\n  }\\n\\n  .support-readonly-banner {\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    gap: 8px;\\n    padding: 12px 16px;\\n    background: var(--widget-surface-hover);\\n    color: var(--widget-text-muted);\\n    font-size: 13px;\\n    font-weight: 500;\\n    border-radius: 8px;\\n  }\\n\\n  .support-readonly-banner svg {\\n    width: 16px;\\n    height: 16px;\\n    fill: #9ca3af;\\n    flex-shrink: 0;\\n  }\\n\\n  /* Archive / New Conversation button in header */\\n  .support-archive-btn {\\n    background: none;\\n    border: none;\\n    cursor: pointer;\\n    padding: 6px;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    border-radius: 6px;\\n    transition: all 0.2s ease;\\n    position: relative;\\n    color: var(--support-secondary-color);\\n    opacity: 0.8;\\n  }\\n\\n  .support-archive-btn:hover {\\n    opacity: 1;\\n    background: rgba(255, 255, 255, 0.15);\\n  }\\n\\n  .support-archive-btn svg {\\n    width: 18px;\\n    height: 18px;\\n    fill: currentColor;\\n  }\\n\\n  .support-archive-btn[data-tooltip]:hover::after {\\n    content: attr(data-tooltip);\\n    position: absolute;\\n    bottom: -28px;\\n    left: 50%;\\n    transform: translateX(-50%);\\n    background: rgba(0, 0, 0, 0.8);\\n    color: white;\\n    padding: 4px 8px;\\n    border-radius: 4px;\\n    font-size: 11px;\\n    white-space: nowrap;\\n    z-index: 10;\\n  }\\n\\n  /* ============ Chat Loading Bar ============ */\\n  .support-chat-loading {\\n    position: relative;\\n    height: 3px;\\n    flex-shrink: 0;\\n    background: rgba(var(--support-primary-rgb), 0.2);\\n    overflow: hidden;\\n  }\\n\\n  .support-chat-loading::after {\\n    content: \\'\\';\\n    position: absolute;\\n    top: 0;\\n    left: 0;\\n    height: 100%;\\n    width: 40%;\\n    background: var(--support-primary-color);\\n    animation: chat-loading 1s ease-in-out infinite;\\n  }\\n\\n  @keyframes chat-loading {\\n    0% { left: -40%; }\\n    100% { left: 100%; }\\n  }\\n\\n  /* ============ History Panel Overlay ============ */\\n  .support-chat-body.history-blur,\\n  .support-chat-footer.history-blur {\\n    filter: blur(4px);\\n    pointer-events: none;\\n  }\\n\\n  .support-history-backdrop {\\n    position: absolute;\\n    top: 0;\\n    left: 0;\\n    right: 0;\\n    bottom: 0;\\n    background: rgba(0, 0, 0, 0.3);\\n    z-index: 100;\\n    cursor: pointer;\\n  }\\n\\n  .support-agent-mode-overlay {\\n    position: absolute;\\n    top: 50%;\\n    left: 50%;\\n    transform: translate(-50%, -50%);\\n    z-index: 101;\\n    background: rgba(255, 255, 255, 0.85);\\n    backdrop-filter: blur(8px);\\n    color: #1f2937;\\n    font-size: 14px;\\n    font-weight: 500;\\n    padding: 14px 24px;\\n    border-radius: 10px;\\n    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);\\n    text-align: center;\\n    height: auto;\\n    width: auto;\\n  }\\n\\n  /* Feature awareness nudge bubble */\\n  .support-awareness-bubble {\\n    position: absolute;\\n    bottom: 70px;\\n    right: 0;\\n    max-width: 340px;\\n    width: max-content;\\n    background: var(--support-white);\\n    border-radius: 12px;\\n    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);\\n    padding: 12px 16px;\\n    cursor: pointer;\\n    display: flex;\\n    align-items: center;\\n    gap: 12px;\\n    animation: awarenessSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\\n    pointer-events: auto;\\n    transition: box-shadow 0.2s ease;\\n  }\\n\\n  .support-awareness-bubble:hover {\\n    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.18);\\n  }\\n\\n  .position-bottom-left .support-awareness-bubble {\\n    right: auto;\\n    left: 0;\\n  }\\n\\n  .position-top-right .support-awareness-bubble {\\n    bottom: auto;\\n    top: 70px;\\n  }\\n\\n  .position-top-left .support-awareness-bubble {\\n    bottom: auto;\\n    top: 70px;\\n    right: auto;\\n    left: 0;\\n  }\\n\\n  .support-awareness-bubble::after {\\n    content: \\'\\';\\n    position: absolute;\\n    bottom: -6px;\\n    right: 22px;\\n    width: 12px;\\n    height: 12px;\\n    background: var(--support-white);\\n    transform: rotate(45deg);\\n    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.05);\\n  }\\n\\n  .position-bottom-left .support-awareness-bubble::after {\\n    right: auto;\\n    left: 22px;\\n  }\\n\\n  .position-top-right .support-awareness-bubble::after,\\n  .position-top-left .support-awareness-bubble::after {\\n    bottom: auto;\\n    top: -6px;\\n    box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.05);\\n  }\\n\\n  /* Anchored to a host-page element (custom trigger button). top/left are set\\n     inline from the anchor\\'s rect; the arrow is recentred via --awareness-arrow-x. */\\n  .support-awareness-bubble.support-awareness-bubble--anchored {\\n    position: fixed;\\n    top: auto;\\n    left: auto;\\n    bottom: auto;\\n    right: auto;\\n  }\\n\\n  .support-awareness-bubble.support-awareness-bubble--anchored::after {\\n    left: var(--awareness-arrow-x, 22px);\\n    right: auto;\\n    margin-left: -6px;\\n  }\\n\\n  /* Nudge sits BELOW the anchor → arrow on its top edge, pointing up. */\\n  .support-awareness-bubble.support-awareness-bubble--below::after {\\n    top: -6px;\\n    bottom: auto;\\n    box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.05);\\n  }\\n\\n  /* Nudge sits ABOVE the anchor → arrow on its bottom edge, pointing down. */\\n  .support-awareness-bubble.support-awareness-bubble--above::after {\\n    bottom: -6px;\\n    top: auto;\\n    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.05);\\n  }\\n\\n  /* Fallback when the widget is hidden and there\\'s no anchor: plain bottom-right\\n     toast, no pointer. */\\n  .support-awareness-bubble.support-awareness-bubble--toast {\\n    position: fixed;\\n    bottom: 20px;\\n    right: 20px;\\n    top: auto;\\n    left: auto;\\n  }\\n\\n  .support-awareness-bubble.support-awareness-bubble--toast::after {\\n    display: none;\\n  }\\n\\n  .support-awareness-dismiss {\\n    flex-shrink: 0;\\n    width: 28px;\\n    height: 28px;\\n    background: none;\\n    border: none;\\n    border-radius: 6px;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    cursor: pointer;\\n    color: #9ca3af;\\n    font-size: 14px;\\n    line-height: 1;\\n    padding: 0;\\n    transition: background 0.2s ease, color 0.2s ease;\\n  }\\n\\n  .support-awareness-dismiss:hover {\\n    color: #4b5563;\\n    background: rgba(0, 0, 0, 0.05);\\n  }\\n\\n  /* When awareness bubble is visible, hide widget bubble\\'s own close button */\\n  .has-awareness-nudge .support-bubble .support-bubble-close {\\n    display: none;\\n  }\\n\\n  .support-awareness-message {\\n    font-size: 14px;\\n    line-height: 1.5;\\n    color: #1f2937;\\n    word-wrap: break-word;\\n  }\\n\\n  @keyframes awarenessSlideIn {\\n    from {\\n      opacity: 0;\\n      transform: translateY(8px);\\n    }\\n    to {\\n      opacity: 1;\\n      transform: translateY(0);\\n    }\\n  }\\n\\n  /* ── Rich activation nudge card (progress + sender + message + CTA) ── */\\n  .support-awareness-bubble.support-nudge-card {\\n    flex-direction: column;\\n    align-items: stretch;\\n    gap: 12px;\\n    width: 320px;\\n    max-width: min(320px, calc(100vw - 32px));\\n    padding: 16px;\\n    background: #ffffff;\\n    border: 1px solid rgba(var(--support-primary-rgb), 0.28);\\n    border-radius: 16px;\\n    box-shadow: 0 12px 40px rgba(18, 28, 53, 0.14);\\n  }\\n\\n  /* No speech-bubble tail on the rich card. */\\n  .support-awareness-bubble.support-nudge-card::after {\\n    display: none;\\n  }\\n\\n  .support-nudge-progress {\\n    display: flex;\\n    gap: 6px;\\n  }\\n\\n  .support-nudge-progress-seg {\\n    flex: 1;\\n    height: 4px;\\n    border-radius: 999px;\\n    background: rgba(18, 28, 53, 0.12);\\n  }\\n\\n  .support-nudge-progress-seg.is-done {\\n    background: var(--support-primary-color);\\n  }\\n\\n  .support-nudge-header {\\n    display: flex;\\n    align-items: center;\\n    gap: 12px;\\n  }\\n\\n  .support-nudge-avatar {\\n    flex-shrink: 0;\\n    width: 44px;\\n    height: 44px;\\n    border-radius: 50%;\\n    background: var(--support-primary-color);\\n    color: #fff;\\n    font-size: 15px;\\n    font-weight: 600;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    overflow: hidden;\\n  }\\n\\n  .support-nudge-avatar img {\\n    width: 100%;\\n    height: 100%;\\n    object-fit: cover;\\n  }\\n\\n  /* Built-in Blar-robot fallback (reuses the AI-avatar bot icon). */\\n  .support-nudge-avatar svg {\\n    width: 26px;\\n    height: 26px;\\n  }\\n\\n  .support-nudge-who {\\n    flex: 1;\\n    min-width: 0;\\n    font-size: 14px;\\n    line-height: 1.3;\\n    white-space: nowrap;\\n    overflow: hidden;\\n    text-overflow: ellipsis;\\n  }\\n\\n  .support-nudge-name {\\n    color: #16203a;\\n    font-weight: 600;\\n  }\\n\\n  .support-nudge-subtitle {\\n    color: rgba(22, 32, 58, 0.55);\\n  }\\n\\n  .support-nudge-subtitle::before {\\n    content: \\' · \\';\\n  }\\n\\n  .support-nudge-card .support-awareness-dismiss {\\n    align-self: flex-start;\\n    color: rgba(22, 32, 58, 0.45);\\n  }\\n\\n  .support-nudge-card .support-awareness-dismiss:hover {\\n    color: #16203a;\\n    background: rgba(22, 32, 58, 0.08);\\n  }\\n\\n  .support-nudge-message {\\n    margin: 0;\\n    color: #16203a;\\n    font-size: 17px;\\n    font-weight: 600;\\n    line-height: 1.35;\\n    word-wrap: break-word;\\n  }\\n\\n  .support-nudge-cta {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n    color: var(--support-primary-color);\\n    font-size: 14px;\\n    font-weight: 600;\\n  }\\n\\n  .support-nudge-cta-icon,\\n  .support-nudge-cta-arrow {\\n    display: inline-flex;\\n    align-items: center;\\n  }\\n\\n  .support-nudge-cta-arrow {\\n    margin-left: auto;\\n    transition: transform 0.15s ease;\\n  }\\n\\n  .support-awareness-bubble.support-nudge-card:hover .support-nudge-cta-arrow {\\n    transform: translateX(3px);\\n  }\\n\\n  /* A confirm card answers through its buttons, so the card is not a target. */\\n  .support-nudge-card--confirm {\\n    cursor: default;\\n  }\\n\\n  /* Confirm row (Yes / No / Later), rendered with the card so accepting is a\\n     single tap. */\\n  .support-nudge-confirm {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 10px;\\n  }\\n\\n  .support-nudge-confirm-prompt {\\n    margin: 0;\\n    color: rgba(22, 32, 58, 0.7);\\n    font-size: 14px;\\n    font-weight: 500;\\n    line-height: 1.35;\\n  }\\n\\n  /* Pills reuse the interactive-button styling; accept takes the extra width so\\n     the one-tap path is the obvious one. Labels never break mid-word — a long\\n     translation wraps the row instead. */\\n  .support-nudge-confirm .support-interactive-button.pill {\\n    flex: 1;\\n    min-height: 40px;\\n    padding: 9px 12px;\\n    text-align: center;\\n    white-space: nowrap;\\n  }\\n\\n  .support-nudge-confirm .support-interactive-button.pill.primary {\\n    flex: 1.5;\\n  }\\n\\n  /* Decline / later stay quiet beside accept, keeping their label above the\\n     4.5:1 contrast floor. */\\n  .support-nudge-confirm .support-interactive-button.pill:not(.primary) {\\n    background: transparent;\\n    border-color: rgba(22, 32, 58, 0.18);\\n    color: rgba(22, 32, 58, 0.7);\\n  }\\n\\n  .support-nudge-confirm .support-interactive-button.pill:not(.primary):hover:not(:disabled) {\\n    background: rgba(22, 32, 58, 0.06);\\n    border-color: rgba(22, 32, 58, 0.32);\\n    color: #16203a;\\n  }\\n\\n  .support-nudge-confirm .support-interactive-button.pill:focus-visible {\\n    outline: 2px solid var(--support-primary-color);\\n    outline-offset: 2px;\\n  }\\n\\n  /* ── Dark color scheme: restore the deep card look (avatar + CTA + filled\\n     progress stay on the primary color, which reads on both schemes). ── */\\n  .support-color-dark .support-nudge-card {\\n    background: #26262b;\\n    border-color: rgba(var(--support-primary-rgb), 0.55);\\n    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);\\n  }\\n\\n  .support-color-dark .support-nudge-progress-seg {\\n    background: rgba(255, 255, 255, 0.16);\\n  }\\n\\n  /* Same specificity as the rule above, so the completed segments need saying\\n     again here or the dark track paints over them. */\\n  .support-color-dark .support-nudge-progress-seg.is-done {\\n    background: var(--support-primary-color);\\n  }\\n\\n  .support-color-dark .support-nudge-name,\\n  .support-color-dark .support-nudge-message {\\n    color: #fff;\\n  }\\n\\n  .support-color-dark .support-nudge-subtitle {\\n    color: rgba(255, 255, 255, 0.55);\\n  }\\n\\n  .support-color-dark .support-nudge-confirm-prompt {\\n    color: rgba(255, 255, 255, 0.7);\\n  }\\n\\n  .support-color-dark .support-nudge-confirm .support-interactive-button.pill:not(.primary) {\\n    border-color: rgba(255, 255, 255, 0.24);\\n    color: rgba(255, 255, 255, 0.78);\\n  }\\n\\n  .support-color-dark .support-nudge-confirm .support-interactive-button.pill:not(.primary):hover:not(:disabled) {\\n    background: rgba(255, 255, 255, 0.1);\\n    border-color: rgba(255, 255, 255, 0.4);\\n    color: #fff;\\n  }\\n\\n  .support-color-dark .support-nudge-card .support-awareness-dismiss {\\n    color: rgba(255, 255, 255, 0.5);\\n  }\\n\\n  .support-color-dark .support-nudge-card .support-awareness-dismiss:hover {\\n    color: #fff;\\n    background: rgba(255, 255, 255, 0.1);\\n  }\\n\\n  /* ── Voice calls: ringing card + launcher ring ── */\\n\\n  .support-voice-call-card {\\n    position: absolute;\\n    bottom: 70px;\\n    right: 0;\\n    width: 320px;\\n    max-width: calc(100vw - 40px);\\n    background: var(--support-white);\\n    border: 1px solid rgba(var(--support-primary-rgb), 0.28);\\n    border-radius: 16px;\\n    box-shadow: 0 12px 40px rgba(18, 28, 53, 0.14);\\n    padding: 16px;\\n    display: flex;\\n    flex-direction: column;\\n    gap: 14px;\\n    pointer-events: auto;\\n    animation: awarenessSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\\n  }\\n\\n  .position-bottom-left .support-voice-call-card,\\n  .position-bottom-left .support-voice-call-pill {\\n    right: auto;\\n    left: 0;\\n  }\\n\\n  .position-top-right .support-voice-call-card,\\n  .position-top-right .support-voice-call-pill {\\n    bottom: auto;\\n    top: 70px;\\n  }\\n\\n  .position-top-left .support-voice-call-card,\\n  .position-top-left .support-voice-call-pill {\\n    bottom: auto;\\n    top: 70px;\\n    right: auto;\\n    left: 0;\\n  }\\n\\n  /* Active-call pill: the only call surface while a call is live (the chat\\n     stays closed for the duration). Body = return-to-call; circle = hang up. */\\n  .support-voice-call-pill {\\n    position: absolute;\\n    bottom: 70px;\\n    right: 0;\\n    width: max-content;\\n    max-width: calc(100vw - 40px);\\n    display: flex;\\n    align-items: center;\\n    gap: 10px;\\n    background: var(--support-primary-dark);\\n    color: #ffffff;\\n    border-radius: 999px;\\n    padding: 6px 6px 6px 14px;\\n    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);\\n    pointer-events: auto;\\n    box-sizing: border-box;\\n  }\\n\\n  .support-voice-call-pill-body {\\n    align-self: stretch;\\n    display: flex;\\n    align-items: center;\\n    gap: 10px;\\n    min-width: 0;\\n    margin: -6px 0 -6px -14px;\\n    padding: 6px 0 6px 14px;\\n    border-radius: 999px 0 0 999px;\\n    box-sizing: border-box;\\n    cursor: pointer;\\n  }\\n\\n  .support-voice-call-pill-body:focus-visible {\\n    outline: 3px solid rgba(245, 158, 11, 0.75);\\n    outline-offset: 3px;\\n  }\\n\\n  .support-voice-call-live-dot {\\n    width: 8px;\\n    height: 8px;\\n    border-radius: 50%;\\n    background: #10b981;\\n    flex-shrink: 0;\\n    animation: voiceCallLivePulse 1.6s ease-out infinite;\\n  }\\n\\n  .support-voice-call-pill-label {\\n    font-size: 13px;\\n    font-weight: 500;\\n    white-space: nowrap;\\n  }\\n\\n  .support-voice-call-pill-timer {\\n    font-size: 12px;\\n    color: rgba(255, 255, 255, 0.65);\\n    font-variant-numeric: tabular-nums;\\n  }\\n\\n  .support-voice-call-hangup {\\n    position: relative;\\n    width: 32px;\\n    height: 32px;\\n    border: none;\\n    border-radius: 50%;\\n    background: #ef4444;\\n    color: #ffffff;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    flex-shrink: 0;\\n    cursor: pointer;\\n    padding: 0;\\n    transition: filter 0.15s ease;\\n  }\\n\\n  .support-voice-call-hangup:hover {\\n    filter: brightness(0.92);\\n  }\\n\\n  .support-voice-call-hangup svg {\\n    width: 15px;\\n    height: 15px;\\n    transform: rotate(135deg);\\n  }\\n\\n  @keyframes voiceCallLivePulse {\\n    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }\\n    70% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }\\n    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }\\n  }\\n\\n  @media (prefers-reduced-motion: reduce) {\\n    .support-voice-call-pill,\\n    .support-voice-call-live-dot,\\n    .support-voice-call-live-dot.support-voice-call-live-dot--sharing {\\n      animation: none;\\n    }\\n\\n    .support-voice-call-hangup,\\n    .support-voice-call-stop-share,\\n    .support-voice-call-share-here {\\n      transition: none;\\n    }\\n  }\\n\\n  .support-voice-call-head {\\n    display: flex;\\n    align-items: center;\\n    gap: 12px;\\n  }\\n\\n  .support-voice-call-avatar {\\n    width: 48px;\\n    height: 48px;\\n    border-radius: 50%;\\n    background: var(--support-primary-color);\\n    color: #ffffff;\\n    font-size: 16px;\\n    font-weight: 600;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    flex-shrink: 0;\\n    animation: voiceCallRingPulse 1.8s ease-out infinite;\\n  }\\n\\n  .support-voice-call-avatar svg {\\n    width: 22px;\\n    height: 22px;\\n  }\\n\\n  .support-voice-call-who {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 3px;\\n    min-width: 0;\\n  }\\n\\n  .support-voice-call-eyebrow {\\n    font-size: 11px;\\n    font-weight: 600;\\n    letter-spacing: 0.06em;\\n    text-transform: uppercase;\\n    color: #6b7280;\\n  }\\n\\n  .support-voice-call-dots span {\\n    display: inline-block;\\n    animation: voiceCallDotBlink 1.4s infinite;\\n  }\\n\\n  .support-voice-call-dots span:nth-child(2) {\\n    animation-delay: 0.2s;\\n  }\\n\\n  .support-voice-call-dots span:nth-child(3) {\\n    animation-delay: 0.4s;\\n  }\\n\\n  .support-voice-call-name {\\n    font-size: 16px;\\n    font-weight: 600;\\n    color: #16203a;\\n    overflow: hidden;\\n    text-overflow: ellipsis;\\n    white-space: nowrap;\\n  }\\n\\n  .support-voice-call-actions {\\n    display: flex;\\n    gap: 8px;\\n  }\\n\\n  .support-voice-call-btn {\\n    flex: 1;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    gap: 8px;\\n    height: 42px;\\n    border-radius: 21px;\\n    font-size: 13px;\\n    font-weight: 600;\\n    font-family: inherit;\\n    cursor: pointer;\\n    transition: filter 0.15s ease;\\n  }\\n\\n  .support-voice-call-btn:hover:not(:disabled) {\\n    filter: brightness(0.95);\\n  }\\n\\n  .support-voice-call-btn:disabled {\\n    opacity: 0.6;\\n    cursor: default;\\n  }\\n\\n  .support-voice-call-btn svg {\\n    width: 16px;\\n    height: 16px;\\n    flex-shrink: 0;\\n  }\\n\\n  .support-voice-call-btn--hangup-icon svg {\\n    transform: rotate(135deg);\\n  }\\n\\n  .support-voice-call-btn--decline {\\n    border: 1px solid rgba(239, 68, 68, 0.4);\\n    background: rgba(239, 68, 68, 0.08);\\n    color: #dc2626;\\n  }\\n\\n  .support-voice-call-btn--accept {\\n    border: 1px solid #10b981;\\n    background: #10b981;\\n    color: #ffffff;\\n  }\\n\\n  /* The launcher rings along with the card so a call is noticeable even if\\n     the card is off-screen behind host chrome. */\\n  .support-widget-container.has-voice-call-ringing .support-bubble {\\n    animation: voiceCallLauncherRing 1.8s ease-out infinite;\\n  }\\n\\n  @keyframes voiceCallRingPulse {\\n    0% { box-shadow: 0 0 0 0 rgba(var(--support-primary-rgb), 0.45); }\\n    70% { box-shadow: 0 0 0 12px rgba(var(--support-primary-rgb), 0); }\\n    100% { box-shadow: 0 0 0 0 rgba(var(--support-primary-rgb), 0); }\\n  }\\n\\n  @keyframes voiceCallDotBlink {\\n    0%, 60%, 100% { opacity: 0.25; }\\n    30% { opacity: 1; }\\n  }\\n\\n  @keyframes voiceCallLauncherRing {\\n    0% { box-shadow: 0 4px 12px rgba(var(--support-primary-rgb), 0.3), 0 0 0 0 rgba(var(--support-primary-rgb), 0.45); }\\n    70% { box-shadow: 0 4px 12px rgba(var(--support-primary-rgb), 0.3), 0 0 0 14px rgba(var(--support-primary-rgb), 0); }\\n    100% { box-shadow: 0 4px 12px rgba(var(--support-primary-rgb), 0.3), 0 0 0 0 rgba(var(--support-primary-rgb), 0); }\\n  }\\n\\n  .support-color-dark .support-voice-call-card {\\n    background: #26262b;\\n    border-color: rgba(var(--support-primary-rgb), 0.55);\\n    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);\\n  }\\n\\n  .support-color-dark .support-voice-call-name {\\n    color: #fff;\\n  }\\n\\n  .support-color-dark .support-voice-call-eyebrow {\\n    color: rgba(255, 255, 255, 0.6);\\n  }\\n\\n  /* ── Screen share: consent card + the pill\\'s sharing state ── */\\n\\n  /* Stacked 10px above the 44px call pill, which is always there — a share only\\n     exists inside a call. The card is the only surface that stacks; sharing\\n     itself is a state of the pill below it. */\\n  .support-screen-share-card {\\n    position: absolute;\\n    bottom: 124px;\\n    right: 0;\\n    width: 320px;\\n    max-width: calc(100vw - 40px);\\n    background: var(--support-white);\\n    border: 1px solid rgba(var(--support-primary-rgb), 0.28);\\n    border-radius: 16px;\\n    box-shadow: 0 12px 40px rgba(18, 28, 53, 0.14);\\n    padding: 16px;\\n    display: flex;\\n    flex-direction: column;\\n    gap: 14px;\\n    pointer-events: auto;\\n    animation: awarenessSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;\\n  }\\n\\n  .position-bottom-left .support-screen-share-card {\\n    right: auto;\\n    left: 0;\\n  }\\n\\n  .position-top-right .support-screen-share-card {\\n    bottom: auto;\\n    top: 124px;\\n  }\\n\\n  .position-top-left .support-screen-share-card {\\n    bottom: auto;\\n    top: 124px;\\n    right: auto;\\n    left: 0;\\n  }\\n\\n  .support-screen-share-avatar-wrap {\\n    position: relative;\\n    width: 48px;\\n    height: 48px;\\n    flex-shrink: 0;\\n  }\\n\\n  /* Reads as \"screen\", not \"call\", at a glance — the one thing that tells this\\n     card apart from the ringing card before any copy is read. */\\n  .support-screen-share-badge {\\n    position: absolute;\\n    right: -3px;\\n    bottom: -3px;\\n    width: 20px;\\n    height: 20px;\\n    border-radius: 50%;\\n    background: #16203a;\\n    border: 2px solid var(--support-white);\\n    color: #ffffff;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n  }\\n\\n  .support-screen-share-badge svg {\\n    width: 10px;\\n    height: 10px;\\n  }\\n\\n  .support-screen-share-body {\\n    margin: 0;\\n    font-size: 12.5px;\\n    line-height: 1.45;\\n    color: #374151;\\n  }\\n\\n  /* The accept label is the longest string on the card (and longer still in\\n     Spanish); the extra flex is what keeps it on one line. */\\n  .support-screen-share-btn--accept {\\n    flex: 1.35;\\n  }\\n\\n  .support-voice-call-live-dot--sharing {\\n    background: #f59e0b;\\n    animation-name: voiceCallSharePulse;\\n  }\\n\\n  /* The circle left of hang-up: amber stop-share in the tab that captures, emerald share-here\\n     (the consent card\\'s accept colour and glyph) in every other tab of the contact. */\\n  .support-voice-call-stop-share,\\n  .support-voice-call-share-here {\\n    position: relative;\\n    width: 32px;\\n    height: 32px;\\n    border: none;\\n    border-radius: 50%;\\n    color: #ffffff;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    flex-shrink: 0;\\n    cursor: pointer;\\n    padding: 0;\\n    transition: filter 0.15s ease;\\n  }\\n\\n  .support-voice-call-stop-share {\\n    background: #f59e0b;\\n  }\\n\\n  .support-voice-call-share-here {\\n    background: #10b981;\\n  }\\n\\n  .support-voice-call-stop-share:hover,\\n  .support-voice-call-share-here:hover:not(:disabled) {\\n    filter: brightness(0.92);\\n  }\\n\\n  .support-voice-call-share-here:disabled {\\n    opacity: 0.6;\\n    cursor: wait;\\n  }\\n\\n  /* The share-here glyph does not explain itself the way a handset does, so the circle names its\\n     action on hover and keyboard focus. Anchored to its right edge: the pill hugs the viewport\\'s\\n     right edge, where a centred tooltip would leave the screen. */\\n  .support-voice-call-share-here::after {\\n    content: attr(data-tooltip);\\n    position: absolute;\\n    right: 0;\\n    bottom: calc(100% + 8px);\\n    background: #16203a;\\n    color: #ffffff;\\n    font-size: 11px;\\n    font-weight: 600;\\n    line-height: 1.3;\\n    padding: 5px 8px;\\n    border-radius: 6px;\\n    white-space: nowrap;\\n    pointer-events: none;\\n    opacity: 0;\\n    transition: opacity 0.15s ease;\\n  }\\n\\n  .support-voice-call-share-here:hover::after,\\n  .support-voice-call-share-here:focus-visible::after {\\n    opacity: 1;\\n  }\\n\\n  .position-top-right .support-voice-call-share-here::after,\\n  .position-top-left .support-voice-call-share-here::after {\\n    bottom: auto;\\n    top: calc(100% + 8px);\\n  }\\n\\n  .support-voice-call-stop-share svg,\\n  .support-voice-call-share-here svg {\\n    width: 16px;\\n    height: 16px;\\n  }\\n\\n  @keyframes voiceCallSharePulse {\\n    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5); }\\n    70% { box-shadow: 0 0 0 7px rgba(245, 158, 11, 0); }\\n    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }\\n  }\\n\\n  .support-color-dark .support-screen-share-card {\\n    background: #26262b;\\n    border-color: rgba(var(--support-primary-rgb), 0.55);\\n    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);\\n  }\\n\\n  .support-color-dark .support-screen-share-body {\\n    color: rgba(255, 255, 255, 0.75);\\n  }\\n\\n  .support-color-dark .support-screen-share-badge {\\n    background: #ffffff;\\n    border-color: #26262b;\\n    color: #16203a;\\n  }\\n\\n  /* ── Onboarding accordion card ── */\\n\\n  .support-onboarding-type-tabs {\\n    display: flex;\\n    gap: 4px;\\n    margin: 16px 16px 12px;\\n    padding: 4px;\\n    background: #f3f4f6;\\n    border-radius: 999px;\\n  }\\n\\n  .support-onboarding-type-tab {\\n    flex: 1;\\n    padding: 8px 12px;\\n    border: none;\\n    border-radius: 999px;\\n    background: transparent;\\n    color: var(--widget-text-muted);\\n    font-size: 13px;\\n    font-weight: 500;\\n    cursor: pointer;\\n    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;\\n  }\\n\\n  .support-onboarding-type-tab:hover:not(.is-active):not(:disabled) {\\n    color: var(--widget-text);\\n  }\\n\\n  .support-onboarding-type-tab.is-active {\\n    background: #ffffff;\\n    color: var(--support-primary-color);\\n    font-weight: 600;\\n    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);\\n  }\\n\\n  .support-onboarding-type-tab:disabled {\\n    opacity: 0.5;\\n    cursor: not-allowed;\\n  }\\n\\n  .support-onboarding-type-tabs + .support-onboarding-card {\\n    margin-top: 0;\\n  }\\n\\n  .support-onboarding-card {\\n    margin: -44px 16px 20px;\\n    background: var(--widget-agent-bubble-bg);\\n    border-radius: 12px;\\n    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);\\n    overflow: hidden;\\n    position: relative;\\n    z-index: 1;\\n    animation: onboardingFadeIn 0.4s ease-out;\\n  }\\n\\n  .support-onboarding-card-exit {\\n    animation: onboardingFadeOut 0.3s ease-in forwards;\\n  }\\n\\n  .support-onboarding-header {\\n    padding: 16px 16px 12px;\\n  }\\n\\n  .support-onboarding-title {\\n    font-size: 15px;\\n    font-weight: 600;\\n    color: var(--widget-text);\\n    margin: 0 0 8px 0;\\n  }\\n\\n  .support-onboarding-progress-meta {\\n    font-size: 12px;\\n    color: var(--widget-text-muted);\\n    margin: 0 0 6px 0;\\n  }\\n\\n  .support-onboarding-progress-bar {\\n    height: 4px;\\n    background: #e5e7eb;\\n    border-radius: 2px;\\n    overflow: hidden;\\n  }\\n\\n  .support-onboarding-progress-fill {\\n    height: 100%;\\n    background: var(--support-primary-color);\\n    border-radius: 2px;\\n    transition: width 0.4s ease;\\n  }\\n\\n  .support-onboarding-step {\\n    border-top: 1px solid var(--widget-border);\\n  }\\n\\n  .support-onboarding-step-header {\\n    display: flex;\\n    align-items: center;\\n    padding: 12px 16px;\\n    gap: 12px;\\n    cursor: pointer;\\n    transition: background 0.1s;\\n  }\\n\\n  .support-onboarding-step-header:hover {\\n    background: #fafafa;\\n  }\\n\\n  .support-onboarding-step.completed .support-onboarding-step-header {\\n    cursor: default;\\n  }\\n\\n  .support-onboarding-step.completed .support-onboarding-step-header:hover {\\n    background: transparent;\\n  }\\n\\n  .support-onboarding-step-number {\\n    width: 24px;\\n    height: 24px;\\n    border-radius: 50%;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    font-size: 12px;\\n    font-weight: 600;\\n    flex-shrink: 0;\\n    background: #f3f4f6;\\n    color: #9ca3af;\\n  }\\n\\n  .support-onboarding-step.active .support-onboarding-step-number {\\n    background: rgba(var(--support-primary-rgb), 0.12);\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-onboarding-step.completed .support-onboarding-step-number {\\n    background: var(--support-primary-color);\\n    color: #fff;\\n  }\\n\\n  .support-onboarding-step-number svg {\\n    width: 14px;\\n    height: 14px;\\n    fill: none;\\n    stroke: currentColor;\\n    stroke-width: 2.5;\\n    stroke-linecap: round;\\n    stroke-linejoin: round;\\n  }\\n\\n  .support-onboarding-step-title {\\n    flex: 1;\\n    font-size: 13px;\\n    font-weight: 500;\\n    color: var(--widget-text);\\n  }\\n\\n  .support-onboarding-step.completed .support-onboarding-step-title {\\n    text-decoration: line-through;\\n    color: #9ca3af;\\n  }\\n\\n  .support-onboarding-step-chevron {\\n    width: 16px;\\n    height: 16px;\\n    color: #9ca3af;\\n    transition: transform 0.2s ease;\\n    flex-shrink: 0;\\n  }\\n\\n  .support-onboarding-step-chevron svg {\\n    width: 16px;\\n    height: 16px;\\n    fill: none;\\n    stroke: currentColor;\\n    stroke-width: 2;\\n    stroke-linecap: round;\\n    stroke-linejoin: round;\\n  }\\n\\n  .support-onboarding-step.expanded .support-onboarding-step-chevron {\\n    transform: rotate(90deg);\\n  }\\n\\n  .support-onboarding-step.completed .support-onboarding-step-chevron {\\n    display: none;\\n  }\\n\\n  .support-onboarding-step-body {\\n    max-height: 0;\\n    overflow: hidden;\\n    transition: max-height 0.3s ease;\\n  }\\n\\n  .support-onboarding-step-body-inner {\\n    padding: 0 16px 14px 52px;\\n  }\\n\\n  .support-onboarding-step-description {\\n    font-size: 13px;\\n    color: #6b7280;\\n    line-height: 1.5;\\n    margin: 0 0 12px 0;\\n  }\\n\\n  .support-onboarding-step-cta {\\n    display: inline-flex;\\n    align-items: center;\\n    padding: 6px 14px;\\n    background: var(--support-primary-color);\\n    color: #fff;\\n    border: none;\\n    border-radius: 6px;\\n    font-size: 12px;\\n    font-weight: 500;\\n    cursor: pointer;\\n    transition: filter 0.15s, transform 0.1s;\\n    font-family: inherit;\\n  }\\n\\n  .support-onboarding-step-cta:hover {\\n    filter: brightness(0.9);\\n    transform: translateY(-1px);\\n  }\\n\\n  .support-onboarding-step-cta:active {\\n    transform: translateY(0);\\n  }\\n\\n  /* ── Onboarding bubble card ── */\\n  .support-onboarding-bubble-card {\\n    position: absolute;\\n    bottom: 0;\\n    right: 0;\\n    width: 292px;\\n    max-width: calc(100vw - 2 * var(--widget-edge-gap) - var(--widget-safe-left) - var(--widget-safe-right));\\n    box-sizing: border-box;\\n    background: var(--support-primary-color);\\n    border-radius: 12px;\\n    padding: 14px 16px;\\n    box-shadow: 0 4px 16px rgba(var(--support-primary-rgb), 0.3);\\n    cursor: pointer;\\n    transform-origin: bottom right;\\n    transition: box-shadow 0.2s ease;\\n    pointer-events: auto;\\n  }\\n\\n  .support-obc-content:focus-visible,\\n  .support-obc-close:focus-visible {\\n    outline: 2px solid var(--support-secondary-color);\\n    outline-offset: 3px;\\n  }\\n\\n  .support-onboarding-bubble-card:hover {\\n    box-shadow: 0 6px 24px rgba(var(--support-primary-rgb), 0.4);\\n  }\\n\\n  .support-onboarding-bubble-card:hover .support-obc-close {\\n    opacity: 1;\\n    visibility: visible;\\n  }\\n\\n  .support-obc-close {\\n    position: absolute;\\n    top: -8px;\\n    right: -8px;\\n    width: 24px;\\n    height: 24px;\\n    background: #6b7280;\\n    border-radius: 50%;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    cursor: pointer;\\n    opacity: 0;\\n    visibility: hidden;\\n    transition: all 0.3s ease;\\n    border: 2px solid var(--support-white);\\n    padding: 0;\\n    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\\n  }\\n\\n  .support-obc-close:hover {\\n    background: #4b5563;\\n  }\\n\\n  .support-obc-close svg {\\n    width: 12px;\\n    height: 12px;\\n    fill: var(--support-white);\\n  }\\n\\n  .support-obc-heading {\\n    display: flex;\\n    align-items: baseline;\\n    justify-content: space-between;\\n    gap: 8px;\\n    margin-bottom: 4px;\\n  }\\n\\n  .support-obc-title {\\n    font-size: 14px;\\n    font-weight: 600;\\n    color: var(--support-secondary-color);\\n    overflow-wrap: anywhere;\\n  }\\n\\n  .support-obc-stage-badge {\\n    flex-shrink: 0;\\n    font-size: 10px;\\n    font-weight: 700;\\n    color: var(--support-secondary-color);\\n    background: rgba(255, 255, 255, 0.2);\\n    border-radius: 999px;\\n    padding: 3px 7px;\\n  }\\n\\n  .support-obc-meta {\\n    display: flex;\\n    justify-content: space-between;\\n    gap: 8px;\\n    font-size: 12px;\\n    color: rgba(255, 255, 255, 0.75);\\n    margin-bottom: 8px;\\n  }\\n\\n  .support-obc-stage-name {\\n    min-width: 0;\\n    overflow-wrap: anywhere;\\n  }\\n\\n  .support-obc-stage-count {\\n    flex-shrink: 0;\\n    color: var(--support-secondary-color);\\n    font-weight: 700;\\n  }\\n\\n  .support-obc-bar {\\n    height: 4px;\\n    background: rgba(255, 255, 255, 0.3);\\n    border-radius: 2px;\\n    overflow: hidden;\\n    margin-bottom: 8px;\\n  }\\n\\n  .support-obc-fill {\\n    height: 100%;\\n    background: var(--support-secondary-color);\\n    border-radius: 2px;\\n    transition: width 0.4s ease;\\n  }\\n\\n  .support-obc-next {\\n    font-size: 13px;\\n    line-height: 1.4;\\n    color: var(--support-secondary-color);\\n    max-height: 5.6em;\\n    overflow-y: auto;\\n    overflow-wrap: anywhere;\\n  }\\n\\n  .support-obc-next span {\\n    display: block;\\n    color: rgba(255, 255, 255, 0.75);\\n  }\\n\\n  .support-obc-next strong {\\n    font-weight: 600;\\n  }\\n\\n  .position-bottom-left .support-onboarding-bubble-card {\\n    right: auto;\\n    left: 0;\\n    transform-origin: bottom left;\\n  }\\n\\n  .position-top-right .support-onboarding-bubble-card {\\n    bottom: auto;\\n    top: 0;\\n    transform-origin: top right;\\n  }\\n\\n  .position-top-left .support-onboarding-bubble-card {\\n    bottom: auto;\\n    top: 0;\\n    right: auto;\\n    left: 0;\\n    transform-origin: top left;\\n  }\\n\\n  @keyframes bubbleScaleOut {\\n    from {\\n      transform: scale(1);\\n      opacity: 1;\\n    }\\n    to {\\n      transform: scale(0);\\n      opacity: 0;\\n    }\\n  }\\n\\n  @keyframes bubbleScaleIn {\\n    from {\\n      transform: scale(0);\\n      opacity: 0;\\n    }\\n    to {\\n      transform: scale(1);\\n      opacity: 1;\\n    }\\n  }\\n\\n  .bubble-scale-out {\\n    animation: bubbleScaleOut 0.3s ease-in forwards;\\n  }\\n\\n  .bubble-scale-in {\\n    animation: bubbleScaleIn 0.3s ease-out forwards;\\n  }\\n\\n  @keyframes onboardingFadeIn {\\n    from {\\n      opacity: 0;\\n      transform: translateY(8px);\\n    }\\n    to {\\n      opacity: 1;\\n      transform: translateY(0);\\n    }\\n  }\\n\\n  @keyframes onboardingFadeOut {\\n    from {\\n      opacity: 1;\\n      transform: translateY(0);\\n    }\\n    to {\\n      opacity: 0;\\n      transform: translateY(-8px);\\n    }\\n  }\\n\\n  @keyframes planPanelSlideIn {\\n    from {\\n      opacity: 0;\\n      transform: translateX(12px);\\n    }\\n    to {\\n      opacity: 1;\\n      transform: translateX(0);\\n    }\\n  }\\n\\n  @keyframes planPanelSlideOut {\\n    from {\\n      opacity: 1;\\n      transform: translateX(0);\\n    }\\n    to {\\n      opacity: 0;\\n      transform: translateX(12px);\\n    }\\n  }\\n\\n  .support-onboarding-plan-panel {\\n    position: absolute;\\n    top: 0;\\n    left: 0;\\n    right: 0;\\n    bottom: 0;\\n    display: flex;\\n    flex-direction: column;\\n    background: var(--widget-agent-bubble-bg);\\n    z-index: 5;\\n    animation: planPanelSlideIn 0.25s ease-out;\\n  }\\n\\n  .support-onboarding-plan-panel-exit {\\n    animation: planPanelSlideOut 0.2s ease-in forwards;\\n  }\\n\\n  .support-onboarding-plan-header {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n    padding: 12px 16px;\\n    border-bottom: 1px solid var(--widget-border);\\n    flex-shrink: 0;\\n  }\\n\\n  .support-onboarding-plan-back {\\n    width: 28px;\\n    height: 28px;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    border: none;\\n    background: transparent;\\n    border-radius: 6px;\\n    cursor: pointer;\\n    color: #6b7280;\\n    padding: 0;\\n    flex-shrink: 0;\\n    transition: background 0.15s, color 0.15s;\\n  }\\n\\n  .support-onboarding-plan-back:hover {\\n    background: rgba(0, 0, 0, 0.06);\\n    color: #374151;\\n  }\\n\\n  .support-onboarding-plan-back svg {\\n    width: 16px;\\n    height: 16px;\\n    fill: none;\\n    stroke: currentColor;\\n    stroke-width: 2;\\n    stroke-linecap: round;\\n    stroke-linejoin: round;\\n  }\\n\\n  .support-onboarding-plan-title {\\n    font-size: 14px;\\n    font-weight: 600;\\n    color: #111827;\\n  }\\n\\n  .support-onboarding-plan-loading-bar {\\n    height: 3px;\\n    flex-shrink: 0;\\n    background: rgba(var(--support-primary-rgb), 0.2);\\n    overflow: hidden;\\n    position: relative;\\n  }\\n\\n  .support-onboarding-plan-loading-bar::after {\\n    content: \\'\\';\\n    position: absolute;\\n    top: 0;\\n    left: 0;\\n    height: 100%;\\n    width: 40%;\\n    background: var(--support-primary-color);\\n    animation: chat-loading 1s ease-in-out infinite;\\n  }\\n\\n  .support-onboarding-plan-body {\\n    flex: 1;\\n    overflow-y: auto;\\n    padding: 12px 16px;\\n  }\\n\\n  .support-onboarding-plan-step-card {\\n    border: 1px solid #e5e7eb;\\n    border-radius: 8px;\\n    padding: 10px 12px;\\n    background: #fafafa;\\n  }\\n\\n  .support-onboarding-plan-step-header {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n    margin-bottom: 6px;\\n  }\\n\\n  .support-onboarding-plan-step-label {\\n    font-size: 11px;\\n    color: #9ca3af;\\n    font-weight: 500;\\n  }\\n\\n  .support-onboarding-plan-step-action {\\n    font-size: 11px;\\n    font-weight: 600;\\n    padding: 1px 8px;\\n    border-radius: 999px;\\n    background: rgba(var(--support-primary-rgb), 0.1);\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-onboarding-plan-step-desc {\\n    font-size: 12px;\\n    color: var(--widget-text);\\n    margin: 0 0 8px;\\n    line-height: 1.5;\\n  }\\n\\n  .support-onboarding-plan-step-connector {\\n    height: 12px;\\n    margin-left: 6px;\\n    border-left: 2px dashed var(--widget-border);\\n  }\\n\\n  .support-onboarding-plan-step-outcome {\\n    background: #f3f4f6;\\n    border-radius: 6px;\\n    padding: 6px 10px;\\n  }\\n\\n  .support-onboarding-plan-step-outcome-label {\\n    font-size: 10px;\\n    font-weight: 600;\\n    color: #9ca3af;\\n    text-transform: uppercase;\\n    margin-bottom: 2px;\\n  }\\n\\n  .support-onboarding-plan-step-outcome-text {\\n    font-size: 12px;\\n    color: #6b7280;\\n    line-height: 1.4;\\n  }\\n\\n  .support-onboarding-plan-arrow-sep {\\n    display: flex;\\n    justify-content: center;\\n    padding: 4px 0;\\n    color: #d1d5db;\\n  }\\n\\n  .support-onboarding-plan-arrow-sep svg {\\n    width: 16px;\\n    height: 16px;\\n    fill: none;\\n    stroke: currentColor;\\n    stroke-width: 2;\\n    stroke-linecap: round;\\n    stroke-linejoin: round;\\n  }\\n\\n  .support-onboarding-plan-empty {\\n    text-align: center;\\n    color: #9ca3af;\\n    font-size: 13px;\\n    padding: 32px 16px;\\n  }\\n\\n  /* Admin mode overrides — dark blue theme (primary color shades) */\\n  .admin-mode .support-badge { display: none !important; }\\n  .admin-mode .support-menu-container { display: none; }\\n  .admin-mode .support-new-chat-btn { display: none; }\\n  .admin-mode .support-branding { display: none; }\\n  .admin-mode .support-agent-banner { display: none; }\\n  .admin-mode .support-attach-btn { display: none; }\\n  .admin-mode .support-mic-btn { display: none !important; }\\n\\n  .admin-mode .support-chat-window {\\n    border-left: 1px solid var(--widget-border);\\n    box-shadow: -4px 0 32px rgba(0, 0, 0, 0.3);\\n    border-radius: 0;\\n  }\\n\\n  .admin-mode .support-chat-header {\\n    background: var(--widget-surface);\\n    border-bottom: 1px solid rgba(69, 147, 248, 0.15);\\n    padding: 14px 16px;\\n  }\\n\\n  .admin-mode .support-entity-action {\\n    color: rgba(255, 255, 255, 0.7);\\n    opacity: 1;\\n  }\\n\\n  .admin-mode .support-entity-title {\\n    color: var(--widget-text);\\n  }\\n\\n  .admin-mode .support-close-btn svg {\\n    fill: rgba(255, 255, 255, 0.4);\\n  }\\n\\n  .admin-mode .support-close-btn:hover {\\n    background: rgba(255, 255, 255, 0.06);\\n  }\\n\\n  .admin-mode .support-close-btn:hover svg {\\n    fill: rgba(255, 255, 255, 0.8);\\n  }\\n\\n  .admin-mode .support-message.agent .support-message-content {\\n    border: 1px solid var(--widget-border);\\n    box-shadow: none;\\n  }\\n\\n  .admin-mode .support-message.thinking.agent .support-message-content.support-thinking-bubble {\\n    background: transparent;\\n    border: none;\\n    box-shadow: none;\\n  }\\n\\n  .admin-mode .support-message.thinking .support-thinking-content {\\n    color: #FFFFFF;\\n  }\\n\\n  @supports ((-webkit-background-clip: text) or (background-clip: text)) {\\n    .admin-mode .support-message.thinking .support-thinking-content {\\n      background: linear-gradient(\\n        90deg,\\n        rgba(255, 255, 255, 0.4) 0%,\\n        rgba(255, 255, 255, 0.4) 40%,\\n        rgba(255, 255, 255, 1) 50%,\\n        rgba(255, 255, 255, 0.4) 60%,\\n        rgba(255, 255, 255, 0.4) 100%\\n      );\\n      background-size: 200% 100%;\\n      -webkit-background-clip: text;\\n      background-clip: text;\\n      -webkit-text-fill-color: transparent;\\n      color: transparent;\\n    }\\n  }\\n\\n  .admin-mode .support-avatar {\\n    background: var(--widget-agent-bubble-bg);\\n    border: 1px solid var(--widget-border);\\n  }\\n\\n  .admin-mode .support-message-content code {\\n    background: rgba(69, 147, 248, 0.12);\\n    color: #6FAFFF;\\n  }\\n\\n  .admin-mode .support-message.user .support-message-content code {\\n    background: rgba(0, 0, 0, 0.2);\\n    color: #D6E8FF;\\n  }\\n\\n  .admin-mode .support-message-content a {\\n    color: #6FAFFF;\\n  }\\n\\n  .admin-mode .support-message.user .support-message-content a {\\n    color: #D6E8FF;\\n  }\\n\\n  .admin-mode .support-message-content pre {\\n    background: #091425;\\n    border: 1px solid var(--widget-border);\\n  }\\n\\n  .admin-mode .support-chat-footer {\\n    border-top: 1px solid rgba(69, 147, 248, 0.15);\\n    padding: 10px 12px;\\n  }\\n\\n  .admin-mode .support-chat-input::placeholder {\\n    color: var(--widget-text-muted);\\n  }\\n\\n  .admin-mode .support-chat-input:focus {\\n    border-color: var(--support-primary-color);\\n    box-shadow: 0 0 0 2px rgba(69, 147, 248, 0.15);\\n  }\\n\\n  .admin-mode .support-send-btn {\\n    background: var(--widget-user-bubble-bg);\\n  }\\n\\n  .admin-mode .support-send-btn:hover {\\n    background: var(--support-primary-color);\\n  }\\n\\n  .admin-mode .support-admin-back-btn {\\n    display: none;\\n    background: transparent;\\n    border: none;\\n    color: rgba(255, 255, 255, 0.6);\\n    cursor: pointer;\\n    padding: 6px;\\n    border-radius: 6px;\\n    align-items: center;\\n    justify-content: center;\\n    transition: background 0.15s, color 0.15s;\\n  }\\n\\n  .admin-mode .support-admin-back-btn svg {\\n    width: 18px;\\n    height: 18px;\\n    fill: currentColor;\\n  }\\n\\n  .admin-mode .support-admin-back-btn:hover {\\n    background: rgba(255, 255, 255, 0.06);\\n    color: rgba(255, 255, 255, 0.9);\\n  }\\n\\n  .admin-mode.admin-step-active .support-admin-back-btn {\\n    display: inline-flex;\\n  }\\n\\n  .admin-mode .support-admin-plan-btn {\\n    display: none;\\n    flex-direction: column;\\n    background: transparent;\\n    border: 1px solid rgba(255, 255, 255, 0.25);\\n    color: rgba(255, 255, 255, 0.8);\\n    cursor: pointer;\\n    padding: 3px 8px;\\n    border-radius: 5px;\\n    align-items: center;\\n    justify-content: center;\\n    font-size: 10px;\\n    font-weight: 500;\\n    font-family: inherit;\\n    line-height: 1.1;\\n    letter-spacing: 0.1px;\\n    white-space: nowrap;\\n    transition: background 0.15s, color 0.15s, border-color 0.15s;\\n  }\\n\\n  .admin-mode .support-admin-plan-btn span {\\n    display: block;\\n    text-align: center;\\n  }\\n\\n  .admin-mode .support-admin-plan-btn:hover {\\n    background: rgba(255, 255, 255, 0.08);\\n    border-color: rgba(255, 255, 255, 0.45);\\n    color: #ffffff;\\n  }\\n\\n  .admin-mode.admin-step-active .support-admin-plan-btn {\\n    display: inline-flex;\\n  }\\n\\n  .admin-mode .support-admin-plan-btn.pulse {\\n    animation: support-admin-plan-btn-pulse 0.6s ease-in-out 3;\\n  }\\n\\n  @keyframes support-admin-plan-btn-pulse {\\n    0%, 100% {\\n      transform: scale(1);\\n      box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.55);\\n      border-color: rgba(255, 255, 255, 0.25);\\n    }\\n    50% {\\n      transform: scale(1.08);\\n      box-shadow: 0 0 0 6px rgba(255, 255, 255, 0);\\n      border-color: rgba(255, 255, 255, 0.7);\\n    }\\n  }\\n\\n  .admin-mode .support-chat-footer {\\n    display: none;\\n  }\\n\\n  .admin-mode.admin-step-active .support-chat-footer {\\n    display: block;\\n  }\\n\\n  .support-onboarding-step-cta-group {\\n    display: flex;\\n    gap: 8px;\\n    flex-wrap: wrap;\\n  }\\n\\n  .admin-mode .support-onboarding-step-cta-test {\\n    background: var(--widget-user-bubble-bg);\\n    color: var(--widget-user-bubble-fg);\\n  }\\n\\n  .admin-mode .support-onboarding-step-cta-test:hover {\\n    background: var(--support-primary-color);\\n    filter: none;\\n  }\\n\\n  .admin-mode .support-onboarding-step-cta-configure {\\n    background: transparent;\\n    color: var(--widget-text);\\n    border: 1px solid rgba(69, 147, 248, 0.35);\\n  }\\n\\n  .admin-mode .support-onboarding-step-cta-configure:hover {\\n    background: rgba(69, 147, 248, 0.12);\\n    filter: none;\\n  }\\n\\n  /* Admin-mode onboarding card theming */\\n  .admin-mode .support-welcome-hero {\\n    background: linear-gradient(180deg,\\n      rgba(69, 147, 248, 0.22) 0%,\\n      rgba(69, 147, 248, 0.12) 40%,\\n      rgba(69, 147, 248, 0.04) 70%,\\n      transparent 100%);\\n  }\\n\\n  .admin-mode .support-welcome-hero-title {\\n    color: var(--widget-text-inverse);\\n  }\\n\\n  .admin-mode .support-welcome-hero-subtitle {\\n    color: #A9C2E6;\\n    opacity: 1;\\n  }\\n\\n  .admin-mode .support-admin-leave-btn {\\n    position: relative;\\n    background: none;\\n    border: none;\\n    color: rgba(255, 255, 255, 0.75);\\n    cursor: pointer;\\n    padding: 6px;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    border-radius: 6px;\\n    transition: background 0.15s, color 0.15s;\\n  }\\n\\n  .admin-mode .support-admin-leave-btn .support-admin-leave-icon {\\n    width: 20px;\\n    height: 20px;\\n    fill: currentColor;\\n  }\\n\\n  .admin-mode .support-admin-leave-btn .support-admin-leave-spinner {\\n    width: 20px;\\n    height: 20px;\\n  }\\n\\n  .admin-mode .support-admin-leave-btn:hover {\\n    background: rgba(255, 255, 255, 0.1);\\n    color: #FFFFFF;\\n  }\\n\\n  .admin-mode .support-admin-leave-btn:disabled {\\n    cursor: default;\\n    background: rgba(255, 255, 255, 0.06);\\n  }\\n\\n  .admin-mode .support-admin-leave-btn[data-tooltip]::before {\\n    content: attr(data-tooltip);\\n    position: absolute;\\n    bottom: -36px;\\n    left: 0;\\n    background: #1f2937;\\n    color: white;\\n    padding: 6px 10px;\\n    border-radius: 6px;\\n    font-size: 12px;\\n    white-space: nowrap;\\n    opacity: 0;\\n    visibility: hidden;\\n    transition: opacity 0.15s, visibility 0.15s;\\n    pointer-events: none;\\n    z-index: 1000;\\n    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);\\n  }\\n\\n  .admin-mode .support-admin-leave-btn[data-tooltip]:hover::before {\\n    opacity: 1;\\n    visibility: visible;\\n  }\\n\\n  .admin-mode .support-admin-leave-btn.loading[data-tooltip]::before {\\n    opacity: 0;\\n    visibility: hidden;\\n  }\\n\\n  .admin-mode .support-admin-leave-spinner {\\n    animation: adminLeaveSpin 0.8s linear infinite;\\n    stroke: currentColor;\\n    fill: none;\\n  }\\n\\n  @keyframes adminLeaveSpin {\\n    from { transform: rotate(0deg); }\\n    to { transform: rotate(360deg); }\\n  }\\n\\n  .admin-mode .support-onboarding-card {\\n    margin: 16px;\\n    border: 1px solid var(--widget-border);\\n    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);\\n  }\\n\\n  .admin-mode .support-onboarding-title {\\n    color: var(--widget-text-inverse);\\n  }\\n\\n  .admin-mode .support-onboarding-progress-bar {\\n    background: rgba(69, 147, 248, 0.15);\\n  }\\n\\n  .admin-mode .support-onboarding-step-header:hover {\\n    background: rgba(69, 147, 248, 0.06);\\n  }\\n\\n  .admin-mode .support-onboarding-step.completed .support-onboarding-step-header:hover {\\n    background: transparent;\\n  }\\n\\n  .admin-mode .support-onboarding-step-number {\\n    background: rgba(69, 147, 248, 0.1);\\n    color: #6B8EC2;\\n  }\\n\\n  .admin-mode .support-onboarding-step.active .support-onboarding-step-number {\\n    background: rgba(69, 147, 248, 0.2);\\n    color: var(--support-primary-color);\\n  }\\n\\n  .admin-mode .support-onboarding-step.completed .support-onboarding-step-number {\\n    background: var(--widget-user-bubble-bg);\\n    color: var(--widget-user-bubble-fg);\\n  }\\n\\n  .admin-mode .support-onboarding-step.completed .support-onboarding-step-title {\\n    color: var(--widget-text-muted);\\n  }\\n\\n  .admin-mode .support-onboarding-step-chevron {\\n    color: #6B8EC2;\\n  }\\n\\n  .admin-mode .support-onboarding-step-description {\\n    color: #A9C2E6;\\n  }\\n\\n  .support-onboarding-step-badge {\\n    display: inline-flex;\\n    align-items: center;\\n    padding: 1px 7px;\\n    font-size: 10px;\\n    font-weight: 600;\\n    border-radius: 999px;\\n    white-space: nowrap;\\n    margin-right: 4px;\\n    flex-shrink: 0;\\n    line-height: 1.4;\\n  }\\n\\n  .support-onboarding-step-badge.ready {\\n    background: rgba(16, 185, 129, 0.15);\\n    color: #10B981;\\n    border: 1px solid rgba(16, 185, 129, 0.3);\\n  }\\n\\n  .support-onboarding-step-badge.needs-config {\\n    background: rgba(245, 158, 11, 0.12);\\n    color: #F59E0B;\\n    border: 1px solid rgba(245, 158, 11, 0.3);\\n  }\\n\\n  .admin-mode .support-onboarding-step-badge.ready {\\n    background: rgba(16, 185, 129, 0.12);\\n    color: #34D399;\\n    border-color: rgba(16, 185, 129, 0.35);\\n  }\\n\\n  .admin-mode .support-onboarding-step-badge.needs-config {\\n    background: rgba(245, 158, 11, 0.1);\\n    color: #FBBF24;\\n    border-color: rgba(245, 158, 11, 0.35);\\n  }\\n\\n  .admin-mode .support-onboarding-plan-back:hover {\\n    background: rgba(69, 147, 248, 0.1);\\n    color: #A9C2E6;\\n  }\\n\\n  .admin-mode .support-onboarding-plan-title {\\n    color: var(--widget-text-inverse);\\n  }\\n\\n  .admin-mode .support-onboarding-plan-step-card {\\n    background: rgba(69, 147, 248, 0.06);\\n    border-color: var(--widget-border);\\n  }\\n\\n  .admin-mode .support-onboarding-plan-step-action {\\n    color: var(--support-primary-color);\\n    background: rgba(69, 147, 248, 0.15);\\n  }\\n\\n  .admin-mode .support-onboarding-plan-step-outcome {\\n    background: rgba(69, 147, 248, 0.08);\\n  }\\n\\n  .admin-mode .support-onboarding-plan-step-outcome-text {\\n    color: #A9C2E6;\\n  }\\n\\n  .admin-mode .support-onboarding-plan-arrow-sep {\\n    color: var(--widget-border);\\n  }\\n\\n  /* ============================================================\\n     Tab bar navigation + view routing\\n     ============================================================ */\\n\\n  .support-view {\\n    display: none;\\n    flex: 1;\\n    min-height: 0;\\n    overflow-y: auto;\\n    background: var(--widget-bg);\\n  }\\n\\n  .support-chat-window[data-active-view=\"home\"] .support-view[data-view=\"home\"],\\n  .support-chat-window[data-active-view=\"messages\"] .support-view[data-view=\"messages\"],\\n  .support-chat-window[data-active-view=\"releases\"] .support-view[data-view=\"releases\"] {\\n    display: block;\\n  }\\n\\n  /* Messages view is a flex column so the sub-tab header stays pinned and\\n     the list below it scrolls independently. */\\n  .support-chat-window[data-active-view=\"messages\"] .support-view[data-view=\"messages\"] {\\n    display: flex;\\n    flex-direction: column;\\n  }\\n\\n  .support-chat-window:not([data-active-view=\"chat\"]) .support-chat-body {\\n    display: none;\\n  }\\n\\n  .support-chat-window:not([data-active-view=\"chat\"]) .support-chat-footer {\\n    display: none;\\n  }\\n\\n  .support-chat-window:not([data-active-view=\"chat\"]) .support-agent-banner {\\n    display: none;\\n  }\\n\\n  .support-chat-window:not([data-active-view=\"chat\"]) .support-header-status {\\n    display: none;\\n  }\\n\\n  /* In-chat IA/Soporte switcher — only shown in the chat view and only when\\n     the user has both a session and a ticket active (logic in SupportWidget). */\\n  .support-chat-window:not([data-active-view=\"chat\"]) .support-conversation-selector {\\n    display: none !important;\\n  }\\n\\n  /* Back-to-home arrow shown in header while viewing a chat */\\n  .support-back-to-menu-btn {\\n    background: none;\\n    border: none;\\n    cursor: pointer;\\n    padding: 6px;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    border-radius: 6px;\\n    color: var(--support-secondary-color);\\n    opacity: 0.85;\\n    transition: opacity 0.15s ease, background 0.15s ease;\\n  }\\n\\n  .support-back-to-menu-btn:hover {\\n    opacity: 1;\\n    background: rgba(255, 255, 255, 0.15);\\n  }\\n\\n  .support-back-to-menu-btn svg {\\n    width: 20px;\\n    height: 20px;\\n    fill: currentColor;\\n  }\\n\\n  /* Back button is the single exit out of any non-home section. */\\n  .support-chat-window[data-active-view=\"home\"] .support-back-to-menu-btn {\\n    display: none;\\n  }\\n\\n  /* Admin mode has its own back button; hide the menu one there. */\\n  .admin-mode .support-back-to-menu-btn {\\n    display: none;\\n  }\\n\\n  .support-tab-bar {\\n    display: flex;\\n    flex-shrink: 0;\\n    height: 56px;\\n    border-top: 1px solid var(--widget-border);\\n    background: var(--widget-surface);\\n  }\\n\\n  /* Tab bar is visible on every view that doesn\\'t have the chat input —\\n     home, messages list, releases. Hidden only while viewing an actual chat,\\n     where the footer input takes its place. */\\n  .support-chat-window[data-active-view=\"chat\"] .support-tab-bar {\\n    display: none;\\n  }\\n\\n  /* Messages-only mode: no home menu. The bottom tab bar and the in-chat\\n     back-to-menu arrow are removed so the widget is a pure conversation view. */\\n  .messages-only .support-tab-bar,\\n  .messages-only .support-back-to-menu-btn {\\n    display: none;\\n  }\\n\\n  .support-chat-window[data-active-view=\"home\"] .support-new-chat-btn,\\n  .support-chat-window[data-active-view=\"releases\"] .support-new-chat-btn,\\n  .support-chat-window.ai-inactive .support-new-chat-btn {\\n    display: none;\\n  }\\n\\n  .support-tab {\\n    flex: 1;\\n    display: flex;\\n    flex-direction: column;\\n    align-items: center;\\n    justify-content: center;\\n    gap: 2px;\\n    padding: 6px 4px;\\n    border: 0;\\n    background: transparent;\\n    color: #9ca3af;\\n    cursor: pointer;\\n    font-family: inherit;\\n    font-size: 11px;\\n    font-weight: 500;\\n    transition: color 0.15s ease;\\n  }\\n\\n  .support-tab svg {\\n    width: 22px;\\n    height: 22px;\\n    stroke: currentColor;\\n    fill: none;\\n  }\\n\\n  .support-tab:hover {\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-tab.is-active {\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-tab-label {\\n    line-height: 1;\\n  }\\n\\n  .admin-mode .support-tab-bar {\\n    border-top: 1px solid rgba(69, 147, 248, 0.15);\\n  }\\n\\n  .admin-mode .support-tab {\\n    color: var(--widget-text-muted);\\n  }\\n\\n  /* Home view wrapper — the welcome module is appended here instead of the chat body */\\n  .support-view[data-view=\"home\"] {\\n    padding: 20px;\\n  }\\n\\n  /* Home quick-resume shortcut cards */\\n  .support-home-shortcuts {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 8px;\\n    margin-top: 16px;\\n  }\\n\\n  .support-home-shortcut-card {\\n    display: flex;\\n    align-items: center;\\n    gap: 12px;\\n    width: 100%;\\n    padding: 12px 14px;\\n    border-radius: 12px;\\n    background: var(--widget-surface);\\n    border: 1px solid var(--widget-border);\\n    cursor: pointer;\\n    text-align: left;\\n    font-family: inherit;\\n    transition: border-color 0.15s ease, transform 0.1s ease;\\n  }\\n\\n  .support-home-shortcut-card:hover {\\n    border-color: var(--support-primary-color);\\n  }\\n\\n  .support-home-shortcut-card:active {\\n    transform: scale(0.98);\\n  }\\n\\n  .support-home-shortcut-icon {\\n    position: relative;\\n    width: 36px;\\n    height: 36px;\\n    border-radius: 50%;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    flex-shrink: 0;\\n    background: rgba(var(--support-primary-rgb), 0.1);\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-home-shortcut-icon svg {\\n    width: 20px;\\n    height: 20px;\\n  }\\n\\n  .support-home-shortcut-dot {\\n    position: absolute;\\n    top: -2px;\\n    right: -2px;\\n    width: 10px;\\n    height: 10px;\\n    background: #ef4444;\\n    border-radius: 50%;\\n    box-shadow: 0 0 0 2px var(--widget-surface);\\n    animation: supportDotPulse 1.8s ease-in-out infinite;\\n  }\\n\\n  @keyframes supportDotPulse {\\n    0%, 100% { transform: scale(1); }\\n    50%      { transform: scale(1.15); }\\n  }\\n\\n  .support-home-shortcut-card.has-unread {\\n    border-color: var(--support-primary-color);\\n  }\\n\\n  .support-home-shortcut-card.has-unread .support-home-shortcut-hint {\\n    color: var(--support-primary-color);\\n    font-weight: 600;\\n  }\\n\\n  .support-home-shortcut-text {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 2px;\\n    flex: 1;\\n    min-width: 0;\\n  }\\n\\n  .support-home-shortcut-label {\\n    font-size: 14px;\\n    font-weight: 600;\\n    color: var(--widget-text);\\n  }\\n\\n  .support-home-shortcut-hint {\\n    font-size: 12px;\\n    color: var(--widget-text-muted);\\n  }\\n\\n  .support-home-shortcut-arrow {\\n    width: 18px;\\n    height: 18px;\\n    stroke: #9ca3af;\\n    fill: none;\\n    flex-shrink: 0;\\n  }\\n\\n  /* Engineering tickets section on home */\\n  .support-engineering-tickets {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 8px;\\n    margin-top: 20px;\\n  }\\n\\n  .support-engineering-tickets-heading {\\n    font-size: 12px;\\n    font-weight: 600;\\n    text-transform: uppercase;\\n    letter-spacing: 0.04em;\\n    color: var(--widget-text-muted);\\n    padding: 0 4px;\\n  }\\n\\n  .support-engineering-ticket-card {\\n    display: flex;\\n    align-items: center;\\n    gap: 12px;\\n    width: 100%;\\n    padding: 12px 14px;\\n    border-radius: 12px;\\n    background: var(--widget-surface);\\n    border: 1px solid var(--widget-border);\\n    cursor: pointer;\\n    text-align: left;\\n    font-family: inherit;\\n    transition: border-color 0.15s ease, transform 0.1s ease;\\n  }\\n\\n  .support-engineering-ticket-card:hover {\\n    border-color: var(--support-primary-color);\\n  }\\n\\n  .support-engineering-ticket-card:active {\\n    transform: scale(0.98);\\n  }\\n\\n  .support-engineering-ticket-icon {\\n    width: 36px;\\n    height: 36px;\\n    border-radius: 50%;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    flex-shrink: 0;\\n    background: rgba(var(--support-primary-rgb), 0.1);\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-engineering-ticket-icon svg {\\n    width: 18px;\\n    height: 18px;\\n  }\\n\\n  .support-engineering-ticket-text {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 4px;\\n    flex: 1;\\n    min-width: 0;\\n  }\\n\\n  .support-engineering-ticket-message {\\n    font-size: 13px;\\n    font-weight: 500;\\n    color: var(--widget-text);\\n    line-height: 1.35;\\n    display: -webkit-box;\\n    -webkit-line-clamp: 2;\\n    -webkit-box-orient: vertical;\\n    overflow: hidden;\\n  }\\n\\n  .support-engineering-ticket-status {\\n    display: inline-flex;\\n    align-self: flex-start;\\n    align-items: center;\\n    padding: 2px 8px;\\n    border-radius: 10px;\\n    font-size: 11px;\\n    font-weight: 600;\\n    background: rgba(107, 114, 128, 0.12);\\n    color: #374151;\\n  }\\n\\n  .support-engineering-ticket-status.open {\\n    background: rgba(59, 130, 246, 0.12);\\n    color: #2563eb;\\n  }\\n\\n  .support-engineering-ticket-status.in_progress {\\n    background: rgba(245, 158, 11, 0.12);\\n    color: #d97706;\\n  }\\n\\n  .support-engineering-ticket-status.blocked {\\n    background: rgba(239, 68, 68, 0.12);\\n    color: #dc2626;\\n  }\\n\\n  .support-engineering-ticket-status.resolved {\\n    background: rgba(16, 185, 129, 0.12);\\n    color: #059669;\\n  }\\n\\n  .support-engineering-ticket-status.closed {\\n    background: rgba(107, 114, 128, 0.12);\\n    color: #6b7280;\\n  }\\n\\n  .support-engineering-ticket-arrow {\\n    width: 18px;\\n    height: 18px;\\n    stroke: #9ca3af;\\n    fill: none;\\n    flex-shrink: 0;\\n  }\\n\\n  /* Ticket detail bottom sheet — opened from a home-screen ticket card */\\n  .support-ticket-sheet-scrim {\\n    position: absolute;\\n    inset: 0;\\n    background: rgba(17, 24, 39, 0.35);\\n    opacity: 0;\\n    transition: opacity 0.25s ease;\\n    z-index: 40;\\n  }\\n\\n  .support-ticket-sheet-scrim.is-visible {\\n    opacity: 1;\\n  }\\n\\n  .support-ticket-sheet {\\n    position: absolute;\\n    left: 0;\\n    right: 0;\\n    bottom: 0;\\n    z-index: 41;\\n    display: flex;\\n    flex-direction: column;\\n    max-height: 82%;\\n    padding-bottom: 8px;\\n    background: var(--widget-surface);\\n    border-radius: 18px 18px 0 0;\\n    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.18);\\n    transform: translateY(100%);\\n    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);\\n  }\\n\\n  .support-ticket-sheet.is-visible {\\n    transform: translateY(0);\\n  }\\n\\n  .support-ticket-sheet-grip {\\n    width: 40px;\\n    height: 4px;\\n    flex-shrink: 0;\\n    margin: 10px auto 4px;\\n    border-radius: 2px;\\n    background: var(--widget-border);\\n  }\\n\\n  .support-ticket-sheet-content {\\n    padding: 10px 20px 20px;\\n    overflow-y: auto;\\n  }\\n\\n  .support-ticket-sheet-meta {\\n    display: flex;\\n    align-items: center;\\n    gap: 10px;\\n    margin-bottom: 12px;\\n  }\\n\\n  .support-ticket-sheet-status {\\n    display: inline-flex;\\n    align-items: center;\\n    padding: 2px 8px;\\n    border-radius: 10px;\\n    font-size: 11px;\\n    font-weight: 600;\\n    background: rgba(107, 114, 128, 0.12);\\n    color: #374151;\\n  }\\n\\n  .support-ticket-sheet-status.open {\\n    background: rgba(59, 130, 246, 0.12);\\n    color: #2563eb;\\n  }\\n\\n  .support-ticket-sheet-status.in_progress {\\n    background: rgba(245, 158, 11, 0.12);\\n    color: #d97706;\\n  }\\n\\n  .support-ticket-sheet-status.blocked {\\n    background: rgba(239, 68, 68, 0.12);\\n    color: #dc2626;\\n  }\\n\\n  .support-ticket-sheet-status.resolved {\\n    background: rgba(16, 185, 129, 0.12);\\n    color: #059669;\\n  }\\n\\n  .support-ticket-sheet-status.closed {\\n    background: rgba(107, 114, 128, 0.12);\\n    color: #6b7280;\\n  }\\n\\n  .support-ticket-sheet-title {\\n    margin: 0 0 14px;\\n    font-size: 18px;\\n    font-weight: 700;\\n    line-height: 1.3;\\n    letter-spacing: -0.01em;\\n    color: var(--widget-text);\\n  }\\n\\n  .support-ticket-sheet-body-label {\\n    margin-bottom: 8px;\\n    font-size: 11px;\\n    font-weight: 700;\\n    text-transform: uppercase;\\n    letter-spacing: 0.05em;\\n    color: var(--widget-text-muted);\\n  }\\n\\n  .support-ticket-sheet-desc {\\n    font-size: 14px;\\n    line-height: 1.6;\\n    color: var(--widget-text);\\n    white-space: pre-wrap;\\n    overflow-wrap: anywhere;\\n  }\\n\\n  .support-ticket-sheet-cta {\\n    display: flex;\\n    align-items: center;\\n    gap: 12px;\\n    width: 100%;\\n    margin-top: 20px;\\n    padding: 14px 16px;\\n    border-radius: 12px;\\n    background: rgba(var(--support-primary-rgb), 0.08);\\n    border: 1px solid rgba(var(--support-primary-rgb), 0.25);\\n    color: var(--support-primary-color);\\n    font-family: inherit;\\n    font-size: 14px;\\n    font-weight: 600;\\n    text-align: left;\\n    cursor: pointer;\\n    transition: background 0.15s ease;\\n  }\\n\\n  .support-ticket-sheet-cta:hover {\\n    background: rgba(var(--support-primary-rgb), 0.14);\\n  }\\n\\n  .support-ticket-sheet-cta-icon {\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    width: 34px;\\n    height: 34px;\\n    flex-shrink: 0;\\n    border-radius: 50%;\\n    background: var(--support-primary-color);\\n    color: #fff;\\n  }\\n\\n  .support-ticket-sheet-cta-icon svg {\\n    width: 18px;\\n    height: 18px;\\n  }\\n\\n  .support-ticket-sheet-cta-label {\\n    flex: 1;\\n  }\\n\\n  .support-ticket-sheet-cta-arrow {\\n    display: flex;\\n    flex-shrink: 0;\\n  }\\n\\n  .support-ticket-sheet-cta-arrow svg {\\n    width: 18px;\\n    height: 18px;\\n  }\\n\\n  .support-ticket-sheet-nolink {\\n    display: flex;\\n    align-items: center;\\n    gap: 12px;\\n    margin-top: 20px;\\n    padding: 14px 16px;\\n    border-radius: 12px;\\n    background: var(--widget-bg);\\n    border: 1px dashed var(--widget-border);\\n    color: var(--widget-text-muted);\\n    font-size: 13px;\\n    line-height: 1.4;\\n  }\\n\\n  .support-ticket-sheet-nolink-icon {\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    width: 34px;\\n    height: 34px;\\n    flex-shrink: 0;\\n    border-radius: 50%;\\n    background: var(--widget-surface-hover);\\n    color: #9ca3af;\\n  }\\n\\n  .support-ticket-sheet-nolink-icon svg {\\n    width: 18px;\\n    height: 18px;\\n  }\\n\\n  /* \"Your progress\" onboarding checklist — sits on the hero like the onboarding card */\\n  .support-progress-card {\\n    margin: -44px 0 20px;\\n    padding: 16px;\\n    display: flex;\\n    flex-direction: column;\\n    gap: 10px;\\n    background: var(--widget-surface);\\n    border: 1px solid var(--widget-border);\\n    border-radius: 14px;\\n    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);\\n    position: relative;\\n    z-index: 1;\\n  }\\n\\n  .support-progress-card + .support-onboarding-card {\\n    margin-top: 0;\\n  }\\n\\n  .support-progress-header {\\n    display: flex;\\n    align-items: center;\\n    justify-content: space-between;\\n    gap: 8px;\\n  }\\n\\n  .support-progress-title {\\n    font-size: 15px;\\n    font-weight: 700;\\n    color: var(--widget-text);\\n  }\\n\\n  .support-progress-count {\\n    padding: 2px 8px;\\n    border-radius: 999px;\\n    background: rgba(var(--support-primary-rgb), 0.12);\\n    color: var(--support-primary-color);\\n    font-size: 12px;\\n    font-weight: 700;\\n    white-space: nowrap;\\n  }\\n\\n  .support-progress-bar {\\n    display: flex;\\n    gap: 4px;\\n  }\\n\\n  .support-progress-segment {\\n    flex: 1;\\n    height: 8px;\\n    border-radius: 4px;\\n    background: rgba(var(--support-primary-rgb), 0.12);\\n  }\\n\\n  .support-progress-segment.is-done {\\n    background: var(--support-primary-color);\\n  }\\n\\n  .support-progress-segment.is-next {\\n    animation: progressNextPulse 1.6s ease-in-out infinite;\\n  }\\n\\n  .support-progress-segment.just-done {\\n    animation: progressSegmentFill 0.6s ease-out;\\n    transform-origin: left;\\n  }\\n\\n  .support-progress-motivation {\\n    font-size: 12px;\\n    font-weight: 600;\\n    color: var(--widget-text-muted);\\n  }\\n\\n  .support-progress-next {\\n    display: flex;\\n    flex-direction: column;\\n    align-items: stretch;\\n    gap: 6px;\\n    padding: 14px;\\n    border-radius: 12px;\\n    background: rgba(var(--support-primary-rgb), 0.06);\\n  }\\n\\n  .support-progress-next.is-done {\\n    flex-direction: row;\\n    align-items: center;\\n    gap: 10px;\\n  }\\n\\n  .support-progress-trophy {\\n    font-size: 24px;\\n    line-height: 1;\\n  }\\n\\n  .support-progress-all-done {\\n    font-size: 14px;\\n    font-weight: 700;\\n    color: var(--widget-text);\\n  }\\n\\n  .support-progress-next-label {\\n    font-size: 11px;\\n    font-weight: 700;\\n    text-transform: uppercase;\\n    letter-spacing: 0.05em;\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-progress-next-name {\\n    font-size: 15px;\\n    font-weight: 700;\\n    color: var(--widget-text);\\n  }\\n\\n  .support-progress-next-meter {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n  }\\n\\n  .support-progress-next-track {\\n    flex: 1;\\n    height: 6px;\\n    border-radius: 3px;\\n    background: rgba(var(--support-primary-rgb), 0.15);\\n    overflow: hidden;\\n  }\\n\\n  .support-progress-next-fill {\\n    height: 100%;\\n    border-radius: 3px;\\n    background: var(--support-primary-color);\\n  }\\n\\n  .support-progress-next-count,\\n  .support-progress-item-count {\\n    font-size: 12px;\\n    font-weight: 600;\\n    color: var(--widget-text-muted);\\n    white-space: nowrap;\\n  }\\n\\n  .support-progress-start {\\n    flex-shrink: 0;\\n    padding: 5px 10px;\\n    border-radius: 8px;\\n    border: 1px solid rgba(var(--support-primary-rgb), 0.35);\\n    background: transparent;\\n    color: var(--support-primary-color);\\n    font-family: inherit;\\n    font-size: 12px;\\n    font-weight: 600;\\n    cursor: pointer;\\n    transition: transform 0.1s ease, background 0.15s ease;\\n  }\\n\\n  .support-progress-start:hover:not(:disabled) {\\n    background: rgba(var(--support-primary-rgb), 0.08);\\n  }\\n\\n  .support-progress-start.primary {\\n    margin-top: 4px;\\n    padding: 9px 14px;\\n    border: none;\\n    background: var(--support-primary-color);\\n    color: #fff;\\n    font-size: 14px;\\n  }\\n\\n  .support-progress-start.primary:hover:not(:disabled) {\\n    background: var(--support-primary-color);\\n    opacity: 0.9;\\n  }\\n\\n  .support-progress-start:active:not(:disabled) {\\n    transform: scale(0.97);\\n  }\\n\\n  .support-progress-start:disabled {\\n    opacity: 0.5;\\n    cursor: default;\\n  }\\n\\n  .support-progress-stage {\\n    border: 1px solid var(--widget-border);\\n    border-radius: 12px;\\n    background: var(--widget-surface);\\n    overflow: hidden;\\n  }\\n\\n  .support-progress-stage summary {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n    min-height: 42px;\\n    padding: 8px 10px;\\n    list-style: none;\\n    cursor: pointer;\\n    border-radius: 10px;\\n  }\\n\\n  .support-progress-stage summary::-webkit-details-marker {\\n    display: none;\\n  }\\n\\n  .support-progress-stage.is-current summary {\\n    background: rgba(var(--support-primary-rgb), 0.06);\\n  }\\n\\n  .support-progress-stage.is-current {\\n    border-color: rgba(var(--support-primary-rgb), 0.3);\\n  }\\n\\n  .support-progress-stage-marker {\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    flex-shrink: 0;\\n    width: 26px;\\n    height: 26px;\\n    border: 2px solid var(--widget-border);\\n    border-radius: 50%;\\n    background: var(--widget-surface);\\n    color: var(--widget-text-muted);\\n    font-size: 12px;\\n    font-weight: 700;\\n  }\\n\\n  .support-progress-stage.is-current .support-progress-stage-marker,\\n  .support-progress-stage.is-complete .support-progress-stage-marker {\\n    border-color: var(--support-primary-color);\\n    background: var(--support-primary-color);\\n    color: #fff;\\n  }\\n\\n  .support-progress-stage-label {\\n    display: flex;\\n    flex: 1;\\n    min-width: 0;\\n    flex-direction: column;\\n    gap: 1px;\\n  }\\n\\n  .support-progress-stage-name {\\n    color: var(--widget-text);\\n    font-size: 13px;\\n    font-weight: 700;\\n    overflow-wrap: anywhere;\\n  }\\n\\n  .support-progress-stage-status {\\n    color: var(--widget-text-muted);\\n    font-size: 10px;\\n  }\\n\\n  .support-progress-stage.is-current .support-progress-stage-status,\\n  .support-progress-stage.is-complete .support-progress-stage-tally {\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-progress-stage-tally {\\n    color: var(--widget-text-muted);\\n    font-size: 12px;\\n    font-weight: 700;\\n    white-space: nowrap;\\n  }\\n\\n  .support-progress-stage summary::after {\\n    content: \\'▸\\';\\n    color: var(--widget-text-muted);\\n    font-size: 11px;\\n    transition: transform 0.15s ease;\\n  }\\n\\n  .support-progress-stage[open] summary::after {\\n    transform: rotate(90deg);\\n  }\\n\\n  .support-progress-stage > .support-progress-item {\\n    margin: 0 10px 10px;\\n    border-top: 1px solid var(--widget-border);\\n    padding: 10px 0 0;\\n  }\\n\\n  .support-progress-item {\\n    display: grid;\\n    grid-template-columns: 24px minmax(0, 1fr) auto;\\n    align-items: center;\\n    column-gap: 8px;\\n    row-gap: 2px;\\n    padding: 6px 0;\\n  }\\n\\n  .support-progress-item-mark {\\n    grid-column: 1;\\n    grid-row: 1 / span 2;\\n    box-sizing: border-box;\\n    width: 24px;\\n    height: 24px;\\n    border-radius: 50%;\\n    border: 2px solid var(--widget-border);\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n  }\\n\\n  .support-progress-item.is-done .support-progress-item-mark {\\n    border-color: var(--support-primary-color);\\n    background: var(--support-primary-color);\\n    color: #fff;\\n  }\\n\\n  .support-progress-item.just-done .support-progress-item-mark {\\n    animation: progressCheckPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);\\n  }\\n\\n  .support-progress-item-mark svg {\\n    width: 11px;\\n    height: 11px;\\n  }\\n\\n  .support-progress-item-name {\\n    grid-column: 2;\\n    grid-row: 1;\\n    min-width: 0;\\n    font-size: 13px;\\n    color: var(--widget-text);\\n  }\\n\\n  .support-progress-item-count {\\n    grid-column: 2;\\n    grid-row: 2;\\n  }\\n\\n  .support-progress-item .support-progress-start {\\n    grid-column: 3;\\n    grid-row: 1 / span 2;\\n    justify-self: end;\\n  }\\n\\n  .support-progress-item.is-done .support-progress-item-name {\\n    color: var(--widget-text-muted);\\n    text-decoration: line-through;\\n  }\\n\\n  .support-progress-secondary {\\n    padding: 8px 10px;\\n    border-radius: 10px;\\n  }\\n\\n  .support-progress-secondary.is-next {\\n    background: rgba(var(--support-primary-rgb), 0.06);\\n  }\\n\\n  .support-progress-item-why {\\n    grid-column: 2;\\n    grid-row: 2;\\n    display: -webkit-box;\\n    -webkit-box-orient: vertical;\\n    -webkit-line-clamp: 2;\\n    overflow: hidden;\\n    color: var(--widget-text-muted);\\n    font-size: 11px;\\n    line-height: 1.35;\\n  }\\n\\n  .support-progress-secondary:hover .support-progress-item-why,\\n  .support-progress-secondary:focus-within .support-progress-item-why {\\n    -webkit-line-clamp: unset;\\n  }\\n\\n  .support-progress-amplifier {\\n    display: grid;\\n    grid-template-columns: 14px minmax(0, 1fr) auto;\\n    align-items: center;\\n    column-gap: 8px;\\n    row-gap: 2px;\\n    margin: 0 10px 10px 42px;\\n  }\\n\\n  .support-progress-amplifier-mark {\\n    grid-column: 1;\\n    grid-row: 1;\\n    color: var(--widget-text-muted);\\n    font-size: 12px;\\n  }\\n\\n  .support-progress-amplifier-name {\\n    grid-column: 2;\\n    grid-row: 1;\\n    min-width: 0;\\n    color: var(--widget-text);\\n    font-size: 12px;\\n    font-weight: 600;\\n  }\\n\\n  .support-progress-amplifier-why {\\n    grid-column: 2;\\n    grid-row: 2;\\n    display: -webkit-box;\\n    -webkit-box-orient: vertical;\\n    -webkit-line-clamp: 2;\\n    overflow: hidden;\\n    color: var(--widget-text-muted);\\n    font-size: 11px;\\n    line-height: 1.35;\\n  }\\n\\n  .support-progress-amplifier:hover .support-progress-amplifier-why,\\n  .support-progress-amplifier:focus-within .support-progress-amplifier-why {\\n    -webkit-line-clamp: unset;\\n  }\\n\\n  .support-progress-amplifier .support-progress-start {\\n    grid-column: 3;\\n    grid-row: 1 / span 2;\\n  }\\n\\n  @keyframes progressNextPulse {\\n    0%, 100% { background: rgba(var(--support-primary-rgb), 0.12); }\\n    50% { background: rgba(var(--support-primary-rgb), 0.4); }\\n  }\\n\\n  @keyframes progressSegmentFill {\\n    from { transform: scaleX(0); }\\n    to { transform: scaleX(1); }\\n  }\\n\\n  @keyframes progressCheckPop {\\n    0% { transform: scale(0.4); }\\n    100% { transform: scale(1); }\\n  }\\n\\n  @media (prefers-reduced-motion: reduce) {\\n    .support-progress-segment.is-next,\\n    .support-progress-segment.just-done,\\n    .support-progress-item.just-done .support-progress-item-mark {\\n      animation: none;\\n    }\\n  }\\n\\n  /* Previous conversation (last closed ticket) — Intercom-style preview row */\\n  .support-last-ticket {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 8px;\\n    margin-top: 20px;\\n  }\\n\\n  .support-last-ticket-heading {\\n    font-size: 12px;\\n    font-weight: 600;\\n    text-transform: uppercase;\\n    letter-spacing: 0.04em;\\n    color: var(--widget-text-muted);\\n    padding: 0 4px;\\n  }\\n\\n  .support-last-ticket-card {\\n    display: flex;\\n    align-items: center;\\n    gap: 12px;\\n    width: 100%;\\n    padding: 12px 14px;\\n    border-radius: 12px;\\n    background: var(--widget-surface);\\n    border: 1px solid var(--widget-border);\\n    cursor: pointer;\\n    text-align: left;\\n    font-family: inherit;\\n    transition: border-color 0.15s ease, transform 0.1s ease;\\n  }\\n\\n  .support-last-ticket-card:hover {\\n    border-color: var(--support-primary-color);\\n  }\\n\\n  .support-last-ticket-card:active {\\n    transform: scale(0.98);\\n  }\\n\\n  .support-last-ticket-avatar {\\n    width: 36px;\\n    height: 36px;\\n    border-radius: 50%;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    flex-shrink: 0;\\n    overflow: hidden;\\n    background: rgba(var(--support-primary-rgb), 0.1);\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-last-ticket-avatar svg {\\n    width: 18px;\\n    height: 18px;\\n  }\\n\\n  .support-last-ticket-avatar img {\\n    width: 100%;\\n    height: 100%;\\n    object-fit: cover;\\n  }\\n\\n  .support-last-ticket-body {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 2px;\\n    flex: 1;\\n    min-width: 0;\\n  }\\n\\n  .support-last-ticket-row {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n  }\\n\\n  .support-last-ticket-title {\\n    font-size: 13px;\\n    font-weight: 600;\\n    color: var(--widget-text);\\n    line-height: 1.35;\\n    flex: 1;\\n    min-width: 0;\\n    white-space: nowrap;\\n    overflow: hidden;\\n    text-overflow: ellipsis;\\n  }\\n\\n  .support-last-ticket-meta {\\n    display: flex;\\n    align-items: center;\\n    gap: 6px;\\n    flex-shrink: 0;\\n  }\\n\\n  .support-last-ticket-time {\\n    font-size: 11px;\\n    color: var(--widget-text-muted);\\n  }\\n\\n  .support-last-ticket-preview {\\n    font-size: 12px;\\n    color: var(--widget-text-muted);\\n    line-height: 1.35;\\n    white-space: nowrap;\\n    overflow: hidden;\\n    text-overflow: ellipsis;\\n  }\\n\\n  .support-last-ticket-status {\\n    display: inline-flex;\\n    align-items: center;\\n    padding: 2px 8px;\\n    border-radius: 10px;\\n    font-size: 11px;\\n    font-weight: 600;\\n    background: rgba(16, 185, 129, 0.12);\\n    color: #059669;\\n  }\\n\\n  .support-last-ticket-status.closed {\\n    background: rgba(107, 114, 128, 0.12);\\n    color: #6b7280;\\n  }\\n\\n  .support-last-ticket-arrow {\\n    width: 18px;\\n    height: 18px;\\n    stroke: #9ca3af;\\n    fill: none;\\n    flex-shrink: 0;\\n  }\\n\\n  /* Messages view (unified sub-tabs for sessions + tickets) */\\n  .support-view[data-view=\"messages\"] {\\n    padding: 0;\\n  }\\n\\n  .support-messages-subtabs {\\n    display: flex;\\n    gap: 4px;\\n    padding: 10px 12px;\\n    border-bottom: 1px solid var(--widget-border);\\n    background: var(--widget-surface);\\n    flex-shrink: 0;\\n  }\\n\\n  .support-messages-subtab {\\n    flex: 1;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    gap: 6px;\\n    padding: 10px 12px;\\n    border: 0;\\n    background: transparent;\\n    color: var(--widget-text-muted);\\n    font-family: inherit;\\n    font-size: 13px;\\n    font-weight: 600;\\n    cursor: pointer;\\n    border-radius: 8px;\\n    transition: background 0.15s ease, color 0.15s ease;\\n  }\\n\\n  .support-messages-subtab:hover {\\n    background: rgba(var(--support-primary-rgb), 0.06);\\n  }\\n\\n  .support-messages-subtab.is-active {\\n    background: rgba(var(--support-primary-rgb), 0.12);\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-messages-subtab-badge {\\n    display: inline-flex;\\n    align-items: center;\\n    justify-content: center;\\n    min-width: 18px;\\n    height: 18px;\\n    padding: 0 5px;\\n    border-radius: 9px;\\n    background: #ef4444;\\n    color: #ffffff;\\n    font-size: 10px;\\n    font-weight: 700;\\n    line-height: 18px;\\n  }\\n\\n  .support-messages-list-wrap {\\n    flex: 1;\\n    min-height: 0;\\n    overflow-y: auto;\\n    padding: 8px;\\n  }\\n\\n  .support-messages-list-wrap[hidden] {\\n    display: none;\\n  }\\n\\n  .support-conversation-list {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 2px;\\n  }\\n\\n  .support-conversation-group {\\n    font-size: 11px;\\n    font-weight: 600;\\n    text-transform: uppercase;\\n    color: var(--widget-text-muted);\\n    padding: 12px 8px 4px 8px;\\n    letter-spacing: 0.04em;\\n  }\\n\\n  .support-conversation-item {\\n    display: flex;\\n    align-items: center;\\n    gap: 12px;\\n    width: 100%;\\n    padding: 12px;\\n    border-radius: 10px;\\n    border: 0;\\n    background: transparent;\\n    cursor: pointer;\\n    text-align: left;\\n    font-family: inherit;\\n    transition: background 0.15s ease;\\n  }\\n\\n  .support-conversation-item:hover {\\n    background: var(--widget-surface);\\n  }\\n\\n  .support-conversation-item-icon {\\n    width: 36px;\\n    height: 36px;\\n    border-radius: 50%;\\n    flex-shrink: 0;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    background: rgba(var(--support-primary-rgb), 0.1);\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-conversation-item-icon.ticket {\\n    background: rgba(16, 185, 129, 0.12);\\n    color: #10b981;\\n  }\\n\\n  .support-conversation-item-icon svg {\\n    width: 20px;\\n    height: 20px;\\n  }\\n\\n  .support-conversation-item-info {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 4px;\\n    flex: 1;\\n    min-width: 0;\\n  }\\n\\n  .support-conversation-item-desc {\\n    font-size: 14px;\\n    font-weight: 500;\\n    color: var(--widget-text);\\n    white-space: nowrap;\\n    overflow: hidden;\\n    text-overflow: ellipsis;\\n  }\\n\\n  .support-conversation-item-desc.voice {\\n    display: inline-flex;\\n    align-items: center;\\n    gap: 5px;\\n  }\\n\\n  .support-conversation-item-desc.voice svg {\\n    width: 13px;\\n    height: 13px;\\n    flex-shrink: 0;\\n    fill: currentColor;\\n  }\\n\\n  .support-conversation-item-meta {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n    font-size: 12px;\\n    color: var(--widget-text-muted);\\n  }\\n\\n  .support-conversation-item-badge {\\n    display: inline-flex;\\n    align-items: center;\\n    padding: 2px 8px;\\n    border-radius: 10px;\\n    font-size: 11px;\\n    font-weight: 600;\\n    text-transform: capitalize;\\n    background: rgba(107, 114, 128, 0.12);\\n    color: #374151;\\n  }\\n\\n  .support-conversation-item-badge.open,\\n  .support-conversation-item-badge.active {\\n    background: rgba(16, 185, 129, 0.12);\\n    color: #059669;\\n  }\\n\\n  .support-conversation-item-badge.closed,\\n  .support-conversation-item-badge.resolved {\\n    background: rgba(107, 114, 128, 0.12);\\n    color: #6b7280;\\n  }\\n\\n  .support-conversation-item-badge.escalated {\\n    background: rgba(245, 158, 11, 0.12);\\n    color: #d97706;\\n  }\\n\\n  .support-conversation-empty,\\n  .support-conversation-loading {\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    padding: 48px 16px;\\n    color: var(--widget-text-muted);\\n    font-size: 13px;\\n    text-align: center;\\n  }\\n\\n  .support-conversation-load-more {\\n    margin: 12px 8px 8px 8px;\\n    padding: 10px;\\n    border: 1px solid var(--widget-border);\\n    border-radius: 8px;\\n    background: transparent;\\n    color: var(--support-primary-color);\\n    font-size: 13px;\\n    font-weight: 600;\\n    cursor: pointer;\\n    font-family: inherit;\\n  }\\n\\n  .support-conversation-load-more:hover {\\n    background: rgba(var(--support-primary-rgb), 0.06);\\n  }\\n\\n  /* Releases stub screen */\\n  .support-releases-empty {\\n    display: flex;\\n    flex-direction: column;\\n    align-items: center;\\n    justify-content: center;\\n    height: 100%;\\n    padding: 48px 24px;\\n    text-align: center;\\n    color: var(--widget-text-muted);\\n  }\\n\\n  .support-releases-empty-icon {\\n    width: 56px;\\n    height: 56px;\\n    margin-bottom: 16px;\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-releases-empty-icon svg {\\n    width: 100%;\\n    height: 100%;\\n  }\\n\\n  .support-releases-empty-title {\\n    margin: 0 0 8px 0;\\n    font-size: 18px;\\n    font-weight: 700;\\n    color: var(--widget-text);\\n  }\\n\\n  .support-releases-empty-subtitle {\\n    margin: 0;\\n    font-size: 13px;\\n    line-height: 1.5;\\n  }\\n\\n  .support-releases-loading {\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    padding: 48px 16px;\\n    color: var(--widget-text-muted);\\n    font-size: 13px;\\n  }\\n\\n  .support-releases-list {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 10px;\\n    padding: 12px;\\n  }\\n\\n  .support-release-card {\\n    position: relative;\\n    background: var(--widget-surface);\\n    border: 1px solid var(--widget-border);\\n    border-radius: 12px;\\n    cursor: pointer;\\n    transition: border-color 0.15s ease, box-shadow 0.15s ease;\\n    font-family: inherit;\\n    overflow: hidden;\\n  }\\n\\n  .support-release-card::before {\\n    content: \\'\\';\\n    position: absolute;\\n    left: 0;\\n    top: 0;\\n    bottom: 0;\\n    width: 3px;\\n    background: var(--support-release-accent, #3b82f6);\\n  }\\n\\n  .support-release-card[data-category=\"announcement\"] { --support-release-accent: #3b82f6; }\\n  .support-release-card[data-category=\"event\"]        { --support-release-accent: #a855f7; }\\n  .support-release-card[data-category=\"feature\"]      { --support-release-accent: #10b981; }\\n  .support-release-card[data-category=\"update\"]       { --support-release-accent: #f59e0b; }\\n\\n  .support-release-card:hover {\\n    border-color: var(--support-release-accent, var(--support-primary-color));\\n  }\\n\\n  .support-release-card.is-read {\\n    opacity: 0.8;\\n  }\\n\\n  .support-release-card.is-expanded {\\n    border-color: var(--support-release-accent, var(--support-primary-color));\\n    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);\\n    cursor: default;\\n    opacity: 1;\\n  }\\n\\n  .support-release-header {\\n    display: flex;\\n    align-items: flex-start;\\n    gap: 12px;\\n    padding: 14px 14px 14px 18px;\\n  }\\n\\n  .support-release-header-text {\\n    flex: 1;\\n    min-width: 0;\\n  }\\n\\n  .support-release-meta {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n    font-size: 10px;\\n    font-weight: 600;\\n    color: #9ca3af;\\n    letter-spacing: 0.02em;\\n    margin-bottom: 6px;\\n  }\\n\\n  .support-release-category {\\n    display: inline-flex;\\n    align-items: center;\\n    padding: 2px 8px;\\n    border-radius: 999px;\\n    font-size: 10px;\\n    font-weight: 700;\\n    text-transform: uppercase;\\n    letter-spacing: 0.06em;\\n    border: 1px solid;\\n  }\\n\\n  .support-release-card[data-category=\"announcement\"] .support-release-category {\\n    background: #dbeafe;\\n    color: #1d4ed8;\\n    border-color: #bfdbfe;\\n  }\\n\\n  .support-release-card[data-category=\"event\"] .support-release-category {\\n    background: #f3e8ff;\\n    color: #7e22ce;\\n    border-color: #e9d5ff;\\n  }\\n\\n  .support-release-card[data-category=\"feature\"] .support-release-category {\\n    background: #d1fae5;\\n    color: #047857;\\n    border-color: #a7f3d0;\\n  }\\n\\n  .support-release-card[data-category=\"update\"] .support-release-category {\\n    background: #fef3c7;\\n    color: #b45309;\\n    border-color: #fde68a;\\n  }\\n\\n  .support-release-dot {\\n    display: none;\\n  }\\n\\n  .support-release-date {\\n    text-transform: uppercase;\\n  }\\n\\n  .support-release-title {\\n    margin: 0 0 4px 0;\\n    font-size: 14px;\\n    font-weight: 700;\\n    color: var(--widget-text);\\n    line-height: 1.3;\\n  }\\n\\n  .support-release-preview {\\n    margin: 0;\\n    font-size: 12px;\\n    line-height: 1.45;\\n    color: var(--widget-text-muted);\\n    display: -webkit-box;\\n    -webkit-line-clamp: 2;\\n    -webkit-box-orient: vertical;\\n    overflow: hidden;\\n  }\\n\\n  .support-release-card.is-expanded .support-release-preview {\\n    display: none;\\n  }\\n\\n  .support-release-thumb {\\n    width: 56px;\\n    height: 56px;\\n    flex-shrink: 0;\\n    border-radius: 8px;\\n    overflow: hidden;\\n    background: #f3f4f6;\\n  }\\n\\n  .support-release-thumb img {\\n    width: 100%;\\n    height: 100%;\\n    object-fit: cover;\\n    display: block;\\n  }\\n\\n  .support-release-card.is-expanded .support-release-thumb {\\n    display: none;\\n  }\\n\\n  .support-release-chevron {\\n    width: 16px;\\n    height: 16px;\\n    color: #9ca3af;\\n    flex-shrink: 0;\\n    margin-top: 4px;\\n    transition: transform 0.2s ease;\\n  }\\n\\n  .support-release-card.is-expanded .support-release-chevron {\\n    transform: rotate(180deg);\\n  }\\n\\n  .support-release-detail {\\n    padding: 0 16px 16px 16px;\\n    animation: supportReleaseExpand 0.25s ease-out;\\n  }\\n\\n  @keyframes supportReleaseExpand {\\n    from { opacity: 0; transform: translateY(-6px); }\\n    to   { opacity: 1; transform: translateY(0); }\\n  }\\n\\n  .support-release-image {\\n    margin: 0 0 12px 0;\\n    border-radius: 10px;\\n    overflow: hidden;\\n    aspect-ratio: 16 / 9;\\n    background: #f3f4f6;\\n  }\\n\\n  .support-release-image img {\\n    width: 100%;\\n    height: 100%;\\n    object-fit: cover;\\n    display: block;\\n  }\\n\\n  .support-release-body {\\n    font-size: 13px;\\n    line-height: 1.55;\\n    color: var(--widget-text);\\n  }\\n\\n  .support-release-body p {\\n    margin: 0 0 8px 0;\\n  }\\n\\n  .support-release-body p:last-child {\\n    margin-bottom: 0;\\n  }\\n\\n  .support-release-body a {\\n    color: var(--support-primary-color);\\n    text-decoration: none;\\n  }\\n\\n  .support-release-body a:hover {\\n    text-decoration: underline;\\n  }\\n\\n  .support-release-body code {\\n    background: #f3f4f6;\\n    padding: 1px 5px;\\n    border-radius: 4px;\\n    font-size: 12px;\\n    word-break: break-word;\\n    overflow-wrap: anywhere;\\n  }\\n\\n  .support-release-body pre {\\n    margin: 0 0 10px 0;\\n    padding: 10px 12px;\\n    background: #f3f4f6;\\n    border-radius: 8px;\\n    font-size: 12px;\\n    line-height: 1.5;\\n    overflow-x: auto;\\n    overscroll-behavior-x: contain;\\n    -webkit-overflow-scrolling: touch;\\n  }\\n\\n  .support-release-body pre code {\\n    display: block;\\n    background: none;\\n    padding: 0;\\n    border-radius: 0;\\n    font-size: inherit;\\n    white-space: pre;\\n    word-break: normal;\\n    overflow-wrap: normal;\\n  }\\n\\n  .support-release-body ul,\\n  .support-release-body ol {\\n    margin: 0 0 8px 0;\\n    padding-left: 20px;\\n  }\\n\\n  .support-release-cta {\\n    display: block;\\n    width: 100%;\\n    margin-top: 14px;\\n    padding: 10px 14px;\\n    background: var(--support-primary-color);\\n    color: var(--support-secondary-color);\\n    border: 0;\\n    border-radius: 8px;\\n    font-family: inherit;\\n    font-size: 13px;\\n    font-weight: 600;\\n    cursor: pointer;\\n    transition: filter 0.15s ease;\\n  }\\n\\n  .support-release-cta:hover {\\n    filter: brightness(1.08);\\n  }\\n\\n  .support-release-cta:active {\\n    filter: brightness(0.95);\\n  }\\n\\n  .support-release-cta-group {\\n    display: flex;\\n    gap: 8px;\\n    flex-wrap: wrap;\\n    margin-top: 14px;\\n  }\\n\\n  .support-release-cta-group .support-release-cta {\\n    flex: 1;\\n    margin-top: 0;\\n  }\\n\\n  .admin-mode .support-release-cta-test {\\n    background: var(--widget-user-bubble-bg);\\n    color: var(--widget-user-bubble-fg);\\n  }\\n\\n  .admin-mode .support-release-cta-test:hover {\\n    background: var(--support-primary-color);\\n    filter: none;\\n  }\\n\\n  .admin-mode .support-release-cta-configure {\\n    background: transparent;\\n    color: var(--widget-text);\\n    border: 1px solid rgba(69, 147, 248, 0.35);\\n  }\\n\\n  .admin-mode .support-release-cta-configure:hover {\\n    background: rgba(69, 147, 248, 0.12);\\n    filter: none;\\n  }\\n\\n  .admin-mode .support-release-cta-plan {\\n    background: transparent;\\n    color: var(--widget-text-muted);\\n    border: 1px solid var(--widget-border);\\n  }\\n\\n  .admin-mode .support-release-cta-plan:hover {\\n    background: var(--widget-surface-hover);\\n    color: var(--widget-text);\\n    filter: none;\\n  }\\n\\n  .support-release-badge {\\n    display: inline-flex;\\n    align-items: center;\\n    padding: 1px 7px;\\n    font-size: 10px;\\n    font-weight: 600;\\n    letter-spacing: 0.3px;\\n    text-transform: uppercase;\\n    border-radius: 10px;\\n    flex-shrink: 0;\\n    line-height: 1.4;\\n  }\\n\\n  .support-release-badge.ready {\\n    background: rgba(16, 185, 129, 0.15);\\n    color: #10B981;\\n    border: 1px solid rgba(16, 185, 129, 0.3);\\n  }\\n\\n  .support-release-badge.needs-config {\\n    background: rgba(245, 158, 11, 0.12);\\n    color: #F59E0B;\\n    border: 1px solid rgba(245, 158, 11, 0.3);\\n  }\\n\\n  .admin-mode .support-release-badge.ready {\\n    background: rgba(16, 185, 129, 0.12);\\n    color: #34D399;\\n    border-color: rgba(16, 185, 129, 0.35);\\n  }\\n\\n  .admin-mode .support-release-badge.needs-config {\\n    background: rgba(245, 158, 11, 0.1);\\n    color: #FBBF24;\\n    border-color: rgba(245, 158, 11, 0.35);\\n  }\\n\\n  .support-release-no-cta-notice {\\n    margin: 14px 0 0 0;\\n    padding: 10px 12px;\\n    font-size: 12px;\\n    line-height: 1.5;\\n    color: var(--widget-text-muted);\\n    background: var(--widget-surface-hover);\\n    border: 1px dashed var(--widget-border);\\n    border-radius: 8px;\\n  }\\n\\n  /* Tab bar unread dot / count badge */\\n  .support-tab {\\n    position: relative;\\n  }\\n\\n  .support-tab-badge {\\n    position: absolute;\\n    top: 4px;\\n    right: calc(50% - 18px);\\n    min-width: 16px;\\n    height: 16px;\\n    padding: 0 4px;\\n    border-radius: 8px;\\n    background: #ef4444;\\n    color: #ffffff;\\n    font-size: 10px;\\n    font-weight: 700;\\n    line-height: 16px;\\n    text-align: center;\\n    box-shadow: 0 0 0 2px var(--widget-surface);\\n    pointer-events: none;\\n  }\\n\\n  /* ============ NPS survey banner ============ */\\n  .support-nps-banner {\\n    position: fixed;\\n    bottom: 24px;\\n    left: 50%;\\n    transform: translateX(-50%);\\n    width: calc(100% - 32px);\\n    max-width: 440px;\\n    box-sizing: border-box;\\n    background: var(--widget-surface);\\n    color: var(--widget-text);\\n    border: 1px solid var(--widget-border);\\n    border-radius: 14px;\\n    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.10);\\n    padding: 18px 18px 14px;\\n    display: flex;\\n    flex-direction: column;\\n    gap: 12px;\\n    animation: nps-slide-up 0.28s ease-out;\\n    z-index: 999998;\\n  }\\n\\n  @keyframes nps-slide-up {\\n    from { opacity: 0; transform: translate(-50%, 16px); }\\n    to   { opacity: 1; transform: translate(-50%, 0); }\\n  }\\n\\n  .support-nps-header {\\n    display: flex;\\n    align-items: flex-start;\\n    gap: 12px;\\n  }\\n\\n  .support-nps-title-wrap {\\n    flex: 1;\\n    min-width: 0;\\n  }\\n\\n  .support-nps-title {\\n    margin: 0;\\n    font-size: 14px;\\n    font-weight: 600;\\n    line-height: 1.4;\\n    color: var(--widget-text);\\n  }\\n\\n  .support-nps-close {\\n    background: transparent;\\n    border: none;\\n    font-size: 20px;\\n    line-height: 1;\\n    color: var(--widget-text-muted);\\n    cursor: pointer;\\n    padding: 2px 8px;\\n    border-radius: 8px;\\n    align-self: flex-start;\\n  }\\n  .support-nps-close:hover {\\n    background: var(--widget-surface-hover);\\n    color: var(--widget-text);\\n  }\\n\\n  .support-nps-score-row {\\n    display: grid;\\n    grid-template-columns: repeat(11, 1fr);\\n    gap: 4px;\\n  }\\n\\n  .support-nps-score {\\n    appearance: none;\\n    background: var(--widget-surface);\\n    border: 1px solid var(--widget-border);\\n    color: var(--widget-text);\\n    font-size: 13px;\\n    font-weight: 600;\\n    height: 34px;\\n    border-radius: 8px;\\n    cursor: pointer;\\n    padding: 0;\\n    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;\\n  }\\n  .support-nps-score:hover {\\n    background: rgba(var(--support-primary-rgb), 0.06);\\n    border-color: rgba(var(--support-primary-rgb), 0.35);\\n  }\\n  .support-nps-score.selected {\\n    background: var(--support-primary-color);\\n    border-color: var(--support-primary-color);\\n    color: var(--support-secondary-color);\\n  }\\n  .support-nps-score:disabled {\\n    cursor: default;\\n    opacity: 0.55;\\n  }\\n  .support-nps-score:disabled:hover {\\n    background: var(--widget-surface);\\n    border-color: var(--widget-border);\\n  }\\n  .support-nps-score.selected:disabled {\\n    opacity: 1;\\n  }\\n\\n  .support-nps-anchors {\\n    display: flex;\\n    justify-content: space-between;\\n    font-size: 11px;\\n    color: var(--widget-text-muted);\\n    margin-top: -4px;\\n  }\\n\\n  .support-nps-subtitle {\\n    margin: 4px 0 0;\\n    font-size: 12px;\\n    color: var(--widget-text-muted);\\n    line-height: 1.4;\\n  }\\n\\n  .support-nps-step2-top {\\n    display: flex;\\n    align-items: center;\\n    justify-content: space-between;\\n    gap: 8px;\\n  }\\n\\n  .support-nps-step-label {\\n    display: inline-flex;\\n    align-items: center;\\n    gap: 6px;\\n    font-size: 11px;\\n    font-weight: 700;\\n    letter-spacing: 0.06em;\\n    text-transform: uppercase;\\n    color: var(--widget-text-muted);\\n  }\\n\\n  .support-nps-step-dot {\\n    width: 8px;\\n    height: 8px;\\n    border-radius: 50%;\\n    background: var(--support-primary-color);\\n    box-shadow: 0 0 0 3px rgba(var(--support-primary-rgb), 0.18);\\n  }\\n\\n  .support-nps-close-step2 {\\n    margin-left: auto;\\n  }\\n\\n  .support-nps-step2-title {\\n    margin: 6px 0 0;\\n    font-size: 16px;\\n    font-weight: 700;\\n    line-height: 1.3;\\n    color: var(--widget-text);\\n  }\\n\\n  .support-nps-step2-subline {\\n    margin: 6px 0 0;\\n    font-size: 13px;\\n    color: var(--widget-text-muted);\\n    line-height: 1.45;\\n  }\\n\\n  .support-nps-score-mark {\\n    display: inline-block;\\n    font-weight: 700;\\n    color: var(--support-primary-color);\\n  }\\n\\n  .support-nps-banner.step-2 {\\n    animation: nps-step-fade 0.2s ease-out;\\n  }\\n  @keyframes nps-step-fade {\\n    from { opacity: 0.4; transform: translate(-50%, 6px); }\\n    to   { opacity: 1; transform: translate(-50%, 0); }\\n  }\\n\\n  .support-nps-comment {\\n    width: 100%;\\n    box-sizing: border-box;\\n    min-height: 52px;\\n    resize: vertical;\\n    font: inherit;\\n    font-size: 13px;\\n    color: var(--widget-text);\\n    background: var(--widget-bg);\\n    border: 1px solid var(--widget-border);\\n    border-radius: 10px;\\n    padding: 8px 10px;\\n    outline: none;\\n    transition: border-color 0.12s ease, box-shadow 0.12s ease;\\n  }\\n  .support-nps-comment:focus {\\n    border-color: var(--support-primary-color);\\n    box-shadow: 0 0 0 3px rgba(var(--support-primary-rgb), 0.18);\\n  }\\n\\n  .support-nps-actions {\\n    display: flex;\\n    justify-content: flex-end;\\n    align-items: center;\\n    gap: 8px;\\n  }\\n\\n  .support-nps-submit {\\n    appearance: none;\\n    border: none;\\n    font: inherit;\\n    font-size: 13px;\\n    font-weight: 600;\\n    padding: 8px 16px;\\n    border-radius: 10px;\\n    cursor: pointer;\\n    background: var(--support-primary-color);\\n    color: var(--support-secondary-color);\\n    transition: filter 0.12s ease, background 0.12s ease, color 0.12s ease;\\n  }\\n  .support-nps-submit:hover:not(:disabled) {\\n    filter: brightness(0.95);\\n  }\\n  .support-nps-submit:disabled {\\n    background: var(--widget-border);\\n    color: var(--widget-text-muted);\\n    cursor: not-allowed;\\n  }\\n\\n  .support-nps-reply-hint {\\n    margin: -4px 0 0;\\n    font-size: 11px;\\n    color: var(--widget-text-muted);\\n    line-height: 1.4;\\n  }\\n\\n  .support-nps-thanks {\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    gap: 10px;\\n    padding: 10px 4px 6px;\\n  }\\n  .support-nps-check {\\n    width: 28px;\\n    height: 28px;\\n    border-radius: 50%;\\n    background: var(--support-primary-color);\\n    color: var(--support-secondary-color);\\n    display: inline-flex;\\n    align-items: center;\\n    justify-content: center;\\n    flex-shrink: 0;\\n  }\\n  .support-nps-thanks-text {\\n    font-size: 14px;\\n    font-weight: 600;\\n    color: var(--widget-text);\\n  }\\n\\n  /* ============ Activation form modal ============ */\\n  .support-activation-form-overlay {\\n    position: fixed;\\n    top: 0;\\n    left: 0;\\n    width: 100%;\\n    height: 100%;\\n    background: rgba(0, 0, 0, 0.5);\\n    z-index: 999998;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    padding: 16px;\\n    box-sizing: border-box;\\n    animation: activation-form-fade 0.2s ease-out;\\n  }\\n\\n  @keyframes activation-form-fade {\\n    from { opacity: 0; }\\n    to   { opacity: 1; }\\n  }\\n\\n  .support-activation-form-card {\\n    width: 100%;\\n    max-width: 440px;\\n    max-height: calc(var(--widget-viewport-height) * 0.85);\\n    overflow-y: auto;\\n    overscroll-behavior: contain;\\n    -webkit-overflow-scrolling: touch;\\n    box-sizing: border-box;\\n    background: var(--widget-surface);\\n    color: var(--widget-text);\\n    border: 1px solid var(--widget-border);\\n    border-radius: 14px;\\n    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);\\n    padding: 20px;\\n    display: flex;\\n    flex-direction: column;\\n    gap: 16px;\\n    animation: activation-form-slide-up 0.24s ease-out;\\n  }\\n\\n  @keyframes activation-form-slide-up {\\n    from { opacity: 0; transform: translateY(12px); }\\n    to   { opacity: 1; transform: translateY(0); }\\n  }\\n\\n  .support-activation-form-header {\\n    display: flex;\\n    align-items: flex-start;\\n    gap: 12px;\\n  }\\n\\n  .support-activation-form-title-wrap {\\n    flex: 1;\\n    min-width: 0;\\n  }\\n\\n  .support-activation-form-title {\\n    margin: 0;\\n    font-size: 15px;\\n    font-weight: 600;\\n    line-height: 1.4;\\n    color: var(--widget-text);\\n  }\\n\\n  .support-activation-form-subtitle {\\n    margin: 4px 0 0;\\n    font-size: 12px;\\n    color: var(--widget-text-muted);\\n    line-height: 1.4;\\n  }\\n\\n  .support-activation-form-close {\\n    background: transparent;\\n    border: none;\\n    font-size: 20px;\\n    line-height: 1;\\n    color: var(--widget-text-muted);\\n    cursor: pointer;\\n    padding: 2px 8px;\\n    border-radius: 8px;\\n    align-self: flex-start;\\n  }\\n  .support-activation-form-close:hover {\\n    background: var(--widget-surface-hover);\\n    color: var(--widget-text);\\n  }\\n\\n  .support-activation-form-questions {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 18px;\\n  }\\n\\n  .support-activation-form-question {\\n    display: flex;\\n    flex-direction: column;\\n    gap: 8px;\\n  }\\n\\n  .support-activation-form-prompt {\\n    font-size: 13px;\\n    font-weight: 600;\\n    color: var(--widget-text);\\n    line-height: 1.4;\\n  }\\n\\n  .support-activation-form-required {\\n    color: #ef4444;\\n    margin-left: 2px;\\n  }\\n\\n  .support-activation-form-error {\\n    font-size: 11px;\\n    color: #ef4444;\\n    line-height: 1.4;\\n    min-height: 0;\\n  }\\n\\n  .support-activation-form-actions {\\n    display: flex;\\n    justify-content: flex-end;\\n    align-items: center;\\n    gap: 8px;\\n  }\\n\\n  .support-activation-form-submit {\\n    appearance: none;\\n    border: none;\\n    font: inherit;\\n    font-size: 13px;\\n    font-weight: 600;\\n    padding: 9px 18px;\\n    border-radius: 10px;\\n    cursor: pointer;\\n    background: var(--support-primary-color);\\n    color: var(--support-secondary-color);\\n    transition: filter 0.12s ease, background 0.12s ease, color 0.12s ease;\\n  }\\n  .support-activation-form-submit:hover:not(:disabled) {\\n    filter: brightness(0.95);\\n  }\\n  .support-activation-form-submit:disabled {\\n    background: var(--widget-border);\\n    color: var(--widget-text-muted);\\n    cursor: not-allowed;\\n  }\\n\\n  .support-activation-form-decline {\\n    appearance: none;\\n    font: inherit;\\n    font-size: 13px;\\n    font-weight: 600;\\n    padding: 9px 18px;\\n    border-radius: 10px;\\n    cursor: pointer;\\n    background: transparent;\\n    color: var(--widget-text);\\n    border: 1px solid var(--widget-border);\\n    transition: background 0.12s ease, border-color 0.12s ease;\\n  }\\n  .support-activation-form-decline:hover:not(:disabled) {\\n    background: var(--widget-surface-hover);\\n  }\\n  .support-activation-form-decline:disabled {\\n    color: var(--widget-text-muted);\\n    cursor: not-allowed;\\n  }\\n\\n  .support-activation-form-submit-error {\\n    font-size: 12px;\\n    color: #ef4444;\\n    text-align: center;\\n    line-height: 1.4;\\n  }\\n\\n'+F,this.shadowRoot.appendChild(e)}createWidget(){this.container=document.createElement(\"div\"),this.container.className=\"support-widget-container\",\"bottom-right\"!==this.config.position&&this.container.classList.add(`position-${this.config.position}`);\"side-panel\"===this.config.displayMode&&(this.container.classList.add(\"side-panel-mode\"),this.container.classList.add(\"left\"===this.config.sidePanelSide?\"side-left\":\"side-right\")),this.config.adminMode&&this.container.classList.add(\"admin-mode\"),this.config.messagesOnly&&this.container.classList.add(\"messages-only\"),this.applyCustomColor(),this.container.innerHTML=`\\n      <button class=\"support-bubble\" aria-label=\"${this.translations.aria.openChat}\">\\n        <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n          <path d=\"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z\"/>\\n        </svg>\\n        <span class=\"support-unread-indicator hidden\"></span>\\n        <span class=\"support-bubble-close\" aria-label=\"${this.translations.aria.minimizeChat}\">\\n          <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n            <path d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\"/>\\n          </svg>\\n        </span>\\n      </button>\\n\\n      <button class=\"support-badge hidden\" aria-label=\"${this.translations.aria.openChat}\">\\n        <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n          <path d=\"M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z\"/>\\n        </svg>\\n        <span class=\"support-unread-indicator hidden\"></span>\\n      </button>\\n\\n      <div class=\"support-toast support-toast--corner\"></div>\\n\\n      <div class=\"support-chat-window\" data-active-view=\"home\">\\n        <div class=\"support-toast\"></div>\\n\\n        <div class=\"support-chat-header\">\\n          <div class=\"support-header-left\">\\n            <button class=\"support-back-to-menu-btn\" aria-label=\"${this.translations.aria.backToMenu}\">\\n              <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n                <path d=\"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z\"/>\\n              </svg>\\n            </button>\\n            <button class=\"support-new-chat-btn\" aria-label=\"${this.translations.aria.newChat}\" data-tooltip=\"${this.translations.tooltips.newAISession}\">\\n              <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n                <path d=\"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z\"/>\\n              </svg>\\n            </button>\\n            ${this.config.adminMode?`<button class=\"support-admin-back-btn\" aria-label=\"${this.translations.adminMode.backToHome}\"><svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z\"/></svg></button>`:\"\"}\\n            ${this.config.adminMode?`<button class=\"support-admin-plan-btn\" aria-label=\"${this.translations.onboarding.planTitle}\">${this.translations.onboarding.planTitle.split(\" \").map(e=>`<span>${e}</span>`).join(\"\")}</button>`:\"\"}\\n          </div>\\n          <div class=\"support-header-status\"></div>\\n          <div class=\"support-header-center\"></div>\\n          <div class=\"support-header-right\">\\n            ${this.config.adminMode?`<button class=\"support-admin-leave-btn\" aria-label=\"${this.translations.adminMode.leaveAdminMode}\" data-tooltip=\"${this.translations.adminMode.leaveAdminMode}\"><svg class=\"support-admin-leave-icon\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M17 7l-1.41 1.41L18.17 11H8v2h10.17l-2.58 2.58L17 17l5-5-5-5zM4 5h8V3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h8v-2H4V5z\"/></svg><svg class=\"support-admin-leave-spinner hidden\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"12\" cy=\"12\" r=\"9\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-dasharray=\"14 42\"/></svg></button>`:\"\"}\\n            <div class=\"support-menu-container\">\\n              <button class=\"support-menu-btn\" aria-label=\"${this.translations.aria.moreOptions}\">\\n                <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n                  <circle cx=\"12\" cy=\"5\" r=\"2\"/>\\n                  <circle cx=\"12\" cy=\"12\" r=\"2\"/>\\n                  <circle cx=\"12\" cy=\"19\" r=\"2\"/>\\n                </svg>\\n              </button>\\n              <div class=\"support-menu-dropdown hidden\">\\n                <button class=\"support-menu-item support-sound-toggle\">\\n                  <svg class=\"support-sound-on\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n                    <path d=\"M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z\"/>\\n                  </svg>\\n                  <svg class=\"support-sound-off hidden\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n                    <path d=\"M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z\"/>\\n                  </svg>\\n                  <span class=\"support-sound-label\">${this.translations.menu.soundNotifications}</span>\\n                </button>\\n                <button class=\"support-menu-item support-expand-toggle\">\\n                  <svg class=\"support-expand-icon\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n                    <path d=\"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z\"/>\\n                  </svg>\\n                  <svg class=\"support-collapse-icon hidden\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n                    <path d=\"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z\"/>\\n                  </svg>\\n                  <span class=\"support-expand-label\">${this.translations.menu.collapseWindow}</span>\\n                </button>\\n              </div>\\n            </div>\\n            <button class=\"support-close-btn\" aria-label=\"${this.translations.aria.closeChat}\">\\n              <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n                <path d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\"/>\\n              </svg>\\n            </button>\\n          </div>\\n        </div>\\n\\n        <div class=\"support-agent-banner hidden\">\\n          <div class=\"support-agent-banner-content\">\\n            <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" aria-hidden=\"true\">\\n              <path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\"/>\\n            </svg>\\n            <span>${this.translations.messages.talkingToHuman}</span>\\n          </div>\\n        </div>\\n\\n        <div class=\"support-view\" data-view=\"home\"></div>\\n        <div class=\"support-view\" data-view=\"messages\"></div>\\n        <div class=\"support-view\" data-view=\"releases\"></div>\\n\\n        <div class=\"support-chat-body\" id=\"support-chat-messages\">\\n        </div>\\n\\n        <nav class=\"support-tab-bar\"></nav>\\n\\n        <div class=\"support-chat-footer\">\\n          <div class=\"support-reply-preview hidden\"></div>\\n          <div class=\"support-attachment-preview hidden\"></div>\\n          <div class=\"support-input-container\">\\n            <input\\n              type=\"file\"\\n              class=\"support-file-input\"\\n              id=\"support-file-input\"\\n              accept=\"image/*,video/*,audio/*,.pdf,.doc,.docx,.txt,.xls,.xlsx,.ppt,.pptx,.csv\"\\n              multiple\\n              hidden\\n            />\\n            <button class=\"support-attach-btn\" aria-label=\"${this.translations.aria.attachFile}\" title=\"${this.translations.aria.attachFile}\">\\n              <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n                <path d=\"M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z\"/>\\n              </svg>\\n            </button>\\n            <textarea\\n              class=\"support-chat-input\"\\n              placeholder=\"${this.translations.placeholders.typeMessage}\"\\n              aria-label=\"${this.translations.aria.messageInput}\"\\n              rows=\"1\"\\n            ></textarea>\\n            <button class=\"support-send-btn\" aria-label=\"${this.translations.aria.sendMessage}\">\\n              <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"currentColor\">\\n                <path d=\"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z\" fill=\"currentColor\"/>\\n              </svg>\\n            </button>\\n            <button class=\"support-mic-btn\" aria-label=\"${this.translations.voiceNotes.record}\" title=\"${this.translations.voiceNotes.record}\" hidden>\\n              <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"currentColor\">\\n                <path d=\"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.91-3c-.49 0-.9.36-.98.85C16.52 14.2 14.47 16 12 16s-4.52-1.8-4.93-4.15c-.08-.49-.49-.85-.98-.85-.61 0-1.09.54-1 1.14.49 3 2.89 5.35 5.91 5.78V20c0 .55.45 1 1 1s1-.45 1-1v-2.08c3.02-.43 5.42-2.78 5.91-5.78.1-.6-.39-1.14-1-1.14z\"/>\\n              </svg>\\n            </button>\\n          </div>\\n          <a\\n            href=\"https://blar.io\"\\n            target=\"_blank\"\\n            rel=\"noopener noreferrer\"\\n            class=\"support-branding ${this.config.showBranding?\"\":\"hidden\"}\"\\n            aria-label=\"${this.translations.aria.poweredBy}\"\\n          >\\n            <span class=\"support-branding-logo\">${I}</span>\\n            <span class=\"support-branding-text\">${this.translations.branding.poweredBy}</span>\\n          </a>\\n        </div>\\n      </div>\\n    `,this.shadowRoot.appendChild(this.container),document.body.appendChild(this.shadowHost)}setAdminStepActive(e){e?this.container.classList.add(\"admin-step-active\"):this.container.classList.remove(\"admin-step-active\")}setEntityContext(e){const t=this.container.querySelector(\".support-header-center\");t&&(t.setAttribute(\"aria-live\",\"polite\"),t.classList.toggle(\"entity-active\",null!==e),t.innerHTML=e?\"loading\"in e?'\\n        <span class=\"support-entity-action support-entity-skeleton\"></span>\\n        <span class=\"support-entity-title support-entity-skeleton\"></span>\\n      ':`\\n      <span class=\"support-entity-action\">${this.escapeHtml(e.action)}</span>\\n      <span class=\"support-entity-title\" title=\"${this.escapeHtml(e.title)}\">${this.escapeHtml(e.title)}</span>\\n    `:\"\")}setAdminInputPlaceholder(e){const t=this.container.querySelector(\".support-chat-input\");t&&(t.placeholder=e)}escapeHtml(e){const t=document.createElement(\"div\");return t.textContent=e,t.innerHTML}applyCustomColor(){const e=this.config.primaryColor;this.container.style.setProperty(\"--support-primary-color\",e),this.container.style.setProperty(\"--support-primary-rgb\",S(e)),this.container.style.setProperty(\"--support-primary-dark\",C(e,25)),this.container.style.setProperty(\"--support-secondary-color\",this.config.secondaryColor)}updateConnectionIndicator(e){}updatePresenceIndicator(e){const t=this.container.querySelector(\".support-presence-indicator\");if(!t)return;if(0===e.length)return t.classList.add(\"hidden\"),void(t.innerHTML=\"\");let n;n=1===e.length?`${e[0].name} ${this.translations.messages.viewing}`:2===e.length?`${e[0].name} ${this.translations.messages.and} ${e[1].name} ${this.translations.messages.viewing}`:`${e[0].name} ${this.translations.messages.and} ${e.length-1} ${this.translations.messages.others} ${this.translations.messages.viewing}`,t.innerHTML=`\\n      <svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" fill=\"none\" class=\"support-presence-dot\">\\n        <circle cx=\"4\" cy=\"4\" r=\"4\" fill=\"#10b981\"/>\\n      </svg>\\n      <span class=\"support-presence-text\">${n}</span>\\n    `,t.classList.remove(\"hidden\")}showAgentBanner(){const e=this.container.querySelector(\".support-agent-banner\"),t=e?.querySelector(\".support-agent-banner-content\");e&&t&&(e.classList.remove(\"other-tab\"),t.innerHTML=`\\n      <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill=\"currentColor\" aria-hidden=\"true\">\\n        <path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\"/>\\n      </svg>\\n      <span>${this.translations.messages.talkingToHuman}</span>\\n    `,e.classList.remove(\"hidden\"))}showOtherTabAgentBanner(e,t,n){const i=this.container.querySelector(\".support-agent-banner\"),s=i?.querySelector(\".support-agent-banner-content\");if(!i||!s)return;const r=this.translations.messages;i.classList.add(\"other-tab\"),s.innerHTML=`\\n      <span>${this.escapeHtml(r.agentInOtherTab(e))}</span>\\n      <button type=\"button\" class=\"support-agent-banner-action\" data-action=\"bring\">${r.bringAgentHere}</button>\\n      <button type=\"button\" class=\"support-agent-banner-action\" data-action=\"stop\">${r.stopAgentInOtherTab}</button>\\n    `,i.querySelector('[data-action=\"bring\"]')?.addEventListener(\"click\",t),i.querySelector('[data-action=\"stop\"]')?.addEventListener(\"click\",n),i.classList.remove(\"hidden\")}hideAgentBanner(){const e=this.container.querySelector(\".support-agent-banner\");e&&e.classList.add(\"hidden\")}showWaitingBadge(e){const t=this.container.querySelector(\".support-chat-body\");t&&(this.hideWaitingBadge(),this.waitingBadgeElement=document.createElement(\"div\"),this.waitingBadgeElement.className=\"support-waiting-badge\",this.waitingBadgeElement.textContent=e||this.translations.messages.waitingForAgent||\"A member of the Support team will help you.\",t.appendChild(this.waitingBadgeElement))}hideWaitingBadge(){const e=this.waitingBadgeElement;this.waitingBadgeElement=null,e&&(e.classList.add(\"hidden\"),setTimeout(()=>{os(e)},300))}setBranding(e){this.config.showBranding=e;const t=this.container.querySelector(\".support-branding\");t&&(e?t.classList.remove(\"hidden\"):t.classList.add(\"hidden\"))}isBrandingVisible(){return this.config.showBranding}setPosition(e){this.container.classList.remove(\"position-bottom-right\",\"position-bottom-left\",\"position-top-right\",\"position-top-left\"),this.config.position=e,\"bottom-right\"!==e&&this.container.classList.add(`position-${e}`)}setColor(e){this.config.primaryColor=e,this.applyCustomColor()}setSecondaryColor(e){this.config.secondaryColor=e,this.applyCustomColor()}getContainer(){return this.container}resolveLauncherVisibility(){const e=this.agentHidden||this.chatOnly,t=this.apiHidden||this.configHidden,n=!e&&(!t||this.revealedForUnread);this.container.style.display=this.apiHidden&&!this.revealedForUnread?\"none\":\"block\";const i=this.container.querySelector(\".support-bubble\"),s=this.container.querySelector(\".support-badge\"),r=n&&\"bubble\"===this.launcherMode,o=n&&\"badge\"===this.launcherMode;i?.classList.toggle(\"hidden\",!r),s?.classList.toggle(\"hidden\",!o)}show(){this.apiHidden=!1,this.revealedForUnread=!1,this.resolveLauncherVisibility()}hide(){this.apiHidden=!0,this.resolveLauncherVisibility()}revealWhileHidden(e){this.revealedForUnread=e,this.resolveLauncherVisibility()}isWidgetHidden(){return this.apiHidden||this.configHidden}setAiActive(e){const t=this.container.querySelector(\".support-chat-window\");t&&t.classList.toggle(\"ai-inactive\",!e)}hideCompletely(){const e=this.container.querySelector(\".support-chat-window\");this.configHidden=!0,e&&e.classList.remove(\"open\"),this.resolveLauncherVisibility()}showChatOnly(){const e=this.container.querySelector(\".support-chat-window\");this.chatOnly=!0,e&&e.classList.add(\"open\"),this.resolveLauncherVisibility()}restoreBubble(){this.chatOnly=!1,this.resolveLauncherVisibility()}isInSidePanelMode(){return\"side-panel\"===this.config.displayMode}getSidePanelExclude(){return\"side-panel\"!==this.config.displayMode?null:{side:this.config.sidePanelSide,width:h}}elevateForAgentMode(){this.shadowHost.style.zIndex=\"2147483640\"}resetAgentModeElevation(){this.shadowHost.style.zIndex=\"999999\"}pushContent(e){this.pushContentManager.push(e)}unpushContent(){this.pushContentManager.unpush()}hideForAgentMode(){const e=this.container.querySelector(\".support-chat-window\");this.agentModeContentWasPushed=this.pushContentManager.isPushed(),this.agentHidden=!0,e&&e.classList.remove(\"open\"),this.resolveLauncherVisibility(),this.agentModeContentWasPushed&&this.pushContentManager.unpush()}showFromAgentMode(){const e=this.container.querySelector(\".support-chat-window\");if(this.agentHidden=!1,e&&e.classList.add(\"open\"),this.resolveLauncherVisibility(),this.agentModeContentWasPushed){const t=e?.classList.contains(\"expanded\")?d:h;this.pushContentManager.push(t)}this.agentModeContentWasPushed=!1}destroy(){kd.release(\"ai-turn\"),this.toastTimer&&(clearTimeout(this.toastTimer),this.toastTimer=null),this.chatLoadingTimeout&&(clearTimeout(this.chatLoadingTimeout),this.chatLoadingTimeout=null),this.pushContentManager.destroy(),this.openChatObserver?.disconnect(),this.openChatObserver=null,this.viewportManager&&(this.viewportManager.destroy(),this.viewportManager=null),this.shadowHost&&os(this.shadowHost)}switchToBadgeMode(){this.launcherMode=\"badge\",this.resolveLauncherVisibility()}switchToBubbleMode(){this.launcherMode=\"bubble\",this.resolveLauncherVisibility()}isInBadgeMode(){return\"badge\"===this.launcherMode}showToast(e,t=\"success\",n=3e3){const i=this.container.querySelector(\".support-chat-window\"),s=this.container.querySelector(\".support-chat-window .support-toast\"),r=this.container.querySelector(\".support-toast--corner\");if(!s||!r)return;const o=!i?.classList.contains(\"open\"),a=o?r:s,l=o?s:r;this.toastTimer&&(clearTimeout(this.toastTimer),this.toastTimer=null),l.classList.remove(\"show\"),a.className=`support-toast ${o?\"support-toast--corner \":\"\"}${t}`,a.textContent=e,o&&a.style.setProperty(\"--support-toast-offset\",`${this.cornerToastOffset()}px`),requestAnimationFrame(()=>{a.classList.add(\"show\"),this.toastTimer=setTimeout(()=>{a.classList.remove(\"show\"),this.toastTimer=null},n)})}cornerToastOffset(){const e=Array.from(this.container.querySelectorAll(\".support-voice-call-card, .support-voice-call-pill, .support-screen-share-card\"));if(0===e.length)return 76;const t=this.container.getBoundingClientRect(),n=this.container.classList.contains(\"position-top-right\")||this.container.classList.contains(\"position-top-left\"),i=e.map(e=>{const i=e.getBoundingClientRect();return n?i.bottom-t.top:t.bottom-i.top});return Math.max(...i)+10}updateLanguage(e){this.translations=e;const t=this.container.querySelector(\".support-bubble\");t&&t.setAttribute(\"aria-label\",e.aria.openChat),this.container.querySelector(\".support-bubble-close\")?.setAttribute(\"aria-label\",e.aria.minimizeChat);const n=this.container.querySelector(\".support-close-btn\");n&&n.setAttribute(\"aria-label\",e.aria.closeChat);const i=this.container.querySelector(\".support-send-btn\");i&&i.setAttribute(\"aria-label\",e.aria.sendMessage);const s=this.container.querySelector(\".support-mic-btn\");s&&(s.setAttribute(\"aria-label\",e.voiceNotes.record),s.setAttribute(\"title\",e.voiceNotes.record));const r=this.container.querySelector(\".support-new-chat-btn\");r&&r.setAttribute(\"aria-label\",e.aria.newChat);const o=this.container.querySelector(\".support-menu-btn\");o&&o.setAttribute(\"aria-label\",e.aria.moreOptions);const a=this.container.querySelector(\".support-sound-label\");a&&(a.textContent=e.menu.soundNotifications);const l=this.container.querySelector(\".support-expand-label\");if(l){const t=this.container.querySelector(\".support-chat-window\");l.textContent=t?.classList.contains(\"expanded\")?e.menu.collapseWindow:e.menu.expandWindow}const c=this.container.querySelector(\".support-chat-input\");c&&(c.setAttribute(\"placeholder\",e.placeholders.typeMessage),c.setAttribute(\"aria-label\",e.aria.messageInput));const d=this.container.querySelector(\".support-branding-text\");d&&(d.textContent=e.branding.poweredBy);const u=this.container.querySelector(\".support-branding\");u&&u.setAttribute(\"aria-label\",e.aria.poweredBy)}showReplyPreview(e,t,n){const i=this.container.querySelector(\".support-reply-preview\");i&&(i.innerHTML=`\\n      <div class=\"support-reply-preview-body\">\\n        <span class=\"support-reply-preview-label\">${this.escapeHtml(this.translations.replies.replyingTo)} ${this.escapeHtml(e)}</span>\\n        <span class=\"support-reply-preview-text\">${this.escapeHtml(t)}</span>\\n      </div>\\n      <button class=\"support-reply-preview-cancel\" type=\"button\" aria-label=\"${this.translations.replies.cancel}\">\\n        <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n          <path d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\"/>\\n        </svg>\\n      </button>\\n    `,i.classList.remove(\"hidden\"),i.querySelector(\".support-reply-preview-cancel\")?.addEventListener(\"click\",n))}hideReplyPreview(){const e=this.container.querySelector(\".support-reply-preview\");e&&(e.innerHTML=\"\",e.classList.add(\"hidden\"))}showAttachmentPreview(e,t){const n=this.container.querySelector(\".support-attachment-preview\");if(!n)return;const i=e.map((e,t)=>{let n=\"\";if(e.type.startsWith(\"image/\")){n=`<img src=\"${URL.createObjectURL(e)}\" alt=\"${e.name}\" class=\"support-preview-image\" />`}else n='\\n          <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\" class=\"support-preview-icon\">\\n            <path d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8l-6-6z\"/>\\n            <path d=\"M14 2v6h6\"/>\\n          </svg>\\n        ';return`\\n        <div class=\"support-preview-item\" data-index=\"${t}\">\\n          <div class=\"support-preview-thumbnail\">${n}</div>\\n          <div class=\"support-preview-info\">\\n            <span class=\"support-preview-name\" title=\"${e.name}\">${e.name}</span>\\n            <span class=\"support-preview-size\">${i=e.size,i<1024?i+\" B\":i<1048576?(i/1024).toFixed(1)+\" KB\":(i/1048576).toFixed(1)+\" MB\"}</span>\\n          </div>\\n          <button class=\"support-preview-remove\" data-index=\"${t}\" aria-label=\"${this.translations.aria.removeFile}\">\\n            <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n              <path d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\"/>\\n            </svg>\\n          </button>\\n        </div>\\n      `;var i}).join(\"\");n.innerHTML=i,n.classList.remove(\"hidden\");n.querySelectorAll(\".support-preview-remove\").forEach(e=>{e.addEventListener(\"click\",()=>{const n=parseInt(e.getAttribute(\"data-index\")||\"0\");t(n)})})}hideAttachmentPreview(){const e=this.container.querySelector(\".support-attachment-preview\");if(!e)return;e.innerHTML=\"\",e.classList.add(\"hidden\");e.querySelectorAll(\".support-preview-image\").forEach(e=>{e.src.startsWith(\"blob:\")&&URL.revokeObjectURL(e.src)})}showUploadingState(){const e=this.container.querySelector(\".support-send-btn\");e&&(e.disabled=!0,e.classList.add(\"uploading\")),this.setComposerEnabled(!1)}hideUploadingState(){const e=this.container.querySelector(\".support-send-btn\");e&&(e.disabled=!1,e.classList.remove(\"uploading\")),this.aiThinkingActive||this.setComposerEnabled(!0)}isAIThinkingState(){return this.aiThinkingActive}setOnAIThinkingChange(e){this.onAIThinkingChange=e}setComposerEnabled(e){const t=this.container.querySelector(\".support-chat-input\"),n=this.container.querySelector(\".support-attach-btn\");t&&(t.disabled=!e),n&&(n.disabled=!e)}showAIThinkingState(){this.aiThinkingActive=!0,kd.hold(\"ai-turn\"),this.setComposerEnabled(!1);const e=this.container.querySelector(\".support-send-btn\");e&&(e.classList.add(\"ai-thinking\"),e.innerHTML='\\n        <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"currentColor\">\\n          <rect width=\"12\" height=\"12\" rx=\"1\"/>\\n        </svg>\\n      ',e.setAttribute(\"aria-label\",this.translations.aria.stopAI)),this.onAIThinkingChange?.()}hideAIThinkingState(){const e=this.aiThinkingActive;this.aiThinkingActive=!1,kd.release(\"ai-turn\"),this.setComposerEnabled(!0);const t=this.container.querySelector(\".support-send-btn\");t&&(t.classList.remove(\"ai-thinking\"),t.innerHTML='\\n        <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"currentColor\">\\n          <path d=\"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z\" fill=\"currentColor\"/>\\n        </svg>\\n      ',t.setAttribute(\"aria-label\",this.translations.aria.sendMessage)),this.onAIThinkingChange?.(),e&&!this.focusIsElsewhere()&&this.focusComposer()}focusComposer(){if(Sd()||this.agentHidden)return;const e=this.container.querySelector(\".support-chat-window\"),t=this.container.querySelector(\".support-chat-input\");e?.classList.contains(\"open\")&&t&&!t.disabled&&t.focus({preventScroll:!0})}focusIsElsewhere(){const e=document.activeElement;if(null===e||e===document.body)return!1;if(e!==this.shadowHost)return!0;const t=this.shadowRoot.activeElement;return null!==t&&null===t.closest(\".support-chat-footer\")}pulseSendButton(){const e=this.container.querySelector(\".support-send-btn\");e&&(e.classList.remove(\"pulse\"),e.offsetWidth,e.classList.add(\"pulse\"),window.setTimeout(()=>e.classList.remove(\"pulse\"),1e3))}setUnreadAnimation(e){this.config.unreadAnimation=e}getUnreadAnimation(){return this.config.unreadAnimation}applyBubbleAnimation(){const e=this.container.querySelector(\".support-bubble\");e&&(this.removeBubbleAnimation(),\"bounce\"===this.config.unreadAnimation?e.classList.add(\"animate-bounce\"):\"pulse\"===this.config.unreadAnimation&&e.classList.add(\"animate-pulse\"))}removeBubbleAnimation(){const e=this.container.querySelector(\".support-bubble\");e&&e.classList.remove(\"animate-bounce\",\"animate-pulse\")}getBubbleRect(){const e=this.container.querySelector(\".support-bubble\");if(!e||e.classList.contains(\"hidden\")){const e=this.container.querySelector(\".support-badge\");return e&&!e.classList.contains(\"hidden\")?e.getBoundingClientRect():null}return e.getBoundingClientRect()}getChatWindowRect(){const e=this.container.querySelector(\".support-chat-window\");return e?e.getBoundingClientRect():null}showConversationSelector(e,t,n){this.hideConversationSelector();const i=this.container.querySelector(\".support-chat-header\");if(!i)return;const s=document.createElement(\"div\");s.className=\"support-conversation-selector\";const r=n?.session||0,o=n?.ticket||0,a=document.createElement(\"button\");if(a.className=\"support-conversation-tab\"+(\"session\"===e?\" active\":\"\"),a.innerHTML=`\\n      <span class=\"support-conversation-tab-avatar\">\\n        <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"white\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${L}</svg>\\n      </span>\\n      <span>${this.translations.conversationSelector.aiConversation}</span>\\n      <span class=\"support-conversation-tab-badge${r>0?\"\":\" hidden\"}\" data-tab-type=\"session\">${r}</span>\\n    `,a.addEventListener(\"click\",()=>t(\"session\")),s.appendChild(a),!this.config.adminMode){const n=document.createElement(\"button\");n.className=\"support-conversation-tab\"+(\"ticket\"===e?\" active\":\"\"),n.innerHTML=`\\n        <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n          <path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\"/>\\n        </svg>\\n        <span>${this.translations.conversationSelector.humanConversation}</span>\\n        <span class=\"support-conversation-tab-badge${o>0?\"\":\" hidden\"}\" data-tab-type=\"ticket\">${o}</span>\\n      `,n.addEventListener(\"click\",()=>t(\"ticket\")),s.appendChild(n)}i.insertAdjacentElement(\"afterend\",s)}updateTabBadge(e,t){const n=this.container.querySelector(`.support-conversation-tab-badge[data-tab-type=\"${e}\"]`);n&&(t>0?(n.textContent=t>99?\"99+\":String(t),n.classList.remove(\"hidden\")):n.classList.add(\"hidden\"))}showConversationPicker(e,t){this.hideConversationPicker();const n=!1!==t?.showTicket&&!this.config.adminMode,i=this.container.querySelector(\".support-chat-body\");if(!i)return;i.style.display=\"none\";const s=this.container.querySelector(\".support-chat-footer\");s&&(s.style.display=\"none\");const r=document.createElement(\"div\");r.className=\"support-conversation-picker\";const o=document.createElement(\"p\");o.className=\"support-conversation-picker-title\",o.textContent=this.translations.conversationSelector.pickerTitle,r.appendChild(o);const a=document.createElement(\"div\");if(a.className=\"support-conversation-picker-card\",a.innerHTML=`\\n      <div class=\"support-conversation-picker-icon ai\">\\n        <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${L}</svg>\\n      </div>\\n      <div class=\"support-conversation-picker-text\">\\n        <span class=\"support-conversation-picker-label\">${this.translations.conversationSelector.aiConversation}</span>\\n        <span class=\"support-conversation-picker-desc\">${this.translations.conversationSelector.aiDescription}</span>\\n      </div>\\n    `,a.addEventListener(\"click\",()=>e(\"session\")),r.appendChild(a),n){const t=document.createElement(\"div\");t.className=\"support-conversation-picker-card\",t.innerHTML=`\\n        <div class=\"support-conversation-picker-icon human\">\\n          <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">${R}</svg>\\n        </div>\\n        <div class=\"support-conversation-picker-text\">\\n          <span class=\"support-conversation-picker-label\">${this.translations.conversationSelector.humanConversation}</span>\\n          <span class=\"support-conversation-picker-desc\">${this.translations.conversationSelector.humanDescription}</span>\\n        </div>\\n      `,t.addEventListener(\"click\",()=>e(\"ticket\")),r.appendChild(t)}i.insertAdjacentElement(\"afterend\",r)}hideConversationPicker(){const e=this.container.querySelector(\".support-conversation-picker\");e&&os(e);const t=this.container.querySelector(\".support-chat-body\");t&&(t.style.display=\"\");const n=this.container.querySelector(\".support-chat-footer\");n&&(n.style.display=\"\")}hideConversationSelector(){const e=this.container.querySelector(\".support-conversation-selector\");e&&os(e)}showArchiveButton(e){this.hideArchiveButton();const t=this.container.querySelector(\".support-header-actions\");if(!t)return;const n=document.createElement(\"button\");n.className=\"support-archive-btn\",n.setAttribute(\"data-tooltip\",this.translations.session.archiveAndNew),n.setAttribute(\"aria-label\",this.translations.session.archiveAndNew),n.innerHTML='\\n      <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n        <path d=\"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z\"/>\\n      </svg>\\n    ',n.addEventListener(\"click\",e);const i=t.querySelector(\".support-menu-container\");i?t.insertBefore(n,i):t.appendChild(n)}hideArchiveButton(){const e=this.container.querySelector(\".support-archive-btn\");e&&os(e)}showBackToPickerButton(e){this.hideBackToPickerButton();const t=this.container.querySelector(\".support-header-actions\");if(!t)return;const n=document.createElement(\"button\");n.className=\"support-archive-btn support-back-picker-btn\",n.setAttribute(\"data-tooltip\",this.translations.conversationSelector.backToPicker),n.setAttribute(\"aria-label\",this.translations.conversationSelector.backToPicker),n.innerHTML='\\n      <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n        <path d=\"M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z\"/>\\n      </svg>\\n    ',n.addEventListener(\"click\",e);const i=t.querySelector(\".support-menu-container\");i?t.insertBefore(n,i):t.appendChild(n)}hideBackToPickerButton(){const e=this.container.querySelector(\".support-back-picker-btn\");e&&os(e)}showChatLoading(){this.hideChatLoading();const e=this.container.querySelector(\".support-chat-window\");if(!e)return;const t=e.querySelector(\".support-chat-header\"),n=document.createElement(\"div\");n.className=\"support-chat-loading\",t?t.insertAdjacentElement(\"afterend\",n):e.appendChild(n),this.chatLoadingTimeout=setTimeout(()=>this.hideChatLoading(),15e3)}hideChatLoading(){this.chatLoadingTimeout&&(clearTimeout(this.chatLoadingTimeout),this.chatLoadingTimeout=null);const e=this.container.querySelector(\".support-chat-loading\");e&&os(e)}showAgentModeOverlay(e){const t=this.container.querySelector(\".support-chat-body\"),n=this.container.querySelector(\".support-chat-footer\"),i=this.container.querySelector(\".support-chat-window\");if(!t||!i)return;if(t.classList.add(\"history-blur\"),n&&n.classList.add(\"history-blur\"),!this.container.querySelector(\".support-history-backdrop\")){const e=document.createElement(\"div\");e.className=\"support-history-backdrop\",i.appendChild(e)}const s=document.createElement(\"div\");s.className=\"support-agent-mode-overlay\",s.textContent=e,i.appendChild(s)}hideAgentModeOverlay(){const e=this.container.querySelector(\".support-agent-mode-overlay\");e&&os(e);const t=this.container.querySelector(\".support-history-backdrop\");t&&os(t);const n=this.container.querySelector(\".support-chat-body\");n&&n.classList.remove(\"history-blur\");const i=this.container.querySelector(\".support-chat-footer\");i&&i.classList.remove(\"history-blur\"),this.hideChatLoading()}}class Ed{constructor(e){this.isOpen=!1,this.hasScrolledOnOpen=!1,this.isTicketClosed=!1,this.container=e,this.translations=Na()}getDefaultInputHTML(){return`\\n      <input\\n        type=\"file\"\\n        class=\"support-file-input\"\\n        id=\"support-file-input\"\\n        accept=\"image/*,video/*,audio/*,.pdf,.doc,.docx,.txt,.xls,.xlsx,.ppt,.pptx,.csv\"\\n        multiple\\n        hidden\\n      />\\n      <button class=\"support-attach-btn\" aria-label=\"${this.translations.aria.attachFile}\" title=\"${this.translations.aria.attachFile}\">\\n        <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n          <path d=\"M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z\"/>\\n        </svg>\\n      </button>\\n      <textarea\\n        class=\"support-chat-input\"\\n        placeholder=\"${this.translations.placeholders.typeMessage}\"\\n        aria-label=\"${this.translations.aria.messageInput}\"\\n        rows=\"1\"\\n      ></textarea>\\n      <button class=\"support-send-btn\" aria-label=\"${this.translations.aria.sendMessage}\">\\n        <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"currentColor\">\\n          <path d=\"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z\" fill=\"currentColor\"/>\\n        </svg>\\n      </button>\\n      <button class=\"support-mic-btn\" aria-label=\"${this.translations.voiceNotes.record}\" title=\"${this.translations.voiceNotes.record}\" hidden>\\n        <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"currentColor\">\\n          <path d=\"M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.91-3c-.49 0-.9.36-.98.85C16.52 14.2 14.47 16 12 16s-4.52-1.8-4.93-4.15c-.08-.49-.49-.85-.98-.85-.61 0-1.09.54-1 1.14.49 3 2.89 5.35 5.91 5.78V20c0 .55.45 1 1 1s1-.45 1-1v-2.08c3.02-.43 5.42-2.78 5.91-5.78.1-.6-.39-1.14-1-1.14z\"/>\\n        </svg>\\n      </button>\\n    `}toggle(){this.isOpen=!this.isOpen;const e=this.container.querySelector(\".support-chat-window\");if(this.isOpen)e.classList.add(\"open\"),window.matchMedia?.(\"(pointer: coarse)\").matches||setTimeout(()=>{const e=this.container.querySelector(\".support-chat-input\");e?.focus()},300);else{const t=this.container.getRootNode(),n=e.contains(t.activeElement);e.classList.remove(\"open\"),n&&this.container.querySelector(\".support-bubble:not(.hidden), .support-badge:not(.hidden)\")?.focus({preventScroll:!0})}}open(){this.isOpen||this.toggle()}close(){this.isOpen&&this.toggle()}isOpened(){return this.isOpen}shouldScrollOnOpen(){return!this.hasScrolledOnOpen&&(this.hasScrolledOnOpen=!0,!0)}resetScrollFlag(){this.hasScrolledOnOpen=!1}getInputElement(){return this.container.querySelector(\".support-chat-input\")}clearInput(){const e=this.getInputElement();e&&(e.value=\"\",e.style.height=\"40px\",e.style.overflowY=\"hidden\")}getMessagesContainer(){return this.container.querySelector(\"#support-chat-messages\")}setTicketClosed(e){this.isTicketClosed=e}isTicketClosedState(){return this.isTicketClosed}showClosedState(){this.isTicketClosed=!0,this.container.classList.add(\"conversation-read-only\");const e=this.container.querySelector(\".support-input-container\");if(!e)return;e.innerHTML=`\\n      <div class=\"support-closed-state\">\\n        <p class=\"support-closed-message\">${this.translations.messages.conversationClosed}</p>\\n        <button class=\"support-new-conversation-button\">${this.translations.buttons.startNewConversation}</button>\\n      </div>\\n    `;const t=e.querySelector(\".support-new-conversation-button\");t&&t.addEventListener(\"click\",()=>{const e=new CustomEvent(\"new-conversation\",{bubbles:!0});this.container.dispatchEvent(e)})}restoreInputState(){this.isTicketClosed=!1,this.container.classList.remove(\"conversation-read-only\");const e=this.container.querySelector(\".support-input-container\");e&&(e.innerHTML=this.getDefaultInputHTML(),e.style.display=\"\")}showNextStepButton(e,t){const n=this.container.querySelector(\".support-input-container\");if(!n)return;n.innerHTML=`\\n      <div class=\"support-next-step-state\">\\n        <button class=\"support-new-conversation-button support-next-step-button\">${this.escapeHtml(e)}</button>\\n      </div>\\n    `;const i=n.querySelector(\".support-next-step-button\");i?.addEventListener(\"click\",t)}isNextStepButtonVisible(){return!!this.container.querySelector(\".support-next-step-button\")}escapeHtml(e){const t=document.createElement(\"div\");return t.textContent=e,t.innerHTML}}const Md=1e3;let Ad=null,_d=null,Td=[],Id=0,Ld=0,Rd=null;function $d(){Rd=document.hidden?s():null}function Nd(){const e=Ld;return Ld=0,{visibility:document.hidden?\"hidden\":\"visible\",hidden_ms:null===Rd?0:s()-Rd,lag_ms:e,sdk_version:\"1.0.0+333a1e0\"}}function Pd(){if(!_d)return null;const e=performance.now()-5e3;return Td=Td.filter(t=>t.end>e),Math.round(Td.reduce((t,n)=>t+n.end-Math.max(n.start,e),0))}function Fd(e,t){if(e.bubble_message)return{bubbleMessage:e.bubble_message,kind:e.bubble_kind??t.bubbleKind,milestoneMessageId:t.milestoneMessageId,sessionId:t.sessionId,seq:t.seq,sender:e.bubble_sender?{name:e.bubble_sender.name,subtitle:e.bubble_sender.subtitle,avatarUrl:e.bubble_sender.avatar_url}:void 0,progress:e.bubble_progress?{total:e.bubble_progress.total,completed:e.bubble_progress.completed}:void 0,ctaLabel:e.bubble_cta_label??t.ctaLabel,decisionCard:t.decisionCard}}function Od(e,t){if(t)for(let n=e.length-1;n>=0;n--){const i=e[n];if((i.body??i.text)!==t)continue;const s=Hd(i);if(s)return s}}function qd(e,t,n){for(let i=e.length-1;i>=0;i--){const s=e[i];if(void 0!==t?s.metadata?.milestone_message_id===t:void 0!==n&&(s.body??s.text)===n)return s.seq}}function Hd(e){const t=e.metadata;if(!t||\"channel_continuation\"!==t.widget_bubble_kind||!0===t.resolved)return;const n=e.idempotency_key??t.idempotency_key,i=Array.isArray(t.decisions)?t.decisions:[],[s,r]=i.map(Bd);return\"string\"==typeof t.suggestion_type&&\"string\"==typeof n&&s&&r?{suggestionType:t.suggestion_type,idempotencyKey:n,accept:s,decline:r}:void 0}function Bd(e){if(!e||\"object\"!=typeof e)return;const{value:t,label:n}=e;return\"string\"==typeof t&&\"string\"==typeof n?{value:t,label:n}:void 0}const Dd=1006;class zd{constructor(e){this.onStale=e,this.lastFrameAt=0,this.timer=null}start(){this.stop(),this.lastFrameAt=s(),this.timer=setInterval(()=>{s()-this.lastFrameAt<45e3||(this.stop(),this.onStale())},5e3)}touch(){this.lastFrameAt=s()}stop(){null!==this.timer&&(clearInterval(this.timer),this.timer=null)}}const Ud=[\"ringing\",\"active\",\"ended\"],jd=[\"completed\",\"declined\",\"missed_timeout\",\"failed\",\"cancelled\"];function Wd(e){if(!(\"voice_call\"in e))return;const t=e.voice_call;return null===t?null:\"object\"!=typeof t||Array.isArray(t)?void 0:function(e){if(\"number\"!=typeof e.call_id)return null;if(\"string\"!=typeof e.status||!Ud.includes(e.status))return null;if(\"string\"!=typeof e.started_at||0===e.started_at.length)return null;const t={call_id:e.call_id,status:e.status,started_at:e.started_at,executive_name:\"string\"==typeof e.executive_name&&e.executive_name.length>0?e.executive_name:null};return\"string\"==typeof e.expires_at&&e.expires_at.length>0&&(t.expires_at=e.expires_at),t}(t)??void 0}function Vd(e){if(!e||\"object\"!=typeof e)return!1;const t=e;return\"number\"==typeof t.event_type_id&&\"string\"==typeof t.prompt&&[\"text_input\",\"radio\",\"checkbox\"].includes(String(t.input_type))&&\"boolean\"==typeof t.required&&\"boolean\"==typeof t.answered&&\"number\"==typeof t.position&&Array.isArray(t.options)&&t.options.every(Gd)}function Gd(e){if(!e||\"object\"!=typeof e)return!1;const t=e;return\"string\"==typeof t.value&&\"string\"==typeof t.label}const Kd=[\"requested\",\"accepted\",\"active\",\"ended\"],Yd=[\"declined\",\"request_timeout\",\"join_timeout\",\"stopped_by_contact\",\"stopped_by_executive\",\"call_ended\",\"sharer_disconnected\",\"failed\"],Xd=[\"move\",\"click\",\"leave\"];function Jd(e){return\"string\"==typeof e&&e.length>0?e:null}function Qd(e){return\"number\"!=typeof e.screen_share_id||\"number\"!=typeof e.voice_call_id?null:\"string\"==typeof e.status&&Kd.includes(e.status)?{screen_share_id:e.screen_share_id,voice_call_id:e.voice_call_id,status:e.status,end_reason:(t=e.end_reason,\"string\"==typeof t&&Yd.includes(t)?t:null),sharer_connected:\"boolean\"==typeof e.sharer_connected?e.sharer_connected:null}:null;var t}function Zd(e,t){switch(e.type){case\"activation_form\":{const n=function(e){if(!e||\"object\"!=typeof e)return null;const t=e;return\"boolean\"==typeof t.is_required&&Array.isArray(t.questions)&&t.questions.every(Vd)?{is_required:t.is_required,questions:t.questions}:null}(e.activation_form);return n&&t.onActivationForm?.(n),!0}case\"activation_feature_check_in\":{const n=cd(e);return n&&t.onFeatureCheckIn?.(n.check_in),!0}case\"activation_session_started\":return\"number\"==typeof e.session_id&&t.onActivationSessionStarted?.({sessionId:e.session_id,previousSessionId:\"number\"==typeof e.previous_session_id?e.previous_session_id:null}),!0;case\"activation_session_closed\":return\"number\"==typeof e.session_id&&t.onActivationSessionClosed?.(e.session_id),!0;case\"activation_session_replaced\":return\"number\"==typeof e.session_id&&\"number\"==typeof e.previous_session_id&&t.onActivationSessionReplaced?.({sessionId:e.session_id,previousSessionId:e.previous_session_id}),!0;case\"voice_call_invite\":{const n=function(e){return\"number\"!=typeof e.call_id||\"string\"!=typeof e.expires_at||0===e.expires_at.length?null:{call_id:e.call_id,executive_name:\"string\"==typeof e.executive_name&&e.executive_name.length>0?e.executive_name:null,expires_at:e.expires_at}}(e);return n&&t.onVoiceCallInvite?.(n),!0}case\"voice_call_status\":{const n=function(e){return\"number\"!=typeof e.call_id?null:\"string\"==typeof e.status&&Ud.includes(e.status)?{call_id:e.call_id,status:e.status,end_reason:\"string\"==typeof e.end_reason&&jd.includes(e.end_reason)?e.end_reason:null}:null}(e);return n&&t.onVoiceCallStatus?.(n),!0}case\"screen_share_invite\":{const n=function(e){return\"number\"!=typeof e.screen_share_id||\"number\"!=typeof e.voice_call_id||\"string\"!=typeof e.expires_at||0===e.expires_at.length?null:{screen_share_id:e.screen_share_id,voice_call_id:e.voice_call_id,executive_name:Jd(e.executive_name),expires_at:e.expires_at}}(e);return n&&t.onScreenShareInvite?.(n),!0}case\"screen_share_status\":{const n=Qd(e);return n&&t.onScreenShareStatus?.(n),!0}}return!1}class eu{constructor(e,t){this.websocket=null,this.isConnected=!1,this.isIntentionallyClosed=!1,this.connectionEpoch=0,this.reconnectAttempts=0,this.maxReconnectAttempts=10,this.reconnectInterval=1e3,this.maxReconnectInterval=3e4,this.reconnectDecay=1.5,this.reconnectTimeoutId=null,this.exhausted=!1,this.exhaustionReported=!1,this.keepAliveTimeoutId=null,this.recover=()=>this.reconnectIfFailed(),this.recoverOnVisible=()=>{document.hidden||this.reconnectIfFailed()},this.identityRefreshUsed=!1,this.liveness=new zd(es(\"websocket:stale\",()=>this.dropStaleSocket())),this.messageQueue=[],this.pendingMessages=new Map,this.responseCache=new Map,this.metadataManager=new xa,this.frameJournal=[],this.historySeen=!1,this.recordingTransport={sendStart:(e,t,n)=>this.sendSessionRecordingStart(e,t,n),sendChunk:(e,t,n,i)=>this.sendSessionRecordingEvents(e,t,n,i),sendStop:e=>this.sendSessionRecordingStop(e)},this.config=e,this.callbacks=t,this.contactFrameHandlers={onActivationForm:e=>{this.identityRefreshUsed=!1,this.callbacks.onActivationForm?.(e)},onFeatureCheckIn:e=>{this.identityRefreshUsed=!1,this.callbacks.onFeatureCheckIn?.(e)},onActivationSessionStarted:e=>this.callbacks.onActivationSessionStarted?.(e),onActivationSessionClosed:e=>this.callbacks.onActivationSessionClosed?.(e),onActivationSessionReplaced:e=>this.callbacks.onActivationSessionReplaced?.(e),onVoiceCallInvite:e=>this.callbacks.onVoiceCallInvite?.(e),onVoiceCallStatus:e=>this.callbacks.onVoiceCallStatus?.(e),onScreenShareInvite:e=>this.callbacks.onScreenShareInvite?.(e),onScreenShareStatus:e=>this.callbacks.onScreenShareStatus?.(e)}}connect(){if(!this.config.conversationId)return;this.liveness.stop(),this.websocket&&(this.websocket.onopen=null,this.websocket.onmessage=null,this.websocket.onerror=null,this.websocket.onclose=null,this.websocket.close(),this.websocket=null),null===Ad&&(Rd=document.hidden?s():null,document.addEventListener(\"visibilitychange\",$d),Id=performance.now()+Md,\"undefined\"!=typeof PerformanceObserver&&PerformanceObserver.supportedEntryTypes?.includes(\"longtask\")&&(_d=new PerformanceObserver(e=>{for(const t of e.getEntries())Td.push({start:t.startTime,end:t.startTime+t.duration})}),_d.observe({type:\"longtask\"})),Ad=setInterval(()=>{const e=performance.now();Ld=Math.max(Ld,Math.round(e-Id)),Id=e+Md},Md)),this.isIntentionallyClosed=!1,this.connectionEpoch++,this.disarmRecovery();const e=this.connectionEpoch,t=this.config.getIdentityProof?.()??null;t?t.catch(()=>null).then(t=>{this.connectionEpoch!==e||this.isIntentionallyClosed||this.openSocket(e,t)}):this.openSocket(e,null)}openSocket(e,t){const n=this.config.conversationId,i=this.config.apiBaseUrl.startsWith(\"https\")?\"wss\":\"ws\";let s=`${this.config.apiBaseUrl.replace(/^https?/,i)}${`/${\"session\"===this.config.conversationType?\"sessions\":\"tickets\"}/chat/${n}/`}?publishable_key=${encodeURIComponent(this.config.publishableKey)}&source_id=${encodeURIComponent(this.config.sourceId)}&tab_id=${encodeURIComponent(ya())}`;this.config.lastSeenSeq>0&&(s+=`&last_seen_seq=${this.config.lastSeenSeq}`);try{this.websocket=t?new WebSocket(s,[t.protocol]):new WebSocket(s),this.websocket.onopen=es(\"websocket:onopen\",()=>{this.connectionEpoch===e&&(this.isConnected=!0,this.reconnectAttempts=0,this.exhaustionReported=!1,this.historySeen=!1,this.liveness.start(),this.callbacks.onConnected(),this.callbacks.onConnectionStateChange(\"connected\"),this.flushMessageQueue(),this.sendJoined())}),this.websocket.onmessage=es(\"websocket:onmessage\",t=>{this.connectionEpoch===e&&(this.liveness.touch(),this.handleMessage(t))}),this.websocket.onerror=es(\"websocket:onerror\",()=>{this.connectionEpoch===e&&(this.isConnected=!1,Qi(\"websocket\",`connection error (attempt ${this.reconnectAttempts})`),this.callbacks.onConnectionStateChange(\"disconnected\"))}),this.websocket.onclose=es(\"websocket:onclose\",t=>{this.connectionEpoch===e&&this.handleClose(e,t.code,t.reason)})}catch(e){this.callbacks.onError(e instanceof Error?e:String(e)),this.scheduleReconnect()}}handleClose(e,t,n){if(this.liveness.stop(),this.isConnected=!1,Qi(\"websocket\",`closed (code ${t}${n?`: ${n}`:\"\"})`),this.callbacks.onDisconnected(),this.callbacks.onConnectionStateChange(\"disconnected\"),this.pendingMessages.size>0&&(this.pendingMessages.forEach(e=>{this.messageQueue.push(e)}),this.pendingMessages.clear()),!this.isIntentionallyClosed){if(4001===t){return!this.identityRefreshUsed&&this.config.refreshIdentityProof?(this.identityRefreshUsed=!0,void this.config.refreshIdentityProof?.().finally(()=>{this.connectionEpoch!==e||this.isIntentionallyClosed||this.scheduleReconnect()})):(Qi(\"websocket\",\"identity refused — not reconnecting\"),this.callbacks.onConnectionStateChange(\"failed\"),void this.callbacks.onIdentityRejected?.())}this.scheduleReconnect()}}dropStaleSocket(){const e=this.websocket;e&&!this.isIntentionallyClosed&&(e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null,e.close(),this.websocket=null,this.handleClose(this.connectionEpoch,Dd,\"no frame from the server\"))}disconnect(){this.isIntentionallyClosed=!0,this.connectionEpoch++,this.disarmRecovery(),this.liveness.stop(),this.sendLeft(),this.reconnectTimeoutId&&(clearTimeout(this.reconnectTimeoutId),this.reconnectTimeoutId=null),this.websocket&&(this.websocket.onopen=null,this.websocket.onmessage=null,this.websocket.onerror=null,this.websocket.onclose=null,this.websocket.close(1e3,\"Client disconnected\"),this.websocket=null),this.isConnected=!1}sendMessage(e,t,n,i){const s=cs(),r={type:\"chat_message\",message:e,idempotency_key:s,metadata:i?.text_dom?i:{...this.metadataManager.getMetadata(),...i}};n&&n.length>0&&(r.attachment_ids=n),t(s),this.websocket&&this.isConnected&&this.websocket.readyState===WebSocket.OPEN?(this.emitFrame(JSON.stringify(r)),this.pendingMessages.set(s,r)):this.messageQueue.push(r)}sendReadReceipt(e){if(!this.websocket||!this.isConnected||this.websocket.readyState!==WebSocket.OPEN)return;const t={type:\"read\",last_read_seq:e};this.emitFrame(JSON.stringify(t))}sendAgentActionResult(e){this.websocket&&this.isConnected&&this.websocket.readyState===WebSocket.OPEN?this.emitFrame(JSON.stringify(e)):this.messageQueue.push(e)}isValidAgentAction(e){if(\"string\"!=typeof e.api_call_id||0===e.api_call_id.length)return!1;if(\"string\"!=typeof e.path||0===e.path.length)return!1;if(void 0!==e.base_url&&\"string\"!=typeof e.base_url)return!1;const t=e.method;return\"string\"==typeof t&&(\"GET\"===t||\"POST\"===t||\"PUT\"===t||\"PATCH\"===t||\"DELETE\"===t)}isValidPermissionRequest(e){return\"string\"==typeof e.permission_id&&0!==e.permission_id.length&&\"string\"==typeof e.user_permission_question}sendSystemResponse(e){if(!this.websocket||!this.isConnected||this.websocket.readyState!==WebSocket.OPEN)return;const t=JSON.stringify(e);this.emitFrame(t)}sendSDKResponse(e){this.sendOrCacheForFlush(e.command_id,e)}sendSDKError(e,t,n){this.sendOrCacheForFlush(e,{type:\"sdk_error\",command_id:e,error:t,...n&&{code:n}})}sendOrCacheForFlush(e,t){const n=JSON.stringify({...t,document_id:fa()}),i=this.websocket,s=!!i&&this.isConnected&&i.readyState===WebSocket.OPEN;this.cacheCommandResponse(e,n,s),i&&s&&i.send(n)}flushUnsentResponses(){if(this.cleanupResponseCache(),!this.websocket||!this.isConnected||this.websocket.readyState!==WebSocket.OPEN)return 0;let e=0;for(const t of this.responseCache.values())t.delivered||(this.emitFrame(t.payload),t.delivered=!0,e++);return e}resendCachedResponse(e){this.cleanupResponseCache();const t=this.responseCache.get(e);return!!t&&(!(!this.websocket||!this.isConnected||this.websocket.readyState!==WebSocket.OPEN)&&(this.emitFrame(t.payload),t.delivered=!0,!0))}cacheCommandResponse(e,t,n){if(this.responseCache.size>=eu.RESPONSE_CACHE_MAX&&!this.responseCache.has(e)){const e=this.responseCache.keys().next().value;void 0!==e&&this.responseCache.delete(e)}this.responseCache.delete(e),this.responseCache.set(e,{payload:t,timestamp:s(),delivered:n})}cleanupResponseCache(){const e=s()-eu.RESPONSE_CACHE_TTL;for(const[t,n]of this.responseCache)n.timestamp<e&&this.responseCache.delete(t)}sendCommandAck(e){if(!this.websocket||!this.isConnected||this.websocket.readyState!==WebSocket.OPEN)return;const t={type:\"command_ack\",command_id:e,buffered_amount:this.websocket.bufferedAmount,blocked_ms:Pd()};this.emitFrame(JSON.stringify(t))}emitFrame(e,t){const n=/\"type\"\\s*:\\s*\"([^\"]+)\"/.exec(e.slice(0,200))?.[1]??\"unknown\";for(this.frameJournal.push({t:s(),type:n,bytes:e.length,...t&&{detail:t}});this.frameJournal.length>eu.FRAME_JOURNAL_MAX;)this.frameJournal.shift();this.websocket?.send(e)}getFrameJournal(){return[...this.frameJournal]}reportServerError(e){try{const t=s(),n=this.frameJournal.map(e=>`  ${String(e.t-t).padStart(7)}ms  ${e.type}${e.detail?`  ${e.detail}`:\"\"}  (${e.bytes} bytes)`);console.error(`[SupportWidget] the server rejected a frame: ${JSON.stringify(e)}\\nconversation=${this.config.conversationType}:${this.config.conversationId} readyState=${this.websocket?.readyState} historySeen=${this.historySeen}\\n`+(this.historySeen?\"\":\"NOTE: history had not arrived yet, so the consumer was still initialising — a frame sent in that window faults on a half-built consumer.\\n\")+(n.length?`frames this socket sent, newest last (the last one is the likely cause):\\n${n.join(\"\\n\")}`:\"this socket had sent no frames yet — the fault was raised on connect, not on a frame we sent.\"))}catch{}}sendSessionRecordingFrame(e,t){if(\"session\"!==this.config.conversationType)return!1;if(!e)return!1;if(!this.websocket||!this.isConnected||this.websocket.readyState!==WebSocket.OPEN)return!1;const n=\"number\"==typeof t.chunk_seq?` seq=${t.chunk_seq}`:\"\";return this.emitFrame(JSON.stringify({...t,span_uid:e}),`span=${e}${n}`),!0}sendSessionRecordingStart(e,t,n){return this.sendSessionRecordingFrame(e,{type:\"session_recording_start\",started_at_ms:t,recorder_version:n})}sendSessionRecordingEvents(e,t,n,i){return this.sendSessionRecordingFrame(e,{type:\"session_recording_events\",chunk_seq:t,events:n,recorder_version:i})}sendSessionRecordingStop(e){return this.sendSessionRecordingFrame(e,{type:\"session_recording_stop\"})}getRecordingTransport(){return this.recordingTransport}sendPresenceEvent(e){if(!this.websocket||!this.isConnected||this.websocket.readyState!==WebSocket.OPEN)return;const t={type:e};this.emitFrame(JSON.stringify(t))}sendTypingStart(){this.sendPresenceEvent(\"typing\")}sendTypingStop(){this.sendPresenceEvent(\"stopped_typing\")}sendJoined(){this.sendPresenceEvent(\"joined\")}sendLeft(){this.sendPresenceEvent(\"left\")}sendAck(e){if(!this.websocket||!this.isConnected||this.websocket.readyState!==WebSocket.OPEN)return;const t={type:\"ack\",last_seen_seq:e};this.emitFrame(JSON.stringify(t))}sendReplay(e){if(!this.websocket||!this.isConnected||this.websocket.readyState!==WebSocket.OPEN)return;const t={type:\"replay\",from_seq:e};this.emitFrame(JSON.stringify(t))}sendAgentCancel(e){if(!this.websocket||!this.isConnected||this.websocket.readyState!==WebSocket.OPEN)return;const t={type:\"agent_cancel\",reason:e||\"user_requested\"};this.emitFrame(JSON.stringify(t))}sendTabClaim(){this.websocket&&this.isConnected&&this.websocket.readyState===WebSocket.OPEN&&this.emitFrame(JSON.stringify({type:\"tab_claim\"}))}sendAgentNavigating(){this.websocket&&this.isConnected&&this.websocket.readyState===WebSocket.OPEN&&this.emitFrame(JSON.stringify({type:\"agent_navigating\"}))}async waitForSendBuffer(t){const n=s()+t;for(;this.websocket&&this.websocket.bufferedAmount>0&&s()<n;)await e(20)}isMessageAcknowledged(e){return!this.pendingMessages.has(e)}acknowledgeMessage(e){this.pendingMessages.delete(e)}updateConfig(e){this.config={...this.config,...e}}getSessionId(){return\"session\"===this.config.conversationType?this.config.conversationId:null}getConnectionStatus(){return this.isConnected}getReadyState(){return this.websocket?.readyState??null}handleMessage(e){try{const t=JSON.parse(e.data);if(\"ping\"===t.type)return void(this.websocket&&this.websocket.readyState===WebSocket.OPEN&&this.emitFrame(JSON.stringify({type:\"pong\",client:Nd()})));if(\"string\"!=typeof t.agent_owner_tab_id&&null!==t.agent_owner_tab_id||this.callbacks.onAgentOwnerChanged?.(t.agent_owner_tab_id),t.event){if(!1===this.config.agentExecution)return;const e=t.data?.batch_id||t.command_id||t.data?.command_id,n=t.command_id||t.data?.command_id||t.data?.batch_id,i={...t.data,command_id:n};switch(e&&this.sendCommandAck(e),t.event){case\"agent_command\":this.callbacks.onAgentCommand?.(i);break;case\"agent_command_batch\":this.callbacks.onAgentCommandBatch?.(t.data);break;case\"request_dom_state\":this.callbacks.onRequestDomState?.(i);break;case\"request_screenshot\":this.callbacks.onRequestScreenshot?.(i);break;case\"clarifying_question\":this.callbacks.onClarifyingQuestion?.(i);break;case\"request_element_context\":this.callbacks.onRequestElementContext?.(i);break;case\"request_text_dom\":this.callbacks.onRequestTextDom?.(i);break;case\"reload_page\":this.callbacks.onReloadPage?.(i)}return}const n=t;if(Zd(n,this.contactFrameHandlers))return;if(\"history\"===n.type){this.historySeen=!0,this.identityRefreshUsed=!1;const e=n.messages||[],t=e.filter(ld),i=void 0!==n.milestone_message_id&&t.some(e=>e.metadata?.milestone_message_id===n.milestone_message_id),s=i?void 0:Fd(n,{milestoneMessageId:n.milestone_message_id,sessionId:n.session_id,seq:qd(e,n.milestone_message_id,n.bubble_message),decisionCard:void 0===n.milestone_message_id?Od(e,n.bubble_message):void 0}),r=Wd(n);this.callbacks.onHistoryReceived(e.filter(e=>!ld(e)),n.last_read_seq,n.ai_assigned,n.first_response_at,n.agent_mode_active,n.agent_mode_intent,n.session_id,n.status,n.was_escalated,s,n.agent_status,r),\"executive_availability\"in n&&this.callbacks.onExecutiveAvailability?.(Hc(n.executive_availability))}else if(\"message\"===n.type){if(ld(n.message))return void this.callbacks.onFeatureCheckInReminder?.();this.callbacks.onMessageReceived(n.message)}else if(\"ai_chunk\"===n.type){const e=n.message?.chunk||\"\",t=n.message?.step;this.callbacks.onAIChunkReceived(e,t)}else if(\"system_action_success\"===n.type)this.callbacks.onSystemActionSuccess(n);else if(\"ticket_update\"===n.type)this.callbacks.onTicketUpdate(n);else if(\"error\"===n.type)this.reportServerError(String(n.error??\"\")),this.callbacks.onError(n.error);else if(\"user_joined\"===n.type)this.callbacks.onUserJoined?.(n);else if(\"user_left\"===n.type)this.callbacks.onUserLeft?.(n);else if(\"user_typing\"===n.type)this.callbacks.onUserTyping?.(n);else if(\"user_stopped_typing\"===n.type)this.callbacks.onUserStoppedTyping?.(n);else if(\"presence_update\"===n.type)this.callbacks.onPresenceUpdate?.(n);else if(\"ai_thinking\"===n.type)this.callbacks.onAIThinkingReceived?.();else if(\"ai_thinking_stop\"===n.type)this.callbacks.onAIThinkingStop?.();else if(\"ai_progress\"===n.type){const e=n.message||\"\";this.callbacks.onAIProgressReceived?.(e,n.progress_type)}else if(\"message_deleted\"===n.type){const e=n.seq;\"number\"==typeof e&&this.callbacks.onMessageDeleted?.(e)}else if(\"message_edited\"===n.type){const e=n.seq,t=n.body;\"number\"==typeof e&&\"string\"==typeof t&&this.callbacks.onMessageEdited?.({seq:e,body:t})}else if(\"agent_cancelled\"===n.type)this.callbacks.onAgentCancelled?.({reason:n.reason});else if(\"agent_acknowledged\"===n.type)this.callbacks.onAgentAcknowledged?.();else if(\"session_recording_ack\"===n.type){const e=n.chunk_seq;!0===n.rejected&&\"string\"==typeof n.span_uid?this.callbacks.onSessionRecordingRejected?.(n.span_uid):!0!==n.rejected&&\"number\"==typeof e&&this.callbacks.onSessionRecordingAck?.(e)}else\"message_queued\"===n.type?this.callbacks.onMessageQueued?.({message:n.message||\"\"}):\"session_escalated\"===n.type?this.callbacks.onSessionEscalated?.({conversation_id:n.conversation_id,session_id:n.session_id,executive_availability:Hc(n.executive_availability)}):\"session_closed\"===n.type?this.callbacks.onSessionClosed?.():\"agent_execution_complete\"===n.type?this.callbacks.onAgentExecutionComplete?.():\"onboarding_step_completed\"===n.type?this.callbacks.onOnboardingStepCompleted?.({step_uuid:n.step_uuid,onboarding_completed:!!n.onboarding_completed}):\"plan_saved\"===n.type?this.callbacks.onPlanSaved?.():\"agent_action\"===n.type?this.isValidAgentAction(n)&&this.callbacks.onAgentAction?.(n):\"permission_request\"===n.type?this.isValidPermissionRequest(n)&&this.callbacks.onPermissionRequest?.(n):\"system_action_ack\"===n.type||(\"replay\"===n.type?this.callbacks.onReplayReceived?.(n.messages||[]):\"sdk_response_ack\"===n.type||\"command_ack\"===n.type||\"joined\"===n.type||\"left\"===n.type||\"read\"===n.type||n.type)}catch(e){this.callbacks.onError(e instanceof Error?e:String(e))}}scheduleReconnect(){if(this.reconnectAttempts>=this.maxReconnectAttempts)return this.exhaustionReported||(Ji(`WebSocket reconnect exhausted after ${this.maxReconnectAttempts} attempts`),this.exhaustionReported=!0),this.callbacks.onConnectionStateChange(\"failed\"),void this.armRecovery();this.reconnectTimeoutId&&clearTimeout(this.reconnectTimeoutId);const e=Math.min(this.reconnectInterval*Math.pow(this.reconnectDecay,this.reconnectAttempts),this.maxReconnectInterval);this.callbacks.onConnectionStateChange(\"reconnecting\");const t=this.connectionEpoch;this.reconnectTimeoutId=setTimeout(()=>{this.connectionEpoch===t&&(this.reconnectAttempts++,this.connect())},e)}reconnectIfFailed(){this.exhausted&&!this.isIntentionallyClosed&&(Qi(\"websocket\",\"retrying after reconnect exhaustion\"),this.reconnectAttempts=0,this.connect())}armRecovery(){this.exhausted||(this.exhausted=!0,window.addEventListener(\"online\",this.recover),document.addEventListener(\"visibilitychange\",this.recoverOnVisible),this.keepAliveTimeoutId=setTimeout(this.recover,6e4))}disarmRecovery(){this.exhausted&&(this.exhausted=!1,window.removeEventListener(\"online\",this.recover),document.removeEventListener(\"visibilitychange\",this.recoverOnVisible),this.keepAliveTimeoutId&&(clearTimeout(this.keepAliveTimeoutId),this.keepAliveTimeoutId=null))}flushMessageQueue(){if(0!==this.messageQueue.length)for(;this.messageQueue.length>0;){const e=this.messageQueue.shift();e&&this.websocket?.readyState===WebSocket.OPEN&&(this.emitFrame(JSON.stringify(e)),\"string\"==typeof e.idempotency_key&&this.pendingMessages.set(e.idempotency_key,e))}}}eu.RESPONSE_CACHE_TTL=6e4,eu.RESPONSE_CACHE_MAX=50,eu.FRAME_JOURNAL_MAX=20;const tu=.25,nu=.35,iu=.25,su=.3,ru=.25,ou=.3,au=.3,lu=.2,cu=.15,du=.4,uu=.15,pu=.25,hu=.35,gu=.2,mu=.3,fu={button:[\"button\",'input[type=\"button\"]','input[type=\"submit\"]','[role=\"button\"]'],textbox:['input[type=\"text\"]','input[type=\"email\"]','input[type=\"search\"]','input[type=\"tel\"]','input[type=\"url\"]',\"input:not([type])\",\"textarea\",'[role=\"textbox\"]','[contenteditable=\"true\"]'],password:['input[type=\"password\"]'],link:[\"a[href]\",'[role=\"link\"]'],checkbox:['input[type=\"checkbox\"]','[role=\"checkbox\"]'],radio:['input[type=\"radio\"]','[role=\"radio\"]'],listbox:[\"select\",'[role=\"listbox\"]'],option:[\"option\",'[role=\"option\"]'],menu:[\"nav\",'[role=\"menu\"]','[role=\"navigation\"]','[role=\"menubar\"]'],menuitem:['[role=\"menuitem\"]'],dialog:[\"dialog\",'[role=\"dialog\"]','[role=\"alertdialog\"]'],table:[\"table\",'[role=\"table\"]','[role=\"grid\"]'],row:[\"tr\",'[role=\"row\"]'],cell:[\"td\",\"th\",'[role=\"cell\"]','[role=\"gridcell\"]'],form:[\"form\",'[role=\"form\"]'],heading:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",'[role=\"heading\"]'],img:[\"img\",'[role=\"img\"]'],list:[\"ul\",\"ol\",'[role=\"list\"]'],listitem:[\"li\",'[role=\"listitem\"]'],tab:['[role=\"tab\"]'],tabpanel:['[role=\"tabpanel\"]'],searchbox:['input[type=\"search\"]','[role=\"searchbox\"]'],slider:['input[type=\"range\"]','[role=\"slider\"]'],spinbutton:['input[type=\"number\"]','[role=\"spinbutton\"]'],combobox:['[role=\"combobox\"]',\"input[list]\"],switch:['[role=\"switch\"]']};class bu{resolve(e){if(e.agent_id){const t=Oo(e.agent_id);if(t)return{element:t,match_details:{matched_on:[\"agent_id\"],partial_matches:[],fallback_used:!1},alternatives:[],all_candidates:[{element:t,score:1}]}}const t=new Map,n=[],i=[];let s=!1;if(e.role){this.findByRole(e.role,t)?n.push(\"role\"):i.push(\"role\")}if(e.text_content){this.filterByTextContent(e.text_content,t,e.match_options,!e.role)?n.push(\"text_content\"):i.push(\"text_content\")}if(e.label){this.filterByLabel(e.label,t,!e.role&&!e.text_content)?n.push(\"label\"):i.push(\"label\")}if(e.icon_description){this.filterByIconDescription(e.icon_description,t,!e.role&&!e.text_content&&!e.label)?n.push(\"icon_description\"):i.push(\"icon_description\")}if(e.form_field_name){this.filterByFormFieldName(e.form_field_name,t)?n.push(\"form_field_name\"):i.push(\"form_field_name\")}if(void 0!==e.value){this.filterByValue(e.value,t,e.match_options)?n.push(\"value\"):i.push(\"value\")}if(e.near_text){this.filterByProximity(e.near_text,t,e.match_options?.max_distance_px)?n.push(\"near_text\"):i.push(\"near_text\")}if(e.inside_container){this.filterByContainer(e.inside_container,t)?n.push(\"inside_container\"):i.push(\"inside_container\")}let r=!1;if(e.selector_hints?.length||e.xpath_hints?.length){if(this.applySelectorsAsBoost(e,t)?(n.push(\"selector_hint\"),r=!0):0===t.size&&(s=this.tryFallbackSelectors(e,t),s&&(n.push(\"fallback_selector\"),r=!0)),!r){this.trySelectorsIgnoringVisibility(e,t)&&(n.push(\"selector_hint_hidden\"),r=!0)}}const o=Array.from(t.entries()).map(([e,t])=>({element:e,score:t})).sort((e,t)=>t.score-e.score),a=this.selectBestMatchWithIndex(o,e);if((e.selector_hints?.length||0)+(e.xpath_hints?.length||0)>0&&!r&&a){if((t.get(a)||0)<.4)return{element:null,match_details:{matched_on:n,partial_matches:[...i,\"selector_hint\"],fallback_used:!1},alternatives:this.getAlternatives(t,a),all_candidates:o}}return{element:a,match_details:{matched_on:n,partial_matches:i,fallback_used:s},alternatives:this.getAlternatives(t,a),all_candidates:o}}selectBestMatchWithIndex(e,t){if(0===e.length)return null;if(\"number\"==typeof t.match_index&&t.match_index>=0){if(t.match_index<e.length)return e[t.match_index].element;console.warn(\"[resolver] match_index=%d out of range (%d candidates); falling back to top scorer\",t.match_index,e.length)}const n=e[0].score,i=e.filter(e=>n-e.score<.1);if(!0===t.is_native_select&&\"number\"==typeof t.select_index&&t.select_index>=0){const e=i.filter(e=>e.element instanceof HTMLSelectElement);if(t.select_index<e.length)return e[t.select_index].element;console.warn(\"[resolver] target.select_index=%d out of range (%d matching <select>s); falling back to top scorer\",t.select_index,e.length)}if(\"number\"==typeof t.element_index&&t.element_index>=0){if(t.element_index<i.length)return i[t.element_index].element;console.warn(\"[resolver] element_index=%d out of range (%d in top cluster); falling back to top scorer\",t.element_index,i.length)}return e[0].element}async resolveWithRetry(t,n=5e3,i=500){const r=s();for(;s()-r<n;){const n=this.resolve(t);if(n.element)return n;await e(i)}return this.resolve(t)}async resolveWithReveal(t,n=5e3,i=500){const r=s();let o=[],a=0;for(;s()-r<n;){const n=this.resolve(t);if(n.element)return{...n,reveal:{hoveredContainers:o}};0===a?o=wo():So(o),a++,await e(i)}return{...this.resolve(t),reveal:{hoveredContainers:o}}}findByRole(e,t){const n=fu[e.toLowerCase()]||[`[role=\"${e}\"]`];let i=!1;return n.forEach(e=>{try{document.querySelectorAll(e).forEach(e=>{const n=e;if(this.isVisible(n)&&this.isInteractable(n)){const e=t.get(n)||0;t.set(n,e+tu),i=!0}})}catch{}}),i}filterByTextContent(e,t,n,i=!1){const s=n?.text_match_mode||\"contains\",r=n?.case_sensitive||!1,o=r?e:e.toLowerCase();let a=!1;if(i||0===t.size){const e=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,null);for(;e.nextNode();){const n=e.currentNode;if(this.isVisible(n)&&this.isInteractable(n)){const e=this.calculateTextMatchScore(n,o,s,r);if(e>0){const i=t.get(n)||0;t.set(n,i+e),a=!0}}}}else t.forEach((e,n)=>{const i=this.calculateTextMatchScore(n,o,s,r);if(i>0)t.set(n,e+i),a=!0;else{const i=\"exact\"===s?.1:.5;t.set(n,e*i)}});return a}calculateTextMatchScore(e,t,n,i){const s=this.getElementText(e),r=i?s:s.toLowerCase();switch(n){case\"exact\":return r.trim()===t.trim()?nu:0;case\"contains\":return r.includes(t)?iu:0;case\"starts_with\":return r.trim().startsWith(t)?su:0;case\"regex\":try{return new RegExp(t,i?\"\":\"i\").test(s)?ru:0}catch{return 0}default:return 0}}filterByLabel(e,t,n=!1){const i=e.toLowerCase();let s=!1;const r=(e,t)=>{const n=e.getAttribute(\"aria-label\")?.toLowerCase();if(n?.includes(i))return s=!0,t+ou;const r=e.getAttribute(\"aria-labelledby\");if(r){const e=document.getElementById(r);if(e?.textContent?.toLowerCase().includes(i))return s=!0,t+au}const o=e.id;if(o){const e=document.querySelector(`label[for=\"${o}\"]`);if(e?.textContent?.toLowerCase().includes(i))return s=!0,t+au}const a=e.closest(\"label\");if(a?.textContent?.toLowerCase().includes(i))return s=!0,t+au;const l=e.getAttribute(\"placeholder\")?.toLowerCase()||e.getAttribute(\"data-placeholder\")?.toLowerCase();if(l?.includes(i))return s=!0,t+lu;if(\"true\"===e.getAttribute(\"contenteditable\")){const n=e.querySelector(\"[data-placeholder]\");if(n?.getAttribute(\"data-placeholder\")?.toLowerCase().includes(i))return s=!0,t+lu}const c=e.getAttribute(\"title\")?.toLowerCase();return c?.includes(i)?(s=!0,t+cu):t};if(n||0===t.size){document.querySelectorAll('input, select, textarea, button, [role=\"button\"], [role=\"textbox\"], [contenteditable=\"true\"]').forEach(e=>{const n=e;if(this.isVisible(n)){const e=r(n,0);if(e>0){const i=t.get(n)||0;t.set(n,i+e)}}})}else t.forEach((e,n)=>{const i=r(n,e);t.set(n,i)});return s}filterByIconDescription(e,t,n=!1){const i=e.toLowerCase();let s=!1;if(n||0===t.size){const e=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,null);for(;e.nextNode();){const n=e.currentNode;if(this.isVisible(n)&&this.isInteractable(n)){const e=er(n);if(e&&e.toLowerCase()===i){const e=t.get(n)||0;t.set(n,e+mu),s=!0}}}}else t.forEach((e,n)=>{const r=er(n);r&&r.toLowerCase()===i?(t.set(n,e+mu),s=!0):t.set(n,.5*e)});return s}filterByFormFieldName(e,t){const n=e.toLowerCase();let i=!1;if(0===t.size){document.querySelectorAll(`[name*=\"${e}\"], [name=\"${e}\"]`).forEach(e=>{const s=e;if(this.isVisible(s)){const e=s.getAttribute(\"name\")?.toLowerCase();e===n?(t.set(s,pu),i=!0):e?.includes(n)&&(t.set(s,.7*pu),i=!0)}})}else t.forEach((e,s)=>{const r=s.getAttribute(\"name\")?.toLowerCase();r===n?(t.set(s,e+pu),i=!0):r?.includes(n)&&(t.set(s,e+.7*pu),i=!0)});return i}filterByValue(e,t,n){const i=n?.text_match_mode||\"exact\",s=n?.case_sensitive??!1,r=s?e:e.toLowerCase();let o=!1;return t.forEach((e,n)=>{const a=this.getElementValue(n);if(null===a)return;const l=s?a:a.toLowerCase();let c=!1;switch(i){case\"exact\":c=l===r;break;case\"contains\":c=l.includes(r);break;case\"starts_with\":c=l.startsWith(r);break;case\"regex\":try{c=new RegExp(r,s?\"\":\"i\").test(a)}catch{}}c?(t.set(n,e+hu),o=!0):t.set(n,.2*e)}),o}getElementValue(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?e.value:\"true\"===e.getAttribute(\"contenteditable\")?(e.innerText||e.textContent||\"\").trim():null}filterByProximity(e,t,n=400){const i=this.findTextNodeRects(e);if(0===i.length)return!1;let s=!1;return t.forEach((e,r)=>{const o=r.getBoundingClientRect();let a=1/0;if(i.forEach(e=>{const t=this.calculateRectDistance(o,e);t<a&&(a=t)}),a<=n){const n=du*Math.exp(-.01*a);t.set(r,e+n),s=!0}else t.set(r,.3*e)}),s}filterByContainer(e,t){const n=e.startsWith(\"#\")?e.slice(1):e;let i=null;if(e.startsWith(\"#\")||e.startsWith(\".\")||e.startsWith(\"[\"))try{i=document.querySelector(e)}catch{}if(i||(i=document.getElementById(n)||document.querySelector(`.${CSS.escape(n)}`)||document.querySelector(`[data-testid=\"${n}\"]`)||document.querySelector(`[data-container=\"${n}\"]`)||this.tryAsTagSelector(n)||this.findElementByTextContent(n)),!i)return!1;let s=!1;return t.forEach((e,n)=>{i.contains(n)?(t.set(n,e+uu),s=!0):t.set(n,.3*e)}),s}applySelectorsAsBoost(e,t){let n=!1;if(e.selector_hints)for(const i of e.selector_hints)try{const e=document.querySelectorAll(i);0===e.length?console.warn(\"[resolver] stale selector_hint matches 0 elements: %s\",i):e.length>5&&console.warn(\"[resolver] broad selector_hint matches %d elements: %s\",e.length,i),e.forEach(e=>{const i=e;if(this.isVisible(i))if(t.has(i)){const e=t.get(i)||0;t.set(i,e+gu),n=!0}else t.set(i,gu),n=!0})}catch{}if(e.xpath_hints)for(const i of e.xpath_hints)try{const e=document.evaluate(i,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(let i=0;i<e.snapshotLength;i++){const s=e.snapshotItem(i);if(this.isVisible(s))if(t.has(s)){const e=t.get(s)||0;t.set(s,e+gu),n=!0}else t.set(s,gu),n=!0}}catch{}if(n){const n=new Set;if(e.selector_hints)for(const t of e.selector_hints)try{document.querySelectorAll(t).forEach(e=>{n.add(e)})}catch{}n.size>0&&t.forEach((e,i)=>{n.has(i)||t.set(i,.2*e)})}return n}tryFallbackSelectors(e,t){let n=!1;if(e.selector_hints)for(const i of e.selector_hints)try{const e=document.querySelector(i);if(e&&this.isVisible(e)){const i=t.get(e)||0;t.set(e,i+gu),n=!0;break}}catch{}if(!n&&e.xpath_hints)for(const i of e.xpath_hints)try{const e=document.evaluate(i,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue;if(e&&this.isVisible(e)){const i=t.get(e)||0;t.set(e,i+gu),n=!0;break}}catch{}return n}trySelectorsIgnoringVisibility(e,t){let n=!1;const i=new Set;if(e.selector_hints)for(const s of e.selector_hints)try{document.querySelectorAll(s).forEach(e=>{const s=e;i.add(s),t.has(s)||(t.set(s,gu),n=!0)})}catch{}if(e.xpath_hints)for(const s of e.xpath_hints)try{const e=document.evaluate(s,document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(let s=0;s<e.snapshotLength;s++){const r=e.snapshotItem(s);i.add(r),t.has(r)||(t.set(r,gu),n=!0)}}catch{}return n&&i.size>0&&t.forEach((e,n)=>{i.has(n)||t.set(n,.2*e)}),n}isVisible(e){if(!e)return!1;if(e instanceof HTMLOptionElement){const t=e.closest(\"select\");return!!t&&this.isVisible(t)}return Ds(e)}isInteractable(e){if(!e)return!1;if(e.hasAttribute(\"disabled\")||\"true\"===e.getAttribute(\"aria-disabled\"))return!1;const t=e.tagName.toLowerCase(),n=e.getAttribute(\"role\");return\"button\"===t||\"a\"===t||\"input\"===t||\"select\"===t||\"textarea\"===t||\"option\"===t||\"button\"===n||\"link\"===n||\"checkbox\"===n||\"radio\"===n||\"textbox\"===n||\"menuitem\"===n||\"tab\"===n||e.hasAttribute(\"onclick\")||e.hasAttribute(\"tabindex\")||\"pointer\"===window.getComputedStyle(e).cursor}getElementText(e){return(e.innerText||e.textContent||\"\").trim()}tryAsTagSelector(e){try{return document.querySelector(e)}catch{return null}}findElementByTextContent(e){const t=e.toLowerCase(),n=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,null);for(;n.nextNode();){const e=n.currentNode;if(this.isVisible(e)&&this.getElementText(e).toLowerCase().includes(t))return e}return null}findTextNodeRects(e){const t=e.toLowerCase(),n=[],i=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,null);for(;i.nextNode();){const e=i.currentNode;if(e.textContent?.toLowerCase().includes(t)){const t=document.createRange();t.selectNodeContents(e);const i=t.getBoundingClientRect();i.width>0&&i.height>0&&n.push(i)}}return n}calculateRectDistance(e,t){const n=Math.max(0,Math.max(t.left-e.right,e.left-t.right)),i=Math.max(0,Math.max(t.top-e.bottom,e.top-t.bottom));return Math.sqrt(n*n+i*i)}getAlternatives(e,t){const n=[];return e.forEach((e,i)=>{i!==t&&e>.1&&n.push({element:i,score:e})}),n.sort((e,t)=>t.score-e.score).slice(0,3).map(e=>e.element)}}function yu(e,t,n){return function(e){if(!e)return;const t=function(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement}(e)?function(e){return vu(e)||function(e){const t=e.getAttribute(\"id\");if(!t)return;const n=e.ownerDocument?.querySelector(`label[for=\"${CSS.escape(t)}\"]`);return wu(n?.textContent||\"\")}(e)||hr(e)||e.getAttribute(\"name\")?.trim()||void 0}(e):function(e){return vu(e)||wu(e.textContent||\"\")||er(e)||Vs(e)}(e);return wu(t||\"\")?.slice(0,80)||void 0}(n)||function(e){return e&&[e.text_content,e.label,e.near_text].filter(Boolean).join(\" | \")||void 0}(t)||e}function vu(e){return e.getAttribute(\"aria-label\")?.trim()||void 0}function wu(e){return e.replace(/\\s+/g,\" \").trim()||void 0}function xu(e){return void 0===e?.wanted||e.checked===e.wanted?null:`The check dispatched but the box is still checked=${e.checked} (wanted ${e.wanted}). If a confirmation dialog opened, answer it; otherwise the control refused the gesture and repeating it will not help.`}const ku=[\"scroll_to\",\"highlight\"];function Su(e){if(e instanceof HTMLInputElement&&(\"checkbox\"===e.type||\"radio\"===e.type)){if(!Ds(e)||0===parseFloat(window.getComputedStyle(e).opacity)){const t=Array.from(e.labels??[]).find(e=>Ds(e));if(t)return t}}return e}function Cu(e){const t=e.tagName.toLowerCase(),n=Array.from(e.classList).filter(e=>!e.includes(\":\")&&!e.includes(\"/\")).slice(0,2),i=n.length>0?`${t}.${n.join(\".\")}`:t;let s=e.parentElement,r=0;for(;s&&r<6&&s!==document.body;){const e=Eu(s);if(e){const t=Au(e,i,s);if(t)return t}s=s.parentElement,r++}for(s=e.parentElement,r=0;s&&r<6&&s!==document.body;){const e=Mu(s);if(e){const t=Au(e,i,s);if(t)return t}s=s.parentElement,r++}}function Eu(e){if(e.id)return`#${CSS.escape(e.id)}`;for(const t of Array.from(e.classList))if(t.includes(\"__\")||t.includes(\"--\"))return`.${CSS.escape(t)}`;return null}function Mu(e){const t=new Set([\"section\",\"fieldset\",\"nav\",\"article\"]),n=e.getAttribute(\"aria-label\"),i=e.getAttribute(\"role\");if(n)return`[aria-label=\"${CSS.escape(n)}\"]`;if(\"group\"===i||\"radiogroup\"===i)return`[role=\"${i}\"]`;const s=e.tagName.toLowerCase();return t.has(s)?s:null}function Au(e,t,n){const i=`${e} ${t}`;try{const e=document.querySelectorAll(i);if(1===e.length)return i;if(e.length>1&&n.parentElement&&n.parentElement!==document.body){const e=n.parentElement,i=Eu(e)||Mu(e);if(i){const s=`${i} > :nth-child(${Array.from(e.children).indexOf(n)+1}) ${t}`;try{if(1===document.querySelectorAll(s).length)return s}catch{}}}}catch{}}function _u(e){const t=Na();switch(e.type){case\"click\":return t.agent.clickElement;case\"type\":{const n=e.value.length>40?e.value.substring(0,40)+\"...\":e.value;return t.agent.typeValue(n)}case\"select\":return t.agent.selectValue(e.value||`option #${e.select_index??\"?\"}`);case\"check\":return e.checked?t.agent.checkCheckbox:t.agent.uncheckCheckbox;case\"scroll_to\":return t.agent.scrollToElement;case\"hover\":return t.agent.hoverElement;case\"press_key\":{const n=e.modifiers?Object.entries(e.modifiers).filter(([e,t])=>t).map(([e])=>e.charAt(0).toUpperCase()+e.slice(1)).join(\"+\")+\"+\":\"\";return t.agent.pressKey(`${n}${e.key}`)}default:return t.agent.performAction}}function Tu(e){const t=e.getRootNode(),n=[];for(let i=e;i!==t&&i.parentNode;i=i.parentNode)n.unshift(Array.prototype.indexOf.call(i.parentNode.children,i));const i=e=>`${e.tagName}|${e.getAttribute(\"role\")}|${e.getAttribute(\"type\")}`,s=i(e);return()=>{if(e.isConnected)return e;if(!t.isConnected)return null;let r,o=t.children;for(const e of n){if(r=o[e],!r)return null;o=r.children}return r&&i(r)===s?r:null}}const Iu=Ho.join(\",\");function Lu(e){const t=e.nodeType===Node.ELEMENT_NODE?e:e.parentElement;return!!t?.closest(Iu)}function Ru(){const t=performance.now(),n=location.href;let i=document.activeElement,s=0,r=null;const o=new MutationObserver(e=>{const t=e.filter(e=>!function(e){if(Lu(e.target))return!0;if(\"childList\"!==e.type)return!1;const t=[...e.addedNodes,...e.removedNodes];return t.length>0&&t.every(Lu)}(e));0!==t.length&&(s+=t.length,r?.(),r=null)});o.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});const a=()=>(o.disconnect(),r=null,(()=>{const e=location.href!==n,r=document.activeElement!==i;return{mutations:s,navigated:e,focusChanged:r,any:s>0||e||r,window_ms:Math.round(performance.now()-t)}})());return{stop:a,rebaseFocus(){i=document.activeElement},async waitForChange(t){if(s>0)return a();const n=new Promise(e=>{r=e});return await Promise.race([n,e(t)]),a()}}}const $u={quietMs:100,maxWaitMs:2e3,pollMs:50,staleRequestMs:15e3};let Nu=\"\",Pu=0;function Fu(e=3e3){Nu=window.location.href,Pu=performance.now()+e}function Ou(){return!!Pu&&(!(performance.now()>=Pu||window.location.href!==Nu)||(Pu=0,!1))}async function qu(t){for(;Ou();)await e(t)}const Hu={graceMs:500};function Bu(t,n={}){const{quietMs:i,maxWaitMs:s,pollMs:r,staleRequestMs:o,graceMs:a}={...$u,...Hu,...n},l=location.href;let c=0;const d=new Set,u=e=>{for(const t of e)for(const e of t.addedNodes){if(!Du(e))continue;d.add(e);const t=()=>{d.delete(e)};e.addEventListener(\"load\",t,{once:!0}),e.addEventListener(\"error\",t,{once:!0})}},p=new MutationObserver(e=>{c=performance.now(),u(e)});p.observe(document.documentElement,{childList:!0,subtree:!0,characterData:!0});const h=()=>d.size>0||zu(t,o),g=()=>p.disconnect();return{wait:async()=>{u(p.takeRecords()),c=0;try{const t=performance.now();let n=!1;for(;performance.now()-t<a;)if(await e(r),h()||location.href!==l||c>0){n=!0;break}if(!n)return;for(;performance.now()-t<s;){await e(r);const t=performance.now();if(h())c=t;else if(t-c>=i)return}}finally{g()}},disarm:g}}function Du(e){return e instanceof HTMLScriptElement&&!!e.src&&(!e.type||/javascript|ecmascript|module/i.test(e.type))}function zu(e,t=$u.staleRequestMs){return function(e,t){if(!e)return!1;const n=performance.now();return Ko(e.getPendingRequestInfo()).some(e=>n-e.started_at<t)}(e,t)||function(){const e=Array.from(document.querySelectorAll('img[src*=\"loading\" i], img[src*=\"spinner\" i]'));for(const t of e)if(Uu(t)&&ju(t))return!0;const t=Array.from(document.querySelectorAll('[aria-busy=\"true\"]'));for(const e of t)if(Uu(e))return!0;return!1}()}function Uu(e){const t=getComputedStyle(e);if(\"none\"===t.display||\"hidden\"===t.visibility||0===parseFloat(t.opacity))return!1;const n=e.getBoundingClientRect();return n.width>0&&n.height>0}function ju(e){for(let t=e;t;t=t.parentElement)if(\"fixed\"===getComputedStyle(t).position)return!0;return!1}const Wu=Ho.join(\", \");let Vu=null;function Gu(e){e&&e===Vu&&!document.hasFocus()&&(Vu=null,e.dispatchEvent(new FocusEvent(\"blur\",{composed:!0})),e.dispatchEvent(new FocusEvent(\"focusout\",{bubbles:!0,composed:!0})))}function Ku(e){const t=e.getRootNode(),n=t.activeElement;e.focus({preventScroll:!0}),document.hasFocus()||n===e||t.activeElement!==e||(Gu(n),Vu=e,e.dispatchEvent(new FocusEvent(\"focus\",{composed:!0})),e.dispatchEvent(new FocusEvent(\"focusin\",{bubbles:!0,composed:!0})))}function Yu(e){const t=e.id?`#${e.id}`:\"\",n=\"string\"==typeof e.className&&e.className?`.${e.className.trim().split(/\\s+/).slice(0,2).join(\".\")}`:\"\";return`${e.tagName.toLowerCase()}${t}${n}`.slice(0,80)}class Xu{constructor(e,t,n=()=>!1,i=()=>{},s=()=>{},r=()=>{}){this.isCancelled=n,this.onNavigationImminent=i,this.onNavigationSettled=s,this.onHiddenScroll=r,this.undoStack=[],this.maxUndoStackSize=20,this.forcedPopups=[],this.elementResolver=e||new bu,this.onBrowsingContextOpen=t}async scrollAndWait(e){if(t())return e.scrollIntoView({behavior:\"instant\",block:\"center\"}),this.onHiddenScroll(e),void ca(\"scroll\",{mode:\"instant\",hidden:!0});await this.scrollIntoViewAndSettle(e)}async scrollIntoViewAndSettle(t){t.scrollIntoView({behavior:\"smooth\",block:\"center\"});let n=null,i=!1;const s=new Promise(e=>{let s=t.getBoundingClientRect().top,r=0;const o=performance.now(),a=()=>{if(i)return;const l=t.getBoundingClientRect().top;Math.abs(l-s)<1?r++:(r=0,s=l);const c=performance.now()-o,d=r>=3&&c>=120;d||c>=1200?e(d?\"settled\":\"capped\"):n=requestAnimationFrame(a)};n=requestAnimationFrame(a)}),r=await Promise.race([s,e(1200).then(()=>\"backstop\")]);i=!0,null!==n&&cancelAnimationFrame(n),ca(\"scroll\",{mode:\"smooth\",exit:r})}async execute(e,t,n){if(this.isActionCancelled(n?.signal))return{success:!1,error:\"Action cancelled\"};if(!(t instanceof HTMLElement)){let i;return i=\"click\"===e.type?await this.executeClick(t,e.modifiers,n):\"check\"===e.type?await this.executeClick(t,void 0,n):\"hover\"===e.type?await this.executeHover(t,e.duration_ms,n?.signal):{success:!1,error:`'${e.type}' is not supported on <${t.tagName.toLowerCase()}>`},i.success||(i.error=this.describeFailure(e,t,i.error)),i}const i=this.resolveEditableTarget(t,e),s=this.captureState(i,e);try{let t;switch(e.type){case\"click\":t=await this.executeClick(i,e.modifiers,n);break;case\"type\":t=await this.executeType(i,e.value,e.clear_first??!0,n?.signal);break;case\"select\":t=await this.executeSelect(i,e.value,e.select_index,n?.signal);break;case\"check\":t=await this.executeCheck(i,e.checked,n);break;case\"scroll_to\":t=await this.executeScrollTo(i);break;case\"hover\":t=await this.executeHover(i,e.duration_ms,n?.signal);break;case\"highlight\":t=await this.executeHighlight(i,e.duration_ms,n?.revealHighlight);break;case\"navigate\":t=await this.executeNavigate(e.url);break;case\"wait_for\":t=await this.executeWaitFor(e.condition);break;case\"press_key\":t=await this.executePressKey(i,e.key,e.modifiers,n?.signal);break;case\"scroll_to_text\":t=await this.executeScrollToText(e.selector);break;default:t={success:!1,error:`Unknown action type: ${e.type}`}}return t.success&&null!==s&&(this.undoStack.push({action:e,element:i,previousState:s}),this.undoStack.length>this.maxUndoStackSize&&this.undoStack.shift()),t.success||(t.error=this.describeFailure(e,i,t.error)),t}catch(t){const n=t instanceof Error?t.message:\"Execution failed\";return{success:!1,error:this.describeFailure(e,i,n)}}}describeFailure(e,t,n){const i=n||`${e.type} action failed`;if(\"navigate\"===e.type||\"wait_for\"===e.type||\"scroll_to_text\"===e.type||!t)return i;const s=t.tagName.toLowerCase(),r=t instanceof HTMLInputElement?` type=\"${t.type}\"`:\"\",o=t.getAttribute(\"role\"),a=`<${s}${r}${o?` role=\"${o}\"`:\"\"}>`;return`${i} (action=${e.type}, target=${a})`}resolveClickTarget(e){const t=Su(e);if(t!==e)return t;if(!(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)){const t=e.querySelector(\"combobox\"===e.getAttribute(\"role\")?'input:not([type=\"hidden\"]):not([disabled]), textarea:not([disabled])':'input[role=\"combobox\"]:not([disabled]), input[role=\"searchbox\"]:not([disabled]), input[aria-haspopup]:not([disabled])');if(t instanceof HTMLElement)return t}return e}resolveEditableTarget(e,t){if(\"click\"!==t.type&&\"type\"!==t.type&&\"hover\"!==t.type&&\"press_key\"!==t.type)return e;if(\"true\"===e.contentEditable||e.isContentEditable){const t=e.parentElement?.closest('[contenteditable=\"true\"]');return t instanceof HTMLElement?t:e}const n=e.closest('[contenteditable=\"true\"]');return n instanceof HTMLElement?n:e}async executeClick(n,i,r){if(n instanceof HTMLSelectElement){if(n.focus(),\"showPicker\"in n&&\"function\"==typeof n.showPicker)try{return n.showPicker(),{success:!0}}catch{}const e=Array.from(n.options).map(e=>({value:e.value,text:e.textContent?.trim()||\"\",selected:e.selected}));return n.scrollIntoView({behavior:\"smooth\",block:\"center\"}),{success:!0,new_state:{picker_blocked:!0,current_value:n.value,available_options:e}}}const o=n instanceof HTMLInputElement&&(\"checkbox\"===n.type||\"radio\"===n.type)?n:null,a=o?cr(o):void 0,l=()=>!!o&&cr(o)!==a,c=this.resolveClickTarget(n);this.restoreForcedPopups();const d=this.revealHoverPopups(c);await this.scrollAndWait(c);const u=0===parseFloat(window.getComputedStyle(c).opacity),p=this.interactabilityReason(c);if(ca(\"gate\",{hidden:t(),interactable:!p,...p&&{reason:p},...this.describeGeometry(c)}),u||p){const e=await this.autoHoverToReveal(c);if(ca(\"reveal\",{revealed:e,hoverGated:u}),p&&!e)return{success:!1,error:p}}const h=(n=c).getAttribute(\"role\"),g=\"option\"===h||\"menuitem\"===h||!!n.closest(`${io}, [role=\"menubar\"], [role=\"grid\"]`),m=this.willDestroyTabOnClick(n,i);await(r?.onBeforeClick?.(m));const f=s();if(g&&!m?await this.cosmeticDelay(100):t()||await Promise.race([r?.untilCursorLands?.()??e(250),e(1800)]),ca(\"beat\",{hidden:t(),waitedMs:Math.round(s()-f)}),this.isActionCancelled(r?.signal))return{success:!1,error:\"Cancelled by user before the click fired\"};const b=n.getBoundingClientRect(),{centerX:y,centerY:v,pointerOptions:w,mouseOptions:x}=this.buildPointerEventOptions(b),k=this.modifierInit(i);Object.assign(w,k),Object.assign(x,k);const S=b.width>0||b.height>0,C=S?function(e,t){if(\"function\"==typeof document.elementsFromPoint)return document.elementsFromPoint(e,t);const n=document.elementFromPoint(e,t);return n?[n]:[]}(y,v):[],E=C.find(e=>(e instanceof HTMLElement||e instanceof SVGElement)&&n.contains(e))??null;let M=E??n,A=!1;if(!E&&n.hasAttribute(Gr)){const e=C.find(e=>!e.closest(Wu));e&&(M=e,A=!0)}if(ca(\"hit-test\",{used:S?E?\"elementFromPoint\":\"fallback\":\"skipped-zero-rect\",...S&&{depth:E?C.indexOf(E):-1},...S&&C.length>0&&{topmost:Yu(C[0])}}),M===n&&n instanceof SVGElement&&\"g\"===n.tagName.toLowerCase()){const e=n.querySelector(\"circle, ellipse, rect, path, line, polygon, polyline\");e&&(M=e)}!g&&(n instanceof HTMLElement||n instanceof SVGElement)&&Ku(n);const _=A||function(e){for(let t=e;t;t=t.parentElement){const e=getComputedStyle(t).cursor;if(\"grab\"===e||\"grabbing\"===e)return!0}return!1}(n)?function(){const e=Array.from(document.querySelectorAll(Wu)).map(e=>{const t=[e.style.getPropertyValue(\"pointer-events\"),e.style.getPropertyPriority(\"pointer-events\")];return e.style.setProperty(\"pointer-events\",\"none\",\"important\"),{el:e,prev:t}});let t=!1;const n=()=>{if(!t){t=!0;for(const{el:t,prev:[n,i]}of e)n?t.style.setProperty(\"pointer-events\",n,i):t.style.removeProperty(\"pointer-events\")}};return setTimeout(n,2e3),n}():null;if(this.dispatchHoverSequence(M,w,x),await e(150),this.isActionCancelled(r?.signal))return _?.(),{success:!1,error:\"Action cancelled\"};const T={...w,buttons:1,pressure:.5},I={...x,buttons:1},L=M.closest(\"a[href]\"),R=L instanceof HTMLAnchorElement?L:null,$=R?R.target:\"\",N=!!$&&\"_self\"!==$&&\"_top\"!==$&&\"_parent\"!==$||!!R&&!(!i?.ctrl&&!i?.meta),P=!!R&&N&&R.origin===location.origin;let F=null;if(P&&R){const e=R.target;R.target=\"_self\",F=()=>{R.target=e},w.ctrlKey=x.ctrlKey=!1,w.metaKey=x.metaKey=!1,T.ctrlKey=I.ctrlKey=!1,T.metaKey=I.metaKey=!1}let O=!1,q=null;const H=window.open;window.open=function(...e){const t=!1===navigator.userActivation?.isActive,n=H.apply(this,e);return n?O=!0:t&&(q=null==e[0]?\"\":String(e[0])),n};const B=this.captureExpandedState(n,M);ca(\"expanded-before\",this.describeExpanded(B));const D=m||P,z=D?null:Ru();D&&Fu();const U=[],j=e=>{U.push({event:e,t:s()})};let W=!1;try{const i=M.dispatchEvent(new PointerEvent(\"pointerdown\",T)),s=M.dispatchEvent(new MouseEvent(\"mousedown\",I));j(\"pointerdown+mousedown\"),ko(!0),i&&s&&(!function(e){if(!e.isConnected)return;const t=e.closest('a[href], area[href], button, input, select, textarea, iframe, summary, [tabindex], [contenteditable]:not([contenteditable=\"false\"])');if(t instanceof HTMLElement||t instanceof SVGElement)return void Ku(t);const n=document.activeElement;(n instanceof HTMLElement||n instanceof SVGElement)&&n!==document.body&&(n.blur(),Gu(n))}(M),z?.rebaseFocus()),await e(50),M.dispatchEvent(new PointerEvent(\"pointerup\",w)),M.dispatchEvent(new MouseEvent(\"mouseup\",x)),j(\"pointerup+mouseup\"),W=this.menuOpenedDuringGesture(B,n,M);const r=this.maybeDispatchTrailingClick(M,x,W,A);r&&j(\"click\"),ca(\"gesture\",{pressHoldMs:50,hidden:t(),events:U}),ca(\"trailing-click\",{fired:r,reason:r?M.closest(\"a[href]\")?\"anchor\":\"no-menu-opened\":\"suppressed-menu-opened-during-press\"})}finally{ko(!1),_?.(),window.open=H,F?.()}if(D&&Ou()&&(ha(\"nav:imminent\",{navigateInSameTab:P,anchorWantsNewTab:N,openedViaScript:O}),this.onNavigationImminent(),this.retractNavigationWarningIfDocumentSurvives()),null!==q&&!D){z?.stop();const e=function(e){if(!e.trim())return null;try{const t=new URL(e,window.location.href);return t.origin===window.location.origin?t.href:null}catch{return null}}(q);return e?(Fu(),ha(\"nav:imminent\",{navigateInSameTab:!0,blockedNewTab:!0}),this.onNavigationImminent(),this.retractNavigationWarningIfDocumentSurvives(),window.location.assign(e),{success:!0}):{success:!1,error:`The click tried to open ${q||\"a page\"} in a new tab and the browser blocked it (new tabs need a real user click). Ask the user to click it themselves.`}}if(P||!N&&!O||this.onBrowsingContextOpen?.(),!z)return{success:!0};let V=await z.waitForChange(250);if(!V.any&&!l()&&!this.isActionCancelled(r?.signal)){const e=Ru(),t=o?await this.recoverCheckable(o,n,!0===a,r?.signal):await this.recoverPressManagedToggle(n,M,B,W,r?.signal);V=t?await e.waitForChange(250):e.stop(),ca(\"recovery\",{retried:t})}return ca(\"effect\",{...V,revealedPopups:d,...o&&{toggled:l()}}),{success:!0,new_state:{no_op:!V.any&&!l()&&0===d}}}async retractNavigationWarningIfDocumentSurvives(){await async function(e=$u.pollMs){const t=Nu;return await qu(e),window.location.href!==t}()&&(ha(\"nav:retracted\",{url:window.location.href}),this.onNavigationSettled())}captureExpandedState(e,t){const n=new Map,i=e=>{e.hasAttribute(\"aria-expanded\")&&n.set(e,e.getAttribute(\"aria-expanded\"))};for(const n of new Set([e,t])){let e=n;for(let t=0;e&&t<5;t++)i(e),e=e.parentElement;n.querySelectorAll(\"[aria-expanded]\").forEach(i)}return n}menuOpenedDuringGesture(e,t,n){const i=this.captureExpandedState(t,n);for(const[t,n]of i)if(\"true\"===n&&\"true\"!==e.get(t))return!0;return!1}describeExpanded(e){return{expanded:[...e].map(([e,t])=>`${e.tagName.toLowerCase()}[aria-expanded=${t}]`)}}describeGeometry(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e);return{rect:`${Math.round(t.width)}x${Math.round(t.height)}@${Math.round(t.left)},${Math.round(t.top)}`,display:n.display,visibility:n.visibility,opacity:n.opacity,connected:e.isConnected}}async recoverPressManagedToggle(t,n,i,s,r){const o=i.get(t)??null;if(!(t instanceof HTMLElement)||null===o||t.getAttribute(\"aria-expanded\")!==o)return!1;for(let n=0;n<6&&t.getAttribute(\"aria-expanded\")===o;n++)if(await e(50),this.isActionCancelled(r))return!1;return!(!t.isConnected||t.getAttribute(\"aria-expanded\")!==o||s||this.menuOpenedDuringGesture(i,t,n))&&(t.click(),!0)}async recoverCheckable(t,n,i,s){if(\"radio\"===t.type&&i)return!1;const r=()=>cr(t)!==i;for(let t=0;t<6&&!r();t++)if(await e(50),this.isActionCancelled(s))return!1;const o=[];for(const e of new Set([n,t])){if(r())break;e instanceof HTMLElement&&e.isConnected&&(e.click(),o.push(e.tagName.toLowerCase()))}return ca(\"checkable-recovery\",{tried:o,landed:r()}),o.length>0}maybeDispatchTrailingClick(e,t,n,i=!1){return!(!e.closest(\"a[href]\")&&n)&&(this.dispatchClick(e,t,i),!0)}willDestroyTabOnClick(e,t){const n=e.closest(\"a[href]\");if(!(n instanceof HTMLAnchorElement))return!1;const i=n.getAttribute(\"href\")||\"\";if(!i||i.startsWith(\"#\")||i.toLowerCase().startsWith(\"javascript:\"))return!1;return!(!!n.target&&\"_self\"!==n.target&&\"_top\"!==n.target&&\"_parent\"!==n.target||!(!t?.ctrl&&!t?.meta))||n.origin===location.origin}modifierInit(e){return{ctrlKey:e?.ctrl??!1,metaKey:e?.meta??!1,shiftKey:e?.shift??!1,altKey:e?.alt??!1}}dispatchClick(e,t,n=!1){const i=!!(t.ctrlKey||t.metaKey||t.shiftKey||t.altKey);e instanceof HTMLElement&&!i&&!n?e.click():e.dispatchEvent(new MouseEvent(\"click\",{...t,composed:!0}))}revealHoverPopups(e){if(!(e instanceof HTMLElement))return 0;const t=fo(e);if(0===t.length)return 0;for(const e of t)this.forcedPopups.push({el:e,display:e.style.getPropertyValue(\"display\"),priority:e.style.getPropertyPriority(\"display\")}),e.style.setProperty(\"display\",\"block\",\"important\");return t.length}restoreForcedPopups(){for(const{el:e,display:t,priority:n}of this.forcedPopups)e.isConnected&&(t?e.style.setProperty(\"display\",t,n):e.style.removeProperty(\"display\"));this.forcedPopups=[]}async executeType(n,i,s=!0,r){if(!(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement||n.isContentEditable)){const e=n.querySelector('input:not([type=\"hidden\"]):not([disabled]), textarea:not([disabled]), [contenteditable=\"true\"]');e instanceof HTMLElement&&(n=e)}const o=n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement,a=n.isContentEditable||\"true\"===n.contentEditable,l=n.getAttribute(\"role\"),c=\"textbox\"===l||\"searchbox\"===l||\"combobox\"===l,d=\"text\"===window.getComputedStyle(n).cursor,u=n.classList.contains(\"ProseMirror\")||n.classList.contains(\"tiptap\")||n.classList.contains(\"ql-editor\")||n.classList.contains(\"slate-editor\")||n.hasAttribute(\"data-slate-editor\")||n.hasAttribute(\"data-lexical-editor\")||n.hasAttribute(\"data-placeholder\")||n.classList.contains(\"DraftEditor-root\")||n.classList.contains(\"public-DraftEditor-content\")||n.classList.contains(\"cke_editable\")||n.classList.contains(\"ck-editor__editable\")||n.classList.contains(\"mce-content-body\")||n.classList.contains(\"fr-element\")||n.classList.contains(\"jodit_wysiwyg\")||null!==n.closest(\".ProseMirror, .tiptap, [data-slate-editor], [data-lexical-editor], [data-placeholder], .DraftEditor-root, .public-DraftEditor-content, .cke_editable, .ck-editor__editable, .mce-content-body, .fr-element, .jodit_wysiwyg\"),p=n.tabIndex>=0||n.hasAttribute(\"tabindex\");if(!o&&!(a||c||u||d&&p))return{success:!1,error:\"Element is not a text input\"};if(await this.scrollAndWait(n),this.isActionCancelled(r))return{success:!1,error:\"Action cancelled\"};const h=!document.hasFocus()&&document.activeElement!==n;if(h&&Gu(document.activeElement),n.dispatchEvent(new FocusEvent(\"focusin\",{bubbles:!0})),n.focus(),n.dispatchEvent(new FocusEvent(\"focus\",{bubbles:!1})),h&&(Vu=n),u)return this.executeRichEditorType(n,i,s);s&&(n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement?n.select():(this.setNativeValue(n,\"\"),n.dispatchEvent(new Event(\"input\",{bubbles:!0}))));if(n instanceof HTMLInputElement&&\"number\"===n.type||t()){const e=i[i.length-1];n.dispatchEvent(new KeyboardEvent(\"keydown\",{key:e,bubbles:!0})),this.dispatchBeforeInput(n,i,\"insertReplacementText\"),this.setNativeValue(n,i),this.dispatchInput(n,i,\"insertReplacementText\"),n.dispatchEvent(new KeyboardEvent(\"keyup\",{key:e,bubbles:!0}))}else{const t=Math.min(30,Math.floor(3e3/i.length));let s=\"\";for(const o of i){if(this.isActionCancelled(r))return{success:!1,error:\"Action cancelled\"};if(s+=o,document.activeElement!==n){if(!n.isConnected)break;n.focus()}n.dispatchEvent(new KeyboardEvent(\"keydown\",{key:o,bubbles:!0})),n.dispatchEvent(new KeyboardEvent(\"keypress\",{key:o,bubbles:!0})),this.dispatchBeforeInput(n,o,\"insertText\"),this.setNativeValue(n,s),this.dispatchInput(n,o,\"insertText\"),n.dispatchEvent(new KeyboardEvent(\"keyup\",{key:o,bubbles:!0})),t>0&&await e(t)}if(this.isActionCancelled(r))return{success:!1,error:\"Action cancelled\"};n.isConnected&&n.value!==i&&(document.activeElement!==n&&n.focus(),this.dispatchBeforeInput(n,i,\"insertReplacementText\"),this.setNativeValue(n,i),this.dispatchInput(n,i,\"insertReplacementText\"))}n.dispatchEvent(new Event(\"change\",{bubbles:!0}));return{success:!0,new_state:{value:n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement?n.value:n.textContent||\"\"}}}isActionCancelled(e){return!0===e?.aborted||this.isCancelled()}draftJsFiberInsert(e,t){try{const n=Object.keys(e).find(e=>e.startsWith(\"__reactFiber\"));let i=n&&e[n];for(let e=0;i&&e<50;e++,i=i.return){const{editorState:e,onChange:n}=i.memoizedProps??{};if(!e||\"function\"!=typeof n)continue;const s=e.constructor,r=e.getCurrentContent().constructor;return n(s.createWithContent(r.createFromText(t))),!0}}catch{}return!1}async executeRichEditorType(t,n,i){if(t.classList.contains(\"public-DraftEditor-content\")&&!t.textContent?.trim())return this.draftJsFiberInsert(t,n)?(await e(50),{success:!0,new_state:{value:n}}):{success:!1,error:\"Empty Draft.js editor: fiber unreachable. Ask the user to type one character into the field first.\"};const s=window.getSelection();if(s){const e=document.createRange();e.selectNodeContents(t),i||e.collapse(!1),s.removeAllRanges(),s.addRange(e)}return document.execCommand(\"insertText\",!1,n),await e(50),{success:!0,new_state:{value:t.textContent||\"\"}}}dispatchBeforeInput(e,t,n){try{e.dispatchEvent(new InputEvent(\"beforeinput\",{data:t,inputType:n,bubbles:!0,cancelable:!0}))}catch{e.dispatchEvent(new Event(\"beforeinput\",{bubbles:!0,cancelable:!0}))}}dispatchInput(e,t,n){try{e.dispatchEvent(new InputEvent(\"input\",{data:t,inputType:n,bubbles:!0}))}catch{e.dispatchEvent(new Event(\"input\",{bubbles:!0}))}}setNativeValue(e,t){if(e instanceof HTMLInputElement){const n=Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype,\"value\")?.set;n?n.call(e,t):e.value=t}else if(e instanceof HTMLTextAreaElement){const n=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,\"value\")?.set;n?n.call(e,t):e.value=t}else e.isContentEditable||\"true\"===e.contentEditable?e.textContent=t:(e.hasAttribute(\"role\")||e.tabIndex>=0)&&(e.focus(),\"\"===t?(document.execCommand(\"selectAll\",!1),document.execCommand(\"delete\",!1)):(document.execCommand(\"selectAll\",!1),document.execCommand(\"insertText\",!1,t)))}async executeSelect(t,n,i,s){if(!(t instanceof HTMLSelectElement))return{success:!1,error:\"Element is not a select dropdown\"};const r=()=>Array.from(t.options).map(e=>({value:e.value,text:e.textContent?.trim()||\"\",selected:e.selected}));let o;if(\"number\"==typeof i){if(o=t.options[i],!o)return{success:!1,error:`Option at index ${i} not found (total: ${t.options.length})`,new_state:{available_options:r()}}}else n&&(o=Array.from(t.options).find(e=>e.value===n||e.textContent?.trim().toLowerCase()===n.toLowerCase()));if(!o)return n?{success:!1,error:`Option \"${n}\" not found in dropdown`,new_state:{available_options:r()}}:{success:!1,error:\"No value or select_index provided for select action\"};if(await this.scrollAndWait(t),this.isActionCancelled(s))return{success:!1,error:\"Action cancelled\"};if(t.focus(),t.dispatchEvent(new MouseEvent(\"mousedown\",{bubbles:!0})),t.click(),await e(50),this.isActionCancelled(s))return{success:!1,error:\"Action cancelled\"};const a=Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,\"value\")?.set;return a?a.call(t,o.value):t.value=o.value,o.selected=!0,t.dispatchEvent(new Event(\"input\",{bubbles:!0})),t.dispatchEvent(new Event(\"change\",{bubbles:!0})),{success:!0,new_state:{value:t.value,selectedText:o.textContent?.trim()}}}async executeCheck(e,t,n){if(e instanceof HTMLInputElement&&(\"checkbox\"===e.type||\"radio\"===e.type)){const i=t??!cr(e);if(cr(e)===i)return{success:!0,new_state:{checked:i,wanted:i}};const s=Tu(e),r=await this.executeClick(e,void 0,n);if(!r.success)return r;const o=s();return o instanceof HTMLInputElement?{success:!0,new_state:{...r.new_state,checked:cr(o),wanted:i}}:r}const i=ur(e);if(null===i&&\"boolean\"==typeof t)return{success:!1,error:`Cannot read whether this control is on or off, so check(${t}) would be a guess and could flip it the wrong way. Look at it on screen; if it needs to change, use click and verify the result.`};const s=t??(null===i?null:!i);if(null!==s&&i===s)return{success:!0,new_state:{checked:s,wanted:s}};const r=Tu(e),o=await this.executeClick(e,void 0,n);if(!o.success)return o;const a=r(),l=a?ur(a):null;return{success:!0,new_state:{...o.new_state,...null!==l&&{checked:l},...null!==l&&null!==s&&{wanted:s}}}}async executeScrollTo(n){return t()?(n.scrollIntoView({behavior:\"instant\",block:\"center\",inline:\"center\"}),this.onHiddenScroll(n)):(n.scrollIntoView({behavior:\"smooth\",block:\"center\",inline:\"center\"}),await e(500)),{success:!0}}async executeScrollToText(n){const i=document.querySelector(n);if(!i)return{success:!1,error:`Element not found for selector: ${n}`};const s=this.findScrollableAncestor(i);if(t()){if(s){const e=i.getBoundingClientRect(),t=s.getBoundingClientRect(),n=s.scrollTop+(e.top-t.top)-t.height/2+e.height/2;s.scrollTo({top:Math.max(0,n),behavior:\"instant\"})}else i.scrollIntoView({behavior:\"instant\",block:\"center\"});this.onHiddenScroll(i)}else{if(s){const e=i.getBoundingClientRect(),t=s.getBoundingClientRect(),n=s.scrollTop+(e.top-t.top)-t.height/2+e.height/2;s.scrollTo({top:Math.max(0,n),behavior:\"smooth\"})}else i.scrollIntoView({behavior:\"smooth\",block:\"center\"});await e(300)}return{success:!0}}findScrollableAncestor(e){let t=e.parentElement;for(;t&&t!==document.documentElement;){const e=window.getComputedStyle(t).overflowY;if((\"auto\"===e||\"scroll\"===e)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null}buildPointerEventOptions(e){const t=e.left+e.width/2,n=e.top+e.height/2,i={bubbles:!0,cancelable:!0,composed:!0,view:window,clientX:t,clientY:n,screenX:t+window.screenX,screenY:n+window.screenY};return{centerX:t,centerY:n,pointerOptions:{...i,pointerId:1,pointerType:\"mouse\",isPrimary:!0,button:0,buttons:0,pressure:0,width:1,height:1},mouseOptions:{...i,button:0,buttons:0,detail:1}}}dispatchHoverSequence(e,t,n){e.dispatchEvent(new PointerEvent(\"pointerover\",t)),e.dispatchEvent(new PointerEvent(\"pointerenter\",{...t,bubbles:!1})),e.dispatchEvent(new MouseEvent(\"mouseover\",n)),e.dispatchEvent(new MouseEvent(\"mouseenter\",{...n,bubbles:!1})),e.dispatchEvent(new PointerEvent(\"pointermove\",t)),e.dispatchEvent(new MouseEvent(\"mousemove\",n))}async executeHover(t,n,i){const s=this.resolveClickTarget(t);if(this.revealHoverPopups(s),await this.scrollAndWait(s),this.isActionCancelled(i))return{success:!1,error:\"Action cancelled\"};const r=0===parseFloat(window.getComputedStyle(s).opacity),o=this.interactabilityReason(s);if(r||o){const e=await this.autoHoverToReveal(s);if(this.isActionCancelled(i))return{success:!1,error:\"Action cancelled\"};if(o&&!e)return{success:!1,error:o}}if(await this.cosmeticDelay(300),this.isActionCancelled(i))return{success:!1,error:\"Action cancelled\"};const a=s.getBoundingClientRect(),{centerX:l,centerY:c,pointerOptions:d,mouseOptions:u}=this.buildPointerEventOptions(a),p=document.elementFromPoint(l,c),h=p instanceof HTMLElement&&s.contains(p)?p:s;this.dispatchHoverSequence(h,d,u);const g=n??500;return await e(g),{success:!0,new_state:{hovered:!0,duration_ms:g}}}async executeHighlight(e,t,n){return n?await n():await this.scrollAndWait(e),{success:!0,new_state:{highlighted:!0,duration_ms:Math.max(3e3,t??3e3)}}}async executeNavigate(e){try{const t=new URL(e,window.location.origin);return t.hostname!==window.location.hostname?{success:!1,error:`Navigation blocked: cannot navigate to external domain \"${t.hostname}\"`}:(window.location.href=t.href,{success:!0,new_state:{url:t.href}})}catch{return{success:!1,error:\"Invalid URL\"}}}async executeWaitFor(t){const n=s(),i=t.timeout_ms||5e3;for(;s()-n<i;){if(await this.checkWaitCondition(t))return{success:!0};await e(200)}return{success:!1,error:`Condition not met within ${i}ms`}}async checkWaitCondition(e){switch(e.type){case\"element_visible\":if(e.target){const t=this.elementResolver.resolve(e.target);return null!==t.element&&this.isVisible(t.element)}return!1;case\"element_hidden\":if(e.target){const t=this.elementResolver.resolve(e.target);return null===t.element||!this.isVisible(t.element)}return!0;case\"text_present\":return!!e.value&&(document.body.textContent?.includes(e.value)??!1);case\"url_contains\":return!!e.value&&window.location.href.includes(e.value);default:return!1}}async executePressKey(t,n,i,s){if(await this.scrollAndWait(t),this.isActionCancelled(s))return{success:!1,error:\"Action cancelled\"};if(Ku(t),await e(50),this.isActionCancelled(s))return{success:!1,error:\"Action cancelled\"};const r={key:n,code:this.getKeyCode(n),bubbles:!0,cancelable:!0,ctrlKey:i?.ctrl??!1,shiftKey:i?.shift??!1,altKey:i?.alt??!1,metaKey:i?.meta??!1},o=t.dispatchEvent(this.makeKeyboardEvent(\"keydown\",n,r));if(await e(50),this.isActionCancelled(s))return t.dispatchEvent(this.makeKeyboardEvent(\"keyup\",n,r)),{success:!1,error:\"Action cancelled\"};if(t.dispatchEvent(this.makeKeyboardEvent(\"keypress\",n,r)),t.dispatchEvent(this.makeKeyboardEvent(\"keyup\",n,r)),\"Enter\"===n&&o&&!i?.ctrl&&!i?.alt&&!i?.meta){const e=t.closest(\"form\");e&&e.requestSubmit()}return{success:!0,new_state:{key:n,modifiers:i}}}getKeyCode(e){return{Enter:\"Enter\",Escape:\"Escape\",Tab:\"Tab\",Space:\"Space\",ArrowUp:\"ArrowUp\",ArrowDown:\"ArrowDown\",ArrowLeft:\"ArrowLeft\",ArrowRight:\"ArrowRight\",Backspace:\"Backspace\",Delete:\"Delete\"}[e]||`Key${e.toUpperCase()}`}makeKeyboardEvent(e,t,n){const i=new KeyboardEvent(e,n),s=this.legacyKeyCode(t);return void 0!==s&&(Object.defineProperty(i,\"keyCode\",{get:()=>s}),Object.defineProperty(i,\"which\",{get:()=>s})),i}legacyKeyCode(e){const t={Enter:13,Escape:27,Tab:9,\" \":32,Space:32,ArrowUp:38,ArrowDown:40,ArrowLeft:37,ArrowRight:39,Backspace:8,Delete:46};return e in t?t[e]:1===e.length?e.toUpperCase().charCodeAt(0):void 0}async undo(){const e=this.undoStack.pop();if(!e)return!1;const{element:t,previousState:n}=e;if(n&&\"object\"==typeof n){const e=n;\"value\"in e&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement)&&(t.value=e.value,t.dispatchEvent(new Event(\"input\",{bubbles:!0})),t.dispatchEvent(new Event(\"change\",{bubbles:!0}))),\"checked\"in e&&t instanceof HTMLInputElement&&(t.checked=e.checked,t.dispatchEvent(new Event(\"change\",{bubbles:!0}))),\"selectedIndex\"in e&&t instanceof HTMLSelectElement&&(t.selectedIndex=e.selectedIndex,t.dispatchEvent(new Event(\"change\",{bubbles:!0})))}return!0}clearUndoStack(){this.undoStack=[]}captureState(e,t){return\"click\"===t.type||\"scroll_to\"===t.type||\"scroll_to_text\"===t.type||\"highlight\"===t.type?null:e instanceof HTMLInputElement?{value:e.value,checked:e.checked}:e instanceof HTMLTextAreaElement?{value:e.value}:e instanceof HTMLSelectElement?{value:e.value,selectedIndex:e.selectedIndex}:\"true\"===e.contentEditable?{textContent:e.textContent}:null}isVisible(e){return Ds(e)}interactabilityReason(e){return function(e,t=Os()){return e.isConnected?e.hasAttribute(\"disabled\")||\"true\"===e.getAttribute(\"aria-disabled\")?\"Element is disabled\":Ds(e,t)?null:\"Element is not visible (hidden or zero-size)\":\"Element is no longer in the DOM (likely replaced by a re-render from a prior action)\"}(e)}ensureForceVisibleStyle(){if(Xu.forceVisibleStyleInjected)return;const e=document.createElement(\"style\");e.textContent=`\\n      .${Xu.FORCE_VISIBLE_CLASS} {\\n        opacity: 1 !important;\\n        transition: opacity 0.15s ease-in-out !important;\\n      }\\n    `,document.head.appendChild(e),Xu.forceVisibleStyleInjected=!0}async autoHoverToReveal(t){let n=t.parentElement;for(;n&&n!==document.body;){if(this.isVisible(n)){const i=n.getBoundingClientRect(),s=i.left+i.width/2,r=i.top+i.height/2,o={bubbles:!0,cancelable:!0,view:window,clientX:s,clientY:r,screenX:s+window.screenX,screenY:r+window.screenY};n.dispatchEvent(new MouseEvent(\"mouseenter\",{...o,bubbles:!1})),n.dispatchEvent(new MouseEvent(\"mouseover\",o)),n.dispatchEvent(new PointerEvent(\"pointerenter\",{...o,bubbles:!1})),n.dispatchEvent(new PointerEvent(\"pointerover\",o)),n.dispatchEvent(new MouseEvent(\"mousemove\",o)),n.dispatchEvent(new PointerEvent(\"pointermove\",o));return\"0\"===window.getComputedStyle(t).opacity&&(this.ensureForceVisibleStyle(),t.classList.add(Xu.FORCE_VISIBLE_CLASS)),await e(300),!0}n=n.parentElement}return!1}cosmeticDelay(n){return t()?Promise.resolve():e(n)}}Xu.FORCE_VISIBLE_CLASS=\"agent-force-visible\",Xu.forceVisibleStyleInjected=!1;const Ju=[\"navigate\",\"wait_for\",\"scroll_to_text\"],Qu=new Set([\"click\",\"select\",\"check\",\"type\"]);class Zu{constructor(e,t,n,i){this.elementResolver=e,this.executionEngine=t,this.confirmationUI=n,this.validator=i}isNoTargetAction(e){return Ju.includes(e)}beginValidation(e,t,n=!1,i){return n||!this.validator?null:this.validator.beginObservation(e,t,i)}async finishValidation(e){if(!e||!this.validator)return null;try{return await this.validator.finishObservation(e)}catch(t){return Ji(\"post-action validation\",t),e.observer?.disconnect(),null}}async executeNoTarget(e,t){return this.executionEngine.execute(e,document.body,{signal:t})}async resolve(e,t,n){if(\"highlight\"===e.type&&e.ref){const n=function(e){const t=ea.get(e);return t&&document.contains(t)?t:null}(e.ref);if(n||0===Object.keys(t).length)return{element:n,action:e,allCandidates:n?[{element:n,score:1}]:[],hasAmbiguousMatches:!1,ambiguousCandidates:[],reveal:{hoveredContainers:[]}}}const i=await this.elementResolver.resolveWithReveal(t,n?.timeoutMs||5e3);if(!i.element)return{element:null,action:e,allCandidates:i.all_candidates||[],hasAmbiguousMatches:!1,ambiguousCandidates:[],reveal:i.reveal};const s=function(e,t){if(!(t instanceof HTMLOptionElement))return{action:e,element:t};const n=t.closest(\"select\");return n?\"click\"===e.type?{action:{type:\"select\",value:t.value},element:n}:\"select\"===e.type?{action:e,element:n}:{action:e,element:t}:{action:e,element:t}}(e,i.element),r=s.element;let o=!1,a=[];const l=\"string\"==typeof t.agent_id||\"number\"==typeof t.match_index||\"number\"==typeof t.element_index||!0===t.is_native_select&&\"number\"==typeof t.select_index,c=i.all_candidates||[];if(c.length>1&&!l){const e=c[0]?.score||0,t=c.filter(t=>e-t.score<.1);t.length>1&&(o=!0,a=t)}return{element:r,action:s.action,allCandidates:c,hasAmbiguousMatches:o,ambiguousCandidates:a,reveal:i.reveal}}async executeWithHighlight(e,t,n,i,s){const r=()=>{},o=i?.hoveredContainers?.length?this.confirmationUI?.startHoverPersistence(i.hoveredContainers)??r:r,a=this.confirmationUI?.highlightDuringAction(t,n,Qu.has(e.type)),l=this.confirmationUI,c={signal:s?.signal,onBeforeClick:s?.onBeforeClick,untilCursorLands:l?()=>l.whenCursorLanded():void 0,revealHighlight:l?.revealHighlight()},d=this.beginValidation(e,t,s?.skipValidation);if(a instanceof Promise)try{const n=await this.executionEngine.execute(e,t,c),[i,s]=await Promise.all([a,this.finishValidation(d)]);return o(),ep(n,s),{result:n,cleanupHighlight:r,highlightAutoResult:i}}catch(e){throw o(),d?.observer?.disconnect(),e}const u=a??r,p=()=>{u(),o()};try{const n=await this.executionEngine.execute(e,t,c);return ep(n,await this.finishValidation(d)),{result:n,cleanupHighlight:p}}catch(e){throw p(),d?.observer?.disconnect(),e}}}function ep(e,t){t&&(e.new_state={...e.new_state??{},post_action_signals:t})}class tp{constructor(){this.cursorEl=null,this.arrival=Promise.resolve(),this.lastTransform=\"\",this.lastMovedAt=0,this.styleEl=null,this.colorUnsubscribe=null,this.followFrame=null,this.sessionEnded=!1,this.colorUnsubscribe=bs.subscribe(()=>this.refreshStyles())}beginSession(){this.sessionEnded=!1}async moveTo(e){this.sessionEnded||(this.ensureCursor(),this.cursorEl&&(this.arrival=this.glideTo(e),await this.arrival,this.cursorEl&&this.triggerClickPulse()))}whenLanded(){return this.arrival}async glideTo(n){if(await this.followUntilSettled(n),!this.cursorEl||t())return;const i=this.lastMovedAt+300-performance.now();i>0&&await e(i)}async followUntilSettled(n){if(null!==this.followFrame&&cancelAnimationFrame(this.followFrame),t())return void this.placeAt(n);let i=!1;const s=new Promise(e=>{let t=n.getBoundingClientRect().top,s=0;const r=performance.now(),o=()=>{if(i)return;if(!this.cursorEl)return this.followFrame=null,void e();this.placeAt(n);const a=n.getBoundingClientRect();a.top===t?s++:(s=0,t=a.top);const l=performance.now()-r;if(s>=2&&l>=350||l>1400)return this.followFrame=null,void e();this.followFrame=requestAnimationFrame(o)};this.followFrame=requestAnimationFrame(o)});await Promise.race([s,e(1400)]),i=!0,null!==this.followFrame&&(cancelAnimationFrame(this.followFrame),this.followFrame=null)}placeAt(e){if(!this.cursorEl)return;const t=e.getBoundingClientRect(),n=`translate(${t.left+t.width/2}px, ${t.top+t.height/2}px)`;n!==this.lastTransform&&(this.lastTransform=n,this.lastMovedAt=performance.now(),this.cursorEl.style.transform=n)}endSession(){if(this.sessionEnded=!0,!this.cursorEl)return;const e=this.cursorEl;this.cursorEl=null,e.classList.add(\"agent-cursor-fade-out\"),setTimeout(()=>os(e),250)}destroy(){this.sessionEnded=!0,null!==this.followFrame&&(cancelAnimationFrame(this.followFrame),this.followFrame=null),os(this.cursorEl),this.cursorEl=null,os(this.styleEl),this.styleEl=null,this.colorUnsubscribe?.(),this.colorUnsubscribe=null}triggerClickPulse(){this.cursorEl&&(this.cursorEl.classList.remove(\"agent-cursor-clicking\"),this.cursorEl.offsetWidth,this.cursorEl.classList.add(\"agent-cursor-clicking\"))}ensureCursor(){if(this.cursorEl)return;this.injectStyles();const e=document.createElement(\"div\");e.className=\"agent-cursor\";const t=window.innerWidth/2,n=window.innerHeight-80;e.style.transform=`translate(${t}px, ${n}px)`,e.innerHTML='\\n      <div class=\"agent-cursor-halo\"></div>\\n      <div class=\"agent-cursor-ring agent-cursor-ring-1\"></div>\\n      <div class=\"agent-cursor-ring agent-cursor-ring-2\"></div>\\n      <div class=\"agent-cursor-flash\"></div>\\n      <svg class=\"agent-cursor-arrow\" width=\"22\" height=\"22\" viewBox=\"0 0 24 24\" fill=\"none\" aria-hidden=\"true\">\\n        <path d=\"M5 3L19 12L12 13.5L9 21L5 3Z\" fill=\"white\" stroke=\"black\" stroke-width=\"1.5\" stroke-linejoin=\"round\"/>\\n      </svg>\\n    ',document.body.appendChild(e),this.cursorEl=e}refreshStyles(){os(this.styleEl),this.styleEl=null,this.cursorEl&&this.injectStyles()}injectStyles(){if(this.styleEl)return;const e=S(bs.getPrimaryColor()),t=document.createElement(\"style\");t.id=\"agent-cursor-styles\",t.textContent=`\\n      @keyframes agentCursorFadeIn {\\n        from { opacity: 0; }\\n        to   { opacity: 1; }\\n      }\\n\\n      @keyframes agentCursorClickRing {\\n        0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 0.95; border-width: 3px; }\\n        70%  { opacity: 0.4; border-width: 2px; }\\n        100% { transform: translate(-50%, -50%) scale(3.2); opacity: 0; border-width: 1px; }\\n      }\\n\\n      @keyframes agentCursorClickPress {\\n        0%   { transform: scale(1); }\\n        35%  { transform: scale(0.62); }\\n        70%  { transform: scale(1.08); }\\n        100% { transform: scale(1); }\\n      }\\n\\n      @keyframes agentCursorClickFlash {\\n        0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0.7; }\\n        100% { transform: translate(-50%, -50%) scale(2.6); opacity: 0; }\\n      }\\n\\n      .agent-cursor {\\n        position: fixed;\\n        top: 0;\\n        left: 0;\\n        width: 0;\\n        height: 0;\\n        z-index: 2147483647;\\n        pointer-events: none;\\n        opacity: 1;\\n        animation: agentCursorFadeIn 0.25s ease-out;\\n        transition: transform 500ms cubic-bezier(0.22, 1, 0.36, 1),\\n                    opacity 0.25s ease-out;\\n        will-change: transform;\\n      }\\n\\n      .agent-cursor-fade-out {\\n        opacity: 0;\\n      }\\n\\n      .agent-cursor-halo {\\n        position: absolute;\\n        top: 50%;\\n        left: 50%;\\n        width: 36px;\\n        height: 36px;\\n        margin: -18px 0 0 -18px;\\n        border-radius: 50%;\\n        background: radial-gradient(\\n          circle,\\n          rgba(${e}, 0.35) 0%,\\n          rgba(${e}, 0.15) 50%,\\n          rgba(${e}, 0) 75%\\n        );\\n      }\\n\\n      .agent-cursor-arrow {\\n        position: absolute;\\n        top: 50%;\\n        left: 50%;\\n        margin: -11px 0 0 -7px;\\n        filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.25));\\n        transform-origin: center;\\n      }\\n\\n      .agent-cursor-ring {\\n        position: absolute;\\n        top: 50%;\\n        left: 50%;\\n        width: 24px;\\n        height: 24px;\\n        margin: -12px 0 0 -12px;\\n        border: 3px solid rgba(${e}, 0.85);\\n        border-radius: 50%;\\n        opacity: 0;\\n        pointer-events: none;\\n      }\\n\\n      .agent-cursor-flash {\\n        position: absolute;\\n        top: 50%;\\n        left: 50%;\\n        width: 28px;\\n        height: 28px;\\n        margin: -14px 0 0 -14px;\\n        border-radius: 50%;\\n        background: radial-gradient(\\n          circle,\\n          rgba(${e}, 0.6) 0%,\\n          rgba(${e}, 0.2) 50%,\\n          rgba(${e}, 0) 80%\\n        );\\n        opacity: 0;\\n        pointer-events: none;\\n      }\\n\\n      .agent-cursor-clicking .agent-cursor-ring-1 {\\n        animation: agentCursorClickRing 0.65s cubic-bezier(0.16, 1, 0.3, 1);\\n      }\\n\\n      .agent-cursor-clicking .agent-cursor-ring-2 {\\n        animation: agentCursorClickRing 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.12s;\\n      }\\n\\n      .agent-cursor-clicking .agent-cursor-flash {\\n        animation: agentCursorClickFlash 0.45s ease-out;\\n      }\\n\\n      .agent-cursor-clicking .agent-cursor-arrow {\\n        animation: agentCursorClickPress 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);\\n      }\\n\\n      @media (prefers-reduced-motion: reduce) {\\n        .agent-cursor {\\n          transition: opacity 0.2s ease-out;\\n        }\\n        .agent-cursor-clicking .agent-cursor-ring-1,\\n        .agent-cursor-clicking .agent-cursor-ring-2,\\n        .agent-cursor-clicking .agent-cursor-flash,\\n        .agent-cursor-clicking .agent-cursor-arrow {\\n          animation: none;\\n        }\\n      }\\n    `,document.head.appendChild(t),this.styleEl=t}}const np=450;class ip{constructor(){this.layer=null,this.styleEl=null,this.tap=null,this.arrival=Promise.resolve(),this.move=0,this.sessionEnded=!1,this.statusCard=null,this.clearingStatusCard=!1,this.colorUnsubscribe=bs.subscribe(()=>this.refreshStyles())}setStatusCard(e){this.statusCard=e}beginSession(){this.sessionEnded=!1}async moveTo(e,n=!0){if(this.sessionEnded)return;this.move+=1;const i=this.move;if(this.dropTap(),t())return void(this.arrival=Promise.resolve());const s=n?this.createTap(e):null;this.arrival=this.untilSettled(e,()=>i===this.move),await this.arrival,s&&i===this.move&&this.press(s)}whenLanded(){return this.arrival}endSession(){this.sessionEnded=!0,this.move+=1,this.stopPinning(),this.tap=null,this.clearStatusCard(null);const e=this.layer;e&&(this.layer=null,e.classList.add(\"agent-tap-layer--leaving\"),setTimeout(()=>os(e),150))}destroy(){this.sessionEnded=!0,this.move+=1,this.stopPinning(),this.tap=null,this.clearStatusCard(null),os(this.layer),this.layer=null,os(this.styleEl),this.styleEl=null,this.colorUnsubscribe?.(),this.colorUnsubscribe=null}async untilSettled(t,n){let i=null;const s=new Promise(e=>{let s=t.getBoundingClientRect().top,r=0;const o=performance.now(),a=()=>{if(!n())return void e();const l=t.getBoundingClientRect().top;l===s?r++:(r=0,s=l);const c=performance.now()-o;r>=2&&c>=350||c>1400?e():i=requestAnimationFrame(a)};i=requestAnimationFrame(a)});await Promise.race([s,e(1400)]),null!==i&&cancelAnimationFrame(i)}createTap(e){const t=this.ensureLayer(),n=document.createElement(\"div\");n.className=\"agent-cursor agent-tap\",n.innerHTML='<div class=\"agent-tap-ring\"><div class=\"agent-tap-fill\"></div></div>',t.appendChild(n);const i={root:n,element:e,frame:null};return this.tap=i,this.pin(i),i}pin(e){const t=()=>{if(this.tap!==e)return;const n=e.element.getBoundingClientRect();e.root.style.transform=`translate(${n.left+n.width/2}px, ${n.top+n.height/2}px)`,this.clearStatusCard(n),e.frame=requestAnimationFrame(t)};t()}press(e){e.root.classList.add(\"agent-tap--pressed\"),this.spawnRipple(e.root.style.transform),setTimeout(()=>{this.tap===e&&this.dropTap()},np)}spawnRipple(e){if(!this.layer)return;const t=document.createElement(\"div\");t.className=\"agent-tap\",t.style.transform=e,t.innerHTML='<div class=\"agent-tap-ripple\"></div>',this.layer.appendChild(t),setTimeout(()=>os(t),590)}dropTap(){this.stopPinning(),this.tap&&os(this.tap.root),this.tap=null,this.clearStatusCard(null)}stopPinning(){null!=this.tap?.frame&&cancelAnimationFrame(this.tap.frame)}clearStatusCard(e){const t=!!e&&!!this.statusCard?.covers(e);(t||this.clearingStatusCard)&&(this.clearingStatusCard=t,this.statusCard?.setClearance(e))}ensureLayer(){return this.injectStyles(),this.layer||(this.layer=document.createElement(\"div\"),this.layer.className=\"agent-tap-layer\",this.layer.setAttribute(\"aria-hidden\",\"true\")),document.body.lastElementChild!==this.layer&&document.body.appendChild(this.layer),this.layer}refreshStyles(){os(this.styleEl),this.styleEl=null,this.layer&&this.injectStyles()}injectStyles(){if(this.styleEl)return;const e=document.createElement(\"style\");e.id=\"agent-tap-styles\",e.textContent=`\\n      @keyframes agentTapApproach {\\n        from { opacity: 0; transform: scale(1.5); }\\n        to   { opacity: 1; transform: scale(1); }\\n      }\\n\\n      @keyframes agentTapPress {\\n        0%      { opacity: 1; transform: scale(1);    animation-timing-function: cubic-bezier(0.33, 0, 0.67, 1); }\\n        20%     { opacity: 1; transform: scale(0.84); animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); }\\n        55.556% { opacity: 1; transform: scale(1);    animation-timing-function: ease-out; }\\n        100%    { opacity: 0; transform: scale(1); }\\n      }\\n\\n      @keyframes agentTapFillPress {\\n        0%      { opacity: 0.24; animation-timing-function: cubic-bezier(0.33, 0, 0.67, 1); }\\n        20%     { opacity: 0.5;  animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1); }\\n        55.556%, 100% { opacity: 0.24; }\\n      }\\n\\n      @keyframes agentTapRipple {\\n        from { opacity: 0.9; transform: scale(1); }\\n        to   { opacity: 0;   transform: scale(2.2); }\\n      }\\n\\n      @keyframes agentTapFadeIn {\\n        from { opacity: 0; }\\n        to   { opacity: 1; }\\n      }\\n\\n      @keyframes agentTapHoldOut {\\n        0%, 55.556% { opacity: 1; }\\n        100%        { opacity: 0; }\\n      }\\n\\n      .agent-tap-layer {\\n        position: fixed;\\n        top: 0;\\n        left: 0;\\n        width: 0;\\n        height: 0;\\n        z-index: 2147483647;\\n        pointer-events: none;\\n        transition: opacity 150ms ease-out;\\n      }\\n\\n      .agent-tap-layer--leaving {\\n        opacity: 0;\\n      }\\n\\n      .agent-tap {\\n        position: absolute;\\n        top: 0;\\n        left: 0;\\n        width: 0;\\n        height: 0;\\n        will-change: transform;\\n      }\\n\\n      .agent-tap-ring,\\n      .agent-tap-ripple {\\n        position: absolute;\\n        top: -20px;\\n        left: -20px;\\n        width: 40px;\\n        height: 40px;\\n        box-sizing: border-box;\\n        border-radius: 50%;\\n      }\\n\\n      .agent-tap-ring {\\n        border: 2.5px solid #ffffff;\\n        box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2), 0 3px 10px rgba(0, 0, 0, 0.28), inset 0 0 0 1px rgba(0, 0, 0, 0.12);\\n        animation: agentTapApproach 220ms cubic-bezier(0.22, 1, 0.36, 1) both;\\n      }\\n\\n      .agent-tap-fill {\\n        position: absolute;\\n        inset: 0;\\n        border-radius: 50%;\\n        background: ${bs.getPrimaryColor()};\\n        opacity: 0.24;\\n      }\\n\\n      .agent-tap--pressed .agent-tap-ring {\\n        animation: agentTapPress 450ms both;\\n      }\\n\\n      .agent-tap--pressed .agent-tap-fill {\\n        animation: agentTapFillPress 450ms both;\\n      }\\n\\n      .agent-tap-ripple {\\n        border: 2px solid #ffffff;\\n        box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.16);\\n        opacity: 0;\\n        animation: agentTapRipple 500ms cubic-bezier(0.16, 1, 0.3, 1) 90ms both;\\n      }\\n\\n      @media (prefers-reduced-motion: reduce) {\\n        .agent-tap-ring {\\n          animation: agentTapFadeIn 150ms ease-out both;\\n        }\\n        .agent-tap--pressed .agent-tap-ring {\\n          animation: agentTapHoldOut 450ms both;\\n        }\\n        .agent-tap--pressed .agent-tap-fill {\\n          animation: none;\\n          opacity: 0.5;\\n        }\\n        .agent-tap-ripple {\\n          display: none;\\n        }\\n      }\\n    `,document.head.appendChild(e),this.styleEl=e}}class sp{constructor(){this.cursor=new tp,this.tap=new ip,this.touch=Sd()}setStatusCard(e){this.tap.setStatusCard(e)}beginSession(){this.touch=Sd(),this.cursor.beginSession(),this.tap.beginSession()}usesTouch(){return this.touch}moveTo(e,t=!0){return this.touch?this.tap.moveTo(e,t):this.cursor.moveTo(e)}whenLanded(){return this.touch?this.tap.whenLanded():this.cursor.whenLanded()}endSession(){this.cursor.endSession(),this.tap.endSession()}destroy(){this.cursor.destroy(),this.tap.destroy()}}function rp(e){const t=e.ownerDocument.scrollingElement,n=[];for(let i=op(e);i;i=op(i))i!==t&&ap(i)&&n.push(i);return n}function op(e){if(e.assignedSlot)return e.assignedSlot;if(e.parentElement)return e.parentElement;const t=e.parentNode;return t instanceof ShadowRoot?t.host:null}function ap(e){const{overflowX:t,overflowY:n}=getComputedStyle(e);return cp(t)&&e.scrollWidth>e.clientWidth||cp(n)&&e.scrollHeight>e.clientHeight}const lp=new Set([\"auto\",\"scroll\",\"hidden\",\"overlay\"]);function cp(e){return lp.has(e)}const dp=12;function up(e,t){const n=Math.min(e.right,t.right)-Math.max(e.left,t.left),i=Math.min(e.bottom,t.bottom)-Math.max(e.top,t.top);return n>0&&i>0?n*i:0}function pp(e,t){return up(e,t)>0}function hp(e,t,n){const i=e.getBoundingClientRect().top+e.clientTop,s=i+e.clientHeight,r=t.getBoundingClientRect();return Math.min(Math.max(n,r.bottom-s),r.top-i)}async function gp(n,i){const s=function(e,t){const n=document.scrollingElement,i=[...n?[n]:[],...rp(e).reverse()];let s=function(e,t){return e.bottom-e.top>t.bottom-t.top?e.top-t.top:(e.top+e.bottom)/2-(t.top+t.bottom)/2}(e.getBoundingClientRect(),t);const r=[];for(const t of i){if(Math.abs(s)<1)break;const i=t.scrollTop,o=e.getBoundingClientRect().top,a=t===n?s:hp(t,e,s);t.scrollTo({top:i+a,behavior:\"instant\"});const l=o-e.getBoundingClientRect().top;Math.abs(l)<1?t.scrollTo({top:i,behavior:\"instant\"}):(r.push({box:t,from:i,to:t.scrollTop}),s-=l)}for(const e of[...r].reverse())e.box.scrollTo({top:e.from,behavior:\"instant\"});return r}(n,i);if(!s.length)return;const r=t()||window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches;for(const e of s)e.box.scrollTo({top:e.to,behavior:r?\"instant\":\"smooth\"});r||await async function(t){let n=null;const i=new Promise(e=>{let i=t.getBoundingClientRect().top,s=0;const r=performance.now(),o=()=>{const a=t.getBoundingClientRect().top;Math.abs(a-i)<1?s++:(s=0,i=a);const l=performance.now()-r;s>=3&&l>=120||l>=1200?e():n=requestAnimationFrame(o)};n=requestAnimationFrame(o)});await Promise.race([i,e(1200)]),null!==n&&cancelAnimationFrame(n)}(n)}function mp(){return window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches??!1}function fp(e){e&&\"function\"==typeof e.animate&&!mp()&&e.animate([{translate:\"0 0\"},{translate:\"0 -6px\"},{translate:\"0 0\"},{translate:\"0 -3px\"},{translate:\"0 0\"}],{duration:320,easing:\"ease-out\"})}class bp{constructor(){this.el=null,this.leaving=null,this.kind=\"confirm\",this.dock=\"bottom\",this.safeTop=0,this.statusCard=null,this.placeFrame=null,this.generation=0,this.focusTaken=!1,this.styleEl=null,this.colorUnsubscribe=bs.subscribe(()=>this.refreshStyles())}setStatusCard(e){this.statusCard=e}get element(){return this.el}async present(e,t,n){this.discard();const i=++this.generation;this.injectStyles(),this.kind=n,this.dock=\"bottom\",this.safeTop=function(){const e=document.createElement(\"div\");e.style.cssText=\"position:fixed;top:0;left:0;width:0;height:env(safe-area-inset-top,0px);visibility:hidden;pointer-events:none\",document.body.appendChild(e);const t=e.getBoundingClientRect().height;return os(e),t}(),this.el=e,e.classList.add(\"agent-panel\",`agent-panel--${n}`,\"agent-panel--measuring\"),\"confirm\"===n&&this.statusCard?.setConfirming(!0),document.body.appendChild(e),this.place();const s=this.statusCard?.getStatusCardRect()??null,r=s?s.top:window.innerHeight-20,o=s?s.bottom:window.innerHeight-20,a=function(){const e=window.visualViewport;return e?e.offsetTop+e.height:window.innerHeight}(),l=e.querySelector(\".agent-panel-hint\");l&&(l.hidden=!1);const c=e.querySelector(\".agent-panel-message\");if(c){const t=e.getBoundingClientRect().height-c.getBoundingClientRect().height,n=Math.min(r-t,a)-this.safeTop-24;c.style.maxHeight=`${function(e){return 2*Math.max(0,e)/7}(n)}px`}const d=e.getBoundingClientRect();l&&(l.hidden=!0);const u=r-d.height;if(await gp(t,function(e,t,n){return{top:e+dp,bottom:Math.min(t,n)-dp}}(this.safeTop,u,a)),i!==this.generation)return!1;const p=o-u,h=this.safeTop+dp;return this.dock=function(e,t,n){const i=up(e,t);return 0===i?\"bottom\":up(e,n)<i?\"top\":\"bottom\"}(t.getBoundingClientRect(),{left:d.left,right:d.right,top:u-dp,bottom:o},{left:d.left,right:d.right,top:h,bottom:h+p+dp}),!0}show(){const e=this.el;if(e){if(\"confirm\"===this.kind&&this.takeFocus(e),\"bottom\"===this.dock)return this.statusCard?.dockPanel(\"bottom\"),void this.enter(e);this.statusCard?.setStackHidden(!0),setTimeout(()=>{this.el===e&&(this.statusCard?.dockPanel(\"top\"),this.statusCard?.setStackHidden(!1),this.enter(e))},210)}}nudge(){this.el&&(this.statusCard?.getStatusCardRect()?this.statusCard.nudge():fp(this.el))}close(){const e=++this.generation,t=this.el;if(this.el=null,this.giveFocusBack(),!t)return Promise.resolve();const n=this.kind,i=this.dock;return t.classList.contains(\"agent-panel--measuring\")?(this.stopPlacing(),os(t),this.releaseStatusCard(n,i,e),Promise.resolve()):(t.classList.replace(\"agent-panel--in\",\"agent-panel--out\"),\"top\"===i&&this.statusCard?.leaveTop(),this.leaving=t,new Promise(s=>{setTimeout(()=>{this.leaving===t&&(this.leaving=null),e===this.generation&&this.stopPlacing(),os(t),this.releaseStatusCard(n,i,e),s()},mp()?150:200)}))}destroy(){this.discard(),os(this.styleEl),this.styleEl=null,this.colorUnsubscribe?.(),this.colorUnsubscribe=null}discard(){this.generation++,this.stopPlacing(),this.giveFocusBack(),os(this.el),this.el=null,this.statusCard?.setConfirming(!1),this.statusCard?.setStackHidden(!1),this.statusCard?.dockPanel(null)}releaseStatusCard(e,t,n){n===this.generation&&(\"confirm\"===e&&this.statusCard?.setConfirming(!1),\"bottom\"!==t?(this.statusCard?.setStackHidden(!0),this.statusCard?.dockPanel(null),setTimeout(()=>{n===this.generation&&this.statusCard?.setStackHidden(!1)},140)):this.statusCard?.dockPanel(null))}enter(e){document.body.appendChild(e),e.classList.remove(\"agent-panel--measuring\"),e.classList.toggle(\"agent-panel--alone\",!this.statusCard?.getStatusCardRect()),e.classList.add(`agent-panel--${this.dock}`,\"agent-panel--in\"),this.startPlacing()}takeFocus(e){const t=document.activeElement;t&&t!==document.body||(e.querySelector(\".agent-panel-message\")?.focus({preventScroll:!0}),this.focusTaken=!0)}giveFocusBack(){if(!this.focusTaken)return;this.focusTaken=!1;const e=document.activeElement;e instanceof HTMLElement&&this.el?.contains(e)&&e.blur()}startPlacing(){this.stopPlacing();const e=()=>{this.place(),this.placeFrame=requestAnimationFrame(e)};e()}stopPlacing(){null!==this.placeFrame&&cancelAnimationFrame(this.placeFrame),this.placeFrame=null}place(){const e=this.el??this.leaving;if(!e)return;const t=this.statusCard?.getStatusCardRect()??null,n=t?t.width:Math.min(416,window.innerWidth-32);e.style.width=`${n}px`,e.style.left=`${t?t.left:(window.innerWidth-n)/2}px`,\"top\"===this.dock?(e.style.bottom=\"auto\",e.style.top=`${t?t.bottom:this.safeTop+dp}px`):(e.style.top=\"auto\",e.style.bottom=(t?window.innerHeight-t.top:20)+\"px\")}refreshStyles(){os(this.styleEl),this.styleEl=null,this.el&&this.injectStyles()}injectStyles(){if(this.styleEl)return;const e=bs.getPrimaryColor(),t=bs.getSecondaryColor(),n=1.05/(M(e)+.05)<1.5?\"#1f2937\":e,i=document.createElement(\"style\");i.id=\"agent-panel-styles\",i.textContent=`\\n      @keyframes agentPanelRiseIn {\\n        from { opacity: 0; transform: translateY(16px); }\\n        to   { opacity: 1; transform: translateY(0); }\\n      }\\n      @keyframes agentPanelSinkOut {\\n        from { opacity: 1; transform: translateY(0); }\\n        to   { opacity: 0; transform: translateY(16px); }\\n      }\\n      @keyframes agentPanelFadeIn {\\n        from { opacity: 0; }\\n        to   { opacity: 1; }\\n      }\\n      @keyframes agentPanelFadeOut {\\n        from { opacity: 1; }\\n        to   { opacity: 0; }\\n      }\\n\\n      .agent-panel {\\n        position: fixed;\\n        box-sizing: border-box;\\n        display: flex;\\n        flex-direction: column;\\n        background: #ffffff;\\n        color: #1f2937;\\n        z-index: 2147483647;\\n        pointer-events: auto;\\n        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n        -webkit-tap-highlight-color: transparent;\\n      }\\n      .agent-panel--measuring { visibility: hidden; }\\n      .agent-panel--bottom {\\n        border-radius: 16px 16px 0 0;\\n        box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.14);\\n      }\\n      .agent-panel--top {\\n        border-radius: 0 0 16px 16px;\\n        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);\\n      }\\n      .agent-panel--alone { border-radius: 16px; }\\n\\n      .agent-panel--confirm { padding: 18px; gap: 16px; }\\n      .agent-panel--confirm.agent-panel--destructive { gap: 12px; }\\n      .agent-panel--read { padding: 18px 12px 6px 18px; gap: 10px; }\\n\\n      .agent-panel-message {\\n        font-size: 16px;\\n        line-height: 23px;\\n        overflow-y: auto;\\n        overscroll-behavior: contain;\\n        outline: none;\\n      }\\n      .agent-panel--read .agent-panel-message { padding-right: 6px; }\\n      .agent-panel-message p { margin: 0 0 6px 0; }\\n      .agent-panel-message p:last-child { margin-bottom: 0; }\\n      .agent-panel-message strong { font-weight: 650; }\\n      .agent-panel-message ul,\\n      .agent-panel-message ol { margin: 4px 0; padding-left: 20px; }\\n      .agent-panel-message code {\\n        padding: 1px 4px;\\n        border-radius: 3px;\\n        background: #f3f4f6;\\n        font-size: 14px;\\n        font-family: 'SF Mono', Monaco, Consolas, monospace;\\n      }\\n\\n      .agent-panel-warning {\\n        display: flex;\\n        align-items: center;\\n        gap: 8px;\\n        box-sizing: border-box;\\n        min-height: 42px;\\n        padding: 0 12px;\\n        border: 1px solid #f59e0b;\\n        border-radius: 10px;\\n        background: #fef3c7;\\n        color: #92400e;\\n        font-size: 14px;\\n      }\\n      .agent-panel-warning svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }\\n\\n      .agent-panel-hint {\\n        padding: 10px 12px;\\n        border-radius: 10px;\\n        background: #f3f4f6;\\n        color: #374151;\\n        font-size: 14px;\\n        line-height: 20px;\\n      }\\n      .agent-panel-hint[hidden] { display: none !important; }\\n\\n      .agent-panel-buttons { display: flex; gap: 10px; }\\n      .agent-panel--destructive .agent-panel-buttons { margin-top: 4px; }\\n      .agent-panel-button {\\n        flex: 1 1 0;\\n        height: 48px;\\n        padding: 0 12px;\\n        border: 0;\\n        border-radius: 12px;\\n        font-family: inherit;\\n        font-size: 16px;\\n        font-weight: 600;\\n        cursor: pointer;\\n      }\\n      .agent-panel-stop { background: #eef0f3; color: #1f2937; }\\n      .agent-panel-confirm {\\n        background: ${e};\\n        color: ${t};\\n        box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);\\n      }\\n      .agent-panel-confirm.destructive { background: #dc2626; color: #ffffff; box-shadow: none; }\\n\\n      .agent-panel-progress { display: flex; align-items: center; gap: 8px; }\\n      .agent-panel-track {\\n        position: relative;\\n        flex: 1;\\n        height: 4px;\\n        border-radius: 2px;\\n        background: rgba(0, 0, 0, 0.08);\\n        overflow: hidden;\\n      }\\n      .agent-panel-bar {\\n        position: absolute;\\n        inset: 0;\\n        background: ${n};\\n        transform: scaleX(0);\\n        transform-origin: left;\\n        transition-property: transform;\\n        transition-timing-function: linear;\\n      }\\n      .agent-panel-skip {\\n        flex-shrink: 0;\\n        height: 44px;\\n        padding: 0 12px;\\n        border: 0;\\n        border-radius: 10px;\\n        background: transparent;\\n        font-family: inherit;\\n        font-size: 15px;\\n        font-weight: 600;\\n        color: #4b5563;\\n        cursor: pointer;\\n      }\\n\\n      .agent-panel--bottom.agent-panel--in { animation: agentPanelRiseIn 260ms cubic-bezier(0.22, 1, 0.36, 1) both; }\\n      .agent-panel--bottom.agent-panel--out { animation: agentPanelSinkOut 200ms cubic-bezier(0.4, 0, 1, 1) both; }\\n      .agent-panel--top.agent-panel--in { animation: agentPanelFadeIn 260ms cubic-bezier(0.22, 1, 0.36, 1) both; }\\n      .agent-panel--top.agent-panel--out { animation: agentPanelFadeOut 200ms cubic-bezier(0.4, 0, 1, 1) both; }\\n\\n      @media (prefers-reduced-motion: reduce) {\\n        .agent-panel--bottom.agent-panel--in,\\n        .agent-panel--top.agent-panel--in { animation: agentPanelFadeIn 150ms ease-out both; }\\n        .agent-panel--bottom.agent-panel--out,\\n        .agent-panel--top.agent-panel--out { animation: agentPanelFadeOut 150ms ease-out both; }\\n      }\\n    `,document.head.appendChild(i),this.styleEl=i}}function yp(e,t,n,i,s){return s<=0?`M ${e} ${t} L ${e+n} ${t} L ${e+n} ${t+i} L ${e} ${t+i} Z`:`M ${e+s} ${t}\\n         L ${e+n-s} ${t}\\n         Q ${e+n} ${t} ${e+n} ${t+s}\\n         L ${e+n} ${t+i-s}\\n         Q ${e+n} ${t+i} ${e+n-s} ${t+i}\\n         L ${e+s} ${t+i}\\n         Q ${e} ${t+i} ${e} ${t+i-s}\\n         L ${e} ${t+s}\\n         Q ${e} ${t} ${e+s} ${t}\\n         Z`}function vp({target:e,borderRadius:t,viewport:n,outlineEdge:i,sidePanel:s}){const r=e.width+16,o=e.height+16,a=Math.min(t,r/2,o/2)+4,l=yp(e.left-8,e.top-8,r,o,a),c=i?`<path d=\"${function(e,t,n){const i=e.width+2*t,s=e.height+2*t,r=Math.min(n,e.width/2,e.height/2)+t;return yp(e.left-t,e.top-t,i,s,Math.min(r,i/2,s/2))}(e,7.75,t)}\" fill=\"none\" stroke=\"rgba(255,255,255,0.9)\" stroke-width=\"1.5\"/>`:\"\",d=s?`<rect x=\"${\"right\"===s.side?n.width-s.width:0}\" y=\"0\" width=\"${s.width}\" height=\"${n.height}\" fill=\"black\"/>`:\"\";return`\\n      <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${n.width}\" height=\"${n.height}\">\\n        <defs>\\n          <mask id=\"agent-hole\">\\n            <rect width=\"100%\" height=\"100%\" fill=\"white\"/>\\n            <path d=\"${l}\" fill=\"black\"/>\\n            ${d}\\n          </mask>\\n        </defs>\\n        <rect width=\"100%\" height=\"100%\" fill=\"rgba(0,0,0,0.6)\" mask=\"url(#agent-hole)\"/>\\n        ${c}\\n      </svg>\\n    `}class wp{constructor(){this.statusCard=null,this.owner=0,this.frame=null}setStatusCard(e){this.statusCard=e}follow(e){const t=++this.owner;this.stopFollowing();let n=e.getBoundingClientRect();const i=()=>{const t=e.getBoundingClientRect(),s=t.top===n.top&&t.left===n.left&&t.width===n.width&&t.height===n.height;n=t;const r=function(e){return{left:e.left-8,top:e.top-8,right:e.right+8,bottom:e.bottom+8}}(t);!s&&this.statusCard?.covers(r)||this.statusCard?.setClearance(r),this.frame=requestAnimationFrame(i)};return this.frame=requestAnimationFrame(i),()=>{t===this.owner&&this.stop()}}stop(){this.owner++,this.stopFollowing(),this.statusCard?.setClearance(null)}stopFollowing(){null!==this.frame&&cancelAnimationFrame(this.frame),this.frame=null}}class xp{constructor(){this.disposables=null,this.message=\"\",this.hostTitle=\"\",this.showingMessage=!1}get isActive(){return null!==this.disposables}start(e){if(this.disposables)return this.message=e,void(this.showingMessage&&(document.title=e));this.message=e,this.hostTitle=document.title,this.showingMessage=!1,this.disposables=new fs,this.disposables.safeOn(document,\"visibilitychange\",()=>this.tick(),\"tab-title-attention: visibility\"),this.disposables.safeInterval(\"tab-title-attention: tick\",()=>this.tick(),1e3),this.tick()}stop(){this.disposables&&(this.disposables.dispose(),this.disposables=null,this.adoptHostTitleChange(),this.restore())}tick(){this.adoptHostTitleChange(),\"hidden\"!==document.visibilityState||this.showingMessage?this.restore():(document.title=this.message,this.showingMessage=!0)}restore(){this.showingMessage&&(document.title=this.hostTitle,this.showingMessage=!1)}adoptHostTitleChange(){const e=document.title;e!==(this.showingMessage?this.message:this.hostTitle)&&(this.hostTitle=e,this.showingMessage=!1)}}const kp=[\"pointerdown\",\"mousedown\",\"touchstart\",\"pointerup\",\"mouseup\",\"touchend\",\"click\"],Sp='<svg viewBox=\"0 0 24 24\"><path d=\"M12 2L1 21h22L12 2zm0 3.5l8.1 14H3.9L12 5.5zM11 10v4h2v-4h-2zm0 6v2h2v-2h-2z\"/></svg>';function Cp(e){const t=e.trim().split(/\\s+/).length/120*60*1e3;return Math.max(6e3,Math.min(18e3,t))}class Ep{constructor(){this.overlay=null,this.overlayOutlinesTarget=!1,this.confirmationCard=null,this.autoCard=null,this.currentResolve=null,this.confirmationTimer=null,this.originalStyles=null,this.highlightedElement=null,this.styleElement=null,this.colorUnsubscribe=null,this.escapeHandler=null,this.pressShield=null,this.sidePanelExclude=null,this.onCancelAgent=null,this.onAttention=null,this.titleAttention=new xp,this.highlightTimer=null,this.highlightEnterHandler=null,this.panel=new bp,this.clearance=new wp,this.releaseClearance=null,this.readingReveal=null,this.trackingFrame=null,this.hoverRevealRestore=null,this.hoverLockContainers=[],this.hoverLockInterval=null,this.injectStyles(),this.colorUnsubscribe=bs.subscribe(()=>this.refreshStyles()),this.cursor=new sp}setSidePanelExclude(e){this.sidePanelExclude=e}setStatusCard(e){this.clearance.setStatusCard(e),this.cursor.setStatusCard(e),this.panel.setStatusCard(e)}setOnCancelAgent(e){this.onCancelAgent=e}setOnAttention(e){this.onAttention=e}lockHoverUntilNextClick(e){if(!e.length)return;if(e.length===this.hoverLockContainers.length&&e.every(e=>this.hoverLockContainers.includes(e))&&null!==this.hoverLockInterval)return;const t=this.hoverLockContainers.filter(t=>!e.includes(t));t.length&&vo(t),null!==this.hoverLockInterval&&(window.clearInterval(this.hoverLockInterval),this.hoverLockInterval=null),this.hoverLockContainers=e.slice(),So(this.hoverLockContainers),this.hoverLockInterval=window.setInterval(()=>{So(this.hoverLockContainers)},400)}applyHoverLockFor(e,t=!1){const n=function(e){const t=[];let n=e;for(;n&&n!==document.body;)n instanceof HTMLElement&&n.matches?.(ho)&&t.push(n),n=n.parentElement;return t}(e);t&&e instanceof HTMLElement&&!n.includes(e)&&n.unshift(e),n.length?this.lockHoverUntilNextClick(n):this.unlockHover()}unlockHover(){null!==this.hoverLockInterval&&(window.clearInterval(this.hoverLockInterval),this.hoverLockInterval=null),this.hoverLockContainers.length&&vo(this.hoverLockContainers),this.hoverLockContainers=[]}startHoverPersistence(e){if(!e.length)return()=>{};So(e);const t=window.setInterval(()=>So(e),400);let n=!1;const i=()=>{if(n)return;n=!0,window.clearInterval(t),window.clearTimeout(s);const i=e.filter(e=>!this.hoverLockContainers.includes(e));i.length&&vo(i)},s=window.setTimeout(()=>{console.warn(\"[hover-persistence] max age reached; releasing hover after %dms\",1e4),i()},1e4);return i}refreshStyles(){this.styleElement&&(os(this.styleElement),this.styleElement=null),this.injectStyles()}injectStyles(){const e=document.getElementById(\"agent-confirmation-styles\");e&&os(e),this.styleElement=document.createElement(\"style\"),this.styleElement.id=\"agent-confirmation-styles\",this.styleElement.textContent=function(){const e=bs.getPrimaryColor(),t=bs.getSecondaryColor(),n=C(e),i=E(e),s=S(e);return`\\n  .agent-confirmation-overlay {\\n    position: fixed;\\n    top: 0;\\n    left: 0;\\n    width: 100%;\\n    height: 100%;\\n    z-index: 999998;\\n    pointer-events: auto;\\n  }\\n\\n  @keyframes agentDimIn {\\n    from { opacity: 0; }\\n    to { opacity: 1; }\\n  }\\n\\n  /* The touch panel's dim fades with it (agent-panel.ts). */\\n  .agent-confirmation-overlay--fade-in {\\n    animation: agentDimIn 200ms ease-out both;\\n  }\\n\\n  .agent-confirmation-overlay--fade-out {\\n    animation: agentDimIn 200ms ease-out reverse both;\\n    pointer-events: none;\\n  }\\n\\n  @media (prefers-reduced-motion: reduce) {\\n    .agent-confirmation-overlay--fade-in,\\n    .agent-confirmation-overlay--fade-out {\\n      animation-duration: 150ms;\\n    }\\n\\n    [data-blar-highlight] {\\n      animation: none !important;\\n      box-shadow: 0 0 0 6px rgba(${s}, 0.35), 0 0 25px rgba(${s}, 0.35) !important;\\n    }\\n  }\\n\\n  .agent-confirmation-card {\\n    position: fixed;\\n    box-sizing: border-box;\\n    display: flex;\\n    flex-direction: column;\\n    background: white;\\n    border-radius: 12px;\\n    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);\\n    padding: 20px;\\n    z-index: 1000002;\\n    animation: agentCardFadeIn 0.3s ease;\\n    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n    pointer-events: auto;\\n  }\\n\\n  @keyframes agentCardFadeIn {\\n    from {\\n      opacity: 0;\\n      transform: translateY(-10px);\\n    }\\n    to {\\n      opacity: 1;\\n      transform: translateY(0);\\n    }\\n  }\\n\\n  @keyframes agentPulse {\\n    0%, 100% {\\n      box-shadow: 0 0 0 4px rgba(${s}, 0.4), 0 0 20px rgba(${s}, 0.3);\\n    }\\n    50% {\\n      box-shadow: 0 0 0 8px rgba(${s}, 0.3), 0 0 30px rgba(${s}, 0.4);\\n    }\\n  }\\n\\n  .agent-confirmation-message {\\n    font-size: 15px;\\n    color: #1f2937;\\n    line-height: 1.5;\\n    margin-bottom: 14px;\\n    min-height: 0;\\n    overflow-y: auto;\\n    overscroll-behavior: contain;\\n  }\\n\\n  .agent-warning,\\n  .agent-confirmation-hint,\\n  .agent-confirmation-buttons {\\n    flex-shrink: 0;\\n  }\\n\\n  .agent-confirmation-message p {\\n    margin: 0 0 6px 0;\\n  }\\n\\n  .agent-confirmation-message p:last-child {\\n    margin-bottom: 0;\\n  }\\n\\n  .agent-confirmation-message code {\\n    padding: 1px 4px;\\n    border-radius: 3px;\\n    background: #f3f4f6;\\n    font-size: 13px;\\n    font-family: 'SF Mono', Monaco, Consolas, monospace;\\n  }\\n\\n  .agent-confirmation-message strong {\\n    font-weight: 600;\\n  }\\n\\n  .agent-warning {\\n    display: flex;\\n    align-items: center;\\n    gap: 8px;\\n    background: #fef3c7;\\n    border: 1px solid #f59e0b;\\n    color: #92400e;\\n    padding: 10px 12px;\\n    border-radius: 6px;\\n    font-size: 13px;\\n    margin-bottom: 14px;\\n  }\\n\\n  .agent-warning svg {\\n    width: 18px;\\n    height: 18px;\\n    fill: currentColor;\\n    flex-shrink: 0;\\n  }\\n\\n  .agent-confirmation-hint {\\n    background: #f3f4f6;\\n    color: #374151;\\n    padding: 8px 10px;\\n    border-radius: 6px;\\n    font-size: 13px;\\n    line-height: 1.45;\\n    margin-bottom: 14px;\\n  }\\n\\n  .agent-confirmation-hint[hidden] {\\n    display: none !important;\\n  }\\n\\n  .agent-confirmation-buttons {\\n    display: flex;\\n    gap: 12px;\\n    justify-content: flex-end;\\n  }\\n\\n  .agent-btn {\\n    padding: 8px 16px;\\n    border-radius: 6px;\\n    border: none;\\n    font-size: 14px;\\n    font-weight: 500;\\n    cursor: pointer;\\n    transition: all 0.2s ease;\\n    pointer-events: auto;\\n  }\\n\\n  .agent-btn-cancel {\\n    background: #e5e7eb;\\n    color: #374151;\\n  }\\n\\n  .agent-btn-cancel:hover {\\n    background: #d1d5db;\\n  }\\n\\n  .agent-btn-confirm {\\n    background: ${e};\\n    color: ${t};\\n    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);\\n  }\\n\\n  .agent-btn-confirm:hover {\\n    background: ${n};\\n  }\\n\\n  .agent-btn-confirm.destructive {\\n    background: #dc2626;\\n    color: #ffffff;\\n    box-shadow: none;\\n  }\\n\\n  .agent-btn-confirm.destructive:hover {\\n    background: #b91c1c;\\n  }\\n\\n  .agent-auto-card {\\n    position: fixed;\\n    background: white;\\n    border-radius: 10px;\\n    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);\\n    padding: 12px 16px;\\n    z-index: 1000002;\\n    animation: agentCardFadeIn 0.3s ease;\\n    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n    display: flex;\\n    flex-direction: column;\\n    align-items: stretch;\\n    gap: 8px;\\n    pointer-events: auto;\\n    max-width: 420px;\\n  }\\n\\n  .agent-auto-text {\\n    font-size: 14px;\\n    color: #374151;\\n    max-width: 350px;\\n    line-height: 1.4;\\n  }\\n\\n  .agent-auto-text p {\\n    margin: 0 0 6px 0;\\n  }\\n\\n  .agent-auto-text p:last-child {\\n    margin-bottom: 0;\\n  }\\n\\n  .agent-auto-text code {\\n    padding: 1px 4px;\\n    border-radius: 3px;\\n    background: #f3f4f6;\\n    font-size: 12px;\\n    font-family: 'SF Mono', Monaco, Consolas, monospace;\\n  }\\n\\n  .agent-auto-text strong {\\n    font-weight: 600;\\n  }\\n\\n  .agent-auto-text ul,\\n  .agent-auto-text ol {\\n    margin: 4px 0;\\n    padding-left: 18px;\\n  }\\n\\n  .agent-auto-text li {\\n    margin-bottom: 2px;\\n  }\\n\\n  .agent-highlight-progress-bar {\\n    width: 100%;\\n    height: 4px;\\n    background: rgba(0, 0, 0, 0.08);\\n    border-radius: 0 0 10px 10px;\\n    margin-top: 8px;\\n    overflow: hidden;\\n  }\\n\\n  .agent-highlight-progress-fill {\\n    height: 100%;\\n    width: 0%;\\n    background: linear-gradient(90deg, ${e}, ${i});\\n    box-shadow: 0 0 10px rgba(${s}, 0.4);\\n    transition: width linear;\\n  }\\n\\n  .agent-highlight-skip-btn {\\n    display: flex;\\n    align-items: center;\\n    gap: 4px;\\n    align-self: flex-end;\\n    margin-top: 6px;\\n    padding: 2px 8px;\\n    border: none;\\n    border-radius: 4px;\\n    background: transparent;\\n    color: #9ca3af;\\n    font-size: 11px;\\n    cursor: pointer;\\n    transition: all 0.15s ease;\\n    pointer-events: auto;\\n  }\\n\\n  .agent-highlight-skip-btn:hover {\\n    background: #f3f4f6;\\n    color: #6b7280;\\n  }\\n\\n  .agent-highlight-skip-btn kbd {\\n    display: inline-flex;\\n    align-items: center;\\n    justify-content: center;\\n    padding: 0 4px;\\n    min-width: 18px;\\n    height: 16px;\\n    border-radius: 3px;\\n    background: #f3f4f6;\\n    border: 1px solid #e5e7eb;\\n    font-size: 10px;\\n    font-family: inherit;\\n    line-height: 1;\\n    color: #9ca3af;\\n  }\\n\\n  .agent-highlight-skip-btn:hover kbd {\\n    background: #e5e7eb;\\n    border-color: #d1d5db;\\n    color: #6b7280;\\n  }\\n`}(),document.head.appendChild(this.styleElement)}addEscapeHandler(e){this.removeEscapeHandler(),this.escapeHandler=t=>{\"Escape\"===t.key&&t.isTrusted&&e()},document.addEventListener(\"keydown\",this.escapeHandler)}removeEscapeHandler(){this.escapeHandler&&(document.removeEventListener(\"keydown\",this.escapeHandler),this.escapeHandler=null)}startTracking(e,t){this.stopTracking();let n=e.getBoundingClientRect();const i=()=>{const s=e.getBoundingClientRect();s.top===n.top&&s.left===n.left&&s.width===n.width&&s.height===n.height||(n=s,t()),this.trackingFrame=requestAnimationFrame(i)};this.trackingFrame=requestAnimationFrame(i)}stopTracking(){null!==this.trackingFrame&&(cancelAnimationFrame(this.trackingFrame),this.trackingFrame=null)}revealHoverGatedTarget(e){this.restoreHoverReveal();const t=[];let n=e instanceof HTMLElement?e:e.parentElement;for(let e=0;n&&e<6&&n!==document.body;e++){const e=window.getComputedStyle(n),i=n;if(\"0\"===e.opacity){const e=i.style.getPropertyValue(\"opacity\"),n=i.style.getPropertyPriority(\"opacity\");i.style.setProperty(\"opacity\",\"1\",\"important\"),t.push(()=>this.restoreInline(i,\"opacity\",e,n))}if(\"hidden\"===e.visibility){const e=i.style.getPropertyValue(\"visibility\"),n=i.style.getPropertyPriority(\"visibility\");i.style.setProperty(\"visibility\",\"visible\",\"important\"),t.push(()=>this.restoreInline(i,\"visibility\",e,n))}n=n.parentElement}this.hoverRevealRestore=t.length?()=>t.forEach(e=>e()):null}restoreInline(e,t,n,i){e.isConnected&&(n?e.style.setProperty(t,n,i):e.style.removeProperty(t))}restoreHoverReveal(){this.hoverRevealRestore&&(this.hoverRevealRestore(),this.hoverRevealRestore=null)}requestConfirmation(e){return this.currentResolve&&this.currentResolve(\"declined\"),this.cleanup(),new Promise(t=>{this.currentResolve=t,this.confirmationTimer=setTimeout(()=>{this.confirmationTimer=null;const e=this.currentResolve;this.cleanup(),e?.(\"timed_out\")},6e4),this.titleAttention.start(Na().agent.confirmationTitle),this.onAttention?.();const n=Su(e.element);this.revealHoverGatedTarget(n),this.cursor.usesTouch()?this.showConfirmationPanel({...e,element:n}):(n.scrollIntoView({behavior:\"smooth\",block:\"center\"}),this.createOverlay(n),this.highlightElement(n),this.showConfirmationCard({...e,element:n}),this.releaseClearance=this.clearance.follow(n),this.startTracking(n,()=>{this.updateOverlayMask(n),this.positionCard(n)}))})}highlightDuringAction(e,n,i=!0){if(e=Su(e),n){if(t())return Promise.resolve({completed:!0});if(this.revealHoverGatedTarget(e),this.cursor.usesTouch())return this.readOnPanel(e,n);this.createOverlay(e,!0),this.highlightedElement=e,e.scrollIntoView({behavior:\"smooth\",block:\"center\"}),this.showAutoCardWithProgress(e,n);const i=Cp(n);return new Promise(n=>{let s=null;const r=()=>{this.highlightTimer&&(clearTimeout(this.highlightTimer),this.highlightTimer=null),this.highlightEnterHandler&&(document.removeEventListener(\"keydown\",this.highlightEnterHandler),this.highlightEnterHandler=null),s&&(document.removeEventListener(\"visibilitychange\",s),s=null),this.stopTracking(),this.removeEscapeHandler(),this.removeAutoCard(),this.removeOverlay(),this.releaseStatusCard(),this.restoreHoverReveal(),this.highlightedElement=null};this.releaseClearance=this.clearance.follow(e),this.startTracking(e,()=>{this.updateOverlayMask(e),this.positionAutoCard(e)}),requestAnimationFrame(()=>{const e=this.autoCard?.querySelector(\".agent-highlight-progress-fill\");e&&(e.style.transitionDuration=`${i}ms`,e.style.width=\"100%\")}),this.highlightTimer=setTimeout(()=>{this.highlightTimer=null,r(),n({completed:!0})},i);const o=this.autoCard?.querySelector(\".agent-highlight-skip-btn\");o?.addEventListener(\"click\",()=>{r(),n({completed:!0})}),this.highlightEnterHandler=e=>{\"Enter\"===e.key&&(r(),n({completed:!0}))},document.addEventListener(\"keydown\",this.highlightEnterHandler),s=()=>{t()&&(r(),n({completed:!0}))},document.addEventListener(\"visibilitychange\",s),this.addEscapeHandler(()=>{r(),this.onCancelAgent&&this.onCancelAgent(),n({completed:!1})})})}return this.cursor.moveTo(e,i),this.cursor.usesTouch()?()=>{}:this.clearance.follow(e)}revealHighlight(){const e=this.readingReveal;return e?()=>e.then(()=>{}):void 0}whenCursorLanded(){return this.cursor.whenLanded()}beginAgentSession(){this.cursor.beginSession()}endAgentSession(){this.cursor.endSession(),this.clearance.stop()}readOnPanel(e,n){const i=Cp(n),s=document.createElement(\"div\");return s.setAttribute(\"role\",\"status\"),s.innerHTML=`\\n      <div class=\"agent-panel-message\">${rc.parse(n,{async:!1})}</div>\\n      <div class=\"agent-panel-progress\">\\n        <div class=\"agent-panel-track\"><div class=\"agent-panel-bar\"></div></div>\\n        <button type=\"button\" class=\"agent-panel-skip\">${Na().agent.readingSkip}</button>\\n      </div>\\n    `,new Promise(n=>{let r=!1;const o=()=>{t()&&l(!0)},a=e=>{\"Enter\"===e.key&&l(!0)},l=e=>{r||(r=!0,this.highlightTimer&&(clearTimeout(this.highlightTimer),this.highlightTimer=null),document.removeEventListener(\"keydown\",a),document.removeEventListener(\"visibilitychange\",o),this.stopTracking(),this.removeEscapeHandler(),this.removeOverlay(),this.releaseStatusCard(),this.panel.element===s&&this.panel.close(),this.restoreHoverReveal(),this.highlightedElement=null,this.readingReveal=null,n({completed:e}))};s.querySelector(\".agent-panel-skip\")?.addEventListener(\"click\",()=>l(!0)),document.addEventListener(\"keydown\",a),document.addEventListener(\"visibilitychange\",o),this.addEscapeHandler(()=>{this.onCancelAgent?.(),l(!1)}),this.readingReveal=this.panel.present(s,e,\"read\").then(t=>{r||(t?(this.createOverlay(e,!0),this.highlightedElement=e,this.releaseClearance=this.clearance.follow(e),this.panel.show(),requestAnimationFrame(()=>{const e=s.querySelector(\".agent-panel-bar\");e&&(e.style.transitionDuration=`${i}ms`,e.style.transform=\"scaleX(1)\")}),this.highlightTimer=setTimeout(()=>l(!0),i),this.startTracking(e,()=>this.updateOverlayMask(e))):l(!1))})})}showConfirmationPanel(e){const{element:t,action:n,risk_level:i,teaching_explanation:s}=e,r=Na(),o=\"destructive\"===i,a=s?.trim()||_u(n),l=o?r.agent.confirmDestructive:r.agent.confirmProceed,c=document.createElement(\"div\");o&&c.classList.add(\"agent-panel--destructive\"),c.setAttribute(\"role\",\"alertdialog\"),c.setAttribute(\"aria-modal\",\"true\"),c.setAttribute(\"aria-labelledby\",\"agent-panel-message\"),c.innerHTML=`\\n      <div class=\"agent-panel-message\" id=\"agent-panel-message\" tabindex=\"-1\">${rc.parse(a,{async:!1})}</div>\\n      ${o?`<div class=\"agent-panel-warning\">${Sp}<span>${r.agent.cannotBeUndone}</span></div>`:\"\"}\\n      <div class=\"agent-panel-hint\" role=\"status\" hidden>${r.agent.confirmationHintTouch(l,r.agent.confirmStop)}</div>\\n      <div class=\"agent-panel-buttons\">\\n        <button type=\"button\" class=\"agent-panel-button agent-panel-stop\">${r.agent.confirmStop}</button>\\n        <button type=\"button\" class=\"agent-panel-button agent-panel-confirm${o?\" destructive\":\"\"}\">${l}</button>\\n      </div>\\n    `,c.addEventListener(\"click\",e=>{e.target instanceof Element&&this.handleCardClick(e.target)}),this.addEscapeHandler(()=>this.cancel());const d=this.currentResolve;this.panel.present(c,t,\"confirm\").then(e=>{e&&this.currentResolve===d&&(this.createOverlay(t),this.highlightElement(t,!1),this.releaseClearance=this.clearance.follow(t),this.panel.show(),this.startTracking(t,()=>this.updateOverlayMask(t)))})}showAutoCardWithProgress(e,t){this.autoCard=document.createElement(\"div\"),this.autoCard.className=\"agent-auto-card\",this.autoCard.style.zIndex=\"2147483647\",this.autoCard.style.pointerEvents=\"none\",this.autoCard.innerHTML=`\\n      <div class=\"agent-auto-text\">${rc.parse(t,{async:!1})}</div>\\n      <div class=\"agent-highlight-progress-bar\">\\n        <div class=\"agent-highlight-progress-fill\"></div>\\n      </div>\\n      <button class=\"agent-highlight-skip-btn\">${Na().agent.readingSkip} <kbd>↵</kbd></button>\\n    `,this.positionAutoCard(e),document.body.appendChild(this.autoCard)}removeAutoCard(){this.highlightTimer&&(clearTimeout(this.highlightTimer),this.highlightTimer=null),this.highlightEnterHandler&&(document.removeEventListener(\"keydown\",this.highlightEnterHandler),this.highlightEnterHandler=null),this.autoCard&&(os(this.autoCard),this.autoCard=null)}removeOverlay(){this.removePressShield(),this.overlay&&(this.dismissOverlay(this.overlay),this.overlay=null,document.body.classList.remove(\"blar-confirmation-active\"))}dismissOverlay(e){e.classList.contains(\"agent-confirmation-overlay--fade-in\")?(e.classList.replace(\"agent-confirmation-overlay--fade-in\",\"agent-confirmation-overlay--fade-out\"),setTimeout(()=>os(e),200)):os(e)}positionAutoCard(e){if(!this.autoCard)return;const t=e.getBoundingClientRect(),n=this.autoCard.getBoundingClientRect(),i=n.width||280,s=n.height||120,r=16,o=window.innerWidth,a=window.innerHeight,l=t.top-12,c=t.left-12,d=t.right+12,u=t.bottom+12;let p,h;d+r+i<o-r?(p=d+r,h=t.top+t.height/2-s/2):c-r-i>r?(p=c-r-i,h=t.top+t.height/2-s/2):u+r+s<a-r?(p=t.left,h=u+r):(p=t.left,h=l-r-s),p=Math.max(r,Math.min(p,o-i-r)),h=Math.max(r,Math.min(h,a-s-r)),this.autoCard.style.top=`${h}px`,this.autoCard.style.left=`${p}px`}createOverlay(e,t=!1){this.overlay=document.createElement(\"div\"),this.overlay.className=\"agent-confirmation-overlay\",this.overlay.style.zIndex=t?\"2147483645\":\"2147483647\",this.overlayOutlinesTarget=!t,this.cursor.usesTouch()&&this.overlay.classList.add(\"agent-confirmation-overlay--fade-in\"),t&&(this.overlay.style.pointerEvents=\"none\"),document.body.classList.add(\"blar-confirmation-active\"),this.updateOverlayMask(e),document.body.appendChild(this.overlay),t||this.installPressShield()}installPressShield(){this.removePressShield();const e=e=>{if(!e.isTrusted)return;if(e.stopImmediatePropagation(),\"mousedown\"===e.type&&e.preventDefault(),\"click\"!==e.type)return;const t=e.target instanceof Element?e.target:null;t?.closest(\".agent-confirmation-card, .agent-panel\")?this.handleCardClick(t):this.pressesSpotlight(e)?this.confirm():this.repeatOptions()};this.pressShield=e;for(const t of kp)window.addEventListener(t,e,!0)}removePressShield(){if(this.pressShield){for(const e of kp)window.removeEventListener(e,this.pressShield,!0);this.pressShield=null}}cancel(){if(this.onCancelAgent)this.onCancelAgent();else{const e=this.currentResolve;this.cleanup(),e?.(\"declined\")}}confirm(){const e=this.currentResolve;this.cleanup(),e?.(\"confirmed\")}repeatOptions(){const e=this.panel.element??this.confirmationCard,t=e?.querySelector(\".agent-confirmation-hint, .agent-panel-hint\");t&&(t.hidden=!1),this.panel.element?this.panel.nudge():(this.highlightedElement&&this.positionCard(this.highlightedElement),fp(this.confirmationCard))}handleCardClick(e){e.closest(\".agent-btn-cancel, .agent-panel-stop\")?this.cancel():e.closest(\".agent-btn-confirm, .agent-panel-confirm\")&&this.confirm()}pressesSpotlight(e){if(!(this.currentResolve&&this.highlightedElement&&e instanceof MouseEvent))return!1;const t=this.highlightedElement.getBoundingClientRect();return e.clientX>=t.left-8&&e.clientX<=t.right+8&&e.clientY>=t.top-8&&e.clientY<=t.bottom+8}releaseStatusCard(){this.releaseClearance?.(),this.releaseClearance=null}updateOverlayMask(e){if(!this.overlay)return;const t=vp({target:e.getBoundingClientRect(),borderRadius:parseFloat(window.getComputedStyle(e).borderRadius)||0,viewport:{width:window.innerWidth,height:window.innerHeight},outlineEdge:this.overlayOutlinesTarget,sidePanel:this.sidePanelExclude});this.overlay.style.background=`url(\"data:image/svg+xml,${encodeURIComponent(t)}\")`}highlightElement(e,t=!0){this.highlightedElement=e;const n=e.style;this.originalStyles={outline:n.outline,outlineOffset:n.outlineOffset,boxShadow:n.boxShadow,animation:n.animation,position:n.position,zIndex:n.zIndex};const i=bs.getPrimaryColor();n.outline=`3px solid ${i}`,n.outlineOffset=\"4px\",n.animation=\"agentPulse 2s ease-in-out infinite\",\"static\"===window.getComputedStyle(e).position&&(n.position=\"relative\"),n.zIndex=\"2147483644\",e.setAttribute(\"data-blar-highlight\",\"\"),t&&e.scrollIntoView({behavior:\"smooth\",block:\"center\"})}removeHighlight(){if(!this.highlightedElement||!this.originalStyles)return;const e=this.highlightedElement.style;e.outline=this.originalStyles.outline,e.outlineOffset=this.originalStyles.outlineOffset,e.boxShadow=this.originalStyles.boxShadow,e.animation=this.originalStyles.animation,e.position=this.originalStyles.position,e.zIndex=this.originalStyles.zIndex,this.highlightedElement.removeAttribute(\"data-blar-highlight\"),this.highlightedElement=null,this.originalStyles=null}showConfirmationCard(e){const{element:t,action:n,risk_level:i,teaching_explanation:s}=e,r=Na(),o=\"destructive\"===i;this.confirmationCard=document.createElement(\"div\"),this.confirmationCard.className=\"agent-confirmation-card\",this.confirmationCard.style.zIndex=\"2147483647\",this.confirmationCard.style.pointerEvents=\"auto\";const a=s?.trim()||_u(n),l=rc.parse(a,{async:!1}),c=o?`\\n      <div class=\"agent-warning\">\\n        ${Sp}\\n        <span>${r.agent.cannotBeUndone}</span>\\n      </div>\\n    `:\"\",d=o?r.agent.confirmDestructive:r.agent.confirmProceed;this.confirmationCard.innerHTML=`\\n      <div class=\"agent-confirmation-message\">${l}</div>\\n      ${c}\\n      <div class=\"agent-confirmation-hint\" role=\"status\" hidden>${r.agent.confirmationHint(d,r.agent.confirmCancel)}</div>\\n      <div class=\"agent-confirmation-buttons\">\\n        <button class=\"agent-btn agent-btn-cancel\" style=\"pointer-events: auto;\">${r.agent.confirmCancel}</button>\\n        <button class=\"agent-btn agent-btn-confirm ${o?\"destructive\":\"\"}\" style=\"pointer-events: auto;\">\\n          ${d}\\n        </button>\\n      </div>\\n    `,document.body.appendChild(this.confirmationCard),this.positionCard(t),this.confirmationCard.addEventListener(\"click\",e=>{e.target instanceof Element&&this.handleCardClick(e.target)}),this.addEscapeHandler(()=>this.cancel())}positionCard(e){if(!this.confirmationCard)return;const t=this.confirmationCard,n=e.getBoundingClientRect(),i=20,s=window.innerWidth,r=window.innerHeight,o=Math.min(360,s-40);t.style.width=`${o}px`;const a=t.querySelector(\".agent-confirmation-message\"),l=a?a.scrollHeight-a.clientHeight:0,c=t.offsetHeight+l,d=t.offsetHeight-(a?.clientHeight??0);let u,p,h=r-40;if(n.right+i+o<s-i)u=n.right+i,p=n.top;else if(n.left-i-o>i)u=n.left-i-o,p=n.top;else{u=(s-o)/2;const e=r-n.bottom-40,t=n.top-40,a=c<=e||c>t&&e>=t;h=a?e:t,p=a?n.bottom+i:n.top-i-Math.min(c,h)}const g=Math.max(h,d);t.style.maxHeight=`${g}px`,p=Math.max(i,Math.min(p,r-Math.min(c,g)-i)),u=Math.max(i,Math.min(u,s-o-i)),t.style.top=`${p}px`,t.style.left=`${u}px`}forceCancel(){this.currentResolve&&(this.currentResolve(\"declined\"),this.currentResolve=null),this.cleanup()}cleanup(){this.confirmationTimer&&(clearTimeout(this.confirmationTimer),this.confirmationTimer=null),this.titleAttention.stop(),this.removeEscapeHandler(),this.removeAutoCard(),this.removeHighlight(),this.stopTracking(),this.releaseStatusCard(),this.restoreHoverReveal(),this.removePressShield(),this.overlay&&(this.dismissOverlay(this.overlay),this.overlay=null),this.panel.element&&this.panel.close(),document.body.classList.remove(\"blar-confirmation-active\"),this.confirmationCard&&(os(this.confirmationCard),this.confirmationCard=null),this.currentResolve=null}destroy(){this.unlockHover(),this.cleanup(),this.clearance.stop(),this.cursor.destroy(),this.panel.destroy(),this.styleElement&&(os(this.styleElement),this.styleElement=null),this.colorUnsubscribe&&(this.colorUnsubscribe(),this.colorUnsubscribe=null)}}const Mp=new Set([\"click\",\"type\",\"select\",\"check\",\"press_key\"]),Ap=Ho.join(\",\"),_p=['[role=\"alert\"]',\".error-message\",\".field-error\",\".invalid-feedback\",'[class*=\"error\"]:not(input):not(button):not(select):not(textarea)'].join(\", \");class Tp{constructor(e){this.networkTracker=e}static shouldValidate(e){return Mp.has(e.type)}beginObservation(e,t,n=1e3){if(!Tp.shouldValidate(e))return null;const i=this.findScope(t),s=new Set,r=new Set,o=new MutationObserver(e=>{for(const t of e)\"attributes\"!==t.type?t.addedNodes.forEach(e=>{e instanceof Element&&s.add(e)}):t.target!==document.body&&r.add(t.target)});return o.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\"style\",\"class\",\"hidden\",\"open\"]}),{startedAt:performance.now(),beforeInvalidFields:this.collectInvalidFields(i),scope:i,baselinePendingCount:this.networkTracker.getPendingRequests().length,maxWindowMs:n,textBefore:Ip(document.body.innerText),inserted:s,flipped:r,observer:o}}async finishObservation(e){if(!e)return null;const t=await this.waitForWindow(e);e.observer?.disconnect();const n=this.diffInvalidFields(e),i=this.collectFailedResponses(e),s=this.collectAppeared(e);return n&&n.length>0||i&&i.length>0||s.length>0?{...n&&n.length>0&&{invalid_fields:n},...i&&i.length>0&&{failed_responses:i},...s.length>0&&{appeared:s},window_ms:Math.round(t)}:null}async waitForWindow(t){const n=200-(performance.now()-t.startedAt);n>0&&await e(n);let i=!1;for(;performance.now()-t.startedAt<t.maxWindowMs;){if(this.networkTracker.getPendingRequests().length<=t.baselinePendingCount)break;i=!0,await e(80)}return i&&performance.now()-t.startedAt<t.maxWindowMs&&await e(80),performance.now()-t.startedAt}findScope(e){return e.closest(\"form\")||e.closest('[role=\"dialog\"], [aria-modal=\"true\"]')||e.closest(\"section, article, main\")||document.body}collectInvalidFields(e){const t=new Set,n=e.querySelectorAll('input, select, textarea, [contenteditable=\"true\"], [contenteditable=\"\"]');let i=0;return n.forEach(e=>{e instanceof HTMLElement&&(\"true\"!==e.getAttribute(\"aria-invalid\")?i>=60||(i++,_o(e,e=>window.getComputedStyle(e)).invalid&&t.add(e)):t.add(e))}),t}diffInvalidFields(e){const t=this.collectInvalidFields(e.scope),n=[];for(const i of t){if(e.beforeInvalidFields.has(i))continue;const t=Cu(i);if(!t)continue;const s=this.findInlineErrorText(i);n.push({selector:t,...s&&{message:s}})}return n}findInlineErrorText(e){let t=e;for(let n=0;n<2&&t;n++){const n=t.parentElement;if(!n)break;const i=n.querySelector(_p);if(i&&i!==e){const e=(i.textContent||\"\").trim().replace(/\\s+/g,\" \");if(e)return e}t=n}const n=e.getAttribute(\"aria-errormessage\")||e.getAttribute(\"aria-describedby\");if(n){const e=document.getElementById(n);if(e){const t=(e.textContent||\"\").trim().replace(/\\s+/g,\" \");if(t)return t}}return _o(e,e=>window.getComputedStyle(e)).message}collectAppeared(e){if(!e.inserted||!e.flipped||void 0===e.textBefore)return[];const t=new Set,n=[];for(const i of[...e.inserted,...e.flipped]){if(n.length>=5)break;if(!(i instanceof HTMLElement&&i.isConnected))continue;if(i.closest(Ap))continue;if(Lp(i,e.inserted))continue;if(!Ds(i))continue;const s=Ip(i.innerText||i.shadowRoot?.textContent);!s||t.has(s)||e.textBefore.includes(s)||(t.add(s),n.push(s.length>200?s.slice(0,199)+\"…\":s))}return n}collectFailedResponses(e){return this.networkTracker.getRecentFailures(e.startedAt).filter($p).map(e=>({url:e.url,method:e.method,status:e.status,...e.body&&{body:e.body},...e.request_id&&{request_id:e.request_id},...e.page_url&&{page_url:e.page_url},timestamp_iso:e.timestamp_iso,duration_ms:e.duration_ms,...e.count>1&&{count:e.count}}))}}function Ip(e){return(e||\"\").replace(/\\s+/g,\" \").trim()}function Lp(e,t){for(let n=e.parentElement;n&&n!==document.body;n=n.parentElement)if(t.has(n))return!0;return!1}const Rp=[\"JS_ERROR\",\"CONSOLE_ERROR\"];function $p(e){if(Rp.includes(e.method))return!0;if(0!==e.status)return!0;try{return Wo(new URL(e.url,window.location.href).hostname,window.location.hostname)}catch{return!0}}class Np{constructor(){this.container=null,this.blob=null,this.isAnimating=!1,this.stylesInjected=!1}play(e,t,n={}){const{duration:i=800,color:s=bs.getPrimaryColor(),onComplete:r}=n;return this.isAnimating?Promise.resolve():(this.isAnimating=!0,this.injectStyles(),this.createContainer(e,t,s,i),new Promise(e=>{setTimeout(()=>{this.fadeOut().then(()=>{this.cleanup(),this.isAnimating=!1,r?.(),e()})},i)}))}createContainer(e,t,n,i){const s=document.createElementNS(\"http://www.w3.org/2000/svg\",\"svg\");s.setAttribute(\"class\",\"blar-slime-filter\"),s.style.cssText=\"position: absolute; width: 0; height: 0;\",s.innerHTML='\\n      <defs>\\n        <filter id=\"blar-gooey\">\\n          <feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"10\" result=\"blur\" />\\n          <feColorMatrix in=\"blur\" mode=\"matrix\" values=\"\\n            1 0 0 0 0\\n            0 1 0 0 0\\n            0 0 1 0 0\\n            0 0 0 20 -10\\n          \" result=\"gooey\" />\\n        </filter>\\n      </defs>\\n    ',document.body.appendChild(s),this.container=document.createElement(\"div\"),this.container.className=\"blar-slime-container\",this.container.style.cssText=\"\\n      position: fixed;\\n      top: 0;\\n      left: 0;\\n      width: 100vw;\\n      height: 100vh;\\n      z-index: 2147483645;\\n      pointer-events: none;\\n      filter: url(#blar-gooey);\\n    \";const r=e.left+e.width/2,o=e.top+e.height/2,a=t.left+t.width/2,l=t.top+t.height/2,c=Math.max(e.width,e.height);this.blob=document.createElement(\"div\"),this.blob.className=\"blar-slime-blob\",this.blob.style.cssText=`\\n      position: absolute;\\n      left: ${r}px;\\n      top: ${o}px;\\n      width: ${c}px;\\n      height: ${c}px;\\n      background: ${n};\\n      border-radius: 50%;\\n      transform: translate(-50%, -50%);\\n      box-shadow: 0 4px 20px ${k(n,.4)};\\n    `;const d=document.createElement(\"div\");d.className=\"blar-slime-trail\",d.style.cssText=`\\n      position: absolute;\\n      left: ${r}px;\\n      top: ${o}px;\\n      width: ${.6*c}px;\\n      height: ${.6*c}px;\\n      background: ${n};\\n      border-radius: 50%;\\n      transform: translate(-50%, -50%);\\n      opacity: 0.8;\\n    `;const u=document.createElement(\"div\");u.className=\"blar-slime-trail2\",u.style.cssText=`\\n      position: absolute;\\n      left: ${r}px;\\n      top: ${o}px;\\n      width: ${.4*c}px;\\n      height: ${.4*c}px;\\n      background: ${n};\\n      border-radius: 50%;\\n      transform: translate(-50%, -50%);\\n      opacity: 0.6;\\n    `,this.container.appendChild(u),this.container.appendChild(d),this.container.appendChild(this.blob),document.body.appendChild(this.container);const p=[{left:`${r}px`,top:`${o}px`,width:`${c}px`,height:`${c}px`,borderRadius:\"50%\",offset:0},{left:`${r+.3*(a-r)}px`,top:`${o+.3*(l-o)}px`,width:1.4*c+\"px\",height:.7*c+\"px\",borderRadius:\"50%\",offset:.25},{left:`${r+.6*(a-r)}px`,top:`${o+.6*(l-o)}px`,width:1.2*c+\"px\",height:.9*c+\"px\",borderRadius:\"45%\",offset:.5},{left:`${a}px`,top:`${l}px`,width:`${t.width}px`,height:`${t.height}px`,borderRadius:\"16px\",offset:1}],h=[{left:`${r}px`,top:`${o}px`,width:.6*c+\"px\",height:.6*c+\"px\",offset:0},{left:`${r+.15*(a-r)}px`,top:`${o+.15*(l-o)}px`,width:.8*c+\"px\",height:.5*c+\"px\",offset:.3},{left:`${r+.5*(a-r)}px`,top:`${o+.5*(l-o)}px`,width:.5*c+\"px\",height:.5*c+\"px\",offset:.6},{left:`${a}px`,top:`${l}px`,width:\"0px\",height:\"0px\",opacity:0,offset:1}],g=[{left:`${r}px`,top:`${o}px`,width:.4*c+\"px\",height:.4*c+\"px\",offset:0},{left:`${r+.1*(a-r)}px`,top:`${o+.1*(l-o)}px`,width:.5*c+\"px\",height:.3*c+\"px\",offset:.35},{left:`${r+.4*(a-r)}px`,top:`${o+.4*(l-o)}px`,width:.3*c+\"px\",height:.3*c+\"px\",offset:.7},{left:`${a}px`,top:`${l}px`,width:\"0px\",height:\"0px\",opacity:0,offset:1}],m=\"cubic-bezier(0.34, 1.56, 0.64, 1)\";this.blob.animate(p,{duration:i,easing:m,fill:\"forwards\"}),d.animate(h,{duration:1.1*i,easing:m,fill:\"forwards\"}),u.animate(g,{duration:1.2*i,easing:m,fill:\"forwards\"})}fadeOut(){return new Promise(e=>{this.container?(this.container.style.transition=\"opacity 0.15s ease-out\",this.container.style.opacity=\"0\",setTimeout(e,150)):e()})}injectStyles(){if(this.stylesInjected)return;const e=\"blar-slime-animation-styles\";if(document.getElementById(e))return void(this.stylesInjected=!0);const t=document.createElement(\"style\");t.id=e,t.textContent=\"\\n      .blar-slime-container {\\n        will-change: opacity;\\n      }\\n\\n      .blar-slime-blob,\\n      .blar-slime-trail,\\n      .blar-slime-trail2 {\\n        will-change: left, top, width, height, border-radius, opacity;\\n      }\\n    \",document.head.appendChild(t),this.stylesInjected=!0}cleanup(){this.container&&(os(this.container),this.container=null,this.blob=null);const e=document.querySelector(\"svg defs #blar-gooey\")?.closest(\"svg\");os(e)}playReverse(e,t,n={}){const{duration:i=700,color:s=bs.getPrimaryColor(),onComplete:r}=n;return this.isAnimating?Promise.resolve():(this.isAnimating=!0,this.injectStyles(),this.createReverseContainer(e,t,s,i),new Promise(e=>{setTimeout(()=>{this.fadeOut().then(()=>{this.cleanup(),this.isAnimating=!1,r?.(),e()})},i)}))}createReverseContainer(e,t,n,i){const s=document.createElementNS(\"http://www.w3.org/2000/svg\",\"svg\");s.setAttribute(\"class\",\"blar-slime-filter\"),s.style.cssText=\"position: absolute; width: 0; height: 0;\",s.innerHTML='\\n      <defs>\\n        <filter id=\"blar-gooey-reverse\">\\n          <feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"12\" result=\"blur\" />\\n          <feColorMatrix in=\"blur\" mode=\"matrix\" values=\"\\n            1 0 0 0 0\\n            0 1 0 0 0\\n            0 0 1 0 0\\n            0 0 0 22 -11\\n          \" result=\"gooey\" />\\n        </filter>\\n      </defs>\\n    ',document.body.appendChild(s),this.container=document.createElement(\"div\"),this.container.className=\"blar-slime-container\",this.container.style.cssText=\"\\n      position: fixed;\\n      top: 0;\\n      left: 0;\\n      width: 100vw;\\n      height: 100vh;\\n      z-index: 2147483645;\\n      pointer-events: none;\\n      filter: url(#blar-gooey-reverse);\\n    \";const r=e.left+e.width/2,o=e.top+e.height/2,a=t.left+t.width/2,l=t.top+t.height/2;this.blob=document.createElement(\"div\"),this.blob.className=\"blar-slime-blob\",this.blob.style.cssText=`\\n      position: absolute;\\n      left: ${r}px;\\n      top: ${o}px;\\n      width: ${e.width}px;\\n      height: ${e.height}px;\\n      background: ${n};\\n      border-radius: 16px;\\n      transform: translate(-50%, -50%);\\n      box-shadow: 0 4px 20px ${k(n,.4)};\\n    `;const c=document.createElement(\"div\");c.className=\"blar-slime-trail\",c.style.cssText=`\\n      position: absolute;\\n      left: ${r}px;\\n      top: ${o}px;\\n      width: ${.6*e.width}px;\\n      height: ${.6*e.height}px;\\n      background: ${n};\\n      border-radius: 16px;\\n      transform: translate(-50%, -50%);\\n      opacity: 0;\\n    `;const d=document.createElement(\"div\");d.className=\"blar-slime-trail2\",d.style.cssText=`\\n      position: absolute;\\n      left: ${r}px;\\n      top: ${o}px;\\n      width: ${.4*e.width}px;\\n      height: ${.4*e.height}px;\\n      background: ${n};\\n      border-radius: 16px;\\n      transform: translate(-50%, -50%);\\n      opacity: 0;\\n    `,this.container.appendChild(d),this.container.appendChild(c),this.container.appendChild(this.blob),document.body.appendChild(this.container);const u=t.top+t.height-e.height/2,p=[{left:`${r}px`,top:`${o}px`,width:`${e.width}px`,height:`${e.height}px`,borderRadius:\"16px\",offset:0},{left:`${a}px`,top:`${u}px`,width:1.1*e.width+\"px\",height:1.1*e.height+\"px\",borderRadius:\"16px\",offset:.55},{left:`${a}px`,top:`${l+.4*(u-l)}px`,width:.85*t.width+\"px\",height:.6*t.height+\"px\",borderRadius:\"16px\",offset:.78},{left:`${a}px`,top:`${l}px`,width:`${t.width}px`,height:`${t.height}px`,borderRadius:\"16px\",offset:1}],h=[{left:`${r}px`,top:`${o}px`,width:.6*e.width+\"px\",height:.6*e.height+\"px\",opacity:.8,offset:0},{left:`${r+.5*(a-r)}px`,top:`${o+.5*(u-o)}px`,width:.7*e.width+\"px\",height:.7*e.height+\"px\",opacity:.7,offset:.4},{left:`${a}px`,top:`${u}px`,width:.5*e.width+\"px\",height:.5*e.height+\"px\",opacity:.4,offset:.6},{left:`${a}px`,top:`${l}px`,width:\"0px\",height:\"0px\",opacity:0,offset:1}],g=[{left:`${r}px`,top:`${o}px`,width:.4*e.width+\"px\",height:.4*e.height+\"px\",opacity:.6,offset:0},{left:`${r+.3*(a-r)}px`,top:`${o+.35*(u-o)}px`,width:.5*e.width+\"px\",height:.5*e.height+\"px\",opacity:.5,offset:.35},{left:`${a}px`,top:u-20+\"px\",width:.3*e.width+\"px\",height:.3*e.height+\"px\",opacity:.2,offset:.65},{left:`${a}px`,top:`${l}px`,width:\"0px\",height:\"0px\",opacity:0,offset:1}],m=\"cubic-bezier(0.4, 0, 0.2, 1)\";this.blob.animate(p,{duration:i,easing:m,fill:\"forwards\"}),c.animate(h,{duration:1.1*i,easing:m,fill:\"forwards\"}),d.animate(g,{duration:1.15*i,easing:m,fill:\"forwards\"})}isPlaying(){return this.isAnimating}stop(){this.cleanup(),this.isAnimating=!1}}function Pp(e,t){const n=parseInt(e.slice(1,3),16)/255,i=parseInt(e.slice(3,5),16)/255,s=parseInt(e.slice(5,7),16)/255,r=Math.max(n,i,s),o=Math.min(n,i,s),a=r-o,l=(r+o)/2;let c=0,d=0;0!==a&&(d=l>.5?a/(2-r-o):a/(r+o),c=r===n?((i-s)/a+(i<s?6:0))/6:r===i?((s-n)/a+2)/6:((n-i)/a+4)/6),c=((360*c+t)%360+360)%360;const u=(e,t,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e),p=l<.5?l*(1+d):l+d-l*d,h=2*l-p,g=Math.round(255*u(h,p,c/360+1/3)),m=Math.round(255*u(h,p,c/360)),f=Math.round(255*u(h,p,c/360-1/3));return`#${g.toString(16).padStart(2,\"0\")}${m.toString(16).padStart(2,\"0\")}${f.toString(16).padStart(2,\"0\")}`}class Fp{constructor(){this.container=null,this.styleEl=null,this.colorUnsubscribe=null,this.animFrame=0,this.startTime=0,this.topBloom=null,this.leftBloom=null,this.rightBloom=null,this.bottomBloom=null,this.tick=e=>{this.container&&(this.updateBlooms(e),this.animFrame=requestAnimationFrame(this.tick))},this.colorUnsubscribe=bs.subscribe(()=>this.rebuildStyles())}show(){this.container||(this.injectStyles(),this.createDOM(),this.startTime=performance.now(),this.animFrame=requestAnimationFrame(this.tick))}hide(){this.animFrame&&(cancelAnimationFrame(this.animFrame),this.animFrame=0),os(this.container),this.container=null,this.topBloom=null,this.leftBloom=null,this.rightBloom=null,this.bottomBloom=null,os(this.styleEl),this.styleEl=null}destroy(){this.hide(),this.colorUnsubscribe?.(),this.colorUnsubscribe=null}rebuildStyles(){this.container&&(os(this.styleEl),this.styleEl=null,this.injectStyles())}updateBlooms(e){const t=(e-this.startTime)/1e3,n=[0,5];let i=0,s=0,r=0;for(const e of n){const n=.4*(t+e)%4-1.5,o=Math.max(0,1-1.5*Math.abs(n)),a=Math.max(0,1-1.5*Math.abs(n-1)),l=Math.max(0,1-1.5*Math.abs(n-.5));i=Math.max(i,o),s=Math.max(s,a),r=Math.max(r,l)}const o=.08;this.leftBloom&&(this.leftBloom.style.opacity=`${o+.92*i}`),this.rightBloom&&(this.rightBloom.style.opacity=`${o+.92*s}`),this.topBloom&&(this.topBloom.style.opacity=`${o+.92*r}`),this.bottomBloom&&(this.bottomBloom.style.opacity=`${o+.92*r}`)}injectStyles(){if(this.styleEl)return;const e=function(e){const t=Pp(e,30),n=Pp(e,60);return{primary:e,primaryRgb:S(e),secondary:t,secondaryRgb:S(t),tertiary:n,tertiaryRgb:S(n)}}(bs.getPrimaryColor()),t=document.createElement(\"style\");t.id=\"blar-border-glow-styles\",t.textContent=`\\n      .blar-border-glow {\\n        position: fixed; inset: 0;\\n        pointer-events: none;\\n        z-index: 2147483636;\\n      }\\n\\n      .blar-border-glow-top-bloom {\\n        position: absolute; top: 0; left: 0; right: 0;\\n        height: 220px;\\n        background: linear-gradient(180deg,\\n          rgba(${e.primaryRgb},0.45) 0%,\\n          rgba(${e.primaryRgb},0.15) 40%,\\n          transparent 100%);\\n        transition: opacity 0.3s ease-out;\\n      }\\n\\n      .blar-border-glow-left-bloom {\\n        position: absolute; top: 0; left: 0; bottom: 0; width: 140px;\\n        background: linear-gradient(90deg,\\n          rgba(${e.primaryRgb},0.55) 0%, transparent 100%);\\n        transition: opacity 0.4s ease-out;\\n      }\\n\\n      .blar-border-glow-right-bloom {\\n        position: absolute; top: 0; right: 0; bottom: 0; width: 140px;\\n        background: linear-gradient(270deg,\\n          rgba(${e.primaryRgb},0.35) 0%, transparent 100%);\\n        transition: opacity 0.3s ease-out;\\n      }\\n\\n      .blar-border-glow-bottom-bloom {\\n        position: absolute; bottom: 0; left: 0; right: 0; height: 140px;\\n        background: linear-gradient(0deg,\\n          rgba(${e.primaryRgb},0.55) 0%, transparent 100%);\\n        transition: opacity 0.4s ease-out;\\n      }\\n\\n      .blar-border-glow-vignette {\\n        position: absolute; inset: 0;\\n        background:\\n          radial-gradient(ellipse at center, transparent 40%, rgba(${e.primaryRgb},0.06) 100%),\\n          linear-gradient(180deg, rgba(${e.primaryRgb},0.02) 0%, transparent 30%, transparent 70%, rgba(${e.primaryRgb},0.02) 100%);\\n        pointer-events: none;\\n      }\\n\\n      body.blar-confirmation-active .blar-border-glow {\\n        opacity: 0;\\n        transition: opacity 0.3s ease-out;\\n      }\\n    `,document.head.appendChild(t),this.styleEl=t}createDOM(){const e=document.createElement(\"div\");e.className=\"blar-border-glow\",e.innerHTML='\\n      <div class=\"blar-border-glow-top-bloom\"></div>\\n      <div class=\"blar-border-glow-left-bloom\"></div>\\n      <div class=\"blar-border-glow-right-bloom\"></div>\\n      <div class=\"blar-border-glow-bottom-bloom\"></div>\\n      <div class=\"blar-border-glow-vignette\"></div>\\n    ',document.body.appendChild(e),this.container=e,this.topBloom=e.querySelector(\".blar-border-glow-top-bloom\"),this.leftBloom=e.querySelector(\".blar-border-glow-left-bloom\"),this.rightBloom=e.querySelector(\".blar-border-glow-right-bloom\"),this.bottomBloom=e.querySelector(\".blar-border-glow-bottom-bloom\")}}const Op=10;class qp{constructor(){this.canvas=null,this.ctx=null,this.animFrame=0,this.startTime=0,this.resizeHandler=null,this.colorUnsubscribe=null,this.tick=e=>{this.ctx&&this.canvas&&(this.draw(e),this.animFrame=requestAnimationFrame(this.tick))},this.colorUnsubscribe=bs.subscribe(()=>{})}show(){this.canvas||(this.createCanvas(),this.startTime=performance.now(),this.animFrame=requestAnimationFrame(this.tick),this.resizeHandler=()=>this.resizeCanvas(),window.addEventListener(\"resize\",this.resizeHandler))}hide(){this.animFrame&&(cancelAnimationFrame(this.animFrame),this.animFrame=0),this.ctx&&this.canvas&&this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),os(this.canvas),this.canvas=null,this.ctx=null,this.resizeHandler&&(window.removeEventListener(\"resize\",this.resizeHandler),this.resizeHandler=null)}destroy(){this.hide(),this.colorUnsubscribe?.(),this.colorUnsubscribe=null}createCanvas(){if(!document.getElementById(\"blar-dot-grid-styles\")){const e=document.createElement(\"style\");e.id=\"blar-dot-grid-styles\",e.textContent=\"\\n        body.blar-confirmation-active .blar-dot-grid-canvas {\\n          opacity: 0;\\n          transition: opacity 0.3s ease-out;\\n        }\\n      \",document.head.appendChild(e)}const e=document.createElement(\"canvas\");e.className=\"blar-dot-grid-canvas\",e.style.cssText=\"position:fixed;inset:0;z-index:2147483635;pointer-events:none;transition:opacity 0.3s ease-out;\",e.width=window.innerWidth,e.height=window.innerHeight,document.body.appendChild(e),this.canvas=e,this.ctx=e.getContext(\"2d\")}resizeCanvas(){this.canvas&&(this.canvas.width=window.innerWidth,this.canvas.height=window.innerHeight)}draw(e){const t=this.ctx,n=this.canvas;if(!t||!n)return;const i=n.width,s=n.height;t.clearRect(0,0,i,s);const r=S(bs.getPrimaryColor()),o=(e-this.startTime)/1e3,a=Math.ceil(i/9)+1,l=Math.ceil(s/9)+1,c=2*Math.PI,d=new Array(Op);for(let e=0;e<Op;e++)d[e]=[];const u=[0,5];for(const e of u){const t=o+e,n=.4*t%4,s=(n-1.5)*i,r=(.4+1.1*(n/4))*i/2;for(let e=0;e<a;e++){const n=9*e+4.5;if(!(n<s-r-80||n>s+r+80))for(let e=0;e<l;e++){const i=9*e+4.5,o=s+(45*Math.sin(.008*i+1.2*t)+20*Math.sin(.02*i+.7*t)+10*Math.sin(.035*i+2*t)),a=Math.abs(n-o)/r;if(a>1)continue;const l=.4*Math.pow(1-a,1.5);d[Math.min(9,l/.4*Op|0)].push(n,i)}}}for(let e=0;e<Op;e++){const n=d[e];if(0===n.length)continue;const i=(e+.5)/Op*.4;t.fillStyle=`rgba(${r}, ${i.toFixed(3)})`,t.beginPath();for(let e=0;e<n.length;e+=2)t.moveTo(n[e]+2.5,n[e+1]),t.arc(n[e],n[e+1],2.5,0,c);t.fill()}}}class Hp{play(){const e=S(bs.getPrimaryColor()),t=document.createElement(\"div\");if(t.className=\"blar-activation-flash\",t.style.cssText=`\\n      position: fixed; inset: 0;\\n      z-index: 2147483643;\\n      pointer-events: none;\\n      background: radial-gradient(\\n        ellipse at center,\\n        rgba(${e}, 0.25) 0%,\\n        rgba(${e}, 0.08) 40%,\\n        transparent 70%\\n      );\\n      animation: blarFlashPop 0.7s ease-out forwards;\\n    `,!document.getElementById(\"blar-flash-styles\")){const e=document.createElement(\"style\");e.id=\"blar-flash-styles\",e.textContent=\"\\n        @keyframes blarFlashPop {\\n          0%   { opacity: 0; transform: scale(0.8); }\\n          30%  { opacity: 1; transform: scale(1.05); }\\n          100% { opacity: 0; transform: scale(1.2); }\\n        }\\n      \",document.head.appendChild(e)}document.body.appendChild(t),t.addEventListener(\"animationend\",()=>os(t))}}const Bp=[\"pointerdown\",\"pointerup\",\"mousedown\",\"mouseup\",\"touchstart\",\"touchend\",\"click\"],Dp=Ho.filter(e=>\".blar-agent-execution-overlay\"!==e).join(\", \");class zp{constructor(e,t){this.statusCard=null,this.minimizedButton=null,this.messageBubblesContainer=null,this.queuedIndicator=null,this.executionOverlay=null,this.clickToast=null,this.clickToastTimeout=null,this.isActive=!1,this.currentStatus=Na().agent.thinking,this.confirming=!1,this.onCancel=null,this.stylesInjected=!1,this.colorUnsubscribe=null,this.escHandler=null,this.statusCardCaptureCleanup=null,this.executionShieldCleanup=null,this.onCancel=e||null,this.slimeAnimation=new Np,this.borderGlow=new Fp,this.dotGridWave=new qp,this.activationFlash=new Hp,this.colorUnsubscribe=bs.subscribe(()=>this.refreshStyles())}refreshStyles(){this.stylesInjected=!1;const e=document.getElementById(\"blar-agent-mode-styles\");e&&os(e),this.isActive&&this.injectStyles()}show(e,t){this.isActive||(this.isActive=!0,this.injectStyles(),this.createStatusCard(),t&&this.playSlimeAnimation(t),this.createMessageBubblesContainer(),this.activationFlash.play(),this.borderGlow.show(),this.dotGridWave.show(),this.escHandler=e=>{\"Escape\"===e.key&&e.isTrusted&&this.onCancel?.()},document.addEventListener(\"keydown\",this.escHandler))}playSlimeAnimation(e){const t=this.statusCard;t&&(t.classList.add(\"blar-agent-status-card--arriving\"),this.slimeAnimation.play(e,t.getBoundingClientRect(),{duration:800,color:bs.getPrimaryColor()}).then(()=>{t.classList.replace(\"blar-agent-status-card--arriving\",\"blar-agent-card-fade-in\")}))}hide(e){if(!this.isActive)return Promise.resolve();if(this.isActive=!1,this.currentStatus=Na().agent.thinking,this.hideQueuedIndicator(),this.removeExecutionPressShield(),this.escHandler&&(document.removeEventListener(\"keydown\",this.escHandler),this.escHandler=null),this.borderGlow.hide(),this.dotGridWave.hide(),e&&this.statusCard){const t=this.statusCard.getBoundingClientRect();return this.removeStatusCard(),this.removeMinimizedButton(),this.removeMessageBubblesContainer(),this.slimeAnimation.playReverse(t,e,{duration:700,color:bs.getPrimaryColor()})}return this.removeStatusCard(),this.removeMinimizedButton(),this.removeMessageBubblesContainer(),Promise.resolve()}showMessageBubble(e){this.messageBubblesContainer||this.createMessageBubblesContainer();const t=Array.from(this.messageBubblesContainer?.children??[]).some(t=>t.dataset.text===e.text);if(t)return;const n=document.createElement(\"div\");n.className=\"blar-agent-message-bubble\",n.dataset.messageId=e.id,n.dataset.text=e.text,n.innerHTML=`\\n      <div class=\"blar-agent-bubble-content\">${this.parseMarkdown(e.text)}</div>\\n    `;const i=e.text.trim().split(/\\s+/).length/120*60*1e3,s=Math.max(6e3,Math.min(18e3,i));setTimeout(()=>this.dismissBubble(n),s),this.messageBubblesContainer?.appendChild(n)}dismissBubble(e){e.parentNode&&!e.classList.contains(\"blar-agent-bubble-fade-out\")&&(e.classList.add(\"blar-agent-bubble-fade-out\"),setTimeout(()=>os(e),300))}clearMessageBubbles(e){if(this.messageBubblesContainer)for(const t of Array.from(this.messageBubblesContainer.children))void 0!==e&&t.dataset.text===e||os(t)}setStatus(e){this.currentStatus=e,this.updateStatusText()}showQueuedIndicator(e){this.hideQueuedIndicator();const t=e||\"Message received, agent will respond shortly...\";if(this.queuedIndicator=document.createElement(\"div\"),this.queuedIndicator.className=\"blar-agent-queued-indicator\",this.queuedIndicator.innerHTML=`\\n      <span class=\"blar-agent-queued-icon\">✓</span>\\n      <span class=\"blar-agent-queued-text\">${this.escapeHtml(t)}</span>\\n    `,this.statusCard){const e=this.statusCard.querySelector(\".blar-agent-input-area\");e?e.insertAdjacentElement(\"beforebegin\",this.queuedIndicator):this.statusCard.appendChild(this.queuedIndicator)}else this.messageBubblesContainer&&this.messageBubblesContainer.appendChild(this.queuedIndicator);setTimeout(()=>{this.hideQueuedIndicator()},5e3)}hideQueuedIndicator(){this.queuedIndicator&&(os(this.queuedIndicator),this.queuedIndicator=null)}showExecutionOverlay(){this.executionOverlay||(this.executionOverlay=document.createElement(\"div\"),this.executionOverlay.className=\"blar-agent-execution-overlay\",document.body.appendChild(this.executionOverlay),this.installExecutionPressShield())}installExecutionPressShield(){this.removeExecutionPressShield();const e=e=>{if(!e.isTrusted)return;const t=e.target;t instanceof Element&&t.closest(Dp)||(e.stopImmediatePropagation(),e.preventDefault(),\"click\"===e.type&&this.showClickBlockedToast())};for(const t of Bp)window.addEventListener(t,e,{capture:!0,passive:!1});this.executionShieldCleanup=()=>{for(const t of Bp)window.removeEventListener(t,e,{capture:!0})}}removeExecutionPressShield(){this.executionShieldCleanup&&(this.executionShieldCleanup(),this.executionShieldCleanup=null)}hideExecutionOverlay(){this.removeExecutionPressShield(),os(this.executionOverlay),this.executionOverlay=null,this.hideClickBlockedToast()}showClickBlockedToast(){this.clickToastTimeout&&clearTimeout(this.clickToastTimeout);const e=Na();this.clickToast||(this.clickToast=document.createElement(\"div\"),this.clickToast.className=\"blar-agent-click-toast\",this.clickToast.textContent=e.agent.clickStopToControl,document.body.appendChild(this.clickToast)),this.clickToast.classList.add(\"visible\"),this.highlightStopButton(),this.clickToastTimeout=setTimeout(()=>{this.hideClickBlockedToast()},2e3)}highlightStopButton(){const e=this.statusCard?.querySelector(\".blar-agent-stop-btn\");e&&(e.classList.add(\"highlight-pulse\"),setTimeout(()=>{e.classList.remove(\"highlight-pulse\")},2500))}hideClickBlockedToast(){this.clickToastTimeout&&(clearTimeout(this.clickToastTimeout),this.clickToastTimeout=null),this.clickToast?.classList.remove(\"visible\")}getStatusCardRect(){return this.statusCard?.getBoundingClientRect()??null}covers(e){return this.cardCovers(e)||this.bubblesCover(e)}setClearance(e){this.statusCard?.classList.toggle(\"blar-agent-status-card--cleared\",!!e&&this.cardCovers(e)),this.messageBubblesContainer?.classList.toggle(\"blar-agent-bubbles-container--cleared\",!!e&&this.bubblesCover(e))}cardCovers(e){return!!this.statusCard&&pp(e,this.statusCard.getBoundingClientRect())}bubblesCover(e){return Array.from(this.messageBubblesContainer?.children??[]).some(t=>pp(e,t.getBoundingClientRect()))}dockPanel(e){const t=this.statusCard;t&&(t.classList.add(\"blar-agent-status-card--rest\"),t.classList.toggle(\"blar-agent-status-card--panel-above\",\"bottom\"===e),t.classList.toggle(\"blar-agent-status-card--top\",\"top\"===e),t.classList.remove(\"blar-agent-status-card--top-leaving\"),e&&document.body.appendChild(t))}leaveTop(){this.statusCard?.classList.add(\"blar-agent-status-card--top-leaving\")}setStackHidden(e){this.statusCard?.classList.toggle(\"blar-agent-status-card--stack-hidden\",e)}setConfirming(e){this.confirming=e,this.statusCard?.classList.toggle(\"blar-agent-status-card--confirming\",e),this.updateStatusText()}nudge(){fp(this.statusCard)}temporarilyHideStatusCard(){this.statusCard&&(this.statusCard.style.opacity=\"0\",this.statusCard.style.pointerEvents=\"none\")}restoreStatusCard(){this.statusCard&&(this.statusCard.style.opacity=\"1\",this.statusCard.style.pointerEvents=\"\")}destroy(){this.hide(),this.hideExecutionOverlay(),this.clickToast&&(os(this.clickToast),this.clickToast=null),this.colorUnsubscribe&&(this.colorUnsubscribe(),this.colorUnsubscribe=null),this.borderGlow.destroy(),this.dotGridWave.destroy()}injectStyles(){if(this.stylesInjected)return;const e=\"blar-agent-mode-styles\",t=document.getElementById(e);t&&os(t);const n=bs.getPrimaryColor(),i=bs.getSecondaryColor(),s=C(n),r=E(n),o=S(i),a=document.createElement(\"style\");a.id=e,a.textContent=`\\n      @keyframes blarAgentStatusPulse {\\n        0%, 100% {\\n          opacity: 1;\\n        }\\n        50% {\\n          opacity: 0.6;\\n        }\\n      }\\n\\n      @keyframes blarAgentCardSlideIn {\\n        0% {\\n          transform: translateX(-50%) translateY(100%);\\n          opacity: 0;\\n        }\\n        100% {\\n          transform: translateX(-50%) translateY(0);\\n          opacity: 1;\\n        }\\n      }\\n\\n      @keyframes blarAgentCardFadeIn {\\n        0% {\\n          opacity: 0;\\n          transform: translateX(-50%) scale(0.95);\\n        }\\n        100% {\\n          opacity: 1;\\n          transform: translateX(-50%) scale(1);\\n        }\\n      }\\n\\n      .blar-agent-card-fade-in {\\n        animation: blarAgentCardFadeIn 0.2s ease-out forwards !important;\\n      }\\n\\n      .blar-agent-status-header {\\n        display: flex;\\n        align-items: center;\\n        gap: 10px;\\n      }\\n\\n      .blar-agent-status-icon {\\n        font-size: 16px;\\n      }\\n\\n      .blar-agent-status-text {\\n        font-size: 13px;\\n        font-weight: 500;\\n        flex: 1;\\n        min-width: 0;\\n        line-height: 1.3;\\n        display: -webkit-box;\\n        -webkit-line-clamp: 2;\\n        -webkit-box-orient: vertical;\\n        overflow: hidden;\\n        font-style: italic;\\n        color: rgba(${o}, 0.55);\\n      }\\n\\n      @supports ((-webkit-background-clip: text) or (background-clip: text)) {\\n        .blar-agent-status-text {\\n          background: linear-gradient(\\n            90deg,\\n            rgba(${o}, 0.55) 0%,\\n            rgba(${o}, 0.55) 40%,\\n            rgba(${o}, 1) 50%,\\n            rgba(${o}, 0.55) 60%,\\n            rgba(${o}, 0.55) 100%\\n          );\\n          background-size: 200% 100%;\\n          -webkit-background-clip: text;\\n          background-clip: text;\\n          -webkit-text-fill-color: transparent;\\n          color: transparent;\\n          animation: blarAgentStatusGlow 2.5s linear infinite;\\n        }\\n      }\\n\\n      @keyframes blarAgentStatusGlow {\\n        from { background-position: 200% 0; }\\n        to { background-position: -200% 0; }\\n      }\\n\\n      .blar-agent-status-dot {\\n        width: 8px;\\n        height: 8px;\\n        background: #86efac;\\n        border-radius: 50%;\\n        animation: blarAgentStatusPulse 1.5s ease-in-out infinite;\\n      }\\n\\n      .blar-agent-status-card {\\n        position: fixed;\\n        bottom: 20px;\\n        left: 50%;\\n        transform: translateX(-50%);\\n        pointer-events: auto;\\n        display: flex;\\n        flex-direction: column;\\n        gap: 10px;\\n        padding: 14px 18px;\\n        background: linear-gradient(135deg, ${n} 0%, ${s} 100%);\\n        border-radius: 16px;\\n        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\\n        z-index: 2147483646;\\n        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n        animation: blarAgentCardSlideIn 0.3s ease-out forwards;\\n        color: ${i};\\n        box-sizing: border-box;\\n        width: min(416px, calc(100vw - 32px));\\n        overflow: hidden;\\n        transition: opacity 200ms ease-out;\\n      }\\n\\n      /* Something under the card has to be seen: a highlight, a confirmation or a click target, a\\n         tap landing. !important: the slide-in animation holds opacity with fill-mode forwards. */\\n      .blar-agent-status-card--cleared {\\n        opacity: 0.1 !important;\\n        pointer-events: none;\\n        transition-duration: 150ms;\\n      }\\n\\n      /* Laid out at its final place while the bubble morphs into it. */\\n      .blar-agent-status-card--arriving {\\n        opacity: 0 !important;\\n        pointer-events: none;\\n        animation: none;\\n      }\\n\\n      /* The touch panel attached to the card (agent-panel.ts). */\\n      .blar-agent-status-card--rest {\\n        animation: none;\\n      }\\n\\n      .blar-agent-status-card--panel-above {\\n        z-index: 2147483647;\\n        border-top-left-radius: 0;\\n        border-top-right-radius: 0;\\n      }\\n\\n      .blar-agent-status-card--top {\\n        z-index: 2147483647;\\n        top: calc(12px + env(safe-area-inset-top, 0px));\\n        bottom: auto;\\n        border-bottom-left-radius: 0;\\n        border-bottom-right-radius: 0;\\n        animation: blarAgentCardDropIn 260ms cubic-bezier(0.22, 1, 0.36, 1) both;\\n      }\\n\\n      .blar-agent-status-card--top.blar-agent-status-card--top-leaving {\\n        animation: blarAgentCardRiseOut 200ms cubic-bezier(0.4, 0, 1, 1) both;\\n      }\\n\\n      .blar-agent-status-card--stack-hidden {\\n        opacity: 0 !important;\\n        pointer-events: none;\\n        transition-duration: 150ms;\\n      }\\n\\n      .blar-agent-status-card--confirming .blar-agent-stop-btn {\\n        display: none;\\n      }\\n\\n      @keyframes blarAgentCardDropIn {\\n        from { opacity: 0; transform: translateX(-50%) translateY(-16px); }\\n        to   { opacity: 1; transform: translateX(-50%) translateY(0); }\\n      }\\n\\n      @keyframes blarAgentCardRiseOut {\\n        from { opacity: 1; transform: translateX(-50%) translateY(0); }\\n        to   { opacity: 0; transform: translateX(-50%) translateY(-16px); }\\n      }\\n\\n      @keyframes blarAgentCardFade {\\n        from { opacity: 0; }\\n        to   { opacity: 1; }\\n      }\\n\\n      @media (prefers-reduced-motion: reduce) {\\n        .blar-agent-status-card--top {\\n          animation: blarAgentCardFade 150ms ease-out both;\\n        }\\n        .blar-agent-status-card--top.blar-agent-status-card--top-leaving {\\n          animation: blarAgentCardFade 150ms ease-out reverse both;\\n        }\\n      }\\n\\n      .blar-agent-stop-btn {\\n        width: 28px;\\n        height: 28px;\\n        padding: 0;\\n        background: rgba(${o}, 0.2);\\n        border: none;\\n        border-radius: 6px;\\n        color: ${i};\\n        cursor: pointer;\\n        transition: all 0.15s ease;\\n        flex-shrink: 0;\\n        display: flex;\\n        align-items: center;\\n        justify-content: center;\\n      }\\n\\n      .blar-agent-stop-btn:hover {\\n        background: rgba(${o}, 0.3);\\n      }\\n\\n      .blar-agent-stop-btn svg {\\n        pointer-events: none;\\n      }\\n\\n      .blar-agent-queued-indicator {\\n        display: flex;\\n        align-items: center;\\n        gap: 6px;\\n        padding: 6px 10px;\\n        background: rgba(134, 239, 172, 0.2);\\n        border-radius: 8px;\\n        font-size: 11px;\\n        color: #86efac;\\n        animation: blarAgentBubbleSlideIn 0.3s ease-out;\\n      }\\n\\n      .blar-agent-queued-icon {\\n        font-size: 12px;\\n      }\\n\\n      .blar-agent-queued-text {\\n        flex: 1;\\n        overflow: hidden;\\n        text-overflow: ellipsis;\\n        white-space: nowrap;\\n      }\\n\\n      .blar-agent-minimized {\\n        position: fixed;\\n        bottom: 20px;\\n        left: 50%;\\n        transform: translateX(-50%);\\n        width: 40px;\\n        height: 40px;\\n        background: linear-gradient(135deg, ${n} 0%, ${s} 100%);\\n        border-radius: 20px;\\n        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);\\n        z-index: 2147483646;\\n        display: flex;\\n        align-items: center;\\n        justify-content: center;\\n        cursor: pointer;\\n        font-size: 18px;\\n        transition: all 0.2s ease;\\n      }\\n\\n      .blar-agent-minimized:hover {\\n        width: 48px;\\n        height: 48px;\\n        background: linear-gradient(135deg, ${r} 0%, ${n} 100%);\\n      }\\n\\n      .blar-agent-bubbles-container {\\n        position: fixed;\\n        bottom: 96px;\\n        left: 50%;\\n        transform: translateX(-50%);\\n        display: flex;\\n        flex-direction: column;\\n        gap: 10px;\\n        z-index: 2147483640;\\n        width: min(380px, calc(100vw - 32px));\\n        transition: opacity 200ms ease-out;\\n      }\\n\\n      /* Same rule as the status card's: what the agent is showing lies underneath. */\\n      .blar-agent-bubbles-container--cleared {\\n        opacity: 0.1;\\n        pointer-events: none;\\n        transition-duration: 150ms;\\n      }\\n\\n      .blar-agent-message-bubble {\\n        cursor: pointer;\\n        background: #ffffff;\\n        border-radius: 12px;\\n        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);\\n        overflow: hidden;\\n        animation: blarAgentBubbleSlideIn 0.3s ease-out;\\n      }\\n\\n      @keyframes blarAgentBubbleSlideIn {\\n        0% {\\n          transform: translateY(20px);\\n          opacity: 0;\\n        }\\n        100% {\\n          transform: translateY(0);\\n          opacity: 1;\\n        }\\n      }\\n\\n      .blar-agent-bubble-fade-out {\\n        animation: blarAgentBubbleFadeOut 0.3s ease-out forwards;\\n      }\\n\\n      @keyframes blarAgentBubbleFadeOut {\\n        0% {\\n          transform: translateY(0);\\n          opacity: 1;\\n        }\\n        100% {\\n          transform: translateY(20px);\\n          opacity: 0;\\n        }\\n      }\\n\\n      .blar-agent-bubble-content {\\n        padding: 12px 14px;\\n        font-size: 14px;\\n        font-weight: 450;\\n        color: #1f2937;\\n        line-height: 1.45;\\n        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n        max-height: 140px;\\n        overflow-y: auto;\\n      }\\n\\n      .blar-agent-bubble-content p {\\n        margin: 0 0 6px 0;\\n      }\\n\\n      .blar-agent-bubble-content p:last-child {\\n        margin-bottom: 0;\\n      }\\n\\n      .blar-agent-bubble-content code {\\n        padding: 1px 4px;\\n        border-radius: 3px;\\n        background: #f3f4f6;\\n        font-size: 12px;\\n        font-family: 'SF Mono', Monaco, Consolas, monospace;\\n      }\\n\\n      .blar-agent-bubble-content pre {\\n        margin: 6px 0;\\n        padding: 8px;\\n        border-radius: 6px;\\n        background: #f3f4f6;\\n        overflow-x: auto;\\n      }\\n\\n      .blar-agent-bubble-content pre code {\\n        padding: 0;\\n        background: none;\\n      }\\n\\n      .blar-agent-bubble-content strong {\\n        font-weight: 600;\\n      }\\n\\n      .blar-agent-bubble-content ul,\\n      .blar-agent-bubble-content ol {\\n        margin: 4px 0;\\n        padding-left: 18px;\\n      }\\n\\n      .blar-agent-bubble-content li {\\n        margin-bottom: 2px;\\n      }\\n\\n      .blar-agent-bubble-content a {\\n        color: ${n};\\n        text-decoration: none;\\n      }\\n\\n      .blar-agent-bubble-content a:hover {\\n        text-decoration: underline;\\n      }\\n\\n      /* Execution blocking overlay */\\n      .blar-agent-execution-overlay {\\n        position: fixed;\\n        top: 0;\\n        left: 0;\\n        width: 100%;\\n        height: 100%;\\n        background: rgba(0, 0, 0, 0.08);\\n        z-index: 2147483639;\\n        pointer-events: auto;\\n        cursor: not-allowed;\\n      }\\n\\n      /* Hide execution overlay when confirmation UI is showing */\\n      body.blar-confirmation-active .blar-agent-execution-overlay {\\n        display: none;\\n      }\\n\\n      /* Toast notification for blocked clicks */\\n      .blar-agent-click-toast {\\n        position: fixed;\\n        bottom: 100px;\\n        left: 50%;\\n        transform: translateX(-50%) translateY(20px);\\n        background: rgba(0, 0, 0, 0.8);\\n        color: white;\\n        padding: 10px 20px;\\n        border-radius: 8px;\\n        font-size: 14px;\\n        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n        z-index: 2147483643;\\n        opacity: 0;\\n        transition: opacity 0.2s ease, transform 0.2s ease;\\n        pointer-events: none;\\n      }\\n\\n      .blar-agent-click-toast.visible {\\n        opacity: 1;\\n        transform: translateX(-50%) translateY(0);\\n      }\\n\\n      /* Stop button highlight pulse animation */\\n      .blar-agent-stop-btn.highlight-pulse {\\n        animation: stopButtonPulse 0.8s ease-in-out 3;\\n        border: 2px solid rgba(255, 255, 255, 0.8);\\n      }\\n\\n      @keyframes stopButtonPulse {\\n        0%, 100% { transform: scale(1); }\\n        50% { transform: scale(1.2); box-shadow: 0 0 15px rgba(255, 255, 255, 0.6); }\\n      }\\n    `,document.head.appendChild(a),this.stylesInjected=!0}createStatusCard(){this.statusCard=document.createElement(\"div\"),this.statusCard.className=\"blar-agent-status-card\";const e=Na();this.statusCard.innerHTML=`\\n      <div class=\"blar-agent-status-header\">\\n        <span class=\"blar-agent-status-text\">${this.escapeHtml(this.currentStatus)}</span>\\n        <button class=\"blar-agent-stop-btn\" title=\"${e.agent.tooltipStop}\">\\n          <svg width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"currentColor\">\\n            <rect width=\"12\" height=\"12\" rx=\"1\"/>\\n          </svg>\\n        </button>\\n      </div>\\n    `,document.body.appendChild(this.statusCard),this.attachStatusCardCaptureListeners()}attachStatusCardCaptureListeners(){this.detachStatusCardCaptureListeners();const e=e=>e.target instanceof Element&&!!e.target.closest(\".blar-agent-status-card\"),t=t=>{e(t)&&t.stopImmediatePropagation()},n=t=>{if(!e(t))return;t.stopImmediatePropagation();t.target.closest(\".blar-agent-stop-btn\")&&(t.preventDefault(),this.onCancel?.())},i=[\"pointerdown\",\"pointerup\",\"mousedown\",\"mouseup\",\"touchstart\",\"touchend\"];for(const e of i)window.addEventListener(e,t,{capture:!0});window.addEventListener(\"click\",n,{capture:!0}),this.statusCardCaptureCleanup=()=>{for(const e of i)window.removeEventListener(e,t,{capture:!0});window.removeEventListener(\"click\",n,{capture:!0})}}detachStatusCardCaptureListeners(){this.statusCardCaptureCleanup&&(this.statusCardCaptureCleanup(),this.statusCardCaptureCleanup=null)}removeStatusCard(){this.detachStatusCardCaptureListeners(),this.statusCard&&(os(this.statusCard),this.statusCard=null)}removeMinimizedButton(){this.minimizedButton&&(os(this.minimizedButton),this.minimizedButton=null)}createMessageBubblesContainer(){if(this.messageBubblesContainer)return;this.messageBubblesContainer=document.createElement(\"div\"),this.messageBubblesContainer.className=\"blar-agent-bubbles-container\",document.body.appendChild(this.messageBubblesContainer);const e=e=>e.stopPropagation();this.messageBubblesContainer.addEventListener(\"click\",e),this.messageBubblesContainer.addEventListener(\"mousedown\",e),this.messageBubblesContainer.addEventListener(\"mouseup\",e),this.messageBubblesContainer.addEventListener(\"pointerdown\",e),this.messageBubblesContainer.addEventListener(\"pointerup\",e),this.messageBubblesContainer.addEventListener(\"click\",e=>{const t=e.target.closest(\".blar-agent-message-bubble\");t&&this.dismissBubble(t)})}removeMessageBubblesContainer(){this.messageBubblesContainer&&(os(this.messageBubblesContainer),this.messageBubblesContainer=null)}updateStatusText(){if(!this.statusCard)return;const e=this.statusCard.querySelector(\".blar-agent-status-text\");e&&(e.textContent=this.confirming?Na().agent.confirmationTitle:this.currentStatus)}escapeHtml(e){const t=document.createElement(\"div\");return t.textContent=e,t.innerHTML}parseMarkdown(e){return rc.parse(e,{async:!1})}}const Up=3e4;const jp=new class{constructor(){this.tail=Promise.resolve()}run(e,t=3e4,n=\"task\"){const i=this.tail.then(()=>this.withWatchdog(e,t,n));return this.tail=i.catch(()=>{}),i}withWatchdog(e,t,r){const o=s();return i(e,t,`Agent ${r} timed out after ${t}ms`).catch(e=>{if(e instanceof n){const e=function(e){const t=la;return!t||t.t<e?\"no progress recorded\":`last progress \"${t.name}\" at +${t.t-e}ms`}(o);throw console.warn(`[AgentWorkQueue] ${r} exceeded ${t}ms (${e}) — abandoning it so the queue can advance (one stuck task must not wedge the rest)`),new n(`Agent ${r} timed out after ${t}ms — ${e}`)}throw e})}};let Wp=0,Vp=0,Gp=!1;function Kp(){const e=window.navigation;return e&&\"function\"==typeof e.addEventListener?e:null}function Yp(){if(Gp)return;const e=Kp();e&&(Gp=!0,e.addEventListener(\"navigate\",e=>{!0===e?.destination?.sameDocument?Vp=s():Wp=s()}))}function Xp(e){return Wp>=e?\"cross-document\":Vp>=e?\"same-document\":null}const Jp=[\"click\",\"check\"];function Qp(e,t){return e.include_page_content?{page_content_skipped:t}:void 0}class Zp{constructor(e,t,n,i,s,r,o=()=>!1,a){this.actionRunner=e,this.confirmationUI=t,this.getWsClient=n,this.showTeachingToast=i,this.networkTracker=s,this.stampActionMarker=r,this.isCancelled=o,this.getAgentModeUI=a,this.runAbort=new AbortController,this.activeCommandId=null,this.domAnalyzer=new qo,this.correctedCommands=new Set,this.lastOutcome=null}stampMarker(e,t,n,i,s){this.stampActionMarker?.({command_id:e,phase:t,action_type:n,element_description:yu(n,i,s),url:window.location.href})}handle(e){this.runAbort.signal.aborted&&(this.runAbort=new AbortController);const t=this.runAbort.signal,n=e.confirmation_required?15e4:Up,i=`${e.action?.type??\"action\"} command`;jp.run(()=>this.handleAsync(e,t),n,i).catch(t=>{this.confirmationUI.forceCancel(),Ji(\"[AgentCommandHandler] Error handling command\",t),this.fail(e.command_id,t instanceof Error?t.message:\"Unknown error\")})}abortRun(){this.runAbort.abort()}async handleAsync(n,i){if(i.aborted||this.isCancelled())return;Yp();const{command_id:r,action:o,target:a,confirmation_required:l,fallback_guidance:c,timeout_ms:d}=n;!function(e,t){ra={command_id:e,action:t,started_at:s(),marks:[]}}(r,o.type),this.activeCommandId&&this.activeCommandId!==r&&(this.sendResponse(this.activeCommandId,!1,\"Command interrupted by new command\",\"user_cancelled\"),this.confirmationUI.forceCancel()),this.activeCommandId=r;try{if(this.actionRunner.isNoTargetAction(o.type)){this.stampMarker(r,\"start\",o.type);const e=s();try{const t=await this.actionRunner.executeNoTarget(o,i);if(t.success){const i=\"navigate\"===o.type?Qp(n,\"navigating\"):n.include_page_content?await this.pageContentFields(t,e,n.page_content_options):void 0;this.sendResponse(r,!0,`${o.type} action completed successfully`,void 0,i)}else this.sendResponse(r,!1,t.error||\"Action failed\",\"execution_error\")}catch(e){this.sendResponse(r,!1,e instanceof Error?e.message:\"Execution failed\",\"execution_error\")}finally{this.stampMarker(r,\"end\",o.type)}return}const u=\"highlight\"===o.type&&!!o.ref,p=\"press_key\"===o.type&&!a;if(!a&&!u&&!p)return void this.sendResponse(r,!1,\"Missing target element\",\"execution_error\");const h=p?function(e){return{element:document.activeElement??document.body,action:e,allCandidates:[],hasAmbiguousMatches:!1,ambiguousCandidates:[],reveal:{hoveredContainers:[]}}}(o):await this.actionRunner.resolve(o,a||{},{timeoutMs:d});if(i.aborted||this.isCancelled())return;if(!h.element)return void this.sendResponse(r,!1,c?`Could not locate the target element. ${c}`:\"Could not locate the target element\",\"element_not_found\");if(h.hasAmbiguousMatches){const e=h.ambiguousCandidates.map(e=>this.extractElementInfo(e.element,e.score));return void this.sendMultipleMatchesWarning(r,e)}const g=h.action,m=h.element,f=\"highlight\"===g.type,b=l&&![\"scroll_to\",\"highlight\",\"hover\"].includes(g.type);if(b){const e=await this.confirmationUI.requestConfirmation({element:m,action:g,risk_level:n.risk_level,teaching_explanation:n.teaching_explanation});if(i.aborted||this.isCancelled())return;if(\"confirmed\"!==e)return void this.sendResponse(r,!1,\"timed_out\"===e?\"User did not respond to the confirmation prompt\":\"User declined the action\",\"user_cancelled\")}n.teaching_explanation&&this.showTeachingToast&&!f&&this.showTeachingToast(n.teaching_explanation),f||this.getAgentModeUI?.()?.setStatus(Na().agent.executingAction);const y=f?n.teaching_explanation||_u(g):void 0,v=ku.includes(g.type),w=`${g.type} action completed successfully`;!v||f||n.include_page_content||this.sendResponse(r,!0,w);let x=!1;const k=async e=>{x=e};this.stampMarker(r,\"start\",g.type,a,m);const S=s(),C=v?null:this.actionRunner.beginValidation(g,m,!1,b?3e3:void 0),E=v?null:Bu(this.networkTracker);try{const{result:o,cleanupHighlight:a,highlightAutoResult:l}=await this.actionRunner.executeWithHighlight(g,m,y,h.reveal,{skipValidation:!0,onBeforeClick:k,signal:i});if(i.aborted||this.isCancelled())return a(),void C?.observer?.disconnect();const c=s()-S,d=(this.networkTracker?.getPendingRequests().length??0)>0;if(o.success&&\"click\"===g.type?this.confirmationUI.applyHoverLockFor(m):o.success&&\"hover\"===g.type&&this.confirmationUI.applyHoverLockFor(m,!0),window.setTimeout(a,500),v)return void(o.success?f?l&&!l.completed?this.sendResponse(r,!1,\"User cancelled during highlight\",\"user_cancelled\"):this.sendResponse(r,!0,\"highlight action completed successfully\"):this.answered(r)||this.sendResponse(r,!0,w,void 0,await this.pageContentFields(o,S,n.page_content_options)):this.fail(r,o.error??\"Action failed\"));if(x&&Ou()||\"cross-document\"===Xp(S))return C?.observer?.disconnect(),void(o.success?this.sendResponse(r,!0,w,void 0,Qp(n,\"navigating\")):this.fail(r,o.error??\"Action failed\"));const u=s();await(E?.wait()),o.success&&\"click\"===g.type&&(b||\"irreversible\"===n.risk_level)&&await async function(n,i,s=6e3){if(!(n instanceof HTMLElement)||t()||!ju(n))return;const r=performance.now();for(;!i?.aborted&&Ds(n)&&performance.now()-r<s;)await e(100)}(m,i);const p=s()-u,M=await this.actionRunner.finishValidation(C),A=s(),_=n.include_page_content?await this.pageContentFields(o,S,n.page_content_options):void 0,T={gesture_ms:Math.round(c),settle_ms:Math.round(p),..._&&{capture_ms:Math.round(s()-A)}};ca(\"timings\",T);const I={...M&&{post_action_signals:M},..._,timings:T},L=o.success?xu(o.new_state):null;o.success?L?this.fail(r,L,I):!0!==o.new_state?.no_op||!Jp.includes(g.type)||d||M?this.sendResponse(r,!0,w,void 0,I):this.fail(r,`The ${g.type} dispatched on the target but the page did not react: no DOM change, no navigation, no focus change. The element may be inert or its activation suppressed — try a different target or a different action.`,I):this.fail(r,o.error??\"Action failed\",I)}catch(e){C?.observer?.disconnect(),this.fail(r,e instanceof Error?e.message:\"Execution failed\")}finally{E?.disarm(),this.stampMarker(r,\"end\",g.type,a,m)}}finally{this.activeCommandId===r&&(this.activeCommandId=null);const e=this.lastOutcome?.commandId===r?this.lastOutcome:null;!function(e,t){if(!ra)return;const n=ra;if(ra=null,n.ok=e,n.duration_ms=s()-n.started_at,t&&(n.error=t),!oa())return;sa.push(n),sa.length>30&&sa.shift();const i=`[blar-agent] ${n.action} ${n.command_id} ok=${e} ${n.duration_ms}ms`+(n.error?` — ${n.error}`:\"\");console.groupCollapsed(i),console.table(n.marks.map(e=>({\"+ms\":e.t-n.started_at,mark:e.name,...e.data}))),console.groupEnd()}(e?.ok??!0,e&&!e.ok?e.message:void 0)}}sendResponse(e,t,n,i,s){const r={type:\"sdk_response\",command_id:e,response_type:\"agent_command_response\",data:{success:t,message:n,...i&&{error:i},...s}};ca(\"response\",{success:t,message:n,...i&&{error:i}}),this.lastOutcome={commandId:e,ok:t,message:n};const o=this.getWsClient();o?o.sendSDKResponse(r):Ji(\"[AgentCommandHandler] No WebSocket client available\"),this.getAgentModeUI?.()?.setStatus(Na().agent.thinking)}async pageContentSkipReason(e,t){if(!0===e.new_state?.no_op)return\"no_op\";const n=Xp(t);return\"cross-document\"===n?\"navigating\":\"same-document\"!==n&&null!==Kp()||await this.awaitStableUrl()?zu(this.networkTracker)?\"page_busy\":null:\"url_unstable\"}async awaitStableUrl(){const t=s()+1e3;let n=window.location.href,i=s();for(;s()-i<250;){if(s()>=t)return!1;await e(50),window.location.href!==n&&(n=window.location.href,i=s())}return!0}async pageContentFields(e,t,n){const i=await this.pageContentSkipReason(e,t);if(i)return{page_content_skipped:i};if(this.isCancelled())return{};try{return this.textDomAnalyzer??(this.textDomAnalyzer=new ia(this.domAnalyzer,this.networkTracker)),{page_content:this.textDomAnalyzer.analyze(n)}}catch(e){return Ji(\"[AgentCommandHandler] post-action page content failed\",e),{}}}answered(e){return this.lastOutcome?.commandId===e}fail(e,t,n){this.answered(e)?this.sendCorrection(e,t):this.sendResponse(e,!1,t,\"execution_error\",n)}sendCorrection(e,t){if(this.correctedCommands.has(e))return;if(this.correctedCommands.add(e),this.correctedCommands.size>50){const e=this.correctedCommands.values().next().value;void 0!==e&&this.correctedCommands.delete(e)}ca(\"correction\",{message:t}),this.lastOutcome={commandId:e,ok:!1,message:t},Qi(\"agent-action\",`correction ${e}: ${t}`);const n=this.getWsClient();n?n.sendSDKError(e,t,\"execution_error\"):Ji(\"[AgentCommandHandler] No WebSocket client available to correct an ack\")}extractElementInfo(e,t){const n=$s(e,2e3),i=Ws(e,3,3e3),s=this.generateSelectors(e),r=e.innerText?.trim()||void 0,o=e.tagName.toLowerCase(),a=Vs(e),l=Gs(e),c=this.buildAncestorClassChain(e),d=Cu(e),u=this.buildNearbyText(e),p=this.domAnalyzer.getContextPath(e);let h,g=e.getAttribute(\"placeholder\")||void 0;if(!g&&\"true\"===e.getAttribute(\"contenteditable\")){const t=e.querySelector(\"[data-placeholder]\");t&&(g=t.getAttribute(\"data-placeholder\")||void 0)}e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?h=e.value:\"true\"===e.getAttribute(\"contenteditable\")&&(h=(e.innerText||e.textContent||\"\").trim());const m=e.getAttribute(\"role\")||void 0,f=e instanceof HTMLInputElement?e.type:void 0;return{html:n,...i&&{parent_html:i},selectors:s,inner_text:r,tag_name:o,score:t,...g&&{placeholder:g},...void 0!==h&&{value:h},...m&&{role:m},...f&&{input_type:f},...a&&{nearest_label:a},...l.length>0&&{sibling_text:l},...c.length>0&&{ancestor_classes:c},...d&&{unique_selector:d},...u&&{nearby_text:u},...p.length>0&&{context_path:p}}}buildAncestorClassChain(e){const t=[];let n=e.parentElement,i=0;for(;n&&i<6&&n!==document.body;){n.id&&t.push(`#${n.id}`);for(const e of Array.from(n.classList))(e.includes(\"__\")||e.includes(\"--\"))&&t.push(`.${e}`);n=n.parentElement,i++}return t}buildNearbyText(e){const t=this.findMeaningfulContainer(e);if(t)return this.extractSiblingText(t)}findMeaningfulContainer(e){const t=new Set([\"SECTION\",\"FIELDSET\",\"NAV\",\"ARTICLE\"]);let n=e.parentElement,i=0,s=null;for(;n&&i<6&&n!==document.body;){if(Array.from(n.classList).some(e=>e.includes(\"__\")||e.includes(\"--\"))||n.id)return n;if(!s){const e=n.querySelector(\":scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > h5, :scope > h6\"),i=n.hasAttribute(\"aria-label\"),r=\"group\"===n.getAttribute(\"role\")||\"radiogroup\"===n.getAttribute(\"role\"),o=t.has(n.tagName);(e||i||r||o)&&(s=n)}n=n.parentElement,i++}return s}extractSiblingText(e){const t={};let n=e.previousSibling;for(;n;){if(n.nodeType===Node.TEXT_NODE){const e=n.textContent?.trim();if(e){t.before=e;break}}else if(n.nodeType===Node.ELEMENT_NODE){const e=n.textContent?.trim();e&&e.length<50&&(t.before=e);break}n=n.previousSibling}let i=e.nextSibling;for(;i;){if(i.nodeType===Node.TEXT_NODE){const e=i.textContent?.trim();if(e){t.after=e;break}}else if(i.nodeType===Node.ELEMENT_NODE){const e=i.textContent?.trim();e&&e.length<50&&(t.after=e);break}i=i.nextSibling}if(t.before||t.after)return t}generateSelectors(e){const t=[];if(e.id){const n=`#${CSS.escape(e.id)}`;t.push({selector:n,strategy:\"id\",unique:1===document.querySelectorAll(n).length})}const n=e.getAttribute(\"data-testid\");if(n){const e=`[data-testid=\"${CSS.escape(n)}\"]`;t.push({selector:e,strategy:\"data-testid\",unique:1===document.querySelectorAll(e).length})}const i=e.getAttribute(\"aria-label\");if(i){const e=`[aria-label=\"${CSS.escape(i)}\"]`;t.push({selector:e,strategy:\"aria-label\",unique:1===document.querySelectorAll(e).length})}if(e.classList.length>0){const n=e.tagName.toLowerCase(),i=e.classList[0],s=`${n}.${CSS.escape(i)}`;t.push({selector:s,strategy:\"class\",unique:1===document.querySelectorAll(s).length})}return t}sendMultipleMatchesWarning(e,t){const n={type:\"sdk_response\",command_id:e,response_type:\"agent_command_response\",data:{success:!1,message:`Found ${t.length} elements with similar match scores. Please provide a more specific selector.`,error:\"multiple_matches\",matched_elements:t}},i=this.getWsClient();i?i.sendSDKResponse(n):Ji(\"[AgentCommandHandler] No WebSocket client available\"),this.getAgentModeUI?.()?.setStatus(Na().agent.thinking)}}class eh{constructor(e,t,n,i,s,r,o,a=()=>!1,l){this.actionRunner=e,this.domStateAnalyzer=t,this.getWsClient=n,this.confirmationUI=i,this.showTeachingToast=s,this.networkTracker=r,this.stampActionMarker=o,this.isCancelled=a,this.getAgentModeUI=l,this.aborted=!1,this.runAbort=new AbortController,this.textDomAnalyzer=new ia(t,r)}stampMarker(e,t,n,i,s){this.stampActionMarker?.({command_id:e,phase:t,action_type:n,element_description:yu(n,i,s),url:window.location.href})}stampUnresolvedStep(e,t,n){this.stampMarker(e,\"start\",t,n),this.stampMarker(e,\"end\",t,n)}abortRun(){this.aborted=!0,this.runAbort.abort()}handle(e){this.runAbort.signal.aborted&&(this.runAbort=new AbortController);const t=this.runAbort.signal,n=e.commands.filter(e=>\"agent_command\"===e.type).length||1,i=`batch of ${n} command${1===n?\"\":\"s\"}`;jp.run(()=>this.processAll(e,t),n*Up,i).catch(t=>{Ji(\"[BatchCommandHandler] Unexpected error\",t),this.sendBatchResponse(e.batch_id,{results:[],stopped_at:0})})}async processAll(t,n=(new AbortController).signal){Yp(),this.aborted=n.aborted;const{batch_id:i,commands:r}=t,o=[];let a,l=null;const c=r.reduce((e,t,n)=>\"agent_command\"===t.type?n:e,-1);!function(e){for(const t of e){const e=To.get(t),n=e?.isConnected?po(e):null;n&&Ro.set(t,n)}}(r.flatMap(e=>\"agent_command\"===e.type&&e.target?.agent_id?[e.target.agent_id]:[]));for(let t=0;t<r.length;t++){const i=r[t];if(n.aborted||this.aborted||this.isCancelled()){l=t,a=\"cancelled\";break}if(\"agent_command\"===i.type){const r=t===c,d=s(),u=await this.executeAgentCommand(i,r,n);if(o.push(u),\"error\"in u&&\"user_cancelled\"===u.error){l=t+1,a=\"cancelled\";break}if(\"check_unreached\"in u&&u.check_unreached){l=t+1,a=\"check_unreached\";break}if(!u.success){l=t;break}if(Ou()||\"cross-document\"===Xp(d)){l=t+1,a=\"navigated\";break}i.dom_settle_ms&&i.dom_settle_ms>0&&await e(i.dom_settle_ms)}else if(\"request_dom_state\"===i.type){const e=this.executeDomState(i);o.push(e)}else if(\"request_text_dom\"===i.type){const e=this.executeTextDom(i);o.push(e)}}this.sendBatchResponse(i,{results:o,stopped_at:l,stopped_reason:a})}async executeAgentCommand(t,n,i){const{command_id:s,action:r,target:o}=t,a=performance.now();if(t.teaching_explanation&&this.showTeachingToast&&\"highlight\"!==r.type&&this.showTeachingToast(t.teaching_explanation),\"highlight\"!==r.type&&this.getAgentModeUI?.()?.setStatus(Na().agent.executingAction),this.actionRunner.isNoTargetAction(r.type)){this.stampMarker(s,\"start\",r.type);try{const e=await this.actionRunner.executeNoTarget(r,i),t=performance.now()-a;return e.success?{command_id:s,success:!0,message:`${r.type} completed`,total_duration_ms:t}:{command_id:s,success:!1,message:e.error||\"Action failed\",error:\"execution_error\",total_duration_ms:t}}catch(e){const t=performance.now()-a;return{command_id:s,success:!1,message:e instanceof Error?e.message:\"Execution failed\",error:\"execution_error\",total_duration_ms:t}}finally{this.stampMarker(s,\"end\",r.type)}}let l,c,d=r,u=0;const p=\"highlight\"===r.type&&!!r.ref;if(\"press_key\"!==r.type||o){if(!o&&!p){const e=performance.now()-a;return this.stampUnresolvedStep(s,r.type,o),{command_id:s,success:!1,message:\"Missing target element\",error:\"execution_error\",total_duration_ms:e}}const e=performance.now(),t=await this.actionRunner.resolve(r,o||{});if(u=performance.now()-e,i?.aborted||this.aborted||this.isCancelled())return{command_id:s,success:!1,message:\"Action cancelled\",error:\"user_cancelled\",resolve_duration_ms:u,total_duration_ms:performance.now()-a};if(!t.element){const e=performance.now()-a;return this.stampUnresolvedStep(s,r.type,o),{command_id:s,success:!1,message:\"Could not locate the target element\",error:\"element_not_found\",resolve_duration_ms:u,total_duration_ms:e}}d=t.action,l=t.element,c=t.reveal}else l=document.activeElement||document.body;const h=\"highlight\"===d.type?t.teaching_explanation||_u(d):void 0;this.stampMarker(s,\"start\",d.type,o,l);const g=n&&!ku.includes(d.type)?Bu(this.networkTracker):null;try{const r=performance.now(),{result:o,cleanupHighlight:p,highlightAutoResult:m}=await this.actionRunner.executeWithHighlight(d,l,h,c,{skipValidation:!0===t.skip_post_action_signals,signal:i});if(i?.aborted||this.aborted||this.isCancelled())return p(),{command_id:s,success:o.success,message:\"Action cancelled\",error:\"user_cancelled\",resolve_duration_ms:u,total_duration_ms:performance.now()-a};const f=performance.now()-r;if(o.success&&\"click\"===d.type?this.confirmationUI?.applyHoverLockFor(l):o.success&&\"hover\"===d.type&&this.confirmationUI?.applyHoverLockFor(l,!0),m&&!m.completed){const e=performance.now()-a;return{command_id:s,success:o.success,message:o.success?`User cancelled; the ${d.type} had already run`:`User cancelled; the ${d.type} failed: ${o.error||\"Action failed\"}`,error:\"user_cancelled\",resolve_duration_ms:u,total_duration_ms:e}}let b=0;if(o.success&&n){const t=performance.now();await(g?g.wait():e(150)),b=performance.now()-t}p();const y=performance.now()-a,v=o.new_state?.post_action_signals,w=o.success?xu(o.new_state):null;if(o.success){const e=!0===o.new_state?.no_op;return{command_id:s,success:!0,message:w??(e?`${d.type} dispatched, but the page did not react (no DOM change, navigation, or focus change)`:`${d.type} completed`),...e&&{no_op:!0},...w&&{check_unreached:!0},resolve_duration_ms:u,execute_duration_ms:f,settle_duration_ms:b,...v&&{post_action_signals:v},total_duration_ms:y}}const x=o.new_state?.available_options;return{command_id:s,success:!1,message:o.error||\"Action failed\",error:\"execution_error\",resolve_duration_ms:u,execute_duration_ms:f,total_duration_ms:y,...x&&{available_options:x},...v&&{post_action_signals:v}}}catch(e){const t=performance.now()-a;return{command_id:s,success:!1,message:e instanceof Error?e.message:\"Execution failed\",error:\"execution_error\",resolve_duration_ms:u,total_duration_ms:t}}finally{g?.disarm(),this.stampMarker(s,\"end\",d.type,o,l)}}executeDomState(e){const t=performance.now(),n=this.domStateAnalyzer.analyze(e.options),i=performance.now()-t;return{command_id:e.command_id,type:\"dom_state\",dom_state:n,total_duration_ms:i}}executeTextDom(e){const t=performance.now(),n=this.textDomAnalyzer.analyze(e.options),i=performance.now()-t;return{command_id:e.command_id,type:\"text_dom\",text_dom:n,total_duration_ms:i}}sendBatchResponse(e,t){const n={type:\"sdk_response\",command_id:e,response_type:\"agent_command_batch_response\",data:t},i=this.getWsClient();i?i.sendSDKResponse(n):Ji(\"[BatchCommandHandler] No WebSocket client available — response LOST\"),this.getAgentModeUI?.()?.setStatus(Na().agent.thinking)}}const th=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=function(e,t){return\"2d\"===e&&(t={...t,willReadFrequently:!0}),th.call(this,e,t)};var nh=Object.defineProperty,ih=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},sh=(e,t)=>{for(var n in t)nh(e,n,{get:t[n],enumerable:!0})};var rh,oh,ah=ih(()=>{rh=class extends Map{constructor(e=100,...t){super(...t),this._maxSize=e}set(e,t){if(this.size>=this._maxSize&&!this.has(e)){let e=this.keys().next().value;void 0!==e&&this.delete(e)}return super.set(e,t)}},oh={image:new rh(100),background:new rh(100),resource:new rh(150),defaultStyle:new rh(64),baseStyle:new rh(50),compress:new rh(50),computedStyle:new WeakMap,measureHints:new WeakMap,warnedReconcile:!1}});function lh(e){let t=e.match(/url\\((['\"]?)(.*?)(\\1)\\)/);if(!t)return null;let n=t[2].trim();return n.startsWith(\"#\")?null:n}function ch(e,t=1){let n=e.match(/^\\s*-?(?:webkit-)?image-set\\(([\\s\\S]*)\\)\\s*$/i);if(!n)return null;let i=[];for(let e of function(e){let t=[],n=0,i=0,s=\"\";for(let r=0;r<e.length;r++){let o=e[r];\"\\\\\"!==o?s?o===s&&(s=\"\"):'\"'===o||\"'\"===o?s=o:\"(\"===o?i++:\")\"===o?i--:\",\"===o&&0===i&&(t.push(e.slice(n,r)),n=r+1):r++}return t.push(e.slice(n)),t}(n[1])){let t=e.match(/url\\((['\"]?)(.*?)(\\1)\\)/);if(!t)continue;let n=e.match(/type\\(\\s*[\"']([^\"']+)[\"']\\s*\\)/i);if(n&&!bh.test(n[1].trim()))continue;let s=e.replace(/url\\((['\"]?)[\\s\\S]*?\\1\\)/,\" \").match(/(\\d+(?:\\.\\d+)?)\\s*(x|dpi|dppx)\\b/i),r=1;if(s){let e=parseFloat(s[1]);r=/dpi/i.test(s[2])?e/96:e}i.push({url:t[2].trim(),dppx:r})}return i.length?(i.sort((e,t)=>e.dppx-t.dppx),(i.find(e=>e.dppx>=t)||i[i.length-1]).url):null}function dh(e){if(/%[0-9A-Fa-f]{2}/.test(e))return e;try{return encodeURI(e)}catch{return e}}function uh(e){return!!e&&\"INPUT\"===e.tagName&&\"password\"===(e.getAttribute(\"type\")||\"\").toLowerCase()}function ph(e,t){return 1===e?.nodeType&&e.localName===t}function hh(e){return 1===e?.nodeType&&e.namespaceURI===yh}function gh(e){return 1===e?.nodeType&&e.namespaceURI===vh}function mh(e){return 11===e?.nodeType&&!!e.host}var fh,bh,yh,vh,wh=ih(()=>{bh=fh=/^image\\/(jpeg|jpg|png|gif|webp|avif|apng|svg\\+xml|bmp|x-icon|vnd\\.microsoft\\.icon)\\s*(;|$)/i,yh=\"http://www.w3.org/1999/xhtml\",vh=\"http://www.w3.org/2000/svg\"});function xh(e,t,n){if(Ih.size>=Th){let e=Date.now();for(let[t,n]of Ih)n.until<=e&&Ih.delete(t);for(;Ih.size>=Th;)Ih.delete(Ih.keys().next().value)}Ih.set(e,{until:Date.now()+n,result:t})}function kh(e,t){if(!t||function(e){return/^data:|^blob:|^about:blank$/i.test(e)}(e)||function(e,t){try{let n=typeof location<\"u\"&&location.href?location.href:\"http://localhost/\",i=t.split(/\\{url(?:Raw)?\\}/)[0],s=new URL(i||\".\",n);if(new URL(e,n).origin===s.origin)return!0}catch{}return!1}(e,t))return!1;try{let t=typeof location<\"u\"&&location.href?location.href:\"http://localhost/\",n=new URL(e,t);return!(typeof location<\"u\")||n.origin!==location.origin}catch{return!!t}}function Sh(e){return new Promise((t,n)=>{let i=new FileReader;i.onload=()=>t(String(i.result||\"\")),i.onerror=()=>n(new Error(\"read_failed\")),i.readAsDataURL(e)})}function Ch(e){try{return new URL(e,globalThis.location?.href||\"http://localhost/\").origin}catch{return\"invalid-url\"}}function Eh(e,t){try{e.onError?.(t)}catch{}}async function Mh(e,t={}){let n,i=t.as??\"blob\",s=t.timeout??3e3,r=t.useProxy||\"\",o=t.errorTTL??8e3,a=t.headers||{},l=!!t.silent;if(/^data:/i.test(e))try{if(\"text\"===i)return{ok:!0,data:String(e),status:200,url:e,fromCache:!1};if(\"dataURL\"===i)return{ok:!0,data:String(e),status:200,url:e,fromCache:!1,mime:String(e).slice(5).split(\";\")[0]||\"\"};let[,t=\"\",n=\"\"]=String(e).match(/^data:([^,]*),(.*)$/)||[],s=/;base64/i.test(t)?atob(n):decodeURIComponent(n),r=new Uint8Array([...s].map(e=>e.charCodeAt(0))),o=new Blob([r],{type:(t||\"\").split(\";\")[0]||\"\"});return{ok:!0,data:o,status:200,url:e,fromCache:!1,mime:o.type||\"\"}}catch{return{ok:!1,data:null,status:0,url:e,fromCache:!1,reason:\"special_url_error\"}}if(/^blob:/i.test(e))try{let t=await fetch(e);if(!t.ok)return{ok:!1,data:null,status:t.status,url:e,fromCache:!1,reason:\"http_error\"};let n=await t.blob(),s=n.type||t.headers.get(\"content-type\")||\"\";return\"dataURL\"===i?{ok:!0,data:await Sh(n),blob:n,status:t.status,url:e,fromCache:!1,mime:s}:\"text\"===i?{ok:!0,data:await n.text(),status:t.status,url:e,fromCache:!1,mime:s}:{ok:!0,data:n,status:t.status,url:e,fromCache:!1,mime:s}}catch{return{ok:!1,data:null,status:0,url:e,fromCache:!1,reason:\"network\"}}if(/^about:blank$/i.test(e))return\"dataURL\"===i?{ok:!0,data:\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==\",status:200,url:e,fromCache:!1,mime:\"image/png\"}:{ok:!0,data:\"text\"===i?\"\":new Blob([]),status:200,url:e,fromCache:!1};try{n=function(e,t){return new Headers(t.headers||{}).keys().next().done?JSON.stringify([t.as||\"blob\",t.timeout??3e3,t.useProxy||\"\",t.errorTTL??8e3,t.credentials||\"\",e]):null}(e,{as:i,timeout:s,useProxy:r,errorTTL:o,credentials:t.credentials,headers:a})}catch{let n={ok:!1,data:null,status:0,url:e,fromCache:!1,reason:\"network\"};return Eh(t,n),n}let c=Ih.get(n);if(c&&c.until>Date.now())return{...c.result,fromCache:!0};c&&Ih.delete(n);let d=_h.get(n);if(d)return d;let u=kh(e,r)?function(e,t){if(!t)return e;if(/\\{url(?:Raw)?\\}/.test(t))return t.replace(\"{urlRaw}\",()=>dh(e)).replace(\"{url}\",()=>encodeURIComponent(e));if(/[?&]url=?$/.test(t))return`${t}${encodeURIComponent(e)}`;if(t.endsWith(\"?\"))return`${t}url=${encodeURIComponent(e)}`;if(t.endsWith(\"/\"))return`${t}${dh(e)}`;let n=t.includes(\"?\")?\"&\":\"?\";return`${t}${n}url=${encodeURIComponent(e)}`}(e,r):e,p=t.credentials;if(!p)try{let t=typeof location<\"u\"&&location.href?location.href:\"http://localhost/\",n=new URL(e,t);p=typeof location<\"u\"&&n.origin===location.origin?\"include\":\"omit\"}catch{p=\"omit\"}let h=new AbortController,g=setTimeout(()=>h.abort(\"timeout\"),s),m=(async()=>{try{let s=await fetch(u,{signal:h.signal,credentials:p,headers:a});if(!s.ok){let r={ok:!1,data:null,status:s.status,url:u,fromCache:!1,reason:\"http_error\"};if(null!==n&&o>0&&xh(n,r,o),!l){let t=`${s.status} ${s.statusText||\"\"}`.trim();Ah.warnOnce(`http:${s.status}:${i}:${Ch(e)}`,`HTTP error ${t} while fetching ${i} ${e}`)}return Eh(t,r),r}if(\"text\"===i)return{ok:!0,data:await s.text(),status:s.status,url:u,fromCache:!1};let r=await s.blob(),c=r.type||s.headers.get(\"content-type\")||\"\";return\"dataURL\"===i?{ok:!0,data:await Sh(r),blob:r,status:s.status,url:u,fromCache:!1,mime:c}:{ok:!0,data:r,status:s.status,url:u,fromCache:!1,mime:c}}catch(r){let a=h.signal.aborted?\"timeout\"===h.signal.reason?\"timeout\":\"abort\":r&&\"object\"==typeof r&&\"AbortError\"===r.name?\"abort\":\"network\",c={ok:!1,data:null,status:0,url:u,fromCache:!1,reason:a};if(null!==n&&!/^blob:/i.test(e)&&o>0&&xh(n,c,o),!l){let t=`${a}:${i}:${Ch(e)}`,n=\"timeout\"===a?`Timeout after ${s}ms. Consider increasing timeout or using a proxy for ${e}`:\"abort\"===a?`Request aborted while fetching ${i} ${e}`:`Network/CORS issue while fetching ${i} ${e}. A proxy may be required`;Ah.errorOnce(t,n)}return Eh(t,c),c}finally{clearTimeout(g),_h.delete(n)}})();return null!==n&&_h.set(n,m),m}var Ah,_h,Th,Ih,Lh=ih(()=>{wh(),Ah=function(e=\"[snapDOM]\",{ttlMs:t=3e5,maxEntries:n=12}={}){let i=new Map,s=0;function r(r,o,a){if(s>=n)return;let l=Date.now();(i.get(o)||0)>l||(i.set(o,l+t),s++,\"warn\"===r&&console&&console.warn?console.warn(`${e} ${a}`):console&&console.error&&console.error(`${e} ${a}`))}return{warnOnce(e,t){r(\"warn\",e,t)},errorOnce(e,t){r(\"error\",e,t)},reset(){i.clear(),s=0}}}(\"[snapDOM]\",{ttlMs:18e4,maxEntries:10}),_h=new Map,Th=50,Ih=new Map});async function Rh(e,t={}){if(/^\\s*url\\(\\s*['\"]?data:/i.test(e)||/^((repeating-)?(linear|radial|conic)-gradient)\\(/i.test(e)||\"none\"===e.trim())return e;let n=ch(e,typeof devicePixelRatio<\"u\"&&devicePixelRatio||1)??lh(e);if(!n)return e;let i=function(e,t){if(!e||/^(data|blob|about|#)/i.test(e.trim()))return e;try{let n=t||typeof document<\"u\"&&(document.baseURI||document.location?.href)||\"http://localhost/\";return new URL(e,n).href}catch{return e}}(n),s=dh(i),r=(t.useProxy||\"\")+\"|\"+s;if(oh.background.has(r)){let e=oh.background.get(r);return e?`url(\"${e}\")`:\"none\"}try{let e=await Mh(s,{as:\"dataURL\",useProxy:t.useProxy});return e.ok?(oh.background.set(r,e.data),`url(\"${e.data}\")`):(oh.background.set(r,null),\"none\")}catch{return oh.background.set(r,null),\"none\"}}var $h=ih(()=>{ah(),wh(),Lh()});function Nh(e){let t=e.replace(Xh,\"\").trim();return t?t.replace(/(^|,)(\\s*)(?=,|$)/g,\"$1$2*\"):\"*\"}function Ph(e,t,n,i){for(let s=0;s<e.length;s++){if(--i.budget<0)return!1;let r=e[s],o=r.style;if(o){let e=!!r.selectorText&&Gh.test(r.selectorText);for(let n=0;n<o.length;n++){let s=o[n];if(t.add(s),e&&i.pseudoProps.add(s),o.getPropertyPriority(s)&&i.importantProps.add(s),s.length>5&&(\"m\"===s[0]||\"p\"===s[0])){let e=s.startsWith(\"margin\")?\"marginUnstable\":s.startsWith(\"padding\")?\"paddingUnstable\":null;e&&!i[e]&&Kh.test(o.getPropertyValue(s))&&(i[e]=!0)}}}let a=r.selectorText;if(a&&a.includes(\":has(\")&&(i.usesHas=!0),a&&a.includes(\"&\"))for(let e=r.parentRule;e&&a.includes(\"&\");e=e.parentRule)e.selectorText&&(a=a.replace(/&/g,`:is(${e.selectorText})`));if(a&&(i.inContainer||Jh.test(a)||a.includes(\"+\")||a.includes(\"~\")))for(let e of Hh(a,\",\")){let t=e.trim();t&&(i.inContainer||Jh.test(t)||t.includes(\"+\")||t.includes(\"~\"))&&i.shareUnsafeSels.add(t)}if(a&&a.includes(\":\"))for(let e in Yh)Yh[e].test(a)&&n[e].push(Nh(a));if(r.styleSheet){if(!Fh(r.styleSheet,t,n,i))return!1}else if(r.cssRules&&r.cssRules.length){let e=\"CSSContainerRule\"===r.constructor?.name;e&&i.inContainer++;let s=Ph(r.cssRules,t,n,i);if(e&&i.inContainer--,!s)return!1}}return!0}function Fh(e,t,n,i){let s;try{s=e.cssRules}catch{return!1}return!!s&&Ph(s,t,n,i)}function Oh(e,t){for(let n of e){let e=n.effect?.getKeyframes?.()||[];for(let n of e)for(let e of Object.keys(n))\"offset\"===e||\"easing\"===e||\"composite\"===e||\"computedOffset\"===e||t.add(e.replace(/[A-Z]/g,e=>\"-\"+e.toLowerCase()))}}function qh(e){let t=new Set;return Fh(e,t,{before:[],after:[],firstLetter:[],marker:[],firstLine:[]},{budget:2e4,usesHas:!1,shareUnsafeSels:new Set,inContainer:0,marginUnstable:!1,paddingUnstable:!1,importantProps:new Set,pseudoProps:new Set})?t:null}function Hh(e,t){if(!e.includes(t))return[e];let n=[],i=0,s=null,r=0;for(let o=0;o<e.length;o++){let a=e[o];\"\\\\\"!==a?s?a===s&&(s=null):'\"'===a||\"'\"===a?s=a:\"(\"===a||\"[\"===a?i++:\")\"===a||\"]\"===a?i--:0===i&&a===t&&(n.push(e.slice(r,o)),r=o+1):o++}return n.push(e.slice(r)),n}function Bh(e){let t=0,n=null,i=0;for(let s=0;s<e.length;s++){let r=e[s];n?r===n&&\"\\\\\"!==e[s-1]&&(n=null):'\"'===r||\"'\"===r?n=r:\"(\"===r||\"[\"===r?t++:\")\"===r||\"]\"===r?t--:0===t&&(\" \"===r||\">\"===r||\"+\"===r||\"~\"===r)&&(i=s+1)}let s=\"\",r=0;for(let t of e.slice(i))\"(\"===t||\"[\"===t?r++:\")\"===t||\"]\"===t?r--:0===r&&(s+=t);let o=e=>!e||/\\\\[0-9a-fA-F]/.test(e)?null:e.replace(/\\\\(.)/g,\"$1\"),a=o((s.match(/\\.((?:\\\\.|[\\w-])+)/)||[])[1]);if(a)return\"c\"+a;let l=o((s.match(/#((?:\\\\.|[\\w-])+)/)||[])[1]);if(l)return\"i\"+l;let c=(s.match(/^([a-zA-Z][\\w-]*)/)||[])[1];return c?\"t\"+c.toLowerCase():null}function Dh(e,t){if(!t.length)return\"\";if(t.some(e=>e.includes(\"&\")))return null;let n=t.join(\",\");try{return e.matches(n),n}catch{return null}}function zh(e,t){let n=e.createElement(\"div\"),i={};for(let e in t){let s=t[e];(\"before\"===e||\"after\"===e)&&s.push(\"q\"),i[e]=Dh(n,s)}return i}function Uh(e){let t={universe:null,pseudoUniverse:null,usesHas:!0,shareGate:null,marginUnstable:!0,paddingUnstable:!0,importantProps:null,pseudoGates:{before:null,after:null,firstLetter:null,marker:null,firstLine:null}};try{let n=new Set(jh),i={before:[],after:[],firstLetter:[],marker:[],firstLine:[]},s={budget:2e4,usesHas:!1,shareUnsafeSels:new Set,inContainer:0,marginUnstable:!1,paddingUnstable:!1,importantProps:new Set,pseudoProps:new Set};for(let r of e.styleSheets)if(!Fh(r,n,i,s))return t;let r=e.adoptedStyleSheets;if(Array.isArray(r))for(let e of r)if(!Fh(e,n,i,s))return t;\"function\"==typeof e.getAnimations&&Oh(e.getAnimations(),n);let o=Array.from(s.shareUnsafeSels),a=null===Dh(e.createElement(\"div\"),o)?null:o.map(e=>({sel:e,key:Bh(e)})),l=new Set(Vh);for(let e of Wh)n.has(e)&&l.add(e);for(let e of s.pseudoProps)l.add(e);return{universe:n,pseudoUniverse:l,pseudoGates:zh(e,i),usesHas:s.usesHas,shareGate:a,marginUnstable:s.marginUnstable,paddingUnstable:s.paddingUnstable,importantProps:s.importantProps}}catch{return t}}var jh,Wh,Vh,Gh,Kh,Yh,Xh,Jh,Qh=ih(()=>{jh=[\"display\",\"position\",\"top\",\"right\",\"bottom\",\"left\",\"float\",\"clear\",\"z-index\",\"box-sizing\",\"width\",\"height\",\"min-width\",\"min-height\",\"max-width\",\"max-height\",\"margin-top\",\"margin-right\",\"margin-bottom\",\"margin-left\",\"padding-top\",\"padding-right\",\"padding-bottom\",\"padding-left\",\"overflow-x\",\"overflow-y\",\"visibility\",\"opacity\",\"content-visibility\",\"vertical-align\",\"border-top-width\",\"border-right-width\",\"border-bottom-width\",\"border-left-width\",\"border-top-style\",\"border-right-style\",\"border-bottom-style\",\"border-left-style\",\"border-top-color\",\"border-right-color\",\"border-bottom-color\",\"border-left-color\",\"border-top-left-radius\",\"border-top-right-radius\",\"border-bottom-right-radius\",\"border-bottom-left-radius\",\"flex-direction\",\"flex-wrap\",\"flex-grow\",\"flex-shrink\",\"flex-basis\",\"order\",\"align-items\",\"align-self\",\"align-content\",\"justify-content\",\"justify-items\",\"justify-self\",\"row-gap\",\"column-gap\",\"grid-template-columns\",\"grid-template-rows\",\"grid-auto-flow\",\"grid-auto-columns\",\"grid-auto-rows\",\"grid-column-start\",\"grid-column-end\",\"grid-row-start\",\"grid-row-end\",\"color\",\"font-family\",\"font-size\",\"font-weight\",\"font-style\",\"font-stretch\",\"line-height\",\"letter-spacing\",\"word-spacing\",\"white-space\",\"text-align\",\"text-transform\",\"text-indent\",\"text-overflow\",\"text-shadow\",\"direction\",\"unicode-bidi\",\"writing-mode\",\"text-orientation\",\"word-break\",\"overflow-wrap\",\"tab-size\",\"list-style-type\",\"list-style-position\",\"list-style-image\",\"counter-reset\",\"counter-increment\",\"counter-set\",\"background-color\",\"background-image\",\"background-size\",\"background-position\",\"background-repeat\",\"background-clip\",\"background-origin\",\"background-attachment\",\"box-shadow\",\"outline-width\",\"outline-style\",\"outline-color\",\"outline-offset\",\"transform\",\"transform-origin\",\"rotate\",\"scale\",\"translate\",\"filter\",\"mix-blend-mode\",\"clip-path\",\"object-fit\",\"object-position\",\"border-collapse\",\"border-spacing\",\"table-layout\",\"caption-side\",\"empty-cells\"],Wh=[\"color\",\"font-family\",\"font-size\",\"font-weight\",\"font-style\",\"font-stretch\",\"font-variant\",\"font-kerning\",\"font-feature-settings\",\"font-variation-settings\",\"line-height\",\"letter-spacing\",\"word-spacing\",\"white-space\",\"text-align\",\"text-align-last\",\"text-indent\",\"text-transform\",\"text-shadow\",\"text-rendering\",\"direction\",\"unicode-bidi\",\"word-break\",\"overflow-wrap\",\"writing-mode\",\"text-orientation\",\"hyphens\",\"tab-size\",\"visibility\",\"list-style-type\",\"list-style-position\",\"list-style-image\",\"border-collapse\",\"border-spacing\",\"caption-side\",\"empty-cells\",\"quotes\",\"color-scheme\",\"-webkit-text-fill-color\",\"-webkit-font-smoothing\",\"image-rendering\"],Vh=[\"display\",\"width\",\"height\",\"min-width\",\"min-height\"],Gh=/::?(?:before|after|first-letter|first-line|marker)/,Kh=/%|\\bauto\\b|calc\\(|var\\(/i,Yh={before:/::?before\\b/,after:/::?after\\b/,firstLetter:/::?first-letter\\b/,marker:/::marker\\b/,firstLine:/::?first-line\\b/},Xh=/::?(?:before|after|first-letter|first-line|marker)\\b/g,Jh=/:(nth-|first-child|last-child|only-|first-of-type|last-of-type|empty|hover|focus|active|target|checked|indeterminate|disabled|enabled|read-only|read-write|placeholder-shown|autofill|valid|invalid|user-valid|user-invalid|in-range|out-of-range|required|optional|default|link|any-link|scope|defined|modal|fullscreen|picture-in-picture|playing|paused|dir\\(|lang\\(|has\\()/});function Zh(e){return tg.add(e),e.setAttribute(\"data-snapdom-internal\",\"\"),e}function eg(e){return tg.has(e)}var tg,ng=ih(()=>{tg=new WeakSet});function ig(e){if(e=String(e).toLowerCase(),hg.has(e)){let t={};return oh.defaultStyle.set(e,t),t}if(oh.defaultStyle.has(e))return oh.defaultStyle.get(e);let t=[...document.querySelectorAll(\"#snapdom-sandbox\")].find(eg);t||(t=document.createElement(\"div\"),Zh(t),t.id=\"snapdom-sandbox\",t.setAttribute(\"data-snapdom-sandbox\",\"true\"),t.setAttribute(\"aria-hidden\",\"true\"),t.style.position=\"absolute\",t.style.left=\"-9999px\",t.style.top=\"-9999px\",t.style.width=\"0px\",t.style.height=\"0px\",t.style.overflow=\"hidden\",document.body.appendChild(t));let n=document.createElement(e.includes(\"-\")?\"span\":e);n.style.all=\"initial\",t.appendChild(n);let i=getComputedStyle(n),s={};for(let e of i){if(sg(e))continue;let t=i.getPropertyValue(e);s[e]=t}for(let e of jh)!(e in s)&&!sg(e)&&(s[e]=i.getPropertyValue(e));return t.removeChild(n),oh.defaultStyle.set(e,s),s}function sg(e){let t=bg.get(e);if(void 0===t){let n=String(e).toLowerCase();t=fg.has(n)||mg.test(n)||gg.test(n),bg.set(e,t)}return t}function rg(e,t){let n=Sg.get(e);if(void 0===n||t[n]!==t[e])return!1;let i=t[\"writing-mode\"];if(i&&\"horizontal-tb\"!==i)return!1;let s=t.direction;return!(s&&\"ltr\"!==s)}function og(e,t){return!wg.has(e)&&(\"inline\"===t||yg.has(e)||vg.has(e))}function ag(e,t,n=!0,i=!1){if(t=String(t||\"\").toLowerCase(),hg.has(t))return\"\";let s=[],r=ig(t),o=(e.display||\"\").toLowerCase(),a=\"inline\"===o,l=og(t,o),c=e[\"text-wrap-mode\"]||e[\"white-space\"]||\"\",d=\"nowrap\"===c||\"pre\"===c,u=l&&n&&!(l&&n&&!a&&d),p=!1;for(let t in e){if(sg(t)||rg(t,e))continue;let n=e[t];if(u){if(xg.has(t))continue;if(kg.has(t)){n&&n!==r[t]&&(s.push(`${t}:${n}`),\"auto\"!==n&&(p=!0));continue}}if(n&&n!==r[t]){if(!d&&(\"width\"===t||\"inline-size\"===t)&&n.endsWith(\"px\")&&n.includes(\".\")){let e=parseFloat(n);if(Number.isFinite(e)){s.push(`${t}:${(e+Cg).toFixed(3)}px`);continue}}s.push(`${t}:${n}`)}}if(u&&!a&&!i&&!p){let t=e.width;t&&\"auto\"!==t&&t!==r.width&&s.push(`min-width:${t}`)}return s.sort(),s.join(\";\")}function lg(e){let t=Array.from(new Set(e.values())).filter(Boolean).sort(),n=new Map,i=1;for(let e of t)n.set(e,\"c\"+i++);return n}function cg(e,t=null){let n=()=>{let e={length:0,getPropertyValue:()=>\"\",item:()=>\"\"};return e[Symbol.iterator]=function*(){},e};if(1!==e?.nodeType){let i=typeof window<\"u\"?window:null;if(i&&\"function\"==typeof i.getComputedStyle)try{return i.getComputedStyle(e,t)||n()}catch{return n()}return n()}let i=oh.computedStyle.get(e);i||(i=new Map,oh.computedStyle.set(e,i));let s=i.get(t);if(!s){let r=function(e){try{let t=e?.ownerDocument;if(!t)return typeof window<\"u\"?window:null;let n=t.defaultView;if(n&&\"function\"==typeof n.getComputedStyle)return n;if(typeof window<\"u\"&&window.frames)for(let e=0;e<window.frames.length;e++)try{if(window.frames[e]?.document===t)return window.frames[e]}catch{}}catch{}return typeof window<\"u\"?window:null}(e),o=null;try{o=r&&\"function\"==typeof r.getComputedStyle?r.getComputedStyle(e,t):null}catch{}if(!o&&typeof window<\"u\"&&\"function\"==typeof window.getComputedStyle)try{e.ownerDocument===document&&(o=window.getComputedStyle(e,t))}catch{}s=o||n(),i.set(t,s)}return s}function dg(e,t=null){let n={};for(let i of t||e){let t=e.getPropertyValue(i);t&&(n[i]=t)}for(let e of Mg){let t=n[`border-${e}-style`],i=n[`border-${e}-width`];(\"none\"===t||\"hidden\"===t||\"0px\"===i)&&(delete n[`border-${e}-style`],delete n[`border-${e}-width`],delete n[`border-${e}-color`])}return n}function ug(e){let t=[],n=0,i=0;for(let s=0;s<e.length;s++){let r=e[s];\"(\"===r&&n++,\")\"===r&&n--,\",\"===r&&0===n&&(t.push(e.slice(i,s).trim()),i=s+1)}return t.push(e.slice(i).trim()),t}var pg,hg,gg,mg,fg,bg,yg,vg,wg,xg,kg,Sg,Cg,Eg,Mg,Ag=ih(()=>{ah(),Qh(),ng(),pg=new Set([\"meta\",\"script\",\"noscript\",\"title\",\"link\",\"template\"]),hg=new Set([\"meta\",\"link\",\"style\",\"title\",\"noscript\",\"script\",\"template\",\"g\",\"defs\",\"use\",\"marker\",\"mask\",\"clipPath\",\"pattern\",\"symbol\",\"path\",\"polygon\",\"polyline\",\"line\",\"circle\",\"ellipse\",\"rect\",\"filter\",\"lineargradient\",\"radialgradient\",\"stop\"]),gg=/(?:^|-)(animation|transition)(?:-|$)/i,mg=/^(--.+|view-timeline|scroll-timeline|animation-trigger|offset-|position-try|app-region|interactivity|overlay|view-transition|-webkit-locale|-webkit-user-(?:drag|modify)|-webkit-tap-highlight-color|-webkit-text-security)$/i,fg=new Set([\"cursor\",\"pointer-events\",\"touch-action\",\"user-select\",\"print-color-adjust\",\"speak\",\"reading-flow\",\"reading-order\",\"anchor-name\",\"anchor-scope\",\"container-name\",\"container-type\",\"timeline-scope\",\"zoom\",\"stroke-color\"]),bg=new Map,yg=new Set([\"span\",\"small\",\"em\",\"strong\",\"b\",\"i\",\"u\",\"s\",\"code\",\"cite\",\"mark\",\"sub\",\"sup\"]),vg=new Set([\"table\",\"thead\",\"tbody\",\"tfoot\",\"tr\",\"td\",\"th\"]),wg=new Set([\"img\",\"video\",\"canvas\",\"svg\",\"iframe\",\"embed\",\"object\",\"input\",\"textarea\",\"select\"]),xg=new Set([\"width\",\"max-width\",\"inline-size\",\"max-inline-size\"]),kg=new Set([\"min-width\",\"min-inline-size\"]),Sg=new Map(Object.entries({\"block-size\":\"height\",\"inline-size\":\"width\",\"min-block-size\":\"min-height\",\"min-inline-size\":\"min-width\",\"max-block-size\":\"max-height\",\"max-inline-size\":\"max-width\",\"margin-block-start\":\"margin-top\",\"margin-block-end\":\"margin-bottom\",\"margin-inline-start\":\"margin-left\",\"margin-inline-end\":\"margin-right\",\"padding-block-start\":\"padding-top\",\"padding-block-end\":\"padding-bottom\",\"padding-inline-start\":\"padding-left\",\"padding-inline-end\":\"padding-right\",\"inset-block-start\":\"top\",\"inset-block-end\":\"bottom\",\"inset-inline-start\":\"left\",\"inset-inline-end\":\"right\",\"border-block-start-width\":\"border-top-width\",\"border-block-start-style\":\"border-top-style\",\"border-block-start-color\":\"border-top-color\",\"border-block-end-width\":\"border-bottom-width\",\"border-block-end-style\":\"border-bottom-style\",\"border-block-end-color\":\"border-bottom-color\",\"border-inline-start-width\":\"border-left-width\",\"border-inline-start-style\":\"border-left-style\",\"border-inline-start-color\":\"border-left-color\",\"border-inline-end-width\":\"border-right-width\",\"border-inline-end-style\":\"border-right-style\",\"border-inline-end-color\":\"border-right-color\",\"border-start-start-radius\":\"border-top-left-radius\",\"border-start-end-radius\":\"border-top-right-radius\",\"border-end-start-radius\":\"border-bottom-left-radius\",\"border-end-end-radius\":\"border-bottom-right-radius\",\"overflow-block\":\"overflow-y\",\"overflow-inline\":\"overflow-x\",\"overscroll-behavior-block\":\"overscroll-behavior-y\",\"overscroll-behavior-inline\":\"overscroll-behavior-x\",\"contain-intrinsic-block-size\":\"contain-intrinsic-height\",\"contain-intrinsic-inline-size\":\"contain-intrinsic-width\"})),Cg=.001,Eg=new Set([\"inline-block\",\"inline-flex\",\"inline-grid\",\"inline-table\",\"inline-flow-root\",\"table\"]),Mg=[\"top\",\"right\",\"bottom\",\"left\"]});function _g(e=1e3){return\"function\"!=typeof requestAnimationFrame||typeof document<\"u\"&&\"hidden\"===document.visibilityState?Promise.resolve():new Promise(t=>{let n=!1,i=()=>{n||(n=!0,t())};try{requestAnimationFrame(i)}catch{return void i()}setTimeout(i,e)})}function Tg(){if(typeof navigator>\"u\")return!1;if(navigator.userAgentData)return\"iOS\"===navigator.userAgentData.platform;let e=navigator.userAgent||\"\",t=/iPhone|iPad|iPod/.test(e),n=navigator.maxTouchPoints>2&&/Macintosh/.test(e);return t||n}function Ig(){if(typeof navigator>\"u\")return!1;let e=navigator.userAgent||\"\",t=e.toLowerCase(),n=t.includes(\"safari\")&&!t.includes(\"chrome\")&&!t.includes(\"crios\")&&!t.includes(\"fxios\")&&!t.includes(\"android\"),i=/applewebkit/i.test(e),s=/mobile/i.test(e),r=!/safari/i.test(e),o=i&&s&&r,a=/(micromessenger|wxwork|wecom|windowswechat|macwechat)/i.test(e),l=/(baiduboxapp|baidubrowser|baidusearch|baiduboxlite)/i.test(t),c=/ipad|iphone|ipod/.test(t)&&i;return n||o||a||l||c}function Lg(){return!(typeof navigator>\"u\")&&(navigator.userAgent||\"\").toLowerCase().includes(\"firefox\")}var Rg,$g,Ng=ih(()=>{Rg=16,$g=40});function Pg(e,t,n){let i=e&&\"object\"==typeof e&&(e.options||e);i&&i.debug&&(void 0!==n?console.warn(\"[snapdom]\",t,n):console.warn(\"[snapdom]\",t))}function Fg(e,t,n,i){let s=e&&e.warnings;s&&s.length<Og&&s.push(void 0===i?{code:t,message:n}:{code:t,message:n,detail:i})}var Og,qg=ih(()=>{Og=50}),Hg=ih(()=>{$h(),Ag(),Ng(),wh(),qg()}),Bg={};function Dg(e){return\"string\"==typeof e&&/^data:image\\/svg\\+xml/i.test(e)}function zg(e){let t=e.indexOf(\",\");return t>=0?decodeURIComponent(e.slice(t+1)):\"\"}function Ug(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}function jg(e){let t=[],n=\"\",i=0;for(let s=0;s<e.length;s++){let r=e[s];\"(\"===r&&i++,\")\"===r&&(i=Math.max(0,i-1)),\";\"!==r||0!==i||/&(?:#\\d+|#x[\\da-f]+|[a-z]+)$/i.test(n)?n+=r:(t.push(n),n=\"\")}return n.trim()&&t.push(n),t.map(e=>e.trim()).filter(Boolean)}function Wg(e){let t=jg(e),n=null,i=null,s=null,r=[];for(let e of t){let t=e.indexOf(\":\");if(t<0)continue;let o=e.slice(0,t).trim().toLowerCase(),a=e.slice(t+1).trim();\"box-shadow\"===o?s=a:\"filter\"===o?n=a:\"-webkit-filter\"===o?i=a:r.push([o,a])}if(s){let e=function(e){let t=[],n=\"\",i=0;for(let s=0;s<e.length;s++){let r=e[s];\"(\"===r&&i++,\")\"===r&&(i=Math.max(0,i-1)),\",\"===r&&0===i?(t.push(n.trim()),n=\"\"):n+=r}n.trim()&&t.push(n.trim());let s=[];for(let e of t){if(/\\binset\\b/i.test(e))continue;let t=e.match(/-?\\d+(?:\\.\\d+)?px/gi)||[],[n=\"0px\",i=\"0px\",r=\"0px\"]=t;r=parseFloat(r)/2+\"px\";let o=e.replace(/-?\\d+(?:\\.\\d+)?px/gi,\"\").replace(/\\binset\\b/gi,\"\").trim().replace(/\\s{2,}/g,\" \"),a=!!o&&\",\"!==o;s.push(`drop-shadow(${n} ${i} ${r}${a?` ${o}`:\"\"})`)}return s.join(\" \")}(s);e&&(n=n?`${n} ${e}`:e,i=i?`${i} ${e}`:e)}let o=[...r];return n&&o.push([\"filter\",n]),i&&o.push([\"-webkit-filter\",i]),o.map(([e,t])=>`${e}:${t}`).join(\";\")}function Vg(e){return e=(e=e.replace(/<style[^>]*>([\\s\\S]*?)<\\/style>/gi,(e,t)=>e.replace(t,function(e){return e.replace(/([^{}]+)\\{([^}]*)\\}/g,(e,t,n)=>`${t}{${Wg(n)}}`)}(t)))).replace(/style=(['\"])([\\s\\S]*?)\\1/gi,(e,t,n)=>`style=${t}${Wg(n)}${t}`)}function Gg(e,t){let n=e=>jg(e).map(e=>{let n=e.indexOf(\":\");if(n<0)return e;let i=e.slice(0,n).trim().toLowerCase();return\"text-shadow\"===i||t&&\"box-shadow\"===i?`${i}:${function(e){let t=[],n=0,i=0;for(let s=0;s<e.length;s++){let r=e[s];\"(\"===r?n++:\")\"===r?n=Math.max(0,n-1):\",\"===r&&0===n&&(t.push(e.slice(i,s)),i=s+1)}return t.push(e.slice(i)),t.map(e=>{let t=0,n=0,i=\"\",s=0;for(;s<e.length;){let r=e[s];if(\"(\"===r?t++:\")\"===r&&(t=Math.max(0,t-1)),0===t&&(0===s||\" \"===e[s-1])){let t=/^-?\\d*\\.?\\d+px/.exec(e.slice(s));if(t){n++,i+=2===n?-parseFloat(t[0])+\"px\":t[0],s+=t[0].length;continue}}i+=r,s++}return i}).join(\",\")}(e.slice(n+1))}`:e}).join(\";\");return e=e.replace(/<style[^>]*>([\\s\\S]*?)<\\/style>/gi,(e,t)=>e.replace(t,t.replace(/([^{}]+)\\{([^}]*)\\}/g,(e,t,i)=>`${t}{${n(i)}}`))),e=e.replace(/style=(['\"])([\\s\\S]*?)\\1/gi,(e,t,i)=>`style=${t}${n(i)}${t}`),e}async function Kg(e){if(!/(?:box-shadow|text-shadow)\\s*:[^;\"}]*px/i.test(e))return{svg:e,naturalOnly:!1};let{native:t,flippedY:n}=await(nm||(nm=(async()=>{try{let e='<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"8\" height=\"20\"><foreignObject width=\"8\" height=\"20\"><div xmlns=\"http://www.w3.org/1999/xhtml\" style=\"width:4px;height:4px;margin-top:8px;background:#000;box-shadow:0 8px 0 0 #000\"></div></foreignObject></svg>',t=new Image;t.decoding=\"sync\",t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`,await t.decode();let n=document.createElement(\"canvas\");n.width=8,n.height=20;let i=n.getContext(\"2d\",{willReadFrequently:!0});i.drawImage(t,0,0);let s=i.getImageData(2,18,1,1).data[3]>128,r=i.getImageData(2,2,1,1).data[3]>128;return{native:s||r,flippedY:r&&!s}}catch{return{native:!1,flippedY:!1}}})(),nm));try{let i=e;return t||(i=Vg(i)),n&&(i=Gg(i,t)),{svg:i,naturalOnly:!0}}catch{return{svg:e,naturalOnly:!0}}}function Yg(e){if(typeof document>\"u\"||!document.body)return new Image;if(rm&&!rm.contentDocument){try{rm.remove()}catch{}rm=null}if(rm&&om>sm&&0===am){try{rm.remove()}catch{}rm=null}if(!rm){let e=document.createElement(\"iframe\");Zh(e),e.setAttribute(\"aria-hidden\",\"true\"),e.style.cssText=\"position:absolute;left:-9999px;top:0;width:0;height:0;border:0;visibility:hidden;pointer-events:none\";try{document.body.appendChild(e)}catch{}if(!e.contentDocument){try{e.remove()}catch{}return new Image}rm=e,om=0}om+=e.length,am+=1;let t=rm.contentDocument.createElement(\"img\");return t.__snapdomDecodeFrame=!0,t}function Xg(e){!e||!e.__snapdomDecodeFrame||(e.__snapdomDecodeFrame=!1,am=Math.max(0,am-1))}function Jg(e,t){return e.loading=\"eager\",e.decoding=\"sync\",e.crossOrigin=\"anonymous\",e.src=t,e.decode()}function Qg(e,t,n,i,s){if(!t.naturalWidth)return void e.drawImage(t,0,0,n,i);let r=n*i,o=r>lm&&!function(e){if(\"string\"!=typeof e)return!1;let t=e.indexOf(\",\")+1,n=Math.max(48,Math.floor((e.length-t)/200)),i=0,s=0;for(let r=t;r+48<=e.length;r+=n){let t=e.slice(r,r+48);i++,um.some(e=>t.includes(e))||s++}return 2*s>i}(s)?Math.min(dm,Math.ceil(r/cm)):1;if(1===o)return void e.drawImage(t,0,0,n,i);let a=t.naturalWidth,l=t.naturalHeight/i;for(let s=0;s<o;s++){let r=Math.round(s*i/o),c=s===o-1?i:Math.round((s+1)*i/o);e.drawImage(t,0,r*l,a,(c-r)*l,0,r,n,c-r)}}async function Zg(e,t){let{width:n,height:i,scale:s=1,dpr:r=1,meta:o={},backgroundColor:a,crop:l=null}=t,c=typeof HTMLCanvasElement<\"u\"&&e instanceof HTMLCanvasElement?e:null,d=e,u=!1,p=!1;if(l&&!Dg(e))throw new RangeError(\"[snapdom] canvas crop requires an SVG capture payload\");if(Dg(e)){let n=(function(e){let t=e.indexOf(\",\");if(t<0)return\"\";let n=e.slice(t+1,t+1201).replace(/%[0-9A-Fa-f]?$/,\"\");try{return decodeURIComponent(n)}catch{return\"\"}}(e).match(/<svg\\b[^>]*>/i)||[])[0]||\"\",i=parseFloat((n.match(/\\bwidth=\"([\\d.]+)/i)||[])[1]),s=parseFloat((n.match(/\\bheight=\"([\\d.]+)/i)||[])[1]),r=Number.isFinite(i)&&Number.isFinite(s)&&i>0&&s>0&&Math.min(1,em/i,em/s,Math.sqrt(tm/(i*s)))<1;if(l||r||Ig())try{let n=zg(e);if(l&&(n=function(e,t){let n=[\"x\",\"y\",\"width\",\"height\"].map(e=>Number(t?.[e]));if(!n.every(Number.isFinite)||n[2]<=0||n[3]<=0)throw new RangeError(\"[snapdom] canvas crop requires finite x/y and positive width/height\");let i=e.match(/<svg\\b[^>]*>/i);if(!i)throw new Error(\"[snapdom] cannot crop a non-SVG capture\");let s=i[0],r=(s.match(/\\bviewBox=\"([^\"]+)\"/i)||[])[1],o=String(r||\"\").trim().split(/[\\s,]+/).map(Number);if(4!==o.length||!o.every(Number.isFinite)||o[2]<=0||o[3]<=0)throw new Error(\"[snapdom] cannot crop an SVG without a finite viewBox\");let[a,l,c,d]=o,u=Math.max(a,n[0]),p=Math.max(l,n[1]),h=Math.min(a+c,n[0]+n[2]),g=Math.min(l+d,n[1]+n[3]);if(!(h>u&&g>p))throw new RangeError(\"[snapdom] canvas crop does not intersect the SVG viewBox\");let m=parseFloat((s.match(/\\bwidth=\"([\\d.]+)/i)||[])[1]),f=parseFloat((s.match(/\\bheight=\"([\\d.]+)/i)||[])[1]),b=Number.isFinite(m)&&m>0?m/c:1,y=Number.isFinite(f)&&f>0?f/d:1,v=Math.max(1,(h-u)*b),w=Math.max(1,(g-p)*y),x=s.replace(/(\\bwidth=\")[^\"]*/i,`$1${v}`).replace(/(\\bheight=\")[^\"]*/i,`$1${w}`).replace(/(\\bviewBox=\")[^\"]*/i,`$1${u} ${p} ${h-u} ${g-p}`);return e.replace(s,x)}(n,l)),Ig()){let e=await Kg(n);n=e.svg,u=e.naturalOnly,p=/@font-face|data:image\\//i.test(n)}(r||l)&&(n=function(e,t){try{let n=e.match(/<svg\\b[^>]*>/i);if(!n)return e;let i=n[0],s=parseFloat((i.match(/\\bwidth=\"([\\d.]+)/i)||[])[1]),r=parseFloat((i.match(/\\bheight=\"([\\d.]+)/i)||[])[1]);if(!Number.isFinite(s)||!Number.isFinite(r)||s<=0||r<=0)return e;let o=Math.min(1,em/s,em/r,Math.sqrt(tm/(s*r)));if(o>=1)return e;let a=Math.max(1,Math.floor(s*o)),l=Math.max(1,Math.floor(r*o));return Fg(t,\"raster-clamp\",`capture ${Math.round(s)}x${Math.round(r)}px exceeds decode limits; downscaled to ${a}x${l}px`),console.warn(`[snapDOM] Capture ${Math.round(s)}×${Math.round(r)}px exceeds the browser image-decode limit (${em}px/side); downscaling to ${a}×${l}px. Lower \\`scale\\` or set \\`width\\`/\\`height\\` to control output size.`),e.replace(i,i.replace(/(\\bwidth=\")[\\d.]+/i,`$1${a}`).replace(/(\\bheight=\")[\\d.]+/i,`$1${l}`))}catch{return e}}(n,t.__session)),d=Ug(n)}catch(t){if(l)throw t;d=e}}let h=c||Yg(d);try{c||await Jg(h,d)}catch(e){if(!h.__snapdomDecodeFrame)throw e;Xg(h),h=Yg(d);try{await Jg(h,d)}catch(e){throw Xg(h),e}}try{!c&&!Ig()&&!Lg()&&Dg(d)&&/(?:%40|@)font-face/i.test(d)&&await new Promise(e=>{let t=new MessageChannel;t.port1.onmessage=()=>{t.port1.close(),t.port2.close(),e()},t.port2.postMessage(0)});let e=Ig()&&!c?function(){let e=document.createElement(\"canvas\");e.width=16,e.height=16;let t=e.getContext(\"2d\",{willReadFrequently:!0});return t?e=>{t.clearRect(0,0,16,16),t.drawImage(e,0,0,16,16);let n=t.getImageData(0,0,16,16).data;for(let e=3;e<n.length;e+=4)if(n[e]>0)return!0;return!1}:null}():null,g=!1;e&&(g=await async function(e,t,n){Zh(e),e.style.cssText=\"position:fixed;left:-99999px;top:-99999px;pointer-events:none\",document.body.appendChild(e);try{if(!n)return await im(),await im(),!1;let i=performance.now()+(t?600:150);for(;;){let t;try{t=n(e)}catch{return!1}if(t)return!0;if(performance.now()>i)return!1;await im()}}finally{try{e.remove()}catch{}}}(h,p,e));let m,f,b=c?c.width:h.naturalWidth,y=c?c.height:h.naturalHeight,v=l?b:Number.isFinite(o.vbW)?o.vbW:Number.isFinite(o.w0)?o.w0:b,w=l?y:Number.isFinite(o.vbH)?o.vbH:Number.isFinite(o.h0)?o.h0:y,x=Number.isFinite(n),k=Number.isFinite(i);if(x&&k)m=Math.max(1,n),f=Math.max(1,i);else if(x){let e=n/Math.max(1,v);m=n,f=w*e}else if(k){let e=i/Math.max(1,w);f=i,m=v*e}else{let e=c&&Number.isFinite(o.vbW)&&Number.isFinite(o.vbH);m=e?o.vbW:b,f=e?o.vbH:y}!x&&!k&&(m*=s,f*=s);let S=m*r,C=f*r,E=Math.max(S/em,C/em,Math.sqrt(S*C/tm));E>1&&(Fg(t.__session,\"canvas-clamp\",`output ${Math.round(S)}x${Math.round(C)}px exceeds canvas limits; downscaled`),console.warn(`[snapDOM] Output ${Math.round(S)}×${Math.round(C)}px exceeds the browser canvas limit (${em}px/side); downscaling. Lower \\`scale\\`/\\`dpr\\` or set \\`width\\`/\\`height\\`.`),m/=E,f/=E);let M=hh(t.canvas)&&ph(t.canvas,\"canvas\")?t.canvas:document.createElement(\"canvas\");M.width=Math.max(1,m*r),M.height=Math.max(1,f*r),M.style.width=`${m}px`,M.style.height=`${f}px`;let A=M.getContext(\"2d\");if(!A)throw new Error(\"[snapdom] toCanvas: the target canvas has no 2d context\");let _=()=>{if(1!==r&&A.scale(r,r),a&&(A.save(),A.fillStyle=a,A.fillRect(0,0,m,f),A.restore()),!u||Math.round(m*r)===b&&Math.round(f*r)===y)A.save(),A.setTransform(1,0,0,1,0,0),Qg(A,h,m*r,f*r,d),A.restore();else{let e=document.createElement(\"canvas\");e.width=b,e.height=y,Qg(e.getContext(\"2d\"),h,b,y,d),A.drawImage(e,0,0,m,f)}};if(_(),e&&g&&p){let t=!0;try{t=e(h)}catch{}if(!t){let n=performance.now()+600;do{await im();try{t=e(h)}catch{break}}while(!t&&performance.now()<n);M.width=M.width,_()}}return M}finally{Xg(h)}}sh(Bg,{decodeSvgFromDataURL:()=>zg,encodeSvgToDataURL:()=>Ug,fixSafariShadows:()=>Kg,toCanvas:()=>Zg});var em,tm,nm,im,sm,rm,om,am,lm,cm,dm,um,pm=ih(()=>{Ng(),qg(),wh(),ng(),em=Ig()?16384:32767,tm=268435456,nm=null,im=()=>new Promise(e=>{requestAnimationFrame(e),setTimeout(e,50)}),sm=25165824,rm=null,om=0,am=0,lm=4e6,cm=2e6,dm=8,um=[\"%3C\",\"%3E\",\"%20\",\"%7B\",\"%7D\",\"%3B\"]}),hm={};async function gm(e,t){let n=await Zg(e,t),i=n.width*n.height<=2e6?n.toDataURL(`image/${t.format}`,t.quality):await new Promise(e=>{let i=()=>e(n.toDataURL(`image/${t.format}`,t.quality));try{n.toBlob(t=>{if(!t)return i();let n=new FileReader;n.onload=()=>e(String(n.result||\"\")),n.onerror=i,n.readAsDataURL(t)},`image/${t.format}`,t.quality)}catch{i()}}),s=new Image;return s.src=i,Ig()?await s.decode():await new Promise((e,t)=>{if(s.complete&&s.naturalWidth)return e();s.onload=e,s.onerror=t}),s.style.width=n.width/t.dpr+\"px\",s.style.height=n.height/t.dpr+\"px\",s}sh(hm,{rasterize:()=>gm});var mm=ih(()=>{pm(),Ng()}),fm={};async function bm(e,t){let{scale:n=1,width:i,height:s,meta:r={}}=t,o=Number.isFinite(i),a=Number.isFinite(s),l=Number.isFinite(n)&&1!==n||o||a;if(Ig()&&l)try{let{svg:t}=await Kg(zg(e)),l=(t.match(/<svg\\b[^>]*>/i)||[])[0]||\"\",c=parseFloat((l.match(/\\bwidth=\"([\\d.]+)/i)||[])[1]),d=parseFloat((l.match(/\\bheight=\"([\\d.]+)/i)||[])[1]);if(!Number.isFinite(c)||!Number.isFinite(d))throw new Error(\"svg without dimensions\");let u,p,h=Number.isFinite(r.vbW)?r.vbW:Number.isFinite(r.w0)?r.w0:c,g=Number.isFinite(r.vbH)?r.vbH:Number.isFinite(r.h0)?r.h0:d;o&&a?(u=i,p=s):o?(u=i,p=Math.max(1,Math.round(g*(i/Math.max(1,h))))):a?(p=s,u=Math.max(1,Math.round(h*(s/Math.max(1,g))))):(u=Math.max(1,Math.round(c*n)),p=Math.max(1,Math.round(d*n)));let m=t.replace(/width=\"[^\"]*\"/,`width=\"${u}\"`).replace(/height=\"[^\"]*\"/,`height=\"${p}\"`),f=new Image;return f.decoding=\"sync\",f.loading=\"eager\",f.src=Ug(m),await f.decode(),f.style.width=`${u}px`,f.style.height=`${p}px`,f}catch(n){return Fg(t.__session,\"safari-png-fallback\",\"safari vector toImg failed, falling back to PNG raster\",n),Pg(t,\"safari vector toImg failed, falling back to PNG\",n),gm(e,{...t,format:\"png\",quality:1,meta:r})}let c=e,d=!1;if(!o&&!a&&1!==n&&\"string\"==typeof e&&e.startsWith(\"data:image/svg+xml\"))try{let t=zg(e),i=(t.match(/<svg\\b[^>]*>/i)||[])[0]||\"\",s=Number((i.match(/\\bwidth=\"([\\d.]+)\"/i)||[])[1]),r=Number((i.match(/\\bheight=\"([\\d.]+)\"/i)||[])[1]);if(s>0&&r>0){let e=i.replace(/\\bwidth=\"[^\"]*\"/i,`width=\"${Math.max(1,Math.round(s*n))}\"`).replace(/\\bheight=\"[^\"]*\"/i,`height=\"${Math.max(1,Math.round(r*n))}\"`);c=Ug(t.replace(i,e)),d=!0}}catch{}let u=new Image;u.decoding=\"sync\",u.loading=\"eager\",u.src=c;try{await u.decode()}catch(t){if(!d)throw t;u.src=e,d=!1,await u.decode()}if(o&&a)u.style.width=`${i}px`,u.style.height=`${s}px`;else if(o){let e=Number.isFinite(r.vbW)?r.vbW:Number.isFinite(r.w0)?r.w0:u.naturalWidth,t=Number.isFinite(r.vbH)?r.vbH:Number.isFinite(r.h0)?r.h0:u.naturalHeight,n=i/Math.max(1,e);u.style.width=`${i}px`,u.style.height=`${Math.max(1,Math.round(t*n))}px`}else if(a){let e=Number.isFinite(r.vbW)?r.vbW:Number.isFinite(r.w0)?r.w0:u.naturalWidth,t=Number.isFinite(r.vbH)?r.vbH:Number.isFinite(r.h0)?r.h0:u.naturalHeight,n=s/Math.max(1,t);u.style.height=`${s}px`,u.style.width=`${Math.max(1,Math.round(e*n))}px`}else{let i=Math.max(1,Math.round(u.naturalWidth*(d?1:n))),s=Math.max(1,Math.round(u.naturalHeight*(d?1:n)));if(u.style.width=`${i}px`,u.style.height=`${s}px`,!d&&1!==n&&\"string\"==typeof e&&e.startsWith(\"data:image/svg+xml\"))try{let t=decodeURIComponent(e.split(\",\")[1]).replace(/width=\"[^\"]*\"/,`width=\"${i}\"`).replace(/height=\"[^\"]*\"/,`height=\"${s}\"`);u.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`,await u.decode()}catch(n){Pg(t,\"SVG width/height patch in toImg failed\",n),u.src!==e&&(u.src=e,await u.decode().catch(()=>{}))}}return u}sh(fm,{toImg:()=>bm,toSvg:()=>bm});var ym=ih(()=>{Hg(),qg(),mm(),pm()}),vm={};async function wm(e,t){let n=t.format||t.type||\"svg\";if(\"svg\"===n){if(typeof HTMLCanvasElement<\"u\"&&e instanceof HTMLCanvasElement)throw new Error(\"[snapdom] toBlob: engine:'html-in-canvas' produces a raster capture; ask for png/jpeg/webp\");let t=decodeURIComponent(e.split(\",\")[1]);return new Blob([t],{type:\"image/svg+xml\"})}let i=await Zg(e,t);return new Promise(e=>i.toBlob(t=>e(t),`image/${\"jpg\"===n?\"jpeg\":n}`,t.quality))}sh(vm,{toBlob:()=>wm});var xm=ih(()=>{pm()}),km={};async function Sm(e,t){let n=new File([e],t,{type:e.type});if(!navigator.canShare?.({files:[n]}))return!1;try{await navigator.share({files:[n],title:t})}catch(e){if(\"AbortError\"!==e.name)return!1}return!0}async function Cm(e,t){let n=new Set([\"png\",\"jpeg\",\"jpg\",\"webp\",\"svg\"]),i=(t?.type||\"\").toLowerCase(),s=n.has(i)?i:\"\",r=(t?.format||s||\"\").toLowerCase(),o=\"jpg\"===r?\"jpeg\":r||\"png\",a=t?.filename||\"snapdom\",l=/\\.(png|jpe?g|webp|svg)$/i.test(a)?a:`${a}.${o}`,c={...t||{},format:o,type:o};c.dpr=1;let d=Tg();if(\"svg\"===o){let t=await wm(e,{...c,type:\"svg\"});if(d&&await Sm(t,l))return;let n=URL.createObjectURL(t),i=document.createElement(\"a\");return i.href=n,i.download=l,document.body.appendChild(i),i.click(),URL.revokeObjectURL(n),void i.remove()}let u=await Zg(e,c);if(d){let e=`image/${o}`,n=await new Promise(n=>u.toBlob(n,e,t?.quality));if(n&&await Sm(n,l))return}let p=document.createElement(\"a\");p.href=u.toDataURL(`image/${o}`,t?.quality),p.download=l,document.body.appendChild(p),p.click(),p.remove()}sh(km,{download:()=>Cm});var Em=ih(()=>{xm(),pm(),Ng()});Hg(),Hg(),Ng(),ah(),Qh(),ng();var Mm=new WeakMap,Am=[\"margin-top\",\"margin-right\",\"margin-bottom\",\"margin-left\",\"margin-block-start\",\"margin-block-end\",\"margin-inline-start\",\"margin-inline-end\"],_m=new Map,Tm=0;function Im(){Tm++}function Lm(e){let t=e&&(1===e.nodeType?e:e.parentElement);for(;t;){if(eg(t))return!0;if(t.parentElement)t=t.parentElement;else{let e=t.getRootNode?.();t=e&&e.host?e.host:null}}return!1}function Rm(e){for(let t of e)if($m(t))return!0;return!1}function $m(e){if(Lm(e.target))return!1;if(\"childList\"===e.type){let t=!0;for(let n of e.addedNodes)if(!Lm(n)){t=!1;break}if(t)for(let n of e.removedNodes)if(!Lm(n)){t=!1;break}if(t)return!1}return!0}var Nm=new WeakMap;function Pm(e){for(let t of e){if(!$m(t))continue;let e=t.target.ownerDocument||document;Nm.set(e,(Nm.get(e)||0)+1);let n=1===t.target.nodeType?t.target:t.target.parentElement||t.target.host;for(;n;n=n.parentElement||n.getRootNode?.()?.host)Nm.set(n,(Nm.get(n)||0)+1)}}function Fm(e){let t=e.ownerDocument||document;return af(t),(Nm.get(t)||0)-(Nm.get(e)||0)}var Om=0;function qm(e=document){return af(e),Om}function Hm(){return af(),Tm}function Bm(e){return e?(af(e.ownerDocument||document),Km(e,Ym(e))):0}function Dm(){Im(),Om++}var zm=new WeakMap,Um=0,jm=0;function Wm(e){zm.set(e,++Um)}function Vm(e){if(!e||1!==e.nodeType)return;Um++,zm.set(e,Um);let t=e.querySelectorAll(\"*\");for(let e=0;e<t.length;e++)zm.set(t[e],Um)}function Gm(e){Vm(e.parentElement||e);for(let t=e.parentElement;t;t=t.parentElement)Wm(t)}function Km(e,t=null){let n=zm.get(e)||0;if(t)for(let e of t)n=Math.max(n,zm.get(e)||0);return 1e9*jm+n}function Ym(e){let t=e.getRootNode?.();if(!t?.host)return null;let n=[];for(;t?.host;)\"open\"===t.mode&&tf(t),n.push(t.host),t=t.host.getRootNode?.();return n}var Xm=new WeakMap;function Jm(e){e=e||document;let t=Xm.get(e);if(!t||t.env!==Om){let n=!0;try{n=ff(e).usesHas}catch{}t={env:Om,usesHas:n},Xm.set(e,t)}return!t.usesHas}var Qm=new WeakSet,Zm=[];function ef(e){if(!Rm(e))return;Pm(e),Im();let t=new Set;for(let n of e){if(!$m(n))continue;let e=n.target.getRootNode&&n.target.getRootNode();if(!e||11!==e.nodeType||t.has(e))continue;t.add(e),e.host?Vm(e.host):Um++;let i=e.querySelectorAll(\"*\");for(let e=0;e<i.length;e++)zm.set(i[e],Um)}}function tf(e){if(e&&!Qm.has(e)){Qm.add(e);try{let t=new MutationObserver(ef);t.observe(e,{subtree:!0,childList:!0,characterData:!0,attributes:!0}),Zm.push({o:t,root:e})}catch{}}}function nf(e){if(!Rm(e))return;Pm(e),Im();let t=function(e){let t=e=>1===e?.nodeType&&(e.matches?.(\"style,link\")||e.querySelector?.(\"style,link\"));for(let n of e){let e=n.target,i=e&&(1===e.nodeType?e:e.parentElement);if(i&&(\"STYLE\"===i.tagName||\"LINK\"===i.tagName))return i.ownerDocument||document;for(let e of n.addedNodes)if(t(e))return e.ownerDocument||document;for(let i of n.removedNodes)if(t(i))return i.ownerDocument||e&&e.ownerDocument||document}return null}(e);if(t)return Xm.delete(t),Om++,void jm++;let n=new Set;for(let t of e){if(!$m(t))continue;let e=1===t.target.nodeType?t.target:t.target.parentElement;if(!e)continue;let i=e.ownerDocument||document;if(!Jm(i))return void jm++;if(e===i.documentElement||e===i.body)return void jm++;let s=e.parentElement||e;n.has(s)||(n.add(s),Gm(e))}}var sf=new WeakSet,rf=null,of=[];function af(e=document){if(e===rf||!e||9!==e.nodeType)return;if(sf.has(e))return void(rf=e);sf.add(e),rf=e;let t=e.defaultView,n=e=>{Rm(e)&&(Im(),Om++)},i=()=>{Im(),Om++};try{let t=new MutationObserver(nf);t.observe(e.documentElement,{subtree:!0,childList:!0,characterData:!0,attributes:!0}),of.push({o:t,env:!1,doc:e})}catch{}try{let t=new MutationObserver(n);t.observe(e.head,{subtree:!0,childList:!0,characterData:!0,attributes:!0}),of.push({o:t,env:!0,doc:e})}catch{}try{t?.addEventListener(\"resize\",i,{passive:!0})}catch{}try{let n=t=>{Im();let n=t.composedPath?.()[0]||t.target;n&&1===n.nodeType&&!Lm(n)&&Jm(n.ownerDocument||e)?Gm(n):jm++};e.addEventListener(\"focusin\",n,{capture:!0,passive:!0}),e.addEventListener(\"focusout\",n,{capture:!0,passive:!0}),e.addEventListener(\"change\",n,{capture:!0,passive:!0}),e.addEventListener(\"pointerdown\",n,{capture:!0,passive:!0}),e.addEventListener(\"pointerup\",n,{capture:!0,passive:!0}),e.addEventListener(\"pointercancel\",n,{capture:!0,passive:!0}),e.addEventListener(\"keydown\",n,{capture:!0,passive:!0}),e.addEventListener(\"keyup\",n,{capture:!0,passive:!0}),e.addEventListener(\"beforetoggle\",n,{capture:!0,passive:!0}),e.addEventListener(\"toggle\",n,{capture:!0,passive:!0}),t?.addEventListener(\"hashchange\",()=>{Im(),jm++},{passive:!0})}catch{}try{let t=e.fonts;t&&(t.addEventListener?.(\"loadingdone\",i),\"loading\"===t.status&&t.ready?.then(i).catch(()=>{}))}catch{}}var lf=new WeakMap;function cf(e,t){if(!e?.querySelectorAll)return;let n;try{n=Array.from(e.querySelectorAll(\":hover\"))}catch{return}let i=lf.get(e)||[];if(i.length===n.length&&i.every((e,t)=>e===n[t]))return;if(lf.set(e,n),Im(),11===e.nodeType){e.host?Vm(e.host):Um++;for(let t of e.querySelectorAll(\"*\"))zm.set(t,Um);return}let s=i.filter(e=>!n.includes(e)).concat(n.filter(e=>!i.includes(e)));for(let e of s)if(e.isConnected){if(!Jm(t))return void jm++;Gm(e)}}function df(e,t=null){if(!e)return;cf(e,e);let n=t||Zm.filter(({root:e})=>e.host?.isConnected).map(({root:e})=>e);for(let t of n)cf(t,e)}function uf(){af();try{for(let e=of.length-1;e>=0;e--){let{o:t,env:n,doc:i}=of[e];if(i!==document&&!i.defaultView){try{t.disconnect()}catch{}sf.delete(i),rf===i&&(rf=null),of.splice(e,1);continue}let s=t.takeRecords();s.length&&(n?Rm(s)&&(Im(),Om++):nf(s))}for(let e=Zm.length-1;e>=0;e--){let{o:t,root:n}=Zm[e];if(!n.host||!n.host.isConnected){try{t.disconnect()}catch{}Qm.delete(n),Zm.splice(e,1);continue}let i=t.takeRecords();i.length&&ef(i)}}catch{}}function pf(e){if(e&&1===e.nodeType){Mm.delete(e);try{let t=(e.ownerDocument||document).createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(;t.nextNode();)Mm.delete(t.currentNode)}catch{}}}var hf=[\"mask\",\"mask-image\",\"-webkit-mask\",\"-webkit-mask-image\",\"mask-source\",\"mask-box-image-source\",\"mask-border-source\",\"-webkit-mask-box-image-source\",\"border-image\",\"border-image-source\"];function gf(e){let t=Mm.get(e);if(t&&_f(t,e)){let e=t.snapshot&&t.snapshot.__needsBgInline;if(void 0!==e)return e}return!0}var mf=new WeakMap;function ff(e){let t=mf.get(e);if(!t||t.epoch!==Tm){let n=t&&t.universe;t={epoch:Tm,...Uh(e)};let i=t.universe;if(n&&i&&n.size===i.size){let e=!0;for(let t of i)if(!n.has(t)){e=!1;break}e&&(t.universe=n)}mf.set(e,t)}return t}function bf(e,t){let n=e.ownerDocument||document,i=e.getRootNode?e.getRootNode():n;return i===n?ff(n).universe:t&&mh(i)?function(e,t,n,i){let s=i.__shadowUniverse;if(null===s)return null;if(!s){let e=ff(n).universe;if(!e)return i.__shadowUniverse=null;s=i.__shadowUniverse={universe:new Set(e),roots:new Set}}let r=e=>{for(;mh(e)&&!s.roots.has(e);e=e.host.getRootNode()){s.roots.add(e);for(let t of[...e.styleSheets,...e.adoptedStyleSheets||[]]){let e=yf.get(t);if((!e||e.epoch!==Tm)&&yf.set(t,e={epoch:Tm,props:qh(t)}),!e.props)return!1;for(let t of e.props)s.universe.add(t)}Oh(e.getAnimations(),s.universe)}return!0},o=r(t)&&(!e.shadowRoot||r(e.shadowRoot));for(let t=e.assignedSlot;o&&t;t=t.assignedSlot)o=r(t.getRootNode());return o?s.universe:i.__shadowUniverse=null}(e,i,n,t):null}var yf=new WeakMap;function vf(e){let t=e.ownerDocument||document;return e.getRootNode&&e.getRootNode()!==t?null:ff(t).pseudoUniverse}var wf={before:null,after:null,firstLetter:null,marker:null,firstLine:null};function xf(e){let t=e.ownerDocument||document;return e.getRootNode&&e.getRootNode()!==t?wf:ff(t).pseudoGates}function kf(e,t={},n=null,i=null){let s={},r=t.excludeStyleProps,o=t=>{if(void 0!==s[t]||sg(t)||r&&(r instanceof RegExp&&r.test(t)||\"function\"==typeof r&&r(t)))return;let n=e.getPropertyValue(t);n&&((\"background-image\"===t||\"content\"===t)&&n.includes(\"url(\")&&!n.includes(\"data:\")&&(n=\"none\"),s[t]=n)};if(i){for(let e of i)o(e);let e=n&&n.style;if(e&&e.length)for(let t=0;t<e.length;t++)o(e[t])}else for(let t=0;t<e.length;t++)o(e[t]);let a=[\"text-decoration-line\",\"text-decoration-color\",\"text-decoration-style\",\"text-decoration-thickness\",\"text-underline-offset\",\"text-decoration-skip-ink\"];for(let t of a)if(!s[t])try{let n=e.getPropertyValue(t);n&&(s[t]=n)}catch{}let l=[\"-webkit-text-stroke\",\"-webkit-text-stroke-width\",\"-webkit-text-stroke-color\",\"paint-order\"];for(let t of l)if(!s[t])try{let n=e.getPropertyValue(t);n&&(s[t]=n)}catch{}if(t.embedFonts){let t=[\"font-feature-settings\",\"font-variation-settings\",\"font-kerning\",\"font-variant\",\"font-variant-ligatures\",\"font-optical-sizing\"];for(let n of t)if(!s[n])try{let t=e.getPropertyValue(n);t&&(s[n]=t)}catch{}}try{\"hidden\"===(s[\"content-visibility\"]||e.getPropertyValue(\"content-visibility\"))&&(s[\"content-visibility\"]=\"hidden\")}catch{}Object.defineProperty(s,\"__needsBgInline\",{value:Sf(e),enumerable:!1});let c=parseFloat(e.getPropertyValue(\"border-top-width\")||0)||0,d=parseFloat(e.getPropertyValue(\"border-right-width\")||0)||0,u=parseFloat(e.getPropertyValue(\"border-bottom-width\")||0)||0,p=parseFloat(e.getPropertyValue(\"border-left-width\")||0)||0;if(0===c&&0===d&&0===u&&0===p){let t=(e.getPropertyValue(\"border-image-source\")||\"\").trim(),n=t&&\"none\"!==t,i=[\"border\",\"border-top\",\"border-right\",\"border-bottom\",\"border-left\",\"border-width\",\"border-style\",\"border-color\",\"border-top-width\",\"border-top-style\",\"border-top-color\",\"border-right-width\",\"border-right-style\",\"border-right-color\",\"border-bottom-width\",\"border-bottom-style\",\"border-bottom-color\",\"border-left-width\",\"border-left-style\",\"border-left-color\",\"border-block\",\"border-block-width\",\"border-block-style\",\"border-block-color\",\"border-inline\",\"border-inline-width\",\"border-inline-style\",\"border-inline-color\",\"border-block-start\",\"border-block-start-width\",\"border-block-start-style\",\"border-block-start-color\",\"border-block-end\",\"border-block-end-width\",\"border-block-end-style\",\"border-block-end-color\",\"border-inline-start\",\"border-inline-start-width\",\"border-inline-start-style\",\"border-inline-start-color\",\"border-inline-end\",\"border-inline-end-width\",\"border-inline-end-style\",\"border-inline-end-color\"];for(let e of i)delete s[e];n||(s.border=\"none\")}return function(e){if(!Lg())return;let t=e[\"background-clip\"]||e[\"-webkit-background-clip\"];if(!t||!t.includes(\"text\"))return;let n=e=>\"transparent\"===e||\"rgba(0, 0, 0, 0)\"===e,i=e[\"-webkit-text-fill-color\"];if(!n(void 0!==i?i:e.color))return;let s=function(e,t){let n=e=>{let t,n=[],i=/rgba?\\(\\s*(\\d+)[,\\s]+(\\d+)[,\\s]+(\\d+)(?:[,\\s/]+([\\d.]+%?))?\\s*\\)/g;for(;t=i.exec(e||\"\");){let e=t[4];(void 0===e?1:parseFloat(e)/(e.endsWith(\"%\")?100:1))>.05&&n.push([+t[1],+t[2],+t[3]])}return n},i=n(e);if(i.length||(i=n(t)),!i.length)return null;let s=[0,0,0];for(let[e,t,n]of i)s[0]+=e,s[1]+=t,s[2]+=n;return`rgb(${s.map(e=>Math.round(e/i.length)).join(\", \")})`}(e[\"background-image\"],e[\"background-color\"]);s&&(n(e.color)&&(e.color=s),void 0!==i&&(e[\"-webkit-text-fill-color\"]=s),e[\"background-image\"]=\"none\",e[\"background-color\"]=\"transparent\",delete e[\"background-clip\"],delete e[\"-webkit-background-clip\"],Object.defineProperty(e,\"__bgClipTextFix\",{value:s,enumerable:!1}))}(s),s}function Sf(e){let t=e.getPropertyValue(\"background-image\");if(t&&\"none\"!==t)return!0;let n=e.getPropertyValue(\"background-color\");if(n&&\"rgba(0, 0, 0, 0)\"!==n&&\"transparent\"!==n)return!0;for(let t of hf){let n=e.getPropertyValue(t);if(n&&\"none\"!==n)return!0}let i=e.getPropertyValue(\"background\");return!(!i||!/url\\s*\\(/i.test(i))}function Cf(e,t,n){try{if(\"function\"==typeof e.computedStyleMap){let t=e.computedStyleMap().get(\"width\");if(null!=t)return!Mf(String(t).trim().toLowerCase())}}catch{}let i=e.style&&(e.style.width||e.style.inlineSize);return!(!i||Mf(String(i).trim().toLowerCase()))||!!function(e,t){let n=e.getBoundingClientRect().width-(parseFloat(t.paddingLeft)||0)-(parseFloat(t.paddingRight)||0)-(parseFloat(t.borderLeftWidth)||0)-(parseFloat(t.borderRightWidth)||0);if(!(n>0))return!1;let i=1/0,s=-1/0,r=null;for(let t=e.firstChild;t;t=t.nextSibling){let e;if(3===t.nodeType){if(!/\\S/.test(t.nodeValue||\"\")||(r=r||document.createRange(),r.selectNode(t),e=r.getBoundingClientRect(),!e.width&&!e.height))continue}else{if(1!==t.nodeType)continue;{let n=cg(t);if(\"none\"===n.display||\"absolute\"===n.position||\"fixed\"===n.position)continue;e=t.getBoundingClientRect()}}e.left<i&&(i=e.left),e.right>s&&(s=e.right)}return s!==-1/0&&s-i<n-.5}(e,t)&&(n||function(e,t){let n=e.parentElement;if(!n)return!1;let i=cg(n),s=n.getBoundingClientRect().width-(parseFloat(i.paddingLeft)||0)-(parseFloat(i.paddingRight)||0)-(parseFloat(i.borderLeftWidth)||0)-(parseFloat(i.borderRightWidth)||0)-(parseFloat(t.marginLeft)||0)-(parseFloat(t.marginRight)||0);return s>0&&Math.abs(e.getBoundingClientRect().width-s)>.5}(e,t))}var Ef=new Set([\"auto\",\"min-content\",\"max-content\",\"stretch\",\"fill-available\",\"-webkit-fill-available\"]);function Mf(e){return Ef.has(e)||e.startsWith(\"fit-content\")}var Af=new WeakMap;function _f(e,t){return e.env===Om&&e.stamp===Km(t,e.hosts)}var Tf=/^(width|height|inline-size|block-size|top|right|bottom|left|transform-origin|perspective-origin)$|^inset-/,If=/(margin|padding)[a-z-]*\\s*:[^;]*(%|\\bauto\\b|calc\\(|var\\()/i,Lf=new Set([\"INPUT\",\"TEXTAREA\",\"SELECT\",\"OPTION\",\"OPTGROUP\",\"PROGRESS\",\"METER\",\"BUTTON\",\"DATALIST\"]);function Rf(e,t){let n=e.snap,i=e.snap={...n};Object.defineProperty(i,\"__needsBgInline\",{value:n.__needsBgInline,enumerable:!1}),void 0!==n.__bgClipTextFix&&Object.defineProperty(i,\"__bgClipTextFix\",{value:n.__bgClipTextFix,enumerable:!1});let s=ff(t.ownerDocument||document),r=t.getAttribute&&t.getAttribute(\"style\")||\"\",o=r&&If.test(r),a=!!s.marginUnstable||o&&/margin/i.test(r),l=!!s.paddingUnstable||o&&/padding/i.test(r),c=void 0!==i.display&&i.display.includes(\"grid\"),d=void 0!==i.transform&&\"none\"!==i.transform,u=[];for(let e in i)(Tf.test(e)||c&&(\"grid-template-columns\"===e||\"grid-template-rows\"===e)||d&&\"transform\"===e||a&&109===e.charCodeAt(0)&&e.startsWith(\"margin-\")||l&&112===e.charCodeAt(0)&&e.startsWith(\"padding-\"))&&u.push(e);e.h&&!(\"height\"in i)&&u.push(\"height\"),e.b&&!(\"block-size\"in i)&&u.push(\"block-size\");let p=new Set(u),h=[t.tagName.toLowerCase()];for(let e in i)p.has(e)||h.push(e,i[e]);return e.rr=u,e.sig=h.join(\"\u0001\")+\"\u0002\"+u.join(\"\u0001\"),u}function $f(e,t,n,i,s){let r=s&&s.__styleShare?i&&i.__styleShare:null,o=r?r.ids.get(e):void 0;if(void 0===o||-1===o||e.shadowRoot||e.assignedSlot)return dg(n,vf(e));let a=o+t,l=r.pseudo||(r.pseudo=new Map),c=l.get(a);if(c){let t={...c.snap},i=c.rr||Rf(c,e);for(let e=0;e<i.length;e++){let s=n.getPropertyValue(i[e]);s?t[i[e]]=s:delete t[i[e]]}return t}let d=dg(n,vf(e));return l.set(a,{snap:d,rr:null,sig:null,h:\"height\"in d,b:\"block-size\"in d}),d}function Nf(e,t=null,n={},i=null,s=null){let r=Mm.get(e),o=!(!n||!n.embedFonts),a=n&&n.excludeStyleProps||null;if(\"function\"!=typeof a&&r&&_f(r,e)&&r.embedFonts===o&&r.excludeStyleProps===a)return r.snapshot;let l,c=t||getComputedStyle(e),d=null,u=i&&i.st.snaps.get(i.id);if(u){l={...u.snap};let t=u.rr||Rf(u,e);d=[];for(let e=0;e<t.length;e++){let n=t[e],i=c.getPropertyValue(n);i?l[n]=i:delete l[n],d.push(i)}Object.defineProperty(l,\"__needsBgInline\",{value:u.snap.__needsBgInline,enumerable:!1}),void 0!==u.snap.__bgClipTextFix&&Object.defineProperty(l,\"__bgClipTextFix\",{value:u.snap.__bgClipTextFix,enumerable:!1})}else l=kf(c,n,e,bf(e,s)),i&&i.st.snaps.set(i.id,{snap:l,rr:null,sig:null,h:\"height\"in l,b:\"block-size\"in l});let p=!1;if(\"function\"==typeof e.computedStyleMap){let t;for(let n of Am)if(\"0px\"===l[n])try{t||=e.computedStyleMap(),\"auto\"===t.get(n)?.toString()&&(l[n]=\"auto\",p=!0)}catch{}}(function(e,t,n){if(hh(e)&&e.style&&e.style.height)return;let i=e.tagName&&e.tagName.toLowerCase();if(!i||![\"div\",\"section\",\"article\",\"main\",\"aside\",\"header\",\"footer\",\"nav\"].includes(i)||t.aspectRatio&&\"none\"!==t.aspectRatio&&\"auto\"!==t.aspectRatio)return;let s=t.display||\"\";if(s.includes(\"flex\")||s.includes(\"grid\"))return;let r=t.position;if(\"absolute\"===r||\"fixed\"===r||\"sticky\"===r||\"none\"!==t.transform||function(e){return!!(e.backgroundImage&&\"none\"!==e.backgroundImage||e.backgroundColor&&\"rgba(0, 0, 0, 0)\"!==e.backgroundColor&&\"transparent\"!==e.backgroundColor||(parseFloat(e.borderTopWidth)||0)>0||(parseFloat(e.borderBottomWidth)||0)>0||(parseFloat(e.paddingTop)||0)>0||(parseFloat(e.paddingBottom)||0)>0)||\"visible\"!==(e.overflowBlock||e.overflowY||\"visible\")}(t)||Hf(e))return;let o=t.overflowX||t.overflow||\"visible\",a=t.overflowY||t.overflow||\"visible\";if(\"visible\"!==o||\"visible\"!==a)return;let l=t.clip;if(l&&\"auto\"!==l&&\"rect(auto, auto, auto, auto)\"!==l||\"hidden\"===t.visibility||\"0\"===t.opacity||!function(e){for(let t=e.firstChild;t;t=t.nextSibling)if(3===t.nodeType&&/\\S/.test(t.nodeValue))return!0;let t=e.firstElementChild,n=e.lastElementChild;if(t&&\"BR\"===t.tagName||n&&\"BR\"===n.tagName)return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling){let e=cg(t);if(\"none\"===e.display)continue;let n=e.position;if(\"absolute\"!==n&&\"fixed\"!==n)return!0}return!1}(e))return;let c=parseFloat(t.height),d=function(e){let t=e.getBoundingClientRect().top,n=-1/0,i=null;for(let t=e.firstChild;t;t=t.nextSibling){if(3===t.nodeType){if(!/\\S/.test(t.nodeValue||\"\"))continue;i=i||document.createRange(),i.selectNode(t);let e=i.getBoundingClientRect();(e.width||e.height)&&(n=Math.max(n,e.bottom));continue}if(1!==t.nodeType)continue;let e=cg(t);if(\"none\"===e.display)continue;let s=e.position;\"absolute\"===s||\"fixed\"===s||e.float&&\"none\"!==e.float||(n=Math.max(n,t.getBoundingClientRect().bottom))}return n===-1/0?NaN:n-t}(e);Number.isFinite(c)&&Number.isFinite(d)&&Math.abs(c-d)>2||(delete n.height,delete n[\"block-size\"])})(e,c,l),null!==d&&(p&&d.push(\"\u0005\",...Am.map(e=>l[e])),Af.set(l,u.sig+\"\u0002\"+d.join(\"\u0001\")+(\"height\"in l?\"\":\"\u0003\")+(\"block-size\"in l?\"\":\"\u0004\")));let h=Ym(e);return Mm.set(e,{env:Om,stamp:Km(e,h),hosts:h,snapshot:l,embedFonts:o,excludeStyleProps:a}),l}var Pf=/%|[\\d.](?:em|rem|ex|ch|cap|ic|lh|rlh|v[whib]|vmin|vmax|cq[whbi]|cqmin|cqmax)\\b|\\b(?:calc|var|min|max|clamp|env|attr)\\(|\\b(?:auto|inherit|initial|unset|revert|currentcolor|-webkit-fill-available|fit-content|min-content|max-content)\\b/i,Ff=e=>\"INPUT\"===e.tagName||\"TEXTAREA\"===e.tagName;function Of(e,t,n){if(!e.style||0===e.style.length)return;let i=function(e){let t=e.ownerDocument||document;return e.getRootNode&&e.getRootNode()!==t?null:ff(t).importantProps}(e),s=null!=i&&!Pf.test(e.getAttribute(\"style\")||\"\");for(let r=0;r<e.style.length;r++){let o=e.style[r];if(s&&!i.has(o)&&(!o.startsWith(\"background\")||!Ff(e)))continue;let a=n.getPropertyValue(o);a&&t.style.setProperty(o,a,e.style.getPropertyPriority(o))}}function qf(e,t,n,i){if(\"STYLE\"===e.tagName)return;let s=function(e,t){if(e&&e.session&&e.persist)return e;if(e&&(e.styleMap||e.styleCache||e.nodeMap)){let n=e.__ctx;return(!n||e.__ctxOpts!==t)&&(n={session:e,persist:{snapshotKeyCache:_m,defaultStyle:oh.defaultStyle,baseStyle:oh.baseStyle,image:oh.image,resource:oh.resource,background:oh.background},options:t||{}},e.__ctx=n,e.__ctxOpts=t),n}return{session:{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map},persist:{snapshotKeyCache:_m,defaultStyle:oh.defaultStyle,baseStyle:oh.baseStyle,image:oh.image,resource:oh.resource,background:oh.background},options:e||t||{}}}(n,i),r=s.options&&s.options.cache||\"soft\";\"disabled\"!==r&&af(e.ownerDocument),\"disabled\"===r&&!s.session.__bumpedForDisabled&&(Im(),_m.clear(),s.session.__bumpedForDisabled=!0);let{session:o,persist:a}=s;if(!o.styleCache.has(e)){let t=null;try{t=getComputedStyle(e)}catch{}o.styleCache.set(e,t||getComputedStyle((e.ownerDocument||document).documentElement))}let l=o.styleCache.get(e);e.getAttribute?.(\"style\")&&Of(e,t,l);let c=l.getPropertyValue(\"animation-name\");t&&t.style&&c&&\"none\"!==c&&t.style.setProperty(\"animation\",\"none\",\"important\");let d=e.tagName?.toLowerCase()||\"div\";if(hg.has(d)){let n={};Object.defineProperty(n,\"__needsBgInline\",{value:Sf(l),enumerable:!1});let i=Ym(e);return Mm.set(e,{env:Om,stamp:Km(e,i),hosts:i,snapshot:n,embedFonts:!(!s.options||!s.options.embedFonts),excludeStyleProps:s.options&&s.options.excludeStyleProps||null}),void o.styleMap.set(t,\"\")}let u=null;if(s.options&&s.options.__styleShare&&o.styleMap){let t=function(e){let t=e.__styleShare;return t||(t=e.__styleShare={ids:new WeakMap,intern:new Map,snaps:new Map,rootSeen:!1}),t}(o),n=function(e,t){let n=t.ids.get(e);if(void 0!==n)return n;let i,s=e.parentElement;if(s){if(i=t.ids.get(s),void 0===i){if(t.rootSeen)return t.ids.set(e,-1),-1;i=\"R\"}}else i=\"R\";if(t.rootSeen=!0,-1===i)return t.ids.set(e,-1),-1;let r=\"\",o=e.attributes;if(o&&o.length)if(1===o.length)r=o[0].name+\"=\"+o[0].value;else{let e=[];for(let t=0;t<o.length;t++)e.push(o[t].name+\"=\"+o[t].value);e.sort(),r=e.join(\"\u0001\")}let a=i+\"|\"+e.tagName+\"|\"+r;return n=t.intern.get(a),void 0===n&&(n=t.intern.size,t.intern.set(a,n)),t.ids.set(e,n),n}(e,t),i=e.ownerDocument||document,s=i.activeElement;-1!==n&&!Lf.has(e.tagName)&&(!s||s===i.body||s===i.documentElement||s!==e)&&(!e.getRootNode||e.getRootNode()===i)&&!e.shadowRoot&&!e.assignedSlot&&(u={st:t,id:n})}let p=Nf(e,l,s.options,u,o);if(e.getAttribute?.(\"style\"))for(let e of[\"top\",\"right\",\"bottom\",\"left\"]){let n=`margin-${e}`;\"auto\"===p[n]&&t.style.setProperty(n,\"auto\",\"important\")}p.__bgClipTextFix&&t&&t.style&&(t.style.setProperty(\"background-image\",\"none\",\"important\"),t.style.setProperty(\"background-color\",\"transparent\",\"important\"),t.style.setProperty(\"color\",p.__bgClipTextFix,\"important\"),t.style.setProperty(\"-webkit-text-fill-color\",p.__bgClipTextFix,\"important\")),function(e,t,n){let i=t.getPropertyValue(\"overflow-x\"),s=t.getPropertyValue(\"overflow-y\");if(!((\"visible\"!==i&&i||\"visible\"!==s&&s)&&\"border-box\"!==t.getPropertyValue(\"box-sizing\")&&\"number\"==typeof e.clientWidth&&e.offsetWidth))return;let r=e=>parseFloat(e)||0,o=e.offsetWidth-e.clientWidth-r(t.getPropertyValue(\"border-left-width\"))-r(t.getPropertyValue(\"border-right-width\")),a=e.offsetHeight-e.clientHeight-r(t.getPropertyValue(\"border-top-width\"))-r(t.getPropertyValue(\"border-bottom-width\")),l=(e,t)=>{let i=n[e];if(!i||!i.endsWith(\"px\"))return;let s=parseFloat(i);Number.isFinite(s)&&(n[e]=Math.round(1e3*(s+t))/1e3+\"px\")};o>.5&&(l(\"width\",o),l(\"inline-size\",o)),a>.5&&(l(\"height\",a),l(\"block-size\",a))}(e,l,p);let h=Hf(e);if(h){let e=l.getPropertyValue(\"min-width\");(!e||\"auto\"===e||\"0px\"===e)&&(p[\"min-width\"]=\"0px\")}let g=function(e,t){let n=Af.get(e);if(n)return n;let i=[t];for(let t in e)i.push(t,e[t]);return n=i.join(\"\u0001\"),Af.set(e,n),n}(p,d),m=!0;if(og(d,(p.display||\"\").toLowerCase())){m=function(e){for(let t=e.firstChild;t;t=t.nextSibling){if(3===t.nodeType&&/\\S/.test(t.nodeValue||\"\"))return!0;if(1===t.nodeType){let e=cg(t).position;if(\"absolute\"!==e&&\"fixed\"!==e)return!0}}return!1}(e),m&&function(e,t,n){let i=(t.display||\"\").toLowerCase();if(\"inline\"===i||vg.has(e))return!1;if(n)return!0;if(\"none\"!==(t.float||\"none\").toLowerCase())return!1;let s=(t.position||\"static\").toLowerCase();return\"absolute\"!==s&&\"fixed\"!==s&&!Eg.has(i)}(d,p,h)&&Cf(e,l,h)&&(m=!1),g=`${g}${m?\"|c\":\"\"}${h?\"|f\":\"\"}`;let t=p[\"text-wrap-mode\"]||p[\"white-space\"]||\"\";m&&\"nowrap\"!==t&&\"pre\"!==t&&(o.reconcileRisk=(o.reconcileRisk||0)+1)}let f=a.snapshotKeyCache.get(g);void 0===f&&(f=ag(p,d,m,h),a.snapshotKeyCache.size>=2e3&&a.snapshotKeyCache.delete(a.snapshotKeyCache.keys().next().value),a.snapshotKeyCache.set(g,f)),o.styleMap.set(t,f)}function Hf(e){let t=e.parentElement;if(!t)return!1;let n=cg(t).display||\"\";return n.includes(\"flex\")||n.includes(\"grid\")}Ag();var Bf=new Set([\"symbol\",\"defs\",\"pattern\",\"marker\",\"linearGradient\",\"radialGradient\",\"filter\"]),Df=new WeakMap,zf=-1;function Uf(e){let t=Hm();return t!==zf&&(Df=new WeakMap,zf=t),jf(e)}function jf(e){let t,n=Df.get(e);if(void 0!==n)return n;if(\"http://www.w3.org/2000/svg\"===e.namespaceURI&&(\"mask\"===e.localName||\"clipPath\"===e.localName?t=!1:Bf.has(e.localName)&&(t=!0)),void 0===t){let n=e.parentNode;t=!(!n||1!==n.nodeType)&&jf(n)}return Df.set(e,t),t}function Wf(e){return!(e&&!e.startsWith(\"data:\")&&!e.startsWith(\"blob:\"))}function Vf(e,t){if(!e)return null;let n=0;try{n=t?t.getBoundingClientRect().width||t.width:0}catch{}n||(n=window.innerWidth||1e3);let i=[];for(let t of e.split(\",\")){let e=t.trim().split(/\\s+/);if(!e[0])continue;let s=e[1]||\"\",r=1;/^\\d*\\.?\\d+x$/i.test(s)?r=parseFloat(s):/^\\d+w$/i.test(s)&&(r=parseInt(s,10)/n),i.push({url:e[0],d:r})}if(!i.length)return null;i.sort((e,t)=>e.d-t.d);let s=window.devicePixelRatio||1;return(i.find(e=>e.d>=s)||i[i.length-1]).url}Hg(),Hg(),ah(),Lh(),Qh(),wh(),ng();var Gf=/::[a-zA-Z-]+(?:\\([^)]*\\))?$|:(?:before|after|first-letter|first-line)$/,Kf=/^::?(?:before|after|first-letter)$/;function Yf(e,t,n){return e?(e=e.replace(/:host-context\\(([^)]+)\\)/g,(e,n)=>`:where(:where(${n.trim()}) ${t})`),e=e.replace(/:host\\(([^)]+)\\)/g,(e,n)=>`:where(${t}:is(${n.trim()}))`),e=(e=e.replace(/:host\\b/g,`:where(${t})`)).replace(/::slotted\\(([^)]+)\\)/g,(e,n)=>`:where(${t} ${n.trim()})`),e=e.replace(/(^|})(\\s*)([^@}{]+){/g,(e,i,s,r)=>{let o=function(e,t,n=!0,i){return Hh(e,\",\").map(e=>e.trim()).filter(Boolean).map(e=>{if(e.startsWith(\":where(\")&&e.includes(\"data-sd\")||e.startsWith(\"@\"))return e;let s=e.match(Gf);if(s&&Kf.test(s[0]))return\":not(*)\";let r=s?e.slice(0,s.index).trim():e,o=n?function(e,t){if(!(e=e.trim()))return e;let n=t?`[data-sd-slotted~=\"${t}\"]`:\"[data-sd-slotted]\";return e.endsWith(\":not([data-sd-slotted])\")||e.endsWith(`:not(${n})`)?e:`${e}:not(${n})`}(r,i):r;return`:where(${t} ${o})${s?s[0]:\"\"}`}).join(\", \")}(r,t,!0,n);return`${i}${s}${o}{`}),e):\"\"}function Xf(e){let t=\"\";for(let n of e)if(n.media&&n.cssRules){let e=!1;try{e=window.matchMedia(n.conditionText||n.media.mediaText).matches}catch{}e&&(t+=Xf(n.cssRules))}else if(\"CSSSupportsRule\"===n.constructor?.name)t+=`@supports ${n.conditionText}{${Xf(n.cssRules)}}`;else if(n.cssRules&&n.cssRules.length&&/@media/i.test(n.cssText)){t+=n.cssText.slice(0,n.cssText.indexOf(\"{\")+1)+(n.style?n.style.cssText:\"\")+Xf(n.cssRules)+\"}\"}else t+=n.cssText+\"\\n\";return t}function Jf(e,t,n={}){try{let i=null,s=cg(e).content;if(s&&s.includes(\"url(\")){let e=s.match(/url\\([\"']?([^\"')]+)[\"']?\\)/);e&&(i=e[1])}let r=e.closest?.(\"picture\"),o=e.getAttribute(\"src\")||\"\",a=e.getAttribute(\"srcset\")||\"\",l=i||(r?function(e,t){let n=e.currentSrc||\"\";if(n&&!Wf(n))return n;let i=t.querySelectorAll(\"source[srcset]\"),s=null;for(let t of i){let n=t.getAttribute(\"srcset\");if(!n||Wf(n))continue;let i=t.getAttribute(\"type\");if(i&&!fh.test(i.trim()))continue;let r=t.getAttribute(\"media\");if(r)try{if(window.matchMedia(r).matches)return Vf(n,e)}catch{}s||(s=Vf(n,e))}return s}(e,r):!a.trim()&&o.startsWith(\"data:\")?o:e.currentSrc)||Vf(a,e)||e.src||\"\";if((!l||Wf(l))&&!1!==n.resolvePicturePlaceholders){let t=function(e){let t=[e.getAttribute(\"data-src\"),e.getAttribute(\"data-lazy-src\"),e.getAttribute(\"data-original\"),e.getAttribute(\"data-hi-res-src\")];for(let e of t)if(e&&!Wf(e))return e;let n=e.getAttribute(\"data-srcset\")||e.getAttribute(\"data-lazy-srcset\");if(n){let e=n.split(\",\")[0].trim().split(/\\s+/)[0];if(e&&!Wf(e))return e}return null}(e);t&&(l=t)}if(!l)return;t.getAttribute(\"src\")!==l&&t.setAttribute(\"src\",l),t.removeAttribute(\"srcset\"),t.removeAttribute(\"sizes\"),t.loading=\"eager\",t.decoding=\"sync\"}catch{}}function Qf(e,t){try{let n=getComputedStyle(e).getPropertyValue(t).trim();if(n)return n}catch{}try{let e=getComputedStyle(document.documentElement).getPropertyValue(t).trim();if(e)return e}catch{}return\"\"}function Zf(e){let t=0,n=0;if(e.offsetWidth>0&&(t=e.offsetWidth),e.offsetHeight>0&&(n=e.offsetHeight),0===t||0===n)try{let i=getComputedStyle(e);if(0===t){let e=parseFloat(i.width);!isNaN(e)&&e>0&&(t=e)}if(0===n){let e=parseFloat(i.height);!isNaN(e)&&e>0&&(n=e)}}catch{}if(0===t||0===n)try{if(0===t){let n=parseFloat(e.getAttribute(\"width\"));!isNaN(n)&&n>0&&(t=n)}if(0===n){let t=parseFloat(e.getAttribute(\"height\"));!isNaN(t)&&t>0&&(n=t)}}catch{}if((0===t||0===n)&&(e.naturalWidth||e.naturalHeight))try{0===t&&e.naturalWidth>0&&(t=e.naturalWidth),0===n&&e.naturalHeight>0&&(n=e.naturalHeight)}catch{}return{width:t,height:n}}async function eb(e,t,n){let i=await async function(e,t=3){let n=()=>{try{return e.contentDocument||e.contentWindow?.document||null}catch{return null}},i=n(),s=0;for(;s<t&&(!i||!i.body&&!i.documentElement);)await new Promise(e=>setTimeout(e,0)),i=n(),s++;return i&&(i.body||i.documentElement)?i:null}(e,3);if(!i)throw new Error(\"iframe document not accessible/ready\");let{contentWidth:s,contentHeight:r,rect:o}=function(e){let t=e.getBoundingClientRect(),n=0,i=0,s=0,r=0;try{let t=getComputedStyle(e);n=parseFloat(t.borderLeftWidth)||0,i=parseFloat(t.borderRightWidth)||0,s=parseFloat(t.borderTopWidth)||0,r=parseFloat(t.borderBottomWidth)||0}catch{}return{contentWidth:Math.max(0,Math.round(t.width-(n+i))),contentHeight:Math.max(0,Math.round(t.height-(s+r))),rect:t}}(e),a=n?.snap;if(!a||\"function\"!=typeof a.toPng)throw new Error(\"[snapdom] iframe capture requires the snapdom entrypoints on options.snap — capture through snapdom(el) (set automatically) or pass options.snap.\");let l,c={...n,scale:1,clip:null,__pinned:!0},d=function(e,t,n){let i=e.defaultView,s=i?i.scrollX:0,r=i?i.scrollY:0,o=e.body?e.body.scrollLeft:0,a=e.body?e.body.scrollTop:0,l=e.documentElement?e.documentElement.scrollLeft:0,c=e.documentElement?e.documentElement.scrollTop:0,d=0,u=0,p=0,h=0;try{let t=i&&e.body?i.getComputedStyle(e.body):null;t&&(d=(parseFloat(t.marginTop)||0)+(parseFloat(t.paddingTop)||0),u=(parseFloat(t.marginRight)||0)+(parseFloat(t.paddingRight)||0),p=(parseFloat(t.marginBottom)||0)+(parseFloat(t.paddingBottom)||0),h=(parseFloat(t.marginLeft)||0)+(parseFloat(t.paddingLeft)||0))}catch{}let g=e.createElement(\"style\");if(g.setAttribute(\"data-sd-iframe-pin\",\"\"),Zh(g),g.textContent=`html {margin: 0 !important;padding: 0 !important;width: ${t}px !important;height: ${n}px !important;min-width: ${t}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}body {margin: 0 !important;padding: ${d}px ${u}px ${p}px ${h}px !important;width: ${t}px !important;height: ${n}px !important;min-width: ${t}px !important;min-height: ${n}px !important;box-sizing: border-box !important;overflow: hidden !important;background-clip: border-box !important;}`,(e.head||e.documentElement).appendChild(g),pf(e.documentElement),s||r)try{e.body&&(e.body.scrollLeft=s,e.body.scrollTop=r),e.documentElement&&(e.documentElement.scrollLeft||(e.documentElement.scrollLeft=s),e.documentElement.scrollTop||(e.documentElement.scrollTop=r))}catch{}return()=>{try{g.remove()}catch{}try{i&&\"function\"==typeof i.scrollTo&&i.scrollTo(s,r),e.body&&(e.body.scrollLeft=o,e.body.scrollTop=a),e.documentElement&&(e.documentElement.scrollLeft=l,e.documentElement.scrollTop=c)}catch{}pf(e.documentElement)}}(i,s,r);try{l=await a.toPng(i.documentElement,c)}finally{d()}l.style.display=\"block\",l.style.width=`${s}px`,l.style.height=`${r}px`;let u=document.createElement(\"div\");return t.nodeMap.set(u,e),qf(e,u,t,n),u.style.overflow=\"hidden\",u.style.display=\"block\",u.style.width||(u.style.width=`${Math.round(o.width)}px`),u.style.height||(u.style.height=`${Math.round(o.height)}px`),u.appendChild(l),u}function tb(e){try{let t=e&&e.accentColor;if(t&&\"auto\"!==t&&\"none\"!==t)return t;let n=e&&e.color;if(n)return n}catch{}return\"#0a6ed1\"}var nb=new rh(80);async function ib(e){if(oh.resource?.has(e))return oh.resource.get(e);if(nb.has(e))return nb.get(e);let t=(async()=>{let t=await Mh(e,{as:\"dataURL\",silent:!0});if(!t.ok||\"string\"!=typeof t.data)throw new Error(`[snapDOM] Failed to read blob URL: ${e}`);return oh.resource?.set(e,t.data),t.data})();nb.set(e,t);try{let n=await t;return nb.set(e,n),n}catch(t){throw nb.delete(e),t}}var sb=/\\bblob:[^)\"'\\s]+/g;function rb(e){return\"string\"==typeof e&&e.startsWith(\"blob:\")}function ob(e){return(e||\"\").split(\",\").map(e=>e.trim()).filter(Boolean).map(e=>{let t=e.match(/^(\\S+)(\\s+.+)?$/);return t?{url:t[1],desc:t[2]||\"\"}:null}).filter(Boolean)}function ab(e){return e.map(e=>e.desc?`${e.url} ${e.desc.trim()}`:e.url).join(\", \")}function lb(e,t){let n=e.querySelectorAll?Array.from(e.querySelectorAll(t)):[];return e.matches?.(t)&&n.unshift(e),n}async function cb(e,t=null){if(!e)return;let n=t,i=new Set,s=[],r=new Map,o=(e,t,n,o)=>{i.add(n),s.push(()=>{r.has(n)&&(e.setAttribute(t,r.get(n)),o?.())})},a=(e,t)=>{if(!e||!e.includes(\"blob:\"))return;let n=e.match(sb)||[];if(n.length){for(let e of n)i.add(e);s.push(()=>{let n=e.replace(sb,e=>r.get(e)||e);n!==e&&t(n)})}},l=lb(e,\"img\");for(let e of l)try{let t=e.getAttribute(\"src\")||e.currentSrc||\"\";rb(t)&&o(e,\"src\",t);let n=e.getAttribute(\"srcset\");if(n&&n.includes(\"blob:\")){let t=ob(n);for(let e of t)rb(e.url)&&i.add(e.url);s.push(()=>{let n=!1;for(let e of t)r.has(e.url)&&(e.url=r.get(e.url),n=!0);n&&e.setAttribute(\"srcset\",ab(t))})}}catch(e){Pg(n,\"resolveBlobUrls for img failed\",e)}let c=lb(e,\"image\");for(let e of c)try{let t=\"http://www.w3.org/1999/xlink\",n=e.getAttribute(\"href\")||e.getAttributeNS?.(t,\"href\");rb(n)&&o(e,\"href\",n,()=>e.removeAttributeNS?.(t,\"href\"))}catch(e){Pg(n,\"resolveBlobUrls for SVG image href failed\",e)}let d=lb(e,\"[style*='blob:']\");for(let e of d)try{a(e.getAttribute(\"style\"),t=>e.setAttribute(\"style\",t))}catch(e){Pg(n,\"replaceBlobUrls in inline style failed\",e)}let u=lb(e,\"style\");for(let e of u)try{a(e.textContent||\"\",t=>{e.textContent=t})}catch(e){Pg(n,\"replaceBlobUrls in style tag failed\",e)}let p=[\"poster\"];for(let t of p){let i=lb(e,`[${t}^='blob:']`);for(let e of i)try{let n=e.getAttribute(t);rb(n)&&o(e,t,n)}catch(e){Pg(n,`resolveBlobUrls for ${t} failed`,e)}}if(!i.size)return;let h=[...i],g=0;await Promise.all(Array.from({length:Math.min(4,h.length)},async()=>{for(;g<h.length;){let e=h[g++];try{r.set(e,await ib(e))}catch(e){Pg(n,\"blobUrlToDataUrl failed; keeping original URL\",e)}}}));for(let e of s)try{e()}catch(e){Pg(n,\"resolved blob URL write failed\",e)}}Ng();var db=new Set([\"rgba(0, 0, 0, 0)\",\"transparent\"]),ub=\"Highlight\";function pb(e,t){let n=e.data;if(!n)return null;let i=e.parentElement;if(!i)return null;let s=[];for(let i of t.ranges){let t=!1;try{t=i.intersectsNode(e)}catch{}if(!t)continue;let r=i.startContainer===e?i.startOffset:0,o=i.endContainer===e?i.endOffset:n.length;o>r&&s.push([r,o])}if(0===s.length)return null;let r=function(e,t){if(t.styles.has(e))return t.styles.get(e);let n;try{let i=getComputedStyle(e);if(\"none\"===i.userSelect||\"none\"===i.webkitUserSelect||\"none\"===i.getPropertyValue(\"-webkit-user-select\"))return t.styles.set(e,null),null;let s=getComputedStyle(e,\"::selection\"),r=[],o=s.backgroundColor,a=o&&!db.has(o)&&o!==i.backgroundColor;r.push(`background-color:${a?o:ub}`),s.color&&s.color!==i.color&&r.push(`color:${s.color}`,`-webkit-text-fill-color:${s.color}`),s.textShadow&&s.textShadow!==i.textShadow&&r.push(`text-shadow:${s.textShadow}`),s.textDecorationLine&&\"none\"!==s.textDecorationLine&&s.textDecorationLine!==i.textDecorationLine&&r.push(`text-decoration:${s.textDecorationLine} ${s.textDecorationStyle||\"solid\"} ${s.textDecorationColor||\"currentcolor\"}`),n=r.join(\";\")}catch{n=`background-color:${ub}`}return t.styles.set(e,n),n}(i,t);if(!r)return null;s.sort((e,t)=>e[0]-t[0]);let o=e.ownerDocument||document,a=o.createDocumentFragment(),l=0;for(let[e,t]of s){e>l&&a.append(o.createTextNode(n.slice(l,e)));let i=o.createElement(\"span\");i.setAttribute(\"data-snapdom-selection\",\"\"),i.setAttribute(\"style\",`all:unset;${r}`),i.textContent=n.slice(e,t),a.append(i),l=t}return l<n.length&&a.append(o.createTextNode(n.slice(l))),a}var hb=e=>Number.parseFloat(e)||0,gb=[\"font-family\",\"font-size\",\"font-weight\",\"font-style\",\"font-variant\",\"font-stretch\",\"letter-spacing\",\"word-spacing\",\"text-transform\",\"text-indent\",\"text-align\",\"line-height\",\"tab-size\",\"direction\"];function mb(e,t){let n=e.ownerDocument||document;if(n.activeElement!==e)return;let i=null,s=null;try{i=e.selectionStart,s=e.selectionEnd}catch{return}if(null==i||null==s||i===s)return;let r=e.value||\"\";if(\"input\"===e.localName&&\"password\"===e.type&&(r=\"•\".repeat(r.length)),!r)return;let o=getComputedStyle(e),a=\"textarea\"===e.localName,l=hb(o.paddingLeft),c=hb(o.paddingTop),d=e.clientWidth-l-hb(o.paddingRight),u=e.clientHeight-c-hb(o.paddingBottom),p=n.createElement(\"div\");p.style.cssText=\"position:absolute;top:0;left:-99999px;visibility:hidden;margin:0;border:0;padding:0;box-sizing:content-box;\";for(let e of gb)p.style.setProperty(e,o.getPropertyValue(e));a?(p.style.whiteSpace=\"pre-wrap\",p.style.overflowWrap=\"break-word\",p.style.width=`${Math.max(0,d)}px`):p.style.whiteSpace=\"pre\";let h=n.createElement(\"span\");h.textContent=r.slice(i,s),p.append(n.createTextNode(r.slice(0,i)),h,n.createTextNode(r.slice(s))),n.body.appendChild(p);let g=[];try{let t=p.getBoundingClientRect(),n=-e.scrollLeft,i=-e.scrollTop;if(!a){i+=Math.max(0,(u-t.height)/2);let e=\"rtl\"===o.direction,s=o.textAlign;\"start\"===s?s=e?\"right\":\"left\":\"end\"===s&&(s=e?\"left\":\"right\");let r=d-t.width;r>0&&(\"right\"===s?n+=r:\"center\"===s&&(n+=r/2))}for(let e of h.getClientRects())e.width<=0||e.height<=0||g.push({x:l+(e.left-t.left)+n,y:c+(e.top-t.top)+i,width:e.width,height:e.height})}finally{p.remove()}if(0===g.length)return;let m=function(e,t){try{let n=getComputedStyle(e,\"::selection\").backgroundColor;if(n&&!db.has(n)&&n!==t.backgroundColor)return n}catch{}return ub}(e,o);t.__snapdomFieldSelection={images:g.map(()=>`linear-gradient(${m},${m})`),positions:g.map(e=>`${e.x}px ${e.y}px`),sizes:g.map(e=>`${e.width}px ${e.height}px`),repeats:g.map(()=>\"no-repeat\"),origins:g.map(()=>\"padding-box\"),clips:g.map(()=>\"padding-box\"),base:{image:o.backgroundImage,position:o.backgroundPosition,size:o.backgroundSize,repeat:o.backgroundRepeat,origin:o.backgroundOrigin,clip:o.backgroundClip}}}ng();var fb=new Map,bb=new Set([\"IFRAME\"]);function yb(e,t){fb.set(String(e).toUpperCase(),t)}function vb(e){let t=cg(e),n=t.display;if(\"none\"===n)return null;let i=/^(block|inline-block|flow-root|flex|inline-flex|grid|inline-grid|list-item)$/.test(n),s=e=>parseFloat(e)||0,r=(e,n,s,r,o)=>{if(!i||!e?.endsWith(\"px\"))return null;let a=parseFloat(e);if(!Number.isFinite(a)||a<0)return null;if(\"border-box\"===t.boxSizing)return a;let l=r-o-s;return a+n+s+(l>0&&a+n<o+l/2?l:0)},[o,a,l,c]=/scroll|auto/.test(t.overflow)?[e.offsetWidth,e.clientWidth,e.offsetHeight,e.clientHeight]:[0,0,0,0],d=r(t.width,s(t.paddingLeft)+s(t.paddingRight),s(t.borderLeftWidth)+s(t.borderRightWidth),o,a),u=r(t.height,s(t.paddingTop)+s(t.paddingBottom),s(t.borderTopWidth)+s(t.borderBottomWidth),l,c);if(null===d||null===u){let{width:t,height:n}=Zf(e),i=t,s=n;if(null===d&&!i||null===u&&!s){let t=e.getBoundingClientRect();i||=t.width||0,s||=t.height||0}d??=i,u??=s}let p=document.createElement(\"div\");return p.style.cssText=`display:${\"inline\"===n?\"inline-block\":n};box-sizing:border-box;width:${d}px;height:${u}px;visibility:hidden;`,p}var wb=new Set([\"style\",\"option\",\"optgroup\"]),xb=200,kb=new Set([\"img\",\"canvas\",\"video\",\"iframe\",\"object\",\"embed\"]);function Sb(e,t){return e.right>=t.left-xb&&e.left<=t.right+xb&&e.bottom>=t.top-xb&&e.top<=t.bottom+xb}async function Cb(e,t,n){if(!e)throw new Error(\"Invalid node\");t.slicer?.due()&&await t.slicer.pause();let i,s=new Set,r=null,o=null;if(e.nodeType===Node.ELEMENT_NODE){let i=(e.localName||e.tagName||\"\").toLowerCase(),s=eg(e);if(s&&(\"snapdom-sandbox\"===e.id||e.hasAttribute(\"data-snapdom-sandbox\"))||e!==n.element&&s||pg.has(i))return null;if(\"foreignobject\"===i&&e.parentElement?.closest?.(\"foreignObject\"))return Pg(t,\"Nested <foreignObject> skipped (SVG spec limitation — not rendered by browsers)\"),null;if(\"source\"===i&&\"picture\"===e.parentElement?.localName)return null}if(e.nodeType===Node.TEXT_NODE){if(t.selection){let n=pb(e,t.selection);if(n)return n}return e.cloneNode(!0)}if(e.nodeType!==Node.ELEMENT_NODE)return e.cloneNode(!0);if(\"exclude\"===e.getAttribute(\"data-capture\")){if(\"hide\"===n.excludeMode)return vb(e);if(\"remove\"===n.excludeMode)return null}if(n.exclude&&Array.isArray(n.exclude))for(let t of n.exclude)try{if(e.matches?.(t)){if(\"hide\"===n.excludeMode)return vb(e);if(\"remove\"===n.excludeMode)return null}}catch(e){console.warn(`Invalid selector in exclude option: ${t}`,e)}if(n.excludePredicates)for(let t of n.excludePredicates)try{if(t(e))return\"remove\"===n.excludeMode?null:vb(e)}catch(e){console.warn(\"Error in exclude predicate:\",e)}if(\"function\"==typeof n.filter)try{if(!n.filter(e)){if(\"hide\"===n.filterMode)return vb(e);if(\"remove\"===n.filterMode)return null}}catch(e){console.warn(\"Error in filter function:\",e)}if(e!==n.element&&!wb.has(e.localName)&&!gh(e)&&\"none\"===cg(e).display){let i=e.cloneNode(!1);\"IMG\"===e.tagName&&(i.removeAttribute(\"src\"),i.removeAttribute(\"srcset\")),i.style.setProperty(\"display\",\"none\",\"important\");for(let s of e.querySelectorAll(\"style\")){let e=await Cb(s,t,n);e&&i.appendChild(e)}return i}if(t.clip&&function(e,t){if(e===t.root)return!1;let n;try{n=e.getBoundingClientRect()}catch{return!1}if(0===n.width&&0===n.height)return!1;let i=cg(e);if(\"inline\"===i.display&&!kb.has((e.localName||\"\").toLowerCase()))return!1;let s=t.rect,r=e.scrollWidth||0,o=e.scrollHeight||0,a={left:\"rtl\"===i.direction?Math.min(n.left,n.right-r):n.left,top:n.top,right:Math.max(n.right,n.left+r),bottom:Math.max(n.bottom,n.top+o)},l=i.writingMode||\"\";if((l.startsWith(\"vertical\")||l.startsWith(\"sideways\"))&&(a.top=Math.min(n.top,n.bottom-o),a.left=Math.min(a.left,n.right-r)),Sb(a,s))return!1;let c=(e.ownerDocument||document).createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(;c.nextNode();){let e=c.currentNode.getBoundingClientRect();if((e.width>0||e.height>0)&&Sb(e,s))return!1}return!0}(e,t.clip))return function(e,t,n){let i=e.cloneNode(!1);\"IMG\"===e.tagName&&(i.removeAttribute(\"src\"),i.removeAttribute(\"srcset\"),i.removeAttribute(\"sizes\")),qf(e,i,t,n);let{width:s,height:r}=Zf(e);s>0&&(i.style.width=`${s}px`,i.style.minWidth=`${s}px`,i.style.maxWidth=`${s}px`),r>0&&(i.style.height=`${r}px`,i.style.minHeight=`${r}px`,i.style.maxHeight=`${r}px`),i.style.visibility=\"hidden\";let o=e.parentElement?cg(e.parentElement).display:\"\",a=cg(e).position;if(!/flex|grid|table/.test(o)&&(\"static\"===a||\"relative\"===a)){let t=e=>{let t=cg(e);return\"none\"!==t.display&&\"absolute\"!==t.position&&\"fixed\"!==t.position},n=e.getBoundingClientRect(),s=e.previousElementSibling;for(;s&&!t(s);)s=s.previousElementSibling;if(s){let e=n.top-s.getBoundingClientRect().bottom;e>=0&&(i.style.marginTop=`${e}px`)}let r=e.nextElementSibling;for(;r&&!t(r);)r=r.nextElementSibling;if(r){let e=r.getBoundingClientRect().top-n.bottom;e>=0&&(i.style.marginBottom=`${e}px`)}}return i.style.boxSizing=\"border-box\",i}(e,t,n);if(n.__resolveNodeHooks)for(let i of n.__resolveNodeHooks){let s;try{s=await i(e,n)}catch(e){Pg(t,\"resolveNode plugin hook failed\",e)}if(null===s)return null;if(s?.nodeType)return s.nodeType===Node.ELEMENT_NODE&&(t.nodeMap.set(s,e),qf(e,s,t,n)),s}{let i=bb.has(e.tagName)&&fb.get(e.tagName);if(i){let s=await i(e,t,n);if(void 0!==s)return s}}if(\"placeholder\"===e.getAttribute(\"data-capture\")){let i=e.cloneNode(!1);t.nodeMap.set(i,e),qf(e,i,t,n);let s=document.createElement(\"div\");return s.textContent=e.getAttribute(\"data-placeholder-text\")||\"\",s.style.cssText=\"color:#666;font-size:12px;text-align:center;line-height:1.4;padding:0.5em;box-sizing:border-box;\",i.appendChild(s),i}{let i=!bb.has(e.tagName)&&fb.get(e.tagName);if(i){let s=await i(e,t,n);if(void 0!==s)return s}}try{if(i=e.cloneNode(!1),function(e,t){if(1!==e?.nodeType||1!==t?.nodeType||Uf(e))return;let n=e.getAttribute?.(\"style\"),i=!(!n||!n.includes(\"var(\"));if(!i&&e.attributes?.length){let t=e.attributes;for(let e=0;e<t.length;e++){let n=t[e];if(n&&\"string\"==typeof n.value&&!n.value.startsWith(\"data:\")&&n.value.includes(\"var(\")){i=!0;break}}}let s=null;if(i)try{s=getComputedStyle(e)}catch{}if(i){let n=e.style;if(n&&n.length){let e=new Set;for(let i=0;i<n.length;i++){let r=n[i];if(e.has(r))continue;e.add(r);let o=n.getPropertyValue(r);if(!o||!o.includes(\"var(\"))continue;let a=s&&s.getPropertyValue(r);if(a)try{t.style.setProperty(r,a.trim(),n.getPropertyPriority(r))}catch{}}}}if(i&&e.attributes?.length){let n=e.attributes;for(let e=0;e<n.length;e++){let i=n[e];if(!i||\"string\"!=typeof i.value||i.value.startsWith(\"data:\")||!i.value.includes(\"var(\"))continue;let r=i.name,o=s&&s.getPropertyValue(r);if(o)try{t.style.setProperty(r,o.trim())}catch{}}}}(e,i),t.nodeMap.set(i,e),\"IMG\"===e.tagName){Jf(e,i,n);try{let t=window.getComputedStyle(e),n=parseFloat(t.width),s=parseFloat(t.height);if(!(n>0&&s>0)){let i=Zf(e),r=e=>parseFloat(t.getPropertyValue(e))||0,o=\"border-box\"===t.getPropertyValue(\"box-sizing\");n>0||(n=i.width-(o?0:r(\"padding-left\")+r(\"padding-right\")+r(\"border-left-width\")+r(\"border-right-width\"))),s>0||(s=i.height-(o?0:r(\"padding-top\")+r(\"padding-bottom\")+r(\"border-top-width\")+r(\"border-bottom-width\")))}let r=Math.round(1e3*(n||0))/1e3,o=Math.round(1e3*(s||0))/1e3;r&&(i.dataset.snapdomWidth=String(r)),o&&(i.dataset.snapdomHeight=String(o))}catch(e){Pg(t,\"getUnscaledDimensions for IMG failed\",e)}try{let t=e.getAttribute(\"style\")||\"\",n=window.getComputedStyle(e),s=e=>{let i=t.match(new RegExp(`${e}\\\\s*:\\\\s*([^;]+)`,\"i\")),s=i?i[1].trim():n.getPropertyValue(e);return/%|auto/i.test(String(s||\"\"))},r=parseFloat(i.dataset.snapdomWidth||\"0\")||0,o=parseFloat(i.dataset.snapdomHeight||\"0\")||0,a=s(\"width\")||!(r>0),l=s(\"height\")||!(o>0);a&&r>0&&(i.style.width=`${r}px`),l&&o>0&&(i.style.height=`${o}px`);let c=n.getPropertyValue(\"object-fit\"),d=n.getPropertyValue(\"object-position\");c&&\"fill\"!==c?(i.style.objectFit=c,d&&(i.style.objectPosition=d)):(r>0&&(i.style.minWidth=`${r}px`),o>0&&(i.style.minHeight=`${o}px`))}catch(e){Pg(t,\"IMG dimension freeze failed\",e)}}}catch(t){throw console.error(\"[Snapdom] Failed to clone node:\",e,t),t}let a=null;if(ph(e,\"textarea\")){let{width:t,height:n}=Zf(e),s=t||e.getBoundingClientRect().width||0,r=n||e.getBoundingClientRect().height||0;s&&(i.style.width=`${s}px`),r&&(i.style.height=`${r}px`)}if(ph(e,\"input\")){let n=(e.type||\"text\").toLowerCase();if(\"checkbox\"!==n&&\"radio\"!==n||!Lg()&&!e.indeterminate)if(\"range\"===n&&(Lg()||Ig())){let{el:n,applyVisual:s}=function(e){let t,{width:n,height:i}=Zf(e),s=e.getBoundingClientRect();try{t=window.getComputedStyle(e)}catch{}let r=t?parseFloat(t.width):NaN,o=t?parseFloat(t.height):NaN,a=Number.isFinite(r)&&r>0?r:n||s.width||128,l=Number.isFinite(o)&&o>0?o:i||s.height||16,c=Number.parseFloat(e.min)||0,d=Number.isFinite(Number.parseFloat(e.max))?Number.parseFloat(e.max):100,u=Number.parseFloat(e.value),p=d-c,h=p>0&&Number.isFinite(u)?Math.min(1,Math.max(0,(u-c)/p)):.5,g=\"middle\";try{t&&t.verticalAlign&&(g=t.verticalAlign)}catch{}let m=document.createElement(\"div\");m.setAttribute(\"data-snapdom-input-replacement\",\"range\"),m.style.cssText=`display:inline-block;width:${a}px;height:${l}px;vertical-align:${g};flex-shrink:0;line-height:0;`;let f=document.createElementNS(\"http://www.w3.org/2000/svg\",\"svg\");function b(){let n=tb(t),i=!!e.disabled,s=Math.max(2,Math.min(4,l)),r=(l-s)/2,o=Math.max(10,Math.min(14,Math.max(l,10))),c=o/2,d=c+h*Math.max(0,a-o);f.innerHTML=\"\";let u=(e,t,n,i)=>{let o=document.createElementNS(\"http://www.w3.org/2000/svg\",\"rect\");o.setAttribute(\"x\",String(e)),o.setAttribute(\"y\",String(r)),o.setAttribute(\"width\",String(Math.max(0,t))),o.setAttribute(\"height\",String(s)),o.setAttribute(\"rx\",String(s/2)),o.setAttribute(\"fill\",n),i&&o.setAttribute(\"fill-opacity\",i),f.appendChild(o)};u(0,a,\"#808080\",\"0.4\"),u(0,d,n);let p=document.createElementNS(\"http://www.w3.org/2000/svg\",\"circle\");p.setAttribute(\"cx\",String(d)),p.setAttribute(\"cy\",String(l/2)),p.setAttribute(\"r\",String(c)),p.setAttribute(\"fill\",n),f.appendChild(p),i&&f.setAttribute(\"opacity\",\"0.5\"),m.style.setProperty(\"width\",`${a}px`,\"important\"),m.style.setProperty(\"height\",`${l}px`,\"important\"),m.style.setProperty(\"min-width\",`${a}px`,\"important\"),m.style.setProperty(\"min-height\",`${l}px`,\"important\")}return f.setAttribute(\"width\",String(a)),f.setAttribute(\"height\",String(l)),f.setAttribute(\"viewBox\",`0 0 ${a} ${l}`),f.style.overflow=\"visible\",m.appendChild(f),b(),{el:m,applyVisual:b}}(e);t.nodeMap.set(n,e),a=s,i=n}else if(\"color\"===n&&Ig()){let t=i,n=e.value||\"#000000\";a=()=>{t.style.setProperty(\"background-color\",n,\"important\"),t.style.setProperty(\"color\",\"transparent\",\"important\"),t.style.setProperty(\"-webkit-text-fill-color\",\"transparent\",\"important\"),t.style.setProperty(\"appearance\",\"none\",\"important\"),t.style.setProperty(\"-webkit-appearance\",\"none\",\"important\")},t.removeAttribute(\"value\")}else if(\"date\"!==n&&\"time\"!==n&&\"datetime-local\"!==n||!Lg()&&!Ig()){let t=uh(e)?function(e){return\"•\".repeat(String(e??\"\").length)}(e.value):e.value;i.value=t,i.setAttribute(\"value\",t),void 0!==e.checked&&(i.checked=e.checked,e.checked?i.setAttribute(\"checked\",\"\"):i.removeAttribute(\"checked\"),e.indeterminate&&(i.indeterminate=e.indeterminate))}else{i.setAttribute(\"type\",\"text\");let t=e.value;\"date\"===n&&e.valueAsDate&&(t=e.valueAsDate.toLocaleDateString(void 0,{timeZone:\"UTC\"})),i.value=t,i.setAttribute(\"value\",t)}else{let{el:n,applyVisual:s}=function(e){let t,{width:n,height:i}=Zf(e),s=e.getBoundingClientRect();try{t=window.getComputedStyle(e)}catch{}let r=t?parseFloat(t.width):NaN,o=t?parseFloat(t.height):NaN,a=Math.round(n||s.width||0),l=Math.round(i||s.height||0),c=Number.isFinite(r)&&r>0?Math.round(r):Math.max(12,a||16),d=Number.isFinite(o)&&o>0?Math.round(o):Math.max(12,l||16),u=\"checkbox\"===(e.type||\"text\").toLowerCase(),p=!!e.checked,h=!!e.indeterminate,g=Math.max(Math.min(c,d),12),m=\"middle\";try{t&&t.verticalAlign&&(m=t.verticalAlign)}catch{}let f=document.createElement(\"div\");f.setAttribute(\"data-snapdom-input-replacement\",e.type||\"checkbox\"),f.style.cssText=`display:inline-block;width:${g}px;height:${g}px;vertical-align:${m};flex-shrink:0;line-height:0;`;let b=document.createElementNS(\"http://www.w3.org/2000/svg\",\"svg\");function y(){let e=tb(t),n=g-2;if(b.innerHTML=\"\",u){let t=document.createElementNS(\"http://www.w3.org/2000/svg\",\"rect\");if(t.setAttribute(\"x\",String(1)),t.setAttribute(\"y\",String(1)),t.setAttribute(\"width\",String(n)),t.setAttribute(\"height\",String(n)),t.setAttribute(\"rx\",\"2\"),t.setAttribute(\"ry\",\"2\"),t.setAttribute(\"fill\",p?e:\"none\"),t.setAttribute(\"stroke\",e),t.setAttribute(\"stroke-width\",String(2)),b.appendChild(t),p){let e=document.createElementNS(\"http://www.w3.org/2000/svg\",\"path\");e.setAttribute(\"d\",`M 3 ${g/2} L ${g/2-1} ${g-1-2} L ${g-1-2} 3`),e.setAttribute(\"stroke\",\"white\"),e.setAttribute(\"stroke-width\",String(Math.max(1.5,2))),e.setAttribute(\"fill\",\"none\"),e.setAttribute(\"stroke-linecap\",\"round\"),e.setAttribute(\"stroke-linejoin\",\"round\"),b.appendChild(e)}else if(h){let t=document.createElementNS(\"http://www.w3.org/2000/svg\",\"rect\"),i=Math.max(6,n-4);t.setAttribute(\"x\",String((g-i)/2)),t.setAttribute(\"y\",String((g-2)/2)),t.setAttribute(\"width\",String(i)),t.setAttribute(\"height\",String(2)),t.setAttribute(\"fill\",e),t.setAttribute(\"rx\",\"1\"),b.appendChild(t)}}else{let t=document.createElementNS(\"http://www.w3.org/2000/svg\",\"circle\");if(t.setAttribute(\"cx\",String(g/2)),t.setAttribute(\"cy\",String(g/2)),t.setAttribute(\"r\",String((g-2)/2)),t.setAttribute(\"fill\",p?e:\"none\"),t.setAttribute(\"stroke\",e),t.setAttribute(\"stroke-width\",String(2)),b.appendChild(t),p){let e=document.createElementNS(\"http://www.w3.org/2000/svg\",\"circle\"),t=Math.max(2,.35*(g-4));e.setAttribute(\"cx\",String(g/2)),e.setAttribute(\"cy\",String(g/2)),e.setAttribute(\"r\",String(t)),e.setAttribute(\"fill\",\"white\"),b.appendChild(e)}}f.style.setProperty(\"width\",`${g}px`,\"important\"),f.style.setProperty(\"height\",`${g}px`,\"important\"),f.style.setProperty(\"min-width\",`${g}px`,\"important\"),f.style.setProperty(\"min-height\",`${g}px`,\"important\")}return b.setAttribute(\"width\",String(g)),b.setAttribute(\"height\",String(g)),b.setAttribute(\"viewBox\",`0 0 ${g} ${g}`),f.appendChild(b),y(),{el:f,applyVisual:y}}(e);t.nodeMap.set(n,e),a=s,i=n}}if((ph(e,\"input\")||ph(e,\"textarea\"))&&!e.value&&e.placeholder)try{let t=window.getComputedStyle(e,\"::placeholder\"),n=t&&t.color;if(n&&\"rgba(0, 0, 0, 0)\"!==n){let e=\"snapdom-ph-\"+(1e6*Math.random()|0);i.classList.add(e);let s=document.createElement(\"style\");s.textContent=`.${e}::placeholder{color:${n}!important;opacity:${t.opacity||\"1\"}!important;-webkit-text-fill-color:${n}!important;}`,i.prepend(s)}}catch{}if(ph(e,\"select\")&&(r=new Set(Array.from(e.options).filter(e=>e.selected))),ph(e,\"textarea\")&&(o=e.value),ph(e,\"input\")||ph(e,\"textarea\")||ph(e,\"select\")){e.disabled&&i.setAttribute(\"disabled\",\"\"),e.required&&i.setAttribute(\"required\",\"\"),e.readOnly&&i.setAttribute(\"readonly\",\"\");let t=e;void 0!==t.min&&\"\"!==t.min&&i.setAttribute(\"min\",t.min),void 0!==t.max&&\"\"!==t.max&&i.setAttribute(\"max\",t.max),void 0!==t.pattern&&\"\"!==t.pattern&&i.setAttribute(\"pattern\",t.pattern);let n=e.getAttribute(\"aria-invalid\");null!==n&&i.setAttribute(\"aria-invalid\",n)}if(Uf(e)||qf(e,i,t,n),a&&a(),n.captureSelection&&(ph(e,\"input\")||ph(e,\"textarea\")))try{mb(e,i)}catch(e){Pg(t,\"inlineTextFieldSelection failed\",e)}if(gh(e)&&!Uf(e)){let t=[\"fill\",\"stroke\",\"stroke-width\",\"stroke-dasharray\",\"stroke-dashoffset\",\"stroke-linecap\",\"stroke-linejoin\",\"stroke-miterlimit\",\"opacity\",\"fill-opacity\",\"stroke-opacity\",\"fill-rule\",\"clip-rule\",\"marker\",\"marker-start\",\"marker-mid\",\"marker-end\",\"visibility\",\"display\",\"color\"];try{let n=window.getComputedStyle(e);for(let e of t){let t=n.getPropertyValue(e);t&&i.style.setProperty(e,t)}}catch{}}if(e.shadowRoot){tf(e.shadowRoot);try{let t=e.shadowRoot.querySelectorAll(\"slot\");for(let e of t){let t=e.assignedNodes?.()||[];for(let e of t)s.add(e)}}catch{}let r=function(e){return e.shadowScopeSeq=(e.shadowScopeSeq||0)+1,`s${e.shadowScopeSeq}`}(t),o=`[data-sd=\"${r}\"]`;t.shadowScopes||=new WeakMap,t.shadowScopes.set(e.shadowRoot,r);try{i.setAttribute(\"data-sd\",r)}catch{}let a=function(e){let t=\"\";try{e.querySelectorAll(\"style\").forEach(e=>{let n=null;try{n=e.sheet&&e.sheet.cssRules}catch{}t+=(n?Xf(n):e.textContent||\"\")+\"\\n\"});let n=e.adoptedStyleSheets||[];for(let e of n)try{e&&e.cssRules&&(t+=Xf(e.cssRules))}catch{}}catch{}return t}(e.shadowRoot);!t.__shadowPseudo&&/::?(?:before|after|first-l|marker)|counter/.test(a)&&(t.__shadowPseudo=!0);let l=Yf(a,o,r),c=function(e){let t=new Set;if(!e)return t;let n,i=/var\\(\\s*(--[A-Za-z0-9_-]+)\\b/g;for(;n=i.exec(e);)t.add(n[1]);return t}(a),d=function(e,t,n){let i=[];for(let n of t){let t=Qf(e,n);t&&i.push(`${n}: ${t};`)}return i.length?`${n}{${i.join(\"\")}}\\n`:\"\"}(e,c,o);!function(e,t,n){if(!t)return;let i=document.createElement(\"style\");i.setAttribute(\"data-sd\",n),i.textContent=t,e.insertBefore(i,e.firstChild||null)}(i,d+l,r);let u=document.createDocumentFragment(),p=await Promise.all(Array.from(e.shadowRoot.childNodes).map(e=>e.nodeType===Node.ELEMENT_NODE&&\"STYLE\"===e.tagName?null:Cb(e,t,n).catch(()=>null)));u.append(...p.filter(e=>!!e)),i.appendChild(u)}if(\"SLOT\"===e.tagName){let i=t.shadowScopes?.get(e.getRootNode()),s=e.assignedNodes?.()||[],r=s.length?e.assignedNodes?.({flatten:!0})||s:[],o=r.length?r:Array.from(e.childNodes),a=document.createDocumentFragment(),l=await Promise.all(o.map(e=>Cb(e,t,n).then(e=>(e&&s.length&&function(e,t){if(!e)return;let n=e=>{let n=e.getAttribute(\"data-sd-slotted\")||\"\";t?` ${n} `.includes(` ${t} `)||e.setAttribute(\"data-sd-slotted\",n?`${n} ${t}`:t):e.setAttribute(\"data-sd-slotted\",n)};e.nodeType===Node.ELEMENT_NODE&&n(e),e.querySelectorAll?.(\"*\").forEach(n)}(e,i),e||null)).catch(()=>null)));return a.append(...l.filter(e=>!!e)),a}let l=await Promise.all(Array.from(e.childNodes).map(i=>(t=>s.has(t)||e.shadowRoot&&!t.assignedSlot)(i)?null:Cb(i,t,n).catch(()=>null)));if(i.append(...l.filter(e=>!!e)),r&&ph(i,\"select\")){let e=!1;for(let n of i.options){let i=r.has(t.nodeMap.get(n));n.selected=i,i?n.setAttribute(\"selected\",\"\"):n.removeAttribute(\"selected\"),e||=i}if(!e&&!i.multiple){let e=i.ownerDocument.createElement(\"option\");e.hidden=!0,e.style.setProperty(\"display\",\"none\",\"important\"),e.setAttribute(\"selected\",\"\"),e.value=\"\",i.appendChild(e)}}return null!==o&&ph(i,\"textarea\")&&(i.textContent=o),i}function Eb(e){try{let t=Math.max(1,Math.min(32,e.width)),n=Math.max(1,Math.min(32,e.height)),i=document.createElement(\"canvas\");i.width=t,i.height=n;let s=i.getContext(\"2d\",{willReadFrequently:!0});if(!s)return!1;s.drawImage(e,0,0,t,n);let r=s.getImageData(0,0,t,n).data;for(let e=3;e<r.length;e+=4)if(0!==r[e])return!1;return!0}catch{return!1}}async function Mb(e,t,n){let i=e.getAttribute(\"data\")||e.getAttribute(\"src\")||\"\",s=(e.getAttribute(\"type\")||\"\").toLowerCase(),r=/^image\\//.test(s)||/\\.(png|jpe?g|gif|webp|avif|bmp|ico|svg)(\\?|#|$)/i.test(i);if(i&&r){let s=document.createElement(\"img\");try{s.decoding=\"sync\",s.loading=\"eager\"}catch{}s.src=i;let{width:r,height:o}=Zf(e);return r>0&&(s.style.width=`${r}px`),o>0&&(s.style.height=`${o}px`),t.nodeMap.set(s,e),qf(e,s,t,n),s}let o=null;try{o=e.contentDocument}catch{}if(o)try{let i=await eb(e,t,n);if(i)return i}catch{}i&&console.warn(`[snapdom] <${e.localName}> content could not be captured (${s||\"unknown type\"}): rendering its fallback children`)}yb(\"IFRAME\",async function(e,t,n){let i=!1;try{i=!(!e.contentDocument&&!e.contentWindow?.document)}catch(e){Pg(t,\"iframe same-origin probe failed\",e)}if(i)try{return await eb(e,t,n)}catch(e){console.warn(\"[SnapDOM] iframe rasterization failed, fallback:\",e)}if(i||console.warn(\"[snapdom] cross-origin <iframe> skipped (its document cannot be read). Captured as a placeholder that keeps the frame's box; pass { placeholders: false } for an invisible spacer.\",e),n.placeholders){let{width:i,height:s}=Zf(e),r=document.createElement(\"div\");return r.style.cssText=`width:${i}px;height:${s}px;background-image:repeating-linear-gradient(45deg,#ddd,#ddd 5px,#f9f9f9 5px,#f9f9f9 10px);display:flex;align-items:center;justify-content:center;font-size:12px;color:#555;border:1px solid #aaa;`,qf(e,r,t,n),r}{let{width:i,height:s}=Zf(e),r=document.createElement(\"div\");return r.style.cssText=`display:inline-block;width:${i}px;height:${s}px;visibility:hidden;`,qf(e,r,t,n),r}}),yb(\"CANVAS\",async function(e,t,n){let i=\"\";try{let t=Eb(e);t&&(await _g(),t=Eb(e));let n=null;if(!t){n=e.getContext(\"2d\",{willReadFrequently:!0});try{n&&n.getImageData(0,0,1,1)}catch{}Ig()&&await _g()}if(i=e.toDataURL(\"image/png\"),!i||\"data:,\"===i){try{n&&n.getImageData(0,0,1,1)}catch{}if(await _g(),i=e.toDataURL(\"image/png\"),!i||\"data:,\"===i){let t=document.createElement(\"canvas\");t.width=e.width,t.height=e.height;let n=t.getContext(\"2d\");n&&(n.drawImage(e,0,0),i=t.toDataURL(\"image/png\"))}}}catch(e){Pg(t,\"Canvas toDataURL failed, using empty/fallback\",e)}n&&n.debug&&i&&Eb(e)&&Pg(t,\"canvas is empty at capture time — capture it after its first frame is drawn\",e);let s=document.createElement(\"img\");try{s.decoding=\"sync\",s.loading=\"eager\"}catch(e){Pg(t,\"img decoding/loading hints failed\",e)}i&&(s.src=i),s.width=e.width,s.height=e.height;let{width:r,height:o}=Zf(e);return r>0&&(s.style.width=`${r}px`),o>0&&(s.style.height=`${o}px`),t.nodeMap.set(s,e),qf(e,s,t,n),s}),yb(\"VIDEO\",async function(e,t,n){let i=\"\",s=e.poster&&e.paused&&!e.currentTime&&!e.played.length,r=document.createElement(\"img\");try{r.decoding=\"sync\",r.loading=\"eager\"}catch{}if(!s)try{let t=document.createElement(\"canvas\");t.width=e.videoWidth||e.offsetWidth||320,t.height=e.videoHeight||e.offsetHeight||240;let n=t.getContext(\"2d\");n&&(n.drawImage(e,0,0,t.width,t.height),i=t.toDataURL(function(e,t,n){try{let i=e.getImageData(0,0,t,n).data;for(let e=3;e<i.length;e+=4)if(255!==i[e])return!1;return!0}catch{return!1}}(n,t.width,t.height)?\"image/jpeg\":\"image/png\",.95),(!i||\"data:,\"===i)&&(i=\"\"))}catch(e){Pg(t,\"Video frame capture failed, using poster fallback\",e)}i?r.src=i:e.poster&&(r.src=e.poster),r.width=e.videoWidth||e.offsetWidth||0,r.height=e.videoHeight||e.offsetHeight||0;let{width:o,height:a}=Zf(e);return o>0&&(r.style.width=`${o}px`),a>0&&(r.style.height=`${a}px`),r.style.objectFit=\"contain\",t.nodeMap.set(r,e),qf(e,r,t,n),r}),yb(\"AUDIO\",async function(e,t,n){if(!e.controls)return;let{width:i,height:s}=Zf(e),r=Math.round(i||e.offsetWidth||300),o=Math.round(s||e.offsetHeight||54),a=o/2,l=Math.max(4,.16*o),c=.34*o,d=r-.34*o,u=c+l+.55*o,p=Math.max(0,d-.7*o-u),h=Math.max(9,Math.round(.24*o)),g=`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${r}\" height=\"${o}\" viewBox=\"0 0 ${r} ${o}\"><rect width=\"${r}\" height=\"${o}\" rx=\"${Math.min(o/2,10)}\" fill=\"#f1f3f4\"/><path d=\"M ${c} ${a-l} L ${c+l} ${a} L ${c} ${a+l} Z\" fill=\"#5f6368\"/><rect x=\"${u}\" y=\"${a-1.5}\" width=\"${p}\" height=\"3\" rx=\"1.5\" fill=\"#bdc1c6\"/><circle cx=\"${u}\" cy=\"${a}\" r=\"${Math.max(3,.09*o)}\" fill=\"#5f6368\"/><text x=\"${d}\" y=\"${a}\" fill=\"#5f6368\" font-family=\"sans-serif\" font-size=\"${h}\" text-anchor=\"end\" dominant-baseline=\"central\">0:00</text></svg>`,m=document.createElement(\"img\");try{m.decoding=\"sync\",m.loading=\"eager\"}catch{}return m.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(g)}`,m.width=r,m.height=o,m.style.width=`${r}px`,m.style.height=`${o}px`,t.nodeMap.set(m,e),qf(e,m,t,n),m}),yb(\"OBJECT\",Mb),yb(\"EMBED\",Mb),Hg(),wh(),Ag(),ah(),ng();var Ab=[/font\\s*awesome/i,/material\\s*icons/i,/ionicons/i,/glyphicons/i,/feather/i,/bootstrap\\s*icons/i,/remix\\s*icons/i,/heroicons/i,/layui/i,/lucide/i],_b=Object.assign({materialIconsFilled:\"https://fonts.gstatic.com/s/materialicons/v48/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2\",materialIconsOutlined:\"https://fonts.gstatic.com/s/materialiconsoutlined/v110/gok-H7zzDkdnRel8-DQ6KAXJ69wP1tGnf4ZGhUcel5euIg.woff2\",materialIconsRound:\"https://fonts.gstatic.com/s/materialiconsround/v109/LDItaoyNOAY6Uewc665JcIzCKsKc_M9flwmPq_HTTw.woff2\",materialIconsSharp:\"https://fonts.gstatic.com/s/materialiconssharp/v110/oPWQ_lt5nv4pWNJpghLP75WiFR4kLh3kvmvRImcycg.woff2\"},typeof window<\"u\"&&window.__SNAPDOM_ICON_FONTS__||{});function Tb(e){return e.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}function Ib(e){let t=Array.isArray(e)?e:e?[e]:[],n=[];for(let e of t)e instanceof RegExp?n.push(e):\"string\"==typeof e?n.push(new RegExp(Tb(e),\"i\")):console.warn(\"[snapdom] Ignored invalid iconFont value:\",e);return n}function Lb(e,t){let n=\"string\"==typeof e?e:\"\";for(let e of Ab)if(e.test(n))return!0;if(t)for(let e of t)if(e instanceof RegExp&&e.test(n))return!0;return!!(/icon/i.test(n)||/glyph/i.test(n)||/symbols/i.test(n)||/feather/i.test(n)||/fontawesome/i.test(n))}function Rb(e,t){if(\"string\"!=typeof e||!e)return!1;let n;try{n=new URL(e,typeof location<\"u\"?location.href:void 0)}catch{return Lb(e,t)}let i=n.searchParams.getAll(\"family\").flatMap(e=>e.split(\"|\")).map(e=>e.split(\":\")[0].trim()).filter(Boolean);return i.length?i.every(e=>Lb(e,t)):Lb(e,t)}function $b(e=\"\"){let t=String(e).toLowerCase();return/\\bmaterial\\s*icons\\b/.test(t)||/\\bmaterial\\s*symbols\\b/.test(t)}var Nb=new Map;function Pb(e){let t=e.getPropertyValue(\"-webkit-text-fill-color\")?.trim()||\"\",n=/^transparent$/i.test(t)||/rgba?\\(\\s*0\\s*,\\s*0\\s*,\\s*0\\s*,\\s*0\\s*\\)/i.test(t);if(t&&!n&&\"currentcolor\"!==t.toLowerCase())return t;let i=e.color?.trim();return i&&\"inherit\"!==i?i:\"#000\"}async function Fb(e,{family:t=\"Material Icons\",weight:n=\"normal\",fontSize:i=32,color:s=\"#000\",variation:r=\"\",className:o=\"\"}={}){let a=String(t||\"\").replace(/^['\"]+|['\"]+$/g,\"\"),l=window.devicePixelRatio||1,c=function(e=\"\"){let t,n=Object.create(null),i=String(e||\"\"),s=/['\"]?\\s*([A-Za-z]{3,4})\\s*['\"]?\\s*([+-]?\\d+(?:\\.\\d+)?)\\s*/g;for(;t=s.exec(i);)n[t[1].toUpperCase()]=Number(t[2]);return n}(r),{familyForMeasure:d,familyForCanvas:u}=await async function(e,t,n){let i=String(e||\"\"),s=i.toLowerCase(),r=String(t||\"\").toLowerCase();if(/\\bmaterial\\s*icons\\b/.test(s)&&!/\\bsymbols\\b/.test(s))return{familyForMeasure:i,familyForCanvas:i};if(!/\\bmaterial\\s*symbols\\b/.test(s))return{familyForMeasure:i,familyForCanvas:i};let o=n&&(n.FILL??n.fill),a=\"outlined\";/\\brounded\\b/.test(r)||/\\bround\\b/.test(r)?a=\"rounded\":/\\bsharp\\b/.test(r)?a=\"sharp\":/\\boutlined\\b/.test(r)&&(a=\"outlined\");let l=null;if(1===o&&(\"outlined\"===a&&_b.materialIconsFilled?l={url:_b.materialIconsFilled,alias:\"snapdom-mi-filled\"}:\"rounded\"===a&&_b.materialIconsRound?l={url:_b.materialIconsRound,alias:\"snapdom-mi-round\"}:\"sharp\"===a&&_b.materialIconsSharp&&(l={url:_b.materialIconsSharp,alias:\"snapdom-mi-sharp\"})),!l)return{familyForMeasure:i,familyForCanvas:i};if(!Nb.has(l.alias))try{let e=new FontFace(l.alias,`url(${l.url})`,{style:\"normal\",weight:\"400\"});await e.load(),document.fonts.add(e),Nb.set(l.alias,!0)}catch{return Nb.set(l.alias,!1),{familyForMeasure:i,familyForCanvas:i}}if(!1===Nb.get(l.alias))return{familyForMeasure:i,familyForCanvas:i};let c=`\"${l.alias}\"`;return{familyForMeasure:c,familyForCanvas:c}}(a,o,c);await async function(e=\"Material Icons\",t=24){try{await Promise.all([document.fonts.load(`400 ${t}px \"${String(e).replace(/[\"']/g,\"\")}\"`),document.fonts.ready])}catch{}}(u.replace(/^[\"']+|[\"']+$/g,\"\"),i);let p=document.createElement(\"span\");Zh(p),p.textContent=e,p.style.position=\"absolute\",p.style.visibility=\"hidden\",p.style.left=\"-99999px\",p.style.whiteSpace=\"nowrap\",p.style.fontFamily=d,p.style.fontWeight=String(n||\"normal\"),p.style.fontSize=`${i}px`,p.style.lineHeight=\"1\",p.style.margin=\"0\",p.style.padding=\"0\",p.style.fontFeatureSettings=\"'liga' 1\",p.style.fontVariantLigatures=\"normal\",p.style.color=s,document.body.appendChild(p);let h=p.getBoundingClientRect(),g=Math.max(1,Math.ceil(h.width)),m=Math.max(1,Math.ceil(h.height));document.body.removeChild(p);let f=document.createElement(\"canvas\");f.width=g*l,f.height=m*l;let b=f.getContext(\"2d\");b.scale(l,l),b.font=`${n?`${n} `:\"\"}${i}px ${u}`,b.textAlign=\"left\",b.textBaseline=\"top\",b.fillStyle=s;try{b.fontKerning=\"normal\"}catch{}return b.fillText(e,0,0),{dataUrl:f.toDataURL(),width:g,height:m}}async function Ob(e,t,n=new Map){if(1!==e?.nodeType)return 0;let i='.material-icons, [class*=\"material-symbols\"]',s=Array.from(e.querySelectorAll(i)).filter(e=>e&&e.textContent&&e.textContent.trim());if(e.matches?.(i)&&e.textContent&&e.textContent.trim()&&s.unshift(e),0===s.length)return 0;let r=1===t?.nodeType?Array.from(t.querySelectorAll(i)).filter(e=>e&&e.textContent&&e.textContent.trim()):[];1===t?.nodeType&&t.matches?.(i)&&t.textContent&&t.textContent.trim()&&r.unshift(t);let o=0;for(let e=0;e<s.length;e++){let t=s[e],i=n&&n.get(t)||r[e]||null;try{let e=getComputedStyle(i||t),n=e.fontFamily||\"Material Icons\";if(!$b(n))continue;let s=(i||t).textContent.trim();if(!s)continue;let r=parseInt(e.fontSize,10)||24,a=e.fontWeight&&\"normal\"!==e.fontWeight?e.fontWeight:\"normal\",l=Pb(e),c=e.fontVariationSettings&&\"normal\"!==e.fontVariationSettings?e.fontVariationSettings:\"\",d=(i||t).className||\"\",{dataUrl:u,width:p,height:h}=await Fb(s,{family:n,weight:a,fontSize:r,color:l,variation:c,className:d});t.textContent=\"\";let g=t.ownerDocument.createElement(\"img\");g.src=u,g.alt=s,g.style.height=`${r}px`,g.style.width=`${Math.max(1,Math.round(p/h*r))}px`,g.style.objectFit=\"contain\",g.style.verticalAlign=getComputedStyle(t).verticalAlign||\"baseline\",t.appendChild(g),o++}catch{}}return o}async function qb(e,t,n,i=32,s=\"#000\",r=\"normal\"){t=t.replace(/^['\"]+|['\"]+$/g,\"\");let o=window.devicePixelRatio||1;try{await document.fonts.ready}catch{}let a=document.createElement(\"span\");Zh(a),a.textContent=e,a.style.position=\"absolute\",a.style.visibility=\"hidden\",a.style.fontFamily=`\"${t}\"`,a.style.fontWeight=n||\"normal\",a.style.fontStyle=r||\"normal\",a.style.fontSize=`${i}px`,a.style.lineHeight=\"1\",a.style.whiteSpace=\"nowrap\",a.style.padding=\"0\",a.style.margin=\"0\",document.body.appendChild(a);let l=a.getBoundingClientRect(),c=Math.ceil(l.width),d=Math.ceil(l.height);document.body.removeChild(a);let u=document.createElement(\"canvas\");u.width=Math.max(1,c*o),u.height=Math.max(1,d*o);let p=u.getContext(\"2d\");return p.scale(o,o),p.font=`${r||\"normal\"} ${n||\"normal\"} ${i}px \"${t}\"`,p.textAlign=\"left\",p.textBaseline=\"top\",p.fillStyle=s,p.fillText(e,0,0),{dataUrl:u.toDataURL(),width:c,height:d}}Lh(),Ng(),ng();var Hb=new Set([\"serif\",\"sans-serif\",\"monospace\",\"cursive\",\"fantasy\",\"system-ui\",\"emoji\",\"math\",\"fangsong\",\"ui-serif\",\"ui-sans-serif\",\"ui-monospace\",\"ui-rounded\"]),Bb=[\"katex\",\"mathjax\",\"mathml\"];function Db(e){if(!e)return\"\";for(let t of e.split(\",\")){let e=t.trim().replace(/^['\"]+|['\"]+$/g,\"\");if(e&&!Hb.has(e.toLowerCase()))return e}return\"\"}function zb(e){let t=String(e??\"400\").trim().toLowerCase();if(\"normal\"===t)return 400;if(\"bold\"===t)return 700;let n=parseInt(t,10);return Number.isFinite(n)?Math.min(900,Math.max(100,n)):400}function Ub(e){let t=String(e??\"normal\").trim().toLowerCase();return t.startsWith(\"italic\")?\"italic\":t.startsWith(\"oblique\")?\"oblique\":\"normal\"}function jb(e){let t=String(e??\"100%\").match(/(\\d+(?:\\.\\d+)?)\\s*%/);return t?Math.max(50,Math.min(200,parseFloat(t[1]))):100}function Wb(e){return e&&\"string\"==typeof e?e.replace(/\\s+(variable|vf|v[0-9]+)$/i,\"\").trim().toLowerCase().replace(/\\s+/g,\"-\"):\"\"}function Vb(e,t,n=[]){if(!e)return!1;try{let i=new URL(e,location.href);if(i.origin===location.origin)return!0;let s=i.host.toLowerCase();if([\"fonts.googleapis.com\",\"fonts.gstatic.com\",\"use.typekit.net\",\"p.typekit.net\",\"kit.fontawesome.com\",\"use.fontawesome.com\",\"cdn.jsdelivr.net\",\"unpkg.com\",\"cdnjs.cloudflare.com\",\"esm.sh\"].some(e=>s.endsWith(e))||n.some(e=>s===e.toLowerCase()||s.endsWith(\".\"+e.toLowerCase())))return!0;let r=(i.pathname+i.search).toLowerCase();if(/\\bfont(s)?\\b/.test(r)||/\\.woff2?(\\b|$)/.test(r)||Bb.some(e=>r.includes(e)))return!0;for(let e of t){let t=e.toLowerCase().replace(/\\s+/g,\"+\"),n=e.toLowerCase().replace(/\\s+/g,\"-\"),i=Wb(e);if(r.includes(t)||r.includes(n)||i&&r.includes(i))return!0}return!1}catch{return!1}}function Gb(e,t){return e&&e.replace(/url\\(\\s*(['\"]?)([^)'\"]+)\\1\\s*\\)/g,(e,n,i)=>{let s=(i||\"\").trim();if(!s||/^data:|^blob:|^https?:|^file:|^about:/i.test(s))return e;let r=s;try{r=new URL(s,t||location.href).href}catch{}return`url(\"${r}\")`})}var Kb=/@import\\s+(?:url\\(\\s*(['\"]?)([^)\"']+)\\1\\s*\\)|(['\"])([^\"']+)\\3)([^;]*);/g;async function Yb(e,t,n){if(!e)return e;let i=new Set;function s(e,t){try{return new URL(e,t||location.href).href}catch{return e}}let r=Gb(e,t||location.href);return r=await async function e(t,r,o=0){if(o>4)return console.warn(`[snapDOM] @import depth exceeded (4) at ${r}`),t;let a,l=\"\",c=0,d=new RegExp(Kb.source,\"g\");for(;a=d.exec(t);){l+=t.slice(c,a.index),c=d.lastIndex;let u=s((a[2]||a[4]||\"\").trim(),r);if(i.has(u)){console.warn(`[snapDOM] Skipping circular @import: ${u}`);continue}i.add(u);let p=\"\";try{let e=await Mh(u,{as:\"text\",useProxy:n,silent:!0});e.ok&&\"string\"==typeof e.data&&(p=e.data)}catch{}p?(p=Gb(p,u),p=await e(p,u,o+1),l+=`\\n/* inlined: ${u} */\\n${p}\\n`):l+=a[0]}return l+=t.slice(c),l}(r,t||location.href,0),r}var Xb=/url\\(([\"']?)([^\"')]+)\\1\\)/g,Jb=/@font-face[^{}]*\\{[^}]*\\}/g;function Qb(e,t,n=\"\"){return(e.match(new RegExp(`${t}\\\\s*:\\\\s*([^;}]+)[;}]`,\"i\"))?.[1]||n).trim()}function Zb(e){if(!e)return[];let t=[],n=e.split(\",\").map(e=>e.trim()).filter(Boolean);for(let e of n){let n=e.match(/^U\\+([0-9A-Fa-f?]+)(?:-([0-9A-Fa-f?]+))?$/);if(!n)continue;let i=n[1],s=n[2],r=e=>{if(!e.includes(\"?\"))return parseInt(e,16);return[parseInt(e.replace(/\\?/g,\"0\"),16),parseInt(e.replace(/\\?/g,\"F\"),16)]};if(s){let e=r(i),n=r(s),o=Array.isArray(e)?e[0]:e,a=Array.isArray(n)?n[1]:n;t.push([Math.min(o,a),Math.max(o,a)])}else{let e=r(i);Array.isArray(e)?t.push([e[0],e[1]]):t.push([e,e])}}return t}function ey(e,t){if(!t.length||!e||0===e.size)return!0;for(let n of e)for(let[e,i]of t)if(n>=e&&n<=i)return!0;return!1}function ty(e,t){let n=[];if(!e)return n;for(let i of e.matchAll(Xb)){let e=(i[2]||\"\").trim();if(e&&!e.startsWith(\"data:\")){if(!/^https?:/i.test(e))try{e=new URL(e,t||location.href).href}catch{}n.push(e)}}return n}async function ny(e,t,n=\"\",i){let s=e;for(let r of e.matchAll(Xb)){let e=lh(r[0]);if(!e)continue;let o=e;if(!o.startsWith(\"http\")&&!o.startsWith(\"data:\"))try{o=new URL(o,t||location.href).href}catch{}if(!Lb(o,i)){if(oh.resource?.has(o)){s=s.replace(r[0],`url(${oh.resource.get(o)})`);continue}try{let e=await Mh(o,{as:\"dataURL\",useProxy:n,silent:!0});if(e.ok&&\"string\"==typeof e.data){let t=e.data;oh.resource?.set(o,t),s=s.replace(r[0],`url(${t})`)}}catch{console.warn(\"[snapDOM] Failed to fetch font resource:\",o)}}}return s}function iy(e={}){let t=new Set((e.families||[]).map(e=>String(e).toLowerCase())),n=new Set((e.domains||[]).map(e=>String(e).toLowerCase())),i=new Set((e.subsets||[]).map(e=>String(e).toLowerCase()));return(e,s)=>{if(t.size&&t.has(e.family.toLowerCase()))return!0;if(n.size)for(let t of e.srcUrls)try{if(n.has(new URL(t).host.toLowerCase()))return!0}catch{}if(i.size){let e=function(e){if(!e.length)return null;let t=(t,n)=>e.some(([e,i])=>!(i<t||e>n)),n=t(0,255)||t(305,305),i=t(256,591)||t(7680,7935),s=t(880,1023),r=t(1024,1279);return t(7840,7929)||t(258,259)||t(416,417)||t(431,432)?\"vietnamese\":r?\"cyrillic\":s?\"greek\":i?\"latin-ext\":n?\"latin\":null}(s);if(e&&i.has(e))return!0}return!1}}var sy=new WeakMap,ry=0;function oy(e,t,n,i,s,r,o,a,l){let c=Array.from(e||[]).sort().join(\"|\"),d=0,u=0;for(let e of o||[]){let t=Math.imul(e,2654435761);t^=t>>>15,t=Math.imul(t,2246822507),t^=t>>>13,d=d+t|0,u++}let p=t?JSON.stringify({families:(t.families||[]).map(e=>String(e).toLowerCase()).sort(),domains:(t.domains||[]).map(e=>String(e).toLowerCase()).sort(),subsets:(t.subsets||[]).map(e=>String(e).toLowerCase()).sort()}):\"\",h=(n||[]).map(e=>`${(e.family||\"\").toLowerCase()}::${e.weight||\"normal\"}::${e.style||\"normal\"}::${e.stretchPct??100}::${e.src||\"\"}`).sort().join(\"|\"),g=i||\"\",m=(s||[]).map(e=>String(e).toLowerCase()).sort().join(\"|\"),f=function(e){let t=sy.get(e);return void 0===t&&(t=ry++,sy.set(e,t)),t}(r||document),b=(a||[]).map(e=>String(e)).sort().join(\"|\");return`fonts-embed-css::req=${c}::ex=${p}::lf=${h}::px=${g}::fd=${m}::doc=${f}::cp=${d}::n=${u}::ic=${b}::env=${l}`}async function ay(e,t,n,i){let s,r=i.doc?.defaultView||window;if(e.disabled||e.media?.mediaText&&!r.matchMedia(e.media.mediaText).matches)return;try{s=e.cssRules||[]}catch{return}let o=(e,t)=>{try{return new URL(e,t||location.href).href}catch{return e}};for(let e of s){if(e.type===CSSRule.IMPORT_RULE&&e.styleSheet){let s=e.href?o(e.href,t):t;if(i.depth>=4){console.warn(`[snapDOM] CSSOM import depth exceeded (4) at ${s}`);continue}if(s&&i.visitedSheets.has(s)){console.warn(`[snapDOM] Skipping circular CSSOM import: ${s}`);continue}s&&i.visitedSheets.add(s);let r={...i,depth:(i.depth||0)+1};await ay(e.styleSheet,s,n,r);continue}if(e.cssRules?.length){if(e.type===CSSRule.MEDIA_RULE&&!r.matchMedia(e.conditionText).matches||e.type===CSSRule.SUPPORTS_RULE&&!r.CSS.supports(e.conditionText))continue;await ay(e,t,n,i)}else if(e.type===CSSRule.FONT_FACE_RULE){let s=Db((e.style.getPropertyValue(\"font-family\")||\"\").trim());if(!s||Lb(s,i.iconMatchers))continue;let r=(e.style.getPropertyValue(\"font-weight\")||\"\").trim(),o=(e.style.getPropertyValue(\"font-style\")||\"\").trim(),a=(e.style.getPropertyValue(\"font-stretch\")||\"\").trim(),l=(e.style.getPropertyValue(\"font-variation-settings\")||\"\").trim(),c=(e.style.getPropertyValue(\"src\")||\"\").trim(),d=(e.style.getPropertyValue(\"unicode-range\")||\"\").trim(),u=r||\"400\",p=o||\"normal\",h=a||\"100%\",g=(o?`font-style:${o};`:\"\")+(r?`font-weight:${r};`:\"\")+(a?`font-stretch:${a};`:\"\")+(l?`font-variation-settings:${l};`:\"\")+(d?`unicode-range:${d};`:\"\"),m=i.faceMatchesRequired(s,p,u,h);if(!m&&!i.requiredIndex.has(s.toLowerCase()))continue;let f=Zb(d);if(!ey(i.usedCodepoints,f))continue;let b={family:s,weightSpec:u,styleSpec:p,stretchSpec:h,unicodeRange:d,srcRaw:c,srcUrls:ty(c,t||location.href),href:t||location.href};if(i.simpleExcluder&&i.simpleExcluder(b,f))continue;if(!m){i.provisionalFaces.push({family:s.toLowerCase(),block:`@font-face{font-family:${s};src:${c};${g}}`,srcRaw:c,baseHref:t||location.href});continue}i.coveredFamilies.add(s.toLowerCase());let y=`\"${String(s).replace(/^\\s*[\"']|[\"']\\s*$/g,\"\").replace(/([\"\\\\])/g,\"\\\\$1\")}\"`;if(/url\\(/i.test(c)){let e=await ny(c,t||location.href,i.useProxy,i.iconMatchers);await n(`@font-face{font-family:${y};src:${e};${g}}`)}else await n(`@font-face{font-family:${y};src:${c};${g}}`)}}}async function ly({required:e,usedCodepoints:t,exclude:n,localFonts:i=[],useProxy:s=\"\",fontStylesheetDomains:r=[],iconMatchers:o=[],doc:a=document}={}){e instanceof Set||(e=new Set),t instanceof Set||(t=new Set);let l=new Map;for(let t of e){let[e,n,i,s]=String(t).split(\"__\");if(!e)continue;let r=e.toLowerCase(),o=l.get(r)||[];o.push({w:parseInt(n,10),s:i,st:parseInt(s,10)}),l.set(r,o)}function c(e,t,n,i){let s=String(e).toLowerCase();if(!l.has(s))return!1;let r=l.get(s),o=function(e){let t=String(e||\"400\").trim(),n=t.match(/^(\\d{2,3})\\s+(\\d{2,3})$/);if(n){let e=zb(n[1]),t=zb(n[2]);return{min:Math.min(e,t),max:Math.max(e,t)}}let i=zb(t);return{min:i,max:i}}(n),a=function(e){let t=String(e||\"normal\").trim().toLowerCase();return\"italic\"===t?{kind:\"italic\"}:t.startsWith(\"oblique\")?{kind:\"oblique\"}:{kind:\"normal\"}}(t),c=function(e){let t=String(e||\"100%\").trim(),n=t.match(/(\\d+(?:\\.\\d+)?)\\s*%\\s+(\\d+(?:\\.\\d+)?)\\s*%/);if(n){let e=parseFloat(n[1]),t=parseFloat(n[2]);return{min:Math.min(e,t),max:Math.max(e,t)}}let i=t.match(/(\\d+(?:\\.\\d+)?)\\s*%/),s=i?parseFloat(i[1]):100;return{min:s,max:s}}(i),d=o.min!==o.max,u=o.min,p=e=>\"normal\"===a.kind&&\"normal\"===e||\"normal\"!==a.kind&&(\"italic\"===e||\"oblique\"===e),h=!1;for(let e of r){let t=d?e.w>=o.min&&e.w<=o.max:e.w===u,n=p(Ub(e.s)),i=e.st>=c.min&&e.st<=c.max;if(t&&n&&i){h=!0;break}}if(h)return!0;if(!d)for(let e of r){let t=p(Ub(e.s)),n=e.st>=c.min&&e.st<=c.max;if(Math.abs(u-e.w)<=300&&t&&n)return!0}if(!d&&\"normal\"===a.kind&&r.some(e=>\"normal\"!==Ub(e.s)))for(let e of r){let t=Math.abs(u-e.w)<=300,n=e.st>=c.min&&e.st<=c.max;if(t&&n)return!0}return!1}let d=iy(n);qm(a),uf();let u=oy(e,n,i,s,r,a,t,o,qm(a));if(oh.resource?.has(u))return oh.resource.get(u);let p=function(e){let t=new Set;for(let n of e||[]){let e=String(n).split(\"__\")[0]?.trim();e&&t.add(e)}return t}(e),h=[],g=Kb;for(let e of a.querySelectorAll(\"style\")){let t=e.textContent||\"\";for(let e of t.matchAll(g)){let t=(e[2]||e[4]||\"\").trim();t&&!Rb(t,o)&&(a.querySelector(`link[rel=\"stylesheet\"][href=\"${t}\"]`)||h.push(t))}}let m=[];h.length&&await Promise.all(h.map(e=>new Promise(t=>{if(a.querySelector(`link[rel=\"stylesheet\"][href=\"${e}\"]`))return t(null);let n=a.createElement(\"link\");n.rel=\"stylesheet\",n.href=e,Zh(n),n.setAttribute(\"data-snapdom\",\"injected-import\");let i=setTimeout(()=>t(null),3e3),s=e=>{clearTimeout(i),t(e)};n.onload=()=>s(n),n.onerror=()=>s(null),a.head.appendChild(n),m.push(n)})));let f=\"\",b=new Set,y=[],v=Array.from(a.querySelectorAll('link[rel=\"stylesheet\"]')).filter(e=>!!e.href);for(let e of m)try{e.remove()}catch{}for(let e of v)try{if(Rb(e.href,o))continue;let i=\"\",u=!1;try{u=new URL(e.href,location.href).origin===location.origin}catch{}if(!u){let t=Array.isArray(r)?r:[];if(!Vb(e.href,p,t))continue}if(u){let t=Array.from(a.styleSheets).find(t=>t.href===e.href);if(t)try{let e=t.cssRules||[];i=Array.from(e).map(e=>e.cssText).join(\"\")}catch{}}if(!i){let t=await Mh(e.href,{as:\"text\",useProxy:s});t?.ok&&\"string\"==typeof t.data&&(i=t.data)}i=await Yb(i,e.href,s);let h=\"\";for(let r of i.match(Jb)||[]){let i=Db(Qb(r,\"font-family\"));if(!i||Lb(i,o))continue;let a=Qb(r,\"font-weight\",\"400\"),u=Qb(r,\"font-style\",\"normal\"),p=Qb(r,\"font-stretch\",\"100%\"),g=Qb(r,\"unicode-range\"),m=Qb(r,\"src\"),f=ty(m,e.href),v=c(i,u,a,p);if(!v&&!l.has(i.toLowerCase()))continue;let w=Zb(g);if(!ey(t,w))continue;let x={family:i,weightSpec:a,styleSpec:u,stretchSpec:p,unicodeRange:g,srcRaw:m,srcUrls:f,href:e.href};n&&d(x,w)||(v?(b.add(i.toLowerCase()),h+=/url\\(/i.test(m)?await ny(r,e.href,s,o):r):y.push({family:i.toLowerCase(),block:r,srcRaw:m,baseHref:e.href}))}h.trim()&&(f+=h)}catch{console.warn(\"[snapDOM] Failed to process stylesheet:\",e.href)}let w={doc:a,requiredIndex:l,usedCodepoints:t,faceMatchesRequired:c,coveredFamilies:b,provisionalFaces:y,simpleExcluder:n?iy(n):null,useProxy:s,iconMatchers:o,visitedSheets:new Set,depth:0},x=new Set([...a.styleSheets,...a.adoptedStyleSheets||[]]);for(let e of x)if(!e.href||!v.some(t=>t.href===e.href))try{let t=e.href||a.baseURI||location.origin+\"/\";t&&w.visitedSheets.add(t),await ay(e,t,async e=>{f+=e},w)}catch{}for(let e of y)b.has(e.family)||(f+=/url\\(/i.test(e.srcRaw)?await ny(e.block,e.baseHref,s,o):e.block);try{for(let e of a.fonts||[]){if(!e||!e.family||\"loaded\"!==e.status||!e._snapdomSrc)continue;let t=String(e.family).replace(/^['\"]+|['\"]+$/g,\"\");if(Lb(t,o)||!l.has(t.toLowerCase())||n?.families&&n.families.some(e=>String(e).toLowerCase()===t.toLowerCase()))continue;let i=e._snapdomSrc;if(!String(i).startsWith(\"data:\"))if(oh.resource?.has(e._snapdomSrc))i=oh.resource.get(e._snapdomSrc);else try{let t=await Mh(e._snapdomSrc,{as:\"dataURL\",useProxy:s,silent:!0});if(!t.ok||\"string\"!=typeof t.data)continue;i=t.data,oh.resource?.set(e._snapdomSrc,i)}catch{console.warn(\"[snapDOM] Failed to fetch dynamic font src:\",e._snapdomSrc);continue}f+=`@font-face{font-family:'${t}';src:url(${i});font-style:${e.style||\"normal\"};font-weight:${e.weight||\"normal\"};}`}}catch{}for(let e of i){if(!e||\"object\"!=typeof e)continue;let t=String(e.family||\"\").replace(/^['\"]+|['\"]+$/g,\"\");if(!t||Lb(t,o)||!l.has(t.toLowerCase())||n?.families&&n.families.some(e=>String(e).toLowerCase()===t.toLowerCase()))continue;let i=null!=e.weight?String(e.weight):\"normal\",r=null!=e.style?String(e.style):\"normal\",a=null!=e.stretchPct?`${e.stretchPct}%`:\"100%\",c=String(e.src||\"\"),d=c;if(!d.startsWith(\"data:\"))if(oh.resource?.has(c))d=oh.resource.get(c);else try{let e=await Mh(c,{as:\"dataURL\",useProxy:s,silent:!0});if(!e.ok||\"string\"!=typeof e.data)continue;d=e.data,oh.resource?.set(c,d)}catch{console.warn(\"[snapDOM] Failed to fetch localFonts src:\",c);continue}f+=`@font-face{font-family:'${t}';src:url(${d});font-style:${r};font-weight:${i};font-stretch:${a};}`}return f&&(f=function(e){if(!e)return e;let t=/@font-face[^{}]*\\{[^}]*\\}/gi,n=new Set,i=[];for(let s of e.match(t)||[]){let e=Db(Qb(s,\"font-family\")),t=Qb(s,\"font-weight\",\"400\"),r=Qb(s,\"font-style\",\"normal\"),o=Qb(s,\"font-stretch\",\"100%\"),a=Qb(s,\"unicode-range\"),l=Qb(s,\"src\"),c=ty(l,location.href),d=c.length?c.map(e=>String(e).toLowerCase()).sort().join(\"|\"):l.toLowerCase(),u=[String(e||\"\").toLowerCase(),t,r,o,a.toLowerCase(),d].join(\"|\");n.has(u)||(n.add(u),i.push(s))}if(0===i.length)return e;let s=0;return e.replace(t,()=>i[s++]||\"\")}(f),oh.resource?.set(u,f)),f}function cy(e,t){let n=new Set,i=new Set;if(!e)return{required:n,usedCodepoints:i};let s=e=>{if(e)for(let t of e)i.add(t.codePointAt(0))},r=e=>{let t=function(e){if(!e)return[];let t=[];for(let n of e.split(\",\")){let e=n.trim().replace(/^['\"]+|['\"]+$/g,\"\");e&&(Hb.has(e.toLowerCase())||t.push(e))}return t}(e.fontFamily);if(t.length)for(let i of t)n.add(`${i}__${zb(e.fontWeight)}__${Ub(e.fontStyle)}__${jb(e.fontStretch)}`)},o=xf(e),a=e.getRootNode(),l=e=>{r(cg(e));let t=e.getRootNode()===a?o:xf(e);for(let n of[\"::before\",\"::after\"]){let o=\"::before\"===n?t.before:t.after;if(null!==o){if(\"\"===o)continue;try{if(!e.matches(o))continue}catch{}}let a=cg(e,n),l=a&&a.content;if(l&&\"none\"!==l&&\"normal\"!==l)if(r(a),/^[\"']/.test(l))s(l.slice(1,-1));else{let e=l.match(/\\\\[0-9A-Fa-f]{1,6}/g);if(e)for(let t of e)try{i.add(parseInt(t.slice(1),16))}catch{}}}},c=[e];for(let n=0;n<c.length;n++){let i=c[n];i.nodeType===Node.ELEMENT_NODE&&l(i),i.shadowRoot&&c.push(i.shadowRoot);let r=(e.ownerDocument||document).createTreeWalker(i,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT,null);for(;r.nextNode();){let e=r.currentNode;if(e.nodeType===Node.TEXT_NODE){if(t&&e.parentElement&&!t(e.parentElement))continue;s(e.nodeValue||\"\")}else{if(t&&!t(e))continue;l(e),e.shadowRoot&&c.push(e.shadowRoot)}}}return{required:n,usedCodepoints:i}}async function dy(e,t=2,n=document){try{await n.fonts.ready}catch{}let i=Array.from(e||[]).filter(Boolean);if(0===i.length)return;let s=()=>{let e=n.createElement(\"div\");Zh(e),e.style.cssText=\"position:absolute!important;left:-9999px!important;top:0!important;opacity:0!important;pointer-events:none!important;contain:layout size style;\";for(let t of i){let i=n.createElement(\"span\");i.textContent=\"AaBbGg1234ÁÉÍÓÚçñ—∞\",i.style.fontFamily=`\"${t}\"`,i.style.fontWeight=\"700\",i.style.fontStyle=\"italic\",i.style.fontSize=\"32px\",i.style.lineHeight=\"1\",i.style.whiteSpace=\"nowrap\",i.style.margin=\"0\",i.style.padding=\"0\",e.appendChild(i)}n.body.appendChild(e),e.offsetWidth,n.body.removeChild(e)};for(let e=0;e<Math.max(1,t);e++)s(),await _g(),await _g()}function uy(e,t=!1){let n=\"\",i=Math.max(1,e);for(;i>0;)i--,n=String.fromCharCode(97+i%26)+n,i=Math.floor(i/26);return t?n.toUpperCase():n}function py(e,t=!0){let n=[[1e3,\"M\"],[900,\"CM\"],[500,\"D\"],[400,\"CD\"],[100,\"C\"],[90,\"XC\"],[50,\"L\"],[40,\"XL\"],[10,\"X\"],[9,\"IX\"],[5,\"V\"],[4,\"IV\"],[1,\"I\"]],i=Math.max(1,Math.min(3999,e)),s=\"\";for(let[e,t]of n)for(;i>=e;)s+=t,i-=e;return t?s:s.toLowerCase()}function hy(e,t){switch((t||\"decimal\").toLowerCase()){case\"decimal\":default:return String(e);case\"decimal-leading-zero\":{let t=Math.abs(e);return(e<0?\"-\":\"\")+(t<10?\"0\":\"\")+String(t)}case\"lower-alpha\":case\"lower-latin\":return uy(e,!1);case\"upper-alpha\":case\"upper-latin\":return uy(e,!0);case\"lower-roman\":return py(e,!1);case\"upper-roman\":return py(e,!0)}}function gy(e,t){let n=(e||\"\").trim().split(/[\\s,]+/).filter(Boolean),i=[];for(let e=0;e<n.length;e++){let s=n[e];if(\"none\"===s)continue;let r=n[e+1],o=void 0!==r&&Number.isFinite(Number(r));i.push([s,o?Number(r):t]),o&&e++}return i}function my(e){let t=new WeakMap,n=function(e){return 9===e?.nodeType}(e)?e.documentElement:e,i=new WeakMap,s=(e,t,n)=>{let s,r,o,a,l=(e=>{let t=new Map;for(let[n,i]of e)t.set(n,i.slice());return t})(e);try{s=getComputedStyle(n)}catch{s=n.style}try{r=s?.counterReset}catch{}if(r&&\"none\"!==r)for(let[e,n]of gy(r,0)){let i=t.get(e);if(i&&i.length){let t=i.slice();t.push(n),l.set(e,t)}else l.set(e,[n])}try{o=s?.counterSet}catch{}if(o&&\"none\"!==o)for(let[e,t]of gy(o,0)){let n=l.get(e)||[];0===n.length&&n.push(0),n[n.length-1]=t,l.set(e,n)}try{a=s?.counterIncrement}catch{}if(a&&\"none\"!==a)for(let[e,t]of gy(a,1)){let n=l.get(e)||[];0===n.length&&n.push(0),n[n.length-1]+=t,l.set(e,n)}try{if(\"list-item\"===s?.display&&(e=>e&&\"LI\"===e.tagName)(n)){let e=n.parentElement,t=e&&i.get(e),s=\"OL\"===e?.tagName?parseInt(e.getAttribute(\"start\"),10):NaN,r=void 0===t?Number.isFinite(s)?s:1:t+1,o=\"OL\"===e?.tagName?parseInt(n.getAttribute(\"value\"),10):NaN;Number.isFinite(o)&&(r=o),e&&i.set(e,r);let a=l.get(\"list-item\")||[];0===a.length&&a.push(0),a[a.length-1]=r,l.set(\"list-item\",a)}}catch{}return l},r=(e,n,i)=>{let o=s(i,n,e);t.set(e,o);let a=o;for(let t of e.children)a=r(t,o,a);let l=new Map;for(let[e,t]of i){let n=t.length,i=a.get(e);l.set(e,i&&i.length?i.slice(0,n):t.slice())}for(let[e,t]of a)!l.has(e)&&t.length&&!n.has(e)&&l.set(e,t.slice(0,1));return l},o=new Map;return r(n,o,o),{get(e,n){let i=t.get(e)?.get(n);return i&&i.length?i[i.length-1]:0},getStack(e,n){let i=t.get(e)?.get(n);return i?i.slice():[]}}}wh(),Lh();var fy=new WeakMap;function by(e){try{return e&&e.cssRules?e.cssRules:null}catch{return null}}function yy(e){let t=e.querySelectorAll('style,link[rel~=\"stylesheet\"]'),n=`n:${t.length}|`,i=0;for(let e=0;e<t.length;e++){let s=t[e];if(\"STYLE\"===s.tagName){n+=`S${s.textContent?s.textContent.length:0}|`;let e=s.sheet,t=e?by(e):null;t&&(i+=t.length)}else{n+=`L${s.getAttribute(\"href\")||\"\"}|m:${s.getAttribute(\"media\")||\"all\"}|`;let e=s.sheet,t=e?by(e):null;t&&(i+=t.length)}}let s=e.adoptedStyleSheets,r=0;if(Array.isArray(s))for(let e of s){let t=by(e);t&&(r+=t.length)}return n+=`ass:${Array.isArray(s)?s.length:0}/${r}|tr:${i}`,n}function vy(e,t,n){let i=by(e);if(!i)return!1;for(let e=0;e<i.length;e++){if(n.budget<=0)return!1;let s=i[e],r=s&&s.cssText?s.cssText:\"\";n.budget--;for(let e of t)if(r.includes(e))return!0;if(s&&s.styleSheet&&vy(s.styleSheet,t,n))return!0;if(s&&s.cssRules&&s.cssRules.length)for(let e=0;e<s.cssRules.length&&n.budget>0;e++){let i=s.cssRules[e],r=i&&i.cssText?i.cssText:\"\";n.budget--;for(let e of t)if(r.includes(e))return!0}if(n.budget<=0)return!1}return!1}function wy(e=document,t=yy(e)){let n=fy.get(e);if(n&&n.fingerprint===t)return n.result;let i=e=>(e.match(/\\|ass:[^|]*/)||[\"\"])[0];n&&i(t)!==i(n.fingerprint)&&Dm();let s=[\"::before\",\"::after\",\"::first-letter\",\"::marker\",\"::first-line\",\":before\",\":after\",\":first-letter\",\":first-line\",\"counter(\",\"counters(\",\"counter-increment\",\"counter-reset\"],r=e.querySelectorAll(\"style\");for(let n=0;n<r.length;n++){let i=r[n].textContent||\"\";for(let n of s)if(i.includes(n))return fy.set(e,{fingerprint:t,result:!0}),!0}let o=e.adoptedStyleSheets;if(Array.isArray(o)&&o.length){let n={budget:1e3};try{for(let i of o)if(vy(i,s,n))return fy.set(e,{fingerprint:t,result:!0}),!0}catch{}}{let n=e.querySelectorAll('style,link[rel~=\"stylesheet\"]'),i={budget:1e3};for(let r=0;r<n.length&&i.budget>0;r++){let o=n[r],a=null;if(o.tagName,a=o.sheet||null,a&&vy(a,s,i))return fy.set(e,{fingerprint:t,result:!0}),!0}}return e.querySelector('[style*=\"counter(\"], [style*=\"counters(\"]')?(fy.set(e,{fingerprint:t,result:!0}),!0):(fy.set(e,{fingerprint:t,result:!1}),!1)}function xy(e){for(let t of[\"Top\",\"Right\",\"Bottom\",\"Left\"]){let n=parseFloat(e[`border${t}Width`])||0,i=e[`border${t}Style`];if(n>0&&i&&\"none\"!==i&&\"hidden\"!==i)return!0}return!1}function ky(e){return e.replace(/\\\\(?:([0-9a-fA-F]{1,6})[ \\t\\n]?|([\\s\\S]))/g,(e,t,n)=>{if(t){let e=parseInt(t,16);return 0===e||e>1114111?\"�\":String.fromCodePoint(e)}return\"\\n\"===n?\"\":n})}function Sy(e){if(!e)return\"\";let t,n=[],i=/\"((?:\\\\[\\s\\S]|[^\"\\\\])*)\"|'((?:\\\\[\\s\\S]|[^'\\\\])*)'/g,s=0;for(;t=i.exec(e);){let r=e.slice(s,t.index).trim();r&&n.push(r),n.push(ky(void 0!==t[1]?t[1]:t[2])),s=i.lastIndex}let r=e.slice(s).trim();return r&&n.push(r),n.join(\"\")}function Cy(e,t,n){let i=e.parentElement,s=i&&n?n.get(i):null;return s?{get(e,n){let i=t.get(e,n),r=s.get(n);return\"number\"==typeof r?Math.max(i,r):i},getStack(e,n){let i=t.getStack(e,n);if(!i.length)return i;let r=s.get(n);if(\"number\"==typeof r){let e=i.slice();return e[e.length-1]=Math.max(e[e.length-1],r),e}return i}}:t}function Ey(e,t,n){let i=new Map,s=(e,t)=>gy(e,t).map(([e,t])=>({name:e,num:t})),r=s(t?.counterReset,0),o=s(t?.counterSet,0),a=s(t?.counterIncrement,1);function l(t){if(i.has(t))return i.get(t).slice();let s=n.getStack(e,t);s=s.length?s.slice():[];let l=r.find(e=>e.name===t);if(l){let e=Number.isFinite(l.num)?l.num:0;s=s.length?[...s,e]:[e]}let c=o.find(e=>e.name===t);if(c){let e=Number.isFinite(c.num)?c.num:0;0===s.length&&(s=[0]),s[s.length-1]=e}let d=a.find(e=>e.name===t);if(d){let e=Number.isFinite(d.num)?d.num:1;0===s.length&&(s=[0]),s[s.length-1]+=e}return i.set(t,s.slice()),s}return{get(e,t){let n=l(t);return n.length?n[n.length-1]:0},getStack:(e,t)=>l(t),__incs:a}}var My=[\"color\",\"-webkit-text-fill-color\",\"font-family\",\"font-size\",\"font-weight\",\"font-style\",\"letter-spacing\",\"line-height\"],Ay=[\"color\",\"-webkit-text-fill-color\",\"font-family\",\"font-size\",\"font-weight\",\"font-style\",\"font-variant\",\"letter-spacing\",\"word-spacing\",\"text-transform\",\"text-decoration-line\",\"text-decoration-color\",\"text-decoration-style\",\"line-height\",\"background-color\",\"vertical-align\"];function _y(e,t,n,i,s,r){try{if(null===i){if(e.getRootNode()!==(e.ownerDocument||document))return;let t=cg(e).display||\"\";if(\"::marker\"===s?!t.includes(\"list-item\"):\"block\"!==t&&\"flow-root\"!==t&&\"list-item\"!==t&&\"inline-block\"!==t&&\"table-cell\"!==t&&\"table-caption\"!==t)return}else if(!e.matches(i))return;if(\"::marker\"===s&&!(cg(e).display||\"\").includes(\"list-item\"))return;let o=cg(e,s),a=cg(e);if(!o)return;let l=\"\";for(let e of r){let t=o.getPropertyValue(e);t&&t!==a.getPropertyValue(e)&&(\"background-color\"!==e||\"rgba(0, 0, 0, 0)\"!==t)&&(\"vertical-align\"!==e||\"baseline\"!==t)&&(l+=`${e}:${t};`)}if(\"::marker\"===s){let e=o.getPropertyValue(\"content\");e&&\"normal\"!==e&&\"none\"!==e&&(l+=`content:${e};`)}if(!l)return;let c=`data-sd-p${n.__pseudoRuleSeq=(n.__pseudoRuleSeq||0)+1}`;t.setAttribute(c,\"\"),n.__pseudoCSS=(n.__pseudoCSS||\"\")+`[${c}]${s}{${l}}`}catch{}}function Ty(e,t,n,i){let s;try{s=cg(e,t)}catch{}let r=s?.content;if(!r||\"none\"===r||\"normal\"===r)return{text:\"\",incs:[]};r=function(e){let t=!1;for(let n=0;n<e.length;n++){let i=e[n];if('\"'===i)t=!t;else if(\"/\"===i&&!t)return e.slice(0,n).trim()}return e}(r),r=function(e,t){if(!/\\b(?:no-)?(?:open|close)-quote\\b/.test(e))return e;let n=\"“\",i=\"”\";try{let e=cg(t).quotes;if(\"none\"===e)n=\"\",i=\"\";else if(e&&\"auto\"!==e){let t=e.match(/\"[^\"]*\"|'[^']*'/g);t&&t.length>=2&&(n=t[0].slice(1,-1),i=t[1].slice(1,-1))}}catch{}return n=n.replace(/\"/g,\"\"),i=i.replace(/\"/g,\"\"),e.replace(/\"[^\"]*\"|\\b(no-open-quote|no-close-quote|open-quote|close-quote)\\b/g,(e,t)=>t?\"open-quote\"===t?`\"${n}\"`:\"close-quote\"===t?`\"${i}\"`:'\"\"':e)}(r,e);let o=Ey(e,s,Cy(e,n,i)),a=function(e){return/\\bcounter\\s*\\(|\\bcounters\\s*\\(/.test(e||\"\")}(r)?function(e,t,n){if(!e||\"none\"===e)return e;try{let i=/\\b(counter|counters)\\s*\\(([^)]+)\\)/g;return e.replace(i,(e,i,s)=>{let r=String(s).split(\",\").map(e=>e.trim());if(\"counter\"===i){let e=r[0]?.replace(/^[\"']|[\"']$/g,\"\"),i=(r[1]||\"decimal\").toLowerCase();return hy(n.get(t,e),i)}{let e=r[0]?.replace(/^[\"']|[\"']$/g,\"\"),i=r[1]?.replace(/^[\"']|[\"']$/g,\"\")??\"\",s=(r[2]||\"decimal\").toLowerCase(),o=n.getStack(t,e);return o.length?o.map(e=>hy(e,s)).join(i):\"\"}})}catch{return\"- \"}}(r,e,o):r;return{text:Sy(a),incs:o.__incs||[]}}async function Iy(e,t,n,i,s=!1){if(1!==e?.nodeType||1!==t?.nodeType||(n.slicer?.due()&&await n.slicer.pause(),\"TEXTAREA\"===e.tagName))return;let r=e.ownerDocument||document;if(!s&&!function(e,t){let n=yy(e);return t?(t.__pseudoPreflightFp!==n&&(uf(),t.__pseudoPreflight=wy(e,n),t.__pseudoPreflightFp=n),!!t.__pseudoPreflight):(uf(),wy(e,n))}(r,n)&&!n.__shadowPseudo||!s&&function(e,t){if(t.__shadowPseudo)return!1;let n=xf(e),i=[];for(let e of[\"before\",\"after\",\"firstLetter\",\"marker\",\"firstLine\"]){let t=n[e];if(null===t)return!1;t&&i.push(t)}if(!i.length)return!0;let s=i.join(\",\");try{return!e.matches(s)&&null===e.querySelector(s)}catch{return!1}}(e,n))return;n.__siblingCounters||(n.__siblingCounters=new WeakMap),n.__counterCtx||(n.__counterCtx=function(e,t){let n=null,i=()=>{if(!n)try{n=my(e)}catch(e){Pg(t,\"buildCounterContext failed\",e),n={get:()=>0,getStack:()=>[]}}return n};return{get:(e,t)=>i().get(e,t),getStack:(e,t)=>i().getStack(e,t)}}(e.ownerDocument||document,n));let o=n.__counterCtx,a=xf(e);\"\"!==a.marker&&_y(e,t,n,a.marker,\"::marker\",My),\"\"!==a.firstLine&&_y(e,t,n,a.firstLine,\"::first-line\",Ay);for(let s of[\"::before\",\"::after\",\"::first-letter\"]){let r=a[\"::before\"===s?\"before\":\"::after\"===s?\"after\":\"firstLetter\"];if(null!==r){if(\"\"===r)continue;try{if(!e.matches(r))continue}catch{}}try{let r=cg(e,s);if(!(r&&(\"none\"!==r.content||\"none\"!==r.backgroundImage||\"transparent\"!==r.backgroundColor&&\"rgba(0, 0, 0, 0)\"!==r.backgroundColor||xy(r)||r.transform&&\"none\"!==r.transform||\"inline\"!==r.display)))continue;if(\"none\"===r.display||\"::first-letter\"!==s&&(\"none\"===r.content||\"normal\"===r.content)){\"::before\"===s&&(t.dataset.snapdomHasBefore=\"1\"),\"::after\"===s&&(t.dataset.snapdomHasAfter=\"1\");continue}if(\"::first-letter\"===s){let i=cg(e),s=(i?.display||\"\").toLowerCase();if(s.includes(\"flex\")||s.includes(\"grid\"))continue;let o=e=>r[e]!==i[e]&&0!==(parseFloat(r[e])||0);if(!(r.color!==i.color||r.fontSize!==i.fontSize||r.fontWeight!==i.fontWeight||r.fontFamily!==i.fontFamily||r.fontStyle!==i.fontStyle||r.textTransform!==i.textTransform||r.float!==i.float&&\"none\"!==r.float||o(\"paddingTop\")||o(\"paddingRight\")||o(\"paddingBottom\")||o(\"paddingLeft\")||o(\"marginTop\")||o(\"marginRight\")||o(\"marginBottom\")||o(\"marginLeft\")))continue;let a=Array.from(t.childNodes).find(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim().length>0);if(!a)continue;let l=a.textContent,c=/^\\s*/.exec(l)[0],d=l.slice(c.length),u=d.match(/^([^\\p{L}\\p{N}\\s]*[\\p{L}\\p{N}](?:['’])?)/u)?.[0],p=d.slice(u?.length||0);if(!u||/[\\uD800-\\uDFFF]/.test(u))continue;let h=document.createElement(\"span\");h.textContent=u,h.dataset.snapdomPseudo=\"::first-letter\";let g=ag(dg(r,vf(e)),\"span\");n.styleMap.set(h,g);let m=document.createTextNode(p);t.replaceChild(m,a),t.insertBefore(h,m),c&&t.insertBefore(document.createTextNode(c),h);continue}let a=r.content??\"\",l=\"\"===a||\"none\"===a||\"normal\"===a,{text:c,incs:d}=Ty(e,s,o,n.__siblingCounters),u=r.backgroundImage,p=r.backgroundColor,h=r.fontFamily,g=parseInt(r.fontSize)||32,m=parseInt(r.fontWeight)||!1,f=r.fontStyle||\"normal\",b=r.color||\"#000\",y=r.transform,v=Lb(h,i?.__iconMatchers),w=!l&&\"\"!==c,x=u&&\"none\"!==u,k=p&&\"transparent\"!==p&&\"rgba(0, 0, 0, 0)\"!==p,S=xy(r),C=y&&\"none\"!==y,E=\"none\"!==a&&\"normal\"!==a,M=/^inline-/.test(r.display||\"\"),A=E&&((parseFloat(r.width)||0)>0||(parseFloat(r.height)||0)>0||M),_=E&&r.boxShadow&&\"none\"!==r.boxShadow,T=E&&r.outlineStyle&&\"none\"!==r.outlineStyle&&(parseFloat(r.outlineWidth)||0)>0;if(!(w||x||k||S||C||A||_||T)){if(d&&d.length&&e.parentElement){let t=n.__siblingCounters.get(e.parentElement)||new Map;for(let{name:i}of d){if(!i)continue;let r=Cy(e,o,n.__siblingCounters),a=Ey(e,cg(e,s),r).get(e,i);t.set(i,a)}n.__siblingCounters.set(e.parentElement,t)}continue}let I=c.startsWith(\"url(\")||/^-?(?:webkit-)?image-set\\(/i.test(c),L=!1;if(w&&!v&&c.length>1&&!I){let n=cg(e),i=parseFloat(n.fontSize)||16,s=parseFloat(n.lineHeight);Number.isFinite(s)||(s=1.5*i),e.getBoundingClientRect().height<1.6*s&&(t.style.whiteSpace=\"nowrap\",L=!0)}let R=document.createElement(\"span\");R.dataset.snapdomPseudo=s,R.style.pointerEvents=\"none\",L&&(R.style.whiteSpace=\"nowrap\");let $=$f(e,s,r,n,i),N=(cg(e).display||\"\").toLowerCase(),P=N.includes(\"flex\")||N.includes(\"grid\");if(P){let e=$[\"min-width\"];(!e||\"auto\"===e||\"0px\"===e)&&($[\"min-width\"]=\"0px\")}let F=ag($,\"span\",w,P);if(n.styleMap.set(R,F),v&&c&&1===c.length){let{dataUrl:e,width:n,height:i}=await qb(c,h,m,g,b,f),s=document.createElement(\"img\");s.src=e,s.style=`height:${g}px;width:${n/i*g}px;object-fit:contain;`,R.appendChild(s),t.dataset.snapdomHasIcon=\"true\"}else if(c&&I){let t=ch(c,typeof devicePixelRatio<\"u\"&&devicePixelRatio||1)??lh(c);if(t?.trim())try{let e=await Mh(dh(t),{as:\"dataURL\",useProxy:i.useProxy});if(e?.ok&&\"string\"==typeof e.data){let t=document.createElement(\"img\");t.src=e.data,t.style=`width:${g}px;height:auto;object-fit:contain;`,R.appendChild(t)}}catch(t){console.error(`[snapdom] Error in pseudo ${s} for`,e,t)}}else!v&&w&&(R.textContent=c);R.style.backgroundImage=\"none\",\"maskImage\"in R.style&&(R.style.maskImage=\"none\"),\"webkitMaskImage\"in R.style&&(R.style.webkitMaskImage=\"none\");try{R.style.backgroundRepeat=r.backgroundRepeat,R.style.backgroundSize=r.backgroundSize,r.backgroundPositionX&&r.backgroundPositionY?(R.style.backgroundPositionX=r.backgroundPositionX,R.style.backgroundPositionY=r.backgroundPositionY):R.style.backgroundPosition=r.backgroundPosition,R.style.backgroundOrigin=r.backgroundOrigin,R.style.backgroundClip=r.backgroundClip,R.style.backgroundAttachment=r.backgroundAttachment,R.style.backgroundBlendMode=r.backgroundBlendMode}catch{}if(x)try{let e=ug(u),t=await Promise.all(e.map(e=>Rh(e,i)));R.style.backgroundImage=t.join(\", \")}catch(e){console.warn(`[snapdom] Failed to inline background-image for ${s}`,e)}k&&(R.style.backgroundColor=p);let O=r.maskImage||r.webkitMaskImage;if(O&&\"none\"!==O)try{let e=(await Promise.all(ug(O).map(e=>Rh(e,i)))).join(\", \");R.style.maskImage=e,R.style.webkitMaskImage=e;for(let e of[\"maskSize\",\"maskRepeat\",\"maskPosition\",\"maskMode\",\"maskComposite\",\"maskOrigin\",\"maskClip\"])r[e]&&(R.style[e]=r[e])}catch(e){console.warn(`[snapdom] Failed to inline mask-image for ${s}`,e)}let q=R.childNodes.length>0||\"\"!==R.textContent?.trim()||x||k||S||C||A||_||T;if(d&&d.length&&e.parentElement){let t=n.__siblingCounters.get(e.parentElement)||new Map,i=Cy(e,o,n.__siblingCounters),r=Ey(e,cg(e,s),i);for(let{name:n}of d){if(!n)continue;let i=r.get(e,n);t.set(n,i)}n.__siblingCounters.set(e.parentElement,t)}if(!q)continue;\"::before\"===s?(t.dataset.snapdomHasBefore=\"1\",t.insertBefore(R,t.firstChild)):(t.dataset.snapdomHasAfter=\"1\",t.appendChild(R))}catch(t){console.warn(`[snapdom] Failed to capture ${s} for`,e,t)}}let l=Array.from(t.children).filter(e=>!e.dataset.snapdomPseudo);if(n.nodeMap)for(let e of l){let t=n.nodeMap.get(e);1===t?.nodeType&&await Iy(t,e,n,i,!0)}else{let t=Array.from(e.children);for(let e=0;e<Math.min(t.length,l.length);e++)await Iy(t[e],l[e],n,i,!0)}}function Ly(e,t,n){if(!e||1!==e?.nodeType)return;let i=e.ownerDocument||document,s=i,r=gh(e)&&\"svg\"===e.localName?[e]:Array.from(e.querySelectorAll(\"svg\")),o=/url\\(\\s*[\"']?\\s*#([^)\"']+)/g,a=[\"fill\",\"stroke\",\"filter\",\"clip-path\",\"mask\",\"marker\",\"marker-start\",\"marker-mid\",\"marker-end\"],l=e=>{if(!e||!e.getAttribute)return null;let t=e.getAttribute(\"href\")||e.getAttribute(\"xlink:href\")||(\"function\"==typeof e.getAttributeNS?e.getAttributeNS(\"http://www.w3.org/1999/xlink\",\"href\"):null);if(t)return t;let n=e.attributes;if(!n)return null;for(let e=0;e<n.length;e++){let t=n[e];if(!t||!t.name)continue;if(\"href\"===t.name)return t.value;let i=t.name.indexOf(\":\");if(-1!==i&&\"href\"===t.name.slice(i+1))return t.value}return null},c=new Set(Array.from(e.querySelectorAll(\"[id]\")).map(e=>e.id)),d=new Set,u=!1,p=(e,t=null)=>{if(!e)return;let n;for(o.lastIndex=0;n=o.exec(e);){u=!0;let e=(n[1]||\"\").trim();e&&(c.has(e)||(d.add(e),t&&!t.has(e)&&t.add(e)))}},h=e=>{let t=e.querySelectorAll(\"use\");for(let e of t){let t=l(e);if(!t||!t.startsWith(\"#\"))continue;u=!0;let n=t.slice(1).trim();n&&!c.has(n)&&d.add(n)}p(e.getAttribute(\"style\")||\"\");for(let t of a)p(e.getAttribute(t));let n=e.querySelectorAll('*[style*=\"url(\"],*[fill^=\"url(\"], *[stroke^=\"url(\"],*[filter^=\"url(\"],*[clip-path^=\"url(\"],*[mask^=\"url(\"],*[marker^=\"url(\"],*[marker-start^=\"url(\"],*[marker-mid^=\"url(\"],*[marker-end^=\"url(\"]');for(let e of n){p(e.getAttribute(\"style\")||\"\");for(let t of a)p(e.getAttribute(t))}};for(let e of r)h(e);if((e=>{if(!e||1!==e.nodeType||!e.querySelectorAll)return;let t=!1;try{t=!(!s.querySelector||!s.querySelector(\"filter[id],clipPath[id],mask[id],linearGradient[id],radialGradient[id],pattern[id]\"))}catch{return}if(!t)return;let n=[\"filter\",\"clipPath\",\"mask\",\"maskImage\",\"webkitMaskImage\"],i=e=>{if(gh(e))return;let t;try{t=getComputedStyle(e)}catch{return}for(let e of n){let n=t[e];n&&n.includes(\"url(\")&&p(n)}};i(e);for(let t of e.querySelectorAll(\"*\"))i(t)})(n),!u)return;let g=e.querySelector(\"svg.inline-defs-container\");g||(g=i.createElementNS(\"http://www.w3.org/2000/svg\",\"svg\"),g.classList.add(\"inline-defs-container\"),g.setAttribute(\"aria-hidden\",\"true\"),g.setAttribute(\"style\",\"position:absolute;width:0;height:0;overflow:hidden\"),e.insertBefore(g,e.firstChild||null));let m=g.querySelector(\"defs\")||null,f=t=>{if(!t||c.has(t))return null;let n=(e=>window.CSS&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,\"\\\\$&\"))(t),i=t=>{let n=s.querySelector(t);return n&&!e.contains(n)?n:null};return i(`svg defs > *#${n}`)||i(`svg > symbol#${n}`)||i(`*#${n}`)};if(!d.size)return;let b=new Set(d),y=new Set;for(;b.size;){let e=b.values().next().value;if(b.delete(e),!e||c.has(e)||y.has(e))continue;let t=f(e);if(!t){y.add(e);continue}m||(m=i.createElementNS(\"http://www.w3.org/2000/svg\",\"defs\"),g.appendChild(m));let n=t.cloneNode(!0);n.id||n.setAttribute(\"id\",e),m.appendChild(n),y.add(e),c.add(e);let s=[n,...n.querySelectorAll(\"*\")];for(let e of s){let t=l(e);if(t&&t.startsWith(\"#\")){let e=t.slice(1).trim();e&&!c.has(e)&&!y.has(e)&&b.add(e)}let n=e.getAttribute?.(\"style\")||\"\";n&&p(n,b);for(let t of a){let n=e.getAttribute?.(t);n&&p(n,b)}}}}wh(),wh();var Ry=new WeakMap,$y=new WeakMap;function Ny(e,t,n){let i=n.get(e),s=e.style;if(!i){let r=s.cssText,o=e.hasAttribute(\"style\");i={users:0,saved:t.map(([e,t])=>{let n={property:e,value:s.getPropertyValue(e),priority:s.getPropertyPriority(e)};return s.setProperty(e,t,\"important\"),n.forcedValue=s.getPropertyValue(e),n}),originalCSS:r,forcedCSS:s.cssText,hadStyle:o},n.set(e,i)}i.users++;let r=!1;return()=>{if(!r&&(r=!0,! --i.users)){if(n.delete(e),s.cssText===i.forcedCSS)s.cssText=i.originalCSS;else for(let e of i.saved)s.getPropertyValue(e.property)!==e.forcedValue||\"important\"!==s.getPropertyPriority(e.property)||(e.value?s.setProperty(e.property,e.value,e.priority):s.removeProperty(e.property));!i.hadStyle&&!s.length&&(e.getAttribute(\"style\"),e.removeAttribute(\"style\"))}}}function Py(e,t=null){let n=[],i=e=>{if(!hh(e))return;if($y.has(e))return void n.push(Ny(e,[],$y));let t=getComputedStyle(e);\"auto\"===(t.contentVisibility||t.getPropertyValue(\"content-visibility\")||\"\")&&n.push(Ny(e,[[\"content-visibility\",\"visible\"]],$y))};try{if(t){let n=e=>{let s;try{s=e.getBoundingClientRect()}catch{return}if(!(s.width>0||s.height>0)||!(s.right<t.left-200||s.left>t.right+200||s.bottom<t.top-200||s.top>t.bottom+200)){i(e);for(let t=e.firstElementChild;t;t=t.nextElementSibling)n(t)}};n(e)}else{for(let t of e.querySelectorAll(\"*\"))i(t);i(e)}}catch{}return()=>{for(let e of n)try{e()}catch{}}}function Fy(e){return qy(e.boxShadow)}function Oy(e){return qy(e.textShadow)}function qy(e){if(!e||\"none\"===e)return{top:0,right:0,bottom:0,left:0};let t=[],n=\"\",i=0;for(let s=0;s<e.length;s++){let r=e[s];\"(\"===r?i++:\")\"===r&&(i=Math.max(0,i-1)),\",\"===r&&0===i?(t.push(n),n=\"\"):n+=r}n.trim()&&t.push(n);let s=0,r=0,o=0,a=0;for(let e of t){if(/\\binset\\b/i.test(e))continue;let t=e.match(/-?\\d+(\\.\\d+)?px/g)?.map(e=>parseFloat(e))||[];if(t.length<2)continue;let[n,i,l=0,c=0]=t,d=Math.abs(n)+l+c,u=Math.abs(i)+l+c;r=Math.max(r,d+Math.max(n,0)),a=Math.max(a,d+Math.max(-n,0)),o=Math.max(o,u+Math.max(i,0)),s=Math.max(s,u+Math.max(-i,0))}return{top:Math.ceil(s),right:Math.ceil(r),bottom:Math.ceil(o),left:Math.ceil(a)}}function Hy(e){let t,n=e.filter&&\"none\"!==e.filter?e.filter:e.webkitFilter||\"\",i=/blur\\(\\s*([0-9.]+)px\\s*\\)/gi,s=0;for(;t=i.exec(n);)s+=parseFloat(t[1])||0;let r=Math.ceil(2*s);return{top:r,right:r,bottom:r,left:r}}function By(e){if(\"none\"===(e.outlineStyle||\"none\"))return{top:0,right:0,bottom:0,left:0};let t=Math.ceil(parseFloat(e.outlineWidth||\"0\")||0),n=parseFloat(e.outlineOffset||\"0\")||0,i=t+Math.max(0,Math.ceil(n));return{top:i,right:i,bottom:i,left:i}}function Dy(e){let t=`${e.filter||\"\"} ${e.webkitFilter||\"\"}`.trim();if(!t||\"none\"===t)return{bleed:{top:0,right:0,bottom:0,left:0},has:!1};let n=t.match(/drop-shadow\\((?:[^()]|\\([^()]*\\))*\\)/gi)||[],i=0,s=0,r=0,o=0,a=!1;for(let e of n){a=!0;let t=e.match(/-?\\d+(?:\\.\\d+)?px/gi)?.map(e=>parseFloat(e))||[],[n=0,l=0,c=0]=t,d=Math.abs(n)+c,u=Math.abs(l)+c;s=Math.max(s,d+Math.max(n,0)),o=Math.max(o,d+Math.max(-n,0)),r=Math.max(r,u+Math.max(l,0)),i=Math.max(i,u+Math.max(-l,0))}return{bleed:{top:vv(i),right:vv(s),bottom:vv(r),left:vv(o)},has:a}}function zy(e){let t=Fy(e),n=Oy(e),i=Hy(e),s=By(e),r=Dy(e);return{top:Math.max(t.top,n.top)+i.top+s.top+r.bleed.top,right:Math.max(t.right,n.right)+i.right+s.right+r.bleed.right,bottom:Math.max(t.bottom,n.bottom)+i.bottom+s.bottom+r.bleed.bottom,left:Math.max(t.left,n.left)+i.left+s.left+r.bleed.left}}function Uy(e){return!!(e.boxShadow&&\"none\"!==e.boxShadow||e.textShadow&&\"none\"!==e.textShadow||\"none\"!==(e.outlineStyle||\"none\")||e.filter&&\"none\"!==e.filter)||!!e.webkitFilter&&\"none\"!==e.webkitFilter}function jy(e){let t=e.overflowX||e.overflow||\"visible\",n=e.overflowY||e.overflow||\"visible\",i=!!e.contain&&/\\b(paint|content|strict)\\b/.test(e.contain)||!!e.clipPath&&\"none\"!==e.clipPath;return{x:i||\"visible\"!==t,y:i||\"visible\"!==n}}function Wy(e,t){if(!e||!t||!t.style)return null;let n=getComputedStyle(e);try{t.style.transformOrigin=\"0 0\"}catch{}try{\"translate\"in t.style&&(t.style.translate=\"none\"),\"rotate\"in t.style&&(t.style.rotate=\"none\")}catch{}let i=n.transform||\"none\";if(\"none\"===i){let n=null;try{n=Ky(e).scale}catch{}try{t.style.transform=\"none\"}catch{}if(!n)return{a:1,b:0,c:0,d:1};let i=Xy({scale:n});return{a:i.a,b:i.b,c:i.c,d:i.d}}function s(e,t,n,i){let s=Math.sqrt(e*e+t*t)||0,r=0,o=0;if(s>0){let a=e/s,l=t/s;r=a*n+l*i;let c=n-a*r,d=i-l*r;o=Math.sqrt(c*c+d*d)||0,o>0?r/=o:r=0}return{a:s,b:0,c:r*o,d:o}}let r=t=>{let n=Ky(e).scale;if(!n)return t;let i=Xy({scale:n,baseTransform:`matrix(${t.a},${t.b},${t.c},${t.d},0,0)`});return{a:i.a,b:i.b,c:i.c,d:i.d}},o=i.match(/^matrix\\(\\s*([^)]+)\\)$/i);if(o){let e=o[1].split(\",\").map(e=>parseFloat(e.trim()));if(6===e.length&&e.every(Number.isFinite)){let[n,i,o,a]=e,l=s(n,i,o,a);try{t.style.transform=`matrix(${l.a}, ${l.b}, ${l.c}, ${l.d}, 0, 0)`}catch{}return r(l)}}let a=i.match(/^matrix3d\\(\\s*([^)]+)\\)$/i);if(a){let e=a[1].split(\",\").map(e=>parseFloat(e.trim()));if(16===e.length&&e.every(Number.isFinite)){let n=s(e[0],e[1],e[4],e[5]);try{t.style.transform=`matrix(${n.a}, ${n.b}, ${n.c}, ${n.d}, 0, 0)`}catch{}return r(n)}}try{let e=new DOMMatrix(i),n=s(e.a,e.b,e.c,e.d);try{t.style.transform=`matrix(${n.a}, ${n.b}, ${n.c}, ${n.d}, 0, 0)`}catch{}return r(n)}catch{return null}}function Vy(e,t,n,i,s){let r=n.a,o=n.b,a=n.c,l=n.d,c=n.e||0,d=n.f||0;function u(e,t){let n=e-i,u=t-s,p=r*n+a*u,h=o*n+l*u;return p+=i+c,h+=s+d,[p,h]}let p=[u(0,0),u(e,0),u(0,t),u(e,t)],h=1/0,g=1/0,m=-1/0,f=-1/0;for(let[e,t]of p)e<h&&(h=e),t<g&&(g=t),e>m&&(m=e),t>f&&(f=t);return{minX:h,minY:g,maxX:m,maxY:f,width:m-h,height:f-g}}function Gy(e,t,n){let i=(e.transformOrigin||\"0 0\").trim().split(/\\s+/),[s,r]=[i[0]||\"0\",i[1]||\"0\"],o=(e,t)=>{let n=e.toLowerCase();return\"left\"===n||\"top\"===n?0:\"center\"===n?t/2:\"right\"===n||\"bottom\"===n?t:n.endsWith(\"px\")?parseFloat(n)||0:n.endsWith(\"%\")?(parseFloat(n)||0)*t/100:/^-?\\d+(\\.\\d+)?$/.test(n)&&parseFloat(n)||0};return{ox:o(s,t),oy:o(r,n)}}function Ky(e){let t={rotate:\"0deg\",scale:null,translate:null},n=null;try{n=\"function\"==typeof e.computedStyleMap?e.computedStyleMap():null}catch{}if(n){let i=e=>{try{return\"function\"==typeof n.has&&!n.has(e)||\"function\"!=typeof n.get?null:n.get(e)}catch{return null}},s=i(\"rotate\");if(s)if(s.angle){let e=s.angle;t.rotate=\"rad\"===e.unit?180*e.value/Math.PI+\"deg\":e.value+e.unit,!1===s.is2D&&s.x&&s.y&&s.z&&(t.rotate=`${s.x.value} ${s.y.value} ${s.z.value} ${t.rotate}`)}else s.unit?t.rotate=\"rad\"===s.unit?180*s.value/Math.PI+\"deg\":s.value+s.unit:t.rotate=String(s);else{let n=getComputedStyle(e);t.rotate=n.rotate&&\"none\"!==n.rotate?n.rotate:\"0deg\"}let r=i(\"scale\");if(r){let e=e=>e&&null!=e.value?`${e.value}${\"percent\"===e.unit?\"%\":\"\"}`:null;\"x\"in r&&null!=r.x?.value?t.scale=[e(r.x),e(r.y)??e(r.x),...!1===r.is2D?[e(r.z)??\"1\"]:[]].join(\" \"):Array.isArray(r)?t.scale=r.map(e).join(\" \"):t.scale=String(r)}else{let n=getComputedStyle(e);t.scale=n.scale&&\"none\"!==n.scale?n.scale:null}let o=i(\"translate\");if(o){let e=e=>e&&null!=e.value?`${e.value}${\"percent\"===e.unit?\"%\":e.unit||\"px\"}`:null;\"x\"in o&&null!=o.x?.value?t.translate=[e(o.x),e(o.y)??\"0px\",...!1===o.is2D?[e(o.z)??\"0px\"]:[]].join(\" \"):Array.isArray(o)?t.translate=o.map(e).join(\" \"):t.translate=String(o)}else{let n=getComputedStyle(e);t.translate=n.translate&&\"none\"!==n.translate?n.translate:null}return(!t.rotate||\"none\"===t.rotate)&&(t.rotate=\"0deg\"),(!t.scale||\"none\"===t.scale)&&(t.scale=null),(!t.translate||\"none\"===t.translate)&&(t.translate=null),t}let i=getComputedStyle(e);return t.rotate=i.rotate&&\"none\"!==i.rotate?i.rotate:\"0deg\",t.scale=i.scale&&\"none\"!==i.scale?i.scale:null,t.translate=i.translate&&\"none\"!==i.translate?i.translate:null,t}Hg(),ah(),ng(),Ag(),ng();var Yy=null;function Xy(e){let t=e=>{let t=[],n=0,i=0,s=String(e).trim();for(let e=0;e<s.length;e++)\"(\"===s[e]?n++:\")\"===s[e]?n--:/\\s/.test(s[e])&&!n&&(e>i&&t.push(s.slice(i,e)),i=e+1);return i<s.length&&t.push(s.slice(i)),t},n=e=>e&&\"none\"!==e,i=[];if(n(e.translate)){let n=t(e.translate);for(let t=0;t<2&&t<n.length;t++){let i=0===t?e.width:e.height;/^[+-]?(?:\\d*\\.)?\\d+%$/.test(n[t])&&Number.isFinite(i)&&(n[t]=parseFloat(n[t])*i/100+\"px\")}i.push(n.length>2?`translate3d(${n.join(\",\")})`:`translate(${n.join(\",\")})`)}if(n(e.rotate)&&\"0deg\"!==e.rotate){let n=t(e.rotate);4===n.length?i.push(`rotate3d(${n.join(\",\")})`):2===n.length&&/^[xyz]$/i.test(n[0])?i.push(`rotate${n[0].toUpperCase()}(${n[1]})`):i.push(`rotate(${n.join(\" \")})`)}if(n(e.scale)){let n=t(e.scale).map(e=>/%$/.test(e)?String(parseFloat(e)/100):e);i.push(n.length>2?`scale3d(${n.join(\",\")})`:`scale(${n.join(\",\")})`)}if(n(e.baseTransform)&&i.push(e.baseTransform),!i.length)return new DOMMatrix;let s=i.join(\" \");try{if(s.includes(\"%\"))throw new Error(\"Transform needs a reference box\");return new DOMMatrix(s)}catch{let t=function(){if(Yy?.isConnected)return Yy;let e=document.createElement(\"div\");return e.id=\"snapdom-measure-slot\",e.setAttribute(\"aria-hidden\",\"true\"),Zh(e),Object.assign(e.style,{position:\"absolute\",left:\"-99999px\",top:\"0px\",width:\"0px\",height:\"0px\",overflow:\"hidden\",opacity:\"0\",pointerEvents:\"none\",contain:\"size layout style\"}),document.documentElement.appendChild(e),Yy=e,e}(),n=document.createElement(\"div\");if(n.style.cssText=\"all:initial!important;display:block!important;transform-origin:0 0!important\",n.style.setProperty(\"width\",`${Number.isFinite(e.width)?e.width:0}px`,\"important\"),n.style.setProperty(\"height\",`${Number.isFinite(e.height)?e.height:0}px`,\"important\"),n.style.setProperty(\"transform\",s,\"important\"),!n.style.transform)throw new Error(\"Invalid transform composition\");t.appendChild(n);try{return function(e){let t=getComputedStyle(e).transform;if(!t||\"none\"===t)return new DOMMatrix;try{return new DOMMatrix(t)}catch{return new WebKitCSSMatrix(t)}}(n)}finally{n.remove()}}}var Jy=new WeakSet;function Qy(e,t){if(!t)return null;let n,i,s,r,o=e.ownerDocument||document,a=o.defaultView||window;if(\"viewport\"===t)n=0,i=0,s=o.documentElement?.clientWidth||a.innerWidth,r=o.documentElement?.clientHeight||a.innerHeight;else{if(\"object\"!=typeof t)return null;n=(Number(t.x)||0)-(a.scrollX||0),i=(Number(t.y)||0)-(a.scrollY||0),s=Number(t.width),r=Number(t.height)}return s>0&&r>0?{left:n,top:i,width:s,height:r,right:n+s,bottom:i+r}:null}function Zy(e){if(e.parentElement)return e.parentElement;let t=e.getRootNode&&e.getRootNode();return mh(t)?t.host:null}function ev(e,t){for(let n=t;n;n=Zy(n))if(n===e)return!0;return!1}function tv(e,t){for(let n=Zy(e);n&&n!==t&&1===n?.nodeType;n=Zy(n)){let e=cg(n);if(\"static\"!==e.position||e.transform&&\"none\"!==e.transform||e.filter&&\"none\"!==e.filter||e.backdropFilter&&\"none\"!==e.backdropFilter||e.perspective&&\"none\"!==e.perspective||/transform|perspective|filter/.test(e.willChange||\"\")||/layout|paint|strict|content/.test(e.contain||\"\"))return n}return null}function nv(e,t){try{return Xy({baseTransform:e,rotate:t?.rotate,scale:t?.scale})}catch{return null}}function iv(e,t,n={}){if(!e||!t||!t.style)return;let i=getComputedStyle(e);try{t.style.boxShadow=\"none\"}catch(e){Pg(n,\"stripRootShadows boxShadow\",e)}try{t.style.textShadow=\"none\"}catch(e){Pg(n,\"stripRootShadows textShadow\",e)}try{t.style.outline=\"none\"}catch(e){Pg(n,\"stripRootShadows outline\",e)}let s=(i.filter||\"\").replace(/\\bdrop-shadow\\((?:[^()]|\\([^()]*\\))*\\)\\s*/gi,\"\").trim().replace(/\\s+/g,\" \");try{t.style.filter=s.length?s:\"none\"}catch(e){Pg(n,\"stripRootShadows filter\",e)}}function sv(e,t){if(!e||!t||!t.style)return;let n=1;try{n=parseFloat(getComputedStyle(e).zoom)}catch{return}if(t.style.getPropertyValue(\"zoom\")||Number.isFinite(n)&&1!==n)try{t.style.setProperty(\"zoom\",\"1\",\"important\")}catch{}}function rv(e){let t=e.display||\"\";if(t.includes(\"flex\")||t.includes(\"grid\")||t.startsWith(\"table\")||\"inline-block\"===t||\"flow-root\"===t||\"absolute\"===e.position||\"fixed\"===e.position||e.float&&\"none\"!==e.float)return!0;let n=e.overflowX||e.overflow||\"visible\",i=e.overflowY||e.overflow||\"visible\";return!!(\"visible\"!==n||\"visible\"!==i||e.contain&&/\\b(layout|content|paint|strict)\\b/.test(e.contain))}function ov(e,t){let n=Array.from(e.childNodes),i=\"top\"===t?n:n.reverse();for(let e of i){if(e.nodeType===Node.TEXT_NODE){if(/\\S/.test(e.textContent||\"\"))return null;continue}if(e.nodeType!==Node.ELEMENT_NODE)continue;let t=getComputedStyle(e),n=String(t.display||\"\");if(\"none\"!==n&&\"contents\"!==n&&\"absolute\"!==t.position&&\"fixed\"!==t.position)return t.float&&\"none\"!==t.float||n.startsWith(\"inline\")?null:e}return null}function av(e,t,n){if(!e||!t||!t.style)return;let i=getComputedStyle(e);if(!rv(i))for(let s of[\"top\",\"bottom\"]){let r=\"top\"===s?\"Top\":\"Bottom\";if((parseFloat(i[`border${r}Width`])||0)>0||(parseFloat(i[`padding${r}`])||0)>0)continue;let o=e,a=t;for(;o&&a;){let e=ov(o,s);if(!e)break;let t=n?Array.from(a.children).find(t=>n.get(t)===e)||null:a.children[Array.from(o.children).indexOf(e)]||null,i=getComputedStyle(e),l=parseFloat(i[`margin${r}`])||0;if(t&&t.style&&l>0&&(t.style[`margin${r}`]=\"0px\"),rv(i)||(parseFloat(i[`border${r}Width`])||0)>0||(parseFloat(i[`padding${r}`])||0)>0)break;o=e,a=t}}}var lv=new Set([\"xml\",\"xlink\"]);function cv(e,t){if(e.startsWith(\"*\")||e.includes(\"@\"))return!0;if(e.includes(\":\")){let t=e.split(\":\",1)[0];if(!lv.has(t))return!0}return!!t&&(e.startsWith(\"x-\")||e.startsWith(\"v-\")||e.startsWith(\":\")||e.startsWith(\"on:\")||e.startsWith(\"bind:\")||e.startsWith(\"let:\")||e.startsWith(\"class:\"))}var dv=/[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F\\uD800-\\uDFFF\\uFFFE\\uFFFF]/g,uv=e=>e.replace(dv,e=>2===e.length?e:\"\"),pv=/^data:[^,]{0,120};base64,/;function hv(e,t={}){if(!e)return;let{stripFrameworkDirectives:n=!0}=t,i=e=>{for(let t of Array.from(e.attributes)){if(cv(t.name,n)){e.removeAttribute(t.name);continue}if(pv.test(t.value))continue;let i=uv(t.value);if(i!==t.value)try{e.setAttribute(t.name,i)}catch{}}};e.nodeType===Node.ELEMENT_NODE&&i(e);let s,r=[],o=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT|NodeFilter.SHOW_COMMENT);for(;s=o.nextNode();)if(s.nodeType===Node.ELEMENT_NODE)i(s);else if(s.nodeType===Node.COMMENT_NODE)r.push(s);else{let e=uv(s.data);e!==s.data&&(s.data=e)}for(let e of r)e.remove()}var gv=new Set([\"img\",\"canvas\",\"video\",\"iframe\",\"object\",\"embed\"]);function mv(e,t){if(1!==e?.nodeType||function(e){try{let t=e.getAttribute?.(\"style\")||\"\";return/\\b(height|width|block-size|inline-size)\\s*:/.test(t)}catch{return!1}}(e)||function(e){return gh(e)||gv.has(e?.localName)}(e))return!1;let n=t.position;if(\"absolute\"===n||\"fixed\"===n||\"sticky\"===n)return!1;let i=t.display||\"\";return!(i.includes(\"flex\")||i.includes(\"grid\")||i.startsWith(\"table\")||t.transform&&\"none\"!==t.transform)}function fv(e){let t=getComputedStyle(e);return!(\"none\"===t.display||\"absolute\"===t.position||\"fixed\"===t.position)}function bv(e,t){if(1!==e?.nodeType)return!1;if(\"exclude\"===e.getAttribute(\"data-capture\"))return\"remove\"===t?.excludeMode;if(Array.isArray(t?.exclude))for(let n of t.exclude)try{if(e.matches(n))return\"remove\"===t.excludeMode}catch(e){Pg(t,\"exclude selector match failed\",e)}if(Array.isArray(t?.excludePredicates))for(let n of t.excludePredicates)try{if(n(e))return\"remove\"===t.excludeMode}catch(e){Pg(t,\"exclude predicate failed\",e)}if(\"function\"==typeof t?.filter&&\"remove\"===t.filterMode)try{if(!t.filter(e))return!0}catch(e){Pg(t,\"filter function failed\",e)}return!1}function yv(e,t){let n=getComputedStyle(e),i=e.getBoundingClientRect(),s=1/0,r=-1/0,o=!1,a=Array.from(e.children);for(let e of a){if(bv(e,t)||!fv(e))continue;let n=e.getBoundingClientRect(),a=n.top-i.top,l=n.bottom-i.top;l<=a||(a<s&&(s=a),l>r&&(r=l),o=!0)}let l=o?Math.max(0,r-s):0;return(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.borderBottomWidth)||0)+(parseFloat(n.paddingTop)||0)+(parseFloat(n.paddingBottom)||0)+l}var vv=(e,t=3)=>Number.isFinite(e)?Math.round(e*10**t)/10**t:e,wv=.75;var xv=/::-(?:webkit-(?:scrollbar|meter|progress|slider)|moz-(?:meter|progress))/i;function kv(e,t=new Set){let n=\"\";if(!e)return n;for(let i=0;i<e.length;i++){let s=e[i];try{if(s.type===CSSRule.IMPORT_RULE&&s.styleSheet){n+=kv(s.styleSheet.cssRules,t);continue}if(s.type===CSSRule.MEDIA_RULE&&s.cssRules){let e=kv(s.cssRules,t);e&&(n+=`@media ${s.conditionText}{${e}}`);continue}if(s.type===CSSRule.STYLE_RULE){let e=s.selectorText||\"\";if(xv.test(e)){let e=s.cssText;e&&!t.has(e)&&(t.add(e),n+=e)}}}catch{}}return n}var Sv=new WeakMap;function Cv(e,t){let n,i=function(e){let t=new Set;return e.nodeType!==Node.ELEMENT_NODE&&e.nodeType!==Node.DOCUMENT_FRAGMENT_NODE?[]:(e.tagName&&t.add(e.tagName.toLowerCase()),\"function\"==typeof e.querySelectorAll&&e.querySelectorAll(\"*\").forEach(e=>t.add(e.tagName.toLowerCase())),Array.from(t))}(e.clone).sort(),s=i.join(\",\"),r=bf(e.element),o=oh.baseStyle.get(s);o&&o.universe===r?n=o.css:(n=function(e,t=null){let n=new Map;for(let i of e){let e=ig(i);if(!e)continue;let s=(t?Object.entries(e).filter(([e])=>t.has(e)):Object.entries(e)).filter(([t])=>!rg(t,e)).map(([e,t])=>`${e}:${t};`).sort(),r=s.join(\"\");r&&(n.has(r)||n.set(r,{tagList:[],declarations:s}),n.get(r).tagList.push(i))}let i=[...n.values()],s=null;for(let{declarations:e}of i){let t=new Set(e);if(s)for(let e of s)t.has(e)||s.delete(e);else s=t}s??=new Set;let r=\"\";s.size&&i.length>1&&(r+=`${i.flatMap(e=>e.tagList).join(\",\")} { ${[...s].join(\"\")} }\\n`);for(let{tagList:e,declarations:t}of i){let n=i.length>1?t.filter(e=>!s.has(e)):t;if(!n.length)continue;let o=n.join(\"\");r+=`${e.join(\",\")} { ${o} }\\n`}return r}(i,r),oh.baseStyle.set(s,{universe:r,css:n}));let a=function(e){if(!e||!e.styleSheets)return\"\";let t=function(e){let t=\"\";for(let n of e.styleSheets){let e=-1;try{e=n.cssRules?n.cssRules.length:-1}catch{}t+=(n.href||\"inline\")+\":\"+e+\"|\"}return t}(e),n=Sv.get(e);if(n&&n.fp===t)return n.css;let i=new Set,s=\"\";for(let t of Array.from(e.styleSheets))try{let e=t.cssRules;e&&(s+=kv(e,i))}catch{}return Sv.set(e,{fp:t,css:s}),s}(e.element?.ownerDocument||document);return e.fontsCSS=t,e.baseCSS=n,e.scrollbarCSS=a,{baseCSS:n,scrollbarCSS:a,fontsCSS:t}}Ng();var Ev=new Set;async function Mv(e,t={}){uf(),df(e.ownerDocument||document);let n=t.__session||{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map},i={styleMap:n.styleMap,styleCache:n.styleCache,nodeMap:n.nodeMap,options:t,slicer:t.__slicer||null},s=null,r=null;if(t.clip&&(r=Qy(e,t.clip),r&&(i.clip={rect:r,root:e})),t.captureSelection)try{i.selection=function(e){let t=(e.ownerDocument||document).getSelection?.();if(!t||t.isCollapsed||0===t.rangeCount)return null;let n=[];for(let i=0;i<t.rangeCount;i+=1){let s=t.getRangeAt(i);if(!s.collapsed)try{s.intersectsNode(e)&&n.push(s)}catch{}}return n.length?{ranges:n,styles:new Map}:null}(e)}catch(e){Pg(i,\"prepareSelectionContext failed\",e)}let o,a=\"\",l=\"\";if(Ev.size){let t=(e,t)=>{for(let n=t;n;n=n.assignedSlot||n.parentElement||n.getRootNode()?.host)if(n===e)return!0;return!1};for(;;){let n=[...Ev].filter(({root:n})=>t(n,e)||t(e,n)).map(({promise:e})=>e.catch(()=>{}));if(!n.length)break;await Promise.all(n)}}if(!i.clip&&e.isConnected&&\"hidden\"!==e.ownerDocument?.visibilityState)try{let t=e.getBoundingClientRect(),n=e.ownerDocument?.defaultView||window,i=t.right<=0||t.bottom<=0||t.left>=n.innerWidth||t.top>=n.innerHeight,s=[];if(i&&(()=>{let t=[];e.shadowRoot&&t.push(e.shadowRoot);for(let n of e.querySelectorAll(\"*\"))n.shadowRoot&&t.push(n.shadowRoot);for(;t.length;){let e=t.pop(),n=\"calcite-icon\"===e.host?.localName;for(let i of e.querySelectorAll(\"*\")){if(i.shadowRoot&&t.push(i.shadowRoot),!n||\"svg\"!==i.localName)continue;let e=i.querySelectorAll(\"path\");if(!e.length||[...e].some(e=>e.getAttribute(\"d\")?.trim()))continue;let r=i.getBoundingClientRect();r.width&&r.height&&s.push(i)}}})(),s.length){let t=(async()=>{let t=e.style,i=e.hasAttribute(\"style\"),r=new Map,o=(e,n)=>{r.has(e)||r.set(e,{value:t.getPropertyValue(e),priority:t.getPropertyPriority(e)}),t.setProperty(e,n,\"important\");let i=r.get(e);i.forcedValue=t.getPropertyValue(e),i.forcedPriority=t.getPropertyPriority(e)};try{o(\"left\",\"0\"),o(\"top\",\"0\"),o(\"right\",\"auto\"),o(\"bottom\",\"auto\"),o(\"margin-top\",\"0\"),o(\"margin-right\",\"0\"),o(\"margin-bottom\",\"0\"),o(\"margin-left\",\"0\"),o(\"transform\",\"none\"),o(\"translate\",\"none\"),o(\"opacity\",\"0\"),o(\"pointer-events\",\"none\");let t=e.getBoundingClientRect();if(t.right<=0||t.bottom<=0||t.left>=n.innerWidth||t.top>=n.innerHeight){let t=e.parentElement?.getBoundingClientRect(),i=t&&t.right>0&&t.left<n.innerWidth?Math.max(0,t.left):0,s=t&&t.bottom>0&&t.top<n.innerHeight?Math.max(0,t.top):0;o(\"position\",\"fixed\"),o(\"left\",`${i}px`),o(\"top\",`${s}px`)}await _g(100);let i=Date.now()+1500,r=()=>s.some(e=>{if([...e.querySelectorAll(\"path\")].some(e=>e.getAttribute(\"d\")?.trim()))return!1;let t=e.getBoundingClientRect();return t.width&&t.height&&t.right>0&&t.bottom>0&&t.left<n.innerWidth&&t.top<n.innerHeight});for(;Date.now()<i&&r();)await new Promise(e=>setTimeout(e,25));await _g(100)}finally{for(let[e,n]of r)t.getPropertyValue(e)!==n.forcedValue||t.getPropertyPriority(e)!==n.forcedPriority||(n.value?t.setProperty(e,n.value,n.priority):t.removeProperty(e));!i&&!t.length&&e.removeAttribute(\"style\"),await _g(100)}})(),i={root:e,promise:t};Ev.add(i);try{await t}finally{Ev.delete(i)}}}catch{}let c=function(e){if(Ry.has(e))return Ny(e,[],Ry);let t=getComputedStyle(e),n=t.outlineStyle,i=t.outlineWidth,s=\"none\"!==n&&parseFloat(i)>0,r=0===parseFloat(t.borderTopWidth)&&0===parseFloat(t.borderRightWidth)&&0===parseFloat(t.borderBottomWidth)&&0===parseFloat(t.borderLeftWidth);if(s&&r){let t=[];for(let e of[\"top\",\"right\",\"bottom\",\"left\"])t.push([`border-${e}-width`,i],[`border-${e}-style`,\"solid\"],[`border-${e}-color`,\"transparent\"]);return Ny(e,t,Ry)}return()=>{}}(e),d=Py(e,r);if(r){let t=e.getBoundingClientRect(),n=e.offsetWidth||t.width,i=e.offsetHeight||t.height,o=t.width&&Math.abs(n-t.width)>=1?n/t.width:1,a=t.height&&Math.abs(i-t.height)>=1?i/t.height:1;s={x:(r.left-t.left)*o,y:(r.top-t.top)*a,width:r.width*o,height:r.height*a}}try{o=await Cb(e,i,t)}catch(e){throw console.warn(\"deepClone failed:\",e),e}finally{d(),c()}i.slicer?.due()&&await i.slicer.pause();try{Ly(o,0,e)}catch(e){console.warn(\"inlineExternal defs or symbol failed:\",e)}try{await Iy(e,o,i,t)}catch(e){console.warn(\"inlinePseudoElements failed:\",e)}await cb(o,i);for(let[e,t]of i.nodeMap.entries())if(\"STYLE\"===t?.tagName&&\"STYLE\"===e?.tagName&&!e.hasAttribute(\"data-sd\"))try{let n=t.sheet&&t.sheet.cssRules;n&&/@media/i.test(e.textContent||\"\")&&(e.textContent=Xf(n))}catch{}try{let e=o.querySelectorAll(\"style[data-sd]\");for(let t of e)l+=t.textContent||\"\",t.remove()}catch(e){Pg(i,\"Failed to extract shadow CSS from style[data-sd]\",e)}i.slicer?.due()&&await i.slicer.pause();let u=lg(i.styleMap);a=Array.from(u.entries()).map(([e,t])=>`.${t}{${e}}`).join(\"\");let p=l+\"[data-snapdom-has-after]::after,[data-snapdom-has-before]::before{content:none!important;display:none!important}\"+(i.__pseudoCSS||\"\");a=p+a;for(let[e,t]of i.styleMap.entries())Av(e,t,u);try{!function(e,t,n){let i=[];for(let t of[\":modal\",\":popover-open\"])try{i.push(...e.querySelectorAll(t))}catch{}if(!i.length)return;let s=new Map;for(let[e,t]of n.entries())s.set(t,e);let r=214748e4;for(let e of i){let n=s.get(e);if(n&&n!==t&&null!=n.parentNode){try{let n=getComputedStyle(e,\"::backdrop\"),i=n.backgroundColor,s=n.backgroundImage;if(i&&\"rgba(0, 0, 0, 0)\"!==i&&\"transparent\"!==i||s&&\"none\"!==s){let e=document.createElement(\"div\");e.setAttribute(\"data-sd-backdrop\",\"\"),e.style.cssText=`position:fixed;inset:0;z-index:${r};background-color:${i};`+(s&&\"none\"!==s&&s.includes(\"data:\")?`background-image:${s};`:\"\"),t.appendChild(e)}}catch{}r+=1,n.style.zIndex=String(r),t.appendChild(n),r+=1}}}(e,o,i.nodeMap)}catch(e){Pg(i,\"top-layer lift failed\",e)}if((i.clip||e.scrollTop||e.scrollLeft)&&1===o?.nodeType)try{let t=i.clip&&s?{x:s.x,y:s.y}:{x:0,y:0};!function(e,t,n,i,s){let r=e.getBoundingClientRect();hh(t)&&\"static\"===cg(e).position&&(t.style.position=\"relative\");let o=[];for(let[t,a]of n){if(!hh(t)||1!==a?.nodeType||a===e||!ev(e,a))continue;let n=i.get(a)||cg(a),l=n.position;if(\"fixed\"!==l&&\"sticky\"!==l&&\"-webkit-sticky\"!==l||\"absolute\"===t.style.position)continue;let c=a.getBoundingClientRect();if(!(c.width>0&&c.height>0))continue;Jy.add(t);let d=n.transform&&\"none\"!==n.transform?n.transform:\"\",u=Ky(a),p=!!(d||\"0deg\"!==u.rotate||u.scale||u.translate),h=p?nv(d,u):null,g=!h||!h.is2D||1===h.a&&0===h.b&&0===h.c&&1===h.d,m=c.width,f=c.height;g||(m=a.offsetWidth||c.width,f=a.offsetHeight||c.height);let b=a.getRootNode&&mh(a.getRootNode()),y=r,v=e.clientLeft||0,w=e.clientTop||0;if(b){let t=tv(a,e);t&&(y=t.getBoundingClientRect(),v=t.clientLeft||0,w=t.clientTop||0)}let x=c.left-y.left-v,k=c.top-y.top-w;if(p)if(t.style.translate=\"none\",t.style.rotate=\"none\",t.style.scale=\"none\",g)t.style.transform=\"none\";else{t.style.transform=`matrix(${h.a},${h.b},${h.c},${h.d},0,0)`;let{ox:e,oy:i}=Gy(n,m,f),s=Vy(m,f,{a:h.a,b:h.b,c:h.c,d:h.d,e:0,f:0},e,i);x-=s.minX,k-=s.minY}if(\"fixed\"!==l){let e=t.cloneNode(!1);e.setAttribute(\"data-snap-ph\",\"1\"),e.style.position=\"static\",e.style.visibility=\"hidden\",e.style.width=`${m}px`,e.style.height=`${f}px`,e.style.boxSizing=\"border-box\",t.parentElement?.insertBefore(e,t)}let S=m+2,C=f;s&&(Math.abs(k-s.y)<.5&&(k-=1,C+=1),Math.abs(x-s.x)<.5&&(x-=1,S+=1)),t.style.position=\"absolute\",t.style.left=`${x}px`,t.style.top=`${k}px`,t.style.right=\"auto\",t.style.bottom=\"auto\",t.style.margin=\"0\",t.style.width=`${S}px`,t.style.height=`${C}px`,t.style.boxSizing=\"border-box\",b||o.push(t)}for(let e of o)t.appendChild(e)}(e,o,i.nodeMap,i.styleCache,t)}catch(e){Pg(i,\"freezeViewportPositioned failed\",e)}for(let[t,n]of i.nodeMap.entries())i.clip&&n===e||_v(t,n);let h=e.ownerDocument;if((e===h.body||e===h.documentElement)&&\"html\"===h.documentElement.localName){let t=i.styleCache.get(h.documentElement)||cg(h.documentElement);e===h.documentElement&&(o.style.overflow=\"visible\");let n=e===h.body?o:o.querySelector(\"body\");if(n&&\"visible\"===t.overflowX&&\"visible\"===t.overflowY&&\"none\"===t.contain&&!t.containerType?.includes(\"size\")&&\"auto\"!==t.contentVisibility&&\"hidden\"!==t.contentVisibility){let e=i.styleCache.get(h.body)||cg(h.body);\"none\"===e.contain&&!e.containerType?.includes(\"size\")&&\"auto\"!==e.contentVisibility&&\"hidden\"!==e.contentVisibility&&\"none\"!==e.display&&(n.style.overflow=\"visible\")}}if(e===i.nodeMap.get(o)){let t=i.styleCache.get(e)||cg(e);i.styleCache.set(e,t);let n=function(e){if(!e||\"none\"===e)return\"\";let t=e.replace(/translate[XY]?\\([^)]*\\)/g,\"\");return t=t.replace(/matrix\\(([^)]+)\\)/g,(e,t)=>{let n=t.split(\",\").map(e=>e.trim());return 6!==n.length?`matrix(${t})`:(n[4]=\"0\",n[5]=\"0\",`matrix(${n.join(\", \")})`)}),t=t.replace(/matrix3d\\(([^)]+)\\)/g,(e,t)=>{let n=t.split(\",\").map(e=>e.trim());return 16!==n.length?`matrix3d(${t})`:(n[12]=\"0\",n[13]=\"0\",`matrix3d(${n.join(\", \")})`)}),t.trim().replace(/\\s{2,}/g,\" \")}(t.transform);o.style.margin=\"0\",o.style.top=\"auto\",o.style.left=\"auto\",o.style.right=\"auto\",o.style.bottom=\"auto\",o.style.animation=\"none\",o.style.transition=\"none\",o.style.willChange=\"auto\",o.style.float=\"none\",o.style.clear=\"none\",o.style.transform=n||\"\",o.style.translate=\"none\"}for(let[e,t]of i.nodeMap.entries())\"PRE\"===t.tagName&&(e.style.marginTop=\"0\",e.style.marginBlockStart=\"0\");return{clone:o,classCSS:a,classPrefixCSS:p,styleCache:i.styleCache,nodeMap:i.nodeMap,reconcileRisk:i.reconcileRisk||0,clipWindow:s}}function Av(e,t,n){if(\"STYLE\"===e.tagName)return;if(e.getRootNode&&mh(e.getRootNode()))return void e.setAttribute(\"style\",t.replace(/;/g,\"; \"));let i=n.get(t);i&&e.classList.add(i);let s=e.style?.backgroundImage,r=e.dataset?.snapdomHasIcon;s&&\"none\"!==s&&(e.style.backgroundImage=s),r&&(e.style.verticalAlign=\"middle\",e.style.display=\"inline\")}function _v(e,t){let n=t.scrollLeft,i=t.scrollTop;if(!n&&!i||1!==e?.nodeType||\"http://www.w3.org/1999/xhtml\"!==e.namespaceURI)return;e.style.overflow=\"hidden\",e.style.scrollbarWidth=\"none\",e.style.msOverflowStyle=\"none\";try{let t=e.querySelectorAll(\"*\");for(let e of t){if(1!==e.nodeType||\"http://www.w3.org/1999/xhtml\"!==e.namespaceURI)continue;let t=e.style.position;if(\"fixed\"===t||\"absolute\"===t){let s=parseFloat(e.style.top)||0,r=parseFloat(e.style.left)||0;e.style.top=`${s+i}px`,e.style.left=`${r+n}px`,\"fixed\"===t&&(e.style.position=\"absolute\")}}}catch{}let s=document.createElement(\"div\");for(s.style.all=\"unset\",s.style.transform=`translate(${-n}px, ${-i}px)`,s.style.willChange=\"transform\",s.style.display=\"inline-block\",s.style.width=\"100%\";e.firstChild;)s.appendChild(e.firstChild);e.appendChild(s)}Lh(),qg(),ah();var Tv=\"http://www.w3.org/1999/xlink\";async function Iv(e,t={}){let n=Array.from(e.querySelectorAll(\"img\"));\"IMG\"===e.tagName&&n.unshift(e);let i=async e=>{if(!e.getAttribute(\"src\")){let t=e.currentSrc||e.src||Vf(e.getAttribute(\"srcset\"),e)||\"\";t&&e.setAttribute(\"src\",t)}if(e.removeAttribute(\"srcset\"),e.removeAttribute(\"sizes\"),(e.getAttribute(\"src\")||\"\").startsWith(\"data:\"))return e.width||(e.width=e.naturalWidth||100),void(e.height||(e.height=e.naturalHeight||100));let n=e.src||\"\";if(!n)return;let i=oh.image?.get(n);if(i)return e.src=i,e.width||(e.width=e.naturalWidth||100),void(e.height||(e.height=e.naturalHeight||100));let s=await Mh(n,{as:\"dataURL\",useProxy:t.useProxy});if(s.ok&&\"string\"==typeof s.data&&s.data.startsWith(\"data:\"))return oh.image?.set(n,s.data),e.src=s.data,s.blob&&(e.__snapdomBlob=s.blob),e.width||(e.width=e.naturalWidth||100),void(e.height||(e.height=e.naturalHeight||100));let{width:r,height:o}=function(e){let t=parseFloat(e.dataset?.snapdomWidth||\"\")||0,n=parseFloat(e.dataset?.snapdomHeight||\"\")||0,i=parseInt(e.getAttribute(\"width\")||\"\",10)||0,s=parseInt(e.getAttribute(\"height\")||\"\",10)||0,r=parseFloat(e.style?.width||\"\")||0,o=parseFloat(e.style?.height||\"\")||0;return{width:t||r||i||e.width||e.naturalWidth||100,height:n||o||s||e.height||e.naturalHeight||100}}(e),{fallbackURL:a}=t||{};if(a)try{let i=\"function\"==typeof a?await a({width:r,height:o,src:n,element:e}):a;if(i){let n=await Mh(i,{as:\"dataURL\",useProxy:t.useProxy});if(n?.ok&&\"string\"==typeof n.data)return e.src=n.data,e.width||(e.width=r),void(e.height||(e.height=o))}}catch{}if(!1!==t.placeholders){Fg(t.__session,\"image-fallback\",`image failed to inline, using placeholder: ${n}`);let i=document.createElement(\"div\");i.style.cssText=[`width:${r}px`,`height:${o}px`,\"background:#ccc\",\"display:inline-block\",\"text-align:center\",`line-height:${o}px`,\"color:#666\",\"font-size:12px\",\"overflow:hidden\"].join(\";\"),i.textContent=\"img\",e.replaceWith(i)}else{let t=document.createElement(\"div\");t.style.cssText=`display:inline-block;width:${r}px;height:${o}px;visibility:hidden;`,e.replaceWith(t)}};for(let e=0;e<n.length;e+=6){let t=n.slice(e,e+6).map(i);await Promise.allSettled(t)}let s=Array.from(e.querySelectorAll(\"image\"));\"image\"===e.localName&&s.unshift(e);let r=async e=>{let n=function(e){return e.getAttribute(\"href\")||e.getAttribute(\"xlink:href\")||(\"function\"==typeof e.getAttributeNS?e.getAttributeNS(Tv,\"href\"):null)}(e);if(!n||n.startsWith(\"data:\")||n.startsWith(\"blob:\"))return;let i=await Mh(n,{as:\"dataURL\",useProxy:t.useProxy});i.ok&&\"string\"==typeof i.data&&i.data.startsWith(\"data:\")&&(e.setAttribute(\"href\",i.data),e.removeAttribute(\"xlink:href\"),\"function\"==typeof e.removeAttributeNS&&e.removeAttributeNS(Tv,\"href\"))};for(let e=0;e<s.length;e+=6){let t=s.slice(e,e+6).map(r);await Promise.allSettled(t)}}Ng(),Hg();var Lv=[\"background-image\",\"mask\",\"mask-image\",\"-webkit-mask\",\"-webkit-mask-image\",\"mask-source\",\"mask-box-image-source\",\"mask-border-source\",\"-webkit-mask-box-image-source\",\"border-image\",\"border-image-source\"],Rv=[\"mask-position\",\"mask-size\",\"mask-repeat\",\"mask-mode\",\"mask-composite\",\"-webkit-mask-position\",\"-webkit-mask-size\",\"-webkit-mask-repeat\",\"-webkit-mask-composite\",\"mask-origin\",\"mask-clip\",\"-webkit-mask-origin\",\"-webkit-mask-clip\",\"-webkit-mask-position-x\",\"-webkit-mask-position-y\"],$v=[\"background-position\",\"background-position-x\",\"background-position-y\",\"background-size\",\"background-repeat\",\"background-origin\",\"background-clip\",\"background-attachment\",\"background-blend-mode\"],Nv=[\"border-image-slice\",\"border-image-width\",\"border-image-outset\",\"border-image-repeat\"];async function Pv(e,t,n,i){let s=n.get(e)||cg(e);n.has(e)||n.set(e,s);let r=function(e){let t=Mm.get(e);if(!t||!_f(t,e))return null;let n=t.snapshot;return!n||n.__bgClipTextFix?null:n}(e),o=r?e=>e in r?r[e]:\"\":e=>s.getPropertyValue(e),a=o(\"border-image\"),l=o(\"border-image-source\"),c=a&&\"none\"!==a||l&&\"none\"!==l,d=s.getPropertyValue(\"background-image\"),u=o(\"background-color\"),p=d&&\"none\"!==d||u&&\"rgba(0, 0, 0, 0)\"!==u&&\"transparent\"!==u||/url\\s*\\(|gradient\\s*\\(/i.test(s.getPropertyValue(\"background\")||\"\"),h=Lg()&&(o(\"background-clip\")||o(\"-webkit-background-clip\")||\"\").includes(\"text\");if(p&&!h)for(let e of $v){let n=o(e);n&&t.style.setProperty(e,n)}for(let e of Lv){if(h&&\"background-image\"===e)continue;let n=s.getPropertyValue(e);if(\"background-image\"===e&&(!n||\"none\"===n)){let e=s.getPropertyValue(\"background\");e&&/url\\s*\\(/.test(e)&&(n=ug(e).filter(e=>/url\\s*\\(/.test(e)).join(\", \")||n)}if(!n||\"none\"===n)continue;let r=ug(n),o=await Promise.all(r.map(e=>Rh(e,i)));o.some(e=>e&&\"none\"!==e&&!/^url\\(undefined/.test(e))&&t.style.setProperty(e,o.join(\", \"))}for(let e of Rv){let n=o(e);!n||\"initial\"===n||t.style.setProperty(e,n)}if(c)for(let e of Nv){let n=o(e);!n||\"initial\"===n||t.style.setProperty(e,n)}if(p&&/fixed/.test(o(\"background-attachment\")||\"\"))try{await async function(e,t,n){let i=(n.getPropertyValue(\"background-attachment\")||\"\").split(\",\").map(e=>e.trim()),s=Tg();if(!s)for(let t=e.parentElement;t&&!s;t=t.parentElement){let e=cg(t);(e.transform&&\"none\"!==e.transform||e.filter&&\"none\"!==e.filter)&&(s=!0)}if(s)return void t.style.setProperty(\"background-attachment\",i.map(()=>\"scroll\").join(\", \"));let r=e.getBoundingClientRect(),o=e.ownerDocument?.defaultView||window,a=o.innerWidth,l=o.innerHeight,c=ug(t.style.backgroundImage||n.getPropertyValue(\"background-image\")||\"\"),d=(t.style.backgroundSize||n.getPropertyValue(\"background-size\")||\"auto\").split(\",\").map(e=>e.trim()),u=(t.style.backgroundPosition||n.getPropertyValue(\"background-position\")||\"0% 0%\").split(\",\").map(e=>e.trim()),p=[],h=[];for(let e=0;e<c.length;e++){let t=i[e%i.length]||\"scroll\",n=d[e%d.length],s=u[e%u.length];if(\"fixed\"!==t){p.push(n),h.push(s);continue}let o=0,g=0,m=c[e]&&c[e].match(/url\\([\"']?([^\"')]+)[\"']?\\)/);if(m)try{let e=new Image;e.src=m[1],await e.decode(),o=e.naturalWidth,g=e.naturalHeight}catch{p.push(n),h.push(s);continue}let f=Fv(n,o,g,a,l);if(!f){p.push(n),h.push(s);continue}let b=s.split(/\\s+/),y=(e,t,n)=>e?e.endsWith(\"px\")?parseFloat(e):e.endsWith(\"%\")?(t-n)*parseFloat(e)/100:void 0:0,v=y(b[0]||\"0%\",a,f.w),w=y(b[1]||b[0]||\"0%\",l,f.h);void 0!==v&&void 0!==w?(p.push(`${Ov(f.w)}px ${Ov(f.h)}px`),h.push(`${Ov(v-r.left)}px ${Ov(w-r.top)}px`)):(p.push(n),h.push(s))}t.style.setProperty(\"background-size\",p.join(\", \")),t.style.setProperty(\"background-position\",h.join(\", \")),t.style.setProperty(\"background-attachment\",i.map(()=>\"scroll\").join(\", \"))}(e,t,s)}catch{}}function Fv(e,t,n,i,s){let r=(e||\"auto\").trim();if(\"cover\"===r||\"contain\"===r){if(!t||!n)return{w:i,h:s};let e=\"cover\"===r?Math.max(i/t,s/n):Math.min(i/t,s/n);return{w:t*e,h:n*e}}let o=r.split(/\\s+/),a=(e,t)=>\"auto\"===e||void 0===e?null:e.endsWith(\"px\")?parseFloat(e):e.endsWith(\"%\")?t*parseFloat(e)/100:void 0,l=a(o[0],i),c=a(o[1],s);if(void 0===l||void 0===c)return null;let d=l,u=c;return null==d&&null==u?(d=t||i,u=n||s):null==d?d=t&&n?u*(t/n):i:null==u&&(u=t&&n?d*(n/t):s),d&&u?{w:d,h:u}:null}var Ov=e=>Math.round(100*e)/100;async function qv(e,t,n,i={},s=new Map){if(!t)return;let r=[];e&&gf(e)&&r.push([e,t]);let o=[t];for(;o.length;){let e=o.pop();if(e.children)for(let t of e.children){if(\"STYLE\"===t.tagName)continue;let e=s.get(t);e&&gf(e)&&r.push([e,t]),o.push(t)}}for(let e=0;e<r.length;e+=6)await Promise.allSettled(r.slice(e,e+6).map(([e,t])=>Pv(e,t,n,i)))}function Hv(e,t,n=new Map){let i=[],s=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(let e=s.currentNode;e;e=s.nextNode()){let s=n.get(e);if(1!==s?.nodeType)continue;let r=cg(s),o=r.getPropertyValue(\"backdrop-filter\")||r.getPropertyValue(\"-webkit-backdrop-filter\");o&&\"none\"!==o&&e!==t&&i.push({cloneEl:e,orig:s,bf:o,path:Uv(t,e)})}if(!i.length)return;let r=e.getBoundingClientRect(),o=i.map((e,s)=>{let r=t.cloneNode(!0);(function(e,t,n,i){let s=[[e,t]];for(;s.length;){let[e,t]=s.pop(),r=i.get(t);if(1===r?.nodeType){let t=r.getBoundingClientRect();(t.left>n.right+zv||t.right<n.left-zv||t.top>n.bottom+zv||t.bottom<n.top-zv)&&(\"IMG\"===e.tagName&&e.setAttribute(\"src\",\"data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA=\"),e.style&&(e.style.backgroundImage=\"none\"))}let o=e.children,a=t.children;for(let e=0;e<o.length;e++)s.push([o[e],a[e]])}})(r,t,e.orig.getBoundingClientRect(),n),function(e){if(e)for(let t=e;t&&t.parentNode;){let n=t.parentNode;for(;t.nextSibling;)t.nextSibling.remove();t===e&&t.remove(),t=n}}(jv(r,e.path));for(let e=0;e<s;e++){let t=jv(r,i[e].path);t&&(t.style.setProperty(\"backdrop-filter\",\"none\",\"important\"),t.style.setProperty(\"-webkit-backdrop-filter\",\"none\",\"important\"))}return{...e,copy:r}});for(let{cloneEl:e,orig:t,bf:n,copy:i}of o)Bv.has(e.tagName)||Dv(e,t,n,i,r)}Hg();var Bv=new Set([\"IMG\",\"INPUT\",\"TEXTAREA\",\"SELECT\",\"CANVAS\",\"VIDEO\",\"AUDIO\",\"IFRAME\",\"EMBED\",\"OBJECT\",\"PROGRESS\",\"METER\",\"HR\",\"BR\"]);function Dv(e,t,n,i,s){let r=t.getBoundingClientRect();if(!r.width||!r.height)return;let o=cg(t),a=t.offsetWidth?r.width/t.offsetWidth:1,l=Math.abs(a-1)>.001?1/a:1;i.style.position=\"absolute\",i.style.left=(s.left-r.left)*l+\"px\",i.style.top=(s.top-r.top)*l+\"px\",i.style.width=`${s.width}px`,i.style.height=`${s.height}px`,i.style.margin=\"0\",i.style.filter=n,1!==l&&(i.style.transform=`scale(${l})`,i.style.transformOrigin=\"top left\");let c=document.createElement(\"div\");c.style.cssText=\"position:absolute;inset:0;overflow:hidden;border-radius:inherit;z-index:-2\",c.appendChild(i);let d=document.createElement(\"div\");d.style.cssText=\"position:absolute;inset:0;border-radius:inherit;z-index:-1\",d.style.backgroundColor=o.backgroundColor,d.style.backgroundImage=e.style.backgroundImage||o.backgroundImage;for(let e of[\"background-size\",\"background-position\",\"background-repeat\",\"background-origin\",\"background-clip\"])d.style.setProperty(e,o.getPropertyValue(e));e.style.setProperty(\"background-color\",\"transparent\",\"important\"),e.style.setProperty(\"background-image\",\"none\",\"important\"),e.style.setProperty(\"backdrop-filter\",\"none\",\"important\"),e.style.setProperty(\"-webkit-backdrop-filter\",\"none\",\"important\"),\"static\"===o.position&&(e.style.position=\"relative\"),e.style.isolation=\"isolate\",e.prepend(d),e.prepend(c)}var zv=128;function Uv(e,t){let n=[];for(let i=t;i!==e;i=i.parentElement){if(!i?.parentElement)return null;n.push([...i.parentElement.children].indexOf(i))}return n.reverse()}function jv(e,t){if(!t)return null;let n=e;for(let e of t)if(n=n.children[e],!n)return null;return n}function Wv(e){return function(e=\"soft\"){\"disabled\"===e&&(oh.computedStyle=new WeakMap,oh.measureHints=new WeakMap,oh.baseStyle=new rh(50),oh.defaultStyle=new rh(64),oh.image=new rh(100),oh.background=new rh(100),oh.resource=new rh(150),oh.compress=new rh(50))}(e),{styleMap:new Map,styleCache:new WeakMap,nodeMap:new Map,warnings:[]}}function Vv(e,t){if(!e)return()=>{};let n=[],i=200;return function e(s){if(t){let e=s.getBoundingClientRect();if(e.width>0||e.height>0){let n=Math.max(e.right,e.left+(s.scrollWidth||0)),r=Math.max(e.bottom,e.top+(s.scrollHeight||0));if(n<t.left-i||e.left>t.right+i||r<t.top-i||e.top>t.bottom+i)return}}let r=getComputedStyle(s),o=function(e,t){if(!e)return()=>{};t=t||getComputedStyle(e);let n=function(e){let t=e.getPropertyValue(\"-webkit-line-clamp\")||e.getPropertyValue(\"line-clamp\");t=(t||\"\").trim();let n=parseInt(t,10);return Number.isFinite(n)&&n>0?n:0}(t);if(n<=0)return()=>{};if(!Xv(e))return()=>{};let i=Kv(e),s=i.text,r=function(e){return(parseFloat(e.paddingTop)||0)+(parseFloat(e.paddingBottom)||0)}(t);i.write(\"X\");let o=e.scrollHeight-r;i.restore();let a=o>0?o:function(e){let t=(e.lineHeight||\"\").trim(),n=parseFloat(e.fontSize)||16;return t&&\"normal\"!==t?t.endsWith(\"px\")?parseFloat(t):/^\\d+(\\.\\d+)?$/.test(t)?Math.round(parseFloat(t)*n):t.endsWith(\"%\")?Math.round(parseFloat(t)/100*n):Math.round(1.2*n):Math.round(1.2*n)}(t),l=Math.round(a*n+r);if(e.scrollHeight<=l+.5)return()=>{};let c=0,d=s.length,u=-1;for(;c<=d;){let t=c+d>>1;i.write(s.slice(0,Yv(s,t))+\"…\"),e.scrollHeight<=l+.5?(u=t,c=t+1):d=t-1}let p=(u>=0?s.slice(0,Yv(s,u)):\"\")+\"…\";return i.write(p),Gv(e,p,i)}(s,r);o&&n.push(o);let a=function(e,t){if(!e)return()=>{};if(t=t||getComputedStyle(e),\"ellipsis\"!==t.textOverflow)return()=>{};if(\"nowrap\"!==t.whiteSpace&&\"pre\"!==t.whiteSpace)return()=>{};if(\"hidden\"!==t.overflowX&&\"clip\"!==t.overflowX)return()=>{};if(!Xv(e))return()=>{};if(e.scrollWidth<=e.clientWidth+.5)return()=>{};let n=Kv(e),i=n.text,s=0,r=i.length,o=-1;for(;s<=r;){let t=s+r>>1;n.write(i.slice(0,Yv(i,t))+\"…\"),e.scrollWidth<=e.clientWidth+.5?(o=t,s=t+1):r=t-1}let a=(o>=0?i.slice(0,Yv(i,o)):\"\")+\"…\";return n.write(a),Gv(e,a,n)}(s,r);a&&n.push(a);for(let t of s.children||[])e(t)}(e),()=>n.forEach(e=>e())}function Gv(e,t,n){return()=>{e.textContent===t&&n.restore()}}function Kv(e){let t=[];for(let n=e.firstChild;n;n=n.nextSibling)n.nodeType===Node.TEXT_NODE&&t.push(n);let n=t.map(e=>e.data);return{text:n.join(\"\"),write(e){t[0].data=e;for(let e=1;e<t.length;e++)t[e].data=\"\"},restore(){for(let e=0;e<t.length;e++)t[e].data=n[e]}}}function Yv(e,t){if(t<=0||t>=e.length)return t;let n=e.charCodeAt(t-1);return n>=55296&&n<=56319?t-1:t}function Xv(e){return!(e.childElementCount>0)&&Array.from(e.childNodes).some(e=>e.nodeType===Node.TEXT_NODE)}Hg(),Ng(),ah(),ah(),qg();var Jv=[\"clone\",\"render\"],Qv={clone:0,render:1},Zv=\"render\";function ew(e,t){return Qv[e]>=Qv[t]}var tw=[];function nw(e){if(!e)return null;if(Array.isArray(e)){let[t,n]=e;return\"function\"==typeof t?t(n):t}if(\"object\"==typeof e&&\"plugin\"in e){let{plugin:t,options:n}=e;return\"function\"==typeof t?t(n):t}return\"function\"==typeof e?e():e}function iw(e){return e&&Array.isArray(e.plugins)?e.plugins:tw}async function sw(e,t,n){let i=n,s=iw(t);for(let n of s){let s=n&&\"function\"==typeof n[e]?n[e]:null;if(!s)continue;let r=await s(t,i);typeof r<\"u\"&&(i=r)}return i}async function rw(e,t,n){let i=[],s=iw(t);for(let r of s){let s=r&&\"function\"==typeof r[e]?r[e]:null;if(!s)continue;let o=await s(t,n);typeof o<\"u\"&&i.push(o)}return i}var ow=0;function aw(e,t,n=!1){return!e||e.plugins&&!n||(e.plugins=function(e){let t=[];if(Array.isArray(e))for(let n of e){let e=nw(n);if(!e)continue;e.name||(e.name=\"anonymous-\"+ ++ow);let i=t.findIndex(t=>t&&t.name===e.name);i>=0&&t.splice(i,1),t.push(e)}for(let e of tw)e&&e.name&&!t.some(t=>t.name===e.name)&&t.push(e);return Object.freeze(t)}(t)),e}var lw=[\"resolveNode\",\"beforeSnap\",\"beforeClone\",\"afterClone\",\"beforeRender\",\"afterRender\"];function cw(e){let t=Array.isArray(e&&e.plugins)?e.plugins:[];for(let e of t){let t=nw(e);if(t&&!0!==t.pure)for(let e of lw)if(\"function\"==typeof t[e])return!0}return!1}ah(),Ag();var dw=\"data-snapdom-asset\",uw=\"http://www.w3.org/1999/xlink\",pw=0;function hw(e,t,n,i,s,r){let o=r.__compressedAssets||=new WeakMap,a=o.get(e);a||(a={token:String(++pw),properties:[]},o.set(e,a),e.setAttribute(dw,a.token));let l=a.properties.find(e=>e.kind===t&&e.name===n);l?(l.compressed!==i&&(l.original=i),l.compressed=s):a.properties.push({kind:t,name:n,original:i,compressed:s})}var gw=(e,t)=>\"style\"===t.kind?e.style?.getPropertyValue(t.name):e.getAttribute(t.name);function mw(e,t){let n=new Map;if(!e||!t)return n;let i=[e,...e.querySelectorAll(`[${dw}]`)];for(let e of i){let i=t.get(e);if(!i||e.getAttribute(dw)!==i.token)continue;let s=i.properties.filter(t=>gw(e,t)===t.compressed).map(e=>Object.freeze({...e}));s.length&&n.set(i.token,Object.freeze(s))}return n}function fw(e,t){if(!e||!t)return;let n=0;for(let i of[e,...e.querySelectorAll(`[${dw}]`)]){let e=t.get(i);e&&(e.token=String(++n),i.setAttribute(dw,e.token))}}function bw(e){if(!1===e.is2D)return 1/0;let t=e.a*e.a+e.b*e.b+e.c*e.c+e.d*e.d,n=e.a*e.d-e.b*e.c;return Math.sqrt((t+Math.sqrt(Math.max(0,t*t-4*n*n)))/2)}function yw(e,t){let n=t.element||e,i=n.isConnected?cg(n):n.style,s=t.__compressionClip,r=(e,t)=>{try{return e[t]?.baseVal?.value||0}catch{return 0}},o=s?.width||n.offsetWidth||parseFloat(i?.width)||r(n,\"width\"),a=s?.height||n.offsetHeight||parseFloat(i?.height)||r(n,\"height\"),l=Number.isFinite(t.width),c=Number.isFinite(t.height);if(!s&&(l||c)&&o&&a)try{let e=!1===t.outerTransforms&&t.__compressionRootTransform?t.__compressionRootTransform:Xy({baseTransform:i?.transform,rotate:i?.rotate,scale:i?.scale,width:o,height:a});if(!1===e.is2D)o=0,a=0;else{let t=Math.abs(e.a)*o+Math.abs(e.c)*a,n=Math.abs(e.b)*o+Math.abs(e.d)*a;o=Math.min(o,t),a=Math.min(a,n)}}catch{o=0,a=0}let d=(l||c?Math.max(l?o?t.width/o:1/0:0,c?a?t.height/a:1/0:0):t.scale||1)*(t.dpr||1);t.__compressionDensity=d;let u=new WeakMap,p=e=>{if(!e||1!==e.nodeType)return 1;if(u.has(e))return u.get(e);let t=e.isConnected?cg(e):e.style,i=1;try{t?.perspective&&\"none\"!==t.perspective&&(i=1/0);let s=t?.transform;if(s&&\"none\"!==s)i*=bw(new DOMMatrix(s));else if(e.transform?.baseVal?.numberOfItems){let t=new DOMMatrix;for(let n=0;n<e.transform.baseVal.numberOfItems;n++){let i=e.transform.baseVal.getItem(n).matrix;t=t.multiply(new DOMMatrix([i.a,i.b,i.c,i.d,i.e,i.f]))}i*=bw(t)}if(t?.scale&&\"none\"!==t.scale){let e=t.scale.trim().split(/\\s+/).map(e=>parseFloat(e)/(e.endsWith(\"%\")?100:1));i*=Math.max(...e.map(Math.abs))}if(e!==n&&t?.zoom&&\"normal\"!==t.zoom&&(i*=parseFloat(t.zoom)||1),\"svg\"===e.localName&&e.viewBox?.baseVal?.width>0&&e.viewBox.baseVal.height>0){let n=e.viewBox.baseVal,s=n=>/^\\d+(?:\\.\\d+)?px$/.test(t?.[n]||\"\")?parseFloat(t[n]):r(e,n),o=s(\"width\"),a=s(\"height\");i*=o>0&&a>0?Math.max(o/n.width,a/n.height):1/0}}catch{i=1/0}return Number.isFinite(i)||(i=1/0),e!==n&&(i*=p(e.parentElement||e.getRootNode?.().host)),u.set(e,i),i};return{density:d,stretch:p}}var vw=33554432,ww=new Map;function xw(e){let t=function(e,t){let n=e.indexOf(\",\");if(n<0||!/;base64/i.test(e.slice(0,n)))return null;let i=4*Math.ceil(t/3),s=e.length-n-1,r=Math.min(s,i);try{let t=atob(e.slice(n+1,n+1+r-r%4)),i=new Uint8Array(t.length);for(let e=0;e<t.length;e++)i[e]=t.charCodeAt(e);return i}catch{return null}}(e,4096);if(!t||t.length<16)return null;let n=e=>t[e]<<8|t[e+1];if(137===t[0]&&80===t[1]&&t.length>=24)return{w:(t[16]<<24|t[17]<<16|t[18]<<8|t[19])>>>0,h:(t[20]<<24|t[21]<<16|t[22]<<8|t[23])>>>0};if(71===t[0]&&73===t[1]&&70===t[2])return{w:t[6]|t[7]<<8,h:t[8]|t[9]<<8};if(82===t[0]&&73===t[1]&&87===t[8]&&t.length>=30){let e=t[15];if(32===e&&157===t[23])return{w:16383&(t[26]|t[27]<<8),h:16383&(t[28]|t[29]<<8)};if(76===e)return{w:1+(t[21]|(63&t[22])<<8),h:1+(16383&(t[22]>>6|t[23]<<2|(15&t[24])<<10))};if(88===e)return{w:1+(t[24]|t[25]<<8|t[26]<<16),h:1+(t[27]|t[28]<<8|t[29]<<16)}}if(255===t[0]&&216===t[1]){let e=2;for(;e+9<t.length;){if(255!==t[e]){e++;continue}let i=t[e+1];if(216===i||1===i||i>=208&&i<=215){e+=2;continue}if(i>=192&&i<=207&&196!==i&&200!==i&&204!==i)return{h:n(e+5),w:n(e+7)};let s=n(e+2);if(s<2)break;e+=2+s}}return null}function kw(e,t,n,i){let s=Math.min(1,Math.max(n/e,i/t));return!(s>0)||s>=.95?0:s}var Sw=Math.max(1,Math.min(4,(typeof navigator<\"u\"&&navigator.hardwareConcurrency||2)-1)),Cw=null,Ew=0,Mw=0,Aw=new Map;function _w(){for(let e of Aw.values())e(void 0);if(Aw.clear(),Array.isArray(Cw))for(let e of Cw)try{e?.terminate()}catch{}Cw=!1}function Tw(){if(!1===Cw)return!1;if(null===Cw){if(typeof Worker>\"u\"||typeof OffscreenCanvas>\"u\")return Cw=!1;Cw=[]}let e=Ew++%Sw;if(!Cw[e]){let t=function(){let e,t=null;try{e=URL.createObjectURL(new Blob([\"self.onmessage = async (e) => {\\n  const { id, dataURL, blob: given, srcLength, targetW, targetH, resFactor, quality, mime } = e.data\\n  try {\\n    const blob = given || await (await fetch(dataURL)).blob()\\n    const bmp = await createImageBitmap(blob)\\n    const nw = bmp.width, nh = bmp.height\\n    if (!nw || !nh) { bmp.close(); self.postMessage({ id, url: null }); return }\\n    const raw = Math.min(1, Math.max(targetW / nw, targetH / nh))\\n    if (!(raw > 0) || raw >= 0.95) { bmp.close(); self.postMessage({ id, url: null }); return }\\n    const factor = raw * resFactor\\n    const ow = Math.max(1, Math.round(nw * factor))\\n    const oh = Math.max(1, Math.round(nh * factor))\\n    const canvas = new OffscreenCanvas(ow, oh)\\n    const ctx = canvas.getContext('2d')\\n    ctx.imageSmoothingEnabled = true\\n    ctx.imageSmoothingQuality = 'high'\\n    ctx.drawImage(bmp, 0, 0, ow, oh)\\n    bmp.close()\\n    const out = await canvas.convertToBlob({ type: mime, quality })\\n    const url = new FileReaderSync().readAsDataURL(out)\\n    self.postMessage({ id, url: (url && url.length < srcLength) ? url : null })\\n  } catch (err) {\\n    self.postMessage({ id, error: String(err) })\\n  }\\n}\"],{type:\"text/javascript\"})),t=new Worker(e),t.onmessage=e=>{let t=Aw.get(e.data.id);t&&(Aw.delete(e.data.id),t(e.data.error?void 0:e.data.url??null))},t.onerror=_w}catch{t=null}return e&&URL.revokeObjectURL(e),t}();if(!t)return _w(),!1;Cw[e]=t}return Cw[e]}async function Iw(e,t,n,i){if(\"string\"!=typeof e||!e.startsWith(\"data:image\")||e.startsWith(\"data:image/svg\"))return null;t=Math.ceil(t),n=Math.ceil(n);let s=e.length+\":\"+e.slice(0,64)+e.slice(-64)+\":\"+t+\"x\"+n,r=oh.compress,o=r.get(s);if(o?.source===e)return o.result;let a=ww.get(s);if(a?.source===e&&a.cache===r)return a.promise;let l=(async()=>{let s,r=function(e){let t=/^data:([^;,]+)/.exec(e);return t?t[1]:\"\"}(e),o=\"image/jpeg\"===r?\"image/jpeg\":\"image/webp\"===r?\"image/webp\":\"image/png\",a=xw(e);if(a&&a.w>0&&a.h>0&&!kw(a.w,a.h,t,n))return null;if(e.length>=65536){let s=await function(e,t,n,i,s){let r=Tw();return r?new Promise(o=>{let a=++Mw,l=setTimeout(()=>{Aw.delete(a),o(void 0)},5e3);Aw.set(a,e=>{clearTimeout(l),o(e)});try{r.postMessage({id:a,dataURL:s?\"\":e,blob:s,srcLength:e.length,targetW:t,targetH:n,resFactor:1,quality:.92,mime:i})}catch{clearTimeout(l),Aw.delete(a),o(void 0)}}):Promise.resolve(void 0)}(e,t,n,o,i);if(void 0!==s)return s}try{s=await async function(e){let t=new Image;return t.decoding=\"sync\",t.src=e,\"function\"==typeof t.decode?(await t.decode(),t):(await new Promise((e,n)=>{t.onload=()=>e(),t.onerror=n}),t)}(e)}catch{return null}let l=s.naturalWidth||s.width,c=s.naturalHeight||s.height;if(!l||!c)return null;let d=kw(l,c,t,n);if(!d)return null;let u=1*d,p=Math.max(1,Math.round(l*u)),h=Math.max(1,Math.round(c*u)),g=document.createElement(\"canvas\");g.width=p,g.height=h;let m=g.getContext(\"2d\");if(!m)return null;m.imageSmoothingEnabled=!0,m.imageSmoothingQuality=\"high\",m.drawImage(s,0,0,p,h);try{let t=g.toDataURL(o,.92);if(\"string\"==typeof t&&t.startsWith(\"data:image\")&&t.length<e.length)return t}catch{}return null})(),c={source:e,promise:l,cache:r};ww.set(s,c);try{let t=await l;return function(e,t,n,i){if(n.length+(i?.length||0)>vw)return;e.set(t,{source:n,result:i});let s=0;for(let t of e.values())s+=t.source.length+(t.result?.length||0);for(;s>vw;){let t=e.keys().next().value,n=e.get(t);s-=n.source.length+(n.result?.length||0),e.delete(t)}}(r,s,e,t),t}finally{ww.get(s)===c&&ww.delete(s)}}var Lw=/^(cover|contain|(\\d+(\\.\\d+)?%(\\s+\\d+(\\.\\d+)?%)?))$/;async function Rw(e,t,n){if(!t.compress)return;let i={};await async function(e,t,n=new Map,i={}){if(!t.compress)return{count:0,before:0,after:0};let s=Array.from(e.querySelectorAll(\"img\"));\"IMG\"===e.tagName&&s.unshift(e);let r=0,o=0,a=0,l=async s=>{let l=s.getAttribute(\"src\")||\"\";if(!l.startsWith(\"data:image\")||l.startsWith(\"data:image/svg\"))return;let c=parseFloat(s.dataset.snapdomWidth)||parseFloat(s.style.width)||s.width||0,d=parseFloat(s.dataset.snapdomHeight)||parseFloat(s.style.height)||s.height||0;if(!c||!d)return;let u=i.value||=yw(e,t),p=u.density*u.stretch(n.get(s)||s),h=await Iw(l,c*p,d*p,s.__snapdomBlob);h&&(r++,o+=l.length,a+=h.length,s.setAttribute(\"src\",h),hw(s,\"attribute\",\"src\",l,h,t))};for(let e=0;e<s.length;e+=6)await Promise.allSettled(s.slice(e,e+6).map(l));return{count:r,before:o,after:a}}(e,t,n,i),await async function(e,t,n=new Map,i={}){if(!t.compress)return{count:0};let s=[],r=[e,...e.querySelectorAll(\"*\")];for(let e of r){let t=e.style&&e.style.backgroundImage;t&&t.includes(\"data:image\")&&s.push(e)}let o=0,a=async s=>{let r,a=n.get(s);if(!a||!a.isConnected)return;try{r=getComputedStyle(a)}catch{return}if((r.backgroundRepeat||\"repeat\").toLowerCase().split(\",\").some(e=>\"no-repeat\"!==e.trim()))return;let l=(s.style.backgroundSize||r.backgroundSize||\"auto\").toLowerCase();if(l.split(\",\").some(e=>!Lw.test(e.trim())))return;let{w:c,h:d}=function(e){return{w:e.offsetWidth||e.getBoundingClientRect().width||0,h:e.offsetHeight||e.getBoundingClientRect().height||0}}(a);if(!c||!d)return;let u=Math.max(1,...(l.match(/\\d+(?:\\.\\d+)?%/g)||[]).map(e=>parseFloat(e)/100)),p=i.value||=yw(e,t),h=p.density*p.stretch(a)*u,g=c*h,m=d*h,f=s.style.backgroundImage,b=[...f.matchAll(/url\\((['\"]?)(data:image\\/[^)'\"]+)\\1\\)/gi)],y=f;for(let e of b){let t=e[2];if(t.startsWith(\"data:image/svg\"))continue;let n=await Iw(t,g,m);n&&(y=y.split(t).join(n),o++)}y!==f&&(s.style.setProperty(\"background-image\",y,s.style.getPropertyPriority(\"background-image\")),hw(s,\"style\",\"background-image\",f,s.style.backgroundImage,t))};for(let e=0;e<s.length;e+=6)await Promise.allSettled(s.slice(e,e+6).map(a));return{count:o}}(e,t,n,i),await async function(e,t,n=new Map,i={}){if(!t.compress)return{count:0};let s=Array.from(e.querySelectorAll(\"image\"));\"image\"===e.localName&&s.unshift(e);let r=0,o=async s=>{let o=s.getAttribute(\"href\")||(\"function\"==typeof s.getAttributeNS?s.getAttributeNS(\"http://www.w3.org/1999/xlink\",\"href\"):null);if(!o||!o.startsWith(\"data:image\")||o.startsWith(\"data:image/svg\"))return;let a=s.getAttribute(\"width\")||\"\",l=s.getAttribute(\"height\")||\"\";if(a.includes(\"%\")||l.includes(\"%\"))return;let c=n.get(s),d=c?cg(c):s.style,u=(e,t)=>{if(/^\\d+(?:\\.\\d+)?px$/.test(d?.[e]||\"\"))return parseFloat(d[e]);if(/^\\d+(?:\\.\\d+)?(?:px)?$/.test(t.trim()))return parseFloat(t);try{return c?.[e]?.baseVal?.value||0}catch{return 0}},p=u(\"width\",a),h=u(\"height\",l);if(!p||!h)return;let g=i.value||=yw(e,t),m=g.density*g.stretch(c||s),f=await Iw(o,p*m,h*m);f&&(s.setAttribute(\"href\",f),hw(s,\"attribute\",\"href\",o,f,t),s.hasAttribute(\"xlink:href\")&&(s.setAttributeNS(uw,\"xlink:href\",f),hw(s,\"attribute\",\"xlink:href\",o,f,t)),r++)};for(let e=0;e<s.length;e+=6)await Promise.allSettled(s.slice(e,e+6).map(o));return{count:r}}(e,t,n,i)}function $w(e,t){if(Ig())return e;let n=e.indexOf(\"</style>\");if(-1===n)return e;let i,s=/<style\\b[^>]*>[\\s\\S]*?<\\/style>/g,r=[],o=n;for(s.lastIndex=n;i=s.exec(e);)r.push({text:e.slice(o,i.index),intern:!0}),r.push({text:i[0],intern:!1}),o=s.lastIndex;r.push({text:e.slice(o),intern:!0});let a,l=new Map,c=/ style=\"([^\"]*)\"/g;for(let e of r)if(e.intern)for(c.lastIndex=0;a=c.exec(e.text);)l.set(a[1],(l.get(a[1])||0)+1);let d=0;for(let[e,t]of l)t>1&&(d+=(t-1)*e.length);if(d<2048||e.includes(\" data-sdi=\"))return e;let u=function(e,t,n){let i=new Set;if(!t&&!n)return i;if(!e||e.querySelector(\"[data-sdi]\"))return null;let s=e=>{let t=e.getAttribute(\"style\");t&&i.add(t)};if(n&&e.querySelectorAll(\"[data-snapdom-asset][style]\").forEach(s),t)try{let t=n=>{for(let i of n){if(i.type===CSSRule.IMPORT_RULE||i.type===CSSRule.NAMESPACE_RULE)throw new Error(\"External or namespaced CSS\");if(i.selectorText){if(/\\[\\s*style\\b|data-sdi|\\[[^\\]]*\\\\|&/i.test(i.selectorText))throw new Error(\"Attribute-dependent or nested CSS\");e.querySelectorAll(i.selectorText).forEach(s)}i.cssRules&&t(i.cssRules)}};for(let n of[...e.querySelectorAll(\"style\")].slice(1)){let e=n.textContent||\"\";if(/@import\\b/i.test(e))return null;let i=new CSSStyleSheet;i.replaceSync(e),t(i.cssRules)}}catch{return null}let r=new Set,o=document.createElement(\"div\"),a=new XMLSerializer;for(let e of i){o.setAttribute(\"style\",e);let t=a.serializeToString(o).match(/ style=\"([^\"]*)\"/);t&&r.add(t[1])}return r}(t,r.some(e=>!e.intern),e.includes(\"data-snapdom-asset\"));if(null===u)return e;let p=new Map,h=0,g=[],m=(e,t)=>{if((l.get(t)||0)<2||u.has(t))return e;let n=p.get(t);return void 0===n&&(n=\"i\"+(h++).toString(36),p.set(t,n),g.push(`[data-sdi=\"${n}\"]{${t}}`)),` data-sdi=\"${n}\"`},f=\"\";for(let e of r)f+=e.intern?e.text.replace(c,m):e.text;return e.slice(0,n)+g.join(\"\")+f}async function Nw(e,t){let n,i,{clipWindow:s,outerTransforms:r,outerShadows:o,rootTransform2D:a,fontsCSS:l}=t,c=e.options;if(e!==c){let{options:t,...n}=e;e=Object.assign(c,n),Object.defineProperty(e,\"options\",{value:e,configurable:!0})}Cv(e,l),await sw(\"beforeRender\",e);let d=cg(e.element),u=e.element.getBoundingClientRect(),p=Math.max(1,vv(e.element.offsetWidth||parseFloat(d.width)||u.width||1)),h=Math.max(1,vv(e.element.offsetHeight||parseFloat(d.height)||u.height||1)),g=e.element.ownerDocument||document;if(!(s||e.element!==g.body&&e.element!==g.documentElement||e.__pinned)){let t=Math.max(e.element.scrollHeight||0,g.documentElement?.scrollHeight||0,g.body?.scrollHeight||0),n=Math.max(e.element.scrollWidth||0,g.documentElement?.scrollWidth||0,g.body?.scrollWidth||0);t>0&&(h=Math.max(h,vv(t))),n>0&&(p=Math.max(p,vv(n)));try{let i=(e.scrollbarCSS||\"\").length+(e.baseCSS||\"\").length+(e.fontsCSS||\"\").length+(e.classCSS||\"\").length,s=oh.measureHints.get(e.element);if(s&&s.cssLen===i&&s.w0===p&&s.docH===t&&s.docW===n)s.csh>0&&(h=Math.max(h,vv(s.csh))),s.csw>0&&(p=Math.max(p,vv(s.csw)));else{let s=g.createElement(\"div\");Zh(s),s.style.cssText=\"position:absolute!important;left:-9999px!important;top:0!important;width:\"+p+\"px!important;overflow:visible!important;visibility:hidden!important;\";let r=s.attachShadow({mode:\"open\"}),o=g.createElement(\"style\");o.textContent=(e.scrollbarCSS||\"\")+e.baseCSS+\"svg{overflow:visible;} foreignObject{overflow:visible;}\"+e.classCSS,r.appendChild(o),r.appendChild(e.clone.cloneNode(!0)),g.body.appendChild(s);let a=s.scrollHeight,l=s.scrollWidth;g.body.removeChild(s),oh.measureHints.set(e.element,{cssLen:i,w0:p,docH:t,docW:n,csh:a,csw:l}),a>0&&(h=Math.max(h,vv(a))),l>0&&(p=Math.max(p,vv(l)))}}catch{}}if(\"remove\"===e.options?.excludeMode||\"function\"==typeof e.options?.filter&&\"remove\"===e.options.filterMode){let t=yv(e.element,e.options),n=1,i=yv(e.element,{}),s=Math.max(2,.15*h);Number.isFinite(i)&&i>=h-s&&Number.isFinite(t)&&t>0&&(h=Math.max(1,Math.min(h,vv(t+n))))}if(e.options?.reconcile)try{let t=(e.scrollbarCSS||\"\")+e.baseCSS+\"svg{overflow:visible;} foreignObject{overflow:visible;}\"+e.classCSS;!function(e,t,n,i,s,r){let o=e.ownerDocument||document,a=e.getBoundingClientRect(),l=s>0&&a.width>0?a.width/s:1,c=r>0&&a.height>0?a.height/r:1;if(Math.abs(l-c)>.02)return 0;let d=o.createElement(\"div\");Zh(d),d.style.cssText=\"position:absolute!important;left:-9999px!important;top:0!important;width:\"+s+\"px!important;overflow:visible!important;visibility:hidden!important;\";let u=d.attachShadow({mode:\"open\"}),p=o.createElement(\"style\");p.textContent=n,u.appendChild(p);let h=t.cloneNode(!0);u.appendChild(h),o.body.appendChild(d);let g=0,m=(e,t,n)=>{let i=cg(e),s=\"border-box\"===i.boxSizing,r=(e,t,...n)=>{let i=parseFloat(e);if(!Number.isFinite(i))return t;let r=i+(s?0:n.reduce((e,t)=>e+(parseFloat(t)||0),0));return Math.abs(r-t)<=.51?r:t};return{width:r(i.width,t,i.paddingLeft,i.paddingRight,i.borderLeftWidth,i.borderRightWidth),height:r(i.height,n,i.paddingTop,i.paddingBottom,i.borderTopWidth,i.borderBottomWidth)}};try{let e=h.getBoundingClientRect(),n=h.offsetWidth||s,o=h.offsetHeight||r,a=n>0&&e.width>0?e.width/n:1,d=o>0&&e.height>0?e.height/o:1,u=(e,t,n=!1)=>{let s=e.children,r=t.children,o=Math.min(s.length,r.length);for(let e=0;e<o;e++){let t=s[e],o=r[e],p=i.get(t),h=n||Jy.has(t);if(1===p?.nodeType&&hh(t)&&t.style&&p.isConnected){let e=p.getBoundingClientRect();if(e.width>0&&e.height>0){let n=o.getBoundingClientRect(),i=e.width/l,s=e.height/c,r=n.width,u=n.height,f=p.offsetWidth||i,b=p.offsetHeight||s,y=o.offsetWidth||r,v=o.offsetHeight||u,w=Math.abs(i-f)>wv||Math.abs(s-b)>wv||Math.abs(r-y)>wv||Math.abs(u-v)>wv;if(h){let e=m(o,y,v);i=r>0?i*a*e.width/r:i,s=u>0?s*d*e.height/u:s,r=e.width,u=e.height}else if(w){let e=m(p,f,b),t=m(o,y,v);i=e.width,s=e.height,r=t.width,u=t.height}let x=r-i,k=u-s;(Math.abs(x)>wv||Math.abs(k)>wv)&&(t.style.boxSizing=\"border-box\",t.style.width=`${vv(i)}px`,t.style.height=`${vv(s)}px`,g++)}}u(t,o,h)}};u(t,h)}finally{d.remove()}}(e.element,e.clone,t,e.nodeMap,p,h)}catch(e){console.warn(\"[snapdom] reconcile pass failed:\",e)}let m=(e,t=NaN)=>{let n=\"string\"==typeof e?parseFloat(e):e;return Number.isFinite(n)?n:t},f=m(e.options.width),b=m(e.options.height),y=s?vv(s.width):p,v=s?vv(s.height):h,w=y,x=v,k=Number.isFinite(f),S=Number.isFinite(b),C=v>0?y/v:1;k&&S?(w=Math.max(1,vv(f)),x=Math.max(1,vv(b))):k?(w=Math.max(1,vv(f)),x=Math.max(1,vv(w/(C||1)))):S&&(x=Math.max(1,vv(b)),w=Math.max(1,vv(x*(C||1))));let E=0,M=0,A=p,_=h;if(s){let t=0,n=0;if(Pw(e.element)){let i=null;if(!r&&a&&Number.isFinite(a.a))i={a:a.a,b:a.b||0,c:a.c||0,d:a.d||1,e:0,f:0};else{let t=Ky(e.element),n=nv(d.transform&&\"none\"!==d.transform?d.transform:\"\",t);n&&n.is2D&&(i={a:n.a,b:n.b,c:n.c,d:n.d,e:0,f:0})}if(i&&(1!==i.a||0!==i.b||0!==i.c||1!==i.d)){let{ox:e,oy:s}=Gy(d,p,h),r=Vy(p,h,i,e,s);t=r.minX,n=r.minY}}E=vv(s.x+t),M=vv(s.y+n),A=vv(E+s.width),_=vv(M+s.height)}else if(!r&&a&&Number.isFinite(a.a)){let e=Vy(p,h,{a:a.a,b:a.b||0,c:a.c||0,d:a.d||1,e:0,f:0},0,0);E=vv(e.minX),M=vv(e.minY),A=vv(e.maxX),_=vv(e.maxY)}else if(r&&Pw(e.element)){let t=d.transform&&\"none\"!==d.transform?d.transform:\"\",n=Ky(e.element),i=Xy({baseTransform:t,rotate:n.rotate||\"0deg\",scale:n.scale,translate:n.translate,width:p,height:h}),{ox:s,oy:r}=Gy(d,p,h),o=i.is2D?i:new DOMMatrix(i.toString()),a=Vy(p,h,{a:o.a,b:o.b,c:o.c,d:o.d,e:0,f:0},s,r);E=vv(a.minX),M=vv(a.minY),A=vv(a.maxX),_=vv(a.maxY)}let T=Fy(d),I=Oy(d),L=Hy(d),R=By(d),$=Dy(d),N=u.width>0?(A-E)/u.width:1,P=u.height>0?(_-M)/u.height:1,F=\"subtree\"!==o||s?{top:0,right:0,bottom:0,left:0}:function(e,t,n,i=1,s=1){let r=0,o=0,a=0,l=0,c=jy(n.get(e)||cg(e));if(c.x&&c.y)return{top:0,right:0,bottom:0,left:0};let d=e.getBoundingClientRect();for(let u of t.values()){if(u===e||1!==u.nodeType||u.ownerDocument!==e.ownerDocument)continue;let t=n.get(u);if(!t||!Uy(t))continue;let p=zy(t);if(!(p.top||p.right||p.bottom||p.left))continue;let h=u.getBoundingClientRect(),g={left:h.left-p.left/i,top:h.top-p.top/s,right:h.right+p.right/i,bottom:h.bottom+p.bottom/s};for(let t=u.parentElement;t;t=t.parentElement){let i=jy(n.get(t)||cg(t));if(i.x||i.y){let e=t.getBoundingClientRect();i.x&&(g.left=Math.max(g.left,e.left),g.right=Math.min(g.right,e.right)),i.y&&(g.top=Math.max(g.top,e.top),g.bottom=Math.min(g.bottom,e.bottom))}if(t===e)break}c.x||(l=Math.max(l,(d.left-g.left)*i),o=Math.max(o,(g.right-d.right)*i)),c.y||(r=Math.max(r,(d.top-g.top)*s),a=Math.max(a,(g.bottom-d.bottom)*s))}return{top:Math.max(0,Math.ceil(r)),right:Math.max(0,Math.ceil(o)),bottom:Math.max(0,Math.ceil(a)),left:Math.max(0,Math.ceil(l))}}(e.element,e.nodeMap,e.styleCache,N,P),O=s?{top:0,right:0,bottom:0,left:0}:o?{top:vv(Math.max(T.top,I.top,F.top)+L.top+R.top+$.bleed.top),right:vv(Math.max(T.right,I.right,F.right)+L.right+R.right+$.bleed.right),bottom:vv(Math.max(T.bottom,I.bottom,F.bottom)+L.bottom+R.bottom+$.bleed.bottom),left:vv(Math.max(T.left,I.left,F.left)+L.left+R.left+$.bleed.left)}:{top:L.top,right:L.right,bottom:L.bottom,left:L.left};E=vv(E-O.left),M=vv(M-O.top),A=vv(A+O.right),_=vv(_+O.bottom);let q=Math.max(1,vv(A-E)),H=Math.max(1,vv(_-M)),B=\"http://www.w3.org/2000/svg\",D=Pw(e.element)?2:0,z=vv(D+(r?0:1)),U=Math.ceil(q+2*z),j=Math.ceil(H+2*z),W=vv(-(vv(E)-z)),V=vv(-(vv(M)-z)),G=Math.max(0,W),K=Math.max(0,V),Y=vv(U-Math.min(0,W)),X=vv(j-Math.min(0,V)),J=document.createElementNS(B,\"foreignObject\");J.setAttribute(\"x\",String(Math.min(0,W))),J.setAttribute(\"y\",String(Math.min(0,V))),J.setAttribute(\"width\",String(Y)),J.setAttribute(\"height\",String(X)),J.style.overflow=\"visible\";let Q=document.createElement(\"style\");Q.textContent=(e.scrollbarCSS||\"\")+e.baseCSS+e.fontsCSS+\"svg{overflow:visible;} foreignObject{overflow:visible;} foreignObject>div{-webkit-text-size-adjust:100%!important;text-size-adjust:100%!important;}\"+e.classCSS,J.appendChild(Q);let Z=document.createElement(\"div\");Z.setAttribute(\"xmlns\",\"http://www.w3.org/1999/xhtml\"),Z.style.cssText=`all:initial;box-sizing:border-box;display:block;overflow:visible;width:${Y}px;height:${X}px`+(0!==G||0!==K?`;padding:${K}px 0 0 ${G}px !important`:\"\"),Z.appendChild(e.clone),J.appendChild(Z);let ee=(new XMLSerializer).serializeToString(J),te=k||S,ne=Object.freeze({w0:y,h0:v,vbW:U,vbH:j,targetW:w,targetH:x,contentX:vv(W+(s?E:0)),contentY:vv(V+(s?M:0)),clip:s?Object.freeze({x:vv(E),y:vv(M),width:y,height:v}):null});Object.defineProperty(c,\"meta\",{value:ne,enumerable:!0,writable:!1,configurable:!0}),i=`<svg xmlns=\"${B}\" width=\"${!te||Ig()?U:k?w:vv(U*(x/j))}\" height=\"${!te||Ig()?j:S?x:vv(j*(w/U))}\" viewBox=\"0 0 ${U} ${j}\" font-size=\"${parseFloat(cg(g.documentElement)?.fontSize)||16}px\">`+$w(ee,J)+\"</svg>\",n=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`,e.svgString=i,e.dataURL=n,c.__artifacts={classCSS:e.classCSS||\"\",fontsCSS:e.fontsCSS||\"\",baseCSS:e.baseCSS||\"\",scrollbarCSS:e.scrollbarCSS||\"\"},await sw(\"afterRender\",e),e.clone=e.nodeMap=e.styleCache=e.svgString=null;let ie=[...document.querySelectorAll(\"#snapdom-sandbox\")].find(eg);return ie&&\"absolute\"===ie.style.position&&ie.remove(),e.dataURL}function Pw(e){return function(e){let t=cg(e),n=t.transform||\"none\";if(\"none\"!==n&&!/^matrix\\(\\s*1\\s*,\\s*0\\s*,\\s*0\\s*,\\s*1\\s*,\\s*0\\s*,\\s*0\\s*\\)$/i.test(n))return!0;let i=t.rotate&&\"none\"!==t.rotate&&\"0deg\"!==t.rotate,s=t.scale&&\"none\"!==t.scale&&\"1\"!==t.scale,r=t.translate&&\"none\"!==t.translate&&\"0px 0px\"!==t.translate;return!!(i||s||r)}(e)}function Fw(e){let t=Array.isArray(e.plugins)?e.plugins:tw.slice(),n=[];for(let e of t){let t=nw(e);t&&\"function\"==typeof t.resolveNode&&n.push(t.resolveNode.bind(t))}return n.length?n:null}async function Ow(e,t){if(!e)throw new Error(\"Element cannot be null or undefined\");t.__session=Wv(t.cache),delete t.__compressedAssets,delete t.__compressedSnapshot,delete t.__compressionDensity,t.__resolveNodeHooks=Fw(t);let n=t;n.element=e,Object.defineProperty(n,\"options\",{value:n,configurable:!0});let i,s,r,o,a,l,c,d=\"\",u=null,p=t.needs||Zv,h=n.format,g=n.type;await sw(\"beforeSnap\",n);let m=n.format!==h&&/^(?:png|jpe?g|webp|svg)$/i.test(n.format),f=n.type!==g&&/^(?:png|jpe?g|webp|svg)$/i.test(n.type);if(m||f){let e=String(m?n.format:n.type).toLowerCase();n.format=\"jpg\"===e?\"jpeg\":e,n.type=n.format,n.__explicitFormat=n.format,/^(?:jpeg|webp)$/.test(n.format)&&(null==n.backgroundColor||\"transparent\"===n.backgroundColor)&&(n.backgroundColor=\"#ffffff\")}await sw(\"beforeClone\",n);let b=!1!==n.outerTransforms,y=\"subtree\"===n.outerShadows?\"subtree\":!!n.outerShadows,v=n.clip?Qy(n.element,n.clip):null;if(void 0===t.__styleShare)try{t.__styleShare=function(e){try{let t=ff(e.ownerDocument||document).shareGate;if(null===t)return!1;if(!t.length)return!0;let n=new Set,i=e=>{n.add(\"t\"+e.localName),e.id&&n.add(\"i\"+e.id);let t=e.classList;for(let e=0;e<t.length;e++)n.add(\"c\"+t[e])};i(e);for(let t of e.querySelectorAll(\"*\"))i(t);let s=[];for(let{sel:e,key:i}of t)(null===i||n.has(i))&&s.push(e);if(!s.length)return!0;let r=s.join(\",\");return!e.matches(r)&&null===e.querySelector(r)}catch{return!1}}(n.element)&&(\"function\"!=typeof n.element.getAnimations||0===n.element.getAnimations({subtree:!0}).length)}catch{t.__styleShare=!1}let w=function(e){if(!1!==e&&\"auto\"!==e)return null;let t=performance.now()+(\"auto\"===e?$g:Rg),n=null,i={yielded:!1,due:()=>performance.now()>=t,pause:()=>n||(n=new Promise(e=>{let s=new MessageChannel;s.port1.onmessage=()=>{n=null,i.yielded=!0,t=performance.now()+Rg,e()},s.port2.postMessage(0)}))};return i}(t.fast);for(;;){t.__slicer=w;let e=Vv(n.element,v);try{({clone:i,classCSS:s,classPrefixCSS:r,styleCache:o,nodeMap:a,reconcileRisk:l,clipWindow:c}=await Mv(n.element,n.options)),l>0&&!t.reconcile&&(Fg(t.__session,\"reconcile-risk\",\"text in inline/table-cell elements kept natural width and may re-wrap; pass { reconcile: true } for pixel-exact layout\"),oh.warnedReconcile||(oh.warnedReconcile=!0,console.warn(\"[snapdom] Text in inline/table-cell elements kept its natural width and may re-wrap under font-fallback rasterization. Pass { reconcile: true } for pixel-exact layout (roughly doubles capture time).\"))),!b&&i&&(u=Wy(n.element,i)),!y&&i&&iv(n.element,i,n.options),i&&(av(n.element,i,a),sv(n.element,i))}finally{e()}if(!w?.yielded||!t.__tornSinceStart?.())break;w=null,t.__session=Wv(t.cache)}if(t.__slicer=null,n.clone=i,n.classCSS=s,n.styleCache=o,n.nodeMap=a,await sw(\"afterClone\",n),!ew(p,\"render\"))return null;if(w?.due()&&await w.pause(),hv(n.clone),\"remove\"===n.options?.excludeMode||\"function\"==typeof n.options?.filter&&\"remove\"===n.options.filterMode)try{!function(e,t,n=new Map,i=null){!function e(t,s){if(1!==t?.nodeType||1!==s?.nodeType)return;let r=t.childElementCount>s.childElementCount,o=n.get(t)||getComputedStyle(t);if(n.has(t)||n.set(t,o),r&&mv(t,o)){s.style.height||(s.style.height=\"auto\"),s.style.width||(s.style.width=\"auto\"),s.style.removeProperty(\"block-size\"),s.style.removeProperty(\"inline-size\"),s.style.minHeight||(s.style.minHeight=\"0\"),s.style.minWidth||(s.style.minWidth=\"0\"),s.style.maxHeight||(s.style.maxHeight=\"none\"),s.style.maxWidth||(s.style.maxWidth=\"none\");let e=o.overflowY||o.overflowBlock||\"visible\",t=o.overflowX||o.overflowInline||\"visible\";(\"visible\"!==e||\"visible\"!==t)&&(s.style.overflow=\"visible\")}let a=Array.from(s.children);if(i)for(let t of a){let n=i.get(t);n&&1===n.nodeType&&e(n,t)}else{let n=Array.from(t.children);for(let t=0;t<Math.min(n.length,a.length);t++)e(n[t],a[t])}}(e,t)}(n.element,n.clone,n.styleCache,n.nodeMap)}catch(e){Fg(t.__session,\"shrink-failed\",\"shrink pass failed\",e),console.warn(\"[snapdom] shrink pass failed:\",e)}try{await Ob(n.clone,n.element,n.nodeMap)}catch{}let x=e=>Promise.resolve().then(e),k=(async()=>{await Promise.all([x(()=>Iv(n.clone,n.options)),x(()=>qv(n.element,n.clone,n.styleCache,n.options,n.nodeMap))]);try{Hv(n.element,n.clone,n.nodeMap)}catch(e){Fg(t.__session,\"backdrop-filter-failed\",\"backdrop-filter emulation failed\",e),console.warn(\"[snapdom] backdrop-filter emulation failed:\",e)}if(t.compress&&(t.__compressionClip=c,t.__compressionRootTransform=u,await x(()=>Rw(n.clone,n.options,n.nodeMap))),t.captureSelection)try{!function(e){for(let t of e.keys()){let e=t.__snapdomFieldSelection;if(!e)continue;delete t.__snapdomFieldSelection;let{images:n,positions:i,sizes:s,repeats:r,origins:o,clips:a,base:l}=e,c=t.style.backgroundImage||l.image;c&&\"none\"!==c?(n.push(c),i.push(t.style.backgroundPosition||l.position),s.push(t.style.backgroundSize||l.size),r.push(t.style.backgroundRepeat||l.repeat),o.push(t.style.backgroundOrigin||l.origin),a.push(t.style.backgroundClip||l.clip)):(n.push(\"linear-gradient(transparent,transparent)\"),i.push(\"0% 0%\"),s.push(\"auto\"),r.push(\"repeat\"),o.push(l.origin||\"padding-box\"),a.push(l.clip||\"border-box\")),t.style.backgroundImage=n.join(\",\"),t.style.backgroundPosition=i.join(\",\"),t.style.backgroundSize=s.join(\",\"),t.style.backgroundRepeat=r.join(\",\"),t.style.backgroundOrigin=o.join(\",\"),t.style.backgroundClip=a.join(\",\")}}(n.nodeMap)}catch(e){Fg(t.__session,\"selection-compose-failed\",\"field selection compose failed\",e)}})(),S=Promise.resolve();(\"auto\"===t.embedFonts?((n.element.ownerDocument||document).fonts?.size||0)>0:t.embedFonts)&&(S=x(async()=>{let e=n.element.ownerDocument||document,i=v?e=>{try{let t=e.getBoundingClientRect();return t.right>=v.left-200&&t.left<=v.right+200&&t.bottom>=v.top-200&&t.top<=v.bottom+200}catch{return!0}}:null,{required:s,usedCodepoints:r}=!v&&t.__fontUsage||cy(n.element,i);if(\"auto\"===t.embedFonts){let t=new Set;try{for(let n of e.fonts)t.add(String(n.family).replace(/[\"']/g,\"\").toLowerCase())}catch{}if(!(t.size>0&&Array.from(s).some(e=>t.has(String(e).split(\"__\")[0].toLowerCase()))))return}if(Ig()){let t=new Set(Array.from(s).map(e=>String(e).split(\"__\")[0]).filter(Boolean));await dy(t,1,e)}d=await ly({required:s,usedCodepoints:r,exclude:n.options.excludeFonts,localFonts:n.options.localFonts,useProxy:n.options.useProxy,fontStylesheetDomains:n.options.fontStylesheetDomains,iconMatchers:n.options.__iconMatchers,doc:e})})),await Promise.all([k,S]),(n.options.plugins||[]).some(e=>e&&(\"function\"==typeof e.beforeRender||\"function\"==typeof e.afterRender)),n.options.engine,w?.due()&&await w.pause();let C=n.clone;fw(C,t.__compressedAssets);let E=await Nw(n,{clipWindow:c,outerTransforms:b,outerShadows:y,rootTransform2D:u,fontsCSS:d});if(t.__compressedSnapshot=mw(C,t.__compressedAssets),\"function\"==typeof t.__retain)try{t.__retain({clone:i,nodeMap:a,styleCache:o,styleMap:t.__session.styleMap,classPrefixCSS:r,fontsCSS:d,clipWindow:c,outerTransforms:b,outerShadows:y,rootTransform2D:u,__compressedAssets:t.__compressedAssets,__compressionDensity:t.__compressionDensity})}catch{}return E}Hg(),ah(),ng(),ah(),wh();var qw=new Set([\"png\",\"jpeg\",\"jpg\",\"webp\",\"svg\"]);Ng(),qg(),Hg();var Hw=\"svg,iframe,canvas,video,audio,object,embed,slot,template,picture,style,pre\";var Bw=/(?:^|;)\\s*(?:-webkit-)?backdrop-filter:\\s*(?!none(?:\\s*!important)?(?:;|$))[^;]+/i;function Dw(e,t){let n=t.has(\"backdrop-filter\")||t.has(\"-webkit-backdrop-filter\");if(!n&&(i=e,n=/(?:^|;)\\s*(?:-webkit-)?backdrop-filter\\s*:/i.test(i.getAttribute?.(\"style\")||\"\"),!n))try{n=!!e.querySelector?.('[style*=\"backdrop-filter\" i]')}catch{n=!0}var i;if(!n)return!1;let s=[e];e.querySelectorAll&&s.push(...e.querySelectorAll(\"*\"));for(let e of s){let t=getComputedStyle(e),n=t.getPropertyValue(\"backdrop-filter\")||t.getPropertyValue(\"-webkit-backdrop-filter\");if(n&&\"none\"!==n)return!0}return!1}var zw=new WeakMap;function Uw(e,t){if(e===t)return!0;if(!e.endsWith(\"px\")||!t.endsWith(\"px\"))return!1;let n=parseFloat(e),i=parseFloat(t);return Number.isFinite(n)&&Number.isFinite(i)&&Math.abs(n-i)<=.0625}var jw=new Map,Ww=[\"width\",\"height\",\"min-width\",\"min-height\"];function Vw(e){let t=jw.get(e);if(void 0===t){t=null;for(let n of Ww){let i=e.match(new RegExp(\"(?:^|;)\"+n+\":([^;]+)\"));i&&i[1].endsWith(\"px\")&&((t||={})[n]=i[1])}jw.size>5e3&&jw.clear(),jw.set(e,t)}return t}function Gw(e){if(e.classList&&e.classList.length)for(let t of Array.from(e.classList))/^c\\d+$/.test(t)&&e.classList.remove(t)}function Kw(e,t){let n=[e];for(;n.length;){let e=n.pop();if(1===e.nodeType){let n=t.nodeMap.get(e);void 0!==n&&(t.nodeMap.delete(e),t.srcToClone.get(n)===e&&t.srcToClone.delete(n)),t.styleMap.delete(e)}for(let t=e.firstChild;t;t=t.nextSibling)n.push(t)}}var Yw={attempts:0,served:0,reconciled:0};async function Xw(e,t,n){Yw.attempts++;try{let i=await async function(e,t,n){let i=t.retained;if(!i||!i.clone||!i.styleMap||!i.srcToClone||n.reconcile||n.clip||n.captureSelection||i.clipWindow||e.scrollTop||e.scrollLeft||function(e){try{return e.matches?.(\"dialog,[popover]\")||!!e.querySelector?.(\"dialog,[popover]\")}catch{return!0}}(e)||function(e){if(void 0!==e.__usesBackdropFilter)return e.__usesBackdropFilter;let t=!1;for(let n of e.styleMap.values())if(Bw.test(n)){t=!0;break}return e.__usesBackdropFilter=t,t}(i)||i.fontsCSS||cw(n))return null;for(let e of n.plugins||[])if(e&&(\"function\"==typeof e.beforeSnap||\"function\"==typeof e.beforeClone||\"function\"==typeof e.resolveNode||\"function\"==typeof e.afterClone))return null;if(i.classPrefixCSS&&(i.classPrefixCSS.includes(\"::marker\")||i.classPrefixCSS.includes(\"::first-line\"))||\"remove\"===n.excludeMode)return null;let s=e.ownerDocument||document,r=bf(e);if(!r||function(e){let t=Hm(),n=zw.get(e);if(n&&n.epoch===t)return n.leaky;let i=!1,s={budget:2e4},r=e=>{for(let t=0;t<e.length&&!i;t++){if(--s.budget<0)return void(i=!0);let n=e[t],o=n.selectorText;if(o&&/[+~]|:has\\(/.test(o))return void(i=!0);let a=n.style;if(a&&(a.counterReset||a.counterIncrement||a.counterSet||a.content&&a.content.includes(\"counter\")))return void(i=!0);n.cssRules&&n.cssRules.length&&r(n.cssRules)}};try{for(let t of e.styleSheets){let e=null;try{e=t.cssRules}catch{i=!0}if(i)break;e&&r(e)}if(!i){let t=e.adoptedStyleSheets;if(Array.isArray(t))for(let e of t){if(i)break;try{r(e.cssRules)}catch{i=!0}}}}catch{i=!0}return zw.set(e,{epoch:t,leaky:i}),i}(s))return null;let o=[];e:for(let n of t.dirtyRoots){if(!n.isConnected||n===e||!e.contains(n))return null;for(let i of t.dirtyRoots)if(i!==n&&i!==e&&i.contains(n))continue e;o.push(n)}if(!o.length)return null;n.__compressedAssets=i.__compressedAssets,n.__compressionDensity=i.__compressionDensity,n.__compressionRootTransform=i.rootTransform2D;for(let t of o){if(t.parentElement===e||t.matches?.(Hw)||t.querySelector?.(Hw)||Dw(t,r))return null;let s=i.srcToClone.get(t);if(!s||!s.parentNode)return null;let o,a=new Map,l={styleMap:i.styleMap,styleCache:i.styleCache,nodeMap:a,options:n},c=Vv(t,null),d=Py(t);try{o=await Cb(t,l,n)}finally{d(),c()}if(!o||1!==o.nodeType||o.querySelector?.(\"style[data-sd]\")||(await Iy(t,o,l,n),l.__pseudoCSS))return null;await cb(o,l),hv(o);try{await Ob(o,t,a)}catch{}if(await Promise.all([Iv(o,n),qv(t,o,i.styleCache,n,a)]),n.compress)try{await Rw(o,n,a)}catch{}for(let[e,t]of a.entries())_v(e,t);s.replaceWith(o),Kw(s,i);for(let[e,t]of a.entries())i.nodeMap.set(e,t),i.srcToClone.set(t,e)}let a={styleMap:i.styleMap,styleCache:i.styleCache,nodeMap:i.nodeMap,options:n};for(let[e,t]of i.nodeMap.entries()){if(!t||1!==t.nodeType||!t.isConnected)continue;let s=i.styleMap.get(e);if(!s)continue;let r=Vw(s);if(!r)continue;let o=null,l=!1;for(let e in r)if(o||=getComputedStyle(t),!Uw(o.getPropertyValue(e),r[e])){l=!0;break}if(l){if(n.__compressedAssets?.has(e))return null;Yw.reconciled++,await qf(t,e,a,n)}}let l=lg(i.styleMap);for(let[e,t]of i.styleMap.entries())Gw(e),Av(e,t,l);let c=(i.classPrefixCSS||\"\")+Array.from(l.entries()).map(([e,t])=>`.${t}{${e}}`).join(\"\");fw(i.clone,n.__compressedAssets);let d=await Nw({element:e,options:n,plugins:n.plugins,clone:i.clone,classCSS:c,styleCache:i.styleCache,nodeMap:i.nodeMap},{clipWindow:null,outerTransforms:i.outerTransforms,outerShadows:i.outerShadows,rootTransform2D:i.rootTransform2D,fontsCSS:i.fontsCSS||\"\"});return n.__compressedSnapshot=mw(i.clone,n.__compressedAssets),i.__compressedAssets=n.__compressedAssets,i.__compressionDensity=n.__compressionDensity,d}(e,t,n);return i&&Yw.served++,i}catch{return null}}wh();var Jw=new WeakMap,Qw=new WeakMap,Zw=new WeakSet,ex=new WeakMap,tx=new Map,nx=[\"scroll\",\"input\",\"change\",\"focusin\",\"focusout\",\"pointerdown\",\"pointerup\",\"pointercancel\",\"keydown\",\"keyup\",\"beforetoggle\",\"toggle\"],ix=[\"(prefers-color-scheme: dark)\",\"(prefers-reduced-motion: reduce)\",\"(prefers-contrast: more)\",\"(forced-colors: active)\",\"(inverted-colors: inverted)\",\"(prefers-reduced-transparency: reduce)\",\"(hover: hover)\",\"(any-hover: hover)\",\"(pointer: coarse)\",\"(any-pointer: coarse)\",\"(color-gamut: p3)\",\"(dynamic-range: high)\"];function sx(e){let t=e?.defaultView;return\"function\"!=typeof t?.matchMedia?\"\":ix.map(e=>{try{return t.matchMedia(e).matches?\"1\":\"0\"}catch{return\"?\"}}).join(\"\")}function rx(e){let t=[];for(let n=e;n;){try{let e=n.getBoundingClientRect();t.push(e.x,e.y,e.width,e.height)}catch{t.push(\"?\")}n=n.parentElement?n.parentElement:n.getRootNode?.()?.host||null}return t.join(\"|\")}function ox(e,t){if(t.disposed||(tx.delete(e),tx.set(e,t),tx.size<=64))return;let[n,i]=tx.entries().next().value;ax(n,i)}function ax(e,t){t.disposed=!0,tx.delete(e),Jw.delete(e);for(let e of t.observers)try{e.disconnect()}catch{}for(let n of nx)e.removeEventListener(n,t.onMediaDirty,!0);for(let e of t.trackedShadowRoots.keys())for(let n of cx)e.removeEventListener(n,t.onMediaDirty,!0);for(let[e,n]of t.trackedImages)e.removeEventListener(\"load\",n),e.removeEventListener(\"error\",n);t.trackedImages.clear(),t.trackedShadowRoots.clear(),t.images.length=0,t.controls.length=0,t.scrollNodes.length=0,t.observers.length=0,t.last=null,t.retained=null,t.retainedFrameDriven=!1}function lx(e,t){if(!e.querySelectorAll)return!1;let n=Qw.get(e);Qw.delete(e);let i=new Set(n?.roots||[]);if(n&&(t.controls=n.controls,t.scannedImages=n.images),!n){let t=[e];for(let e=0;e<t.length;e++){let n=t[e];n.shadowRoot&&!i.has(n.shadowRoot)&&(i.add(n.shadowRoot),t.push(n.shadowRoot));for(let e of n.querySelectorAll(\"*\"))e.shadowRoot&&!i.has(e.shadowRoot)&&(i.add(e.shadowRoot),t.push(e.shadowRoot))}}for(let[e,n]of t.trackedShadowRoots)if(!i.has(e)){try{n.disconnect()}catch{}for(let n of cx)e.removeEventListener(n,t.onMediaDirty,!0);t.trackedShadowRoots.delete(e);let i=t.observers.indexOf(n);i>=0&&t.observers.splice(i,1)}for(let e of i)if(!t.trackedShadowRoots.has(e))try{let n=new MutationObserver(t.markDirty);n.observe(e,{subtree:!0,childList:!0,attributes:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0}),n.__flush=t.markDirty,t.observers.push(n),t.trackedShadowRoots.set(e,n);for(let n of cx)e.addEventListener(n,t.onMediaDirty,{capture:!0,passive:!0});t.retained&&t.dirtyAll()}catch{}return!!n}var cx=[\"scroll\",\"change\",\"beforetoggle\",\"toggle\"];function dx(e,t){return[e,...t.trackedShadowRoots.keys()]}function ux(e,t){let n=t.scannedImages;if(t.scannedImages=null,!n){n=[],\"IMG\"===e.tagName&&n.push(e);for(let i of dx(e,t))i.querySelectorAll&&n.push(...i.querySelectorAll(\"img\"))}if(t.images=n,t.trackedImages.size){let e=new Set(n);for(let[n,i]of t.trackedImages)e.has(n)||(n.removeEventListener(\"load\",i),n.removeEventListener(\"error\",i),t.trackedImages.delete(n))}for(let e of n){if(e.complete||t.trackedImages.has(e))continue;let n=()=>{t.capturing&&(t.torn=!0),t.dirty=!0,t.dirtyRoots=null,e.removeEventListener(\"load\",n),e.removeEventListener(\"error\",n),t.trackedImages.delete(e)};t.trackedImages.set(e,n),e.addEventListener(\"load\",n),e.addEventListener(\"error\",n)}}function px(e){let t=new Map,n=new Map,i=new Map;for(let s of e)if($m(s))if(\"attributes\"===s.type){let e=t.get(s.target);e||t.set(s.target,e=new Map),e.has(s.attributeName)||e.set(s.attributeName,s.oldValue)}else if(\"characterData\"===s.type)n.has(s.target)||n.set(s.target,s.oldValue);else{if(\"childList\"!==s.type)return!0;{let e=i.get(s.target);e||i.set(s.target,e=new Map);for(let t of s.addedNodes){if(3!==t.nodeType)return!0;e.set(t.data,(e.get(t.data)||0)+1)}for(let t of s.removedNodes){if(3!==t.nodeType)return!0;e.set(t.data,(e.get(t.data)||0)-1)}}}for(let[e,n]of t)for(let[t,i]of n)if(e.getAttribute(t)!==i)return!0;for(let[e,t]of n)if(e.data!==t)return!0;for(let e of i.values())for(let t of e.values())if(0!==t)return!0;return!1}var hx=/(?:^data:image\\/(?:gif|apng)|\\.(?:gif|apng)(?=[?#)'\"\\s;]|$))/i,gx=e=>!e||\"object\"!=typeof e&&\"function\"!=typeof e?\"-\":Tx(e);function mx(e){let t=(e.match(/^data:([^;,]+)/i)?.[1]||\"\").toLowerCase();if(\"image/gif\"===t||\"image/apng\"===t)return!0;if(!/image\\/(?:png|webp|avif|svg\\+xml)/.test(t))return!1;let n=function(e,t=131072){if(e=String(e||\"\").trim(),!/^data:/i.test(e))return\"\";let n=e.indexOf(\",\");if(n<0)return\"\";let i=e.slice(0,n),s=e.slice(n+1);try{if(/;base64/i.test(i)){let e=4*Math.ceil(t/3);return atob(s.slice(0,e-e%4))}return s.slice(0,3*t).replace(/%([0-9a-f]{2})/gi,(e,t)=>String.fromCharCode(parseInt(t,16))).slice(0,t)}catch{return\"\"}}(e);return\"image/png\"===t?n.includes(\"acTL\"):\"image/webp\"===t?n.includes(\"ANIM\")||n.includes(\"ANMF\")||n.includes(\"VP8X\")&&!!(2&n.charCodeAt(n.indexOf(\"VP8X\")+8)):\"image/avif\"===t?n.includes(\"avis\"):/<(?:animate|animateTransform|animateMotion|set)\\b|@keyframes\\b|animation(?:-name)?\\s*:/i.test(n)}function fx(e){let t=String(e||\"\").trim();return!!t&&(!!hx.test(t)||!!/^data:/i.test(t)&&mx(t))}function bx(e){let t=String(e||\"\");if(fx(t))return!0;for(let e of t.matchAll(/url\\(\\s*(?:\"((?:\\\\.|[^\"\\\\])*)\"|'((?:\\\\.|[^'\\\\])*)'|([^)]*))\\s*\\)/gi))if(fx(e[1]??e[2]??e[3]))return!0;return!1}function yx(e,t=null){let n=e&&e.clone;if(!n)return!1;let i=t?t.map(t=>e.srcToClone?.get(t)).filter(Boolean):[n];for(let t of i)for(let n of vx(t))if(bx(n.getAttribute?.(\"src\"))||bx(n.getAttribute?.(\"href\"))||bx(n.getAttribute?.(\"style\"))||bx(e.styleMap?.get(n)))return!0;return!1}function vx(e){let t=[];e&&1===e.nodeType&&t.push(e);try{t.push(...e.querySelectorAll(\"*\"))}catch{}return t}function wx(e,t){let n=[],i=new Set,s=e=>{e&&!i.has(e)&&(i.add(e),n.push(e))};e.matches?.(\"input,textarea,select,option\")&&s(e);for(let n of dx(e,t))try{for(let e of n.querySelectorAll(\"input,textarea,select,option\"))s(e)}catch{}t.controls=n}function xx(e,t){let n=[],i=new Set,s=(e,t=!1)=>{if(e&&!i.has(e)){i.add(e);try{(t||e.scrollLeft||e.scrollTop||e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight)&&n.push(e)}catch{}}};for(let t=e;t;t=t.parentElement)s(t,!0);for(let n of dx(e,t))for(let e of vx(n))s(e);t.scrollNodes=n}function kx(e,t){let n=e.ownerDocument||document,i=n.defaultView,s=[i?.location?.hash||\"\",sx(n),i?.innerWidth||0,i?.innerHeight||0,i?.devicePixelRatio||1,i?.screen?.orientation?.type||\"\"];try{s.push(...[...n.adoptedStyleSheets||[]].map(gx))}catch{}for(let e of t.trackedShadowRoots.keys())try{s.push(\"#shadow\",...[...e.adoptedStyleSheets||[]].map(gx))}catch{}let r=n.activeElement,o=n.fullscreenElement;(r?.contains(e)||e.contains(r))&&s.push(gx(r)),(o?.contains(e)||e.contains(o))&&s.push(gx(o));let a=[i?.scrollX||0,i?.scrollY||0];for(let e of t.scrollNodes)a.push(e.scrollLeft||0,e.scrollTop||0);let l=[];for(let e of t.controls){let t=String(e.localName||\"\").toLowerCase();\"input\"===t?l.push(e.type,uh(e)?e.value.length:e.value,e.checked?1:0,e.indeterminate?1:0):\"textarea\"===t?l.push(e.value):\"select\"===t?l.push(e.selectedIndex,e.value):l.push(e.selected?1:0)}let c=[];for(let e of t.images){let t=\"\";try{t=e.currentSrc||e.src||\"\"}catch{}c.push(t,e.complete?1:0,e.naturalWidth||0,e.naturalHeight||0)}return{style:s.join(\"|\"),scroll:a.join(\"|\"),controls:l,images:c,frameDriven:t.retainedFrameDriven}}function Sx(e,t,n){if(!e)return!1;let i=e[n],s=t[n];if(i===s)return!0;if(!Array.isArray(i)||i.length!==s.length)return!1;for(let e=0;e<i.length;e++)if(i[e]!==s[e])return!1;return!0}function Cx(e,t){let n=new Set;for(let i of dx(e,t))try{let e=i.getAnimations?.(1===i.nodeType?{subtree:!0}:void 0)||[];for(let t of e)n.add(t)}catch{}return[...n]}function Ex(e){return e.map(e=>[gx(e),e.playState,Math.round(10*(Number(e.currentTime)||0)),e.playbackRate].join(\":\")).join(\"|\")}function Mx(e,t,n){if(!n||1!==n.nodeType)return null;if(n===e||e.contains(n))return e;for(let e of t.trackedShadowRoots.keys())if(e.contains(n))return e;return null}var Ax=0,_x=new WeakMap;function Tx(e){let t=_x.get(e);return t||(t=\"@\"+ ++Ax,_x.set(e,t)),t}function Ix(e,t){let n=typeof e;if(\"undefined\"===n)return null;if(null===e||\"boolean\"===n||\"number\"===n||\"string\"===n)return JSON.stringify(e);if(\"function\"===n||\"symbol\"===n)return\"symbol\"===n?null:JSON.stringify(Tx(e));if(\"object\"!==n)return null;if(\"number\"==typeof e.nodeType)return JSON.stringify(Tx(e));if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let n=[];for(let i of e){let e=Ix(i,t);if(null===e)return null;n.push(e)}return\"[\"+n.join(\",\")+\"]\"}let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&null!==n)return JSON.stringify(Tx(e));let i=[];for(let n of Object.keys(e).sort()){let s=e[n];if(void 0===s)continue;let r=Ix(s,t);if(null===r)return null;i.push(JSON.stringify(n)+\":\"+r)}return\"{\"+i.join(\",\")+\"}\"}finally{t.delete(e)}}function Lx(e,t){let{burst:n,invalidate:i,...s}=e||{};try{let e=Ix(s,new Set);return null===e?null:`${(t||[]).map(gx).join(\",\")}:${e}`}catch{return null}}function Rx(e,t,n,i,s=null){let r=Jw.get(e);r||(r=function(e){let t={dirty:!0,pending:[],torn:!1,dirtyRoots:new Set,retained:null,retainedFrameDriven:!1,disposed:!1,capturing:!1,last:null,inflight:Promise.resolve(),observers:[],trackedShadowRoots:new Map,trackedImages:new Map,images:[],scannedImages:null,scrollNodes:[],controls:[],envEpoch:qm(),styleEpoch:Hm(),styleStamp:Bm(e),outsideMutations:Fm(e),geometry:null,renderState:null},n=()=>{t.dirty=!0,t.dirtyRoots=null},i=n=>{if(!t.dirtyRoots)return;let i=n&&(1===n.nodeType?n:n.parentElement);!i||i===e||!e.contains(i)||t.dirtyRoots.size>=12?t.dirtyRoots=null:t.dirtyRoots.add(i)},s=e=>{if(t.capturing)for(let n of e)t.pending.push(n);else for(let n of e)$m(n)&&(t.dirty=!0,i(n.target))},r=()=>{t.capturing?t.torn=!0:n()};t.dirtyAll=n;try{let n=new MutationObserver(s);n.observe(e,{subtree:!0,childList:!0,attributes:!0,characterData:!0,attributeOldValue:!0,characterDataOldValue:!0}),n.__flush=s,t.observers.push(n)}catch{}t.markDirty=s,t.onMediaDirty=r;try{for(let t of nx)e.addEventListener(t,r,{capture:!0,passive:!0})}catch{}return lx(e,t)||wx(e,t),xx(e,t),ux(e,t),t}(e),r.baselineSignature=Lx(t,n.plugins),Jw.set(e,r));let o=Lx(t,n.plugins),a=async()=>{if(r.disposed)return i();let t=null===o||o!==r.baselineSignature;t&&null!==o?r.pendingSig===o?(r.baselineSignature=o,r.last=null,r.dirty=!0,r.dirtyRoots=null,r.pendingSig=null,t=!1):r.pendingSig=o:r.pendingSig=null,lx(e,r),ux(e,r);for(let e of r.observers)e.__flush(e.takeRecords());uf();let a=Fm(e);r.dirty&&r.outsideMutations!==a&&r.dirtyAll(),r.outsideMutations=a;let l=e.getRootNode?.(),c=[...r.trackedShadowRoots.keys()];11===l?.nodeType&&!c.includes(l)&&c.push(l),df(e.ownerDocument||document,c);let d=Bm(e);r.styleStamp!==d&&(r.styleStamp=d,r.dirty||r.dirtyAll());let u=kx(e,r),p=Cx(e,r);u.animation=Ex(p),r.renderState&&(!Sx(r.renderState,u,\"style\")&&(Dm(),r.dirtyAll()),Sx(r.renderState,u,\"scroll\")||r.dirtyAll(),Sx(r.renderState,u,\"controls\")||(pf(e),r.dirtyAll()),!Sx(r.renderState,u,\"images\")&&!r.dirty&&r.dirtyAll());let h=qm();r.envEpoch!==h&&(r.dirtyAll(),r.envEpoch=h);let g=Hm();if(r.styleEpoch!==g&&(r.styleEpoch=g,!r.dirty)){let t=rx(e);null!==r.geometry&&t!==r.geometry&&(pf(e),r.dirtyAll()),r.geometry=t}n.invalidate&&r.dirtyAll();let m=!1,f=!!r.renderState&&!Sx(r.renderState,u,\"animation\");try{let t=new Set;f&&0===p.length&&(t=null);for(let n of p){let i=\"running\"===n.playState;if(!i&&!f)continue;i&&(m=!0),f=!0;let s=n.effect?.target;if(Mx(e,r,s)!==e){t=null;break}t.add(s)}if(f&&t&&t.size&&r.retained){r.dirty=!0;for(let e of t)r.dirtyRoots&&r.dirtyRoots.add(e),pf(e)}else f&&!t&&r.dirtyAll()}catch{}let b=u.frameDriven,y=m||b;if(y&&(r.last=null),b&&r.dirtyAll(),!t&&!y&&!r.dirty&&r.last)return ox(e,r),r.last;r.capturing=!0;let v=null;try{let o=null,l=!1,c=null;if(!t&&r.dirty&&r.retained&&r.dirtyRoots&&r.dirtyRoots.size&&s){c=[...r.dirtyRoots];let t=await Xw(e,r,n);t&&(o=await s(t),l=!0)}if(o||(t||(n.__retain=e=>{let t=new Map;for(let[n,i]of e.nodeMap.entries())t.set(i,n);v={...e,srcToClone:t}}),n.__tornSinceStart=()=>{for(let e of r.observers)for(let t of e.takeRecords())r.pending.push(t);return uf(),r.torn||px(r.pending)||Fm(e)!==a},o=await i()),!t&&!r.disposed){r.dirty=!1,r.dirtyRoots=new Set,v?(r.retained=v,r.retainedFrameDriven=yx(v),wx(e,r),xx(e,r)):l&&(r.retainedFrameDriven||=yx(r.retained,c),wx(e,r),xx(e,r));let t=kx(e,r);t.animation=Ex(Cx(e,r));let n=[\"style\",\"scroll\",\"controls\",\"images\"];m||n.push(\"animation\");let i=n.every(e=>Sx(u,t,e));r.renderState=t,r.styleEpoch=Hm(),r.styleStamp=Bm(e),r.geometry=rx(e),r.renderState.frameDriven?(Zw.add(e),ax(e,r)):i?!y&&!r.renderState.frameDriven&&(r.last=o,ox(e,r)):(r.dirtyAll(),r.last=null)}return o}finally{n.__retain=void 0,n.__tornSinceStart=void 0;for(let e of r.observers)for(let t of e.takeRecords())r.pending.push(t);uf();let t=Fm(e);(r.torn||px(r.pending)||t!==a)&&(r.dirtyAll(),r.last=null),r.outsideMutations=t,r.styleEpoch=Hm(),r.styleStamp=Bm(e),r.pending.length=0,r.torn=!1,r.capturing=!1,r.disposed||(lx(e,r),ux(e,r))}},l=r.inflight.then(a,a);return r.inflight=l.catch(()=>{}),l}var $x=null;var Nx=!1,Px=null,Fx=new WeakMap,Ox=!1;function qx(e){let t={control:e};Px=t,setTimeout(()=>{Px===t&&(Px=null)},0)}function Hx(e){let t=e.target,n=t&&(1===t.nodeType?t:t.parentElement);return n&&n.closest?n.closest('button, a[href], [role=\"button\"], input, select, summary, label, [tabindex]'):null}function Bx(e){if(\"keydown\"===e.type&&\"Enter\"!==e.key&&\" \"!==e.key)return;let t=Hx(e);t&&(qx(t),zx(e,!1))}function Dx(e){let t=Hx(e);t&&qx(t)}function zx(e,t=!0){if(!$x||\"hidden\"===document.visibilityState)return;let n=Hx(e);if(!n||\"pointerenter\"===e.type&&e.target!==n)return;let i=Fx.get(n);if(i)return i.element.isConnected?void $x(i.element,i.options).catch(()=>{}):void Fx.delete(n);t&&!Ox&&(Ox=!0,$x(document.body,{clip:\"viewport\",burst:!1}).catch(()=>{}))}ng();var Ux=Object.assign(Gx,{plugins:function(...e){return function(...e){let t=e.flat();for(let e of t){let t=nw(e);if(t){if(void 0!==t.needs&&t.needs!==Zv)throw new Error(`[snapdom] global plugin '${t.name||\"(unnamed)\"}' declares needs: ${JSON.stringify(t.needs)}. A global plugin must run to '${Zv}': lowering it here would stop EVERY capture in the app short of pixels. Pass it per capture instead: snapdom(el, { plugins: [<plugin>] }).`);tw.some(e=>e&&e.name&&t.name&&e.name===t.name)||tw.push(t)}}}(...e),Ux},fromString:async function(e,t){if(\"string\"!=typeof e||!e.trim())throw new Error(\"[snapdom.fromString] html string required\");let n=document.createElement(\"div\");Zh(n),n.style.cssText=\"position:fixed;left:-99999px;top:0;pointer-events:none;\",n.innerHTML=e,document.body.appendChild(n);try{await _g();let e=Array.from(n.childNodes).some(e=>3===e.nodeType&&e.textContent.trim()),i=1!==n.children.length||e?n:n.firstElementChild;return await Gx(i,{...t||{},burst:!1})}finally{n.remove()}},version:\"3.1.1\",preCapture:function(){if(Nx||typeof document>\"u\"||\"function\"!=typeof document.addEventListener)return;Nx=!0;let e={capture:!0,passive:!0};document.addEventListener(\"pointerdown\",Bx,e),document.addEventListener(\"keydown\",Bx,e),document.addEventListener(\"click\",Dx,e),document.addEventListener(\"pointerenter\",zx,e),document.addEventListener(\"focusin\",zx,e)}});$x=Gx;var jx=Symbol(\"snapdom.internal\"),Wx=Symbol(\"snapdom.internal.silent\"),Vx=new Set([\"png\",\"jpeg\",\"jpg\",\"webp\",\"svg\"]);async function Gx(e,t){if(!e)throw new Error(\"Element cannot be null or undefined\");let n=function(e={}){let t=\"string\"==typeof e.type&&qw.has(e.type.toLowerCase())?e.type.toLowerCase():null,n=e.format??t??\"png\";\"jpg\"===n&&(n=\"jpeg\");let i=null!=e.format?n:\"jpg\"===t?\"jpeg\":t,s=function(e){return!1===e||\"string\"==typeof e&&\"disabled\"===e.toLowerCase().trim()?\"disabled\":\"soft\"}(e.cache),r=null==e.exclude?[]:Array.isArray(e.exclude)?e.exclude:[e.exclude],o=[],a=[];for(let e of r)\"string\"==typeof e?o.push(e):\"function\"==typeof e?a.push(e):null!=e&&console.warn(\"[snapdom] Ignored invalid exclude entry (expected selector string or predicate):\",e);let l=e.excludeMode??\"hide\",c={debug:e.debug??!1,scale:e.scale??1,exclude:o,excludePredicates:a.length?a:null,excludeMode:l,filter:e.filter??null,filterMode:e.filterMode??\"hide\",shouldExclude:e=>{if(!e||1!==e.nodeType)return!1;if(\"exclude\"===e.getAttribute(\"data-capture\"))return!0;for(let t of Array.isArray(c.exclude)?c.exclude:[])try{if(e.matches(t))return!0}catch{}for(let t of Array.isArray(c.excludePredicates)?c.excludePredicates:[])try{if(t(e))return!0}catch{}if(\"function\"==typeof c.filter)try{if(!c.filter(e))return!0}catch{}return!1},placeholders:!1!==e.placeholders,captureSelection:e.captureSelection??!1,canvas:ph(e.canvas,\"canvas\")?e.canvas:null,embedFonts:e.embedFonts??\"auto\",iconFonts:Array.isArray(e.iconFonts)?e.iconFonts:e.iconFonts?[e.iconFonts]:[],__iconMatchers:Ib(e.iconFonts),localFonts:Array.isArray(e.localFonts)?e.localFonts:[],excludeFonts:e.excludeFonts??void 0,fontStylesheetDomains:Array.isArray(e.fontStylesheetDomains)?e.fontStylesheetDomains:[],fallbackURL:e.fallbackURL??void 0,cache:s,__styleShare:e.__styleShare,useProxy:\"string\"==typeof e.useProxy?e.useProxy:\"\",width:e.width??null,height:e.height??null,format:n,__explicitFormat:i,type:n,quality:e.quality??.92,dpr:e.dpr??(window.devicePixelRatio||1),backgroundColor:e.backgroundColor??([\"jpeg\",\"webp\"].includes(n)?\"#ffffff\":null),filename:e.filename??\"snapDOM\",outerTransforms:e.outerTransforms??!0,outerShadows:e.outerShadows??!1,reconcile:e.reconcile??!1,burst:e.burst,fast:!1!==e.fast&&\"auto\"!==e.fast||e.fast,engine:e.engine,invalidate:e.invalidate??!1,__pinned:!0===e.__pinned,clip:e.clip??null,compress:!1!==e.compress,excludeStyleProps:e.excludeStyleProps??null,resolvePicturePlaceholders:!1!==e.resolvePicturePlaceholders};return c}(t);n.element=e,n.invalidate&&Dm(),aw(n,t&&t.plugins);let{stage:i,loweredBy:s}=function(e){let t=Array.isArray(e&&e.plugins)?e.plugins:[];if(!t.length)return{stage:Zv,loweredBy:[]};let n=-1,i=[];for(let e of t){if(!e||\"object\"!=typeof e)continue;let t=void 0===e.needs?Zv:e.needs;if(!Object.prototype.hasOwnProperty.call(Qv,t))throw new Error(`[snapdom] plugin '${e.name||\"(unnamed)\"}' declares needs: ${JSON.stringify(t)}, expected one of ${Jv.join(\", \")}`);i.push({name:e.name||\"(unnamed)\",needs:t}),n=Math.max(n,Qv[t])}if(n<0)return{stage:Zv,loweredBy:[]};let s=Jv[n];return{loweredBy:s===Zv?[]:i.filter(e=>e.needs===s).map(e=>e.name),stage:s}}(n);n.needs=i,n.__needsLoweredBy=s;let r=ew(i,\"render\"),o=!0===n.burst||!cw(n),a=\"function\"==typeof n.filter||!!n.excludePredicates||\"function\"==typeof n.excludeStyleProps||\"function\"==typeof n.fallbackURL,l=r&&!n.captureSelection&&!1!==n.burst&&o&&!a&&function(e){if(Zw.has(e))return!1;Qw.delete(e);let t=[e],n=[],i=[];for(let e=0;e<t.length;e++){let s=t[e],r=[];1===s?.nodeType&&r.push(s);try{r.push(...s.querySelectorAll(\"*\"))}catch{return!1}for(let e of r){e.shadowRoot&&t.push(e.shadowRoot);let s=String(e.localName||e.tagName||\"\").toLowerCase();if(/^(?:iframe|canvas|video|audio|object|embed|marquee|blink)$/.test(s)||\"progress\"===s&&!e.hasAttribute(\"value\")||/^(?:animate|animatetransform|animatemotion|set)$/.test(s))return!1;let r=\"\";if(\"img\"===s){i.push(e);try{r=e.currentSrc||e.src||\"\"}catch{}}/^(?:input|textarea|select|option)$/.test(s)&&n.push(e);let o=e.getAttribute?.(\"style\")||\"\",a=ex.get(e);if(r||o){if((!a||a.src!==r||a.style!==o)&&(a={src:r,style:o,animated:bx(r)||bx(o)},ex.set(e,a)),a.animated)return!1}else a&&ex.delete(e)}}return Qw.set(e,{roots:t.slice(1),controls:n,images:i}),!0}(e);return l&&function(e,t){!Nx||!Px||t&&!1===t.burst||Fx.set(Px.control,{element:e,options:t&&\"object\"==typeof t?{...t}:t})}(e,t),n.snap||(n.snap={toPng:(e,t)=>Ux.toPng(e,t),toSvg:(e,t)=>Ux.toSvg(e,t)}),l?Rx(e,t,n,()=>Ux.capture(e,n,jx),e=>Kx(e,n)):Ux.capture(e,n,jx)}async function Kx(e,t){let n=t.needs||Zv,i=ew(n,\"render\"),s=e=>function(e,t,n){let i=t.length?t.map(e=>`'${e}'`).join(\", \"):\"the attached plugins\";return new Error(`[snapdom] no ${n}: this capture stopped at '${e}' because ${i} declared needs: '${e}' (result.needs says so too). It is not re-captured on demand — that would be a different instant. Ask the plugin for needs: 'render', or capture without it.`)}(n,t.__needsLoweredBy||[],e),r=typeof HTMLCanvasElement<\"u\"&&e instanceof HTMLCanvasElement?e:null,o=r?null:e,a=()=>o??=r.toDataURL(),l=r||e;r&&(e=\"\");let c=t.__compressedSnapshot,d=t.__compressionDensity;delete t.__compressedSnapshot,delete t.__compressedAssets;let u,p=t.meta||{},h=(Number.isFinite(t.width)||Number.isFinite(t.height))&&!Ig(),g=h?Number.isFinite(t.width)?p.targetW/p.vbW:p.targetH/p.vbH:1,m=h?Number.isFinite(t.height)?p.targetH/p.vbH:p.targetW/p.vbW:1,f=e=>{if(r||!c?.size)return l;let t=p.vbW,n=p.vbH,i=e.crop;i&&(t=Math.max(1,Math.min(t,i.x+i.width)-Math.max(0,i.x)),n=Math.max(1,Math.min(n,i.y+i.height)-Math.max(0,i.y)));let s=Number.isFinite(e.width),o=Number.isFinite(e.height);return(s&&o?Math.max(e.width/t,e.height/n):s?e.width/t*(i?Math.max(1,m/g):1):o?e.height/n*(i?Math.max(1,g/m):1):(e.scale||1)*Math.max(g,m))*(e.dpr||1)<=d?l:u??=function(e,t){if(!t?.size||\"string\"!=typeof e||!e.startsWith(\"data:image/svg+xml\"))return e;let n=e.indexOf(\",\"),i=(new DOMParser).parseFromString(decodeURIComponent(e.slice(n+1)),\"image/svg+xml\");if(i.querySelector(\"parsererror\"))return e;let s=!1;for(let e of i.querySelectorAll(`[${dw}]`))for(let n of t.get(e.getAttribute(dw))||[])gw(e,n)===n.compressed&&(\"style\"===n.kind?e.style.setProperty(n.name,n.original,e.style.getPropertyPriority(n.name)):\"xlink:href\"===n.name?e.setAttributeNS(uw,n.name,n.original):e.setAttribute(n.name,n.original),s=!0);return s?`data:image/svg+xml;charset=utf-8,${encodeURIComponent((new XMLSerializer).serializeToString(i))}`:e}(a(),c)},b=async(e,t)=>{let{rasterize:n}=await Promise.resolve().then(()=>(mm(),hm));return n(l,{...e,...t||{},format:\"png\"})},y=()=>{if(!i)throw s(\"svgString\");if(r)throw new Error(\"[snapdom] svgString: engine:'html-in-canvas' produces a raster capture; there is no serialized SVG\");let t=e.indexOf(\",\");return t>=0?decodeURIComponent(e.slice(t+1)):\"\"},v=e=>Object.defineProperty({...e||{},svgString:y},\"url\",i?{get:a,enumerable:!0}:{get(){throw s(\"export.url\")},enumerable:!1,configurable:!0}),w={img:async(e,t)=>{if(r)return b(e,t);let{toImg:n}=await Promise.resolve().then(()=>(ym(),fm)),i={...e,...t||{}};return n(f(i),i)},svg:async(e,t)=>{if(r)return b(e,t);let{toSvg:n}=await Promise.resolve().then(()=>(ym(),fm)),i={...e,...t||{}};return n(f(i),i)},canvas:async(e,t)=>{let{toCanvas:n}=await Promise.resolve().then(()=>(pm(),Bg)),i={...e,...t||{}};return n(f(i),i)},blob:async(e,t)=>{let{toBlob:n}=await Promise.resolve().then(()=>(xm(),vm)),i={...e,...t||{}};return n(f(i),i)},png:async(e,t)=>{let{rasterize:n}=await Promise.resolve().then(()=>(mm(),hm)),i={...e,...t||{},format:\"png\"};return n(f(i),i)},jpeg:async(e,t)=>{let{rasterize:n}=await Promise.resolve().then(()=>(mm(),hm)),i={...e,...t||{},format:\"jpeg\"};return n(f(i),i)},webp:async(e,t)=>{let{rasterize:n}=await Promise.resolve().then(()=>(mm(),hm)),i={...e,...t||{},format:\"webp\"};return n(f(i),i)},download:async(e,t)=>{let{download:n}=await Promise.resolve().then(()=>(Em(),km)),i={...e,...t||{}};return n(f(i),i)}};if(!i)for(let e of Object.keys(w)){let t=\"download\"===e?\"download()\":`to${e.charAt(0).toUpperCase()}${e.slice(1)}()`;w[e]=async()=>{throw s(t)}}let x={};for(let e of[\"img\",\"svg\",\"canvas\",\"blob\",\"png\",\"jpeg\",\"webp\"])x[e]=async n=>w[e](t,{...A(e,n||{}),[Wx]:!0});x.jpg=x.jpeg;let k=e=>Object.defineProperty({...t,...e},\"options\",{value:t,configurable:!0}),S=k({artifacts:t.__artifacts||null,export:v(),exports:x}),C=await rw(\"defineExports\",S),E=Object.assign({},...C.filter(e=>e&&\"object\"==typeof e).reverse()),M={...w,...E};function A(e,n){let i=n||{},s={...t,...i},o=\"string\"==typeof i.type?i.type.toLowerCase():\"\",a=\"string\"==typeof i.format?i.format.toLowerCase():Vx.has(o)?o:\"\";a&&(s.format=\"jpg\"===a?\"jpeg\":a),s.__explicitFormat=a?s.format:t.__explicitFormat??null,\"blob\"===e&&!s.__explicitFormat&&(s.format=r?\"png\":\"svg\"),s.type=s.format;return[e,s.format,o].map(e=>\"string\"==typeof e?e.toLowerCase():\"\").find(e=>\"jpeg\"===e||\"jpg\"===e||\"webp\"===e)&&(null==s.backgroundColor||\"transparent\"===s.backgroundColor)&&(s.backgroundColor=\"#ffffff\"),1!==s.scale&&(Number.isFinite(s.width)||Number.isFinite(s.height))&&Pg(s,\"width/height define the output size — scale is ignored when either is set\"),s}M.jpeg&&!M.jpg&&(M.jpg=(e,t)=>M.jpeg(e,t));let _=!1,T=Promise.resolve();async function I(e,n){let i=Object.freeze(n&&\"object\"==typeof n?{...n}:{}),s=T.then(async()=>{let n=M[e];if(!n)throw new Error(`[snapdom] Unknown export type: ${e}`);let s=A(e,i),r=k({artifacts:t.__artifacts||null,export:v({type:e,options:s,requestedOptions:i})}),o=s.format,a=s.type;await rw(\"beforeExport\",r,{format:e,options:s});let l=s.format!==o?s.format:s.type!==a?s.type:\"\",c=\"string\"==typeof l?l.toLowerCase():\"\";Vx.has(c)&&(s.format=\"jpg\"===c?\"jpeg\":c,s.type=s.format,s.__explicitFormat=s.format,/^(?:jpeg|webp)$/.test(s.format)&&(null==s.backgroundColor||\"transparent\"===s.backgroundColor)&&(s.backgroundColor=\"#ffffff\"));let d=await n(r,s);return await rw(\"afterExport\",r,{format:e,options:s,result:d}),_||(_=!0,await sw(\"afterSnap\",t)),d});return T=s.catch(()=>{}),s}let L={url:e,needs:n,warnings:t.__session&&t.__session.warnings||[],toRaw:()=>{if(!i)throw s(\"toRaw()\");return a()},to:(e,t)=>I(e,t),toImg:e=>I(\"img\",e),toSvg:e=>I(\"svg\",e),toCanvas:e=>I(\"canvas\",e),toBlob:e=>I(\"blob\",e),toPng:e=>I(\"png\",e),toJpg:e=>I(\"jpg\",e),toWebp:e=>I(\"webp\",e),download:e=>I(\"download\",e)};i?r&&Object.defineProperty(L,\"url\",{get:a,enumerable:!0,configurable:!0}):Object.defineProperty(L,\"url\",{get(){throw s(\"url\")},enumerable:!1,configurable:!0}),Object.defineProperty(L,\"meta\",i?{value:t.meta,enumerable:!0}:{get(){throw s(\"meta\")},enumerable:!1,configurable:!0});for(let e of Object.keys(M)){let t=\"to\"+e.charAt(0).toUpperCase()+e.slice(1);L[t]||(L[t]=t=>I(e,t))}return L}Ux.capture=async(e,t,n)=>{if(n!==jx)throw new Error(\"[snapdom.capture] is internal. Use snapdom(...) instead.\");if(ew(t.needs||Zv,\"render\")&&Ig()){if(t.embedFonts)try{let n=e.ownerDocument||document,i=new Set;if(\"auto\"===t.embedFonts){try{for(let e of n.fonts)i.add(String(e.family).replace(/[\"']/g,\"\").toLowerCase())}catch{}if(0===i.size)throw null}let s=cy(e);t.clip||(t.__fontUsage=s);let r=s.required,o=new Set([...r].map(e=>String(e).split(\"__\")[0]).filter(Boolean));if(\"auto\"===t.embedFonts&&(o=new Set([...o].filter(e=>i.has(e.toLowerCase()))),0===o.size))throw null;await dy(o,1,n)}catch{}let n=Array.from(e.querySelectorAll(\"canvas\"));\"CANVAS\"===e.tagName&&n.unshift(e);for(let e of n)try{if(Eb(e))continue;let t=e.getContext(\"2d\",{willReadFrequently:!0});t&&t.getImageData(0,0,1,1)}catch(e){Pg(t,\"safari canvas poke failed\",e)}}return Kx(await Ow(e,t),t)},Ux.toRaw=(e,t)=>Ux(e,t).then(e=>e.toRaw()),Ux.toImg=(e,t)=>Ux(e,t).then(e=>e.toImg()),Ux.toSvg=(e,t)=>Ux(e,t).then(e=>e.toSvg()),Ux.toCanvas=(e,t)=>Ux(e,t).then(e=>e.toCanvas()),Ux.toBlob=(e,t)=>Ux(e,t).then(e=>e.toBlob()),Ux.toPng=(e,t)=>Ux(e,{...t,format:\"png\"}).then(e=>e.toPng()),Ux.toJpg=(e,t)=>Ux(e,{...t,format:\"jpeg\"}).then(e=>e.toJpg()),Ux.toWebp=(e,t)=>Ux(e,{...t,format:\"webp\"}).then(e=>e.toWebp()),Ux.download=(e,t)=>Ux(e,t).then(e=>e.download());let Yx=0;const Xx=new Set;function Jx(){0===Yx&&(Qx=function(){const e=console.warn,t=console.error,n=e=>\"string\"==typeof e[0]&&/^\\[snapdom/i.test(e[0]);return console.warn=(...t)=>{n(t)||e.apply(console,t)},console.error=(...e)=>{n(e)||t.apply(console,e)},()=>{console.warn=e,console.error=t}}(),ek=Zx()),Yx++;let e=!1;return()=>{e||(e=!0,Yx=Math.max(0,Yx-1),0===Yx&&(Qx?.(),Qx=null))}}let Qx=null;const Zx=()=>({count:0,totalMs:0,slowestMs:0,failed:0,skipped:0});let ek=Zx();function tk(e){0!==Yx&&(Xx.size>=100||Xx.add(e))}const nk=/\\.(png|jpe?g|gif|webp|avif|svg|bmp|ico|woff2?|ttf|otf|eot)(\\?|#|$)/i;const ik=/^(?:(?:xml|xlink):)?[A-Za-z_][A-Za-z0-9._-]*$/;function sk(e){return ik.test(e)}function rk(e){if(!(e instanceof DOMException)||\"EncodingError\"!==e.name)return\"\";try{const{tags:e,attributes:t}=function(e){const t=new Set,n=new Set,i=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(let s=e;s;s=i.nextNode()){sk(s.nodeName)||t.add(s.nodeName);for(const e of s.attributes)sk(e.name)||n.add(e.name)}return{tags:[...t].sort(),attributes:[...n].sort()}}(document.body),n=[...e.map(e=>`<${e}>`),...t].slice(0,5).join(\", \");return n?` (unserializable: ${n})`:\" (names ok)\"}catch{return\"\"}}const ok={name:\"blar-xml-name-sanitizer\",afterClone(e){const t=e.clone;t&&rs(()=>function(e){const t=new Set,n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(let i=e;i;i=n.nextNode()){const e=Array.from(i.attributes,e=>e.name);for(const n of e)sk(n)||(i.removeAttribute(n),t.add(n))}return[...t]}(t),\"screenshot: xml-name sanitize\")}};function ak(){try{return!0===window.__blarCaptureDebug||\"1\"===localStorage.getItem(\"blar_capture_debug\")}catch{return!1}}const lk=new Set([\"VIDEO\",\"AUDIO\"]),ck=Ho.join(\",\");function dk(e){const t=parseInt(window.getComputedStyle(e).zIndex,10);return Number.isNaN(t)?0:t}function uk(e){const t=e.id?`#${e.id}`:\"\",n=e.classList.length?`.${Array.from(e.classList).slice(0,2).join(\".\")}`:\"\",i=e.getAttribute(\"role\");return`${e.tagName.toLowerCase()}${t}${n}${i?`[role=${i}]`:\"\"}`}function pk(e){if(\"true\"===e.getAttribute(\"aria-hidden\"))return!1;const t=window.getComputedStyle(e);if(\"none\"===t.display||\"hidden\"===t.visibility||\"0\"===t.opacity)return!1;const n=e.getBoundingClientRect();return n.width>0&&n.height>0}function hk(){const e=[],t=document.createTreeWalker(document.body,NodeFilter.SHOW_ELEMENT,{acceptNode(t){const n=t;if(e.some(e=>e.contains(n)))return NodeFilter.FILTER_REJECT;if(\"SELECT\"===n.tagName)return NodeFilter.FILTER_REJECT;const i=window.getComputedStyle(n),s=\"fixed\"===i.position||\"absolute\"===i.position&&(function(e){return\"none\"!==e.perspective||/preserve-3d/.test(e.transformStyle)||e.transform.startsWith(\"matrix3d\")||/transform|perspective/.test(e.willChange)}(i)||n.classList.contains(\"pac-container\"));return s?pk(n)?\"IFRAME\"===n.tagName||n.querySelector(\"iframe\")||n.closest(ck)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT:NodeFilter.FILTER_SKIP}});for(;t.nextNode();)e.push(t.currentNode);return e.sort((e,t)=>dk(e)-dk(t)),e}async function gk(e,t){const n={...t,outerTransforms:!1,filter:n=>n===e||(t.filter?.(n)??!0),filterMode:\"hide\",excludeMode:\"hide\",plugins:[ok]};return i(()=>Ux(e,n),3e3,\"snapdom overlay capture timed out\")}let mk=0,fk=0,bk=0;function yk(e){if(mk++,lk.has(e.tagName))return!1;if(\"OPTION\"===e.tagName){const t=e.selected;return t&&fk++,t}if(\"OPTGROUP\"===e.tagName){const t=null!==e.querySelector(\"option:checked\");return t&&fk++,t}bk++;const t=window.getComputedStyle(e);if(\"none\"===t.display||\"hidden\"===t.visibility)return!1;if(0===e.childElementCount){const t=e.getBoundingClientRect();if(0===t.width&&0===t.height)return!1}return fk++,!0}function vk(){let e=performance.now(),t=0,n=!0;const i=()=>{if(!n)return;const s=performance.now();t=Math.max(t,s-e),e=s,requestAnimationFrame(i)};return requestAnimationFrame(i),{stop:()=>(n=!1,t)}}const wk={embedFonts:!0,dpr:1,fast:!0,cache:\"soft\",exclude:[...Ho],excludeMode:\"remove\",filter:yk,filterMode:\"remove\"};class xk{async captureScreenshot(){const e=wk,t=e.dpr??1,n=ak();n&&function(){if(kk||\"undefined\"==typeof window)return;kk=!0,window.__blarCapture={snapdom:Ux,findOverlays:hk,performanceFilter:yk,describeOverlay:uk,blarUiSelectors:[...Ho],baseCaptureOptions:()=>({embedFonts:!0,dpr:window.devicePixelRatio||1,fast:!0,cache:\"soft\",exclude:[...Ho],excludeMode:\"remove\",filter:yk,filterMode:\"remove\",clip:\"viewport\",plugins:[ok]}),async probe(e,t={}){const n=e.getBoundingClientRect(),i=await(await Ux(e,t)).toCanvas(),s=t.dpr??window.devicePixelRatio??1;return{live:`${Math.round(n.width)}x${Math.round(n.height)}`,captured:`${i.width}x${i.height}`,capturedCss:`${Math.round(i.width/s)}x${Math.round(i.height/s)}`,ok:i.height/s>n.height-4}},describeGeometry(e){const t=getComputedStyle(e),n=e.getBoundingClientRect();return{rect:`${Math.round(n.width)}x${Math.round(n.height)} @${Math.round(n.left)},${Math.round(n.top)}`,offset:`${e.offsetWidth}x${e.offsetHeight}`,scroll:`${e.scrollWidth}x${e.scrollHeight}`,client:`${e.clientWidth}x${e.clientHeight}`,childElementCount:e.childElementCount,inlineStyle:e.getAttribute(\"style\")||\"(none)\",...Object.fromEntries([\"position\",\"display\",\"height\",\"maxHeight\",\"minHeight\",\"top\",\"bottom\",\"overflow\",\"overflowY\",\"transform\",\"contain\",\"aspectRatio\",\"zoom\"].map(e=>[e,t[e]]))}}}}();const s=n?vk():null;n&&(mk=0,fk=0,bk=0);const r=performance.now(),{scrollX:o,scrollY:a}=window,l=performance.now(),c=hk(),d=n?performance.now()-l:0,u=c.map(e=>e.getBoundingClientRect()),p=new Set(c),h={...e,clip:\"viewport\",filter:e=>!p.has(e)&&yk(e),plugins:[ok]},g=Jx();let m,f=null,b=0;const y=[];let v=0;const w=[];try{f=function(){const e=document.documentElement,t=e.clientWidth||window.innerWidth,n=e.clientHeight||window.innerHeight,i=[];document.querySelectorAll(\"select\").forEach(e=>{if(e.options.length<=1)return;if(e.multiple||e.size>1)return;const s=e.getBoundingClientRect();if(s.bottom<0||s.top>n||s.right<0||s.left>t)return;const r=window.getComputedStyle(e);i.push({select:e,usedWidth:\"border-box\"===r.boxSizing?`${e.offsetWidth}px`:r.width})});const s=[];for(const{select:e,usedWidth:t}of i){const n=Array.from(e.childNodes),i=e.selectedIndex,r=e.style.width;e.style.width=t,e.replaceChildren(e.selectedOptions[0]||e.options[0]),s.push(()=>{e.replaceChildren(...n),e.selectedIndex=i,e.style.width=r})}const r=()=>s.forEach(e=>rs(e,\"screenshot: restore select options\"));return r.count=s.length,r}(),b=f.count;const o=performance.now();m=await i(()=>Ux(document.body,h),8e3,\"snapdom base capture timed out\"),v=n?performance.now()-o:0;const a=performance.now()+4e3;for(let i=0;i<c.length;i++){const s=c[i];if(s.isConnected&&pk(s)){if(performance.now()>a){n&&console.warn(`[snapdom-capture] overlay budget exhausted — compositing ${y.length}/${c.length} overlays`);break}try{const r=performance.now();y.push({shot:await gk(s,e),dx:u[i].left*t,dy:u[i].top*t,rect:u[i],label:uk(s)}),n&&w.push(Math.round(performance.now()-r))}catch(e){n&&console.warn(\"[snapdom-capture] overlay capture failed — not compositing it\",e)}}}if(n){const e={...ek};console.warn(\"[snapdom-capture] clone+style pass\",{assets:`${e.count} fetched (${e.failed} failed, ${e.skipped} skipped by negative cache), ${Math.round(e.totalMs)}ms summed, slowest ${Math.round(e.slowestMs)}ms`,compositedOverlays:y.length,overlays:y.map(e=>`${e.label} @${Math.round(e.rect.left)},${Math.round(e.rect.top)} ${Math.round(e.rect.width)}x${Math.round(e.rect.height)}`),skippedOverlays:c.length-y.length,snapdomMs:Math.round(performance.now()-r),findOverlaysMs:Math.round(d),baseMs:Math.round(v),overlayMs:w,longestStallMs:Math.round(s?.stop()??0),prunedSelects:b,filterCalls:mk,filterKept:fk,filterDropped:mk-fk,filterStyleReads:bk})}}finally{rs(g,\"screenshot: close capture-resource window\"),rs(f,\"screenshot: restore pruned selects\"),window.scrollX===o&&window.scrollY===a||window.scrollTo({left:o,top:a,behavior:\"instant\"})}return{async toCanvas(){const e=await m.toCanvas();if(y.length){const i=e.getContext(\"2d\");if(i)for(const e of y){const s=await e.shot.toCanvas();if(n){const n=Math.round(e.rect.width*t),i=Math.round(e.rect.height*t);(s.width<n-4||s.height<i-4)&&console.warn(\"[snapdom-capture] overlay size mismatch — composite will be clipped\",{overlay:e.label,expected:`${n}x${i}`,captured:`${s.width}x${s.height}`,drawnAt:`${Math.round(e.dx)},${Math.round(e.dy)}`})}i.drawImage(s,e.dx,e.dy)}}return e}}}async snapshotToDataUrl(e,t=\"jpeg\",n=.8){if(!ak()){const i=await this.snapshotToCanvas(e,t,n);return this.canvasToDataUrl(i,t,n)}const i=vk(),s=performance.now(),r=await this.snapshotToCanvas(e,t,n),o=performance.now()-s,a=performance.now(),l=this.canvasToDataUrl(r,t,n),c=performance.now()-a,d=i.stop();return console.warn(\"[snapdom-capture] rasterize pass\",{toCanvasMs:Math.round(o),encodeMs:Math.round(c),longestStallMs:Math.round(d),canvas:`${r.width}x${r.height}`}),l}async snapshotToCanvas(e,t=\"jpeg\",n=.8){return e.toCanvas()}resizeIfNeeded(e,t){const{maxWidth:n,maxHeight:i}=t;if(!n&&!i)return e;let s=e.width,r=e.height;if(n&&e.width>n){const t=n/e.width;s=n,r=Math.round(e.height*t)}if(i&&r>i){const e=i/r;r=i,s=Math.round(s*e)}if(s===e.width&&r===e.height)return e;const o=document.createElement(\"canvas\");o.width=s,o.height=r;const a=o.getContext(\"2d\",{willReadFrequently:!0});return a&&a.drawImage(e,0,0,s,r),o}canvasToDataUrl(e,t,n){const i=\"png\"===t?\"image/png\":\"image/jpeg\";return e.toDataURL(i,n)}}let kk=!1;const Sk={idle:[\"pending\",\"active\"],pending:[\"active\",\"idle\"],active:[\"exiting\"],exiting:[\"idle\"]};class Ck{constructor(){this.phase=\"idle\"}getPhase(){return this.phase}isActive(){return\"active\"===this.phase}isIdle(){return\"idle\"===this.phase}isEngaged(){return\"active\"===this.phase||\"exiting\"===this.phase}transition(e){return this.phase!==e&&(!!Sk[this.phase].includes(e)&&(this.phase=e,!0))}forceIdle(){this.phase=\"idle\"}}var Ek,Mk=Object.defineProperty,Ak=(e,t,n)=>((e,t,n)=>t in e?Mk(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,\"symbol\"!=typeof t?t+\"\":t,n),_k=(e=>(e[e.DomContentLoaded=0]=\"DomContentLoaded\",e[e.Load=1]=\"Load\",e[e.FullSnapshot=2]=\"FullSnapshot\",e[e.IncrementalSnapshot=3]=\"IncrementalSnapshot\",e[e.Meta=4]=\"Meta\",e[e.Custom=5]=\"Custom\",e[e.Plugin=6]=\"Plugin\",e[e.Asset=7]=\"Asset\",e))(_k||{}),Tk=(e=>(e[e.Mutation=0]=\"Mutation\",e[e.MouseMove=1]=\"MouseMove\",e[e.MouseInteraction=2]=\"MouseInteraction\",e[e.Scroll=3]=\"Scroll\",e[e.ViewportResize=4]=\"ViewportResize\",e[e.Input=5]=\"Input\",e[e.TouchMove=6]=\"TouchMove\",e[e.MediaInteraction=7]=\"MediaInteraction\",e[e.StyleSheetRule=8]=\"StyleSheetRule\",e[e.CanvasMutation=9]=\"CanvasMutation\",e[e.Font=10]=\"Font\",e[e.Log=11]=\"Log\",e[e.Drag=12]=\"Drag\",e[e.StyleDeclaration=13]=\"StyleDeclaration\",e[e.Selection=14]=\"Selection\",e[e.AdoptedStyleSheet=15]=\"AdoptedStyleSheet\",e[e.CustomElement=16]=\"CustomElement\",e))(Tk||{}),Ik=(e=>(e[e.MouseUp=0]=\"MouseUp\",e[e.MouseDown=1]=\"MouseDown\",e[e.Click=2]=\"Click\",e[e.ContextMenu=3]=\"ContextMenu\",e[e.DblClick=4]=\"DblClick\",e[e.Focus=5]=\"Focus\",e[e.Blur=6]=\"Blur\",e[e.TouchStart=7]=\"TouchStart\",e[e.TouchMove_Departed=8]=\"TouchMove_Departed\",e[e.TouchEnd=9]=\"TouchEnd\",e[e.TouchCancel=10]=\"TouchCancel\",e))(Ik||{}),Lk=(e=>(e[e.Mouse=0]=\"Mouse\",e[e.Pen=1]=\"Pen\",e[e.Touch=2]=\"Touch\",e))(Lk||{}),Rk=(e=>(e[e[\"2D\"]=0]=\"2D\",e[e.WebGL=1]=\"WebGL\",e[e.WebGL2=2]=\"WebGL2\",e))(Rk||{}),$k=(e=>(e[e.Play=0]=\"Play\",e[e.Pause=1]=\"Pause\",e[e.Seeked=2]=\"Seeked\",e[e.VolumeChange=3]=\"VolumeChange\",e[e.RateChange=4]=\"RateChange\",e))($k||{}),Nk=(e=>(e[e.Document=0]=\"Document\",e[e.DocumentType=1]=\"DocumentType\",e[e.Element=2]=\"Element\",e[e.Text=3]=\"Text\",e[e.CDATA=4]=\"CDATA\",e[e.Comment=5]=\"Comment\",e))(Nk||{});const Pk={Node:[\"childNodes\",\"parentNode\",\"parentElement\",\"textContent\",\"ownerDocument\"],ShadowRoot:[\"host\",\"styleSheets\"],Element:[\"shadowRoot\",\"querySelector\",\"querySelectorAll\"],MutationObserver:[]},Fk={Node:[\"contains\",\"getRootNode\"],ShadowRoot:[\"getSelection\"],Element:[],MutationObserver:[\"constructor\"]},Ok={},qk={};function Hk(e){if(Ok[e])return Ok[e];const t=globalThis[e],n=t.prototype,i=e in Pk?Pk[e]:void 0,s=Boolean(i&&i.every(e=>{var t,i;return Boolean(null==(i=null==(t=Object.getOwnPropertyDescriptor(n,e))?void 0:t.get)?void 0:i.toString().includes(\"[native code]\"))})),r=e in Fk?Fk[e]:void 0,o=Boolean(r&&r.every(e=>{var t;return\"function\"==typeof n[e]&&(null==(t=n[e])?void 0:t.toString().includes(\"[native code]\"))}));if(s&&o&&!globalThis.Zone)return Ok[e]=t.prototype,t.prototype;try{const i=document.createElement(\"iframe\");i.style.display=\"none\",document.body.appendChild(i);const s=i.contentWindow;if(!s)return t.prototype;const r=s[e].prototype;if(!r)return i.remove(),n;const o=navigator.userAgent;return o.includes(\"Safari\")&&!o.includes(\"Chrome\")?(i.classList.add(\"rr-block\"),i.setAttribute(\"__rrwebUntaintedMutationObserver\",\"\"),qk[e]=()=>i.remove()):i.remove(),Ok[e]=r}catch{return n}}const Bk={};function Dk(e,t,n){var i;const s=`${e}.${String(n)}`;if(Bk[s])return Bk[s].call(t);const r=Hk(e),o=null==(i=Object.getOwnPropertyDescriptor(r,n))?void 0:i.get;return o?(Bk[s]=o,o.call(t)):t[n]}const zk={};function Uk(e,t,n){const i=`${e}.${String(n)}`;if(zk[i])return zk[i].bind(t);const s=Hk(e)[n];return\"function\"!=typeof s?t[n]:(zk[i]=s,s.bind(t))}function jk(){return[Hk(\"MutationObserver\").constructor,qk.MutationObserver??(()=>{})]}let Wk=Date.now;function Vk(e,t,n){try{if(!(t in e))return()=>{};const i=e[t],s=n(i);return\"function\"==typeof s&&(s.prototype=s.prototype||{},Object.defineProperties(s,{__rrweb_original__:{enumerable:!1,value:i}})),e[t]=s,()=>{e[t]=i}}catch{return()=>{}}}/[1-9][0-9]{12}/.test(Date.now().toString())||(Wk=()=>(new Date).getTime());const Gk={ownerDocument:function(e){return Dk(\"Node\",e,\"ownerDocument\")},childNodes:function(e){return Dk(\"Node\",e,\"childNodes\")},parentNode:function(e){return Dk(\"Node\",e,\"parentNode\")},parentElement:function(e){return Dk(\"Node\",e,\"parentElement\")},textContent:function(e){return Dk(\"Node\",e,\"textContent\")},contains:function(e,t){return Uk(\"Node\",e,\"contains\")(t)},getRootNode:function(e){return Uk(\"Node\",e,\"getRootNode\")()},host:function(e){return e&&\"host\"in e?Dk(\"ShadowRoot\",e,\"host\"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&\"shadowRoot\"in e?Dk(\"Element\",e,\"shadowRoot\"):null},querySelector:function(e,t){return Dk(\"Element\",e,\"querySelector\")(t)},querySelectorAll:function(e,t){return Dk(\"Element\",e,\"querySelectorAll\")(t)},nowTimestamp:Wk,mutationObserverCtor:jk,patch:Vk};function Kk(e){return e.nodeType===e.ELEMENT_NODE}function Yk(e){const t=e&&\"host\"in e&&\"mode\"in e&&Gk.host(e)||null;return Boolean(t&&\"shadowRoot\"in t&&Gk.shadowRoot(t)===e)}function Xk(e){return\"[object ShadowRoot]\"===Object.prototype.toString.call(e)}function Jk(e){try{const n=e.rules||e.cssRules;if(!n)return null;let i=e.href;!i&&e.ownerNode&&(i=e.ownerNode.baseURI);const s=Array.from(n,e=>Qk(e,i)).join(\"\");return(t=s).includes(\" background-clip: text;\")&&!t.includes(\" -webkit-background-clip: text;\")&&(t=t.replace(/\\sbackground-clip:\\s*text;/g,\" -webkit-background-clip: text; background-clip: text;\")),t}catch(e){return null}var t}function Qk(e,t){if(function(e){return\"styleSheet\"in e}(e)){let t;try{t=Jk(e.styleSheet)||function(e){const{cssText:t}=e;if(t.split('\"').length<3)return t;const n=[\"@import\",`url(${JSON.stringify(e.href)})`];return\"\"===e.layerName?n.push(\"layer\"):e.layerName&&n.push(`layer(${e.layerName})`),e.supportsText&&n.push(`supports(${e.supportsText})`),e.media.length&&n.push(e.media.mediaText),n.join(\" \")+\";\"}(e)}catch(n){t=e.cssText}return e.styleSheet.href?cS(t,e.styleSheet.href):t}{let n=e.cssText;return function(e){return\"selectorText\"in e}(e)&&e.selectorText.includes(\":\")&&(n=function(e){const t=/(\\[(?:[\\w-]+)[^\\\\])(:(?:[\\w-]+)\\])/gm;return e.replace(t,\"$1\\\\$2\")}(n)),t?cS(n,t):n}}class Zk{constructor(){Ak(this,\"idNodeMap\",new Map),Ak(this,\"nodeMetaMap\",new WeakMap)}getId(e){var t;if(!e)return-1;return(null==(t=this.getMeta(e))?void 0:t.id)??-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){const t=this.getId(e);this.idNodeMap.delete(t),e.childNodes&&e.childNodes.forEach(e=>this.removeNodeFromMap(e))}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,t){const n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)}replace(e,t){const n=this.getNode(e);if(n){const e=this.nodeMetaMap.get(n);e&&this.nodeMetaMap.set(t,e)}this.idNodeMap.set(e,t)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}}function eS({element:e,maskInputOptions:t,tagName:n,type:i,value:s,maskInputFn:r}){let o=s||\"\";const a=i&&tS(i);return(t[n.toLowerCase()]||a&&t[a])&&(o=r?r(o,e):\"*\".repeat(o.length)),o}function tS(e){return e.toLowerCase()}const nS=\"__rrweb_original__\";function iS(e){const t=e.type;return e.hasAttribute(\"data-rr-is-password\")?\"password\":t?tS(t):null}function sS(e,t){let n;try{n=new URL(e,t??window.location.href)}catch(e){return null}const i=n.pathname.match(/\\.([0-9a-z]+)(?:$)/i);return(null==i?void 0:i[1])??null}const rS=/url\\((?:(')([^']*)'|(\")(.*?)\"|([^)]*))\\)/gm,oS=/^(?:[a-z+]+:)?\\/\\//i,aS=/^www\\..*/i,lS=/^(data:)([^,]*),(.*)/i;function cS(e,t){return(e||\"\").replace(rS,(e,n,i,s,r,o)=>{const a=i||r||o,l=n||s||\"\";if(!a)return e;if(oS.test(a)||aS.test(a))return`url(${l}${a}${l})`;if(lS.test(a))return`url(${l}${a}${l})`;if(\"/\"===a[0])return`url(${l}${function(e){let t=\"\";return t=e.indexOf(\"//\")>-1?e.split(\"/\").slice(0,3).join(\"/\"):e.split(\"/\")[0],t=t.split(\"?\")[0],t}(t)+a}${l})`;const c=a.split(\"#\")[0],d=a.substring(c.length),u=t.split(\"#\")[0].split(\"/\"),p=c.split(\"/\");u.pop();for(const e of p)\".\"!==e&&(\"..\"===e?u.pop():u.push(e));return`url(${l}${u.join(\"/\")}${d}${l})`})}function dS(e,t=!1){return t?e.replace(/(\\/\\*[^*]*\\*\\/)|[\\s;]/g,\"\"):e.replace(/(\\/\\*[^*]*\\*\\/)|[\\s;]/g,\"\").replace(/0px/g,\"0\")}function uS(e,t){return function(e,t,n=!1){const i=Array.from(t.childNodes),s=[];let r=0;if(i.length>1&&e&&\"string\"==typeof e){let t=dS(e,n);const o=t.length/e.length;for(let a=1;a<i.length;a++)if(i[a].textContent&&\"string\"==typeof i[a].textContent){const l=dS(i[a].textContent,n),c=100;let d=3;for(;d<l.length&&(l[d].match(/[a-zA-Z0-9]/)||-1!==l.indexOf(l.substring(0,d),1));d++);for(;d<l.length;d++){let u=l.substring(0,d),p=t.split(u),h=-1;if(2===p.length)h=p[0].length;else if(p.length>2&&\"\"===p[0]&&\"\"!==i[a-1].textContent)h=t.indexOf(u,1);else if(1===p.length){if(u=u.substring(0,u.length-1),p=t.split(u),p.length<=1)return s.push(e),s;d=c+1}else d===l.length-1&&(h=t.indexOf(u));if(p.length>=2&&d>c){const e=i[a-1].textContent;if(e&&\"string\"==typeof e){const n=dS(e).length;h=t.indexOf(u,n)}-1===h&&(h=p[0].length)}if(-1!==h){let a=Math.floor(h/o);for(;a>0&&a<e.length;){if(r+=1,r>50*i.length)return s.push(e),s;const l=dS(e.substring(0,a),n);if(l.length===h){s.push(e.substring(0,a)),e=e.substring(a),t=t.substring(h);break}l.length<h?a+=Math.max(1,Math.floor((h-l.length)/o)):a-=Math.max(1,Math.floor((l.length-h)*o))}break}}}}return s.push(e),s}(e,t).join(\"/* rr_split */\")}let pS=1;const hS=new RegExp(\"[^a-z0-9-_:]\");function gS(){return pS++}let mS,fS;const bS=/^[^ \\t\\n\\r\\u000c]+/,yS=/^[, \\t\\n\\r\\u000c]+/;const vS=new WeakMap;function wS(e,t){return t&&\"\"!==t.trim()?kS(e,t):t}function xS(e){return Boolean(\"svg\"===e.tagName||e.ownerSVGElement)}function kS(e,t){let n=vS.get(e);if(n||(n=e.createElement(\"a\"),vS.set(e,n)),t){if(t.startsWith(\"blob:\")||t.startsWith(\"data:\"))return t}else t=\"\";return n.setAttribute(\"href\",t),n.href}function SS(e,t,n,i){return i?\"src\"===n||\"href\"===n&&(\"use\"!==t||\"#\"!==i[0])||\"xlink:href\"===n&&\"#\"!==i[0]||\"background\"===n&&[\"table\",\"td\",\"th\"].includes(t)?wS(e,i):\"srcset\"===n?function(e,t){if(\"\"===t.trim())return t;let n=0;function i(e){let i;const s=e.exec(t.substring(n));return s?(i=s[0],n+=i.length,i):\"\"}const s=[];for(;i(yS),!(n>=t.length);){let r=i(bS);if(\",\"===r.slice(-1))r=wS(e,r.substring(0,r.length-1)),s.push(r);else{let i=\"\";r=wS(e,r);let o=!1;for(;;){const e=t.charAt(n);if(\"\"===e){s.push((r+i).trim());break}if(o)\")\"===e&&(o=!1);else{if(\",\"===e){n+=1,s.push((r+i).trim());break}\"(\"===e&&(o=!0)}i+=e,n+=1}}}return s.join(\", \")}(e,i):\"style\"===n?cS(i,kS(e)):\"object\"===t&&\"data\"===n?wS(e,i):i:i}function CS(e,t,n){return[\"video\",\"audio\"].includes(e)&&\"autoplay\"===t}function ES(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&ES(Gk.parentNode(e),t,n);for(let n=e.classList.length;n--;){const i=e.classList[n];if(t.test(i))return!0}return!!n&&ES(Gk.parentNode(e),t,n)}function MS(e,t,n,i){let s;if(Kk(e)){if(s=e,!Gk.childNodes(s).length)return!1}else{if(null===Gk.parentElement(e))return!1;s=Gk.parentElement(e)}try{if(\"string\"==typeof t){if(i){if(s.closest(`.${t}`))return!0}else if(s.classList.contains(t))return!0}else if(ES(s,t,i))return!0;if(n)if(i){if(s.closest(n))return!0}else if(s.matches(n))return!0}catch(e){}return!1}function AS(e,t){const{doc:n,mirror:i,blockClass:s,blockSelector:r,needsMask:o,inlineStylesheet:a,maskInputOptions:l={},maskTextFn:c,maskInputFn:d,dataURLOptions:u={},inlineImages:p,recordCanvas:h,keepIframeSrcFn:g,newlyAddedElement:m=!1,cssCaptured:f=!1}=t,b=function(e,t){if(!t.hasNode(e))return;const n=t.getId(e);return 1===n?void 0:n}(n,i);switch(e.nodeType){case e.DOCUMENT_NODE:return\"CSS1Compat\"!==e.compatMode?{type:Nk.Document,childNodes:[],compatMode:e.compatMode}:{type:Nk.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:Nk.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:b};case e.ELEMENT_NODE:return function(e,t){const{doc:n,blockClass:i,blockSelector:s,inlineStylesheet:r,maskInputOptions:o={},maskInputFn:a,dataURLOptions:l={},inlineImages:c,recordCanvas:d,keepIframeSrcFn:u,newlyAddedElement:p=!1,rootId:h}=t,g=function(e,t,n){try{if(\"string\"==typeof t){if(e.classList.contains(t))return!0}else for(let n=e.classList.length;n--;){const i=e.classList[n];if(t.test(i))return!0}if(n)return e.matches(n)}catch(e){}return!1}(e,i,s),m=function(e){if(e instanceof HTMLFormElement)return\"form\";const t=tS(e.tagName);return hS.test(t)?\"div\":t}(e);let f={};const b=e.attributes.length;for(let t=0;t<b;t++){const i=e.attributes[t];CS(m,i.name,i.value)||(f[i.name]=SS(n,m,tS(i.name),i.value))}if(\"link\"===m&&r){const t=Array.from(n.styleSheets).find(t=>t.href===e.href);let i=null;t&&(i=Jk(t)),i&&(delete f.rel,delete f.href,f._cssText=i)}if(\"style\"===m&&e.sheet){let t=Jk(e.sheet);t&&(e.childNodes.length>1&&(t=uS(t,e)),f._cssText=t)}if([\"input\",\"textarea\",\"select\"].includes(m)){const t=e.value,n=e.checked;\"radio\"!==f.type&&\"checkbox\"!==f.type&&\"submit\"!==f.type&&\"button\"!==f.type&&t?f.value=eS({element:e,type:iS(e),tagName:m,value:t,maskInputOptions:o,maskInputFn:a}):n&&(f.checked=n)}\"option\"===m&&(e.selected&&!o.select?f.selected=!0:delete f.selected);\"dialog\"===m&&e.open&&(f.rr_open_mode=e.matches(\"dialog:modal\")?\"modal\":\"non-modal\");if(\"canvas\"===m&&d)if(\"2d\"===e.__context)(function(e){const t=e.getContext(\"2d\");if(!t)return!0;for(let n=0;n<e.width;n+=50)for(let i=0;i<e.height;i+=50){const s=t.getImageData,r=nS in s?s[nS]:s;if(new Uint32Array(r.call(t,n,i,Math.min(50,e.width-n),Math.min(50,e.height-i)).data.buffer).some(e=>0!==e))return!1}return!0})(e)||(f.rr_dataURL=e.toDataURL(l.type,l.quality));else if(!(\"__context\"in e)){const t=e.toDataURL(l.type,l.quality),i=n.createElement(\"canvas\");i.width=e.width,i.height=e.height;t!==i.toDataURL(l.type,l.quality)&&(f.rr_dataURL=t)}if(\"img\"===m&&c){mS||(mS=n.createElement(\"canvas\"),fS=mS.getContext(\"2d\"));const t=e,i=t.currentSrc||t.getAttribute(\"src\")||\"<unknown-src>\",s=t.crossOrigin,r=()=>{t.removeEventListener(\"load\",r);try{mS.width=t.naturalWidth,mS.height=t.naturalHeight,fS.drawImage(t,0,0),f.rr_dataURL=mS.toDataURL(l.type,l.quality)}catch(e){if(\"anonymous\"!==t.crossOrigin)return t.crossOrigin=\"anonymous\",void(t.complete&&0!==t.naturalWidth?r():t.addEventListener(\"load\",r));console.warn(`Cannot inline img src=${i}! Error: ${e}`)}\"anonymous\"===t.crossOrigin&&(s?f.crossOrigin=s:t.removeAttribute(\"crossorigin\"))};t.complete&&0!==t.naturalWidth?r():t.addEventListener(\"load\",r)}if([\"audio\",\"video\"].includes(m)){const t=f;t.rr_mediaState=e.paused?\"paused\":\"played\",t.rr_mediaCurrentTime=e.currentTime,t.rr_mediaPlaybackRate=e.playbackRate,t.rr_mediaMuted=e.muted,t.rr_mediaLoop=e.loop,t.rr_mediaVolume=e.volume}p||(e.scrollLeft&&(f.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(f.rr_scrollTop=e.scrollTop));if(g){const{width:t,height:n}=e.getBoundingClientRect();f={class:f.class,rr_width:`${t}px`,rr_height:`${n}px`}}\"iframe\"!==m||u(f.src)||(e.contentDocument||(f.rr_src=f.src),delete f.src);let y;try{customElements.get(m)&&(y=!0)}catch(e){}return{type:Nk.Element,tagName:m,attributes:f,childNodes:[],isSVG:xS(e)||void 0,needBlock:g,rootId:h,isCustom:y}}(e,{doc:n,blockClass:s,blockSelector:r,inlineStylesheet:a,maskInputOptions:l,maskInputFn:d,dataURLOptions:u,inlineImages:p,recordCanvas:h,keepIframeSrcFn:g,newlyAddedElement:m,rootId:b});case e.TEXT_NODE:return function(e,t){const{needsMask:n,maskTextFn:i,rootId:s,cssCaptured:r}=t,o=Gk.parentNode(e),a=o&&o.tagName;let l=\"\";const c=\"STYLE\"===a||void 0,d=\"SCRIPT\"===a||void 0;d?l=\"SCRIPT_PLACEHOLDER\":r||(l=Gk.textContent(e),c&&l&&(l=cS(l,kS(t.doc))));!c&&!d&&l&&n&&(l=i?i(l,Gk.parentElement(e)):l.replace(/[\\S]/g,\"*\"));return{type:Nk.Text,textContent:l||\"\",rootId:s}}(e,{doc:n,needsMask:o,maskTextFn:c,rootId:b,cssCaptured:f});case e.CDATA_SECTION_NODE:return{type:Nk.CDATA,textContent:\"\",rootId:b};case e.COMMENT_NODE:return{type:Nk.Comment,textContent:Gk.textContent(e)||\"\",rootId:b};default:return!1}}function _S(e){return null==e?\"\":e.toLowerCase()}function TS(e){return!0===e||\"all\"===e?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:\"all\"===e,headMetaDescKeywords:\"all\"===e,headTitleMutations:\"all\"===e}:e||{}}function IS(e,t){const{doc:n,mirror:i,blockClass:s,blockSelector:r,maskTextClass:o,maskTextSelector:a,skipChild:l=!1,inlineStylesheet:c=!0,maskInputOptions:d={},maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:g={},inlineImages:m=!1,recordCanvas:f=!1,onSerialize:b,onIframeLoad:y,iframeLoadTimeout:v=5e3,onStylesheetLoad:w,stylesheetLoadTimeout:x=5e3,keepIframeSrcFn:k=()=>!1,newlyAddedElement:S=!1,cssCaptured:C=!1}=t;let{needsMask:E}=t,{preserveWhiteSpace:M=!0}=t;if(!E){E=MS(e,o,a,void 0===E)}const A=AS(e,{doc:n,mirror:i,blockClass:s,blockSelector:r,needsMask:E,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:p,dataURLOptions:g,inlineImages:m,recordCanvas:f,keepIframeSrcFn:k,newlyAddedElement:S,cssCaptured:C});if(!A)return console.warn(e,\"not serialized\"),null;let _;_=i.hasNode(e)?i.getId(e):function(e,t){if(t.comment&&e.type===Nk.Comment)return!0;if(e.type===Nk.Element){if(t.script&&(\"script\"===e.tagName||\"link\"===e.tagName&&(\"preload\"===e.attributes.rel&&\"script\"===e.attributes.as||\"modulepreload\"===e.attributes.rel)||\"link\"===e.tagName&&\"prefetch\"===e.attributes.rel&&\"string\"==typeof e.attributes.href&&\"js\"===sS(e.attributes.href)))return!0;if(t.headFavicon&&(\"link\"===e.tagName&&\"shortcut icon\"===e.attributes.rel||\"meta\"===e.tagName&&(_S(e.attributes.name).match(/^msapplication-tile(image|color)$/)||\"application-name\"===_S(e.attributes.name)||\"icon\"===_S(e.attributes.rel)||\"apple-touch-icon\"===_S(e.attributes.rel)||\"shortcut icon\"===_S(e.attributes.rel))))return!0;if(\"meta\"===e.tagName){if(t.headMetaDescKeywords&&_S(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(_S(e.attributes.property).match(/^(og|twitter|fb):/)||_S(e.attributes.name).match(/^(og|twitter):/)||\"pinterest\"===_S(e.attributes.name)))return!0;if(t.headMetaRobots&&(\"robots\"===_S(e.attributes.name)||\"googlebot\"===_S(e.attributes.name)||\"bingbot\"===_S(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes[\"http-equiv\"])return!0;if(t.headMetaAuthorship&&(\"author\"===_S(e.attributes.name)||\"generator\"===_S(e.attributes.name)||\"framework\"===_S(e.attributes.name)||\"publisher\"===_S(e.attributes.name)||\"progid\"===_S(e.attributes.name)||_S(e.attributes.property).match(/^article:/)||_S(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&(\"google-site-verification\"===_S(e.attributes.name)||\"yandex-verification\"===_S(e.attributes.name)||\"csrf-token\"===_S(e.attributes.name)||\"p:domain_verify\"===_S(e.attributes.name)||\"verify-v1\"===_S(e.attributes.name)||\"verification\"===_S(e.attributes.name)||\"shopify-checkout-api-token\"===_S(e.attributes.name)))return!0}}return!1}(A,h)||!M&&A.type===Nk.Text&&!A.textContent.replace(/^\\s+|\\s+$/gm,\"\").length?-2:gS();const T=Object.assign(A,{id:_});if(i.add(e,T),-2===_)return null;b&&b(e);let I=!l;if(T.type===Nk.Element){I=I&&!T.needBlock,delete T.needBlock;const t=Gk.shadowRoot(e);t&&Xk(t)&&(T.isShadowHost=!0)}if((T.type===Nk.Document||T.type===Nk.Element)&&I){h.headWhitespace&&T.type===Nk.Element&&\"head\"===T.tagName&&(M=!1);const t={doc:n,mirror:i,blockClass:s,blockSelector:r,needsMask:E,maskTextClass:o,maskTextSelector:a,skipChild:l,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:g,inlineImages:m,recordCanvas:f,preserveWhiteSpace:M,onSerialize:b,onIframeLoad:y,iframeLoadTimeout:v,onStylesheetLoad:w,stylesheetLoadTimeout:x,keepIframeSrcFn:k,cssCaptured:!1};if(T.type===Nk.Element&&\"textarea\"===T.tagName&&void 0!==T.attributes.value);else{T.type===Nk.Element&&void 0!==T.attributes._cssText&&\"string\"==typeof T.attributes._cssText&&(t.cssCaptured=!0);for(const n of Array.from(Gk.childNodes(e))){const e=IS(n,t);e&&T.childNodes.push(e)}}let S=null;if(Kk(e)&&(S=Gk.shadowRoot(e)))for(const e of Array.from(Gk.childNodes(S))){const n=IS(e,t);n&&(Xk(S)&&(n.isShadow=!0),T.childNodes.push(n))}}const L=Gk.parentNode(e);return L&&Yk(L)&&Xk(L)&&(T.isShadow=!0),T.type===Nk.Element&&\"iframe\"===T.tagName&&function(e,t,n){const i=e.contentWindow;if(!i)return;let s,r=!1;try{s=i.document.readyState}catch(e){return}if(\"complete\"!==s){const i=setTimeout(()=>{r||(t(),r=!0)},n);return void e.addEventListener(\"load\",()=>{clearTimeout(i),r=!0,t()})}const o=\"about:blank\";if(i.location.href!==o||e.src===o||\"\"===e.src)return setTimeout(t,0),e.addEventListener(\"load\",t);e.addEventListener(\"load\",t)}(e,()=>{const t=e.contentDocument;if(t&&y){const n=IS(t,{doc:t,mirror:i,blockClass:s,blockSelector:r,needsMask:E,maskTextClass:o,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:g,inlineImages:m,recordCanvas:f,preserveWhiteSpace:M,onSerialize:b,onIframeLoad:y,iframeLoadTimeout:v,onStylesheetLoad:w,stylesheetLoadTimeout:x,keepIframeSrcFn:k});n&&y(e,n)}},v),T.type===Nk.Element&&\"link\"===T.tagName&&\"string\"==typeof T.attributes.rel&&(\"stylesheet\"===T.attributes.rel||\"preload\"===T.attributes.rel&&\"string\"==typeof T.attributes.href&&\"css\"===sS(T.attributes.href))&&function(e,t,n){let i,s=!1;try{i=e.sheet}catch(e){return}if(i)return;const r=setTimeout(()=>{s||(t(),s=!0)},n);e.addEventListener(\"load\",()=>{clearTimeout(r),s=!0,t()})}(e,()=>{if(w){const t=IS(e,{doc:n,mirror:i,blockClass:s,blockSelector:r,needsMask:E,maskTextClass:o,maskTextSelector:a,skipChild:!1,inlineStylesheet:c,maskInputOptions:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:h,dataURLOptions:g,inlineImages:m,recordCanvas:f,preserveWhiteSpace:M,onSerialize:b,onIframeLoad:y,iframeLoadTimeout:v,onStylesheetLoad:w,stylesheetLoadTimeout:x,keepIframeSrcFn:k});t&&w(e,t)}},x),T}class LS{constructor(...e){Ak(this,\"parentElement\",null),Ak(this,\"parentNode\",null),Ak(this,\"ownerDocument\"),Ak(this,\"firstChild\",null),Ak(this,\"lastChild\",null),Ak(this,\"previousSibling\",null),Ak(this,\"nextSibling\",null),Ak(this,\"ELEMENT_NODE\",1),Ak(this,\"TEXT_NODE\",3),Ak(this,\"nodeType\"),Ak(this,\"nodeName\"),Ak(this,\"RRNodeType\")}get childNodes(){const e=[];let t=this.firstChild;for(;t;)e.push(t),t=t.nextSibling;return e}contains(e){if(!(e instanceof LS))return!1;if(e.ownerDocument!==this.ownerDocument)return!1;if(e===this)return!0;for(;e.parentNode;){if(e.parentNode===this)return!0;e=e.parentNode}return!1}appendChild(e){throw new Error(\"RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.\")}insertBefore(e,t){throw new Error(\"RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.\")}removeChild(e){throw new Error(\"RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.\")}toString(){return\"RRNode\"}}function RS(e,t,n=document){const i={capture:!0,passive:!0};return n.addEventListener(e,t,i),()=>n.removeEventListener(e,t,i)}const $S=\"Please stop import mirror directly. Instead of that,\\r\\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\\r\\nor you can use record.mirror to access the mirror instance during recording.\";let NS={map:{},getId:()=>(console.error($S),-1),getNode:()=>(console.error($S),null),removeNodeFromMap(){console.error($S)},has:()=>(console.error($S),!1),reset(){console.error($S)}};function PS(e,t,n={}){let i=null,s=0;return function(...r){const o=Date.now();s||!1!==n.leading||(s=o);const a=t-(o-s),l=this;a<=0||a>t?(i&&(clearTimeout(i),i=null),s=o,e.apply(l,r)):i||!1===n.trailing||(i=setTimeout(()=>{s=!1===n.leading?0:Date.now(),i=null,e.apply(l,r)},a))}}function FS(e,t,n,i,s=window){const r=s.Object.getOwnPropertyDescriptor(e,t);return s.Object.defineProperty(e,t,i?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),r&&r.set&&r.set.call(this,e)}}),()=>FS(e,t,r||{},!0)}function OS(e){var t,n,i,s;const r=e.document;return{left:r.scrollingElement?r.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:r.documentElement.scrollLeft||(null==r?void 0:r.body)&&(null==(t=Gk.parentElement(r.body))?void 0:t.scrollLeft)||(null==(n=null==r?void 0:r.body)?void 0:n.scrollLeft)||0,top:r.scrollingElement?r.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==r?void 0:r.documentElement.scrollTop)||(null==r?void 0:r.body)&&(null==(i=Gk.parentElement(r.body))?void 0:i.scrollTop)||(null==(s=null==r?void 0:r.body)?void 0:s.scrollTop)||0}}function qS(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function HS(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function BS(e){if(!e)return null;return e.nodeType===e.ELEMENT_NODE?e:Gk.parentElement(e)}function DS(e,t,n,i){if(!e)return!1;const s=BS(e);if(!s)return!1;try{if(\"string\"==typeof t){if(s.classList.contains(t))return!0;if(i&&null!==s.closest(\".\"+t))return!0}else if(ES(s,t,i))return!0}catch(e){}if(n){if(s.matches(n))return!0;if(i&&null!==s.closest(n))return!0}return!1}function zS(e,t,n){return!(\"TITLE\"!==e.tagName||!n.headTitleMutations)||-2===t.getId(e)}function US(e,t){if(Yk(e))return!1;const n=t.getId(e);if(!t.has(n))return!0;const i=Gk.parentNode(e);return(!i||i.nodeType!==e.DOCUMENT_NODE)&&(!i||US(i,t))}function jS(e){return Boolean(e.changedTouches)}function WS(e,t){return Boolean(\"IFRAME\"===e.nodeName&&t.getMeta(e))}function VS(e,t){return Boolean(\"LINK\"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&\"stylesheet\"===e.getAttribute(\"rel\")&&t.getMeta(e))}function GS(e){return!!e&&(e instanceof LS&&\"shadowRoot\"in e?Boolean(e.shadowRoot):Boolean(Gk.shadowRoot(e)))}\"undefined\"!=typeof window&&window.Proxy&&window.Reflect&&(NS=new Proxy(NS,{get:(e,t,n)=>(\"map\"===t&&console.error($S),Reflect.get(e,t,n))}));class KS{constructor(){Ak(this,\"id\",1),Ak(this,\"styleIDMap\",new WeakMap),Ak(this,\"idStyleMap\",new Map)}getId(e){return this.styleIDMap.get(e)??-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function YS(e){var t;let n=null;return\"getRootNode\"in e&&(null==(t=Gk.getRootNode(e))?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&Gk.host(Gk.getRootNode(e))&&(n=Gk.host(Gk.getRootNode(e))),n}function XS(e){const t=Gk.ownerDocument(e);if(!t)return!1;const n=function(e){let t,n=e;for(;t=YS(n);)n=t;return n}(e);return Gk.contains(t,n)}function JS(e){const t=Gk.ownerDocument(e);return!!t&&(Gk.contains(t,e)||XS(e))}function QS(e){return\"__ln\"in e}class ZS{constructor(){Ak(this,\"length\",0),Ak(this,\"head\",null),Ak(this,\"tail\",null)}get(e){if(e>=this.length)throw new Error(\"Position outside of list range\");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&QS(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&QS(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;null===t.next&&(this.tail=t),this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next?t.next.previous=t.previous:this.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}}const eC=(e,t)=>`${e}@${t}`;class tC{constructor(){Ak(this,\"frozen\",!1),Ak(this,\"locked\",!1),Ak(this,\"texts\",[]),Ak(this,\"attributes\",[]),Ak(this,\"attributeMap\",new WeakMap),Ak(this,\"removes\",[]),Ak(this,\"mapRemoves\",[]),Ak(this,\"movedMap\",{}),Ak(this,\"addedSet\",new Set),Ak(this,\"movedSet\",new Set),Ak(this,\"droppedSet\",new Set),Ak(this,\"removesSubTreeCache\",new Set),Ak(this,\"mutationCb\"),Ak(this,\"blockClass\"),Ak(this,\"blockSelector\"),Ak(this,\"maskTextClass\"),Ak(this,\"maskTextSelector\"),Ak(this,\"inlineStylesheet\"),Ak(this,\"maskInputOptions\"),Ak(this,\"maskTextFn\"),Ak(this,\"maskInputFn\"),Ak(this,\"keepIframeSrcFn\"),Ak(this,\"recordCanvas\"),Ak(this,\"inlineImages\"),Ak(this,\"slimDOMOptions\"),Ak(this,\"dataURLOptions\"),Ak(this,\"doc\"),Ak(this,\"mirror\"),Ak(this,\"iframeManager\"),Ak(this,\"stylesheetManager\"),Ak(this,\"shadowDomManager\"),Ak(this,\"canvasManager\"),Ak(this,\"processedNodeManager\"),Ak(this,\"unattachedDoc\"),Ak(this,\"processMutations\",e=>{e.forEach(this.processMutation),this.emit()}),Ak(this,\"emit\",()=>{if(this.frozen||this.locked)return;const e=[],t=new Set,n=new ZS,i=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},s=s=>{const r=Gk.parentNode(s);if(!r||!JS(s))return;let o=!1;if(s.nodeType===Node.TEXT_NODE){const e=r.tagName;if(\"TEXTAREA\"===e)return;\"STYLE\"===e&&this.addedSet.has(r)&&(o=!0)}const a=Yk(r)?this.mirror.getId(YS(s)):this.mirror.getId(r),l=i(s);if(-1===a||-1===l)return n.addNode(s);const c=IS(s,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{WS(e,this.mirror)&&this.iframeManager.addIframe(e),VS(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),GS(s)&&this.shadowDomManager.addShadowRoot(Gk.shadowRoot(s),this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)},cssCaptured:o});c&&(e.push({parentId:a,nextId:l,node:c}),t.add(c.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of this.movedSet)iC(this.removesSubTreeCache,e,this.mirror)&&!this.movedSet.has(Gk.parentNode(e))||s(e);for(const e of this.addedSet)sC(this.droppedSet,e)||iC(this.removesSubTreeCache,e,this.mirror)?sC(this.movedSet,e)?s(e):this.droppedSet.add(e):s(e);let r=null;for(;n.length;){let e=null;if(r){const t=this.mirror.getId(Gk.parentNode(r.value)),n=i(r.value);-1!==t&&-1!==n&&(e=r)}if(!e){let t=n.tail;for(;t;){const n=t;if(t=t.previous,n){const t=this.mirror.getId(Gk.parentNode(n.value));if(-1===i(n.value))continue;if(-1!==t){e=n;break}{const t=n.value,i=Gk.parentNode(t);if(i&&i.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const t=Gk.host(i);if(-1!==this.mirror.getId(t)){e=n;break}}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}r=e.previous,n.removeNode(e.value),s(e.value)}const o={texts:this.texts.map(e=>{const t=e.node,n=Gk.parentNode(t);return n&&\"TEXTAREA\"===n.tagName&&this.genTextAreaValueMutation(n),{id:this.mirror.getId(t),value:e.value}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>{const{attributes:t}=e;if(\"string\"==typeof t.style){const n=JSON.stringify(e.styleDiff),i=JSON.stringify(e._unchangedStyles);n.length<t.style.length&&(n+i).split(\"var(\").length===t.style.split(\"var(\").length&&(t.style=e.styleDiff)}return{id:this.mirror.getId(e.node),attributes:t}}).filter(e=>!t.has(e.id)).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e};(o.texts.length||o.attributes.length||o.removes.length||o.adds.length)&&(this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.removesSubTreeCache=new Set,this.movedMap={},this.mutationCb(o))}),Ak(this,\"genTextAreaValueMutation\",e=>{let t=this.attributeMap.get(e);t||(t={node:e,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(t),this.attributeMap.set(e,t));const n=Array.from(Gk.childNodes(e),e=>Gk.textContent(e)||\"\").join(\"\");t.attributes.value=eS({element:e,maskInputOptions:this.maskInputOptions,tagName:e.tagName,type:iS(e),value:n,maskInputFn:this.maskInputFn})}),Ak(this,\"processMutation\",e=>{if(!zS(e.target,this.mirror,this.slimDOMOptions))switch(e.type){case\"characterData\":{const t=Gk.textContent(e.target);DS(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:MS(e.target,this.maskTextClass,this.maskTextSelector,!0)&&t?this.maskTextFn?this.maskTextFn(t,BS(e.target)):t.replace(/[\\S]/g,\"*\"):t,node:e.target});break}case\"attributes\":{const t=e.target;let n=e.attributeName,i=e.target.getAttribute(n);if(\"value\"===n){const e=iS(t);i=eS({element:t,maskInputOptions:this.maskInputOptions,tagName:t.tagName,type:e,value:i,maskInputFn:this.maskInputFn})}if(DS(e.target,this.blockClass,this.blockSelector,!1)||i===e.oldValue)return;let s=this.attributeMap.get(e.target);if(\"IFRAME\"===t.tagName&&\"src\"===n&&!this.keepIframeSrcFn(i)){if(t.contentDocument)return;n=\"rr_src\"}if(s||(s={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(s),this.attributeMap.set(e.target,s)),\"type\"===n&&\"INPUT\"===t.tagName&&\"password\"===(e.oldValue||\"\").toLowerCase()&&t.setAttribute(\"data-rr-is-password\",\"true\"),!CS(t.tagName,n))if(s.attributes[n]=SS(this.doc,tS(t.tagName),tS(n),i),\"style\"===n){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(e){this.unattachedDoc=this.doc}const n=this.unattachedDoc.createElement(\"span\");e.oldValue&&n.setAttribute(\"style\",e.oldValue);for(const e of Array.from(t.style)){const i=t.style.getPropertyValue(e),r=t.style.getPropertyPriority(e);i!==n.style.getPropertyValue(e)||r!==n.style.getPropertyPriority(e)?s.styleDiff[e]=\"\"===r?i:[i,r]:s._unchangedStyles[e]=[i,r]}for(const e of Array.from(n.style))\"\"===t.style.getPropertyValue(e)&&(s.styleDiff[e]=!1)}else\"open\"===n&&\"DIALOG\"===t.tagName&&(t.matches(\"dialog:modal\")?s.attributes.rr_open_mode=\"modal\":s.attributes.rr_open_mode=\"non-modal\");break}case\"childList\":if(DS(e.target,this.blockClass,this.blockSelector,!0))return;if(\"TEXTAREA\"===e.target.tagName)return void this.genTextAreaValueMutation(e.target);e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{const n=this.mirror.getId(t),i=Yk(e.target)?this.mirror.getId(Gk.host(e.target)):this.mirror.getId(e.target);DS(e.target,this.blockClass,this.blockSelector,!1)||zS(t,this.mirror,this.slimDOMOptions)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(nC(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||US(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[eC(n,i)]?nC(this.movedSet,t):(this.removes.push({parentId:i,id:n,isShadow:!(!Yk(e.target)||!Xk(e.target))||void 0}),function(e,t){const n=[e];for(;n.length;){const e=n.pop();t.has(e)||(t.add(e),Gk.childNodes(e).forEach(e=>n.push(e)))}}(t,this.removesSubTreeCache))),this.mapRemoves.push(t))})}}),Ak(this,\"genAdds\",(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(zS(e,this.mirror,this.slimDOMOptions))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[eC(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);DS(e,this.blockClass,this.blockSelector,!1)||(Gk.childNodes(e).forEach(e=>this.genAdds(e)),GS(e)&&Gk.childNodes(Gk.shadowRoot(e)).forEach(t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)}))}})}init(e){[\"mutationCb\",\"blockClass\",\"blockSelector\",\"maskTextClass\",\"maskTextSelector\",\"inlineStylesheet\",\"maskInputOptions\",\"maskTextFn\",\"maskInputFn\",\"keepIframeSrcFn\",\"recordCanvas\",\"inlineImages\",\"slimDOMOptions\",\"dataURLOptions\",\"doc\",\"mirror\",\"iframeManager\",\"stylesheetManager\",\"shadowDomManager\",\"canvasManager\",\"processedNodeManager\"].forEach(t=>{this[t]=e[t]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function nC(e,t){e.delete(t),Gk.childNodes(t).forEach(t=>nC(e,t))}function iC(e,t,n){return 0!==e.size&&function(e,t){const n=Gk.parentNode(t);return!!n&&e.has(n)}(e,t)}function sC(e,t){return 0!==e.size&&rC(e,t)}function rC(e,t){const n=Gk.parentNode(t);return!!n&&(!!e.has(n)||rC(e,n))}let oC;const aC=e=>{if(!oC)return e;return(...t)=>{try{return e(...t)}catch(e){if(oC&&!0===oC(e))return;throw e}}},lC=[];function cC(e){try{if(\"composedPath\"in e){const t=e.composedPath();if(t.length)return t[0]}else if(\"path\"in e&&e.path.length)return e.path[0]}catch{}return e&&e.target}function dC(e,t){const n=new tC;lC.push(n),n.init(e);const[i,s]=jk(),r=new i(aC(n.processMutations.bind(n)));return r.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),[r,s]}function uC({mouseInteractionCb:e,doc:t,mirror:n,blockClass:i,blockSelector:s,sampling:r}){if(!1===r.mouseInteraction)return()=>{};const o=!0===r.mouseInteraction||void 0===r.mouseInteraction?{}:r.mouseInteraction,a=[];let l=null;return Object.keys(Ik).filter(e=>Number.isNaN(Number(e))&&!e.endsWith(\"_Departed\")&&!1!==o[e]).forEach(r=>{let o=tS(r);const c=(t=>r=>{const o=cC(r);if(DS(o,i,s,!0))return;let a=null,c=t;if(\"pointerType\"in r){switch(r.pointerType){case\"mouse\":a=Lk.Mouse;break;case\"touch\":a=Lk.Touch;break;case\"pen\":a=Lk.Pen}a===Lk.Touch?Ik[t]===Ik.MouseDown?c=\"TouchStart\":Ik[t]===Ik.MouseUp&&(c=\"TouchEnd\"):Lk.Pen}else jS(r)&&(a=Lk.Touch);null!==a?(l=a,(c.startsWith(\"Touch\")&&a===Lk.Touch||c.startsWith(\"Mouse\")&&a===Lk.Mouse)&&(a=null)):Ik[t]===Ik.Click&&(a=l,l=null);const d=jS(r)?r.changedTouches[0]:r;if(!d)return;const u=n.getId(o),{clientX:p,clientY:h}=d;aC(e)({type:Ik[c],id:u,x:p,y:h,...null!==a&&{pointerType:a}})})(r);if(window.PointerEvent)switch(Ik[r]){case Ik.MouseDown:case Ik.MouseUp:o=o.replace(\"mouse\",\"pointer\");break;case Ik.TouchStart:case Ik.TouchEnd:return}a.push(RS(o,c,t))}),aC(()=>{a.forEach(e=>e())})}function pC({scrollCb:e,doc:t,mirror:n,blockClass:i,blockSelector:s,sampling:r}){const o=aC(PS(aC(r=>{const o=cC(r);if(!o||DS(o,i,s,!0))return;const a=n.getId(o);if(o===t&&t.defaultView){const n=OS(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:o.scrollLeft,y:o.scrollTop})}),r.scroll||100));return RS(\"scroll\",o,t)}const hC=[\"INPUT\",\"TEXTAREA\",\"SELECT\"],gC=new WeakMap;function mC(e){return function e(t,n){if(vC(\"CSSGroupingRule\")&&t.parentRule instanceof CSSGroupingRule||vC(\"CSSMediaRule\")&&t.parentRule instanceof CSSMediaRule||vC(\"CSSSupportsRule\")&&t.parentRule instanceof CSSSupportsRule||vC(\"CSSConditionRule\")&&t.parentRule instanceof CSSConditionRule){const i=Array.from(t.parentRule.cssRules).indexOf(t);return n.unshift(i),e(t.parentRule,n)}if(t.parentStyleSheet){const e=Array.from(t.parentStyleSheet.cssRules).indexOf(t);n.unshift(e)}return n}(e,[])}function fC(e,t,n){let i,s;return e?(e.ownerNode?i=t.getId(e.ownerNode):s=n.getId(e),{styleId:s,id:i}):{}}function bC({mirror:e,stylesheetManager:t},n){var i,s,r;let o=null;o=\"#document\"===n.nodeName?e.getId(n):e.getId(Gk.host(n));const a=\"#document\"===n.nodeName?null==(i=n.defaultView)?void 0:i.Document:null==(r=null==(s=n.ownerDocument)?void 0:s.defaultView)?void 0:r.ShadowRoot,l=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,\"adoptedStyleSheets\"):void 0;return null!==o&&-1!==o&&a&&l?(Object.defineProperty(n,\"adoptedStyleSheets\",{configurable:l.configurable,enumerable:l.enumerable,get(){var e;return null==(e=l.get)?void 0:e.call(this)},set(e){var n;const i=null==(n=l.set)?void 0:n.call(this,e);if(null!==o&&-1!==o)try{t.adoptStyleSheets(e,o)}catch(e){}return i}}),aC(()=>{Object.defineProperty(n,\"adoptedStyleSheets\",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})})):()=>{}}function yC(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};let i;!function(e,t){const{mutationCb:n,mousemoveCb:i,mouseInteractionCb:s,scrollCb:r,viewportResizeCb:o,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:d,canvasMutationCb:u,fontCb:p,selectionCb:h,customElementCb:g}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),i(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),s(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),r(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),o(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),l(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),c(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),p(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),h(...e)},e.customElementCb=(...e)=>{t.customElement&&t.customElement(...e),g(...e)}}(e,t);let s=()=>{};e.recordDOM&&([i,s]=dC(e,e.doc));const r=function({mousemoveCb:e,sampling:t,doc:n,mirror:i}){if(!1===t.mousemove)return()=>{};const s=\"number\"==typeof t.mousemove?t.mousemove:50,r=\"number\"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let o,a=[];const l=PS(aC(t=>{const n=Date.now()-o;e(a.map(e=>(e.timeOffset-=n,e)),t),a=[],o=null}),r),c=aC(PS(aC(e=>{const t=cC(e),{clientX:n,clientY:s}=jS(e)?e.changedTouches[0]:e;o||(o=Wk()),a.push({x:n,y:s,id:i.getId(t),timeOffset:Wk()-o}),l(\"undefined\"!=typeof DragEvent&&e instanceof DragEvent?Tk.Drag:e instanceof MouseEvent?Tk.MouseMove:Tk.TouchMove)}),s,{trailing:!1})),d=[RS(\"mousemove\",c,n),RS(\"touchmove\",c,n),RS(\"drag\",c,n)];return aC(()=>{d.forEach(e=>e())})}(e),o=uC(e),a=pC(e),l=function({viewportResizeCb:e},{win:t}){let n=-1,i=-1;return RS(\"resize\",aC(PS(aC(()=>{const t=qS(),s=HS();n===t&&i===s||(e({width:Number(s),height:Number(t)}),n=t,i=s)}),200)),t)}(e,{win:n}),c=function({inputCb:e,doc:t,mirror:n,blockClass:i,blockSelector:s,ignoreClass:r,ignoreSelector:o,maskInputOptions:a,maskInputFn:l,sampling:c,userTriggeredOnInput:d}){function u(e){let n=cC(e);const c=e.isTrusted,u=n&&n.tagName;if(n&&\"OPTION\"===u&&(n=Gk.parentElement(n)),!n||!u||hC.indexOf(u)<0||DS(n,i,s,!0))return;if(n.classList.contains(r)||o&&n.matches(o))return;let h=n.value,g=!1;const m=iS(n)||\"\";\"radio\"===m||\"checkbox\"===m?g=n.checked:(a[u.toLowerCase()]||a[m])&&(h=eS({element:n,maskInputOptions:a,tagName:u,type:m,value:h,maskInputFn:l})),p(n,d?{text:h,isChecked:g,userTriggered:c}:{text:h,isChecked:g});const f=n.name;\"radio\"===m&&f&&g&&t.querySelectorAll(`input[type=\"radio\"][name=\"${f}\"]`).forEach(e=>{if(e!==n){const t=e.value;p(e,d?{text:t,isChecked:!g,userTriggered:!1}:{text:t,isChecked:!g})}})}function p(t,i){const s=gC.get(t);if(!s||s.text!==i.text||s.isChecked!==i.isChecked){gC.set(t,i);const s=n.getId(t);aC(e)({...i,id:s})}}const h=(\"last\"===c.input?[\"change\"]:[\"input\",\"change\"]).map(e=>RS(e,aC(u),t)),g=t.defaultView;if(!g)return()=>{h.forEach(e=>e())};const m=g.Object.getOwnPropertyDescriptor(g.HTMLInputElement.prototype,\"value\"),f=[[g.HTMLInputElement.prototype,\"value\"],[g.HTMLInputElement.prototype,\"checked\"],[g.HTMLSelectElement.prototype,\"value\"],[g.HTMLTextAreaElement.prototype,\"value\"],[g.HTMLSelectElement.prototype,\"selectedIndex\"],[g.HTMLOptionElement.prototype,\"selected\"]];return m&&m.set&&h.push(...f.map(e=>FS(e[0],e[1],{set(){aC(u)({target:this,isTrusted:!1})}},!1,g))),aC(()=>{h.forEach(e=>e())})}(e),d=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:i,sampling:s,doc:r}){const o=aC(r=>PS(aC(s=>{const o=cC(s);if(!o||DS(o,t,n,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:d,loop:u}=o;e({type:r,id:i.getId(o),currentTime:a,volume:l,muted:c,playbackRate:d,loop:u})}),s.media||500)),a=[RS(\"play\",o($k.Play),r),RS(\"pause\",o($k.Pause),r),RS(\"seeked\",o($k.Seeked),r),RS(\"volumechange\",o($k.VolumeChange),r),RS(\"ratechange\",o($k.RateChange),r)];return aC(()=>{a.forEach(e=>e())})}(e);let u=()=>{},p=()=>{},h=()=>{},g=()=>{};e.recordDOM&&(u=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:i}){if(!i.CSSStyleSheet||!i.CSSStyleSheet.prototype)return()=>{};const s=i.CSSStyleSheet.prototype.insertRule;i.CSSStyleSheet.prototype.insertRule=new Proxy(s,{apply:aC((i,s,r)=>{const[o,a]=r,{id:l,styleId:c}=fC(s,t,n.styleMirror);return(l&&-1!==l||c&&-1!==c)&&e({id:l,styleId:c,adds:[{rule:o,index:a}]}),i.apply(s,r)})}),i.CSSStyleSheet.prototype.addRule=function(e,t,n=this.cssRules.length){const s=`${e} { ${t} }`;return i.CSSStyleSheet.prototype.insertRule.apply(this,[s,n])};const r=i.CSSStyleSheet.prototype.deleteRule;let o,a;i.CSSStyleSheet.prototype.deleteRule=new Proxy(r,{apply:aC((i,s,r)=>{const[o]=r,{id:a,styleId:l}=fC(s,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,removes:[{index:o}]}),i.apply(s,r)})}),i.CSSStyleSheet.prototype.removeRule=function(e){return i.CSSStyleSheet.prototype.deleteRule.apply(this,[e])},i.CSSStyleSheet.prototype.replace&&(o=i.CSSStyleSheet.prototype.replace,i.CSSStyleSheet.prototype.replace=new Proxy(o,{apply:aC((i,s,r)=>{const[o]=r,{id:a,styleId:l}=fC(s,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,replace:o}),i.apply(s,r)})})),i.CSSStyleSheet.prototype.replaceSync&&(a=i.CSSStyleSheet.prototype.replaceSync,i.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:aC((i,s,r)=>{const[o]=r,{id:a,styleId:l}=fC(s,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,replaceSync:o}),i.apply(s,r)})}));const l={};wC(\"CSSGroupingRule\")?l.CSSGroupingRule=i.CSSGroupingRule:(wC(\"CSSMediaRule\")&&(l.CSSMediaRule=i.CSSMediaRule),wC(\"CSSConditionRule\")&&(l.CSSConditionRule=i.CSSConditionRule),wC(\"CSSSupportsRule\")&&(l.CSSSupportsRule=i.CSSSupportsRule));const c={};return Object.entries(l).forEach(([i,s])=>{c[i]={insertRule:s.prototype.insertRule,deleteRule:s.prototype.deleteRule},s.prototype.insertRule=new Proxy(c[i].insertRule,{apply:aC((i,s,r)=>{const[o,a]=r,{id:l,styleId:c}=fC(s.parentStyleSheet,t,n.styleMirror);return(l&&-1!==l||c&&-1!==c)&&e({id:l,styleId:c,adds:[{rule:o,index:[...mC(s),a||0]}]}),i.apply(s,r)})}),s.prototype.deleteRule=new Proxy(c[i].deleteRule,{apply:aC((i,s,r)=>{const[o]=r,{id:a,styleId:l}=fC(s.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,removes:[{index:[...mC(s),o]}]}),i.apply(s,r)})})}),aC(()=>{i.CSSStyleSheet.prototype.insertRule=s,i.CSSStyleSheet.prototype.deleteRule=r,o&&(i.CSSStyleSheet.prototype.replace=o),a&&(i.CSSStyleSheet.prototype.replaceSync=a),Object.entries(l).forEach(([e,t])=>{t.prototype.insertRule=c[e].insertRule,t.prototype.deleteRule=c[e].deleteRule})})}(e,{win:n}),p=bC(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:i},{win:s}){const r=s.CSSStyleDeclaration.prototype.setProperty;s.CSSStyleDeclaration.prototype.setProperty=new Proxy(r,{apply:aC((s,o,a)=>{var l;const[c,d,u]=a;if(n.has(c))return r.apply(o,[c,d,u]);const{id:p,styleId:h}=fC(null==(l=o.parentRule)?void 0:l.parentStyleSheet,t,i.styleMirror);return(p&&-1!==p||h&&-1!==h)&&e({id:p,styleId:h,set:{property:c,value:d,priority:u},index:mC(o.parentRule)}),s.apply(o,a)})});const o=s.CSSStyleDeclaration.prototype.removeProperty;return s.CSSStyleDeclaration.prototype.removeProperty=new Proxy(o,{apply:aC((s,r,a)=>{var l;const[c]=a;if(n.has(c))return o.apply(r,[c]);const{id:d,styleId:u}=fC(null==(l=r.parentRule)?void 0:l.parentStyleSheet,t,i.styleMirror);return(d&&-1!==d||u&&-1!==u)&&e({id:d,styleId:u,remove:{property:c},index:mC(r.parentRule)}),s.apply(r,a)})}),aC(()=>{s.CSSStyleDeclaration.prototype.setProperty=r,s.CSSStyleDeclaration.prototype.removeProperty=o})}(e,{win:n}),e.collectFonts&&(g=function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const i=[],s=new WeakMap,r=n.FontFace;n.FontFace=function(e,t,n){const i=new r(e,t,n);return s.set(i,{family:e,buffer:\"string\"!=typeof t,descriptors:n,fontSource:\"string\"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),i};const o=Vk(t.fonts,\"add\",function(t){return function(n){return setTimeout(aC(()=>{const t=s.get(n);t&&(e(t),s.delete(n))}),0),t.apply(this,[n])}});return i.push(()=>{n.FontFace=r}),i.push(o),aC(()=>{i.forEach(e=>e())})}(e)));const m=function(e){const{doc:t,mirror:n,blockClass:i,blockSelector:s,selectionCb:r}=e;let o=!0;const a=aC(()=>{const e=t.getSelection();if(!e||o&&(null==e?void 0:e.isCollapsed))return;o=e.isCollapsed||!1;const a=[],l=e.rangeCount||0;for(let t=0;t<l;t++){const r=e.getRangeAt(t),{startContainer:o,startOffset:l,endContainer:c,endOffset:d}=r;DS(o,i,s,!0)||DS(c,i,s,!0)||a.push({start:n.getId(o),startOffset:l,end:n.getId(c),endOffset:d})}r({ranges:a})});return a(),RS(\"selectionchange\",a)}(e),f=function({doc:e,customElementCb:t}){const n=e.defaultView;if(!n||!n.customElements)return()=>{};const i=Vk(n.customElements,\"define\",function(e){return function(n,i,s){try{t({define:{name:n}})}catch(e){console.warn(`Custom element callback failed for ${n}`)}return e.apply(this,[n,i,s])}});return i}(e),b=[];for(const t of e.plugins)b.push(t.observer(t.callback,n,t.options));return aC(()=>{lC.forEach(e=>e.reset()),null==i||i.disconnect(),s(),r(),o(),a(),l(),c(),d(),u(),p(),h(),g(),m(),f(),b.forEach(e=>e())})}function vC(e){return void 0!==window[e]}function wC(e){return Boolean(void 0!==window[e]&&window[e].prototype&&\"insertRule\"in window[e].prototype&&\"deleteRule\"in window[e].prototype)}class xC{constructor(e){Ak(this,\"iframeIdToRemoteIdMap\",new WeakMap),Ak(this,\"iframeRemoteIdToIdMap\",new WeakMap),this.generateIdFn=e}getId(e,t,n,i){const s=n||this.getIdToRemoteIdMap(e),r=i||this.getRemoteIdToIdMap(e);let o=s.get(t);return o||(o=this.generateIdFn(),s.set(t,o),r.set(o,t)),o}getIds(e,t){const n=this.getIdToRemoteIdMap(e),i=this.getRemoteIdToIdMap(e);return t.map(t=>this.getId(e,t,n,i))}getRemoteId(e,t,n){const i=n||this.getRemoteIdToIdMap(e);if(\"number\"!=typeof t)return t;const s=i.get(t);return s||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map(t=>this.getRemoteId(e,t,n))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class kC{constructor(e){Ak(this,\"iframes\",new WeakMap),Ak(this,\"crossOriginIframeMap\",new WeakMap),Ak(this,\"crossOriginIframeMirror\",new xC(gS)),Ak(this,\"crossOriginIframeStyleMirror\"),Ak(this,\"crossOriginIframeRootIdMap\",new WeakMap),Ak(this,\"mirror\"),Ak(this,\"mutationCb\"),Ak(this,\"wrappedEmit\"),Ak(this,\"loadListener\"),Ak(this,\"stylesheetManager\"),Ak(this,\"recordCrossOriginIframes\"),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new xC(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener(\"message\",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n,i;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&(null==(n=e.contentWindow)||n.addEventListener(\"message\",this.handleMessage.bind(this))),null==(i=this.loadListener)||i.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const t=e;if(\"rrweb\"!==t.data.type||t.origin!==t.data.origin)return;if(!e.source)return;const n=this.crossOriginIframeMap.get(e.source);if(!n)return;const i=this.transformCrossOriginEvent(n,t.data.event);i&&this.wrappedEmit(i,t.data.isCheckout)}transformCrossOriginEvent(e,t){var n;switch(t.type){case _k.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);const n=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,n),this.patchRootIdOnNode(t.data.node,n),{timestamp:t.timestamp,type:_k.IncrementalSnapshot,data:{source:Tk.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case _k.Meta:case _k.Load:case _k.DomContentLoaded:return!1;case _k.Plugin:return t;case _k.Custom:return this.replaceIds(t.data.payload,e,[\"id\",\"parentId\",\"previousId\",\"nextId\"]),t;case _k.IncrementalSnapshot:switch(t.data.source){case Tk.Mutation:return t.data.adds.forEach(t=>{this.replaceIds(t,e,[\"parentId\",\"nextId\",\"previousId\"]),this.replaceIdOnNode(t.node,e);const n=this.crossOriginIframeRootIdMap.get(e);n&&this.patchRootIdOnNode(t.node,n)}),t.data.removes.forEach(t=>{this.replaceIds(t,e,[\"parentId\",\"id\"])}),t.data.attributes.forEach(t=>{this.replaceIds(t,e,[\"id\"])}),t.data.texts.forEach(t=>{this.replaceIds(t,e,[\"id\"])}),t;case Tk.Drag:case Tk.TouchMove:case Tk.MouseMove:return t.data.positions.forEach(t=>{this.replaceIds(t,e,[\"id\"])}),t;case Tk.ViewportResize:return!1;case Tk.MediaInteraction:case Tk.MouseInteraction:case Tk.Scroll:case Tk.CanvasMutation:case Tk.Input:return this.replaceIds(t.data,e,[\"id\"]),t;case Tk.StyleSheetRule:case Tk.StyleDeclaration:return this.replaceIds(t.data,e,[\"id\"]),this.replaceStyleIds(t.data,e,[\"styleId\"]),t;case Tk.Font:return t;case Tk.Selection:return t.data.ranges.forEach(t=>{this.replaceIds(t,e,[\"start\",\"end\"])}),t;case Tk.AdoptedStyleSheet:return this.replaceIds(t.data,e,[\"id\"]),this.replaceStyleIds(t.data,e,[\"styleIds\"]),null==(n=t.data.styles)||n.forEach(t=>{this.replaceStyleIds(t,e,[\"styleId\"])}),t}}return!1}replace(e,t,n,i){for(const s of i)(Array.isArray(t[s])||\"number\"==typeof t[s])&&(Array.isArray(t[s])?t[s]=e.getIds(n,t[s]):t[s]=e.getId(n,t[s]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,[\"id\",\"rootId\"]),\"childNodes\"in e&&e.childNodes.forEach(e=>{this.replaceIdOnNode(e,t)})}patchRootIdOnNode(e,t){e.type===Nk.Document||e.rootId||(e.rootId=t),\"childNodes\"in e&&e.childNodes.forEach(e=>{this.patchRootIdOnNode(e,t)})}}class SC{constructor(e){Ak(this,\"shadowDoms\",new WeakSet),Ak(this,\"mutationCb\"),Ak(this,\"scrollCb\"),Ak(this,\"bypassOptions\"),Ak(this,\"mirror\"),Ak(this,\"restoreHandlers\",[]),this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,t){if(!Xk(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const[n]=dC({...this.bypassOptions,doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},e);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(pC({...this.bypassOptions,scrollCb:this.scrollCb,doc:e,mirror:this.mirror})),setTimeout(()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(Gk.host(e))),this.restoreHandlers.push(bC({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e))},0)}observeAttachShadow(e){e.contentWindow&&e.contentDocument&&this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,t){const n=this;this.restoreHandlers.push(Vk(e.prototype,\"attachShadow\",function(e){return function(i){const s=e.call(this,i),r=Gk.shadowRoot(this);return r&&JS(this)&&n.addShadowRoot(r,t),s}}))}reset(){this.restoreHandlers.forEach(e=>{try{e()}catch(e){}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}for(var CC=\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\",EC=\"undefined\"==typeof Uint8Array?[]:new Uint8Array(256),MC=0;MC<64;MC++)EC[CC.charCodeAt(MC)]=MC;const AC=new Map;const _C=(e,t,n)=>{if(!e||!LC(e,t)&&\"object\"!=typeof e)return;const i=function(e,t){let n=AC.get(e);return n||(n=new Map,AC.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let s=i.indexOf(e);return-1===s&&(s=i.length,i.push(e)),s};function TC(e,t,n){if(e instanceof Array)return e.map(e=>TC(e,t,n));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),i=n.length,s=\"\";for(t=0;t<i;t+=3)s+=CC[n[t]>>2],s+=CC[(3&n[t])<<4|n[t+1]>>4],s+=CC[(15&n[t+1])<<2|n[t+2]>>6],s+=CC[63&n[t+2]];return i%3==2?s=s.substring(0,s.length-1)+\"=\":i%3==1&&(s=s.substring(0,s.length-2)+\"==\"),s}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[TC(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:\"HTMLImageElement\",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[TC(e.data,t,n),e.width,e.height]}}if(LC(e,t)||\"object\"==typeof e){return{rr_type:e.constructor.name,index:_C(e,t,n)}}return e}const IC=(e,t,n)=>e.map(e=>TC(e,t,n)),LC=(e,t)=>{const n=[\"WebGLActiveInfo\",\"WebGLBuffer\",\"WebGLFramebuffer\",\"WebGLProgram\",\"WebGLRenderbuffer\",\"WebGLShader\",\"WebGLShaderPrecisionFormat\",\"WebGLTexture\",\"WebGLUniformLocation\",\"WebGLVertexArrayObject\",\"WebGLVertexArrayObjectOES\"].filter(e=>\"function\"==typeof t[e]);return Boolean(n.find(n=>e instanceof t[n]))};function RC(e,t,n,i){const s=[];try{const r=Vk(e.HTMLCanvasElement.prototype,\"getContext\",function(e){return function(s,...r){if(!DS(this,t,n,!0)){const e=function(e){return\"experimental-webgl\"===e?\"webgl\":e}(s);if(\"__context\"in this||(this.__context=e),i&&[\"webgl\",\"webgl2\"].includes(e))if(r[0]&&\"object\"==typeof r[0]){const e=r[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else r.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[s,...r])}});s.push(r)}catch{console.error(\"failed to patch HTMLCanvasElement.prototype.getContext\")}return()=>{s.forEach(e=>e())}}function $C(e,t,n,i,s,r){const o=[],a=Object.getOwnPropertyNames(e);for(const l of a)if(![\"isContextLost\",\"canvas\",\"drawingBufferWidth\",\"drawingBufferHeight\"].includes(l))try{if(\"function\"!=typeof e[l])continue;const a=Vk(e,l,function(e){return function(...o){const a=e.apply(this,o);if(_C(a,r,this),\"tagName\"in this.canvas&&!DS(this.canvas,i,s,!0)){const e=IC(o,r,this),i={type:t,property:l,args:e};n(this.canvas,i)}return a}});o.push(a)}catch{const i=FS(e,l,{set(e){n(this.canvas,{type:t,property:l,args:[e],setter:!0})}});o.push(i)}return o}const NC='(function() {\\n  \"use strict\";\\n  var chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\\n  var lookup = typeof Uint8Array === \"undefined\" ? [] : new Uint8Array(256);\\n  for (var i = 0; i < chars.length; i++) {\\n    lookup[chars.charCodeAt(i)] = i;\\n  }\\n  var encode = function(arraybuffer) {\\n    var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = \"\";\\n    for (i2 = 0; i2 < len; i2 += 3) {\\n      base64 += chars[bytes[i2] >> 2];\\n      base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];\\n      base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];\\n      base64 += chars[bytes[i2 + 2] & 63];\\n    }\\n    if (len % 3 === 2) {\\n      base64 = base64.substring(0, base64.length - 1) + \"=\";\\n    } else if (len % 3 === 1) {\\n      base64 = base64.substring(0, base64.length - 2) + \"==\";\\n    }\\n    return base64;\\n  };\\n  const lastBlobMap = /* @__PURE__ */ new Map();\\n  const transparentBlobMap = /* @__PURE__ */ new Map();\\n  async function getTransparentBlobFor(width, height, dataURLOptions) {\\n    const id = `${width}-${height}`;\\n    if (\"OffscreenCanvas\" in globalThis) {\\n      if (transparentBlobMap.has(id)) return transparentBlobMap.get(id);\\n      const offscreen = new OffscreenCanvas(width, height);\\n      offscreen.getContext(\"2d\");\\n      const blob = await offscreen.convertToBlob(dataURLOptions);\\n      const arrayBuffer = await blob.arrayBuffer();\\n      const base64 = encode(arrayBuffer);\\n      transparentBlobMap.set(id, base64);\\n      return base64;\\n    } else {\\n      return \"\";\\n    }\\n  }\\n  const worker = self;\\n  worker.onmessage = async function(e) {\\n    if (\"OffscreenCanvas\" in globalThis) {\\n      const { id, bitmap, width, height, dataURLOptions } = e.data;\\n      const transparentBase64 = getTransparentBlobFor(\\n        width,\\n        height,\\n        dataURLOptions\\n      );\\n      const offscreen = new OffscreenCanvas(width, height);\\n      const ctx = offscreen.getContext(\"2d\");\\n      ctx.drawImage(bitmap, 0, 0);\\n      bitmap.close();\\n      const blob = await offscreen.convertToBlob(dataURLOptions);\\n      const type = blob.type;\\n      const arrayBuffer = await blob.arrayBuffer();\\n      const base64 = encode(arrayBuffer);\\n      if (!lastBlobMap.has(id) && await transparentBase64 === base64) {\\n        lastBlobMap.set(id, base64);\\n        return worker.postMessage({ id });\\n      }\\n      if (lastBlobMap.get(id) === base64) return worker.postMessage({ id });\\n      worker.postMessage({\\n        id,\\n        type,\\n        base64,\\n        width,\\n        height\\n      });\\n      lastBlobMap.set(id, base64);\\n    } else {\\n      return worker.postMessage({ id: e.data.id });\\n    }\\n  };\\n})();\\n//# sourceMappingURL=image-bitmap-data-url-worker-IJpC7g_b.js.map\\n',PC=\"undefined\"!=typeof self&&self.Blob&&new Blob([NC],{type:\"text/javascript;charset=utf-8\"});function FC(e){let t;try{if(t=PC&&(self.URL||self.webkitURL).createObjectURL(PC),!t)throw\"\";const n=new Worker(t,{name:null==e?void 0:e.name});return n.addEventListener(\"error\",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch(t){return new Worker(\"data:text/javascript;charset=utf-8,\"+encodeURIComponent(NC),{name:null==e?void 0:e.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}class OC{constructor(e){Ak(this,\"pendingCanvasMutations\",new Map),Ak(this,\"rafStamps\",{latestId:0,invokeId:null}),Ak(this,\"mirror\"),Ak(this,\"mutationCb\"),Ak(this,\"resetObservers\"),Ak(this,\"frozen\",!1),Ak(this,\"locked\",!1),Ak(this,\"processMutation\",(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)});const{sampling:t=\"all\",win:n,blockClass:i,blockSelector:s,recordCanvas:r,dataURLOptions:o}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,r&&\"all\"===t&&this.initCanvasMutationObserver(n,i,s),r&&\"number\"==typeof t&&this.initCanvasFPSObserver(t,n,i,s,{dataURLOptions:o})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,i,s){const r=RC(t,n,i,!0),o=new Map,a=new FC;a.onmessage=e=>{const{id:t}=e.data;if(o.set(t,!1),!(\"base64\"in e.data))return;const{base64:n,type:i,width:s,height:r}=e.data;this.mutationCb({id:t,type:Rk[\"2D\"],commands:[{property:\"clearRect\",args:[0,0,s,r]},{property:\"drawImage\",args:[{rr_type:\"ImageBitmap\",args:[{rr_type:\"Blob\",data:[{rr_type:\"ArrayBuffer\",base64:n}],type:i}]},0,0]}]})};const l=1e3/e;let c,d=0;const u=e=>{d&&e-d<l||(d=e,(()=>{const e=[];return t.document.querySelectorAll(\"canvas\").forEach(t=>{DS(t,n,i,!0)||e.push(t)}),e})().forEach(async e=>{var t;const n=this.mirror.getId(e);if(o.get(n))return;if(0===e.width||0===e.height)return;if(o.set(n,!0),[\"webgl\",\"webgl2\"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null==(t=null==n?void 0:n.getContextAttributes())?void 0:t.preserveDrawingBuffer)&&n.clear(n.COLOR_BUFFER_BIT)}const i=await createImageBitmap(e);a.postMessage({id:n,bitmap:i,width:e.width,height:e.height,dataURLOptions:s.dataURLOptions},[i])})),c=requestAnimationFrame(u)};c=requestAnimationFrame(u),this.resetObservers=()=>{r(),cancelAnimationFrame(c)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const i=RC(e,t,n,!1),s=function(e,t,n,i){const s=[],r=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const o of r)try{if(\"function\"!=typeof t.CanvasRenderingContext2D.prototype[o])continue;const r=Vk(t.CanvasRenderingContext2D.prototype,o,function(s){return function(...r){return DS(this.canvas,n,i,!0)||setTimeout(()=>{const n=IC(r,t,this);e(this.canvas,{type:Rk[\"2D\"],property:o,args:n})},0),s.apply(this,r)}});s.push(r)}catch{const n=FS(t.CanvasRenderingContext2D.prototype,o,{set(t){e(this.canvas,{type:Rk[\"2D\"],property:o,args:[t],setter:!0})}});s.push(n)}return()=>{s.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n),r=function(e,t,n,i){const s=[];return void 0!==t.WebGLRenderingContext&&s.push(...$C(t.WebGLRenderingContext.prototype,Rk.WebGL,e,n,i,t)),void 0!==t.WebGL2RenderingContext&&s.push(...$C(t.WebGL2RenderingContext.prototype,Rk.WebGL2,e,n,i,t)),()=>{s.forEach(e=>e())}}(this.processMutation.bind(this),e,t,n);this.resetObservers=()=>{i(),s(),r()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const i=n.map(e=>{const{type:t,...n}=e;return n}),{type:s}=n[0];this.mutationCb({id:t,type:s,commands:i}),this.pendingCanvasMutations.delete(e)}}class qC{constructor(e){Ak(this,\"trackedLinkElements\",new WeakSet),Ak(this,\"mutationCb\"),Ak(this,\"adoptedStyleSheetCb\"),Ak(this,\"styleMirror\",new KS),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){\"_cssText\"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},i=[];for(const t of e){let e;this.styleMirror.has(t)?e=this.styleMirror.getId(t):(e=this.styleMirror.add(t),i.push({styleId:e,rules:Array.from(t.rules||CSSRule,(e,n)=>({rule:Qk(e,t.href),index:n}))})),n.styleIds.push(e)}i.length>0&&(n.styles=i),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}class HC{constructor(){Ak(this,\"nodeMap\",new WeakMap),Ak(this,\"active\",!1)}inOtherBuffer(e,t){const n=this.nodeMap.get(e);return n&&Array.from(n).some(e=>e!==t)}add(e,t){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}destroy(){}}let BC,DC,zC,UC=!1;try{if(2!==Array.from([1],e=>2*e)[0]){const e=document.createElement(\"iframe\");document.body.appendChild(e),Array.from=(null==(Ek=e.contentWindow)?void 0:Ek.Array.from)||Array.from,document.body.removeChild(e)}}catch(e){console.debug(\"Unable to override Array.from\",e)}const jC=new Zk;function WC(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:i,blockClass:s=\"rr-block\",blockSelector:r=null,ignoreClass:o=\"rr-ignore\",ignoreSelector:a=null,maskTextClass:l=\"rr-mask\",maskTextSelector:c=null,inlineStylesheet:d=!0,maskAllInputs:u,maskInputOptions:p,slimDOMOptions:h,maskInputFn:g,maskTextFn:m,hooks:f,packFn:b,sampling:y={},dataURLOptions:v={},mousemoveWait:w,recordDOM:x=!0,recordCanvas:k=!1,recordCrossOriginIframes:S=!1,recordAfter:C=(\"DOMContentLoaded\"===e.recordAfter?e.recordAfter:\"load\"),userTriggeredOnInput:E=!1,collectFonts:M=!1,inlineImages:A=!1,plugins:_,keepIframeSrcFn:T=()=>!1,ignoreCSSAttributes:I=new Set([]),errorHandler:L}=e;oC=L;const R=!S||window.parent===window;let $=!1;if(!R)try{window.parent.document&&($=!1)}catch(e){$=!0}if(R&&!t)throw new Error(\"emit function is required\");if(!R&&!$)return()=>{};void 0!==w&&void 0===y.mousemove&&(y.mousemove=w),jC.reset();const N=!0===u?{color:!0,date:!0,\"datetime-local\":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==p?p:{password:!0},P=TS(h);let F;!function(e=window){\"NodeList\"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),\"DOMTokenList\"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach)}();let O=0;const q=e=>{for(const t of _||[])t.eventProcessor&&(e=t.eventProcessor(e));return b&&!$&&(e=b(e)),e};BC=(e,s)=>{var r;const o=e;if(o.timestamp=Wk(),!(null==(r=lC[0])?void 0:r.isFrozen())||o.type===_k.FullSnapshot||o.type===_k.IncrementalSnapshot&&o.data.source===Tk.Mutation||lC.forEach(e=>e.unfreeze()),R)null==t||t(q(o),s);else if($){const e={type:\"rrweb\",event:q(o),origin:window.location.origin,isCheckout:s};window.parent.postMessage(e,\"*\")}if(o.type===_k.FullSnapshot)F=o,O=0;else if(o.type===_k.IncrementalSnapshot){if(o.data.source===Tk.Mutation&&o.data.isAttachIframe)return;O++;const e=i&&O>=i,t=n&&o.timestamp-F.timestamp>n;(e||t)&&DC(!0)}};const H=e=>{BC({type:_k.IncrementalSnapshot,data:{source:Tk.Mutation,...e}})},B=e=>BC({type:_k.IncrementalSnapshot,data:{source:Tk.Scroll,...e}}),D=e=>BC({type:_k.IncrementalSnapshot,data:{source:Tk.CanvasMutation,...e}}),z=new qC({mutationCb:H,adoptedStyleSheetCb:e=>BC({type:_k.IncrementalSnapshot,data:{source:Tk.AdoptedStyleSheet,...e}})}),U=new kC({mirror:jC,mutationCb:H,stylesheetManager:z,recordCrossOriginIframes:S,wrappedEmit:BC});for(const e of _||[])e.getMirror&&e.getMirror({nodeMirror:jC,crossOriginIframeMirror:U.crossOriginIframeMirror,crossOriginIframeStyleMirror:U.crossOriginIframeStyleMirror});const j=new HC;zC=new OC({recordCanvas:k,mutationCb:D,win:window,blockClass:s,blockSelector:r,mirror:jC,sampling:y.canvas,dataURLOptions:v});const W=new SC({mutationCb:H,scrollCb:B,bypassOptions:{blockClass:s,blockSelector:r,maskTextClass:l,maskTextSelector:c,inlineStylesheet:d,maskInputOptions:N,dataURLOptions:v,maskTextFn:m,maskInputFn:g,recordCanvas:k,inlineImages:A,sampling:y,slimDOMOptions:P,iframeManager:U,stylesheetManager:z,canvasManager:zC,keepIframeSrcFn:T,processedNodeManager:j},mirror:jC});DC=(e=!1)=>{if(!x)return;BC({type:_k.Meta,data:{href:window.location.href,width:HS(),height:qS()}},e),z.reset(),W.init(),lC.forEach(e=>e.lock());const t=function(e,t){const{mirror:n=new Zk,blockClass:i=\"rr-block\",blockSelector:s=null,maskTextClass:r=\"rr-mask\",maskTextSelector:o=null,inlineStylesheet:a=!0,inlineImages:l=!1,recordCanvas:c=!1,maskAllInputs:d=!1,maskTextFn:u,maskInputFn:p,slimDOM:h=!1,dataURLOptions:g,preserveWhiteSpace:m,onSerialize:f,onIframeLoad:b,iframeLoadTimeout:y,onStylesheetLoad:v,stylesheetLoadTimeout:w,keepIframeSrcFn:x=()=>!1}=t;return IS(e,{doc:e,mirror:n,blockClass:i,blockSelector:s,maskTextClass:r,maskTextSelector:o,skipChild:!1,inlineStylesheet:a,maskInputOptions:!0===d?{color:!0,date:!0,\"datetime-local\":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===d?{password:!0}:d,maskTextFn:u,maskInputFn:p,slimDOMOptions:TS(h),dataURLOptions:g,inlineImages:l,recordCanvas:c,preserveWhiteSpace:m,onSerialize:f,onIframeLoad:b,iframeLoadTimeout:y,onStylesheetLoad:v,stylesheetLoadTimeout:w,keepIframeSrcFn:x,newlyAddedElement:!1})}(document,{mirror:jC,blockClass:s,blockSelector:r,maskTextClass:l,maskTextSelector:c,inlineStylesheet:d,maskAllInputs:N,maskTextFn:m,maskInputFn:g,slimDOM:P,dataURLOptions:v,recordCanvas:k,inlineImages:A,onSerialize:e=>{WS(e,jC)&&U.addIframe(e),VS(e,jC)&&z.trackLinkElement(e),GS(e)&&W.addShadowRoot(Gk.shadowRoot(e),document)},onIframeLoad:(e,t)=>{U.attachIframe(e,t),W.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{z.attachLinkElement(e,t)},keepIframeSrcFn:T});if(!t)return console.warn(\"Failed to snapshot the document\");BC({type:_k.FullSnapshot,data:{node:t,initialOffset:OS(window)}},e),lC.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&z.adoptStyleSheets(document.adoptedStyleSheets,jC.getId(document))};try{const e=[],t=e=>{var t;return aC(yC)({mutationCb:H,mousemoveCb:(e,t)=>BC({type:_k.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>BC({type:_k.IncrementalSnapshot,data:{source:Tk.MouseInteraction,...e}}),scrollCb:B,viewportResizeCb:e=>BC({type:_k.IncrementalSnapshot,data:{source:Tk.ViewportResize,...e}}),inputCb:e=>BC({type:_k.IncrementalSnapshot,data:{source:Tk.Input,...e}}),mediaInteractionCb:e=>BC({type:_k.IncrementalSnapshot,data:{source:Tk.MediaInteraction,...e}}),styleSheetRuleCb:e=>BC({type:_k.IncrementalSnapshot,data:{source:Tk.StyleSheetRule,...e}}),styleDeclarationCb:e=>BC({type:_k.IncrementalSnapshot,data:{source:Tk.StyleDeclaration,...e}}),canvasMutationCb:D,fontCb:e=>BC({type:_k.IncrementalSnapshot,data:{source:Tk.Font,...e}}),selectionCb:e=>{BC({type:_k.IncrementalSnapshot,data:{source:Tk.Selection,...e}})},customElementCb:e=>{BC({type:_k.IncrementalSnapshot,data:{source:Tk.CustomElement,...e}})},blockClass:s,ignoreClass:o,ignoreSelector:a,maskTextClass:l,maskTextSelector:c,maskInputOptions:N,inlineStylesheet:d,sampling:y,recordDOM:x,recordCanvas:k,inlineImages:A,userTriggeredOnInput:E,collectFonts:M,doc:e,maskInputFn:g,maskTextFn:m,keepIframeSrcFn:T,blockSelector:r,slimDOMOptions:P,dataURLOptions:v,mirror:jC,iframeManager:U,stylesheetManager:z,shadowDomManager:W,processedNodeManager:j,canvasManager:zC,ignoreCSSAttributes:I,plugins:(null==(t=null==_?void 0:_.filter(e=>e.observer))?void 0:t.map(e=>({observer:e.observer,options:e.options,callback:t=>BC({type:_k.Plugin,data:{plugin:e.name,payload:t}})})))||[]},f)};U.addLoadListener(n=>{try{e.push(t(n.contentDocument))}catch(e){console.warn(e)}});const n=()=>{DC(),e.push(t(document)),UC=!0};return[\"interactive\",\"complete\"].includes(document.readyState)?n():(e.push(RS(\"DOMContentLoaded\",()=>{BC({type:_k.DomContentLoaded,data:{}}),\"DOMContentLoaded\"===C&&n()})),e.push(RS(\"load\",()=>{BC({type:_k.Load,data:{}}),\"load\"===C&&n()},window))),()=>{e.forEach(e=>{try{e()}catch(e){String(e).toLowerCase().includes(\"cross-origin\")||console.warn(e)}}),j.destroy(),UC=!1,oC=void 0}}catch(e){console.warn(e)}}WC.addCustomEvent=(e,t)=>{if(!UC)throw new Error(\"please add custom event after start recording\");BC({type:_k.Custom,data:{tag:e,payload:t}})},WC.freezePage=()=>{lC.forEach(e=>e.freeze())},WC.takeFullSnapshot=e=>{if(!UC)throw new Error(\"please take full snapshot after start recording\");DC(e)},WC.mirror=jC;const VC={password:!0,email:!0,tel:!0,text:!0,textarea:!0,number:!0,search:!0,url:!0,date:!0,\"datetime-local\":!0,month:!0,week:!0,time:!0,select:!0,color:!0,range:!0},GC=['input[type=\"password\"]','input[type=\"email\"]','input[type=\"tel\"]','[autocomplete^=\"cc-\"]','[autocomplete=\"one-time-code\"]','[autocomplete=\"current-password\"]','[autocomplete=\"new-password\"]','[autocomplete=\"name\"]','[autocomplete=\"given-name\"]','[autocomplete=\"family-name\"]','[autocomplete=\"street-address\"]','[autocomplete=\"address-line1\"]','[autocomplete=\"address-line2\"]','[autocomplete=\"postal-code\"]','[autocomplete=\"bday\"]','[autocomplete=\"bday-day\"]','[autocomplete=\"bday-month\"]','[autocomplete=\"bday-year\"]','[name*=\"rut\" i]','[name*=\"dni\" i]','[name*=\"ssn\" i]','[name*=\"passport\" i]','[name*=\"cedula\" i]','[name*=\"curp\" i]',\"[data-blar-mask]\"].join(\",\");function KC(e,t){try{if(t&&!t.closest(GC))return e}catch{}return\"********\"}const YC=[\"display\",\"z-index\"];class XC{constructor(){this.open=new Map,this.toggleHandler=null}start(){if(!this.toggleHandler){this.toggleHandler=e=>{const t=e.target;t instanceof HTMLElement&&t.hasAttribute(\"popover\")&&(\"open\"===e.newState?this.mark(t):this.unmark(t))},document.addEventListener(\"toggle\",this.toggleHandler,!0);for(const e of Array.from(document.querySelectorAll(\"[popover]\")))JC(e)&&this.mark(e)}}stop(){this.toggleHandler&&(document.removeEventListener(\"toggle\",this.toggleHandler,!0),this.toggleHandler=null);for(const e of Array.from(this.open.keys()))this.unmark(e)}mark(e){this.open.has(e)||this.open.set(e,YC.map(t=>[t,e.style.getPropertyValue(t),e.style.getPropertyPriority(t)])),e.style.setProperty(\"display\",window.getComputedStyle(e).display,\"important\"),e.style.setProperty(\"z-index\",\"2147483647\",\"important\")}unmark(e){const t=this.open.get(e);if(this.open.delete(e),t&&e.isConnected)for(const[n,i,s]of t)i?e.style.setProperty(n,i,s):e.style.removeProperty(n)}}function JC(e){try{return e.matches(\":popover-open\")}catch{return!1}}class QC{constructor(e){this.getNode=e,this.lastText=new Map}observe(e){if(2===e.type)return this.lastText.clear(),[];if(3!==e.type)return[];const t=e.data;if(5===t.source&&\"number\"==typeof t.id&&\"string\"==typeof t.text)return this.lastText.set(t.id,t.text),[];if(0!==t.source)return[];const n=new Set(this.lastText.keys());for(const{id:e,attributes:i}of t.attributes??[])\"value\"in i&&n.add(e);const i=[];for(const t of n){const n=this.getNode(t);if(\"INPUT\"!==n?.tagName||!(n.type in VC)){this.lastText.delete(t);continue}const s=KC(n.value,n);this.lastText.get(t)!==s&&(this.lastText.set(t,s),i.push({type:3,timestamp:e.timestamp,data:{source:5,id:t,text:s,isChecked:!1}}))}return i}}const ZC=\"support_widget_session_recording_v2\",eE={save(e){const t=[...e.unacked],n=t.map(e=>JSON.stringify(e).length+1);let i=n.reduce((e,t)=>e+t,1);for(;t.length>0&&i>524288;)t.pop(),i-=n[t.length];try{const n={...e,unacked:t,ts:s()};sessionStorage.setItem(ZC,JSON.stringify(n))}catch{}},take(e){let t=null;try{t=sessionStorage.getItem(ZC),null!==t&&sessionStorage.removeItem(ZC)}catch{return null}if(!t)return null;try{const n=JSON.parse(t);if(n?.scopeKey!==e)return null;if(\"string\"!=typeof n.spanUid||0===n.spanUid.length)return null;if(\"number\"!=typeof n.nextSeq)return null;const i=r(n.startedAtMs),o=r(n.ts);return null===i||null===o||s()-o>6e4?null:{...n,startedAtMs:i,ts:o,unacked:Array.isArray(n.unacked)?n.unacked:[],stopPending:!0===n.stopPending}}catch{return null}},clear(){try{sessionStorage.removeItem(ZC)}catch{}}};async function tE(e){if(\"undefined\"==typeof DecompressionStream)return null;try{const t=Uint8Array.from(atob(e),e=>e.charCodeAt(0)),n=(new TextDecoder).decode(await nE(t,new DecompressionStream(\"gzip\"))),i=JSON.parse(n);return Array.isArray(i)?i:null}catch{return null}}async function nE(e,t){const n=t.writable.getWriter();n.write(e).then(()=>n.close()).catch(()=>{});const i=[],s=t.readable.getReader();for(let e=await s.read();!e.done;e=await s.read())i.push(e.value);const r=new Uint8Array(i.reduce((e,t)=>e+t.length,0));let o=0;for(const e of i)r.set(e,o),o+=e.length;return r}const iE=\"rrweb@2.1.1/blar-1\",sE=[\"[data-blar-block]\",\".blar-block\"].join(\",\"),rE=`${sE},.rr-block`;class oE{constructor(e,t=()=>!1){this.getTransport=e,this.isHeldByAnotherTab=t,this.stopRecording=null,this.buffer=[],this.bufferBytes=0,this.flushTimer=null,this.pagehideHandler=null,this.domReadyHandler=null,this.topLayerMirror=new XC,this.inputValues=new QC(e=>WC.mirror.getNode(e)),this.captureLive=!1,this.spanUid=null,this.spanStartedAtMs=0,this.nextSeq=0,this.unacked=new Map,this.packed=new Map,this.liveBuffer=[],this.liveBufferBytes=0,this.liveSeq=0,this.liveTimer=null,this.lastPointerStampMs=0,this.resyncing=!1,this.scopeKey=null,this.pendingSettle=null,this.spanAnnounced=!1,this.spanStopped=!1,this.stopDelivered=!1}get stopOwed(){return this.spanStopped&&(!this.stopDelivered||this.unacked.size>0||this.packed.size>0)}start(e,t){if(this.stopRecording)return;if(this.isHeldByAnotherTab())return;const n=this.takeCarriedSpan(e);this.scopeKey=e,t.resume&&n&&!n.stopPending?this.adopt(n):(n?.stopPending&&this.settle(n),this.spanUid=cs(),this.spanStartedAtMs=s(),this.spanAnnounced=!1,this.nextSeq=0,this.unacked.clear(),this.packed.clear(),this.spanStopped=!1,this.stopDelivered=!1),this.resetLiveSink(),this.announceSpan(),this.persist(),this.topLayerMirror.start();try{this.stopRecording=WC({emit:e=>this.onEvent(e),blockSelector:sE,maskTextSelector:GC,maskAllInputs:!0,maskInputOptions:VC,maskInputFn:KC,recordCanvas:!1,collectFonts:!1,recordAfter:\"DOMContentLoaded\"})??null}catch(e){return Ji(\"session-recording: rrweb failed to start\",e),this.topLayerMirror.stop(),this.stopRecording=null,void this.clearSpan()}this.captureLive=\"loading\"!==document.readyState,this.captureLive||(this.domReadyHandler=()=>{this.captureLive=!0},document.addEventListener(\"DOMContentLoaded\",this.domReadyHandler,{once:!0})),this.flushTimer=setInterval(()=>this.flush(),5e3),this.pagehideHandler=()=>this.onPagehide(),window.addEventListener(\"pagehide\",this.pagehideHandler)}stop(){if(!this.stopRecording)return;try{this.stopRecording()}catch(e){Ji(\"session-recording: rrweb failed to stop\",e)}this.stopRecording=null,this.topLayerMirror.stop(),null!==this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),this.pagehideHandler&&(window.removeEventListener(\"pagehide\",this.pagehideHandler),this.pagehideHandler=null),this.domReadyHandler&&(document.removeEventListener(\"DOMContentLoaded\",this.domReadyHandler),this.domReadyHandler=null),this.captureLive=!1;const e=this.spanUid;null!==e?(this.flushLive(),this.resetLiveSink(),this.flush(),this.spanStopped=!0,this.stopDelivered=!0===this.getTransport()?.sendStop(e),this.stopOwed?this.persist():this.clearSpan()):this.resetLiveSink()}isRecording(){return null!==this.stopRecording}getSpanUid(){return this.spanUid}getScopeKey(){return this.scopeKey}abandonSpan(){this.clearSpan()}rejectSpan(e){this.spanUid===e&&(this.buffer=[],this.bufferBytes=0,this.abandonSpan(),this.stop())}stampActionMarker(e){if(this.stopRecording&&this.captureLive){try{WC.addCustomEvent(\"blar-action\",e)}catch(e){return void Ji(\"session-recording: failed to stamp action marker\",e)}\"end\"===e.phase&&this.flush()}}resync(){if(this.stopRecording&&this.captureLive&&this.getTransport()?.sendLive&&!this.resyncing){this.resyncing=!0;try{WC.takeFullSnapshot()}catch(e){Ji(\"session-recording: failed to take a resync snapshot\",e)}finally{this.resyncing=!1}}}stampPointer(e){if(!this.stopRecording||!this.captureLive)return;const t=s();if(!(t-this.lastPointerStampMs<50)){this.lastPointerStampMs=t;try{WC.addCustomEvent(\"blar-pointer\",e)}catch(e){Ji(\"session-recording: failed to stamp a pointer\",e)}}}stampScrollPositions(e){if(!this.stopRecording||!this.captureLive)return;for(const t of rp(e))t.closest(rE)||this.stampScroll(t,t.scrollLeft,t.scrollTop);const t=e.ownerDocument.defaultView;t&&this.stampScroll(e.ownerDocument,t.scrollX,t.scrollY)}stampScroll(e,t,n){const i=WC.mirror.getId(e);-1!==i&&this.onEvent({type:3,timestamp:s(),data:{source:3,id:i,x:t,y:n}})}resolveNode(e){if(null===e||!this.captureLive)return null;try{const t=WC.mirror.getNode(e);return t instanceof Element?t:null}catch{return null}}acknowledgeChunk(e){this.unacked.delete(e),this.packed.delete(e),this.spanStopped&&(this.stopOwed?this.persist():this.clearSpan())}flushOnConnectionReady(){const e=this.getTransport();if(e&&(this.pendingSettle&&this.settle(this.pendingSettle),null!==this.spanUid)){!this.isRecording()&&this.spanAnnounced||this.announceSpan();for(const[t,n]of[...this.unacked.entries()].sort((e,t)=>e[0]-t[0]))e.sendChunk(this.spanUid,t,n,iE);this.stopOwed&&(this.stopDelivered=!0===e.sendStop(this.spanUid),this.stopOwed?this.persist():this.clearSpan())}}announceSpan(){null!==this.spanUid&&(this.spanAnnounced=!0===this.getTransport()?.sendStart(this.spanUid,this.spanStartedAtMs,iE))}onEvent(e){if(null===this.spanUid||this.spanStopped)return;const t=JSON.stringify(e).length;if(!this.resyncing||2!==e.type&&4!==e.type){this.buffer.push(e),this.bufferBytes+=t,this.appendLive(e,t),this.bufferBytes>=262144&&this.flush();for(const t of this.inputValues.observe(e))this.onEvent(t)}else this.appendLive(e,t)}appendLive(e,t){this.getTransport()?.sendLive&&(this.liveBuffer.push(e),this.liveBufferBytes+=t,2===e.type||this.liveBufferBytes>=65536?this.flushLive():null===this.liveTimer&&(this.liveTimer=setTimeout(()=>this.flushLive(),250)))}flushLive(){if(null!==this.liveTimer&&(clearTimeout(this.liveTimer),this.liveTimer=null),0===this.liveBuffer.length||null===this.spanUid)return;const e=this.liveBuffer;this.liveBuffer=[],this.liveBufferBytes=0,this.getTransport()?.sendLive?.(this.spanUid,this.liveSeq++,e)}flush(){if(0===this.buffer.length||null===this.spanUid)return;const e=this.nextSeq++,t=this.buffer;this.buffer=[],this.bufferBytes=0,this.unacked.set(e,t),this.evictOverflow(),this.pack(e,t),this.spanAnnounced&&this.getTransport()?.sendChunk(this.spanUid,e,t,iE),this.persist()}evictOverflow(){let e=0;for(const t of this.unacked.values())e+=JSON.stringify(t).length;for(;this.unacked.size>20||e>4194304&&this.unacked.size>1;){const t=Math.min(...this.unacked.keys()),n=this.unacked.get(t);e-=n?JSON.stringify(n).length:0,this.unacked.delete(t),this.packed.delete(t),Qi(\"session-recording\",`dropped unacked chunk ${t} (buffer full)`)}}onPagehide(){this.flushLive(),this.flush(),this.persist()}persist(){null!==this.scopeKey&&null!==this.spanUid&&eE.save({scopeKey:this.scopeKey,spanUid:this.spanUid,startedAtMs:this.spanStartedAtMs,nextSeq:this.nextSeq,unacked:this.carriedChunks(),stopPending:this.stopOwed})}carriedChunks(){return[...new Set([...this.unacked.keys(),...this.packed.keys()])].sort((e,t)=>e-t).map(e=>{const t=this.packed.get(e);return void 0===t?{seq:e,events:this.unacked.get(e)}:{seq:e,packed:t}})}async pack(e,t){const n=await async function(e){if(\"undefined\"==typeof CompressionStream)return null;try{const t=await nE((new TextEncoder).encode(JSON.stringify(e)),new CompressionStream(\"gzip\"));let n=\"\";for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));return btoa(n)}catch{return null}}(t);null!==n&&this.unacked.get(e)===t&&(this.packed.set(e,n),this.persist())}async unpack(e,t,n){const i=await tE(n);if(this.spanUid===e&&this.packed.get(t)===n&&!this.unacked.has(t)){if(null===i)return this.packed.delete(t),Qi(\"session-recording\",`dropped carried chunk ${t} (unpack failed)`),void this.persist();this.unacked.set(t,i),this.spanAnnounced&&this.getTransport()?.sendChunk(e,t,i,iE)}}clearSpan(){this.spanUid=null,this.spanStartedAtMs=0,this.spanAnnounced=!1,this.nextSeq=0,this.unacked.clear(),this.packed.clear(),this.spanStopped=!1,this.stopDelivered=!1,eE.clear()}resetLiveSink(){null!==this.liveTimer&&(clearTimeout(this.liveTimer),this.liveTimer=null),this.liveBuffer=[],this.liveBufferBytes=0,this.liveSeq=0,this.lastPointerStampMs=0}takeCarriedSpan(e){const t=eE.take(e);return this.scopeKey!==e||null===this.spanUid?t:{spanUid:this.spanUid,startedAtMs:this.spanStartedAtMs,nextSeq:this.nextSeq,unacked:this.carriedChunks().map(e=>{const t=this.unacked.get(e.seq);return t?{seq:e.seq,events:t}:e}),stopPending:this.stopOwed}}adopt(e){this.spanAnnounced=!1,this.spanUid=e.spanUid,this.spanStartedAtMs=e.startedAtMs,this.nextSeq=e.nextSeq,this.unacked.clear(),this.packed.clear();for(const t of e.unacked)t.events&&this.unacked.set(t.seq,t.events),t.packed&&this.packed.set(t.seq,t.packed),t.packed&&!t.events&&this.unpack(e.spanUid,t.seq,t.packed);this.spanStopped=!1,this.stopDelivered=!1}settle(e){const t=this.getTransport();for(const n of e.unacked)n.events?t?.sendChunk(e.spanUid,n.seq,n.events,iE):n.packed&&this.settlePacked(e,n.seq,n.packed);!0!==t?.sendStop(e.spanUid)?this.pendingSettle=e:this.pendingSettle=null}async settlePacked(e,t,n){const i=await tE(n);if(null===i)return void Qi(\"session-recording\",`dropped carried chunk ${t} (unpack failed)`);const s=this.getTransport();!0!==s?.sendChunk(e.spanUid,t,i,iE)?null===this.pendingSettle?this.pendingSettle={...e,unacked:[{seq:t,events:i}]}:this.pendingSettle.spanUid===e.spanUid?this.pendingSettle.unacked.push({seq:t,events:i}):Qi(\"session-recording\",`dropped carried chunk ${t} (another settle pending)`):s.sendStop(e.spanUid)}}const aE=\"support_widget_agent_active\";class lE{isCancelled(){return this.cancelledRun===this.runGeneration}constructor(e,t,n,i,r,o,a=()=>!1){this.isScreenSharing=a,this.runGeneration=0,this.cancelledRun=null,this.stateMachine=new Ck,this.wsClientGetter=e,this.networkTracker=t,this.sessionRecorder=new oE(()=>e()?.getRecordingTransport()??null,o),this.elementResolver=new bu,this.executionEngine=new Xu(this.elementResolver,r,()=>this.isCancelled(),()=>this.wsClientGetter()?.sendAgentNavigating(),()=>this.wsClientGetter()?.sendJoined(),e=>this.sessionRecorder.stampScrollPositions(e)),this.confirmationUI=new Ep,this.confirmationUI.setOnCancelAgent(n||null),this.domStateAnalyzer=new qo,this.agentModeUI=new zp(n,i),this.confirmationUI.setStatusCard(this.agentModeUI),this.screenshotCapture=new xk;const l=new Tp(this.networkTracker),c=new Zu(this.elementResolver,this.executionEngine,this.confirmationUI,l),d=e=>{this.agentModeUI.showMessageBubble({id:`teaching-${s()}`,text:e,role:\"ai\"})},u=e=>{this.sessionRecorder.stampActionMarker(e)};this.commandHandler=new Zp(c,this.confirmationUI,this.wsClientGetter,d,this.networkTracker,u,()=>this.isCancelled(),()=>this.agentModeUI),this.batchCommandHandler=new eh(c,this.domStateAnalyzer,this.wsClientGetter,this.confirmationUI,d,this.networkTracker,u,()=>this.isCancelled(),()=>this.agentModeUI)}getSessionRecorder(){return this.sessionRecorder}teardownRun(){this.confirmationUI.forceCancel(),this.confirmationUI.unlockHover(),this.confirmationUI.endAgentSession(),this.agentModeUI.hideExecutionOverlay(),this.sessionRecorder.stop(),kd.release(\"agent-run\")}cancelActiveCommand(){this.cancelledRun=this.runGeneration,this.commandHandler.abortRun(),this.batchCommandHandler.abortRun(),this.teardownRun()}isCancelPending(){return this.isCancelled()}enterPending(){return this.stateMachine.transition(\"pending\")}leavePending(){return this.stateMachine.transition(\"idle\")}enterAgentMode(e,t,n=!1){if(!this.stateMachine.transition(\"active\"))return ha(\"agent-flag:enter-rejected\",{phase:this.stateMachine.getPhase()}),!1;this.cancelledRun=null,this.confirmationUI.beginAgentSession();const i=this.wsClientGetter()?.getSessionId();return null==i||this.isScreenSharing()||this.sessionRecorder.start(`session:${i}`,{resume:n}),kd.hold(\"agent-run\"),sessionStorage.setItem(aE,\"1\"),ha(\"agent-flag:set\",{by:\"enterAgentMode\"}),this.agentModeUI.show(e,t),this.agentModeUI.showExecutionOverlay(),!0}startExiting(){return this.stateMachine.transition(\"exiting\")}finishExiting(e){this.teardownRun();const t=()=>{sessionStorage.removeItem(aE),ha(\"agent-flag:cleared\",{by:\"finishExiting\"}),this.stateMachine.transition(\"idle\")};return this.agentModeUI.hide(e).then(t,t)}getPhase(){return this.stateMachine.getPhase()}isAgentModeActive(){return this.stateMachine.isActive()}isEngaged(){return this.stateMachine.isEngaged()}getAgentModeUI(){return this.agentModeUI}getElementResolver(){return this.elementResolver}getExecutionEngine(){return this.executionEngine}getConfirmationUI(){return this.confirmationUI}getCommandHandler(){return this.commandHandler}getScreenshotCaptureManager(){return this.screenshotCapture}getNetworkRequestTracker(){return this.networkTracker}getDomStateAnalyzer(){return this.domStateAnalyzer}getDomState(e){return this.domStateAnalyzer.analyze(e)}getAgentId(e){return function(e){return e.isConnected?Io.get(e)??null:null}(e)}getTextDom(e){return this.textDomAnalyzer||(this.textDomAnalyzer=new ia(this.domStateAnalyzer,this.networkTracker)),this.textDomAnalyzer.analyze(e)}handleCommand(e){this.agentModeUI.clearMessageBubbles(e.teaching_explanation),this.openRun(),this.commandHandler.handle(e)}handleBatch(e){this.agentModeUI.clearMessageBubbles(),this.openRun(),this.batchCommandHandler.handle(e)}openRun(){this.runGeneration++}resolveElement(e){return this.elementResolver.resolve(e)}async executeAction(e,t){return this.executionEngine.execute(e,t)}async undoLastAction(){return this.executionEngine.undo()}destroy(){this.stateMachine.forceIdle(),sessionStorage.removeItem(aE),ha(\"agent-flag:cleared\",{by:\"destroy\"}),this.teardownRun(),this.confirmationUI.destroy(),this.agentModeUI.destroy(),this.executionEngine.clearUndoStack()}}class cE{constructor(e,t,n,i,s,r,o,a,l,c){this.messageHandler=e,this.readReceiptManager=t,this.chatStateManager=n,this.getWsClient=i,this.presenceHandler=s,this.onAiAssignedChange=r,this.onNewTicketHistoryLoaded=o,this.onAgentModeRestore=a,this.onAgentWorkingStopped=l,this.onSessionStatusReceived=c}handle(e){const{messages:t,lastReadSeq:n,ai_assigned:i,first_response_at:s,agent_mode_active:r,agent_mode_intent:o,agent_status:a,sessionStatus:l}=e,c=!0===e.was_escalated;if(l&&this.onSessionStatusReceived&&this.onSessionStatusReceived(l,{hasSupportHandoff:c}),void 0!==i&&this.onAiAssignedChange&&this.onAiAssignedChange(i),\"waiting\"===a||\"cancelled\"===a||\"idle\"===a?this.onAgentWorkingStopped?.():r&&this.onAgentModeRestore&&this.onAgentModeRestore(o||void 0),void 0!==n){n>this.readReceiptManager.getLastReadSeq()&&this.readReceiptManager.setLastReadSeq(n)}this.messageHandler.handleMessageHistory(t,this.readReceiptManager.getLastSeenSeq());const d=t??[],u=d.length>0&&d.every(e=>\"contact\"===e.role),p=d.filter(e=>\"event\"!==e.role);if(p.length>0){const e=Math.max(...p.map(e=>e.seq??0)),t=this.readReceiptManager.getLastSeenSeq();this.readReceiptManager.setLastSeenSeq(Math.max(t,e));const n=this.getWsClient();n?.updateConfig({lastSeenSeq:this.readReceiptManager.getLastSeenSeq()}),n?.sendAck(this.readReceiptManager.getLastSeenSeq()),this.readReceiptManager.updateUnreadIndicator()}const h=this.presenceHandler.getActiveAgents().length>0;u&&null===s&&!h&&this.onNewTicketHistoryLoaded&&this.onNewTicketHistoryLoaded(!0),this.chatStateManager.isOpened()&&this.chatStateManager.shouldScrollOnOpen()&&this.readReceiptManager.scheduleReadTimer()}}class dE{constructor(e){this.messageHandler=e}handle(e){this.messageHandler.appendToStreamingMessage(e.chunk,e.step)}}class uE{constructor(e,t,n,i,s,r){this.messageHandler=e,this.readReceiptManager=t,this.chatStateManager=n,this.getWsClient=i,this.getCurrentView=s,this.onNewMessage=r}handleDuplicateMessage(e){const t=e.idempotency_key;if(!t)return!1;if(!this.messageHandler.hasMessageWithIdempotencyKey(t))return!1;const n=this.getWsClient();return n&&n.acknowledgeMessage(t),this.messageHandler.removePendingIndicator(t,e.attachments,e.id),e.metadata?.resolved&&e.metadata?.resolved_decision&&this.messageHandler.resolveSystemMessage(t,e.metadata.resolved_decision),e.seq&&e.seq>this.readReceiptManager.getLastReadSeq()&&this.readReceiptManager.sendRead(e.seq),!0}handle(e){if(!e)return;if(e.is_draft)return;if(e.idempotency_key&&this.handleDuplicateMessage(e))return;if(e.is_ephemeral){const t=e.metadata;if(\"recording\"===t?.type)return;if(\"screenshot\"===t?.type&&e.attachments?.length)return void this.messageHandler.addScreenshotMessage(e.attachments[0].id,{action_type:String(t.action_type??\"\"),element_description:String(t.element_description??\"\"),url:String(t.url??\"\"),body:e.body},e.idempotency_key,e.seq);if(\"screenshot\"===t?.type&&(t.action_type||e.body))return void this.messageHandler.addAgentActionStep({action_type:String(t.action_type??\"\"),element_description:String(t.element_description??\"\"),url:String(t.url??\"\"),body:e.body},e.idempotency_key,e.seq)}if(\"event\"===e.role)return;if(\"system\"===e.role&&!0===e.metadata?.resolved){const t=e.metadata?.suggestion_type;if(\"close_ticket\"===t||\"human_assistance\"===t)return}if(!(e.body||\"system\"===e.role||e.attachments&&0!==e.attachments.length))return;\"ai\"===e.role&&this.messageHandler.finalizeStreamingMessage();const t=\"contact\"!==e.role;this.messageHandler.addMessage({id:e.id,text:e.body||\"\",isAgent:t,idempotencyKey:e.idempotency_key,seq:e.seq,role:e.role,replyTo:Bc(e.reply_to),metadata:e.metadata,tour:e.tour,attachments:e.attachments,author_user_name:e.author_user_name,author_user_avatar_url:e.author_user_avatar_url,ai_icon_url:e.ai_icon_url,edited_at:e.edited_at,bubble_message:e.bubble_message});const n=\"contact\"!==e.role,i=this.chatStateManager.isOpened()&&\"chat\"===this.getCurrentView()&&!document.hidden;if(n&&i&&this.readReceiptManager.markMessagesAsRead(),e.seq){const t=this.readReceiptManager.getLastSeenSeq();this.readReceiptManager.setLastSeenSeq(Math.max(t,e.seq));const n=this.getWsClient();n?.updateConfig({lastSeenSeq:this.readReceiptManager.getLastSeenSeq()}),n?.sendAck(this.readReceiptManager.getLastSeenSeq())}!n||this.chatStateManager.isOpened()&&!document.hidden||this.onNewMessage?.()}}class pE{constructor(e,t,n,i){this.messageHandler=e,this.chatStateManager=t,this.tourManager=n,this.onDisconnect=i}handle(e){const{suggestion_type:t,decision:n}=e;\"close_ticket\"!==t&&\"human_assistance\"!==t||this.messageHandler.removeCurrentSystemAction(),\"close_ticket\"===t?\"accept\"===n&&(this.tourManager.stopActiveTour(),this.chatStateManager.showClosedState()):\"csat_survey\"===t&&this.onDisconnect?.()}}class hE{constructor(e,t){this.onAiAssignedChange=e,this.onConversationStatusChange=t}handle(e){const t=e.data?.status,n=e.data?.ai_assigned,i=e.data?.was_escalated??!1;void 0!==n&&this.onAiAssignedChange?.(n),t&&this.onConversationStatusChange?.(t,i)}}class gE{constructor(e,t){this.uiManager=e,this.onAgentJoined=t,this.activeAgents=[]}handle(e){switch(e.type){case\"user_joined\":e.user&&\"agent\"===e.user.role&&this.handleUserJoined(e.user);break;case\"user_left\":void 0!==e.user_id&&this.handleUserLeft(e.user_id);break;case\"presence_update\":e.active_users&&this.handlePresenceUpdate(e.active_users)}}handleUserJoined(e){if(\"agent\"!==e.role)return;this.activeAgents.find(t=>t.id===e.id)||(this.activeAgents.push(e),this.updateUI(),this.onAgentJoined&&this.onAgentJoined())}handleUserLeft(e){const t=this.activeAgents.length;this.activeAgents=this.activeAgents.filter(t=>t.id!==e),this.activeAgents.length!==t&&this.updateUI()}handlePresenceUpdate(e){this.activeAgents=e.filter(e=>\"agent\"===e.role),this.updateUI(),this.activeAgents.length>0&&this.onAgentJoined&&this.onAgentJoined()}updateUI(){this.uiManager.updatePresenceIndicator(this.activeAgents)}getActiveAgents(){return[...this.activeAgents]}clear(){this.activeAgents=[],this.updateUI()}}class mE{constructor(){this.typingAgents=[],this.typingBubbleElement=null,this.messagesContainer=null,this.translations=Na()}setMessagesContainer(e){this.messagesContainer=e}handle(e){switch(e.type){case\"user_typing\":e.user&&\"agent\"===e.user.role&&this.handleUserTyping(e.user);break;case\"user_stopped_typing\":void 0!==e.user_id&&this.handleUserStoppedTyping(e.user_id)}}handleUserTyping(e){if(\"agent\"!==e.role)return;this.typingAgents.find(t=>t.id===e.id)||(this.typingAgents.push(e),this.updateTypingIndicator())}handleUserStoppedTyping(e){const t=this.typingAgents.length;this.typingAgents=this.typingAgents.filter(t=>t.id!==e),this.typingAgents.length!==t&&this.updateTypingIndicator()}updateTypingIndicator(){if(!this.messagesContainer)return;if(0===this.typingAgents.length)return void this.removeTypingIndicator();const e=this.getAgentNamesText();this.typingBubbleElement?this.updateTypingIndicatorContent(e):this.createTypingIndicator(e,this.messagesContainer),this.messagesContainer.scrollTop=this.messagesContainer.scrollHeight}getAgentNamesText(){const e=this.typingAgents;return 1===e.length?e[0].name:2===e.length?`${e[0].name} ${this.translations.messages.and} ${e[1].name}`:`${e[0].name} ${this.translations.messages.and} ${e.length-1} ${this.translations.messages.others}`}createTypingIndicator(e,t){this.typingBubbleElement=document.createElement(\"div\"),this.typingBubbleElement.id=\"support-typing-indicator\",this.typingBubbleElement.className=\"support-message agent typing-indicator\";const n=this.typingAgents[0],i=n.avatar_url?`<img src=\"${n.avatar_url}\" alt=\"${n.name}\" class=\"support-avatar-image\" />`:'<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n          <path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\"/>\\n        </svg>';this.typingBubbleElement.innerHTML=`\\n      <div class=\"support-avatar\">\\n        ${i}\\n      </div>\\n      <div class=\"support-message-content\">\\n        <div class=\"support-message-author\">${e}</div>\\n        <div class=\"support-typing-bubble\">\\n          <span class=\"support-typing-dot\"></span>\\n          <span class=\"support-typing-dot\"></span>\\n          <span class=\"support-typing-dot\"></span>\\n        </div>\\n      </div>\\n    `,t.appendChild(this.typingBubbleElement)}updateTypingIndicatorContent(e){if(!this.typingBubbleElement)return;const t=this.typingBubbleElement.querySelector(\".support-message-author\");t&&(t.textContent=e);const n=this.typingAgents[0],i=this.typingBubbleElement.querySelector(\".support-avatar\");if(i&&n){const e=n.avatar_url?`<img src=\"${n.avatar_url}\" alt=\"${n.name}\" class=\"support-avatar-image\" />`:'<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n            <path d=\"M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z\"/>\\n          </svg>';i.innerHTML=e}}removeTypingIndicator(){this.typingBubbleElement&&(os(this.typingBubbleElement),this.typingBubbleElement=null)}getTypingAgents(){return[...this.typingAgents]}clear(){this.typingAgents=[],this.removeTypingIndicator()}}class fE{constructor(e){this.messageManager=e}handle(e){\"number\"==typeof e.seq&&this.messageManager.removeMessageBySeq(e.seq)}}class bE{constructor(e){this.messageManager=e}handle(e){\"number\"==typeof e.seq&&\"string\"==typeof e.body&&this.messageManager.updateMessageBodyBySeq(e.seq,e.body)}}class yE{constructor(e,t){this.getWsClient=e,this.getAgentModeUI=t,this.analyzer=new qo}handle(e){const{command_id:t,options:n}=e,i=this.getAgentModeUI?.(),s=Na();i?.setStatus(s.agent.scanningPage);try{const e=this.analyzer.analyze(n);i?.setStatus(s.agent.thinking),this.sendResponse(t,e)}catch(e){Ji(\"[DOMStateHandler] Error analyzing DOM state\",e),i?.setStatus(s.agent.errorOccurred);const n=this.getWsClient();n?.sendSDKError(t,e instanceof Error?e.message:\"Unknown error\")}}getAnalyzer(){return this.analyzer}sendResponse(e,t){const n={type:\"sdk_response\",command_id:e,response_type:\"dom_state_response\",data:t},i=this.getWsClient();i?i.sendSDKResponse(n):Ji(\"[DOMStateHandler] No WebSocket client available\")}}class vE{constructor(){this.overlay=null,this.styleElement=null,this.currentResolve=null,this.injectStyles()}injectStyles(){document.getElementById(\"agent-question-styles\")||(this.styleElement=document.createElement(\"style\"),this.styleElement.id=\"agent-question-styles\",this.styleElement.textContent=\"\\n  .agent-question-overlay {\\n    position: fixed;\\n    top: 0;\\n    left: 0;\\n    width: 100%;\\n    height: 100%;\\n    background: rgba(0, 0, 0, 0.5);\\n    z-index: 999998;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n  }\\n\\n  .agent-question-card {\\n    background: white;\\n    border-radius: 12px;\\n    padding: 20px;\\n    max-width: 500px;\\n    width: 90%;\\n    max-height: 80vh;\\n    overflow-y: auto;\\n    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n  }\\n\\n  .agent-question-text {\\n    font-size: 14px;\\n    color: #1f2937;\\n    line-height: 1.6;\\n    margin: 0 0 16px 0;\\n    white-space: pre-wrap;\\n  }\\n\\n  .agent-question-input {\\n    width: 100%;\\n    padding: 12px;\\n    border: 1px solid #d1d5db;\\n    border-radius: 8px;\\n    font-size: 14px;\\n    font-family: inherit;\\n    resize: vertical;\\n    min-height: 100px;\\n    box-sizing: border-box;\\n  }\\n\\n  .agent-question-input:focus {\\n    outline: none;\\n    border-color: #3b82f6;\\n  }\\n\\n  .agent-question-buttons {\\n    display: flex;\\n    gap: 10px;\\n    justify-content: flex-end;\\n    margin-top: 16px;\\n  }\\n\\n  .agent-question-btn {\\n    padding: 8px 16px;\\n    border-radius: 6px;\\n    border: none;\\n    font-size: 14px;\\n    cursor: pointer;\\n  }\\n\\n  .agent-question-btn-cancel {\\n    background: #e5e7eb;\\n    color: #374151;\\n  }\\n\\n  .agent-question-btn-submit {\\n    background: #3b82f6;\\n    color: white;\\n  }\\n\\n  .agent-question-btn-submit:disabled {\\n    background: #93c5fd;\\n    cursor: not-allowed;\\n  }\\n\",document.head.appendChild(this.styleElement))}showQuestion(e){return new Promise(t=>{this.currentResolve=t,this.createUI(e)})}createUI(e){const{question:t}=e,n=Na();this.overlay=document.createElement(\"div\"),this.overlay.className=\"agent-question-overlay\",this.overlay.innerHTML=`\\n      <div class=\"agent-question-card\">\\n        <p class=\"agent-question-text\">${this.escapeHtml(t)}</p>\\n        <textarea class=\"agent-question-input\" placeholder=\"${n.agent.answerPlaceholder}\"></textarea>\\n        <div class=\"agent-question-buttons\">\\n          <button class=\"agent-question-btn agent-question-btn-cancel\">${n.agent.confirmCancel}</button>\\n          <button class=\"agent-question-btn agent-question-btn-submit\" disabled>${n.systemActions.interactive.submit}</button>\\n        </div>\\n      </div>\\n    `,document.body.appendChild(this.overlay),this.bindEvents()}bindEvents(){if(!this.overlay)return;const e=this.overlay.querySelector(\".agent-question-input\"),t=this.overlay.querySelector(\".agent-question-btn-submit\"),n=this.overlay.querySelector(\".agent-question-btn-cancel\");e.addEventListener(\"input\",()=>{t.disabled=!e.value.trim()}),t.addEventListener(\"click\",()=>{e.value.trim()&&(this.cleanup(),this.currentResolve?.({answer:e.value.trim(),isFreeText:!0}))}),n?.addEventListener(\"click\",()=>{this.cleanup(),this.currentResolve?.(null)}),this.overlay.addEventListener(\"click\",e=>{e.target===this.overlay&&(this.cleanup(),this.currentResolve?.(null))}),e.focus()}escapeHtml(e){const t=document.createElement(\"div\");return t.textContent=e,t.innerHTML}cleanup(){this.overlay&&(os(this.overlay),this.overlay=null),this.currentResolve=null}destroy(){this.cleanup(),this.styleElement&&(os(this.styleElement),this.styleElement=null)}}class wE{constructor(e){this.getWsClient=e,this.questionUI=new vE}handle(e){e.command_id?this.handleAsync(e).catch(t=>{Ji(\"[ClarifyingQuestionHandler] Error handling question\",t),e.command_id&&this.sendResponse(e.command_id,{answer:\"\",is_free_text:!1})}):Ji(\"[ClarifyingQuestionHandler] Missing command_id in clarifying question\")}async handleAsync(e){const{command_id:t,question:n,options:i=[],allow_free_text:s}=e;if(!n)return void Ji(\"[ClarifyingQuestionHandler] Missing question\");const r=void 0!==s?s:0===i.length,o=await this.questionUI.showQuestion({question:n,options:i,allowFreeText:r});null!==o?this.sendResponse(t,{answer:o.answer,selected_option_index:o.selectedOptionIndex,is_free_text:o.isFreeText}):this.sendResponse(t,{answer:\"\",is_free_text:!1})}sendResponse(e,t){const n={type:\"sdk_response\",command_id:e,response_type:\"clarifying_question_response\",data:t},i=this.getWsClient();i?i.sendSDKResponse(n):Ji(\"[ClarifyingQuestionHandler] No WebSocket client available\")}getQuestionUI(){return this.questionUI}destroy(){this.questionUI.destroy()}}const xE=\"Screenshot unavailable: this page was too heavy to capture in time. The page itself is responding normally — use read_page_content or dom_state instead, both are accurate here. Do NOT tell the user you cannot see their screen, and do NOT hand the task back to them.\";class kE{constructor(e,t,n,i){this.getWsClient=e,this.screenshotCapture=t,this.getAgentModeUI=n,this.networkTracker=i}async handle(e){const{command_id:r,options:o={}}=e;if(t())return void this.getWsClient()?.sendSDKError(r,\"Screenshot unavailable: the user has switched to another tab, and browsers suspend rendering there, so the page cannot be captured. Do not retry — use read_page_content or dom_state instead; both are accurate while the tab is hidden. Screenshots resume when the user comes back.\",\"TAB_HIDDEN\");const a=this.getAgentModeUI?.(),l=Na();a?.setStatus(l.agent.capturingScreenshot||\"Capturing screenshot...\");try{const e=window.devicePixelRatio||1,t={x:window.scrollX,y:window.scrollY},c=performance.now(),d=o.format||\"jpeg\",u=o.quality||.8,p=c+12e3,h=()=>{if(performance.now()>p)throw new n(xE)},g=await i(async()=>{const e=await this.screenshotCapture.captureScreenshot();h();const t=await this.screenshotCapture.snapshotToCanvas(e,d,u);h();const n=this.screenshotCapture.resizeIfNeeded(t,o),i=\"png\"===d?\"image/png\":\"image/jpeg\";return n.toDataURL(i,u)},12e3,xE),m=performance.now()-c;a?.setStatus(l.agent.thinking);const f=this.networkTracker?.getPendingRequests();this.sendResponse(r,{success:!0,image:g,format:d,url:window.location.href,screenshot_metadata:{url:window.location.href},timestamp:s(),devicePixelRatio:e,scrollPosition:t,capture_duration_ms:m,sent_at:s(),...f&&f.length>0&&{pendingRequests:f.join(\", \")}})}catch(e){Ji(`[ScreenshotHandler] Error capturing screenshot${rk(e)}`,e),a?.setStatus(l.agent.errorOccurred);let t=\"CAPTURE_FAILED\",i=e instanceof Error?e.message:\"Screenshot capture failed\";e instanceof n?(t=\"TIMEOUT\",i=xE):e instanceof Error&&(e.message.includes(\"cross-origin\")||e.message.includes(\"CORS\"))&&(t=\"CROSS_ORIGIN_ERROR\"),this.getWsClient()?.sendSDKError(r,i,t)}}sendResponse(e,t){const n={type:\"sdk_response\",command_id:e,response_type:\"screenshot_response\",data:t},i=this.getWsClient();i?i.sendSDKResponse(n):Ji(\"[ScreenshotHandler] No WebSocket client available\")}}class SE{constructor(e,t){this.getWsClient=e,this.analyzer=t}handle(e){const{command_id:t,agent_ids:n,selectors:i,context_options:s}=e,r=s?.parent_levels??3,o=s?.max_html_length??1500,a=!0===s?.include_parent_html,l=!1!==s?.include_siblings,c=[];for(const e of n??[]){const t=Oo(e);t?c.push(this.buildItem(t,{agent_id:e},{includeSiblings:l,includeParentHtml:a,parentLevels:r,maxHtmlLength:o})):c.push({agent_id:e,found:!1})}for(const e of i??[])try{const t=document.querySelectorAll(e);if(0===t.length){c.push({selector:e,found:!1});continue}t.forEach((n,i)=>{const s=n;c.push(this.buildItem(s,{selector:e,match_index:i,total_matches:t.length},{includeSiblings:l,includeParentHtml:a,parentLevels:r,maxHtmlLength:o}))})}catch{c.push({selector:e,found:!1})}this.sendResponse(t,{elements:c})}buildItem(e,t,n){const i=this.analyzer.getHTMLContext(e),s=this.analyzer.getElementText(e)||this.analyzer.extractIconLabel(e)||\"\",r={...t,found:!0,tag_name:e.tagName.toLowerCase(),visible:this.analyzer.isVisible(e),html:i};return s&&(r.text_content=s.substring(0,300)),r.placeholder=hr(e),r.nearest_label=Vs(e),n.includeSiblings&&(r.sibling_text=Gs(e)),n.includeParentHtml&&(r.parent_html=Ws(e,n.parentLevels,n.maxHtmlLength)),r}sendResponse(e,t){const n={type:\"sdk_response\",command_id:e,response_type:\"element_context_response\",data:t},i=this.getWsClient();i?i.sendSDKResponse(n):Ji(\"[ElementContextHandler] No WebSocket client available\")}}class CE{constructor(e,t,n,i){this.getWsClient=e,this.getAgentModeUI=t,this.analyzer=new ia(n||new qo,i)}handle(e){const{command_id:t,options:n}=e,i=this.getAgentModeUI?.(),s=Na();i?.setStatus(s.agent.scanningPage);try{const e=this.analyzer.analyze(n);i?.setStatus(s.agent.thinking),this.sendResponse(t,e)}catch(e){Ji(\"[TextDOMHandler] Error analyzing text DOM\",e),i?.setStatus(s.agent.errorOccurred);const n=this.getWsClient();n?.sendSDKError(t,e instanceof Error?e.message:\"Unknown error\")}}getAnalyzer(){return this.analyzer}sendResponse(e,t){const n={type:\"sdk_response\",command_id:e,response_type:\"text_dom_response\",data:t},i=this.getWsClient();i?i.sendSDKResponse(n):Ji(\"[TextDOMHandler] No WebSocket client available\")}}class EE{constructor(e,t){this.getWsClient=e,this.executor=t}async handle(e){const t=await this.executor.execute(e);this.sendResult(t)}sendResult(e){const t=this.getWsClient();t?t.sendAgentActionResult(e):Ji(`[AgentActionHandler] No WebSocket client — dropping result for ${e.api_call_id}`)}}class ME{constructor(e,t,n=()=>window.location.reload()){this.getWsClient=e,this.isChatOpen=t,this.reload=n}async handle(e){const t=this.getWsClient();if(!t)return;const n=t.getSessionId();if(null===n)return void t.sendSDKError(e.command_id,\"reload_page needs a session socket\",\"no_session\");t.sendAgentNavigating(),function(e){try{sessionStorage.setItem(_s,JSON.stringify({...e,expiresAt:s()+3e4}))}catch{}}({sessionId:n,chatOpen:this.isChatOpen()});const i={type:\"sdk_response\",command_id:e.command_id,response_type:\"reload_page_response\",data:{success:!0}};t.sendSDKResponse(i),await t.waitForSendBuffer(1e3);const r=new Promise(e=>{let t=!1;window.addEventListener(\"pagehide\",()=>{t=!0},{once:!0}),window.addEventListener(\"beforeunload\",n=>{setTimeout(()=>{!function(e){const{returnValue:t}=e;return e.defaultPrevented||\"string\"==typeof t&&\"\"!==t}(n)?e(!1):setTimeout(()=>e(!t),3e3)},0)},{once:!0})});this.reload(),await r&&(!function(){try{sessionStorage.removeItem(_s)}catch{}}(),this.getWsClient()?.sendSDKError(e.command_id,\"The page did not reload: it asked the user to confirm leaving and they stayed, so it still shows the old data\",\"reload_cancelled\"),this.getWsClient()?.sendJoined())}}class AE{constructor(){this.tokenCallbacks=new Map,this.refreshTokenCallback=void 0}registerTokenCallback(e,t){this.tokenCallbacks.set(e,t)}unregisterTokenCallback(e){this.tokenCallbacks.delete(e)}getTokenCallback(e){return this.tokenCallbacks.get(e)}setRefreshToken(e){this.refreshTokenCallback=e}getRefreshToken(){return this.refreshTokenCallback}}const _E=new Set([\"__proto__\",\"constructor\",\"prototype\"]);class TE{constructor(e,t=new AE,n=()=>null,i=()=>null){this.getBridge=e,this.callbacks=t,this.getObservedHeader=n,this.getAttributionId=i}async execute(e){const t=s(),n=this.getBridge();if(!n)return this.toResult(e.api_call_id,{status:0,responseBody:null,error:{code:\"no_descriptor\",message:\"No api_bridge descriptor configured for this session\"}},!1,t);const i=this.resolveBaseUrl(n,e);if(null===i)return this.toResult(e.api_call_id,{status:0,responseBody:null,error:{code:\"invalid_base_url\",message:`${e.base_url} is not an allowed API host`}},!1,t);const r=await this.resolveAuth(n,i);if(r.error)return this.toResult(e.api_call_id,{status:0,responseBody:null,error:r.error},!1,t);let o=await this.fetchOnce(n,i,e,r.headers),a=!1;if(401===o.status&&this.callbacks.getRefreshToken()){a=!0;const t=await this.runRefreshAndReauth(n,i);t.error||(o=await this.fetchOnce(n,i,e,t.headers))}return this.toResult(e.api_call_id,o,a,t)}async runRefreshAndReauth(e,t){const n=this.callbacks.getRefreshToken();if(!n)return{headers:{}};try{await n()}catch{}return this.resolveAuth(e,t)}async resolveAuth(e,t){const{descriptor:n}=e,i=Object.create(null);if(n.staticHeaders)for(const[e,t]of Object.entries(n.staticHeaders))_E.has(e)||(i[e]=t);if(n.attributionEnabled){const e=this.getAttributionId();e&&(i[\"X-Blar-Agent\"]=e)}if(\"bearer\"===n.authMode){const e=n.authHeader??\"Authorization\",s=n.authScheme??\"Bearer\",r=e=>s?`${s} ${e}`:e;if(n.tokenSource){const t=await this.readTokenSource(n.tokenSource);if(t.error)return{headers:i,error:t.error};if(t.value)return i[e]=r(t.value),this.applyCsrf(n,i)}const o=this.getObservedHeader(t,e);return o?(i[e]=o,this.applyCsrf(n,i)):\"callback\"===n.tokenSource?.kind?{headers:i,error:{code:\"no_callback\",message:`No token callback registered for id \"${n.tokenSource.id}\" and no observed \"${e}\" header to fall back on`}}:{headers:i,error:{code:\"no_auth\",message:`Could not resolve a token for the \"${e}\" header from the configured source or passive observation`}}}return this.applyCsrf(n,i)}async applyCsrf(e,t){if(e.csrfSource&&e.csrfHeader){const n=await this.readTokenSource(e.csrfSource);if(n.error)return{headers:t,error:n.error};n.value&&(t[e.csrfHeader]=n.value)}return{headers:t}}async readTokenSource(e){switch(e.kind){case\"localStorage\":return{value:this.extractStorageToken(this.safeReadStorage(window.localStorage,e.key),e.path)};case\"sessionStorage\":return{value:this.extractStorageToken(this.safeReadStorage(window.sessionStorage,e.key),e.path)};case\"cookie\":return{value:this.readCookie(e.name)};case\"meta\":return{value:this.readMeta(e.name)};case\"callback\":{const t=this.callbacks.getTokenCallback(e.id);if(!t)return{value:null};try{return{value:await t()??null}}catch(t){return{value:null,error:{code:\"no_auth\",message:`Token callback \"${e.id}\" threw: ${this.describeError(t)}`}}}}}}safeReadStorage(e,t){try{return e.getItem(t)}catch{return null}}extractStorageToken(e,t){if(null===e)return null;if(void 0===t)return e;let n;try{n=JSON.parse(e)}catch{return null}for(const e of t.split(\".\")){if(null===n||\"object\"!=typeof n)return null;n=n[e]}return\"string\"==typeof n?n:null}readCookie(e){const t=\"undefined\"!=typeof document?document.cookie:\"\";if(!t)return null;const n=`${e}=`;for(const e of t.split(\";\")){const t=e.trimStart();if(t.startsWith(n))return decodeURIComponent(t.slice(n.length))}return null}readMeta(e){if(\"undefined\"==typeof document)return null;const t=e.replace(/\"/g,'\\\\\"'),n=document.querySelector(`meta[name=\"${t}\"]`),i=n?.getAttribute(\"content\");return i&&i.length>0?i:null}resolveBaseUrl(e,t){if(void 0===t.base_url)return od(e.apiBaseUrl);const n=od(t.base_url);return e.allowedBaseUrls.includes(n)?n:null}buildUrl(e,t){let n=`${e}${t.path.startsWith(\"/\")?t.path:`/${t.path}`}`;const i=this.serializeQuery(t.query_params);return i&&(n+=n.includes(\"?\")?`&${i}`:`?${i}`),n}serializeQuery(e){if(!e)return\"\";const t=new URLSearchParams;for(const[n,i]of Object.entries(e))null!==i&&t.append(n,String(i));return t.toString()}async fetchOnce(e,t,n,i){const s=this.buildUrl(t,n),r={...i},o={method:n.method,headers:r,credentials:\"cookie\"===e.descriptor.authMode?\"include\":\"omit\"};if(\"GET\"!==n.method&&void 0!==n.body){const t=function(e,t){const n=\"form\"===t;if(\"string\"==typeof e)return{body:e,contentType:n?\"application/x-www-form-urlencoded\":\"application/json\"};if(n){const t=new URLSearchParams;if(null!==e&&\"object\"==typeof e&&!Array.isArray(e))for(const[n,i]of Object.entries(e))null==i?t.append(n,\"\"):\"string\"==typeof i||\"number\"==typeof i||\"boolean\"==typeof i?t.append(n,String(i)):t.append(n,JSON.stringify(i));return{body:t.toString(),contentType:\"application/x-www-form-urlencoded\"}}return{body:JSON.stringify(e),contentType:\"application/json\"}}(n.body,e.descriptor.bodyEncoding);o.body=t.body,\"Content-Type\"in r||\"content-type\"in r||(r[\"Content-Type\"]=t.contentType)}o.headers=r;const a=new AbortController;o.signal=a.signal;const l=n.timeout_ms&&n.timeout_ms>0?n.timeout_ms:3e4;let c=!1;const d=setTimeout(()=>{c=!0,a.abort()},l);let u;try{u=await fetch(s,o)}catch(e){return clearTimeout(d),c?{status:0,responseBody:null,error:{code:\"timeout\",message:`Request exceeded ${l}ms`}}:{status:0,responseBody:null,error:{code:\"transport\",message:`Network error: ${this.describeError(e)}`}}}return clearTimeout(d),this.readResponse(u)}async readResponse(e){const{status:t}=e,n=(e.headers.get(\"content-type\")||\"\").toLowerCase().includes(\"application/json\");let i=\"\";try{i=await e.text()}catch(e){return{status:t,responseBody:null,error:{code:\"transport\",message:`Failed to read response body: ${this.describeError(e)}`}}}let s=null;if(i.length>0)if(n)try{s=JSON.parse(i)}catch(e){return{status:t,responseBody:null,error:{code:\"invalid_response\",message:`Response declared JSON but failed to parse: ${this.describeError(e)}`}}}else s=i;return t<200||t>=300?{status:t,responseBody:s,error:{code:\"http\",message:`Customer API returned HTTP ${t}`}}:{status:t,responseBody:s,error:null}}toResult(e,t,n,i){return{type:\"agent_action_result\",api_call_id:e,status:t.status,response_body:t.responseBody,duration_ms:s()-i,error:t.error,retried:n}}describeError(e){return e instanceof Error?e.message:\"string\"==typeof e?e:\"unknown\"}}class IE{constructor(e,t){this.onChange=t,this.tabId=ya(),this.beat=null,this.expiry=null,this.boundStorage=null,this.lastNotified=!1,this.key=`blar_agent_run:${e}`,t&&(this.boundStorage=e=>{e.key===this.key&&this.notify()},window.addEventListener(\"storage\",this.boundStorage),this.notify())}isRunningElsewhere(){const e=this.read();return!!e&&e.tabId!==this.tabId&&s()-e.updatedAt<1e4}start(e){this.stamp(),this.beat||(this.beat=setInterval(()=>{e()?this.stamp():this.stop()},3e3))}stop(){this.beat&&(clearInterval(this.beat),this.beat=null),this.read()?.tabId===this.tabId&&this.clearEntry()}markSettled(){this.read()&&this.clearEntry(),this.notify()}destroy(){this.stop(),this.expiry&&(clearTimeout(this.expiry),this.expiry=null),this.boundStorage&&(window.removeEventListener(\"storage\",this.boundStorage),this.boundStorage=null)}read(){try{const e=localStorage.getItem(this.key);if(!e)return null;const t=JSON.parse(e),n=r(t?.updatedAt);return\"string\"==typeof t?.tabId&&null!==n?{...t,updatedAt:n}:null}catch{return null}}stamp(){try{localStorage.setItem(this.key,JSON.stringify({tabId:this.tabId,updatedAt:s()}))}catch{}}clearEntry(){try{localStorage.removeItem(this.key)}catch{}}notify(){this.expiry&&(clearTimeout(this.expiry),this.expiry=null);const e=this.isRunningElsewhere();e&&(this.expiry=setTimeout(()=>this.notify(),1e4)),e!==this.lastNotified&&(this.lastNotified=e,this.onChange?.(e))}}const LE=new Set([\"goal_nudge\",\"in_app_continuation\"]);class RE{constructor(){this.pending=null}handleRenderedMetadata(e,t){const n=t||e.idempotency_key,i=e.suggestion_type;!0!==e.resolved?n&&i&&!LE.has(i)&&(this.pending={idempotencyKey:n,suggestionType:i}):n&&this.pending?.idempotencyKey===n&&(this.pending=null)}take(){const e=this.pending;return this.pending=null,e}clear(e){void 0!==e&&this.pending?.idempotencyKey!==e||(this.pending=null)}}class $E{constructor(e,t,n,i,s,r,o,a,l,c,d,u,p,h,g,m,f,b,y,v,w,x,k,S,C,E,M,A,_,T,I,L,R,$,N){this.config=e,this.networkTracker=t,this.authHeaderObserver=n,this.sessionManager=i,this.messageHandler=s,this.readReceiptManager=r,this.chatStateManager=o,this.uiManager=a,this.tourManager=l,this.getCurrentView=c,this.onNewTicketHistoryLoaded=u,this.onAgentJoined=p,this.onNewMessageSound=h,this.onReattachInputListeners=g,this.onSessionEscalated=m,this.onSessionStatusReceived=f,this.onAiAssignedChange=b,this.onWebSocketError=y,this.onSessionClosedExternal=v,this.onConnectionStateChanged=w,this.onOnboardingStepCompleted=k,this.onPlanSaved=S,this.onConversationStatusChange=C,this.onSessionBubbleReceived=E,this.onVoiceCallInvite=M,this.onVoiceCallStatus=A,this.onScreenShareInvite=_,this.onScreenShareStatus=T,this.onLiveCallSnapshot=I,this.onActivationForm=L,this.onFeatureCheckIn=R,this.onFeatureCheckInReminder=$,this.onExecutiveAvailability=N,this.wsClient=null,this.currentConversation=null,this.tabCoordinator=null,this.agentRunRegistry=null,this.serverOwnerTabId=null,this.serverAgentRunning=!1,this.onAgentRunElsewhereChange=null,this.onActivationSessionStarted=null,this.onActivationSessionClosed=null,this.onActivationSessionReplaced=null,this.onAgentRunComplete=null,this.isScreenSharingProbe=null,this.handoffAbsorbCompletion=!1,this.handoffWatchdog=null,this.apiBridgeCallbacks=new AE,this.pendingSystemActionStore=new RE,this.shouldBlockInputCallback=null,this.onAIAckSettledCallback=null,this.processedCommandIds=new Map,this.inFlightReads=new Set,this.pendingAgentModeTimer=null,this.pendingAgentEscHandler=null,this.pendingCommands=[],this.shouldBlockInputCallback=d||null,this.onAIAckSettledCallback=x||null,this.handoffStorage=new As(e.publishableKey),s.onSystemActionCallback=(e,t)=>{this.pendingSystemActionStore.handleRenderedMetadata(e,t);const n=t||e.idempotency_key;!0===e.resolved&&\"string\"==typeof n&&this.onSessionCardResolved?.(n)},this.presenceHandler=new gE(this.uiManager,this.onAgentJoined),this.historyHandler=new cE(this.messageHandler,this.readReceiptManager,this.chatStateManager,()=>this.wsClient,this.presenceHandler,this.onAiAssignedChange,this.onNewTicketHistoryLoaded,e=>{this.config.agentExecution&&this.tabCoordinator?.isActiveTab()&&(this.agentManager.isEngaged()||this.enterAgentModeAuto(e,{animate:!1}))},()=>this.exitAgentModeAuto(),(e,t)=>{this.onSessionStatusReceived?.(e,t)}),this.aiChunkHandler=new dE(this.messageHandler),this.messageHandlerWS=new uE(this.messageHandler,this.readReceiptManager,this.chatStateManager,()=>this.wsClient,this.getCurrentView,this.onNewMessageSound),this.systemActionHandler=new pE(this.messageHandler,this.chatStateManager,this.tourManager,()=>this.disconnect()),this.ticketUpdateHandler=new hE(this.onAiAssignedChange,this.onConversationStatusChange),this.typingHandler=new mE,this.messageDeletedHandler=new fE(this.messageHandler),this.messageEditedHandler=new bE(this.messageHandler),this.agentManager=new lE(()=>this.wsClient,this.networkTracker,()=>this.cancelAgent(),e=>this.sendMessage(e),()=>this.handoffToNewTab(),()=>!0===this.tabCoordinator?.isHeldByAnotherTab(),()=>this.isScreenSharing()),this.agentManager.getConfirmationUI().setOnAttention(this.onNewMessageSound??null),this.domStateHandler=new yE(()=>this.wsClient,()=>this.agentManager.getAgentModeUI()),this.clarifyingQuestionHandler=new wE(()=>this.wsClient),this.screenshotHandler=new kE(()=>this.wsClient,this.agentManager.getScreenshotCaptureManager(),()=>this.agentManager.getAgentModeUI(),this.agentManager.getNetworkRequestTracker()),this.elementContextHandler=new SE(()=>this.wsClient,this.domStateHandler.getAnalyzer()),this.textDomHandler=new CE(()=>this.wsClient,()=>this.agentManager.getAgentModeUI(),this.domStateHandler.getAnalyzer(),this.networkTracker),this.agentActionHandler=new EE(()=>this.wsClient,new TE(()=>this.sessionManager.getApiBridge(),this.apiBridgeCallbacks,(e,t)=>this.authHeaderObserver.getObservedHeader(e,t),()=>{const e=this.sessionManager.getSessionId();return null!=e?String(e):null})),this.reloadPageHandler=new ME(()=>this.wsClient,()=>this.chatStateManager.isOpened())}getApiBridgeCallbacks(){return this.apiBridgeCallbacks}handoffToNewTab(){\"session\"===this.currentConversation?.type&&this.handoffStorage.set(this.currentConversation.id),sessionStorage.removeItem(\"support_widget_agent_active\"),ha(\"agent-flag:cleared\",{by:\"handoffToNewTab\"}),this.tabCoordinator?.yieldForHandoff(),this.agentManager.isEngaged()&&this.exitAgentModeAuto()}beginHandoffWait(){this.clearHandoffWait(),this.handoffAbsorbCompletion=!0,this.armHandoffWatchdog()}armHandoffWatchdog(){this.handoffWatchdog&&clearTimeout(this.handoffWatchdog),this.handoffWatchdog=setTimeout(()=>{this.handoffAbsorbCompletion=!1,this.handoffWatchdog=null,this.agentManager.isEngaged()&&this.exitAgentModeAuto()},3e4)}noteHandoffActivity(){this.handoffAbsorbCompletion?this.armHandoffWatchdog():this.handoffWatchdog&&this.clearHandoffWait()}clearHandoffWait(){this.handoffAbsorbCompletion=!1,this.handoffWatchdog&&(clearTimeout(this.handoffWatchdog),this.handoffWatchdog=null)}enterAgentModeAuto(e,t){if(this.agentManager.isEngaged())return void ha(\"agent-mode:enter-skipped\",{reason:\"already-engaged\",phase:this.agentManager.getPhase()});if(ha(\"agent-mode:enter\",{intent:e,phase:this.agentManager.getPhase()}),!1===this.tabCoordinator?.claimActiveTab())return;this.agentRunRegistry?.start(()=>this.agentManager.isEngaged());const n=t?.animate??!0,i=this.chatStateManager.isOpened(),s=n?i?this.uiManager.getChatWindowRect():this.uiManager.getBubbleRect():null;this.uiManager.hideForAgentMode(),this.agentManager.enterAgentMode(e,s||void 0,!0===t?.resume)||this.uiManager.showFromAgentMode()}isAgentEngaged(){return this.agentManager.isEngaged()}showAgentModeMessageAndEnter(e){if(this.pendingAgentModeTimer)return;if(!this.agentManager.enterPending())return;const t=Na();this.uiManager.showAgentModeOverlay(t.agent.agentModeActivated),this.pendingAgentEscHandler=e=>{\"Escape\"===e.key&&e.isTrusted&&(this.clearPendingAgentMode(),this.cancelAgent(\"user_cancelled\"))},document.addEventListener(\"keydown\",this.pendingAgentEscHandler),this.pendingAgentModeTimer=setTimeout(()=>{const t=[...this.pendingCommands];this.clearPendingAgentMode(),this.enterAgentModeAuto(e);for(const e of t)\"command\"===e.type?this.agentManager.handleCommand(e.data):this.agentManager.handleBatch(e.data)},2e3)}clearPendingAgentMode(){this.pendingAgentModeTimer&&(clearTimeout(this.pendingAgentModeTimer),this.pendingAgentModeTimer=null),this.pendingAgentEscHandler&&(document.removeEventListener(\"keydown\",this.pendingAgentEscHandler),this.pendingAgentEscHandler=null),this.pendingCommands=[],this.uiManager.hideAgentModeOverlay(),this.agentManager.leavePending()}exitAgentModeAuto(){ha(\"agent-mode:exit\",{phase:this.agentManager.getPhase()}),this.clearHandoffWait(),this.clearPendingAgentMode(),this.messageHandler.finalizeStreamingMessage(),this.uiManager.hideAIThinkingState(),this.agentManager.teardownRun(),this.agentManager.startExiting()&&this.agentManager.finishExiting().then(()=>{this.uiManager.showFromAgentMode(),this.chatStateManager.open(),this.drainPendingCommands(),this.uiManager.focusComposer()})}drainPendingCommands(){if(0===this.pendingCommands.length)return;if(this.agentManager.isCancelPending())return void(this.pendingCommands=[]);const e=[...this.pendingCommands];if(this.pendingCommands=[],this.enterAgentModeAuto(),this.agentManager.isAgentModeActive())for(const t of e)\"command\"===t.type?this.agentManager.handleCommand(t.data):this.agentManager.handleBatch(t.data)}connect(e,t,n){let i,s;if(e&&t)i=e,s=t;else if(\"session\"===e)s=this.sessionManager.getSessionId(),i=\"session\";else if(\"ticket\"===e)s=this.sessionManager.getTicketId(),i=\"ticket\";else{const e=this.sessionManager.getSessionId(),t=this.sessionManager.getTicketId();if(e)s=e,i=\"session\";else{if(!t)return;s=t,i=\"ticket\"}}if(!s)return;if(this.isLiveConversation(i,s))return;null===this.currentConversation||this.currentConversation.type===i&&this.currentConversation.id===s||this.clearForNewConversation(!0===n?.preserveMessages),this.disconnect(),this.currentConversation={type:i,id:s};const r=this.sessionManager.getSourceId()||\"\";this.tabCoordinator?.destroy();const o=`${i}:${s}`;this.tabCoordinator=new wa(o,()=>{this.agentManager.isEngaged()&&this.exitAgentModeAuto()}),this.agentRunRegistry?.destroy(),this.agentRunRegistry=new IE(o,e=>{this.onAgentRunElsewhereChange?.(e||this.isServerRunElsewhere())}),this.wsClient=new eu({apiBaseUrl:this.config.apiBaseUrl,publishableKey:this.config.publishableKey,conversationId:s,conversationType:i,sourceId:r,lastSeenSeq:this.readReceiptManager.getLastSeenSeq(),testAgentMode:this.config.testAgentMode,agentExecution:this.config.agentExecution,getIdentityProof:()=>this.sessionManager.getIdentityProof(),refreshIdentityProof:()=>this.sessionManager.refreshIdentityProof()},this.createCallbacks()),this.uiManager.showChatLoading(),this.wsClient.connect();const a=\"1\"===sessionStorage.getItem(\"support_widget_agent_active\"),l=!0===this.tabCoordinator?.isHeldByAnotherTab(),c=this.agentManager.getPhase(),d=!n?.follow&&(\"session\"===(u={conversationType:i,resumeFlag:a,phase:c}).conversationType&&u.resumeFlag&&\"idle\"===u.phase);var u;ha(\"agent-resume:decision\",{willResume:d,conversationType:i,conversationId:s,resumeFlag:a,otherTabDriving:l,phase:c}),d?(this.enterAgentModeAuto(void 0,{animate:!1,resume:!0}),this.beginHandoffWait()):!n?.follow&&this.agentManager.isEngaged()&&this.tabCoordinator?.claimActiveTab()}getFrameJournal(){return this.wsClient?.getFrameJournal()??[]}clearForNewConversation(e=!1){e||this.messageHandler.clearMessages(!0),this.pendingSystemActionStore.clear(),this.readReceiptManager.reset(),this.chatStateManager.resetScrollFlag(),this.uiManager.hideWaitingBadge(),this.chatStateManager.restoreInputState(),this.onReattachInputListeners?.()}createCallbacks(){return{onAgentOwnerChanged:e=>{this.serverOwnerTabId=e,null!==e&&e!==ya()&&(this.agentManager.cancelActiveCommand(),this.clearPendingAgentMode()),this.tabCoordinator?.setServerOwner(e),this.notifyAgentRunElsewhere()},onConnected:()=>{ha(\"ws:connected\",{conversationType:this.currentConversation?.type,conversationId:this.currentConversation?.id,phase:this.agentManager.getPhase()}),this.wsClient?.flushUnsentResponses()},onDisconnected:()=>{ha(\"ws:disconnected\",{phase:this.agentManager.getPhase()}),this.uiManager.hideChatLoading(),this.presenceHandler.clear(),this.typingHandler.clear()},onConnectionStateChange:e=>{\"failed\"===e&&(this.uiManager.hideChatLoading(),this.exitAgentModeAuto()),this.onConnectionStateChanged?.(e)},onHistoryReceived:(e,t,n,i,s,r,o,a,l,c,d,u)=>{this.serverAgentRunning=void 0!==d?\"executing\"===d:!0===s,this.notifyAgentRunElsewhere(),this.uiManager.hideChatLoading(),this.agentManager.getSessionRecorder().flushOnConnectionReady(),this.onLiveCallSnapshot?.(u),this.historyHandler.handle({messages:e,lastReadSeq:t,ai_assigned:n,first_response_at:i,agent_mode_active:s,agent_mode_intent:r,agent_status:d,session_id:o,sessionStatus:a,was_escalated:l}),c&&this.onSessionBubbleReceived?.(c)},onExecutiveAvailability:e=>{\"ticket\"===this.currentConversation?.type&&this.onExecutiveAvailability?.(e)},onMessageReceived:e=>{if(e.is_draft)return;if(!0===e.is_ephemeral)return this.messageHandlerWS.handle(e),void this.readReceiptManager.updateUnreadIndicator();\"ai\"!==e.role&&\"system\"!==e.role||!this.shouldBlockInputCallback?.()||(this.onAIAckSettledCallback?.(),this.messageHandler.finalizeStreamingMessage()),\"system\"===e.role&&!0===e.metadata?.engineering_handoff&&this.onConversationStatusChange?.(\"escalated\",!0),this.messageHandlerWS.handle(e),this.readReceiptManager.updateUnreadIndicator();const t=e.metadata?.milestone_message_id,n=Fd(e,{milestoneMessageId:\"number\"==typeof t?t:void 0,sessionId:\"session\"===this.currentConversation?.type?this.currentConversation.id:void 0,seq:e.seq,bubbleKind:\"channel_continuation\"===e.metadata?.widget_bubble_kind?\"channel_continuation\":void 0,ctaLabel:\"string\"==typeof e.metadata?.widget_bubble_cta_label?e.metadata.widget_bubble_cta_label:void 0,decisionCard:Od([e],e.bubble_message)});n&&this.onSessionBubbleReceived?.(n);const i=e.text||e.body;this.tabCoordinator?.isActiveTab()&&this.agentManager.isAgentModeActive()&&(\"ai\"===e.role||\"agent\"===e.role||\"system\"===e.role)&&i&&this.agentManager.getAgentModeUI().showMessageBubble({id:e.idempotencyKey||`msg-${s()}`,text:i,role:e.role}),this.tabCoordinator?.isActiveTab()&&this.agentManager.isAgentModeActive()&&!0===e.wait_for_response&&this.exitAgentModeAuto()},onAIChunkReceived:(e,t)=>{this.aiChunkHandler.handle({chunk:e,step:t})},onSystemActionSuccess:e=>{this.systemActionHandler.handle(e)},onTicketUpdate:e=>{this.ticketUpdateHandler.handle(e)},onError:e=>{this.uiManager.hideChatLoading(),Ji(\"WebSocket error\",e),this.onWebSocketError?.(e)},onIdentityRejected:()=>{this.uiManager.hideChatLoading(),this.uiManager.showToast(Na().errors.identityVerificationFailed,\"error\")},onUserJoined:e=>{this.presenceHandler.handle({type:\"user_joined\",...e})},onUserLeft:e=>{this.presenceHandler.handle({type:\"user_left\",...e}),this.typingHandler.handle({type:\"user_stopped_typing\",...e})},onUserTyping:e=>{this.typingHandler.handle({type:\"user_typing\",...e})},onUserStoppedTyping:e=>{this.typingHandler.handle({type:\"user_stopped_typing\",...e})},onPresenceUpdate:e=>{this.presenceHandler.handle({type:\"presence_update\",...e})},onAIThinkingReceived:()=>{this.serverAgentRunning=!0,this.notifyAgentRunElsewhere(),this.onAIAckSettledCallback?.(),this.messageHandler.showThinkingBubble(),this.shouldBlockInputCallback?.()&&this.uiManager.showAIThinkingState()},onAIThinkingStop:()=>{this.serverAgentRunning=!1,this.notifyAgentRunElsewhere(),this.onAIAckSettledCallback?.(),this.messageHandler.finalizeStreamingMessage(),this.uiManager.hideAIThinkingState()},onAIProgressReceived:(e,t)=>{\"search_document\"!==t?(this.messageHandler.updateProgressMessage(e),this.tabCoordinator?.isActiveTab()&&this.agentManager.isAgentModeActive()&&e&&(!function(e,t){return t?\"step\"===t:!/(\\.\\.\\.|…)$/.test(e.trim())}(e,t)?this.agentManager.getAgentModeUI().setStatus(e):this.agentManager.getAgentModeUI().showMessageBubble({id:`step-${s()}`,text:e,role:\"ai\"}))):this.messageHandler.appendDocumentReadItem(e)},onMessageDeleted:e=>{this.messageDeletedHandler.handle({seq:e})},onMessageEdited:({seq:e,body:t})=>{this.messageEditedHandler.handle({seq:e,body:t})},onAgentCommand:e=>{if(this.rejectWhenPassive(e.command_id))return;if(this.noteHandoffActivity(),this.answeredFromCache(e.command_id))return;this.markCommandProcessed(e.command_id);const t=this.agentManager.getPhase();\"active\"===t?this.agentManager.handleCommand(e):\"exiting\"===t||\"pending\"===t?this.pendingCommands.push({type:\"command\",data:e}):(this.pendingCommands.push({type:\"command\",data:e}),this.showAgentModeMessageAndEnter())},onAgentCommandBatch:e=>{if(this.rejectWhenPassive(e.batch_id))return;this.noteHandoffActivity();const t=e.commands.filter(e=>\"agent_command\"===e.type).map(e=>e.command_id);if(t.length>0&&t.every(e=>this.isCommandProcessed(e))&&this.wsClient?.resendCachedResponse(e.batch_id))return;t.forEach(e=>this.markCommandProcessed(e));const n=this.agentManager.getPhase();\"active\"===n?this.agentManager.handleBatch(e):\"exiting\"===n||\"pending\"===n?this.pendingCommands.push({type:\"batch\",data:e}):(this.pendingCommands.push({type:\"batch\",data:e}),this.showAgentModeMessageAndEnter())},onRequestDomState:e=>{this.rejectWhenPassive(e.command_id)||this.answeredFromCache(e.command_id)||(e.command_id&&this.markCommandProcessed(e.command_id),this.enqueueRead(e.command_id,()=>this.domStateHandler.handle(e),\"dom_state read\"))},onRequestScreenshot:e=>{this.rejectWhenPassive(e.command_id)||this.answeredFromCache(e.command_id)||(e.command_id&&this.markCommandProcessed(e.command_id),this.enqueueRead(e.command_id,()=>this.screenshotHandler.handle(e),\"screenshot\"))},onClarifyingQuestion:e=>{this.rejectWhenPassive(e.command_id)||this.answeredFromCache(e.command_id)||(e.command_id&&this.markCommandProcessed(e.command_id),this.clarifyingQuestionHandler.handle(e))},onRequestElementContext:e=>{this.rejectWhenPassive(e.command_id)||this.answeredFromCache(e.command_id)||(e.command_id&&this.markCommandProcessed(e.command_id),this.enqueueRead(e.command_id,()=>this.elementContextHandler.handle(e),\"element_context read\"))},onRequestTextDom:e=>{this.rejectWhenPassive(e.command_id)||this.answeredFromCache(e.command_id)||(e.command_id&&this.markCommandProcessed(e.command_id),this.enqueueRead(e.command_id,()=>this.textDomHandler.handle(e),\"text_dom read\"))},onReloadPage:e=>{this.rejectWhenPassive(e.command_id)||this.reloadPageHandler.handle(e)},onAgentCancelled:()=>{this.serverAgentRunning=!1,this.notifyAgentRunElsewhere(),this.onAIAckSettledCallback?.(),this.agentManager.cancelActiveCommand(),this.exitAgentModeAuto()},onAgentAcknowledged:()=>{if(this.handoffAbsorbCompletion)return this.handoffAbsorbCompletion=!1,void this.armHandoffWatchdog();this.onAIAckSettledCallback?.(),this.agentManager.cancelActiveCommand(),this.exitAgentModeAuto()},onSessionRecordingAck:e=>{this.agentManager.getSessionRecorder().acknowledgeChunk(e)},onSessionRecordingRejected:e=>{const t=this.agentManager.getSessionRecorder();t.getSpanUid()===e&&(t.rejectSpan(e),this.exitAgentModeAuto())},onSessionEscalated:e=>{this.onSessionEscalated?.(e.conversation_id,e.executive_availability)},onSessionClosed:()=>{this.tourManager.stopActiveTour(),this.agentManager.teardownRun(),this.chatStateManager.showClosedState(),this.onSessionClosedExternal?.()},onMessageQueued:e=>{this.agentManager.isAgentModeActive()&&this.agentManager.getAgentModeUI().showQueuedIndicator(e.message)},onAgentExecutionComplete:()=>{if(this.handoffAbsorbCompletion)return this.handoffAbsorbCompletion=!1,void this.armHandoffWatchdog();this.serverAgentRunning=!1,this.notifyAgentRunElsewhere(),this.agentManager.cancelActiveCommand(),this.exitAgentModeAuto(),this.onAgentRunComplete?.()},onReplayReceived:e=>{for(const t of e)this.messageHandlerWS.handle(t);this.readReceiptManager.updateUnreadIndicator()},onOnboardingStepCompleted:e=>this.onOnboardingStepCompleted?.(e),onPlanSaved:()=>this.onPlanSaved?.(),onAgentAction:e=>{this.agentActionHandler.handle(e)},onActivationForm:e=>this.onActivationForm?.(e),onFeatureCheckIn:e=>this.onFeatureCheckIn?.(e),onFeatureCheckInReminder:()=>this.onFeatureCheckInReminder?.(),onActivationSessionStarted:e=>this.onActivationSessionStarted?.(e),onActivationSessionClosed:e=>this.onActivationSessionClosed?.(e),onActivationSessionReplaced:e=>this.onActivationSessionReplaced?.(e),onVoiceCallInvite:e=>this.onVoiceCallInvite?.(e),onVoiceCallStatus:e=>this.onVoiceCallStatus?.(e),onScreenShareInvite:e=>this.onScreenShareInvite?.(e),onScreenShareStatus:e=>this.onScreenShareStatus?.(e)}}sendAgentActionPermission(e,t){this.wsClient&&this.wsClient.sendSystemResponse({type:\"agent_action_permission\",permission_id:e,decision:t})}sendMessage(e,t,n,i){if(!this.wsClient)return;this.claimActiveTab();const s=this.pendingSystemActionStore.take();if(s){const e={type:\"system_action\",role:\"system\",metadata:{suggestion_type:s.suggestionType,decision:\"decline\",source:{idempotency_key:s.idempotencyKey}}};this.wsClient.sendSystemResponse(e)}this.wsClient.sendMessage(e,i=>{const s=n||t?.map(e=>({id:String(e),file_name:\"Uploading...\",mime_type:\"image/png\",size_bytes:0,thumbnail_url:\"\",created_at:(new Date).toISOString()}));this.messageHandler.addMessage({text:e,isAgent:!1,idempotencyKey:i,isPending:!0,attachments:s})},t,i)}sendSystemAction(e,t,n){if(!this.wsClient)return;const i=n??this.pendingSystemActionStore.take();if(!i)return;this.pendingSystemActionStore.clear(i.idempotencyKey);const s=i.suggestionType,r={suggestion_type:s,decision:e,source:{idempotency_key:i.idempotencyKey},tab_id:ya()};void 0!==t&&(r.comment=t);const o={type:\"system_action\",role:\"system\",metadata:r};this.wsClient.sendSystemResponse(o),\"close_ticket\"===s&&\"accept\"===e&&(this.tourManager.stopActiveTour(),this.chatStateManager.showClosedState())}declinePendingSystemAction(){if(!this.wsClient)return!1;const e=this.pendingSystemActionStore.take();if(!e)return!1;const t={type:\"system_action\",role:\"system\",metadata:{suggestion_type:e.suggestionType,decision:\"decline\",source:{idempotency_key:e.idempotencyKey}}};return this.wsClient.sendSystemResponse(t),!0}sendReplay(e){this.wsClient&&this.wsClient.sendReplay(e)}sendReadReceipt(e){this.wsClient&&this.wsClient.sendReadReceipt(e)}claimActiveTab(){this.agentRunRegistry?.isRunningElsewhere()&&(this.wsClient?.sendAgentCancel(\"tab_handover\"),this.agentRunRegistry.markSettled()),this.tabCoordinator?.claimActiveTab()}takeOverAgentHere(){this.claimActiveTab(),this.wsClient?.sendTabClaim()}isServerRunElsewhere(){return this.serverAgentRunning&&null!=this.serverOwnerTabId&&this.serverOwnerTabId!==ya()}notifyAgentRunElsewhere(){this.onAgentRunElsewhereChange?.(this.isServerRunElsewhere()||!0===this.agentRunRegistry?.isRunningElsewhere())}isActiveTab(){return this.tabCoordinator?.isLocallyActiveTab()??\"visible\"===document.visibilityState}isAgentRecording(){return this.agentManager.getSessionRecorder().isRecording()}isScreenSharing(){return this.isScreenSharingProbe?.()??!1}claimTabOwnership(){this.tabCoordinator?.claimActiveTab()}reclaimTabAfterReload(){this.tabCoordinator?.isHeldByAnotherTab()||this.tabCoordinator?.claimActiveTab()}stopAgentElsewhere(){this.wsClient?.sendAgentCancel(\"user_stopped_other_tab\"),this.agentRunRegistry?.markSettled()}disconnect(){this.clearHandoffWait(),this.wsClient&&(this.wsClient.disconnect(),this.wsClient=null),this.tabCoordinator?.destroy(),this.tabCoordinator=null,this.agentRunRegistry?.destroy(),this.agentRunRegistry=null,this.serverOwnerTabId=null,this.serverAgentRunning=!1,this.onAgentRunElsewhereChange?.(!1),this.uiManager.hideAgentBanner(),this.uiManager.hideChatLoading(),this.onExecutiveAvailability?.(null)}destroy(){this.agentManager.destroy(),this.disconnect()}isConnected(){return this.wsClient?.getConnectionStatus()??!1}reconnectIfFailed(){this.wsClient?.reconnectIfFailed()}isLiveConversation(e,t){if(!this.wsClient)return!1;if(this.currentConversation?.type!==e||this.currentConversation?.id!==t)return!1;const n=this.wsClient.getReadyState();return n===WebSocket.CONNECTING||n===WebSocket.OPEN}getClient(){return this.wsClient}setMessagesContainer(e){this.typingHandler.setMessagesContainer(e)}sendTypingStart(){this.wsClient&&this.wsClient.sendTypingStart()}sendTypingStop(){this.wsClient&&this.wsClient.sendTypingStop()}cancelAgent(e){this.wsClient?.sendAgentCancel(e),this.endRunLocally()}endClosedRun(){sessionStorage.removeItem(\"support_widget_agent_active\"),\"idle\"!==this.agentManager.getPhase()&&this.endRunLocally()}endRunLocally(){this.agentManager.cancelActiveCommand();const e=this.agentManager.getPhase();\"pending\"===e?this.clearPendingAgentMode():\"active\"===e&&this.exitAgentModeAuto()}cancelAgentIfActive(){\"idle\"!==this.agentManager.getPhase()&&this.cancelAgent()}isAgentModeEngaged(){return this.agentManager.isEngaged()}getAgentManager(){return this.agentManager}getCurrentConversation(){return this.currentConversation}enqueueRead(t,n,i=\"read\"){if(t){if(this.inFlightReads.has(t))return;this.inFlightReads.add(t)}jp.run(async()=>{await async function(t,n={}){const{quietMs:i,maxWaitMs:s,pollMs:r,staleRequestMs:o}={...$u,...n},a=()=>zu(t,o);if(await qu(r),!a())return;const l=performance.now();let c=null;for(;performance.now()-l<s;){if(await e(r),a()){c=null;continue}const t=performance.now();if(null===c)c=t;else if(t-c>=i)return}}(this.networkTracker),await n()},void 0,i).catch(e=>{if(!t)return;const n=e instanceof Error?e.message:`Agent ${i} timed out`;this.wsClient?.sendSDKError(t,n,\"timeout\")}).finally(()=>{t&&this.inFlightReads.delete(t)})}rejectWhenPassive(e){return!this.tabCoordinator?.isActiveTab()&&(e&&this.wsClient?.sendSDKError(e,\"another tab is driving the agent\",\"tab_not_active\"),!0)}answeredFromCache(e){return!(!e||!this.isCommandProcessed(e))&&!0===this.wsClient?.resendCachedResponse(e)}isCommandProcessed(e){return this.cleanupExpiredCommands(),this.processedCommandIds.has(e)}markCommandProcessed(e){this.processedCommandIds.set(e,s())}cleanupExpiredCommands(){const e=s()-6e4;for(const[t,n]of this.processedCommandIds)n<e&&this.processedCommandIds.delete(t)}}class NE{constructor(){this._type=null,this._id=null,this._status=null,this._aiAssigned=null,this._hasSupportHandoff=!1}setActive(e,t){this._type=e,this._id=t,this._status=null,this._aiAssigned=null,this._hasSupportHandoff=!1}clear(){this._type=null,this._id=null,this._status=null,this._aiAssigned=null,this._hasSupportHandoff=!1}setStatus(e){e&&(this._status=e)}setAiAssigned(e){void 0!==e&&(this._aiAssigned=e)}markSupportHandoff(e){!0===e&&(this._hasSupportHandoff=!0)}get type(){return this._type}get id(){return this._id}get status(){return this._status}get aiAssigned(){return this._aiAssigned}get hasSupportHandoff(){return this._hasSupportHandoff}getBannerVariant(){if(\"ticket\"!==this._type)return\"hidden\";if(\"resolved\"===this._status||\"closed\"===this._status)return\"hidden\";return(this._hasSupportHandoff||\"escalated\"===this._status)&&!1===this._aiAssigned?\"human\":\"hidden\"}}const PE=[\"x-request-id\",\"x-trace-id\",\"traceparent\",\"x-correlation-id\"];class FE{constructor(e,t=!1){this.pending=new Set,this.pendingInfo=new Map,this.pendingCounter=0,this.recentResponses=[],this.installed=!1,this.originalFetch=null,this.originalXhrOpen=null,this.originalXhrSend=null,this.errorListener=null,this.rejectionListener=null,this.originalConsoleError=null,this.apiBaseUrl=e,this.trackAllRequests=t}install(){this.installed||(this.installed=!0,this.patchFetch(),this.patchXhr(),this.patchGlobalErrors(),this.patchConsole())}uninstall(){this.installed&&(this.installed=!1,this.originalFetch&&(window.fetch=this.originalFetch,this.originalFetch=null),this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen,this.originalXhrOpen=null),this.originalXhrSend&&(XMLHttpRequest.prototype.send=this.originalXhrSend,this.originalXhrSend=null),this.errorListener&&(window.removeEventListener(\"error\",this.errorListener),this.errorListener=null),this.rejectionListener&&(window.removeEventListener(\"unhandledrejection\",this.rejectionListener),this.rejectionListener=null),this.originalConsoleError&&(console.error=this.originalConsoleError,this.originalConsoleError=null))}fetchWithAssetDeadline(e,t,n,i){if(!function(e){return Yx>0&&nk.test(e)}(i))return e.call(window,t,n);const s=new AbortController,r=n?.signal;r&&(r.aborted?s.abort():r.addEventListener(\"abort\",()=>s.abort(),{once:!0}));const o=setTimeout(()=>{tk(i),s.abort()},1500),a=function(){const e=performance.now();ek.count++;let t=!1;return n=>{if(t)return;t=!0;const i=performance.now()-e;ek.totalMs+=i,i>ek.slowestMs&&(ek.slowestMs=i),\"failed\"===n&&ek.failed++}}();return e.call(window,t,{...n||{},signal:s.signal}).then(e=>(a(e.ok?\"ok\":\"failed\"),e),e=>{throw a(\"failed\"),e}).finally(()=>clearTimeout(o))}patchFetch(){this.originalFetch=window.fetch;const e=this.originalFetch;window.fetch=(t,n)=>{let i;try{if(i=ss(t),this.isWidgetRequest(i))return e.call(window,t,n)}catch(i){return Ji(\"network-tracker:fetch-prologue\",i),e.call(window,t,n)}if(function(e){return Yx>0&&Xx.has(e)}(i))return ek.skipped++,Promise.reject(new TypeError(\"Failed to fetch (cached capture-resource failure)\"));const s=(n?.method||\"GET\").toUpperCase(),r=performance.now(),o=this.addPending(s,i,r);return this.fetchWithAssetDeadline(e,t,n,i).then(e=>{try{if(this.removePending(o),!e.ok){const t=this.extractRequestIdFromHeaders(t=>e.headers.get(t));e.clone().text().then(n=>{this.recordResponse({url:i,method:s,status:e.status,body:this.truncate(n),request_id:t,started_at:r,ended_at:performance.now()})}).catch(()=>{this.recordResponse({url:i,method:s,status:e.status,request_id:t,started_at:r,ended_at:performance.now()})})}}catch(e){Ji(\"network-tracker:fetch-response\",e)}return e},e=>{try{this.removePending(o),tk(i),this.recordResponse({url:i,method:s,status:0,body:this.truncate(this.errorMessage(e)),started_at:r,ended_at:performance.now()})}catch(e){Ji(\"network-tracker:fetch-failure\",e)}throw e})}}patchXhr(){this.originalXhrOpen=XMLHttpRequest.prototype.open,this.originalXhrSend=XMLHttpRequest.prototype.send;const e=this.isWidgetRequest.bind(this),t=this.truncate.bind(this),n=this.recordResponse.bind(this),i=this.extractRequestIdFromHeaders.bind(this),s=this.addPending.bind(this),r=this.removePending.bind(this),o=this.originalXhrOpen,a=this.originalXhrSend;XMLHttpRequest.prototype.open=function(e,t,...n){try{this._nrt_method=e.toUpperCase(),this._nrt_url=ss(t)}catch(e){Ji(\"network-tracker:xhr-open\",e)}return o.apply(this,[e,t,...n])},XMLHttpRequest.prototype.send=function(o){try{const o=this._nrt_url;if(o&&!e(o)){const e=this._nrt_method||\"GET\",a=performance.now();this._nrt_recorded=!1;const l=s(e,o,a),c=t=>{try{if(this._nrt_recorded)return;this._nrt_recorded=!0,r(l),n({url:o,method:e,status:0,body:`xhr_${t}`,started_at:a,ended_at:performance.now()})}catch(e){Ji(\"network-tracker:xhr-transport-failure\",e)}};this.addEventListener(\"error\",()=>c(\"error\")),this.addEventListener(\"timeout\",()=>c(\"timeout\")),this.addEventListener(\"abort\",()=>c(\"abort\")),this.addEventListener(\"loadend\",s=>{try{if(this._nrt_recorded)return;this._nrt_recorded=!0,r(l);const c=s.target;if(!c||c.status<400)return;let d;try{\"\"!==c.responseType&&\"text\"!==c.responseType||(d=t(c.responseText||\"\"))}catch{}const u=new Map(c.getAllResponseHeaders().trim().split(/\\r?\\n/).map(e=>{const t=e.indexOf(\":\");return[e.slice(0,t).trim().toLowerCase(),e.slice(t+1).trim()]})),p=i(e=>u.get(e)??null);n({url:o,method:e,status:c.status,body:d,request_id:p,started_at:a,ended_at:performance.now()})}catch(e){Ji(\"network-tracker:xhr-loadend\",e)}})}}catch(e){Ji(\"network-tracker:xhr-send\",e)}return a.call(this,o)}}patchGlobalErrors(){this.errorListener=es(\"network-tracker:window-error\",e=>{const t=e.error?.stack?`\\n${e.error.stack}`:\"\",n=performance.now();this.recordResponse({url:e.filename||\"window.onerror\",method:\"JS_ERROR\",status:0,body:this.truncate(`${e.message??\"unknown\"}${t}`),started_at:n,ended_at:n})}),window.addEventListener(\"error\",this.errorListener),this.rejectionListener=es(\"network-tracker:unhandledrejection\",e=>{const t=e.reason,n=performance.now();this.recordResponse({url:\"unhandledrejection\",method:\"JS_ERROR\",status:0,body:this.truncate(this.errorMessage(t)),started_at:n,ended_at:n})}),window.addEventListener(\"unhandledrejection\",this.rejectionListener)}patchConsole(){this.originalConsoleError=console.error;const e=this.originalConsoleError;console.error=(...t)=>{try{this.recordConsoleError(t)}catch(e){Ji(\"network-tracker:console-error\",e)}e.apply(console,t)}}recordConsoleError(e){if(0===e.length)return;if(\"string\"==typeof e[0]&&/^\\[(SupportWidget|snapdom)/i.test(e[0]))return;const t=performance.now();this.recordResponse({url:this.consoleErrorLabel(e),method:\"CONSOLE_ERROR\",status:0,body:this.truncate(this.formatConsoleArgs(e)),started_at:t,ended_at:t})}formatConsoleArgs(e){return e.map(e=>this.formatConsoleArg(e)).join(\" \")}formatConsoleArg(e){if(\"string\"==typeof e)return e;if(e instanceof Error)return e.stack||`${e.name}: ${e.message}`;try{return JSON.stringify(e)??String(e)}catch{return String(e)}}consoleErrorLabel(e){const t=e.find(e=>e instanceof Error),n=(t?`${t.name}: ${t.message}`:this.formatConsoleArg(e[0])).split(\"\\n\",1)[0].trim();return n?n.length>120?n.slice(0,119)+\"…\":n:\"console.error\"}getPendingRequests(){return Array.from(this.pending)}getPendingRequestInfo(){return Array.from(this.pendingInfo.values())}addPending(e,t,n){const i=++this.pendingCounter,s=`${e} ${this.extractPathname(t)}`;return this.pending.add(s),this.pendingInfo.set(i,{method:e,url:t,started_at:n}),{key:s,id:i}}removePending(e){this.pending.delete(e.key),this.pendingInfo.delete(e.id)}getRecentFailures(e){const t=e-3e4,n=new Map;for(const e of this.recentResponses){if(e.ended_at<t)continue;if(e.status<400&&0!==e.status)continue;const i=`${e.method} ${e.url} ${e.status}`,s=n.get(i);s?(s.count+=1,s.ended_at=e.ended_at,s.duration_ms=Math.round(e.ended_at-e.started_at),s.timestamp_iso=e.timestamp_iso,s.page_url=e.page_url,void 0!==e.body&&(s.body=e.body),e.request_id&&(s.request_id=e.request_id)):n.set(i,{url:e.url,method:e.method,status:e.status,...void 0!==e.body&&{body:e.body},...e.request_id&&{request_id:e.request_id},page_url:e.page_url,timestamp_iso:e.timestamp_iso,duration_ms:Math.round(e.ended_at-e.started_at),count:1,started_at:e.started_at,ended_at:e.ended_at})}return Array.from(n.values()).sort((e,t)=>e.ended_at-t.ended_at).slice(-10)}extractRequestIdFromHeaders(e){for(const t of PE){const n=e(t);if(n)return n}}recordResponse(e){const t={...e,page_url:e.page_url??window.location.href,timestamp_iso:e.timestamp_iso??(new Date).toISOString()};this.recentResponses.push(t),this.recentResponses.length>50&&this.recentResponses.shift()}truncate(e){return e.length<=500?e:e.slice(0,499)+\"…\"}errorMessage(e){return e instanceof Error?e.message||e.name||\"Error\":\"string\"==typeof e?e:String(e&&\"object\"==typeof e&&\"message\"in e?e.message:e??\"unknown\")}extractPathname(e){try{return new URL(e,window.location.origin).pathname}catch{return e}}isWidgetRequest(e){if(this.trackAllRequests||!this.apiBaseUrl)return!1;try{if(new URL(e,window.location.origin).href.startsWith(this.apiBaseUrl))return!0}catch{}return!1}}class OE{constructor(){this.installed=!1,this.targetOrigins=new Set,this.headerName=null,this.observed=new Map,this.originalFetch=null,this.originalXhrOpen=null,this.originalSetRequestHeader=null}install(){this.installed||(this.installed=!0,this.patchFetch(),this.patchXhr())}uninstall(){this.installed&&(this.installed=!1,this.originalFetch&&(window.fetch=this.originalFetch,this.originalFetch=null),this.originalXhrOpen&&(XMLHttpRequest.prototype.open=this.originalXhrOpen,this.originalXhrOpen=null),this.originalSetRequestHeader&&(XMLHttpRequest.prototype.setRequestHeader=this.originalSetRequestHeader,this.originalSetRequestHeader=null),this.observed.clear())}setTargetOrigins(e,t){const n=new Set;for(const t of e){const e=this.originOf(t);null!==e&&n.add(e)}this.targetOrigins=n,this.headerName=t.toLowerCase()}getObservedHeader(e,t){if(t.toLowerCase()!==this.headerName)return null;const n=this.originOf(e);return null===n?null:this.observed.get(n)??null}patchFetch(){this.originalFetch=window.fetch;const e=this.originalFetch;window.fetch=(t,n)=>{try{const e=this.targetOriginOf(ss(t));if(null!==e){const i=this.extractHeaderFromFetch(t,n);null!==i&&this.observed.set(e,i)}}catch{}return e.call(window,t,n)}}patchXhr(){this.originalXhrOpen=XMLHttpRequest.prototype.open,this.originalSetRequestHeader=XMLHttpRequest.prototype.setRequestHeader;const e=this.originalXhrOpen,t=this.originalSetRequestHeader,n=this.targetOriginOf.bind(this),i=this.matchesHeaderName.bind(this),s=this.observed;XMLHttpRequest.prototype.open=function(t,n,...i){return this._aho_url=ss(n),e.apply(this,[t,n,...i])},XMLHttpRequest.prototype.setRequestHeader=function(e,r){try{const t=this._aho_url&&i(e)?n(this._aho_url):null;null!==t&&s.set(t,r)}catch{}return t.call(this,e,r)}}extractHeaderFromFetch(e,t){return t&&void 0!==t.headers?this.readHeader(t.headers):\"undefined\"!=typeof Request&&e instanceof Request?this.readHeader(e.headers):null}readHeader(e){if(null===this.headerName)return null;if(\"undefined\"!=typeof Headers&&e instanceof Headers)return e.get(this.headerName);if(Array.isArray(e)){for(const t of e)if(t.length>=2&&t[0].toLowerCase()===this.headerName)return t[1];return null}for(const[t,n]of Object.entries(e))if(t.toLowerCase()===this.headerName)return n;return null}matchesHeaderName(e){return null!==this.headerName&&e.toLowerCase()===this.headerName}targetOriginOf(e){const t=this.originOf(e);return null!==t&&this.targetOrigins.has(t)?t:null}originOf(e){try{return new URL(e,window.location.origin).origin}catch{return null}}}function qE(e,t){return\"contact\"!==e.role&&\"event\"!==e.role&&(!e.is_draft&&!e.is_ephemeral&&(e.seq??0)>t)}OE.SDK_SESSION_CALLBACK_ID=\"session\";class HE{constructor(e,t,n,i){this.config=e,this.sourceId=t,this.callbacks=n,this.getIdentityProof=i,this.wsClient=null,this.unreadCount=0,this.conversationType=null,this.conversationId=null}connect(e,t){this.disconnect(),this.conversationType=e,this.conversationId=t,this.unreadCount=0;const n={onActivationForm:e=>this.callbacks.onActivationForm?.(e),onFeatureCheckIn:e=>this.callbacks.onFeatureCheckIn?.(e),onFeatureCheckInReminder:()=>this.callbacks.onFeatureCheckInReminder?.(),onConnected:()=>{},onDisconnected:()=>{},onConnectionStateChange:()=>{},onHistoryReceived:(n,i)=>{if(null===this.conversationType)return;const s=Math.max(i??0,Uc.readStoredLastReadSeq(e,t));this.unreadCount=n.filter(e=>qE(e,s)).length,this.callbacks.onUnreadChange(this.conversationType,this.unreadCount)},onAIChunkReceived:()=>{},onSystemActionSuccess:()=>{},onTicketUpdate:()=>{},onError:()=>{},onMessageReceived:e=>{const t=e.role||(!1===e.isAgent?\"contact\":\"agent\");qE({...e,role:t},0)&&null!==this.conversationType&&(this.unreadCount++,this.callbacks.onUnreadChange(this.conversationType,this.unreadCount),this.callbacks.onNewMessageSound())},onSessionEscalated:e=>{this.callbacks.onSessionEscalated(e.conversation_id,e.executive_availability)}};this.wsClient=new eu({apiBaseUrl:this.config.apiBaseUrl,publishableKey:this.config.publishableKey,conversationId:t,conversationType:e,sourceId:this.sourceId,lastSeenSeq:0,testAgentMode:!1,getIdentityProof:this.getIdentityProof},n),this.wsClient.connect()}disconnect(){this.wsClient&&(this.wsClient.disconnect(),this.wsClient=null)}resetUnread(){this.unreadCount=0,this.conversationType&&this.callbacks.onUnreadChange(this.conversationType,0)}getUnreadCount(){return this.unreadCount}getConversationType(){return this.conversationType}getConversationId(){return this.conversationId}}const BE=\"blar_tour_state\";function DE(e,t){try{const n={tourId:e,currentStep:t,timestamp:s()};sessionStorage.setItem(BE,JSON.stringify(n))}catch{}}function zE(){try{sessionStorage.removeItem(BE)}catch{}}function UE(e){return s()-e.timestamp>6e5}const jE={en:{waiting:\"⏳ Waiting for element to load...\",not_found:\"⚠️ Can't find this element. It may not have loaded or the page changed.\",end_tour:\"End Tour\",retry:\"Retry\",click_first:\"⚠️ Please click the highlighted element first\",click_to_continue:\"👆 Click the highlighted element to continue\"},es:{waiting:\"⏳ Esperando a que el elemento cargue...\",not_found:\"⚠️ No se encuentra este elemento. Puede que no haya cargado o la página cambió.\",end_tour:\"Terminar Tour\",retry:\"Reintentar\",click_first:\"⚠️ Por favor haz clic en el elemento resaltado primero\",click_to_continue:\"👆 Haz clic en el elemento resaltado para continuar\"}};class WE extends HTMLElement{constructor(e,t,n=\"en\",i,s=0){super(),this.currentStep=0,this.tourActive=!1,this.currentElement=null,this.stepClickListener=null,this.stepCompleted=!1,this.originalElementStyles=null,this.scrollListener=null,this.overlay=null,this.retryInterval=null,this.steps=[],this.root=this.attachShadow({mode:\"open\"}),this.tourId=e,this.steps=t,this.t=jE[n]||jE.en,this.onTourEndCallback=i,this.startingStep=Math.min(s,t.length-1),this.root.innerHTML='\\n      <style>\\n  :host {\\n    position: fixed;\\n    top: 0;\\n    left: 0;\\n    width: 100%;\\n    height: 100%;\\n    pointer-events: none;\\n    z-index: 1000000;\\n  }\\n\\n  .tour-progress-bar {\\n    position: fixed;\\n    top: 0;\\n    left: 0;\\n    width: 100%;\\n    height: 4px;\\n    background: rgba(255, 255, 255, 0.2);\\n    z-index: 1;\\n    pointer-events: none;\\n  }\\n\\n  .tour-progress-fill {\\n    height: 100%;\\n    background: linear-gradient(90deg, #3b82f6, #60a5fa);\\n    transition: width 0.3s ease;\\n    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);\\n  }\\n\\n  .tour-tooltip {\\n    position: fixed;\\n    background: white;\\n    border-radius: 12px;\\n    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);\\n    padding: 20px;\\n    width: 350px;\\n    height: 250px;\\n    pointer-events: auto;\\n    animation: tooltipFadeIn 0.3s ease;\\n    display: flex;\\n    flex-direction: column;\\n  }\\n\\n  .tour-close-btn {\\n    position: absolute;\\n    top: 8px;\\n    right: 8px;\\n    width: 24px;\\n    height: 24px;\\n    border: none;\\n    background: transparent;\\n    color: #9ca3af;\\n    font-size: 20px;\\n    line-height: 1;\\n    cursor: pointer;\\n    display: flex;\\n    align-items: center;\\n    justify-content: center;\\n    border-radius: 4px;\\n    transition: all 0.2s ease;\\n  }\\n\\n  .tour-close-btn:hover {\\n    background: #f3f4f6;\\n    color: #374151;\\n  }\\n\\n  @keyframes tooltipFadeIn {\\n    from {\\n      opacity: 0;\\n      transform: translateY(-10px);\\n    }\\n    to {\\n      opacity: 1;\\n      transform: translateY(0);\\n    }\\n  }\\n\\n  .tour-tooltip-header {\\n    font-size: 18px;\\n    font-weight: 600;\\n    color: #1f2937;\\n    margin-bottom: 8px;\\n  }\\n\\n  .tour-tooltip-description {\\n    font-size: 14px;\\n    color: #6b7280;\\n    line-height: 1.5;\\n    margin-bottom: 16px;\\n    flex-grow: 1;\\n    overflow-y: auto;\\n    min-height: 0;\\n  }\\n\\n  .tour-tooltip-footer {\\n    display: flex;\\n    justify-content: space-between;\\n    align-items: center;\\n    gap: 16px;\\n    margin-top: auto;\\n  }\\n\\n  .tour-button {\\n    padding: 8px 16px;\\n    border-radius: 6px;\\n    border: none;\\n    font-size: 14px;\\n    font-weight: 500;\\n    cursor: pointer;\\n    transition: all 0.2s ease;\\n  }\\n\\n  .tour-button-primary {\\n    background: #3b82f6;\\n    color: white;\\n  }\\n\\n  .tour-button-primary:hover {\\n    background: #2563eb;\\n    transform: translateY(-1px);\\n  }\\n\\n  .tour-button-secondary {\\n    background: #e5e7eb;\\n    color: #374151;\\n  }\\n\\n  .tour-button-secondary:hover {\\n    background: #d1d5db;\\n  }\\n\\n  .tour-button:disabled {\\n    opacity: 0.5;\\n    cursor: not-allowed;\\n  }\\n\\n  .tour-warning {\\n    background: #fef3c7;\\n    border: 1px solid #f59e0b;\\n    color: #92400e;\\n    padding: 8px 12px;\\n    border-radius: 6px;\\n    font-size: 13px;\\n    margin-bottom: 12px;\\n  }\\n\\n  .tour-click-hint {\\n    background: #eff6ff;\\n    border: 1px solid #3b82f6;\\n    color: #1d4ed8;\\n    padding: 8px 12px;\\n    border-radius: 6px;\\n    font-size: 13px;\\n    margin-top: 12px;\\n    margin-bottom: 8px;\\n  }\\n</style>\\n      <div class=\"tour-progress-bar\">\\n        <div class=\"tour-progress-fill\"></div>\\n      </div>\\n      <div class=\"tour-tooltip\"></div>\\n    '}connectedCallback(){const e=e=>e.stopPropagation();this.addEventListener(\"click\",e),this.addEventListener(\"mousedown\",e),this.addEventListener(\"mouseup\",e),this.addEventListener(\"pointerdown\",e),this.addEventListener(\"pointerup\",e),this.createOverlay(),this.startTour()}disconnectedCallback(){this.cleanup()}createOverlay(){this.overlay=document.createElement(\"div\"),this.overlay.style.cssText=\"\\n      position: fixed;\\n      top: 0;\\n      left: 0;\\n      width: 100%;\\n      height: 100%;\\n      background: rgba(0, 0, 0, 0.5);\\n      z-index: 999998;\\n      pointer-events: none;\\n    \",document.body.appendChild(this.overlay)}updateOverlayHole(e){if(!this.overlay||!e)return;const t=e.getBoundingClientRect(),n=window.getComputedStyle(e),i=parseFloat(n.borderRadius)||0,s=t.left,r=t.top,o=t.width,a=t.height,l=Math.min(i,o/2,a/2),c=`\\n      <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${window.innerWidth}\" height=\"${window.innerHeight}\">\\n        <defs>\\n          <mask id=\"hole\">\\n            <rect width=\"100%\" height=\"100%\" fill=\"white\"/>\\n            <path d=\"${l>0?`M ${s+l} ${r}\\n         L ${s+o-l} ${r}\\n         Q ${s+o} ${r} ${s+o} ${r+l}\\n         L ${s+o} ${r+a-l}\\n         Q ${s+o} ${r+a} ${s+o-l} ${r+a}\\n         L ${s+l} ${r+a}\\n         Q ${s} ${r+a} ${s} ${r+a-l}\\n         L ${s} ${r+l}\\n         Q ${s} ${r} ${s+l} ${r}\\n         Z`:`M ${s} ${r} L ${s+o} ${r} L ${s+o} ${r+a} L ${s} ${r+a} Z`}\" fill=\"black\"/>\\n          </mask>\\n        </defs>\\n        <rect width=\"100%\" height=\"100%\" fill=\"rgba(0,0,0,0.5)\" mask=\"url(#hole)\"/>\\n      </svg>\\n    `;this.overlay.style.background=`url(\"data:image/svg+xml,${encodeURIComponent(c)}\")`,this.overlay.style.clipPath=\"none\"}clearOverlayHole(){this.overlay&&(this.overlay.style.background=\"rgba(0, 0, 0, 0.5)\")}highlightElement(e){this.originalElementStyles={outline:e.style.outline,outlineOffset:e.style.outlineOffset,boxShadow:e.style.boxShadow,animation:e.style.animation};const t=document.createElement(\"style\");t.id=\"blar-tour-pulse-animation\",t.textContent=\"\\n      @keyframes blarTourPulse {\\n        0%, 100% {\\n          box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.4), 0 0 20px rgba(59, 130, 246, 0.3);\\n        }\\n        50% {\\n          box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.3), 0 0 30px rgba(59, 130, 246, 0.4);\\n        }\\n      }\\n    \",document.getElementById(\"blar-tour-pulse-animation\")||document.head.appendChild(t),e.style.outline=\"3px solid #3b82f6\",e.style.outlineOffset=\"4px\",e.style.animation=\"blarTourPulse 2s ease-in-out infinite\",this.updateOverlayHole(e)}removeHighlight(e){e&&this.originalElementStyles&&(e.style.outline=this.originalElementStyles.outline,e.style.outlineOffset=this.originalElementStyles.outlineOffset,e.style.boxShadow=this.originalElementStyles.boxShadow,e.style.animation=this.originalElementStyles.animation,this.clearOverlayHole(),this.originalElementStyles=null)}isXPath(e){return e.startsWith(\"//\")||e.includes(\"contains(\")||e.includes(\"text()\")}findElementByXPath(e){return document.evaluate(e,document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue}findElementBySelector(e){return this.isXPath(e)?this.findElementByXPath(e):document.querySelector(e)}findElement(e){let t=null;try{t=this.findElementBySelector(e.selector)}catch(t){console.warn(`[BlarTour] Invalid selector: ${e.selector}`,t)}if(!t&&e.fallbacks)for(const n of e.fallbacks)try{if(t=this.findElementBySelector(n),t)break}catch(e){console.warn(`[BlarTour] Invalid fallback selector: ${n}`,e)}return t}getElementPosition(e){const t=e.getBoundingClientRect();return{top:t.top+window.scrollY,left:t.left+window.scrollX,width:t.width,height:t.height,bottom:t.bottom+window.scrollY,right:t.right+window.scrollX}}scrollToElement(e){e.scrollIntoView({behavior:\"smooth\",block:\"center\",inline:\"center\"})}updateProgressBar(e){const t=this.root.querySelector(\".tour-progress-fill\");if(t){const n=(e+1)/this.steps.length*100;t.style.width=`${n}%`}}checkPositionFits(e,t,n){const i=20,s=window.innerWidth,r=window.innerHeight;let o,a;switch(n){case\"right\":o=e.top+e.height/2-t.height/2,a=e.right+i;break;case\"left\":o=e.top+e.height/2-t.height/2,a=e.left-t.width-i;break;case\"top\":o=e.top-t.height-i,a=e.left+e.width/2-t.width/2;break;case\"bottom\":o=e.bottom+i,a=e.left+e.width/2-t.width/2;break;default:return null}const l=a>=i&&a+t.width<=s-i,c=o>=i&&o+t.height<=r-i;return{top:o,left:a,fits:l&&c}}positionTooltip(e,t=\"right\"){const n=this.root.querySelector(\".tour-tooltip\");if(!n)return;const i=this.getElementPosition(e),s=n.getBoundingClientRect(),r=[\"bottom\",\"top\",\"right\",\"left\"];r.includes(t)||(t=\"right\");const o=[t,...r.filter(e=>e!==t)];let a,l;for(const e of o){const t=this.checkPositionFits(i,s,e);if(t&&t.fits){a=t.top,l=t.left;break}}if(void 0===a||void 0===l){const e=this.checkPositionFits(i,s,t);if(e){a=e.top,l=e.left;const t=window.innerWidth-s.width-20,n=window.innerHeight-s.height-20;l=Math.max(20,Math.min(l,t)),a=Math.max(20,Math.min(a,n))}}void 0!==a&&void 0!==l&&(n.style.top=`${a}px`,n.style.left=`${l}px`)}updateTooltipContent(e,t,n=null){const i=this.root.querySelector(\".tour-tooltip\");if(!i)return;const s=0===t,r=t===this.steps.length-1,o=\"click\"===e.action;let a=\"\";n&&(a=`<div class=\"tour-warning\">${n}</div>`);const l=o?`<div class=\"tour-click-hint\">${this.t.click_to_continue}</div>`:\"\",c=s?\"\":'<button class=\"tour-button tour-button-secondary\" id=\"prev-btn\">&lt;</button>';let d=\"\";r?o||(d=`<button class=\"tour-button tour-button-primary\" id=\"end-btn\">${this.t.end_tour}</button>`):o||(d='<button class=\"tour-button tour-button-primary\" id=\"next-btn\">&gt;</button>');const u=c||d?`<div class=\"tour-tooltip-footer\">${c}${d}</div>`:\"\";i.innerHTML=`\\n      <button class=\"tour-close-btn\" id=\"close-btn\">×</button>\\n      <div class=\"tour-tooltip-header\">${e.title}</div>\\n      <div class=\"tour-tooltip-description\">${e.description}</div>\\n      ${a}\\n      ${l}\\n      ${u}\\n    `,i.querySelector(\"#close-btn\")?.addEventListener(\"click\",e=>{e.stopPropagation(),this.endTour()});const p=i.querySelector(\"#prev-btn\");p&&p.addEventListener(\"click\",e=>{e.stopPropagation(),this.previousStep()});const h=i.querySelector(\"#next-btn\");h&&h.addEventListener(\"click\",e=>{e.stopPropagation(),this.nextStep()});const g=i.querySelector(\"#end-btn\");g&&g.addEventListener(\"click\",e=>{e.stopPropagation(),this.endTour()})}cleanupCurrentStep(){this.currentElement&&this.removeHighlight(this.currentElement),this.stepClickListener&&this.currentElement&&(this.currentElement.removeEventListener(\"click\",this.stepClickListener),this.stepClickListener=null),this.retryInterval&&(clearInterval(this.retryInterval),this.retryInterval=null),this.currentElement=null,this.stepCompleted=!1}retryFindElement(e,t,n=10){let i=0;const s=this.root.querySelector(\".tour-tooltip\");s&&(s.innerHTML=`\\n      <button class=\"tour-close-btn\" id=\"close-btn\">×</button>\\n      <div class=\"tour-tooltip-header\">${e.title}</div>\\n      <div class=\"tour-warning\">${this.t.waiting}</div>\\n    `,s.querySelector(\"#close-btn\")?.addEventListener(\"click\",e=>{e.stopPropagation(),this.endTour()}),this.retryInterval=setInterval(()=>{const s=this.findElement(e);if(s)return this.retryInterval&&clearInterval(this.retryInterval),this.retryInterval=null,void this.continueWithElement(s,e,t);i++,i>=n&&(console.warn(`[BlarTour] Element not found after ${n} retries`),this.retryInterval&&clearInterval(this.retryInterval),this.retryInterval=null,this.showRetryUI(e,t))},500))}showRetryUI(e,t){const n=this.root.querySelector(\".tour-tooltip\");n&&(n.innerHTML=`\\n      <button class=\"tour-close-btn\" id=\"close-btn\">×</button>\\n      <div class=\"tour-tooltip-header\">${e.title}</div>\\n      <div class=\"tour-warning\">${this.t.not_found}</div>\\n      <div class=\"tour-tooltip-footer\">\\n        <button class=\"tour-button tour-button-primary\" id=\"retry-btn\">${this.t.retry}</button>\\n      </div>\\n    `,n.querySelector(\"#close-btn\")?.addEventListener(\"click\",e=>{e.stopPropagation(),this.endTour()}),n.querySelector(\"#retry-btn\")?.addEventListener(\"click\",n=>{n.stopPropagation(),this.retryFindElement(e,t)}))}continueWithElement(e,t,n){this.currentElement=e,this.scrollToElement(e),setTimeout(()=>{this.highlightElement(e),this.updateTooltipContent(t,n),this.positionTooltip(e,t.position||\"right\"),this.updateProgressBar(n),\"click\"===t.action?(this.stepClickListener=()=>{this.stepCompleted=!0;const e=this.currentStep+1;e<this.steps.length&&DE(this.tourId,e),this.nextStep()},e.addEventListener(\"click\",this.stepClickListener)):this.stepCompleted=!0},500)}showStep(e){if(e<0||e>=this.steps.length)return void this.endTour();this.cleanupCurrentStep(),this.currentStep=e,DE(this.tourId,e);const t=this.steps[this.currentStep],n=this.findElement(t);if(!n)return console.warn(`[BlarTour] Element not found for step ${e+1}: ${t.selector}, starting retry`),void this.retryFindElement(t,e);this.continueWithElement(n,t,e)}nextStep(){const e=this.steps[this.currentStep];if(\"click\"===e.action&&!this.stepCompleted)return void this.updateTooltipContent(e,this.currentStep,this.t.click_first);const t=e.delay_ms??(\"click\"===e.action?500:0);setTimeout(()=>{this.currentStep<this.steps.length-1?this.showStep(this.currentStep+1):this.endTour()},t)}previousStep(){this.currentStep>0&&this.showStep(this.currentStep-1)}startTour(){this.tourActive||(this.tourActive=!0,this.scrollListener=()=>{if(this.currentElement){const e=this.steps[this.currentStep];this.positionTooltip(this.currentElement,e.position||\"right\"),this.updateOverlayHole(this.currentElement)}},window.addEventListener(\"scroll\",this.scrollListener,!0),window.addEventListener(\"resize\",this.scrollListener),this.showStep(this.startingStep))}endTour(){this.tourActive=!1,this.cleanup(),zE(),window.dispatchEvent(new CustomEvent(\"blar-tour-ended\")),this.onTourEndCallback&&this.onTourEndCallback(),os(this)}cleanup(){this.cleanupCurrentStep(),this.scrollListener&&(window.removeEventListener(\"scroll\",this.scrollListener,!0),window.removeEventListener(\"resize\",this.scrollListener),this.scrollListener=null),this.overlay&&(os(this.overlay),this.overlay=null);const e=document.getElementById(\"blar-tour-pulse-animation\");e&&os(e)}}customElements.get(\"blar-tour\")||customElements.define(\"blar-tour\",WE);class VE{constructor(){this.activeTour=null,this.tourActive=!1}startTour(e,t,n=\"en\",i,s=0){this.stopActiveTour(),this.tourActive=!0,this.activeTour=new WE(e,t.steps,n,()=>{this.tourActive=!1,this.activeTour=null,i&&i()},s),document.body.appendChild(this.activeTour)}stopActiveTour(){this.activeTour&&(os(this.activeTour),this.activeTour=null);const e=document.getElementById(\"blar-tour-pulse-animation\");e&&os(e)}cleanup(){this.stopActiveTour()}isTourActive(){return this.tourActive}}const GE={image:10485760,video:209715200,audio:10485760,document:20971520},KE={image:[\"image/png\",\"image/jpeg\",\"image/jpg\",\"image/gif\",\"image/webp\"],video:[\"video/mp4\",\"video/quicktime\",\"video/x-msvideo\",\"video/webm\"],audio:[\"audio/mpeg\",\"audio/mp3\",\"audio/webm\",\"audio/ogg\",\"audio/opus\",\"audio/wav\",\"audio/wave\",\"audio/x-wav\",\"audio/aac\",\"audio/x-aac\",\"audio/mp4\",\"audio/x-m4a\",\"audio/amr\"],document:[\"application/pdf\",\"application/msword\",\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\"text/plain\",\"application/vnd.ms-excel\",\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\"application/vnd.ms-powerpoint\",\"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\"text/csv\"]},YE=262144e3;function XE(e){if(0===e)return\"0 Bytes\";const t=Math.floor(Math.log(e)/Math.log(1024));return Math.round(e/Math.pow(1024,t)*100)/100+\" \"+[\"Bytes\",\"KB\",\"MB\",\"GB\"][t]}function JE(e){const t=Na(),n=(i=e.type).startsWith(\"image/\")?\"image\":i.startsWith(\"video/\")?\"video\":i.startsWith(\"audio/\")?\"audio\":\"document\";var i;if(!KE[n].includes(e.type))return{valid:!1,error:t.validation.fileTypeNotSupported(e.type)};const s=GE[n];return e.size>s?{valid:!1,error:t.validation.fileSizeExceeds(XE(s),n)}:0===e.size?{valid:!1,error:t.validation.fileEmpty}:{valid:!0}}function QE(e){const t=Na();if(0===e.length)return{valid:!1,error:t.validation.noFilesSelected};if(e.length>5)return{valid:!1,error:t.validation.maxFilesExceeded(5)};for(const t of e){const e=JE(t);if(!e.valid)return{...e,error:`${t.name}: ${e.error}`}}return e.reduce((e,t)=>e+t.size,0)>YE?{valid:!1,error:t.validation.totalSizeExceeds(XE(YE))}:{valid:!0}}class ZE{constructor(e,t={}){this.uploadProgress=new Map,this.apiClient=e,this.callbacks=t}async uploadFiles(e){const t=QE(e);if(!t.valid){const e=t.error||Na().attachments.uploadFailed;throw this.handleError(e),new Error(e)}try{this.initializeProgress(e);const t=e.map(e=>({name:e.name,type:e.type,size:e.size})),n=await this.apiClient.prepareUpload({files:t});await this.uploadToGCS(e,n.upload_configs);const i=n.upload_configs.map(e=>e.upload_token),s=await this.apiClient.verifyUploads({upload_tokens:i}),r=Array.isArray(s)?s:s.attachments||[];return this.markAllCompleted(),this.callbacks.onComplete?.(r),r}catch(e){throw Ji(\"[AttachmentManager] Upload error\",e),this.handleError(Na().attachments.uploadFailed),e}}initializeProgress(e){this.uploadProgress.clear(),e.forEach(e=>{this.uploadProgress.set(e.name,{file:e,progress:0,status:\"pending\"})}),this.notifyProgress()}async uploadToGCS(e,t){const n=e.map(async(e,n)=>{const i=t[n],s=this.uploadProgress.get(e.name);s&&(s.status=\"uploading\",s.progress=0,this.notifyProgress());try{await this.apiClient.uploadToGCS(e,i.upload_url,i.max_size,i.content_type),s&&(s.status=\"processing\",s.progress=100,this.notifyProgress())}catch(e){throw s&&(s.status=\"error\",s.error=e instanceof Error?e.message:\"Upload failed\",this.notifyProgress()),e}});await Promise.all(n)}markAllCompleted(){this.uploadProgress.forEach(e=>{e.status=\"completed\",e.progress=100}),this.notifyProgress()}handleError(e){this.uploadProgress.forEach(t=>{\"completed\"!==t.status&&(t.status=\"error\",t.error=e)}),this.notifyProgress(),this.callbacks.onError?.(e)}notifyProgress(){const e=Array.from(this.uploadProgress.values());this.callbacks.onProgress?.(e)}getProgress(){return Array.from(this.uploadProgress.values())}clearProgress(){this.uploadProgress.clear()}}class eM{constructor(e){this.cache=new Map,this.inFlight=new Map,this.waiting=[],this.active=0,this.apiClient=e}getUrl(e){const t=this.cache.get(e);if(t&&Date.now()<t.expiresAt-3e5)return Promise.resolve(t.url);const n=this.inFlight.get(e);if(n)return n;const i=this.fetchUrl(e).finally(()=>this.inFlight.delete(e));return this.inFlight.set(e,i),i}async fetchUrl(e){await this.takeSlot();try{const t=Date.now(),n=await this.apiClient.getAttachmentUrl(e);return this.cache.set(e,{url:n.download_url,expiresAt:t+1e3*n.expires_in}),n.download_url}finally{this.releaseSlot()}}takeSlot(){return this.active<4?(this.active+=1,Promise.resolve()):new Promise(e=>this.waiting.push(e))}releaseSlot(){const e=this.waiting.pop();e?e():this.active-=1}}class tM{constructor(e){this.root=null,this.state=\"idle\",this.recorderEl=null,this.current=null,this.previewBars=[],this.pushLevel=null,this.isSending=!1,this.restoredPreviewUrl=null,this.callbacks=e,this.recorder=new vc({onRecordingStart:()=>this.handleRecordingStart(),onReview:e=>this.handleReview(e),onIdle:()=>this.teardown(),onError:e=>this.handleError(e),onTick:e=>this.handleTick(e),onLevel:e=>this.pushLevel?.(e)})}attach(e){this.root=e,\"idle\"===this.state||this.recorderEl&&this.recorderEl.isConnected||(this.recorder.destroy(),this.teardown());const t=e.querySelector(\".support-mic-btn\"),n=e.querySelector(\".support-chat-input\");t?.addEventListener(\"click\",()=>{this.callbacks.canRecord()&&\"idle\"===this.state&&this.recorder.start()}),n?.addEventListener(\"input\",()=>this.syncMicSlot()),this.syncMicSlot()}syncMicSlot(){if(!this.root)return;const e=this.root.querySelector(\".support-mic-btn\"),t=this.root.querySelector(\".support-send-btn\"),n=this.root.querySelector(\".support-chat-input\");if(!e||!t||!n)return;const i=bc()&&this.callbacks.canRecord()&&!this.callbacks.hasSelectedFiles()&&0===n.value.trim().length;e.hidden=!i,t.hidden=i}cancelActive(){\"idle\"!==this.state&&this.recorder.cancel()}destroy(){this.recorder.destroy(),this.teardown()}getInputContainer(){return this.root?.querySelector(\".support-input-container\")||null}el(e){return this.recorderEl?.querySelector(`[data-el=\"${e}\"]`)||null}setState(e){this.state=e,this.recorderEl&&(this.recorderEl.dataset.state=e),\"review\"!==e&&this.el(\"preview-audio\")?.pause()}buildRecorderUI(){const e=this.getInputContainer();if(!e)return;const t=Na(),n=document.createElement(\"div\");n.className=\"support-voice-recorder\",n.innerHTML=`\\n      <div class=\"support-voice-budget\" data-only=\"recording\">\\n        <div class=\"support-voice-budget-track\"><div class=\"support-voice-budget-fill\" data-el=\"budget\"></div></div>\\n        <span class=\"support-voice-budget-max\">${yc(300)}</span>\\n      </div>\\n      <div class=\"support-voice-row\">\\n        <button type=\"button\" class=\"support-voice-trash\" data-act=\"discard\" aria-label=\"${t.voiceNotes.discard}\" title=\"${t.voiceNotes.discard}\">\\n          <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z\"/></svg>\\n        </button>\\n        <div class=\"support-voice-bar\">\\n          <span class=\"support-voice-dot\" data-only=\"recording\"></span>\\n          <span class=\"support-voice-time\" data-el=\"timer\" data-only=\"recording\">0:00</span>\\n          <div class=\"support-voice-wave\" data-el=\"live-wave\" data-only=\"recording\"></div>\\n          <button type=\"button\" class=\"support-voice-play\" data-act=\"preview\" data-only=\"review\" aria-label=\"${t.voiceNotes.playPreview}\">\\n            <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M8 5.5v13a1 1 0 0 0 1.54.84l10-6.5a1 1 0 0 0 0-1.68l-10-6.5A1 1 0 0 0 8 5.5z\"/></svg>\\n          </button>\\n          <div class=\"support-voice-wave\" data-el=\"preview-wave\" data-only=\"review\"></div>\\n          <span class=\"support-voice-time\" data-el=\"review-time\" data-only=\"review\">0:00</span>\\n          <span class=\"support-voice-status\" data-only=\"uploading\">${t.voiceNotes.sending}</span>\\n        </div>\\n        <button type=\"button\" class=\"support-voice-action\" data-act=\"stop\" data-only=\"recording\" aria-label=\"${t.voiceNotes.stop}\" title=\"${t.voiceNotes.stop}\">\\n          <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><rect x=\"6\" y=\"6\" width=\"12\" height=\"12\" rx=\"2.5\"/></svg>\\n        </button>\\n        <button type=\"button\" class=\"support-voice-action\" data-act=\"send\" data-only=\"review uploading\" aria-label=\"${t.voiceNotes.send}\" title=\"${t.voiceNotes.send}\">\\n          <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\" data-only=\"review\"><path d=\"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z\"/></svg>\\n          <span class=\"support-voice-spinner\" data-only=\"uploading\"></span>\\n        </button>\\n      </div>\\n      <audio data-el=\"preview-audio\" preload=\"metadata\" hidden></audio>\\n    `,n.addEventListener(\"click\",e=>{const t=e.target.closest(\"[data-act]\");if(t)switch(t.dataset.act){case\"discard\":\"uploading\"!==this.state&&(this.callbacks.onDraftChanged(null),this.recorder.cancel());break;case\"stop\":this.recorder.stop();break;case\"send\":this.sendCurrent();break;case\"preview\":this.togglePreview()}});const i=n.querySelector('[data-el=\"preview-audio\"]');i.addEventListener(\"timeupdate\",()=>{if(!this.current||0===this.previewBars.length)return;const e=Number.isFinite(i.duration)&&i.duration>0?i.duration:this.current.durationSeconds;Mc(this.previewBars,this.current.peaks,Math.min(1,i.currentTime/e))}),i.addEventListener(\"ended\",()=>{this.current&&Mc(this.previewBars,this.current.peaks,0)}),e.appendChild(n),e.classList.add(\"voice-active\"),this.recorderEl=n}handleRecordingStart(){if(this.recorderEl&&this.recorderEl.isConnected||this.buildRecorderUI(),!this.recorderEl)return;const e=this.el(\"timer\");e&&(e.textContent=\"0:00\");const t=this.el(\"budget\");t&&(t.style.width=\"0%\",t.classList.remove(\"is-near\"));const n=this.el(\"live-wave\");if(n){const e=Ec(n,28);e.forEach(e=>e.classList.add(\"is-on\"));const t=new Array(e.length).fill(0);let i=0;this.pushLevel=n=>{const s=performance.now();if(!(s-i<55)){i=s,t.shift(),t.push(n);for(let n=0;n<e.length;n++)e[n].style.transform=\"scaleY(\"+Math.max(.14,t[n])+\")\"}}}this.setState(\"recording\")}handleTick(e){const t=this.el(\"timer\");t&&(t.textContent=yc(e));const n=this.el(\"budget\");if(n){const t=Math.min(1,e/300);n.style.width=100*t+\"%\",n.classList.toggle(\"is-near\",t>=.9)}}handleReview(e){this.enterReview(e),this.callbacks.onDraftChanged(e)}enterReview(e){this.current=e,this.pushLevel=null;const t=this.el(\"preview-wave\");t&&(this.previewBars=Ec(t,e.peaks.length),Mc(this.previewBars,e.peaks,0));const n=this.el(\"review-time\");n&&(n.textContent=yc(e.durationSeconds));const i=this.el(\"preview-audio\");i&&(i.src=e.previewUrl),this.setState(\"review\")}restoreDraft(e){\"idle\"===this.state&&this.callbacks.canRecord()&&(this.recorderEl&&this.recorderEl.isConnected||this.buildRecorderUI(),this.recorderEl&&(this.restoredPreviewUrl=URL.createObjectURL(e.file),this.enterReview({...e,previewUrl:this.restoredPreviewUrl})))}handleError(e){this.teardown(),this.callbacks.onError(e)}togglePreview(){const e=this.el(\"preview-audio\");e&&(e.paused?e.play():e.pause())}async sendCurrent(){if(!this.current||this.isSending)return;this.isSending=!0,this.setState(\"uploading\");const e=this.current;try{await this.callbacks.onSend(e),this.callbacks.onDraftChanged(null),this.recorder.cancel()}catch(t){Ji(\"[VoiceNoteComposer] Voice note send failed\",t),this.current=e,this.setState(\"review\"),this.callbacks.onError(\"sendFailed\")}finally{this.isSending=!1}}teardown(){this.state=\"idle\",this.current=null,this.pushLevel=null,this.previewBars=[],this.restoredPreviewUrl&&(URL.revokeObjectURL(this.restoredPreviewUrl),this.restoredPreviewUrl=null),this.recorderEl&&(os(this.recorderEl),this.recorderEl=null),this.getInputContainer()?.classList.remove(\"voice-active\"),this.syncMicSlot()}}const nM=\"drafts\";async function iM(e,t){const n=await new Promise((e,t)=>{if(\"undefined\"==typeof indexedDB)return void t(new Error(\"IndexedDB unavailable\"));const n=indexedDB.open(\"support_widget_voice_drafts\",2);n.onupgradeneeded=()=>{const e=n.result;e.objectStoreNames.contains(nM)&&e.deleteObjectStore(nM),e.createObjectStore(nM,{keyPath:\"conversationKey\"})},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error)});try{return await new Promise((i,s)=>{const r=t(n.transaction(nM,e).objectStore(nM));r.onsuccess=()=>i(r.result),r.onerror=()=>s(r.error)})}finally{n.close()}}const sM={async save(e,t){try{const n={conversationKey:e,blob:t.file,fileName:t.file.name,mimeType:t.file.type,durationSeconds:t.durationSeconds,peaks:t.peaks,createdAt:s()};await iM(\"readwrite\",e=>e.put(n))}catch{}},async load(e){try{const t=await iM(\"readonly\",t=>t.get(e));return t?s()-t.createdAt>864e5?(this.clear(e),null):{file:new File([t.blob],t.fileName,{type:t.mimeType}),durationSeconds:t.durationSeconds,peaks:t.peaks}:null}catch{return null}},async clear(e){try{await iM(\"readwrite\",t=>t.delete(e))}catch{}}};class rM{constructor(e,t,n,i){this.isSubmitting=!1,this.originalChatBodyContent=\"\",this.config=e,this.container=t,this.apiClient=n,this.callbacks=i,this.translations=Na()}shouldShowForm(e,t){return!!this.config.enabled&&(!t&&!e)}renderForm(){const e=this.container.querySelector(\".support-chat-body\");if(!e)return;this.originalChatBodyContent=e.innerHTML;const t=this.container.querySelector(\".support-input-container\");t&&(t.style.display=\"none\");const n=this.config.title||this.translations.preChatForm.defaultTitle,i=this.config.subtitle||this.translations.preChatForm.defaultSubtitle,s=this.config.submitButtonText||this.translations.preChatForm.defaultSubmitButton,r=this.config.fields.map(e=>this.renderField(e)).join(\"\");e.innerHTML=`\\n      <div class=\"support-prechat-form-container\">\\n        <div class=\"support-prechat-form-header\">\\n          <h4 class=\"support-prechat-title\">${n}</h4>\\n          <p class=\"support-prechat-subtitle\">${i}</p>\\n        </div>\\n        <form class=\"support-prechat-form\" novalidate>\\n          ${r}\\n          <button type=\"submit\" class=\"support-prechat-submit\">${s}</button>\\n        </form>\\n      </div>\\n    `,this.attachEventListeners()}renderField(e){const t=this.translations.preChatForm.labels[e.type],n=this.translations.preChatForm.placeholders[e.type],i=e.required?'<span class=\"required-indicator\">*</span>':\"\",s=this.getInputType(e.type);return`\\n      <div class=\"support-prechat-field\" data-field-type=\"${e.type}\">\\n        <label for=\"support-prechat-${e.type}\">${t}${i}</label>\\n        <input\\n          type=\"${s}\"\\n          id=\"support-prechat-${e.type}\"\\n          name=\"${e.type}\"\\n          placeholder=\"${n}\"\\n          ${e.required?\"required\":\"\"}\\n          autocomplete=\"${this.getAutoComplete(e.type)}\"\\n        />\\n        <span class=\"support-prechat-error\"></span>\\n      </div>\\n    `}getInputType(e){switch(e){case\"email\":return\"email\";case\"phone\":return\"tel\";default:return\"text\"}}getAutoComplete(e){switch(e){case\"name\":return\"name\";case\"email\":return\"email\";case\"phone\":return\"tel\";default:return\"off\"}}attachEventListeners(){const e=this.container.querySelector(\".support-prechat-form\");e&&(e.addEventListener(\"submit\",e=>{e.preventDefault(),this.handleSubmit()}),this.config.fields.forEach(t=>{const n=e.querySelector(`#support-prechat-${t.type}`);n&&n.addEventListener(\"input\",()=>{this.clearFieldError(t.type)})}))}async handleSubmit(){if(this.isSubmitting)return;const e=this.container.querySelector(\".support-prechat-form\");if(!e)return;const t=this.getFormData(e),n=this.validateForm(t);if(!n.valid)return void this.showErrors(n.errors);this.isSubmitting=!0;const i=e.querySelector(\".support-prechat-submit\");i&&(i.disabled=!0,i.textContent=this.translations.preChatForm.submitting,i.classList.add(\"loading\"));try{await this.apiClient.submitPreChatForm(t),this.hideForm(),this.callbacks.onFormComplete(t)}catch(e){Ji(\"[PreChatFormManager] Failed to submit form\",e),this.showSubmitError()}finally{this.isSubmitting=!1,i&&(i.disabled=!1,i.textContent=this.config.submitButtonText||this.translations.preChatForm.defaultSubmitButton,i.classList.remove(\"loading\"))}}getFormData(e){const t={};return this.config.fields.forEach(n=>{const i=e.querySelector(`#support-prechat-${n.type}`);i&&i.value.trim()&&(t[n.type]=i.value.trim())}),t}validateForm(e){const t={},n=this.translations.preChatForm;for(const i of this.config.fields){const s=e[i.type];if(!i.required||s&&\"\"!==s.trim()){if(s&&\"email\"===i.type){/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(s)||(t[i.type]=n.validation.invalidEmail)}if(s&&\"phone\"===i.type){/^[\\d\\s\\-+()]{7,}$/.test(s)||(t[i.type]=n.validation.invalidPhone)}}else t[i.type]=n.validation.required}return{valid:0===Object.keys(t).length,errors:t}}showErrors(e){Object.entries(e).forEach(([e,t])=>{const n=this.container.querySelector(`.support-prechat-field[data-field-type=\"${e}\"]`);if(!n)return;const i=n.querySelector(\"input\"),s=n.querySelector(\".support-prechat-error\");i&&i.classList.add(\"error\"),s&&(s.textContent=t)})}clearFieldError(e){const t=this.container.querySelector(`.support-prechat-field[data-field-type=\"${e}\"]`);if(!t)return;const n=t.querySelector(\"input\"),i=t.querySelector(\".support-prechat-error\");n&&n.classList.remove(\"error\"),i&&(i.textContent=\"\")}showSubmitError(){const e=this.container.querySelector(\".support-prechat-form\");if(!e)return;let t=e.querySelector(\".support-prechat-submit-error\");if(!t){t=document.createElement(\"div\"),t.className=\"support-prechat-submit-error support-prechat-error\",t.style.textAlign=\"center\",t.style.marginTop=\"8px\";const n=e.querySelector(\".support-prechat-submit\");n&&n.insertAdjacentElement(\"afterend\",t)}t.textContent=this.translations.preChatForm.submitError}hideForm(){const e=this.container.querySelector(\".support-chat-body\");if(!e)return;e.innerHTML=this.originalChatBodyContent;const t=this.container.querySelector(\".support-input-container\");t&&(t.style.display=\"\")}}class oM{constructor(e,t){this.bubbleEl=null,this.anchorEl=null,this.trackHandler=null,this.trackRaf=0,this.container=e,this.callbacks=t}isVisible(){return null!==this.bubbleEl}show(e){this.bubbleEl&&this.hide(),this.callbacks.isChatOpen()||this.mount(this.build(e))}hide(){this.stopTracking(),this.bubbleEl&&(os(this.bubbleEl),this.bubbleEl=null,this.container.classList.remove(\"has-awareness-nudge\")),this.anchorEl=null}build(e){const t=Boolean(e.sender||e.progress)?this.buildRichCard(e):this.buildSimpleBubble(e),n=e.onClick;return n&&!e.confirm&&t.addEventListener(\"click\",()=>n()),t}buildSimpleBubble(e){const t=document.createElement(\"div\");t.className=\"support-awareness-bubble\";const n=document.createElement(\"span\");return n.className=\"support-awareness-message\",n.textContent=e.message,t.appendChild(n),t.appendChild(this.buildDismiss(e)),t}buildRichCard(e){const t=document.createElement(\"div\");t.className=\"support-awareness-bubble support-nudge-card\",e.progress&&e.progress.total>0&&t.appendChild(this.buildProgress(e.progress));const n=document.createElement(\"div\");n.className=\"support-nudge-header\",e.sender&&(n.appendChild(this.buildAvatar(e.sender)),n.appendChild(this.buildSender(e.sender))),n.appendChild(this.buildDismiss(e)),t.appendChild(n);const i=document.createElement(\"p\");i.className=\"support-nudge-message\",i.textContent=e.message,t.appendChild(i);const s=e.confirm;return s?(t.classList.add(\"support-nudge-card--confirm\"),e.ctaLabel&&t.appendChild(this.buildCta(e.ctaLabel,!1)),t.appendChild(this.buildConfirm(s))):e.onClick&&e.ctaLabel&&t.appendChild(this.buildCta(e.ctaLabel,!0)),t}buildProgress(e){const t=document.createElement(\"div\");t.className=\"support-nudge-progress\";const n=Math.max(1,Math.floor(e.total)),i=Math.max(0,Math.min(Math.floor(e.completed),n));for(let e=0;e<n;e++){const n=document.createElement(\"span\");n.className=\"support-nudge-progress-seg\",e<i&&n.classList.add(\"is-done\"),t.appendChild(n)}return t}buildAvatar(e){const t=document.createElement(\"div\");if(t.className=\"support-nudge-avatar\",e.avatarUrl){const n=document.createElement(\"img\");n.src=e.avatarUrl,n.alt=\"\",n.addEventListener(\"error\",()=>{this.renderAvatarFallback(t,e)}),t.appendChild(n)}else this.renderAvatarFallback(t,e);return t}renderAvatarFallback(e,t){this.isBlarPersona(t.name)?(e.classList.add(\"support-nudge-avatar--bot\"),e.innerHTML=`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${L}</svg>`):(e.classList.remove(\"support-nudge-avatar--bot\"),e.textContent=as(t.name))}isBlarPersona(e){return e.trim().toLowerCase()===\"Blar\".toLowerCase()}buildSender(e){const t=document.createElement(\"div\");t.className=\"support-nudge-who\";const n=document.createElement(\"span\");if(n.className=\"support-nudge-name\",n.textContent=e.name,t.appendChild(n),e.subtitle){const n=document.createElement(\"span\");n.className=\"support-nudge-subtitle\",n.textContent=e.subtitle,t.appendChild(n)}return t}buildCta(e,t){const n=document.createElement(\"div\");n.className=\"support-nudge-cta\";const i=document.createElement(\"span\");i.className=\"support-nudge-cta-icon\",i.innerHTML='<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" width=\"16\" height=\"16\"><circle cx=\"12\" cy=\"12\" r=\"9\"></circle><polyline points=\"12 7 12 12 15 14\"></polyline></svg>';const s=document.createElement(\"span\");if(s.className=\"support-nudge-cta-label\",s.textContent=e,n.appendChild(i),n.appendChild(s),t){const e=document.createElement(\"span\");e.className=\"support-nudge-cta-arrow\",e.innerHTML='<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" width=\"18\" height=\"18\"><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"></line><polyline points=\"12 5 19 12 12 19\"></polyline></svg>',n.appendChild(e)}return n}buildConfirm(e){const t=document.createElement(\"div\");if(t.className=\"support-nudge-confirm\",e.prompt){const n=document.createElement(\"p\");n.className=\"support-nudge-confirm-prompt\",n.textContent=e.prompt,t.appendChild(n)}const n=document.createElement(\"div\");n.className=\"support-interactive-button-group horizontal\",n.appendChild(this.buildConfirmButton(e.acceptLabel,\"primary\",()=>e.onAccept())),n.appendChild(this.buildConfirmButton(e.declineLabel,\"\",()=>{e.onDecline(),this.hide()}));const{laterLabel:i,onLater:s}=e;return i&&n.appendChild(this.buildConfirmButton(i,\"\",()=>{s?.(),this.hide()})),t.appendChild(n),t}buildConfirmButton(e,t,n){const i=document.createElement(\"button\");return i.type=\"button\",i.className=\"support-interactive-button pill\"+(t?` ${t}`:\"\"),i.textContent=e,i.addEventListener(\"click\",e=>{e.stopPropagation(),n()}),i}buildDismiss(e){const t=document.createElement(\"button\");return t.className=\"support-awareness-dismiss\",t.setAttribute(\"aria-label\",e.dismissLabel),t.textContent=\"✕\",t.addEventListener(\"click\",t=>{t.stopPropagation(),e.onDismiss?.(),this.hide()}),t}mount(e){this.container.appendChild(e),this.container.classList.add(\"has-awareness-nudge\"),this.bubbleEl=e;const t=this.resolveAnchor();t&&this.isOnScreen(t)?(this.anchorEl=t,e.classList.add(\"support-awareness-bubble--anchored\"),this.positionToAnchor(),this.startTracking()):this.callbacks.isWidgetHidden?.()&&e.classList.add(\"support-awareness-bubble--toast\")}resolveAnchor(){const e=this.callbacks.getAnchor?.();if(e&&e.isConnected)return e;const t=document.querySelector(\"[data-blar-nudge-anchor]\");return t instanceof HTMLElement?t:null}isOnScreen(e){const t=e.getBoundingClientRect();return!(t.width<=0||t.height<=0)&&(t.bottom>0&&t.right>0&&t.top<window.innerHeight&&t.left<window.innerWidth)}positionToAnchor(){const e=this.anchorEl,t=this.bubbleEl;if(!e||!t)return;const n=e.getBoundingClientRect();if(n.width<=0||n.height<=0)return void this.hide();const i=t.getBoundingClientRect(),s=n.top<window.innerHeight/2;let r=s?n.bottom+10:n.top-i.height-10,o=n.left+n.width/2-i.width/2;o=Math.max(8,Math.min(o,window.innerWidth-i.width-8)),r=Math.max(8,Math.min(r,window.innerHeight-i.height-8)),t.style.top=`${Math.round(r)}px`,t.style.left=`${Math.round(o)}px`,t.classList.toggle(\"support-awareness-bubble--above\",!s),t.classList.toggle(\"support-awareness-bubble--below\",s);const a=n.left+n.width/2-o;t.style.setProperty(\"--awareness-arrow-x\",`${Math.round(a)}px`)}startTracking(){const e=()=>{this.trackRaf||(this.trackRaf=requestAnimationFrame(()=>{this.trackRaf=0,!this.anchorEl||this.anchorEl.isConnected?this.positionToAnchor():this.hide()}))};this.trackHandler=e,window.addEventListener(\"scroll\",e,!0),window.addEventListener(\"resize\",e)}stopTracking(){this.trackHandler&&(window.removeEventListener(\"scroll\",this.trackHandler,!0),window.removeEventListener(\"resize\",this.trackHandler),this.trackHandler=null),this.trackRaf&&(cancelAnimationFrame(this.trackRaf),this.trackRaf=0)}}class aM{constructor(e,t,n,i=null){this.clicking=!1,this.apiClient=t,this.callbacks=n,this.testId=i,this.bubble=new oM(e,{isChatOpen:()=>this.callbacks.isChatOpen(),getAnchor:this.callbacks.getAnchor,isWidgetHidden:this.callbacks.isWidgetHidden})}showMessage(e){this.callbacks.isChatOpen()||this.bubble.show({message:e,dismissLabel:Na().awareness.dismiss})}async checkForNudge(e){try{const t=this.testId?await this.apiClient.awarenessPreview(this.testId):await this.apiClient.awarenessMatch(e);if(!t)return;if(this.callbacks.isChatOpen())return;if(this.callbacks.isSuppressed?.())return;if(this.testId)return void this.handleClick(t,e);this.showBubble(t,e)}catch{}}showBubble(e,t){const n=e.bubble_icon?`${e.bubble_icon} `:\"\";this.bubble.show({message:`${n}${e.bubble_message}`,dismissLabel:Na().awareness.dismiss,onClick:()=>this.handleClick(e,t),onDismiss:()=>this.handleDismiss(e)}),this.apiClient.awarenessImpression(e.uuid,t,null!==this.testId).catch(()=>{})}hideBubble(){this.bubble.hide()}async handleClick(e,t){if(!this.clicking){this.clicking=!0;try{const n=await this.apiClient.awarenessClick(e.uuid,t,null!==this.testId);this.bubble.hide(),this.callbacks.onNudgeClick(n.session_id)}catch{this.callbacks.onError(Na().awareness.clickError)}finally{this.clicking=!1}}}handleDismiss(e){this.apiClient.awarenessDismiss(e.uuid,null!==this.testId).catch(()=>{})}cleanup(){this.bubble.hide()}}const lM=[\"mousemove\",\"keydown\",\"scroll\",\"click\",\"touchstart\"];class cM{constructor(e,t){this.transport=null,this.timer=null,this.lastInteraction=0,this.lastActivityProcessed=0,this.inFlight=!1,this.started=!1,this.completionSourceId=null,this.acknowledgedCompletionSourceId=null,this.completionMismatchCount=0,this.completionPaused=!1,this.handleActivity=()=>{const e=s();if(e-this.lastActivityProcessed<1e3)return void(this.lastInteraction=e);const t=!this.isPresent();this.lastActivityProcessed=e,this.lastInteraction=e,t&&this.fireNow()},this.handleVisibilityChange=()=>{\"visible\"===document.visibilityState&&this.fireNow()},this.apiClient=e,this.onPendingNudge=t.onPendingNudge,this.onConversation=t.onConversation,this.onCompletionRecorded=t.onCompletionRecorded,this.onCompletionMismatch=t.onCompletionMismatch,this.completionStorageKey=t.completionStorageKey??\"support_widget_intro_completion_pending\"}readStoredCompletion(){try{return localStorage.getItem(this.completionStorageKey)}catch{return null}}storeCompletion(e){try{localStorage.setItem(this.completionStorageKey,e)}catch{}}clearStoredCompletion(e){try{localStorage.getItem(this.completionStorageKey)===e&&localStorage.removeItem(this.completionStorageKey)}catch{}}syncSource(){const e=this.apiClient.getSourceId(),t=this.readStoredCompletion();t&&t!==e&&this.clearStoredCompletion(t),this.completionSourceId&&this.completionSourceId!==e&&(this.completionSourceId=null,this.completionMismatchCount=0,this.completionPaused=!1),e&&t===e&&this.acknowledgedCompletionSourceId!==e&&(this.completionSourceId=e)}setTransport(e){this.transport=e}beatNow(){this.started&&this.fireNow()}completeIntroPresentation(){this.syncSource();const e=this.apiClient.getSourceId();e&&this.completionSourceId!==e&&this.acknowledgedCompletionSourceId!==e&&(this.completionSourceId=e,this.completionMismatchCount=0,this.completionPaused=!1,this.storeCompletion(e),this.started&&!this.inFlight&&this.send())}start(){if(!this.started){this.syncSource(),this.started=!0,this.lastInteraction=s();for(const e of lM)window.addEventListener(e,this.handleActivity,{passive:!0});document.addEventListener(\"visibilitychange\",this.handleVisibilityChange),this.fireNow(),this.completionSourceId&&!this.inFlight&&this.send()}}stop(){if(this.started){this.started=!1,null!==this.timer&&(clearTimeout(this.timer),this.timer=null);for(const e of lM)window.removeEventListener(e,this.handleActivity);document.removeEventListener(\"visibilitychange\",this.handleVisibilityChange)}}isPresent(){return\"visible\"===document.visibilityState&&s()-this.lastInteraction<=18e4}fireNow(){this.isPresent()&&this.send(),this.scheduleNext()}scheduleNext(){null!==this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.isPresent()&&this.send(),this.scheduleNext()},3e4)}async send(){const e=this.apiClient.getSourceId();if(!e||!this.started)return;this.syncSource();const t=this.completionSourceId===e&&!this.completionPaused;if(!t&&this.transport?.sendPresence())return;if(this.inFlight)return;this.inFlight=!0;let n=!1;try{const i=await this.apiClient.heartbeat(t);if(!this.started||this.apiClient.getSourceId()!==e)return;if(t&&this.completionSourceId===e)if(!0===i?.intro_presentation_completion_recorded)this.completionSourceId=null,this.acknowledgedCompletionSourceId=e,this.clearStoredCompletion(e),this.onCompletionRecorded?.(e);else{if(this.completionMismatchCount++,1===this.completionMismatchCount){Ji(`Intro completion heartbeat was not recorded: ${!1===i?.intro_presentation_completion_recorded?\"false acknowledgement\":\"missing acknowledgement\"}`)}if(1===this.completionMismatchCount&&this.onCompletionMismatch)try{await this.onCompletionMismatch(e),n=!0}catch(e){Ji(\"Intro completion reconciliation failed\",e),this.completionPaused=!0}else this.completionPaused=!0}i?.has_pending_nudge&&this.onPendingNudge();const s=i?.conversation_id;null!==s&&\"number\"!=typeof s||this.onConversation?.(s)}catch{}finally{this.inFlight=!1,!this.started||this.completionPaused||null===this.completionSourceId||this.completionSourceId!==this.apiClient.getSourceId()||t&&this.completionSourceId===e&&!n||this.send()}}}function dM(){return\"hidden\"===document.visibilityState}function uM(e,t){return e+Math.random()*(t-e)}class pM{constructor(e,t){this.config=e,this.callbacks=t,this.socket=null,this.connection=\"down\",this.snapshotSeen=!1,this.stopped=!1,this.epoch=0,this.failures=0,this.identityRefreshUsed=!1,this.reconnectTimer=null,this.recycleTimer=null,this.hiddenTimer=null,this.waitingForVisible=!1,this.liveness=new zd(es(\"contact-socket:stale\",()=>{this.teardown(),this.handleClose(Dd)})),this.onVisibilityChange=es(\"contact-socket:visibility\",()=>{dM()?this.armHiddenClose():(this.clearTimer(\"hiddenTimer\"),this.waitingForVisible&&(this.waitingForVisible=!1,this.connect()))}),this.onOnline=es(\"contact-socket:online\",()=>{null!==this.reconnectTimer&&(this.clearTimer(\"reconnectTimer\"),this.connect())})}start(){document.addEventListener(\"visibilitychange\",this.onVisibilityChange),window.addEventListener(\"online\",this.onOnline),dM()?this.waitingForVisible=!0:this.connect()}stop(){this.stopped=!0,document.removeEventListener(\"visibilitychange\",this.onVisibilityChange),window.removeEventListener(\"online\",this.onOnline),this.clearTimer(\"reconnectTimer\"),this.clearTimer(\"hiddenTimer\"),this.teardown()}isLive(){return\"ordered\"===this.connection||\"unordered\"===this.connection}sendPresence(){return!!this.isLive()&&this.send({type:\"presence\"})}sendCheckInRequest(e,t){return!!this.isLive()&&this.send({type:e,request_id:t})}connect(){if(this.stopped)return;this.teardown();const e=++this.epoch;this.snapshotSeen=!1,this.setConnection(\"awaiting\");const t=this.config.getIdentityProof();t?t.catch(()=>null).then(t=>{this.epoch!==e||this.stopped||this.open(e,t)}):this.open(e,null)}open(e,t){const n=this.config.apiBaseUrl.startsWith(\"https\")?\"wss\":\"ws\",i=`${this.config.apiBaseUrl.replace(/^https?/,n)}/contacts/socket/?publishable_key=${encodeURIComponent(this.config.publishableKey)}&source_id=${encodeURIComponent(this.config.sourceId)}&tab_id=${encodeURIComponent(this.config.tabId)}`;try{const n=t?new WebSocket(i,[t.protocol]):new WebSocket(i);this.socket=n,this.liveness.start(),n.onmessage=es(\"contact-socket:onmessage\",t=>{this.epoch===e&&(this.liveness.touch(),this.handleMessage(t))}),n.onerror=es(\"contact-socket:onerror\",()=>{Qi(\"contact-socket\",`socket error (failures ${this.failures})`)}),n.onclose=es(\"contact-socket:onclose\",t=>{this.epoch===e&&(this.socket=null,this.handleClose(t.code))})}catch(e){Ji(\"contact-socket: failed to open the contact socket\",e),this.markDown(),this.scheduleReconnect()}}handleMessage(e){let t;try{t=JSON.parse(e.data)}catch{return}if(\"ping\"!==t.type){if(\"contact_state\"===t.type){const e=function(e){const t=e.conversation_id;return null!==t&&\"number\"!=typeof t||\"boolean\"!=typeof e.has_pending_nudge?null:{conversationId:t,hasPendingNudge:e.has_pending_nudge}}(t);if(!e)return;return this.isLive()||this.goLive(),void this.callbacks.onState(e)}\"activation_feature_check_in\"!==t.type||this.isLive()||(this.snapshotSeen=!0),this.callbacks.onFrame(t)}else this.send({type:\"pong\"})}goLive(){this.failures=0,this.identityRefreshUsed=!1,this.recycleTimer=setTimeout(es(\"contact-socket:recycle\",()=>{this.recycleTimer=null,this.connect()}),uM(3e6,348e4)),this.setConnection(this.snapshotSeen?\"ordered\":\"unordered\")}handleClose(e){if(this.markDown(),Qi(\"contact-socket\",`closed (code ${e})`),!this.stopped)if(4100!==e)if(4003!==e){if(4001===e){if(this.identityRefreshUsed)return void this.refuse(\"identity\");this.identityRefreshUsed=!0;const e=this.epoch;return void this.config.refreshIdentityProof().catch(()=>null).then(()=>{this.epoch!==e||this.stopped||this.scheduleReconnect()})}this.scheduleReconnect()}else this.refuse(\"source\");else this.refuse(\"disabled\")}refuse(e){this.stop(),this.callbacks.onRefused(e)}scheduleReconnect(){this.clearTimer(\"reconnectTimer\");const e=this.nextDelay();this.failures++,this.reconnectTimer=setTimeout(es(\"contact-socket:reconnect\",()=>{this.reconnectTimer=null,dM()?this.waitingForVisible=!0:this.connect()}),e)}nextDelay(){return 0===this.failures?uM(1e3,15e3):this.failures>=5?3e5:Math.random()*Math.min(6e4,15e3*2**this.failures)}armHiddenClose(){null===this.hiddenTimer&&(this.hiddenTimer=setTimeout(es(\"contact-socket:hidden-close\",()=>{this.hiddenTimer=null,this.stopped||(this.clearTimer(\"reconnectTimer\"),this.epoch++,this.teardown(),this.waitingForVisible=!0)}),3e5))}send(e){if(!this.socket||this.socket.readyState!==WebSocket.OPEN)return!1;try{return this.socket.send(JSON.stringify(e)),!0}catch(e){return Ji(\"contact-socket: failed to send a frame\",e),!1}}markDown(){this.liveness.stop(),this.clearTimer(\"recycleTimer\"),this.setConnection(\"down\")}setConnection(e){this.connection!==e&&(this.connection=e,this.callbacks.onConnection(e))}teardown(){this.markDown();const e=this.socket;e&&(e.onmessage=null,e.onerror=null,e.onclose=null,this.socket=null,e.close())}clearTimer(e){const t=this[e];null!==t&&(clearTimeout(t),this[e]=null)}}const hM=\"support_widget_contact_socket_disabled_until\";class gM{constructor(e,t){this.config=e,this.deps=t,this.socket=null,this.socketKey=null,this.refusedKey=null,this.disabledForPage=!1,this.stopped=!1,t.presence.setTransport(this),t.checkIns.setTransport(this)}sync(){if(this.stopped)return;const e=this.currentKey();null===e||e===this.refusedKey||this.isDisabled()?this.closeSocket():this.socket&&e===this.socketKey||(this.closeSocket(),this.openSocket(e))}closeIfStale(){this.socket&&this.socketKey!==this.currentKey()&&this.closeSocket()}sendPresence(){return this.sync(),this.socket?.sendPresence()??!1}sendCheckInRequest(e,t){return this.socket?.sendCheckInRequest(e,t)??!1}pickUp(e,t){if(this.stopped||null===e)return;const{host:n}=this.deps;if(n.isSettling())return;if(this.isOpen(n.getActive(),e)||this.isOpen(n.getBackground(),e))return;const i=n.getActive();if(null===i)n.openTicket(e);else if(\"session\"===i.type)n.openTicketInBackground(e);else{if(n.isReadingChat()||n.activeHasUnread())return;n.openTicket(e)}t.announce&&n.playSound()}stop(){this.stopped=!0,this.closeSocket(),this.deps.presence.setTransport(null),this.deps.checkIns.setTransport(null)}isOpen(e,t){return\"ticket\"===e?.type&&e.id===t}currentKey(){const e=this.config.getSourceId(),t=this.config.getExternalId();return e&&t?`${e}|${t}`:null}isDisabled(){return this.disabledForPage||function(){try{return Number(localStorage.getItem(hM))||0}catch{return 0}}()>s()}openSocket(e){const t=this.config.getSourceId();if(!t)return;const n=new pM({apiBaseUrl:this.config.apiBaseUrl,publishableKey:this.config.publishableKey,sourceId:t,tabId:this.config.tabId,getIdentityProof:this.config.getIdentityProof,refreshIdentityProof:this.config.refreshIdentityProof},{onConnection:e=>this.handleConnection(e),onState:e=>this.handleState(e),onFrame:e=>{this.routeCheckInFrame(e)||Zd(e,this.deps.frames)},onRefused:e=>this.handleRefused(e)});this.socket=n,this.socketKey=e,n.start()}closeSocket(){this.socket?.stop(),this.socket=null,this.socketKey=null}handleConnection(e){\"ordered\"!==e&&\"unordered\"!==e||this.deps.presence.beatNow(),this.deps.checkIns.setConnection(e)}routeCheckInFrame(e){const t=\"string\"==typeof e.request_id?e.request_id:null;if(\"feature_check_in_unavailable\"===e.type)return this.deps.checkIns.receiveUnavailable(t),!0;if(\"activation_feature_check_in\"!==e.type)return!1;const n=cd(e);return n?this.deps.checkIns.receive(n.check_in,t):null!==t&&this.deps.checkIns.receiveUnavailable(t),!0}handleState(e){this.pickUp(e.conversationId,{announce:!0}),e.hasPendingNudge&&this.deps.presence.isPresent()&&this.deps.onPendingNudge()}handleRefused(e){\"disabled\"===e?(this.disabledForPage=!0,function(){try{localStorage.setItem(hM,String(s()+18e5))}catch{return}}()):this.refusedKey=this.socketKey,this.socket=null,this.socketKey=null}}const mM='<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polyline points=\"20 6 9 17 4 12\"/></svg>';class fM{constructor(e,t,n,i,s){this.container=e,this.apiClient=t,this.onStart=n,this.onStartSecondary=i,this.onData=s,this.el=null,this.fetchSeq=0,this.starting=!1,this.doneIds=null,this.doneFeatureIds=null,this.checklist=null}async refresh(){const e=++this.fetchSeq;try{const t=await this.apiClient.getChecklist();e===this.fetchSeq&&(this.render(t),this.onData?.(t))}catch{}}rerender(){this.el&&this.checklist&&this.render(this.checklist)}clear(){this.fetchSeq++,this.doneIds=null,this.doneFeatureIds=null,this.checklist=null,os(this.el),this.el=null,this.onData?.(null)}render(e){os(this.el),this.el=null,this.checklist=e;const t=this.container.querySelector('.support-view[data-view=\"home\"] .support-welcome-hero');if(!t||!Array.isArray(e.items)||0===e.items.length)return;const n=e.full_value?this.fullValueCard(e.full_value):this.journeyCard(e);t.after(n),this.el=n}journeyCard(e){const t=this.doneIds;this.doneIds=new Set(e.items.filter(e=>e.is_done).map(e=>e.pipeline_milestone_id));const n=e=>e.is_done&&null!==t&&!t.has(e.pipeline_milestone_id),i=Na().progress,s=document.createElement(\"div\");s.className=\"support-progress-card\";const r=document.createElement(\"div\");r.className=\"support-progress-header\",r.append(bM(\"span\",\"support-progress-title\",i.title),bM(\"span\",\"support-progress-count\",i.count(e.done,e.total)));const o=document.createElement(\"div\");o.className=\"support-progress-bar\";for(const t of e.items){const i=document.createElement(\"span\");i.className=\"support-progress-segment\",t.is_done&&i.classList.add(\"is-done\"),n(t)&&i.classList.add(\"just-done\"),t.pipeline_milestone_id===e.next_step?.pipeline_milestone_id&&i.classList.add(\"is-next\"),o.appendChild(i)}const a=e.items.find(t=>t.pipeline_milestone_id===e.next_step?.pipeline_milestone_id),l=a?.stage??e.current_stage,c=e.items.filter(e=>e.stage===l&&!e.is_done).length,d=e.items.some(n)?i.justDone:c>0?i.stageRemaining(c):null;s.append(r,o),d&&s.appendChild(bM(\"div\",\"support-progress-motivation\",d)),s.appendChild(this.nextStepBlock(e.next_step));const u=function(e){const t=new Map;for(const n of e){const e=t.get(n.stage);e?e.push(n):t.set(n.stage,[n])}return t}(e.items);let p=0;for(const[e,t]of u){p++;const r=document.createElement(\"details\"),o=e===l,a=t.filter(e=>e.is_done).length,c=a===t.length;r.className=`support-progress-stage${o?\" is-current\":\"\"}${c?\" is-complete\":\"\"}`,r.open=o;const d=document.createElement(\"summary\");o&&d.setAttribute(\"aria-current\",\"step\");const u=bM(\"span\",\"support-progress-stage-marker\",c?\"✓\":String(p)),h=document.createElement(\"span\");h.className=\"support-progress-stage-label\",h.append(bM(\"span\",\"support-progress-stage-name\",i.stages[e]??e),bM(\"span\",\"support-progress-stage-status\",c?i.stageComplete:o?i.stageCurrent:i.stageUpcoming));const g=bM(\"span\",\"support-progress-stage-tally\",`${a}/${t.length}`);d.append(u,h,g),r.appendChild(d);for(const e of t){r.appendChild(this.row(e,n(e)));for(const t of e.amplifiers??[])r.appendChild(this.amplifierRow(e.pipeline_milestone_id,t))}s.appendChild(r)}return s}fullValueCard(e){const t=this.doneFeatureIds;this.doneFeatureIds=new Set(e.secondaries.filter(e=>e.is_done).map(e=>e.feature_id));const n=document.createElement(\"div\");if(n.className=\"support-progress-card\",n.appendChild(this.nextStepBlock(null)),0===e.secondaries.length)return n;const i=Na().progress,s=document.createElement(\"div\");s.className=\"support-progress-header\",s.append(bM(\"span\",\"support-progress-title\",i.fullValueTitle),bM(\"span\",\"support-progress-count\",i.count(e.done,e.total))),n.appendChild(s);for(const i of e.secondaries){const s=i.is_done&&null!==t&&!t.has(i.feature_id);n.appendChild(this.secondaryRow(i,!i.is_done&&i.feature_id===e.next_feature_id,s))}return n}nextStepBlock(e){const t=Na().progress,n=document.createElement(\"div\");if(n.className=\"support-progress-next\",!e)return n.classList.add(\"is-done\"),n.append(bM(\"span\",\"support-progress-trophy\",\"🏆\"),bM(\"span\",\"support-progress-all-done\",t.allDone)),n;n.append(bM(\"span\",\"support-progress-next-label\",t.nextStep),bM(\"span\",\"support-progress-next-name\",e.name));const i=yM(e);if(i){const t=document.createElement(\"div\");t.className=\"support-progress-next-meter\";const s=document.createElement(\"div\");s.className=\"support-progress-next-track\";const r=document.createElement(\"div\");r.className=\"support-progress-next-fill\",r.style.width=`${Math.min(100,(e.progress_count??0)/(e.progress_required||1)*100)}%`,s.appendChild(r),t.append(s,bM(\"span\",\"support-progress-next-count\",i)),n.appendChild(t)}return e.amplifiers?.length||n.appendChild(this.startButton(t.doItWithMe,\"support-progress-start primary\",()=>this.onStart(e.pipeline_milestone_id))),n}row(e,t){const n=document.createElement(\"div\");n.className=`support-progress-item${e.is_done?\" is-done\":\"\"}${t?\" just-done\":\"\"}`;const i=document.createElement(\"span\");if(i.className=\"support-progress-item-mark\",e.is_done&&(i.innerHTML=mM),n.append(i,bM(\"span\",\"support-progress-item-name\",e.name)),e.is_done)return n;const s=yM(e);return s&&n.appendChild(bM(\"span\",\"support-progress-item-count\",s)),e.amplifiers?.length||n.appendChild(this.startButton(Na().progress.doItWithMeShort,\"support-progress-start\",()=>this.onStart(e.pipeline_milestone_id))),n}amplifierRow(e,t){const n=document.createElement(\"div\");return n.className=\"support-progress-amplifier\",n.append(bM(\"span\",\"support-progress-amplifier-mark\",\"↳\"),bM(\"span\",\"support-progress-amplifier-name\",t.name),bM(\"span\",\"support-progress-amplifier-why\",t.why_it_helps),this.startButton(Na().progress.startAmplifier,\"support-progress-start\",()=>this.onStart(e,t.feature_id))),n}secondaryRow(e,t,n){const i=document.createElement(\"div\");i.className=`support-progress-item support-progress-secondary${e.is_done?\" is-done\":\"\"}${t?\" is-next\":\"\"}${n?\" just-done\":\"\"}`,t&&i.setAttribute(\"aria-current\",\"step\");const s=document.createElement(\"span\");if(s.className=\"support-progress-item-mark\",e.is_done&&(s.innerHTML=mM),i.append(s,bM(\"span\",\"support-progress-item-name\",e.name),bM(\"span\",\"support-progress-item-why\",e.why_it_helps)),e.is_done)return i;const r=t?\"support-progress-start primary\":\"support-progress-start\";return i.appendChild(this.startButton(Na().progress.startAmplifier,r,()=>this.onStartSecondary(e.feature_id))),i}startButton(e,t,n){const i=document.createElement(\"button\");return i.type=\"button\",i.className=t,i.textContent=e,i.disabled=this.starting,i.addEventListener(\"click\",()=>{this.start(n)}),i}async start(e){if(!this.starting){this.setStarting(!0);try{await e()}finally{this.setStarting(!1)}}}setStarting(e){this.starting=e,this.el?.querySelectorAll(\".support-progress-start\").forEach(t=>{t.disabled=e})}}function bM(e,t,n){const i=document.createElement(e);return i.className=t,i.textContent=n,i}function yM(e){return\"number\"!=typeof e.progress_count||\"number\"!=typeof e.progress_required?null:Na().progress.count(e.progress_count,e.progress_required)}const vM=\"[blar:share]\";function wM(e,t){try{const n=(new Date).toISOString().slice(11,23),i=ya().slice(0,8);void 0===t?console.warn(`${vM} ${n} tab=${i} ${e}`):console.warn(`${vM} ${n} tab=${i} ${e}`,t)}catch{}}const xM='<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"2\" y=\"3\" width=\"20\" height=\"14\" rx=\"2\"/><path d=\"M8 21h8M12 17v4\"/></svg>';class kM{constructor(e){this.element=null,this.getContainer=e}isVisible(){return null!==this.element}showRequest(e){const t=this.getContainer();if(!t)return;this.hide();const n=Na().screenShare,i=document.createElement(\"div\");i.className=\"support-screen-share-card\",i.appendChild(this.buildHead(e.executiveName));const s=document.createElement(\"p\");s.className=\"support-screen-share-body\",s.textContent=n.requestBody,i.appendChild(s),i.appendChild(this.buildActions(e)),t.appendChild(i),this.element=i}hide(){this.element&&(os(this.element),this.element=null)}buildHead(e){const t=document.createElement(\"div\");t.className=\"support-voice-call-head\";const n=document.createElement(\"div\");n.className=\"support-screen-share-avatar-wrap\";const i=document.createElement(\"div\");if(i.className=\"support-voice-call-avatar\",e){i.textContent=as(e);const t=document.createElement(\"span\");t.className=\"support-screen-share-badge\",t.innerHTML='<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"2\" y=\"3\" width=\"20\" height=\"14\" rx=\"2\"/><path d=\"M8 21h8M12 17v4\"/></svg>',n.appendChild(i),n.appendChild(t)}else i.innerHTML=xM,n.appendChild(i);t.appendChild(n);const s=document.createElement(\"div\");s.className=\"support-voice-call-who\";const r=document.createElement(\"span\");r.className=\"support-voice-call-eyebrow\",r.textContent=Na().screenShare.requestTitle;const o=document.createElement(\"span\");o.className=\"support-voice-call-dots\",o.innerHTML=\"<span>.</span><span>.</span><span>.</span>\",r.appendChild(o),s.appendChild(r);const a=document.createElement(\"span\");return a.className=\"support-voice-call-name\",a.textContent=e??Na().config.title,s.appendChild(a),t.appendChild(s),t}buildActions(e){const t=document.createElement(\"div\");t.className=\"support-voice-call-actions\";const n=Na().screenShare;return t.appendChild(this.buildButton(n.decline,\"decline\",'<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18 6 6 18M6 6l12 12\"/></svg>',e.onDecline,t)),t.appendChild(this.buildButton(n.accept,\"accept\",xM,e.onAccept,t)),t}buildButton(e,t,n,i,s){const r=document.createElement(\"button\");r.type=\"button\",r.className=`support-voice-call-btn support-voice-call-btn--${t} support-screen-share-btn--${t}`,r.innerHTML=n;const o=document.createElement(\"span\");return o.textContent=e,r.appendChild(o),r.addEventListener(\"click\",()=>{for(const e of Array.from(s.querySelectorAll(\"button\")))e.disabled=!0;i()}),r}}const SM='<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z\"/></svg>';class CM{constructor(e){this.element=null,this.bodyEl=null,this.timerEl=null,this.dotEl=null,this.labelEl=null,this.shareCircleEl=null,this.activeContent=null,this.shareMode={kind:\"normal\"},this.getContainer=e}isVisible(){return null!==this.element}showRinging(e){const t=this.getContainer();if(!t)return;this.hide();const n=document.createElement(\"div\");n.className=\"support-voice-call-card\",n.appendChild(this.buildHead(e.executiveName)),n.appendChild(this.buildActions(e)),t.appendChild(n),this.element=n}showActive(e){const t=this.getContainer();if(!t)return;this.hide(),this.activeContent=e;const n=Na().voiceCalls,i=document.createElement(\"div\");i.className=\"support-voice-call-pill\";const s=document.createElement(\"div\");s.className=\"support-voice-call-pill-body\",s.setAttribute(\"role\",\"button\"),s.setAttribute(\"tabindex\",\"0\"),s.setAttribute(\"aria-label\",n.returnToCall),s.addEventListener(\"click\",()=>this.activatePill()),s.addEventListener(\"keydown\",e=>{\"Enter\"!==e.key&&\" \"!==e.key||(e.preventDefault(),this.activatePill())});const r=document.createElement(\"span\");r.className=\"support-voice-call-live-dot\",s.appendChild(r),this.dotEl=r;const o=document.createElement(\"span\");o.className=\"support-voice-call-pill-label\",o.textContent=n.callInProgress,s.appendChild(o),this.labelEl=o;const a=document.createElement(\"span\");a.className=\"support-voice-call-pill-timer\",a.textContent=this.formatElapsed(0),s.appendChild(a),this.timerEl=a,i.appendChild(s),this.bodyEl=s;const l=document.createElement(\"button\");l.type=\"button\",l.className=\"support-voice-call-hangup\",l.setAttribute(\"aria-label\",n.hangUp),l.innerHTML=SM,l.addEventListener(\"click\",t=>{t.stopPropagation(),e.onHangUp()}),i.appendChild(l),t.appendChild(i),this.element=i,this.renderShareMode()}setShareMode(e){wM(\"pill mode\",{mode:e.kind,pillOnScreen:null!==this.element}),this.shareMode=e,this.renderShareMode()}renderShareMode(){const e=this.element,t=this.bodyEl;if(!(e&&t&&this.dotEl&&this.labelEl))return;const n=Na();if(this.dotEl.classList.toggle(\"support-voice-call-live-dot--sharing\",\"normal\"!==this.shareMode.kind),os(this.shareCircleEl),this.shareCircleEl=null,\"normal\"===this.shareMode.kind)return void(this.labelEl.textContent=n.voiceCalls.callInProgress);if(\"owner\"===this.shareMode.kind)return this.labelEl.textContent=n.screenShare.sharing,void(this.shareCircleEl=this.addShareCircle(e,\"support-voice-call-stop-share\",n.screenShare.stop,'<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"2\" y=\"3\" width=\"20\" height=\"14\" rx=\"2\"/><path d=\"M8 21h8M12 17v4\"/><path d=\"M9.5 7.5l5 5M14.5 7.5l-5 5\"/></svg>',()=>{\"owner\"===this.shareMode.kind&&this.shareMode.onStop()}));const i=this.addShareCircle(e,\"support-voice-call-share-here\",n.screenShare.shareThisTabInstead,xM,()=>{\"available\"===this.shareMode.kind&&this.shareMode.onTakeover()});if(this.shareCircleEl=i,\"available\"===this.shareMode.kind)return this.labelEl.textContent=n.screenShare.sharingElsewhere,void(i.dataset.tooltip=n.screenShare.shareThisTabInstead);this.labelEl.textContent=n.screenShare.switching,i.dataset.tooltip=n.screenShare.switching,i.disabled=!0,i.setAttribute(\"aria-busy\",\"true\")}addShareCircle(e,t,n,i,s){const r=document.createElement(\"button\");return r.type=\"button\",r.className=t,r.setAttribute(\"aria-label\",n),r.innerHTML=i,r.addEventListener(\"click\",e=>{e.stopPropagation(),s()}),e.insertBefore(r,e.lastElementChild),r}activatePill(){wM(\"pill clicked\",{mode:this.shareMode.kind,hasCall:null!==this.activeContent}),this.activeContent?.onReturnToCall()}setElapsed(e){this.timerEl&&(this.timerEl.textContent=this.formatElapsed(e))}hide(){this.element&&(os(this.element),this.element=null),this.timerEl=null,this.bodyEl=null,this.dotEl=null,this.labelEl=null,this.shareCircleEl=null,this.activeContent=null}formatElapsed(e){const t=Math.max(0,Math.floor(e)),n=e=>String(e).padStart(2,\"0\");return t>=3600?`${Math.floor(t/3600)}:${n(Math.floor(t%3600/60))}:${n(t%60)}`:`${n(Math.floor(t/60))}:${n(t%60)}`}buildHead(e){const t=document.createElement(\"div\");t.className=\"support-voice-call-head\";const n=document.createElement(\"div\");n.className=\"support-voice-call-avatar\",e?n.textContent=as(e):n.innerHTML=SM,t.appendChild(n);const i=document.createElement(\"div\");i.className=\"support-voice-call-who\";const s=document.createElement(\"span\");s.className=\"support-voice-call-eyebrow\",s.textContent=Na().voiceCalls.incomingCall;const r=document.createElement(\"span\");if(r.className=\"support-voice-call-dots\",r.innerHTML=\"<span>.</span><span>.</span><span>.</span>\",s.appendChild(r),i.appendChild(s),e){const t=document.createElement(\"span\");t.className=\"support-voice-call-name\",t.textContent=e,i.appendChild(t)}return t.appendChild(i),t}buildActions(e){const t=document.createElement(\"div\");t.className=\"support-voice-call-actions\";const n=Na().voiceCalls,i=this.buildButton(n.decline,\"decline\",e.onDecline,t),s=this.buildButton(n.accept,\"accept\",e.onAccept,t);return t.appendChild(i),t.appendChild(s),t}buildButton(e,t,n,i){const s=document.createElement(\"button\");s.type=\"button\",s.className=`support-voice-call-btn support-voice-call-btn--${t}`,s.innerHTML=SM,\"decline\"===t&&s.classList.add(\"support-voice-call-btn--hangup-icon\");const r=document.createElement(\"span\");return r.textContent=e,s.appendChild(r),s.addEventListener(\"click\",()=>{for(const e of Array.from(i.querySelectorAll(\"button\")))e.disabled=!0;n()}),s}}function EM(e){return`blar_meet_call_${e}`}const MM=\"blar_host_\";let AM=null;function _M(){return window.name.startsWith(MM)||(AM=window.name,window.name=`${MM}${cs()}`),window.name}function TM(e,t){const n=e.includes(\"#\")?\"&\":\"#\";return`${e}${n}host=${encodeURIComponent(t)}`}function IM(e){return window.open(\"about:blank\",function(e){return`blar_meet_pending_${e}_${cs()}`}(e))}function LM(e,t){e.location.href=t}function RM(e){try{e?.close()}catch{}}const $M=[293.66,440];class NM{constructor(){this.context=null,this.cycleTimer=null}start(){null===this.cycleTimer&&this.openContext()&&(this.playCycle(),this.cycleTimer=setInterval(es(\"ringtone: cycle\",()=>this.playCycle()),3e3))}stop(){null!==this.cycleTimer&&(clearInterval(this.cycleTimer),this.cycleTimer=null);const e=this.context;this.context=null,e&&e.close().catch(()=>{})}openContext(){if(this.context)return!0;const e=window.AudioContext??window.webkitAudioContext;if(!e)return!1;try{this.context=new e}catch{return!1}return!0}playCycle(){const e=this.context;if(e)if(\"running\"===e.state)for(let t=0;t<2;t++)this.playPulse(e,e.currentTime+t*(.4+.2));else e.resume().catch(()=>{})}playPulse(e,t){const n=t+.4,i=e.createGain();i.connect(e.destination),i.gain.setValueAtTime(0,t),i.gain.linearRampToValueAtTime(.09,t+.06),i.gain.setValueAtTime(.09,n-.14),i.gain.linearRampToValueAtTime(0,n),$M.forEach((s,r)=>{const o=e.createOscillator();o.type=\"sine\",o.frequency.value=s,o.connect(i),o.start(t),o.stop(n),r===$M.length-1&&(o.onended=()=>i.disconnect())})}}const PM=45e3,FM=new Set([404,409,410]);class OM{constructor(e){this.disposables=new fs,this.ringtone=new NM,this.ringingCall=null,this.ringTimer=null,this.ringtoneOwnershipTimer=null,this.accepting=!1,this.activeCall=null,this.meetWindow=null,this.elapsedTimer=null,this.handleInvite=es(\"voice-call: handle invite\",e=>{this.disposables.isDisposed||this.ringingCall?.callId!==e.call_id&&this.activeCall?.callId!==e.call_id&&this.startRinging(e.call_id,e.executive_name,PM)}),this.restoreFromServer=es(\"voice-call: restore from server\",e=>{if(!this.disposables.isDisposed&&this.ringingCall?.callId!==e.call_id&&this.activeCall?.callId!==e.call_id)if(\"active\"===e.status){const t=Date.parse(e.started_at);this.showActivePill(e.call_id,Number.isFinite(t)?t:Date.now())}else if(\"ringing\"===e.status){const t=void 0!==e.expires_at?Date.parse(e.expires_at)-Date.now():PM;if(!Number.isFinite(t)||t<=0)return;this.startRinging(e.call_id,e.executive_name??null,Math.min(t,PM))}}),this.handleStatus=es(\"voice-call: handle status\",e=>{if(this.disposables.isDisposed)return;const t=this.activeCall?.callId??this.ringingCall?.callId??null;if(null===t||e.call_id===t)if(\"active\"===e.status)this.clearRingingUi(),this.showActivePill(e.call_id,Date.now());else if(\"ended\"===e.status){const e=null!==this.ringingCall||null!==this.activeCall;this.clearRingingUi(),this.clearActiveUi(),e&&this.deps.showToast(Na().voiceCalls.callEnded,\"info\")}}),this.deps=e,this.banner=new CM(e.getContainer)}getActiveCallId(){return this.activeCall?.callId??null}setScreenShareMode(e){this.banner.setShareMode(e)}destroy(){this.disposables.dispose(),this.clearRingingUi(),this.clearActiveUi()}startRinging(e,t,n){this.clearRingTimer(),this.clearRingtoneOwnershipTimer(),this.ringingCall={callId:e,executiveName:t},this.accepting=!1,this.deps.isChatOpen()&&this.deps.closeChat(),this.showRinging(),this.ringtoneOwnershipTimer=this.disposables.safeInterval(\"voice-call: ringtone ownership\",()=>this.syncRingtoneOwnership(),500),this.ringTimer=this.disposables.safeTimeout(\"voice-call: ring timeout\",()=>this.clearRingingUi(),n),this.deps.apiClient.acknowledgeVoiceCallInvite(e).catch(()=>{})}showRinging(){const e=this.ringingCall;e&&(this.banner.showRinging({executiveName:e.executiveName,onAccept:es(\"voice-call: accept click\",()=>this.acceptRingingCall()),onDecline:es(\"voice-call: decline click\",()=>this.declineRingingCall())}),this.deps.getContainer()?.classList.add(\"has-voice-call-ringing\"),this.syncRingtoneOwnership())}acceptRingingCall(){const e=this.ringingCall;if(!e||this.accepting)return;this.deps.claimActiveTab();const t=IM(e.callId);if(this.ringtone.stop(),!t)return this.deps.showToast(Na().voiceCalls.popupBlocked,\"error\"),void this.showRinging();this.accepting=!0,this.deps.apiClient.acceptVoiceCall(e.callId).then(n=>{!function(e,t,n){e.name=EM(t),LM(e,n)}(t,e.callId,TM(n.meet_url,_M())),this.disposables.isDisposed||(this.meetWindow=t,this.clearRingingUi())}).catch(e=>{RM(t),this.disposables.isDisposed||(this.accepting=!1,e instanceof Pi&&\"http\"===e.kind&&FM.has(e.status)?this.clearRingingUi():(this.deps.showToast(Na().voiceCalls.acceptFailed,\"error\"),this.ringingCall&&this.showRinging()))})}declineRingingCall(){const e=this.ringingCall;e&&(this.deps.apiClient.declineVoiceCall(e.callId).catch(()=>{}),this.clearRingingUi())}showActivePill(e,t){this.activeCall={callId:e,startedAtMs:t},this.banner.showActive({onReturnToCall:es(\"voice-call: return-to-call click\",()=>this.returnToCall()),onHangUp:es(\"voice-call: hang-up click\",()=>this.hangUp())}),this.tickElapsed(),null===this.elapsedTimer&&(this.elapsedTimer=this.disposables.safeInterval(\"voice-call: pill timer\",()=>this.tickElapsed(),1e3))}returnToCall(){const e=this.activeCall;if(!e)return;const t=this.meetWindow;if(t&&!t.closed)try{return void t.focus()}catch{}const n=function(e){const t=window.open(\"\",EM(e));if(!t)return{kind:\"blocked\"};try{return\"about:blank\"===t.location.href?{kind:\"fresh\",win:t}:{kind:\"focused\"}}catch{return{kind:\"focused\"}}}(e.callId);if(\"focused\"===n.kind)return;if(\"blocked\"===n.kind)return void this.deps.showToast(Na().voiceCalls.popupBlocked,\"error\");const i=n.win;this.deps.apiClient.getActiveVoiceCall({rejoin:!0}).then(e=>{this.disposables.isDisposed?RM(i):e.call&&e.meet_url?(LM(i,TM(e.meet_url,_M())),this.meetWindow=i):(RM(i),this.clearActiveUi())}).catch(()=>{RM(i),this.disposables.isDisposed||this.deps.showToast(Na().voiceCalls.acceptFailed,\"error\")})}hangUp(){const e=this.activeCall;e&&this.deps.apiClient.endVoiceCall(e.callId).catch(()=>{})}tickElapsed(){const e=this.activeCall;e&&this.banner.setElapsed((Date.now()-e.startedAtMs)/1e3)}syncRingtoneOwnership(){null!==this.ringingCall&&!this.accepting&&this.deps.isSoundEnabled()&&this.deps.isActiveTab()?this.ringtone.start():this.ringtone.stop()}clearRingingUi(){this.ringingCall=null,this.accepting=!1,null===this.activeCall&&this.banner.hide(),this.deps.getContainer()?.classList.remove(\"has-voice-call-ringing\"),this.ringtone.stop(),this.clearRingTimer(),this.clearRingtoneOwnershipTimer()}clearActiveUi(){null!==this.activeCall&&(this.activeCall=null,this.meetWindow=null,null!==AM&&(window.name=AM,AM=null),this.banner.hide(),null!==this.elapsedTimer&&(clearInterval(this.elapsedTimer),this.elapsedTimer=null))}clearRingTimer(){null!==this.ringTimer&&(clearTimeout(this.ringTimer),this.ringTimer=null)}clearRingtoneOwnershipTimer(){null!==this.ringtoneOwnershipTimer&&(clearInterval(this.ringtoneOwnershipTimer),this.ringtoneOwnershipTimer=null)}}class qM{constructor(e,t,n){this.getHeaderSlot=e,this.getBanner=t,this.getExecutiveName=n,this.status=null,this.name=null,this.stopClock=()=>{}}apply(e){this.dismiss();const t=this.getExecutiveName(),n=this.getHeaderSlot(),i=this.getBanner();if(!e||!t||!n||!i||e.freeAt<=s())return;const r=Na().executiveAvailability,{element:o,name:a,text:l}=function(e,t,n){const i=document.createElement(\"div\");i.className=\"support-executive-status\",i.dataset.reason=t,i.setAttribute(\"role\",\"status\");const s=document.createElement(\"span\");s.className=\"support-executive-status-name\",s.textContent=e;const r=document.createElementNS(\"http://www.w3.org/2000/svg\",\"svg\");r.classList.add(\"support-executive-status-icon\"),r.setAttribute(\"viewBox\",\"0 0 24 24\"),r.setAttribute(\"aria-hidden\",\"true\"),r.innerHTML=\"busy\"===t?'<circle cx=\"12\" cy=\"12\" r=\"8\"/><path d=\"M12 7v5l3 2\"/>':'<path d=\"M20 13.2A8.2 8.2 0 0 1 10.8 4 8.2 8.2 0 1 0 20 13.2Z\"/>';const o=document.createElement(\"div\");o.className=\"support-executive-status-content\";const a=document.createElement(\"span\");a.className=\"support-executive-status-reason\",a.textContent=n;const l=document.createElement(\"span\");return l.className=\"support-executive-status-line\",o.append(a,l),i.append(r,o),{element:i,name:s,text:l}}(t,e.reason,r.reason[e.reason]);n.appendChild(a),i.appendChild(o),this.status=o,this.name=a,this.stopClock=Fc(l,e,r.available,()=>this.dismiss())}dismiss(){this.stopClock(),this.stopClock=()=>{},this.status&&os(this.status),this.name&&os(this.name),this.status=null,this.name=null}}class HM{constructor(){this.el=null,this.chipEl=null,this.outlineEl=null,this.styleEl=null,this.target=null,this.current=null,this.frame=null,this.idleTimer=null,this.chipTimer=null,this.outlineTimer=null,this.destroyed=!1}pointTo(e,t){this.destroyed||(this.ensureElement(),this.el&&(this.target={x:e,y:t},this.current||(this.current={x:e,y:t}),this.el.classList.remove(\"blar-laser--gone\"),this.armIdleFade(),this.startLoop()))}click(e,t,n,i){this.destroyed||(this.pointTo(e,t),this.el&&(this.el.classList.remove(\"blar-laser--clicking\"),this.el.offsetWidth,this.el.classList.add(\"blar-laser--clicking\"),this.showChip(i),this.showOutline(n)))}leave(){this.el?.classList.add(\"blar-laser--gone\"),this.clearIdleFade(),this.stopLoop()}clear(){this.stopLoop(),this.clearIdleFade(),this.clearTimer(this.chipTimer),this.chipTimer=null,this.clearTimer(this.outlineTimer),this.outlineTimer=null,os(this.el),this.el=null,this.chipEl=null,os(this.outlineEl),this.outlineEl=null,os(this.styleEl),this.styleEl=null,this.target=null,this.current=null}destroy(){this.destroyed=!0,this.clear()}startLoop(){if(null!==this.frame)return;const e=()=>{if(this.frame=null,!this.el||!this.current||!this.target)return;const t=this.target.x-this.current.x,n=this.target.y-this.current.y,i=Math.abs(t)<.5&&Math.abs(n)<.5;this.current=i?{...this.target}:{x:this.current.x+.25*t,y:this.current.y+.25*n},this.el.style.transform=`translate(${this.current.x-window.scrollX}px, ${this.current.y-window.scrollY}px)`,this.frame=requestAnimationFrame(e)};this.frame=requestAnimationFrame(e)}stopLoop(){null!==this.frame&&(cancelAnimationFrame(this.frame),this.frame=null)}armIdleFade(){this.clearIdleFade(),this.idleTimer=setTimeout(()=>{this.el?.classList.add(\"blar-laser--gone\"),this.stopLoop()},5e3)}clearIdleFade(){this.clearTimer(this.idleTimer),this.idleTimer=null}showChip(e){this.chipEl&&(this.clearTimer(this.chipTimer),e?(this.chipEl.textContent=e,this.chipEl.classList.add(\"blar-laser-chip--shown\"),this.chipTimer=setTimeout(()=>this.chipEl?.classList.remove(\"blar-laser-chip--shown\"),1500)):this.chipEl.classList.remove(\"blar-laser-chip--shown\"))}showOutline(e){if(this.clearTimer(this.outlineTimer),this.outlineTimer=null,os(this.outlineEl),this.outlineEl=null,!e||!e.isConnected)return;const t=e.getBoundingClientRect();if(0===t.width&&0===t.height)return;const n=document.createElement(\"div\");n.className=\"blar-laser-outline\",n.setAttribute(\"data-blar-block\",\"\"),n.style.left=`${t.left}px`,n.style.top=`${t.top}px`,n.style.width=`${t.width}px`,n.style.height=`${t.height}px`,n.style.borderRadius=window.getComputedStyle(e).borderRadius,document.body.appendChild(n),this.outlineEl=n,this.outlineTimer=setTimeout(()=>{os(n),this.outlineEl===n&&(this.outlineEl=null)},850)}clearTimer(e){null!==e&&clearTimeout(e)}ensureElement(){if(this.el)return;this.injectStyles();const e=document.createElement(\"div\");e.className=\"blar-laser\",e.setAttribute(\"data-blar-block\",\"\"),e.innerHTML='\\n      <div class=\"blar-laser-halo\"></div>\\n      <div class=\"blar-laser-ring blar-laser-ring-1\"></div>\\n      <div class=\"blar-laser-ring blar-laser-ring-2\"></div>\\n      <div class=\"blar-laser-flash\"></div>\\n      <div class=\"blar-laser-core\"></div>\\n      <span class=\"blar-laser-chip\"></span>\\n    ',document.body.appendChild(e),this.el=e,this.chipEl=e.querySelector(\".blar-laser-chip\")}injectStyles(){if(this.styleEl)return;const e=document.createElement(\"style\");e.id=\"blar-laser-pointer-styles\",e.setAttribute(\"data-blar-block\",\"\"),e.textContent=\"\\n      @keyframes blarLaserRing {\\n        0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 0.95; border-width: 3px; }\\n        70%  { opacity: 0.4; border-width: 2px; }\\n        100% { transform: translate(-50%, -50%) scale(3.2); opacity: 0; border-width: 1px; }\\n      }\\n\\n      @keyframes blarLaserPress {\\n        0%   { transform: translate(-50%, -50%) scale(1); }\\n        35%  { transform: translate(-50%, -50%) scale(0.62); }\\n        70%  { transform: translate(-50%, -50%) scale(1.08); }\\n        100% { transform: translate(-50%, -50%) scale(1); }\\n      }\\n\\n      @keyframes blarLaserFlash {\\n        0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0.7; }\\n        100% { transform: translate(-50%, -50%) scale(2.6); opacity: 0; }\\n      }\\n\\n      @keyframes blarLaserOutline {\\n        0%   { opacity: 0; transform: scale(0.96); }\\n        18%  { opacity: 1; transform: scale(1); }\\n        100% { opacity: 0; transform: scale(1.08); }\\n      }\\n\\n      .blar-laser {\\n        position: fixed;\\n        top: 0;\\n        left: 0;\\n        width: 0;\\n        height: 0;\\n        z-index: 2147483647;\\n        pointer-events: none;\\n        opacity: 1;\\n        transition: opacity 0.25s ease-out;\\n        will-change: transform;\\n      }\\n\\n      .blar-laser--gone {\\n        opacity: 0;\\n      }\\n\\n      .blar-laser-halo {\\n        position: absolute;\\n        top: 50%;\\n        left: 50%;\\n        width: 36px;\\n        height: 36px;\\n        margin: -18px 0 0 -18px;\\n        border-radius: 50%;\\n        background: radial-gradient(\\n          circle,\\n          rgba(239, 68, 68, 0.35) 0%,\\n          rgba(239, 68, 68, 0.15) 50%,\\n          rgba(239, 68, 68, 0) 75%\\n        );\\n      }\\n\\n      .blar-laser-core {\\n        position: absolute;\\n        top: 50%;\\n        left: 50%;\\n        width: 12px;\\n        height: 12px;\\n        border-radius: 50%;\\n        background: #ef4444;\\n        border: 2px solid #ffffff;\\n        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);\\n        transform: translate(-50%, -50%);\\n      }\\n\\n      .blar-laser-ring {\\n        position: absolute;\\n        top: 50%;\\n        left: 50%;\\n        width: 24px;\\n        height: 24px;\\n        border: 3px solid rgba(239, 68, 68, 0.85);\\n        border-radius: 50%;\\n        transform: translate(-50%, -50%) scale(0.3);\\n        opacity: 0;\\n        pointer-events: none;\\n      }\\n\\n      .blar-laser-flash {\\n        position: absolute;\\n        top: 50%;\\n        left: 50%;\\n        width: 28px;\\n        height: 28px;\\n        border-radius: 50%;\\n        background: radial-gradient(\\n          circle,\\n          rgba(239, 68, 68, 0.6) 0%,\\n          rgba(239, 68, 68, 0.2) 50%,\\n          rgba(239, 68, 68, 0) 80%\\n        );\\n        transform: translate(-50%, -50%) scale(0.4);\\n        opacity: 0;\\n        pointer-events: none;\\n      }\\n\\n      .blar-laser--clicking .blar-laser-ring-1 {\\n        animation: blarLaserRing 0.65s cubic-bezier(0.16, 1, 0.3, 1);\\n      }\\n\\n      .blar-laser--clicking .blar-laser-ring-2 {\\n        animation: blarLaserRing 0.85s cubic-bezier(0.16, 1, 0.3, 1) 0.12s;\\n      }\\n\\n      .blar-laser--clicking .blar-laser-flash {\\n        animation: blarLaserFlash 0.45s ease-out;\\n      }\\n\\n      .blar-laser--clicking .blar-laser-core {\\n        animation: blarLaserPress 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);\\n      }\\n\\n      .blar-laser-chip {\\n        position: absolute;\\n        left: 14px;\\n        top: -24px;\\n        background: rgba(22, 32, 58, 0.88);\\n        color: #ffffff;\\n        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n        font-size: 11px;\\n        font-weight: 600;\\n        line-height: 1.4;\\n        padding: 3px 7px;\\n        border-radius: 6px;\\n        white-space: nowrap;\\n        opacity: 0;\\n        transition: opacity 0.2s ease-out;\\n      }\\n\\n      .blar-laser-chip--shown {\\n        opacity: 1;\\n      }\\n\\n      .blar-laser-outline {\\n        position: fixed;\\n        z-index: 2147483646;\\n        pointer-events: none;\\n        /* Border drawn INSIDE the rect, so the outline traces the element rather than sitting 2px\\n           proud of it on every side. */\\n        box-sizing: border-box;\\n        border: 2px solid rgba(239, 68, 68, 0.85);\\n        box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.25);\\n        animation: blarLaserOutline 0.85s cubic-bezier(0.16, 1, 0.3, 1) forwards;\\n      }\\n\\n      @media (prefers-reduced-motion: reduce) {\\n        .blar-laser--clicking .blar-laser-ring-1,\\n        .blar-laser--clicking .blar-laser-ring-2,\\n        .blar-laser--clicking .blar-laser-flash,\\n        .blar-laser--clicking .blar-laser-core,\\n        .blar-laser-outline {\\n          animation: none;\\n        }\\n      }\\n    \",document.head.appendChild(e),this.styleEl=e}}const BM=new Set([4001,4003,4004,4009,4010]),DM=262144;class zM{constructor(e,t){this.config=e,this.callbacks=t,this.socket=null,this.connected=!1,this.closedIntentionally=!1,this.reconnectAttempts=0,this.reconnectTimer=null,this.epoch=0,this.liveness=new zd(es(\"screen-share-socket:stale\",()=>{this.teardownSocket(),this.handleClose(Dd,\"no frame from the server\",!1)}))}connect(){if(this.closedIntentionally)return void wM(\"ws connect skipped\",{reason:\"closed for good\",shareId:this.config.screenShareId});this.teardownSocket();const e=++this.epoch,t=this.config.getIdentityProof?.()??null;t?t.catch(()=>null).then(t=>{this.epoch!==e||this.closedIntentionally||this.openSocket(e,t)}):this.openSocket(e,null)}openSocket(e,t){const n=this.config.apiBaseUrl.startsWith(\"https\")?\"wss\":\"ws\",i=`${this.config.apiBaseUrl.replace(/^https?/,n)}/screen-shares/${this.config.screenShareId}/?publishable_key=${encodeURIComponent(this.config.publishableKey)}&source_id=${encodeURIComponent(this.config.sourceId)}&tab_id=${encodeURIComponent(this.config.tabId)}`+(this.config.takeover?\"&takeover=1\":\"\");wM(\"ws connecting\",{shareId:this.config.screenShareId,takeover:!0===this.config.takeover,tabId:this.config.tabId,attempt:this.reconnectAttempts,identified:null!==t});try{const n=t?new WebSocket(i,[t.protocol]):new WebSocket(i);this.socket=n,n.onopen=es(\"screen-share-socket:onopen\",()=>{this.epoch===e&&(wM(\"ws open\",{shareId:this.config.screenShareId,takeover:!0===this.config.takeover}),this.connected=!0,this.reconnectAttempts=0,this.liveness.start(),this.callbacks.onReady())}),n.onmessage=es(\"screen-share-socket:onmessage\",t=>{this.epoch===e&&(this.liveness.touch(),this.handleMessage(t))}),n.onerror=es(\"screen-share-socket:onerror\",()=>{Qi(\"screen-share\",`socket error (attempt ${this.reconnectAttempts})`)}),n.onclose=es(\"screen-share-socket:onclose\",t=>{this.epoch===e?this.handleClose(t.code,t.reason,t.wasClean):wM(\"ws close ignored\",{reason:\"superseded socket\",code:t.code})})}catch(e){Ji(\"screen-share: failed to open the share socket\",e),this.scheduleReconnect()}}handleClose(e,t,n){if(this.liveness.stop(),this.connected=!1,wM(\"ws close\",{shareId:this.config.screenShareId,code:e,reason:t,wasClean:n,takeover:!0===this.config.takeover,intentional:this.closedIntentionally}),!this.closedIntentionally)return BM.has(e)||this.config.takeover?(this.closedIntentionally=!0,void this.callbacks.onClosed(e)):void this.scheduleReconnect()}isConnected(){return this.connected}close(){wM(\"ws closing from our side\",{shareId:this.config.screenShareId,wasConnected:this.connected}),this.closedIntentionally=!0,null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.teardownSocket()}sendStart(e,t,n){return this.send({type:\"screen_share_start\",span_uid:e,started_at_ms:t,recorder_version:n})}sendChunk(e,t,n,i){return this.sendEvents({type:\"screen_share_chunk\",span_uid:e,chunk_seq:t,events:n,recorder_version:i})}sendStop(e){return this.send({type:\"screen_share_stop\",span_uid:e})}sendLive(e,t,n){return this.sendEvents({type:\"screen_share_live\",span_uid:e,seq:t,events:n})}sendEvents(e){if(!this.connected||this.socket?.readyState!==WebSocket.OPEN)return!1;const{type:t,events:n,...i}=e,s=(new TextEncoder).encode(JSON.stringify(n));if(s.length<=DM)return this.send(e);const r=new TextDecoder(\"utf-8\",{ignoreBOM:!0}),o=[];for(let e=0;e<s.length;){let t=Math.min(e+DM,s.length);for(;t<s.length&&128==(192&s[t]);)t--;o.push(r.decode(s.subarray(e,t))),e=t}for(let e=0;e<o.length;e++){if(!this.send({type:`${t}_part`,...i,part:e,parts:o.length,data:o[e]}))return!1}return!0}send(e){if(!this.socket||!this.connected||this.socket.readyState!==WebSocket.OPEN)return!1;try{return this.socket.send(JSON.stringify(e)),!0}catch(e){return Ji(\"screen-share: failed to send a frame\",e),!1}}handleMessage(e){let t;try{t=JSON.parse(e.data)}catch{return}if(\"ping\"!==t.type){if(\"screen_share_status\"===t.type){const e=Qd(t);return wM(\"ws status frame\",{parsed:null!==e,status:e?.status??null,raw:t.status}),void(e&&(this.config.takeover&&\"active\"===e.status&&(this.config.takeover=!1),this.callbacks.onStatus(e)))}if(\"screen_share_chunk_ack\"!==t.type){if(\"screen_share_pointer\"===t.type){const e=function(e){return\"string\"==typeof e.kind&&Xd.includes(e.kind)&&Number.isFinite(e.x)&&Number.isFinite(e.y)?{kind:e.kind,x:e.x,y:e.y,node_id:\"number\"==typeof e.node_id?e.node_id:null,executive_name:Jd(e.executive_name)}:null}(t);return void(e&&this.callbacks.onPointer(e))}\"screen_share_resync\"===t.type&&this.callbacks.onResync()}else\"number\"==typeof t.chunk_seq&&this.callbacks.onChunkAck(t.chunk_seq)}else this.send({type:\"pong\"})}scheduleReconnect(){if(wM(\"ws will reconnect\",{shareId:this.config.screenShareId,attempt:this.reconnectAttempts}),this.reconnectAttempts>=10)return Qi(\"screen-share\",\"reconnect exhausted — giving the share up\"),this.closedIntentionally=!0,void this.callbacks.onClosed(0);null!==this.reconnectTimer&&clearTimeout(this.reconnectTimer);const e=Math.min(1e3*Math.pow(1.5,this.reconnectAttempts),3e4),t=this.epoch;this.reconnectTimer=setTimeout(es(\"screen-share-socket:reconnect\",()=>{this.epoch!==t||this.closedIntentionally||(this.reconnectAttempts++,this.connect())}),e)}teardownSocket(){this.liveness.stop();const e=this.socket;if(e){e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null,this.socket=null,this.connected=!1;try{e.close()}catch{}}}}const UM=45e3,jM=new Set([400,404,409,410]);class WM{constructor(e){this.disposables=new fs,this.laser=new HM,this.titleAttention=new xp,this.socket=null,this.requested=null,this.requestTimer=null,this.accepting=!1,this.shareId=null,this.shareStatus=null,this.ownsShare=!1,this.switching=!1,this.socketPurpose=null,this.engaged=!1,this.handleInvite=es(\"screen-share: handle invite\",e=>{if(wM(\"invite frame\",{shareId:e.screen_share_id,callId:e.voice_call_id,activeTab:this.deps.isActiveTab(),onCall:this.deps.getActiveVoiceCallId()}),this.disposables.isDisposed)wM(\"invite dropped\",{reason:\"disposed\"});else if(this.requested?.shareId!==e.screen_share_id)if(this.shareId!==e.screen_share_id)if(this.deps.isActiveTab()){if(this.deps.getActiveVoiceCallId()===e.voice_call_id)return this.deps.isAgentRecording()?(wM(\"invite declined\",{reason:\"agent recording\"}),this.deps.apiClient.declineScreenShare(e.screen_share_id).catch(()=>{}),void this.deps.showToast(Na().screenShare.busyWithAgent,\"info\")):void this.startRequest(e.screen_share_id,e.voice_call_id,e.executive_name,UM);wM(\"invite dropped\",{reason:\"not on this call\"})}else wM(\"invite dropped\",{reason:\"not the active tab\"});else wM(\"invite dropped\",{reason:\"already ours\"});else wM(\"invite dropped\",{reason:\"already requested\"})}),this.restoreFromServer=es(\"screen-share: restore from server\",e=>{if(wM(\"rediscovered share\",{shareId:e.screen_share_id,status:e.status,isSharerTab:e.is_sharer_tab,callId:e.voice_call_id,held:{shareId:this.shareId,status:this.shareStatus,owns:this.ownsShare,socket:null!==this.socket}}),!this.disposables.isDisposed)if(this.requested?.shareId!==e.screen_share_id){if(\"requested\"===e.status){if(!this.deps.isActiveTab())return void wM(\"rediscovery dropped\",{reason:\"not the active tab\"});if(this.deps.getActiveVoiceCallId()!==e.voice_call_id)return void wM(\"rediscovery dropped\",{reason:\"not on this call\"});if(this.deps.isAgentRecording())return void wM(\"rediscovery dropped\",{reason:\"agent recording\"});const t=e.expires_at?Date.parse(e.expires_at)-Date.now():UM;return!Number.isFinite(t)||t<=0?void wM(\"rediscovery dropped\",{reason:\"request expired\",remainingMs:t}):void this.startRequest(e.screen_share_id,e.voice_call_id,e.executive_name,Math.min(t,UM))}if(\"accepted\"===e.status||\"active\"===e.status){const t=this.shareId===e.screen_share_id&&this.ownsShare&&!e.is_sharer_tab;this.shareId=e.screen_share_id,this.shareStatus=e.status,this.ownsShare=e.is_sharer_tab,this.ownsShare?(wM(\"rediscovery: we are the sharer tab, reconnecting\"),this.openSocket(e.screen_share_id,\"owner\")):t?(wM(\"rediscovery: another tab took the share, standing down\"),this.becomeTakeoverTab()):\"active\"===e.status?(wM(\"rediscovery: shared elsewhere, offering handoff\"),this.showTakeoverMode()):(wM(\"rediscovery: share not active yet, normal pill\"),this.deps.setCallShareMode({kind:\"normal\"}))}}else wM(\"rediscovery dropped\",{reason:\"card already up\"})}),this.handleStatus=es(\"screen-share: handle status\",e=>{this.disposables.isDisposed||this.applyStatus(e)}),this.deps=e,this.banner=new kM(e.getContainer),this.recorder=new oE(()=>this.socket)}isSharing(){return this.recorder.isRecording()}endLocally(e={}){const t=this.engaged;wM(\"ending locally\",{silent:!0===e.silent,shareId:this.shareId,owns:this.ownsShare,hadSocket:null!==this.socket,wasEngaged:t}),this.clearRequestUi(),this.stopCapture(),this.recorder.abandonSpan(),this.socket?.close(),this.socket=null,this.socketPurpose=null,this.shareId=null,this.shareStatus=null,this.ownsShare=!1,this.switching=!1,this.engaged=!1,this.deps.setCallShareMode({kind:\"normal\"}),this.laser.clear(),t&&!e.silent&&this.deps.showToast(Na().screenShare.ended,\"info\")}destroy(){this.disposables.dispose(),this.endLocally({silent:!0}),this.laser.destroy()}startRequest(e,t,n,i){this.clearRequestTimer(),this.requested={shareId:e,voiceCallId:t,executiveName:n},this.accepting=!1,this.showRequest(),this.titleAttention.start(Na().screenShare.requestTitle),this.requestTimer=this.disposables.safeTimeout(\"screen-share: request timeout\",()=>this.clearRequestUi(),i),this.deps.apiClient.acknowledgeScreenShareInvite(e).catch(()=>{})}showRequest(){const e=this.requested;e&&this.banner.showRequest({executiveName:e.executiveName,onAccept:es(\"screen-share: accept click\",()=>this.accept()),onDecline:es(\"screen-share: decline click\",()=>this.decline())})}accept(){const e=this.requested;e&&!this.accepting?(wM(\"accept click\",{shareId:e.shareId}),this.accepting=!0,this.deps.claimActiveTab(),this.deps.apiClient.acceptScreenShare(e.shareId,this.deps.tabId).then(()=>{this.disposables.isDisposed||(wM(\"accept accepted by server\",{shareId:e.shareId}),this.clearRequestUi(),this.shareId=e.shareId,this.shareStatus=\"accepted\",this.ownsShare=!0,this.openSocket(e.shareId,\"owner\"))}).catch(t=>{this.disposables.isDisposed||(this.accepting=!1,wM(\"accept rejected\",{shareId:e.shareId,status:t instanceof Pi?t.status:null}),t instanceof Pi&&\"http\"===t.kind&&jM.has(t.status)?this.clearRequestUi():(this.deps.showToast(Na().screenShare.acceptFailed,\"error\"),this.requested&&this.showRequest()))})):wM(\"accept click ignored\",{hasRequest:null!==e,accepting:this.accepting})}decline(){const e=this.requested;e&&(this.deps.apiClient.declineScreenShare(e.shareId).catch(()=>{}),this.clearRequestUi())}openSocket(e,t){this.socket?wM(\"socket NOT opened\",{reason:\"one is already open\",wanted:t,openFor:this.socketPurpose,shareId:e}):(wM(\"opening socket\",{shareId:e,purpose:t,tabId:this.deps.tabId}),this.shareId=e,this.socketPurpose=t,this.socket=new zM({apiBaseUrl:this.deps.apiBaseUrl,publishableKey:this.deps.publishableKey,sourceId:this.deps.getSourceId(),tabId:this.deps.tabId,screenShareId:e,takeover:\"takeover\"===t,getIdentityProof:()=>this.deps.apiClient.getIdentityProof()},{onStatus:e=>this.applyStatus(e,!0),onChunkAck:e=>this.recorder.acknowledgeChunk(e),onPointer:e=>this.handlePointer(e),onResync:()=>this.recorder.resync(),onReady:()=>this.handleSocketReady(),onClosed:e=>this.handleSocketClosed(e)}),this.socket.connect())}handleSocketReady(){wM(\"socket ready\",{shareId:this.shareId,purpose:this.socketPurpose}),this.engaged=!0,\"owner\"===this.socketPurpose&&this.recorder.getScopeKey()===this.shareScopeKey()&&this.recorder.flushOnConnectionReady(),this.recorder.isRecording()&&this.recorder.resync()}handleSocketClosed(e){const t=this.socketPurpose;if(wM(\"socket closed\",{code:e,purpose:t,shareId:this.shareId,owns:this.ownsShare}),4010===e||\"takeover\"===t)return this.becomeTakeoverTab(),void(\"takeover\"===t&&this.deps.showToast(Na().screenShare.switchFailed,\"error\"));this.endLocally({silent:4003===e||4004===e||4010===e})}applyStatus(e,t=!1){const n=this.shareId??this.requested?.shareId??null;wM(\"status frame\",{via:t?\"share socket\":\"conversation socket\",shareId:e.screen_share_id,status:e.status,endReason:e.end_reason,held:{shareId:this.shareId,owns:this.ownsShare,switching:this.switching,purpose:this.socketPurpose}}),null===n||e.screen_share_id===n?\"ended\"!==e.status?(this.shareStatus=e.status,e.screen_share_id!==this.shareId&&(this.clearRequestUi(),this.shareId=e.screen_share_id,this.ownsShare=!1),t&&(this.ownsShare=!0,this.switching=!1),!this.ownsShare||\"accepted\"!==e.status&&\"active\"!==e.status||this.startCapture(),\"active\"===e.status&&(this.ownsShare?(wM(\"pill: sharing here\"),this.deps.setCallShareMode({kind:\"owner\",onStop:es(\"screen-share: stop click\",()=>this.stopSharing())})):this.showTakeoverMode()),t&&(this.socketPurpose=\"owner\")):this.endLocally():wM(\"status dropped\",{reason:\"other share\",known:n})}startCapture(){null===this.shareId||this.recorder.isRecording()?wM(\"capture not started\",{shareId:this.shareId,alreadyRecording:this.recorder.isRecording()}):(wM(\"capture starting\",{shareId:this.shareId,resume:\"takeover\"!==this.socketPurpose}),this.recorder.start(this.shareScopeKey(),{resume:\"takeover\"!==this.socketPurpose}))}showTakeoverMode(){if(null===this.shareId||\"active\"!==this.shareStatus)return wM(\"pill: normal call\",{shareId:this.shareId,status:this.shareStatus}),void this.deps.setCallShareMode({kind:\"normal\"});wM(\"pill: handoff offered\",{shareId:this.shareId}),this.deps.setCallShareMode({kind:\"available\",onTakeover:es(\"screen-share: takeover click\",()=>this.takeOver())})}takeOver(){if(wM(\"takeover click\",{shareId:this.shareId,status:this.shareStatus,owns:this.ownsShare,switching:this.switching,hasSocket:null!==this.socket,agentRecording:this.deps.isAgentRecording()}),null===this.shareId||\"active\"!==this.shareStatus||this.ownsShare||this.switching)wM(\"takeover blocked\",{reason:null===this.shareId?\"no share\":\"active\"!==this.shareStatus?\"share not active\":this.ownsShare?\"already ours\":\"a switch is already in flight\"});else{if(this.deps.isAgentRecording())return wM(\"takeover blocked\",{reason:\"agent recording\"}),void this.deps.showToast(Na().screenShare.busyWithAgent,\"info\");this.switching=!0,this.deps.claimActiveTab(),this.recorder.abandonSpan(),this.deps.setCallShareMode({kind:\"switching\"}),this.openSocket(this.shareId,\"takeover\")}}becomeTakeoverTab(){wM(\"standing down as sharer\",{shareId:this.shareId});const e=this.socket;this.socket=null,this.socketPurpose=null,this.stopCapture(),this.recorder.abandonSpan(),e?.close(),this.laser.clear(),this.ownsShare=!1,this.switching=!1,this.engaged=!1,this.showTakeoverMode()}shareScopeKey(){return`share:${this.shareId}`}stopCapture(){this.recorder.stop()}stopSharing(){wM(\"stop-share click\",{shareId:this.shareId}),this.stopCapture()}handlePointer(e){\"leave\"===e.kind?this.laser.leave():\"click\"===e.kind?this.laser.click(e.x,e.y,this.recorder.resolveNode(e.node_id),e.executive_name):this.laser.pointTo(e.x,e.y),this.recorder.stampPointer({kind:e.kind,x:e.x,y:e.y,node_id:e.node_id,executive_name:e.executive_name})}clearRequestUi(){this.requested=null,this.accepting=!1,this.banner.hide(),this.titleAttention.stop(),this.clearRequestTimer()}clearRequestTimer(){null!==this.requestTimer&&(clearTimeout(this.requestTimer),this.requestTimer=null)}}class VM{constructor(e,t,n,i,s=!1){this.expandedStepUuid=null,this.cardElement=null,this.moduleEl=e,this.data=t,this.onStepTest=n,this.onStepConfigure=i,this.isAdminMode=s,this.translations=Na(),this.completedStepUuids=new Set(t.completed_step_uuids);const r=t.steps.find(e=>!this.completedStepUuids.has(e.uuid));r&&(this.expandedStepUuid=r.uuid)}render(){this.moduleEl.querySelector(\".support-onboarding-card\")||(this.cardElement=this.renderCard(),this.moduleEl.appendChild(this.cardElement))}cleanup(){this.cardElement&&(os(this.cardElement),this.cardElement=null)}renderCard(){const e=document.createElement(\"div\");e.className=\"support-onboarding-card\";const t=document.createElement(\"div\");t.className=\"support-onboarding-header\";const n=document.createElement(\"div\");n.className=\"support-onboarding-title\",n.textContent=this.data.name||this.translations.onboarding.title;const i=document.createElement(\"div\");i.className=\"support-onboarding-progress-meta\",i.textContent=this.translations.onboarding.progressMeta(this.completedStepUuids.size,this.data.steps.length);const s=document.createElement(\"div\");s.className=\"support-onboarding-progress-bar\";const r=document.createElement(\"div\");return r.className=\"support-onboarding-progress-fill\",r.style.width=`${this.progressPercent()}%`,s.appendChild(r),t.appendChild(n),t.appendChild(i),t.appendChild(s),e.appendChild(t),this.data.steps.forEach((t,n)=>{e.appendChild(this.renderStepRow(t,n))}),e}renderStepRow(e,t){const n=document.createElement(\"div\");n.className=\"support-onboarding-step\",n.dataset.stepUuid=e.uuid,this.applyStepClasses(n,e);const i=document.createElement(\"div\");i.className=\"support-onboarding-step-header\";const s=document.createElement(\"div\");s.className=\"support-onboarding-step-number\",this.completedStepUuids.has(e.uuid)?s.innerHTML='<svg viewBox=\"0 0 24 24\"><polyline points=\"20 6 9 17 4 12\"/></svg>':s.textContent=`${t+1}`;const r=document.createElement(\"div\");r.className=\"support-onboarding-step-title\",r.textContent=e.title;const o=document.createElement(\"div\");if(o.className=\"support-onboarding-step-chevron\",o.innerHTML='<svg viewBox=\"0 0 24 24\"><polyline points=\"9 18 15 12 9 6\"/></svg>',i.appendChild(s),i.appendChild(r),this.isAdminMode){const t=document.createElement(\"span\"),n=!0===e.is_configured;t.className=\"support-onboarding-step-badge \"+(n?\"ready\":\"needs-config\"),t.textContent=n?this.translations.onboarding.readyBadge:this.translations.onboarding.needsConfigBadge,i.appendChild(t)}i.appendChild(o),i.addEventListener(\"click\",()=>{this.completedStepUuids.has(e.uuid)||this.toggleStep(e.uuid)});const a=document.createElement(\"div\");a.className=\"support-onboarding-step-body\";const l=document.createElement(\"div\");l.className=\"support-onboarding-step-body-inner\";const c=document.createElement(\"p\");if(c.className=\"support-onboarding-step-description\",c.textContent=e.description,l.appendChild(c),this.isAdminMode){const t=document.createElement(\"div\");if(t.className=\"support-onboarding-step-cta-group\",!0===e.is_configured){const n=document.createElement(\"button\");n.className=\"support-onboarding-step-cta support-onboarding-step-cta-test\",n.textContent=this.translations.onboarding.testStepLabel,n.addEventListener(\"click\",t=>{t.stopPropagation(),this.onStepTest(e)}),t.appendChild(n)}const n=document.createElement(\"button\");n.className=\"support-onboarding-step-cta support-onboarding-step-cta-configure\",n.textContent=this.translations.onboarding.configureStepLabel,n.addEventListener(\"click\",t=>{t.stopPropagation(),this.onStepConfigure(e)}),t.appendChild(n),l.appendChild(t)}else{const t=document.createElement(\"button\");t.className=\"support-onboarding-step-cta\",t.textContent=this.translations.onboarding.ctaLabel,t.addEventListener(\"click\",t=>{t.stopPropagation(),this.onStepTest(e)}),l.appendChild(t)}return a.appendChild(l),n.appendChild(i),n.appendChild(a),this.expandedStepUuid!==e.uuid||this.completedStepUuids.has(e.uuid)||requestAnimationFrame(()=>{a.style.maxHeight=`${a.scrollHeight}px`}),n}applyStepClasses(e,t){e.classList.remove(\"active\",\"completed\",\"expanded\"),this.completedStepUuids.has(t.uuid)?e.classList.add(\"completed\"):this.expandedStepUuid===t.uuid&&e.classList.add(\"active\",\"expanded\")}toggleStep(e){this.cardElement&&(this.expandedStepUuid===e?(this.collapseStep(e),this.expandedStepUuid=null):(null!==this.expandedStepUuid&&this.collapseStep(this.expandedStepUuid),this.expandedStepUuid=e,this.expandStep(e)))}expandStep(e){if(!this.cardElement)return;const t=this.cardElement.querySelector(`[data-step-uuid=\"${e}\"]`);if(!t)return;t.classList.add(\"active\",\"expanded\");const n=t.querySelector(\".support-onboarding-step-body\");n&&(n.style.maxHeight=`${n.scrollHeight}px`)}collapseStep(e){if(!this.cardElement)return;const t=this.cardElement.querySelector(`[data-step-uuid=\"${e}\"]`);if(!t)return;t.classList.remove(\"active\",\"expanded\");const n=t.querySelector(\".support-onboarding-step-body\");n&&(n.style.maxHeight=\"0\")}progressPercent(){return 0===this.data.steps.length?0:this.completedStepUuids.size/this.data.steps.length*100}}class GM{constructor(e,t,n,i,s=!1,r){this.moduleEl=null,this.shortcutsEl=null,this.engineeringTicketsEl=null,this.lastTicketEl=null,this.titleOverride=\"\",this.aiIconUrl=\"\",this.onboardingManager=null,this.onboardingData=null,this.currentOnboardingType=\"company\",this.cachedOnboardings={company:null,user:null},this.onboardingTypeTabsEl=null,this.onOnboardingDataLoaded=null,this.onResumeConversation=null,this.onSelectEngineeringTicket=null,this.onOpenLastTicket=null,this.container=e,this.apiClient=t,this.onStepTest=n,this.onStepConfigure=i,this.isAdminMode=s,this.welcomeSubtitle=r,this.translations=Na()}setOnOnboardingDataLoaded(e){this.onOnboardingDataLoaded=e}setOnResumeConversation(e){this.onResumeConversation=e}setOnSelectEngineeringTicket(e){this.onSelectEngineeringTicket=e}setOnOpenLastTicket(e){this.onOpenLastTicket=e}isPreview(){return this.isAdminMode}setTitle(e){this.titleOverride=e}setAiIconUrl(e){this.aiIconUrl=e;const t=this.moduleEl?.querySelector(\".support-welcome-hero-avatar\");t&&(t.innerHTML=this.heroAvatarMarkup())}heroAvatarMarkup(){return this.aiIconUrl?`<img class=\"support-avatar-image\" src=\"${this.escapeHtml(this.aiIconUrl)}\" alt=\"AI\" />`:`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${L}</svg>`}show(){const e=this.getHomeContainer();e&&(this.moduleEl||(this.moduleEl=this.createModuleElement(),e.appendChild(this.moduleEl)),this.cleanupOnboarding(),this.fetchOnboarding())}getOnboardingData(){return this.onboardingData}async refresh(){await this.fetchOnboarding()}destroy(){this.cleanupOnboarding(),os(this.moduleEl),this.moduleEl=null,os(this.shortcutsEl),this.shortcutsEl=null,os(this.engineeringTicketsEl),this.engineeringTicketsEl=null,os(this.onboardingTypeTabsEl),this.onboardingTypeTabsEl=null}setActiveConversationShortcuts(e){const t=this.getHomeContainer();if(!t)return;if(this.isAdminMode)return os(this.shortcutsEl),void(this.shortcutsEl=null);if(os(this.shortcutsEl),this.shortcutsEl=null,0===e.length)return;const n=document.createElement(\"div\");n.className=\"support-home-shortcuts\",e.forEach(e=>{const t=document.createElement(\"button\");t.type=\"button\",t.className=\"support-home-shortcut-card\",e.unread&&t.classList.add(\"has-unread\"),t.setAttribute(\"data-shortcut-type\",e.type);const i=\"session\"===e.type?`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${L}</svg>`:`<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">${R}</svg>`,s=\"session\"===e.type?this.translations.home.resumeSession:this.translations.home.resumeTicket,r=e.unread?this.translations.home.newMessage:this.translations.home.resumeHint;t.innerHTML=`\\n        <div class=\"support-home-shortcut-icon ${e.type}\">${i}${e.unread?'<span class=\"support-home-shortcut-dot\"></span>':\"\"}</div>\\n        <div class=\"support-home-shortcut-text\">\\n          <span class=\"support-home-shortcut-label\">${s}</span>\\n          <span class=\"support-home-shortcut-hint\">${r}</span>\\n        </div>\\n        <svg class=\"support-home-shortcut-arrow\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\\n          <polyline points=\"9 6 15 12 9 18\"/>\\n        </svg>\\n      `,t.addEventListener(\"click\",()=>{this.onResumeConversation?.(e.type,e.id)}),n.appendChild(t)}),this.shortcutsEl=n,t.appendChild(n)}clearActiveConversationShortcuts(){os(this.shortcutsEl),this.shortcutsEl=null}setEngineeringTickets(e){const t=this.getHomeContainer();if(!t)return;if(os(this.engineeringTicketsEl),this.engineeringTicketsEl=null,this.isAdminMode||0===e.length)return;const n=document.createElement(\"div\");n.className=\"support-engineering-tickets\";const i=document.createElement(\"div\");i.className=\"support-engineering-tickets-heading\",i.textContent=this.translations.engineeringTickets.heading,n.appendChild(i),e.forEach(e=>{const t=document.createElement(\"button\");t.type=\"button\",t.className=\"support-engineering-ticket-card\",t.setAttribute(\"data-ticket-status\",e.status);const i=this.translations.engineeringTickets.statuses[e.status]||e.status;t.innerHTML=`\\n        <div class=\"support-engineering-ticket-icon\">\\n          <svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\\n            <path d=\"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z\"/>\\n          </svg>\\n        </div>\\n        <div class=\"support-engineering-ticket-text\">\\n          <span class=\"support-engineering-ticket-message\">${this.escapeHtml(e.title)}</span>\\n          <span class=\"support-engineering-ticket-status ${e.status}\">${this.escapeHtml(i)}</span>\\n        </div>\\n        <svg class=\"support-engineering-ticket-arrow\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\\n          <polyline points=\"9 6 15 12 9 18\"/>\\n        </svg>\\n      `,t.addEventListener(\"click\",()=>{this.onSelectEngineeringTicket?.(e)}),n.appendChild(t)}),this.engineeringTicketsEl=n,t.appendChild(n)}setLastTicket(e){const t=this.getHomeContainer();if(!t)return;if(os(this.lastTicketEl),this.lastTicketEl=null,this.isAdminMode||!e)return;const n=this.translations.lastTicket,i=(e.description||\"\").trim()||n.fallbackTitle,s=n.statuses[e.status]||e.status,r=e.last_message,o=ls(r?.sent_at||e.resolved_at||e.last_message_at),a=r?\"contact\"===r.role?`${n.you}: ${r.preview}`:r.preview:n.subtitle,l=\"agent\"===r?.role&&r.author_name?` title=\"${this.escapeHtml(r.author_name)}\"`:\"\",c=document.createElement(\"div\");c.className=\"support-last-ticket\";const d=document.createElement(\"div\");d.className=\"support-last-ticket-heading\",d.textContent=n.heading,c.appendChild(d);const u=document.createElement(\"button\");u.type=\"button\",u.className=\"support-last-ticket-card\",u.setAttribute(\"data-ticket-status\",e.status),u.innerHTML=`\\n      <div class=\"support-last-ticket-avatar\"${l}>${this.lastTicketAvatar(r)}</div>\\n      <div class=\"support-last-ticket-body\">\\n        <div class=\"support-last-ticket-row\">\\n          <span class=\"support-last-ticket-title\">${this.escapeHtml(i)}</span>\\n          <span class=\"support-last-ticket-meta\">\\n            <span class=\"support-last-ticket-status ${e.status}\">${this.escapeHtml(s)}</span>\\n            ${o?`<span class=\"support-last-ticket-time\">${this.escapeHtml(o)}</span>`:\"\"}\\n          </span>\\n        </div>\\n        <span class=\"support-last-ticket-preview\">${this.escapeHtml(a)}</span>\\n      </div>\\n      <svg class=\"support-last-ticket-arrow\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\\n        <polyline points=\"9 6 15 12 9 18\"/>\\n      </svg>\\n    `,u.addEventListener(\"click\",()=>{this.onOpenLastTicket?.(e.session_id,e.status)}),c.appendChild(u),this.lastTicketEl=c,t.appendChild(c)}lastTicketAvatar(e){return\"agent\"===e?.role||\"contact\"===e?.role?`<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">${R}</svg>`:this.aiIconUrl?`<img src=\"${this.escapeHtml(this.aiIconUrl)}\" alt=\"\" />`:`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${L}</svg>`}escapeHtml(e){return e.replace(/&/g,\"&amp;\").replace(/</g,\"&lt;\").replace(/>/g,\"&gt;\").replace(/\"/g,\"&quot;\").replace(/'/g,\"&#39;\")}createModuleElement(){const e=document.createElement(\"div\");e.className=\"support-welcome-module\";const t=document.createElement(\"div\");t.className=\"support-welcome-message support-welcome-hero\";const n=this.isAdminMode?this.translations.adminMode.homeTitle:this.titleOverride||this.translations.messages.welcomeTitle,i=this.isAdminMode?this.translations.adminMode.homeSubtitle:this.welcomeSubtitle||this.translations.messages.welcomeSubtitle;return t.innerHTML=`\\n      <div class=\"support-welcome-hero-content\">\\n        <div class=\"support-welcome-hero-header\">\\n          <div class=\"support-avatar ai support-welcome-hero-avatar\">\\n            ${this.heroAvatarMarkup()}\\n          </div>\\n          <h2 class=\"support-welcome-hero-title\">${n}</h2>\\n        </div>\\n        <p class=\"support-welcome-hero-subtitle\">${this.escapeHtml(i)}</p>\\n      </div>\\n    `,e.appendChild(t),e}async fetchOnboarding(){try{if(!this.isAdminMode){const e=await this.apiClient.onboardingMatch();return e?(this.onboardingData=e,this.moduleEl&&(this.onboardingManager?.cleanup(),this.onboardingManager=new VM(this.moduleEl,e,e=>this.onStepTest(e),e=>this.onStepConfigure(e),this.isAdminMode),this.onboardingManager.render()),void this.onOnboardingDataLoaded?.(e)):void this.cleanupOnboarding()}const[e,t]=await Promise.all([this.apiClient.onboardingPreview(\"company\"),this.apiClient.onboardingPreview(\"user\")]);if(this.cachedOnboardings={company:e,user:t},!e&&!t)return;const n=e?\"company\":\"user\";this.currentOnboardingType=n;const i=this.cachedOnboardings[n];if(!i)return;this.renderOnboardingTypeTabs(),this.onboardingData=i,this.moduleEl&&(this.onboardingManager?.cleanup(),this.onboardingManager=new VM(this.moduleEl,i,e=>this.onStepTest(e),e=>this.onStepConfigure(e),this.isAdminMode),this.onboardingManager.render()),this.onOnboardingDataLoaded?.(i)}catch{}}renderOnboardingTypeTabs(){if(!this.moduleEl)return;os(this.onboardingTypeTabsEl);const e=document.createElement(\"div\");e.className=\"support-onboarding-type-tabs\";[\"company\",\"user\"].forEach(t=>{const n=document.createElement(\"button\");n.type=\"button\",n.className=\"support-onboarding-type-tab\",n.dataset.onboardingType=t,n.textContent=this.translations.onboarding.typeTabs[t],t===this.currentOnboardingType&&n.classList.add(\"is-active\"),this.cachedOnboardings[t]||(n.disabled=!0),e.appendChild(n)}),e.addEventListener(\"click\",e=>{const t=e.target.closest(\".support-onboarding-type-tab\");if(!t||t.disabled)return;const n=t.dataset.onboardingType;n&&this.setActiveOnboardingTab(n)});const t=this.moduleEl.querySelector(\".support-welcome-hero\");t?t.insertAdjacentElement(\"afterend\",e):this.moduleEl.appendChild(e),this.onboardingTypeTabsEl=e}setActiveOnboardingTab(e){if(e===this.currentOnboardingType)return;const t=this.cachedOnboardings[e];t&&(this.currentOnboardingType=e,this.onboardingTypeTabsEl&&this.onboardingTypeTabsEl.querySelectorAll(\".support-onboarding-type-tab\").forEach(t=>{t.classList.toggle(\"is-active\",t.dataset.onboardingType===e)}),this.onboardingData=t,this.moduleEl&&(this.onboardingManager?.cleanup(),this.onboardingManager=new VM(this.moduleEl,t,e=>this.onStepTest(e),e=>this.onStepConfigure(e),this.isAdminMode),this.onboardingManager.render()),this.onOnboardingDataLoaded?.(t))}cleanupOnboarding(){this.onboardingManager?.cleanup(),this.onboardingManager=null,this.onboardingData=null,os(this.onboardingTypeTabsEl),this.onboardingTypeTabsEl=null,this.cachedOnboardings={company:null,user:null},this.onOnboardingDataLoaded?.(null)}getHomeContainer(){return this.container.querySelector('.support-view[data-view=\"home\"]')}}const KM={home:'<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 10l9-7 9 7v10a2 2 0 0 1-2 2h-4v-6h-6v6H5a2 2 0 0 1-2-2z\"/></svg>',messages:'<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\"/></svg>',releases:'<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 11l18-5v12L3 14v-3z\"/><path d=\"M11.6 16.8a3 3 0 1 1-5.8-1.6\"/></svg>'};class YM{constructor(e,t,n=[\"home\",\"messages\",\"releases\"]){this.barEl=null,this.onBarClick=null,this.container=e,this.onChange=t,this.visibleTabs=n}init(){if(this.barEl=this.container.querySelector(\".support-tab-bar\"),!this.barEl)return;const e=Na();this.barEl.innerHTML=this.renderButtons(e),this.onBarClick=e=>{const t=e.target.closest(\".support-tab\");if(!t)return;const n=t.getAttribute(\"data-tab\");n&&this.onChange(n)},this.barEl.addEventListener(\"click\",this.onBarClick)}destroy(){this.barEl&&this.onBarClick&&this.barEl.removeEventListener(\"click\",this.onBarClick),this.onBarClick=null}setActiveTab(e){this.barEl&&this.barEl.querySelectorAll(\".support-tab\").forEach(t=>{t.classList.toggle(\"is-active\",t.getAttribute(\"data-tab\")===e)})}setUnreadBadge(e,t){if(!this.barEl)return;const n=this.barEl.querySelector(`.support-tab[data-tab=\"${e}\"]`);if(!n)return;let i=n.querySelector(\".support-tab-badge\");t>0?(i||(i=document.createElement(\"span\"),i.className=\"support-tab-badge\",n.appendChild(i)),i.textContent=t>99?\"99+\":String(t)):i&&os(i)}updateLanguage(e){this.barEl&&(this.barEl.innerHTML=this.renderButtons(e))}renderButtons(e){const t={home:e.tabs.home,messages:e.tabs.messages,releases:e.tabs.releases};return this.visibleTabs.map(e=>`\\n        <button class=\"support-tab${\"home\"===e?\" is-active\":\"\"}\" data-tab=\"${e}\" type=\"button\">\\n          ${KM[e]}\\n          <span class=\"support-tab-label\">${t[e]}</span>\\n        </button>\\n      `).join(\"\")}}class XM{constructor(e,t){this.current=\"home\",this.chatWindow=e,this.hooks=t,this.chatWindow.setAttribute(\"data-active-view\",this.current)}showView(e){const t=this.current;this.current=e,this.chatWindow.setAttribute(\"data-active-view\",e),this.hooks[e]?.(t)}getCurrentView(){return this.current}}class JM{constructor(e,t,n,i){this.items=[],this.fetchedOffset=0,this.hasMore=!0,this.loading=!1,this.loaded=!1,this.container=e,this.apiClient=t,this.filter=n,this.onSelect=i,this.translations=Na()}async ensureLoaded(){this.loaded||this.loading||await this.load()}async reload(){this.items=[],this.fetchedOffset=0,this.hasMore=!0,this.loaded=!1,await this.load()}updateLanguage(e){this.translations=e,this.loaded&&this.render()}async load(){this.loading=!0,this.renderLoading();try{await this.fetchUntilEnough(10),this.loaded=!0,this.render()}catch{this.renderError()}finally{this.loading=!1}}async loadMore(){if(!this.loading&&this.hasMore){this.loading=!0;try{const e=this.items.length;await this.fetchUntilEnough(e+10),this.render()}finally{this.loading=!1}}}async fetchUntilEnough(e){for(;this.items.length<e&&this.hasMore;){const e=await this.apiClient.getContactHistory(10,this.fetchedOffset);if(this.fetchedOffset+=e.results.length,this.hasMore=null!==e.next,0===e.results.length){this.hasMore=!1;break}for(const t of e.results)t.type===this.filter&&this.items.push(t)}}render(){if(this.container.innerHTML=\"\",0===this.items.length){const e=document.createElement(\"div\");return e.className=\"support-conversation-empty\",e.textContent=this.translations.history.noHistory,void this.container.appendChild(e)}const e=document.createElement(\"div\");e.className=\"support-conversation-list\";if(this.groupByTime(this.items).forEach(t=>{const n=document.createElement(\"div\");n.className=\"support-conversation-group\",n.textContent=t.label,e.appendChild(n),t.items.forEach(t=>e.appendChild(this.createItem(t)))}),this.hasMore){const t=document.createElement(\"button\");t.type=\"button\",t.className=\"support-conversation-load-more\",t.textContent=this.translations.history.loadMore,t.addEventListener(\"click\",()=>this.loadMore()),e.appendChild(t)}e.addEventListener(\"scroll\",()=>{e.scrollTop+e.clientHeight>=e.scrollHeight-50&&this.loadMore()}),this.container.appendChild(e)}renderLoading(){this.container.innerHTML=`<div class=\"support-conversation-loading\">${this.escapeHtml(this.translations.history.loading)}</div>`}renderError(){this.container.innerHTML=`<div class=\"support-conversation-empty\">${this.escapeHtml(this.translations.history.noHistory)}</div>`}createItem(e){const t=document.createElement(\"button\");t.type=\"button\",t.className=\"support-conversation-item\";const n=!0===e.last_message_is_voice_note,i=(e.last_message_body??\"\").trim()||(e.description||\"\").trim()||this.translations.history.newConversation,s=\"session\"===e.type?`<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${L}</svg>`:`<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">${R}</svg>`,r=e.status?e.status.charAt(0).toUpperCase()+e.status.slice(1):\"\";return t.innerHTML=`\\n      <div class=\"support-conversation-item-icon ${e.type}\">${s}</div>\\n      <div class=\"support-conversation-item-info\">\\n        ${n?`<span class=\"support-conversation-item-desc voice\"><svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">${xc}</svg>${this.escapeHtml(this.translations.history.voiceMessage)}</span>`:`<span class=\"support-conversation-item-desc\">${this.escapeHtml(i)}</span>`}\\n        <div class=\"support-conversation-item-meta\">\\n          ${r?`<span class=\"support-conversation-item-badge ${e.status}\">${this.escapeHtml(r)}</span>`:\"\"}\\n          <span class=\"support-conversation-item-time\">${ls(e.last_message_at)}</span>\\n        </div>\\n      </div>\\n    `,t.addEventListener(\"click\",()=>{this.onSelect({id:e.id,type:e.type,status:e.status,wasEscalated:e.was_escalated})}),t}groupByTime(e){const t=new Date,n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),i=new Date(n.getTime()-864e5),s=new Date(n.getTime()-6048e5),r={today:[],yesterday:[],lastWeek:[],older:[]};for(const t of e){const e=new Date(t.last_message_at);e>=n?r.today.push(t):e>=i?r.yesterday.push(t):e>=s?r.lastWeek.push(t):r.older.push(t)}const o=[];return r.today.length&&o.push({label:this.translations.history.today,items:r.today}),r.yesterday.length&&o.push({label:this.translations.history.yesterday,items:r.yesterday}),r.lastWeek.length&&o.push({label:this.translations.history.lastWeek,items:r.lastWeek}),r.older.length&&o.push({label:this.translations.history.older,items:r.older}),o}escapeHtml(e){const t=document.createElement(\"div\");return t.textContent=e,t.innerHTML}}class QM{constructor(e,t,n){this.activeFilter=\"session\",this.subtabsEl=null,this.unreadByFilter={session:0,ticket:0},this.initialized=!1,this.container=e,this.apiClient=t,this.onSelect=n,this.translations=Na()}init(){this.initialized||(this.initialized=!0,this.container.innerHTML=`\\n      <div class=\"support-messages-subtabs\" role=\"tablist\">\\n        <button class=\"support-messages-subtab is-active\" data-filter=\"session\" type=\"button\">\\n          <span class=\"support-messages-subtab-label\">${this.escapeHtml(this.translations.messagesView.subtabSession)}</span>\\n          <span class=\"support-messages-subtab-badge\" data-filter=\"session\" hidden></span>\\n        </button>\\n        <button class=\"support-messages-subtab\" data-filter=\"ticket\" type=\"button\">\\n          <span class=\"support-messages-subtab-label\">${this.escapeHtml(this.translations.messagesView.subtabTicket)}</span>\\n          <span class=\"support-messages-subtab-badge\" data-filter=\"ticket\" hidden></span>\\n        </button>\\n      </div>\\n      <div class=\"support-messages-list-wrap\" data-filter=\"session\"></div>\\n      <div class=\"support-messages-list-wrap\" data-filter=\"ticket\" hidden></div>\\n    `,this.subtabsEl=this.container.querySelector(\".support-messages-subtabs\"),this.subtabsEl?.addEventListener(\"click\",e=>{const t=e.target.closest(\".support-messages-subtab\");if(!t)return;const n=t.getAttribute(\"data-filter\");n&&this.setFilter(n)}),this.sessionsContainer=this.container.querySelector('.support-messages-list-wrap[data-filter=\"session\"]'),this.ticketsContainer=this.container.querySelector('.support-messages-list-wrap[data-filter=\"ticket\"]'),this.sessionsList=new JM(this.sessionsContainer,this.apiClient,\"session\",this.onSelect),this.ticketsList=new JM(this.ticketsContainer,this.apiClient,\"ticket\",this.onSelect))}setFilter(e){this.init(),this.activeFilter=e,this.subtabsEl?.querySelectorAll(\".support-messages-subtab\").forEach(t=>{t.classList.toggle(\"is-active\",t.getAttribute(\"data-filter\")===e)}),this.sessionsContainer.hidden=\"session\"!==e,this.ticketsContainer.hidden=\"ticket\"!==e,this.activeList().ensureLoaded()}ensureLoaded(){return this.init(),this.activeList().ensureLoaded()}setUnreadBadge(e,t){if(this.unreadByFilter[e]=t,!this.subtabsEl)return;const n=this.subtabsEl.querySelector(`.support-messages-subtab-badge[data-filter=\"${e}\"]`);n&&(t>0?(n.textContent=t>99?\"99+\":String(t),n.hidden=!1):(n.hidden=!0,n.textContent=\"\"))}updateLanguage(e){if(this.translations=e,this.sessionsList?.updateLanguage(e),this.ticketsList?.updateLanguage(e),this.subtabsEl){const t=this.subtabsEl.querySelector('.support-messages-subtab[data-filter=\"session\"] .support-messages-subtab-label'),n=this.subtabsEl.querySelector('.support-messages-subtab[data-filter=\"ticket\"] .support-messages-subtab-label');t&&(t.textContent=e.messagesView.subtabSession),n&&(n.textContent=e.messagesView.subtabTicket)}}activeList(){return\"session\"===this.activeFilter?this.sessionsList:this.ticketsList}escapeHtml(e){const t=document.createElement(\"div\");return t.textContent=e,t.innerHTML}}class ZM{constructor(e){this.scrimEl=null,this.sheetEl=null,this.onOpenConversation=null,this.root=e}setOnOpenConversation(e){this.onOpenConversation=e}open(e){this.close();const t=Na(),n=t.engineeringTickets.statuses[e.status]||e.status,i=e.body.trim(),{conversationId:s}=e,r=i?`<div class=\"support-ticket-sheet-body-label\">${this.escapeHtml(t.ticketDetail.descriptionLabel)}</div>\\n         <div class=\"support-ticket-sheet-desc\">${this.escapeHtml(i)}</div>`:\"\",o=null!==s?`<button type=\"button\" class=\"support-ticket-sheet-cta\">\\n             <span class=\"support-ticket-sheet-cta-icon\"><svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\"/></svg></span>\\n             <span class=\"support-ticket-sheet-cta-label\">${this.escapeHtml(t.ticketDetail.openConversation)}</span>\\n             <span class=\"support-ticket-sheet-cta-arrow\"><svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M5 12h14M13 6l6 6-6 6\"/></svg></span>\\n           </button>`:`<div class=\"support-ticket-sheet-nolink\">\\n             <span class=\"support-ticket-sheet-nolink-icon\"><svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M18.36 6.64a9 9 0 1 1-12.73 0\"/><line x1=\"12\" y1=\"2\" x2=\"12\" y2=\"12\"/></svg></span>\\n             <span>${this.escapeHtml(t.ticketDetail.noConversation)}</span>\\n           </div>`,a=document.createElement(\"div\");a.className=\"support-ticket-sheet-scrim\",a.addEventListener(\"click\",()=>this.close());const l=document.createElement(\"div\");if(l.className=\"support-ticket-sheet\",l.innerHTML=`\\n      <div class=\"support-ticket-sheet-grip\"></div>\\n      <div class=\"support-ticket-sheet-content\">\\n        <div class=\"support-ticket-sheet-meta\">\\n          <span class=\"support-ticket-sheet-status ${e.status}\">${this.escapeHtml(n)}</span>\\n        </div>\\n        <h2 class=\"support-ticket-sheet-title\">${this.escapeHtml(e.title)}</h2>\\n        ${r}\\n        ${o}\\n      </div>\\n    `,null!==s){const e=l.querySelector(\".support-ticket-sheet-cta\");e?.addEventListener(\"click\",()=>this.onOpenConversation?.(s))}this.root.appendChild(a),this.root.appendChild(l),this.scrimEl=a,this.sheetEl=l,l.offsetHeight,a.classList.add(\"is-visible\"),l.classList.add(\"is-visible\")}close(){const e=this.scrimEl,t=this.sheetEl;this.scrimEl=null,this.sheetEl=null,(e||t)&&(e?.classList.remove(\"is-visible\"),t?.classList.remove(\"is-visible\"),window.setTimeout(()=>{os(e),os(t)},280))}escapeHtml(e){const t=document.createElement(\"div\");return t.textContent=e,t.innerHTML}}class eA{constructor(e,t,n=!1){this.onUnreadChange=null,this.onCtaClick=null,this.onConfigureClick=null,this.onTestClick=null,this.loaded=!1,this.loading=!1,this.releases=[],this.unreadCount=0,this.impressionsSeen=new Set,this.intersectionObserver=null,this.expandedUuid=null,this.container=e,this.apiClient=t,this.isAdminMode=n,this.translations=Na()}setOnUnreadChange(e){this.onUnreadChange=e}setOnCtaClick(e){this.onCtaClick=e}setOnConfigureClick(e){this.onConfigureClick=e}setOnTestClick(e){this.onTestClick=e}getUnreadCount(){return this.unreadCount}async ensureLoaded(){this.loaded||this.loading||await this.refresh()}async refresh(){this.loading=!0,this.renderLoading();try{const e=this.isAdminMode?await this.apiClient.getAdminReleases():await this.apiClient.getReleases();this.releases=e.results,this.unreadCount=e.unread_count,this.loaded=!0,this.render(),this.onUnreadChange?.(this.unreadCount)}catch{this.renderError()}finally{this.loading=!1}}updateLanguage(e){this.translations=e,this.loaded?this.render():this.renderEmptyInitial()}render(){this.loaded?this.paint():this.renderEmptyInitial()}renderEmptyInitial(){this.container.innerHTML=`\\n      <div class=\"support-releases-empty\">\\n        <div class=\"support-releases-empty-icon\">\\n          <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\\n            <path d=\"M3 11l18-5v12L3 14v-3z\"/>\\n            <path d=\"M11.6 16.8a3 3 0 1 1-5.8-1.6\"/>\\n          </svg>\\n        </div>\\n        <h3 class=\"support-releases-empty-title\">${this.escapeHtml(this.translations.releases.comingSoonTitle)}</h3>\\n        <p class=\"support-releases-empty-subtitle\">${this.escapeHtml(this.translations.releases.comingSoonSubtitle)}</p>\\n      </div>\\n    `}renderLoading(){this.loaded&&this.releases.length>0||(this.container.innerHTML=`\\n      <div class=\"support-releases-loading\">${this.escapeHtml(this.translations.history.loading)}</div>\\n    `)}renderError(){this.renderEmptyInitial()}paint(){if(this.disconnectObserver(),0===this.releases.length)return void this.renderEmptyInitial();const e=document.createElement(\"div\");e.className=\"support-releases-list\";for(const t of this.releases)t.is_dismissed||e.appendChild(this.createCard(t));this.container.innerHTML=\"\",this.container.appendChild(e),this.observeImpressions()}createCard(e){const t=document.createElement(\"article\");t.className=\"support-release-card\",t.dataset.uuid=e.uuid,t.dataset.category=e.category,e.is_read&&t.classList.add(\"is-read\");const n=this.expandedUuid===e.uuid;n&&t.classList.add(\"is-expanded\");const i=this.categoryLabel(e.category),s=this.formatDate(e.published_at),r=this.previewText(e.body),o=e.image_url?`<div class=\"support-release-thumb\"><img src=\"${e.image_url}\" alt=\"\" loading=\"lazy\" /></div>`:\"\",a=Boolean(e.cta_label),l=this.isAdminMode&&a?(()=>{const t=!0===e.is_configured,n=t?this.translations.onboarding.readyBadge:this.translations.onboarding.needsConfigBadge;return`<span class=\"support-release-badge ${t?\"ready\":\"needs-config\"}\">${this.escapeHtml(n)}</span>`})():\"\",c=`\\n      <header class=\"support-release-header\">\\n        <div class=\"support-release-header-text\">\\n          <div class=\"support-release-meta\">\\n            <span class=\"support-release-category\">${this.escapeHtml(i)}</span>\\n            <span class=\"support-release-dot\">·</span>\\n            <span class=\"support-release-date\">${this.escapeHtml(s)}</span>\\n            ${l}\\n          </div>\\n          <h3 class=\"support-release-title\">${this.escapeHtml(e.title)}</h3>\\n          <p class=\"support-release-preview\">${this.escapeHtml(r)}</p>\\n        </div>\\n        ${o}\\n        <svg class=\"support-release-chevron\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\\n          <polyline points=\"6 9 12 15 18 9\"/>\\n        </svg>\\n      </header>\\n    `,d=n?this.renderDetail(e):\"\";return t.innerHTML=c+d,t.addEventListener(\"click\",t=>{const n=t.target;return n.closest(\".support-release-cta-test\")?(t.stopPropagation(),void this.handleTestClick(e)):n.closest(\".support-release-cta-configure\")?(t.stopPropagation(),void this.handleConfigureClick(e)):n.closest(\".support-release-cta\")?(t.stopPropagation(),void this.handleCtaClick(e)):void this.toggleExpand(e)}),t}renderDetail(e){const t=rc.parse(e.body||\"\",{async:!1}),n=e.image_url?`<div class=\"support-release-image\"><img src=\"${e.image_url}\" alt=\"\" loading=\"lazy\" /></div>`:\"\",i=Boolean(e.cta_label);let s=\"\";if(this.isAdminMode)if(i){s=`<div class=\"support-release-cta-group\">${!0===e.is_configured?`<button class=\"support-release-cta support-release-cta-test\" type=\"button\">${this.escapeHtml(this.translations.releases.testReleaseLabel)}</button>`:\"\"}${`<button class=\"support-release-cta support-release-cta-configure\" type=\"button\">${this.escapeHtml(this.translations.releases.configureReleaseLabel)}</button>`}</div>`}else s=`<p class=\"support-release-no-cta-notice\">${this.escapeHtml(this.translations.releases.noCtaNotice)}</p>`;else i&&(s=`<button class=\"support-release-cta\" type=\"button\">${this.escapeHtml(e.cta_label)}</button>`);return`\\n      <div class=\"support-release-detail\">\\n        ${n}\\n        <div class=\"support-release-body\">${t}</div>\\n        ${s}\\n      </div>\\n    `}toggleExpand(e){const t=this.expandedUuid!==e.uuid;this.expandedUuid=t?e.uuid:null,t&&this.markAsRead(e),this.paint(),t&&requestAnimationFrame(()=>{const t=this.container.querySelector(`.support-release-card[data-uuid=\"${e.uuid}\"]`);t?.scrollIntoView({behavior:\"smooth\",block:\"start\"})})}previewText(e){const t=(e||\"\").replace(/```[\\s\\S]*?```/g,\" \").replace(/`[^`]*`/g,\" \").replace(/!\\[[^\\]]*\\]\\([^)]*\\)/g,\" \").replace(/\\[([^\\]]*)\\]\\([^)]*\\)/g,\"$1\").replace(/[#*_>~\\-]/g,\" \").replace(/\\s+/g,\" \").trim();return t.length<=120?t:t.slice(0,117)+\"…\"}observeImpressions(){if(\"undefined\"==typeof IntersectionObserver)return void this.container.querySelectorAll(\".support-release-card\").forEach(e=>{const t=e.dataset.uuid;t&&this.recordImpression(t)});const e=new IntersectionObserver(e=>{e.forEach(e=>{if(!e.isIntersecting)return;const t=e.target.dataset.uuid;t&&this.recordImpression(t)})},{root:this.container,threshold:.4});this.intersectionObserver=e,this.container.querySelectorAll(\".support-release-card\").forEach(t=>{e.observe(t)})}disconnectObserver(){this.intersectionObserver?.disconnect(),this.intersectionObserver=null}destroy(){this.disconnectObserver()}recordImpression(e){this.impressionsSeen.has(e)||(this.impressionsSeen.add(e),this.apiClient.recordReleaseImpression(e).catch(()=>{}))}markAsRead(e){if(e.is_read)return;e.is_read=!0;const t=this.container.querySelector(`.support-release-card[data-uuid=\"${e.uuid}\"]`);t?.classList.add(\"is-read\"),this.unreadCount>0&&(this.unreadCount-=1,this.onUnreadChange?.(this.unreadCount)),this.apiClient.markReleaseRead(e.uuid).catch(()=>{})}handleCtaClick(e){e.is_read||(e.is_read=!0,this.unreadCount>0&&(this.unreadCount-=1,this.onUnreadChange?.(this.unreadCount))),this.onCtaClick?.(e)}handleConfigureClick(e){this.onConfigureClick?.(e)}handleTestClick(e){this.onTestClick?.(e)}categoryLabel(e){return this.translations.releases.categories[e]||e.toUpperCase()}formatDate(e){try{return new Date(e).toLocaleDateString(void 0,{day:\"2-digit\",month:\"short\",year:\"numeric\"})}catch{return\"\"}}escapeHtml(e){const t=document.createElement(\"div\");return t.textContent=e,t.innerHTML}}class tA{constructor(e,t,n,i,s,r=3e4){this.cardElement=null,this.contentElement=null,this.intervalId=null,this.showingCard=!1,this.onboardingData=null,this.checklistData=null,this.animating=!1,this.bubbleHidden=!1,this.transitionVersion=0,this.container=e,this.onCardClick=t,this.onCardDismiss=n,this.isChatOpen=i,this.isBadgeMode=s,this.intervalMs=r}setBubbleHidden(e){this.bubbleHidden=e}setOnboardingData(e){this.onboardingData=e,this.resume()}setChecklistData(e){this.checklistData=e,this.resume()}resume(){const e=this.progressPreview();if(!e||this.isChatOpen()||this.isBadgeMode())this.stop();else{if(this.cardElement||(this.cardElement=this.createCardElement(),this.container.appendChild(this.cardElement)),this.updateCardContent(e),this.bubbleHidden)return this.cardElement.classList.remove(\"hidden\"),void(this.showingCard=!0);this.intervalId||(this.intervalId=setInterval(()=>this.alternate(),this.intervalMs))}}stop(){this.transitionVersion++,this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null),this.forceRestoreState()}rerender(){this.contentElement?.setAttribute(\"aria-label\",Na().aria.openChat),this.cardElement?.querySelector(\".support-obc-close\")?.setAttribute(\"aria-label\",Na().aria.minimizeChat),this.resume()}destroy(){this.stop(),os(this.cardElement),this.cardElement=null,this.contentElement=null,this.onboardingData=null,this.checklistData=null}alternate(){this.animating||(this.isChatOpen()?this.showingCard&&this.transitionToElement(\"bubble\"):this.showingCard?this.transitionToElement(\"bubble\"):this.transitionToElement(\"card\"))}transitionToElement(e){const t=this.container.querySelector(\".support-bubble\");if(!t||!this.cardElement)return;this.animating=!0;const n=++this.transitionVersion,i=\"card\"===e?t:this.cardElement,s=\"card\"===e?this.cardElement:t;if(window.matchMedia?.(\"(prefers-reduced-motion: reduce)\").matches)return i.classList.add(\"hidden\"),s.classList.remove(\"hidden\"),this.animating=!1,void(this.showingCard=\"card\"===e);i.classList.add(\"bubble-scale-out\"),i.addEventListener(\"animationend\",()=>{n===this.transitionVersion&&(i.classList.remove(\"bubble-scale-out\"),i.classList.add(\"hidden\"),s.classList.remove(\"hidden\"),s.classList.add(\"bubble-scale-in\"),s.addEventListener(\"animationend\",()=>{n===this.transitionVersion&&(s.classList.remove(\"bubble-scale-in\"),this.animating=!1,this.showingCard=\"card\"===e)},{once:!0}))},{once:!0})}forceRestoreState(){if(this.animating=!1,this.showingCard=!1,this.cardElement&&(this.cardElement.classList.add(\"hidden\"),this.cardElement.classList.remove(\"bubble-scale-out\",\"bubble-scale-in\")),this.bubbleHidden)return;if(this.isBadgeMode())return;const e=this.container.querySelector(\".support-bubble\");e&&e.classList.remove(\"hidden\",\"bubble-scale-out\",\"bubble-scale-in\")}createCardElement(){const e=document.createElement(\"div\");e.className=\"support-onboarding-bubble-card hidden\",e.addEventListener(\"click\",()=>this.onCardClick());const t=document.createElement(\"div\");t.className=\"support-obc-content\",t.setAttribute(\"role\",\"button\"),t.tabIndex=0,t.setAttribute(\"aria-label\",Na().aria.openChat),t.addEventListener(\"keydown\",e=>{\"Enter\"!==e.key&&\" \"!==e.key||(e.preventDefault(),this.onCardClick())}),e.appendChild(t),this.contentElement=t;const n=document.createElement(\"button\");return n.type=\"button\",n.className=\"support-obc-close\",n.setAttribute(\"aria-label\",Na().aria.minimizeChat),n.innerHTML='\\n      <svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\\n        <path d=\"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\"/>\\n      </svg>\\n    ',n.addEventListener(\"click\",e=>{e.stopPropagation(),this.onCardDismiss()}),e.appendChild(n),e}progressPreview(){const e=Na(),t=this.checklistData;if(t?.items?.length){if(t.full_value)return function(e){const{done:t,total:n,secondaries:i}=e,s=i.filter(e=>!e.is_done),r=s.find(t=>t.feature_id===e.next_feature_id)??s[0];if(!r||n<=0)return null;const o=Na();return{title:o.progress.fullValueTitle,meta:o.progress.count(t,n),nextLabel:o.progress.nextStep,nextName:r.name,percent:Math.max(0,Math.min(100,t/n*100))}}(t.full_value);const{done:n,total:i,next_step:s}=t;if(!s||i<=0||n>=i)return null;const r=[...new Set(t.items.map(e=>e.stage))],o=r.includes(s.stage)?s.stage:r.includes(t.current_stage)?t.current_stage:r[0],a=t.items.filter(e=>e.stage===o),l=a.filter(e=>e.is_done).length,c=r.indexOf(o);return{title:e.progress.title,meta:e.progress.count(l,a.length),stageBadge:e.progress.stageOrdinal(c+1,r.length),stageName:e.progress.stages[o]??o,nextLabel:e.progress.nextStep,nextName:s.name,percent:Math.max(0,Math.min(100,l/a.length*100))}}const n=this.onboardingData;if(!n?.steps.length)return null;const i=new Set(n.completed_step_uuids??[]),s=n.steps.find(e=>!i.has(e.uuid));if(!s)return null;const r=n.steps.filter(e=>i.has(e.uuid)).length;return{title:n.name||e.onboarding.title,meta:e.onboarding.progressMeta(r,n.steps.length),nextLabel:e.onboarding.nextStep,nextName:s.title,percent:r/n.steps.length*100}}updateCardContent(e){if(!this.contentElement)return;const t=document.createElement(\"div\");t.className=\"support-obc-title\",t.textContent=e.title;const n=document.createElement(\"div\");if(n.className=\"support-obc-heading\",n.appendChild(t),e.stageBadge){const t=document.createElement(\"span\");t.className=\"support-obc-stage-badge\",t.textContent=e.stageBadge,n.appendChild(t)}const i=document.createElement(\"div\");if(i.className=\"support-obc-meta\",e.stageName){const t=document.createElement(\"span\");t.className=\"support-obc-stage-name\",t.textContent=e.stageName,i.appendChild(t);const n=document.createElement(\"span\");n.className=\"support-obc-stage-count\",n.textContent=e.meta,i.appendChild(n)}else i.textContent=e.meta;const s=document.createElement(\"div\");s.className=\"support-obc-bar\";const r=document.createElement(\"div\");r.className=\"support-obc-fill\",r.style.width=`${e.percent}%`,s.appendChild(r);const o=document.createElement(\"div\");o.className=\"support-obc-next\";const a=document.createElement(\"span\");a.textContent=e.nextLabel;const l=document.createElement(\"strong\");l.textContent=e.nextName,o.append(a,l),this.contentElement.replaceChildren(n,i,s,o)}}var nA={};!function e(t,n,i,s){var r=!!(t.Worker&&t.Blob&&t.Promise&&t.OffscreenCanvas&&t.OffscreenCanvasRenderingContext2D&&t.HTMLCanvasElement&&t.HTMLCanvasElement.prototype.transferControlToOffscreen&&t.URL&&t.URL.createObjectURL),o=\"function\"==typeof Path2D&&\"function\"==typeof DOMMatrix,a=function(){if(!t.OffscreenCanvas)return!1;try{var e=new OffscreenCanvas(1,1),n=e.getContext(\"2d\");n.fillRect(0,0,1,1);var i=e.transferToImageBitmap();n.createPattern(i,\"no-repeat\")}catch(e){return!1}return!0}();function l(){}function c(e){var i=n.exports.Promise,s=void 0!==i?i:t.Promise;return\"function\"==typeof s?new s(e):(e(l,l),null)}var d,u,p,h,g,m,f,b,y,v,w,x=(d=a,u=new Map,{transform:function(e){if(d)return e;if(u.has(e))return u.get(e);var t=new OffscreenCanvas(e.width,e.height);return t.getContext(\"2d\").drawImage(e,0,0),u.set(e,t),t},clear:function(){u.clear()}}),k=(g=Math.floor(1e3/60),m={},f=0,\"function\"==typeof requestAnimationFrame&&\"function\"==typeof cancelAnimationFrame?(p=function(e){var t=Math.random();return m[t]=requestAnimationFrame(function n(i){f===i||f+g-1<i?(f=i,delete m[t],e()):m[t]=requestAnimationFrame(n)}),t},h=function(e){m[e]&&cancelAnimationFrame(m[e])}):(p=function(e){return setTimeout(e,g)},h=function(e){return clearTimeout(e)}),{frame:p,cancel:h}),S=(v={},function(){if(b)return b;if(!i&&r){var t=[\"var CONFETTI, SIZE = {}, module = {};\",\"(\"+e.toString()+\")(this, module, true, SIZE);\",\"onmessage = function(msg) {\",\"  if (msg.data.options) {\",\"    CONFETTI(msg.data.options).then(function () {\",\"      if (msg.data.callback) {\",\"        postMessage({ callback: msg.data.callback });\",\"      }\",\"    });\",\"  } else if (msg.data.reset) {\",\"    CONFETTI && CONFETTI.reset();\",\"  } else if (msg.data.resize) {\",\"    SIZE.width = msg.data.resize.width;\",\"    SIZE.height = msg.data.resize.height;\",\"  } else if (msg.data.canvas) {\",\"    SIZE.width = msg.data.canvas.width;\",\"    SIZE.height = msg.data.canvas.height;\",\"    CONFETTI = module.exports.create(msg.data.canvas);\",\"  }\",\"}\"].join(\"\\n\");try{b=new Worker(URL.createObjectURL(new Blob([t])))}catch(e){return\"undefined\"!=typeof console&&\"function\"==typeof console.warn&&console.warn(\"🎊 Could not load worker\",e),null}!function(e){function t(t,n){e.postMessage({options:t||{},callback:n})}e.init=function(t){var n=t.transferControlToOffscreen();e.postMessage({canvas:n},[n])},e.fire=function(n,i,s){if(y)return t(n,null),y;var r=Math.random().toString(36).slice(2);return y=c(function(i){function o(t){t.data.callback===r&&(delete v[r],e.removeEventListener(\"message\",o),y=null,x.clear(),s(),i())}e.addEventListener(\"message\",o),t(n,r),v[r]=o.bind(null,{data:{callback:r}})})},e.reset=function(){for(var t in e.postMessage({reset:!0}),v)v[t](),delete v[t]}}(b)}return b}),C={particleCount:50,angle:90,spread:45,startVelocity:45,decay:.9,gravity:1,drift:0,ticks:200,x:.5,y:.5,shapes:[\"square\",\"circle\"],zIndex:100,colors:[\"#26ccff\",\"#a25afd\",\"#ff5e7e\",\"#88ff5a\",\"#fcff42\",\"#ffa62d\",\"#ff36ff\"],disableForReducedMotion:!1,scalar:1};function E(e,t,n){return function(e,t){return t?t(e):e}(e&&null!=e[t]?e[t]:C[t],n)}function M(e){return e<0?0:Math.floor(e)}function A(e,t){return Math.floor(Math.random()*(t-e))+e}function _(e){return parseInt(e,16)}function T(e){return e.map(I)}function I(e){var t=String(e).replace(/[^0-9a-f]/gi,\"\");return t.length<6&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),{r:_(t.substring(0,2)),g:_(t.substring(2,4)),b:_(t.substring(4,6))}}function L(e){e.width=document.documentElement.clientWidth,e.height=document.documentElement.clientHeight}function R(e){var t=e.getBoundingClientRect();e.width=t.width,e.height=t.height}function $(e){var t=e.angle*(Math.PI/180),n=e.spread*(Math.PI/180);return{x:e.x,y:e.y,wobble:10*Math.random(),wobbleSpeed:Math.min(.11,.1*Math.random()+.05),velocity:.5*e.startVelocity+Math.random()*e.startVelocity,angle2D:-t+(.5*n-Math.random()*n),tiltAngle:(.5*Math.random()+.25)*Math.PI,color:e.color,shape:e.shape,tick:0,totalTicks:e.ticks,decay:e.decay,drift:e.drift,random:Math.random()+2,tiltSin:0,tiltCos:0,wobbleX:0,wobbleY:0,gravity:3*e.gravity,ovalScalar:.6,scalar:e.scalar,flat:e.flat}}function N(e,t){t.x+=Math.cos(t.angle2D)*t.velocity+t.drift,t.y+=Math.sin(t.angle2D)*t.velocity+t.gravity,t.velocity*=t.decay,t.flat?(t.wobble=0,t.wobbleX=t.x+10*t.scalar,t.wobbleY=t.y+10*t.scalar,t.tiltSin=0,t.tiltCos=0,t.random=1):(t.wobble+=t.wobbleSpeed,t.wobbleX=t.x+10*t.scalar*Math.cos(t.wobble),t.wobbleY=t.y+10*t.scalar*Math.sin(t.wobble),t.tiltAngle+=.1,t.tiltSin=Math.sin(t.tiltAngle),t.tiltCos=Math.cos(t.tiltAngle),t.random=Math.random()+2);var n=t.tick++/t.totalTicks,i=t.x+t.random*t.tiltCos,s=t.y+t.random*t.tiltSin,r=t.wobbleX+t.random*t.tiltCos,a=t.wobbleY+t.random*t.tiltSin;if(e.fillStyle=\"rgba(\"+t.color.r+\", \"+t.color.g+\", \"+t.color.b+\", \"+(1-n)+\")\",e.beginPath(),o&&\"path\"===t.shape.type&&\"string\"==typeof t.shape.path&&Array.isArray(t.shape.matrix))e.fill(function(e,t,n,i,s,r,o){var a=new Path2D(e),l=new Path2D;l.addPath(a,new DOMMatrix(t));var c=new Path2D;return c.addPath(l,new DOMMatrix([Math.cos(o)*s,Math.sin(o)*s,-Math.sin(o)*r,Math.cos(o)*r,n,i])),c}(t.shape.path,t.shape.matrix,t.x,t.y,.1*Math.abs(r-i),.1*Math.abs(a-s),Math.PI/10*t.wobble));else if(\"bitmap\"===t.shape.type){var l=Math.PI/10*t.wobble,c=.1*Math.abs(r-i),d=.1*Math.abs(a-s),u=t.shape.bitmap.width*t.scalar,p=t.shape.bitmap.height*t.scalar,h=new DOMMatrix([Math.cos(l)*c,Math.sin(l)*c,-Math.sin(l)*d,Math.cos(l)*d,t.x,t.y]);h.multiplySelf(new DOMMatrix(t.shape.matrix));var g=e.createPattern(x.transform(t.shape.bitmap),\"no-repeat\");g.setTransform(h),e.globalAlpha=1-n,e.fillStyle=g,e.fillRect(t.x-u/2,t.y-p/2,u,p),e.globalAlpha=1}else if(\"circle\"===t.shape)e.ellipse?e.ellipse(t.x,t.y,Math.abs(r-i)*t.ovalScalar,Math.abs(a-s)*t.ovalScalar,Math.PI/10*t.wobble,0,2*Math.PI):function(e,t,n,i,s,r,o,a,l){e.save(),e.translate(t,n),e.rotate(r),e.scale(i,s),e.arc(0,0,1,o,a,l),e.restore()}(e,t.x,t.y,Math.abs(r-i)*t.ovalScalar,Math.abs(a-s)*t.ovalScalar,Math.PI/10*t.wobble,0,2*Math.PI);else if(\"star\"===t.shape)for(var m=Math.PI/2*3,f=4*t.scalar,b=8*t.scalar,y=t.x,v=t.y,w=5,k=Math.PI/w;w--;)y=t.x+Math.cos(m)*b,v=t.y+Math.sin(m)*b,e.lineTo(y,v),m+=k,y=t.x+Math.cos(m)*f,v=t.y+Math.sin(m)*f,e.lineTo(y,v),m+=k;else e.moveTo(Math.floor(t.x),Math.floor(t.y)),e.lineTo(Math.floor(t.wobbleX),Math.floor(s)),e.lineTo(Math.floor(r),Math.floor(a)),e.lineTo(Math.floor(i),Math.floor(t.wobbleY));return e.closePath(),e.fill(),t.tick<t.totalTicks}function P(e,n){var o,a=!e,l=!!E(n||{},\"resize\"),d=!1,u=E(n,\"disableForReducedMotion\",Boolean),p=r&&!!E(n||{},\"useWorker\")?S():null,h=a?L:R,g=!(!e||!p)&&!!e.__confetti_initialized,m=\"function\"==typeof matchMedia&&matchMedia(\"(prefers-reduced-motion)\").matches;function f(t,n,r){for(var a=E(t,\"particleCount\",M),l=E(t,\"angle\",Number),d=E(t,\"spread\",Number),u=E(t,\"startVelocity\",Number),p=E(t,\"decay\",Number),g=E(t,\"gravity\",Number),m=E(t,\"drift\",Number),f=E(t,\"colors\",T),b=E(t,\"ticks\",Number),y=E(t,\"shapes\"),v=E(t,\"scalar\"),w=!!E(t,\"flat\"),S=function(e){var t=E(e,\"origin\",Object);return t.x=E(t,\"x\",Number),t.y=E(t,\"y\",Number),t}(t),C=a,_=[],I=e.width*S.x,L=e.height*S.y;C--;)_.push($({x:I,y:L,angle:l,spread:d,startVelocity:u,color:f[C%f.length],shape:y[A(0,y.length)],ticks:b,decay:p,gravity:g,drift:m,scalar:v,flat:w}));return o?o.addFettis(_):(o=function(e,t,n,r,o){var a,l,d=t.slice(),u=e.getContext(\"2d\"),p=c(function(t){function c(){a=l=null,u.clearRect(0,0,r.width,r.height),x.clear(),o(),t()}a=k.frame(function t(){!i||r.width===s.width&&r.height===s.height||(r.width=e.width=s.width,r.height=e.height=s.height),r.width||r.height||(n(e),r.width=e.width,r.height=e.height),u.clearRect(0,0,r.width,r.height),(d=d.filter(function(e){return N(u,e)})).length?a=k.frame(t):c()}),l=c});return{addFettis:function(e){return d=d.concat(e),p},canvas:e,promise:p,reset:function(){a&&k.cancel(a),l&&l()}}}(e,_,h,n,r),o.promise)}function b(n){var i=u||E(n,\"disableForReducedMotion\",Boolean),s=E(n,\"zIndex\",Number);if(i&&m)return c(function(e){e()});a&&o?e=o.canvas:a&&!e&&(e=function(e){var t=document.createElement(\"canvas\");return t.style.position=\"fixed\",t.style.top=\"0px\",t.style.left=\"0px\",t.style.pointerEvents=\"none\",t.style.zIndex=e,t}(s),document.body.appendChild(e)),l&&!g&&h(e);var r={width:e.width,height:e.height};function b(){if(p){var t={getBoundingClientRect:function(){if(!a)return e.getBoundingClientRect()}};return h(t),void p.postMessage({resize:{width:t.width,height:t.height}})}r.width=r.height=null}function y(){o=null,l&&(d=!1,t.removeEventListener(\"resize\",b)),a&&e&&(document.body.contains(e)&&document.body.removeChild(e),e=null,g=!1)}return p&&!g&&p.init(e),g=!0,p&&(e.__confetti_initialized=!0),l&&!d&&(d=!0,t.addEventListener(\"resize\",b,!1)),p?p.fire(n,r,y):f(n,r,y)}return b.reset=function(){p&&p.reset(),o&&o.reset()},b}function F(){return w||(w=P(null,{useWorker:!0,resize:!0})),w}n.exports=function(){return F().apply(this,arguments)},n.exports.reset=function(){F().reset()},n.exports.create=P,n.exports.shapeFromPath=function(e){if(!o)throw new Error(\"path confetti are not supported in this browser\");var t,n;\"string\"==typeof e?t=e:(t=e.path,n=e.matrix);var i=new Path2D(t),s=document.createElement(\"canvas\").getContext(\"2d\");if(!n){for(var r,a,l=1e3,c=l,d=l,u=0,p=0,h=0;h<l;h+=2)for(var g=0;g<l;g+=2)s.isPointInPath(i,h,g,\"nonzero\")&&(c=Math.min(c,h),d=Math.min(d,g),u=Math.max(u,h),p=Math.max(p,g));r=u-c,a=p-d;var m=Math.min(10/r,10/a);n=[m,0,0,m,-Math.round(r/2+c)*m,-Math.round(a/2+d)*m]}return{type:\"path\",path:t,matrix:n}},n.exports.shapeFromText=function(e){var t,n=1,i=\"#000000\",s='\"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\", \"EmojiOne Color\", \"Android Emoji\", \"Twemoji Mozilla\", \"system emoji\", sans-serif';\"string\"==typeof e?t=e:(t=e.text,n=\"scalar\"in e?e.scalar:n,s=\"fontFamily\"in e?e.fontFamily:s,i=\"color\"in e?e.color:i);var r=10*n,o=r+\"px \"+s,a=new OffscreenCanvas(r,r),l=a.getContext(\"2d\");l.font=o;var c=l.measureText(t),d=Math.ceil(c.actualBoundingBoxRight+c.actualBoundingBoxLeft),u=Math.ceil(c.actualBoundingBoxAscent+c.actualBoundingBoxDescent),p=c.actualBoundingBoxLeft+2,h=c.actualBoundingBoxAscent+2;d+=4,u+=4,(l=(a=new OffscreenCanvas(d,u)).getContext(\"2d\")).font=o,l.fillStyle=i,l.fillText(t,p,h);var g=1/n;return{type:\"bitmap\",bitmap:a.transferToImageBitmap(),matrix:[g,0,0,g,-d*g/2,-u*g/2]}}}(function(){return\"undefined\"!=typeof window?window:\"undefined\"!=typeof self?self:this||{}}(),nA,!1);var iA=nA.exports;function sA(e){const t=e.querySelector(\".support-chat-window\");if(!t)return;const n=document.createElement(\"canvas\");n.style.cssText=\"position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:10;\",t.appendChild(n);const i=iA.create(n,{resize:!0});i({particleCount:100,spread:70,origin:{y:.6},colors:[\"#4593F8\",\"#FF6B6B\",\"#FFD93D\",\"#6BCB77\",\"#9B59B6\",\"#FF8C42\",\"#00D2FF\"]}),setTimeout(()=>{i({particleCount:50,angle:60,spread:55,origin:{x:0,y:.6},colors:[\"#4593F8\",\"#FFD93D\",\"#6BCB77\"]}),i({particleCount:50,angle:120,spread:55,origin:{x:1,y:.6},colors:[\"#FF6B6B\",\"#9B59B6\",\"#00D2FF\"]})},300),setTimeout(()=>os(n),4e3)}nA.exports.create;class rA{constructor(e,t){this.panelElement=null,this.container=e,this.apiClient=t,this.translations=Na()}async show(e){return this.showPlan(()=>this.apiClient.getStepPlan(e))}async showReleasePlan(e){return this.showPlan(()=>this.apiClient.getReleasePlan(e))}async showPlan(e){this.hide();const t=this.container.querySelector(\".support-chat-window\");if(!t)return;const n=document.createElement(\"div\");n.className=\"support-onboarding-plan-panel\";const i=document.createElement(\"div\");i.className=\"support-onboarding-plan-header\";const s=document.createElement(\"button\");s.className=\"support-onboarding-plan-back\",s.innerHTML='<svg viewBox=\"0 0 24 24\"><polyline points=\"15 18 9 12 15 6\"/></svg>',s.addEventListener(\"click\",()=>this.hide());const r=document.createElement(\"div\");r.className=\"support-onboarding-plan-title\",r.textContent=this.translations.onboarding.planTitle,i.appendChild(s),i.appendChild(r),n.appendChild(i);const o=document.createElement(\"div\");o.className=\"support-onboarding-plan-loading-bar\",n.appendChild(o);const a=document.createElement(\"div\");a.className=\"support-onboarding-plan-body\",n.appendChild(a),this.panelElement=n,t.appendChild(n);let l=null;try{l=await e()}catch{l=null}this.panelElement&&(os(o),this.renderPlanContent(a,l))}hide(){if(!this.panelElement)return;const e=this.panelElement;this.panelElement=null,e.classList.add(\"support-onboarding-plan-panel-exit\"),e.addEventListener(\"animationend\",()=>{os(e)},{once:!0})}isVisible(){return null!==this.panelElement}renderPlanContent(e,t){if(!t||0===t.steps.length){const t=document.createElement(\"div\");return t.className=\"support-onboarding-plan-empty\",t.textContent=this.translations.onboarding.planEmpty,void e.appendChild(t)}const n=[...t.steps].sort((e,t)=>e.step_number-t.step_number);n.forEach((t,i)=>{e.appendChild(this.renderPlanStepCard(t)),i<n.length-1&&e.appendChild(this.renderPlanArrowSeparator())})}renderPlanStepCard(e){const t=document.createElement(\"div\");t.className=\"support-onboarding-plan-step-card\";const n=document.createElement(\"div\");n.className=\"support-onboarding-plan-step-header\";const i=document.createElement(\"span\");i.className=\"support-onboarding-plan-step-label\",i.textContent=this.translations.onboarding.planStepLabel(e.step_number);const s=document.createElement(\"span\");s.className=\"support-onboarding-plan-step-action\",s.textContent=e.action,n.appendChild(i),n.appendChild(s),t.appendChild(n);const r=document.createElement(\"p\");r.className=\"support-onboarding-plan-step-desc\",r.textContent=e.description,t.appendChild(r);const o=document.createElement(\"div\");o.className=\"support-onboarding-plan-step-connector\",t.appendChild(o);const a=document.createElement(\"div\");a.className=\"support-onboarding-plan-step-outcome\";const l=document.createElement(\"div\");l.className=\"support-onboarding-plan-step-outcome-label\",l.textContent=this.translations.onboarding.planExpectedOutcome;const c=document.createElement(\"div\");return c.className=\"support-onboarding-plan-step-outcome-text\",c.textContent=e.expected_outcome,a.appendChild(l),a.appendChild(c),t.appendChild(a),t}renderPlanArrowSeparator(){const e=document.createElement(\"div\");return e.className=\"support-onboarding-plan-arrow-sep\",e.innerHTML='<svg viewBox=\"0 0 24 24\"><polyline points=\"6 9 12 15 18 9\"/></svg>',e}}class oA{constructor(e,t){this.banner=null,this.commentInput=null,this.campaignId=null,this.capturedScore=null,this.capturedCategory=null,this.isPostingScore=!1,this.isPatchingComment=!1,this.dismissFired=!1,this.onClosed=null,this.dismissTimeout=null,this.escListener=null,this.container=e,this.apiClient=t}isVisible(){return null!==this.banner}show(e,t){this.isVisible()||(this.campaignId=e,this.capturedScore=null,this.capturedCategory=null,this.isPostingScore=!1,this.isPatchingComment=!1,this.dismissFired=!1,this.onClosed=t??null,this.banner=document.createElement(\"div\"),this.banner.className=\"support-nps-banner\",this.banner.setAttribute(\"role\",\"dialog\"),this.banner.setAttribute(\"aria-label\",Na().nps.title),this.renderStep1(),this.container.appendChild(this.banner),this.escListener=e=>{\"Escape\"===e.key&&this.isVisible()&&this.handleClose()},document.addEventListener(\"keydown\",this.escListener))}hide(){this.dismissTimeout&&(clearTimeout(this.dismissTimeout),this.dismissTimeout=null),this.escListener&&(document.removeEventListener(\"keydown\",this.escListener),this.escListener=null),this.banner&&(os(this.banner),this.banner=null),this.commentInput=null;const e=this.onClosed;this.onClosed=null,this.campaignId=null,this.capturedScore=null,this.capturedCategory=null,this.isPostingScore=!1,this.isPatchingComment=!1,this.dismissFired=!1,e?.()}handleClose(){null!==this.capturedScore||null===this.campaignId||this.dismissFired||(this.dismissFired=!0,this.apiClient.dismissNPS({campaign_id:this.campaignId}).catch(()=>{})),this.hide()}renderStep1(){if(!this.banner)return;const e=Na().nps;this.banner.classList.remove(\"step-2\",\"step-thanks\"),this.banner.classList.add(\"step-1\"),this.banner.innerHTML=\"\",this.commentInput=null;const t=document.createElement(\"div\");t.className=\"support-nps-header\";const n=document.createElement(\"div\");n.className=\"support-nps-title-wrap\";const i=document.createElement(\"h4\");i.className=\"support-nps-title\",i.textContent=e.title;const s=document.createElement(\"p\");s.className=\"support-nps-subtitle\",s.textContent=e.subtitle,n.appendChild(i),n.appendChild(s);const r=document.createElement(\"button\");r.type=\"button\",r.className=\"support-nps-close\",r.setAttribute(\"aria-label\",e.skip),r.textContent=\"×\",r.addEventListener(\"click\",()=>this.handleClose()),t.appendChild(n),t.appendChild(r);const o=document.createElement(\"div\");o.className=\"support-nps-score-row\";for(let e=0;e<=10;e++){const t=document.createElement(\"button\");t.type=\"button\",t.className=\"support-nps-score\",t.textContent=String(e),t.dataset.score=String(e),t.addEventListener(\"click\",()=>this.handleScoreTap(e)),o.appendChild(t)}const a=document.createElement(\"div\");a.className=\"support-nps-anchors\";const l=document.createElement(\"span\");l.textContent=e.lowLabel;const c=document.createElement(\"span\");c.textContent=e.highLabel,a.appendChild(l),a.appendChild(c),this.banner.appendChild(t),this.banner.appendChild(o),this.banner.appendChild(a)}renderStep2(){if(!this.banner||null===this.capturedScore||null===this.capturedCategory)return;const e=Na().nps,t=this.capturedCategory,n=this.capturedScore;this.banner.classList.remove(\"step-1\",\"step-thanks\"),this.banner.classList.add(\"step-2\"),this.banner.innerHTML=\"\";const i=document.createElement(\"div\");i.className=\"support-nps-step-label\";const s=document.createElement(\"span\");s.className=\"support-nps-step-dot\";const r=document.createElement(\"span\");r.textContent=e.stepLabel,i.appendChild(s),i.appendChild(r);const o=document.createElement(\"button\");o.type=\"button\",o.className=\"support-nps-close support-nps-close-step2\",o.setAttribute(\"aria-label\",e.skip),o.textContent=\"×\",o.addEventListener(\"click\",()=>this.handleClose());const a=document.createElement(\"div\");a.className=\"support-nps-step2-top\",a.appendChild(i),a.appendChild(o);const l=document.createElement(\"h4\");l.className=\"support-nps-step2-title\",l.textContent=this.step2TitleFor(t,e);const c=document.createElement(\"p\");c.className=\"support-nps-step2-subline\";const[d,u]=e.step2Subline.split(\"{score}\");c.appendChild(document.createTextNode(d));const p=document.createElement(\"span\");p.className=\"support-nps-score-mark\",p.textContent=String(n),c.appendChild(p),c.appendChild(document.createTextNode(u??\"\"));const h=document.createElement(\"textarea\");h.className=\"support-nps-comment\",h.placeholder=e.commentPlaceholder,h.rows=3,this.commentInput=h;const g=document.createElement(\"p\");g.className=\"support-nps-reply-hint\",g.textContent=e.replyHint;const m=document.createElement(\"div\");m.className=\"support-nps-actions\";const f=document.createElement(\"button\");f.type=\"button\",f.className=\"support-nps-submit\",f.textContent=e.submit,f.addEventListener(\"click\",()=>this.handleSendComment()),m.appendChild(f),this.banner.appendChild(a),this.banner.appendChild(l),this.banner.appendChild(c),this.banner.appendChild(h),this.banner.appendChild(g),this.banner.appendChild(m),setTimeout(()=>h.focus(),0)}step2TitleFor(e,t){return\"promoter\"===e?t.step2TitlePromoter:\"detractor\"===e?t.step2TitleDetractor:t.step2TitlePassive}async handleScoreTap(e){if(!this.banner||null===this.campaignId||this.isPostingScore)return;this.isPostingScore=!0;const t=this.banner.querySelectorAll(\".support-nps-score\");let n;t.forEach(t=>{t.disabled=!0,t.dataset.score===String(e)&&t.classList.add(\"selected\")});try{n=await this.apiClient.submitNPS({campaign_id:this.campaignId,score:e,comment:\"\"})}catch(e){return e instanceof Pi&&e.status>=400&&e.status<500?void this.hide():(this.isPostingScore=!1,void t.forEach(e=>{e.disabled=!1,e.classList.remove(\"selected\")}))}this.capturedScore=n.score,this.capturedCategory=n.category,this.isPostingScore=!1,this.renderStep2()}async handleSendComment(){if(!this.banner||null===this.campaignId||this.isPatchingComment)return;const e=(this.commentInput?.value??\"\").trim();if(\"\"===e)return this.renderThanks(),void(this.dismissTimeout=setTimeout(()=>this.hide(),2500));this.isPatchingComment=!0;const t=this.banner.querySelector(\".support-nps-submit\");t&&(t.disabled=!0);try{await this.apiClient.commentNPS({campaign_id:this.campaignId,comment:e})}catch{}this.isPatchingComment=!1,this.renderThanks(),this.dismissTimeout=setTimeout(()=>this.hide(),2500)}renderThanks(){if(!this.banner)return;const e=Na().nps,t=this.capturedCategory;let n=e.thanksDefault;\"promoter\"===t?n=e.thanksPromoter:\"detractor\"===t&&(n=e.thanksDetractor),this.banner.classList.remove(\"step-1\",\"step-2\"),this.banner.classList.add(\"step-thanks\"),this.banner.innerHTML=\"\",this.commentInput=null;const i=document.createElement(\"div\");i.className=\"support-nps-thanks\";const s=document.createElement(\"div\");s.className=\"support-nps-check\",s.innerHTML='<svg viewBox=\"0 0 24 24\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path fill=\"none\" stroke=\"currentColor\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M5 12.5l4.5 4.5L19 7\"/></svg>';const r=document.createElement(\"div\");r.className=\"support-nps-thanks-text\",r.textContent=n,i.appendChild(s),i.appendChild(r),this.banner.appendChild(i)}}const aA=\"blar-campaign-banner\",lA={notice:\"#FDE68A\",warning:\"#FDBA74\",critical:\"#FCA5A5\"},cA=/^#[0-9a-f]{3,8}$/i;function dA(e){const t=document.getElementById(aA);if(!e||!e.title&&!e.body)return void os(t);const n=t??document.createElement(\"div\"),i=n.shadowRoot??n.attachShadow({mode:\"open\"});i.replaceChildren();const s=document.createElement(\"style\");s.textContent='\\n  :host {\\n    display: block;\\n    position: relative;\\n    z-index: 999998;\\n    font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif;\\n    font-size: 14px;\\n    line-height: 1.4;\\n  }\\n  .bar {\\n    display: flex;\\n    align-items: center;\\n    flex-wrap: wrap;\\n    gap: 4px 16px;\\n    padding: 8px 16px;\\n    box-sizing: border-box;\\n  }\\n  .title { font-weight: 700; }\\n  .body { flex: 1 1 auto; min-width: 0; }\\n  .cta {\\n    margin-left: auto;\\n    padding: 4px 12px;\\n    border-radius: 6px;\\n    font-weight: 600;\\n    text-decoration: none;\\n    white-space: nowrap;\\n    color: #1F1F1F;\\n    background: #FFFDF5;\\n  }\\n  .cta:hover { background: #FFFFFF; }\\n  .cta:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }\\n';const r=document.createElement(\"div\");r.className=\"bar\",r.setAttribute(\"role\",\"status\");const o=e.color??\"\",a=e.text_color??\"\";if(r.style.background=cA.test(o)?o:lA[e.urgency]??lA.critical,r.style.color=cA.test(a)?a:\"#111827\",e.title){const t=document.createElement(\"span\");t.className=\"title\",t.textContent=e.title,r.appendChild(t)}if(e.body){const t=document.createElement(\"span\");t.className=\"body\",t.textContent=e.body,r.appendChild(t)}if(e.cta_label&&function(e){try{const{protocol:t}=new URL(e);return\"https:\"===t||\"http:\"===t}catch{return!1}}(e.cta_url)){const t=document.createElement(\"a\");t.className=\"cta\",t.href=e.cta_url,t.target=\"_blank\",t.rel=\"noopener noreferrer\",t.textContent=e.cta_label,r.appendChild(t)}i.append(s,r),n.setAttribute(\"data-campaign-uuid\",e.campaign_uuid),t||(n.id=aA,document.body.prepend(n))}class uA{constructor(e,t,n){this.questions=[],this.isRequired=!1,this.overlay=null,this.isSubmitting=!1,this.backdropPressed=!1,this.escListener=null,this.container=e,this.apiClient=t,this.callbacks=n,this.translations=Na()}isVisible(){return null!==this.overlay}update(e,t){const n=[...e].sort((e,t)=>e.position-t.position);this.isVisible()&&this.isRequired===t&&JSON.stringify(this.questions)===JSON.stringify(n)||(this.hide(),this.show(n,t))}show(e,t=!1){if(this.isVisible())return;if(0===e.length)return;this.questions=[...e].sort((e,t)=>e.position-t.position),this.isRequired=t,this.isSubmitting=!1,this.translations=Na();const n=this.translations.activationForm,i=this.isRequired?\"\":`<button type=\"button\" class=\"support-activation-form-close\" aria-label=\"${this.escapeHtml(n.skip)}\">×</button>`;this.overlay=document.createElement(\"div\"),this.overlay.className=\"support-activation-form-overlay\",this.overlay.setAttribute(\"role\",\"dialog\"),this.overlay.setAttribute(\"aria-label\",n.title),this.overlay.innerHTML=`\\n      <div class=\"support-activation-form-card\">\\n        <div class=\"support-activation-form-header\">\\n          <div class=\"support-activation-form-title-wrap\">\\n            <h4 class=\"support-activation-form-title\">${this.escapeHtml(n.title)}</h4>\\n            <p class=\"support-activation-form-subtitle\">${this.escapeHtml(n.subtitle)}</p>\\n          </div>\\n          ${i}\\n        </div>\\n        <div class=\"support-activation-form-questions\">\\n          ${this.questions.map(e=>this.renderQuestion(e)).join(\"\")}\\n        </div>\\n        <div class=\"support-activation-form-actions\">\\n          <button type=\"button\" class=\"support-activation-form-submit\">${this.escapeHtml(n.submit)}</button>\\n        </div>\\n      </div>\\n    `,this.container.appendChild(this.overlay),this.attachEventListeners(),this.isRequired||(this.escListener=e=>{\"Escape\"===e.key&&this.isVisible()&&this.handleSkip()},document.addEventListener(\"keydown\",this.escListener))}hide(){this.escListener&&(document.removeEventListener(\"keydown\",this.escListener),this.escListener=null),this.overlay&&(os(this.overlay),this.overlay=null),this.isSubmitting=!1}destroy(){this.hide()}renderQuestion(e){const t=e.required?'<span class=\"support-activation-form-required\">*</span>':\"\";return`\\n      <div class=\"support-activation-form-question\" data-event-type-id=\"${e.event_type_id}\" data-input-type=\"${this.escapeHtml(e.input_type)}\">\\n        <div class=\"support-activation-form-prompt\">${this.escapeHtml(e.prompt)}${t}</div>\\n        ${this.renderInput(e)}\\n        <div class=\"support-activation-form-error\"></div>\\n      </div>\\n    `}renderInput(e){if(\"text_input\"===e.input_type)return`\\n        <input\\n          type=\"text\"\\n          class=\"support-text-input\"\\n          data-activation-text\\n          placeholder=\"${this.escapeHtml(this.translations.activationForm.textPlaceholder)}\"\\n        />\\n      `;if(\"radio\"===e.input_type){const t=`activation-radio-${e.event_type_id}`,n=e.options.map((e,n)=>{const i=`${t}-${n}`;return`\\n            <div class=\"support-radio-option\">\\n              <input type=\"radio\" id=\"${i}\" name=\"${t}\" value=\"${this.escapeHtml(e.value)}\" data-activation-radio />\\n              <label for=\"${i}\">${this.escapeHtml(e.label)}</label>\\n            </div>\\n          `}).join(\"\");return`<div class=\"support-radio-group\">${n}</div>`}const t=`activation-checkbox-${e.event_type_id}`,n=e.options.map((e,n)=>{const i=`${t}-${n}`;return`\\n          <div class=\"support-checkbox-option\">\\n            <input type=\"checkbox\" id=\"${i}\" value=\"${this.escapeHtml(e.value)}\" data-activation-checkbox />\\n            <label for=\"${i}\">${this.escapeHtml(e.label)}</label>\\n          </div>\\n        `}).join(\"\");return`<div class=\"support-checkbox-group\">${n}</div>`}attachEventListeners(){if(!this.overlay)return;const e=this.overlay.querySelector(\".support-activation-form-submit\");if(e?.addEventListener(\"click\",()=>this.handleSubmit()),!this.isRequired){const e=this.overlay.querySelector(\".support-activation-form-close\");e?.addEventListener(\"click\",()=>this.handleSkip()),this.overlay.addEventListener(\"mousedown\",e=>{this.backdropPressed=e.target===this.overlay}),this.overlay.addEventListener(\"click\",e=>{e.target===this.overlay&&this.backdropPressed&&this.handleSkip(),this.backdropPressed=!1})}this.overlay.querySelectorAll(\"[data-activation-text], [data-activation-radio], [data-activation-checkbox]\").forEach(e=>{e.addEventListener(\"input\",()=>{const t=e.closest(\".support-activation-form-question\");t&&this.clearQuestionError(t)}),e.addEventListener(\"change\",()=>{const t=e.closest(\".support-activation-form-question\");t&&this.clearQuestionError(t)})})}async handleSubmit(){if(this.isSubmitting||!this.overlay)return;const e=this.overlay,t=this.collectAndValidate();if(!t.valid)return void this.showFieldErrors(t.errors);this.isSubmitting=!0;const n=this.overlay.querySelector(\".support-activation-form-submit\");n&&(n.disabled=!0,n.textContent=this.translations.activationForm.submitting);try{const n=await this.apiClient.submitActivationForm({answers:t.answers});if(this.overlay!==e)return;this.hide(),this.callbacks.onComplete(n)}catch{this.overlay===e&&this.showSubmitError()}finally{this.overlay===e&&(this.isSubmitting=!1),n&&this.overlay===e&&(n.disabled=!1,n.textContent=this.translations.activationForm.submit)}}async handleSkip(){if(this.isSubmitting||!this.overlay)return;const e=this.overlay;this.isSubmitting=!0;try{const t=await this.apiClient.skipActivationForm();if(this.overlay!==e)return;this.hide(),this.callbacks.onComplete(t)}catch{this.overlay===e&&this.showSubmitError()}finally{this.overlay===e&&(this.isSubmitting=!1)}}collectAndValidate(){const e=[],t=new Map,n=this.translations.activationForm;for(const i of this.questions){const s=this.overlay?.querySelector(`.support-activation-form-question[data-event-type-id=\"${i.event_type_id}\"]`);if(!s)continue;if(\"text_input\"===i.input_type){const r=s.querySelector(\"[data-activation-text]\"),o=(r?.value??\"\").trim();if(\"\"===o){i.required&&t.set(i.event_type_id,n.requiredError);continue}e.push({event_type_id:i.event_type_id,answer_text:o});continue}if(\"radio\"===i.input_type){const r=s.querySelector(\"[data-activation-radio]:checked\");if(!r){i.required&&t.set(i.event_type_id,n.selectOneError);continue}e.push({event_type_id:i.event_type_id,selected_values:[r.value]});continue}const r=Array.from(s.querySelectorAll(\"[data-activation-checkbox]:checked\"));0!==r.length?e.push({event_type_id:i.event_type_id,selected_values:[...new Set(r.map(e=>e.value))]}):i.required&&t.set(i.event_type_id,n.selectAtLeastOneError)}return{valid:0===t.size,answers:e,errors:t}}showFieldErrors(e){e.forEach((e,t)=>{const n=this.overlay?.querySelector(`.support-activation-form-question[data-event-type-id=\"${t}\"]`),i=n?.querySelector(\".support-activation-form-error\"),s=n?.querySelector(\"[data-activation-text]\");i&&(i.textContent=e),s&&s.classList.add(\"error\")})}clearQuestionError(e){const t=e.querySelector(\".support-activation-form-error\"),n=e.querySelector(\"[data-activation-text]\");t&&(t.textContent=\"\"),n&&n.classList.remove(\"error\")}showSubmitError(){if(!this.overlay)return;const e=this.overlay.querySelector(\".support-activation-form-card\");if(!e)return;let t=e.querySelector(\".support-activation-form-submit-error\");if(!t){t=document.createElement(\"div\"),t.className=\"support-activation-form-submit-error\";const n=e.querySelector(\".support-activation-form-actions\");n?.insertAdjacentElement(\"beforebegin\",t)}t.textContent=this.translations.activationForm.submitError}escapeHtml(e){return e.replace(/&/g,\"&amp;\").replace(/</g,\"&lt;\").replace(/>/g,\"&gt;\").replace(/\"/g,\"&quot;\").replace(/'/g,\"&#39;\")}}class pA{constructor(e,t,n){this.container=e,this.apiClient=t,this.callbacks=n,this.current=null,this.rendered=null,this.overlay=null,this.isSubmitting=!1}hasPending(){return null!==this.current}isVisible(){return null!==this.overlay}apply(e){this.current=e,this.callbacks.onChange()}show(){this.current?this.overlay&&JSON.stringify(this.rendered)===JSON.stringify(this.current)||(this.hide(),this.render(this.current)):this.hide()}hide(){this.overlay&&(os(this.overlay),this.overlay=null),this.rendered=null,this.isSubmitting=!1}reset(){this.hide(),this.current=null}destroy(){this.reset()}render(e){const t=Na().featureCheckIn,n=document.createElement(\"div\");n.className=\"support-activation-form-overlay support-feature-check-in\",n.setAttribute(\"role\",\"dialog\"),n.setAttribute(\"aria-label\",e.feature.name);const i=document.createElement(\"div\");i.className=\"support-activation-form-card\";const s=document.createElement(\"div\");s.className=\"support-activation-form-header\";const r=document.createElement(\"div\");r.className=\"support-activation-form-title-wrap\";const o=document.createElement(\"h4\");o.className=\"support-activation-form-title\",o.textContent=e.feature.name,r.appendChild(o),s.appendChild(r);const a=document.createElement(\"div\");a.className=\"support-activation-form-prompt\",a.textContent=e.prompt;const l=document.createElement(\"div\");l.className=\"support-activation-form-actions\",l.appendChild(this.buildAnswerButton(\"support-activation-form-decline\",t.no,!1)),l.appendChild(this.buildAnswerButton(\"support-activation-form-submit\",t.yes,!0)),i.appendChild(s),i.appendChild(a),i.appendChild(l),n.appendChild(i),this.container.appendChild(n),this.overlay=n,this.rendered=e,this.isSubmitting=!1}buildAnswerButton(e,t,n){const i=document.createElement(\"button\");return i.type=\"button\",i.className=e,i.dataset.checkInAnswer=n?\"yes\":\"no\",i.textContent=t,i.addEventListener(\"click\",()=>{this.answer(n,i)}),i}async answer(e,t){if(this.isSubmitting||!this.overlay||!this.current)return;const n=this.overlay,i=this.current,s=Na().featureCheckIn,r=t.textContent;this.isSubmitting=!0,this.setBusy(!0),t.textContent=s.submitting;try{const t=await this.apiClient.answerFeatureCheckIn(i.id,{enabled:e});this.callbacks.onAnswered(t),this.overlay===n&&this.hide()}catch(e){if(this.overlay!==n)return;if(function(e){return e instanceof Pi&&(409===e.status||404===e.status)}(e))return void await this.callbacks.onStale(i);this.showSubmitError()}finally{this.overlay===n&&(this.isSubmitting=!1,this.setBusy(!1),t.textContent=r)}}setBusy(e){this.overlay?.querySelectorAll(\"[data-check-in-answer]\").forEach(t=>{t.disabled=e})}showSubmitError(){const e=this.overlay?.querySelector(\".support-activation-form-card\");if(!e)return;let t=e.querySelector(\".support-activation-form-submit-error\");t||(t=document.createElement(\"div\"),t.className=\"support-activation-form-submit-error\",e.querySelector(\".support-activation-form-actions\")?.insertAdjacentElement(\"beforebegin\",t)),t.textContent=Na().featureCheckIn.submitError}}function hA(e,t){const n=document.createElement(\"div\");n.className=\"blar-intro-executive-avatar\";const i=()=>{n.classList.remove(\"blar-intro-executive-avatar--photo\"),n.textContent=as(e)};if(!t)return i(),n;const s=document.createElement(\"img\");return s.className=\"blar-intro-executive-img\",s.alt=e,s.decoding=\"async\",s.onerror=()=>{os(s),i()},n.classList.add(\"blar-intro-executive-avatar--photo\"),n.appendChild(s),s.src=t,n}function gA(e){const t=document.createElement(\"div\");t.className=\"blar-intro-executive\";const n=document.createElement(\"span\");if(n.className=\"blar-intro-executive-name\",n.textContent=e.name,t.appendChild(n),e.role_label){const n=document.createElement(\"span\");n.className=\"blar-intro-executive-role\",n.textContent=e.role_label,t.appendChild(n)}return t}const mA=\"blar-intro-presentation-styles\",fA=\"blar-intro-widget-styles\",bA=320,yA=12,vA=I.replace(/#4593F8/g,\"currentColor\").replace(/width=\"16\"/,'width=\"26\"').replace(/height=\"16\"/,'height=\"26\"');class wA{constructor(e){this.callbacks=e,this.activeMode=\"widget\",this.agentName=T,this.agentAvatarUrl=null,this.executive=null,this.backdrop=null,this.card=null,this.overlay=null,this.cardRoot=null,this.hostStyleEl=null,this.widgetStyleEl=null,this.captionEl=null,this.highlightEl=null,this.savedStyles=null,this.playing=!1,this.aborted=!1,this.introResolve=null,this.waitResolve=null,this.waitTimer=null,this.finishTimer=null,this.escHandler=null,this.reducedMotion=\"function\"==typeof matchMedia&&matchMedia(\"(prefers-reduced-motion: reduce)\").matches,this.cursor=new sp,this.agentUI=new zp(()=>this.finishEarly())}async play(e=\"widget\",t,n,i){if(!this.playing){if(this.playing=!0,this.aborted=!1,this.cursor.beginSession(),this.activeMode=e,this.agentName=t?.trim()||T,this.agentAvatarUrl=this.safeAvatarUrl(n),this.executive=i??null,this.ensureHostStyles(),\"takeover\"===this.activeMode)this.buildBackdrop(),this.buildTakeoverCard();else if(await this.openWidgetSurface(),!this.cardRoot)return void await this.finish();this.applyAgentAvatar(),this.applyExecutive(),this.installEscHandler(),await this.raf(),this.setSurfaceVisible(!0);try{\"continue\"!==await this.runIntro()||this.aborted||await this.runHighlights()}finally{await this.finish()}}}destroy(){this.finishEarly(),null!==this.finishTimer&&(clearTimeout(this.finishTimer),this.finishTimer=null),this.removeEscHandler(),this.restoreHighlight(),this.removeCaption(),this.teardownSurface(),this.cursor.destroy(),this.agentUI.destroy(),os(this.hostStyleEl),this.hostStyleEl=null,os(this.widgetStyleEl),this.widgetStyleEl=null,this.playing=!1}buildBackdrop(){const e=document.createElement(\"div\");return e.className=\"blar-intro-backdrop\",document.body.appendChild(e),this.backdrop=e,e}ensureBackdropForReel(){if(this.backdrop)return void this.backdrop.classList.add(\"blar-intro-backdrop--visible\");const e=this.buildBackdrop();requestAnimationFrame(()=>e.classList.add(\"blar-intro-backdrop--visible\"))}buildTakeoverCard(){const e=document.createElement(\"div\");e.className=\"blar-intro-card\",e.setAttribute(\"role\",\"dialog\"),e.setAttribute(\"aria-modal\",\"true\"),e.innerHTML=this.cardInnerHtml(),document.body.appendChild(e),this.card=e,this.cardRoot=e,e.querySelector(\".blar-intro-skip\").onclick=()=>this.finishEarly()}async openWidgetSurface(){await(this.callbacks.openChat?.());const e=this.callbacks.getContainer?.()??null,t=e?.querySelector(\".support-chat-window\");if(!e||!t)return;this.ensureWidgetStyles(e);const n=document.createElement(\"div\");n.className=\"support-intro-overlay\",n.setAttribute(\"role\",\"dialog\"),n.innerHTML=this.cardInnerHtml(),t.appendChild(n),this.overlay=n,this.cardRoot=n,n.querySelector(\".blar-intro-skip\").onclick=()=>this.finishEarly()}cardInnerHtml(){const e=Na().introPresentation;return`\\n      <button class=\"blar-intro-skip\" type=\"button\" aria-label=\"${e.ariaSkip}\">${e.skip}</button>\\n      <div class=\"blar-intro-avatars\">\\n        <div class=\"blar-intro-badge\">${vA}</div>\\n      </div>\\n      <div class=\"blar-intro-card-text blar-intro-card-text--in\">\\n        <h2 class=\"blar-intro-card-title\"></h2>\\n        <p class=\"blar-intro-card-body\"></p>\\n      </div>\\n      <div class=\"blar-intro-footer\">\\n        <div class=\"blar-intro-dots\"></div>\\n        <button class=\"blar-intro-next\" type=\"button\"></button>\\n      </div>\\n    `}setSurfaceVisible(e){\"takeover\"===this.activeMode?(this.backdrop?.classList.toggle(\"blar-intro-backdrop--visible\",e),this.card?.classList.toggle(\"blar-intro-card--visible\",e)):this.overlay?.classList.toggle(\"support-intro-overlay--visible\",e)}hideCardForReel(){\"takeover\"===this.activeMode?this.card?.classList.remove(\"blar-intro-card--visible\"):this.overlay?.classList.remove(\"support-intro-overlay--visible\")}teardownSurface(){os(this.backdrop),this.backdrop=null,os(this.card),this.card=null,os(this.overlay),this.overlay=null,this.cardRoot=null}runIntro(){return new Promise(e=>{this.introResolve=e;const t=this.introSteps();let n=0;const i=this.cardRoot;if(!i)return void e(\"skip\");const s=i.querySelector(\".blar-intro-card-title\"),r=i.querySelector(\".blar-intro-card-body\"),o=i.querySelector(\".blar-intro-dots\"),a=i.querySelector(\".blar-intro-next\"),l=()=>{const e=t[n];s.textContent=this.fillNames(e.title),r.textContent=this.fillNames(e.body),i.classList.toggle(\"blar-intro--executive\",null!==this.executive&&1===n);const l=Na().introPresentation;a.textContent=n===t.length-1?l.showMe:l.next,o.innerHTML=t.map((e,t)=>`<span class=\"blar-intro-dot${t===n?\" is-active\":\"\"}\"></span>`).join(\"\");const c=r.parentElement;c?.classList.remove(\"blar-intro-card-text--in\"),c?.classList.add(\"blar-intro-card-text--in\")};a.onclick=()=>{n<t.length-1?(n++,l()):(this.introResolve=null,e(\"continue\"))},l()})}async runHighlights(){const e=this.pickTargets(3),t=Na().introPresentation.captions,n=this.findTextInput();this.hideCardForReel(),this.ensureBackdropForReel(),this.agentUI.show(),this.agentUI.setStatus(Na().agent.scanningPage);for(let i=0;i<e.length;i++){if(this.aborted)return;const s=t[i%t.length];1===i&&n?await this.runTypingBeat(n,s):await this.runHighlightBeat(e[i],s)}}async runHighlightBeat(e,t){await this.cursor.moveTo(e,!1),this.aborted||(this.highlightElement(e),this.showCaption(e,t),await this.wait(1900),this.restoreHighlight(),this.removeCaption())}async runTypingBeat(e,t){if(await this.cursor.moveTo(e,!1),this.aborted)return;this.highlightElement(e),this.showCaption(e,t);const n=Na().introPresentation.typeSample,i=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement,s=i?e.value:e.textContent??\"\",r=t=>{i?e.value=t:e.textContent=t};try{for(let e=1;e<=n.length&&!this.aborted;e++)r(n.slice(0,e)),await this.wait(55);this.aborted||await this.wait(900)}finally{r(s),this.restoreHighlight(),this.removeCaption()}}findTextInput(){const e=['input[type=\"text\"]','input[type=\"email\"]','input[type=\"search\"]','input[type=\"url\"]',\"input:not([type])\",\"textarea\",'[contenteditable=\"\"]','[contenteditable=\"true\"]'].join(\", \");for(const t of Array.from(document.querySelectorAll(e)))if(this.isGoodTarget(t)){if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){if(t.disabled||t.readOnly||t.value.trim())continue}else if(t.textContent&&t.textContent.trim())continue;return t}return null}finish(){return new Promise(e=>{this.restoreHighlight(),this.removeCaption(),this.cursor.endSession(),this.removeEscHandler(),this.agentUI.hide(),this.setSurfaceVisible(!1),this.backdrop?.classList.remove(\"blar-intro-backdrop--visible\"),this.finishTimer=window.setTimeout(()=>{this.finishTimer=null,this.teardownSurface(),this.playing=!1,this.callbacks.onFinish(),e()},this.reducedMotion?0:bA)})}finishEarly(){if(!this.aborted){if(this.aborted=!0,this.introResolve){const e=this.introResolve;this.introResolve=null,e(\"skip\")}if(null!==this.waitTimer&&(clearTimeout(this.waitTimer),this.waitTimer=null),this.waitResolve){const e=this.waitResolve;this.waitResolve=null,e()}}}pickTargets(e){const t=Array.from(document.querySelectorAll(\"[data-blar-intro-highlight]\")).filter(e=>this.isGoodTarget(e)),n=this.scanCandidates(),i=[],s=new Set;for(const r of[...this.shuffle(t),...this.shuffle(n)])if(!s.has(r)&&(s.add(r),i.push(r),i.length>=e))break;return i}scanCandidates(){const e=new Set,t=[];return document.querySelectorAll('button, a[href], [role=\"button\"], [role=\"link\"], nav a, h1, h2, [class*=\"card\"]').forEach(n=>{!e.has(n)&&this.isGoodTarget(n)&&(e.add(n),t.push(n))}),t}isGoodTarget(e){if(this.isBlarUi(e))return!1;const t=getComputedStyle(e);if(\"none\"===t.display||\"hidden\"===t.visibility||0===parseFloat(t.opacity))return!1;const n=e.getBoundingClientRect();return!(n.width<24||n.height<16)&&(!(n.width>.95*window.innerWidth&&n.height>.9*window.innerHeight)&&!(n.bottom<=0||n.right<=0||n.top>=window.innerHeight||n.left>=window.innerWidth))}isBlarUi(e){return Ho.some(t=>null!==e.closest(t))}shuffle(e){const t=e.slice();for(let e=t.length-1;e>0;e--){const n=Math.floor(Math.random()*(e+1));[t[e],t[n]]=[t[n],t[e]]}return t}highlightElement(e){this.highlightEl=e;const t=e.style;this.savedStyles={outline:t.outline,outlineOffset:t.outlineOffset,boxShadow:t.boxShadow,position:t.position,zIndex:t.zIndex,borderRadius:t.borderRadius,pointerEvents:t.pointerEvents};const n=bs.getPrimaryColor();t.position&&\"static\"!==t.position||(t.position=\"relative\"),t.zIndex=String(2147483643),t.outline=`3px solid ${n}`,t.outlineOffset=\"3px\",t.borderRadius||(t.borderRadius=\"6px\"),t.pointerEvents=\"none\",e.classList.add(\"blar-intro-highlight\")}restoreHighlight(){if(!this.highlightEl||!this.savedStyles)return;const e=this.highlightEl.style,t=this.savedStyles;e.outline=t.outline,e.outlineOffset=t.outlineOffset,e.boxShadow=t.boxShadow,e.position=t.position,e.zIndex=t.zIndex,e.borderRadius=t.borderRadius,e.pointerEvents=t.pointerEvents,this.highlightEl.classList.remove(\"blar-intro-highlight\"),this.highlightEl=null,this.savedStyles=null}showCaption(e,t){this.removeCaption();const n=document.createElement(\"div\");n.className=\"blar-intro-caption\",n.textContent=t,document.body.appendChild(n),this.captionEl=n;const i=e.getBoundingClientRect(),s=n.getBoundingClientRect();let r=i.top<window.innerHeight/2?i.bottom+yA:i.top-s.height-yA,o=i.left+i.width/2-s.width/2;o=Math.max(yA,Math.min(o,window.innerWidth-s.width-yA)),r=Math.max(yA,Math.min(r,window.innerHeight-s.height-yA)),n.style.top=`${Math.round(r)}px`,n.style.left=`${Math.round(o)}px`}removeCaption(){os(this.captionEl),this.captionEl=null}introSteps(){const e=Na().introPresentation;return this.executive?[...e.steps.slice(0,1),e.executiveStep,...e.steps.slice(1)]:e.steps}fillNames(e){const t=this.executive?.name??\"\";return e.replace(/\\{name\\}/g,()=>this.agentName).replace(/\\{executive\\}/g,()=>t)}safeAvatarUrl(e){const t=e?.trim();if(!t)return null;try{const e=new URL(t,window.location.href);return\"http:\"===e.protocol||\"https:\"===e.protocol?e.href:null}catch{return null}}applyAgentAvatar(){if(!this.agentAvatarUrl||!this.cardRoot)return;const e=this.cardRoot.querySelector(\".blar-intro-badge\");if(!e)return;const t=document.createElement(\"img\");t.className=\"blar-intro-badge-img\",t.alt=this.agentName,t.decoding=\"async\",t.onerror=()=>{e.classList.remove(\"blar-intro-badge--photo\"),os(t)},e.classList.add(\"blar-intro-badge--photo\"),e.appendChild(t),t.src=this.agentAvatarUrl}applyExecutive(){if(!this.executive||!this.cardRoot)return;const e=this.cardRoot.querySelector(\".blar-intro-avatars\"),t=this.cardRoot.querySelector(\".blar-intro-card-text\");if(!e||!t)return;const{avatar:n,identity:i}=(s=this.executive,r=this.safeAvatarUrl(this.executive.avatar_url),{avatar:hA(s.name,r),identity:gA(s)});var s,r;e.appendChild(n),t.parentNode?.insertBefore(i,t)}installEscHandler(){this.escHandler=e=>{\"Escape\"===e.key&&this.finishEarly()},document.addEventListener(\"keydown\",this.escHandler,!0)}removeEscHandler(){this.escHandler&&(document.removeEventListener(\"keydown\",this.escHandler,!0),this.escHandler=null)}wait(e){return new Promise(t=>{this.waitResolve=t,this.waitTimer=window.setTimeout(()=>{this.waitTimer=null,this.waitResolve=null,t()},e)})}raf(){return new Promise(e=>requestAnimationFrame(()=>e()))}ensureHostStyles(){if(document.getElementById(mA))return;const e=document.createElement(\"style\");e.id=mA,e.textContent=this.buildHostStyles(),document.head.appendChild(e),this.hostStyleEl=e}ensureWidgetStyles(e){const t=e.getRootNode();if(!(t instanceof ShadowRoot)||t.getElementById(fA))return;const n=document.createElement(\"style\");n.id=fA,n.textContent=this.buildWidgetStyles(),t.appendChild(n),this.widgetStyleEl=n}cardInnerCss(e,t){return`\\n      .blar-intro-avatars {\\n        display: flex; align-items: center; gap: 12px;\\n        margin-bottom: 18px;\\n        animation: blarIntroBadgeFloat 3.2s ease-in-out infinite;\\n      }\\n      .blar-intro-badge {\\n        width: 56px; height: 56px; border-radius: 16px; flex-shrink: 0;\\n        display: flex; align-items: center; justify-content: center;\\n        color: #ffffff;\\n        background: linear-gradient(135deg, ${e}, rgba(${t}, 0.75));\\n        box-shadow: 0 8px 24px rgba(${t}, 0.45);\\n      }\\n      .blar-intro-badge svg { width: 30px; height: 30px; }\\n\\n      /* Persona photo fills the badge; the gradient + logo are the fallback. */\\n      .blar-intro-badge--photo { background: none; overflow: hidden; }\\n      .blar-intro-badge--photo svg { display: none; }\\n      .blar-intro-badge-img {\\n        width: 100%; height: 100%; object-fit: cover;\\n        border-radius: 16px; display: block;\\n      }\\n\\n      .blar-intro-card-text { min-height: 96px; }\\n      .blar-intro-card-text--in { animation: blarIntroTextIn 0.32s ease both; }\\n      .blar-intro-card-title {\\n        margin: 0 0 8px; font-size: 20px; font-weight: 700; line-height: 1.25;\\n        color: var(--widget-text, #0f172a);\\n      }\\n      .blar-intro-card-body {\\n        margin: 0; font-size: 14.5px; line-height: 1.55;\\n        color: var(--widget-text-muted, #475569);\\n      }\\n\\n      .blar-intro-footer {\\n        display: flex; align-items: center; justify-content: space-between;\\n        margin-top: 22px;\\n      }\\n      .blar-intro-dots { display: flex; gap: 7px; }\\n      .blar-intro-dot {\\n        width: 7px; height: 7px; border-radius: 50%;\\n        background: var(--widget-border, #cbd5e1); transition: all 0.25s ease;\\n      }\\n      .blar-intro-dot.is-active { width: 22px; border-radius: 4px; background: ${e}; }\\n\\n      .blar-intro-next {\\n        border: none; cursor: pointer; padding: 10px 20px; border-radius: 10px;\\n        font-size: 14px; font-weight: 600; color: #ffffff; background: ${e};\\n        box-shadow: 0 4px 14px rgba(${t}, 0.4);\\n        transition: transform 0.15s ease, box-shadow 0.15s ease;\\n      }\\n      .blar-intro-next:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(${t}, 0.5); }\\n      .blar-intro-next:active { transform: translateY(0); }\\n\\n      .blar-intro-skip {\\n        position: absolute; top: 14px; right: 16px;\\n        border: none; background: transparent; cursor: pointer;\\n        font-size: 13px; font-weight: 500; padding: 4px 6px; font-family: inherit;\\n        color: var(--widget-text-muted, #94a3b8);\\n      }\\n      .blar-intro-skip:hover { opacity: 0.7; }\\n\\n      @keyframes blarIntroBadgeFloat {\\n        0%, 100% { transform: translateY(0); }\\n        50% { transform: translateY(-5px); }\\n      }\\n      @keyframes blarIntroTextIn {\\n        from { opacity: 0; transform: translateY(8px); }\\n        to { opacity: 1; transform: translateY(0); }\\n      }\\n\\n      ${function(e,t){return`\\n    .blar-intro-executive-avatar {\\n      display: none; flex-shrink: 0;\\n      width: 56px; height: 56px; border-radius: 50%; overflow: hidden;\\n      align-items: center; justify-content: center;\\n      font-size: 20px; font-weight: 700; letter-spacing: 0.5px;\\n      color: #ffffff; background: ${e};\\n      box-shadow: 0 8px 24px rgba(${t}, 0.35);\\n    }\\n    .blar-intro-executive-avatar--photo { background: var(--widget-border, #e2e8f0); }\\n    .blar-intro-executive-img { width: 100%; height: 100%; object-fit: cover; display: block; }\\n\\n    .blar-intro-executive {\\n      display: none; flex-direction: column; gap: 2px;\\n      margin: -4px 0 14px;\\n    }\\n    .blar-intro-executive-name {\\n      font-size: 15px; font-weight: 700; line-height: 1.3;\\n      color: var(--widget-text, #0f172a);\\n    }\\n    .blar-intro-executive-role {\\n      font-size: 13px; line-height: 1.35;\\n      color: var(--widget-text-muted, #64748b);\\n    }\\n\\n    .blar-intro--executive .blar-intro-executive-avatar {\\n      display: flex;\\n      animation: blarIntroExecutiveIn 0.36s cubic-bezier(0.34, 1.56, 0.64, 1) both;\\n    }\\n    .blar-intro--executive .blar-intro-executive {\\n      display: flex;\\n      animation: blarIntroTextIn 0.32s ease both;\\n    }\\n\\n    @keyframes blarIntroExecutiveIn {\\n      from { opacity: 0; transform: scale(0.6); }\\n      to { opacity: 1; transform: scale(1); }\\n    }\\n\\n    @media (prefers-reduced-motion: reduce) {\\n      .blar-intro--executive .blar-intro-executive-avatar,\\n      .blar-intro--executive .blar-intro-executive { animation: none; }\\n    }\\n  `}(e,t)}\\n    `}buildHostStyles(){const e=bs.getPrimaryColor(),t=S(e);return`\\n      .blar-intro-backdrop {\\n        position: fixed; inset: 0; z-index: 2147483630;\\n        background: radial-gradient(circle at 50% 40%, rgba(15, 23, 42, 0.55), rgba(2, 6, 23, 0.82));\\n        opacity: 0; transition: opacity 320ms ease; pointer-events: auto;\\n      }\\n      .blar-intro-backdrop--visible { opacity: 1; }\\n\\n      .blar-intro-card {\\n        position: fixed; top: 50%; left: 50%; z-index: 2147483645;\\n        width: min(380px, calc(100vw - 40px)); box-sizing: border-box;\\n        padding: 28px 26px 22px; background: #ffffff; border-radius: 20px;\\n        box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);\\n        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n        opacity: 0; transform: translate(-50%, -46%) scale(0.94);\\n        transition: opacity 320ms ease, transform 320ms cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0s linear 320ms;\\n        pointer-events: auto;\\n      }\\n      .blar-intro-card--visible { opacity: 1; transform: translate(-50%, -50%) scale(1); transition-delay: 0s; }\\n      .blar-intro-card:not(.blar-intro-card--visible) { pointer-events: none; visibility: hidden; }\\n\\n      .blar-intro-highlight {\\n        border-radius: 6px;\\n        /* Static glow so the element pops even with reduced motion (no keyframes). */\\n        box-shadow:\\n          0 0 0 3px rgba(255, 255, 255, 0.9),\\n          0 0 0 7px rgba(${t}, 0.6),\\n          0 0 36px 10px rgba(${t}, 0.7);\\n        animation: blarIntroPulse 1.6s ease-in-out infinite;\\n      }\\n      @keyframes blarIntroPulse {\\n        0%, 100% {\\n          box-shadow:\\n            0 0 0 3px rgba(255, 255, 255, 0.9),\\n            0 0 0 6px rgba(${t}, 0.6),\\n            0 0 30px 8px rgba(${t}, 0.6);\\n        }\\n        50% {\\n          box-shadow:\\n            0 0 0 3px rgba(255, 255, 255, 1),\\n            0 0 0 11px rgba(${t}, 0.5),\\n            0 0 52px 16px rgba(${t}, 0.85);\\n        }\\n      }\\n\\n      .blar-intro-caption {\\n        position: fixed; z-index: 2147483644; max-width: 240px;\\n        padding: 9px 14px; border-radius: 12px; background: ${e}; color: #ffffff;\\n        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n        font-size: 13.5px; font-weight: 600; line-height: 1.4;\\n        box-shadow: 0 10px 30px rgba(${t}, 0.5); pointer-events: none;\\n        animation: blarIntroCaptionIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) both;\\n      }\\n      @keyframes blarIntroCaptionIn {\\n        from { opacity: 0; transform: scale(0.85); }\\n        to { opacity: 1; transform: scale(1); }\\n      }\\n\\n      ${this.cardInnerCss(e,t)}\\n\\n      @media (prefers-reduced-motion: reduce) {\\n        .blar-intro-backdrop, .blar-intro-card { transition: opacity 0.01ms linear; }\\n        .blar-intro-avatars, .blar-intro-highlight, .blar-intro-card-text--in,\\n        .blar-intro-caption { animation: none; }\\n        .blar-intro-card--visible { transform: translate(-50%, -50%) scale(1); }\\n      }\\n    `}buildWidgetStyles(){const e=bs.getPrimaryColor(),t=S(e);return`\\n      .support-intro-overlay {\\n        position: absolute; inset: 0; z-index: 20; box-sizing: border-box;\\n        display: flex; flex-direction: column; justify-content: center;\\n        padding: 28px 26px; background: var(--widget-surface, #ffffff);\\n        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\\n        opacity: 0; transform: translateY(10px);\\n        transition: opacity 320ms ease, transform 320ms cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0s linear 320ms;\\n        pointer-events: auto;\\n      }\\n      .support-intro-overlay--visible { opacity: 1; transform: translateY(0); transition-delay: 0s; }\\n      .support-intro-overlay:not(.support-intro-overlay--visible) { pointer-events: none; visibility: hidden; }\\n\\n      ${this.cardInnerCss(e,t)}\\n\\n      @media (prefers-reduced-motion: reduce) {\\n        .support-intro-overlay { transition: opacity 0.01ms linear; }\\n        .blar-intro-avatars, .blar-intro-card-text--in { animation: none; }\\n      }\\n    `}}class xA{get isAdminMode(){return null!==this.config.adminToken||null!==this.config.releaseUuidToOpen||null!==this.config.releaseUuidToTest}get isMessagesOnly(){return this.config.messagesOnly&&!this.isAdminMode}get activeConversation(){return this._activeConversation}set activeConversation(e){this._activeConversation=e,this.voiceComposer?.syncMicSlot(),this.restoreVoiceDraft()}constructor(e){if(this.stopSelfUpdate=()=>{},this.isNewTicket=!1,this.awarenessManager=null,this.presenceManager=null,this.pendingIntroCompletionSourceId=null,this.contactLive=null,this.nudgeAnchor=null,this.goalNudgeBubble=null,this.voiceCallManager=null,this.screenShareManager=null,this.goalNudgeActive=!1,this.decisionCardBubbleKey=null,this.activationStartsInFlight=0,this.activationSessionStartedInFlight=null,this.goalNudgeAccept=null,this._activeConversation=null,this.replyTarget=null,this.aiAckTimeout=null,this.disposables=new fs,this.destroyed=!1,this.backgroundNotifier=null,this.tabUnreadCounts=new Map,this.selectedFiles=[],this.isTyping=!1,this.typingTimeout=null,this.lastTypingSent=0,this.TYPING_THROTTLE_MS=1e3,this.TYPING_TIMEOUT_MS=3e3,this.resizeHandler=null,this.preChatFormConfig=null,this.preChatFormManager=null,this.aiConfigIconUrl=\"\",this.isHandlingEscalation=!1,this.conversationCreationsInFlight=0,this.pendingNudgeInFlight=!1,this.isArchiving=!1,this.onboardingWasComplete=!1,this.introInProgress=!1,this.introStarted=!1,this.introPresentationSourceId=null,this.activationFormReady=!1,this.activationFormObserver=null,this.activationFormReadyTimer=null,this.awarenessSessionSticky=!1,this.conversationContext=new NE,this.agentRunInOtherTab=!1,this.isRestoringAdminSession=!1,this.hostIdentity=null,this.initSettled=!1,this.identityChanges=0,this.sessionOriginTab=\"home\",this.activeReleaseUuid=null,!e.publishableKey)throw new Error(Na().errors.noPublishableKey);this.hostConfig=e,this.proofIdentity=e.identity??null,this.hostHidden=e.startHidden??!1,this.onboardingStepToConfigure=e.onboardingStepToConfigure??null,this.onboardingStepToTest=e.onboardingStepToTest??null,ds.setSkipCookie(e.skipCookie||!1);const t=ds.get(\"support_widget_language\"),n=e.language||t||\"en\";!function(e=\"en\"){Ra(e)}(n);const i=e.theme?_[e.theme]:e.primaryColor||c.PRIMARY_COLOR,s=e.secondaryColor||A(i);var r;this.config={publishableKey:e.publishableKey,title:e.title,welcomeSubtitle:e.welcomeSubtitle,position:e.position||c.POSITION,primaryColor:i,secondaryColor:s,colorScheme:e.colorScheme||c.COLOR_SCHEME,autoOpen:e.autoOpen||c.AUTO_OPEN,showBranding:!0,apiBaseUrl:e.apiBaseUrl||\"https://api.blar.io\",language:n,autoResponseMessage:e.autoResponseMessage||c.AUTO_RESPONSE_MESSAGE,enableSound:!1!==e.enableSound,unreadAnimation:e.unreadAnimation||c.UNREAD_ANIMATION,testAgentMode:e.testAgentMode??c.TEST_AGENT_MODE,startHidden:e.startHidden??c.START_HIDDEN,messagesOnly:e.messagesOnly??!1,agentExecution:!1!==e.agentExecution,displayMode:e.displayMode||c.DISPLAY_MODE,sidePanelSide:e.sidePanelSide||c.SIDE_PANEL_SIDE,sidePanelBehavior:e.sidePanelBehavior||c.SIDE_PANEL_BEHAVIOR,pushTarget:e.pushTarget??null,skipCookie:e.skipCookie||!1,trackAllRequests:e.trackAllRequests||!1,releaseUuidToOpen:e.releaseUuidToOpen??null,releaseUuidToTest:e.releaseUuidToTest??null,adminToken:e.adminToken??null,identity:e.identity,onClose:e.onClose?es(\"SupportWidget.onClose\",e.onClose):null},this.nudgeAnchor=e.nudgeAnchor??null,r={publishableKey:this.config.publishableKey,widgetVersion:\"1.0.0\"},Hi={...Hi,...r},Bi=()=>({websocketConnected:this.wsEventDispatcher.isConnected(),chatOpen:this.chatStateManager.isOpened()}),function(e){Di=e}(()=>({sourceId:this.sessionManager.getSourceId(),sessionId:this.sessionManager.getSessionId(),conversationId:this.sessionManager.getTicketId(),userExternalId:this.sessionManager.getUser()?.externalId??null,companyExternalId:this.sessionManager.getUser()?.contactCompanyExternalId??null})),this.isAdminMode&&(this.config.autoOpen=!0,this.config.showBranding=!1,this.config.enableSound=!1,this.config.displayMode=\"side-panel\",this.config.sidePanelSide=\"right\",this.config.sidePanelBehavior=\"overlay\"),this.networkTracker=new FE(this.config.apiBaseUrl,this.config.trackAllRequests),this.networkTracker.install(),this.authHeaderObserver=new OE,this.authHeaderObserver.install(),this.adminModeStorage=new Ms(this.config.publishableKey),this.agentHandoffStorage=new As(this.config.publishableKey),this.config.adminToken&&this.adminModeStorage.setAdminToken(this.config.adminToken),ds.set(\"support_widget_language\",n);const o=ds.get(\"support_widget_sound\");null!==o&&(this.config.enableSound=\"1\"===o),e.preChatForm&&(this.preChatFormConfig=e.preChatForm),bs.setColors(this.config.primaryColor,this.config.secondaryColor),this.apiClient=new Ss(this.config.apiBaseUrl,this.config.publishableKey),this.apiClient.setAdminToken(this.config.adminToken),this.apiClient.setOnAdminAuthError(()=>this.handleAdminAuthExpired()),this.config.identity&&this.apiClient.setIdentity(this.config.identity),this.sessionManager=new bd(this.apiClient,this.config.publishableKey),this.sessionManager.onSessionIdChange=e.onSessionChange?es(\"SupportWidget.onSessionChange\",e.onSessionChange):null,this.sessionManager.onCampaignBanner=dA,this.sessionManager.onFeatureCheckIn=e=>this.handleFeatureCheckIn(e),this.sessionManager.onContactChange=()=>{this.contactLive?.closeIfStale(),this.presenceManager?.syncSource()},this.metadataManager=new xa(this.networkTracker),this.tourManager=new VE,this.initPromise=this.init(),this.initPromise.catch(e=>Ji(\"init\",e));const a=()=>{this.initSettled=!0};this.initPromise.then(a,a);const l=function(e,t){const n=e.constructor?.name??\"Widget\";return new Proxy(e,{get(e,i){const s=Reflect.get(e,i,e);if(\"function\"!=typeof s||\"string\"!=typeof i)return s;if(ts.has(i))return s.bind(e);const r=s,o=`${n}.${i}`;return function(...n){try{const s=r.apply(e,n);return function(e){return null!==e&&\"object\"==typeof e&&\"function\"==typeof e.then}(s)?s.then(e=>e,e=>(t(o,e),is(i))):s}catch(e){return t(o,e),is(i)}}}})}(this,Ji);return this.stopSelfUpdate=gs(l),l}async init(){let e;try{e=await this.sessionManager.loadAnonymousSession()}catch{if(!this.isAdminMode)throw new Error(\"Failed to load session\");e={}}this.apiClient.getAIConfig().then(e=>{this.aiConfigIconUrl=e.icon_url||\"\",this.applyAgentIdentity()}).catch(()=>{}),this.uiManager=new Cd({title:this.config.title,primaryColor:this.config.primaryColor,secondaryColor:this.config.secondaryColor,position:this.config.position,showBranding:this.config.showBranding,unreadAnimation:this.config.unreadAnimation,displayMode:this.config.displayMode,sidePanelSide:this.config.sidePanelSide,sidePanelBehavior:this.config.sidePanelBehavior,pushTarget:this.config.pushTarget,adminMode:this.isAdminMode,messagesOnly:this.isMessagesOnly}),this.container=this.uiManager.init(),this.applyColorScheme(),this.uiManager.setAiActive(this.sessionManager.getAiActive()),this.restoreWidgetMode(),this.config.startHidden&&this.uiManager.hideCompletely(),this.chatStateManager=new Ed(this.container),this.messageHandler=new zc(this.container,void 0,(e,t)=>this.handleTourStart(e,t)),this.isAdminMode||this.messageHandler.setReplyHandler(e=>this.startReply(e)),this.messageHandler.setExecutiveNameProvider(()=>this.sessionManager.getExecutive()?.name??null),this.executiveAvailabilityNotice=new qM(()=>this.container.querySelector(\".support-header-status\"),()=>this.container.querySelector(\".support-agent-banner\"),()=>this.sessionManager.getExecutive()?.name??null),this.messageHandler.setHumanReplyListener(()=>this.executiveAvailabilityNotice.dismiss()),this.homeScreenManager=new GM(this.container,this.apiClient,e=>this.handleOnboardingStepStart(e),e=>this.handleOnboardingStepConfigure(e),this.isAdminMode,this.config.welcomeSubtitle),this.sessionManager.onAgentPersona=()=>this.applyAgentIdentity(),this.applyAgentIdentity(),this.progressChecklist=new fM(this.container,this.apiClient,(e,t)=>this.startChecklistObjective(e,t),e=>this.startChecklistSecondary(e),e=>this.bubbleAlternator?.setChecklistData(e)),this.planPanelManager=new rA(this.container,this.apiClient),this.npsPrompt=new oA(this.container,this.apiClient),this.activationFormManager=new uA(this.container,this.apiClient,{onComplete:()=>{this.sessionManager.clearPendingActivationForm(),this.homeScreenManager.refresh(),this.refreshProgressChecklist(),this.tryShowNPS()}}),this.featureCheckInManager=new pA(this.container,this.apiClient,{onChange:()=>{this.tryShowActivationPrompts(),this.tryShowNPS()},onAnswered:e=>{this.sessionManager.checkIns.acknowledgeAnswer(e),this.homeScreenManager.refresh(),this.refreshProgressChecklist()},onStale:e=>this.sessionManager.checkIns.recoverStale(e)}),this.introPresentation=new wA({openChat:()=>this.openChat(),getContainer:()=>this.container,onFinish:()=>{this.signalIntroCompletion(),this.introStarted=!1,this.introInProgress=!1,this.openChat(),sA(this.container),setTimeout(()=>{this.tryShowActivationPrompts(),this.tryShowNPS()},600)}}),this.introInProgress=this.sessionManager.getShouldPlayIntro()&&\"1\"!==sessionStorage.getItem(\"support_widget_agent_active\"),this.bubbleAlternator=new tA(this.container,()=>this.handleOnboardingBubbleCardClick(),()=>this.switchToBadgeMode(),()=>this.chatStateManager.isOpened(),()=>this.uiManager.isInBadgeMode()),this.config.startHidden&&this.bubbleAlternator.setBubbleHidden(!0),this.isAdminMode&&null===this.config.releaseUuidToOpen&&null===this.config.releaseUuidToTest?this.homeScreenManager.setOnOnboardingDataLoaded(e=>{if(e&&this.onboardingStepToConfigure){const t=this.onboardingStepToConfigure;this.onboardingStepToConfigure=null;const n=e.steps.find(e=>e.uuid===t);n&&this.handleOnboardingStepConfigure(n)}if(e&&this.onboardingStepToTest){const t=this.onboardingStepToTest;this.onboardingStepToTest=null;const n=e.steps.find(e=>e.uuid===t);n&&this.handleOnboardingStepStart(n)}}):this.homeScreenManager.setOnOnboardingDataLoaded(e=>{if(e){(e.completed_step_uuids?.length??0)>=e.steps.length&&!this.onboardingWasComplete&&(this.onboardingWasComplete=!0,sA(this.container))}this.isAdminMode||this.bubbleAlternator.setOnboardingData(e)}),this.homeScreenManager.setOnResumeConversation((e,t)=>{this.openConversationFromTab({id:t,type:e,status:\"\"})}),this.homeScreenManager.setOnSelectEngineeringTicket(e=>{this.ticketDetailSheet.open({title:e.title,body:e.handoff_message,status:e.status,conversationId:e.conversation_id})}),this.homeScreenManager.setOnOpenLastTicket((e,t)=>{this.openConversationFromTab({id:e,type:\"session\",status:t})}),this.initTabNavigation(),this.readReceiptManager=new Uc(this.container,{onSendRead:e=>this.wsEventDispatcher.sendReadReceipt(e),onGetMaxSeq:()=>this.getMaxMessageSeq(),onApplyBubbleAnimation:()=>{this.uiManager.applyBubbleAnimation(),this.refreshUnreadBadges()},onRemoveBubbleAnimation:()=>{this.uiManager.removeBubbleAnimation(),this.refreshUnreadBadges()},onUnreadChange:()=>this.updateHiddenWidgetVisibility()}),this.wsEventDispatcher=new $E({apiBaseUrl:this.config.apiBaseUrl,publishableKey:this.config.publishableKey,testAgentMode:this.config.testAgentMode,agentExecution:this.config.agentExecution},this.networkTracker,this.authHeaderObserver,this.sessionManager,this.messageHandler,this.readReceiptManager,this.chatStateManager,this.uiManager,this.tourManager,()=>this.viewRouter.getCurrentView(),()=>this.shouldBlockInputWhileAIThinking(),e=>this.handleNewTicketHistoryLoaded(e),()=>this.handleAgentJoined(),()=>this.playNotificationSound(),()=>this.reattachInputListeners(),(e,t)=>this.handleSessionEscalated(e,t),(e,t)=>this.handleSessionStatus(e,t),e=>this.handleAiAssignedChange(e),()=>this.handleAdminSessionRestoreFailure(),()=>this.handleAdminSessionRestoreFailure(),e=>{\"connected\"===e?(this.isRestoringAdminSession=!1,this.refreshProgressChecklist(),this.wsEventDispatcher.onSessionCardResolved=e=>this.releaseResolvedCardBubble(e)):\"disconnected\"!==e&&\"failed\"!==e||this.handleAdminSessionRestoreFailure()},()=>this.clearAIAckTimer(),e=>this.handleOnboardingStepCompleted(e),()=>this.handlePlanSaved(),(e,t)=>this.handleConversationStatusChange(e,t),e=>this.surfaceSessionBubble(e),e=>this.voiceCallManager?.handleInvite(e),e=>this.handleVoiceCallStatus(e),e=>this.screenShareManager?.handleInvite(e),e=>this.screenShareManager?.handleStatus(e),e=>this.applyLiveCallSnapshot(e),e=>this.handleActivationForm(e),e=>this.sessionManager.checkIns.applyChatFrame(e),()=>this.sessionManager.checkIns.reconcile(),e=>this.executiveAvailabilityNotice.apply(e)),this.apiClient.setOnReachable(()=>this.wsEventDispatcher.reconnectIfFailed()),this.isAdminMode||(this.voiceCallManager=new OM({getContainer:()=>this.container??null,apiClient:this.apiClient,showToast:(e,t)=>this.uiManager.showToast(e,t),isChatOpen:()=>this.chatStateManager.isOpened(),closeChat:()=>{this.closeChat().catch(()=>{})},isActiveTab:()=>this.wsEventDispatcher.isActiveTab(),claimActiveTab:()=>this.wsEventDispatcher.claimTabOwnership(),isSoundEnabled:()=>this.config.enableSound}),this.screenShareManager=new WM({getContainer:()=>this.container??null,apiClient:this.apiClient,showToast:(e,t)=>this.uiManager.showToast(e,t),isActiveTab:()=>this.wsEventDispatcher.isActiveTab(),claimActiveTab:()=>this.wsEventDispatcher.claimTabOwnership(),getActiveVoiceCallId:()=>this.voiceCallManager?.getActiveCallId()??null,isAgentRecording:()=>this.wsEventDispatcher.isAgentRecording(),setCallShareMode:e=>this.voiceCallManager?.setScreenShareMode(e),apiBaseUrl:this.config.apiBaseUrl,publishableKey:this.config.publishableKey,getSourceId:()=>this.sessionManager.getSourceId()||\"\",tabId:ya()}),this.wsEventDispatcher.isScreenSharingProbe=()=>this.screenShareManager?.isSharing()??!1),this.wsEventDispatcher.onAgentRunElsewhereChange=e=>{this.agentRunInOtherTab=e,this.updateAgentBanner()},this.wsEventDispatcher.onActivationSessionStarted=e=>this.handleActivationSessionStarted(e),this.wsEventDispatcher.onActivationSessionClosed=e=>this.handleActivationSessionClosed(e),this.wsEventDispatcher.onActivationSessionReplaced=e=>this.handleActivationSessionReplaced(e),this.wsEventDispatcher.onAgentRunComplete=()=>this.refreshProgressChecklist(),this.armAuthHeaderObserver();const t=this.container.querySelector(\"#support-chat-messages\");if(t&&this.wsEventDispatcher.setMessagesContainer(t),this.messageSender=new ka(this.apiClient,{onMessageSent:(e,t)=>{this.messageHandler.removePendingIndicator(e,t.attachments,t.id)},onMessageFailed:(e,t,n)=>{n||(this.messageHandler.updateMessageStatus(e,\"failed\"),this.messageHandler.setRetryHandler(e,()=>{this.messageHandler.updateMessageStatus(e,\"sending\"),this.messageSender.retryMessage(e)}))},onStatusChange:(e,t)=>{t===Ts.SENDING&&this.messageHandler.updateMessageStatus(e,\"sending\")}},this.metadataManager),this.attachmentManager=new ZE(this.apiClient,{onError:e=>{this.uiManager.showToast(e,\"error\"),this.uiManager.hideUploadingState()}}),this.voiceAttachmentManager=new ZE(this.apiClient),this.voiceComposer=new tM({canRecord:()=>null!==this.activeConversation&&!this.chatStateManager.isTicketClosedState()&&!this.uiManager.isAIThinkingState()&&!this.isAdminMode,hasSelectedFiles:()=>this.selectedFiles.length>0,onSend:e=>this.sendVoiceNote(e),onError:e=>this.uiManager.showToast(Na().voiceNotes.errors[e],\"error\"),onDraftChanged:e=>{const t=this.voiceDraftKey();null!==t&&(e?sM.save(t,e):sM.clear(t))}}),this.uiManager.setOnAIThinkingChange(()=>this.voiceComposer?.syncMicSlot()),this.attachmentUrlCache=new eM(this.apiClient),this.messageHandler.setUrlCache(this.attachmentUrlCache),this.config.title&&this.homeScreenManager.setTitle(this.config.title),this.attachEventListeners(),this.setupVisibilityTracking(),\"side-panel\"===this.config.displayMode&&this.setupResizeHandler(),this.initializeNotificationSound(),this.updateSoundUI(),this.updateExpandUI(),this.isAdminMode){const e=Na(),t=this.container.querySelector(\".support-chat-input\");t&&(t.placeholder=e.adminMode.placeholder);const n=this.adminModeStorage.getAdminSessionId();if(null!==n){this.isRestoringAdminSession=!0,this.viewRouter.showView(\"chat\"),this.uiManager.setAdminStepActive(!0);const t=this.adminModeStorage.getAdminEntity();t&&(this.uiManager.setEntityContext(t),this.uiManager.setAdminInputPlaceholder(e.adminMode.scopedPlaceholder(t.title)));const i=this.adminModeStorage.getAdminReleaseUuid();return i&&(this.activeReleaseUuid=i,this.sessionOriginTab=\"releases\"),this.chatStateManager.open(),this.sessionManager.setSessionId(n),void this.connectToSession(n)}if(this.config.releaseUuidToOpen){const t=this.config.releaseUuidToOpen;this.sessionOriginTab=\"releases\",this.activeReleaseUuid=t,this.adminModeStorage.setAdminReleaseUuid(t),this.viewRouter.showView(\"chat\"),this.uiManager.showChatLoading(),this.uiManager.setAdminStepActive(!0),this.uiManager.setEntityContext({loading:!0}),this.resolveReleaseEntity(t,\"configure\");try{const e=await this.apiClient.startLiveFeedbackSession({releaseUuid:t});this.chatStateManager.open(),this.sessionManager.setSessionId(e.session_id),this.sessionManager.setTicketId(null),this.wsEventDispatcher.disconnect(),this.readReceiptManager.reset(),this.messageHandler.clearMessages(),this.connectToSession(e.session_id)}catch{this.uiManager.hideChatLoading(),this.uiManager.showToast(e.errors.apiRequestFailed,\"error\"),this.handleAdminBackToHome()}return}if(this.config.releaseUuidToTest){const t=this.config.releaseUuidToTest;this.sessionOriginTab=\"releases\",this.activeReleaseUuid=t,this.adminModeStorage.setAdminReleaseUuid(t),this.viewRouter.showView(\"chat\"),this.uiManager.showChatLoading(),this.uiManager.setAdminStepActive(!0),this.uiManager.setEntityContext({loading:!0}),this.resolveReleaseEntity(t,\"test\");try{const e=await this.apiClient.clickRelease(t);this.chatStateManager.open(),this.sessionManager.setSessionId(e.session_id),this.sessionManager.setTicketId(null),this.wsEventDispatcher.disconnect(),this.readReceiptManager.reset(),this.messageHandler.clearMessages(),this.chatStateManager.resetScrollFlag(),this.connectToSession(e.session_id)}catch{this.uiManager.hideChatLoading(),this.uiManager.showToast(e.errors.apiRequestFailed,\"error\"),this.handleAdminBackToHome()}return}return void this.viewRouter.showView(\"home\")}const n=e.sessionId,i=e.ticketId,r=void 0!==n,o=void 0!==i,a=null!==this.sessionManager.getUser(),l=this.preChatFormConfig&&this.preChatFormConfig.enabled&&!e.contactInfoSubmitted&&!a&&!r&&!o,c=this.isMessagesOnly?\"chat\":\"home\";l&&this.preChatFormConfig?(this.viewRouter.showView(\"chat\"),this.preChatFormManager=new rM(this.preChatFormConfig,this.container,this.apiClient,{onFormComplete:()=>{this.sessionManager.setContactInfoSubmitted(!0),this.viewRouter.showView(c),this.refreshHomeShortcuts()}}),this.preChatFormManager.renderForm()):this.viewRouter.showView(c),this.refreshHomeShortcuts();const d=\"1\"===sessionStorage.getItem(\"support_widget_agent_active\"),u=this.agentHandoffStorage.getSessionId();null!==u&&(this.agentHandoffStorage.clear(),sessionStorage.setItem(\"support_widget_agent_active\",\"1\"),ha(\"agent-flag:set\",{by:\"handoff-cookie\"}));const p=function(){let e;try{e=sessionStorage.getItem(_s),sessionStorage.removeItem(_s)}catch{return null}if(null===e)return null;try{const t=JSON.parse(e);return\"number\"!=typeof t?.expiresAt||t.expiresAt<s()?null:Number.isInteger(t.sessionId)&&\"boolean\"==typeof t.chatOpen?{sessionId:t.sessionId,chatOpen:t.chatOpen}:null}catch{return null}}(),h=null!==p?p.sessionId:d&&void 0!==n?n:null!==u?u:void 0;void 0!==h?(this.viewRouter.showView(\"chat\"),this.connectToSession(h),null!==p&&(this.wsEventDispatcher.reclaimTabAfterReload(),p.chatOpen&&!d&&this.openChat()),void 0!==i&&this.startBackgroundNotifier(\"ticket\",i)):void 0===n||void 0===i||this.sessionManager.getAiActive()?void 0!==n?this.connectToSession(n):void 0!==i&&(this.activeConversation={type:\"ticket\",id:i},this.conversationContext.setActive(\"ticket\",i),this.readReceiptManager.setTicketId(i),this.wsEventDispatcher.connect(\"ticket\")):(this.activeConversation={type:\"ticket\",id:i},this.conversationContext.setActive(\"ticket\",i),this.conversationContext.markSupportHandoff(!0),this.readReceiptManager.setTicketId(i),this.wsEventDispatcher.connect(\"ticket\"),this.startBackgroundNotifier(\"session\",n));const g=e.source;if(!this.isAdminMode&&g&&void 0!==n&&\"ticket\"!==this.activeConversation?.type){const e=Na();\"onboarding\"===g.type?this.uiManager.setEntityContext({action:e.onboarding.stepN(g.step.order+1),title:g.step.title}):\"release\"===g.type?(this.uiManager.setEntityContext({action:e.releases.releaseLabel,title:g.release.title}),this.sessionOriginTab=\"releases\"):\"awareness\"===g.type&&this.uiManager.setEntityContext({action:e.awareness.tipLabel,title:g.awareness.name})}this.updateConversationSelector();const m=us(\"blar_tour_id\"),f=function(){try{const e=sessionStorage.getItem(BE);return e?JSON.parse(e):null}catch{return null}}();if(m){const e=f?.tourId!==m||UE(f)?0:f.currentStep;this.loadAndRunTour(m,e)}else f&&!UE(f)&&this.loadAndRunTour(f.tourId,f.currentStep);this.awarenessManager=this.createAwarenessManager(us(\"blar_awareness_test\")),this.awarenessManager.checkForNudge(function(){const e=new URLSearchParams(window.location.search);e.delete(\"blar_awareness_test\");const t=e.toString();return window.location.pathname+(t?`?${t}`:\"\")}()).catch(()=>{}),this.startIntroPresentation(),setTimeout(()=>this.tryShowNPS(),1500),this.isAdminMode||(this.activationFormReadyTimer=setTimeout(()=>{this.activationFormReady=!0,this.tryShowActivationPrompts()},1500),this.activationFormObserver=new MutationObserver(()=>this.tryShowActivationPrompts()),this.activationFormObserver.observe(this.container,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[\"class\"]}),this.handleFeatureCheckIn(this.sessionManager.getFeatureCheckIn())),this.isAdminMode||(this.presenceManager=new cM(this.apiClient,{onPendingNudge:()=>this.handlePendingNudge(),onConversation:e=>this.contactLive?.pickUp(e,{announce:!0}),onCompletionRecorded:e=>{this.handleIntroCompletionRecorded(e)},onCompletionMismatch:async e=>{this.apiClient.getSourceId()===e&&(await this.sessionManager.refreshIdentityProof(),this.apiClient.getSourceId()===e&&await this.sessionManager.loadAnonymousSession())},completionStorageKey:`support_widget_intro_completion_${Cs(this.config.publishableKey)}`}),this.contactLive=new gM({apiBaseUrl:this.config.apiBaseUrl,publishableKey:this.config.publishableKey,tabId:ya(),getSourceId:()=>this.sessionManager.getSourceId(),getExternalId:()=>this.sessionManager.getUser()?.externalId??null,getIdentityProof:()=>this.sessionManager.getIdentityProof(),refreshIdentityProof:()=>this.sessionManager.refreshIdentityProof()},{presence:this.presenceManager,host:this.conversationPickUpHost(),frames:this.contactFrameHandlers(),checkIns:this.sessionManager.checkIns,onPendingNudge:()=>this.handlePendingNudge()}),this.contactLive.pickUp(this.sessionManager.getTicketId(),{announce:!1}),this.pendingIntroCompletionSourceId===this.apiClient.getSourceId()&&this.presenceManager.completeIntroPresentation(),this.pendingIntroCompletionSourceId=null,this.presenceManager.start()),this.refreshProgressChecklist()}handleVoiceCallStatus(e){this.voiceCallManager?.handleStatus(e),\"ended\"===e.status&&this.screenShareManager?.endLocally({silent:!0})}contactFrameHandlers(){return{onActivationForm:e=>this.handleActivationForm(e),onActivationSessionStarted:e=>{null!==this.activeConversation&&this.handleActivationSessionStarted(e)},onActivationSessionClosed:e=>this.handleActivationSessionClosed(e),onActivationSessionReplaced:e=>this.handleActivationSessionReplaced(e),onVoiceCallInvite:e=>this.voiceCallManager?.handleInvite(e),onVoiceCallStatus:e=>this.handleVoiceCallStatus(e),onScreenShareInvite:e=>this.screenShareManager?.handleInvite(e),onScreenShareStatus:e=>this.screenShareManager?.handleStatus(e)}}conversationPickUpHost(){return{getActive:()=>this.activeConversation,getBackground:()=>{const e=this.backgroundNotifier?.getConversationType(),t=this.backgroundNotifier?.getConversationId();return e&&t?{type:e,id:t}:null},isReadingChat:()=>this.chatStateManager.isOpened()&&\"chat\"===this.viewRouter.getCurrentView()&&!document.hidden,activeHasUnread:()=>this.readReceiptManager.getUnreadCount()>0,isSettling:()=>this.conversationCreationsInFlight>0||this.isHandlingEscalation,openTicket:e=>{this.sessionManager.setTicketId(e),this.openConversationFromTab({id:e,type:\"ticket\",status:\"\"},{reveal:!1}),this.refreshHomeShortcuts()},openTicketInBackground:e=>{this.sessionManager.setTicketId(e),this.startBackgroundNotifier(\"ticket\",e),this.updateConversationSelector(),this.refreshHomeShortcuts()},playSound:()=>this.playNotificationSound()}}applyLiveCallSnapshot(e){this.voiceCallManager&&(void 0!==e?null!==e&&(this.voiceCallManager.restoreFromServer(e),this.lookUpLiveShare()):this.rediscoverLiveCallOverHttp())}rediscoverLiveCallOverHttp(){this.apiClient.getActiveVoiceCall().then(e=>{e.call&&(this.voiceCallManager?.restoreFromServer(e.call),this.lookUpLiveShare())}).catch(()=>{})}lookUpLiveShare(){this.apiClient.getActiveScreenShare(ya()).then(e=>{wM(\"bootstrap lookup\",{share:e?.share??null}),e?.share&&this.screenShareManager?.restoreFromServer(e.share)}).catch(()=>{})}armAuthHeaderObserver(){const e=this.sessionManager.getApiBridge();if(!e)return;const t=e.descriptor.authHeader??\"Authorization\";this.authHeaderObserver.setTargetOrigins(e.allowedBaseUrls,t)}isNativeToggleControl(e){return!!e.closest(\"label, summary\")||e instanceof HTMLInputElement&&(\"checkbox\"===e.type||\"radio\"===e.type)}isEditableTarget(e){return e instanceof HTMLElement&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e.isContentEditable)}attachEventListeners(){const e=this.container.getRootNode()instanceof ShadowRoot?this.container.getRootNode().host:null;if(e){const t=e=>e.stopPropagation(),n=[\"pointerdown\",\"mousedown\",\"touchstart\",\"click\",\"dblclick\",\"auxclick\",\"contextmenu\",\"focusin\",\"focusout\"];for(const i of n)e.addEventListener(i,t);const i=e=>{e.ctrlKey||e.metaKey||e.altKey||1!==e.key.length||this.isEditableTarget(e.composedPath()[0]??null)&&e.stopPropagation()};for(const t of[\"keydown\",\"keypress\",\"keyup\"])e.addEventListener(t,i);const s=new WeakSet,r=t=>{if(!(t instanceof MouseEvent))return;if(s.has(t))return;const n=t.composedPath();if(!n.includes(e))return;const i=n[0];if(!(i instanceof Element)||i===e)return;t.stopImmediatePropagation();const r={bubbles:!0,cancelable:!0,composed:!1,detail:t.detail,view:t.view,screenX:t.screenX,screenY:t.screenY,clientX:t.clientX,clientY:t.clientY,ctrlKey:t.ctrlKey,shiftKey:t.shiftKey,altKey:t.altKey,metaKey:t.metaKey,button:t.button,buttons:t.buttons,relatedTarget:t.relatedTarget},o=t instanceof PointerEvent?new PointerEvent(t.type,{...r,pointerId:t.pointerId,pointerType:t.pointerType,isPrimary:t.isPrimary,pressure:t.pressure,width:t.width,height:t.height}):new MouseEvent(t.type,r);if(s.add(o),\"click\"===t.type&&this.isNativeToggleControl(i)&&i.addEventListener(\"click\",e=>{s.has(e)&&e.preventDefault()},{once:!0,capture:!0}),i.dispatchEvent(o),\"click\"===t.type){if(!o.defaultPrevented){const e=i.closest(\"a[href]\");if(e instanceof HTMLAnchorElement){const t=e.href;\"_blank\"===e.target?window.open(t,\"_blank\",\"noopener,noreferrer\"):t&&(window.location.href=t)}}}else o.defaultPrevented&&t.preventDefault()};for(const e of[\"pointerdown\",\"mousedown\",\"click\"])this.disposables.safeOn(window,e,r,`shadow-${e}-capture`,{capture:!0});let o=[];const a=()=>{o.forEach(e=>e()),o=[],document.querySelectorAll('[aria-modal=\"true\"]').forEach(e=>{const t=e.focus.bind(e);e.focus=()=>{},o.push(()=>{e.focus=t})})},l=()=>{o.forEach(e=>e()),o=[]};e.addEventListener(\"focusin\",a),e.addEventListener(\"focusout\",()=>{setTimeout(l,150)})}const t=this.container.querySelector(\".support-chat-body\");t&&t.addEventListener(\"wheel\",e=>{e.stopPropagation()},{passive:!0}),this.container.addEventListener(\"mousedown\",e=>{const t=e.target;t.classList.contains(\"support-chat-input\")&&setTimeout(()=>this.forceFocusOnInput(t),0)});const n=this.container.querySelector(\".support-bubble\"),i=this.container.querySelector(\".support-badge\"),r=this.container.querySelector(\".support-bubble-close\"),o=this.container.querySelector(\".support-close-btn\"),a=this.container.querySelector(\".support-new-chat-btn\"),l=this.container.querySelector(\".support-chat-input\"),c=this.container.querySelector(\".support-send-btn\"),d=this.container.querySelector(\".support-attach-btn\"),u=this.container.querySelector(\".support-file-input\"),p=this.container.querySelector(\".support-menu-btn\"),h=this.container.querySelector(\".support-menu-dropdown\"),g=this.container.querySelector(\".support-sound-toggle\"),m=this.container.querySelector(\".support-expand-toggle\");n.addEventListener(\"click\",()=>this.toggleChat()),this.setupBadgeDrag(i),r.addEventListener(\"click\",e=>{e.stopPropagation(),this.switchToBadgeMode()}),o.addEventListener(\"click\",()=>this.closeChat()),a.addEventListener(\"click\",()=>this.archiveSession());const f=this.container.querySelector(\".support-admin-back-btn\");f?.addEventListener(\"click\",()=>this.handleAdminBackToHome());const b=this.container.querySelector(\".support-admin-leave-btn\");b?.addEventListener(\"click\",()=>this.leaveAdminMode());const y=this.container.querySelector(\".support-admin-plan-btn\");y?.addEventListener(\"click\",()=>this.handleShowPlan());const v=this.container.querySelector(\".support-back-to-menu-btn\");v?.addEventListener(\"click\",()=>{const e=this.sessionOriginTab;this.sessionOriginTab=\"home\",this.hideNextStepCta(),this.uiManager.setEntityContext(null),this.clearReleaseChatContext(),this.tabBarManager.setActiveTab(e),this.viewRouter.showView(e)}),c.addEventListener(\"click\",()=>this.handleSendButtonClick()),l.addEventListener(\"keydown\",e=>{\"Enter\"!==e.key||e.shiftKey||(e.preventDefault(),this.handleEnterKeyPress())}),p.addEventListener(\"click\",e=>{e.stopPropagation(),h.classList.toggle(\"hidden\")}),this.disposables.safeOn(document,\"click\",e=>{p.contains(e.target)||h.contains(e.target)||h.classList.add(\"hidden\")},\"menu-close-click\"),g.addEventListener(\"click\",()=>{this.toggleSound(),this.updateSoundUI(),h.classList.add(\"hidden\")}),m.addEventListener(\"click\",()=>{this.toggleExpanded(),this.updateExpandUI(),h.classList.add(\"hidden\")}),l.addEventListener(\"input\",()=>{this.handleTypingInput(l.value),this.autoResizeTextarea(l)}),d.addEventListener(\"click\",()=>{u.click()}),u.addEventListener(\"change\",()=>{this.handleFileSelection(u)}),l.addEventListener(\"paste\",e=>this.handlePaste(e));const w=this.container.querySelector(\".support-input-container\");w&&(w.addEventListener(\"dragover\",e=>this.handleDragOver(e)),w.addEventListener(\"dragleave\",e=>this.handleDragLeave(e)),w.addEventListener(\"drop\",e=>this.handleDrop(e))),this.voiceComposer?.attach(this.container),this.container.addEventListener(\"system-action\",e=>{const t=e,{action:n,comment:i,source:r}=t.detail;\"goal_nudge\"===r?.suggestionType&&\"accept\"===n&&\"session\"===this.activeConversation?.type&&(this.goalNudgeAccept={sessionId:this.activeConversation.id,at:s()}),this.wsEventDispatcher.sendSystemAction(n,i,r)}),this.container.addEventListener(\"api-confirmation\",e=>{const t=e,{permission_id:n,decision:i}=t.detail;this.wsEventDispatcher.sendAgentActionPermission(n,i)}),this.container.addEventListener(\"new-conversation\",()=>{this.archiveSession()})}forceFocusOnInput(e){e.getRootNode().activeElement!==e&&(document.activeElement?.blur?.(),e.focus({preventScroll:!0}))}autoResizeTextarea(e){e.style.height=\"auto\";const t=e.scrollHeight;t<=40?(e.style.height=\"40px\",e.style.overflowY=\"hidden\"):t>=120?(e.style.height=\"120px\",e.style.overflowY=\"auto\"):(e.style.height=t+\"px\",e.style.overflowY=\"hidden\")}getMaxMessageSeq(){const e=this.messageHandler.getMessages().filter(e=>void 0!==e.seq&&e.seq>0).map(e=>e.seq);return 0===e.length?this.readReceiptManager.getLastSeenSeq():Math.max(...e)}setupVisibilityTracking(){this.disposables.safeOn(document,\"visibilitychange\",()=>{if(!this.chatStateManager)return;const e=!document.hidden;this.readReceiptManager.setVisibility(e),e&&this.chatStateManager.isOpened()&&this.messageHandler.getMessages().length>0&&this.readReceiptManager.scheduleReadTimer(),e&&this.sessionManager.checkIns.reconcile()},\"visibilitychange\")}isMobile(){return P()}computePushWidth(){const e=this.container.querySelector(\".support-chat-window\");return e?.classList.contains(\"expanded\")?d:h}setupResizeHandler(){this.resizeHandler=()=>{this.chatStateManager&&\"side-panel\"===this.config.displayMode&&this.chatStateManager.isOpened()&&(this.isMobile()?this.uiManager.unpushContent():this.uiManager.pushContent(this.computePushWidth()))},window.addEventListener(\"resize\",this.resizeHandler)}toggleChat(){this.chatStateManager.toggle(),this.readReceiptManager.setChatOpen(this.chatStateManager.isOpened()),this.chatStateManager.isOpened()?(this.bubbleAlternator.stop(),this.awarenessManager?.hideBubble(),this.goalNudgeActive=!1,this.goalNudgeBubble?.hide(),\"side-panel\"===this.config.displayMode&&this.uiManager.pushContent(this.computePushWidth()),this.readReceiptManager.updateUnreadIndicator(),this.readReceiptManager.hasUnreadMessages()&&(this.readReceiptManager.showNewMessagesDivider(),setTimeout(()=>{const e=this.container.querySelector(\".support-new-messages-divider\");e&&e.scrollIntoView({behavior:\"smooth\",block:\"start\"})},350),this.readReceiptManager.scheduleReadTimer())):(this.uiManager.restoreBubble(),this.voiceComposer?.cancelActive(),this.isAdminMode||this.bubbleAlternator.resume(),\"side-panel\"===this.config.displayMode&&this.uiManager.unpushContent(),this.readReceiptManager.hideNewMessagesDivider(),this.readReceiptManager.updateUnreadIndicator(),this.config.onClose?.())}tryShowNPS(){if(this.destroyed||this.isAdminMode||this.config.startHidden||this.introInProgress)return;const e=this.sessionManager.getPendingNPS();e&&(this.npsPrompt.isVisible()||this.sessionManager.getPendingActivationForm()||this.activationFormManager.isVisible()||this.featureCheckInManager.hasPending()||this.canShowActivationPrompt()&&this.npsPrompt.show(e.campaignId,()=>{this.sessionManager.clearPendingNPS(),this.tryShowActivationPrompts()}))}tryShowActivationPrompts(){this.tryShowFeatureCheckIn(),this.tryShowActivationForm()}tryShowFeatureCheckIn(){this.destroyed||this.isAdminMode||!this.activationFormReady||this.introInProgress||(this.featureCheckInManager.hasPending()?this.canShowActivationPrompt()&&(this.activationFormManager.hide(),this.featureCheckInManager.show()):this.featureCheckInManager.hide())}tryShowActivationForm(){if(this.destroyed||this.isAdminMode||!this.activationFormReady||this.introInProgress)return;const e=this.sessionManager.getPendingActivationForm();e&&0!==e.questions.length&&!this.featureCheckInManager.hasPending()?this.npsPrompt.isVisible()||this.canShowActivationPrompt()&&this.activationFormManager.update(e.questions,e.is_required):this.activationFormManager.hide()}canShowActivationPrompt(){return!!this.sessionManager.getSourceId()&&(!this.container.querySelector(\".support-agent-mode-overlay\")&&(!this.container.querySelector(\".support-prechat-form-container\")&&!this.messageHandler.hasUnresolvedCSAT()))}handleFeatureCheckIn(e){this.destroyed||this.isAdminMode||this.featureCheckInManager?.apply(e)}handleActivationForm(e){if(this.destroyed||this.isAdminMode)return;const t=this.sessionManager.getPendingActivationForm(),n=t?.questions.some(t=>!e.questions.some(e=>e.event_type_id===t.event_type_id));this.sessionManager.setPendingActivationForm(e.questions.length?e:null),this.tryShowActivationForm(),n&&(this.homeScreenManager.refresh(),this.refreshProgressChecklist()),0===e.questions.length&&this.tryShowNPS()}async openChat(){await this.initPromise,this.chatStateManager.isOpened()||this.toggleChat()}async closeChat(){await this.initPromise,this.chatStateManager.isOpened()&&this.toggleChat()}async openSession(e){await this.initPromise,this.jumpToActiveConversation(\"session\",e),await this.openChat()}async minimize(){await this.initPromise,this.uiManager.isInBadgeMode()||this.switchToBadgeMode()}async unminimize(){await this.initPromise,this.uiManager.isInBadgeMode()&&this.switchToBubbleMode()}isMinimized(){return this.uiManager?.isInBadgeMode()??!1}async toggleExpanded(){await this.initPromise;this.container.querySelector(\".support-chat-window\").classList.toggle(\"expanded\"),this.updateExpandUI(),\"side-panel\"===this.config.displayMode&&this.chatStateManager.isOpened()&&this.uiManager.pushContent(this.computePushWidth())}toggleSound(){const e=!this.config.enableSound;this.enableSound(e)}updateSoundUI(){const e=this.container.querySelector(\".support-sound-on\"),t=this.container.querySelector(\".support-sound-off\");this.config.enableSound?(e.classList.remove(\"hidden\"),t.classList.add(\"hidden\")):(e.classList.add(\"hidden\"),t.classList.remove(\"hidden\"))}updateExpandUI(){const e=this.container.querySelector(\".support-chat-window\"),t=this.container.querySelector(\".support-expand-icon\"),n=this.container.querySelector(\".support-collapse-icon\"),i=this.container.querySelector(\".support-expand-label\"),s=Na();e.classList.contains(\"expanded\")?(t.classList.add(\"hidden\"),n.classList.remove(\"hidden\"),i&&(i.textContent=s.menu.collapseWindow)):(t.classList.remove(\"hidden\"),n.classList.add(\"hidden\"),i&&(i.textContent=s.menu.expandWindow))}handleFileSelection(e){const t=Array.from(e.files||[]);this.handleFiles(t),e.value=\"\"}handleFiles(e){if(0===e.length)return;const t=[...this.selectedFiles,...e],n=QE(t);n.valid?(this.selectedFiles=t,this.uiManager.showAttachmentPreview(this.selectedFiles,e=>{this.removeFile(e)}),this.voiceComposer?.syncMicSlot()):this.uiManager.showToast(n.error||\"Invalid files\",\"error\")}handlePaste(e){const t=e.clipboardData;if(!t)return;const n=Array.from(t.files||[]);if(0===n.length&&t.items)for(const e of Array.from(t.items))if(\"file\"===e.kind){const t=e.getAsFile();t&&n.push(t)}0!==n.length&&(e.preventDefault(),this.handleFiles(n))}handleDragOver(e){e.preventDefault(),e.stopPropagation();const t=this.container.querySelector(\".support-input-container\");t&&t.classList.add(\"drag-over\")}handleDragLeave(e){e.preventDefault(),e.stopPropagation();const t=this.container.querySelector(\".support-input-container\");t&&t.classList.remove(\"drag-over\")}handleDrop(e){e.preventDefault(),e.stopPropagation();const t=this.container.querySelector(\".support-input-container\");t&&t.classList.remove(\"drag-over\");const n=Array.from(e.dataTransfer?.files||[]);this.handleFiles(n)}removeFile(e){this.selectedFiles.splice(e,1),0===this.selectedFiles.length?this.uiManager.hideAttachmentPreview():this.uiManager.showAttachmentPreview(this.selectedFiles,e=>{this.removeFile(e)}),this.voiceComposer?.syncMicSlot()}handleSendButtonClick(){this.shouldBlockInputWhileAIThinking()&&this.uiManager.isAIThinkingState()?this.wsEventDispatcher.cancelAgent(\"user_cancelled\"):this.shouldBlockInputWhileAIThinking()&&this.messageHandler.hasPendingMessages()&&this.hasContentToSend()?this.notifyMessagePending():this.sendMessage()}handleEnterKeyPress(){if(this.hasContentToSend())return this.shouldBlockInputWhileAIThinking()&&this.uiManager.isAIThinkingState()?(this.uiManager.showToast(Na().toasts.aiStillResponding,\"info\"),void this.uiManager.pulseSendButton()):void(this.shouldBlockInputWhileAIThinking()&&this.messageHandler.hasPendingMessages()?this.notifyMessagePending():this.sendMessage())}hasContentToSend(){const e=this.chatStateManager.getInputElement();return!!(e?.value.trim()??\"\")||this.selectedFiles.length>0}notifyMessagePending(){this.uiManager.showToast(Na().toasts.messagePending,\"info\"),this.uiManager.pulseSendButton()}startReply(e){if(this.chatStateManager.isTicketClosedState())return;this.replyTarget=e;const{author:t,preview:n}=Dc(e,Na());this.uiManager.showReplyPreview(t,n,()=>this.clearReplyTarget()),this.chatStateManager.getInputElement()?.focus()}clearReplyTarget(){this.replyTarget=null,this.uiManager.hideReplyPreview()}consumeReplyTarget(){const e=this.replyTarget;return e&&this.clearReplyTarget(),e}async createConversation(e){this.conversationCreationsInFlight++;try{return await async function(e,t){let n=null;for(let i=0;;i++)try{const s=await Ta(e,t);return null!==n&&Qi(\"api\",`first message delivered on attempt ${i+1} after ${Ma(n)}`),s}catch(e){const s=Sa[i];if(void 0===s||!Ea(e))throw _a(e,i+1,t),e;n=e,await Aa(s)}}(this.apiClient,e)}finally{this.conversationCreationsInFlight--}}async startConversation(e){const t=e.idempotency_key;let n;this.uiManager.showChatLoading();try{n=await this.createConversation(e)}catch(n){this.uiManager.hideChatLoading(),this.messageHandler.updateMessageStatus(t,\"failed\"),this.messageHandler.setRetryHandler(t,()=>{this.messageHandler.updateMessageStatus(t,\"sending\"),this.activeConversation?this.messageSender.sendFirstMessage(this.activeConversation.id,this.activeConversation.type,e):this.startConversation(e)});const i=Na().errors;return void this.messageHandler.addMessage({text:Ca(n)?i.firstMessageConnectionFailed:i.ticketCreationFailed,isAgent:!0})}this.messageHandler.updateMessageStatus(t,\"sent\"),this.openCreatedConversation(n)}openCreatedConversation(e){e.session_id?(this.sessionManager.setSessionId(e.session_id),this.activeConversation={type:\"session\",id:e.session_id},this.readReceiptManager.setConversationId(\"session\",e.session_id),this.uiManager.showArchiveButton(()=>this.archiveSession())):e.conversation_id&&(this.sessionManager.setTicketId(e.conversation_id),this.activeConversation={type:\"ticket\",id:e.conversation_id},this.readReceiptManager.setTicketId(e.conversation_id)),e.session_id&&e.conversation_id&&this.sessionManager.setTicketId(e.conversation_id),this.isNewTicket=!0,this.updateConversationSelector(),this.wsEventDispatcher.connect(this.activeConversation?.type),this.wsEventDispatcher.claimActiveTab(),this.messageSender.resumePendingMessages(),this.startAIAckTimer()}async sendMessage(){const e=this.chatStateManager.getInputElement();if(!e)return;const t=e.value.trim(),n=this.selectedFiles.length>0;if(!t&&!n)return;if(this.shouldBlockInputWhileAIThinking()&&this.uiManager.isAIThinkingState())return;this.stopTypingIndicator(),this.wsEventDispatcher.claimActiveTab(),this.chatStateManager.clearInput(),this.voiceComposer?.syncMicSlot();const i=\"ticket\"===this.activeConversation?.type?this.activeConversation.id:null,s=null!==this.activeConversation;if(this.chatStateManager.isTicketClosedState())return this.startNewConversation(),void setTimeout(()=>{const e=this.chatStateManager.getInputElement();e&&(e.value=t,this.sendMessage())},100);const r=this.consumeReplyTarget();if(n){if(!s){let e;this.uiManager.showChatLoading(),this.uiManager.showUploadingState(),this.uiManager.hideAttachmentPreview();try{e=await this.attachmentManager.uploadFiles(this.selectedFiles)}catch{return this.uiManager.hideChatLoading(),this.uiManager.hideUploadingState(),void this.messageHandler.addMessage({text:Na().errors.ticketCreationFailed,isAgent:!0})}this.selectedFiles=[],this.uiManager.hideUploadingState();const n={body:t||\"Attachment\",idempotency_key:cs(),metadata:this.metadataManager.getMetadata(),attachment_ids:e.map(e=>e.id),reply_to_message_id:r?.id};return this.messageHandler.addMessage({text:t,isAgent:!1,idempotencyKey:n.idempotency_key,isPending:!0,sendStatus:\"sending\",attachments:e,replyTo:r}),void await this.startConversation(n)}i?await this.uploadAndSendMessage(i,t,r):this.activeConversation&&await this.uploadAndSendSessionMessage(this.activeConversation.id,t,r)}else if(s){if(i){const e=this.wsEventDispatcher.declinePendingSystemAction(),n=this.metadataManager.getMetadata(),s=e?null:r,o=this.messageSender.sendMessage(i,\"ticket\",t,void 0,n,void 0,s?.id);this.messageHandler.addMessage({text:t,isAgent:!1,idempotencyKey:o,isPending:!0,sendStatus:\"sending\",replyTo:s})}else if(this.activeConversation){const e=this.activeConversation.id;this.wsEventDispatcher.declinePendingSystemAction();const n=this.metadataManager.getMetadata(),i=this.messageSender.sendMessage(e,\"session\",t,void 0,n,void 0,r?.id);this.messageHandler.addMessage({text:t,isAgent:!1,idempotencyKey:i,isPending:!0,sendStatus:\"sending\",replyTo:r}),this.startAIAckTimer()}}else{const e=cs();this.messageHandler.addMessage({text:t,isAgent:!1,idempotencyKey:e,isPending:!0,sendStatus:\"sending\",replyTo:r}),await this.startConversation({body:t,idempotency_key:e,metadata:this.metadataManager.getMetadata(),reply_to_message_id:r?.id})}}async uploadAndSendMessage(e,t,n){try{this.uiManager.showUploadingState(),this.uiManager.hideAttachmentPreview();const i=await this.attachmentManager.uploadFiles(this.selectedFiles),s=i.map(e=>e.id);this.selectedFiles=[];const r=this.messageSender.sendMessage(e,\"ticket\",t,s,void 0,void 0,n?.id);this.messageHandler.addMessage({text:t,isAgent:!1,idempotencyKey:r,isPending:!0,sendStatus:\"sending\",attachments:i,replyTo:n}),this.uiManager.hideUploadingState()}catch{this.uiManager.hideUploadingState(),this.uiManager.showToast(Na().toasts.uploadFailed,\"error\")}finally{this.voiceComposer?.syncMicSlot()}}voiceDraftKey(){const e=this.activeConversation;return e?`${e.type}:${e.id}`:null}restoreVoiceDraft(){const e=this.voiceDraftKey();null!==e&&this.voiceComposer&&sM.load(e).then(t=>{t&&this.voiceDraftKey()===e&&this.voiceComposer?.restoreDraft(t)})}async sendVoiceNote(e){const t=this.activeConversation;if(!t)throw new Error(\"Voice notes require an active conversation\");const n=await this.voiceAttachmentManager.uploadFiles([e.file]),i=n[0];if(!i)throw new Error(\"Voice note upload returned no attachment\");var s,r;s=i.id,r=e.file,Cc.set(s,r);const o={...this.metadataManager.getMetadata(),is_voice_note:!0,voice_note_duration:e.durationSeconds};this.wsEventDispatcher.claimActiveTab(),this.wsEventDispatcher.declinePendingSystemAction();const a=this.messageSender.sendMessage(t.id,t.type,\"\",[i.id],o,!0);this.messageHandler.addMessage({text:\"\",isAgent:!1,idempotencyKey:a,isPending:!0,sendStatus:\"sending\",attachments:n,metadata:{is_voice_note:!0,voice_note_duration:e.durationSeconds}}),this.startAIAckTimer()}async uploadAndSendSessionMessage(e,t,n){try{this.uiManager.showUploadingState(),this.uiManager.hideAttachmentPreview();const i=await this.attachmentManager.uploadFiles(this.selectedFiles),s=i.map(e=>e.id);this.selectedFiles=[];const r=this.messageSender.sendMessage(e,\"session\",t,s,void 0,void 0,n?.id);this.messageHandler.addMessage({text:t,isAgent:!1,idempotencyKey:r,isPending:!0,sendStatus:\"sending\",attachments:i,replyTo:n}),this.uiManager.hideUploadingState()}catch{this.uiManager.hideUploadingState(),this.uiManager.showToast(Na().toasts.uploadFailed,\"error\")}finally{this.voiceComposer?.syncMicSlot()}}async show(){this.hostHidden=!1,await this.initPromise,this.uiManager.show()}async hide(){this.hostHidden=!0,await this.initPromise,this.uiManager.hide(),this.chatStateManager.isOpened()||this.updateHiddenWidgetVisibility()}updateHiddenWidgetVisibility(){if(!this.uiManager.isWidgetHidden())return;const e=this.readReceiptManager.hasUnreadMessages()||this.chatStateManager.isOpened();e&&this.bubbleAlternator.stop(),this.uiManager.revealWhileHidden(e)}handleOnboardingBubbleCardClick(){this.bubbleAlternator.stop(),this.chatStateManager.isOpened()||this.toggleChat(),\"home\"!==this.viewRouter.getCurrentView()&&this.viewRouter.showView(\"home\")}async handleOnboardingStepStart(e){this.hideNextStepCta();const t=this.homeScreenManager.getOnboardingData();if(!t)return;const n=Na();this.viewRouter.showView(\"chat\"),this.uiManager.showChatLoading();const i={action:this.isAdminMode?n.adminMode.testingStepN(e.order+1):n.onboarding.stepN(e.order+1),title:e.title};this.uiManager.setEntityContext(i),this.isAdminMode&&(this.uiManager.setAdminStepActive(!0),this.adminModeStorage.setAdminStepUuid(e.uuid),this.uiManager.setAdminInputPlaceholder(n.adminMode.scopedPlaceholder(e.title)),this.adminModeStorage.setAdminEntity(i));try{const n=await this.apiClient.onboardingStartStep(e.uuid,this.homeScreenManager.isPreview());if(this.chatStateManager.open(),this.sessionManager.setSessionId(n.session_id),this.wsEventDispatcher.disconnect(),this.readReceiptManager.reset(),this.connectToSession(n.session_id),this.updateConversationSelector(),!this.isAdminMode){new Set(t.completed_step_uuids??[]).has(e.uuid)&&this.maybeShowNextStepCta(e.uuid)}}catch{this.uiManager.hideChatLoading(),this.uiManager.showToast(n.errors.apiRequestFailed,\"error\"),this.isAdminMode?this.handleAdminBackToHome():this.uiManager.setEntityContext(null)}}async handleOnboardingStepCompleted(e){sA(this.container),e.onboarding_completed&&(this.onboardingWasComplete=!0),this.homeScreenManager.refresh(),this.refreshProgressChecklist(),e.onboarding_completed?this.showCompleteOnboardingCta():await this.maybeShowNextStepCta(e.step_uuid)}handlePlanSaved(){if(!this.isAdminMode)return;(null!==this.adminModeStorage.getAdminStepUuid()||null!==this.activeReleaseUuid)&&(this.uiManager.showToast(Na().toasts.planSaved,\"success\"),this.pulseAdminPlanButton())}pulseAdminPlanButton(){const e=this.container.querySelector(\".support-admin-plan-btn\");if(!e)return;e.classList.remove(\"pulse\"),e.offsetWidth,e.classList.add(\"pulse\");const t=()=>{e.classList.remove(\"pulse\"),e.removeEventListener(\"animationend\",t)};e.addEventListener(\"animationend\",t)}async maybeShowNextStepCta(e){const t=await this.resolveNextOnboardingStep(e);if(!t)return void this.showCompleteOnboardingCta();const n=Na();this.chatStateManager.showNextStepButton(n.onboarding.goToNextStepButton,()=>{this.hideNextStepCta(),this.handleOnboardingStepStart(t)})}showCompleteOnboardingCta(){const e=Na();this.chatStateManager.showNextStepButton(e.onboarding.completeOnboardingButton,()=>{this.hideNextStepCta(),this.handleCompleteOnboarding()})}async handleCompleteOnboarding(){const e=this.sessionManager.getSessionId();if(e)try{await this.apiClient.archiveSession(e)}catch{}this.wsEventDispatcher.disconnect(),this.messageHandler.clearMessages(),this.readReceiptManager.reset(),this.chatStateManager.resetScrollFlag(),this.sessionManager.setSessionId(null),this.tabUnreadCounts.delete(\"session\"),this.activeConversation=null,this.navigateToHomeFromStep()}navigateToHomeFromStep(){this.sessionOriginTab=\"home\",this.uiManager.setEntityContext(null),this.tabBarManager?.setActiveTab(\"home\"),this.viewRouter?.showView(\"home\")}hideNextStepCta(){this.chatStateManager?.isNextStepButtonVisible()&&(this.chatStateManager.restoreInputState(),this.reattachInputListeners())}async resolveNextOnboardingStep(e){let t=this.homeScreenManager.getOnboardingData();if(!t&&(await this.homeScreenManager.refresh(),t=this.homeScreenManager.getOnboardingData(),!t))return null;const n=new Set(t.completed_step_uuids??[]);return n.add(e),[...t.steps].sort((e,t)=>e.order-t.order).find(e=>!n.has(e.uuid))??null}handleAdminBackToHome(){this.hideNextStepCta();const e=Na(),t=this.sessionOriginTab;this.sessionOriginTab=\"home\",this.activeReleaseUuid=null,this.adminModeStorage.clearAdminSessionId(),this.adminModeStorage.clearAdminStepUuid(),this.adminModeStorage.clearAdminEntity(),this.adminModeStorage.clearAdminReleaseUuid(),this.planPanelManager.hide(),this.wsEventDispatcher.disconnect(),this.messageHandler.clearMessages(),this.readReceiptManager.reset(),this.sessionManager.setSessionId(null),this.sessionManager.setTicketId(null),this.activeConversation=null,this.uiManager.hideChatLoading(),this.uiManager.setAdminStepActive(!1),this.uiManager.setEntityContext(null),this.uiManager.setAdminInputPlaceholder(e.adminMode.placeholder),this.tabBarManager?.setActiveTab(t),this.viewRouter.showView(t),\"home\"===t&&this.refreshHomeShortcuts()}async resolveReleaseEntity(e,t){const n=Na();try{const i=(await this.apiClient.getAdminReleases()).results.find(t=>t.uuid===e);if(!i)return this.uiManager.setEntityContext(null),void this.uiManager.setAdminInputPlaceholder(n.adminMode.placeholder);const s={action:\"test\"===t?n.adminMode.testingRelease:n.adminMode.configuringRelease,title:i.title};this.uiManager.setEntityContext(s),this.uiManager.setAdminInputPlaceholder(n.adminMode.scopedPlaceholder(i.title)),this.adminModeStorage.setAdminEntity(s)}catch{this.uiManager.setEntityContext(null),this.uiManager.setAdminInputPlaceholder(n.adminMode.placeholder)}}setReleaseChatContext(e){const t=Na();this.activeReleaseUuid=e.uuid,this.uiManager.setEntityContext({action:t.releases.releaseLabel,title:e.title})}clearReleaseChatContext(){null!==this.activeReleaseUuid&&(this.activeReleaseUuid=null,this.uiManager.setEntityContext(null))}handleShowPlan(){if(this.planPanelManager.isVisible())return void this.planPanelManager.hide();if(this.activeReleaseUuid)return void this.planPanelManager.showReleasePlan(this.activeReleaseUuid);const e=this.adminModeStorage.getAdminStepUuid();e&&this.planPanelManager.show(e)}handleAdminSessionRestoreFailure(){this.isRestoringAdminSession&&(this.isRestoringAdminSession=!1,this.adminModeStorage.clearAdminSessionId(),this.handleAdminBackToHome())}handleAdminAuthExpired(){this.uiManager?.showToast(Na().adminMode.sessionExpired,\"error\")}leaveAdminMode(){if(!this.isAdminMode)return;const e=this.container.querySelector(\".support-admin-leave-btn\");if(e){e.classList.add(\"loading\"),e.disabled=!0;const t=e.querySelector(\".support-admin-leave-icon\"),n=e.querySelector(\".support-admin-leave-spinner\");t?.classList.add(\"hidden\"),n?.classList.remove(\"hidden\")}this.adminModeStorage.clearAll();const t=new URL(window.location.href);t.searchParams.delete(\"blar_admin_mode\"),window.history.replaceState({},\"\",t.toString()),window.location.reload()}async handleOnboardingStepConfigure(e){const t=Na();this.viewRouter.showView(\"chat\"),this.uiManager.showChatLoading(),this.uiManager.setAdminStepActive(!0),this.adminModeStorage.setAdminStepUuid(e.uuid);const n={action:t.adminMode.configuringStepN(e.order+1),title:e.title};this.uiManager.setEntityContext(n),this.uiManager.setAdminInputPlaceholder(t.adminMode.scopedPlaceholder(e.title)),this.adminModeStorage.setAdminEntity(n);try{const t=e.live_feedback_session_id??(await this.apiClient.startLiveFeedbackSession({stepUuid:e.uuid})).session_id;this.chatStateManager.open(),this.sessionManager.setSessionId(t),this.sessionManager.setTicketId(null),this.wsEventDispatcher.disconnect(),this.readReceiptManager.reset(),this.messageHandler.clearMessages(),this.connectToSession(t)}catch{this.uiManager.hideChatLoading(),this.uiManager.showToast(t.errors.apiRequestFailed,\"error\"),this.handleAdminBackToHome()}}handleTourStart(e,t){this.closeChat();const n=\"es\"===this.config.language?\"es\":\"en\",i=e.tour_name;this.tourManager.startTour(i,e,n,()=>{t(),this.openChat()})}async loadAndRunTour(e,t=0){try{const n=await this.apiClient.getTour(e),i=\"es\"===this.config.language?\"es\":\"en\";await this.waitForDOMReady();const s=Math.max(0,Math.min(t,n.steps.length-1));this.tourManager.startTour(e,n,i,void 0,s)}catch(e){Ji(\"Failed to load tour\",e),zE();const t=Na();this.openChat(),this.messageHandler.addMessage({text:t.tour.loadError,isAgent:!0})}}waitForDOMReady(){return new Promise(e=>{\"complete\"===document.readyState?requestAnimationFrame(()=>e()):window.addEventListener(\"load\",()=>{requestAnimationFrame(()=>e())})})}shouldBlockInputWhileAIThinking(){return\"ticket\"!==this.activeConversation?.type}startAIAckTimer(){\"session\"===this.activeConversation?.type&&(this.clearAIAckTimer(),this.messageHandler.showThinkingBubble(),this.uiManager.showAIThinkingState(),this.aiAckTimeout=window.setTimeout(es(\"ai-ack-timeout\",()=>this.handleAIAckTimeout()),3e4))}clearAIAckTimer(){null!==this.aiAckTimeout&&(window.clearTimeout(this.aiAckTimeout),this.aiAckTimeout=null)}handleAIAckTimeout(){this.aiAckTimeout=null,this.messageHandler.finalizeStreamingMessage(),this.uiManager.hideAIThinkingState(),this.uiManager.showToast(Na().errors.aiNoResponse,\"error\")}handleTypingInput(e){const t=s();e?(this.typingTimeout&&(clearTimeout(this.typingTimeout),this.typingTimeout=null),!this.isTyping&&t-this.lastTypingSent>=this.TYPING_THROTTLE_MS&&(this.wsEventDispatcher.sendTypingStart(),this.isTyping=!0,this.lastTypingSent=t),this.typingTimeout=setTimeout(es(\"typing-timeout\",()=>{this.stopTypingIndicator()}),this.TYPING_TIMEOUT_MS)):this.stopTypingIndicator()}stopTypingIndicator(){this.isTyping&&(this.wsEventDispatcher.sendTypingStop(),this.isTyping=!1),this.typingTimeout&&(clearTimeout(this.typingTimeout),this.typingTimeout=null)}connectToSession(e,t){this.isAdminMode&&this.adminModeStorage.setAdminSessionId(e),this.activeConversation={type:\"session\",id:e},this.conversationContext.setActive(\"session\",e),this.readReceiptManager.setConversationId(\"session\",e),this.wsEventDispatcher.connect(\"session\",e,t),this.uiManager.showArchiveButton(()=>this.archiveSession()),this.refreshHomeShortcuts()}async archiveSession(){if(!this.isArchiving){this.isArchiving=!0;try{const e=Na(),t=this.sessionManager.getSessionId();if(t)try{await this.apiClient.archiveSession(t)}catch{}\"session\"===this.backgroundNotifier?.getConversationType()&&this.dropBackgroundNotifier(),\"session\"===this.activeConversation?.type&&(this.wsEventDispatcher.disconnect(),this.messageHandler.clearMessages(),this.readReceiptManager.reset(),this.chatStateManager.resetScrollFlag()),this.uiManager.hideWaitingBadge(),this.uiManager.hideAgentBanner(),this.chatStateManager.restoreInputState(),this.reattachInputListeners(),this.uiManager.hideBackToPickerButton(),this.uiManager.setEntityContext(null),this.sessionManager.setSessionId(null),this.tabUnreadCounts.delete(\"session\");const n=this.sessionManager.getTicketId();try{const e=await this.apiClient.createSession({forceAgentMode:this.config.testAgentMode});this.sessionManager.setSessionId(e.session_id),n?(this.wsEventDispatcher.disconnect(),this.messageHandler.clearMessages(),this.readReceiptManager.reset(),this.chatStateManager.resetScrollFlag(),this.connectToSession(e.session_id),this.startBackgroundNotifier(\"ticket\",n)):this.connectToSession(e.session_id),this.viewRouter.showView(\"chat\"),this.updateConversationSelector()}catch(t){t instanceof Pi&&\"ai_disabled\"===t.code?(this.sessionManager.setAiActive(!1),this.uiManager.setAiActive(!1),this.uiManager.showToast(e.errors.aiDisabled,\"error\")):this.uiManager.showToast(e.session.archiveFailed,\"error\")}}finally{this.isArchiving=!1}}}initTabNavigation(){const e=this.container.querySelector(\".support-chat-window\"),t=this.container.querySelector('.support-view[data-view=\"messages\"]'),n=this.container.querySelector('.support-view[data-view=\"releases\"]');this.ticketDetailSheet=new ZM(e),this.ticketDetailSheet.setOnOpenConversation(e=>{this.ticketDetailSheet.close(),this.openConversationFromTab({id:e,type:\"ticket\",status:\"\"})}),this.messagesViewManager=new QM(t,this.apiClient,e=>this.openConversationFromTab(e)),this.messagesViewManager.init(),this.releasesScreenManager=new eA(n,this.apiClient,this.isAdminMode),this.releasesScreenManager.setOnUnreadChange(e=>{this.tabBarManager?.setUnreadBadge(\"releases\",e),this.readReceiptManager?.setExternalUnreadCount(\"releases\",e)}),this.releasesScreenManager.setOnCtaClick(e=>{this.handleReleaseCta(e)}),this.releasesScreenManager.setOnConfigureClick(e=>{this.handleReleaseConfigure(e)}),this.releasesScreenManager.setOnTestClick(e=>{this.handleReleaseTest(e)}),this.viewRouter=new XM(e,{home:()=>{this.homeScreenManager.show(),this.refreshProgressChecklist(),this.refreshHomeShortcuts(),this.refreshUnreadBadges()},messages:()=>{this.messagesViewManager.ensureLoaded()},releases:()=>{this.releasesScreenManager.ensureLoaded()},chat:()=>{setTimeout(()=>this.refreshUnreadBadges(),100),this.updateConversationSelector()}});const i=this.isAdminMode?[\"home\",\"releases\"]:[\"home\",\"messages\",\"releases\"];this.tabBarManager=new YM(this.container,e=>{this.tabBarManager.setActiveTab(e),\"messages\"!==e?this.viewRouter.showView(e):this.handleMessagesTabClick()},i),this.tabBarManager.init(),this.releasesScreenManager.ensureLoaded()}handleMessagesTabClick(){const e=this.sessionManager.getTicketId();if(e)return void this.jumpToActiveConversation(\"ticket\",e);const t=this.sessionManager.getSessionId();t?this.jumpToActiveConversation(\"session\",t):(this.startNewConversation(),this.viewRouter.showView(\"chat\"))}refreshHomeShortcuts(){if(!this.homeScreenManager)return;const e=[],t=this.sessionManager.getSessionId(),n=this.sessionManager.getTicketId();t&&e.push({type:\"session\",id:t,unread:this.getUnreadForType(\"session\")>0}),n&&e.push({type:\"ticket\",id:n,unread:this.getUnreadForType(\"ticket\")>0}),this.homeScreenManager.setActiveConversationShortcuts(e),this.homeScreenManager.setEngineeringTickets(this.sessionManager.getEngineeringTickets()),this.homeScreenManager.setLastTicket(this.sessionManager.getLastTicket())}getUnreadForType(e){const t=this.activeConversation?.type===e,n=\"chat\"===this.viewRouter?.getCurrentView();return t?n?0:this.readReceiptManager?.getUnreadCount?.()??0:this.tabUnreadCounts.get(e)||0}refreshUnreadBadges(){if(!this.tabBarManager||!this.homeScreenManager)return;const e=this.getUnreadForType(\"session\"),t=this.getUnreadForType(\"ticket\");this.tabBarManager.setUnreadBadge(\"messages\",e+t),this.messagesViewManager?.setUnreadBadge(\"session\",e),this.messagesViewManager?.setUnreadBadge(\"ticket\",t),this.refreshHomeShortcuts()}async handleReleaseCta(e){try{this.sessionOriginTab=\"releases\",this.setReleaseChatContext(e);const t=await this.apiClient.clickRelease(e.uuid);this.wsEventDispatcher.disconnect(),this.messageHandler.clearMessages(),this.readReceiptManager.reset(),this.chatStateManager.resetScrollFlag(),this.sessionManager.setSessionId(t.session_id),this.connectToSession(t.session_id),this.tabBarManager.setActiveTab(\"messages\"),this.viewRouter.showView(\"chat\")}catch{this.clearReleaseChatContext(),this.uiManager.showToast(Na().errors.apiRequestFailed,\"error\")}}async handleReleaseTest(e){const t=Na();this.sessionOriginTab=\"releases\",this.activeReleaseUuid=e.uuid,this.adminModeStorage.setAdminReleaseUuid(e.uuid),this.viewRouter.showView(\"chat\"),this.uiManager.showChatLoading(),this.uiManager.setAdminStepActive(!0);const n={action:t.adminMode.testingRelease,title:e.title};this.uiManager.setEntityContext(n),this.uiManager.setAdminInputPlaceholder(t.adminMode.scopedPlaceholder(e.title)),this.adminModeStorage.setAdminEntity(n);try{const t=await this.apiClient.clickRelease(e.uuid);this.wsEventDispatcher.disconnect(),this.messageHandler.clearMessages(),this.readReceiptManager.reset(),this.chatStateManager.resetScrollFlag(),this.chatStateManager.open(),this.sessionManager.setSessionId(t.session_id),this.sessionManager.setTicketId(null),this.connectToSession(t.session_id)}catch{this.uiManager.hideChatLoading(),this.uiManager.showToast(t.errors.apiRequestFailed,\"error\"),this.handleAdminBackToHome()}}async handleReleaseConfigure(e){const t=Na();this.sessionOriginTab=\"releases\",this.activeReleaseUuid=e.uuid,this.adminModeStorage.setAdminReleaseUuid(e.uuid),this.viewRouter.showView(\"chat\"),this.uiManager.showChatLoading(),this.uiManager.setAdminStepActive(!0);const n={action:t.adminMode.configuringRelease,title:e.title};this.uiManager.setEntityContext(n),this.uiManager.setAdminInputPlaceholder(t.adminMode.scopedPlaceholder(e.title)),this.adminModeStorage.setAdminEntity(n);try{const t=await this.apiClient.startLiveFeedbackSession({releaseUuid:e.uuid});this.chatStateManager.open(),this.sessionManager.setSessionId(t.session_id),this.sessionManager.setTicketId(null),this.wsEventDispatcher.disconnect(),this.readReceiptManager.reset(),this.messageHandler.clearMessages(),this.connectToSession(t.session_id)}catch{this.uiManager.hideChatLoading(),this.uiManager.showToast(t.errors.apiRequestFailed,\"error\"),this.handleAdminBackToHome()}}jumpToActiveConversation(e,t){this.activeConversation?.type===e&&this.activeConversation.id===t?this.viewRouter.showView(\"chat\"):this.openConversationFromTab({id:t,type:e,status:\"\"})}openConversationFromTab(e,t={}){const n=this.activeConversation,i=this.backgroundNotifier?.getConversationType()===e.type&&this.backgroundNotifier.getConversationId()===e.id;this.clearReplyTarget(),this.clearReleaseChatContext(),this.wsEventDispatcher.disconnect(),this.messageHandler.clearMessages(),this.readReceiptManager.reset(),this.chatStateManager.resetScrollFlag(),this.conversationContext.setActive(e.type,e.id),this.conversationContext.setStatus(e.status),this.conversationContext.markSupportHandoff(e.wasEscalated),!1!==t.reveal&&this.viewRouter.showView(\"chat\"),\"ticket\"===e.type?(this.activeConversation={type:\"ticket\",id:e.id},this.readReceiptManager.setTicketId(e.id),this.wsEventDispatcher.connect(\"ticket\",e.id)):(this.sessionManager.setSessionId(e.id),this.activeConversation={type:\"session\",id:e.id},this.readReceiptManager.setConversationId(\"session\",e.id),this.wsEventDispatcher.connect(\"session\")),i&&(this.tabUnreadCounts.set(e.type,0),n?this.startBackgroundNotifier(n.type,n.id):this.dropBackgroundNotifier()),this.updateConversationSelector(),this.updateAgentBanner()}async handleSessionEscalated(e,t=null){if((\"ticket\"!==this.activeConversation?.type||this.activeConversation.id!==e)&&!this.isHandlingEscalation){this.isHandlingEscalation=!0,this.clearAIAckTimer();try{this.wsEventDispatcher.isAgentModeEngaged()&&this.wsEventDispatcher.cancelAgent(\"escalated\"),this.clearReleaseChatContext(),this.sessionManager.setTicketId(e),this.sessionManager.setSessionId(null),this.dropBackgroundNotifier(),this.wsEventDispatcher.disconnect(),this.readReceiptManager.reset(),this.chatStateManager.resetScrollFlag(),this.chatStateManager.restoreInputState(),this.reattachInputListeners(),this.activeConversation={type:\"ticket\",id:e},this.conversationContext.setActive(\"ticket\",e),this.conversationContext.markSupportHandoff(!0),this.conversationContext.setAiAssigned(!1),this.readReceiptManager.setTicketId(e),this.wsEventDispatcher.connect(\"ticket\",void 0,{preserveMessages:!0}),this.uiManager.hideArchiveButton(),this.uiManager.hideBackToPickerButton(),this.uiManager.hideConversationSelector();const n=Na(),i=this.sessionManager.getExecutive();this.uiManager.showToast(i?n.session.escalatedToExecutive(i.name):n.session.escalated,\"info\"),this.uiManager.showWaitingBadge(),this.updateAgentBanner(),this.executiveAvailabilityNotice.apply(t),this.refreshHomeShortcuts()}finally{this.isHandlingEscalation=!1}}}updateAgentBanner(){this.agentRunInOtherTab?this.uiManager.showOtherTabAgentBanner(this.sessionManager.getAgentName(),()=>this.wsEventDispatcher.takeOverAgentHere(),()=>this.wsEventDispatcher.stopAgentElsewhere()):\"hidden\"===this.conversationContext.getBannerVariant()?this.uiManager.hideAgentBanner():this.uiManager.showAgentBanner()}applyAgentIdentity(){const e=this.sessionManager.getAgent()?.avatar_url||this.aiConfigIconUrl;this.messageHandler?.setAiIconUrl(e),this.messageHandler?.setAgentName(this.sessionManager.getAgentName()),this.homeScreenManager?.setAiIconUrl(e)}handleConversationStatusChange(e,t=!1){this.conversationContext.setStatus(e),this.conversationContext.markSupportHandoff(t),this.updateAgentBanner(),\"resolved\"!==e&&\"closed\"!==e||(this.tourManager.stopActiveTour(),this.chatStateManager.showClosedState(),this.executiveAvailabilityNotice.dismiss())}async handleSessionStatus(e,t={hasSupportHandoff:!1}){if(this.conversationContext.markSupportHandoff(t.hasSupportHandoff),this.conversationContext.setStatus(e),this.updateAgentBanner(),this.handleConversationStatusChange(e),\"escalated\"===e&&\"ticket\"!==this.activeConversation?.type){if(this.awarenessSessionSticky)return;try{const e=await this.sessionManager.loadAnonymousSession();e.ticketId&&this.handleSessionEscalated(e.ticketId)}catch(e){Ji(\"Failed to load session after escalation status\",e)}}}updateConversationSelector(){const e=this.sessionManager.getSessionId(),t=this.sessionManager.getTicketId();if(e&&t){const e=this.activeConversation?.type||\"session\",t={session:this.tabUnreadCounts.get(\"session\")||0,ticket:this.tabUnreadCounts.get(\"ticket\")||0};this.uiManager.showConversationSelector(e,e=>this.switchConversationTab(e),t)}else this.uiManager.hideConversationSelector()}startBackgroundNotifier(e,t){this.dropBackgroundNotifier();const n=this.sessionManager.getSourceId()||\"\";this.backgroundNotifier=new HE({apiBaseUrl:this.config.apiBaseUrl,publishableKey:this.config.publishableKey},n,{onUnreadChange:(e,t)=>this.handleBackgroundUnreadChange(e,t),onNewMessageSound:()=>this.playNotificationSound(),onSessionEscalated:(e,t)=>this.handleSessionEscalated(e,t),onActivationForm:e=>this.handleActivationForm(e),onFeatureCheckIn:e=>this.sessionManager.checkIns.applyChatFrame(e),onFeatureCheckInReminder:()=>this.sessionManager.checkIns.reconcile()},()=>this.sessionManager.getIdentityProof()),this.backgroundNotifier.connect(e,t)}dropBackgroundNotifier(){this.backgroundNotifier?.disconnect(),this.backgroundNotifier=null,this.readReceiptManager?.setExternalUnreadCount(\"background\",0)}handleBackgroundUnreadChange(e,t){this.tabUnreadCounts.set(e,t),this.readReceiptManager?.setExternalUnreadCount(\"background\",t),this.uiManager.updateTabBadge(e,t),this.refreshUnreadBadges()}switchConversationTab(e){if(this.activeConversation?.type===e)return;this.awarenessSessionSticky=!1;const t=this.activeConversation,n=\"session\"===e?this.sessionManager.getSessionId():this.sessionManager.getTicketId();n&&(t&&(this.backgroundNotifier?.disconnect(),this.startBackgroundNotifier(t.type,t.id)),this.wsEventDispatcher.disconnect(),this.messageHandler.clearMessages(),this.readReceiptManager.reset(),this.chatStateManager.resetScrollFlag(),this.uiManager.hideWaitingBadge(),this.chatStateManager.restoreInputState(),this.reattachInputListeners(),this.activeConversation={type:e,id:n},this.conversationContext.setActive(e,n),\"session\"===e?(this.readReceiptManager.setConversationId(\"session\",n),this.wsEventDispatcher.connect(\"session\"),this.uiManager.showArchiveButton(()=>this.archiveSession())):(this.readReceiptManager.setTicketId(n),this.wsEventDispatcher.connect(\"ticket\"),this.uiManager.hideArchiveButton()),this.tabUnreadCounts.set(e,0),this.updateConversationSelector(),this.updateAgentBanner())}getSelfUpdateHandoff(){return this.destroyed||!this.initSettled||this.isAdminMode||this.onboardingStepToConfigure||this.onboardingStepToTest||this.identityChanges>0||this.sessionManager?.isRestoring()||this.chatStateManager?.isOpened()||this.wsEventDispatcher?.isAgentEngaged()||null!=this.voiceCallManager?.getActiveCallId()||this.screenShareManager?.isSharing()?null:{config:{...this.hostConfig,theme:void 0,position:this.config.position,primaryColor:this.config.primaryColor,secondaryColor:this.config.secondaryColor,colorScheme:this.config.colorScheme,language:this.config.language,unreadAnimation:this.config.unreadAnimation,autoOpen:!1,startHidden:this.hostHidden,nudgeAnchor:this.nudgeAnchor,identity:this.proofIdentity??void 0},identity:this.hostIdentity,showBranding:this.config.showBranding}}applySelfUpdateHandoff(e){e.showBranding||this.setBranding(!1),e.identity&&this.setUser(e.identity).catch(e=>Ji(\"self-update: identify failed\",e))}destroy(){this.destroyed||(this.destroyed=!0,this.stopSelfUpdate(),this.disposables.dispose(),this.typingTimeout&&(clearTimeout(this.typingTimeout),this.typingTimeout=null),this.clearAIAckTimer(),this.authHeaderObserver?.uninstall(),this.networkTracker?.uninstall(),this.backgroundNotifier?.disconnect(),this.readReceiptManager?.cleanup(),this.voiceComposer?.destroy(),this.wsEventDispatcher?.destroy(),this.tourManager?.cleanup(),this.progressChecklist?.clear(),this.bubbleAlternator?.destroy(),this.homeScreenManager?.destroy(),this.activationFormObserver?.disconnect(),this.activationFormManager?.destroy(),this.featureCheckInManager?.destroy(),null!==this.activationFormReadyTimer&&clearTimeout(this.activationFormReadyTimer),this.releasesScreenManager?.destroy(),this.tabBarManager?.destroy(),this.introPresentation?.destroy(),this.awarenessManager?.cleanup(),this.presenceManager?.stop(),this.contactLive?.stop(),this.sessionManager?.checkIns.destroy(),null!==Ad&&(clearInterval(Ad),Ad=null,_d?.disconnect(),_d=null,Td=[],document.removeEventListener(\"visibilitychange\",$d),Ld=0,Rd=null),this.goalNudgeBubble?.hide(),this.voiceCallManager?.destroy(),this.screenShareManager?.destroy(),\"side-panel\"===this.config.displayMode&&this.uiManager?.unpushContent(),this.resizeHandler&&(window.removeEventListener(\"resize\",this.resizeHandler),this.resizeHandler=null),this.uiManager?.destroy(),dA(null))}sendCustomMessage(e,t=!0){this.messageHandler.addMessage({text:e,isAgent:t})}simulateIncomingMessage(e=\"Simulated agent reply\"){const t=this.readReceiptManager.getLastSeenSeq()+1;this.messageHandler.addMessage({text:e,isAgent:!0,role:\"agent\",seq:t}),this.readReceiptManager.setLastSeenSeq(t),this.readReceiptManager.updateUnreadIndicator()}simulateGoalNudge(e={}){this.surfaceSessionBubble({bubbleMessage:\"Benja, vi que casi terminas 👀 Te falta 1 paso para activar tu agenda y empezar a recibir citas.\",sender:{name:\"Arianna Soto\",subtitle:\"Equipo de activación\"},progress:{total:5,completed:4},ctaLabel:\"Activar mi agenda · 30 seg\",...e})}getMessages(){return this.messageHandler.getMessages()}setPosition(e){this.config.position=e,this.uiManager.setPosition(e)}applyColorScheme(){this.container?.classList.toggle(\"support-color-dark\",\"dark\"===this.config.colorScheme)}setColorScheme(e){this.config.colorScheme=e,this.applyColorScheme()}getColorScheme(){return this.config.colorScheme}setColor(e){this.config.primaryColor=e;const t=A(e);this.config.secondaryColor=t,bs.setColors(e,t),this.uiManager?.setColor(e),this.uiManager?.setSecondaryColor(t)}setTheme(e){const t=_[e];this.setColor(t)}getColor(){return this.config.primaryColor}setSecondaryColor(e){this.config.secondaryColor=e,bs.setColors(this.config.primaryColor,e),this.uiManager?.setSecondaryColor(e)}getSecondaryColor(){return this.config.secondaryColor}setBranding(e){this.config.showBranding=e,this.uiManager?.setBranding(e)}isBrandingVisible(){return this.uiManager.isBrandingVisible()}async setLanguage(e){await this.initPromise,this.config.language=e,Ra(e),ds.set(\"support_widget_language\",e);const t=Na();this.uiManager.updateLanguage(t),this.messageHandler.updateLanguage(t),this.progressChecklist.rerender(),this.bubbleAlternator.rerender()}getLanguage(){return $a()}async setUser(e,t,n,i,s,r,o,a){const l=\"string\"==typeof e?{externalId:e,email:t,name:n,phone:i,contactCompany:s,contactCompanyExternalId:r,identitySignature:o,customFields:a}:e;return this.whileChangingIdentity(()=>this.identify(l))}async identify(e){if(this.hostIdentity=e,this.proofIdentity=e,this.isAdminMode||this.sessionManager.getUser()||this.apiClient.setIdentity(e),await this.initPromise,this.isAdminMode)return;const t=this.sessionManager.getUser();if(!(!t||t.externalId!==e.externalId))return;t&&(await this.clearUser(),this.hostIdentity=e,this.proofIdentity=e),this.dropBackgroundNotifier(),this.tabUnreadCounts.clear();const n=this.activeConversation?.type;this.wsEventDispatcher.disconnect();try{await this.sessionManager.setUser(e)}catch(e){if(this.contactLive?.sync(),n&&this.wsEventDispatcher.connect(n),Fi(e))return this.hostIdentity=null,this.proofIdentity=null,void this.uiManager.showToast(Na().errors.identityVerificationFailed,\"error\");throw e}this.uiManager.setAiActive(this.sessionManager.getAiActive()),this.refreshProgressChecklist(),this.startIntroPresentation();const i=this.sessionManager.getTicketId(),s=this.sessionManager.getSessionId();if(i||s){this.wsEventDispatcher.disconnect(),this.messageHandler.clearMessages(),this.readReceiptManager.reset(),this.chatStateManager.resetScrollFlag(),this.uiManager.hideWaitingBadge(),this.uiManager.hideArchiveButton(),this.chatStateManager.restoreInputState(),this.reattachInputListeners();\"1\"===sessionStorage.getItem(\"support_widget_agent_active\")&&s?(this.connectToSession(s),i&&this.startBackgroundNotifier(\"ticket\",i)):s&&i&&!this.sessionManager.getAiActive()?(this.activeConversation={type:\"ticket\",id:i},this.readReceiptManager.setTicketId(i),this.wsEventDispatcher.connect(\"ticket\"),this.startBackgroundNotifier(\"session\",s)):s?this.connectToSession(s):i&&(this.activeConversation={type:\"ticket\",id:i},this.readReceiptManager.setTicketId(i),this.wsEventDispatcher.connect(\"ticket\")),this.updateConversationSelector()}else this.startNewConversation();this.contactLive?.pickUp(this.sessionManager.getTicketId(),{announce:!1}),this.contactLive?.sync(),setTimeout(()=>this.tryShowNPS(),1500),this.tryShowActivationPrompts()}async handlePendingNudge(){if(!(this.introInProgress||this.goalNudgeActive||this.pendingNudgeInFlight||this.chatStateManager?.isOpened()||\"ticket\"===this.activeConversation?.type)){this.pendingNudgeInFlight=!0;try{const{sessionId:e}=await this.sessionManager.loadAnonymousSession();if(this.introInProgress)return;if(void 0===e)return;if(this.wsEventDispatcher.isLiveConversation(\"session\",e))return;this.connectToSession(e)}catch{}finally{this.pendingNudgeInFlight=!1}}}async handleIntroCompletionRecorded(e){if(this.apiClient.getSourceId()===e)try{const{sessionId:t}=await this.sessionManager.loadAnonymousSession();if(this.destroyed||this.apiClient.getSourceId()!==e||void 0===t)return;if(this.wsEventDispatcher.isLiveConversation(\"session\",t))return;if(!this.chatStateManager.isOpened()||\"chat\"!==this.viewRouter.getCurrentView())return void this.connectToSession(t);this.openNudgeSession(t)}catch(e){Ji(\"Failed to connect to intro completion session\",e)}}startIntroPresentation(){this.introStarted||(this.sessionManager.getShouldPlayIntro()&&\"1\"!==sessionStorage.getItem(\"support_widget_agent_active\")&&!this.container.querySelector(\".support-agent-mode-overlay\")?(this.introInProgress=!0,this.introStarted=!0,this.introPresentationSourceId=this.apiClient.getSourceId(),this.awarenessManager?.hideBubble(),this.goalNudgeBubble?.hide(),this.goalNudgeActive=!1,this.introPresentation.play(this.sessionManager.getIntroMode(),this.sessionManager.getIntroAgentName(),this.sessionManager.getIntroAgentAvatarUrl(),this.sessionManager.getExecutive()).catch(()=>{this.introPresentationSourceId=null,this.introStarted=!1,this.introInProgress=!1,this.tryShowActivationPrompts(),this.tryShowNPS()})):this.introInProgress=!1)}signalIntroCompletion(){const e=this.introPresentationSourceId;this.introPresentationSourceId=null,e&&e===this.apiClient.getSourceId()&&(this.presenceManager?this.presenceManager.completeIntroPresentation():this.pendingIntroCompletionSourceId=e)}surfaceSessionBubble(e){if(!e.bubbleMessage)return;if(this.introInProgress)return;if(this.chatStateManager.isOpened())return;if(!e.decisionCard&&null!==this.decisionCardBubbleKey&&this.goalNudgeBubble?.isVisible())return;this.goalNudgeActive=!0,this.awarenessManager?.hideBubble(),this.goalNudgeBubble||(this.goalNudgeBubble=new oM(this.container,{isChatOpen:()=>this.chatStateManager.isOpened(),getAnchor:()=>this.nudgeAnchor,isWidgetHidden:()=>this.isCornerWidgetHidden()}));const t={message:e.bubbleMessage,dismissLabel:Na().awareness.dismiss,sender:e.sender,progress:e.progress,ctaLabel:e.ctaLabel??Na().awareness.cta},n=e.decisionCard;if(this.decisionCardBubbleKey=n&&void 0===e.milestoneMessageId?n.idempotencyKey:null,n&&void 0===e.milestoneMessageId)return void this.goalNudgeBubble.show({message:e.bubbleMessage,dismissLabel:Na().awareness.dismiss,sender:e.sender??{name:this.sessionManager.getIntroAgentName()??T,avatarUrl:this.sessionManager.getIntroAgentAvatarUrl()??void 0},confirm:{acceptLabel:n.accept.label,declineLabel:n.decline.label,onAccept:()=>{this.markBubbleRead(e),this.answerBubbleCard(n,n.accept.value),this.goalNudgeBubble?.hide(),void 0!==e.sessionId&&this.openGoalSession(e.sessionId)},onDecline:()=>{this.markBubbleRead(e),this.answerBubbleCard(n,n.decline.value)}},onDismiss:()=>this.markBubbleRead(e)});const i=void 0!==e.milestoneMessageId||void 0!==e.sender||void 0!==e.progress;\"channel_continuation\"!==e.kind&&i?this.goalNudgeBubble.show({...t,confirm:{prompt:Na().awareness.confirmPrompt,acceptLabel:Na().awareness.accept,declineLabel:Na().awareness.decline,laterLabel:Na().awareness.later,onAccept:()=>{this.markBubbleRead(e),this.acceptGoalNudge(e.sessionId)},onDecline:()=>{this.markBubbleRead(e),void 0!==e.milestoneMessageId&&this.apiClient.dismissNudge({milestone_message_id:e.milestoneMessageId,decision:\"decline\"}).catch(()=>{})},onLater:()=>{this.markBubbleRead(e),void 0!==e.milestoneMessageId&&this.apiClient.snoozeNudge({milestone_message_id:e.milestoneMessageId}).catch(()=>{}),this.goalNudgeActive=!1}},onDismiss:()=>{this.markBubbleRead(e),void 0!==e.milestoneMessageId&&this.apiClient.dismissNudge({milestone_message_id:e.milestoneMessageId}).catch(()=>{})}}):this.goalNudgeBubble.show({...t,onClick:()=>{void 0!==e.sessionId&&this.openGoalSession(e.sessionId)},onDismiss:()=>this.markBubbleRead(e)})}markBubbleRead(e){void 0!==e.sessionId&&void 0!==e.seq&&this.readReceiptManager.markReadUpTo(\"session\",e.sessionId,e.seq)}answerBubbleCard(e,t){this.wsEventDispatcher.sendSystemAction(t,void 0,{suggestionType:e.suggestionType,idempotencyKey:e.idempotencyKey})}releaseResolvedCardBubble(e){this.decisionCardBubbleKey===e&&(this.decisionCardBubbleKey=null,this.goalNudgeBubble?.hide())}async acceptGoalNudge(e){this.goalNudgeBubble?.hide();const t=(await this.whileStartingActivation(()=>this.apiClient.openNudge(ya())).catch(()=>({}))).session_id??this.activationSessionStartedInFlight??e;void 0!==t&&this.openGoalSession(t)}startChecklistObjective(e,t){return this.startChecklistSession(()=>this.apiClient.startChecklistObjective(e,ya(),t))}startChecklistSecondary(e){return this.startChecklistSession(()=>this.apiClient.startChecklistSecondary(e,ya()))}async startChecklistSession(e){try{const t=await this.whileStartingActivation(e);this.openNudgeSession(t.session_id)}catch(e){e instanceof Pi&&400===e.status?(this.uiManager.showToast(Na().progress.alreadyDone,\"info\"),this.refreshProgressChecklist()):null!==this.activationSessionStartedInFlight?this.openNudgeSession(this.activationSessionStartedInFlight):this.uiManager.showToast(Na().awareness.clickError,\"error\")}}async whileStartingActivation(e){0===this.activationStartsInFlight++&&(this.activationSessionStartedInFlight=null);try{return await e()}finally{this.activationStartsInFlight--}}handleActivationSessionStarted({sessionId:e,previousSessionId:t}){if(this.activationStartsInFlight>0)return void(this.activationSessionStartedInFlight=e);const n=this.activeConversation;if(\"session\"===n?.type&&n.id===e)return;const i=this.goalNudgeAccept,r=null!==i&&i.sessionId===t&&s()-i.at<15e3;r&&(this.goalNudgeAccept=null),this.wsEventDispatcher.endClosedRun(),this.openNudgeSession(e,r)}handleActivationSessionClosed(e){if(this.sessionManager.getSessionId()===e&&this.sessionManager.setSessionId(null),this.isBackgroundConversation(\"session\",e))return this.tabUnreadCounts.delete(\"session\"),this.dropBackgroundNotifier(),void this.updateConversationSelector();const t=this.activeConversation;\"session\"===t?.type&&t.id===e&&(this.activeConversation=null,this.awarenessSessionSticky=!1,this.wsEventDispatcher.disconnect(),this.releaseNudgeBubble(),this.uiManager.hideAgentBanner(),this.uiManager.hideArchiveButton(),this.clearMessages(),this.tabUnreadCounts.delete(\"session\"),this.readReceiptManager.updateUnreadIndicator(),\"chat\"===this.viewRouter.getCurrentView()&&this.viewRouter.showView(\"home\"),this.updateConversationSelector(),this.refreshHomeShortcuts())}handleActivationSessionReplaced({sessionId:e,previousSessionId:t}){if(this.sessionManager.getSessionId()===t&&this.sessionManager.setSessionId(e),this.isBackgroundConversation(\"session\",t))return this.tabUnreadCounts.delete(\"session\"),this.startBackgroundNotifier(\"session\",e),void this.updateConversationSelector();const n=this.activeConversation;\"session\"===n?.type&&n.id===t&&(this.wsEventDispatcher.disconnect(),this.releaseNudgeBubble(),this.uiManager.hideAgentBanner(),this.clearMessages(),this.connectToSession(e,{follow:!0}),this.updateConversationSelector())}isBackgroundConversation(e,t){return this.backgroundNotifier?.getConversationType()===e&&this.backgroundNotifier.getConversationId()===t}releaseNudgeBubble(){this.goalNudgeBubble?.hide(),this.goalNudgeActive=!1,this.decisionCardBubbleKey=null}refreshProgressChecklist(){!this.isAdminMode&&this.sessionManager.getUser()?this.progressChecklist.refresh():this.progressChecklist.clear()}openGoalSession(e){this.goalNudgeBubble?.hide(),this.openNudgeSession(e)}openNudgeSession(e,t=!0){const n=this.activeConversation;this.awarenessSessionSticky=!0,this.sessionManager.setSessionId(e),this.wsEventDispatcher.disconnect(),this.messageHandler.clearMessages(),this.readReceiptManager.reset(),this.chatStateManager.resetScrollFlag(),this.uiManager.hideAgentBanner(),this.uiManager.hideWaitingBadge(),this.connectToSession(e,{follow:!t}),t&&this.wsEventDispatcher.claimActiveTab(),\"ticket\"===n?.type&&this.startBackgroundNotifier(\"ticket\",n.id),this.uiManager.restoreBubble(),this.readReceiptManager.setChatOpen(!0),this.viewRouter.showView(\"chat\"),this.chatStateManager.open(),this.updateConversationSelector()}getUser(){return this.sessionManager.getUser()}async playIntroPresentation(e,t,n){await this.initPromise,this.isAdminMode||await this.introPresentation.play(e,t??this.sessionManager.getIntroAgentName(),n??this.sessionManager.getIntroAgentAvatarUrl(),this.sessionManager.getExecutive())}async configureAuth(e,t){await this.initPromise,this.wsEventDispatcher.getApiBridgeCallbacks().registerTokenCallback(e,t)}async configureRefreshToken(e){await this.initPromise,this.wsEventDispatcher.getApiBridgeCallbacks().setRefreshToken(e)}async triggerPlaybook(e,t,n,i=!1){if(await this.initPromise,!this.sessionManager.getAiActive())return void this.uiManager.showToast(Na().errors.aiDisabled,\"error\");this.uiManager.showChatOnly(),this.chatStateManager.open();const s=cs();this.uiManager.showChatLoading();try{const i=await this.apiClient.triggerPlaybook({playbook_id:e,message:t,context:n,idempotency_key:s});this.sessionManager.setSessionId(i.session_id),this.activeConversation={type:\"session\",id:i.session_id},this.readReceiptManager.setConversationId(\"session\",i.session_id),this.isNewTicket=!0,this.wsEventDispatcher.disconnect(),this.wsEventDispatcher.connect(\"session\"),this.messageHandler.addMessage({text:t,isAgent:!1}),this.messageSender.resumePendingMessages()}catch(s){this.uiManager.hideChatLoading();const r=Na();if(s instanceof Pi&&\"ai_disabled\"===s.code)this.sessionManager.setAiActive(!1),this.uiManager.setAiActive(!1),this.uiManager.showToast(r.errors.aiDisabled,\"error\");else if(s instanceof Error&&s.message.includes(\"404\"))this.uiManager.showToast(r.errors.playbookNotFound,\"error\");else if(s instanceof Error&&s.message.includes(\"403\")&&!i)try{return await this.sessionManager.loadAnonymousSession(),void await this.triggerPlaybook(e,t,n,!0)}catch{this.uiManager.showToast(r.errors.authFailed,\"error\")}else s instanceof Error&&s.message.includes(\"400\")?this.uiManager.showToast(r.errors.playbookInactive,\"error\"):this.uiManager.showToast(r.errors.ticketCreationFailed,\"error\")}}showAwarenessMessage(e){this.ensureAwarenessManager(),this.awarenessManager?.showMessage(e)}hideAwarenessMessage(){this.awarenessManager?.hideBubble()}setNudgeAnchor(e){this.nudgeAnchor=e}isCornerWidgetHidden(){const e=this.container.querySelector(\".support-bubble, .support-badge\");if(!e||e.classList.contains(\"hidden\"))return!0;const t=getComputedStyle(e);return\"none\"===t.display||\"hidden\"===t.visibility||0===e.getBoundingClientRect().width}createAwarenessManager(e=null){return new aM(this.container,this.apiClient,{onNudgeClick:e=>this.handleAwarenessClick(e),onError:e=>this.uiManager.showToast(e,\"error\"),isChatOpen:()=>this.chatStateManager.isOpened(),getAnchor:()=>this.nudgeAnchor,isWidgetHidden:()=>this.isCornerWidgetHidden(),isSuppressed:()=>this.goalNudgeActive||this.introInProgress},e)}ensureAwarenessManager(){this.awarenessManager||(this.awarenessManager=this.createAwarenessManager())}handleAwarenessClick(e){this.openNudgeSession(e)}async clearUser(){return this.whileChangingIdentity(()=>this.logOut())}async whileChangingIdentity(e){this.identityChanges+=1;try{await e()}finally{this.identityChanges-=1}}async logOut(){this.hostIdentity=null,this.proofIdentity=null,await this.initPromise,this.activationFormManager.hide(),this.featureCheckInManager.reset(),this.introInProgress=!1,this.introStarted=!1,this.introPresentationSourceId=null,this.goalNudgeActive=!1,this.goalNudgeBubble?.hide(),this.bubbleAlternator.setOnboardingData(null),this.progressChecklist.clear(),this.startNewConversation(),this.sessionManager.clearUser(),this.contactLive?.sync(),await this.sessionManager.loadAnonymousSession()}getSessionUuid(){return this.sessionManager.getSessionUuid()}getTicketId(){return this.sessionManager.getTicketId()}getSessionId(){return this.sessionManager.getSessionId()}isWebSocketConnected(){return this.wsEventDispatcher?.isConnected()??!1}testThinkingBubble(){this.messageHandler.startStreamingMessage(),this.messageHandler.appendToStreamingMessage(\"Analyzing your question and understanding the context to provide the most relevant and accurate response possible...\",0)}testCaptureError(){throw new Error(\"Test error from SupportWidget — verifying error containment + Sentry reporting\")}clearMessages(){this.clearReplyTarget(),this.messageHandler.clearMessages(),this.readReceiptManager.reset(),this.chatStateManager.resetScrollFlag(),this.uiManager.hideWaitingBadge(),this.chatStateManager.restoreInputState(),this.reattachInputListeners()}startNewConversation(){this.dropBackgroundNotifier(),this.tabUnreadCounts.clear(),this.clearReleaseChatContext(),this.sessionManager.setTicketId(null),this.sessionManager.setSessionId(null),this.activeConversation=null,this.isNewTicket=!1,this.awarenessSessionSticky=!1,this.wsEventDispatcher.cancelAgentIfActive(),this.wsEventDispatcher.disconnect(),this.uiManager.hideAIThinkingState(),this.uiManager.hideAgentBanner(),this.uiManager.hideConversationSelector(),this.uiManager.hideArchiveButton(),this.uiManager.hideBackToPickerButton(),this.clearMessages(),this.refreshHomeShortcuts()}handleNewTicketHistoryLoaded(e){e&&this.uiManager.showWaitingBadge(this.config.autoResponseMessage||void 0),this.isNewTicket&&(this.isNewTicket=!1)}handleAgentJoined(){this.uiManager.hideWaitingBadge(),this.executiveAvailabilityNotice.dismiss(),this.updateAgentBanner()}handleAiAssignedChange(e){this.conversationContext.setAiAssigned(e),e||this.conversationContext.markSupportHandoff(!0),this.updateAgentBanner()}switchToBadgeMode(){this.bubbleAlternator.stop(),this.uiManager.switchToBadgeMode(),localStorage.setItem(\"support_widget_mode\",\"badge\")}switchToBubbleMode(){this.uiManager.switchToBubbleMode(),localStorage.setItem(\"support_widget_mode\",\"bubble\")}handleBadgeClick(){this.switchToBubbleMode(),this.openChat()}restoreWidgetMode(){\"badge\"===localStorage.getItem(\"support_widget_mode\")&&this.uiManager.switchToBadgeMode()}setupBadgeDrag(e){let t,n,i=!1,s=!1;const r=r=>{i=!0,s=!1;const o=e.getBoundingClientRect();if(n=o.top,\"touchstart\"===r.type){t=r.touches[0].clientY}else{t=r.clientY}e.style.transition=\"none\"},o=()=>{if(i&&!s&&this.handleBadgeClick(),i=!1,e.classList.remove(\"dragging\"),e.style.transition=\"\",s){const t=e.getBoundingClientRect(),n=t.left+t.width/2,i=window.innerWidth,s=e.style.top;n<i/2?(e.style.left=\"0\",e.style.right=\"auto\",e.style.top=s,e.style.bottom=\"auto\",e.style.transform=\"\",e.classList.add(\"badge-left\"),e.classList.remove(\"badge-right\")):(e.style.right=\"0\",e.style.left=\"auto\",e.style.top=s,e.style.bottom=\"auto\",e.style.transform=\"\",e.classList.remove(\"badge-left\"),e.classList.add(\"badge-right\"))}},a=r=>{if(!i)return;let o;if(r.preventDefault(),\"touchmove\"===r.type){o=r.touches[0].clientY}else{o=r.clientY}const a=o-t;if(Math.abs(a)>5){s=!0,e.classList.add(\"dragging\");let t=n+a;const i=e.getBoundingClientRect(),r=window.innerHeight-i.height;t=Math.max(0,Math.min(r,t)),e.style.top=`${t}px`,e.style.bottom=\"auto\"}};e.classList.add(\"badge-right\"),e.addEventListener(\"mousedown\",r),this.disposables.safeOn(document,\"mousemove\",a,\"badge-drag-mousemove\"),this.disposables.safeOn(document,\"mouseup\",o,\"badge-drag-mouseup\"),e.addEventListener(\"touchstart\",r,{passive:!1}),this.disposables.safeOn(document,\"touchmove\",a,\"badge-drag-touchmove\",{passive:!1}),this.disposables.safeOn(document,\"touchend\",o,\"badge-drag-touchend\")}reattachInputListeners(){this.uiManager.hideAIThinkingState();const e=this.container.querySelector(\".support-send-btn\"),t=this.container.querySelector(\".support-chat-input\"),n=this.container.querySelector(\".support-attach-btn\"),i=this.container.querySelector(\".support-file-input\");e&&t&&(e.addEventListener(\"click\",()=>this.handleSendButtonClick()),t.addEventListener(\"keydown\",e=>{\"Enter\"!==e.key||e.shiftKey||(e.preventDefault(),this.handleEnterKeyPress())}),t.addEventListener(\"input\",()=>{this.autoResizeTextarea(t)}),t.addEventListener(\"paste\",e=>this.handlePaste(e))),n&&i&&(n.addEventListener(\"click\",()=>i.click()),i.addEventListener(\"change\",()=>this.handleFileSelection(i))),this.voiceComposer?.attach(this.container),this.restoreVoiceDraft()}initializeNotificationSound(){}playNotificationSound(){if(this.config.enableSound)try{const e=new(window.AudioContext||window.webkitAudioContext),t=e.createOscillator(),n=e.createGain();t.connect(n),n.connect(e.destination),t.frequency.value=800,t.type=\"sine\",n.gain.setValueAtTime(.3,e.currentTime),n.gain.exponentialRampToValueAtTime(.01,e.currentTime+.1),t.start(e.currentTime),t.stop(e.currentTime+.1);const i=e.createOscillator(),s=e.createGain();i.connect(s),s.connect(e.destination),i.frequency.value=1200,i.type=\"sine\",s.gain.setValueAtTime(.3,e.currentTime+.1),s.gain.exponentialRampToValueAtTime(.01,e.currentTime+.2),i.start(e.currentTime+.1),i.stop(e.currentTime+.2)}catch(e){Ji(\"Error playing notification beep\",e)}}enableSound(e=!0){this.config.enableSound=e,ds.set(\"support_widget_sound\",e?\"1\":\"0\")}disableSound(){this.enableSound(!1)}isSoundEnabled(){return this.config.enableSound}setUnreadAnimation(e){this.config.unreadAnimation=e,this.uiManager.setUnreadAnimation(e)}getUnreadAnimation(){return this.config.unreadAnimation}getAgentManager(){return this.wsEventDispatcher?.getAgentManager()}getAgentDiagnostics(){return{get enabled(){return oa()},setEnabled:aa,traces:da,lifecycle:ga,frames:()=>this.wsEventDispatcher.getFrameJournal(),clear:()=>{sa.length=0,function(){try{sessionStorage.removeItem(ua)}catch{}}()}}}cancelAgent(e){this.wsEventDispatcher.cancelAgent(e)}getUIManager(){return this.uiManager}getDisplayMode(){return this.config.displayMode}}function kA(e){if(!(\"true\"===e.getAttribute(\"data-pre-chat-form\")))return;const t=e.getAttribute(\"data-pre-chat-form-fields\"),n=[];if(t){const e=t.split(\",\");for(const t of e){const[e,i]=t.trim().split(\":\");[\"name\",\"email\",\"phone\"].includes(e)&&n.push({type:e,required:\"required\"===i})}}return 0===n.length&&(n.push({type:\"name\",required:!0}),n.push({type:\"email\",required:!0})),{enabled:!0,fields:n,title:e.getAttribute(\"data-pre-chat-form-title\")||void 0,subtitle:e.getAttribute(\"data-pre-chat-form-subtitle\")||void 0,submitButtonText:e.getAttribute(\"data-pre-chat-form-submit-text\")||void 0}}return xA.release=\"1.0.0+333a1e0\",function(){if(window.self!==window.top){const e=document.currentScript||document.querySelector(\"script[data-support-widget]\"),t=e?.getAttribute(\"data-allowed-origins\");if(!t)return;const n=t.split(\",\").map(e=>e.trim());let i;try{i=window.top?.location.origin||\"\"}catch{try{i=document.referrer?new URL(document.referrer).origin:\"\"}catch{return}}if(!n.includes(i))return void console.warn(`[SupportWidget] Iframe embedding blocked. Origin \"${i}\" not in allowed list.`)}window.SupportWidget=xA,window.NetworkRequestTracker=FE;let e=!1;function t(e,t){if(window.supportWidgetInstance)return;const n=new xA(e);window.supportWidgetInstance=n,e.autoOpen&&n.openChat(),function(e,t){const n=e.getAttribute(\"data-awareness-message\");n&&t.showAwarenessMessage(n)}(t,n)}!function(){if(e||window.supportWidgetInstance)return;e=!0;const n=document.currentScript||document.querySelector(\"script[data-support-widget]\");if(n){const e=n,i=n.getAttribute(\"data-publishable-key\");if(!i)return;const s={publishableKey:i,title:n.getAttribute(\"data-title\")||void 0,welcomeSubtitle:n.getAttribute(\"data-welcome-subtitle\")||void 0,position:n.getAttribute(\"data-position\")||void 0,primaryColor:n.getAttribute(\"data-color\")||void 0,secondaryColor:n.getAttribute(\"data-secondary-color\")||void 0,theme:n.getAttribute(\"data-theme\")||void 0,autoOpen:\"true\"===n.getAttribute(\"data-auto-open\"),apiBaseUrl:n.getAttribute(\"data-api-base-url\")||void 0,language:n.getAttribute(\"data-language\")||void 0,autoResponseMessage:n.getAttribute(\"data-auto-response-message\")||void 0,enableSound:\"false\"!==n.getAttribute(\"data-enable-sound\"),unreadAnimation:n.getAttribute(\"data-unread-animation\")||void 0,preChatForm:kA(n),testAgentMode:\"true\"===n.getAttribute(\"data-test-agent-mode\"),startHidden:\"true\"===n.getAttribute(\"data-start-hidden\"),messagesOnly:\"true\"===n.getAttribute(\"data-messages-only\"),displayMode:n.getAttribute(\"data-display-mode\")||void 0,sidePanelSide:n.getAttribute(\"data-side-panel-side\")||void 0,sidePanelBehavior:n.getAttribute(\"data-side-panel-behavior\")||void 0,pushTarget:n.getAttribute(\"data-push-target\")||void 0,skipCookie:\"true\"===n.getAttribute(\"data-skip-cookie\"),trackAllRequests:\"true\"===n.getAttribute(\"data-track-all-requests\")},r=new URLSearchParams(window.location.search),o=r.get(\"blar_release_admin_mode\");if(o){s.releaseUuidToOpen=o,s.autoOpen=!0;const e=new URL(window.location.href);e.searchParams.delete(\"blar_release_admin_mode\"),window.history.replaceState({},\"\",e.toString())}const a=r.get(\"blar_release_test\");if(a){s.releaseUuidToTest=a,s.autoOpen=!0;const e=new URL(window.location.href);e.searchParams.delete(\"blar_release_test\"),window.history.replaceState({},\"\",e.toString())}let l=r.get(\"blar_admin_token\");if(l){const e=new URL(window.location.href);e.searchParams.delete(\"blar_admin_token\"),window.history.replaceState(null,\"\",e.toString())}else l=new Ms(i).getAdminToken();l&&(s.adminToken=l,s.autoOpen=!0);const c=r.get(\"blar_onboarding_step_admin_mode\");if(c){s.onboardingStepToConfigure=c,s.autoOpen=!0;const e=new URL(window.location.href);e.searchParams.delete(\"blar_onboarding_step_admin_mode\"),window.history.replaceState({},\"\",e.toString())}const d=r.get(\"blar_onboarding_step_test\");if(d){s.onboardingStepToTest=d,s.autoOpen=!0;const e=new URL(window.location.href);e.searchParams.delete(\"blar_onboarding_step_test\"),window.history.replaceState({},\"\",e.toString())}\"loading\"===document.readyState?document.addEventListener(\"DOMContentLoaded\",()=>t(s,e)):t(s,e)}}(),window.initSupportWidget=function(e){return window.supportWidgetInstance&&window.supportWidgetInstance.destroy(),window.supportWidgetInstance=new xA(e),window.supportWidgetInstance},window.getSupportWidget=function(){return window.supportWidgetInstance}}(),xA}();\n\n//# debugId=7c9adb98-4d54-5a40-93c5-d13143314c38\n";
