@rtrvr-ai/rover 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/embed.js +568 -0
- package/dist/index.d.ts +115 -0
- package/dist/loader.d.ts +1 -0
- package/dist/loader.js +8 -0
- package/dist/rover.js +15958 -0
- package/dist/worker/rover-worker.js +4387 -0
- package/package.json +44 -0
package/dist/embed.js
ADDED
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
var __ROVER_SCRIPT_URL__=(document.currentScript&&document.currentScript.src)||'';
|
|
2
|
+
"use strict";var __roverSDK=(()=>{var Uo=Object.defineProperty;var _c=Object.getOwnPropertyDescriptor;var Tc=Object.getOwnPropertyNames;var xc=Object.prototype.hasOwnProperty;var vc=(e,t,n)=>t in e?Uo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Rc=(e,t)=>{for(var n in t)Uo(e,n,{get:t[n],enumerable:!0})},Sc=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Tc(t))!xc.call(e,r)&&r!==n&&Uo(e,r,{get:()=>t[r],enumerable:!(o=_c(t,r))||o.enumerable});return e};var kc=e=>Sc(Uo({},"__esModule",{value:!0}),e);var W=(e,t,n)=>vc(e,typeof t!="symbol"?t+"":t,n);var ef={};Rc(ef,{boot:()=>$r,close:()=>Gr,endTask:()=>Yr,getState:()=>Xs,hide:()=>Ys,init:()=>Vs,installGlobal:()=>yc,newTask:()=>Do,open:()=>Lo,registerTool:()=>js,send:()=>qs,show:()=>Gs,shutdown:()=>$s,update:()=>Wr});var M;(function(e){e.click_element="click_element",e.type_into_element="type_into_element",e.type_and_enter="type_and_enter",e.select_dropdown_value="select_dropdown_value",e.clear_element="clear_element",e.focus_element="focus_element",e.check_field_validity="check_field_validity",e.select_text="select_text",e.hover_element="hover_element",e.right_click_element="right_click_element",e.double_click_element="double_click_element",e.press_key="press_key",e.mouse_wheel="mouse_wheel",e.dispatch_pointer_path="dispatch_pointer_path",e.drag_element="drag_element",e.drag_and_drop="drag_and_drop",e.adjust_slider="adjust_slider",e.scroll_page="scroll_page",e.scroll_to_element="scroll_to_element",e.swipe_element="swipe_element",e.long_press_element="long_press_element",e.pinch_zoom="pinch_zoom",e.go_back="go_back",e.go_forward="go_forward",e.goto_url="goto_url",e.refresh_page="refresh_page",e.open_new_tab="open_new_tab",e.switch_tab="switch_tab",e.close_tab="close_tab",e.describe_images="describe_images",e.google_search="google_search",e.network_run_recipe="network_run_recipe",e.copy_text="copy_text",e.paste_text="paste_text",e.wait_action="wait_action",e.wait_for_element="wait_for_element",e.answer_task="answer_task",e.upload_file="upload_file",e.solve_captcha="solve_captcha"})(M||(M={}));var nf=new Set(Object.values(M));var Ic=40;function Qs(e){let t=Array.isArray(e?.element_ids)?e.element_ids:e?.element_id!=null?[e.element_id]:[];return Array.from(new Set(t.map(o=>Math.trunc(Number(o))))).filter(o=>Number.isFinite(o)&&o>0).slice(0,Ic)}var Et;(function(e){e[e.Unknown=0]="Unknown",e[e.React=1]="React",e[e.Vue=2]="Vue",e[e.Angular=3]="Angular",e[e.Svelte=4]="Svelte",e[e.JQuery=5]="JQuery"})(Et||(Et={}));var Js={[Et.Unknown]:"unknown",[Et.React]:"react",[Et.Vue]:"vue",[Et.Angular]:"angular",[Et.Svelte]:"svelte",[Et.JQuery]:"jquery"},qr={react:Et.React,vue:Et.Vue,angular:Et.Angular,svelte:Et.Svelte,jquery:Et.JQuery},We;(function(e){e[e.Other=0]="Other",e[e.Inline=1]="Inline",e[e.Delegated=2]="Delegated",e[e.React=3]="React",e[e.Vue=4]="Vue",e[e.Angular=5]="Angular",e[e.Svelte=6]="Svelte",e[e.JQuery=7]="JQuery",e[e.Native=8]="Native"})(We||(We={}));var sf={[We.Other]:"other",[We.Inline]:"inline",[We.Delegated]:"delegated",[We.React]:"react",[We.Vue]:"vue",[We.Angular]:"angular",[We.Svelte]:"svelte",[We.JQuery]:"jquery",[We.Native]:"native"},af={inline:We.Inline,delegated:We.Delegated,react:We.React,vue:We.Vue,angular:We.Angular,svelte:We.Svelte,jquery:We.JQuery,other:We.Other,native:We.Native},de;(function(e){e[e.click_element=1]="click_element",e[e.type_into_element=2]="type_into_element",e[e.type_and_enter=3]="type_and_enter",e[e.select_dropdown_value=4]="select_dropdown_value",e[e.clear_element=5]="clear_element",e[e.focus_element=6]="focus_element",e[e.hover_element=7]="hover_element",e[e.right_click_element=8]="right_click_element",e[e.double_click_element=9]="double_click_element",e[e.long_press_element=10]="long_press_element",e[e.drag_element=11]="drag_element",e[e.drag_and_drop=12]="drag_and_drop",e[e.swipe_element=13]="swipe_element",e[e.adjust_slider=14]="adjust_slider",e[e.describe_images=15]="describe_images",e[e.scroll_to_element=16]="scroll_to_element",e[e.paste_text=17]="paste_text",e[e.check_field_validity=18]="check_field_validity",e[e.select_text=19]="select_text",e[e.mouse_wheel=20]="mouse_wheel",e[e.copy_text=21]="copy_text",e[e.upload_file=22]="upload_file",e[e.go_back=23]="go_back",e[e.go_forward=24]="go_forward",e[e.refresh_page=25]="refresh_page",e[e.press_key=26]="press_key",e[e.scroll_page=27]="scroll_page",e[e.wait_action=28]="wait_action",e[e.wait_for_element=29]="wait_for_element",e[e.pinch_zoom=30]="pinch_zoom",e[e.goto_url=31]="goto_url",e[e.google_search=32]="google_search",e[e.open_new_tab=33]="open_new_tab",e[e.switch_tab=34]="switch_tab",e[e.close_tab=35]="close_tab",e[e.solve_captcha=36]="solve_captcha",e[e.answer_task=37]="answer_task",e[e.dispatch_pointer_path=38]="dispatch_pointer_path",e[e.network_run_recipe=40]="network_run_recipe"})(de||(de={}));var Fo={[M.click_element]:de.click_element,[M.type_into_element]:de.type_into_element,[M.type_and_enter]:de.type_and_enter,[M.select_dropdown_value]:de.select_dropdown_value,[M.clear_element]:de.clear_element,[M.focus_element]:de.focus_element,[M.hover_element]:de.hover_element,[M.right_click_element]:de.right_click_element,[M.double_click_element]:de.double_click_element,[M.long_press_element]:de.long_press_element,[M.drag_element]:de.drag_element,[M.drag_and_drop]:de.drag_and_drop,[M.swipe_element]:de.swipe_element,[M.adjust_slider]:de.adjust_slider,[M.describe_images]:de.describe_images,[M.scroll_to_element]:de.scroll_to_element,[M.paste_text]:de.paste_text,[M.check_field_validity]:de.check_field_validity,[M.select_text]:de.select_text,[M.mouse_wheel]:de.mouse_wheel,[M.copy_text]:de.copy_text,[M.upload_file]:de.upload_file,[M.go_back]:de.go_back,[M.go_forward]:de.go_forward,[M.refresh_page]:de.refresh_page,[M.press_key]:de.press_key,[M.scroll_page]:de.scroll_page,[M.wait_action]:de.wait_action,[M.wait_for_element]:de.wait_for_element,[M.pinch_zoom]:de.pinch_zoom,[M.goto_url]:de.goto_url,[M.google_search]:de.google_search,[M.open_new_tab]:de.open_new_tab,[M.switch_tab]:de.switch_tab,[M.close_tab]:de.close_tab,[M.solve_captcha]:de.solve_captcha,[M.answer_task]:de.answer_task,[M.dispatch_pointer_path]:de.dispatch_pointer_path,[M.network_run_recipe]:de.network_run_recipe},Zs=Object.fromEntries(Object.entries(Fo).map(([e,t])=>[t,e]));function Ho(e){let t=[];return e&&(e&1&&t.push("native"),e&2&&t.push("inline"),e&4&&t.push("react"),e&8&&t.push("vue"),e&16&&t.push("angular"),e&32&&t.push("svelte"),e&64&&t.push("jquery"),e&128&&t.push("delegated"),e&256&&t.push("other")),t}var ti={semanticIdStart:1,interactiveIdStart:1,includeFrameContents:!0,clearIframes:!0,frameContextLabel:null,signalProvider:null,disableDomAnnotations:!1},at={...ti},Bo=globalThis;function ni(e){at={...ti,...e||{}}}function _n(){return at.signalProvider??null}function Ye(){try{return typeof Bo.document<"u"?Bo.document:null}catch{return null}}function Ot(){try{return typeof Bo.window<"u"?Bo.window:null}catch{return null}}function V(e,t){if(e&&typeof e=="object"){let n=e.ownerDocument;if(n)return n;if(e.nodeType===9)return e}return t??Ye()??{}}function re(e,t){return V(e,t?t.document:null)?.defaultView??t??Ot()??{}}function q(e,t){return e?.defaultView??t??Ot()??{}}function Wo(e,t){try{return e?.getElementById?.(t)??null}catch{return null}}function Vo(e,t){try{return e?.querySelector?.(t)??null}catch{return null}}function Xr(e,t){try{return Array.from(e?.querySelectorAll?.(t)??[])}catch{return[]}}function Tn(e){try{return e.contentDocument||(e.contentWindow?.document??null)}catch{return null}}function $o(e,t){let n=e.CSS?.escape;return typeof n=="function"?n(t):t.replace(/([^\w-])/g,"\\$1")}function wt(e,t){try{return e[t]}catch{return}}function Ut(e,t){return!!e&&String(e.tagName||"").toUpperCase()===t.toUpperCase()}function oi(e,t){let n=wt(t,"HTMLAnchorElement");return n?e instanceof n:Ut(e,"A")}function Rt(e,t){let n=wt(t,"HTMLInputElement");return n?e instanceof n:Ut(e,"INPUT")}function It(e,t){let n=wt(t,"HTMLTextAreaElement");return n?e instanceof n:Ut(e,"TEXTAREA")}function ri(e,t){let n=wt(t,"HTMLLabelElement");return n?e instanceof n:Ut(e,"LABEL")}function si(e,t){let n=wt(t,"HTMLSelectElement");return n?e instanceof n:Ut(e,"SELECT")}function ii(e,t){let n=wt(t,"HTMLSlotElement");return n?e instanceof n:Ut(e,"SLOT")}function ai(e,t){let n=wt(t,"HTMLButtonElement");return n?e instanceof n:Ut(e,"BUTTON")}function ci(e,t){let n=wt(t,"HTMLImageElement");return n?e instanceof n:Ut(e,"IMG")}function li(e,t){let n=wt(t,"HTMLVideoElement");return n?e instanceof n:Ut(e,"VIDEO")}function ui(e,t){let n=wt(t,"HTMLCanvasElement");return n?e instanceof n:Ut(e,"CANVAS")}function Ve(e,t){if(!e||e.nodeType!==1)return!1;let n=wt(t,"HTMLElement");return n?e instanceof n:typeof e.tagName=="string"}function yt(e){return!!e&&e.nodeType===11&&typeof e.host=="object"&&typeof e.mode=="string"}function xn(e){if(!e||e.nodeType!==1)return!1;let t=V(e),o=q(t).Element;return o?e instanceof o:typeof e.tagName=="string"}function co(e){if(!e||e.nodeType!==1)return!1;let t=V(e),o=q(t).HTMLIFrameElement;return o&&e instanceof o?!0:String(e.tagName||"").toUpperCase()==="IFRAME"}function Ac(e,t){if(!e)return!1;if(e.nodeType===9)return!0;let n=wt(t,"Document");return n?e instanceof n:!1}function Mc(e,t){if(!e)return!1;let n=wt(t,"Window");if(n)return e instanceof n;try{return e.window===e}catch{return!1}}function Go(e){try{return e.document}catch{return null}}function Yo(e,t){if(Ac(e,t))try{return e.documentElement}catch{return null}if(Mc(e,t)){let n=Go(e);if(!n)return null;try{return n.documentElement}catch{return null}}return null}function Po(e){if(!e)return null;if(typeof e=="string")return e;if(typeof e=="object"&&typeof e.baseVal=="string")return e.baseVal;try{return String(e)}catch{return null}}function ei(e,t,n){try{let o=V(t,n);return new URL(e,o.baseURI).href}catch{return e}}function di(e,t){let n=e.tagName.includes("-"),o=e.getAttribute("href")||e.getAttribute("src")||e.getAttribute("data")||e.getAttribute("action");if(o){let r=ei(o,e,t);return r.trim().toLowerCase().startsWith("javascript:")?null:r}if(n)return null;try{let r=e,s=Po(r.href)||Po(r.src)||Po(r.data)||Po(r.action);return s?ei(s,e,t):null}catch{return null}}var fi=["click","dblclick","doubleclick","mousedown","mouseup","mouseenter","mouseleave","mousemove","mouseover","mouseout","contextmenu","auxclick","keydown","keyup","keypress","input","change","submit","reset","select","search","invalid","beforeinput","focus","blur","focusin","focusout","touchstart","touchend","touchmove","touchcancel","pointerdown","pointerup","pointermove","pointerenter","pointerleave","pointercancel","pointerover","dragstart","dragend","drag","dragenter","dragleave","dragover","drop","copy","cut","paste","scroll","wheel","play","pause","ended","volumechange","seeking","seeked","animationstart","animationend","transitionend","transitionstart","resize","toggle","fullscreenchange","load","error","abort","beforeunload","unload","hashchange","popstate","storage","message"],Te={};fi.forEach((e,t)=>{Te[e]=t});var Vt={};fi.forEach((e,t)=>{Vt[t]=e});function vn(e){if(!e)return null;let t=e.trim();if(!t||!t.includes("~"))return null;let n=[];for(let o of t.split(",")){if(!o)continue;let[r,s]=o.split("~"),c=Number(r);if(!Number.isFinite(c))continue;let l=s&&parseInt(s,36)||0;n.push({id:c,mask:l})}return n.length?{entries:n}:null}function Cc(e){let t=vn(e);if(t){let n=new Set;for(let{id:o}of t.entries)n.add(o);return[...n]}return[]}function lo(e){return Wn(e).map(n=>Vt[n]).filter(n=>!!n)}function Wn(e){let t=_n();if(t?.getEventHandlerIds)try{let r=t.getEventHandlerIds(e);if(r&&r.length)return r}catch{}let n=e.getAttribute(nn),o=Cc(n);return!o||o.length===0?[]:o}var jr=["media"],hi=new Set(jr),zr=["alert","alertdialog","application","directory","feed","grid","log","marquee","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","note","radiogroup","scrollbar","search","switch","tab","tablist","tabpanel","timer","toolbar","tooltip","tree","treegrid","treeitem"];var pi=new Set(zr),$t=new Set(["button","checkbox","combobox","figure","img","link","listbox","option","radio","scrollbar","searchbox","separator","slider","spinbutton","switch","tab","tabpanel","textbox","tooltip","treeitem","grid","gridcell","table","cell","columnheader","rowheader","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","tree","treegrid","radiogroup","application","dialog","alertdialog","alert","status","progressbar","meter","search","code","media"]),uo=new Set(["group","region","section","banner","contentinfo","main","navigation","complementary","form","article","document","presentation","none"]);var mi=["none","presentation"],be;(function(e){e[e.ANCESTOR_ROLE_REQUIRED=6]="ANCESTOR_ROLE_REQUIRED",e[e.PROPERTY_VALUE_MATCH=5]="PROPERTY_VALUE_MATCH",e[e.HAS_TABLE_ROW_DATA=7]="HAS_TABLE_ROW_DATA",e[e.BOOLEAN_PROPERTY=0]="BOOLEAN_PROPERTY",e[e.ATTRIBUTE_GREATER_THAN=2]="ATTRIBUTE_GREATER_THAN",e[e.HAS_TABLE_COLUMN_DATA=8]="HAS_TABLE_COLUMN_DATA",e[e.FORBIDDEN_ANCESTORS=1]="FORBIDDEN_ANCESTORS",e[e.HAS_ACCESSIBLE_NAME=4]="HAS_ACCESSIBLE_NAME",e[e.ATTRIBUTE_LESS_THAN=3]="ATTRIBUTE_LESS_THAN"})(be||(be={}));var gi={a:["link"],area:["link"],article:["article"],aside:["complementary"],body:["document"],button:["button"],datalist:["listbox"],dd:["definition"],details:["group"],dfn:["term"],dialog:["dialog"],dt:["term"],fieldset:["group"],figure:["figure"],footer:["contentinfo"],form:["form"],h1:["heading"],h2:["heading"],h3:["heading"],h4:["heading"],h5:["heading"],h6:["heading"],header:["banner"],hr:["separator"],img:["img"],input:["button","checkbox","combobox","radio","searchbox","slider","spinbutton","textbox"],li:["listitem"],link:["link"],main:["main"],math:["math"],menu:["list"],nav:["navigation"],ol:["list"],optgroup:["group"],option:["option"],output:["status"],progress:["progressbar"],section:["region"],select:["combobox","listbox"],summary:["button"],table:["table"],tbody:["rowgroup"],td:["cell","gridcell"],textarea:["textbox"],tfoot:["rowgroup"],th:["cell","columnheader","gridcell","rowheader"],thead:["rowgroup"],tr:["row"],ul:["list"],code:["code"],pre:["code"]},fo={heading:{selector:"h6,h1,h3,h2,h5,h4"},checkbox:{conditionalSelectors:[{selector:"input",conditions:[{type:be.PROPERTY_VALUE_MATCH,property:"type",values:["checkbox"]}]}]},navigation:{selector:"nav"},row:{selector:"tr"},complementary:{selector:"aside"},table:{selector:"table"},gridcell:{conditionalSelectors:[{selector:"td",conditions:[{type:be.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"grid"}]},{selector:"td",conditions:[{type:be.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"treegrid"}]},{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:be.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"treegrid"},{type:be.HAS_TABLE_COLUMN_DATA,hasData:!0},{type:be.HAS_TABLE_ROW_DATA,hasData:!0}]}]},slider:{conditionalSelectors:[{selector:"input",conditions:[{type:be.PROPERTY_VALUE_MATCH,property:"type",values:["range"]}]}]},listitem:{selector:"li"},contentinfo:{conditionalSelectors:[{selector:"footer",conditions:[{type:be.FORBIDDEN_ANCESTORS,selector:'section,nav,main,aside,article,[role="region"],[role="navigation"],[role="main"],[role="complementary"],[role="article"]'}]}]},definition:{selector:"dd"},button:{selector:"summary,button",conditionalSelectors:[{selector:"input",conditions:[{type:be.PROPERTY_VALUE_MATCH,property:"type",values:["submit","reset","image","button"]}]}]},status:{selector:"output"},form:{conditionalSelectors:[{selector:"form",conditions:[{type:be.HAS_ACCESSIBLE_NAME}]}]},article:{selector:"article"},textbox:{selector:"textarea",conditionalSelectors:[{selector:"input:not([list])",conditions:[{type:be.PROPERTY_VALUE_MATCH,property:"type",values:["url","text","tel","email"]}]}]},radio:{conditionalSelectors:[{selector:"input",conditions:[{type:be.PROPERTY_VALUE_MATCH,property:"type",values:["radio"]}]}]},columnheader:{selector:'th[scope="colgroup"],th[scope="col"]',conditionalSelectors:[{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:be.HAS_TABLE_ROW_DATA,hasData:!1}]}]},list:{selector:"ul,ol,menu"},region:{conditionalSelectors:[{selector:"section",conditions:[{type:be.HAS_ACCESSIBLE_NAME}]}]},document:{selector:"body"},option:{selector:"select > option,select > optgroup > option,datalist > option"},separator:{selector:"hr"},link:{selector:"area[href],a[href],link[href]"},img:{selector:"img[alt],img:not([alt])"},main:{selector:"main"},searchbox:{conditionalSelectors:[{selector:"input:not([list])",conditions:[{type:be.PROPERTY_VALUE_MATCH,property:"type",values:["search"]}]}]},cell:{conditionalSelectors:[{selector:"td",conditions:[{type:be.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"table"}]},{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:be.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"table"},{type:be.HAS_TABLE_COLUMN_DATA,hasData:!0},{type:be.HAS_TABLE_ROW_DATA,hasData:!0}]}]},rowheader:{selector:'th[scope="rowgroup"],th[scope="row"]',conditionalSelectors:[{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:be.HAS_TABLE_COLUMN_DATA,hasData:!1},{type:be.HAS_TABLE_ROW_DATA,hasData:!0}]}]},dialog:{selector:"dialog"},listbox:{selector:"select[multiple],datalist",conditionalSelectors:[{selector:"select",conditions:[{type:be.ATTRIBUTE_GREATER_THAN,attribute:"size",value:1}]}]},group:{selector:"optgroup,fieldset,details"},term:{selector:"dt,dfn"},progressbar:{selector:"progress"},figure:{selector:"figure"},spinbutton:{conditionalSelectors:[{selector:"input",conditions:[{type:be.PROPERTY_VALUE_MATCH,property:"type",values:["number"]}]}]},math:{selector:"math"},combobox:{selector:"select:not([size]):not([multiple])",conditionalSelectors:[{selector:"select:not([multiple])",conditions:[{type:be.ATTRIBUTE_LESS_THAN,attribute:"size",value:2}]},{selector:"input[list]",conditions:[{type:be.PROPERTY_VALUE_MATCH,property:"type",values:["url","text","tel","search","email"]}]}]},banner:{conditionalSelectors:[{selector:"header",conditions:[{type:be.FORBIDDEN_ANCESTORS,selector:'[role="region"],[role="navigation"],[role="main"],[role="complementary"],[role="article"],section,nav,main,aside,article'}]}]},rowgroup:{selector:"thead,tfoot,tbody"},code:{selector:"code,pre"}},nn="rtrvr-ls",Gt="rtrvr-ro",Kr="rtrvr-mw-ready",ho="rtrvr-mw-busy",Qr="rtrvr-mwa-ready",bi=new Set(["button","cell","checkbox","columnheader","gridcell","heading","link","menuitem","menuitemcheckbox","menuitemradio","option","radio","row","rowgroup","rowheader","switch","tab","tooltip","tree","treeitem","sectionhead","definition","term","deletion","insertion"]),Ei=["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"],wi=["h1","h2","h3","h4","h5","h6"],yi="http://www.w3.org/1999/xhtml",_i="http://www.w3.org/2000/svg",nt="rtrvr-label";var jo=new Set(["NOSCRIPT","SCRIPT","STYLE","META"]),Rn="CODE",Sn="PRE",Ti="aria-hidden",xi="target";var qo;(function(e){e[e.value=0]="value",e[e.alt=1]="alt",e[e.list=2]="list",e[e.title=3]="title"})(qo||(qo={}));var Vn;(function(e){e[e["data-icon"]=13]="data-icon",e[e["data-name"]=14]="data-name",e[e["data-tooltip"]=15]="data-tooltip",e[e["data-label"]=16]="data-label"})(Vn||(Vn={}));var Xo;(function(e){e[e.VALUENOW=0]="VALUENOW",e[e.VALUETEXT=1]="VALUETEXT"})(Xo||(Xo={}));var Jr=new Set([Te.click,Te.dblclick,Te.doubleclick,Te.contextmenu,Te.auxclick,Te.pointerdown,Te.pointerup,Te.mousedown,Te.mouseup,Te.touchstart,Te.touchend,Te.keydown,Te.keyup,Te.input,Te.beforeinput,Te.change,Te.submit,Te.reset,Te.paste,Te.dragstart,Te.dragend,Te.drop]),vi=new Set([...Jr,Te.scroll,Te.wheel,Te.mouseenter,Te.mouseover,Te.focus,Te.blur,Te.focusin,Te.focusout]),zo=new Set(["click","dblclick","auxclick","contextmenu","mousedown","mouseup","pointerdown","pointerup","touchstart","touchend"]),Zr=new Set(["input","change","beforeinput","keydown","keyup","keypress","paste","compositionstart","compositionend"]),es=new Set(["drag","dragstart","dragend","dragenter","dragleave","dragover","drop"]);var po;(function(e){e[e.ELEMENT=1]="ELEMENT",e[e.ATTRIBUTE=2]="ATTRIBUTE",e[e.TEXT=3]="TEXT",e[e.CDATA_SECTION=4]="CDATA_SECTION",e[e.ENTITY_REFERENCE=5]="ENTITY_REFERENCE",e[e.ENTITY=6]="ENTITY",e[e.PROCESSING_INSTRUCTION=7]="PROCESSING_INSTRUCTION",e[e.COMMENT=8]="COMMENT",e[e.DOCUMENT=9]="DOCUMENT",e[e.DOCUMENT_TYPE=10]="DOCUMENT_TYPE",e[e.DOCUMENT_FRAGMENT=11]="DOCUMENT_FRAGMENT",e[e.NOTATION=12]="NOTATION"})(po||(po={}));var mo;(function(e){e[e.HTML=0]="HTML",e[e.SVG=1]="SVG"})(mo||(mo={}));var Ko;(function(e){e[e.VALUENOW=0]="VALUENOW",e[e.VALUETEXT=1]="VALUETEXT",e[e.ATOMIC=2]="ATOMIC",e[e.AUTOCOMPLETE=3]="AUTOCOMPLETE",e[e.COLCOUNT=4]="COLCOUNT",e[e.COLINDEX=5]="COLINDEX",e[e.COLSPAN=6]="COLSPAN",e[e.ERRORMESSAGE=7]="ERRORMESSAGE",e[e.HASPOPUP=8]="HASPOPUP",e[e.LEVEL=9]="LEVEL",e[e.LIVE=10]="LIVE",e[e.MULTILINE=11]="MULTILINE",e[e.MULTISELECTABLE=12]="MULTISELECTABLE",e[e.ORIENTATION=13]="ORIENTATION",e[e.PLACEHOLDER=14]="PLACEHOLDER",e[e.POSINSET=15]="POSINSET",e[e.READONLY=16]="READONLY",e[e.RELEVANT=17]="RELEVANT",e[e.REQUIRED=18]="REQUIRED",e[e.ROWCOUNT=19]="ROWCOUNT",e[e.ROWINDEX=20]="ROWINDEX",e[e.ROWSPAN=21]="ROWSPAN",e[e.SETSIZE=22]="SETSIZE",e[e.SORT=23]="SORT",e[e.VALUEMAX=24]="VALUEMAX",e[e.VALUEMIN=25]="VALUEMIN",e[e.KEYSHORTCUTS=26]="KEYSHORTCUTS",e[e.ROLEDESCRIPTION=27]="ROLEDESCRIPTION"})(Ko||(Ko={}));var Qo;(function(e){e[e.BUSY=0]="BUSY",e[e.CHECKED=1]="CHECKED",e[e.CURRENT=2]="CURRENT",e[e.EXPANDED=3]="EXPANDED",e[e.INVALID=4]="INVALID",e[e.PRESSED=5]="PRESSED",e[e.SELECTED=6]="SELECTED"})(Qo||(Qo={}));var mt;(function(e){e[e["rtrvr-label"]=0]="rtrvr-label",e[e.role=1]="role",e[e.value=2]="value",e[e.alt=3]="alt",e[e.list=4]="list",e[e.title=5]="title",e[e["aria-label"]=6]="aria-label",e[e["aria-labelledby"]=7]="aria-labelledby",e[e["aria-description"]=8]="aria-description",e[e["aria-describedby"]=9]="aria-describedby",e[e.disabled=10]="disabled",e[e.href=11]="href",e[e.placeholder=12]="placeholder",e[e.type=13]="type",e[e.tabindex=14]="tabindex",e[e.id=15]="id",e[e._ngcontent=16]="_ngcontent",e[e["ng-reflect-*"]=17]="ng-reflect-*",e[e["data-reactroot"]=18]="data-reactroot",e[e["data-v-*"]=19]="data-v-*",e[e.required=20]="required",e[e.contenteditable=21]="contenteditable",e[e.accept=22]="accept"})(mt||(mt={}));var Je;(function(e){e[e.display=0]="display",e[e.content=1]="content",e[e.beforeDisplay=2]="beforeDisplay",e[e.afterDisplay=3]="afterDisplay",e[e.beforeContent=4]="beforeContent",e[e.afterContent=5]="afterContent",e[e.width=6]="width",e[e.height=7]="height",e[e.minWidth=8]="minWidth",e[e.minHeight=9]="minHeight",e[e.position=10]="position",e[e.top=11]="top",e[e.left=12]="left",e[e.right=13]="right",e[e.bottom=14]="bottom",e[e.paddingTop=15]="paddingTop",e[e.paddingRight=16]="paddingRight",e[e.paddingBottom=17]="paddingBottom",e[e.paddingLeft=18]="paddingLeft",e[e.marginTop=19]="marginTop",e[e.marginRight=20]="marginRight",e[e.marginBottom=21]="marginBottom",e[e.marginLeft=22]="marginLeft",e[e.cursor=23]="cursor",e[e.opacity=24]="opacity",e[e.visibility=25]="visibility",e[e.overflowX=26]="overflowX",e[e.overflowY=27]="overflowY",e[e.backgroundColor=28]="backgroundColor",e[e.color=29]="color",e[e.borderWidth=30]="borderWidth",e[e.borderStyle=31]="borderStyle",e[e.boxShadow=32]="boxShadow",e[e.outline=33]="outline"})(Je||(Je={}));var Yt;(function(e){e[e.text=0]="text",e[e.elText=1]="elText",e[e.viewBox=2]="viewBox",e[e.paths=3]="paths",e[e.pathData=4]="pathData",e[e.circles=5]="circles",e[e.rects=6]="rects",e[e.lines=7]="lines",e[e.polygons=8]="polygons",e[e.polylines=9]="polylines",e[e.ellipses=10]="ellipses"})(Yt||(Yt={}));var Nc=[...zr,...Object.keys(fo),...jr],Ri=[...new Set(Nc)],$n={};Ri.forEach((e,t)=>{$n[e]=t});var go={};Ri.forEach((e,t)=>{go[t]=e});var Jo=class{constructor(t=1){W(this,"currentId");this.currentId=t}generateId(){let t=this.currentId;return this.currentId++,t}initialize(t=1){this.currentId=t}getCurrentValue(){return this.currentId}};function bo(e){let t=_n();if(t?.getRoleHint)try{let r=t.getRoleHint(e);if(r)return r}catch{}let n=e.getAttribute(Gt);if(!n)return null;let o=n.trim();if(!o)return null;if(o.startsWith("s:"))return o.slice(2);if(/^\d+$/.test(o)){let r=Number(o);if(Number.isFinite(r)){let s=go[r];if(s)return s}}return o}function Gn(e){return Array.from(new Set(e))}function Si(e,t){if(!e||e.length===0)return Gn(t);let n=new Set([...e,...t]);return Gn(Array.from(n))}function _t(e,t){let o=_n()?.getEventHandlerIds?.(e)??Wn(e),r=o.length>0&&o.some(l=>Jr.has(l)),s=Zo(e),c=t?uo.has(t):!1;return{element:e,semanticRole:t,eventHandlerIndices:o,isEditableRegion:s,hasNodeWorthyHandlers:r,isLikelyStructuralContainer:c}}var Lc=new Set(["text","search","url","tel","password","email","number","date","datetime-local","time","month","week","color"]);function Dc(e){let n=re(e).getComputedStyle(e);if(n.display==="none"||n.visibility==="hidden"||n.pointerEvents==="none")return!1;let o=e.getBoundingClientRect();return!(o.width===0||o.height===0)}function Oc(e){let t=re(e);if(!Rt(e,t))return!1;let n=(e.type||"text").toLowerCase();return Lc.has(n)?!e.disabled&&!e.readOnly:!1}function Uc(e){let t=re(e);return It(e,t)&&!e.disabled&&!e.readOnly}function Fc(e){let t=e;return!(!t.isContentEditable||t.getAttribute("aria-readonly")==="true"||t.getAttribute("aria-disabled")==="true")}function Zo(e){return!e||!Dc(e)?!1:!!(Oc(e)||Uc(e)||Fc(e))}function Eo(e){if(!e)return null;let t=e.match(/^\s*\[id=(\d+)\]/);if(t?.[1]){let r=parseInt(t[1],10);return Number.isFinite(r)?r:null}let n=/\[id=(\d+)\]/g,o;for(;o=n.exec(e);){let r=o.index??0,s=e.slice(Math.max(0,r-30),r);if(/iframeRoot\s*=\s*$/.test(s)||s.includes("iframeRoot="))continue;let c=parseInt(o[1],10);if(Number.isFinite(c))return c}try{let r=e.match(LABEL_ID_PATTERN);if(r?.[1]){let s=parseInt(r[1],10);return Number.isFinite(s)?s:null}}catch{}return null}function wo(e){let t=String(e??"").replace(/[\n\r\t]/g," ").replace(/\s+/g," ").trim();return t=t.replace(/\[/g,"[").replace(/\]/g,"]"),t}function ki({element:e,elementID:t,frameContextLabel:n}){let o=!at.disableDomAnnotations,r=[`[id=${t}]`],s=re(e);if(co(e)){let f=wo(e.id||e.getAttribute("name")||"unnamed");r.push(`[iframe=${f}]`)}if(n){let f=wo(n);r.push(`[iframeRoot=${f}]`)}if(ci(e,s)&&r.push(`[size=${e.clientWidth}x${e.clientHeight}]`),(li(e,s)||ui(e,s))&&r.push(`[size=${e.clientWidth}x${e.clientHeight}]`),Rt(e,s)||It(e,s)){let f=Hc(e);r.push(...f)}e.getAttribute(Ti)==="true"&&r.push("[aria-hidden=true]"),e.disabled&&r.push("[disabled]"),o&&oi(e,s)&&e.setAttribute(xi,"_self");let l=r.join(" ");return o&&e.setAttribute(nt,l),l}function Hc(e){let t=[],n=re(e),o=Rt(e,n);if(o&&e.type&&e.type!=="text"&&t.push(`[type=${e.type}]`),e.name){let r=wo(e.name);r&&t.push(`[name=${r}]`)}if(o&&e.multiple&&t.push("[multiple]"),o&&(e.type==="checkbox"||e.type==="radio")&&t.push(`[checked=${e.checked}]`),o&&e.type==="file"&&e.files?.length&&t.push(`[files=${e.files.length}]`),o&&e.type==="number"&&(e.min!==""&&t.push(`[min=${e.min}]`),e.max!==""&&t.push(`[max=${e.max}]`),e.step!==""&&e.step!=="1"&&t.push(`[step=${e.step}]`)),o&&e.type==="range"&&(t.push(`[min=${e.min||"0"}]`),t.push(`[max=${e.max||"100"}]`),t.push(`[value=${e.value}]`)),e.readOnly&&t.push("[readonly]"),e.required&&t.push("[required]"),e.maxLength&&e.maxLength!==-1&&e.maxLength<524288&&t.push(`[maxlength=${e.maxLength}]`),o&&e.pattern&&t.push("[pattern]"),e.autocomplete&&e.autocomplete!=="off"&&t.push(`[autocomplete=${e.autocomplete}]`),e.placeholder){let r=wo(e.placeholder).replace(/\\/g,"\\\\").replace(/"/g,'\\"');r&&t.push(`[placeholder="${r}"]`)}if(e.value){let r=e.value;o&&e.type==="password"&&(r="*".repeat(Math.min(r.length,10)));let s=wo(r).replace(/\\/g,"\\\\").replace(/"/g,'\\"');t.push(`[value="${s}"]`)}return t}var yo=new Jo,ts=new WeakMap;function Ii(){ts=new WeakMap}function er(e){let t=ts.get(e);if(t)return t;let n=yo.generateId();return ts.set(e,n),n}var tr=new Map,ns=new WeakMap;function Ai(){tr.clear(),ns=new WeakMap}function os(e,t){try{typeof WeakRef<"u"?tr.set(e,new WeakRef(t)):tr.set(e,t)}catch{}}function _o(e){let t=tr.get(e);if(!t)return null;let n=t instanceof WeakRef?t.deref():t;return!n||n.isConnected===!1?null:n}function on(e){let t=null,n=er(e);if(at.frameContextLabel)t=at.frameContextLabel;else{let r=Ye();if(r&&e.ownerDocument!==r)try{let c=e.ownerDocument?.defaultView?.frameElement?.getAttribute(nt)||"",l=c?Eo(c):null;t=l?String(l):null}catch{t=""}}let o=ki({element:e,elementID:n,frameContextLabel:t});if(os(n,e),o)try{ns.set(e,o)}catch{}return o}function Mi(e){return ns.get(e)??null}function rs(e,t){try{e.querySelectorAll?.(`[${nt}]`)?.forEach(o=>o.removeAttribute(nt))}catch{}if(t.includeShadow)try{let n=e.querySelectorAll?.("*");if(n)for(let o of Array.from(n))try{let r=o.shadowRoot;r&&rs(r,t)}catch{}}catch{}if(t.includeIframes)try{let n=e.querySelectorAll?.("iframe");if(n)for(let o of Array.from(n))try{let r=Tn(o);r?.body&&rs(r.body,t)}catch{}}catch{}}function Ci(e,t={}){if(at.disableDomAnnotations)return;let n=xn(e)?re(e):q(e)??window,o=Yo(e,n)??e;if(o){try{o.removeAttribute?.(nt)}catch{}rs(o,{includeShadow:t.includeShadow??!0,includeIframes:t.includeIframes??!0})}}var rn={},ss=new WeakMap,nr=new WeakSet;function Ni(){rn={},ss=new WeakMap,nr=new WeakSet,Ii()}function ot({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:o,isFrameNode:r,frameContentNodes:s,originatedFromParent:c,elementContext:l}){let f=er(e);os(f,e);let R=rn[f];if(c){if(!R){let p={nodeCategory:e.nodeType,provisionalFromParent:!0},T=e.nodeName;T&&T.trim()&&(p.elementName=T);let S=e.getAttribute("role");S&&(p.preservedAttributes={1:S});let x=e.tagName;x&&(p.elementTag=x),rn[f]=p}}else{if(R&&!R.provisionalFromParent){if((r||Yn(e))&&(R.isFrameElement=!0,s&&s.length>0&&(R.frameContent=s)),l){let{eventHandlerIndices:p,isEditableRegion:T}=l;if(p&&p.length>0){let S=Gn(p);S.length>0&&(R.eventHandlers=Si(R.eventHandlers,S))}T&&(R.isEditable=!0)}return f}if(nr.has(e))return f;nr.add(e);try{rn[f]=Li({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:o,isFrameNode:r,frameContentNodes:s,elementContext:l})}finally{nr.delete(e)}}return f}function To(e){let t=ss.get(e);if(t!==void 0)return t;let o=(e.textContent||"").replace(/\s+/g," ").trim(),r=e.data?.replace(/\s+/g," ").trim();if(!o&&!r)return 0;let s=yo.generateId(),c={textContent:o,nodeCategory:e.nodeType};return r&&r!==o&&(c.rawData=r),rn[s]=c,ss.set(e,s),s}function Oi(e,t){let n=Fi(e),{minY:o,maxY:r}=n.getCellBounds(t);return n.getRows().slice(o,r+1).some(s=>s.some(xo))}function Ui(e,t){let n=Fi(e),{minX:o,maxX:r}=n.getCellBounds(t);return n.getRows().some(s=>s.slice(o,r+1).some(xo))}var rr=class{constructor(t=[]){W(this,"cells");W(this,"getCellAt",(t,n)=>this.getRowAt(n)[t]);W(this,"setCellAt",(t,n,o)=>{this.getRowAt(n)[t]=o});W(this,"getRowAt",t=>(this.cells[t]===void 0&&(this.cells[t]=[]),this.cells[t]));W(this,"getRows",()=>this.cells);W(this,"getCellBounds",t=>{let n=this.columnCount,o=this.rowCount,r=-1,s=-1;for(let c=0;c<this.rowCount;c++){let l=this.getRowAt(c),f=l.indexOf(t);f!==-1&&(r=Math.max(r,l.lastIndexOf(t)),s=Math.max(s,c),n=Math.min(n,f),o=Math.min(o,c))}return{minX:n,minY:o,maxX:r,maxY:s}});W(this,"merge",t=>{this.cells=this.getRows().concat(t.getRows())});this.cells=t}get rowCount(){return this.cells.length}get columnCount(){return Math.max(...this.cells.map(t=>t.length))}};function Fi(e){let n=re(e).TableGrid||rr,o=new n;e.tHead!==null&&o.merge(or(e.tHead.rows)),Array.from(e.tBodies).forEach(s=>{o.merge(or(s.rows))});let r=[];for(let s of Array.from(e.children))is(s)&&kn(s,"tr")&&r.push(s);return o.merge(or(r)),e.tFoot!==null&&o.merge(or(e.tFoot.rows)),o}function or(e){let t=new rr,n=[];for(let o=0;o<e.length;o++){let r=0;for(let s of Array.from(e[o].cells)){for(;t.getCellAt(r,o)||n[r];)!xo(t.getCellAt(r,o))&&n[r]&&t.setCellAt(r,o,n[r]),r++;for(let c=r;c<r+s.colSpan;c++){Di(s)===0&&(n[c]=s,t.setCellAt(c,o,s));for(let l=o;l<o+Di(s);l++)xo(t.getCellAt(c,l))||t.setCellAt(c,l,s)}r+=s.colSpan}for(let s=r;s<t.columnCount;s++){let c=n[s];c!==void 0&&!xo(t.getCellAt(s,o))&&t.setCellAt(s,o,c)}}return t}function Di(e){let t=e.getAttribute("rowSpan");if(t===null||t.trim()==="")return 1;let n=Number(t);return isNaN(n)?1:n}function xo(e){return e!==void 0&&kn(e,"td")}function At(e){let t=e.tagName?.toLowerCase();if(t==="code"||t==="pre"){let o=Xc(e);if(o)return o}let n=Hi(e);if(n===null){if(t==="dl")return"list";if(t==="form")return"form";if(t==="header")return"banner";if(t==="footer")return"contentinfo";if(t==="option")return"option";if(t==="textarea")return"textbox";if(t==="input"){let r=e;switch(r.type.toLowerCase()){case"checkbox":return"checkbox";case"radio":return"radio";case"button":case"submit":case"reset":case"image":return"button";case"number":return"spinbutton";case"range":return"slider";case"hidden":return null;default:return r.hasAttribute("list")?"combobox":"textbox"}}if(t==="select")return e.multiple?"listbox":"combobox";if(t==="svg"){if(e.getAttribute("aria-hidden")==="true")return null;let r=e.querySelector("title"),s=e.querySelector("desc"),c=e.hasAttribute("aria-label"),l=e.hasAttribute("role");return r||s||c||l||Wn(e).length>0||e.getAttribute("tabindex")!==null?"img":null}if(Wn(e).length>0){let r=e.tagName.toLowerCase();if(["div","span","li","p","i","em","strong","b"].includes(r))return Pc(e)}}if(t==="td"&&e.getAttribute("role")===null)return"cell";if(n!==null&&t==="th"){let o=e.getAttribute("role");if(o&&Pi(o))return o;let r=e;return r.scope==="col"||r.hasAttribute("aria-sort")?"columnheader":r.scope==="row"?"rowheader":"cell"}return n}function Pc(e){return bo(e)??null}function Hi(e){let t=e.getAttribute("role");if(t!==null)return mi.includes(t)||!Pi(t)?null:t;let n=e.tagName.toLowerCase();return(gi[n]??[]).find(r=>Bc(e,r))||null}function Bc(e,t){let n=fo[t],o=n?.selector;if(o&&sr(e,o))return!0;let r=n?.conditionalSelectors;return r?r.some(c=>sr(e,c.selector)&&c.conditions.every(f=>Vc(e,f))):!1}function Wc(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let o=e.getRootNode?.();if(yt(o)){let r=re(e),s=`#${$o(r,n)}`,c=Vo(o,s);if(c)return c}}catch{}return Wo(V(e),n)}function Vc(e,t){switch(t.type){case be.ATTRIBUTE_GREATER_THAN:{let n=e.getAttribute(t.attribute);return n!==null&&Number(n)>t.value}case be.ATTRIBUTE_LESS_THAN:{let n=e.getAttribute(t.attribute);return n!==null&&Number(n)<t.value}case be.HAS_ACCESSIBLE_NAME:return e.hasAttribute("aria-label")?!0:(e.getAttribute("aria-labelledby")||"").split(/\s+/).filter(Boolean).some(o=>Wc(e,o)!=null);case be.FORBIDDEN_ANCESTORS:return qt(e,t.selector)===null;case be.BOOLEAN_PROPERTY:return e[t.property]===t.value;case be.PROPERTY_VALUE_MATCH:return t.values.some(n=>n===e[t.property]);case be.ANCESTOR_ROLE_REQUIRED:{let n=e.parentElement;if(n===null)return!1;let o=qt(n,t.tag);return o!==null&&Hi(o)===t.role}case be.HAS_TABLE_COLUMN_DATA:{let n=qt(e,"table");return n===null?!1:t.hasData===Ui(n,e)}case be.HAS_TABLE_ROW_DATA:{let n=qt(e,"table");return n===null?!1:t.hasData===Oi(n,e)}default:return $c(t),!1}}function $c(e){throw new Error(`unexpected value ${e}!`)}function Pi(e){return Yc(e)||qc(e)||Gc(e)}function Gc(e){return hi.has(e)}function Yc(e){return pi.has(e)}function qc(e){return fo.hasOwnProperty(e)}function Xc(e){if(e.tagName!==Rn&&e.tagName!==Sn)return null;if(lo(e).some(o=>o==="click"||o==="copy"))return"button";let n=e.getAttribute("tabindex");return n!==null&&parseInt(n,10)>=0?"button":e.tagName===Sn||e.tagName===Rn&&e.closest("pre")?"code":null}var jc={[Je.display]:[Je.beforeDisplay,Je.afterDisplay],[Je.content]:[Je.beforeContent,Je.afterContent]},as=new Map,zc={minWidth:"min-width",minHeight:"min-height",backgroundColor:"background-color",borderWidth:"border-width",borderStyle:"border-style",boxShadow:"box-shadow",paddingTop:"padding-top",paddingRight:"padding-right",paddingBottom:"padding-bottom",paddingLeft:"padding-left",marginTop:"margin-top",marginRight:"margin-right",marginBottom:"margin-bottom",marginLeft:"margin-left",overflowX:"overflow-x",overflowY:"overflow-y"};function Kc(e,t){if(!as.has(e)){let n=zc[t]||t.replace(/([A-Z])/g,"-$1").toLowerCase();as.set(e,n)}return as.get(e)}var Qc={display:e=>e!=="block"&&e!=="inline"&&e!=="",visibility:e=>e!=="visible",opacity:e=>parseFloat(e)<1,position:e=>e!=="static",cursor:e=>e!=="auto"&&e!=="default"&&e!=="text",width:e=>e!=="auto"&&e!=="",height:e=>e!=="auto"&&e!=="",minWidth:e=>e!=="0px"&&e!=="",minHeight:e=>e!=="0px"&&e!=="",paddingTop:e=>parseFloat(e)>0,paddingRight:e=>parseFloat(e)>0,paddingBottom:e=>parseFloat(e)>0,paddingLeft:e=>parseFloat(e)>0,marginTop:e=>Math.abs(parseFloat(e))>5,marginRight:e=>Math.abs(parseFloat(e))>5,marginBottom:e=>Math.abs(parseFloat(e))>5,marginLeft:e=>Math.abs(parseFloat(e))>5,overflowX:e=>e!=="visible",overflowY:e=>e!=="visible",backgroundColor:e=>e!=="transparent"&&e!=="rgba(0, 0, 0, 0)"&&e!=="initial",color:e=>e!=="initial"&&e!=="inherit"&&e!=="",borderWidth:e=>e!=="0px"&&parseFloat(e)>0,borderStyle:e=>e!=="none"&&e!=="initial",boxShadow:e=>e!=="none"&&e!=="",outline:e=>e!=="none"&&e!==""&&!e.includes("0px")};function Vi(e,t,n){let o=Qc[e];return o?o(t,n):t.trim()!==""&&!["initial","inherit","unset"].includes(t)}function $i(e){let t={},n=re(e);if(!Ve(e,n))return t;let o=n.getComputedStyle(e),r=new Map([[Je.beforeDisplay,n.getComputedStyle(e,"::before")],[Je.afterDisplay,n.getComputedStyle(e,"::after")],[Je.beforeContent,n.getComputedStyle(e,"::before")],[Je.afterContent,n.getComputedStyle(e,"::after")]]);for(let s in Je)if(isNaN(Number(s))){let c=Je[s],l=Kc(c,s),f=jc[c];f?((c===Je.display||c===Je.content)&&Bi(o,l,c,s,t,e),Wi(r.get(f[0]),l,f[0],"beforeContent",t),Wi(r.get(f[1]),l,f[1],"afterContent",t)):Bi(o,l,c,s,t,e)}return t}function Bi(e,t,n,o,r,s){if(e){let c=e.getPropertyValue(t);c&&Vi(o,c,s)&&(r[n]=c)}}function Wi(e,t,n,o,r){if(e){let s=e.getPropertyValue(t);(t==="content"&&s&&s!=="none"&&s!=='""'&&s!=="''"||s&&Vi(o,s))&&(r[n]=s)}}function In(e,t){let n=re(e);if(!Ve(e,n))return!0;if(t&&$t.has(t))return!1;if(e.hasAttribute("hidden")||qt(e,"[hidden]")!==null||qt(e,"[inert]")!==null)return!0;let o=n.getComputedStyle(e);if(o.display==="none"||o.visibility==="hidden"||o.visibility==="collapse"||e.getClientRects().length===0)return!0;let r=e.getBoundingClientRect(),s=1e6;return Math.abs(r.left)>s||Math.abs(r.top)>s}function vo(e){return Mt(e)&&e.classList.contains("jasmine_html-reporter")}function Jc(e){let t=e.getAttribute("role");return t==="presentation"||t==="none"}function Gi(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).map(t=>t.replace(/^#/,"")):[]}function Yi(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let r=e.getRootNode?.();if(yt(r)){let s=re(e),c=`#${$o(s,n)}`,l=Vo(r,c);if(l)return l}}catch{}let o=V(e);return Wo(o,n)}function cs(e){let n=[];for(let o=0;o<arguments.length;o++){let r=arguments[o];if(Array.isArray(r))for(let s=0;s<r.length;s+=8192){let c=Zc(r,s,s+8192),l=cs.apply(null,c);for(let f=0;f<l.length;f++)n.push(l[f])}else n.push(r)}return n}function Zc(e,t,n){return arguments.length<=2?Array.prototype.slice.call(e,t):Array.prototype.slice.call(e,t,n)}function qi(e,t){return el(e,t).concat(tl(e))}function el(e,t){return cs(us(e).map(o=>Zi(o)&&Mt(o)?Xi(o,t):o))}function Xi(e,t){if(!e||In(e,t))return[];if(!Jc(e))return[e];let n=Array.from(e.children);return cs(n.map(o=>Xi(o,t)))}function ji(e){let t=Gi(e.getAttribute("aria-owns"));if(!t.length)return[];let n=[],o=new Set;for(let r of t){if(o.has(r))continue;o.add(r);let s=Yi(e,r);s&&s!==e&&n.push(s)}return n}function tl(e){let t=ji(e);for(let n of t)n["aria-owned-by"]=e;return t}function zi(e){let t=re(e),n=V(e);if(e.getAttribute("role")!=="dialog"&&e.getAttribute("role")!=="alertdialog"||e.getAttribute("aria-modal")!=="true")return!1;let o=t.getComputedStyle(e);if(o?.position!=="fixed"&&o?.position!=="absolute"||parseInt(o?.zIndex,10)<=sl(e))return!1;let r=nl(e);return!r||!rl(r)||!al(e)||r.getAttribute("role")==="dialog"||e.getAttribute("role")==="dialog"?!1:il(e)}function nl(e){return[e.previousElementSibling,e.nextElementSibling,...Array.from(e.children),...e.parentElement?[e.parentElement.previousElementSibling,e.parentElement.nextElementSibling]:[]].filter(n=>n!==null).find(ol)||null}function ol(e){if(In(e))return!1;let n=re(e).getComputedStyle(e);return(n?.position==="fixed"||n?.position==="absolute")&&n?.backgroundColor!=="rgba(0, 0, 0, 0)"&&n?.backgroundColor!=="transparent"&&n?.pointerEvents!=="none"}function rl(e){let t=re(e),n=e.getBoundingClientRect();return n.top<=0&&n.left<=0&&n.bottom>=t.innerHeight&&n.right>=t.innerWidth}function sl(e){let t=V(e),n=re(e),o=n?.getComputedStyle;if(!o)return 0;let r=Xr(t,"*").filter(s=>s!==e&&!In(s)).map(s=>parseInt(o.call(n,s)?.zIndex,10)).filter(s=>Number.isFinite(s)&&!isNaN(s));return r.length?Math.max(...r):0}function il(e){return e.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])').length>0}function al(e){let t=e.parentElement;if(!t)return!1;for(let n of Array.from(t.children))if(n!==e&&!In(n)&&n.getAttribute("aria-hidden")!=="true")return!1;return!0}function cl(){try{let t=Ye()?.querySelector?.("dialog:modal");return'[aria-modal="true"], dialog:modal'}catch{return'[aria-modal="true"]'}}var Ki=cl();function ll(e){return e.getAttribute("aria-disabled")==="true"||e.hasAttribute("disabled")}function ls(e){let t=e.getAttribute("href")||e.getAttribute("src")||e.getAttribute("data")||e.getAttribute("action");if(!t&&!e.tagName.includes("-"))try{let n=e;t=n.href||n.src||n.data||n.action||null}catch{return!1}if(!t)return!1;try{let n=V(e),o=new URL(t,n.baseURI);return o.protocol==="javascript:"&&(o.pathname.trim()!==""||o.search.trim()!==""||o.hash.trim()!=="")}catch{return!1}}function Qi(e){return bi.has(e)}function ul(e){let t=e.parentElement,n=V(e);if(!(!t||t===n.body||t===n.documentElement))return ot({targetElement:t,originatedFromParent:!0})}function Li({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:o,isFrameNode:r,frameContentNodes:s,elementContext:c}){let l={nodeCategory:e.nodeType},f=t||ll(e),R=ul(e);if(R&&(l.parent=R),n){let xe=$n[n];typeof xe=="number"?l.semanticRole=xe:l.semanticRole=n}if(f&&(l.isDisabled=!0),c){let{eventHandlerIndices:xe,isEditableRegion:Oe}=c,Ke=Gn(xe);Ke.length>0&&(l.eventHandlers=Ke),Oe&&(l.isEditable=!0)}let p=fl(e);p&&Object.keys(p).length>0&&(l.ariaProperties=p);let T=hl(e);T&&Object.keys(T).length>0&&(l.ariaStates=T);let S=e.nodeName;S&&S.trim()&&(l.elementName=S);let x=$i(e);x&&Object.keys(x).length>0&&(l.computedStyles=x),In(e)&&(l.isInvisible=!0);let A=dl(e,n);A&&Object.keys(A).length>0&&(l.preservedAttributes=A),e.draggable&&(l.isDraggable=!0),e.scrollWidth&&e.clientWidth&&e.scrollWidth>e.clientWidth&&(l.supportsHorizontalSwipe=!0),e.scrollHeight&&e.clientHeight&&e.scrollHeight>e.clientHeight&&(l.supportsVerticalSwipe=!0);let L=e.getAttribute("class");if(L?.trim()){L.includes("handle")&&(l.isDragHandle=!0),l.supportsHorizontalSwipe||(L.includes("horizontal")||L.includes("carousel"))&&(l.supportsHorizontalSwipe=!0),l.supportsVerticalSwipe||(L.includes("vertical")||L.includes("feed"))&&(l.supportsVerticalSwipe=!0),L.includes("dismissible")&&(l.supportsDismissSwipe=!0),(L.includes("long-press")||L.includes("hold")||L.includes("press-hold"))&&(l.supportsLongPress=!0);let xe=l.inputType||l.preservedAttributes?.[mt.type];xe==="submit"||xe==="reset"||xe==="clear"||(L.includes("submit")&&(l.preservedAttributes={...l.preservedAttributes||{},[mt.type]:"submit"}),L.includes("clear")&&(l.preservedAttributes={...l.preservedAttributes||{},[mt.type]:"clear"}),L.includes("reset")&&(l.preservedAttributes={...l.preservedAttributes||{},[mt.type]:"reset"}))}let P=wl({element:e});P&&P.length>0&&(l.labelReferences=P);let G=e.tagName;if(G&&(l.elementTag=G),ml(e)&&(l.hasFocus=!0),!r){let xe=ds({element:e,semanticRole:n,parentDisabled:f,excludeLabels:o});xe&&xe.length>0&&(l.childElements=xe)}let D=Sl({element:e});D&&D.length>0&&(l.ownedElements=D);let F=di(e);F&&(l.resourceLocator=F),(r||Yn(e))&&(l.isFrameElement=!0),s&&s.length>0&&(l.frameContent=s);let H=e.type;H&&typeof H=="string"&&H.trim()&&(l.inputType=H);let X=e.placeholder;X&&typeof X=="string"&&X.trim()&&(l.placeholderText=X);let J=e.value;J&&typeof J=="string"&&J.trim()&&(l.elementValue=J);let Z=yl({element:e,parentDisabled:t,semanticRole:n});if(Z&&Z.length>0&&(l.selectedOptions=Z),qt(e,"select,datalist")&&(l.nearestSelectList=!0),is(e))l.elementNamespace=mo.HTML;else if(pl(e)){l.elementNamespace=mo.SVG,l.svgStructure=gl(e);let xe=bl(e);xe&&Object.keys(xe).length>0&&(l.preservedAttributes?l.preservedAttributes={...l.preservedAttributes,...xe}:l.preservedAttributes=xe)}let K=o?void 0:_l({element:e});K&&K.length>0&&(l.associatedLabels=K);let fe=e.scope;fe&&typeof fe=="string"&&fe.trim()&&(l.tableScope=fe);let ee=xl({element:e});ee&&(l.tableCaption=ee);let pe=vl({element:e});pe&&(l.figureCaption=pe);let se=Rl({element:e});return se&&(l.fieldsetLegend=se),qt(e,"table")&&(l.nearestTable=!0),l}function dl(e,t){let n={},o=new Set(Object.values(mt).filter(l=>typeof l=="string")),r=new Set(Object.keys(qo).filter(l=>isNaN(Number(l)))),s=new Set(["_ngcontent","ng-reflect-*","data-v-*"]),c=e?.attributes?Array.from(e.attributes):[];for(let l of c){let f=l.name,R=l.value;if(f==="id"&&(!t||!$t.has(t)))continue;let p;if(o.has(f)?p=f:f.startsWith("data-v-")?p="data-v-*":f.startsWith("ng-reflect-")?p="ng-reflect-*":f.startsWith("_ngcontent")&&(p="_ngcontent"),p){let T=R.trim()!=="",S=r.has(p);if(T||S){let x=mt[p],A=s.has(p)?"true":R;n[x]=A}}}if(!n[mt[nt]]){let l=Mi(e);l&&(n[mt[nt]]=l)}return n}function fl(e){return Ji(e,Ko,Xo)}function hl(e){return Ji(e,Qo,null)}function Ji(e,t,n){let o={};for(let r in t)if(isNaN(Number(r))){let s=t[r],l=`aria-${r.toLowerCase().replace(/_/g,"-")}`,f=e.getAttribute(l),R=!1;n!==null&&(R=Object.values(n).filter(T=>typeof T=="number").includes(s)),e.hasAttribute(l)&&R||f?.trim()?o[s]=f:l==="aria-level"&&wi.includes(e.tagName.toLowerCase()?.trim())&&(o[s]=e.tagName.substring(1))}return o}function Mt(e){return Zi(e)&&e.nodeType===po.ELEMENT}function ir(e){return e.nodeType===po.TEXT}function Zi(e){let t=typeof e;return t=="object"&&e!=null||t=="function"}function is(e){return Mt(e)&&(!e.namespaceURI||e.namespaceURI===yi)}function pl(e){return Mt(e)&&e.namespaceURI===_i}function Yn(e){return e.tagName==="IFRAME"}function kn(e,t){return"tagName"in e?e.tagName?.toLowerCase()===t:e.elementTag?.toLowerCase()===t}function qt(e,t){if(e.closest)return e.closest(t);for(;!sr(e,t);){if(e.parentElement===null)return null;e=e.parentElement}return e}function sr(e,t){return e.matches?.(t)??e.msMatchesSelector?.(t)??e.webkitMatchesSelector(t)}function ml(e){let t=e.ownerDocument,n=t?.hasFocus()?t.activeElement:null;if(n){let o=n.getAttribute("aria-activedescendant");o&&(n=t.getElementById(o)||n)}return e===n}function gl(e){let t={},n=Yt.text,o=Yt.elText;e.textContent?.trim()&&(t[n]=e.textContent);let r=e.querySelector("title"),s=e.querySelector("img");r?.textContent?.trim()?t[o]=r.textContent:s?.alt?.trim()&&(t[o]=s.alt);let c=e.getAttribute("viewBox");c&&(t[Yt.viewBox]=c);let l=e.querySelectorAll("path");l.length>0&&(t[Yt.paths]=l.length,t[Yt.pathData]=Array.from(l).slice(0,3).map(R=>R.getAttribute("d")).filter(Boolean).map(R=>R.substring(0,100)));let f={circles:e.querySelectorAll("circle").length,rects:e.querySelectorAll("rect").length,lines:e.querySelectorAll("line").length,polygons:e.querySelectorAll("polygon").length,polylines:e.querySelectorAll("polyline").length,ellipses:e.querySelectorAll("ellipse").length};return Object.entries(f).forEach(([R,p])=>{if(p>0){let T=Yt[R];t[T]=p}}),Object.keys(t).length>0?t:void 0}function bl(e){let t={};if(!e?.hasAttributes())return t;for(let n of Object.values(Vn).filter(o=>typeof o=="number")){let o=Vn[n];if(o){let r=o;if(Vn.hasOwnProperty(r)&&e.hasAttribute(r)){let s=e.getAttribute(r);s?.trim()&&(t[n]=s)}}}return t}function El({frameElement:e,parentDisabled:t,excludeLabels:n}){if(!at.includeFrameContents)return[];let o=null;try{o=e.contentWindow?.document?.body||null}catch{return[]}if(!o)return[];let r=[];for(let s of us(o))if(!(vo(s)||ea(s))){if(Mt(s)){let c=s,l=At(c),f=_t(c,l),{shouldCreate:R,shouldAnnotate:p}=ar(f);if(R){p&&on(c);let T=ot({targetElement:c,parentDisabled:t,semanticRole:l??void 0,excludeLabels:n,elementContext:f});T&&r.push(T)}else{let T=ds({element:c,semanticRole:l??void 0,parentDisabled:t,excludeLabels:n});r.push(...T)}}else if(ir(s)){let c=To(s);c&&r.push(c)}}return r}function us(e){let t=re(e);if(ii(e,t)){try{let n=e.assignedNodes({flatten:!0});if(n&&n.length)return n}catch{}return Array.from(e.childNodes)}try{let n=e.shadowRoot||_n()?.getShadowRoot?.(e)||null;if(n){let o=Array.from(n.childNodes),r=Array.from(e.childNodes).filter(s=>!s.assignedSlot);return o.concat(r)}}catch{}return Array.from(e.childNodes)}function ds({element:e,semanticRole:t,parentDisabled:n,excludeLabels:o}){let r=[];for(let s of us(e))if(!(vo(s)||ea(s))){if(Mt(s)){let c=s,l=At(c),f=_t(c,l);if(Yn(c)){on(c);let T=El({frameElement:c,parentDisabled:n,excludeLabels:o}),S=ot({targetElement:c,parentDisabled:n,semanticRole:l??void 0,excludeLabels:o,isFrameNode:!0,frameContentNodes:T,elementContext:f});S&&r.push(S);continue}let{shouldCreate:R,shouldAnnotate:p}=ar(f);if(R){p&&on(c);let T=ot({targetElement:c,parentDisabled:n,semanticRole:l??void 0,excludeLabels:o,elementContext:f});T&&r.push(T)}else{let T=ds({element:c,semanticRole:l??void 0,parentDisabled:n,excludeLabels:o});r.push(...T)}}else if(ir(s)){let c=To(s);c&&r.push(c)}}return r}function wl({element:e}){let t=Gi(e.getAttribute("aria-labelledby")),n=new Set;for(let o of t){let r=Yi(e,o);if(!(!r||r===e)&&r){let s=At(r),c=ot({targetElement:r,semanticRole:s,elementContext:_t(r,s)});n.add(c)}}return Array.from(n)}function yl({element:e,parentDisabled:t,semanticRole:n}){let o=[];return e&&(n&&n==="listbox"?o=Array.from(e.querySelectorAll('[role="option"][aria-selected="true"]')).map(r=>ot({targetElement:r,parentDisabled:t,semanticRole:"option",elementContext:_t(r,"option")})):kn(e,"select")&&(o=Array.from(e.selectedOptions).map(r=>ot({targetElement:r,parentDisabled:t,semanticRole:"option",elementContext:_t(r,"option")})))),o}function _l({element:e}){if(Ei.includes(e.tagName)){let t=V(e),n=Xr(t,"label"),o=new Set;return Array.from(n).filter(r=>r!==e&&Tl(r,e)).map(r=>{let s=At(r),c=ot({targetElement:r,semanticRole:s,excludeLabels:!0,elementContext:_t(r,s)});o.add(c)}),Array.from(o)}}function Tl(e,t){let n=e.control;return n!==void 0?n===t:e.htmlFor!==""&&e.htmlFor===t.id?!0:!!(e.htmlFor===""&&e.contains(t))}function xl({element:e}){if(kn(e,"table")){let t=e.querySelector("caption");if(t&&t!==e){let n=At(t);return ot({targetElement:t,semanticRole:n,elementContext:_t(t,n)})}}}function vl({element:e}){if(kn(e,"figure")){let t=e.querySelector("figcaption");if(t&&t!==e){let n=At(t);return ot({targetElement:t,semanticRole:n,elementContext:_t(t,n)})}}}function Rl({element:e}){if(kn(e,"fieldset")){let t=e.querySelector("legend");if(t&&t!==e){let n=At(t);return ot({targetElement:t,semanticRole:n,elementContext:_t(t,n)})}}}function Sl({element:e}){let t=new Set,n=ji(e);for(let o of n){let r=At(o),s=ot({targetElement:o,semanticRole:r,elementContext:_t(o,r)});t.add(s)}return Array.from(t)}function ar(e){let{semanticRole:t,eventHandlerIndices:n,isEditableRegion:o,hasNodeWorthyHandlers:r,isLikelyStructuralContainer:s}=e,c=n.length>0&&n.some(T=>vi.has(T)),f=!!t||!s&&(r||o),R=!!t&&$t.has(t);return{shouldCreate:f,shouldAnnotate:f&&(R||o||c)}}function ea(e){if(!Mt(e))return!1;let t=e,n=t.tagName;return jo.has(n)?!0:n===Rn||n===Sn?kl(t):!1}function kl(e){let t=re(e),n=t?.getComputedStyle;if(!n||n.call(t,e).display==="none")return!0;let r=e.getBoundingClientRect();return r.width===0&&r.height===0&&!(typeof e.closest=="function"&&e.closest("pre"))||r.right<-1e3||r.left>t.innerWidth+1e3}function fs(e,t={}){return ni(t),Ni(),Ai(),Ci(e,{includeShadow:!0,includeIframes:at.clearIframes}),yo.initialize(at.semanticIdStart),{rootNodes:ta(e),semanticNodes:rn}}function ta(e){let t=[];try{let n=V(e),r=Array.from(n.querySelectorAll(Ki)).filter(s=>!In(s)&&zi(s));if(r.length===0)t=qn({targetElement:e});else if(r.length===1){let s=r[0];s.contains(e)?t=qn({targetElement:e}):e.contains(s)?t=qn({targetElement:s}):t=qn({targetElement:e})}else t=qn({targetElement:e})}catch(n){throw console.error("Error constructing semantic tree",n),n}return t}function qn({targetElement:e,parentNode:t}){if(vo(e)||na(e))return[];let n=At(e),o=_t(e,n);if(Yn(e))return[Al({frameElement:e,role:n,parentNode:t,elementContext:o})];let r=0,{shouldCreate:s,shouldAnnotate:c}=ar(o);s&&(c&&on(e),r=ot({targetElement:e,parentDisabled:t?.isDisabled,semanticRole:n,elementContext:o}));let l=rn[r],f=Il(e,n,r?l:t);return r&&f.length>0&&(l.semanticChildren=f),r?[r]:f}function Il(e,t,n){let o=[],r=qi(e,t);for(let s of r)if(!(vo(s)||na(s))){if(Mt(s)){let c=qn({targetElement:s,parentNode:n});o.push(...c)}else if(ir(s)&&Cl(s,n)){let c=To(s);c&&o.push(c)}}return o}function Al({frameElement:e,role:t,parentNode:n,elementContext:o}){on(e);let r=Ml(e);return ot({targetElement:e,parentDisabled:n?.isDisabled,semanticRole:t,isFrameNode:!0,frameContentNodes:r,elementContext:o})}function Ml(e){if(!at.includeFrameContents)return[];let n=Tn(e)?.body??null;return n?ta(n):[]}function Cl(e,t){let n=e.data.trim();if(!n||n==="")return!1;if(t?.semanticRole!==void 0&&t?.semanticRole!==null){let o=typeof t.semanticRole=="number"?go[t.semanticRole]:t.semanticRole;if(Qi(o))return!1}return!0}function na(e){if(!Mt(e))return!1;let t=e,n=t.tagName;return jo.has(n)?!0:n===Rn||n===Sn?Nl(t):!1}function Nl(e){let t=re(e);if(t.getComputedStyle(e).display==="none")return!0;let o=e.getBoundingClientRect();return o.width===0&&o.height===0&&!e.closest("pre")||o.right<-1e3||o.left>t.innerWidth+1e3}function lr(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t}function Ll(e){let t=e.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}function jn(e,t,n){let o=V(e,t),r=q(o,n);try{e.focus?.({preventScroll:!0})}catch{}if(lr(o)===e)return!0;try{let{x:s,y:c}=Ll(e),l=r.PointerEvent||PointerEvent,f=r.MouseEvent||MouseEvent;e.dispatchEvent(new l("pointerdown",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:c,buttons:1,button:0,pointerType:"mouse"})),e.dispatchEvent(new f("mousedown",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:c,buttons:1,button:0})),e.dispatchEvent(new f("mouseup",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:c,buttons:0,button:0})),e.dispatchEvent(new l("pointerup",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:c,buttons:0,button:0,pointerType:"mouse"})),(e.isContentEditable||Rt(e,r)||It(e,r)||e.getAttribute("contenteditable")==="true")&&e.dispatchEvent(new f("click",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:c,button:0}))}catch{}try{e.focus?.({preventScroll:!0})}catch{}return lr(o)===e}function Ro(e,t){let n=re(e),o=It(e,n)?n.HTMLTextAreaElement.prototype:n.HTMLInputElement.prototype,r=Object.getOwnPropertyDescriptor(o,"value");r?.set?r.set.call(e,t):e.value=t}function Mn(e,t,n="insertText"){let o=re(e),r=o.InputEvent||(typeof InputEvent<"u"?InputEvent:null),s=o.Event||Event;try{r?e.dispatchEvent(new r("beforeinput",{bubbles:!0,cancelable:!0,composed:!0,data:String(t??""),inputType:n})):e.dispatchEvent(new s("beforeinput",{bubbles:!0,cancelable:!0,composed:!0}))}catch{try{e.dispatchEvent(new s("beforeinput",{bubbles:!0,cancelable:!0,composed:!0}))}catch{}}try{r?e.dispatchEvent(new r("input",{bubbles:!0,cancelable:!1,composed:!0,data:String(t??""),inputType:n})):e.dispatchEvent(new s("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{try{e.dispatchEvent(new s("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{}}try{e.dispatchEvent(new s("change",{bubbles:!0,cancelable:!0,composed:!0}))}catch{}}function Dl(e){let n=re(e).KeyboardEvent||KeyboardEvent,o={key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0,composed:!0},r=e.dispatchEvent(new n("keydown",o)),s=e.dispatchEvent(new n("keypress",o)),c=e.dispatchEvent(new n("keyup",o));return{canceled:!(r&&s&&c)}}function An(e){if(!e)return!1;let t=re(e);if(It(e,t))return!e.disabled&&!e.readOnly;if(Rt(e,t)){let n=(e.type||"text").toLowerCase();return(n==="text"||n==="search"||n==="email"||n==="url"||n==="tel"||n==="password"||n==="number")&&!e.disabled&&!e.readOnly}return!1}function hs(e){let t=re(e);if(!e||!Ve(e,t))return!1;if(e.isContentEditable)return!0;let n=e.getAttribute("contenteditable");return!!(n&&n!=="false"||e.getAttribute("role")==="textbox"&&!("value"in e))}function Ol(e,t){let n=e.getRootNode();return yt(n)?n:V(e)??t}function Ul(e,t){let n=[];for(let o of t.split(/\s+/).filter(Boolean)){let r=e.getElementById?.(o)||e.querySelector?.(`#${CSS.escape(o)}`),s=re(r);Ve(r,s)&&n.push(r)}return n}function ia(e,t){if(!e)return{kind:"none",el:null,via:"no-root"};if(An(e))return{kind:"input",el:e,via:"self-input"};if(hs(e))return{kind:"contenteditable",el:e,via:"self-contenteditable"};let n=V(e)??t,o=q(n),r=Ol(e,n);if(ri(e,o)){let f=e.control;if(An(f))return{kind:"input",el:f,via:"label.control"};let R=e.htmlFor;if(R){let p=r.getElementById?.(R)||r.querySelector?.(`#${CSS.escape(R)}`);if(An(p))return{kind:"input",el:p,via:"label.for"}}}let s=e.getAttribute("aria-controls")||e.getAttribute("aria-owns");if(s)for(let f of Ul(r,s)){if(An(f))return{kind:"input",el:f,via:"aria-controls/owns"};if(hs(f))return{kind:"contenteditable",el:f,via:"aria-controls/owns"};let R=f.querySelector?.("input,textarea");if(An(R))return{kind:"input",el:R,via:"aria-controls->desc"}}let c=e.querySelector?.("input,textarea");if(An(c))return{kind:"input",el:c,via:"descendant"};let l=e.shadowRoot||null;if(l){let f=l.querySelector?.("input,textarea");if(An(f))return{kind:"input",el:f,via:"open-shadow-input"};let R=l.querySelector?.('[contenteditable="true"],[contenteditable=""],[role="textbox"]');if(hs(R))return{kind:"contenteditable",el:R,via:"open-shadow-contenteditable"}}return e.getAttribute("role")==="textbox"&&!("value"in e)?{kind:"contenteditable",el:e,via:"role=textbox"}:{kind:"none",el:null,via:"not-found"}}function Xn(e,t,n,o=!1){let r=V(e,t),c=q(r,n).getSelection?.();if(!c)return!1;try{let l=r.createRange();return l.selectNodeContents(e),o&&l.collapse(!1),c.removeAllRanges(),c.addRange(l),!0}catch{return!1}}function Cn(e){return(e.textContent??"").replace(/\u00A0/g," ").trim()}var cr=e=>String(e??"").replace(/\s+/g," ").trim(),aa=new MessageChannel,ca=[];aa.port1.onmessage=()=>{let e=ca.shift();e&&e()};function oa(){return new Promise(e=>{ca.push(e),aa.port2.postMessage(0)})}async function ra(e,t,n){await Promise.resolve();let o=Math.max(0,Math.min(4,Number(n)||0));for(let r=0;r<o;r++)e.hidden?await oa():await new Promise(s=>{try{t.requestAnimationFrame(()=>s())}catch{oa().then(s)}})}function Fl(e){let t=String(e??"");return t===" "?{code:"Space",which:32}:/^[a-z]$/i.test(t)?{code:`Key${t.toUpperCase()}`,which:t.toUpperCase().charCodeAt(0)}:/^[0-9]$/.test(t)?{code:`Digit${t}`,which:t.charCodeAt(0)}:{code:"",which:t.length===1?t.charCodeAt(0):0}}function sa(e,t,n,o){let r=V(e,t),c=q(r,n).KeyboardEvent||KeyboardEvent,l=String(o??"");for(let f of l){let{code:R,which:p}=Fl(f),T={key:f,code:R,bubbles:!0,cancelable:!0,composed:!0,keyCode:p,which:p};e.dispatchEvent(new c("keydown",T)),e.dispatchEvent(new c("keypress",T)),e.dispatchEvent(new c("keyup",T))}}async function la(e,t,n,o,r){let s=String(o??"");if(e.disabled||e.readOnly)return{success:!1,method:"type-native-setter",details:"disabled_or_readonly",allowFallback:!0};let c=String(e.value??""),l=V(e,t),f=q(l,n),R=jn(e,l,f),p=Number.isFinite(Number(r?.settleFrames))?Math.max(0,Math.min(4,Number(r?.settleFrames))):l.hidden?1:2,T=!!r?.useKeyFallback,S=Number.isFinite(Number(r?.keyFallbackMaxLen))?Number(r?.keyFallbackMaxLen):140,x=T&&s.length>0&&s.length<=S;Ro(e,s),Mn(e,s,"insertReplacementText"),x&&sa(e,l,f,s),await ra(l,f,p);let A=String(e.value??""),L=cr(c),P=cr(A),G=cr(s),D=L===G,F=P===G,H=A!==c,X=s.length>0&&!D&&A===c,J=1;if(!D&&!F&&!H){J=2;try{e.focus?.({preventScroll:!0}),e.select?.()}catch{}let ee=!1;try{l.execCommand?.("selectAll",!1,void 0),ee=!!l.execCommand?.("insertText",!1,s)}catch{ee=!1}if(!ee)try{Ro(e,s)}catch{}try{Mn(e,s,"insertReplacementText")}catch{}x&&sa(e,l,f,s),await ra(l,f,p),A=String(e.value??"")}let ie=cr(A)===G,K=A!==c;X=s.length>0&&!D&&A===c;let fe=D||ie||K;return{success:fe,method:"type-native-setter",details:`focus=${R};attempts=${J};settleFrames=${p};beforeLen=${c.length};afterLen=${A.length};changed=${K};alreadyCorrect=${D};nowCorrect=${ie};reverted=${X};keyFallback=${x}`,allowFallback:fe?void 0:!0}}function Hl(e,t,n){let r=re(e).InputEvent||InputEvent,s=new r("beforeinput",{bubbles:!0,cancelable:!0,composed:!0,data:t,inputType:n});return{ok:e.dispatchEvent(s),defaultPrevented:s.defaultPrevented}}function ua(e,t,n,o){let r=V(e,n),s=q(r,o),c=s.InputEvent||InputEvent,l=s.Event||Event,f=String(t??""),R=Cn(e),p=jn(e,r,s),T=Xn(e,r,s,!0),S=Hl(e,f,"insertText"),x=!1,A="execCommand",L=!1,P=()=>{L=!0};try{e.addEventListener("input",P,{capture:!0})}catch{}if(S.ok&&!S.defaultPrevented)try{x=!!r.execCommand?.("insertText",!1,f)}catch{}if(!x)try{let F=s.getSelection?.(),H=F&&F.rangeCount?F.getRangeAt(0):null;if(!H||!e.contains(H.commonAncestorContainer)){Xn(e,r,s,!0);let X=s.getSelection?.();H=X&&X.rangeCount?X.getRangeAt(0):null}H&&(H.insertNode(r.createTextNode(f)),H.collapse(!1),F?.removeAllRanges(),F?.addRange(H),x=!0,A="range")}catch{}if(x&&!L){try{e.dispatchEvent(new c("input",{bubbles:!0,cancelable:!1,composed:!0,data:f,inputType:"insertText"}))}catch{try{e.dispatchEvent(new l("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{}}try{e.dispatchEvent(new l("change",{bubbles:!0,cancelable:!0,composed:!0}))}catch{}}try{e.removeEventListener("input",P,{capture:!0})}catch{}let G=Cn(e);return{success:G!==R||!!f&&G.includes(f),method:`type-contenteditable-${A}`,details:`focus=${p};selectedWithin=${T};inserted=${x}`}}function da(e){let{canceled:t}=Dl(e);if(t)return{submitted:!1,method:"enter-handled"};let n=e.form||e.closest?.("form");return n?(n.requestSubmit?.()??n.submit?.(),{submitted:!0,method:"enter->form-submit"}):{submitted:!1,method:"enter-dispatched"}}function fa(e,t,n){if(e.disabled||e.readOnly)return{success:!1,method:"clear-native-setter",details:"disabled_or_readonly",allowFallback:!0};let o=V(e,t),r=q(o,n),s=String(e.value??""),c=jn(e,o,r);Ro(e,""),Mn(e,"","deleteByCut");let l=String(e.value??""),f=l!==s;return{success:f||l.length===0,method:"clear-native-setter",details:`focus=${c};beforeLen=${s.length};afterLen=${l.length};changed=${f}`}}function ha(e,t,n){let o=V(e,t),r=q(o,n),s=Cn(e),c=jn(e,o,r),l=Xn(e,o,r,!1),f=!1,R="execCommand";try{f=!!o.execCommand?.("delete",!1,void 0)}catch{f=!1}if(!f)try{let x=r.getSelection?.(),A=x&&x.rangeCount?x.getRangeAt(0):null;(!A||!e.contains(A.commonAncestorContainer))&&Xn(e,o,r,!1);let L=r.getSelection?.(),P=L&&L.rangeCount?L.getRangeAt(0):null;P&&(P.deleteContents(),P.collapse(!1),L?.removeAllRanges(),L?.addRange(P),f=!0,R="range")}catch{}if(!f)try{e.textContent="",f=!0,R="textContent"}catch{}Mn(e,"","deleteByCut");let p=Cn(e),T=p!==s;return{success:f||T||p.length===0,method:`clear-contenteditable-${R}`,details:`focus=${c};selectedWithin=${l};cleared=${f};changed=${T}`}}function pa(e,t){if(e===t||e.contains(t))return!0;let n=t;for(;n;){let o=n.getRootNode?.();if(yt(o)){let r=o.host;if(r===e||e.contains(r))return!0;n=r;continue}n=n.parentNode||null}return!1}var ur;(function(e){e.FLASH_LITE="Gemini Flash Lite",e.FLASH="Gemini Flash",e.PRO="Gemini Pro"})(ur||(ur={}));var ma;(function(e){e[e.NativeHostConnected=0]="NativeHostConnected",e[e.NativeHostDisconnected=1]="NativeHostDisconnected"})(ma||(ma={}));var Pl=["image/png","image/jpeg","image/webp"],Bl=["application/pdf","text/plain"],Wh=[...Pl,...Bl];var Ze;(function(e){e.ACT="act_on_tab",e.CRAWL="crawl_and_extract_from_tab",e.EXTRACT="extract_from_tab",e.SHEETS_WORKFLOW="sheets_workflow",e.INFER_SHEET_DATA="infer_sheet_data",e.GRAPHBOT="graph_bot",e.PDF_FILLER="pdf_filler",e.CUSTOM_TOOL_GENERATOR="custom_tool_generator",e.WEBPAGE_GENERATOR="webpage_generator",e.GOOGLE_DOC_GENERATOR="google_doc_generator",e.GOOGLE_SLIDES_GENERATOR="google_slides_generator",e.PROCESS_TEXT="process_text",e.CREATE_SHEET_FROM_DATA="create_sheet_from_data",e.CONFIGURE_API_KEY="configure_api_key",e.TASK_COMPLETE="task_complete",e.ASK_USER="ask_user",e.EXECUTE_MULTIPLE_TOOLS="execute_multiple_tools",e.QUERY_RTRVR_AI_DOCUMENTATION="query_rtrvr_ai_documentation"})(Ze||(Ze={}));var je;(function(e){e.PLANNER="Planner",e.AGENTIC_SEEK="Agentic Action",e.CRAWL_PAGES="Crawl Pages",e.EXTRACT_PAGE="Extract Page",e.SHEETS_WORKFLOW="Sheets Workflow",e.INFER_SHEET_DATA="Infer Sheet Data",e.MULTI_STEPS="Multi Steps",e.PDF_FILLER="PDF Filler",e.CUSTOM_TOOL_GENERATOR="Custom Tool Generator",e.WEBPAGE_GENERATOR="WebPage Generator",e.GOOGLE_DOC_GENERATOR="Google Doc Generator",e.GOOGLE_SLIDES_GENERATOR="Google Slides Generator",e.PROCESS_TEXT="Process Text",e.CREATE_SHEET_FROM_DATA="Create Sheet From Data",e.EXECUTE_MULTIPLE_TOOLS="Execute Multiple User Tools",e.CONFIGURE_API_KEY="Configure Gemini API Key",e.QUERY_RTRVR_AI_DOCUMENTATION="query_rtrvr_ai_documentation"})(je||(je={}));var Vh={[Ze.ACT]:je.AGENTIC_SEEK,[Ze.CRAWL]:je.CRAWL_PAGES,[Ze.EXTRACT]:je.EXTRACT_PAGE,[Ze.SHEETS_WORKFLOW]:je.SHEETS_WORKFLOW,[Ze.INFER_SHEET_DATA]:je.INFER_SHEET_DATA,[Ze.PDF_FILLER]:je.PDF_FILLER,[Ze.CUSTOM_TOOL_GENERATOR]:je.CUSTOM_TOOL_GENERATOR,[Ze.WEBPAGE_GENERATOR]:je.WEBPAGE_GENERATOR,[Ze.GOOGLE_DOC_GENERATOR]:je.GOOGLE_DOC_GENERATOR,[Ze.GOOGLE_SLIDES_GENERATOR]:je.GOOGLE_SLIDES_GENERATOR,[Ze.PROCESS_TEXT]:je.PROCESS_TEXT,[Ze.CREATE_SHEET_FROM_DATA]:je.CREATE_SHEET_FROM_DATA,[Ze.EXECUTE_MULTIPLE_TOOLS]:je.EXECUTE_MULTIPLE_TOOLS,[Ze.CONFIGURE_API_KEY]:je.CONFIGURE_API_KEY,[Ze.QUERY_RTRVR_AI_DOCUMENTATION]:je.QUERY_RTRVR_AI_DOCUMENTATION};var ps=200;var $h=ur.FLASH;var Gh=je.PLANNER;var ms="application/pdf",gs="application/gsheet";var Yh=20*1024*1024;var dr={maxParallelTabs:4,pageLoadDelay:2e3,disableAutoScroll:!1,makeNewTabsActive:!1,writeRowProcessingTime:!1,totalBudgetMs:25e3,pageDataTimeoutMs:22e3,pdfTextSelectionTimeoutMs:12e3,onlyTextContent:!1};var Wl=1,Vl=9,$l=11,Es="application/gdoc",zn="text/html",fr="text/plain";function Gl(e){return!!e&&typeof e=="object"&&e.nodeType===Vl}function ga(e){return!!e&&typeof e=="object"&&e.nodeType===Wl}function Yl(e){return!!e&&typeof e=="object"&&e.nodeType===$l&&typeof e.host=="object"&&typeof e.mode=="string"}function ba(e){return ga(e)&&String(e.tagName).toUpperCase()==="IFRAME"}function bs(e){let t;if(typeof e=="number")t=e;else if(typeof e=="bigint")t=Number(e);else if(typeof e=="string")t=Number(e.trim());else return null;if(!Number.isFinite(t))return null;let n=Math.trunc(t);return n<=0?null:n}function ql(e){try{let t=e.shadowRoot;return t||globalThis?.chrome?.dom?.openOrClosedShadowRoot?.(e)||null}catch{return null}}function Xl(e,t,n={}){let o=n.traverseShadow!==!1,r=n.traverseIframes!==!1,s=n.requireOwnerDocument,c=[e],l=new WeakSet;for(;c.length;){let f=c.pop();if(f&&typeof f=="object"){if(l.has(f))continue;l.add(f)}if(Gl(f)){let T=f.documentElement||f.body;T&&c.push(T);continue}if(Yl(f)){let T=f.children;if(T&&T.length)for(let S=T.length-1;S>=0;S--)c.push(T[S]);continue}if(!ga(f))continue;let R=f;if(s&&R.ownerDocument!==s)continue;let p=R.getAttribute?.(nt);if(p&&Eo(p)===t)return R;if(o)try{let T=ql(R);T&&c.push(T)}catch{}if(r&&ba(R))try{let T=Tn(R);T&&c.push(T)}catch{}for(let T=R.lastElementChild;T;T=T.previousElementSibling)c.push(T)}return null}function Ct(e,t,n={}){let o=bs(t);if(!o)return null;let r=_o(o);return r&&(!n.requireOwnerDocument||r.ownerDocument===n.requireOwnerDocument)?r:Xl(e,o,{requireOwnerDocument:n.requireOwnerDocument,traverseShadow:n.traverseShadow,traverseIframes:n.traverseIframes})}function ws(e=document){return e.querySelector('embed[type="application/pdf"], embed[type="application/x-google-chrome-pdf"]')}function Ea(e){if(e==null)return[];if(Array.isArray(e)){let t=[];for(let n of e){let o=bs(n);o&&t.push(o)}return t}if(typeof e=="number"||typeof e=="bigint"){let t=bs(e);return t?[t]:[]}if(typeof e=="string"){let t=e.match(/\d+/g);return t?t.map(o=>parseInt(o,10)).filter(o=>Number.isFinite(o)&&o>0):[]}if(typeof e=="object"){let t=e.path??e.ids??e.iframe_path;if(t!==void 0)return Ea(t)}return[]}function Kn(e,t){let n=Ea(t),o=e.defaultView||window;if(!n.length)return{doc:e,win:o,iframePath:n,resolvedPath:[],unresolvedPath:[]};let r=e,s=[];for(let c=0;c<n.length;c++){let l=n[c],f=n.length===1,R=Ct(r,l,{requireOwnerDocument:f?void 0:r,traverseShadow:!0,traverseIframes:f});if(!R||!ba(R))return{doc:r,win:r.defaultView||o,iframePath:n,resolvedPath:s,unresolvedPath:n.slice(c)};let p=null;try{p=Tn(R)||null}catch{p=null}if(!p)return{doc:r,win:r.defaultView||o,iframePath:n,resolvedPath:s,unresolvedPath:n.slice(c)};s.push(l),r=p}return{doc:r,win:r.defaultView||o,iframePath:n,resolvedPath:s,unresolvedPath:[]}}function wa(e){return e==="application/pdf"||e==="application/x-pdf"||e==="application/x-google-chrome-pdf"}function jl(){return Date.now()}function St(e){return!e||!Number.isFinite(e)?Number.POSITIVE_INFINITY:Math.max(0,e-jl())}async function ya(e,t,n){if(!Number.isFinite(e)||e<=0)return;let o=St(n);o<=0||o<e+40||await et(e,t)}async function Qn(e,t,n){let o=Math.max(0,Math.floor(t));return o?await Promise.race([e.then(s=>({ok:!0,value:s})),(async()=>(await et(o,n),{ok:!1,reason:"timeout"}))()]):{ok:!1,reason:"timeout"}}var et=(()=>{let e=new MessageChannel,t=[];e.port1.onmessage=()=>{let o=t.shift();o&&o()};let n=()=>new Promise(o=>{t.push(o),e.port2.postMessage(0)});return async(o,r)=>{let s=Number(o);if(!Number.isFinite(s)||s<=0)return;if(!r.hidden){let l=r.defaultView||window,f=l.setTimeout?l.setTimeout.bind(l):setTimeout;await new Promise(R=>f(R,s));return}let c=Date.now();for(;Date.now()-c<s;)await n()}})();var zl=3e4;function _a(e){return(String(e??"").replace(/\\/g,"/").split("/").pop()||"upload").replace(/[\u0000-\u001f\u007f]/g,"").trim()||"upload"}var ys=class extends Error{constructor(n,o){super(n);W(this,"url");W(this,"status");W(this,"statusText");W(this,"bodySnippet");this.name="FetchFileError",this.url=o.url,this.status=o.status,this.statusText=o.statusText,this.bodySnippet=o.bodySnippet}};function Kl(e){return e&&e.split(";")[0].trim()||"application/octet-stream"}function Ql(e){if(!e)return;let t=/filename\*\s*=\s*UTF-8''([^;]+)/i.exec(e);if(t?.[1])try{return decodeURIComponent(t[1].trim().replace(/^\"(.*)\"$/,"$1"))}catch{}let n=/filename\s*=\s*(\"?)([^\";]+)\1/i.exec(e);if(n?.[2])return n[2].trim()}function _s(e,t){try{let o=(t??window).URL||URL,s=new o(e).pathname.match(/\/o\/(.+?)(\?|$)/);if(s?.[1]){let l=decodeURIComponent(s[1]).split("/");return l[l.length-1].replace(/^\d+-/,"")}}catch{}}function Ta(e){let t=atob(e),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n}async function Jl(e,t={},n,o=fetch){let r=new AbortController,s=zl,c=!1,l=()=>{};if(n){let R=!1;l=()=>{R=!0},(async()=>{try{if(await et(s,n),R)return;c=!0,r.abort()}catch{}})().catch(()=>{})}else{let R=setTimeout(()=>{c=!0,r.abort()},s);l=()=>clearTimeout(R)}let f=new Headers(t.headers);f.has("Accept")||f.set("Accept","*/*");try{let R=await o(e,{method:"GET",redirect:t.redirect??"follow",cache:t.cache??"no-store",mode:t.mode??"cors",credentials:t.credentials??"include",...t,headers:f,signal:r.signal});if(!R.ok){let x=await R.text().catch(()=>"");throw new ys(`Fetch failed (${R.status})`,{url:e,status:R.status,statusText:R.statusText,bodySnippet:x.slice(0,256)})}let p=await R.arrayBuffer(),T=Kl(R.headers.get("content-type")),S=Ql(R.headers.get("content-disposition"))||_s(e);return{bytes:p,mimeType:T,fileName:S}}finally{l()}}async function xa(e,t,n){return await Jl(t,{referrer:n??void 0,referrerPolicy:"strict-origin-when-cross-origin"})}var Fe;(function(e){e.UP="UP",e.DOWN="DOWN",e.LEFT="LEFT",e.RIGHT="RIGHT",e.TOP="TOP",e.BOTTOM="BOTTOM"})(Fe||(Fe={}));var tt;(function(e){e.START="START",e.CENTER="CENTER",e.END="END",e.NEAREST="NEAREST"})(tt||(tt={}));function Ra(e){if(!e)return tt.CENTER;let t=typeof e=="string"?e.toUpperCase():String(e).toUpperCase();return tt&&t in tt?tt[t]:tt.CENTER}function Ts(e){return globalThis.CSS&&typeof globalThis.CSS.escape=="function"?globalThis.CSS.escape(e):e.replace(/([ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}function Jn(e,t){if(!e)return"";let n=V(e,t);if(e===n.documentElement)return"html";if(e===n.body)return"body";if(e.id)return`#${Ts(e.id)}`;let o=[],r=e;for(;r&&r!==n.body&&r!==n.documentElement;){let s=r.tagName.toLowerCase();if(r.id){s+=`#${Ts(r.id)}`,o.unshift(s);break}let l=(r.classList&&r.classList.length?Array.from(r.classList):(r.className||"").toString().split(/\s+/).filter(Boolean)).filter(f=>f&&f.length<=48).sort((f,R)=>f.length-R.length).slice(0,3).map(Ts);if(l.length)s+="."+l.join(".");else{let f=r.parentElement;if(f){let R=Array.from(f.children).filter(p=>p.tagName===r.tagName);if(R.length>1){let p=R.indexOf(r)+1;s+=`:nth-of-type(${p})`}}}o.unshift(s),r=r.parentElement}return o.join(" > ")}function Nn(e){return e.scrollingElement||e.documentElement||e.body}function hr(e,t,n,o,r){let s=V(e,t),c=q(s,n),l=Nn(s),f=e===s.documentElement||e===s.body||e===l,R=f?l:e,p=f?c.innerHeight:R.clientHeight,T=f?c.innerWidth:R.clientWidth,S=r??p*.8;switch(o){case Fe.DOWN:{R.scrollTop+=S;break}case Fe.UP:{R.scrollTop=Math.max(0,R.scrollTop-S);break}case Fe.LEFT:return R.scrollLeft=Math.max(0,R.scrollLeft-(r??T*.8)),{success:!0,scrollLeft:R.scrollLeft};case Fe.RIGHT:return R.scrollLeft+=r??T*.8,{success:!0,scrollLeft:R.scrollLeft};default:return{success:!1,error:`Unsupported scroll direction: ${String(o)}`}}let x=R.scrollHeight,A=f?c.innerHeight:R.clientHeight,L=x-A;return{success:!0,scrollTop:R.scrollTop,isAtTop:R.scrollTop<=5,isAtBottom:R.scrollTop>=L-5}}function Zl(e,t,n){let o=V(e,t),r=q(o,n),s=Nn(o),c=e;for(;c&&c!==o.body&&c!==o.documentElement;){let f=r.getComputedStyle(c).overflowY;if((f==="auto"||f==="scroll"||f==="overlay")&&c.scrollHeight>c.clientHeight+5)return c;c=c.parentElement}return s}function va(e,t,n){let o=V(e,t),r=q(o,n),s=Nn(o),c=e===o.documentElement||e===o.body||e===s,l=c?s:e,f=l.scrollHeight,R=c?r.innerHeight:l.clientHeight,p=f-R;return l.scrollTop>=p-5}function xs(e,t,n,o){let r=V(e,t),s=q(r,n),c=Nn(r),l=Zl(e,r,s),f=l===r.documentElement||l===r.body||l===c,R=f?c:l,p=e.getBoundingClientRect(),T=f?new(s.DOMRect||DOMRect)(0,0,s.innerWidth,s.innerHeight):l.getBoundingClientRect(),S=f?s.innerHeight:l.clientHeight,x=24,A=p.top-T.top,L=R.scrollTop+A,P;switch(o){case tt.START:P=L-x;break;case tt.END:P=L+p.height-S+x;break;case tt.NEAREST:{if(p.top>=T.top&&p.bottom<=T.bottom)return{success:!0,scrollTop:R.scrollTop,isAtTop:R.scrollTop<=5,isAtBottom:va(R,r,s)};p.top<T.top?P=L-x:P=L+p.height-S+x;break}case tt.CENTER:default:P=L-S/2+p.height/2;break}let G=R.scrollHeight-S;return R.scrollTop=Math.max(0,Math.min(P,G)),{success:!0,scrollTop:R.scrollTop,isAtTop:R.scrollTop<=5,isAtBottom:va(R,r,s)}}var eu=new Set([M.click_element,M.type_into_element,M.type_and_enter,M.hover_element,M.right_click_element,M.double_click_element,M.press_key,M.scroll_page,M.scroll_to_element,M.mouse_wheel,M.drag_element,M.drag_and_drop,M.swipe_element,M.long_press_element,M.adjust_slider,M.select_dropdown_value,M.clear_element,M.focus_element,M.check_field_validity,M.select_text,M.copy_text,M.paste_text,M.pinch_zoom,M.upload_file]);(()=>{let e="__RTRVR_ACTION_EXECUTOR__";if(window[e])return;window[e]=!0;try{document.documentElement?.setAttribute(Qr,"1")}catch{}let n="__RTRVR_INTERNAL__";try{window.__RTRVR_INTERNAL_KEY__=window.__RTRVR_INTERNAL_KEY__||n}catch{}let o=window.__RTRVR_INTERNAL_KEY__||n,r=window[o],s=r&&typeof r=="object"?r:{};if(!r)try{Object.defineProperty(window,o,{value:s,writable:!1,configurable:!1,enumerable:!1})}catch{window[o]=s}async function c(i){let w={};try{let b=Zs[i.opcode];if(!b)throw new Error(`Unknown tool opcode: ${i.opcode}`);let E={...i.call,name:b};w=(await L({tabIndex:i.tabIndex,call:E,elementData:A(i.elementData),payload:i.payload}))[0]?.response??{success:!1,error:"Empty tool response",allowFallback:!0}}catch(b){w={success:!1,error:b?.message||String(b),allowFallback:!0}}return w}try{Object.defineProperty(s,"actions",{value:Object.freeze({execute:c}),writable:!1,configurable:!1,enumerable:!1})}catch{}let l="__RTRVR_UPLOAD_BYTES_REQ__",f="__RTRVR_UPLOAD_BYTES_RES__",R="__RTRVR_UPLOAD_BYTES_BRIDGE__",p="__RTRVR_WINDOW_MESSAGE_MUX__";function T(i){let w=i,b=w[p];if(!b||typeof b!="object"){b={handlers:new Set,installed:!1};try{Object.defineProperty(w,p,{value:b,enumerable:!1,configurable:!1})}catch{w[p]=b}}if(!b.installed){b.installed=!0,i.addEventListener("message",E=>{if(E.source===i)for(let d of Array.from(b.handlers))try{d(E)}catch{}},!0);try{i.addEventListener("pagehide",()=>{let d=i[R]?.pending;if(d)for(let[u,h]of d){try{h.cancelTimeout()}catch{}h.reject(new Error("pagehide: upload bytes request canceled")),d.delete(u)}},!0)}catch{}}return b}function S(i){let w=i,b=w[R];if(!b||typeof b!="object"){b={pending:new Map};try{Object.defineProperty(w,R,{value:b,enumerable:!1,configurable:!1})}catch{w[R]=b}T(i).handlers.add(d=>{let u=d?.data;if(!u||typeof u!="object"||u.type!==f)return;let h=String(u.requestId||"");if(!h)return;let v=b.pending.get(h);if(!v)return;b.pending.delete(h);try{v.cancelTimeout()}catch{}if(!u.ok){v.reject(new Error(u.error||"Failed to get bytes"));return}let C=u.bytes;if(!(C instanceof ArrayBuffer)){v.reject(new Error("Invalid bytes payload (expected ArrayBuffer)"));return}if(typeof v.expectedByteLength=="number"&&C.byteLength!==v.expectedByteLength){v.reject(new Error(`Byte length mismatch: got=${C.byteLength}, expected=${v.expectedByteLength}`));return}v.resolve(C)})}return b}function x(i,w,b,E=9e4){let d=i.__ROVER_UPLOAD_BYTES__||i.rover?.uploadBytes||i.rtrvr?.uploadBytes;if(typeof d=="function")return Promise.resolve().then(()=>d({token:w,byteLength:b,timeoutMs:E})).then(I=>{if(I instanceof ArrayBuffer)return I;if(I&&I.buffer instanceof ArrayBuffer)return I.buffer;throw new Error("Upload bytes provider returned invalid buffer")});let u=S(i),h=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(16).slice(2)}`,v=Math.max(1e3,Math.min(Number(E)||9e4,18e4)),C=Go(i)||document;return new Promise((I,N)=>{let U=!1,$=!1,z=()=>{$=!0};(async()=>{await et(v,C),!($||U)&&(u.pending.delete(h),U=!0,N(new Error("Timed out waiting for upload bytes")))})().catch(()=>{}),u.pending.set(h,{cancelTimeout:z,expectedByteLength:b,resolve:ne=>{U||(U=!0,z(),I(ne))},reject:ne=>{U||(U=!0,z(),N(ne))}}),i.postMessage({type:l,requestId:h,token:w,byteLength:b},"*")})}function A(i){if(i)return{frameworks:i.frameworks?i.frameworks.map(w=>Js[w]).filter(w=>w&&w!=="unknown"):[],listenersRaw:i.listenersRaw??"",role:i.role??void 0,pattern:i.pattern??void 0,value:i.value??void 0}}async function L({tabIndex:i,call:w,elementData:b,payload:E}){let d=(()=>{try{return Ot()?.top?.document||document}catch{return document}})(),u=w.args,h,v,C;try{({doc:h,win:v,unresolvedPath:C}=Kn(d,u.iframe_id))}catch{h=document,v=q(h)}let I=w.name,N=u.element_id?Ct(h,u.element_id):null,U=N?.ownerDocument??null,$;if(!eu.has(I))$={success:!1,error:`Tool not promotable to main: ${I}`,allowFallback:!0};else{let z=U??h,ne=q(z,v);$=await G(I,N,u,b,z,ne,E)}return[{name:w.name,args:w.args,response:$}]}async function P(i,w,b){try{let E=i.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",u=i[E]?.scroll?.execute;if(typeof u!="function")throw new Error("main-world scroll detector not available");let h=b?.doc||Go(i)||document,v=Math.max(250,Math.min(Number(b?.timeoutMs??3500),8e3)),C=await Qn(Promise.resolve().then(()=>u(w)),v,h);if(!C.ok)throw new Error("scroll detector timeout");return C.value}catch(E){throw new Error(E?.message||"main-world scroll detector not available")}}async function G(i,w,b,E,d,u,h){let v=$=>({success:$.success,error:$.success?void 0:$.details||"Action failed",allowFallback:$.success?void 0:$.allowFallback??!0}),C=i===M.press_key||i===M.scroll_page||i===M.drag_and_drop||i===M.pinch_zoom;if(!w&&!C)return v({success:!1,method:"missing-element-race",details:"Target element missing",allowFallback:!0});let I=new Set([M.type_into_element,M.type_and_enter,M.clear_element,M.focus_element,M.select_text,M.check_field_validity]),N=w,U=V(N,d);if(N&&I.has(i)){let $=ia(N,U);($.kind==="input"||$.kind==="contenteditable")&&(N=$.el)}try{switch(i){case M.click_element:return v(X(w,d,u,E));case M.double_click_element:return v(en(w,d,u));case M.right_click_element:return v(pn(w,d,u));case M.hover_element:return v(await ut(w,d,u,E,b.duration));case M.type_into_element:return v(await xt(N,d,u,b.text,E));case M.type_and_enter:return v(await ft(N,d,u,b.text,E));case M.clear_element:return v(await vt(N,d,u,E));case M.focus_element:return v(st(N,d,u));case M.select_dropdown_value:return v(ve(w,d,u,b.value,E));case M.adjust_slider:return v(Ft(w,d,u,E?.value??b.value,E));case M.check_field_validity:return v(Oo(N,d,u));case M.select_text:return v(Hn(N,d,u,b.start_offset,b.end_offset));case M.scroll_page:return v(await Kt(w,d,u,b));case M.scroll_to_element:return v(await oo(w,d,u,b));case M.mouse_wheel:return v(ht(w,d,u,b.delta_x,b.delta_y));case M.drag_element:return v(await un(w,d,u,b,E));case M.drag_and_drop:return v(await Bt(b,w,d,u));case M.swipe_element:return v(await dn(w,d,u,b));case M.long_press_element:return v(await ro(w,d,u,b.duration));case M.pinch_zoom:return v(await Be(w,d,u,b));case M.press_key:return v(Qt(b.key,b.modifiers,w,d,u));case M.copy_text:return v(await fn(w,d,u));case M.paste_text:return v(await Jt(w,d,u,E));case M.upload_file:return v(await Zt(b,d,u,h,w,E));default:return v({success:!1,method:"unhandled",details:`Unhandled ${i}`,allowFallback:!0})}}catch($){return v({success:!1,method:"exception",details:$?.message||"exception",allowFallback:!0})}}function D(i){let w=new Map;if(!i)return w;let b=i.trim();if(!b)return w;let E=vn(b);if(E){for(let{id:d,mask:u}of E.entries){let h=Vt[d];if(!h)continue;let v=new Set(Ho(u)),C=w.get(h);if(C)for(let I of v)C.add(I);else w.set(h,v)}return w}return w}function F(i,...w){return i?w.some(b=>i.has(b)):!1}function H(i,w){let b=D(w?.listenersRaw),E=new Set;for(let[,I]of b)for(let N of I)(N==="react"||N==="vue"||N==="angular"||N==="svelte"||N==="jquery")&&E.add(N);let d=new Set;for(let[I,N]of b)if(["click","input","change","keydown","keyup","pointerdown","pointerup","mousedown","mouseup","submit","dragstart","drop","wheel","scroll"].includes(I))for(let U of N)d.add(U);let u=E.size>0||[...d].some(I=>["react","vue","angular","svelte","jquery"].includes(I)),h=F(b.get("click"),"delegated"),v=F(b.get("input"),"delegated")||F(b.get("change"),"delegated")||F(b.get("keydown"),"delegated"),C=w?.role||bo(i)||i.getAttribute("role");return{sourcesByType:b,fws:E,isFrameworkElement:u,delegatedClick:h,delegatedInput:v,role:C}}function X(i,w,b,E){let d=H(i,E),u=V(i,w),h=q(u,b);Ce(i,u,h),E?.pattern==="hover-activate"&&ut(i,u,h,E,120);let v=d.fws.has("react")||F(d.sourcesByType.get("click"),"react"),C=d.fws.has("vue")||F(d.sourcesByType.get("click"),"vue"),I=d.fws.has("angular")||F(d.sourcesByType.get("click"),"angular"),N=d.fws.has("svelte")||F(d.sourcesByType.get("click"),"svelte"),U=d.fws.has("jquery")||F(d.sourcesByType.get("click"),"jquery");return pt(()=>J(i,u,h),()=>Z(i,u,h),()=>v?K(i,u,h):null,()=>C?fe(i,u,h):null,()=>I?ee(i,u,h):null,()=>N?pe(i,u,h):null,()=>U?se(i,u,h):null)}function J(i,w,b){let E=V(i,w),d=q(E,b),u=d.PointerEvent||PointerEvent,h=d.MouseEvent||MouseEvent,{x:v,y:C}=ie(i,E,d),I={bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:v,clientY:C,button:0,buttons:1};return i.focus?.({preventScroll:!0}),[new u("pointerover",I),new u("pointerenter",{...I,bubbles:!1}),new h("mouseover",I),new h("mouseenter",{...I,bubbles:!1}),new u("pointerdown",I),new h("mousedown",I),new u("pointerup",{...I,buttons:0}),new h("mouseup",{...I,buttons:0}),new h("click",{...I,buttons:0})].forEach(U=>i.dispatchEvent(U)),{success:!0,method:"pointer-mouse-click"}}function Z(i,w,b){let E=V(i,w),d=q(E,b);try{if(i instanceof HTMLAnchorElement){let u=i.getAttribute("target");try{i.setAttribute("target","_self"),i.click()}finally{u===null?i.removeAttribute("target"):i.setAttribute("target",u)}}else i.click?.();return{success:!0,method:"native-click"}}catch{return{success:!1,method:"native-click"}}}function ie(i,w,b){let E=V(i,w),d=i.getBoundingClientRect(),u=[{x:d.left+d.width/2,y:d.top+d.height/2},{x:d.left+4,y:d.top+4},{x:d.right-4,y:d.top+4},{x:d.left+4,y:d.bottom-4},{x:d.right-4,y:d.bottom-4}],h=null;for(let v=0;v<u.length;v++){let C=u[v],I=E.elementFromPoint(C.x,C.y);if(v===0&&(h=I),I&&pa(i,I))return{...C,hit:I,ok:!0}}return{...u[0],hit:h,ok:!1}}function K(i,w,b){let E=V(i,w),d=q(E,b);try{let u=En(i);if(!u)return{success:!1,method:"react-no-fiber"};let h=wn(u),v=h.onClick||h.onClickCapture;return v?(v(Wt("click",i,E,d)),{success:!0,method:"react-fiber-onClick"}):{success:!1,method:"react-no-onClick"}}catch{return{success:!1,method:"react-fiber-onClick"}}}function fe(i,w,b){let E=V(i,w),u=q(E,b).MouseEvent||MouseEvent;try{let h=io(i);if(!h)return{success:!1,method:"vue-none"};let v=ao(h);return v.click?(v.click(new u("click",{bubbles:!0})),{success:!0,method:"vue-handler"}):h.$emit?(h.$emit("click"),{success:!0,method:"vue-emit"}):{success:!1,method:"vue-no-click"}}catch{return{success:!1,method:"vue-handler"}}}function ee(i,w,b){let E=V(i,w),d=q(E,b),u=d.MouseEvent||MouseEvent;try{let h=d.ng?.getZone?.()||null;return h?.run?(h.run(()=>i.dispatchEvent(new u("click",{bubbles:!0,cancelable:!0}))),{success:!0,method:"angular-zone-click"}):(i.dispatchEvent(new u("click",{bubbles:!0,cancelable:!0})),i.click?.(),{success:!0,method:"angular-click"})}catch{return{success:!1,method:"angular-click",allowFallback:!0}}}function pe(i,w,b){let E=V(i,w),u=q(E,b).MouseEvent||MouseEvent;try{let h=i.getBoundingClientRect(),v={bubbles:!0,cancelable:!0,view:i.ownerDocument?.defaultView||window,clientX:h.left+h.width/2,clientY:h.top+h.height/2};return i.dispatchEvent(new u("mousedown",v)),i.dispatchEvent(new u("mouseup",v)),i.dispatchEvent(new u("click",v)),{success:!0,method:"svelte-click"}}catch{return{success:!1,method:"svelte-click"}}}function se(i,w,b){let E=V(i,w),d=q(E,b);try{return d.jQuery?.(i)?.trigger?.("click"),{success:!0,method:"jquery-trigger"}}catch{return{success:!1,method:"jquery-trigger"}}}async function ut(i,w,b,E,d=500){let u=V(i,w),h=q(u,b),v=H(i,E);Ce(i,u,h);let C=h.PointerEvent||PointerEvent,I=h.MouseEvent||MouseEvent,N=i.getBoundingClientRect(),U=N.left+N.width/2,$=N.top+N.height/2;if(v.fws.has("react")){let me=En(i),oe=me?wn(me):{};oe.onMouseEnter?.(Wt("mouseenter",i,u,h)),oe.onPointerEnter?.(Wt("pointerenter",i,u,h))}else if(v.fws.has("vue")){let me=io(i),oe=me?ao(me):{};oe.mouseenter?.(new I("mouseenter",{bubbles:!0})),oe.mouseover?.(new I("mouseover",{bubbles:!0}))}let z={bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:U,clientY:$};return[new C("pointerover",z),new C("pointerenter",{...z,bubbles:!1}),new I("mouseover",z),new I("mouseenter",{...z,bubbles:!1})].forEach(me=>i.dispatchEvent(me)),await et(d,u),{success:!0,method:"hover-seq"}}async function xe(i,w,b=1){await Promise.resolve();for(let E=0;E<b;E++)i.hidden?await Lt():await new Promise(d=>{try{w.requestAnimationFrame(()=>d())}catch{Lt().then(d)}})}let Oe=i=>String(i??"").replace(/\s+/g," ").trim();function Ke(i){try{if("value"in i)return String(i.value??"")}catch{}return""}function Qe(i){try{return typeof Cn=="function"?Cn(i):Oe(i.textContent)}catch{return""}}function dt(i,w){if(!(w.isFrameworkElement||w.delegatedInput))return!1;let b=String(i??"").length;return b>0&&b<=140}async function xt(i,w,b,E,d){let u=H(i,d),h=V(i,w),v=q(h,b);if(Ce(i,h,v),Rt(i,v)||It(i,v)){let I=dt(String(E??""),u),N=await la(i,h,v,E,{settleFrames:h.hidden?1:2,useKeyFallback:I,keyFallbackMaxLen:140});return{success:N.success,method:N.method,details:N.details,allowFallback:!N.success}}if(i.isContentEditable===!0||u.role==="textbox"&&!("value"in i)){let I=Qe(i),N=ua(i,E,h,v);await xe(h,v,h.hidden?1:2);let U=Qe(i),$=!1;if(String(E??"").length>0&&U===I){$=!0;try{jn(i,h,v),Xn(i,h,v,!0);try{h.execCommand?.("insertText",!1,String(E??""))}catch{}Mn(i,String(E??""),"insertText")}catch{}await xe(h,v,h.hidden?1:2)}let z=Qe(i),ne=z!==I||!!String(E??"")&&z.includes(String(E??""));return{success:ne,method:N.method,details:`${N.details};beforeLen=${I.length};afterLen=${z.length};reverted=${U===I};fallback=${$}`,allowFallback:ne?void 0:!0}}return{success:!1,method:"type",details:"target not editable",allowFallback:!0}}async function ft(i,w,b,E,d){let u=V(i,w),h=q(u,b),v=await xt(i,u,h,E,d);if(!v.success)return v;let C=da(i);return{success:!0,method:"type+enter",details:`${v.details};enter=${C.method}`}}async function vt(i,w,b,E){let d=V(i,w),u=q(d,b),h=u.Event||Event;if(Ce(i,d,u),Rt(i,u)||It(i,u)){let C=Ke(i),I=fa(i,d,u);if(await xe(d,u,d.hidden?1:2),Ke(i)===C&&C.length>0){try{Ro(i,""),Mn(i,"","deleteByCut")}catch{}await xe(d,u,d.hidden?1:2)}let $=Ke(i),z=$.length===0||$!==C;return{success:I.success,method:I.method,details:I.details,allowFallback:!I.success}}if(i.isContentEditable===!0||H(i,E).role==="textbox"&&!("value"in i)){let C=ha(i,d,u);return await xe(d,u,d.hidden?1:2),{success:C.success,method:C.method,details:C.details,allowFallback:!C.success}}if("value"in i){try{i.value=""}catch{}return i.dispatchEvent(new h("input",{bubbles:!0,composed:!0})),i.dispatchEvent(new h("change",{bubbles:!0,composed:!0})),{success:!0,method:"clear-generic-value"}}return{success:!1,method:"clear",details:"target not clearable",allowFallback:!0}}function st(i,w,b){try{let E=V(i,w),d=q(E,b),u=d.FocusEvent||FocusEvent;return Ce(i,E,d),i.focus?.({preventScroll:!0}),i.dispatchEvent(new u("focus",{bubbles:!0})),i.dispatchEvent(new u("focusin",{bubbles:!0})),{success:!0,method:"focus"}}catch(E){return{success:!1,method:"focus",details:E.message,allowFallback:!0}}}function ve(i,w,b,E,d){try{let u=V(i,w),h=q(u,b),v=h.Event||Event;if(!si(i,h))return{success:!1,method:"select",details:"target not select",allowFallback:!0};Ce(i,u,h),i.focus?.({preventScroll:!0});let C=Array.from(i.options).find($=>$.value===E||$.text.trim()===E.trim());if(!C)return{success:!1,method:"select",details:`Option not found: ${E}`,allowFallback:!0};C.selected=!0;let I=Object.getPrototypeOf(i),N=Object.getOwnPropertyDescriptor(I,"value");if(N?.set?N.set.call(i,C.value):i.value=C.value,i.dispatchEvent(new v("input",{bubbles:!0,composed:!0})),i.dispatchEvent(new v("change",{bubbles:!0,composed:!0})),H(i,d).fws.has("react")){let $=En(i);if($){let z=wn($);if(z.onChange){let ne=Wt("change",i,u,h);ne.target.value=C.value,z.onChange(ne)}}}return{success:!0,method:"select"}}catch(u){return{success:!1,method:"select",details:u.message,allowFallback:!0}}}function Ft(i,w,b,E,d){try{let u=V(i,w),h=q(u,b),v=h.Event||Event;if(!Rt(i,h))return{success:!1,method:"slider",details:"target not input",allowFallback:!0};Ce(i,u,h),i.focus?.({preventScroll:!0});let C=Object.getPrototypeOf(i),I=Object.getOwnPropertyDescriptor(C,"value");if(I?.set?I.set.call(i,String(E)):i.value=String(E),i.dispatchEvent(new v("input",{bubbles:!0,composed:!0})),i.dispatchEvent(new v("change",{bubbles:!0,composed:!0})),H(i,d).fws.has("react")){let U=En(i);if(U){let $=wn(U);if($.onChange){let z=Wt("change",i,u,h);z.target.value=String(E),$.onChange(z)}}}return{success:!0,method:"slider"}}catch(u){return{success:!1,method:"slider",details:u.message,allowFallback:!0}}}function Oo(i,w,b){try{let E=i.checkValidity?.()??!0;return E||i.reportValidity?.(),{success:E,method:"check-validity",details:E?void 0:i.validationMessage}}catch(E){return{success:!1,method:"check-validity",details:E.message,allowFallback:!0}}}function Hn(i,w,b,E,d){try{let u=V(i,w),h=q(u,b);if("setSelectionRange"in i){let I=i;I.focus?.();let N=I.value?.length??0;return I.setSelectionRange(E??0,d??N),{success:!0,method:"select-range"}}let v=h.getSelection();if(!v)return{success:!1,method:"select-range",allowFallback:!0};let C=u.createRange();return C.selectNodeContents(i),v.removeAllRanges(),v.addRange(C),{success:!0,method:"select-range-node"}}catch(u){return{success:!1,method:"select-range",details:u.message,allowFallback:!0}}}function Ht(i,w,b,E,d){let u=Nn((i&&V(i))??w),h=i||u,v=V(h,w),C=q(v,b),I=h===v.documentElement||h===v.body||h===u;if(E===Fe.TOP||E===Fe.BOTTOM){let N=h.scrollHeight,U=I?C.innerHeight:h.clientHeight,$=Math.max(0,N-U);return h.scrollTop=E===Fe.TOP?0:$,{success:!0,scrollTop:h.scrollTop}}return hr(h,v,C,E,d)}async function Kt(i,w,b,E){let d=E.direction,u=E.amount,h=V(i,w),v=q(h,b),C=!h.hidden,I=C?"smooth":"auto";try{if(i){let U=Pt(i,h,v),$=Ht(U,h,v,d,u);return $?.success?{success:!0,method:"direct-element-scroll",details:JSON.stringify($)}:{success:!1,method:"direct-element-scroll",details:$?.error||"direct scroll failed",allowFallback:!0}}if(d===Fe.TOP||d===Fe.BOTTOM){let U=await P(v,{action:"scrollTo",direction:d,options:{behavior:I,isTabActive:C}},{doc:h,timeoutMs:h.hidden?5200:2800});return{success:!0,method:"detector-scrollTo",details:JSON.stringify(U)}}let N=await P(v,{action:"scrollBy",direction:d,options:{amount:u,behavior:I,isTabActive:C}},{doc:h,timeoutMs:h.hidden?5200:2800});return{success:!0,method:"detector-scrollBy",details:JSON.stringify(N)}}catch(N){let U=h?Ht(Nn(h),h,v,d,u):void 0;return U?.success?{success:!0,method:"direct-primary-scroll-fallback",details:JSON.stringify(U)}:{success:!1,method:"scroll-page-failed",details:N?.message||U?.error||"scroll_page failed",allowFallback:!0}}}async function oo(i,w,b,E){let d=V(i,w),u=q(d,b),h=!d.hidden,v=h?"smooth":"auto",C=Ra(E.position),I=Jn(i,d);if(!I){let N=xs(i,d,u,C);return{success:N.success,method:"direct-scrollElement-no-selector",details:N.error,allowFallback:!N.success}}try{let N=await P(u,{action:"scrollElement",selector:I,position:C,options:{behavior:v,isTabActive:h}},{doc:d,timeoutMs:d.hidden?5600:3e3});return{success:!0,method:"detector-scrollElement",details:JSON.stringify(N)}}catch(N){let U=xs(i,d,u,C);return U.success?{success:!0,method:"direct-scrollElement-fallback",details:JSON.stringify(U)}:{success:!1,method:"scroll-to-element-failed",details:N?.message||U.error||"scroll_to_element failed",allowFallback:!0}}}function ht(i,w,b,E,d){try{let u=V(i,w),h=q(u,b),v=h.WheelEvent||WheelEvent;Ce(i,u,h);let C=Pt(i,u,h);return C.dispatchEvent(new v("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:h,deltaX:E||0,deltaY:d||0,deltaMode:v.DOM_DELTA_PIXEL})),C.scrollBy({left:E||0,top:d||0,behavior:"auto"}),{success:!0,method:"wheel"}}catch(u){return{success:!1,method:"wheel",details:u.message,allowFallback:!0}}}function Pt(i,w,b){let E=V(i,w),d=q(E,b),u=E.scrollingElement||E.documentElement||E.body,h=i;for(;h&&h!==E.body&&h!==E.documentElement;){let C=d.getComputedStyle(h).overflowY;if((C==="auto"||C==="scroll"||C==="overlay")&&h.scrollHeight>h.clientHeight+5)return h;h=h.parentElement}return u}async function un(i,w,b,E,d){try{let u=V(i,w),h=q(u,b),v=h.PointerEvent||PointerEvent,C=h.MouseEvent||MouseEvent,I=h.DragEvent||DragEvent,N=h.DataTransfer||DataTransfer;Ce(i,u,h);let U=ie(i,u,h),$=Ve(U.hit,h)?U.hit:i,z=i.getBoundingClientRect(),ne=Number.isFinite(Number(E?.distance))?Number(E.distance):160,me=0,oe=0;switch(String(E?.direction||"").toUpperCase()){case"UP":oe=-ne;break;case"DOWN":oe=ne;break;case"LEFT":me=-ne;break;case"RIGHT":me=ne;break;default:me=Number(E?.delta_x)||0,oe=Number(E?.delta_y)||0}let ae=(y,k)=>({x:Math.max(2,Math.min(y,h.innerWidth-3)),y:Math.max(2,Math.min(k,h.innerHeight-3))}),le=ae(U.x,U.y),ke=ae(U.x+me,U.y+oe),qe=500+Date.now()%1e4,ge=Math.max(12,Math.min(36,Number(E?.steps)||18)),_e=(y,k)=>({bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:y,clientY:k,pageX:y+(h.scrollX||0),pageY:k+(h.scrollY||0)}),ye=(y,k,O)=>({..._e(y,k),pointerId:qe,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:O?.5:0,buttons:O,button:0}),Ie=(y,k,O)=>({..._e(y,k),buttons:O,button:0});$.dispatchEvent(new v("pointerdown",ye(le.x,le.y,1))),$.dispatchEvent(new C("mousedown",Ie(le.x,le.y,1)));try{$.setPointerCapture?.(qe)}catch{}let a=null;try{(i.draggable||H(i,d).sourcesByType.has("dragstart"))&&(a=new N)}catch{a=null}if(a)try{i.dispatchEvent(new I("dragstart",{bubbles:!0,cancelable:!0,clientX:le.x,clientY:le.y,dataTransfer:a}))}catch{}let m=null;for(let y=1;y<=ge;y++){let k=le.x+(ke.x-le.x)*y/ge,O=le.y+(ke.y-le.y)*y/ge,Y=u.elementFromPoint(k,O)||i;if(Y.dispatchEvent(new v("pointermove",ye(k,O,1))),Y.dispatchEvent(new C("mousemove",Ie(k,O,1))),a)try{m&&m!==Y&&m.dispatchEvent(new I("dragleave",{bubbles:!0,cancelable:!0,clientX:k,clientY:O,dataTransfer:a})),Y.dispatchEvent(new I("dragover",{bubbles:!0,cancelable:!0,clientX:k,clientY:O,dataTransfer:a})),m=Y}catch{}y%3===0&&await Lt()}let g=u.elementFromPoint(ke.x,ke.y)||i;if(g.dispatchEvent(new v("pointerup",ye(ke.x,ke.y,0))),g.dispatchEvent(new C("mouseup",Ie(ke.x,ke.y,0))),a)try{i.dispatchEvent(new I("dragend",{bubbles:!0,cancelable:!0,clientX:ke.x,clientY:ke.y,dataTransfer:a}))}catch{}return{success:!0,method:"drag",details:`dx=${me};dy=${oe};steps=${ge};hitOk=${U.ok}`}}catch(u){return{success:!1,method:"drag",details:u?.message||"drag failed",allowFallback:!0}}}async function Bt(i,w,b,E){try{let d=V(w,b),u=q(d,E),h=u.PointerEvent||PointerEvent,v=u.MouseEvent||MouseEvent,C=u.DragEvent||DragEvent,I=u.DataTransfer||DataTransfer,N=i?.source_element_id??i?.element_id,U=(N?Ct(d,String(N)):null)||w;if(!U)return{success:!1,method:"drag-drop",details:"source missing",allowFallback:!0};let $=null,z=Number(i?.target_x),ne=Number(i?.target_y);if(i?.target_element_id){if($=Ct(d,String(i.target_element_id)),!$)return{success:!1,method:"drag-drop",details:"target missing",allowFallback:!0};let g=$.getBoundingClientRect();z=g.left+g.width/2,ne=g.top+g.height/2}if((!Number.isFinite(z)||!Number.isFinite(ne))&&!$)return{success:!1,method:"drag-drop",details:"missing target coords",allowFallback:!0};Ce(U,d,u),$&&Ce($,d,u);let me=(g,y)=>({x:Math.max(2,Math.min(g,u.innerWidth-3)),y:Math.max(2,Math.min(y,u.innerHeight-3))}),oe=U.getBoundingClientRect(),ae=me(oe.left+oe.width/2,oe.top+oe.height/2),le=me(Number(z),Number(ne)),ke=600+Date.now()%1e4,qe=Math.max(14,Math.min(42,Number(i?.steps)||22)),ge=(g,y)=>({bubbles:!0,cancelable:!0,composed:!0,view:u,clientX:g,clientY:y,pageX:g+(u.scrollX||0),pageY:y+(u.scrollY||0)}),_e=(g,y,k)=>({...ge(g,y),pointerId:ke,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:k?.5:0,buttons:k,button:0}),ye=(g,y,k)=>({...ge(g,y),buttons:k,button:0}),Ie=null;try{Ie=new I}catch{Ie=null}U.dispatchEvent(new h("pointerdown",_e(ae.x,ae.y,1))),U.dispatchEvent(new v("mousedown",ye(ae.x,ae.y,1)));try{U.setPointerCapture?.(ke)}catch{}if(Ie)try{U.dispatchEvent(new C("dragstart",{bubbles:!0,cancelable:!0,clientX:ae.x,clientY:ae.y,dataTransfer:Ie}))}catch{}let a=null;for(let g=1;g<=qe;g++){let y=ae.x+(le.x-ae.x)*g/qe,k=ae.y+(le.y-ae.y)*g/qe,O=d.elementFromPoint(y,k)||$||d.body;if(O.dispatchEvent(new h("pointermove",_e(y,k,1))),O.dispatchEvent(new v("mousemove",ye(y,k,1))),Ie)try{a&&a!==O&&a.dispatchEvent(new C("dragleave",{bubbles:!0,cancelable:!0,clientX:y,clientY:k,dataTransfer:Ie})),O.dispatchEvent(new C("dragenter",{bubbles:!0,cancelable:!0,clientX:y,clientY:k,dataTransfer:Ie})),O.dispatchEvent(new C("dragover",{bubbles:!0,cancelable:!0,clientX:y,clientY:k,dataTransfer:Ie})),a=O}catch{}g%3===0&&await Lt()}let m=$||d.elementFromPoint(le.x,le.y)||d.body;if(Ie)try{m.dispatchEvent(new C("drop",{bubbles:!0,cancelable:!0,clientX:le.x,clientY:le.y,dataTransfer:Ie}))}catch{}if(m.dispatchEvent(new h("pointerup",_e(le.x,le.y,0))),m.dispatchEvent(new v("mouseup",ye(le.x,le.y,0))),Ie)try{U.dispatchEvent(new C("dragend",{bubbles:!0,cancelable:!0,clientX:le.x,clientY:le.y,dataTransfer:Ie}))}catch{}return{success:!0,method:"html5+pointer-dragdrop",details:`steps=${qe};source=${String(N)}`}}catch(d){return{success:!1,method:"drag-drop",details:d?.message||"drag-drop failed",allowFallback:!0}}}async function dn(i,w,b,E){try{let d=V(i,w),u=q(d,b),h=u.PointerEvent||PointerEvent,v=u.MouseEvent||MouseEvent;Ce(i,d,u);let C=ie(i,d,u),I={x:C.x,y:C.y},N=i.getBoundingClientRect(),U=Number.isFinite(Number(E?.distance))?Number(E.distance):Math.min(Math.max(80,Math.min(N.width,N.height)),220),$=String(E?.direction||"RIGHT").toUpperCase(),z=I.x,ne=I.y;$==="LEFT"&&(z-=U),$==="RIGHT"&&(z+=U),$==="UP"&&(ne-=U),$==="DOWN"&&(ne+=U);let me=(y,k)=>({x:Math.max(2,Math.min(y,u.innerWidth-3)),y:Math.max(2,Math.min(k,u.innerHeight-3))}),oe=me(I.x,I.y),ae=me(z,ne),le=700+Date.now()%1e4,ke=Math.max(10,Math.min(28,Number(E?.steps)||16)),qe=(y,k)=>({bubbles:!0,cancelable:!0,composed:!0,view:u,clientX:y,clientY:k,pageX:y+(u.scrollX||0),pageY:k+(u.scrollY||0)}),ge=(y,k,O)=>({...qe(y,k),pointerId:le,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:O?.5:0,buttons:O,button:0}),_e=(y,k,O)=>({...qe(y,k),buttons:O,button:0}),ye=d.elementFromPoint(oe.x,oe.y)||i;ye.dispatchEvent(new h("pointerdown",ge(oe.x,oe.y,1))),ye.dispatchEvent(new v("mousedown",_e(oe.x,oe.y,1)));let Ie=u.Touch,a=u.TouchEvent,m=!!Ie&&!!a;if(m)try{let y=new Ie({identifier:le,target:ye,clientX:oe.x,clientY:oe.y,pageX:oe.x,pageY:oe.y,screenX:oe.x,screenY:oe.y,radiusX:1,radiusY:1,rotationAngle:0,force:1});ye.dispatchEvent(new a("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[y],targetTouches:[y],changedTouches:[y]}))}catch{}for(let y=1;y<=ke;y++){let k=oe.x+(ae.x-oe.x)*y/ke,O=oe.y+(ae.y-oe.y)*y/ke,Y=d.elementFromPoint(k,O)||i;if(Y.dispatchEvent(new h("pointermove",ge(k,O,1))),Y.dispatchEvent(new v("mousemove",_e(k,O,1))),m)try{let Q=new Ie({identifier:le,target:Y,clientX:k,clientY:O,pageX:k,pageY:O,screenX:k,screenY:O,radiusX:1,radiusY:1,rotationAngle:0,force:1});Y.dispatchEvent(new a("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[Q],targetTouches:[Q],changedTouches:[Q]}))}catch{}y%3===0&&await Lt()}let g=d.elementFromPoint(ae.x,ae.y)||i;if(g.dispatchEvent(new h("pointerup",ge(ae.x,ae.y,0))),g.dispatchEvent(new v("mouseup",_e(ae.x,ae.y,0))),m)try{let y=new Ie({identifier:le,target:g,clientX:ae.x,clientY:ae.y,pageX:ae.x,pageY:ae.y,screenX:ae.x,screenY:ae.y,radiusX:1,radiusY:1,rotationAngle:0,force:0});g.dispatchEvent(new a("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[y]}))}catch{}return{success:!0,method:"swipe",details:`dir=${$};dist=${U};steps=${ke};hitOk=${C.ok}`}}catch(d){return{success:!1,method:"swipe",details:d?.message||"swipe failed",allowFallback:!0}}}async function Be(i,w,b,E){try{let d=i||w.body,u=V(d,w),h=q(u,b),v=h.PointerEvent||PointerEvent,C=h.WheelEvent||WheelEvent;Ce(d,u,h);let I=Number.isFinite(Number(E?.scale))?Number(E.scale):1.2,N=d.getBoundingClientRect(),U=N.left+N.width/2,$=N.top+N.height/2,z=24,ne=Math.max(6,Math.min(200,z*I)),me=Math.max(6,Math.min(18,Number(E?.steps)||10)),oe=h.Touch,ae=h.TouchEvent;if(!!oe&&!!ae)try{let ge=(m,g)=>new oe({identifier:m,target:d,clientX:g,clientY:$,pageX:g,pageY:$,screenX:g,screenY:$,radiusX:1,radiusY:1,rotationAngle:0,force:1}),_e=ge(911,U-z),ye=ge(912,U+z);d.dispatchEvent(new ae("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[_e,ye],targetTouches:[_e,ye],changedTouches:[_e,ye]}));for(let m=1;m<=me;m++){let g=z+(ne-z)*m/me,y=ge(911,U-g),k=ge(912,U+g);d.dispatchEvent(new ae("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[y,k],targetTouches:[y,k],changedTouches:[y,k]})),m%2===0&&await Lt()}let Ie=ge(911,U-ne),a=ge(912,U+ne);d.dispatchEvent(new ae("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[Ie,a]}))}catch{}try{let ge=(_e,ye,Ie)=>({bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:ye,clientY:$,pointerId:_e,pointerType:"touch",isPrimary:_e===821,width:1,height:1,pressure:Ie?.5:0,buttons:Ie,button:0});d.dispatchEvent(new v("pointerdown",ge(821,U-z,1))),d.dispatchEvent(new v("pointerdown",ge(822,U+z,1)));for(let _e=1;_e<=me;_e++){let ye=z+(ne-z)*_e/me;d.dispatchEvent(new v("pointermove",ge(821,U-ye,1))),d.dispatchEvent(new v("pointermove",ge(822,U+ye,1))),_e%2===0&&await Lt()}d.dispatchEvent(new v("pointerup",ge(821,U-ne,0))),d.dispatchEvent(new v("pointerup",ge(822,U+ne,0)))}catch{}try{let ke=I>=1?-120:120;d.dispatchEvent(new C("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:U,clientY:$,ctrlKey:!0,deltaY:ke,deltaMode:C.DOM_DELTA_PIXEL}))}catch{}return{success:!0,method:"pinch-zoom",details:`scale=${I};steps=${me}`}}catch(d){return{success:!1,method:"pinch-zoom",details:d?.message||"pinch-zoom failed",allowFallback:!0}}}async function ro(i,w,b,E=800){try{let d=V(i,w),u=q(d,b),h=u.PointerEvent||PointerEvent,v=u.MouseEvent||MouseEvent,C=u.FocusEvent||FocusEvent;Ce(i,d,u);let I=ie(i,d,u),N=i;!I.ok&&Ve(I.hit,u)?N=I.hit.closest?.('a,button,input,select,textarea,summary,[role="button"],[role="link"],[onclick]')||I.hit:Ve(I.hit,u)&&(N=I.hit);let U=B(N,d,u),$=I.x,z=I.y,ne=1+Date.now()%1e4,me={bubbles:!0,cancelable:!0,composed:!0,view:u,clientX:$,clientY:z,pageX:$+(u.scrollX||0),pageY:z+(u.scrollY||0),screenX:$+(u.screenX||0),screenY:z+(u.screenY||0)},oe={...me,pointerId:ne,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:0,buttons:0,button:0};try{N.dispatchEvent(new h("pointerover",oe)),N.dispatchEvent(new h("pointerenter",{...oe,bubbles:!1}))}catch{}try{N.dispatchEvent(new v("mouseover",me)),N.dispatchEvent(new v("mouseenter",{...me,bubbles:!1}))}catch{}try{N.focus?.({preventScroll:!0}),N.dispatchEvent(new C("focus",{bubbles:!0,composed:!0})),N.dispatchEvent(new C("focusin",{bubbles:!0,composed:!0}))}catch{}try{N.dispatchEvent(new h("pointerdown",{...oe,buttons:1,pressure:.5}))}catch{}try{N.dispatchEvent(new v("mousedown",{...me,buttons:1,button:0}))}catch{}try{let ge=u.Touch,_e=u.TouchEvent;if(typeof ge<"u"&&typeof _e<"u"){let ye=new ge({identifier:ne,target:N,clientX:$,clientY:z,pageX:$+(u.scrollX||0),pageY:z+(u.scrollY||0),screenX:$+(u.screenX||0),screenY:z+(u.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:1});N.dispatchEvent(new _e("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[ye],targetTouches:[ye],changedTouches:[ye]}))}}catch{}let ae=Number(E),le=Number.isFinite(ae)&&ae>0?ae:800,ke=d.hidden?Math.max(le,1200):le;await et(ke,d);try{N.dispatchEvent(new v("contextmenu",{...me,button:2,buttons:2}))}catch{}try{N.dispatchEvent(new h("pointerup",{...oe,buttons:0,pressure:0}))}catch{}try{N.dispatchEvent(new v("mouseup",{...me,buttons:0,button:0}))}catch{}try{let ge=u.Touch,_e=u.TouchEvent;if(typeof ge<"u"&&typeof _e<"u"){let ye=new ge({identifier:ne,target:N,clientX:$,clientY:z,pageX:$+(u.scrollX||0),pageY:z+(u.scrollY||0),screenX:$+(u.screenX||0),screenY:z+(u.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:0});N.dispatchEvent(new _e("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[ye]}))}}catch{}let qe=await Ee(N,d,u,U);return{success:!0,method:"long-press",details:`holdMs=${ke};verified=${qe};hitOk=${I.ok};target=${N.tagName.toLowerCase()}`}}catch(d){return{success:!1,method:"long-press",details:d?.message||"long-press failed",allowFallback:!0}}}function Qt(i,w,b,E,d){try{let u=V(b,E),v=q(u,d).KeyboardEvent||KeyboardEvent,C=b||u.activeElement||u.body||u.documentElement;C.focus?.();let I={key:i,code:gn(i),bubbles:!0,cancelable:!0,ctrlKey:w?.includes("CTRL"),altKey:w?.includes("ALT"),shiftKey:w?.includes("SHIFT"),metaKey:w?.includes("META")},N=C.dispatchEvent(new v("keydown",I)),U=C.dispatchEvent(new v("keypress",I)),$=C.dispatchEvent(new v("keyup",I));if(i==="Enter"&&!!(N&&U&&$)){let ne=C.form||C.closest?.("form");ne?.requestSubmit?ne.requestSubmit():ne?.submit?.()}return{success:!0,method:"press-key"}}catch(u){return{success:!1,method:"press-key",details:u.message,allowFallback:!0}}}async function fn(i,w,b){try{let E=i.innerText||i.value||"";if(!E)return{success:!1,method:"copy",details:"nothing to copy",allowFallback:!0};let d=V(i,w),u=q(d,b);if(u.navigator?.clipboard?.writeText)return await u.navigator.clipboard.writeText(E),{success:!0,method:"clipboard-copy"};let h=d.createRange();h.selectNodeContents(i);let v=u.getSelection?.()||(d.defaultView||window).getSelection?.();v?.removeAllRanges(),v?.addRange(h);let C=d.execCommand?.("copy")??!1;return v?.removeAllRanges(),{success:!!C,method:"execCommand-copy",allowFallback:!C}}catch(E){return{success:!1,method:"clipboard-copy",details:E.message,allowFallback:!0}}}async function Jt(i,w,b,E){try{i.focus?.();let d=V(i,w),u=q(d,b);if(u.navigator?.clipboard?.readText){let v=await u.navigator.clipboard.readText();if(v)return await xt(i,d,u,v,E)}return d.execCommand?.("paste")??!1?{success:!0,method:"execCommand-paste"}:{success:!1,method:"paste",details:"clipboard empty or denied",allowFallback:!0}}catch(d){return{success:!1,method:"paste",details:d.message,allowFallback:!0}}}function so(i){return`${(i/1024).toFixed(1)}KB`}function kt(i,w){if(i instanceof w.defaultView.HTMLInputElement){let h=i;if((h.type||"").toLowerCase()==="file")return h}let b=i.closest?.("label"),E=b?.htmlFor||i.htmlFor||"";if(E){let h=w.getElementById(E);if(h&&(h.type||"").toLowerCase()==="file")return h}if(b){let h=b.querySelector?.('input[type="file"]');if(h)return h}let d=i.closest?.("form");if(d){let h=d.querySelector?.('input[type="file"]');if(h)return h}let u=i.closest?.("div,section,main,article")||i.parentElement;if(u){let h=u.querySelector?.('input[type="file"]');if(h)return h}return null}function hn(i,w,b){try{let E=b.HTMLInputElement?.prototype,d=E?Object.getOwnPropertyDescriptor(E,"files")?.set:void 0;if(!d){let u=Object.getPrototypeOf(i);for(;u&&!d;)d=Object.getOwnPropertyDescriptor(u,"files")?.set,u=Object.getPrototypeOf(u)}return d?(d.call(i,w),!0):(i.files=w,!0)}catch{try{return i.files=w,!0}catch{return!1}}}async function Zt(i,w,b,E,d,u){try{let{file_url:h,element_id:v,file_name:C}=i,I=null;if(d&&(I=kt(d,w)),!I&&v!==void 0&&(I=w.querySelector(`input[type="file"][${nt}*="[id=${v}]"]`)),!I){let g=w.querySelectorAll('input[type="file"]');for(let y of g){if(y.disabled)continue;let k=y.getBoundingClientRect();if(k.width>0&&k.height>0){I=y;break}}}if(!I)return{success:!1,method:"upload-file",details:"No file input found",allowFallback:!0};if(I.disabled)return{success:!1,method:"upload-file",details:"File input is disabled",allowFallback:!0};let N=V(I,w),U=q(N,b);if(!(E?.kind==="upload_file"&&typeof E.byteLength=="number"&&E.byteLength>=0&&typeof E.mimeType=="string"&&(typeof E.inlineB64=="string"||typeof E.token=="string")))return{success:!1,method:"upload-file",details:"Missing upload payload (need inlineB64 or token)",allowFallback:!0};let z=Number(E.byteLength),ne=(E.mimeType||"application/octet-stream").split(";")[0].trim()||"application/octet-stream",me;if(E.inlineB64&&typeof E.inlineB64=="string"){let g=Ta(E.inlineB64);if(g.byteLength!==z)return{success:!1,method:"upload-file",details:`Inline bytes length mismatch: got=${g.byteLength} expected=${z}`,allowFallback:!0};me=g.buffer}else{let g=String(E.token);me=await x(U,g,z,9e4)}let oe=U.Blob||Blob,ae=new oe([me],{type:ne}),le=C||E?.fileName;!le&&h&&typeof h=="string"&&(le=_s(h,U)),le=_a(le||"upload");let ke=U.File||File,qe=new ke([ae],le,{type:ne,lastModified:Date.now()}),ge=U.Event||Event,_e=U.DataTransfer||DataTransfer;if(!_e)return{success:!1,method:"upload-file",details:"DataTransfer unavailable in this context",allowFallback:!0};let ye=new _e;if(ye.items.add(qe),!hn(I,ye.files,U))return{success:!1,method:"upload-file",details:"Failed to set input.files",allowFallback:!0};I.dispatchEvent(new ge("input",{bubbles:!0,composed:!0,cancelable:!0})),I.dispatchEvent(new ge("change",{bubbles:!0,composed:!0,cancelable:!0}));let a=En(I);if(a){let g=wn(a);if(g.onChange){let y=Wt("change",I,N,U);y.target.files=ye.files,g.onChange(y)}}let m=io(I);if(m){let g=ao(m);if(g.change){let y=new ge("change",{bubbles:!0});y.target=I,y.target.files=ye.files,g.change(y)}}try{let g=U.jQuery||U.$;g&&typeof g=="function"&&g(I).triggerHandler?.("change")}catch{}return I.focus?.({preventScroll:!0}),await xe(N,U,2),{success:!0,method:"upload-file",details:`Uploaded ${le} (${so(ae.size)}) [token]`}}catch(h){return{success:!1,method:"upload-file",details:h?.message||"Upload failed",allowFallback:!0}}}function en(i,w,b){let E=V(i,w),d=q(E,b),u=d.MouseEvent||MouseEvent;Ce(i,E,d),J(i,E,d),J(i,E,d);let h=i.getBoundingClientRect();return i.dispatchEvent(new u("dblclick",{bubbles:!0,cancelable:!0,clientX:h.left+h.width/2,clientY:h.top+h.height/2,detail:2,view:d})),{success:!0,method:"dblclick"}}function pn(i,w,b){let E=V(i,w),d=q(E,b),u=d.PointerEvent||PointerEvent,h=d.MouseEvent||MouseEvent;Ce(i,E,d);let v=i.getBoundingClientRect(),C=v.left+v.width/2,I=v.top+v.height/2,N={bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:C,clientY:I,button:2,buttons:2};return i.dispatchEvent(new u("pointerdown",N)),i.dispatchEvent(new h("mousedown",N)),i.dispatchEvent(new u("pointerup",{...N,buttons:0})),i.dispatchEvent(new h("mouseup",{...N,buttons:0})),i.dispatchEvent(new h("contextmenu",N)),{success:!0,method:"contextmenu"}}function B(i,w,b){let E=V(i,w),d=q(E,b),u=i,h=i.getBoundingClientRect();return{href:String(d.location.href),hash:String(d.location.hash),ariaExpanded:i.getAttribute("aria-expanded"),ariaPressed:i.getAttribute("aria-pressed"),ariaDisabled:i.getAttribute("aria-disabled"),disabled:!!u.disabled,open:typeof u.open<"u"?u.open:void 0,checked:typeof u.checked<"u"?u.checked:void 0,value:typeof u.value<"u"?u.value:void 0,active:lr(E),rect:{w:h.width,h:h.height}}}function te(i,w){let b=Math.abs(i.rect.w-w.rect.w)>2||Math.abs(i.rect.h-w.rect.h)>2;return i.href!==w.href||i.hash!==w.hash||i.ariaExpanded!==w.ariaExpanded||i.ariaPressed!==w.ariaPressed||i.ariaDisabled!==w.ariaDisabled||i.disabled!==w.disabled||i.open!==w.open||i.checked!==w.checked||i.value!==w.value||i.active!==w.active||b}async function Ee(i,w,b,E){await Promise.resolve();let d=V(i,w),u=q(d,b);w.hidden||await Lt();let h=B(i,d,u);return te(E,h)}function ce(i,w,b){i.focus?.({preventScroll:!0});let E=V(i,w),d=q(E,b),v=i.getAttribute("role")==="button"||ai(i,d)||i.tagName.toLowerCase()==="button"?[" ","Enter"]:["Enter"],C=d.KeyboardEvent||KeyboardEvent;for(let I of v){let N={key:I,code:I===" "?"Space":"Enter",bubbles:!0,cancelable:!0,composed:!0};i.dispatchEvent(new C("keydown",N)),i.dispatchEvent(new C("keypress",N)),i.dispatchEvent(new C("keyup",N))}return{success:!0,method:"keyboard-activate"}}async function Ue(i,w,b,...E){let d=null;for(let u of E){let h=V(i,w),v=q(h,b),C=B(i,h,v),I=u();if(!I||!I.success)continue;if(await Ee(i,h,v,C))return{...I,details:(I.details?I.details+";":"")+"verified=true"};d=I}return d?{...d,details:(d.details?d.details+";":"")+"verified=false"}:{success:!1,method:"all-strategies-unverified",details:"no verified effect",allowFallback:!0}}function pt(...i){for(let w of i)try{let b=w();if(b&&b.success)return b}catch{}return{success:!1,method:"all-strategies-failed",allowFallback:!0}}function Ce(i,w,b){let E=V(i,w),d=q(E,b),u=i.getBoundingClientRect();u.top>=0&&u.left>=0&&u.bottom<=d.innerHeight&&u.right<=d.innerWidth||(i.scrollIntoView({behavior:"auto",block:"center",inline:"center"}),i.offsetHeight)}function mn(i,w,b,E){let d=V(i,w),h=q(d,b).KeyboardEvent||KeyboardEvent;for(let v of E){let C=String(v??""),I="";/^[a-z]$/i.test(C)?I=`Key${C.toUpperCase()}`:/^[0-9]$/.test(C)?I=`Digit${C}`:C===" "&&(I="Space");let N=C.length===1?C.charCodeAt(0):0,U={key:C,code:I,bubbles:!0,cancelable:!0,composed:!0,keyCode:N,which:N};i.dispatchEvent(new h("keydown",U)),i.dispatchEvent(new h("keypress",U)),i.dispatchEvent(new h("keyup",U))}}function tn(i,w,b){let E=V(i,w),u=q(E,b).KeyboardEvent||KeyboardEvent,h={key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0,composed:!0},v=i.dispatchEvent(new u("keydown",h)),C=i.dispatchEvent(new u("keypress",h)),I=i.dispatchEvent(new u("keyup",h));if(!!(v&&C&&I)){let U=i.form||i.closest?.("form");U?.requestSubmit?.()??U?.submit?.()}}function gn(i){return{Enter:"Enter",Tab:"Tab",Escape:"Escape",Space:"Space"," ":"Space",ArrowUp:"ArrowUp",ArrowDown:"ArrowDown",ArrowLeft:"ArrowLeft",ArrowRight:"ArrowRight",Backspace:"Backspace",Delete:"Delete",Home:"Home",End:"End",PageUp:"PageUp",PageDown:"PageDown",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12"}[i]||`Key${i.toUpperCase()}`}let bn=new MessageChannel,Pn=[];bn.port1.onmessage=()=>{let i=Pn.shift();i&&i()};function Lt(){return new Promise(i=>{Pn.push(i),bn.port2.postMessage(0)})}function En(i){let w=E=>{if(!E)return null;let d=Object.keys(E);for(let u of d)if(u.startsWith("__reactFiber")||u.startsWith("__reactInternalInstance")||u.includes("reactFiber")||u.includes("reactProps")||u.includes("reactEventHandlers")||/^__r\d+/.test(u))return E[u];return null},b=i;for(let E=0;E<4&&b;E++){let d=w(b);if(d)return d;b=b.parentElement}return null}function wn(i){let w={},b=i,E=0;for(;b&&E++<10;){let d=[b.memoizedProps,b.pendingProps,b.stateNode?.props,b._memoizedProps,b._pendingProps,b.alternate?.memoizedProps].filter(Boolean);for(let u of d)if(!(!u||typeof u!="object"))for(let h in u)h.startsWith("on")&&typeof u[h]=="function"&&(w[h]=u[h]);if(Object.keys(w).length)break;b=b.return||b.alternate}return w}function zs(i,w){let b=i;for(;b;){if(b._reactRootContainer||b.__reactContainer||b.hasAttribute("data-reactroot")||b.hasAttribute("data-react-root")||["root","app","__next"].includes(b.id))return b;b=b.parentElement}return V(i,w).querySelector("#root,#app,#__next,[data-reactroot],[data-react-root]")}function Wt(i,w,b,E){let d=V(w,b),u=q(d,E),h=u.MouseEvent||MouseEvent,v=w.getBoundingClientRect(),C=new h(i,{bubbles:!0,cancelable:!0,view:u,clientX:v.left+v.width/2,clientY:v.top+v.height/2});return{type:i,target:w,currentTarget:w,bubbles:!0,cancelable:!0,nativeEvent:C,isTrusted:!0,preventDefault(){C.preventDefault()},stopPropagation(){C.stopPropagation()}}}function io(i){let w=i;if(w.__vue__)return w.__vue__;if(w.__vueParentComponent)return w.__vueParentComponent;if(w._vnode)return w._vnode;let b=i.parentElement;for(let E=0;E<3&&b;E++){let d=b;if(d.__vue__||d.__vueParentComponent||d._vnode)return d.__vue__||d.__vueParentComponent||d._vnode;b=b.parentElement}return null}function ao(i){let w={};if(i?.$listeners&&Object.assign(w,i.$listeners),i?._events)for(let b in i._events){let E=i._events[b];w[b]=Array.isArray(E)?E[0]:E}if(i?.props)for(let b in i.props)b.startsWith("on")&&typeof i.props[b]=="function"&&(w[b.substring(2).toLowerCase()]=i.props[b]);if(i?.vnode?.props)for(let b in i.vnode.props)b.startsWith("on")&&typeof i.vnode.props[b]=="function"&&(w[b.substring(2).toLowerCase()]=i.vnode.props[b]);return w}})();function Sa(){let e=window,t=e.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__";e[t]?.actions?.execute}async function ka(e){let t=window,n=t.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",r=t[n]?.actions?.execute;if(typeof r!="function")throw new Error("Rover main-world action executor not initialized");return r(e)}function pr(e,t,n={}){let{rootNodes:o,semanticNodes:r}=fs(e,{includeFrameContents:n.includeFrames??!0,clearIframes:n.includeFrames??!0,frameContextLabel:n.frameContextLabel??null,signalProvider:t.signalProvider,disableDomAnnotations:n.disableDomAnnotations??!0}),s={};for(let c of Object.keys(r)){let l=Number(c);if(!Number.isFinite(l))continue;let f=_o(l);f&&(s[l]=t.getFrameworkMetadata(f))}return{rootNodes:o,semanticNodes:r,elementMeta:s}}(()=>{let e="__rtrvr_scroll_detector",t="__RTRVR_SCROLL_API__",n="__RTRVR_INTERNAL__";if(window[e])return;class o{constructor(p=document,T=window){W(this,"doc");W(this,"win");W(this,"viewport");W(this,"lastDetectedPrimary",null);W(this,"detectionCache",new Map);W(this,"lastDetectionTime",0);W(this,"CACHE_TTL",5e3);this.doc=p,this.win=T,this.viewport={width:T.innerWidth,height:T.innerHeight},this.updateViewport()}getValidPrimary(){return this.lastDetectedPrimary&&!this.doc.contains(this.lastDetectedPrimary)&&(this.lastDetectedPrimary=null),this.lastDetectedPrimary}async handleCommand(p){switch(p.action){case"detectPrimary":{let T=this.detectPrimaryScrollable();if(!T)return null;let{target:S,isRoot:x}=this.getScrollContext(T.element),A=S.scrollHeight,L=Ot(),P=x&&L?L.innerHeight:S.clientHeight,G=Math.max(0,A-P),D=S.scrollTop;return{selector:T.selector,score:T.score,type:T.type,metrics:{scrollTop:D,scrollHeight:A,clientHeight:P,isAtTop:D<=5,isAtBottom:D>=G-5}}}case"scrollTo":if(!p.direction)throw new Error("scrollTo requires direction");return this.scrollToDirection(p.direction,p.options);case"scrollBy":if(!p.direction)throw new Error("scrollBy requires direction");return this.scrollByAmount(p.direction,p.options);case"scrollElement":if(!p.selector)throw new Error("scrollElement requires selector");return this.scrollElementIntoView(p.selector,p.position,p.options);case"getMetrics":return this.getScrollMetrics();default:throw new Error(`Unknown command: ${p.action}`)}}updateViewport(){this.viewport={width:this.win.innerWidth,height:this.win.innerHeight}}async execute(p){return this.handleCommand(p)}detectPrimaryScrollable(){if(Date.now()-this.lastDetectionTime<this.CACHE_TTL&&this.detectionCache.size>0){let x=Array.from(this.detectionCache.values()).sort((A,L)=>L.score-A.score)[0];if(x)return this.lastDetectedPrimary=x.element,x}this.updateViewport();let p=this.collectScrollableCandidates();if(p.length===0){let x=this.doc.scrollingElement||this.doc.documentElement||this.doc.body;if(!x)return null;let A=this.buildFeatures(x),L=V(x,this.doc),P={element:x,selector:Jn(x,L),score:.5,features:A,type:"document"};return this.detectionCache.clear(),this.detectionCache.set(P.selector,P),this.lastDetectionTime=Date.now(),this.lastDetectedPrimary=x,P}let T=this.scoreCandidates(p);if(T.length===0)return null;this.detectionCache.clear();for(let x of T)this.detectionCache.set(x.selector,x);this.lastDetectionTime=Date.now();let S=T[0];return S&&(this.lastDetectedPrimary=S.element),S||null}collectAllElementsDeep(p,T=15e4){let S=[],x=[],A=p.body||p.documentElement;A&&x.push(A);let L=0,P=G=>{try{let D=this.win.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",H=this.win[D]?.shadow?.getRoot;if(typeof H=="function"){let X=H(G);if(X)return X}}catch{}try{return G.shadowRoot||null}catch{return null}};for(;x.length&&!(++L>T);){let G=x.pop();if(yt(G)){let H=G.children;for(let X=H.length-1;X>=0;X--)x.push(H[X]);continue}let D=G,F=re(D);Ve(D,F)&&S.push(D);try{let H=P(D);H&&x.push(H)}catch{}for(let H=D.lastElementChild;H;H=H.previousElementSibling)x.push(H)}return S}collectScrollableCandidates(){let p=[],T=new WeakSet,S=[this.doc.scrollingElement,this.doc.documentElement,this.doc.body];for(let A of S){if(!A||T.has(A))continue;let L=this.isScrollable(A);(L.vertical||L.horizontal)&&(p.push(A),T.add(A))}let x=this.collectAllElementsDeep(this.doc);for(let A of Array.from(x)){if(T.has(A))continue;let L=A.getBoundingClientRect(),P=this.win.getComputedStyle(A);if(!this.isElementRendered(A,L,P)||!this.isScrollable(A).vertical)continue;let D=40,F=this.viewport.width*.15;if(L.height<D||L.width<F){let H=(A.className||"").toLowerCase().includes("scroll"),X=P.overflowY==="auto"||P.overflowY==="scroll"||P.overflow==="auto"||P.overflow==="scroll";if(!H&&!X)continue}p.push(A),T.add(A)}return p}isElementRendered(p,T,S){if(S.display==="none"||S.visibility==="hidden")return!1;let x=parseFloat(S.opacity||"1");return!(!Number.isNaN(x)&&x<.01||T.width<=1||T.height<=1)}isScrollable(p){let T=this.win.getComputedStyle(p),S=T.overflowY,x=T.overflowX,A=this.doc.scrollingElement,L=p===this.doc.documentElement||p===this.doc.body||!!A&&p===A,P=p.scrollHeight,G=p.clientHeight,D=p.scrollWidth,F=p.clientWidth;if(L){let ee=this.doc.documentElement,pe=this.doc.body;P=Math.max(ee?ee.scrollHeight:0,pe?pe.scrollHeight:0),G=this.win.innerHeight}let H=P-G>8,X=D-F>8,J=S==="auto"||S==="scroll"||S==="overlay",Z=x==="auto"||x==="scroll"||x==="overlay";return{vertical:L?H:H&&J,horizontal:L?X:X&&Z,byOverflow:J||Z}}calculateVisibleIntersection(p){let T=Math.max(0,p.left),S=Math.max(0,p.top),x=Math.min(this.viewport.width,p.right),A=Math.min(this.viewport.height,p.bottom),L=Math.max(0,x-T),P=Math.max(0,A-S);return{width:L,height:P,area:L*P}}analyzeTextContent(p,T=2e3){let S=0,x=0,A=p.ownerDocument||this.doc,P=(A.defaultView||this.win).NodeFilter||NodeFilter,G=A.createTreeWalker(p,P.SHOW_ELEMENT|P.SHOW_TEXT,null),D=0,F=G.currentNode,H=[];for(;F&&D<T;){if(F.nodeType===Node.TEXT_NODE){let K=(F.textContent||"").replace(/\s+/g,"").length;if(K>0){S+=K;let fe=F.parentElement;fe&&fe.closest("a")&&(x+=K)}}else F.nodeType===Node.ELEMENT_NODE&&H.push(F);D++,F=G.nextNode()}let X=H.length||1,J=S/X,Z=S>0?x/S:0;return{textChars:S,linkChars:x,textDensity:J,linkDensity:Z}}calculateRepetitionScore(p){let T=Array.from(p.children);if(T.length<3)return 0;let S=T.slice(0,50),x=new Map,A=new Map,L=new Map;for(let ie of S){let K=re(ie);if(!Ve(ie,K))continue;let fe=ie.getBoundingClientRect();if(fe.height<5||fe.width<this.viewport.width*.1)continue;let ee=Math.round(fe.height/10)*10,pe=Math.round(fe.width/10)*10;x.set(ee,(x.get(ee)||0)+1),A.set(pe,(A.get(pe)||0)+1);let se=(ie.className||ie.tagName).toString();L.set(se,(L.get(se)||0)+1)}let P=S.length||1,G=Math.max(0,...x.values()),D=Math.max(0,...A.values()),F=Math.max(0,...L.values()),H=G/P,X=D/P,J=F/P,Z=.4*H+.3*X+.3*J;return Math.min(1,Math.max(0,Z))}calculateSemanticScore(p){let T=0,S=null,x=!1,A=(p.getAttribute("role")||"").toLowerCase(),L=p.tagName.toLowerCase(),P=(p.id||"").toLowerCase(),G=(p.className||"").toLowerCase(),D=`${A} ${L} ${P} ${G}`;return(L==="main"||A==="main")&&(T+=1.2,S="article"),L==="article"&&(T+=1,S=S||"article"),(A==="feed"||D.includes("feed"))&&(T+=1,S="feed"),(A==="log"||D.includes("chat")||D.includes("messages"))&&(T+=1,S="chat"),D.includes("content")&&(T+=.5),(D.includes("results")||D.includes("list"))&&(T+=.4),(D.includes("job")||D.includes("jobs"))&&(T+=.4),(L==="nav"||A==="navigation"||D.includes("sidebar"))&&(T-=1,x=!0),(L==="aside"||A==="complementary")&&(T-=.7,x=!0),(L==="footer"||A==="contentinfo"||D.includes("footer"))&&(T-=.8,x=!0),D.includes("header")&&(T-=.6),T=Math.max(-1,Math.min(1,T)),{semanticScore:T,typeHint:S,navLike:x}}detectScrollListeners(p){return[p.querySelector('[class*="infinite"]'),p.querySelector('[class*="load-more"]'),p.querySelector("[data-infinite]"),p.querySelector('[loading="lazy"]'),p.querySelector(".observer-target"),p.querySelector("[data-scroll]")].some(S=>S!==null)}buildFeatures(p){let T=p.getBoundingClientRect(),S=this.win.getComputedStyle(p),x=this.calculateVisibleIntersection(T),A=this.viewport.width*this.viewport.height||1,L=x.area/A,P=this.viewport.width>0?x.width/this.viewport.width:0,G=T.top+T.height/2,D=this.viewport.height/2||1,F=Math.min(1,Math.abs(G-D)/D),H=this.isScrollable(p),X=this.doc.scrollingElement,J=p===this.doc.documentElement||p===this.doc.body||!!X&&p===X,Z=p.scrollHeight,ie=p.clientHeight;if(J){let Qe=this.doc.documentElement,dt=this.doc.body;Z=Math.max(Qe?Qe.scrollHeight:0,dt?dt.scrollHeight:0),ie=this.win.innerHeight}let K=Math.max(0,Z-ie),fe=K*x.width,ee=this.analyzeTextContent(p),pe=this.calculateRepetitionScore(p),se=this.calculateSemanticScore(p),ut=p.contains(this.doc.activeElement),xe=this.detectScrollListeners(p),Oe=parseInt(S.zIndex||"0",10),Ke=Number.isFinite(Oe)?Oe:0;return{geometry:{viewportCoverage:L,widthProminence:P,centerDistance:F,scrollCapacity:K,scrollSurface:fe,zIndex:Ke},content:{textDensity:ee.textDensity,linkDensity:ee.linkDensity,repetitionScore:pe,semanticScore:se.semanticScore},interaction:{hasScrollListeners:xe,hasFocus:ut,recentActivity:ut?1:0}}}inferElementType(p,T,S,x){if(S)return S;let A=(p.getAttribute("role")||"").toLowerCase(),L=(p.className||"").toLowerCase(),P=p.tagName.toLowerCase(),G=T.geometry,D=T.content;if(A==="log"||L.includes("chat")||L.includes("messages"))return"chat";let F=this.win.getComputedStyle(p);if((F.position==="fixed"||F.position==="absolute")&&G.zIndex>100&&G.viewportCoverage>.2&&G.centerDistance<.4)return"modal";if(A==="feed"||D.repetitionScore>.3&&G.scrollCapacity>400&&G.widthProminence>=.25)return"feed";if(P==="article"||D.textDensity>40&&D.linkDensity<.4&&G.widthProminence>.4)return"article";if(x||G.widthProminence<.3&&D.linkDensity>.3)return"sidebar";let X=this.doc.scrollingElement;return p===this.doc.documentElement||p===this.doc.body||X&&p===X?"document":"unknown"}scoreCandidates(p){let T=[],S=[],x=[],A=[],L=[],P=[];for(let J of p){let Z=this.buildFeatures(J),ie=Z.content.semanticScore,K=this.calculateSemanticScore(J),fe=this.inferElementType(J,Z,K.typeHint,K.navLike);P.push({element:J,features:{geometry:{...Z.geometry},content:{...Z.content,semanticScore:K.semanticScore},interaction:Z.interaction},type:fe,navLike:K.navLike,semanticScore:K.semanticScore}),S.push(Z.geometry.scrollSurface),x.push(Z.content.textDensity),A.push(Math.abs(K.semanticScore)),L.push(Z.content.repetitionScore)}let G=Math.max(0,...S),D=Math.max(0,...x),F=Math.max(0,...A),H=Math.max(0,...L),X=-1/0;for(let J of P){let{element:Z,features:ie,type:K,navLike:fe,semanticScore:ee}=J,pe=ie.geometry,se=ie.content,ut=ie.interaction,xe=G>0?pe.scrollSurface/G:0,Oe=D>0?se.textDensity/D:0,Ke=F>0?(ee/F+1)/2:.5,Qe=K==="feed"||se.repetitionScore>.3&&pe.scrollCapacity>400,dt=se.linkDensity>.5?(se.linkDensity-.5)/.5:0,xt=Qe?0:dt,ft=(Qe?1:.5)*se.repetitionScore*Math.min(1,pe.scrollCapacity/4e3),st={feed:.2,chat:.2,article:.08,modal:.08,document:.05,sidebar:-.12,unknown:0}[K]||0,ve=0;ve+=pe.viewportCoverage*.18,ve+=pe.widthProminence*.15,ve+=(1-pe.centerDistance)*.07,ve+=xe*.22,ve+=ft*.18,ve+=Oe*.08,ve+=(H>0?se.repetitionScore/H:0)*.05,ve+=Ke*.07,ve-=xt*.05,ut.hasFocus&&(ve+=.05),ut.hasScrollListeners&&(ve+=.05),ve+=st,fe&&(ve-=.05);let Ft=Math.max(0,Math.min(1,ve));Ft>X&&(X=Ft),T.push({element:Z,selector:Jn(Z,V(Z)),score:Ft,features:ie,type:K})}if(T.sort((J,Z)=>Z.score-J.score),T.length>=2){let J=T[0],Z=T[1];Math.abs(J.score-Z.score)<.08&&J.type==="article"&&Z.type==="feed"&&(T[0]=Z,T[1]=J)}return T}getScrollContext(p){let T=document.scrollingElement;return p===document.documentElement||p===document.body||!!T&&p===T?{target:T||document.documentElement||document.body,isRoot:!0}:{target:p,isRoot:!1}}async scrollToDirection(p,T){let S=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!S)return{success:!1,error:"No scrollable element found"};let{target:x,isRoot:A}=this.getScrollContext(S),L=V(x),P=q(L),G=T?.isTabActive??!L.hidden,D=T?.behavior,F=G&&D==="smooth",H=A?Math.max(L.documentElement?L.documentElement.scrollHeight:0,L.body?L.body.scrollHeight:0):x.scrollHeight,X=A?P.innerHeight:x.clientHeight,J=Math.max(0,H-X),Z=()=>A?P.scrollY:x.scrollTop,ie=K=>{if(F)try{A?P.scrollTo({top:K,behavior:"smooth"}):x.scrollTo({top:K,behavior:"smooth"})}catch{A?(L.scrollingElement||L.documentElement||L.body).scrollTop=K:x.scrollTop=K}else if(A){let fe=L.scrollingElement||L.documentElement||L.body;fe.scrollTop=K}else x.scrollTop=K};switch(p){case Fe.TOP:return ie(0),{success:!0,scrollTop:0,isAtTop:!0};case Fe.BOTTOM:return ie(J),{success:!0,scrollTop:J,isAtBottom:!0};default:return{success:!1,error:`Unknown direction: ${p}`}}}async scrollByAmount(p,T){let S=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!S)return{success:!1,error:"No scrollable element found"};let{target:x,isRoot:A}=this.getScrollContext(S),L=T?.isTabActive??!document.hidden,P=T?.behavior,G=L&&P==="smooth",D=Ot(),F=A&&D?D.innerHeight:x.clientHeight,H=A&&D?D.innerWidth:x.clientWidth,X=T?.amount??F*.8,J=A?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):x.scrollHeight,Z=A&&D?D.innerHeight:x.clientHeight,ie=Math.max(0,J-Z),K=ee=>{if(G)try{A?D?.scrollTo({top:ee,behavior:"smooth"}):x.scrollTo({top:ee,behavior:"smooth"})}catch{let pe=document.scrollingElement||document.documentElement||document.body;pe.scrollTop=ee}else{let pe=A?document.scrollingElement||document.documentElement||document.body:x;pe.scrollTop=ee}},fe=ee=>{if(G)try{x.scrollBy({left:ee,behavior:"smooth"})}catch{x.scrollLeft+=ee}else x.scrollLeft+=ee};switch(p){case Fe.DOWN:{let pe=(A&&D?D.scrollY:x.scrollTop)+X;K(pe);let se=A&&D?D.scrollY:x.scrollTop;return{success:!0,scrollTop:se,isAtTop:se<=5,isAtBottom:se>=ie-5}}case Fe.UP:{let ee=A&&D?D.scrollY:x.scrollTop,pe=Math.max(0,ee-X);K(pe);let se=A&&D?D.scrollY:x.scrollTop;return{success:!0,scrollTop:se,isAtTop:se<=5,isAtBottom:se>=ie-5}}case Fe.LEFT:{let ee=-(T?.amount??H*.8);return fe(ee),{success:!0,scrollLeft:x.scrollLeft}}case Fe.RIGHT:{let ee=T?.amount??H*.8;return fe(ee),{success:!0,scrollLeft:x.scrollLeft}}default:return{success:!1,error:`Unknown direction: ${p}`}}}normalizeScrollPosition(p){switch(p){case tt.START:return"start";case tt.END:return"end";case tt.NEAREST:return"nearest";case tt.CENTER:default:return"center"}}getScrollContainerForElement(p){let T=document.scrollingElement,S=p;for(;S&&S!==document.body&&S!==document.documentElement;){let L=getComputedStyle(S).overflowY,P=L==="auto"||L==="scroll"||L==="overlay",G=S.scrollHeight-S.clientHeight>8;if(P&&G)return{container:S,isRoot:!1};S=S.parentElement}return{container:T||document.documentElement||document.body,isRoot:!0}}scrollElementIntoView(p,T,S){let x=document.querySelector(p);if(!x)return{success:!1,error:`Element not found for selector: ${p}`};let{container:A,isRoot:L}=this.getScrollContainerForElement(x),P=re(A),G=P?.DOMRect||DOMRect,D=L?new G(0,0,P.innerWidth??0,P.innerHeight??0):A.getBoundingClientRect(),F=x.getBoundingClientRect(),H=24,X=F.top>=D.top+H&&F.bottom<=D.bottom-H,J=S?.isTabActive??!document.hidden,Z=S?.behavior,ie=J&&Z==="smooth",K=this.normalizeScrollPosition(T);if(T===tt.NEAREST&&X)return{success:!0,alreadyVisible:!0,...this.getScrollMetricsForContainer(A,L)};try{x.scrollIntoView({behavior:ie?"smooth":"auto",block:K,inline:"nearest"})}catch{x.scrollIntoView()}let fe=this.getScrollMetricsForContainer(A,L);return{success:!0,position:K,...fe}}getScrollMetricsForContainer(p,T){let S=T?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):p.scrollHeight,x=V(p),A=re(p),L=T&&A?A.innerHeight:p.clientHeight,P=Math.max(0,S-L),D=(T?x.scrollingElement||x.documentElement||x.body:p).scrollTop;return{scrollTop:D,scrollHeight:S,clientHeight:L,maxScroll:P,isAtTop:D<=5,isAtBottom:D>=P-5,scrollPercentage:P>0?D/P*100:0}}getScrollMetrics(){let p=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!p)return null;let{target:T,isRoot:S}=this.getScrollContext(p),x=V(T),A=q(x),L=S?Math.max(x.documentElement?x.documentElement.scrollHeight:0,x.body?x.body.scrollHeight:0):T.scrollHeight,P=S?A.innerHeight:T.clientHeight,G=Math.max(0,L-P),F=(S?x.scrollingElement||x.documentElement||x.body:T).scrollTop;return{element:Jn(T,x),scrollTop:F,scrollHeight:L,clientHeight:P,maxScroll:G,isAtTop:F<=5,isAtBottom:F>=G-5,scrollPercentage:G>0?F/G*100:0}}}let r=new o;window[e]=r;let s={execute:R=>r.execute(R)};try{Object.defineProperty(window,t,{value:s,writable:!1,configurable:!1,enumerable:!1})}catch{try{window[t]=s}catch{}}let c=window.__RTRVR_INTERNAL_KEY__||n,l=window[c],f=l&&typeof l=="object"?l:null;if(f){try{f.scroll=f.scroll||s}catch{}try{f.scroll||Object.defineProperty(f,"scroll",{value:s,writable:!1,configurable:!1,enumerable:!1})}catch{}}if(c!==n)try{!window[n]&&f&&Object.defineProperty(window,n,{value:f,writable:!1,configurable:!1,enumerable:!1})}catch{}})();var tu=/\[id=(\d+)\]/,$e;(function(e){e.HTML="html",e.PDF="pdf",e.GOOGLE_DOC="google_doc",e.GOOGLE_SHEET="google_sheet",e.PLAIN_TEXT="plain_text"})($e||($e={}));var Ia=new Map;function nu(e){let t={};for(let n of Object.keys(e)){let o=e[Number(n)],r=o?.preservedAttributes?.[mt["rtrvr-label"]],s=o?.resourceLocator;if(typeof r=="string"&&typeof s=="string"){let c=r.match(tu);if(c?.[1]){let l=Number(c[1]);Number.isFinite(l)&&(t[l]=s)}}}return t}async function La(e,t,n={}){let o=e.ownerDocument||document,r=n.pageConfig||dr,s=String(o.contentType||"").trim().toLowerCase(),c=su(s,o),l=ru(c.documentType,s),f={url:o.URL,title:o.title,contentType:l},R=ou(r);if(c.documentType!==$e.HTML){let L=Number(r?.pageDataTimeoutMs),P=Number.isFinite(L)?Math.max(200,Math.floor(L)):9e3,G=Math.max(200,Math.min(P,St(R))),D=lu(o,c.documentType,r,R),F=await Qn(D,G,o);if(!F.ok)return{...f,content:"",error:`non_html_timeout:${l}`,metadata:{extractionMethod:"timeout"}};let H=F.value||{},X=c.documentType===$e.GOOGLE_SHEET?Hu(o):void 0;return{...f,...H,contentType:H.contentType||f.contentType,sheetInfo:H.sheetInfo||X}}if(r?.onlyTextContent)return{...f,contentType:zn,content:Er(o)};let p=Math.max(0,Math.min(3e3,St(R))),T=performance.now(),S=!1;if(!r?.disableAutoScroll&&p>80){let L=o.hidden?900:1500,P=Math.min(L,p);P>80&&(S=await Ou(o,{profile:"light",timeBudgetMs:P,delayMs:o.hidden?0:160,finalWaitMs:o.hidden?0:200}))}let x=Math.max(0,p-(performance.now()-T));x>80&&await Fu(o,{mode:"full",totalBudgetMs:Math.min(o.hidden?1400:1200,x),budgetMs:Math.min(o.hidden?650:850,x),maxPasses:o.hidden?1:2});let A=pr(e,t,{includeFrames:n.includeFrames??!0,disableDomAnnotations:n.disableDomAnnotations??!0});return fu(A.rootNodes,A.semanticNodes)?{...f,contentType:zn,content:Er(o),metadata:{scrollingPerformed:S}}:{...f,contentType:zn,roots:A.rootNodes,nodes:A.semanticNodes,elementLinkRecord:nu(A.semanticNodes),metadata:{scrollingPerformed:S}}}function ou(e){let t=Number(e?.deadlineEpochMs);if(Number.isFinite(t)&&t>0)return t;let n=Number(e?.totalBudgetMs),o=Number.isFinite(n)?Math.max(1500,Math.floor(n)):9e3;return Date.now()+o}function ru(e,t){switch(e){case $e.PDF:return ms;case $e.GOOGLE_DOC:return Es;case $e.GOOGLE_SHEET:return gs;case $e.PLAIN_TEXT:return fr;case $e.HTML:default:return t||zn}}function su(e,t){let n=e||String(t.contentType||"").toLowerCase();return wa(n)?{documentType:$e.PDF}:iu(t)&&(cu(t)||au(t.URL))?{documentType:$e.PDF}:yu(t)?{documentType:$e.GOOGLE_DOC}:_u(t)?{documentType:$e.GOOGLE_SHEET}:n.includes(fr)?{documentType:$e.PLAIN_TEXT}:{documentType:$e.HTML}}function iu(e){try{let t=hu(e);return ws(t)?!0:!!t.querySelector?.('object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]')}catch{return!1}}function au(e){try{return e?e.toLowerCase().includes(".pdf")?!0:(new URL(e).searchParams.get("file")||"").toLowerCase().includes(".pdf"):!1}catch{return String(e||"").toLowerCase().includes(".pdf")}}function cu(e){try{let t=e.body;return!t||t.querySelectorAll('embed[type="application/pdf"],embed[type="application/x-google-chrome-pdf"],object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]').length===0||(t.innerText||"").trim().length>40?!1:Array.from(t.children).filter(s=>!["SCRIPT","STYLE"].includes(String(s.tagName).toUpperCase())).length<=3}catch{return!1}}async function lu(e,t,n,o){switch(t){case $e.PDF:return uu(e,n,o);case $e.GOOGLE_DOC:return du(e);case $e.GOOGLE_SHEET:return Nu(e,n);case $e.PLAIN_TEXT:return{content:Er(e),contentType:fr};case $e.HTML:default:return{content:Er(e),contentType:zn}}}async function uu(e,t,n){St(n)>ps+50&&await ya(ps,e,n);let r=(()=>{let p=Number(t?.pdfTextSelectionTimeoutMs),T=dr.pdfTextSelectionTimeoutMs;return Number.isFinite(p)?Math.max(150,Math.floor(p)):T})(),s=St(n),l=Number.isFinite(s)?Math.max(150,Math.min(r,Math.max(0,s-150))):r,f=await mu(e,l),R=!!f.success&&!!(f.data||"").trim();return{content:R&&f.data||"",contentType:ms,error:R?void 0:`pdf_extraction_failed:${f.reason||"unknown"}`}}async function du(e){return{content:Cu(),contentType:Es}}function fu(e,t){return!Array.isArray(e)||e.length===0||!t||Object.keys(t).length===0}function Er(e){return e.body?.innerText||e.body?.textContent||e.documentElement?.innerText||e.documentElement?.textContent||""}function hu(e){try{let t=e.defaultView||window,n=t.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",r=t[n]?.shadow?.getRoot;if(typeof r=="function"){let s=r(e.body||e.documentElement);if(s)return s}}catch{}return e}function pu(e){let t=e.URL||"";try{let n=new URL(t),o=n.searchParams.get("file")||n.searchParams.get("src")||"";return o||t}catch{return t}}async function mu(e,t){let n=Number.isFinite(t)&&t>0?Math.floor(t):dr.pdfTextSelectionTimeoutMs,o=pu(e),r=Ia.get(o)??"";if(r.trim().length>0)return{success:!0,data:r,reason:"ok"};let s=await gu(e,n);return s.success&&s.data.trim()&&Ia.set(o,s.data),s}async function gu(e,t){let n=e.defaultView||window,o=bu(e);if(!o||typeof o.postMessage!="function")return{success:!1,data:"",reason:"no_viewer"};let r=globalThis.crypto&&"randomUUID"in globalThis.crypto?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`,s=!1,c="",l=p=>{if(s||!Eu(String(p.origin||""),e))return;let T=p.data;wu(T,r)&&typeof T.selectedText=="string"&&T.selectedText.trim().length>0&&(c=T.selectedText,s=!0)};n.addEventListener("message",l);try{o.postMessage({type:"selectAll",requestId:r},"*")}catch{}let f=Date.now();for(;!s&&Date.now()-f<t;){try{o.postMessage({type:"getSelectedText",requestId:r},"*")}catch{}if(await et(200,e),c.trim()){s=!0;break}}return n.removeEventListener("message",l),c.trim()?{success:!0,data:c,reason:"ok"}:{success:!1,data:"",reason:Date.now()-f>=t?"timeout":"no_response"}}function bu(e){let t=ws(e)||e.querySelector?.('object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]');if(t&&typeof t.postMessage=="function")return t;let n=e.querySelector?.('iframe[type="application/pdf"]');return n?.contentWindow?n.contentWindow:null}function Eu(e,t){let n=(e||"").toLowerCase();if(!n||n==="null"||n.startsWith("chrome-extension://")||n.startsWith("chrome://")||n.startsWith("chrome-untrusted://"))return!0;try{let o=new URL(t.URL||"").origin.toLowerCase();if(o&&n===o)return!0}catch{}return!1}function wu(e,t){return!(!e||typeof e!="object"||e.type!=="getSelectedTextReply"||typeof e.selectedText!="string"||e.requestId&&e.requestId!==t)}function yu(e){try{let t=e.defaultView||Ot();if(t?.location.hostname==="docs.google.com"&&t?.location.pathname.startsWith("/document/d/"))return!0}catch{}try{if(e.querySelector('iframe[src^="https://docs.google.com/document/d/"]'))return!0}catch{}return Zn(e)!==null}function _u(e){let n=(e.defaultView||Ot())?.location.href??"";return/^https:\/\/docs\.google\.com\/spreadsheets\/(?:u\/\d+\/)?d\/[a-zA-Z0-9_-]+/.test(n)}function Tu(e){try{return e.defaultView?.top?.document??e}catch{return e}}function wr(e){let t=[e],n=Tu(e);return n!==e&&t.push(n),t}var xu=".docs-texteventtarget-iframe",vu=".kix-cursor",Ru=".docos-replyview-body",Su=".docos-replyview",ku=".docos-author",Da="\u200B",Iu="\xA0";function Zn(e){for(let t of wr(e)){let n=t.querySelector(xu);if(n)return n}return null}function Au(e){for(let t of wr(e)){let n=t.querySelector(vu);if(n)return n}return null}function mr(e){let t=Au(e);return t?(t.ownerDocument?.defaultView?.getComputedStyle(t).display??t.style.display)==="none":!1}function gr(e,t){let n=Zn(e);if(!n)return;let o=t?"ArrowUp":"ArrowDown",s={key:o,keyCode:t?38:40,altKey:!0,shiftKey:!0,code:o,bubbles:!0,cancelable:!0},c=n.contentDocument,l=n.contentWindow;if(!c)return;let f=l?.KeyboardEvent||KeyboardEvent;c.dispatchEvent(new f("keydown",s))}function Aa(e){let t=Zn(e);if(!t)return;let n={key:"ArrowLeft",keyCode:37,code:"ArrowLeft",bubbles:!0,cancelable:!0},o=t.contentDocument,r=t.contentWindow;if(!o)return;let s=r?.KeyboardEvent||KeyboardEvent;o.dispatchEvent(new s("keydown",n))}function Mu(e){let t=Zn(e);if(!t)return;let o=(typeof navigator<"u"?String(navigator.platform||""):"").toUpperCase().indexOf("MAC")>=0,r={key:"a",code:"KeyA",ctrlKey:!o,metaKey:o,bubbles:!0,cancelable:!0},s=t.contentDocument,c=t.contentWindow;if(!s)return;let l=c?.KeyboardEvent||KeyboardEvent;s.dispatchEvent(new l("keydown",r))}function br(e){let t=Zn(e);if(!t)return"";let n=t.contentDocument,o=t.contentWindow,r=n?.body;if(!n||!r)return"";try{let l=o?.ClipboardEvent||ClipboardEvent,f=new l("copy",{bubbles:!0,cancelable:!0});r.firstChild?.dispatchEvent?.(f),r.firstChild?.dispatchEvent||r.dispatchEvent(f)}catch{}let s=r.innerText||r.textContent||"";return String(s).replace(new RegExp(Da,"g"),"")??""}function vs(e){let t=`
|
|
3
|
+
|
|
4
|
+
Comments: `,n=new Set,o=[];for(let s of wr(e))try{let c=Array.from(s.querySelectorAll(Ru));for(let l of c)n.has(l)||(n.add(l),o.push(l))}catch{}let r=o.filter(s=>s.textContent);if(r.length===0)return"";for(let s of r){let c=s.closest(Su);if(!c)continue;let l=c.querySelector(ku);l&&l.textContent&&(t+=`
|
|
5
|
+
Author: ${l.textContent} `),s.textContent&&(t+=`Comment: ${s.textContent}
|
|
6
|
+
`)}return t.trim()}function Cu(){let e=Ye()||document,t=Zn(e),n=t?.contentDocument,o=t?.contentWindow,r=()=>{let s=n?.body,c=Ye(),l=s?.innerText||s?.textContent||""||c?.body?.innerText||c?.body?.textContent||"";return String(l).replace(new RegExp(Da,"g"),"")+vs(e)};try{try{o?.focus(),n?.body?.focus?.()}catch{}if(Mu(e),mr(e)){let f=br(e);if(f.trim()!==""){let R=vs(e).trim();return f+R}else Aa(e)}let s="";if(gr(e,!0),mr(e)){let f=br(e);f.endsWith(`
|
|
7
|
+
|
|
8
|
+
`)||(s+=f.trimEnd())}if(gr(e,!1),mr(e)?br(e).endsWith(Iu+`
|
|
9
|
+
`)&&gr(e,!1):gr(e,!1),mr(e)){let f=br(e);f.trim()!==""&&!f.startsWith(`
|
|
10
|
+
`)&&(s+=f)}Aa(e);let c=vs(e).trim(),l=s.trim()+c;return l.trim()?l:r()}catch{return r()}}async function Nu(e,t){let n="",o;Oa(e,e.defaultView||window);let r=St(t?.deadlineEpochMs);try{let s=Math.max(250,Math.min(1500,Math.floor(r*.45))),c=await Qn(Lu(e),s,e);if(!(c.ok&&c.value))throw new Error("google_sheet_copy_failed");let f=St(t?.deadlineEpochMs),R=Math.max(250,Math.min(2500,Math.floor(f*.55)));if(n=await Du(R,e),!n.trim())throw new Error("google_sheet_empty_clipboard")}catch(s){o=s instanceof Error?s.message:String(s)}return{content:n,contentType:gs,error:o}}function Oa(e,t){try{t?.focus?.()}catch{}try{e?.body?.focus?.()}catch{}}function Rs(e,t){let o=e.defaultView?.KeyboardEvent||KeyboardEvent,r=new o("keydown",{bubbles:!0,cancelable:!0,...t}),s=e.activeElement;(s&&s.ownerDocument===e?s:e).dispatchEvent(r)}async function Lu(e){try{if(Oa(e,e.defaultView||window),e.hidden||!e.hasFocus())return!1;Rs(e,{key:"Escape",code:"Escape"}),await et(150,e);let t=e.querySelector(".grid-container")||Ma(e,".grid-container"),n=e.querySelector(".grid4-inner-container:last-child")||Ma(e,".grid4-inner-container:last-child");if(n){try{n.focus()}catch{}await et(100,e)}else if(t){try{t.focus?.()}catch{}await et(80,e)}let r=(typeof navigator<"u"?String(navigator.platform||""):"").toUpperCase().indexOf("MAC")>=0;Rs(e,{key:"a",code:"KeyA",ctrlKey:!r,metaKey:r}),await et(200,e),Rs(e,{key:"c",code:"KeyC",ctrlKey:!r,metaKey:r}),await et(200,e);try{e.execCommand("copy")}catch{}return!0}catch{return!1}}async function Du(e,t){let n=Math.max(250,Math.min(5e3,Math.floor(e)));if(navigator?.clipboard?.readText){let s=await Qn(navigator.clipboard.readText(),n,t);if(s.ok)return s.value||""}let o=t.createElement("textarea");o.style.position="fixed",o.style.opacity="0",o.style.pointerEvents="none",o.style.left="-9999px",o.style.top="0",t.body?.appendChild(o),o.focus();try{t.execCommand("paste")}catch{}let r=o.value||"";return o.remove(),r}function Ma(e,t){let n=wr(e);for(let l of n)try{let f=l.querySelector(t);if(f)return f}catch{}let o=25e3,r=0,s=(l,f)=>{if(!f)return;let R=f.children;if(R)for(let p=0;p<R.length;p++)l.push(R[p])},c=[];for(let l of n)try{s(c,l.documentElement??l.body??null)}catch{}for(;c.length&&r<o;){let l=c.pop();r++;try{if(l.matches(t))return l}catch{}s(c,l);let f=l.shadowRoot;if(f&&s(c,f),String(l.tagName).toUpperCase()==="IFRAME")try{let p=l.contentDocument;p&&s(c,p.documentElement??p.body??null)}catch{}}return null}async function Ou(e,t){let n=t?.profile??"light",o=!e.hidden,r=Math.max(0,Math.min(t?.timeBudgetMs??(n==="light"?1600:2800),3e3));if(r<=0)return!1;let s=Date.now(),c=()=>r-(Date.now()-s),l=t?.delayMs??(n==="light"?220:280),f=t?.finalWaitMs??(n==="light"?350:900),R=o?l:0,p=o?f:0,T=t?.amount,S=t?.maxSteps??(n==="light"?8:18),x=t?.maxDistancePx??(n==="light"?12e3:3e4),A=null;try{let D=await Ca(e,{action:"detectPrimary"});if(D?.selector){let H=Uu(e,D.selector);H&&(A=H)}let F=D?.metrics;if(F&&typeof F.scrollHeight=="number"&&typeof F.clientHeight=="number"){let H=Math.max(0,F.scrollHeight-F.clientHeight);x=Math.min(x,H||x),H<1500?S=Math.min(S,2):H<4e3?S=Math.min(S,4):H<1e4&&(S=Math.min(S,6))}}catch{}if(A||(A=e.scrollingElement||e.documentElement||e.body),!A)return!1;let L=0,P=null,G=0;for(let D=0;D<S&&!(c()<=0);D++){let F=null;try{F=await Ca(e,{action:"scrollBy",direction:Fe.DOWN,options:{amount:T,behavior:"auto",isTabActive:o}})}catch{}if(!F||!F.success){let X=e.defaultView||window;F=hr(A,e,X,Fe.DOWN,T),G=2}if(!F?.success)break;let H=F.scrollTop??P??0;if(P!==null){let X=Math.max(0,H-P);L+=X,G=X===0?G+1:0}if(P=H,F.isAtBottom||G>=2||L>=x)break;if(R>0&&D<S-1){let X=Math.min(R,Math.max(0,c()));if(X<=0)break;await et(X,e)}}if(p>0){let D=Math.min(p,Math.max(0,c()));D>0&&await et(D,e)}if(c()>80)try{let D=e.scrollingElement||e.documentElement||e.body,F=e.defaultView||window,H=A===e.documentElement||A===e.body||A===D?D:A;if(H){let X=H===D?F.innerHeight:H.clientHeight||F.innerHeight,J=Math.max(0,H.scrollHeight-X);H.scrollTop=J}}catch{}return!0}function Uu(e,t){try{return e.querySelector(t)}catch{return null}}async function Ca(e,t){let n=e.defaultView||window,o=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",c=(n[o]?.scroll||n.__RTRVR_SCROLL_API__)?.execute;return typeof c!="function"?null:c(t)}async function Fu(e,t){let n=e.defaultView||window,o=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",s=n[o]?.flushScan;if(typeof s!="function"){try{n.rtrvrAIMarkInteractiveElements?.()}catch{}return}let c=Date.now()+Math.max(100,Math.floor(t.totalBudgetMs)),l=0;for(;l<t.maxPasses&&St(c)>0;){let f=Math.max(50,Math.min(t.budgetMs,St(c)));try{await s({mode:t.mode??"full",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:f,deadlineEpochMs:c})}catch{break}if(Na(e)===0)break;l++}if(Na(e)>0&&St(c)>50){let f=Math.min(120,St(c));try{await s({mode:"priority",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:f,deadlineEpochMs:c})}catch{}}}function Na(e){let t=e.documentElement;if(!t)return 0;let n=t.getAttribute(ho);if(!n)return 0;let o=Number.parseInt(n,10);return Number.isFinite(o)&&o>0?o:0}function Hu(e){let t=Pu(e.URL||"");if(!t?.sheetId)return;let n=Bu(e),o=n?.title||"Sheet1";return{sheetId:t.sheetId,sheetTitle:e.title||n?.title||void 0,sheetTab:o,sheetTabId:t.sheetTabId??n?.id,sheetTabs:void 0}}function Pu(e){if(!e)return null;try{let t=new URL(e);if(t.hostname!=="docs.google.com")return null;let n=t.pathname.split("/"),o=n.indexOf("spreadsheets"),r=n.indexOf("d");if(o===-1||r===-1||r!==o+1||n.length<=r+1)return null;let s=n[r+1];if(!s||!/^[a-zA-Z0-9_-]+$/.test(s))return null;let c;return t.hash&&t.hash.includes("gid=")&&(c=new URLSearchParams(t.hash.substring(1)).get("gid")??void 0),!c&&t.searchParams.has("gid")&&(c=t.searchParams.get("gid")??void 0),c&&!/^\\d+$/.test(c)&&(c=void 0),{sheetId:s,sheetTabId:c?parseInt(c,10):0}}catch{return null}}function Bu(e){try{let t=e.querySelector('[role="tab"][aria-selected="true"]')||e.querySelector(".docs-sheet-tab-active")||e.querySelector('.docs-sheet-tab[aria-selected="true"]');if(!t)return null;let n=t.getAttribute("aria-label")||t.textContent?.trim()||void 0,o=t.getAttribute("data-sheet-id")||t.getAttribute("data-tab-id")||void 0,r=o&&/^\d+$/.test(o)?Number(o):void 0;return{title:n,id:r}}catch{return null}}var Tt;(function(e){e[e.Native=1]="Native",e[e.Inline=2]="Inline",e[e.React=4]="React",e[e.Vue=8]="Vue",e[e.Angular=16]="Angular",e[e.Svelte=32]="Svelte",e[e.JQuery=64]="JQuery",e[e.Delegated=128]="Delegated",e[e.Other=256]="Other",e[e.Inferred=512]="Inferred"})(Tt||(Tt={}));var Wu={native:Tt.Native,inline:Tt.Inline,react:Tt.React,vue:Tt.Vue,angular:Tt.Angular,svelte:Tt.Svelte,jquery:Tt.JQuery,delegated:Tt.Delegated,other:Tt.Other};(()=>{let e=window,t="__RTRVR_MAIN_WORLD_INITIALIZED__",n=new WeakMap,o={frameworks:new Set,reactRoots:new WeakSet,vueRoots:new WeakSet,angularRoots:new WeakSet,svelteRoots:new WeakSet,jqueryRoots:new WeakSet},r=new WeakMap,s=new WeakMap,c=new Set,l=500,f=200,R=0,p=0,T=new WeakSet,S="__RTRVR_ET_HOOKED__",x="__RTRVR_ATTACH_SHADOW_HOOKED__";function A(a){if(a&&!T.has(a)){T.add(a);try{L(a)}catch{}try{P(a)}catch{}}}function L(a){try{let m=a.EventTarget;if(!m?.prototype||m.prototype[S])return;m.prototype[S]=!0;let g=m.prototype.addEventListener,y=m.prototype.removeEventListener;m.prototype.addEventListener=function(k,O,Y){try{oo(O)||En(this,k,Y)}catch{}return g.call(this,k,O,Y)},m.prototype.removeEventListener=function(k,O,Y){try{wn(this,k,Y)}catch{}return y.call(this,k,O,Y)};try{let k=Function.prototype.toString;m.prototype.addEventListener.toString=()=>k.call(g),m.prototype.removeEventListener.toString=()=>k.call(y)}catch{}}catch{}}function P(a){try{let m=a.Element;if(!m?.prototype?.attachShadow||m.prototype[x])return;m.prototype[x]=!0;let g=m.prototype.attachShadow;m.prototype.attachShadow=function(y){let k=g.call(this,y);try{ge.set(this,k)}catch{}try{ae(k)}catch{}return k};try{let y=Function.prototype.toString;m.prototype.attachShadow.toString=()=>y.call(g)}catch{}}catch{}}function G(a){let g=n.get(a)?.listenerTypeMasks;if(g&&g.size){let y=[];for(let k of g.keys()){let O=Vt[k];O&&y.push(O)}return y}return lo(a)}let D=["onclick","ondblclick","ondoubleclick","onmousedown","onmouseup","role","contenteditable","draggable","tabindex","disabled","type","aria-haspopup","aria-expanded","data-click","data-action","data-handler","data-toggle","data-target"],F=0,H=new Set,X=6,J=["click","input","change","keydown","keyup","pointerdown","pointerup","submit","focus","blur"],Z=["mouseenter","mouseleave","mouseover","mouseout","mousedown","mouseup","wheel","scroll","dragstart","drop","touchstart","touchend"];if(e[t]){typeof e.rtrvrAIMarkInteractiveElements=="function"&&e.rtrvrAIMarkInteractiveElements();return}e[t]=!0;let ie={onclick:"click",ondblclick:"dblclick",ondoubleclick:"doubleclick",onmousedown:"mousedown",onmouseup:"mouseup",onmouseenter:"mouseenter",onmouseleave:"mouseleave",onmousemove:"mousemove",onmouseover:"mouseover",onmouseout:"mouseout",oncontextmenu:"contextmenu",onauxclick:"auxclick",onkeydown:"keydown",onkeyup:"keyup",onkeypress:"keypress",oninput:"input",onchange:"change",onsubmit:"submit",onreset:"reset",onselect:"select",onsearch:"search",oninvalid:"invalid",onbeforeinput:"beforeinput",onfocus:"focus",onblur:"blur",onfocusin:"focusin",onfocusout:"focusout",ontouchstart:"touchstart",ontouchend:"touchend",ontouchmove:"touchmove",ontouchcancel:"touchcancel",onpointerdown:"pointerdown",onpointerup:"pointerup",onpointermove:"pointermove",onpointerenter:"pointerenter",onpointerleave:"pointerleave",onpointercancel:"pointercancel",onpointerover:"pointerover",ondragstart:"dragstart",ondragend:"dragend",ondrag:"drag",ondragenter:"dragenter",ondragleave:"dragleave",ondragover:"dragover",ondrop:"drop",oncopy:"copy",oncut:"cut",onpaste:"paste",onscroll:"scroll",onwheel:"wheel",onplay:"play",onpause:"pause",onended:"ended",onvolumechange:"volumechange",onseeking:"seeking",onseeked:"seeked",onanimationstart:"animationstart",onanimationend:"animationend",ontransitionend:"transitionend",ontransitionstart:"transitionstart",onresize:"resize",ontoggle:"toggle",onfullscreenchange:"fullscreenchange",onload:"load",onerror:"error",onabort:"abort",onbeforeunload:"beforeunload",onunload:"unload",onhashchange:"hashchange",onpopstate:"popstate",onstorage:"storage",onmessage:"message"};function K(a){return a?String(a).split(".")[0].toLowerCase():""}let fe=["data-click","data-action","data-event","data-handler","data-on-click","data-onclick","data-tap","data-press","data-toggle","data-target"],ee=0,pe=null,se=new MessageChannel,ut=[];se.port1.onmessage=()=>{let a=ut.shift();a&&a()};function xe(){return Date.now()}function Oe(a){return!a||!Number.isFinite(a)?Number.POSITIVE_INFINITY:Math.max(0,a-xe())}let Ke=8,Qe=new MessageChannel,dt=!1;function xt(){if(!dt){dt=!0;try{Qe.port2.postMessage(0)}catch{}}}function ft(a){let m=a.values().next();if(m.done)return null;let g=m.value;return a.delete(g),g}function vt(){return new Promise(a=>{ut.push(a),se.port2.postMessage(0)})}let st=!1;function ve(){if(!st)try{let a=e.jQuery;a&&a.fn&&(zs(a),st=!0,ce("jquery"))}catch{}}function Ft(a,m){for(let g=m.lastElementChild;g;g=g.previousElementSibling)a.push(g)}function Oo(a,m,g){if(g)try{let y=_e(m);y&&a.push(y)}catch{}}function Hn(a,m,g){if(g&&co(m))try{let y=m.contentWindow||null;y&&A(y);let k=y?.document?.documentElement;k&&a.push(k)}catch{}}let Ht=new WeakSet;function Kt(a){a&&(typeof a=="function"||typeof a=="object")&&Ht.add(a)}function oo(a){return!!a&&(typeof a=="function"||typeof a=="object")&&Ht.has(a)}Qe.port1.onmessage=()=>{dt=!1,dn(500);let a=performance.now();for(;H.size&&performance.now()-a<Ke;){let m=ft(H);if(!m)break;try{U(m)}catch{}finally{F=Math.max(0,F-1)}}for(;c.size&&performance.now()-a<Ke;){let m=ft(c);if(!m)break;try{Ue(m)}catch{}}ht(),(H.size||c.size)&&xt()};function ht(){try{let a=Ye()?.documentElement;if(!a)return;a.setAttribute(ho,String(F))}catch{}}function Pt(a){let m=n.get(a);return m||(m={frameworks:new Set,listeners:new Map},n.set(a,m)),m}function un(a){c.add(a),xt()}function Bt(a){H.has(a)||(H.add(a),F++,ht(),xt(),H.size>8e3&&dn(3e3))}function dn(a=2e3){let m=0;for(let g of H){if(m>a)break;g.isConnected||(H.delete(g),F=Math.max(0,F-1))}m=0;for(let g of c){if(m>a)break;g.isConnected||c.delete(g)}ht()}let Be=null;function ro(a,m,g){return`${a}|${m?1:0}|${g?1:0}`}function Qt(a){let m=a.tagName;if(m==="A"||m==="BUTTON"||m==="INPUT"||m==="SELECT"||m==="TEXTAREA"||m==="SUMMARY"||a.hasAttribute("role")||a.hasAttribute("tabindex")||a.hasAttribute("contenteditable")||a.hasAttribute("onclick")||a.getAttributeNames().some(g=>g.startsWith("on")))return!0;for(let g of fe)if(a.hasAttribute(g))return!0;return!!(a.hasAttribute("aria-haspopup")||a.hasAttribute("aria-expanded"))}function fn(a){let m=re(a);if(!Ve(a,m))return!1;let g=a.tagName;if(g!=="DIV"&&g!=="SPAN"&&g!=="LI"&&g!=="SECTION"&&g!=="ARTICLE"&&g!=="P")return!1;let y=a;if(y.__ngContext__||y.__svelte__||y.__vue__||y._vnode||y.__reactFiber$||y.__reactProps$)return!0;let k=0;for(let O in y){if(++k>30)break;if(O.startsWith("__react")||O.includes("reactFiber")||O.includes("reactProps"))return!0}return!1}function Jt(){let a=Ye()?.documentElement;return a?o.frameworks.size>0||a.hasAttribute("rtrvr-react")||a.hasAttribute("rtrvr-vue")||a.hasAttribute("rtrvr-angular")||a.hasAttribute("rtrvr-svelte")||a.hasAttribute("rtrvr-jquery"):!1}function so(a){let m=performance.now();for(;H.size&&performance.now()-m<a;){let g=ft(H);if(!g)break;try{U(g)}catch{}finally{F=Math.max(0,F-1)}}for(;c.size&&performance.now()-m<a;){let g=ft(c);if(!g)break;try{Ue(g)}catch{}}}async function kt(a={}){dn(3e3),ve(),ye();let m=a.mode??"full",g=a.includeShadow??!0,y=a.includeSameOriginIframes??!0,k=Math.max(50,Math.min(a.budgetMs??2500,15e3)),O=a.deadlineEpochMs,Y=Math.max(0,Math.min(k,Oe(O))),Q=ro(m,g,y);if(Y<=0){let Xe=(Be?.stack?.length??0)+H.size+c.size;return{revision:++ee,scanned:0,durationMs:0,done:Xe===0,remaining:Xe}}if((!Be||Be.optsKey!==Q)&&Oe(O)>30&&await ne({budgetMs:18,deadlineEpochMs:O}),m==="priority"){let Xe=performance.now(),Le=0;for(;H.size&&performance.now()-Xe<=Y&&!(O&&Oe(O)<=0);){let He=ft(H);if(!He)break;try{U(He)}catch{}Le++,F=Math.max(0,F-1)}for(;c.size&&performance.now()-Xe<=Y&&!(O&&Oe(O)<=0);){let He=ft(c);if(!He)break;try{Ue(He)}catch{}}return ht(),{revision:++ee,scanned:Le,durationMs:performance.now()-Xe,done:H.size===0&&c.size===0,remaining:H.size+c.size}}if(!Be||Be.optsKey!==Q){let Xe=Ye()?.documentElement;Be={optsKey:Q,stack:Xe?[Xe]:[],scannedTotal:0}}let Re=performance.now(),Ae=0;for(F++,ht();Be.stack.length&&!(O&&Oe(O)<=0);){let Xe=Be.stack.pop();if(yt(Xe)){let He=Xe.children;for(let yn=He.length-1;yn>=0;yn--)Be.stack.push(He[yn]);continue}let Le=Xe;if(!(!Le||Le.nodeType!==1)&&!(Le.tagName==="SCRIPT"||Le.tagName==="STYLE"||Le.tagName==="META"||Le.tagName==="NOSCRIPT")){try{(Qt(Le)||Jt()&&fn(Le))&&U(Le)}catch{}try{Ue(Le)}catch{}if(H.delete(Le)&&(F=Math.max(0,F-1)),c.delete(Le),Ae++,Be.scannedTotal++,g)try{let He=_e(Le);He&&(ae(He),Be.stack.push(He))}catch{}if(y&&co(Le))try{let He=Le.contentWindow||null;He&&A(He);let yn=He?.document,Ks=yn?.documentElement;yn&&Ks&&(ke(yn),Be.stack.push(Ks))}catch{}for(let He=Le.lastElementChild;He;He=He.previousElementSibling)Be.stack.push(He);Ae%800===0&&Oe(O)>20&&await vt()}}let Ne=Math.max(0,Y-(performance.now()-Re)),it=Oe(O);so(Math.min(250,Ne,it)),F=Math.max(0,F-1),ht();let Dt=Be.stack.length===0,Bn=Be.stack.length;return Dt&&(Be=null),{revision:++ee,scanned:Ae,durationMs:performance.now()-Re,done:Dt,remaining:Bn}}async function hn(a={}){return pe||(pe=kt(a).finally(()=>{pe=null}),pe)}e.rtrvrAIFlushScan=hn;let Zt="__RTRVR_INTERNAL__";Object(window).__RTRVR_INTERNAL_KEY__=Zt;let en=e[Zt],pn=en&&typeof en=="object"?en:{};if(!en)try{Object.defineProperty(e,Zt,{value:pn,writable:!1,configurable:!1,enumerable:!1})}catch{}try{Object.defineProperty(pn,"flushScan",{value:hn,writable:!1,configurable:!1,enumerable:!1})}catch{}function B(a,m){let g=Pt(a),y=K(m.type);if(!y)return;let k=!1,O=g.listeners.get(y);O||(O=[],g.listeners.set(y,O),k=!0);let Y=O.find(he=>he.source===m.source&&!!he.inferred==!!m.inferred);if(Y){let he=!!Y.capture,Re=!!Y.passive,Ae=!!Y.once;Y.capture=Y.capture||m.capture,Y.passive=Y.passive||m.passive,Y.once=Y.once||m.once,(he!==!!Y.capture||Re!==!!Y.passive||Ae!==!!Y.once)&&(k=!0)}else O.push({...m,type:y}),k=!0;let Q=Te[y];if(Q!==void 0){g.listenerTypeMasks||(g.listenerTypeMasks=new Map);let he=0,Re=Wu[m.source];he|=Re!==void 0?Re:Tt.Other,m.inferred&&(he|=Tt.Inferred);let Ae=g.listenerTypeMasks.get(Q)||0,Ne=Ae|he;Ne!==Ae&&(g.listenerTypeMasks.set(Q,Ne),k=!0)}k&&(g.role=void 0,un(a))}function te(a){let m=a.listenerTypeMasks;return!m||m.size===0?null:[...m.entries()].sort((y,k)=>y[0]-k[0]).map(([y,k])=>`${y}~${(k||0).toString(36)}`).join(",")}function Ee(a,m){let g=Pt(a);g.frameworks.has(m)||(g.frameworks.add(m),un(a))}function ce(a){o.frameworks.has(a)||(o.frameworks.add(a),Ye()?.documentElement?.setAttribute(`rtrvr-${a}`,"1"))}function Ue(a){let m=n.get(a);if(!m)return;c.delete(a);let g=te(m);g?g!==m.lastListenersSerialized&&(a.setAttribute(nn,g),m.lastListenersSerialized=g):m.lastListenersSerialized&&(a.removeAttribute(nn),m.lastListenersSerialized=void 0);let y=re(a);if(Ve(a,y))if(m.role===void 0&&(m.role=tn(a)),m.role){let k=$n[m.role],O=typeof k=="number"?String(k):`s:${m.role}`;O!==m.lastRoleSerialized&&(a.setAttribute(Gt,O),m.lastRoleSerialized=O)}else(m.lastRoleSerialized||a.hasAttribute(Gt))&&(a.removeAttribute(Gt),m.lastRoleSerialized=void 0)}function pt(a){let m=[],g=a;for(;g;)m.push(g),g=g.parentNode||g.host;return m}function Ce(a){let m=a.tagName.toLowerCase(),g=a.getAttribute("role"),y=g?g.toLowerCase().trim():"";if(y&&$t.has(y)||m==="button"||(m==="a"||m==="area")&&a.hasAttribute("href"))return!0;if(m==="input")return a.type?.toLowerCase()!=="hidden";if(m==="select"||m==="textarea"||(m==="video"||m==="audio")&&a.hasAttribute("controls")||a.isContentEditable||a.hasAttribute("contenteditable"))return!0;let k=a.getAttribute("tabindex");return!!(k!==null&&!Number.isNaN(Number.parseInt(k,10))&&(G(a).some(Q=>zo.has(Q))||a.getAttributeNames().some(Q=>Q.startsWith("on"))))}function mn(a,m=10,g=600){let y=[];for(let O=0;O<a.children.length;O++)y.push({node:a.children[O],depth:1});let k=0;for(;y.length;){let{node:O,depth:Y}=y.pop();if(++k>g||Ce(O))return!0;if(!(Y>=m))for(let Q=0;Q<O.children.length;Q++)y.push({node:O.children[Q],depth:Y+1})}return!1}function tn(a){let m=a.tagName.toLowerCase(),g=a.getAttribute("role"),y=g?g.toLowerCase().trim():"",k=a.type?.toLowerCase();if(y&&$t.has(y))return y;if(y&&uo.has(y))return null;if(m==="a"&&a.hasAttribute("href"))return"link";if(m==="button")return"button";if(m==="input")return k==="hidden"?null:k==="checkbox"?"checkbox":k==="radio"?"radio":k==="range"?"slider":k==="number"?"spinbutton":k==="search"?"searchbox":["button","submit","reset","image","file"].includes(k)?"button":a.hasAttribute("list")?"combobox":"textbox";if(m==="textarea")return"textbox";if(m==="select"){let Ne=a;return Ne.multiple||Ne.size&&Ne.size>1?"listbox":"combobox"}if(m==="option")return"option";if(m==="form")return"form";if(m==="video"||m==="audio"){let Ne=lo(a);return a.hasAttribute("controls")||Ne.length>0?"media":null}if(a.isContentEditable||a.hasAttribute("contenteditable"))return"textbox";let O=G(a);if(!O.length)return null;let Y=!1,Q=!1,he=!1;for(let Ne=0;Ne<O.length;Ne++){let it=O[Ne];!Y&&zo.has(it)&&(Y=!0),!Q&&Zr.has(it)&&(Q=!0),!he&&es.has(it)&&(he=!0)}if(!Y&&!Q&&!he)return null;let Re=a.getAttribute("tabindex"),Ae=Re!==null&&!Number.isNaN(Number.parseInt(Re,10));if(Y&&(ls(a)||a.getAttribute("href")||a.closest("a[href]")))return"link";if(Q){if(a.isContentEditable||a.hasAttribute("contenteditable"))return"textbox";if(y==="textbox"||y==="searchbox"||y==="combobox"||y==="spinbutton")return y;if(!Y&&Ae)return"textbox"}if(Y){let Ne=a.getAttribute("aria-checked"),it=a.getAttribute("aria-pressed");if(Ne!==null||it!==null){if(y==="radio")return"radio";if(y==="menuitemradio")return"menuitemradio";if(y==="menuitemcheckbox")return"menuitemcheckbox";if(it!==null)return"button";if(Ne!==null)return"checkbox"}if((Ae||y==="button")&&!mn(a))return"button"}return he?"application":null}let gn=EventTarget.prototype.addEventListener,bn=EventTarget.prototype.removeEventListener;function Pn(a){let m=!1,g,y;return typeof a=="boolean"?m=a:a&&typeof a=="object"&&(m=!!a.capture,g=a.passive,y=a.once),{capture:m,passive:g,once:y}}function Lt(a){try{let m=a;if(m?.nodeType===9&&m?.documentElement)return m;let g=m?.document;if(g&&g.nodeType===9&&g.documentElement)return g}catch{}return null}function En(a,m,g){let y=K(m);if(!y)return;let{capture:k,passive:O,once:Y}=Pn(g),Q=r.get(a);Q||(Q=new Map,r.set(a,Q));let he=Q.get(y);if(he?(he.count+=1,he.capture=he.capture||k,he.passive=he.passive||O):Q.set(y,{count:1,capture:k,passive:O}),xn(a))try{B(a,{type:y,source:"native",capture:k,passive:O,once:Y})}catch{}let Re=Lt(a);if(Re&&(y==="click"||y==="input"||y==="keydown"))try{Re.documentElement?.setAttribute(`rtrvr-gl-${y}`,"1")}catch{}}function wn(a,m,g){let y=K(m);if(!y)return;let k=r.get(a);if(!k)return;let O=k.get(y);O&&(O.count-=1,O.count<=0&&k.delete(y),k.size===0&&r.delete(a))}A(window);function zs(a){if(!a||!a.fn)return;let m=a.fn.on,g=a.fn.off;function y(O){if(!O)return[];if(typeof O=="string")return O.split(/\s/).map(Y=>K(Y)).filter(Boolean);if(typeof O=="object")try{return Object.keys(O).map(Y=>K(Y)).filter(Boolean)}catch{return[]}return[]}function k(O){try{if(!O)return null;if(xn(O))return O;let Y=re(O);return Yo(O,Y)||null}catch{}return null}a.fn.on=function(O,Y){let Q=y(O),he=typeof Y=="string"&&!!Y;return this.each(function(){let Re=k(this);if(Re){if(he){let Ae=s.get(Re);Ae||(Ae=[],s.set(Re,Ae));for(let Ne of Q){let it=`${Ne}::${Y}`;Ae.some(Dt=>`${Dt.type}::${Dt.selector}`===it)||(Ae.push({type:Ne,selector:Y}),Ae.length>400&&Ae.shift())}}else for(let Ae of Q)B(Re,{type:Ae,source:"jquery"});Ee(Re,"jquery"),ce("jquery"),o.jqueryRoots.add(Re)}}),m.apply(this,arguments)},a.fn.off=function(){return g.apply(this,arguments)},ce("jquery")}function Wt(a){fe.some(g=>a.hasAttribute(g))&&(B(a,{type:"click",source:"other",inferred:!0}),(a.tagName==="INPUT"||a.tagName==="TEXTAREA")&&(B(a,{type:"input",source:"other",inferred:!0}),B(a,{type:"change",source:"other",inferred:!0})))}function io(a){let m=re(a),g=Ve(a,m),y=a.getAttributeNames().some(he=>he.startsWith("on")),k=/^(button|a|input|select|textarea|summary)$/i.test(a.tagName),O=a,Y=g&&(Zo(a)||!!O.isContentEditable||a.hasAttribute("contenteditable")),Q=g&&!!O.draggable;if(!y&&!k&&!Y&&!Q){Wt(a);return}for(let[he,Re]of Object.entries(ie))typeof a[he]=="function"&&B(a,{type:Re,source:"inline"});Y&&(B(a,{type:"input",source:"other",inferred:!0}),B(a,{type:"keydown",source:"other",inferred:!0}),B(a,{type:"keyup",source:"other",inferred:!0}),B(a,{type:"paste",source:"other",inferred:!0})),Q&&(B(a,{type:"dragstart",source:"other",inferred:!0}),B(a,{type:"dragend",source:"other",inferred:!0})),Wt(a)}function ao(a){if(!a.startsWith("on")||a.length<=2)return null;if(a.endsWith("Capture")){let g=a.substring(2,a.length-7);return g?{type:g.toLowerCase(),capture:!0}:null}let m=a.substring(2);return m?{type:m.toLowerCase(),capture:!1}:null}function i(a){let m=null;if(a){for(let g in a)if(g.startsWith("__react")||g.startsWith("_react")||g.includes("reactFiber")||g.includes("reactProps")||g.includes("reactInternalInstance")){m=g;break}if(m)try{let g=a[m],y=g?.memoizedProps||g?.pendingProps;if(y&&typeof y=="object"){for(let k in y){if(typeof y[k]!="function")continue;let Y=ao(k);Y&&B(a,{type:Y.type,source:"react",capture:Y.capture})}xn(g?.stateNode)&&o.reactRoots.add(g.stateNode),Ee(a,"react"),ce("react")}}catch{}}}function w(a){let m=a,g=!1;if(m.__vue__){g=!0;let y=m.__vue__;y.$listeners&&Object.keys(y.$listeners).forEach(k=>B(a,{type:k,source:"vue"})),y._events&&Object.keys(y._events).forEach(k=>B(a,{type:k,source:"vue"})),y.$options?._parentListeners&&Object.keys(y.$options._parentListeners).forEach(k=>B(a,{type:k,source:"vue"})),o.vueRoots.add(a)}if(m._vnode?.props){g=!0;let y=m._vnode.props;Object.keys(y).forEach(k=>{k.startsWith("on")&&k.length>2&&B(a,{type:k.substring(2).toLowerCase(),source:"vue"})}),o.vueRoots.add(a)}g&&(Ee(a,"vue"),ce("vue"))}function b(a){let m=a,g=!1;if(m.__ngContext__||a.hasAttribute("_ngcontent")||a.hasAttribute("ng-version")){g=!0,Array.from(a.attributes).forEach(y=>{if(y.name.startsWith("(")&&y.name.endsWith(")")){let k=y.name.slice(1,-1).split(".")[0];k&&B(a,{type:k,source:"angular"})}if(y.name.startsWith("on-")){let k=y.name.substring(3);k&&B(a,{type:k,source:"angular"})}if(y.name.includes(".")){let k=y.name.match(/\(([^.)]+)/);k?.[1]&&B(a,{type:k[1],source:"angular"})}});try{if(e.ng?.getComponent){let y=e.ng.getComponent(a);y&&Object.keys(y).forEach(k=>{(k.endsWith("Output")||k.endsWith("Emitter"))&&B(a,{type:k.replace(/(Output|Emitter)$/,"").toLowerCase(),source:"angular"})})}}catch{}}g&&(Ee(a,"angular"),ce("angular"),o.angularRoots.add(a))}function E(a){let m=a,g=!1;if(m.__svelte__){g=!0,Array.from(a.attributes).forEach(y=>{if(y.name.startsWith("on:")){let k=y.name.substring(3);k&&B(a,{type:k,source:"svelte"})}});try{let y=m.__svelte__?.$$?.callbacks;y&&typeof y=="object"&&Object.keys(y).forEach(k=>B(a,{type:k,source:"svelte"}))}catch{}o.svelteRoots.add(a)}g&&(Ee(a,"svelte"),ce("svelte"))}function d(a,m){return a?!!r.get(a)?.has(m):!1}function u(a,m,g=96){let y=K(m);if(!y)return!1;let k=V(a),O=q(k);if(d(k,y)||d(O,y))return!0;let Y=0,Q=a;for(;Q&&Y<g;){if(Q.parentElement)Q=Q.parentElement;else{let he=Q.getRootNode?.();if(yt(he)){if(d(he,y)||d(he.host,y))return!0;Q=he.host}else break}if(Q&&d(Q,y))return!0}return!1}function h(a,m,g=128){let y=0,k=a;for(;k&&y<g;){if(m(k),k.parentElement){k=k.parentElement;continue}let O=k.getRootNode?.();if(yt(O)){k=O.host;continue}break}}function v(a){let m=re(a);if(!Ve(a,m))return;let g=Pt(a);g.role=g.role||tn(a);let y=u(a,"click"),k=u(a,"input"),O=u(a,"keydown"),Q=V(a).documentElement;if(o.frameworks.size>0||Q.hasAttribute("rtrvr-react")||Q.hasAttribute("rtrvr-vue")||Q.hasAttribute("rtrvr-angular")||Q.hasAttribute("rtrvr-svelte")||Q.hasAttribute("rtrvr-jquery")||y||k||O){let Re=g.role||"other";y&&["button","link","checkbox","radio","switch","menuitem","menuitemcheckbox","menuitemradio","tab","option","treeitem","gridcell","cell","img","figure"].includes(Re)&&B(a,{type:"click",source:"delegated",inferred:!0}),["textbox","searchbox","spinbutton","code"].includes(Re)&&(k&&(B(a,{type:"input",source:"delegated",inferred:!0}),B(a,{type:"change",source:"delegated",inferred:!0})),O&&B(a,{type:"keydown",source:"delegated",inferred:!0})),["combobox","listbox"].includes(Re)&&(y&&B(a,{type:"click",source:"delegated",inferred:!0}),k&&B(a,{type:"change",source:"delegated",inferred:!0})),["slider","scrollbar","progressbar","meter"].includes(Re)&&k&&B(a,{type:"input",source:"delegated",inferred:!0})}h(a,Re=>{let Ae=s.get(Re);if(Ae?.length)for(let{type:Ne,selector:it}of Ae)try{a.matches(it)&&(B(a,{type:Ne,source:"jquery",inferred:!0}),Ee(a,"jquery"),ce("jquery"))}catch{}})}function C(a){let m=g=>{let y=g,k=y.composedPath&&y.composedPath()||pt(g.target),Y=a==="mousemove"||a==="pointermove"||a==="scroll"||a==="wheel"?1:Math.min(k.length,X);for(let Q=0;Q<Y;Q++){let he=k[Q];xn(he)&&B(he,{type:a,source:"delegated",inferred:!0})}};Kt(m);try{gn.call(document,a,m,{capture:!0,passive:!0})}catch{}}let I=!1;function N(){J.forEach(C);let a=Ye()?.documentElement;if(!a)return;let m=()=>{if(I)return;let g=a.hasAttribute("rtrvr-react")||a.hasAttribute("rtrvr-vue")||a.hasAttribute("rtrvr-angular")||a.hasAttribute("rtrvr-svelte"),y=a.hasAttribute("rtrvr-gl-click")||a.hasAttribute("rtrvr-gl-input")||a.hasAttribute("rtrvr-gl-keydown");(g||y)&&(I=!0,Z.forEach(C))};m();try{new MutationObserver(()=>m()).observe(a,{attributes:!0,attributeFilter:["rtrvr-react","rtrvr-vue","rtrvr-angular","rtrvr-svelte","rtrvr-gl-click","rtrvr-gl-input","rtrvr-gl-keydown"]})}catch{}}function U(a){if(a.nodeType!==1)return;let m=re(a);if(Ve(a,m)){let g=Pt(a);g.role=void 0}io(a),i(a),w(a),b(a),E(a),v(a),un(a)}function $(){let a=["a[href]","button","input","select","textarea","summary","details > summary",...Array.from($t).map(m=>`[role="${m}"]`),"[onclick]","[ondblclick]","[ondoubleclick]","[onmousedown]","[tabindex]","[contenteditable]",'[draggable="true"]',"[aria-haspopup]","[aria-expanded]","[data-click]","[data-action]","[data-handler]","[data-toggle]","[data-target]",".clickable",".interactive",".btn",".button"];F++,ht();try{let m=a.join(",");Ye()?.querySelectorAll(m).forEach(g=>{try{U(g)}catch{}})}finally{F=Math.max(0,F-1),ht()}}function z(a){for(let m of a){for(let g of Array.from(m.addedNodes)){if(g.nodeType!==1)continue;let y=g;Bt(y),y.querySelectorAll?.('a,button,input,select,textarea,summary,[role],[onclick],[ondblclick],[ondoubleclick],[contenteditable],[draggable="true"],[tabindex]').forEach(Bt)}if(m.type==="attributes"&&m.target.nodeType===1){let g=m.target;m.attributeName==="class"?(Jt()||Qt(g))&&Bt(g):Bt(g)}}}async function ne(a={}){let m=Ye(),g=m?.documentElement;if(!g||!(g.hasAttribute("rtrvr-react")||g.hasAttribute("rtrvr-vue")||g.hasAttribute("rtrvr-angular")||g.hasAttribute("rtrvr-svelte")))return;let k=a.deadlineEpochMs,O=Math.max(5,Math.min(a.budgetMs??12,50));if(Math.max(0,Math.min(O,Oe(k)))<=0)return;let Q=performance.now();F++,ht();try{let he=0,Re=4e3,Ae=["div","span","li","section","article","p"];for(let Ne of Ae){let it=m.getElementsByTagName(Ne)??[];for(let Dt=0;Dt<it.length;Dt++){if(he++>=Re||k&&Oe(k)<=0)return;let Bn=it[Dt],Xe=Bn;(Xe.__ngContext__||Xe.__svelte__||Xe.__vue__||Xe._vnode||fn(Bn))&&U(Bn),he%250===0&&Oe(k)>20&&await vt()}}}finally{F=Math.max(0,F-1),ht()}}let me=new MutationObserver(z),oe=new WeakMap;function ae(a){if(!oe.has(a)&&!(R>=l))try{let m=q(a.ownerDocument).MutationObserver||MutationObserver,g=new m(z);oe.set(a,g),R++,g.observe(a,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...D,"class"]})}catch{}}let le=new WeakMap;function ke(a){if(!le.has(a)&&!(p>=f))try{A(a.defaultView||null);let m=a.documentElement;if(!m)return;let g=q(a).MutationObserver||MutationObserver,y=new g(z);le.set(a,y),p++,y.observe(m,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...D,"class"]})}catch{}}function qe(){let a=Ye()?.documentElement;a&&me.observe(a,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...D,"class"]})}let ge=new WeakMap;function _e(a){return a.shadowRoot||ge.get(a)||null}try{Object.defineProperty(pn,"shadow",{value:Object.freeze({getRoot:a=>_e(a)}),writable:!1,configurable:!1,enumerable:!1})}catch{}function ye(){try{(e.React||e.__REACT_DEVTOOLS_GLOBAL_HOOK__)&&ce("react"),e.Vue&&ce("vue"),e.ng&&ce("angular"),e.jQuery&&ce("jquery"),ve()}catch{}}e.rtrvrAIMarkInteractiveElements=function(){return Ye()?.body?($(),!0):!1};function Ie(){let a=Ye();ve(),ye(),N();let m=()=>{ve(),ye(),qe(),e.rtrvrAIMarkInteractiveElements?.(),ne({budgetMs:20}),a?.documentElement.setAttribute(Kr,"1")};a?.readyState==="loading"?a.addEventListener("DOMContentLoaded",m,{once:!0}):m()}Ie()})();var yr=null;function Ss(e){try{return e.getAttribute(nn)}catch{return null}}function Ua(e){let t=Ss(e);return vn(t)?.entries??[]}function Fa(e){try{let t=e.getAttribute(Gt);return t&&t.trim()?t:null}catch{return null}}function Vu(e){let t=e?.ownerDocument?.defaultView,n=t?.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",r=t?.[n]?.shadow?.getRoot;if(typeof r=="function")try{return r(e)||null}catch{}return e.shadowRoot||null}function $u(e){let t=new Set;for(let n of e){let o=Ho(n.mask);for(let r of o)(r==="react"||r==="vue"||r==="angular"||r==="svelte"||r==="jquery")&&t.add(r)}return t}function Gu(e){let t=new Set,n=e;return(n.__reactFiber||n.__reactProps||n.__reactInternalInstance||n.__reactRootContainer)&&t.add("react"),(n.__vue__||n.__vueParentComponent||n.__vnode||n.__vue_app__)&&t.add("vue"),n.__ngContext__&&t.add("angular"),(n.__svelte||n.__svelte_meta)&&t.add("svelte"),(n.__jquery||n.jQuery)&&t.add("jquery"),t}function Yu(e){let t=Ua(e),n=$u(t),o=Gu(e);for(let r of o)n.add(r);return{frameworks:[...n],listenersRaw:Ss(e)||"",role:Fa(e)??(e.getAttribute?.("role")||null)}}function qu(){return{getEventHandlerIds:e=>Ua(e).map(t=>t.id),getRoleHint:Fa,getShadowRoot:Vu}}function Ha(e={}){if(yr)return yr;if(typeof window<"u")try{window.rtrvrAIMarkInteractiveElements?.()}catch{}return yr={signalProvider:qu(),getFrameworkMetadata:Yu,getListenerEncoding:Ss,dispose:()=>{}},yr}var Rr=class{constructor(t={}){W(this,"root");W(this,"includeFrames");W(this,"disableDomAnnotations");W(this,"allowActions");W(this,"runtimeId");W(this,"domainScopeMode");W(this,"allowedDomains");W(this,"externalNavigationPolicy");W(this,"registerOpenedTab");W(this,"listKnownTabs");W(this,"switchToLogicalTab");W(this,"onNavigationGuardrail");W(this,"instrumentation");W(this,"highlightEl",null);W(this,"clientTools",new Map);W(this,"uploadStore",new Map);W(this,"uploadProviderInstalled",!1);this.root=t.root??document.body??document.documentElement,this.includeFrames=t.includeFrames??!0,this.disableDomAnnotations=t.disableDomAnnotations??!0,this.allowActions=t.allowActions??!0,this.runtimeId=t.runtimeId,this.domainScopeMode=Pa(t.domainScopeMode),this.allowedDomains=ks(t.allowedDomains,window.location.hostname,this.domainScopeMode),this.externalNavigationPolicy=Ba(t.externalNavigationPolicy,t.crossDomainPolicy),this.registerOpenedTab=t.registerOpenedTab,this.listKnownTabs=t.listKnownTabs,this.switchToLogicalTab=t.switchToLogicalTab,this.onNavigationGuardrail=t.onNavigationGuardrail,this.instrumentation=t.instrumentation??Ha({includeIframes:!0,scanInlineHandlers:!0,observeInlineMutations:!0,...t.instrumentationOptions||{}}),Sa(),t.uploadBytesProvider&&this.setUploadBytesProvider(t.uploadBytesProvider)}setAllowActions(t){this.allowActions=!!t}setNavigationPolicy(t){t.domainScopeMode&&(this.domainScopeMode=Pa(t.domainScopeMode),t.allowedDomains||(this.allowedDomains=ks(void 0,window.location.hostname,this.domainScopeMode))),t.allowedDomains&&(this.allowedDomains=ks(t.allowedDomains,window.location.hostname,this.domainScopeMode)),(t.externalNavigationPolicy||t.crossDomainPolicy)&&(this.externalNavigationPolicy=Ba(t.externalNavigationPolicy,t.crossDomainPolicy))}async getSnapshot(){return await $a(this.root),pr(this.root,this.instrumentation,{includeFrames:this.includeFrames,disableDomAnnotations:this.disableDomAnnotations})}async getPageData(t){return await $a(this.root),await La(this.root,this.instrumentation,{includeFrames:this.includeFrames,disableDomAnnotations:this.disableDomAnnotations,pageConfig:t?.pageConfig})}async executeTool(t,n){let o=Xu(t?.name);if(!o)return{success:!1,error:`Unknown tool: ${String(t?.name)}`,allowFallback:!1};if(this.shouldBlockForOutOfScopeContext(o)){let S=`Current tab is outside the allowed domain scope (${xr(this.allowedDomains)}).`;return this.domainScopeBlockedResponse(window.location.href,S,{fromCurrentContext:!0})}if(!this.allowActions&&!Va.has(o))return{success:!1,error:"Actions disabled by configuration",allowFallback:!1};let r=await this.handleNavigationTools(o,t?.args||{});if(r)return r;if(o===M.wait_action){let S=Number(t?.args?.duration??1e3);return await new Promise(x=>setTimeout(x,Math.max(0,Math.min(S,6e4)))),{success:!0}}if(o===M.wait_for_element)return this.waitForElement(t?.args||{});if(o===M.answer_task)return{success:!0};if(o===M.solve_captcha)return vr("CAPTCHA solving requires human intervention in embed mode.","HUMAN_INTERVENTION_REQUIRED");if(o===M.dispatch_pointer_path)return vr("dispatch_pointer_path is not yet supported in embed mode.","CAPABILITY_UNAVAILABLE");if(o===M.click_element&&t?.args?.open_in_new_tab)return this.openElementInNewTab(t?.args||{});if(o===M.click_element&&this.shouldInterceptExternalClick(t?.args||{})){let S=this.getExternalClickTargetUrl(t?.args||{});if(S){let x=`Blocked same-tab navigation to out-of-scope domain (${new URL(S).hostname}).`;return this.externalNavigationPolicy==="open_new_tab_notice"?this.openUrlInNewTab(S,{policyBlocked:!0,reason:x}):this.domainScopeBlockedResponse(S,x)}}if(o===M.describe_images)return this.describeImages(t?.args||{});if(!(o in Fo))return{success:!1,error:`Unknown tool: ${String(t?.name)}`,allowFallback:!1};let s=t?.args||{},{doc:c}=Kn(document,s.iframe_id),l=s.element_id??s.source_element_id??s.target_element_id??s.center_element_id??null,f=l?Ct(c,l):null,R;if(f){let S=this.instrumentation.getFrameworkMetadata(f),x=ed(S.listenersRaw||"",o),A=s?.value??s?.text??null;R=Zu({...S,pattern:x,value:A})}let p=Fo[o];return o===M.upload_file&&!n&&(n=await this.buildUploadPayload(s).catch(()=>{})),ka({opcode:p,call:{name:o,args:s},elementData:R,tabIndex:0,payload:n})}highlight(t){let n=Ct(document,t);if(!n)return;let o=n.getBoundingClientRect();if(!this.highlightEl){let r=document.createElement("div");r.style.position="fixed",r.style.pointerEvents="none",r.style.border="2px solid #ff7a59",r.style.boxShadow="0 0 0 2px rgba(255, 122, 89, 0.2)",r.style.borderRadius="6px",r.style.zIndex="2147483647",this.highlightEl=r,document.body.appendChild(r)}this.highlightEl.style.left=`${o.left}px`,this.highlightEl.style.top=`${o.top}px`,this.highlightEl.style.width=`${Math.max(0,o.width)}px`,this.highlightEl.style.height=`${Math.max(0,o.height)}px`,this.highlightEl.style.display="block"}clearHighlight(){this.highlightEl&&(this.highlightEl.style.display="none")}setUploadBytesProvider(t){window.__ROVER_UPLOAD_BYTES__=t}registerTool(t,n){let o=typeof t=="string"?{name:t}:t;!o?.name||typeof n!="function"||this.clientTools.set(o.name,{handler:n,def:o})}async executeClientTool(t,n){let o=this.clientTools.get(t);if(!o)throw new Error(`Unknown client tool: ${t}`);return o.handler(n)}listClientTools(){return Array.from(this.clientTools.values()).map(t=>t.def)}async handleNavigationTools(t,n){switch(t){case M.goto_url:{let o=String(n.url||"").trim();if(!o)return{success:!1,error:"goto_url: missing url",allowFallback:!0};let r=_r(o,window.location.href);if(!r)return{success:!1,error:`goto_url: invalid url "${o}"`,allowFallback:!0};if(this.shouldGuardExternalNavigation(r)){let s=`Navigation blocked by domain policy. Allowed: ${xr(this.allowedDomains)}`;return this.externalNavigationPolicy==="open_new_tab_notice"?await this.openUrlInNewTab(r,{policyBlocked:!0,reason:s}):this.domainScopeBlockedResponse(r,s)}return window.location.href=r,{success:!0,output:{url:r,navigation:"same_tab"}}}case M.google_search:{let o=String(n.query||"").trim();if(!o)return{success:!1,error:"google_search: missing query",allowFallback:!0};let r=`https://www.google.com/search?q=${encodeURIComponent(o)}`;if(this.shouldGuardExternalNavigation(r)){let s=`Google search opens outside the allowed domain scope (${xr(this.allowedDomains)}).`;return this.externalNavigationPolicy==="open_new_tab_notice"?await this.openUrlInNewTab(r,{policyBlocked:!0,reason:s}):this.domainScopeBlockedResponse(r,s)}return window.location.href=r,{success:!0,output:{url:r,navigation:"same_tab"}}}case M.go_back:return window.history.back(),{success:!0};case M.go_forward:return window.history.forward(),{success:!0};case M.refresh_page:return window.location.reload(),{success:!0};case M.open_new_tab:{let o=String(n.url||"").trim();if(!o)return{success:!1,error:"open_new_tab: missing url",allowFallback:!0};let r=_r(o,window.location.href);return r?await this.openUrlInNewTab(r,{policyBlocked:!1}):{success:!1,error:`open_new_tab: invalid url "${o}"`,allowFallback:!0}}case M.switch_tab:{let o=Number(n.logical_tab_id??n.tab_id);if(!Number.isFinite(o)||o<=0)return{success:!1,error:"switch_tab: missing/invalid logical_tab_id",allowFallback:!0};if(this.externalNavigationPolicy!=="allow"&&this.listKnownTabs){let r=this.listKnownTabs().find(s=>Number(s.logicalTabId)===o);if(r?.external)return this.domainScopeBlockedResponse(r.url||`logical_tab_id:${o}`,`Tab ${o} is out of scope. Direct actions are blocked outside ${xr(this.allowedDomains)}.`)}if(!this.switchToLogicalTab)return vr("switch_tab requires session coordinator support.","CAPABILITY_UNAVAILABLE");try{let r=await this.switchToLogicalTab(o);return r?.ok?{success:!0,output:{logicalTabId:o,delegated:!!r.delegated,mode:r.delegated?"delegated":"local"}}:{success:!1,error:r?.reason||`switch_tab failed for logical tab ${o}`,allowFallback:!0}}catch(r){return{success:!1,error:r?.message||"switch_tab failed",allowFallback:!0}}}case M.close_tab:try{return window.close(),{success:!0}}catch{return vr("close_tab failed in embed mode.","CAPABILITY_UNAVAILABLE")}default:return null}}shouldGuardExternalNavigation(t){return this.externalNavigationPolicy==="allow"?!1:!Tr(t,this.allowedDomains)}shouldBlockForOutOfScopeContext(t){return this.externalNavigationPolicy==="allow"||Va.has(t)||Ju.has(t)?!1:!Tr(window.location.href,this.allowedDomains)}shouldInterceptExternalClick(t){if(this.externalNavigationPolicy==="allow")return!1;let n=this.getExternalClickTargetUrl(t);return n?!Tr(n,this.allowedDomains):!1}getExternalClickTargetUrl(t){let n=t.element_id??t.source_element_id??t.target_element_id??t.center_element_id??null;if(!n)return null;let{doc:o}=Kn(document,t.iframe_id),r=Ct(o,n);if(!r)return null;let s=Wa(r),c=s?.href||s?.getAttribute("href")||"";return _r(c,window.location.href)}domainScopeBlockedResponse(t,n,o){let r=this.externalNavigationPolicy==="block"?"block":"open_new_tab_notice";return this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:r,reason:n,allowedDomains:this.allowedDomains,openedInNewTab:!1}),{success:!1,error:n,allowFallback:!0,output:{success:!1,error:{code:"DOMAIN_SCOPE_BLOCKED",message:n,missing:[],next_action:r==="block"?"Stay on the configured domain or update allowedDomains/domainScopeMode.":"Use open_new_tab to access external pages without losing context.",retryable:!1},blocked_url:t,current_url:window.location.href,allowed_domains:this.allowedDomains,policy_action:r,from_current_context:!!o?.fromCurrentContext},errorDetails:{code:"DOMAIN_SCOPE_BLOCKED",message:n,retryable:!1,details:{blockedUrl:t,currentUrl:window.location.href,allowedDomains:this.allowedDomains,policyAction:r}}}}emitNavigationGuardrail(t){try{this.onNavigationGuardrail?.(t)}catch{}}async openUrlInNewTab(t,n){let o=!Tr(t,this.allowedDomains),r=window.open(t,"_blank","noopener,noreferrer"),s;if(this.registerOpenedTab)try{s=(await this.registerOpenedTab({url:t,title:void 0,external:o,openerRuntimeId:this.runtimeId}))?.logicalTabId}catch{}if(!r){let l="Browser popup settings blocked opening a new tab.";return n?.policyBlocked&&this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:"open_new_tab_notice",reason:n.reason||l,allowedDomains:this.allowedDomains,openedInNewTab:!1}),{success:!1,error:"open_new_tab blocked by browser popup settings",allowFallback:!0,output:{url:t,external:o,logicalTabId:s},errorDetails:{code:"POPUP_BLOCKED",message:l,retryable:!0,next_action:"Allow popups for this site and try again."}}}let c=n?.policyBlocked?n.reason||"Opened in a new tab due to domain policy.":void 0;return n?.policyBlocked&&this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:"open_new_tab_notice",reason:c||"Opened in new tab due to domain policy.",allowedDomains:this.allowedDomains,openedInNewTab:!0}),{success:!0,output:{url:t,external:o,logicalTabId:s,openedInNewTab:!0,policyBlocked:!!n?.policyBlocked,message:c},allowFallback:!0}}async openElementInNewTab(t){let n=t.element_id??t.source_element_id??t.target_element_id??t.center_element_id??null;if(!n)return{success:!1,error:"click_element with open_in_new_tab requires element_id.",allowFallback:!0};let{doc:o}=Kn(document,t.iframe_id),r=Ct(o,n);if(!r)return{success:!1,error:`click_element: element_id ${String(n)} not found.`,allowFallback:!0};let s=Wa(r),c=s?.href||s?.getAttribute("href")||"",l=_r(c,window.location.href);return l?await this.openUrlInNewTab(l,{policyBlocked:!1}):{success:!1,error:"click_element open_in_new_tab only works when target resolves to a valid link URL.",allowFallback:!0}}async waitForElement(t){let n=String(t.selector||"").trim(),o=Math.max(0,Math.min(Number(t.timeout??5e3),3e4));if(!n)return{success:!1,error:"wait_for_element: missing selector",allowFallback:!0};let r=Date.now(),s=document;for(;Date.now()-r<o;){let c=null;try{c=s.querySelector(n)}catch{c=null}if(c||(c=td(s,n)),c)return{success:!0};await new Promise(l=>setTimeout(l,200))}return{success:!1,error:`wait_for_element: not found (${n})`,allowFallback:!0}}async describeImages(t){let n=Qs(t);if(!n.length)return{success:!1,error:"describe_images: element_ids is empty",allowFallback:!1};let o=[],r=[];for(let s of n){let c=Ct(document,s);if(!c){r.push(`element_id ${s} not found`);continue}try{let l=await nd(c);if(!l?.data||!l?.mimeType){r.push(`element_id ${s}: unsupported image`);continue}o.push({element_id:s,...l})}catch(l){r.push(`element_id ${s}: ${l?.message||String(l)}`)}}return o.length?{success:!0,output:{images:o,errors:r.length?r:void 0}}:{success:!1,error:r[0]||"describe_images failed",output:{images:[],errors:r}}}ensureUploadProvider(){this.uploadProviderInstalled||(this.uploadProviderInstalled=!0,this.setUploadBytesProvider(async({token:t,byteLength:n})=>{this.pruneUploadStore();let o=this.uploadStore.get(t);if(!o)throw new Error("upload bytes token not found");if(o.bytes.byteLength!==n)throw new Error("upload bytes size mismatch");return o.bytes}))}pruneUploadStore(){let t=Date.now()-6e5;for(let[n,o]of this.uploadStore.entries())o.createdAt<t&&this.uploadStore.delete(n)}async buildUploadPayload(t){let n=String(t.file_url||"").trim();if(n)try{let o=await xa(0,n,document?.referrer||null),r=o.bytes,s=r.byteLength,c=o.mimeType||t.mime_type||"application/octet-stream",l=t.file_name||o.fileName,f=1024*1024;if(s<=f)return{kind:"upload_file",inlineB64:Ya(r),byteLength:s,mimeType:c,fileName:l};this.ensureUploadProvider();let R=crypto.randomUUID();return this.uploadStore.set(R,{bytes:r,createdAt:Date.now()}),{kind:"upload_file",token:R,byteLength:s,mimeType:c,fileName:l,durable:!1}}catch{return}}};function Xu(e){return e==="open_url_new_tab"?M.open_new_tab:String(e||"").trim()}function Pa(e){return e==="host_only"?"host_only":"registrable_domain"}function ju(e){if(e==="allow")return"allow";if(e==="block_new_tab")return"open_new_tab_notice"}function Ba(e,t){return e==="allow"||e==="block"||e==="open_new_tab_notice"?e:ju(t)||"open_new_tab_notice"}function ks(e,t,n){let o=Array.isArray(e)?e:[],r=new Set;for(let s of o){let c=String(s||"").trim().toLowerCase().replace(/^\./,"");c&&r.add(c)}if(!r.size){let s=zu(t,n);s&&r.add(s)}return Array.from(r)}function zu(e,t){let n=String(e||"").trim().toLowerCase();if(!n)return"";if(n==="localhost"||/^\\d+\\.\\d+\\.\\d+\\.\\d+$/.test(n))return`=${n}`;if(t==="host_only")return`=${n}`;let o=n.split(".").filter(Boolean);return o.length<2?n:`${o[o.length-2]}.${o[o.length-1]}`}function _r(e,t){let n=String(e||"").trim();if(!n)return null;try{return new URL(n,t).toString()}catch{return null}}function Tr(e,t){let n=Ku(e);if(!n)return!1;if(!t.length)return!0;for(let o of t)if(Qu(n,o))return!0;return!1}function Ku(e){try{return new URL(e).hostname.toLowerCase()}catch{return null}}function Qu(e,t){let n=String(t||"").trim().toLowerCase().replace(/^\./,"");if(!n)return!1;if(n==="*")return!0;if(n.startsWith("=")){let o=n.slice(1);return!!o&&e===o}if(n.startsWith("*.")){let o=n.slice(2);return o?e===o||e.endsWith(`.${o}`):!1}return e===n?!0:e.endsWith(`.${n}`)}function xr(e){return e.length?e.map(t=>{let n=String(t||"");return n.startsWith("=")?n.slice(1):n}).join(", "):"*"}function Wa(e){if(e instanceof HTMLAnchorElement&&e.href)return e;let t=e.closest?.("a[href]");return t instanceof HTMLAnchorElement&&t.href?t:null}function vr(e,t="CAPABILITY_UNAVAILABLE"){return{success:!1,error:e,allowFallback:!0,errorDetails:{code:t,message:e,retryable:!1}}}var Va=new Set([M.describe_images,M.wait_action,M.wait_for_element,M.answer_task,M.solve_captcha,M.network_run_recipe]),Ju=new Set([M.goto_url,M.google_search,M.go_back,M.go_forward,M.refresh_page,M.open_new_tab,M.switch_tab,M.close_tab]);function Zu(e){return{frameworks:(e.frameworks||[]).filter(n=>n in qr).map(n=>qr[n]),listenersRaw:e.listenersRaw??"",role:e.role??null,pattern:e.pattern,value:e.value??null}}async function $a(e){try{let n=(e.ownerDocument||document).defaultView||window,o=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",s=n[o]?.flushScan;if(typeof s=="function"){await s({mode:"priority",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:1500});return}n.rtrvrAIMarkInteractiveElements?.()}catch{}}function ed(e,t){if(t!==M.click_element)return"standard";let n=vn(e||"");if(!n)return"standard";let o=new Set(n.entries.map(f=>Vt[f.id]).filter(f=>typeof f=="string")),r=o.has("click")||o.has("mousedown")||o.has("mouseup")||o.has("pointerdown")||o.has("pointerup")||o.has("touchend");if((o.has("mouseenter")||o.has("mouseover")||o.has("pointerenter"))&&r)return"hover-activate";let c=o.has("touchstart"),l=o.has("touchend");return c&&l?"touch-sequence":"standard"}function Ya(e){let t=new Uint8Array(e),n="",o=32768;for(let r=0;r<t.length;r+=o)n+=String.fromCharCode(...t.subarray(r,r+o));return btoa(n)}function td(e,t){let n=t.toLowerCase(),o=["button","a","input","textarea","select","label","[role]","div","span"],r=e.querySelectorAll(o.join(","));for(let s of Array.from(r))if((s.textContent||"").trim().toLowerCase().includes(n)||(s.getAttribute("aria-label")||"").toLowerCase().includes(n))return s;return null}async function nd(e){if(e instanceof HTMLCanvasElement){let r=e.toDataURL(),s=qa(r);if(!s)throw new Error("canvas toDataURL failed");return s}if(e instanceof SVGElement){let r=new XMLSerializer().serializeToString(e);return{data:btoa(unescape(encodeURIComponent(r))),mimeType:"image/svg+xml",displayName:"svg"}}if(e instanceof HTMLImageElement){let r=e.currentSrc||e.src;return await Ga(r,e.alt||e.getAttribute("aria-label")||void 0)}let n=window.getComputedStyle(e).backgroundImage||"",o=/url\\((['\"]?)(.*?)\\1\\)/.exec(n);if(o?.[2])return await Ga(o[2],e.getAttribute("aria-label")||void 0);throw new Error("unsupported element")}function qa(e){let t=/^data:([^;]+);base64,(.*)$/.exec(e);return t?{mimeType:t[1],data:t[2]}:null}async function Ga(e,t){if(!e)throw new Error("missing src");if(e.startsWith("data:")){let l=qa(e);if(!l)throw new Error("invalid data url");return{...l,displayName:t}}let n=await fetch(e,{mode:"cors"});if(!n.ok)throw new Error(`fetch failed (${n.status})`);let o=await n.blob(),r=await o.arrayBuffer(),s=Ya(r),c=o.type||"image/png";return{data:s,mimeType:c,displayName:t}}function Xa(e,t){e.onmessage=async n=>{let o=n.data;if(!o||o.t!=="req")return;let{id:r,method:s,params:c}=o;try{let l=t[s];if(!l)throw new Error(`No handler for ${s}`);let f=await l(c);e.postMessage({t:"res",id:r,ok:!0,result:f})}catch(l){e.postMessage({t:"res",id:r,ok:!1,error:{message:l?.message||String(l)}})}}}var od="https://www.rtrvr.ai/rover/mascot.mp4",rd="https://www.rtrvr.ai/rover/mascot.webm";function za(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function ja(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function sd(e){return e.status?e.status:e.kind==="tool_start"||e.kind==="plan"||e.kind==="thought"?"pending":e.kind==="tool_result"?"success":e.kind==="error"?"error":"info"}function id(e){let t=String(e.title||"").trim().toLowerCase();return t.startsWith("running ")?`tool:${t.replace(/^running\s+/,"").trim()}`:t.endsWith(" completed")?`tool:${t.replace(/\s+completed$/,"").trim()}`:t==="run started"||t==="run resumed"||t==="run completed"?"run":e.kind==="status"?`status:${t||"status"}`:e.id||za("trace")}function eo(e){return String(e||"").trim()}function ad(e){let t=eo(e),n=/^(Analyze|Route|Execute|Verify|Complete):\s*(.*)$/i.exec(t);if(!n)return{plainTitle:t};let o=n[1].toLowerCase(),r=eo(n[2]||t);return{stage:o,plainTitle:r||t}}function Ka(e){let t=document.createElement("div");t.id="rover-widget-root",document.documentElement.appendChild(t);let n=t.attachShadow({mode:"closed"}),o=document.createElement("style");o.textContent=`
|
|
11
|
+
:host {
|
|
12
|
+
all: initial;
|
|
13
|
+
--rv-bg-0: #fffdfa;
|
|
14
|
+
--rv-bg-1: #fff4eb;
|
|
15
|
+
--rv-surface: rgba(255, 255, 255, 0.94);
|
|
16
|
+
--rv-border: rgba(255, 102, 45, 0.24);
|
|
17
|
+
--rv-text: #132033;
|
|
18
|
+
--rv-subtext: #5f6c7f;
|
|
19
|
+
--rv-accent: #f45d05;
|
|
20
|
+
--rv-accent-2: #ff8b46;
|
|
21
|
+
--rv-success: #059669;
|
|
22
|
+
--rv-error: #dc2626;
|
|
23
|
+
--rv-info: #2563eb;
|
|
24
|
+
}
|
|
25
|
+
.rover { all: initial; font-family: 'Sora', 'Manrope', 'Space Grotesk', system-ui, -apple-system, Segoe UI, sans-serif; }
|
|
26
|
+
.rover * { box-sizing: border-box; }
|
|
27
|
+
|
|
28
|
+
.launcher {
|
|
29
|
+
position: fixed;
|
|
30
|
+
right: 20px;
|
|
31
|
+
bottom: 20px;
|
|
32
|
+
width: 58px;
|
|
33
|
+
height: 58px;
|
|
34
|
+
border-radius: 18px;
|
|
35
|
+
border: 1px solid var(--rv-border);
|
|
36
|
+
background: linear-gradient(140deg, var(--rv-accent), var(--rv-accent-2));
|
|
37
|
+
box-shadow: 0 18px 44px rgba(244, 93, 5, 0.3);
|
|
38
|
+
color: #fff;
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
z-index: 2147483647;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
display: grid;
|
|
43
|
+
place-items: center;
|
|
44
|
+
padding: 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.launcher video {
|
|
48
|
+
width: 100%;
|
|
49
|
+
height: 100%;
|
|
50
|
+
object-fit: cover;
|
|
51
|
+
border-radius: inherit;
|
|
52
|
+
transition: filter 180ms ease, transform 180ms ease;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.rover[data-mood="running"] .launcher video,
|
|
56
|
+
.rover[data-mood="running"] .avatar video {
|
|
57
|
+
filter: saturate(1.2);
|
|
58
|
+
transform: scale(1.02);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.rover[data-mood="typing"] .launcher {
|
|
62
|
+
box-shadow: 0 20px 54px rgba(37, 99, 235, 0.26);
|
|
63
|
+
border-color: rgba(37, 99, 235, 0.3);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.rover[data-mood="success"] .launcher {
|
|
67
|
+
box-shadow: 0 20px 54px rgba(5, 150, 105, 0.28);
|
|
68
|
+
border-color: rgba(5, 150, 105, 0.34);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.rover[data-mood="error"] .launcher {
|
|
72
|
+
box-shadow: 0 20px 54px rgba(220, 38, 38, 0.28);
|
|
73
|
+
border-color: rgba(220, 38, 38, 0.34);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.launcherFallback {
|
|
77
|
+
font-size: 14px;
|
|
78
|
+
font-weight: 700;
|
|
79
|
+
letter-spacing: 0.7px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.panel {
|
|
83
|
+
position: fixed;
|
|
84
|
+
right: 20px;
|
|
85
|
+
bottom: 90px;
|
|
86
|
+
width: min(460px, calc(100vw - 20px));
|
|
87
|
+
height: min(680px, calc(100vh - 110px));
|
|
88
|
+
min-width: 320px;
|
|
89
|
+
min-height: 460px;
|
|
90
|
+
max-width: min(720px, calc(100vw - 16px));
|
|
91
|
+
max-height: calc(100vh - 16px);
|
|
92
|
+
background:
|
|
93
|
+
radial-gradient(120% 80% at 100% 0%, rgba(255, 109, 37, 0.14), transparent 52%),
|
|
94
|
+
linear-gradient(180deg, var(--rv-bg-0), var(--rv-bg-1));
|
|
95
|
+
border: 1px solid var(--rv-border);
|
|
96
|
+
border-radius: 24px;
|
|
97
|
+
box-shadow: 0 30px 90px rgba(244, 93, 5, 0.18), 0 14px 36px rgba(15, 23, 42, 0.16);
|
|
98
|
+
display: none;
|
|
99
|
+
flex-direction: column;
|
|
100
|
+
overflow: hidden;
|
|
101
|
+
z-index: 2147483646;
|
|
102
|
+
color: var(--rv-text);
|
|
103
|
+
backdrop-filter: blur(14px);
|
|
104
|
+
-webkit-backdrop-filter: blur(14px);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.panel.open { display: flex; }
|
|
108
|
+
|
|
109
|
+
.header {
|
|
110
|
+
display: flex;
|
|
111
|
+
align-items: center;
|
|
112
|
+
gap: 8px;
|
|
113
|
+
padding: 10px 12px;
|
|
114
|
+
border-bottom: 1px solid rgba(255, 76, 0, 0.14);
|
|
115
|
+
background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(255, 244, 236, 0.9));
|
|
116
|
+
min-height: 48px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.avatar {
|
|
120
|
+
width: 34px;
|
|
121
|
+
height: 34px;
|
|
122
|
+
border-radius: 999px;
|
|
123
|
+
overflow: hidden;
|
|
124
|
+
border: 1px solid rgba(255, 76, 0, 0.22);
|
|
125
|
+
background: #fff;
|
|
126
|
+
flex: 0 0 auto;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.avatar video {
|
|
130
|
+
width: 100%;
|
|
131
|
+
height: 100%;
|
|
132
|
+
object-fit: cover;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.avatarFallback {
|
|
136
|
+
width: 100%;
|
|
137
|
+
height: 100%;
|
|
138
|
+
display: grid;
|
|
139
|
+
place-items: center;
|
|
140
|
+
color: #ff4c00;
|
|
141
|
+
font-size: 11px;
|
|
142
|
+
font-weight: 700;
|
|
143
|
+
letter-spacing: 0.45px;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.meta {
|
|
147
|
+
min-width: 44px;
|
|
148
|
+
flex: 1 1 44px;
|
|
149
|
+
display: flex;
|
|
150
|
+
flex-direction: column;
|
|
151
|
+
gap: 1px;
|
|
152
|
+
overflow: hidden;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.title {
|
|
156
|
+
font-size: 15px;
|
|
157
|
+
font-weight: 700;
|
|
158
|
+
color: #111827;
|
|
159
|
+
letter-spacing: 0.2px;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.status {
|
|
163
|
+
font-size: 11px;
|
|
164
|
+
color: #6b7280;
|
|
165
|
+
white-space: nowrap;
|
|
166
|
+
overflow: hidden;
|
|
167
|
+
text-overflow: ellipsis;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.controls {
|
|
171
|
+
display: flex;
|
|
172
|
+
align-items: center;
|
|
173
|
+
gap: 4px;
|
|
174
|
+
flex: 0 0 auto;
|
|
175
|
+
margin-left: auto;
|
|
176
|
+
overflow: hidden;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.taskBtn,
|
|
180
|
+
.traceBtn,
|
|
181
|
+
.takeControl,
|
|
182
|
+
.closeBtn {
|
|
183
|
+
border-radius: 999px;
|
|
184
|
+
font-size: 10px;
|
|
185
|
+
font-weight: 700;
|
|
186
|
+
letter-spacing: 0.22px;
|
|
187
|
+
height: 22px;
|
|
188
|
+
padding: 0 7px;
|
|
189
|
+
cursor: pointer;
|
|
190
|
+
border: 1px solid rgba(100, 116, 139, 0.24);
|
|
191
|
+
background: rgba(255, 255, 255, 0.92);
|
|
192
|
+
color: #334155;
|
|
193
|
+
white-space: nowrap;
|
|
194
|
+
flex: 0 0 auto;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.taskBtn:hover,
|
|
198
|
+
.traceBtn:hover,
|
|
199
|
+
.takeControl:hover,
|
|
200
|
+
.closeBtn:hover {
|
|
201
|
+
border-color: rgba(255, 76, 0, 0.35);
|
|
202
|
+
color: #9a3412;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.taskBtn.endTask {
|
|
206
|
+
border-color: rgba(239, 68, 68, 0.28);
|
|
207
|
+
color: #991b1b;
|
|
208
|
+
background: rgba(254, 242, 242, 0.9);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.traceBtn.active {
|
|
212
|
+
border-color: rgba(255, 76, 0, 0.34);
|
|
213
|
+
color: #9a3412;
|
|
214
|
+
background: rgba(255, 240, 232, 0.92);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.modeBadge {
|
|
218
|
+
font-size: 9px;
|
|
219
|
+
font-weight: 700;
|
|
220
|
+
letter-spacing: 0.3px;
|
|
221
|
+
text-transform: uppercase;
|
|
222
|
+
border-radius: 999px;
|
|
223
|
+
padding: 3px 6px;
|
|
224
|
+
border: 1px solid transparent;
|
|
225
|
+
flex: 0 0 auto;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.modeBadge.controller {
|
|
229
|
+
color: #9a3412;
|
|
230
|
+
background: rgba(255, 76, 0, 0.11);
|
|
231
|
+
border-color: rgba(255, 76, 0, 0.22);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.modeBadge.observer {
|
|
235
|
+
color: #475569;
|
|
236
|
+
background: rgba(148, 163, 184, 0.16);
|
|
237
|
+
border-color: rgba(100, 116, 139, 0.2);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.takeControl {
|
|
241
|
+
display: none;
|
|
242
|
+
border-color: rgba(255, 76, 0, 0.24);
|
|
243
|
+
color: #9a3412;
|
|
244
|
+
background: rgba(255, 76, 0, 0.08);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.takeControl.visible { display: inline-flex; }
|
|
248
|
+
|
|
249
|
+
.closeBtn {
|
|
250
|
+
width: 22px;
|
|
251
|
+
min-width: 22px;
|
|
252
|
+
padding: 0;
|
|
253
|
+
display: grid;
|
|
254
|
+
place-items: center;
|
|
255
|
+
font-size: 14px;
|
|
256
|
+
line-height: 1;
|
|
257
|
+
color: #64748b;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.feed {
|
|
261
|
+
flex: 1;
|
|
262
|
+
min-height: 0;
|
|
263
|
+
overflow: auto;
|
|
264
|
+
padding: 12px 12px 8px;
|
|
265
|
+
display: flex;
|
|
266
|
+
flex-direction: column;
|
|
267
|
+
gap: 8px;
|
|
268
|
+
background: radial-gradient(circle at 10% 0%, rgba(255, 76, 0, 0.06), transparent 45%);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.entry {
|
|
272
|
+
display: flex;
|
|
273
|
+
flex-direction: column;
|
|
274
|
+
gap: 4px;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.entry .stamp {
|
|
278
|
+
font-size: 10px;
|
|
279
|
+
color: #6b7280;
|
|
280
|
+
align-self: flex-end;
|
|
281
|
+
padding: 0 2px;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.entry.message { max-width: 90%; }
|
|
285
|
+
.entry.message.user { align-self: flex-end; }
|
|
286
|
+
.entry.message.assistant,
|
|
287
|
+
.entry.message.system { align-self: flex-start; }
|
|
288
|
+
|
|
289
|
+
.bubble {
|
|
290
|
+
border-radius: 14px;
|
|
291
|
+
padding: 10px 12px;
|
|
292
|
+
line-height: 1.42;
|
|
293
|
+
font-size: 12px;
|
|
294
|
+
white-space: pre-wrap;
|
|
295
|
+
word-break: break-word;
|
|
296
|
+
border: 1px solid transparent;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.entry.message.user .bubble {
|
|
300
|
+
background: linear-gradient(145deg, #ff4c00, #ff7a39);
|
|
301
|
+
border-color: rgba(255, 76, 0, 0.4);
|
|
302
|
+
color: #fff;
|
|
303
|
+
box-shadow: 0 8px 18px rgba(255, 76, 0, 0.24);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.entry.message.assistant .bubble {
|
|
307
|
+
background: rgba(255, 255, 255, 0.92);
|
|
308
|
+
border-color: rgba(255, 76, 0, 0.2);
|
|
309
|
+
color: #111827;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.entry.message.system .bubble {
|
|
313
|
+
background: rgba(241, 245, 249, 0.94);
|
|
314
|
+
border-color: rgba(148, 163, 184, 0.25);
|
|
315
|
+
color: #334155;
|
|
316
|
+
font-size: 11px;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.entry.trace {
|
|
320
|
+
width: 100%;
|
|
321
|
+
border: 1px solid rgba(148, 163, 184, 0.25);
|
|
322
|
+
border-radius: 14px;
|
|
323
|
+
padding: 9px 10px;
|
|
324
|
+
background: rgba(255, 255, 255, 0.9);
|
|
325
|
+
transition: all 140ms ease;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.entry.trace.pending {
|
|
329
|
+
border-color: rgba(255, 76, 0, 0.24);
|
|
330
|
+
background: rgba(255, 243, 236, 0.9);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.entry.trace.success {
|
|
334
|
+
border-color: rgba(16, 185, 129, 0.24);
|
|
335
|
+
background: rgba(236, 253, 245, 0.9);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.entry.trace.error {
|
|
339
|
+
border-color: rgba(239, 68, 68, 0.26);
|
|
340
|
+
background: rgba(254, 242, 242, 0.9);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.entry.trace.info {
|
|
344
|
+
border-color: rgba(37, 99, 235, 0.22);
|
|
345
|
+
background: rgba(239, 246, 255, 0.88);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.traceTop {
|
|
349
|
+
display: flex;
|
|
350
|
+
align-items: center;
|
|
351
|
+
justify-content: space-between;
|
|
352
|
+
gap: 10px;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.traceMeta {
|
|
356
|
+
display: inline-flex;
|
|
357
|
+
align-items: center;
|
|
358
|
+
gap: 6px;
|
|
359
|
+
min-width: 0;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.traceStage {
|
|
363
|
+
font-size: 9px;
|
|
364
|
+
letter-spacing: 0.25px;
|
|
365
|
+
text-transform: uppercase;
|
|
366
|
+
font-weight: 700;
|
|
367
|
+
border-radius: 999px;
|
|
368
|
+
border: 1px solid rgba(148, 163, 184, 0.35);
|
|
369
|
+
background: rgba(255, 255, 255, 0.96);
|
|
370
|
+
color: #334155;
|
|
371
|
+
padding: 2px 7px;
|
|
372
|
+
flex: 0 0 auto;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
.traceTitle {
|
|
376
|
+
font-size: 12px;
|
|
377
|
+
line-height: 1.35;
|
|
378
|
+
font-weight: 600;
|
|
379
|
+
color: #0f172a;
|
|
380
|
+
white-space: nowrap;
|
|
381
|
+
overflow: hidden;
|
|
382
|
+
text-overflow: ellipsis;
|
|
383
|
+
min-width: 0;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.traceTs {
|
|
387
|
+
font-size: 10px;
|
|
388
|
+
color: #6b7280;
|
|
389
|
+
flex: 0 0 auto;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.traceDetail {
|
|
393
|
+
font-size: 11px;
|
|
394
|
+
line-height: 1.42;
|
|
395
|
+
color: #475569;
|
|
396
|
+
white-space: pre-wrap;
|
|
397
|
+
word-break: break-word;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.entry.trace.compact .traceDetail {
|
|
401
|
+
display: none;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
.taskSuggestion {
|
|
405
|
+
display: none;
|
|
406
|
+
border-top: 1px solid rgba(148, 163, 184, 0.18);
|
|
407
|
+
padding: 8px 10px;
|
|
408
|
+
background: rgba(255, 251, 235, 0.85);
|
|
409
|
+
align-items: center;
|
|
410
|
+
justify-content: space-between;
|
|
411
|
+
gap: 8px;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.taskSuggestion.visible {
|
|
415
|
+
display: flex;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
.taskSuggestionText {
|
|
419
|
+
font-size: 11px;
|
|
420
|
+
line-height: 1.35;
|
|
421
|
+
color: #7c2d12;
|
|
422
|
+
flex: 1;
|
|
423
|
+
min-width: 0;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
.taskSuggestionActions {
|
|
427
|
+
display: inline-flex;
|
|
428
|
+
align-items: center;
|
|
429
|
+
gap: 6px;
|
|
430
|
+
flex: 0 0 auto;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
.taskSuggestionBtn {
|
|
434
|
+
border: 1px solid rgba(148, 163, 184, 0.3);
|
|
435
|
+
background: rgba(255, 255, 255, 0.95);
|
|
436
|
+
color: #334155;
|
|
437
|
+
border-radius: 999px;
|
|
438
|
+
font-size: 10px;
|
|
439
|
+
font-weight: 700;
|
|
440
|
+
letter-spacing: 0.18px;
|
|
441
|
+
padding: 4px 8px;
|
|
442
|
+
cursor: pointer;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
.taskSuggestionBtn.primary {
|
|
446
|
+
border-color: rgba(255, 76, 0, 0.36);
|
|
447
|
+
color: #9a3412;
|
|
448
|
+
background: rgba(255, 241, 234, 0.9);
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
.composer {
|
|
452
|
+
display: flex;
|
|
453
|
+
align-items: flex-end;
|
|
454
|
+
gap: 8px;
|
|
455
|
+
border-top: 1px solid rgba(148, 163, 184, 0.2);
|
|
456
|
+
padding: 10px;
|
|
457
|
+
background: rgba(255, 255, 255, 0.95);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
.composer textarea {
|
|
461
|
+
flex: 1;
|
|
462
|
+
resize: none;
|
|
463
|
+
min-height: 42px;
|
|
464
|
+
max-height: 96px;
|
|
465
|
+
border: 1px solid rgba(148, 163, 184, 0.35);
|
|
466
|
+
border-radius: 12px;
|
|
467
|
+
padding: 10px 11px;
|
|
468
|
+
font-size: 12px;
|
|
469
|
+
line-height: 1.35;
|
|
470
|
+
font-family: inherit;
|
|
471
|
+
color: #111827;
|
|
472
|
+
background: #fff;
|
|
473
|
+
outline: none;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
.composer textarea:focus {
|
|
477
|
+
border-color: rgba(255, 76, 0, 0.5);
|
|
478
|
+
box-shadow: 0 0 0 3px rgba(255, 76, 0, 0.12);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
.composer button {
|
|
482
|
+
border: none;
|
|
483
|
+
background: linear-gradient(145deg, #ff4c00, #ff7a39);
|
|
484
|
+
color: #fff;
|
|
485
|
+
border-radius: 11px;
|
|
486
|
+
height: 42px;
|
|
487
|
+
min-width: 78px;
|
|
488
|
+
padding: 0 12px;
|
|
489
|
+
font-size: 12px;
|
|
490
|
+
font-weight: 700;
|
|
491
|
+
letter-spacing: 0.25px;
|
|
492
|
+
cursor: pointer;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
.composer button:hover { filter: brightness(0.98); }
|
|
496
|
+
|
|
497
|
+
.resizeHandle {
|
|
498
|
+
position: absolute;
|
|
499
|
+
left: 8px;
|
|
500
|
+
bottom: 8px;
|
|
501
|
+
width: 14px;
|
|
502
|
+
height: 14px;
|
|
503
|
+
border-left: 2px solid rgba(148, 163, 184, 0.4);
|
|
504
|
+
border-bottom: 2px solid rgba(148, 163, 184, 0.4);
|
|
505
|
+
border-radius: 2px;
|
|
506
|
+
cursor: nwse-resize;
|
|
507
|
+
opacity: 0.8;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
.feed::-webkit-scrollbar {
|
|
511
|
+
width: 6px;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
.feed::-webkit-scrollbar-thumb {
|
|
515
|
+
background: rgba(148, 163, 184, 0.4);
|
|
516
|
+
border-radius: 999px;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
@media (max-width: 640px) {
|
|
520
|
+
.launcher {
|
|
521
|
+
right: 14px;
|
|
522
|
+
bottom: 14px;
|
|
523
|
+
width: 54px;
|
|
524
|
+
height: 54px;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
.panel {
|
|
528
|
+
right: 8px;
|
|
529
|
+
left: 8px;
|
|
530
|
+
bottom: 78px;
|
|
531
|
+
width: auto;
|
|
532
|
+
min-width: 0;
|
|
533
|
+
height: min(76vh, calc(100vh - 92px));
|
|
534
|
+
border-radius: 18px;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
.controls {
|
|
538
|
+
gap: 3px;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
.taskBtn,
|
|
542
|
+
.traceBtn,
|
|
543
|
+
.takeControl,
|
|
544
|
+
.closeBtn {
|
|
545
|
+
height: 20px;
|
|
546
|
+
padding: 0 5px;
|
|
547
|
+
font-size: 9px;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
.modeBadge {
|
|
551
|
+
font-size: 8px;
|
|
552
|
+
padding: 2px 5px;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
.resizeHandle {
|
|
556
|
+
display: none;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
`;let r=document.createElement("div");r.className="rover",r.dataset.mood="idle";let s=document.createElement("button");s.className="launcher",s.setAttribute("aria-label","Open Rover assistant");let c=document.createElement("video");c.autoplay=!0,c.muted=!0,c.loop=!0,c.playsInline=!0,c.preload="metadata";let l=document.createElement("source");l.src=e.mascot?.mp4Url||od,l.type="video/mp4";let f=document.createElement("source");f.src=e.mascot?.webmUrl||rd,f.type="video/webm",c.appendChild(l),c.appendChild(f);let R=document.createElement("span");R.className="launcherFallback",R.textContent="RVR",s.appendChild(c),s.appendChild(R);let p=document.createElement("div");p.className="panel";let T=document.createElement("div");T.className="header";let S=document.createElement("div");S.className="avatar";let x=c.cloneNode(!0);S.appendChild(x);let A=document.createElement("span");A.className="avatarFallback",A.textContent="R",S.appendChild(A);let L=document.createElement("div");L.className="meta";let P=document.createElement("div");P.className="title",P.textContent="Rover";let G=document.createElement("div");G.className="status",G.textContent="ready",L.appendChild(P),L.appendChild(G);let D=document.createElement("div");D.className="controls";let F=document.createElement("button");F.type="button",F.className="taskBtn newTask",F.textContent="New task",e.showTaskControls===!1&&(F.style.display="none");let H=document.createElement("button");H.type="button",H.className="taskBtn endTask",H.textContent="End",e.showTaskControls===!1&&(H.style.display="none");let X=document.createElement("button");X.type="button",X.className="traceBtn",X.textContent="Details";let J=document.createElement("span");J.className="modeBadge controller",J.textContent="active";let Z=document.createElement("button");Z.type="button",Z.className="takeControl",Z.textContent="Take control";let ie=document.createElement("button");ie.type="button",ie.className="closeBtn",ie.setAttribute("aria-label","Close Rover panel"),ie.textContent="\xD7",D.appendChild(F),D.appendChild(H),D.appendChild(X),D.appendChild(J),D.appendChild(Z),D.appendChild(ie),T.appendChild(S),T.appendChild(L),T.appendChild(D);let K=document.createElement("div");K.className="feed";let fe=document.createElement("form");fe.className="composer",fe.innerHTML=`
|
|
560
|
+
<textarea rows="1" placeholder="Ask Rover to act on this website..."></textarea>
|
|
561
|
+
<button type="submit">Send</button>
|
|
562
|
+
`;let ee=document.createElement("div");ee.className="taskSuggestion",ee.innerHTML=`
|
|
563
|
+
<div class="taskSuggestionText"></div>
|
|
564
|
+
<div class="taskSuggestionActions">
|
|
565
|
+
<button type="button" class="taskSuggestionBtn primary">Start new</button>
|
|
566
|
+
<button type="button" class="taskSuggestionBtn secondary">Continue</button>
|
|
567
|
+
</div>
|
|
568
|
+
`;let pe=document.createElement("div");pe.className="resizeHandle",pe.setAttribute("aria-hidden","true"),p.appendChild(T),p.appendChild(K),p.appendChild(ee),p.appendChild(fe),p.appendChild(pe),r.appendChild(s),r.appendChild(p),n.appendChild(o),n.appendChild(r);let se=fe.querySelector("textarea"),ut=ee.querySelector(".taskSuggestionText"),xe=ee.querySelector(".taskSuggestionBtn.primary"),Oe=ee.querySelector(".taskSuggestionBtn.secondary"),Ke=new Set,Qe=new Map,dt=[],xt="controller",ft=!1,vt=!1,st=null;function ve(B,te=0){r.dataset.mood=B,st!=null&&(window.clearTimeout(st),st=null),te>0&&B!=="idle"&&(st=window.setTimeout(()=>{r.dataset.mood="idle",st=null},te))}function Ft(){K.scrollTop=K.scrollHeight}function Oo(){se.disabled=xt==="observer"&&!ft}function Hn(B){vt=B,X.classList.toggle("active",vt),X.textContent=vt?"Hide details":"Details";for(let te of dt){let Ee=te.dataset.status,ce=Ee==="success"||Ee==="error"||Ee==="info";te.classList.toggle("compact",!vt&&ce)}}function Ht(){r.style.display="",p.classList.add("open"),ve("idle"),e.onOpen?.(),se.disabled||se.focus()}function Kt(){p.classList.remove("open"),ve("idle"),e.onClose?.()}function oo(){r.style.display=""}function ht(){Kt(),r.style.display="none"}function Pt(B,te){let Ee=eo(te);if(!Ee)return;let ce=document.createElement("div");ce.className=`entry message ${B}`;let Ue=document.createElement("div");Ue.className="bubble",Ue.textContent=Ee;let pt=document.createElement("div");pt.className="stamp",pt.textContent=ja(Date.now()),ce.appendChild(Ue),ce.appendChild(pt),K.appendChild(ce),B==="user"?ve("typing",1200):B==="assistant"?ve("success",1400):ve("running",900),Ft()}function un(){for(let B of Array.from(K.querySelectorAll(".entry.message")))B.remove()}function Bt(B){let te=Qe.get(B);if(te)return te;let Ee=document.createElement("div");Ee.className="entry trace pending";let ce=document.createElement("div");ce.className="traceTop";let Ue=document.createElement("div");Ue.className="traceMeta";let pt=document.createElement("span");pt.className="traceStage",pt.textContent="step";let Ce=document.createElement("div");Ce.className="traceTitle";let mn=document.createElement("div");mn.className="traceTs",Ue.appendChild(pt),Ue.appendChild(Ce),ce.appendChild(Ue),ce.appendChild(mn);let tn=document.createElement("div");return tn.className="traceDetail",Ee.appendChild(ce),Ee.appendChild(tn),Qe.set(B,Ee),dt.push(Ee),K.appendChild(Ee),Ee}function dn(B,te){let Ee=Number(te.ts)||Date.now(),ce=sd(te),Ue=B.querySelector(".traceTop"),Ce=Ue.querySelector(".traceMeta").querySelector(".traceStage"),mn=Ue.querySelector(".traceTitle"),tn=Ue.querySelector(".traceTs"),gn=B.querySelector(".traceDetail"),bn=ad(te.title||"");mn.textContent=bn.plainTitle||"Step",Ce.textContent=bn.stage||te.kind||"step",Ce.style.display=bn.stage||te.kind==="status"||te.kind==="plan"?"":"none",tn.textContent=ja(Ee),gn.textContent=eo(te.detail||""),gn.style.display=gn.textContent?"":"none",B.classList.remove("pending","success","error","info"),B.classList.add(ce),B.dataset.status=ce,B.dataset.kind=te.kind;let Pn=ce==="success"||ce==="error"||ce==="info";B.classList.toggle("compact",!vt&&Pn),ce==="error"?ve("error",2200):ce==="success"?ve("success",1200):ce==="pending"&&ve("running",800)}function Be(B){let te=eo(B.title||"");if(!te||te.toLowerCase()==="assistant update")return;let Ee=B.id||za("timeline");if(B.id&&Ke.has(Ee))return;Ke.add(Ee);let ce=id(B),Ue=ce==="run"||ce.startsWith("tool:")||B.kind==="tool_result"||B.kind==="status"&&Qe.has(ce),pt=Bt(Ue?ce:`${ce}:${Ee}`);dn(pt,{...B,title:te}),te.toLowerCase()==="run completed"&&Hn(!1),Ft()}function ro(){Ke.clear(),Qe.clear(),dt.length=0;for(let B of Array.from(K.querySelectorAll(".entry.trace")))B.remove()}function Qt(B){let te=!!B?.visible;ee.classList.toggle("visible",te),ut.textContent=B?.text||"Looks like a new request. Start a new task?",xe.textContent=B?.primaryLabel||"Start new",Oe.textContent=B?.secondaryLabel||"Continue"}function fn(B){let te=String(B||"ready");G.textContent=te;let Ee=te.toLowerCase();Ee.includes("error")||Ee.includes("failed")?ve("error",1800):Ee==="ready"||Ee.includes("complete")?ve("idle"):ve("running",1e3)}function Jt(B,te){xt=B,ft=B==="observer"?te?.canComposeInObserver===!0:!0,Oo(),J.classList.remove("controller","observer"),J.classList.add(B),B==="controller"?(J.textContent="active",Z.classList.remove("visible"),se.placeholder="Ask Rover to act on this website..."):(J.textContent="observer",te?.canTakeControl!==!1?Z.classList.add("visible"):Z.classList.remove("visible"),te?.note?se.placeholder=te.note:ft?se.placeholder="Send to take control and run here.":te?.activeLogicalTabId&&te?.localLogicalTabId&&te.activeLogicalTabId!==te.localLogicalTabId?se.placeholder=`Observing: Rover is acting in tab #${te.activeLogicalTabId}`:se.placeholder="Observer mode. Take control to run actions here.")}function so(){st!=null&&(window.clearTimeout(st),st=null),t.remove()}s.addEventListener("click",()=>{p.classList.contains("open")?Kt():Ht()}),ie.addEventListener("click",()=>Kt()),Z.addEventListener("click",()=>{e.onRequestControl?.()}),F.addEventListener("click",()=>{e.onNewTask?.()}),H.addEventListener("click",()=>{e.onEndTask?.()}),X.addEventListener("click",()=>{Hn(!vt)}),xe.addEventListener("click",()=>{e.onTaskSuggestionPrimary?.()}),Oe.addEventListener("click",()=>{e.onTaskSuggestionSecondary?.()}),se.addEventListener("input",()=>{se.style.height="auto",se.style.height=`${Math.min(96,Math.max(42,se.scrollHeight))}px`}),fe.addEventListener("submit",B=>{if(B.preventDefault(),se.disabled)return;let te=eo(se.value);te&&(Qt({visible:!1}),e.onSend(te),se.value="",se.style.height="42px")});let kt=null,hn=B=>{if(!kt)return;let te=kt.startX-B.clientX,Ee=B.clientY-kt.startY,ce=Math.max(320,Math.min(window.innerWidth-16,kt.startW+te)),Ue=Math.max(460,Math.min(window.innerHeight-16,kt.startH+Ee));p.style.width=`${ce}px`,p.style.height=`${Ue}px`},Zt=()=>{kt=null,window.removeEventListener("pointermove",hn),window.removeEventListener("pointerup",Zt)};pe.addEventListener("pointerdown",B=>{window.matchMedia("(max-width: 640px)").matches||(B.preventDefault(),kt={startX:B.clientX,startY:B.clientY,startW:p.getBoundingClientRect().width,startH:p.getBoundingClientRect().height},window.addEventListener("pointermove",hn),window.addEventListener("pointerup",Zt))});let en=()=>{c.style.display="none",R.style.display="grid"},pn=()=>{x.style.display="none",A.style.display="grid"};return c.addEventListener("error",en,{once:!0}),x.addEventListener("error",pn,{once:!0}),R.style.display="none",A.style.display="none",Jt("controller"),Hn(!1),{addMessage:Pt,clearMessages:un,addTimelineEvent:Be,clearTimeline:ro,setTaskSuggestion:Qt,setStatus:fn,setExecutionMode:Jt,open:Ht,close:Kt,show:oo,hide:ht,destroy:so}}var cd="rover:shared:",ld="rover:channel:";function ue(){return Date.now()}function Xt(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Is(e){let t=String(e||"").trim();if(!t)return"";try{return new URL(t,window.location.href).toString()}catch{return t}}function Ja(e){if(!e||typeof e!="object")return;let t=typeof e.taskId=="string"?e.taskId.trim():"";if(!t)return;let n=e.status==="completed"||e.status==="ended"||e.status==="running"?e.status:"running";return{taskId:t,status:n,startedAt:Number(e.startedAt)||ue(),lastUserAt:Number(e.lastUserAt)||void 0,lastAssistantAt:Number(e.lastAssistantAt)||void 0,boundaryReason:typeof e.boundaryReason=="string"?e.boundaryReason:void 0,endedAt:Number(e.endedAt)||void 0}}function ud(e){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;try{return structuredClone(e)}catch{try{return JSON.parse(JSON.stringify(e))}catch{return}}}function Qa(e,t){if(!Array.isArray(e))return[];let n=[];for(let o of e.slice(-t)){let r=ud(o);r!==void 0&&n.push(r)}return n}function Za(e){if(!e||typeof e!="object")return;let t=s=>s.slice(-80).map(c=>({role:typeof c?.role=="string"?c.role:"assistant",content:typeof c?.content=="string"?c.content:""})).filter(c=>!!c.content),n=Array.isArray(e.history)?t(e.history):[],o=Qa(e.plannerHistory,40),r=Qa(e.agentPrevSteps,80);return{trajectoryId:typeof e.trajectoryId=="string"?e.trajectoryId:void 0,history:n,plannerHistory:o,agentPrevSteps:r,updatedAt:Number(e.updatedAt)||ue()}}function As(e,t){return{version:2,siteId:e,sessionId:t,seq:1,updatedAt:ue(),lease:void 0,tabs:[],nextLogicalTabId:1,activeLogicalTabId:void 0,uiMessages:[],timeline:[],uiStatus:void 0,activeRun:void 0,taskEpoch:1,task:void 0,workerContext:void 0}}function So(e,t,n){let o=As(t,n);if(!e||typeof e!="object")return o;let r={...o,version:2,siteId:t,sessionId:n,seq:Math.max(1,Number(e.seq)||1),updatedAt:Number(e.updatedAt)||ue(),tabs:Array.isArray(e.tabs)?e.tabs.map(s=>({logicalTabId:Math.max(1,Number(s?.logicalTabId)||0),runtimeId:typeof s?.runtimeId=="string"?s.runtimeId:void 0,url:String(s?.url||""),title:typeof s?.title=="string"?s.title:void 0,openedAt:Number(s?.openedAt)||ue(),updatedAt:Number(s?.updatedAt)||ue(),external:!!s?.external,openerRuntimeId:typeof s?.openerRuntimeId=="string"?s.openerRuntimeId:void 0})).filter(s=>!!s.logicalTabId):[],nextLogicalTabId:Math.max(1,Number(e.nextLogicalTabId)||1),activeLogicalTabId:Number(e.activeLogicalTabId)||void 0,uiMessages:Array.isArray(e.uiMessages)?e.uiMessages.map(s=>({id:String(s?.id||Xt("msg")),role:s?.role==="user"||s?.role==="assistant"||s?.role==="system"?s.role:"system",text:String(s?.text||""),ts:Number(s?.ts)||ue(),sourceRuntimeId:typeof s?.sourceRuntimeId=="string"?s.sourceRuntimeId:void 0})).filter(s=>!!s.text):[],timeline:Array.isArray(e.timeline)?e.timeline.map(s=>({id:String(s?.id||Xt("timeline")),kind:String(s?.kind||"status"),title:String(s?.title||"Step"),detail:typeof s?.detail=="string"?s.detail:void 0,status:s?.status==="pending"||s?.status==="success"||s?.status==="error"||s?.status==="info"?s.status:void 0,ts:Number(s?.ts)||ue(),sourceRuntimeId:typeof s?.sourceRuntimeId=="string"?s.sourceRuntimeId:void 0})).filter(s=>!!s.title):[],taskEpoch:Math.max(1,Number(e.taskEpoch)||1),task:Ja(e.task),workerContext:Za(e.workerContext),uiStatus:typeof e.uiStatus=="string"?e.uiStatus:void 0,activeRun:e.activeRun&&typeof e.activeRun=="object"?{runId:String(e.activeRun.runId||""),text:String(e.activeRun.text||""),runtimeId:String(e.activeRun.runtimeId||""),startedAt:Number(e.activeRun.startedAt)||ue(),updatedAt:Number(e.activeRun.updatedAt)||ue()}:void 0,lease:e.lease&&typeof e.lease=="object"&&e.lease.holderRuntimeId?{holderRuntimeId:String(e.lease.holderRuntimeId),expiresAt:Number(e.lease.expiresAt)||0,updatedAt:Number(e.lease.updatedAt)||ue()}:void 0};return r.nextLogicalTabId<=r.tabs.length&&(r.nextLogicalTabId=r.tabs.reduce((s,c)=>Math.max(s,c.logicalTabId),0)+1),r}var Sr=class{constructor(t){W(this,"siteId");W(this,"sessionId");W(this,"runtimeId");W(this,"leaseMs");W(this,"heartbeatMs");W(this,"maxMessages");W(this,"maxTimeline");W(this,"onRoleChange");W(this,"onStateChange");W(this,"onSwitchRequested");W(this,"key");W(this,"channelName");W(this,"state");W(this,"channel",null);W(this,"heartbeatTimer",null);W(this,"storageHandler",null);W(this,"localLogicalTabId");W(this,"started",!1);this.siteId=t.siteId,this.sessionId=t.sessionId,this.runtimeId=t.runtimeId,this.leaseMs=Math.max(4e3,Number(t.leaseMs)||12e3),this.heartbeatMs=Math.max(800,Number(t.heartbeatMs)||2e3),this.maxMessages=Math.max(40,Number(t.maxMessages)||220),this.maxTimeline=Math.max(40,Number(t.maxTimeline)||280),this.onRoleChange=t.onRoleChange,this.onStateChange=t.onStateChange,this.onSwitchRequested=t.onSwitchRequested,this.key=`${cd}${this.siteId}:${this.sessionId}`,this.channelName=`${ld}${this.siteId}:${this.sessionId}`,this.state=this.loadState()}start(){this.started||(this.started=!0,this.registerCurrentTab(window.location.href,document.title||void 0),this.claimLease(!1),this.state.task||this.mutate("local",t=>{t.task={taskId:Xt("task"),status:"running",startedAt:ue(),boundaryReason:"session_start"}}),typeof BroadcastChannel<"u"&&(this.channel=new BroadcastChannel(this.channelName),this.channel.onmessage=t=>{let n=t.data;if(!(!n||typeof n!="object")){if(n.type==="state"&&n.state){let o=So(n.state,this.siteId,this.sessionId);this.applyIncomingState(o)}n.type==="switch_request"&&n.targetRuntimeId===this.runtimeId&&this.onSwitchRequested?.(Number(n.logicalTabId)||0)}}),this.storageHandler=t=>{if(!(t.key!==this.key||!t.newValue))try{let n=So(JSON.parse(t.newValue),this.siteId,this.sessionId);this.applyIncomingState(n)}catch{}},window.addEventListener("storage",this.storageHandler),this.heartbeatTimer=window.setInterval(()=>{this.heartbeat()},this.heartbeatMs),this.notifyRoleChange(),this.onStateChange?.(this.state,"local"))}stop(){this.started&&(this.started=!1,this.heartbeatTimer!=null&&(window.clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.storageHandler&&(window.removeEventListener("storage",this.storageHandler),this.storageHandler=null),this.channel&&(this.channel.close(),this.channel=null),this.mutate("local",t=>{t.tabs=t.tabs.filter(n=>n.runtimeId!==this.runtimeId),t.lease?.holderRuntimeId===this.runtimeId&&(t.lease=void 0),t.activeLogicalTabId&&!t.tabs.some(n=>n.logicalTabId===t.activeLogicalTabId)&&(t.activeLogicalTabId=void 0)}))}isController(){let t=this.state.lease;return!t||t.expiresAt<=ue()?!1:t.holderRuntimeId===this.runtimeId}getRole(){return this.isController()?"controller":"observer"}getLocalLogicalTabId(){return this.localLogicalTabId}getActiveLogicalTabId(){return this.state.activeLogicalTabId}getCurrentHolderRuntimeId(){return this.state.lease?.holderRuntimeId}getState(){return this.state}getTaskEpoch(){return this.state.taskEpoch}getTask(){return this.state.task}getWorkerContext(){return this.state.workerContext}syncTask(t,n){this.mutate("local",o=>{n&&Number.isFinite(n)&&n>o.taskEpoch&&(o.taskEpoch=Math.max(1,Math.trunc(n))),t&&(o.task=Ja(t)||o.task)})}hydrateExternalState(t){let n=So(t,this.siteId,this.sessionId),o=this.state.seq,r=this.state.updatedAt;return this.applyIncomingState(n),this.state.seq!==o||this.state.updatedAt!==r?(this.persistState(),this.localLogicalTabId||this.registerCurrentTab(window.location.href,document.title||void 0),!0):!1}listTabs(){return[...this.state.tabs]}startNewTask(t){let n=Number(t.startedAt)||ue(),o={taskId:String(t.taskId||Xt("task")),status:t.status==="completed"||t.status==="ended"?t.status:"running",startedAt:n,lastUserAt:Number(t.lastUserAt)||n,lastAssistantAt:Number(t.lastAssistantAt)||void 0,boundaryReason:t.boundaryReason,endedAt:void 0};return this.mutate("local",r=>{r.taskEpoch=Math.max(1,Number(r.taskEpoch)||1)+1,r.task=o,r.uiMessages=[],r.timeline=[],r.uiStatus=void 0,r.activeRun=void 0,r.workerContext=void 0}),o}endTask(t){let n;return this.mutate("local",o=>{o.task&&(o.task={...o.task,status:"ended",boundaryReason:t||o.task.boundaryReason,endedAt:ue()},o.activeRun=void 0,n=o.task)}),n}markTaskActivity(t,n=ue()){t!=="system"&&this.mutate("local",o=>{if(!o.task){o.task={taskId:Xt("task"),status:"running",startedAt:n,boundaryReason:"implicit",lastUserAt:t==="user"?n:void 0,lastAssistantAt:t==="assistant"?n:void 0};return}t==="user"&&(o.task.lastUserAt=n),t==="assistant"&&(o.task.lastAssistantAt=n),o.task.status==="ended"&&(o.task.status="running",o.task.endedAt=void 0)})}setWorkerContext(t){this.mutate("local",n=>{if(!t){n.workerContext=void 0;return}n.workerContext=Za(t)})}setStatus(t){this.mutate("local",n=>{n.uiStatus=t||void 0})}appendMessage(t){let n={id:t.id||Xt("msg"),role:t.role,text:String(t.text||""),ts:Number(t.ts)||ue(),sourceRuntimeId:this.runtimeId};return this.mutate("local",o=>{o.uiMessages.push(n),o.uiMessages.length>this.maxMessages&&(o.uiMessages=o.uiMessages.slice(-this.maxMessages)),o.task||(o.task={taskId:Xt("task"),status:"running",startedAt:n.ts,boundaryReason:"implicit"}),n.role==="user"?o.task.lastUserAt=n.ts:n.role==="assistant"&&(o.task.lastAssistantAt=n.ts)}),n}appendTimeline(t){let n={id:t.id||Xt("timeline"),kind:String(t.kind||"status"),title:String(t.title||"Step"),detail:t.detail?String(t.detail):void 0,status:t.status,ts:Number(t.ts)||ue(),sourceRuntimeId:this.runtimeId};return this.mutate("local",o=>{o.timeline.push(n),o.timeline.length>this.maxTimeline&&(o.timeline=o.timeline.slice(-this.maxTimeline))}),n}clearTimeline(){this.mutate("local",t=>{t.timeline=[]})}setActiveRun(t){this.mutate("local",n=>{if(!t){n.activeRun=void 0,n.task&&n.task.status==="running"&&(n.task.status="completed");return}n.activeRun={runId:t.runId,text:t.text,runtimeId:this.runtimeId,startedAt:n.activeRun?.runId===t.runId?n.activeRun.startedAt:ue(),updatedAt:ue()},n.task?n.task.status!=="ended"&&(n.task.status="running"):n.task={taskId:Xt("task"),status:"running",startedAt:ue()}})}requestControl(){return this.claimLease(!0)}registerCurrentTab(t,n){let o=Is(t),r;return this.mutate("local",s=>{let c=s.tabs.find(l=>l.runtimeId===this.runtimeId);if(c)c.url=o||c.url,c.title=n||c.title,c.updatedAt=ue(),r=c.logicalTabId;else{let l=s.tabs.find(f=>!f.runtimeId&&f.url===o&&ue()-f.openedAt<18e4);if(l)l.runtimeId=this.runtimeId,l.title=n||l.title,l.updatedAt=ue(),r=l.logicalTabId;else{let f=s.nextLogicalTabId++;s.tabs.push({logicalTabId:f,runtimeId:this.runtimeId,url:o,title:n,openedAt:ue(),updatedAt:ue(),external:!1}),r=f}}s.activeLogicalTabId||(s.activeLogicalTabId=r)}),this.localLogicalTabId=r,this.notifyRoleChange(),r||1}registerOpenedTab(t){let n=Is(t.url),o=0;return this.mutate("local",r=>{o=r.nextLogicalTabId++,r.tabs.push({logicalTabId:o,runtimeId:void 0,url:n,title:t.title,openedAt:ue(),updatedAt:ue(),external:!!t.external,openerRuntimeId:t.openerRuntimeId})}),{logicalTabId:o}}switchToLogicalTab(t){let n={ok:!1,reason:"Unknown tab"};return this.mutate("local",o=>{let r=o.tabs.find(s=>s.logicalTabId===t);if(!r){n={ok:!1,reason:`Tab ${t} not found`};return}if(o.activeLogicalTabId=t,r.runtimeId&&r.runtimeId!==this.runtimeId){o.lease={holderRuntimeId:r.runtimeId,expiresAt:ue()+this.leaseMs,updatedAt:ue()},this.channel&&this.channel.postMessage({type:"switch_request",logicalTabId:t,targetRuntimeId:r.runtimeId,sourceRuntimeId:this.runtimeId}),n={ok:!0,delegated:!0};return}if(!r.runtimeId){n={ok:!1,reason:`Tab ${t} is not attached to an active Rover runtime yet`};return}o.lease={holderRuntimeId:this.runtimeId,expiresAt:ue()+this.leaseMs,updatedAt:ue()},n={ok:!0,delegated:!1}}),this.notifyRoleChange(),n}heartbeat(){let t=Is(window.location.href),n=document.title||void 0;this.mutate("local",o=>{let r=o.tabs.find(l=>l.runtimeId===this.runtimeId);if(r)r.url=t||r.url,r.title=n||r.title,r.updatedAt=ue(),this.localLogicalTabId=r.logicalTabId;else{let l=o.nextLogicalTabId++;o.tabs.push({logicalTabId:l,runtimeId:this.runtimeId,url:t,title:n,openedAt:ue(),updatedAt:ue(),external:!1}),this.localLogicalTabId=l}let s=o.lease;(!s||s.expiresAt<=ue()||s?.holderRuntimeId===this.runtimeId)&&(o.lease={holderRuntimeId:this.runtimeId,expiresAt:ue()+this.leaseMs,updatedAt:ue()},!o.activeLogicalTabId&&this.localLogicalTabId&&(o.activeLogicalTabId=this.localLogicalTabId))}),this.notifyRoleChange()}claimLease(t){let n=!1;return this.mutate("local",o=>{let r=o.lease,s=!r||r.expiresAt<=ue();(t||s||r?.holderRuntimeId===this.runtimeId)&&(o.lease={holderRuntimeId:this.runtimeId,expiresAt:ue()+this.leaseMs,updatedAt:ue()},!o.activeLogicalTabId&&this.localLogicalTabId&&(o.activeLogicalTabId=this.localLogicalTabId),n=!0)}),this.notifyRoleChange(),n}notifyRoleChange(){this.onRoleChange?.(this.getRole(),{localLogicalTabId:this.localLogicalTabId,activeLogicalTabId:this.state.activeLogicalTabId,holderRuntimeId:this.state.lease?.holderRuntimeId})}mutate(t,n){let o=So(this.state,this.siteId,this.sessionId);n(o),o.seq=Math.max(1,Number(o.seq)||1)+(t==="local"?1:0),o.updatedAt=ue(),this.state=o,t==="local"&&(this.persistState(),this.channel&&this.channel.postMessage({type:"state",sourceRuntimeId:this.runtimeId,state:this.state})),this.onStateChange?.(this.state,t)}applyIncomingState(t){if(!t||t.seq<this.state.seq||t.seq===this.state.seq&&t.updatedAt<=this.state.updatedAt)return;this.state=t;let n=this.state.tabs.find(o=>o.runtimeId===this.runtimeId);this.localLogicalTabId=n?.logicalTabId,this.onStateChange?.(this.state,"remote"),this.notifyRoleChange()}loadState(){try{let t=window.localStorage.getItem(this.key);if(!t)return As(this.siteId,this.sessionId);let n=JSON.parse(t);return So(n,this.siteId,this.sessionId)}catch{return As(this.siteId,this.sessionId)}}persistState(){try{window.localStorage.setItem(this.key,JSON.stringify(this.state))}catch{}}};var dd="https://us-central1-rtrvr-extension-functions.cloudfunctions.net";function to(e,t){let n=Number(e);return Number.isFinite(n)?n:t}function fd(e,t=8e3){let n=String(e??"");return n.length<=t?n:`${n.slice(0,t)}\u2026`}function hd(e){let t=Number(e.sharedState?.seq||0),n=Array.isArray(e.sharedState?.uiMessages)?e.sharedState.uiMessages.length:0,o=Number(e.runtimeState?.updatedAt||0),r=Array.isArray(e.runtimeState?.uiMessages)?e.runtimeState.uiMessages.length:0;return[e.sessionId,to(e.updatedAt,0),t,n,o,r].join(":")}function pd(e){let t=(e||dd).replace(/\/$/,"");return t.endsWith("/extensionRouter")?t:`${t}/extensionRouter`}function Ms(e,t){let n=new Error(e);return n.details=t,n}var kr=class{constructor(t){W(this,"endpoint");W(this,"token");W(this,"siteId");W(this,"visitorId");W(this,"ttlHours");W(this,"flushIntervalMs");W(this,"pullIntervalMs");W(this,"minFlushIntervalMs");W(this,"shouldWrite");W(this,"buildCheckpoint");W(this,"onCheckpoint");W(this,"onError");W(this,"started",!1);W(this,"dirty",!1);W(this,"flushTimer",null);W(this,"pullTimer",null);W(this,"lastFlushAt",0);W(this,"lastPullAt",0);W(this,"lastUploadedRevision","");W(this,"lastAppliedRemoteUpdatedAt",0);W(this,"pushInFlight",!1);W(this,"pullInFlight",!1);let n=String(t.apiKey||t.authToken||"").trim();if(!n)throw Ms("Rover cloud checkpoint requires apiKey or authToken.");this.endpoint=pd(t.apiBase),this.token=n,this.siteId=t.siteId,this.visitorId=t.visitorId,this.ttlHours=Math.max(1,Math.min(168,Math.floor(to(t.ttlHours,1)))),this.flushIntervalMs=Math.max(2e3,Math.floor(to(t.flushIntervalMs,8e3))),this.pullIntervalMs=Math.max(2e3,Math.floor(to(t.pullIntervalMs,9e3))),this.minFlushIntervalMs=Math.max(1e3,Math.floor(to(t.minFlushIntervalMs,2500))),this.shouldWrite=t.shouldWrite||(()=>!0),this.buildCheckpoint=t.buildCheckpoint,this.onCheckpoint=t.onCheckpoint,this.onError=t.onError}start(){this.started||(this.started=!0,this.flushTimer=window.setInterval(()=>{this.flush(!1)},this.flushIntervalMs),this.pullTimer=window.setInterval(()=>{this.pull(!1)},this.pullIntervalMs),this.pull(!0))}stop(){this.started&&(this.started=!1,this.flushTimer!=null&&(window.clearInterval(this.flushTimer),this.flushTimer=null),this.pullTimer!=null&&(window.clearInterval(this.pullTimer),this.pullTimer=null),this.flush(!0))}markDirty(){this.dirty=!0}syncNow(){this.flush(!0),this.pull(!0)}async flush(t){if(this.pushInFlight||!this.dirty&&!t||!this.shouldWrite()||!t&&Date.now()-this.lastFlushAt<this.minFlushIntervalMs)return;let n=this.buildCheckpoint();if(!n)return;let o=hd(n);if(!t&&o===this.lastUploadedRevision){this.dirty=!1;return}this.pushInFlight=!0;try{let r=await this.callExtensionRouter("roverSessionCheckpointUpsert",{siteId:this.siteId,visitorId:this.visitorId,sessionId:n.sessionId,ttlHours:this.ttlHours,updatedAt:n.updatedAt,checkpoint:n});this.lastFlushAt=Date.now(),r?.saved&&(this.dirty=!1,this.lastUploadedRevision=o),r?.stale&&r?.checkpoint&&typeof r.checkpoint=="object"&&(this.applyRemoteCheckpoint(r.checkpoint,"push_stale"),this.dirty=!1)}catch(r){this.onError?.(r)}finally{this.pushInFlight=!1}}async pull(t){if(!this.pullInFlight&&!(!t&&Date.now()-this.lastPullAt<this.pullIntervalMs)){this.pullInFlight=!0;try{let n=await this.callExtensionRouter("roverSessionCheckpointGet",{siteId:this.siteId,visitorId:this.visitorId});if(this.lastPullAt=Date.now(),!n?.found||!n?.checkpoint||typeof n.checkpoint!="object")return;this.applyRemoteCheckpoint(n.checkpoint,"pull")}catch(n){this.onError?.(n)}finally{this.pullInFlight=!1}}}applyRemoteCheckpoint(t,n){let o=Math.max(0,Math.floor(to(t?.updatedAt,0)));o<=this.lastAppliedRemoteUpdatedAt||(this.lastAppliedRemoteUpdatedAt=o,this.onCheckpoint(t,n))}async callExtensionRouter(t,n){let o=await fetch(this.endpoint,{method:"POST",headers:{Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"},body:JSON.stringify({action:t,data:n})});if(!o.ok){let s;try{s=await o.json()}catch{let c=await o.text().catch(()=>"");s=c?{error:fd(c,2e3)}:void 0}throw Ms(`Checkpoint HTTP ${o.status}`,s)}let r=await o.json();if(r?.success===!1)throw Ms("Checkpoint extensionRouter returned success=false",r);return r?.data}};var md="rover-runtime-state-db",Ir="runtime-state",Cs=class{read(t){try{let n=window.sessionStorage.getItem(t);return n?JSON.parse(n):null}catch{return null}}write(t,n){try{window.sessionStorage.setItem(t,JSON.stringify(n))}catch{}}remove(t){try{window.sessionStorage.removeItem(t)}catch{}}},Ns=class{constructor(){W(this,"dbPromise",null)}openDb(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((t,n)=>{if(typeof indexedDB>"u"){n(new Error("indexedDB unavailable"));return}let o=indexedDB.open(md,1);o.onupgradeneeded=()=>{let r=o.result;r.objectStoreNames.contains(Ir)||r.createObjectStore(Ir)},o.onsuccess=()=>{t(o.result)},o.onerror=()=>{n(o.error||new Error("indexedDB open failed"))}}).catch(t=>{throw this.dbPromise=null,t}),this.dbPromise)}async withStore(t,n){let o=await this.openDb();return new Promise((r,s)=>{let c=o.transaction(Ir,t),l=c.objectStore(Ir);n(l,r,s),c.onerror=()=>{s(c.error||new Error("indexedDB transaction failed"))}})}async read(t){try{return await this.withStore("readonly",(n,o,r)=>{let s=n.get(t);s.onsuccess=()=>{let c=s.result;o(c??null)},s.onerror=()=>{r(s.error||new Error("indexedDB read failed"))}})}catch{return null}}async write(t,n){await this.withStore("readwrite",(o,r,s)=>{let c=o.put(n,t);c.onsuccess=()=>r(),c.onerror=()=>{s(c.error||new Error("indexedDB write failed"))}}).catch(()=>{})}async remove(t){await this.withStore("readwrite",(n,o,r)=>{let s=n.delete(t);s.onsuccess=()=>o(),s.onerror=()=>{r(s.error||new Error("indexedDB delete failed"))}}).catch(()=>{})}};function ec(){let e=new Cs,t=new Ns;return{readSync:n=>e.read(n),readAsync:async n=>t.read(n),write:(n,o)=>{e.write(n,o),t.write(n,o)},remove:n=>{e.remove(n),t.remove(n)}}}var Us=1,gd="rover:runtime:",bd="rover:runtime-id:",Ed="rover:visitor-id:",Ds=160,Os=240,sc=80,Dr=40,wd=8e3,yd=15*6e4,_d=12,Td=3600*24*365,xd=1,Fs=5*6e4,Hs=.18,vd=3,Ln=null,gt=null,De=null,we=null,Se=null,no=null,_=null,Dn=null,Ge="",j=null,bt=null,ct,Or=!1,lt="controller",ln=!1,Ur=!1,tc=!1,On=null,Ar="",jt=new Map,Rd=new Set(["run_started","run_completed","assistant","status","tool_start","tool_result","auth_required","navigation_guardrail","error"]),Mr=[],Cr=new Map;function Pe(e,t){let n=Cr.get(e);if(n)for(let o of n)try{o(t)}catch{}}function ic(e,t){Cr.has(e)||Cr.set(e,new Set);let n=Cr.get(e);return n.add(t),()=>{n.delete(t)}}function Sd(e){return typeof e=="string"?{name:e}:e}function an(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function kd(e){let t=`${bd}${e}`;try{let n=window.sessionStorage.getItem(t);if(n&&n.trim())return n.trim();let o=an("runtime");return window.sessionStorage.setItem(t,o),o}catch{return an("runtime")}}function Fr(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")}function Ls(e){return String(e||"").trim().replace(/[^a-zA-Z0-9._:-]/g,"").slice(0,180)}function ac(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]||""):void 0}catch{return}}function nc(e,t,n){try{let o=n?`; domain=${n}`:"";return document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${Td}; samesite=lax${o}`,ac(e)===t}catch{return!1}}function Id(e){let t=String(e||"").trim().toLowerCase();if(!t||t==="localhost"||/^\d{1,3}(\.\d{1,3}){3}$/.test(t))return[];let n=t.split(".").filter(Boolean);if(n.length<2)return[];let o=[];for(let r=n.length-2;r>=0;r-=1)o.push(`.${n.slice(r).join(".")}`);return o}function oc(e,t){let n=`rover_vid_${Fr(e)}`;for(let o of Id(window.location.hostname))if(nc(n,t,o))return;nc(n,t)}function cc(e){let t=Ls(e.visitorId||"");if(t)return t;if(e.checkpointing?.autoVisitorId===!1)return;let n=`${Ed}${e.siteId}`,o=`rover_vid_${Fr(e.siteId)}`,r=Ls(ac(o)||"");if(r){try{window.localStorage.setItem(n,r)}catch{}return r}try{let c=Ls(window.localStorage.getItem(n)||"");if(c)return oc(e.siteId,c),c}catch{}let s=`v_${Fr(`${e.siteId}:${an("visitor")}`)}_${Date.now().toString(36)}`;try{window.localStorage.setItem(n,s)}catch{}return oc(e.siteId,s),s}function Ad(e,t){return`visitor-${Fr(`${e}:${t}`)}`}function lc(e){!gt||!De||(gt.registerTool(e.def,e.handler),De.postMessage({type:"register_tool",tool:e.def}))}function Md(e){return`${gd}${e}`}function cn(e="session_start"){let t=Date.now();return{taskId:an("task"),status:"running",startedAt:t,lastUserAt:void 0,lastAssistantAt:void 0,boundaryReason:e,endedAt:void 0}}function uc(e,t){return{version:Us,sessionId:e,runtimeId:t,uiOpen:!1,uiHidden:!1,uiStatus:void 0,uiMessages:[],timeline:[],executionMode:"controller",workerState:void 0,pendingRun:void 0,taskEpoch:1,activeTask:cn(),lastRoutingDecision:void 0,updatedAt:Date.now()}}function rt(e,t=wd){return e.length<=t?e:`${e.slice(0,t)}\u2026`}function Nr(e){if(e!=null){if(typeof e=="string")return rt(e,1200);try{return rt(JSON.stringify(e),1200)}catch{try{return rt(String(e),1200)}catch{return}}}}function Cd(e){if(e==="analyze"||e==="route"||e==="execute"||e==="verify"||e==="complete")return e}function Nd(e){return e?e==="analyze"?"Analyze":e==="route"?"Route":e==="execute"?"Execute":e==="verify"?"Verify":e==="complete"?"Complete":"Status":"Status"}function Ld(e,t,n){return[String(t||""),String(e||"").trim().toLowerCase(),String(n||"").trim().toLowerCase()].join("|")}function Dd(){return _?.pendingRun?.id}function dc(){let e=j?.getState()?.activeRun;return!!(e&&e.runtimeId&&e.runtimeId!==Ge)}function fc(){return!dc()}function hc(e){if(e==="observer")return dc()?"Observing active run in another tab...":"Send to take control and run here."}function Od(e){let t=typeof e?.type=="string"?e.type:"";if(!Rd.has(t))return!1;let n=typeof e?.runId=="string"&&e.runId?e.runId:void 0,o=Dd();return t==="run_started"?!n||!o?!1:o!==n:n?o?o!==n:!0:!1}function Ud(e){if(e&&jt.has(e))return jt.get(e);if(_?.uiMessages?.length)for(let t=_.uiMessages.length-1;t>=0;t-=1){let n=_.uiMessages[t];if(n.role==="assistant"&&n.text)return n.text}}function Fd(e){return Dn?Dn.readSync(e):null}function Hd(e){if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return e;try{return structuredClone(e)}catch{try{return JSON.parse(JSON.stringify(e))}catch{return}}}function pc(e){if(!e||typeof e!="object")return null;let t=e.role,n=e.content;return typeof t!="string"||typeof n!="string"||!n?null:{role:t,content:n}}function Hr(e,t){if(!Array.isArray(e))return[];let n=[];for(let o of e.slice(-t)){let r=Hd(o);r!==void 0&&n.push(r)}return n}async function Pd(e){if(!Dn)return null;try{return await Dn.readAsync(e)}catch{return null}}function ko(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-Ds)){let o=n?.role;o!=="user"&&o!=="assistant"&&o!=="system"||t.push({id:typeof n?.id=="string"&&n.id?n.id:an("msg"),role:o,text:rt(String(n?.text||"")),ts:Number(n?.ts)||Date.now(),sourceRuntimeId:typeof n?.sourceRuntimeId=="string"?n.sourceRuntimeId:void 0})}return t}function Io(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-Os)){let o=rt(String(n?.title||""),400);if(!o)continue;let r=String(n?.kind||"status"),s=n?.status;t.push({id:typeof n?.id=="string"&&n.id?n.id:an("timeline"),kind:r,title:o,detail:n?.detail?rt(String(n.detail),1200):void 0,status:s==="pending"||s==="success"||s==="error"||s==="info"?s:void 0,ts:Number(n?.ts)||Date.now(),sourceRuntimeId:typeof n?.sourceRuntimeId=="string"?n.sourceRuntimeId:void 0})}return t}function Un(e){if(!e||typeof e!="object")return;let t=Array.isArray(e.history)?e.history:[],n=Array.isArray(e.plannerHistory)?e.plannerHistory:[],o=Array.isArray(e.agentPrevSteps)?e.agentPrevSteps:Array.isArray(e.lastToolPreviousSteps)?e.lastToolPreviousSteps:[],r=t.slice(-sc).map(l=>pc(l)).filter(l=>!!l),s=Hr(n,Dr),c=Hr(o,Dr*2);return{trajectoryId:typeof e.trajectoryId=="string"?e.trajectoryId:void 0,history:r,plannerHistory:s,agentPrevSteps:c,lastToolPreviousSteps:c,updatedAt:Number(e.updatedAt)||Date.now()}}function Ao(e,t,n){if(!e||typeof e!="object")return uc(t,n);let o=cn(),r=No(e.activeTask,o);return{version:Us,sessionId:typeof e.sessionId=="string"&&e.sessionId?e.sessionId:t,runtimeId:typeof e.runtimeId=="string"&&e.runtimeId?e.runtimeId:n,uiOpen:!!e.uiOpen,uiHidden:!!e.uiHidden,uiStatus:typeof e.uiStatus=="string"?rt(e.uiStatus,300):void 0,uiMessages:ko(e.uiMessages),timeline:Io(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:Un(e.workerState),pendingRun:Mo(e.pendingRun),taskEpoch:Math.max(1,Number(e.taskEpoch)||1),activeTask:r,lastRoutingDecision:e.lastRoutingDecision&&(e.lastRoutingDecision.mode==="act"||e.lastRoutingDecision.mode==="planner")?{mode:e.lastRoutingDecision.mode,score:Number(e.lastRoutingDecision.score)||void 0,reason:typeof e.lastRoutingDecision.reason=="string"?rt(e.lastRoutingDecision.reason,200):void 0,ts:Number(e.lastRoutingDecision.ts)||Date.now()}:void 0,updatedAt:Number(e.updatedAt)||Date.now()}}function No(e,t){if(!e||typeof e!="object")return t;let n=typeof e.taskId=="string"&&e.taskId.trim()?e.taskId.trim():t.taskId,o=e.status==="ended"||e.status==="completed"||e.status==="running"?e.status:"running";return{taskId:n,status:o,startedAt:Number(e.startedAt)||t.startedAt,lastUserAt:Number(e.lastUserAt)||void 0,lastAssistantAt:Number(e.lastAssistantAt)||void 0,boundaryReason:typeof e.boundaryReason=="string"?rt(e.boundaryReason,120):t.boundaryReason,endedAt:Number(e.endedAt)||void 0}}function Bd(e,t){return No(e,t)}function mc(e){if(e)return{trajectoryId:e.trajectoryId,history:Array.isArray(e.history)?e.history.slice(-sc).map(t=>pc(t)).filter(t=>!!t):[],plannerHistory:Hr(e.plannerHistory,Dr),agentPrevSteps:Hr(e.agentPrevSteps,Dr*2),updatedAt:Number(e.updatedAt)||Date.now()}}function Mo(e){if(!e||typeof e!="object")return;let t=typeof e.id=="string"&&e.id.trim()?e.id.trim():void 0,n=typeof e.text=="string"?e.text.trim():"";if(!(!t||!n))return{id:t,text:n,startedAt:Number(e.startedAt)||Date.now(),attempts:Math.max(0,Number(e.attempts)||0),autoResume:e.autoResume!==!1}}function Me(){if(!(!_||!no))try{_.updatedAt=Date.now(),Dn?.write(no,_),Or||bt?.markDirty()}catch{}}function Wd(){if(tc)return;tc=!0;let e=()=>{Me(),bt?.markDirty(),bt?.syncNow(),bt?.stop(),j?.stop()};window.addEventListener("pagehide",e,{capture:!0})}function Vr(e="implicit"){if(_)return _.activeTask||(_.activeTask=cn(e),_.taskEpoch=Math.max(1,Number(_.taskEpoch)||1)),_.activeTask}function Vd(e,t=Date.now()){if(!_)return;let n=Vr("implicit");n&&(e==="user"&&(n.lastUserAt=t),e==="assistant"&&(n.lastAssistantAt=t),n.status==="ended"&&(n.status="running",n.endedAt=void 0))}function Fn(){On=null,we?.setTaskSuggestion({visible:!1})}function gc(){we?.clearMessages(),we?.clearTimeline(),Fn()}function $d(){return _?_.uiMessages.filter(t=>t.role==="user").slice(-vd).map(t=>t.text.trim()).filter(Boolean):[]}function rc(e){return new Set(String(e||"").toLowerCase().replace(/[^a-z0-9\s]/g," ").split(/\s+/).map(t=>t.trim()).filter(t=>t.length>2))}function Gd(e,t){let n=rc(e),o=rc(t);if(!n.size||!o.size)return 0;let r=0;for(let s of n)o.has(s)&&(r+=1);return r/Math.max(n.size,o.size)}function Yd(e){if(!_||!Se)return{suggest:!1};if(!(Se.taskContext?.suggestReset!==!1))return{suggest:!1};if(_.pendingRun)return{suggest:!1};let n=Vr("implicit");if(!n||n.status==="ended")return{suggest:!1};let o=Math.max(6e4,Number(Se.taskContext?.inactivityMs)||Fs),r=Date.now(),s=Math.max(n.lastUserAt||0,n.lastAssistantAt||0,n.startedAt||0);if(!s||r-s<o)return{suggest:!1};let c=$d();if(!c.length)return{suggest:!0,reason:"inactivity_only"};let l=c.join(" "),f=Gd(l,e),R=Math.max(.05,Math.min(.9,Number(Se.taskContext?.semanticSimilarityThreshold)||Hs));return f<R?{suggest:!0,reason:`low_similarity_${f.toFixed(2)}`}:{suggest:!1}}function Nt(e,t,n=!0,o){let r=rt(String(t||""));if(!r)return;let s={id:o?.id||an("msg"),role:e,text:r,ts:o?.ts||Date.now(),sourceRuntimeId:o?.sourceRuntimeId};return we?.addMessage(s.role,s.text),_&&n&&(_.uiMessages.push(s),_.uiMessages.length>Ds&&(_.uiMessages=_.uiMessages.slice(-Ds)),Vd(s.role,s.ts),Me()),j&&o?.publishShared!==!1&&(j.appendMessage({id:s.id,role:s.role,text:s.text,ts:s.ts}),j.markTaskActivity(s.role,s.ts)),s}function Ps(e){for(let t of e)Nt(t.role,t.text,!1,{id:t.id,ts:t.ts,sourceRuntimeId:t.sourceRuntimeId,publishShared:!1})}function ze(e,t=!0){let n={id:e.id||an("timeline"),kind:e.kind,title:rt(e.title,400),detail:e.detail?rt(e.detail,1200):void 0,status:e.status,ts:e.ts||Date.now(),sourceRuntimeId:e.sourceRuntimeId};return we?.addTimelineEvent(n),_&&t&&(_.timeline.push(n),_.timeline.length>Os&&(_.timeline=_.timeline.slice(-Os)),Me()),j&&e.publishShared!==!1&&j.appendTimeline({id:n.id,kind:n.kind,title:n.title,detail:n.detail,status:n.status,ts:n.ts}),n}function Bs(e){we?.clearTimeline();for(let t of e)ze({id:t.id,kind:t.kind,title:t.title,detail:t.detail,status:t.status,ts:t.ts,sourceRuntimeId:t.sourceRuntimeId,publishShared:!1},!1)}function zt(e,t){we?.setStatus(e),_&&(_.uiStatus=rt(e,300),Me()),j&&t?.publishShared!==!1&&j.setStatus(e)}function Co(e,t){lt=e,_&&(_.executionMode=e,Me()),we?.setExecutionMode(e,{controllerRuntimeId:t?.holderRuntimeId??j?.getCurrentHolderRuntimeId(),localLogicalTabId:t?.localLogicalTabId??j?.getLocalLogicalTabId(),activeLogicalTabId:t?.activeLogicalTabId??j?.getActiveLogicalTabId(),canTakeControl:!0,canComposeInObserver:fc(),note:hc(e)}),Pe("mode_change",{mode:e,...t})}function sn(e){if(!_)return;_.pendingRun=e;let t=Vr("implicit");t&&(e?(t.status="running",t.endedAt=void 0):t.status==="running"&&(t.status="completed")),Me()}function bc(e,t){let n=String(e||"").trim();if(!n||!De)return;if(lt==="observer"&&!(j?.requestControl()??!1)){Nt("system","Unable to take control right now because another tab is still running Rover actions.",!0),ze({kind:"info",title:"Observer mode",detail:"Action execution is currently owned by another tab runtime.",status:"info"});return}let o=t?.runId||crypto.randomUUID(),r=!!t?.resume;t?.appendUserMessage!==!1&&Nt("user",n,!0);let c=_?.pendingRun?.id===o?_.pendingRun.attempts:0;sn({id:o,text:n,startedAt:Date.now(),attempts:r?c+1:0,autoResume:t?.autoResume!==!1}),j?.setActiveRun({runId:o,text:n}),De.postMessage({type:"run",text:n,runId:o,resume:r})}function Lr(e,t){let n=String(e||"").trim();if(n){if(t?.startNewTask)Do({reason:t.reason||"suggested_new_task",clearUi:!0});else if(!t?.bypassSuggestion){let o=Yd(n);if(o.suggest){On={text:n,reason:o.reason||"heuristic",createdAt:Date.now()},we?.setTaskSuggestion({visible:!0,text:"This looks like a different request. Start a new task or continue this one?",primaryLabel:"Start new",secondaryLabel:"Continue"}),Pe("task_suggested_reset",{text:n,reason:On.reason});return}}Fn(),bc(n,{appendUserMessage:!0,resume:!1,autoResume:!0})}}function Pr(){if(lt==="observer")return;let e=j?.getState()?.activeRun;if(e?.runtimeId&&e.runtimeId!==Ge||!ln||!De||Ur||!_?.pendingRun||_.activeTask?.status==="ended")return;let t=_.pendingRun;if(!t.autoResume)return;if(Date.now()-t.startedAt>yd){sn(void 0),zt("Previous task expired after navigation.");return}if(t.attempts>=_d){sn(void 0),Nt("system","Auto-resume stopped after too many navigation attempts.",!0);return}Ur=!0,zt("Resuming previous task after navigation..."),bc(t.text,{runId:t.id,resume:!0,appendUserMessage:!1,autoResume:!0})}async function qd(e){if(!_)return;let t=await Pd(e);if(!t||!_)return;let n=Number(_.updatedAt)||0,o=Ao({...t,sessionId:_.sessionId,runtimeId:Ge},_.sessionId,Ge);(Number(o.updatedAt)||0)<=n+200||(_=Ao({..._,...o,sessionId:_.sessionId,runtimeId:Ge},_.sessionId,Ge),Me(),we&&(we.clearMessages(),Ps(_.uiMessages),Bs(_.timeline),_.uiStatus&&we.setStatus(_.uiStatus),_.uiHidden?we.hide():(we.show(),_.uiOpen?we.open():we.close())),ln&&De&&_.workerState&<==="controller"&&(De.postMessage({type:"hydrate_state",state:_.workerState}),Pe("context_restored",{source:"indexeddb_checkpoint",ts:Date.now()})))}function Ws(e,t){if(_){if(t==="remote"){let n=Math.max(1,Number(_.taskEpoch)||1),o=Math.max(1,Number(e.taskEpoch)||1),r=o>n;_.taskEpoch=Math.max(n,o);let s=_.activeTask||cn("shared_sync");_.activeTask=Bd(e.task,s),r&&(_.uiMessages=[],_.timeline=[],gc(),sn(void 0),Fn());let c=ko(e.uiMessages),l=new Set(c.map(S=>S.id));if(c.length<_.uiMessages.length||_.uiMessages.some(S=>!l.has(S.id)))_.uiMessages=c,we?.clearMessages(),Ps(_.uiMessages);else{let S=new Set(_.uiMessages.map(x=>x.id));for(let x of c)S.has(x.id)||(Nt(x.role,x.text,!0,{id:x.id,ts:x.ts,sourceRuntimeId:x.sourceRuntimeId,publishShared:!1}),S.add(x.id))}let R=Io(e.timeline),p=new Set(R.map(S=>S.id));if(R.length<_.timeline.length||_.timeline.some(S=>!p.has(S.id)))_.timeline=R,Bs(_.timeline);else{let S=new Set(_.timeline.map(x=>x.id));for(let x of R)S.has(x.id)||(ze({id:x.id,kind:x.kind,title:x.title,detail:x.detail,status:x.status,ts:x.ts,sourceRuntimeId:x.sourceRuntimeId,publishShared:!1},!0),S.add(x.id))}if(typeof e.uiStatus=="string"&&zt(e.uiStatus,{publishShared:!1}),e.activeRun&&e.activeRun.runtimeId!==Ge?sn(Mo({id:e.activeRun.runId,text:e.activeRun.text,startedAt:e.activeRun.startedAt,attempts:_.pendingRun?.attempts||0,autoResume:!0})):!e.activeRun&<==="observer"&&sn(void 0),lt==="observer"&&Co("observer",{localLogicalTabId:j?.getLocalLogicalTabId(),activeLogicalTabId:j?.getActiveLogicalTabId(),holderRuntimeId:j?.getCurrentHolderRuntimeId()}),e.workerContext){let S=Un(e.workerContext),x=Number(_.workerState?.updatedAt)||0,A=Number(S?.updatedAt)||0;S&&A>x+100&&(_.workerState=S,ln&&De&<==="controller"&&(De.postMessage({type:"hydrate_state",state:S}),Pe("context_restored",{source:"shared_session",ts:Date.now()})))}}_.uiMessages=ko(_.uiMessages),_.timeline=Io(_.timeline),_.workerState=Un(_.workerState),_.activeTask=No(_.activeTask,cn("implicit")),Me()}}function Ec(e){let t=cn("checkpoint_clone");return{version:Us,sessionId:e.sessionId,runtimeId:e.runtimeId,uiOpen:!!e.uiOpen,uiHidden:!!e.uiHidden,uiStatus:typeof e.uiStatus=="string"?rt(e.uiStatus,300):void 0,uiMessages:ko(e.uiMessages),timeline:Io(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:Un(e.workerState),pendingRun:Mo(e.pendingRun),taskEpoch:Math.max(1,Number(e.taskEpoch)||1),activeTask:No(e.activeTask,t),lastRoutingDecision:e.lastRoutingDecision&&(e.lastRoutingDecision.mode==="act"||e.lastRoutingDecision.mode==="planner")?{mode:e.lastRoutingDecision.mode,score:Number(e.lastRoutingDecision.score)||void 0,reason:e.lastRoutingDecision.reason,ts:Number(e.lastRoutingDecision.ts)||Date.now()}:void 0,updatedAt:Number(e.updatedAt)||Date.now()}}function Xd(e){return!(e.sessionScope==="tab"||e.checkpointing?.enabled!==!0||!(e.apiKey||e.authToken)||!ct)}function jd(){if(!_||!Se||!ct)return null;let e=j?.getState(),t=Ec(_),n=Math.max(Number(e?.updatedAt||0),Number(t.updatedAt||0),Date.now());return{version:xd,siteId:Se.siteId,visitorId:ct,sessionId:_.sessionId,updatedAt:n,sharedState:e,runtimeState:t}}function zd(e){if(!e||typeof e!="object"||!_||!Se||e.siteId&&e.siteId!==Se.siteId||ct&&e.visitorId&&e.visitorId!==ct)return;let t=typeof e.sessionId=="string"&&e.sessionId.trim()?e.sessionId.trim():_.sessionId;Or=!0;try{if(t&&_.sessionId!==t&&(_.sessionId=t,Se={...Se,sessionId:t},Br(Se),De?.postMessage({type:"update_config",config:{sessionId:t}})),e.sharedState&&j&&j.hydrateExternalState(e.sharedState)&&(Ws(j.getState(),"remote"),Co(j.getRole(),{localLogicalTabId:j.getLocalLogicalTabId(),activeLogicalTabId:j.getActiveLogicalTabId(),holderRuntimeId:j.getCurrentHolderRuntimeId()})),e.runtimeState&&typeof e.runtimeState=="object"){let n=Ao({...e.runtimeState,sessionId:t,runtimeId:Ge},t,Ge),o=Number(_.updatedAt)||0;(Number(n.updatedAt)||0)>o+200&&(_=Ao({..._,...n,sessionId:t,runtimeId:Ge},t,Ge),Me(),_.uiStatus&&we?.setStatus(_.uiStatus),_.uiHidden?we?.hide():(we?.show(),_.uiOpen?we?.open():we?.close()),ln&&_.workerState&&(De?.postMessage({type:"hydrate_state",state:_.workerState}),Pe("context_restored",{source:"cloud_checkpoint",ts:Date.now()})),lt==="controller"&&Pr())}}finally{Or=!1}}function wc(e){if(bt?.stop(),bt=null,!!Xd(e)&&ct)try{bt=new kr({apiBase:e.apiBase,apiKey:e.apiKey,authToken:e.authToken,siteId:e.siteId,visitorId:ct,ttlHours:e.checkpointing?.ttlHours??1,flushIntervalMs:e.checkpointing?.flushIntervalMs,pullIntervalMs:e.checkpointing?.pullIntervalMs,minFlushIntervalMs:e.checkpointing?.minFlushIntervalMs,shouldWrite:()=>lt==="controller",buildCheckpoint:()=>jd(),onCheckpoint:t=>{zd(t)},onError:()=>{}}),bt.start(),bt.markDirty()}catch{bt=null}}function Br(e){if(_){if(j?.stop(),j=null,e.sessionScope==="tab"){Co("controller");return}j=new Sr({siteId:e.siteId,sessionId:_.sessionId,runtimeId:Ge,leaseMs:e.tabPolicy?.actionLeaseMs,onRoleChange:(t,n)=>{Co(t,n);let o=t==="controller"&&(Se?.allowActions??!0);if(gt?.setAllowActions(o),t==="controller"){let r=j?.getWorkerContext();if(r){let s=Un(r),c=Number(_?.workerState?.updatedAt)||0,l=Number(s?.updatedAt)||0;s&&l>c+100&&(_&&(_.workerState=s,Me()),ln&&De&&(De.postMessage({type:"hydrate_state",state:s}),Pe("context_restored",{source:"controller_handoff",ts:Date.now()})))}Pr()}},onStateChange:(t,n)=>{Ws(t,n)},onSwitchRequested:t=>{t>0&&(Lo(),ze({kind:"status",title:`Switched to tab #${t}`,status:"info"}))}}),j.start(),_?.activeTask&&j.syncTask({..._.activeTask,taskId:_.activeTask.taskId},_.taskEpoch),_?.workerState&&j.setWorkerContext(mc(_.workerState))}}function Kd(e){let t=rt(Ud(e)||"Done.",1200);we?.clearTimeline(),_&&(_.timeline=[]),j?.clearTimeline(),ze({id:e?`run:${e}:final`:void 0,kind:"tool_result",title:"Execution completed",detail:t,status:"success"})}function Qd(e){if(!(!e||typeof e!="object")&&!Od(e)){if(e.type==="assistant"){let t=String(e.text||"");if(typeof e.runId=="string"&&e.runId&&(jt.set(e.runId,t),jt.size>80)){let n=jt.keys().next().value;n&&jt.delete(n)}Nt("assistant",t,!0),ze({kind:"tool_result",title:"Assistant update",detail:t,status:"success"});return}if(e.type==="status"){let t=Cd(e.stage),n=e.message?String(e.message):void 0,o=e.compactThought?String(e.compactThought):void 0,r=Ld(n,t,o);if(n&&zt(n),r&&r!==Ar&&(Ar=r,n)){let s=t?`${Nd(t)}: ${n}`:n;ze({kind:"status",title:s,detail:o||(e.thought?String(e.thought):void 0),status:t==="complete"?"success":e.thought?"pending":"info"})}Pe("status",e);return}if(e.type==="tool_start"){Nt("system",`Running ${e.call?.name||"tool"}...`,!0),ze({kind:"tool_start",title:`Running ${e.call?.name||"tool"}`,detail:Nr(e.call?.args),status:"pending"}),Pe("tool_start",e);return}if(e.type==="tool_result"){Nt("system",`${e.call?.name||"tool"} done`,!0),ze({kind:"tool_result",title:`${e.call?.name||"tool"} completed`,detail:Nr(e.result),status:e?.result?.success===!1?"error":"success"}),Pe("tool_result",e);return}if(e.type==="auth_required"){Pe("auth_required",e.error),e.error?.message&&(Nt("system",`Auth required: ${e.error.message}`,!0),ze({kind:"error",title:"Auth required",detail:String(e.error.message),status:"error"}));return}if(e.type==="navigation_guardrail"){Pe("navigation_guardrail",e),ze({kind:"status",title:"Navigation guardrail",detail:Nr(e),status:"info"});return}if(e.type==="error"){Nt("system",`Error: ${e.message||"unknown"}`,!0),ze({kind:"error",title:"Execution error",detail:String(e.message||"unknown"),status:"error"}),Pe("error",e);return}if(e.type==="state_snapshot"){_&&(_.workerState=Un({...e.state||{},updatedAt:Date.now()}),e?.activeRun?.runId&&e?.activeRun?.text&&!_.pendingRun&&(_.pendingRun=Mo({id:e.activeRun.runId,text:e.activeRun.text,startedAt:e.activeRun.startedAt,attempts:0,autoResume:!0})),e?.activeRun?.runId&&e?.activeRun?.text&&j?.setActiveRun({runId:e.activeRun.runId,text:e.activeRun.text}),_.workerState&&j?.setWorkerContext(mc(_.workerState)),Me());return}if(e.type==="task_started"){Pe("task_started",{taskId:e.taskId,reason:"worker"});return}if(e.type==="run_started"){Ar="",Fn(),typeof e.runId=="string"&&e.runId&&jt.delete(e.runId);let t=_?.pendingRun;sn(Mo({id:e.runId,text:e.text,startedAt:t?.startedAt||Date.now(),attempts:t?.attempts||0,autoResume:t?.autoResume!==!1})),j?.setActiveRun({runId:e.runId,text:String(e.text||"")});let n=`run:${String(e.runId||"")}:start`;_?.timeline.some(o=>o.id===n)||ze({id:n,kind:"plan",title:e.resume?"Run resumed":"Run started",detail:String(e.text||""),status:"pending"});return}if(e.type==="run_completed"){Ar="",_?.pendingRun?.id===e.runId&&sn(void 0),_&&e?.route&&(e.route.mode==="act"||e.route.mode==="planner")&&(_.lastRoutingDecision={mode:e.route.mode,score:Number(e.route.score)||void 0,reason:typeof e.route.reason=="string"?rt(e.route.reason,200):void 0,ts:Date.now()},Me()),j?.setActiveRun(void 0),!e.ok&&e.error?(zt(`Task failed: ${String(e.error)}`),jt.delete(String(e.runId||"")),ze({kind:"error",title:"Run failed",detail:String(e.error),status:"error"})):e.ok&&(zt("Execution completed"),Kd(typeof e.runId=="string"?e.runId:void 0),typeof e.runId=="string"&&e.runId&&jt.delete(e.runId));return}if(e.type==="ready"){ln=!0,zt("ready"),Pe("ready");let t=j?.getWorkerContext(),n=Un(t),o=Number(_?.workerState?.updatedAt)||0,r=Number(n?.updatedAt)||0,s=n&&r>o+100?n:_?.workerState;_&&s&&s!==_.workerState&&(_.workerState=s,Me()),s?(De?.postMessage({type:"hydrate_state",state:s}),Pe("context_restored",{source:"runtime_start",ts:Date.now()})):Pr();return}if(e.type==="hydrated"){Pr();return}e.type==="updated"&&Pe("updated")}}function Jd(e){if(Br(e),j){let r=j.getRole();lt=r,_&&(_.executionMode=r)}wc(e);let t=(e.allowActions??!0)&&(j?j.isController():!0);gt=new Rr({allowActions:t,runtimeId:Ge,allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy,crossDomainPolicy:e.crossDomainPolicy,registerOpenedTab:r=>j?.registerOpenedTab(r),switchToLogicalTab:r=>j?.switchToLogicalTab(r)||{ok:!1,reason:"No session coordinator"},listKnownTabs:()=>(j?.listTabs()||[]).map(r=>({logicalTabId:r.logicalTabId,runtimeId:r.runtimeId,url:r.url,title:r.title,external:!!r.external})),onNavigationGuardrail:r=>{Pe("navigation_guardrail",r),ze({kind:"status",title:"Navigation guardrail",detail:Nr(r),status:"info"})},instrumentationOptions:e.mode==="safe"?{observeInlineMutations:!1}:void 0});let n=new MessageChannel;Xa(n.port1,{getSnapshot:()=>gt.getSnapshot(),getPageData:r=>gt.getPageData(r),executeTool:r=>gt.executeTool(r.call,r.payload),executeClientTool:r=>gt.executeClientTool(r.name,r.args),listClientTools:()=>gt.listClientTools(),getTabContext:()=>{let r=j?.getLocalLogicalTabId(),s=j?.getActiveLogicalTabId();return{id:r||1,logicalTabId:r||1,activeLogicalTabId:s||r||1,runtimeId:Ge,mode:lt,url:window.location.href,title:document.title}},listSessionTabs:()=>j?.listTabs()||[]}),n.port1.start?.();let o=e.workerUrl?e.workerUrl:new URL("./worker/worker.js",__ROVER_SCRIPT_URL__).toString();De=new Worker(o,{type:"module"}),De.postMessage({type:"init",config:e,port:n.port2},[n.port2]),we=Ka({onSend:r=>{Lr(r)},onRequestControl:()=>{j?.requestControl()??!1?ze({kind:"status",title:"Control requested",detail:"This tab is now the active Rover controller.",status:"info"}):Nt("system","Unable to acquire control right now. Try again in a moment.",!0)},onNewTask:()=>{Do({reason:"manual_new_task",clearUi:!0})},onEndTask:()=>{Yr({reason:"manual_end_task"})},onTaskSuggestionPrimary:()=>{let r=On;r&&Lr(r.text,{bypassSuggestion:!0,startNewTask:!0,reason:r.reason})},onTaskSuggestionSecondary:()=>{let r=On;r&&Lr(r.text,{bypassSuggestion:!0})},showTaskControls:e.ui?.showTaskControls!==!1,mascot:{mp4Url:e.ui?.mascot?.mp4Url,webmUrl:e.ui?.mascot?.webmUrl},onOpen:()=>{_&&(_.uiOpen=!0,_.uiHidden=!1,Me()),Pe("open")},onClose:()=>{_&&(_.uiOpen=!1,Me()),Pe("close")}}),Fn(),_?.uiMessages?.length&&Ps(_.uiMessages),_?.timeline?.length&&Bs(_.timeline),_?.uiStatus&&we.setStatus(_.uiStatus),_?.executionMode&&we.setExecutionMode(_.executionMode,{localLogicalTabId:j?.getLocalLogicalTabId(),activeLogicalTabId:j?.getActiveLogicalTabId(),controllerRuntimeId:j?.getCurrentHolderRuntimeId(),canTakeControl:!0,canComposeInObserver:fc(),note:hc(_.executionMode)}),De.onmessage=r=>{Qd(r.data||{})},_?.uiHidden?we.hide():(we.show(),_?.uiOpen??!!e.openOnInit?we.open():we.close()),_&&(_.uiHidden=!!_.uiHidden,_.uiOpen=!!_.uiOpen,Me()),j&&(Ws(j.getState(),"remote"),Co(j.getRole(),{localLogicalTabId:j.getLocalLogicalTabId(),activeLogicalTabId:j.getActiveLogicalTabId(),holderRuntimeId:j.getCurrentHolderRuntimeId()}))}function $r(e){if(Ln)return Wr(e),Ln;Dn=ec(),Ge=kd(e.siteId),ct=cc(e),no=Md(e.siteId);let t=Fd(no),n=e.sessionId?.trim(),o=!n&&!t?.sessionId&&e.sessionScope!=="tab"&&ct?Ad(e.siteId,ct):void 0,r=n||t?.sessionId||o||crypto.randomUUID();if(_=Ao(t,r,Ge),n&&_.sessionId!==n&&(_=uc(n,Ge)),Se={...e,visitorId:ct||e.visitorId,sessionId:n||_.sessionId,taskRouting:{mode:e.taskRouting?.mode||"act",actHeuristicThreshold:e.taskRouting?.actHeuristicThreshold,plannerOnActError:e.taskRouting?.plannerOnActError},taskContext:{inactivityMs:e.taskContext?.inactivityMs??Fs,suggestReset:e.taskContext?.suggestReset??!0,semanticSimilarityThreshold:e.taskContext?.semanticSimilarityThreshold??Hs}},_.sessionId=Se.sessionId,_.runtimeId=Ge,_.executionMode=_.executionMode||"controller",_.timeline=Io(_.timeline),_.uiMessages=ko(_.uiMessages),_.activeTask=No(_.activeTask,cn("boot")),_.taskEpoch=Math.max(1,Number(_.taskEpoch)||1),lt=_.executionMode,Me(),ln=!1,Ur=!1,Jd(Se),no&&qd(no),Wd(),Ln={boot:$r,init:Vs,update:Wr,shutdown:$s,open:Lo,close:Gr,show:Gs,hide:Ys,send:qs,newTask:Do,endTask:Yr,getState:Xs,registerTool:js,on:ic},Mr.length){for(let s of Mr)lc(s);Mr.length=0}return Ln}function Vs(e){return $r(e)}function Wr(e){!Ln||!De||!Se||(Se={...Se,...e,taskRouting:{...Se.taskRouting,...e.taskRouting},taskContext:{inactivityMs:e.taskContext?.inactivityMs??Se.taskContext?.inactivityMs??Fs,suggestReset:e.taskContext?.suggestReset??Se.taskContext?.suggestReset??!0,semanticSimilarityThreshold:e.taskContext?.semanticSimilarityThreshold??Se.taskContext?.semanticSimilarityThreshold??Hs},ui:{...Se.ui,...e.ui,panel:{...Se.ui?.panel,...e.ui?.panel}}},ct=cc(Se),ct&&(Se.visitorId=ct),e.sessionId&&_?(_.sessionId=e.sessionId,Me(),Br(Se)):(e.sessionScope||e.tabPolicy)&&Br(Se),wc(Se),gt&&(typeof e.allowActions=="boolean"&>.setAllowActions(e.allowActions&<==="controller"),(e.allowedDomains||e.crossDomainPolicy||e.domainScopeMode||e.externalNavigationPolicy)&>.setNavigationPolicy({allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy,crossDomainPolicy:e.crossDomainPolicy})),De.postMessage({type:"update_config",config:e}),typeof e.openOnInit=="boolean"&&(e.openOnInit?Lo():Gr()))}function $s(){Fn(),Me(),bt?.markDirty(),bt?.syncNow(),bt?.stop(),bt=null,j?.stop(),j=null,De?.terminate(),De=null,we?.destroy(),we=null,gt=null,Se=null,ln=!1,Ur=!1,Ge="",ct=void 0,Or=!1,lt="controller",On=null,Dn=null,Ln=null}function Lo(){we?.show(),we?.open(),_&&(_.uiHidden=!1,_.uiOpen=!0,Me())}function Gr(){we?.close(),_&&(_.uiOpen=!1,Me())}function Gs(){we?.show(),_&&(_.uiHidden=!1,Me())}function Ys(){we?.hide(),_&&(_.uiHidden=!0,_.uiOpen=!1,Me())}function qs(e){e?.trim()&&Lr(e)}function Do(e){if(!_)return;let t=e?.reason||"manual_new_task",n=e?.clearUi!==!1,o=Math.max(1,Number(_.taskEpoch)||1)+1,r=cn(t);_.taskEpoch=o,_.activeTask=r,_.pendingRun=void 0,_.workerState=void 0,n&&(_.uiMessages=[],_.timeline=[],_.uiStatus=void 0,gc()),j?.startNewTask({taskId:r.taskId,startedAt:r.startedAt,boundaryReason:t,status:"running",lastUserAt:void 0,lastAssistantAt:void 0}),j?.setActiveRun(void 0),j?.setWorkerContext(void 0),zt("New task started."),Me(),De?.postMessage({type:"start_new_task",taskId:r.taskId}),ze({kind:"info",title:"Started new task",detail:t,status:"info"}),Pe("task_started",{taskId:r.taskId,reason:t,taskEpoch:o})}function Yr(e){if(!_)return;let t=e?.reason||"manual_end_task",n=Vr("manual_end_task");n&&(n.status="ended",n.endedAt=Date.now(),n.boundaryReason=t,_.pendingRun=void 0,Fn(),zt("Task ended. Start a new task to continue."),j?.endTask(t),j?.setActiveRun(void 0),Me(),ze({kind:"info",title:"Task ended",detail:"Start a new task when you are ready.",status:"info"}),Pe("task_ended",{taskId:n.taskId,reason:t,endedAt:n.endedAt}))}function Xs(){return{mode:lt,runtimeId:Ge,runtimeState:_?Ec(_):null,sharedState:j?.getState()||null,pendingTaskSuggestion:On}}function js(e,t){let n=Sd(e);if(!Ln||!gt||!De){Mr.push({def:n,handler:t});return}lc({def:n,handler:t})}function Zd(e){if(!e)return;let t=String(e);if(t==="init")return"init";if(t==="boot")return"boot";if(t==="update")return"update";if(t==="shutdown")return"shutdown";if(t==="open")return"open";if(t==="close")return"close";if(t==="show")return"show";if(t==="hide")return"hide";if(t==="send")return"send";if(t==="newTask")return"newTask";if(t==="endTask")return"endTask";if(t==="getState")return"getState";if(t==="registerTool")return"registerTool";if(t==="on")return"on"}function yc(){let e=window,t=e.rover,n=((o,...r)=>{let s=Zd(o),c=s?n[s]:void 0;if(typeof c=="function")return c(...r)});if(n.boot=$r,n.init=Vs,n.update=Wr,n.shutdown=$s,n.open=Lo,n.close=Gr,n.show=Gs,n.hide=Ys,n.send=qs,n.newTask=Do,n.endTask=Yr,n.getState=Xs,n.registerTool=js,n.on=ic,e.rover=n,typeof t=="function"&&Array.isArray(t.q))for(let o of t.q){let[r,...s]=Array.isArray(o)?o:Array.from(o);typeof r=="string"&&n(r,...s)}}yc();return kc(ef);})();
|