@rtrvr-ai/rover 1.0.2 → 1.0.3
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 +31 -10
- package/dist/rover.js +114 -12
- package/dist/worker/rover-worker.js +20 -5
- package/package.json +1 -1
package/dist/embed.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
var __ROVER_SCRIPT_EL__=document.currentScript||null;var __ROVER_SCRIPT_URL__=(__ROVER_SCRIPT_EL__&&__ROVER_SCRIPT_EL__.src)||'';
|
|
2
|
-
"use strict";var __roverSDK=(()=>{var Br=Object.defineProperty;var Ac=Object.getOwnPropertyDescriptor;var Cc=Object.getOwnPropertyNames;var Mc=Object.prototype.hasOwnProperty;var Lc=(e,t,n)=>t in e?Br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Nc=(e,t)=>{for(var n in t)Br(e,n,{get:t[n],enumerable:!0})},Dc=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Cc(t))!Mc.call(e,o)&&o!==n&&Br(e,o,{get:()=>t[o],enumerable:!(r=Ac(t,o))||r.enumerable});return e};var Oc=e=>Dc(Br({},"__esModule",{value:!0}),e);var $=(e,t,n)=>Lc(e,typeof t!="symbol"?t+"":t,n);var uf={};Nc(uf,{boot:()=>Dr,close:()=>Ko,endTask:()=>Qo,getState:()=>Zs,hide:()=>Qs,init:()=>zs,installGlobal:()=>Sc,newTask:()=>Hr,open:()=>Fr,registerTool:()=>ei,send:()=>Js,show:()=>Ks,shutdown:()=>js,update:()=>zo});var L;(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"})(L||(L={}));var ff=new Set(Object.values(L));var Fc=40;function ni(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(r=>Math.trunc(Number(r))))).filter(r=>Number.isFinite(r)&&r>0).slice(0,Fc)}var vt;(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"})(vt||(vt={}));var ri={[vt.Unknown]:"unknown",[vt.React]:"react",[vt.Vue]:"vue",[vt.Angular]:"angular",[vt.Svelte]:"svelte",[vt.JQuery]:"jquery"},Jo={react:vt.React,vue:vt.Vue,angular:vt.Angular,svelte:vt.Svelte,jquery:vt.JQuery},Be;(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"})(Be||(Be={}));var mf={[Be.Other]:"other",[Be.Inline]:"inline",[Be.Delegated]:"delegated",[Be.React]:"react",[Be.Vue]:"vue",[Be.Angular]:"angular",[Be.Svelte]:"svelte",[Be.JQuery]:"jquery",[Be.Native]:"native"},gf={inline:Be.Inline,delegated:Be.Delegated,react:Be.React,vue:Be.Vue,angular:Be.Angular,svelte:Be.Svelte,jquery:Be.JQuery,other:Be.Other,native:Be.Native},le;(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"})(le||(le={}));var Wr={[L.click_element]:le.click_element,[L.type_into_element]:le.type_into_element,[L.type_and_enter]:le.type_and_enter,[L.select_dropdown_value]:le.select_dropdown_value,[L.clear_element]:le.clear_element,[L.focus_element]:le.focus_element,[L.hover_element]:le.hover_element,[L.right_click_element]:le.right_click_element,[L.double_click_element]:le.double_click_element,[L.long_press_element]:le.long_press_element,[L.drag_element]:le.drag_element,[L.drag_and_drop]:le.drag_and_drop,[L.swipe_element]:le.swipe_element,[L.adjust_slider]:le.adjust_slider,[L.describe_images]:le.describe_images,[L.scroll_to_element]:le.scroll_to_element,[L.paste_text]:le.paste_text,[L.check_field_validity]:le.check_field_validity,[L.select_text]:le.select_text,[L.mouse_wheel]:le.mouse_wheel,[L.copy_text]:le.copy_text,[L.upload_file]:le.upload_file,[L.go_back]:le.go_back,[L.go_forward]:le.go_forward,[L.refresh_page]:le.refresh_page,[L.press_key]:le.press_key,[L.scroll_page]:le.scroll_page,[L.wait_action]:le.wait_action,[L.wait_for_element]:le.wait_for_element,[L.pinch_zoom]:le.pinch_zoom,[L.goto_url]:le.goto_url,[L.google_search]:le.google_search,[L.open_new_tab]:le.open_new_tab,[L.switch_tab]:le.switch_tab,[L.close_tab]:le.close_tab,[L.solve_captcha]:le.solve_captcha,[L.answer_task]:le.answer_task,[L.dispatch_pointer_path]:le.dispatch_pointer_path,[L.network_run_recipe]:le.network_run_recipe},oi=Object.fromEntries(Object.entries(Wr).map(([e,t])=>[t,e]));function Vr(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 ii={semanticIdStart:1,interactiveIdStart:1,includeFrameContents:!0,clearIframes:!0,frameContextLabel:null,signalProvider:null,disableDomAnnotations:!1},ut={...ii},Gr=globalThis;function ai(e){ut={...ii,...e||{}}}function vn(){return ut.signalProvider??null}function Xe(){try{return typeof Gr.document<"u"?Gr.document:null}catch{return null}}function $t(){try{return typeof Gr.window<"u"?Gr.window:null}catch{return null}}function G(e,t){if(e&&typeof e=="object"){let n=e.ownerDocument;if(n)return n;if(e.nodeType===9)return e}return t??Xe()??{}}function re(e,t){return G(e,t?t.document:null)?.defaultView??t??$t()??{}}function Y(e,t){return e?.defaultView??t??$t()??{}}function qr(e,t){try{return e?.getElementById?.(t)??null}catch{return null}}function Yr(e,t){try{return e?.querySelector?.(t)??null}catch{return null}}function Zo(e,t){try{return Array.from(e?.querySelectorAll?.(t)??[])}catch{return[]}}function _n(e){try{return e.contentDocument||(e.contentWindow?.document??null)}catch{return null}}function Xr(e,t){let n=e.CSS?.escape;return typeof n=="function"?n(t):t.replace(/([^\w-])/g,"\\$1")}function _t(e,t){try{return e[t]}catch{return}}function Gt(e,t){return!!e&&String(e.tagName||"").toUpperCase()===t.toUpperCase()}function ci(e,t){let n=_t(t,"HTMLAnchorElement");return n?e instanceof n:Gt(e,"A")}function At(e,t){let n=_t(t,"HTMLInputElement");return n?e instanceof n:Gt(e,"INPUT")}function Ft(e,t){let n=_t(t,"HTMLTextAreaElement");return n?e instanceof n:Gt(e,"TEXTAREA")}function li(e,t){let n=_t(t,"HTMLLabelElement");return n?e instanceof n:Gt(e,"LABEL")}function ui(e,t){let n=_t(t,"HTMLSelectElement");return n?e instanceof n:Gt(e,"SELECT")}function di(e,t){let n=_t(t,"HTMLSlotElement");return n?e instanceof n:Gt(e,"SLOT")}function fi(e,t){let n=_t(t,"HTMLButtonElement");return n?e instanceof n:Gt(e,"BUTTON")}function pi(e,t){let n=_t(t,"HTMLImageElement");return n?e instanceof n:Gt(e,"IMG")}function hi(e,t){let n=_t(t,"HTMLVideoElement");return n?e instanceof n:Gt(e,"VIDEO")}function mi(e,t){let n=_t(t,"HTMLCanvasElement");return n?e instanceof n:Gt(e,"CANVAS")}function We(e,t){if(!e||e.nodeType!==1)return!1;let n=_t(t,"HTMLElement");return n?e instanceof n:typeof e.tagName=="string"}function Tt(e){return!!e&&e.nodeType===11&&typeof e.host=="object"&&typeof e.mode=="string"}function Tn(e){if(!e||e.nodeType!==1)return!1;let t=G(e),r=Y(t).Element;return r?e instanceof r:typeof e.tagName=="string"}function dr(e){if(!e||e.nodeType!==1)return!1;let t=G(e),r=Y(t).HTMLIFrameElement;return r&&e instanceof r?!0:String(e.tagName||"").toUpperCase()==="IFRAME"}function Hc(e,t){if(!e)return!1;if(e.nodeType===9)return!0;let n=_t(t,"Document");return n?e instanceof n:!1}function Uc(e,t){if(!e)return!1;let n=_t(t,"Window");if(n)return e instanceof n;try{return e.window===e}catch{return!1}}function zr(e){try{return e.document}catch{return null}}function jr(e,t){if(Hc(e,t))try{return e.documentElement}catch{return null}if(Uc(e,t)){let n=zr(e);if(!n)return null;try{return n.documentElement}catch{return null}}return null}function $r(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 si(e,t,n){try{let r=G(t,n);return new URL(e,r.baseURI).href}catch{return e}}function gi(e,t){let n=e.tagName.includes("-"),r=e.getAttribute("href")||e.getAttribute("src")||e.getAttribute("data")||e.getAttribute("action");if(r){let o=si(r,e,t);return o.trim().toLowerCase().startsWith("javascript:")?null:o}if(n)return null;try{let o=e,s=$r(o.href)||$r(o.src)||$r(o.data)||$r(o.action);return s?si(s,e,t):null}catch{return null}}var bi=["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"],we={};bi.forEach((e,t)=>{we[e]=t});var Qt={};bi.forEach((e,t)=>{Qt[t]=e});function xn(e){if(!e)return null;let t=e.trim();if(!t||!t.includes("~"))return null;let n=[];for(let r of t.split(",")){if(!r)continue;let[o,s]=r.split("~"),i=Number(o);if(!Number.isFinite(i))continue;let c=s&&parseInt(s,36)||0;n.push({id:i,mask:c})}return n.length?{entries:n}:null}function Pc(e){let t=xn(e);if(t){let n=new Set;for(let{id:r}of t.entries)n.add(r);return[...n]}return[]}function fr(e){return $n(e).map(n=>Qt[n]).filter(n=>!!n)}function $n(e){let t=vn();if(t?.getEventHandlerIds)try{let o=t.getEventHandlerIds(e);if(o&&o.length)return o}catch{}let n=e.getAttribute(an),r=Pc(n);return!r||r.length===0?[]:r}var es=["media"],Ei=new Set(es),ts=["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 wi=new Set(ts),Jt=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"]),pr=new Set(["group","region","section","banner","contentinfo","main","navigation","complementary","form","article","document","presentation","none"]);var yi=["none","presentation"],fe;(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"})(fe||(fe={}));var vi={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"]},hr={heading:{selector:"h6,h1,h3,h2,h5,h4"},checkbox:{conditionalSelectors:[{selector:"input",conditions:[{type:fe.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:fe.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"grid"}]},{selector:"td",conditions:[{type:fe.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"treegrid"}]},{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:fe.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"treegrid"},{type:fe.HAS_TABLE_COLUMN_DATA,hasData:!0},{type:fe.HAS_TABLE_ROW_DATA,hasData:!0}]}]},slider:{conditionalSelectors:[{selector:"input",conditions:[{type:fe.PROPERTY_VALUE_MATCH,property:"type",values:["range"]}]}]},listitem:{selector:"li"},contentinfo:{conditionalSelectors:[{selector:"footer",conditions:[{type:fe.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:fe.PROPERTY_VALUE_MATCH,property:"type",values:["submit","reset","image","button"]}]}]},status:{selector:"output"},form:{conditionalSelectors:[{selector:"form",conditions:[{type:fe.HAS_ACCESSIBLE_NAME}]}]},article:{selector:"article"},textbox:{selector:"textarea",conditionalSelectors:[{selector:"input:not([list])",conditions:[{type:fe.PROPERTY_VALUE_MATCH,property:"type",values:["url","text","tel","email"]}]}]},radio:{conditionalSelectors:[{selector:"input",conditions:[{type:fe.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:fe.HAS_TABLE_ROW_DATA,hasData:!1}]}]},list:{selector:"ul,ol,menu"},region:{conditionalSelectors:[{selector:"section",conditions:[{type:fe.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:fe.PROPERTY_VALUE_MATCH,property:"type",values:["search"]}]}]},cell:{conditionalSelectors:[{selector:"td",conditions:[{type:fe.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"table"}]},{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:fe.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"table"},{type:fe.HAS_TABLE_COLUMN_DATA,hasData:!0},{type:fe.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:fe.HAS_TABLE_COLUMN_DATA,hasData:!1},{type:fe.HAS_TABLE_ROW_DATA,hasData:!0}]}]},dialog:{selector:"dialog"},listbox:{selector:"select[multiple],datalist",conditionalSelectors:[{selector:"select",conditions:[{type:fe.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:fe.PROPERTY_VALUE_MATCH,property:"type",values:["number"]}]}]},math:{selector:"math"},combobox:{selector:"select:not([size]):not([multiple])",conditionalSelectors:[{selector:"select:not([multiple])",conditions:[{type:fe.ATTRIBUTE_LESS_THAN,attribute:"size",value:2}]},{selector:"input[list]",conditions:[{type:fe.PROPERTY_VALUE_MATCH,property:"type",values:["url","text","tel","search","email"]}]}]},banner:{conditionalSelectors:[{selector:"header",conditions:[{type:fe.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"}},an="rtrvr-ls",Zt="rtrvr-ro",ns="rtrvr-mw-ready",mr="rtrvr-mw-busy",rs="rtrvr-mwa-ready",_i=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"]),Ti=["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"],xi=["h1","h2","h3","h4","h5","h6"],Ri="http://www.w3.org/1999/xhtml",ki="http://www.w3.org/2000/svg",st="rtrvr-label";var Jr=new Set(["NOSCRIPT","SCRIPT","STYLE","META"]),Rn="CODE",kn="PRE",Ii="aria-hidden",Si="target";var Kr;(function(e){e[e.value=0]="value",e[e.alt=1]="alt",e[e.list=2]="list",e[e.title=3]="title"})(Kr||(Kr={}));var Gn;(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"})(Gn||(Gn={}));var Qr;(function(e){e[e.VALUENOW=0]="VALUENOW",e[e.VALUETEXT=1]="VALUETEXT"})(Qr||(Qr={}));var os=new Set([we.click,we.dblclick,we.doubleclick,we.contextmenu,we.auxclick,we.pointerdown,we.pointerup,we.mousedown,we.mouseup,we.touchstart,we.touchend,we.keydown,we.keyup,we.input,we.beforeinput,we.change,we.submit,we.reset,we.paste,we.dragstart,we.dragend,we.drop]),Ai=new Set([...os,we.scroll,we.wheel,we.mouseenter,we.mouseover,we.focus,we.blur,we.focusin,we.focusout]),Zr=new Set(["click","dblclick","auxclick","contextmenu","mousedown","mouseup","pointerdown","pointerup","touchstart","touchend"]),ss=new Set(["input","change","beforeinput","keydown","keyup","keypress","paste","compositionstart","compositionend"]),is=new Set(["drag","dragstart","dragend","dragenter","dragleave","dragover","drop"]);var gr;(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"})(gr||(gr={}));var br;(function(e){e[e.HTML=0]="HTML",e[e.SVG=1]="SVG"})(br||(br={}));var eo;(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"})(eo||(eo={}));var to;(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"})(to||(to={}));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 tt;(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"})(tt||(tt={}));var en;(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"})(en||(en={}));var Bc=[...ts,...Object.keys(hr),...es],Ci=[...new Set(Bc)],qn={};Ci.forEach((e,t)=>{qn[e]=t});var Er={};Ci.forEach((e,t)=>{Er[t]=e});var no=class{constructor(t=1){$(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 wr(e){let t=vn();if(t?.getRoleHint)try{let o=t.getRoleHint(e);if(o)return o}catch{}let n=e.getAttribute(Zt);if(!n)return null;let r=n.trim();if(!r)return null;if(r.startsWith("s:"))return r.slice(2);if(/^\d+$/.test(r)){let o=Number(r);if(Number.isFinite(o)){let s=Er[o];if(s)return s}}return r}function Yn(e){return Array.from(new Set(e))}function Mi(e,t){if(!e||e.length===0)return Yn(t);let n=new Set([...e,...t]);return Yn(Array.from(n))}function xt(e,t){let r=vn()?.getEventHandlerIds?.(e)??$n(e),o=r.length>0&&r.some(c=>os.has(c)),s=ro(e),i=t?pr.has(t):!1;return{element:e,semanticRole:t,eventHandlerIndices:r,isEditableRegion:s,hasNodeWorthyHandlers:o,isLikelyStructuralContainer:i}}var Wc=new Set(["text","search","url","tel","password","email","number","date","datetime-local","time","month","week","color"]);function Vc(e){let n=re(e).getComputedStyle(e);if(n.display==="none"||n.visibility==="hidden"||n.pointerEvents==="none")return!1;let r=e.getBoundingClientRect();return!(r.width===0||r.height===0)}function $c(e){let t=re(e);if(!At(e,t))return!1;let n=(e.type||"text").toLowerCase();return Wc.has(n)?!e.disabled&&!e.readOnly:!1}function Gc(e){let t=re(e);return Ft(e,t)&&!e.disabled&&!e.readOnly}function qc(e){let t=e;return!(!t.isContentEditable||t.getAttribute("aria-readonly")==="true"||t.getAttribute("aria-disabled")==="true")}function ro(e){return!e||!Vc(e)?!1:!!($c(e)||Gc(e)||qc(e))}function yr(e){if(!e)return null;let t=e.match(/^\s*\[id=(\d+)\]/);if(t?.[1]){let o=parseInt(t[1],10);return Number.isFinite(o)?o:null}let n=/\[id=(\d+)\]/g,r;for(;r=n.exec(e);){let o=r.index??0,s=e.slice(Math.max(0,o-30),o);if(/iframeRoot\s*=\s*$/.test(s)||s.includes("iframeRoot="))continue;let i=parseInt(r[1],10);if(Number.isFinite(i))return i}try{let o=e.match(LABEL_ID_PATTERN);if(o?.[1]){let s=parseInt(o[1],10);return Number.isFinite(s)?s:null}}catch{}return null}function vr(e){let t=String(e??"").replace(/[\n\r\t]/g," ").replace(/\s+/g," ").trim();return t=t.replace(/\[/g,"[").replace(/\]/g,"]"),t}function Li({element:e,elementID:t,frameContextLabel:n}){let r=!ut.disableDomAnnotations,o=[`[id=${t}]`],s=re(e);if(dr(e)){let f=vr(e.id||e.getAttribute("name")||"unnamed");o.push(`[iframe=${f}]`)}if(n){let f=vr(n);o.push(`[iframeRoot=${f}]`)}if(pi(e,s)&&o.push(`[size=${e.clientWidth}x${e.clientHeight}]`),(hi(e,s)||mi(e,s))&&o.push(`[size=${e.clientWidth}x${e.clientHeight}]`),At(e,s)||Ft(e,s)){let f=Yc(e);o.push(...f)}e.getAttribute(Ii)==="true"&&o.push("[aria-hidden=true]"),e.disabled&&o.push("[disabled]"),r&&ci(e,s)&&e.setAttribute(Si,"_self");let c=o.join(" ");return r&&e.setAttribute(st,c),c}function Yc(e){let t=[],n=re(e),r=At(e,n);if(r&&e.type&&e.type!=="text"&&t.push(`[type=${e.type}]`),e.name){let o=vr(e.name);o&&t.push(`[name=${o}]`)}if(r&&e.multiple&&t.push("[multiple]"),r&&(e.type==="checkbox"||e.type==="radio")&&t.push(`[checked=${e.checked}]`),r&&e.type==="file"&&e.files?.length&&t.push(`[files=${e.files.length}]`),r&&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}]`)),r&&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}]`),r&&e.pattern&&t.push("[pattern]"),e.autocomplete&&e.autocomplete!=="off"&&t.push(`[autocomplete=${e.autocomplete}]`),e.placeholder){let o=vr(e.placeholder).replace(/\\/g,"\\\\").replace(/"/g,'\\"');o&&t.push(`[placeholder="${o}"]`)}if(e.value){let o=e.value;r&&e.type==="password"&&(o="*".repeat(Math.min(o.length,10)));let s=vr(o).replace(/\\/g,"\\\\").replace(/"/g,'\\"');t.push(`[value="${s}"]`)}return t}var _r=new no,as=new WeakMap;function Ni(){as=new WeakMap}function oo(e){let t=as.get(e);if(t)return t;let n=_r.generateId();return as.set(e,n),n}var so=new Map,cs=new WeakMap;function Di(){so.clear(),cs=new WeakMap}function ls(e,t){try{typeof WeakRef<"u"?so.set(e,new WeakRef(t)):so.set(e,t)}catch{}}function Tr(e){let t=so.get(e);if(!t)return null;let n=t instanceof WeakRef?t.deref():t;return!n||n.isConnected===!1?null:n}function cn(e){let t=null,n=oo(e);if(ut.frameContextLabel)t=ut.frameContextLabel;else{let o=Xe();if(o&&e.ownerDocument!==o)try{let i=e.ownerDocument?.defaultView?.frameElement?.getAttribute(st)||"",c=i?yr(i):null;t=c?String(c):null}catch{t=""}}let r=Li({element:e,elementID:n,frameContextLabel:t});if(ls(n,e),r)try{cs.set(e,r)}catch{}return r}function Oi(e){return cs.get(e)??null}function us(e,t){try{e.querySelectorAll?.(`[${st}]`)?.forEach(r=>r.removeAttribute(st))}catch{}if(t.includeShadow)try{let n=e.querySelectorAll?.("*");if(n)for(let r of Array.from(n))try{let o=r.shadowRoot;o&&us(o,t)}catch{}}catch{}if(t.includeIframes)try{let n=e.querySelectorAll?.("iframe");if(n)for(let r of Array.from(n))try{let o=_n(r);o?.body&&us(o.body,t)}catch{}}catch{}}function Fi(e,t={}){if(ut.disableDomAnnotations)return;let n=Tn(e)?re(e):Y(e)??window,r=jr(e,n)??e;if(r){try{r.removeAttribute?.(st)}catch{}us(r,{includeShadow:t.includeShadow??!0,includeIframes:t.includeIframes??!0})}}var ln={},ds=new WeakMap,io=new WeakSet;function Hi(){ln={},ds=new WeakMap,io=new WeakSet,Ni()}function it({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,originatedFromParent:i,elementContext:c}){let f=oo(e);ls(f,e);let v=ln[f];if(i){if(!v){let b={nodeCategory:e.nodeType,provisionalFromParent:!0},w=e.nodeName;w&&w.trim()&&(b.elementName=w);let I=e.getAttribute("role");I&&(b.preservedAttributes={1:I});let x=e.tagName;x&&(b.elementTag=x),ln[f]=b}}else{if(v&&!v.provisionalFromParent){if((o||Xn(e))&&(v.isFrameElement=!0,s&&s.length>0&&(v.frameContent=s)),c){let{eventHandlerIndices:b,isEditableRegion:w}=c;if(b&&b.length>0){let I=Yn(b);I.length>0&&(v.eventHandlers=Mi(v.eventHandlers,I))}w&&(v.isEditable=!0)}return f}if(io.has(e))return f;io.add(e);try{ln[f]=Ui({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,elementContext:c})}finally{io.delete(e)}}return f}function xr(e){let t=ds.get(e);if(t!==void 0)return t;let r=(e.textContent||"").replace(/\s+/g," ").trim(),o=e.data?.replace(/\s+/g," ").trim();if(!r&&!o)return 0;let s=_r.generateId(),i={textContent:r,nodeCategory:e.nodeType};return o&&o!==r&&(i.rawData=o),ln[s]=i,ds.set(e,s),s}function Bi(e,t){let n=Vi(e),{minY:r,maxY:o}=n.getCellBounds(t);return n.getRows().slice(r,o+1).some(s=>s.some(Rr))}function Wi(e,t){let n=Vi(e),{minX:r,maxX:o}=n.getCellBounds(t);return n.getRows().some(s=>s.slice(r,o+1).some(Rr))}var co=class{constructor(t=[]){$(this,"cells");$(this,"getCellAt",(t,n)=>this.getRowAt(n)[t]);$(this,"setCellAt",(t,n,r)=>{this.getRowAt(n)[t]=r});$(this,"getRowAt",t=>(this.cells[t]===void 0&&(this.cells[t]=[]),this.cells[t]));$(this,"getRows",()=>this.cells);$(this,"getCellBounds",t=>{let n=this.columnCount,r=this.rowCount,o=-1,s=-1;for(let i=0;i<this.rowCount;i++){let c=this.getRowAt(i),f=c.indexOf(t);f!==-1&&(o=Math.max(o,c.lastIndexOf(t)),s=Math.max(s,i),n=Math.min(n,f),r=Math.min(r,i))}return{minX:n,minY:r,maxX:o,maxY:s}});$(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 Vi(e){let n=re(e).TableGrid||co,r=new n;e.tHead!==null&&r.merge(ao(e.tHead.rows)),Array.from(e.tBodies).forEach(s=>{r.merge(ao(s.rows))});let o=[];for(let s of Array.from(e.children))fs(s)&&In(s,"tr")&&o.push(s);return r.merge(ao(o)),e.tFoot!==null&&r.merge(ao(e.tFoot.rows)),r}function ao(e){let t=new co,n=[];for(let r=0;r<e.length;r++){let o=0;for(let s of Array.from(e[r].cells)){for(;t.getCellAt(o,r)||n[o];)!Rr(t.getCellAt(o,r))&&n[o]&&t.setCellAt(o,r,n[o]),o++;for(let i=o;i<o+s.colSpan;i++){Pi(s)===0&&(n[i]=s,t.setCellAt(i,r,s));for(let c=r;c<r+Pi(s);c++)Rr(t.getCellAt(i,c))||t.setCellAt(i,c,s)}o+=s.colSpan}for(let s=o;s<t.columnCount;s++){let i=n[s];i!==void 0&&!Rr(t.getCellAt(s,r))&&t.setCellAt(s,r,i)}}return t}function Pi(e){let t=e.getAttribute("rowSpan");if(t===null||t.trim()==="")return 1;let n=Number(t);return isNaN(n)?1:n}function Rr(e){return e!==void 0&&In(e,"td")}function Ht(e){let t=e.tagName?.toLowerCase();if(t==="code"||t==="pre"){let r=tl(e);if(r)return r}let n=$i(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 o=e;switch(o.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 o.hasAttribute("list")?"combobox":"textbox"}}if(t==="select")return e.multiple?"listbox":"combobox";if(t==="svg"){if(e.getAttribute("aria-hidden")==="true")return null;let o=e.querySelector("title"),s=e.querySelector("desc"),i=e.hasAttribute("aria-label"),c=e.hasAttribute("role");return o||s||i||c||$n(e).length>0||e.getAttribute("tabindex")!==null?"img":null}if($n(e).length>0){let o=e.tagName.toLowerCase();if(["div","span","li","p","i","em","strong","b"].includes(o))return Xc(e)}}if(t==="td"&&e.getAttribute("role")===null)return"cell";if(n!==null&&t==="th"){let r=e.getAttribute("role");if(r&&Gi(r))return r;let o=e;return o.scope==="col"||o.hasAttribute("aria-sort")?"columnheader":o.scope==="row"?"rowheader":"cell"}return n}function Xc(e){return wr(e)??null}function $i(e){let t=e.getAttribute("role");if(t!==null)return yi.includes(t)||!Gi(t)?null:t;let n=e.tagName.toLowerCase();return(vi[n]??[]).find(o=>zc(e,o))||null}function zc(e,t){let n=hr[t],r=n?.selector;if(r&&lo(e,r))return!0;let o=n?.conditionalSelectors;return o?o.some(i=>lo(e,i.selector)&&i.conditions.every(f=>Kc(e,f))):!1}function jc(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let r=e.getRootNode?.();if(Tt(r)){let o=re(e),s=`#${Xr(o,n)}`,i=Yr(r,s);if(i)return i}}catch{}return qr(G(e),n)}function Kc(e,t){switch(t.type){case fe.ATTRIBUTE_GREATER_THAN:{let n=e.getAttribute(t.attribute);return n!==null&&Number(n)>t.value}case fe.ATTRIBUTE_LESS_THAN:{let n=e.getAttribute(t.attribute);return n!==null&&Number(n)<t.value}case fe.HAS_ACCESSIBLE_NAME:return e.hasAttribute("aria-label")?!0:(e.getAttribute("aria-labelledby")||"").split(/\s+/).filter(Boolean).some(r=>jc(e,r)!=null);case fe.FORBIDDEN_ANCESTORS:return tn(e,t.selector)===null;case fe.BOOLEAN_PROPERTY:return e[t.property]===t.value;case fe.PROPERTY_VALUE_MATCH:return t.values.some(n=>n===e[t.property]);case fe.ANCESTOR_ROLE_REQUIRED:{let n=e.parentElement;if(n===null)return!1;let r=tn(n,t.tag);return r!==null&&$i(r)===t.role}case fe.HAS_TABLE_COLUMN_DATA:{let n=tn(e,"table");return n===null?!1:t.hasData===Wi(n,e)}case fe.HAS_TABLE_ROW_DATA:{let n=tn(e,"table");return n===null?!1:t.hasData===Bi(n,e)}default:return Qc(t),!1}}function Qc(e){throw new Error(`unexpected value ${e}!`)}function Gi(e){return Zc(e)||el(e)||Jc(e)}function Jc(e){return Ei.has(e)}function Zc(e){return wi.has(e)}function el(e){return hr.hasOwnProperty(e)}function tl(e){if(e.tagName!==Rn&&e.tagName!==kn)return null;if(fr(e).some(r=>r==="click"||r==="copy"))return"button";let n=e.getAttribute("tabindex");return n!==null&&parseInt(n,10)>=0?"button":e.tagName===kn||e.tagName===Rn&&e.closest("pre")?"code":null}var nl={[tt.display]:[tt.beforeDisplay,tt.afterDisplay],[tt.content]:[tt.beforeContent,tt.afterContent]},ps=new Map,rl={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 ol(e,t){if(!ps.has(e)){let n=rl[t]||t.replace(/([A-Z])/g,"-$1").toLowerCase();ps.set(e,n)}return ps.get(e)}var sl={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 Xi(e,t,n){let r=sl[e];return r?r(t,n):t.trim()!==""&&!["initial","inherit","unset"].includes(t)}function zi(e){let t={},n=re(e);if(!We(e,n))return t;let r=n.getComputedStyle(e),o=new Map([[tt.beforeDisplay,n.getComputedStyle(e,"::before")],[tt.afterDisplay,n.getComputedStyle(e,"::after")],[tt.beforeContent,n.getComputedStyle(e,"::before")],[tt.afterContent,n.getComputedStyle(e,"::after")]]);for(let s in tt)if(isNaN(Number(s))){let i=tt[s],c=ol(i,s),f=nl[i];f?((i===tt.display||i===tt.content)&&qi(r,c,i,s,t,e),Yi(o.get(f[0]),c,f[0],"beforeContent",t),Yi(o.get(f[1]),c,f[1],"afterContent",t)):qi(r,c,i,s,t,e)}return t}function qi(e,t,n,r,o,s){if(e){let i=e.getPropertyValue(t);i&&Xi(r,i,s)&&(o[n]=i)}}function Yi(e,t,n,r,o){if(e){let s=e.getPropertyValue(t);(t==="content"&&s&&s!=="none"&&s!=='""'&&s!=="''"||s&&Xi(r,s))&&(o[n]=s)}}function Sn(e,t){let n=re(e);if(!We(e,n))return!0;if(t&&Jt.has(t))return!1;if(e.hasAttribute("hidden")||tn(e,"[hidden]")!==null||tn(e,"[inert]")!==null)return!0;let r=n.getComputedStyle(e);if(r.display==="none"||r.visibility==="hidden"||r.visibility==="collapse"||e.getClientRects().length===0)return!0;let o=e.getBoundingClientRect(),s=1e6;return Math.abs(o.left)>s||Math.abs(o.top)>s}function kr(e){return Ut(e)&&e.classList.contains("jasmine_html-reporter")}function il(e){let t=e.getAttribute("role");return t==="presentation"||t==="none"}function ji(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).map(t=>t.replace(/^#/,"")):[]}function Ki(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let o=e.getRootNode?.();if(Tt(o)){let s=re(e),i=`#${Xr(s,n)}`,c=Yr(o,i);if(c)return c}}catch{}let r=G(e);return qr(r,n)}function hs(e){let n=[];for(let r=0;r<arguments.length;r++){let o=arguments[r];if(Array.isArray(o))for(let s=0;s<o.length;s+=8192){let i=al(o,s,s+8192),c=hs.apply(null,i);for(let f=0;f<c.length;f++)n.push(c[f])}else n.push(o)}return n}function al(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 cl(e,t).concat(ll(e))}function cl(e,t){return hs(gs(e).map(r=>oa(r)&&Ut(r)?Ji(r,t):r))}function Ji(e,t){if(!e||Sn(e,t))return[];if(!il(e))return[e];let n=Array.from(e.children);return hs(n.map(r=>Ji(r,t)))}function Zi(e){let t=ji(e.getAttribute("aria-owns"));if(!t.length)return[];let n=[],r=new Set;for(let o of t){if(r.has(o))continue;r.add(o);let s=Ki(e,o);s&&s!==e&&n.push(s)}return n}function ll(e){let t=Zi(e);for(let n of t)n["aria-owned-by"]=e;return t}function ea(e){let t=re(e),n=G(e);if(e.getAttribute("role")!=="dialog"&&e.getAttribute("role")!=="alertdialog"||e.getAttribute("aria-modal")!=="true")return!1;let r=t.getComputedStyle(e);if(r?.position!=="fixed"&&r?.position!=="absolute"||parseInt(r?.zIndex,10)<=pl(e))return!1;let o=ul(e);return!o||!fl(o)||!ml(e)||o.getAttribute("role")==="dialog"||e.getAttribute("role")==="dialog"?!1:hl(e)}function ul(e){return[e.previousElementSibling,e.nextElementSibling,...Array.from(e.children),...e.parentElement?[e.parentElement.previousElementSibling,e.parentElement.nextElementSibling]:[]].filter(n=>n!==null).find(dl)||null}function dl(e){if(Sn(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 fl(e){let t=re(e),n=e.getBoundingClientRect();return n.top<=0&&n.left<=0&&n.bottom>=t.innerHeight&&n.right>=t.innerWidth}function pl(e){let t=G(e),n=re(e),r=n?.getComputedStyle;if(!r)return 0;let o=Zo(t,"*").filter(s=>s!==e&&!Sn(s)).map(s=>parseInt(r.call(n,s)?.zIndex,10)).filter(s=>Number.isFinite(s)&&!isNaN(s));return o.length?Math.max(...o):0}function hl(e){return e.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])').length>0}function ml(e){let t=e.parentElement;if(!t)return!1;for(let n of Array.from(t.children))if(n!==e&&!Sn(n)&&n.getAttribute("aria-hidden")!=="true")return!1;return!0}function gl(){try{let t=Xe()?.querySelector?.("dialog:modal");return'[aria-modal="true"], dialog:modal'}catch{return'[aria-modal="true"]'}}var ta=gl();function bl(e){return e.getAttribute("aria-disabled")==="true"||e.hasAttribute("disabled")}function ms(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=G(e),r=new URL(t,n.baseURI);return r.protocol==="javascript:"&&(r.pathname.trim()!==""||r.search.trim()!==""||r.hash.trim()!=="")}catch{return!1}}function na(e){return _i.has(e)}function El(e){let t=e.parentElement,n=G(e);if(!(!t||t===n.body||t===n.documentElement))return it({targetElement:t,originatedFromParent:!0})}function Ui({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,elementContext:i}){let c={nodeCategory:e.nodeType},f=t||bl(e),v=El(e);if(v&&(c.parent=v),n){let pe=qn[n];typeof pe=="number"?c.semanticRole=pe:c.semanticRole=n}if(f&&(c.isDisabled=!0),i){let{eventHandlerIndices:pe,isEditableRegion:Ie}=i,ot=Yn(pe);ot.length>0&&(c.eventHandlers=ot),Ie&&(c.isEditable=!0)}let b=yl(e);b&&Object.keys(b).length>0&&(c.ariaProperties=b);let w=vl(e);w&&Object.keys(w).length>0&&(c.ariaStates=w);let I=e.nodeName;I&&I.trim()&&(c.elementName=I);let x=zi(e);x&&Object.keys(x).length>0&&(c.computedStyles=x),Sn(e)&&(c.isInvisible=!0);let A=wl(e,n);A&&Object.keys(A).length>0&&(c.preservedAttributes=A),e.draggable&&(c.isDraggable=!0),e.scrollWidth&&e.clientWidth&&e.scrollWidth>e.clientWidth&&(c.supportsHorizontalSwipe=!0),e.scrollHeight&&e.clientHeight&&e.scrollHeight>e.clientHeight&&(c.supportsVerticalSwipe=!0);let D=e.getAttribute("class");if(D?.trim()){D.includes("handle")&&(c.isDragHandle=!0),c.supportsHorizontalSwipe||(D.includes("horizontal")||D.includes("carousel"))&&(c.supportsHorizontalSwipe=!0),c.supportsVerticalSwipe||(D.includes("vertical")||D.includes("feed"))&&(c.supportsVerticalSwipe=!0),D.includes("dismissible")&&(c.supportsDismissSwipe=!0),(D.includes("long-press")||D.includes("hold")||D.includes("press-hold"))&&(c.supportsLongPress=!0);let pe=c.inputType||c.preservedAttributes?.[mt.type];pe==="submit"||pe==="reset"||pe==="clear"||(D.includes("submit")&&(c.preservedAttributes={...c.preservedAttributes||{},[mt.type]:"submit"}),D.includes("clear")&&(c.preservedAttributes={...c.preservedAttributes||{},[mt.type]:"clear"}),D.includes("reset")&&(c.preservedAttributes={...c.preservedAttributes||{},[mt.type]:"reset"}))}let P=Il({element:e});P&&P.length>0&&(c.labelReferences=P);let q=e.tagName;if(q&&(c.elementTag=q),Tl(e)&&(c.hasFocus=!0),!o){let pe=bs({element:e,semanticRole:n,parentDisabled:f,excludeLabels:r});pe&&pe.length>0&&(c.childElements=pe)}let F=Dl({element:e});F&&F.length>0&&(c.ownedElements=F);let H=gi(e);H&&(c.resourceLocator=H),(o||Xn(e))&&(c.isFrameElement=!0),s&&s.length>0&&(c.frameContent=s);let U=e.type;U&&typeof U=="string"&&U.trim()&&(c.inputType=U);let X=e.placeholder;X&&typeof X=="string"&&X.trim()&&(c.placeholderText=X);let Z=e.value;Z&&typeof Z=="string"&&Z.trim()&&(c.elementValue=Z);let te=Sl({element:e,parentDisabled:t,semanticRole:n});if(te&&te.length>0&&(c.selectedOptions=te),tn(e,"select,datalist")&&(c.nearestSelectList=!0),fs(e))c.elementNamespace=br.HTML;else if(_l(e)){c.elementNamespace=br.SVG,c.svgStructure=xl(e);let pe=Rl(e);pe&&Object.keys(pe).length>0&&(c.preservedAttributes?c.preservedAttributes={...c.preservedAttributes,...pe}:c.preservedAttributes=pe)}let K=r?void 0:Al({element:e});K&&K.length>0&&(c.associatedLabels=K);let se=e.scope;se&&typeof se=="string"&&se.trim()&&(c.tableScope=se);let ae=Ml({element:e});ae&&(c.tableCaption=ae);let me=Ll({element:e});me&&(c.figureCaption=me);let ye=Nl({element:e});return ye&&(c.fieldsetLegend=ye),tn(e,"table")&&(c.nearestTable=!0),c}function wl(e,t){let n={},r=new Set(Object.values(mt).filter(c=>typeof c=="string")),o=new Set(Object.keys(Kr).filter(c=>isNaN(Number(c)))),s=new Set(["_ngcontent","ng-reflect-*","data-v-*"]),i=e?.attributes?Array.from(e.attributes):[];for(let c of i){let f=c.name,v=c.value;if(f==="id"&&(!t||!Jt.has(t)))continue;let b;if(r.has(f)?b=f:f.startsWith("data-v-")?b="data-v-*":f.startsWith("ng-reflect-")?b="ng-reflect-*":f.startsWith("_ngcontent")&&(b="_ngcontent"),b){let w=v.trim()!=="",I=o.has(b);if(w||I){let x=mt[b],A=s.has(b)?"true":v;n[x]=A}}}if(!n[mt[st]]){let c=Oi(e);c&&(n[mt[st]]=c)}return n}function yl(e){return ra(e,eo,Qr)}function vl(e){return ra(e,to,null)}function ra(e,t,n){let r={};for(let o in t)if(isNaN(Number(o))){let s=t[o],c=`aria-${o.toLowerCase().replace(/_/g,"-")}`,f=e.getAttribute(c),v=!1;n!==null&&(v=Object.values(n).filter(w=>typeof w=="number").includes(s)),e.hasAttribute(c)&&v||f?.trim()?r[s]=f:c==="aria-level"&&xi.includes(e.tagName.toLowerCase()?.trim())&&(r[s]=e.tagName.substring(1))}return r}function Ut(e){return oa(e)&&e.nodeType===gr.ELEMENT}function uo(e){return e.nodeType===gr.TEXT}function oa(e){let t=typeof e;return t=="object"&&e!=null||t=="function"}function fs(e){return Ut(e)&&(!e.namespaceURI||e.namespaceURI===Ri)}function _l(e){return Ut(e)&&e.namespaceURI===ki}function Xn(e){return e.tagName==="IFRAME"}function In(e,t){return"tagName"in e?e.tagName?.toLowerCase()===t:e.elementTag?.toLowerCase()===t}function tn(e,t){if(e.closest)return e.closest(t);for(;!lo(e,t);){if(e.parentElement===null)return null;e=e.parentElement}return e}function lo(e,t){return e.matches?.(t)??e.msMatchesSelector?.(t)??e.webkitMatchesSelector(t)}function Tl(e){let t=e.ownerDocument,n=t?.hasFocus()?t.activeElement:null;if(n){let r=n.getAttribute("aria-activedescendant");r&&(n=t.getElementById(r)||n)}return e===n}function xl(e){let t={},n=en.text,r=en.elText;e.textContent?.trim()&&(t[n]=e.textContent);let o=e.querySelector("title"),s=e.querySelector("img");o?.textContent?.trim()?t[r]=o.textContent:s?.alt?.trim()&&(t[r]=s.alt);let i=e.getAttribute("viewBox");i&&(t[en.viewBox]=i);let c=e.querySelectorAll("path");c.length>0&&(t[en.paths]=c.length,t[en.pathData]=Array.from(c).slice(0,3).map(v=>v.getAttribute("d")).filter(Boolean).map(v=>v.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(([v,b])=>{if(b>0){let w=en[v];t[w]=b}}),Object.keys(t).length>0?t:void 0}function Rl(e){let t={};if(!e?.hasAttributes())return t;for(let n of Object.values(Gn).filter(r=>typeof r=="number")){let r=Gn[n];if(r){let o=r;if(Gn.hasOwnProperty(o)&&e.hasAttribute(o)){let s=e.getAttribute(o);s?.trim()&&(t[n]=s)}}}return t}function kl({frameElement:e,parentDisabled:t,excludeLabels:n}){if(!ut.includeFrameContents)return[];let r=null;try{r=e.contentWindow?.document?.body||null}catch{return[]}if(!r)return[];let o=[];for(let s of gs(r))if(!(kr(s)||sa(s))){if(Ut(s)){let i=s,c=Ht(i),f=xt(i,c),{shouldCreate:v,shouldAnnotate:b}=fo(f);if(v){b&&cn(i);let w=it({targetElement:i,parentDisabled:t,semanticRole:c??void 0,excludeLabels:n,elementContext:f});w&&o.push(w)}else{let w=bs({element:i,semanticRole:c??void 0,parentDisabled:t,excludeLabels:n});o.push(...w)}}else if(uo(s)){let i=xr(s);i&&o.push(i)}}return o}function gs(e){let t=re(e);if(di(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||vn()?.getShadowRoot?.(e)||null;if(n){let r=Array.from(n.childNodes),o=Array.from(e.childNodes).filter(s=>!s.assignedSlot);return r.concat(o)}}catch{}return Array.from(e.childNodes)}function bs({element:e,semanticRole:t,parentDisabled:n,excludeLabels:r}){let o=[];for(let s of gs(e))if(!(kr(s)||sa(s))){if(Ut(s)){let i=s,c=Ht(i),f=xt(i,c);if(Xn(i)){cn(i);let w=kl({frameElement:i,parentDisabled:n,excludeLabels:r}),I=it({targetElement:i,parentDisabled:n,semanticRole:c??void 0,excludeLabels:r,isFrameNode:!0,frameContentNodes:w,elementContext:f});I&&o.push(I);continue}let{shouldCreate:v,shouldAnnotate:b}=fo(f);if(v){b&&cn(i);let w=it({targetElement:i,parentDisabled:n,semanticRole:c??void 0,excludeLabels:r,elementContext:f});w&&o.push(w)}else{let w=bs({element:i,semanticRole:c??void 0,parentDisabled:n,excludeLabels:r});o.push(...w)}}else if(uo(s)){let i=xr(s);i&&o.push(i)}}return o}function Il({element:e}){let t=ji(e.getAttribute("aria-labelledby")),n=new Set;for(let r of t){let o=Ki(e,r);if(!(!o||o===e)&&o){let s=Ht(o),i=it({targetElement:o,semanticRole:s,elementContext:xt(o,s)});n.add(i)}}return Array.from(n)}function Sl({element:e,parentDisabled:t,semanticRole:n}){let r=[];return e&&(n&&n==="listbox"?r=Array.from(e.querySelectorAll('[role="option"][aria-selected="true"]')).map(o=>it({targetElement:o,parentDisabled:t,semanticRole:"option",elementContext:xt(o,"option")})):In(e,"select")&&(r=Array.from(e.selectedOptions).map(o=>it({targetElement:o,parentDisabled:t,semanticRole:"option",elementContext:xt(o,"option")})))),r}function Al({element:e}){if(Ti.includes(e.tagName)){let t=G(e),n=Zo(t,"label"),r=new Set;return Array.from(n).filter(o=>o!==e&&Cl(o,e)).map(o=>{let s=Ht(o),i=it({targetElement:o,semanticRole:s,excludeLabels:!0,elementContext:xt(o,s)});r.add(i)}),Array.from(r)}}function Cl(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 Ml({element:e}){if(In(e,"table")){let t=e.querySelector("caption");if(t&&t!==e){let n=Ht(t);return it({targetElement:t,semanticRole:n,elementContext:xt(t,n)})}}}function Ll({element:e}){if(In(e,"figure")){let t=e.querySelector("figcaption");if(t&&t!==e){let n=Ht(t);return it({targetElement:t,semanticRole:n,elementContext:xt(t,n)})}}}function Nl({element:e}){if(In(e,"fieldset")){let t=e.querySelector("legend");if(t&&t!==e){let n=Ht(t);return it({targetElement:t,semanticRole:n,elementContext:xt(t,n)})}}}function Dl({element:e}){let t=new Set,n=Zi(e);for(let r of n){let o=Ht(r),s=it({targetElement:r,semanticRole:o,elementContext:xt(r,o)});t.add(s)}return Array.from(t)}function fo(e){let{semanticRole:t,eventHandlerIndices:n,isEditableRegion:r,hasNodeWorthyHandlers:o,isLikelyStructuralContainer:s}=e,i=n.length>0&&n.some(w=>Ai.has(w)),f=!!t||!s&&(o||r),v=!!t&&Jt.has(t);return{shouldCreate:f,shouldAnnotate:f&&(v||r||i)}}function sa(e){if(!Ut(e))return!1;let t=e,n=t.tagName;return Jr.has(n)?!0:n===Rn||n===kn?Ol(t):!1}function Ol(e){let t=re(e),n=t?.getComputedStyle;if(!n||n.call(t,e).display==="none")return!0;let o=e.getBoundingClientRect();return o.width===0&&o.height===0&&!(typeof e.closest=="function"&&e.closest("pre"))||o.right<-1e3||o.left>t.innerWidth+1e3}function Es(e,t={}){return ai(t),Hi(),Di(),Fi(e,{includeShadow:!0,includeIframes:ut.clearIframes}),_r.initialize(ut.semanticIdStart),{rootNodes:ia(e),semanticNodes:ln}}function ia(e){let t=[];try{let n=G(e),o=Array.from(n.querySelectorAll(ta)).filter(s=>!Sn(s)&&ea(s));if(o.length===0)t=zn({targetElement:e});else if(o.length===1){let s=o[0];s.contains(e)?t=zn({targetElement:e}):e.contains(s)?t=zn({targetElement:s}):t=zn({targetElement:e})}else t=zn({targetElement:e})}catch(n){throw console.error("Error constructing semantic tree",n),n}return t}function zn({targetElement:e,parentNode:t}){if(kr(e)||aa(e))return[];let n=Ht(e),r=xt(e,n);if(Xn(e))return[Hl({frameElement:e,role:n,parentNode:t,elementContext:r})];let o=0,{shouldCreate:s,shouldAnnotate:i}=fo(r);s&&(i&&cn(e),o=it({targetElement:e,parentDisabled:t?.isDisabled,semanticRole:n,elementContext:r}));let c=ln[o],f=Fl(e,n,o?c:t);return o&&f.length>0&&(c.semanticChildren=f),o?[o]:f}function Fl(e,t,n){let r=[],o=Qi(e,t);for(let s of o)if(!(kr(s)||aa(s))){if(Ut(s)){let i=zn({targetElement:s,parentNode:n});r.push(...i)}else if(uo(s)&&Pl(s,n)){let i=xr(s);i&&r.push(i)}}return r}function Hl({frameElement:e,role:t,parentNode:n,elementContext:r}){cn(e);let o=Ul(e);return it({targetElement:e,parentDisabled:n?.isDisabled,semanticRole:t,isFrameNode:!0,frameContentNodes:o,elementContext:r})}function Ul(e){if(!ut.includeFrameContents)return[];let n=_n(e)?.body??null;return n?ia(n):[]}function Pl(e,t){let n=e.data.trim();if(!n||n==="")return!1;if(t?.semanticRole!==void 0&&t?.semanticRole!==null){let r=typeof t.semanticRole=="number"?Er[t.semanticRole]:t.semanticRole;if(na(r))return!1}return!0}function aa(e){if(!Ut(e))return!1;let t=e,n=t.tagName;return Jr.has(n)?!0:n===Rn||n===kn?Bl(t):!1}function Bl(e){let t=re(e);if(t.getComputedStyle(e).display==="none")return!0;let r=e.getBoundingClientRect();return r.width===0&&r.height===0&&!e.closest("pre")||r.right<-1e3||r.left>t.innerWidth+1e3}function ho(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t}function Wl(e){let t=e.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}function Kn(e,t,n){let r=G(e,t),o=Y(r,n);try{e.focus?.({preventScroll:!0})}catch{}if(ho(r)===e)return!0;try{let{x:s,y:i}=Wl(e),c=o.PointerEvent||PointerEvent,f=o.MouseEvent||MouseEvent;e.dispatchEvent(new c("pointerdown",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:1,button:0,pointerType:"mouse"})),e.dispatchEvent(new f("mousedown",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:1,button:0})),e.dispatchEvent(new f("mouseup",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:0,button:0})),e.dispatchEvent(new c("pointerup",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:0,button:0,pointerType:"mouse"})),(e.isContentEditable||At(e,o)||Ft(e,o)||e.getAttribute("contenteditable")==="true")&&e.dispatchEvent(new f("click",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,button:0}))}catch{}try{e.focus?.({preventScroll:!0})}catch{}return ho(r)===e}function Ir(e,t){let n=re(e),r=Ft(e,n)?n.HTMLTextAreaElement.prototype:n.HTMLInputElement.prototype,o=Object.getOwnPropertyDescriptor(r,"value");o?.set?o.set.call(e,t):e.value=t}function Cn(e,t,n="insertText"){let r=re(e),o=r.InputEvent||(typeof InputEvent<"u"?InputEvent:null),s=r.Event||Event;try{o?e.dispatchEvent(new o("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{o?e.dispatchEvent(new o("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 Vl(e){let n=re(e).KeyboardEvent||KeyboardEvent,r={key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0,composed:!0},o=e.dispatchEvent(new n("keydown",r)),s=e.dispatchEvent(new n("keypress",r)),i=e.dispatchEvent(new n("keyup",r));return{canceled:!(o&&s&&i)}}function An(e){if(!e)return!1;let t=re(e);if(Ft(e,t))return!e.disabled&&!e.readOnly;if(At(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 ws(e){let t=re(e);if(!e||!We(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 $l(e,t){let n=e.getRootNode();return Tt(n)?n:G(e)??t}function Gl(e,t){let n=[];for(let r of t.split(/\s+/).filter(Boolean)){let o=e.getElementById?.(r)||e.querySelector?.(`#${CSS.escape(r)}`),s=re(o);We(o,s)&&n.push(o)}return n}function da(e,t){if(!e)return{kind:"none",el:null,via:"no-root"};if(An(e))return{kind:"input",el:e,via:"self-input"};if(ws(e))return{kind:"contenteditable",el:e,via:"self-contenteditable"};let n=G(e)??t,r=Y(n),o=$l(e,n);if(li(e,r)){let f=e.control;if(An(f))return{kind:"input",el:f,via:"label.control"};let v=e.htmlFor;if(v){let b=o.getElementById?.(v)||o.querySelector?.(`#${CSS.escape(v)}`);if(An(b))return{kind:"input",el:b,via:"label.for"}}}let s=e.getAttribute("aria-controls")||e.getAttribute("aria-owns");if(s)for(let f of Gl(o,s)){if(An(f))return{kind:"input",el:f,via:"aria-controls/owns"};if(ws(f))return{kind:"contenteditable",el:f,via:"aria-controls/owns"};let v=f.querySelector?.("input,textarea");if(An(v))return{kind:"input",el:v,via:"aria-controls->desc"}}let i=e.querySelector?.("input,textarea");if(An(i))return{kind:"input",el:i,via:"descendant"};let c=e.shadowRoot||null;if(c){let f=c.querySelector?.("input,textarea");if(An(f))return{kind:"input",el:f,via:"open-shadow-input"};let v=c.querySelector?.('[contenteditable="true"],[contenteditable=""],[role="textbox"]');if(ws(v))return{kind:"contenteditable",el:v,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 jn(e,t,n,r=!1){let o=G(e,t),i=Y(o,n).getSelection?.();if(!i)return!1;try{let c=o.createRange();return c.selectNodeContents(e),r&&c.collapse(!1),i.removeAllRanges(),i.addRange(c),!0}catch{return!1}}function Mn(e){return(e.textContent??"").replace(/\u00A0/g," ").trim()}var po=e=>String(e??"").replace(/\s+/g," ").trim(),fa=new MessageChannel,pa=[];fa.port1.onmessage=()=>{let e=pa.shift();e&&e()};function ca(){return new Promise(e=>{pa.push(e),fa.port2.postMessage(0)})}async function la(e,t,n){await Promise.resolve();let r=Math.max(0,Math.min(4,Number(n)||0));for(let o=0;o<r;o++)e.hidden?await ca():await new Promise(s=>{try{t.requestAnimationFrame(()=>s())}catch{ca().then(s)}})}function ql(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 ua(e,t,n,r){let o=G(e,t),i=Y(o,n).KeyboardEvent||KeyboardEvent,c=String(r??"");for(let f of c){let{code:v,which:b}=ql(f),w={key:f,code:v,bubbles:!0,cancelable:!0,composed:!0,keyCode:b,which:b};e.dispatchEvent(new i("keydown",w)),e.dispatchEvent(new i("keypress",w)),e.dispatchEvent(new i("keyup",w))}}async function ha(e,t,n,r,o){let s=String(r??"");if(e.disabled||e.readOnly)return{success:!1,method:"type-native-setter",details:"disabled_or_readonly",allowFallback:!0};let i=String(e.value??""),c=G(e,t),f=Y(c,n),v=Kn(e,c,f),b=Number.isFinite(Number(o?.settleFrames))?Math.max(0,Math.min(4,Number(o?.settleFrames))):c.hidden?1:2,w=!!o?.useKeyFallback,I=Number.isFinite(Number(o?.keyFallbackMaxLen))?Number(o?.keyFallbackMaxLen):140,x=w&&s.length>0&&s.length<=I;Ir(e,s),Cn(e,s,"insertReplacementText"),x&&ua(e,c,f,s),await la(c,f,b);let A=String(e.value??""),D=po(i),P=po(A),q=po(s),F=D===q,H=P===q,U=A!==i,X=s.length>0&&!F&&A===i,Z=1;if(!F&&!H&&!U){Z=2;try{e.focus?.({preventScroll:!0}),e.select?.()}catch{}let ae=!1;try{c.execCommand?.("selectAll",!1,void 0),ae=!!c.execCommand?.("insertText",!1,s)}catch{ae=!1}if(!ae)try{Ir(e,s)}catch{}try{Cn(e,s,"insertReplacementText")}catch{}x&&ua(e,c,f,s),await la(c,f,b),A=String(e.value??"")}let oe=po(A)===q,K=A!==i;X=s.length>0&&!F&&A===i;let se=F||oe||K;return{success:se,method:"type-native-setter",details:`focus=${v};attempts=${Z};settleFrames=${b};beforeLen=${i.length};afterLen=${A.length};changed=${K};alreadyCorrect=${F};nowCorrect=${oe};reverted=${X};keyFallback=${x}`,allowFallback:se?void 0:!0}}function Yl(e,t,n){let o=re(e).InputEvent||InputEvent,s=new o("beforeinput",{bubbles:!0,cancelable:!0,composed:!0,data:t,inputType:n});return{ok:e.dispatchEvent(s),defaultPrevented:s.defaultPrevented}}function ma(e,t,n,r){let o=G(e,n),s=Y(o,r),i=s.InputEvent||InputEvent,c=s.Event||Event,f=String(t??""),v=Mn(e),b=Kn(e,o,s),w=jn(e,o,s,!0),I=Yl(e,f,"insertText"),x=!1,A="execCommand",D=!1,P=()=>{D=!0};try{e.addEventListener("input",P,{capture:!0})}catch{}if(I.ok&&!I.defaultPrevented)try{x=!!o.execCommand?.("insertText",!1,f)}catch{}if(!x)try{let H=s.getSelection?.(),U=H&&H.rangeCount?H.getRangeAt(0):null;if(!U||!e.contains(U.commonAncestorContainer)){jn(e,o,s,!0);let X=s.getSelection?.();U=X&&X.rangeCount?X.getRangeAt(0):null}U&&(U.insertNode(o.createTextNode(f)),U.collapse(!1),H?.removeAllRanges(),H?.addRange(U),x=!0,A="range")}catch{}if(x&&!D){try{e.dispatchEvent(new i("input",{bubbles:!0,cancelable:!1,composed:!0,data:f,inputType:"insertText"}))}catch{try{e.dispatchEvent(new c("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{}}try{e.dispatchEvent(new c("change",{bubbles:!0,cancelable:!0,composed:!0}))}catch{}}try{e.removeEventListener("input",P,{capture:!0})}catch{}let q=Mn(e);return{success:q!==v||!!f&&q.includes(f),method:`type-contenteditable-${A}`,details:`focus=${b};selectedWithin=${w};inserted=${x}`}}function ga(e){let{canceled:t}=Vl(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 ba(e,t,n){if(e.disabled||e.readOnly)return{success:!1,method:"clear-native-setter",details:"disabled_or_readonly",allowFallback:!0};let r=G(e,t),o=Y(r,n),s=String(e.value??""),i=Kn(e,r,o);Ir(e,""),Cn(e,"","deleteByCut");let c=String(e.value??""),f=c!==s;return{success:f||c.length===0,method:"clear-native-setter",details:`focus=${i};beforeLen=${s.length};afterLen=${c.length};changed=${f}`}}function Ea(e,t,n){let r=G(e,t),o=Y(r,n),s=Mn(e),i=Kn(e,r,o),c=jn(e,r,o,!1),f=!1,v="execCommand";try{f=!!r.execCommand?.("delete",!1,void 0)}catch{f=!1}if(!f)try{let x=o.getSelection?.(),A=x&&x.rangeCount?x.getRangeAt(0):null;(!A||!e.contains(A.commonAncestorContainer))&&jn(e,r,o,!1);let D=o.getSelection?.(),P=D&&D.rangeCount?D.getRangeAt(0):null;P&&(P.deleteContents(),P.collapse(!1),D?.removeAllRanges(),D?.addRange(P),f=!0,v="range")}catch{}if(!f)try{e.textContent="",f=!0,v="textContent"}catch{}Cn(e,"","deleteByCut");let b=Mn(e),w=b!==s;return{success:f||w||b.length===0,method:`clear-contenteditable-${v}`,details:`focus=${i};selectedWithin=${c};cleared=${f};changed=${w}`}}function wa(e,t){if(e===t||e.contains(t))return!0;let n=t;for(;n;){let r=n.getRootNode?.();if(Tt(r)){let o=r.host;if(o===e||e.contains(o))return!0;n=o;continue}n=n.parentNode||null}return!1}var mo;(function(e){e.FLASH_LITE="Gemini Flash Lite",e.FLASH="Gemini Flash",e.PRO="Gemini Pro"})(mo||(mo={}));var ya;(function(e){e[e.NativeHostConnected=0]="NativeHostConnected",e[e.NativeHostDisconnected=1]="NativeHostDisconnected"})(ya||(ya={}));var Xl=["image/png","image/jpeg","image/webp"],zl=["application/pdf","text/plain"],Kp=[...Xl,...zl];var nt;(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"})(nt||(nt={}));var Ze;(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"})(Ze||(Ze={}));var Qp={[nt.ACT]:Ze.AGENTIC_SEEK,[nt.CRAWL]:Ze.CRAWL_PAGES,[nt.EXTRACT]:Ze.EXTRACT_PAGE,[nt.SHEETS_WORKFLOW]:Ze.SHEETS_WORKFLOW,[nt.INFER_SHEET_DATA]:Ze.INFER_SHEET_DATA,[nt.PDF_FILLER]:Ze.PDF_FILLER,[nt.CUSTOM_TOOL_GENERATOR]:Ze.CUSTOM_TOOL_GENERATOR,[nt.WEBPAGE_GENERATOR]:Ze.WEBPAGE_GENERATOR,[nt.GOOGLE_DOC_GENERATOR]:Ze.GOOGLE_DOC_GENERATOR,[nt.GOOGLE_SLIDES_GENERATOR]:Ze.GOOGLE_SLIDES_GENERATOR,[nt.PROCESS_TEXT]:Ze.PROCESS_TEXT,[nt.CREATE_SHEET_FROM_DATA]:Ze.CREATE_SHEET_FROM_DATA,[nt.EXECUTE_MULTIPLE_TOOLS]:Ze.EXECUTE_MULTIPLE_TOOLS,[nt.CONFIGURE_API_KEY]:Ze.CONFIGURE_API_KEY,[nt.QUERY_RTRVR_AI_DOCUMENTATION]:Ze.QUERY_RTRVR_AI_DOCUMENTATION};var ys=200;var Jp=mo.FLASH;var Zp=Ze.PLANNER;var vs="application/pdf",_s="application/gsheet";var eh=20*1024*1024;var go={maxParallelTabs:4,pageLoadDelay:2e3,disableAutoScroll:!1,makeNewTabsActive:!1,writeRowProcessingTime:!1,totalBudgetMs:25e3,pageDataTimeoutMs:22e3,pdfTextSelectionTimeoutMs:12e3,onlyTextContent:!1};var jl=1,Kl=9,Ql=11,xs="application/gdoc",Qn="text/html",bo="text/plain";function Jl(e){return!!e&&typeof e=="object"&&e.nodeType===Kl}function va(e){return!!e&&typeof e=="object"&&e.nodeType===jl}function Zl(e){return!!e&&typeof e=="object"&&e.nodeType===Ql&&typeof e.host=="object"&&typeof e.mode=="string"}function _a(e){return va(e)&&String(e.tagName).toUpperCase()==="IFRAME"}function Ts(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 eu(e){try{let t=e.shadowRoot;return t||globalThis?.chrome?.dom?.openOrClosedShadowRoot?.(e)||null}catch{return null}}function tu(e,t,n={}){let r=n.traverseShadow!==!1,o=n.traverseIframes!==!1,s=n.requireOwnerDocument,i=[e],c=new WeakSet;for(;i.length;){let f=i.pop();if(f&&typeof f=="object"){if(c.has(f))continue;c.add(f)}if(Jl(f)){let w=f.documentElement||f.body;w&&i.push(w);continue}if(Zl(f)){let w=f.children;if(w&&w.length)for(let I=w.length-1;I>=0;I--)i.push(w[I]);continue}if(!va(f))continue;let v=f;if(s&&v.ownerDocument!==s)continue;let b=v.getAttribute?.(st);if(b&&yr(b)===t)return v;if(r)try{let w=eu(v);w&&i.push(w)}catch{}if(o&&_a(v))try{let w=_n(v);w&&i.push(w)}catch{}for(let w=v.lastElementChild;w;w=w.previousElementSibling)i.push(w)}return null}function Pt(e,t,n={}){let r=Ts(t);if(!r)return null;let o=Tr(r);return o&&(!n.requireOwnerDocument||o.ownerDocument===n.requireOwnerDocument)?o:tu(e,r,{requireOwnerDocument:n.requireOwnerDocument,traverseShadow:n.traverseShadow,traverseIframes:n.traverseIframes})}function Rs(e=document){return e.querySelector('embed[type="application/pdf"], embed[type="application/x-google-chrome-pdf"]')}function Ta(e){if(e==null)return[];if(Array.isArray(e)){let t=[];for(let n of e){let r=Ts(n);r&&t.push(r)}return t}if(typeof e=="number"||typeof e=="bigint"){let t=Ts(e);return t?[t]:[]}if(typeof e=="string"){let t=e.match(/\d+/g);return t?t.map(r=>parseInt(r,10)).filter(r=>Number.isFinite(r)&&r>0):[]}if(typeof e=="object"){let t=e.path??e.ids??e.iframe_path;if(t!==void 0)return Ta(t)}return[]}function Jn(e,t){let n=Ta(t),r=e.defaultView||window;if(!n.length)return{doc:e,win:r,iframePath:n,resolvedPath:[],unresolvedPath:[]};let o=e,s=[];for(let i=0;i<n.length;i++){let c=n[i],f=n.length===1,v=Pt(o,c,{requireOwnerDocument:f?void 0:o,traverseShadow:!0,traverseIframes:f});if(!v||!_a(v))return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:n.slice(i)};let b=null;try{b=_n(v)||null}catch{b=null}if(!b)return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:n.slice(i)};s.push(c),o=b}return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:[]}}function xa(e){return e==="application/pdf"||e==="application/x-pdf"||e==="application/x-google-chrome-pdf"}function nu(){return Date.now()}function Ct(e){return!e||!Number.isFinite(e)?Number.POSITIVE_INFINITY:Math.max(0,e-nu())}async function Ra(e,t,n){if(!Number.isFinite(e)||e<=0)return;let r=Ct(n);r<=0||r<e+40||await et(e,t)}async function Zn(e,t,n){let r=Math.max(0,Math.floor(t));return r?await Promise.race([e.then(s=>({ok:!0,value:s})),(async()=>(await et(r,n),{ok:!1,reason:"timeout"}))()]):{ok:!1,reason:"timeout"}}var et=(()=>{let e=new MessageChannel,t=[];e.port1.onmessage=()=>{let r=t.shift();r&&r()};let n=()=>new Promise(r=>{t.push(r),e.port2.postMessage(0)});return async(r,o)=>{let s=Number(r);if(!Number.isFinite(s)||s<=0)return;if(!o.hidden){let c=o.defaultView||window,f=c.setTimeout?c.setTimeout.bind(c):setTimeout;await new Promise(v=>f(v,s));return}let i=Date.now();for(;Date.now()-i<s;)await n()}})();var ru=3e4;function ka(e){return(String(e??"").replace(/\\/g,"/").split("/").pop()||"upload").replace(/[\u0000-\u001f\u007f]/g,"").trim()||"upload"}var ks=class extends Error{constructor(n,r){super(n);$(this,"url");$(this,"status");$(this,"statusText");$(this,"bodySnippet");this.name="FetchFileError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.bodySnippet=r.bodySnippet}};function ou(e){return e&&e.split(";")[0].trim()||"application/octet-stream"}function su(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 Is(e,t){try{let r=(t??window).URL||URL,s=new r(e).pathname.match(/\/o\/(.+?)(\?|$)/);if(s?.[1]){let c=decodeURIComponent(s[1]).split("/");return c[c.length-1].replace(/^\d+-/,"")}}catch{}}function Ia(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}async function iu(e,t={},n,r=fetch){let o=new AbortController,s=ru,i=!1,c=()=>{};if(n){let v=!1;c=()=>{v=!0},(async()=>{try{if(await et(s,n),v)return;i=!0,o.abort()}catch{}})().catch(()=>{})}else{let v=setTimeout(()=>{i=!0,o.abort()},s);c=()=>clearTimeout(v)}let f=new Headers(t.headers);f.has("Accept")||f.set("Accept","*/*");try{let v=await r(e,{method:"GET",redirect:t.redirect??"follow",cache:t.cache??"no-store",mode:t.mode??"cors",credentials:t.credentials??"include",...t,headers:f,signal:o.signal});if(!v.ok){let x=await v.text().catch(()=>"");throw new ks(`Fetch failed (${v.status})`,{url:e,status:v.status,statusText:v.statusText,bodySnippet:x.slice(0,256)})}let b=await v.arrayBuffer(),w=ou(v.headers.get("content-type")),I=su(v.headers.get("content-disposition"))||Is(e);return{bytes:b,mimeType:w,fileName:I}}finally{c()}}async function Sa(e,t,n){return await iu(t,{referrer:n??void 0,referrerPolicy:"strict-origin-when-cross-origin"})}var Ne;(function(e){e.UP="UP",e.DOWN="DOWN",e.LEFT="LEFT",e.RIGHT="RIGHT",e.TOP="TOP",e.BOTTOM="BOTTOM"})(Ne||(Ne={}));var rt;(function(e){e.START="START",e.CENTER="CENTER",e.END="END",e.NEAREST="NEAREST"})(rt||(rt={}));function Ca(e){if(!e)return rt.CENTER;let t=typeof e=="string"?e.toUpperCase():String(e).toUpperCase();return rt&&t in rt?rt[t]:rt.CENTER}function Ss(e){return globalThis.CSS&&typeof globalThis.CSS.escape=="function"?globalThis.CSS.escape(e):e.replace(/([ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}function er(e,t){if(!e)return"";let n=G(e,t);if(e===n.documentElement)return"html";if(e===n.body)return"body";if(e.id)return`#${Ss(e.id)}`;let r=[],o=e;for(;o&&o!==n.body&&o!==n.documentElement;){let s=o.tagName.toLowerCase();if(o.id){s+=`#${Ss(o.id)}`,r.unshift(s);break}let c=(o.classList&&o.classList.length?Array.from(o.classList):(o.className||"").toString().split(/\s+/).filter(Boolean)).filter(f=>f&&f.length<=48).sort((f,v)=>f.length-v.length).slice(0,3).map(Ss);if(c.length)s+="."+c.join(".");else{let f=o.parentElement;if(f){let v=Array.from(f.children).filter(b=>b.tagName===o.tagName);if(v.length>1){let b=v.indexOf(o)+1;s+=`:nth-of-type(${b})`}}}r.unshift(s),o=o.parentElement}return r.join(" > ")}function Ln(e){return e.scrollingElement||e.documentElement||e.body}function Eo(e,t,n,r,o){let s=G(e,t),i=Y(s,n),c=Ln(s),f=e===s.documentElement||e===s.body||e===c,v=f?c:e,b=f?i.innerHeight:v.clientHeight,w=f?i.innerWidth:v.clientWidth,I=o??b*.8;switch(r){case Ne.DOWN:{v.scrollTop+=I;break}case Ne.UP:{v.scrollTop=Math.max(0,v.scrollTop-I);break}case Ne.LEFT:return v.scrollLeft=Math.max(0,v.scrollLeft-(o??w*.8)),{success:!0,scrollLeft:v.scrollLeft};case Ne.RIGHT:return v.scrollLeft+=o??w*.8,{success:!0,scrollLeft:v.scrollLeft};default:return{success:!1,error:`Unsupported scroll direction: ${String(r)}`}}let x=v.scrollHeight,A=f?i.innerHeight:v.clientHeight,D=x-A;return{success:!0,scrollTop:v.scrollTop,isAtTop:v.scrollTop<=5,isAtBottom:v.scrollTop>=D-5}}function au(e,t,n){let r=G(e,t),o=Y(r,n),s=Ln(r),i=e;for(;i&&i!==r.body&&i!==r.documentElement;){let f=o.getComputedStyle(i).overflowY;if((f==="auto"||f==="scroll"||f==="overlay")&&i.scrollHeight>i.clientHeight+5)return i;i=i.parentElement}return s}function Aa(e,t,n){let r=G(e,t),o=Y(r,n),s=Ln(r),i=e===r.documentElement||e===r.body||e===s,c=i?s:e,f=c.scrollHeight,v=i?o.innerHeight:c.clientHeight,b=f-v;return c.scrollTop>=b-5}function As(e,t,n,r){let o=G(e,t),s=Y(o,n),i=Ln(o),c=au(e,o,s),f=c===o.documentElement||c===o.body||c===i,v=f?i:c,b=e.getBoundingClientRect(),w=f?new(s.DOMRect||DOMRect)(0,0,s.innerWidth,s.innerHeight):c.getBoundingClientRect(),I=f?s.innerHeight:c.clientHeight,x=24,A=b.top-w.top,D=v.scrollTop+A,P;switch(r){case rt.START:P=D-x;break;case rt.END:P=D+b.height-I+x;break;case rt.NEAREST:{if(b.top>=w.top&&b.bottom<=w.bottom)return{success:!0,scrollTop:v.scrollTop,isAtTop:v.scrollTop<=5,isAtBottom:Aa(v,o,s)};b.top<w.top?P=D-x:P=D+b.height-I+x;break}case rt.CENTER:default:P=D-I/2+b.height/2;break}let q=v.scrollHeight-I;return v.scrollTop=Math.max(0,Math.min(P,q)),{success:!0,scrollTop:v.scrollTop,isAtTop:v.scrollTop<=5,isAtBottom:Aa(v,o,s)}}var cu=new Set([L.click_element,L.type_into_element,L.type_and_enter,L.hover_element,L.right_click_element,L.double_click_element,L.press_key,L.scroll_page,L.scroll_to_element,L.mouse_wheel,L.drag_element,L.drag_and_drop,L.swipe_element,L.long_press_element,L.adjust_slider,L.select_dropdown_value,L.clear_element,L.focus_element,L.check_field_validity,L.select_text,L.copy_text,L.paste_text,L.pinch_zoom,L.upload_file,L.dispatch_pointer_path]);(()=>{let e="__RTRVR_ACTION_EXECUTOR__";if(window[e])return;window[e]=!0;try{document.documentElement?.setAttribute(rs,"1")}catch{}let n="__RTRVR_INTERNAL__";try{window.__RTRVR_INTERNAL_KEY__=window.__RTRVR_INTERNAL_KEY__||n}catch{}let r=window.__RTRVR_INTERNAL_KEY__||n,o=window[r],s=o&&typeof o=="object"?o:{};if(!o)try{Object.defineProperty(window,r,{value:s,writable:!1,configurable:!1,enumerable:!1})}catch{window[r]=s}async function i(a){let u={};try{let h=oi[a.opcode];if(!h)throw new Error(`Unknown tool opcode: ${a.opcode}`);let m={...a.call,name:h};u=(await D({tabIndex:a.tabIndex,call:m,elementData:A(a.elementData),payload:a.payload}))[0]?.response??{success:!1,error:"Empty tool response",allowFallback:!0}}catch(h){u={success:!1,error:h?.message||String(h),allowFallback:!0}}return u}try{Object.defineProperty(s,"actions",{value:Object.freeze({execute:i}),writable:!1,configurable:!1,enumerable:!1})}catch{}let c="__RTRVR_UPLOAD_BYTES_REQ__",f="__RTRVR_UPLOAD_BYTES_RES__",v="__RTRVR_UPLOAD_BYTES_BRIDGE__",b="__RTRVR_WINDOW_MESSAGE_MUX__";function w(a){let u=a,h=u[b];if(!h||typeof h!="object"){h={handlers:new Set,installed:!1};try{Object.defineProperty(u,b,{value:h,enumerable:!1,configurable:!1})}catch{u[b]=h}}if(!h.installed){h.installed=!0,a.addEventListener("message",m=>{if(m.source===a)for(let p of Array.from(h.handlers))try{p(m)}catch{}},!0);try{a.addEventListener("pagehide",()=>{let p=a[v]?.pending;if(p)for(let[d,g]of p){try{g.cancelTimeout()}catch{}g.reject(new Error("pagehide: upload bytes request canceled")),p.delete(d)}},!0)}catch{}}return h}function I(a){let u=a,h=u[v];if(!h||typeof h!="object"){h={pending:new Map};try{Object.defineProperty(u,v,{value:h,enumerable:!1,configurable:!1})}catch{u[v]=h}w(a).handlers.add(p=>{let d=p?.data;if(!d||typeof d!="object"||d.type!==f)return;let g=String(d.requestId||"");if(!g)return;let _=h.pending.get(g);if(!_)return;h.pending.delete(g);try{_.cancelTimeout()}catch{}if(!d.ok){_.reject(new Error(d.error||"Failed to get bytes"));return}let C=d.bytes;if(!(C instanceof ArrayBuffer)){_.reject(new Error("Invalid bytes payload (expected ArrayBuffer)"));return}if(typeof _.expectedByteLength=="number"&&C.byteLength!==_.expectedByteLength){_.reject(new Error(`Byte length mismatch: got=${C.byteLength}, expected=${_.expectedByteLength}`));return}_.resolve(C)})}return h}function x(a,u,h,m=9e4){let p=a.__ROVER_UPLOAD_BYTES__||a.rover?.uploadBytes||a.rtrvr?.uploadBytes;if(typeof p=="function")return Promise.resolve().then(()=>p({token:u,byteLength:h,timeoutMs:m})).then(S=>{if(S instanceof ArrayBuffer)return S;if(S&&S.buffer instanceof ArrayBuffer)return S.buffer;throw new Error("Upload bytes provider returned invalid buffer")});let d=I(a),g=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(16).slice(2)}`,_=Math.max(1e3,Math.min(Number(m)||9e4,18e4)),C=zr(a)||document;return new Promise((S,M)=>{let O=!1,B=!1,z=()=>{B=!0};(async()=>{await et(_,C),!(B||O)&&(d.pending.delete(g),O=!0,M(new Error("Timed out waiting for upload bytes")))})().catch(()=>{}),d.pending.set(g,{cancelTimeout:z,expectedByteLength:h,resolve:Q=>{O||(O=!0,z(),S(Q))},reject:Q=>{O||(O=!0,z(),M(Q))}}),a.postMessage({type:c,requestId:g,token:u,byteLength:h},"*")})}function A(a){if(a)return{frameworks:a.frameworks?a.frameworks.map(u=>ri[u]).filter(u=>u&&u!=="unknown"):[],listenersRaw:a.listenersRaw??"",role:a.role??void 0,pattern:a.pattern??void 0,value:a.value??void 0}}async function D({tabIndex:a,call:u,elementData:h,payload:m}){let p=(()=>{try{return $t()?.top?.document||document}catch{return document}})(),d=u.args,g,_,C;try{({doc:g,win:_,unresolvedPath:C}=Jn(p,d.iframe_id))}catch{if(d.iframe_id!=null)return[{name:u.name,args:u.args,response:{success:!1,error:`Cannot access iframe ${d.iframe_id} (cross-origin or not found)`}}];g=document,_=Y(g)}let S=u.name,M=d.element_id?Pt(g,d.element_id):null,O=M?.ownerDocument??null,B;if(!cu.has(S))B={success:!1,error:`Tool not promotable to main: ${S}`,allowFallback:!0};else{let z=O??g,Q=Y(z,_);B=await q(S,M,d,h,z,Q,m)}return[{name:u.name,args:u.args,response:B}]}async function P(a,u,h){try{let m=a.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",d=a[m]?.scroll?.execute;if(typeof d!="function")throw new Error("main-world scroll detector not available");let g=h?.doc||zr(a)||document,_=Math.max(250,Math.min(Number(h?.timeoutMs??3500),8e3)),C=await Zn(Promise.resolve().then(()=>d(u)),_,g);if(!C.ok)throw new Error("scroll detector timeout");return C.value}catch(m){throw new Error(m?.message||"main-world scroll detector not available")}}async function q(a,u,h,m,p,d,g){let _=B=>({success:B.success,error:B.success?void 0:B.details||"Action failed",allowFallback:B.success?void 0:B.allowFallback??!0}),C=a===L.press_key||a===L.scroll_page||a===L.drag_and_drop||a===L.pinch_zoom;if(!u&&!C)return _({success:!1,method:"missing-element-race",details:"Target element missing",allowFallback:!0});let S=new Set([L.type_into_element,L.type_and_enter,L.clear_element,L.focus_element,L.select_text,L.check_field_validity]),M=u,O=G(M,p);if(M&&S.has(a)){let B=da(M,O);(B.kind==="input"||B.kind==="contenteditable")&&(M=B.el)}try{switch(a){case L.click_element:return _(X(u,p,d,m));case L.double_click_element:return _(En(u,p,d));case L.right_click_element:return _(de(u,p,d));case L.hover_element:return _(await Me(u,p,d,m,h.duration));case L.type_into_element:return _(await pt(M,p,d,h.text,m));case L.type_and_enter:return _(await ke(M,p,d,h.text,m));case L.clear_element:return _(await bt(M,p,d,m));case L.focus_element:return _(Ke(M,p,d));case L.select_dropdown_value:return _(Te(u,p,d,h.value,m));case L.adjust_slider:return _(Et(u,p,d,m?.value??h.value,m));case L.check_field_validity:return _(hn(M,p,d));case L.select_text:return _(mn(M,p,d,h.start_offset,h.end_offset));case L.scroll_page:return _(await Oe(u,p,d,h));case L.scroll_to_element:return _(await ir(u,p,d,h));case L.mouse_wheel:return _(ct(u,p,d,h.delta_x,h.delta_y));case L.drag_element:return _(await zt(u,p,d,h,m));case L.drag_and_drop:return _(await Lt(h,u,p,d));case L.swipe_element:return _(await jt(u,p,d,h));case L.long_press_element:return _(await gn(u,p,d,h.duration));case L.pinch_zoom:return _(await Fe(u,p,d,h));case L.press_key:return _(Nt(h.key,h.modifiers,u,p,d));case L.copy_text:return _(await ht(u,p,d));case L.paste_text:return _(await Dt(u,p,d,m));case L.upload_file:return _(await kt(h,p,d,g,u,m));case L.dispatch_pointer_path:return _(await Qe(h,p,d));default:return _({success:!1,method:"unhandled",details:`Unhandled ${a}`,allowFallback:!0})}}catch(B){return _({success:!1,method:"exception",details:B?.message||"exception",allowFallback:!0})}}function F(a){let u=new Map;if(!a)return u;let h=a.trim();if(!h)return u;let m=xn(h);if(m){for(let{id:p,mask:d}of m.entries){let g=Qt[p];if(!g)continue;let _=new Set(Vr(d)),C=u.get(g);if(C)for(let S of _)C.add(S);else u.set(g,_)}return u}return u}function H(a,...u){return a?u.some(h=>a.has(h)):!1}function U(a,u){let h=F(u?.listenersRaw),m=new Set;for(let[,S]of h)for(let M of S)(M==="react"||M==="vue"||M==="angular"||M==="svelte"||M==="jquery")&&m.add(M);let p=new Set;for(let[S,M]of h)if(["click","input","change","keydown","keyup","pointerdown","pointerup","mousedown","mouseup","submit","dragstart","drop","wheel","scroll"].includes(S))for(let O of M)p.add(O);let d=m.size>0||[...p].some(S=>["react","vue","angular","svelte","jquery"].includes(S)),g=H(h.get("click"),"delegated"),_=H(h.get("input"),"delegated")||H(h.get("change"),"delegated")||H(h.get("keydown"),"delegated"),C=u?.role||wr(a)||a.getAttribute("role");return{sourcesByType:h,fws:m,isFrameworkElement:d,delegatedClick:g,delegatedInput:_,role:C}}function X(a,u,h,m){let p=U(a,m),d=G(a,u),g=Y(d,h);Pe(a,d,g),m?.pattern==="hover-activate"&&Me(a,d,g,m,120);let _=p.fws.has("react")||H(p.sourcesByType.get("click"),"react"),C=p.fws.has("vue")||H(p.sourcesByType.get("click"),"vue"),S=p.fws.has("angular")||H(p.sourcesByType.get("click"),"angular"),M=p.fws.has("svelte")||H(p.sourcesByType.get("click"),"svelte"),O=p.fws.has("jquery")||H(p.sourcesByType.get("click"),"jquery");return ar(()=>Z(a,d,g),()=>te(a,d,g),()=>_?K(a,d,g):null,()=>C?se(a,d,g):null,()=>S?ae(a,d,g):null,()=>M?me(a,d,g):null,()=>O?ye(a,d,g):null)}function Z(a,u,h){let m=G(a,u),p=Y(m,h),d=p.PointerEvent||PointerEvent,g=p.MouseEvent||MouseEvent,{x:_,y:C}=oe(a,m,p),S={bubbles:!0,cancelable:!0,composed:!0,view:p,clientX:_,clientY:C,button:0,buttons:1};return a.focus?.({preventScroll:!0}),[new d("pointerover",S),new d("pointerenter",{...S,bubbles:!1}),new g("mouseover",S),new g("mouseenter",{...S,bubbles:!1}),new d("pointerdown",S),new g("mousedown",S),new d("pointerup",{...S,buttons:0}),new g("mouseup",{...S,buttons:0}),new g("click",{...S,buttons:0})].forEach(O=>a.dispatchEvent(O)),{success:!0,method:"pointer-mouse-click"}}function te(a,u,h){let m=G(a,u),p=Y(m,h);try{if(a instanceof HTMLAnchorElement){let d=a.getAttribute("target");try{a.setAttribute("target","_self"),a.click()}finally{d===null?a.removeAttribute("target"):a.setAttribute("target",d)}}else a.click?.();return{success:!0,method:"native-click"}}catch{return{success:!1,method:"native-click"}}}function oe(a,u,h){let m=G(a,u),p=a.getBoundingClientRect(),d=[{x:p.left+p.width/2,y:p.top+p.height/2},{x:p.left+4,y:p.top+4},{x:p.right-4,y:p.top+4},{x:p.left+4,y:p.bottom-4},{x:p.right-4,y:p.bottom-4}],g=null;for(let _=0;_<d.length;_++){let C=d[_],S=m.elementFromPoint(C.x,C.y);if(_===0&&(g=S),S&&wa(a,S))return{...C,hit:S,ok:!0}}return{...d[0],hit:g,ok:!1}}function K(a,u,h){let m=G(a,u),p=Y(m,h);try{let d=Kt(a);if(!d)return{success:!1,method:"react-no-fiber"};let g=Wt(d),_=g.onClick||g.onClickCapture;return _?(_(Ot("click",a,m,p)),{success:!0,method:"react-fiber-onClick"}):{success:!1,method:"react-no-onClick"}}catch{return{success:!1,method:"react-fiber-onClick"}}}function se(a,u,h){let m=G(a,u),d=Y(m,h).MouseEvent||MouseEvent;try{let g=yt(a);if(!g)return{success:!1,method:"vue-none"};let _=sn(g);return _.click?(_.click(new d("click",{bubbles:!0})),{success:!0,method:"vue-handler"}):g.$emit?(g.$emit("click"),{success:!0,method:"vue-emit"}):{success:!1,method:"vue-no-click"}}catch{return{success:!1,method:"vue-handler"}}}function ae(a,u,h){let m=G(a,u),p=Y(m,h),d=p.MouseEvent||MouseEvent;try{let g=p.ng?.getZone?.()||null;return g?.run?(g.run(()=>a.dispatchEvent(new d("click",{bubbles:!0,cancelable:!0}))),{success:!0,method:"angular-zone-click"}):(a.dispatchEvent(new d("click",{bubbles:!0,cancelable:!0})),a.click?.(),{success:!0,method:"angular-click"})}catch{return{success:!1,method:"angular-click",allowFallback:!0}}}function me(a,u,h){let m=G(a,u),d=Y(m,h).MouseEvent||MouseEvent;try{let g=a.getBoundingClientRect(),_={bubbles:!0,cancelable:!0,view:a.ownerDocument?.defaultView||window,clientX:g.left+g.width/2,clientY:g.top+g.height/2};return a.dispatchEvent(new d("mousedown",_)),a.dispatchEvent(new d("mouseup",_)),a.dispatchEvent(new d("click",_)),{success:!0,method:"svelte-click"}}catch{return{success:!1,method:"svelte-click"}}}function ye(a,u,h){let m=G(a,u),p=Y(m,h);try{return p.jQuery?.(a)?.trigger?.("click"),{success:!0,method:"jquery-trigger"}}catch{return{success:!1,method:"jquery-trigger"}}}async function Me(a,u,h,m,p=500){let d=Math.min(Math.max(0,Number(p)||500),3e4),g=G(a,u),_=Y(g,h),C=U(a,m);Pe(a,g,_);let S=_.PointerEvent||PointerEvent,M=_.MouseEvent||MouseEvent,O=a.getBoundingClientRect(),B=O.left+O.width/2,z=O.top+O.height/2;if(C.fws.has("react")){let ee=Kt(a),ne=ee?Wt(ee):{};ne.onMouseEnter?.(Ot("mouseenter",a,g,_)),ne.onPointerEnter?.(Ot("pointerenter",a,g,_))}else if(C.fws.has("vue")){let ee=yt(a),ne=ee?sn(ee):{};ne.mouseenter?.(new M("mouseenter",{bubbles:!0})),ne.mouseover?.(new M("mouseover",{bubbles:!0}))}let Q={bubbles:!0,cancelable:!0,composed:!0,view:_,clientX:B,clientY:z};return[new S("pointerover",Q),new S("pointerenter",{...Q,bubbles:!1}),new M("mouseover",Q),new M("mouseenter",{...Q,bubbles:!1})].forEach(ee=>a.dispatchEvent(ee)),await et(d,g),{success:!0,method:"hover-seq"}}async function pe(a,u,h=1){await Promise.resolve();for(let m=0;m<h;m++)a.hidden?await wt():await new Promise(p=>{try{u.requestAnimationFrame(()=>p())}catch{wt().then(p)}})}let Ie=a=>String(a??"").replace(/\s+/g," ").trim();function ot(a){try{if("value"in a)return String(a.value??"")}catch{}return""}function Ge(a){try{return typeof Mn=="function"?Mn(a):Ie(a.textContent)}catch{return""}}function Ue(a,u){if(!(u.isFrameworkElement||u.delegatedInput))return!1;let h=String(a??"").length;return h>0&&h<=140}async function pt(a,u,h,m,p){let d=U(a,p),g=G(a,u),_=Y(g,h);if(Pe(a,g,_),At(a,_)||Ft(a,_)){let S=Ue(String(m??""),d),M=await ha(a,g,_,m,{settleFrames:g.hidden?1:2,useKeyFallback:S,keyFallbackMaxLen:140});return{success:M.success,method:M.method,details:M.details,allowFallback:!M.success}}if(a.isContentEditable===!0||d.role==="textbox"&&!("value"in a)){let S=Ge(a),M=ma(a,m,g,_);await pe(g,_,g.hidden?1:2);let O=Ge(a),B=!1;if(String(m??"").length>0&&O===S){B=!0;try{Kn(a,g,_),jn(a,g,_,!0);try{g.execCommand?.("insertText",!1,String(m??""))}catch{}Cn(a,String(m??""),"insertText")}catch{}await pe(g,_,g.hidden?1:2)}let z=Ge(a),Q=z!==S||!!String(m??"")&&z.includes(String(m??""));return{success:Q,method:M.method,details:`${M.details};beforeLen=${S.length};afterLen=${z.length};reverted=${O===S};fallback=${B}`,allowFallback:Q?void 0:!0}}return{success:!1,method:"type",details:"target not editable",allowFallback:!0}}async function ke(a,u,h,m,p){let d=G(a,u),g=Y(d,h),_=await pt(a,d,g,m,p);if(!_.success)return _;let C=ga(a);return{success:!0,method:"type+enter",details:`${_.details};enter=${C.method}`}}async function bt(a,u,h,m){let p=G(a,u),d=Y(p,h),g=d.Event||Event;if(Pe(a,p,d),At(a,d)||Ft(a,d)){let C=ot(a),S=ba(a,p,d);if(await pe(p,d,p.hidden?1:2),ot(a)===C&&C.length>0){try{Ir(a,""),Cn(a,"","deleteByCut")}catch{}await pe(p,d,p.hidden?1:2)}let B=ot(a),z=B.length===0||B!==C;return{success:S.success,method:S.method,details:S.details,allowFallback:!S.success}}if(a.isContentEditable===!0||U(a,m).role==="textbox"&&!("value"in a)){let C=Ea(a,p,d);return await pe(p,d,p.hidden?1:2),{success:C.success,method:C.method,details:C.details,allowFallback:!C.success}}if("value"in a){try{a.value=""}catch{}return a.dispatchEvent(new g("input",{bubbles:!0,composed:!0})),a.dispatchEvent(new g("change",{bubbles:!0,composed:!0})),{success:!0,method:"clear-generic-value"}}return{success:!1,method:"clear",details:"target not clearable",allowFallback:!0}}function Ke(a,u,h){try{let m=G(a,u),p=Y(m,h),d=p.FocusEvent||FocusEvent;return Pe(a,m,p),a.focus?.({preventScroll:!0}),a.dispatchEvent(new d("focus",{bubbles:!0})),a.dispatchEvent(new d("focusin",{bubbles:!0})),{success:!0,method:"focus"}}catch(m){return{success:!1,method:"focus",details:m.message,allowFallback:!0}}}function Te(a,u,h,m,p){try{let d=G(a,u),g=Y(d,h),_=g.Event||Event;if(!ui(a,g))return{success:!1,method:"select",details:"target not select",allowFallback:!0};Pe(a,d,g),a.focus?.({preventScroll:!0});let C=Array.from(a.options).find(B=>B.value===m||B.text.trim()===m.trim());if(!C)return{success:!1,method:"select",details:`Option not found: ${m}`,allowFallback:!0};C.selected=!0;let S=Object.getPrototypeOf(a),M=Object.getOwnPropertyDescriptor(S,"value");if(M?.set?M.set.call(a,C.value):a.value=C.value,a.dispatchEvent(new _("input",{bubbles:!0,composed:!0})),a.dispatchEvent(new _("change",{bubbles:!0,composed:!0})),U(a,p).fws.has("react")){let B=Kt(a);if(B){let z=Wt(B);if(z.onChange){let Q=Ot("change",a,d,g);Q.target.value=C.value,z.onChange(Q)}}}return{success:!0,method:"select"}}catch(d){return{success:!1,method:"select",details:d.message,allowFallback:!0}}}function Et(a,u,h,m,p){try{let d=G(a,u),g=Y(d,h),_=g.Event||Event;if(!At(a,g))return{success:!1,method:"slider",details:"target not input",allowFallback:!0};Pe(a,d,g),a.focus?.({preventScroll:!0});let C=Object.getPrototypeOf(a),S=Object.getOwnPropertyDescriptor(C,"value");if(S?.set?S.set.call(a,String(m)):a.value=String(m),a.dispatchEvent(new _("input",{bubbles:!0,composed:!0})),a.dispatchEvent(new _("change",{bubbles:!0,composed:!0})),U(a,p).fws.has("react")){let O=Kt(a);if(O){let B=Wt(O);if(B.onChange){let z=Ot("change",a,d,g);z.target.value=String(m),B.onChange(z)}}}return{success:!0,method:"slider"}}catch(d){return{success:!1,method:"slider",details:d.message,allowFallback:!0}}}function hn(a,u,h){try{let m=a.checkValidity?.()??!0;return m||a.reportValidity?.(),{success:m,method:"check-validity",details:m?void 0:a.validationMessage}}catch(m){return{success:!1,method:"check-validity",details:m.message,allowFallback:!0}}}function mn(a,u,h,m,p){try{let d=G(a,u),g=Y(d,h);if("setSelectionRange"in a){let S=a;S.focus?.();let M=S.value?.length??0;return S.setSelectionRange(m??0,p??M),{success:!0,method:"select-range"}}let _=g.getSelection();if(!_)return{success:!1,method:"select-range",allowFallback:!0};let C=d.createRange();return C.selectNodeContents(a),_.removeAllRanges(),_.addRange(C),{success:!0,method:"select-range-node"}}catch(d){return{success:!1,method:"select-range",details:d.message,allowFallback:!0}}}function Mt(a,u,h,m,p){let d=Ln((a&&G(a))??u),g=a||d,_=G(g,u),C=Y(_,h),S=g===_.documentElement||g===_.body||g===d;if(m===Ne.TOP||m===Ne.BOTTOM){let M=g.scrollHeight,O=S?C.innerHeight:g.clientHeight,B=Math.max(0,M-O);return g.scrollTop=m===Ne.TOP?0:B,{success:!0,scrollTop:g.scrollTop}}return Eo(g,_,C,m,p)}async function Oe(a,u,h,m){let p=m.direction,d=m.amount,g=G(a,u),_=Y(g,h),C=!g.hidden,S=C?"smooth":"auto";try{if(a){let O=Bt(a,g,_),B=Mt(O,g,_,p,d);return B?.success?{success:!0,method:"direct-element-scroll",details:JSON.stringify(B)}:{success:!1,method:"direct-element-scroll",details:B?.error||"direct scroll failed",allowFallback:!0}}if(p===Ne.TOP||p===Ne.BOTTOM){let O=await P(_,{action:"scrollTo",direction:p,options:{behavior:S,isTabActive:C}},{doc:g,timeoutMs:g.hidden?5200:2800});return{success:!0,method:"detector-scrollTo",details:JSON.stringify(O)}}let M=await P(_,{action:"scrollBy",direction:p,options:{amount:d,behavior:S,isTabActive:C}},{doc:g,timeoutMs:g.hidden?5200:2800});return{success:!0,method:"detector-scrollBy",details:JSON.stringify(M)}}catch(M){let O=g?Mt(Ln(g),g,_,p,d):void 0;return O?.success?{success:!0,method:"direct-primary-scroll-fallback",details:JSON.stringify(O)}:{success:!1,method:"scroll-page-failed",details:M?.message||O?.error||"scroll_page failed",allowFallback:!0}}}async function ir(a,u,h,m){let p=G(a,u),d=Y(p,h),g=!p.hidden,_=g?"smooth":"auto",C=Ca(m.position),S=er(a,p);if(!S){let M=As(a,p,d,C);return{success:M.success,method:"direct-scrollElement-no-selector",details:M.error,allowFallback:!M.success}}try{let M=await P(d,{action:"scrollElement",selector:S,position:C,options:{behavior:_,isTabActive:g}},{doc:p,timeoutMs:p.hidden?5600:3e3});return{success:!0,method:"detector-scrollElement",details:JSON.stringify(M)}}catch(M){let O=As(a,p,d,C);return O.success?{success:!0,method:"direct-scrollElement-fallback",details:JSON.stringify(O)}:{success:!1,method:"scroll-to-element-failed",details:M?.message||O.error||"scroll_to_element failed",allowFallback:!0}}}function ct(a,u,h,m,p){try{let d=G(a,u),g=Y(d,h),_=g.WheelEvent||WheelEvent;Pe(a,d,g);let C=Bt(a,d,g);return C.dispatchEvent(new _("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:g,deltaX:m||0,deltaY:p||0,deltaMode:_.DOM_DELTA_PIXEL})),C.scrollBy({left:m||0,top:p||0,behavior:"auto"}),{success:!0,method:"wheel"}}catch(d){return{success:!1,method:"wheel",details:d.message,allowFallback:!0}}}function Bt(a,u,h){let m=G(a,u),p=Y(m,h),d=m.scrollingElement||m.documentElement||m.body,g=a;for(;g&&g!==m.body&&g!==m.documentElement;){let C=p.getComputedStyle(g).overflowY;if((C==="auto"||C==="scroll"||C==="overlay")&&g.scrollHeight>g.clientHeight+5)return g;g=g.parentElement}return d}async function zt(a,u,h,m,p){try{let d=G(a,u),g=Y(d,h),_=g.PointerEvent||PointerEvent,C=g.MouseEvent||MouseEvent,S=g.DragEvent||DragEvent,M=g.DataTransfer||DataTransfer;Pe(a,d,g);let O=oe(a,d,g),B=We(O.hit,g)?O.hit:a,z=a.getBoundingClientRect(),Q=Number.isFinite(Number(m?.distance))?Number(m.distance):160,ge=0,ee=0;switch(String(m?.direction||"").toUpperCase()){case"UP":ee=-Q;break;case"DOWN":ee=Q;break;case"LEFT":ge=-Q;break;case"RIGHT":ge=Q;break;default:ge=Number(m?.delta_x)||0,ee=Number(m?.delta_y)||0}let ne=(k,N)=>({x:Math.max(2,Math.min(k,g.innerWidth-3)),y:Math.max(2,Math.min(N,g.innerHeight-3))}),ce=ne(O.x,O.y),xe=ne(O.x+ge,O.y+ee),Ye=500+Date.now()%1e4,ue=Math.max(12,Math.min(36,Number(m?.steps)||18)),be=(k,N)=>({bubbles:!0,cancelable:!0,composed:!0,view:g,clientX:k,clientY:N,pageX:k+(g.scrollX||0),pageY:N+(g.scrollY||0)}),Ee=(k,N,V)=>({...be(k,N),pointerId:Ye,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:V?.5:0,buttons:V,button:0}),l=(k,N,V)=>({...be(k,N),buttons:V,button:0});B.dispatchEvent(new _("pointerdown",Ee(ce.x,ce.y,1))),B.dispatchEvent(new C("mousedown",l(ce.x,ce.y,1)));try{B.setPointerCapture?.(Ye)}catch{}let E=null;try{(a.draggable||U(a,p).sourcesByType.has("dragstart"))&&(E=new M)}catch{E=null}if(E)try{a.dispatchEvent(new S("dragstart",{bubbles:!0,cancelable:!0,clientX:ce.x,clientY:ce.y,dataTransfer:E}))}catch{}let R=null;for(let k=1;k<=ue;k++){let N=ce.x+(xe.x-ce.x)*k/ue,V=ce.y+(xe.y-ce.y)*k/ue,j=d.elementFromPoint(N,V)||a;if(j.dispatchEvent(new _("pointermove",Ee(N,V,1))),j.dispatchEvent(new C("mousemove",l(N,V,1))),E)try{R&&R!==j&&R.dispatchEvent(new S("dragleave",{bubbles:!0,cancelable:!0,clientX:N,clientY:V,dataTransfer:E})),j.dispatchEvent(new S("dragover",{bubbles:!0,cancelable:!0,clientX:N,clientY:V,dataTransfer:E})),R=j}catch{}k%3===0&&await wt()}let T=d.elementFromPoint(xe.x,xe.y)||a;if(T.dispatchEvent(new _("pointerup",Ee(xe.x,xe.y,0))),T.dispatchEvent(new C("mouseup",l(xe.x,xe.y,0))),E)try{a.dispatchEvent(new S("dragend",{bubbles:!0,cancelable:!0,clientX:xe.x,clientY:xe.y,dataTransfer:E}))}catch{}return{success:!0,method:"drag",details:`dx=${ge};dy=${ee};steps=${ue};hitOk=${O.ok}`}}catch(d){return{success:!1,method:"drag",details:d?.message||"drag failed",allowFallback:!0}}}async function Lt(a,u,h,m){try{let p=G(u,h),d=Y(p,m),g=d.PointerEvent||PointerEvent,_=d.MouseEvent||MouseEvent,C=d.DragEvent||DragEvent,S=d.DataTransfer||DataTransfer,M=a?.source_element_id??a?.element_id,O=(M?Pt(p,String(M)):null)||u;if(!O)return{success:!1,method:"drag-drop",details:"source missing",allowFallback:!0};let B=null,z=Number(a?.target_x),Q=Number(a?.target_y);if(a?.target_element_id){if(B=Pt(p,String(a.target_element_id)),!B)return{success:!1,method:"drag-drop",details:"target missing",allowFallback:!0};let T=B.getBoundingClientRect();z=T.left+T.width/2,Q=T.top+T.height/2}if((!Number.isFinite(z)||!Number.isFinite(Q))&&!B)return{success:!1,method:"drag-drop",details:"missing target coords",allowFallback:!0};Pe(O,p,d),B&&Pe(B,p,d);let ge=(T,k)=>({x:Math.max(2,Math.min(T,d.innerWidth-3)),y:Math.max(2,Math.min(k,d.innerHeight-3))}),ee=O.getBoundingClientRect(),ne=ge(ee.left+ee.width/2,ee.top+ee.height/2),ce=ge(Number(z),Number(Q)),xe=600+Date.now()%1e4,Ye=Math.max(14,Math.min(42,Number(a?.steps)||22)),ue=(T,k)=>({bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:T,clientY:k,pageX:T+(d.scrollX||0),pageY:k+(d.scrollY||0)}),be=(T,k,N)=>({...ue(T,k),pointerId:xe,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:N?.5:0,buttons:N,button:0}),Ee=(T,k,N)=>({...ue(T,k),buttons:N,button:0}),l=null;try{l=new S}catch{l=null}O.dispatchEvent(new g("pointerdown",be(ne.x,ne.y,1))),O.dispatchEvent(new _("mousedown",Ee(ne.x,ne.y,1)));try{O.setPointerCapture?.(xe)}catch{}if(l)try{O.dispatchEvent(new C("dragstart",{bubbles:!0,cancelable:!0,clientX:ne.x,clientY:ne.y,dataTransfer:l}))}catch{}let E=null;for(let T=1;T<=Ye;T++){let k=ne.x+(ce.x-ne.x)*T/Ye,N=ne.y+(ce.y-ne.y)*T/Ye,V=p.elementFromPoint(k,N)||B||p.body;if(V.dispatchEvent(new g("pointermove",be(k,N,1))),V.dispatchEvent(new _("mousemove",Ee(k,N,1))),l)try{E&&E!==V&&E.dispatchEvent(new C("dragleave",{bubbles:!0,cancelable:!0,clientX:k,clientY:N,dataTransfer:l})),V.dispatchEvent(new C("dragenter",{bubbles:!0,cancelable:!0,clientX:k,clientY:N,dataTransfer:l})),V.dispatchEvent(new C("dragover",{bubbles:!0,cancelable:!0,clientX:k,clientY:N,dataTransfer:l})),E=V}catch{}T%3===0&&await wt()}let R=B||p.elementFromPoint(ce.x,ce.y)||p.body;if(l)try{R.dispatchEvent(new C("drop",{bubbles:!0,cancelable:!0,clientX:ce.x,clientY:ce.y,dataTransfer:l}))}catch{}if(R.dispatchEvent(new g("pointerup",be(ce.x,ce.y,0))),R.dispatchEvent(new _("mouseup",Ee(ce.x,ce.y,0))),l)try{O.dispatchEvent(new C("dragend",{bubbles:!0,cancelable:!0,clientX:ce.x,clientY:ce.y,dataTransfer:l}))}catch{}return{success:!0,method:"html5+pointer-dragdrop",details:`steps=${Ye};source=${String(M)}`}}catch(p){return{success:!1,method:"drag-drop",details:p?.message||"drag-drop failed",allowFallback:!0}}}async function jt(a,u,h,m){try{let p=G(a,u),d=Y(p,h),g=d.PointerEvent||PointerEvent,_=d.MouseEvent||MouseEvent;Pe(a,p,d);let C=oe(a,p,d),S={x:C.x,y:C.y},M=a.getBoundingClientRect(),O=Number.isFinite(Number(m?.distance))?Number(m.distance):Math.min(Math.max(80,Math.min(M.width,M.height)),220),B=String(m?.direction||"RIGHT").toUpperCase(),z=S.x,Q=S.y;B==="LEFT"&&(z-=O),B==="RIGHT"&&(z+=O),B==="UP"&&(Q-=O),B==="DOWN"&&(Q+=O);let ge=(k,N)=>({x:Math.max(2,Math.min(k,d.innerWidth-3)),y:Math.max(2,Math.min(N,d.innerHeight-3))}),ee=ge(S.x,S.y),ne=ge(z,Q),ce=700+Date.now()%1e4,xe=Math.max(10,Math.min(28,Number(m?.steps)||16)),Ye=(k,N)=>({bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:k,clientY:N,pageX:k+(d.scrollX||0),pageY:N+(d.scrollY||0)}),ue=(k,N,V)=>({...Ye(k,N),pointerId:ce,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:V?.5:0,buttons:V,button:0}),be=(k,N,V)=>({...Ye(k,N),buttons:V,button:0}),Ee=p.elementFromPoint(ee.x,ee.y)||a;Ee.dispatchEvent(new g("pointerdown",ue(ee.x,ee.y,1))),Ee.dispatchEvent(new _("mousedown",be(ee.x,ee.y,1)));let l=d.Touch,E=d.TouchEvent,R=!!l&&!!E;if(R)try{let k=new l({identifier:ce,target:Ee,clientX:ee.x,clientY:ee.y,pageX:ee.x,pageY:ee.y,screenX:ee.x,screenY:ee.y,radiusX:1,radiusY:1,rotationAngle:0,force:1});Ee.dispatchEvent(new E("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[k],targetTouches:[k],changedTouches:[k]}))}catch{}for(let k=1;k<=xe;k++){let N=ee.x+(ne.x-ee.x)*k/xe,V=ee.y+(ne.y-ee.y)*k/xe,j=p.elementFromPoint(N,V)||a;if(j.dispatchEvent(new g("pointermove",ue(N,V,1))),j.dispatchEvent(new _("mousemove",be(N,V,1))),R)try{let ie=new l({identifier:ce,target:j,clientX:N,clientY:V,pageX:N,pageY:V,screenX:N,screenY:V,radiusX:1,radiusY:1,rotationAngle:0,force:1});j.dispatchEvent(new E("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[ie],targetTouches:[ie],changedTouches:[ie]}))}catch{}k%3===0&&await wt()}let T=p.elementFromPoint(ne.x,ne.y)||a;if(T.dispatchEvent(new g("pointerup",ue(ne.x,ne.y,0))),T.dispatchEvent(new _("mouseup",be(ne.x,ne.y,0))),R)try{let k=new l({identifier:ce,target:T,clientX:ne.x,clientY:ne.y,pageX:ne.x,pageY:ne.y,screenX:ne.x,screenY:ne.y,radiusX:1,radiusY:1,rotationAngle:0,force:0});T.dispatchEvent(new E("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[k]}))}catch{}return{success:!0,method:"swipe",details:`dir=${B};dist=${O};steps=${xe};hitOk=${C.ok}`}}catch(p){return{success:!1,method:"swipe",details:p?.message||"swipe failed",allowFallback:!0}}}async function Fe(a,u,h,m){try{let p=a||u.body,d=G(p,u),g=Y(d,h),_=g.PointerEvent||PointerEvent,C=g.WheelEvent||WheelEvent;Pe(p,d,g);let S=Number.isFinite(Number(m?.scale))?Number(m.scale):1.2,M=p.getBoundingClientRect(),O=M.left+M.width/2,B=M.top+M.height/2,z=24,Q=Math.max(6,Math.min(200,z*S)),ge=Math.max(6,Math.min(18,Number(m?.steps)||10)),ee=g.Touch,ne=g.TouchEvent;if(!!ee&&!!ne)try{let ue=(R,T)=>new ee({identifier:R,target:p,clientX:T,clientY:B,pageX:T,pageY:B,screenX:T,screenY:B,radiusX:1,radiusY:1,rotationAngle:0,force:1}),be=ue(911,O-z),Ee=ue(912,O+z);p.dispatchEvent(new ne("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[be,Ee],targetTouches:[be,Ee],changedTouches:[be,Ee]}));for(let R=1;R<=ge;R++){let T=z+(Q-z)*R/ge,k=ue(911,O-T),N=ue(912,O+T);p.dispatchEvent(new ne("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[k,N],targetTouches:[k,N],changedTouches:[k,N]})),R%2===0&&await wt()}let l=ue(911,O-Q),E=ue(912,O+Q);p.dispatchEvent(new ne("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[l,E]}))}catch{}try{let ue=(be,Ee,l)=>({bubbles:!0,cancelable:!0,composed:!0,view:g,clientX:Ee,clientY:B,pointerId:be,pointerType:"touch",isPrimary:be===821,width:1,height:1,pressure:l?.5:0,buttons:l,button:0});p.dispatchEvent(new _("pointerdown",ue(821,O-z,1))),p.dispatchEvent(new _("pointerdown",ue(822,O+z,1)));for(let be=1;be<=ge;be++){let Ee=z+(Q-z)*be/ge;p.dispatchEvent(new _("pointermove",ue(821,O-Ee,1))),p.dispatchEvent(new _("pointermove",ue(822,O+Ee,1))),be%2===0&&await wt()}p.dispatchEvent(new _("pointerup",ue(821,O-Q,0))),p.dispatchEvent(new _("pointerup",ue(822,O+Q,0)))}catch{}try{let xe=S>=1?-120:120;p.dispatchEvent(new C("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:g,clientX:O,clientY:B,ctrlKey:!0,deltaY:xe,deltaMode:C.DOM_DELTA_PIXEL}))}catch{}return{success:!0,method:"pinch-zoom",details:`scale=${S};steps=${ge}`}}catch(p){return{success:!1,method:"pinch-zoom",details:p?.message||"pinch-zoom failed",allowFallback:!0}}}async function gn(a,u,h,m=800){try{let p=G(a,u),d=Y(p,h),g=d.PointerEvent||PointerEvent,_=d.MouseEvent||MouseEvent,C=d.FocusEvent||FocusEvent;Pe(a,p,d);let S=oe(a,p,d),M=a;!S.ok&&We(S.hit,d)?M=S.hit.closest?.('a,button,input,select,textarea,summary,[role="button"],[role="link"],[onclick]')||S.hit:We(S.hit,d)&&(M=S.hit);let O=wn(M,p,d),B=S.x,z=S.y,Q=1+Date.now()%1e4,ge={bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:B,clientY:z,pageX:B+(d.scrollX||0),pageY:z+(d.scrollY||0),screenX:B+(d.screenX||0),screenY:z+(d.screenY||0)},ee={...ge,pointerId:Q,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:0,buttons:0,button:0};try{M.dispatchEvent(new g("pointerover",ee)),M.dispatchEvent(new g("pointerenter",{...ee,bubbles:!1}))}catch{}try{M.dispatchEvent(new _("mouseover",ge)),M.dispatchEvent(new _("mouseenter",{...ge,bubbles:!1}))}catch{}try{M.focus?.({preventScroll:!0}),M.dispatchEvent(new C("focus",{bubbles:!0,composed:!0})),M.dispatchEvent(new C("focusin",{bubbles:!0,composed:!0}))}catch{}try{M.dispatchEvent(new g("pointerdown",{...ee,buttons:1,pressure:.5}))}catch{}try{M.dispatchEvent(new _("mousedown",{...ge,buttons:1,button:0}))}catch{}try{let ue=d.Touch,be=d.TouchEvent;if(typeof ue<"u"&&typeof be<"u"){let Ee=new ue({identifier:Q,target:M,clientX:B,clientY:z,pageX:B+(d.scrollX||0),pageY:z+(d.scrollY||0),screenX:B+(d.screenX||0),screenY:z+(d.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:1});M.dispatchEvent(new be("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[Ee],targetTouches:[Ee],changedTouches:[Ee]}))}}catch{}let ne=Number(m),ce=Number.isFinite(ne)&&ne>0?ne:800,xe=p.hidden?Math.max(ce,1200):ce;await et(xe,p);try{M.dispatchEvent(new _("contextmenu",{...ge,button:2,buttons:2}))}catch{}try{M.dispatchEvent(new g("pointerup",{...ee,buttons:0,pressure:0}))}catch{}try{M.dispatchEvent(new _("mouseup",{...ge,buttons:0,button:0}))}catch{}try{let ue=d.Touch,be=d.TouchEvent;if(typeof ue<"u"&&typeof be<"u"){let Ee=new ue({identifier:Q,target:M,clientX:B,clientY:z,pageX:B+(d.scrollX||0),pageY:z+(d.scrollY||0),screenX:B+(d.screenX||0),screenY:z+(d.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:0});M.dispatchEvent(new be("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[Ee]}))}}catch{}let Ye=await qe(M,p,d,O);return{success:!0,method:"long-press",details:`holdMs=${xe};verified=${Ye};hitOk=${S.ok};target=${M.tagName.toLowerCase()}`}}catch(p){return{success:!1,method:"long-press",details:p?.message||"long-press failed",allowFallback:!0}}}function Nt(a,u,h,m,p){try{let d=G(h,m),_=Y(d,p).KeyboardEvent||KeyboardEvent,C=h||d.activeElement||d.body||d.documentElement;C.focus?.();let S={key:a,code:Pr(a),bubbles:!0,cancelable:!0,ctrlKey:u?.includes("CTRL"),altKey:u?.includes("ALT"),shiftKey:u?.includes("SHIFT"),metaKey:u?.includes("META")},M=C.dispatchEvent(new _("keydown",S)),O=C.dispatchEvent(new _("keypress",S)),B=C.dispatchEvent(new _("keyup",S));if(a==="Enter"&&!!(M&&O&&B)){let Q=C.form||C.closest?.("form");Q?.requestSubmit?Q.requestSubmit():Q?.submit?.()}return{success:!0,method:"press-key"}}catch(d){return{success:!1,method:"press-key",details:d.message,allowFallback:!0}}}async function ht(a,u,h){try{let m=a.innerText||a.value||"";if(!m)return{success:!1,method:"copy",details:"nothing to copy",allowFallback:!0};let p=G(a,u),d=Y(p,h);if(d.navigator?.clipboard?.writeText)return await d.navigator.clipboard.writeText(m),{success:!0,method:"clipboard-copy"};let g=p.createRange();g.selectNodeContents(a);let _=d.getSelection?.()||(p.defaultView||window).getSelection?.();_?.removeAllRanges(),_?.addRange(g);let C=p.execCommand?.("copy")??!1;return _?.removeAllRanges(),{success:!!C,method:"execCommand-copy",allowFallback:!C}}catch(m){return{success:!1,method:"clipboard-copy",details:m.message,allowFallback:!0}}}async function Dt(a,u,h,m){try{a.focus?.();let p=G(a,u),d=Y(p,h);if(d.navigator?.clipboard?.readText){let _=await d.navigator.clipboard.readText();if(_)return await pt(a,p,d,_,m)}return p.execCommand?.("paste")??!1?{success:!0,method:"execCommand-paste"}:{success:!1,method:"paste",details:"clipboard empty or denied",allowFallback:!0}}catch(p){return{success:!1,method:"paste",details:p.message,allowFallback:!0}}}function on(a){return`${(a/1024).toFixed(1)}KB`}function bn(a,u){if(a instanceof u.defaultView.HTMLInputElement){let g=a;if((g.type||"").toLowerCase()==="file")return g}let h=a.closest?.("label"),m=h?.htmlFor||a.htmlFor||"";if(m){let g=u.getElementById(m);if(g&&(g.type||"").toLowerCase()==="file")return g}if(h){let g=h.querySelector?.('input[type="file"]');if(g)return g}let p=a.closest?.("form");if(p){let g=p.querySelector?.('input[type="file"]');if(g)return g}let d=a.closest?.("div,section,main,article")||a.parentElement;if(d){let g=d.querySelector?.('input[type="file"]');if(g)return g}return null}function Pn(a,u,h){try{let m=h.HTMLInputElement?.prototype,p=m?Object.getOwnPropertyDescriptor(m,"files")?.set:void 0;if(!p){let d=Object.getPrototypeOf(a);for(;d&&!p;)p=Object.getOwnPropertyDescriptor(d,"files")?.set,d=Object.getPrototypeOf(d)}return p?(p.call(a,u),!0):(a.files=u,!0)}catch{try{return a.files=u,!0}catch{return!1}}}async function kt(a,u,h,m,p,d){try{let{file_url:g,element_id:_,file_name:C}=a,S=null;if(p&&(S=bn(p,u)),!S&&_!==void 0&&(S=u.querySelector(`input[type="file"][${st}*="[id=${_}]"]`)),!S){let T=u.querySelectorAll('input[type="file"]');for(let k of T){if(k.disabled)continue;let N=k.getBoundingClientRect();if(N.width>0&&N.height>0){S=k;break}}}if(!S)return{success:!1,method:"upload-file",details:"No file input found",allowFallback:!0};if(S.disabled)return{success:!1,method:"upload-file",details:"File input is disabled",allowFallback:!0};let M=G(S,u),O=Y(M,h);if(!(m?.kind==="upload_file"&&typeof m.byteLength=="number"&&m.byteLength>=0&&typeof m.mimeType=="string"&&(typeof m.inlineB64=="string"||typeof m.token=="string")))return{success:!1,method:"upload-file",details:"Missing upload payload (need inlineB64 or token)",allowFallback:!0};let z=Number(m.byteLength),Q=(m.mimeType||"application/octet-stream").split(";")[0].trim()||"application/octet-stream",ge;if(m.inlineB64&&typeof m.inlineB64=="string"){let T=Ia(m.inlineB64);if(T.byteLength!==z)return{success:!1,method:"upload-file",details:`Inline bytes length mismatch: got=${T.byteLength} expected=${z}`,allowFallback:!0};ge=T.buffer}else{let T=String(m.token);ge=await x(O,T,z,9e4)}let ee=O.Blob||Blob,ne=new ee([ge],{type:Q}),ce=C||m?.fileName;!ce&&g&&typeof g=="string"&&(ce=Is(g,O)),ce=ka(ce||"upload");let xe=O.File||File,Ye=new xe([ne],ce,{type:Q,lastModified:Date.now()}),ue=O.Event||Event,be=O.DataTransfer||DataTransfer;if(!be)return{success:!1,method:"upload-file",details:"DataTransfer unavailable in this context",allowFallback:!0};let Ee=new be;if(Ee.items.add(Ye),!Pn(S,Ee.files,O))return{success:!1,method:"upload-file",details:"Failed to set input.files",allowFallback:!0};S.dispatchEvent(new ue("input",{bubbles:!0,composed:!0,cancelable:!0})),S.dispatchEvent(new ue("change",{bubbles:!0,composed:!0,cancelable:!0}));let E=Kt(S);if(E){let T=Wt(E);if(T.onChange){let k=Ot("change",S,M,O);k.target.files=Ee.files,T.onChange(k)}}let R=yt(S);if(R){let T=sn(R);if(T.change){let k=new ue("change",{bubbles:!0});k.target=S,k.target.files=Ee.files,T.change(k)}}try{let T=O.jQuery||O.$;T&&typeof T=="function"&&T(S).triggerHandler?.("change")}catch{}return S.focus?.({preventScroll:!0}),await pe(M,O,2),{success:!0,method:"upload-file",details:`Uploaded ${ce} (${on(ne.size)}) [token]`}}catch(g){return{success:!1,method:"upload-file",details:g?.message||"Upload failed",allowFallback:!0}}}async function Qe(a,u,h){let m=Array.isArray(a.path)?a.path:[];if(!m.length)return{success:!1,method:"dispatch_pointer_path",details:"Empty path",allowFallback:!0};let p=h.PointerEvent||PointerEvent,d=h.MouseEvent||MouseEvent,g=16;for(let _=0;_<m.length;_++){let C=m[_],S=Number(C.x)||0,M=Number(C.y)||0,O=Number(C.pressure)||(_===0||_===m.length-1?0:.5),B=u.elementFromPoint(S,M)||u.documentElement,z={bubbles:!0,cancelable:!0,clientX:S,clientY:M,screenX:S,screenY:M,view:h};if(_===0?(B.dispatchEvent(new p("pointerdown",{...z,pressure:O,pointerId:1,pointerType:"mouse"})),B.dispatchEvent(new d("mousedown",{...z,button:0,buttons:1}))):(B.dispatchEvent(new p("pointermove",{...z,pressure:O,pointerId:1,pointerType:"mouse"})),B.dispatchEvent(new d("mousemove",{...z,button:0,buttons:1}))),_===m.length-1&&(B.dispatchEvent(new p("pointerup",{...z,pressure:0,pointerId:1,pointerType:"mouse"})),B.dispatchEvent(new d("mouseup",{...z,button:0,buttons:0}))),_<m.length-1){let Q=Number(C.timestamp)||0,ge=Number(m[_+1].timestamp)||0,ee=Q&&ge?Math.max(0,Math.min(ge-Q,1e3)):g;ee>0&&await et(ee,u)}}return{success:!0,method:"dispatch_pointer_path",details:`Dispatched ${m.length} point(s)`}}function En(a,u,h){let m=G(a,u),p=Y(m,h),d=p.MouseEvent||MouseEvent;Pe(a,m,p),Z(a,m,p),Z(a,m,p);let g=a.getBoundingClientRect();return a.dispatchEvent(new d("dblclick",{bubbles:!0,cancelable:!0,clientX:g.left+g.width/2,clientY:g.top+g.height/2,detail:2,view:p})),{success:!0,method:"dblclick"}}function de(a,u,h){let m=G(a,u),p=Y(m,h),d=p.PointerEvent||PointerEvent,g=p.MouseEvent||MouseEvent;Pe(a,m,p);let _=a.getBoundingClientRect(),C=_.left+_.width/2,S=_.top+_.height/2,M={bubbles:!0,cancelable:!0,composed:!0,view:p,clientX:C,clientY:S,button:2,buttons:2};return a.dispatchEvent(new d("pointerdown",M)),a.dispatchEvent(new g("mousedown",M)),a.dispatchEvent(new d("pointerup",{...M,buttons:0})),a.dispatchEvent(new g("mouseup",{...M,buttons:0})),a.dispatchEvent(new g("contextmenu",M)),{success:!0,method:"contextmenu"}}function wn(a,u,h){let m=G(a,u),p=Y(m,h),d=a,g=a.getBoundingClientRect();return{href:String(p.location.href),hash:String(p.location.hash),ariaExpanded:a.getAttribute("aria-expanded"),ariaPressed:a.getAttribute("aria-pressed"),ariaDisabled:a.getAttribute("aria-disabled"),disabled:!!d.disabled,open:typeof d.open<"u"?d.open:void 0,checked:typeof d.checked<"u"?d.checked:void 0,value:typeof d.value<"u"?d.value:void 0,active:ho(m),rect:{w:g.width,h:g.height}}}function It(a,u){let h=Math.abs(a.rect.w-u.rect.w)>2||Math.abs(a.rect.h-u.rect.h)>2;return a.href!==u.href||a.hash!==u.hash||a.ariaExpanded!==u.ariaExpanded||a.ariaPressed!==u.ariaPressed||a.ariaDisabled!==u.ariaDisabled||a.disabled!==u.disabled||a.open!==u.open||a.checked!==u.checked||a.value!==u.value||a.active!==u.active||h}async function qe(a,u,h,m){await Promise.resolve();let p=G(a,u),d=Y(p,h);u.hidden||await wt();let g=wn(a,p,d);return It(m,g)}function St(a,u,h){a.focus?.({preventScroll:!0});let m=G(a,u),p=Y(m,h),_=a.getAttribute("role")==="button"||fi(a,p)||a.tagName.toLowerCase()==="button"?[" ","Enter"]:["Enter"],C=p.KeyboardEvent||KeyboardEvent;for(let S of _){let M={key:S,code:S===" "?"Space":"Enter",bubbles:!0,cancelable:!0,composed:!0};a.dispatchEvent(new C("keydown",M)),a.dispatchEvent(new C("keypress",M)),a.dispatchEvent(new C("keyup",M))}return{success:!0,method:"keyboard-activate"}}async function Ur(a,u,h,...m){let p=null;for(let d of m){let g=G(a,u),_=Y(g,h),C=wn(a,g,_),S=d();if(!S||!S.success)continue;if(await qe(a,g,_,C))return{...S,details:(S.details?S.details+";":"")+"verified=true"};p=S}return p?{...p,details:(p.details?p.details+";":"")+"verified=false"}:{success:!1,method:"all-strategies-unverified",details:"no verified effect",allowFallback:!0}}function ar(...a){for(let u of a)try{let h=u();if(h&&h.success)return h}catch{}return{success:!1,method:"all-strategies-failed",allowFallback:!0}}function Pe(a,u,h){let m=G(a,u),p=Y(m,h),d=a.getBoundingClientRect();d.top>=0&&d.left>=0&&d.bottom<=p.innerHeight&&d.right<=p.innerWidth||(a.scrollIntoView({behavior:"auto",block:"center",inline:"center"}),a.offsetHeight)}function cr(a,u,h,m){let p=G(a,u),g=Y(p,h).KeyboardEvent||KeyboardEvent;for(let _ of m){let C=String(_??""),S="";/^[a-z]$/i.test(C)?S=`Key${C.toUpperCase()}`:/^[0-9]$/.test(C)?S=`Digit${C}`:C===" "&&(S="Space");let M=C.length===1?C.charCodeAt(0):0,O={key:C,code:S,bubbles:!0,cancelable:!0,composed:!0,keyCode:M,which:M};a.dispatchEvent(new g("keydown",O)),a.dispatchEvent(new g("keypress",O)),a.dispatchEvent(new g("keyup",O))}}function lr(a,u,h){let m=G(a,u),d=Y(m,h).KeyboardEvent||KeyboardEvent,g={key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0,composed:!0},_=a.dispatchEvent(new d("keydown",g)),C=a.dispatchEvent(new d("keypress",g)),S=a.dispatchEvent(new d("keyup",g));if(!!(_&&C&&S)){let O=a.form||a.closest?.("form");O?.requestSubmit?.()??O?.submit?.()}}function Pr(a){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"}[a]||`Key${a.toUpperCase()}`}let Bn=new MessageChannel,Wn=[];Bn.port1.onmessage=()=>{let a=Wn.shift();a&&a()};function wt(){return new Promise(a=>{Wn.push(a),Bn.port2.postMessage(0)})}function Kt(a){let u=m=>{if(!m)return null;let p=Object.keys(m);for(let d of p)if(d.startsWith("__reactFiber")||d.startsWith("__reactInternalInstance")||d.includes("reactFiber")||d.includes("reactProps")||d.includes("reactEventHandlers")||/^__r\d+/.test(d))return m[d];return null},h=a;for(let m=0;m<4&&h;m++){let p=u(h);if(p)return p;h=h.parentElement}return null}function Wt(a){let u={},h=a,m=0;for(;h&&m++<10;){let p=[h.memoizedProps,h.pendingProps,h.stateNode?.props,h._memoizedProps,h._pendingProps,h.alternate?.memoizedProps].filter(Boolean);for(let d of p)if(!(!d||typeof d!="object"))for(let g in d)g.startsWith("on")&&typeof d[g]=="function"&&(u[g]=d[g]);if(Object.keys(u).length)break;h=h.return||h.alternate}return u}function ur(a,u){let h=a;for(;h;){if(h._reactRootContainer||h.__reactContainer||h.hasAttribute("data-reactroot")||h.hasAttribute("data-react-root")||["root","app","__next"].includes(h.id))return h;h=h.parentElement}return G(a,u).querySelector("#root,#app,#__next,[data-reactroot],[data-react-root]")}function Ot(a,u,h,m){let p=G(u,h),d=Y(p,m),g=d.MouseEvent||MouseEvent,_=u.getBoundingClientRect(),C=new g(a,{bubbles:!0,cancelable:!0,view:d,clientX:_.left+_.width/2,clientY:_.top+_.height/2});return{type:a,target:u,currentTarget:u,bubbles:!0,cancelable:!0,nativeEvent:C,isTrusted:!0,preventDefault(){C.preventDefault()},stopPropagation(){C.stopPropagation()}}}function yt(a){let u=a;if(u.__vue__)return u.__vue__;if(u.__vueParentComponent)return u.__vueParentComponent;if(u._vnode)return u._vnode;let h=a.parentElement;for(let m=0;m<3&&h;m++){let p=h;if(p.__vue__||p.__vueParentComponent||p._vnode)return p.__vue__||p.__vueParentComponent||p._vnode;h=h.parentElement}return null}function sn(a){let u={};if(a?.$listeners&&Object.assign(u,a.$listeners),a?._events)for(let h in a._events){let m=a._events[h];u[h]=Array.isArray(m)?m[0]:m}if(a?.props)for(let h in a.props)h.startsWith("on")&&typeof a.props[h]=="function"&&(u[h.substring(2).toLowerCase()]=a.props[h]);if(a?.vnode?.props)for(let h in a.vnode.props)h.startsWith("on")&&typeof a.vnode.props[h]=="function"&&(u[h.substring(2).toLowerCase()]=a.vnode.props[h]);return u}})();function Ma(){let e=window,t=e.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__";e[t]?.actions?.execute}async function La(e){let t=window,n=t.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",o=t[n]?.actions?.execute;if(typeof o!="function")throw new Error("Rover main-world action executor not initialized");return o(e)}function wo(e,t,n={}){let{rootNodes:r,semanticNodes:o}=Es(e,{includeFrameContents:n.includeFrames??!0,clearIframes:n.includeFrames??!0,frameContextLabel:n.frameContextLabel??null,signalProvider:t.signalProvider,disableDomAnnotations:n.disableDomAnnotations??!0}),s={};for(let i of Object.keys(o)){let c=Number(i);if(!Number.isFinite(c))continue;let f=Tr(c);f&&(s[c]=t.getFrameworkMetadata(f))}return{rootNodes:r,semanticNodes:o,elementMeta:s}}(()=>{let e="__rtrvr_scroll_detector",t="__RTRVR_SCROLL_API__",n="__RTRVR_INTERNAL__";if(window[e])return;class r{constructor(b=document,w=window){$(this,"doc");$(this,"win");$(this,"viewport");$(this,"lastDetectedPrimary",null);$(this,"detectionCache",new Map);$(this,"lastDetectionTime",0);$(this,"CACHE_TTL",5e3);this.doc=b,this.win=w,this.viewport={width:w.innerWidth,height:w.innerHeight},this.updateViewport()}getValidPrimary(){return this.lastDetectedPrimary&&!this.doc.contains(this.lastDetectedPrimary)&&(this.lastDetectedPrimary=null),this.lastDetectedPrimary}async handleCommand(b){switch(b.action){case"detectPrimary":{let w=this.detectPrimaryScrollable();if(!w)return null;let{target:I,isRoot:x}=this.getScrollContext(w.element),A=I.scrollHeight,D=$t(),P=x&&D?D.innerHeight:I.clientHeight,q=Math.max(0,A-P),F=I.scrollTop;return{selector:w.selector,score:w.score,type:w.type,metrics:{scrollTop:F,scrollHeight:A,clientHeight:P,isAtTop:F<=5,isAtBottom:F>=q-5}}}case"scrollTo":if(!b.direction)throw new Error("scrollTo requires direction");return this.scrollToDirection(b.direction,b.options);case"scrollBy":if(!b.direction)throw new Error("scrollBy requires direction");return this.scrollByAmount(b.direction,b.options);case"scrollElement":if(!b.selector)throw new Error("scrollElement requires selector");return this.scrollElementIntoView(b.selector,b.position,b.options);case"getMetrics":return this.getScrollMetrics();default:throw new Error(`Unknown command: ${b.action}`)}}updateViewport(){this.viewport={width:this.win.innerWidth,height:this.win.innerHeight}}async execute(b){return this.handleCommand(b)}detectPrimaryScrollable(){if(Date.now()-this.lastDetectionTime<this.CACHE_TTL&&this.detectionCache.size>0){let x=Array.from(this.detectionCache.values()).sort((A,D)=>D.score-A.score)[0];if(x)return this.lastDetectedPrimary=x.element,x}this.updateViewport();let b=this.collectScrollableCandidates();if(b.length===0){let x=this.doc.scrollingElement||this.doc.documentElement||this.doc.body;if(!x)return null;let A=this.buildFeatures(x),D=G(x,this.doc),P={element:x,selector:er(x,D),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 w=this.scoreCandidates(b);if(w.length===0)return null;this.detectionCache.clear();for(let x of w)this.detectionCache.set(x.selector,x);this.lastDetectionTime=Date.now();let I=w[0];return I&&(this.lastDetectedPrimary=I.element),I||null}collectAllElementsDeep(b,w=15e4){let I=[],x=[],A=b.body||b.documentElement;A&&x.push(A);let D=0,P=q=>{try{let F=this.win.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",U=this.win[F]?.shadow?.getRoot;if(typeof U=="function"){let X=U(q);if(X)return X}}catch{}try{return q.shadowRoot||null}catch{return null}};for(;x.length&&!(++D>w);){let q=x.pop();if(Tt(q)){let U=q.children;for(let X=U.length-1;X>=0;X--)x.push(U[X]);continue}let F=q,H=re(F);We(F,H)&&I.push(F);try{let U=P(F);U&&x.push(U)}catch{}for(let U=F.lastElementChild;U;U=U.previousElementSibling)x.push(U)}return I}collectScrollableCandidates(){let b=[],w=new WeakSet,I=[this.doc.scrollingElement,this.doc.documentElement,this.doc.body];for(let A of I){if(!A||w.has(A))continue;let D=this.isScrollable(A);(D.vertical||D.horizontal)&&(b.push(A),w.add(A))}let x=this.collectAllElementsDeep(this.doc);for(let A of Array.from(x)){if(w.has(A))continue;let D=A.getBoundingClientRect(),P=this.win.getComputedStyle(A);if(!this.isElementRendered(A,D,P)||!this.isScrollable(A).vertical)continue;let F=40,H=this.viewport.width*.15;if(D.height<F||D.width<H){let U=(A.className||"").toLowerCase().includes("scroll"),X=P.overflowY==="auto"||P.overflowY==="scroll"||P.overflow==="auto"||P.overflow==="scroll";if(!U&&!X)continue}b.push(A),w.add(A)}return b}isElementRendered(b,w,I){if(I.display==="none"||I.visibility==="hidden")return!1;let x=parseFloat(I.opacity||"1");return!(!Number.isNaN(x)&&x<.01||w.width<=1||w.height<=1)}isScrollable(b){let w=this.win.getComputedStyle(b),I=w.overflowY,x=w.overflowX,A=this.doc.scrollingElement,D=b===this.doc.documentElement||b===this.doc.body||!!A&&b===A,P=b.scrollHeight,q=b.clientHeight,F=b.scrollWidth,H=b.clientWidth;if(D){let ae=this.doc.documentElement,me=this.doc.body;P=Math.max(ae?ae.scrollHeight:0,me?me.scrollHeight:0),q=this.win.innerHeight}let U=P-q>8,X=F-H>8,Z=I==="auto"||I==="scroll"||I==="overlay",te=x==="auto"||x==="scroll"||x==="overlay";return{vertical:D?U:U&&Z,horizontal:D?X:X&&te,byOverflow:Z||te}}calculateVisibleIntersection(b){let w=Math.max(0,b.left),I=Math.max(0,b.top),x=Math.min(this.viewport.width,b.right),A=Math.min(this.viewport.height,b.bottom),D=Math.max(0,x-w),P=Math.max(0,A-I);return{width:D,height:P,area:D*P}}analyzeTextContent(b,w=2e3){let I=0,x=0,A=b.ownerDocument||this.doc,P=(A.defaultView||this.win).NodeFilter||NodeFilter,q=A.createTreeWalker(b,P.SHOW_ELEMENT|P.SHOW_TEXT,null),F=0,H=q.currentNode,U=[];for(;H&&F<w;){if(H.nodeType===Node.TEXT_NODE){let K=(H.textContent||"").replace(/\s+/g,"").length;if(K>0){I+=K;let se=H.parentElement;se&&se.closest("a")&&(x+=K)}}else H.nodeType===Node.ELEMENT_NODE&&U.push(H);F++,H=q.nextNode()}let X=U.length||1,Z=I/X,te=I>0?x/I:0;return{textChars:I,linkChars:x,textDensity:Z,linkDensity:te}}calculateRepetitionScore(b){let w=Array.from(b.children);if(w.length<3)return 0;let I=w.slice(0,50),x=new Map,A=new Map,D=new Map;for(let oe of I){let K=re(oe);if(!We(oe,K))continue;let se=oe.getBoundingClientRect();if(se.height<5||se.width<this.viewport.width*.1)continue;let ae=Math.round(se.height/10)*10,me=Math.round(se.width/10)*10;x.set(ae,(x.get(ae)||0)+1),A.set(me,(A.get(me)||0)+1);let ye=(oe.className||oe.tagName).toString();D.set(ye,(D.get(ye)||0)+1)}let P=I.length||1,q=Math.max(0,...x.values()),F=Math.max(0,...A.values()),H=Math.max(0,...D.values()),U=q/P,X=F/P,Z=H/P,te=.4*U+.3*X+.3*Z;return Math.min(1,Math.max(0,te))}calculateSemanticScore(b){let w=0,I=null,x=!1,A=(b.getAttribute("role")||"").toLowerCase(),D=b.tagName.toLowerCase(),P=(b.id||"").toLowerCase(),q=(b.className||"").toLowerCase(),F=`${A} ${D} ${P} ${q}`;return(D==="main"||A==="main")&&(w+=1.2,I="article"),D==="article"&&(w+=1,I=I||"article"),(A==="feed"||F.includes("feed"))&&(w+=1,I="feed"),(A==="log"||F.includes("chat")||F.includes("messages"))&&(w+=1,I="chat"),F.includes("content")&&(w+=.5),(F.includes("results")||F.includes("list"))&&(w+=.4),(F.includes("job")||F.includes("jobs"))&&(w+=.4),(D==="nav"||A==="navigation"||F.includes("sidebar"))&&(w-=1,x=!0),(D==="aside"||A==="complementary")&&(w-=.7,x=!0),(D==="footer"||A==="contentinfo"||F.includes("footer"))&&(w-=.8,x=!0),F.includes("header")&&(w-=.6),w=Math.max(-1,Math.min(1,w)),{semanticScore:w,typeHint:I,navLike:x}}detectScrollListeners(b){return[b.querySelector('[class*="infinite"]'),b.querySelector('[class*="load-more"]'),b.querySelector("[data-infinite]"),b.querySelector('[loading="lazy"]'),b.querySelector(".observer-target"),b.querySelector("[data-scroll]")].some(I=>I!==null)}buildFeatures(b){let w=b.getBoundingClientRect(),I=this.win.getComputedStyle(b),x=this.calculateVisibleIntersection(w),A=this.viewport.width*this.viewport.height||1,D=x.area/A,P=this.viewport.width>0?x.width/this.viewport.width:0,q=w.top+w.height/2,F=this.viewport.height/2||1,H=Math.min(1,Math.abs(q-F)/F),U=this.isScrollable(b),X=this.doc.scrollingElement,Z=b===this.doc.documentElement||b===this.doc.body||!!X&&b===X,te=b.scrollHeight,oe=b.clientHeight;if(Z){let Ge=this.doc.documentElement,Ue=this.doc.body;te=Math.max(Ge?Ge.scrollHeight:0,Ue?Ue.scrollHeight:0),oe=this.win.innerHeight}let K=Math.max(0,te-oe),se=K*x.width,ae=this.analyzeTextContent(b),me=this.calculateRepetitionScore(b),ye=this.calculateSemanticScore(b),Me=b.contains(this.doc.activeElement),pe=this.detectScrollListeners(b),Ie=parseInt(I.zIndex||"0",10),ot=Number.isFinite(Ie)?Ie:0;return{geometry:{viewportCoverage:D,widthProminence:P,centerDistance:H,scrollCapacity:K,scrollSurface:se,zIndex:ot},content:{textDensity:ae.textDensity,linkDensity:ae.linkDensity,repetitionScore:me,semanticScore:ye.semanticScore},interaction:{hasScrollListeners:pe,hasFocus:Me,recentActivity:Me?1:0}}}inferElementType(b,w,I,x){if(I)return I;let A=(b.getAttribute("role")||"").toLowerCase(),D=(b.className||"").toLowerCase(),P=b.tagName.toLowerCase(),q=w.geometry,F=w.content;if(A==="log"||D.includes("chat")||D.includes("messages"))return"chat";let H=this.win.getComputedStyle(b);if((H.position==="fixed"||H.position==="absolute")&&q.zIndex>100&&q.viewportCoverage>.2&&q.centerDistance<.4)return"modal";if(A==="feed"||F.repetitionScore>.3&&q.scrollCapacity>400&&q.widthProminence>=.25)return"feed";if(P==="article"||F.textDensity>40&&F.linkDensity<.4&&q.widthProminence>.4)return"article";if(x||q.widthProminence<.3&&F.linkDensity>.3)return"sidebar";let X=this.doc.scrollingElement;return b===this.doc.documentElement||b===this.doc.body||X&&b===X?"document":"unknown"}scoreCandidates(b){let w=[],I=[],x=[],A=[],D=[],P=[];for(let Z of b){let te=this.buildFeatures(Z),oe=te.content.semanticScore,K=this.calculateSemanticScore(Z),se=this.inferElementType(Z,te,K.typeHint,K.navLike);P.push({element:Z,features:{geometry:{...te.geometry},content:{...te.content,semanticScore:K.semanticScore},interaction:te.interaction},type:se,navLike:K.navLike,semanticScore:K.semanticScore}),I.push(te.geometry.scrollSurface),x.push(te.content.textDensity),A.push(Math.abs(K.semanticScore)),D.push(te.content.repetitionScore)}let q=Math.max(0,...I),F=Math.max(0,...x),H=Math.max(0,...A),U=Math.max(0,...D),X=-1/0;for(let Z of P){let{element:te,features:oe,type:K,navLike:se,semanticScore:ae}=Z,me=oe.geometry,ye=oe.content,Me=oe.interaction,pe=q>0?me.scrollSurface/q:0,Ie=F>0?ye.textDensity/F:0,ot=H>0?(ae/H+1)/2:.5,Ge=K==="feed"||ye.repetitionScore>.3&&me.scrollCapacity>400,Ue=ye.linkDensity>.5?(ye.linkDensity-.5)/.5:0,pt=Ge?0:Ue,ke=(Ge?1:.5)*ye.repetitionScore*Math.min(1,me.scrollCapacity/4e3),Ke={feed:.2,chat:.2,article:.08,modal:.08,document:.05,sidebar:-.12,unknown:0}[K]||0,Te=0;Te+=me.viewportCoverage*.18,Te+=me.widthProminence*.15,Te+=(1-me.centerDistance)*.07,Te+=pe*.22,Te+=ke*.18,Te+=Ie*.08,Te+=(U>0?ye.repetitionScore/U:0)*.05,Te+=ot*.07,Te-=pt*.05,Me.hasFocus&&(Te+=.05),Me.hasScrollListeners&&(Te+=.05),Te+=Ke,se&&(Te-=.05);let Et=Math.max(0,Math.min(1,Te));Et>X&&(X=Et),w.push({element:te,selector:er(te,G(te)),score:Et,features:oe,type:K})}if(w.sort((Z,te)=>te.score-Z.score),w.length>=2){let Z=w[0],te=w[1];Math.abs(Z.score-te.score)<.08&&Z.type==="article"&&te.type==="feed"&&(w[0]=te,w[1]=Z)}return w}getScrollContext(b){let w=document.scrollingElement;return b===document.documentElement||b===document.body||!!w&&b===w?{target:w||document.documentElement||document.body,isRoot:!0}:{target:b,isRoot:!1}}async scrollToDirection(b,w){let I=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!I)return{success:!1,error:"No scrollable element found"};let{target:x,isRoot:A}=this.getScrollContext(I),D=G(x),P=Y(D),q=w?.isTabActive??!D.hidden,F=w?.behavior,H=q&&F==="smooth",U=A?Math.max(D.documentElement?D.documentElement.scrollHeight:0,D.body?D.body.scrollHeight:0):x.scrollHeight,X=A?P.innerHeight:x.clientHeight,Z=Math.max(0,U-X),te=()=>A?P.scrollY:x.scrollTop,oe=K=>{if(H)try{A?P.scrollTo({top:K,behavior:"smooth"}):x.scrollTo({top:K,behavior:"smooth"})}catch{A?(D.scrollingElement||D.documentElement||D.body).scrollTop=K:x.scrollTop=K}else if(A){let se=D.scrollingElement||D.documentElement||D.body;se.scrollTop=K}else x.scrollTop=K};switch(b){case Ne.TOP:return oe(0),{success:!0,scrollTop:0,isAtTop:!0};case Ne.BOTTOM:return oe(Z),{success:!0,scrollTop:Z,isAtBottom:!0};default:return{success:!1,error:`Unknown direction: ${b}`}}}async scrollByAmount(b,w){let I=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!I)return{success:!1,error:"No scrollable element found"};let{target:x,isRoot:A}=this.getScrollContext(I),D=w?.isTabActive??!document.hidden,P=w?.behavior,q=D&&P==="smooth",F=$t(),H=A&&F?F.innerHeight:x.clientHeight,U=A&&F?F.innerWidth:x.clientWidth,X=w?.amount??H*.8,Z=A?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):x.scrollHeight,te=A&&F?F.innerHeight:x.clientHeight,oe=Math.max(0,Z-te),K=ae=>{if(q)try{A?F?.scrollTo({top:ae,behavior:"smooth"}):x.scrollTo({top:ae,behavior:"smooth"})}catch{let me=document.scrollingElement||document.documentElement||document.body;me.scrollTop=ae}else{let me=A?document.scrollingElement||document.documentElement||document.body:x;me.scrollTop=ae}},se=ae=>{if(q)try{x.scrollBy({left:ae,behavior:"smooth"})}catch{x.scrollLeft+=ae}else x.scrollLeft+=ae};switch(b){case Ne.DOWN:{let me=(A&&F?F.scrollY:x.scrollTop)+X;K(me);let ye=A&&F?F.scrollY:x.scrollTop;return{success:!0,scrollTop:ye,isAtTop:ye<=5,isAtBottom:ye>=oe-5}}case Ne.UP:{let ae=A&&F?F.scrollY:x.scrollTop,me=Math.max(0,ae-X);K(me);let ye=A&&F?F.scrollY:x.scrollTop;return{success:!0,scrollTop:ye,isAtTop:ye<=5,isAtBottom:ye>=oe-5}}case Ne.LEFT:{let ae=-(w?.amount??U*.8);return se(ae),{success:!0,scrollLeft:x.scrollLeft}}case Ne.RIGHT:{let ae=w?.amount??U*.8;return se(ae),{success:!0,scrollLeft:x.scrollLeft}}default:return{success:!1,error:`Unknown direction: ${b}`}}}normalizeScrollPosition(b){switch(b){case rt.START:return"start";case rt.END:return"end";case rt.NEAREST:return"nearest";case rt.CENTER:default:return"center"}}getScrollContainerForElement(b){let w=document.scrollingElement,I=b;for(;I&&I!==document.body&&I!==document.documentElement;){let D=getComputedStyle(I).overflowY,P=D==="auto"||D==="scroll"||D==="overlay",q=I.scrollHeight-I.clientHeight>8;if(P&&q)return{container:I,isRoot:!1};I=I.parentElement}return{container:w||document.documentElement||document.body,isRoot:!0}}scrollElementIntoView(b,w,I){let x=document.querySelector(b);if(!x)return{success:!1,error:`Element not found for selector: ${b}`};let{container:A,isRoot:D}=this.getScrollContainerForElement(x),P=re(A),q=P?.DOMRect||DOMRect,F=D?new q(0,0,P.innerWidth??0,P.innerHeight??0):A.getBoundingClientRect(),H=x.getBoundingClientRect(),U=24,X=H.top>=F.top+U&&H.bottom<=F.bottom-U,Z=I?.isTabActive??!document.hidden,te=I?.behavior,oe=Z&&te==="smooth",K=this.normalizeScrollPosition(w);if(w===rt.NEAREST&&X)return{success:!0,alreadyVisible:!0,...this.getScrollMetricsForContainer(A,D)};try{x.scrollIntoView({behavior:oe?"smooth":"auto",block:K,inline:"nearest"})}catch{x.scrollIntoView()}let se=this.getScrollMetricsForContainer(A,D);return{success:!0,position:K,...se}}getScrollMetricsForContainer(b,w){let I=w?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):b.scrollHeight,x=G(b),A=re(b),D=w&&A?A.innerHeight:b.clientHeight,P=Math.max(0,I-D),F=(w?x.scrollingElement||x.documentElement||x.body:b).scrollTop;return{scrollTop:F,scrollHeight:I,clientHeight:D,maxScroll:P,isAtTop:F<=5,isAtBottom:F>=P-5,scrollPercentage:P>0?F/P*100:0}}getScrollMetrics(){let b=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!b)return null;let{target:w,isRoot:I}=this.getScrollContext(b),x=G(w),A=Y(x),D=I?Math.max(x.documentElement?x.documentElement.scrollHeight:0,x.body?x.body.scrollHeight:0):w.scrollHeight,P=I?A.innerHeight:w.clientHeight,q=Math.max(0,D-P),H=(I?x.scrollingElement||x.documentElement||x.body:w).scrollTop;return{element:er(w,x),scrollTop:H,scrollHeight:D,clientHeight:P,maxScroll:q,isAtTop:H<=5,isAtBottom:H>=q-5,scrollPercentage:q>0?H/q*100:0}}}let o=new r;window[e]=o;let s={execute:v=>o.execute(v)};try{Object.defineProperty(window,t,{value:s,writable:!1,configurable:!1,enumerable:!1})}catch{try{window[t]=s}catch{}}let i=window.__RTRVR_INTERNAL_KEY__||n,c=window[i],f=c&&typeof c=="object"?c: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(i!==n)try{!window[n]&&f&&Object.defineProperty(window,n,{value:f,writable:!1,configurable:!1,enumerable:!1})}catch{}})();var lu=/\[id=(\d+)\]/,Ve;(function(e){e.HTML="html",e.PDF="pdf",e.GOOGLE_DOC="google_doc",e.GOOGLE_SHEET="google_sheet",e.PLAIN_TEXT="plain_text"})(Ve||(Ve={}));var Na=new Map;function uu(e){let t={};for(let n of Object.keys(e)){let r=e[Number(n)],o=r?.preservedAttributes?.[mt["rtrvr-label"]],s=r?.resourceLocator;if(typeof o=="string"&&typeof s=="string"){let i=o.match(lu);if(i?.[1]){let c=Number(i[1]);Number.isFinite(c)&&(t[c]=s)}}}return t}async function Ua(e,t,n={}){let r=e.ownerDocument||document,o=n.pageConfig||go,s=String(r.contentType||"").trim().toLowerCase(),i=pu(s,r),c=fu(i.documentType,s),f={url:r.URL,title:r.title,contentType:c},v=du(o);if(i.documentType!==Ve.HTML){let D=Number(o?.pageDataTimeoutMs),P=Number.isFinite(D)?Math.max(200,Math.floor(D)):9e3,q=Math.max(200,Math.min(P,Ct(v))),F=bu(r,i.documentType,o,v),H=await Zn(F,q,r);if(!H.ok)return{...f,content:"",error:`non_html_timeout:${c}`,metadata:{extractionMethod:"timeout"}};let U=H.value||{},X=i.documentType===Ve.GOOGLE_SHEET?Yu(r):void 0;return{...f,...U,contentType:U.contentType||f.contentType,sheetInfo:U.sheetInfo||X}}if(o?.onlyTextContent)return{...f,contentType:Qn,content:To(r)};let b=Math.max(0,Math.min(3e3,Ct(v))),w=performance.now(),I=!1;if(!o?.disableAutoScroll&&b>80){let D=r.hidden?900:1500,P=Math.min(D,b);P>80&&(I=await $u(r,{profile:"light",timeBudgetMs:P,delayMs:r.hidden?0:160,finalWaitMs:r.hidden?0:200}))}let x=Math.max(0,b-(performance.now()-w));x>80&&await qu(r,{mode:"full",totalBudgetMs:Math.min(r.hidden?1400:1200,x),budgetMs:Math.min(r.hidden?650:850,x),maxPasses:r.hidden?1:2});let A=wo(e,t,{includeFrames:n.includeFrames??!0,disableDomAnnotations:n.disableDomAnnotations??!0});return yu(A.rootNodes,A.semanticNodes)?{...f,contentType:Qn,content:To(r),metadata:{scrollingPerformed:I}}:{...f,contentType:Qn,roots:A.rootNodes,nodes:A.semanticNodes,elementLinkRecord:uu(A.semanticNodes),metadata:{scrollingPerformed:I}}}function du(e){let t=Number(e?.deadlineEpochMs);if(Number.isFinite(t)&&t>0)return t;let n=Number(e?.totalBudgetMs),r=Number.isFinite(n)?Math.max(1500,Math.floor(n)):9e3;return Date.now()+r}function fu(e,t){switch(e){case Ve.PDF:return vs;case Ve.GOOGLE_DOC:return xs;case Ve.GOOGLE_SHEET:return _s;case Ve.PLAIN_TEXT:return bo;case Ve.HTML:default:return t||Qn}}function pu(e,t){let n=e||String(t.contentType||"").toLowerCase();return xa(n)?{documentType:Ve.PDF}:hu(t)&&(gu(t)||mu(t.URL))?{documentType:Ve.PDF}:Su(t)?{documentType:Ve.GOOGLE_DOC}:Au(t)?{documentType:Ve.GOOGLE_SHEET}:n.includes(bo)?{documentType:Ve.PLAIN_TEXT}:{documentType:Ve.HTML}}function hu(e){try{let t=vu(e);return Rs(t)?!0:!!t.querySelector?.('object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]')}catch{return!1}}function mu(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 gu(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 bu(e,t,n,r){switch(t){case Ve.PDF:return Eu(e,n,r);case Ve.GOOGLE_DOC:return wu(e);case Ve.GOOGLE_SHEET:return Bu(e,n);case Ve.PLAIN_TEXT:return{content:To(e),contentType:bo};case Ve.HTML:default:return{content:To(e),contentType:Qn}}}async function Eu(e,t,n){Ct(n)>ys+50&&await Ra(ys,e,n);let o=(()=>{let b=Number(t?.pdfTextSelectionTimeoutMs),w=go.pdfTextSelectionTimeoutMs;return Number.isFinite(b)?Math.max(150,Math.floor(b)):w})(),s=Ct(n),c=Number.isFinite(s)?Math.max(150,Math.min(o,Math.max(0,s-150))):o,f=await Tu(e,c),v=!!f.success&&!!(f.data||"").trim();return{content:v&&f.data||"",contentType:vs,error:v?void 0:`pdf_extraction_failed:${f.reason||"unknown"}`}}async function wu(e){return{content:Pu(),contentType:xs}}function yu(e,t){return!Array.isArray(e)||e.length===0||!t||Object.keys(t).length===0}function To(e){return e.body?.innerText||e.body?.textContent||e.documentElement?.innerText||e.documentElement?.textContent||""}function vu(e){try{let t=e.defaultView||window,n=t.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",o=t[n]?.shadow?.getRoot;if(typeof o=="function"){let s=o(e.body||e.documentElement);if(s)return s}}catch{}return e}function _u(e){let t=e.URL||"";try{let n=new URL(t),r=n.searchParams.get("file")||n.searchParams.get("src")||"";return r||t}catch{return t}}async function Tu(e,t){let n=Number.isFinite(t)&&t>0?Math.floor(t):go.pdfTextSelectionTimeoutMs,r=_u(e),o=Na.get(r)??"";if(o.trim().length>0)return{success:!0,data:o,reason:"ok"};let s=await xu(e,n);return s.success&&s.data.trim()&&Na.set(r,s.data),s}async function xu(e,t){let n=e.defaultView||window,r=Ru(e);if(!r||typeof r.postMessage!="function")return{success:!1,data:"",reason:"no_viewer"};let o=globalThis.crypto&&"randomUUID"in globalThis.crypto?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`,s=!1,i="",c=b=>{if(s||!ku(String(b.origin||""),e))return;let w=b.data;Iu(w,o)&&typeof w.selectedText=="string"&&w.selectedText.trim().length>0&&(i=w.selectedText,s=!0)};n.addEventListener("message",c);try{r.postMessage({type:"selectAll",requestId:o},"*")}catch{}let f=Date.now();for(;!s&&Date.now()-f<t;){try{r.postMessage({type:"getSelectedText",requestId:o},"*")}catch{}if(await et(200,e),i.trim()){s=!0;break}}return n.removeEventListener("message",c),i.trim()?{success:!0,data:i,reason:"ok"}:{success:!1,data:"",reason:Date.now()-f>=t?"timeout":"no_response"}}function Ru(e){let t=Rs(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 ku(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 r=new URL(t.URL||"").origin.toLowerCase();if(r&&n===r)return!0}catch{}return!1}function Iu(e,t){return!(!e||typeof e!="object"||e.type!=="getSelectedTextReply"||typeof e.selectedText!="string"||e.requestId&&e.requestId!==t)}function Su(e){try{let t=e.defaultView||$t();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 tr(e)!==null}function Au(e){let n=(e.defaultView||$t())?.location.href??"";return/^https:\/\/docs\.google\.com\/spreadsheets\/(?:u\/\d+\/)?d\/[a-zA-Z0-9_-]+/.test(n)}function Cu(e){try{return e.defaultView?.top?.document??e}catch{return e}}function xo(e){let t=[e],n=Cu(e);return n!==e&&t.push(n),t}var Mu=".docs-texteventtarget-iframe",Lu=".kix-cursor",Nu=".docos-replyview-body",Du=".docos-replyview",Ou=".docos-author",Pa="\u200B",Fu="\xA0";function tr(e){for(let t of xo(e)){let n=t.querySelector(Mu);if(n)return n}return null}function Hu(e){for(let t of xo(e)){let n=t.querySelector(Lu);if(n)return n}return null}function yo(e){let t=Hu(e);return t?(t.ownerDocument?.defaultView?.getComputedStyle(t).display??t.style.display)==="none":!1}function vo(e,t){let n=tr(e);if(!n)return;let r=t?"ArrowUp":"ArrowDown",s={key:r,keyCode:t?38:40,altKey:!0,shiftKey:!0,code:r,bubbles:!0,cancelable:!0},i=n.contentDocument,c=n.contentWindow;if(!i)return;let f=c?.KeyboardEvent||KeyboardEvent;i.dispatchEvent(new f("keydown",s))}function Da(e){let t=tr(e);if(!t)return;let n={key:"ArrowLeft",keyCode:37,code:"ArrowLeft",bubbles:!0,cancelable:!0},r=t.contentDocument,o=t.contentWindow;if(!r)return;let s=o?.KeyboardEvent||KeyboardEvent;r.dispatchEvent(new s("keydown",n))}function Uu(e){let t=tr(e);if(!t)return;let r=(typeof navigator<"u"?String(navigator.platform||""):"").toUpperCase().indexOf("MAC")>=0,o={key:"a",code:"KeyA",ctrlKey:!r,metaKey:r,bubbles:!0,cancelable:!0},s=t.contentDocument,i=t.contentWindow;if(!s)return;let c=i?.KeyboardEvent||KeyboardEvent;s.dispatchEvent(new c("keydown",o))}function _o(e){let t=tr(e);if(!t)return"";let n=t.contentDocument,r=t.contentWindow,o=n?.body;if(!n||!o)return"";try{let c=r?.ClipboardEvent||ClipboardEvent,f=new c("copy",{bubbles:!0,cancelable:!0});o.firstChild?.dispatchEvent?.(f),o.firstChild?.dispatchEvent||o.dispatchEvent(f)}catch{}let s=o.innerText||o.textContent||"";return String(s).replace(new RegExp(Pa,"g"),"")??""}function Cs(e){let t=`
|
|
2
|
+
"use strict";var __roverSDK=(()=>{var Br=Object.defineProperty;var Ac=Object.getOwnPropertyDescriptor;var Cc=Object.getOwnPropertyNames;var Mc=Object.prototype.hasOwnProperty;var Lc=(e,t,n)=>t in e?Br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Nc=(e,t)=>{for(var n in t)Br(e,n,{get:t[n],enumerable:!0})},Dc=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Cc(t))!Mc.call(e,o)&&o!==n&&Br(e,o,{get:()=>t[o],enumerable:!(r=Ac(t,o))||r.enumerable});return e};var Oc=e=>Dc(Br({},"__esModule",{value:!0}),e);var $=(e,t,n)=>Lc(e,typeof t!="symbol"?t+"":t,n);var uf={};Nc(uf,{boot:()=>Dr,close:()=>Ko,endTask:()=>Qo,getState:()=>Zs,hide:()=>Qs,init:()=>zs,installGlobal:()=>Sc,newTask:()=>Hr,open:()=>Fr,registerTool:()=>ei,send:()=>Js,show:()=>Ks,shutdown:()=>js,update:()=>zo});var L;(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"})(L||(L={}));var ff=new Set(Object.values(L));var Fc=40;function ni(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(r=>Math.trunc(Number(r))))).filter(r=>Number.isFinite(r)&&r>0).slice(0,Fc)}var wt;(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"})(wt||(wt={}));var ri={[wt.Unknown]:"unknown",[wt.React]:"react",[wt.Vue]:"vue",[wt.Angular]:"angular",[wt.Svelte]:"svelte",[wt.JQuery]:"jquery"},Jo={react:wt.React,vue:wt.Vue,angular:wt.Angular,svelte:wt.Svelte,jquery:wt.JQuery},Ve;(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"})(Ve||(Ve={}));var mf={[Ve.Other]:"other",[Ve.Inline]:"inline",[Ve.Delegated]:"delegated",[Ve.React]:"react",[Ve.Vue]:"vue",[Ve.Angular]:"angular",[Ve.Svelte]:"svelte",[Ve.JQuery]:"jquery",[Ve.Native]:"native"},gf={inline:Ve.Inline,delegated:Ve.Delegated,react:Ve.React,vue:Ve.Vue,angular:Ve.Angular,svelte:Ve.Svelte,jquery:Ve.JQuery,other:Ve.Other,native:Ve.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 Wr={[L.click_element]:de.click_element,[L.type_into_element]:de.type_into_element,[L.type_and_enter]:de.type_and_enter,[L.select_dropdown_value]:de.select_dropdown_value,[L.clear_element]:de.clear_element,[L.focus_element]:de.focus_element,[L.hover_element]:de.hover_element,[L.right_click_element]:de.right_click_element,[L.double_click_element]:de.double_click_element,[L.long_press_element]:de.long_press_element,[L.drag_element]:de.drag_element,[L.drag_and_drop]:de.drag_and_drop,[L.swipe_element]:de.swipe_element,[L.adjust_slider]:de.adjust_slider,[L.describe_images]:de.describe_images,[L.scroll_to_element]:de.scroll_to_element,[L.paste_text]:de.paste_text,[L.check_field_validity]:de.check_field_validity,[L.select_text]:de.select_text,[L.mouse_wheel]:de.mouse_wheel,[L.copy_text]:de.copy_text,[L.upload_file]:de.upload_file,[L.go_back]:de.go_back,[L.go_forward]:de.go_forward,[L.refresh_page]:de.refresh_page,[L.press_key]:de.press_key,[L.scroll_page]:de.scroll_page,[L.wait_action]:de.wait_action,[L.wait_for_element]:de.wait_for_element,[L.pinch_zoom]:de.pinch_zoom,[L.goto_url]:de.goto_url,[L.google_search]:de.google_search,[L.open_new_tab]:de.open_new_tab,[L.switch_tab]:de.switch_tab,[L.close_tab]:de.close_tab,[L.solve_captcha]:de.solve_captcha,[L.answer_task]:de.answer_task,[L.dispatch_pointer_path]:de.dispatch_pointer_path,[L.network_run_recipe]:de.network_run_recipe},oi=Object.fromEntries(Object.entries(Wr).map(([e,t])=>[t,e]));function Vr(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 ii={semanticIdStart:1,interactiveIdStart:1,includeFrameContents:!0,clearIframes:!0,frameContextLabel:null,signalProvider:null,disableDomAnnotations:!1},ut={...ii},Gr=globalThis;function ai(e){ut={...ii,...e||{}}}function Rn(){return ut.signalProvider??null}function ze(){try{return typeof Gr.document<"u"?Gr.document:null}catch{return null}}function Yt(){try{return typeof Gr.window<"u"?Gr.window:null}catch{return null}}function G(e,t){if(e&&typeof e=="object"){let n=e.ownerDocument;if(n)return n;if(e.nodeType===9)return e}return t??ze()??{}}function re(e,t){return G(e,t?t.document:null)?.defaultView??t??Yt()??{}}function X(e,t){return e?.defaultView??t??Yt()??{}}function qr(e,t){try{return e?.getElementById?.(t)??null}catch{return null}}function Yr(e,t){try{return e?.querySelector?.(t)??null}catch{return null}}function Zo(e,t){try{return Array.from(e?.querySelectorAll?.(t)??[])}catch{return[]}}function kn(e){try{return e.contentDocument||(e.contentWindow?.document??null)}catch{return null}}function Xr(e,t){let n=e.CSS?.escape;return typeof n=="function"?n(t):t.replace(/([^\w-])/g,"\\$1")}function yt(e,t){try{return e[t]}catch{return}}function Xt(e,t){return!!e&&String(e.tagName||"").toUpperCase()===t.toUpperCase()}function ci(e,t){let n=yt(t,"HTMLAnchorElement");return n?e instanceof n:Xt(e,"A")}function kt(e,t){let n=yt(t,"HTMLInputElement");return n?e instanceof n:Xt(e,"INPUT")}function Ct(e,t){let n=yt(t,"HTMLTextAreaElement");return n?e instanceof n:Xt(e,"TEXTAREA")}function li(e,t){let n=yt(t,"HTMLLabelElement");return n?e instanceof n:Xt(e,"LABEL")}function ui(e,t){let n=yt(t,"HTMLSelectElement");return n?e instanceof n:Xt(e,"SELECT")}function di(e,t){let n=yt(t,"HTMLSlotElement");return n?e instanceof n:Xt(e,"SLOT")}function fi(e,t){let n=yt(t,"HTMLButtonElement");return n?e instanceof n:Xt(e,"BUTTON")}function pi(e,t){let n=yt(t,"HTMLImageElement");return n?e instanceof n:Xt(e,"IMG")}function hi(e,t){let n=yt(t,"HTMLVideoElement");return n?e instanceof n:Xt(e,"VIDEO")}function mi(e,t){let n=yt(t,"HTMLCanvasElement");return n?e instanceof n:Xt(e,"CANVAS")}function $e(e,t){if(!e||e.nodeType!==1)return!1;let n=yt(t,"HTMLElement");return n?e instanceof n:typeof e.tagName=="string"}function vt(e){return!!e&&e.nodeType===11&&typeof e.host=="object"&&typeof e.mode=="string"}function In(e){if(!e||e.nodeType!==1)return!1;let t=G(e),r=X(t).Element;return r?e instanceof r:typeof e.tagName=="string"}function dr(e){if(!e||e.nodeType!==1)return!1;let t=G(e),r=X(t).HTMLIFrameElement;return r&&e instanceof r?!0:String(e.tagName||"").toUpperCase()==="IFRAME"}function Hc(e,t){if(!e)return!1;if(e.nodeType===9)return!0;let n=yt(t,"Document");return n?e instanceof n:!1}function Uc(e,t){if(!e)return!1;let n=yt(t,"Window");if(n)return e instanceof n;try{return e.window===e}catch{return!1}}function zr(e){try{return e.document}catch{return null}}function jr(e,t){if(Hc(e,t))try{return e.documentElement}catch{return null}if(Uc(e,t)){let n=zr(e);if(!n)return null;try{return n.documentElement}catch{return null}}return null}function $r(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 si(e,t,n){try{let r=G(t,n);return new URL(e,r.baseURI).href}catch{return e}}function gi(e,t){let n=e.tagName.includes("-"),r=e.getAttribute("href")||e.getAttribute("src")||e.getAttribute("data")||e.getAttribute("action");if(r){let o=si(r,e,t);return o.trim().toLowerCase().startsWith("javascript:")?null:o}if(n)return null;try{let o=e,s=$r(o.href)||$r(o.src)||$r(o.data)||$r(o.action);return s?si(s,e,t):null}catch{return null}}var bi=["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"],we={};bi.forEach((e,t)=>{we[e]=t});var tn={};bi.forEach((e,t)=>{tn[t]=e});function Sn(e){if(!e)return null;let t=e.trim();if(!t||!t.includes("~"))return null;let n=[];for(let r of t.split(",")){if(!r)continue;let[o,s]=r.split("~"),i=Number(o);if(!Number.isFinite(i))continue;let c=s&&parseInt(s,36)||0;n.push({id:i,mask:c})}return n.length?{entries:n}:null}function Pc(e){let t=Sn(e);if(t){let n=new Set;for(let{id:r}of t.entries)n.add(r);return[...n]}return[]}function fr(e){return Xn(e).map(n=>tn[n]).filter(n=>!!n)}function Xn(e){let t=Rn();if(t?.getEventHandlerIds)try{let o=t.getEventHandlerIds(e);if(o&&o.length)return o}catch{}let n=e.getAttribute(dn),r=Pc(n);return!r||r.length===0?[]:r}var es=["media"],Ei=new Set(es),ts=["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 wi=new Set(ts),nn=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"]),pr=new Set(["group","region","section","banner","contentinfo","main","navigation","complementary","form","article","document","presentation","none"]);var yi=["none","presentation"],me;(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"})(me||(me={}));var vi={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"]},hr={heading:{selector:"h6,h1,h3,h2,h5,h4"},checkbox:{conditionalSelectors:[{selector:"input",conditions:[{type:me.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:me.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"grid"}]},{selector:"td",conditions:[{type:me.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"treegrid"}]},{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:me.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"treegrid"},{type:me.HAS_TABLE_COLUMN_DATA,hasData:!0},{type:me.HAS_TABLE_ROW_DATA,hasData:!0}]}]},slider:{conditionalSelectors:[{selector:"input",conditions:[{type:me.PROPERTY_VALUE_MATCH,property:"type",values:["range"]}]}]},listitem:{selector:"li"},contentinfo:{conditionalSelectors:[{selector:"footer",conditions:[{type:me.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:me.PROPERTY_VALUE_MATCH,property:"type",values:["submit","reset","image","button"]}]}]},status:{selector:"output"},form:{conditionalSelectors:[{selector:"form",conditions:[{type:me.HAS_ACCESSIBLE_NAME}]}]},article:{selector:"article"},textbox:{selector:"textarea",conditionalSelectors:[{selector:"input:not([list])",conditions:[{type:me.PROPERTY_VALUE_MATCH,property:"type",values:["url","text","tel","email"]}]}]},radio:{conditionalSelectors:[{selector:"input",conditions:[{type:me.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:me.HAS_TABLE_ROW_DATA,hasData:!1}]}]},list:{selector:"ul,ol,menu"},region:{conditionalSelectors:[{selector:"section",conditions:[{type:me.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:me.PROPERTY_VALUE_MATCH,property:"type",values:["search"]}]}]},cell:{conditionalSelectors:[{selector:"td",conditions:[{type:me.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"table"}]},{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:me.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"table"},{type:me.HAS_TABLE_COLUMN_DATA,hasData:!0},{type:me.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:me.HAS_TABLE_COLUMN_DATA,hasData:!1},{type:me.HAS_TABLE_ROW_DATA,hasData:!0}]}]},dialog:{selector:"dialog"},listbox:{selector:"select[multiple],datalist",conditionalSelectors:[{selector:"select",conditions:[{type:me.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:me.PROPERTY_VALUE_MATCH,property:"type",values:["number"]}]}]},math:{selector:"math"},combobox:{selector:"select:not([size]):not([multiple])",conditionalSelectors:[{selector:"select:not([multiple])",conditions:[{type:me.ATTRIBUTE_LESS_THAN,attribute:"size",value:2}]},{selector:"input[list]",conditions:[{type:me.PROPERTY_VALUE_MATCH,property:"type",values:["url","text","tel","search","email"]}]}]},banner:{conditionalSelectors:[{selector:"header",conditions:[{type:me.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"}},dn="rtrvr-ls",rn="rtrvr-ro",ns="rtrvr-mw-ready",mr="rtrvr-mw-busy",rs="rtrvr-mwa-ready",_i=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"]),Ti=["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"],xi=["h1","h2","h3","h4","h5","h6"],Ri="http://www.w3.org/1999/xhtml",ki="http://www.w3.org/2000/svg",ot="rtrvr-label";var Jr=new Set(["NOSCRIPT","SCRIPT","STYLE","META"]),An="CODE",Cn="PRE",Ii="aria-hidden",Si="target";var Kr;(function(e){e[e.value=0]="value",e[e.alt=1]="alt",e[e.list=2]="list",e[e.title=3]="title"})(Kr||(Kr={}));var zn;(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"})(zn||(zn={}));var Qr;(function(e){e[e.VALUENOW=0]="VALUENOW",e[e.VALUETEXT=1]="VALUETEXT"})(Qr||(Qr={}));var os=new Set([we.click,we.dblclick,we.doubleclick,we.contextmenu,we.auxclick,we.pointerdown,we.pointerup,we.mousedown,we.mouseup,we.touchstart,we.touchend,we.keydown,we.keyup,we.input,we.beforeinput,we.change,we.submit,we.reset,we.paste,we.dragstart,we.dragend,we.drop]),Ai=new Set([...os,we.scroll,we.wheel,we.mouseenter,we.mouseover,we.focus,we.blur,we.focusin,we.focusout]),Zr=new Set(["click","dblclick","auxclick","contextmenu","mousedown","mouseup","pointerdown","pointerup","touchstart","touchend"]),ss=new Set(["input","change","beforeinput","keydown","keyup","keypress","paste","compositionstart","compositionend"]),is=new Set(["drag","dragstart","dragend","dragenter","dragleave","dragover","drop"]);var gr;(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"})(gr||(gr={}));var br;(function(e){e[e.HTML=0]="HTML",e[e.SVG=1]="SVG"})(br||(br={}));var eo;(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"})(eo||(eo={}));var to;(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"})(to||(to={}));var gt;(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"})(gt||(gt={}));var tt;(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"})(tt||(tt={}));var on;(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"})(on||(on={}));var Bc=[...ts,...Object.keys(hr),...es],Ci=[...new Set(Bc)],jn={};Ci.forEach((e,t)=>{jn[e]=t});var Er={};Ci.forEach((e,t)=>{Er[t]=e});var no=class{constructor(t=1){$(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 wr(e){let t=Rn();if(t?.getRoleHint)try{let o=t.getRoleHint(e);if(o)return o}catch{}let n=e.getAttribute(rn);if(!n)return null;let r=n.trim();if(!r)return null;if(r.startsWith("s:"))return r.slice(2);if(/^\d+$/.test(r)){let o=Number(r);if(Number.isFinite(o)){let s=Er[o];if(s)return s}}return r}function Kn(e){return Array.from(new Set(e))}function Mi(e,t){if(!e||e.length===0)return Kn(t);let n=new Set([...e,...t]);return Kn(Array.from(n))}function _t(e,t){let r=Rn()?.getEventHandlerIds?.(e)??Xn(e),o=r.length>0&&r.some(c=>os.has(c)),s=ro(e),i=t?pr.has(t):!1;return{element:e,semanticRole:t,eventHandlerIndices:r,isEditableRegion:s,hasNodeWorthyHandlers:o,isLikelyStructuralContainer:i}}var Wc=new Set(["text","search","url","tel","password","email","number","date","datetime-local","time","month","week","color"]);function Vc(e){let n=re(e).getComputedStyle(e);if(n.display==="none"||n.visibility==="hidden"||n.pointerEvents==="none")return!1;let r=e.getBoundingClientRect();return!(r.width===0||r.height===0)}function $c(e){let t=re(e);if(!kt(e,t))return!1;let n=(e.type||"text").toLowerCase();return Wc.has(n)?!e.disabled&&!e.readOnly:!1}function Gc(e){let t=re(e);return Ct(e,t)&&!e.disabled&&!e.readOnly}function qc(e){let t=e;return!(!t.isContentEditable||t.getAttribute("aria-readonly")==="true"||t.getAttribute("aria-disabled")==="true")}function ro(e){return!e||!Vc(e)?!1:!!($c(e)||Gc(e)||qc(e))}function yr(e){if(!e)return null;let t=e.match(/^\s*\[id=(\d+)\]/);if(t?.[1]){let o=parseInt(t[1],10);return Number.isFinite(o)?o:null}let n=/\[id=(\d+)\]/g,r;for(;r=n.exec(e);){let o=r.index??0,s=e.slice(Math.max(0,o-30),o);if(/iframeRoot\s*=\s*$/.test(s)||s.includes("iframeRoot="))continue;let i=parseInt(r[1],10);if(Number.isFinite(i))return i}try{let o=e.match(LABEL_ID_PATTERN);if(o?.[1]){let s=parseInt(o[1],10);return Number.isFinite(s)?s:null}}catch{}return null}function vr(e){let t=String(e??"").replace(/[\n\r\t]/g," ").replace(/\s+/g," ").trim();return t=t.replace(/\[/g,"[").replace(/\]/g,"]"),t}function Li({element:e,elementID:t,frameContextLabel:n}){let r=!ut.disableDomAnnotations,o=[`[id=${t}]`],s=re(e);if(dr(e)){let d=vr(e.id||e.getAttribute("name")||"unnamed");o.push(`[iframe=${d}]`)}if(n){let d=vr(n);o.push(`[iframeRoot=${d}]`)}if(pi(e,s)&&o.push(`[size=${e.clientWidth}x${e.clientHeight}]`),(hi(e,s)||mi(e,s))&&o.push(`[size=${e.clientWidth}x${e.clientHeight}]`),kt(e,s)||Ct(e,s)){let d=Yc(e);o.push(...d)}e.getAttribute(Ii)==="true"&&o.push("[aria-hidden=true]"),e.disabled&&o.push("[disabled]"),r&&ci(e,s)&&e.setAttribute(Si,"_self");let c=o.join(" ");return r&&e.setAttribute(ot,c),c}function Yc(e){let t=[],n=re(e),r=kt(e,n);if(r&&e.type&&e.type!=="text"&&t.push(`[type=${e.type}]`),e.name){let o=vr(e.name);o&&t.push(`[name=${o}]`)}if(r&&e.multiple&&t.push("[multiple]"),r&&(e.type==="checkbox"||e.type==="radio")&&t.push(`[checked=${e.checked}]`),r&&e.type==="file"&&e.files?.length&&t.push(`[files=${e.files.length}]`),r&&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}]`)),r&&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}]`),r&&e.pattern&&t.push("[pattern]"),e.autocomplete&&e.autocomplete!=="off"&&t.push(`[autocomplete=${e.autocomplete}]`),e.placeholder){let o=vr(e.placeholder).replace(/\\/g,"\\\\").replace(/"/g,'\\"');o&&t.push(`[placeholder="${o}"]`)}if(e.value){let o=e.value;r&&e.type==="password"&&(o="*".repeat(Math.min(o.length,10)));let s=vr(o).replace(/\\/g,"\\\\").replace(/"/g,'\\"');t.push(`[value="${s}"]`)}return t}var _r=new no,as=new WeakMap;function Ni(){as=new WeakMap}function oo(e){let t=as.get(e);if(t)return t;let n=_r.generateId();return as.set(e,n),n}var so=new Map,cs=new WeakMap;function Di(){so.clear(),cs=new WeakMap}function ls(e,t){try{typeof WeakRef<"u"?so.set(e,new WeakRef(t)):so.set(e,t)}catch{}}function Tr(e){let t=so.get(e);if(!t)return null;let n=t instanceof WeakRef?t.deref():t;return!n||n.isConnected===!1?null:n}function fn(e){let t=null,n=oo(e);if(ut.frameContextLabel)t=ut.frameContextLabel;else{let o=ze();if(o&&e.ownerDocument!==o)try{let i=e.ownerDocument?.defaultView?.frameElement?.getAttribute(ot)||"",c=i?yr(i):null;t=c?String(c):null}catch{t=""}}let r=Li({element:e,elementID:n,frameContextLabel:t});if(ls(n,e),r)try{cs.set(e,r)}catch{}return r}function Oi(e){return cs.get(e)??null}function us(e,t){try{e.querySelectorAll?.(`[${ot}]`)?.forEach(r=>r.removeAttribute(ot))}catch{}if(t.includeShadow)try{let n=e.querySelectorAll?.("*");if(n)for(let r of Array.from(n))try{let o=r.shadowRoot;o&&us(o,t)}catch{}}catch{}if(t.includeIframes)try{let n=e.querySelectorAll?.("iframe");if(n)for(let r of Array.from(n))try{let o=kn(r);o?.body&&us(o.body,t)}catch{}}catch{}}function Fi(e,t={}){if(ut.disableDomAnnotations)return;let n=In(e)?re(e):X(e)??window,r=jr(e,n)??e;if(r){try{r.removeAttribute?.(ot)}catch{}us(r,{includeShadow:t.includeShadow??!0,includeIframes:t.includeIframes??!0})}}var pn={},ds=new WeakMap,io=new WeakSet;function Hi(){pn={},ds=new WeakMap,io=new WeakSet,Ni()}function st({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,originatedFromParent:i,elementContext:c}){let d=oo(e);ls(d,e);let _=pn[d];if(i){if(!_){let h={nodeCategory:e.nodeType,provisionalFromParent:!0},v=e.nodeName;v&&v.trim()&&(h.elementName=v);let I=e.getAttribute("role");I&&(h.preservedAttributes={1:I});let x=e.tagName;x&&(h.elementTag=x),pn[d]=h}}else{if(_&&!_.provisionalFromParent){if((o||Qn(e))&&(_.isFrameElement=!0,s&&s.length>0&&(_.frameContent=s)),c){let{eventHandlerIndices:h,isEditableRegion:v}=c;if(h&&h.length>0){let I=Kn(h);I.length>0&&(_.eventHandlers=Mi(_.eventHandlers,I))}v&&(_.isEditable=!0)}return d}if(io.has(e))return d;io.add(e);try{pn[d]=Ui({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,elementContext:c})}finally{io.delete(e)}}return d}function xr(e){let t=ds.get(e);if(t!==void 0)return t;let r=(e.textContent||"").replace(/\s+/g," ").trim(),o=e.data?.replace(/\s+/g," ").trim();if(!r&&!o)return 0;let s=_r.generateId(),i={textContent:r,nodeCategory:e.nodeType};return o&&o!==r&&(i.rawData=o),pn[s]=i,ds.set(e,s),s}function Bi(e,t){let n=Vi(e),{minY:r,maxY:o}=n.getCellBounds(t);return n.getRows().slice(r,o+1).some(s=>s.some(Rr))}function Wi(e,t){let n=Vi(e),{minX:r,maxX:o}=n.getCellBounds(t);return n.getRows().some(s=>s.slice(r,o+1).some(Rr))}var co=class{constructor(t=[]){$(this,"cells");$(this,"getCellAt",(t,n)=>this.getRowAt(n)[t]);$(this,"setCellAt",(t,n,r)=>{this.getRowAt(n)[t]=r});$(this,"getRowAt",t=>(this.cells[t]===void 0&&(this.cells[t]=[]),this.cells[t]));$(this,"getRows",()=>this.cells);$(this,"getCellBounds",t=>{let n=this.columnCount,r=this.rowCount,o=-1,s=-1;for(let i=0;i<this.rowCount;i++){let c=this.getRowAt(i),d=c.indexOf(t);d!==-1&&(o=Math.max(o,c.lastIndexOf(t)),s=Math.max(s,i),n=Math.min(n,d),r=Math.min(r,i))}return{minX:n,minY:r,maxX:o,maxY:s}});$(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 Vi(e){let n=re(e).TableGrid||co,r=new n;e.tHead!==null&&r.merge(ao(e.tHead.rows)),Array.from(e.tBodies).forEach(s=>{r.merge(ao(s.rows))});let o=[];for(let s of Array.from(e.children))fs(s)&&Mn(s,"tr")&&o.push(s);return r.merge(ao(o)),e.tFoot!==null&&r.merge(ao(e.tFoot.rows)),r}function ao(e){let t=new co,n=[];for(let r=0;r<e.length;r++){let o=0;for(let s of Array.from(e[r].cells)){for(;t.getCellAt(o,r)||n[o];)!Rr(t.getCellAt(o,r))&&n[o]&&t.setCellAt(o,r,n[o]),o++;for(let i=o;i<o+s.colSpan;i++){Pi(s)===0&&(n[i]=s,t.setCellAt(i,r,s));for(let c=r;c<r+Pi(s);c++)Rr(t.getCellAt(i,c))||t.setCellAt(i,c,s)}o+=s.colSpan}for(let s=o;s<t.columnCount;s++){let i=n[s];i!==void 0&&!Rr(t.getCellAt(s,r))&&t.setCellAt(s,r,i)}}return t}function Pi(e){let t=e.getAttribute("rowSpan");if(t===null||t.trim()==="")return 1;let n=Number(t);return isNaN(n)?1:n}function Rr(e){return e!==void 0&&Mn(e,"td")}function Mt(e){let t=e.tagName?.toLowerCase();if(t==="code"||t==="pre"){let r=tl(e);if(r)return r}let n=$i(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 o=e;switch(o.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 o.hasAttribute("list")?"combobox":"textbox"}}if(t==="select")return e.multiple?"listbox":"combobox";if(t==="svg"){if(e.getAttribute("aria-hidden")==="true")return null;let o=e.querySelector("title"),s=e.querySelector("desc"),i=e.hasAttribute("aria-label"),c=e.hasAttribute("role");return o||s||i||c||Xn(e).length>0||e.getAttribute("tabindex")!==null?"img":null}if(Xn(e).length>0){let o=e.tagName.toLowerCase();if(["div","span","li","p","i","em","strong","b"].includes(o))return Xc(e)}}if(t==="td"&&e.getAttribute("role")===null)return"cell";if(n!==null&&t==="th"){let r=e.getAttribute("role");if(r&&Gi(r))return r;let o=e;return o.scope==="col"||o.hasAttribute("aria-sort")?"columnheader":o.scope==="row"?"rowheader":"cell"}return n}function Xc(e){return wr(e)??null}function $i(e){let t=e.getAttribute("role");if(t!==null)return yi.includes(t)||!Gi(t)?null:t;let n=e.tagName.toLowerCase();return(vi[n]??[]).find(o=>zc(e,o))||null}function zc(e,t){let n=hr[t],r=n?.selector;if(r&&lo(e,r))return!0;let o=n?.conditionalSelectors;return o?o.some(i=>lo(e,i.selector)&&i.conditions.every(d=>Kc(e,d))):!1}function jc(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let r=e.getRootNode?.();if(vt(r)){let o=re(e),s=`#${Xr(o,n)}`,i=Yr(r,s);if(i)return i}}catch{}return qr(G(e),n)}function Kc(e,t){switch(t.type){case me.ATTRIBUTE_GREATER_THAN:{let n=e.getAttribute(t.attribute);return n!==null&&Number(n)>t.value}case me.ATTRIBUTE_LESS_THAN:{let n=e.getAttribute(t.attribute);return n!==null&&Number(n)<t.value}case me.HAS_ACCESSIBLE_NAME:return e.hasAttribute("aria-label")?!0:(e.getAttribute("aria-labelledby")||"").split(/\s+/).filter(Boolean).some(r=>jc(e,r)!=null);case me.FORBIDDEN_ANCESTORS:return sn(e,t.selector)===null;case me.BOOLEAN_PROPERTY:return e[t.property]===t.value;case me.PROPERTY_VALUE_MATCH:return t.values.some(n=>n===e[t.property]);case me.ANCESTOR_ROLE_REQUIRED:{let n=e.parentElement;if(n===null)return!1;let r=sn(n,t.tag);return r!==null&&$i(r)===t.role}case me.HAS_TABLE_COLUMN_DATA:{let n=sn(e,"table");return n===null?!1:t.hasData===Wi(n,e)}case me.HAS_TABLE_ROW_DATA:{let n=sn(e,"table");return n===null?!1:t.hasData===Bi(n,e)}default:return Qc(t),!1}}function Qc(e){throw new Error(`unexpected value ${e}!`)}function Gi(e){return Zc(e)||el(e)||Jc(e)}function Jc(e){return Ei.has(e)}function Zc(e){return wi.has(e)}function el(e){return hr.hasOwnProperty(e)}function tl(e){if(e.tagName!==An&&e.tagName!==Cn)return null;if(fr(e).some(r=>r==="click"||r==="copy"))return"button";let n=e.getAttribute("tabindex");return n!==null&&parseInt(n,10)>=0?"button":e.tagName===Cn||e.tagName===An&&e.closest("pre")?"code":null}var nl={[tt.display]:[tt.beforeDisplay,tt.afterDisplay],[tt.content]:[tt.beforeContent,tt.afterContent]},ps=new Map,rl={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 ol(e,t){if(!ps.has(e)){let n=rl[t]||t.replace(/([A-Z])/g,"-$1").toLowerCase();ps.set(e,n)}return ps.get(e)}var sl={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 Xi(e,t,n){let r=sl[e];return r?r(t,n):t.trim()!==""&&!["initial","inherit","unset"].includes(t)}function zi(e){let t={},n=re(e);if(!$e(e,n))return t;let r=n.getComputedStyle(e),o=new Map([[tt.beforeDisplay,n.getComputedStyle(e,"::before")],[tt.afterDisplay,n.getComputedStyle(e,"::after")],[tt.beforeContent,n.getComputedStyle(e,"::before")],[tt.afterContent,n.getComputedStyle(e,"::after")]]);for(let s in tt)if(isNaN(Number(s))){let i=tt[s],c=ol(i,s),d=nl[i];d?((i===tt.display||i===tt.content)&&qi(r,c,i,s,t,e),Yi(o.get(d[0]),c,d[0],"beforeContent",t),Yi(o.get(d[1]),c,d[1],"afterContent",t)):qi(r,c,i,s,t,e)}return t}function qi(e,t,n,r,o,s){if(e){let i=e.getPropertyValue(t);i&&Xi(r,i,s)&&(o[n]=i)}}function Yi(e,t,n,r,o){if(e){let s=e.getPropertyValue(t);(t==="content"&&s&&s!=="none"&&s!=='""'&&s!=="''"||s&&Xi(r,s))&&(o[n]=s)}}function Ln(e,t){let n=re(e);if(!$e(e,n))return!0;if(t&&nn.has(t))return!1;if(e.hasAttribute("hidden")||sn(e,"[hidden]")!==null||sn(e,"[inert]")!==null)return!0;let r=n.getComputedStyle(e);if(r.display==="none"||r.visibility==="hidden"||r.visibility==="collapse"||e.getClientRects().length===0)return!0;let o=e.getBoundingClientRect(),s=1e6;return Math.abs(o.left)>s||Math.abs(o.top)>s}function kr(e){return Lt(e)&&e.classList.contains("jasmine_html-reporter")}function il(e){let t=e.getAttribute("role");return t==="presentation"||t==="none"}function ji(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).map(t=>t.replace(/^#/,"")):[]}function Ki(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let o=e.getRootNode?.();if(vt(o)){let s=re(e),i=`#${Xr(s,n)}`,c=Yr(o,i);if(c)return c}}catch{}let r=G(e);return qr(r,n)}function hs(e){let n=[];for(let r=0;r<arguments.length;r++){let o=arguments[r];if(Array.isArray(o))for(let s=0;s<o.length;s+=8192){let i=al(o,s,s+8192),c=hs.apply(null,i);for(let d=0;d<c.length;d++)n.push(c[d])}else n.push(o)}return n}function al(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 cl(e,t).concat(ll(e))}function cl(e,t){return hs(gs(e).map(r=>oa(r)&&Lt(r)?Ji(r,t):r))}function Ji(e,t){if(!e||Ln(e,t))return[];if(!il(e))return[e];let n=Array.from(e.children);return hs(n.map(r=>Ji(r,t)))}function Zi(e){let t=ji(e.getAttribute("aria-owns"));if(!t.length)return[];let n=[],r=new Set;for(let o of t){if(r.has(o))continue;r.add(o);let s=Ki(e,o);s&&s!==e&&n.push(s)}return n}function ll(e){let t=Zi(e);for(let n of t)n["aria-owned-by"]=e;return t}function ea(e){let t=re(e),n=G(e);if(e.getAttribute("role")!=="dialog"&&e.getAttribute("role")!=="alertdialog"||e.getAttribute("aria-modal")!=="true")return!1;let r=t.getComputedStyle(e);if(r?.position!=="fixed"&&r?.position!=="absolute"||parseInt(r?.zIndex,10)<=pl(e))return!1;let o=ul(e);return!o||!fl(o)||!ml(e)||o.getAttribute("role")==="dialog"||e.getAttribute("role")==="dialog"?!1:hl(e)}function ul(e){return[e.previousElementSibling,e.nextElementSibling,...Array.from(e.children),...e.parentElement?[e.parentElement.previousElementSibling,e.parentElement.nextElementSibling]:[]].filter(n=>n!==null).find(dl)||null}function dl(e){if(Ln(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 fl(e){let t=re(e),n=e.getBoundingClientRect();return n.top<=0&&n.left<=0&&n.bottom>=t.innerHeight&&n.right>=t.innerWidth}function pl(e){let t=G(e),n=re(e),r=n?.getComputedStyle;if(!r)return 0;let o=Zo(t,"*").filter(s=>s!==e&&!Ln(s)).map(s=>parseInt(r.call(n,s)?.zIndex,10)).filter(s=>Number.isFinite(s)&&!isNaN(s));return o.length?Math.max(...o):0}function hl(e){return e.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])').length>0}function ml(e){let t=e.parentElement;if(!t)return!1;for(let n of Array.from(t.children))if(n!==e&&!Ln(n)&&n.getAttribute("aria-hidden")!=="true")return!1;return!0}function gl(){try{let t=ze()?.querySelector?.("dialog:modal");return'[aria-modal="true"], dialog:modal'}catch{return'[aria-modal="true"]'}}var ta=gl();function bl(e){return e.getAttribute("aria-disabled")==="true"||e.hasAttribute("disabled")}function ms(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=G(e),r=new URL(t,n.baseURI);return r.protocol==="javascript:"&&(r.pathname.trim()!==""||r.search.trim()!==""||r.hash.trim()!=="")}catch{return!1}}function na(e){return _i.has(e)}function El(e){let t=e.parentElement,n=G(e);if(!(!t||t===n.body||t===n.documentElement))return st({targetElement:t,originatedFromParent:!0})}function Ui({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,elementContext:i}){let c={nodeCategory:e.nodeType},d=t||bl(e),_=El(e);if(_&&(c.parent=_),n){let le=jn[n];typeof le=="number"?c.semanticRole=le:c.semanticRole=n}if(d&&(c.isDisabled=!0),i){let{eventHandlerIndices:le,isEditableRegion:ke}=i,We=Kn(le);We.length>0&&(c.eventHandlers=We),ke&&(c.isEditable=!0)}let h=yl(e);h&&Object.keys(h).length>0&&(c.ariaProperties=h);let v=vl(e);v&&Object.keys(v).length>0&&(c.ariaStates=v);let I=e.nodeName;I&&I.trim()&&(c.elementName=I);let x=zi(e);x&&Object.keys(x).length>0&&(c.computedStyles=x),Ln(e)&&(c.isInvisible=!0);let M=wl(e,n);M&&Object.keys(M).length>0&&(c.preservedAttributes=M),e.draggable&&(c.isDraggable=!0),e.scrollWidth&&e.clientWidth&&e.scrollWidth>e.clientWidth&&(c.supportsHorizontalSwipe=!0),e.scrollHeight&&e.clientHeight&&e.scrollHeight>e.clientHeight&&(c.supportsVerticalSwipe=!0);let D=e.getAttribute("class");if(D?.trim()){D.includes("handle")&&(c.isDragHandle=!0),c.supportsHorizontalSwipe||(D.includes("horizontal")||D.includes("carousel"))&&(c.supportsHorizontalSwipe=!0),c.supportsVerticalSwipe||(D.includes("vertical")||D.includes("feed"))&&(c.supportsVerticalSwipe=!0),D.includes("dismissible")&&(c.supportsDismissSwipe=!0),(D.includes("long-press")||D.includes("hold")||D.includes("press-hold"))&&(c.supportsLongPress=!0);let le=c.inputType||c.preservedAttributes?.[gt.type];le==="submit"||le==="reset"||le==="clear"||(D.includes("submit")&&(c.preservedAttributes={...c.preservedAttributes||{},[gt.type]:"submit"}),D.includes("clear")&&(c.preservedAttributes={...c.preservedAttributes||{},[gt.type]:"clear"}),D.includes("reset")&&(c.preservedAttributes={...c.preservedAttributes||{},[gt.type]:"reset"}))}let P=Il({element:e});P&&P.length>0&&(c.labelReferences=P);let q=e.tagName;if(q&&(c.elementTag=q),Tl(e)&&(c.hasFocus=!0),!o){let le=bs({element:e,semanticRole:n,parentDisabled:d,excludeLabels:r});le&&le.length>0&&(c.childElements=le)}let F=Dl({element:e});F&&F.length>0&&(c.ownedElements=F);let H=gi(e);H&&(c.resourceLocator=H),(o||Qn(e))&&(c.isFrameElement=!0),s&&s.length>0&&(c.frameContent=s);let U=e.type;U&&typeof U=="string"&&U.trim()&&(c.inputType=U);let z=e.placeholder;z&&typeof z=="string"&&z.trim()&&(c.placeholderText=z);let Z=e.value;Z&&typeof Z=="string"&&Z.trim()&&(c.elementValue=Z);let ne=Sl({element:e,parentDisabled:t,semanticRole:n});if(ne&&ne.length>0&&(c.selectedOptions=ne),sn(e,"select,datalist")&&(c.nearestSelectList=!0),fs(e))c.elementNamespace=br.HTML;else if(_l(e)){c.elementNamespace=br.SVG,c.svgStructure=xl(e);let le=Rl(e);le&&Object.keys(le).length>0&&(c.preservedAttributes?c.preservedAttributes={...c.preservedAttributes,...le}:c.preservedAttributes=le)}let Q=r?void 0:Al({element:e});Q&&Q.length>0&&(c.associatedLabels=Q);let ie=e.scope;ie&&typeof ie=="string"&&ie.trim()&&(c.tableScope=ie);let ce=Ml({element:e});ce&&(c.tableCaption=ce);let ge=Ll({element:e});ge&&(c.figureCaption=ge);let ve=Nl({element:e});return ve&&(c.fieldsetLegend=ve),sn(e,"table")&&(c.nearestTable=!0),c}function wl(e,t){let n={},r=new Set(Object.values(gt).filter(c=>typeof c=="string")),o=new Set(Object.keys(Kr).filter(c=>isNaN(Number(c)))),s=new Set(["_ngcontent","ng-reflect-*","data-v-*"]),i=e?.attributes?Array.from(e.attributes):[];for(let c of i){let d=c.name,_=c.value;if(d==="id"&&(!t||!nn.has(t)))continue;let h;if(r.has(d)?h=d:d.startsWith("data-v-")?h="data-v-*":d.startsWith("ng-reflect-")?h="ng-reflect-*":d.startsWith("_ngcontent")&&(h="_ngcontent"),h){let v=_.trim()!=="",I=o.has(h);if(v||I){let x=gt[h],M=s.has(h)?"true":_;n[x]=M}}}if(!n[gt[ot]]){let c=Oi(e);c&&(n[gt[ot]]=c)}return n}function yl(e){return ra(e,eo,Qr)}function vl(e){return ra(e,to,null)}function ra(e,t,n){let r={};for(let o in t)if(isNaN(Number(o))){let s=t[o],c=`aria-${o.toLowerCase().replace(/_/g,"-")}`,d=e.getAttribute(c),_=!1;n!==null&&(_=Object.values(n).filter(v=>typeof v=="number").includes(s)),e.hasAttribute(c)&&_||d?.trim()?r[s]=d:c==="aria-level"&&xi.includes(e.tagName.toLowerCase()?.trim())&&(r[s]=e.tagName.substring(1))}return r}function Lt(e){return oa(e)&&e.nodeType===gr.ELEMENT}function uo(e){return e.nodeType===gr.TEXT}function oa(e){let t=typeof e;return t=="object"&&e!=null||t=="function"}function fs(e){return Lt(e)&&(!e.namespaceURI||e.namespaceURI===Ri)}function _l(e){return Lt(e)&&e.namespaceURI===ki}function Qn(e){return e.tagName==="IFRAME"}function Mn(e,t){return"tagName"in e?e.tagName?.toLowerCase()===t:e.elementTag?.toLowerCase()===t}function sn(e,t){if(e.closest)return e.closest(t);for(;!lo(e,t);){if(e.parentElement===null)return null;e=e.parentElement}return e}function lo(e,t){return e.matches?.(t)??e.msMatchesSelector?.(t)??e.webkitMatchesSelector(t)}function Tl(e){let t=e.ownerDocument,n=t?.hasFocus()?t.activeElement:null;if(n){let r=n.getAttribute("aria-activedescendant");r&&(n=t.getElementById(r)||n)}return e===n}function xl(e){let t={},n=on.text,r=on.elText;e.textContent?.trim()&&(t[n]=e.textContent);let o=e.querySelector("title"),s=e.querySelector("img");o?.textContent?.trim()?t[r]=o.textContent:s?.alt?.trim()&&(t[r]=s.alt);let i=e.getAttribute("viewBox");i&&(t[on.viewBox]=i);let c=e.querySelectorAll("path");c.length>0&&(t[on.paths]=c.length,t[on.pathData]=Array.from(c).slice(0,3).map(_=>_.getAttribute("d")).filter(Boolean).map(_=>_.substring(0,100)));let d={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(d).forEach(([_,h])=>{if(h>0){let v=on[_];t[v]=h}}),Object.keys(t).length>0?t:void 0}function Rl(e){let t={};if(!e?.hasAttributes())return t;for(let n of Object.values(zn).filter(r=>typeof r=="number")){let r=zn[n];if(r){let o=r;if(zn.hasOwnProperty(o)&&e.hasAttribute(o)){let s=e.getAttribute(o);s?.trim()&&(t[n]=s)}}}return t}function kl({frameElement:e,parentDisabled:t,excludeLabels:n}){if(!ut.includeFrameContents)return[];let r=null;try{r=e.contentWindow?.document?.body||null}catch{return[]}if(!r)return[];let o=[];for(let s of gs(r))if(!(kr(s)||sa(s))){if(Lt(s)){let i=s,c=Mt(i),d=_t(i,c),{shouldCreate:_,shouldAnnotate:h}=fo(d);if(_){h&&fn(i);let v=st({targetElement:i,parentDisabled:t,semanticRole:c??void 0,excludeLabels:n,elementContext:d});v&&o.push(v)}else{let v=bs({element:i,semanticRole:c??void 0,parentDisabled:t,excludeLabels:n});o.push(...v)}}else if(uo(s)){let i=xr(s);i&&o.push(i)}}return o}function gs(e){let t=re(e);if(di(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||Rn()?.getShadowRoot?.(e)||null;if(n){let r=Array.from(n.childNodes),o=Array.from(e.childNodes).filter(s=>!s.assignedSlot);return r.concat(o)}}catch{}return Array.from(e.childNodes)}function bs({element:e,semanticRole:t,parentDisabled:n,excludeLabels:r}){let o=[];for(let s of gs(e))if(!(kr(s)||sa(s))){if(Lt(s)){let i=s,c=Mt(i),d=_t(i,c);if(Qn(i)){fn(i);let v=kl({frameElement:i,parentDisabled:n,excludeLabels:r}),I=st({targetElement:i,parentDisabled:n,semanticRole:c??void 0,excludeLabels:r,isFrameNode:!0,frameContentNodes:v,elementContext:d});I&&o.push(I);continue}let{shouldCreate:_,shouldAnnotate:h}=fo(d);if(_){h&&fn(i);let v=st({targetElement:i,parentDisabled:n,semanticRole:c??void 0,excludeLabels:r,elementContext:d});v&&o.push(v)}else{let v=bs({element:i,semanticRole:c??void 0,parentDisabled:n,excludeLabels:r});o.push(...v)}}else if(uo(s)){let i=xr(s);i&&o.push(i)}}return o}function Il({element:e}){let t=ji(e.getAttribute("aria-labelledby")),n=new Set;for(let r of t){let o=Ki(e,r);if(!(!o||o===e)&&o){let s=Mt(o),i=st({targetElement:o,semanticRole:s,elementContext:_t(o,s)});n.add(i)}}return Array.from(n)}function Sl({element:e,parentDisabled:t,semanticRole:n}){let r=[];return e&&(n&&n==="listbox"?r=Array.from(e.querySelectorAll('[role="option"][aria-selected="true"]')).map(o=>st({targetElement:o,parentDisabled:t,semanticRole:"option",elementContext:_t(o,"option")})):Mn(e,"select")&&(r=Array.from(e.selectedOptions).map(o=>st({targetElement:o,parentDisabled:t,semanticRole:"option",elementContext:_t(o,"option")})))),r}function Al({element:e}){if(Ti.includes(e.tagName)){let t=G(e),n=Zo(t,"label"),r=new Set;return Array.from(n).filter(o=>o!==e&&Cl(o,e)).map(o=>{let s=Mt(o),i=st({targetElement:o,semanticRole:s,excludeLabels:!0,elementContext:_t(o,s)});r.add(i)}),Array.from(r)}}function Cl(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 Ml({element:e}){if(Mn(e,"table")){let t=e.querySelector("caption");if(t&&t!==e){let n=Mt(t);return st({targetElement:t,semanticRole:n,elementContext:_t(t,n)})}}}function Ll({element:e}){if(Mn(e,"figure")){let t=e.querySelector("figcaption");if(t&&t!==e){let n=Mt(t);return st({targetElement:t,semanticRole:n,elementContext:_t(t,n)})}}}function Nl({element:e}){if(Mn(e,"fieldset")){let t=e.querySelector("legend");if(t&&t!==e){let n=Mt(t);return st({targetElement:t,semanticRole:n,elementContext:_t(t,n)})}}}function Dl({element:e}){let t=new Set,n=Zi(e);for(let r of n){let o=Mt(r),s=st({targetElement:r,semanticRole:o,elementContext:_t(r,o)});t.add(s)}return Array.from(t)}function fo(e){let{semanticRole:t,eventHandlerIndices:n,isEditableRegion:r,hasNodeWorthyHandlers:o,isLikelyStructuralContainer:s}=e,i=n.length>0&&n.some(v=>Ai.has(v)),d=!!t||!s&&(o||r),_=!!t&&nn.has(t);return{shouldCreate:d,shouldAnnotate:d&&(_||r||i)}}function sa(e){if(!Lt(e))return!1;let t=e,n=t.tagName;return Jr.has(n)?!0:n===An||n===Cn?Ol(t):!1}function Ol(e){let t=re(e),n=t?.getComputedStyle;if(!n||n.call(t,e).display==="none")return!0;let o=e.getBoundingClientRect();return o.width===0&&o.height===0&&!(typeof e.closest=="function"&&e.closest("pre"))||o.right<-1e3||o.left>t.innerWidth+1e3}function Es(e,t={}){return ai(t),Hi(),Di(),Fi(e,{includeShadow:!0,includeIframes:ut.clearIframes}),_r.initialize(ut.semanticIdStart),{rootNodes:ia(e),semanticNodes:pn}}function ia(e){let t=[];try{let n=G(e),o=Array.from(n.querySelectorAll(ta)).filter(s=>!Ln(s)&&ea(s));if(o.length===0)t=Jn({targetElement:e});else if(o.length===1){let s=o[0];s.contains(e)?t=Jn({targetElement:e}):e.contains(s)?t=Jn({targetElement:s}):t=Jn({targetElement:e})}else t=Jn({targetElement:e})}catch(n){throw console.error("Error constructing semantic tree",n),n}return t}function Jn({targetElement:e,parentNode:t}){if(kr(e)||aa(e))return[];let n=Mt(e),r=_t(e,n);if(Qn(e))return[Hl({frameElement:e,role:n,parentNode:t,elementContext:r})];let o=0,{shouldCreate:s,shouldAnnotate:i}=fo(r);s&&(i&&fn(e),o=st({targetElement:e,parentDisabled:t?.isDisabled,semanticRole:n,elementContext:r}));let c=pn[o],d=Fl(e,n,o?c:t);return o&&d.length>0&&(c.semanticChildren=d),o?[o]:d}function Fl(e,t,n){let r=[],o=Qi(e,t);for(let s of o)if(!(kr(s)||aa(s))){if(Lt(s)){let i=Jn({targetElement:s,parentNode:n});r.push(...i)}else if(uo(s)&&Pl(s,n)){let i=xr(s);i&&r.push(i)}}return r}function Hl({frameElement:e,role:t,parentNode:n,elementContext:r}){fn(e);let o=Ul(e);return st({targetElement:e,parentDisabled:n?.isDisabled,semanticRole:t,isFrameNode:!0,frameContentNodes:o,elementContext:r})}function Ul(e){if(!ut.includeFrameContents)return[];let n=kn(e)?.body??null;return n?ia(n):[]}function Pl(e,t){let n=e.data.trim();if(!n||n==="")return!1;if(t?.semanticRole!==void 0&&t?.semanticRole!==null){let r=typeof t.semanticRole=="number"?Er[t.semanticRole]:t.semanticRole;if(na(r))return!1}return!0}function aa(e){if(!Lt(e))return!1;let t=e,n=t.tagName;return Jr.has(n)?!0:n===An||n===Cn?Bl(t):!1}function Bl(e){let t=re(e);if(t.getComputedStyle(e).display==="none")return!0;let r=e.getBoundingClientRect();return r.width===0&&r.height===0&&!e.closest("pre")||r.right<-1e3||r.left>t.innerWidth+1e3}function ho(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t}function Wl(e){let t=e.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}function er(e,t,n){let r=G(e,t),o=X(r,n);try{e.focus?.({preventScroll:!0})}catch{}if(ho(r)===e)return!0;try{let{x:s,y:i}=Wl(e),c=o.PointerEvent||PointerEvent,d=o.MouseEvent||MouseEvent;e.dispatchEvent(new c("pointerdown",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:1,button:0,pointerType:"mouse"})),e.dispatchEvent(new d("mousedown",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:1,button:0})),e.dispatchEvent(new d("mouseup",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:0,button:0})),e.dispatchEvent(new c("pointerup",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:0,button:0,pointerType:"mouse"})),(e.isContentEditable||kt(e,o)||Ct(e,o)||e.getAttribute("contenteditable")==="true")&&e.dispatchEvent(new d("click",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,button:0}))}catch{}try{e.focus?.({preventScroll:!0})}catch{}return ho(r)===e}function Ir(e,t){let n=re(e),r=Ct(e,n)?n.HTMLTextAreaElement.prototype:n.HTMLInputElement.prototype,o=Object.getOwnPropertyDescriptor(r,"value");o?.set?o.set.call(e,t):e.value=t}function Dn(e,t,n="insertText"){let r=re(e),o=r.InputEvent||(typeof InputEvent<"u"?InputEvent:null),s=r.Event||Event;try{o?e.dispatchEvent(new o("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{o?e.dispatchEvent(new o("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 Vl(e){let n=re(e).KeyboardEvent||KeyboardEvent,r={key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0,composed:!0},o=e.dispatchEvent(new n("keydown",r)),s=e.dispatchEvent(new n("keypress",r)),i=e.dispatchEvent(new n("keyup",r));return{canceled:!(o&&s&&i)}}function Nn(e){if(!e)return!1;let t=re(e);if(Ct(e,t))return!e.disabled&&!e.readOnly;if(kt(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 ws(e){let t=re(e);if(!e||!$e(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 $l(e,t){let n=e.getRootNode();return vt(n)?n:G(e)??t}function Gl(e,t){let n=[];for(let r of t.split(/\s+/).filter(Boolean)){let o=e.getElementById?.(r)||e.querySelector?.(`#${CSS.escape(r)}`),s=re(o);$e(o,s)&&n.push(o)}return n}function da(e,t){if(!e)return{kind:"none",el:null,via:"no-root"};if(Nn(e))return{kind:"input",el:e,via:"self-input"};if(ws(e))return{kind:"contenteditable",el:e,via:"self-contenteditable"};let n=G(e)??t,r=X(n),o=$l(e,n);if(li(e,r)){let d=e.control;if(Nn(d))return{kind:"input",el:d,via:"label.control"};let _=e.htmlFor;if(_){let h=o.getElementById?.(_)||o.querySelector?.(`#${CSS.escape(_)}`);if(Nn(h))return{kind:"input",el:h,via:"label.for"}}}let s=e.getAttribute("aria-controls")||e.getAttribute("aria-owns");if(s)for(let d of Gl(o,s)){if(Nn(d))return{kind:"input",el:d,via:"aria-controls/owns"};if(ws(d))return{kind:"contenteditable",el:d,via:"aria-controls/owns"};let _=d.querySelector?.("input,textarea");if(Nn(_))return{kind:"input",el:_,via:"aria-controls->desc"}}let i=e.querySelector?.("input,textarea");if(Nn(i))return{kind:"input",el:i,via:"descendant"};let c=e.shadowRoot||null;if(c){let d=c.querySelector?.("input,textarea");if(Nn(d))return{kind:"input",el:d,via:"open-shadow-input"};let _=c.querySelector?.('[contenteditable="true"],[contenteditable=""],[role="textbox"]');if(ws(_))return{kind:"contenteditable",el:_,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 Zn(e,t,n,r=!1){let o=G(e,t),i=X(o,n).getSelection?.();if(!i)return!1;try{let c=o.createRange();return c.selectNodeContents(e),r&&c.collapse(!1),i.removeAllRanges(),i.addRange(c),!0}catch{return!1}}function On(e){return(e.textContent??"").replace(/\u00A0/g," ").trim()}var po=e=>String(e??"").replace(/\s+/g," ").trim(),fa=new MessageChannel,pa=[];fa.port1.onmessage=()=>{let e=pa.shift();e&&e()};function ca(){return new Promise(e=>{pa.push(e),fa.port2.postMessage(0)})}async function la(e,t,n){await Promise.resolve();let r=Math.max(0,Math.min(4,Number(n)||0));for(let o=0;o<r;o++)e.hidden?await ca():await new Promise(s=>{try{t.requestAnimationFrame(()=>s())}catch{ca().then(s)}})}function ql(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 ua(e,t,n,r){let o=G(e,t),i=X(o,n).KeyboardEvent||KeyboardEvent,c=String(r??"");for(let d of c){let{code:_,which:h}=ql(d),v={key:d,code:_,bubbles:!0,cancelable:!0,composed:!0,keyCode:h,which:h};e.dispatchEvent(new i("keydown",v)),e.dispatchEvent(new i("keypress",v)),e.dispatchEvent(new i("keyup",v))}}async function ha(e,t,n,r,o){let s=String(r??"");if(e.disabled||e.readOnly)return{success:!1,method:"type-native-setter",details:"disabled_or_readonly",allowFallback:!0};let i=String(e.value??""),c=G(e,t),d=X(c,n),_=er(e,c,d),h=Number.isFinite(Number(o?.settleFrames))?Math.max(0,Math.min(4,Number(o?.settleFrames))):c.hidden?1:2,v=!!o?.useKeyFallback,I=Number.isFinite(Number(o?.keyFallbackMaxLen))?Number(o?.keyFallbackMaxLen):140,x=v&&s.length>0&&s.length<=I;Ir(e,s),Dn(e,s,"insertReplacementText"),x&&ua(e,c,d,s),await la(c,d,h);let M=String(e.value??""),D=po(i),P=po(M),q=po(s),F=D===q,H=P===q,U=M!==i,z=s.length>0&&!F&&M===i,Z=1;if(!F&&!H&&!U){Z=2;try{e.focus?.({preventScroll:!0}),e.select?.()}catch{}let ce=!1;try{c.execCommand?.("selectAll",!1,void 0),ce=!!c.execCommand?.("insertText",!1,s)}catch{ce=!1}if(!ce)try{Ir(e,s)}catch{}try{Dn(e,s,"insertReplacementText")}catch{}x&&ua(e,c,d,s),await la(c,d,h),M=String(e.value??"")}let se=po(M)===q,Q=M!==i;z=s.length>0&&!F&&M===i;let ie=F||se||Q;return{success:ie,method:"type-native-setter",details:`focus=${_};attempts=${Z};settleFrames=${h};beforeLen=${i.length};afterLen=${M.length};changed=${Q};alreadyCorrect=${F};nowCorrect=${se};reverted=${z};keyFallback=${x}`,allowFallback:ie?void 0:!0}}function Yl(e,t,n){let o=re(e).InputEvent||InputEvent,s=new o("beforeinput",{bubbles:!0,cancelable:!0,composed:!0,data:t,inputType:n});return{ok:e.dispatchEvent(s),defaultPrevented:s.defaultPrevented}}function ma(e,t,n,r){let o=G(e,n),s=X(o,r),i=s.InputEvent||InputEvent,c=s.Event||Event,d=String(t??""),_=On(e),h=er(e,o,s),v=Zn(e,o,s,!0),I=Yl(e,d,"insertText"),x=!1,M="execCommand",D=!1,P=()=>{D=!0};try{e.addEventListener("input",P,{capture:!0})}catch{}if(I.ok&&!I.defaultPrevented)try{x=!!o.execCommand?.("insertText",!1,d)}catch{}if(!x)try{let H=s.getSelection?.(),U=H&&H.rangeCount?H.getRangeAt(0):null;if(!U||!e.contains(U.commonAncestorContainer)){Zn(e,o,s,!0);let z=s.getSelection?.();U=z&&z.rangeCount?z.getRangeAt(0):null}U&&(U.insertNode(o.createTextNode(d)),U.collapse(!1),H?.removeAllRanges(),H?.addRange(U),x=!0,M="range")}catch{}if(x&&!D){try{e.dispatchEvent(new i("input",{bubbles:!0,cancelable:!1,composed:!0,data:d,inputType:"insertText"}))}catch{try{e.dispatchEvent(new c("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{}}try{e.dispatchEvent(new c("change",{bubbles:!0,cancelable:!0,composed:!0}))}catch{}}try{e.removeEventListener("input",P,{capture:!0})}catch{}let q=On(e);return{success:q!==_||!!d&&q.includes(d),method:`type-contenteditable-${M}`,details:`focus=${h};selectedWithin=${v};inserted=${x}`}}function ga(e){let{canceled:t}=Vl(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 ba(e,t,n){if(e.disabled||e.readOnly)return{success:!1,method:"clear-native-setter",details:"disabled_or_readonly",allowFallback:!0};let r=G(e,t),o=X(r,n),s=String(e.value??""),i=er(e,r,o);Ir(e,""),Dn(e,"","deleteByCut");let c=String(e.value??""),d=c!==s;return{success:d||c.length===0,method:"clear-native-setter",details:`focus=${i};beforeLen=${s.length};afterLen=${c.length};changed=${d}`}}function Ea(e,t,n){let r=G(e,t),o=X(r,n),s=On(e),i=er(e,r,o),c=Zn(e,r,o,!1),d=!1,_="execCommand";try{d=!!r.execCommand?.("delete",!1,void 0)}catch{d=!1}if(!d)try{let x=o.getSelection?.(),M=x&&x.rangeCount?x.getRangeAt(0):null;(!M||!e.contains(M.commonAncestorContainer))&&Zn(e,r,o,!1);let D=o.getSelection?.(),P=D&&D.rangeCount?D.getRangeAt(0):null;P&&(P.deleteContents(),P.collapse(!1),D?.removeAllRanges(),D?.addRange(P),d=!0,_="range")}catch{}if(!d)try{e.textContent="",d=!0,_="textContent"}catch{}Dn(e,"","deleteByCut");let h=On(e),v=h!==s;return{success:d||v||h.length===0,method:`clear-contenteditable-${_}`,details:`focus=${i};selectedWithin=${c};cleared=${d};changed=${v}`}}function wa(e,t){if(e===t||e.contains(t))return!0;let n=t;for(;n;){let r=n.getRootNode?.();if(vt(r)){let o=r.host;if(o===e||e.contains(o))return!0;n=o;continue}n=n.parentNode||null}return!1}var mo;(function(e){e.FLASH_LITE="Gemini Flash Lite",e.FLASH="Gemini Flash",e.PRO="Gemini Pro"})(mo||(mo={}));var ya;(function(e){e[e.NativeHostConnected=0]="NativeHostConnected",e[e.NativeHostDisconnected=1]="NativeHostDisconnected"})(ya||(ya={}));var Xl=["image/png","image/jpeg","image/webp"],zl=["application/pdf","text/plain"],Kp=[...Xl,...zl];var nt;(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"})(nt||(nt={}));var Qe;(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"})(Qe||(Qe={}));var Qp={[nt.ACT]:Qe.AGENTIC_SEEK,[nt.CRAWL]:Qe.CRAWL_PAGES,[nt.EXTRACT]:Qe.EXTRACT_PAGE,[nt.SHEETS_WORKFLOW]:Qe.SHEETS_WORKFLOW,[nt.INFER_SHEET_DATA]:Qe.INFER_SHEET_DATA,[nt.PDF_FILLER]:Qe.PDF_FILLER,[nt.CUSTOM_TOOL_GENERATOR]:Qe.CUSTOM_TOOL_GENERATOR,[nt.WEBPAGE_GENERATOR]:Qe.WEBPAGE_GENERATOR,[nt.GOOGLE_DOC_GENERATOR]:Qe.GOOGLE_DOC_GENERATOR,[nt.GOOGLE_SLIDES_GENERATOR]:Qe.GOOGLE_SLIDES_GENERATOR,[nt.PROCESS_TEXT]:Qe.PROCESS_TEXT,[nt.CREATE_SHEET_FROM_DATA]:Qe.CREATE_SHEET_FROM_DATA,[nt.EXECUTE_MULTIPLE_TOOLS]:Qe.EXECUTE_MULTIPLE_TOOLS,[nt.CONFIGURE_API_KEY]:Qe.CONFIGURE_API_KEY,[nt.QUERY_RTRVR_AI_DOCUMENTATION]:Qe.QUERY_RTRVR_AI_DOCUMENTATION};var ys=200;var Jp=mo.FLASH;var Zp=Qe.PLANNER;var vs="application/pdf",_s="application/gsheet";var eh=20*1024*1024;var go={maxParallelTabs:4,pageLoadDelay:2e3,disableAutoScroll:!1,makeNewTabsActive:!1,writeRowProcessingTime:!1,totalBudgetMs:25e3,pageDataTimeoutMs:22e3,pdfTextSelectionTimeoutMs:12e3,onlyTextContent:!1};var jl=1,Kl=9,Ql=11,xs="application/gdoc",tr="text/html",bo="text/plain";function Jl(e){return!!e&&typeof e=="object"&&e.nodeType===Kl}function va(e){return!!e&&typeof e=="object"&&e.nodeType===jl}function Zl(e){return!!e&&typeof e=="object"&&e.nodeType===Ql&&typeof e.host=="object"&&typeof e.mode=="string"}function _a(e){return va(e)&&String(e.tagName).toUpperCase()==="IFRAME"}function Ts(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 eu(e){try{let t=e.shadowRoot;return t||globalThis?.chrome?.dom?.openOrClosedShadowRoot?.(e)||null}catch{return null}}function tu(e,t,n={}){let r=n.traverseShadow!==!1,o=n.traverseIframes!==!1,s=n.requireOwnerDocument,i=[e],c=new WeakSet;for(;i.length;){let d=i.pop();if(d&&typeof d=="object"){if(c.has(d))continue;c.add(d)}if(Jl(d)){let v=d.documentElement||d.body;v&&i.push(v);continue}if(Zl(d)){let v=d.children;if(v&&v.length)for(let I=v.length-1;I>=0;I--)i.push(v[I]);continue}if(!va(d))continue;let _=d;if(s&&_.ownerDocument!==s)continue;let h=_.getAttribute?.(ot);if(h&&yr(h)===t)return _;if(r)try{let v=eu(_);v&&i.push(v)}catch{}if(o&&_a(_))try{let v=kn(_);v&&i.push(v)}catch{}for(let v=_.lastElementChild;v;v=v.previousElementSibling)i.push(v)}return null}function Nt(e,t,n={}){let r=Ts(t);if(!r)return null;let o=Tr(r);return o&&(!n.requireOwnerDocument||o.ownerDocument===n.requireOwnerDocument)?o:tu(e,r,{requireOwnerDocument:n.requireOwnerDocument,traverseShadow:n.traverseShadow,traverseIframes:n.traverseIframes})}function Rs(e=document){return e.querySelector('embed[type="application/pdf"], embed[type="application/x-google-chrome-pdf"]')}function Ta(e){if(e==null)return[];if(Array.isArray(e)){let t=[];for(let n of e){let r=Ts(n);r&&t.push(r)}return t}if(typeof e=="number"||typeof e=="bigint"){let t=Ts(e);return t?[t]:[]}if(typeof e=="string"){let t=e.match(/\d+/g);return t?t.map(r=>parseInt(r,10)).filter(r=>Number.isFinite(r)&&r>0):[]}if(typeof e=="object"){let t=e.path??e.ids??e.iframe_path;if(t!==void 0)return Ta(t)}return[]}function nr(e,t){let n=Ta(t),r=e.defaultView||window;if(!n.length)return{doc:e,win:r,iframePath:n,resolvedPath:[],unresolvedPath:[]};let o=e,s=[];for(let i=0;i<n.length;i++){let c=n[i],d=n.length===1,_=Nt(o,c,{requireOwnerDocument:d?void 0:o,traverseShadow:!0,traverseIframes:d});if(!_||!_a(_))return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:n.slice(i)};let h=null;try{h=kn(_)||null}catch{h=null}if(!h)return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:n.slice(i)};s.push(c),o=h}return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:[]}}function xa(e){return e==="application/pdf"||e==="application/x-pdf"||e==="application/x-google-chrome-pdf"}function nu(){return Date.now()}function It(e){return!e||!Number.isFinite(e)?Number.POSITIVE_INFINITY:Math.max(0,e-nu())}async function Ra(e,t,n){if(!Number.isFinite(e)||e<=0)return;let r=It(n);r<=0||r<e+40||await Je(e,t)}async function rr(e,t,n){let r=Math.max(0,Math.floor(t));return r?await Promise.race([e.then(s=>({ok:!0,value:s})),(async()=>(await Je(r,n),{ok:!1,reason:"timeout"}))()]):{ok:!1,reason:"timeout"}}var Je=(()=>{let e=new MessageChannel,t=[];e.port1.onmessage=()=>{let r=t.shift();r&&r()};let n=()=>new Promise(r=>{t.push(r),e.port2.postMessage(0)});return async(r,o)=>{let s=Number(r);if(!Number.isFinite(s)||s<=0)return;if(!o.hidden){let c=o.defaultView||window,d=c.setTimeout?c.setTimeout.bind(c):setTimeout;await new Promise(_=>d(_,s));return}let i=Date.now();for(;Date.now()-i<s;)await n()}})();var ru=3e4;function ka(e){return(String(e??"").replace(/\\/g,"/").split("/").pop()||"upload").replace(/[\u0000-\u001f\u007f]/g,"").trim()||"upload"}var ks=class extends Error{constructor(n,r){super(n);$(this,"url");$(this,"status");$(this,"statusText");$(this,"bodySnippet");this.name="FetchFileError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.bodySnippet=r.bodySnippet}};function ou(e){return e&&e.split(";")[0].trim()||"application/octet-stream"}function su(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 Is(e,t){try{let r=(t??window).URL||URL,s=new r(e).pathname.match(/\/o\/(.+?)(\?|$)/);if(s?.[1]){let c=decodeURIComponent(s[1]).split("/");return c[c.length-1].replace(/^\d+-/,"")}}catch{}}function Ia(e){let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}async function iu(e,t={},n,r=fetch){let o=new AbortController,s=ru,i=!1,c=()=>{};if(n){let _=!1;c=()=>{_=!0},(async()=>{try{if(await Je(s,n),_)return;i=!0,o.abort()}catch{}})().catch(()=>{})}else{let _=setTimeout(()=>{i=!0,o.abort()},s);c=()=>clearTimeout(_)}let d=new Headers(t.headers);d.has("Accept")||d.set("Accept","*/*");try{let _=await r(e,{method:"GET",redirect:t.redirect??"follow",cache:t.cache??"no-store",mode:t.mode??"cors",credentials:t.credentials??"include",...t,headers:d,signal:o.signal});if(!_.ok){let x=await _.text().catch(()=>"");throw new ks(`Fetch failed (${_.status})`,{url:e,status:_.status,statusText:_.statusText,bodySnippet:x.slice(0,256)})}let h=await _.arrayBuffer(),v=ou(_.headers.get("content-type")),I=su(_.headers.get("content-disposition"))||Is(e);return{bytes:h,mimeType:v,fileName:I}}finally{c()}}async function Sa(e,t,n){return await iu(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 rt;(function(e){e.START="START",e.CENTER="CENTER",e.END="END",e.NEAREST="NEAREST"})(rt||(rt={}));function Ca(e){if(!e)return rt.CENTER;let t=typeof e=="string"?e.toUpperCase():String(e).toUpperCase();return rt&&t in rt?rt[t]:rt.CENTER}function Ss(e){return globalThis.CSS&&typeof globalThis.CSS.escape=="function"?globalThis.CSS.escape(e):e.replace(/([ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}function or(e,t){if(!e)return"";let n=G(e,t);if(e===n.documentElement)return"html";if(e===n.body)return"body";if(e.id)return`#${Ss(e.id)}`;let r=[],o=e;for(;o&&o!==n.body&&o!==n.documentElement;){let s=o.tagName.toLowerCase();if(o.id){s+=`#${Ss(o.id)}`,r.unshift(s);break}let c=(o.classList&&o.classList.length?Array.from(o.classList):(o.className||"").toString().split(/\s+/).filter(Boolean)).filter(d=>d&&d.length<=48).sort((d,_)=>d.length-_.length).slice(0,3).map(Ss);if(c.length)s+="."+c.join(".");else{let d=o.parentElement;if(d){let _=Array.from(d.children).filter(h=>h.tagName===o.tagName);if(_.length>1){let h=_.indexOf(o)+1;s+=`:nth-of-type(${h})`}}}r.unshift(s),o=o.parentElement}return r.join(" > ")}function Fn(e){return e.scrollingElement||e.documentElement||e.body}function Eo(e,t,n,r,o){let s=G(e,t),i=X(s,n),c=Fn(s),d=e===s.documentElement||e===s.body||e===c,_=d?c:e,h=d?i.innerHeight:_.clientHeight,v=d?i.innerWidth:_.clientWidth,I=o??h*.8;switch(r){case Fe.DOWN:{_.scrollTop+=I;break}case Fe.UP:{_.scrollTop=Math.max(0,_.scrollTop-I);break}case Fe.LEFT:return _.scrollLeft=Math.max(0,_.scrollLeft-(o??v*.8)),{success:!0,scrollLeft:_.scrollLeft};case Fe.RIGHT:return _.scrollLeft+=o??v*.8,{success:!0,scrollLeft:_.scrollLeft};default:return{success:!1,error:`Unsupported scroll direction: ${String(r)}`}}let x=_.scrollHeight,M=d?i.innerHeight:_.clientHeight,D=x-M;return{success:!0,scrollTop:_.scrollTop,isAtTop:_.scrollTop<=5,isAtBottom:_.scrollTop>=D-5}}function au(e,t,n){let r=G(e,t),o=X(r,n),s=Fn(r),i=e;for(;i&&i!==r.body&&i!==r.documentElement;){let d=o.getComputedStyle(i).overflowY;if((d==="auto"||d==="scroll"||d==="overlay")&&i.scrollHeight>i.clientHeight+5)return i;i=i.parentElement}return s}function Aa(e,t,n){let r=G(e,t),o=X(r,n),s=Fn(r),i=e===r.documentElement||e===r.body||e===s,c=i?s:e,d=c.scrollHeight,_=i?o.innerHeight:c.clientHeight,h=d-_;return c.scrollTop>=h-5}function As(e,t,n,r){let o=G(e,t),s=X(o,n),i=Fn(o),c=au(e,o,s),d=c===o.documentElement||c===o.body||c===i,_=d?i:c,h=e.getBoundingClientRect(),v=d?new(s.DOMRect||DOMRect)(0,0,s.innerWidth,s.innerHeight):c.getBoundingClientRect(),I=d?s.innerHeight:c.clientHeight,x=24,M=h.top-v.top,D=_.scrollTop+M,P;switch(r){case rt.START:P=D-x;break;case rt.END:P=D+h.height-I+x;break;case rt.NEAREST:{if(h.top>=v.top&&h.bottom<=v.bottom)return{success:!0,scrollTop:_.scrollTop,isAtTop:_.scrollTop<=5,isAtBottom:Aa(_,o,s)};h.top<v.top?P=D-x:P=D+h.height-I+x;break}case rt.CENTER:default:P=D-I/2+h.height/2;break}let q=_.scrollHeight-I;return _.scrollTop=Math.max(0,Math.min(P,q)),{success:!0,scrollTop:_.scrollTop,isAtTop:_.scrollTop<=5,isAtBottom:Aa(_,o,s)}}var cu=new Set([L.click_element,L.type_into_element,L.type_and_enter,L.hover_element,L.right_click_element,L.double_click_element,L.press_key,L.scroll_page,L.scroll_to_element,L.mouse_wheel,L.drag_element,L.drag_and_drop,L.swipe_element,L.long_press_element,L.adjust_slider,L.select_dropdown_value,L.clear_element,L.focus_element,L.check_field_validity,L.select_text,L.copy_text,L.paste_text,L.pinch_zoom,L.upload_file,L.dispatch_pointer_path]);(()=>{let e="__RTRVR_ACTION_EXECUTOR__";if(window[e])return;window[e]=!0;try{document.documentElement?.setAttribute(rs,"1")}catch{}let n="__RTRVR_INTERNAL__";try{window.__RTRVR_INTERNAL_KEY__=window.__RTRVR_INTERNAL_KEY__||n}catch{}let r=window.__RTRVR_INTERNAL_KEY__||n,o=window[r],s=o&&typeof o=="object"?o:{};if(!o)try{Object.defineProperty(window,r,{value:s,writable:!1,configurable:!1,enumerable:!1})}catch{window[r]=s}async function i(a){let E={};try{let m=oi[a.opcode];if(!m)throw new Error(`Unknown tool opcode: ${a.opcode}`);let g={...a.call,name:m};E=(await D({tabIndex:a.tabIndex,call:g,elementData:M(a.elementData),payload:a.payload}))[0]?.response??{success:!1,error:"Empty tool response",allowFallback:!0}}catch(m){E={success:!1,error:m?.message||String(m),allowFallback:!0}}return E}try{Object.defineProperty(s,"actions",{value:Object.freeze({execute:i}),writable:!1,configurable:!1,enumerable:!1})}catch{}let c="__RTRVR_UPLOAD_BYTES_REQ__",d="__RTRVR_UPLOAD_BYTES_RES__",_="__RTRVR_UPLOAD_BYTES_BRIDGE__",h="__RTRVR_WINDOW_MESSAGE_MUX__";function v(a){let E=a,m=E[h];if(!m||typeof m!="object"){m={handlers:new Set,installed:!1};try{Object.defineProperty(E,h,{value:m,enumerable:!1,configurable:!1})}catch{E[h]=m}}if(!m.installed){m.installed=!0,a.addEventListener("message",g=>{if(g.source===a)for(let p of Array.from(m.handlers))try{p(g)}catch{}},!0);try{a.addEventListener("pagehide",()=>{let p=a[_]?.pending;if(p)for(let[l,f]of p){try{f.cancelTimeout()}catch{}f.reject(new Error("pagehide: upload bytes request canceled")),p.delete(l)}},!0)}catch{}}return m}function I(a){let E=a,m=E[_];if(!m||typeof m!="object"){m={pending:new Map};try{Object.defineProperty(E,_,{value:m,enumerable:!1,configurable:!1})}catch{E[_]=m}v(a).handlers.add(p=>{let l=p?.data;if(!l||typeof l!="object"||l.type!==d)return;let f=String(l.requestId||"");if(!f)return;let b=m.pending.get(f);if(!b)return;m.pending.delete(f);try{b.cancelTimeout()}catch{}if(!l.ok){b.reject(new Error(l.error||"Failed to get bytes"));return}let S=l.bytes;if(!(S instanceof ArrayBuffer)){b.reject(new Error("Invalid bytes payload (expected ArrayBuffer)"));return}if(typeof b.expectedByteLength=="number"&&S.byteLength!==b.expectedByteLength){b.reject(new Error(`Byte length mismatch: got=${S.byteLength}, expected=${b.expectedByteLength}`));return}b.resolve(S)})}return m}function x(a,E,m,g=9e4){let p=a.__ROVER_UPLOAD_BYTES__||a.rover?.uploadBytes||a.rtrvr?.uploadBytes;if(typeof p=="function")return Promise.resolve().then(()=>p({token:E,byteLength:m,timeoutMs:g})).then(A=>{if(A instanceof ArrayBuffer)return A;if(A&&A.buffer instanceof ArrayBuffer)return A.buffer;throw new Error("Upload bytes provider returned invalid buffer")});let l=I(a),f=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(16).slice(2)}`,b=Math.max(1e3,Math.min(Number(g)||9e4,18e4)),S=zr(a)||document;return new Promise((A,C)=>{let O=!1,W=!1,Y=()=>{W=!0};(async()=>{await Je(b,S),!(W||O)&&(l.pending.delete(f),O=!0,C(new Error("Timed out waiting for upload bytes")))})().catch(()=>{}),l.pending.set(f,{cancelTimeout:Y,expectedByteLength:m,resolve:K=>{O||(O=!0,Y(),A(K))},reject:K=>{O||(O=!0,Y(),C(K))}}),a.postMessage({type:c,requestId:f,token:E,byteLength:m},"*")})}function M(a){if(a)return{frameworks:a.frameworks?a.frameworks.map(E=>ri[E]).filter(E=>E&&E!=="unknown"):[],listenersRaw:a.listenersRaw??"",role:a.role??void 0,pattern:a.pattern??void 0,value:a.value??void 0}}async function D({tabIndex:a,call:E,elementData:m,payload:g}){let p=(()=>{try{return Yt()?.top?.document||document}catch{return document}})(),l=E.args,f,b,S;try{({doc:f,win:b,unresolvedPath:S}=nr(p,l.iframe_id))}catch{if(l.iframe_id!=null)return[{name:E.name,args:E.args,response:{success:!1,error:`Cannot access iframe ${l.iframe_id} (cross-origin or not found)`}}];f=document,b=X(f)}let A=E.name,C=l.element_id?Nt(f,l.element_id):null,O=C?.ownerDocument??null,W;if(!cu.has(A))W={success:!1,error:`Tool not promotable to main: ${A}`,allowFallback:!0};else{let Y=O??f,K=X(Y,b);W=await q(A,C,l,m,Y,K,g)}return[{name:E.name,args:E.args,response:W}]}async function P(a,E,m){try{let g=a.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",l=a[g]?.scroll?.execute;if(typeof l!="function")throw new Error("main-world scroll detector not available");let f=m?.doc||zr(a)||document,b=Math.max(250,Math.min(Number(m?.timeoutMs??3500),8e3)),S=await rr(Promise.resolve().then(()=>l(E)),b,f);if(!S.ok)throw new Error("scroll detector timeout");return S.value}catch(g){throw new Error(g?.message||"main-world scroll detector not available")}}async function q(a,E,m,g,p,l,f){let b=W=>({success:W.success,error:W.success?void 0:W.details||"Action failed",allowFallback:W.success?void 0:W.allowFallback??!0}),S=a===L.press_key||a===L.scroll_page||a===L.drag_and_drop||a===L.pinch_zoom;if(!E&&!S)return b({success:!1,method:"missing-element-race",details:"Target element missing",allowFallback:!0});let A=new Set([L.type_into_element,L.type_and_enter,L.clear_element,L.focus_element,L.select_text,L.check_field_validity]),C=E,O=G(C,p);if(C&&A.has(a)){let W=da(C,O);(W.kind==="input"||W.kind==="contenteditable")&&(C=W.el)}try{switch(a){case L.click_element:return b(z(E,p,l,g));case L.double_click_element:return b(wn(E,p,l));case L.right_click_element:return b(ue(E,p,l));case L.hover_element:return b(await Be(E,p,l,g,m.duration));case L.type_into_element:return b(await qe(C,p,l,m.text,g));case L.type_and_enter:return b(await ct(C,p,l,m.text,g));case L.clear_element:return b(await De(C,p,l,g));case L.focus_element:return b(pt(C,p,l));case L.select_dropdown_value:return b(ye(E,p,l,m.value,g));case L.adjust_slider:return b(ht(E,p,l,g?.value??m.value,g));case L.check_field_validity:return b(jt(C,p,l));case L.select_text:return b(En(C,p,l,m.start_offset,m.end_offset));case L.scroll_page:return b(await cn(E,p,l,m));case L.scroll_to_element:return b(await Ue(E,p,l,m));case L.mouse_wheel:return b(mt(E,p,l,m.delta_x,m.delta_y));case L.drag_element:return b(await ln(E,p,l,m,g));case L.drag_and_drop:return b(await Ht(m,E,p,l));case L.swipe_element:return b(await Ut(E,p,l,m));case L.long_press_element:return b(await $n(E,p,l,m.duration));case L.pinch_zoom:return b(await Oe(E,p,l,m));case L.press_key:return b(Kt(m.key,m.modifiers,E,p,l));case L.copy_text:return b(await Qt(E,p,l));case L.paste_text:return b(await Et(E,p,l,g));case L.upload_file:return b(await Bt(m,p,l,f,E,g));case L.dispatch_pointer_path:return b(await Wt(m,p,l));default:return b({success:!1,method:"unhandled",details:`Unhandled ${a}`,allowFallback:!0})}}catch(W){return b({success:!1,method:"exception",details:W?.message||"exception",allowFallback:!0})}}function F(a){let E=new Map;if(!a)return E;let m=a.trim();if(!m)return E;let g=Sn(m);if(g){for(let{id:p,mask:l}of g.entries){let f=tn[p];if(!f)continue;let b=new Set(Vr(l)),S=E.get(f);if(S)for(let A of b)S.add(A);else E.set(f,b)}return E}return E}function H(a,...E){return a?E.some(m=>a.has(m)):!1}function U(a,E){let m=F(E?.listenersRaw),g=new Set;for(let[,A]of m)for(let C of A)(C==="react"||C==="vue"||C==="angular"||C==="svelte"||C==="jquery")&&g.add(C);let p=new Set;for(let[A,C]of m)if(["click","input","change","keydown","keyup","pointerdown","pointerup","mousedown","mouseup","submit","dragstart","drop","wheel","scroll"].includes(A))for(let O of C)p.add(O);let l=g.size>0||[...p].some(A=>["react","vue","angular","svelte","jquery"].includes(A)),f=H(m.get("click"),"delegated"),b=H(m.get("input"),"delegated")||H(m.get("change"),"delegated")||H(m.get("keydown"),"delegated"),S=E?.role||wr(a)||a.getAttribute("role");return{sourcesByType:m,fws:g,isFrameworkElement:l,delegatedClick:f,delegatedInput:b,role:S}}function z(a,E,m,g){let p=U(a,g),l=G(a,E),f=X(l,m);Se(a,l,f),g?.pattern==="hover-activate"&&Be(a,l,f,g,120);let b=p.fws.has("react")||H(p.sourcesByType.get("click"),"react"),S=p.fws.has("vue")||H(p.sourcesByType.get("click"),"vue"),A=p.fws.has("angular")||H(p.sourcesByType.get("click"),"angular"),C=p.fws.has("svelte")||H(p.sourcesByType.get("click"),"svelte"),O=p.fws.has("jquery")||H(p.sourcesByType.get("click"),"jquery");return vn(()=>Z(a,l,f),()=>ne(a,l,f),()=>b?Q(a,l,f):null,()=>S?ie(a,l,f):null,()=>A?ce(a,l,f):null,()=>C?ge(a,l,f):null,()=>O?ve(a,l,f):null)}function Z(a,E,m){let g=G(a,E),p=X(g,m),l=p.PointerEvent||PointerEvent,f=p.MouseEvent||MouseEvent,{x:b,y:S}=se(a,g,p),A={bubbles:!0,cancelable:!0,composed:!0,view:p,clientX:b,clientY:S,button:0,buttons:1};return a.focus?.({preventScroll:!0}),[new l("pointerover",A),new l("pointerenter",{...A,bubbles:!1}),new f("mouseover",A),new f("mouseenter",{...A,bubbles:!1}),new l("pointerdown",A),new f("mousedown",A),new l("pointerup",{...A,buttons:0}),new f("mouseup",{...A,buttons:0}),new f("click",{...A,buttons:0})].forEach(O=>a.dispatchEvent(O)),{success:!0,method:"pointer-mouse-click"}}function ne(a,E,m){let g=G(a,E),p=X(g,m);try{if(a instanceof HTMLAnchorElement){let l=a.getAttribute("target");try{a.setAttribute("target","_self"),a.click()}finally{l===null?a.removeAttribute("target"):a.setAttribute("target",l)}}else a.click?.();return{success:!0,method:"native-click"}}catch{return{success:!1,method:"native-click"}}}function se(a,E,m){let g=G(a,E),p=a.getBoundingClientRect(),l=[{x:p.left+p.width/2,y:p.top+p.height/2},{x:p.left+4,y:p.top+4},{x:p.right-4,y:p.top+4},{x:p.left+4,y:p.bottom-4},{x:p.right-4,y:p.bottom-4}],f=null;for(let b=0;b<l.length;b++){let S=l[b],A=g.elementFromPoint(S.x,S.y);if(b===0&&(f=A),A&&wa(a,A))return{...S,hit:A,ok:!0}}return{...l[0],hit:f,ok:!1}}function Q(a,E,m){let g=G(a,E),p=X(g,m);try{let l=Zt(a);if(!l)return{success:!1,method:"react-no-fiber"};let f=en(l),b=f.onClick||f.onClickCapture;return b?(b(Gt("click",a,g,p)),{success:!0,method:"react-fiber-onClick"}):{success:!1,method:"react-no-onClick"}}catch{return{success:!1,method:"react-fiber-onClick"}}}function ie(a,E,m){let g=G(a,E),l=X(g,m).MouseEvent||MouseEvent;try{let f=Tn(a);if(!f)return{success:!1,method:"vue-none"};let b=un(f);return b.click?(b.click(new l("click",{bubbles:!0})),{success:!0,method:"vue-handler"}):f.$emit?(f.$emit("click"),{success:!0,method:"vue-emit"}):{success:!1,method:"vue-no-click"}}catch{return{success:!1,method:"vue-handler"}}}function ce(a,E,m){let g=G(a,E),p=X(g,m),l=p.MouseEvent||MouseEvent;try{let f=p.ng?.getZone?.()||null;return f?.run?(f.run(()=>a.dispatchEvent(new l("click",{bubbles:!0,cancelable:!0}))),{success:!0,method:"angular-zone-click"}):(a.dispatchEvent(new l("click",{bubbles:!0,cancelable:!0})),a.click?.(),{success:!0,method:"angular-click"})}catch{return{success:!1,method:"angular-click",allowFallback:!0}}}function ge(a,E,m){let g=G(a,E),l=X(g,m).MouseEvent||MouseEvent;try{let f=a.getBoundingClientRect(),b={bubbles:!0,cancelable:!0,view:a.ownerDocument?.defaultView||window,clientX:f.left+f.width/2,clientY:f.top+f.height/2};return a.dispatchEvent(new l("mousedown",b)),a.dispatchEvent(new l("mouseup",b)),a.dispatchEvent(new l("click",b)),{success:!0,method:"svelte-click"}}catch{return{success:!1,method:"svelte-click"}}}function ve(a,E,m){let g=G(a,E),p=X(g,m);try{return p.jQuery?.(a)?.trigger?.("click"),{success:!0,method:"jquery-trigger"}}catch{return{success:!1,method:"jquery-trigger"}}}async function Be(a,E,m,g,p=500){let l=Math.min(Math.max(0,Number(p)||500),3e4),f=G(a,E),b=X(f,m),S=U(a,g);Se(a,f,b);let A=b.PointerEvent||PointerEvent,C=b.MouseEvent||MouseEvent,O=a.getBoundingClientRect(),W=O.left+O.width/2,Y=O.top+O.height/2;if(S.fws.has("react")){let J=Zt(a),te=J?en(J):{};te.onMouseEnter?.(Gt("mouseenter",a,f,b)),te.onPointerEnter?.(Gt("pointerenter",a,f,b))}else if(S.fws.has("vue")){let J=Tn(a),te=J?un(J):{};te.mouseenter?.(new C("mouseenter",{bubbles:!0})),te.mouseover?.(new C("mouseover",{bubbles:!0}))}let K={bubbles:!0,cancelable:!0,composed:!0,view:b,clientX:W,clientY:Y};return[new A("pointerover",K),new A("pointerenter",{...K,bubbles:!1}),new C("mouseover",K),new C("mouseenter",{...K,bubbles:!1})].forEach(J=>a.dispatchEvent(J)),await Je(l,f),{success:!0,method:"hover-seq"}}async function le(a,E,m=1){await Promise.resolve();for(let g=0;g<m;g++)a.hidden?await Rt():await new Promise(p=>{try{E.requestAnimationFrame(()=>p())}catch{Rt().then(p)}})}let ke=a=>String(a??"").replace(/\s+/g," ").trim();function We(a){try{if("value"in a)return String(a.value??"")}catch{}return""}function at(a){try{return typeof On=="function"?On(a):ke(a.textContent)}catch{return""}}function Ze(a,E){if(!(E.isFrameworkElement||E.delegatedInput))return!1;let m=String(a??"").length;return m>0&&m<=140}async function qe(a,E,m,g,p){let l=U(a,p),f=G(a,E),b=X(f,m);if(Se(a,f,b),kt(a,b)||Ct(a,b)){let A=Ze(String(g??""),l),C=await ha(a,f,b,g,{settleFrames:f.hidden?1:2,useKeyFallback:A,keyFallbackMaxLen:140});return{success:C.success,method:C.method,details:C.details,allowFallback:!C.success}}if(a.isContentEditable===!0||l.role==="textbox"&&!("value"in a)){let A=at(a),C=ma(a,g,f,b);await le(f,b,f.hidden?1:2);let O=at(a),W=!1;if(String(g??"").length>0&&O===A){W=!0;try{er(a,f,b),Zn(a,f,b,!0);try{f.execCommand?.("insertText",!1,String(g??""))}catch{}Dn(a,String(g??""),"insertText")}catch{}await le(f,b,f.hidden?1:2)}let Y=at(a),K=Y!==A||!!String(g??"")&&Y.includes(String(g??""));return{success:K,method:C.method,details:`${C.details};beforeLen=${A.length};afterLen=${Y.length};reverted=${O===A};fallback=${W}`,allowFallback:K?void 0:!0}}return{success:!1,method:"type",details:"target not editable",allowFallback:!0}}async function ct(a,E,m,g,p){let l=G(a,E),f=X(l,m),b=await qe(a,l,f,g,p);if(!b.success)return b;let S=ga(a);return{success:!0,method:"type+enter",details:`${b.details};enter=${S.method}`}}async function De(a,E,m,g){let p=G(a,E),l=X(p,m),f=l.Event||Event;if(Se(a,p,l),kt(a,l)||Ct(a,l)){let S=We(a),A=ba(a,p,l);if(await le(p,l,p.hidden?1:2),We(a)===S&&S.length>0){try{Ir(a,""),Dn(a,"","deleteByCut")}catch{}await le(p,l,p.hidden?1:2)}let W=We(a),Y=W.length===0||W!==S;return{success:A.success,method:A.method,details:A.details,allowFallback:!A.success}}if(a.isContentEditable===!0||U(a,g).role==="textbox"&&!("value"in a)){let S=Ea(a,p,l);return await le(p,l,p.hidden?1:2),{success:S.success,method:S.method,details:S.details,allowFallback:!S.success}}if("value"in a){try{a.value=""}catch{}return a.dispatchEvent(new f("input",{bubbles:!0,composed:!0})),a.dispatchEvent(new f("change",{bubbles:!0,composed:!0})),{success:!0,method:"clear-generic-value"}}return{success:!1,method:"clear",details:"target not clearable",allowFallback:!0}}function pt(a,E,m){try{let g=G(a,E),p=X(g,m),l=p.FocusEvent||FocusEvent;return Se(a,g,p),a.focus?.({preventScroll:!0}),a.dispatchEvent(new l("focus",{bubbles:!0})),a.dispatchEvent(new l("focusin",{bubbles:!0})),{success:!0,method:"focus"}}catch(g){return{success:!1,method:"focus",details:g.message,allowFallback:!0}}}function ye(a,E,m,g,p){try{let l=G(a,E),f=X(l,m),b=f.Event||Event;if(!ui(a,f))return{success:!1,method:"select",details:"target not select",allowFallback:!0};Se(a,l,f),a.focus?.({preventScroll:!0});let S=Array.from(a.options).find(W=>W.value===g||W.text.trim()===g.trim());if(!S)return{success:!1,method:"select",details:`Option not found: ${g}`,allowFallback:!0};S.selected=!0;let A=Object.getPrototypeOf(a),C=Object.getOwnPropertyDescriptor(A,"value");if(C?.set?C.set.call(a,S.value):a.value=S.value,a.dispatchEvent(new b("input",{bubbles:!0,composed:!0})),a.dispatchEvent(new b("change",{bubbles:!0,composed:!0})),U(a,p).fws.has("react")){let W=Zt(a);if(W){let Y=en(W);if(Y.onChange){let K=Gt("change",a,l,f);K.target.value=S.value,Y.onChange(K)}}}return{success:!0,method:"select"}}catch(l){return{success:!1,method:"select",details:l.message,allowFallback:!0}}}function ht(a,E,m,g,p){try{let l=G(a,E),f=X(l,m),b=f.Event||Event;if(!kt(a,f))return{success:!1,method:"slider",details:"target not input",allowFallback:!0};Se(a,l,f),a.focus?.({preventScroll:!0});let S=Object.getPrototypeOf(a),A=Object.getOwnPropertyDescriptor(S,"value");if(A?.set?A.set.call(a,String(g)):a.value=String(g),a.dispatchEvent(new b("input",{bubbles:!0,composed:!0})),a.dispatchEvent(new b("change",{bubbles:!0,composed:!0})),U(a,p).fws.has("react")){let O=Zt(a);if(O){let W=en(O);if(W.onChange){let Y=Gt("change",a,l,f);Y.target.value=String(g),W.onChange(Y)}}}return{success:!0,method:"slider"}}catch(l){return{success:!1,method:"slider",details:l.message,allowFallback:!0}}}function jt(a,E,m){try{let g=a.checkValidity?.()??!0;return g||a.reportValidity?.(),{success:g,method:"check-validity",details:g?void 0:a.validationMessage}}catch(g){return{success:!1,method:"check-validity",details:g.message,allowFallback:!0}}}function En(a,E,m,g,p){try{let l=G(a,E),f=X(l,m);if("setSelectionRange"in a){let A=a;A.focus?.();let C=A.value?.length??0;return A.setSelectionRange(g??0,p??C),{success:!0,method:"select-range"}}let b=f.getSelection();if(!b)return{success:!1,method:"select-range",allowFallback:!0};let S=l.createRange();return S.selectNodeContents(a),b.removeAllRanges(),b.addRange(S),{success:!0,method:"select-range-node"}}catch(l){return{success:!1,method:"select-range",details:l.message,allowFallback:!0}}}function At(a,E,m,g,p){let l=Fn((a&&G(a))??E),f=a||l,b=G(f,E),S=X(b,m),A=f===b.documentElement||f===b.body||f===l;if(g===Fe.TOP||g===Fe.BOTTOM){let C=f.scrollHeight,O=A?S.innerHeight:f.clientHeight,W=Math.max(0,C-O);return f.scrollTop=g===Fe.TOP?0:W,{success:!0,scrollTop:f.scrollTop}}return Eo(f,b,S,g,p)}async function cn(a,E,m,g){let p=g.direction,l=g.amount,f=G(a,E),b=X(f,m),S=!f.hidden,A=S?"smooth":"auto";try{if(a){let O=Ft(a,f,b),W=At(O,f,b,p,l);return W?.success?{success:!0,method:"direct-element-scroll",details:JSON.stringify(W)}:{success:!1,method:"direct-element-scroll",details:W?.error||"direct scroll failed",allowFallback:!0}}if(p===Fe.TOP||p===Fe.BOTTOM){let O=await P(b,{action:"scrollTo",direction:p,options:{behavior:A,isTabActive:S}},{doc:f,timeoutMs:f.hidden?5200:2800});return{success:!0,method:"detector-scrollTo",details:JSON.stringify(O)}}let C=await P(b,{action:"scrollBy",direction:p,options:{amount:l,behavior:A,isTabActive:S}},{doc:f,timeoutMs:f.hidden?5200:2800});return{success:!0,method:"detector-scrollBy",details:JSON.stringify(C)}}catch(C){let O=f?At(Fn(f),f,b,p,l):void 0;return O?.success?{success:!0,method:"direct-primary-scroll-fallback",details:JSON.stringify(O)}:{success:!1,method:"scroll-page-failed",details:C?.message||O?.error||"scroll_page failed",allowFallback:!0}}}async function Ue(a,E,m,g){let p=G(a,E),l=X(p,m),f=!p.hidden,b=f?"smooth":"auto",S=Ca(g.position),A=or(a,p);if(!A){let C=As(a,p,l,S);return{success:C.success,method:"direct-scrollElement-no-selector",details:C.error,allowFallback:!C.success}}try{let C=await P(l,{action:"scrollElement",selector:A,position:S,options:{behavior:b,isTabActive:f}},{doc:p,timeoutMs:p.hidden?5600:3e3});return{success:!0,method:"detector-scrollElement",details:JSON.stringify(C)}}catch(C){let O=As(a,p,l,S);return O.success?{success:!0,method:"direct-scrollElement-fallback",details:JSON.stringify(O)}:{success:!1,method:"scroll-to-element-failed",details:C?.message||O.error||"scroll_to_element failed",allowFallback:!0}}}function mt(a,E,m,g,p){try{let l=G(a,E),f=X(l,m),b=f.WheelEvent||WheelEvent;Se(a,l,f);let S=Ft(a,l,f);return S.dispatchEvent(new b("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:f,deltaX:g||0,deltaY:p||0,deltaMode:b.DOM_DELTA_PIXEL})),S.scrollBy({left:g||0,top:p||0,behavior:"auto"}),{success:!0,method:"wheel"}}catch(l){return{success:!1,method:"wheel",details:l.message,allowFallback:!0}}}function Ft(a,E,m){let g=G(a,E),p=X(g,m),l=g.scrollingElement||g.documentElement||g.body,f=a;for(;f&&f!==g.body&&f!==g.documentElement;){let S=p.getComputedStyle(f).overflowY;if((S==="auto"||S==="scroll"||S==="overlay")&&f.scrollHeight>f.clientHeight+5)return f;f=f.parentElement}return l}async function ln(a,E,m,g,p){try{let l=G(a,E),f=X(l,m),b=f.PointerEvent||PointerEvent,S=f.MouseEvent||MouseEvent,A=f.DragEvent||DragEvent,C=f.DataTransfer||DataTransfer;Se(a,l,f);let O=se(a,l,f),W=$e(O.hit,f)?O.hit:a,Y=a.getBoundingClientRect(),K=Number.isFinite(Number(g?.distance))?Number(g.distance):160,fe=0,J=0;switch(String(g?.direction||"").toUpperCase()){case"UP":J=-K;break;case"DOWN":J=K;break;case"LEFT":fe=-K;break;case"RIGHT":fe=K;break;default:fe=Number(g?.delta_x)||0,J=Number(g?.delta_y)||0}let te=(k,N)=>({x:Math.max(2,Math.min(k,f.innerWidth-3)),y:Math.max(2,Math.min(N,f.innerHeight-3))}),oe=te(O.x,O.y),xe=te(O.x+fe,O.y+J),Xe=500+Date.now()%1e4,pe=Math.max(12,Math.min(36,Number(g?.steps)||18)),be=(k,N)=>({bubbles:!0,cancelable:!0,composed:!0,view:f,clientX:k,clientY:N,pageX:k+(f.scrollX||0),pageY:N+(f.scrollY||0)}),Ee=(k,N,V)=>({...be(k,N),pointerId:Xe,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:V?.5:0,buttons:V,button:0}),u=(k,N,V)=>({...be(k,N),buttons:V,button:0});W.dispatchEvent(new b("pointerdown",Ee(oe.x,oe.y,1))),W.dispatchEvent(new S("mousedown",u(oe.x,oe.y,1)));try{W.setPointerCapture?.(Xe)}catch{}let w=null;try{(a.draggable||U(a,p).sourcesByType.has("dragstart"))&&(w=new C)}catch{w=null}if(w)try{a.dispatchEvent(new A("dragstart",{bubbles:!0,cancelable:!0,clientX:oe.x,clientY:oe.y,dataTransfer:w}))}catch{}let R=null;for(let k=1;k<=pe;k++){let N=oe.x+(xe.x-oe.x)*k/pe,V=oe.y+(xe.y-oe.y)*k/pe,j=l.elementFromPoint(N,V)||a;if(j.dispatchEvent(new b("pointermove",Ee(N,V,1))),j.dispatchEvent(new S("mousemove",u(N,V,1))),w)try{R&&R!==j&&R.dispatchEvent(new A("dragleave",{bubbles:!0,cancelable:!0,clientX:N,clientY:V,dataTransfer:w})),j.dispatchEvent(new A("dragover",{bubbles:!0,cancelable:!0,clientX:N,clientY:V,dataTransfer:w})),R=j}catch{}k%3===0&&await Rt()}let T=l.elementFromPoint(xe.x,xe.y)||a;if(T.dispatchEvent(new b("pointerup",Ee(xe.x,xe.y,0))),T.dispatchEvent(new S("mouseup",u(xe.x,xe.y,0))),w)try{a.dispatchEvent(new A("dragend",{bubbles:!0,cancelable:!0,clientX:xe.x,clientY:xe.y,dataTransfer:w}))}catch{}return{success:!0,method:"drag",details:`dx=${fe};dy=${J};steps=${pe};hitOk=${O.ok}`}}catch(l){return{success:!1,method:"drag",details:l?.message||"drag failed",allowFallback:!0}}}async function Ht(a,E,m,g){try{let p=G(E,m),l=X(p,g),f=l.PointerEvent||PointerEvent,b=l.MouseEvent||MouseEvent,S=l.DragEvent||DragEvent,A=l.DataTransfer||DataTransfer,C=a?.source_element_id??a?.element_id,O=(C?Nt(p,String(C)):null)||E;if(!O)return{success:!1,method:"drag-drop",details:"source missing",allowFallback:!0};let W=null,Y=Number(a?.target_x),K=Number(a?.target_y);if(a?.target_element_id){if(W=Nt(p,String(a.target_element_id)),!W)return{success:!1,method:"drag-drop",details:"target missing",allowFallback:!0};let T=W.getBoundingClientRect();Y=T.left+T.width/2,K=T.top+T.height/2}if((!Number.isFinite(Y)||!Number.isFinite(K))&&!W)return{success:!1,method:"drag-drop",details:"missing target coords",allowFallback:!0};Se(O,p,l),W&&Se(W,p,l);let fe=(T,k)=>({x:Math.max(2,Math.min(T,l.innerWidth-3)),y:Math.max(2,Math.min(k,l.innerHeight-3))}),J=O.getBoundingClientRect(),te=fe(J.left+J.width/2,J.top+J.height/2),oe=fe(Number(Y),Number(K)),xe=600+Date.now()%1e4,Xe=Math.max(14,Math.min(42,Number(a?.steps)||22)),pe=(T,k)=>({bubbles:!0,cancelable:!0,composed:!0,view:l,clientX:T,clientY:k,pageX:T+(l.scrollX||0),pageY:k+(l.scrollY||0)}),be=(T,k,N)=>({...pe(T,k),pointerId:xe,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:N?.5:0,buttons:N,button:0}),Ee=(T,k,N)=>({...pe(T,k),buttons:N,button:0}),u=null;try{u=new A}catch{u=null}O.dispatchEvent(new f("pointerdown",be(te.x,te.y,1))),O.dispatchEvent(new b("mousedown",Ee(te.x,te.y,1)));try{O.setPointerCapture?.(xe)}catch{}if(u)try{O.dispatchEvent(new S("dragstart",{bubbles:!0,cancelable:!0,clientX:te.x,clientY:te.y,dataTransfer:u}))}catch{}let w=null;for(let T=1;T<=Xe;T++){let k=te.x+(oe.x-te.x)*T/Xe,N=te.y+(oe.y-te.y)*T/Xe,V=p.elementFromPoint(k,N)||W||p.body;if(V.dispatchEvent(new f("pointermove",be(k,N,1))),V.dispatchEvent(new b("mousemove",Ee(k,N,1))),u)try{w&&w!==V&&w.dispatchEvent(new S("dragleave",{bubbles:!0,cancelable:!0,clientX:k,clientY:N,dataTransfer:u})),V.dispatchEvent(new S("dragenter",{bubbles:!0,cancelable:!0,clientX:k,clientY:N,dataTransfer:u})),V.dispatchEvent(new S("dragover",{bubbles:!0,cancelable:!0,clientX:k,clientY:N,dataTransfer:u})),w=V}catch{}T%3===0&&await Rt()}let R=W||p.elementFromPoint(oe.x,oe.y)||p.body;if(u)try{R.dispatchEvent(new S("drop",{bubbles:!0,cancelable:!0,clientX:oe.x,clientY:oe.y,dataTransfer:u}))}catch{}if(R.dispatchEvent(new f("pointerup",be(oe.x,oe.y,0))),R.dispatchEvent(new b("mouseup",Ee(oe.x,oe.y,0))),u)try{O.dispatchEvent(new S("dragend",{bubbles:!0,cancelable:!0,clientX:oe.x,clientY:oe.y,dataTransfer:u}))}catch{}return{success:!0,method:"html5+pointer-dragdrop",details:`steps=${Xe};source=${String(C)}`}}catch(p){return{success:!1,method:"drag-drop",details:p?.message||"drag-drop failed",allowFallback:!0}}}async function Ut(a,E,m,g){try{let p=G(a,E),l=X(p,m),f=l.PointerEvent||PointerEvent,b=l.MouseEvent||MouseEvent;Se(a,p,l);let S=se(a,p,l),A={x:S.x,y:S.y},C=a.getBoundingClientRect(),O=Number.isFinite(Number(g?.distance))?Number(g.distance):Math.min(Math.max(80,Math.min(C.width,C.height)),220),W=String(g?.direction||"RIGHT").toUpperCase(),Y=A.x,K=A.y;W==="LEFT"&&(Y-=O),W==="RIGHT"&&(Y+=O),W==="UP"&&(K-=O),W==="DOWN"&&(K+=O);let fe=(k,N)=>({x:Math.max(2,Math.min(k,l.innerWidth-3)),y:Math.max(2,Math.min(N,l.innerHeight-3))}),J=fe(A.x,A.y),te=fe(Y,K),oe=700+Date.now()%1e4,xe=Math.max(10,Math.min(28,Number(g?.steps)||16)),Xe=(k,N)=>({bubbles:!0,cancelable:!0,composed:!0,view:l,clientX:k,clientY:N,pageX:k+(l.scrollX||0),pageY:N+(l.scrollY||0)}),pe=(k,N,V)=>({...Xe(k,N),pointerId:oe,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:V?.5:0,buttons:V,button:0}),be=(k,N,V)=>({...Xe(k,N),buttons:V,button:0}),Ee=p.elementFromPoint(J.x,J.y)||a;Ee.dispatchEvent(new f("pointerdown",pe(J.x,J.y,1))),Ee.dispatchEvent(new b("mousedown",be(J.x,J.y,1)));let u=l.Touch,w=l.TouchEvent,R=!!u&&!!w;if(R)try{let k=new u({identifier:oe,target:Ee,clientX:J.x,clientY:J.y,pageX:J.x,pageY:J.y,screenX:J.x,screenY:J.y,radiusX:1,radiusY:1,rotationAngle:0,force:1});Ee.dispatchEvent(new w("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[k],targetTouches:[k],changedTouches:[k]}))}catch{}for(let k=1;k<=xe;k++){let N=J.x+(te.x-J.x)*k/xe,V=J.y+(te.y-J.y)*k/xe,j=p.elementFromPoint(N,V)||a;if(j.dispatchEvent(new f("pointermove",pe(N,V,1))),j.dispatchEvent(new b("mousemove",be(N,V,1))),R)try{let ae=new u({identifier:oe,target:j,clientX:N,clientY:V,pageX:N,pageY:V,screenX:N,screenY:V,radiusX:1,radiusY:1,rotationAngle:0,force:1});j.dispatchEvent(new w("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[ae],targetTouches:[ae],changedTouches:[ae]}))}catch{}k%3===0&&await Rt()}let T=p.elementFromPoint(te.x,te.y)||a;if(T.dispatchEvent(new f("pointerup",pe(te.x,te.y,0))),T.dispatchEvent(new b("mouseup",be(te.x,te.y,0))),R)try{let k=new u({identifier:oe,target:T,clientX:te.x,clientY:te.y,pageX:te.x,pageY:te.y,screenX:te.x,screenY:te.y,radiusX:1,radiusY:1,rotationAngle:0,force:0});T.dispatchEvent(new w("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[k]}))}catch{}return{success:!0,method:"swipe",details:`dir=${W};dist=${O};steps=${xe};hitOk=${S.ok}`}}catch(p){return{success:!1,method:"swipe",details:p?.message||"swipe failed",allowFallback:!0}}}async function Oe(a,E,m,g){try{let p=a||E.body,l=G(p,E),f=X(l,m),b=f.PointerEvent||PointerEvent,S=f.WheelEvent||WheelEvent;Se(p,l,f);let A=Number.isFinite(Number(g?.scale))?Number(g.scale):1.2,C=p.getBoundingClientRect(),O=C.left+C.width/2,W=C.top+C.height/2,Y=24,K=Math.max(6,Math.min(200,Y*A)),fe=Math.max(6,Math.min(18,Number(g?.steps)||10)),J=f.Touch,te=f.TouchEvent;if(!!J&&!!te)try{let pe=(R,T)=>new J({identifier:R,target:p,clientX:T,clientY:W,pageX:T,pageY:W,screenX:T,screenY:W,radiusX:1,radiusY:1,rotationAngle:0,force:1}),be=pe(911,O-Y),Ee=pe(912,O+Y);p.dispatchEvent(new te("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[be,Ee],targetTouches:[be,Ee],changedTouches:[be,Ee]}));for(let R=1;R<=fe;R++){let T=Y+(K-Y)*R/fe,k=pe(911,O-T),N=pe(912,O+T);p.dispatchEvent(new te("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[k,N],targetTouches:[k,N],changedTouches:[k,N]})),R%2===0&&await Rt()}let u=pe(911,O-K),w=pe(912,O+K);p.dispatchEvent(new te("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[u,w]}))}catch{}try{let pe=(be,Ee,u)=>({bubbles:!0,cancelable:!0,composed:!0,view:f,clientX:Ee,clientY:W,pointerId:be,pointerType:"touch",isPrimary:be===821,width:1,height:1,pressure:u?.5:0,buttons:u,button:0});p.dispatchEvent(new b("pointerdown",pe(821,O-Y,1))),p.dispatchEvent(new b("pointerdown",pe(822,O+Y,1)));for(let be=1;be<=fe;be++){let Ee=Y+(K-Y)*be/fe;p.dispatchEvent(new b("pointermove",pe(821,O-Ee,1))),p.dispatchEvent(new b("pointermove",pe(822,O+Ee,1))),be%2===0&&await Rt()}p.dispatchEvent(new b("pointerup",pe(821,O-K,0))),p.dispatchEvent(new b("pointerup",pe(822,O+K,0)))}catch{}try{let xe=A>=1?-120:120;p.dispatchEvent(new S("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:f,clientX:O,clientY:W,ctrlKey:!0,deltaY:xe,deltaMode:S.DOM_DELTA_PIXEL}))}catch{}return{success:!0,method:"pinch-zoom",details:`scale=${A};steps=${fe}`}}catch(p){return{success:!1,method:"pinch-zoom",details:p?.message||"pinch-zoom failed",allowFallback:!0}}}async function $n(a,E,m,g=800){try{let p=G(a,E),l=X(p,m),f=l.PointerEvent||PointerEvent,b=l.MouseEvent||MouseEvent,S=l.FocusEvent||FocusEvent;Se(a,p,l);let A=se(a,p,l),C=a;!A.ok&&$e(A.hit,l)?C=A.hit.closest?.('a,button,input,select,textarea,summary,[role="button"],[role="link"],[onclick]')||A.hit:$e(A.hit,l)&&(C=A.hit);let O=et(C,p,l),W=A.x,Y=A.y,K=1+Date.now()%1e4,fe={bubbles:!0,cancelable:!0,composed:!0,view:l,clientX:W,clientY:Y,pageX:W+(l.scrollX||0),pageY:Y+(l.scrollY||0),screenX:W+(l.screenX||0),screenY:Y+(l.screenY||0)},J={...fe,pointerId:K,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:0,buttons:0,button:0};try{C.dispatchEvent(new f("pointerover",J)),C.dispatchEvent(new f("pointerenter",{...J,bubbles:!1}))}catch{}try{C.dispatchEvent(new b("mouseover",fe)),C.dispatchEvent(new b("mouseenter",{...fe,bubbles:!1}))}catch{}try{C.focus?.({preventScroll:!0}),C.dispatchEvent(new S("focus",{bubbles:!0,composed:!0})),C.dispatchEvent(new S("focusin",{bubbles:!0,composed:!0}))}catch{}try{C.dispatchEvent(new f("pointerdown",{...J,buttons:1,pressure:.5}))}catch{}try{C.dispatchEvent(new b("mousedown",{...fe,buttons:1,button:0}))}catch{}try{let pe=l.Touch,be=l.TouchEvent;if(typeof pe<"u"&&typeof be<"u"){let Ee=new pe({identifier:K,target:C,clientX:W,clientY:Y,pageX:W+(l.scrollX||0),pageY:Y+(l.scrollY||0),screenX:W+(l.screenX||0),screenY:Y+(l.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:1});C.dispatchEvent(new be("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[Ee],targetTouches:[Ee],changedTouches:[Ee]}))}}catch{}let te=Number(g),oe=Number.isFinite(te)&&te>0?te:800,xe=p.hidden?Math.max(oe,1200):oe;await Je(xe,p);try{C.dispatchEvent(new b("contextmenu",{...fe,button:2,buttons:2}))}catch{}try{C.dispatchEvent(new f("pointerup",{...J,buttons:0,pressure:0}))}catch{}try{C.dispatchEvent(new b("mouseup",{...fe,buttons:0,button:0}))}catch{}try{let pe=l.Touch,be=l.TouchEvent;if(typeof pe<"u"&&typeof be<"u"){let Ee=new pe({identifier:K,target:C,clientX:W,clientY:Y,pageX:W+(l.scrollX||0),pageY:Y+(l.scrollY||0),screenX:W+(l.screenX||0),screenY:Y+(l.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:0});C.dispatchEvent(new be("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[Ee]}))}}catch{}let Xe=await Ye(C,p,l,O);return{success:!0,method:"long-press",details:`holdMs=${xe};verified=${Xe};hitOk=${A.ok};target=${C.tagName.toLowerCase()}`}}catch(p){return{success:!1,method:"long-press",details:p?.message||"long-press failed",allowFallback:!0}}}function Kt(a,E,m,g,p){try{let l=G(m,g),b=X(l,p).KeyboardEvent||KeyboardEvent,S=m||l.activeElement||l.body||l.documentElement;S.focus?.();let A={key:a,code:Pr(a),bubbles:!0,cancelable:!0,ctrlKey:E?.includes("CTRL"),altKey:E?.includes("ALT"),shiftKey:E?.includes("SHIFT"),metaKey:E?.includes("META")},C=S.dispatchEvent(new b("keydown",A)),O=S.dispatchEvent(new b("keypress",A)),W=S.dispatchEvent(new b("keyup",A));if(a==="Enter"&&!!(C&&O&&W)){let K=S.form||S.closest?.("form");K?.requestSubmit?K.requestSubmit():K?.submit?.()}return{success:!0,method:"press-key"}}catch(l){return{success:!1,method:"press-key",details:l.message,allowFallback:!0}}}async function Qt(a,E,m){try{let g=a.innerText||a.value||"";if(!g)return{success:!1,method:"copy",details:"nothing to copy",allowFallback:!0};let p=G(a,E),l=X(p,m);if(l.navigator?.clipboard?.writeText)return await l.navigator.clipboard.writeText(g),{success:!0,method:"clipboard-copy"};let f=p.createRange();f.selectNodeContents(a);let b=l.getSelection?.()||(p.defaultView||window).getSelection?.();b?.removeAllRanges(),b?.addRange(f);let S=p.execCommand?.("copy")??!1;return b?.removeAllRanges(),{success:!!S,method:"execCommand-copy",allowFallback:!S}}catch(g){return{success:!1,method:"clipboard-copy",details:g.message,allowFallback:!0}}}async function Et(a,E,m,g){try{a.focus?.();let p=G(a,E),l=X(p,m);if(l.navigator?.clipboard?.readText){let b=await l.navigator.clipboard.readText();if(b)return await qe(a,p,l,b,g)}return p.execCommand?.("paste")??!1?{success:!0,method:"execCommand-paste"}:{success:!1,method:"paste",details:"clipboard empty or denied",allowFallback:!0}}catch(p){return{success:!1,method:"paste",details:p.message,allowFallback:!0}}}function Jt(a){return`${(a/1024).toFixed(1)}KB`}function xt(a,E){if(a instanceof E.defaultView.HTMLInputElement){let f=a;if((f.type||"").toLowerCase()==="file")return f}let m=a.closest?.("label"),g=m?.htmlFor||a.htmlFor||"";if(g){let f=E.getElementById(g);if(f&&(f.type||"").toLowerCase()==="file")return f}if(m){let f=m.querySelector?.('input[type="file"]');if(f)return f}let p=a.closest?.("form");if(p){let f=p.querySelector?.('input[type="file"]');if(f)return f}let l=a.closest?.("div,section,main,article")||a.parentElement;if(l){let f=l.querySelector?.('input[type="file"]');if(f)return f}return null}function Pt(a,E,m){try{let g=m.HTMLInputElement?.prototype,p=g?Object.getOwnPropertyDescriptor(g,"files")?.set:void 0;if(!p){let l=Object.getPrototypeOf(a);for(;l&&!p;)p=Object.getOwnPropertyDescriptor(l,"files")?.set,l=Object.getPrototypeOf(l)}return p?(p.call(a,E),!0):(a.files=E,!0)}catch{try{return a.files=E,!0}catch{return!1}}}async function Bt(a,E,m,g,p,l){try{let{file_url:f,element_id:b,file_name:S}=a,A=null;if(p&&(A=xt(p,E)),!A&&b!==void 0&&(A=E.querySelector(`input[type="file"][${ot}*="[id=${b}]"]`)),!A){let T=E.querySelectorAll('input[type="file"]');for(let k of T){if(k.disabled)continue;let N=k.getBoundingClientRect();if(N.width>0&&N.height>0){A=k;break}}}if(!A)return{success:!1,method:"upload-file",details:"No file input found",allowFallback:!0};if(A.disabled)return{success:!1,method:"upload-file",details:"File input is disabled",allowFallback:!0};let C=G(A,E),O=X(C,m);if(!(g?.kind==="upload_file"&&typeof g.byteLength=="number"&&g.byteLength>=0&&typeof g.mimeType=="string"&&(typeof g.inlineB64=="string"||typeof g.token=="string")))return{success:!1,method:"upload-file",details:"Missing upload payload (need inlineB64 or token)",allowFallback:!0};let Y=Number(g.byteLength),K=(g.mimeType||"application/octet-stream").split(";")[0].trim()||"application/octet-stream",fe;if(g.inlineB64&&typeof g.inlineB64=="string"){let T=Ia(g.inlineB64);if(T.byteLength!==Y)return{success:!1,method:"upload-file",details:`Inline bytes length mismatch: got=${T.byteLength} expected=${Y}`,allowFallback:!0};fe=T.buffer}else{let T=String(g.token);fe=await x(O,T,Y,9e4)}let J=O.Blob||Blob,te=new J([fe],{type:K}),oe=S||g?.fileName;!oe&&f&&typeof f=="string"&&(oe=Is(f,O)),oe=ka(oe||"upload");let xe=O.File||File,Xe=new xe([te],oe,{type:K,lastModified:Date.now()}),pe=O.Event||Event,be=O.DataTransfer||DataTransfer;if(!be)return{success:!1,method:"upload-file",details:"DataTransfer unavailable in this context",allowFallback:!0};let Ee=new be;if(Ee.items.add(Xe),!Pt(A,Ee.files,O))return{success:!1,method:"upload-file",details:"Failed to set input.files",allowFallback:!0};A.dispatchEvent(new pe("input",{bubbles:!0,composed:!0,cancelable:!0})),A.dispatchEvent(new pe("change",{bubbles:!0,composed:!0,cancelable:!0}));let w=Zt(A);if(w){let T=en(w);if(T.onChange){let k=Gt("change",A,C,O);k.target.files=Ee.files,T.onChange(k)}}let R=Tn(A);if(R){let T=un(R);if(T.change){let k=new pe("change",{bubbles:!0});k.target=A,k.target.files=Ee.files,T.change(k)}}try{let T=O.jQuery||O.$;T&&typeof T=="function"&&T(A).triggerHandler?.("change")}catch{}return A.focus?.({preventScroll:!0}),await le(C,O,2),{success:!0,method:"upload-file",details:`Uploaded ${oe} (${Jt(te.size)}) [token]`}}catch(f){return{success:!1,method:"upload-file",details:f?.message||"Upload failed",allowFallback:!0}}}async function Wt(a,E,m){let g=Array.isArray(a.path)?a.path:[];if(!g.length)return{success:!1,method:"dispatch_pointer_path",details:"Empty path",allowFallback:!0};let p=m.PointerEvent||PointerEvent,l=m.MouseEvent||MouseEvent,f=16;for(let b=0;b<g.length;b++){let S=g[b],A=Number(S.x)||0,C=Number(S.y)||0,O=Number(S.pressure)||(b===0||b===g.length-1?0:.5),W=E.elementFromPoint(A,C)||E.documentElement,Y={bubbles:!0,cancelable:!0,clientX:A,clientY:C,screenX:A,screenY:C,view:m};if(b===0?(W.dispatchEvent(new p("pointerdown",{...Y,pressure:O,pointerId:1,pointerType:"mouse"})),W.dispatchEvent(new l("mousedown",{...Y,button:0,buttons:1}))):(W.dispatchEvent(new p("pointermove",{...Y,pressure:O,pointerId:1,pointerType:"mouse"})),W.dispatchEvent(new l("mousemove",{...Y,button:0,buttons:1}))),b===g.length-1&&(W.dispatchEvent(new p("pointerup",{...Y,pressure:0,pointerId:1,pointerType:"mouse"})),W.dispatchEvent(new l("mouseup",{...Y,button:0,buttons:0}))),b<g.length-1){let K=Number(S.timestamp)||0,fe=Number(g[b+1].timestamp)||0,J=K&&fe?Math.max(0,Math.min(fe-K,1e3)):f;J>0&&await Je(J,E)}}return{success:!0,method:"dispatch_pointer_path",details:`Dispatched ${g.length} point(s)`}}function wn(a,E,m){let g=G(a,E),p=X(g,m),l=p.MouseEvent||MouseEvent;Se(a,g,p),Z(a,g,p),Z(a,g,p);let f=a.getBoundingClientRect();return a.dispatchEvent(new l("dblclick",{bubbles:!0,cancelable:!0,clientX:f.left+f.width/2,clientY:f.top+f.height/2,detail:2,view:p})),{success:!0,method:"dblclick"}}function ue(a,E,m){let g=G(a,E),p=X(g,m),l=p.PointerEvent||PointerEvent,f=p.MouseEvent||MouseEvent;Se(a,g,p);let b=a.getBoundingClientRect(),S=b.left+b.width/2,A=b.top+b.height/2,C={bubbles:!0,cancelable:!0,composed:!0,view:p,clientX:S,clientY:A,button:2,buttons:2};return a.dispatchEvent(new l("pointerdown",C)),a.dispatchEvent(new f("mousedown",C)),a.dispatchEvent(new l("pointerup",{...C,buttons:0})),a.dispatchEvent(new f("mouseup",{...C,buttons:0})),a.dispatchEvent(new f("contextmenu",C)),{success:!0,method:"contextmenu"}}function et(a,E,m){let g=G(a,E),p=X(g,m),l=a,f=a.getBoundingClientRect();return{href:String(p.location.href),hash:String(p.location.hash),ariaExpanded:a.getAttribute("aria-expanded"),ariaPressed:a.getAttribute("aria-pressed"),ariaDisabled:a.getAttribute("aria-disabled"),disabled:!!l.disabled,open:typeof l.open<"u"?l.open:void 0,checked:typeof l.checked<"u"?l.checked:void 0,value:typeof l.value<"u"?l.value:void 0,active:ho(g),rect:{w:f.width,h:f.height}}}function Vt(a,E){let m=Math.abs(a.rect.w-E.rect.w)>2||Math.abs(a.rect.h-E.rect.h)>2;return a.href!==E.href||a.hash!==E.hash||a.ariaExpanded!==E.ariaExpanded||a.ariaPressed!==E.ariaPressed||a.ariaDisabled!==E.ariaDisabled||a.disabled!==E.disabled||a.open!==E.open||a.checked!==E.checked||a.value!==E.value||a.active!==E.active||m}async function Ye(a,E,m,g){await Promise.resolve();let p=G(a,E),l=X(p,m);E.hidden||await Rt();let f=et(a,p,l);return Vt(g,f)}function yn(a,E,m){a.focus?.({preventScroll:!0});let g=G(a,E),p=X(g,m),b=a.getAttribute("role")==="button"||fi(a,p)||a.tagName.toLowerCase()==="button"?[" ","Enter"]:["Enter"],S=p.KeyboardEvent||KeyboardEvent;for(let A of b){let C={key:A,code:A===" "?"Space":"Enter",bubbles:!0,cancelable:!0,composed:!0};a.dispatchEvent(new S("keydown",C)),a.dispatchEvent(new S("keypress",C)),a.dispatchEvent(new S("keyup",C))}return{success:!0,method:"keyboard-activate"}}async function Gn(a,E,m,...g){let p=null;for(let l of g){let f=G(a,E),b=X(f,m),S=et(a,f,b),A=l();if(!A||!A.success)continue;if(await Ye(a,f,b,S))return{...A,details:(A.details?A.details+";":"")+"verified=true"};p=A}return p?{...p,details:(p.details?p.details+";":"")+"verified=false"}:{success:!1,method:"all-strategies-unverified",details:"no verified effect",allowFallback:!0}}function vn(...a){for(let E of a)try{let m=E();if(m&&m.success)return m}catch{}return{success:!1,method:"all-strategies-failed",allowFallback:!0}}function Se(a,E,m){let g=G(a,E),p=X(g,m),l=a.getBoundingClientRect();l.top>=0&&l.left>=0&&l.bottom<=p.innerHeight&&l.right<=p.innerWidth||(a.scrollIntoView({behavior:"auto",block:"center",inline:"center"}),a.offsetHeight)}function ur(a,E,m,g){let p=G(a,E),f=X(p,m).KeyboardEvent||KeyboardEvent;for(let b of g){let S=String(b??""),A="";/^[a-z]$/i.test(S)?A=`Key${S.toUpperCase()}`:/^[0-9]$/.test(S)?A=`Digit${S}`:S===" "&&(A="Space");let C=S.length===1?S.charCodeAt(0):0,O={key:S,code:A,bubbles:!0,cancelable:!0,composed:!0,keyCode:C,which:C};a.dispatchEvent(new f("keydown",O)),a.dispatchEvent(new f("keypress",O)),a.dispatchEvent(new f("keyup",O))}}function Ur(a,E,m){let g=G(a,E),l=X(g,m).KeyboardEvent||KeyboardEvent,f={key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0,composed:!0},b=a.dispatchEvent(new l("keydown",f)),S=a.dispatchEvent(new l("keypress",f)),A=a.dispatchEvent(new l("keyup",f));if(!!(b&&S&&A)){let O=a.form||a.closest?.("form");O?.requestSubmit?.()??O?.submit?.()}}function Pr(a){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"}[a]||`Key${a.toUpperCase()}`}let qn=new MessageChannel,_n=[];qn.port1.onmessage=()=>{let a=_n.shift();a&&a()};function Rt(){return new Promise(a=>{_n.push(a),qn.port2.postMessage(0)})}function Zt(a){let E=g=>{if(!g)return null;let p=Object.keys(g);for(let l of p)if(l.startsWith("__reactFiber")||l.startsWith("__reactInternalInstance")||l.includes("reactFiber")||l.includes("reactProps")||l.includes("reactEventHandlers")||/^__r\d+/.test(l))return g[l];return null},m=a;for(let g=0;g<4&&m;g++){let p=E(m);if(p)return p;m=m.parentElement}return null}function en(a){let E={},m=a,g=0;for(;m&&g++<10;){let p=[m.memoizedProps,m.pendingProps,m.stateNode?.props,m._memoizedProps,m._pendingProps,m.alternate?.memoizedProps].filter(Boolean);for(let l of p)if(!(!l||typeof l!="object"))for(let f in l)f.startsWith("on")&&typeof l[f]=="function"&&(E[f]=l[f]);if(Object.keys(E).length)break;m=m.return||m.alternate}return E}function $t(a,E){let m=a;for(;m;){if(m._reactRootContainer||m.__reactContainer||m.hasAttribute("data-reactroot")||m.hasAttribute("data-react-root")||["root","app","__next"].includes(m.id))return m;m=m.parentElement}return G(a,E).querySelector("#root,#app,#__next,[data-reactroot],[data-react-root]")}function Gt(a,E,m,g){let p=G(E,m),l=X(p,g),f=l.MouseEvent||MouseEvent,b=E.getBoundingClientRect(),S=new f(a,{bubbles:!0,cancelable:!0,view:l,clientX:b.left+b.width/2,clientY:b.top+b.height/2});return{type:a,target:E,currentTarget:E,bubbles:!0,cancelable:!0,nativeEvent:S,isTrusted:!0,preventDefault(){S.preventDefault()},stopPropagation(){S.stopPropagation()}}}function Tn(a){let E=a;if(E.__vue__)return E.__vue__;if(E.__vueParentComponent)return E.__vueParentComponent;if(E._vnode)return E._vnode;let m=a.parentElement;for(let g=0;g<3&&m;g++){let p=m;if(p.__vue__||p.__vueParentComponent||p._vnode)return p.__vue__||p.__vueParentComponent||p._vnode;m=m.parentElement}return null}function un(a){let E={};if(a?.$listeners&&Object.assign(E,a.$listeners),a?._events)for(let m in a._events){let g=a._events[m];E[m]=Array.isArray(g)?g[0]:g}if(a?.props)for(let m in a.props)m.startsWith("on")&&typeof a.props[m]=="function"&&(E[m.substring(2).toLowerCase()]=a.props[m]);if(a?.vnode?.props)for(let m in a.vnode.props)m.startsWith("on")&&typeof a.vnode.props[m]=="function"&&(E[m.substring(2).toLowerCase()]=a.vnode.props[m]);return E}})();function Ma(){let e=window,t=e.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__";e[t]?.actions?.execute}async function La(e){let t=window,n=t.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",o=t[n]?.actions?.execute;if(typeof o!="function")throw new Error("Rover main-world action executor not initialized");return o(e)}function wo(e,t,n={}){let{rootNodes:r,semanticNodes:o}=Es(e,{includeFrameContents:n.includeFrames??!0,clearIframes:n.includeFrames??!0,frameContextLabel:n.frameContextLabel??null,signalProvider:t.signalProvider,disableDomAnnotations:n.disableDomAnnotations??!0}),s={};for(let i of Object.keys(o)){let c=Number(i);if(!Number.isFinite(c))continue;let d=Tr(c);d&&(s[c]=t.getFrameworkMetadata(d))}return{rootNodes:r,semanticNodes:o,elementMeta:s}}(()=>{let e="__rtrvr_scroll_detector",t="__RTRVR_SCROLL_API__",n="__RTRVR_INTERNAL__";if(window[e])return;class r{constructor(h=document,v=window){$(this,"doc");$(this,"win");$(this,"viewport");$(this,"lastDetectedPrimary",null);$(this,"detectionCache",new Map);$(this,"lastDetectionTime",0);$(this,"CACHE_TTL",5e3);this.doc=h,this.win=v,this.viewport={width:v.innerWidth,height:v.innerHeight},this.updateViewport()}getValidPrimary(){return this.lastDetectedPrimary&&!this.doc.contains(this.lastDetectedPrimary)&&(this.lastDetectedPrimary=null),this.lastDetectedPrimary}async handleCommand(h){switch(h.action){case"detectPrimary":{let v=this.detectPrimaryScrollable();if(!v)return null;let{target:I,isRoot:x}=this.getScrollContext(v.element),M=I.scrollHeight,D=Yt(),P=x&&D?D.innerHeight:I.clientHeight,q=Math.max(0,M-P),F=I.scrollTop;return{selector:v.selector,score:v.score,type:v.type,metrics:{scrollTop:F,scrollHeight:M,clientHeight:P,isAtTop:F<=5,isAtBottom:F>=q-5}}}case"scrollTo":if(!h.direction)throw new Error("scrollTo requires direction");return this.scrollToDirection(h.direction,h.options);case"scrollBy":if(!h.direction)throw new Error("scrollBy requires direction");return this.scrollByAmount(h.direction,h.options);case"scrollElement":if(!h.selector)throw new Error("scrollElement requires selector");return this.scrollElementIntoView(h.selector,h.position,h.options);case"getMetrics":return this.getScrollMetrics();default:throw new Error(`Unknown command: ${h.action}`)}}updateViewport(){this.viewport={width:this.win.innerWidth,height:this.win.innerHeight}}async execute(h){return this.handleCommand(h)}detectPrimaryScrollable(){if(Date.now()-this.lastDetectionTime<this.CACHE_TTL&&this.detectionCache.size>0){let x=Array.from(this.detectionCache.values()).sort((M,D)=>D.score-M.score)[0];if(x)return this.lastDetectedPrimary=x.element,x}this.updateViewport();let h=this.collectScrollableCandidates();if(h.length===0){let x=this.doc.scrollingElement||this.doc.documentElement||this.doc.body;if(!x)return null;let M=this.buildFeatures(x),D=G(x,this.doc),P={element:x,selector:or(x,D),score:.5,features:M,type:"document"};return this.detectionCache.clear(),this.detectionCache.set(P.selector,P),this.lastDetectionTime=Date.now(),this.lastDetectedPrimary=x,P}let v=this.scoreCandidates(h);if(v.length===0)return null;this.detectionCache.clear();for(let x of v)this.detectionCache.set(x.selector,x);this.lastDetectionTime=Date.now();let I=v[0];return I&&(this.lastDetectedPrimary=I.element),I||null}collectAllElementsDeep(h,v=15e4){let I=[],x=[],M=h.body||h.documentElement;M&&x.push(M);let D=0,P=q=>{try{let F=this.win.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",U=this.win[F]?.shadow?.getRoot;if(typeof U=="function"){let z=U(q);if(z)return z}}catch{}try{return q.shadowRoot||null}catch{return null}};for(;x.length&&!(++D>v);){let q=x.pop();if(vt(q)){let U=q.children;for(let z=U.length-1;z>=0;z--)x.push(U[z]);continue}let F=q,H=re(F);$e(F,H)&&I.push(F);try{let U=P(F);U&&x.push(U)}catch{}for(let U=F.lastElementChild;U;U=U.previousElementSibling)x.push(U)}return I}collectScrollableCandidates(){let h=[],v=new WeakSet,I=[this.doc.scrollingElement,this.doc.documentElement,this.doc.body];for(let M of I){if(!M||v.has(M))continue;let D=this.isScrollable(M);(D.vertical||D.horizontal)&&(h.push(M),v.add(M))}let x=this.collectAllElementsDeep(this.doc);for(let M of Array.from(x)){if(v.has(M))continue;let D=M.getBoundingClientRect(),P=this.win.getComputedStyle(M);if(!this.isElementRendered(M,D,P)||!this.isScrollable(M).vertical)continue;let F=40,H=this.viewport.width*.15;if(D.height<F||D.width<H){let U=(M.className||"").toLowerCase().includes("scroll"),z=P.overflowY==="auto"||P.overflowY==="scroll"||P.overflow==="auto"||P.overflow==="scroll";if(!U&&!z)continue}h.push(M),v.add(M)}return h}isElementRendered(h,v,I){if(I.display==="none"||I.visibility==="hidden")return!1;let x=parseFloat(I.opacity||"1");return!(!Number.isNaN(x)&&x<.01||v.width<=1||v.height<=1)}isScrollable(h){let v=this.win.getComputedStyle(h),I=v.overflowY,x=v.overflowX,M=this.doc.scrollingElement,D=h===this.doc.documentElement||h===this.doc.body||!!M&&h===M,P=h.scrollHeight,q=h.clientHeight,F=h.scrollWidth,H=h.clientWidth;if(D){let ce=this.doc.documentElement,ge=this.doc.body;P=Math.max(ce?ce.scrollHeight:0,ge?ge.scrollHeight:0),q=this.win.innerHeight}let U=P-q>8,z=F-H>8,Z=I==="auto"||I==="scroll"||I==="overlay",ne=x==="auto"||x==="scroll"||x==="overlay";return{vertical:D?U:U&&Z,horizontal:D?z:z&&ne,byOverflow:Z||ne}}calculateVisibleIntersection(h){let v=Math.max(0,h.left),I=Math.max(0,h.top),x=Math.min(this.viewport.width,h.right),M=Math.min(this.viewport.height,h.bottom),D=Math.max(0,x-v),P=Math.max(0,M-I);return{width:D,height:P,area:D*P}}analyzeTextContent(h,v=2e3){let I=0,x=0,M=h.ownerDocument||this.doc,P=(M.defaultView||this.win).NodeFilter||NodeFilter,q=M.createTreeWalker(h,P.SHOW_ELEMENT|P.SHOW_TEXT,null),F=0,H=q.currentNode,U=[];for(;H&&F<v;){if(H.nodeType===Node.TEXT_NODE){let Q=(H.textContent||"").replace(/\s+/g,"").length;if(Q>0){I+=Q;let ie=H.parentElement;ie&&ie.closest("a")&&(x+=Q)}}else H.nodeType===Node.ELEMENT_NODE&&U.push(H);F++,H=q.nextNode()}let z=U.length||1,Z=I/z,ne=I>0?x/I:0;return{textChars:I,linkChars:x,textDensity:Z,linkDensity:ne}}calculateRepetitionScore(h){let v=Array.from(h.children);if(v.length<3)return 0;let I=v.slice(0,50),x=new Map,M=new Map,D=new Map;for(let se of I){let Q=re(se);if(!$e(se,Q))continue;let ie=se.getBoundingClientRect();if(ie.height<5||ie.width<this.viewport.width*.1)continue;let ce=Math.round(ie.height/10)*10,ge=Math.round(ie.width/10)*10;x.set(ce,(x.get(ce)||0)+1),M.set(ge,(M.get(ge)||0)+1);let ve=(se.className||se.tagName).toString();D.set(ve,(D.get(ve)||0)+1)}let P=I.length||1,q=Math.max(0,...x.values()),F=Math.max(0,...M.values()),H=Math.max(0,...D.values()),U=q/P,z=F/P,Z=H/P,ne=.4*U+.3*z+.3*Z;return Math.min(1,Math.max(0,ne))}calculateSemanticScore(h){let v=0,I=null,x=!1,M=(h.getAttribute("role")||"").toLowerCase(),D=h.tagName.toLowerCase(),P=(h.id||"").toLowerCase(),q=(h.className||"").toLowerCase(),F=`${M} ${D} ${P} ${q}`;return(D==="main"||M==="main")&&(v+=1.2,I="article"),D==="article"&&(v+=1,I=I||"article"),(M==="feed"||F.includes("feed"))&&(v+=1,I="feed"),(M==="log"||F.includes("chat")||F.includes("messages"))&&(v+=1,I="chat"),F.includes("content")&&(v+=.5),(F.includes("results")||F.includes("list"))&&(v+=.4),(F.includes("job")||F.includes("jobs"))&&(v+=.4),(D==="nav"||M==="navigation"||F.includes("sidebar"))&&(v-=1,x=!0),(D==="aside"||M==="complementary")&&(v-=.7,x=!0),(D==="footer"||M==="contentinfo"||F.includes("footer"))&&(v-=.8,x=!0),F.includes("header")&&(v-=.6),v=Math.max(-1,Math.min(1,v)),{semanticScore:v,typeHint:I,navLike:x}}detectScrollListeners(h){return[h.querySelector('[class*="infinite"]'),h.querySelector('[class*="load-more"]'),h.querySelector("[data-infinite]"),h.querySelector('[loading="lazy"]'),h.querySelector(".observer-target"),h.querySelector("[data-scroll]")].some(I=>I!==null)}buildFeatures(h){let v=h.getBoundingClientRect(),I=this.win.getComputedStyle(h),x=this.calculateVisibleIntersection(v),M=this.viewport.width*this.viewport.height||1,D=x.area/M,P=this.viewport.width>0?x.width/this.viewport.width:0,q=v.top+v.height/2,F=this.viewport.height/2||1,H=Math.min(1,Math.abs(q-F)/F),U=this.isScrollable(h),z=this.doc.scrollingElement,Z=h===this.doc.documentElement||h===this.doc.body||!!z&&h===z,ne=h.scrollHeight,se=h.clientHeight;if(Z){let at=this.doc.documentElement,Ze=this.doc.body;ne=Math.max(at?at.scrollHeight:0,Ze?Ze.scrollHeight:0),se=this.win.innerHeight}let Q=Math.max(0,ne-se),ie=Q*x.width,ce=this.analyzeTextContent(h),ge=this.calculateRepetitionScore(h),ve=this.calculateSemanticScore(h),Be=h.contains(this.doc.activeElement),le=this.detectScrollListeners(h),ke=parseInt(I.zIndex||"0",10),We=Number.isFinite(ke)?ke:0;return{geometry:{viewportCoverage:D,widthProminence:P,centerDistance:H,scrollCapacity:Q,scrollSurface:ie,zIndex:We},content:{textDensity:ce.textDensity,linkDensity:ce.linkDensity,repetitionScore:ge,semanticScore:ve.semanticScore},interaction:{hasScrollListeners:le,hasFocus:Be,recentActivity:Be?1:0}}}inferElementType(h,v,I,x){if(I)return I;let M=(h.getAttribute("role")||"").toLowerCase(),D=(h.className||"").toLowerCase(),P=h.tagName.toLowerCase(),q=v.geometry,F=v.content;if(M==="log"||D.includes("chat")||D.includes("messages"))return"chat";let H=this.win.getComputedStyle(h);if((H.position==="fixed"||H.position==="absolute")&&q.zIndex>100&&q.viewportCoverage>.2&&q.centerDistance<.4)return"modal";if(M==="feed"||F.repetitionScore>.3&&q.scrollCapacity>400&&q.widthProminence>=.25)return"feed";if(P==="article"||F.textDensity>40&&F.linkDensity<.4&&q.widthProminence>.4)return"article";if(x||q.widthProminence<.3&&F.linkDensity>.3)return"sidebar";let z=this.doc.scrollingElement;return h===this.doc.documentElement||h===this.doc.body||z&&h===z?"document":"unknown"}scoreCandidates(h){let v=[],I=[],x=[],M=[],D=[],P=[];for(let Z of h){let ne=this.buildFeatures(Z),se=ne.content.semanticScore,Q=this.calculateSemanticScore(Z),ie=this.inferElementType(Z,ne,Q.typeHint,Q.navLike);P.push({element:Z,features:{geometry:{...ne.geometry},content:{...ne.content,semanticScore:Q.semanticScore},interaction:ne.interaction},type:ie,navLike:Q.navLike,semanticScore:Q.semanticScore}),I.push(ne.geometry.scrollSurface),x.push(ne.content.textDensity),M.push(Math.abs(Q.semanticScore)),D.push(ne.content.repetitionScore)}let q=Math.max(0,...I),F=Math.max(0,...x),H=Math.max(0,...M),U=Math.max(0,...D),z=-1/0;for(let Z of P){let{element:ne,features:se,type:Q,navLike:ie,semanticScore:ce}=Z,ge=se.geometry,ve=se.content,Be=se.interaction,le=q>0?ge.scrollSurface/q:0,ke=F>0?ve.textDensity/F:0,We=H>0?(ce/H+1)/2:.5,at=Q==="feed"||ve.repetitionScore>.3&&ge.scrollCapacity>400,Ze=ve.linkDensity>.5?(ve.linkDensity-.5)/.5:0,qe=at?0:Ze,ct=(at?1:.5)*ve.repetitionScore*Math.min(1,ge.scrollCapacity/4e3),pt={feed:.2,chat:.2,article:.08,modal:.08,document:.05,sidebar:-.12,unknown:0}[Q]||0,ye=0;ye+=ge.viewportCoverage*.18,ye+=ge.widthProminence*.15,ye+=(1-ge.centerDistance)*.07,ye+=le*.22,ye+=ct*.18,ye+=ke*.08,ye+=(U>0?ve.repetitionScore/U:0)*.05,ye+=We*.07,ye-=qe*.05,Be.hasFocus&&(ye+=.05),Be.hasScrollListeners&&(ye+=.05),ye+=pt,ie&&(ye-=.05);let ht=Math.max(0,Math.min(1,ye));ht>z&&(z=ht),v.push({element:ne,selector:or(ne,G(ne)),score:ht,features:se,type:Q})}if(v.sort((Z,ne)=>ne.score-Z.score),v.length>=2){let Z=v[0],ne=v[1];Math.abs(Z.score-ne.score)<.08&&Z.type==="article"&&ne.type==="feed"&&(v[0]=ne,v[1]=Z)}return v}getScrollContext(h){let v=document.scrollingElement;return h===document.documentElement||h===document.body||!!v&&h===v?{target:v||document.documentElement||document.body,isRoot:!0}:{target:h,isRoot:!1}}async scrollToDirection(h,v){let I=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!I)return{success:!1,error:"No scrollable element found"};let{target:x,isRoot:M}=this.getScrollContext(I),D=G(x),P=X(D),q=v?.isTabActive??!D.hidden,F=v?.behavior,H=q&&F==="smooth",U=M?Math.max(D.documentElement?D.documentElement.scrollHeight:0,D.body?D.body.scrollHeight:0):x.scrollHeight,z=M?P.innerHeight:x.clientHeight,Z=Math.max(0,U-z),ne=()=>M?P.scrollY:x.scrollTop,se=Q=>{if(H)try{M?P.scrollTo({top:Q,behavior:"smooth"}):x.scrollTo({top:Q,behavior:"smooth"})}catch{M?(D.scrollingElement||D.documentElement||D.body).scrollTop=Q:x.scrollTop=Q}else if(M){let ie=D.scrollingElement||D.documentElement||D.body;ie.scrollTop=Q}else x.scrollTop=Q};switch(h){case Fe.TOP:return se(0),{success:!0,scrollTop:0,isAtTop:!0};case Fe.BOTTOM:return se(Z),{success:!0,scrollTop:Z,isAtBottom:!0};default:return{success:!1,error:`Unknown direction: ${h}`}}}async scrollByAmount(h,v){let I=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!I)return{success:!1,error:"No scrollable element found"};let{target:x,isRoot:M}=this.getScrollContext(I),D=v?.isTabActive??!document.hidden,P=v?.behavior,q=D&&P==="smooth",F=Yt(),H=M&&F?F.innerHeight:x.clientHeight,U=M&&F?F.innerWidth:x.clientWidth,z=v?.amount??H*.8,Z=M?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):x.scrollHeight,ne=M&&F?F.innerHeight:x.clientHeight,se=Math.max(0,Z-ne),Q=ce=>{if(q)try{M?F?.scrollTo({top:ce,behavior:"smooth"}):x.scrollTo({top:ce,behavior:"smooth"})}catch{let ge=document.scrollingElement||document.documentElement||document.body;ge.scrollTop=ce}else{let ge=M?document.scrollingElement||document.documentElement||document.body:x;ge.scrollTop=ce}},ie=ce=>{if(q)try{x.scrollBy({left:ce,behavior:"smooth"})}catch{x.scrollLeft+=ce}else x.scrollLeft+=ce};switch(h){case Fe.DOWN:{let ge=(M&&F?F.scrollY:x.scrollTop)+z;Q(ge);let ve=M&&F?F.scrollY:x.scrollTop;return{success:!0,scrollTop:ve,isAtTop:ve<=5,isAtBottom:ve>=se-5}}case Fe.UP:{let ce=M&&F?F.scrollY:x.scrollTop,ge=Math.max(0,ce-z);Q(ge);let ve=M&&F?F.scrollY:x.scrollTop;return{success:!0,scrollTop:ve,isAtTop:ve<=5,isAtBottom:ve>=se-5}}case Fe.LEFT:{let ce=-(v?.amount??U*.8);return ie(ce),{success:!0,scrollLeft:x.scrollLeft}}case Fe.RIGHT:{let ce=v?.amount??U*.8;return ie(ce),{success:!0,scrollLeft:x.scrollLeft}}default:return{success:!1,error:`Unknown direction: ${h}`}}}normalizeScrollPosition(h){switch(h){case rt.START:return"start";case rt.END:return"end";case rt.NEAREST:return"nearest";case rt.CENTER:default:return"center"}}getScrollContainerForElement(h){let v=document.scrollingElement,I=h;for(;I&&I!==document.body&&I!==document.documentElement;){let D=getComputedStyle(I).overflowY,P=D==="auto"||D==="scroll"||D==="overlay",q=I.scrollHeight-I.clientHeight>8;if(P&&q)return{container:I,isRoot:!1};I=I.parentElement}return{container:v||document.documentElement||document.body,isRoot:!0}}scrollElementIntoView(h,v,I){let x=document.querySelector(h);if(!x)return{success:!1,error:`Element not found for selector: ${h}`};let{container:M,isRoot:D}=this.getScrollContainerForElement(x),P=re(M),q=P?.DOMRect||DOMRect,F=D?new q(0,0,P.innerWidth??0,P.innerHeight??0):M.getBoundingClientRect(),H=x.getBoundingClientRect(),U=24,z=H.top>=F.top+U&&H.bottom<=F.bottom-U,Z=I?.isTabActive??!document.hidden,ne=I?.behavior,se=Z&&ne==="smooth",Q=this.normalizeScrollPosition(v);if(v===rt.NEAREST&&z)return{success:!0,alreadyVisible:!0,...this.getScrollMetricsForContainer(M,D)};try{x.scrollIntoView({behavior:se?"smooth":"auto",block:Q,inline:"nearest"})}catch{x.scrollIntoView()}let ie=this.getScrollMetricsForContainer(M,D);return{success:!0,position:Q,...ie}}getScrollMetricsForContainer(h,v){let I=v?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):h.scrollHeight,x=G(h),M=re(h),D=v&&M?M.innerHeight:h.clientHeight,P=Math.max(0,I-D),F=(v?x.scrollingElement||x.documentElement||x.body:h).scrollTop;return{scrollTop:F,scrollHeight:I,clientHeight:D,maxScroll:P,isAtTop:F<=5,isAtBottom:F>=P-5,scrollPercentage:P>0?F/P*100:0}}getScrollMetrics(){let h=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!h)return null;let{target:v,isRoot:I}=this.getScrollContext(h),x=G(v),M=X(x),D=I?Math.max(x.documentElement?x.documentElement.scrollHeight:0,x.body?x.body.scrollHeight:0):v.scrollHeight,P=I?M.innerHeight:v.clientHeight,q=Math.max(0,D-P),H=(I?x.scrollingElement||x.documentElement||x.body:v).scrollTop;return{element:or(v,x),scrollTop:H,scrollHeight:D,clientHeight:P,maxScroll:q,isAtTop:H<=5,isAtBottom:H>=q-5,scrollPercentage:q>0?H/q*100:0}}}let o=new r;window[e]=o;let s={execute:_=>o.execute(_)};try{Object.defineProperty(window,t,{value:s,writable:!1,configurable:!1,enumerable:!1})}catch{try{window[t]=s}catch{}}let i=window.__RTRVR_INTERNAL_KEY__||n,c=window[i],d=c&&typeof c=="object"?c:null;if(d){try{d.scroll=d.scroll||s}catch{}try{d.scroll||Object.defineProperty(d,"scroll",{value:s,writable:!1,configurable:!1,enumerable:!1})}catch{}}if(i!==n)try{!window[n]&&d&&Object.defineProperty(window,n,{value:d,writable:!1,configurable:!1,enumerable:!1})}catch{}})();var lu=/\[id=(\d+)\]/,Ge;(function(e){e.HTML="html",e.PDF="pdf",e.GOOGLE_DOC="google_doc",e.GOOGLE_SHEET="google_sheet",e.PLAIN_TEXT="plain_text"})(Ge||(Ge={}));var Na=new Map;function uu(e){let t={};for(let n of Object.keys(e)){let r=e[Number(n)],o=r?.preservedAttributes?.[gt["rtrvr-label"]],s=r?.resourceLocator;if(typeof o=="string"&&typeof s=="string"){let i=o.match(lu);if(i?.[1]){let c=Number(i[1]);Number.isFinite(c)&&(t[c]=s)}}}return t}async function Ua(e,t,n={}){let r=e.ownerDocument||document,o=n.pageConfig||go,s=String(r.contentType||"").trim().toLowerCase(),i=pu(s,r),c=fu(i.documentType,s),d={url:r.URL,title:r.title,contentType:c},_=du(o);if(i.documentType!==Ge.HTML){let D=Number(o?.pageDataTimeoutMs),P=Number.isFinite(D)?Math.max(200,Math.floor(D)):9e3,q=Math.max(200,Math.min(P,It(_))),F=bu(r,i.documentType,o,_),H=await rr(F,q,r);if(!H.ok)return{...d,content:"",error:`non_html_timeout:${c}`,metadata:{extractionMethod:"timeout"}};let U=H.value||{},z=i.documentType===Ge.GOOGLE_SHEET?Yu(r):void 0;return{...d,...U,contentType:U.contentType||d.contentType,sheetInfo:U.sheetInfo||z}}if(o?.onlyTextContent)return{...d,contentType:tr,content:To(r)};let h=Math.max(0,Math.min(3e3,It(_))),v=performance.now(),I=!1;if(!o?.disableAutoScroll&&h>80){let D=r.hidden?900:1500,P=Math.min(D,h);P>80&&(I=await $u(r,{profile:"light",timeBudgetMs:P,delayMs:r.hidden?0:160,finalWaitMs:r.hidden?0:200}))}let x=Math.max(0,h-(performance.now()-v));x>80&&await qu(r,{mode:"full",totalBudgetMs:Math.min(r.hidden?1400:1200,x),budgetMs:Math.min(r.hidden?650:850,x),maxPasses:r.hidden?1:2});let M=wo(e,t,{includeFrames:n.includeFrames??!0,disableDomAnnotations:n.disableDomAnnotations??!0});return yu(M.rootNodes,M.semanticNodes)?{...d,contentType:tr,content:To(r),metadata:{scrollingPerformed:I}}:{...d,contentType:tr,roots:M.rootNodes,nodes:M.semanticNodes,elementLinkRecord:uu(M.semanticNodes),metadata:{scrollingPerformed:I}}}function du(e){let t=Number(e?.deadlineEpochMs);if(Number.isFinite(t)&&t>0)return t;let n=Number(e?.totalBudgetMs),r=Number.isFinite(n)?Math.max(1500,Math.floor(n)):9e3;return Date.now()+r}function fu(e,t){switch(e){case Ge.PDF:return vs;case Ge.GOOGLE_DOC:return xs;case Ge.GOOGLE_SHEET:return _s;case Ge.PLAIN_TEXT:return bo;case Ge.HTML:default:return t||tr}}function pu(e,t){let n=e||String(t.contentType||"").toLowerCase();return xa(n)?{documentType:Ge.PDF}:hu(t)&&(gu(t)||mu(t.URL))?{documentType:Ge.PDF}:Su(t)?{documentType:Ge.GOOGLE_DOC}:Au(t)?{documentType:Ge.GOOGLE_SHEET}:n.includes(bo)?{documentType:Ge.PLAIN_TEXT}:{documentType:Ge.HTML}}function hu(e){try{let t=vu(e);return Rs(t)?!0:!!t.querySelector?.('object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]')}catch{return!1}}function mu(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 gu(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 bu(e,t,n,r){switch(t){case Ge.PDF:return Eu(e,n,r);case Ge.GOOGLE_DOC:return wu(e);case Ge.GOOGLE_SHEET:return Bu(e,n);case Ge.PLAIN_TEXT:return{content:To(e),contentType:bo};case Ge.HTML:default:return{content:To(e),contentType:tr}}}async function Eu(e,t,n){It(n)>ys+50&&await Ra(ys,e,n);let o=(()=>{let h=Number(t?.pdfTextSelectionTimeoutMs),v=go.pdfTextSelectionTimeoutMs;return Number.isFinite(h)?Math.max(150,Math.floor(h)):v})(),s=It(n),c=Number.isFinite(s)?Math.max(150,Math.min(o,Math.max(0,s-150))):o,d=await Tu(e,c),_=!!d.success&&!!(d.data||"").trim();return{content:_&&d.data||"",contentType:vs,error:_?void 0:`pdf_extraction_failed:${d.reason||"unknown"}`}}async function wu(e){return{content:Pu(),contentType:xs}}function yu(e,t){return!Array.isArray(e)||e.length===0||!t||Object.keys(t).length===0}function To(e){return e.body?.innerText||e.body?.textContent||e.documentElement?.innerText||e.documentElement?.textContent||""}function vu(e){try{let t=e.defaultView||window,n=t.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",o=t[n]?.shadow?.getRoot;if(typeof o=="function"){let s=o(e.body||e.documentElement);if(s)return s}}catch{}return e}function _u(e){let t=e.URL||"";try{let n=new URL(t),r=n.searchParams.get("file")||n.searchParams.get("src")||"";return r||t}catch{return t}}async function Tu(e,t){let n=Number.isFinite(t)&&t>0?Math.floor(t):go.pdfTextSelectionTimeoutMs,r=_u(e),o=Na.get(r)??"";if(o.trim().length>0)return{success:!0,data:o,reason:"ok"};let s=await xu(e,n);return s.success&&s.data.trim()&&Na.set(r,s.data),s}async function xu(e,t){let n=e.defaultView||window,r=Ru(e);if(!r||typeof r.postMessage!="function")return{success:!1,data:"",reason:"no_viewer"};let o=globalThis.crypto&&"randomUUID"in globalThis.crypto?globalThis.crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`,s=!1,i="",c=h=>{if(s||!ku(String(h.origin||""),e))return;let v=h.data;Iu(v,o)&&typeof v.selectedText=="string"&&v.selectedText.trim().length>0&&(i=v.selectedText,s=!0)};n.addEventListener("message",c);try{r.postMessage({type:"selectAll",requestId:o},"*")}catch{}let d=Date.now();for(;!s&&Date.now()-d<t;){try{r.postMessage({type:"getSelectedText",requestId:o},"*")}catch{}if(await Je(200,e),i.trim()){s=!0;break}}return n.removeEventListener("message",c),i.trim()?{success:!0,data:i,reason:"ok"}:{success:!1,data:"",reason:Date.now()-d>=t?"timeout":"no_response"}}function Ru(e){let t=Rs(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 ku(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 r=new URL(t.URL||"").origin.toLowerCase();if(r&&n===r)return!0}catch{}return!1}function Iu(e,t){return!(!e||typeof e!="object"||e.type!=="getSelectedTextReply"||typeof e.selectedText!="string"||e.requestId&&e.requestId!==t)}function Su(e){try{let t=e.defaultView||Yt();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 sr(e)!==null}function Au(e){let n=(e.defaultView||Yt())?.location.href??"";return/^https:\/\/docs\.google\.com\/spreadsheets\/(?:u\/\d+\/)?d\/[a-zA-Z0-9_-]+/.test(n)}function Cu(e){try{return e.defaultView?.top?.document??e}catch{return e}}function xo(e){let t=[e],n=Cu(e);return n!==e&&t.push(n),t}var Mu=".docs-texteventtarget-iframe",Lu=".kix-cursor",Nu=".docos-replyview-body",Du=".docos-replyview",Ou=".docos-author",Pa="\u200B",Fu="\xA0";function sr(e){for(let t of xo(e)){let n=t.querySelector(Mu);if(n)return n}return null}function Hu(e){for(let t of xo(e)){let n=t.querySelector(Lu);if(n)return n}return null}function yo(e){let t=Hu(e);return t?(t.ownerDocument?.defaultView?.getComputedStyle(t).display??t.style.display)==="none":!1}function vo(e,t){let n=sr(e);if(!n)return;let r=t?"ArrowUp":"ArrowDown",s={key:r,keyCode:t?38:40,altKey:!0,shiftKey:!0,code:r,bubbles:!0,cancelable:!0},i=n.contentDocument,c=n.contentWindow;if(!i)return;let d=c?.KeyboardEvent||KeyboardEvent;i.dispatchEvent(new d("keydown",s))}function Da(e){let t=sr(e);if(!t)return;let n={key:"ArrowLeft",keyCode:37,code:"ArrowLeft",bubbles:!0,cancelable:!0},r=t.contentDocument,o=t.contentWindow;if(!r)return;let s=o?.KeyboardEvent||KeyboardEvent;r.dispatchEvent(new s("keydown",n))}function Uu(e){let t=sr(e);if(!t)return;let r=(typeof navigator<"u"?String(navigator.platform||""):"").toUpperCase().indexOf("MAC")>=0,o={key:"a",code:"KeyA",ctrlKey:!r,metaKey:r,bubbles:!0,cancelable:!0},s=t.contentDocument,i=t.contentWindow;if(!s)return;let c=i?.KeyboardEvent||KeyboardEvent;s.dispatchEvent(new c("keydown",o))}function _o(e){let t=sr(e);if(!t)return"";let n=t.contentDocument,r=t.contentWindow,o=n?.body;if(!n||!o)return"";try{let c=r?.ClipboardEvent||ClipboardEvent,d=new c("copy",{bubbles:!0,cancelable:!0});o.firstChild?.dispatchEvent?.(d),o.firstChild?.dispatchEvent||o.dispatchEvent(d)}catch{}let s=o.innerText||o.textContent||"";return String(s).replace(new RegExp(Pa,"g"),"")??""}function Cs(e){let t=`
|
|
3
3
|
|
|
4
4
|
Comments: `,n=new Set,r=[];for(let s of xo(e))try{let i=Array.from(s.querySelectorAll(Nu));for(let c of i)n.has(c)||(n.add(c),r.push(c))}catch{}let o=r.filter(s=>s.textContent);if(o.length===0)return"";for(let s of o){let i=s.closest(Du);if(!i)continue;let c=i.querySelector(Ou);c&&c.textContent&&(t+=`
|
|
5
5
|
Author: ${c.textContent} `),s.textContent&&(t+=`Comment: ${s.textContent}
|
|
6
|
-
`)}return t.trim()}function Pu(){let e=
|
|
6
|
+
`)}return t.trim()}function Pu(){let e=ze()||document,t=sr(e),n=t?.contentDocument,r=t?.contentWindow,o=()=>{let s=n?.body,i=ze(),c=s?.innerText||s?.textContent||""||i?.body?.innerText||i?.body?.textContent||"";return String(c).replace(new RegExp(Pa,"g"),"")+Cs(e)};try{try{r?.focus(),n?.body?.focus?.()}catch{}if(Uu(e),yo(e)){let d=_o(e);if(d.trim()!==""){let _=Cs(e).trim();return d+_}else Da(e)}let s="";if(vo(e,!0),yo(e)){let d=_o(e);d.endsWith(`
|
|
7
7
|
|
|
8
|
-
`)||(s+=
|
|
9
|
-
`)&&vo(e,!1):vo(e,!1),yo(e)){let
|
|
10
|
-
`)&&(s+=f)}Da(e);let i=Cs(e).trim(),c=s.trim()+i;return c.trim()?c:o()}catch{return o()}}async function Bu(e,t){let n="",r;Ba(e,e.defaultView||window);let o=Ct(t?.deadlineEpochMs);try{let s=Math.max(250,Math.min(1500,Math.floor(o*.45))),i=await Zn(Wu(e),s,e);if(!(i.ok&&i.value))throw new Error("google_sheet_copy_failed");let f=Ct(t?.deadlineEpochMs),v=Math.max(250,Math.min(2500,Math.floor(f*.55)));if(n=await Vu(v,e),!n.trim())throw new Error("google_sheet_empty_clipboard")}catch(s){r=s instanceof Error?s.message:String(s)}return{content:n,contentType:_s,error:r}}function Ba(e,t){try{t?.focus?.()}catch{}try{e?.body?.focus?.()}catch{}}function Ms(e,t){let r=e.defaultView?.KeyboardEvent||KeyboardEvent,o=new r("keydown",{bubbles:!0,cancelable:!0,...t}),s=e.activeElement;(s&&s.ownerDocument===e?s:e).dispatchEvent(o)}async function Wu(e){try{if(Ba(e,e.defaultView||window),e.hidden||!e.hasFocus())return!1;Ms(e,{key:"Escape",code:"Escape"}),await et(150,e);let t=e.querySelector(".grid-container")||Oa(e,".grid-container"),n=e.querySelector(".grid4-inner-container:last-child")||Oa(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 o=(typeof navigator<"u"?String(navigator.platform||""):"").toUpperCase().indexOf("MAC")>=0;Ms(e,{key:"a",code:"KeyA",ctrlKey:!o,metaKey:o}),await et(200,e),Ms(e,{key:"c",code:"KeyC",ctrlKey:!o,metaKey:o}),await et(200,e);try{e.execCommand("copy")}catch{}return!0}catch{return!1}}async function Vu(e,t){let n=Math.max(250,Math.min(5e3,Math.floor(e)));if(navigator?.clipboard?.readText){let s=await Zn(navigator.clipboard.readText(),n,t);if(s.ok)return s.value||""}let r=t.createElement("textarea");r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",r.style.left="-9999px",r.style.top="0",t.body?.appendChild(r),r.focus();try{t.execCommand("paste")}catch{}let o=r.value||"";return r.remove(),o}function Oa(e,t){let n=xo(e);for(let c of n)try{let f=c.querySelector(t);if(f)return f}catch{}let r=25e3,o=0,s=(c,f)=>{if(!f)return;let v=f.children;if(v)for(let b=0;b<v.length;b++)c.push(v[b])},i=[];for(let c of n)try{s(i,c.documentElement??c.body??null)}catch{}for(;i.length&&o<r;){let c=i.pop();o++;try{if(c.matches(t))return c}catch{}s(i,c);let f=c.shadowRoot;if(f&&s(i,f),String(c.tagName).toUpperCase()==="IFRAME")try{let b=c.contentDocument;b&&s(i,b.documentElement??b.body??null)}catch{}}return null}async function $u(e,t){let n=t?.profile??"light",r=!e.hidden,o=Math.max(0,Math.min(t?.timeBudgetMs??(n==="light"?1600:2800),3e3));if(o<=0)return!1;let s=Date.now(),i=()=>o-(Date.now()-s),c=t?.delayMs??(n==="light"?220:280),f=t?.finalWaitMs??(n==="light"?350:900),v=r?c:0,b=r?f:0,w=t?.amount,I=t?.maxSteps??(n==="light"?8:18),x=t?.maxDistancePx??(n==="light"?12e3:3e4),A=null;try{let F=await Fa(e,{action:"detectPrimary"});if(F?.selector){let U=Gu(e,F.selector);U&&(A=U)}let H=F?.metrics;if(H&&typeof H.scrollHeight=="number"&&typeof H.clientHeight=="number"){let U=Math.max(0,H.scrollHeight-H.clientHeight);x=Math.min(x,U||x),U<1500?I=Math.min(I,2):U<4e3?I=Math.min(I,4):U<1e4&&(I=Math.min(I,6))}}catch{}if(A||(A=e.scrollingElement||e.documentElement||e.body),!A)return!1;let D=0,P=null,q=0;for(let F=0;F<I&&!(i()<=0);F++){let H=null;try{H=await Fa(e,{action:"scrollBy",direction:Ne.DOWN,options:{amount:w,behavior:"auto",isTabActive:r}})}catch{}if(!H||!H.success){let X=e.defaultView||window;H=Eo(A,e,X,Ne.DOWN,w),q=2}if(!H?.success)break;let U=H.scrollTop??P??0;if(P!==null){let X=Math.max(0,U-P);D+=X,q=X===0?q+1:0}if(P=U,H.isAtBottom||q>=2||D>=x)break;if(v>0&&F<I-1){let X=Math.min(v,Math.max(0,i()));if(X<=0)break;await et(X,e)}}if(b>0){let F=Math.min(b,Math.max(0,i()));F>0&&await et(F,e)}if(i()>80)try{let F=e.scrollingElement||e.documentElement||e.body,H=e.defaultView||window,U=A===e.documentElement||A===e.body||A===F?F:A;if(U){let X=U===F?H.innerHeight:U.clientHeight||H.innerHeight,Z=Math.max(0,U.scrollHeight-X);U.scrollTop=Z}}catch{}return!0}function Gu(e,t){try{return e.querySelector(t)}catch{return null}}async function Fa(e,t){let n=e.defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",i=(n[r]?.scroll||n.__RTRVR_SCROLL_API__)?.execute;return typeof i!="function"?null:i(t)}async function qu(e,t){let n=e.defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",s=n[r]?.flushScan;if(typeof s!="function"){try{n.rtrvrAIMarkInteractiveElements?.()}catch{}return}let i=Date.now()+Math.max(100,Math.floor(t.totalBudgetMs)),c=0;for(;c<t.maxPasses&&Ct(i)>0;){let f=Math.max(50,Math.min(t.budgetMs,Ct(i)));try{await s({mode:t.mode??"full",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:f,deadlineEpochMs:i})}catch{break}if(Ha(e)===0)break;c++}if(Ha(e)>0&&Ct(i)>50){let f=Math.min(120,Ct(i));try{await s({mode:"priority",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:f,deadlineEpochMs:i})}catch{}}}function Ha(e){let t=e.documentElement;if(!t)return 0;let n=t.getAttribute(mr);if(!n)return 0;let r=Number.parseInt(n,10);return Number.isFinite(r)&&r>0?r:0}function Yu(e){let t=Xu(e.URL||"");if(!t?.sheetId)return;let n=zu(e),r=n?.title||"Sheet1";return{sheetId:t.sheetId,sheetTitle:e.title||n?.title||void 0,sheetTab:r,sheetTabId:t.sheetTabId??n?.id,sheetTabs:void 0}}function Xu(e){if(!e)return null;try{let t=new URL(e);if(t.hostname!=="docs.google.com")return null;let n=t.pathname.split("/"),r=n.indexOf("spreadsheets"),o=n.indexOf("d");if(r===-1||o===-1||o!==r+1||n.length<=o+1)return null;let s=n[o+1];if(!s||!/^[a-zA-Z0-9_-]+$/.test(s))return null;let i;return t.hash&&t.hash.includes("gid=")&&(i=new URLSearchParams(t.hash.substring(1)).get("gid")??void 0),!i&&t.searchParams.has("gid")&&(i=t.searchParams.get("gid")??void 0),i&&!/^\\d+$/.test(i)&&(i=void 0),{sheetId:s,sheetTabId:i?parseInt(i,10):0}}catch{return null}}function zu(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,r=t.getAttribute("data-sheet-id")||t.getAttribute("data-tab-id")||void 0,o=r&&/^\d+$/.test(r)?Number(r):void 0;return{title:n,id:o}}catch{return null}}var Rt;(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"})(Rt||(Rt={}));var ju={native:Rt.Native,inline:Rt.Inline,react:Rt.React,vue:Rt.Vue,angular:Rt.Angular,svelte:Rt.Svelte,jquery:Rt.JQuery,delegated:Rt.Delegated,other:Rt.Other};(()=>{let e=window,t="__RTRVR_MAIN_WORLD_INITIALIZED__",n=new WeakMap,r={frameworks:new Set,reactRoots:new WeakSet,vueRoots:new WeakSet,angularRoots:new WeakSet,svelteRoots:new WeakSet,jqueryRoots:new WeakSet},o=new WeakMap,s=new WeakMap,i=new Set,c=500,f=200,v=0,b=0,w=new WeakSet,I="__RTRVR_ET_HOOKED__",x="__RTRVR_ATTACH_SHADOW_HOOKED__";function A(l){if(l&&!w.has(l)){w.add(l);try{D(l)}catch{}try{P(l)}catch{}}}function D(l){try{let E=l.EventTarget;if(!E?.prototype||E.prototype[I])return;E.prototype[I]=!0;let R=E.prototype.addEventListener,T=E.prototype.removeEventListener;E.prototype.addEventListener=function(k,N,V){try{ir(N)||wt(this,k,V)}catch{}return R.call(this,k,N,V)},E.prototype.removeEventListener=function(k,N,V){try{Kt(this,k,V)}catch{}return T.call(this,k,N,V)};try{let k=Function.prototype.toString;E.prototype.addEventListener.toString=()=>k.call(R),E.prototype.removeEventListener.toString=()=>k.call(T)}catch{}}catch{}}function P(l){try{let E=l.Element;if(!E?.prototype?.attachShadow||E.prototype[x])return;E.prototype[x]=!0;let R=E.prototype.attachShadow;E.prototype.attachShadow=function(T){let k=R.call(this,T);try{Ye.set(this,k)}catch{}try{ee(k)}catch{}return k};try{let T=Function.prototype.toString;E.prototype.attachShadow.toString=()=>T.call(R)}catch{}}catch{}}function q(l){let R=n.get(l)?.listenerTypeMasks;if(R&&R.size){let T=[];for(let k of R.keys()){let N=Qt[k];N&&T.push(N)}return T}return fr(l)}let F=["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"],H=0,U=new Set,X=6,Z=["click","input","change","keydown","keyup","pointerdown","pointerup","submit","focus","blur"],te=["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 oe={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(l){return l?String(l).split(".")[0].toLowerCase():""}let se=["data-click","data-action","data-event","data-handler","data-on-click","data-onclick","data-tap","data-press","data-toggle","data-target"],ae=0,me=null,ye=new MessageChannel,Me=[];ye.port1.onmessage=()=>{let l=Me.shift();l&&l()};function pe(){return Date.now()}function Ie(l){return!l||!Number.isFinite(l)?Number.POSITIVE_INFINITY:Math.max(0,l-pe())}let ot=8,Ge=new MessageChannel,Ue=!1;function pt(){if(!Ue){Ue=!0;try{Ge.port2.postMessage(0)}catch{}}}function ke(l){let E=l.values().next();if(E.done)return null;let R=E.value;return l.delete(R),R}function bt(){return new Promise(l=>{Me.push(l),ye.port2.postMessage(0)})}let Ke=!1;function Te(){if(!Ke)try{let l=e.jQuery;l&&l.fn&&(Wt(l),Ke=!0,qe("jquery"))}catch{}}function Et(l,E){for(let R=E.lastElementChild;R;R=R.previousElementSibling)l.push(R)}function hn(l,E,R){if(R)try{let T=ue(E);T&&l.push(T)}catch{}}function mn(l,E,R){if(R&&dr(E))try{let T=E.contentWindow||null;T&&A(T);let k=T?.document?.documentElement;k&&l.push(k)}catch{}}let Mt=new WeakSet;function Oe(l){l&&(typeof l=="function"||typeof l=="object")&&Mt.add(l)}function ir(l){return!!l&&(typeof l=="function"||typeof l=="object")&&Mt.has(l)}Ge.port1.onmessage=()=>{Ue=!1,jt(500);let l=performance.now();for(;U.size&&performance.now()-l<ot;){let E=ke(U);if(!E)break;try{M(E)}catch{}finally{H=Math.max(0,H-1)}}for(;i.size&&performance.now()-l<ot;){let E=ke(i);if(!E)break;try{St(E)}catch{}}ct(),(U.size||i.size)&&pt()};function ct(){try{let l=Xe()?.documentElement;if(!l)return;l.setAttribute(mr,String(H))}catch{}}function Bt(l){let E=n.get(l);return E||(E={frameworks:new Set,listeners:new Map},n.set(l,E)),E}function zt(l){i.add(l),pt()}function Lt(l){U.has(l)||(U.add(l),H++,ct(),pt(),U.size>8e3&&jt(3e3))}function jt(l=2e3){let E=0;for(let R of U){if(E>l)break;R.isConnected||(U.delete(R),H=Math.max(0,H-1))}E=0;for(let R of i){if(E>l)break;R.isConnected||i.delete(R)}ct()}let Fe=null;function gn(l,E,R){return`${l}|${E?1:0}|${R?1:0}`}function Nt(l){let E=l.tagName;if(E==="A"||E==="BUTTON"||E==="INPUT"||E==="SELECT"||E==="TEXTAREA"||E==="SUMMARY"||l.hasAttribute("role")||l.hasAttribute("tabindex")||l.hasAttribute("contenteditable")||l.hasAttribute("onclick")||l.getAttributeNames().some(R=>R.startsWith("on")))return!0;for(let R of se)if(l.hasAttribute(R))return!0;return!!(l.hasAttribute("aria-haspopup")||l.hasAttribute("aria-expanded"))}function ht(l){let E=re(l);if(!We(l,E))return!1;let R=l.tagName;if(R!=="DIV"&&R!=="SPAN"&&R!=="LI"&&R!=="SECTION"&&R!=="ARTICLE"&&R!=="P")return!1;let T=l;if(T.__ngContext__||T.__svelte__||T.__vue__||T._vnode||T.__reactFiber$||T.__reactProps$)return!0;let k=0;for(let N in T){if(++k>30)break;if(N.startsWith("__react")||N.includes("reactFiber")||N.includes("reactProps"))return!0}return!1}function Dt(){let l=Xe()?.documentElement;return l?r.frameworks.size>0||l.hasAttribute("rtrvr-react")||l.hasAttribute("rtrvr-vue")||l.hasAttribute("rtrvr-angular")||l.hasAttribute("rtrvr-svelte")||l.hasAttribute("rtrvr-jquery"):!1}function on(l){let E=performance.now();for(;U.size&&performance.now()-E<l;){let R=ke(U);if(!R)break;try{M(R)}catch{}finally{H=Math.max(0,H-1)}}for(;i.size&&performance.now()-E<l;){let R=ke(i);if(!R)break;try{St(R)}catch{}}}async function bn(l={}){jt(3e3),Te(),be();let E=l.mode??"full",R=l.includeShadow??!0,T=l.includeSameOriginIframes??!0,k=Math.max(50,Math.min(l.budgetMs??2500,15e3)),N=l.deadlineEpochMs,V=Math.max(0,Math.min(k,Ie(N))),j=gn(E,R,T);if(V<=0){let Je=(Fe?.stack?.length??0)+U.size+i.size;return{revision:++ae,scanned:0,durationMs:0,done:Je===0,remaining:Je}}if((!Fe||Fe.optsKey!==j)&&Ie(N)>30&&await z({budgetMs:18,deadlineEpochMs:N}),E==="priority"){let Je=performance.now(),Le=0;for(;U.size&&performance.now()-Je<=V&&!(N&&Ie(N)<=0);){let He=ke(U);if(!He)break;try{M(He)}catch{}Le++,H=Math.max(0,H-1)}for(;i.size&&performance.now()-Je<=V&&!(N&&Ie(N)<=0);){let He=ke(i);if(!He)break;try{St(He)}catch{}}return ct(),{revision:++ae,scanned:Le,durationMs:performance.now()-Je,done:U.size===0&&i.size===0,remaining:U.size+i.size}}if(!Fe||Fe.optsKey!==j){let Je=Xe()?.documentElement;Fe={optsKey:j,stack:Je?[Je]:[],scannedTotal:0}}let ve=performance.now(),Re=0;for(H++,ct();Fe.stack.length&&!(N&&Ie(N)<=0);){let Je=Fe.stack.pop();if(Tt(Je)){let He=Je.children;for(let yn=He.length-1;yn>=0;yn--)Fe.stack.push(He[yn]);continue}let Le=Je;if(!(!Le||Le.nodeType!==1)&&!(Le.tagName==="SCRIPT"||Le.tagName==="STYLE"||Le.tagName==="META"||Le.tagName==="NOSCRIPT")){try{(Nt(Le)||Dt()&&ht(Le))&&M(Le)}catch{}try{St(Le)}catch{}if(U.delete(Le)&&(H=Math.max(0,H-1)),i.delete(Le),Re++,Fe.scannedTotal++,R)try{let He=ue(Le);He&&(ee(He),Fe.stack.push(He))}catch{}if(T&&dr(Le))try{let He=Le.contentWindow||null;He&&A(He);let yn=He?.document,ti=yn?.documentElement;yn&&ti&&(ce(yn),Fe.stack.push(ti))}catch{}for(let He=Le.lastElementChild;He;He=He.previousElementSibling)Fe.stack.push(He);Re%800===0&&Ie(N)>20&&await bt()}}let Ae=Math.max(0,V-(performance.now()-ve)),lt=Ie(N);on(Math.min(250,Ae,lt)),H=Math.max(0,H-1),ct();let Vt=Fe.stack.length===0,Vn=Fe.stack.length;return Vt&&(Fe=null),{revision:++ae,scanned:Re,durationMs:performance.now()-ve,done:Vt,remaining:Vn}}async function Pn(l={}){return me||(me=bn(l).finally(()=>{me=null}),me)}e.rtrvrAIFlushScan=Pn;let kt="__RTRVR_INTERNAL__";Object(window).__RTRVR_INTERNAL_KEY__=kt;let Qe=e[kt],En=Qe&&typeof Qe=="object"?Qe:{};if(!Qe)try{Object.defineProperty(e,kt,{value:En,writable:!1,configurable:!1,enumerable:!1})}catch{}try{Object.defineProperty(En,"flushScan",{value:Pn,writable:!1,configurable:!1,enumerable:!1})}catch{}function de(l,E){let R=Bt(l),T=K(E.type);if(!T)return;let k=!1,N=R.listeners.get(T);N||(N=[],R.listeners.set(T,N),k=!0);let V=N.find(ie=>ie.source===E.source&&!!ie.inferred==!!E.inferred);if(V){let ie=!!V.capture,ve=!!V.passive,Re=!!V.once;V.capture=V.capture||E.capture,V.passive=V.passive||E.passive,V.once=V.once||E.once,(ie!==!!V.capture||ve!==!!V.passive||Re!==!!V.once)&&(k=!0)}else N.push({...E,type:T}),k=!0;let j=we[T];if(j!==void 0){R.listenerTypeMasks||(R.listenerTypeMasks=new Map);let ie=0,ve=ju[E.source];ie|=ve!==void 0?ve:Rt.Other,E.inferred&&(ie|=Rt.Inferred);let Re=R.listenerTypeMasks.get(j)||0,Ae=Re|ie;Ae!==Re&&(R.listenerTypeMasks.set(j,Ae),k=!0)}k&&(R.role=void 0,zt(l))}function wn(l){let E=l.listenerTypeMasks;return!E||E.size===0?null:[...E.entries()].sort((T,k)=>T[0]-k[0]).map(([T,k])=>`${T}~${(k||0).toString(36)}`).join(",")}function It(l,E){let R=Bt(l);R.frameworks.has(E)||(R.frameworks.add(E),zt(l))}function qe(l){r.frameworks.has(l)||(r.frameworks.add(l),Xe()?.documentElement?.setAttribute(`rtrvr-${l}`,"1"))}function St(l){let E=n.get(l);if(!E)return;i.delete(l);let R=wn(E);R?R!==E.lastListenersSerialized&&(l.setAttribute(an,R),E.lastListenersSerialized=R):E.lastListenersSerialized&&(l.removeAttribute(an),E.lastListenersSerialized=void 0);let T=re(l);if(We(l,T))if(E.role===void 0&&(E.role=cr(l)),E.role){let k=qn[E.role],N=typeof k=="number"?String(k):`s:${E.role}`;N!==E.lastRoleSerialized&&(l.setAttribute(Zt,N),E.lastRoleSerialized=N)}else(E.lastRoleSerialized||l.hasAttribute(Zt))&&(l.removeAttribute(Zt),E.lastRoleSerialized=void 0)}function Ur(l){let E=[],R=l;for(;R;)E.push(R),R=R.parentNode||R.host;return E}function ar(l){let E=l.tagName.toLowerCase(),R=l.getAttribute("role"),T=R?R.toLowerCase().trim():"";if(T&&Jt.has(T)||E==="button"||(E==="a"||E==="area")&&l.hasAttribute("href"))return!0;if(E==="input")return l.type?.toLowerCase()!=="hidden";if(E==="select"||E==="textarea"||(E==="video"||E==="audio")&&l.hasAttribute("controls")||l.isContentEditable||l.hasAttribute("contenteditable"))return!0;let k=l.getAttribute("tabindex");return!!(k!==null&&!Number.isNaN(Number.parseInt(k,10))&&(q(l).some(j=>Zr.has(j))||l.getAttributeNames().some(j=>j.startsWith("on"))))}function Pe(l,E=10,R=600){let T=[];for(let N=0;N<l.children.length;N++)T.push({node:l.children[N],depth:1});let k=0;for(;T.length;){let{node:N,depth:V}=T.pop();if(++k>R||ar(N))return!0;if(!(V>=E))for(let j=0;j<N.children.length;j++)T.push({node:N.children[j],depth:V+1})}return!1}function cr(l){let E=l.tagName.toLowerCase(),R=l.getAttribute("role"),T=R?R.toLowerCase().trim():"",k=l.type?.toLowerCase();if(T&&Jt.has(T))return T;if(T&&pr.has(T))return null;if(E==="a"&&l.hasAttribute("href"))return"link";if(E==="button")return"button";if(E==="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":l.hasAttribute("list")?"combobox":"textbox";if(E==="textarea")return"textbox";if(E==="select"){let Ae=l;return Ae.multiple||Ae.size&&Ae.size>1?"listbox":"combobox"}if(E==="option")return"option";if(E==="form")return"form";if(E==="video"||E==="audio"){let Ae=fr(l);return l.hasAttribute("controls")||Ae.length>0?"media":null}if(l.isContentEditable||l.hasAttribute("contenteditable"))return"textbox";let N=q(l);if(!N.length)return null;let V=!1,j=!1,ie=!1;for(let Ae=0;Ae<N.length;Ae++){let lt=N[Ae];!V&&Zr.has(lt)&&(V=!0),!j&&ss.has(lt)&&(j=!0),!ie&&is.has(lt)&&(ie=!0)}if(!V&&!j&&!ie)return null;let ve=l.getAttribute("tabindex"),Re=ve!==null&&!Number.isNaN(Number.parseInt(ve,10));if(V&&(ms(l)||l.getAttribute("href")||l.closest("a[href]")))return"link";if(j){if(l.isContentEditable||l.hasAttribute("contenteditable"))return"textbox";if(T==="textbox"||T==="searchbox"||T==="combobox"||T==="spinbutton")return T;if(!V&&Re)return"textbox"}if(V){let Ae=l.getAttribute("aria-checked"),lt=l.getAttribute("aria-pressed");if(Ae!==null||lt!==null){if(T==="radio")return"radio";if(T==="menuitemradio")return"menuitemradio";if(T==="menuitemcheckbox")return"menuitemcheckbox";if(lt!==null)return"button";if(Ae!==null)return"checkbox"}if((Re||T==="button")&&!Pe(l))return"button"}return ie?"application":null}let lr=EventTarget.prototype.addEventListener,Pr=EventTarget.prototype.removeEventListener;function Bn(l){let E=!1,R,T;return typeof l=="boolean"?E=l:l&&typeof l=="object"&&(E=!!l.capture,R=l.passive,T=l.once),{capture:E,passive:R,once:T}}function Wn(l){try{let E=l;if(E?.nodeType===9&&E?.documentElement)return E;let R=E?.document;if(R&&R.nodeType===9&&R.documentElement)return R}catch{}return null}function wt(l,E,R){let T=K(E);if(!T)return;let{capture:k,passive:N,once:V}=Bn(R),j=o.get(l);j||(j=new Map,o.set(l,j));let ie=j.get(T);if(ie?(ie.count+=1,ie.capture=ie.capture||k,ie.passive=ie.passive||N):j.set(T,{count:1,capture:k,passive:N}),Tn(l))try{de(l,{type:T,source:"native",capture:k,passive:N,once:V})}catch{}let ve=Wn(l);if(ve&&(T==="click"||T==="input"||T==="keydown"))try{ve.documentElement?.setAttribute(`rtrvr-gl-${T}`,"1")}catch{}}function Kt(l,E,R){let T=K(E);if(!T)return;let k=o.get(l);if(!k)return;let N=k.get(T);N&&(N.count-=1,N.count<=0&&k.delete(T),k.size===0&&o.delete(l))}A(window);function Wt(l){if(!l||!l.fn)return;let E=l.fn.on,R=l.fn.off;function T(N){if(!N)return[];if(typeof N=="string")return N.split(/\s/).map(V=>K(V)).filter(Boolean);if(typeof N=="object")try{return Object.keys(N).map(V=>K(V)).filter(Boolean)}catch{return[]}return[]}function k(N){try{if(!N)return null;if(Tn(N))return N;let V=re(N);return jr(N,V)||null}catch{}return null}l.fn.on=function(N,V){let j=T(N),ie=typeof V=="string"&&!!V;return this.each(function(){let ve=k(this);if(ve){if(ie){let Re=s.get(ve);Re||(Re=[],s.set(ve,Re));for(let Ae of j){let lt=`${Ae}::${V}`;Re.some(Vt=>`${Vt.type}::${Vt.selector}`===lt)||(Re.push({type:Ae,selector:V}),Re.length>400&&Re.shift())}}else for(let Re of j)de(ve,{type:Re,source:"jquery"});It(ve,"jquery"),qe("jquery"),r.jqueryRoots.add(ve)}}),E.apply(this,arguments)},l.fn.off=function(){return R.apply(this,arguments)},qe("jquery")}function ur(l){se.some(R=>l.hasAttribute(R))&&(de(l,{type:"click",source:"other",inferred:!0}),(l.tagName==="INPUT"||l.tagName==="TEXTAREA")&&(de(l,{type:"input",source:"other",inferred:!0}),de(l,{type:"change",source:"other",inferred:!0})))}function Ot(l){let E=re(l),R=We(l,E),T=l.getAttributeNames().some(ie=>ie.startsWith("on")),k=/^(button|a|input|select|textarea|summary)$/i.test(l.tagName),N=l,V=R&&(ro(l)||!!N.isContentEditable||l.hasAttribute("contenteditable")),j=R&&!!N.draggable;if(!T&&!k&&!V&&!j){ur(l);return}for(let[ie,ve]of Object.entries(oe))typeof l[ie]=="function"&&de(l,{type:ve,source:"inline"});V&&(de(l,{type:"input",source:"other",inferred:!0}),de(l,{type:"keydown",source:"other",inferred:!0}),de(l,{type:"keyup",source:"other",inferred:!0}),de(l,{type:"paste",source:"other",inferred:!0})),j&&(de(l,{type:"dragstart",source:"other",inferred:!0}),de(l,{type:"dragend",source:"other",inferred:!0})),ur(l)}function yt(l){if(!l.startsWith("on")||l.length<=2)return null;if(l.endsWith("Capture")){let R=l.substring(2,l.length-7);return R?{type:R.toLowerCase(),capture:!0}:null}let E=l.substring(2);return E?{type:E.toLowerCase(),capture:!1}:null}function sn(l){let E=null;if(l){for(let R in l)if(R.startsWith("__react")||R.startsWith("_react")||R.includes("reactFiber")||R.includes("reactProps")||R.includes("reactInternalInstance")){E=R;break}if(E)try{let R=l[E],T=R?.memoizedProps||R?.pendingProps;if(T&&typeof T=="object"){for(let k in T){if(typeof T[k]!="function")continue;let V=yt(k);V&&de(l,{type:V.type,source:"react",capture:V.capture})}Tn(R?.stateNode)&&r.reactRoots.add(R.stateNode),It(l,"react"),qe("react")}}catch{}}}function a(l){let E=l,R=!1;if(E.__vue__){R=!0;let T=E.__vue__;T.$listeners&&Object.keys(T.$listeners).forEach(k=>de(l,{type:k,source:"vue"})),T._events&&Object.keys(T._events).forEach(k=>de(l,{type:k,source:"vue"})),T.$options?._parentListeners&&Object.keys(T.$options._parentListeners).forEach(k=>de(l,{type:k,source:"vue"})),r.vueRoots.add(l)}if(E._vnode?.props){R=!0;let T=E._vnode.props;Object.keys(T).forEach(k=>{k.startsWith("on")&&k.length>2&&de(l,{type:k.substring(2).toLowerCase(),source:"vue"})}),r.vueRoots.add(l)}R&&(It(l,"vue"),qe("vue"))}function u(l){let E=l,R=!1;if(E.__ngContext__||l.hasAttribute("_ngcontent")||l.hasAttribute("ng-version")){R=!0,Array.from(l.attributes).forEach(T=>{if(T.name.startsWith("(")&&T.name.endsWith(")")){let k=T.name.slice(1,-1).split(".")[0];k&&de(l,{type:k,source:"angular"})}if(T.name.startsWith("on-")){let k=T.name.substring(3);k&&de(l,{type:k,source:"angular"})}if(T.name.includes(".")){let k=T.name.match(/\(([^.)]+)/);k?.[1]&&de(l,{type:k[1],source:"angular"})}});try{if(e.ng?.getComponent){let T=e.ng.getComponent(l);T&&Object.keys(T).forEach(k=>{(k.endsWith("Output")||k.endsWith("Emitter"))&&de(l,{type:k.replace(/(Output|Emitter)$/,"").toLowerCase(),source:"angular"})})}}catch{}}R&&(It(l,"angular"),qe("angular"),r.angularRoots.add(l))}function h(l){let E=l,R=!1;if(E.__svelte__){R=!0,Array.from(l.attributes).forEach(T=>{if(T.name.startsWith("on:")){let k=T.name.substring(3);k&&de(l,{type:k,source:"svelte"})}});try{let T=E.__svelte__?.$$?.callbacks;T&&typeof T=="object"&&Object.keys(T).forEach(k=>de(l,{type:k,source:"svelte"}))}catch{}r.svelteRoots.add(l)}R&&(It(l,"svelte"),qe("svelte"))}function m(l,E){return l?!!o.get(l)?.has(E):!1}function p(l,E,R=96){let T=K(E);if(!T)return!1;let k=G(l),N=Y(k);if(m(k,T)||m(N,T))return!0;let V=0,j=l;for(;j&&V<R;){if(j.parentElement)j=j.parentElement;else{let ie=j.getRootNode?.();if(Tt(ie)){if(m(ie,T)||m(ie.host,T))return!0;j=ie.host}else break}if(j&&m(j,T))return!0}return!1}function d(l,E,R=128){let T=0,k=l;for(;k&&T<R;){if(E(k),k.parentElement){k=k.parentElement;continue}let N=k.getRootNode?.();if(Tt(N)){k=N.host;continue}break}}function g(l){let E=re(l);if(!We(l,E))return;let R=Bt(l);R.role=R.role||cr(l);let T=p(l,"click"),k=p(l,"input"),N=p(l,"keydown"),j=G(l).documentElement;if(r.frameworks.size>0||j.hasAttribute("rtrvr-react")||j.hasAttribute("rtrvr-vue")||j.hasAttribute("rtrvr-angular")||j.hasAttribute("rtrvr-svelte")||j.hasAttribute("rtrvr-jquery")||T||k||N){let ve=R.role||"other";T&&["button","link","checkbox","radio","switch","menuitem","menuitemcheckbox","menuitemradio","tab","option","treeitem","gridcell","cell","img","figure"].includes(ve)&&de(l,{type:"click",source:"delegated",inferred:!0}),["textbox","searchbox","spinbutton","code"].includes(ve)&&(k&&(de(l,{type:"input",source:"delegated",inferred:!0}),de(l,{type:"change",source:"delegated",inferred:!0})),N&&de(l,{type:"keydown",source:"delegated",inferred:!0})),["combobox","listbox"].includes(ve)&&(T&&de(l,{type:"click",source:"delegated",inferred:!0}),k&&de(l,{type:"change",source:"delegated",inferred:!0})),["slider","scrollbar","progressbar","meter"].includes(ve)&&k&&de(l,{type:"input",source:"delegated",inferred:!0})}d(l,ve=>{let Re=s.get(ve);if(Re?.length)for(let{type:Ae,selector:lt}of Re)try{l.matches(lt)&&(de(l,{type:Ae,source:"jquery",inferred:!0}),It(l,"jquery"),qe("jquery"))}catch{}})}function _(l){let E=R=>{let T=R,k=T.composedPath&&T.composedPath()||Ur(R.target),V=l==="mousemove"||l==="pointermove"||l==="scroll"||l==="wheel"?1:Math.min(k.length,X);for(let j=0;j<V;j++){let ie=k[j];Tn(ie)&&de(ie,{type:l,source:"delegated",inferred:!0})}};Oe(E);try{lr.call(document,l,E,{capture:!0,passive:!0})}catch{}}let C=!1;function S(){Z.forEach(_);let l=Xe()?.documentElement;if(!l)return;let E=()=>{if(C)return;let R=l.hasAttribute("rtrvr-react")||l.hasAttribute("rtrvr-vue")||l.hasAttribute("rtrvr-angular")||l.hasAttribute("rtrvr-svelte"),T=l.hasAttribute("rtrvr-gl-click")||l.hasAttribute("rtrvr-gl-input")||l.hasAttribute("rtrvr-gl-keydown");(R||T)&&(C=!0,te.forEach(_))};E();try{new MutationObserver(()=>E()).observe(l,{attributes:!0,attributeFilter:["rtrvr-react","rtrvr-vue","rtrvr-angular","rtrvr-svelte","rtrvr-gl-click","rtrvr-gl-input","rtrvr-gl-keydown"]})}catch{}}function M(l){if(l.nodeType!==1)return;let E=re(l);if(We(l,E)){let R=Bt(l);R.role=void 0}Ot(l),sn(l),a(l),u(l),h(l),g(l),zt(l)}function O(){let l=["a[href]","button","input","select","textarea","summary","details > summary",...Array.from(Jt).map(E=>`[role="${E}"]`),"[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"];H++,ct();try{let E=l.join(",");Xe()?.querySelectorAll(E).forEach(R=>{try{M(R)}catch{}})}finally{H=Math.max(0,H-1),ct()}}function B(l){for(let E of l){for(let R of Array.from(E.addedNodes)){if(R.nodeType!==1)continue;let T=R;Lt(T),T.querySelectorAll?.('a,button,input,select,textarea,summary,[role],[onclick],[ondblclick],[ondoubleclick],[contenteditable],[draggable="true"],[tabindex]').forEach(Lt)}if(E.type==="attributes"&&E.target.nodeType===1){let R=E.target;E.attributeName==="class"?(Dt()||Nt(R))&&Lt(R):Lt(R)}}}async function z(l={}){let E=Xe(),R=E?.documentElement;if(!R||!(R.hasAttribute("rtrvr-react")||R.hasAttribute("rtrvr-vue")||R.hasAttribute("rtrvr-angular")||R.hasAttribute("rtrvr-svelte")))return;let k=l.deadlineEpochMs,N=Math.max(5,Math.min(l.budgetMs??12,50));if(Math.max(0,Math.min(N,Ie(k)))<=0)return;let j=performance.now();H++,ct();try{let ie=0,ve=4e3,Re=["div","span","li","section","article","p"];for(let Ae of Re){let lt=E.getElementsByTagName(Ae)??[];for(let Vt=0;Vt<lt.length;Vt++){if(ie++>=ve||k&&Ie(k)<=0)return;let Vn=lt[Vt],Je=Vn;(Je.__ngContext__||Je.__svelte__||Je.__vue__||Je._vnode||ht(Vn))&&M(Vn),ie%250===0&&Ie(k)>20&&await bt()}}}finally{H=Math.max(0,H-1),ct()}}let Q=new MutationObserver(B),ge=new WeakMap;function ee(l){if(!ge.has(l)&&!(v>=c))try{let E=Y(l.ownerDocument).MutationObserver||MutationObserver,R=new E(B);ge.set(l,R),v++,R.observe(l,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...F,"class"]})}catch{}}let ne=new WeakMap;function ce(l){if(!ne.has(l)&&!(b>=f))try{A(l.defaultView||null);let E=l.documentElement;if(!E)return;let R=Y(l).MutationObserver||MutationObserver,T=new R(B);ne.set(l,T),b++,T.observe(E,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...F,"class"]})}catch{}}function xe(){let l=Xe()?.documentElement;l&&Q.observe(l,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...F,"class"]})}let Ye=new WeakMap;function ue(l){return l.shadowRoot||Ye.get(l)||null}try{Object.defineProperty(En,"shadow",{value:Object.freeze({getRoot:l=>ue(l)}),writable:!1,configurable:!1,enumerable:!1})}catch{}function be(){try{(e.React||e.__REACT_DEVTOOLS_GLOBAL_HOOK__)&&qe("react"),e.Vue&&qe("vue"),e.ng&&qe("angular"),e.jQuery&&qe("jquery"),Te()}catch{}}e.rtrvrAIMarkInteractiveElements=function(){return Xe()?.body?(O(),!0):!1};function Ee(){let l=Xe();Te(),be(),S();let E=()=>{Te(),be(),xe(),e.rtrvrAIMarkInteractiveElements?.(),z({budgetMs:20}),l?.documentElement.setAttribute(ns,"1")};l?.readyState==="loading"?l.addEventListener("DOMContentLoaded",E,{once:!0}):E()}Ee()})();var Ro=null;function Ls(e){try{return e.getAttribute(an)}catch{return null}}function Wa(e){let t=Ls(e);return xn(t)?.entries??[]}function Va(e){try{let t=e.getAttribute(Zt);return t&&t.trim()?t:null}catch{return null}}function Ku(e){let t=e?.ownerDocument?.defaultView,n=t?.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",o=t?.[n]?.shadow?.getRoot;if(typeof o=="function")try{return o(e)||null}catch{}return e.shadowRoot||null}function Qu(e){let t=new Set;for(let n of e){let r=Vr(n.mask);for(let o of r)(o==="react"||o==="vue"||o==="angular"||o==="svelte"||o==="jquery")&&t.add(o)}return t}function Ju(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 Zu(e){let t=Wa(e),n=Qu(t),r=Ju(e);for(let o of r)n.add(o);return{frameworks:[...n],listenersRaw:Ls(e)||"",role:Va(e)??(e.getAttribute?.("role")||null)}}function ed(){return{getEventHandlerIds:e=>Wa(e).map(t=>t.id),getRoleHint:Va,getShadowRoot:Ku}}function $a(e={}){if(Ro)return Ro;if(typeof window<"u")try{window.rtrvrAIMarkInteractiveElements?.()}catch{}return Ro={signalProvider:ed(),getFrameworkMetadata:Zu,getListenerEncoding:Ls,dispose:()=>{}},Ro}var Co=class{constructor(t={}){$(this,"root");$(this,"includeFrames");$(this,"disableDomAnnotations");$(this,"allowActions");$(this,"runtimeId");$(this,"domainScopeMode");$(this,"allowedDomains");$(this,"externalNavigationPolicy");$(this,"registerOpenedTab");$(this,"listKnownTabs");$(this,"switchToLogicalTab");$(this,"onNavigationGuardrail");$(this,"instrumentation");$(this,"highlightEl",null);$(this,"clientTools",new Map);$(this,"uploadStore",new Map);$(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=Ga(t.domainScopeMode),this.allowedDomains=Ns(t.allowedDomains,window.location.hostname,this.domainScopeMode),this.externalNavigationPolicy=qa(t.externalNavigationPolicy,t.crossDomainPolicy),this.registerOpenedTab=t.registerOpenedTab,this.listKnownTabs=t.listKnownTabs,this.switchToLogicalTab=t.switchToLogicalTab,this.onNavigationGuardrail=t.onNavigationGuardrail,this.instrumentation=t.instrumentation??$a({includeIframes:!0,scanInlineHandlers:!0,observeInlineMutations:!0,...t.instrumentationOptions||{}}),Ma(),t.uploadBytesProvider&&this.setUploadBytesProvider(t.uploadBytesProvider)}setAllowActions(t){this.allowActions=!!t}setNavigationPolicy(t){t.domainScopeMode&&(this.domainScopeMode=Ga(t.domainScopeMode),t.allowedDomains||(this.allowedDomains=Ns(void 0,window.location.hostname,this.domainScopeMode))),t.allowedDomains&&(this.allowedDomains=Ns(t.allowedDomains,window.location.hostname,this.domainScopeMode)),(t.externalNavigationPolicy||t.crossDomainPolicy)&&(this.externalNavigationPolicy=qa(t.externalNavigationPolicy,t.crossDomainPolicy))}async getSnapshot(){return await za(this.root),wo(this.root,this.instrumentation,{includeFrames:this.includeFrames,disableDomAnnotations:this.disableDomAnnotations})}async getPageData(t){return await za(this.root),await Ua(this.root,this.instrumentation,{includeFrames:this.includeFrames,disableDomAnnotations:this.disableDomAnnotations,pageConfig:t?.pageConfig})}async executeTool(t,n){let r=td(t?.name);if(!r)return{success:!1,error:`Unknown tool: ${String(t?.name)}`,allowFallback:!1};if(this.shouldBlockForOutOfScopeContext(r)){let I=`Current tab is outside the allowed domain scope (${So(this.allowedDomains)}).`;return this.domainScopeBlockedResponse(window.location.href,I,{fromCurrentContext:!0})}if(!this.allowActions&&!Xa.has(r))return{success:!1,error:"Actions disabled by configuration",allowFallback:!1};let o=await this.handleNavigationTools(r,t?.args||{});if(o)return o;if(r===L.wait_action){let I=Number(t?.args?.duration??1e3);return await new Promise(x=>setTimeout(x,Math.max(0,Math.min(I,6e4)))),{success:!0}}if(r===L.wait_for_element)return this.waitForElement(t?.args||{});if(r===L.answer_task)return{success:!0};if(r===L.solve_captcha)return Ao("CAPTCHA solving requires human intervention in embed mode.","HUMAN_INTERVENTION_REQUIRED");if(r===L.network_run_recipe)return Ao("network_run_recipe is not supported in embed mode.","CAPABILITY_UNAVAILABLE");if(r===L.click_element&&t?.args?.open_in_new_tab)return this.openElementInNewTab(t?.args||{});if(r===L.click_element&&this.shouldInterceptExternalClick(t?.args||{})){let I=this.getExternalClickTargetUrl(t?.args||{});if(I){let x=`Blocked same-tab navigation to out-of-scope domain (${new URL(I).hostname}).`;return this.externalNavigationPolicy==="open_new_tab_notice"?this.openUrlInNewTab(I,{policyBlocked:!0,reason:x}):this.domainScopeBlockedResponse(I,x)}}if(r===L.describe_images)return this.describeImages(t?.args||{});if(!(r in Wr))return{success:!1,error:`Unknown tool: ${String(t?.name)}`,allowFallback:!1};let s=t?.args||{},{doc:i}=Jn(document,s.iframe_id),c=s.element_id??s.source_element_id??s.target_element_id??s.center_element_id??null,f=c?Pt(i,c):null,v;if(f){let I=this.instrumentation.getFrameworkMetadata(f),x=cd(I.listenersRaw||"",r),A=s?.value??s?.text??null;v=ad({...I,pattern:x,value:A})}let b=Wr[r];return r===L.upload_file&&!n&&(n=await this.buildUploadPayload(s).catch(()=>{})),La({opcode:b,call:{name:r,args:s},elementData:v,tabIndex:0,payload:n})}highlight(t){let n=Pt(document,t);if(!n)return;let r=n.getBoundingClientRect();if(!this.highlightEl){let o=document.createElement("div");o.style.position="fixed",o.style.pointerEvents="none",o.style.border="2px solid #ff7a59",o.style.boxShadow="0 0 0 2px rgba(255, 122, 89, 0.2)",o.style.borderRadius="6px",o.style.zIndex="2147483647",this.highlightEl=o,document.body.appendChild(o)}this.highlightEl.style.left=`${r.left}px`,this.highlightEl.style.top=`${r.top}px`,this.highlightEl.style.width=`${Math.max(0,r.width)}px`,this.highlightEl.style.height=`${Math.max(0,r.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 r=typeof t=="string"?{name:t}:t;!r?.name||typeof n!="function"||this.clientTools.set(r.name,{handler:n,def:r})}async executeClientTool(t,n){let r=this.clientTools.get(t);if(!r)throw new Error(`Unknown client tool: ${t}`);return r.handler(n)}listClientTools(){return Array.from(this.clientTools.values()).map(t=>t.def)}async handleNavigationTools(t,n){switch(t){case L.goto_url:{let r=String(n.url||"").trim();if(!r)return{success:!1,error:"goto_url: missing url",allowFallback:!0};let o=ko(r,window.location.href);if(!o)return{success:!1,error:`goto_url: invalid url "${r}"`,allowFallback:!0};if(this.shouldGuardExternalNavigation(o)){let s=`Navigation blocked by domain policy. Allowed: ${So(this.allowedDomains)}`;return this.externalNavigationPolicy==="open_new_tab_notice"?await this.openUrlInNewTab(o,{policyBlocked:!0,reason:s}):this.domainScopeBlockedResponse(o,s)}return window.location.href=o,{success:!0,output:{url:o,navigation:"same_tab"}}}case L.google_search:{let r=String(n.query||"").trim();if(!r)return{success:!1,error:"google_search: missing query",allowFallback:!0};let o=`https://www.google.com/search?q=${encodeURIComponent(r)}`;if(this.shouldGuardExternalNavigation(o)){let s=`Google search opens outside the allowed domain scope (${So(this.allowedDomains)}).`;return this.externalNavigationPolicy==="open_new_tab_notice"?await this.openUrlInNewTab(o,{policyBlocked:!0,reason:s}):this.domainScopeBlockedResponse(o,s)}return window.location.href=o,{success:!0,output:{url:o,navigation:"same_tab"}}}case L.go_back:return window.history.back(),{success:!0};case L.go_forward:return window.history.forward(),{success:!0};case L.refresh_page:return window.location.reload(),{success:!0};case L.open_new_tab:{let r=String(n.url||"").trim();if(!r)return{success:!1,error:"open_new_tab: missing url",allowFallback:!0};let o=ko(r,window.location.href);return o?await this.openUrlInNewTab(o,{policyBlocked:!1}):{success:!1,error:`open_new_tab: invalid url "${r}"`,allowFallback:!0}}case L.switch_tab:{let r=Number(n.logical_tab_id??n.tab_id);if(!Number.isFinite(r)||r<=0)return{success:!1,error:"switch_tab: missing/invalid logical_tab_id",allowFallback:!0};if(this.externalNavigationPolicy!=="allow"&&this.listKnownTabs){let o=this.listKnownTabs().find(s=>Number(s.logicalTabId)===r);if(o?.external)return this.domainScopeBlockedResponse(o.url||`logical_tab_id:${r}`,`Tab ${r} is out of scope. Direct actions are blocked outside ${So(this.allowedDomains)}.`)}if(!this.switchToLogicalTab)return Ao("switch_tab requires session coordinator support.","CAPABILITY_UNAVAILABLE");try{let o=await this.switchToLogicalTab(r);return o?.ok?{success:!0,output:{logicalTabId:r,delegated:!!o.delegated,mode:o.delegated?"delegated":"local"}}:{success:!1,error:o?.reason||`switch_tab failed for logical tab ${r}`,allowFallback:!0}}catch(o){return{success:!1,error:o?.message||"switch_tab failed",allowFallback:!0}}}case L.close_tab:try{return window.close(),{success:!0}}catch{return Ao("close_tab failed in embed mode.","CAPABILITY_UNAVAILABLE")}default:return null}}shouldGuardExternalNavigation(t){return this.externalNavigationPolicy==="allow"?!1:!Io(t,this.allowedDomains)}shouldBlockForOutOfScopeContext(t){return this.externalNavigationPolicy==="allow"||Xa.has(t)||id.has(t)?!1:!Io(window.location.href,this.allowedDomains)}shouldInterceptExternalClick(t){if(this.externalNavigationPolicy==="allow")return!1;let n=this.getExternalClickTargetUrl(t);return n?!Io(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:r}=Jn(document,t.iframe_id),o=Pt(r,n);if(!o)return null;let s=Ya(o),i=s?.href||s?.getAttribute("href")||"";return ko(i,window.location.href)}domainScopeBlockedResponse(t,n,r){let o=this.externalNavigationPolicy==="block"?"block":"open_new_tab_notice";return this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:o,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:o==="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:o,from_current_context:!!r?.fromCurrentContext},errorDetails:{code:"DOMAIN_SCOPE_BLOCKED",message:n,retryable:!1,details:{blockedUrl:t,currentUrl:window.location.href,allowedDomains:this.allowedDomains,policyAction:o}}}}emitNavigationGuardrail(t){try{this.onNavigationGuardrail?.(t)}catch{}}async openUrlInNewTab(t,n){let r=!Io(t,this.allowedDomains),o=window.open(t,"_blank","noopener,noreferrer"),s;if(this.registerOpenedTab)try{s=(await this.registerOpenedTab({url:t,title:void 0,external:r,openerRuntimeId:this.runtimeId}))?.logicalTabId}catch{}let i=!s&&!!this.registerOpenedTab;if(!o){let f="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||f,allowedDomains:this.allowedDomains,openedInNewTab:!1}),{success:!1,error:"open_new_tab blocked by browser popup settings",allowFallback:!0,output:{url:t,external:r,logicalTabId:s},errorDetails:{code:"POPUP_BLOCKED",message:f,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:r,logicalTabId:s,openedInNewTab:!0,policyBlocked:!!n?.policyBlocked,message:c,...i&&{warning:"Tab opened but registration failed \u2014 tab may not be targetable"}},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:r}=Jn(document,t.iframe_id),o=Pt(r,n);if(!o)return{success:!1,error:`click_element: element_id ${String(n)} not found.`,allowFallback:!0};let s=Ya(o),i=s?.href||s?.getAttribute("href")||"",c=ko(i,window.location.href);return c?await this.openUrlInNewTab(c,{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(),r=Math.max(0,Math.min(Number(t.timeout??5e3),3e4));if(!n)return{success:!1,error:"wait_for_element: missing selector",allowFallback:!0};let o=Date.now(),s=document;for(;Date.now()-o<r;){let i=null;try{i=s.querySelector(n)}catch{i=null}if(i||(i=ld(s,n)),i)return{success:!0};await new Promise(c=>setTimeout(c,200))}return{success:!1,error:`wait_for_element: not found (${n})`,allowFallback:!0}}async describeImages(t){let n=ni(t);if(!n.length)return{success:!1,error:"describe_images: element_ids is empty",allowFallback:!1};let r=[],o=[];for(let s of n){let i=Pt(document,s);if(!i){o.push(`element_id ${s} not found`);continue}try{let c=await ud(i);if(!c?.data||!c?.mimeType){o.push(`element_id ${s}: unsupported image`);continue}r.push({element_id:s,...c})}catch(c){o.push(`element_id ${s}: ${c?.message||String(c)}`)}}return r.length?{success:!0,output:{images:r,errors:o.length?o:void 0}}:{success:!1,error:o[0]||"describe_images failed",output:{images:[],errors:o}}}ensureUploadProvider(){this.uploadProviderInstalled||(this.uploadProviderInstalled=!0,this.setUploadBytesProvider(async({token:t,byteLength:n})=>{this.pruneUploadStore();let r=this.uploadStore.get(t);if(!r)throw new Error("upload bytes token not found");if(r.bytes.byteLength!==n)throw new Error("upload bytes size mismatch");return r.bytes}))}pruneUploadStore(){let t=Date.now()-6e5;for(let[n,r]of this.uploadStore.entries())r.createdAt<t&&this.uploadStore.delete(n)}async buildUploadPayload(t){let n=String(t.file_url||"").trim();if(n)try{let r=await Sa(0,n,document?.referrer||null),o=r.bytes,s=o.byteLength,i=r.mimeType||t.mime_type||"application/octet-stream",c=t.file_name||r.fileName,f=1024*1024;if(s<=f)return{kind:"upload_file",inlineB64:Ka(o),byteLength:s,mimeType:i,fileName:c};this.ensureUploadProvider();let v=crypto.randomUUID();return this.uploadStore.set(v,{bytes:o,createdAt:Date.now()}),{kind:"upload_file",token:v,byteLength:s,mimeType:i,fileName:c,durable:!1}}catch{return}}};function td(e){return e==="open_url_new_tab"?L.open_new_tab:String(e||"").trim()}function Ga(e){return e==="host_only"?"host_only":"registrable_domain"}function nd(e){if(e==="allow")return"allow";if(e==="block_new_tab")return"open_new_tab_notice"}function qa(e,t){return e==="allow"||e==="block"||e==="open_new_tab_notice"?e:nd(t)||"open_new_tab_notice"}function Ns(e,t,n){let r=Array.isArray(e)?e:[],o=new Set;for(let s of r){let i=String(s||"").trim().toLowerCase().replace(/^\./,"");i&&o.add(i)}if(!o.size){let s=rd(t,n);s&&o.add(s)}return Array.from(o)}function rd(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 r=n.split(".").filter(Boolean);return r.length<2?n:`${r[r.length-2]}.${r[r.length-1]}`}function ko(e,t){let n=String(e||"").trim();if(!n)return null;try{return new URL(n,t).toString()}catch{return null}}function Io(e,t){let n=od(e);if(!n)return!1;if(!t.length)return!0;for(let r of t)if(sd(n,r))return!0;return!1}function od(e){try{return new URL(e).hostname.toLowerCase()}catch{return null}}function sd(e,t){let n=String(t||"").trim().toLowerCase().replace(/^\./,"");if(!n)return!1;if(n==="*")return!0;if(n.startsWith("=")){let r=n.slice(1);return!!r&&e===r}if(n.startsWith("*.")){let r=n.slice(2);return r?e===r||e.endsWith(`.${r}`):!1}return e===n?!0:e.endsWith(`.${n}`)}function So(e){return e.length?e.map(t=>{let n=String(t||"");return n.startsWith("=")?n.slice(1):n}).join(", "):"*"}function Ya(e){if(e instanceof HTMLAnchorElement&&e.href)return e;let t=e.closest?.("a[href]");return t instanceof HTMLAnchorElement&&t.href?t:null}function Ao(e,t="CAPABILITY_UNAVAILABLE"){return{success:!1,error:e,allowFallback:!0,errorDetails:{code:t,message:e,retryable:!1}}}var Xa=new Set([L.describe_images,L.wait_action,L.wait_for_element,L.answer_task,L.solve_captcha,L.network_run_recipe]),id=new Set([L.goto_url,L.google_search,L.go_back,L.go_forward,L.refresh_page,L.open_new_tab,L.switch_tab,L.close_tab]);function ad(e){return{frameworks:(e.frameworks||[]).filter(n=>n in Jo).map(n=>Jo[n]),listenersRaw:e.listenersRaw??"",role:e.role??null,pattern:e.pattern,value:e.value??null}}async function za(e){try{let n=(e.ownerDocument||document).defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",s=n[r]?.flushScan;if(typeof s=="function"){await s({mode:"priority",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:1500});return}n.rtrvrAIMarkInteractiveElements?.()}catch{}}function cd(e,t){if(t!==L.click_element)return"standard";let n=xn(e||"");if(!n)return"standard";let r=new Set(n.entries.map(f=>Qt[f.id]).filter(f=>typeof f=="string")),o=r.has("click")||r.has("mousedown")||r.has("mouseup")||r.has("pointerdown")||r.has("pointerup")||r.has("touchend");if((r.has("mouseenter")||r.has("mouseover")||r.has("pointerenter"))&&o)return"hover-activate";let i=r.has("touchstart"),c=r.has("touchend");return i&&c?"touch-sequence":"standard"}function Ka(e){let t=new Uint8Array(e),n="",r=32768;for(let o=0;o<t.length;o+=r)n+=String.fromCharCode(...t.subarray(o,o+r));return btoa(n)}function ld(e,t){let n=t.toLowerCase(),r=["button","a","input","textarea","select","label","[role]","div","span"],o=e.querySelectorAll(r.join(","));for(let s of Array.from(o))if((s.textContent||"").trim().toLowerCase().includes(n)||(s.getAttribute("aria-label")||"").toLowerCase().includes(n))return s;return null}async function ud(e){if(e instanceof HTMLCanvasElement){let o=e.toDataURL(),s=Qa(o);if(!s)throw new Error("canvas toDataURL failed");return s}if(e instanceof SVGElement){let o=new XMLSerializer().serializeToString(e);return{data:btoa(unescape(encodeURIComponent(o))),mimeType:"image/svg+xml",displayName:"svg"}}if(e instanceof HTMLImageElement){let o=e.currentSrc||e.src;return await ja(o,e.alt||e.getAttribute("aria-label")||void 0)}let n=window.getComputedStyle(e).backgroundImage||"",r=/url\\((['\"]?)(.*?)\\1\\)/.exec(n);if(r?.[2])return await ja(r[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 ja(e,t){if(!e)throw new Error("missing src");if(e.startsWith("data:")){let c=Qa(e);if(!c)throw new Error("invalid data url");return{...c,displayName:t}}let n=await fetch(e,{mode:"cors"});if(!n.ok)throw new Error(`fetch failed (${n.status})`);let r=await n.blob(),o=await r.arrayBuffer(),s=Ka(o),i=r.type||"image/png";return{data:s,mimeType:i,displayName:t}}function Ja(e,t){e.onmessage=async n=>{let r=n.data;if(!r||r.t!=="req")return;let{id:o,method:s,params:i}=r;try{let c=t[s];if(!c)throw new Error(`No handler for ${s}`);let f=await c(i);e.postMessage({t:"res",id:o,ok:!0,result:f})}catch(c){e.postMessage({t:"res",id:o,ok:!1,error:{message:c?.message||String(c)}})}}}var dd="https://www.rtrvr.ai/rover/mascot.mp4",fd="https://www.rtrvr.ai/rover/mascot.webm";function tc(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Za(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function pd(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 hd(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||tc("trace")}function nr(e){return String(e||"").trim()}function nc(e){let t=nr(e),n=/^(Analyze|Route|Execute|Verify|Complete):\s*(.*)$/i.exec(t);if(!n)return{plainTitle:t};let r=n[1].toLowerCase(),o=nr(n[2]||t);return{stage:r,plainTitle:o||t}}function md(e){let t=(e.title||"").toLowerCase();if(t==="run started"||t==="run resumed"||t==="run completed")return"detail";if(e.kind==="status"){let n=nc(e.title||"");if(n.stage==="analyze"||n.stage==="route"||n.stage==="complete")return"detail"}return"primary"}function Ds(e,t){let n=/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)|\*\*(.+?)\*\*/g,r=0,o;for(;(o=n.exec(t))!==null;){if(o.index>r&&e.appendChild(document.createTextNode(t.slice(r,o.index))),o[1]&&o[2]){let s=document.createElement("a");s.className="rvLink",s.href=o[2],s.target="_blank",s.rel="noopener noreferrer",s.textContent=o[1],e.appendChild(s)}else if(o[3]){let s=document.createElement("strong");s.textContent=o[3],e.appendChild(s)}r=o.index+o[0].length}r<t.length&&e.appendChild(document.createTextNode(t.slice(r)))}function Sr(e){let t=document.createDocumentFragment(),n=e.split(`
|
|
11
|
-
`),r=null;for(let o of n){let s=o.trim();if(!s){r&&(t.appendChild(r),r=null);continue}if(s==="---"){r&&(t.appendChild(r),r=null);let
|
|
12
|
-
`),o=0,s=0;for(let
|
|
8
|
+
`)||(s+=d.trimEnd())}if(vo(e,!1),yo(e)?_o(e).endsWith(Fu+`
|
|
9
|
+
`)&&vo(e,!1):vo(e,!1),yo(e)){let d=_o(e);d.trim()!==""&&!d.startsWith(`
|
|
10
|
+
`)&&(s+=d)}Da(e);let i=Cs(e).trim(),c=s.trim()+i;return c.trim()?c:o()}catch{return o()}}async function Bu(e,t){let n="",r;Ba(e,e.defaultView||window);let o=It(t?.deadlineEpochMs);try{let s=Math.max(250,Math.min(1500,Math.floor(o*.45))),i=await rr(Wu(e),s,e);if(!(i.ok&&i.value))throw new Error("google_sheet_copy_failed");let d=It(t?.deadlineEpochMs),_=Math.max(250,Math.min(2500,Math.floor(d*.55)));if(n=await Vu(_,e),!n.trim())throw new Error("google_sheet_empty_clipboard")}catch(s){r=s instanceof Error?s.message:String(s)}return{content:n,contentType:_s,error:r}}function Ba(e,t){try{t?.focus?.()}catch{}try{e?.body?.focus?.()}catch{}}function Ms(e,t){let r=e.defaultView?.KeyboardEvent||KeyboardEvent,o=new r("keydown",{bubbles:!0,cancelable:!0,...t}),s=e.activeElement;(s&&s.ownerDocument===e?s:e).dispatchEvent(o)}async function Wu(e){try{if(Ba(e,e.defaultView||window),e.hidden||!e.hasFocus())return!1;Ms(e,{key:"Escape",code:"Escape"}),await Je(150,e);let t=e.querySelector(".grid-container")||Oa(e,".grid-container"),n=e.querySelector(".grid4-inner-container:last-child")||Oa(e,".grid4-inner-container:last-child");if(n){try{n.focus()}catch{}await Je(100,e)}else if(t){try{t.focus?.()}catch{}await Je(80,e)}let o=(typeof navigator<"u"?String(navigator.platform||""):"").toUpperCase().indexOf("MAC")>=0;Ms(e,{key:"a",code:"KeyA",ctrlKey:!o,metaKey:o}),await Je(200,e),Ms(e,{key:"c",code:"KeyC",ctrlKey:!o,metaKey:o}),await Je(200,e);try{e.execCommand("copy")}catch{}return!0}catch{return!1}}async function Vu(e,t){let n=Math.max(250,Math.min(5e3,Math.floor(e)));if(navigator?.clipboard?.readText){let s=await rr(navigator.clipboard.readText(),n,t);if(s.ok)return s.value||""}let r=t.createElement("textarea");r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",r.style.left="-9999px",r.style.top="0",t.body?.appendChild(r),r.focus();try{t.execCommand("paste")}catch{}let o=r.value||"";return r.remove(),o}function Oa(e,t){let n=xo(e);for(let c of n)try{let d=c.querySelector(t);if(d)return d}catch{}let r=25e3,o=0,s=(c,d)=>{if(!d)return;let _=d.children;if(_)for(let h=0;h<_.length;h++)c.push(_[h])},i=[];for(let c of n)try{s(i,c.documentElement??c.body??null)}catch{}for(;i.length&&o<r;){let c=i.pop();o++;try{if(c.matches(t))return c}catch{}s(i,c);let d=c.shadowRoot;if(d&&s(i,d),String(c.tagName).toUpperCase()==="IFRAME")try{let h=c.contentDocument;h&&s(i,h.documentElement??h.body??null)}catch{}}return null}async function $u(e,t){let n=t?.profile??"light",r=!e.hidden,o=Math.max(0,Math.min(t?.timeBudgetMs??(n==="light"?1600:2800),3e3));if(o<=0)return!1;let s=Date.now(),i=()=>o-(Date.now()-s),c=t?.delayMs??(n==="light"?220:280),d=t?.finalWaitMs??(n==="light"?350:900),_=r?c:0,h=r?d:0,v=t?.amount,I=t?.maxSteps??(n==="light"?8:18),x=t?.maxDistancePx??(n==="light"?12e3:3e4),M=null;try{let F=await Fa(e,{action:"detectPrimary"});if(F?.selector){let U=Gu(e,F.selector);U&&(M=U)}let H=F?.metrics;if(H&&typeof H.scrollHeight=="number"&&typeof H.clientHeight=="number"){let U=Math.max(0,H.scrollHeight-H.clientHeight);x=Math.min(x,U||x),U<1500?I=Math.min(I,2):U<4e3?I=Math.min(I,4):U<1e4&&(I=Math.min(I,6))}}catch{}if(M||(M=e.scrollingElement||e.documentElement||e.body),!M)return!1;let D=0,P=null,q=0;for(let F=0;F<I&&!(i()<=0);F++){let H=null;try{H=await Fa(e,{action:"scrollBy",direction:Fe.DOWN,options:{amount:v,behavior:"auto",isTabActive:r}})}catch{}if(!H||!H.success){let z=e.defaultView||window;H=Eo(M,e,z,Fe.DOWN,v),q=2}if(!H?.success)break;let U=H.scrollTop??P??0;if(P!==null){let z=Math.max(0,U-P);D+=z,q=z===0?q+1:0}if(P=U,H.isAtBottom||q>=2||D>=x)break;if(_>0&&F<I-1){let z=Math.min(_,Math.max(0,i()));if(z<=0)break;await Je(z,e)}}if(h>0){let F=Math.min(h,Math.max(0,i()));F>0&&await Je(F,e)}if(i()>80)try{let F=e.scrollingElement||e.documentElement||e.body,H=e.defaultView||window,U=M===e.documentElement||M===e.body||M===F?F:M;if(U){let z=U===F?H.innerHeight:U.clientHeight||H.innerHeight,Z=Math.max(0,U.scrollHeight-z);U.scrollTop=Z}}catch{}return!0}function Gu(e,t){try{return e.querySelector(t)}catch{return null}}async function Fa(e,t){let n=e.defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",i=(n[r]?.scroll||n.__RTRVR_SCROLL_API__)?.execute;return typeof i!="function"?null:i(t)}async function qu(e,t){let n=e.defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",s=n[r]?.flushScan;if(typeof s!="function"){try{n.rtrvrAIMarkInteractiveElements?.()}catch{}return}let i=Date.now()+Math.max(100,Math.floor(t.totalBudgetMs)),c=0;for(;c<t.maxPasses&&It(i)>0;){let d=Math.max(50,Math.min(t.budgetMs,It(i)));try{await s({mode:t.mode??"full",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:d,deadlineEpochMs:i})}catch{break}if(Ha(e)===0)break;c++}if(Ha(e)>0&&It(i)>50){let d=Math.min(120,It(i));try{await s({mode:"priority",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:d,deadlineEpochMs:i})}catch{}}}function Ha(e){let t=e.documentElement;if(!t)return 0;let n=t.getAttribute(mr);if(!n)return 0;let r=Number.parseInt(n,10);return Number.isFinite(r)&&r>0?r:0}function Yu(e){let t=Xu(e.URL||"");if(!t?.sheetId)return;let n=zu(e),r=n?.title||"Sheet1";return{sheetId:t.sheetId,sheetTitle:e.title||n?.title||void 0,sheetTab:r,sheetTabId:t.sheetTabId??n?.id,sheetTabs:void 0}}function Xu(e){if(!e)return null;try{let t=new URL(e);if(t.hostname!=="docs.google.com")return null;let n=t.pathname.split("/"),r=n.indexOf("spreadsheets"),o=n.indexOf("d");if(r===-1||o===-1||o!==r+1||n.length<=o+1)return null;let s=n[o+1];if(!s||!/^[a-zA-Z0-9_-]+$/.test(s))return null;let i;return t.hash&&t.hash.includes("gid=")&&(i=new URLSearchParams(t.hash.substring(1)).get("gid")??void 0),!i&&t.searchParams.has("gid")&&(i=t.searchParams.get("gid")??void 0),i&&!/^\\d+$/.test(i)&&(i=void 0),{sheetId:s,sheetTabId:i?parseInt(i,10):0}}catch{return null}}function zu(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,r=t.getAttribute("data-sheet-id")||t.getAttribute("data-tab-id")||void 0,o=r&&/^\d+$/.test(r)?Number(r):void 0;return{title:n,id:o}}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 ju={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,r={frameworks:new Set,reactRoots:new WeakSet,vueRoots:new WeakSet,angularRoots:new WeakSet,svelteRoots:new WeakSet,jqueryRoots:new WeakSet},o=new WeakMap,s=new WeakMap,i=new Set,c=500,d=200,_=0,h=0,v=new WeakSet,I="__RTRVR_ET_HOOKED__",x="__RTRVR_ATTACH_SHADOW_HOOKED__";function M(u){if(u&&!v.has(u)){v.add(u);try{D(u)}catch{}try{P(u)}catch{}}}function D(u){try{let w=u.EventTarget;if(!w?.prototype||w.prototype[I])return;w.prototype[I]=!0;let R=w.prototype.addEventListener,T=w.prototype.removeEventListener;w.prototype.addEventListener=function(k,N,V){try{Ue(N)||Rt(this,k,V)}catch{}return R.call(this,k,N,V)},w.prototype.removeEventListener=function(k,N,V){try{Zt(this,k,V)}catch{}return T.call(this,k,N,V)};try{let k=Function.prototype.toString;w.prototype.addEventListener.toString=()=>k.call(R),w.prototype.removeEventListener.toString=()=>k.call(T)}catch{}}catch{}}function P(u){try{let w=u.Element;if(!w?.prototype?.attachShadow||w.prototype[x])return;w.prototype[x]=!0;let R=w.prototype.attachShadow;w.prototype.attachShadow=function(T){let k=R.call(this,T);try{Xe.set(this,k)}catch{}try{J(k)}catch{}return k};try{let T=Function.prototype.toString;w.prototype.attachShadow.toString=()=>T.call(R)}catch{}}catch{}}function q(u){let R=n.get(u)?.listenerTypeMasks;if(R&&R.size){let T=[];for(let k of R.keys()){let N=tn[k];N&&T.push(N)}return T}return fr(u)}let F=["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"],H=0,U=new Set,z=6,Z=["click","input","change","keydown","keyup","pointerdown","pointerup","submit","focus","blur"],ne=["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 se={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 Q(u){return u?String(u).split(".")[0].toLowerCase():""}let ie=["data-click","data-action","data-event","data-handler","data-on-click","data-onclick","data-tap","data-press","data-toggle","data-target"],ce=0,ge=null,ve=new MessageChannel,Be=[];ve.port1.onmessage=()=>{let u=Be.shift();u&&u()};function le(){return Date.now()}function ke(u){return!u||!Number.isFinite(u)?Number.POSITIVE_INFINITY:Math.max(0,u-le())}let We=8,at=new MessageChannel,Ze=!1;function qe(){if(!Ze){Ze=!0;try{at.port2.postMessage(0)}catch{}}}function ct(u){let w=u.values().next();if(w.done)return null;let R=w.value;return u.delete(R),R}function De(){return new Promise(u=>{Be.push(u),ve.port2.postMessage(0)})}let pt=!1;function ye(){if(!pt)try{let u=e.jQuery;u&&u.fn&&(en(u),pt=!0,Ye("jquery"))}catch{}}function ht(u,w){for(let R=w.lastElementChild;R;R=R.previousElementSibling)u.push(R)}function jt(u,w,R){if(R)try{let T=pe(w);T&&u.push(T)}catch{}}function En(u,w,R){if(R&&dr(w))try{let T=w.contentWindow||null;T&&M(T);let k=T?.document?.documentElement;k&&u.push(k)}catch{}}let At=new WeakSet;function cn(u){u&&(typeof u=="function"||typeof u=="object")&&At.add(u)}function Ue(u){return!!u&&(typeof u=="function"||typeof u=="object")&&At.has(u)}at.port1.onmessage=()=>{Ze=!1,Ut(500);let u=performance.now();for(;U.size&&performance.now()-u<We;){let w=ct(U);if(!w)break;try{C(w)}catch{}finally{H=Math.max(0,H-1)}}for(;i.size&&performance.now()-u<We;){let w=ct(i);if(!w)break;try{yn(w)}catch{}}mt(),(U.size||i.size)&&qe()};function mt(){try{let u=ze()?.documentElement;if(!u)return;u.setAttribute(mr,String(H))}catch{}}function Ft(u){let w=n.get(u);return w||(w={frameworks:new Set,listeners:new Map},n.set(u,w)),w}function ln(u){i.add(u),qe()}function Ht(u){U.has(u)||(U.add(u),H++,mt(),qe(),U.size>8e3&&Ut(3e3))}function Ut(u=2e3){let w=0;for(let R of U){if(w>u)break;R.isConnected||(U.delete(R),H=Math.max(0,H-1))}w=0;for(let R of i){if(w>u)break;R.isConnected||i.delete(R)}mt()}let Oe=null;function $n(u,w,R){return`${u}|${w?1:0}|${R?1:0}`}function Kt(u){let w=u.tagName;if(w==="A"||w==="BUTTON"||w==="INPUT"||w==="SELECT"||w==="TEXTAREA"||w==="SUMMARY"||u.hasAttribute("role")||u.hasAttribute("tabindex")||u.hasAttribute("contenteditable")||u.hasAttribute("onclick")||u.getAttributeNames().some(R=>R.startsWith("on")))return!0;for(let R of ie)if(u.hasAttribute(R))return!0;return!!(u.hasAttribute("aria-haspopup")||u.hasAttribute("aria-expanded"))}function Qt(u){let w=re(u);if(!$e(u,w))return!1;let R=u.tagName;if(R!=="DIV"&&R!=="SPAN"&&R!=="LI"&&R!=="SECTION"&&R!=="ARTICLE"&&R!=="P")return!1;let T=u;if(T.__ngContext__||T.__svelte__||T.__vue__||T._vnode||T.__reactFiber$||T.__reactProps$)return!0;let k=0;for(let N in T){if(++k>30)break;if(N.startsWith("__react")||N.includes("reactFiber")||N.includes("reactProps"))return!0}return!1}function Et(){let u=ze()?.documentElement;return u?r.frameworks.size>0||u.hasAttribute("rtrvr-react")||u.hasAttribute("rtrvr-vue")||u.hasAttribute("rtrvr-angular")||u.hasAttribute("rtrvr-svelte")||u.hasAttribute("rtrvr-jquery"):!1}function Jt(u){let w=performance.now();for(;U.size&&performance.now()-w<u;){let R=ct(U);if(!R)break;try{C(R)}catch{}finally{H=Math.max(0,H-1)}}for(;i.size&&performance.now()-w<u;){let R=ct(i);if(!R)break;try{yn(R)}catch{}}}async function xt(u={}){Ut(3e3),ye(),be();let w=u.mode??"full",R=u.includeShadow??!0,T=u.includeSameOriginIframes??!0,k=Math.max(50,Math.min(u.budgetMs??2500,15e3)),N=u.deadlineEpochMs,V=Math.max(0,Math.min(k,ke(N))),j=$n(w,R,T);if(V<=0){let Ke=(Oe?.stack?.length??0)+U.size+i.size;return{revision:++ce,scanned:0,durationMs:0,done:Ke===0,remaining:Ke}}if((!Oe||Oe.optsKey!==j)&&ke(N)>30&&await Y({budgetMs:18,deadlineEpochMs:N}),w==="priority"){let Ke=performance.now(),Me=0;for(;U.size&&performance.now()-Ke<=V&&!(N&&ke(N)<=0);){let Pe=ct(U);if(!Pe)break;try{C(Pe)}catch{}Me++,H=Math.max(0,H-1)}for(;i.size&&performance.now()-Ke<=V&&!(N&&ke(N)<=0);){let Pe=ct(i);if(!Pe)break;try{yn(Pe)}catch{}}return mt(),{revision:++ce,scanned:Me,durationMs:performance.now()-Ke,done:U.size===0&&i.size===0,remaining:U.size+i.size}}if(!Oe||Oe.optsKey!==j){let Ke=ze()?.documentElement;Oe={optsKey:j,stack:Ke?[Ke]:[],scannedTotal:0}}let _e=performance.now(),Re=0;for(H++,mt();Oe.stack.length&&!(N&&ke(N)<=0);){let Ke=Oe.stack.pop();if(vt(Ke)){let Pe=Ke.children;for(let xn=Pe.length-1;xn>=0;xn--)Oe.stack.push(Pe[xn]);continue}let Me=Ke;if(!(!Me||Me.nodeType!==1)&&!(Me.tagName==="SCRIPT"||Me.tagName==="STYLE"||Me.tagName==="META"||Me.tagName==="NOSCRIPT")){try{(Kt(Me)||Et()&&Qt(Me))&&C(Me)}catch{}try{yn(Me)}catch{}if(U.delete(Me)&&(H=Math.max(0,H-1)),i.delete(Me),Re++,Oe.scannedTotal++,R)try{let Pe=pe(Me);Pe&&(J(Pe),Oe.stack.push(Pe))}catch{}if(T&&dr(Me))try{let Pe=Me.contentWindow||null;Pe&&M(Pe);let xn=Pe?.document,ti=xn?.documentElement;xn&&ti&&(oe(xn),Oe.stack.push(ti))}catch{}for(let Pe=Me.lastElementChild;Pe;Pe=Pe.previousElementSibling)Oe.stack.push(Pe);Re%800===0&&ke(N)>20&&await De()}}let Ce=Math.max(0,V-(performance.now()-_e)),lt=ke(N);Jt(Math.min(250,Ce,lt)),H=Math.max(0,H-1),mt();let qt=Oe.stack.length===0,Yn=Oe.stack.length;return qt&&(Oe=null),{revision:++ce,scanned:Re,durationMs:performance.now()-_e,done:qt,remaining:Yn}}async function Pt(u={}){return ge||(ge=xt(u).finally(()=>{ge=null}),ge)}e.rtrvrAIFlushScan=Pt;let Bt="__RTRVR_INTERNAL__";Object(window).__RTRVR_INTERNAL_KEY__=Bt;let Wt=e[Bt],wn=Wt&&typeof Wt=="object"?Wt:{};if(!Wt)try{Object.defineProperty(e,Bt,{value:wn,writable:!1,configurable:!1,enumerable:!1})}catch{}try{Object.defineProperty(wn,"flushScan",{value:Pt,writable:!1,configurable:!1,enumerable:!1})}catch{}function ue(u,w){let R=Ft(u),T=Q(w.type);if(!T)return;let k=!1,N=R.listeners.get(T);N||(N=[],R.listeners.set(T,N),k=!0);let V=N.find(ae=>ae.source===w.source&&!!ae.inferred==!!w.inferred);if(V){let ae=!!V.capture,_e=!!V.passive,Re=!!V.once;V.capture=V.capture||w.capture,V.passive=V.passive||w.passive,V.once=V.once||w.once,(ae!==!!V.capture||_e!==!!V.passive||Re!==!!V.once)&&(k=!0)}else N.push({...w,type:T}),k=!0;let j=we[T];if(j!==void 0){R.listenerTypeMasks||(R.listenerTypeMasks=new Map);let ae=0,_e=ju[w.source];ae|=_e!==void 0?_e:Tt.Other,w.inferred&&(ae|=Tt.Inferred);let Re=R.listenerTypeMasks.get(j)||0,Ce=Re|ae;Ce!==Re&&(R.listenerTypeMasks.set(j,Ce),k=!0)}k&&(R.role=void 0,ln(u))}function et(u){let w=u.listenerTypeMasks;return!w||w.size===0?null:[...w.entries()].sort((T,k)=>T[0]-k[0]).map(([T,k])=>`${T}~${(k||0).toString(36)}`).join(",")}function Vt(u,w){let R=Ft(u);R.frameworks.has(w)||(R.frameworks.add(w),ln(u))}function Ye(u){r.frameworks.has(u)||(r.frameworks.add(u),ze()?.documentElement?.setAttribute(`rtrvr-${u}`,"1"))}function yn(u){let w=n.get(u);if(!w)return;i.delete(u);let R=et(w);R?R!==w.lastListenersSerialized&&(u.setAttribute(dn,R),w.lastListenersSerialized=R):w.lastListenersSerialized&&(u.removeAttribute(dn),w.lastListenersSerialized=void 0);let T=re(u);if($e(u,T))if(w.role===void 0&&(w.role=ur(u)),w.role){let k=jn[w.role],N=typeof k=="number"?String(k):`s:${w.role}`;N!==w.lastRoleSerialized&&(u.setAttribute(rn,N),w.lastRoleSerialized=N)}else(w.lastRoleSerialized||u.hasAttribute(rn))&&(u.removeAttribute(rn),w.lastRoleSerialized=void 0)}function Gn(u){let w=[],R=u;for(;R;)w.push(R),R=R.parentNode||R.host;return w}function vn(u){let w=u.tagName.toLowerCase(),R=u.getAttribute("role"),T=R?R.toLowerCase().trim():"";if(T&&nn.has(T)||w==="button"||(w==="a"||w==="area")&&u.hasAttribute("href"))return!0;if(w==="input")return u.type?.toLowerCase()!=="hidden";if(w==="select"||w==="textarea"||(w==="video"||w==="audio")&&u.hasAttribute("controls")||u.isContentEditable||u.hasAttribute("contenteditable"))return!0;let k=u.getAttribute("tabindex");return!!(k!==null&&!Number.isNaN(Number.parseInt(k,10))&&(q(u).some(j=>Zr.has(j))||u.getAttributeNames().some(j=>j.startsWith("on"))))}function Se(u,w=10,R=600){let T=[];for(let N=0;N<u.children.length;N++)T.push({node:u.children[N],depth:1});let k=0;for(;T.length;){let{node:N,depth:V}=T.pop();if(++k>R||vn(N))return!0;if(!(V>=w))for(let j=0;j<N.children.length;j++)T.push({node:N.children[j],depth:V+1})}return!1}function ur(u){let w=u.tagName.toLowerCase(),R=u.getAttribute("role"),T=R?R.toLowerCase().trim():"",k=u.type?.toLowerCase();if(T&&nn.has(T))return T;if(T&&pr.has(T))return null;if(w==="a"&&u.hasAttribute("href"))return"link";if(w==="button")return"button";if(w==="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":u.hasAttribute("list")?"combobox":"textbox";if(w==="textarea")return"textbox";if(w==="select"){let Ce=u;return Ce.multiple||Ce.size&&Ce.size>1?"listbox":"combobox"}if(w==="option")return"option";if(w==="form")return"form";if(w==="video"||w==="audio"){let Ce=fr(u);return u.hasAttribute("controls")||Ce.length>0?"media":null}if(u.isContentEditable||u.hasAttribute("contenteditable"))return"textbox";let N=q(u);if(!N.length)return null;let V=!1,j=!1,ae=!1;for(let Ce=0;Ce<N.length;Ce++){let lt=N[Ce];!V&&Zr.has(lt)&&(V=!0),!j&&ss.has(lt)&&(j=!0),!ae&&is.has(lt)&&(ae=!0)}if(!V&&!j&&!ae)return null;let _e=u.getAttribute("tabindex"),Re=_e!==null&&!Number.isNaN(Number.parseInt(_e,10));if(V&&(ms(u)||u.getAttribute("href")||u.closest("a[href]")))return"link";if(j){if(u.isContentEditable||u.hasAttribute("contenteditable"))return"textbox";if(T==="textbox"||T==="searchbox"||T==="combobox"||T==="spinbutton")return T;if(!V&&Re)return"textbox"}if(V){let Ce=u.getAttribute("aria-checked"),lt=u.getAttribute("aria-pressed");if(Ce!==null||lt!==null){if(T==="radio")return"radio";if(T==="menuitemradio")return"menuitemradio";if(T==="menuitemcheckbox")return"menuitemcheckbox";if(lt!==null)return"button";if(Ce!==null)return"checkbox"}if((Re||T==="button")&&!Se(u))return"button"}return ae?"application":null}let Ur=EventTarget.prototype.addEventListener,Pr=EventTarget.prototype.removeEventListener;function qn(u){let w=!1,R,T;return typeof u=="boolean"?w=u:u&&typeof u=="object"&&(w=!!u.capture,R=u.passive,T=u.once),{capture:w,passive:R,once:T}}function _n(u){try{let w=u;if(w?.nodeType===9&&w?.documentElement)return w;let R=w?.document;if(R&&R.nodeType===9&&R.documentElement)return R}catch{}return null}function Rt(u,w,R){let T=Q(w);if(!T)return;let{capture:k,passive:N,once:V}=qn(R),j=o.get(u);j||(j=new Map,o.set(u,j));let ae=j.get(T);if(ae?(ae.count+=1,ae.capture=ae.capture||k,ae.passive=ae.passive||N):j.set(T,{count:1,capture:k,passive:N}),In(u))try{ue(u,{type:T,source:"native",capture:k,passive:N,once:V})}catch{}let _e=_n(u);if(_e&&(T==="click"||T==="input"||T==="keydown"))try{_e.documentElement?.setAttribute(`rtrvr-gl-${T}`,"1")}catch{}}function Zt(u,w,R){let T=Q(w);if(!T)return;let k=o.get(u);if(!k)return;let N=k.get(T);N&&(N.count-=1,N.count<=0&&k.delete(T),k.size===0&&o.delete(u))}M(window);function en(u){if(!u||!u.fn)return;let w=u.fn.on,R=u.fn.off;function T(N){if(!N)return[];if(typeof N=="string")return N.split(/\s/).map(V=>Q(V)).filter(Boolean);if(typeof N=="object")try{return Object.keys(N).map(V=>Q(V)).filter(Boolean)}catch{return[]}return[]}function k(N){try{if(!N)return null;if(In(N))return N;let V=re(N);return jr(N,V)||null}catch{}return null}u.fn.on=function(N,V){let j=T(N),ae=typeof V=="string"&&!!V;return this.each(function(){let _e=k(this);if(_e){if(ae){let Re=s.get(_e);Re||(Re=[],s.set(_e,Re));for(let Ce of j){let lt=`${Ce}::${V}`;Re.some(qt=>`${qt.type}::${qt.selector}`===lt)||(Re.push({type:Ce,selector:V}),Re.length>400&&Re.shift())}}else for(let Re of j)ue(_e,{type:Re,source:"jquery"});Vt(_e,"jquery"),Ye("jquery"),r.jqueryRoots.add(_e)}}),w.apply(this,arguments)},u.fn.off=function(){return R.apply(this,arguments)},Ye("jquery")}function $t(u){ie.some(R=>u.hasAttribute(R))&&(ue(u,{type:"click",source:"other",inferred:!0}),(u.tagName==="INPUT"||u.tagName==="TEXTAREA")&&(ue(u,{type:"input",source:"other",inferred:!0}),ue(u,{type:"change",source:"other",inferred:!0})))}function Gt(u){let w=re(u),R=$e(u,w),T=u.getAttributeNames().some(ae=>ae.startsWith("on")),k=/^(button|a|input|select|textarea|summary)$/i.test(u.tagName),N=u,V=R&&(ro(u)||!!N.isContentEditable||u.hasAttribute("contenteditable")),j=R&&!!N.draggable;if(!T&&!k&&!V&&!j){$t(u);return}for(let[ae,_e]of Object.entries(se))typeof u[ae]=="function"&&ue(u,{type:_e,source:"inline"});V&&(ue(u,{type:"input",source:"other",inferred:!0}),ue(u,{type:"keydown",source:"other",inferred:!0}),ue(u,{type:"keyup",source:"other",inferred:!0}),ue(u,{type:"paste",source:"other",inferred:!0})),j&&(ue(u,{type:"dragstart",source:"other",inferred:!0}),ue(u,{type:"dragend",source:"other",inferred:!0})),$t(u)}function Tn(u){if(!u.startsWith("on")||u.length<=2)return null;if(u.endsWith("Capture")){let R=u.substring(2,u.length-7);return R?{type:R.toLowerCase(),capture:!0}:null}let w=u.substring(2);return w?{type:w.toLowerCase(),capture:!1}:null}function un(u){let w=null;if(u){for(let R in u)if(R.startsWith("__react")||R.startsWith("_react")||R.includes("reactFiber")||R.includes("reactProps")||R.includes("reactInternalInstance")){w=R;break}if(w)try{let R=u[w],T=R?.memoizedProps||R?.pendingProps;if(T&&typeof T=="object"){for(let k in T){if(typeof T[k]!="function")continue;let V=Tn(k);V&&ue(u,{type:V.type,source:"react",capture:V.capture})}In(R?.stateNode)&&r.reactRoots.add(R.stateNode),Vt(u,"react"),Ye("react")}}catch{}}}function a(u){let w=u,R=!1;if(w.__vue__){R=!0;let T=w.__vue__;T.$listeners&&Object.keys(T.$listeners).forEach(k=>ue(u,{type:k,source:"vue"})),T._events&&Object.keys(T._events).forEach(k=>ue(u,{type:k,source:"vue"})),T.$options?._parentListeners&&Object.keys(T.$options._parentListeners).forEach(k=>ue(u,{type:k,source:"vue"})),r.vueRoots.add(u)}if(w._vnode?.props){R=!0;let T=w._vnode.props;Object.keys(T).forEach(k=>{k.startsWith("on")&&k.length>2&&ue(u,{type:k.substring(2).toLowerCase(),source:"vue"})}),r.vueRoots.add(u)}R&&(Vt(u,"vue"),Ye("vue"))}function E(u){let w=u,R=!1;if(w.__ngContext__||u.hasAttribute("_ngcontent")||u.hasAttribute("ng-version")){R=!0,Array.from(u.attributes).forEach(T=>{if(T.name.startsWith("(")&&T.name.endsWith(")")){let k=T.name.slice(1,-1).split(".")[0];k&&ue(u,{type:k,source:"angular"})}if(T.name.startsWith("on-")){let k=T.name.substring(3);k&&ue(u,{type:k,source:"angular"})}if(T.name.includes(".")){let k=T.name.match(/\(([^.)]+)/);k?.[1]&&ue(u,{type:k[1],source:"angular"})}});try{if(e.ng?.getComponent){let T=e.ng.getComponent(u);T&&Object.keys(T).forEach(k=>{(k.endsWith("Output")||k.endsWith("Emitter"))&&ue(u,{type:k.replace(/(Output|Emitter)$/,"").toLowerCase(),source:"angular"})})}}catch{}}R&&(Vt(u,"angular"),Ye("angular"),r.angularRoots.add(u))}function m(u){let w=u,R=!1;if(w.__svelte__){R=!0,Array.from(u.attributes).forEach(T=>{if(T.name.startsWith("on:")){let k=T.name.substring(3);k&&ue(u,{type:k,source:"svelte"})}});try{let T=w.__svelte__?.$$?.callbacks;T&&typeof T=="object"&&Object.keys(T).forEach(k=>ue(u,{type:k,source:"svelte"}))}catch{}r.svelteRoots.add(u)}R&&(Vt(u,"svelte"),Ye("svelte"))}function g(u,w){return u?!!o.get(u)?.has(w):!1}function p(u,w,R=96){let T=Q(w);if(!T)return!1;let k=G(u),N=X(k);if(g(k,T)||g(N,T))return!0;let V=0,j=u;for(;j&&V<R;){if(j.parentElement)j=j.parentElement;else{let ae=j.getRootNode?.();if(vt(ae)){if(g(ae,T)||g(ae.host,T))return!0;j=ae.host}else break}if(j&&g(j,T))return!0}return!1}function l(u,w,R=128){let T=0,k=u;for(;k&&T<R;){if(w(k),k.parentElement){k=k.parentElement;continue}let N=k.getRootNode?.();if(vt(N)){k=N.host;continue}break}}function f(u){let w=re(u);if(!$e(u,w))return;let R=Ft(u);R.role=R.role||ur(u);let T=p(u,"click"),k=p(u,"input"),N=p(u,"keydown"),j=G(u).documentElement;if(r.frameworks.size>0||j.hasAttribute("rtrvr-react")||j.hasAttribute("rtrvr-vue")||j.hasAttribute("rtrvr-angular")||j.hasAttribute("rtrvr-svelte")||j.hasAttribute("rtrvr-jquery")||T||k||N){let _e=R.role||"other";T&&["button","link","checkbox","radio","switch","menuitem","menuitemcheckbox","menuitemradio","tab","option","treeitem","gridcell","cell","img","figure"].includes(_e)&&ue(u,{type:"click",source:"delegated",inferred:!0}),["textbox","searchbox","spinbutton","code"].includes(_e)&&(k&&(ue(u,{type:"input",source:"delegated",inferred:!0}),ue(u,{type:"change",source:"delegated",inferred:!0})),N&&ue(u,{type:"keydown",source:"delegated",inferred:!0})),["combobox","listbox"].includes(_e)&&(T&&ue(u,{type:"click",source:"delegated",inferred:!0}),k&&ue(u,{type:"change",source:"delegated",inferred:!0})),["slider","scrollbar","progressbar","meter"].includes(_e)&&k&&ue(u,{type:"input",source:"delegated",inferred:!0})}l(u,_e=>{let Re=s.get(_e);if(Re?.length)for(let{type:Ce,selector:lt}of Re)try{u.matches(lt)&&(ue(u,{type:Ce,source:"jquery",inferred:!0}),Vt(u,"jquery"),Ye("jquery"))}catch{}})}function b(u){let w=R=>{let T=R,k=T.composedPath&&T.composedPath()||Gn(R.target),V=u==="mousemove"||u==="pointermove"||u==="scroll"||u==="wheel"?1:Math.min(k.length,z);for(let j=0;j<V;j++){let ae=k[j];In(ae)&&ue(ae,{type:u,source:"delegated",inferred:!0})}};cn(w);try{Ur.call(document,u,w,{capture:!0,passive:!0})}catch{}}let S=!1;function A(){Z.forEach(b);let u=ze()?.documentElement;if(!u)return;let w=()=>{if(S)return;let R=u.hasAttribute("rtrvr-react")||u.hasAttribute("rtrvr-vue")||u.hasAttribute("rtrvr-angular")||u.hasAttribute("rtrvr-svelte"),T=u.hasAttribute("rtrvr-gl-click")||u.hasAttribute("rtrvr-gl-input")||u.hasAttribute("rtrvr-gl-keydown");(R||T)&&(S=!0,ne.forEach(b))};w();try{new MutationObserver(()=>w()).observe(u,{attributes:!0,attributeFilter:["rtrvr-react","rtrvr-vue","rtrvr-angular","rtrvr-svelte","rtrvr-gl-click","rtrvr-gl-input","rtrvr-gl-keydown"]})}catch{}}function C(u){if(u.nodeType!==1)return;let w=re(u);if($e(u,w)){let R=Ft(u);R.role=void 0}Gt(u),un(u),a(u),E(u),m(u),f(u),ln(u)}function O(){let u=["a[href]","button","input","select","textarea","summary","details > summary",...Array.from(nn).map(w=>`[role="${w}"]`),"[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"];H++,mt();try{let w=u.join(",");ze()?.querySelectorAll(w).forEach(R=>{try{C(R)}catch{}})}finally{H=Math.max(0,H-1),mt()}}function W(u){for(let w of u){for(let R of Array.from(w.addedNodes)){if(R.nodeType!==1)continue;let T=R;Ht(T),T.querySelectorAll?.('a,button,input,select,textarea,summary,[role],[onclick],[ondblclick],[ondoubleclick],[contenteditable],[draggable="true"],[tabindex]').forEach(Ht)}if(w.type==="attributes"&&w.target.nodeType===1){let R=w.target;w.attributeName==="class"?(Et()||Kt(R))&&Ht(R):Ht(R)}}}async function Y(u={}){let w=ze(),R=w?.documentElement;if(!R||!(R.hasAttribute("rtrvr-react")||R.hasAttribute("rtrvr-vue")||R.hasAttribute("rtrvr-angular")||R.hasAttribute("rtrvr-svelte")))return;let k=u.deadlineEpochMs,N=Math.max(5,Math.min(u.budgetMs??12,50));if(Math.max(0,Math.min(N,ke(k)))<=0)return;let j=performance.now();H++,mt();try{let ae=0,_e=4e3,Re=["div","span","li","section","article","p"];for(let Ce of Re){let lt=w.getElementsByTagName(Ce)??[];for(let qt=0;qt<lt.length;qt++){if(ae++>=_e||k&&ke(k)<=0)return;let Yn=lt[qt],Ke=Yn;(Ke.__ngContext__||Ke.__svelte__||Ke.__vue__||Ke._vnode||Qt(Yn))&&C(Yn),ae%250===0&&ke(k)>20&&await De()}}}finally{H=Math.max(0,H-1),mt()}}let K=new MutationObserver(W),fe=new WeakMap;function J(u){if(!fe.has(u)&&!(_>=c))try{let w=X(u.ownerDocument).MutationObserver||MutationObserver,R=new w(W);fe.set(u,R),_++,R.observe(u,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...F,"class"]})}catch{}}let te=new WeakMap;function oe(u){if(!te.has(u)&&!(h>=d))try{M(u.defaultView||null);let w=u.documentElement;if(!w)return;let R=X(u).MutationObserver||MutationObserver,T=new R(W);te.set(u,T),h++,T.observe(w,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...F,"class"]})}catch{}}function xe(){let u=ze()?.documentElement;u&&K.observe(u,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...F,"class"]})}let Xe=new WeakMap;function pe(u){return u.shadowRoot||Xe.get(u)||null}try{Object.defineProperty(wn,"shadow",{value:Object.freeze({getRoot:u=>pe(u)}),writable:!1,configurable:!1,enumerable:!1})}catch{}function be(){try{(e.React||e.__REACT_DEVTOOLS_GLOBAL_HOOK__)&&Ye("react"),e.Vue&&Ye("vue"),e.ng&&Ye("angular"),e.jQuery&&Ye("jquery"),ye()}catch{}}e.rtrvrAIMarkInteractiveElements=function(){return ze()?.body?(O(),!0):!1};function Ee(){let u=ze();ye(),be(),A();let w=()=>{ye(),be(),xe(),e.rtrvrAIMarkInteractiveElements?.(),Y({budgetMs:20}),u?.documentElement.setAttribute(ns,"1")};u?.readyState==="loading"?u.addEventListener("DOMContentLoaded",w,{once:!0}):w()}Ee()})();var Ro=null;function Ls(e){try{return e.getAttribute(dn)}catch{return null}}function Wa(e){let t=Ls(e);return Sn(t)?.entries??[]}function Va(e){try{let t=e.getAttribute(rn);return t&&t.trim()?t:null}catch{return null}}function Ku(e){let t=e?.ownerDocument?.defaultView,n=t?.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",o=t?.[n]?.shadow?.getRoot;if(typeof o=="function")try{return o(e)||null}catch{}return e.shadowRoot||null}function Qu(e){let t=new Set;for(let n of e){let r=Vr(n.mask);for(let o of r)(o==="react"||o==="vue"||o==="angular"||o==="svelte"||o==="jquery")&&t.add(o)}return t}function Ju(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 Zu(e){let t=Wa(e),n=Qu(t),r=Ju(e);for(let o of r)n.add(o);return{frameworks:[...n],listenersRaw:Ls(e)||"",role:Va(e)??(e.getAttribute?.("role")||null)}}function ed(){return{getEventHandlerIds:e=>Wa(e).map(t=>t.id),getRoleHint:Va,getShadowRoot:Ku}}function $a(e={}){if(Ro)return Ro;if(typeof window<"u")try{window.rtrvrAIMarkInteractiveElements?.()}catch{}return Ro={signalProvider:ed(),getFrameworkMetadata:Zu,getListenerEncoding:Ls,dispose:()=>{}},Ro}var Co=class{constructor(t={}){$(this,"root");$(this,"includeFrames");$(this,"disableDomAnnotations");$(this,"allowActions");$(this,"runtimeId");$(this,"domainScopeMode");$(this,"allowedDomains");$(this,"externalNavigationPolicy");$(this,"registerOpenedTab");$(this,"listKnownTabs");$(this,"switchToLogicalTab");$(this,"onNavigationGuardrail");$(this,"instrumentation");$(this,"highlightEl",null);$(this,"clientTools",new Map);$(this,"uploadStore",new Map);$(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=Ga(t.domainScopeMode),this.allowedDomains=Ns(t.allowedDomains,window.location.hostname,this.domainScopeMode),this.externalNavigationPolicy=qa(t.externalNavigationPolicy,t.crossDomainPolicy),this.registerOpenedTab=t.registerOpenedTab,this.listKnownTabs=t.listKnownTabs,this.switchToLogicalTab=t.switchToLogicalTab,this.onNavigationGuardrail=t.onNavigationGuardrail,this.instrumentation=t.instrumentation??$a({includeIframes:!0,scanInlineHandlers:!0,observeInlineMutations:!0,...t.instrumentationOptions||{}}),Ma(),t.uploadBytesProvider&&this.setUploadBytesProvider(t.uploadBytesProvider)}setAllowActions(t){this.allowActions=!!t}setNavigationPolicy(t){t.domainScopeMode&&(this.domainScopeMode=Ga(t.domainScopeMode),t.allowedDomains||(this.allowedDomains=Ns(void 0,window.location.hostname,this.domainScopeMode))),t.allowedDomains&&(this.allowedDomains=Ns(t.allowedDomains,window.location.hostname,this.domainScopeMode)),(t.externalNavigationPolicy||t.crossDomainPolicy)&&(this.externalNavigationPolicy=qa(t.externalNavigationPolicy,t.crossDomainPolicy))}async getSnapshot(){return await za(this.root),wo(this.root,this.instrumentation,{includeFrames:this.includeFrames,disableDomAnnotations:this.disableDomAnnotations})}async getPageData(t){return await za(this.root),await Ua(this.root,this.instrumentation,{includeFrames:this.includeFrames,disableDomAnnotations:this.disableDomAnnotations,pageConfig:t?.pageConfig})}async executeTool(t,n){let r=td(t?.name);if(!r)return{success:!1,error:`Unknown tool: ${String(t?.name)}`,allowFallback:!1};if(this.shouldBlockForOutOfScopeContext(r)){let I=`Current tab is outside the allowed domain scope (${So(this.allowedDomains)}).`;return this.domainScopeBlockedResponse(window.location.href,I,{fromCurrentContext:!0})}if(!this.allowActions&&!Xa.has(r))return{success:!1,error:"Actions disabled by configuration",allowFallback:!1};let o=await this.handleNavigationTools(r,t?.args||{});if(o)return o;if(r===L.wait_action){let I=Number(t?.args?.duration??1e3);return await new Promise(x=>setTimeout(x,Math.max(0,Math.min(I,6e4)))),{success:!0}}if(r===L.wait_for_element)return this.waitForElement(t?.args||{});if(r===L.answer_task)return{success:!0};if(r===L.solve_captcha)return Ao("CAPTCHA solving requires human intervention in embed mode.","HUMAN_INTERVENTION_REQUIRED");if(r===L.network_run_recipe)return Ao("network_run_recipe is not supported in embed mode.","CAPABILITY_UNAVAILABLE");if(r===L.click_element&&t?.args?.open_in_new_tab)return this.openElementInNewTab(t?.args||{});if(r===L.click_element&&this.shouldInterceptExternalClick(t?.args||{})){let I=this.getExternalClickTargetUrl(t?.args||{});if(I){let x=`Blocked same-tab navigation to out-of-scope domain (${new URL(I).hostname}).`;return this.externalNavigationPolicy==="open_new_tab_notice"?this.openUrlInNewTab(I,{policyBlocked:!0,reason:x}):this.domainScopeBlockedResponse(I,x)}}if(r===L.describe_images)return this.describeImages(t?.args||{});if(!(r in Wr))return{success:!1,error:`Unknown tool: ${String(t?.name)}`,allowFallback:!1};let s=t?.args||{},{doc:i}=nr(document,s.iframe_id),c=s.element_id??s.source_element_id??s.target_element_id??s.center_element_id??null,d=c?Nt(i,c):null,_;if(d){let I=this.instrumentation.getFrameworkMetadata(d),x=cd(I.listenersRaw||"",r),M=s?.value??s?.text??null;_=ad({...I,pattern:x,value:M})}let h=Wr[r];return r===L.upload_file&&!n&&(n=await this.buildUploadPayload(s).catch(()=>{})),La({opcode:h,call:{name:r,args:s},elementData:_,tabIndex:0,payload:n})}highlight(t){let n=Nt(document,t);if(!n)return;let r=n.getBoundingClientRect();if(!this.highlightEl){let o=document.createElement("div");o.style.position="fixed",o.style.pointerEvents="none",o.style.border="2px solid #ff7a59",o.style.boxShadow="0 0 0 2px rgba(255, 122, 89, 0.2)",o.style.borderRadius="6px",o.style.zIndex="2147483647",this.highlightEl=o,document.body.appendChild(o)}this.highlightEl.style.left=`${r.left}px`,this.highlightEl.style.top=`${r.top}px`,this.highlightEl.style.width=`${Math.max(0,r.width)}px`,this.highlightEl.style.height=`${Math.max(0,r.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 r=typeof t=="string"?{name:t}:t;!r?.name||typeof n!="function"||this.clientTools.set(r.name,{handler:n,def:r})}async executeClientTool(t,n){let r=this.clientTools.get(t);if(!r)throw new Error(`Unknown client tool: ${t}`);return r.handler(n)}listClientTools(){return Array.from(this.clientTools.values()).map(t=>t.def)}async handleNavigationTools(t,n){switch(t){case L.goto_url:{let r=String(n.url||"").trim();if(!r)return{success:!1,error:"goto_url: missing url",allowFallback:!0};let o=ko(r,window.location.href);if(!o)return{success:!1,error:`goto_url: invalid url "${r}"`,allowFallback:!0};if(this.shouldGuardExternalNavigation(o)){let s=`Navigation blocked by domain policy. Allowed: ${So(this.allowedDomains)}`;return this.externalNavigationPolicy==="open_new_tab_notice"?await this.openUrlInNewTab(o,{policyBlocked:!0,reason:s}):this.domainScopeBlockedResponse(o,s)}return window.location.href=o,{success:!0,output:{url:o,navigation:"same_tab"}}}case L.google_search:{let r=String(n.query||"").trim();if(!r)return{success:!1,error:"google_search: missing query",allowFallback:!0};let o=`https://www.google.com/search?q=${encodeURIComponent(r)}`;if(this.shouldGuardExternalNavigation(o)){let s=`Google search opens outside the allowed domain scope (${So(this.allowedDomains)}).`;return this.externalNavigationPolicy==="open_new_tab_notice"?await this.openUrlInNewTab(o,{policyBlocked:!0,reason:s}):this.domainScopeBlockedResponse(o,s)}return window.location.href=o,{success:!0,output:{url:o,navigation:"same_tab"}}}case L.go_back:return window.history.back(),{success:!0};case L.go_forward:return window.history.forward(),{success:!0};case L.refresh_page:return window.location.reload(),{success:!0};case L.open_new_tab:{let r=String(n.url||"").trim();if(!r)return{success:!1,error:"open_new_tab: missing url",allowFallback:!0};let o=ko(r,window.location.href);return o?await this.openUrlInNewTab(o,{policyBlocked:!1}):{success:!1,error:`open_new_tab: invalid url "${r}"`,allowFallback:!0}}case L.switch_tab:{let r=Number(n.logical_tab_id??n.tab_id);if(!Number.isFinite(r)||r<=0)return{success:!1,error:"switch_tab: missing/invalid logical_tab_id",allowFallback:!0};if(this.externalNavigationPolicy!=="allow"&&this.listKnownTabs){let o=this.listKnownTabs().find(s=>Number(s.logicalTabId)===r);if(o?.external)return this.domainScopeBlockedResponse(o.url||`logical_tab_id:${r}`,`Tab ${r} is out of scope. Direct actions are blocked outside ${So(this.allowedDomains)}.`)}if(!this.switchToLogicalTab)return Ao("switch_tab requires session coordinator support.","CAPABILITY_UNAVAILABLE");try{let o=await this.switchToLogicalTab(r);return o?.ok?{success:!0,output:{logicalTabId:r,delegated:!!o.delegated,mode:o.delegated?"delegated":"local"}}:{success:!1,error:o?.reason||`switch_tab failed for logical tab ${r}`,allowFallback:!0}}catch(o){return{success:!1,error:o?.message||"switch_tab failed",allowFallback:!0}}}case L.close_tab:try{return window.close(),{success:!0}}catch{return Ao("close_tab failed in embed mode.","CAPABILITY_UNAVAILABLE")}default:return null}}shouldGuardExternalNavigation(t){return this.externalNavigationPolicy==="allow"?!1:!Io(t,this.allowedDomains)}shouldBlockForOutOfScopeContext(t){return this.externalNavigationPolicy==="allow"||Xa.has(t)||id.has(t)?!1:!Io(window.location.href,this.allowedDomains)}shouldInterceptExternalClick(t){if(this.externalNavigationPolicy==="allow")return!1;let n=this.getExternalClickTargetUrl(t);return n?!Io(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:r}=nr(document,t.iframe_id),o=Nt(r,n);if(!o)return null;let s=Ya(o),i=s?.href||s?.getAttribute("href")||"";return ko(i,window.location.href)}domainScopeBlockedResponse(t,n,r){let o=this.externalNavigationPolicy==="block"?"block":"open_new_tab_notice";return this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:o,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:o==="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:o,from_current_context:!!r?.fromCurrentContext},errorDetails:{code:"DOMAIN_SCOPE_BLOCKED",message:n,retryable:!1,details:{blockedUrl:t,currentUrl:window.location.href,allowedDomains:this.allowedDomains,policyAction:o}}}}emitNavigationGuardrail(t){try{this.onNavigationGuardrail?.(t)}catch{}}async openUrlInNewTab(t,n){let r=!Io(t,this.allowedDomains),o=window.open(t,"_blank","noopener,noreferrer"),s;if(this.registerOpenedTab)try{s=(await this.registerOpenedTab({url:t,title:void 0,external:r,openerRuntimeId:this.runtimeId}))?.logicalTabId}catch{}let i=!s&&!!this.registerOpenedTab;if(!o){let d="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||d,allowedDomains:this.allowedDomains,openedInNewTab:!1}),{success:!1,error:"open_new_tab blocked by browser popup settings",allowFallback:!0,output:{url:t,external:r,logicalTabId:s},errorDetails:{code:"POPUP_BLOCKED",message:d,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:r,logicalTabId:s,openedInNewTab:!0,policyBlocked:!!n?.policyBlocked,message:c,...i&&{warning:"Tab opened but registration failed \u2014 tab may not be targetable"}},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:r}=nr(document,t.iframe_id),o=Nt(r,n);if(!o)return{success:!1,error:`click_element: element_id ${String(n)} not found.`,allowFallback:!0};let s=Ya(o),i=s?.href||s?.getAttribute("href")||"",c=ko(i,window.location.href);return c?await this.openUrlInNewTab(c,{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(),r=Math.max(0,Math.min(Number(t.timeout??5e3),3e4));if(!n)return{success:!1,error:"wait_for_element: missing selector",allowFallback:!0};let o=Date.now(),s=document;for(;Date.now()-o<r;){let i=null;try{i=s.querySelector(n)}catch{i=null}if(i||(i=ld(s,n)),i)return{success:!0};await new Promise(c=>setTimeout(c,200))}return{success:!1,error:`wait_for_element: not found (${n})`,allowFallback:!0}}async describeImages(t){let n=ni(t);if(!n.length)return{success:!1,error:"describe_images: element_ids is empty",allowFallback:!1};let r=[],o=[];for(let s of n){let i=Nt(document,s);if(!i){o.push(`element_id ${s} not found`);continue}try{let c=await ud(i);if(!c?.data||!c?.mimeType){o.push(`element_id ${s}: unsupported image`);continue}r.push({element_id:s,...c})}catch(c){o.push(`element_id ${s}: ${c?.message||String(c)}`)}}return r.length?{success:!0,output:{images:r,errors:o.length?o:void 0}}:{success:!1,error:o[0]||"describe_images failed",output:{images:[],errors:o}}}ensureUploadProvider(){this.uploadProviderInstalled||(this.uploadProviderInstalled=!0,this.setUploadBytesProvider(async({token:t,byteLength:n})=>{this.pruneUploadStore();let r=this.uploadStore.get(t);if(!r)throw new Error("upload bytes token not found");if(r.bytes.byteLength!==n)throw new Error("upload bytes size mismatch");return r.bytes}))}pruneUploadStore(){let t=Date.now()-6e5;for(let[n,r]of this.uploadStore.entries())r.createdAt<t&&this.uploadStore.delete(n)}async buildUploadPayload(t){let n=String(t.file_url||"").trim();if(n)try{let r=await Sa(0,n,document?.referrer||null),o=r.bytes,s=o.byteLength,i=r.mimeType||t.mime_type||"application/octet-stream",c=t.file_name||r.fileName,d=1024*1024;if(s<=d)return{kind:"upload_file",inlineB64:Ka(o),byteLength:s,mimeType:i,fileName:c};this.ensureUploadProvider();let _=crypto.randomUUID();return this.uploadStore.set(_,{bytes:o,createdAt:Date.now()}),{kind:"upload_file",token:_,byteLength:s,mimeType:i,fileName:c,durable:!1}}catch{return}}};function td(e){return e==="open_url_new_tab"?L.open_new_tab:String(e||"").trim()}function Ga(e){return e==="host_only"?"host_only":"registrable_domain"}function nd(e){if(e==="allow")return"allow";if(e==="block_new_tab")return"open_new_tab_notice"}function qa(e,t){return e==="allow"||e==="block"||e==="open_new_tab_notice"?e:nd(t)||"open_new_tab_notice"}function Ns(e,t,n){let r=Array.isArray(e)?e:[],o=new Set;for(let s of r){let i=String(s||"").trim().toLowerCase().replace(/^\./,"");i&&o.add(i)}if(!o.size){let s=rd(t,n);s&&o.add(s)}return Array.from(o)}function rd(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 r=n.split(".").filter(Boolean);return r.length<2?n:`${r[r.length-2]}.${r[r.length-1]}`}function ko(e,t){let n=String(e||"").trim();if(!n)return null;try{return new URL(n,t).toString()}catch{return null}}function Io(e,t){let n=od(e);if(!n)return!1;if(!t.length)return!0;for(let r of t)if(sd(n,r))return!0;return!1}function od(e){try{return new URL(e).hostname.toLowerCase()}catch{return null}}function sd(e,t){let n=String(t||"").trim().toLowerCase().replace(/^\./,"");if(!n)return!1;if(n==="*")return!0;if(n.startsWith("=")){let r=n.slice(1);return!!r&&e===r}if(n.startsWith("*.")){let r=n.slice(2);return r?e===r||e.endsWith(`.${r}`):!1}return e===n?!0:e.endsWith(`.${n}`)}function So(e){return e.length?e.map(t=>{let n=String(t||"");return n.startsWith("=")?n.slice(1):n}).join(", "):"*"}function Ya(e){if(e instanceof HTMLAnchorElement&&e.href)return e;let t=e.closest?.("a[href]");return t instanceof HTMLAnchorElement&&t.href?t:null}function Ao(e,t="CAPABILITY_UNAVAILABLE"){return{success:!1,error:e,allowFallback:!0,errorDetails:{code:t,message:e,retryable:!1}}}var Xa=new Set([L.describe_images,L.wait_action,L.wait_for_element,L.answer_task,L.solve_captcha,L.network_run_recipe]),id=new Set([L.goto_url,L.google_search,L.go_back,L.go_forward,L.refresh_page,L.open_new_tab,L.switch_tab,L.close_tab]);function ad(e){return{frameworks:(e.frameworks||[]).filter(n=>n in Jo).map(n=>Jo[n]),listenersRaw:e.listenersRaw??"",role:e.role??null,pattern:e.pattern,value:e.value??null}}async function za(e){try{let n=(e.ownerDocument||document).defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",s=n[r]?.flushScan;if(typeof s=="function"){await s({mode:"priority",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:1500});return}n.rtrvrAIMarkInteractiveElements?.()}catch{}}function cd(e,t){if(t!==L.click_element)return"standard";let n=Sn(e||"");if(!n)return"standard";let r=new Set(n.entries.map(d=>tn[d.id]).filter(d=>typeof d=="string")),o=r.has("click")||r.has("mousedown")||r.has("mouseup")||r.has("pointerdown")||r.has("pointerup")||r.has("touchend");if((r.has("mouseenter")||r.has("mouseover")||r.has("pointerenter"))&&o)return"hover-activate";let i=r.has("touchstart"),c=r.has("touchend");return i&&c?"touch-sequence":"standard"}function Ka(e){let t=new Uint8Array(e),n="",r=32768;for(let o=0;o<t.length;o+=r)n+=String.fromCharCode(...t.subarray(o,o+r));return btoa(n)}function ld(e,t){let n=t.toLowerCase(),r=["button","a","input","textarea","select","label","[role]","div","span"],o=e.querySelectorAll(r.join(","));for(let s of Array.from(o))if((s.textContent||"").trim().toLowerCase().includes(n)||(s.getAttribute("aria-label")||"").toLowerCase().includes(n))return s;return null}async function ud(e){if(e instanceof HTMLCanvasElement){let o=e.toDataURL(),s=Qa(o);if(!s)throw new Error("canvas toDataURL failed");return s}if(e instanceof SVGElement){let o=new XMLSerializer().serializeToString(e);return{data:btoa(unescape(encodeURIComponent(o))),mimeType:"image/svg+xml",displayName:"svg"}}if(e instanceof HTMLImageElement){let o=e.currentSrc||e.src;return await ja(o,e.alt||e.getAttribute("aria-label")||void 0)}let n=window.getComputedStyle(e).backgroundImage||"",r=/url\\((['\"]?)(.*?)\\1\\)/.exec(n);if(r?.[2])return await ja(r[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 ja(e,t){if(!e)throw new Error("missing src");if(e.startsWith("data:")){let c=Qa(e);if(!c)throw new Error("invalid data url");return{...c,displayName:t}}let n=await fetch(e,{mode:"cors"});if(!n.ok)throw new Error(`fetch failed (${n.status})`);let r=await n.blob(),o=await r.arrayBuffer(),s=Ka(o),i=r.type||"image/png";return{data:s,mimeType:i,displayName:t}}function Ja(e,t){e.onmessage=async n=>{let r=n.data;if(!r||r.t!=="req")return;let{id:o,method:s,params:i}=r;try{let c=t[s];if(!c)throw new Error(`No handler for ${s}`);let d=await c(i);e.postMessage({t:"res",id:o,ok:!0,result:d})}catch(c){e.postMessage({t:"res",id:o,ok:!1,error:{message:c?.message||String(c)}})}}}var dd="https://www.rtrvr.ai/rover/mascot.mp4",fd="https://www.rtrvr.ai/rover/mascot.webm";function tc(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Za(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function pd(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 hd(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||tc("trace")}function ir(e){return String(e||"").trim()}function nc(e){let t=ir(e),n=/^(Analyze|Route|Execute|Verify|Complete):\s*(.*)$/i.exec(t);if(!n)return{plainTitle:t};let r=n[1].toLowerCase(),o=ir(n[2]||t);return{stage:r,plainTitle:o||t}}function md(e){let t=(e.title||"").toLowerCase();if(t==="run started"||t==="run resumed"||t==="run completed")return"detail";if(e.kind==="status"){let n=nc(e.title||"");if(n.stage==="analyze"||n.stage==="route"||n.stage==="complete")return"detail"}return"primary"}function Ds(e,t){let n=/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)|\*\*(.+?)\*\*/g,r=0,o;for(;(o=n.exec(t))!==null;){if(o.index>r&&e.appendChild(document.createTextNode(t.slice(r,o.index))),o[1]&&o[2]){let s=document.createElement("a");s.className="rvLink",s.href=o[2],s.target="_blank",s.rel="noopener noreferrer",s.textContent=o[1],e.appendChild(s)}else if(o[3]){let s=document.createElement("strong");s.textContent=o[3],e.appendChild(s)}r=o.index+o[0].length}r<t.length&&e.appendChild(document.createTextNode(t.slice(r)))}function Sr(e){let t=document.createDocumentFragment(),n=e.split(`
|
|
11
|
+
`),r=null;for(let o of n){let s=o.trim();if(!s){r&&(t.appendChild(r),r=null);continue}if(s==="---"){r&&(t.appendChild(r),r=null);let d=document.createElement("hr");d.className="rvSep",t.appendChild(d);continue}if(s.startsWith("- ")){r||(r=document.createElement("ul"),r.className="rvList");let d=document.createElement("li");Ds(d,s.slice(2)),r.appendChild(d);continue}if(r&&(t.appendChild(r),r=null),/^Step \d+/i.test(s)){let d=document.createElement("div");d.className="rvStepHeader",d.textContent=s,t.appendChild(d);continue}if(s.startsWith("[error] ")){let d=document.createElement("div");d.className="rvError",d.textContent=s.slice(8),t.appendChild(d);continue}if(s.startsWith("[next] ")){let d=document.createElement("div");d.className="rvNext",d.textContent=s.slice(7),t.appendChild(d);continue}let i=s.match(/^\*\*(.+?):\*\*\s*(.*)$/);if(i){let d=document.createElement("div");d.className="rvKv";let _=document.createElement("span");_.className="rvKvLabel",_.textContent=i[1];let h=document.createElement("span");h.className="rvKvValue",Ds(h,i[2]),d.appendChild(_),d.appendChild(h),t.appendChild(d);continue}let c=document.createElement("div");c.className="rvLine",Ds(c,s),t.appendChild(c)}return r&&t.appendChild(r),t}function ec(e,t){let n=document.createElement("div");if(n.className="expandableWrap",e.length<=t)return n.appendChild(Sr(e)),n;let r=e.split(`
|
|
12
|
+
`),o=0,s=0;for(let _=0;_<r.length;_++)if(o+=r[_].length+1,o>=t){s=_+1;break}s===0&&(s=1);let i=r.slice(0,s).join(`
|
|
13
13
|
`),c=r.slice(s).join(`
|
|
14
|
-
`),
|
|
14
|
+
`),d=document.createElement("div");if(d.className="expandPreview",d.appendChild(Sr(i)),n.appendChild(d),c.trim()){let _=document.createElement("div");_.className="expandRest",_.appendChild(Sr(c)),_.style.display="none",n.appendChild(_);let h=document.createElement("button");h.type="button",h.className="expandToggle",h.textContent="...Show more",h.addEventListener("click",v=>{v.stopPropagation();let I=_.style.display==="none";_.style.display=I?"block":"none",h.textContent=I?" Show less":"...Show more"}),n.appendChild(h)}return n}function rc(e){let t=document.createElement("div");t.id="rover-widget-root",document.documentElement.appendChild(t);let n=t.attachShadow({mode:"closed"}),r=document.createElement("style");r.textContent=`
|
|
15
15
|
@font-face {
|
|
16
16
|
font-family: 'Manrope';
|
|
17
17
|
font-style: normal;
|
|
@@ -327,6 +327,27 @@ Author: ${c.textContent} `),s.textContent&&(t+=`Comment: ${s.textContent}
|
|
|
327
327
|
border-color: var(--rv-border-strong);
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
+
.stopBtn {
|
|
331
|
+
width: 32px; height: 32px;
|
|
332
|
+
border-radius: var(--rv-radius-sm);
|
|
333
|
+
border: 1px solid rgba(220, 38, 38, 0.25);
|
|
334
|
+
background: rgba(220, 38, 38, 0.06);
|
|
335
|
+
color: var(--rv-error);
|
|
336
|
+
cursor: pointer;
|
|
337
|
+
display: none; place-items: center;
|
|
338
|
+
font-size: 10px;
|
|
339
|
+
font-weight: 700;
|
|
340
|
+
transition: background 120ms ease, border-color 120ms ease;
|
|
341
|
+
flex: 0 0 auto; padding: 0;
|
|
342
|
+
}
|
|
343
|
+
.stopBtn:hover {
|
|
344
|
+
background: rgba(220, 38, 38, 0.12);
|
|
345
|
+
border-color: rgba(220, 38, 38, 0.35);
|
|
346
|
+
}
|
|
347
|
+
.stopBtn.visible {
|
|
348
|
+
display: grid;
|
|
349
|
+
}
|
|
350
|
+
|
|
330
351
|
.muteBtn {
|
|
331
352
|
width: 32px; height: 32px;
|
|
332
353
|
border-radius: var(--rv-radius-sm);
|
|
@@ -1022,10 +1043,10 @@ Author: ${c.textContent} `),s.textContent&&(t+=`Comment: ${s.textContent}
|
|
|
1022
1043
|
gap: 8px;
|
|
1023
1044
|
}
|
|
1024
1045
|
}
|
|
1025
|
-
`;let s=document.createElement("div");s.className="rover",s.dataset.mood="idle";let i=document.createElement("button");i.className="launcher",i.setAttribute("aria-label","Open Rover assistant");let c=e.mascot?.disabled===!0,
|
|
1046
|
+
`;let s=document.createElement("div");s.className="rover",s.dataset.mood="idle";let i=document.createElement("button");i.className="launcher",i.setAttribute("aria-label","Open Rover assistant");let c=e.mascot?.disabled===!0,d=null;if(!c){d=document.createElement("video"),d.autoplay=!0,d.muted=!0,d.loop=!0,d.playsInline=!0,d.preload="metadata";let l=document.createElement("source");l.src=e.mascot?.mp4Url||dd,l.type="video/mp4";let f=document.createElement("source");f.src=e.mascot?.webmUrl||fd,f.type="video/webm",d.appendChild(l),d.appendChild(f),i.appendChild(d)}let _=document.createElement("span");_.className="launcherFallback",_.textContent="RVR";let h=document.createElement("div");h.className="launcherShine",i.appendChild(_),i.appendChild(h);let v=document.createElement("div");v.className="panel";let I=document.createElement("div");I.className="header";let x=document.createElement("div");x.className="avatar";let M=null;!c&&d&&(M=d.cloneNode(!0),x.appendChild(M));let D=document.createElement("span");D.className="avatarFallback",D.textContent="R",x.appendChild(D);let P=document.createElement("div");P.className="meta";let q=document.createElement("div");q.className="title",q.textContent="Rover";let F=document.createElement("div");F.className="status";let H=document.createElement("span");H.className="statusDot";let U=document.createElement("span");U.textContent="ready",F.appendChild(H),F.appendChild(U),P.appendChild(q),P.appendChild(F);let z=document.createElement("div");z.className="headerActions";let Z=document.createElement("span");Z.className="modeBadge controller",Z.textContent="active";let ne=document.createElement("button");ne.type="button",ne.className="overflowBtn",ne.setAttribute("aria-label","More options"),ne.innerHTML="⋯";let se=document.createElement("button");se.type="button",se.className="closeBtn",se.setAttribute("aria-label","Close Rover panel"),se.textContent="\xD7";let Q=document.createElement("button");Q.type="button",Q.className="muteBtn",Q.setAttribute("aria-label","Toggle sound");let ie=e.muted??!1;try{let l=localStorage.getItem("rover:muted");l!==null&&(ie=l!=="false")}catch{}let ce='<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><line x1="23" y1="9" x2="17" y2="15"/><line x1="17" y1="9" x2="23" y2="15"/></svg>',ge='<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14"/><path d="M15.54 8.46a5 5 0 0 1 0 7.07"/></svg>';function ve(){Q.innerHTML=ie?ce:ge,Q.setAttribute("aria-label",ie?"Unmute":"Mute"),d&&(d.muted=ie),M&&(M.muted=ie)}ve(),Q.addEventListener("click",l=>{l.stopPropagation(),ie=!ie;try{localStorage.setItem("rover:muted",String(ie))}catch{}ve()});let Be=document.createElement("button");Be.type="button",Be.className="stopBtn",Be.setAttribute("aria-label","Cancel task"),Be.textContent="\u25A0",z.appendChild(Be),z.appendChild(Z),z.appendChild(Q),z.appendChild(ne),z.appendChild(se);let le=document.createElement("div");le.className="overflowMenu";let ke=document.createElement("button");ke.type="button",ke.className="menuItem",ke.textContent="New task";let We=document.createElement("button");We.type="button",We.className="menuItem danger",We.textContent="End task";let at=document.createElement("div");at.className="menuDivider";let Ze=document.createElement("button");Ze.type="button",Ze.className="menuItem",Ze.textContent="Show details";let qe=document.createElement("button");qe.type="button",qe.className="menuItem",qe.textContent="Take control",qe.style.display="none",le.appendChild(ke),le.appendChild(We),le.appendChild(at),le.appendChild(Ze),le.appendChild(qe),e.showTaskControls===!1&&(ke.style.display="none",We.style.display="none"),I.appendChild(x),I.appendChild(P),I.appendChild(z),I.appendChild(le);let ct=document.createElement("div");ct.style.cssText="position:relative;flex:1;min-height:0;display:flex;flex-direction:column;";let De=document.createElement("div");De.className="feed";let pt=document.createElement("div");pt.className="typingIndicator";for(let l=0;l<3;l++){let f=document.createElement("span");f.className="typingDot",pt.appendChild(f)}De.appendChild(pt);let ye=document.createElement("button");ye.type="button",ye.className="scrollBtn",ye.setAttribute("aria-label","Scroll to bottom"),ye.innerHTML='<svg viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"></polyline></svg>',ct.appendChild(De),ct.appendChild(ye);let ht=document.createElement("div");ht.className="taskSuggestion",ht.innerHTML=`
|
|
1026
1047
|
<div class="taskSuggestionText"></div>
|
|
1027
1048
|
<div class="taskSuggestionActions">
|
|
1028
1049
|
<button type="button" class="taskSuggestionBtn primary">Start new</button>
|
|
1029
1050
|
<button type="button" class="taskSuggestionBtn secondary">Continue</button>
|
|
1030
1051
|
</div>
|
|
1031
|
-
`;let Et=document.createElement("form");Et.className="composer";let hn=document.createElement("textarea");hn.rows=1,hn.placeholder="Ask Rover to act on this website...",Et.appendChild(hn);let mn=document.createElement("button");mn.type="submit",mn.className="sendBtn",mn.innerHTML='<svg viewBox="0 0 24 24"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>',Et.appendChild(mn);let Mt=document.createElement("div");Mt.className="resizeHandle",Mt.setAttribute("aria-hidden","true"),w.appendChild(I),w.appendChild(pt),w.appendChild(Te),w.appendChild(Et),w.appendChild(Mt),s.appendChild(i),s.appendChild(w),n.appendChild(o),n.appendChild(s);let Oe=hn,ir=Te.querySelector(".taskSuggestionText"),ct=Te.querySelector(".taskSuggestionBtn.primary"),Bt=Te.querySelector(".taskSuggestionBtn.secondary"),zt=new Set,Lt=new Map,jt=[],Fe="controller",gn=!1,Nt=!1,ht=null,Dt=!1,on=!1,bn=0;function Pn(){Dt=!Dt,Me.classList.toggle("visible",Dt)}function kt(){Dt=!1,Me.classList.remove("visible")}function Qe(u,h=0){s.dataset.mood=u,ht!=null&&(window.clearTimeout(ht),ht=null),u==="typing"||u==="running"?(bt.classList.add("visible"),ke.appendChild(bt),de()):bt.classList.remove("visible"),h>0&&u!=="idle"&&(ht=window.setTimeout(()=>{s.dataset.mood="idle",bt.classList.remove("visible"),ht=null},h))}function En(){return ke.scrollHeight-ke.scrollTop-ke.clientHeight<60}function de(){on?Ke.classList.add("visible"):(requestAnimationFrame(()=>{ke.scrollTo({top:ke.scrollHeight,behavior:"smooth"}),bn=Date.now()}),Ke.classList.remove("visible"))}ke.addEventListener("scroll",()=>{Date.now()-bn<200||(En()?(on=!1,Ke.classList.remove("visible")):(on=!0,Ke.classList.add("visible")))},{passive:!0}),Ke.addEventListener("click",()=>{on=!1,bn=Date.now(),ke.scrollTo({top:ke.scrollHeight,behavior:"smooth"}),Ke.classList.remove("visible")});function wn(){Oe.disabled=Fe==="observer"&&!gn}function It(u){Nt=u,s.dataset.showDetails=u?"true":"false",Ge.textContent=Nt?"Hide details":"Show details";for(let h of jt){let m=h.dataset.status,p=m==="success"||m==="error"||m==="info";h.classList.toggle("compact",!Nt&&p)}}function qe(){s.style.display="",w.classList.remove("closing"),w.classList.add("open"),Qe("idle"),e.onOpen?.(),Oe.disabled||Oe.focus()}function St(){if(kt(),!w.classList.contains("open")){e.onClose?.();return}w.classList.remove("open"),w.classList.add("closing"),Qe("idle");let u=()=>{w.classList.remove("closing"),w.removeEventListener("animationend",u)};w.addEventListener("animationend",u),e.onClose?.()}function Ur(){s.style.display=""}function ar(){St(),s.style.display="none"}function Pe(u,h){let m=nr(h);if(!m)return;let p=document.createElement("div");p.className=`entry message ${u}`;let d=document.createElement("div");d.className="bubble",u==="assistant"?m.length>280?d.appendChild(ec(m,280)):d.appendChild(Sr(m)):d.textContent=m;let g=document.createElement("div");g.className="stamp",g.textContent=Za(Date.now()),p.appendChild(d),p.appendChild(g),ke.appendChild(p),u==="user"?Qe("typing",1200):u==="assistant"?Qe("success",1400):Qe("running",900),de()}function cr(){for(let u of Array.from(ke.querySelectorAll(".entry.message")))u.remove()}function lr(u){let h=Lt.get(u);if(h)return h;let m=document.createElement("div");m.className="entry trace pending";let p=document.createElement("div");p.className="traceTop";let d=document.createElement("div");d.className="traceMeta";let g=document.createElement("span");g.className="traceStage",g.textContent="step";let _=document.createElement("div");_.className="traceTitle";let C=document.createElement("div");C.className="traceTs",d.appendChild(g),d.appendChild(_),p.appendChild(d),p.appendChild(C);let S=document.createElement("div");return S.className="traceDetail",m.appendChild(p),m.appendChild(S),Lt.set(u,m),jt.push(m),ke.appendChild(m),m}function Pr(u,h){let m=Number(h.ts)||Date.now(),p=pd(h),d=u.querySelector(".traceTop"),_=d.querySelector(".traceMeta").querySelector(".traceStage"),C=d.querySelector(".traceTitle"),S=d.querySelector(".traceTs"),M=u.querySelector(".traceDetail"),O=nc(h.title||"");C.textContent=O.plainTitle||"Step",_.textContent=O.stage||h.kind||"step",_.style.display=O.stage||h.kind==="status"||h.kind==="plan"||h.kind==="thought"?"":"none",S.textContent=Za(m),M.innerHTML="";let B=nr(h.detail||"");if(B){let Q=h.kind==="thought"?150:h.kind==="tool_start"||h.kind==="tool_result"?100:280;B.length>Q?M.appendChild(ec(B,Q)):M.appendChild(Sr(B)),M.style.display=""}else M.style.display="none";u.classList.remove("pending","success","error","info"),u.classList.add(p),u.dataset.status=p,u.dataset.kind=h.kind,u.dataset.visibility=md(h);let z=p==="success"||p==="error"||p==="info";u.classList.toggle("compact",!Nt&&z),p==="error"?Qe("error",2200):p==="success"?Qe("success",1200):p==="pending"&&Qe("running",800)}function Bn(u){let h=nr(u.title||"");if(!h||h.toLowerCase()==="assistant update")return;let m=u.id||tc("timeline");if(u.id&&zt.has(m))return;zt.add(m);let p=hd(u),d=p==="run"||p.startsWith("tool:")||u.kind==="tool_result"||u.kind==="status"&&Lt.has(p),g=lr(d?p:`${p}:${m}`);Pr(g,{...u,title:h}),h.toLowerCase()==="run completed"&&It(!1),de()}function Wn(){zt.clear(),Lt.clear(),jt.length=0;for(let u of Array.from(ke.querySelectorAll(".entry.trace")))u.remove()}function wt(u){let h=!!u?.visible;Te.classList.toggle("visible",h),ir.textContent=u?.text||"Looks like a new request. Start a new task?",ct.textContent=u?.primaryLabel||"Start new",Bt.textContent=u?.secondaryLabel||"Continue"}function Kt(u){let h=String(u||"ready");U.textContent=h;let m=h.toLowerCase();m.includes("error")||m.includes("failed")?Qe("error",1800):m==="ready"||m.includes("complete")?Qe("idle"):Qe("running",1e3)}function Wt(u,h){Fe=u,gn=u==="observer"?h?.canComposeInObserver===!0:!0,wn(),Z.classList.remove("controller","observer"),Z.classList.add(u),u==="controller"?(Z.textContent="active",Ue.style.display="none",Oe.placeholder="Ask Rover to act on this website..."):(Z.textContent="observer",h?.canTakeControl!==!1?Ue.style.display="":Ue.style.display="none",h?.note?Oe.placeholder=h.note:gn?Oe.placeholder="Send to take control and run here.":h?.activeLogicalTabId&&h?.localLogicalTabId&&h.activeLogicalTabId!==h.localLogicalTabId?Oe.placeholder=`Observing: Rover is acting in tab #${h.activeLogicalTabId}`:Oe.placeholder="Observer mode. Take control to run actions here.")}function ur(){ht!=null&&(window.clearTimeout(ht),ht=null),document.removeEventListener("keydown",Ot),r.remove(),t.remove()}i.addEventListener("click",()=>{w.classList.contains("open")?St():qe()}),oe.addEventListener("click",()=>St()),te.addEventListener("click",u=>{u.stopPropagation(),Pn()}),s.addEventListener("click",u=>{Dt&&!Me.contains(u.target)&&u.target!==te&&kt()}),pe.addEventListener("click",()=>{kt(),e.onNewTask?.()}),Ie.addEventListener("click",()=>{kt(),e.onEndTask?.()}),Ge.addEventListener("click",()=>{kt(),It(!Nt)}),Ue.addEventListener("click",()=>{kt(),e.onRequestControl?.()}),ct.addEventListener("click",()=>{e.onTaskSuggestionPrimary?.()}),Bt.addEventListener("click",()=>{e.onTaskSuggestionSecondary?.()}),Oe.addEventListener("input",()=>{Oe.style.height="auto",Oe.style.height=`${Math.min(96,Math.max(44,Oe.scrollHeight))}px`}),Oe.addEventListener("keydown",u=>{u.key==="Enter"&&!u.shiftKey&&!u.isComposing&&(u.preventDefault(),Et.requestSubmit())}),Et.addEventListener("submit",u=>{if(u.preventDefault(),Oe.disabled)return;let h=nr(Oe.value);h&&(wt({visible:!1}),e.onSend(h),Oe.value="",Oe.style.height="44px")}),n.addEventListener("keydown",u=>{let h=u;h.key==="Escape"&&w.classList.contains("open")&&(h.stopPropagation(),St())});let Ot=u=>{u.code==="Period"&&u.shiftKey&&(u.metaKey||u.ctrlKey)&&(u.preventDefault(),u.stopPropagation(),w.classList.contains("open")?St():qe())};document.addEventListener("keydown",Ot);let yt=null,sn=u=>{if(!yt)return;let h=yt.startX-u.clientX,m=u.clientY-yt.startY,p=Math.max(320,Math.min(window.innerWidth-16,yt.startW+h)),d=Math.max(460,Math.min(window.innerHeight-16,yt.startH+m));w.style.width=`${p}px`,w.style.height=`${d}px`},a=()=>{yt=null,window.removeEventListener("pointermove",sn),window.removeEventListener("pointerup",a)};if(Mt.addEventListener("pointerdown",u=>{window.matchMedia("(max-width: 640px)").matches||(u.preventDefault(),yt={startX:u.clientX,startY:u.clientY,startW:w.getBoundingClientRect().width,startH:w.getBoundingClientRect().height},window.addEventListener("pointermove",sn),window.addEventListener("pointerup",a))}),f){let u=()=>{f.style.display="none",v.style.display="grid"};f.addEventListener("error",u,{once:!0}),v.style.display="none"}if(A){let u=()=>{A.style.display="none",D.style.display="grid"};A.addEventListener("error",u,{once:!0}),D.style.display="none"}return Wt("controller"),It(!1),{addMessage:Pe,clearMessages:cr,addTimelineEvent:Bn,clearTimeline:Wn,setTaskSuggestion:wt,setStatus:Kt,setExecutionMode:Wt,open:qe,close:St,show:Ur,hide:ar,destroy:ur}}var gd="rover:shared:",bd="rover:channel:";function J(){return Date.now()}function qt(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Os(e){let t=String(e||"").trim();if(!t)return"";try{return new URL(t,window.location.href).toString()}catch{return t}}function sc(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)||J(),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 Ed(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 oc(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e.slice(-t)){let o=Ed(r);o!==void 0&&n.push(o)}return n}function ic(e){if(!e||typeof e!="object")return;let t=s=>s.slice(-80).map(i=>({role:typeof i?.role=="string"?i.role:"assistant",content:typeof i?.content=="string"?i.content:""})).filter(i=>!!i.content),n=Array.isArray(e.history)?t(e.history):[],r=oc(e.plannerHistory,40),o=oc(e.agentPrevSteps,80);return{trajectoryId:typeof e.trajectoryId=="string"?e.trajectoryId:void 0,history:n,plannerHistory:r,agentPrevSteps:o,updatedAt:Number(e.updatedAt)||J()}}function Fs(e,t){return{version:2,siteId:e,sessionId:t,seq:1,updatedAt:J(),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,workflowLock:void 0}}function rr(e,t,n){let r=Fs(t,n);if(!e||typeof e!="object")return r;let o={...r,version:2,siteId:t,sessionId:n,seq:Math.max(1,Number(e.seq)||1),updatedAt:Number(e.updatedAt)||J(),tabs:Array.isArray(e.tabs)?e.tabs.map(c=>({logicalTabId:Math.max(1,Number(c?.logicalTabId)||0),runtimeId:typeof c?.runtimeId=="string"?c.runtimeId:void 0,url:String(c?.url||""),title:typeof c?.title=="string"?c.title:void 0,openedAt:Number(c?.openedAt)||J(),updatedAt:Number(c?.updatedAt)||J(),external:!!c?.external,openerRuntimeId:typeof c?.openerRuntimeId=="string"?c.openerRuntimeId:void 0})).filter(c=>!!c.logicalTabId):[],nextLogicalTabId:Math.max(1,Number(e.nextLogicalTabId)||1),activeLogicalTabId:Number(e.activeLogicalTabId)||void 0,uiMessages:Array.isArray(e.uiMessages)?e.uiMessages.map(c=>({id:String(c?.id||qt("msg")),role:c?.role==="user"||c?.role==="assistant"||c?.role==="system"?c.role:"system",text:String(c?.text||""),ts:Number(c?.ts)||J(),sourceRuntimeId:typeof c?.sourceRuntimeId=="string"?c.sourceRuntimeId:void 0})).filter(c=>!!c.text):[],timeline:Array.isArray(e.timeline)?e.timeline.map(c=>({id:String(c?.id||qt("timeline")),kind:String(c?.kind||"status"),title:String(c?.title||"Step"),detail:typeof c?.detail=="string"?c.detail:void 0,status:c?.status==="pending"||c?.status==="success"||c?.status==="error"||c?.status==="info"?c.status:void 0,ts:Number(c?.ts)||J(),sourceRuntimeId:typeof c?.sourceRuntimeId=="string"?c.sourceRuntimeId:void 0})).filter(c=>!!c.title):[],taskEpoch:Math.max(1,Number(e.taskEpoch)||1),task:sc(e.task),workerContext:ic(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)||J(),updatedAt:Number(e.activeRun.updatedAt)||J()}: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)||J()}:void 0,workflowLock:e.workflowLock&&typeof e.workflowLock=="object"&&e.workflowLock.runtimeId&&e.workflowLock.runId?{runtimeId:String(e.workflowLock.runtimeId),runId:String(e.workflowLock.runId),lockedAt:Number(e.workflowLock.lockedAt)||J(),expiresAt:Number(e.workflowLock.expiresAt)||0}:void 0},s=o.tabs.length,i=new Set;return o.tabs=o.tabs.filter(c=>i.has(c.logicalTabId)?!1:(i.add(c.logicalTabId),!0)),o.nextLogicalTabId<=(o.tabs.at(-1)?.logicalTabId??0)&&(o.nextLogicalTabId=o.tabs.reduce((c,f)=>Math.max(c,f.logicalTabId),0)+1),s>0&&o.tabs.length<s&&console.warn(`[rover] sanitizeSharedState: dropped ${s-o.tabs.length} invalid/duplicate tab entries`),o}var Lo=class Lo{constructor(t){$(this,"siteId");$(this,"sessionId");$(this,"runtimeId");$(this,"leaseMs");$(this,"heartbeatMs");$(this,"maxMessages");$(this,"maxTimeline");$(this,"onRoleChange");$(this,"onStateChange");$(this,"onSwitchRequested");$(this,"key");$(this,"channelName");$(this,"state");$(this,"channel",null);$(this,"heartbeatTimer",null);$(this,"storageHandler",null);$(this,"localLogicalTabId");$(this,"closing",!1);$(this,"started",!1);$(this,"pendingRpcRequests",new Map);$(this,"rpcRequestHandler");$(this,"lastNotifiedRole");$(this,"roleChangeTimer",null);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=`${gd}${this.siteId}:${this.sessionId}`,this.channelName=`${bd}${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:qt("task"),status:"running",startedAt:J(),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 r=rr(n.state,this.siteId,this.sessionId);this.applyIncomingState(r)}n.type==="switch_request"&&n.targetRuntimeId===this.runtimeId&&this.onSwitchRequested?.(Number(n.logicalTabId)||0),n.type==="rpc_request"&&n.targetRuntimeId===this.runtimeId&&this.handleInboundRpcRequest(n),n.type==="rpc_response"&&n.targetRuntimeId===this.runtimeId&&this.handleInboundRpcResponse(n),n.type==="tab_navigated"&&n.runtimeId&&n.runtimeId!==this.runtimeId&&this.handleRemoteNavigation(n),n.type==="tab_closing"&&n.runtimeId&&n.runtimeId!==this.runtimeId&&this.handleRemoteTabClosing(n)}}),this.storageHandler=t=>{if(!(t.key!==this.key||!t.newValue))try{let n=rr(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(){if(this.started){this.started=!1,this.heartbeatTimer!=null&&(window.clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.roleChangeTimer!=null&&(window.clearTimeout(this.roleChangeTimer),this.roleChangeTimer=null),this.storageHandler&&(window.removeEventListener("storage",this.storageHandler),this.storageHandler=null),this.channel&&(this.channel.close(),this.channel=null);for(let[,t]of this.pendingRpcRequests)window.clearTimeout(t.timer),t.reject(new Error("SessionCoordinator stopped"));this.pendingRpcRequests.clear(),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<=J()?!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",r=>{n&&Number.isFinite(n)&&n>r.taskEpoch&&(r.taskEpoch=Math.max(1,Math.trunc(n))),t&&(r.task=sc(t)||r.task)})}hydrateExternalState(t){let n=rr(t,this.siteId,this.sessionId),r=this.state.seq,o=this.state.updatedAt;return this.applyIncomingState(n),this.state.seq!==r||this.state.updatedAt!==o?(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)||J(),r={taskId:String(t.taskId||qt("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",o=>{o.taskEpoch=Math.max(1,Number(o.taskEpoch)||1)+1,o.task=r,o.uiMessages=[],o.timeline=[],o.uiStatus=void 0,o.activeRun=void 0,o.workerContext=void 0}),r}endTask(t){let n;return this.mutate("local",r=>{r.task&&(r.task={...r.task,status:"ended",boundaryReason:t||r.task.boundaryReason,endedAt:J()},r.activeRun=void 0,n=r.task)}),n}markTaskActivity(t,n=J()){t!=="system"&&this.mutate("local",r=>{if(!r.task){r.task={taskId:qt("task"),status:"running",startedAt:n,boundaryReason:"implicit",lastUserAt:t==="user"?n:void 0,lastAssistantAt:t==="assistant"?n:void 0};return}t==="user"&&(r.task.lastUserAt=n),t==="assistant"&&(r.task.lastAssistantAt=n),r.task.status==="ended"&&(r.task.status="running",r.task.endedAt=void 0)})}setWorkerContext(t){this.mutate("local",n=>{if(!t){n.workerContext=void 0;return}n.workerContext=ic(t)})}setStatus(t){this.mutate("local",n=>{n.uiStatus=t||void 0})}appendMessage(t){let n={id:t.id||qt("msg"),role:t.role,text:String(t.text||""),ts:Number(t.ts)||J(),sourceRuntimeId:this.runtimeId};return this.mutate("local",r=>{r.uiMessages.push(n),r.uiMessages.length>this.maxMessages&&(r.uiMessages=r.uiMessages.slice(-this.maxMessages)),r.task||(r.task={taskId:qt("task"),status:"running",startedAt:n.ts,boundaryReason:"implicit"}),n.role==="user"?r.task.lastUserAt=n.ts:n.role==="assistant"&&(r.task.lastAssistantAt=n.ts)}),n}appendTimeline(t){let n={id:t.id||qt("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)||J(),sourceRuntimeId:this.runtimeId};return this.mutate("local",r=>{r.timeline.push(n),r.timeline.length>this.maxTimeline&&(r.timeline=r.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:J(),updatedAt:J()},n.task?n.task.status!=="ended"&&(n.task.status="running"):n.task={taskId:qt("task"),status:"running",startedAt:J()}})}requestControl(){return this.claimLease(!0)}registerCurrentTab(t,n){let r=Os(t),o;return this.mutate("local",s=>{let i=s.tabs.find(c=>c.runtimeId===this.runtimeId);if(i)i.url=r||i.url,i.title=n||i.title,i.updatedAt=J(),o=i.logicalTabId;else{let c=s.tabs.find(f=>!f.runtimeId&&f.url===r&&J()-f.openedAt<18e4);if(c)c.runtimeId=this.runtimeId,c.title=n||c.title,c.updatedAt=J(),o=c.logicalTabId;else{let f=s.nextLogicalTabId++;s.tabs.push({logicalTabId:f,runtimeId:this.runtimeId,url:r,title:n,openedAt:J(),updatedAt:J(),external:!1}),o=f}}s.activeLogicalTabId||(s.activeLogicalTabId=o)}),this.notifyRoleChange(),this.localLogicalTabId||o||1}registerOpenedTab(t){let n=Os(t.url),r=0;return this.mutate("local",o=>{r=o.nextLogicalTabId++,o.tabs.push({logicalTabId:r,runtimeId:void 0,url:n,title:t.title,openedAt:J(),updatedAt:J(),external:!!t.external,openerRuntimeId:t.openerRuntimeId})}),{logicalTabId:r}}switchToLogicalTab(t){let n={ok:!1,reason:"Unknown tab"};return this.mutate("local",r=>{let o=r.tabs.find(s=>s.logicalTabId===t);if(!o){n={ok:!1,reason:`Tab ${t} not found`};return}if(r.activeLogicalTabId=t,o.runtimeId&&o.runtimeId!==this.runtimeId){r.lease={holderRuntimeId:o.runtimeId,expiresAt:J()+this.leaseMs,updatedAt:J()},this.channel&&this.channel.postMessage({type:"switch_request",logicalTabId:t,targetRuntimeId:o.runtimeId,sourceRuntimeId:this.runtimeId}),n={ok:!0,delegated:!0};return}if(!o.runtimeId){n={ok:!1,reason:`Tab ${t} is not attached to an active Rover runtime yet`};return}r.lease={holderRuntimeId:this.runtimeId,expiresAt:J()+this.leaseMs,updatedAt:J()},n={ok:!0,delegated:!1}}),this.notifyRoleChange(),n}sendCrossTabRpc(t,n,r,o=15e3){return new Promise((s,i)=>{if(!this.channel){i(new Error("BroadcastChannel not available"));return}let c=qt("rpc"),f=window.setTimeout(()=>{this.pendingRpcRequests.delete(c),i(new Error(`Cross-tab RPC timed out after ${o}ms (method=${n}, target=${t})`))},o);this.pendingRpcRequests.set(c,{resolve:s,reject:i,timer:f}),this.channel.postMessage({type:"rpc_request",requestId:c,sourceRuntimeId:this.runtimeId,targetRuntimeId:t,method:n,params:r,timeoutMs:o,createdAt:J()})})}setRpcRequestHandler(t){this.rpcRequestHandler=t}broadcastNavigation(t,n){this.channel&&this.channel.postMessage({type:"tab_navigated",runtimeId:this.runtimeId,logicalTabId:this.localLogicalTabId,url:t,title:n})}broadcastClosing(){this.closing=!0,this.channel&&(this.mutate("local",t=>{t.tabs=t.tabs.filter(n=>n.runtimeId!==this.runtimeId),t.activeLogicalTabId&&!t.tabs.some(n=>n.logicalTabId===t.activeLogicalTabId)&&(t.activeLogicalTabId=void 0)}),this.channel.postMessage({type:"tab_closing",runtimeId:this.runtimeId,logicalTabId:this.localLogicalTabId}))}isTabAlive(t){let n=this.state.tabs.find(r=>r.logicalTabId===t);return n?n.updatedAt>J()-2*this.heartbeatMs:!1}acquireWorkflowLock(t){let n=!1;return this.mutate("local",r=>{let o=r.workflowLock;if(o&&o.runtimeId!==this.runtimeId&&o.expiresAt>J()){let s=r.tabs.find(c=>c.runtimeId===o.runtimeId);if(s&&s.updatedAt>J()-2*this.heartbeatMs){n=!1;return}}r.workflowLock={runtimeId:this.runtimeId,runId:t,lockedAt:J(),expiresAt:J()+this.leaseMs*5},n=!0}),n}clearActiveRunRuntimeId(t){this.mutate("local",n=>{n.activeRun&&n.activeRun.runId===t&&(n.activeRun.runtimeId="")})}releaseWorkflowLock(t){this.mutate("local",n=>{n.workflowLock&&n.workflowLock.runId===t&&(n.workflowLock=void 0)})}isWorkflowLocked(){let t=this.state.workflowLock;return!t||t.runtimeId===this.runtimeId?!1:t.expiresAt>J()}getWorkflowLockInfo(){let t=this.state.workflowLock;return!t||t.expiresAt<=J()?{locked:!1}:{locked:!0,holderRuntimeId:t.runtimeId,runId:t.runId}}async handleInboundRpcRequest(t){let{requestId:n,sourceRuntimeId:r,method:o,params:s}=t;if(!this.rpcRequestHandler){this.channel?.postMessage({type:"rpc_response",requestId:n,sourceRuntimeId:this.runtimeId,targetRuntimeId:r,ok:!1,error:{message:"No RPC handler registered",code:"NO_HANDLER"}});return}try{let i=await this.rpcRequestHandler({method:o,params:s});this.channel?.postMessage({type:"rpc_response",requestId:n,sourceRuntimeId:this.runtimeId,targetRuntimeId:r,ok:!0,result:i})}catch(i){this.channel?.postMessage({type:"rpc_response",requestId:n,sourceRuntimeId:this.runtimeId,targetRuntimeId:r,ok:!1,error:{message:i?.message||String(i)}})}}handleInboundRpcResponse(t){let{requestId:n,ok:r,result:o,error:s}=t,i=this.pendingRpcRequests.get(n);i&&(this.pendingRpcRequests.delete(n),window.clearTimeout(i.timer),r?i.resolve(o):i.reject(new Error(s?.message||"Cross-tab RPC failed")))}handleRemoteNavigation(t){let{runtimeId:n,url:r,title:o}=t;this.mutate("local",s=>{let i=s.tabs.find(c=>c.runtimeId===n);i&&(i.url=r||i.url,i.title=o||i.title,i.updatedAt=J())})}handleRemoteTabClosing(t){let{runtimeId:n}=t;this.mutate("local",r=>{r.tabs=r.tabs.filter(o=>o.runtimeId!==n),r.lease?.holderRuntimeId===n&&(r.lease=void 0),r.workflowLock?.runtimeId===n&&(r.workflowLock=void 0),r.activeRun?.runtimeId===n&&(r.activeRun=void 0),r.activeLogicalTabId&&!r.tabs.some(o=>o.logicalTabId===r.activeLogicalTabId)&&(r.activeLogicalTabId=void 0)}),this.notifyRoleChange()}heartbeat(){if(this.closing)return;let t=Os(window.location.href),n=document.title||void 0;this.mutate("local",r=>{let o=r.tabs.find(c=>c.runtimeId===this.runtimeId);if(o)o.url=t||o.url,o.title=n||o.title,o.updatedAt=J();else{let c=r.nextLogicalTabId++;r.tabs.push({logicalTabId:c,runtimeId:this.runtimeId,url:t,title:n,openedAt:J(),updatedAt:J(),external:!1})}let s=r.lease;(!s||s.expiresAt<=J()||s?.holderRuntimeId===this.runtimeId)&&(r.lease={holderRuntimeId:this.runtimeId,expiresAt:J()+this.leaseMs,updatedAt:J()},!r.activeLogicalTabId&&this.localLogicalTabId&&(r.activeLogicalTabId=this.localLogicalTabId)),r.workflowLock?.runtimeId===this.runtimeId&&(r.workflowLock.expiresAt=J()+this.leaseMs*5)}),this.notifyRoleChange()}reloadFromStorage(){let t=this.loadState();return(t.seq>this.state.seq||t.seq===this.state.seq&&t.updatedAt>this.state.updatedAt)&&(this.state=t,this.syncLocalLogicalTabId(),this.onStateChange?.(this.state,"remote")),this.closing=!1,this.state}claimLease(t){let n=!1;return this.mutate("local",r=>{let o=r.lease,s=!o||o.expiresAt<=J();(t||s||o?.holderRuntimeId===this.runtimeId)&&(r.lease={holderRuntimeId:this.runtimeId,expiresAt:J()+this.leaseMs,updatedAt:J()},!r.activeLogicalTabId&&this.localLogicalTabId&&(r.activeLogicalTabId=this.localLogicalTabId),n=!0)}),this.notifyRoleChange(),n}notifyRoleChange(){this.getRole()!==this.lastNotifiedRole&&(this.roleChangeTimer!=null&&window.clearTimeout(this.roleChangeTimer),this.roleChangeTimer=window.setTimeout(()=>{this.roleChangeTimer=null;let n=this.getRole();n!==this.lastNotifiedRole&&(this.lastNotifiedRole=n,this.onRoleChange?.(n,{localLogicalTabId:this.localLogicalTabId,activeLogicalTabId:this.state.activeLogicalTabId,holderRuntimeId:this.state.lease?.holderRuntimeId}))},Lo.ROLE_CHANGE_DEBOUNCE_MS))}syncLocalLogicalTabId(){let t=this.state.tabs.find(n=>n.runtimeId===this.runtimeId);this.localLogicalTabId=t?.logicalTabId}mutate(t,n){if(t==="local")try{let o=window.localStorage.getItem(this.key);if(o){let s=rr(JSON.parse(o),this.siteId,this.sessionId);(s.seq>this.state.seq||s.seq===this.state.seq&&s.updatedAt>this.state.updatedAt)&&(this.state=s)}}catch{}let r=rr(this.state,this.siteId,this.sessionId);n(r),r.seq=Math.max(1,Number(r.seq)||1)+(t==="local"?1:0),r.updatedAt=J(),this.state=r,this.syncLocalLogicalTabId(),t==="local"&&(this.persistState(),this.channel&&this.channel.postMessage({type:"state",sourceRuntimeId:this.runtimeId,state:this.state})),this.onStateChange?.(this.state,t)}applyIncomingState(t){t&&(t.seq<this.state.seq||t.seq===this.state.seq&&t.updatedAt<=this.state.updatedAt||(this.state=t,this.syncLocalLogicalTabId(),this.onStateChange?.(this.state,"remote"),this.notifyRoleChange()))}loadState(){try{let t=window.localStorage.getItem(this.key);if(!t)return Fs(this.siteId,this.sessionId);let n=JSON.parse(t);return rr(n,this.siteId,this.sessionId)}catch(t){return console.warn("[rover] Failed to load shared state from localStorage:",t),Fs(this.siteId,this.sessionId)}}persistState(){try{window.localStorage.setItem(this.key,JSON.stringify(this.state))}catch{}}};$(Lo,"ROLE_CHANGE_DEBOUNCE_MS",200);var Mo=Lo;var wd="https://us-central1-rtrvr-extension-functions.cloudfunctions.net";function or(e,t){let n=Number(e);return Number.isFinite(n)?n:t}function yd(e,t=8e3){let n=String(e??"");return n.length<=t?n:`${n.slice(0,t)}\u2026`}function vd(e){let t=Number(e.sharedState?.seq||0),n=Array.isArray(e.sharedState?.uiMessages)?e.sharedState.uiMessages.length:0,r=Number(e.runtimeState?.updatedAt||0),o=Array.isArray(e.runtimeState?.uiMessages)?e.runtimeState.uiMessages.length:0;return[e.sessionId,or(e.updatedAt,0),t,n,r,o].join(":")}function _d(e){let t=(e||wd).replace(/\/$/,"");return t.endsWith("/extensionRouter")?t:`${t}/extensionRouter`}function Hs(e,t){let n=new Error(e);return n.details=t,n}var No=class{constructor(t){$(this,"endpoint");$(this,"token");$(this,"siteId");$(this,"visitorId");$(this,"ttlHours");$(this,"flushIntervalMs");$(this,"pullIntervalMs");$(this,"minFlushIntervalMs");$(this,"shouldWrite");$(this,"buildCheckpoint");$(this,"onCheckpoint");$(this,"onError");$(this,"started",!1);$(this,"dirty",!1);$(this,"flushTimer",null);$(this,"pullTimer",null);$(this,"lastFlushAt",0);$(this,"lastPullAt",0);$(this,"lastUploadedRevision","");$(this,"lastAppliedRemoteUpdatedAt",0);$(this,"pushInFlight",!1);$(this,"pullInFlight",!1);let n=String(t.apiKey||t.authToken||"").trim();if(!n)throw Hs("Rover cloud checkpoint requires apiKey or authToken.");this.endpoint=_d(t.apiBase),this.token=n,this.siteId=t.siteId,this.visitorId=t.visitorId,this.ttlHours=Math.max(1,Math.min(168,Math.floor(or(t.ttlHours,1)))),this.flushIntervalMs=Math.max(2e3,Math.floor(or(t.flushIntervalMs,8e3))),this.pullIntervalMs=Math.max(2e3,Math.floor(or(t.pullIntervalMs,9e3))),this.minFlushIntervalMs=Math.max(1e3,Math.floor(or(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 r=vd(n);if(!t&&r===this.lastUploadedRevision){this.dirty=!1;return}this.pushInFlight=!0;try{let o=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(),o?.saved&&(this.dirty=!1,this.lastUploadedRevision=r),o?.stale&&o?.checkpoint&&typeof o.checkpoint=="object"&&(this.applyRemoteCheckpoint(o.checkpoint,"push_stale"),this.dirty=!1)}catch(o){this.onError?.(o)}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 r=Math.max(0,Math.floor(or(t?.updatedAt,0)));r<=this.lastAppliedRemoteUpdatedAt||(this.lastAppliedRemoteUpdatedAt=r,this.onCheckpoint(t,n))}async callExtensionRouter(t,n){let r=await fetch(this.endpoint,{method:"POST",headers:{Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"},body:JSON.stringify({action:t,data:n})});if(!r.ok){let s;try{s=await r.json()}catch{let i=await r.text().catch(()=>"");s=i?{error:yd(i,2e3)}:void 0}throw Hs(`Checkpoint HTTP ${r.status}`,s)}let o=await r.json();if(o?.success===!1)throw Hs("Checkpoint extensionRouter returned success=false",o);return o?.data}};var Td="rover-runtime-state-db",Do="runtime-state",Us=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{}}},Ps=class{constructor(){$(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 r=indexedDB.open(Td,1);r.onupgradeneeded=()=>{let o=r.result;o.objectStoreNames.contains(Do)||o.createObjectStore(Do)},r.onsuccess=()=>{t(r.result)},r.onerror=()=>{n(r.error||new Error("indexedDB open failed"))}}).catch(t=>{throw this.dbPromise=null,t}),this.dbPromise)}async withStore(t,n){let r=await this.openDb();return new Promise((o,s)=>{let i=r.transaction(Do,t),c=i.objectStore(Do);n(c,o,s),i.onerror=()=>{s(i.error||new Error("indexedDB transaction failed"))}})}async read(t){try{return await this.withStore("readonly",(n,r,o)=>{let s=n.get(t);s.onsuccess=()=>{let i=s.result;r(i??null)},s.onerror=()=>{o(s.error||new Error("indexedDB read failed"))}})}catch{return null}}async write(t,n){await this.withStore("readwrite",(r,o,s)=>{let i=r.put(n,t);i.onsuccess=()=>o(),i.onerror=()=>{s(i.error||new Error("indexedDB write failed"))}}).catch(()=>{})}async remove(t){await this.withStore("readwrite",(n,r,o)=>{let s=n.delete(t);s.onsuccess=()=>r(),s.onerror=()=>{o(s.error||new Error("indexedDB delete failed"))}}).catch(()=>{})}};function ac(){let e=new Us,t=new Ps;return{readSync:n=>e.read(n),readAsync:async n=>t.read(n),write:(n,r)=>{e.write(n,r),t.write(n,r)},remove:n=>{e.remove(n),t.remove(n)}}}var Vs=1,xd="rover:runtime:",Rd="rover:runtime-id:",dc="rover:visitor-id:",Bs=160,Ws=240,fc=80,Vo=40,kd=8e3,Id=15*6e4,Sd=12,Ad=3600*24*365,Cd=1,$s=5*6e4,Gs=.18,Md=3,un=null,je=null,Ce=null,he=null,_e=null,sr=null,y=null,Dn=null,$e="",W=null,gt=null,dt,$o=!1,ft="controller",pn=!1,On=!1,Nn=null,cc=!1,Fn=null,Oo="",pc,nn=new Map,Ld=new Set(["run_started","run_completed","assistant","status","tool_start","tool_result","auth_required","navigation_guardrail","error"]),Uo=[],Po=new Map;function De(e,t){let n=Po.get(e);if(n)for(let r of n)try{r(t)}catch{}}function hc(e,t){Po.has(e)||Po.set(e,new Set);let n=Po.get(e);return n.add(t),()=>{n.delete(t)}}function Nd(e){return typeof e=="string"?{name:e}:e}function dn(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Dd(e){let t=`${Rd}${e}`;try{let n=window.sessionStorage.getItem(t);if(n&&n.trim())return n.trim();let r=dn("runtime");return window.sessionStorage.setItem(t,r),r}catch{return dn("runtime")}}function Go(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 Fo(e){return String(e||"").trim().replace(/[^a-zA-Z0-9._:-]/g,"").slice(0,180)}function mc(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]||""):void 0}catch{return}}function lc(e,t,n){try{let r=n?`; domain=${n}`:"";return document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${Ad}; samesite=lax${r}`,mc(e)===t}catch{return!1}}function Od(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 r=[];for(let o=n.length-2;o>=0;o-=1)r.push(`.${n.slice(o).join(".")}`);return r}function Fd(e,t){let n=`rover_vid_${Go(e)}`;for(let r of Od(window.location.hostname))if(lc(n,t,r))return;lc(n,t)}function Ho(e,t){let n=`${dc}${e}`;try{window.localStorage.setItem(n,t)}catch{}try{window.sessionStorage.setItem(n,t)}catch{}Fd(e,t)}function gc(e){let t=Fo(e.visitorId||"");if(t)return t;if(e.checkpointing?.autoVisitorId===!1)return;let n=`${dc}${e.siteId}`,r=`rover_vid_${Go(e.siteId)}`,o=Fo(mc(r)||"");if(o)return Ho(e.siteId,o),o;try{let i=Fo(window.localStorage.getItem(n)||"");if(i)return Ho(e.siteId,i),i}catch{}try{let i=Fo(window.sessionStorage.getItem(n)||"");if(i)return Ho(e.siteId,i),i}catch{}let s=`v_${Go(`${e.siteId}:${dn("visitor")}`)}_${Date.now().toString(36)}`;return Ho(e.siteId,s),s}function Hd(e,t){return`visitor-${Go(`${e}:${t}`)}`}function bc(e){!je||!Ce||(je.registerTool(e.def,e.handler),Ce.postMessage({type:"register_tool",tool:e.def}))}function Ud(e){return`${xd}${e}`}function fn(e="session_start"){let t=Date.now();return{taskId:dn("task"),status:"running",startedAt:t,lastUserAt:void 0,lastAssistantAt:void 0,boundaryReason:e,endedAt:void 0}}function Ec(e,t){return{version:Vs,sessionId:e,runtimeId:t,uiOpen:!1,uiHidden:!1,uiStatus:void 0,uiMessages:[],timeline:[],executionMode:"controller",workerState:void 0,pendingRun:void 0,taskEpoch:1,activeTask:fn(),lastRoutingDecision:void 0,updatedAt:Date.now()}}function at(e,t=kd){return e.length<=t?e:`${e.slice(0,t)}\u2026`}function Bo(e){if(e!=null){if(typeof e=="string")return at(e,1200);try{return at(JSON.stringify(e),1200)}catch{try{return at(String(e),1200)}catch{return}}}}function Pd(e){if(e==="analyze"||e==="route"||e==="execute"||e==="verify"||e==="complete")return e}function Bd(e){return e?e==="analyze"?"Analyze":e==="route"?"Route":e==="execute"?"Execute":e==="verify"?"Verify":e==="complete"?"Complete":"Status":"Status"}function Wd(e,t,n){return[String(t||""),String(e||"").trim().toLowerCase(),String(n||"").trim().toLowerCase()].join("|")}function Vd(e,t){if(!e)return!0;let n=e.trim();return!!(t&&n.toLowerCase()===t.trim().toLowerCase()||/^complexity score\b/i.test(n)||/\btool loop$/i.test(n)||/^calling \w[\w\s]*(workflow|sub-agent)$/i.test(n))}function $d(){return y?.pendingRun?.id}function wc(){let e=W?.getState()?.activeRun;return!!(e&&e.runtimeId&&e.runtimeId!==$e)}function yc(){return!wc()}function vc(e){if(e==="observer")return wc()?"Observing active run in another tab...":"Send to take control and run here."}function Gd(e){let t=typeof e?.type=="string"?e.type:"";if(!Ld.has(t))return!1;let n=typeof e?.runId=="string"&&e.runId?e.runId:void 0,r=$d();return t==="run_started"?!n||!r?!1:r!==n:n?r?r!==n:!0:!1}function qd(e){if(e&&nn.has(e))return nn.get(e);if(y?.uiMessages?.length)for(let t=y.uiMessages.length-1;t>=0;t-=1){let n=y.uiMessages[t];if(n.role==="assistant"&&n.text)return n.text}}function Yd(e){return Dn?Dn.readSync(e):null}function Xd(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 _c(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 qo(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e.slice(-t)){let o=Xd(r);o!==void 0&&n.push(o)}return n}async function zd(e){if(!Dn)return null;try{return await Dn.readAsync(e)}catch{return null}}function Ar(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-Bs)){let r=n?.role;r!=="user"&&r!=="assistant"&&r!=="system"||t.push({id:typeof n?.id=="string"&&n.id?n.id:dn("msg"),role:r,text:at(String(n?.text||"")),ts:Number(n?.ts)||Date.now(),sourceRuntimeId:typeof n?.sourceRuntimeId=="string"?n.sourceRuntimeId:void 0})}return t}function Cr(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-Ws)){let r=at(String(n?.title||""),400);if(!r)continue;let o=String(n?.kind||"status"),s=n?.status;t.push({id:typeof n?.id=="string"&&n.id?n.id:dn("timeline"),kind:o,title:r,detail:n?.detail?at(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 Hn(e){if(!e||typeof e!="object")return;let t=Array.isArray(e.history)?e.history:[],n=Array.isArray(e.plannerHistory)?e.plannerHistory:[],r=Array.isArray(e.agentPrevSteps)?e.agentPrevSteps:Array.isArray(e.lastToolPreviousSteps)?e.lastToolPreviousSteps:[],o=t.slice(-fc).map(c=>_c(c)).filter(c=>!!c),s=qo(n,Vo),i=qo(r,Vo*2);return{trajectoryId:typeof e.trajectoryId=="string"?e.trajectoryId:void 0,history:o,plannerHistory:s,agentPrevSteps:i,lastToolPreviousSteps:i,updatedAt:Number(e.updatedAt)||Date.now()}}function Mr(e,t,n){if(!e||typeof e!="object")return Ec(t,n);let r=fn(),o=Or(e.activeTask,r);return{version:Vs,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"?at(e.uiStatus,300):void 0,uiMessages:Ar(e.uiMessages),timeline:Cr(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:Hn(e.workerState),pendingRun:Lr(e.pendingRun),taskEpoch:Math.max(1,Number(e.taskEpoch)||1),activeTask:o,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"?at(e.lastRoutingDecision.reason,200):void 0,ts:Number(e.lastRoutingDecision.ts)||Date.now()}:void 0,updatedAt:Number(e.updatedAt)||Date.now()}}function Or(e,t){if(!e||typeof e!="object")return t;let n=typeof e.taskId=="string"&&e.taskId.trim()?e.taskId.trim():t.taskId,r=e.status==="ended"||e.status==="completed"||e.status==="running"?e.status:"running";return{taskId:n,status:r,startedAt:Number(e.startedAt)||t.startedAt,lastUserAt:Number(e.lastUserAt)||void 0,lastAssistantAt:Number(e.lastAssistantAt)||void 0,boundaryReason:typeof e.boundaryReason=="string"?at(e.boundaryReason,120):t.boundaryReason,endedAt:Number(e.endedAt)||void 0}}function jd(e,t){return Or(e,t)}function Tc(e){if(e)return{trajectoryId:e.trajectoryId,history:Array.isArray(e.history)?e.history.slice(-fc).map(t=>_c(t)).filter(t=>!!t):[],plannerHistory:qo(e.plannerHistory,Vo),agentPrevSteps:qo(e.agentPrevSteps,Vo*2),updatedAt:Number(e.updatedAt)||Date.now()}}function Lr(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 Se(){if(!(!y||!sr))try{y.updatedAt=Date.now(),Dn?.write(sr,y),$o||gt?.markDirty()}catch{}}function Kd(){if(cc)return;cc=!0;let e=()=>{y?.pendingRun?.autoResume&&W?.clearActiveRunRuntimeId(y.pendingRun.id),W?.broadcastClosing(),y?.pendingRun&&W?.releaseWorkflowLock(y.pendingRun.id),Se(),gt?.markDirty(),gt?.syncNow(),gt?.stop(),W?.stop()};window.addEventListener("pagehide",e,{capture:!0});let t=n=>{n.persisted&&(W&&(W.reloadFromStorage(),W.registerCurrentTab(window.location.href,document.title||void 0),W.claimLease(!1)),On=!1)};window.addEventListener("pageshow",t)}function jo(e="implicit"){if(y)return y.activeTask||(y.activeTask=fn(e),y.taskEpoch=Math.max(1,Number(y.taskEpoch)||1)),y.activeTask}function Qd(e,t=Date.now()){if(!y)return;let n=jo("implicit");n&&(e==="user"&&(n.lastUserAt=t),e==="assistant"&&(n.lastAssistantAt=t),n.status==="ended"&&(n.status="running",n.endedAt=void 0))}function Un(){Fn=null,he?.setTaskSuggestion({visible:!1})}function xc(){he?.clearMessages(),he?.clearTimeline(),Un()}function Jd(){return y?y.uiMessages.filter(t=>t.role==="user").slice(-Md).map(t=>t.text.trim()).filter(Boolean):[]}function uc(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 Zd(e,t){let n=uc(e),r=uc(t);if(!n.size||!r.size)return 0;let o=0;for(let s of n)r.has(s)&&(o+=1);return o/Math.max(n.size,r.size)}function ef(e){if(!y||!_e)return{suggest:!1};if(!(_e.taskContext?.suggestReset!==!1))return{suggest:!1};if(y.pendingRun)return{suggest:!1};let n=jo("implicit");if(!n||n.status==="ended")return{suggest:!1};let r=Math.max(6e4,Number(_e.taskContext?.inactivityMs)||$s),o=Date.now(),s=Math.max(n.lastUserAt||0,n.lastAssistantAt||0,n.startedAt||0);if(!s||o-s<r)return{suggest:!1};let i=Jd();if(!i.length)return{suggest:!0,reason:"inactivity_only"};let c=i.join(" "),f=Zd(c,e),v=Math.max(.05,Math.min(.9,Number(_e.taskContext?.semanticSimilarityThreshold)||Gs));return f<v?{suggest:!0,reason:`low_similarity_${f.toFixed(2)}`}:{suggest:!1}}function Xt(e,t,n=!0,r){let o=at(String(t||""));if(!o)return;let s={id:r?.id||dn("msg"),role:e,text:o,ts:r?.ts||Date.now(),sourceRuntimeId:r?.sourceRuntimeId};return he?.addMessage(s.role,s.text),y&&n&&(y.uiMessages.push(s),y.uiMessages.length>Bs&&(y.uiMessages=y.uiMessages.slice(-Bs)),Qd(s.role,s.ts),Se()),W&&r?.publishShared!==!1&&(W.appendMessage({id:s.id,role:s.role,text:s.text,ts:s.ts}),W.markTaskActivity(s.role,s.ts)),s}function qs(e){for(let t of e)Xt(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||dn("timeline"),kind:e.kind,title:at(e.title,400),detail:e.detail?at(e.detail,1200):void 0,status:e.status,ts:e.ts||Date.now(),sourceRuntimeId:e.sourceRuntimeId};return he?.addTimelineEvent(n),y&&t&&(y.timeline.push(n),y.timeline.length>Ws&&(y.timeline=y.timeline.slice(-Ws)),Se()),W&&e.publishShared!==!1&&W.appendTimeline({id:n.id,kind:n.kind,title:n.title,detail:n.detail,status:n.status,ts:n.ts}),n}function Ys(e){he?.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 Yt(e,t){he?.setStatus(e),y&&(y.uiStatus=at(e,300),Se()),W&&t?.publishShared!==!1&&W.setStatus(e)}function Nr(e,t){ft=e,y&&(y.executionMode=e,Se()),he?.setExecutionMode(e,{controllerRuntimeId:t?.holderRuntimeId??W?.getCurrentHolderRuntimeId(),localLogicalTabId:t?.localLogicalTabId??W?.getLocalLogicalTabId(),activeLogicalTabId:t?.activeLogicalTabId??W?.getActiveLogicalTabId(),canTakeControl:!0,canComposeInObserver:yc(),note:vc(e)}),De("mode_change",{mode:e,...t})}function rn(e){if(!y)return;y.pendingRun=e;let t=jo("implicit");t&&(e?(t.status="running",t.endedAt=void 0):t.status==="running"&&(t.status="completed")),Se()}function Rc(e,t){let n=String(e||"").trim();if(!n||!Ce)return;if(ft==="observer"&&!(W?.requestControl()??!1)){Xt("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 r=t?.runId||crypto.randomUUID(),o=!!t?.resume;t?.appendUserMessage!==!1&&Xt("user",n,!0);let i=y?.pendingRun?.id===r?y.pendingRun.attempts:0;rn({id:r,text:n,startedAt:Date.now(),attempts:o?i+1:0,autoResume:t?.autoResume!==!1}),pc=n,W?.acquireWorkflowLock(r),W?.setActiveRun({runId:r,text:n}),Ce.postMessage({type:"run",text:n,runId:r,resume:o}),Nn&&clearTimeout(Nn);let c=r;Nn=setTimeout(()=>{y?.pendingRun?.id===c&&(rn(void 0),W?.releaseWorkflowLock(c),W?.setActiveRun(void 0),Yt("Task timed out."),Xt("system","Task timed out after 5 minutes with no response.",!0),De("error",{message:"Run safety timeout"})),Nn=null},5*6e4)}function Wo(e,t){let n=String(e||"").trim();if(n){if(t?.startNewTask)Hr({reason:t.reason||"suggested_new_task",clearUi:!0});else if(!t?.bypassSuggestion){let r=ef(n);if(r.suggest){Fn={text:n,reason:r.reason||"heuristic",createdAt:Date.now()},he?.setTaskSuggestion({visible:!0,text:"This looks like a different request. Start a new task or continue this one?",primaryLabel:"Start new",secondaryLabel:"Continue"}),De("task_suggested_reset",{text:n,reason:Fn.reason});return}}Un(),Rc(n,{appendUserMessage:!0,resume:!1,autoResume:!0})}}function Yo(){if(ft==="observer")return;let e=W?.getState()?.activeRun;if(e?.runtimeId&&e.runtimeId!==$e&&!(y?.pendingRun?.id===e.runId)||!pn||!Ce||On||!y?.pendingRun||y.activeTask?.status==="ended")return;let t=y.pendingRun;if(!t.autoResume)return;if(Date.now()-t.startedAt>Id){rn(void 0),Yt("Previous task expired after navigation.");return}if(t.attempts>=Sd){rn(void 0),Xt("system","Auto-resume stopped after too many navigation attempts.",!0);return}On=!0,Yt("Resuming previous task after navigation..."),Rc(t.text,{runId:t.id,resume:!0,appendUserMessage:!1,autoResume:!0})}async function tf(e){if(!y)return;let t=await zd(e);if(!t||!y)return;let n=Number(y.updatedAt)||0,r=Mr({...t,sessionId:y.sessionId,runtimeId:$e},y.sessionId,$e);(Number(r.updatedAt)||0)<=n+200||(y=Mr({...y,...r,sessionId:y.sessionId,runtimeId:$e},y.sessionId,$e),Se(),he&&(he.clearMessages(),qs(y.uiMessages),Ys(y.timeline),y.uiStatus&&he.setStatus(y.uiStatus),y.uiHidden?he.hide():(he.show(),y.uiOpen?he.open():he.close())),pn&&Ce&&y.workerState&&ft==="controller"&&(Ce.postMessage({type:"hydrate_state",state:y.workerState}),De("context_restored",{source:"indexeddb_checkpoint",ts:Date.now()})))}function Xs(e,t){if(y){if(t==="remote"){let n=Math.max(1,Number(y.taskEpoch)||1),r=Math.max(1,Number(e.taskEpoch)||1),o=r>n;y.taskEpoch=Math.max(n,r);let s=y.activeTask||fn("shared_sync");y.activeTask=jd(e.task,s),o&&(y.uiMessages=[],y.timeline=[],xc(),rn(void 0),Un());let i=Ar(e.uiMessages),c=new Set(i.map(I=>I.id));if(i.length<y.uiMessages.length||y.uiMessages.some(I=>!c.has(I.id)))y.uiMessages=i,he?.clearMessages(),qs(y.uiMessages);else{let I=new Set(y.uiMessages.map(x=>x.id));for(let x of i)I.has(x.id)||(Xt(x.role,x.text,!0,{id:x.id,ts:x.ts,sourceRuntimeId:x.sourceRuntimeId,publishShared:!1}),I.add(x.id))}let v=Cr(e.timeline),b=new Set(v.map(I=>I.id));if(v.length<y.timeline.length||y.timeline.some(I=>!b.has(I.id)))y.timeline=v,Ys(y.timeline);else{let I=new Set(y.timeline.map(x=>x.id));for(let x of v)I.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),I.add(x.id))}if(typeof e.uiStatus=="string"&&Yt(e.uiStatus,{publishShared:!1}),e.activeRun&&e.activeRun.runtimeId!==$e?rn(Lr({id:e.activeRun.runId,text:e.activeRun.text,startedAt:e.activeRun.startedAt,attempts:y.pendingRun?.attempts||0,autoResume:!0})):!e.activeRun&&ft==="observer"&&rn(void 0),ft==="observer"&&Nr("observer",{localLogicalTabId:W?.getLocalLogicalTabId(),activeLogicalTabId:W?.getActiveLogicalTabId(),holderRuntimeId:W?.getCurrentHolderRuntimeId()}),e.workerContext){let I=Hn(e.workerContext),x=Number(y.workerState?.updatedAt)||0,A=Number(I?.updatedAt)||0;I&&A>x+100&&(y.workerState=I,pn&&Ce&&ft==="controller"&&(Ce.postMessage({type:"hydrate_state",state:I}),De("context_restored",{source:"shared_session",ts:Date.now()})))}}y.uiMessages=Ar(y.uiMessages),y.timeline=Cr(y.timeline),y.workerState=Hn(y.workerState),y.activeTask=Or(y.activeTask,fn("implicit")),Se()}}function kc(e){let t=fn("checkpoint_clone");return{version:Vs,sessionId:e.sessionId,runtimeId:e.runtimeId,uiOpen:!!e.uiOpen,uiHidden:!!e.uiHidden,uiStatus:typeof e.uiStatus=="string"?at(e.uiStatus,300):void 0,uiMessages:Ar(e.uiMessages),timeline:Cr(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:Hn(e.workerState),pendingRun:Lr(e.pendingRun),taskEpoch:Math.max(1,Number(e.taskEpoch)||1),activeTask:Or(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 nf(e){return!(e.sessionScope==="tab"||e.checkpointing?.enabled!==!0||!(e.apiKey||e.authToken)||!dt)}function rf(){if(!y||!_e||!dt)return null;let e=W?.getState(),t=kc(y),n=Math.max(Number(e?.updatedAt||0),Number(t.updatedAt||0),Date.now());return{version:Cd,siteId:_e.siteId,visitorId:dt,sessionId:y.sessionId,updatedAt:n,sharedState:e,runtimeState:t}}function of(e){if(!e||typeof e!="object"||!y||!_e||e.siteId&&e.siteId!==_e.siteId||dt&&e.visitorId&&e.visitorId!==dt)return;let t=typeof e.sessionId=="string"&&e.sessionId.trim()?e.sessionId.trim():y.sessionId;$o=!0;try{if(t&&y.sessionId!==t&&(y.sessionId=t,_e={..._e,sessionId:t},Xo(_e),Ce?.postMessage({type:"update_config",config:{sessionId:t}})),e.sharedState&&W&&W.hydrateExternalState(e.sharedState)&&(Xs(W.getState(),"remote"),Nr(W.getRole(),{localLogicalTabId:W.getLocalLogicalTabId(),activeLogicalTabId:W.getActiveLogicalTabId(),holderRuntimeId:W.getCurrentHolderRuntimeId()})),e.runtimeState&&typeof e.runtimeState=="object"){let n=Mr({...e.runtimeState,sessionId:t,runtimeId:$e},t,$e),r=Number(y.updatedAt)||0;(Number(n.updatedAt)||0)>r+200&&(y=Mr({...y,...n,sessionId:t,runtimeId:$e},t,$e),Se(),y.uiStatus&&he?.setStatus(y.uiStatus),y.uiHidden?he?.hide():(he?.show(),y.uiOpen?he?.open():he?.close()),pn&&y.workerState&&(Ce?.postMessage({type:"hydrate_state",state:y.workerState}),De("context_restored",{source:"cloud_checkpoint",ts:Date.now()})),ft==="controller"&&Yo())}}finally{$o=!1}}function Ic(e){if(gt?.stop(),gt=null,!!nf(e)&&dt)try{gt=new No({apiBase:e.apiBase,apiKey:e.apiKey,authToken:e.authToken,siteId:e.siteId,visitorId:dt,ttlHours:e.checkpointing?.ttlHours??1,flushIntervalMs:e.checkpointing?.flushIntervalMs,pullIntervalMs:e.checkpointing?.pullIntervalMs,minFlushIntervalMs:e.checkpointing?.minFlushIntervalMs,shouldWrite:()=>ft==="controller",buildCheckpoint:()=>rf(),onCheckpoint:t=>{of(t)},onError:()=>{}}),gt.start(),gt.markDirty()}catch{gt=null}}function Xo(e){if(y){if(W?.stop(),W=null,e.sessionScope==="tab"){Nr("controller");return}W=new Mo({siteId:e.siteId,sessionId:y.sessionId,runtimeId:$e,leaseMs:e.tabPolicy?.actionLeaseMs,onRoleChange:(t,n)=>{Nr(t,n);let r=t==="controller"&&(_e?.allowActions??!0);if(je?.setAllowActions(r),t==="controller"){let o=W?.getWorkerContext();if(o){let s=Hn(o),i=Number(y?.workerState?.updatedAt)||0,c=Number(s?.updatedAt)||0;s&&c>i+100&&(y&&(y.workerState=s,Se()),pn&&Ce&&(Ce.postMessage({type:"hydrate_state",state:s}),De("context_restored",{source:"controller_handoff",ts:Date.now()})))}Yo()}},onStateChange:(t,n)=>{Xs(t,n)},onSwitchRequested:t=>{t>0&&(Fr(),ze({kind:"status",title:`Switched to tab #${t}`,status:"info"}))}}),W.start(),W.setRpcRequestHandler(async t=>{if(!je)throw new Error("Bridge not available");if(t.method==="getPageData")return je.getPageData(t.params);if(t.method==="executeTool")return je.executeTool(t.params.call,t.params.payload);throw new Error(`Unknown RPC method: ${t.method}`)}),y?.activeTask&&W.syncTask({...y.activeTask,taskId:y.activeTask.taskId},y.taskEpoch),y?.workerState&&W.setWorkerContext(Tc(y.workerState))}}function sf(e){let t=at(qd(e)||"Done.",1200);he?.clearTimeline(),y&&(y.timeline=[]),W?.clearTimeline(),ze({id:e?`run:${e}:final`:void 0,kind:"tool_result",title:"Execution completed",detail:t,status:"success"})}function af(e){if(!(!e||typeof e!="object")&&!Gd(e)){if(e.type==="assistant"){let t=String(e.text||"");if(typeof e.runId=="string"&&e.runId&&(nn.set(e.runId,t),nn.size>80)){let n=nn.keys().next().value;n&&nn.delete(n)}Xt("assistant",t,!0),ze({kind:"tool_result",title:"Assistant update",detail:t,status:"success"});return}if(e.type==="status"){let t=Pd(e.stage),n=e.message?String(e.message):void 0,r=e.compactThought?String(e.compactThought):void 0,o=Wd(n,t,r);if(n&&Yt(n),o&&o!==Oo&&(Oo=o,n)){let s=!!(e.thought||r),i=r||(e.thought?String(e.thought):"");if(s&&t!=="analyze"&&t!=="route"&&t!=="complete"&&!Vd(i,pc))ze({kind:"thought",title:i,detail:e.thought?String(e.thought):r,status:"pending"});else{let f=t?`${Bd(t)}: ${n}`:n;ze({kind:"status",title:f,detail:r||(e.thought?String(e.thought):void 0),status:t==="complete"?"success":"info"})}}De("status",e);return}if(e.type==="tool_start"){ze({kind:"tool_start",title:`Running ${e.call?.name||"tool"}`,detail:Bo(e.call?.args),status:"pending"}),De("tool_start",e);return}if(e.type==="tool_result"){ze({kind:"tool_result",title:`${e.call?.name||"tool"} completed`,detail:Bo(e.result),status:e?.result?.success===!1?"error":"success"}),De("tool_result",e);return}if(e.type==="auth_required"){De("auth_required",e.error),e.error?.message&&(Xt("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"){De("navigation_guardrail",e),ze({kind:"status",title:"Navigation guardrail",detail:Bo(e),status:"info"});return}if(e.type==="error"){Xt("system",`Error: ${e.message||"unknown"}`,!0),ze({kind:"error",title:"Execution error",detail:String(e.message||"unknown"),status:"error"}),De("error",e);return}if(e.type==="state_snapshot"){y&&(y.workerState=Hn({...e.state||{},updatedAt:Date.now()}),e?.activeRun?.runId&&e?.activeRun?.text&&!y.pendingRun&&(y.pendingRun=Lr({id:e.activeRun.runId,text:e.activeRun.text,startedAt:e.activeRun.startedAt,attempts:0,autoResume:!0})),e?.activeRun?.runId&&e?.activeRun?.text&&W?.setActiveRun({runId:e.activeRun.runId,text:e.activeRun.text}),y.workerState&&W?.setWorkerContext(Tc(y.workerState)),Se());return}if(e.type==="task_started"){De("task_started",{taskId:e.taskId,reason:"worker"});return}if(e.type==="run_started"){Oo="",Un(),typeof e.runId=="string"&&e.runId&&nn.delete(e.runId);let t=y?.pendingRun;rn(Lr({id:e.runId,text:e.text,startedAt:t?.startedAt||Date.now(),attempts:t?.attempts||0,autoResume:t?.autoResume!==!1})),W?.setActiveRun({runId:e.runId,text:String(e.text||"")});let n=`run:${String(e.runId||"")}:start`;y?.timeline.some(r=>r.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"){Oo="",On=!1,Nn&&(clearTimeout(Nn),Nn=null),y?.pendingRun?.id===e.runId&&rn(void 0),typeof e.runId=="string"&&e.runId&&W?.releaseWorkflowLock(e.runId),y&&e?.route&&(e.route.mode==="act"||e.route.mode==="planner")&&(y.lastRoutingDecision={mode:e.route.mode,score:Number(e.route.score)||void 0,reason:typeof e.route.reason=="string"?at(e.route.reason,200):void 0,ts:Date.now()},Se()),W?.setActiveRun(void 0),!e.ok&&e.error?(Yt(`Task failed: ${String(e.error)}`),nn.delete(String(e.runId||"")),ze({kind:"error",title:"Run failed",detail:String(e.error),status:"error"})):e.ok&&(Yt("Execution completed"),sf(typeof e.runId=="string"?e.runId:void 0),typeof e.runId=="string"&&e.runId&&nn.delete(e.runId));return}if(e.type==="ready"){pn=!0,Yt("ready"),De("ready");let t=W?.getWorkerContext(),n=Hn(t),r=Number(y?.workerState?.updatedAt)||0,o=Number(n?.updatedAt)||0,s=n&&o>r+100?n:y?.workerState;y&&s&&s!==y.workerState&&(y.workerState=s,Se()),s?(Ce?.postMessage({type:"hydrate_state",state:s}),De("context_restored",{source:"runtime_start",ts:Date.now()})):Yo();return}if(e.type==="hydrated"){Yo();return}e.type==="updated"&&De("updated")}}function cf(e){if(Xo(e),W){let s=W.getRole();ft=s,y&&(y.executionMode=s)}Ic(e);let t=(e.allowActions??!0)&&(W?W.isController():!0);je=new Co({allowActions:t,runtimeId:$e,allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy,crossDomainPolicy:e.crossDomainPolicy,registerOpenedTab:s=>W?.registerOpenedTab(s),switchToLogicalTab:s=>W?.switchToLogicalTab(s)||{ok:!1,reason:"No session coordinator"},listKnownTabs:()=>(W?.listTabs()||[]).map(s=>({logicalTabId:s.logicalTabId,runtimeId:s.runtimeId,url:s.url,title:s.title,external:!!s.external})),onNavigationGuardrail:s=>{De("navigation_guardrail",s),ze({kind:"status",title:"Navigation guardrail",detail:Bo(s),status:"info"})},instrumentationOptions:e.mode==="safe"?{observeInlineMutations:!1}:void 0});let n=new MessageChannel;Ja(n.port1,{getSnapshot:()=>je.getSnapshot(),getPageData:async s=>{let i=s?.tabId,c=W?.getLocalLogicalTabId();if(!i||i===c||!W)return je.getPageData(s);let v=W.listTabs().find(b=>b.logicalTabId===i);if(!v)return je.getPageData(s);if(!v.runtimeId)return{url:v.url,title:v.title,fallback:!0};if(!W.isTabAlive(i))return{url:v.url,title:v.title,fallback:!0,stale:!0};try{return await W.sendCrossTabRpc(v.runtimeId,"getPageData",s,15e3)}catch{return{url:v.url,title:v.title,fallback:!0,error:"rpc_failed"}}},executeTool:async s=>{let i=W?.getActiveLogicalTabId(),c=W?.getLocalLogicalTabId();if(!i||i===c||!W)return je.executeTool(s.call,s.payload);let v=W.listTabs().find(b=>b.logicalTabId===i);if(!v?.runtimeId)return je.executeTool(s.call,s.payload);try{return await W.sendCrossTabRpc(v.runtimeId,"executeTool",s,2e4)}catch(b){return{success:!1,error:b?.message||"Cross-tab tool execution failed",allowFallback:!0}}},executeClientTool:s=>je.executeClientTool(s.name,s.args),listClientTools:()=>je.listClientTools(),getTabContext:()=>{let s=W?.getLocalLogicalTabId(),i=W?.getActiveLogicalTabId();return{id:s||1,logicalTabId:s||1,activeLogicalTabId:i||s||1,runtimeId:$e,mode:ft,url:window.location.href,title:document.title}},listSessionTabs:()=>W?.listTabs()||[]}),n.port1.start?.();let r=e.workerUrl?e.workerUrl:new URL("./worker/worker.js",__ROVER_SCRIPT_URL__).toString(),o=r;try{let s=window.location.origin,i=new URL(r).origin;if(s!==i){let c=new Blob([`import '${r}';`],{type:"application/javascript"});o=URL.createObjectURL(c)}}catch{}if(Ce=new Worker(o,{type:"module"}),Ce.postMessage({type:"init",config:e,port:n.port2},[n.port2]),he=rc({onSend:s=>{Wo(s)},onRequestControl:()=>{W?.requestControl()??!1?ze({kind:"status",title:"Control requested",detail:"This tab is now the active Rover controller.",status:"info"}):Xt("system","Unable to acquire control right now. Try again in a moment.",!0)},onNewTask:()=>{Hr({reason:"manual_new_task",clearUi:!0})},onEndTask:()=>{Qo({reason:"manual_end_task"})},onTaskSuggestionPrimary:()=>{let s=Fn;s&&Wo(s.text,{bypassSuggestion:!0,startNewTask:!0,reason:s.reason})},onTaskSuggestionSecondary:()=>{let s=Fn;s&&Wo(s.text,{bypassSuggestion:!0})},showTaskControls:e.ui?.showTaskControls!==!1,muted:e.ui?.muted,mascot:{disabled:e.ui?.mascot?.disabled,mp4Url:e.ui?.mascot?.mp4Url,webmUrl:e.ui?.mascot?.webmUrl},onOpen:()=>{y&&(y.uiOpen=!0,y.uiHidden=!1,Se()),De("open")},onClose:()=>{y&&(y.uiOpen=!1,Se()),De("close")}}),Un(),y?.uiMessages?.length&&qs(y.uiMessages),y?.timeline?.length&&Ys(y.timeline),y?.uiStatus&&he.setStatus(y.uiStatus),y?.executionMode&&he.setExecutionMode(y.executionMode,{localLogicalTabId:W?.getLocalLogicalTabId(),activeLogicalTabId:W?.getActiveLogicalTabId(),controllerRuntimeId:W?.getCurrentHolderRuntimeId(),canTakeControl:!0,canComposeInObserver:yc(),note:vc(y.executionMode)}),Ce.onmessage=s=>{af(s.data||{})},W){let s=()=>{W?.registerCurrentTab(window.location.href,document.title),W?.broadcastNavigation(window.location.href,document.title)},i=history.pushState.bind(history),c=history.replaceState.bind(history);history.pushState=function(...f){let v=i(...f);return setTimeout(s,0),v},history.replaceState=function(...f){let v=c(...f);return setTimeout(s,0),v},window.addEventListener("popstate",s)}y?.uiHidden?he.hide():(he.show(),y?.uiOpen??!!e.openOnInit?he.open():he.close()),y&&(y.uiHidden=!!y.uiHidden,y.uiOpen=!!y.uiOpen,Se()),W&&(Xs(W.getState(),"remote"),Nr(W.getRole(),{localLogicalTabId:W.getLocalLogicalTabId(),activeLogicalTabId:W.getActiveLogicalTabId(),holderRuntimeId:W.getCurrentHolderRuntimeId()}))}function Dr(e){if(un)return zo(e),un;Dn=ac(),$e=Dd(e.siteId),dt=gc(e),sr=Ud(e.siteId);let t=Yd(sr),n=e.sessionId?.trim(),r=!n&&!t?.sessionId&&e.sessionScope!=="tab"&&dt?Hd(e.siteId,dt):void 0,o=n||t?.sessionId||r||crypto.randomUUID();if(y=Mr(t,o,$e),n&&y.sessionId!==n&&(y=Ec(n,$e)),_e={...e,visitorId:dt||e.visitorId,sessionId:n||y.sessionId,taskRouting:{mode:e.taskRouting?.mode||"act",actHeuristicThreshold:e.taskRouting?.actHeuristicThreshold,plannerOnActError:e.taskRouting?.plannerOnActError},taskContext:{inactivityMs:e.taskContext?.inactivityMs??$s,suggestReset:e.taskContext?.suggestReset??!0,semanticSimilarityThreshold:e.taskContext?.semanticSimilarityThreshold??Gs}},y.sessionId=_e.sessionId,y.runtimeId=$e,y.executionMode=y.executionMode||"controller",y.timeline=Cr(y.timeline),y.uiMessages=Ar(y.uiMessages),y.activeTask=Or(y.activeTask,fn("boot")),y.taskEpoch=Math.max(1,Number(y.taskEpoch)||1),ft=y.executionMode,Se(),pn=!1,On=!1,cf(_e),sr&&tf(sr),Kd(),un={boot:Dr,init:zs,update:zo,shutdown:js,open:Fr,close:Ko,show:Ks,hide:Qs,send:Js,newTask:Hr,endTask:Qo,getState:Zs,registerTool:ei,on:hc},Uo.length){for(let s of Uo)bc(s);Uo.length=0}return un}function zs(e){return Dr(e)}function zo(e){!un||!Ce||!_e||(_e={..._e,...e,taskRouting:{..._e.taskRouting,...e.taskRouting},taskContext:{inactivityMs:e.taskContext?.inactivityMs??_e.taskContext?.inactivityMs??$s,suggestReset:e.taskContext?.suggestReset??_e.taskContext?.suggestReset??!0,semanticSimilarityThreshold:e.taskContext?.semanticSimilarityThreshold??_e.taskContext?.semanticSimilarityThreshold??Gs},ui:{..._e.ui,...e.ui,panel:{..._e.ui?.panel,...e.ui?.panel}}},dt=gc(_e),dt&&(_e.visitorId=dt),e.sessionId&&y?(y.sessionId=e.sessionId,Se(),Xo(_e)):(e.sessionScope||e.tabPolicy)&&Xo(_e),Ic(_e),je&&(typeof e.allowActions=="boolean"&&je.setAllowActions(e.allowActions&&ft==="controller"),(e.allowedDomains||e.crossDomainPolicy||e.domainScopeMode||e.externalNavigationPolicy)&&je.setNavigationPolicy({allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy,crossDomainPolicy:e.crossDomainPolicy})),Ce.postMessage({type:"update_config",config:e}),typeof e.openOnInit=="boolean"&&(e.openOnInit?Fr():Ko()))}function js(){Un(),Se(),gt?.markDirty(),gt?.syncNow(),gt?.stop(),gt=null,W?.stop(),W=null,Ce?.terminate(),Ce=null,he?.destroy(),he=null,je=null,_e=null,pn=!1,On=!1,$e="",dt=void 0,$o=!1,ft="controller",Fn=null,Dn=null,un=null}function Fr(){he?.show(),he?.open(),y&&(y.uiHidden=!1,y.uiOpen=!0,Se())}function Ko(){he?.close(),y&&(y.uiOpen=!1,Se())}function Ks(){he?.show(),y&&(y.uiHidden=!1,Se())}function Qs(){he?.hide(),y&&(y.uiHidden=!0,y.uiOpen=!1,Se())}function Js(e){e?.trim()&&Wo(e)}function Hr(e){if(!y)return;let t=e?.reason||"manual_new_task",n=e?.clearUi!==!1,r=Math.max(1,Number(y.taskEpoch)||1)+1,o=fn(t);y.pendingRun&&W?.releaseWorkflowLock(y.pendingRun.id),On=!1,y.taskEpoch=r,y.activeTask=o,y.pendingRun=void 0,y.workerState=void 0,n&&(y.uiMessages=[],y.timeline=[],y.uiStatus=void 0,xc()),W?.startNewTask({taskId:o.taskId,startedAt:o.startedAt,boundaryReason:t,status:"running",lastUserAt:void 0,lastAssistantAt:void 0}),W?.setActiveRun(void 0),W?.setWorkerContext(void 0),Yt("New task started."),Se(),Ce?.postMessage({type:"start_new_task",taskId:o.taskId}),ze({kind:"info",title:"Started new task",detail:t,status:"info"}),De("task_started",{taskId:o.taskId,reason:t,taskEpoch:r})}function Qo(e){if(!y)return;let t=e?.reason||"manual_end_task",n=jo("manual_end_task");n&&(n.status="ended",n.endedAt=Date.now(),n.boundaryReason=t,y.pendingRun&&(Ce?.postMessage({type:"cancel_run",runId:y.pendingRun.id}),W?.releaseWorkflowLock(y.pendingRun.id)),y.pendingRun=void 0,Un(),Yt("Task ended. Start a new task to continue."),W?.endTask(t),W?.setActiveRun(void 0),Se(),ze({kind:"info",title:"Task ended",detail:"Start a new task when you are ready.",status:"info"}),De("task_ended",{taskId:n.taskId,reason:t,endedAt:n.endedAt}))}function Zs(){return{mode:ft,runtimeId:$e,runtimeState:y?kc(y):null,sharedState:W?.getState()||null,pendingTaskSuggestion:Fn}}function ei(e,t){let n=Nd(e);if(!un||!je||!Ce){Uo.push({def:n,handler:t});return}bc({def:n,handler:t})}function lf(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 Sc(){let e=window,t=e.rover,n=((r,...o)=>{let s=lf(r),i=s?n[s]:void 0;if(typeof i=="function")return i(...o)});if(n.boot=Dr,n.init=zs,n.update=zo,n.shutdown=js,n.open=Fr,n.close=Ko,n.show=Ks,n.hide=Qs,n.send=Js,n.newTask=Hr,n.endTask=Qo,n.getState=Zs,n.registerTool=ei,n.on=hc,e.rover=n,typeof t=="function"&&Array.isArray(t.q))for(let r of t.q){let[o,...s]=Array.isArray(r)?r:Array.from(r);typeof o=="string"&&n(o,...s)}if(!un){let r=typeof globalThis.__ROVER_SCRIPT_EL__<"u"?globalThis.__ROVER_SCRIPT_EL__:null;if(r){let o=r.getAttribute("data-site-id"),s=r.getAttribute("data-api-key");if(o&&s){let i={siteId:o,apiKey:s},c=r.getAttribute("data-allowed-domains");c&&(i.allowedDomains=c.split(",").map(b=>b.trim()).filter(Boolean));let f=r.getAttribute("data-site-key-id");f&&(i.siteKeyId=f);let v=r.getAttribute("data-worker-url");v&&(i.workerUrl=v),Dr(i)}}}}Sc();return Oc(uf);})();
|
|
1052
|
+
`;let jt=document.createElement("form");jt.className="composer";let En=document.createElement("textarea");En.rows=1,En.placeholder="Ask Rover to act on this website...",jt.appendChild(En);let At=document.createElement("button");At.type="submit",At.className="sendBtn",At.innerHTML='<svg viewBox="0 0 24 24"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>',jt.appendChild(At);let cn=document.createElement("div");cn.className="resizeHandle",cn.setAttribute("aria-hidden","true"),v.appendChild(I),v.appendChild(ct),v.appendChild(ht),v.appendChild(jt),v.appendChild(cn),s.appendChild(i),s.appendChild(v),n.appendChild(o),n.appendChild(s);let Ue=En,mt=ht.querySelector(".taskSuggestionText"),Ft=ht.querySelector(".taskSuggestionBtn.primary"),ln=ht.querySelector(".taskSuggestionBtn.secondary"),Ht=new Set,Ut=new Map,Oe=[],$n="controller",Kt=!1,Qt=!1,Et=null,Jt=!1,xt=null,Pt=!1,Bt=!1,Wt=0;function wn(){Pt=!Pt,le.classList.toggle("visible",Pt)}function ue(){Pt=!1,le.classList.remove("visible")}function et(l,f=0){s.dataset.mood=l,xt!=null&&(window.clearTimeout(xt),xt=null),l==="typing"||l==="running"?(pt.classList.add("visible"),De.appendChild(pt),Ye()):pt.classList.remove("visible"),f>0&&l!=="idle"&&(xt=window.setTimeout(()=>{s.dataset.mood="idle",pt.classList.remove("visible"),xt=null},f))}function Vt(){return De.scrollHeight-De.scrollTop-De.clientHeight<60}function Ye(){Bt?ye.classList.add("visible"):(requestAnimationFrame(()=>{De.scrollTo({top:De.scrollHeight,behavior:"smooth"}),Wt=Date.now()}),ye.classList.remove("visible"))}De.addEventListener("scroll",()=>{Date.now()-Wt<200||(Vt()?(Bt=!1,ye.classList.remove("visible")):(Bt=!0,ye.classList.add("visible")))},{passive:!0}),ye.addEventListener("click",()=>{Bt=!1,Wt=Date.now(),De.scrollTo({top:De.scrollHeight,behavior:"smooth"}),ye.classList.remove("visible")});function yn(){Ue.disabled=$n==="observer"&&!Kt}function Gn(l){Jt=l,s.dataset.showDetails=l?"true":"false",Ze.textContent=Jt?"Hide details":"Show details";for(let f of Oe){let b=f.dataset.status,S=b==="success"||b==="error"||b==="info";f.classList.toggle("compact",!Jt&&S)}}function vn(){s.style.display="",v.classList.remove("closing"),v.classList.add("open"),et("idle"),e.onOpen?.(),Ue.disabled||Ue.focus()}function Se(){if(ue(),!v.classList.contains("open")){e.onClose?.();return}v.classList.remove("open"),v.classList.add("closing"),et("idle");let l=()=>{v.classList.remove("closing"),v.removeEventListener("animationend",l)};v.addEventListener("animationend",l),e.onClose?.()}function ur(){s.style.display=""}function Ur(){Se(),s.style.display="none"}function Pr(l,f){let b=ir(f);if(!b)return;let S=document.createElement("div");S.className=`entry message ${l}`;let A=document.createElement("div");A.className="bubble",l==="assistant"?b.length>280?A.appendChild(ec(b,280)):A.appendChild(Sr(b)):A.textContent=b;let C=document.createElement("div");C.className="stamp",C.textContent=Za(Date.now()),S.appendChild(A),S.appendChild(C),De.appendChild(S),l==="user"?et("typing",1200):l==="assistant"?et("success",1400):et("running",900),Ye()}function qn(){for(let l of Array.from(De.querySelectorAll(".entry.message")))l.remove()}function _n(l){let f=Ut.get(l);if(f)return f;let b=document.createElement("div");b.className="entry trace pending";let S=document.createElement("div");S.className="traceTop";let A=document.createElement("div");A.className="traceMeta";let C=document.createElement("span");C.className="traceStage",C.textContent="step";let O=document.createElement("div");O.className="traceTitle";let W=document.createElement("div");W.className="traceTs",A.appendChild(C),A.appendChild(O),S.appendChild(A),S.appendChild(W);let Y=document.createElement("div");return Y.className="traceDetail",b.appendChild(S),b.appendChild(Y),Ut.set(l,b),Oe.push(b),De.appendChild(b),b}function Rt(l,f){let b=Number(f.ts)||Date.now(),S=pd(f),A=l.querySelector(".traceTop"),O=A.querySelector(".traceMeta").querySelector(".traceStage"),W=A.querySelector(".traceTitle"),Y=A.querySelector(".traceTs"),K=l.querySelector(".traceDetail"),fe=nc(f.title||"");W.textContent=fe.plainTitle||"Step",O.textContent=fe.stage||f.kind||"step",O.style.display=fe.stage||f.kind==="status"||f.kind==="plan"||f.kind==="thought"?"":"none",Y.textContent=Za(b),K.innerHTML="";let J=ir(f.detail||"");if(J){let oe=f.kind==="thought"?150:f.kind==="tool_start"||f.kind==="tool_result"?100:280;J.length>oe?K.appendChild(ec(J,oe)):K.appendChild(Sr(J)),K.style.display=""}else K.style.display="none";l.classList.remove("pending","success","error","info"),l.classList.add(S),l.dataset.status=S,l.dataset.kind=f.kind,l.dataset.visibility=md(f);let te=S==="success"||S==="error"||S==="info";l.classList.toggle("compact",!Jt&&te),S==="error"?et("error",2200):S==="success"?et("success",1200):S==="pending"&&et("running",800)}function Zt(l){let f=ir(l.title||"");if(!f||f.toLowerCase()==="assistant update")return;let b=l.id||tc("timeline");if(l.id&&Ht.has(b))return;Ht.add(b);let S=hd(l),A=S==="run"||S.startsWith("tool:")||l.kind==="tool_result"||l.kind==="status"&&Ut.has(S),C=_n(A?S:`${S}:${b}`);Rt(C,{...l,title:f}),f.toLowerCase()==="run completed"&&Gn(!1),Ye()}function en(){Ht.clear(),Ut.clear(),Oe.length=0;for(let l of Array.from(De.querySelectorAll(".entry.trace")))l.remove()}function $t(l){let f=!!l?.visible;ht.classList.toggle("visible",f),mt.textContent=l?.text||"Looks like a new request. Start a new task?",Ft.textContent=l?.primaryLabel||"Start new",ln.textContent=l?.secondaryLabel||"Continue"}function Gt(l){let f=String(l||"ready");U.textContent=f;let b=f.toLowerCase();b.includes("error")||b.includes("failed")?et("error",1800):b==="ready"||b.includes("complete")?et("idle"):et("running",1e3)}function Tn(l){Qt=l,Be.classList.toggle("visible",l),Z.style.display=l?"none":""}function un(l,f){$n=l,Kt=l==="observer"?f?.canComposeInObserver===!0:!0,yn(),Z.classList.remove("controller","observer"),Z.classList.add(l),l==="controller"?(Z.textContent="active",qe.style.display="none",Ue.placeholder="Ask Rover to act on this website..."):(Z.textContent="observer",f?.canTakeControl!==!1?qe.style.display="":qe.style.display="none",f?.note?Ue.placeholder=f.note:Kt?Ue.placeholder="Send to take control and run here.":f?.activeLogicalTabId&&f?.localLogicalTabId&&f.activeLogicalTabId!==f.localLogicalTabId?Ue.placeholder=`Observing: Rover is acting in tab #${f.activeLogicalTabId}`:Ue.placeholder="Observer mode. Take control to run actions here.")}function a(){xt!=null&&(window.clearTimeout(xt),xt=null),document.removeEventListener("keydown",E),r.remove(),t.remove()}i.addEventListener("click",()=>{v.classList.contains("open")?Se():vn()}),se.addEventListener("click",()=>Se()),ne.addEventListener("click",l=>{l.stopPropagation(),wn()}),s.addEventListener("click",l=>{Pt&&!le.contains(l.target)&&l.target!==ne&&ue()}),ke.addEventListener("click",()=>{ue(),Qt&&e.onCancelRun?(Et="new_task",$t({visible:!0,text:"A task is in progress. Cancel it and start new?",primaryLabel:"Cancel & start new",secondaryLabel:"Keep running"})):e.onNewTask?.()}),We.addEventListener("click",()=>{ue(),Qt&&e.onCancelRun?(Et="end_task",$t({visible:!0,text:"A task is in progress. Cancel and end it?",primaryLabel:"Cancel & end",secondaryLabel:"Keep running"})):e.onEndTask?.()}),Ze.addEventListener("click",()=>{ue(),Gn(!Jt)}),qe.addEventListener("click",()=>{ue(),e.onRequestControl?.()}),Be.addEventListener("click",()=>{e.onCancelRun?.()}),Ft.addEventListener("click",()=>{if(Et){let l=Et;Et=null,$t({visible:!1}),e.onCancelRun?.(),l==="new_task"?e.onNewTask?.():l==="end_task"&&e.onEndTask?.();return}e.onTaskSuggestionPrimary?.()}),ln.addEventListener("click",()=>{if(Et){Et=null,$t({visible:!1});return}e.onTaskSuggestionSecondary?.()}),Ue.addEventListener("input",()=>{Ue.style.height="auto",Ue.style.height=`${Math.min(96,Math.max(44,Ue.scrollHeight))}px`}),Ue.addEventListener("keydown",l=>{l.key==="Enter"&&!l.shiftKey&&!l.isComposing&&(l.preventDefault(),jt.requestSubmit())}),jt.addEventListener("submit",l=>{if(l.preventDefault(),Ue.disabled)return;let f=ir(Ue.value);f&&($t({visible:!1}),e.onSend(f),Ue.value="",Ue.style.height="44px")}),n.addEventListener("keydown",l=>{let f=l;f.key==="Escape"&&v.classList.contains("open")&&(f.stopPropagation(),Se())});let E=l=>{l.code==="Period"&&l.shiftKey&&(l.metaKey||l.ctrlKey)&&(l.preventDefault(),l.stopPropagation(),v.classList.contains("open")?Se():vn())};document.addEventListener("keydown",E);let m=null,g=l=>{if(!m)return;let f=m.startX-l.clientX,b=l.clientY-m.startY,S=Math.max(320,Math.min(window.innerWidth-16,m.startW+f)),A=Math.max(460,Math.min(window.innerHeight-16,m.startH+b));v.style.width=`${S}px`,v.style.height=`${A}px`},p=()=>{m=null,window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",p)};if(cn.addEventListener("pointerdown",l=>{window.matchMedia("(max-width: 640px)").matches||(l.preventDefault(),m={startX:l.clientX,startY:l.clientY,startW:v.getBoundingClientRect().width,startH:v.getBoundingClientRect().height},window.addEventListener("pointermove",g),window.addEventListener("pointerup",p))}),d){let l=()=>{d.style.display="none",_.style.display="grid"};d.addEventListener("error",l,{once:!0}),_.style.display="none"}if(M){let l=()=>{M.style.display="none",D.style.display="grid"};M.addEventListener("error",l,{once:!0}),D.style.display="none"}return un("controller"),Gn(!1),{addMessage:Pr,clearMessages:qn,addTimelineEvent:Zt,clearTimeline:en,setTaskSuggestion:$t,setStatus:Gt,setRunning:Tn,setExecutionMode:un,open:vn,close:Se,show:ur,hide:Ur,destroy:a}}var gd="rover:shared:",bd="rover:channel:";function ee(){return Date.now()}function zt(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Os(e){let t=String(e||"").trim();if(!t)return"";try{return new URL(t,window.location.href).toString()}catch{return t}}function sc(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)||ee(),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 Ed(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 oc(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e.slice(-t)){let o=Ed(r);o!==void 0&&n.push(o)}return n}function ic(e){if(!e||typeof e!="object")return;let t=s=>s.slice(-80).map(i=>({role:typeof i?.role=="string"?i.role:"assistant",content:typeof i?.content=="string"?i.content:""})).filter(i=>!!i.content),n=Array.isArray(e.history)?t(e.history):[],r=oc(e.plannerHistory,40),o=oc(e.agentPrevSteps,80);return{trajectoryId:typeof e.trajectoryId=="string"?e.trajectoryId:void 0,history:n,plannerHistory:r,agentPrevSteps:o,updatedAt:Number(e.updatedAt)||ee()}}function Fs(e,t){return{version:2,siteId:e,sessionId:t,seq:1,updatedAt:ee(),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,workflowLock:void 0}}function ar(e,t,n){let r=Fs(t,n);if(!e||typeof e!="object")return r;let o={...r,version:2,siteId:t,sessionId:n,seq:Math.max(1,Number(e.seq)||1),updatedAt:Number(e.updatedAt)||ee(),tabs:Array.isArray(e.tabs)?e.tabs.map(c=>({logicalTabId:Math.max(1,Number(c?.logicalTabId)||0),runtimeId:typeof c?.runtimeId=="string"?c.runtimeId:void 0,url:String(c?.url||""),title:typeof c?.title=="string"?c.title:void 0,openedAt:Number(c?.openedAt)||ee(),updatedAt:Number(c?.updatedAt)||ee(),external:!!c?.external,openerRuntimeId:typeof c?.openerRuntimeId=="string"?c.openerRuntimeId:void 0})).filter(c=>!!c.logicalTabId):[],nextLogicalTabId:Math.max(1,Number(e.nextLogicalTabId)||1),activeLogicalTabId:Number(e.activeLogicalTabId)||void 0,uiMessages:Array.isArray(e.uiMessages)?e.uiMessages.map(c=>({id:String(c?.id||zt("msg")),role:c?.role==="user"||c?.role==="assistant"||c?.role==="system"?c.role:"system",text:String(c?.text||""),ts:Number(c?.ts)||ee(),sourceRuntimeId:typeof c?.sourceRuntimeId=="string"?c.sourceRuntimeId:void 0})).filter(c=>!!c.text):[],timeline:Array.isArray(e.timeline)?e.timeline.map(c=>({id:String(c?.id||zt("timeline")),kind:String(c?.kind||"status"),title:String(c?.title||"Step"),detail:typeof c?.detail=="string"?c.detail:void 0,status:c?.status==="pending"||c?.status==="success"||c?.status==="error"||c?.status==="info"?c.status:void 0,ts:Number(c?.ts)||ee(),sourceRuntimeId:typeof c?.sourceRuntimeId=="string"?c.sourceRuntimeId:void 0})).filter(c=>!!c.title):[],taskEpoch:Math.max(1,Number(e.taskEpoch)||1),task:sc(e.task),workerContext:ic(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)||ee(),updatedAt:Number(e.activeRun.updatedAt)||ee()}: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)||ee()}:void 0,workflowLock:e.workflowLock&&typeof e.workflowLock=="object"&&e.workflowLock.runtimeId&&e.workflowLock.runId?{runtimeId:String(e.workflowLock.runtimeId),runId:String(e.workflowLock.runId),lockedAt:Number(e.workflowLock.lockedAt)||ee(),expiresAt:Number(e.workflowLock.expiresAt)||0}:void 0},s=o.tabs.length,i=new Set;return o.tabs=o.tabs.filter(c=>i.has(c.logicalTabId)?!1:(i.add(c.logicalTabId),!0)),o.nextLogicalTabId<=(o.tabs.at(-1)?.logicalTabId??0)&&(o.nextLogicalTabId=o.tabs.reduce((c,d)=>Math.max(c,d.logicalTabId),0)+1),s>0&&o.tabs.length<s&&console.warn(`[rover] sanitizeSharedState: dropped ${s-o.tabs.length} invalid/duplicate tab entries`),o}var Lo=class Lo{constructor(t){$(this,"siteId");$(this,"sessionId");$(this,"runtimeId");$(this,"leaseMs");$(this,"heartbeatMs");$(this,"maxMessages");$(this,"maxTimeline");$(this,"onRoleChange");$(this,"onStateChange");$(this,"onSwitchRequested");$(this,"key");$(this,"channelName");$(this,"state");$(this,"channel",null);$(this,"heartbeatTimer",null);$(this,"storageHandler",null);$(this,"localLogicalTabId");$(this,"closing",!1);$(this,"started",!1);$(this,"pendingRpcRequests",new Map);$(this,"rpcRequestHandler");$(this,"lastNotifiedRole");$(this,"roleChangeTimer",null);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=`${gd}${this.siteId}:${this.sessionId}`,this.channelName=`${bd}${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:zt("task"),status:"running",startedAt:ee(),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 r=ar(n.state,this.siteId,this.sessionId);this.applyIncomingState(r)}n.type==="switch_request"&&n.targetRuntimeId===this.runtimeId&&this.onSwitchRequested?.(Number(n.logicalTabId)||0),n.type==="rpc_request"&&n.targetRuntimeId===this.runtimeId&&this.handleInboundRpcRequest(n),n.type==="rpc_response"&&n.targetRuntimeId===this.runtimeId&&this.handleInboundRpcResponse(n),n.type==="tab_navigated"&&n.runtimeId&&n.runtimeId!==this.runtimeId&&this.handleRemoteNavigation(n),n.type==="tab_closing"&&n.runtimeId&&n.runtimeId!==this.runtimeId&&this.handleRemoteTabClosing(n)}}),this.storageHandler=t=>{if(!(t.key!==this.key||!t.newValue))try{let n=ar(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(){if(this.started){this.started=!1,this.heartbeatTimer!=null&&(window.clearInterval(this.heartbeatTimer),this.heartbeatTimer=null),this.roleChangeTimer!=null&&(window.clearTimeout(this.roleChangeTimer),this.roleChangeTimer=null),this.storageHandler&&(window.removeEventListener("storage",this.storageHandler),this.storageHandler=null),this.channel&&(this.channel.close(),this.channel=null);for(let[,t]of this.pendingRpcRequests)window.clearTimeout(t.timer),t.reject(new Error("SessionCoordinator stopped"));this.pendingRpcRequests.clear(),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<=ee()?!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",r=>{n&&Number.isFinite(n)&&n>r.taskEpoch&&(r.taskEpoch=Math.max(1,Math.trunc(n))),t&&(r.task=sc(t)||r.task)})}hydrateExternalState(t){let n=ar(t,this.siteId,this.sessionId),r=this.state.seq,o=this.state.updatedAt;return this.applyIncomingState(n),this.state.seq!==r||this.state.updatedAt!==o?(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)||ee(),r={taskId:String(t.taskId||zt("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",o=>{o.taskEpoch=Math.max(1,Number(o.taskEpoch)||1)+1,o.task=r,o.uiMessages=[],o.timeline=[],o.uiStatus=void 0,o.activeRun=void 0,o.workerContext=void 0}),r}endTask(t){let n;return this.mutate("local",r=>{r.task&&(r.task={...r.task,status:"ended",boundaryReason:t||r.task.boundaryReason,endedAt:ee()},r.activeRun=void 0,n=r.task)}),n}markTaskActivity(t,n=ee()){t!=="system"&&this.mutate("local",r=>{if(!r.task){r.task={taskId:zt("task"),status:"running",startedAt:n,boundaryReason:"implicit",lastUserAt:t==="user"?n:void 0,lastAssistantAt:t==="assistant"?n:void 0};return}t==="user"&&(r.task.lastUserAt=n),t==="assistant"&&(r.task.lastAssistantAt=n),r.task.status==="ended"&&(r.task.status="running",r.task.endedAt=void 0)})}setWorkerContext(t){this.mutate("local",n=>{if(!t){n.workerContext=void 0;return}n.workerContext=ic(t)})}setStatus(t){this.mutate("local",n=>{n.uiStatus=t||void 0})}appendMessage(t){let n={id:t.id||zt("msg"),role:t.role,text:String(t.text||""),ts:Number(t.ts)||ee(),sourceRuntimeId:this.runtimeId};return this.mutate("local",r=>{r.uiMessages.push(n),r.uiMessages.length>this.maxMessages&&(r.uiMessages=r.uiMessages.slice(-this.maxMessages)),r.task||(r.task={taskId:zt("task"),status:"running",startedAt:n.ts,boundaryReason:"implicit"}),n.role==="user"?r.task.lastUserAt=n.ts:n.role==="assistant"&&(r.task.lastAssistantAt=n.ts)}),n}appendTimeline(t){let n={id:t.id||zt("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)||ee(),sourceRuntimeId:this.runtimeId};return this.mutate("local",r=>{r.timeline.push(n),r.timeline.length>this.maxTimeline&&(r.timeline=r.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:ee(),updatedAt:ee()},n.task?n.task.status!=="ended"&&(n.task.status="running"):n.task={taskId:zt("task"),status:"running",startedAt:ee()}})}requestControl(){return this.claimLease(!0)}registerCurrentTab(t,n){let r=Os(t),o;return this.mutate("local",s=>{let i=s.tabs.find(c=>c.runtimeId===this.runtimeId);if(i)i.url=r||i.url,i.title=n||i.title,i.updatedAt=ee(),o=i.logicalTabId;else{let c=s.tabs.find(d=>!d.runtimeId&&d.url===r&&ee()-d.openedAt<18e4);if(c)c.runtimeId=this.runtimeId,c.title=n||c.title,c.updatedAt=ee(),o=c.logicalTabId;else{let d=s.nextLogicalTabId++;s.tabs.push({logicalTabId:d,runtimeId:this.runtimeId,url:r,title:n,openedAt:ee(),updatedAt:ee(),external:!1}),o=d}}s.activeLogicalTabId||(s.activeLogicalTabId=o)}),this.notifyRoleChange(),this.localLogicalTabId||o||1}registerOpenedTab(t){let n=Os(t.url),r=0;return this.mutate("local",o=>{r=o.nextLogicalTabId++,o.tabs.push({logicalTabId:r,runtimeId:void 0,url:n,title:t.title,openedAt:ee(),updatedAt:ee(),external:!!t.external,openerRuntimeId:t.openerRuntimeId})}),{logicalTabId:r}}switchToLogicalTab(t){let n={ok:!1,reason:"Unknown tab"};return this.mutate("local",r=>{let o=r.tabs.find(s=>s.logicalTabId===t);if(!o){n={ok:!1,reason:`Tab ${t} not found`};return}if(r.activeLogicalTabId=t,o.runtimeId&&o.runtimeId!==this.runtimeId){r.lease={holderRuntimeId:o.runtimeId,expiresAt:ee()+this.leaseMs,updatedAt:ee()},this.channel&&this.channel.postMessage({type:"switch_request",logicalTabId:t,targetRuntimeId:o.runtimeId,sourceRuntimeId:this.runtimeId}),n={ok:!0,delegated:!0};return}if(!o.runtimeId){n={ok:!1,reason:`Tab ${t} is not attached to an active Rover runtime yet`};return}r.lease={holderRuntimeId:this.runtimeId,expiresAt:ee()+this.leaseMs,updatedAt:ee()},n={ok:!0,delegated:!1}}),this.notifyRoleChange(),n}sendCrossTabRpc(t,n,r,o=15e3){return new Promise((s,i)=>{if(!this.channel){i(new Error("BroadcastChannel not available"));return}let c=zt("rpc"),d=window.setTimeout(()=>{this.pendingRpcRequests.delete(c),i(new Error(`Cross-tab RPC timed out after ${o}ms (method=${n}, target=${t})`))},o);this.pendingRpcRequests.set(c,{resolve:s,reject:i,timer:d}),this.channel.postMessage({type:"rpc_request",requestId:c,sourceRuntimeId:this.runtimeId,targetRuntimeId:t,method:n,params:r,timeoutMs:o,createdAt:ee()})})}setRpcRequestHandler(t){this.rpcRequestHandler=t}broadcastNavigation(t,n){this.channel&&this.channel.postMessage({type:"tab_navigated",runtimeId:this.runtimeId,logicalTabId:this.localLogicalTabId,url:t,title:n})}broadcastClosing(){this.closing=!0,this.channel&&(this.mutate("local",t=>{t.tabs=t.tabs.filter(n=>n.runtimeId!==this.runtimeId),t.activeLogicalTabId&&!t.tabs.some(n=>n.logicalTabId===t.activeLogicalTabId)&&(t.activeLogicalTabId=void 0)}),this.channel.postMessage({type:"tab_closing",runtimeId:this.runtimeId,logicalTabId:this.localLogicalTabId}))}isTabAlive(t){let n=this.state.tabs.find(r=>r.logicalTabId===t);return n?n.updatedAt>ee()-2*this.heartbeatMs:!1}acquireWorkflowLock(t){let n=!1;return this.mutate("local",r=>{let o=r.workflowLock;if(o&&o.runtimeId!==this.runtimeId&&o.expiresAt>ee()){let s=r.tabs.find(c=>c.runtimeId===o.runtimeId);if(s&&s.updatedAt>ee()-2*this.heartbeatMs){n=!1;return}}r.workflowLock={runtimeId:this.runtimeId,runId:t,lockedAt:ee(),expiresAt:ee()+this.leaseMs*5},n=!0}),n}clearActiveRunRuntimeId(t){this.mutate("local",n=>{n.activeRun&&n.activeRun.runId===t&&(n.activeRun.runtimeId="")})}releaseWorkflowLock(t){this.mutate("local",n=>{n.workflowLock&&n.workflowLock.runId===t&&(n.workflowLock=void 0)})}isWorkflowLocked(){let t=this.state.workflowLock;return!t||t.runtimeId===this.runtimeId?!1:t.expiresAt>ee()}getWorkflowLockInfo(){let t=this.state.workflowLock;return!t||t.expiresAt<=ee()?{locked:!1}:{locked:!0,holderRuntimeId:t.runtimeId,runId:t.runId}}async handleInboundRpcRequest(t){let{requestId:n,sourceRuntimeId:r,method:o,params:s}=t;if(!this.rpcRequestHandler){this.channel?.postMessage({type:"rpc_response",requestId:n,sourceRuntimeId:this.runtimeId,targetRuntimeId:r,ok:!1,error:{message:"No RPC handler registered",code:"NO_HANDLER"}});return}try{let i=await this.rpcRequestHandler({method:o,params:s});this.channel?.postMessage({type:"rpc_response",requestId:n,sourceRuntimeId:this.runtimeId,targetRuntimeId:r,ok:!0,result:i})}catch(i){this.channel?.postMessage({type:"rpc_response",requestId:n,sourceRuntimeId:this.runtimeId,targetRuntimeId:r,ok:!1,error:{message:i?.message||String(i)}})}}handleInboundRpcResponse(t){let{requestId:n,ok:r,result:o,error:s}=t,i=this.pendingRpcRequests.get(n);i&&(this.pendingRpcRequests.delete(n),window.clearTimeout(i.timer),r?i.resolve(o):i.reject(new Error(s?.message||"Cross-tab RPC failed")))}handleRemoteNavigation(t){let{runtimeId:n,url:r,title:o}=t;this.mutate("local",s=>{let i=s.tabs.find(c=>c.runtimeId===n);i&&(i.url=r||i.url,i.title=o||i.title,i.updatedAt=ee())})}handleRemoteTabClosing(t){let{runtimeId:n}=t;this.mutate("local",r=>{r.tabs=r.tabs.filter(o=>o.runtimeId!==n),r.lease?.holderRuntimeId===n&&(r.lease=void 0),r.workflowLock?.runtimeId===n&&(r.workflowLock=void 0),r.activeRun?.runtimeId===n&&(r.activeRun=void 0),r.activeLogicalTabId&&!r.tabs.some(o=>o.logicalTabId===r.activeLogicalTabId)&&(r.activeLogicalTabId=void 0)}),this.notifyRoleChange()}heartbeat(){if(this.closing)return;let t=Os(window.location.href),n=document.title||void 0;this.mutate("local",r=>{let o=r.tabs.find(c=>c.runtimeId===this.runtimeId);if(o)o.url=t||o.url,o.title=n||o.title,o.updatedAt=ee();else{let c=r.nextLogicalTabId++;r.tabs.push({logicalTabId:c,runtimeId:this.runtimeId,url:t,title:n,openedAt:ee(),updatedAt:ee(),external:!1})}let s=r.lease;(!s||s.expiresAt<=ee()||s?.holderRuntimeId===this.runtimeId)&&(r.lease={holderRuntimeId:this.runtimeId,expiresAt:ee()+this.leaseMs,updatedAt:ee()},!r.activeLogicalTabId&&this.localLogicalTabId&&(r.activeLogicalTabId=this.localLogicalTabId)),r.workflowLock?.runtimeId===this.runtimeId&&(r.workflowLock.expiresAt=ee()+this.leaseMs*5)}),this.notifyRoleChange()}reloadFromStorage(){let t=this.loadState();return(t.seq>this.state.seq||t.seq===this.state.seq&&t.updatedAt>this.state.updatedAt)&&(this.state=t,this.syncLocalLogicalTabId(),this.onStateChange?.(this.state,"remote")),this.closing=!1,this.state}claimLease(t){let n=!1;return this.mutate("local",r=>{let o=r.lease,s=!o||o.expiresAt<=ee();(t||s||o?.holderRuntimeId===this.runtimeId)&&(r.lease={holderRuntimeId:this.runtimeId,expiresAt:ee()+this.leaseMs,updatedAt:ee()},!r.activeLogicalTabId&&this.localLogicalTabId&&(r.activeLogicalTabId=this.localLogicalTabId),n=!0)}),this.notifyRoleChange(),n}notifyRoleChange(){this.getRole()!==this.lastNotifiedRole&&(this.roleChangeTimer!=null&&window.clearTimeout(this.roleChangeTimer),this.roleChangeTimer=window.setTimeout(()=>{this.roleChangeTimer=null;let n=this.getRole();n!==this.lastNotifiedRole&&(this.lastNotifiedRole=n,this.onRoleChange?.(n,{localLogicalTabId:this.localLogicalTabId,activeLogicalTabId:this.state.activeLogicalTabId,holderRuntimeId:this.state.lease?.holderRuntimeId}))},Lo.ROLE_CHANGE_DEBOUNCE_MS))}syncLocalLogicalTabId(){let t=this.state.tabs.find(n=>n.runtimeId===this.runtimeId);this.localLogicalTabId=t?.logicalTabId}mutate(t,n){if(t==="local")try{let o=window.localStorage.getItem(this.key);if(o){let s=ar(JSON.parse(o),this.siteId,this.sessionId);(s.seq>this.state.seq||s.seq===this.state.seq&&s.updatedAt>this.state.updatedAt)&&(this.state=s)}}catch{}let r=ar(this.state,this.siteId,this.sessionId);n(r),r.seq=Math.max(1,Number(r.seq)||1)+(t==="local"?1:0),r.updatedAt=ee(),this.state=r,this.syncLocalLogicalTabId(),t==="local"&&(this.persistState(),this.channel&&this.channel.postMessage({type:"state",sourceRuntimeId:this.runtimeId,state:this.state})),this.onStateChange?.(this.state,t)}applyIncomingState(t){t&&(t.seq<this.state.seq||t.seq===this.state.seq&&t.updatedAt<=this.state.updatedAt||(this.state=t,this.syncLocalLogicalTabId(),this.onStateChange?.(this.state,"remote"),this.notifyRoleChange()))}loadState(){try{let t=window.localStorage.getItem(this.key);if(!t)return Fs(this.siteId,this.sessionId);let n=JSON.parse(t);return ar(n,this.siteId,this.sessionId)}catch(t){return console.warn("[rover] Failed to load shared state from localStorage:",t),Fs(this.siteId,this.sessionId)}}persistState(){try{window.localStorage.setItem(this.key,JSON.stringify(this.state))}catch{}}};$(Lo,"ROLE_CHANGE_DEBOUNCE_MS",200);var Mo=Lo;var wd="https://us-central1-rtrvr-extension-functions.cloudfunctions.net";function cr(e,t){let n=Number(e);return Number.isFinite(n)?n:t}function yd(e,t=8e3){let n=String(e??"");return n.length<=t?n:`${n.slice(0,t)}\u2026`}function vd(e){let t=Number(e.sharedState?.seq||0),n=Array.isArray(e.sharedState?.uiMessages)?e.sharedState.uiMessages.length:0,r=Number(e.runtimeState?.updatedAt||0),o=Array.isArray(e.runtimeState?.uiMessages)?e.runtimeState.uiMessages.length:0;return[e.sessionId,cr(e.updatedAt,0),t,n,r,o].join(":")}function _d(e){let t=(e||wd).replace(/\/$/,"");return t.endsWith("/extensionRouter")?t:`${t}/extensionRouter`}function Hs(e,t){let n=new Error(e);return n.details=t,n}var No=class{constructor(t){$(this,"endpoint");$(this,"token");$(this,"siteId");$(this,"visitorId");$(this,"ttlHours");$(this,"flushIntervalMs");$(this,"pullIntervalMs");$(this,"minFlushIntervalMs");$(this,"shouldWrite");$(this,"buildCheckpoint");$(this,"onCheckpoint");$(this,"onError");$(this,"started",!1);$(this,"dirty",!1);$(this,"flushTimer",null);$(this,"pullTimer",null);$(this,"lastFlushAt",0);$(this,"lastPullAt",0);$(this,"lastUploadedRevision","");$(this,"lastAppliedRemoteUpdatedAt",0);$(this,"pushInFlight",!1);$(this,"pullInFlight",!1);let n=String(t.apiKey||t.authToken||"").trim();if(!n)throw Hs("Rover cloud checkpoint requires apiKey or authToken.");this.endpoint=_d(t.apiBase),this.token=n,this.siteId=t.siteId,this.visitorId=t.visitorId,this.ttlHours=Math.max(1,Math.min(168,Math.floor(cr(t.ttlHours,1)))),this.flushIntervalMs=Math.max(2e3,Math.floor(cr(t.flushIntervalMs,8e3))),this.pullIntervalMs=Math.max(2e3,Math.floor(cr(t.pullIntervalMs,9e3))),this.minFlushIntervalMs=Math.max(1e3,Math.floor(cr(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 r=vd(n);if(!t&&r===this.lastUploadedRevision){this.dirty=!1;return}this.pushInFlight=!0;try{let o=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(),o?.saved&&(this.dirty=!1,this.lastUploadedRevision=r),o?.stale&&o?.checkpoint&&typeof o.checkpoint=="object"&&(this.applyRemoteCheckpoint(o.checkpoint,"push_stale"),this.dirty=!1)}catch(o){this.onError?.(o)}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 r=Math.max(0,Math.floor(cr(t?.updatedAt,0)));r<=this.lastAppliedRemoteUpdatedAt||(this.lastAppliedRemoteUpdatedAt=r,this.onCheckpoint(t,n))}async callExtensionRouter(t,n){let r=await fetch(this.endpoint,{method:"POST",headers:{Authorization:`Bearer ${this.token}`,"Content-Type":"application/json"},body:JSON.stringify({action:t,data:n})});if(!r.ok){let s;try{s=await r.json()}catch{let i=await r.text().catch(()=>"");s=i?{error:yd(i,2e3)}:void 0}throw Hs(`Checkpoint HTTP ${r.status}`,s)}let o=await r.json();if(o?.success===!1)throw Hs("Checkpoint extensionRouter returned success=false",o);return o?.data}};var Td="rover-runtime-state-db",Do="runtime-state",Us=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{}}},Ps=class{constructor(){$(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 r=indexedDB.open(Td,1);r.onupgradeneeded=()=>{let o=r.result;o.objectStoreNames.contains(Do)||o.createObjectStore(Do)},r.onsuccess=()=>{t(r.result)},r.onerror=()=>{n(r.error||new Error("indexedDB open failed"))}}).catch(t=>{throw this.dbPromise=null,t}),this.dbPromise)}async withStore(t,n){let r=await this.openDb();return new Promise((o,s)=>{let i=r.transaction(Do,t),c=i.objectStore(Do);n(c,o,s),i.onerror=()=>{s(i.error||new Error("indexedDB transaction failed"))}})}async read(t){try{return await this.withStore("readonly",(n,r,o)=>{let s=n.get(t);s.onsuccess=()=>{let i=s.result;r(i??null)},s.onerror=()=>{o(s.error||new Error("indexedDB read failed"))}})}catch{return null}}async write(t,n){await this.withStore("readwrite",(r,o,s)=>{let i=r.put(n,t);i.onsuccess=()=>o(),i.onerror=()=>{s(i.error||new Error("indexedDB write failed"))}}).catch(()=>{})}async remove(t){await this.withStore("readwrite",(n,r,o)=>{let s=n.delete(t);s.onsuccess=()=>r(),s.onerror=()=>{o(s.error||new Error("indexedDB delete failed"))}}).catch(()=>{})}};function ac(){let e=new Us,t=new Ps;return{readSync:n=>e.read(n),readAsync:async n=>t.read(n),write:(n,r)=>{e.write(n,r),t.write(n,r)},remove:n=>{e.remove(n),t.remove(n)}}}var Vs=1,xd="rover:runtime:",Rd="rover:runtime-id:",dc="rover:visitor-id:",Bs=160,Ws=240,fc=80,Vo=40,kd=8e3,Id=15*6e4,Sd=12,Ad=3600*24*365,Cd=1,$s=5*6e4,Gs=.18,Md=3,hn=null,Le=null,Ie=null,he=null,Te=null,lr=null,y=null,Un=null,Ne="",B=null,bt=null,dt,$o=!1,ft="controller",bn=!1,Pn=!1,Hn=null,cc=!1,Bn=null,Oo="",pc,an=new Map,Ld=new Set(["run_started","run_completed","assistant","status","tool_start","tool_result","auth_required","navigation_guardrail","error"]),Uo=[],Po=new Map;function He(e,t){let n=Po.get(e);if(n)for(let r of n)try{r(t)}catch{}}function hc(e,t){Po.has(e)||Po.set(e,new Set);let n=Po.get(e);return n.add(t),()=>{n.delete(t)}}function Nd(e){return typeof e=="string"?{name:e}:e}function mn(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Dd(e){let t=`${Rd}${e}`;try{let n=window.sessionStorage.getItem(t);if(n&&n.trim())return n.trim();let r=mn("runtime");return window.sessionStorage.setItem(t,r),r}catch{return mn("runtime")}}function Go(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 Fo(e){return String(e||"").trim().replace(/[^a-zA-Z0-9._:-]/g,"").slice(0,180)}function mc(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]||""):void 0}catch{return}}function lc(e,t,n){try{let r=n?`; domain=${n}`:"";return document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${Ad}; samesite=lax${r}`,mc(e)===t}catch{return!1}}function Od(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 r=[];for(let o=n.length-2;o>=0;o-=1)r.push(`.${n.slice(o).join(".")}`);return r}function Fd(e,t){let n=`rover_vid_${Go(e)}`;for(let r of Od(window.location.hostname))if(lc(n,t,r))return;lc(n,t)}function Ho(e,t){let n=`${dc}${e}`;try{window.localStorage.setItem(n,t)}catch{}try{window.sessionStorage.setItem(n,t)}catch{}Fd(e,t)}function gc(e){let t=Fo(e.visitorId||"");if(t)return t;if(e.checkpointing?.autoVisitorId===!1)return;let n=`${dc}${e.siteId}`,r=`rover_vid_${Go(e.siteId)}`,o=Fo(mc(r)||"");if(o)return Ho(e.siteId,o),o;try{let i=Fo(window.localStorage.getItem(n)||"");if(i)return Ho(e.siteId,i),i}catch{}try{let i=Fo(window.sessionStorage.getItem(n)||"");if(i)return Ho(e.siteId,i),i}catch{}let s=`v_${Go(`${e.siteId}:${mn("visitor")}`)}_${Date.now().toString(36)}`;return Ho(e.siteId,s),s}function Hd(e,t){return`visitor-${Go(`${e}:${t}`)}`}function bc(e){!Le||!Ie||(Le.registerTool(e.def,e.handler),Ie.postMessage({type:"register_tool",tool:e.def}))}function Ud(e){return`${xd}${e}`}function gn(e="session_start"){let t=Date.now();return{taskId:mn("task"),status:"running",startedAt:t,lastUserAt:void 0,lastAssistantAt:void 0,boundaryReason:e,endedAt:void 0}}function Ec(e,t){return{version:Vs,sessionId:e,runtimeId:t,uiOpen:!1,uiHidden:!1,uiStatus:void 0,uiMessages:[],timeline:[],executionMode:"controller",workerState:void 0,pendingRun:void 0,taskEpoch:1,activeTask:gn(),lastRoutingDecision:void 0,updatedAt:Date.now()}}function it(e,t=kd){return e.length<=t?e:`${e.slice(0,t)}\u2026`}function Bo(e){if(e!=null){if(typeof e=="string")return it(e,1200);try{return it(JSON.stringify(e),1200)}catch{try{return it(String(e),1200)}catch{return}}}}function Pd(e){if(e==="analyze"||e==="route"||e==="execute"||e==="verify"||e==="complete")return e}function Bd(e){return e?e==="analyze"?"Analyze":e==="route"?"Route":e==="execute"?"Execute":e==="verify"?"Verify":e==="complete"?"Complete":"Status":"Status"}function Wd(e,t,n){return[String(t||""),String(e||"").trim().toLowerCase(),String(n||"").trim().toLowerCase()].join("|")}function Vd(e,t){if(!e)return!0;let n=e.trim();return!!(t&&n.toLowerCase()===t.trim().toLowerCase()||/^complexity score\b/i.test(n)||/\btool loop$/i.test(n)||/^calling \w[\w\s]*(workflow|sub-agent)$/i.test(n))}function $d(){return y?.pendingRun?.id}function wc(){let e=B?.getState()?.activeRun;return!!(e&&e.runtimeId&&e.runtimeId!==Ne)}function yc(){return!wc()}function vc(e){if(e==="observer")return wc()?"Observing active run in another tab...":"Send to take control and run here."}function Gd(e){let t=typeof e?.type=="string"?e.type:"";if(!Ld.has(t))return!1;let n=typeof e?.runId=="string"&&e.runId?e.runId:void 0,r=$d();return t==="run_started"?!n||!r?!1:r!==n:n?r?r!==n:!0:!1}function qd(e){if(e&&an.has(e))return an.get(e);if(y?.uiMessages?.length)for(let t=y.uiMessages.length-1;t>=0;t-=1){let n=y.uiMessages[t];if(n.role==="assistant"&&n.text)return n.text}}function Yd(e){return Un?Un.readSync(e):null}function Xd(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 _c(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 qo(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e.slice(-t)){let o=Xd(r);o!==void 0&&n.push(o)}return n}async function zd(e){if(!Un)return null;try{return await Un.readAsync(e)}catch{return null}}function Ar(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-Bs)){let r=n?.role;r!=="user"&&r!=="assistant"&&r!=="system"||t.push({id:typeof n?.id=="string"&&n.id?n.id:mn("msg"),role:r,text:it(String(n?.text||"")),ts:Number(n?.ts)||Date.now(),sourceRuntimeId:typeof n?.sourceRuntimeId=="string"?n.sourceRuntimeId:void 0})}return t}function Cr(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-Ws)){let r=it(String(n?.title||""),400);if(!r)continue;let o=String(n?.kind||"status"),s=n?.status;t.push({id:typeof n?.id=="string"&&n.id?n.id:mn("timeline"),kind:o,title:r,detail:n?.detail?it(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 Wn(e){if(!e||typeof e!="object")return;let t=Array.isArray(e.history)?e.history:[],n=Array.isArray(e.plannerHistory)?e.plannerHistory:[],r=Array.isArray(e.agentPrevSteps)?e.agentPrevSteps:Array.isArray(e.lastToolPreviousSteps)?e.lastToolPreviousSteps:[],o=t.slice(-fc).map(c=>_c(c)).filter(c=>!!c),s=qo(n,Vo),i=qo(r,Vo*2);return{trajectoryId:typeof e.trajectoryId=="string"?e.trajectoryId:void 0,history:o,plannerHistory:s,agentPrevSteps:i,lastToolPreviousSteps:i,updatedAt:Number(e.updatedAt)||Date.now()}}function Mr(e,t,n){if(!e||typeof e!="object")return Ec(t,n);let r=gn(),o=Or(e.activeTask,r);return{version:Vs,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"?it(e.uiStatus,300):void 0,uiMessages:Ar(e.uiMessages),timeline:Cr(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:Wn(e.workerState),pendingRun:Lr(e.pendingRun),taskEpoch:Math.max(1,Number(e.taskEpoch)||1),activeTask:o,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"?it(e.lastRoutingDecision.reason,200):void 0,ts:Number(e.lastRoutingDecision.ts)||Date.now()}:void 0,updatedAt:Number(e.updatedAt)||Date.now()}}function Or(e,t){if(!e||typeof e!="object")return t;let n=typeof e.taskId=="string"&&e.taskId.trim()?e.taskId.trim():t.taskId,r=e.status==="ended"||e.status==="completed"||e.status==="running"?e.status:"running";return{taskId:n,status:r,startedAt:Number(e.startedAt)||t.startedAt,lastUserAt:Number(e.lastUserAt)||void 0,lastAssistantAt:Number(e.lastAssistantAt)||void 0,boundaryReason:typeof e.boundaryReason=="string"?it(e.boundaryReason,120):t.boundaryReason,endedAt:Number(e.endedAt)||void 0}}function jd(e,t){return Or(e,t)}function Tc(e){if(e)return{trajectoryId:e.trajectoryId,history:Array.isArray(e.history)?e.history.slice(-fc).map(t=>_c(t)).filter(t=>!!t):[],plannerHistory:qo(e.plannerHistory,Vo),agentPrevSteps:qo(e.agentPrevSteps,Vo*2),updatedAt:Number(e.updatedAt)||Date.now()}}function Lr(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 Ae(){if(!(!y||!lr))try{y.updatedAt=Date.now(),Un?.write(lr,y),$o||bt?.markDirty()}catch{}}function Kd(){if(cc)return;cc=!0;let e=()=>{y?.pendingRun?.autoResume&&B?.clearActiveRunRuntimeId(y.pendingRun.id),B?.broadcastClosing(),y?.pendingRun&&B?.releaseWorkflowLock(y.pendingRun.id),Ae(),bt?.markDirty(),bt?.syncNow(),bt?.stop(),B?.stop()};window.addEventListener("pagehide",e,{capture:!0});let t=n=>{n.persisted&&(B&&(B.reloadFromStorage(),B.registerCurrentTab(window.location.href,document.title||void 0),B.claimLease(!1)),Pn=!1)};window.addEventListener("pageshow",t)}function jo(e="implicit"){if(y)return y.activeTask||(y.activeTask=gn(e),y.taskEpoch=Math.max(1,Number(y.taskEpoch)||1)),y.activeTask}function Qd(e,t=Date.now()){if(!y)return;let n=jo("implicit");n&&(e==="user"&&(n.lastUserAt=t),e==="assistant"&&(n.lastAssistantAt=t),n.status==="ended"&&(n.status="running",n.endedAt=void 0))}function Vn(){Bn=null,he?.setTaskSuggestion({visible:!1})}function xc(){he?.clearMessages(),he?.clearTimeline(),Vn()}function Jd(){return y?y.uiMessages.filter(t=>t.role==="user").slice(-Md).map(t=>t.text.trim()).filter(Boolean):[]}function uc(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 Zd(e,t){let n=uc(e),r=uc(t);if(!n.size||!r.size)return 0;let o=0;for(let s of n)r.has(s)&&(o+=1);return o/Math.max(n.size,r.size)}function ef(e){if(!y||!Te)return{suggest:!1};if(!(Te.taskContext?.suggestReset!==!1))return{suggest:!1};if(y.pendingRun)return{suggest:!1};let n=jo("implicit");if(!n||n.status==="ended")return{suggest:!1};let r=Math.max(6e4,Number(Te.taskContext?.inactivityMs)||$s),o=Date.now(),s=Math.max(n.lastUserAt||0,n.lastAssistantAt||0,n.startedAt||0);if(!s||o-s<r)return{suggest:!1};let i=Jd();if(!i.length)return{suggest:!0,reason:"inactivity_only"};let c=i.join(" "),d=Zd(c,e),_=Math.max(.05,Math.min(.9,Number(Te.taskContext?.semanticSimilarityThreshold)||Gs));return d<_?{suggest:!0,reason:`low_similarity_${d.toFixed(2)}`}:{suggest:!1}}function Dt(e,t,n=!0,r){let o=it(String(t||""));if(!o)return;let s={id:r?.id||mn("msg"),role:e,text:o,ts:r?.ts||Date.now(),sourceRuntimeId:r?.sourceRuntimeId};return he?.addMessage(s.role,s.text),y&&n&&(y.uiMessages.push(s),y.uiMessages.length>Bs&&(y.uiMessages=y.uiMessages.slice(-Bs)),Qd(s.role,s.ts),Ae()),B&&r?.publishShared!==!1&&(B.appendMessage({id:s.id,role:s.role,text:s.text,ts:s.ts}),B.markTaskActivity(s.role,s.ts)),s}function qs(e){for(let t of e)Dt(t.role,t.text,!1,{id:t.id,ts:t.ts,sourceRuntimeId:t.sourceRuntimeId,publishShared:!1})}function je(e,t=!0){let n={id:e.id||mn("timeline"),kind:e.kind,title:it(e.title,400),detail:e.detail?it(e.detail,1200):void 0,status:e.status,ts:e.ts||Date.now(),sourceRuntimeId:e.sourceRuntimeId};return he?.addTimelineEvent(n),y&&t&&(y.timeline.push(n),y.timeline.length>Ws&&(y.timeline=y.timeline.slice(-Ws)),Ae()),B&&e.publishShared!==!1&&B.appendTimeline({id:n.id,kind:n.kind,title:n.title,detail:n.detail,status:n.status,ts:n.ts}),n}function Ys(e){he?.clearTimeline();for(let t of e)je({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 St(e,t){he?.setStatus(e),y&&(y.uiStatus=it(e,300),Ae()),B&&t?.publishShared!==!1&&B.setStatus(e)}function Nr(e,t){ft=e,y&&(y.executionMode=e,Ae()),he?.setExecutionMode(e,{controllerRuntimeId:t?.holderRuntimeId??B?.getCurrentHolderRuntimeId(),localLogicalTabId:t?.localLogicalTabId??B?.getLocalLogicalTabId(),activeLogicalTabId:t?.activeLogicalTabId??B?.getActiveLogicalTabId(),canTakeControl:!0,canComposeInObserver:yc(),note:vc(e)}),He("mode_change",{mode:e,...t})}function Ot(e){if(!y)return;y.pendingRun=e;let t=jo("implicit");t&&(e?(t.status="running",t.endedAt=void 0):t.status==="running"&&(t.status="completed")),Ae()}function Rc(e,t){let n=String(e||"").trim();if(!n||!Ie)return;if(ft==="observer"&&!(B?.requestControl()??!1)){Dt("system","Unable to take control right now because another tab is still running Rover actions.",!0),je({kind:"info",title:"Observer mode",detail:"Action execution is currently owned by another tab runtime.",status:"info"});return}let r=t?.runId||crypto.randomUUID(),o=!!t?.resume;t?.appendUserMessage!==!1&&Dt("user",n,!0);let i=y?.pendingRun?.id===r?y.pendingRun.attempts:0;Ot({id:r,text:n,startedAt:Date.now(),attempts:o?i+1:0,autoResume:t?.autoResume!==!1}),pc=n,B?.acquireWorkflowLock(r),B?.setActiveRun({runId:r,text:n}),Ie.postMessage({type:"run",text:n,runId:r,resume:o}),Hn&&clearTimeout(Hn);let c=r;Hn=setTimeout(()=>{y?.pendingRun?.id===c&&(Ot(void 0),B?.releaseWorkflowLock(c),B?.setActiveRun(void 0),St("Task timed out."),Dt("system","Task timed out after 5 minutes with no response.",!0),He("error",{message:"Run safety timeout"})),Hn=null},5*6e4)}function Wo(e,t){let n=String(e||"").trim();if(n){if(t?.startNewTask)Hr({reason:t.reason||"suggested_new_task",clearUi:!0});else if(!t?.bypassSuggestion){let r=ef(n);if(r.suggest){Bn={text:n,reason:r.reason||"heuristic",createdAt:Date.now()},he?.setTaskSuggestion({visible:!0,text:"This looks like a different request. Start a new task or continue this one?",primaryLabel:"Start new",secondaryLabel:"Continue"}),He("task_suggested_reset",{text:n,reason:Bn.reason});return}}Vn(),Rc(n,{appendUserMessage:!0,resume:!1,autoResume:!0})}}function Yo(){if(ft==="observer")return;let e=B?.getState()?.activeRun;if(e?.runtimeId&&e.runtimeId!==Ne&&!(y?.pendingRun?.id===e.runId)||!bn||!Ie||Pn||!y?.pendingRun||y.activeTask?.status==="ended")return;let t=y.pendingRun;if(!t.autoResume)return;let n=Te?.siteId||"";if(!!!sessionStorage.getItem(`rover:tab-alive:${n}`)&&!(B?.listTabs()||[]).some(c=>c.runtimeId!==Ne&&c.updatedAt>Date.now()-2*2e3)&&y?.pendingRun){Ot(void 0),St("Previous task expired.");return}if(Date.now()-t.startedAt>Id){Ot(void 0),St("Previous task expired after navigation.");return}if(t.attempts>=Sd){Ot(void 0),Dt("system","Auto-resume stopped after too many navigation attempts.",!0);return}Pn=!0,St("Resuming previous task after navigation..."),Rc(t.text,{runId:t.id,resume:!0,appendUserMessage:!1,autoResume:!0})}async function tf(e){if(!y)return;let t=await zd(e);if(!t||!y)return;let n=Number(y.updatedAt)||0,r=Mr({...t,sessionId:y.sessionId,runtimeId:Ne},y.sessionId,Ne);(Number(r.updatedAt)||0)<=n+200||(y=Mr({...y,...r,sessionId:y.sessionId,runtimeId:Ne},y.sessionId,Ne),Ae(),he&&(he.clearMessages(),qs(y.uiMessages),Ys(y.timeline),y.uiStatus&&he.setStatus(y.uiStatus),y.uiHidden?he.hide():(he.show(),y.uiOpen?he.open():he.close())),bn&&Ie&&y.workerState&&ft==="controller"&&(Ie.postMessage({type:"hydrate_state",state:y.workerState}),He("context_restored",{source:"indexeddb_checkpoint",ts:Date.now()})))}function Xs(e,t){if(y){if(t==="remote"){let n=Math.max(1,Number(y.taskEpoch)||1),r=Math.max(1,Number(e.taskEpoch)||1),o=r>n;y.taskEpoch=Math.max(n,r);let s=y.activeTask||gn("shared_sync");y.activeTask=jd(e.task,s),o&&(y.uiMessages=[],y.timeline=[],xc(),Ot(void 0),Vn());let i=Ar(e.uiMessages),c=new Set(i.map(I=>I.id));if(i.length<y.uiMessages.length||y.uiMessages.some(I=>!c.has(I.id)))y.uiMessages=i,he?.clearMessages(),qs(y.uiMessages);else{let I=new Set(y.uiMessages.map(x=>x.id));for(let x of i)I.has(x.id)||(Dt(x.role,x.text,!0,{id:x.id,ts:x.ts,sourceRuntimeId:x.sourceRuntimeId,publishShared:!1}),I.add(x.id))}let _=Cr(e.timeline),h=new Set(_.map(I=>I.id));if(_.length<y.timeline.length||y.timeline.some(I=>!h.has(I.id)))y.timeline=_,Ys(y.timeline);else{let I=new Set(y.timeline.map(x=>x.id));for(let x of _)I.has(x.id)||(je({id:x.id,kind:x.kind,title:x.title,detail:x.detail,status:x.status,ts:x.ts,sourceRuntimeId:x.sourceRuntimeId,publishShared:!1},!0),I.add(x.id))}if(typeof e.uiStatus=="string"&&St(e.uiStatus,{publishShared:!1}),e.activeRun&&e.activeRun.runtimeId!==Ne?Ot(Lr({id:e.activeRun.runId,text:e.activeRun.text,startedAt:e.activeRun.startedAt,attempts:y.pendingRun?.attempts||0,autoResume:!0})):!e.activeRun&&ft==="observer"&&Ot(void 0),ft==="observer"&&Nr("observer",{localLogicalTabId:B?.getLocalLogicalTabId(),activeLogicalTabId:B?.getActiveLogicalTabId(),holderRuntimeId:B?.getCurrentHolderRuntimeId()}),e.workerContext){let I=Wn(e.workerContext),x=Number(y.workerState?.updatedAt)||0,M=Number(I?.updatedAt)||0;I&&M>x+100&&(y.workerState=I,bn&&Ie&&ft==="controller"&&(Ie.postMessage({type:"hydrate_state",state:I}),He("context_restored",{source:"shared_session",ts:Date.now()})))}}y.uiMessages=Ar(y.uiMessages),y.timeline=Cr(y.timeline),y.workerState=Wn(y.workerState),y.activeTask=Or(y.activeTask,gn("implicit")),Ae()}}function kc(e){let t=gn("checkpoint_clone");return{version:Vs,sessionId:e.sessionId,runtimeId:e.runtimeId,uiOpen:!!e.uiOpen,uiHidden:!!e.uiHidden,uiStatus:typeof e.uiStatus=="string"?it(e.uiStatus,300):void 0,uiMessages:Ar(e.uiMessages),timeline:Cr(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:Wn(e.workerState),pendingRun:Lr(e.pendingRun),taskEpoch:Math.max(1,Number(e.taskEpoch)||1),activeTask:Or(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 nf(e){return!(e.sessionScope==="tab"||e.checkpointing?.enabled!==!0||!(e.apiKey||e.authToken)||!dt)}function rf(){if(!y||!Te||!dt)return null;let e=B?.getState(),t=kc(y),n=Math.max(Number(e?.updatedAt||0),Number(t.updatedAt||0),Date.now());return{version:Cd,siteId:Te.siteId,visitorId:dt,sessionId:y.sessionId,updatedAt:n,sharedState:e,runtimeState:t}}function of(e){if(!e||typeof e!="object"||!y||!Te||e.siteId&&e.siteId!==Te.siteId||dt&&e.visitorId&&e.visitorId!==dt)return;let t=typeof e.sessionId=="string"&&e.sessionId.trim()?e.sessionId.trim():y.sessionId;$o=!0;try{if(t&&y.sessionId!==t&&(y.sessionId=t,Te={...Te,sessionId:t},Xo(Te),Ie?.postMessage({type:"update_config",config:{sessionId:t}})),e.sharedState&&B&&B.hydrateExternalState(e.sharedState)&&(Xs(B.getState(),"remote"),Nr(B.getRole(),{localLogicalTabId:B.getLocalLogicalTabId(),activeLogicalTabId:B.getActiveLogicalTabId(),holderRuntimeId:B.getCurrentHolderRuntimeId()})),e.runtimeState&&typeof e.runtimeState=="object"){let n=Mr({...e.runtimeState,sessionId:t,runtimeId:Ne},t,Ne),r=Number(y.updatedAt)||0;(Number(n.updatedAt)||0)>r+200&&(y=Mr({...y,...n,sessionId:t,runtimeId:Ne},t,Ne),Ae(),y.uiStatus&&he?.setStatus(y.uiStatus),y.uiHidden?he?.hide():(he?.show(),y.uiOpen?he?.open():he?.close()),bn&&y.workerState&&(Ie?.postMessage({type:"hydrate_state",state:y.workerState}),He("context_restored",{source:"cloud_checkpoint",ts:Date.now()})),ft==="controller"&&Yo())}}finally{$o=!1}}function Ic(e){if(bt?.stop(),bt=null,!!nf(e)&&dt)try{bt=new No({apiBase:e.apiBase,apiKey:e.apiKey,authToken:e.authToken,siteId:e.siteId,visitorId:dt,ttlHours:e.checkpointing?.ttlHours??1,flushIntervalMs:e.checkpointing?.flushIntervalMs,pullIntervalMs:e.checkpointing?.pullIntervalMs,minFlushIntervalMs:e.checkpointing?.minFlushIntervalMs,shouldWrite:()=>ft==="controller",buildCheckpoint:()=>rf(),onCheckpoint:t=>{of(t)},onError:()=>{}}),bt.start(),bt.markDirty()}catch{bt=null}}function Xo(e){if(y){if(B?.stop(),B=null,e.sessionScope==="tab"){Nr("controller");return}B=new Mo({siteId:e.siteId,sessionId:y.sessionId,runtimeId:Ne,leaseMs:e.tabPolicy?.actionLeaseMs,onRoleChange:(t,n)=>{Nr(t,n);let r=t==="controller"&&(Te?.allowActions??!0);if(Le?.setAllowActions(r),t==="controller"){let o=B?.getWorkerContext();if(o){let s=Wn(o),i=Number(y?.workerState?.updatedAt)||0,c=Number(s?.updatedAt)||0;s&&c>i+100&&(y&&(y.workerState=s,Ae()),bn&&Ie&&(Ie.postMessage({type:"hydrate_state",state:s}),He("context_restored",{source:"controller_handoff",ts:Date.now()})))}Yo()}},onStateChange:(t,n)=>{Xs(t,n)},onSwitchRequested:t=>{t>0&&(Fr(),je({kind:"status",title:`Switched to tab #${t}`,status:"info"}))}}),B.start(),B.setRpcRequestHandler(async t=>{if(!Le)throw new Error("Bridge not available");if(t.method==="getPageData")return Le.getPageData(t.params);if(t.method==="executeTool")return Le.executeTool(t.params.call,t.params.payload);throw new Error(`Unknown RPC method: ${t.method}`)}),y?.activeTask&&B.syncTask({...y.activeTask,taskId:y.activeTask.taskId},y.taskEpoch),y?.workerState&&B.setWorkerContext(Tc(y.workerState))}}function sf(e){let t=it(qd(e)||"Done.",1200);he?.clearTimeline(),y&&(y.timeline=[]),B?.clearTimeline(),je({id:e?`run:${e}:final`:void 0,kind:"tool_result",title:"Execution completed",detail:t,status:"success"})}function af(e){if(!(!e||typeof e!="object")&&!Gd(e)){if(e.type==="assistant"){let t=String(e.text||"");if(typeof e.runId=="string"&&e.runId&&(an.set(e.runId,t),an.size>80)){let n=an.keys().next().value;n&&an.delete(n)}Dt("assistant",t,!0),je({kind:"tool_result",title:"Assistant update",detail:t,status:"success"});return}if(e.type==="status"){let t=Pd(e.stage),n=e.message?String(e.message):void 0,r=e.compactThought?String(e.compactThought):void 0,o=Wd(n,t,r);if(n&&St(n),o&&o!==Oo&&(Oo=o,n)){let s=!!(e.thought||r),i=r||(e.thought?String(e.thought):"");if(s&&t!=="analyze"&&t!=="route"&&t!=="complete"&&!Vd(i,pc))je({kind:"thought",title:i,detail:e.thought?String(e.thought):r,status:"pending"});else{let d=t?`${Bd(t)}: ${n}`:n;je({kind:"status",title:d,detail:r||(e.thought?String(e.thought):void 0),status:t==="complete"?"success":"info"})}}He("status",e);return}if(e.type==="tool_start"){je({kind:"tool_start",title:`Running ${e.call?.name||"tool"}`,detail:Bo(e.call?.args),status:"pending"}),He("tool_start",e);return}if(e.type==="tool_result"){je({kind:"tool_result",title:`${e.call?.name||"tool"} completed`,detail:Bo(e.result),status:e?.result?.success===!1?"error":"success"}),He("tool_result",e);return}if(e.type==="auth_required"){He("auth_required",e.error),e.error?.message&&(Dt("system",`Auth required: ${e.error.message}`,!0),je({kind:"error",title:"Auth required",detail:String(e.error.message),status:"error"}));return}if(e.type==="navigation_guardrail"){He("navigation_guardrail",e),je({kind:"status",title:"Navigation guardrail",detail:Bo(e),status:"info"});return}if(e.type==="error"){Dt("system",`Error: ${e.message||"unknown"}`,!0),je({kind:"error",title:"Execution error",detail:String(e.message||"unknown"),status:"error"}),He("error",e);return}if(e.type==="state_snapshot"){y&&(y.workerState=Wn({...e.state||{},updatedAt:Date.now()}),e?.activeRun?.runId&&e?.activeRun?.text&&!y.pendingRun&&(y.pendingRun=Lr({id:e.activeRun.runId,text:e.activeRun.text,startedAt:e.activeRun.startedAt,attempts:0,autoResume:!0})),e?.activeRun?.runId&&e?.activeRun?.text&&B?.setActiveRun({runId:e.activeRun.runId,text:e.activeRun.text}),y.workerState&&B?.setWorkerContext(Tc(y.workerState)),Ae());return}if(e.type==="task_started"){He("task_started",{taskId:e.taskId,reason:"worker"});return}if(e.type==="run_started"){Oo="",Vn(),typeof e.runId=="string"&&e.runId&&an.delete(e.runId);let t=y?.pendingRun;Ot(Lr({id:e.runId,text:e.text,startedAt:t?.startedAt||Date.now(),attempts:t?.attempts||0,autoResume:t?.autoResume!==!1})),B?.setActiveRun({runId:e.runId,text:String(e.text||"")}),he?.setRunning(!0);let n=`run:${String(e.runId||"")}:start`;y?.timeline.some(r=>r.id===n)||je({id:n,kind:"plan",title:e.resume?"Run resumed":"Run started",detail:String(e.text||""),status:"pending"});return}if(e.type==="run_completed"){Oo="",Pn=!1,he?.setRunning(!1),Hn&&(clearTimeout(Hn),Hn=null),y?.pendingRun?.id===e.runId&&Ot(void 0),typeof e.runId=="string"&&e.runId&&B?.releaseWorkflowLock(e.runId),y&&e?.route&&(e.route.mode==="act"||e.route.mode==="planner")&&(y.lastRoutingDecision={mode:e.route.mode,score:Number(e.route.score)||void 0,reason:typeof e.route.reason=="string"?it(e.route.reason,200):void 0,ts:Date.now()},Ae()),B?.setActiveRun(void 0),!e.ok&&e.error?(St(`Task failed: ${String(e.error)}`),an.delete(String(e.runId||"")),je({kind:"error",title:"Run failed",detail:String(e.error),status:"error"})):e.ok&&(St("Execution completed"),sf(typeof e.runId=="string"?e.runId:void 0),typeof e.runId=="string"&&e.runId&&an.delete(e.runId));return}if(e.type==="ready"){bn=!0,St("ready"),He("ready");let t=B?.getWorkerContext(),n=Wn(t),r=Number(y?.workerState?.updatedAt)||0,o=Number(n?.updatedAt)||0,s=n&&o>r+100?n:y?.workerState;y&&s&&s!==y.workerState&&(y.workerState=s,Ae()),s?(Ie?.postMessage({type:"hydrate_state",state:s}),He("context_restored",{source:"runtime_start",ts:Date.now()})):Yo();return}if(e.type==="hydrated"){Yo();return}e.type==="updated"&&He("updated")}}function cf(e){if(Xo(e),B){let s=B.getRole();ft=s,y&&(y.executionMode=s)}Ic(e);let t=(e.allowActions??!0)&&(B?B.isController():!0);Le=new Co({allowActions:t,runtimeId:Ne,allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy,crossDomainPolicy:e.crossDomainPolicy,registerOpenedTab:s=>B?.registerOpenedTab(s),switchToLogicalTab:s=>B?.switchToLogicalTab(s)||{ok:!1,reason:"No session coordinator"},listKnownTabs:()=>(B?.listTabs()||[]).map(s=>({logicalTabId:s.logicalTabId,runtimeId:s.runtimeId,url:s.url,title:s.title,external:!!s.external})),onNavigationGuardrail:s=>{He("navigation_guardrail",s),je({kind:"status",title:"Navigation guardrail",detail:Bo(s),status:"info"})},instrumentationOptions:e.mode==="safe"?{observeInlineMutations:!1}:void 0});let n=new MessageChannel;Ja(n.port1,{getSnapshot:()=>Le.getSnapshot(),getPageData:async s=>{let i=s?.tabId,c=B?.getLocalLogicalTabId();if(!i||i===c||!B)return Le.getPageData(s);let _=B.listTabs().find(h=>h.logicalTabId===i);if(!_||_.runtimeId===Ne||!_.runtimeId||!B.isTabAlive(i))return Le.getPageData(s);try{return await B.sendCrossTabRpc(_.runtimeId,"getPageData",s,15e3)}catch{return Le.getPageData(s)}},executeTool:async s=>{let i=B?.getActiveLogicalTabId(),c=B?.getLocalLogicalTabId();if(!i||i===c||!B)return Le.executeTool(s.call,s.payload);let _=B.listTabs().find(h=>h.logicalTabId===i);if(!_?.runtimeId||_.runtimeId===Ne||!B.isTabAlive(i))return Le.executeTool(s.call,s.payload);try{return await B.sendCrossTabRpc(_.runtimeId,"executeTool",s,2e4)}catch{return Le.executeTool(s.call,s.payload)}},executeClientTool:s=>Le.executeClientTool(s.name,s.args),listClientTools:()=>Le.listClientTools(),getTabContext:()=>{let s=B?.getLocalLogicalTabId(),i=B?.getActiveLogicalTabId();return{id:s||1,logicalTabId:s||1,activeLogicalTabId:i||s||1,runtimeId:Ne,mode:ft,url:window.location.href,title:document.title}},listSessionTabs:()=>B?.listTabs()||[]}),n.port1.start?.();let r=e.workerUrl?e.workerUrl:new URL("./worker/worker.js",__ROVER_SCRIPT_URL__).toString(),o=r;try{let s=window.location.origin,i=new URL(r).origin;if(s!==i){let c=new Blob([`import '${r}';`],{type:"application/javascript"});o=URL.createObjectURL(c)}}catch{}if(Ie=new Worker(o,{type:"module"}),Ie.postMessage({type:"init",config:e,port:n.port2},[n.port2]),he=rc({onSend:s=>{Wo(s)},onRequestControl:()=>{B?.requestControl()??!1?je({kind:"status",title:"Control requested",detail:"This tab is now the active Rover controller.",status:"info"}):Dt("system","Unable to acquire control right now. Try again in a moment.",!0)},onCancelRun:()=>{y?.pendingRun&&(Ie?.postMessage({type:"cancel_run",runId:y.pendingRun.id}),B?.releaseWorkflowLock(y.pendingRun.id),B?.setActiveRun(void 0),Ot(void 0),St("Task cancelled."),Dt("system","Task cancelled.",!0))},onNewTask:()=>{Hr({reason:"manual_new_task",clearUi:!0})},onEndTask:()=>{Qo({reason:"manual_end_task"})},onTaskSuggestionPrimary:()=>{let s=Bn;s&&Wo(s.text,{bypassSuggestion:!0,startNewTask:!0,reason:s.reason})},onTaskSuggestionSecondary:()=>{let s=Bn;s&&Wo(s.text,{bypassSuggestion:!0})},showTaskControls:e.ui?.showTaskControls!==!1,muted:e.ui?.muted,mascot:{disabled:e.ui?.mascot?.disabled,mp4Url:e.ui?.mascot?.mp4Url,webmUrl:e.ui?.mascot?.webmUrl},onOpen:()=>{y&&(y.uiOpen=!0,y.uiHidden=!1,Ae()),He("open")},onClose:()=>{y&&(y.uiOpen=!1,Ae()),He("close")}}),Vn(),y?.uiMessages?.length&&qs(y.uiMessages),y?.timeline?.length&&Ys(y.timeline),y?.uiStatus&&he.setStatus(y.uiStatus),y?.executionMode&&he.setExecutionMode(y.executionMode,{localLogicalTabId:B?.getLocalLogicalTabId(),activeLogicalTabId:B?.getActiveLogicalTabId(),controllerRuntimeId:B?.getCurrentHolderRuntimeId(),canTakeControl:!0,canComposeInObserver:yc(),note:vc(y.executionMode)}),Ie.onmessage=s=>{af(s.data||{})},B){let s=()=>{B?.registerCurrentTab(window.location.href,document.title),B?.broadcastNavigation(window.location.href,document.title)},i=history.pushState.bind(history),c=history.replaceState.bind(history);history.pushState=function(...d){let _=i(...d);return setTimeout(s,0),_},history.replaceState=function(...d){let _=c(...d);return setTimeout(s,0),_},window.addEventListener("popstate",s)}y?.uiHidden?he.hide():(he.show(),y?.uiOpen??!!e.openOnInit?he.open():he.close()),y&&(y.uiHidden=!!y.uiHidden,y.uiOpen=!!y.uiOpen,Ae()),B&&(Xs(B.getState(),"remote"),Nr(B.getRole(),{localLogicalTabId:B.getLocalLogicalTabId(),activeLogicalTabId:B.getActiveLogicalTabId(),holderRuntimeId:B.getCurrentHolderRuntimeId()}))}function Dr(e){if(hn)return zo(e),hn;Un=ac(),Ne=Dd(e.siteId),dt=gc(e),lr=Ud(e.siteId);let t=Yd(lr),n=e.sessionId?.trim(),r=!n&&!t?.sessionId&&e.sessionScope!=="tab"&&dt?Hd(e.siteId,dt):void 0,o=n||t?.sessionId||r||crypto.randomUUID();y=Mr(t,o,Ne),n&&y.sessionId!==n&&(y=Ec(n,Ne)),Te={...e,visitorId:dt||e.visitorId,sessionId:n||y.sessionId,taskRouting:{mode:e.taskRouting?.mode||"act",actHeuristicThreshold:e.taskRouting?.actHeuristicThreshold,plannerOnActError:e.taskRouting?.plannerOnActError},taskContext:{inactivityMs:e.taskContext?.inactivityMs??$s,suggestReset:e.taskContext?.suggestReset??!0,semanticSimilarityThreshold:e.taskContext?.semanticSimilarityThreshold??Gs}},y.sessionId=Te.sessionId,y.runtimeId=Ne,y.executionMode=y.executionMode||"controller",y.timeline=Cr(y.timeline),y.uiMessages=Ar(y.uiMessages),y.activeTask=Or(y.activeTask,gn("boot")),y.taskEpoch=Math.max(1,Number(y.taskEpoch)||1),ft=y.executionMode,Ae();try{sessionStorage.setItem(`rover:tab-alive:${e.siteId}`,"1")}catch{}if(bn=!1,Pn=!1,cf(Te),lr&&tf(lr),Kd(),hn={boot:Dr,init:zs,update:zo,shutdown:js,open:Fr,close:Ko,show:Ks,hide:Qs,send:Js,newTask:Hr,endTask:Qo,getState:Zs,registerTool:ei,on:hc},Uo.length){for(let s of Uo)bc(s);Uo.length=0}return hn}function zs(e){return Dr(e)}function zo(e){!hn||!Ie||!Te||(Te={...Te,...e,taskRouting:{...Te.taskRouting,...e.taskRouting},taskContext:{inactivityMs:e.taskContext?.inactivityMs??Te.taskContext?.inactivityMs??$s,suggestReset:e.taskContext?.suggestReset??Te.taskContext?.suggestReset??!0,semanticSimilarityThreshold:e.taskContext?.semanticSimilarityThreshold??Te.taskContext?.semanticSimilarityThreshold??Gs},ui:{...Te.ui,...e.ui,panel:{...Te.ui?.panel,...e.ui?.panel}}},dt=gc(Te),dt&&(Te.visitorId=dt),e.sessionId&&y?(y.sessionId=e.sessionId,Ae(),Xo(Te)):(e.sessionScope||e.tabPolicy)&&Xo(Te),Ic(Te),Le&&(typeof e.allowActions=="boolean"&&Le.setAllowActions(e.allowActions&&ft==="controller"),(e.allowedDomains||e.crossDomainPolicy||e.domainScopeMode||e.externalNavigationPolicy)&&Le.setNavigationPolicy({allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy,crossDomainPolicy:e.crossDomainPolicy})),Ie.postMessage({type:"update_config",config:e}),typeof e.openOnInit=="boolean"&&(e.openOnInit?Fr():Ko()))}function js(){Vn(),Ae(),bt?.markDirty(),bt?.syncNow(),bt?.stop(),bt=null,B?.stop(),B=null,Ie?.terminate(),Ie=null,he?.destroy(),he=null,Le=null,Te=null,bn=!1,Pn=!1,Ne="",dt=void 0,$o=!1,ft="controller",Bn=null,Un=null,hn=null}function Fr(){he?.show(),he?.open(),y&&(y.uiHidden=!1,y.uiOpen=!0,Ae())}function Ko(){he?.close(),y&&(y.uiOpen=!1,Ae())}function Ks(){he?.show(),y&&(y.uiHidden=!1,Ae())}function Qs(){he?.hide(),y&&(y.uiHidden=!0,y.uiOpen=!1,Ae())}function Js(e){e?.trim()&&Wo(e)}function Hr(e){if(!y)return;let t=e?.reason||"manual_new_task",n=e?.clearUi!==!1,r=Math.max(1,Number(y.taskEpoch)||1)+1,o=gn(t);y.pendingRun&&(Ie?.postMessage({type:"cancel_run",runId:y.pendingRun.id}),B?.releaseWorkflowLock(y.pendingRun.id)),Pn=!1,y.taskEpoch=r,y.activeTask=o,y.pendingRun=void 0,y.workerState=void 0,n&&(y.uiMessages=[],y.timeline=[],y.uiStatus=void 0,xc()),B?.startNewTask({taskId:o.taskId,startedAt:o.startedAt,boundaryReason:t,status:"running",lastUserAt:void 0,lastAssistantAt:void 0}),B?.setActiveRun(void 0),B?.setWorkerContext(void 0),St("New task started."),Ae(),Ie?.postMessage({type:"start_new_task",taskId:o.taskId}),je({kind:"info",title:"Started new task",detail:t,status:"info"}),He("task_started",{taskId:o.taskId,reason:t,taskEpoch:r})}function Qo(e){if(!y)return;let t=e?.reason||"manual_end_task",n=jo("manual_end_task");n&&(n.status="ended",n.endedAt=Date.now(),n.boundaryReason=t,y.pendingRun&&(Ie?.postMessage({type:"cancel_run",runId:y.pendingRun.id}),B?.releaseWorkflowLock(y.pendingRun.id)),y.pendingRun=void 0,Vn(),St("Task ended. Start a new task to continue."),B?.endTask(t),B?.setActiveRun(void 0),Ae(),je({kind:"info",title:"Task ended",detail:"Start a new task when you are ready.",status:"info"}),He("task_ended",{taskId:n.taskId,reason:t,endedAt:n.endedAt}))}function Zs(){return{mode:ft,runtimeId:Ne,runtimeState:y?kc(y):null,sharedState:B?.getState()||null,pendingTaskSuggestion:Bn}}function ei(e,t){let n=Nd(e);if(!hn||!Le||!Ie){Uo.push({def:n,handler:t});return}bc({def:n,handler:t})}function lf(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 Sc(){let e=window,t=e.rover,n=((r,...o)=>{let s=lf(r),i=s?n[s]:void 0;if(typeof i=="function")return i(...o)});if(n.boot=Dr,n.init=zs,n.update=zo,n.shutdown=js,n.open=Fr,n.close=Ko,n.show=Ks,n.hide=Qs,n.send=Js,n.newTask=Hr,n.endTask=Qo,n.getState=Zs,n.registerTool=ei,n.on=hc,e.rover=n,typeof t=="function"&&Array.isArray(t.q))for(let r of t.q){let[o,...s]=Array.isArray(r)?r:Array.from(r);typeof o=="string"&&n(o,...s)}if(!hn){let r=typeof globalThis.__ROVER_SCRIPT_EL__<"u"?globalThis.__ROVER_SCRIPT_EL__:null;if(r){let o=r.getAttribute("data-site-id"),s=r.getAttribute("data-api-key");if(o&&s){let i={siteId:o,apiKey:s},c=r.getAttribute("data-allowed-domains");c&&(i.allowedDomains=c.split(",").map(h=>h.trim()).filter(Boolean));let d=r.getAttribute("data-site-key-id");d&&(i.siteKeyId=d);let _=r.getAttribute("data-worker-url");_&&(i.workerUrl=_),Dr(i)}}}}Sc();return Oc(uf);})();
|