@hanzo/browser-extension 1.9.66 → 1.9.68
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/chrome/background.js +91 -77
- package/chrome/content-script.js +15 -19
- package/chrome/manifest.json +1 -1
- package/chrome/page.js +14 -14
- package/chrome/sidebar.js +1 -1
- package/firefox/background.js +49 -56
- package/firefox/content-script.js +15 -19
- package/firefox/manifest.json +1 -1
- package/firefox/page.js +14 -14
- package/firefox/sidebar.js +1 -1
- package/package.json +1 -1
package/chrome/content-script.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
"use strict";(()=>{var te=Object.create;var R=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ie=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var se=(o,e)=>()=>{try{return e||o((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var ae=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of re(e))!oe.call(o,i)&&i!==t&&R(o,i,{get:()=>e[i],enumerable:!(n=ne(e,i))||n.enumerable});return o};var le=(o,e,t)=>(t=o!=null?te(ie(o)):{},ae(e||!o||!o.__esModule?R(t,"default",{value:o,enumerable:!0}):t,o));var G=se((K,V)=>{(function(o,e){if(typeof define=="function"&&define.amd)define("webextension-polyfill",["module"],e);else if(typeof K<"u")e(V);else{var t={exports:{}};e(t),o.browser=t.exports}})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:K,function(o){"use strict";if(!(globalThis.chrome&&globalThis.chrome.runtime&&globalThis.chrome.runtime.id))throw new Error("This script should only be loaded in a browser extension.");if(globalThis.browser&&globalThis.browser.runtime&&globalThis.browser.runtime.id)o.exports=globalThis.browser;else{let e="The message port closed before a response was received.",t=n=>{let i={alarms:{clear:{minArgs:0,maxArgs:1},clearAll:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getAll:{minArgs:0,maxArgs:0}},bookmarks:{create:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},getChildren:{minArgs:1,maxArgs:1},getRecent:{minArgs:1,maxArgs:1},getSubTree:{minArgs:1,maxArgs:1},getTree:{minArgs:0,maxArgs:0},move:{minArgs:2,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeTree:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}},browserAction:{disable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},enable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},getBadgeBackgroundColor:{minArgs:1,maxArgs:1},getBadgeText:{minArgs:1,maxArgs:1},getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},openPopup:{minArgs:0,maxArgs:0},setBadgeBackgroundColor:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setBadgeText:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},browsingData:{remove:{minArgs:2,maxArgs:2},removeCache:{minArgs:1,maxArgs:1},removeCookies:{minArgs:1,maxArgs:1},removeDownloads:{minArgs:1,maxArgs:1},removeFormData:{minArgs:1,maxArgs:1},removeHistory:{minArgs:1,maxArgs:1},removeLocalStorage:{minArgs:1,maxArgs:1},removePasswords:{minArgs:1,maxArgs:1},removePluginData:{minArgs:1,maxArgs:1},settings:{minArgs:0,maxArgs:0}},commands:{getAll:{minArgs:0,maxArgs:0}},contextMenus:{remove:{minArgs:1,maxArgs:1},removeAll:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},cookies:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:1,maxArgs:1},getAllCookieStores:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},devtools:{inspectedWindow:{eval:{minArgs:1,maxArgs:2,singleCallbackArg:!1}},panels:{create:{minArgs:3,maxArgs:3,singleCallbackArg:!0},elements:{createSidebarPane:{minArgs:1,maxArgs:1}}}},downloads:{cancel:{minArgs:1,maxArgs:1},download:{minArgs:1,maxArgs:1},erase:{minArgs:1,maxArgs:1},getFileIcon:{minArgs:1,maxArgs:2},open:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},pause:{minArgs:1,maxArgs:1},removeFile:{minArgs:1,maxArgs:1},resume:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},extension:{isAllowedFileSchemeAccess:{minArgs:0,maxArgs:0},isAllowedIncognitoAccess:{minArgs:0,maxArgs:0}},history:{addUrl:{minArgs:1,maxArgs:1},deleteAll:{minArgs:0,maxArgs:0},deleteRange:{minArgs:1,maxArgs:1},deleteUrl:{minArgs:1,maxArgs:1},getVisits:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1}},i18n:{detectLanguage:{minArgs:1,maxArgs:1},getAcceptLanguages:{minArgs:0,maxArgs:0}},identity:{launchWebAuthFlow:{minArgs:1,maxArgs:1}},idle:{queryState:{minArgs:1,maxArgs:1}},management:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},getSelf:{minArgs:0,maxArgs:0},setEnabled:{minArgs:2,maxArgs:2},uninstallSelf:{minArgs:0,maxArgs:1}},notifications:{clear:{minArgs:1,maxArgs:1},create:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:0},getPermissionLevel:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},pageAction:{getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},hide:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},permissions:{contains:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},request:{minArgs:1,maxArgs:1}},runtime:{getBackgroundPage:{minArgs:0,maxArgs:0},getPlatformInfo:{minArgs:0,maxArgs:0},openOptionsPage:{minArgs:0,maxArgs:0},requestUpdateCheck:{minArgs:0,maxArgs:0},sendMessage:{minArgs:1,maxArgs:3},sendNativeMessage:{minArgs:2,maxArgs:2},setUninstallURL:{minArgs:1,maxArgs:1}},sessions:{getDevices:{minArgs:0,maxArgs:1},getRecentlyClosed:{minArgs:0,maxArgs:1},restore:{minArgs:0,maxArgs:1}},storage:{local:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},managed:{get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1}},sync:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}}},tabs:{captureVisibleTab:{minArgs:0,maxArgs:2},create:{minArgs:1,maxArgs:1},detectLanguage:{minArgs:0,maxArgs:1},discard:{minArgs:0,maxArgs:1},duplicate:{minArgs:1,maxArgs:1},executeScript:{minArgs:1,maxArgs:2},get:{minArgs:1,maxArgs:1},getCurrent:{minArgs:0,maxArgs:0},getZoom:{minArgs:0,maxArgs:1},getZoomSettings:{minArgs:0,maxArgs:1},goBack:{minArgs:0,maxArgs:1},goForward:{minArgs:0,maxArgs:1},highlight:{minArgs:1,maxArgs:1},insertCSS:{minArgs:1,maxArgs:2},move:{minArgs:2,maxArgs:2},query:{minArgs:1,maxArgs:1},reload:{minArgs:0,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeCSS:{minArgs:1,maxArgs:2},sendMessage:{minArgs:2,maxArgs:3},setZoom:{minArgs:1,maxArgs:2},setZoomSettings:{minArgs:1,maxArgs:2},update:{minArgs:1,maxArgs:2}},topSites:{get:{minArgs:0,maxArgs:0}},webNavigation:{getAllFrames:{minArgs:1,maxArgs:1},getFrame:{minArgs:1,maxArgs:1}},webRequest:{handlerBehaviorChanged:{minArgs:0,maxArgs:0}},windows:{create:{minArgs:0,maxArgs:1},get:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:1},getCurrent:{minArgs:0,maxArgs:1},getLastFocused:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}}};if(Object.keys(i).length===0)throw new Error("api-metadata.json has not been included in browser-polyfill");class d extends WeakMap{constructor(s,c=void 0){super(c),this.createItem=s}get(s){return this.has(s)||this.set(s,this.createItem(s)),super.get(s)}}let a=r=>r&&typeof r=="object"&&typeof r.then=="function",u=(r,s)=>(...c)=>{n.runtime.lastError?r.reject(new Error(n.runtime.lastError.message)):s.singleCallbackArg||c.length<=1&&s.singleCallbackArg!==!1?r.resolve(c[0]):r.resolve(c)},g=r=>r==1?"argument":"arguments",S=(r,s)=>function(m,...b){if(b.length<s.minArgs)throw new Error(`Expected at least ${s.minArgs} ${g(s.minArgs)} for ${r}(), got ${b.length}`);if(b.length>s.maxArgs)throw new Error(`Expected at most ${s.maxArgs} ${g(s.maxArgs)} for ${r}(), got ${b.length}`);return new Promise((v,l)=>{if(s.fallbackToNoCallback)try{m[r](...b,u({resolve:v,reject:l},s))}catch(h){console.warn(`${r} API method doesn't seem to support the callback parameter, falling back to call it without a callback: `,h),m[r](...b),s.fallbackToNoCallback=!1,s.noCallback=!0,v()}else s.noCallback?(m[r](...b),v()):m[r](...b,u({resolve:v,reject:l},s))})},A=(r,s,c)=>new Proxy(s,{apply(m,b,v){return c.call(b,r,...v)}}),_=Function.call.bind(Object.prototype.hasOwnProperty),T=(r,s={},c={})=>{let m=Object.create(null),b={has(l,h){return h in r||h in m},get(l,h,L){if(h in m)return m[h];if(!(h in r))return;let w=r[h];if(typeof w=="function")if(typeof s[h]=="function")w=A(r,r[h],s[h]);else if(_(c,h)){let H=S(h,c[h]);w=A(r,r[h],H)}else w=w.bind(r);else if(typeof w=="object"&&w!==null&&(_(s,h)||_(c,h)))w=T(w,s[h],c[h]);else if(_(c,"*"))w=T(w,s[h],c["*"]);else return Object.defineProperty(m,h,{configurable:!0,enumerable:!0,get(){return r[h]},set(H){r[h]=H}}),w;return m[h]=w,w},set(l,h,L,w){return h in m?m[h]=L:r[h]=L,!0},defineProperty(l,h,L){return Reflect.defineProperty(m,h,L)},deleteProperty(l,h){return Reflect.deleteProperty(m,h)}},v=Object.create(r);return new Proxy(v,b)},p=r=>({addListener(s,c,...m){s.addListener(r.get(c),...m)},hasListener(s,c){return s.hasListener(r.get(c))},removeListener(s,c){s.removeListener(r.get(c))}}),f=new d(r=>typeof r!="function"?r:function(c){let m=T(c,{},{getContent:{minArgs:0,maxArgs:0}});r(m)}),x=new d(r=>typeof r!="function"?r:function(c,m,b){let v=!1,l,h=new Promise($=>{l=function(C){v=!0,$(C)}}),L;try{L=r(c,m,l)}catch($){L=Promise.reject($)}let w=L!==!0&&a(L);if(L!==!0&&!w&&!v)return!1;let H=$=>{$.then(C=>{b(C)},C=>{let W;C&&(C instanceof Error||typeof C.message=="string")?W=C.message:W="An unexpected error occurred",b({__mozWebExtensionPolyfillReject__:!0,message:W})}).catch(C=>{console.error("Failed to send onMessage rejected reply",C)})};return H(w?L:h),!0}),y=({reject:r,resolve:s},c)=>{n.runtime.lastError?n.runtime.lastError.message===e?s():r(new Error(n.runtime.lastError.message)):c&&c.__mozWebExtensionPolyfillReject__?r(new Error(c.message)):s(c)},z=(r,s,c,...m)=>{if(m.length<s.minArgs)throw new Error(`Expected at least ${s.minArgs} ${g(s.minArgs)} for ${r}(), got ${m.length}`);if(m.length>s.maxArgs)throw new Error(`Expected at most ${s.maxArgs} ${g(s.maxArgs)} for ${r}(), got ${m.length}`);return new Promise((b,v)=>{let l=y.bind(null,{resolve:b,reject:v});m.push(l),c.sendMessage(...m)})},E={devtools:{network:{onRequestFinished:p(f)}},runtime:{onMessage:p(x),onMessageExternal:p(x),sendMessage:z.bind(null,"sendMessage",{minArgs:1,maxArgs:3})},tabs:{sendMessage:z.bind(null,"sendMessage",{minArgs:2,maxArgs:3})}},k={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return i.privacy={network:{"*":k},services:{"*":k},websites:{"*":k}},T(n,E,i)};o.exports=t(chrome)}})});var he=le(G());var N="hanzo_shortcut_inspect",O={ctrl:!0,meta:!1,alt:!1,shift:!1,key:""};function F(o,e){return!(e.ctrl&&!o.ctrlKey||e.meta&&!o.metaKey||e.alt&&!o.altKey||e.shift&&!o.shiftKey||!e.ctrl&&o.ctrlKey||!e.meta&&o.metaKey||!e.alt&&o.altKey||!e.shift&&o.shiftKey||e.key&&(o.key||"").toLowerCase()!==e.key.toLowerCase())}async function X(o){try{let t=(await o.get([N]))[N];if(t&&typeof t=="object"&&typeof t.ctrl=="boolean"&&typeof t.alt=="boolean"&&typeof t.shift=="boolean"&&typeof t.meta=="boolean"&&typeof t.key=="string")return t}catch{}return{...O}}var j=class{constructor(){this.inspectShortcut={...O};this.loadShortcut(),this.watchShortcut(),this.setupClickHandler(),this.injectHelpers(),this.setupMessageHandlers()}async loadShortcut(){try{this.inspectShortcut=await X(chrome.storage.local)}catch{this.inspectShortcut={...O}}}watchShortcut(){try{chrome.storage.onChanged.addListener((e,t)=>{if(t!=="local")return;let n=e[N];n&&(n.newValue&&typeof n.newValue=="object"?this.inspectShortcut=n.newValue:this.inspectShortcut={...O})})}catch{}}setupClickHandler(){document.addEventListener("click",e=>{if(!F(e,this.inspectShortcut))return;e.preventDefault(),e.stopPropagation();let t=e.target,n=this.extractSourceLocation(t),i=this.getDOMPath(t),d={event:"elementSelected",framework:this.detectFramework(),domPath:i,source:n,fallbackId:t.getAttribute("data-hanzo-id")||void 0};chrome.runtime.sendMessage({action:"elementSelected",data:d})})}setupMessageHandlers(){chrome.runtime.onMessage.addListener((e,t,n)=>{var i;switch(e.action){case"ai.control.start":return P.show(e.task||"AI is controlling this page"),n({success:!0}),!0;case"ai.control.stop":return P.hide(),n({success:!0}),!0;case"ai.control.cursor":return P.moveCursor(e.x,e.y),n({success:!0}),!0;case"ai.control.highlight":return P.highlight(e.selector),n({success:!0}),!0;case"ai.control.status":return P.updateStatus(e.text),n({success:!0}),!0;case"page.overlay.toggle":return(e.side==="left"||e.side==="right")&&M.setSide(e.side),(e.mode==="push"||e.mode==="overlay")&&M.setMode(e.mode),(e.width==="compact"||e.width==="default"||e.width==="wide")&&M.setWidth(e.width),n({success:!0,open:M.toggle()}),!0;case"page.overlay.show":return(e.side==="left"||e.side==="right")&&M.setSide(e.side),(e.mode==="push"||e.mode==="overlay")&&M.setMode(e.mode),(e.width==="compact"||e.width==="default"||e.width==="wide")&&M.setWidth(e.width),M.show(),n({success:!0,open:!0}),!0;case"page.overlay.hide":return M.hide(),n({success:!0,open:!1}),!0;case"page.overlay.status":return n({success:!0,open:M.isOpen(),side:M.getSide(),mode:M.getMode()}),!0;case"page.overlay.setSide":return e.side==="left"||e.side==="right"?(M.setSide(e.side),n({success:!0,side:e.side})):n({success:!1,error:'side must be "left" or "right"'}),!0;case"page.overlay.setMode":return e.mode==="push"||e.mode==="overlay"?(M.setMode(e.mode),n({success:!0,mode:e.mode})):n({success:!1,error:'mode must be "push" or "overlay"'}),!0;case"page.overlay.setWidth":return e.width==="compact"||e.width==="default"||e.width==="wide"?(M.setWidth(e.width),n({success:!0,width:e.width})):n({success:!1,error:"width must be compact|default|wide"}),!0;case"page.overlay.setEnabled":return typeof e.enabled=="boolean"?(M.setEnabled(e.enabled),n({success:!0,enabled:e.enabled})):n({success:!1,error:"enabled must be boolean"}),!0;case"tool.picker.start":return Y.start(),n({success:!0}),!0;case"tool.picker.stop":return Y.stop(),n({success:!0}),!0;case"tool.pageinfo":return n({success:!0,info:ce()}),!0;case"tool.console.start":return Q.show(),n({success:!0}),!0;case"tool.console.hide":return Q.hide(),n({success:!0}),!0}return e.action==="getContent"?(n({content:((i=document.documentElement)==null?void 0:i.outerHTML)||""}),!0):e.action==="setContent"?(typeof e.content=="string"&&(document.open(),document.write(e.content),document.close()),n({success:!0}),!0):!1})}extractSourceLocation(e){switch(this.detectFramework()){case"react":return this.extractReactSource(e);case"vue":return this.extractVueSource(e);case"svelte":return this.extractSvelteSource(e);default:return}}extractReactSource(e){var d,a;if(!window.__REACT_DEVTOOLS_GLOBAL_HOOK__)return;let n=this.findReactFiber(e);if(!n)return;let i=n._debugSource||((d=n.pendingProps)==null?void 0:d.__source)||((a=n.memoizedProps)==null?void 0:a.__source);if(i&&i.fileName)return{file:i.fileName,line:i.lineNumber,column:i.columnNumber}}findReactFiber(e){let t=Object.keys(e).find(n=>n.startsWith("__reactInternalInstance$")||n.startsWith("__reactFiber$"));return t?e[t]:null}extractVueSource(e){var i,d;if(!window.__VUE_DEVTOOLS_GLOBAL_HOOK__)return;let n=e.__vueParentComponent;if(n||(n=e.__vue__),(i=n==null?void 0:n.type)!=null&&i.__file){let a={file:n.type.__file,line:1};return(d=n.vnode)!=null&&d.loc&&(a.line=n.vnode.loc.start.line,a.column=n.vnode.loc.start.column),a}}extractSvelteSource(e){var n,i;let t=e.__svelte_component;if((i=(n=t==null?void 0:t.$$)==null?void 0:n.ctx)!=null&&i.$$_location)return t.$$.ctx.$$_location}detectFramework(){return window.__REACT_DEVTOOLS_GLOBAL_HOOK__?"react":window.__VUE_DEVTOOLS_GLOBAL_HOOK__?"vue":window.__svelte?"svelte":null}getDOMPath(e){let t=[],n=e;for(;n&&n!==document.body;){let i=n.tagName.toLowerCase();n.id?i+=`#${n.id}`:n.className&&(i+=`.${n.className.split(" ").join(".")}`),t.unshift(i),n=n.parentElement}return t.join(" > ")}injectHelpers(){let e=document.createElement("style");e.textContent=`
|
|
1
|
+
"use strict";(()=>{var se=Object.create;var j=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ae=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var ce=(s,e)=>()=>{try{return e||s((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var de=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ie(e))!le.call(s,o)&&o!==t&&j(s,o,{get:()=>e[o],enumerable:!(n=oe(e,o))||n.enumerable});return s};var ue=(s,e,t)=>(t=s!=null?se(ae(s)):{},de(e||!s||!s.__esModule?j(t,"default",{value:s,enumerable:!0}):t,s));var G=ce((R,V)=>{(function(s,e){if(typeof define=="function"&&define.amd)define("webextension-polyfill",["module"],e);else if(typeof R<"u")e(V);else{var t={exports:{}};e(t),s.browser=t.exports}})(typeof globalThis<"u"?globalThis:typeof self<"u"?self:R,function(s){"use strict";if(!(globalThis.chrome&&globalThis.chrome.runtime&&globalThis.chrome.runtime.id))throw new Error("This script should only be loaded in a browser extension.");if(globalThis.browser&&globalThis.browser.runtime&&globalThis.browser.runtime.id)s.exports=globalThis.browser;else{let e="The message port closed before a response was received.",t=n=>{let o={alarms:{clear:{minArgs:0,maxArgs:1},clearAll:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getAll:{minArgs:0,maxArgs:0}},bookmarks:{create:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},getChildren:{minArgs:1,maxArgs:1},getRecent:{minArgs:1,maxArgs:1},getSubTree:{minArgs:1,maxArgs:1},getTree:{minArgs:0,maxArgs:0},move:{minArgs:2,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeTree:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}},browserAction:{disable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},enable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},getBadgeBackgroundColor:{minArgs:1,maxArgs:1},getBadgeText:{minArgs:1,maxArgs:1},getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},openPopup:{minArgs:0,maxArgs:0},setBadgeBackgroundColor:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setBadgeText:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},browsingData:{remove:{minArgs:2,maxArgs:2},removeCache:{minArgs:1,maxArgs:1},removeCookies:{minArgs:1,maxArgs:1},removeDownloads:{minArgs:1,maxArgs:1},removeFormData:{minArgs:1,maxArgs:1},removeHistory:{minArgs:1,maxArgs:1},removeLocalStorage:{minArgs:1,maxArgs:1},removePasswords:{minArgs:1,maxArgs:1},removePluginData:{minArgs:1,maxArgs:1},settings:{minArgs:0,maxArgs:0}},commands:{getAll:{minArgs:0,maxArgs:0}},contextMenus:{remove:{minArgs:1,maxArgs:1},removeAll:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},cookies:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:1,maxArgs:1},getAllCookieStores:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},devtools:{inspectedWindow:{eval:{minArgs:1,maxArgs:2,singleCallbackArg:!1}},panels:{create:{minArgs:3,maxArgs:3,singleCallbackArg:!0},elements:{createSidebarPane:{minArgs:1,maxArgs:1}}}},downloads:{cancel:{minArgs:1,maxArgs:1},download:{minArgs:1,maxArgs:1},erase:{minArgs:1,maxArgs:1},getFileIcon:{minArgs:1,maxArgs:2},open:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},pause:{minArgs:1,maxArgs:1},removeFile:{minArgs:1,maxArgs:1},resume:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},extension:{isAllowedFileSchemeAccess:{minArgs:0,maxArgs:0},isAllowedIncognitoAccess:{minArgs:0,maxArgs:0}},history:{addUrl:{minArgs:1,maxArgs:1},deleteAll:{minArgs:0,maxArgs:0},deleteRange:{minArgs:1,maxArgs:1},deleteUrl:{minArgs:1,maxArgs:1},getVisits:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1}},i18n:{detectLanguage:{minArgs:1,maxArgs:1},getAcceptLanguages:{minArgs:0,maxArgs:0}},identity:{launchWebAuthFlow:{minArgs:1,maxArgs:1}},idle:{queryState:{minArgs:1,maxArgs:1}},management:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},getSelf:{minArgs:0,maxArgs:0},setEnabled:{minArgs:2,maxArgs:2},uninstallSelf:{minArgs:0,maxArgs:1}},notifications:{clear:{minArgs:1,maxArgs:1},create:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:0},getPermissionLevel:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},pageAction:{getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},hide:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},permissions:{contains:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},request:{minArgs:1,maxArgs:1}},runtime:{getBackgroundPage:{minArgs:0,maxArgs:0},getPlatformInfo:{minArgs:0,maxArgs:0},openOptionsPage:{minArgs:0,maxArgs:0},requestUpdateCheck:{minArgs:0,maxArgs:0},sendMessage:{minArgs:1,maxArgs:3},sendNativeMessage:{minArgs:2,maxArgs:2},setUninstallURL:{minArgs:1,maxArgs:1}},sessions:{getDevices:{minArgs:0,maxArgs:1},getRecentlyClosed:{minArgs:0,maxArgs:1},restore:{minArgs:0,maxArgs:1}},storage:{local:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},managed:{get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1}},sync:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}}},tabs:{captureVisibleTab:{minArgs:0,maxArgs:2},create:{minArgs:1,maxArgs:1},detectLanguage:{minArgs:0,maxArgs:1},discard:{minArgs:0,maxArgs:1},duplicate:{minArgs:1,maxArgs:1},executeScript:{minArgs:1,maxArgs:2},get:{minArgs:1,maxArgs:1},getCurrent:{minArgs:0,maxArgs:0},getZoom:{minArgs:0,maxArgs:1},getZoomSettings:{minArgs:0,maxArgs:1},goBack:{minArgs:0,maxArgs:1},goForward:{minArgs:0,maxArgs:1},highlight:{minArgs:1,maxArgs:1},insertCSS:{minArgs:1,maxArgs:2},move:{minArgs:2,maxArgs:2},query:{minArgs:1,maxArgs:1},reload:{minArgs:0,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeCSS:{minArgs:1,maxArgs:2},sendMessage:{minArgs:2,maxArgs:3},setZoom:{minArgs:1,maxArgs:2},setZoomSettings:{minArgs:1,maxArgs:2},update:{minArgs:1,maxArgs:2}},topSites:{get:{minArgs:0,maxArgs:0}},webNavigation:{getAllFrames:{minArgs:1,maxArgs:1},getFrame:{minArgs:1,maxArgs:1}},webRequest:{handlerBehaviorChanged:{minArgs:0,maxArgs:0}},windows:{create:{minArgs:0,maxArgs:1},get:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:1},getCurrent:{minArgs:0,maxArgs:1},getLastFocused:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}}};if(Object.keys(o).length===0)throw new Error("api-metadata.json has not been included in browser-polyfill");class d extends WeakMap{constructor(i,c=void 0){super(c),this.createItem=i}get(i){return this.has(i)||this.set(i,this.createItem(i)),super.get(i)}}let a=r=>r&&typeof r=="object"&&typeof r.then=="function",f=(r,i)=>(...c)=>{n.runtime.lastError?r.reject(new Error(n.runtime.lastError.message)):i.singleCallbackArg||c.length<=1&&i.singleCallbackArg!==!1?r.resolve(c[0]):r.resolve(c)},h=r=>r==1?"argument":"arguments",y=(r,i)=>function(g,...b){if(b.length<i.minArgs)throw new Error(`Expected at least ${i.minArgs} ${h(i.minArgs)} for ${r}(), got ${b.length}`);if(b.length>i.maxArgs)throw new Error(`Expected at most ${i.maxArgs} ${h(i.maxArgs)} for ${r}(), got ${b.length}`);return new Promise((A,l)=>{if(i.fallbackToNoCallback)try{g[r](...b,f({resolve:A,reject:l},i))}catch(u){console.warn(`${r} API method doesn't seem to support the callback parameter, falling back to call it without a callback: `,u),g[r](...b),i.fallbackToNoCallback=!1,i.noCallback=!0,A()}else i.noCallback?(g[r](...b),A()):g[r](...b,f({resolve:A,reject:l},i))})},E=(r,i,c)=>new Proxy(i,{apply(g,b,A){return c.call(b,r,...A)}}),_=Function.call.bind(Object.prototype.hasOwnProperty),L=(r,i={},c={})=>{let g=Object.create(null),b={has(l,u){return u in r||u in g},get(l,u,z){if(u in g)return g[u];if(!(u in r))return;let k=r[u];if(typeof k=="function")if(typeof i[u]=="function")k=E(r,r[u],i[u]);else if(_(c,u)){let H=y(u,c[u]);k=E(r,r[u],H)}else k=k.bind(r);else if(typeof k=="object"&&k!==null&&(_(i,u)||_(c,u)))k=L(k,i[u],c[u]);else if(_(c,"*"))k=L(k,i[u],c["*"]);else return Object.defineProperty(g,u,{configurable:!0,enumerable:!0,get(){return r[u]},set(H){r[u]=H}}),k;return g[u]=k,k},set(l,u,z,k){return u in g?g[u]=z:r[u]=z,!0},defineProperty(l,u,z){return Reflect.defineProperty(g,u,z)},deleteProperty(l,u){return Reflect.deleteProperty(g,u)}},A=Object.create(r);return new Proxy(A,b)},m=r=>({addListener(i,c,...g){i.addListener(r.get(c),...g)},hasListener(i,c){return i.hasListener(r.get(c))},removeListener(i,c){i.removeListener(r.get(c))}}),p=new d(r=>typeof r!="function"?r:function(c){let g=L(c,{},{getContent:{minArgs:0,maxArgs:0}});r(g)}),x=new d(r=>typeof r!="function"?r:function(c,g,b){let A=!1,l,u=new Promise($=>{l=function(C){A=!0,$(C)}}),z;try{z=r(c,g,l)}catch($){z=Promise.reject($)}let k=z!==!0&&a(z);if(z!==!0&&!k&&!A)return!1;let H=$=>{$.then(C=>{b(C)},C=>{let U;C&&(C instanceof Error||typeof C.message=="string")?U=C.message:U="An unexpected error occurred",b({__mozWebExtensionPolyfillReject__:!0,message:U})}).catch(C=>{console.error("Failed to send onMessage rejected reply",C)})};return H(k?z:u),!0}),v=({reject:r,resolve:i},c)=>{n.runtime.lastError?n.runtime.lastError.message===e?i():r(new Error(n.runtime.lastError.message)):c&&c.__mozWebExtensionPolyfillReject__?r(new Error(c.message)):i(c)},T=(r,i,c,...g)=>{if(g.length<i.minArgs)throw new Error(`Expected at least ${i.minArgs} ${h(i.minArgs)} for ${r}(), got ${g.length}`);if(g.length>i.maxArgs)throw new Error(`Expected at most ${i.maxArgs} ${h(i.maxArgs)} for ${r}(), got ${g.length}`);return new Promise((b,A)=>{let l=v.bind(null,{resolve:b,reject:A});g.push(l),c.sendMessage(...g)})},w={devtools:{network:{onRequestFinished:m(p)}},runtime:{onMessage:m(x),onMessageExternal:m(x),sendMessage:T.bind(null,"sendMessage",{minArgs:1,maxArgs:3})},tabs:{sendMessage:T.bind(null,"sendMessage",{minArgs:2,maxArgs:3})}},M={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return o.privacy={network:{"*":M},services:{"*":M},websites:{"*":M}},L(n,w,o)};s.exports=t(chrome)}})});var be=ue(G());var N="hanzo_shortcut_inspect",O={ctrl:!0,meta:!1,alt:!1,shift:!1,key:""};function F(s,e){return!(e.ctrl&&!s.ctrlKey||e.meta&&!s.metaKey||e.alt&&!s.altKey||e.shift&&!s.shiftKey||!e.ctrl&&s.ctrlKey||!e.meta&&s.metaKey||!e.alt&&s.altKey||!e.shift&&s.shiftKey||e.key&&(s.key||"").toLowerCase()!==e.key.toLowerCase())}async function X(s){try{let t=(await s.get([N]))[N];if(t&&typeof t=="object"&&typeof t.ctrl=="boolean"&&typeof t.alt=="boolean"&&typeof t.shift=="boolean"&&typeof t.meta=="boolean"&&typeof t.key=="string")return t}catch{}return{...O}}function he(s){return s?Math.ceil(s.length/4):0}function Y(s){return(s||[]).reduce((e,t)=>e+he((t==null?void 0:t.content)||""),0)}function Z(s,e,t){return s&&s!=="auto"?s:t<=900&&e.includes("zen5-flash")?"zen5-flash":"zen5"}var ge=/embed|image|video|music|voice|tts|rerank|guard|foley|moderation|router/;function q(s){return s.filter(e=>(e==null?void 0:e.owned_by)==="zenlm"&&!ge.test(e.id))}var W=class{constructor(){this.inspectShortcut={...O};this.loadShortcut(),this.watchShortcut(),this.setupClickHandler(),this.injectHelpers(),this.setupMessageHandlers()}async loadShortcut(){try{this.inspectShortcut=await X(chrome.storage.local)}catch{this.inspectShortcut={...O}}}watchShortcut(){try{chrome.storage.onChanged.addListener((e,t)=>{if(t!=="local")return;let n=e[N];n&&(n.newValue&&typeof n.newValue=="object"?this.inspectShortcut=n.newValue:this.inspectShortcut={...O})})}catch{}}setupClickHandler(){document.addEventListener("click",e=>{if(!F(e,this.inspectShortcut))return;e.preventDefault(),e.stopPropagation();let t=e.target,n=this.extractSourceLocation(t),o=this.getDOMPath(t),d={event:"elementSelected",framework:this.detectFramework(),domPath:o,source:n,fallbackId:t.getAttribute("data-hanzo-id")||void 0};chrome.runtime.sendMessage({action:"elementSelected",data:d})})}setupMessageHandlers(){chrome.runtime.onMessage.addListener((e,t,n)=>{var o;switch(e.action){case"ai.control.start":return P.show(e.task||"AI is controlling this page"),n({success:!0}),!0;case"ai.control.stop":return P.hide(),n({success:!0}),!0;case"ai.control.cursor":return P.moveCursor(e.x,e.y),n({success:!0}),!0;case"ai.control.highlight":return P.highlight(e.selector),n({success:!0}),!0;case"ai.control.status":return P.updateStatus(e.text),n({success:!0}),!0;case"page.overlay.toggle":return(e.side==="left"||e.side==="right")&&S.setSide(e.side),(e.mode==="push"||e.mode==="overlay")&&S.setMode(e.mode),(e.width==="compact"||e.width==="default"||e.width==="wide")&&S.setWidth(e.width),n({success:!0,open:S.toggle()}),!0;case"page.overlay.show":return(e.side==="left"||e.side==="right")&&S.setSide(e.side),(e.mode==="push"||e.mode==="overlay")&&S.setMode(e.mode),(e.width==="compact"||e.width==="default"||e.width==="wide")&&S.setWidth(e.width),S.show(),n({success:!0,open:!0}),!0;case"page.overlay.hide":return S.hide(),n({success:!0,open:!1}),!0;case"page.overlay.status":return n({success:!0,open:S.isOpen(),side:S.getSide(),mode:S.getMode()}),!0;case"page.overlay.setSide":return e.side==="left"||e.side==="right"?(S.setSide(e.side),n({success:!0,side:e.side})):n({success:!1,error:'side must be "left" or "right"'}),!0;case"page.overlay.setMode":return e.mode==="push"||e.mode==="overlay"?(S.setMode(e.mode),n({success:!0,mode:e.mode})):n({success:!1,error:'mode must be "push" or "overlay"'}),!0;case"page.overlay.setWidth":return e.width==="compact"||e.width==="default"||e.width==="wide"?(S.setWidth(e.width),n({success:!0,width:e.width})):n({success:!1,error:"width must be compact|default|wide"}),!0;case"page.overlay.setEnabled":return typeof e.enabled=="boolean"?(S.setEnabled(e.enabled),n({success:!0,enabled:e.enabled})):n({success:!1,error:"enabled must be boolean"}),!0;case"tool.picker.start":return J.start(),n({success:!0}),!0;case"tool.picker.stop":return J.stop(),n({success:!0}),!0;case"tool.pageinfo":return n({success:!0,info:me()}),!0;case"tool.console.start":return ee.show(),n({success:!0}),!0;case"tool.console.hide":return ee.hide(),n({success:!0}),!0}return e.action==="getContent"?(n({content:((o=document.documentElement)==null?void 0:o.outerHTML)||""}),!0):e.action==="setContent"?(typeof e.content=="string"&&(document.open(),document.write(e.content),document.close()),n({success:!0}),!0):!1})}extractSourceLocation(e){switch(this.detectFramework()){case"react":return this.extractReactSource(e);case"vue":return this.extractVueSource(e);case"svelte":return this.extractSvelteSource(e);default:return}}extractReactSource(e){var d,a;if(!window.__REACT_DEVTOOLS_GLOBAL_HOOK__)return;let n=this.findReactFiber(e);if(!n)return;let o=n._debugSource||((d=n.pendingProps)==null?void 0:d.__source)||((a=n.memoizedProps)==null?void 0:a.__source);if(o&&o.fileName)return{file:o.fileName,line:o.lineNumber,column:o.columnNumber}}findReactFiber(e){let t=Object.keys(e).find(n=>n.startsWith("__reactInternalInstance$")||n.startsWith("__reactFiber$"));return t?e[t]:null}extractVueSource(e){var o,d;if(!window.__VUE_DEVTOOLS_GLOBAL_HOOK__)return;let n=e.__vueParentComponent;if(n||(n=e.__vue__),(o=n==null?void 0:n.type)!=null&&o.__file){let a={file:n.type.__file,line:1};return(d=n.vnode)!=null&&d.loc&&(a.line=n.vnode.loc.start.line,a.column=n.vnode.loc.start.column),a}}extractSvelteSource(e){var n,o;let t=e.__svelte_component;if((o=(n=t==null?void 0:t.$$)==null?void 0:n.ctx)!=null&&o.$$_location)return t.$$.ctx.$$_location}detectFramework(){return window.__REACT_DEVTOOLS_GLOBAL_HOOK__?"react":window.__VUE_DEVTOOLS_GLOBAL_HOOK__?"vue":window.__svelte?"svelte":null}getDOMPath(e){let t=[],n=e;for(;n&&n!==document.body;){let o=n.tagName.toLowerCase();n.id?o+=`#${n.id}`:n.className&&(o+=`.${n.className.split(" ").join(".")}`),t.unshift(o),n=n.parentElement}return t.join(" > ")}injectHelpers(){let e=document.createElement("style");e.textContent=`
|
|
2
2
|
[data-hanzo-hover] {
|
|
3
3
|
outline: 2px dashed #ff6b6b !important;
|
|
4
4
|
outline-offset: 2px !important;
|
|
5
5
|
}
|
|
6
|
-
`,document.head.appendChild(e),document.addEventListener("mousemove",t=>{document.querySelectorAll("[data-hanzo-hover]").forEach(n=>{n.removeAttribute("data-hanzo-hover")}),F(t,this.inspectShortcut)&&t.target instanceof HTMLElement&&t.target.setAttribute("data-hanzo-hover","true")})}},P=(()=>{let
|
|
6
|
+
`,document.head.appendChild(e),document.addEventListener("mousemove",t=>{document.querySelectorAll("[data-hanzo-hover]").forEach(n=>{n.removeAttribute("data-hanzo-hover")}),F(t,this.inspectShortcut)&&t.target instanceof HTMLElement&&t.target.setAttribute("data-hanzo-hover","true")})}},P=(()=>{let s=null,e=null,t=null,n=null,o=null,d=[],a=!1,f="hanzo-ai-overlay",h="hanzo-ai-overlay-styles",y=["click","dblclick","mousedown","mouseup","contextmenu","pointerdown","pointerup","touchstart","touchmove","touchend","wheel","keydown","keyup","keypress"];function E(){if(document.getElementById(h))return;let r=document.createElement("style");r.id=h,r.textContent=`
|
|
7
7
|
/* ---- Overlay backdrop ---- */
|
|
8
|
-
#${
|
|
8
|
+
#${f} {
|
|
9
9
|
position: fixed;
|
|
10
10
|
inset: 0;
|
|
11
11
|
z-index: 2147483646;
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
opacity: 0;
|
|
19
19
|
transition: opacity 300ms ease;
|
|
20
20
|
}
|
|
21
|
-
#${
|
|
21
|
+
#${f}.hanzo-visible {
|
|
22
22
|
opacity: 1;
|
|
23
23
|
}
|
|
24
24
|
|
|
@@ -217,12 +217,12 @@
|
|
|
217
217
|
box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
|
|
218
218
|
transition: left 0.15s, top 0.15s, width 0.15s, height 0.15s;
|
|
219
219
|
}
|
|
220
|
-
`,document.head.appendChild(r)}function _(r){return r instanceof Node?!!(
|
|
220
|
+
`,document.head.appendChild(r)}function _(r){return r instanceof Node?!!(s!=null&&s.contains(r)||t!=null&&t.contains(r)||n!=null&&n.contains(r)||e!=null&&e.contains(r)||o!=null&&o.contains(r)):!1}function L(r){if(a){if(r instanceof KeyboardEvent&&r.key==="Escape"){chrome.runtime.sendMessage({action:"ai.control.cancel"}),x();return}_(r.target)||(r.preventDefault(),r.stopPropagation(),r.stopImmediatePropagation())}}function m(r){if(a!==r){a=r;for(let i of y)r?document.addEventListener(i,L,!0):document.removeEventListener(i,L,!0)}}function p(r){var i;s&&x(),E(),m(!0),s=document.createElement("div"),s.id=f,document.body.appendChild(s),e=document.createElement("div"),e.className="hanzo-ai-cursor",e.style.left=`${window.innerWidth/2}px`,e.style.top=`${window.innerHeight/2}px`,document.body.appendChild(e),t=document.createElement("div"),t.className="hanzo-ai-status",t.innerHTML=`
|
|
221
221
|
<span class="hanzo-brand-bubble">AI</span>
|
|
222
222
|
<div class="hanzo-pulse-dot"></div>
|
|
223
|
-
<span class="hanzo-label">${
|
|
223
|
+
<span class="hanzo-label">${M(r||"Hanzo AI is controlling this tab")}</span><span class="hanzo-dots"></span>
|
|
224
224
|
<button class="hanzo-stop-btn">Stop</button>
|
|
225
|
-
`,document.body.appendChild(t),(
|
|
225
|
+
`,document.body.appendChild(t),(i=t.querySelector(".hanzo-stop-btn"))==null||i.addEventListener("click",()=>{chrome.runtime.sendMessage({action:"ai.control.cancel"}),x()}),n=document.createElement("button"),n.className="hanzo-ai-cancel",n.textContent="Take Back Control",n.addEventListener("click",()=>{chrome.runtime.sendMessage({action:"ai.control.cancel"}),x()}),document.body.appendChild(n),requestAnimationFrame(()=>{s==null||s.classList.add("hanzo-visible"),e==null||e.classList.add("hanzo-visible"),t==null||t.classList.add("hanzo-visible"),n==null||n.classList.add("hanzo-visible")})}function x(){s==null||s.classList.remove("hanzo-visible"),e==null||e.classList.remove("hanzo-visible"),t==null||t.classList.remove("hanzo-visible"),n==null||n.classList.remove("hanzo-visible");let r={overlay:s,cursor:e,statusEl:t,cancelBtn:n,highlightEl:o},i=[...d];setTimeout(()=>{var c,g,b,A,l;(c=r.overlay)==null||c.remove(),(g=r.cursor)==null||g.remove(),(b=r.statusEl)==null||b.remove(),(A=r.cancelBtn)==null||A.remove(),(l=r.highlightEl)==null||l.remove();for(let u of i)u.remove()},320),m(!1),s=null,e=null,t=null,n=null,o=null,d=[]}function v(r,i){var A;if(!e)return;let c=Math.max(0,Math.min(window.innerWidth,Number.isFinite(r)?r:0)),g=Math.max(0,Math.min(window.innerHeight,Number.isFinite(i)?i:0)),b=document.createElement("div");for(b.className="hanzo-cursor-trail",b.style.left=`${c}px`,b.style.top=`${g}px`,document.body.appendChild(b),d.push(b),setTimeout(()=>{b.remove(),d=d.filter(l=>l!==b)},400);d.length>10;)(A=d.shift())==null||A.remove();e.style.left=`${c}px`,e.style.top=`${g}px`}function T(r){if(o==null||o.remove(),o=null,!(!r||typeof r!="string"))try{let i=document.querySelector(r);if(!i)return;let c=i.getBoundingClientRect();if(c.width===0&&c.height===0)return;o=document.createElement("div"),o.className="hanzo-ai-highlight",o.style.left=`${Math.max(0,c.left-4)}px`,o.style.top=`${Math.max(0,c.top-4)}px`,o.style.width=`${c.width+8}px`,o.style.height=`${c.height+8}px`,document.body.appendChild(o)}catch{}}function w(r){if(!t)return;let i=t.querySelector(".hanzo-label");i&&(i.textContent=r||"Hanzo AI is controlling this tab")}function M(r){let i=document.createElement("div");return i.textContent=r,i.innerHTML}return{show:p,hide:x,moveCursor:v,highlight:T,updateStatus:w}})(),Q={compact:320,default:420,wide:560},K=class{constructor(){this.mounted=!1;this.enabled=!1;this.open=!1;this.side="right";this.mode="overlay";this.width="default";this.sending=!1;this.watchMode=!1;this.editMode=!1;this.modelsLoaded=!1;this.messages=[];this.selectedContext=null;this.hoveredElement=null;this.editingElement=null;this.root=null;this.launcher=null;this.panel=null;this.messagesEl=null;this.inputEl=null;this.sendBtn=null;this.modelEl=null;this.contextEl=null;this.watchBtn=null;this.editBtn=null;this.statusEl=null;this.highlightBox=null;this.injectStyles(),this.mount(),this.bindGlobalEvents(),this.restorePrefs()}restorePrefs(){var e,t;try{let n=(t=(e=typeof browser<"u"?browser:chrome)==null?void 0:e.storage)==null?void 0:t.sync;if(!(n!=null&&n.get))return;let o=n.get(["overlaySide","overlayMode","overlayWidth"]),d=a=>{var f,h;((a==null?void 0:a.overlaySide)==="left"||(a==null?void 0:a.overlaySide)==="right")&&(this.side=a.overlaySide,(f=this.root)==null||f.setAttribute("data-side",this.side)),((a==null?void 0:a.overlayMode)==="push"||(a==null?void 0:a.overlayMode)==="overlay")&&(this.mode=a.overlayMode,(h=this.root)==null||h.setAttribute("data-mode",this.mode)),((a==null?void 0:a.overlayWidth)==="compact"||(a==null?void 0:a.overlayWidth)==="default"||(a==null?void 0:a.overlayWidth)==="wide")&&(this.width=a.overlayWidth,this.applyWidth()),this.applyPushIfOpen()};o&&typeof o.then=="function"?o.then(d).catch(()=>{}):n.get(["overlaySide","overlayMode","overlayWidth"],d)}catch{}}applyWidth(){let e=Q[this.width]??Q.default;this.root&&(this.root.style.setProperty("--hanzo-overlay-width",`${e}px`),this.root.style.width=`min(${e}px, 100vw)`),document.documentElement.style.setProperty("--hanzo-overlay-width",`${e}px`)}applyPushIfOpen(){let e=document.documentElement;e.classList.remove("hanzo-overlay-push","hanzo-overlay-push-left","hanzo-overlay-push-right"),this.open&&this.enabled&&this.mode==="push"&&e.classList.add("hanzo-overlay-push",`hanzo-overlay-push-${this.side}`)}toggle(){return!this.enabled||!this.open?(this.show(),!0):(this.hide(),!1)}isOpen(){return this.open}getSide(){return this.side}getMode(){return this.mode}setSide(e){var t;this.side=e,(t=this.root)==null||t.setAttribute("data-side",e),this.applyPushIfOpen(),this.persist({overlaySide:e})}setMode(e){var t;this.mode=e,(t=this.root)==null||t.setAttribute("data-mode",e),this.applyPushIfOpen(),this.persist({overlayMode:e})}setWidth(e){this.width=e,this.applyWidth(),this.persist({overlayWidth:e})}setEnabled(e){var t;this.enabled=e,(t=this.root)==null||t.setAttribute("data-enabled",e?"true":"false"),e||this.hide(),this.persist({overlayEnabled:e})}persist(e){var t,n,o;try{let d=(n=(t=typeof browser<"u"?browser:chrome)==null?void 0:t.storage)==null?void 0:n.sync;(o=d==null?void 0:d.set)==null||o.call(d,e)}catch{}}show(){var e,t;this.ensureMounted(),this.enabled=!0,this.open=!0,(e=this.root)==null||e.setAttribute("data-enabled","true"),(t=this.root)==null||t.setAttribute("data-open","true"),this.applyPushIfOpen(),this.loadModels(),this.focusInput()}hide(){var e;this.open=!1,(e=this.root)==null||e.setAttribute("data-open","false"),this.applyPushIfOpen(),this.updateStatus(""),this.clearHighlight(),this.setWatchMode(!1),this.setEditMode(!1)}ensureMounted(){this.mounted||this.mount()}injectStyles(){if(document.getElementById("hanzo-page-overlay-styles"))return;let e=document.createElement("style");e.id="hanzo-page-overlay-styles",e.textContent=`
|
|
226
226
|
/* Edge-pinned sidebar panel \u2014 no FAB, opened from extension popup.
|
|
227
227
|
Hanzo brand: monochrome (white primary, neutral surfaces). No blue. */
|
|
228
228
|
#hanzo-page-overlay-root {
|
|
@@ -498,7 +498,7 @@
|
|
|
498
498
|
outline: 2px solid rgba(255, 255, 255, 0.92) !important;
|
|
499
499
|
outline-offset: 2px !important;
|
|
500
500
|
}
|
|
501
|
-
`,document.head.appendChild(e)}mount(){var t,n,
|
|
501
|
+
`,document.head.appendChild(e)}mount(){var t,n,o,d,a,f;if(this.mounted)return;this.root=document.createElement("div"),this.root.id="hanzo-page-overlay-root",this.root.setAttribute("data-open","false"),this.root.setAttribute("data-enabled","false"),this.root.setAttribute("data-side",this.side),this.root.setAttribute("data-mode",this.mode),this.applyWidth(),this.root.innerHTML=`
|
|
502
502
|
<div class="hanzo-page-panel" role="dialog" aria-label="Hanzo Page Assistant">
|
|
503
503
|
<div class="hanzo-page-header">
|
|
504
504
|
<div class="hanzo-page-brand">Hanzo</div>
|
|
@@ -519,11 +519,7 @@
|
|
|
519
519
|
</div>
|
|
520
520
|
<div class="hanzo-model-row">
|
|
521
521
|
<select data-role="model">
|
|
522
|
-
<option value="
|
|
523
|
-
<option value="claude-opus-4-20250514">Claude Opus 4</option>
|
|
524
|
-
<option value="gpt-4o">GPT-4o</option>
|
|
525
|
-
<option value="zen-coder-flash">Zen Coder Flash</option>
|
|
526
|
-
<option value="zen-max">Zen Max</option>
|
|
522
|
+
<option value="auto">Auto</option>
|
|
527
523
|
</select>
|
|
528
524
|
</div>
|
|
529
525
|
<div class="hanzo-page-messages" data-role="messages">
|
|
@@ -534,11 +530,11 @@
|
|
|
534
530
|
<button data-role="send" type="button">Ask</button>
|
|
535
531
|
</div>
|
|
536
532
|
</div>
|
|
537
|
-
`,this.panel=this.root.querySelector(".hanzo-page-panel"),this.launcher=null,this.messagesEl=this.root.querySelector('[data-role="messages"]'),this.inputEl=this.root.querySelector('[data-role="input"]'),this.sendBtn=this.root.querySelector('[data-role="send"]'),this.modelEl=this.root.querySelector('[data-role="model"]'),this.contextEl=this.root.querySelector(".hanzo-page-context"),this.watchBtn=this.root.querySelector('[data-role="watch"]'),this.editBtn=this.root.querySelector('[data-role="edit"]'),this.statusEl=this.root.querySelector(".hanzo-page-status"),(t=this.root.querySelector('[data-role="close"]'))==null||t.addEventListener("click",()=>this.hide());let e=this.root.querySelector('[data-role="pin-mode"]');e==null||e.setAttribute("data-active",this.mode==="push"?"true":"false"),e==null||e.addEventListener("click",()=>{let
|
|
538
|
-
`)}async askPageQuestion(){var
|
|
539
|
-
`)},...this.messages.slice(-8),{role:"user",content:e}];try{let
|
|
540
|
-
`);navigator.clipboard.writeText(r).catch(()=>{}),chrome.runtime.sendMessage({action:"elementSelected",data:{selector:x,fullPath:
|
|
541
|
-
`)}var
|
|
533
|
+
`,this.panel=this.root.querySelector(".hanzo-page-panel"),this.launcher=null,this.messagesEl=this.root.querySelector('[data-role="messages"]'),this.inputEl=this.root.querySelector('[data-role="input"]'),this.sendBtn=this.root.querySelector('[data-role="send"]'),this.modelEl=this.root.querySelector('[data-role="model"]'),this.contextEl=this.root.querySelector(".hanzo-page-context"),this.watchBtn=this.root.querySelector('[data-role="watch"]'),this.editBtn=this.root.querySelector('[data-role="edit"]'),this.statusEl=this.root.querySelector(".hanzo-page-status"),(t=this.root.querySelector('[data-role="close"]'))==null||t.addEventListener("click",()=>this.hide());let e=this.root.querySelector('[data-role="pin-mode"]');e==null||e.setAttribute("data-active",this.mode==="push"?"true":"false"),e==null||e.addEventListener("click",()=>{let h=this.mode==="push"?"overlay":"push";this.setMode(h),e.setAttribute("data-active",h==="push"?"true":"false")}),(n=this.watchBtn)==null||n.addEventListener("click",()=>this.setWatchMode(!this.watchMode)),(o=this.editBtn)==null||o.addEventListener("click",()=>this.setEditMode(!this.editMode)),(d=this.sendBtn)==null||d.addEventListener("click",()=>this.askPageQuestion()),(a=this.inputEl)==null||a.addEventListener("keydown",h=>{h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),this.askPageQuestion())}),(f=this.inputEl)==null||f.addEventListener("input",()=>{this.inputEl&&(this.inputEl.style.height="auto",this.inputEl.style.height=`${Math.min(this.inputEl.scrollHeight,110)}px`)}),document.documentElement.appendChild(this.root),this.mounted=!0}bindGlobalEvents(){document.addEventListener("mousemove",e=>this.onMouseMove(e),!0),document.addEventListener("click",e=>this.onDocumentClick(e),!0),document.addEventListener("keydown",e=>this.onKeyDown(e),!0)}onMouseMove(e){if(!this.watchMode)return;let t=this.getPageTarget(e.target);t&&(this.hoveredElement=t,this.showHighlight(t),this.selectedContext||this.contextEl&&(this.contextEl.textContent=this.getElementSummary(t)))}onDocumentClick(e){if(!this.watchMode&&!this.editMode)return;let t=this.getPageTarget(e.target);t&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.watchMode&&(this.selectedContext=this.captureElementContext(t),this.contextEl&&(this.contextEl.textContent=this.getElementSummary(t)),this.updateStatus("Element selected")),this.editMode&&(this.enableInlineEdit(t),this.updateStatus("Editing element")))}onKeyDown(e){if(e.key==="Escape"){if(this.editingElement){this.disableInlineEdit(this.editingElement,!1),this.updateStatus("Edit canceled"),e.preventDefault();return}this.open&&(this.hide(),e.preventDefault())}}getPageTarget(e){var t;return!(e instanceof HTMLElement)||(t=this.root)!=null&&t.contains(e)||!e.isConnected||e.tagName.toLowerCase()==="html"||e.tagName.toLowerCase()==="body"?null:e}setWatchMode(e){var t;this.watchMode=e,e&&this.setEditMode(!1),(t=this.watchBtn)==null||t.setAttribute("data-active",e?"true":"false"),e?this.updateStatus("Watch mode on"):(this.hoveredElement=null,this.clearHighlight(),!this.selectedContext&&this.contextEl&&(this.contextEl.textContent="Use Watch to inspect page elements."))}setEditMode(e){var t;this.editMode=e,e&&this.setWatchMode(!1),(t=this.editBtn)==null||t.setAttribute("data-active",e?"true":"false"),!e&&this.editingElement?this.disableInlineEdit(this.editingElement,!0):e&&this.updateStatus("Edit mode on")}enableInlineEdit(e){if(this.editingElement&&this.editingElement!==e&&this.disableInlineEdit(this.editingElement,!0),e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){e.focus(),this.editingElement=e;return}e.hasAttribute("data-hanzo-original-html")||e.setAttribute("data-hanzo-original-html",e.innerHTML),e.setAttribute("contenteditable","true"),e.setAttribute("spellcheck","true"),e.setAttribute("data-hanzo-inline-editing","true"),e.focus(),this.editingElement=e;let t=o=>{o.key==="Escape"&&(this.disableInlineEdit(e,!1),this.updateStatus("Edit reverted")),o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),this.disableInlineEdit(e,!0),this.updateStatus("Edit applied"))},n=()=>{this.disableInlineEdit(e,!0),this.updateStatus("Edit applied")};e.addEventListener("keydown",t,{once:!0}),e.addEventListener("blur",n,{once:!0})}disableInlineEdit(e,t){if(!t){let n=e.getAttribute("data-hanzo-original-html");n!==null&&(e.innerHTML=n)}e.removeAttribute("contenteditable"),e.removeAttribute("spellcheck"),e.removeAttribute("data-hanzo-inline-editing"),e.removeAttribute("data-hanzo-original-html"),this.editingElement===e&&(this.editingElement=null)}showHighlight(e){let t=e.getBoundingClientRect();if(t.width===0&&t.height===0){this.clearHighlight();return}this.highlightBox||(this.highlightBox=document.createElement("div"),this.highlightBox.className="hanzo-page-highlight",document.documentElement.appendChild(this.highlightBox)),this.highlightBox.style.left=`${Math.max(0,t.left-3)}px`,this.highlightBox.style.top=`${Math.max(0,t.top-3)}px`,this.highlightBox.style.width=`${t.width+6}px`,this.highlightBox.style.height=`${t.height+6}px`}clearHighlight(){var e;(e=this.highlightBox)==null||e.remove(),this.highlightBox=null}captureElementContext(e){let t=this.normalizeText(e.innerText||e.textContent||"");return{selector:this.buildSelector(e),tag:e.tagName.toLowerCase(),text:t.slice(0,800),html:e.outerHTML.slice(0,1200)}}buildSelector(e){if(e.id)return`#${e.id}`;let t=[],n=e,o=0;for(;n&&o<6;){let d=n.tagName.toLowerCase();if(n.classList.length>0){let f=Array.from(n.classList).slice(0,2).join(".");f&&(d+=`.${f}`)}let a=n.parentElement;if(a){let f=Array.from(a.children).filter(h=>h.tagName===n.tagName);if(f.length>1){let h=f.indexOf(n)+1;d+=`:nth-of-type(${h})`}}t.unshift(d),n=a,o+=1}return t.join(" > ")}normalizeText(e){return e.replace(/\s+/g," ").trim()}getElementSummary(e){let t=this.captureElementContext(e);return`${t.tag} \u2022 ${t.selector}`}async loadModels(){if(!(this.modelsLoaded||!this.modelEl))try{let e=await chrome.runtime.sendMessage({action:"chat.listModels"});if(!(e!=null&&e.success)||!Array.isArray(e.models))return;for(let t of q(e.models)){let n=document.createElement("option");n.value=t.id,n.textContent=t.name||t.id,this.modelEl.appendChild(n)}this.modelsLoaded=!0}catch{}}focusInput(){this.inputEl&&this.inputEl.focus()}appendMessage(e,t){if(!this.messagesEl)return;let n=document.createElement("div");n.className=`hanzo-page-msg ${e}`,n.textContent=t,this.messagesEl.appendChild(n),this.messagesEl.scrollTop=this.messagesEl.scrollHeight}updateStatus(e){this.statusEl&&(this.statusEl.textContent=e)}buildPageContext(){var o,d;let e=this.normalizeText(((d=(o=window.getSelection)==null?void 0:o.call(window))==null?void 0:d.toString())||""),t=[`URL: ${location.href}`,`Title: ${document.title||"Untitled"}`];e&&t.push(`TextSelection: ${e.slice(0,600)}`);let n=this.selectedContext||(this.hoveredElement?this.captureElementContext(this.hoveredElement):null);return n&&(t.push(`ElementSelector: ${n.selector}`),n.text&&t.push(`ElementText: ${n.text.slice(0,600)}`),t.push(`ElementHTML: ${n.html.slice(0,800)}`)),t.join(`
|
|
534
|
+
`)}async askPageQuestion(){var f,h;if(this.sending||!this.inputEl)return;let e=this.normalizeText(this.inputEl.value);if(!e)return;let t=await chrome.runtime.sendMessage({action:"auth.getToken"});if(!(t!=null&&t.success)||!t.token){this.appendMessage("assistant","Please sign in from the Hanzo sidebar/popup before using page chat.");return}this.sending=!0,this.updateStatus("Thinking..."),this.sendBtn&&(this.sendBtn.disabled=!0),this.inputEl.value="",this.inputEl.style.height="auto",this.appendMessage("user",e);let o=[{role:"system",content:["You are Hanzo page overlay assistant.","Use provided page context and selected element context when relevant.","Be concise and provide concrete UI or DOM edit suggestions when asked.","",this.buildPageContext()].join(`
|
|
535
|
+
`)},...this.messages.slice(-8),{role:"user",content:e}],d=Array.from(((f=this.modelEl)==null?void 0:f.options)||[],y=>y.value),a=Z(((h=this.modelEl)==null?void 0:h.value)||"auto",d,Y(o));try{let y=await chrome.runtime.sendMessage({action:"chat.complete",model:a,messages:o});if(!(y!=null&&y.success)||!y.content)throw new Error((y==null?void 0:y.error)||"No response from chat service");let E=String(y.content).trim();this.appendMessage("assistant",E||"No response content."),this.messages.push({role:"user",content:e},{role:"assistant",content:E}),this.messages=this.messages.slice(-20),this.updateStatus("Ready")}catch(y){this.appendMessage("assistant",`Error: ${(y==null?void 0:y.message)||"Chat request failed"}`),this.updateStatus("Error")}finally{this.sending=!1,this.sendBtn&&(this.sendBtn.disabled=!1),this.focusInput()}}},S=new K,J=(()=>{let s=!1,e=null,t=null,n=null;function o(m){if(m.id)return`#${m.id}`;let p=m.tagName.toLowerCase(),x=Array.from(m.classList).filter(w=>!w.startsWith("hanzo-")).slice(0,3),v=p;if(x.length&&(v+=`.${x.join(".")}`),document.querySelectorAll(v).length>1){let w=m.parentElement;if(w){let M=Array.from(w.children).indexOf(m)+1;v+=`:nth-child(${M})`}}return v}function d(m){let p=[],x=m;for(;x&&x!==document.documentElement;)p.unshift(o(x)),x=x.parentElement;return p.join(" > ")}function a(){e||(e=document.createElement("div"),e.id="hanzo-picker-overlay",e.style.cssText="position:fixed;pointer-events:none;z-index:2147483646;border:2px solid #fff;border-radius:3px;background:rgba(255,255,255,0.06);transition:all 0.1s ease;display:none;",t=document.createElement("div"),t.id="hanzo-picker-label",t.style.cssText="position:fixed;z-index:2147483647;pointer-events:none;background:#000;color:#fff;font:11px/1.4 Zen Mono,Menlo,monospace;padding:3px 8px;border-radius:4px;max-width:400px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:none;box-shadow:0 2px 8px rgba(0,0,0,0.4);",document.body.appendChild(e),document.body.appendChild(t))}function f(m){var M,r,i,c,g,b,A;if(!m)return;let p=(M=m.closest)==null?void 0:M.call(m,"[data-at]");if(p)return{at:p.getAttribute("data-at")||"",component:p.getAttribute("data-is")||"",usedIn:p.getAttribute("data-in")||"",via:"gui"};let x=Object.keys(m).find(l=>l.startsWith("__reactFiber$")||l.startsWith("__reactInternalInstance$")),v=x?m[x]:null;for(;v;){let l=v._debugSource||((r=v._debugInfo)==null?void 0:r[0]);if(l!=null&&l.fileName)return{at:`${String(l.fileName).split("/").pop()}:${l.lineNumber??0}`,file:l.fileName,line:l.lineNumber??0,component:typeof v.type=="function"?v.type.displayName||v.type.name||"":String(v.type||""),via:"react"};v=v.return}let T=m;for(;T;){let l=(i=T.__svelte_meta)==null?void 0:i.loc;if(l!=null&&l.file)return{at:`${String(l.file).split("/").pop()}:${l.line??0}`,file:l.file,line:l.line??0,via:"svelte"};T=T.parentElement}let w=m;for(;w;){let l=w.__vueParentComponent||w.__vue__,u=((c=l==null?void 0:l.type)==null?void 0:c.__file)||((g=l==null?void 0:l.$options)==null?void 0:g.__file);if(u)return{at:String(u).split("/").pop()||String(u),file:u,component:((b=l==null?void 0:l.type)==null?void 0:b.name)||((A=l==null?void 0:l.$options)==null?void 0:A.name)||"",via:"vue"};w=w.parentElement}return{at:location.pathname,file:location.href,selector:o(m),via:"dom"}}function h(m){var v;if(!s)return;let p=m.target;if(!p||p===e||p===t||(v=p.id)!=null&&v.startsWith("hanzo-picker"))return;n=p;let x=p.getBoundingClientRect();if(e&&(e.style.display="block",e.style.top=x.top+"px",e.style.left=x.left+"px",e.style.width=x.width+"px",e.style.height=x.height+"px"),t){t.style.display="block",t.textContent=o(p);let T=x.top-28;t.style.top=(T>0?T:x.bottom+4)+"px",t.style.left=x.left+"px"}}function y(m){if(!s)return;m.preventDefault(),m.stopPropagation(),m.stopImmediatePropagation();let p=n||m.target;if(!p)return;let x=o(p),v=d(p),T=p.tagName.toLowerCase(),w=(p.textContent||"").trim().slice(0,80),M=p.getBoundingClientRect(),r=[`Selector: ${x}`,`Path: ${v}`,`Tag: ${T}`,`Size: ${Math.round(M.width)}x${Math.round(M.height)}`,p.id?`ID: ${p.id}`:"",p.className?`Classes: ${p.className}`:"",w?`Text: "${w}"`:""].filter(Boolean).join(`
|
|
536
|
+
`);navigator.clipboard.writeText(r).catch(()=>{}),chrome.runtime.sendMessage({action:"elementSelected",data:{selector:x,fullPath:v,tag:T,text:w,source:f(p),rect:{x:M.x,y:M.y,w:M.width,h:M.height}}}),L()}function E(m){m.key==="Escape"&&(m.preventDefault(),L())}function _(){s||(s=!0,a(),document.addEventListener("mousemove",h,!0),document.addEventListener("click",y,!0),document.addEventListener("keydown",E,!0),document.body.style.cursor="crosshair")}function L(){s=!1,document.removeEventListener("mousemove",h,!0),document.removeEventListener("click",y,!0),document.removeEventListener("keydown",E,!0),document.body.style.cursor="",e&&(e.style.display="none"),t&&(t.style.display="none"),n=null}return{start:_,stop:L}})();function me(){let s=h=>{var y;return((y=document.querySelector(`meta[name="${h}"], meta[property="${h}"]`))==null?void 0:y.getAttribute("content"))||""},e=[`Title: ${document.title}`,`URL: ${location.href}`,`Description: ${s("description")||s("og:description")}`,`Charset: ${document.characterSet}`,`Language: ${document.documentElement.lang||"unknown"}`,`Viewport: ${s("viewport")}`],t=[];window.__REACT_DEVTOOLS_GLOBAL_HOOK__&&t.push("React"),window.__VUE_DEVTOOLS_GLOBAL_HOOK__&&t.push("Vue"),window.__svelte&&t.push("Svelte"),window.__NEXT_DATA__&&t.push("Next.js"),window.__NUXT__&&t.push("Nuxt"),document.querySelector("[ng-version]")&&t.push("Angular"),t.length&&e.push(`Frameworks: ${t.join(", ")}`);let n=document.querySelectorAll("script[src]").length,o=document.querySelectorAll('link[rel="stylesheet"]').length,d=document.querySelectorAll("img").length,a=document.querySelectorAll("a[href]").length;e.push(`Resources: ${n} scripts, ${o} stylesheets, ${d} images, ${a} links`);let f=performance.getEntriesByType("navigation")[0];return f&&e.push(`Load: ${Math.round(f.loadEventEnd-f.startTime)}ms (DOM: ${Math.round(f.domContentLoadedEventEnd-f.startTime)}ms)`),e.filter(h=>!h.endsWith(": ")).join(`
|
|
537
|
+
`)}var ee=(()=>{let s=null,e=null,t=null,n=!1;function o(){s||(s=document.createElement("div"),s.id="hanzo-console-root",s.style.cssText='position:fixed;bottom:20px;left:20px;right:20px;z-index:2147483646;font-family:Zen Mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;font-size:12px;display:none;',s.innerHTML=`
|
|
542
538
|
<div style="background:rgba(0,0,0,0.92);backdrop-filter:blur(12px);border:1px solid rgba(255,255,255,0.15);border-radius:10px;overflow:hidden;box-shadow:0 8px 32px rgba(0,0,0,0.5);">
|
|
543
539
|
<div id="hanzo-console-output" style="max-height:200px;overflow-y:auto;padding:8px 12px;color:#ccc;white-space:pre-wrap;word-break:break-all;"></div>
|
|
544
540
|
<div style="display:flex;align-items:center;border-top:1px solid rgba(255,255,255,0.1);padding:0 12px;">
|
|
@@ -547,4 +543,4 @@
|
|
|
547
543
|
<span style="color:#444;font-size:10px;margin-left:8px;">Esc to close</span>
|
|
548
544
|
</div>
|
|
549
545
|
</div>
|
|
550
|
-
`,document.body.appendChild(
|
|
546
|
+
`,document.body.appendChild(s),e=s.querySelector("#hanzo-console-input"),t=s.querySelector("#hanzo-console-output"),e==null||e.addEventListener("keydown",h=>{if(h.key==="Escape"){f();return}if(h.key!=="Enter"||!(e!=null&&e.value.trim()))return;let y=e.value.trim();e.value="",d(`> ${y}`,"#888");try{let E=(0,eval)(y);d(String(E),"#4CAF50")}catch(E){d((E==null?void 0:E.message)||String(E),"#F44336")}}))}function d(h,y){if(!t)return;let E=document.createElement("div");E.style.color=y,E.textContent=h,t.appendChild(E),t.scrollTop=t.scrollHeight}function a(){o(),s&&(s.style.display="block"),n=!0,setTimeout(()=>e==null?void 0:e.focus(),50)}function f(){s&&(s.style.display="none"),n=!1}return{show:a,hide:f,isVisible:()=>n}})();new W;var I,te,B,ne,D,re;try{let s=((te=(I=browser==null?void 0:browser.runtime)==null?void 0:I.connect)==null?void 0:te.call(I,{name:"zap-keepalive"}))||((ne=(B=chrome==null?void 0:chrome.runtime)==null?void 0:B.connect)==null?void 0:ne.call(B,{name:"zap-keepalive"}));if(s){let e=setInterval(()=>{try{s.postMessage({type:"ping",t:Date.now()})}catch{clearInterval(e)}},1e4);(re=(D=s.onDisconnect)==null?void 0:D.addListener)==null||re.call(D,()=>{var t;(t=chrome==null?void 0:chrome.runtime)==null||t.lastError,clearInterval(e)})}}catch{}})();
|
package/chrome/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"manifest_version": 3,
|
|
3
3
|
"name": "Hanzo AI",
|
|
4
|
-
"version": "1.9.
|
|
4
|
+
"version": "1.9.68",
|
|
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
|
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxfXGh0lPUT5m04GKfjUwrLsV6pLaK3VcZuFRPogqAir2tzyLYnQPRtHynue9yvDyguIVnlkwvcwfDOYZrvH76zbw4s6onPBG8HqTKO6LQ9K3kdO1qBBkMMjdOgULQ1MrWThEbpU7NSTiwLYpEta/jAvrKRCAeKIlQE8p6htZmPy9aRUZuae66JgLcAlzD2vviX9sVB1asFABJVswL1RgZ55/8IzZaUrFjzOo9OHK4hmEOtudzkML+5silsAYdC+1BZugph2x94ai17YmZTCL1XyUa5Ke4q80cj+i9rOTgzhZs+mruyhL/AvNVOXilsgqCdNqSz77naWzC3pVGbxOewIDAQAB",
|
|
7
7
|
"permissions": [
|
package/chrome/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=
|
|
3
|
-
`);else if(e.localName==="input"&&e.form){let s=e.form;typeof s.requestSubmit=="function"?s.requestSubmit():s.submit()}else
|
|
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
|
|
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
|
|
15
|
-
`))}function
|
|
16
|
-
`;case"hr":return E("---");case"ul":case"ol":return
|
|
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=
|
|
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}]`}case"iframe":{let s=null;try{s=t.contentDocument}catch{}return s?E(
|
|
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}]`}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
|
|
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
|
|
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=
|
|
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>
|
|
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 ${
|
|
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)}}};})();
|