browserzap 0.5.5 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +56 -0
- package/bridge-server/background-runs.js +91 -4
- package/bridge-server/cli-run.js +2 -0
- package/bridge-server/limits.js +27 -1
- package/bridge-server/mcp-server.js +25 -9
- package/bridge-server/panel.js +14 -3
- package/bridge-server/resolvers.js +287 -0
- package/bridge-server/tools.js +43 -4
- package/bridge-server/workflows.js +298 -11
- package/extension/background.js +1 -1
- package/extension/engine.js +1 -1
- package/extension/manifest.json +1 -1
- package/extension/sidepanel.css +1 -1
- package/package.json +1 -1
package/extension/engine.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";const e="data-browserzap-cursor",t="data-browserzap-control",n="data-browserzap-approval",o="data-browserzap-handoff",r="data-browserzap-comment";function i(i){return i instanceof Element&&(i.hasAttribute(e)||i.hasAttribute(t)||i.hasAttribute(n)||i.hasAttribute(o)||i.hasAttribute(r))}function a(e,t){for(const[n,o]of Object.entries(t))e.style.setProperty(n,o)}function s(){try{return matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function l(e){if(!e)return null;let t="";try{t=getComputedStyle(e).backgroundColor}catch{return null}const n=/^rgba?\(([^)]+)\)$/.exec(t);if(!n)return null;const o=n[1].split(",").map(e=>Number(e.trim())),[r,i,a]=o,s=o.length>3?o[3]:1;return![r,i,a,s].every(Number.isFinite)||s<.5?null:.2126*r+.7152*i+.0722*a}function c(){return(l(document.body)??l(document.documentElement)??255)<110?{strong:"#ff922b",soft:"rgba(255, 146, 43, 0.30)",ink:"#1a0d04"}:{strong:"#d9480f",soft:"rgba(217, 72, 15, 0.18)",ink:"#ffffff"}}function u(e,t){const n=document.createElement("div");return a(n,e),void 0!==t&&(n.textContent=t),n}function d(e,t,n){if(e?.el.isConnected)return e;e?.el.remove();const o=document.fullscreenElement??document.documentElement;if(!o)return null;const r=document.createElement("div");r.setAttribute(t,""),n?(r.setAttribute("role",n.role),r.setAttribute("aria-label",n.label)):r.setAttribute("aria-hidden","true"),a(r,{position:"fixed",inset:"0","z-index":"2147483647","pointer-events":"none",overflow:"visible"});const i=r.attachShadow({mode:"closed"});return o.appendChild(r),{el:r,root:i}}function f(e){return(e??"").replace(/\s+/g," ").trim()}function p(e){return f(e).toLowerCase()}function m(e,t){return e.length>t?`${e.slice(0,t-1)}…`:e}function h(e,t=!1){const n=[],o=r=>{if(r.nodeType===Node.TEXT_NODE)return void n.push(r.textContent??"");if(r.nodeType!==Node.ELEMENT_NODE)return;const i=r,a=i.tagName;if("SCRIPT"===a||"STYLE"===a||"TEMPLATE"===a)return;if(t&&("INPUT"===a||"SELECT"===a||"TEXTAREA"===a||"BUTTON"===a))return;if("IMG"===a)return void n.push(` ${i.getAttribute("alt")??""} `);const s=i!==e&&function(e){const t=e.ownerDocument.defaultView?.getComputedStyle(e).display??"inline";return"inline"!==t&&"contents"!==t&&"none"!==t}(i);s&&n.push(" ");for(const e of Array.from(i.childNodes))o(e);s&&n.push(" ")};return o(e),f(n.join(""))}function*g(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let n=t.nextNode();for(;n;){const e=n;yield e,e.shadowRoot&&(yield*g(e.shadowRoot)),n=t.nextNode()}}function b(){const e=Array.from(document.querySelectorAll("dialog[open]"));for(let t=e.length-1;t>=0;t--)if(e[t].matches(":modal"))return e[t];return null}function x(){return"hidden"===document.visibilityState}function y(e){if(e.parentElement)return e.parentElement;const t=e.getRootNode();return t instanceof ShadowRoot?t.host:null}function v(e,t){let n=t;for(;n;){if(n===e)return!0;n=y(n)}return!1}function w(e,t){const n=e.getRootNode();try{return n.querySelector(`#${CSS.escape(t)}`)??document.getElementById(t)}catch{return null}}const k=String.raw`pass(word|code|phrase)?\b|\bpwd\b|\bpin\b|\botp\b|one[-\s]?time|2fa|\bmfa\b|security code|verification code|\bcvv\b|\bcvc\b|\bcsc\b|card ?number|credit ?card|social security|\bssn\b|\biban\b|routing number|account number|tax id|national id|passport`,E=new Set(["button","link","checkbox","radio","switch","tab","menuitem","menuitemcheckbox","menuitemradio","option","combobox","listbox","textbox","searchbox","slider","spinbutton","treeitem","gridcell"]),T=new Set(["button","link","checkbox","radio","switch","tab","menuitem","menuitemcheckbox","menuitemradio","option","treeitem","heading","gridcell","cell"]),A=new Set(["textbox","searchbox","spinbutton","combobox"]),S=/\b(delete|remove|erase|destroy|discard|deactivate|terminate|revoke|unsubscribe|close (my )?account|cancel (my |the )?(subscription|order|plan|membership))\b/i,M=/\b(pay|payment|purchase|buy|checkout|check out|place (the |my )?order|submit order|order now|complete (the )?order|donate|transfer|send money|subscribe|upgrade)\b/i,$=/\b(submit|send|post|publish|share|tweet|reply|comment|confirm|apply|book|reserve|sign up|invite|save changes|approve|accept|merge|deploy)\b/i,L=new RegExp(k,"i"),C=/\b(verify (that )?you('re| are) (a )?human|are you a robot|i'?m not a robot|human verification|security check|captcha|checking your browser)\b/i,N=/\b(two[- ]factor|2fa|multi[- ]factor|verification code|one[- ]time (pass)?code|authenticator app|enter the code)\b/i,I={checkbox:"checkbox",radio:"radio",button:"button",submit:"button",reset:"button",image:"button",range:"slider",number:"spinbutton",search:"searchbox",file:"button",color:"button"};function R(e){const t=f(e.getAttribute("role")).split(" ")[0];if(t)return t.toLowerCase();switch(e.tagName.toLowerCase()){case"a":case"area":return e.hasAttribute("href")?"link":"generic";case"button":case"summary":return"button";case"select":{const t=e;return t.multiple||t.size>1?"listbox":"combobox"}case"textarea":return"textbox";case"input":{const t=(e.type||"text").toLowerCase();return I[t]??"textbox"}case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return"heading";case"img":return"img";default:return e.isContentEditable?"textbox":"generic"}}function H(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function O(e){return H(e)&&e.labels?Array.from(e.labels):[]}function P(e){const t=f(e.getAttribute("aria-labelledby"));if(t){const n=f(t.split(" ").map(t=>w(e,t)).filter(e=>Boolean(e)).map(e=>h(e)).join(" "));if(n)return{name:n,source:"aria-labelledby"}}const n=f(e.getAttribute("aria-label"));if(n)return{name:n,source:"aria-label"};if(e instanceof HTMLInputElement){const t=e.type.toLowerCase();if("submit"===t||"button"===t||"reset"===t){const n="submit"===t?"Submit":"reset"===t?"Reset":"";return{name:f(e.value)||n,source:"value"}}if("image"===t)return{name:f(e.alt)||"Submit",source:"alt"}}if(H(e)){const t=f(O(e).map(e=>h(e,!0)).join(" "));if(t)return{name:t,source:"label"}}if(e instanceof HTMLImageElement){const t=f(e.alt);if(t)return{name:t,source:"alt"}}const o=R(e);if(T.has(o)||"SUMMARY"===e.tagName){const t=h(e);if(t)return{name:t,source:"content"}}const r=f(e.getAttribute("title"));if(r)return{name:r,source:"title"};const i=f(e.getAttribute("placeholder"));return i?{name:i,source:"placeholder"}:{name:"",source:"none"}}function _(e){const t=e.tagName;if("INPUT"===t)return"hidden"!==e.type.toLowerCase();if("BUTTON"===t||"SELECT"===t||"TEXTAREA"===t||"SUMMARY"===t)return!0;if(("A"===t||"AREA"===t)&&e.hasAttribute("href"))return!0;const n=f(e.getAttribute("role")).split(" ")[0].toLowerCase();return!(!n||!E.has(n))||!0===e.isContentEditable&&null!==e.getAttribute("contenteditable")}const B={docId:function(){const e=new Uint8Array(8);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")}(),snapshotId:0,nextRef:1,refs:new Map,ids:new WeakMap,mutations:0},U={label:new Map,sibling:new Map};function q(){U.label=new Map,U.sibling=new Map}function z(e){const t=e;if("function"==typeof t.checkVisibility&&!t.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}))return!1;const n=e.getBoundingClientRect();return!(n.width<=0||n.height<=0||e.closest('[inert],[aria-hidden="true"]'))}function D(e){return e.getClientRects()[0]??e.getBoundingClientRect()}function F(e){return z(e)?e:e instanceof HTMLInputElement&&("checkbox"===e.type||"radio"===e.type)?O(e).find(e=>z(e))??null:null}function G(e){if("true"===e.getAttribute("aria-disabled"))return!0;try{return e.matches(":disabled")}catch{return!1}}function j(e,t){if(!H(e)&&!e.isContentEditable)return null;if("password"===(e.getAttribute("type")??"").toLowerCase())return"password field";const n=(e.getAttribute("autocomplete")??"").toLowerCase();if(/\b(cc-[a-z-]+|current-password|new-password|one-time-code)\b/.test(n))return`autocomplete=${n}`;const o=[t,e.getAttribute("name"),e.id,e.getAttribute("aria-label"),e.getAttribute("placeholder")].join(" ").match(L);return o?`looks like "${o[0].toLowerCase()}"`:null}function W(e){const t={};if(G(e)&&(t.disabled=!0),e instanceof HTMLInputElement&&("checkbox"===e.type||"radio"===e.type)?t.checked=e.checked:e.hasAttribute("aria-checked")&&(t.checked="true"===e.getAttribute("aria-checked")),e.hasAttribute("aria-expanded")&&(t.expanded="true"===e.getAttribute("aria-expanded")),e.hasAttribute("aria-selected")&&(t.selected="true"===e.getAttribute("aria-selected")),e instanceof HTMLSelectElement){const n=e.selectedOptions[0];n&&(t.value=m(f(n.label||n.text),100)),t.options=e.options.length}else(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&(e.required&&(t.required=!0),e instanceof HTMLInputElement&&("checkbox"===e.type||"radio"===e.type)||(t.filled=e.value.length>0),e.readOnly&&(t.readonly=!0));return t}function K(e){const t=U.label.get(e);if(void 0!==t)return t;const n=function(e){const t=f(e.getAttribute("aria-labelledby"));if(t){const n=f(t.split(" ").map(t=>w(e,t)).filter(Boolean).map(e=>h(e)).join(" "));if(n)return n}const n=f(e.getAttribute("aria-label"));if(n)return n;if(!e.matches("section,article,aside,nav,main,form,fieldset,dialog,header,footer,li,table,tr,[role=region],[role=group],[role=dialog],[role=alertdialog],[role=form],[role=tabpanel],[role=navigation],[role=complementary],[role=listitem],[role=row]"))return function(e){const t=e.parentElement;if(!t||!e.className||"string"!=typeof e.className)return!1;let n=U.sibling.get(t);if(!n){n=new Map;for(const e of Array.from(t.children)){if("string"!=typeof e.className||!e.className)continue;const t=`${e.tagName}.${e.className}`;n.set(t,(n.get(t)??0)+1)}U.sibling.set(t,n)}return(n.get(`${e.tagName}.${e.className}`)??0)>=2&&null!==e.querySelector(V)}(e)?Q(e):"";const o=e.querySelector(":scope > :is(h1,h2,h3,h4,h5,h6,legend,caption), :scope > header :is(h1,h2,h3,h4,h5,h6)");return o?h(o):e.matches(X)?function(e){const t=Array.from(e.children).filter(e=>e.matches("th,td,[role=cell],[role=gridcell],[role=rowheader],[role=columnheader]")).filter(e=>!e.querySelector(V)&&h(e)),n=t.find(e=>e.matches("th,[role=rowheader]"));return n?h(n):t[0]?h(t[0]):""}(e):e.matches(Y)?Q(e):""}(e);return U.label.set(e,n),n}const X="tr,[role=row]",Y="li,[role=listitem],article",V='a[href],button,input:not([type=hidden]),select,textarea,summary,[role=button],[role=link],[role=checkbox],[role=radio],[role=switch],[role=tab],[role=menuitem],[role=option],[role=combobox],[role=textbox],[contenteditable=""],[contenteditable=true]',Z=60;function Q(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let n=0;for(let e=t.nextNode();e&&n<Z;e=t.nextNode(),n++){const t=e;if(!(t.matches("label,script,style,template")||_(t)||t.querySelector(V))&&(Array.from(t.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&f(e.textContent))&&z(t)))return m(h(t),60)}return""}function J(e){const t=[];let n=y(e);for(;n&&n!==document.documentElement;){const e=K(n);e&&t.push(e),n=y(n)}return t}function ee(e){let t=y(e);for(;t&&t!==document.documentElement;){const e=K(t);if(e)return e;t=y(t)}return""}function te(e,t){return`${e}|${p(t)}`}function ne(e,t,n,o){let r=B.ids.get(e);return r||(r="e"+B.nextRef++,B.ids.set(e,r)),B.refs.set(r,{el:new WeakRef(e),fingerprint:te(t,n),context:o}),r}function oe(e){return e.visible??=e.proxy?null!==F(e.el):z(e.el),e.visible}function re(){const e=[];for(const t of g(document)){if(!_(t))continue;const{name:n,source:o}=P(t);e.push({el:t,role:R(t),name:m(n,200),source:o,proxy:!0})}return e}function ie(e){const t=ee(e.el);return{ref:ne(e.el,e.role,e.name,t),role:e.role,name:m(e.name,100),context:t?m(t,60):void 0,visible:oe(e)}}function ae(e,t,n){return H(e)&&A.has(t)?"reversible":S.test(n)?"destructive":M.test(n)?"financial":$.test(n)||(e instanceof HTMLButtonElement&&"submit"===e.type&&null!==e.form||e instanceof HTMLInputElement&&("submit"===e.type||"image"===e.type)&&null!==e.form)&&"post"===e.form.method.toLowerCase()?"external_side_effect":"reversible"}function se(){if(document.querySelector('iframe[src*="recaptcha"],iframe[src*="hcaptcha"],iframe[src*="challenges.cloudflare.com"],iframe[title*="captcha" i],.g-recaptcha,.h-captcha,.cf-turnstile,#challenge-form,[data-sitekey]'))return{kind:"captcha",evidence:"a CAPTCHA widget is present"};const e=Array.from(document.querySelectorAll("h1,h2,h3,legend,[role=heading]")).filter(e=>z(e)).map(e=>h(e)).join(" | "),t=`${document.title} | ${e}`.match(C);if(t)return{kind:"captcha",evidence:`page asks: "${t[0]}"`};if(document.querySelector('input[autocomplete="one-time-code"]'))return{kind:"mfa",evidence:"a one-time-code field is present"};const n=e.match(N);return n?{kind:"mfa",evidence:`page asks: "${n[0]}"`}:null}function le(e){return!(e.overlay||e.interactive||e.insideInteractive||e.insideClickableRegion)&&!!(e.cursorPointer||e.inlineOnClick||e.tabbable)&&!e.parentCursorPointer&&!e.containsInteractive&&e.visible&&e.enabled&&e.hasText}const ce="clickable",ue=new Set,de=new WeakSet;function fe(e){try{return getComputedStyle(e).cursor}catch{return""}}function pe(e,t){let n,o=null;const r=()=>void 0===n?n=y(e):n;let a=null,s=null,l=null;const c=()=>{if(l)return l;const e={interactive:!1,clickable:!1};for(let n=r();n;n=y(n))_(n)&&(e.interactive=!0),t.has(n)&&(e.clickable=!0);return l=e,e};return{get overlay(){return i(e)},get interactive(){return _(e)},get insideInteractive(){return c().interactive},get insideClickableRegion(){return c().clickable},get cursorPointer(){return"pointer"===(o??=fe(e))},get inlineOnClick(){return e.hasAttribute("onclick")},get tabbable(){return e.tabIndex>=0},get parentCursorPointer(){const e=r();return null!==e&&"pointer"===(a??=fe(e))},get containsInteractive(){return null!==e.querySelector(V)},get visible(){return z(e)},get enabled(){return!G(e)},get hasText(){return(s??=me(e)).length>0}}}function me(e){const t=e.innerText;return f("string"==typeof t&&t?t:h(e))}function he(e){return m(me(e),200)}function ge(){const e=new Set,t=[];for(const n of g(document))le(pe(n,e))&&(e.add(n),t.push({el:n,role:ce,name:he(n),source:"content",proxy:!1}));return t}function be(e){let t="";for(const n of Array.from(e.childNodes))n.nodeType===Node.TEXT_NODE&&(t+=n.textContent??"");return t}function xe(e){for(let t=y(e);t;t=y(t))if(_(t))return!0;return!1}function ye(e,t,n={}){return{ok:!1,code:e,message:t,...n}}function ve(e){return`"${m(e,60)}"`}function we(e,t,n={}){return ye("TARGET_NOT_INTERACTABLE",`${e} ${t}`,n)}function ke(){const e=b();if(e)return e;const t=Array.from(document.querySelectorAll('[aria-modal="true"]')).filter(e=>e.matches("dialog,[role=dialog],[role=alertdialog]")&&z(e));return t.length?t[t.length-1]:null}function Ee(e,t){const n=p(t),o=e.filter(e=>p(ee(e.el))===n);return o.length?o:e.filter(e=>J(e.el).some(e=>p(e)===n))}function Te(e){const t=B.refs.get(e),n=t?.el.deref();if(!t||!n)return ye("STALE_SNAPSHOT",`Reference ${e} is unknown on this page. Run page_inspect again.`);if(!n.isConnected)return ye("STALE_SNAPSHOT",`The element behind ${e} was removed from the page. Run page_inspect again.`,{staleFingerprint:t.fingerprint,staleContext:t.context});const o=function(e){return de.has(e)||function(e){return le(pe(e,ue))}(e)?ce:R(e)}(n),{name:r,source:i}=function(e,t){return t===ce?{name:he(e),source:"content"}:P(e)}(n,o);return te(o,r)!==t.fingerprint?ye("STALE_SNAPSHOT",`The element behind ${e} changed (now ${o} "${m(r,40)}"). Run page_inspect again.`,{staleFingerprint:t.fingerprint,staleContext:t.context}):{el:n,role:o,name:r,source:i,proxy:!0}}function Ae(e){if(e.ref)return Te(e.ref);const t=e.role?.toLowerCase(),n=!(t&&!E.has(t)&&"generic"!==t&&"clickable"!==t);let o=n?re():function(e){const t=[];for(const n of g(document)){if(R(n)!==e)continue;const{name:o,source:r}=P(n);t.push({el:n,role:e,name:m(o,200),source:r,proxy:!1})}return t}(t);const r=n&&("clickable"===t||!t&&(Boolean(e.name)||Boolean(e.text)));r&&(o=o.concat(ge())),t&&(o=o.filter(e=>e.role===t)),n&&(o=function(e){const t=ke();return t?e.filter(e=>v(t,e.el)):e}(o)),e.within&&(o=Ee(o,e.within));const a=[],s=e.name??e.label??e.text;if(e.label){const t=p(e.label);a.push({label:"label",pick:e=>H(e.el)&&"placeholder"!==e.source&&p(e.name)===t})}if(e.href){const t=e.href;a.push({label:"href",pick:e=>e.el instanceof HTMLAnchorElement&&((e.el.getAttribute("href")??"")===t||e.el.href===t||e.el.pathname===t)})}if(e.name||e.text){const t=p(e.name??e.text);a.push({label:"name",pick:e=>"placeholder"!==e.source&&p(e.name)===t})}if(e.text){const t=p(e.text);a.push({label:"text",pick:e=>p(h(e.el))===t}),a.push({label:"text in a clickable region",pick:e=>"clickable"===e.role&&function(e,t){if(!t)return!1;const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(let e=n.nextNode();e;e=n.nextNode()){const n=e;if(0===n.children.length&&p(h(n))===t)return!0}return!1}(e.el,t)}),a.push({label:"placeholder",pick:e=>p(e.el.getAttribute("placeholder"))===t})}if(!a.length&&e.role&&a.push({label:"role",pick:()=>!0}),!a.length)return ye("INVALID_ARGUMENT","A target needs one of: ref, name, label, text, href (optionally with role and within).");for(const t of a){const n=o.filter(t.pick);if(!n.length)continue;const r=n.filter(oe),i=r.length?r:n;return 1===i.length?i[0]:ye("TARGET_AMBIGUOUS",`${i.length} elements match ${Se(e)} by ${t.label}. Nothing was done. `+(i.length>50?"The first 50 are listed. ":"")+"Use a ref from the candidates, or add role/within (a candidate's context) to narrow it.",{candidates:i.slice(0,50).map(ie)})}if(e.text&&r){let t=function(e,t){const n=new Set,o=[];if(!e)return o;for(const r of g(document)){if(t&&!v(t,r))continue;if(p(0===r.children.length?h(r):be(r))!==e)continue;if(i(r)||_(r)||xe(r)||!z(r))continue;if(r.closest("th, thead, [role=columnheader]"))continue;const a=r.closest("tr, [role=row], li, [role=listitem]"),s=a&&!a.querySelector(V)?a:r;n.has(s)||G(s)||(n.add(s),de.add(s),o.push({el:s,role:ce,name:he(s),source:"content",proxy:!1}))}return o}(p(e.text),ke());if(e.within&&(t=Ee(t,e.within)),1===t.length)return t[0];if(t.length>1)return ye("TARGET_AMBIGUOUS",`${t.length} elements show ${Se(e)}. Nothing was done. Use a ref from the candidates, or add within (a candidate's context) to narrow it.`,{candidates:t.slice(0,50).map(ie)})}const l=p(s??e.href??""),c=l?o.filter(e=>p(e.name).includes(l)&&oe(e)).slice(0,8).map(ie):[];return ye("TARGET_NOT_FOUND",`No element matches ${Se(e)}.`,c.length?{candidates:c}:{})}function Se(e){const t=[];return e.role&&t.push(`role=${e.role}`),e.name&&t.push(`name="${e.name}"`),e.label&&t.push(`label="${e.label}"`),e.text&&t.push(`text="${e.text}"`),e.href&&t.push(`href="${e.href}"`),e.within&&t.push(`within="${e.within}"`),t.join(" ")||"(empty target)"}const Me=new WeakMap,$e=[];function Le(e,t){const n=Me.get(e);return Boolean(n&&n.bursts.length>=3&&t-n.bursts[0]<3e3&&t-n.last<3e3)}function Ce(e){if("childList"!==e.type||0===e.addedNodes.length&&0===e.removedNodes.length)return!1;for(const t of e.addedNodes)if(!i(t))return!1;for(const t of e.removedNodes)if(!i(t))return!1;return!0}new MutationObserver(e=>{const t=performance.now();for(const n of e){if(Ce(n))continue;B.mutations+=1;let e=Me.get(n.target);e||(e={last:-1/0,bursts:[]},Me.set(n.target,e)),t-e.last>50&&(e.bursts.push(t),e.bursts.length>3&&e.bursts.shift()),e.last=t,$e.push({seq:B.mutations,at:t,node:new WeakRef(n.target)}),$e.length>2e3&&$e.shift()}}).observe(document,{subtree:!0,childList:!0,attributes:!0,characterData:!0});const Ne=['[aria-busy="true"]','[role="progressbar"]',"progress",'[role="status"]','[role="alert"]','[class*="spinner" i]','[class*="loading" i]','[class*="loader" i]','[id*="spinner" i]','[id*="loading" i]'].join(", "),Ie=/load|wait|fetch|progress|processing|please|searching|saving/i;let Re=null,He=0;const Oe=new WeakMap;function Pe(e){q();const{name:t,source:n}=P(e),o=R(e),r=H(e)&&t&&"placeholder"!==n?{label:t}:t&&"placeholder"===n?{text:t}:{role:o,name:t},i=[ee(e),...J(e)].filter((e,t,n)=>e&&n.indexOf(e)===t);for(const n of[r,...i.map(e=>({...r,within:e}))]){if(!t)break;const o=Ae(n);if("el"in o&&o.el===e)return{target:n,ambiguous:!1,name:t}}return{target:i[0]?{...r,within:i[0]}:r,ambiguous:!0,name:t}}function _e(e,t){try{chrome.runtime.sendMessage({source:"engine-recorder",step:{...e,id:`${B.docId}-${++He}`},value:t})}catch{}}function Be(e){return e instanceof HTMLInputElement&&!["checkbox","radio","button","submit","reset","file","image","hidden","range","color"].includes(e.type)||e instanceof HTMLTextAreaElement}function Ue(e){const t=e.value;if(Oe.get(e)===t)return;Oe.set(e,t);const{target:n,ambiguous:o,name:r}=Pe(e),i=Boolean(j(e,r));_e({tool:"field_fill",args:{target:n},label:`Type into "${r||"field"}"`,param:r||"value",sensitive:i,ambiguous:o},i?void 0:t)}const qe="data-browserzap-comment-target";let ze=null,De=0;function Fe(e){try{chrome.runtime.sendMessage({source:"engine-comment",...e})}catch{}}function Ge(e){return e.composedPath().some(e=>e instanceof Node&&i(e))}function je(e){const t=[];let n=e;for(;n&&t.length<6&&n!==document.documentElement&&n!==document.body;){let e=n.tagName.toLowerCase();if(n.id)e+=`#${n.id}`;else{const t=Array.from(n.classList).filter(e=>!/^\d/.test(e)).slice(0,2);t.length&&(e+=`.${t.join(".")}`);const o=y(n);if(o){const t=Array.from(o.children).filter(e=>e.tagName===n.tagName);t.length>1&&(e+=`:nth-of-type(${t.indexOf(n)+1})`)}}if(t.unshift(e),n.id)break;n=y(n)}return t.join(" > ")}function We(e){q();const{name:t}=P(e),{target:n,ambiguous:o}=Pe(e),r=e.getBoundingClientRect(),i=H(e)||e.isContentEditable,a=e.getAttribute("data-testid")??e.getAttribute("data-test")??e.getAttribute("data-cy")??e.getAttribute("data-test-id"),s={role:R(e),name:t||null,target:n,targetUnique:!o,tag:e.tagName.toLowerCase(),id:e.id||null,testId:a||null,classes:Array.from(e.classList).slice(0,6),domPath:je(e),rect:{x:Math.round(r.x),y:Math.round(r.y),width:Math.round(r.width),height:Math.round(r.height)}};if(i)s.sensitive=Boolean(j(e,t));else{const t=f(e.innerText??e.textContent??"");t&&(s.text=t.length>160?`${t.slice(0,159)}…`:t)}return s}function Ke(e){q();const{name:t}=P(e),n=R(e),o=e.tagName.toLowerCase(),r=n&&"generic"!==n?n:o;return t?`${r} "${t.length>40?`${t.slice(0,39)}…`:t}"`:r}function Xe(e,t){const n=t.getBoundingClientRect();a(e,{transform:`translate(${n.left}px, ${n.top}px)`,width:`${Math.max(n.width,2)}px`,height:`${Math.max(n.height,2)}px`})}function Ye(){if(ze){ze.frame=0,ze.picked&&Xe(ze.highlight,ze.picked);for(const e of ze.pins.values()){if(!e.el.isConnected){e.badge.style.display="none";continue}const t=e.el.getBoundingClientRect();a(e.badge,{display:"flex",transform:`translate(${Math.max(t.left-10,2)}px, ${Math.max(t.top-10,2)}px)`})}}}function Ve(){ze&&!ze.frame&&(ze.frame=requestAnimationFrame(Ye))}function Ze(){ze?.card&&(ze.card.remove(),ze.card=null)}function Qe(e){if(!ze)return{ok:!1};const t=String(e.cid??""),n=Number(e.n)||ze.next;let o=e.el instanceof Element?e.el:null;if(!o)try{o=document.querySelector(`[${qe}="${CSS.escape(t)}"]`)}catch{o=null}if(document.querySelectorAll(`[${qe}="${CSS.escape(t)}"]`).forEach(e=>e.removeAttribute(qe)),!o)return{ok:!1};ze.pins.get(t)?.badge.remove();const r=function(e){const t=c();return u({position:"fixed",left:"0",top:"0",width:"20px",height:"20px","border-radius":"50%",display:"flex","align-items":"center","justify-content":"center",background:t.strong,color:t.ink,font:"700 11px/1 system-ui, sans-serif","box-shadow":"0 1px 4px rgba(0,0,0,.4)"},String(e))}(n);return ze.host.root.appendChild(r),ze.pins.set(t,{n,el:o,badge:r}),ze.next=Math.max(ze.next,n+1),Ye(),{ok:!0}}let Je=null,et=null,tt=null,nt=null,ot=null;function rt(){null!==tt&&(clearTimeout(tt),tt=null)}function it(e){if(!Je?.el.isConnected||!et)return;const t=et.pill,n=t.getBoundingClientRect();e.x>=n.left-4&&e.x<=n.right+4&&e.y>=n.top-4&&e.y<=n.bottom+4&&(t.style.setProperty("pointer-events","none"),setTimeout(()=>{et?.pill===t&&t.style.setProperty("pointer-events","auto")},1200))}function at(e){if(rt(),!Je)return;const t=Je;if(Je=null,et=null,e||s()||"function"!=typeof t.el.animate)return void t.el.remove();const n=()=>t.el.remove();t.el.animate([{opacity:1},{opacity:0}],{duration:140,easing:"ease-out"}).finished.then(n).catch(n)}function st(){if(null!==ot&&(clearTimeout(ot),ot=null),!nt)return;const e=nt;nt=null,removeEventListener("scroll",e.follow,!0),removeEventListener("resize",e.follow),e.host.el.remove()}const lt=[404,500,502,503,504],ct=[/\bsomething went wrong\b/,/\b(?:we(?:'ve| have) )?encountered an error\b/,/\binternal server error\b/,/\bservice (?:temporarily )?unavailable\b/,/\b(?:an )?unexpected error (?:has )?occurred\b/,/\ban error occurred\b/,/\bthis page (?:isn'?t|is not) working\b/,/\bpage not found\b/],ut=/^(?:error\s+|http\s+)?(\d{3})(?!\d)/,dt=/^(?:error\s+|http\s+)?\d{3}\s*$/;function ft(e){const t=e.trim().toLowerCase().match(ut);if(!t)return null;const n=Number(t[1]);return lt.includes(n)?n:null}function pt(e){const t=e.toLowerCase().match(new RegExp(ct.map(e=>e.source).join("|")));return t?t[0].slice(0,120):null}function mt(e){const t=document.querySelector("main")??document.body;return t?function(e){const t=e.headings.filter(e=>e.level<=2&&e.text.trim()).slice(0,2);for(const e of t){const t=ft(e.text);if(null!==t&&!(e.level>1&&dt.test(e.text.trim())))return{status:t,text:e.text.trim().slice(0,120)}}for(const e of t){const t=pt(e.text);if(t)return{status:null,text:t}}const n=pt(e.text);return n&&e.network5xx?{status:null,text:n}:null}({headings:Array.from(document.querySelectorAll("h1,h2")).filter(e=>z(e)).slice(0,2).map(e=>({level:Number(e.tagName[1]),text:m(f(h(e)),120)})),text:f(t.innerText??"").slice(0,4e3),network5xx:e}):null}function ht(e){const t=e.target??{},n=String(e.purpose??"click"),o=Ae(t);if("ok"in o)return o;const{el:r,role:a,name:s}=o,l=ee(r),c={ref:ne(r,a,s,l),role:a,name:m(s,100),context:l?m(l,60):void 0};if("probe"!==n){if(G(r))return we(`${a} ${ve(s)}`,"is disabled.",{target:c});if(!F(r))return we(`${a} ${ve(s)}`,"is not visible.",{target:c})}const u={ok:!0,...c,docId:B.docId,risk:ae(r,a,s),sensitive:j(r,s),state:W(r),challenge:se(),mutations:B.mutations,url:location.href,hidden:x()},d=e.scroll?F(r):null;if(e.scroll&&d){const e=d;e.scrollIntoView({block:"center",inline:"center",behavior:"instant"});const t=D(e),n=Math.round(t.left+t.width/2),o=Math.round(t.top+t.height/2);if(n<0||o<0||n>innerWidth||o>innerHeight)return we(`${a} ${ve(s)}`,"could not be scrolled into view.",{target:c});const l=e.getRootNode().elementFromPoint(n,o);if(null===l||!(i(l)||v(e,l)||v(r,l)||l instanceof HTMLLabelElement&&O(r).includes(l))){const e=l?`${l.tagName.toLowerCase()} "${m(P(l).name||h(l),40)}"`:"nothing";return we(`${a} ${ve(s)}`,`is covered by ${e}.`,{target:c})}u.point={x:n,y:o},u.pageRect={x:t.left+scrollX,y:t.top+scrollY,width:t.width,height:t.height},u.mutations=B.mutations}return u}function gt(e){return e instanceof HTMLTextAreaElement?e:e instanceof HTMLInputElement?["checkbox","radio","button","submit","reset","image","file","range","color","hidden"].includes(e.type)?null:e:e.isContentEditable?e:null}function bt(){let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e}function xt(e,t){const n=e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,o=Object.getOwnPropertyDescriptor(n,"value")?.set;o?o.call(e,t):e.value=t,e.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))}function yt(e){const t=Te(String(e.ref));if("ok"in t)return t;const n=String(e.value??""),o=t.el;let r;if(o instanceof HTMLInputElement||o instanceof HTMLTextAreaElement)o.focus({preventScroll:!0}),xt(o,n),r="nativeSetter";else{const e=o;e.focus({preventScroll:!0});const t=document.createRange();t.selectNodeContents(e);const i=getSelection();i?.removeAllRanges(),i?.addRange(t);const a=n?document.execCommand("insertText",!1,n):document.execCommand("delete");a||(e.textContent=n),r=a?"insertText":"textContent"}o.dispatchEvent(new Event("change",{bubbles:!0}));const i=function(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e.value:e.innerText??""}(o);return{ok:!0,verified:o instanceof HTMLInputElement&&"number"===o.type?Number(i)===Number(n):f(i)===f(n),method:r,length:i.length,mutations:B.mutations}}let vt=null,wt=null,kt=null,Et=null,Tt=!1;function At(e){return`translate3d(${e.x-1}px, ${e.y-1}px, 0)`}function St(e){e.getAnimations().forEach(e=>e.cancel())}function Mt(){if(vt?.el.isConnected&&wt)return wt;const t=d(vt,e);return vt=t,t?(wt=function(e){const t=c(),n=document.createElement("div");n.setAttribute("data-bz-marker","arrow"),a(n,{position:"absolute",left:"0",top:"0",width:"18px",height:"22px","transform-origin":"1px 1px","will-change":"transform, opacity",opacity:"0","pointer-events":"none"});const o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("width","18"),o.setAttribute("height","22"),o.setAttribute("viewBox","0 0 18 22"),o.setAttribute("aria-hidden","true");const r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d","M1 1v16.2l4.4-4 2.7 7.2 2.9-1.2-2.7-7.1 5.9-.5z"),r.setAttribute("fill","#ffffff"),r.setAttribute("stroke","#111111"),r.setAttribute("stroke-width","1.4"),r.setAttribute("stroke-linejoin","round"),o.appendChild(r),n.appendChild(o);const i=u({position:"absolute",left:"0",top:"0",width:"9px",height:"18px",display:"none",opacity:"0","pointer-events":"none","will-change":"transform, opacity"});i.setAttribute("data-bz-marker","caret");const s=`${t.strong}`,l="0 0 0 0.5px rgba(255, 255, 255, 0.85), 0 0 0 1.5px rgba(17, 17, 17, 0.35)",d=u({position:"absolute",left:"4px",top:"0",width:"1.5px",height:"100%",background:s,"box-shadow":l}),f=u({position:"absolute",left:"0",top:"0",width:"9px",height:"2px",background:s,"box-shadow":l}),p=u({position:"absolute",left:"0",bottom:"0",width:"9px",height:"2px",background:s,"box-shadow":l});i.append(d,f,p);const m=document.createElement("div");a(m,{position:"absolute",left:"0",top:"0",width:"30px",height:"30px","border-radius":"50%","box-sizing":"border-box",border:`2px solid ${t.strong}`,background:t.soft,opacity:"0","pointer-events":"none"});const h=document.createElement("div");a(h,{position:"absolute",left:"0",top:"0","max-width":"160px",padding:"2px 7px","border-radius":"5px",background:"rgba(17, 17, 17, 0.9)",color:"#ffffff","box-shadow":"0 2px 8px rgba(0, 0, 0, 0.28)",font:'600 10px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',"white-space":"nowrap","text-overflow":"ellipsis",overflow:"hidden",opacity:"0","pointer-events":"none"}),h.textContent="click";const g=document.createElement("div");return a(g,{position:"absolute",left:"0",top:"0","box-sizing":"border-box",border:`2px solid ${t.strong}`,"border-radius":"6px","box-shadow":`0 0 0 3px ${t.soft}`,opacity:"0","will-change":"opacity","pointer-events":"none"}),e.append(g,m,n,i,h),{cursor:n,ripple:m,label:h,outline:g,caret:i}}(t.root),wt):(wt=null,null)}const $t=new Set(["","text","search","url","tel","email","password","number"]);function Lt(e){const t=function(){const e=bt();return e&&e!==document.body&&e!==document.documentElement&>(e)?e:null}(),n=t?function(e){const t=e.getBoundingClientRect();if(t.width<=0||t.height<=0)return null;const n=getComputedStyle(e),o=parseFloat(n.lineHeight)||1.35*(parseFloat(n.fontSize)||13),r=t.left+(parseFloat(n.borderLeftWidth)||0)+(parseFloat(n.paddingLeft)||0),i=t.right-(parseFloat(n.borderRightWidth)||0)-(parseFloat(n.paddingRight)||0),a=Math.max(r,i-1),s=Math.min(Math.max(o,12),Math.max(t.height-2,12));if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const n=e instanceof HTMLInputElement?e.type:"textarea";let o="";if(e instanceof HTMLTextAreaElement||$t.has(n)){const t=e instanceof HTMLInputElement&&"password"===n?"•".repeat(e.value.length):e.value;o=e instanceof HTMLTextAreaElement?t.slice(t.lastIndexOf("\n")+1):t}const i=Math.min(Math.max(r+function(e,t){if(!t)return 0;const n=getComputedStyle(e);try{const e=document.createElement("canvas").getContext("2d");if(e)return e.font=n.font&&""!==n.font?n.font:`${n.fontStyle} ${n.fontWeight} ${n.fontSize} ${n.fontFamily}`,e.measureText(t).width}catch{}return t.length*(parseFloat(n.fontSize)||13)*.55}(e,o)-e.scrollLeft,r),a);return{x:i,y:t.top+(t.height-s)/2,height:s}}const l=getSelection(),c=l&&l.rangeCount?l.getRangeAt(0):null;if(c&&l?.isCollapsed&&function(e,t){for(let n=t;n;n=n.parentNode)if(n===e)return!0;return!1}(e,c.startContainer)){const e=c.getBoundingClientRect();if(e.height>0)return{x:Math.min(Math.max(e.left,r),a),y:e.top,height:Math.min(Math.max(e.height,12),t.height)}}return{x:r,y:t.top+(t.height-s)/2,height:s}}(t):null;return!(!t||!n||(St(e.caret),e.caret.style.display="block",e.caret.style.height=`${Math.round(n.height)}px`,e.caret.style.transform=`translate3d(${Math.round(n.x-4)}px, ${Math.round(n.y)}px, 0)`,e.caret.style.opacity="1",e.cursor.style.display="none",e.cursor.style.opacity="0",s()||e.caret.animate([{opacity:1},{opacity:0}],{duration:560,iterations:1/0,direction:"alternate",easing:"steps(1, end)"}),0))}function Ct(e){St(e.caret),e.caret.style.display="none",e.caret.style.opacity="0",e.cursor.style.display="block"}function Nt(e,t){const n=kt;if(kt=t,St(e.cursor),e.cursor.style.opacity="1",!n||s()||Math.hypot(t.x-n.x,t.y-n.y)<2)return e.cursor.style.transform=At(t),null;const o=Math.hypot(t.x-n.x,t.y-n.y),r=Math.max(90,Math.min(240,o/3));return e.cursor.style.transform=At(n),e.cursor.animate([{transform:At(n)},{transform:At(t)}],{duration:r,easing:"cubic-bezier(0.2, 0.7, 0.3, 1)",fill:"forwards"})}function It(e,t,n){St(e.label),e.label.textContent=n||"click",e.label.style.transform=`translate3d(${t.x+12}px, ${t.y+14}px, 0)`,s()?e.label.style.opacity="1":e.label.animate([{opacity:0,transform:`translate3d(${t.x+12}px, ${t.y+20}px, 0)`},{opacity:1,transform:`translate3d(${t.x+12}px, ${t.y+14}px, 0)`,offset:.18},{opacity:1,transform:`translate3d(${t.x+12}px, ${t.y+14}px, 0)`,offset:.7},{opacity:0,transform:`translate3d(${t.x+12}px, ${t.y+10}px, 0)`}],{duration:700,easing:"ease-out"})}function Rt(e,t){return"click"===e.phase||"press"===e.phase?(function(e,t){const n=Mt();n&&(it(e),St(n.ripple),St(n.outline),n.outline.style.opacity="0",Ct(n),n.cursor.style.opacity="1",n.cursor.style.transform=At(e),It(n,e,t),s()||(St(n.cursor),n.cursor.animate([{transform:`${At(e)} scale(1)`},{transform:`${At(e)} scale(0.86)`,offset:.35},{transform:`${At(e)} scale(1)`}],{duration:180,easing:"ease-out"}),n.ripple.animate([{transform:`translate3d(${e.x-15}px, ${e.y-15}px, 0) scale(0.25)`,opacity:.9},{transform:`translate3d(${e.x-15}px, ${e.y-15}px, 0) scale(1.3)`,opacity:0}],{duration:420,easing:"cubic-bezier(0.16, 1, 0.3, 1)"})),kt=e)}(e.point,e.label),Promise.resolve()):"type"===e.phase||"label"===e.phase?(function(e,t,n,o){const r=Mt();r&&(St(r.outline),r.outline.style.opacity="0",o&&Lt(r)||(Ct(r),Nt(r,e)),It(r,e,t),n&&function(e,t){St(e.outline);const n=Math.round(t.x-scrollX),o=Math.round(t.y-scrollY);a(e.outline,{width:`${Math.max(1,Math.round(t.width))}px`,height:`${Math.max(1,Math.round(t.height))}px`,transform:`translate3d(${n}px, ${o}px, 0)`}),s()?e.outline.style.opacity="1":e.outline.animate([{opacity:0},{opacity:1,offset:.15},{opacity:1,offset:.7},{opacity:0}],{duration:900,easing:"ease-out"})}(r,n))}(e.point,e.label||"type",e.rect,t),Promise.resolve()):async function(e,t){const n=Mt();if(!n)return;it(e);const o=null===kt;if(t&&Lt(n))return void(kt=e);Ct(n);const r=Nt(n,e);if(o&&!s()&&(St(n.cursor),n.cursor.animate([{opacity:0},{opacity:1}],{duration:120,easing:"ease-out"})),!r)return;const i=Number(r.effect?.getTiming().duration)||240;await Promise.race([r.finished.catch(()=>{}),new Promise(e=>setTimeout(e,i+120))]),n.cursor.style.transform=At(e),r.cancel()}(e.point,t)}document.addEventListener("visibilitychange",()=>{"visible"===document.visibilityState&&Tt&&Et&&(document.fullscreenElement&&vt&&vt.el.parentElement!==document.fullscreenElement&&(vt.el.remove(),vt=null,wt=null),Rt(Et,"arrow"!==Et.marker).catch(()=>{}))});let Ht=null,Ot=null,Pt=null,_t=null,Bt="";function Ut(e){const t=e.replace(/\s+/g," ").trim();return t.length>320?`${t.slice(0,319)}…`:t}function qt(e){e.preventDefault(),e.stopPropagation()}function zt(){_t&&(removeEventListener("scroll",_t,!0),removeEventListener("resize",_t),_t=null),Ot&&(Ot.frame.style.setProperty("opacity","0"),Ot.frame.getAnimations().forEach(e=>e.cancel()))}function Dt(){const e=Pt;if(!e)return{ok:!0,skipped:!0};const t=d(Ht,o,{role:"alertdialog",label:"BrowserZap: your turn"});if(Ht=t,!t)return Ot=null,{ok:!0,skipped:!0};Ot||(Ot=function(e){const t=c(),n=u({position:"absolute",left:"50%",bottom:"28px",transform:"translateX(-50%)",width:"min(440px, calc(100vw - 32px))","box-sizing":"border-box",display:"flex","flex-direction":"column","align-items":"flex-start",gap:"7px",padding:"12px 15px 13px","border-radius":"12px",background:"rgba(17, 17, 17, 0.96)",color:"#ffffff",border:`1px solid ${t.strong}`,"box-shadow":"0 12px 36px rgba(0, 0, 0, 0.42)",font:'500 13px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',"pointer-events":"none"}),o=u({font:'700 12px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',"letter-spacing":"0.06em","text-transform":"uppercase"},"Your turn"),r=u({"overflow-wrap":"anywhere","white-space":"pre-wrap"}),i=document.createElement("button");i.type="button",i.tabIndex=-1,i.textContent="Done",a(i,{appearance:"none",margin:"2px 0 0",padding:"6px 20px",border:"0","border-radius":"999px",background:t.strong,color:t.ink,font:'700 12.5px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',cursor:"pointer","pointer-events":"auto"}),i.addEventListener("pointerdown",qt),i.addEventListener("mousedown",qt),i.addEventListener("click",e=>{if(qt(e),e.isTrusted)try{chrome.runtime.sendMessage({source:"engine-handoff",type:"done",pauseId:Bt}).catch(()=>{})}catch{}}),n.append(o,r,i);const s=u({position:"absolute",left:"0",top:"0","box-sizing":"border-box","will-change":"transform",opacity:"0","pointer-events":"none"});s.setAttribute("data-bz-ring","field");const l=u({position:"absolute",inset:"0","box-sizing":"border-box",border:`2px solid ${t.strong}`,"border-radius":"8px","box-shadow":`0 0 0 3px ${t.soft}`,opacity:"0.9"});return s.append(l),e.append(s,n),{card:n,message:r,done:i,frame:s,box:l}}(t.root)),Ot.message.textContent=e.message,e.field||(e.field=function(e){if(!e)return null;if(e.ref){const t=B.refs.get(e.ref)?.el.deref();if(t?.isConnected)return t}if(e.name||e.label){const t=Ae({role:e.role,name:e.name,label:e.label,within:e.within});if(!("ok"in t))return t.el}return null}(e.target));const n=e.field,r=function(e){if(!e||null===gt(e))return!1;try{e.focus({preventScroll:!1})}catch{return!1}return bt()===e}(n);return function(e){if(!Ot)return;if(zt(),!e||!e.isConnected)return;const t=Ot,n=()=>{if(!e.isConnected)return;const n=e.getBoundingClientRect();a(t.frame,{width:`${Math.round(n.width+6)}px`,height:`${Math.round(n.height+6)}px`,transform:`translate3d(${Math.round(n.left-3)}px, ${Math.round(n.top-3)}px, 0)`,opacity:"1"})};n(),_t=n,addEventListener("scroll",_t,{capture:!0,passive:!0}),addEventListener("resize",_t,{passive:!0}),s()||t.box.animate([{opacity:.5,transform:"scale(1)"},{opacity:1,transform:"scale(1.015)"}],{duration:1100,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}(n),{ok:!0,ringed:Boolean(n),focused:r}}function Ft(e){if(!e||e===document.body||e===document.documentElement)return{};if(!z(e))return{};const t=D(e);if(t.width<=0||t.height<=0)return{};const n=Math.round(t.left+Math.min(t.width/2,18)),o=Math.round(t.top+t.height/2);if(n<0||o<0||n>innerWidth||o>innerHeight)return{};const{name:r}=P(e);return{point:{x:n,y:o},ref:ne(e,R(e),r,ee(e))}}function Gt(e){return!e||e instanceof HTMLTextAreaElement||e.isContentEditable?null:e.form??e.closest("form")}function jt(e){return e.querySelector("button[type=submit],button:not([type]),input[type=submit],input[type=image]")}function Wt(e){return!!e&&(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||(e instanceof HTMLInputElement?null!==gt(e):!0===e.isContentEditable))}document.addEventListener("visibilitychange",()=>{"visible"===document.visibilityState&&Pt&&Dt()});const Kt={ArrowDown:()=>({top:40}),ArrowUp:()=>({top:-40}),ArrowRight:()=>({left:40}),ArrowLeft:()=>({left:-40}),PageDown:e=>({top:e}),PageUp:e=>({top:-e}),Space:e=>({top:e}),Home:()=>({to:"start"}),End:()=>({to:"end"})},Xt="data-browserzap-upload",Yt={loadInfo:function(){const e=performance.getEntriesByType("navigation")[0],t=e=>"number"==typeof e&&e>0?Math.round(e):null;return{ok:!0,docId:B.docId,readyState:document.readyState,httpStatus:e?.responseStatus||null,ttfbMs:t(e?.responseStart),domContentLoadedMs:t(e?.domContentLoadedEventStart),loadMs:t(e?.loadEventEnd)}},busyState:function(){let e=null;for(const t of Array.from(document.querySelectorAll(Ne))){if(!z(t))continue;const n=t.getAttribute("role"),o=f(t.innerText??t.textContent);if("status"!==n&&"alert"!==n||Ie.test(o)){if(("progressbar"===n||"PROGRESS"===t.tagName)&&("PROGRESS"===t.tagName?t.hasAttribute("value"):t.hasAttribute("aria-valuenow"))&&!Ie.test(`${o} ${t.getAttribute("aria-label")??""}`))continue;e=m(o||t.getAttribute("aria-label")||n||t.tagName.toLowerCase(),60);break}}return{ok:!0,docId:B.docId,readyState:document.readyState,mutations:B.mutations,indicator:e}},recordStart:function(){if(Re)return{ok:!0,recording:!0};const e=e=>{if(!e.isTrusted)return;const t=function(e){let t=e instanceof Element?e:null;for(;t&&!_(t);)t=y(t);return t}(e.composedPath()[0]??null);if(!t||Be(t)||t instanceof HTMLSelectElement)return;if(t instanceof HTMLInputElement&&("checkbox"===t.type||"radio"===t.type))return;const n=B.mutations,o=location.href,{target:r,ambiguous:i,name:a}=Pe(t);_e({tool:"element_click",args:{target:r},label:`Click ${R(t)} "${a||"(unnamed)"}"`,ambiguous:i,expectChange:!0});const s=`${B.docId}-${He}`;setTimeout(()=>{if(B.mutations===n&&location.href===o)try{chrome.runtime.sendMessage({source:"engine-recorder",patch:{id:s,expectChange:!1}})}catch{}},800)},t=e=>{if(!e.isTrusted)return;const t=e.composedPath()[0];if(t instanceof Element)if(Be(t))Ue(t);else if(t instanceof HTMLInputElement&&("checkbox"===t.type||"radio"===t.type)){if("radio"===t.type&&!t.checked)return;const{target:e,ambiguous:n,name:o}=Pe(t);_e({tool:"field_fill",args:{target:e,value:String(t.checked)},label:`${t.checked?"Check":"Uncheck"} "${o}"`,ambiguous:n})}else if(t instanceof HTMLSelectElement){const e=t.selectedOptions[0];if(!e)return;const{target:n,ambiguous:o,name:r}=Pe(t),i=f(e.label||e.text);_e({tool:"select_option",args:{target:n,option:{label:i}},label:`Choose "${i}" in "${r}"`,ambiguous:o})}},n=e=>{const t=e;if(!t.isTrusted||"Enter"!==t.key||t.isComposing)return;const n=t.composedPath()[0];n instanceof HTMLInputElement&&Be(n)&&(Ue(n),_e({tool:"browser_press_key",args:{key:"Enter"},label:"Press Enter",expectChange:!0}))};return document.addEventListener("click",e,!0),document.addEventListener("change",t,!0),document.addEventListener("keydown",n,!0),Re={off:()=>{document.removeEventListener("click",e,!0),document.removeEventListener("change",t,!0),document.removeEventListener("keydown",n,!0)}},{ok:!0,recording:!0}},recordStop:function(){return Re?.off(),Re=null,{ok:!0,recording:!1}},commentStart:function(e){if(ze)return{ok:!0,on:!0};const t=d(null,r);if(!t)return{ok:!0,on:!0};const n=c(),o=u({position:"fixed",left:"0",top:"0",display:"none","box-sizing":"border-box",border:`2px solid ${n.strong}`,background:n.soft,"border-radius":"3px"}),s=u({position:"absolute",left:"0",bottom:"100%","margin-bottom":"2px",background:n.strong,color:n.ink,font:"600 11px/1.3 system-ui, sans-serif",padding:"1px 6px","border-radius":"3px","white-space":"nowrap"});o.appendChild(s);const l=u({position:"fixed",top:"8px",left:"50%",transform:"translateX(-50%)",background:"#1b1b1b",color:"#f5f5f5",font:"600 12px/1.3 system-ui, sans-serif",padding:"6px 12px","border-radius":"999px","box-shadow":"0 2px 10px rgba(0,0,0,.3)",border:`1px solid ${n.strong}`},"Comment mode — click an element to comment · Esc to finish");t.root.append(o,l);const f=e=>{const t=e.composedPath()[0];return t instanceof Element&&!i(t)?t:null},p=e=>{if(!ze||ze.card||Ge(e))return;const t=f(e);t&&t!==document.documentElement&&t!==document.body&&(ze.picked=t,s.textContent=Ke(t),ze.highlight.style.display="block",Xe(ze.highlight,t))},m=e=>{Ge(e)||(e.preventDefault(),e.stopImmediatePropagation())},h=e=>{if(Ge(e))return;if(m(e),!e.isTrusted||!ze)return;const t=f(e);t&&(ze.picked=t,s.textContent=Ke(t),ze.highlight.style.display="block",Xe(ze.highlight,t),function(e){if(!ze)return;Ze();const t=c(),n=e.getBoundingClientRect(),o=u({position:"fixed",left:`${Math.min(Math.max(n.left,8),innerWidth-300-8)}px`,top:`${n.bottom+170<innerHeight?n.bottom+8:Math.max(n.top-170,8)}px`,width:"300px","box-sizing":"border-box",background:"#1b1b1b",color:"#f5f5f5","border-radius":"10px",padding:"10px","pointer-events":"auto","box-shadow":"0 8px 28px rgba(0,0,0,.35)",font:'13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif',border:`1px solid ${t.strong}`}),r=u({"font-weight":"600","margin-bottom":"6px",overflow:"hidden","text-overflow":"ellipsis","white-space":"nowrap"},`Comment on ${Ke(e)}`),i=document.createElement("textarea");i.placeholder="What should change here?",i.maxLength=2e3,i.rows=3,a(i,{width:"100%","box-sizing":"border-box",resize:"vertical","border-radius":"6px",border:"1px solid #444",background:"#262626",color:"#f5f5f5",padding:"6px",font:"inherit"});const s=u({display:"flex",gap:"6px","justify-content":"flex-end","margin-top":"8px","align-items":"center"}),l=u({"margin-right":"auto",color:"#a3a3a3","font-size":"11px"},"Ctrl+Enter to save · Esc to cancel"),d=(e,n)=>{const o=document.createElement("button");return o.type="button",o.textContent=e,a(o,{border:n?"none":"1px solid #555",background:n?t.strong:"transparent",color:n?t.ink:"#eee","border-radius":"6px",padding:"4px 12px",cursor:"pointer",font:"inherit","font-weight":"600"}),o},f=d("Cancel",!1),p=d("Save",!0),m=()=>{const e=i.value.trim();if(!e||!ze?.picked)return;const t=ze.picked,n=`c-${Date.now().toString(36)}-${++De}`;t.setAttribute(qe,n),Ze(),ze.highlight.style.display="none",ze.picked=null,Fe({type:"add",cid:n,text:e,info:We(t),page:{url:location.href,title:document.title.slice(0,200),viewport:{width:innerWidth,height:innerHeight},devicePixelRatio}})};p.addEventListener("click",e=>{e.isTrusted&&m()}),f.addEventListener("click",e=>{e.isTrusted&&(Ze(),ze&&(ze.picked=null,ze.highlight.style.display="none"))}),i.addEventListener("keydown",e=>{e.stopPropagation(),e.isTrusted&&("Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),m()),"Escape"===e.key&&(e.preventDefault(),Ze(),ze&&(ze.picked=null,ze.highlight.style.display="none")))}),s.append(l,f,p),o.append(r,i,s),ze.host.root.appendChild(o),ze.card=o,i.focus()}(t))},g=e=>{e.isTrusted&&"Escape"===e.key&&!Ge(e)&&(e.preventDefault(),ze?.card?Ze():Fe({type:"exit"}))},b=["pointerdown","pointerup","mousedown","mouseup","dblclick","contextmenu","auxclick","submit"];window.addEventListener("pointermove",p,!0),window.addEventListener("click",h,!0);for(const e of b)window.addEventListener(e,m,!0);window.addEventListener("keydown",g,!0),window.addEventListener("scroll",Ve,!0),window.addEventListener("resize",Ve,!0),ze={host:t,highlight:o,label:s,card:null,picked:null,pins:new Map,masks:[],frame:0,next:1,off:()=>{window.removeEventListener("pointermove",p,!0),window.removeEventListener("click",h,!0);for(const e of b)window.removeEventListener(e,m,!0);window.removeEventListener("keydown",g,!0),window.removeEventListener("scroll",Ve,!0),window.removeEventListener("resize",Ve,!0)}};for(const t of Array.isArray(e.pins)?e.pins:[]){let e=null;try{e=t.domPath?document.querySelector(t.domPath):null}catch{e=null}e&&Qe({cid:t.cid,n:t.n,el:e})}return{ok:!0,on:!0}},commentStop:function(){return ze?(ze.off(),ze.frame&&cancelAnimationFrame(ze.frame),ze.host.el.remove(),document.querySelectorAll(`[${qe}]`).forEach(e=>e.removeAttribute(qe)),ze=null,{ok:!0,on:!1}):{ok:!0,on:!1}},commentPin:Qe,commentUnpin:function(e){const t=String(e.cid??"");return ze?.pins.get(t)?.badge.remove(),ze?.pins.delete(t),document.querySelectorAll(`[${qe}="${CSS.escape(t)}"]`).forEach(e=>e.removeAttribute(qe)),{ok:!0}},commentCaptureStart:async function(e){if(!ze)return{ok:!1};const t=String(e.cid??"");let n=null;try{n=document.querySelector(`[${qe}="${CSS.escape(t)}"]`)}catch{n=null}for(const e of Array.from(ze.host.root.children))e.style.visibility="hidden";q();for(const e of Array.from(document.querySelectorAll('input, textarea, [contenteditable=""], [contenteditable="true"]'))){const{name:t}=P(e);if(!j(e,t))continue;const n=e.getBoundingClientRect();if(n.width<1||n.height<1||n.bottom<0||n.top>innerHeight)continue;const o=u({position:"fixed",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,background:"#3a3a3a"});ze.host.root.appendChild(o),ze.masks.push(o)}await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e())));const o=n?.getBoundingClientRect();return{ok:!0,rect:o?{x:o.x,y:o.y,width:o.width,height:o.height}:null,viewport:{width:innerWidth,height:innerHeight},devicePixelRatio}},commentCaptureEnd:function(){if(!ze)return{ok:!0};for(const e of ze.masks)e.remove();ze.masks=[];for(const e of Array.from(ze.host.root.children))e.style.visibility="";return ze.picked||(ze.highlight.style.display="none"),{ok:!0}},snapshot:function(e){const t=Math.min(Number(e.maxElements)||150,400),n=!1!==e.includeText,o=Math.min(Number(e.maxTextChars)||4e3,2e4);B.snapshotId+=1;const r=re(),i=r.filter(oe),a=ke();let s=a?i.filter(e=>v(a,e.el)):i;const l="string"==typeof e.within&&e.within?e.within:null;l&&(s=Ee(s,l)),function(){if(!(B.refs.size<2e3))for(const[e,t]of B.refs)t.el.deref()||B.refs.delete(e)}();const c=[];let u=0,d=!1;const g=e=>{if(c.length>=t)return!1;const n=(e=>{const t=ee(e.el),n={ref:ne(e.el,e.role,e.name,t),role:e.role,name:m(e.name,100),...W(e.el)};"placeholder"!==e.source&&"none"!==e.source||(n.nameSource=e.source),t&&(n.context=m(t,60)),e.el instanceof HTMLAnchorElement&&e.el.href&&(n.href=m(e.el.href,200)),j(e.el,e.name)&&(n.sensitive=!0);const o=e.el.getBoundingClientRect();return(o.bottom<0||o.top>innerHeight)&&(n.offscreen=!0),n})(e),o=JSON.stringify(n).length;return!(u+o>98304||(u+=o,c.push(n),0))};for(const e of s)if(!g(e)){d=!0;break}const b=ge(),x=(a?b.filter(e=>v(a,e.el)):b).filter(oe),y=l?Ee(x,l):x;let w=0,k=!1;for(const e of y){if(w>=60||!g(e)){k=!0;break}w+=1}const E=l?p(l):null,T=Array.from(document.querySelectorAll("h1,h2,h3,h4,h5,h6")).filter(e=>z(e)).filter(e=>!E||p(h(e))===E||J(e).some(e=>p(e)===E)).slice(0,40).map(e=>({level:Number(e.tagName[1]),text:m(h(e),100)})),A=Array.from(document.querySelectorAll("iframe,frame")),S=A.filter(e=>{try{return!e.contentDocument}catch{return!0}}).length;let M,$=!1;if(n){const e=f(document.body?.innerText??"");$=e.length>o,M=e.slice(0,o)}return{ok:!0,snapshotId:`s${B.snapshotId}`,docId:B.docId,url:location.href,title:m(document.title,200),elements:c,headings:T,text:M,challenge:se(),siteError:mt(!0===e.network5xx),counts:{interactive:r.length,visible:i.length,returned:c.length,hidden:r.length-i.length,...a||l?{inScope:s.length}:{},...y.length?{clickable:y.length,clickableReturned:w}:{}},modal:a?{name:m(P(a).name||K(a),100),outside:i.length-(a?i.filter(e=>v(a,e.el)).length:0)}:null,within:l,limits:{truncated:d,textTruncated:$,clickableTruncated:k,frames:A.length,crossOriginFrames:S,note:[a?"A modal dialog is open: only its controls are listed and can be targeted. Close it to reach the page behind.":"",l&&0===s.length&&0===y.length?`No visible controls are inside "${m(l,80)}".`:"",k?`Only ${w} of ${y.length} clickable region(s) are listed; use within to narrow the page.`:"",S?"Controls inside cross-origin frames are not inspected.":""].filter(Boolean).join(" ")||void 0}}},siteError:function(e){return{ok:!0,docId:B.docId,siteError:mt(!0===e.network5xx)}},fileInput:function(e){const t=String(e.phase??"mark"),n=String(e.mark??"");if("unmark"===t)return document.querySelectorAll(`[${Xt}]`).forEach(e=>e.removeAttribute(Xt)),{ok:!0};const o=Te(String(e.ref));if("ok"in o)return o;const r=o.el;return r instanceof HTMLInputElement&&"file"===r.type?r.disabled?{ok:!1,code:"TARGET_NOT_INTERACTABLE",message:"The file input is disabled."}:"check"===t?{ok:!0,files:r.files?.length??0,names:Array.from(r.files??[]).map(e=>e.name).slice(0,10)}:(n&&r.setAttribute(Xt,n),{ok:!0,multiple:r.multiple,accept:r.accept||null,files:r.files?.length??0}):{ok:!1,code:"TARGET_NOT_INTERACTABLE",message:`"${o.name||r.tagName.toLowerCase()}" is not a file input. Target the page's "Choose file" input itself.`}},resolve:ht,click:function(e){const t=Te(String(e.ref));if("ok"in t)return t;const n=F(t.el);if(!n)return we(ve(t.name),"is not visible.");const o=D(n);return o.width<=0||o.height<=0?we(ve(t.name),"has no visible area."):(function(e){e.scrollIntoView({block:"center",inline:"center",behavior:"instant"});const t=e.getBoundingClientRect(),n=t.left+t.width/2,o=t.top+t.height/2,r={bubbles:!0,cancelable:!0,composed:!0,view:window,button:0,buttons:1,clientX:n,clientY:o,screenX:n,screenY:o,detail:1};try{const t={...r,pointerId:1,pointerType:"mouse",isPrimary:!0,width:1,height:1};e.dispatchEvent(new PointerEvent("pointerdown",t)),e.dispatchEvent(new MouseEvent("mousedown",r)),e.dispatchEvent(new PointerEvent("pointerup",{...t,buttons:0})),e.dispatchEvent(new MouseEvent("mouseup",{...r,buttons:0}))}catch{}"function"==typeof e.click?e.click():e.dispatchEvent(new MouseEvent("click",{...r,buttons:0}))}(n),{ok:!0,ref:e.ref,method:"dom",hidden:x(),state:W(t.el),mutations:B.mutations})},cursor:async function(e){const t=String(e.phase??"move");if("hide"===t)return function(e){if(Tt=!1,Et=null,kt=null,!vt)return;const t=vt;if(vt=null,wt=null,e||s()||"function"!=typeof t.el.animate)return void t.el.remove();const n=()=>t.el.remove();t.el.animate([{opacity:1},{opacity:0}],{duration:140,easing:"ease-out"}).finished.then(n).catch(n),setTimeout(n,220)}(!0===e.immediate),{ok:!0};if("idle"===t)return{ok:!0};const n=e.point;if(!n||!Number.isFinite(n.x)||!Number.isFinite(n.y))return{ok:!0,skipped:!0};const o=e.rect,r={phase:t,point:n,label:"string"==typeof e.label?e.label.slice(0,24):"",rect:o&&Number.isFinite(o.width)&&Number.isFinite(o.height)?{x:o.x,y:o.y,width:o.width,height:o.height}:null,marker:"arrow"===e.marker?"arrow":"caret"};return Et=r,"visible"!==document.visibilityState?{ok:!0,skipped:!0}:(Tt=!0,await Rt(r,"arrow"!==r.marker),"move"===t?{ok:!0,mutations:B.mutations}:{ok:!0})},indicator:function(e){const o=String(e.phase??"show");return"hide"===o?(at(!0===e.immediate),st(),{ok:!0}):"visible"!==document.visibilityState?{ok:!0,skipped:!0}:"ring"===o?(function(e){const t=B.refs.get(e)?.el.deref();if(!t||!t.isConnected)return void st();st();const o=d(null,n);if(!o)return;const r=c(),i=u({position:"absolute",left:"0",top:"0","will-change":"transform","pointer-events":"none"}),l=u({position:"absolute",inset:"0","box-sizing":"border-box",border:`2px solid ${r.strong}`,"border-radius":"8px","box-shadow":`0 0 0 3px ${r.soft}`,opacity:"0.9"});i.append(l),o.root.append(i);const f=()=>{if(!t.isConnected)return void st();const e=t.getBoundingClientRect();a(i,{width:`${Math.round(e.width+6)}px`,height:`${Math.round(e.height+6)}px`,transform:`translate3d(${Math.round(e.left-3)}px, ${Math.round(e.top-3)}px, 0)`})};f(),nt={host:o,follow:f},ot=setTimeout(()=>st(),12e4),s()||(l.animate([{opacity:.5,transform:"scale(1)"},{opacity:1,transform:"scale(1.015)"}],{duration:1100,iterations:1/0,direction:"alternate",easing:"ease-in-out"}),addEventListener("scroll",f,{capture:!0,passive:!0}),addEventListener("resize",f,{passive:!0}))}(String(e.ref??"")),{ok:!0}):"ringHide"===o?(st(),{ok:!0}):(r="idle"===o?1500:3e4,function(){if(Je?.el.isConnected&&et)return et;const e=d(Je,t);return Je=e,e?(et=function(e){const t=c(),n=u({position:"absolute",inset:"0","box-sizing":"border-box",border:`2px solid ${t.strong}`,"box-shadow":`inset 0 0 26px ${t.soft}`,opacity:"0.9","pointer-events":"none"}),o=u({position:"absolute",left:"0",right:"0",bottom:"22px",display:"flex","justify-content":"center","pointer-events":"none"}),r=u({display:"flex","align-items":"center",gap:"9px",padding:"5px 6px 5px 12px","border-radius":"999px",background:"rgba(17, 17, 17, 0.9)",color:"#ffffff","box-shadow":"0 4px 18px rgba(0, 0, 0, 0.3)",font:'600 11.5px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',"white-space":"nowrap","pointer-events":"auto"}),i=u({width:"6px",height:"6px","border-radius":"50%",background:t.strong,"flex-shrink":"0"}),l=u({"letter-spacing":"0.01em",opacity:"0.94"},"BrowserZap · agent working"),d=document.createElement("button");d.type="button",d.tabIndex=-1,d.textContent="Stop",a(d,{appearance:"none",margin:"0",padding:"3px 11px",border:"0","border-radius":"999px",background:t.strong,color:t.ink,font:'700 11px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',cursor:"pointer"});const f=e=>{e.preventDefault(),e.stopPropagation()};return d.addEventListener("pointerdown",f),d.addEventListener("mousedown",f),d.addEventListener("click",e=>{if(f(e),e.isTrusted){try{chrome.runtime.sendMessage({source:"engine-control",type:"stop"}).catch(()=>{})}catch{}at(!1)}}),r.append(i,l,d),o.append(r),e.append(n,o),s()||r.animate([{opacity:0,transform:"translate3d(0, 6px, 0)"},{opacity:1,transform:"translate3d(0, 0, 0)"}],{duration:160,easing:"ease-out"}),{border:n,pill:r}}(e.root),s()||et.border.animate([{opacity:.45},{opacity:1}],{duration:1500,iterations:1/0,direction:"alternate",easing:"ease-in-out"}),et):(et=null,null)}()&&(rt(),tt=setTimeout(()=>at(!1),r)),{ok:!0});var r},handoff:function(e){const t=String(e.phase??"show");return"hide"===t?(zt(),Pt=null,Ht&&(Ht.el.remove(),Ht=null,Ot=null),{ok:!0}):(Ht?.el.isConnected||(Ht=null,Ot=null),"suppress"===t?(Ht&&Ht.el.style.setProperty("display","none"),{ok:!0}):"restore"===t?(Ht&&Ht.el.style.removeProperty("display"),{ok:!0}):(Pt={message:Ut(String(e.message??"The agent needs you to take over.")),target:e.target??void 0,field:null},Bt=String(e.pauseId??""),"visible"!==document.visibilityState?{ok:!0,skipped:!0}:Dt()))},fillPrepare:function(e){const t=ht({target:e.target,purpose:"fill",scroll:!0});if(!t.ok)return t;const n=Te(t.ref);if(t.sensitive)return ye("USER_ACTION_REQUIRED",`"${t.name}" is a sensitive field (${t.sensitive}). BrowserZap never types into it; ask the user to fill it.`,{target:{ref:t.ref,role:t.role,name:t.name},sensitive:t.sensitive});if(n.el instanceof HTMLInputElement&&("checkbox"===n.el.type||"radio"===n.el.type))return{...t,kind:"toggle",checked:n.el.checked};if(n.el instanceof HTMLSelectElement)return ye("UNSUPPORTED_CONTROL",`"${t.name}" is a <select>. Use select_option.`,{target:t});const o=gt(n.el);if(!o)return ye("UNSUPPORTED_CONTROL",`${t.role} "${t.name}" does not accept text.`,{target:t});if(o.readOnly)return ye("TARGET_NOT_INTERACTABLE",`"${t.name}" is read-only.`,{target:t});if(o.focus({preventScroll:!0}),o instanceof HTMLInputElement||o instanceof HTMLTextAreaElement)o instanceof HTMLTextAreaElement||["text","search","url","tel","password",""].includes(o.type)?o.select():o.value&&xt(o,"");else{const e=document.createRange();e.selectNodeContents(o);const t=getSelection();t?.removeAllRanges(),t?.addRange(e)}const r=v(o,bt());return"string"!=typeof e.value||t.challenge?{...t,kind:"text",focused:r}:{...t,kind:"text",focused:r,applied:yt({ref:t.ref,value:e.value})}},fillApply:yt,selectOption:function(e){const t=ht({target:e.target,purpose:"select",scroll:!0});if(!t.ok)return t;const n=Te(t.ref).el;if(!(n instanceof HTMLSelectElement))return ye("UNSUPPORTED_CONTROL",`${t.role} "${t.name}" is not a native <select>. Open it with element_click, then click the option.`,{target:t});const o=e.option??{},r=Array.from(n.options);let i=[];if(void 0!==o.value)i=r.filter(e=>e.value===o.value);else{if(void 0===o.label)return ye("INVALID_ARGUMENT","option needs a label or a value.");{const e=p(o.label);i=r.filter(t=>p(t.label||t.text)===e)}}if(!i.length)return ye("TARGET_NOT_FOUND",`No option matches in "${t.name}".`,{candidates:r.slice(0,20).map(e=>({ref:"",role:"option",name:m(f(e.label||e.text),100),value:e.value}))});if(i.length>1)return ye("TARGET_AMBIGUOUS",`${i.length} options match in "${t.name}". Select by value instead.`,{candidates:i.slice(0,8).map(e=>({ref:"",role:"option",name:f(e.label||e.text),value:e.value}))});const a=i[0];if(a.disabled)return ye("TARGET_NOT_INTERACTABLE",`Option "${f(a.label)}" is disabled.`);const s=n.value;n.focus({preventScroll:!0}),n.value=a.value,n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0}));const l=n.value===a.value&&n.selectedOptions[0]===a;return{ok:!0,ref:t.ref,name:t.name,selected:{label:m(f(a.label||a.text),100),value:a.value},changed:s!==n.value,verified:l,sensitive:t.sensitive,point:t.point,pageRect:t.pageRect}},observe:function(e){let t;if("string"==typeof e.ref){const n=B.refs.get(e.ref),o=n?.el.deref();t=o&&o.isConnected?{connected:!0,...W(o)}:{connected:!1}}const n={ok:!0,docId:B.docId,url:location.href,title:document.title,readyState:document.readyState,mutations:B.mutations,target:t};if("number"==typeof e.since){const t=function(e){if(e>=B.mutations)return{count:0,quietMs:null};const t=performance.now();if($e.length&&$e[0].seq>e+1)return{count:2e3,quietMs:0};let n=t;const o=new Set;for(let r=$e.length-1;r>=0;r--){const i=$e[r];if(i.seq>e)continue;if(n===t&&(n=i.at),i.at<n-1500)break;const a=i.node.deref();a&&o.add(a)}const r=new Set;let i=null,a=0;for(let n=$e.length-1;n>=0&&$e[n].seq>e;n--){const e=$e[n].node.deref();if(!e||r.has(e))continue;if(r.add(e),o.has(e)||Le(e,t))continue;a++;const s=Me.get(e)?.last??t;(null===i||s>i)&&(i=s)}return{count:a,quietMs:null===i?null:Math.round(t-i)}}(e.since);n.changes=t.count,n.changeQuietMs=t.quietMs}if(e.expect&&"object"==typeof e.expect){const t=function(e){const t={ok:!0,docId:B.docId,url:location.href};if("string"==typeof e.text&&(t.text=p(document.body?.innerText).includes(p(e.text))),e.target){const n=Ae(e.target);t.target=!("ok"in n)&&oe(n),t.targetAmbiguous="ok"in n&&"TARGET_AMBIGUOUS"===n.code,t.targetAmbiguous&&(t.targetCandidates=("candidates"in n?n.candidates:void 0)??[])}if(e.targetGone){const n=Ae(e.targetGone);t.targetGone="ok"in n?"TARGET_NOT_FOUND"===n.code||"STALE_SNAPSHOT"===n.code:!oe(n)}return t}(e.expect);n.expect={text:t.text,target:t.target,targetGone:t.targetGone,ambiguous:t.targetAmbiguous,candidates:t.targetCandidates}}return n},keyContext:function(e){const t=bt(),n=String(e.key??""),o={ok:!0,docId:B.docId,url:location.href,hidden:x(),...Ft(t)};if("Enter"!==n||!t)return{...o,risk:"reversible"};if(t instanceof HTMLButtonElement||t instanceof HTMLAnchorElement&&t.href||t instanceof HTMLInputElement&&["submit","image","button"].includes(t.type)){const{name:e}=P(t),n=R(t);return{...o,risk:ae(t,n,e),submits:{role:n,name:m(e,100),fingerprint:te(n,e)},challenge:se()}}const r=Gt(t);if(!r)return{...o,risk:"reversible"};const i=jt(r),a=i?P(i).name:K(r)||"form",s=i?R(i):"form",l=i?ae(i,s,a):"post"===r.method.toLowerCase()?"external_side_effect":"reversible";return{...o,risk:l,submits:{role:s,name:m(a,100),fingerprint:te(s,a)},challenge:se()}},pressKey:function(e){const t=String(e.key??""),n=new Set(Array.isArray(e.modifiers)?e.modifiers:[]),o=bt()??document.body??document.documentElement,r=Number(e.keyCode)||0,i={key:"Space"===t?" ":t,code:String(e.code??t),keyCode:r,which:r,bubbles:!0,cancelable:!0,composed:!0,view:window,altKey:n.has("alt"),ctrlKey:n.has("ctrl"),metaKey:n.has("meta"),shiftKey:n.has("shift")},a=o.dispatchEvent(new KeyboardEvent("keydown",i));!a||"Enter"!==t&&"Space"!==t||o.dispatchEvent(new KeyboardEvent("keypress",i));let s="none";return!a||i.altKey||i.ctrlKey||i.metaKey||(s=function(e,t,n){const o=t,r=t instanceof HTMLButtonElement||"SUMMARY"===t.tagName||t instanceof HTMLInputElement&&["button","submit","reset","image","checkbox","radio"].includes(t.type);if("Enter"===e){if(t instanceof HTMLAnchorElement&&t.href)return o.click(),"activate";if(t instanceof HTMLButtonElement||"SUMMARY"===t.tagName)return o.click(),"activate";const e=Gt(t);if(e&&t instanceof HTMLInputElement&>(t)){const t=jt(e);if(t){if(G(t))return"none";t.click()}else e.requestSubmit();return"submit"}return"none"}if("Space"===e&&r)return o.click(),"activate";if("Tab"===e){const e=function(){const e=[];for(const t of g(document)){const n=t;"number"!=typeof n.tabIndex||n.tabIndex<0||G(t)||t instanceof HTMLInputElement&&"hidden"===t.type||z(t)&&e.push(n)}return[...e.filter(e=>e.tabIndex>0).sort((e,t)=>e.tabIndex-t.tabIndex),...e.filter(e=>0===e.tabIndex)]}();if(!e.length)return"none";const t=e.indexOf(o);return(t<0?e[n?e.length-1:0]:e[(t+(n?-1:1)+e.length)%e.length]).focus(),"focus"}if("Escape"===e){const e=b();return e&&e.dispatchEvent(new Event("cancel",{cancelable:!0}))?(e.close(),"closeDialog"):"none"}if(("Backspace"===e||"Delete"===e)&&Wt(t))return document.execCommand("Backspace"===e?"delete":"forwardDelete"),"delete";const i=Kt[e];if(i&&!Wt(t)&&!r){const t=i(Math.round(.875*innerHeight));return t.to?scrollTo({top:"start"===t.to?0:document.documentElement.scrollHeight,behavior:"instant"}):window.scrollBy({top:(n&&"Space"===e?-1:1)*(t.top??0),left:t.left??0,behavior:"instant"}),"scroll"}return"none"}(t,o,Boolean(i.shiftKey))),o.dispatchEvent(new KeyboardEvent("keyup",i)),{ok:!0,method:"dom",prevented:!a,defaultAction:s,mutations:B.mutations}},scroll:function(e){const t=Math.min(Math.max(Number(e.amount)||600,1),5e3),n=String(e.direction??"down"),o="left"===n?-t:"right"===n?t:0,r="up"===n?-t:"down"===n?t:0;let i=window;if(e.target){const t=Ae(e.target);if("ok"in t)return t;i=t.el}const a=()=>i===window?{x:scrollX,y:scrollY}:{x:i.scrollLeft,y:i.scrollTop},s=a();i.scrollBy({left:o,top:r,behavior:"instant"});const l=a();return{ok:!0,moved:s.x!==l.x||s.y!==l.y,position:l,atEnd:i===window&&innerHeight+scrollY>=document.documentElement.scrollHeight-2}}};14!==globalThis.__browserzapEngine?.version&&(globalThis.__browserzapEngine={version:14,run(e,t){const n=Object.prototype.hasOwnProperty.call(Yt,e)?Yt[e]:void 0;if(!n)return ye("INVALID_ARGUMENT",`Unknown engine operation: ${e}`);q();try{return n(t??{})}catch(e){return ye("INTERNAL",e instanceof Error?e.message:String(e))}finally{q()}}})})();
|
|
1
|
+
(()=>{"use strict";const e="data-browserzap-cursor",t="data-browserzap-control",n="data-browserzap-approval",o="data-browserzap-approve",r="data-browserzap-note",i="data-browserzap-handoff",a="data-browserzap-comment";function s(s){return s instanceof Element&&(s.hasAttribute(e)||s.hasAttribute(t)||s.hasAttribute(n)||s.hasAttribute(o)||s.hasAttribute(r)||s.hasAttribute(i)||s.hasAttribute(a))}function l(e,t){for(const[n,o]of Object.entries(t))e.style.setProperty(n,o)}function c(){try{return matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function u(e){if(!e)return null;let t="";try{t=getComputedStyle(e).backgroundColor}catch{return null}const n=/^rgba?\(([^)]+)\)$/.exec(t);if(!n)return null;const o=n[1].split(",").map(e=>Number(e.trim())),[r,i,a]=o,s=o.length>3?o[3]:1;return![r,i,a,s].every(Number.isFinite)||s<.5?null:.2126*r+.7152*i+.0722*a}function d(){return(u(document.body)??u(document.documentElement)??255)<110?{strong:"#ff922b",soft:"rgba(255, 146, 43, 0.30)",ink:"#1a0d04"}:{strong:"#d9480f",soft:"rgba(217, 72, 15, 0.18)",ink:"#ffffff"}}function p(e,t){const n=document.createElement("div");return l(n,e),void 0!==t&&(n.textContent=t),n}function f(e,t,n){if(e?.el.isConnected)return e;e?.el.remove();const o=document.fullscreenElement??document.documentElement;if(!o)return null;const r=document.createElement("div");r.setAttribute(t,""),n?(r.setAttribute("role",n.role),r.setAttribute("aria-label",n.label)):r.setAttribute("aria-hidden","true"),l(r,{position:"fixed",inset:"0","z-index":"2147483647","pointer-events":"none",overflow:"visible"});const i=r.attachShadow({mode:"closed"});return o.appendChild(r),{el:r,root:i}}function m(e){return(e??"").replace(/\s+/g," ").trim()}function h(e){return m(e).toLowerCase()}function g(e,t){return e.length>t?`${e.slice(0,t-1)}…`:e}function b(e,t=!1){const n=[],o=r=>{if(r.nodeType===Node.TEXT_NODE)return void n.push(r.textContent??"");if(r.nodeType!==Node.ELEMENT_NODE)return;const i=r,a=i.tagName;if("SCRIPT"===a||"STYLE"===a||"TEMPLATE"===a)return;if(t&&("INPUT"===a||"SELECT"===a||"TEXTAREA"===a||"BUTTON"===a))return;if("IMG"===a)return void n.push(` ${i.getAttribute("alt")??""} `);const s=i!==e&&function(e){const t=e.ownerDocument.defaultView?.getComputedStyle(e).display??"inline";return"inline"!==t&&"contents"!==t&&"none"!==t}(i);s&&n.push(" ");for(const e of Array.from(i.childNodes))o(e);s&&n.push(" ")};return o(e),m(n.join(""))}function*x(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let n=t.nextNode();for(;n;){const e=n;yield e,e.shadowRoot&&(yield*x(e.shadowRoot)),n=t.nextNode()}}function y(){const e=Array.from(document.querySelectorAll("dialog[open]"));for(let t=e.length-1;t>=0;t--)if(e[t].matches(":modal"))return e[t];return null}function v(){return"hidden"===document.visibilityState}function w(e){if(e.parentElement)return e.parentElement;const t=e.getRootNode();return t instanceof ShadowRoot?t.host:null}function k(e,t){let n=t;for(;n;){if(n===e)return!0;n=w(n)}return!1}function E(e,t){const n=e.getRootNode();try{return n.querySelector(`#${CSS.escape(t)}`)??document.getElementById(t)}catch{return null}}const T=String.raw`pass(word|code|phrase)?\b|\bpwd\b|\bpin\b|\botp\b|one[-\s]?time|2fa|\bmfa\b|security code|verification code|\bcvv\b|\bcvc\b|\bcsc\b|card ?number|credit ?card|social security|\bssn\b|\biban\b|routing number|account number|tax id|national id|passport`,A=new Set(["button","link","checkbox","radio","switch","tab","menuitem","menuitemcheckbox","menuitemradio","option","combobox","listbox","textbox","searchbox","slider","spinbutton","treeitem","gridcell"]),S=new Set(["button","link","checkbox","radio","switch","tab","menuitem","menuitemcheckbox","menuitemradio","option","treeitem","heading","gridcell","cell"]),M=new Set(["textbox","searchbox","spinbutton","combobox"]),$=/\b(delete|remove|erase|destroy|discard|deactivate|terminate|revoke|unsubscribe|close (my )?account|cancel (my |the )?(subscription|order|plan|membership))\b/i,L=/\b(pay|payment|purchase|buy|checkout|check out|place (the |my )?order|submit order|order now|complete (the )?order|donate|transfer|send money|subscribe|upgrade)\b/i,C=/\b(submit|send|post|publish|share|tweet|reply|comment|confirm|apply|book|reserve|sign up|invite|save changes|approve|accept|merge|deploy)\b/i,N=new RegExp(T,"i"),I=/\b(verify (that )?you('re| are) (a )?human|are you a robot|i'?m not a robot|human verification|security check|captcha|checking your browser)\b/i,R=/\b(two[- ]factor|2fa|multi[- ]factor|verification code|one[- ]time (pass)?code|authenticator app|enter the code)\b/i,H={checkbox:"checkbox",radio:"radio",button:"button",submit:"button",reset:"button",image:"button",range:"slider",number:"spinbutton",search:"searchbox",file:"button",color:"button"};function O(e){const t=m(e.getAttribute("role")).split(" ")[0];if(t)return t.toLowerCase();switch(e.tagName.toLowerCase()){case"a":case"area":return e.hasAttribute("href")?"link":"generic";case"button":case"summary":return"button";case"select":{const t=e;return t.multiple||t.size>1?"listbox":"combobox"}case"textarea":return"textbox";case"input":{const t=(e.type||"text").toLowerCase();return H[t]??"textbox"}case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return"heading";case"img":return"img";default:return e.isContentEditable?"textbox":"generic"}}function P(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function _(e){return P(e)&&e.labels?Array.from(e.labels):[]}function B(e){const t=m(e.getAttribute("aria-labelledby"));if(t){const n=m(t.split(" ").map(t=>E(e,t)).filter(e=>Boolean(e)).map(e=>b(e)).join(" "));if(n)return{name:n,source:"aria-labelledby"}}const n=m(e.getAttribute("aria-label"));if(n)return{name:n,source:"aria-label"};if(e instanceof HTMLInputElement){const t=e.type.toLowerCase();if("submit"===t||"button"===t||"reset"===t){const n="submit"===t?"Submit":"reset"===t?"Reset":"";return{name:m(e.value)||n,source:"value"}}if("image"===t)return{name:m(e.alt)||"Submit",source:"alt"}}if(P(e)){const t=m(_(e).map(e=>b(e,!0)).join(" "));if(t)return{name:t,source:"label"}}if(e instanceof HTMLImageElement){const t=m(e.alt);if(t)return{name:t,source:"alt"}}const o=O(e);if(S.has(o)||"SUMMARY"===e.tagName){const t=b(e);if(t)return{name:t,source:"content"}}const r=m(e.getAttribute("title"));if(r)return{name:r,source:"title"};const i=m(e.getAttribute("placeholder"));return i?{name:i,source:"placeholder"}:{name:"",source:"none"}}function U(e){const t=e.tagName;if("INPUT"===t)return"hidden"!==e.type.toLowerCase();if("BUTTON"===t||"SELECT"===t||"TEXTAREA"===t||"SUMMARY"===t)return!0;if(("A"===t||"AREA"===t)&&e.hasAttribute("href"))return!0;const n=m(e.getAttribute("role")).split(" ")[0].toLowerCase();return!(!n||!A.has(n))||!0===e.isContentEditable&&null!==e.getAttribute("contenteditable")}const z={docId:function(){const e=new Uint8Array(8);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")}(),snapshotId:0,nextRef:1,refs:new Map,ids:new WeakMap,mutations:0},q={label:new Map,sibling:new Map};function D(){q.label=new Map,q.sibling=new Map}function F(e){const t=e;if("function"==typeof t.checkVisibility&&!t.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0}))return!1;const n=e.getBoundingClientRect();return!(n.width<=0||n.height<=0||e.closest('[inert],[aria-hidden="true"]'))}function G(e){return e.getClientRects()[0]??e.getBoundingClientRect()}function W(e){return F(e)?e:e instanceof HTMLInputElement&&("checkbox"===e.type||"radio"===e.type)?_(e).find(e=>F(e))??null:null}function j(e){if("true"===e.getAttribute("aria-disabled"))return!0;try{return e.matches(":disabled")}catch{return!1}}function K(e,t){if(!P(e)&&!e.isContentEditable)return null;if("password"===(e.getAttribute("type")??"").toLowerCase())return"password field";const n=(e.getAttribute("autocomplete")??"").toLowerCase();if(/\b(cc-[a-z-]+|current-password|new-password|one-time-code)\b/.test(n))return`autocomplete=${n}`;const o=[t,e.getAttribute("name"),e.id,e.getAttribute("aria-label"),e.getAttribute("placeholder")].join(" ").match(N);return o?`looks like "${o[0].toLowerCase()}"`:null}function X(e){const t={};if(j(e)&&(t.disabled=!0),e instanceof HTMLInputElement&&("checkbox"===e.type||"radio"===e.type)?t.checked=e.checked:e.hasAttribute("aria-checked")&&(t.checked="true"===e.getAttribute("aria-checked")),e.hasAttribute("aria-expanded")&&(t.expanded="true"===e.getAttribute("aria-expanded")),e.hasAttribute("aria-selected")&&(t.selected="true"===e.getAttribute("aria-selected")),e instanceof HTMLSelectElement){const n=e.selectedOptions[0];n&&(t.value=g(m(n.label||n.text),100)),t.options=e.options.length}else(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&(e.required&&(t.required=!0),e instanceof HTMLInputElement&&("checkbox"===e.type||"radio"===e.type)||(t.filled=e.value.length>0),e.readOnly&&(t.readonly=!0));return t}function Y(e){const t=q.label.get(e);if(void 0!==t)return t;const n=function(e){const t=m(e.getAttribute("aria-labelledby"));if(t){const n=m(t.split(" ").map(t=>E(e,t)).filter(Boolean).map(e=>b(e)).join(" "));if(n)return n}const n=m(e.getAttribute("aria-label"));if(n)return n;if(!e.matches("section,article,aside,nav,main,form,fieldset,dialog,header,footer,li,table,tr,[role=region],[role=group],[role=dialog],[role=alertdialog],[role=form],[role=tabpanel],[role=navigation],[role=complementary],[role=listitem],[role=row]"))return function(e){const t=e.parentElement;if(!t||!e.className||"string"!=typeof e.className)return!1;let n=q.sibling.get(t);if(!n){n=new Map;for(const e of Array.from(t.children)){if("string"!=typeof e.className||!e.className)continue;const t=`${e.tagName}.${e.className}`;n.set(t,(n.get(t)??0)+1)}q.sibling.set(t,n)}return(n.get(`${e.tagName}.${e.className}`)??0)>=2&&null!==e.querySelector(Q)}(e)?ee(e):"";const o=e.querySelector(":scope > :is(h1,h2,h3,h4,h5,h6,legend,caption), :scope > header :is(h1,h2,h3,h4,h5,h6)");return o?b(o):e.matches(V)?function(e){const t=Array.from(e.children).filter(e=>e.matches("th,td,[role=cell],[role=gridcell],[role=rowheader],[role=columnheader]")).filter(e=>!e.querySelector(Q)&&b(e)),n=t.find(e=>e.matches("th,[role=rowheader]"));return n?b(n):t[0]?b(t[0]):""}(e):e.matches(Z)?ee(e):""}(e);return q.label.set(e,n),n}const V="tr,[role=row]",Z="li,[role=listitem],article",Q='a[href],button,input:not([type=hidden]),select,textarea,summary,[role=button],[role=link],[role=checkbox],[role=radio],[role=switch],[role=tab],[role=menuitem],[role=option],[role=combobox],[role=textbox],[contenteditable=""],[contenteditable=true]',J=60;function ee(e){const t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);let n=0;for(let e=t.nextNode();e&&n<J;e=t.nextNode(),n++){const t=e;if(!(t.matches("label,script,style,template")||U(t)||t.querySelector(Q))&&(Array.from(t.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&m(e.textContent))&&F(t)))return g(b(t),60)}return""}function te(e){const t=[];let n=w(e);for(;n&&n!==document.documentElement;){const e=Y(n);e&&t.push(e),n=w(n)}return t}function ne(e){let t=w(e);for(;t&&t!==document.documentElement;){const e=Y(t);if(e)return e;t=w(t)}return""}function oe(e,t){return`${e}|${h(t)}`}function re(e,t,n,o){let r=z.ids.get(e);return r||(r="e"+z.nextRef++,z.ids.set(e,r)),z.refs.set(r,{el:new WeakRef(e),fingerprint:oe(t,n),context:o}),r}function ie(e){return e.visible??=e.proxy?null!==W(e.el):F(e.el),e.visible}function ae(){const e=[];for(const t of x(document)){if(!U(t))continue;const{name:n,source:o}=B(t);e.push({el:t,role:O(t),name:g(n,200),source:o,proxy:!0})}return e}function se(e){const t=ne(e.el);return{ref:re(e.el,e.role,e.name,t),role:e.role,name:g(e.name,100),context:t?g(t,60):void 0,visible:ie(e)}}function le(e,t,n){return P(e)&&M.has(t)?"reversible":$.test(n)?"destructive":L.test(n)?"financial":C.test(n)||(e instanceof HTMLButtonElement&&"submit"===e.type&&null!==e.form||e instanceof HTMLInputElement&&("submit"===e.type||"image"===e.type)&&null!==e.form)&&"post"===e.form.method.toLowerCase()?"external_side_effect":"reversible"}function ce(){if(document.querySelector('iframe[src*="recaptcha"],iframe[src*="hcaptcha"],iframe[src*="challenges.cloudflare.com"],iframe[title*="captcha" i],.g-recaptcha,.h-captcha,.cf-turnstile,#challenge-form,[data-sitekey]'))return{kind:"captcha",evidence:"a CAPTCHA widget is present"};const e=Array.from(document.querySelectorAll("h1,h2,h3,legend,[role=heading]")).filter(e=>F(e)).map(e=>b(e)).join(" | "),t=`${document.title} | ${e}`.match(I);if(t)return{kind:"captcha",evidence:`page asks: "${t[0]}"`};if(document.querySelector('input[autocomplete="one-time-code"]'))return{kind:"mfa",evidence:"a one-time-code field is present"};const n=e.match(R);return n?{kind:"mfa",evidence:`page asks: "${n[0]}"`}:null}function ue(e){return!(e.overlay||e.interactive||e.insideInteractive||e.insideClickableRegion)&&!!(e.cursorPointer||e.inlineOnClick||e.tabbable)&&!e.parentCursorPointer&&!e.containsInteractive&&e.visible&&e.enabled&&e.hasText}const de="clickable",pe=new Set,fe=new WeakSet;function me(e){try{return getComputedStyle(e).cursor}catch{return""}}function he(e,t){let n,o=null;const r=()=>void 0===n?n=w(e):n;let i=null,a=null,l=null;const c=()=>{if(l)return l;const e={interactive:!1,clickable:!1};for(let n=r();n;n=w(n))U(n)&&(e.interactive=!0),t.has(n)&&(e.clickable=!0);return l=e,e};return{get overlay(){return s(e)},get interactive(){return U(e)},get insideInteractive(){return c().interactive},get insideClickableRegion(){return c().clickable},get cursorPointer(){return"pointer"===(o??=me(e))},get inlineOnClick(){return e.hasAttribute("onclick")},get tabbable(){return e.tabIndex>=0},get parentCursorPointer(){const e=r();return null!==e&&"pointer"===(i??=me(e))},get containsInteractive(){return null!==e.querySelector(Q)},get visible(){return F(e)},get enabled(){return!j(e)},get hasText(){return(a??=ge(e)).length>0}}}function ge(e){const t=e.innerText;return m("string"==typeof t&&t?t:b(e))}function be(e){return g(ge(e),200)}function xe(){const e=new Set,t=[];for(const n of x(document))ue(he(n,e))&&(e.add(n),t.push({el:n,role:de,name:be(n),source:"content",proxy:!1}));return t}function ye(e){let t="";for(const n of Array.from(e.childNodes))n.nodeType===Node.TEXT_NODE&&(t+=n.textContent??"");return t}function ve(e){for(let t=w(e);t;t=w(t))if(U(t))return!0;return!1}function we(e,t,n={}){return{ok:!1,code:e,message:t,...n}}function ke(e){return`"${g(e,60)}"`}function Ee(e,t,n={}){return we("TARGET_NOT_INTERACTABLE",`${e} ${t}`,n)}function Te(){const e=y();if(e)return e;const t=Array.from(document.querySelectorAll('[aria-modal="true"]')).filter(e=>e.matches("dialog,[role=dialog],[role=alertdialog]")&&F(e));return t.length?t[t.length-1]:null}function Ae(e,t){const n=h(t),o=e.filter(e=>h(ne(e.el))===n);return o.length?o:e.filter(e=>te(e.el).some(e=>h(e)===n))}function Se(e){const t=z.refs.get(e),n=t?.el.deref();if(!t||!n)return we("STALE_SNAPSHOT",`Reference ${e} is unknown on this page. Run page_inspect again.`);if(!n.isConnected)return we("STALE_SNAPSHOT",`The element behind ${e} was removed from the page. Run page_inspect again.`,{staleFingerprint:t.fingerprint,staleContext:t.context});const o=function(e){return fe.has(e)||function(e){return ue(he(e,pe))}(e)?de:O(e)}(n),{name:r,source:i}=function(e,t){return t===de?{name:be(e),source:"content"}:B(e)}(n,o);return oe(o,r)!==t.fingerprint?we("STALE_SNAPSHOT",`The element behind ${e} changed (now ${o} "${g(r,40)}"). Run page_inspect again.`,{staleFingerprint:t.fingerprint,staleContext:t.context}):{el:n,role:o,name:r,source:i,proxy:!0}}function Me(e){if(e.ref)return Se(e.ref);const t=e.role?.toLowerCase(),n=!(t&&!A.has(t)&&"generic"!==t&&"clickable"!==t);let o=n?ae():function(e){const t=[];for(const n of x(document)){if(O(n)!==e)continue;const{name:o,source:r}=B(n);t.push({el:n,role:e,name:g(o,200),source:r,proxy:!1})}return t}(t);const r=n&&("clickable"===t||!t&&(Boolean(e.name)||Boolean(e.text)));r&&(o=o.concat(xe())),t&&(o=o.filter(e=>e.role===t)),n&&(o=function(e){const t=Te();return t?e.filter(e=>k(t,e.el)):e}(o)),e.within&&(o=Ae(o,e.within));const i=[],a=e.name??e.label??e.text;if(e.label){const t=h(e.label);i.push({label:"label",pick:e=>P(e.el)&&"placeholder"!==e.source&&h(e.name)===t})}if(e.href){const t=e.href;i.push({label:"href",pick:e=>e.el instanceof HTMLAnchorElement&&((e.el.getAttribute("href")??"")===t||e.el.href===t||e.el.pathname===t)})}if(e.name||e.text){const t=h(e.name??e.text);i.push({label:"name",pick:e=>"placeholder"!==e.source&&h(e.name)===t})}if(e.text){const t=h(e.text);i.push({label:"text",pick:e=>h(b(e.el))===t}),i.push({label:"text in a clickable region",pick:e=>"clickable"===e.role&&function(e,t){if(!t)return!1;const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT);for(let e=n.nextNode();e;e=n.nextNode()){const n=e;if(0===n.children.length&&h(b(n))===t)return!0}return!1}(e.el,t)}),i.push({label:"placeholder",pick:e=>h(e.el.getAttribute("placeholder"))===t})}if(!i.length&&e.role&&i.push({label:"role",pick:()=>!0}),!i.length)return we("INVALID_ARGUMENT","A target needs one of: ref, name, label, text, href (optionally with role and within).");for(const t of i){const n=o.filter(t.pick);if(!n.length)continue;const r=n.filter(ie),i=r.length?r:n;return 1===i.length?i[0]:we("TARGET_AMBIGUOUS",`${i.length} elements match ${$e(e)} by ${t.label}. Nothing was done. `+(i.length>50?"The first 50 are listed. ":"")+"Use a ref from the candidates, or add role/within (a candidate's context) to narrow it.",{candidates:i.slice(0,50).map(se)})}if(e.text&&r){let t=function(e,t){const n=new Set,o=[];if(!e)return o;for(const r of x(document)){if(t&&!k(t,r))continue;if(h(0===r.children.length?b(r):ye(r))!==e)continue;if(s(r)||U(r)||ve(r)||!F(r))continue;if(r.closest("th, thead, [role=columnheader]"))continue;const i=r.closest("tr, [role=row], li, [role=listitem]"),a=i&&!i.querySelector(Q)?i:r;n.has(a)||j(a)||(n.add(a),fe.add(a),o.push({el:a,role:de,name:be(a),source:"content",proxy:!1}))}return o}(h(e.text),Te());if(e.within&&(t=Ae(t,e.within)),1===t.length)return t[0];if(t.length>1)return we("TARGET_AMBIGUOUS",`${t.length} elements show ${$e(e)}. Nothing was done. Use a ref from the candidates, or add within (a candidate's context) to narrow it.`,{candidates:t.slice(0,50).map(se)})}const l=h(a??e.href??""),c=l?o.filter(e=>h(e.name).includes(l)&&ie(e)).slice(0,8).map(se):[];return we("TARGET_NOT_FOUND",`No element matches ${$e(e)}.`,c.length?{candidates:c}:{})}function $e(e){const t=[];return e.role&&t.push(`role=${e.role}`),e.name&&t.push(`name="${e.name}"`),e.label&&t.push(`label="${e.label}"`),e.text&&t.push(`text="${e.text}"`),e.href&&t.push(`href="${e.href}"`),e.within&&t.push(`within="${e.within}"`),t.join(" ")||"(empty target)"}const Le=new WeakMap,Ce=[];function Ne(e,t){const n=Le.get(e);return Boolean(n&&n.bursts.length>=3&&t-n.bursts[0]<3e3&&t-n.last<3e3)}function Ie(e){if("childList"!==e.type||0===e.addedNodes.length&&0===e.removedNodes.length)return!1;for(const t of e.addedNodes)if(!s(t))return!1;for(const t of e.removedNodes)if(!s(t))return!1;return!0}new MutationObserver(e=>{const t=performance.now();for(const n of e){if(Ie(n))continue;z.mutations+=1;let e=Le.get(n.target);e||(e={last:-1/0,bursts:[]},Le.set(n.target,e)),t-e.last>50&&(e.bursts.push(t),e.bursts.length>3&&e.bursts.shift()),e.last=t,Ce.push({seq:z.mutations,at:t,node:new WeakRef(n.target)}),Ce.length>2e3&&Ce.shift()}}).observe(document,{subtree:!0,childList:!0,attributes:!0,characterData:!0});const Re=['[aria-busy="true"]','[role="progressbar"]',"progress",'[role="status"]','[role="alert"]','[class*="spinner" i]','[class*="loading" i]','[class*="loader" i]','[id*="spinner" i]','[id*="loading" i]'].join(", "),He=/load|wait|fetch|progress|processing|please|searching|saving/i;let Oe=null,Pe=0;const _e=new WeakMap;function Be(e){D();const{name:t,source:n}=B(e),o=O(e),r=P(e)&&t&&"placeholder"!==n?{label:t}:t&&"placeholder"===n?{text:t}:{role:o,name:t},i=[ne(e),...te(e)].filter((e,t,n)=>e&&n.indexOf(e)===t);for(const n of[r,...i.map(e=>({...r,within:e}))]){if(!t)break;const o=Me(n);if("el"in o&&o.el===e)return{target:n,ambiguous:!1,name:t}}return{target:i[0]?{...r,within:i[0]}:r,ambiguous:!0,name:t}}function Ue(e,t){try{chrome.runtime.sendMessage({source:"engine-recorder",step:{...e,id:`${z.docId}-${++Pe}`},value:t})}catch{}}function ze(e){return e instanceof HTMLInputElement&&!["checkbox","radio","button","submit","reset","file","image","hidden","range","color"].includes(e.type)||e instanceof HTMLTextAreaElement}function qe(e){const t=e.value;if(_e.get(e)===t)return;_e.set(e,t);const{target:n,ambiguous:o,name:r}=Be(e),i=Boolean(K(e,r));Ue({tool:"field_fill",args:{target:n},label:`Type into "${r||"field"}"`,param:r||"value",sensitive:i,ambiguous:o},i?void 0:t)}const De="data-browserzap-comment-target";let Fe=null,Ge=0;function We(e){try{chrome.runtime.sendMessage({source:"engine-comment",...e})}catch{}}function je(e){return e.composedPath().some(e=>e instanceof Node&&s(e))}function Ke(e){const t=[];let n=e;for(;n&&t.length<6&&n!==document.documentElement&&n!==document.body;){let e=n.tagName.toLowerCase();if(n.id)e+=`#${n.id}`;else{const t=Array.from(n.classList).filter(e=>!/^\d/.test(e)).slice(0,2);t.length&&(e+=`.${t.join(".")}`);const o=w(n);if(o){const t=Array.from(o.children).filter(e=>e.tagName===n.tagName);t.length>1&&(e+=`:nth-of-type(${t.indexOf(n)+1})`)}}if(t.unshift(e),n.id)break;n=w(n)}return t.join(" > ")}function Xe(e){D();const{name:t}=B(e),{target:n,ambiguous:o}=Be(e),r=e.getBoundingClientRect(),i=P(e)||e.isContentEditable,a=e.getAttribute("data-testid")??e.getAttribute("data-test")??e.getAttribute("data-cy")??e.getAttribute("data-test-id"),s={role:O(e),name:t||null,target:n,targetUnique:!o,tag:e.tagName.toLowerCase(),id:e.id||null,testId:a||null,classes:Array.from(e.classList).slice(0,6),domPath:Ke(e),rect:{x:Math.round(r.x),y:Math.round(r.y),width:Math.round(r.width),height:Math.round(r.height)}};if(i)s.sensitive=Boolean(K(e,t));else{const t=m(e.innerText??e.textContent??"");t&&(s.text=t.length>160?`${t.slice(0,159)}…`:t)}return s}function Ye(e){D();const{name:t}=B(e),n=O(e),o=e.tagName.toLowerCase(),r=n&&"generic"!==n?n:o;return t?`${r} "${t.length>40?`${t.slice(0,39)}…`:t}"`:r}function Ve(e,t){const n=t.getBoundingClientRect();l(e,{transform:`translate(${n.left}px, ${n.top}px)`,width:`${Math.max(n.width,2)}px`,height:`${Math.max(n.height,2)}px`})}function Ze(){if(Fe){Fe.frame=0,Fe.picked&&Ve(Fe.highlight,Fe.picked);for(const e of Fe.pins.values()){if(!e.el.isConnected){e.badge.style.display="none";continue}const t=e.el.getBoundingClientRect();l(e.badge,{display:"flex",transform:`translate(${Math.max(t.left-10,2)}px, ${Math.max(t.top-10,2)}px)`})}}}function Qe(){Fe&&!Fe.frame&&(Fe.frame=requestAnimationFrame(Ze))}function Je(){Fe?.card&&(Fe.card.remove(),Fe.card=null)}function et(e){if(!Fe)return{ok:!1};const t=String(e.cid??""),n=Number(e.n)||Fe.next;let o=e.el instanceof Element?e.el:null;if(!o)try{o=document.querySelector(`[${De}="${CSS.escape(t)}"]`)}catch{o=null}if(document.querySelectorAll(`[${De}="${CSS.escape(t)}"]`).forEach(e=>e.removeAttribute(De)),!o)return{ok:!1};Fe.pins.get(t)?.badge.remove();const r=function(e){const t=d();return p({position:"fixed",left:"0",top:"0",width:"20px",height:"20px","border-radius":"50%",display:"flex","align-items":"center","justify-content":"center",background:t.strong,color:t.ink,font:"700 11px/1 system-ui, sans-serif","box-shadow":"0 1px 4px rgba(0,0,0,.4)"},String(e))}(n);return Fe.host.root.appendChild(r),Fe.pins.set(t,{n,el:o,badge:r}),Fe.next=Math.max(Fe.next,n+1),Ze(),{ok:!0}}let tt=null,nt=null,ot=null,rt=null,it=null;function at(e){e.preventDefault(),e.stopPropagation()}function st(e,t,n){const o=document.createElement("button");return o.type="button",o.tabIndex=-1,o.textContent=t,l(o,{appearance:"none",margin:"0",padding:"6px 14px",border:n?"0":"1px solid rgba(255, 255, 255, 0.35)","border-radius":"999px",background:n?e.strong:"transparent",color:n?e.ink:"#ffffff",font:'700 12px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',cursor:"pointer","pointer-events":"auto"}),o.addEventListener("pointerdown",at),o.addEventListener("mousedown",at),o.addEventListener("click",e=>{at(e),e.isTrusted&&function(e,t){try{chrome.runtime.sendMessage({source:"engine-approval",type:"decide",approvalId:e,approve:t}).catch(()=>{})}catch{}}(ot?.approvalId??"",o===nt?.approve)}),o}function lt(e){if(!e)return null;const t=z.refs.get(e)?.el.deref();return t?.isConnected?t:null}function ct(){rt&&(removeEventListener("scroll",rt,!0),removeEventListener("resize",rt),rt=null)}function ut(){if(!nt)return;const e=nt.card,t=lt(ot?.ref),n=e.offsetWidth||300,o=e.offsetHeight||96,r=Math.max(8,innerWidth-n-8);if(!t)return void l(e,{left:`${Math.round((innerWidth-n)/2)}px`,top:`${Math.round(innerHeight-o-28)}px`});const i=t.getBoundingClientRect(),a=Math.min(Math.max(8,Math.round(i.left)),r),s=Math.round(i.bottom+8),c=Math.round(i.top-8-o);l(e,{left:`${a}px`,top:`${s+o<=innerHeight-8?s:Math.max(8,c)}px`})}function dt(){null!==it&&(clearTimeout(it),it=null)}function pt(){dt(),ct(),ot=null,tt&&(tt.el.remove(),tt=null,nt=null)}function ft(){const e=ot;if(!e)return{ok:!0,skipped:!0};const t=f(tt,o,{role:"alertdialog",label:"BrowserZap: approve this action"});if(tt=t,!t)return nt=null,{ok:!0,skipped:!0};nt||(nt=function(e){const t=d(),n=p({position:"absolute",left:"0",top:"0",width:"min(300px, calc(100vw - 24px))","box-sizing":"border-box",display:"flex","flex-direction":"column","align-items":"flex-start",gap:"6px",padding:"10px 13px 11px","border-radius":"11px",background:"rgba(17, 17, 17, 0.96)",color:"#ffffff",border:`1px solid ${t.strong}`,"box-shadow":"0 12px 32px rgba(0, 0, 0, 0.42)",font:'500 12.5px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',"pointer-events":"auto"}),o=p({font:'700 11.5px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',"letter-spacing":"0.06em","text-transform":"uppercase"},"Approve this action?"),r=p({"overflow-wrap":"anywhere"}),i=p({opacity:"0.7",font:'500 11px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif'}),a=p({display:"flex",gap:"8px","align-items":"center","margin-top":"3px"}),s=st(t,"Approve once",!0),l=st(t,"Deny",!1);return a.append(s,l),n.append(o,r,i,a),c()||n.animate([{opacity:0,transform:"translate3d(0, 4px, 0)"},{opacity:1,transform:"translate3d(0, 0, 0)"}],{duration:140,easing:"ease-out"}),e.append(n),{card:n,summary:r,risk:i,approve:s,deny:l}}(t.root));const n=nt;return n.summary.textContent=function(e){const t=e.replace(/\s+/g," ").trim();return t.length>200?`${t.slice(0,199)}…`:t}(e.summary),n.risk.textContent=function(e){const t=e.replace(/_/g," ").trim();return t?`Risk: ${t}`:"Needs your OK"}(e.risk),ut(),ct(),rt=()=>{const t=lt(e.ref);!e.ref||t?ut():pt()},addEventListener("scroll",rt,{capture:!0,passive:!0}),addEventListener("resize",rt,{passive:!0}),dt(),it=setTimeout(pt,3e5),n.card.style.removeProperty("pointer-events"),{ok:!0}}document.addEventListener("visibilitychange",()=>{"visible"===document.visibilityState&&ot&&!tt?.el.isConnected&&ft()});let mt=null,ht=null,gt=null,bt=null,xt=null;function yt(){null!==gt&&(clearTimeout(gt),gt=null)}function vt(e){if(!mt?.el.isConnected||!ht)return;const t=ht.pill,n=t.getBoundingClientRect();e.x>=n.left-4&&e.x<=n.right+4&&e.y>=n.top-4&&e.y<=n.bottom+4&&(t.style.setProperty("pointer-events","none"),setTimeout(()=>{ht?.pill===t&&t.style.setProperty("pointer-events","auto")},1200))}function wt(e){if(yt(),!mt)return;const t=mt;if(mt=null,ht=null,e||c()||"function"!=typeof t.el.animate)return void t.el.remove();const n=()=>t.el.remove();t.el.animate([{opacity:1},{opacity:0}],{duration:140,easing:"ease-out"}).finished.then(n).catch(n)}function kt(){if(null!==xt&&(clearTimeout(xt),xt=null),!bt)return;const e=bt;bt=null,removeEventListener("scroll",e.follow,!0),removeEventListener("resize",e.follow),e.host.el.remove()}const Et=[404,500,502,503,504],Tt=[/\bsomething went wrong\b/,/\b(?:we(?:'ve| have) )?encountered an error\b/,/\binternal server error\b/,/\bservice (?:temporarily )?unavailable\b/,/\b(?:an )?unexpected error (?:has )?occurred\b/,/\ban error occurred\b/,/\bthis page (?:isn'?t|is not) working\b/,/\bpage not found\b/],At=/^(?:error\s+|http\s+)?(\d{3})(?!\d)/,St=/^(?:error\s+|http\s+)?\d{3}\s*$/;function Mt(e){const t=e.trim().toLowerCase().match(At);if(!t)return null;const n=Number(t[1]);return Et.includes(n)?n:null}function $t(e){const t=e.toLowerCase().match(new RegExp(Tt.map(e=>e.source).join("|")));return t?t[0].slice(0,120):null}function Lt(e){const t=document.querySelector("main")??document.body;return t?function(e){const t=e.headings.filter(e=>e.level<=2&&e.text.trim()).slice(0,2);for(const e of t){const t=Mt(e.text);if(null!==t&&!(e.level>1&&St.test(e.text.trim())))return{status:t,text:e.text.trim().slice(0,120)}}for(const e of t){const t=$t(e.text);if(t)return{status:null,text:t}}const n=$t(e.text);return n&&e.network5xx?{status:null,text:n}:null}({headings:Array.from(document.querySelectorAll("h1,h2")).filter(e=>F(e)).slice(0,2).map(e=>({level:Number(e.tagName[1]),text:g(m(b(e)),120)})),text:m(t.innerText??"").slice(0,4e3),network5xx:e}):null}function Ct(e){const t=e.target??{},n=String(e.purpose??"click"),o=Me(t);if("ok"in o)return o;const{el:r,role:i,name:a}=o,l=ne(r),c={ref:re(r,i,a,l),role:i,name:g(a,100),context:l?g(l,60):void 0};if("probe"!==n){if(j(r))return Ee(`${i} ${ke(a)}`,"is disabled.",{target:c});if(!W(r))return Ee(`${i} ${ke(a)}`,"is not visible.",{target:c})}const u={ok:!0,...c,docId:z.docId,risk:le(r,i,a),sensitive:K(r,a),state:X(r),challenge:ce(),mutations:z.mutations,url:location.href,hidden:v()},d=e.scroll?W(r):null;if(e.scroll&&d){const e=d;e.scrollIntoView({block:"center",inline:"center",behavior:"instant"});const t=G(e),n=Math.round(t.left+t.width/2),o=Math.round(t.top+t.height/2);if(n<0||o<0||n>innerWidth||o>innerHeight)return Ee(`${i} ${ke(a)}`,"could not be scrolled into view.",{target:c});const l=e.getRootNode().elementFromPoint(n,o);if(null===l||!(s(l)||k(e,l)||k(r,l)||l instanceof HTMLLabelElement&&_(r).includes(l))){const e=l?`${l.tagName.toLowerCase()} "${g(B(l).name||b(l),40)}"`:"nothing";return Ee(`${i} ${ke(a)}`,`is covered by ${e}.`,{target:c})}u.point={x:n,y:o},u.pageRect={x:t.left+scrollX,y:t.top+scrollY,width:t.width,height:t.height},u.mutations=z.mutations}return u}function Nt(e){return e instanceof HTMLTextAreaElement?e:e instanceof HTMLInputElement?["checkbox","radio","button","submit","reset","image","file","range","color","hidden"].includes(e.type)?null:e:e.isContentEditable?e:null}function It(){let e=document.activeElement;for(;e?.shadowRoot?.activeElement;)e=e.shadowRoot.activeElement;return e}function Rt(e,t){const n=e instanceof HTMLTextAreaElement?HTMLTextAreaElement.prototype:HTMLInputElement.prototype,o=Object.getOwnPropertyDescriptor(n,"value")?.set;o?o.call(e,t):e.value=t,e.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))}function Ht(e){const t=Se(String(e.ref));if("ok"in t)return t;const n=String(e.value??""),o=t.el;let r;if(o instanceof HTMLInputElement||o instanceof HTMLTextAreaElement)o.focus({preventScroll:!0}),Rt(o,n),r="nativeSetter";else{const e=o;e.focus({preventScroll:!0});const t=document.createRange();t.selectNodeContents(e);const i=getSelection();i?.removeAllRanges(),i?.addRange(t);const a=n?document.execCommand("insertText",!1,n):document.execCommand("delete");a||(e.textContent=n),r=a?"insertText":"textContent"}o.dispatchEvent(new Event("change",{bubbles:!0}));const i=function(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e.value:e.innerText??""}(o);return{ok:!0,verified:o instanceof HTMLInputElement&&"number"===o.type?Number(i)===Number(n):m(i)===m(n),method:r,length:i.length,mutations:z.mutations}}let Ot=null,Pt=null,_t=null,Bt=null,Ut=!1;function zt(e){return`translate3d(${e.x-1}px, ${e.y-1}px, 0)`}function qt(e){e.getAnimations().forEach(e=>e.cancel())}function Dt(){if(Ot?.el.isConnected&&Pt)return Pt;const t=f(Ot,e);return Ot=t,t?(Pt=function(e){const t=d(),n=document.createElement("div");n.setAttribute("data-bz-marker","arrow"),l(n,{position:"absolute",left:"0",top:"0",width:"18px",height:"22px","transform-origin":"1px 1px","will-change":"transform, opacity",opacity:"0","pointer-events":"none"});const o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("width","18"),o.setAttribute("height","22"),o.setAttribute("viewBox","0 0 18 22"),o.setAttribute("aria-hidden","true");const r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d","M1 1v16.2l4.4-4 2.7 7.2 2.9-1.2-2.7-7.1 5.9-.5z"),r.setAttribute("fill","#ffffff"),r.setAttribute("stroke","#111111"),r.setAttribute("stroke-width","1.4"),r.setAttribute("stroke-linejoin","round"),o.appendChild(r),n.appendChild(o);const i=p({position:"absolute",left:"0",top:"0",width:"9px",height:"18px",display:"none",opacity:"0","pointer-events":"none","will-change":"transform, opacity"});i.setAttribute("data-bz-marker","caret");const a=`${t.strong}`,s="0 0 0 0.5px rgba(255, 255, 255, 0.85), 0 0 0 1.5px rgba(17, 17, 17, 0.35)",c=p({position:"absolute",left:"4px",top:"0",width:"1.5px",height:"100%",background:a,"box-shadow":s}),u=p({position:"absolute",left:"0",top:"0",width:"9px",height:"2px",background:a,"box-shadow":s}),f=p({position:"absolute",left:"0",bottom:"0",width:"9px",height:"2px",background:a,"box-shadow":s});i.append(c,u,f);const m=document.createElement("div");l(m,{position:"absolute",left:"0",top:"0",width:"30px",height:"30px","border-radius":"50%","box-sizing":"border-box",border:`2px solid ${t.strong}`,background:t.soft,opacity:"0","pointer-events":"none"});const h=document.createElement("div");l(h,{position:"absolute",left:"0",top:"0","max-width":"160px",padding:"2px 7px","border-radius":"5px",background:"rgba(17, 17, 17, 0.9)",color:"#ffffff","box-shadow":"0 2px 8px rgba(0, 0, 0, 0.28)",font:'600 10px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',"white-space":"nowrap","text-overflow":"ellipsis",overflow:"hidden",opacity:"0","pointer-events":"none"}),h.textContent="click";const g=document.createElement("div");return l(g,{position:"absolute",left:"0",top:"0","box-sizing":"border-box",border:`2px solid ${t.strong}`,"border-radius":"6px","box-shadow":`0 0 0 3px ${t.soft}`,opacity:"0","will-change":"opacity","pointer-events":"none"}),e.append(g,m,n,i,h),{cursor:n,ripple:m,label:h,outline:g,caret:i}}(t.root),Pt):(Pt=null,null)}const Ft=new Set(["","text","search","url","tel","email","password","number"]);function Gt(e){const t=function(){const e=It();return e&&e!==document.body&&e!==document.documentElement&&Nt(e)?e:null}(),n=t?function(e){const t=e.getBoundingClientRect();if(t.width<=0||t.height<=0)return null;const n=getComputedStyle(e),o=parseFloat(n.lineHeight)||1.35*(parseFloat(n.fontSize)||13),r=t.left+(parseFloat(n.borderLeftWidth)||0)+(parseFloat(n.paddingLeft)||0),i=t.right-(parseFloat(n.borderRightWidth)||0)-(parseFloat(n.paddingRight)||0),a=Math.max(r,i-1),s=Math.min(Math.max(o,12),Math.max(t.height-2,12));if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){const n=e instanceof HTMLInputElement?e.type:"textarea";let o="";if(e instanceof HTMLTextAreaElement||Ft.has(n)){const t=e instanceof HTMLInputElement&&"password"===n?"•".repeat(e.value.length):e.value;o=e instanceof HTMLTextAreaElement?t.slice(t.lastIndexOf("\n")+1):t}const i=Math.min(Math.max(r+function(e,t){if(!t)return 0;const n=getComputedStyle(e);try{const e=document.createElement("canvas").getContext("2d");if(e)return e.font=n.font&&""!==n.font?n.font:`${n.fontStyle} ${n.fontWeight} ${n.fontSize} ${n.fontFamily}`,e.measureText(t).width}catch{}return t.length*(parseFloat(n.fontSize)||13)*.55}(e,o)-e.scrollLeft,r),a);return{x:i,y:t.top+(t.height-s)/2,height:s}}const l=getSelection(),c=l&&l.rangeCount?l.getRangeAt(0):null;if(c&&l?.isCollapsed&&function(e,t){for(let n=t;n;n=n.parentNode)if(n===e)return!0;return!1}(e,c.startContainer)){const e=c.getBoundingClientRect();if(e.height>0)return{x:Math.min(Math.max(e.left,r),a),y:e.top,height:Math.min(Math.max(e.height,12),t.height)}}return{x:r,y:t.top+(t.height-s)/2,height:s}}(t):null;return!(!t||!n||(qt(e.caret),e.caret.style.display="block",e.caret.style.height=`${Math.round(n.height)}px`,e.caret.style.transform=`translate3d(${Math.round(n.x-4)}px, ${Math.round(n.y)}px, 0)`,e.caret.style.opacity="1",e.cursor.style.display="none",e.cursor.style.opacity="0",c()||e.caret.animate([{opacity:1},{opacity:0}],{duration:560,iterations:1/0,direction:"alternate",easing:"steps(1, end)"}),0))}function Wt(e){qt(e.caret),e.caret.style.display="none",e.caret.style.opacity="0",e.cursor.style.display="block"}function jt(e,t){const n=_t;if(_t=t,qt(e.cursor),e.cursor.style.opacity="1",!n||c()||Math.hypot(t.x-n.x,t.y-n.y)<2)return e.cursor.style.transform=zt(t),null;const o=Math.hypot(t.x-n.x,t.y-n.y),r=Math.max(90,Math.min(240,o/3));return e.cursor.style.transform=zt(n),e.cursor.animate([{transform:zt(n)},{transform:zt(t)}],{duration:r,easing:"cubic-bezier(0.2, 0.7, 0.3, 1)",fill:"forwards"})}function Kt(e,t,n){qt(e.label),e.label.textContent=n||"click",e.label.style.transform=`translate3d(${t.x+12}px, ${t.y+14}px, 0)`,c()?e.label.style.opacity="1":e.label.animate([{opacity:0,transform:`translate3d(${t.x+12}px, ${t.y+20}px, 0)`},{opacity:1,transform:`translate3d(${t.x+12}px, ${t.y+14}px, 0)`,offset:.18},{opacity:1,transform:`translate3d(${t.x+12}px, ${t.y+14}px, 0)`,offset:.7},{opacity:0,transform:`translate3d(${t.x+12}px, ${t.y+10}px, 0)`}],{duration:700,easing:"ease-out"})}function Xt(e,t){return"click"===e.phase||"press"===e.phase?(function(e,t){const n=Dt();n&&(vt(e),function(e){if(!tt?.el.isConnected||!nt)return;const t=nt.card,n=t.getBoundingClientRect();e.x>=n.left-4&&e.x<=n.right+4&&e.y>=n.top-4&&e.y<=n.bottom+4&&(t.style.setProperty("pointer-events","none"),setTimeout(()=>{nt?.card===t&&t.style.setProperty("pointer-events","auto")},1200))}(e),qt(n.ripple),qt(n.outline),n.outline.style.opacity="0",Wt(n),n.cursor.style.opacity="1",n.cursor.style.transform=zt(e),Kt(n,e,t),c()||(qt(n.cursor),n.cursor.animate([{transform:`${zt(e)} scale(1)`},{transform:`${zt(e)} scale(0.86)`,offset:.35},{transform:`${zt(e)} scale(1)`}],{duration:180,easing:"ease-out"}),n.ripple.animate([{transform:`translate3d(${e.x-15}px, ${e.y-15}px, 0) scale(0.25)`,opacity:.9},{transform:`translate3d(${e.x-15}px, ${e.y-15}px, 0) scale(1.3)`,opacity:0}],{duration:420,easing:"cubic-bezier(0.16, 1, 0.3, 1)"})),_t=e)}(e.point,e.label),Promise.resolve()):"type"===e.phase||"label"===e.phase?(function(e,t,n,o){const r=Dt();r&&(qt(r.outline),r.outline.style.opacity="0",o&&Gt(r)||(Wt(r),jt(r,e)),Kt(r,e,t),n&&function(e,t){qt(e.outline);const n=Math.round(t.x-scrollX),o=Math.round(t.y-scrollY);l(e.outline,{width:`${Math.max(1,Math.round(t.width))}px`,height:`${Math.max(1,Math.round(t.height))}px`,transform:`translate3d(${n}px, ${o}px, 0)`}),c()?e.outline.style.opacity="1":e.outline.animate([{opacity:0},{opacity:1,offset:.15},{opacity:1,offset:.7},{opacity:0}],{duration:900,easing:"ease-out"})}(r,n))}(e.point,e.label||"type",e.rect,t),Promise.resolve()):async function(e,t){const n=Dt();if(!n)return;vt(e);const o=null===_t;if(t&&Gt(n))return void(_t=e);Wt(n);const r=jt(n,e);if(o&&!c()&&(qt(n.cursor),n.cursor.animate([{opacity:0},{opacity:1}],{duration:120,easing:"ease-out"})),!r)return;const i=Number(r.effect?.getTiming().duration)||240;await Promise.race([r.finished.catch(()=>{}),new Promise(e=>setTimeout(e,i+120))]),n.cursor.style.transform=zt(e),r.cancel()}(e.point,t)}document.addEventListener("visibilitychange",()=>{"visible"===document.visibilityState&&Ut&&Bt&&(document.fullscreenElement&&Ot&&Ot.el.parentElement!==document.fullscreenElement&&(Ot.el.remove(),Ot=null,Pt=null),Xt(Bt,"arrow"!==Bt.marker).catch(()=>{}))});let Yt=null,Vt=null,Zt=null,Qt=null,Jt="",en=!1;function tn(e){e.isTrusted&&(en=!0)}function nn(e){const t=e.replace(/\s+/g," ").trim();return t.length>420?`${t.slice(0,419)}…`:t}function on(e){e.preventDefault(),e.stopPropagation()}function rn(){Qt&&(removeEventListener("scroll",Qt,!0),removeEventListener("resize",Qt),Qt=null),Vt&&(Vt.frame.style.setProperty("opacity","0"),Vt.frame.getAnimations().forEach(e=>e.cancel()))}function an(){const e=Zt;if(!e)return{ok:!0,skipped:!0};const t=f(Yt,i,{role:"alertdialog",label:"BrowserZap: your turn"});if(Yt=t,!t)return Vt=null,{ok:!0,skipped:!0};Vt||(Vt=function(e){const t=d(),n=p({position:"absolute",left:"50%",bottom:"28px",transform:"translateX(-50%)",width:"min(440px, calc(100vw - 32px))","box-sizing":"border-box",display:"flex","flex-direction":"column","align-items":"flex-start",gap:"7px",padding:"12px 15px 13px","border-radius":"12px",background:"rgba(17, 17, 17, 0.96)",color:"#ffffff",border:`1px solid ${t.strong}`,"box-shadow":"0 12px 36px rgba(0, 0, 0, 0.42)",font:'500 13px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',"pointer-events":"none"}),o=p({font:'700 12px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',"letter-spacing":"0.06em","text-transform":"uppercase"},"Your turn"),r=p({"overflow-wrap":"anywhere","white-space":"pre-wrap"}),i=document.createElement("button");i.type="button",i.tabIndex=-1,i.textContent="Done",l(i,{appearance:"none",margin:"2px 0 0",padding:"6px 20px",border:"0","border-radius":"999px",background:t.strong,color:t.ink,font:'700 12.5px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',cursor:"pointer","pointer-events":"auto"}),i.addEventListener("pointerdown",on),i.addEventListener("mousedown",on),i.addEventListener("click",e=>{if(on(e),e.isTrusted)try{chrome.runtime.sendMessage({source:"engine-handoff",type:"done",pauseId:Jt}).catch(()=>{})}catch{}}),n.append(o,r,i);const a=p({position:"absolute",left:"0",top:"0","box-sizing":"border-box","will-change":"transform",opacity:"0","pointer-events":"none"});a.setAttribute("data-bz-ring","field");const s=p({position:"absolute",inset:"0","box-sizing":"border-box",border:`2px solid ${t.strong}`,"border-radius":"8px","box-shadow":`0 0 0 3px ${t.soft}`,opacity:"0.9"});return a.append(s),e.append(a,n),{card:n,message:r,done:i,frame:a,box:s}}(t.root)),Vt.message.textContent=e.message,document.addEventListener("input",tn,!0),e.field||(e.field=function(e){if(!e)return null;if(e.ref){const t=z.refs.get(e.ref)?.el.deref();if(t?.isConnected)return t}if(e.name||e.label){const t=Me({role:e.role,name:e.name,label:e.label,within:e.within});if(!("ok"in t))return t.el}return null}(e.target));const n=e.field,o=function(e){if(!e||null===Nt(e))return!1;try{e.focus({preventScroll:!1})}catch{return!1}return It()===e}(n);return function(e){if(!Vt)return;if(rn(),!e||!e.isConnected)return;const t=Vt,n=()=>{if(!e.isConnected)return;const n=e.getBoundingClientRect();l(t.frame,{width:`${Math.round(n.width+6)}px`,height:`${Math.round(n.height+6)}px`,transform:`translate3d(${Math.round(n.left-3)}px, ${Math.round(n.top-3)}px, 0)`,opacity:"1"})};n(),Qt=n,addEventListener("scroll",Qt,{capture:!0,passive:!0}),addEventListener("resize",Qt,{passive:!0}),c()||t.box.animate([{opacity:.5,transform:"scale(1)"},{opacity:1,transform:"scale(1.015)"}],{duration:1100,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}(n),{ok:!0,ringed:Boolean(n),focused:o}}document.addEventListener("visibilitychange",()=>{"visible"===document.visibilityState&&Zt&&an()});let sn=null,ln=null,cn=null,un=null;function dn(e){e.preventDefault(),e.stopPropagation()}function pn(){null!==un&&(clearTimeout(un),un=null)}function fn(){if(null===cn)return{ok:!0,skipped:!0};const e=f(sn,r,{role:"status",label:"BrowserZap"});if(sn=e,!e)return ln=null,{ok:!0,skipped:!0};ln||(ln=function(e){const t=p({position:"absolute",left:"50%",bottom:"26px",transform:"translateX(-50%)",width:"min(380px, calc(100vw - 32px))","box-sizing":"border-box",display:"flex","align-items":"center",gap:"10px",padding:"9px 10px 9px 14px","border-radius":"11px",background:"rgba(17, 17, 17, 0.94)",color:"#ffffff",border:`1px solid ${d().soft}`,"box-shadow":"0 10px 30px rgba(0, 0, 0, 0.36)",font:'500 12.5px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',"pointer-events":"auto"}),n=p({flex:"1 1 auto","overflow-wrap":"anywhere"}),o=document.createElement("button");return o.type="button",o.tabIndex=-1,o.setAttribute("aria-label","Dismiss"),o.textContent="×",l(o,{appearance:"none",margin:"0",padding:"0 7px",border:"0","border-radius":"999px",background:"transparent",color:"#ffffff",font:'700 16px/1.4 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',cursor:"pointer","pointer-events":"auto"}),o.addEventListener("pointerdown",dn),o.addEventListener("mousedown",dn),o.addEventListener("click",e=>{dn(e),e.isTrusted&&mn()}),t.append(n,o),e.append(t),c()||t.animate([{opacity:0,transform:"translate(-50%, 6px)"},{opacity:1,transform:"translate(-50%, 0)"}],{duration:160,easing:"ease-out"}),{card:t,message:n}}(e.root));const t=cn.length>240?`${cn.slice(0,239)}…`:cn;return ln.message.textContent=t,pn(),un=setTimeout(mn,6e3),{ok:!0}}function mn(){pn(),cn=null,sn&&(sn.el.remove(),sn=null,ln=null)}function hn(e){if(!e||e===document.body||e===document.documentElement)return{};if(!F(e))return{};const t=G(e);if(t.width<=0||t.height<=0)return{};const n=Math.round(t.left+Math.min(t.width/2,18)),o=Math.round(t.top+t.height/2);if(n<0||o<0||n>innerWidth||o>innerHeight)return{};const{name:r}=B(e);return{point:{x:n,y:o},ref:re(e,O(e),r,ne(e))}}function gn(e){return!e||e instanceof HTMLTextAreaElement||e.isContentEditable?null:e.form??e.closest("form")}function bn(e){return e.querySelector("button[type=submit],button:not([type]),input[type=submit],input[type=image]")}function xn(e){return!!e&&(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement||(e instanceof HTMLInputElement?null!==Nt(e):!0===e.isContentEditable))}document.addEventListener("visibilitychange",()=>{"visible"!==document.visibilityState||null===cn||sn?.el.isConnected||fn()});const yn={ArrowDown:()=>({top:40}),ArrowUp:()=>({top:-40}),ArrowRight:()=>({left:40}),ArrowLeft:()=>({left:-40}),PageDown:e=>({top:e}),PageUp:e=>({top:-e}),Space:e=>({top:e}),Home:()=>({to:"start"}),End:()=>({to:"end"})},vn="data-browserzap-upload",wn={loadInfo:function(){const e=performance.getEntriesByType("navigation")[0],t=e=>"number"==typeof e&&e>0?Math.round(e):null;return{ok:!0,docId:z.docId,readyState:document.readyState,httpStatus:e?.responseStatus||null,ttfbMs:t(e?.responseStart),domContentLoadedMs:t(e?.domContentLoadedEventStart),loadMs:t(e?.loadEventEnd)}},busyState:function(){let e=null;for(const t of Array.from(document.querySelectorAll(Re))){if(!F(t))continue;const n=t.getAttribute("role"),o=m(t.innerText??t.textContent);if("status"!==n&&"alert"!==n||He.test(o)){if(("progressbar"===n||"PROGRESS"===t.tagName)&&("PROGRESS"===t.tagName?t.hasAttribute("value"):t.hasAttribute("aria-valuenow"))&&!He.test(`${o} ${t.getAttribute("aria-label")??""}`))continue;e=g(o||t.getAttribute("aria-label")||n||t.tagName.toLowerCase(),60);break}}return{ok:!0,docId:z.docId,readyState:document.readyState,mutations:z.mutations,indicator:e}},recordStart:function(){if(Oe)return{ok:!0,recording:!0};const e=e=>{if(!e.isTrusted)return;const t=function(e){let t=e instanceof Element?e:null;for(;t&&!U(t);)t=w(t);return t}(e.composedPath()[0]??null);if(!t||ze(t)||t instanceof HTMLSelectElement)return;if(t instanceof HTMLInputElement&&("checkbox"===t.type||"radio"===t.type))return;const n=z.mutations,o=location.href,{target:r,ambiguous:i,name:a}=Be(t);Ue({tool:"element_click",args:{target:r},label:`Click ${O(t)} "${a||"(unnamed)"}"`,ambiguous:i,expectChange:!0});const s=`${z.docId}-${Pe}`;setTimeout(()=>{if(z.mutations===n&&location.href===o)try{chrome.runtime.sendMessage({source:"engine-recorder",patch:{id:s,expectChange:!1}})}catch{}},800)},t=e=>{if(!e.isTrusted)return;const t=e.composedPath()[0];if(t instanceof Element)if(ze(t))qe(t);else if(t instanceof HTMLInputElement&&("checkbox"===t.type||"radio"===t.type)){if("radio"===t.type&&!t.checked)return;const{target:e,ambiguous:n,name:o}=Be(t);Ue({tool:"field_fill",args:{target:e,value:String(t.checked)},label:`${t.checked?"Check":"Uncheck"} "${o}"`,ambiguous:n})}else if(t instanceof HTMLSelectElement){const e=t.selectedOptions[0];if(!e)return;const{target:n,ambiguous:o,name:r}=Be(t),i=m(e.label||e.text);Ue({tool:"select_option",args:{target:n,option:{label:i}},label:`Choose "${i}" in "${r}"`,ambiguous:o})}},n=e=>{const t=e;if(!t.isTrusted||"Enter"!==t.key||t.isComposing)return;const n=t.composedPath()[0];n instanceof HTMLInputElement&&ze(n)&&(qe(n),Ue({tool:"browser_press_key",args:{key:"Enter"},label:"Press Enter",expectChange:!0}))};return document.addEventListener("click",e,!0),document.addEventListener("change",t,!0),document.addEventListener("keydown",n,!0),Oe={off:()=>{document.removeEventListener("click",e,!0),document.removeEventListener("change",t,!0),document.removeEventListener("keydown",n,!0)}},{ok:!0,recording:!0}},recordStop:function(){return Oe?.off(),Oe=null,{ok:!0,recording:!1}},commentStart:function(e){if(Fe)return{ok:!0,on:!0};const t=f(null,a);if(!t)return{ok:!0,on:!0};const n=d(),o=p({position:"fixed",left:"0",top:"0",display:"none","box-sizing":"border-box",border:`2px solid ${n.strong}`,background:n.soft,"border-radius":"3px"}),r=p({position:"absolute",left:"0",bottom:"100%","margin-bottom":"2px",background:n.strong,color:n.ink,font:"600 11px/1.3 system-ui, sans-serif",padding:"1px 6px","border-radius":"3px","white-space":"nowrap"});o.appendChild(r);const i=p({position:"fixed",top:"8px",left:"50%",transform:"translateX(-50%)",background:"#1b1b1b",color:"#f5f5f5",font:"600 12px/1.3 system-ui, sans-serif",padding:"6px 12px","border-radius":"999px","box-shadow":"0 2px 10px rgba(0,0,0,.3)",border:`1px solid ${n.strong}`},"Comment mode — click an element to comment · Esc to finish");t.root.append(o,i);const c=e=>{const t=e.composedPath()[0];return t instanceof Element&&!s(t)?t:null},u=e=>{if(!Fe||Fe.card||je(e))return;const t=c(e);t&&t!==document.documentElement&&t!==document.body&&(Fe.picked=t,r.textContent=Ye(t),Fe.highlight.style.display="block",Ve(Fe.highlight,t))},m=e=>{je(e)||(e.preventDefault(),e.stopImmediatePropagation())},h=e=>{if(je(e))return;if(m(e),!e.isTrusted||!Fe)return;const t=c(e);t&&(Fe.picked=t,r.textContent=Ye(t),Fe.highlight.style.display="block",Ve(Fe.highlight,t),function(e){if(!Fe)return;Je();const t=d(),n=e.getBoundingClientRect(),o=p({position:"fixed",left:`${Math.min(Math.max(n.left,8),innerWidth-300-8)}px`,top:`${n.bottom+170<innerHeight?n.bottom+8:Math.max(n.top-170,8)}px`,width:"300px","box-sizing":"border-box",background:"#1b1b1b",color:"#f5f5f5","border-radius":"10px",padding:"10px","pointer-events":"auto","box-shadow":"0 8px 28px rgba(0,0,0,.35)",font:'13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif',border:`1px solid ${t.strong}`}),r=p({"font-weight":"600","margin-bottom":"6px",overflow:"hidden","text-overflow":"ellipsis","white-space":"nowrap"},`Comment on ${Ye(e)}`),i=document.createElement("textarea");i.placeholder="What should change here?",i.maxLength=2e3,i.rows=3,l(i,{width:"100%","box-sizing":"border-box",resize:"vertical","border-radius":"6px",border:"1px solid #444",background:"#262626",color:"#f5f5f5",padding:"6px",font:"inherit"});const a=p({display:"flex",gap:"6px","justify-content":"flex-end","margin-top":"8px","align-items":"center"}),s=p({"margin-right":"auto",color:"#a3a3a3","font-size":"11px"},"Ctrl+Enter to save · Esc to cancel"),c=(e,n)=>{const o=document.createElement("button");return o.type="button",o.textContent=e,l(o,{border:n?"none":"1px solid #555",background:n?t.strong:"transparent",color:n?t.ink:"#eee","border-radius":"6px",padding:"4px 12px",cursor:"pointer",font:"inherit","font-weight":"600"}),o},u=c("Cancel",!1),f=c("Save",!0),m=()=>{const e=i.value.trim();if(!e||!Fe?.picked)return;const t=Fe.picked,n=`c-${Date.now().toString(36)}-${++Ge}`;t.setAttribute(De,n),Je(),Fe.highlight.style.display="none",Fe.picked=null,We({type:"add",cid:n,text:e,info:Xe(t),page:{url:location.href,title:document.title.slice(0,200),viewport:{width:innerWidth,height:innerHeight},devicePixelRatio}})};f.addEventListener("click",e=>{e.isTrusted&&m()}),u.addEventListener("click",e=>{e.isTrusted&&(Je(),Fe&&(Fe.picked=null,Fe.highlight.style.display="none"))}),i.addEventListener("keydown",e=>{e.stopPropagation(),e.isTrusted&&("Enter"===e.key&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),m()),"Escape"===e.key&&(e.preventDefault(),Je(),Fe&&(Fe.picked=null,Fe.highlight.style.display="none")))}),a.append(s,u,f),o.append(r,i,a),Fe.host.root.appendChild(o),Fe.card=o,i.focus()}(t))},g=e=>{e.isTrusted&&"Escape"===e.key&&!je(e)&&(e.preventDefault(),Fe?.card?Je():We({type:"exit"}))},b=["pointerdown","pointerup","mousedown","mouseup","dblclick","contextmenu","auxclick","submit"];window.addEventListener("pointermove",u,!0),window.addEventListener("click",h,!0);for(const e of b)window.addEventListener(e,m,!0);window.addEventListener("keydown",g,!0),window.addEventListener("scroll",Qe,!0),window.addEventListener("resize",Qe,!0),Fe={host:t,highlight:o,label:r,card:null,picked:null,pins:new Map,masks:[],frame:0,next:1,off:()=>{window.removeEventListener("pointermove",u,!0),window.removeEventListener("click",h,!0);for(const e of b)window.removeEventListener(e,m,!0);window.removeEventListener("keydown",g,!0),window.removeEventListener("scroll",Qe,!0),window.removeEventListener("resize",Qe,!0)}};for(const t of Array.isArray(e.pins)?e.pins:[]){let e=null;try{e=t.domPath?document.querySelector(t.domPath):null}catch{e=null}e&&et({cid:t.cid,n:t.n,el:e})}return{ok:!0,on:!0}},commentStop:function(){return Fe?(Fe.off(),Fe.frame&&cancelAnimationFrame(Fe.frame),Fe.host.el.remove(),document.querySelectorAll(`[${De}]`).forEach(e=>e.removeAttribute(De)),Fe=null,{ok:!0,on:!1}):{ok:!0,on:!1}},commentPin:et,commentUnpin:function(e){const t=String(e.cid??"");return Fe?.pins.get(t)?.badge.remove(),Fe?.pins.delete(t),document.querySelectorAll(`[${De}="${CSS.escape(t)}"]`).forEach(e=>e.removeAttribute(De)),{ok:!0}},commentCaptureStart:async function(e){if(!Fe)return{ok:!1};const t=String(e.cid??"");let n=null;try{n=document.querySelector(`[${De}="${CSS.escape(t)}"]`)}catch{n=null}for(const e of Array.from(Fe.host.root.children))e.style.visibility="hidden";D();for(const e of Array.from(document.querySelectorAll('input, textarea, [contenteditable=""], [contenteditable="true"]'))){const{name:t}=B(e);if(!K(e,t))continue;const n=e.getBoundingClientRect();if(n.width<1||n.height<1||n.bottom<0||n.top>innerHeight)continue;const o=p({position:"fixed",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,background:"#3a3a3a"});Fe.host.root.appendChild(o),Fe.masks.push(o)}await new Promise(e=>requestAnimationFrame(()=>requestAnimationFrame(()=>e())));const o=n?.getBoundingClientRect();return{ok:!0,rect:o?{x:o.x,y:o.y,width:o.width,height:o.height}:null,viewport:{width:innerWidth,height:innerHeight},devicePixelRatio}},commentCaptureEnd:function(){if(!Fe)return{ok:!0};for(const e of Fe.masks)e.remove();Fe.masks=[];for(const e of Array.from(Fe.host.root.children))e.style.visibility="";return Fe.picked||(Fe.highlight.style.display="none"),{ok:!0}},snapshot:function(e){const t=Math.min(Number(e.maxElements)||150,400),n=!1!==e.includeText,o=Math.min(Number(e.maxTextChars)||4e3,2e4);z.snapshotId+=1;const r=ae(),i=r.filter(ie),a=Te();let s=a?i.filter(e=>k(a,e.el)):i;const l="string"==typeof e.within&&e.within?e.within:null;l&&(s=Ae(s,l)),function(){if(!(z.refs.size<2e3))for(const[e,t]of z.refs)t.el.deref()||z.refs.delete(e)}();const c=[];let u=0,d=!1;const p=e=>{if(c.length>=t)return!1;const n=(e=>{const t=ne(e.el),n={ref:re(e.el,e.role,e.name,t),role:e.role,name:g(e.name,100),...X(e.el)};"placeholder"!==e.source&&"none"!==e.source||(n.nameSource=e.source),t&&(n.context=g(t,60)),e.el instanceof HTMLAnchorElement&&e.el.href&&(n.href=g(e.el.href,200)),K(e.el,e.name)&&(n.sensitive=!0);const o=e.el.getBoundingClientRect();return(o.bottom<0||o.top>innerHeight)&&(n.offscreen=!0),n})(e),o=JSON.stringify(n).length;return!(u+o>98304||(u+=o,c.push(n),0))};for(const e of s)if(!p(e)){d=!0;break}const f=xe(),x=(a?f.filter(e=>k(a,e.el)):f).filter(ie),y=l?Ae(x,l):x;let v=0,w=!1;for(const e of y){if(v>=60||!p(e)){w=!0;break}v+=1}const E=l?h(l):null,T=Array.from(document.querySelectorAll("h1,h2,h3,h4,h5,h6")).filter(e=>F(e)).filter(e=>!E||h(b(e))===E||te(e).some(e=>h(e)===E)).slice(0,40).map(e=>({level:Number(e.tagName[1]),text:g(b(e),100)})),A=Array.from(document.querySelectorAll("iframe,frame")),S=A.filter(e=>{try{return!e.contentDocument}catch{return!0}}).length;let M,$=!1;if(n){const e=m(document.body?.innerText??"");$=e.length>o,M=e.slice(0,o)}return{ok:!0,snapshotId:`s${z.snapshotId}`,docId:z.docId,url:location.href,title:g(document.title,200),elements:c,headings:T,text:M,challenge:ce(),siteError:Lt(!0===e.network5xx),counts:{interactive:r.length,visible:i.length,returned:c.length,hidden:r.length-i.length,...a||l?{inScope:s.length}:{},...y.length?{clickable:y.length,clickableReturned:v}:{}},modal:a?{name:g(B(a).name||Y(a),100),outside:i.length-(a?i.filter(e=>k(a,e.el)).length:0)}:null,within:l,limits:{truncated:d,textTruncated:$,clickableTruncated:w,frames:A.length,crossOriginFrames:S,note:[a?"A modal dialog is open: only its controls are listed and can be targeted. Close it to reach the page behind.":"",l&&0===s.length&&0===y.length?`No visible controls are inside "${g(l,80)}".`:"",w?`Only ${v} of ${y.length} clickable region(s) are listed; use within to narrow the page.`:"",S?"Controls inside cross-origin frames are not inspected.":""].filter(Boolean).join(" ")||void 0}}},siteError:function(e){return{ok:!0,docId:z.docId,siteError:Lt(!0===e.network5xx)}},fileInput:function(e){const t=String(e.phase??"mark"),n=String(e.mark??"");if("unmark"===t)return document.querySelectorAll(`[${vn}]`).forEach(e=>e.removeAttribute(vn)),{ok:!0};const o=Se(String(e.ref));if("ok"in o)return o;const r=o.el;return r instanceof HTMLInputElement&&"file"===r.type?r.disabled?{ok:!1,code:"TARGET_NOT_INTERACTABLE",message:"The file input is disabled."}:"check"===t?{ok:!0,files:r.files?.length??0,names:Array.from(r.files??[]).map(e=>e.name).slice(0,10)}:(n&&r.setAttribute(vn,n),{ok:!0,multiple:r.multiple,accept:r.accept||null,files:r.files?.length??0}):{ok:!1,code:"TARGET_NOT_INTERACTABLE",message:`"${o.name||r.tagName.toLowerCase()}" is not a file input. Target the page's "Choose file" input itself.`}},resolve:Ct,click:function(e){const t=Se(String(e.ref));if("ok"in t)return t;const n=W(t.el);if(!n)return Ee(ke(t.name),"is not visible.");const o=G(n);return o.width<=0||o.height<=0?Ee(ke(t.name),"has no visible area."):(function(e){e.scrollIntoView({block:"center",inline:"center",behavior:"instant"});const t=e.getBoundingClientRect(),n=t.left+t.width/2,o=t.top+t.height/2,r={bubbles:!0,cancelable:!0,composed:!0,view:window,button:0,buttons:1,clientX:n,clientY:o,screenX:n,screenY:o,detail:1};try{const t={...r,pointerId:1,pointerType:"mouse",isPrimary:!0,width:1,height:1};e.dispatchEvent(new PointerEvent("pointerdown",t)),e.dispatchEvent(new MouseEvent("mousedown",r)),e.dispatchEvent(new PointerEvent("pointerup",{...t,buttons:0})),e.dispatchEvent(new MouseEvent("mouseup",{...r,buttons:0}))}catch{}"function"==typeof e.click?e.click():e.dispatchEvent(new MouseEvent("click",{...r,buttons:0}))}(n),{ok:!0,ref:e.ref,method:"dom",hidden:v(),state:X(t.el),mutations:z.mutations})},cursor:async function(e){const t=String(e.phase??"move");if("hide"===t)return function(e){if(Ut=!1,Bt=null,_t=null,!Ot)return;const t=Ot;if(Ot=null,Pt=null,e||c()||"function"!=typeof t.el.animate)return void t.el.remove();const n=()=>t.el.remove();t.el.animate([{opacity:1},{opacity:0}],{duration:140,easing:"ease-out"}).finished.then(n).catch(n),setTimeout(n,220)}(!0===e.immediate),{ok:!0};if("idle"===t)return{ok:!0};const n=e.point;if(!n||!Number.isFinite(n.x)||!Number.isFinite(n.y))return{ok:!0,skipped:!0};const o=e.rect,r={phase:t,point:n,label:"string"==typeof e.label?e.label.slice(0,24):"",rect:o&&Number.isFinite(o.width)&&Number.isFinite(o.height)?{x:o.x,y:o.y,width:o.width,height:o.height}:null,marker:"arrow"===e.marker?"arrow":"caret"};return Bt=r,"visible"!==document.visibilityState?{ok:!0,skipped:!0}:(Ut=!0,await Xt(r,"arrow"!==r.marker),"move"===t?{ok:!0,mutations:z.mutations}:{ok:!0})},indicator:function(e){const o=String(e.phase??"show");return"hide"===o?(wt(!0===e.immediate),kt(),{ok:!0}):"visible"!==document.visibilityState?{ok:!0,skipped:!0}:"ring"===o?(function(e){const t=z.refs.get(e)?.el.deref();if(!t||!t.isConnected)return void kt();kt();const o=f(null,n);if(!o)return;const r=d(),i=p({position:"absolute",left:"0",top:"0","will-change":"transform","pointer-events":"none"}),a=p({position:"absolute",inset:"0","box-sizing":"border-box",border:`2px solid ${r.strong}`,"border-radius":"8px","box-shadow":`0 0 0 3px ${r.soft}`,opacity:"0.9"});i.append(a),o.root.append(i);const s=()=>{if(!t.isConnected)return void kt();const e=t.getBoundingClientRect();l(i,{width:`${Math.round(e.width+6)}px`,height:`${Math.round(e.height+6)}px`,transform:`translate3d(${Math.round(e.left-3)}px, ${Math.round(e.top-3)}px, 0)`})};s(),bt={host:o,follow:s},xt=setTimeout(()=>kt(),12e4),c()||(a.animate([{opacity:.5,transform:"scale(1)"},{opacity:1,transform:"scale(1.015)"}],{duration:1100,iterations:1/0,direction:"alternate",easing:"ease-in-out"}),addEventListener("scroll",s,{capture:!0,passive:!0}),addEventListener("resize",s,{passive:!0}))}(String(e.ref??"")),{ok:!0}):"ringHide"===o?(kt(),{ok:!0}):(r="idle"===o?1500:3e4,function(){if(mt?.el.isConnected&&ht)return ht;const e=f(mt,t);return mt=e,e?(ht=function(e){const t=d(),n=p({position:"absolute",inset:"0","box-sizing":"border-box",border:`2px solid ${t.strong}`,"box-shadow":`inset 0 0 26px ${t.soft}`,opacity:"0.9","pointer-events":"none"}),o=p({position:"absolute",left:"0",right:"0",bottom:"22px",display:"flex","justify-content":"center","pointer-events":"none"}),r=p({display:"flex","align-items":"center",gap:"9px",padding:"5px 6px 5px 12px","border-radius":"999px",background:"rgba(17, 17, 17, 0.9)",color:"#ffffff","box-shadow":"0 4px 18px rgba(0, 0, 0, 0.3)",font:'600 11.5px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',"white-space":"nowrap","pointer-events":"auto"}),i=p({width:"6px",height:"6px","border-radius":"50%",background:t.strong,"flex-shrink":"0"}),a=p({"letter-spacing":"0.01em",opacity:"0.94"},"BrowserZap · agent working"),s=document.createElement("button");s.type="button",s.tabIndex=-1,s.textContent="Stop",l(s,{appearance:"none",margin:"0",padding:"3px 11px",border:"0","border-radius":"999px",background:t.strong,color:t.ink,font:'700 11px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif',cursor:"pointer"});const u=e=>{e.preventDefault(),e.stopPropagation()};return s.addEventListener("pointerdown",u),s.addEventListener("mousedown",u),s.addEventListener("click",e=>{if(u(e),e.isTrusted){try{chrome.runtime.sendMessage({source:"engine-control",type:"stop"}).catch(()=>{})}catch{}wt(!1)}}),r.append(i,a,s),o.append(r),e.append(n,o),c()||r.animate([{opacity:0,transform:"translate3d(0, 6px, 0)"},{opacity:1,transform:"translate3d(0, 0, 0)"}],{duration:160,easing:"ease-out"}),{border:n,pill:r}}(e.root),c()||ht.border.animate([{opacity:.45},{opacity:1}],{duration:1500,iterations:1/0,direction:"alternate",easing:"ease-in-out"}),ht):(ht=null,null)}()&&(yt(),gt=setTimeout(()=>wt(!1),r)),{ok:!0});var r},handoff:function(e){const t=String(e.phase??"show");return"status"===t?{ok:!0,paused:Boolean(Zt),typed:en}:"hide"===t?(rn(),document.removeEventListener("input",tn,!0),Zt=null,en=!1,Yt&&(Yt.el.remove(),Yt=null,Vt=null),{ok:!0}):(Yt?.el.isConnected||(Yt=null,Vt=null),"suppress"===t?(Yt&&Yt.el.style.setProperty("display","none"),{ok:!0}):"restore"===t?(Yt&&Yt.el.style.removeProperty("display"),{ok:!0}):(Zt={message:nn(String(e.message??"The agent needs you to take over.")),target:e.target??void 0,field:null},Jt=String(e.pauseId??""),"visible"!==document.visibilityState?{ok:!0,skipped:!0}:an()))},approval:function(e){const t=String(e.phase??"show");return"hide"===t?(pt(),{ok:!0}):(tt?.el.isConnected||(tt=null,nt=null),"suppress"===t?(tt&&tt.el.style.setProperty("display","none"),{ok:!0}):"restore"===t?(tt&&tt.el.style.removeProperty("display"),{ok:!0}):(ot={approvalId:String(e.approvalId??""),summary:String(e.summary??"This action needs your OK."),risk:String(e.risk??""),ref:void 0===e.ref?void 0:String(e.ref)},"visible"!==document.visibilityState?{ok:!0,skipped:!0}:ft()))},note:function(e){return"hide"===String(e.phase??"show")?(mn(),{ok:!0}):(cn=String(e.message??"The agent finished — this tab is yours."),"visible"!==document.visibilityState?{ok:!0,skipped:!0}:fn())},fillPrepare:function(e){const t=Ct({target:e.target,purpose:"fill",scroll:!0});if(!t.ok)return t;const n=Se(t.ref);if(t.sensitive)return we("USER_ACTION_REQUIRED",`"${t.name}" is a sensitive field (${t.sensitive}). BrowserZap never types into it; ask the user to fill it.`,{target:{ref:t.ref,role:t.role,name:t.name},sensitive:t.sensitive});if(n.el instanceof HTMLInputElement&&("checkbox"===n.el.type||"radio"===n.el.type))return{...t,kind:"toggle",checked:n.el.checked};if(n.el instanceof HTMLSelectElement)return we("UNSUPPORTED_CONTROL",`"${t.name}" is a <select>. Use select_option.`,{target:t});const o=Nt(n.el);if(!o)return we("UNSUPPORTED_CONTROL",`${t.role} "${t.name}" does not accept text.`,{target:t});if(o.readOnly)return we("TARGET_NOT_INTERACTABLE",`"${t.name}" is read-only.`,{target:t});if(o.focus({preventScroll:!0}),o instanceof HTMLInputElement||o instanceof HTMLTextAreaElement)o instanceof HTMLTextAreaElement||["text","search","url","tel","password",""].includes(o.type)?o.select():o.value&&Rt(o,"");else{const e=document.createRange();e.selectNodeContents(o);const t=getSelection();t?.removeAllRanges(),t?.addRange(e)}const r=k(o,It());return"string"!=typeof e.value||t.challenge?{...t,kind:"text",focused:r}:{...t,kind:"text",focused:r,applied:Ht({ref:t.ref,value:e.value})}},fillApply:Ht,selectOption:function(e){const t=Ct({target:e.target,purpose:"select",scroll:!0});if(!t.ok)return t;const n=Se(t.ref).el;if(!(n instanceof HTMLSelectElement))return we("UNSUPPORTED_CONTROL",`${t.role} "${t.name}" is not a native <select>. Open it with element_click, then click the option.`,{target:t});const o=e.option??{},r=Array.from(n.options);let i=[];if(void 0!==o.value)i=r.filter(e=>e.value===o.value);else{if(void 0===o.label)return we("INVALID_ARGUMENT","option needs a label or a value.");{const e=h(o.label);i=r.filter(t=>h(t.label||t.text)===e)}}if(!i.length)return we("TARGET_NOT_FOUND",`No option matches in "${t.name}".`,{candidates:r.slice(0,20).map(e=>({ref:"",role:"option",name:g(m(e.label||e.text),100),value:e.value}))});if(i.length>1)return we("TARGET_AMBIGUOUS",`${i.length} options match in "${t.name}". Select by value instead.`,{candidates:i.slice(0,8).map(e=>({ref:"",role:"option",name:m(e.label||e.text),value:e.value}))});const a=i[0];if(a.disabled)return we("TARGET_NOT_INTERACTABLE",`Option "${m(a.label)}" is disabled.`);const s=n.value;n.focus({preventScroll:!0}),n.value=a.value,n.dispatchEvent(new Event("input",{bubbles:!0})),n.dispatchEvent(new Event("change",{bubbles:!0}));const l=n.value===a.value&&n.selectedOptions[0]===a;return{ok:!0,ref:t.ref,name:t.name,selected:{label:g(m(a.label||a.text),100),value:a.value},changed:s!==n.value,verified:l,sensitive:t.sensitive,point:t.point,pageRect:t.pageRect}},observe:function(e){let t;if("string"==typeof e.ref){const n=z.refs.get(e.ref),o=n?.el.deref();t=o&&o.isConnected?{connected:!0,...X(o)}:{connected:!1}}const n={ok:!0,docId:z.docId,url:location.href,title:document.title,readyState:document.readyState,mutations:z.mutations,target:t};if("number"==typeof e.since){const t=function(e){if(e>=z.mutations)return{count:0,quietMs:null};const t=performance.now();if(Ce.length&&Ce[0].seq>e+1)return{count:2e3,quietMs:0};let n=t;const o=new Set;for(let r=Ce.length-1;r>=0;r--){const i=Ce[r];if(i.seq>e)continue;if(n===t&&(n=i.at),i.at<n-1500)break;const a=i.node.deref();a&&o.add(a)}const r=new Set;let i=null,a=0;for(let n=Ce.length-1;n>=0&&Ce[n].seq>e;n--){const e=Ce[n].node.deref();if(!e||r.has(e))continue;if(r.add(e),o.has(e)||Ne(e,t))continue;a++;const s=Le.get(e)?.last??t;(null===i||s>i)&&(i=s)}return{count:a,quietMs:null===i?null:Math.round(t-i)}}(e.since);n.changes=t.count,n.changeQuietMs=t.quietMs}if(!0===e.modal){const e=Te();n.modal=e?{role:e.getAttribute("role")||"dialog",name:g(B(e).name||"",80)||null}:null}if(e.expect&&"object"==typeof e.expect){const t=function(e){const t={ok:!0,docId:z.docId,url:location.href};if("string"==typeof e.text&&(t.text=h(document.body?.innerText).includes(h(e.text))),e.target){const n=Me(e.target);t.target=!("ok"in n)&&ie(n),t.targetAmbiguous="ok"in n&&"TARGET_AMBIGUOUS"===n.code,t.targetAmbiguous&&(t.targetCandidates=("candidates"in n?n.candidates:void 0)??[])}if(e.targetGone){const n=Me(e.targetGone);t.targetGone="ok"in n?"TARGET_NOT_FOUND"===n.code||"STALE_SNAPSHOT"===n.code:!ie(n)}return t}(e.expect);n.expect={text:t.text,target:t.target,targetGone:t.targetGone,ambiguous:t.targetAmbiguous,candidates:t.targetCandidates}}return n},keyContext:function(e){const t=It(),n=String(e.key??""),o={ok:!0,docId:z.docId,url:location.href,hidden:v(),...hn(t)};if("Enter"!==n||!t)return{...o,risk:"reversible"};if(t instanceof HTMLButtonElement||t instanceof HTMLAnchorElement&&t.href||t instanceof HTMLInputElement&&["submit","image","button"].includes(t.type)){const{name:e}=B(t),n=O(t);return{...o,risk:le(t,n,e),submits:{role:n,name:g(e,100),fingerprint:oe(n,e)},challenge:ce()}}const r=gn(t);if(!r)return{...o,risk:"reversible"};const i=bn(r),a=i?B(i).name:Y(r)||"form",s=i?O(i):"form",l=i?le(i,s,a):"post"===r.method.toLowerCase()?"external_side_effect":"reversible";return{...o,risk:l,submits:{role:s,name:g(a,100),fingerprint:oe(s,a)},challenge:ce()}},pressKey:function(e){const t=String(e.key??""),n=new Set(Array.isArray(e.modifiers)?e.modifiers:[]),o=It()??document.body??document.documentElement,r=Number(e.keyCode)||0,i={key:"Space"===t?" ":t,code:String(e.code??t),keyCode:r,which:r,bubbles:!0,cancelable:!0,composed:!0,view:window,altKey:n.has("alt"),ctrlKey:n.has("ctrl"),metaKey:n.has("meta"),shiftKey:n.has("shift")},a=o.dispatchEvent(new KeyboardEvent("keydown",i));!a||"Enter"!==t&&"Space"!==t||o.dispatchEvent(new KeyboardEvent("keypress",i));let s="none";return!a||i.altKey||i.ctrlKey||i.metaKey||(s=function(e,t,n){const o=t,r=t instanceof HTMLButtonElement||"SUMMARY"===t.tagName||t instanceof HTMLInputElement&&["button","submit","reset","image","checkbox","radio"].includes(t.type);if("Enter"===e){if(t instanceof HTMLAnchorElement&&t.href)return o.click(),"activate";if(t instanceof HTMLButtonElement||"SUMMARY"===t.tagName)return o.click(),"activate";const e=gn(t);if(e&&t instanceof HTMLInputElement&&Nt(t)){const t=bn(e);if(t){if(j(t))return"none";t.click()}else e.requestSubmit();return"submit"}return"none"}if("Space"===e&&r)return o.click(),"activate";if("Tab"===e){const e=function(){const e=[];for(const t of x(document)){const n=t;"number"!=typeof n.tabIndex||n.tabIndex<0||j(t)||t instanceof HTMLInputElement&&"hidden"===t.type||F(t)&&e.push(n)}return[...e.filter(e=>e.tabIndex>0).sort((e,t)=>e.tabIndex-t.tabIndex),...e.filter(e=>0===e.tabIndex)]}();if(!e.length)return"none";const t=e.indexOf(o);return(t<0?e[n?e.length-1:0]:e[(t+(n?-1:1)+e.length)%e.length]).focus(),"focus"}if("Escape"===e){const e=y();return e&&e.dispatchEvent(new Event("cancel",{cancelable:!0}))?(e.close(),"closeDialog"):"none"}if(("Backspace"===e||"Delete"===e)&&xn(t))return document.execCommand("Backspace"===e?"delete":"forwardDelete"),"delete";const i=yn[e];if(i&&!xn(t)&&!r){const t=i(Math.round(.875*innerHeight));return t.to?scrollTo({top:"start"===t.to?0:document.documentElement.scrollHeight,behavior:"instant"}):window.scrollBy({top:(n&&"Space"===e?-1:1)*(t.top??0),left:t.left??0,behavior:"instant"}),"scroll"}return"none"}(t,o,Boolean(i.shiftKey))),o.dispatchEvent(new KeyboardEvent("keyup",i)),{ok:!0,method:"dom",prevented:!a,defaultAction:s,mutations:z.mutations}},scroll:function(e){const t=Math.min(Math.max(Number(e.amount)||600,1),5e3),n=String(e.direction??"down"),o="left"===n?-t:"right"===n?t:0,r="up"===n?-t:"down"===n?t:0;let i=window;if(e.target){const t=Me(e.target);if("ok"in t)return t;i=t.el}const a=()=>i===window?{x:scrollX,y:scrollY}:{x:i.scrollLeft,y:i.scrollTop},s=a();i.scrollBy({left:o,top:r,behavior:"instant"});const l=a();return{ok:!0,moved:s.x!==l.x||s.y!==l.y,position:l,atEnd:i===window&&innerHeight+scrollY>=document.documentElement.scrollHeight-2}}};16!==globalThis.__browserzapEngine?.version&&(globalThis.__browserzapEngine={version:16,run(e,t){const n=Object.prototype.hasOwnProperty.call(wn,e)?wn[e]:void 0;if(!n)return we("INVALID_ARGUMENT",`Unknown engine operation: ${e}`);D();try{return n(t??{})}catch(e){return we("INTERNAL",e instanceof Error?e.message:String(e))}finally{D()}}})})();
|
package/extension/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "BrowserZap",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.6.1",
|
|
5
5
|
"description": "Let your AI agent use the Chrome you already use: exact clicks, your approval before anything risky, passwords stay yours.",
|
|
6
6
|
"homepage_url": "https://browserzap.com",
|
|
7
7
|
"permissions": [
|