@hanzo/browser-extension 1.9.65 → 1.9.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Hanzo AI",
4
- "version": "1.9.65",
4
+ "version": "1.9.67",
5
5
  "description": "AI answer engine, search, and dev assistant — Hanzo AI in a new tab, address-bar search, source-cited answers, realtime news, WebGPU AI, and MCP.",
6
6
  "permissions": [
7
7
  "activeTab",
@@ -11,7 +11,8 @@
11
11
  "webNavigation",
12
12
  "scripting",
13
13
  "cookies",
14
- "alarms"
14
+ "alarms",
15
+ "nativeMessaging"
15
16
  ],
16
17
  "host_permissions": [
17
18
  "http://localhost/*",
package/firefox/page.js CHANGED
@@ -1,35 +1,35 @@
1
- "use strict";(()=>{var R=new Set(["button","link","textbox","searchbox","checkbox","radio","switch","combobox","listbox","option","slider","spinbutton","tab","menuitem","menuitemcheckbox","menuitemradio","treeitem","clickable"]),Oe=new Set(["heading","img","cell","gridcell","columnheader","rowheader","dialog","alertdialog","article","region","navigation","form","iframe"]),fe=new Set(["button","link","heading","cell","gridcell","columnheader","rowheader","option","tab","menuitem","menuitemcheckbox","menuitemradio","treeitem","checkbox","radio","switch","tooltip","clickable"]),Re=new Set(["cell","gridcell","columnheader","rowheader"]),De=new Set(["textbox","searchbox","combobox","spinbutton","slider"]),Ke=new Set(["script","style","noscript","template","head","meta","link","title","base","object","embed","param","source","track","datalist"]),D=new Set(["inline","inline-block","inline-flex","inline-grid","contents"]),je=new Set(["hanzo-ai-overlay","hanzo-page-overlay-root","hanzo-picker-overlay","hanzo-console-root"]),me='a[href],area[href],button,input,select,textarea,summary,iframe,[tabindex],[contenteditable=""],[contenteditable="true"]',Be={fieldset:"legend",table:"caption",figure:"figcaption"},d=150,P=300,L=25,I=new Map,W=new WeakMap,x=0;function de(e){let n=W.get(e);return n||(n=`e${++x}`,W.set(e,n)),I.set(n,new WeakRef(e)),n}function he(e){return/^@?e\d+$/.test(e.trim())}function pe(e){return e.isConnected&&!!e.ownerDocument.defaultView}function h(e){var r;if(!e||!e.trim())throw new Error("selector required: a snapshot ref (@e2) or a CSS selector");let n=e.trim();if(he(n)){let o=n.replace(/^@/,""),i=(r=I.get(o))==null?void 0:r.deref();if(!i)throw new Error(`Unknown ref @${o}: this page has no such ref (it navigated, or the ref came from another tab). Run snapshot again for fresh refs.`);if(!pe(i))throw I.delete(o),new Error(`Stale ref @${o}: its element is no longer in the page. Run snapshot again for fresh refs.`);return i}let t;try{t=document.querySelector(n)}catch{throw new Error(`Invalid selector ${JSON.stringify(n)}: pass a snapshot ref (@e2) or a CSS selector.`)}if(!t)throw new Error(`No element matches ${JSON.stringify(n)}. Run snapshot to see what is on the page.`);return t}function g(e){return e.ownerDocument.defaultView.getComputedStyle(e)}function U(e){var t;let n=e;try{if(typeof n.openOrClosedShadowRoot=="function")return n.openOrClosedShadowRoot()??null;let r=(t=globalThis.chrome)==null?void 0:t.dom;if(r!=null&&r.openOrClosedShadowRoot&&e instanceof e.ownerDocument.defaultView.HTMLElement)return r.openOrClosedShadowRoot(e)??null}catch{}return e.shadowRoot}function $(e){let n=e instanceof Element?U(e):null,t=[];for(let r of Array.from((n??e).childNodes))if(r.nodeType===1&&r.localName==="slot"){let o=r,i=typeof o.assignedNodes=="function"?o.assignedNodes({flatten:!0}):[];t.push(...i.length?i:Array.from(o.childNodes))}else t.push(r);return t}function X(e){if(e.assignedSlot)return e.assignedSlot;let n=e.parentNode;return n?n.nodeType===11?n.host??null:n.nodeType===1?n:null:null}function Ve(e,n){for(let t=n;t;t=X(t))if(t===e)return!0;return!1}function k(e){if(Ke.has(e.localName)||je.has(e.id)||e.hidden||e.getAttribute("aria-hidden")==="true")return!0;let n=g(e).display;return n==="none"?!0:n!=="contents"&&typeof e.checkVisibility=="function"&&!e.checkVisibility()}function f(e){return e.replace(/\s+/g," ").trim()}function m(e,n){return e.length>n?`${e.slice(0,n-1)}\u2026`:e}function A(e,n=d*2){let t="",r=o=>{if(t.length>n)return;if(o.nodeType===3){t+=o.textContent;return}if(o.nodeType!==1)return;let i=o;if(k(i))return;let s=i.getAttribute("aria-label");if(s&&s.trim()){t+=` ${s} `;return}if(i.localName==="img"){t+=` ${i.getAttribute("alt")??""} `;return}if(i.localName==="input"){let c=i.type;(c==="submit"||c==="button"||c==="reset")&&(t+=` ${i.value} `);return}if(i.localName==="select"||i.localName==="textarea")return;let a=!D.has(g(i).display),l=t.length;a&&(t+=" ");for(let c of $(i))r(c);!t.slice(l).trim()&&i.getAttribute("title")&&(t+=` ${i.getAttribute("title")} `),a&&(t+=" ")};for(let o of $(e))r(o);return f(t)}function Pe(e,n){let t=e.getAttribute(n);if(!t)return"";let r=e.getRootNode();return f(t.split(/\s+/).map(o=>{var s;let i=((s=r.getElementById)==null?void 0:s.call(r,o))??e.ownerDocument.getElementById(o);return i?A(i):""}).join(" "))}function ne(e){for(let n=e.parentElement;n;n=n.parentElement)if(["article","aside","main","nav","section"].includes(n.localName))return!0;return!1}function We(e){var t;switch(e.localName){case"a":case"area":return e.hasAttribute("href")?"link":"";case"button":return"button";case"input":{let r=e.type;return r==="hidden"?"":r==="button"||r==="submit"||r==="reset"||r==="image"||r==="file"?"button":r==="checkbox"?"checkbox":r==="radio"?"radio":r==="range"?"slider":r==="number"?"spinbutton":e.hasAttribute("list")?"combobox":r==="search"?"searchbox":"textbox"}case"select":return e.multiple||e.size>1?"listbox":"combobox";case"option":return"option";case"textarea":return"textbox";case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return"heading";case"img":return e.getAttribute("alt")===""?"":"img";case"svg":return e.getAttribute("aria-label")||e.querySelector("title")?"img":"";case"ul":case"ol":case"menu":return"list";case"li":return"listitem";case"nav":return"navigation";case"main":return"main";case"header":return ne(e)?"":"banner";case"footer":return ne(e)?"":"contentinfo";case"aside":return"complementary";case"form":return"form";case"section":return e.hasAttribute("aria-label")||e.hasAttribute("aria-labelledby")?"region":"";case"article":return"article";case"table":return"table";case"tr":return"row";case"td":return"cell";case"th":return e.getAttribute("scope")==="row"?"rowheader":"columnheader";case"dialog":return"dialog";case"details":case"fieldset":return"group";case"summary":return"button";case"p":return"paragraph";case"blockquote":return"blockquote";case"hr":return"separator";case"progress":return"progressbar";case"meter":return"meter";case"output":return"status";case"iframe":return"iframe";case"figure":return"figure"}return e.isContentEditable&&!((t=e.parentElement)!=null&&t.isContentEditable)?"textbox":""}function z(e,n,t){let r=(e.getAttribute("role")||"").trim().split(/\s+/)[0].toLowerCase();if(r&&r!=="presentation"&&r!=="none"&&r!=="generic")return r;let o=We(e);if(o)return o;let i=e.localName;return i==="label"||i==="body"||i==="html"?"":e.hasAttribute("tabindex")&&e.tabIndex>=0||e.hasAttribute("onclick")||n==="pointer"&&t!=="pointer"?"clickable":""}function be(e){let n=e.localName;if(n==="select")return Array.from(e.selectedOptions).map(o=>f(o.label||o.text)).join(", ");if(n==="input"||n==="textarea"){let r=e;return r.type==="password"?r.value?"\u2022".repeat(Math.min(r.value.length,8)):"":r.value}return e.isContentEditable?f(e.textContent||""):e.getAttribute("aria-valuenow")??void 0}function ge(e,n){var s;let t=Pe(e,"aria-labelledby");if(t)return m(t,d);let r=e.getAttribute("aria-label");if(r&&r.trim())return m(f(r),d);let o=e.localName;if(o==="input"||o==="select"||o==="textarea"){let a=e;if(o==="input"&&(a.type==="submit"||a.type==="reset"||a.type==="button"))return m(a.value||(a.type==="submit"?"Submit":a.type==="reset"?"Reset":""),d);if(o==="input"&&a.type==="image")return m(a.alt||a.title||"Submit",d);let l=Array.from(a.labels??[]).map(c=>A(c)).filter(Boolean).join(" ");return m(l||f(a.placeholder||e.getAttribute("title")||""),d)}if(o==="img"||o==="area")return m(f(e.getAttribute("alt")||e.getAttribute("title")||""),d);if(o==="svg")return m(f(((s=e.querySelector("title"))==null?void 0:s.textContent)||""),d);let i=Be[o];if(i){let a=e.querySelector(`:scope > ${i}`);if(a)return m(A(a),d)}if(o==="iframe")return m(f(e.getAttribute("title")||e.getAttribute("name")||""),d);if(fe.has(n)){let a=A(e);if(a)return m(a,d)}return m(f(e.getAttribute("title")||""),d)}function T(e){try{if(e.matches(":disabled"))return!0}catch{}return!!e.closest('[aria-disabled="true"]')}function F(e){if(e.localName==="input"){let t=e;if(t.type==="checkbox"||t.type==="radio")return t.indeterminate?"mixed":t.checked}let n=e.getAttribute("aria-checked");if(n==="mixed")return"mixed";if(n==="true"||n==="false")return n==="true"}function Fe(e,n){var i;let t=[];if(n==="heading"){let s=/^h([1-6])$/.exec(e.localName);t.push(`level=${e.getAttribute("aria-level")||(s?s[1]:"2")}`)}let r=F(e);r==="mixed"?t.push("checked=mixed"):r===!0&&t.push("checked"),R.has(n)&&T(e)&&t.push("disabled");let o=e.getAttribute("aria-expanded");return o==="true"||o==="false"?t.push(`expanded=${o}`):e.localName==="summary"&&((i=e.parentElement)==null?void 0:i.localName)==="details"&&t.push(`expanded=${e.parentElement.open}`),(e.getAttribute("aria-selected")==="true"||e.localName==="option"&&e.selected)&&t.push("selected"),e.getAttribute("aria-pressed")==="true"&&t.push("pressed"),(e.required||e.getAttribute("aria-required")==="true")&&t.push("required"),t}function H(e){return e.text===void 0&&R.has(e.role)&&!!e.el||e.kids.some(H)}function _e(e,n){let t=e[e.length-1];t&&t.text!==void 0&&!t.closed?t.text+=n:e.push({role:"",name:"",text:n,props:[],kids:[]})}function v(e){let n=e[e.length-1];n&&n.text!==void 0&&(n.closed=!0)}function C(e,n,t,r){for(let o of $(e))o.nodeType===3?t||_e(n,o.textContent||""):o.nodeType===1&&Ee(o,n,r)}function Ee(e,n,t){if(k(e))return;let r=g(e),o=r.visibility!=="visible",i=o?"":z(e,r.cursor,t),s=!D.has(r.display);if(!i){s&&v(n),C(e,n,o,r.cursor),s&&v(n);return}let a={role:i,name:ge(e,i),el:e,props:Fe(e,i),kids:[]},l=[];if((De.has(i)||e.localName==="select")&&(a.value=be(e)),e.localName==="select"){let c=Array.from(e.options);for(let p of c.slice(0,L))a.kids.push({role:"option",name:m(f(p.label||p.text),d),props:p.selected?["selected"]:[],kids:[]});c.length>L&&a.kids.push({role:"",name:"",text:`\u2026 ${c.length-L} more options`,props:[],kids:[]})}else if(e.localName==="iframe"){let c=null;try{c=e.contentDocument}catch{}c!=null&&c.body?C(c.body,a.kids,!1,""):a.props.push("cross-origin")}else i==="img"||e.localName==="input"||e.localName==="textarea"||(C(e,a.kids,!1,r.cursor),l=a.kids,Re.has(i)&&a.kids.some(H)&&!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&(a.name=""),fe.has(i)&&a.name&&(a.kids=a.kids.filter(H)));if(i==="clickable"&&l.some(H)){s&&v(n),n.push(...l),s&&v(n);return}s&&v(n),n.push(a),s&&v(n)}function we(e){let n=[];for(let t of e){if(t.text!==void 0){let r=f(t.text);r&&n.push({...t,text:r});continue}t.kids=we(t.kids),!(ye(t)&&!t.kids.length&&t.role!=="separator")&&n.push(t)}return n}function ye(e){return!xe(e)&&!e.name&&e.value===void 0&&e.props.length===0}function xe(e){return e.el?R.has(e.role)||Oe.has(e.role)&&(!!e.name||e.role==="iframe"):!1}function ke(e){let n=[];for(let t of e){if(t.text!==void 0){n.push(t);continue}if(t.kids=ke(t.kids),ye(t)&&t.kids.length<=1){n.push(...t.kids);continue}n.push(t)}return n}function Y(e,n=[]){for(let t of e)t.text===void 0&&R.has(t.role)&&t.el&&n.push({...t,kids:[]}),Y(t.kids,n);return n}function Je(e,n){if(e.text!==void 0)return`${n}- text: ${m(e.text,P)}`;let t=`${n}- ${e.role}`;e.name&&(t+=` ${JSON.stringify(e.name)}`),xe(e)&&(t+=` [ref=${de(e.el)}]`);for(let r of e.props)t+=` [${r}]`;return t}function Te(e,n,t,r){let o=" ".repeat(n),i=!t.depth||n+1<t.depth;for(let s of e){let a=Je(s,o),l=s.kids;if(s.text===void 0){s.value&&(!l.length||!i)?a+=`: ${m(f(s.value),P)}`:l.length===1&&l[0].text!==void 0&&(a+=`: ${m(l[0].text,P)}`,l=[]);let c=t.urls&&s.role==="link"?s.el.href:"";(c||l.length&&i)&&(a+=":"),r.push(a),c&&r.push(`${o} - /url: ${c}`),i&&Te(l,n+1,t,r)}else r.push(a)}}function ve(e){let n=[];if(e.selector){let t=h(e.selector),r=X(t);Ee(t,n,r?g(r).cursor:"")}else{let t=document.body??document.documentElement;C(t,n,!1,"")}return n=we(n),e.compact?ke(n):n}function $e(){for(let[e,n]of I){let t=n.deref();(!t||!pe(t))&&I.delete(e)}}function Ne(e={}){e.base&&e.base>x&&(x=e.base),$e();let n=ve(e);e.interactive&&(n=Y(n));let t=[];Te(n,0,e,t);let r=t.filter(o=>o.includes("[ref=")).length;return{tree:t.join(`
2
- `)||"(empty: nothing rendered)",refs:r,last:x,url:location.href,title:document.title}}function u(e){let n=z(e,"","")||e.localName,t=ge(e,n),r=W.get(e);return`${r?`@${r} `:""}(${n}${t?` ${JSON.stringify(m(t,60))}`:""})`}function Ue(e){let n=e.localName;e.id&&(n+=`#${e.id}`);let t=typeof e.className=="string"?e.className.trim().split(/\s+/).filter(Boolean).slice(0,2):[];t.length&&(n+=`.${t.join(".")}`);let r=m(A(e,80),60);return`<${n}>${r?` ${JSON.stringify(r)}`:""}`}function Xe(e){let n=e.ownerDocument.defaultView;return{width:n.innerWidth,height:n.innerHeight}}function N(e){let n=e.getBoundingClientRect();return n.width<=0||n.height<=0||g(e).visibility!=="visible"?null:n}function re(e,n,t){let r=e.elementFromPoint(n,t);for(;r;){let o=U(r);if(!o)break;let i=o.elementFromPoint(n,t);if(!i||i===r)break;r=i}return r}function oe(e,n,t,r){let o=n?Ue(n):"nothing (the point is outside the page)";return new Error(`${u(e)} is covered by ${o} at (${Math.round(t)}, ${Math.round(r)}). Dismiss or act on the covering element (a consent banner, modal or overlay), then run snapshot again before reusing refs.`)}function ze(e){var Z;if(!N(e))throw new Error(`${u(e)} is not visible (no box on screen). Run snapshot again; it may be collapsed or hidden.`);try{e.scrollIntoView({block:"center",inline:"center",behavior:"instant"})}catch{}let n=e.getBoundingClientRect(),t=Xe(e),r=Math.max(n.left,0),o=Math.min(n.right,t.width),i=Math.max(n.top,0),s=Math.min(n.bottom,t.height);if(o<=r||s<=i)throw new Error(`${u(e)} is outside the viewport and could not be scrolled into it.`);let a=(r+o)/2,l=(i+s)/2,c=re(e.ownerDocument,a,l),p=c==null?void 0:c.closest("label");if(!c||!(Ve(e,c)||(p==null?void 0:p.control)===e))throw oe(e,c,a,l);let j=e.ownerDocument,B=a,V=l;for(;j!==document;){let b=(Z=j.defaultView)==null?void 0:Z.frameElement;if(!b)break;let q=b.getBoundingClientRect(),ee=g(b);B+=q.left+b.clientLeft+parseFloat(ee.paddingLeft||"0"),V+=q.top+b.clientTop+parseFloat(ee.paddingTop||"0");let te=re(b.ownerDocument,B,V);if(te!==b)throw oe(e,te,B,V);j=b.ownerDocument}return{x:a,y:l,hit:c}}function w(e,n,t,r,o={}){let i=e.ownerDocument.defaultView,s=n.startsWith("pointer")?i.PointerEvent??i.MouseEvent:i.MouseEvent,a=n.endsWith("enter")||n.endsWith("leave");return e.dispatchEvent(new s(n,{bubbles:!a,cancelable:!a,composed:!0,clientX:t,clientY:r,screenX:t,screenY:r,button:0,buttons:0,detail:0,pointerId:1,pointerType:"mouse",isPrimary:!0,...o}))}function Ye(e){var n,t;for(let r=e;r;r=X(r))if(r.matches(me)&&!T(r)){r.focus({preventScroll:!0});return}(t=(n=e.ownerDocument.activeElement)==null?void 0:n.blur)==null||t.call(n)}function ie(e,n,t,r){w(e,"pointerdown",n,t,{buttons:1}),w(e,"mousedown",n,t,{buttons:1,detail:r})&&Ye(e),w(e,"pointerup",n,t),w(e,"mouseup",n,t,{detail:r}),w(e,"click",n,t,{detail:r})}function Se(e,n){if(n!=="hover"&&T(e))throw new Error(`${u(e)} is disabled.`);let{x:t,y:r,hit:o}=ze(e);for(let i of["pointerover","pointerenter","mouseover","mouseenter","pointermove","mousemove"])w(o,i,t,r);n!=="hover"&&(ie(o,t,r,1),n==="dblclick"&&(ie(o,t,r,2),w(o,"dblclick",t,r,{detail:2})))}var Ge=new Set(["","text","search","email","url","tel","password","number","date","datetime-local","month","week","time","color"]);function K(e){let n=e.localName;if(n==="textarea")return"field";if(n==="input"){let t=e.type;if(Ge.has(t))return"field";let r=t==="checkbox"||t==="radio"?"use check/uncheck":t==="file"?"use upload":"it takes no text";throw new Error(`${u(e)} is an <input type=${t}>: ${r}.`)}if(n==="select")throw new Error(`${u(e)} is a <select>: use select with the option's value or label.`);if(e.isContentEditable)return"rich";throw new Error(`${u(e)} is not editable. Run snapshot and pick a textbox.`)}function se(e){let n=K(e);if(T(e))throw new Error(`${u(e)} is disabled.`);if(e.readOnly)throw new Error(`${u(e)} is read-only.`);return n}function G(e,n){var r;let t=(r=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),"value"))==null?void 0:r.set;t?t.call(e,n):e.value=n}function O(e,n,t){let r=e.ownerDocument.defaultView;e.dispatchEvent(new(r.InputEvent??r.Event)("input",{bubbles:!0,composed:!0,inputType:n,data:t}))}function _(e,n){e.dispatchEvent(new e.ownerDocument.defaultView.Event(n,{bubbles:!0}))}function Me(e){try{let n=e.selectionStart,t=e.selectionEnd;if(n!==null&&t!==null)return[n,t]}catch{}return[e.value.length,e.value.length]}function J(e,n){var t;if(K(e)==="rich"){let r=e.ownerDocument;(t=r.execCommand)!=null&&t.call(r,"insertText",!1,n)||e.append(n)}else{let r=e,[o,i]=Me(r);G(r,r.value.slice(0,o)+n+r.value.slice(i));try{r.setSelectionRange(o+n.length,o+n.length)}catch{}}O(e,"insertText",n)}function Qe(e,n){if(K(e)!=="field")return;let t=e,[r,o]=Me(t);r===o&&(n?o=Math.min(t.value.length,o+1):r=Math.max(0,r-1)),G(t,t.value.slice(0,r)+t.value.slice(o));try{t.setSelectionRange(r,r)}catch{}O(e,n?"deleteContentForward":"deleteContentBackward",null)}function ae(e){if(e.ownerDocument.activeElement===e)return;e.focus({preventScroll:!0});let n=e;if(e.localName==="input"||e.localName==="textarea")try{n.setSelectionRange(n.value.length,n.value.length)}catch{}}function ce(){var n;let e=document.activeElement;for(;;){let t=e?((n=U(e))==null?void 0:n.activeElement)??null:null;if(t){e=t;continue}if((e==null?void 0:e.localName)==="iframe"){let r=null;try{r=e.contentDocument}catch{}if(r!=null&&r.activeElement){e=r.activeElement;continue}}break}return e??document.body}var Ze={enter:"Enter",return:"Enter",tab:"Tab",escape:"Escape",esc:"Escape",space:" ",backspace:"Backspace",delete:"Delete",del:"Delete",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",arrowup:"ArrowUp",arrowdown:"ArrowDown",arrowleft:"ArrowLeft",arrowright:"ArrowRight",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"},qe={control:"ctrlKey",ctrl:"ctrlKey",shift:"shiftKey",alt:"altKey",option:"altKey",meta:"metaKey",cmd:"metaKey",command:"metaKey"};function et(e){let n=e.split("+").map(i=>i.trim());n[n.length-1]===""&&n.length>1&&(n.pop(),n[n.length-1]="+");let t={};for(let i of n.slice(0,-1)){let s=qe[i.toLowerCase()];if(!s)throw new Error(`Unknown modifier ${JSON.stringify(i)} in ${JSON.stringify(e)}: use Control, Shift, Alt or Meta.`);t[s]=!0}let r=n[n.length-1];return{key:Ze[r.toLowerCase()]??(r.length===1?r:r[0].toUpperCase()+r.slice(1)),mods:t}}function tt(e){return/^[a-z]$/i.test(e)?`Key${e.toUpperCase()}`:/^\d$/.test(e)?`Digit${e}`:e===" "?"Space":e}function y(e,n,t,r){let o=e.ownerDocument.defaultView;return e.dispatchEvent(new o.KeyboardEvent(n,{key:t,code:tt(t),bubbles:!0,cancelable:!0,composed:!0,...r}))}function nt(e){return Array.from(e.querySelectorAll(me)).filter(n=>n.tabIndex>=0&&!T(n)&&!!N(n))}var rt=new Set(["button","link","tab","menuitem","option","clickable"]),ot=new Set(["button","checkbox","radio","switch","tab","menuitem","option","clickable"]);function le(e,n){return n.has(z(e,"",""))?(e.click(),!0):!1}function it(e,n){let{key:t,mods:r}=et(n),o=r.ctrlKey||r.metaKey||r.altKey,i=t.length===1&&!o;if(y(e,"keydown",t,r)&&!(t===" "&&e.localName!=="input"&&e.localName!=="textarea"&&le(e,ot)))if(i)y(e,"keypress",t,r),(e.localName==="input"||e.localName==="textarea"||e.isContentEditable)&&J(e,t);else if(t==="Enter")if(y(e,"keypress",t,r),e.localName==="textarea")J(e,`
3
- `);else if(e.localName==="input"&&e.form){let s=e.form;typeof s.requestSubmit=="function"?s.requestSubmit():s.submit()}else le(e,rt);else if(t==="Tab"){let s=nt(e.ownerDocument),a=s.indexOf(e),l=s[(a+(r.shiftKey?-1:1)+s.length)%s.length];l==null||l.focus()}else t==="Backspace"||t==="Delete"?Qe(e,t==="Delete"):(r.ctrlKey||r.metaKey)&&t.toLowerCase()==="a"&&K(e)==="field"&&e.select();y(e,"keyup",t,r)}function st(e,n){if(e.localName!=="select")throw new Error(`${u(e)} is not a <select>. For a custom dropdown: click it open, snapshot, then click the option.`);if(T(e))throw new Error(`${u(e)} is disabled.`);let t=e,r=Array.from(t.options),o=n.trim(),i=r.find(s=>s.value===n)??r.find(s=>f(s.label||s.text)===o)??r.find(s=>f(s.label||s.text).toLowerCase()===o.toLowerCase());if(!i){let s=r.slice(0,L).map(a=>JSON.stringify(f(a.label||a.text))).join(", ");throw new Error(`${u(e)} has no option ${JSON.stringify(n)}. Options: ${s}${r.length>L?", \u2026":""}.`)}if(i.disabled)throw new Error(`Option ${JSON.stringify(f(i.label))} of ${u(e)} is disabled.`);return t.focus(),i.selected=!0,_(t,"input"),_(t,"change"),{value:i.value,label:f(i.label||i.text)}}function at(e,n){let t=F(e);if(t===void 0)throw new Error(`${u(e)} is not a checkbox, radio or switch.`);if(t===n)return{checked:n,changed:!1};if(!n&&e.localName==="input"&&e.type==="radio")throw new Error(`${u(e)} is a radio: it unchecks when another option in its group is checked.`);let r=e.localName==="input"&&!N(e)?Array.from(e.labels??[]).find(o=>N(o)):void 0;if(T(e))throw new Error(`${u(e)} is disabled.`);if(Se(r??e,"click"),F(e)!==n)throw new Error(`Clicking ${u(e)} did not ${n?"check":"uncheck"} it.`);return{checked:n,changed:!0}}function ue(e){if(e.localName==="input"||e.localName==="textarea")return e.value;if(e.localName==="select")return be(e)??"";let n=e.innerText;return(typeof n=="string"?n:e.textContent||"").trim()}function Le(e){let n=e.op;switch(n){case"click":case"dblclick":case"hover":{let t=h(e.selector);return Se(t,n),{[n==="hover"?"hovered":"clicked"]:u(t)}}case"fill":{let t=h(e.selector),r=se(t),o=e.text??"";return t.focus({preventScroll:!0}),r==="rich"?(t.textContent=o,O(t,"insertText",o)):(G(t,o),O(t,"insertText",o),_(t,"change")),{filled:u(t),value:r==="rich"?o:t.value}}case"type":{let t=e.selector?h(e.selector):ce();se(t),e.selector&&ae(t);for(let r of e.text??"")y(t,"keydown",r,{}),y(t,"keypress",r,{}),J(t,r),y(t,"keyup",r,{});return{typed:u(t),value:ue(t)}}case"press":{if(!e.key)throw new Error("key required: Enter, Tab, Escape, ArrowDown, Control+a \u2026");let t=e.selector?h(e.selector):ce();return e.selector&&ae(t),it(t,e.key),{pressed:e.key,on:u(t)}}case"focus":{let t=h(e.selector);return t.focus({preventScroll:!0}),{focused:u(t)}}case"select":return{selected:st(h(e.selector),e.value??e.text??"")};case"check":case"uncheck":return at(h(e.selector),n==="check");case"text":return{text:ue(h(e.selector))};case"attribute":{if(!e.attribute)throw new Error("attribute required: the attribute name to read");return{value:h(e.selector).getAttribute(e.attribute)}}case"scrollIntoView":{let t=h(e.selector);return t.scrollIntoView({block:"center",inline:"center",behavior:"instant"}),{scrolled:u(t)}}case"scroll":{let t=e.selector?h(e.selector):document.scrollingElement??document.documentElement;return t.scrollBy({left:e.dx??0,top:e.dy??0,behavior:"instant"}),{x:t.scrollLeft,y:t.scrollTop}}case"count":{if(!e.selector)throw new Error("selector required: a CSS selector to count");return{count:document.querySelectorAll(e.selector).length}}}throw new Error(`Unknown page action ${JSON.stringify(n)}.`)}function Ae(e){let n=e.state==="hidden";if(e.text){let o=document.body,i=o==null?void 0:o.innerText;return{met:(typeof i=="string"?i:(o==null?void 0:o.textContent)||"").includes(e.text)!==n}}let t=null;try{t=h(e.selector)}catch(o){if(e.selector&&he(e.selector)&&!n)throw o}return{met:(!!t&&!!N(t))!==n}}function Ie(e=0){var t;e>x&&(x=e),$e();let n=[];for(let r of Y(ve({}))){let o=r.el,i=N(o);if(!i)continue;let s=i.left,a=i.top;for(let l=o.ownerDocument;l!==document;){let c=(t=l.defaultView)==null?void 0:t.frameElement;if(!c)break;let p=c.getBoundingClientRect();s+=p.left+c.clientLeft,a+=p.top+c.clientTop,l=c.ownerDocument}s+i.width<=0||a+i.height<=0||s>=innerWidth||a>=innerHeight||n.push({ref:de(o),label:`${r.role}${r.name?` ${JSON.stringify(m(r.name,60))}`:""}`,x:s,y:a,w:i.width,h:i.height})}return{boxes:n,last:x,width:innerWidth,height:innerHeight}}var Q=6e4,ct=new Set(["input","select","textarea","svg","canvas","video","audio","map"]);function M(e,n){let t=e.nodeType===9?e.body:e;return t?$(t).map(r=>ft(r,n)).join(""):""}function S(e,n){return f(M(e,n))}function E(e){return e.trim()?`
1
+ "use strict";(()=>{var I=e=>new Map(Object.entries(e)),Be=I({enter:"Enter",return:"Enter",tab:"Tab",escape:"Escape",esc:"Escape",space:" ",backspace:"Backspace",delete:"Delete",del:"Delete",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",arrowup:"ArrowUp",arrowdown:"ArrowDown",arrowleft:"ArrowLeft",arrowright:"ArrowRight",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown",comma:","}),je=I({control:"ctrlKey",ctrl:"ctrlKey",shift:"shiftKey",alt:"altKey",option:"altKey",meta:"metaKey",cmd:"metaKey",command:"metaKey"}),Pe=I({Backspace:8,Tab:9,Enter:13,Shift:16,Control:17,Alt:18,CapsLock:20,Escape:27," ":32,PageUp:33,PageDown:34,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,Insert:45,Delete:46,Meta:91,ContextMenu:93,")":48,"!":49,"@":50,"#":51,$:52,"%":53,"^":54,"&":55,"*":56,"(":57,";":186,":":186,"=":187,"+":187,",":188,"<":188,"-":189,_:189,".":190,">":190,"/":191,"?":191,"`":192,"~":192,"[":219,"{":219,"\\":220,"|":220,"]":221,"}":221,"'":222,'"':222}),Ve=I({" ":"Space",",":"Comma",".":"Period",";":"Semicolon","=":"Equal","-":"Minus","/":"Slash","`":"Backquote","[":"BracketLeft","]":"BracketRight","\\":"Backslash","'":"Quote"});function re(e,n){let t=e.split("+").map(l=>l.trim());t[t.length-1]===""&&t.length>1&&(t.pop(),t[t.length-1]="+");let r={};for(let l of t.slice(0,-1)){let c=je.get(l.toLowerCase());if(!c)throw new Error(`Unknown modifier ${JSON.stringify(l)} in ${JSON.stringify(e)}: use Control, Shift, Alt or Meta.`);r[c]=!0}let o=typeof n=="number"||typeof n=="string"&&/^\d+$/.test(n)?Number(n):0,i=n&&typeof n=="object"?n:{};(o&1||i.alt)&&(r.altKey=!0),(o&2||i.ctrl)&&(r.ctrlKey=!0),(o&4||i.meta)&&(r.metaKey=!0),(o&8||i.shift)&&(r.shiftKey=!0);let s=t[t.length-1];if(!s)throw new Error("key required: Enter, Tab, Escape, ArrowDown, Control+a \u2026");return{key:Be.get(s.toLowerCase())??(s.length===1?s:s[0].toUpperCase()+s.slice(1)),mods:r}}function oe(e){return/^[a-z]$/i.test(e)?`Key${e.toUpperCase()}`:/^\d$/.test(e)?`Digit${e}`:Ve.get(e)??e}function Fe(e){let n=Pe.get(e);if(n!==void 0)return n;if(/^[a-z0-9]$/i.test(e))return e.toUpperCase().charCodeAt(0);let t=/^F([1-9]|1\d|2[0-4])$/.exec(e);return t?111+Number(t[1]):0}function ie(e,n){if(e==="keypress"){let r=n==="Enter"?13:n.length===1?n.charCodeAt(0):0;return{keyCode:r,which:r,charCode:r}}let t=Fe(n);return{keyCode:t,which:t,charCode:0}}var R=new Set(["button","link","textbox","searchbox","checkbox","radio","switch","combobox","listbox","option","slider","spinbutton","tab","menuitem","menuitemcheckbox","menuitemradio","treeitem","clickable"]),We=new Set(["heading","img","cell","gridcell","columnheader","rowheader","dialog","alertdialog","article","region","navigation","form","iframe"]),pe=new Set(["button","link","heading","cell","gridcell","columnheader","rowheader","option","tab","menuitem","menuitemcheckbox","menuitemradio","treeitem","checkbox","radio","switch","tooltip","clickable"]),_e=new Set(["cell","gridcell","columnheader","rowheader"]),Ue=new Set(["textbox","searchbox","combobox","spinbutton","slider"]),Je=new Set(["script","style","noscript","template","head","meta","link","title","base","object","embed","param","source","track","datalist"]),K=new Set(["inline","inline-block","inline-flex","inline-grid","contents"]),ze=new Set(["hanzo-ai-overlay","hanzo-page-overlay-root","hanzo-picker-overlay","hanzo-console-root"]),be='a[href],area[href],button,input,select,textarea,summary,iframe,[tabindex],[contenteditable=""],[contenteditable="true"]',Xe={fieldset:"legend",table:"caption",figure:"figcaption"},d=150,F=300,L=25,C=new Map,W=new WeakMap,x=0;function ge(e){let n=W.get(e);return n||(n=`e${++x}`,W.set(e,n)),C.set(n,new WeakRef(e)),n}function Ee(e){return/^@?e\d+$/.test(e.trim())}function we(e){return e.isConnected&&!!e.ownerDocument.defaultView}function h(e){var r;if(!e||!e.trim())throw new Error("selector required: a snapshot ref (@e2) or a CSS selector");let n=e.trim();if(Ee(n)){let o=n.replace(/^@/,""),i=(r=C.get(o))==null?void 0:r.deref();if(!i)throw new Error(`Unknown ref @${o}: this page has no such ref (it navigated, or the ref came from another tab). Run snapshot again for fresh refs.`);if(!we(i))throw C.delete(o),new Error(`Stale ref @${o}: its element is no longer in the page. Run snapshot again for fresh refs.`);return i}let t;try{t=document.querySelector(n)}catch{throw new Error(`Invalid selector ${JSON.stringify(n)}: pass a snapshot ref (@e2) or a CSS selector.`)}if(!t)throw new Error(`No element matches ${JSON.stringify(n)}. Run snapshot to see what is on the page.`);return t}function g(e){return e.ownerDocument.defaultView.getComputedStyle(e)}function z(e){var t;let n=e;try{if(typeof n.openOrClosedShadowRoot=="function")return n.openOrClosedShadowRoot()??null;let r=(t=globalThis.chrome)==null?void 0:t.dom;if(r!=null&&r.openOrClosedShadowRoot&&e instanceof e.ownerDocument.defaultView.HTMLElement)return r.openOrClosedShadowRoot(e)??null}catch{}return e.shadowRoot}function $(e){let n=e instanceof Element?z(e):null,t=[];for(let r of Array.from((n??e).childNodes))if(r.nodeType===1&&r.localName==="slot"){let o=r,i=typeof o.assignedNodes=="function"?o.assignedNodes({flatten:!0}):[];t.push(...i.length?i:Array.from(o.childNodes))}else t.push(r);return t}function X(e){if(e.assignedSlot)return e.assignedSlot;let n=e.parentNode;return n?n.nodeType===11?n.host??null:n.nodeType===1?n:null:null}function Ye(e,n){for(let t=n;t;t=X(t))if(t===e)return!0;return!1}function k(e){if(Je.has(e.localName)||ze.has(e.id)||e.hidden||e.getAttribute("aria-hidden")==="true")return!0;let n=g(e).display;return n==="none"?!0:n!=="contents"&&typeof e.checkVisibility=="function"&&!e.checkVisibility()}function f(e){return e.replace(/\s+/g," ").trim()}function m(e,n){return e.length>n?`${e.slice(0,n-1)}\u2026`:e}function A(e,n=d*2){let t="",r=o=>{if(t.length>n)return;if(o.nodeType===3){t+=o.textContent;return}if(o.nodeType!==1)return;let i=o;if(k(i))return;let s=i.getAttribute("aria-label");if(s&&s.trim()){t+=` ${s} `;return}if(i.localName==="img"){t+=` ${i.getAttribute("alt")??""} `;return}if(i.localName==="input"){let c=i.type;(c==="submit"||c==="button"||c==="reset")&&(t+=` ${i.value} `);return}if(i.localName==="select"||i.localName==="textarea")return;let a=!K.has(g(i).display),l=t.length;a&&(t+=" ");for(let c of $(i))r(c);!t.slice(l).trim()&&i.getAttribute("title")&&(t+=` ${i.getAttribute("title")} `),a&&(t+=" ")};for(let o of $(e))r(o);return f(t)}function Qe(e,n){let t=e.getAttribute(n);if(!t)return"";let r=e.getRootNode();return f(t.split(/\s+/).map(o=>{var s;let i=((s=r.getElementById)==null?void 0:s.call(r,o))??e.ownerDocument.getElementById(o);return i?A(i):""}).join(" "))}function se(e){for(let n=e.parentElement;n;n=n.parentElement)if(["article","aside","main","nav","section"].includes(n.localName))return!0;return!1}function Ge(e){var t;switch(e.localName){case"a":case"area":return e.hasAttribute("href")?"link":"";case"button":return"button";case"input":{let r=e.type;return r==="hidden"?"":r==="button"||r==="submit"||r==="reset"||r==="image"||r==="file"?"button":r==="checkbox"?"checkbox":r==="radio"?"radio":r==="range"?"slider":r==="number"?"spinbutton":e.hasAttribute("list")?"combobox":r==="search"?"searchbox":"textbox"}case"select":return e.multiple||e.size>1?"listbox":"combobox";case"option":return"option";case"textarea":return"textbox";case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return"heading";case"img":return e.getAttribute("alt")===""?"":"img";case"svg":return e.getAttribute("aria-label")||e.querySelector("title")?"img":"";case"ul":case"ol":case"menu":return"list";case"li":return"listitem";case"nav":return"navigation";case"main":return"main";case"header":return se(e)?"":"banner";case"footer":return se(e)?"":"contentinfo";case"aside":return"complementary";case"form":return"form";case"section":return e.hasAttribute("aria-label")||e.hasAttribute("aria-labelledby")?"region":"";case"article":return"article";case"table":return"table";case"tr":return"row";case"td":return"cell";case"th":return e.getAttribute("scope")==="row"?"rowheader":"columnheader";case"dialog":return"dialog";case"details":case"fieldset":return"group";case"summary":return"button";case"p":return"paragraph";case"blockquote":return"blockquote";case"hr":return"separator";case"progress":return"progressbar";case"meter":return"meter";case"output":return"status";case"iframe":return"iframe";case"figure":return"figure"}return e.isContentEditable&&!((t=e.parentElement)!=null&&t.isContentEditable)?"textbox":""}function Y(e,n,t){let r=(e.getAttribute("role")||"").trim().split(/\s+/)[0].toLowerCase();if(r&&r!=="presentation"&&r!=="none"&&r!=="generic")return r;let o=Ge(e);if(o)return o;let i=e.localName;return i==="label"||i==="body"||i==="html"?"":e.hasAttribute("tabindex")&&e.tabIndex>=0||e.hasAttribute("onclick")||n==="pointer"&&t!=="pointer"?"clickable":""}function ye(e){let n=e.localName;if(n==="select")return Array.from(e.selectedOptions).map(o=>f(o.label||o.text)).join(", ");if(n==="input"||n==="textarea"){let r=e;return r.type==="password"?r.value?"\u2022".repeat(Math.min(r.value.length,8)):"":r.value}return e.isContentEditable?f(e.textContent||""):e.getAttribute("aria-valuenow")??void 0}function xe(e,n){var s;let t=Qe(e,"aria-labelledby");if(t)return m(t,d);let r=e.getAttribute("aria-label");if(r&&r.trim())return m(f(r),d);let o=e.localName;if(o==="input"||o==="select"||o==="textarea"){let a=e;if(o==="input"&&(a.type==="submit"||a.type==="reset"||a.type==="button"))return m(a.value||(a.type==="submit"?"Submit":a.type==="reset"?"Reset":""),d);if(o==="input"&&a.type==="image")return m(a.alt||a.title||"Submit",d);let l=Array.from(a.labels??[]).map(c=>A(c)).filter(Boolean).join(" ");return m(l||f(a.placeholder||e.getAttribute("title")||""),d)}if(o==="img"||o==="area")return m(f(e.getAttribute("alt")||e.getAttribute("title")||""),d);if(o==="svg")return m(f(((s=e.querySelector("title"))==null?void 0:s.textContent)||""),d);let i=Xe[o];if(i){let a=e.querySelector(`:scope > ${i}`);if(a)return m(A(a),d)}if(o==="iframe")return m(f(e.getAttribute("title")||e.getAttribute("name")||""),d);if(pe.has(n)){let a=A(e);if(a)return m(a,d)}return m(f(e.getAttribute("title")||""),d)}function T(e){try{if(e.matches(":disabled"))return!0}catch{}return!!e.closest('[aria-disabled="true"]')}function _(e){if(e.localName==="input"){let t=e;if(t.type==="checkbox"||t.type==="radio")return t.indeterminate?"mixed":t.checked}let n=e.getAttribute("aria-checked");if(n==="mixed")return"mixed";if(n==="true"||n==="false")return n==="true"}function Ze(e,n){var i;let t=[];if(n==="heading"){let s=/^h([1-6])$/.exec(e.localName);t.push(`level=${e.getAttribute("aria-level")||(s?s[1]:"2")}`)}let r=_(e);r==="mixed"?t.push("checked=mixed"):r===!0&&t.push("checked"),R.has(n)&&T(e)&&t.push("disabled");let o=e.getAttribute("aria-expanded");return o==="true"||o==="false"?t.push(`expanded=${o}`):e.localName==="summary"&&((i=e.parentElement)==null?void 0:i.localName)==="details"&&t.push(`expanded=${e.parentElement.open}`),(e.getAttribute("aria-selected")==="true"||e.localName==="option"&&e.selected)&&t.push("selected"),e.getAttribute("aria-pressed")==="true"&&t.push("pressed"),(e.required||e.getAttribute("aria-required")==="true")&&t.push("required"),t}function H(e){return e.text===void 0&&R.has(e.role)&&!!e.el||e.kids.some(H)}function qe(e,n){let t=e[e.length-1];t&&t.text!==void 0&&!t.closed?t.text+=n:e.push({role:"",name:"",text:n,props:[],kids:[]})}function v(e){let n=e[e.length-1];n&&n.text!==void 0&&(n.closed=!0)}function O(e,n,t,r){for(let o of $(e))o.nodeType===3?t||qe(n,o.textContent||""):o.nodeType===1&&ke(o,n,r)}function ke(e,n,t){if(k(e))return;let r=g(e),o=r.visibility!=="visible",i=o?"":Y(e,r.cursor,t),s=!K.has(r.display);if(!i){s&&v(n),O(e,n,o,r.cursor),s&&v(n);return}let a={role:i,name:xe(e,i),el:e,props:Ze(e,i),kids:[]},l=[];if((Ue.has(i)||e.localName==="select")&&(a.value=ye(e)),e.localName==="select"){let c=Array.from(e.options);for(let p of c.slice(0,L))a.kids.push({role:"option",name:m(f(p.label||p.text),d),props:p.selected?["selected"]:[],kids:[]});c.length>L&&a.kids.push({role:"",name:"",text:`\u2026 ${c.length-L} more options`,props:[],kids:[]})}else if(e.localName==="iframe"){let c=null;try{c=e.contentDocument}catch{}c!=null&&c.body?O(c.body,a.kids,!1,""):a.props.push("cross-origin")}else i==="img"||e.localName==="input"||e.localName==="textarea"||(O(e,a.kids,!1,r.cursor),l=a.kids,_e.has(i)&&a.kids.some(H)&&!e.hasAttribute("aria-label")&&!e.hasAttribute("aria-labelledby")&&(a.name=""),pe.has(i)&&a.name&&(a.kids=a.kids.filter(H)));if(i==="clickable"&&l.some(H)){s&&v(n),n.push(...l),s&&v(n);return}s&&v(n),n.push(a),s&&v(n)}function Te(e){let n=[];for(let t of e){if(t.text!==void 0){let r=f(t.text);r&&n.push({...t,text:r});continue}t.kids=Te(t.kids),!(ve(t)&&!t.kids.length&&t.role!=="separator")&&n.push(t)}return n}function ve(e){return!$e(e)&&!e.name&&e.value===void 0&&e.props.length===0}function $e(e){return e.el?R.has(e.role)||We.has(e.role)&&(!!e.name||e.role==="iframe"):!1}function Me(e){let n=[];for(let t of e){if(t.text!==void 0){n.push(t);continue}if(t.kids=Me(t.kids),ve(t)&&t.kids.length<=1){n.push(...t.kids);continue}n.push(t)}return n}function Q(e,n=[]){for(let t of e)t.text===void 0&&R.has(t.role)&&t.el&&n.push({...t,kids:[]}),Q(t.kids,n);return n}function et(e,n){if(e.text!==void 0)return`${n}- text: ${m(e.text,F)}`;let t=`${n}- ${e.role}`;e.name&&(t+=` ${JSON.stringify(e.name)}`),$e(e)&&(t+=` [ref=${ge(e.el)}]`);for(let r of e.props)t+=` [${r}]`;return t}function Se(e,n,t,r){let o=" ".repeat(n),i=!t.depth||n+1<t.depth;for(let s of e){let a=et(s,o),l=s.kids;if(s.text===void 0){s.value&&(!l.length||!i)?a+=`: ${m(f(s.value),F)}`:l.length===1&&l[0].text!==void 0&&(a+=`: ${m(l[0].text,F)}`,l=[]);let c=t.urls&&s.role==="link"?s.el.href:"";(c||l.length&&i)&&(a+=":"),r.push(a),c&&r.push(`${o} - /url: ${c}`),i&&Se(l,n+1,t,r)}else r.push(a)}}function Ne(e){let n=[];if(e.selector){let t=h(e.selector),r=X(t);ke(t,n,r?g(r).cursor:"")}else{let t=document.body??document.documentElement;O(t,n,!1,"")}return n=Te(n),e.compact?Me(n):n}function Le(){for(let[e,n]of C){let t=n.deref();(!t||!we(t))&&C.delete(e)}}function Ae(e={}){e.base&&e.base>x&&(x=e.base),Le();let n=Ne(e);e.interactive&&(n=Q(n));let t=[];Se(n,0,e,t);let r=t.filter(o=>o.includes("[ref=")).length;return{tree:t.join(`
2
+ `)||"(empty: nothing rendered)",refs:r,last:x,url:location.href,title:document.title}}function u(e){let n=Y(e,"","")||e.localName,t=xe(e,n),r=W.get(e);return`${r?`@${r} `:""}(${n}${t?` ${JSON.stringify(m(t,60))}`:""})`}function tt(e){let n=e.localName;e.id&&(n+=`#${e.id}`);let t=typeof e.className=="string"?e.className.trim().split(/\s+/).filter(Boolean).slice(0,2):[];t.length&&(n+=`.${t.join(".")}`);let r=m(A(e,80),60);return`<${n}>${r?` ${JSON.stringify(r)}`:""}`}function nt(e){let n=e.ownerDocument.defaultView;return{width:n.innerWidth,height:n.innerHeight}}function M(e){let n=e.getBoundingClientRect();return n.width<=0||n.height<=0||g(e).visibility!=="visible"?null:n}function ae(e,n,t){let r=e.elementFromPoint(n,t);for(;r;){let o=z(r);if(!o)break;let i=o.elementFromPoint(n,t);if(!i||i===r)break;r=i}return r}function ce(e,n,t,r){let o=n?tt(n):"nothing (the point is outside the page)";return new Error(`${u(e)} is covered by ${o} at (${Math.round(t)}, ${Math.round(r)}). Dismiss or act on the covering element (a consent banner, modal or overlay), then run snapshot again before reusing refs.`)}function rt(e){var q;if(!M(e))throw new Error(`${u(e)} is not visible (no box on screen). Run snapshot again; it may be collapsed or hidden.`);try{e.scrollIntoView({block:"center",inline:"center",behavior:"instant"})}catch{}let n=e.getBoundingClientRect(),t=nt(e),r=Math.max(n.left,0),o=Math.min(n.right,t.width),i=Math.max(n.top,0),s=Math.min(n.bottom,t.height);if(o<=r||s<=i)throw new Error(`${u(e)} is outside the viewport and could not be scrolled into it.`);let a=(r+o)/2,l=(i+s)/2,c=ae(e.ownerDocument,a,l),p=c==null?void 0:c.closest("label");if(!c||!(Ye(e,c)||(p==null?void 0:p.control)===e))throw ce(e,c,a,l);let j=e.ownerDocument,P=a,V=l;for(;j!==document;){let b=(q=j.defaultView)==null?void 0:q.frameElement;if(!b)break;let ee=b.getBoundingClientRect(),te=g(b);P+=ee.left+b.clientLeft+parseFloat(te.paddingLeft||"0"),V+=ee.top+b.clientTop+parseFloat(te.paddingTop||"0");let ne=ae(b.ownerDocument,P,V);if(ne!==b)throw ce(e,ne,P,V);j=b.ownerDocument}return{x:a,y:l,hit:c}}function w(e,n,t,r,o={}){let i=e.ownerDocument.defaultView,s=n.startsWith("pointer")?i.PointerEvent??i.MouseEvent:i.MouseEvent,a=n.endsWith("enter")||n.endsWith("leave");return e.dispatchEvent(new s(n,{bubbles:!a,cancelable:!a,composed:!0,clientX:t,clientY:r,screenX:t,screenY:r,button:0,buttons:0,detail:0,pointerId:1,pointerType:"mouse",isPrimary:!0,...o}))}function ot(e){var n,t;for(let r=e;r;r=X(r))if(r.matches(be)&&!T(r)){r.focus({preventScroll:!0});return}(t=(n=e.ownerDocument.activeElement)==null?void 0:n.blur)==null||t.call(n)}function le(e,n,t,r){w(e,"pointerdown",n,t,{buttons:1}),w(e,"mousedown",n,t,{buttons:1,detail:r})&&ot(e),w(e,"pointerup",n,t),w(e,"mouseup",n,t,{detail:r}),w(e,"click",n,t,{detail:r})}function Ce(e,n){if(n!=="hover"&&T(e))throw new Error(`${u(e)} is disabled.`);let{x:t,y:r,hit:o}=rt(e);for(let i of["pointerover","pointerenter","mouseover","mouseenter","pointermove","mousemove"])w(o,i,t,r);n!=="hover"&&(le(o,t,r,1),n==="dblclick"&&(le(o,t,r,2),w(o,"dblclick",t,r,{detail:2})))}var it=new Set(["","text","search","email","url","tel","password","number","date","datetime-local","month","week","time","color"]);function B(e){let n=e.localName;if(n==="textarea")return"field";if(n==="input"){let t=e.type;if(it.has(t))return"field";let r=t==="checkbox"||t==="radio"?"use check/uncheck":t==="file"?"use upload":"it takes no text";throw new Error(`${u(e)} is an <input type=${t}>: ${r}.`)}if(n==="select")throw new Error(`${u(e)} is a <select>: use select with the option's value or label.`);if(e.isContentEditable)return"rich";throw new Error(`${u(e)} is not editable. Run snapshot and pick a textbox.`)}function ue(e){let n=B(e);if(T(e))throw new Error(`${u(e)} is disabled.`);if(e.readOnly)throw new Error(`${u(e)} is read-only.`);return n}function G(e,n){var r;let t=(r=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(e),"value"))==null?void 0:r.set;t?t.call(e,n):e.value=n}function D(e,n,t){let r=e.ownerDocument.defaultView;e.dispatchEvent(new(r.InputEvent??r.Event)("input",{bubbles:!0,composed:!0,inputType:n,data:t}))}function U(e,n){e.dispatchEvent(new e.ownerDocument.defaultView.Event(n,{bubbles:!0}))}function Ie(e){try{let n=e.selectionStart,t=e.selectionEnd;if(n!==null&&t!==null)return[n,t]}catch{}return[e.value.length,e.value.length]}function J(e,n){var t;if(B(e)==="rich"){let r=e.ownerDocument;(t=r.execCommand)!=null&&t.call(r,"insertText",!1,n)||e.append(n)}else{let r=e,[o,i]=Ie(r);G(r,r.value.slice(0,o)+n+r.value.slice(i));try{r.setSelectionRange(o+n.length,o+n.length)}catch{}}D(e,"insertText",n)}function st(e,n){if(B(e)!=="field")return;let t=e,[r,o]=Ie(t);r===o&&(n?o=Math.min(t.value.length,o+1):r=Math.max(0,r-1)),G(t,t.value.slice(0,r)+t.value.slice(o));try{t.setSelectionRange(r,r)}catch{}D(e,n?"deleteContentForward":"deleteContentBackward",null)}function fe(e){if(e.ownerDocument.activeElement===e)return;e.focus({preventScroll:!0});let n=e;if(e.localName==="input"||e.localName==="textarea")try{n.setSelectionRange(n.value.length,n.value.length)}catch{}}function me(){var n;let e=document.activeElement;for(;;){let t=e?((n=z(e))==null?void 0:n.activeElement)??null:null;if(t){e=t;continue}if((e==null?void 0:e.localName)==="iframe"){let r=null;try{r=e.contentDocument}catch{}if(r!=null&&r.activeElement){e=r.activeElement;continue}}break}return e??document.body}function y(e,n,t,r){let o=e.ownerDocument.defaultView,i=ie(n,t),s=new o.KeyboardEvent(n,{key:t,code:oe(t),bubbles:!0,cancelable:!0,composed:!0,...i,...r});for(let a of["keyCode","which","charCode"])s[a]!==i[a]&&Object.defineProperty(s,a,{get:()=>i[a]});return e.dispatchEvent(s)}function at(e){return Array.from(e.querySelectorAll(be)).filter(n=>n.tabIndex>=0&&!T(n)&&!!M(n))}var ct=new Set(["button","link","tab","menuitem","option","clickable"]),lt=new Set(["button","checkbox","radio","switch","tab","menuitem","option","clickable"]);function de(e,n){return n.has(Y(e,"",""))?(e.click(),!0):!1}function ut(e,n){let{key:t,mods:r}=re(n),o=r.ctrlKey||r.metaKey||r.altKey,i=t.length===1&&!o;if(y(e,"keydown",t,r)&&!(t===" "&&e.localName!=="input"&&e.localName!=="textarea"&&de(e,lt)))if(i)y(e,"keypress",t,r),(e.localName==="input"||e.localName==="textarea"||e.isContentEditable)&&J(e,t);else if(t==="Enter")if(y(e,"keypress",t,r),e.localName==="textarea")J(e,`
3
+ `);else if(e.localName==="input"&&e.form){let s=e.form;typeof s.requestSubmit=="function"?s.requestSubmit():s.submit()}else de(e,ct);else if(t==="Tab"){let s=at(e.ownerDocument),a=s.indexOf(e),l=s[(a+(r.shiftKey?-1:1)+s.length)%s.length];l==null||l.focus()}else t==="Backspace"||t==="Delete"?st(e,t==="Delete"):(r.ctrlKey||r.metaKey)&&t.toLowerCase()==="a"&&B(e)==="field"&&e.select();y(e,"keyup",t,r)}function ft(e,n){if(e.localName!=="select")throw new Error(`${u(e)} is not a <select>. For a custom dropdown: click it open, snapshot, then click the option.`);if(T(e))throw new Error(`${u(e)} is disabled.`);let t=e,r=Array.from(t.options),o=n.trim(),i=r.find(s=>s.value===n)??r.find(s=>f(s.label||s.text)===o)??r.find(s=>f(s.label||s.text).toLowerCase()===o.toLowerCase());if(!i){let s=r.slice(0,L).map(a=>JSON.stringify(f(a.label||a.text))).join(", ");throw new Error(`${u(e)} has no option ${JSON.stringify(n)}. Options: ${s}${r.length>L?", \u2026":""}.`)}if(i.disabled)throw new Error(`Option ${JSON.stringify(f(i.label))} of ${u(e)} is disabled.`);return t.focus(),i.selected=!0,U(t,"input"),U(t,"change"),{value:i.value,label:f(i.label||i.text)}}function mt(e,n){let t=_(e);if(t===void 0)throw new Error(`${u(e)} is not a checkbox, radio or switch.`);if(t===n)return{checked:n,changed:!1};if(!n&&e.localName==="input"&&e.type==="radio")throw new Error(`${u(e)} is a radio: it unchecks when another option in its group is checked.`);let r=e.localName==="input"&&!M(e)?Array.from(e.labels??[]).find(o=>M(o)):void 0;if(T(e))throw new Error(`${u(e)} is disabled.`);if(Ce(r??e,"click"),_(e)!==n)throw new Error(`Clicking ${u(e)} did not ${n?"check":"uncheck"} it.`);return{checked:n,changed:!0}}function he(e){if(e.localName==="input"||e.localName==="textarea")return e.value;if(e.localName==="select")return ye(e)??"";let n=e.innerText;return(typeof n=="string"?n:e.textContent||"").trim()}function He(e){let n=e.op;switch(n){case"click":case"dblclick":case"hover":{let t=h(e.selector);return Ce(t,n),{[n==="hover"?"hovered":"clicked"]:u(t)}}case"fill":{let t=h(e.selector),r=ue(t),o=e.text??"";return t.focus({preventScroll:!0}),r==="rich"?(t.textContent=o,D(t,"insertText",o)):(G(t,o),D(t,"insertText",o),U(t,"change")),{filled:u(t),value:r==="rich"?o:t.value}}case"type":{let t=e.selector?h(e.selector):me();ue(t),e.selector&&fe(t);for(let r of e.text??"")y(t,"keydown",r,{}),y(t,"keypress",r,{}),J(t,r),y(t,"keyup",r,{});return{typed:u(t),value:he(t)}}case"press":{if(!e.key)throw new Error("key required: Enter, Tab, Escape, ArrowDown, Control+a \u2026");let t=e.selector?h(e.selector):me();return e.selector&&fe(t),ut(t,e.key),{pressed:e.key,on:u(t)}}case"focus":{let t=h(e.selector);return t.focus({preventScroll:!0}),{focused:u(t)}}case"select":return{selected:ft(h(e.selector),e.value??e.text??"")};case"check":case"uncheck":return mt(h(e.selector),n==="check");case"text":return{text:he(h(e.selector))};case"attribute":{if(!e.attribute)throw new Error("attribute required: the attribute name to read");return{value:h(e.selector).getAttribute(e.attribute)}}case"scrollIntoView":{let t=h(e.selector);return t.scrollIntoView({block:"center",inline:"center",behavior:"instant"}),{scrolled:u(t)}}case"scroll":{let t=e.selector?h(e.selector):document.scrollingElement??document.documentElement;return t.scrollBy({left:e.dx??0,top:e.dy??0,behavior:"instant"}),{x:t.scrollLeft,y:t.scrollTop}}case"count":{if(!e.selector)throw new Error("selector required: a CSS selector to count");return{count:document.querySelectorAll(e.selector).length}}}throw new Error(`Unknown page action ${JSON.stringify(n)}.`)}function Oe(e){let n=e.state==="hidden";if(e.text){let o=document.body,i=o==null?void 0:o.innerText;return{met:(typeof i=="string"?i:(o==null?void 0:o.textContent)||"").includes(e.text)!==n}}let t=null;try{t=h(e.selector)}catch(o){if(e.selector&&Ee(e.selector)&&!n)throw o}return{met:(!!t&&!!M(t))!==n}}function De(e=0){var t;e>x&&(x=e),Le();let n=[];for(let r of Q(Ne({}))){let o=r.el,i=M(o);if(!i)continue;let s=i.left,a=i.top;for(let l=o.ownerDocument;l!==document;){let c=(t=l.defaultView)==null?void 0:t.frameElement;if(!c)break;let p=c.getBoundingClientRect();s+=p.left+c.clientLeft,a+=p.top+c.clientTop,l=c.ownerDocument}s+i.width<=0||a+i.height<=0||s>=innerWidth||a>=innerHeight||n.push({ref:ge(o),label:`${r.role}${r.name?` ${JSON.stringify(m(r.name,60))}`:""}`,x:s,y:a,w:i.width,h:i.height})}return{boxes:n,last:x,width:innerWidth,height:innerHeight}}var Z=6e4,dt=new Set(["input","select","textarea","svg","canvas","video","audio","map"]);function N(e,n){let t=e.nodeType===9?e.body:e;return t?$(t).map(r=>bt(r,n)).join(""):""}function S(e,n){return f(N(e,n))}function E(e){return e.trim()?`
4
4
 
5
5
  ${e.trim()}
6
6
 
7
- `:""}function lt(e,n){let t=e.localName==="ol",r=Number(e.getAttribute("start"))||1,o=" ".repeat(n),i=[];for(let s of $(e)){if(s.nodeType!==1||k(s))continue;let a=M(s,n+1).replace(/\n{2,}/g,`
7
+ `:""}function ht(e,n){let t=e.localName==="ol",r=Number(e.getAttribute("start"))||1,o=" ".repeat(n),i=[];for(let s of $(e)){if(s.nodeType!==1||k(s))continue;let a=N(s,n+1).replace(/\n{2,}/g,`
8
8
  `).trim();if(!a)continue;let[l,...c]=a.split(`
9
9
  `);i.push(`${o}${t?`${r++}.`:"-"} ${l.trim()}`,...c)}return`
10
10
 
11
11
  ${i.join(`
12
12
  `)}
13
13
 
14
- `}function ut(e,n){let t=Array.from(e.querySelectorAll("tr")).filter(i=>i.closest("table")===e&&!k(i)).map(i=>Array.from(i.children).filter(s=>(s.localName==="td"||s.localName==="th")&&!k(s)).map(s=>S(s,n).replace(/\|/g,"\\|")));if(!t.length)return"";let r=Math.max(...t.map(i=>i.length)),o=i=>`| ${[...i,...Array(r-i.length).fill("")].join(" | ")} |`;return E([o(t[0]),o(Array(r).fill("---")),...t.slice(1).map(o)].join(`
15
- `))}function ft(e,n){if(e.nodeType===3)return(e.textContent||"").replace(/\s+/g," ");if(e.nodeType!==1)return"";let t=e;if(k(t)||ct.has(t.localName))return"";let r=t.localName,o=/^h([1-6])$/.exec(r);if(o){let s=S(t,n);return s?E(`${"#".repeat(Number(o[1]))} ${s}`):""}switch(r){case"p":return E(S(t,n));case"br":return`
16
- `;case"hr":return E("---");case"ul":case"ol":return lt(t,n);case"table":return ut(t,n);case"pre":{let s=t.innerText,a=typeof s=="string"?s:t.textContent||"";return E(`\`\`\`
14
+ `}function pt(e,n){let t=Array.from(e.querySelectorAll("tr")).filter(i=>i.closest("table")===e&&!k(i)).map(i=>Array.from(i.children).filter(s=>(s.localName==="td"||s.localName==="th")&&!k(s)).map(s=>S(s,n).replace(/\|/g,"\\|")));if(!t.length)return"";let r=Math.max(...t.map(i=>i.length)),o=i=>`| ${[...i,...Array(r-i.length).fill("")].join(" | ")} |`;return E([o(t[0]),o(Array(r).fill("---")),...t.slice(1).map(o)].join(`
15
+ `))}function bt(e,n){if(e.nodeType===3)return(e.textContent||"").replace(/\s+/g," ");if(e.nodeType!==1)return"";let t=e;if(k(t)||dt.has(t.localName))return"";let r=t.localName,o=/^h([1-6])$/.exec(r);if(o){let s=S(t,n);return s?E(`${"#".repeat(Number(o[1]))} ${s}`):""}switch(r){case"p":return E(S(t,n));case"br":return`
16
+ `;case"hr":return E("---");case"ul":case"ol":return ht(t,n);case"table":return pt(t,n);case"pre":{let s=t.innerText,a=typeof s=="string"?s:t.textContent||"";return E(`\`\`\`
17
17
  ${a.replace(/\n+$/,"")}
18
- \`\`\``)}case"code":{let s=f(t.textContent||"");return s?`\`${s}\``:""}case"blockquote":{let s=M(t,n).trim().replace(/\n{3,}/g,`
18
+ \`\`\``)}case"code":{let s=f(t.textContent||"");return s?`\`${s}\``:""}case"blockquote":{let s=N(t,n).trim().replace(/\n{3,}/g,`
19
19
 
20
20
  `);return s?E(s.split(`
21
21
  `).map(a=>`> ${a}`).join(`
22
- `)):""}case"strong":case"b":{let s=S(t,n);return s?`**${s}**`:""}case"em":case"i":{let s=S(t,n);return s?`_${s}_`:""}case"a":{let s=S(t,n),a=t.href;return s?a&&!a.startsWith("javascript:")?`[${s}](${a})`:s:""}case"img":{let s=f(t.getAttribute("alt")||"");if(!s)return"";let a=t.src;return a&&!a.startsWith("data:")?`![${s}](${a})`:`![${s}]`}case"iframe":{let s=null;try{s=t.contentDocument}catch{}return s?E(M(s,n)):""}}let i=M(t,n);return D.has(g(t).display)?i:E(i)}function mt(e){let n=!1;return e.split(`
22
+ `)):""}case"strong":case"b":{let s=S(t,n);return s?`**${s}**`:""}case"em":case"i":{let s=S(t,n);return s?`_${s}_`:""}case"a":{let s=S(t,n),a=t.href;return s?a&&!a.startsWith("javascript:")?`[${s}](${a})`:s:""}case"img":{let s=f(t.getAttribute("alt")||"");if(!s)return"";let a=t.src;return a&&!a.startsWith("data:")?`![${s}](${a})`:`![${s}]`}case"iframe":{let s=null;try{s=t.contentDocument}catch{}return s?E(N(s,n)):""}}let i=N(t,n);return K.has(g(t).display)?i:E(i)}function gt(e){let n=!1;return e.split(`
23
23
  `).map(t=>{if(t.trimStart().startsWith("```"))return n=!n,t.trim();if(n)return t;let[,r,o]=/^(\s*)(.*)$/.exec(t),i=o.replace(/[ \t]+/g," ").trim();return/^(-|\d+\.) /.test(i)?r+i:i}).join(`
24
24
  `).replace(/\n{3,}/g,`
25
25
 
26
- `).trim()}function He(e){let n=[],t=[],r=!1;for(let o of e.split(`
26
+ `).trim()}function Re(e){let n=[],t=[],r=!1;for(let o of e.split(`
27
27
  `))o.startsWith("```")&&(r=!r),!r&&/^#{1,6} /.test(o)&&t.length&&(n.push(t.join(`
28
28
  `).trim()),t=[]),t.push(o);return t.length&&n.push(t.join(`
29
- `).trim()),n.filter(Boolean)}function Ce(e={}){var o;let n=mt(M(document.body??document.documentElement,0)),t=(o=e.filter)==null?void 0:o.trim().toLowerCase();e.outline?n=He(n).map(i=>i.split(`
29
+ `).trim()),n.filter(Boolean)}function Ke(e={}){var o;let n=gt(N(document.body??document.documentElement,0)),t=(o=e.filter)==null?void 0:o.trim().toLowerCase();e.outline?n=Re(n).map(i=>i.split(`
30
30
  `)[0]).filter(i=>/^#{1,6} /.test(i)&&(!t||i.toLowerCase().includes(t))).join(`
31
- `):t&&(n=He(n).filter(i=>i.toLowerCase().includes(t)).join(`
31
+ `):t&&(n=Re(n).filter(i=>i.toLowerCase().includes(t)).join(`
32
32
 
33
- `)),n||(n=t?`(no section mentions ${JSON.stringify(e.filter)})`:e.outline?"(no headings)":"(no text)");let r=n.length>Q;return r&&(n=`${n.slice(0,Q)}
33
+ `)),n||(n=t?`(no section mentions ${JSON.stringify(e.filter)})`:e.outline?"(no headings)":"(no text)");let r=n.length>Z;return r&&(n=`${n.slice(0,Z)}
34
34
 
35
- \u2026 (truncated at ${Q} characters: narrow with filter, or skim with outline)`),{title:document.title,url:location.href,markdown:n,truncated:r}}function dt(e){switch(e.op){case"snapshot":return Ne(e);case"read":return Ce(e);case"boxes":return Ie(e.base);case"probe":return Ae(e);default:return Le(e)}}var ht=globalThis;ht.__hanzoPage??=e=>{try{return{ok:!0,...dt(e)}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}};})();
35
+ \u2026 (truncated at ${Z} characters: narrow with filter, or skim with outline)`),{title:document.title,url:location.href,markdown:n,truncated:r}}function Et(e){switch(e.op){case"snapshot":return Ae(e);case"read":return Ke(e);case"boxes":return De(e.base);case"probe":return Oe(e);default:return He(e)}}var wt=globalThis;wt.__hanzoPage??=e=>{try{return{ok:!0,...Et(e)}}catch(n){return{ok:!1,error:n instanceof Error?n.message:String(n)}}};})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanzo/browser-extension",
3
- "version": "1.9.65",
3
+ "version": "1.9.67",
4
4
  "description": "Hanzo AI Browser Extension",
5
5
  "license": "MIT",
6
6
  "files": [