@rtrvr-ai/rover 1.1.1 → 1.1.2

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 CHANGED
@@ -1,5 +1,5 @@
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 $r=Object.defineProperty;var Gc=Object.getOwnPropertyDescriptor;var qc=Object.getOwnPropertyNames;var Yc=Object.prototype.hasOwnProperty;var Xc=(e,t,n)=>t in e?$r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var zc=(e,t)=>{for(var n in t)$r(e,n,{get:t[n],enumerable:!0})},Kc=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of qc(t))!Yc.call(e,o)&&o!==n&&$r(e,o,{get:()=>t[o],enumerable:!(r=Gc(t,o))||r.enumerable});return e};var jc=e=>Kc($r({},"__esModule",{value:!0}),e);var $=(e,t,n)=>Xc(e,typeof t!="symbol"?t+"":t,n);var Lf={};zc(Lf,{boot:()=>Fr,close:()=>ss,endTask:()=>is,getState:()=>ui,hide:()=>ci,init:()=>si,installGlobal:()=>$c,newTask:()=>Wr,open:()=>Br,registerTool:()=>di,send:()=>li,show:()=>ai,shutdown:()=>ii,update:()=>ns});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 Df=new Set(Object.values(L));var Qc=40;function pi(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,Qc)}var _t;(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"})(_t||(_t={}));var hi={[_t.Unknown]:"unknown",[_t.React]:"react",[_t.Vue]:"vue",[_t.Angular]:"angular",[_t.Svelte]:"svelte",[_t.JQuery]:"jquery"},as={react:_t.React,vue:_t.Vue,angular:_t.Angular,svelte:_t.Svelte,jquery:_t.JQuery},$e;(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"})($e||($e={}));var Ff={[$e.Other]:"other",[$e.Inline]:"inline",[$e.Delegated]:"delegated",[$e.React]:"react",[$e.Vue]:"vue",[$e.Angular]:"angular",[$e.Svelte]:"svelte",[$e.JQuery]:"jquery",[$e.Native]:"native"},Hf={inline:$e.Inline,delegated:$e.Delegated,react:$e.React,vue:$e.Vue,angular:$e.Angular,svelte:$e.Svelte,jquery:$e.JQuery,other:$e.Other,native:$e.Native},fe;(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"})(fe||(fe={}));var Gr={[L.click_element]:fe.click_element,[L.type_into_element]:fe.type_into_element,[L.type_and_enter]:fe.type_and_enter,[L.select_dropdown_value]:fe.select_dropdown_value,[L.clear_element]:fe.clear_element,[L.focus_element]:fe.focus_element,[L.hover_element]:fe.hover_element,[L.right_click_element]:fe.right_click_element,[L.double_click_element]:fe.double_click_element,[L.long_press_element]:fe.long_press_element,[L.drag_element]:fe.drag_element,[L.drag_and_drop]:fe.drag_and_drop,[L.swipe_element]:fe.swipe_element,[L.adjust_slider]:fe.adjust_slider,[L.describe_images]:fe.describe_images,[L.scroll_to_element]:fe.scroll_to_element,[L.paste_text]:fe.paste_text,[L.check_field_validity]:fe.check_field_validity,[L.select_text]:fe.select_text,[L.mouse_wheel]:fe.mouse_wheel,[L.copy_text]:fe.copy_text,[L.upload_file]:fe.upload_file,[L.go_back]:fe.go_back,[L.go_forward]:fe.go_forward,[L.refresh_page]:fe.refresh_page,[L.press_key]:fe.press_key,[L.scroll_page]:fe.scroll_page,[L.wait_action]:fe.wait_action,[L.wait_for_element]:fe.wait_for_element,[L.pinch_zoom]:fe.pinch_zoom,[L.goto_url]:fe.goto_url,[L.google_search]:fe.google_search,[L.open_new_tab]:fe.open_new_tab,[L.switch_tab]:fe.switch_tab,[L.close_tab]:fe.close_tab,[L.solve_captcha]:fe.solve_captcha,[L.answer_task]:fe.answer_task,[L.dispatch_pointer_path]:fe.dispatch_pointer_path,[L.network_run_recipe]:fe.network_run_recipe},mi=Object.fromEntries(Object.entries(Gr).map(([e,t])=>[t,e]));function qr(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 bi={semanticIdStart:1,interactiveIdStart:1,includeFrameContents:!0,clearIframes:!0,frameContextLabel:null,signalProvider:null,disableDomAnnotations:!1},ft={...bi},Xr=globalThis;function Ei(e){ft={...bi,...e||{}}}function In(){return ft.signalProvider??null}function Xe(){try{return typeof Xr.document<"u"?Xr.document:null}catch{return null}}function Kt(){try{return typeof Xr.window<"u"?Xr.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 oe(e,t){return G(e,t?t.document:null)?.defaultView??t??Kt()??{}}function X(e,t){return e?.defaultView??t??Kt()??{}}function zr(e,t){try{return e?.getElementById?.(t)??null}catch{return null}}function Kr(e,t){try{return e?.querySelector?.(t)??null}catch{return null}}function cs(e,t){try{return Array.from(e?.querySelectorAll?.(t)??[])}catch{return[]}}function Sn(e){try{return e.contentDocument||(e.contentWindow?.document??null)}catch{return null}}function jr(e,t){let n=e.CSS?.escape;return typeof n=="function"?n(t):t.replace(/([^\w-])/g,"\\$1")}function Tt(e,t){try{return e[t]}catch{return}}function jt(e,t){return!!e&&String(e.tagName||"").toUpperCase()===t.toUpperCase()}function wi(e,t){let n=Tt(t,"HTMLAnchorElement");return n?e instanceof n:jt(e,"A")}function Lt(e,t){let n=Tt(t,"HTMLInputElement");return n?e instanceof n:jt(e,"INPUT")}function Ft(e,t){let n=Tt(t,"HTMLTextAreaElement");return n?e instanceof n:jt(e,"TEXTAREA")}function yi(e,t){let n=Tt(t,"HTMLLabelElement");return n?e instanceof n:jt(e,"LABEL")}function _i(e,t){let n=Tt(t,"HTMLSelectElement");return n?e instanceof n:jt(e,"SELECT")}function Ti(e,t){let n=Tt(t,"HTMLSlotElement");return n?e instanceof n:jt(e,"SLOT")}function vi(e,t){let n=Tt(t,"HTMLButtonElement");return n?e instanceof n:jt(e,"BUTTON")}function xi(e,t){let n=Tt(t,"HTMLImageElement");return n?e instanceof n:jt(e,"IMG")}function Ri(e,t){let n=Tt(t,"HTMLVideoElement");return n?e instanceof n:jt(e,"VIDEO")}function ki(e,t){let n=Tt(t,"HTMLCanvasElement");return n?e instanceof n:jt(e,"CANVAS")}function Ge(e,t){if(!e||e.nodeType!==1)return!1;let n=Tt(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 An(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 pr(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 Jc(e,t){if(!e)return!1;if(e.nodeType===9)return!0;let n=Tt(t,"Document");return n?e instanceof n:!1}function Zc(e,t){if(!e)return!1;let n=Tt(t,"Window");if(n)return e instanceof n;try{return e.window===e}catch{return!1}}function Qr(e){try{return e.document}catch{return null}}function Jr(e,t){if(Jc(e,t))try{return e.documentElement}catch{return null}if(Zc(e,t)){let n=Qr(e);if(!n)return null;try{return n.documentElement}catch{return null}}return null}function Yr(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 gi(e,t,n){try{let r=G(t,n);return new URL(e,r.baseURI).href}catch{return e}}function Ii(e,t){let n=e.tagName.includes("-"),r=e.getAttribute("href")||e.getAttribute("src")||e.getAttribute("data")||e.getAttribute("action");if(r){let o=gi(r,e,t);return o.trim().toLowerCase().startsWith("javascript:")?null:o}if(n)return null;try{let o=e,s=Yr(o.href)||Yr(o.src)||Yr(o.data)||Yr(o.action);return s?gi(s,e,t):null}catch{return null}}var Si=["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"],_e={};Si.forEach((e,t)=>{_e[e]=t});var nn={};Si.forEach((e,t)=>{nn[t]=e});function Cn(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 a=s&&parseInt(s,36)||0;n.push({id:i,mask:a})}return n.length?{entries:n}:null}function el(e){let t=Cn(e);if(t){let n=new Set;for(let{id:r}of t.entries)n.add(r);return[...n]}return[]}function hr(e){return zn(e).map(n=>nn[n]).filter(n=>!!n)}function zn(e){let t=In();if(t?.getEventHandlerIds)try{let o=t.getEventHandlerIds(e);if(o&&o.length)return o}catch{}let n=e.getAttribute(pn),r=el(n);return!r||r.length===0?[]:r}var ls=["media"],Ai=new Set(ls),us=["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 Ci=new Set(us),rn=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"]),mr=new Set(["group","region","section","banner","contentinfo","main","navigation","complementary","form","article","document","presentation","none"]);var Mi=["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 Li={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"]},gr={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"}},pn="rtrvr-ls",on="rtrvr-ro",ds="rtrvr-mw-ready",br="rtrvr-mw-busy",fs="rtrvr-mwa-ready",Ni=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"]),Di=["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"],Oi=["h1","h2","h3","h4","h5","h6"],Ui="http://www.w3.org/1999/xhtml",Fi="http://www.w3.org/2000/svg",at="rtrvr-label";var to=new Set(["NOSCRIPT","SCRIPT","STYLE","META"]),Mn="CODE",Ln="PRE",Hi="aria-hidden",Pi="target";var Zr;(function(e){e[e.value=0]="value",e[e.alt=1]="alt",e[e.list=2]="list",e[e.title=3]="title"})(Zr||(Zr={}));var Kn;(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"})(Kn||(Kn={}));var eo;(function(e){e[e.VALUENOW=0]="VALUENOW",e[e.VALUETEXT=1]="VALUETEXT"})(eo||(eo={}));var ps=new Set([_e.click,_e.dblclick,_e.doubleclick,_e.contextmenu,_e.auxclick,_e.pointerdown,_e.pointerup,_e.mousedown,_e.mouseup,_e.touchstart,_e.touchend,_e.keydown,_e.keyup,_e.input,_e.beforeinput,_e.change,_e.submit,_e.reset,_e.paste,_e.dragstart,_e.dragend,_e.drop]),Bi=new Set([...ps,_e.scroll,_e.wheel,_e.mouseenter,_e.mouseover,_e.focus,_e.blur,_e.focusin,_e.focusout]),no=new Set(["click","dblclick","auxclick","contextmenu","mousedown","mouseup","pointerdown","pointerup","touchstart","touchend"]),hs=new Set(["input","change","beforeinput","keydown","keyup","keypress","paste","compositionstart","compositionend"]),ms=new Set(["drag","dragstart","dragend","dragenter","dragleave","dragover","drop"]);var Er;(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"})(Er||(Er={}));var wr;(function(e){e[e.HTML=0]="HTML",e[e.SVG=1]="SVG"})(wr||(wr={}));var ro;(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"})(ro||(ro={}));var oo;(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"})(oo||(oo={}));var bt;(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"})(bt||(bt={}));var nt;(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"})(nt||(nt={}));var sn;(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"})(sn||(sn={}));var tl=[...us,...Object.keys(gr),...ls],Wi=[...new Set(tl)],jn={};Wi.forEach((e,t)=>{jn[e]=t});var yr={};Wi.forEach((e,t)=>{yr[t]=e});var so=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 _r(e){let t=In();if(t?.getRoleHint)try{let o=t.getRoleHint(e);if(o)return o}catch{}let n=e.getAttribute(on);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=yr[o];if(s)return s}}return r}function Qn(e){return Array.from(new Set(e))}function Vi(e,t){if(!e||e.length===0)return Qn(t);let n=new Set([...e,...t]);return Qn(Array.from(n))}function xt(e,t){let r=In()?.getEventHandlerIds?.(e)??zn(e),o=r.length>0&&r.some(a=>ps.has(a)),s=io(e),i=t?mr.has(t):!1;return{element:e,semanticRole:t,eventHandlerIndices:r,isEditableRegion:s,hasNodeWorthyHandlers:o,isLikelyStructuralContainer:i}}var nl=new Set(["text","search","url","tel","password","email","number","date","datetime-local","time","month","week","color"]);function rl(e){let n=oe(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 ol(e){let t=oe(e);if(!Lt(e,t))return!1;let n=(e.type||"text").toLowerCase();return nl.has(n)?!e.disabled&&!e.readOnly:!1}function sl(e){let t=oe(e);return Ft(e,t)&&!e.disabled&&!e.readOnly}function il(e){let t=e;return!(!t.isContentEditable||t.getAttribute("aria-readonly")==="true"||t.getAttribute("aria-disabled")==="true")}function io(e){return!e||!rl(e)?!1:!!(ol(e)||sl(e)||il(e))}function Tr(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,"&#91;").replace(/\]/g,"&#93;"),t}function $i({element:e,elementID:t,frameContextLabel:n}){let r=!ft.disableDomAnnotations,o=[`[id=${t}]`],s=oe(e);if(pr(e)){let u=vr(e.id||e.getAttribute("name")||"unnamed");o.push(`[iframe=${u}]`)}if(n){let u=vr(n);o.push(`[iframeRoot=${u}]`)}if(xi(e,s)&&o.push(`[size=${e.clientWidth}x${e.clientHeight}]`),(Ri(e,s)||ki(e,s))&&o.push(`[size=${e.clientWidth}x${e.clientHeight}]`),Lt(e,s)||Ft(e,s)){let u=al(e);o.push(...u)}e.getAttribute(Hi)==="true"&&o.push("[aria-hidden=true]"),e.disabled&&o.push("[disabled]"),r&&wi(e,s)&&e.setAttribute(Pi,"_self");let a=o.join(" ");return r&&e.setAttribute(at,a),a}function al(e){let t=[],n=oe(e),r=Lt(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 xr=new so,gs=new WeakMap;function Gi(){gs=new WeakMap}function ao(e){let t=gs.get(e);if(t)return t;let n=xr.generateId();return gs.set(e,n),n}var co=new Map,bs=new WeakMap;function qi(){co.clear(),bs=new WeakMap}function Es(e,t){try{typeof WeakRef<"u"?co.set(e,new WeakRef(t)):co.set(e,t)}catch{}}function Rr(e){let t=co.get(e);if(!t)return null;let n=t instanceof WeakRef?t.deref():t;return!n||n.isConnected===!1?null:n}function hn(e){let t=null,n=ao(e);if(ft.frameContextLabel)t=ft.frameContextLabel;else{let o=Xe();if(o&&e.ownerDocument!==o)try{let i=e.ownerDocument?.defaultView?.frameElement?.getAttribute(at)||"",a=i?Tr(i):null;t=a?String(a):null}catch{t=""}}let r=$i({element:e,elementID:n,frameContextLabel:t});if(Es(n,e),r)try{bs.set(e,r)}catch{}return r}function Yi(e){return bs.get(e)??null}function ws(e,t){try{e.querySelectorAll?.(`[${at}]`)?.forEach(r=>r.removeAttribute(at))}catch{}if(t.includeShadow)try{let n=e.querySelectorAll?.("*");if(n)for(let r of Array.from(n))try{let o=r.shadowRoot;o&&ws(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=Sn(r);o?.body&&ws(o.body,t)}catch{}}catch{}}function Xi(e,t={}){if(ft.disableDomAnnotations)return;let n=An(e)?oe(e):X(e)??window,r=Jr(e,n)??e;if(r){try{r.removeAttribute?.(at)}catch{}ws(r,{includeShadow:t.includeShadow??!0,includeIframes:t.includeIframes??!0})}}var mn={},ys=new WeakMap,lo=new WeakSet;function zi(){mn={},ys=new WeakMap,lo=new WeakSet,Gi()}function ct({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,originatedFromParent:i,elementContext:a}){let u=ao(e);Es(u,e);let v=mn[u];if(i){if(!v){let p={nodeCategory:e.nodeType,provisionalFromParent:!0},_=e.nodeName;_&&_.trim()&&(p.elementName=_);let A=e.getAttribute("role");A&&(p.preservedAttributes={1:A});let S=e.tagName;S&&(p.elementTag=S),mn[u]=p}}else{if(v&&!v.provisionalFromParent){if((o||Jn(e))&&(v.isFrameElement=!0,s&&s.length>0&&(v.frameContent=s)),a){let{eventHandlerIndices:p,isEditableRegion:_}=a;if(p&&p.length>0){let A=Qn(p);A.length>0&&(v.eventHandlers=Vi(v.eventHandlers,A))}_&&(v.isEditable=!0)}return u}if(lo.has(e))return u;lo.add(e);try{mn[u]=Ki({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,elementContext:a})}finally{lo.delete(e)}}return u}function kr(e){let t=ys.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=xr.generateId(),i={textContent:r,nodeCategory:e.nodeType};return o&&o!==r&&(i.rawData=o),mn[s]=i,ys.set(e,s),s}function Qi(e,t){let n=Zi(e),{minY:r,maxY:o}=n.getCellBounds(t);return n.getRows().slice(r,o+1).some(s=>s.some(Ir))}function Ji(e,t){let n=Zi(e),{minX:r,maxX:o}=n.getCellBounds(t);return n.getRows().some(s=>s.slice(r,o+1).some(Ir))}var fo=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 a=this.getRowAt(i),u=a.indexOf(t);u!==-1&&(o=Math.max(o,a.lastIndexOf(t)),s=Math.max(s,i),n=Math.min(n,u),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 Zi(e){let n=oe(e).TableGrid||fo,r=new n;e.tHead!==null&&r.merge(uo(e.tHead.rows)),Array.from(e.tBodies).forEach(s=>{r.merge(uo(s.rows))});let o=[];for(let s of Array.from(e.children))_s(s)&&Nn(s,"tr")&&o.push(s);return r.merge(uo(o)),e.tFoot!==null&&r.merge(uo(e.tFoot.rows)),r}function uo(e){let t=new fo,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];)!Ir(t.getCellAt(o,r))&&n[o]&&t.setCellAt(o,r,n[o]),o++;for(let i=o;i<o+s.colSpan;i++){ji(s)===0&&(n[i]=s,t.setCellAt(i,r,s));for(let a=r;a<r+ji(s);a++)Ir(t.getCellAt(i,a))||t.setCellAt(i,a,s)}o+=s.colSpan}for(let s=o;s<t.columnCount;s++){let i=n[s];i!==void 0&&!Ir(t.getCellAt(s,r))&&t.setCellAt(s,r,i)}}return t}function ji(e){let t=e.getAttribute("rowSpan");if(t===null||t.trim()==="")return 1;let n=Number(t);return isNaN(n)?1:n}function Ir(e){return e!==void 0&&Nn(e,"td")}function Ht(e){let t=e.tagName?.toLowerCase();if(t==="code"||t==="pre"){let r=gl(e);if(r)return r}let n=ea(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"),a=e.hasAttribute("role");return o||s||i||a||zn(e).length>0||e.getAttribute("tabindex")!==null?"img":null}if(zn(e).length>0){let o=e.tagName.toLowerCase();if(["div","span","li","p","i","em","strong","b"].includes(o))return cl(e)}}if(t==="td"&&e.getAttribute("role")===null)return"cell";if(n!==null&&t==="th"){let r=e.getAttribute("role");if(r&&ta(r))return r;let o=e;return o.scope==="col"||o.hasAttribute("aria-sort")?"columnheader":o.scope==="row"?"rowheader":"cell"}return n}function cl(e){return _r(e)??null}function ea(e){let t=e.getAttribute("role");if(t!==null)return Mi.includes(t)||!ta(t)?null:t;let n=e.tagName.toLowerCase();return(Li[n]??[]).find(o=>ll(e,o))||null}function ll(e,t){let n=gr[t],r=n?.selector;if(r&&po(e,r))return!0;let o=n?.conditionalSelectors;return o?o.some(i=>po(e,i.selector)&&i.conditions.every(u=>dl(e,u))):!1}function ul(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let r=e.getRootNode?.();if(vt(r)){let o=oe(e),s=`#${jr(o,n)}`,i=Kr(r,s);if(i)return i}}catch{}return zr(G(e),n)}function dl(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=>ul(e,r)!=null);case me.FORBIDDEN_ANCESTORS:return an(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=an(n,t.tag);return r!==null&&ea(r)===t.role}case me.HAS_TABLE_COLUMN_DATA:{let n=an(e,"table");return n===null?!1:t.hasData===Ji(n,e)}case me.HAS_TABLE_ROW_DATA:{let n=an(e,"table");return n===null?!1:t.hasData===Qi(n,e)}default:return fl(t),!1}}function fl(e){throw new Error(`unexpected value ${e}!`)}function ta(e){return hl(e)||ml(e)||pl(e)}function pl(e){return Ai.has(e)}function hl(e){return Ci.has(e)}function ml(e){return gr.hasOwnProperty(e)}function gl(e){if(e.tagName!==Mn&&e.tagName!==Ln)return null;if(hr(e).some(r=>r==="click"||r==="copy"))return"button";let n=e.getAttribute("tabindex");return n!==null&&parseInt(n,10)>=0?"button":e.tagName===Ln||e.tagName===Mn&&e.closest("pre")?"code":null}var bl={[nt.display]:[nt.beforeDisplay,nt.afterDisplay],[nt.content]:[nt.beforeContent,nt.afterContent]},Ts=new Map,El={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 wl(e,t){if(!Ts.has(e)){let n=El[t]||t.replace(/([A-Z])/g,"-$1").toLowerCase();Ts.set(e,n)}return Ts.get(e)}var yl={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 oa(e,t,n){let r=yl[e];return r?r(t,n):t.trim()!==""&&!["initial","inherit","unset"].includes(t)}function sa(e){let t={},n=oe(e);if(!Ge(e,n))return t;let r=n.getComputedStyle(e),o=new Map([[nt.beforeDisplay,n.getComputedStyle(e,"::before")],[nt.afterDisplay,n.getComputedStyle(e,"::after")],[nt.beforeContent,n.getComputedStyle(e,"::before")],[nt.afterContent,n.getComputedStyle(e,"::after")]]);for(let s in nt)if(isNaN(Number(s))){let i=nt[s],a=wl(i,s),u=bl[i];u?((i===nt.display||i===nt.content)&&na(r,a,i,s,t,e),ra(o.get(u[0]),a,u[0],"beforeContent",t),ra(o.get(u[1]),a,u[1],"afterContent",t)):na(r,a,i,s,t,e)}return t}function na(e,t,n,r,o,s){if(e){let i=e.getPropertyValue(t);i&&oa(r,i,s)&&(o[n]=i)}}function ra(e,t,n,r,o){if(e){let s=e.getPropertyValue(t);(t==="content"&&s&&s!=="none"&&s!=='""'&&s!=="''"||s&&oa(r,s))&&(o[n]=s)}}function Dn(e,t){let n=oe(e);if(!Ge(e,n))return!0;if(t&&rn.has(t))return!1;if(e.hasAttribute("hidden")||an(e,"[hidden]")!==null||an(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 Sr(e){return Pt(e)&&e.classList.contains("jasmine_html-reporter")}function _l(e){let t=e.getAttribute("role");return t==="presentation"||t==="none"}function ia(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).map(t=>t.replace(/^#/,"")):[]}function aa(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let o=e.getRootNode?.();if(vt(o)){let s=oe(e),i=`#${jr(s,n)}`,a=Kr(o,i);if(a)return a}}catch{}let r=G(e);return zr(r,n)}function vs(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=Tl(o,s,s+8192),a=vs.apply(null,i);for(let u=0;u<a.length;u++)n.push(a[u])}else n.push(o)}return n}function Tl(e,t,n){return arguments.length<=2?Array.prototype.slice.call(e,t):Array.prototype.slice.call(e,t,n)}function ca(e,t){return vl(e,t).concat(xl(e))}function vl(e,t){return vs(Rs(e).map(r=>ma(r)&&Pt(r)?la(r,t):r))}function la(e,t){if(!e||Dn(e,t))return[];if(!_l(e))return[e];let n=Array.from(e.children);return vs(n.map(r=>la(r,t)))}function ua(e){let t=ia(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=aa(e,o);s&&s!==e&&n.push(s)}return n}function xl(e){let t=ua(e);for(let n of t)n["aria-owned-by"]=e;return t}function da(e){let t=oe(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)<=Sl(e))return!1;let o=Rl(e);return!o||!Il(o)||!Cl(e)||o.getAttribute("role")==="dialog"||e.getAttribute("role")==="dialog"?!1:Al(e)}function Rl(e){return[e.previousElementSibling,e.nextElementSibling,...Array.from(e.children),...e.parentElement?[e.parentElement.previousElementSibling,e.parentElement.nextElementSibling]:[]].filter(n=>n!==null).find(kl)||null}function kl(e){if(Dn(e))return!1;let n=oe(e).getComputedStyle(e);return(n?.position==="fixed"||n?.position==="absolute")&&n?.backgroundColor!=="rgba(0, 0, 0, 0)"&&n?.backgroundColor!=="transparent"&&n?.pointerEvents!=="none"}function Il(e){let t=oe(e),n=e.getBoundingClientRect();return n.top<=0&&n.left<=0&&n.bottom>=t.innerHeight&&n.right>=t.innerWidth}function Sl(e){let t=G(e),n=oe(e),r=n?.getComputedStyle;if(!r)return 0;let o=cs(t,"*").filter(s=>s!==e&&!Dn(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 Al(e){return e.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])').length>0}function Cl(e){let t=e.parentElement;if(!t)return!1;for(let n of Array.from(t.children))if(n!==e&&!Dn(n)&&n.getAttribute("aria-hidden")!=="true")return!1;return!0}function Ml(){try{let t=Xe()?.querySelector?.("dialog:modal");return'[aria-modal="true"], dialog:modal'}catch{return'[aria-modal="true"]'}}var fa=Ml();function Ll(e){return e.getAttribute("aria-disabled")==="true"||e.hasAttribute("disabled")}function xs(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 pa(e){return Ni.has(e)}function Nl(e){let t=e.parentElement,n=G(e);if(!(!t||t===n.body||t===n.documentElement))return ct({targetElement:t,originatedFromParent:!0})}function Ki({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,elementContext:i}){let a={nodeCategory:e.nodeType},u=t||Ll(e),v=Nl(e);if(v&&(a.parent=v),n){let Te=jn[n];typeof Te=="number"?a.semanticRole=Te:a.semanticRole=n}if(u&&(a.isDisabled=!0),i){let{eventHandlerIndices:Te,isEditableRegion:Oe}=i,He=Qn(Te);He.length>0&&(a.eventHandlers=He),Oe&&(a.isEditable=!0)}let p=Ol(e);p&&Object.keys(p).length>0&&(a.ariaProperties=p);let _=Ul(e);_&&Object.keys(_).length>0&&(a.ariaStates=_);let A=e.nodeName;A&&A.trim()&&(a.elementName=A);let S=sa(e);S&&Object.keys(S).length>0&&(a.computedStyles=S),Dn(e)&&(a.isInvisible=!0);let M=Dl(e,n);M&&Object.keys(M).length>0&&(a.preservedAttributes=M),e.draggable&&(a.isDraggable=!0),e.scrollWidth&&e.clientWidth&&e.scrollWidth>e.clientWidth&&(a.supportsHorizontalSwipe=!0),e.scrollHeight&&e.clientHeight&&e.scrollHeight>e.clientHeight&&(a.supportsVerticalSwipe=!0);let O=e.getAttribute("class");if(O?.trim()){O.includes("handle")&&(a.isDragHandle=!0),a.supportsHorizontalSwipe||(O.includes("horizontal")||O.includes("carousel"))&&(a.supportsHorizontalSwipe=!0),a.supportsVerticalSwipe||(O.includes("vertical")||O.includes("feed"))&&(a.supportsVerticalSwipe=!0),O.includes("dismissible")&&(a.supportsDismissSwipe=!0),(O.includes("long-press")||O.includes("hold")||O.includes("press-hold"))&&(a.supportsLongPress=!0);let Te=a.inputType||a.preservedAttributes?.[bt.type];Te==="submit"||Te==="reset"||Te==="clear"||(O.includes("submit")&&(a.preservedAttributes={...a.preservedAttributes||{},[bt.type]:"submit"}),O.includes("clear")&&(a.preservedAttributes={...a.preservedAttributes||{},[bt.type]:"clear"}),O.includes("reset")&&(a.preservedAttributes={...a.preservedAttributes||{},[bt.type]:"reset"}))}let W=Vl({element:e});W&&W.length>0&&(a.labelReferences=W);let q=e.tagName;if(q&&(a.elementTag=q),Hl(e)&&(a.hasFocus=!0),!o){let Te=ks({element:e,semanticRole:n,parentDisabled:u,excludeLabels:r});Te&&Te.length>0&&(a.childElements=Te)}let U=Kl({element:e});U&&U.length>0&&(a.ownedElements=U);let P=Ii(e);P&&(a.resourceLocator=P),(o||Jn(e))&&(a.isFrameElement=!0),s&&s.length>0&&(a.frameContent=s);let B=e.type;B&&typeof B=="string"&&B.trim()&&(a.inputType=B);let z=e.placeholder;z&&typeof z=="string"&&z.trim()&&(a.placeholderText=z);let te=e.value;te&&typeof te=="string"&&te.trim()&&(a.elementValue=te);let re=$l({element:e,parentDisabled:t,semanticRole:n});if(re&&re.length>0&&(a.selectedOptions=re),an(e,"select,datalist")&&(a.nearestSelectList=!0),_s(e))a.elementNamespace=wr.HTML;else if(Fl(e)){a.elementNamespace=wr.SVG,a.svgStructure=Pl(e);let Te=Bl(e);Te&&Object.keys(Te).length>0&&(a.preservedAttributes?a.preservedAttributes={...a.preservedAttributes,...Te}:a.preservedAttributes=Te)}let j=r?void 0:Gl({element:e});j&&j.length>0&&(a.associatedLabels=j);let le=e.scope;le&&typeof le=="string"&&le.trim()&&(a.tableScope=le);let ne=Yl({element:e});ne&&(a.tableCaption=ne);let de=Xl({element:e});de&&(a.figureCaption=de);let be=zl({element:e});return be&&(a.fieldsetLegend=be),an(e,"table")&&(a.nearestTable=!0),a}function Dl(e,t){let n={},r=new Set(Object.values(bt).filter(a=>typeof a=="string")),o=new Set(Object.keys(Zr).filter(a=>isNaN(Number(a)))),s=new Set(["_ngcontent","ng-reflect-*","data-v-*"]),i=e?.attributes?Array.from(e.attributes):[];for(let a of i){let u=a.name,v=a.value;if(u==="id"&&(!t||!rn.has(t)))continue;let p;if(r.has(u)?p=u:u.startsWith("data-v-")?p="data-v-*":u.startsWith("ng-reflect-")?p="ng-reflect-*":u.startsWith("_ngcontent")&&(p="_ngcontent"),p){let _=v.trim()!=="",A=o.has(p);if(_||A){let S=bt[p],M=s.has(p)?"true":v;n[S]=M}}}if(!n[bt[at]]){let a=Yi(e);a&&(n[bt[at]]=a)}return n}function Ol(e){return ha(e,ro,eo)}function Ul(e){return ha(e,oo,null)}function ha(e,t,n){let r={};for(let o in t)if(isNaN(Number(o))){let s=t[o],a=`aria-${o.toLowerCase().replace(/_/g,"-")}`,u=e.getAttribute(a),v=!1;n!==null&&(v=Object.values(n).filter(_=>typeof _=="number").includes(s)),e.hasAttribute(a)&&v||u?.trim()?r[s]=u:a==="aria-level"&&Oi.includes(e.tagName.toLowerCase()?.trim())&&(r[s]=e.tagName.substring(1))}return r}function Pt(e){return ma(e)&&e.nodeType===Er.ELEMENT}function ho(e){return e.nodeType===Er.TEXT}function ma(e){let t=typeof e;return t=="object"&&e!=null||t=="function"}function _s(e){return Pt(e)&&(!e.namespaceURI||e.namespaceURI===Ui)}function Fl(e){return Pt(e)&&e.namespaceURI===Fi}function Jn(e){return e.tagName==="IFRAME"}function Nn(e,t){return"tagName"in e?e.tagName?.toLowerCase()===t:e.elementTag?.toLowerCase()===t}function an(e,t){if(e.closest)return e.closest(t);for(;!po(e,t);){if(e.parentElement===null)return null;e=e.parentElement}return e}function po(e,t){return e.matches?.(t)??e.msMatchesSelector?.(t)??e.webkitMatchesSelector(t)}function Hl(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 Pl(e){let t={},n=sn.text,r=sn.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[sn.viewBox]=i);let a=e.querySelectorAll("path");a.length>0&&(t[sn.paths]=a.length,t[sn.pathData]=Array.from(a).slice(0,3).map(v=>v.getAttribute("d")).filter(Boolean).map(v=>v.substring(0,100)));let u={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(u).forEach(([v,p])=>{if(p>0){let _=sn[v];t[_]=p}}),Object.keys(t).length>0?t:void 0}function Bl(e){let t={};if(!e?.hasAttributes())return t;for(let n of Object.values(Kn).filter(r=>typeof r=="number")){let r=Kn[n];if(r){let o=r;if(Kn.hasOwnProperty(o)&&e.hasAttribute(o)){let s=e.getAttribute(o);s?.trim()&&(t[n]=s)}}}return t}function Wl({frameElement:e,parentDisabled:t,excludeLabels:n}){if(!ft.includeFrameContents)return[];let r=null;try{r=e.contentWindow?.document?.body||null}catch{return[]}if(!r)return[];let o=[];for(let s of Rs(r))if(!(Sr(s)||ga(s))){if(Pt(s)){let i=s,a=Ht(i),u=xt(i,a),{shouldCreate:v,shouldAnnotate:p}=mo(u);if(v){p&&hn(i);let _=ct({targetElement:i,parentDisabled:t,semanticRole:a??void 0,excludeLabels:n,elementContext:u});_&&o.push(_)}else{let _=ks({element:i,semanticRole:a??void 0,parentDisabled:t,excludeLabels:n});o.push(..._)}}else if(ho(s)){let i=kr(s);i&&o.push(i)}}return o}function Rs(e){let t=oe(e);if(Ti(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||In()?.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 ks({element:e,semanticRole:t,parentDisabled:n,excludeLabels:r}){let o=[];for(let s of Rs(e))if(!(Sr(s)||ga(s))){if(Pt(s)){let i=s,a=Ht(i),u=xt(i,a);if(Jn(i)){hn(i);let _=Wl({frameElement:i,parentDisabled:n,excludeLabels:r}),A=ct({targetElement:i,parentDisabled:n,semanticRole:a??void 0,excludeLabels:r,isFrameNode:!0,frameContentNodes:_,elementContext:u});A&&o.push(A);continue}let{shouldCreate:v,shouldAnnotate:p}=mo(u);if(v){p&&hn(i);let _=ct({targetElement:i,parentDisabled:n,semanticRole:a??void 0,excludeLabels:r,elementContext:u});_&&o.push(_)}else{let _=ks({element:i,semanticRole:a??void 0,parentDisabled:n,excludeLabels:r});o.push(..._)}}else if(ho(s)){let i=kr(s);i&&o.push(i)}}return o}function Vl({element:e}){let t=ia(e.getAttribute("aria-labelledby")),n=new Set;for(let r of t){let o=aa(e,r);if(!(!o||o===e)&&o){let s=Ht(o),i=ct({targetElement:o,semanticRole:s,elementContext:xt(o,s)});n.add(i)}}return Array.from(n)}function $l({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=>ct({targetElement:o,parentDisabled:t,semanticRole:"option",elementContext:xt(o,"option")})):Nn(e,"select")&&(r=Array.from(e.selectedOptions).map(o=>ct({targetElement:o,parentDisabled:t,semanticRole:"option",elementContext:xt(o,"option")})))),r}function Gl({element:e}){if(Di.includes(e.tagName)){let t=G(e),n=cs(t,"label"),r=new Set;return Array.from(n).filter(o=>o!==e&&ql(o,e)).map(o=>{let s=Ht(o),i=ct({targetElement:o,semanticRole:s,excludeLabels:!0,elementContext:xt(o,s)});r.add(i)}),Array.from(r)}}function ql(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 Yl({element:e}){if(Nn(e,"table")){let t=e.querySelector("caption");if(t&&t!==e){let n=Ht(t);return ct({targetElement:t,semanticRole:n,elementContext:xt(t,n)})}}}function Xl({element:e}){if(Nn(e,"figure")){let t=e.querySelector("figcaption");if(t&&t!==e){let n=Ht(t);return ct({targetElement:t,semanticRole:n,elementContext:xt(t,n)})}}}function zl({element:e}){if(Nn(e,"fieldset")){let t=e.querySelector("legend");if(t&&t!==e){let n=Ht(t);return ct({targetElement:t,semanticRole:n,elementContext:xt(t,n)})}}}function Kl({element:e}){let t=new Set,n=ua(e);for(let r of n){let o=Ht(r),s=ct({targetElement:r,semanticRole:o,elementContext:xt(r,o)});t.add(s)}return Array.from(t)}function mo(e){let{semanticRole:t,eventHandlerIndices:n,isEditableRegion:r,hasNodeWorthyHandlers:o,isLikelyStructuralContainer:s}=e,i=n.length>0&&n.some(_=>Bi.has(_)),u=!!t||!s&&(o||r),v=!!t&&rn.has(t);return{shouldCreate:u,shouldAnnotate:u&&(v||r||i)}}function ga(e){if(!Pt(e))return!1;let t=e,n=t.tagName;return to.has(n)?!0:n===Mn||n===Ln?jl(t):!1}function jl(e){let t=oe(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 Is(e,t={}){return Ei(t),zi(),qi(),Xi(e,{includeShadow:!0,includeIframes:ft.clearIframes}),xr.initialize(ft.semanticIdStart),{rootNodes:ba(e),semanticNodes:mn}}function ba(e){let t=[];try{let n=G(e),o=Array.from(n.querySelectorAll(fa)).filter(s=>!Dn(s)&&da(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(Sr(e)||Ea(e))return[];let n=Ht(e),r=xt(e,n);if(Jn(e))return[Jl({frameElement:e,role:n,parentNode:t,elementContext:r})];let o=0,{shouldCreate:s,shouldAnnotate:i}=mo(r);s&&(i&&hn(e),o=ct({targetElement:e,parentDisabled:t?.isDisabled,semanticRole:n,elementContext:r}));let a=mn[o],u=Ql(e,n,o?a:t);return o&&u.length>0&&(a.semanticChildren=u),o?[o]:u}function Ql(e,t,n){let r=[],o=ca(e,t);for(let s of o)if(!(Sr(s)||Ea(s))){if(Pt(s)){let i=Zn({targetElement:s,parentNode:n});r.push(...i)}else if(ho(s)&&eu(s,n)){let i=kr(s);i&&r.push(i)}}return r}function Jl({frameElement:e,role:t,parentNode:n,elementContext:r}){hn(e);let o=Zl(e);return ct({targetElement:e,parentDisabled:n?.isDisabled,semanticRole:t,isFrameNode:!0,frameContentNodes:o,elementContext:r})}function Zl(e){if(!ft.includeFrameContents)return[];let n=Sn(e)?.body??null;return n?ba(n):[]}function eu(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"?yr[t.semanticRole]:t.semanticRole;if(pa(r))return!1}return!0}function Ea(e){if(!Pt(e))return!1;let t=e,n=t.tagName;return to.has(n)?!0:n===Mn||n===Ln?tu(t):!1}function tu(e){let t=oe(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 bo(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t}function nu(e){let t=e.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}function tr(e,t,n){let r=G(e,t),o=X(r,n);try{e.focus?.({preventScroll:!0})}catch{}if(bo(r)===e)return!0;try{let{x:s,y:i}=nu(e),a=o.PointerEvent||PointerEvent,u=o.MouseEvent||MouseEvent;e.dispatchEvent(new a("pointerdown",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:1,button:0,pointerType:"mouse"})),e.dispatchEvent(new u("mousedown",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:1,button:0})),e.dispatchEvent(new u("mouseup",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:0,button:0})),e.dispatchEvent(new a("pointerup",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:0,button:0,pointerType:"mouse"})),(e.isContentEditable||Lt(e,o)||Ft(e,o)||e.getAttribute("contenteditable")==="true")&&e.dispatchEvent(new u("click",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,button:0}))}catch{}try{e.focus?.({preventScroll:!0})}catch{}return bo(r)===e}function Ar(e,t){let n=oe(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 Un(e,t,n="insertText"){let r=oe(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 ru(e){let n=oe(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 On(e){if(!e)return!1;let t=oe(e);if(Ft(e,t))return!e.disabled&&!e.readOnly;if(Lt(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 Ss(e){let t=oe(e);if(!e||!Ge(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 ou(e,t){let n=e.getRootNode();return vt(n)?n:G(e)??t}function su(e,t){let n=[];for(let r of t.split(/\s+/).filter(Boolean)){let o=e.getElementById?.(r)||e.querySelector?.(`#${CSS.escape(r)}`),s=oe(o);Ge(o,s)&&n.push(o)}return n}function Ta(e,t){if(!e)return{kind:"none",el:null,via:"no-root"};if(On(e))return{kind:"input",el:e,via:"self-input"};if(Ss(e))return{kind:"contenteditable",el:e,via:"self-contenteditable"};let n=G(e)??t,r=X(n),o=ou(e,n);if(yi(e,r)){let u=e.control;if(On(u))return{kind:"input",el:u,via:"label.control"};let v=e.htmlFor;if(v){let p=o.getElementById?.(v)||o.querySelector?.(`#${CSS.escape(v)}`);if(On(p))return{kind:"input",el:p,via:"label.for"}}}let s=e.getAttribute("aria-controls")||e.getAttribute("aria-owns");if(s)for(let u of su(o,s)){if(On(u))return{kind:"input",el:u,via:"aria-controls/owns"};if(Ss(u))return{kind:"contenteditable",el:u,via:"aria-controls/owns"};let v=u.querySelector?.("input,textarea");if(On(v))return{kind:"input",el:v,via:"aria-controls->desc"}}let i=e.querySelector?.("input,textarea");if(On(i))return{kind:"input",el:i,via:"descendant"};let a=e.shadowRoot||null;if(a){let u=a.querySelector?.("input,textarea");if(On(u))return{kind:"input",el:u,via:"open-shadow-input"};let v=a.querySelector?.('[contenteditable="true"],[contenteditable=""],[role="textbox"]');if(Ss(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 er(e,t,n,r=!1){let o=G(e,t),i=X(o,n).getSelection?.();if(!i)return!1;try{let a=o.createRange();return a.selectNodeContents(e),r&&a.collapse(!1),i.removeAllRanges(),i.addRange(a),!0}catch{return!1}}function Fn(e){return(e.textContent??"").replace(/\u00A0/g," ").trim()}var go=e=>String(e??"").replace(/\s+/g," ").trim(),va=new MessageChannel,xa=[];va.port1.onmessage=()=>{let e=xa.shift();e&&e()};function wa(){return new Promise(e=>{xa.push(e),va.port2.postMessage(0)})}async function ya(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 wa():await new Promise(s=>{try{t.requestAnimationFrame(()=>s())}catch{wa().then(s)}})}function iu(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 _a(e,t,n,r){let o=G(e,t),i=X(o,n).KeyboardEvent||KeyboardEvent,a=String(r??"");for(let u of a){let{code:v,which:p}=iu(u),_={key:u,code:v,bubbles:!0,cancelable:!0,composed:!0,keyCode:p,which:p};e.dispatchEvent(new i("keydown",_)),e.dispatchEvent(new i("keypress",_)),e.dispatchEvent(new i("keyup",_))}}async function Ra(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??""),a=G(e,t),u=X(a,n),v=tr(e,a,u),p=Number.isFinite(Number(o?.settleFrames))?Math.max(0,Math.min(4,Number(o?.settleFrames))):a.hidden?1:2,_=!!o?.useKeyFallback,A=Number.isFinite(Number(o?.keyFallbackMaxLen))?Number(o?.keyFallbackMaxLen):140,S=_&&s.length>0&&s.length<=A;Ar(e,s),Un(e,s,"insertReplacementText"),S&&_a(e,a,u,s),await ya(a,u,p);let M=String(e.value??""),O=go(i),W=go(M),q=go(s),U=O===q,P=W===q,B=M!==i,z=s.length>0&&!U&&M===i,te=1;if(!U&&!P&&!B){te=2;try{e.focus?.({preventScroll:!0}),e.select?.()}catch{}let ne=!1;try{a.execCommand?.("selectAll",!1,void 0),ne=!!a.execCommand?.("insertText",!1,s)}catch{ne=!1}if(!ne)try{Ar(e,s)}catch{}try{Un(e,s,"insertReplacementText")}catch{}S&&_a(e,a,u,s),await ya(a,u,p),M=String(e.value??"")}let ie=go(M)===q,j=M!==i;z=s.length>0&&!U&&M===i;let le=U||ie||j;return{success:le,method:"type-native-setter",details:`focus=${v};attempts=${te};settleFrames=${p};beforeLen=${i.length};afterLen=${M.length};changed=${j};alreadyCorrect=${U};nowCorrect=${ie};reverted=${z};keyFallback=${S}`,allowFallback:le?void 0:!0}}function au(e,t,n){let o=oe(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 ka(e,t,n,r){let o=G(e,n),s=X(o,r),i=s.InputEvent||InputEvent,a=s.Event||Event,u=String(t??""),v=Fn(e),p=tr(e,o,s),_=er(e,o,s,!0),A=au(e,u,"insertText"),S=!1,M="execCommand",O=!1,W=()=>{O=!0};try{e.addEventListener("input",W,{capture:!0})}catch{}if(A.ok&&!A.defaultPrevented)try{S=!!o.execCommand?.("insertText",!1,u)}catch{}if(!S)try{let P=s.getSelection?.(),B=P&&P.rangeCount?P.getRangeAt(0):null;if(!B||!e.contains(B.commonAncestorContainer)){er(e,o,s,!0);let z=s.getSelection?.();B=z&&z.rangeCount?z.getRangeAt(0):null}B&&(B.insertNode(o.createTextNode(u)),B.collapse(!1),P?.removeAllRanges(),P?.addRange(B),S=!0,M="range")}catch{}if(S&&!O){try{e.dispatchEvent(new i("input",{bubbles:!0,cancelable:!1,composed:!0,data:u,inputType:"insertText"}))}catch{try{e.dispatchEvent(new a("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{}}try{e.dispatchEvent(new a("change",{bubbles:!0,cancelable:!0,composed:!0}))}catch{}}try{e.removeEventListener("input",W,{capture:!0})}catch{}let q=Fn(e);return{success:q!==v||!!u&&q.includes(u),method:`type-contenteditable-${M}`,details:`focus=${p};selectedWithin=${_};inserted=${S}`}}function Ia(e){let{canceled:t}=ru(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 Sa(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=tr(e,r,o);Ar(e,""),Un(e,"","deleteByCut");let a=String(e.value??""),u=a!==s;return{success:u||a.length===0,method:"clear-native-setter",details:`focus=${i};beforeLen=${s.length};afterLen=${a.length};changed=${u}`}}function Aa(e,t,n){let r=G(e,t),o=X(r,n),s=Fn(e),i=tr(e,r,o),a=er(e,r,o,!1),u=!1,v="execCommand";try{u=!!r.execCommand?.("delete",!1,void 0)}catch{u=!1}if(!u)try{let S=o.getSelection?.(),M=S&&S.rangeCount?S.getRangeAt(0):null;(!M||!e.contains(M.commonAncestorContainer))&&er(e,r,o,!1);let O=o.getSelection?.(),W=O&&O.rangeCount?O.getRangeAt(0):null;W&&(W.deleteContents(),W.collapse(!1),O?.removeAllRanges(),O?.addRange(W),u=!0,v="range")}catch{}if(!u)try{e.textContent="",u=!0,v="textContent"}catch{}Un(e,"","deleteByCut");let p=Fn(e),_=p!==s;return{success:u||_||p.length===0,method:`clear-contenteditable-${v}`,details:`focus=${i};selectedWithin=${a};cleared=${u};changed=${_}`}}function Ca(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 Eo;(function(e){e.FLASH_LITE="Gemini Flash Lite",e.FLASH="Gemini Flash",e.PRO="Gemini Pro"})(Eo||(Eo={}));var Ma;(function(e){e[e.NativeHostConnected=0]="NativeHostConnected",e[e.NativeHostDisconnected=1]="NativeHostDisconnected"})(Ma||(Ma={}));var cu=["image/png","image/jpeg","image/webp"],lu=["application/pdf","text/plain"],Eh=[...cu,...lu];var rt;(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"})(rt||(rt={}));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 wh={[rt.ACT]:Qe.AGENTIC_SEEK,[rt.CRAWL]:Qe.CRAWL_PAGES,[rt.EXTRACT]:Qe.EXTRACT_PAGE,[rt.SHEETS_WORKFLOW]:Qe.SHEETS_WORKFLOW,[rt.INFER_SHEET_DATA]:Qe.INFER_SHEET_DATA,[rt.PDF_FILLER]:Qe.PDF_FILLER,[rt.CUSTOM_TOOL_GENERATOR]:Qe.CUSTOM_TOOL_GENERATOR,[rt.WEBPAGE_GENERATOR]:Qe.WEBPAGE_GENERATOR,[rt.GOOGLE_DOC_GENERATOR]:Qe.GOOGLE_DOC_GENERATOR,[rt.GOOGLE_SLIDES_GENERATOR]:Qe.GOOGLE_SLIDES_GENERATOR,[rt.PROCESS_TEXT]:Qe.PROCESS_TEXT,[rt.CREATE_SHEET_FROM_DATA]:Qe.CREATE_SHEET_FROM_DATA,[rt.EXECUTE_MULTIPLE_TOOLS]:Qe.EXECUTE_MULTIPLE_TOOLS,[rt.CONFIGURE_API_KEY]:Qe.CONFIGURE_API_KEY,[rt.QUERY_RTRVR_AI_DOCUMENTATION]:Qe.QUERY_RTRVR_AI_DOCUMENTATION};var As=200;var yh=Eo.FLASH;var _h=Qe.PLANNER;var Cs="application/pdf",Ms="application/gsheet";var Th=20*1024*1024;var wo={maxParallelTabs:4,pageLoadDelay:2e3,disableAutoScroll:!1,makeNewTabsActive:!1,writeRowProcessingTime:!1,totalBudgetMs:25e3,pageDataTimeoutMs:22e3,pdfTextSelectionTimeoutMs:12e3,onlyTextContent:!1};var uu=1,du=9,fu=11,Ns="application/gdoc",nr="text/html",yo="text/plain";function pu(e){return!!e&&typeof e=="object"&&e.nodeType===du}function La(e){return!!e&&typeof e=="object"&&e.nodeType===uu}function hu(e){return!!e&&typeof e=="object"&&e.nodeType===fu&&typeof e.host=="object"&&typeof e.mode=="string"}function Na(e){return La(e)&&String(e.tagName).toUpperCase()==="IFRAME"}function Ls(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 mu(e){try{let t=e.shadowRoot;return t||globalThis?.chrome?.dom?.openOrClosedShadowRoot?.(e)||null}catch{return null}}function gu(e,t,n={}){let r=n.traverseShadow!==!1,o=n.traverseIframes!==!1,s=n.requireOwnerDocument,i=[e],a=new WeakSet;for(;i.length;){let u=i.pop();if(u&&typeof u=="object"){if(a.has(u))continue;a.add(u)}if(pu(u)){let _=u.documentElement||u.body;_&&i.push(_);continue}if(hu(u)){let _=u.children;if(_&&_.length)for(let A=_.length-1;A>=0;A--)i.push(_[A]);continue}if(!La(u))continue;let v=u;if(s&&v.ownerDocument!==s)continue;let p=v.getAttribute?.(at);if(p&&Tr(p)===t)return v;if(r)try{let _=mu(v);_&&i.push(_)}catch{}if(o&&Na(v))try{let _=Sn(v);_&&i.push(_)}catch{}for(let _=v.lastElementChild;_;_=_.previousElementSibling)i.push(_)}return null}function Bt(e,t,n={}){let r=Ls(t);if(!r)return null;let o=Rr(r);return o&&(!n.requireOwnerDocument||o.ownerDocument===n.requireOwnerDocument)?o:gu(e,r,{requireOwnerDocument:n.requireOwnerDocument,traverseShadow:n.traverseShadow,traverseIframes:n.traverseIframes})}function Ds(e=document){return e.querySelector('embed[type="application/pdf"], embed[type="application/x-google-chrome-pdf"]')}function Da(e){if(e==null)return[];if(Array.isArray(e)){let t=[];for(let n of e){let r=Ls(n);r&&t.push(r)}return t}if(typeof e=="number"||typeof e=="bigint"){let t=Ls(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 Da(t)}return[]}function rr(e,t){let n=Da(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 a=n[i],u=n.length===1,v=Bt(o,a,{requireOwnerDocument:u?void 0:o,traverseShadow:!0,traverseIframes:u});if(!v||!Na(v))return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:n.slice(i)};let p=null;try{p=Sn(v)||null}catch{p=null}if(!p)return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:n.slice(i)};s.push(a),o=p}return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:[]}}function Oa(e){return e==="application/pdf"||e==="application/x-pdf"||e==="application/x-google-chrome-pdf"}function bu(){return Date.now()}function Nt(e){return!e||!Number.isFinite(e)?Number.POSITIVE_INFINITY:Math.max(0,e-bu())}async function Ua(e,t,n){if(!Number.isFinite(e)||e<=0)return;let r=Nt(n);r<=0||r<e+40||await Je(e,t)}async function or(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 a=o.defaultView||window,u=a.setTimeout?a.setTimeout.bind(a):setTimeout;await new Promise(v=>u(v,s));return}let i=Date.now();for(;Date.now()-i<s;)await n()}})();var Eu=3e4;function Fa(e){return(String(e??"").replace(/\\/g,"/").split("/").pop()||"upload").replace(/[\u0000-\u001f\u007f]/g,"").trim()||"upload"}var Os=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 wu(e){return e&&e.split(";")[0].trim()||"application/octet-stream"}function yu(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 Us(e,t){try{let r=(t??window).URL||URL,s=new r(e).pathname.match(/\/o\/(.+?)(\?|$)/);if(s?.[1]){let a=decodeURIComponent(s[1]).split("/");return a[a.length-1].replace(/^\d+-/,"")}}catch{}}function Ha(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 _u(e,t={},n,r=fetch){let o=new AbortController,s=Eu,i=!1,a=()=>{};if(n){let v=!1;a=()=>{v=!0},(async()=>{try{if(await Je(s,n),v)return;i=!0,o.abort()}catch{}})().catch(()=>{})}else{let v=setTimeout(()=>{i=!0,o.abort()},s);a=()=>clearTimeout(v)}let u=new Headers(t.headers);u.has("Accept")||u.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:u,signal:o.signal});if(!v.ok){let S=await v.text().catch(()=>"");throw new Os(`Fetch failed (${v.status})`,{url:e,status:v.status,statusText:v.statusText,bodySnippet:S.slice(0,256)})}let p=await v.arrayBuffer(),_=wu(v.headers.get("content-type")),A=yu(v.headers.get("content-disposition"))||Us(e);return{bytes:p,mimeType:_,fileName:A}}finally{a()}}async function Pa(e,t,n){return await _u(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 ot;(function(e){e.START="START",e.CENTER="CENTER",e.END="END",e.NEAREST="NEAREST"})(ot||(ot={}));function Wa(e){if(!e)return ot.CENTER;let t=typeof e=="string"?e.toUpperCase():String(e).toUpperCase();return ot&&t in ot?ot[t]:ot.CENTER}function Fs(e){return globalThis.CSS&&typeof globalThis.CSS.escape=="function"?globalThis.CSS.escape(e):e.replace(/([ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}function sr(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`#${Fs(e.id)}`;let r=[],o=e;for(;o&&o!==n.body&&o!==n.documentElement;){let s=o.tagName.toLowerCase();if(o.id){s+=`#${Fs(o.id)}`,r.unshift(s);break}let a=(o.classList&&o.classList.length?Array.from(o.classList):(o.className||"").toString().split(/\s+/).filter(Boolean)).filter(u=>u&&u.length<=48).sort((u,v)=>u.length-v.length).slice(0,3).map(Fs);if(a.length)s+="."+a.join(".");else{let u=o.parentElement;if(u){let v=Array.from(u.children).filter(p=>p.tagName===o.tagName);if(v.length>1){let p=v.indexOf(o)+1;s+=`:nth-of-type(${p})`}}}r.unshift(s),o=o.parentElement}return r.join(" > ")}function Hn(e){return e.scrollingElement||e.documentElement||e.body}function _o(e,t,n,r,o){let s=G(e,t),i=X(s,n),a=Hn(s),u=e===s.documentElement||e===s.body||e===a,v=u?a:e,p=u?i.innerHeight:v.clientHeight,_=u?i.innerWidth:v.clientWidth,A=o??p*.8;switch(r){case Fe.DOWN:{v.scrollTop+=A;break}case Fe.UP:{v.scrollTop=Math.max(0,v.scrollTop-A);break}case Fe.LEFT:return v.scrollLeft=Math.max(0,v.scrollLeft-(o??_*.8)),{success:!0,scrollLeft:v.scrollLeft};case Fe.RIGHT:return v.scrollLeft+=o??_*.8,{success:!0,scrollLeft:v.scrollLeft};default:return{success:!1,error:`Unsupported scroll direction: ${String(r)}`}}let S=v.scrollHeight,M=u?i.innerHeight:v.clientHeight,O=S-M;return{success:!0,scrollTop:v.scrollTop,isAtTop:v.scrollTop<=5,isAtBottom:v.scrollTop>=O-5}}function Tu(e,t,n){let r=G(e,t),o=X(r,n),s=Hn(r),i=e;for(;i&&i!==r.body&&i!==r.documentElement;){let u=o.getComputedStyle(i).overflowY;if((u==="auto"||u==="scroll"||u==="overlay")&&i.scrollHeight>i.clientHeight+5)return i;i=i.parentElement}return s}function Ba(e,t,n){let r=G(e,t),o=X(r,n),s=Hn(r),i=e===r.documentElement||e===r.body||e===s,a=i?s:e,u=a.scrollHeight,v=i?o.innerHeight:a.clientHeight,p=u-v;return a.scrollTop>=p-5}function Hs(e,t,n,r){let o=G(e,t),s=X(o,n),i=Hn(o),a=Tu(e,o,s),u=a===o.documentElement||a===o.body||a===i,v=u?i:a,p=e.getBoundingClientRect(),_=u?new(s.DOMRect||DOMRect)(0,0,s.innerWidth,s.innerHeight):a.getBoundingClientRect(),A=u?s.innerHeight:a.clientHeight,S=24,M=p.top-_.top,O=v.scrollTop+M,W;switch(r){case ot.START:W=O-S;break;case ot.END:W=O+p.height-A+S;break;case ot.NEAREST:{if(p.top>=_.top&&p.bottom<=_.bottom)return{success:!0,scrollTop:v.scrollTop,isAtTop:v.scrollTop<=5,isAtBottom:Ba(v,o,s)};p.top<_.top?W=O-S:W=O+p.height-A+S;break}case ot.CENTER:default:W=O-A/2+p.height/2;break}let q=v.scrollHeight-A;return v.scrollTop=Math.max(0,Math.min(W,q)),{success:!0,scrollTop:v.scrollTop,isAtTop:v.scrollTop<=5,isAtBottom:Ba(v,o,s)}}var vu=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(fs,"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(c){let y={};try{let b=mi[c.opcode];if(!b)throw new Error(`Unknown tool opcode: ${c.opcode}`);let g={...c.call,name:b};y=(await O({tabIndex:c.tabIndex,call:g,elementData:M(c.elementData),payload:c.payload}))[0]?.response??{success:!1,error:"Empty tool response",allowFallback:!0}}catch(b){y={success:!1,error:b?.message||String(b),allowFallback:!0}}return y}try{Object.defineProperty(s,"actions",{value:Object.freeze({execute:i}),writable:!1,configurable:!1,enumerable:!1})}catch{}let a="__RTRVR_UPLOAD_BYTES_REQ__",u="__RTRVR_UPLOAD_BYTES_RES__",v="__RTRVR_UPLOAD_BYTES_BRIDGE__",p="__RTRVR_WINDOW_MESSAGE_MUX__";function _(c){let y=c,b=y[p];if(!b||typeof b!="object"){b={handlers:new Set,installed:!1};try{Object.defineProperty(y,p,{value:b,enumerable:!1,configurable:!1})}catch{y[p]=b}}if(!b.installed){b.installed=!0,c.addEventListener("message",g=>{if(g.source===c)for(let f of Array.from(b.handlers))try{f(g)}catch{}},!0);try{c.addEventListener("pagehide",()=>{let f=c[v]?.pending;if(f)for(let[d,h]of f){try{h.cancelTimeout()}catch{}h.reject(new Error("pagehide: upload bytes request canceled")),f.delete(d)}},!0)}catch{}}return b}function A(c){let y=c,b=y[v];if(!b||typeof b!="object"){b={pending:new Map};try{Object.defineProperty(y,v,{value:b,enumerable:!1,configurable:!1})}catch{y[v]=b}_(c).handlers.add(f=>{let d=f?.data;if(!d||typeof d!="object"||d.type!==u)return;let h=String(d.requestId||"");if(!h)return;let x=b.pending.get(h);if(!x)return;b.pending.delete(h);try{x.cancelTimeout()}catch{}if(!d.ok){x.reject(new Error(d.error||"Failed to get bytes"));return}let m=d.bytes;if(!(m instanceof ArrayBuffer)){x.reject(new Error("Invalid bytes payload (expected ArrayBuffer)"));return}if(typeof x.expectedByteLength=="number"&&m.byteLength!==x.expectedByteLength){x.reject(new Error(`Byte length mismatch: got=${m.byteLength}, expected=${x.expectedByteLength}`));return}x.resolve(m)})}return b}function S(c,y,b,g=9e4){let f=c.__ROVER_UPLOAD_BYTES__||c.rover?.uploadBytes||c.rtrvr?.uploadBytes;if(typeof f=="function")return Promise.resolve().then(()=>f({token:y,byteLength:b,timeoutMs:g})).then(T=>{if(T instanceof ArrayBuffer)return T;if(T&&T.buffer instanceof ArrayBuffer)return T.buffer;throw new Error("Upload bytes provider returned invalid buffer")});let d=A(c),h=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(16).slice(2)}`,x=Math.max(1e3,Math.min(Number(g)||9e4,18e4)),m=Qr(c)||document;return new Promise((T,C)=>{let N=!1,F=!1,Y=()=>{F=!0};(async()=>{await Je(x,m),!(F||N)&&(d.pending.delete(h),N=!0,C(new Error("Timed out waiting for upload bytes")))})().catch(()=>{}),d.pending.set(h,{cancelTimeout:Y,expectedByteLength:b,resolve:Q=>{N||(N=!0,Y(),T(Q))},reject:Q=>{N||(N=!0,Y(),C(Q))}}),c.postMessage({type:a,requestId:h,token:y,byteLength:b},"*")})}function M(c){if(c)return{frameworks:c.frameworks?c.frameworks.map(y=>hi[y]).filter(y=>y&&y!=="unknown"):[],listenersRaw:c.listenersRaw??"",role:c.role??void 0,pattern:c.pattern??void 0,value:c.value??void 0}}async function O({tabIndex:c,call:y,elementData:b,payload:g}){let f=(()=>{try{return Kt()?.top?.document||document}catch{return document}})(),d=y.args,h,x,m;try{({doc:h,win:x,unresolvedPath:m}=rr(f,d.iframe_id))}catch{if(d.iframe_id!=null)return[{name:y.name,args:y.args,response:{success:!1,error:`Cannot access iframe ${d.iframe_id} (cross-origin or not found)`}}];h=document,x=X(h)}let T=y.name,C=d.element_id?Bt(h,d.element_id):null,N=C?.ownerDocument??null,F;if(!vu.has(T))F={success:!1,error:`Tool not promotable to main: ${T}`,allowFallback:!0};else{let Y=N??h,Q=X(Y,x);F=await q(T,C,d,b,Y,Q,g)}return[{name:y.name,args:y.args,response:F}]}async function W(c,y,b){try{let g=c.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",d=c[g]?.scroll?.execute;if(typeof d!="function")throw new Error("main-world scroll detector not available");let h=b?.doc||Qr(c)||document,x=Math.max(250,Math.min(Number(b?.timeoutMs??3500),8e3)),m=await or(Promise.resolve().then(()=>d(y)),x,h);if(!m.ok)throw new Error("scroll detector timeout");return m.value}catch(g){throw new Error(g?.message||"main-world scroll detector not available")}}async function q(c,y,b,g,f,d,h){let x=F=>({success:F.success,error:F.success?void 0:F.details||"Action failed",allowFallback:F.success?void 0:F.allowFallback??!0}),m=c===L.press_key||c===L.scroll_page||c===L.drag_and_drop||c===L.pinch_zoom;if(!y&&!m)return x({success:!1,method:"missing-element-race",details:"Target element missing",allowFallback:!0});let T=new Set([L.type_into_element,L.type_and_enter,L.clear_element,L.focus_element,L.select_text,L.check_field_validity]),C=y,N=G(C,f);if(C&&T.has(c)){let F=Ta(C,N);(F.kind==="input"||F.kind==="contenteditable")&&(C=F.el)}try{switch(c){case L.click_element:return x(z(y,f,d,g));case L.double_click_element:return x(Ut(y,f,d));case L.right_click_element:return x(he(y,f,d));case L.hover_element:return x(await ht(y,f,d,g,b.duration));case L.type_into_element:return x(await st(C,f,d,b.text,g));case L.type_and_enter:return x(await yt(C,f,d,b.text,g));case L.clear_element:return x(await It(C,f,d,g));case L.focus_element:return x(it(C,f,d));case L.select_dropdown_value:return x(ke(y,f,d,b.value,g));case L.adjust_slider:return x(Le(y,f,d,g?.value??b.value,g));case L.check_field_validity:return x(Vt(C,f,d));case L.select_text:return x(mt(C,f,d,b.start_offset,b.end_offset));case L.scroll_page:return x(await $t(y,f,d,b));case L.scroll_to_element:return x(await ln(y,f,d,b));case L.mouse_wheel:return x(et(y,f,d,b.delta_x,b.delta_y));case L.drag_element:return x(await Ne(y,f,d,b,g));case L.drag_and_drop:return x(await un(b,y,f,d));case L.swipe_element:return x(await dn(y,f,d,b));case L.long_press_element:return x(await yn(y,f,d,b.duration));case L.pinch_zoom:return x(await Pe(y,f,d,b));case L.press_key:return x(Gt(b.key,b.modifiers,y,f,d));case L.copy_text:return x(await Jt(y,f,d));case L.paste_text:return x(await fn(y,f,d,g));case L.upload_file:return x(await Ot(b,f,d,h,y,g));case L.dispatch_pointer_path:return x(await ut(b,f,d));default:return x({success:!1,method:"unhandled",details:`Unhandled ${c}`,allowFallback:!0})}}catch(F){return x({success:!1,method:"exception",details:F?.message||"exception",allowFallback:!0})}}function U(c){let y=new Map;if(!c)return y;let b=c.trim();if(!b)return y;let g=Cn(b);if(g){for(let{id:f,mask:d}of g.entries){let h=nn[f];if(!h)continue;let x=new Set(qr(d)),m=y.get(h);if(m)for(let T of x)m.add(T);else y.set(h,x)}return y}return y}function P(c,...y){return c?y.some(b=>c.has(b)):!1}function B(c,y){let b=U(y?.listenersRaw),g=new Set;for(let[,T]of b)for(let C of T)(C==="react"||C==="vue"||C==="angular"||C==="svelte"||C==="jquery")&&g.add(C);let f=new Set;for(let[T,C]of b)if(["click","input","change","keydown","keyup","pointerdown","pointerup","mousedown","mouseup","submit","dragstart","drop","wheel","scroll"].includes(T))for(let N of C)f.add(N);let d=g.size>0||[...f].some(T=>["react","vue","angular","svelte","jquery"].includes(T)),h=P(b.get("click"),"delegated"),x=P(b.get("input"),"delegated")||P(b.get("change"),"delegated")||P(b.get("keydown"),"delegated"),m=y?.role||_r(c)||c.getAttribute("role");return{sourcesByType:b,fws:g,isFrameworkElement:d,delegatedClick:h,delegatedInput:x,role:m}}function z(c,y,b,g){let f=B(c,g),d=G(c,y),h=X(d,b);Ve(c,d,h),g?.pattern==="hover-activate"&&ht(c,d,h,g,120);let x=f.fws.has("react")||P(f.sourcesByType.get("click"),"react"),m=f.fws.has("vue")||P(f.sourcesByType.get("click"),"vue"),T=f.fws.has("angular")||P(f.sourcesByType.get("click"),"angular"),C=f.fws.has("svelte")||P(f.sourcesByType.get("click"),"svelte"),N=f.fws.has("jquery")||P(f.sourcesByType.get("click"),"jquery");return vn(()=>te(c,d,h),()=>re(c,d,h),()=>x?j(c,d,h):null,()=>m?le(c,d,h):null,()=>T?ne(c,d,h):null,()=>C?de(c,d,h):null,()=>N?be(c,d,h):null)}function te(c,y,b){let g=G(c,y),f=X(g,b),d=f.PointerEvent||PointerEvent,h=f.MouseEvent||MouseEvent,{x,y:m}=ie(c,g,f),T={bubbles:!0,cancelable:!0,composed:!0,view:f,clientX:x,clientY:m,button:0,buttons:1};return c.focus?.({preventScroll:!0}),[new d("pointerover",T),new d("pointerenter",{...T,bubbles:!1}),new h("mouseover",T),new h("mouseenter",{...T,bubbles:!1}),new d("pointerdown",T),new h("mousedown",T),new d("pointerup",{...T,buttons:0}),new h("mouseup",{...T,buttons:0}),new h("click",{...T,buttons:0})].forEach(N=>c.dispatchEvent(N)),{success:!0,method:"pointer-mouse-click"}}function re(c,y,b){let g=G(c,y),f=X(g,b);try{if(c instanceof HTMLAnchorElement){let d=c.getAttribute("target");try{c.setAttribute("target","_self"),c.click()}finally{d===null?c.removeAttribute("target"):c.setAttribute("target",d)}}else c.click?.();return{success:!0,method:"native-click"}}catch{return{success:!1,method:"native-click"}}}function ie(c,y,b){let g=G(c,y),f=c.getBoundingClientRect(),d=[{x:f.left+f.width/2,y:f.top+f.height/2},{x:f.left+4,y:f.top+4},{x:f.right-4,y:f.top+4},{x:f.left+4,y:f.bottom-4},{x:f.right-4,y:f.bottom-4}],h=null;for(let x=0;x<d.length;x++){let m=d[x],T=g.elementFromPoint(m.x,m.y);if(x===0&&(h=T),T&&Ca(c,T))return{...m,hit:T,ok:!0}}return{...d[0],hit:h,ok:!1}}function j(c,y,b){let g=G(c,y),f=X(g,b);try{let d=tn(c);if(!d)return{success:!1,method:"react-no-fiber"};let h=Yt(d),x=h.onClick||h.onClickCapture;return x?(x(Xt("click",c,g,f)),{success:!0,method:"react-fiber-onClick"}):{success:!1,method:"react-no-onClick"}}catch{return{success:!1,method:"react-fiber-onClick"}}}function le(c,y,b){let g=G(c,y),d=X(g,b).MouseEvent||MouseEvent;try{let h=Rn(c);if(!h)return{success:!1,method:"vue-none"};let x=Mt(h);return x.click?(x.click(new d("click",{bubbles:!0})),{success:!0,method:"vue-handler"}):h.$emit?(h.$emit("click"),{success:!0,method:"vue-emit"}):{success:!1,method:"vue-no-click"}}catch{return{success:!1,method:"vue-handler"}}}function ne(c,y,b){let g=G(c,y),f=X(g,b),d=f.MouseEvent||MouseEvent;try{let h=f.ng?.getZone?.()||null;return h?.run?(h.run(()=>c.dispatchEvent(new d("click",{bubbles:!0,cancelable:!0}))),{success:!0,method:"angular-zone-click"}):(c.dispatchEvent(new d("click",{bubbles:!0,cancelable:!0})),c.click?.(),{success:!0,method:"angular-click"})}catch{return{success:!1,method:"angular-click",allowFallback:!0}}}function de(c,y,b){let g=G(c,y),d=X(g,b).MouseEvent||MouseEvent;try{let h=c.getBoundingClientRect(),x={bubbles:!0,cancelable:!0,view:c.ownerDocument?.defaultView||window,clientX:h.left+h.width/2,clientY:h.top+h.height/2};return c.dispatchEvent(new d("mousedown",x)),c.dispatchEvent(new d("mouseup",x)),c.dispatchEvent(new d("click",x)),{success:!0,method:"svelte-click"}}catch{return{success:!1,method:"svelte-click"}}}function be(c,y,b){let g=G(c,y),f=X(g,b);try{return f.jQuery?.(c)?.trigger?.("click"),{success:!0,method:"jquery-trigger"}}catch{return{success:!1,method:"jquery-trigger"}}}async function ht(c,y,b,g,f=500){let d=Math.min(Math.max(0,Number(f)||500),3e4),h=G(c,y),x=X(h,b),m=B(c,g);Ve(c,h,x);let T=x.PointerEvent||PointerEvent,C=x.MouseEvent||MouseEvent,N=c.getBoundingClientRect(),F=N.left+N.width/2,Y=N.top+N.height/2;if(m.fws.has("react")){let J=tn(c),ee=J?Yt(J):{};ee.onMouseEnter?.(Xt("mouseenter",c,h,x)),ee.onPointerEnter?.(Xt("pointerenter",c,h,x))}else if(m.fws.has("vue")){let J=Rn(c),ee=J?Mt(J):{};ee.mouseenter?.(new C("mouseenter",{bubbles:!0})),ee.mouseover?.(new C("mouseover",{bubbles:!0}))}let Q={bubbles:!0,cancelable:!0,composed:!0,view:x,clientX:F,clientY:Y};return[new T("pointerover",Q),new T("pointerenter",{...Q,bubbles:!1}),new C("mouseover",Q),new C("mouseenter",{...Q,bubbles:!1})].forEach(J=>c.dispatchEvent(J)),await Je(d,h),{success:!0,method:"hover-seq"}}async function Te(c,y,b=1){await Promise.resolve();for(let g=0;g<b;g++)c.hidden?await Ct():await new Promise(f=>{try{y.requestAnimationFrame(()=>f())}catch{Ct().then(f)}})}let Oe=c=>String(c??"").replace(/\s+/g," ").trim();function He(c){try{if("value"in c)return String(c.value??"")}catch{}return""}function Me(c){try{return typeof Fn=="function"?Fn(c):Oe(c.textContent)}catch{return""}}function Ze(c,y){if(!(y.isFrameworkElement||y.delegatedInput))return!1;let b=String(c??"").length;return b>0&&b<=140}async function st(c,y,b,g,f){let d=B(c,f),h=G(c,y),x=X(h,b);if(Ve(c,h,x),Lt(c,x)||Ft(c,x)){let T=Ze(String(g??""),d),C=await Ra(c,h,x,g,{settleFrames:h.hidden?1:2,useKeyFallback:T,keyFallbackMaxLen:140});return{success:C.success,method:C.method,details:C.details,allowFallback:!C.success}}if(c.isContentEditable===!0||d.role==="textbox"&&!("value"in c)){let T=Me(c),C=ka(c,g,h,x);await Te(h,x,h.hidden?1:2);let N=Me(c),F=!1;if(String(g??"").length>0&&N===T){F=!0;try{tr(c,h,x),er(c,h,x,!0);try{h.execCommand?.("insertText",!1,String(g??""))}catch{}Un(c,String(g??""),"insertText")}catch{}await Te(h,x,h.hidden?1:2)}let Y=Me(c),Q=Y!==T||!!String(g??"")&&Y.includes(String(g??""));return{success:Q,method:C.method,details:`${C.details};beforeLen=${T.length};afterLen=${Y.length};reverted=${N===T};fallback=${F}`,allowFallback:Q?void 0:!0}}return{success:!1,method:"type",details:"target not editable",allowFallback:!0}}async function yt(c,y,b,g,f){let d=G(c,y),h=X(d,b),x=await st(c,d,h,g,f);if(!x.success)return x;let m=Ia(c);return{success:!0,method:"type+enter",details:`${x.details};enter=${m.method}`}}async function It(c,y,b,g){let f=G(c,y),d=X(f,b),h=d.Event||Event;if(Ve(c,f,d),Lt(c,d)||Ft(c,d)){let m=He(c),T=Sa(c,f,d);if(await Te(f,d,f.hidden?1:2),He(c)===m&&m.length>0){try{Ar(c,""),Un(c,"","deleteByCut")}catch{}await Te(f,d,f.hidden?1:2)}let F=He(c),Y=F.length===0||F!==m;return{success:T.success,method:T.method,details:T.details,allowFallback:!T.success}}if(c.isContentEditable===!0||B(c,g).role==="textbox"&&!("value"in c)){let m=Aa(c,f,d);return await Te(f,d,f.hidden?1:2),{success:m.success,method:m.method,details:m.details,allowFallback:!m.success}}if("value"in c){try{c.value=""}catch{}return c.dispatchEvent(new h("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new h("change",{bubbles:!0,composed:!0})),{success:!0,method:"clear-generic-value"}}return{success:!1,method:"clear",details:"target not clearable",allowFallback:!0}}function it(c,y,b){try{let g=G(c,y),f=X(g,b),d=f.FocusEvent||FocusEvent;return Ve(c,g,f),c.focus?.({preventScroll:!0}),c.dispatchEvent(new d("focus",{bubbles:!0})),c.dispatchEvent(new d("focusin",{bubbles:!0})),{success:!0,method:"focus"}}catch(g){return{success:!1,method:"focus",details:g.message,allowFallback:!0}}}function ke(c,y,b,g,f){try{let d=G(c,y),h=X(d,b),x=h.Event||Event;if(!_i(c,h))return{success:!1,method:"select",details:"target not select",allowFallback:!0};Ve(c,d,h),c.focus?.({preventScroll:!0});let m=Array.from(c.options).find(F=>F.value===g||F.text.trim()===g.trim());if(!m)return{success:!1,method:"select",details:`Option not found: ${g}`,allowFallback:!0};m.selected=!0;let T=Object.getPrototypeOf(c),C=Object.getOwnPropertyDescriptor(T,"value");if(C?.set?C.set.call(c,m.value):c.value=m.value,c.dispatchEvent(new x("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new x("change",{bubbles:!0,composed:!0})),B(c,f).fws.has("react")){let F=tn(c);if(F){let Y=Yt(F);if(Y.onChange){let Q=Xt("change",c,d,h);Q.target.value=m.value,Y.onChange(Q)}}}return{success:!0,method:"select"}}catch(d){return{success:!1,method:"select",details:d.message,allowFallback:!0}}}function Le(c,y,b,g,f){try{let d=G(c,y),h=X(d,b),x=h.Event||Event;if(!Lt(c,h))return{success:!1,method:"slider",details:"target not input",allowFallback:!0};Ve(c,d,h),c.focus?.({preventScroll:!0});let m=Object.getPrototypeOf(c),T=Object.getOwnPropertyDescriptor(m,"value");if(T?.set?T.set.call(c,String(g)):c.value=String(g),c.dispatchEvent(new x("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new x("change",{bubbles:!0,composed:!0})),B(c,f).fws.has("react")){let N=tn(c);if(N){let F=Yt(N);if(F.onChange){let Y=Xt("change",c,d,h);Y.target.value=String(g),F.onChange(Y)}}}return{success:!0,method:"slider"}}catch(d){return{success:!1,method:"slider",details:d.message,allowFallback:!0}}}function Vt(c,y,b){try{let g=c.checkValidity?.()??!0;return g||c.reportValidity?.(),{success:g,method:"check-validity",details:g?void 0:c.validationMessage}}catch(g){return{success:!1,method:"check-validity",details:g.message,allowFallback:!0}}}function mt(c,y,b,g,f){try{let d=G(c,y),h=X(d,b);if("setSelectionRange"in c){let T=c;T.focus?.();let C=T.value?.length??0;return T.setSelectionRange(g??0,f??C),{success:!0,method:"select-range"}}let x=h.getSelection();if(!x)return{success:!1,method:"select-range",allowFallback:!0};let m=d.createRange();return m.selectNodeContents(c),x.removeAllRanges(),x.addRange(m),{success:!0,method:"select-range-node"}}catch(d){return{success:!1,method:"select-range",details:d.message,allowFallback:!0}}}function gt(c,y,b,g,f){let d=Hn((c&&G(c))??y),h=c||d,x=G(h,y),m=X(x,b),T=h===x.documentElement||h===x.body||h===d;if(g===Fe.TOP||g===Fe.BOTTOM){let C=h.scrollHeight,N=T?m.innerHeight:h.clientHeight,F=Math.max(0,C-N);return h.scrollTop=g===Fe.TOP?0:F,{success:!0,scrollTop:h.scrollTop}}return _o(h,x,m,g,f)}async function $t(c,y,b,g){let f=g.direction,d=g.amount,h=G(c,y),x=X(h,b),m=!h.hidden,T=m?"smooth":"auto";try{if(c){let N=St(c,h,x),F=gt(N,h,x,f,d);return F?.success?{success:!0,method:"direct-element-scroll",details:JSON.stringify(F)}:{success:!1,method:"direct-element-scroll",details:F?.error||"direct scroll failed",allowFallback:!0}}if(f===Fe.TOP||f===Fe.BOTTOM){let N=await W(x,{action:"scrollTo",direction:f,options:{behavior:T,isTabActive:m}},{doc:h,timeoutMs:h.hidden?5200:2800});return{success:!0,method:"detector-scrollTo",details:JSON.stringify(N)}}let C=await W(x,{action:"scrollBy",direction:f,options:{amount:d,behavior:T,isTabActive:m}},{doc:h,timeoutMs:h.hidden?5200:2800});return{success:!0,method:"detector-scrollBy",details:JSON.stringify(C)}}catch(C){let N=h?gt(Hn(h),h,x,f,d):void 0;return N?.success?{success:!0,method:"direct-primary-scroll-fallback",details:JSON.stringify(N)}:{success:!1,method:"scroll-page-failed",details:C?.message||N?.error||"scroll_page failed",allowFallback:!0}}}async function ln(c,y,b,g){let f=G(c,y),d=X(f,b),h=!f.hidden,x=h?"smooth":"auto",m=Wa(g.position),T=sr(c,f);if(!T){let C=Hs(c,f,d,m);return{success:C.success,method:"direct-scrollElement-no-selector",details:C.error,allowFallback:!C.success}}try{let C=await W(d,{action:"scrollElement",selector:T,position:m,options:{behavior:x,isTabActive:h}},{doc:f,timeoutMs:f.hidden?5600:3e3});return{success:!0,method:"detector-scrollElement",details:JSON.stringify(C)}}catch(C){let N=Hs(c,f,d,m);return N.success?{success:!0,method:"direct-scrollElement-fallback",details:JSON.stringify(N)}:{success:!1,method:"scroll-to-element-failed",details:C?.message||N.error||"scroll_to_element failed",allowFallback:!0}}}function et(c,y,b,g,f){try{let d=G(c,y),h=X(d,b),x=h.WheelEvent||WheelEvent;Ve(c,d,h);let m=St(c,d,h);return m.dispatchEvent(new x("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:h,deltaX:g||0,deltaY:f||0,deltaMode:x.DOM_DELTA_PIXEL})),m.scrollBy({left:g||0,top:f||0,behavior:"auto"}),{success:!0,method:"wheel"}}catch(d){return{success:!1,method:"wheel",details:d.message,allowFallback:!0}}}function St(c,y,b){let g=G(c,y),f=X(g,b),d=g.scrollingElement||g.documentElement||g.body,h=c;for(;h&&h!==g.body&&h!==g.documentElement;){let m=f.getComputedStyle(h).overflowY;if((m==="auto"||m==="scroll"||m==="overlay")&&h.scrollHeight>h.clientHeight+5)return h;h=h.parentElement}return d}async function Ne(c,y,b,g,f){try{let d=G(c,y),h=X(d,b),x=h.PointerEvent||PointerEvent,m=h.MouseEvent||MouseEvent,T=h.DragEvent||DragEvent,C=h.DataTransfer||DataTransfer;Ve(c,d,h);let N=ie(c,d,h),F=Ge(N.hit,h)?N.hit:c,Y=c.getBoundingClientRect(),Q=Number.isFinite(Number(g?.distance))?Number(g.distance):160,pe=0,J=0;switch(String(g?.direction||"").toUpperCase()){case"UP":J=-Q;break;case"DOWN":J=Q;break;case"LEFT":pe=-Q;break;case"RIGHT":pe=Q;break;default:pe=Number(g?.delta_x)||0,J=Number(g?.delta_y)||0}let ee=(I,D)=>({x:Math.max(2,Math.min(I,h.innerWidth-3)),y:Math.max(2,Math.min(D,h.innerHeight-3))}),se=ee(N.x,N.y),we=ee(N.x+pe,N.y+J),Be=500+Date.now()%1e4,ue=Math.max(12,Math.min(36,Number(g?.steps)||18)),Ee=(I,D)=>({bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:I,clientY:D,pageX:I+(h.scrollX||0),pageY:D+(h.scrollY||0)}),ye=(I,D,V)=>({...Ee(I,D),pointerId:Be,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:V?.5:0,buttons:V,button:0}),l=(I,D,V)=>({...Ee(I,D),buttons:V,button:0});F.dispatchEvent(new x("pointerdown",ye(se.x,se.y,1))),F.dispatchEvent(new m("mousedown",l(se.x,se.y,1)));try{F.setPointerCapture?.(Be)}catch{}let E=null;try{(c.draggable||B(c,f).sourcesByType.has("dragstart"))&&(E=new C)}catch{E=null}if(E)try{c.dispatchEvent(new T("dragstart",{bubbles:!0,cancelable:!0,clientX:se.x,clientY:se.y,dataTransfer:E}))}catch{}let k=null;for(let I=1;I<=ue;I++){let D=se.x+(we.x-se.x)*I/ue,V=se.y+(we.y-se.y)*I/ue,K=d.elementFromPoint(D,V)||c;if(K.dispatchEvent(new x("pointermove",ye(D,V,1))),K.dispatchEvent(new m("mousemove",l(D,V,1))),E)try{k&&k!==K&&k.dispatchEvent(new T("dragleave",{bubbles:!0,cancelable:!0,clientX:D,clientY:V,dataTransfer:E})),K.dispatchEvent(new T("dragover",{bubbles:!0,cancelable:!0,clientX:D,clientY:V,dataTransfer:E})),k=K}catch{}I%3===0&&await Ct()}let R=d.elementFromPoint(we.x,we.y)||c;if(R.dispatchEvent(new x("pointerup",ye(we.x,we.y,0))),R.dispatchEvent(new m("mouseup",l(we.x,we.y,0))),E)try{c.dispatchEvent(new T("dragend",{bubbles:!0,cancelable:!0,clientX:we.x,clientY:we.y,dataTransfer:E}))}catch{}return{success:!0,method:"drag",details:`dx=${pe};dy=${J};steps=${ue};hitOk=${N.ok}`}}catch(d){return{success:!1,method:"drag",details:d?.message||"drag failed",allowFallback:!0}}}async function un(c,y,b,g){try{let f=G(y,b),d=X(f,g),h=d.PointerEvent||PointerEvent,x=d.MouseEvent||MouseEvent,m=d.DragEvent||DragEvent,T=d.DataTransfer||DataTransfer,C=c?.source_element_id??c?.element_id,N=(C?Bt(f,String(C)):null)||y;if(!N)return{success:!1,method:"drag-drop",details:"source missing",allowFallback:!0};let F=null,Y=Number(c?.target_x),Q=Number(c?.target_y);if(c?.target_element_id){if(F=Bt(f,String(c.target_element_id)),!F)return{success:!1,method:"drag-drop",details:"target missing",allowFallback:!0};let R=F.getBoundingClientRect();Y=R.left+R.width/2,Q=R.top+R.height/2}if((!Number.isFinite(Y)||!Number.isFinite(Q))&&!F)return{success:!1,method:"drag-drop",details:"missing target coords",allowFallback:!0};Ve(N,f,d),F&&Ve(F,f,d);let pe=(R,I)=>({x:Math.max(2,Math.min(R,d.innerWidth-3)),y:Math.max(2,Math.min(I,d.innerHeight-3))}),J=N.getBoundingClientRect(),ee=pe(J.left+J.width/2,J.top+J.height/2),se=pe(Number(Y),Number(Q)),we=600+Date.now()%1e4,Be=Math.max(14,Math.min(42,Number(c?.steps)||22)),ue=(R,I)=>({bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:R,clientY:I,pageX:R+(d.scrollX||0),pageY:I+(d.scrollY||0)}),Ee=(R,I,D)=>({...ue(R,I),pointerId:we,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:D?.5:0,buttons:D,button:0}),ye=(R,I,D)=>({...ue(R,I),buttons:D,button:0}),l=null;try{l=new T}catch{l=null}N.dispatchEvent(new h("pointerdown",Ee(ee.x,ee.y,1))),N.dispatchEvent(new x("mousedown",ye(ee.x,ee.y,1)));try{N.setPointerCapture?.(we)}catch{}if(l)try{N.dispatchEvent(new m("dragstart",{bubbles:!0,cancelable:!0,clientX:ee.x,clientY:ee.y,dataTransfer:l}))}catch{}let E=null;for(let R=1;R<=Be;R++){let I=ee.x+(se.x-ee.x)*R/Be,D=ee.y+(se.y-ee.y)*R/Be,V=f.elementFromPoint(I,D)||F||f.body;if(V.dispatchEvent(new h("pointermove",Ee(I,D,1))),V.dispatchEvent(new x("mousemove",ye(I,D,1))),l)try{E&&E!==V&&E.dispatchEvent(new m("dragleave",{bubbles:!0,cancelable:!0,clientX:I,clientY:D,dataTransfer:l})),V.dispatchEvent(new m("dragenter",{bubbles:!0,cancelable:!0,clientX:I,clientY:D,dataTransfer:l})),V.dispatchEvent(new m("dragover",{bubbles:!0,cancelable:!0,clientX:I,clientY:D,dataTransfer:l})),E=V}catch{}R%3===0&&await Ct()}let k=F||f.elementFromPoint(se.x,se.y)||f.body;if(l)try{k.dispatchEvent(new m("drop",{bubbles:!0,cancelable:!0,clientX:se.x,clientY:se.y,dataTransfer:l}))}catch{}if(k.dispatchEvent(new h("pointerup",Ee(se.x,se.y,0))),k.dispatchEvent(new x("mouseup",ye(se.x,se.y,0))),l)try{N.dispatchEvent(new m("dragend",{bubbles:!0,cancelable:!0,clientX:se.x,clientY:se.y,dataTransfer:l}))}catch{}return{success:!0,method:"html5+pointer-dragdrop",details:`steps=${Be};source=${String(C)}`}}catch(f){return{success:!1,method:"drag-drop",details:f?.message||"drag-drop failed",allowFallback:!0}}}async function dn(c,y,b,g){try{let f=G(c,y),d=X(f,b),h=d.PointerEvent||PointerEvent,x=d.MouseEvent||MouseEvent;Ve(c,f,d);let m=ie(c,f,d),T={x:m.x,y:m.y},C=c.getBoundingClientRect(),N=Number.isFinite(Number(g?.distance))?Number(g.distance):Math.min(Math.max(80,Math.min(C.width,C.height)),220),F=String(g?.direction||"RIGHT").toUpperCase(),Y=T.x,Q=T.y;F==="LEFT"&&(Y-=N),F==="RIGHT"&&(Y+=N),F==="UP"&&(Q-=N),F==="DOWN"&&(Q+=N);let pe=(I,D)=>({x:Math.max(2,Math.min(I,d.innerWidth-3)),y:Math.max(2,Math.min(D,d.innerHeight-3))}),J=pe(T.x,T.y),ee=pe(Y,Q),se=700+Date.now()%1e4,we=Math.max(10,Math.min(28,Number(g?.steps)||16)),Be=(I,D)=>({bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:I,clientY:D,pageX:I+(d.scrollX||0),pageY:D+(d.scrollY||0)}),ue=(I,D,V)=>({...Be(I,D),pointerId:se,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:V?.5:0,buttons:V,button:0}),Ee=(I,D,V)=>({...Be(I,D),buttons:V,button:0}),ye=f.elementFromPoint(J.x,J.y)||c;ye.dispatchEvent(new h("pointerdown",ue(J.x,J.y,1))),ye.dispatchEvent(new x("mousedown",Ee(J.x,J.y,1)));let l=d.Touch,E=d.TouchEvent,k=!!l&&!!E;if(k)try{let I=new l({identifier:se,target:ye,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});ye.dispatchEvent(new E("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[I],targetTouches:[I],changedTouches:[I]}))}catch{}for(let I=1;I<=we;I++){let D=J.x+(ee.x-J.x)*I/we,V=J.y+(ee.y-J.y)*I/we,K=f.elementFromPoint(D,V)||c;if(K.dispatchEvent(new h("pointermove",ue(D,V,1))),K.dispatchEvent(new x("mousemove",Ee(D,V,1))),k)try{let ae=new l({identifier:se,target:K,clientX:D,clientY:V,pageX:D,pageY:V,screenX:D,screenY:V,radiusX:1,radiusY:1,rotationAngle:0,force:1});K.dispatchEvent(new E("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[ae],targetTouches:[ae],changedTouches:[ae]}))}catch{}I%3===0&&await Ct()}let R=f.elementFromPoint(ee.x,ee.y)||c;if(R.dispatchEvent(new h("pointerup",ue(ee.x,ee.y,0))),R.dispatchEvent(new x("mouseup",Ee(ee.x,ee.y,0))),k)try{let I=new l({identifier:se,target:R,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:0});R.dispatchEvent(new E("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[I]}))}catch{}return{success:!0,method:"swipe",details:`dir=${F};dist=${N};steps=${we};hitOk=${m.ok}`}}catch(f){return{success:!1,method:"swipe",details:f?.message||"swipe failed",allowFallback:!0}}}async function Pe(c,y,b,g){try{let f=c||y.body,d=G(f,y),h=X(d,b),x=h.PointerEvent||PointerEvent,m=h.WheelEvent||WheelEvent;Ve(f,d,h);let T=Number.isFinite(Number(g?.scale))?Number(g.scale):1.2,C=f.getBoundingClientRect(),N=C.left+C.width/2,F=C.top+C.height/2,Y=24,Q=Math.max(6,Math.min(200,Y*T)),pe=Math.max(6,Math.min(18,Number(g?.steps)||10)),J=h.Touch,ee=h.TouchEvent;if(!!J&&!!ee)try{let ue=(k,R)=>new J({identifier:k,target:f,clientX:R,clientY:F,pageX:R,pageY:F,screenX:R,screenY:F,radiusX:1,radiusY:1,rotationAngle:0,force:1}),Ee=ue(911,N-Y),ye=ue(912,N+Y);f.dispatchEvent(new ee("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[Ee,ye],targetTouches:[Ee,ye],changedTouches:[Ee,ye]}));for(let k=1;k<=pe;k++){let R=Y+(Q-Y)*k/pe,I=ue(911,N-R),D=ue(912,N+R);f.dispatchEvent(new ee("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[I,D],targetTouches:[I,D],changedTouches:[I,D]})),k%2===0&&await Ct()}let l=ue(911,N-Q),E=ue(912,N+Q);f.dispatchEvent(new ee("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[l,E]}))}catch{}try{let ue=(Ee,ye,l)=>({bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:ye,clientY:F,pointerId:Ee,pointerType:"touch",isPrimary:Ee===821,width:1,height:1,pressure:l?.5:0,buttons:l,button:0});f.dispatchEvent(new x("pointerdown",ue(821,N-Y,1))),f.dispatchEvent(new x("pointerdown",ue(822,N+Y,1)));for(let Ee=1;Ee<=pe;Ee++){let ye=Y+(Q-Y)*Ee/pe;f.dispatchEvent(new x("pointermove",ue(821,N-ye,1))),f.dispatchEvent(new x("pointermove",ue(822,N+ye,1))),Ee%2===0&&await Ct()}f.dispatchEvent(new x("pointerup",ue(821,N-Q,0))),f.dispatchEvent(new x("pointerup",ue(822,N+Q,0)))}catch{}try{let we=T>=1?-120:120;f.dispatchEvent(new m("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:N,clientY:F,ctrlKey:!0,deltaY:we,deltaMode:m.DOM_DELTA_PIXEL}))}catch{}return{success:!0,method:"pinch-zoom",details:`scale=${T};steps=${pe}`}}catch(f){return{success:!1,method:"pinch-zoom",details:f?.message||"pinch-zoom failed",allowFallback:!0}}}async function yn(c,y,b,g=800){try{let f=G(c,y),d=X(f,b),h=d.PointerEvent||PointerEvent,x=d.MouseEvent||MouseEvent,m=d.FocusEvent||FocusEvent;Ve(c,f,d);let T=ie(c,f,d),C=c;!T.ok&&Ge(T.hit,d)?C=T.hit.closest?.('a,button,input,select,textarea,summary,[role="button"],[role="link"],[onclick]')||T.hit:Ge(T.hit,d)&&(C=T.hit);let N=Zt(C,f,d),F=T.x,Y=T.y,Q=1+Date.now()%1e4,pe={bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:F,clientY:Y,pageX:F+(d.scrollX||0),pageY:Y+(d.scrollY||0),screenX:F+(d.screenX||0),screenY:Y+(d.screenY||0)},J={...pe,pointerId:Q,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:0,buttons:0,button:0};try{C.dispatchEvent(new h("pointerover",J)),C.dispatchEvent(new h("pointerenter",{...J,bubbles:!1}))}catch{}try{C.dispatchEvent(new x("mouseover",pe)),C.dispatchEvent(new x("mouseenter",{...pe,bubbles:!1}))}catch{}try{C.focus?.({preventScroll:!0}),C.dispatchEvent(new m("focus",{bubbles:!0,composed:!0})),C.dispatchEvent(new m("focusin",{bubbles:!0,composed:!0}))}catch{}try{C.dispatchEvent(new h("pointerdown",{...J,buttons:1,pressure:.5}))}catch{}try{C.dispatchEvent(new x("mousedown",{...pe,buttons:1,button:0}))}catch{}try{let ue=d.Touch,Ee=d.TouchEvent;if(typeof ue<"u"&&typeof Ee<"u"){let ye=new ue({identifier:Q,target:C,clientX:F,clientY:Y,pageX:F+(d.scrollX||0),pageY:Y+(d.scrollY||0),screenX:F+(d.screenX||0),screenY:Y+(d.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:1});C.dispatchEvent(new Ee("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[ye],targetTouches:[ye],changedTouches:[ye]}))}}catch{}let ee=Number(g),se=Number.isFinite(ee)&&ee>0?ee:800,we=f.hidden?Math.max(se,1200):se;await Je(we,f);try{C.dispatchEvent(new x("contextmenu",{...pe,button:2,buttons:2}))}catch{}try{C.dispatchEvent(new h("pointerup",{...J,buttons:0,pressure:0}))}catch{}try{C.dispatchEvent(new x("mouseup",{...pe,buttons:0,button:0}))}catch{}try{let ue=d.Touch,Ee=d.TouchEvent;if(typeof ue<"u"&&typeof Ee<"u"){let ye=new ue({identifier:Q,target:C,clientX:F,clientY:Y,pageX:F+(d.scrollX||0),pageY:Y+(d.scrollY||0),screenX:F+(d.screenX||0),screenY:Y+(d.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:0});C.dispatchEvent(new Ee("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[ye]}))}}catch{}let Be=await Ue(C,f,d,N);return{success:!0,method:"long-press",details:`holdMs=${we};verified=${Be};hitOk=${T.ok};target=${C.tagName.toLowerCase()}`}}catch(f){return{success:!1,method:"long-press",details:f?.message||"long-press failed",allowFallback:!0}}}function Gt(c,y,b,g,f){try{let d=G(b,g),x=X(d,f).KeyboardEvent||KeyboardEvent,m=b||d.activeElement||d.body||d.documentElement;m.focus?.();let T={key:c,code:en(c),bubbles:!0,cancelable:!0,ctrlKey:y?.includes("CTRL"),altKey:y?.includes("ALT"),shiftKey:y?.includes("SHIFT"),metaKey:y?.includes("META")},C=m.dispatchEvent(new x("keydown",T)),N=m.dispatchEvent(new x("keypress",T)),F=m.dispatchEvent(new x("keyup",T));if(c==="Enter"&&!!(C&&N&&F)){let Q=m.form||m.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 Jt(c,y,b){try{let g=c.innerText||c.value||"";if(!g)return{success:!1,method:"copy",details:"nothing to copy",allowFallback:!0};let f=G(c,y),d=X(f,b);if(d.navigator?.clipboard?.writeText)return await d.navigator.clipboard.writeText(g),{success:!0,method:"clipboard-copy"};let h=f.createRange();h.selectNodeContents(c);let x=d.getSelection?.()||(f.defaultView||window).getSelection?.();x?.removeAllRanges(),x?.addRange(h);let m=f.execCommand?.("copy")??!1;return x?.removeAllRanges(),{success:!!m,method:"execCommand-copy",allowFallback:!m}}catch(g){return{success:!1,method:"clipboard-copy",details:g.message,allowFallback:!0}}}async function fn(c,y,b,g){try{c.focus?.();let f=G(c,y),d=X(f,b);if(d.navigator?.clipboard?.readText){let x=await d.navigator.clipboard.readText();if(x)return await st(c,f,d,x,g)}return f.execCommand?.("paste")??!1?{success:!0,method:"execCommand-paste"}:{success:!1,method:"paste",details:"clipboard empty or denied",allowFallback:!0}}catch(f){return{success:!1,method:"paste",details:f.message,allowFallback:!0}}}function _n(c){return`${(c/1024).toFixed(1)}KB`}function Tn(c,y){if(c instanceof y.defaultView.HTMLInputElement){let h=c;if((h.type||"").toLowerCase()==="file")return h}let b=c.closest?.("label"),g=b?.htmlFor||c.htmlFor||"";if(g){let h=y.getElementById(g);if(h&&(h.type||"").toLowerCase()==="file")return h}if(b){let h=b.querySelector?.('input[type="file"]');if(h)return h}let f=c.closest?.("form");if(f){let h=f.querySelector?.('input[type="file"]');if(h)return h}let d=c.closest?.("div,section,main,article")||c.parentElement;if(d){let h=d.querySelector?.('input[type="file"]');if(h)return h}return null}function At(c,y,b){try{let g=b.HTMLInputElement?.prototype,f=g?Object.getOwnPropertyDescriptor(g,"files")?.set:void 0;if(!f){let d=Object.getPrototypeOf(c);for(;d&&!f;)f=Object.getOwnPropertyDescriptor(d,"files")?.set,d=Object.getPrototypeOf(d)}return f?(f.call(c,y),!0):(c.files=y,!0)}catch{try{return c.files=y,!0}catch{return!1}}}async function Ot(c,y,b,g,f,d){try{let{file_url:h,element_id:x,file_name:m}=c,T=null;if(f&&(T=Tn(f,y)),!T&&x!==void 0&&(T=y.querySelector(`input[type="file"][${at}*="[id=${x}]"]`)),!T){let R=y.querySelectorAll('input[type="file"]');for(let I of R){if(I.disabled)continue;let D=I.getBoundingClientRect();if(D.width>0&&D.height>0){T=I;break}}}if(!T)return{success:!1,method:"upload-file",details:"No file input found",allowFallback:!0};if(T.disabled)return{success:!1,method:"upload-file",details:"File input is disabled",allowFallback:!0};let C=G(T,y),N=X(C,b);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),Q=(g.mimeType||"application/octet-stream").split(";")[0].trim()||"application/octet-stream",pe;if(g.inlineB64&&typeof g.inlineB64=="string"){let R=Ha(g.inlineB64);if(R.byteLength!==Y)return{success:!1,method:"upload-file",details:`Inline bytes length mismatch: got=${R.byteLength} expected=${Y}`,allowFallback:!0};pe=R.buffer}else{let R=String(g.token);pe=await S(N,R,Y,9e4)}let J=N.Blob||Blob,ee=new J([pe],{type:Q}),se=m||g?.fileName;!se&&h&&typeof h=="string"&&(se=Us(h,N)),se=Fa(se||"upload");let we=N.File||File,Be=new we([ee],se,{type:Q,lastModified:Date.now()}),ue=N.Event||Event,Ee=N.DataTransfer||DataTransfer;if(!Ee)return{success:!1,method:"upload-file",details:"DataTransfer unavailable in this context",allowFallback:!0};let ye=new Ee;if(ye.items.add(Be),!At(T,ye.files,N))return{success:!1,method:"upload-file",details:"Failed to set input.files",allowFallback:!0};T.dispatchEvent(new ue("input",{bubbles:!0,composed:!0,cancelable:!0})),T.dispatchEvent(new ue("change",{bubbles:!0,composed:!0,cancelable:!0}));let E=tn(T);if(E){let R=Yt(E);if(R.onChange){let I=Xt("change",T,C,N);I.target.files=ye.files,R.onChange(I)}}let k=Rn(T);if(k){let R=Mt(k);if(R.change){let I=new ue("change",{bubbles:!0});I.target=T,I.target.files=ye.files,R.change(I)}}try{let R=N.jQuery||N.$;R&&typeof R=="function"&&R(T).triggerHandler?.("change")}catch{}return T.focus?.({preventScroll:!0}),await Te(C,N,2),{success:!0,method:"upload-file",details:`Uploaded ${se} (${_n(ee.size)}) [token]`}}catch(h){return{success:!1,method:"upload-file",details:h?.message||"Upload failed",allowFallback:!0}}}async function ut(c,y,b){let g=Array.isArray(c.path)?c.path:[];if(!g.length)return{success:!1,method:"dispatch_pointer_path",details:"Empty path",allowFallback:!0};let f=b.PointerEvent||PointerEvent,d=b.MouseEvent||MouseEvent,h=16;for(let x=0;x<g.length;x++){let m=g[x],T=Number(m.x)||0,C=Number(m.y)||0,N=Number(m.pressure)||(x===0||x===g.length-1?0:.5),F=y.elementFromPoint(T,C)||y.documentElement,Y={bubbles:!0,cancelable:!0,clientX:T,clientY:C,screenX:T,screenY:C,view:b};if(x===0?(F.dispatchEvent(new f("pointerdown",{...Y,pressure:N,pointerId:1,pointerType:"mouse"})),F.dispatchEvent(new d("mousedown",{...Y,button:0,buttons:1}))):(F.dispatchEvent(new f("pointermove",{...Y,pressure:N,pointerId:1,pointerType:"mouse"})),F.dispatchEvent(new d("mousemove",{...Y,button:0,buttons:1}))),x===g.length-1&&(F.dispatchEvent(new f("pointerup",{...Y,pressure:0,pointerId:1,pointerType:"mouse"})),F.dispatchEvent(new d("mouseup",{...Y,button:0,buttons:0}))),x<g.length-1){let Q=Number(m.timestamp)||0,pe=Number(g[x+1].timestamp)||0,J=Q&&pe?Math.max(0,Math.min(pe-Q,1e3)):h;J>0&&await Je(J,y)}}return{success:!0,method:"dispatch_pointer_path",details:`Dispatched ${g.length} point(s)`}}function Ut(c,y,b){let g=G(c,y),f=X(g,b),d=f.MouseEvent||MouseEvent;Ve(c,g,f),te(c,g,f),te(c,g,f);let h=c.getBoundingClientRect();return c.dispatchEvent(new d("dblclick",{bubbles:!0,cancelable:!0,clientX:h.left+h.width/2,clientY:h.top+h.height/2,detail:2,view:f})),{success:!0,method:"dblclick"}}function he(c,y,b){let g=G(c,y),f=X(g,b),d=f.PointerEvent||PointerEvent,h=f.MouseEvent||MouseEvent;Ve(c,g,f);let x=c.getBoundingClientRect(),m=x.left+x.width/2,T=x.top+x.height/2,C={bubbles:!0,cancelable:!0,composed:!0,view:f,clientX:m,clientY:T,button:2,buttons:2};return c.dispatchEvent(new d("pointerdown",C)),c.dispatchEvent(new h("mousedown",C)),c.dispatchEvent(new d("pointerup",{...C,buttons:0})),c.dispatchEvent(new h("mouseup",{...C,buttons:0})),c.dispatchEvent(new h("contextmenu",C)),{success:!0,method:"contextmenu"}}function Zt(c,y,b){let g=G(c,y),f=X(g,b),d=c,h=c.getBoundingClientRect();return{href:String(f.location.href),hash:String(f.location.hash),ariaExpanded:c.getAttribute("aria-expanded"),ariaPressed:c.getAttribute("aria-pressed"),ariaDisabled:c.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:bo(g),rect:{w:h.width,h:h.height}}}function qt(c,y){let b=Math.abs(c.rect.w-y.rect.w)>2||Math.abs(c.rect.h-y.rect.h)>2;return c.href!==y.href||c.hash!==y.hash||c.ariaExpanded!==y.ariaExpanded||c.ariaPressed!==y.ariaPressed||c.ariaDisabled!==y.ariaDisabled||c.disabled!==y.disabled||c.open!==y.open||c.checked!==y.checked||c.value!==y.value||c.active!==y.active||b}async function Ue(c,y,b,g){await Promise.resolve();let f=G(c,y),d=X(f,b);y.hidden||await Ct();let h=Zt(c,f,d);return qt(g,h)}function tt(c,y,b){c.focus?.({preventScroll:!0});let g=G(c,y),f=X(g,b),x=c.getAttribute("role")==="button"||vi(c,f)||c.tagName.toLowerCase()==="button"?[" ","Enter"]:["Enter"],m=f.KeyboardEvent||KeyboardEvent;for(let T of x){let C={key:T,code:T===" "?"Space":"Enter",bubbles:!0,cancelable:!0,composed:!0};c.dispatchEvent(new m("keydown",C)),c.dispatchEvent(new m("keypress",C)),c.dispatchEvent(new m("keyup",C))}return{success:!0,method:"keyboard-activate"}}async function Vr(c,y,b,...g){let f=null;for(let d of g){let h=G(c,y),x=X(h,b),m=Zt(c,h,x),T=d();if(!T||!T.success)continue;if(await Ue(c,h,x,m))return{...T,details:(T.details?T.details+";":"")+"verified=true"};f=T}return f?{...f,details:(f.details?f.details+";":"")+"verified=false"}:{success:!1,method:"all-strategies-unverified",details:"no verified effect",allowFallback:!0}}function vn(...c){for(let y of c)try{let b=y();if(b&&b.success)return b}catch{}return{success:!1,method:"all-strategies-failed",allowFallback:!0}}function Ve(c,y,b){let g=G(c,y),f=X(g,b),d=c.getBoundingClientRect();d.top>=0&&d.left>=0&&d.bottom<=f.innerHeight&&d.right<=f.innerWidth||(c.scrollIntoView({behavior:"auto",block:"center",inline:"center"}),c.offsetHeight)}function xn(c,y,b,g){let f=G(c,y),h=X(f,b).KeyboardEvent||KeyboardEvent;for(let x of g){let m=String(x??""),T="";/^[a-z]$/i.test(m)?T=`Key${m.toUpperCase()}`:/^[0-9]$/.test(m)?T=`Digit${m}`:m===" "&&(T="Space");let C=m.length===1?m.charCodeAt(0):0,N={key:m,code:T,bubbles:!0,cancelable:!0,composed:!0,keyCode:C,which:C};c.dispatchEvent(new h("keydown",N)),c.dispatchEvent(new h("keypress",N)),c.dispatchEvent(new h("keyup",N))}}function Gn(c,y,b){let g=G(c,y),d=X(g,b).KeyboardEvent||KeyboardEvent,h={key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0,composed:!0},x=c.dispatchEvent(new d("keydown",h)),m=c.dispatchEvent(new d("keypress",h)),T=c.dispatchEvent(new d("keyup",h));if(!!(x&&m&&T)){let N=c.form||c.closest?.("form");N?.requestSubmit?.()??N?.submit?.()}}function en(c){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"}[c]||`Key${c.toUpperCase()}`}let qn=new MessageChannel,Yn=[];qn.port1.onmessage=()=>{let c=Yn.shift();c&&c()};function Ct(){return new Promise(c=>{Yn.push(c),qn.port2.postMessage(0)})}function tn(c){let y=g=>{if(!g)return null;let f=Object.keys(g);for(let d of f)if(d.startsWith("__reactFiber")||d.startsWith("__reactInternalInstance")||d.includes("reactFiber")||d.includes("reactProps")||d.includes("reactEventHandlers")||/^__r\d+/.test(d))return g[d];return null},b=c;for(let g=0;g<4&&b;g++){let f=y(b);if(f)return f;b=b.parentElement}return null}function Yt(c){let y={},b=c,g=0;for(;b&&g++<10;){let f=[b.memoizedProps,b.pendingProps,b.stateNode?.props,b._memoizedProps,b._pendingProps,b.alternate?.memoizedProps].filter(Boolean);for(let d of f)if(!(!d||typeof d!="object"))for(let h in d)h.startsWith("on")&&typeof d[h]=="function"&&(y[h]=d[h]);if(Object.keys(y).length)break;b=b.return||b.alternate}return y}function fr(c,y){let b=c;for(;b;){if(b._reactRootContainer||b.__reactContainer||b.hasAttribute("data-reactroot")||b.hasAttribute("data-react-root")||["root","app","__next"].includes(b.id))return b;b=b.parentElement}return G(c,y).querySelector("#root,#app,#__next,[data-reactroot],[data-react-root]")}function Xt(c,y,b,g){let f=G(y,b),d=X(f,g),h=d.MouseEvent||MouseEvent,x=y.getBoundingClientRect(),m=new h(c,{bubbles:!0,cancelable:!0,view:d,clientX:x.left+x.width/2,clientY:x.top+x.height/2});return{type:c,target:y,currentTarget:y,bubbles:!0,cancelable:!0,nativeEvent:m,isTrusted:!0,preventDefault(){m.preventDefault()},stopPropagation(){m.stopPropagation()}}}function Rn(c){let y=c;if(y.__vue__)return y.__vue__;if(y.__vueParentComponent)return y.__vueParentComponent;if(y._vnode)return y._vnode;let b=c.parentElement;for(let g=0;g<3&&b;g++){let f=b;if(f.__vue__||f.__vueParentComponent||f._vnode)return f.__vue__||f.__vueParentComponent||f._vnode;b=b.parentElement}return null}function Mt(c){let y={};if(c?.$listeners&&Object.assign(y,c.$listeners),c?._events)for(let b in c._events){let g=c._events[b];y[b]=Array.isArray(g)?g[0]:g}if(c?.props)for(let b in c.props)b.startsWith("on")&&typeof c.props[b]=="function"&&(y[b.substring(2).toLowerCase()]=c.props[b]);if(c?.vnode?.props)for(let b in c.vnode.props)b.startsWith("on")&&typeof c.vnode.props[b]=="function"&&(y[b.substring(2).toLowerCase()]=c.vnode.props[b]);return y}})();function Va(){let e=window,t=e.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__";e[t]?.actions?.execute}async function $a(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 To(e,t,n={}){let{rootNodes:r,semanticNodes:o}=Is(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 a=Number(i);if(!Number.isFinite(a))continue;let u=Rr(a);u&&(s[a]=t.getFrameworkMetadata(u))}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(p=document,_=window){$(this,"doc");$(this,"win");$(this,"viewport");$(this,"lastDetectedPrimary",null);$(this,"detectionCache",new Map);$(this,"lastDetectionTime",0);$(this,"CACHE_TTL",5e3);this.doc=p,this.win=_,this.viewport={width:_.innerWidth,height:_.innerHeight},this.updateViewport()}getValidPrimary(){return this.lastDetectedPrimary&&!this.doc.contains(this.lastDetectedPrimary)&&(this.lastDetectedPrimary=null),this.lastDetectedPrimary}async handleCommand(p){switch(p.action){case"detectPrimary":{let _=this.detectPrimaryScrollable();if(!_)return null;let{target:A,isRoot:S}=this.getScrollContext(_.element),M=A.scrollHeight,O=Kt(),W=S&&O?O.innerHeight:A.clientHeight,q=Math.max(0,M-W),U=A.scrollTop;return{selector:_.selector,score:_.score,type:_.type,metrics:{scrollTop:U,scrollHeight:M,clientHeight:W,isAtTop:U<=5,isAtBottom:U>=q-5}}}case"scrollTo":if(!p.direction)throw new Error("scrollTo requires direction");return this.scrollToDirection(p.direction,p.options);case"scrollBy":if(!p.direction)throw new Error("scrollBy requires direction");return this.scrollByAmount(p.direction,p.options);case"scrollElement":if(!p.selector)throw new Error("scrollElement requires selector");return this.scrollElementIntoView(p.selector,p.position,p.options);case"getMetrics":return this.getScrollMetrics();default:throw new Error(`Unknown command: ${p.action}`)}}updateViewport(){this.viewport={width:this.win.innerWidth,height:this.win.innerHeight}}async execute(p){return this.handleCommand(p)}detectPrimaryScrollable(){if(Date.now()-this.lastDetectionTime<this.CACHE_TTL&&this.detectionCache.size>0){let S=Array.from(this.detectionCache.values()).sort((M,O)=>O.score-M.score)[0];if(S)return this.lastDetectedPrimary=S.element,S}this.updateViewport();let p=this.collectScrollableCandidates();if(p.length===0){let S=this.doc.scrollingElement||this.doc.documentElement||this.doc.body;if(!S)return null;let M=this.buildFeatures(S),O=G(S,this.doc),W={element:S,selector:sr(S,O),score:.5,features:M,type:"document"};return this.detectionCache.clear(),this.detectionCache.set(W.selector,W),this.lastDetectionTime=Date.now(),this.lastDetectedPrimary=S,W}let _=this.scoreCandidates(p);if(_.length===0)return null;this.detectionCache.clear();for(let S of _)this.detectionCache.set(S.selector,S);this.lastDetectionTime=Date.now();let A=_[0];return A&&(this.lastDetectedPrimary=A.element),A||null}collectAllElementsDeep(p,_=15e4){let A=[],S=[],M=p.body||p.documentElement;M&&S.push(M);let O=0,W=q=>{try{let U=this.win.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",B=this.win[U]?.shadow?.getRoot;if(typeof B=="function"){let z=B(q);if(z)return z}}catch{}try{return q.shadowRoot||null}catch{return null}};for(;S.length&&!(++O>_);){let q=S.pop();if(vt(q)){let B=q.children;for(let z=B.length-1;z>=0;z--)S.push(B[z]);continue}let U=q,P=oe(U);Ge(U,P)&&A.push(U);try{let B=W(U);B&&S.push(B)}catch{}for(let B=U.lastElementChild;B;B=B.previousElementSibling)S.push(B)}return A}collectScrollableCandidates(){let p=[],_=new WeakSet,A=[this.doc.scrollingElement,this.doc.documentElement,this.doc.body];for(let M of A){if(!M||_.has(M))continue;let O=this.isScrollable(M);(O.vertical||O.horizontal)&&(p.push(M),_.add(M))}let S=this.collectAllElementsDeep(this.doc);for(let M of Array.from(S)){if(_.has(M))continue;let O=M.getBoundingClientRect(),W=this.win.getComputedStyle(M);if(!this.isElementRendered(M,O,W)||!this.isScrollable(M).vertical)continue;let U=40,P=this.viewport.width*.15;if(O.height<U||O.width<P){let B=(M.className||"").toLowerCase().includes("scroll"),z=W.overflowY==="auto"||W.overflowY==="scroll"||W.overflow==="auto"||W.overflow==="scroll";if(!B&&!z)continue}p.push(M),_.add(M)}return p}isElementRendered(p,_,A){if(A.display==="none"||A.visibility==="hidden")return!1;let S=parseFloat(A.opacity||"1");return!(!Number.isNaN(S)&&S<.01||_.width<=1||_.height<=1)}isScrollable(p){let _=this.win.getComputedStyle(p),A=_.overflowY,S=_.overflowX,M=this.doc.scrollingElement,O=p===this.doc.documentElement||p===this.doc.body||!!M&&p===M,W=p.scrollHeight,q=p.clientHeight,U=p.scrollWidth,P=p.clientWidth;if(O){let ne=this.doc.documentElement,de=this.doc.body;W=Math.max(ne?ne.scrollHeight:0,de?de.scrollHeight:0),q=this.win.innerHeight}let B=W-q>8,z=U-P>8,te=A==="auto"||A==="scroll"||A==="overlay",re=S==="auto"||S==="scroll"||S==="overlay";return{vertical:O?B:B&&te,horizontal:O?z:z&&re,byOverflow:te||re}}calculateVisibleIntersection(p){let _=Math.max(0,p.left),A=Math.max(0,p.top),S=Math.min(this.viewport.width,p.right),M=Math.min(this.viewport.height,p.bottom),O=Math.max(0,S-_),W=Math.max(0,M-A);return{width:O,height:W,area:O*W}}analyzeTextContent(p,_=2e3){let A=0,S=0,M=p.ownerDocument||this.doc,W=(M.defaultView||this.win).NodeFilter||NodeFilter,q=M.createTreeWalker(p,W.SHOW_ELEMENT|W.SHOW_TEXT,null),U=0,P=q.currentNode,B=[];for(;P&&U<_;){if(P.nodeType===Node.TEXT_NODE){let j=(P.textContent||"").replace(/\s+/g,"").length;if(j>0){A+=j;let le=P.parentElement;le&&le.closest("a")&&(S+=j)}}else P.nodeType===Node.ELEMENT_NODE&&B.push(P);U++,P=q.nextNode()}let z=B.length||1,te=A/z,re=A>0?S/A:0;return{textChars:A,linkChars:S,textDensity:te,linkDensity:re}}calculateRepetitionScore(p){let _=Array.from(p.children);if(_.length<3)return 0;let A=_.slice(0,50),S=new Map,M=new Map,O=new Map;for(let ie of A){let j=oe(ie);if(!Ge(ie,j))continue;let le=ie.getBoundingClientRect();if(le.height<5||le.width<this.viewport.width*.1)continue;let ne=Math.round(le.height/10)*10,de=Math.round(le.width/10)*10;S.set(ne,(S.get(ne)||0)+1),M.set(de,(M.get(de)||0)+1);let be=(ie.className||ie.tagName).toString();O.set(be,(O.get(be)||0)+1)}let W=A.length||1,q=Math.max(0,...S.values()),U=Math.max(0,...M.values()),P=Math.max(0,...O.values()),B=q/W,z=U/W,te=P/W,re=.4*B+.3*z+.3*te;return Math.min(1,Math.max(0,re))}calculateSemanticScore(p){let _=0,A=null,S=!1,M=(p.getAttribute("role")||"").toLowerCase(),O=p.tagName.toLowerCase(),W=(p.id||"").toLowerCase(),q=(p.className||"").toLowerCase(),U=`${M} ${O} ${W} ${q}`;return(O==="main"||M==="main")&&(_+=1.2,A="article"),O==="article"&&(_+=1,A=A||"article"),(M==="feed"||U.includes("feed"))&&(_+=1,A="feed"),(M==="log"||U.includes("chat")||U.includes("messages"))&&(_+=1,A="chat"),U.includes("content")&&(_+=.5),(U.includes("results")||U.includes("list"))&&(_+=.4),(U.includes("job")||U.includes("jobs"))&&(_+=.4),(O==="nav"||M==="navigation"||U.includes("sidebar"))&&(_-=1,S=!0),(O==="aside"||M==="complementary")&&(_-=.7,S=!0),(O==="footer"||M==="contentinfo"||U.includes("footer"))&&(_-=.8,S=!0),U.includes("header")&&(_-=.6),_=Math.max(-1,Math.min(1,_)),{semanticScore:_,typeHint:A,navLike:S}}detectScrollListeners(p){return[p.querySelector('[class*="infinite"]'),p.querySelector('[class*="load-more"]'),p.querySelector("[data-infinite]"),p.querySelector('[loading="lazy"]'),p.querySelector(".observer-target"),p.querySelector("[data-scroll]")].some(A=>A!==null)}buildFeatures(p){let _=p.getBoundingClientRect(),A=this.win.getComputedStyle(p),S=this.calculateVisibleIntersection(_),M=this.viewport.width*this.viewport.height||1,O=S.area/M,W=this.viewport.width>0?S.width/this.viewport.width:0,q=_.top+_.height/2,U=this.viewport.height/2||1,P=Math.min(1,Math.abs(q-U)/U),B=this.isScrollable(p),z=this.doc.scrollingElement,te=p===this.doc.documentElement||p===this.doc.body||!!z&&p===z,re=p.scrollHeight,ie=p.clientHeight;if(te){let Me=this.doc.documentElement,Ze=this.doc.body;re=Math.max(Me?Me.scrollHeight:0,Ze?Ze.scrollHeight:0),ie=this.win.innerHeight}let j=Math.max(0,re-ie),le=j*S.width,ne=this.analyzeTextContent(p),de=this.calculateRepetitionScore(p),be=this.calculateSemanticScore(p),ht=p.contains(this.doc.activeElement),Te=this.detectScrollListeners(p),Oe=parseInt(A.zIndex||"0",10),He=Number.isFinite(Oe)?Oe:0;return{geometry:{viewportCoverage:O,widthProminence:W,centerDistance:P,scrollCapacity:j,scrollSurface:le,zIndex:He},content:{textDensity:ne.textDensity,linkDensity:ne.linkDensity,repetitionScore:de,semanticScore:be.semanticScore},interaction:{hasScrollListeners:Te,hasFocus:ht,recentActivity:ht?1:0}}}inferElementType(p,_,A,S){if(A)return A;let M=(p.getAttribute("role")||"").toLowerCase(),O=(p.className||"").toLowerCase(),W=p.tagName.toLowerCase(),q=_.geometry,U=_.content;if(M==="log"||O.includes("chat")||O.includes("messages"))return"chat";let P=this.win.getComputedStyle(p);if((P.position==="fixed"||P.position==="absolute")&&q.zIndex>100&&q.viewportCoverage>.2&&q.centerDistance<.4)return"modal";if(M==="feed"||U.repetitionScore>.3&&q.scrollCapacity>400&&q.widthProminence>=.25)return"feed";if(W==="article"||U.textDensity>40&&U.linkDensity<.4&&q.widthProminence>.4)return"article";if(S||q.widthProminence<.3&&U.linkDensity>.3)return"sidebar";let z=this.doc.scrollingElement;return p===this.doc.documentElement||p===this.doc.body||z&&p===z?"document":"unknown"}scoreCandidates(p){let _=[],A=[],S=[],M=[],O=[],W=[];for(let te of p){let re=this.buildFeatures(te),ie=re.content.semanticScore,j=this.calculateSemanticScore(te),le=this.inferElementType(te,re,j.typeHint,j.navLike);W.push({element:te,features:{geometry:{...re.geometry},content:{...re.content,semanticScore:j.semanticScore},interaction:re.interaction},type:le,navLike:j.navLike,semanticScore:j.semanticScore}),A.push(re.geometry.scrollSurface),S.push(re.content.textDensity),M.push(Math.abs(j.semanticScore)),O.push(re.content.repetitionScore)}let q=Math.max(0,...A),U=Math.max(0,...S),P=Math.max(0,...M),B=Math.max(0,...O),z=-1/0;for(let te of W){let{element:re,features:ie,type:j,navLike:le,semanticScore:ne}=te,de=ie.geometry,be=ie.content,ht=ie.interaction,Te=q>0?de.scrollSurface/q:0,Oe=U>0?be.textDensity/U:0,He=P>0?(ne/P+1)/2:.5,Me=j==="feed"||be.repetitionScore>.3&&de.scrollCapacity>400,Ze=be.linkDensity>.5?(be.linkDensity-.5)/.5:0,st=Me?0:Ze,yt=(Me?1:.5)*be.repetitionScore*Math.min(1,de.scrollCapacity/4e3),it={feed:.2,chat:.2,article:.08,modal:.08,document:.05,sidebar:-.12,unknown:0}[j]||0,ke=0;ke+=de.viewportCoverage*.18,ke+=de.widthProminence*.15,ke+=(1-de.centerDistance)*.07,ke+=Te*.22,ke+=yt*.18,ke+=Oe*.08,ke+=(B>0?be.repetitionScore/B:0)*.05,ke+=He*.07,ke-=st*.05,ht.hasFocus&&(ke+=.05),ht.hasScrollListeners&&(ke+=.05),ke+=it,le&&(ke-=.05);let Le=Math.max(0,Math.min(1,ke));Le>z&&(z=Le),_.push({element:re,selector:sr(re,G(re)),score:Le,features:ie,type:j})}if(_.sort((te,re)=>re.score-te.score),_.length>=2){let te=_[0],re=_[1];Math.abs(te.score-re.score)<.08&&te.type==="article"&&re.type==="feed"&&(_[0]=re,_[1]=te)}return _}getScrollContext(p){let _=document.scrollingElement;return p===document.documentElement||p===document.body||!!_&&p===_?{target:_||document.documentElement||document.body,isRoot:!0}:{target:p,isRoot:!1}}async scrollToDirection(p,_){let A=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!A)return{success:!1,error:"No scrollable element found"};let{target:S,isRoot:M}=this.getScrollContext(A),O=G(S),W=X(O),q=_?.isTabActive??!O.hidden,U=_?.behavior,P=q&&U==="smooth",B=M?Math.max(O.documentElement?O.documentElement.scrollHeight:0,O.body?O.body.scrollHeight:0):S.scrollHeight,z=M?W.innerHeight:S.clientHeight,te=Math.max(0,B-z),re=()=>M?W.scrollY:S.scrollTop,ie=j=>{if(P)try{M?W.scrollTo({top:j,behavior:"smooth"}):S.scrollTo({top:j,behavior:"smooth"})}catch{M?(O.scrollingElement||O.documentElement||O.body).scrollTop=j:S.scrollTop=j}else if(M){let le=O.scrollingElement||O.documentElement||O.body;le.scrollTop=j}else S.scrollTop=j};switch(p){case Fe.TOP:return ie(0),{success:!0,scrollTop:0,isAtTop:!0};case Fe.BOTTOM:return ie(te),{success:!0,scrollTop:te,isAtBottom:!0};default:return{success:!1,error:`Unknown direction: ${p}`}}}async scrollByAmount(p,_){let A=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!A)return{success:!1,error:"No scrollable element found"};let{target:S,isRoot:M}=this.getScrollContext(A),O=_?.isTabActive??!document.hidden,W=_?.behavior,q=O&&W==="smooth",U=Kt(),P=M&&U?U.innerHeight:S.clientHeight,B=M&&U?U.innerWidth:S.clientWidth,z=_?.amount??P*.8,te=M?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):S.scrollHeight,re=M&&U?U.innerHeight:S.clientHeight,ie=Math.max(0,te-re),j=ne=>{if(q)try{M?U?.scrollTo({top:ne,behavior:"smooth"}):S.scrollTo({top:ne,behavior:"smooth"})}catch{let de=document.scrollingElement||document.documentElement||document.body;de.scrollTop=ne}else{let de=M?document.scrollingElement||document.documentElement||document.body:S;de.scrollTop=ne}},le=ne=>{if(q)try{S.scrollBy({left:ne,behavior:"smooth"})}catch{S.scrollLeft+=ne}else S.scrollLeft+=ne};switch(p){case Fe.DOWN:{let de=(M&&U?U.scrollY:S.scrollTop)+z;j(de);let be=M&&U?U.scrollY:S.scrollTop;return{success:!0,scrollTop:be,isAtTop:be<=5,isAtBottom:be>=ie-5}}case Fe.UP:{let ne=M&&U?U.scrollY:S.scrollTop,de=Math.max(0,ne-z);j(de);let be=M&&U?U.scrollY:S.scrollTop;return{success:!0,scrollTop:be,isAtTop:be<=5,isAtBottom:be>=ie-5}}case Fe.LEFT:{let ne=-(_?.amount??B*.8);return le(ne),{success:!0,scrollLeft:S.scrollLeft}}case Fe.RIGHT:{let ne=_?.amount??B*.8;return le(ne),{success:!0,scrollLeft:S.scrollLeft}}default:return{success:!1,error:`Unknown direction: ${p}`}}}normalizeScrollPosition(p){switch(p){case ot.START:return"start";case ot.END:return"end";case ot.NEAREST:return"nearest";case ot.CENTER:default:return"center"}}getScrollContainerForElement(p){let _=document.scrollingElement,A=p;for(;A&&A!==document.body&&A!==document.documentElement;){let O=getComputedStyle(A).overflowY,W=O==="auto"||O==="scroll"||O==="overlay",q=A.scrollHeight-A.clientHeight>8;if(W&&q)return{container:A,isRoot:!1};A=A.parentElement}return{container:_||document.documentElement||document.body,isRoot:!0}}scrollElementIntoView(p,_,A){let S=document.querySelector(p);if(!S)return{success:!1,error:`Element not found for selector: ${p}`};let{container:M,isRoot:O}=this.getScrollContainerForElement(S),W=oe(M),q=W?.DOMRect||DOMRect,U=O?new q(0,0,W.innerWidth??0,W.innerHeight??0):M.getBoundingClientRect(),P=S.getBoundingClientRect(),B=24,z=P.top>=U.top+B&&P.bottom<=U.bottom-B,te=A?.isTabActive??!document.hidden,re=A?.behavior,ie=te&&re==="smooth",j=this.normalizeScrollPosition(_);if(_===ot.NEAREST&&z)return{success:!0,alreadyVisible:!0,...this.getScrollMetricsForContainer(M,O)};try{S.scrollIntoView({behavior:ie?"smooth":"auto",block:j,inline:"nearest"})}catch{S.scrollIntoView()}let le=this.getScrollMetricsForContainer(M,O);return{success:!0,position:j,...le}}getScrollMetricsForContainer(p,_){let A=_?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):p.scrollHeight,S=G(p),M=oe(p),O=_&&M?M.innerHeight:p.clientHeight,W=Math.max(0,A-O),U=(_?S.scrollingElement||S.documentElement||S.body:p).scrollTop;return{scrollTop:U,scrollHeight:A,clientHeight:O,maxScroll:W,isAtTop:U<=5,isAtBottom:U>=W-5,scrollPercentage:W>0?U/W*100:0}}getScrollMetrics(){let p=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!p)return null;let{target:_,isRoot:A}=this.getScrollContext(p),S=G(_),M=X(S),O=A?Math.max(S.documentElement?S.documentElement.scrollHeight:0,S.body?S.body.scrollHeight:0):_.scrollHeight,W=A?M.innerHeight:_.clientHeight,q=Math.max(0,O-W),P=(A?S.scrollingElement||S.documentElement||S.body:_).scrollTop;return{element:sr(_,S),scrollTop:P,scrollHeight:O,clientHeight:W,maxScroll:q,isAtTop:P<=5,isAtBottom:P>=q-5,scrollPercentage:q>0?P/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,a=window[i],u=a&&typeof a=="object"?a:null;if(u){try{u.scroll=u.scroll||s}catch{}try{u.scroll||Object.defineProperty(u,"scroll",{value:s,writable:!1,configurable:!1,enumerable:!1})}catch{}}if(i!==n)try{!window[n]&&u&&Object.defineProperty(window,n,{value:u,writable:!1,configurable:!1,enumerable:!1})}catch{}})();var xu=/\[id=(\d+)\]/,qe;(function(e){e.HTML="html",e.PDF="pdf",e.GOOGLE_DOC="google_doc",e.GOOGLE_SHEET="google_sheet",e.PLAIN_TEXT="plain_text"})(qe||(qe={}));var Ga=new Map;function Ru(e){let t={};for(let n of Object.keys(e)){let r=e[Number(n)],o=r?.preservedAttributes?.[bt["rtrvr-label"]],s=r?.resourceLocator;if(typeof o=="string"&&typeof s=="string"){let i=o.match(xu);if(i?.[1]){let a=Number(i[1]);Number.isFinite(a)&&(t[a]=s)}}}return t}async function Ka(e,t,n={}){let r=e.ownerDocument||document,o=n.pageConfig||wo,s=String(r.contentType||"").trim().toLowerCase(),i=Su(s,r),a=Iu(i.documentType,s),u={url:r.URL,title:r.title,contentType:a},v=ku(o);if(i.documentType!==qe.HTML){let O=Number(o?.pageDataTimeoutMs),W=Number.isFinite(O)?Math.max(200,Math.floor(O)):9e3,q=Math.max(200,Math.min(W,Nt(v))),U=Lu(r,i.documentType,o,v),P=await or(U,q,r);if(!P.ok)return{...u,content:"",error:`non_html_timeout:${a}`,metadata:{extractionMethod:"timeout"}};let B=P.value||{},z=i.documentType===qe.GOOGLE_SHEET?ad(r):void 0;return{...u,...B,contentType:B.contentType||u.contentType,sheetInfo:B.sheetInfo||z}}if(o?.onlyTextContent)return{...u,contentType:nr,content:ko(r)};let p=Math.max(0,Math.min(3e3,Nt(v))),_=performance.now(),A=!1;if(!o?.disableAutoScroll&&p>80){let O=r.hidden?900:1500,W=Math.min(O,p);W>80&&(A=await od(r,{profile:"light",timeBudgetMs:W,delayMs:r.hidden?0:160,finalWaitMs:r.hidden?0:200}))}let S=Math.max(0,p-(performance.now()-_));S>80&&await id(r,{mode:"full",totalBudgetMs:Math.min(r.hidden?1400:1200,S),budgetMs:Math.min(r.hidden?650:850,S),maxPasses:r.hidden?1:2});let M=To(e,t,{includeFrames:n.includeFrames??!0,disableDomAnnotations:n.disableDomAnnotations??!0});return Ou(M.rootNodes,M.semanticNodes)?{...u,contentType:nr,content:ko(r),metadata:{scrollingPerformed:A}}:{...u,contentType:nr,roots:M.rootNodes,nodes:M.semanticNodes,elementLinkRecord:Ru(M.semanticNodes),metadata:{scrollingPerformed:A}}}function ku(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 Iu(e,t){switch(e){case qe.PDF:return Cs;case qe.GOOGLE_DOC:return Ns;case qe.GOOGLE_SHEET:return Ms;case qe.PLAIN_TEXT:return yo;case qe.HTML:default:return t||nr}}function Su(e,t){let n=e||String(t.contentType||"").toLowerCase();return Oa(n)?{documentType:qe.PDF}:Au(t)&&(Mu(t)||Cu(t.URL))?{documentType:qe.PDF}:$u(t)?{documentType:qe.GOOGLE_DOC}:Gu(t)?{documentType:qe.GOOGLE_SHEET}:n.includes(yo)?{documentType:qe.PLAIN_TEXT}:{documentType:qe.HTML}}function Au(e){try{let t=Uu(e);return Ds(t)?!0:!!t.querySelector?.('object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]')}catch{return!1}}function Cu(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 Mu(e){try{let t=e.body;return!t||t.querySelectorAll('embed[type="application/pdf"],embed[type="application/x-google-chrome-pdf"],object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]').length===0||(t.innerText||"").trim().length>40?!1:Array.from(t.children).filter(s=>!["SCRIPT","STYLE"].includes(String(s.tagName).toUpperCase())).length<=3}catch{return!1}}async function Lu(e,t,n,r){switch(t){case qe.PDF:return Nu(e,n,r);case qe.GOOGLE_DOC:return Du(e);case qe.GOOGLE_SHEET:return td(e,n);case qe.PLAIN_TEXT:return{content:ko(e),contentType:yo};case qe.HTML:default:return{content:ko(e),contentType:nr}}}async function Nu(e,t,n){Nt(n)>As+50&&await Ua(As,e,n);let o=(()=>{let p=Number(t?.pdfTextSelectionTimeoutMs),_=wo.pdfTextSelectionTimeoutMs;return Number.isFinite(p)?Math.max(150,Math.floor(p)):_})(),s=Nt(n),a=Number.isFinite(s)?Math.max(150,Math.min(o,Math.max(0,s-150))):o,u=await Hu(e,a),v=!!u.success&&!!(u.data||"").trim();return{content:v&&u.data||"",contentType:Cs,error:v?void 0:`pdf_extraction_failed:${u.reason||"unknown"}`}}async function Du(e){return{content:ed(),contentType:Ns}}function Ou(e,t){return!Array.isArray(e)||e.length===0||!t||Object.keys(t).length===0}function ko(e){return e.body?.innerText||e.body?.textContent||e.documentElement?.innerText||e.documentElement?.textContent||""}function Uu(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 Fu(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 Hu(e,t){let n=Number.isFinite(t)&&t>0?Math.floor(t):wo.pdfTextSelectionTimeoutMs,r=Fu(e),o=Ga.get(r)??"";if(o.trim().length>0)return{success:!0,data:o,reason:"ok"};let s=await Pu(e,n);return s.success&&s.data.trim()&&Ga.set(r,s.data),s}async function Pu(e,t){let n=e.defaultView||window,r=Bu(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="",a=p=>{if(s||!Wu(String(p.origin||""),e))return;let _=p.data;Vu(_,o)&&typeof _.selectedText=="string"&&_.selectedText.trim().length>0&&(i=_.selectedText,s=!0)};n.addEventListener("message",a);try{r.postMessage({type:"selectAll",requestId:o},"*")}catch{}let u=Date.now();for(;!s&&Date.now()-u<t;){try{r.postMessage({type:"getSelectedText",requestId:o},"*")}catch{}if(await Je(200,e),i.trim()){s=!0;break}}return n.removeEventListener("message",a),i.trim()?{success:!0,data:i,reason:"ok"}:{success:!1,data:"",reason:Date.now()-u>=t?"timeout":"no_response"}}function Bu(e){let t=Ds(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 Wu(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 Vu(e,t){return!(!e||typeof e!="object"||e.type!=="getSelectedTextReply"||typeof e.selectedText!="string"||e.requestId&&e.requestId!==t)}function $u(e){try{let t=e.defaultView||Kt();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 ir(e)!==null}function Gu(e){let n=(e.defaultView||Kt())?.location.href??"";return/^https:\/\/docs\.google\.com\/spreadsheets\/(?:u\/\d+\/)?d\/[a-zA-Z0-9_-]+/.test(n)}function qu(e){try{return e.defaultView?.top?.document??e}catch{return e}}function Io(e){let t=[e],n=qu(e);return n!==e&&t.push(n),t}var Yu=".docs-texteventtarget-iframe",Xu=".kix-cursor",zu=".docos-replyview-body",Ku=".docos-replyview",ju=".docos-author",ja="\u200B",Qu="\xA0";function ir(e){for(let t of Io(e)){let n=t.querySelector(Yu);if(n)return n}return null}function Ju(e){for(let t of Io(e)){let n=t.querySelector(Xu);if(n)return n}return null}function vo(e){let t=Ju(e);return t?(t.ownerDocument?.defaultView?.getComputedStyle(t).display??t.style.display)==="none":!1}function xo(e,t){let n=ir(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,a=n.contentWindow;if(!i)return;let u=a?.KeyboardEvent||KeyboardEvent;i.dispatchEvent(new u("keydown",s))}function qa(e){let t=ir(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 Zu(e){let t=ir(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 a=i?.KeyboardEvent||KeyboardEvent;s.dispatchEvent(new a("keydown",o))}function Ro(e){let t=ir(e);if(!t)return"";let n=t.contentDocument,r=t.contentWindow,o=n?.body;if(!n||!o)return"";try{let a=r?.ClipboardEvent||ClipboardEvent,u=new a("copy",{bubbles:!0,cancelable:!0});o.firstChild?.dispatchEvent?.(u),o.firstChild?.dispatchEvent||o.dispatchEvent(u)}catch{}let s=o.innerText||o.textContent||"";return String(s).replace(new RegExp(ja,"g"),"")??""}function Ps(e){let t=`
2
+ "use strict";var __roverSDK=(()=>{var $r=Object.defineProperty;var Gc=Object.getOwnPropertyDescriptor;var qc=Object.getOwnPropertyNames;var Yc=Object.prototype.hasOwnProperty;var Xc=(e,t,n)=>t in e?$r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var zc=(e,t)=>{for(var n in t)$r(e,n,{get:t[n],enumerable:!0})},Kc=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of qc(t))!Yc.call(e,o)&&o!==n&&$r(e,o,{get:()=>t[o],enumerable:!(r=Gc(t,o))||r.enumerable});return e};var jc=e=>Kc($r({},"__esModule",{value:!0}),e);var $=(e,t,n)=>Xc(e,typeof t!="symbol"?t+"":t,n);var Df={};zc(Df,{boot:()=>Fr,close:()=>ss,endTask:()=>is,getState:()=>ui,hide:()=>ci,init:()=>si,installGlobal:()=>$c,newTask:()=>Wr,open:()=>Br,registerTool:()=>di,send:()=>li,show:()=>ai,shutdown:()=>ii,update:()=>ns});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 Uf=new Set(Object.values(L));var Qc=40;function pi(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,Qc)}var _t;(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"})(_t||(_t={}));var hi={[_t.Unknown]:"unknown",[_t.React]:"react",[_t.Vue]:"vue",[_t.Angular]:"angular",[_t.Svelte]:"svelte",[_t.JQuery]:"jquery"},as={react:_t.React,vue:_t.Vue,angular:_t.Angular,svelte:_t.Svelte,jquery:_t.JQuery},$e;(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"})($e||($e={}));var Pf={[$e.Other]:"other",[$e.Inline]:"inline",[$e.Delegated]:"delegated",[$e.React]:"react",[$e.Vue]:"vue",[$e.Angular]:"angular",[$e.Svelte]:"svelte",[$e.JQuery]:"jquery",[$e.Native]:"native"},Bf={inline:$e.Inline,delegated:$e.Delegated,react:$e.React,vue:$e.Vue,angular:$e.Angular,svelte:$e.Svelte,jquery:$e.JQuery,other:$e.Other,native:$e.Native},fe;(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"})(fe||(fe={}));var Gr={[L.click_element]:fe.click_element,[L.type_into_element]:fe.type_into_element,[L.type_and_enter]:fe.type_and_enter,[L.select_dropdown_value]:fe.select_dropdown_value,[L.clear_element]:fe.clear_element,[L.focus_element]:fe.focus_element,[L.hover_element]:fe.hover_element,[L.right_click_element]:fe.right_click_element,[L.double_click_element]:fe.double_click_element,[L.long_press_element]:fe.long_press_element,[L.drag_element]:fe.drag_element,[L.drag_and_drop]:fe.drag_and_drop,[L.swipe_element]:fe.swipe_element,[L.adjust_slider]:fe.adjust_slider,[L.describe_images]:fe.describe_images,[L.scroll_to_element]:fe.scroll_to_element,[L.paste_text]:fe.paste_text,[L.check_field_validity]:fe.check_field_validity,[L.select_text]:fe.select_text,[L.mouse_wheel]:fe.mouse_wheel,[L.copy_text]:fe.copy_text,[L.upload_file]:fe.upload_file,[L.go_back]:fe.go_back,[L.go_forward]:fe.go_forward,[L.refresh_page]:fe.refresh_page,[L.press_key]:fe.press_key,[L.scroll_page]:fe.scroll_page,[L.wait_action]:fe.wait_action,[L.wait_for_element]:fe.wait_for_element,[L.pinch_zoom]:fe.pinch_zoom,[L.goto_url]:fe.goto_url,[L.google_search]:fe.google_search,[L.open_new_tab]:fe.open_new_tab,[L.switch_tab]:fe.switch_tab,[L.close_tab]:fe.close_tab,[L.solve_captcha]:fe.solve_captcha,[L.answer_task]:fe.answer_task,[L.dispatch_pointer_path]:fe.dispatch_pointer_path,[L.network_run_recipe]:fe.network_run_recipe},mi=Object.fromEntries(Object.entries(Gr).map(([e,t])=>[t,e]));function qr(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 bi={semanticIdStart:1,interactiveIdStart:1,includeFrameContents:!0,clearIframes:!0,frameContextLabel:null,signalProvider:null,disableDomAnnotations:!1},ft={...bi},Xr=globalThis;function Ei(e){ft={...bi,...e||{}}}function In(){return ft.signalProvider??null}function Xe(){try{return typeof Xr.document<"u"?Xr.document:null}catch{return null}}function Kt(){try{return typeof Xr.window<"u"?Xr.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 oe(e,t){return G(e,t?t.document:null)?.defaultView??t??Kt()??{}}function X(e,t){return e?.defaultView??t??Kt()??{}}function zr(e,t){try{return e?.getElementById?.(t)??null}catch{return null}}function Kr(e,t){try{return e?.querySelector?.(t)??null}catch{return null}}function cs(e,t){try{return Array.from(e?.querySelectorAll?.(t)??[])}catch{return[]}}function Sn(e){try{return e.contentDocument||(e.contentWindow?.document??null)}catch{return null}}function jr(e,t){let n=e.CSS?.escape;return typeof n=="function"?n(t):t.replace(/([^\w-])/g,"\\$1")}function Tt(e,t){try{return e[t]}catch{return}}function jt(e,t){return!!e&&String(e.tagName||"").toUpperCase()===t.toUpperCase()}function wi(e,t){let n=Tt(t,"HTMLAnchorElement");return n?e instanceof n:jt(e,"A")}function Lt(e,t){let n=Tt(t,"HTMLInputElement");return n?e instanceof n:jt(e,"INPUT")}function Ft(e,t){let n=Tt(t,"HTMLTextAreaElement");return n?e instanceof n:jt(e,"TEXTAREA")}function yi(e,t){let n=Tt(t,"HTMLLabelElement");return n?e instanceof n:jt(e,"LABEL")}function _i(e,t){let n=Tt(t,"HTMLSelectElement");return n?e instanceof n:jt(e,"SELECT")}function Ti(e,t){let n=Tt(t,"HTMLSlotElement");return n?e instanceof n:jt(e,"SLOT")}function vi(e,t){let n=Tt(t,"HTMLButtonElement");return n?e instanceof n:jt(e,"BUTTON")}function xi(e,t){let n=Tt(t,"HTMLImageElement");return n?e instanceof n:jt(e,"IMG")}function Ri(e,t){let n=Tt(t,"HTMLVideoElement");return n?e instanceof n:jt(e,"VIDEO")}function ki(e,t){let n=Tt(t,"HTMLCanvasElement");return n?e instanceof n:jt(e,"CANVAS")}function Ge(e,t){if(!e||e.nodeType!==1)return!1;let n=Tt(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 An(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 pr(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 Jc(e,t){if(!e)return!1;if(e.nodeType===9)return!0;let n=Tt(t,"Document");return n?e instanceof n:!1}function Zc(e,t){if(!e)return!1;let n=Tt(t,"Window");if(n)return e instanceof n;try{return e.window===e}catch{return!1}}function Qr(e){try{return e.document}catch{return null}}function Jr(e,t){if(Jc(e,t))try{return e.documentElement}catch{return null}if(Zc(e,t)){let n=Qr(e);if(!n)return null;try{return n.documentElement}catch{return null}}return null}function Yr(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 gi(e,t,n){try{let r=G(t,n);return new URL(e,r.baseURI).href}catch{return e}}function Ii(e,t){let n=e.tagName.includes("-"),r=e.getAttribute("href")||e.getAttribute("src")||e.getAttribute("data")||e.getAttribute("action");if(r){let o=gi(r,e,t);return o.trim().toLowerCase().startsWith("javascript:")?null:o}if(n)return null;try{let o=e,s=Yr(o.href)||Yr(o.src)||Yr(o.data)||Yr(o.action);return s?gi(s,e,t):null}catch{return null}}var Si=["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"],_e={};Si.forEach((e,t)=>{_e[e]=t});var nn={};Si.forEach((e,t)=>{nn[t]=e});function Cn(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 a=s&&parseInt(s,36)||0;n.push({id:i,mask:a})}return n.length?{entries:n}:null}function el(e){let t=Cn(e);if(t){let n=new Set;for(let{id:r}of t.entries)n.add(r);return[...n]}return[]}function hr(e){return zn(e).map(n=>nn[n]).filter(n=>!!n)}function zn(e){let t=In();if(t?.getEventHandlerIds)try{let o=t.getEventHandlerIds(e);if(o&&o.length)return o}catch{}let n=e.getAttribute(pn),r=el(n);return!r||r.length===0?[]:r}var ls=["media"],Ai=new Set(ls),us=["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 Ci=new Set(us),rn=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"]),mr=new Set(["group","region","section","banner","contentinfo","main","navigation","complementary","form","article","document","presentation","none"]);var Mi=["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 Li={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"]},gr={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"}},pn="rtrvr-ls",on="rtrvr-ro",ds="rtrvr-mw-ready",br="rtrvr-mw-busy",fs="rtrvr-mwa-ready",Ni=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"]),Di=["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"],Oi=["h1","h2","h3","h4","h5","h6"],Ui="http://www.w3.org/1999/xhtml",Fi="http://www.w3.org/2000/svg",at="rtrvr-label";var to=new Set(["NOSCRIPT","SCRIPT","STYLE","META"]),Mn="CODE",Ln="PRE",Hi="aria-hidden",Pi="target";var Zr;(function(e){e[e.value=0]="value",e[e.alt=1]="alt",e[e.list=2]="list",e[e.title=3]="title"})(Zr||(Zr={}));var Kn;(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"})(Kn||(Kn={}));var eo;(function(e){e[e.VALUENOW=0]="VALUENOW",e[e.VALUETEXT=1]="VALUETEXT"})(eo||(eo={}));var ps=new Set([_e.click,_e.dblclick,_e.doubleclick,_e.contextmenu,_e.auxclick,_e.pointerdown,_e.pointerup,_e.mousedown,_e.mouseup,_e.touchstart,_e.touchend,_e.keydown,_e.keyup,_e.input,_e.beforeinput,_e.change,_e.submit,_e.reset,_e.paste,_e.dragstart,_e.dragend,_e.drop]),Bi=new Set([...ps,_e.scroll,_e.wheel,_e.mouseenter,_e.mouseover,_e.focus,_e.blur,_e.focusin,_e.focusout]),no=new Set(["click","dblclick","auxclick","contextmenu","mousedown","mouseup","pointerdown","pointerup","touchstart","touchend"]),hs=new Set(["input","change","beforeinput","keydown","keyup","keypress","paste","compositionstart","compositionend"]),ms=new Set(["drag","dragstart","dragend","dragenter","dragleave","dragover","drop"]);var Er;(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"})(Er||(Er={}));var wr;(function(e){e[e.HTML=0]="HTML",e[e.SVG=1]="SVG"})(wr||(wr={}));var ro;(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"})(ro||(ro={}));var oo;(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"})(oo||(oo={}));var bt;(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"})(bt||(bt={}));var nt;(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"})(nt||(nt={}));var sn;(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"})(sn||(sn={}));var tl=[...us,...Object.keys(gr),...ls],Wi=[...new Set(tl)],jn={};Wi.forEach((e,t)=>{jn[e]=t});var yr={};Wi.forEach((e,t)=>{yr[t]=e});var so=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 _r(e){let t=In();if(t?.getRoleHint)try{let o=t.getRoleHint(e);if(o)return o}catch{}let n=e.getAttribute(on);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=yr[o];if(s)return s}}return r}function Qn(e){return Array.from(new Set(e))}function Vi(e,t){if(!e||e.length===0)return Qn(t);let n=new Set([...e,...t]);return Qn(Array.from(n))}function xt(e,t){let r=In()?.getEventHandlerIds?.(e)??zn(e),o=r.length>0&&r.some(a=>ps.has(a)),s=io(e),i=t?mr.has(t):!1;return{element:e,semanticRole:t,eventHandlerIndices:r,isEditableRegion:s,hasNodeWorthyHandlers:o,isLikelyStructuralContainer:i}}var nl=new Set(["text","search","url","tel","password","email","number","date","datetime-local","time","month","week","color"]);function rl(e){let n=oe(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 ol(e){let t=oe(e);if(!Lt(e,t))return!1;let n=(e.type||"text").toLowerCase();return nl.has(n)?!e.disabled&&!e.readOnly:!1}function sl(e){let t=oe(e);return Ft(e,t)&&!e.disabled&&!e.readOnly}function il(e){let t=e;return!(!t.isContentEditable||t.getAttribute("aria-readonly")==="true"||t.getAttribute("aria-disabled")==="true")}function io(e){return!e||!rl(e)?!1:!!(ol(e)||sl(e)||il(e))}function Tr(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,"&#91;").replace(/\]/g,"&#93;"),t}function $i({element:e,elementID:t,frameContextLabel:n}){let r=!ft.disableDomAnnotations,o=[`[id=${t}]`],s=oe(e);if(pr(e)){let u=vr(e.id||e.getAttribute("name")||"unnamed");o.push(`[iframe=${u}]`)}if(n){let u=vr(n);o.push(`[iframeRoot=${u}]`)}if(xi(e,s)&&o.push(`[size=${e.clientWidth}x${e.clientHeight}]`),(Ri(e,s)||ki(e,s))&&o.push(`[size=${e.clientWidth}x${e.clientHeight}]`),Lt(e,s)||Ft(e,s)){let u=al(e);o.push(...u)}e.getAttribute(Hi)==="true"&&o.push("[aria-hidden=true]"),e.disabled&&o.push("[disabled]"),r&&wi(e,s)&&e.setAttribute(Pi,"_self");let a=o.join(" ");return r&&e.setAttribute(at,a),a}function al(e){let t=[],n=oe(e),r=Lt(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 xr=new so,gs=new WeakMap;function Gi(){gs=new WeakMap}function ao(e){let t=gs.get(e);if(t)return t;let n=xr.generateId();return gs.set(e,n),n}var co=new Map,bs=new WeakMap;function qi(){co.clear(),bs=new WeakMap}function Es(e,t){try{typeof WeakRef<"u"?co.set(e,new WeakRef(t)):co.set(e,t)}catch{}}function Rr(e){let t=co.get(e);if(!t)return null;let n=t instanceof WeakRef?t.deref():t;return!n||n.isConnected===!1?null:n}function hn(e){let t=null,n=ao(e);if(ft.frameContextLabel)t=ft.frameContextLabel;else{let o=Xe();if(o&&e.ownerDocument!==o)try{let i=e.ownerDocument?.defaultView?.frameElement?.getAttribute(at)||"",a=i?Tr(i):null;t=a?String(a):null}catch{t=""}}let r=$i({element:e,elementID:n,frameContextLabel:t});if(Es(n,e),r)try{bs.set(e,r)}catch{}return r}function Yi(e){return bs.get(e)??null}function ws(e,t){try{e.querySelectorAll?.(`[${at}]`)?.forEach(r=>r.removeAttribute(at))}catch{}if(t.includeShadow)try{let n=e.querySelectorAll?.("*");if(n)for(let r of Array.from(n))try{let o=r.shadowRoot;o&&ws(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=Sn(r);o?.body&&ws(o.body,t)}catch{}}catch{}}function Xi(e,t={}){if(ft.disableDomAnnotations)return;let n=An(e)?oe(e):X(e)??window,r=Jr(e,n)??e;if(r){try{r.removeAttribute?.(at)}catch{}ws(r,{includeShadow:t.includeShadow??!0,includeIframes:t.includeIframes??!0})}}var mn={},ys=new WeakMap,lo=new WeakSet;function zi(){mn={},ys=new WeakMap,lo=new WeakSet,Gi()}function ct({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,originatedFromParent:i,elementContext:a}){let u=ao(e);Es(u,e);let v=mn[u];if(i){if(!v){let p={nodeCategory:e.nodeType,provisionalFromParent:!0},_=e.nodeName;_&&_.trim()&&(p.elementName=_);let A=e.getAttribute("role");A&&(p.preservedAttributes={1:A});let S=e.tagName;S&&(p.elementTag=S),mn[u]=p}}else{if(v&&!v.provisionalFromParent){if((o||Jn(e))&&(v.isFrameElement=!0,s&&s.length>0&&(v.frameContent=s)),a){let{eventHandlerIndices:p,isEditableRegion:_}=a;if(p&&p.length>0){let A=Qn(p);A.length>0&&(v.eventHandlers=Vi(v.eventHandlers,A))}_&&(v.isEditable=!0)}return u}if(lo.has(e))return u;lo.add(e);try{mn[u]=Ki({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,elementContext:a})}finally{lo.delete(e)}}return u}function kr(e){let t=ys.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=xr.generateId(),i={textContent:r,nodeCategory:e.nodeType};return o&&o!==r&&(i.rawData=o),mn[s]=i,ys.set(e,s),s}function Qi(e,t){let n=Zi(e),{minY:r,maxY:o}=n.getCellBounds(t);return n.getRows().slice(r,o+1).some(s=>s.some(Ir))}function Ji(e,t){let n=Zi(e),{minX:r,maxX:o}=n.getCellBounds(t);return n.getRows().some(s=>s.slice(r,o+1).some(Ir))}var fo=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 a=this.getRowAt(i),u=a.indexOf(t);u!==-1&&(o=Math.max(o,a.lastIndexOf(t)),s=Math.max(s,i),n=Math.min(n,u),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 Zi(e){let n=oe(e).TableGrid||fo,r=new n;e.tHead!==null&&r.merge(uo(e.tHead.rows)),Array.from(e.tBodies).forEach(s=>{r.merge(uo(s.rows))});let o=[];for(let s of Array.from(e.children))_s(s)&&Nn(s,"tr")&&o.push(s);return r.merge(uo(o)),e.tFoot!==null&&r.merge(uo(e.tFoot.rows)),r}function uo(e){let t=new fo,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];)!Ir(t.getCellAt(o,r))&&n[o]&&t.setCellAt(o,r,n[o]),o++;for(let i=o;i<o+s.colSpan;i++){ji(s)===0&&(n[i]=s,t.setCellAt(i,r,s));for(let a=r;a<r+ji(s);a++)Ir(t.getCellAt(i,a))||t.setCellAt(i,a,s)}o+=s.colSpan}for(let s=o;s<t.columnCount;s++){let i=n[s];i!==void 0&&!Ir(t.getCellAt(s,r))&&t.setCellAt(s,r,i)}}return t}function ji(e){let t=e.getAttribute("rowSpan");if(t===null||t.trim()==="")return 1;let n=Number(t);return isNaN(n)?1:n}function Ir(e){return e!==void 0&&Nn(e,"td")}function Ht(e){let t=e.tagName?.toLowerCase();if(t==="code"||t==="pre"){let r=gl(e);if(r)return r}let n=ea(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"),a=e.hasAttribute("role");return o||s||i||a||zn(e).length>0||e.getAttribute("tabindex")!==null?"img":null}if(zn(e).length>0){let o=e.tagName.toLowerCase();if(["div","span","li","p","i","em","strong","b"].includes(o))return cl(e)}}if(t==="td"&&e.getAttribute("role")===null)return"cell";if(n!==null&&t==="th"){let r=e.getAttribute("role");if(r&&ta(r))return r;let o=e;return o.scope==="col"||o.hasAttribute("aria-sort")?"columnheader":o.scope==="row"?"rowheader":"cell"}return n}function cl(e){return _r(e)??null}function ea(e){let t=e.getAttribute("role");if(t!==null)return Mi.includes(t)||!ta(t)?null:t;let n=e.tagName.toLowerCase();return(Li[n]??[]).find(o=>ll(e,o))||null}function ll(e,t){let n=gr[t],r=n?.selector;if(r&&po(e,r))return!0;let o=n?.conditionalSelectors;return o?o.some(i=>po(e,i.selector)&&i.conditions.every(u=>dl(e,u))):!1}function ul(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let r=e.getRootNode?.();if(vt(r)){let o=oe(e),s=`#${jr(o,n)}`,i=Kr(r,s);if(i)return i}}catch{}return zr(G(e),n)}function dl(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=>ul(e,r)!=null);case me.FORBIDDEN_ANCESTORS:return an(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=an(n,t.tag);return r!==null&&ea(r)===t.role}case me.HAS_TABLE_COLUMN_DATA:{let n=an(e,"table");return n===null?!1:t.hasData===Ji(n,e)}case me.HAS_TABLE_ROW_DATA:{let n=an(e,"table");return n===null?!1:t.hasData===Qi(n,e)}default:return fl(t),!1}}function fl(e){throw new Error(`unexpected value ${e}!`)}function ta(e){return hl(e)||ml(e)||pl(e)}function pl(e){return Ai.has(e)}function hl(e){return Ci.has(e)}function ml(e){return gr.hasOwnProperty(e)}function gl(e){if(e.tagName!==Mn&&e.tagName!==Ln)return null;if(hr(e).some(r=>r==="click"||r==="copy"))return"button";let n=e.getAttribute("tabindex");return n!==null&&parseInt(n,10)>=0?"button":e.tagName===Ln||e.tagName===Mn&&e.closest("pre")?"code":null}var bl={[nt.display]:[nt.beforeDisplay,nt.afterDisplay],[nt.content]:[nt.beforeContent,nt.afterContent]},Ts=new Map,El={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 wl(e,t){if(!Ts.has(e)){let n=El[t]||t.replace(/([A-Z])/g,"-$1").toLowerCase();Ts.set(e,n)}return Ts.get(e)}var yl={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 oa(e,t,n){let r=yl[e];return r?r(t,n):t.trim()!==""&&!["initial","inherit","unset"].includes(t)}function sa(e){let t={},n=oe(e);if(!Ge(e,n))return t;let r=n.getComputedStyle(e),o=new Map([[nt.beforeDisplay,n.getComputedStyle(e,"::before")],[nt.afterDisplay,n.getComputedStyle(e,"::after")],[nt.beforeContent,n.getComputedStyle(e,"::before")],[nt.afterContent,n.getComputedStyle(e,"::after")]]);for(let s in nt)if(isNaN(Number(s))){let i=nt[s],a=wl(i,s),u=bl[i];u?((i===nt.display||i===nt.content)&&na(r,a,i,s,t,e),ra(o.get(u[0]),a,u[0],"beforeContent",t),ra(o.get(u[1]),a,u[1],"afterContent",t)):na(r,a,i,s,t,e)}return t}function na(e,t,n,r,o,s){if(e){let i=e.getPropertyValue(t);i&&oa(r,i,s)&&(o[n]=i)}}function ra(e,t,n,r,o){if(e){let s=e.getPropertyValue(t);(t==="content"&&s&&s!=="none"&&s!=='""'&&s!=="''"||s&&oa(r,s))&&(o[n]=s)}}function Dn(e,t){let n=oe(e);if(!Ge(e,n))return!0;if(t&&rn.has(t))return!1;if(e.hasAttribute("hidden")||an(e,"[hidden]")!==null||an(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 Sr(e){return Pt(e)&&e.classList.contains("jasmine_html-reporter")}function _l(e){let t=e.getAttribute("role");return t==="presentation"||t==="none"}function ia(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).map(t=>t.replace(/^#/,"")):[]}function aa(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let o=e.getRootNode?.();if(vt(o)){let s=oe(e),i=`#${jr(s,n)}`,a=Kr(o,i);if(a)return a}}catch{}let r=G(e);return zr(r,n)}function vs(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=Tl(o,s,s+8192),a=vs.apply(null,i);for(let u=0;u<a.length;u++)n.push(a[u])}else n.push(o)}return n}function Tl(e,t,n){return arguments.length<=2?Array.prototype.slice.call(e,t):Array.prototype.slice.call(e,t,n)}function ca(e,t){return vl(e,t).concat(xl(e))}function vl(e,t){return vs(Rs(e).map(r=>ma(r)&&Pt(r)?la(r,t):r))}function la(e,t){if(!e||Dn(e,t))return[];if(!_l(e))return[e];let n=Array.from(e.children);return vs(n.map(r=>la(r,t)))}function ua(e){let t=ia(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=aa(e,o);s&&s!==e&&n.push(s)}return n}function xl(e){let t=ua(e);for(let n of t)n["aria-owned-by"]=e;return t}function da(e){let t=oe(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)<=Sl(e))return!1;let o=Rl(e);return!o||!Il(o)||!Cl(e)||o.getAttribute("role")==="dialog"||e.getAttribute("role")==="dialog"?!1:Al(e)}function Rl(e){return[e.previousElementSibling,e.nextElementSibling,...Array.from(e.children),...e.parentElement?[e.parentElement.previousElementSibling,e.parentElement.nextElementSibling]:[]].filter(n=>n!==null).find(kl)||null}function kl(e){if(Dn(e))return!1;let n=oe(e).getComputedStyle(e);return(n?.position==="fixed"||n?.position==="absolute")&&n?.backgroundColor!=="rgba(0, 0, 0, 0)"&&n?.backgroundColor!=="transparent"&&n?.pointerEvents!=="none"}function Il(e){let t=oe(e),n=e.getBoundingClientRect();return n.top<=0&&n.left<=0&&n.bottom>=t.innerHeight&&n.right>=t.innerWidth}function Sl(e){let t=G(e),n=oe(e),r=n?.getComputedStyle;if(!r)return 0;let o=cs(t,"*").filter(s=>s!==e&&!Dn(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 Al(e){return e.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])').length>0}function Cl(e){let t=e.parentElement;if(!t)return!1;for(let n of Array.from(t.children))if(n!==e&&!Dn(n)&&n.getAttribute("aria-hidden")!=="true")return!1;return!0}function Ml(){try{let t=Xe()?.querySelector?.("dialog:modal");return'[aria-modal="true"], dialog:modal'}catch{return'[aria-modal="true"]'}}var fa=Ml();function Ll(e){return e.getAttribute("aria-disabled")==="true"||e.hasAttribute("disabled")}function xs(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 pa(e){return Ni.has(e)}function Nl(e){let t=e.parentElement,n=G(e);if(!(!t||t===n.body||t===n.documentElement))return ct({targetElement:t,originatedFromParent:!0})}function Ki({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:s,elementContext:i}){let a={nodeCategory:e.nodeType},u=t||Ll(e),v=Nl(e);if(v&&(a.parent=v),n){let Te=jn[n];typeof Te=="number"?a.semanticRole=Te:a.semanticRole=n}if(u&&(a.isDisabled=!0),i){let{eventHandlerIndices:Te,isEditableRegion:Oe}=i,He=Qn(Te);He.length>0&&(a.eventHandlers=He),Oe&&(a.isEditable=!0)}let p=Ol(e);p&&Object.keys(p).length>0&&(a.ariaProperties=p);let _=Ul(e);_&&Object.keys(_).length>0&&(a.ariaStates=_);let A=e.nodeName;A&&A.trim()&&(a.elementName=A);let S=sa(e);S&&Object.keys(S).length>0&&(a.computedStyles=S),Dn(e)&&(a.isInvisible=!0);let M=Dl(e,n);M&&Object.keys(M).length>0&&(a.preservedAttributes=M),e.draggable&&(a.isDraggable=!0),e.scrollWidth&&e.clientWidth&&e.scrollWidth>e.clientWidth&&(a.supportsHorizontalSwipe=!0),e.scrollHeight&&e.clientHeight&&e.scrollHeight>e.clientHeight&&(a.supportsVerticalSwipe=!0);let O=e.getAttribute("class");if(O?.trim()){O.includes("handle")&&(a.isDragHandle=!0),a.supportsHorizontalSwipe||(O.includes("horizontal")||O.includes("carousel"))&&(a.supportsHorizontalSwipe=!0),a.supportsVerticalSwipe||(O.includes("vertical")||O.includes("feed"))&&(a.supportsVerticalSwipe=!0),O.includes("dismissible")&&(a.supportsDismissSwipe=!0),(O.includes("long-press")||O.includes("hold")||O.includes("press-hold"))&&(a.supportsLongPress=!0);let Te=a.inputType||a.preservedAttributes?.[bt.type];Te==="submit"||Te==="reset"||Te==="clear"||(O.includes("submit")&&(a.preservedAttributes={...a.preservedAttributes||{},[bt.type]:"submit"}),O.includes("clear")&&(a.preservedAttributes={...a.preservedAttributes||{},[bt.type]:"clear"}),O.includes("reset")&&(a.preservedAttributes={...a.preservedAttributes||{},[bt.type]:"reset"}))}let W=Vl({element:e});W&&W.length>0&&(a.labelReferences=W);let q=e.tagName;if(q&&(a.elementTag=q),Hl(e)&&(a.hasFocus=!0),!o){let Te=ks({element:e,semanticRole:n,parentDisabled:u,excludeLabels:r});Te&&Te.length>0&&(a.childElements=Te)}let U=Kl({element:e});U&&U.length>0&&(a.ownedElements=U);let P=Ii(e);P&&(a.resourceLocator=P),(o||Jn(e))&&(a.isFrameElement=!0),s&&s.length>0&&(a.frameContent=s);let B=e.type;B&&typeof B=="string"&&B.trim()&&(a.inputType=B);let z=e.placeholder;z&&typeof z=="string"&&z.trim()&&(a.placeholderText=z);let te=e.value;te&&typeof te=="string"&&te.trim()&&(a.elementValue=te);let re=$l({element:e,parentDisabled:t,semanticRole:n});if(re&&re.length>0&&(a.selectedOptions=re),an(e,"select,datalist")&&(a.nearestSelectList=!0),_s(e))a.elementNamespace=wr.HTML;else if(Fl(e)){a.elementNamespace=wr.SVG,a.svgStructure=Pl(e);let Te=Bl(e);Te&&Object.keys(Te).length>0&&(a.preservedAttributes?a.preservedAttributes={...a.preservedAttributes,...Te}:a.preservedAttributes=Te)}let j=r?void 0:Gl({element:e});j&&j.length>0&&(a.associatedLabels=j);let le=e.scope;le&&typeof le=="string"&&le.trim()&&(a.tableScope=le);let ne=Yl({element:e});ne&&(a.tableCaption=ne);let de=Xl({element:e});de&&(a.figureCaption=de);let be=zl({element:e});return be&&(a.fieldsetLegend=be),an(e,"table")&&(a.nearestTable=!0),a}function Dl(e,t){let n={},r=new Set(Object.values(bt).filter(a=>typeof a=="string")),o=new Set(Object.keys(Zr).filter(a=>isNaN(Number(a)))),s=new Set(["_ngcontent","ng-reflect-*","data-v-*"]),i=e?.attributes?Array.from(e.attributes):[];for(let a of i){let u=a.name,v=a.value;if(u==="id"&&(!t||!rn.has(t)))continue;let p;if(r.has(u)?p=u:u.startsWith("data-v-")?p="data-v-*":u.startsWith("ng-reflect-")?p="ng-reflect-*":u.startsWith("_ngcontent")&&(p="_ngcontent"),p){let _=v.trim()!=="",A=o.has(p);if(_||A){let S=bt[p],M=s.has(p)?"true":v;n[S]=M}}}if(!n[bt[at]]){let a=Yi(e);a&&(n[bt[at]]=a)}return n}function Ol(e){return ha(e,ro,eo)}function Ul(e){return ha(e,oo,null)}function ha(e,t,n){let r={};for(let o in t)if(isNaN(Number(o))){let s=t[o],a=`aria-${o.toLowerCase().replace(/_/g,"-")}`,u=e.getAttribute(a),v=!1;n!==null&&(v=Object.values(n).filter(_=>typeof _=="number").includes(s)),e.hasAttribute(a)&&v||u?.trim()?r[s]=u:a==="aria-level"&&Oi.includes(e.tagName.toLowerCase()?.trim())&&(r[s]=e.tagName.substring(1))}return r}function Pt(e){return ma(e)&&e.nodeType===Er.ELEMENT}function ho(e){return e.nodeType===Er.TEXT}function ma(e){let t=typeof e;return t=="object"&&e!=null||t=="function"}function _s(e){return Pt(e)&&(!e.namespaceURI||e.namespaceURI===Ui)}function Fl(e){return Pt(e)&&e.namespaceURI===Fi}function Jn(e){return e.tagName==="IFRAME"}function Nn(e,t){return"tagName"in e?e.tagName?.toLowerCase()===t:e.elementTag?.toLowerCase()===t}function an(e,t){if(e.closest)return e.closest(t);for(;!po(e,t);){if(e.parentElement===null)return null;e=e.parentElement}return e}function po(e,t){return e.matches?.(t)??e.msMatchesSelector?.(t)??e.webkitMatchesSelector(t)}function Hl(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 Pl(e){let t={},n=sn.text,r=sn.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[sn.viewBox]=i);let a=e.querySelectorAll("path");a.length>0&&(t[sn.paths]=a.length,t[sn.pathData]=Array.from(a).slice(0,3).map(v=>v.getAttribute("d")).filter(Boolean).map(v=>v.substring(0,100)));let u={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(u).forEach(([v,p])=>{if(p>0){let _=sn[v];t[_]=p}}),Object.keys(t).length>0?t:void 0}function Bl(e){let t={};if(!e?.hasAttributes())return t;for(let n of Object.values(Kn).filter(r=>typeof r=="number")){let r=Kn[n];if(r){let o=r;if(Kn.hasOwnProperty(o)&&e.hasAttribute(o)){let s=e.getAttribute(o);s?.trim()&&(t[n]=s)}}}return t}function Wl({frameElement:e,parentDisabled:t,excludeLabels:n}){if(!ft.includeFrameContents)return[];let r=null;try{r=e.contentWindow?.document?.body||null}catch{return[]}if(!r)return[];let o=[];for(let s of Rs(r))if(!(Sr(s)||ga(s))){if(Pt(s)){let i=s,a=Ht(i),u=xt(i,a),{shouldCreate:v,shouldAnnotate:p}=mo(u);if(v){p&&hn(i);let _=ct({targetElement:i,parentDisabled:t,semanticRole:a??void 0,excludeLabels:n,elementContext:u});_&&o.push(_)}else{let _=ks({element:i,semanticRole:a??void 0,parentDisabled:t,excludeLabels:n});o.push(..._)}}else if(ho(s)){let i=kr(s);i&&o.push(i)}}return o}function Rs(e){let t=oe(e);if(Ti(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||In()?.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 ks({element:e,semanticRole:t,parentDisabled:n,excludeLabels:r}){let o=[];for(let s of Rs(e))if(!(Sr(s)||ga(s))){if(Pt(s)){let i=s,a=Ht(i),u=xt(i,a);if(Jn(i)){hn(i);let _=Wl({frameElement:i,parentDisabled:n,excludeLabels:r}),A=ct({targetElement:i,parentDisabled:n,semanticRole:a??void 0,excludeLabels:r,isFrameNode:!0,frameContentNodes:_,elementContext:u});A&&o.push(A);continue}let{shouldCreate:v,shouldAnnotate:p}=mo(u);if(v){p&&hn(i);let _=ct({targetElement:i,parentDisabled:n,semanticRole:a??void 0,excludeLabels:r,elementContext:u});_&&o.push(_)}else{let _=ks({element:i,semanticRole:a??void 0,parentDisabled:n,excludeLabels:r});o.push(..._)}}else if(ho(s)){let i=kr(s);i&&o.push(i)}}return o}function Vl({element:e}){let t=ia(e.getAttribute("aria-labelledby")),n=new Set;for(let r of t){let o=aa(e,r);if(!(!o||o===e)&&o){let s=Ht(o),i=ct({targetElement:o,semanticRole:s,elementContext:xt(o,s)});n.add(i)}}return Array.from(n)}function $l({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=>ct({targetElement:o,parentDisabled:t,semanticRole:"option",elementContext:xt(o,"option")})):Nn(e,"select")&&(r=Array.from(e.selectedOptions).map(o=>ct({targetElement:o,parentDisabled:t,semanticRole:"option",elementContext:xt(o,"option")})))),r}function Gl({element:e}){if(Di.includes(e.tagName)){let t=G(e),n=cs(t,"label"),r=new Set;return Array.from(n).filter(o=>o!==e&&ql(o,e)).map(o=>{let s=Ht(o),i=ct({targetElement:o,semanticRole:s,excludeLabels:!0,elementContext:xt(o,s)});r.add(i)}),Array.from(r)}}function ql(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 Yl({element:e}){if(Nn(e,"table")){let t=e.querySelector("caption");if(t&&t!==e){let n=Ht(t);return ct({targetElement:t,semanticRole:n,elementContext:xt(t,n)})}}}function Xl({element:e}){if(Nn(e,"figure")){let t=e.querySelector("figcaption");if(t&&t!==e){let n=Ht(t);return ct({targetElement:t,semanticRole:n,elementContext:xt(t,n)})}}}function zl({element:e}){if(Nn(e,"fieldset")){let t=e.querySelector("legend");if(t&&t!==e){let n=Ht(t);return ct({targetElement:t,semanticRole:n,elementContext:xt(t,n)})}}}function Kl({element:e}){let t=new Set,n=ua(e);for(let r of n){let o=Ht(r),s=ct({targetElement:r,semanticRole:o,elementContext:xt(r,o)});t.add(s)}return Array.from(t)}function mo(e){let{semanticRole:t,eventHandlerIndices:n,isEditableRegion:r,hasNodeWorthyHandlers:o,isLikelyStructuralContainer:s}=e,i=n.length>0&&n.some(_=>Bi.has(_)),u=!!t||!s&&(o||r),v=!!t&&rn.has(t);return{shouldCreate:u,shouldAnnotate:u&&(v||r||i)}}function ga(e){if(!Pt(e))return!1;let t=e,n=t.tagName;return to.has(n)?!0:n===Mn||n===Ln?jl(t):!1}function jl(e){let t=oe(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 Is(e,t={}){return Ei(t),zi(),qi(),Xi(e,{includeShadow:!0,includeIframes:ft.clearIframes}),xr.initialize(ft.semanticIdStart),{rootNodes:ba(e),semanticNodes:mn}}function ba(e){let t=[];try{let n=G(e),o=Array.from(n.querySelectorAll(fa)).filter(s=>!Dn(s)&&da(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(Sr(e)||Ea(e))return[];let n=Ht(e),r=xt(e,n);if(Jn(e))return[Jl({frameElement:e,role:n,parentNode:t,elementContext:r})];let o=0,{shouldCreate:s,shouldAnnotate:i}=mo(r);s&&(i&&hn(e),o=ct({targetElement:e,parentDisabled:t?.isDisabled,semanticRole:n,elementContext:r}));let a=mn[o],u=Ql(e,n,o?a:t);return o&&u.length>0&&(a.semanticChildren=u),o?[o]:u}function Ql(e,t,n){let r=[],o=ca(e,t);for(let s of o)if(!(Sr(s)||Ea(s))){if(Pt(s)){let i=Zn({targetElement:s,parentNode:n});r.push(...i)}else if(ho(s)&&eu(s,n)){let i=kr(s);i&&r.push(i)}}return r}function Jl({frameElement:e,role:t,parentNode:n,elementContext:r}){hn(e);let o=Zl(e);return ct({targetElement:e,parentDisabled:n?.isDisabled,semanticRole:t,isFrameNode:!0,frameContentNodes:o,elementContext:r})}function Zl(e){if(!ft.includeFrameContents)return[];let n=Sn(e)?.body??null;return n?ba(n):[]}function eu(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"?yr[t.semanticRole]:t.semanticRole;if(pa(r))return!1}return!0}function Ea(e){if(!Pt(e))return!1;let t=e,n=t.tagName;return to.has(n)?!0:n===Mn||n===Ln?tu(t):!1}function tu(e){let t=oe(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 bo(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t}function nu(e){let t=e.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}function tr(e,t,n){let r=G(e,t),o=X(r,n);try{e.focus?.({preventScroll:!0})}catch{}if(bo(r)===e)return!0;try{let{x:s,y:i}=nu(e),a=o.PointerEvent||PointerEvent,u=o.MouseEvent||MouseEvent;e.dispatchEvent(new a("pointerdown",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:1,button:0,pointerType:"mouse"})),e.dispatchEvent(new u("mousedown",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:1,button:0})),e.dispatchEvent(new u("mouseup",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:0,button:0})),e.dispatchEvent(new a("pointerup",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,buttons:0,button:0,pointerType:"mouse"})),(e.isContentEditable||Lt(e,o)||Ft(e,o)||e.getAttribute("contenteditable")==="true")&&e.dispatchEvent(new u("click",{bubbles:!0,cancelable:!0,composed:!0,clientX:s,clientY:i,button:0}))}catch{}try{e.focus?.({preventScroll:!0})}catch{}return bo(r)===e}function Ar(e,t){let n=oe(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 Un(e,t,n="insertText"){let r=oe(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 ru(e){let n=oe(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 On(e){if(!e)return!1;let t=oe(e);if(Ft(e,t))return!e.disabled&&!e.readOnly;if(Lt(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 Ss(e){let t=oe(e);if(!e||!Ge(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 ou(e,t){let n=e.getRootNode();return vt(n)?n:G(e)??t}function su(e,t){let n=[];for(let r of t.split(/\s+/).filter(Boolean)){let o=e.getElementById?.(r)||e.querySelector?.(`#${CSS.escape(r)}`),s=oe(o);Ge(o,s)&&n.push(o)}return n}function Ta(e,t){if(!e)return{kind:"none",el:null,via:"no-root"};if(On(e))return{kind:"input",el:e,via:"self-input"};if(Ss(e))return{kind:"contenteditable",el:e,via:"self-contenteditable"};let n=G(e)??t,r=X(n),o=ou(e,n);if(yi(e,r)){let u=e.control;if(On(u))return{kind:"input",el:u,via:"label.control"};let v=e.htmlFor;if(v){let p=o.getElementById?.(v)||o.querySelector?.(`#${CSS.escape(v)}`);if(On(p))return{kind:"input",el:p,via:"label.for"}}}let s=e.getAttribute("aria-controls")||e.getAttribute("aria-owns");if(s)for(let u of su(o,s)){if(On(u))return{kind:"input",el:u,via:"aria-controls/owns"};if(Ss(u))return{kind:"contenteditable",el:u,via:"aria-controls/owns"};let v=u.querySelector?.("input,textarea");if(On(v))return{kind:"input",el:v,via:"aria-controls->desc"}}let i=e.querySelector?.("input,textarea");if(On(i))return{kind:"input",el:i,via:"descendant"};let a=e.shadowRoot||null;if(a){let u=a.querySelector?.("input,textarea");if(On(u))return{kind:"input",el:u,via:"open-shadow-input"};let v=a.querySelector?.('[contenteditable="true"],[contenteditable=""],[role="textbox"]');if(Ss(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 er(e,t,n,r=!1){let o=G(e,t),i=X(o,n).getSelection?.();if(!i)return!1;try{let a=o.createRange();return a.selectNodeContents(e),r&&a.collapse(!1),i.removeAllRanges(),i.addRange(a),!0}catch{return!1}}function Fn(e){return(e.textContent??"").replace(/\u00A0/g," ").trim()}var go=e=>String(e??"").replace(/\s+/g," ").trim(),va=new MessageChannel,xa=[];va.port1.onmessage=()=>{let e=xa.shift();e&&e()};function wa(){return new Promise(e=>{xa.push(e),va.port2.postMessage(0)})}async function ya(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 wa():await new Promise(s=>{try{t.requestAnimationFrame(()=>s())}catch{wa().then(s)}})}function iu(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 _a(e,t,n,r){let o=G(e,t),i=X(o,n).KeyboardEvent||KeyboardEvent,a=String(r??"");for(let u of a){let{code:v,which:p}=iu(u),_={key:u,code:v,bubbles:!0,cancelable:!0,composed:!0,keyCode:p,which:p};e.dispatchEvent(new i("keydown",_)),e.dispatchEvent(new i("keypress",_)),e.dispatchEvent(new i("keyup",_))}}async function Ra(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??""),a=G(e,t),u=X(a,n),v=tr(e,a,u),p=Number.isFinite(Number(o?.settleFrames))?Math.max(0,Math.min(4,Number(o?.settleFrames))):a.hidden?1:2,_=!!o?.useKeyFallback,A=Number.isFinite(Number(o?.keyFallbackMaxLen))?Number(o?.keyFallbackMaxLen):140,S=_&&s.length>0&&s.length<=A;Ar(e,s),Un(e,s,"insertReplacementText"),S&&_a(e,a,u,s),await ya(a,u,p);let M=String(e.value??""),O=go(i),W=go(M),q=go(s),U=O===q,P=W===q,B=M!==i,z=s.length>0&&!U&&M===i,te=1;if(!U&&!P&&!B){te=2;try{e.focus?.({preventScroll:!0}),e.select?.()}catch{}let ne=!1;try{a.execCommand?.("selectAll",!1,void 0),ne=!!a.execCommand?.("insertText",!1,s)}catch{ne=!1}if(!ne)try{Ar(e,s)}catch{}try{Un(e,s,"insertReplacementText")}catch{}S&&_a(e,a,u,s),await ya(a,u,p),M=String(e.value??"")}let ie=go(M)===q,j=M!==i;z=s.length>0&&!U&&M===i;let le=U||ie||j;return{success:le,method:"type-native-setter",details:`focus=${v};attempts=${te};settleFrames=${p};beforeLen=${i.length};afterLen=${M.length};changed=${j};alreadyCorrect=${U};nowCorrect=${ie};reverted=${z};keyFallback=${S}`,allowFallback:le?void 0:!0}}function au(e,t,n){let o=oe(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 ka(e,t,n,r){let o=G(e,n),s=X(o,r),i=s.InputEvent||InputEvent,a=s.Event||Event,u=String(t??""),v=Fn(e),p=tr(e,o,s),_=er(e,o,s,!0),A=au(e,u,"insertText"),S=!1,M="execCommand",O=!1,W=()=>{O=!0};try{e.addEventListener("input",W,{capture:!0})}catch{}if(A.ok&&!A.defaultPrevented)try{S=!!o.execCommand?.("insertText",!1,u)}catch{}if(!S)try{let P=s.getSelection?.(),B=P&&P.rangeCount?P.getRangeAt(0):null;if(!B||!e.contains(B.commonAncestorContainer)){er(e,o,s,!0);let z=s.getSelection?.();B=z&&z.rangeCount?z.getRangeAt(0):null}B&&(B.insertNode(o.createTextNode(u)),B.collapse(!1),P?.removeAllRanges(),P?.addRange(B),S=!0,M="range")}catch{}if(S&&!O){try{e.dispatchEvent(new i("input",{bubbles:!0,cancelable:!1,composed:!0,data:u,inputType:"insertText"}))}catch{try{e.dispatchEvent(new a("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{}}try{e.dispatchEvent(new a("change",{bubbles:!0,cancelable:!0,composed:!0}))}catch{}}try{e.removeEventListener("input",W,{capture:!0})}catch{}let q=Fn(e);return{success:q!==v||!!u&&q.includes(u),method:`type-contenteditable-${M}`,details:`focus=${p};selectedWithin=${_};inserted=${S}`}}function Ia(e){let{canceled:t}=ru(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 Sa(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=tr(e,r,o);Ar(e,""),Un(e,"","deleteByCut");let a=String(e.value??""),u=a!==s;return{success:u||a.length===0,method:"clear-native-setter",details:`focus=${i};beforeLen=${s.length};afterLen=${a.length};changed=${u}`}}function Aa(e,t,n){let r=G(e,t),o=X(r,n),s=Fn(e),i=tr(e,r,o),a=er(e,r,o,!1),u=!1,v="execCommand";try{u=!!r.execCommand?.("delete",!1,void 0)}catch{u=!1}if(!u)try{let S=o.getSelection?.(),M=S&&S.rangeCount?S.getRangeAt(0):null;(!M||!e.contains(M.commonAncestorContainer))&&er(e,r,o,!1);let O=o.getSelection?.(),W=O&&O.rangeCount?O.getRangeAt(0):null;W&&(W.deleteContents(),W.collapse(!1),O?.removeAllRanges(),O?.addRange(W),u=!0,v="range")}catch{}if(!u)try{e.textContent="",u=!0,v="textContent"}catch{}Un(e,"","deleteByCut");let p=Fn(e),_=p!==s;return{success:u||_||p.length===0,method:`clear-contenteditable-${v}`,details:`focus=${i};selectedWithin=${a};cleared=${u};changed=${_}`}}function Ca(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 Eo;(function(e){e.FLASH_LITE="Gemini Flash Lite",e.FLASH="Gemini Flash",e.PRO="Gemini Pro"})(Eo||(Eo={}));var Ma;(function(e){e[e.NativeHostConnected=0]="NativeHostConnected",e[e.NativeHostDisconnected=1]="NativeHostDisconnected"})(Ma||(Ma={}));var cu=["image/png","image/jpeg","image/webp"],lu=["application/pdf","text/plain"],yh=[...cu,...lu];var rt;(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"})(rt||(rt={}));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 _h={[rt.ACT]:Qe.AGENTIC_SEEK,[rt.CRAWL]:Qe.CRAWL_PAGES,[rt.EXTRACT]:Qe.EXTRACT_PAGE,[rt.SHEETS_WORKFLOW]:Qe.SHEETS_WORKFLOW,[rt.INFER_SHEET_DATA]:Qe.INFER_SHEET_DATA,[rt.PDF_FILLER]:Qe.PDF_FILLER,[rt.CUSTOM_TOOL_GENERATOR]:Qe.CUSTOM_TOOL_GENERATOR,[rt.WEBPAGE_GENERATOR]:Qe.WEBPAGE_GENERATOR,[rt.GOOGLE_DOC_GENERATOR]:Qe.GOOGLE_DOC_GENERATOR,[rt.GOOGLE_SLIDES_GENERATOR]:Qe.GOOGLE_SLIDES_GENERATOR,[rt.PROCESS_TEXT]:Qe.PROCESS_TEXT,[rt.CREATE_SHEET_FROM_DATA]:Qe.CREATE_SHEET_FROM_DATA,[rt.EXECUTE_MULTIPLE_TOOLS]:Qe.EXECUTE_MULTIPLE_TOOLS,[rt.CONFIGURE_API_KEY]:Qe.CONFIGURE_API_KEY,[rt.QUERY_RTRVR_AI_DOCUMENTATION]:Qe.QUERY_RTRVR_AI_DOCUMENTATION};var As=200;var Th=Eo.FLASH;var vh=Qe.PLANNER;var Cs="application/pdf",Ms="application/gsheet";var xh=20*1024*1024;var wo={maxParallelTabs:4,pageLoadDelay:2e3,disableAutoScroll:!1,makeNewTabsActive:!1,writeRowProcessingTime:!1,totalBudgetMs:25e3,pageDataTimeoutMs:22e3,pdfTextSelectionTimeoutMs:12e3,onlyTextContent:!1};var uu=1,du=9,fu=11,Ns="application/gdoc",nr="text/html",yo="text/plain";function pu(e){return!!e&&typeof e=="object"&&e.nodeType===du}function La(e){return!!e&&typeof e=="object"&&e.nodeType===uu}function hu(e){return!!e&&typeof e=="object"&&e.nodeType===fu&&typeof e.host=="object"&&typeof e.mode=="string"}function Na(e){return La(e)&&String(e.tagName).toUpperCase()==="IFRAME"}function Ls(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 mu(e){try{let t=e.shadowRoot;return t||globalThis?.chrome?.dom?.openOrClosedShadowRoot?.(e)||null}catch{return null}}function gu(e,t,n={}){let r=n.traverseShadow!==!1,o=n.traverseIframes!==!1,s=n.requireOwnerDocument,i=[e],a=new WeakSet;for(;i.length;){let u=i.pop();if(u&&typeof u=="object"){if(a.has(u))continue;a.add(u)}if(pu(u)){let _=u.documentElement||u.body;_&&i.push(_);continue}if(hu(u)){let _=u.children;if(_&&_.length)for(let A=_.length-1;A>=0;A--)i.push(_[A]);continue}if(!La(u))continue;let v=u;if(s&&v.ownerDocument!==s)continue;let p=v.getAttribute?.(at);if(p&&Tr(p)===t)return v;if(r)try{let _=mu(v);_&&i.push(_)}catch{}if(o&&Na(v))try{let _=Sn(v);_&&i.push(_)}catch{}for(let _=v.lastElementChild;_;_=_.previousElementSibling)i.push(_)}return null}function Bt(e,t,n={}){let r=Ls(t);if(!r)return null;let o=Rr(r);return o&&(!n.requireOwnerDocument||o.ownerDocument===n.requireOwnerDocument)?o:gu(e,r,{requireOwnerDocument:n.requireOwnerDocument,traverseShadow:n.traverseShadow,traverseIframes:n.traverseIframes})}function Ds(e=document){return e.querySelector('embed[type="application/pdf"], embed[type="application/x-google-chrome-pdf"]')}function Da(e){if(e==null)return[];if(Array.isArray(e)){let t=[];for(let n of e){let r=Ls(n);r&&t.push(r)}return t}if(typeof e=="number"||typeof e=="bigint"){let t=Ls(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 Da(t)}return[]}function rr(e,t){let n=Da(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 a=n[i],u=n.length===1,v=Bt(o,a,{requireOwnerDocument:u?void 0:o,traverseShadow:!0,traverseIframes:u});if(!v||!Na(v))return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:n.slice(i)};let p=null;try{p=Sn(v)||null}catch{p=null}if(!p)return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:n.slice(i)};s.push(a),o=p}return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:s,unresolvedPath:[]}}function Oa(e){return e==="application/pdf"||e==="application/x-pdf"||e==="application/x-google-chrome-pdf"}function bu(){return Date.now()}function Nt(e){return!e||!Number.isFinite(e)?Number.POSITIVE_INFINITY:Math.max(0,e-bu())}async function Ua(e,t,n){if(!Number.isFinite(e)||e<=0)return;let r=Nt(n);r<=0||r<e+40||await Je(e,t)}async function or(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 a=o.defaultView||window,u=a.setTimeout?a.setTimeout.bind(a):setTimeout;await new Promise(v=>u(v,s));return}let i=Date.now();for(;Date.now()-i<s;)await n()}})();var Eu=3e4;function Fa(e){return(String(e??"").replace(/\\/g,"/").split("/").pop()||"upload").replace(/[\u0000-\u001f\u007f]/g,"").trim()||"upload"}var Os=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 wu(e){return e&&e.split(";")[0].trim()||"application/octet-stream"}function yu(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 Us(e,t){try{let r=(t??window).URL||URL,s=new r(e).pathname.match(/\/o\/(.+?)(\?|$)/);if(s?.[1]){let a=decodeURIComponent(s[1]).split("/");return a[a.length-1].replace(/^\d+-/,"")}}catch{}}function Ha(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 _u(e,t={},n,r=fetch){let o=new AbortController,s=Eu,i=!1,a=()=>{};if(n){let v=!1;a=()=>{v=!0},(async()=>{try{if(await Je(s,n),v)return;i=!0,o.abort()}catch{}})().catch(()=>{})}else{let v=setTimeout(()=>{i=!0,o.abort()},s);a=()=>clearTimeout(v)}let u=new Headers(t.headers);u.has("Accept")||u.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:u,signal:o.signal});if(!v.ok){let S=await v.text().catch(()=>"");throw new Os(`Fetch failed (${v.status})`,{url:e,status:v.status,statusText:v.statusText,bodySnippet:S.slice(0,256)})}let p=await v.arrayBuffer(),_=wu(v.headers.get("content-type")),A=yu(v.headers.get("content-disposition"))||Us(e);return{bytes:p,mimeType:_,fileName:A}}finally{a()}}async function Pa(e,t,n){return await _u(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 ot;(function(e){e.START="START",e.CENTER="CENTER",e.END="END",e.NEAREST="NEAREST"})(ot||(ot={}));function Wa(e){if(!e)return ot.CENTER;let t=typeof e=="string"?e.toUpperCase():String(e).toUpperCase();return ot&&t in ot?ot[t]:ot.CENTER}function Fs(e){return globalThis.CSS&&typeof globalThis.CSS.escape=="function"?globalThis.CSS.escape(e):e.replace(/([ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}function sr(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`#${Fs(e.id)}`;let r=[],o=e;for(;o&&o!==n.body&&o!==n.documentElement;){let s=o.tagName.toLowerCase();if(o.id){s+=`#${Fs(o.id)}`,r.unshift(s);break}let a=(o.classList&&o.classList.length?Array.from(o.classList):(o.className||"").toString().split(/\s+/).filter(Boolean)).filter(u=>u&&u.length<=48).sort((u,v)=>u.length-v.length).slice(0,3).map(Fs);if(a.length)s+="."+a.join(".");else{let u=o.parentElement;if(u){let v=Array.from(u.children).filter(p=>p.tagName===o.tagName);if(v.length>1){let p=v.indexOf(o)+1;s+=`:nth-of-type(${p})`}}}r.unshift(s),o=o.parentElement}return r.join(" > ")}function Hn(e){return e.scrollingElement||e.documentElement||e.body}function _o(e,t,n,r,o){let s=G(e,t),i=X(s,n),a=Hn(s),u=e===s.documentElement||e===s.body||e===a,v=u?a:e,p=u?i.innerHeight:v.clientHeight,_=u?i.innerWidth:v.clientWidth,A=o??p*.8;switch(r){case Fe.DOWN:{v.scrollTop+=A;break}case Fe.UP:{v.scrollTop=Math.max(0,v.scrollTop-A);break}case Fe.LEFT:return v.scrollLeft=Math.max(0,v.scrollLeft-(o??_*.8)),{success:!0,scrollLeft:v.scrollLeft};case Fe.RIGHT:return v.scrollLeft+=o??_*.8,{success:!0,scrollLeft:v.scrollLeft};default:return{success:!1,error:`Unsupported scroll direction: ${String(r)}`}}let S=v.scrollHeight,M=u?i.innerHeight:v.clientHeight,O=S-M;return{success:!0,scrollTop:v.scrollTop,isAtTop:v.scrollTop<=5,isAtBottom:v.scrollTop>=O-5}}function Tu(e,t,n){let r=G(e,t),o=X(r,n),s=Hn(r),i=e;for(;i&&i!==r.body&&i!==r.documentElement;){let u=o.getComputedStyle(i).overflowY;if((u==="auto"||u==="scroll"||u==="overlay")&&i.scrollHeight>i.clientHeight+5)return i;i=i.parentElement}return s}function Ba(e,t,n){let r=G(e,t),o=X(r,n),s=Hn(r),i=e===r.documentElement||e===r.body||e===s,a=i?s:e,u=a.scrollHeight,v=i?o.innerHeight:a.clientHeight,p=u-v;return a.scrollTop>=p-5}function Hs(e,t,n,r){let o=G(e,t),s=X(o,n),i=Hn(o),a=Tu(e,o,s),u=a===o.documentElement||a===o.body||a===i,v=u?i:a,p=e.getBoundingClientRect(),_=u?new(s.DOMRect||DOMRect)(0,0,s.innerWidth,s.innerHeight):a.getBoundingClientRect(),A=u?s.innerHeight:a.clientHeight,S=24,M=p.top-_.top,O=v.scrollTop+M,W;switch(r){case ot.START:W=O-S;break;case ot.END:W=O+p.height-A+S;break;case ot.NEAREST:{if(p.top>=_.top&&p.bottom<=_.bottom)return{success:!0,scrollTop:v.scrollTop,isAtTop:v.scrollTop<=5,isAtBottom:Ba(v,o,s)};p.top<_.top?W=O-S:W=O+p.height-A+S;break}case ot.CENTER:default:W=O-A/2+p.height/2;break}let q=v.scrollHeight-A;return v.scrollTop=Math.max(0,Math.min(W,q)),{success:!0,scrollTop:v.scrollTop,isAtTop:v.scrollTop<=5,isAtBottom:Ba(v,o,s)}}var vu=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(fs,"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(c){let y={};try{let b=mi[c.opcode];if(!b)throw new Error(`Unknown tool opcode: ${c.opcode}`);let g={...c.call,name:b};y=(await O({tabIndex:c.tabIndex,call:g,elementData:M(c.elementData),payload:c.payload}))[0]?.response??{success:!1,error:"Empty tool response",allowFallback:!0}}catch(b){y={success:!1,error:b?.message||String(b),allowFallback:!0}}return y}try{Object.defineProperty(s,"actions",{value:Object.freeze({execute:i}),writable:!1,configurable:!1,enumerable:!1})}catch{}let a="__RTRVR_UPLOAD_BYTES_REQ__",u="__RTRVR_UPLOAD_BYTES_RES__",v="__RTRVR_UPLOAD_BYTES_BRIDGE__",p="__RTRVR_WINDOW_MESSAGE_MUX__";function _(c){let y=c,b=y[p];if(!b||typeof b!="object"){b={handlers:new Set,installed:!1};try{Object.defineProperty(y,p,{value:b,enumerable:!1,configurable:!1})}catch{y[p]=b}}if(!b.installed){b.installed=!0,c.addEventListener("message",g=>{if(g.source===c)for(let f of Array.from(b.handlers))try{f(g)}catch{}},!0);try{c.addEventListener("pagehide",()=>{let f=c[v]?.pending;if(f)for(let[d,h]of f){try{h.cancelTimeout()}catch{}h.reject(new Error("pagehide: upload bytes request canceled")),f.delete(d)}},!0)}catch{}}return b}function A(c){let y=c,b=y[v];if(!b||typeof b!="object"){b={pending:new Map};try{Object.defineProperty(y,v,{value:b,enumerable:!1,configurable:!1})}catch{y[v]=b}_(c).handlers.add(f=>{let d=f?.data;if(!d||typeof d!="object"||d.type!==u)return;let h=String(d.requestId||"");if(!h)return;let x=b.pending.get(h);if(!x)return;b.pending.delete(h);try{x.cancelTimeout()}catch{}if(!d.ok){x.reject(new Error(d.error||"Failed to get bytes"));return}let m=d.bytes;if(!(m instanceof ArrayBuffer)){x.reject(new Error("Invalid bytes payload (expected ArrayBuffer)"));return}if(typeof x.expectedByteLength=="number"&&m.byteLength!==x.expectedByteLength){x.reject(new Error(`Byte length mismatch: got=${m.byteLength}, expected=${x.expectedByteLength}`));return}x.resolve(m)})}return b}function S(c,y,b,g=9e4){let f=c.__ROVER_UPLOAD_BYTES__||c.rover?.uploadBytes||c.rtrvr?.uploadBytes;if(typeof f=="function")return Promise.resolve().then(()=>f({token:y,byteLength:b,timeoutMs:g})).then(T=>{if(T instanceof ArrayBuffer)return T;if(T&&T.buffer instanceof ArrayBuffer)return T.buffer;throw new Error("Upload bytes provider returned invalid buffer")});let d=A(c),h=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(16).slice(2)}`,x=Math.max(1e3,Math.min(Number(g)||9e4,18e4)),m=Qr(c)||document;return new Promise((T,C)=>{let N=!1,F=!1,Y=()=>{F=!0};(async()=>{await Je(x,m),!(F||N)&&(d.pending.delete(h),N=!0,C(new Error("Timed out waiting for upload bytes")))})().catch(()=>{}),d.pending.set(h,{cancelTimeout:Y,expectedByteLength:b,resolve:Q=>{N||(N=!0,Y(),T(Q))},reject:Q=>{N||(N=!0,Y(),C(Q))}}),c.postMessage({type:a,requestId:h,token:y,byteLength:b},"*")})}function M(c){if(c)return{frameworks:c.frameworks?c.frameworks.map(y=>hi[y]).filter(y=>y&&y!=="unknown"):[],listenersRaw:c.listenersRaw??"",role:c.role??void 0,pattern:c.pattern??void 0,value:c.value??void 0}}async function O({tabIndex:c,call:y,elementData:b,payload:g}){let f=(()=>{try{return Kt()?.top?.document||document}catch{return document}})(),d=y.args,h,x,m;try{({doc:h,win:x,unresolvedPath:m}=rr(f,d.iframe_id))}catch{if(d.iframe_id!=null)return[{name:y.name,args:y.args,response:{success:!1,error:`Cannot access iframe ${d.iframe_id} (cross-origin or not found)`}}];h=document,x=X(h)}let T=y.name,C=d.element_id?Bt(h,d.element_id):null,N=C?.ownerDocument??null,F;if(!vu.has(T))F={success:!1,error:`Tool not promotable to main: ${T}`,allowFallback:!0};else{let Y=N??h,Q=X(Y,x);F=await q(T,C,d,b,Y,Q,g)}return[{name:y.name,args:y.args,response:F}]}async function W(c,y,b){try{let g=c.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",d=c[g]?.scroll?.execute;if(typeof d!="function")throw new Error("main-world scroll detector not available");let h=b?.doc||Qr(c)||document,x=Math.max(250,Math.min(Number(b?.timeoutMs??3500),8e3)),m=await or(Promise.resolve().then(()=>d(y)),x,h);if(!m.ok)throw new Error("scroll detector timeout");return m.value}catch(g){throw new Error(g?.message||"main-world scroll detector not available")}}async function q(c,y,b,g,f,d,h){let x=F=>({success:F.success,error:F.success?void 0:F.details||"Action failed",allowFallback:F.success?void 0:F.allowFallback??!0}),m=c===L.press_key||c===L.scroll_page||c===L.drag_and_drop||c===L.pinch_zoom;if(!y&&!m)return x({success:!1,method:"missing-element-race",details:"Target element missing",allowFallback:!0});let T=new Set([L.type_into_element,L.type_and_enter,L.clear_element,L.focus_element,L.select_text,L.check_field_validity]),C=y,N=G(C,f);if(C&&T.has(c)){let F=Ta(C,N);(F.kind==="input"||F.kind==="contenteditable")&&(C=F.el)}try{switch(c){case L.click_element:return x(z(y,f,d,g));case L.double_click_element:return x(Ut(y,f,d));case L.right_click_element:return x(he(y,f,d));case L.hover_element:return x(await ht(y,f,d,g,b.duration));case L.type_into_element:return x(await st(C,f,d,b.text,g));case L.type_and_enter:return x(await yt(C,f,d,b.text,g));case L.clear_element:return x(await It(C,f,d,g));case L.focus_element:return x(it(C,f,d));case L.select_dropdown_value:return x(ke(y,f,d,b.value,g));case L.adjust_slider:return x(Le(y,f,d,g?.value??b.value,g));case L.check_field_validity:return x(Vt(C,f,d));case L.select_text:return x(mt(C,f,d,b.start_offset,b.end_offset));case L.scroll_page:return x(await $t(y,f,d,b));case L.scroll_to_element:return x(await ln(y,f,d,b));case L.mouse_wheel:return x(et(y,f,d,b.delta_x,b.delta_y));case L.drag_element:return x(await Ne(y,f,d,b,g));case L.drag_and_drop:return x(await un(b,y,f,d));case L.swipe_element:return x(await dn(y,f,d,b));case L.long_press_element:return x(await yn(y,f,d,b.duration));case L.pinch_zoom:return x(await Pe(y,f,d,b));case L.press_key:return x(Gt(b.key,b.modifiers,y,f,d));case L.copy_text:return x(await Jt(y,f,d));case L.paste_text:return x(await fn(y,f,d,g));case L.upload_file:return x(await Ot(b,f,d,h,y,g));case L.dispatch_pointer_path:return x(await ut(b,f,d));default:return x({success:!1,method:"unhandled",details:`Unhandled ${c}`,allowFallback:!0})}}catch(F){return x({success:!1,method:"exception",details:F?.message||"exception",allowFallback:!0})}}function U(c){let y=new Map;if(!c)return y;let b=c.trim();if(!b)return y;let g=Cn(b);if(g){for(let{id:f,mask:d}of g.entries){let h=nn[f];if(!h)continue;let x=new Set(qr(d)),m=y.get(h);if(m)for(let T of x)m.add(T);else y.set(h,x)}return y}return y}function P(c,...y){return c?y.some(b=>c.has(b)):!1}function B(c,y){let b=U(y?.listenersRaw),g=new Set;for(let[,T]of b)for(let C of T)(C==="react"||C==="vue"||C==="angular"||C==="svelte"||C==="jquery")&&g.add(C);let f=new Set;for(let[T,C]of b)if(["click","input","change","keydown","keyup","pointerdown","pointerup","mousedown","mouseup","submit","dragstart","drop","wheel","scroll"].includes(T))for(let N of C)f.add(N);let d=g.size>0||[...f].some(T=>["react","vue","angular","svelte","jquery"].includes(T)),h=P(b.get("click"),"delegated"),x=P(b.get("input"),"delegated")||P(b.get("change"),"delegated")||P(b.get("keydown"),"delegated"),m=y?.role||_r(c)||c.getAttribute("role");return{sourcesByType:b,fws:g,isFrameworkElement:d,delegatedClick:h,delegatedInput:x,role:m}}function z(c,y,b,g){let f=B(c,g),d=G(c,y),h=X(d,b);Ve(c,d,h),g?.pattern==="hover-activate"&&ht(c,d,h,g,120);let x=f.fws.has("react")||P(f.sourcesByType.get("click"),"react"),m=f.fws.has("vue")||P(f.sourcesByType.get("click"),"vue"),T=f.fws.has("angular")||P(f.sourcesByType.get("click"),"angular"),C=f.fws.has("svelte")||P(f.sourcesByType.get("click"),"svelte"),N=f.fws.has("jquery")||P(f.sourcesByType.get("click"),"jquery");return vn(()=>te(c,d,h),()=>re(c,d,h),()=>x?j(c,d,h):null,()=>m?le(c,d,h):null,()=>T?ne(c,d,h):null,()=>C?de(c,d,h):null,()=>N?be(c,d,h):null)}function te(c,y,b){let g=G(c,y),f=X(g,b),d=f.PointerEvent||PointerEvent,h=f.MouseEvent||MouseEvent,{x,y:m}=ie(c,g,f),T={bubbles:!0,cancelable:!0,composed:!0,view:f,clientX:x,clientY:m,button:0,buttons:1};return c.focus?.({preventScroll:!0}),[new d("pointerover",T),new d("pointerenter",{...T,bubbles:!1}),new h("mouseover",T),new h("mouseenter",{...T,bubbles:!1}),new d("pointerdown",T),new h("mousedown",T),new d("pointerup",{...T,buttons:0}),new h("mouseup",{...T,buttons:0}),new h("click",{...T,buttons:0})].forEach(N=>c.dispatchEvent(N)),{success:!0,method:"pointer-mouse-click"}}function re(c,y,b){let g=G(c,y),f=X(g,b);try{if(c instanceof HTMLAnchorElement){let d=c.getAttribute("target");try{c.setAttribute("target","_self"),c.click()}finally{d===null?c.removeAttribute("target"):c.setAttribute("target",d)}}else c.click?.();return{success:!0,method:"native-click"}}catch{return{success:!1,method:"native-click"}}}function ie(c,y,b){let g=G(c,y),f=c.getBoundingClientRect(),d=[{x:f.left+f.width/2,y:f.top+f.height/2},{x:f.left+4,y:f.top+4},{x:f.right-4,y:f.top+4},{x:f.left+4,y:f.bottom-4},{x:f.right-4,y:f.bottom-4}],h=null;for(let x=0;x<d.length;x++){let m=d[x],T=g.elementFromPoint(m.x,m.y);if(x===0&&(h=T),T&&Ca(c,T))return{...m,hit:T,ok:!0}}return{...d[0],hit:h,ok:!1}}function j(c,y,b){let g=G(c,y),f=X(g,b);try{let d=tn(c);if(!d)return{success:!1,method:"react-no-fiber"};let h=Yt(d),x=h.onClick||h.onClickCapture;return x?(x(Xt("click",c,g,f)),{success:!0,method:"react-fiber-onClick"}):{success:!1,method:"react-no-onClick"}}catch{return{success:!1,method:"react-fiber-onClick"}}}function le(c,y,b){let g=G(c,y),d=X(g,b).MouseEvent||MouseEvent;try{let h=Rn(c);if(!h)return{success:!1,method:"vue-none"};let x=Mt(h);return x.click?(x.click(new d("click",{bubbles:!0})),{success:!0,method:"vue-handler"}):h.$emit?(h.$emit("click"),{success:!0,method:"vue-emit"}):{success:!1,method:"vue-no-click"}}catch{return{success:!1,method:"vue-handler"}}}function ne(c,y,b){let g=G(c,y),f=X(g,b),d=f.MouseEvent||MouseEvent;try{let h=f.ng?.getZone?.()||null;return h?.run?(h.run(()=>c.dispatchEvent(new d("click",{bubbles:!0,cancelable:!0}))),{success:!0,method:"angular-zone-click"}):(c.dispatchEvent(new d("click",{bubbles:!0,cancelable:!0})),c.click?.(),{success:!0,method:"angular-click"})}catch{return{success:!1,method:"angular-click",allowFallback:!0}}}function de(c,y,b){let g=G(c,y),d=X(g,b).MouseEvent||MouseEvent;try{let h=c.getBoundingClientRect(),x={bubbles:!0,cancelable:!0,view:c.ownerDocument?.defaultView||window,clientX:h.left+h.width/2,clientY:h.top+h.height/2};return c.dispatchEvent(new d("mousedown",x)),c.dispatchEvent(new d("mouseup",x)),c.dispatchEvent(new d("click",x)),{success:!0,method:"svelte-click"}}catch{return{success:!1,method:"svelte-click"}}}function be(c,y,b){let g=G(c,y),f=X(g,b);try{return f.jQuery?.(c)?.trigger?.("click"),{success:!0,method:"jquery-trigger"}}catch{return{success:!1,method:"jquery-trigger"}}}async function ht(c,y,b,g,f=500){let d=Math.min(Math.max(0,Number(f)||500),3e4),h=G(c,y),x=X(h,b),m=B(c,g);Ve(c,h,x);let T=x.PointerEvent||PointerEvent,C=x.MouseEvent||MouseEvent,N=c.getBoundingClientRect(),F=N.left+N.width/2,Y=N.top+N.height/2;if(m.fws.has("react")){let J=tn(c),ee=J?Yt(J):{};ee.onMouseEnter?.(Xt("mouseenter",c,h,x)),ee.onPointerEnter?.(Xt("pointerenter",c,h,x))}else if(m.fws.has("vue")){let J=Rn(c),ee=J?Mt(J):{};ee.mouseenter?.(new C("mouseenter",{bubbles:!0})),ee.mouseover?.(new C("mouseover",{bubbles:!0}))}let Q={bubbles:!0,cancelable:!0,composed:!0,view:x,clientX:F,clientY:Y};return[new T("pointerover",Q),new T("pointerenter",{...Q,bubbles:!1}),new C("mouseover",Q),new C("mouseenter",{...Q,bubbles:!1})].forEach(J=>c.dispatchEvent(J)),await Je(d,h),{success:!0,method:"hover-seq"}}async function Te(c,y,b=1){await Promise.resolve();for(let g=0;g<b;g++)c.hidden?await Ct():await new Promise(f=>{try{y.requestAnimationFrame(()=>f())}catch{Ct().then(f)}})}let Oe=c=>String(c??"").replace(/\s+/g," ").trim();function He(c){try{if("value"in c)return String(c.value??"")}catch{}return""}function Me(c){try{return typeof Fn=="function"?Fn(c):Oe(c.textContent)}catch{return""}}function Ze(c,y){if(!(y.isFrameworkElement||y.delegatedInput))return!1;let b=String(c??"").length;return b>0&&b<=140}async function st(c,y,b,g,f){let d=B(c,f),h=G(c,y),x=X(h,b);if(Ve(c,h,x),Lt(c,x)||Ft(c,x)){let T=Ze(String(g??""),d),C=await Ra(c,h,x,g,{settleFrames:h.hidden?1:2,useKeyFallback:T,keyFallbackMaxLen:140});return{success:C.success,method:C.method,details:C.details,allowFallback:!C.success}}if(c.isContentEditable===!0||d.role==="textbox"&&!("value"in c)){let T=Me(c),C=ka(c,g,h,x);await Te(h,x,h.hidden?1:2);let N=Me(c),F=!1;if(String(g??"").length>0&&N===T){F=!0;try{tr(c,h,x),er(c,h,x,!0);try{h.execCommand?.("insertText",!1,String(g??""))}catch{}Un(c,String(g??""),"insertText")}catch{}await Te(h,x,h.hidden?1:2)}let Y=Me(c),Q=Y!==T||!!String(g??"")&&Y.includes(String(g??""));return{success:Q,method:C.method,details:`${C.details};beforeLen=${T.length};afterLen=${Y.length};reverted=${N===T};fallback=${F}`,allowFallback:Q?void 0:!0}}return{success:!1,method:"type",details:"target not editable",allowFallback:!0}}async function yt(c,y,b,g,f){let d=G(c,y),h=X(d,b),x=await st(c,d,h,g,f);if(!x.success)return x;let m=Ia(c);return{success:!0,method:"type+enter",details:`${x.details};enter=${m.method}`}}async function It(c,y,b,g){let f=G(c,y),d=X(f,b),h=d.Event||Event;if(Ve(c,f,d),Lt(c,d)||Ft(c,d)){let m=He(c),T=Sa(c,f,d);if(await Te(f,d,f.hidden?1:2),He(c)===m&&m.length>0){try{Ar(c,""),Un(c,"","deleteByCut")}catch{}await Te(f,d,f.hidden?1:2)}let F=He(c),Y=F.length===0||F!==m;return{success:T.success,method:T.method,details:T.details,allowFallback:!T.success}}if(c.isContentEditable===!0||B(c,g).role==="textbox"&&!("value"in c)){let m=Aa(c,f,d);return await Te(f,d,f.hidden?1:2),{success:m.success,method:m.method,details:m.details,allowFallback:!m.success}}if("value"in c){try{c.value=""}catch{}return c.dispatchEvent(new h("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new h("change",{bubbles:!0,composed:!0})),{success:!0,method:"clear-generic-value"}}return{success:!1,method:"clear",details:"target not clearable",allowFallback:!0}}function it(c,y,b){try{let g=G(c,y),f=X(g,b),d=f.FocusEvent||FocusEvent;return Ve(c,g,f),c.focus?.({preventScroll:!0}),c.dispatchEvent(new d("focus",{bubbles:!0})),c.dispatchEvent(new d("focusin",{bubbles:!0})),{success:!0,method:"focus"}}catch(g){return{success:!1,method:"focus",details:g.message,allowFallback:!0}}}function ke(c,y,b,g,f){try{let d=G(c,y),h=X(d,b),x=h.Event||Event;if(!_i(c,h))return{success:!1,method:"select",details:"target not select",allowFallback:!0};Ve(c,d,h),c.focus?.({preventScroll:!0});let m=Array.from(c.options).find(F=>F.value===g||F.text.trim()===g.trim());if(!m)return{success:!1,method:"select",details:`Option not found: ${g}`,allowFallback:!0};m.selected=!0;let T=Object.getPrototypeOf(c),C=Object.getOwnPropertyDescriptor(T,"value");if(C?.set?C.set.call(c,m.value):c.value=m.value,c.dispatchEvent(new x("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new x("change",{bubbles:!0,composed:!0})),B(c,f).fws.has("react")){let F=tn(c);if(F){let Y=Yt(F);if(Y.onChange){let Q=Xt("change",c,d,h);Q.target.value=m.value,Y.onChange(Q)}}}return{success:!0,method:"select"}}catch(d){return{success:!1,method:"select",details:d.message,allowFallback:!0}}}function Le(c,y,b,g,f){try{let d=G(c,y),h=X(d,b),x=h.Event||Event;if(!Lt(c,h))return{success:!1,method:"slider",details:"target not input",allowFallback:!0};Ve(c,d,h),c.focus?.({preventScroll:!0});let m=Object.getPrototypeOf(c),T=Object.getOwnPropertyDescriptor(m,"value");if(T?.set?T.set.call(c,String(g)):c.value=String(g),c.dispatchEvent(new x("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new x("change",{bubbles:!0,composed:!0})),B(c,f).fws.has("react")){let N=tn(c);if(N){let F=Yt(N);if(F.onChange){let Y=Xt("change",c,d,h);Y.target.value=String(g),F.onChange(Y)}}}return{success:!0,method:"slider"}}catch(d){return{success:!1,method:"slider",details:d.message,allowFallback:!0}}}function Vt(c,y,b){try{let g=c.checkValidity?.()??!0;return g||c.reportValidity?.(),{success:g,method:"check-validity",details:g?void 0:c.validationMessage}}catch(g){return{success:!1,method:"check-validity",details:g.message,allowFallback:!0}}}function mt(c,y,b,g,f){try{let d=G(c,y),h=X(d,b);if("setSelectionRange"in c){let T=c;T.focus?.();let C=T.value?.length??0;return T.setSelectionRange(g??0,f??C),{success:!0,method:"select-range"}}let x=h.getSelection();if(!x)return{success:!1,method:"select-range",allowFallback:!0};let m=d.createRange();return m.selectNodeContents(c),x.removeAllRanges(),x.addRange(m),{success:!0,method:"select-range-node"}}catch(d){return{success:!1,method:"select-range",details:d.message,allowFallback:!0}}}function gt(c,y,b,g,f){let d=Hn((c&&G(c))??y),h=c||d,x=G(h,y),m=X(x,b),T=h===x.documentElement||h===x.body||h===d;if(g===Fe.TOP||g===Fe.BOTTOM){let C=h.scrollHeight,N=T?m.innerHeight:h.clientHeight,F=Math.max(0,C-N);return h.scrollTop=g===Fe.TOP?0:F,{success:!0,scrollTop:h.scrollTop}}return _o(h,x,m,g,f)}async function $t(c,y,b,g){let f=g.direction,d=g.amount,h=G(c,y),x=X(h,b),m=!h.hidden,T=m?"smooth":"auto";try{if(c){let N=St(c,h,x),F=gt(N,h,x,f,d);return F?.success?{success:!0,method:"direct-element-scroll",details:JSON.stringify(F)}:{success:!1,method:"direct-element-scroll",details:F?.error||"direct scroll failed",allowFallback:!0}}if(f===Fe.TOP||f===Fe.BOTTOM){let N=await W(x,{action:"scrollTo",direction:f,options:{behavior:T,isTabActive:m}},{doc:h,timeoutMs:h.hidden?5200:2800});return{success:!0,method:"detector-scrollTo",details:JSON.stringify(N)}}let C=await W(x,{action:"scrollBy",direction:f,options:{amount:d,behavior:T,isTabActive:m}},{doc:h,timeoutMs:h.hidden?5200:2800});return{success:!0,method:"detector-scrollBy",details:JSON.stringify(C)}}catch(C){let N=h?gt(Hn(h),h,x,f,d):void 0;return N?.success?{success:!0,method:"direct-primary-scroll-fallback",details:JSON.stringify(N)}:{success:!1,method:"scroll-page-failed",details:C?.message||N?.error||"scroll_page failed",allowFallback:!0}}}async function ln(c,y,b,g){let f=G(c,y),d=X(f,b),h=!f.hidden,x=h?"smooth":"auto",m=Wa(g.position),T=sr(c,f);if(!T){let C=Hs(c,f,d,m);return{success:C.success,method:"direct-scrollElement-no-selector",details:C.error,allowFallback:!C.success}}try{let C=await W(d,{action:"scrollElement",selector:T,position:m,options:{behavior:x,isTabActive:h}},{doc:f,timeoutMs:f.hidden?5600:3e3});return{success:!0,method:"detector-scrollElement",details:JSON.stringify(C)}}catch(C){let N=Hs(c,f,d,m);return N.success?{success:!0,method:"direct-scrollElement-fallback",details:JSON.stringify(N)}:{success:!1,method:"scroll-to-element-failed",details:C?.message||N.error||"scroll_to_element failed",allowFallback:!0}}}function et(c,y,b,g,f){try{let d=G(c,y),h=X(d,b),x=h.WheelEvent||WheelEvent;Ve(c,d,h);let m=St(c,d,h);return m.dispatchEvent(new x("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:h,deltaX:g||0,deltaY:f||0,deltaMode:x.DOM_DELTA_PIXEL})),m.scrollBy({left:g||0,top:f||0,behavior:"auto"}),{success:!0,method:"wheel"}}catch(d){return{success:!1,method:"wheel",details:d.message,allowFallback:!0}}}function St(c,y,b){let g=G(c,y),f=X(g,b),d=g.scrollingElement||g.documentElement||g.body,h=c;for(;h&&h!==g.body&&h!==g.documentElement;){let m=f.getComputedStyle(h).overflowY;if((m==="auto"||m==="scroll"||m==="overlay")&&h.scrollHeight>h.clientHeight+5)return h;h=h.parentElement}return d}async function Ne(c,y,b,g,f){try{let d=G(c,y),h=X(d,b),x=h.PointerEvent||PointerEvent,m=h.MouseEvent||MouseEvent,T=h.DragEvent||DragEvent,C=h.DataTransfer||DataTransfer;Ve(c,d,h);let N=ie(c,d,h),F=Ge(N.hit,h)?N.hit:c,Y=c.getBoundingClientRect(),Q=Number.isFinite(Number(g?.distance))?Number(g.distance):160,pe=0,J=0;switch(String(g?.direction||"").toUpperCase()){case"UP":J=-Q;break;case"DOWN":J=Q;break;case"LEFT":pe=-Q;break;case"RIGHT":pe=Q;break;default:pe=Number(g?.delta_x)||0,J=Number(g?.delta_y)||0}let ee=(I,D)=>({x:Math.max(2,Math.min(I,h.innerWidth-3)),y:Math.max(2,Math.min(D,h.innerHeight-3))}),se=ee(N.x,N.y),we=ee(N.x+pe,N.y+J),Be=500+Date.now()%1e4,ue=Math.max(12,Math.min(36,Number(g?.steps)||18)),Ee=(I,D)=>({bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:I,clientY:D,pageX:I+(h.scrollX||0),pageY:D+(h.scrollY||0)}),ye=(I,D,V)=>({...Ee(I,D),pointerId:Be,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:V?.5:0,buttons:V,button:0}),l=(I,D,V)=>({...Ee(I,D),buttons:V,button:0});F.dispatchEvent(new x("pointerdown",ye(se.x,se.y,1))),F.dispatchEvent(new m("mousedown",l(se.x,se.y,1)));try{F.setPointerCapture?.(Be)}catch{}let E=null;try{(c.draggable||B(c,f).sourcesByType.has("dragstart"))&&(E=new C)}catch{E=null}if(E)try{c.dispatchEvent(new T("dragstart",{bubbles:!0,cancelable:!0,clientX:se.x,clientY:se.y,dataTransfer:E}))}catch{}let k=null;for(let I=1;I<=ue;I++){let D=se.x+(we.x-se.x)*I/ue,V=se.y+(we.y-se.y)*I/ue,K=d.elementFromPoint(D,V)||c;if(K.dispatchEvent(new x("pointermove",ye(D,V,1))),K.dispatchEvent(new m("mousemove",l(D,V,1))),E)try{k&&k!==K&&k.dispatchEvent(new T("dragleave",{bubbles:!0,cancelable:!0,clientX:D,clientY:V,dataTransfer:E})),K.dispatchEvent(new T("dragover",{bubbles:!0,cancelable:!0,clientX:D,clientY:V,dataTransfer:E})),k=K}catch{}I%3===0&&await Ct()}let R=d.elementFromPoint(we.x,we.y)||c;if(R.dispatchEvent(new x("pointerup",ye(we.x,we.y,0))),R.dispatchEvent(new m("mouseup",l(we.x,we.y,0))),E)try{c.dispatchEvent(new T("dragend",{bubbles:!0,cancelable:!0,clientX:we.x,clientY:we.y,dataTransfer:E}))}catch{}return{success:!0,method:"drag",details:`dx=${pe};dy=${J};steps=${ue};hitOk=${N.ok}`}}catch(d){return{success:!1,method:"drag",details:d?.message||"drag failed",allowFallback:!0}}}async function un(c,y,b,g){try{let f=G(y,b),d=X(f,g),h=d.PointerEvent||PointerEvent,x=d.MouseEvent||MouseEvent,m=d.DragEvent||DragEvent,T=d.DataTransfer||DataTransfer,C=c?.source_element_id??c?.element_id,N=(C?Bt(f,String(C)):null)||y;if(!N)return{success:!1,method:"drag-drop",details:"source missing",allowFallback:!0};let F=null,Y=Number(c?.target_x),Q=Number(c?.target_y);if(c?.target_element_id){if(F=Bt(f,String(c.target_element_id)),!F)return{success:!1,method:"drag-drop",details:"target missing",allowFallback:!0};let R=F.getBoundingClientRect();Y=R.left+R.width/2,Q=R.top+R.height/2}if((!Number.isFinite(Y)||!Number.isFinite(Q))&&!F)return{success:!1,method:"drag-drop",details:"missing target coords",allowFallback:!0};Ve(N,f,d),F&&Ve(F,f,d);let pe=(R,I)=>({x:Math.max(2,Math.min(R,d.innerWidth-3)),y:Math.max(2,Math.min(I,d.innerHeight-3))}),J=N.getBoundingClientRect(),ee=pe(J.left+J.width/2,J.top+J.height/2),se=pe(Number(Y),Number(Q)),we=600+Date.now()%1e4,Be=Math.max(14,Math.min(42,Number(c?.steps)||22)),ue=(R,I)=>({bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:R,clientY:I,pageX:R+(d.scrollX||0),pageY:I+(d.scrollY||0)}),Ee=(R,I,D)=>({...ue(R,I),pointerId:we,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:D?.5:0,buttons:D,button:0}),ye=(R,I,D)=>({...ue(R,I),buttons:D,button:0}),l=null;try{l=new T}catch{l=null}N.dispatchEvent(new h("pointerdown",Ee(ee.x,ee.y,1))),N.dispatchEvent(new x("mousedown",ye(ee.x,ee.y,1)));try{N.setPointerCapture?.(we)}catch{}if(l)try{N.dispatchEvent(new m("dragstart",{bubbles:!0,cancelable:!0,clientX:ee.x,clientY:ee.y,dataTransfer:l}))}catch{}let E=null;for(let R=1;R<=Be;R++){let I=ee.x+(se.x-ee.x)*R/Be,D=ee.y+(se.y-ee.y)*R/Be,V=f.elementFromPoint(I,D)||F||f.body;if(V.dispatchEvent(new h("pointermove",Ee(I,D,1))),V.dispatchEvent(new x("mousemove",ye(I,D,1))),l)try{E&&E!==V&&E.dispatchEvent(new m("dragleave",{bubbles:!0,cancelable:!0,clientX:I,clientY:D,dataTransfer:l})),V.dispatchEvent(new m("dragenter",{bubbles:!0,cancelable:!0,clientX:I,clientY:D,dataTransfer:l})),V.dispatchEvent(new m("dragover",{bubbles:!0,cancelable:!0,clientX:I,clientY:D,dataTransfer:l})),E=V}catch{}R%3===0&&await Ct()}let k=F||f.elementFromPoint(se.x,se.y)||f.body;if(l)try{k.dispatchEvent(new m("drop",{bubbles:!0,cancelable:!0,clientX:se.x,clientY:se.y,dataTransfer:l}))}catch{}if(k.dispatchEvent(new h("pointerup",Ee(se.x,se.y,0))),k.dispatchEvent(new x("mouseup",ye(se.x,se.y,0))),l)try{N.dispatchEvent(new m("dragend",{bubbles:!0,cancelable:!0,clientX:se.x,clientY:se.y,dataTransfer:l}))}catch{}return{success:!0,method:"html5+pointer-dragdrop",details:`steps=${Be};source=${String(C)}`}}catch(f){return{success:!1,method:"drag-drop",details:f?.message||"drag-drop failed",allowFallback:!0}}}async function dn(c,y,b,g){try{let f=G(c,y),d=X(f,b),h=d.PointerEvent||PointerEvent,x=d.MouseEvent||MouseEvent;Ve(c,f,d);let m=ie(c,f,d),T={x:m.x,y:m.y},C=c.getBoundingClientRect(),N=Number.isFinite(Number(g?.distance))?Number(g.distance):Math.min(Math.max(80,Math.min(C.width,C.height)),220),F=String(g?.direction||"RIGHT").toUpperCase(),Y=T.x,Q=T.y;F==="LEFT"&&(Y-=N),F==="RIGHT"&&(Y+=N),F==="UP"&&(Q-=N),F==="DOWN"&&(Q+=N);let pe=(I,D)=>({x:Math.max(2,Math.min(I,d.innerWidth-3)),y:Math.max(2,Math.min(D,d.innerHeight-3))}),J=pe(T.x,T.y),ee=pe(Y,Q),se=700+Date.now()%1e4,we=Math.max(10,Math.min(28,Number(g?.steps)||16)),Be=(I,D)=>({bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:I,clientY:D,pageX:I+(d.scrollX||0),pageY:D+(d.scrollY||0)}),ue=(I,D,V)=>({...Be(I,D),pointerId:se,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:V?.5:0,buttons:V,button:0}),Ee=(I,D,V)=>({...Be(I,D),buttons:V,button:0}),ye=f.elementFromPoint(J.x,J.y)||c;ye.dispatchEvent(new h("pointerdown",ue(J.x,J.y,1))),ye.dispatchEvent(new x("mousedown",Ee(J.x,J.y,1)));let l=d.Touch,E=d.TouchEvent,k=!!l&&!!E;if(k)try{let I=new l({identifier:se,target:ye,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});ye.dispatchEvent(new E("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[I],targetTouches:[I],changedTouches:[I]}))}catch{}for(let I=1;I<=we;I++){let D=J.x+(ee.x-J.x)*I/we,V=J.y+(ee.y-J.y)*I/we,K=f.elementFromPoint(D,V)||c;if(K.dispatchEvent(new h("pointermove",ue(D,V,1))),K.dispatchEvent(new x("mousemove",Ee(D,V,1))),k)try{let ae=new l({identifier:se,target:K,clientX:D,clientY:V,pageX:D,pageY:V,screenX:D,screenY:V,radiusX:1,radiusY:1,rotationAngle:0,force:1});K.dispatchEvent(new E("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[ae],targetTouches:[ae],changedTouches:[ae]}))}catch{}I%3===0&&await Ct()}let R=f.elementFromPoint(ee.x,ee.y)||c;if(R.dispatchEvent(new h("pointerup",ue(ee.x,ee.y,0))),R.dispatchEvent(new x("mouseup",Ee(ee.x,ee.y,0))),k)try{let I=new l({identifier:se,target:R,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:0});R.dispatchEvent(new E("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[I]}))}catch{}return{success:!0,method:"swipe",details:`dir=${F};dist=${N};steps=${we};hitOk=${m.ok}`}}catch(f){return{success:!1,method:"swipe",details:f?.message||"swipe failed",allowFallback:!0}}}async function Pe(c,y,b,g){try{let f=c||y.body,d=G(f,y),h=X(d,b),x=h.PointerEvent||PointerEvent,m=h.WheelEvent||WheelEvent;Ve(f,d,h);let T=Number.isFinite(Number(g?.scale))?Number(g.scale):1.2,C=f.getBoundingClientRect(),N=C.left+C.width/2,F=C.top+C.height/2,Y=24,Q=Math.max(6,Math.min(200,Y*T)),pe=Math.max(6,Math.min(18,Number(g?.steps)||10)),J=h.Touch,ee=h.TouchEvent;if(!!J&&!!ee)try{let ue=(k,R)=>new J({identifier:k,target:f,clientX:R,clientY:F,pageX:R,pageY:F,screenX:R,screenY:F,radiusX:1,radiusY:1,rotationAngle:0,force:1}),Ee=ue(911,N-Y),ye=ue(912,N+Y);f.dispatchEvent(new ee("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[Ee,ye],targetTouches:[Ee,ye],changedTouches:[Ee,ye]}));for(let k=1;k<=pe;k++){let R=Y+(Q-Y)*k/pe,I=ue(911,N-R),D=ue(912,N+R);f.dispatchEvent(new ee("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[I,D],targetTouches:[I,D],changedTouches:[I,D]})),k%2===0&&await Ct()}let l=ue(911,N-Q),E=ue(912,N+Q);f.dispatchEvent(new ee("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[l,E]}))}catch{}try{let ue=(Ee,ye,l)=>({bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:ye,clientY:F,pointerId:Ee,pointerType:"touch",isPrimary:Ee===821,width:1,height:1,pressure:l?.5:0,buttons:l,button:0});f.dispatchEvent(new x("pointerdown",ue(821,N-Y,1))),f.dispatchEvent(new x("pointerdown",ue(822,N+Y,1)));for(let Ee=1;Ee<=pe;Ee++){let ye=Y+(Q-Y)*Ee/pe;f.dispatchEvent(new x("pointermove",ue(821,N-ye,1))),f.dispatchEvent(new x("pointermove",ue(822,N+ye,1))),Ee%2===0&&await Ct()}f.dispatchEvent(new x("pointerup",ue(821,N-Q,0))),f.dispatchEvent(new x("pointerup",ue(822,N+Q,0)))}catch{}try{let we=T>=1?-120:120;f.dispatchEvent(new m("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:N,clientY:F,ctrlKey:!0,deltaY:we,deltaMode:m.DOM_DELTA_PIXEL}))}catch{}return{success:!0,method:"pinch-zoom",details:`scale=${T};steps=${pe}`}}catch(f){return{success:!1,method:"pinch-zoom",details:f?.message||"pinch-zoom failed",allowFallback:!0}}}async function yn(c,y,b,g=800){try{let f=G(c,y),d=X(f,b),h=d.PointerEvent||PointerEvent,x=d.MouseEvent||MouseEvent,m=d.FocusEvent||FocusEvent;Ve(c,f,d);let T=ie(c,f,d),C=c;!T.ok&&Ge(T.hit,d)?C=T.hit.closest?.('a,button,input,select,textarea,summary,[role="button"],[role="link"],[onclick]')||T.hit:Ge(T.hit,d)&&(C=T.hit);let N=Zt(C,f,d),F=T.x,Y=T.y,Q=1+Date.now()%1e4,pe={bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:F,clientY:Y,pageX:F+(d.scrollX||0),pageY:Y+(d.scrollY||0),screenX:F+(d.screenX||0),screenY:Y+(d.screenY||0)},J={...pe,pointerId:Q,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:0,buttons:0,button:0};try{C.dispatchEvent(new h("pointerover",J)),C.dispatchEvent(new h("pointerenter",{...J,bubbles:!1}))}catch{}try{C.dispatchEvent(new x("mouseover",pe)),C.dispatchEvent(new x("mouseenter",{...pe,bubbles:!1}))}catch{}try{C.focus?.({preventScroll:!0}),C.dispatchEvent(new m("focus",{bubbles:!0,composed:!0})),C.dispatchEvent(new m("focusin",{bubbles:!0,composed:!0}))}catch{}try{C.dispatchEvent(new h("pointerdown",{...J,buttons:1,pressure:.5}))}catch{}try{C.dispatchEvent(new x("mousedown",{...pe,buttons:1,button:0}))}catch{}try{let ue=d.Touch,Ee=d.TouchEvent;if(typeof ue<"u"&&typeof Ee<"u"){let ye=new ue({identifier:Q,target:C,clientX:F,clientY:Y,pageX:F+(d.scrollX||0),pageY:Y+(d.scrollY||0),screenX:F+(d.screenX||0),screenY:Y+(d.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:1});C.dispatchEvent(new Ee("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[ye],targetTouches:[ye],changedTouches:[ye]}))}}catch{}let ee=Number(g),se=Number.isFinite(ee)&&ee>0?ee:800,we=f.hidden?Math.max(se,1200):se;await Je(we,f);try{C.dispatchEvent(new x("contextmenu",{...pe,button:2,buttons:2}))}catch{}try{C.dispatchEvent(new h("pointerup",{...J,buttons:0,pressure:0}))}catch{}try{C.dispatchEvent(new x("mouseup",{...pe,buttons:0,button:0}))}catch{}try{let ue=d.Touch,Ee=d.TouchEvent;if(typeof ue<"u"&&typeof Ee<"u"){let ye=new ue({identifier:Q,target:C,clientX:F,clientY:Y,pageX:F+(d.scrollX||0),pageY:Y+(d.scrollY||0),screenX:F+(d.screenX||0),screenY:Y+(d.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:0});C.dispatchEvent(new Ee("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[ye]}))}}catch{}let Be=await Ue(C,f,d,N);return{success:!0,method:"long-press",details:`holdMs=${we};verified=${Be};hitOk=${T.ok};target=${C.tagName.toLowerCase()}`}}catch(f){return{success:!1,method:"long-press",details:f?.message||"long-press failed",allowFallback:!0}}}function Gt(c,y,b,g,f){try{let d=G(b,g),x=X(d,f).KeyboardEvent||KeyboardEvent,m=b||d.activeElement||d.body||d.documentElement;m.focus?.();let T={key:c,code:en(c),bubbles:!0,cancelable:!0,ctrlKey:y?.includes("CTRL"),altKey:y?.includes("ALT"),shiftKey:y?.includes("SHIFT"),metaKey:y?.includes("META")},C=m.dispatchEvent(new x("keydown",T)),N=m.dispatchEvent(new x("keypress",T)),F=m.dispatchEvent(new x("keyup",T));if(c==="Enter"&&!!(C&&N&&F)){let Q=m.form||m.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 Jt(c,y,b){try{let g=c.innerText||c.value||"";if(!g)return{success:!1,method:"copy",details:"nothing to copy",allowFallback:!0};let f=G(c,y),d=X(f,b);if(d.navigator?.clipboard?.writeText)return await d.navigator.clipboard.writeText(g),{success:!0,method:"clipboard-copy"};let h=f.createRange();h.selectNodeContents(c);let x=d.getSelection?.()||(f.defaultView||window).getSelection?.();x?.removeAllRanges(),x?.addRange(h);let m=f.execCommand?.("copy")??!1;return x?.removeAllRanges(),{success:!!m,method:"execCommand-copy",allowFallback:!m}}catch(g){return{success:!1,method:"clipboard-copy",details:g.message,allowFallback:!0}}}async function fn(c,y,b,g){try{c.focus?.();let f=G(c,y),d=X(f,b);if(d.navigator?.clipboard?.readText){let x=await d.navigator.clipboard.readText();if(x)return await st(c,f,d,x,g)}return f.execCommand?.("paste")??!1?{success:!0,method:"execCommand-paste"}:{success:!1,method:"paste",details:"clipboard empty or denied",allowFallback:!0}}catch(f){return{success:!1,method:"paste",details:f.message,allowFallback:!0}}}function _n(c){return`${(c/1024).toFixed(1)}KB`}function Tn(c,y){if(c instanceof y.defaultView.HTMLInputElement){let h=c;if((h.type||"").toLowerCase()==="file")return h}let b=c.closest?.("label"),g=b?.htmlFor||c.htmlFor||"";if(g){let h=y.getElementById(g);if(h&&(h.type||"").toLowerCase()==="file")return h}if(b){let h=b.querySelector?.('input[type="file"]');if(h)return h}let f=c.closest?.("form");if(f){let h=f.querySelector?.('input[type="file"]');if(h)return h}let d=c.closest?.("div,section,main,article")||c.parentElement;if(d){let h=d.querySelector?.('input[type="file"]');if(h)return h}return null}function At(c,y,b){try{let g=b.HTMLInputElement?.prototype,f=g?Object.getOwnPropertyDescriptor(g,"files")?.set:void 0;if(!f){let d=Object.getPrototypeOf(c);for(;d&&!f;)f=Object.getOwnPropertyDescriptor(d,"files")?.set,d=Object.getPrototypeOf(d)}return f?(f.call(c,y),!0):(c.files=y,!0)}catch{try{return c.files=y,!0}catch{return!1}}}async function Ot(c,y,b,g,f,d){try{let{file_url:h,element_id:x,file_name:m}=c,T=null;if(f&&(T=Tn(f,y)),!T&&x!==void 0&&(T=y.querySelector(`input[type="file"][${at}*="[id=${x}]"]`)),!T){let R=y.querySelectorAll('input[type="file"]');for(let I of R){if(I.disabled)continue;let D=I.getBoundingClientRect();if(D.width>0&&D.height>0){T=I;break}}}if(!T)return{success:!1,method:"upload-file",details:"No file input found",allowFallback:!0};if(T.disabled)return{success:!1,method:"upload-file",details:"File input is disabled",allowFallback:!0};let C=G(T,y),N=X(C,b);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),Q=(g.mimeType||"application/octet-stream").split(";")[0].trim()||"application/octet-stream",pe;if(g.inlineB64&&typeof g.inlineB64=="string"){let R=Ha(g.inlineB64);if(R.byteLength!==Y)return{success:!1,method:"upload-file",details:`Inline bytes length mismatch: got=${R.byteLength} expected=${Y}`,allowFallback:!0};pe=R.buffer}else{let R=String(g.token);pe=await S(N,R,Y,9e4)}let J=N.Blob||Blob,ee=new J([pe],{type:Q}),se=m||g?.fileName;!se&&h&&typeof h=="string"&&(se=Us(h,N)),se=Fa(se||"upload");let we=N.File||File,Be=new we([ee],se,{type:Q,lastModified:Date.now()}),ue=N.Event||Event,Ee=N.DataTransfer||DataTransfer;if(!Ee)return{success:!1,method:"upload-file",details:"DataTransfer unavailable in this context",allowFallback:!0};let ye=new Ee;if(ye.items.add(Be),!At(T,ye.files,N))return{success:!1,method:"upload-file",details:"Failed to set input.files",allowFallback:!0};T.dispatchEvent(new ue("input",{bubbles:!0,composed:!0,cancelable:!0})),T.dispatchEvent(new ue("change",{bubbles:!0,composed:!0,cancelable:!0}));let E=tn(T);if(E){let R=Yt(E);if(R.onChange){let I=Xt("change",T,C,N);I.target.files=ye.files,R.onChange(I)}}let k=Rn(T);if(k){let R=Mt(k);if(R.change){let I=new ue("change",{bubbles:!0});I.target=T,I.target.files=ye.files,R.change(I)}}try{let R=N.jQuery||N.$;R&&typeof R=="function"&&R(T).triggerHandler?.("change")}catch{}return T.focus?.({preventScroll:!0}),await Te(C,N,2),{success:!0,method:"upload-file",details:`Uploaded ${se} (${_n(ee.size)}) [token]`}}catch(h){return{success:!1,method:"upload-file",details:h?.message||"Upload failed",allowFallback:!0}}}async function ut(c,y,b){let g=Array.isArray(c.path)?c.path:[];if(!g.length)return{success:!1,method:"dispatch_pointer_path",details:"Empty path",allowFallback:!0};let f=b.PointerEvent||PointerEvent,d=b.MouseEvent||MouseEvent,h=16;for(let x=0;x<g.length;x++){let m=g[x],T=Number(m.x)||0,C=Number(m.y)||0,N=Number(m.pressure)||(x===0||x===g.length-1?0:.5),F=y.elementFromPoint(T,C)||y.documentElement,Y={bubbles:!0,cancelable:!0,clientX:T,clientY:C,screenX:T,screenY:C,view:b};if(x===0?(F.dispatchEvent(new f("pointerdown",{...Y,pressure:N,pointerId:1,pointerType:"mouse"})),F.dispatchEvent(new d("mousedown",{...Y,button:0,buttons:1}))):(F.dispatchEvent(new f("pointermove",{...Y,pressure:N,pointerId:1,pointerType:"mouse"})),F.dispatchEvent(new d("mousemove",{...Y,button:0,buttons:1}))),x===g.length-1&&(F.dispatchEvent(new f("pointerup",{...Y,pressure:0,pointerId:1,pointerType:"mouse"})),F.dispatchEvent(new d("mouseup",{...Y,button:0,buttons:0}))),x<g.length-1){let Q=Number(m.timestamp)||0,pe=Number(g[x+1].timestamp)||0,J=Q&&pe?Math.max(0,Math.min(pe-Q,1e3)):h;J>0&&await Je(J,y)}}return{success:!0,method:"dispatch_pointer_path",details:`Dispatched ${g.length} point(s)`}}function Ut(c,y,b){let g=G(c,y),f=X(g,b),d=f.MouseEvent||MouseEvent;Ve(c,g,f),te(c,g,f),te(c,g,f);let h=c.getBoundingClientRect();return c.dispatchEvent(new d("dblclick",{bubbles:!0,cancelable:!0,clientX:h.left+h.width/2,clientY:h.top+h.height/2,detail:2,view:f})),{success:!0,method:"dblclick"}}function he(c,y,b){let g=G(c,y),f=X(g,b),d=f.PointerEvent||PointerEvent,h=f.MouseEvent||MouseEvent;Ve(c,g,f);let x=c.getBoundingClientRect(),m=x.left+x.width/2,T=x.top+x.height/2,C={bubbles:!0,cancelable:!0,composed:!0,view:f,clientX:m,clientY:T,button:2,buttons:2};return c.dispatchEvent(new d("pointerdown",C)),c.dispatchEvent(new h("mousedown",C)),c.dispatchEvent(new d("pointerup",{...C,buttons:0})),c.dispatchEvent(new h("mouseup",{...C,buttons:0})),c.dispatchEvent(new h("contextmenu",C)),{success:!0,method:"contextmenu"}}function Zt(c,y,b){let g=G(c,y),f=X(g,b),d=c,h=c.getBoundingClientRect();return{href:String(f.location.href),hash:String(f.location.hash),ariaExpanded:c.getAttribute("aria-expanded"),ariaPressed:c.getAttribute("aria-pressed"),ariaDisabled:c.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:bo(g),rect:{w:h.width,h:h.height}}}function qt(c,y){let b=Math.abs(c.rect.w-y.rect.w)>2||Math.abs(c.rect.h-y.rect.h)>2;return c.href!==y.href||c.hash!==y.hash||c.ariaExpanded!==y.ariaExpanded||c.ariaPressed!==y.ariaPressed||c.ariaDisabled!==y.ariaDisabled||c.disabled!==y.disabled||c.open!==y.open||c.checked!==y.checked||c.value!==y.value||c.active!==y.active||b}async function Ue(c,y,b,g){await Promise.resolve();let f=G(c,y),d=X(f,b);y.hidden||await Ct();let h=Zt(c,f,d);return qt(g,h)}function tt(c,y,b){c.focus?.({preventScroll:!0});let g=G(c,y),f=X(g,b),x=c.getAttribute("role")==="button"||vi(c,f)||c.tagName.toLowerCase()==="button"?[" ","Enter"]:["Enter"],m=f.KeyboardEvent||KeyboardEvent;for(let T of x){let C={key:T,code:T===" "?"Space":"Enter",bubbles:!0,cancelable:!0,composed:!0};c.dispatchEvent(new m("keydown",C)),c.dispatchEvent(new m("keypress",C)),c.dispatchEvent(new m("keyup",C))}return{success:!0,method:"keyboard-activate"}}async function Vr(c,y,b,...g){let f=null;for(let d of g){let h=G(c,y),x=X(h,b),m=Zt(c,h,x),T=d();if(!T||!T.success)continue;if(await Ue(c,h,x,m))return{...T,details:(T.details?T.details+";":"")+"verified=true"};f=T}return f?{...f,details:(f.details?f.details+";":"")+"verified=false"}:{success:!1,method:"all-strategies-unverified",details:"no verified effect",allowFallback:!0}}function vn(...c){for(let y of c)try{let b=y();if(b&&b.success)return b}catch{}return{success:!1,method:"all-strategies-failed",allowFallback:!0}}function Ve(c,y,b){let g=G(c,y),f=X(g,b),d=c.getBoundingClientRect();d.top>=0&&d.left>=0&&d.bottom<=f.innerHeight&&d.right<=f.innerWidth||(c.scrollIntoView({behavior:"auto",block:"center",inline:"center"}),c.offsetHeight)}function xn(c,y,b,g){let f=G(c,y),h=X(f,b).KeyboardEvent||KeyboardEvent;for(let x of g){let m=String(x??""),T="";/^[a-z]$/i.test(m)?T=`Key${m.toUpperCase()}`:/^[0-9]$/.test(m)?T=`Digit${m}`:m===" "&&(T="Space");let C=m.length===1?m.charCodeAt(0):0,N={key:m,code:T,bubbles:!0,cancelable:!0,composed:!0,keyCode:C,which:C};c.dispatchEvent(new h("keydown",N)),c.dispatchEvent(new h("keypress",N)),c.dispatchEvent(new h("keyup",N))}}function Gn(c,y,b){let g=G(c,y),d=X(g,b).KeyboardEvent||KeyboardEvent,h={key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0,composed:!0},x=c.dispatchEvent(new d("keydown",h)),m=c.dispatchEvent(new d("keypress",h)),T=c.dispatchEvent(new d("keyup",h));if(!!(x&&m&&T)){let N=c.form||c.closest?.("form");N?.requestSubmit?.()??N?.submit?.()}}function en(c){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"}[c]||`Key${c.toUpperCase()}`}let qn=new MessageChannel,Yn=[];qn.port1.onmessage=()=>{let c=Yn.shift();c&&c()};function Ct(){return new Promise(c=>{Yn.push(c),qn.port2.postMessage(0)})}function tn(c){let y=g=>{if(!g)return null;let f=Object.keys(g);for(let d of f)if(d.startsWith("__reactFiber")||d.startsWith("__reactInternalInstance")||d.includes("reactFiber")||d.includes("reactProps")||d.includes("reactEventHandlers")||/^__r\d+/.test(d))return g[d];return null},b=c;for(let g=0;g<4&&b;g++){let f=y(b);if(f)return f;b=b.parentElement}return null}function Yt(c){let y={},b=c,g=0;for(;b&&g++<10;){let f=[b.memoizedProps,b.pendingProps,b.stateNode?.props,b._memoizedProps,b._pendingProps,b.alternate?.memoizedProps].filter(Boolean);for(let d of f)if(!(!d||typeof d!="object"))for(let h in d)h.startsWith("on")&&typeof d[h]=="function"&&(y[h]=d[h]);if(Object.keys(y).length)break;b=b.return||b.alternate}return y}function fr(c,y){let b=c;for(;b;){if(b._reactRootContainer||b.__reactContainer||b.hasAttribute("data-reactroot")||b.hasAttribute("data-react-root")||["root","app","__next"].includes(b.id))return b;b=b.parentElement}return G(c,y).querySelector("#root,#app,#__next,[data-reactroot],[data-react-root]")}function Xt(c,y,b,g){let f=G(y,b),d=X(f,g),h=d.MouseEvent||MouseEvent,x=y.getBoundingClientRect(),m=new h(c,{bubbles:!0,cancelable:!0,view:d,clientX:x.left+x.width/2,clientY:x.top+x.height/2});return{type:c,target:y,currentTarget:y,bubbles:!0,cancelable:!0,nativeEvent:m,isTrusted:!0,preventDefault(){m.preventDefault()},stopPropagation(){m.stopPropagation()}}}function Rn(c){let y=c;if(y.__vue__)return y.__vue__;if(y.__vueParentComponent)return y.__vueParentComponent;if(y._vnode)return y._vnode;let b=c.parentElement;for(let g=0;g<3&&b;g++){let f=b;if(f.__vue__||f.__vueParentComponent||f._vnode)return f.__vue__||f.__vueParentComponent||f._vnode;b=b.parentElement}return null}function Mt(c){let y={};if(c?.$listeners&&Object.assign(y,c.$listeners),c?._events)for(let b in c._events){let g=c._events[b];y[b]=Array.isArray(g)?g[0]:g}if(c?.props)for(let b in c.props)b.startsWith("on")&&typeof c.props[b]=="function"&&(y[b.substring(2).toLowerCase()]=c.props[b]);if(c?.vnode?.props)for(let b in c.vnode.props)b.startsWith("on")&&typeof c.vnode.props[b]=="function"&&(y[b.substring(2).toLowerCase()]=c.vnode.props[b]);return y}})();function Va(){let e=window,t=e.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__";e[t]?.actions?.execute}async function $a(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 To(e,t,n={}){let{rootNodes:r,semanticNodes:o}=Is(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 a=Number(i);if(!Number.isFinite(a))continue;let u=Rr(a);u&&(s[a]=t.getFrameworkMetadata(u))}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(p=document,_=window){$(this,"doc");$(this,"win");$(this,"viewport");$(this,"lastDetectedPrimary",null);$(this,"detectionCache",new Map);$(this,"lastDetectionTime",0);$(this,"CACHE_TTL",5e3);this.doc=p,this.win=_,this.viewport={width:_.innerWidth,height:_.innerHeight},this.updateViewport()}getValidPrimary(){return this.lastDetectedPrimary&&!this.doc.contains(this.lastDetectedPrimary)&&(this.lastDetectedPrimary=null),this.lastDetectedPrimary}async handleCommand(p){switch(p.action){case"detectPrimary":{let _=this.detectPrimaryScrollable();if(!_)return null;let{target:A,isRoot:S}=this.getScrollContext(_.element),M=A.scrollHeight,O=Kt(),W=S&&O?O.innerHeight:A.clientHeight,q=Math.max(0,M-W),U=A.scrollTop;return{selector:_.selector,score:_.score,type:_.type,metrics:{scrollTop:U,scrollHeight:M,clientHeight:W,isAtTop:U<=5,isAtBottom:U>=q-5}}}case"scrollTo":if(!p.direction)throw new Error("scrollTo requires direction");return this.scrollToDirection(p.direction,p.options);case"scrollBy":if(!p.direction)throw new Error("scrollBy requires direction");return this.scrollByAmount(p.direction,p.options);case"scrollElement":if(!p.selector)throw new Error("scrollElement requires selector");return this.scrollElementIntoView(p.selector,p.position,p.options);case"getMetrics":return this.getScrollMetrics();default:throw new Error(`Unknown command: ${p.action}`)}}updateViewport(){this.viewport={width:this.win.innerWidth,height:this.win.innerHeight}}async execute(p){return this.handleCommand(p)}detectPrimaryScrollable(){if(Date.now()-this.lastDetectionTime<this.CACHE_TTL&&this.detectionCache.size>0){let S=Array.from(this.detectionCache.values()).sort((M,O)=>O.score-M.score)[0];if(S)return this.lastDetectedPrimary=S.element,S}this.updateViewport();let p=this.collectScrollableCandidates();if(p.length===0){let S=this.doc.scrollingElement||this.doc.documentElement||this.doc.body;if(!S)return null;let M=this.buildFeatures(S),O=G(S,this.doc),W={element:S,selector:sr(S,O),score:.5,features:M,type:"document"};return this.detectionCache.clear(),this.detectionCache.set(W.selector,W),this.lastDetectionTime=Date.now(),this.lastDetectedPrimary=S,W}let _=this.scoreCandidates(p);if(_.length===0)return null;this.detectionCache.clear();for(let S of _)this.detectionCache.set(S.selector,S);this.lastDetectionTime=Date.now();let A=_[0];return A&&(this.lastDetectedPrimary=A.element),A||null}collectAllElementsDeep(p,_=15e4){let A=[],S=[],M=p.body||p.documentElement;M&&S.push(M);let O=0,W=q=>{try{let U=this.win.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",B=this.win[U]?.shadow?.getRoot;if(typeof B=="function"){let z=B(q);if(z)return z}}catch{}try{return q.shadowRoot||null}catch{return null}};for(;S.length&&!(++O>_);){let q=S.pop();if(vt(q)){let B=q.children;for(let z=B.length-1;z>=0;z--)S.push(B[z]);continue}let U=q,P=oe(U);Ge(U,P)&&A.push(U);try{let B=W(U);B&&S.push(B)}catch{}for(let B=U.lastElementChild;B;B=B.previousElementSibling)S.push(B)}return A}collectScrollableCandidates(){let p=[],_=new WeakSet,A=[this.doc.scrollingElement,this.doc.documentElement,this.doc.body];for(let M of A){if(!M||_.has(M))continue;let O=this.isScrollable(M);(O.vertical||O.horizontal)&&(p.push(M),_.add(M))}let S=this.collectAllElementsDeep(this.doc);for(let M of Array.from(S)){if(_.has(M))continue;let O=M.getBoundingClientRect(),W=this.win.getComputedStyle(M);if(!this.isElementRendered(M,O,W)||!this.isScrollable(M).vertical)continue;let U=40,P=this.viewport.width*.15;if(O.height<U||O.width<P){let B=(M.className||"").toLowerCase().includes("scroll"),z=W.overflowY==="auto"||W.overflowY==="scroll"||W.overflow==="auto"||W.overflow==="scroll";if(!B&&!z)continue}p.push(M),_.add(M)}return p}isElementRendered(p,_,A){if(A.display==="none"||A.visibility==="hidden")return!1;let S=parseFloat(A.opacity||"1");return!(!Number.isNaN(S)&&S<.01||_.width<=1||_.height<=1)}isScrollable(p){let _=this.win.getComputedStyle(p),A=_.overflowY,S=_.overflowX,M=this.doc.scrollingElement,O=p===this.doc.documentElement||p===this.doc.body||!!M&&p===M,W=p.scrollHeight,q=p.clientHeight,U=p.scrollWidth,P=p.clientWidth;if(O){let ne=this.doc.documentElement,de=this.doc.body;W=Math.max(ne?ne.scrollHeight:0,de?de.scrollHeight:0),q=this.win.innerHeight}let B=W-q>8,z=U-P>8,te=A==="auto"||A==="scroll"||A==="overlay",re=S==="auto"||S==="scroll"||S==="overlay";return{vertical:O?B:B&&te,horizontal:O?z:z&&re,byOverflow:te||re}}calculateVisibleIntersection(p){let _=Math.max(0,p.left),A=Math.max(0,p.top),S=Math.min(this.viewport.width,p.right),M=Math.min(this.viewport.height,p.bottom),O=Math.max(0,S-_),W=Math.max(0,M-A);return{width:O,height:W,area:O*W}}analyzeTextContent(p,_=2e3){let A=0,S=0,M=p.ownerDocument||this.doc,W=(M.defaultView||this.win).NodeFilter||NodeFilter,q=M.createTreeWalker(p,W.SHOW_ELEMENT|W.SHOW_TEXT,null),U=0,P=q.currentNode,B=[];for(;P&&U<_;){if(P.nodeType===Node.TEXT_NODE){let j=(P.textContent||"").replace(/\s+/g,"").length;if(j>0){A+=j;let le=P.parentElement;le&&le.closest("a")&&(S+=j)}}else P.nodeType===Node.ELEMENT_NODE&&B.push(P);U++,P=q.nextNode()}let z=B.length||1,te=A/z,re=A>0?S/A:0;return{textChars:A,linkChars:S,textDensity:te,linkDensity:re}}calculateRepetitionScore(p){let _=Array.from(p.children);if(_.length<3)return 0;let A=_.slice(0,50),S=new Map,M=new Map,O=new Map;for(let ie of A){let j=oe(ie);if(!Ge(ie,j))continue;let le=ie.getBoundingClientRect();if(le.height<5||le.width<this.viewport.width*.1)continue;let ne=Math.round(le.height/10)*10,de=Math.round(le.width/10)*10;S.set(ne,(S.get(ne)||0)+1),M.set(de,(M.get(de)||0)+1);let be=(ie.className||ie.tagName).toString();O.set(be,(O.get(be)||0)+1)}let W=A.length||1,q=Math.max(0,...S.values()),U=Math.max(0,...M.values()),P=Math.max(0,...O.values()),B=q/W,z=U/W,te=P/W,re=.4*B+.3*z+.3*te;return Math.min(1,Math.max(0,re))}calculateSemanticScore(p){let _=0,A=null,S=!1,M=(p.getAttribute("role")||"").toLowerCase(),O=p.tagName.toLowerCase(),W=(p.id||"").toLowerCase(),q=(p.className||"").toLowerCase(),U=`${M} ${O} ${W} ${q}`;return(O==="main"||M==="main")&&(_+=1.2,A="article"),O==="article"&&(_+=1,A=A||"article"),(M==="feed"||U.includes("feed"))&&(_+=1,A="feed"),(M==="log"||U.includes("chat")||U.includes("messages"))&&(_+=1,A="chat"),U.includes("content")&&(_+=.5),(U.includes("results")||U.includes("list"))&&(_+=.4),(U.includes("job")||U.includes("jobs"))&&(_+=.4),(O==="nav"||M==="navigation"||U.includes("sidebar"))&&(_-=1,S=!0),(O==="aside"||M==="complementary")&&(_-=.7,S=!0),(O==="footer"||M==="contentinfo"||U.includes("footer"))&&(_-=.8,S=!0),U.includes("header")&&(_-=.6),_=Math.max(-1,Math.min(1,_)),{semanticScore:_,typeHint:A,navLike:S}}detectScrollListeners(p){return[p.querySelector('[class*="infinite"]'),p.querySelector('[class*="load-more"]'),p.querySelector("[data-infinite]"),p.querySelector('[loading="lazy"]'),p.querySelector(".observer-target"),p.querySelector("[data-scroll]")].some(A=>A!==null)}buildFeatures(p){let _=p.getBoundingClientRect(),A=this.win.getComputedStyle(p),S=this.calculateVisibleIntersection(_),M=this.viewport.width*this.viewport.height||1,O=S.area/M,W=this.viewport.width>0?S.width/this.viewport.width:0,q=_.top+_.height/2,U=this.viewport.height/2||1,P=Math.min(1,Math.abs(q-U)/U),B=this.isScrollable(p),z=this.doc.scrollingElement,te=p===this.doc.documentElement||p===this.doc.body||!!z&&p===z,re=p.scrollHeight,ie=p.clientHeight;if(te){let Me=this.doc.documentElement,Ze=this.doc.body;re=Math.max(Me?Me.scrollHeight:0,Ze?Ze.scrollHeight:0),ie=this.win.innerHeight}let j=Math.max(0,re-ie),le=j*S.width,ne=this.analyzeTextContent(p),de=this.calculateRepetitionScore(p),be=this.calculateSemanticScore(p),ht=p.contains(this.doc.activeElement),Te=this.detectScrollListeners(p),Oe=parseInt(A.zIndex||"0",10),He=Number.isFinite(Oe)?Oe:0;return{geometry:{viewportCoverage:O,widthProminence:W,centerDistance:P,scrollCapacity:j,scrollSurface:le,zIndex:He},content:{textDensity:ne.textDensity,linkDensity:ne.linkDensity,repetitionScore:de,semanticScore:be.semanticScore},interaction:{hasScrollListeners:Te,hasFocus:ht,recentActivity:ht?1:0}}}inferElementType(p,_,A,S){if(A)return A;let M=(p.getAttribute("role")||"").toLowerCase(),O=(p.className||"").toLowerCase(),W=p.tagName.toLowerCase(),q=_.geometry,U=_.content;if(M==="log"||O.includes("chat")||O.includes("messages"))return"chat";let P=this.win.getComputedStyle(p);if((P.position==="fixed"||P.position==="absolute")&&q.zIndex>100&&q.viewportCoverage>.2&&q.centerDistance<.4)return"modal";if(M==="feed"||U.repetitionScore>.3&&q.scrollCapacity>400&&q.widthProminence>=.25)return"feed";if(W==="article"||U.textDensity>40&&U.linkDensity<.4&&q.widthProminence>.4)return"article";if(S||q.widthProminence<.3&&U.linkDensity>.3)return"sidebar";let z=this.doc.scrollingElement;return p===this.doc.documentElement||p===this.doc.body||z&&p===z?"document":"unknown"}scoreCandidates(p){let _=[],A=[],S=[],M=[],O=[],W=[];for(let te of p){let re=this.buildFeatures(te),ie=re.content.semanticScore,j=this.calculateSemanticScore(te),le=this.inferElementType(te,re,j.typeHint,j.navLike);W.push({element:te,features:{geometry:{...re.geometry},content:{...re.content,semanticScore:j.semanticScore},interaction:re.interaction},type:le,navLike:j.navLike,semanticScore:j.semanticScore}),A.push(re.geometry.scrollSurface),S.push(re.content.textDensity),M.push(Math.abs(j.semanticScore)),O.push(re.content.repetitionScore)}let q=Math.max(0,...A),U=Math.max(0,...S),P=Math.max(0,...M),B=Math.max(0,...O),z=-1/0;for(let te of W){let{element:re,features:ie,type:j,navLike:le,semanticScore:ne}=te,de=ie.geometry,be=ie.content,ht=ie.interaction,Te=q>0?de.scrollSurface/q:0,Oe=U>0?be.textDensity/U:0,He=P>0?(ne/P+1)/2:.5,Me=j==="feed"||be.repetitionScore>.3&&de.scrollCapacity>400,Ze=be.linkDensity>.5?(be.linkDensity-.5)/.5:0,st=Me?0:Ze,yt=(Me?1:.5)*be.repetitionScore*Math.min(1,de.scrollCapacity/4e3),it={feed:.2,chat:.2,article:.08,modal:.08,document:.05,sidebar:-.12,unknown:0}[j]||0,ke=0;ke+=de.viewportCoverage*.18,ke+=de.widthProminence*.15,ke+=(1-de.centerDistance)*.07,ke+=Te*.22,ke+=yt*.18,ke+=Oe*.08,ke+=(B>0?be.repetitionScore/B:0)*.05,ke+=He*.07,ke-=st*.05,ht.hasFocus&&(ke+=.05),ht.hasScrollListeners&&(ke+=.05),ke+=it,le&&(ke-=.05);let Le=Math.max(0,Math.min(1,ke));Le>z&&(z=Le),_.push({element:re,selector:sr(re,G(re)),score:Le,features:ie,type:j})}if(_.sort((te,re)=>re.score-te.score),_.length>=2){let te=_[0],re=_[1];Math.abs(te.score-re.score)<.08&&te.type==="article"&&re.type==="feed"&&(_[0]=re,_[1]=te)}return _}getScrollContext(p){let _=document.scrollingElement;return p===document.documentElement||p===document.body||!!_&&p===_?{target:_||document.documentElement||document.body,isRoot:!0}:{target:p,isRoot:!1}}async scrollToDirection(p,_){let A=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!A)return{success:!1,error:"No scrollable element found"};let{target:S,isRoot:M}=this.getScrollContext(A),O=G(S),W=X(O),q=_?.isTabActive??!O.hidden,U=_?.behavior,P=q&&U==="smooth",B=M?Math.max(O.documentElement?O.documentElement.scrollHeight:0,O.body?O.body.scrollHeight:0):S.scrollHeight,z=M?W.innerHeight:S.clientHeight,te=Math.max(0,B-z),re=()=>M?W.scrollY:S.scrollTop,ie=j=>{if(P)try{M?W.scrollTo({top:j,behavior:"smooth"}):S.scrollTo({top:j,behavior:"smooth"})}catch{M?(O.scrollingElement||O.documentElement||O.body).scrollTop=j:S.scrollTop=j}else if(M){let le=O.scrollingElement||O.documentElement||O.body;le.scrollTop=j}else S.scrollTop=j};switch(p){case Fe.TOP:return ie(0),{success:!0,scrollTop:0,isAtTop:!0};case Fe.BOTTOM:return ie(te),{success:!0,scrollTop:te,isAtBottom:!0};default:return{success:!1,error:`Unknown direction: ${p}`}}}async scrollByAmount(p,_){let A=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!A)return{success:!1,error:"No scrollable element found"};let{target:S,isRoot:M}=this.getScrollContext(A),O=_?.isTabActive??!document.hidden,W=_?.behavior,q=O&&W==="smooth",U=Kt(),P=M&&U?U.innerHeight:S.clientHeight,B=M&&U?U.innerWidth:S.clientWidth,z=_?.amount??P*.8,te=M?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):S.scrollHeight,re=M&&U?U.innerHeight:S.clientHeight,ie=Math.max(0,te-re),j=ne=>{if(q)try{M?U?.scrollTo({top:ne,behavior:"smooth"}):S.scrollTo({top:ne,behavior:"smooth"})}catch{let de=document.scrollingElement||document.documentElement||document.body;de.scrollTop=ne}else{let de=M?document.scrollingElement||document.documentElement||document.body:S;de.scrollTop=ne}},le=ne=>{if(q)try{S.scrollBy({left:ne,behavior:"smooth"})}catch{S.scrollLeft+=ne}else S.scrollLeft+=ne};switch(p){case Fe.DOWN:{let de=(M&&U?U.scrollY:S.scrollTop)+z;j(de);let be=M&&U?U.scrollY:S.scrollTop;return{success:!0,scrollTop:be,isAtTop:be<=5,isAtBottom:be>=ie-5}}case Fe.UP:{let ne=M&&U?U.scrollY:S.scrollTop,de=Math.max(0,ne-z);j(de);let be=M&&U?U.scrollY:S.scrollTop;return{success:!0,scrollTop:be,isAtTop:be<=5,isAtBottom:be>=ie-5}}case Fe.LEFT:{let ne=-(_?.amount??B*.8);return le(ne),{success:!0,scrollLeft:S.scrollLeft}}case Fe.RIGHT:{let ne=_?.amount??B*.8;return le(ne),{success:!0,scrollLeft:S.scrollLeft}}default:return{success:!1,error:`Unknown direction: ${p}`}}}normalizeScrollPosition(p){switch(p){case ot.START:return"start";case ot.END:return"end";case ot.NEAREST:return"nearest";case ot.CENTER:default:return"center"}}getScrollContainerForElement(p){let _=document.scrollingElement,A=p;for(;A&&A!==document.body&&A!==document.documentElement;){let O=getComputedStyle(A).overflowY,W=O==="auto"||O==="scroll"||O==="overlay",q=A.scrollHeight-A.clientHeight>8;if(W&&q)return{container:A,isRoot:!1};A=A.parentElement}return{container:_||document.documentElement||document.body,isRoot:!0}}scrollElementIntoView(p,_,A){let S=document.querySelector(p);if(!S)return{success:!1,error:`Element not found for selector: ${p}`};let{container:M,isRoot:O}=this.getScrollContainerForElement(S),W=oe(M),q=W?.DOMRect||DOMRect,U=O?new q(0,0,W.innerWidth??0,W.innerHeight??0):M.getBoundingClientRect(),P=S.getBoundingClientRect(),B=24,z=P.top>=U.top+B&&P.bottom<=U.bottom-B,te=A?.isTabActive??!document.hidden,re=A?.behavior,ie=te&&re==="smooth",j=this.normalizeScrollPosition(_);if(_===ot.NEAREST&&z)return{success:!0,alreadyVisible:!0,...this.getScrollMetricsForContainer(M,O)};try{S.scrollIntoView({behavior:ie?"smooth":"auto",block:j,inline:"nearest"})}catch{S.scrollIntoView()}let le=this.getScrollMetricsForContainer(M,O);return{success:!0,position:j,...le}}getScrollMetricsForContainer(p,_){let A=_?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):p.scrollHeight,S=G(p),M=oe(p),O=_&&M?M.innerHeight:p.clientHeight,W=Math.max(0,A-O),U=(_?S.scrollingElement||S.documentElement||S.body:p).scrollTop;return{scrollTop:U,scrollHeight:A,clientHeight:O,maxScroll:W,isAtTop:U<=5,isAtBottom:U>=W-5,scrollPercentage:W>0?U/W*100:0}}getScrollMetrics(){let p=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!p)return null;let{target:_,isRoot:A}=this.getScrollContext(p),S=G(_),M=X(S),O=A?Math.max(S.documentElement?S.documentElement.scrollHeight:0,S.body?S.body.scrollHeight:0):_.scrollHeight,W=A?M.innerHeight:_.clientHeight,q=Math.max(0,O-W),P=(A?S.scrollingElement||S.documentElement||S.body:_).scrollTop;return{element:sr(_,S),scrollTop:P,scrollHeight:O,clientHeight:W,maxScroll:q,isAtTop:P<=5,isAtBottom:P>=q-5,scrollPercentage:q>0?P/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,a=window[i],u=a&&typeof a=="object"?a:null;if(u){try{u.scroll=u.scroll||s}catch{}try{u.scroll||Object.defineProperty(u,"scroll",{value:s,writable:!1,configurable:!1,enumerable:!1})}catch{}}if(i!==n)try{!window[n]&&u&&Object.defineProperty(window,n,{value:u,writable:!1,configurable:!1,enumerable:!1})}catch{}})();var xu=/\[id=(\d+)\]/,qe;(function(e){e.HTML="html",e.PDF="pdf",e.GOOGLE_DOC="google_doc",e.GOOGLE_SHEET="google_sheet",e.PLAIN_TEXT="plain_text"})(qe||(qe={}));var Ga=new Map;function Ru(e){let t={};for(let n of Object.keys(e)){let r=e[Number(n)],o=r?.preservedAttributes?.[bt["rtrvr-label"]],s=r?.resourceLocator;if(typeof o=="string"&&typeof s=="string"){let i=o.match(xu);if(i?.[1]){let a=Number(i[1]);Number.isFinite(a)&&(t[a]=s)}}}return t}async function Ka(e,t,n={}){let r=e.ownerDocument||document,o=n.pageConfig||wo,s=String(r.contentType||"").trim().toLowerCase(),i=Su(s,r),a=Iu(i.documentType,s),u={url:r.URL,title:r.title,contentType:a},v=ku(o);if(i.documentType!==qe.HTML){let O=Number(o?.pageDataTimeoutMs),W=Number.isFinite(O)?Math.max(200,Math.floor(O)):9e3,q=Math.max(200,Math.min(W,Nt(v))),U=Lu(r,i.documentType,o,v),P=await or(U,q,r);if(!P.ok)return{...u,content:"",error:`non_html_timeout:${a}`,metadata:{extractionMethod:"timeout"}};let B=P.value||{},z=i.documentType===qe.GOOGLE_SHEET?ad(r):void 0;return{...u,...B,contentType:B.contentType||u.contentType,sheetInfo:B.sheetInfo||z}}if(o?.onlyTextContent)return{...u,contentType:nr,content:ko(r)};let p=Math.max(0,Math.min(3e3,Nt(v))),_=performance.now(),A=!1;if(!o?.disableAutoScroll&&p>80){let O=r.hidden?900:1500,W=Math.min(O,p);W>80&&(A=await od(r,{profile:"light",timeBudgetMs:W,delayMs:r.hidden?0:160,finalWaitMs:r.hidden?0:200}))}let S=Math.max(0,p-(performance.now()-_));S>80&&await id(r,{mode:"full",totalBudgetMs:Math.min(r.hidden?1400:1200,S),budgetMs:Math.min(r.hidden?650:850,S),maxPasses:r.hidden?1:2});let M=To(e,t,{includeFrames:n.includeFrames??!0,disableDomAnnotations:n.disableDomAnnotations??!0});return Ou(M.rootNodes,M.semanticNodes)?{...u,contentType:nr,content:ko(r),metadata:{scrollingPerformed:A}}:{...u,contentType:nr,roots:M.rootNodes,nodes:M.semanticNodes,elementLinkRecord:Ru(M.semanticNodes),metadata:{scrollingPerformed:A}}}function ku(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 Iu(e,t){switch(e){case qe.PDF:return Cs;case qe.GOOGLE_DOC:return Ns;case qe.GOOGLE_SHEET:return Ms;case qe.PLAIN_TEXT:return yo;case qe.HTML:default:return t||nr}}function Su(e,t){let n=e||String(t.contentType||"").toLowerCase();return Oa(n)?{documentType:qe.PDF}:Au(t)&&(Mu(t)||Cu(t.URL))?{documentType:qe.PDF}:$u(t)?{documentType:qe.GOOGLE_DOC}:Gu(t)?{documentType:qe.GOOGLE_SHEET}:n.includes(yo)?{documentType:qe.PLAIN_TEXT}:{documentType:qe.HTML}}function Au(e){try{let t=Uu(e);return Ds(t)?!0:!!t.querySelector?.('object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]')}catch{return!1}}function Cu(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 Mu(e){try{let t=e.body;return!t||t.querySelectorAll('embed[type="application/pdf"],embed[type="application/x-google-chrome-pdf"],object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]').length===0||(t.innerText||"").trim().length>40?!1:Array.from(t.children).filter(s=>!["SCRIPT","STYLE"].includes(String(s.tagName).toUpperCase())).length<=3}catch{return!1}}async function Lu(e,t,n,r){switch(t){case qe.PDF:return Nu(e,n,r);case qe.GOOGLE_DOC:return Du(e);case qe.GOOGLE_SHEET:return td(e,n);case qe.PLAIN_TEXT:return{content:ko(e),contentType:yo};case qe.HTML:default:return{content:ko(e),contentType:nr}}}async function Nu(e,t,n){Nt(n)>As+50&&await Ua(As,e,n);let o=(()=>{let p=Number(t?.pdfTextSelectionTimeoutMs),_=wo.pdfTextSelectionTimeoutMs;return Number.isFinite(p)?Math.max(150,Math.floor(p)):_})(),s=Nt(n),a=Number.isFinite(s)?Math.max(150,Math.min(o,Math.max(0,s-150))):o,u=await Hu(e,a),v=!!u.success&&!!(u.data||"").trim();return{content:v&&u.data||"",contentType:Cs,error:v?void 0:`pdf_extraction_failed:${u.reason||"unknown"}`}}async function Du(e){return{content:ed(),contentType:Ns}}function Ou(e,t){return!Array.isArray(e)||e.length===0||!t||Object.keys(t).length===0}function ko(e){return e.body?.innerText||e.body?.textContent||e.documentElement?.innerText||e.documentElement?.textContent||""}function Uu(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 Fu(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 Hu(e,t){let n=Number.isFinite(t)&&t>0?Math.floor(t):wo.pdfTextSelectionTimeoutMs,r=Fu(e),o=Ga.get(r)??"";if(o.trim().length>0)return{success:!0,data:o,reason:"ok"};let s=await Pu(e,n);return s.success&&s.data.trim()&&Ga.set(r,s.data),s}async function Pu(e,t){let n=e.defaultView||window,r=Bu(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="",a=p=>{if(s||!Wu(String(p.origin||""),e))return;let _=p.data;Vu(_,o)&&typeof _.selectedText=="string"&&_.selectedText.trim().length>0&&(i=_.selectedText,s=!0)};n.addEventListener("message",a);try{r.postMessage({type:"selectAll",requestId:o},"*")}catch{}let u=Date.now();for(;!s&&Date.now()-u<t;){try{r.postMessage({type:"getSelectedText",requestId:o},"*")}catch{}if(await Je(200,e),i.trim()){s=!0;break}}return n.removeEventListener("message",a),i.trim()?{success:!0,data:i,reason:"ok"}:{success:!1,data:"",reason:Date.now()-u>=t?"timeout":"no_response"}}function Bu(e){let t=Ds(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 Wu(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 Vu(e,t){return!(!e||typeof e!="object"||e.type!=="getSelectedTextReply"||typeof e.selectedText!="string"||e.requestId&&e.requestId!==t)}function $u(e){try{let t=e.defaultView||Kt();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 ir(e)!==null}function Gu(e){let n=(e.defaultView||Kt())?.location.href??"";return/^https:\/\/docs\.google\.com\/spreadsheets\/(?:u\/\d+\/)?d\/[a-zA-Z0-9_-]+/.test(n)}function qu(e){try{return e.defaultView?.top?.document??e}catch{return e}}function Io(e){let t=[e],n=qu(e);return n!==e&&t.push(n),t}var Yu=".docs-texteventtarget-iframe",Xu=".kix-cursor",zu=".docos-replyview-body",Ku=".docos-replyview",ju=".docos-author",ja="\u200B",Qu="\xA0";function ir(e){for(let t of Io(e)){let n=t.querySelector(Yu);if(n)return n}return null}function Ju(e){for(let t of Io(e)){let n=t.querySelector(Xu);if(n)return n}return null}function vo(e){let t=Ju(e);return t?(t.ownerDocument?.defaultView?.getComputedStyle(t).display??t.style.display)==="none":!1}function xo(e,t){let n=ir(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,a=n.contentWindow;if(!i)return;let u=a?.KeyboardEvent||KeyboardEvent;i.dispatchEvent(new u("keydown",s))}function qa(e){let t=ir(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 Zu(e){let t=ir(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 a=i?.KeyboardEvent||KeyboardEvent;s.dispatchEvent(new a("keydown",o))}function Ro(e){let t=ir(e);if(!t)return"";let n=t.contentDocument,r=t.contentWindow,o=n?.body;if(!n||!o)return"";try{let a=r?.ClipboardEvent||ClipboardEvent,u=new a("copy",{bubbles:!0,cancelable:!0});o.firstChild?.dispatchEvent?.(u),o.firstChild?.dispatchEvent||o.dispatchEvent(u)}catch{}let s=o.innerText||o.textContent||"";return String(s).replace(new RegExp(ja,"g"),"")??""}function Ps(e){let t=`
3
3
 
4
4
  Comments: `,n=new Set,r=[];for(let s of Io(e))try{let i=Array.from(s.querySelectorAll(zu));for(let a of i)n.has(a)||(n.add(a),r.push(a))}catch{}let o=r.filter(s=>s.textContent);if(o.length===0)return"";for(let s of o){let i=s.closest(Ku);if(!i)continue;let a=i.querySelector(ju);a&&a.textContent&&(t+=`
5
5
  Author: ${a.textContent} `),s.textContent&&(t+=`Comment: ${s.textContent}
@@ -1049,4 +1049,4 @@ Author: ${a.textContent} `),s.textContent&&(t+=`Comment: ${s.textContent}
1049
1049
  <button type="button" class="taskSuggestionBtn primary">Start new</button>
1050
1050
  <button type="button" class="taskSuggestionBtn secondary">Continue</button>
1051
1051
  </div>
1052
- `;let $t=document.createElement("form");$t.className="composer";let ln=document.createElement("textarea");ln.rows=1,ln.placeholder=`Ask ${t} to act on this website...`,$t.appendChild(ln);let et=document.createElement("button");et.type="submit",et.className="sendBtn",et.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>',$t.appendChild(et);let St=document.createElement("div");St.className="resizeHandle",St.setAttribute("aria-hidden","true"),M.appendChild(O),M.appendChild(ke),M.appendChild(gt),M.appendChild($t),M.appendChild(St),u.appendChild(v),u.appendChild(M),s.appendChild(a),s.appendChild(u);let Ne=ln,un=gt.querySelector(".taskSuggestionText"),dn=gt.querySelector(".taskSuggestionBtn.primary"),Pe=gt.querySelector(".taskSuggestionBtn.secondary"),yn=new Set,Gt=new Map,Jt=[],fn="controller",_n=!1,Tn=!1,At=null,Ot=!1,ut=null,Ut=!1,he=!1,Zt=0;function qt(){Ut=!Ut,Me.classList.toggle("visible",Ut)}function Ue(){Ut=!1,Me.classList.remove("visible")}function tt(m,T=0){u.dataset.mood=m,ut!=null&&(window.clearTimeout(ut),ut=null),m==="typing"||m==="running"?(Vt.classList.add("visible"),Le.appendChild(Vt),vn()):Vt.classList.remove("visible"),T>0&&m!=="idle"&&(ut=window.setTimeout(()=>{u.dataset.mood="idle",Vt.classList.remove("visible"),ut=null},T))}function Vr(){return Le.scrollHeight-Le.scrollTop-Le.clientHeight<60}function vn(){he?mt.classList.add("visible"):(requestAnimationFrame(()=>{Le.scrollTo({top:Le.scrollHeight,behavior:"smooth"}),Zt=Date.now()}),mt.classList.remove("visible"))}Le.addEventListener("scroll",()=>{Date.now()-Zt<200||(Vr()?(he=!1,mt.classList.remove("visible")):(he=!0,mt.classList.add("visible")))},{passive:!0}),mt.addEventListener("click",()=>{he=!1,Zt=Date.now(),Le.scrollTo({top:Le.scrollHeight,behavior:"smooth"}),mt.classList.remove("visible")});function Ve(){Ne.disabled=fn==="observer"&&!_n}function xn(m){Ot=m,u.dataset.showDetails=m?"true":"false",It.textContent=Ot?"Hide details":"Show details";for(let T of Jt){let C=T.dataset.status,N=C==="success"||C==="error"||C==="info";T.classList.toggle("compact",!Ot&&N)}}function Gn(){u.style.display="",M.classList.remove("closing"),M.classList.add("open"),tt("idle"),e.onOpen?.(),Ne.disabled||Ne.focus()}function en(){if(Ue(),!M.classList.contains("open")){e.onClose?.();return}M.classList.remove("open"),M.classList.add("closing"),tt("idle");let m=()=>{M.classList.remove("closing"),M.removeEventListener("animationend",m)};M.addEventListener("animationend",m),e.onClose?.()}function qn(){u.style.display=""}function Yn(){en(),u.style.display="none"}function Ct(m,T){let C=ar(T);if(!C)return;let N=document.createElement("div");N.className=`entry message ${m}`;let F=document.createElement("div");F.className="bubble",m==="assistant"?C.length>280?F.appendChild(dc(C,280)):F.appendChild(Cr(C)):F.textContent=C;let Y=document.createElement("div");Y.className="stamp",Y.textContent=uc(Date.now()),N.appendChild(F),N.appendChild(Y),Le.appendChild(N),m==="user"?tt("typing",1200):m==="assistant"?tt("success",1400):tt("running",900),vn()}function tn(){for(let m of Array.from(Le.querySelectorAll(".entry.message")))m.remove()}function Yt(m){let T=Gt.get(m);if(T)return T;let C=document.createElement("div");C.className="entry trace pending";let N=document.createElement("div");N.className="traceTop";let F=document.createElement("div");F.className="traceMeta";let Y=document.createElement("span");Y.className="traceStage",Y.textContent="step";let Q=document.createElement("div");Q.className="traceTitle";let pe=document.createElement("div");pe.className="traceTs",F.appendChild(Y),F.appendChild(Q),N.appendChild(F),N.appendChild(pe);let J=document.createElement("div");return J.className="traceDetail",C.appendChild(N),C.appendChild(J),Gt.set(m,C),Jt.push(C),Le.appendChild(C),C}function fr(m,T){let C=Number(T.ts)||Date.now(),N=Id(T),F=m.querySelector(".traceTop"),Q=F.querySelector(".traceMeta").querySelector(".traceStage"),pe=F.querySelector(".traceTitle"),J=F.querySelector(".traceTs"),ee=m.querySelector(".traceDetail"),se=pc(T.title||"");pe.textContent=se.plainTitle||"Step",Q.textContent=se.stage||T.kind||"step",Q.style.display=se.stage||T.kind==="status"||T.kind==="plan"||T.kind==="thought"?"":"none",J.textContent=uc(C),ee.innerHTML="";let we=ar(T.detail||"");if(we){let ue=T.kind==="thought"?150:T.kind==="tool_start"||T.kind==="tool_result"?100:280;we.length>ue?ee.appendChild(dc(we,ue)):ee.appendChild(Cr(we)),ee.style.display=""}else ee.style.display="none";m.classList.remove("pending","success","error","info"),m.classList.add(N),m.dataset.status=N,m.dataset.kind=T.kind,m.dataset.visibility=Ld(T);let Be=N==="success"||N==="error"||N==="info";m.classList.toggle("compact",!Ot&&Be),N==="error"?tt("error",2200):N==="success"?tt("success",1200):N==="pending"&&tt("running",800)}function Xt(m){let T=ar(m.title||"");if(!T||T.toLowerCase()==="assistant update")return;let C=m.id||fc("timeline");if(m.id&&yn.has(C))return;yn.add(C);let N=Sd(m),F=N==="run"||N.startsWith("tool:")||m.kind==="tool_result"||m.kind==="status"&&Gt.has(N),Y=Yt(F?N:`${N}:${C}`);fr(Y,{...m,title:T}),T.toLowerCase()==="run completed"&&xn(!1),vn()}function Rn(){yn.clear(),Gt.clear(),Jt.length=0;for(let m of Array.from(Le.querySelectorAll(".entry.trace")))m.remove()}function Mt(m){let T=!!m?.visible;gt.classList.toggle("visible",T),un.textContent=m?.text||"Looks like a new request. Start a new task?",dn.textContent=m?.primaryLabel||"Start new",Pe.textContent=m?.secondaryLabel||"Continue"}function c(m){let T=String(m||"ready");re.textContent=T;let C=T.toLowerCase();C.includes("error")||C.includes("failed")?tt("error",1800):C==="ready"||C.includes("complete")?tt("idle"):tt("running",1e3)}function y(m){Tn=m,He.classList.toggle("visible",m),j.style.display=m?"none":""}function b(m,T){fn=m,_n=m==="observer"?T?.canComposeInObserver===!0:!0,Ve(),j.classList.remove("controller","observer"),j.classList.add(m),m==="controller"?(j.textContent="active",it.style.display="none",Ne.placeholder=`Ask ${t} to act on this website...`):(j.textContent="observer",T?.canTakeControl!==!1?it.style.display="":it.style.display="none",T?.note?Ne.placeholder=T.note:_n?Ne.placeholder="Send to take control and run here.":T?.activeLogicalTabId&&T?.localLogicalTabId&&T.activeLogicalTabId!==T.localLogicalTabId?Ne.placeholder=`Observing: ${t} is acting in tab #${T.activeLogicalTabId}`:Ne.placeholder="Observer mode. Take control to run actions here.")}function g(){ut!=null&&(window.clearTimeout(ut),ut=null),document.removeEventListener("keydown",f),i.remove(),o.remove()}v.addEventListener("click",()=>{M.classList.contains("open")?en():Gn()}),ne.addEventListener("click",()=>en()),le.addEventListener("click",m=>{m.stopPropagation(),qt()}),u.addEventListener("click",m=>{Ut&&!Me.contains(m.target)&&m.target!==le&&Ue()}),Ze.addEventListener("click",()=>{Ue(),Tn&&e.onCancelRun?(At="new_task",Mt({visible:!0,text:"A task is in progress. Cancel it and start new?",primaryLabel:"Cancel & start new",secondaryLabel:"Keep running"})):e.onNewTask?.()}),st.addEventListener("click",()=>{Ue(),Tn&&e.onCancelRun?(At="end_task",Mt({visible:!0,text:"A task is in progress. Cancel and end it?",primaryLabel:"Cancel & end",secondaryLabel:"Keep running"})):e.onEndTask?.()}),It.addEventListener("click",()=>{Ue(),xn(!Ot)}),it.addEventListener("click",()=>{Ue(),e.onRequestControl?.()}),He.addEventListener("click",()=>{e.onCancelRun?.()}),dn.addEventListener("click",()=>{if(At){let m=At;At=null,Mt({visible:!1}),e.onCancelRun?.(),m==="new_task"?e.onNewTask?.():m==="end_task"&&e.onEndTask?.();return}e.onTaskSuggestionPrimary?.()}),Pe.addEventListener("click",()=>{if(At){At=null,Mt({visible:!1});return}e.onTaskSuggestionSecondary?.()}),Ne.addEventListener("input",()=>{Ne.style.height="auto",Ne.style.height=`${Math.min(96,Math.max(44,Ne.scrollHeight))}px`}),Ne.addEventListener("keydown",m=>{m.key==="Enter"&&!m.shiftKey&&!m.isComposing&&(m.preventDefault(),$t.requestSubmit())}),$t.addEventListener("submit",m=>{if(m.preventDefault(),Ne.disabled)return;let T=ar(Ne.value);T&&(Mt({visible:!1}),e.onSend(T),Ne.value="",Ne.style.height="44px")}),s.addEventListener("keydown",m=>{let T=m;T.key==="Escape"&&M.classList.contains("open")&&(T.stopPropagation(),en())});let f=m=>{m.code==="Period"&&m.shiftKey&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),m.stopPropagation(),M.classList.contains("open")?en():Gn())};document.addEventListener("keydown",f);let d=null,h=m=>{if(!d)return;let T=d.startX-m.clientX,C=m.clientY-d.startY,N=Math.max(320,Math.min(window.innerWidth-16,d.startW+T)),F=Math.max(460,Math.min(window.innerHeight-16,d.startH+C));M.style.width=`${N}px`,M.style.height=`${F}px`},x=()=>{d=null,window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",x)};if(St.addEventListener("pointerdown",m=>{window.matchMedia("(max-width: 640px)").matches||(m.preventDefault(),d={startX:m.clientX,startY:m.clientY,startW:M.getBoundingClientRect().width,startH:M.getBoundingClientRect().height},window.addEventListener("pointermove",h),window.addEventListener("pointerup",x))}),_){let m=()=>{_.style.display="none",A.style.display="grid"};_.addEventListener("error",m,{once:!0}),A.style.display="none"}if(q){let m=()=>{q.style.display="none",U.style.display="grid"};q.addEventListener("error",m,{once:!0}),U.style.display="none"}return b("controller"),xn(!1),{addMessage:Ct,clearMessages:tn,addTimelineEvent:Xt,clearTimeline:Rn,setTaskSuggestion:Mt,setStatus:c,setRunning:y,setExecutionMode:b,open:Gn,close:en,show:qn,hide:Yn,destroy:g}}var Nd="rover:shared:",Dd="rover:channel:";function Z(){return Date.now()}function Qt(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function qs(e){let t=String(e||"").trim();if(!t)return"";try{return new URL(t,window.location.href).toString()}catch{return t}}function gc(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)||Z(),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 Od(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 mc(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e.slice(-t)){let o=Od(r);o!==void 0&&n.push(o)}return n}function bc(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=mc(e.plannerHistory,40),o=mc(e.agentPrevSteps,80);return{trajectoryId:typeof e.trajectoryId=="string"?e.trajectoryId:void 0,history:n,plannerHistory:r,agentPrevSteps:o,updatedAt:Number(e.updatedAt)||Z()}}function Ys(e,t){return{version:2,siteId:e,sessionId:t,seq:1,updatedAt:Z(),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 cr(e,t,n){let r=Ys(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)||Z(),tabs:Array.isArray(e.tabs)?e.tabs.map(a=>({logicalTabId:Math.max(1,Number(a?.logicalTabId)||0),runtimeId:typeof a?.runtimeId=="string"?a.runtimeId:void 0,url:String(a?.url||""),title:typeof a?.title=="string"?a.title:void 0,openedAt:Number(a?.openedAt)||Z(),updatedAt:Number(a?.updatedAt)||Z(),external:!!a?.external,openerRuntimeId:typeof a?.openerRuntimeId=="string"?a.openerRuntimeId:void 0})).filter(a=>!!a.logicalTabId):[],nextLogicalTabId:Math.max(1,Number(e.nextLogicalTabId)||1),activeLogicalTabId:Number(e.activeLogicalTabId)||void 0,uiMessages:Array.isArray(e.uiMessages)?e.uiMessages.map(a=>({id:String(a?.id||Qt("msg")),role:a?.role==="user"||a?.role==="assistant"||a?.role==="system"?a.role:"system",text:String(a?.text||""),ts:Number(a?.ts)||Z(),sourceRuntimeId:typeof a?.sourceRuntimeId=="string"?a.sourceRuntimeId:void 0})).filter(a=>!!a.text):[],timeline:Array.isArray(e.timeline)?e.timeline.map(a=>({id:String(a?.id||Qt("timeline")),kind:String(a?.kind||"status"),title:String(a?.title||"Step"),detail:typeof a?.detail=="string"?a.detail:void 0,status:a?.status==="pending"||a?.status==="success"||a?.status==="error"||a?.status==="info"?a.status:void 0,ts:Number(a?.ts)||Z(),sourceRuntimeId:typeof a?.sourceRuntimeId=="string"?a.sourceRuntimeId:void 0})).filter(a=>!!a.title):[],taskEpoch:Math.max(1,Number(e.taskEpoch)||1),task:gc(e.task),workerContext:bc(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)||Z(),updatedAt:Number(e.activeRun.updatedAt)||Z()}: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)||Z()}: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)||Z(),expiresAt:Number(e.workflowLock.expiresAt)||0}:void 0},s=o.tabs.length,i=new Set;return o.tabs=o.tabs.filter(a=>i.has(a.logicalTabId)?!1:(i.add(a.logicalTabId),!0)),o.nextLogicalTabId<=(o.tabs.at(-1)?.logicalTabId??0)&&(o.nextLogicalTabId=o.tabs.reduce((a,u)=>Math.max(a,u.logicalTabId),0)+1),s>0&&o.tabs.length<s&&console.warn(`[rover] sanitizeSharedState: dropped ${s-o.tabs.length} invalid/duplicate tab entries`),o}var Oo=class Oo{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=`${Nd}${this.siteId}:${this.sessionId}`,this.channelName=`${Dd}${this.siteId}:${this.sessionId}`,this.state=this.loadState()}pruneDetachedTabs(t,n){let r=!!n?.dropRuntimeDetached,o=!!n?.dropAllDetachedExternal,s=Z(),i=t.tabs.length;t.tabs=t.tabs.filter(a=>a.runtimeId?a.runtimeId===this.runtimeId?!0:s-Math.max(a.updatedAt||0,a.openedAt||0)<=45e3:r&&a.openerRuntimeId===this.runtimeId?!1:a.external?o?!1:s-Math.max(a.updatedAt||0,a.openedAt||0)<=12e4:s-Math.max(a.updatedAt||0,a.openedAt||0)<=6e5),i!==t.tabs.length&&(t.activeLogicalTabId&&!t.tabs.some(a=>a.logicalTabId===t.activeLogicalTabId)&&(t.activeLogicalTabId=this.localLogicalTabId||t.tabs[0]?.logicalTabId),t.nextLogicalTabId<=(t.tabs.at(-1)?.logicalTabId??0)&&(t.nextLogicalTabId=t.tabs.reduce((a,u)=>Math.max(a,u.logicalTabId),0)+1))}start(){this.started||(this.started=!0,this.mutate("local",t=>{this.pruneDetachedTabs(t,{dropRuntimeDetached:!0,dropAllDetachedExternal:!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:Z(),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=cr(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=cr(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<=Z()?!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=gc(t)||r.task)})}hydrateExternalState(t){let n=cr(t,this.siteId,this.sessionId);this.pruneDetachedTabs(n,{dropRuntimeDetached:!0,dropAllDetachedExternal:!0});let r=this.state.seq,o=this.state.updatedAt;this.applyIncomingState(n);let s=this.state.seq!==r||this.state.updatedAt!==o;if(!s&&this.state.tabs.some(a=>a.runtimeId?!1:a.external?!0:a.openerRuntimeId===this.runtimeId)){let a=this.state.tabs.length;this.mutate("local",u=>{this.pruneDetachedTabs(u,{dropRuntimeDetached:!0,dropAllDetachedExternal:!0})}),s=this.state.tabs.length!==a}return s?(this.persistState(),this.localLogicalTabId||this.registerCurrentTab(window.location.href,document.title||void 0),!0):!1}listTabs(){let t=Z();return this.state.tabs.filter(n=>n.runtimeId?n.runtimeId===this.runtimeId?!0:t-Math.max(n.updatedAt||0,n.openedAt||0)<=45e3:n.external?t-Math.max(n.updatedAt||0,n.openedAt||0)<=12e4:t-Math.max(n.updatedAt||0,n.openedAt||0)<=6e5)}pruneTabs(t){this.mutate("local",n=>{this.pruneDetachedTabs(n,t)})}startNewTask(t){let n=Number(t.startedAt)||Z(),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,this.pruneDetachedTabs(o,{dropAllDetachedExternal:!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:Z()},r.activeRun=void 0,n=r.task)}),n}markTaskActivity(t,n=Z()){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=bc(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)||Z(),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)||Z(),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;return}n.activeRun={runId:t.runId,text:t.text,runtimeId:this.runtimeId,startedAt:n.activeRun?.runId===t.runId?n.activeRun.startedAt:Z(),updatedAt:Z()},n.task?n.task.status!=="ended"&&(n.task.status="running"):n.task={taskId:Qt("task"),status:"running",startedAt:Z()}})}requestControl(){return this.claimLease(!0)}registerCurrentTab(t,n){let r=qs(t),o;return this.mutate("local",s=>{let i=s.tabs.find(a=>a.runtimeId===this.runtimeId);if(i)i.url=r||i.url,i.title=n||i.title,i.updatedAt=Z(),o=i.logicalTabId;else{let a=s.tabs.find(u=>!u.runtimeId&&u.url===r&&Z()-u.openedAt<18e4);if(a)a.runtimeId=this.runtimeId,a.title=n||a.title,a.updatedAt=Z(),o=a.logicalTabId;else{let u=s.nextLogicalTabId++;s.tabs.push({logicalTabId:u,runtimeId:this.runtimeId,url:r,title:n,openedAt:Z(),updatedAt:Z(),external:!1}),o=u}}s.activeLogicalTabId||(s.activeLogicalTabId=o)}),this.notifyRoleChange(),this.localLogicalTabId||o||1}registerOpenedTab(t){let n=qs(t.url),r=0;return this.mutate("local",o=>{let s=o.tabs.find(i=>!i.runtimeId&&!!i.external&&i.url===n);if(s){s.title=t.title||s.title,s.updatedAt=Z(),s.openerRuntimeId=t.openerRuntimeId||s.openerRuntimeId,r=s.logicalTabId;return}r=o.nextLogicalTabId++,o.tabs.push({logicalTabId:r,runtimeId:void 0,url:n,title:t.title,openedAt:Z(),updatedAt:Z(),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:Z()+this.leaseMs,updatedAt:Z()},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:Z()+this.leaseMs,updatedAt:Z()},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 a=Qt("rpc"),u=window.setTimeout(()=>{this.pendingRpcRequests.delete(a),i(new Error(`Cross-tab RPC timed out after ${o}ms (method=${n}, target=${t})`))},o);this.pendingRpcRequests.set(a,{resolve:s,reject:i,timer:u}),this.channel.postMessage({type:"rpc_request",requestId:a,sourceRuntimeId:this.runtimeId,targetRuntimeId:t,method:n,params:r,timeoutMs:o,createdAt:Z()})})}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>Z()-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>Z()){let s=r.tabs.find(a=>a.runtimeId===o.runtimeId);if(s&&s.updatedAt>Z()-2*this.heartbeatMs){n=!1;return}}r.workflowLock={runtimeId:this.runtimeId,runId:t,lockedAt:Z(),expiresAt:Z()+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>Z()}getWorkflowLockInfo(){let t=this.state.workflowLock;return!t||t.expiresAt<=Z()?{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(a=>a.runtimeId===n);i&&(i.url=r||i.url,i.title=o||i.title,i.updatedAt=Z())})}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=qs(window.location.href),n=document.title||void 0;this.mutate("local",r=>{let o=r.tabs.find(a=>a.runtimeId===this.runtimeId);if(o)o.url=t||o.url,o.title=n||o.title,o.updatedAt=Z();else{let a=r.nextLogicalTabId++;r.tabs.push({logicalTabId:a,runtimeId:this.runtimeId,url:t,title:n,openedAt:Z(),updatedAt:Z(),external:!1})}let s=r.lease;(!s||s.expiresAt<=Z()||s?.holderRuntimeId===this.runtimeId)&&(r.lease={holderRuntimeId:this.runtimeId,expiresAt:Z()+this.leaseMs,updatedAt:Z()},!r.activeLogicalTabId&&this.localLogicalTabId&&(r.activeLogicalTabId=this.localLogicalTabId)),r.workflowLock?.runtimeId===this.runtimeId&&(r.workflowLock.expiresAt=Z()+this.leaseMs*5),this.pruneDetachedTabs(r)}),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<=Z();(t||s||o?.holderRuntimeId===this.runtimeId)&&(r.lease={holderRuntimeId:this.runtimeId,expiresAt:Z()+this.leaseMs,updatedAt:Z()},!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}))},Oo.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=cr(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=cr(this.state,this.siteId,this.sessionId);n(r),r.seq=Math.max(1,Number(r.seq)||1)+(t==="local"?1:0),r.updatedAt=Z(),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.pruneDetachedTabs(t),this.state=t,this.syncLocalLogicalTabId(),this.onStateChange?.(this.state,"remote"),this.notifyRoleChange()))}loadState(){try{let t=window.localStorage.getItem(this.key);if(!t)return Ys(this.siteId,this.sessionId);let n=JSON.parse(t);return cr(n,this.siteId,this.sessionId)}catch(t){return console.warn("[rover] Failed to load shared state from localStorage:",t),Ys(this.siteId,this.sessionId)}}persistState(){try{window.localStorage.setItem(this.key,JSON.stringify(this.state))}catch{}}};$(Oo,"ROLE_CHANGE_DEBOUNCE_MS",200);var Do=Oo;var Ud="https://us-central1-rtrvr-extension-functions.cloudfunctions.net";function lr(e,t){let n=Number(e);return Number.isFinite(n)?n:t}function Ec(e,t=8e3){let n=String(e??"");return n.length<=t?n:`${n.slice(0,t)}\u2026`}function Fd(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,lr(e.updatedAt,0),t,n,r,o].join(":")}function Hd(e){let t=(e||Ud).replace(/\/$/,"");return t.endsWith("/extensionRouter")?t:`${t}/extensionRouter`}function Xs(e,t){let n=new Error(e);return n.details=t,n}var Uo=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,"onStateChange");$(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);$(this,"state","active");let n=String(t.authToken||t.apiKey||"").trim();if(!n)throw Xs("Rover cloud checkpoint requires apiKey or authToken.");this.endpoint=Hd(t.apiBase),this.token=n,this.siteId=t.siteId,this.visitorId=t.visitorId,this.ttlHours=Math.max(1,Math.min(168,Math.floor(lr(t.ttlHours,1)))),this.flushIntervalMs=Math.max(2e3,Math.floor(lr(t.flushIntervalMs,8e3))),this.pullIntervalMs=Math.max(2e3,Math.floor(lr(t.pullIntervalMs,9e3))),this.minFlushIntervalMs=Math.max(1e3,Math.floor(lr(t.minFlushIntervalMs,2500))),this.shouldWrite=t.shouldWrite||(()=>!0),this.buildCheckpoint=t.buildCheckpoint,this.onCheckpoint=t.onCheckpoint,this.onStateChange=t.onStateChange,this.onError=t.onError}start(){this.started||(this.started=!0,this.setState("active"),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.state==="paused_auth"||!this.dirty&&!t||!this.shouldWrite()||!t&&Date.now()-this.lastFlushAt<this.minFlushIntervalMs)return;let n=this.buildCheckpoint();if(!n)return;let r=Fd(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),this.setState("active")}catch(o){this.handleCheckpointError(o,"roverSessionCheckpointUpsert")}finally{this.pushInFlight=!1}}async pull(t){if(!this.pullInFlight&&this.state!=="paused_auth"&&!(!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"),this.setState("active")}catch(n){this.handleCheckpointError(n,"roverSessionCheckpointGet")}finally{this.pullInFlight=!1}}}applyRemoteCheckpoint(t,n){let r=Math.max(0,Math.floor(lr(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:Ec(i,2e3)}:void 0}throw Xs(`Checkpoint HTTP ${r.status}`,{action:t,status:r.status,payload:s})}let o=await r.json();if(o?.success===!1)throw Xs("Checkpoint extensionRouter returned success=false",{action:t,status:r.status,payload:o});return o?.data}setState(t,n){this.state!==t&&(this.state=t,this.onStateChange?.(t,n||{}))}handleCheckpointError(t,n){let r=this.normalizeCheckpointError(t),o=this.isAuthFailure(r);o&&this.setState("paused_auth",{reason:"auth_failed",action:n,code:r.code,message:r.message}),this.onError?.(t,{action:n,state:this.state,code:r.code,message:r.message,status:r.status,paused:o})}normalizeCheckpointError(t){let n=t,r=n?.details,o=r?.payload||r?.response||r,s=o?.errorCode||o?.errorDetails?.code||o?.error?.code||o?.code,i=o?.error||o?.errorDetails?.message||o?.error?.message||n?.message||"Checkpoint request failed",a=Number(r?.status);return{code:typeof s=="string"?s:void 0,message:Ec(i,1e3),status:Number.isFinite(a)?a:void 0}}isAuthFailure(t){let n=String(t.code||"").toUpperCase();return n==="INVALID_API_KEY"||n==="MISSING_API_KEY"||n==="UNAUTHENTICATED"||n==="PERMISSION_DENIED"?!0:t.status===401||t.status===403}};var Pd="rover-runtime-state-db",Fo="runtime-state",zs=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{}}},Ks=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(Pd,1);r.onupgradeneeded=()=>{let o=r.result;o.objectStoreNames.contains(Fo)||o.createObjectStore(Fo)},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(Fo,t),a=i.objectStore(Fo);n(a,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 wc(){let e=new zs,t=new Ks;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 Js=1,Bd="rover:runtime:",Wd="rover:runtime-id:",xc="rover:visitor-id:",js=160,Qs=240,Rc=80,Ko=40,Vd=8e3,$d=15*6e4,Gd=12,qd=3600*24*365,Yd=1,Xd=3e3,zd=9e4,Kd=12e3,jd=30,jo=240,gn=null,ze=null,Ie=null,ge=null,ce=null,ur=null,w=null,Bn=null,Se="",H=null,wt=null,$o=null,Et=[],Go=!1,dr=!1,kc=0,lt,Qo=!1,pt="controller",wn=!1,Wn=!1,Pn=null,yc=!1,Mr=null,Ho="",Ic,cn=new Map,Qd=new Set(["run_started","run_completed","assistant","status","tool_start","tool_result","auth_required","navigation_guardrail","error"]),qo=[],Yo=new Map;function Ce(e,t){af(e,t);let n=Yo.get(e);if(n)for(let r of n)try{r(t)}catch{}}function Sc(e,t){Yo.has(e)||Yo.set(e,new Set);let n=Yo.get(e);return n.add(t),()=>{n.delete(t)}}function Jd(e){return typeof e=="string"?{name:e}:e}function bn(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Zd(e){let t=`${Wd}${e}`;try{let n=window.sessionStorage.getItem(t);if(n&&n.trim())return n.trim();let r=bn("runtime");return window.sessionStorage.setItem(t,r),r}catch{return bn("runtime")}}function Jo(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 Po(e){return String(e||"").trim().replace(/[^a-zA-Z0-9._:-]/g,"").slice(0,180)}function Ac(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]||""):void 0}catch{return}}function _c(e,t,n){try{let r=n?`; domain=${n}`:"";return document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${qd}; samesite=lax${r}`,Ac(e)===t}catch{return!1}}function ef(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 tf(e,t){let n=`rover_vid_${Jo(e)}`;for(let r of ef(window.location.hostname))if(_c(n,t,r))return;_c(n,t)}function Bo(e,t){let n=`${xc}${e}`;try{window.localStorage.setItem(n,t)}catch{}try{window.sessionStorage.setItem(n,t)}catch{}tf(e,t)}function Cc(e){let t=Po(e.visitorId||"");if(t)return t;if(e.checkpointing?.autoVisitorId===!1)return;let n=`${xc}${e.siteId}`,r=`rover_vid_${Jo(e.siteId)}`,o=Po(Ac(r)||"");if(o)return Bo(e.siteId,o),o;try{let i=Po(window.localStorage.getItem(n)||"");if(i)return Bo(e.siteId,i),i}catch{}try{let i=Po(window.sessionStorage.getItem(n)||"");if(i)return Bo(e.siteId,i),i}catch{}let s=`v_${Jo(`${e.siteId}:${bn("visitor")}`)}_${Date.now().toString(36)}`;return Bo(e.siteId,s),s}function nf(e,t){return`visitor-${Jo(`${e}:${t}`)}`}function Mc(e){!ze||!Ie||(ze.registerTool(e.def,e.handler),Ie.postMessage({type:"register_tool",tool:e.def}))}function rf(e){return`${Bd}${e}`}function En(e="session_start"){let t=Date.now();return{taskId:bn("task"),status:"running",startedAt:t,lastUserAt:void 0,lastAssistantAt:void 0,boundaryReason:e,endedAt:void 0}}function Lc(e,t){return{version:Js,sessionId:e,runtimeId:t,uiOpen:!1,uiHidden:!1,uiStatus:void 0,uiMessages:[],timeline:[],executionMode:"controller",workerState:void 0,pendingRun:void 0,taskEpoch:1,activeTask:En(),lastRoutingDecision:void 0,updatedAt:Date.now()}}function Ke(e,t=Vd){return e.length<=t?e:`${e.slice(0,t)}\u2026`}function Xo(e){if(e!=null){if(typeof e=="string")return Ke(e,1200);try{return Ke(JSON.stringify(e),1200)}catch{try{return Ke(String(e),1200)}catch{return}}}}function rs(e){let t=e?.telemetry,n=Number(t?.sampleRate),r=Number.isFinite(n)?Math.min(1,Math.max(0,n)):1,o=Number(t?.flushIntervalMs),s=Number.isFinite(o)?Math.min(6e4,Math.max(2e3,Math.floor(o))):Kd,i=Number(t?.maxBatchSize),a=Number.isFinite(i)?Math.min(80,Math.max(1,Math.floor(i))):jd;return{enabled:t?.enabled!==!1,sampleRate:r,flushIntervalMs:s,maxBatchSize:a,includePayloads:t?.includePayloads===!0}}function Zs(e){return!(!e||!rs(e).enabled||!(e.authToken||e.apiKey))}function Tc(e){if(e!=null){if(typeof e=="string")return Ke(e,260);if(typeof e=="number"||typeof e=="boolean")return e;if(Array.isArray(e))return{type:"array",length:e.length};if(typeof e=="object"){let n={type:"object",keys:Object.keys(e).slice(0,20)},r=["code","message","stage","status","reason","taskId","runId","policyAction"];for(let o of r){let s=e?.[o];s!=null&&(typeof s=="string"?n[o]=Ke(s,180):(typeof s=="number"||typeof s=="boolean")&&(n[o]=s))}return n}}}function of(e,t){if(!t)return Tc(e);let n=Uc(e);if(n!=null)return typeof n=="string"?Ke(n,1e3):typeof n=="number"||typeof n=="boolean"?n:Array.isArray(n)?{type:"array",length:n.length}:typeof n=="object"?n:Tc(e)}function ei(){$o&&(clearInterval($o),$o=null)}function sf(e){let t=(e.apiBase||"https://us-central1-rtrvr-extension-functions.cloudfunctions.net").replace(/\/$/,"");return t.endsWith("/extensionRouter")?t:`${t}/extensionRouter`}async function os(e=!1){if(Go||dr)return;if(!ce||!Zs(ce)){Et=[];return}if(!Et.length)return;let t=rs(ce),n=String(ce.authToken||ce.apiKey||"").trim();if(!n)return;let r=Et.splice(0,t.maxBatchSize);if(r.length){Go=!0;try{let o=await fetch(sf(ce),{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({action:"roverTelemetryIngest",data:{siteId:ce.siteId,runtimeId:Se,sessionId:w?.sessionId,visitorId:lt,flushReason:e?"manual":"interval",sdkVersion:"rover_sdk_v1",pageUrl:window.location.href,userAgent:navigator.userAgent,sampleRate:t.sampleRate,events:r}})});if(!o.ok){o.status===401||o.status===403?dr=!0:Et=[...r,...Et].slice(-jo);return}let s=await o.json().catch(()=>{});if(s?.success===!1){let i=String(s?.errorCode||s?.errorDetails?.code||"").toUpperCase();(i==="INVALID_API_KEY"||i==="MISSING_API_KEY"||i==="UNAUTHENTICATED"||i==="PERMISSION_DENIED")&&(dr=!0);return}}catch{Et=[...r,...Et].slice(-jo)}finally{Go=!1}}}function ti(e){if(ei(),dr=!1,!Zs(e)){Et=[];return}let t=rs(e);$o=setInterval(()=>{os(!1)},t.flushIntervalMs)}function af(e,t){if(!Zs(ce)||dr)return;let n=rs(ce);if(n.sampleRate<1&&Math.random()>n.sampleRate)return;let r={name:e,ts:Date.now(),seq:++kc,payload:of(t,n.includePayloads)};Et.push(r),Et.length>jo&&(Et=Et.slice(-jo)),Et.length>=n.maxBatchSize&&os(!1)}function Wo(e,t,n="tab_not_accessible"){let r=Number(t?.logicalTabId)||void 0,o=t?.url||"",s=t?.title||(t?.external?"External Tab (Inaccessible)":"Inactive Tab"),i=String(n||"").trim(),a=i?` Reason: ${i}.`:"",u=t?.external?`This external tab is tracked in virtual mode only. Live DOM control and accessibility-tree access are unavailable here.${a}`:`This tab is currently not attached to an active Rover runtime. Switch to a live tab or reopen it.${a}`;return{url:o,title:s,contentType:"text/html",content:u,metadata:{inaccessible:!0,external:!!t?.external,accessMode:t?.external?"external_placeholder":"inactive_tab",reason:n,logicalTabId:r}}}function Vo(e,t,n="tab_not_accessible"){let r=Number(t?.logicalTabId)||0,o=t?.url||"",s=t?.external?`Tab ${r} is external to the active runtime and cannot be controlled directly.`:`Tab ${r} is not attached to an active Rover runtime.`,i=t?.external?"DOMAIN_SCOPE_BLOCKED":"TAB_NOT_ACCESSIBLE";return{success:!1,error:s,allowFallback:!0,output:{success:!1,error:{code:i,message:s,missing:[],next_action:t?.external?"Use open_new_tab for external context or continue on an in-scope tab.":"Switch to an active tab and retry.",retryable:!1},blocked_url:o||void 0,logical_tab_id:r||void 0,external:!!t?.external,policy_action:t?.external?e.externalNavigationPolicy||"open_new_tab_notice":void 0,reason:n},errorDetails:{code:i,message:s,retryable:!1,details:{logicalTabId:r,blockedUrl:o,external:!!t?.external,reason:n}}}}function cf(e){if(e==="analyze"||e==="route"||e==="execute"||e==="verify"||e==="complete")return e}function lf(e){return e?e==="analyze"?"Analyze":e==="route"?"Route":e==="execute"?"Execute":e==="verify"?"Verify":e==="complete"?"Complete":"Status":"Status"}function uf(e,t,n){return[String(t||""),String(e||"").trim().toLowerCase(),String(n||"").trim().toLowerCase()].join("|")}function df(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 ff(){return w?.pendingRun?.id}function Nc(){let e=H?.getState()?.activeRun;return!!(e&&e.runtimeId&&e.runtimeId!==Se)}function Dc(){return!Nc()}function Oc(e){if(e==="observer")return Nc()?"Observing active run in another tab...":"Send to take control and run here."}function pf(e){let t=typeof e?.type=="string"?e.type:"";if(!Qd.has(t))return!1;let n=typeof e?.runId=="string"&&e.runId?e.runId:void 0,r=ff();if(t==="run_started")return!n||!r?!1:r!==n;if(!n)return!1;if(t==="run_completed"){if(!r){let o=H?.getState()?.activeRun?.runId;return!(o&&o===n)}return r!==n}return r?r!==n:!0}function hf(e){if(!e||typeof e!="object")return{taskComplete:!1,needsUserInput:!1};let t=e.needsUserInput===!0;return{taskComplete:e.taskComplete===!0&&!t,needsUserInput:t}}function mf(e){if(e&&cn.has(e))return cn.get(e);if(w?.uiMessages?.length)for(let t=w.uiMessages.length-1;t>=0;t-=1){let n=w.uiMessages[t];if(n.role==="assistant"&&n.text)return n.text}}function gf(e){return Bn?Bn.readSync(e):null}function Uc(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 Fc(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 Zo(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e.slice(-t)){let o=Uc(r);o!==void 0&&n.push(o)}return n}async function bf(e){if(!Bn)return null;try{return await Bn.readAsync(e)}catch{return null}}function Lr(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-js)){let r=n?.role;r!=="user"&&r!=="assistant"&&r!=="system"||t.push({id:typeof n?.id=="string"&&n.id?n.id:bn("msg"),role:r,text:Ke(String(n?.text||"")),ts:Number(n?.ts)||Date.now(),sourceRuntimeId:typeof n?.sourceRuntimeId=="string"?n.sourceRuntimeId:void 0})}return t}function Nr(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-Qs)){let r=Ke(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:bn("timeline"),kind:o,title:r,detail:n?.detail?Ke(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 Vn(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(-Rc).map(a=>Fc(a)).filter(a=>!!a),s=Zo(n,Ko),i=Zo(r,Ko*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 Dr(e,t,n){if(!e||typeof e!="object")return Lc(t,n);let r=En(),o=Hr(e.activeTask,r);return{version:Js,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"?Ke(e.uiStatus,300):void 0,uiMessages:Lr(e.uiMessages),timeline:Nr(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:Vn(e.workerState),pendingRun:Or(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"?Ke(e.lastRoutingDecision.reason,200):void 0,ts:Number(e.lastRoutingDecision.ts)||Date.now()}:void 0,updatedAt:Number(e.updatedAt)||Date.now()}}function Hr(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"?Ke(e.boundaryReason,120):t.boundaryReason,endedAt:Number(e.endedAt)||void 0}}function Ef(e,t){return Hr(e,t)}function Hc(e){if(e)return{trajectoryId:e.trajectoryId,history:Array.isArray(e.history)?e.history.slice(-Rc).map(t=>Fc(t)).filter(t=>!!t):[],plannerHistory:Zo(e.plannerHistory,Ko),agentPrevSteps:Zo(e.agentPrevSteps,Ko*2),updatedAt:Number(e.updatedAt)||Date.now()}}function Or(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 Re(){if(!(!w||!ur))try{w.updatedAt=Date.now(),Bn?.write(ur,w),Qo||wt?.markDirty()}catch{}}function wf(){if(yc)return;yc=!0;let e=()=>{w?.pendingRun?.autoResume&&H?.clearActiveRunRuntimeId(w.pendingRun.id),H?.broadcastClosing(),w?.pendingRun&&H?.releaseWorkflowLock(w.pendingRun.id),Re(),os(!0),ei(),wt?.markDirty(),wt?.syncNow(),wt?.stop(),H?.stop()};window.addEventListener("pagehide",e,{capture:!0});let t=n=>{n.persisted&&(H&&(H.reloadFromStorage(),H.registerCurrentTab(window.location.href,document.title||void 0),H.claimLease(!1)),Wn=!1,ce&&ti(ce))};window.addEventListener("pageshow",t)}function Pr(e="implicit"){if(w)return w.activeTask||(w.activeTask=En(e),w.taskEpoch=Math.max(1,Number(w.taskEpoch)||1)),w.activeTask}function yf(e,t=Date.now()){if(!w)return;let n=Pr("implicit");n&&(e==="user"&&(n.lastUserAt=t),e==="assistant"&&(n.lastAssistantAt=t),n.status==="ended"&&(n.status="running",n.endedAt=void 0))}function vc(e="worker_task_active",t=Date.now()){if(!w)return;let n=Pr(e);n&&(n.status="running",n.endedAt=void 0,n.boundaryReason=e,!n.lastUserAt&&!n.lastAssistantAt&&(n.lastAssistantAt=t),H?.syncTask({...n},w.taskEpoch),Re())}function _f(e="worker_task_complete",t=Date.now()){if(!w)return;let n=Pr(e);n&&(n.status="completed",n.endedAt=t,n.boundaryReason=e,H?.syncTask({...n},w.taskEpoch),Re())}function $n(){Mr=null,ge?.setTaskSuggestion({visible:!1})}function Pc(){ge?.clearMessages(),ge?.clearTimeline(),$n()}function Tf(){let e=w?.pendingRun;if(!e)return!1;if(!H)return!0;let t=H?.getState()?.activeRun;if(t?.runId&&t.runId===e.id||t?.runtimeId&&t.runtimeId!==Se)return!0;let n=Date.now()-Number(e.startedAt||0);return n>=0&&n<=Xd}function vf(){if(!w?.pendingRun||Tf()||!H)return;let e=w.pendingRun,t=Date.now()-Number(e.startedAt||0);!Number.isFinite(t)||t<zd||(Dt(void 0),H?.clearActiveRunRuntimeId(e.id),H?.releaseWorkflowLock(e.id),H?.setActiveRun(void 0))}function Wt(e,t,n=!0,r){let o=Ke(String(t||""));if(!o)return;let s={id:r?.id||bn("msg"),role:e,text:o,ts:r?.ts||Date.now(),sourceRuntimeId:r?.sourceRuntimeId};return ge?.addMessage(s.role,s.text),w&&n&&(w.uiMessages.push(s),w.uiMessages.length>js&&(w.uiMessages=w.uiMessages.slice(-js)),yf(s.role,s.ts),Re()),H&&r?.publishShared!==!1&&(H.appendMessage({id:s.id,role:s.role,text:s.text,ts:s.ts}),H.markTaskActivity(s.role,s.ts)),s}function ni(e){for(let t of e)Wt(t.role,t.text,!1,{id:t.id,ts:t.ts,sourceRuntimeId:t.sourceRuntimeId,publishShared:!1})}function Ye(e,t=!0){let n={id:e.id||bn("timeline"),kind:e.kind,title:Ke(e.title,400),detail:e.detail?Ke(e.detail,1200):void 0,status:e.status,ts:e.ts||Date.now(),sourceRuntimeId:e.sourceRuntimeId};return ge?.addTimelineEvent(n),w&&t&&(w.timeline.push(n),w.timeline.length>Qs&&(w.timeline=w.timeline.slice(-Qs)),Re()),H&&e.publishShared!==!1&&H.appendTimeline({id:n.id,kind:n.kind,title:n.title,detail:n.detail,status:n.status,ts:n.ts}),n}function ri(e){ge?.clearTimeline();for(let t of e)Ye({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 kt(e,t){ge?.setStatus(e),w&&(w.uiStatus=Ke(e,300),Re()),H&&t?.publishShared!==!1&&H.setStatus(e)}function Ur(e,t){pt=e,w&&(w.executionMode=e,Re()),ge?.setExecutionMode(e,{controllerRuntimeId:t?.holderRuntimeId??H?.getCurrentHolderRuntimeId(),localLogicalTabId:t?.localLogicalTabId??H?.getLocalLogicalTabId(),activeLogicalTabId:t?.activeLogicalTabId??H?.getActiveLogicalTabId(),canTakeControl:!0,canComposeInObserver:Dc(),note:Oc(e)}),Ce("mode_change",{mode:e,...t})}function Dt(e){if(!w)return;w.pendingRun=e;let t=Pr("implicit");t&&(e?(t.status="running",t.endedAt=void 0):t.status==="running"&&(t.status="completed")),Re()}function Bc(e,t){let n=String(e||"").trim();if(!n||!Ie)return;if(pt==="observer"&&!(H?.requestControl()??!1)){Wt("system","Unable to take control right now because another tab is still running Rover actions.",!0),Ye({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&&Wt("user",n,!0);let i=w?.pendingRun?.id===r?w.pendingRun.attempts:0;Dt({id:r,text:n,startedAt:Date.now(),attempts:o?i+1:0,autoResume:t?.autoResume!==!1}),Ic=n,H?.acquireWorkflowLock(r),H?.setActiveRun({runId:r,text:n}),Ie.postMessage({type:"run",text:n,runId:r,resume:o}),Pn&&clearTimeout(Pn);let a=r;Pn=setTimeout(()=>{w?.pendingRun?.id===a&&(Dt(void 0),H?.releaseWorkflowLock(a),H?.setActiveRun(void 0),kt("Task timed out."),Wt("system","Task timed out after 5 minutes with no response.",!0),Ce("error",{message:"Run safety timeout"})),Pn=null},5*6e4)}function zo(e,t){let n=String(e||"").trim();if(!n)return;vf();let r=w?.activeTask?.status,o=!!t?.startNewTask||r==="completed"||r==="ended";if(H?.pruneTabs({dropRuntimeDetached:!0,dropAllDetachedExternal:o}),o){let s=t?.reason||(r==="completed"?"auto_after_task_complete":"auto_after_task_end");Wr({reason:s,clearUi:!0})}$n(),Bc(n,{appendUserMessage:!0,resume:!1,autoResume:!0})}function es(){if(pt==="observer")return;let e=H?.getState()?.activeRun;if(e?.runtimeId&&e.runtimeId!==Se&&!(w?.pendingRun?.id===e.runId)||!wn||!Ie||Wn||!w?.pendingRun||w.activeTask?.status==="ended")return;let t=w.pendingRun;if(!t.autoResume)return;let n=ce?.siteId||"";if(!!!sessionStorage.getItem(`rover:tab-alive:${n}`)&&!(H?.listTabs()||[]).some(a=>a.runtimeId!==Se&&a.updatedAt>Date.now()-2*2e3)&&w?.pendingRun){Dt(void 0),kt("Previous task expired.");return}if(Date.now()-t.startedAt>$d){Dt(void 0),kt("Previous task expired after navigation.");return}if(t.attempts>=Gd){Dt(void 0),Wt("system","Auto-resume stopped after too many navigation attempts.",!0);return}Wn=!0,kt("Resuming previous task after navigation..."),Bc(t.text,{runId:t.id,resume:!0,appendUserMessage:!1,autoResume:!0})}async function xf(e){if(!w)return;let t=await bf(e);if(!t||!w)return;let n=Number(w.updatedAt)||0,r=Dr({...t,sessionId:w.sessionId,runtimeId:Se},w.sessionId,Se);(Number(r.updatedAt)||0)<=n+200||(w=Dr({...w,...r,sessionId:w.sessionId,runtimeId:Se},w.sessionId,Se),Re(),ge&&(ge.clearMessages(),ni(w.uiMessages),ri(w.timeline),w.uiStatus&&ge.setStatus(w.uiStatus),w.uiHidden?ge.hide():(ge.show(),w.uiOpen?ge.open():ge.close())),wn&&Ie&&w.workerState&&pt==="controller"&&(Ie.postMessage({type:"hydrate_state",state:w.workerState}),Ce("context_restored",{source:"indexeddb_checkpoint",ts:Date.now()})))}function oi(e,t){if(w){if(t==="remote"){let n=Math.max(1,Number(w.taskEpoch)||1),r=Math.max(1,Number(e.taskEpoch)||1),o=r>n;w.taskEpoch=Math.max(n,r);let s=w.activeTask||En("shared_sync");w.activeTask=Ef(e.task,s),o&&(w.uiMessages=[],w.timeline=[],Pc(),Dt(void 0),$n());let i=Lr(e.uiMessages),a=new Set(i.map(A=>A.id));if(i.length<w.uiMessages.length||w.uiMessages.some(A=>!a.has(A.id)))w.uiMessages=i,ge?.clearMessages(),ni(w.uiMessages);else{let A=new Set(w.uiMessages.map(S=>S.id));for(let S of i)A.has(S.id)||(Wt(S.role,S.text,!0,{id:S.id,ts:S.ts,sourceRuntimeId:S.sourceRuntimeId,publishShared:!1}),A.add(S.id))}let v=Nr(e.timeline),p=new Set(v.map(A=>A.id));if(v.length<w.timeline.length||w.timeline.some(A=>!p.has(A.id)))w.timeline=v,ri(w.timeline);else{let A=new Set(w.timeline.map(S=>S.id));for(let S of v)A.has(S.id)||(Ye({id:S.id,kind:S.kind,title:S.title,detail:S.detail,status:S.status,ts:S.ts,sourceRuntimeId:S.sourceRuntimeId,publishShared:!1},!0),A.add(S.id))}if(typeof e.uiStatus=="string"&&kt(e.uiStatus,{publishShared:!1}),e.activeRun&&e.activeRun.runtimeId!==Se?Dt(Or({id:e.activeRun.runId,text:e.activeRun.text,startedAt:e.activeRun.startedAt,attempts:w.pendingRun?.attempts||0,autoResume:!0})):!e.activeRun&&pt==="observer"&&Dt(void 0),pt==="observer"&&Ur("observer",{localLogicalTabId:H?.getLocalLogicalTabId(),activeLogicalTabId:H?.getActiveLogicalTabId(),holderRuntimeId:H?.getCurrentHolderRuntimeId()}),e.workerContext){let A=Vn(e.workerContext),S=Number(w.workerState?.updatedAt)||0,M=Number(A?.updatedAt)||0;A&&M>S+100&&(w.workerState=A,wn&&Ie&&pt==="controller"&&(Ie.postMessage({type:"hydrate_state",state:A}),Ce("context_restored",{source:"shared_session",ts:Date.now()})))}}w.uiMessages=Lr(w.uiMessages),w.timeline=Nr(w.timeline),w.workerState=Vn(w.workerState),w.activeTask=Hr(w.activeTask,En("implicit")),Re()}}function Wc(e){let t=En("checkpoint_clone");return{version:Js,sessionId:e.sessionId,runtimeId:e.runtimeId,uiOpen:!!e.uiOpen,uiHidden:!!e.uiHidden,uiStatus:typeof e.uiStatus=="string"?Ke(e.uiStatus,300):void 0,uiMessages:Lr(e.uiMessages),timeline:Nr(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:Vn(e.workerState),pendingRun:Or(e.pendingRun),taskEpoch:Math.max(1,Number(e.taskEpoch)||1),activeTask:Hr(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 Rf(e){return!(e.sessionScope==="tab"||e.checkpointing?.enabled!==!0||!(e.apiKey||e.authToken)||!lt)}function kf(){if(!w||!ce||!lt)return null;let e=H?.getState(),t=Wc(w),n=Math.max(Number(e?.updatedAt||0),Number(t.updatedAt||0),Date.now());return{version:Yd,siteId:ce.siteId,visitorId:lt,sessionId:w.sessionId,updatedAt:n,sharedState:e,runtimeState:t}}function If(e){if(!e||typeof e!="object"||!w||!ce||e.siteId&&e.siteId!==ce.siteId||lt&&e.visitorId&&e.visitorId!==lt)return;let t=typeof e.sessionId=="string"&&e.sessionId.trim()?e.sessionId.trim():w.sessionId;Qo=!0;try{if(t&&w.sessionId!==t&&(w.sessionId=t,ce={...ce,sessionId:t},ts(ce),Ie?.postMessage({type:"update_config",config:{sessionId:t}})),e.sharedState&&H&&H.hydrateExternalState(e.sharedState)&&(oi(H.getState(),"remote"),Ur(H.getRole(),{localLogicalTabId:H.getLocalLogicalTabId(),activeLogicalTabId:H.getActiveLogicalTabId(),holderRuntimeId:H.getCurrentHolderRuntimeId()})),e.runtimeState&&typeof e.runtimeState=="object"){let n=Dr({...e.runtimeState,sessionId:t,runtimeId:Se},t,Se),r=Number(w.updatedAt)||0;(Number(n.updatedAt)||0)>r+200&&(w=Dr({...w,...n,sessionId:t,runtimeId:Se},t,Se),Re(),w.uiStatus&&ge?.setStatus(w.uiStatus),w.uiHidden?ge?.hide():(ge?.show(),w.uiOpen?ge?.open():ge?.close()),wn&&w.workerState&&(Ie?.postMessage({type:"hydrate_state",state:w.workerState}),Ce("context_restored",{source:"cloud_checkpoint",ts:Date.now()})),pt==="controller"&&es())}}finally{Qo=!1}}function Vc(e){if(wt?.stop(),wt=null,!!Rf(e)&&lt)try{let t=n=>{Ce("checkpoint_state",n),e.checkpointing?.onStateChange?.(n)};wt=new Uo({apiBase:e.apiBase,apiKey:e.apiKey,authToken:e.authToken,siteId:e.siteId,visitorId:lt,ttlHours:e.checkpointing?.ttlHours??1,flushIntervalMs:e.checkpointing?.flushIntervalMs,pullIntervalMs:e.checkpointing?.pullIntervalMs,minFlushIntervalMs:e.checkpointing?.minFlushIntervalMs,shouldWrite:()=>pt==="controller",buildCheckpoint:()=>kf(),onCheckpoint:n=>{If(n)},onStateChange:(n,r)=>{t({state:n,reason:r.reason,action:r.action,code:r.code,message:r.message}),n==="paused_auth"&&Ce("checkpoint_error",{action:r.action,code:r.code||"INVALID_API_KEY",message:r.message||"Checkpoint sync paused due to auth failure.",disabled:!0,reason:r.reason||"auth_failed"})},onError:(n,r)=>{e.checkpointing?.onError?.(r),r.paused||Ce("checkpoint_error",{action:r.action,code:r.code,message:r.message,status:r.status,disabled:!1,reason:"transient_failure"})}}),wt.start(),wt.markDirty()}catch{wt=null}}function ts(e){if(w){if(H?.stop(),H=null,e.sessionScope==="tab"){Ur("controller");return}H=new Do({siteId:e.siteId,sessionId:w.sessionId,runtimeId:Se,leaseMs:e.tabPolicy?.actionLeaseMs,onRoleChange:(t,n)=>{Ur(t,n);let r=t==="controller"&&(ce?.allowActions??!0);if(ze?.setAllowActions(r),t==="controller"){let o=H?.getWorkerContext();if(o){let s=Vn(o),i=Number(w?.workerState?.updatedAt)||0,a=Number(s?.updatedAt)||0;s&&a>i+100&&(w&&(w.workerState=s,Re()),wn&&Ie&&(Ie.postMessage({type:"hydrate_state",state:s}),Ce("context_restored",{source:"controller_handoff",ts:Date.now()})))}es()}},onStateChange:(t,n)=>{oi(t,n)},onSwitchRequested:t=>{t>0&&(Br(),Ye({kind:"status",title:`Switched to tab #${t}`,status:"info"}))}}),H.start(),H.setRpcRequestHandler(async t=>{if(!ze)throw new Error("Bridge not available");if(t.method==="getPageData")return ze.getPageData(t.params);if(t.method==="executeTool")return ze.executeTool(t.params.call,t.params.payload);throw new Error(`Unknown RPC method: ${t.method}`)}),w?.activeTask&&H.syncTask({...w.activeTask,taskId:w.activeTask.taskId},w.taskEpoch),w?.workerState&&H.setWorkerContext(Hc(w.workerState))}}function Sf(e){let t=Ke(mf(e)||"Done.",1200);ge?.clearTimeline(),w&&(w.timeline=[]),H?.clearTimeline(),Ye({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")&&!pf(e)){if(e.type==="assistant"){let t=String(e.text||"");if(typeof e.runId=="string"&&e.runId&&(cn.set(e.runId,t),cn.size>80)){let n=cn.keys().next().value;n&&cn.delete(n)}Wt("assistant",t,!0),Ye({kind:"tool_result",title:"Assistant update",detail:t,status:"success"});return}if(e.type==="status"){let t=cf(e.stage),n=e.message?String(e.message):void 0,r=e.compactThought?String(e.compactThought):void 0,o=uf(n,t,r);if(n&&kt(n),o&&o!==Ho&&(Ho=o,n)){let s=!!(e.thought||r),i=r||(e.thought?String(e.thought):"");if(s&&t!=="analyze"&&t!=="route"&&t!=="complete"&&!df(i,Ic))Ye({kind:"thought",title:i,detail:e.thought?String(e.thought):r,status:"pending"});else{let u=t?`${lf(t)}: ${n}`:n;Ye({kind:"status",title:u,detail:r||(e.thought?String(e.thought):void 0),status:t==="complete"?"success":"info"})}}Ce("status",e);return}if(e.type==="tool_start"){Ye({kind:"tool_start",title:`Running ${e.call?.name||"tool"}`,detail:Xo(e.call?.args),status:"pending"}),Ce("tool_start",e);return}if(e.type==="tool_result"){Ye({kind:"tool_result",title:`${e.call?.name||"tool"} completed`,detail:Xo(e.result),status:e?.result?.success===!1?"error":"success"}),Ce("tool_result",e);return}if(e.type==="auth_required"){Ce("auth_required",e.error),e.error?.message&&(Wt("system",`Auth required: ${e.error.message}`,!0),Ye({kind:"error",title:"Auth required",detail:String(e.error.message),status:"error"}));return}if(e.type==="navigation_guardrail"){Ce("navigation_guardrail",e),Ye({kind:"status",title:"Navigation guardrail",detail:Xo(e),status:"info"});return}if(e.type==="error"){Wt("system",`Error: ${e.message||"unknown"}`,!0),Ye({kind:"error",title:"Execution error",detail:String(e.message||"unknown"),status:"error"}),Ce("error",e);return}if(e.type==="state_snapshot"){w&&(w.workerState=Vn({...e.state||{},updatedAt:Date.now()}),e?.activeRun?.runId&&e?.activeRun?.text&&!w.pendingRun&&(w.pendingRun=Or({id:e.activeRun.runId,text:e.activeRun.text,startedAt:e.activeRun.startedAt,attempts:0,autoResume:!0})),e?.activeRun?.runId&&e?.activeRun?.text&&H?.setActiveRun({runId:e.activeRun.runId,text:e.activeRun.text}),w.workerState&&H?.setWorkerContext(Hc(w.workerState)),Re());return}if(e.type==="task_started"){Ce("task_started",{taskId:e.taskId,reason:"worker"});return}if(e.type==="run_started"){Ho="",$n(),typeof e.runId=="string"&&e.runId&&cn.delete(e.runId);let t=w?.pendingRun;Dt(Or({id:e.runId,text:e.text,startedAt:t?.startedAt||Date.now(),attempts:t?.attempts||0,autoResume:t?.autoResume!==!1})),H?.setActiveRun({runId:e.runId,text:String(e.text||"")}),ge?.setRunning(!0);let n=`run:${String(e.runId||"")}:start`;w?.timeline.some(r=>r.id===n)||Ye({id:n,kind:"plan",title:e.resume?"Run resumed":"Run started",detail:String(e.text||""),status:"pending"});return}if(e.type==="run_completed"){if(Ho="",Wn=!1,ge?.setRunning(!1),Pn&&(clearTimeout(Pn),Pn=null),w?.pendingRun?.id===e.runId&&Dt(void 0),typeof e.runId=="string"&&e.runId&&H?.releaseWorkflowLock(e.runId),w&&e?.route&&(e.route.mode==="act"||e.route.mode==="planner")&&(w.lastRoutingDecision={mode:e.route.mode,score:Number(e.route.score)||void 0,reason:typeof e.route.reason=="string"?Ke(e.route.reason,200):void 0,ts:Date.now()},Re()),H?.setActiveRun(void 0),!e.ok&&e.error)vc("worker_run_failed"),kt(`Task failed: ${String(e.error)}`),cn.delete(String(e.runId||"")),Ye({kind:"error",title:"Run failed",detail:String(e.error),status:"error"});else if(e.ok){let t=hf(e),n=t.taskComplete,r=t.needsUserInput;n?(_f("worker_task_complete"),H?.pruneTabs({dropRuntimeDetached:!0,dropAllDetachedExternal:!0}),kt("Task completed"),Sf(typeof e.runId=="string"?e.runId:void 0)):(vc(r?"worker_waiting_for_input":"worker_continuation"),kt(r?"Need more input to continue":"Execution finished. Continue when ready."),Ye({kind:"status",title:r?"Waiting for your input":"Continuation available",detail:r?"Planner requested more information before marking the task complete.":"Task is still active and will continue with your next message.",status:"info"})),typeof e.runId=="string"&&e.runId&&cn.delete(e.runId)}return}if(e.type==="ready"){wn=!0,kt("ready"),Ce("ready");let t=H?.getWorkerContext(),n=Vn(t),r=Number(w?.workerState?.updatedAt)||0,o=Number(n?.updatedAt)||0,s=n&&o>r+100?n:w?.workerState;w&&s&&s!==w.workerState&&(w.workerState=s,Re()),s?(Ie?.postMessage({type:"hydrate_state",state:s}),Ce("context_restored",{source:"runtime_start",ts:Date.now()})):es();return}if(e.type==="hydrated"){es();return}e.type==="updated"&&Ce("updated")}}function Cf(e){if(ts(e),H){let s=H.getRole();pt=s,w&&(w.executionMode=s)}Vc(e),ti(e);let t=(e.allowActions??!0)&&(H?H.isController():!0);ze=new No({allowActions:t,runtimeId:Se,allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy,registerOpenedTab:s=>H?.registerOpenedTab(s),switchToLogicalTab:s=>H?.switchToLogicalTab(s)||{ok:!1,reason:"No session coordinator"},listKnownTabs:()=>(H?.listTabs()||[]).map(s=>({logicalTabId:s.logicalTabId,runtimeId:s.runtimeId,url:s.url,title:s.title,external:!!s.external})),onNavigationGuardrail:s=>{Ce("navigation_guardrail",s),Ye({kind:"status",title:"Navigation guardrail",detail:Xo(s),status:"info"})},instrumentationOptions:e.mode==="safe"?{observeInlineMutations:!1}:void 0});let n=new MessageChannel;lc(n.port1,{getSnapshot:()=>ze.getSnapshot(),getPageData:async s=>{let i=ce||e,a=Number(s?.tabId),u=H?.getLocalLogicalTabId();if(!Number.isFinite(a)||a<=0||a===u||!H)return ze.getPageData(s);let p=H.listTabs().find(_=>_.logicalTabId===a);if(!p)return Wo(i,{logicalTabId:a,external:!0},"target_tab_missing");if(p.runtimeId===Se)return ze.getPageData(s);if(p.external&&i.externalNavigationPolicy!=="allow")return Wo(i,p,"external_domain_inaccessible");if(!p.runtimeId||!H.isTabAlive(a))return Wo(i,p,"target_tab_inactive");try{return await H.sendCrossTabRpc(p.runtimeId,"getPageData",s,15e3)}catch{return Wo(i,p,"cross_tab_rpc_failed")}},executeTool:async s=>{let i=ce||e,a=H?.getActiveLogicalTabId(),u=H?.getLocalLogicalTabId();if(!a||a===u||!H)return ze.executeTool(s.call,s.payload);let p=H.listTabs().find(_=>_.logicalTabId===a);if(!p)return Vo(i,{logicalTabId:a,external:!0},"target_tab_missing");if(p.external&&i.externalNavigationPolicy!=="allow")return Vo(i,p,"external_tab_action_blocked");if(p.runtimeId===Se)return ze.executeTool(s.call,s.payload);if(!p.runtimeId||!H.isTabAlive(a))return Vo(i,p,"target_tab_inactive");try{return await H.sendCrossTabRpc(p.runtimeId,"executeTool",s,2e4)}catch{return Vo(i,p,"cross_tab_execute_failed")}},executeClientTool:s=>ze.executeClientTool(s.name,s.args),listClientTools:()=>ze.listClientTools(),getTabContext:()=>{let s=H?.getLocalLogicalTabId(),i=H?.getActiveLogicalTabId();return{id:s||1,logicalTabId:s||1,activeLogicalTabId:i||s||1,runtimeId:Se,mode:pt,url:window.location.href,title:document.title}},listSessionTabs:()=>H?.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 a=new Blob([`import '${r}';`],{type:"application/javascript"});o=URL.createObjectURL(a)}}catch{}if(Ie=new Worker(o,{type:"module"}),Ie.postMessage({type:"init",config:e,port:n.port2},[n.port2]),ge=hc({onSend:s=>{zo(s)},onRequestControl:()=>{H?.requestControl()??!1?Ye({kind:"status",title:"Control requested",detail:"This tab is now the active Rover controller.",status:"info"}):Wt("system","Unable to acquire control right now. Try again in a moment.",!0)},onCancelRun:()=>{w?.pendingRun&&(Ie?.postMessage({type:"cancel_run",runId:w.pendingRun.id}),H?.releaseWorkflowLock(w.pendingRun.id),H?.setActiveRun(void 0),Dt(void 0),kt("Task cancelled."),Wt("system","Task cancelled.",!0))},onNewTask:()=>{Wr({reason:"manual_new_task",clearUi:!0})},onEndTask:()=>{is({reason:"manual_end_task"})},onTaskSuggestionPrimary:()=>{let s=Mr;s&&zo(s.text,{bypassSuggestion:!0,startNewTask:!0,reason:s.reason})},onTaskSuggestionSecondary:()=>{let s=Mr;s&&zo(s.text,{bypassSuggestion:!0})},showTaskControls:e.ui?.showTaskControls!==!1,muted:e.ui?.muted,agent:{name:e.ui?.agent?.name},mascot:{disabled:e.ui?.mascot?.disabled,mp4Url:e.ui?.mascot?.mp4Url,webmUrl:e.ui?.mascot?.webmUrl},onOpen:()=>{w&&(w.uiOpen=!0,w.uiHidden=!1,Re()),Ce("open")},onClose:()=>{w&&(w.uiOpen=!1,Re()),Ce("close")}}),$n(),w?.uiMessages?.length&&ni(w.uiMessages),w?.timeline?.length&&ri(w.timeline),w?.uiStatus&&ge.setStatus(w.uiStatus),w?.executionMode&&ge.setExecutionMode(w.executionMode,{localLogicalTabId:H?.getLocalLogicalTabId(),activeLogicalTabId:H?.getActiveLogicalTabId(),controllerRuntimeId:H?.getCurrentHolderRuntimeId(),canTakeControl:!0,canComposeInObserver:Dc(),note:Oc(w.executionMode)}),Ie.onmessage=s=>{Af(s.data||{})},H){let s=()=>{H?.registerCurrentTab(window.location.href,document.title),H?.broadcastNavigation(window.location.href,document.title)},i=history.pushState.bind(history),a=history.replaceState.bind(history);history.pushState=function(...u){let v=i(...u);return setTimeout(s,0),v},history.replaceState=function(...u){let v=a(...u);return setTimeout(s,0),v},window.addEventListener("popstate",s)}w?.uiHidden?ge.hide():(ge.show(),w?.uiOpen??!!e.openOnInit?ge.open():ge.close()),w&&(w.uiHidden=!!w.uiHidden,w.uiOpen=!!w.uiOpen,Re()),H&&(oi(H.getState(),"remote"),Ur(H.getRole(),{localLogicalTabId:H.getLocalLogicalTabId(),activeLogicalTabId:H.getActiveLogicalTabId(),holderRuntimeId:H.getCurrentHolderRuntimeId()}))}function Fr(e){if(gn)return ns(e),gn;Bn=wc(),Se=Zd(e.siteId),lt=Cc(e),ur=rf(e.siteId);let t=gf(ur),n=e.sessionId?.trim(),r=!n&&!t?.sessionId&&e.sessionScope!=="tab"&&lt?nf(e.siteId,lt):void 0,o=n||t?.sessionId||r||crypto.randomUUID();w=Dr(t,o,Se),n&&w.sessionId!==n&&(w=Lc(n,Se)),ce={...e,visitorId:lt||e.visitorId,sessionId:n||w.sessionId,taskRouting:{mode:e.taskRouting?.mode||"act",actHeuristicThreshold:e.taskRouting?.actHeuristicThreshold,plannerOnActError:e.taskRouting?.plannerOnActError},taskContext:{...e.taskContext}},w.sessionId=ce.sessionId,w.runtimeId=Se,w.executionMode=w.executionMode||"controller",w.timeline=Nr(w.timeline),w.uiMessages=Lr(w.uiMessages),w.activeTask=Hr(w.activeTask,En("boot")),w.taskEpoch=Math.max(1,Number(w.taskEpoch)||1),pt=w.executionMode,Re();try{sessionStorage.setItem(`rover:tab-alive:${e.siteId}`,"1")}catch{}if(wn=!1,Wn=!1,Cf(ce),ur&&xf(ur),wf(),gn={boot:Fr,init:si,update:ns,shutdown:ii,open:Br,close:ss,show:ai,hide:ci,send:li,newTask:Wr,endTask:is,getState:ui,registerTool:di,on:Sc},qo.length){for(let s of qo)Mc(s);qo.length=0}return gn}function si(e){return Fr(e)}function ns(e){!gn||!Ie||!ce||(ce={...ce,...e,taskRouting:{...ce.taskRouting,...e.taskRouting},taskContext:{...ce.taskContext,...e.taskContext},ui:{...ce.ui,...e.ui,agent:{...ce.ui?.agent,...e.ui?.agent},panel:{...ce.ui?.panel,...e.ui?.panel}},tools:{...ce.tools,...e.tools,client:e.tools?.client??ce.tools?.client,web:{...ce.tools?.web,...e.tools?.web}}},lt=Cc(ce),lt&&(ce.visitorId=lt),e.sessionId&&w?(w.sessionId=e.sessionId,Re(),ts(ce)):(e.sessionScope||e.tabPolicy)&&ts(ce),Vc(ce),ti(ce),ze&&(typeof e.allowActions=="boolean"&&ze.setAllowActions(e.allowActions&&pt==="controller"),(e.allowedDomains||e.domainScopeMode||e.externalNavigationPolicy)&&ze.setNavigationPolicy({allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy})),Ie.postMessage({type:"update_config",config:e}),typeof e.openOnInit=="boolean"&&(e.openOnInit?Br():ss()))}function ii(){$n(),Re(),os(!0),ei(),wt?.markDirty(),wt?.syncNow(),wt?.stop(),wt=null,H?.stop(),H=null,Ie?.terminate(),Ie=null,ge?.destroy(),ge=null,ze=null,ce=null,wn=!1,Wn=!1,Se="",lt=void 0,Qo=!1,Go=!1,dr=!1,Et=[],kc=0,pt="controller",Mr=null,Bn=null,gn=null}function Br(){ge?.show(),ge?.open(),w&&(w.uiHidden=!1,w.uiOpen=!0,Re())}function ss(){ge?.close(),w&&(w.uiOpen=!1,Re())}function ai(){ge?.show(),w&&(w.uiHidden=!1,Re())}function ci(){ge?.hide(),w&&(w.uiHidden=!0,w.uiOpen=!1,Re())}function li(e){e?.trim()&&zo(e)}function Wr(e){if(!w)return;let t=e?.reason||"manual_new_task",n=e?.clearUi!==!1,r=Math.max(1,Number(w.taskEpoch)||1)+1,o=En(t);w.pendingRun&&(Ie?.postMessage({type:"cancel_run",runId:w.pendingRun.id}),H?.releaseWorkflowLock(w.pendingRun.id)),Wn=!1,w.taskEpoch=r,w.activeTask=o,w.pendingRun=void 0,w.workerState=void 0,n&&(w.uiMessages=[],w.timeline=[],w.uiStatus=void 0,Pc()),H?.startNewTask({taskId:o.taskId,startedAt:o.startedAt,boundaryReason:t,status:"running",lastUserAt:void 0,lastAssistantAt:void 0}),H?.setActiveRun(void 0),H?.setWorkerContext(void 0),kt("New task started."),Re(),Ie?.postMessage({type:"start_new_task",taskId:o.taskId}),Ye({kind:"info",title:"Started new task",detail:t,status:"info"}),Ce("task_started",{taskId:o.taskId,reason:t,taskEpoch:r})}function is(e){if(!w)return;let t=e?.reason||"manual_end_task",n=Pr("manual_end_task");n&&(n.status="ended",n.endedAt=Date.now(),n.boundaryReason=t,w.pendingRun&&(Ie?.postMessage({type:"cancel_run",runId:w.pendingRun.id}),H?.releaseWorkflowLock(w.pendingRun.id)),w.pendingRun=void 0,$n(),kt("Task ended. Start a new task to continue."),H?.endTask(t),H?.setActiveRun(void 0),Re(),Ye({kind:"info",title:"Task ended",detail:"Start a new task when you are ready.",status:"info"}),Ce("task_ended",{taskId:n.taskId,reason:t,endedAt:n.endedAt}))}function ui(){return{mode:pt,runtimeId:Se,runtimeState:w?Wc(w):null,sharedState:H?.getState()||null,pendingTaskSuggestion:Mr}}function di(e,t){let n=Jd(e);if(!gn||!ze||!Ie){qo.push({def:n,handler:t});return}Mc({def:n,handler:t})}function Mf(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 $c(){let e=window,t=e.rover,n=((r,...o)=>{let s=Mf(r),i=s?n[s]:void 0;if(typeof i=="function")return i(...o)});if(n.boot=Fr,n.init=si,n.update=ns,n.shutdown=ii,n.open=Br,n.close=ss,n.show=ai,n.hide=ci,n.send=li,n.newTask=Wr,n.endTask=is,n.getState=ui,n.registerTool=di,n.on=Sc,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(!gn){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},a=r.getAttribute("data-allowed-domains");a&&(i.allowedDomains=a.split(",").map(p=>p.trim()).filter(Boolean));let u=r.getAttribute("data-site-key-id");u&&(i.siteKeyId=u);let v=r.getAttribute("data-worker-url");v&&(i.workerUrl=v),Fr(i)}}}}$c();return jc(Lf);})();
1052
+ `;let $t=document.createElement("form");$t.className="composer";let ln=document.createElement("textarea");ln.rows=1,ln.placeholder=`Ask ${t} to act on this website...`,$t.appendChild(ln);let et=document.createElement("button");et.type="submit",et.className="sendBtn",et.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>',$t.appendChild(et);let St=document.createElement("div");St.className="resizeHandle",St.setAttribute("aria-hidden","true"),M.appendChild(O),M.appendChild(ke),M.appendChild(gt),M.appendChild($t),M.appendChild(St),u.appendChild(v),u.appendChild(M),s.appendChild(a),s.appendChild(u);let Ne=ln,un=gt.querySelector(".taskSuggestionText"),dn=gt.querySelector(".taskSuggestionBtn.primary"),Pe=gt.querySelector(".taskSuggestionBtn.secondary"),yn=new Set,Gt=new Map,Jt=[],fn="controller",_n=!1,Tn=!1,At=null,Ot=!1,ut=null,Ut=!1,he=!1,Zt=0;function qt(){Ut=!Ut,Me.classList.toggle("visible",Ut)}function Ue(){Ut=!1,Me.classList.remove("visible")}function tt(m,T=0){u.dataset.mood=m,ut!=null&&(window.clearTimeout(ut),ut=null),m==="typing"||m==="running"?(Vt.classList.add("visible"),Le.appendChild(Vt),vn()):Vt.classList.remove("visible"),T>0&&m!=="idle"&&(ut=window.setTimeout(()=>{u.dataset.mood="idle",Vt.classList.remove("visible"),ut=null},T))}function Vr(){return Le.scrollHeight-Le.scrollTop-Le.clientHeight<60}function vn(){he?mt.classList.add("visible"):(requestAnimationFrame(()=>{Le.scrollTo({top:Le.scrollHeight,behavior:"smooth"}),Zt=Date.now()}),mt.classList.remove("visible"))}Le.addEventListener("scroll",()=>{Date.now()-Zt<200||(Vr()?(he=!1,mt.classList.remove("visible")):(he=!0,mt.classList.add("visible")))},{passive:!0}),mt.addEventListener("click",()=>{he=!1,Zt=Date.now(),Le.scrollTo({top:Le.scrollHeight,behavior:"smooth"}),mt.classList.remove("visible")});function Ve(){Ne.disabled=fn==="observer"&&!_n}function xn(m){Ot=m,u.dataset.showDetails=m?"true":"false",It.textContent=Ot?"Hide details":"Show details";for(let T of Jt){let C=T.dataset.status,N=C==="success"||C==="error"||C==="info";T.classList.toggle("compact",!Ot&&N)}}function Gn(){u.style.display="",M.classList.remove("closing"),M.classList.add("open"),tt("idle"),e.onOpen?.(),Ne.disabled||Ne.focus()}function en(){if(Ue(),!M.classList.contains("open")){e.onClose?.();return}M.classList.remove("open"),M.classList.add("closing"),tt("idle");let m=()=>{M.classList.remove("closing"),M.removeEventListener("animationend",m)};M.addEventListener("animationend",m),e.onClose?.()}function qn(){u.style.display=""}function Yn(){en(),u.style.display="none"}function Ct(m,T){let C=ar(T);if(!C)return;let N=document.createElement("div");N.className=`entry message ${m}`;let F=document.createElement("div");F.className="bubble",m==="assistant"?C.length>280?F.appendChild(dc(C,280)):F.appendChild(Cr(C)):F.textContent=C;let Y=document.createElement("div");Y.className="stamp",Y.textContent=uc(Date.now()),N.appendChild(F),N.appendChild(Y),Le.appendChild(N),m==="user"?tt("typing",1200):m==="assistant"?tt("success",1400):tt("running",900),vn()}function tn(){for(let m of Array.from(Le.querySelectorAll(".entry.message")))m.remove()}function Yt(m){let T=Gt.get(m);if(T)return T;let C=document.createElement("div");C.className="entry trace pending";let N=document.createElement("div");N.className="traceTop";let F=document.createElement("div");F.className="traceMeta";let Y=document.createElement("span");Y.className="traceStage",Y.textContent="step";let Q=document.createElement("div");Q.className="traceTitle";let pe=document.createElement("div");pe.className="traceTs",F.appendChild(Y),F.appendChild(Q),N.appendChild(F),N.appendChild(pe);let J=document.createElement("div");return J.className="traceDetail",C.appendChild(N),C.appendChild(J),Gt.set(m,C),Jt.push(C),Le.appendChild(C),C}function fr(m,T){let C=Number(T.ts)||Date.now(),N=Id(T),F=m.querySelector(".traceTop"),Q=F.querySelector(".traceMeta").querySelector(".traceStage"),pe=F.querySelector(".traceTitle"),J=F.querySelector(".traceTs"),ee=m.querySelector(".traceDetail"),se=pc(T.title||"");pe.textContent=se.plainTitle||"Step",Q.textContent=se.stage||T.kind||"step",Q.style.display=se.stage||T.kind==="status"||T.kind==="plan"||T.kind==="thought"?"":"none",J.textContent=uc(C),ee.innerHTML="";let we=ar(T.detail||"");if(we){let ue=T.kind==="thought"?150:T.kind==="tool_start"||T.kind==="tool_result"?100:280;we.length>ue?ee.appendChild(dc(we,ue)):ee.appendChild(Cr(we)),ee.style.display=""}else ee.style.display="none";m.classList.remove("pending","success","error","info"),m.classList.add(N),m.dataset.status=N,m.dataset.kind=T.kind,m.dataset.visibility=Ld(T);let Be=N==="success"||N==="error"||N==="info";m.classList.toggle("compact",!Ot&&Be),N==="error"?tt("error",2200):N==="success"?tt("success",1200):N==="pending"&&tt("running",800)}function Xt(m){let T=ar(m.title||"");if(!T||T.toLowerCase()==="assistant update")return;let C=m.id||fc("timeline");if(m.id&&yn.has(C))return;yn.add(C);let N=Sd(m),F=N==="run"||N.startsWith("tool:")||m.kind==="tool_result"||m.kind==="status"&&Gt.has(N),Y=Yt(F?N:`${N}:${C}`);fr(Y,{...m,title:T}),T.toLowerCase()==="run completed"&&xn(!1),vn()}function Rn(){yn.clear(),Gt.clear(),Jt.length=0;for(let m of Array.from(Le.querySelectorAll(".entry.trace")))m.remove()}function Mt(m){let T=!!m?.visible;gt.classList.toggle("visible",T),un.textContent=m?.text||"Looks like a new request. Start a new task?",dn.textContent=m?.primaryLabel||"Start new",Pe.textContent=m?.secondaryLabel||"Continue"}function c(m){let T=String(m||"ready");re.textContent=T;let C=T.toLowerCase();C.includes("error")||C.includes("failed")?tt("error",1800):C==="ready"||C.includes("complete")?tt("idle"):tt("running",1e3)}function y(m){Tn=m,He.classList.toggle("visible",m),j.style.display=m?"none":""}function b(m,T){fn=m,_n=m==="observer"?T?.canComposeInObserver===!0:!0,Ve(),j.classList.remove("controller","observer"),j.classList.add(m),m==="controller"?(j.textContent="active",it.style.display="none",Ne.placeholder=`Ask ${t} to act on this website...`):(j.textContent="observer",T?.canTakeControl!==!1?it.style.display="":it.style.display="none",T?.note?Ne.placeholder=T.note:_n?Ne.placeholder="Send to take control and run here.":T?.activeLogicalTabId&&T?.localLogicalTabId&&T.activeLogicalTabId!==T.localLogicalTabId?Ne.placeholder=`Observing: ${t} is acting in tab #${T.activeLogicalTabId}`:Ne.placeholder="Observer mode. Take control to run actions here.")}function g(){ut!=null&&(window.clearTimeout(ut),ut=null),document.removeEventListener("keydown",f),i.remove(),o.remove()}v.addEventListener("click",()=>{M.classList.contains("open")?en():Gn()}),ne.addEventListener("click",()=>en()),le.addEventListener("click",m=>{m.stopPropagation(),qt()}),u.addEventListener("click",m=>{Ut&&!Me.contains(m.target)&&m.target!==le&&Ue()}),Ze.addEventListener("click",()=>{Ue(),Tn&&e.onCancelRun?(At="new_task",Mt({visible:!0,text:"A task is in progress. Cancel it and start new?",primaryLabel:"Cancel & start new",secondaryLabel:"Keep running"})):e.onNewTask?.()}),st.addEventListener("click",()=>{Ue(),Tn&&e.onCancelRun?(At="end_task",Mt({visible:!0,text:"A task is in progress. Cancel and end it?",primaryLabel:"Cancel & end",secondaryLabel:"Keep running"})):e.onEndTask?.()}),It.addEventListener("click",()=>{Ue(),xn(!Ot)}),it.addEventListener("click",()=>{Ue(),e.onRequestControl?.()}),He.addEventListener("click",()=>{e.onCancelRun?.()}),dn.addEventListener("click",()=>{if(At){let m=At;At=null,Mt({visible:!1}),e.onCancelRun?.(),m==="new_task"?e.onNewTask?.():m==="end_task"&&e.onEndTask?.();return}e.onTaskSuggestionPrimary?.()}),Pe.addEventListener("click",()=>{if(At){At=null,Mt({visible:!1});return}e.onTaskSuggestionSecondary?.()}),Ne.addEventListener("input",()=>{Ne.style.height="auto",Ne.style.height=`${Math.min(96,Math.max(44,Ne.scrollHeight))}px`}),Ne.addEventListener("keydown",m=>{m.key==="Enter"&&!m.shiftKey&&!m.isComposing&&(m.preventDefault(),$t.requestSubmit())}),$t.addEventListener("submit",m=>{if(m.preventDefault(),Ne.disabled)return;let T=ar(Ne.value);T&&(Mt({visible:!1}),e.onSend(T),Ne.value="",Ne.style.height="44px")}),s.addEventListener("keydown",m=>{let T=m;T.key==="Escape"&&M.classList.contains("open")&&(T.stopPropagation(),en())});let f=m=>{m.code==="Period"&&m.shiftKey&&(m.metaKey||m.ctrlKey)&&(m.preventDefault(),m.stopPropagation(),M.classList.contains("open")?en():Gn())};document.addEventListener("keydown",f);let d=null,h=m=>{if(!d)return;let T=d.startX-m.clientX,C=m.clientY-d.startY,N=Math.max(320,Math.min(window.innerWidth-16,d.startW+T)),F=Math.max(460,Math.min(window.innerHeight-16,d.startH+C));M.style.width=`${N}px`,M.style.height=`${F}px`},x=()=>{d=null,window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",x)};if(St.addEventListener("pointerdown",m=>{window.matchMedia("(max-width: 640px)").matches||(m.preventDefault(),d={startX:m.clientX,startY:m.clientY,startW:M.getBoundingClientRect().width,startH:M.getBoundingClientRect().height},window.addEventListener("pointermove",h),window.addEventListener("pointerup",x))}),_){let m=()=>{_.style.display="none",A.style.display="grid"};_.addEventListener("error",m,{once:!0}),A.style.display="none"}if(q){let m=()=>{q.style.display="none",U.style.display="grid"};q.addEventListener("error",m,{once:!0}),U.style.display="none"}return b("controller"),xn(!1),{addMessage:Ct,clearMessages:tn,addTimelineEvent:Xt,clearTimeline:Rn,setTaskSuggestion:Mt,setStatus:c,setRunning:y,setExecutionMode:b,open:Gn,close:en,show:qn,hide:Yn,destroy:g}}var Nd="rover:shared:",Dd="rover:channel:";function Z(){return Date.now()}function Qt(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function qs(e){let t=String(e||"").trim();if(!t)return"";try{return new URL(t,window.location.href).toString()}catch{return t}}function gc(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)||Z(),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 Od(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 mc(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e.slice(-t)){let o=Od(r);o!==void 0&&n.push(o)}return n}function bc(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=mc(e.plannerHistory,40),o=mc(e.agentPrevSteps,80);return{trajectoryId:typeof e.trajectoryId=="string"?e.trajectoryId:void 0,history:n,plannerHistory:r,agentPrevSteps:o,updatedAt:Number(e.updatedAt)||Z()}}function Ys(e,t){return{version:2,siteId:e,sessionId:t,seq:1,updatedAt:Z(),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 cr(e,t,n){let r=Ys(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)||Z(),tabs:Array.isArray(e.tabs)?e.tabs.map(a=>({logicalTabId:Math.max(1,Number(a?.logicalTabId)||0),runtimeId:typeof a?.runtimeId=="string"?a.runtimeId:void 0,url:String(a?.url||""),title:typeof a?.title=="string"?a.title:void 0,openedAt:Number(a?.openedAt)||Z(),updatedAt:Number(a?.updatedAt)||Z(),external:!!a?.external,openerRuntimeId:typeof a?.openerRuntimeId=="string"?a.openerRuntimeId:void 0})).filter(a=>!!a.logicalTabId):[],nextLogicalTabId:Math.max(1,Number(e.nextLogicalTabId)||1),activeLogicalTabId:Number(e.activeLogicalTabId)||void 0,uiMessages:Array.isArray(e.uiMessages)?e.uiMessages.map(a=>({id:String(a?.id||Qt("msg")),role:a?.role==="user"||a?.role==="assistant"||a?.role==="system"?a.role:"system",text:String(a?.text||""),ts:Number(a?.ts)||Z(),sourceRuntimeId:typeof a?.sourceRuntimeId=="string"?a.sourceRuntimeId:void 0})).filter(a=>!!a.text):[],timeline:Array.isArray(e.timeline)?e.timeline.map(a=>({id:String(a?.id||Qt("timeline")),kind:String(a?.kind||"status"),title:String(a?.title||"Step"),detail:typeof a?.detail=="string"?a.detail:void 0,status:a?.status==="pending"||a?.status==="success"||a?.status==="error"||a?.status==="info"?a.status:void 0,ts:Number(a?.ts)||Z(),sourceRuntimeId:typeof a?.sourceRuntimeId=="string"?a.sourceRuntimeId:void 0})).filter(a=>!!a.title):[],taskEpoch:Math.max(1,Number(e.taskEpoch)||1),task:gc(e.task),workerContext:bc(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)||Z(),updatedAt:Number(e.activeRun.updatedAt)||Z()}: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)||Z()}: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)||Z(),expiresAt:Number(e.workflowLock.expiresAt)||0}:void 0},s=o.tabs.length,i=new Set;return o.tabs=o.tabs.filter(a=>i.has(a.logicalTabId)?!1:(i.add(a.logicalTabId),!0)),o.nextLogicalTabId<=(o.tabs.at(-1)?.logicalTabId??0)&&(o.nextLogicalTabId=o.tabs.reduce((a,u)=>Math.max(a,u.logicalTabId),0)+1),s>0&&o.tabs.length<s&&console.warn(`[rover] sanitizeSharedState: dropped ${s-o.tabs.length} invalid/duplicate tab entries`),o}var Oo=class Oo{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=`${Nd}${this.siteId}:${this.sessionId}`,this.channelName=`${Dd}${this.siteId}:${this.sessionId}`,this.state=this.loadState()}pruneDetachedTabs(t,n){let r=!!n?.dropRuntimeDetached,o=!!n?.dropAllDetachedExternal,s=Z(),i=t.tabs.length;t.tabs=t.tabs.filter(a=>a.runtimeId?a.runtimeId===this.runtimeId?!0:s-Math.max(a.updatedAt||0,a.openedAt||0)<=45e3:r&&a.openerRuntimeId===this.runtimeId?!1:a.external?o?!1:s-Math.max(a.updatedAt||0,a.openedAt||0)<=12e4:s-Math.max(a.updatedAt||0,a.openedAt||0)<=6e5),i!==t.tabs.length&&(t.activeLogicalTabId&&!t.tabs.some(a=>a.logicalTabId===t.activeLogicalTabId)&&(t.activeLogicalTabId=this.localLogicalTabId||t.tabs[0]?.logicalTabId),t.nextLogicalTabId<=(t.tabs.at(-1)?.logicalTabId??0)&&(t.nextLogicalTabId=t.tabs.reduce((a,u)=>Math.max(a,u.logicalTabId),0)+1))}start(){this.started||(this.started=!0,this.mutate("local",t=>{this.pruneDetachedTabs(t,{dropRuntimeDetached:!0,dropAllDetachedExternal:!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:Z(),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=cr(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=cr(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<=Z()?!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=gc(t)||r.task)})}hydrateExternalState(t){let n=cr(t,this.siteId,this.sessionId);this.pruneDetachedTabs(n,{dropRuntimeDetached:!0,dropAllDetachedExternal:!0});let r=this.state.seq,o=this.state.updatedAt;this.applyIncomingState(n);let s=this.state.seq!==r||this.state.updatedAt!==o;if(!s&&this.state.tabs.some(a=>a.runtimeId?!1:a.external?!0:a.openerRuntimeId===this.runtimeId)){let a=this.state.tabs.length;this.mutate("local",u=>{this.pruneDetachedTabs(u,{dropRuntimeDetached:!0,dropAllDetachedExternal:!0})}),s=this.state.tabs.length!==a}return s?(this.persistState(),this.localLogicalTabId||this.registerCurrentTab(window.location.href,document.title||void 0),!0):!1}listTabs(){let t=Z();return this.state.tabs.filter(n=>n.runtimeId?n.runtimeId===this.runtimeId?!0:t-Math.max(n.updatedAt||0,n.openedAt||0)<=45e3:n.external?t-Math.max(n.updatedAt||0,n.openedAt||0)<=12e4:t-Math.max(n.updatedAt||0,n.openedAt||0)<=6e5)}pruneTabs(t){this.mutate("local",n=>{this.pruneDetachedTabs(n,t)})}startNewTask(t){let n=Number(t.startedAt)||Z(),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,this.pruneDetachedTabs(o,{dropAllDetachedExternal:!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:Z()},r.activeRun=void 0,n=r.task)}),n}markTaskActivity(t,n=Z()){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=bc(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)||Z(),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)||Z(),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;return}n.activeRun={runId:t.runId,text:t.text,runtimeId:this.runtimeId,startedAt:n.activeRun?.runId===t.runId?n.activeRun.startedAt:Z(),updatedAt:Z()},n.task?n.task.status!=="ended"&&(n.task.status="running"):n.task={taskId:Qt("task"),status:"running",startedAt:Z()}})}requestControl(){return this.claimLease(!0)}registerCurrentTab(t,n){let r=qs(t),o;return this.mutate("local",s=>{let i=s.tabs.find(a=>a.runtimeId===this.runtimeId);if(i)i.url=r||i.url,i.title=n||i.title,i.updatedAt=Z(),o=i.logicalTabId;else{let a=s.tabs.find(u=>!u.runtimeId&&u.url===r&&Z()-u.openedAt<18e4);if(a)a.runtimeId=this.runtimeId,a.title=n||a.title,a.updatedAt=Z(),o=a.logicalTabId;else{let u=s.nextLogicalTabId++;s.tabs.push({logicalTabId:u,runtimeId:this.runtimeId,url:r,title:n,openedAt:Z(),updatedAt:Z(),external:!1}),o=u}}s.activeLogicalTabId||(s.activeLogicalTabId=o)}),this.notifyRoleChange(),this.localLogicalTabId||o||1}registerOpenedTab(t){let n=qs(t.url),r=0;return this.mutate("local",o=>{let s=o.tabs.find(i=>!i.runtimeId&&!!i.external&&i.url===n);if(s){s.title=t.title||s.title,s.updatedAt=Z(),s.openerRuntimeId=t.openerRuntimeId||s.openerRuntimeId,r=s.logicalTabId;return}r=o.nextLogicalTabId++,o.tabs.push({logicalTabId:r,runtimeId:void 0,url:n,title:t.title,openedAt:Z(),updatedAt:Z(),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:Z()+this.leaseMs,updatedAt:Z()},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:Z()+this.leaseMs,updatedAt:Z()},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 a=Qt("rpc"),u=window.setTimeout(()=>{this.pendingRpcRequests.delete(a),i(new Error(`Cross-tab RPC timed out after ${o}ms (method=${n}, target=${t})`))},o);this.pendingRpcRequests.set(a,{resolve:s,reject:i,timer:u}),this.channel.postMessage({type:"rpc_request",requestId:a,sourceRuntimeId:this.runtimeId,targetRuntimeId:t,method:n,params:r,timeoutMs:o,createdAt:Z()})})}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>Z()-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>Z()){let s=r.tabs.find(a=>a.runtimeId===o.runtimeId);if(s&&s.updatedAt>Z()-2*this.heartbeatMs){n=!1;return}}r.workflowLock={runtimeId:this.runtimeId,runId:t,lockedAt:Z(),expiresAt:Z()+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>Z()}getWorkflowLockInfo(){let t=this.state.workflowLock;return!t||t.expiresAt<=Z()?{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(a=>a.runtimeId===n);i&&(i.url=r||i.url,i.title=o||i.title,i.updatedAt=Z())})}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=qs(window.location.href),n=document.title||void 0;this.mutate("local",r=>{let o=r.tabs.find(a=>a.runtimeId===this.runtimeId);if(o)o.url=t||o.url,o.title=n||o.title,o.updatedAt=Z();else{let a=r.nextLogicalTabId++;r.tabs.push({logicalTabId:a,runtimeId:this.runtimeId,url:t,title:n,openedAt:Z(),updatedAt:Z(),external:!1})}let s=r.lease;(!s||s.expiresAt<=Z()||s?.holderRuntimeId===this.runtimeId)&&(r.lease={holderRuntimeId:this.runtimeId,expiresAt:Z()+this.leaseMs,updatedAt:Z()},!r.activeLogicalTabId&&this.localLogicalTabId&&(r.activeLogicalTabId=this.localLogicalTabId)),r.workflowLock?.runtimeId===this.runtimeId&&(r.workflowLock.expiresAt=Z()+this.leaseMs*5),this.pruneDetachedTabs(r)}),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<=Z();(t||s||o?.holderRuntimeId===this.runtimeId)&&(r.lease={holderRuntimeId:this.runtimeId,expiresAt:Z()+this.leaseMs,updatedAt:Z()},!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}))},Oo.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=cr(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=cr(this.state,this.siteId,this.sessionId);n(r),r.seq=Math.max(1,Number(r.seq)||1)+(t==="local"?1:0),r.updatedAt=Z(),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.pruneDetachedTabs(t),this.state=t,this.syncLocalLogicalTabId(),this.onStateChange?.(this.state,"remote"),this.notifyRoleChange()))}loadState(){try{let t=window.localStorage.getItem(this.key);if(!t)return Ys(this.siteId,this.sessionId);let n=JSON.parse(t);return cr(n,this.siteId,this.sessionId)}catch(t){return console.warn("[rover] Failed to load shared state from localStorage:",t),Ys(this.siteId,this.sessionId)}}persistState(){try{window.localStorage.setItem(this.key,JSON.stringify(this.state))}catch{}}};$(Oo,"ROLE_CHANGE_DEBOUNCE_MS",200);var Do=Oo;var Ud="https://extensionrouter.rtrvr.ai";function lr(e,t){let n=Number(e);return Number.isFinite(n)?n:t}function Ec(e,t=8e3){let n=String(e??"");return n.length<=t?n:`${n.slice(0,t)}\u2026`}function Fd(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,lr(e.updatedAt,0),t,n,r,o].join(":")}function Hd(e){let t=Ud,n=String(e||t).trim().replace(/\/+$/,"");if(!n)return t;if(n.endsWith("/extensionRouter"))return n;try{let r=new URL(n),o=r.pathname.replace(/\/+$/,"");if(o&&o!=="/"||r.hostname.toLowerCase()==="extensionrouter.rtrvr.ai")return n}catch{}return`${n}/extensionRouter`}function Xs(e,t){let n=new Error(e);return n.details=t,n}var Uo=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,"onStateChange");$(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);$(this,"state","active");let n=String(t.authToken||t.apiKey||"").trim();if(!n)throw Xs("Rover cloud checkpoint requires apiKey or authToken.");this.endpoint=Hd(t.apiBase),this.token=n,this.siteId=t.siteId,this.visitorId=t.visitorId,this.ttlHours=Math.max(1,Math.min(168,Math.floor(lr(t.ttlHours,1)))),this.flushIntervalMs=Math.max(2e3,Math.floor(lr(t.flushIntervalMs,8e3))),this.pullIntervalMs=Math.max(2e3,Math.floor(lr(t.pullIntervalMs,9e3))),this.minFlushIntervalMs=Math.max(1e3,Math.floor(lr(t.minFlushIntervalMs,2500))),this.shouldWrite=t.shouldWrite||(()=>!0),this.buildCheckpoint=t.buildCheckpoint,this.onCheckpoint=t.onCheckpoint,this.onStateChange=t.onStateChange,this.onError=t.onError}start(){this.started||(this.started=!0,this.setState("active"),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.state==="paused_auth"||!this.dirty&&!t||!this.shouldWrite()||!t&&Date.now()-this.lastFlushAt<this.minFlushIntervalMs)return;let n=this.buildCheckpoint();if(!n)return;let r=Fd(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),this.setState("active")}catch(o){this.handleCheckpointError(o,"roverSessionCheckpointUpsert")}finally{this.pushInFlight=!1}}async pull(t){if(!this.pullInFlight&&this.state!=="paused_auth"&&!(!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"),this.setState("active")}catch(n){this.handleCheckpointError(n,"roverSessionCheckpointGet")}finally{this.pullInFlight=!1}}}applyRemoteCheckpoint(t,n){let r=Math.max(0,Math.floor(lr(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:Ec(i,2e3)}:void 0}throw Xs(`Checkpoint HTTP ${r.status}`,{action:t,status:r.status,payload:s})}let o=await r.json();if(o?.success===!1)throw Xs("Checkpoint extensionRouter returned success=false",{action:t,status:r.status,payload:o});return o?.data}setState(t,n){this.state!==t&&(this.state=t,this.onStateChange?.(t,n||{}))}handleCheckpointError(t,n){let r=this.normalizeCheckpointError(t),o=this.isAuthFailure(r);o&&this.setState("paused_auth",{reason:"auth_failed",action:n,code:r.code,message:r.message}),this.onError?.(t,{action:n,state:this.state,code:r.code,message:r.message,status:r.status,paused:o})}normalizeCheckpointError(t){let n=t,r=n?.details,o=r?.payload||r?.response||r,s=o?.errorCode||o?.errorDetails?.code||o?.error?.code||o?.code,i=o?.error||o?.errorDetails?.message||o?.error?.message||n?.message||"Checkpoint request failed",a=Number(r?.status);return{code:typeof s=="string"?s:void 0,message:Ec(i,1e3),status:Number.isFinite(a)?a:void 0}}isAuthFailure(t){let n=String(t.code||"").toUpperCase();return n==="INVALID_API_KEY"||n==="MISSING_API_KEY"||n==="UNAUTHENTICATED"||n==="PERMISSION_DENIED"?!0:t.status===401||t.status===403}};var Pd="rover-runtime-state-db",Fo="runtime-state",zs=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{}}},Ks=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(Pd,1);r.onupgradeneeded=()=>{let o=r.result;o.objectStoreNames.contains(Fo)||o.createObjectStore(Fo)},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(Fo,t),a=i.objectStore(Fo);n(a,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 wc(){let e=new zs,t=new Ks;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 Js=1,Bd="rover:runtime:",Wd="rover:runtime-id:",xc="rover:visitor-id:",js=160,Qs=240,Rc=80,Ko=40,Vd=8e3,$d=15*6e4,Gd=12,qd=3600*24*365,Yd=1,Xd=3e3,zd=9e4,Kd=12e3,jd=30,jo=240,gn=null,ze=null,Ie=null,ge=null,ce=null,ur=null,w=null,Bn=null,Se="",H=null,wt=null,$o=null,Et=[],Go=!1,dr=!1,kc=0,lt,Qo=!1,pt="controller",wn=!1,Wn=!1,Pn=null,yc=!1,Mr=null,Ho="",Ic,cn=new Map,Qd=new Set(["run_started","run_completed","assistant","status","tool_start","tool_result","auth_required","navigation_guardrail","error"]),qo=[],Yo=new Map;function Ce(e,t){lf(e,t);let n=Yo.get(e);if(n)for(let r of n)try{r(t)}catch{}}function Sc(e,t){Yo.has(e)||Yo.set(e,new Set);let n=Yo.get(e);return n.add(t),()=>{n.delete(t)}}function Jd(e){return typeof e=="string"?{name:e}:e}function bn(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Zd(e){let t=`${Wd}${e}`;try{let n=window.sessionStorage.getItem(t);if(n&&n.trim())return n.trim();let r=bn("runtime");return window.sessionStorage.setItem(t,r),r}catch{return bn("runtime")}}function Jo(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 Po(e){return String(e||"").trim().replace(/[^a-zA-Z0-9._:-]/g,"").slice(0,180)}function Ac(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]||""):void 0}catch{return}}function _c(e,t,n){try{let r=n?`; domain=${n}`:"";return document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${qd}; samesite=lax${r}`,Ac(e)===t}catch{return!1}}function ef(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 tf(e,t){let n=`rover_vid_${Jo(e)}`;for(let r of ef(window.location.hostname))if(_c(n,t,r))return;_c(n,t)}function Bo(e,t){let n=`${xc}${e}`;try{window.localStorage.setItem(n,t)}catch{}try{window.sessionStorage.setItem(n,t)}catch{}tf(e,t)}function Cc(e){let t=Po(e.visitorId||"");if(t)return t;if(e.checkpointing?.autoVisitorId===!1)return;let n=`${xc}${e.siteId}`,r=`rover_vid_${Jo(e.siteId)}`,o=Po(Ac(r)||"");if(o)return Bo(e.siteId,o),o;try{let i=Po(window.localStorage.getItem(n)||"");if(i)return Bo(e.siteId,i),i}catch{}try{let i=Po(window.sessionStorage.getItem(n)||"");if(i)return Bo(e.siteId,i),i}catch{}let s=`v_${Jo(`${e.siteId}:${bn("visitor")}`)}_${Date.now().toString(36)}`;return Bo(e.siteId,s),s}function nf(e,t){return`visitor-${Jo(`${e}:${t}`)}`}function Mc(e){!ze||!Ie||(ze.registerTool(e.def,e.handler),Ie.postMessage({type:"register_tool",tool:e.def}))}function rf(e){return`${Bd}${e}`}function En(e="session_start"){let t=Date.now();return{taskId:bn("task"),status:"running",startedAt:t,lastUserAt:void 0,lastAssistantAt:void 0,boundaryReason:e,endedAt:void 0}}function Lc(e,t){return{version:Js,sessionId:e,runtimeId:t,uiOpen:!1,uiHidden:!1,uiStatus:void 0,uiMessages:[],timeline:[],executionMode:"controller",workerState:void 0,pendingRun:void 0,taskEpoch:1,activeTask:En(),lastRoutingDecision:void 0,updatedAt:Date.now()}}function Ke(e,t=Vd){return e.length<=t?e:`${e.slice(0,t)}\u2026`}function Xo(e){if(e!=null){if(typeof e=="string")return Ke(e,1200);try{return Ke(JSON.stringify(e),1200)}catch{try{return Ke(String(e),1200)}catch{return}}}}function rs(e){let t=e?.telemetry,n=Number(t?.sampleRate),r=Number.isFinite(n)?Math.min(1,Math.max(0,n)):1,o=Number(t?.flushIntervalMs),s=Number.isFinite(o)?Math.min(6e4,Math.max(2e3,Math.floor(o))):Kd,i=Number(t?.maxBatchSize),a=Number.isFinite(i)?Math.min(80,Math.max(1,Math.floor(i))):jd;return{enabled:t?.enabled!==!1,sampleRate:r,flushIntervalMs:s,maxBatchSize:a,includePayloads:t?.includePayloads===!0}}function Zs(e){return!(!e||!rs(e).enabled||!(e.authToken||e.apiKey))}function Tc(e){if(e!=null){if(typeof e=="string")return Ke(e,260);if(typeof e=="number"||typeof e=="boolean")return e;if(Array.isArray(e))return{type:"array",length:e.length};if(typeof e=="object"){let n={type:"object",keys:Object.keys(e).slice(0,20)},r=["code","message","stage","status","reason","taskId","runId","policyAction"];for(let o of r){let s=e?.[o];s!=null&&(typeof s=="string"?n[o]=Ke(s,180):(typeof s=="number"||typeof s=="boolean")&&(n[o]=s))}return n}}}function of(e,t){if(!t)return Tc(e);let n=Uc(e);if(n!=null)return typeof n=="string"?Ke(n,1e3):typeof n=="number"||typeof n=="boolean"?n:Array.isArray(n)?{type:"array",length:n.length}:typeof n=="object"?n:Tc(e)}function ei(){$o&&(clearInterval($o),$o=null)}var sf="https://extensionrouter.rtrvr.ai";function af(e){let t=sf,n=String(e||t).trim().replace(/\/+$/,"");if(!n)return t;if(n.endsWith("/extensionRouter"))return n;try{let r=new URL(n),o=r.pathname.replace(/\/+$/,"");if(o&&o!=="/"||r.hostname.toLowerCase()==="extensionrouter.rtrvr.ai")return n}catch{}return`${n}/extensionRouter`}function cf(e){return af(e.apiBase)}async function os(e=!1){if(Go||dr)return;if(!ce||!Zs(ce)){Et=[];return}if(!Et.length)return;let t=rs(ce),n=String(ce.authToken||ce.apiKey||"").trim();if(!n)return;let r=Et.splice(0,t.maxBatchSize);if(r.length){Go=!0;try{let o=await fetch(cf(ce),{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({action:"roverTelemetryIngest",data:{siteId:ce.siteId,runtimeId:Se,sessionId:w?.sessionId,visitorId:lt,flushReason:e?"manual":"interval",sdkVersion:"rover_sdk_v1",pageUrl:window.location.href,userAgent:navigator.userAgent,sampleRate:t.sampleRate,events:r}})});if(!o.ok){o.status===401||o.status===403?dr=!0:Et=[...r,...Et].slice(-jo);return}let s=await o.json().catch(()=>{});if(s?.success===!1){let i=String(s?.errorCode||s?.errorDetails?.code||"").toUpperCase();(i==="INVALID_API_KEY"||i==="MISSING_API_KEY"||i==="UNAUTHENTICATED"||i==="PERMISSION_DENIED")&&(dr=!0);return}}catch{Et=[...r,...Et].slice(-jo)}finally{Go=!1}}}function ti(e){if(ei(),dr=!1,!Zs(e)){Et=[];return}let t=rs(e);$o=setInterval(()=>{os(!1)},t.flushIntervalMs)}function lf(e,t){if(!Zs(ce)||dr)return;let n=rs(ce);if(n.sampleRate<1&&Math.random()>n.sampleRate)return;let r={name:e,ts:Date.now(),seq:++kc,payload:of(t,n.includePayloads)};Et.push(r),Et.length>jo&&(Et=Et.slice(-jo)),Et.length>=n.maxBatchSize&&os(!1)}function Wo(e,t,n="tab_not_accessible"){let r=Number(t?.logicalTabId)||void 0,o=t?.url||"",s=t?.title||(t?.external?"External Tab (Inaccessible)":"Inactive Tab"),i=String(n||"").trim(),a=i?` Reason: ${i}.`:"",u=t?.external?`This external tab is tracked in virtual mode only. Live DOM control and accessibility-tree access are unavailable here.${a}`:`This tab is currently not attached to an active Rover runtime. Switch to a live tab or reopen it.${a}`;return{url:o,title:s,contentType:"text/html",content:u,metadata:{inaccessible:!0,external:!!t?.external,accessMode:t?.external?"external_placeholder":"inactive_tab",reason:n,logicalTabId:r}}}function Vo(e,t,n="tab_not_accessible"){let r=Number(t?.logicalTabId)||0,o=t?.url||"",s=t?.external?`Tab ${r} is external to the active runtime and cannot be controlled directly.`:`Tab ${r} is not attached to an active Rover runtime.`,i=t?.external?"DOMAIN_SCOPE_BLOCKED":"TAB_NOT_ACCESSIBLE";return{success:!1,error:s,allowFallback:!0,output:{success:!1,error:{code:i,message:s,missing:[],next_action:t?.external?"Use open_new_tab for external context or continue on an in-scope tab.":"Switch to an active tab and retry.",retryable:!1},blocked_url:o||void 0,logical_tab_id:r||void 0,external:!!t?.external,policy_action:t?.external?e.externalNavigationPolicy||"open_new_tab_notice":void 0,reason:n},errorDetails:{code:i,message:s,retryable:!1,details:{logicalTabId:r,blockedUrl:o,external:!!t?.external,reason:n}}}}function uf(e){if(e==="analyze"||e==="route"||e==="execute"||e==="verify"||e==="complete")return e}function df(e){return e?e==="analyze"?"Analyze":e==="route"?"Route":e==="execute"?"Execute":e==="verify"?"Verify":e==="complete"?"Complete":"Status":"Status"}function ff(e,t,n){return[String(t||""),String(e||"").trim().toLowerCase(),String(n||"").trim().toLowerCase()].join("|")}function pf(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 hf(){return w?.pendingRun?.id}function Nc(){let e=H?.getState()?.activeRun;return!!(e&&e.runtimeId&&e.runtimeId!==Se)}function Dc(){return!Nc()}function Oc(e){if(e==="observer")return Nc()?"Observing active run in another tab...":"Send to take control and run here."}function mf(e){let t=typeof e?.type=="string"?e.type:"";if(!Qd.has(t))return!1;let n=typeof e?.runId=="string"&&e.runId?e.runId:void 0,r=hf();if(t==="run_started")return!n||!r?!1:r!==n;if(!n)return!1;if(t==="run_completed"){if(!r){let o=H?.getState()?.activeRun?.runId;return!(o&&o===n)}return r!==n}return r?r!==n:!0}function gf(e){if(!e||typeof e!="object")return{taskComplete:!1,needsUserInput:!1};let t=e.needsUserInput===!0;return{taskComplete:e.taskComplete===!0&&!t,needsUserInput:t}}function bf(e){if(e&&cn.has(e))return cn.get(e);if(w?.uiMessages?.length)for(let t=w.uiMessages.length-1;t>=0;t-=1){let n=w.uiMessages[t];if(n.role==="assistant"&&n.text)return n.text}}function Ef(e){return Bn?Bn.readSync(e):null}function Uc(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 Fc(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 Zo(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e.slice(-t)){let o=Uc(r);o!==void 0&&n.push(o)}return n}async function wf(e){if(!Bn)return null;try{return await Bn.readAsync(e)}catch{return null}}function Lr(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-js)){let r=n?.role;r!=="user"&&r!=="assistant"&&r!=="system"||t.push({id:typeof n?.id=="string"&&n.id?n.id:bn("msg"),role:r,text:Ke(String(n?.text||"")),ts:Number(n?.ts)||Date.now(),sourceRuntimeId:typeof n?.sourceRuntimeId=="string"?n.sourceRuntimeId:void 0})}return t}function Nr(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-Qs)){let r=Ke(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:bn("timeline"),kind:o,title:r,detail:n?.detail?Ke(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 Vn(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(-Rc).map(a=>Fc(a)).filter(a=>!!a),s=Zo(n,Ko),i=Zo(r,Ko*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 Dr(e,t,n){if(!e||typeof e!="object")return Lc(t,n);let r=En(),o=Hr(e.activeTask,r);return{version:Js,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"?Ke(e.uiStatus,300):void 0,uiMessages:Lr(e.uiMessages),timeline:Nr(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:Vn(e.workerState),pendingRun:Or(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"?Ke(e.lastRoutingDecision.reason,200):void 0,ts:Number(e.lastRoutingDecision.ts)||Date.now()}:void 0,updatedAt:Number(e.updatedAt)||Date.now()}}function Hr(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"?Ke(e.boundaryReason,120):t.boundaryReason,endedAt:Number(e.endedAt)||void 0}}function yf(e,t){return Hr(e,t)}function Hc(e){if(e)return{trajectoryId:e.trajectoryId,history:Array.isArray(e.history)?e.history.slice(-Rc).map(t=>Fc(t)).filter(t=>!!t):[],plannerHistory:Zo(e.plannerHistory,Ko),agentPrevSteps:Zo(e.agentPrevSteps,Ko*2),updatedAt:Number(e.updatedAt)||Date.now()}}function Or(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 Re(){if(!(!w||!ur))try{w.updatedAt=Date.now(),Bn?.write(ur,w),Qo||wt?.markDirty()}catch{}}function _f(){if(yc)return;yc=!0;let e=()=>{w?.pendingRun?.autoResume&&H?.clearActiveRunRuntimeId(w.pendingRun.id),H?.broadcastClosing(),w?.pendingRun&&H?.releaseWorkflowLock(w.pendingRun.id),Re(),os(!0),ei(),wt?.markDirty(),wt?.syncNow(),wt?.stop(),H?.stop()};window.addEventListener("pagehide",e,{capture:!0});let t=n=>{n.persisted&&(H&&(H.reloadFromStorage(),H.registerCurrentTab(window.location.href,document.title||void 0),H.claimLease(!1)),Wn=!1,ce&&ti(ce))};window.addEventListener("pageshow",t)}function Pr(e="implicit"){if(w)return w.activeTask||(w.activeTask=En(e),w.taskEpoch=Math.max(1,Number(w.taskEpoch)||1)),w.activeTask}function Tf(e,t=Date.now()){if(!w)return;let n=Pr("implicit");n&&(e==="user"&&(n.lastUserAt=t),e==="assistant"&&(n.lastAssistantAt=t),n.status==="ended"&&(n.status="running",n.endedAt=void 0))}function vc(e="worker_task_active",t=Date.now()){if(!w)return;let n=Pr(e);n&&(n.status="running",n.endedAt=void 0,n.boundaryReason=e,!n.lastUserAt&&!n.lastAssistantAt&&(n.lastAssistantAt=t),H?.syncTask({...n},w.taskEpoch),Re())}function vf(e="worker_task_complete",t=Date.now()){if(!w)return;let n=Pr(e);n&&(n.status="completed",n.endedAt=t,n.boundaryReason=e,H?.syncTask({...n},w.taskEpoch),Re())}function $n(){Mr=null,ge?.setTaskSuggestion({visible:!1})}function Pc(){ge?.clearMessages(),ge?.clearTimeline(),$n()}function xf(){let e=w?.pendingRun;if(!e)return!1;if(!H)return!0;let t=H?.getState()?.activeRun;if(t?.runId&&t.runId===e.id||t?.runtimeId&&t.runtimeId!==Se)return!0;let n=Date.now()-Number(e.startedAt||0);return n>=0&&n<=Xd}function Rf(){if(!w?.pendingRun||xf()||!H)return;let e=w.pendingRun,t=Date.now()-Number(e.startedAt||0);!Number.isFinite(t)||t<zd||(Dt(void 0),H?.clearActiveRunRuntimeId(e.id),H?.releaseWorkflowLock(e.id),H?.setActiveRun(void 0))}function Wt(e,t,n=!0,r){let o=Ke(String(t||""));if(!o)return;let s={id:r?.id||bn("msg"),role:e,text:o,ts:r?.ts||Date.now(),sourceRuntimeId:r?.sourceRuntimeId};return ge?.addMessage(s.role,s.text),w&&n&&(w.uiMessages.push(s),w.uiMessages.length>js&&(w.uiMessages=w.uiMessages.slice(-js)),Tf(s.role,s.ts),Re()),H&&r?.publishShared!==!1&&(H.appendMessage({id:s.id,role:s.role,text:s.text,ts:s.ts}),H.markTaskActivity(s.role,s.ts)),s}function ni(e){for(let t of e)Wt(t.role,t.text,!1,{id:t.id,ts:t.ts,sourceRuntimeId:t.sourceRuntimeId,publishShared:!1})}function Ye(e,t=!0){let n={id:e.id||bn("timeline"),kind:e.kind,title:Ke(e.title,400),detail:e.detail?Ke(e.detail,1200):void 0,status:e.status,ts:e.ts||Date.now(),sourceRuntimeId:e.sourceRuntimeId};return ge?.addTimelineEvent(n),w&&t&&(w.timeline.push(n),w.timeline.length>Qs&&(w.timeline=w.timeline.slice(-Qs)),Re()),H&&e.publishShared!==!1&&H.appendTimeline({id:n.id,kind:n.kind,title:n.title,detail:n.detail,status:n.status,ts:n.ts}),n}function ri(e){ge?.clearTimeline();for(let t of e)Ye({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 kt(e,t){ge?.setStatus(e),w&&(w.uiStatus=Ke(e,300),Re()),H&&t?.publishShared!==!1&&H.setStatus(e)}function Ur(e,t){pt=e,w&&(w.executionMode=e,Re()),ge?.setExecutionMode(e,{controllerRuntimeId:t?.holderRuntimeId??H?.getCurrentHolderRuntimeId(),localLogicalTabId:t?.localLogicalTabId??H?.getLocalLogicalTabId(),activeLogicalTabId:t?.activeLogicalTabId??H?.getActiveLogicalTabId(),canTakeControl:!0,canComposeInObserver:Dc(),note:Oc(e)}),Ce("mode_change",{mode:e,...t})}function Dt(e){if(!w)return;w.pendingRun=e;let t=Pr("implicit");t&&(e?(t.status="running",t.endedAt=void 0):t.status==="running"&&(t.status="completed")),Re()}function Bc(e,t){let n=String(e||"").trim();if(!n||!Ie)return;if(pt==="observer"&&!(H?.requestControl()??!1)){Wt("system","Unable to take control right now because another tab is still running Rover actions.",!0),Ye({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&&Wt("user",n,!0);let i=w?.pendingRun?.id===r?w.pendingRun.attempts:0;Dt({id:r,text:n,startedAt:Date.now(),attempts:o?i+1:0,autoResume:t?.autoResume!==!1}),Ic=n,H?.acquireWorkflowLock(r),H?.setActiveRun({runId:r,text:n}),Ie.postMessage({type:"run",text:n,runId:r,resume:o}),Pn&&clearTimeout(Pn);let a=r;Pn=setTimeout(()=>{w?.pendingRun?.id===a&&(Dt(void 0),H?.releaseWorkflowLock(a),H?.setActiveRun(void 0),kt("Task timed out."),Wt("system","Task timed out after 5 minutes with no response.",!0),Ce("error",{message:"Run safety timeout"})),Pn=null},5*6e4)}function zo(e,t){let n=String(e||"").trim();if(!n)return;Rf();let r=w?.activeTask?.status,o=!!t?.startNewTask||r==="completed"||r==="ended";if(H?.pruneTabs({dropRuntimeDetached:!0,dropAllDetachedExternal:o}),o){let s=t?.reason||(r==="completed"?"auto_after_task_complete":"auto_after_task_end");Wr({reason:s,clearUi:!0})}$n(),Bc(n,{appendUserMessage:!0,resume:!1,autoResume:!0})}function es(){if(pt==="observer")return;let e=H?.getState()?.activeRun;if(e?.runtimeId&&e.runtimeId!==Se&&!(w?.pendingRun?.id===e.runId)||!wn||!Ie||Wn||!w?.pendingRun||w.activeTask?.status==="ended")return;let t=w.pendingRun;if(!t.autoResume)return;let n=ce?.siteId||"";if(!!!sessionStorage.getItem(`rover:tab-alive:${n}`)&&!(H?.listTabs()||[]).some(a=>a.runtimeId!==Se&&a.updatedAt>Date.now()-2*2e3)&&w?.pendingRun){Dt(void 0),kt("Previous task expired.");return}if(Date.now()-t.startedAt>$d){Dt(void 0),kt("Previous task expired after navigation.");return}if(t.attempts>=Gd){Dt(void 0),Wt("system","Auto-resume stopped after too many navigation attempts.",!0);return}Wn=!0,kt("Resuming previous task after navigation..."),Bc(t.text,{runId:t.id,resume:!0,appendUserMessage:!1,autoResume:!0})}async function kf(e){if(!w)return;let t=await wf(e);if(!t||!w)return;let n=Number(w.updatedAt)||0,r=Dr({...t,sessionId:w.sessionId,runtimeId:Se},w.sessionId,Se);(Number(r.updatedAt)||0)<=n+200||(w=Dr({...w,...r,sessionId:w.sessionId,runtimeId:Se},w.sessionId,Se),Re(),ge&&(ge.clearMessages(),ni(w.uiMessages),ri(w.timeline),w.uiStatus&&ge.setStatus(w.uiStatus),w.uiHidden?ge.hide():(ge.show(),w.uiOpen?ge.open():ge.close())),wn&&Ie&&w.workerState&&pt==="controller"&&(Ie.postMessage({type:"hydrate_state",state:w.workerState}),Ce("context_restored",{source:"indexeddb_checkpoint",ts:Date.now()})))}function oi(e,t){if(w){if(t==="remote"){let n=Math.max(1,Number(w.taskEpoch)||1),r=Math.max(1,Number(e.taskEpoch)||1),o=r>n;w.taskEpoch=Math.max(n,r);let s=w.activeTask||En("shared_sync");w.activeTask=yf(e.task,s),o&&(w.uiMessages=[],w.timeline=[],Pc(),Dt(void 0),$n());let i=Lr(e.uiMessages),a=new Set(i.map(A=>A.id));if(i.length<w.uiMessages.length||w.uiMessages.some(A=>!a.has(A.id)))w.uiMessages=i,ge?.clearMessages(),ni(w.uiMessages);else{let A=new Set(w.uiMessages.map(S=>S.id));for(let S of i)A.has(S.id)||(Wt(S.role,S.text,!0,{id:S.id,ts:S.ts,sourceRuntimeId:S.sourceRuntimeId,publishShared:!1}),A.add(S.id))}let v=Nr(e.timeline),p=new Set(v.map(A=>A.id));if(v.length<w.timeline.length||w.timeline.some(A=>!p.has(A.id)))w.timeline=v,ri(w.timeline);else{let A=new Set(w.timeline.map(S=>S.id));for(let S of v)A.has(S.id)||(Ye({id:S.id,kind:S.kind,title:S.title,detail:S.detail,status:S.status,ts:S.ts,sourceRuntimeId:S.sourceRuntimeId,publishShared:!1},!0),A.add(S.id))}if(typeof e.uiStatus=="string"&&kt(e.uiStatus,{publishShared:!1}),e.activeRun&&e.activeRun.runtimeId!==Se?Dt(Or({id:e.activeRun.runId,text:e.activeRun.text,startedAt:e.activeRun.startedAt,attempts:w.pendingRun?.attempts||0,autoResume:!0})):!e.activeRun&&pt==="observer"&&Dt(void 0),pt==="observer"&&Ur("observer",{localLogicalTabId:H?.getLocalLogicalTabId(),activeLogicalTabId:H?.getActiveLogicalTabId(),holderRuntimeId:H?.getCurrentHolderRuntimeId()}),e.workerContext){let A=Vn(e.workerContext),S=Number(w.workerState?.updatedAt)||0,M=Number(A?.updatedAt)||0;A&&M>S+100&&(w.workerState=A,wn&&Ie&&pt==="controller"&&(Ie.postMessage({type:"hydrate_state",state:A}),Ce("context_restored",{source:"shared_session",ts:Date.now()})))}}w.uiMessages=Lr(w.uiMessages),w.timeline=Nr(w.timeline),w.workerState=Vn(w.workerState),w.activeTask=Hr(w.activeTask,En("implicit")),Re()}}function Wc(e){let t=En("checkpoint_clone");return{version:Js,sessionId:e.sessionId,runtimeId:e.runtimeId,uiOpen:!!e.uiOpen,uiHidden:!!e.uiHidden,uiStatus:typeof e.uiStatus=="string"?Ke(e.uiStatus,300):void 0,uiMessages:Lr(e.uiMessages),timeline:Nr(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:Vn(e.workerState),pendingRun:Or(e.pendingRun),taskEpoch:Math.max(1,Number(e.taskEpoch)||1),activeTask:Hr(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 If(e){return!(e.sessionScope==="tab"||e.checkpointing?.enabled!==!0||!(e.apiKey||e.authToken)||!lt)}function Sf(){if(!w||!ce||!lt)return null;let e=H?.getState(),t=Wc(w),n=Math.max(Number(e?.updatedAt||0),Number(t.updatedAt||0),Date.now());return{version:Yd,siteId:ce.siteId,visitorId:lt,sessionId:w.sessionId,updatedAt:n,sharedState:e,runtimeState:t}}function Af(e){if(!e||typeof e!="object"||!w||!ce||e.siteId&&e.siteId!==ce.siteId||lt&&e.visitorId&&e.visitorId!==lt)return;let t=typeof e.sessionId=="string"&&e.sessionId.trim()?e.sessionId.trim():w.sessionId;Qo=!0;try{if(t&&w.sessionId!==t&&(w.sessionId=t,ce={...ce,sessionId:t},ts(ce),Ie?.postMessage({type:"update_config",config:{sessionId:t}})),e.sharedState&&H&&H.hydrateExternalState(e.sharedState)&&(oi(H.getState(),"remote"),Ur(H.getRole(),{localLogicalTabId:H.getLocalLogicalTabId(),activeLogicalTabId:H.getActiveLogicalTabId(),holderRuntimeId:H.getCurrentHolderRuntimeId()})),e.runtimeState&&typeof e.runtimeState=="object"){let n=Dr({...e.runtimeState,sessionId:t,runtimeId:Se},t,Se),r=Number(w.updatedAt)||0;(Number(n.updatedAt)||0)>r+200&&(w=Dr({...w,...n,sessionId:t,runtimeId:Se},t,Se),Re(),w.uiStatus&&ge?.setStatus(w.uiStatus),w.uiHidden?ge?.hide():(ge?.show(),w.uiOpen?ge?.open():ge?.close()),wn&&w.workerState&&(Ie?.postMessage({type:"hydrate_state",state:w.workerState}),Ce("context_restored",{source:"cloud_checkpoint",ts:Date.now()})),pt==="controller"&&es())}}finally{Qo=!1}}function Vc(e){if(wt?.stop(),wt=null,!!If(e)&&lt)try{let t=n=>{Ce("checkpoint_state",n),e.checkpointing?.onStateChange?.(n)};wt=new Uo({apiBase:e.apiBase,apiKey:e.apiKey,authToken:e.authToken,siteId:e.siteId,visitorId:lt,ttlHours:e.checkpointing?.ttlHours??1,flushIntervalMs:e.checkpointing?.flushIntervalMs,pullIntervalMs:e.checkpointing?.pullIntervalMs,minFlushIntervalMs:e.checkpointing?.minFlushIntervalMs,shouldWrite:()=>pt==="controller",buildCheckpoint:()=>Sf(),onCheckpoint:n=>{Af(n)},onStateChange:(n,r)=>{t({state:n,reason:r.reason,action:r.action,code:r.code,message:r.message}),n==="paused_auth"&&Ce("checkpoint_error",{action:r.action,code:r.code||"INVALID_API_KEY",message:r.message||"Checkpoint sync paused due to auth failure.",disabled:!0,reason:r.reason||"auth_failed"})},onError:(n,r)=>{e.checkpointing?.onError?.(r),r.paused||Ce("checkpoint_error",{action:r.action,code:r.code,message:r.message,status:r.status,disabled:!1,reason:"transient_failure"})}}),wt.start(),wt.markDirty()}catch{wt=null}}function ts(e){if(w){if(H?.stop(),H=null,e.sessionScope==="tab"){Ur("controller");return}H=new Do({siteId:e.siteId,sessionId:w.sessionId,runtimeId:Se,leaseMs:e.tabPolicy?.actionLeaseMs,onRoleChange:(t,n)=>{Ur(t,n);let r=t==="controller"&&(ce?.allowActions??!0);if(ze?.setAllowActions(r),t==="controller"){let o=H?.getWorkerContext();if(o){let s=Vn(o),i=Number(w?.workerState?.updatedAt)||0,a=Number(s?.updatedAt)||0;s&&a>i+100&&(w&&(w.workerState=s,Re()),wn&&Ie&&(Ie.postMessage({type:"hydrate_state",state:s}),Ce("context_restored",{source:"controller_handoff",ts:Date.now()})))}es()}},onStateChange:(t,n)=>{oi(t,n)},onSwitchRequested:t=>{t>0&&(Br(),Ye({kind:"status",title:`Switched to tab #${t}`,status:"info"}))}}),H.start(),H.setRpcRequestHandler(async t=>{if(!ze)throw new Error("Bridge not available");if(t.method==="getPageData")return ze.getPageData(t.params);if(t.method==="executeTool")return ze.executeTool(t.params.call,t.params.payload);throw new Error(`Unknown RPC method: ${t.method}`)}),w?.activeTask&&H.syncTask({...w.activeTask,taskId:w.activeTask.taskId},w.taskEpoch),w?.workerState&&H.setWorkerContext(Hc(w.workerState))}}function Cf(e){let t=Ke(bf(e)||"Done.",1200);ge?.clearTimeline(),w&&(w.timeline=[]),H?.clearTimeline(),Ye({id:e?`run:${e}:final`:void 0,kind:"tool_result",title:"Execution completed",detail:t,status:"success"})}function Mf(e){if(!(!e||typeof e!="object")&&!mf(e)){if(e.type==="assistant"){let t=String(e.text||"");if(typeof e.runId=="string"&&e.runId&&(cn.set(e.runId,t),cn.size>80)){let n=cn.keys().next().value;n&&cn.delete(n)}Wt("assistant",t,!0),Ye({kind:"tool_result",title:"Assistant update",detail:t,status:"success"});return}if(e.type==="status"){let t=uf(e.stage),n=e.message?String(e.message):void 0,r=e.compactThought?String(e.compactThought):void 0,o=ff(n,t,r);if(n&&kt(n),o&&o!==Ho&&(Ho=o,n)){let s=!!(e.thought||r),i=r||(e.thought?String(e.thought):"");if(s&&t!=="analyze"&&t!=="route"&&t!=="complete"&&!pf(i,Ic))Ye({kind:"thought",title:i,detail:e.thought?String(e.thought):r,status:"pending"});else{let u=t?`${df(t)}: ${n}`:n;Ye({kind:"status",title:u,detail:r||(e.thought?String(e.thought):void 0),status:t==="complete"?"success":"info"})}}Ce("status",e);return}if(e.type==="tool_start"){Ye({kind:"tool_start",title:`Running ${e.call?.name||"tool"}`,detail:Xo(e.call?.args),status:"pending"}),Ce("tool_start",e);return}if(e.type==="tool_result"){Ye({kind:"tool_result",title:`${e.call?.name||"tool"} completed`,detail:Xo(e.result),status:e?.result?.success===!1?"error":"success"}),Ce("tool_result",e);return}if(e.type==="auth_required"){Ce("auth_required",e.error),e.error?.message&&(Wt("system",`Auth required: ${e.error.message}`,!0),Ye({kind:"error",title:"Auth required",detail:String(e.error.message),status:"error"}));return}if(e.type==="navigation_guardrail"){Ce("navigation_guardrail",e),Ye({kind:"status",title:"Navigation guardrail",detail:Xo(e),status:"info"});return}if(e.type==="error"){Wt("system",`Error: ${e.message||"unknown"}`,!0),Ye({kind:"error",title:"Execution error",detail:String(e.message||"unknown"),status:"error"}),Ce("error",e);return}if(e.type==="state_snapshot"){w&&(w.workerState=Vn({...e.state||{},updatedAt:Date.now()}),e?.activeRun?.runId&&e?.activeRun?.text&&!w.pendingRun&&(w.pendingRun=Or({id:e.activeRun.runId,text:e.activeRun.text,startedAt:e.activeRun.startedAt,attempts:0,autoResume:!0})),e?.activeRun?.runId&&e?.activeRun?.text&&H?.setActiveRun({runId:e.activeRun.runId,text:e.activeRun.text}),w.workerState&&H?.setWorkerContext(Hc(w.workerState)),Re());return}if(e.type==="task_started"){Ce("task_started",{taskId:e.taskId,reason:"worker"});return}if(e.type==="run_started"){Ho="",$n(),typeof e.runId=="string"&&e.runId&&cn.delete(e.runId);let t=w?.pendingRun;Dt(Or({id:e.runId,text:e.text,startedAt:t?.startedAt||Date.now(),attempts:t?.attempts||0,autoResume:t?.autoResume!==!1})),H?.setActiveRun({runId:e.runId,text:String(e.text||"")}),ge?.setRunning(!0);let n=`run:${String(e.runId||"")}:start`;w?.timeline.some(r=>r.id===n)||Ye({id:n,kind:"plan",title:e.resume?"Run resumed":"Run started",detail:String(e.text||""),status:"pending"});return}if(e.type==="run_completed"){if(Ho="",Wn=!1,ge?.setRunning(!1),Pn&&(clearTimeout(Pn),Pn=null),w?.pendingRun?.id===e.runId&&Dt(void 0),typeof e.runId=="string"&&e.runId&&H?.releaseWorkflowLock(e.runId),w&&e?.route&&(e.route.mode==="act"||e.route.mode==="planner")&&(w.lastRoutingDecision={mode:e.route.mode,score:Number(e.route.score)||void 0,reason:typeof e.route.reason=="string"?Ke(e.route.reason,200):void 0,ts:Date.now()},Re()),H?.setActiveRun(void 0),!e.ok&&e.error)vc("worker_run_failed"),kt(`Task failed: ${String(e.error)}`),cn.delete(String(e.runId||"")),Ye({kind:"error",title:"Run failed",detail:String(e.error),status:"error"});else if(e.ok){let t=gf(e),n=t.taskComplete,r=t.needsUserInput;n?(vf("worker_task_complete"),H?.pruneTabs({dropRuntimeDetached:!0,dropAllDetachedExternal:!0}),kt("Task completed"),Cf(typeof e.runId=="string"?e.runId:void 0)):(vc(r?"worker_waiting_for_input":"worker_continuation"),kt(r?"Need more input to continue":"Execution finished. Continue when ready."),Ye({kind:"status",title:r?"Waiting for your input":"Continuation available",detail:r?"Planner requested more information before marking the task complete.":"Task is still active and will continue with your next message.",status:"info"})),typeof e.runId=="string"&&e.runId&&cn.delete(e.runId)}return}if(e.type==="ready"){wn=!0,kt("ready"),Ce("ready");let t=H?.getWorkerContext(),n=Vn(t),r=Number(w?.workerState?.updatedAt)||0,o=Number(n?.updatedAt)||0,s=n&&o>r+100?n:w?.workerState;w&&s&&s!==w.workerState&&(w.workerState=s,Re()),s?(Ie?.postMessage({type:"hydrate_state",state:s}),Ce("context_restored",{source:"runtime_start",ts:Date.now()})):es();return}if(e.type==="hydrated"){es();return}e.type==="updated"&&Ce("updated")}}function Lf(e){if(ts(e),H){let s=H.getRole();pt=s,w&&(w.executionMode=s)}Vc(e),ti(e);let t=(e.allowActions??!0)&&(H?H.isController():!0);ze=new No({allowActions:t,runtimeId:Se,allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy,registerOpenedTab:s=>H?.registerOpenedTab(s),switchToLogicalTab:s=>H?.switchToLogicalTab(s)||{ok:!1,reason:"No session coordinator"},listKnownTabs:()=>(H?.listTabs()||[]).map(s=>({logicalTabId:s.logicalTabId,runtimeId:s.runtimeId,url:s.url,title:s.title,external:!!s.external})),onNavigationGuardrail:s=>{Ce("navigation_guardrail",s),Ye({kind:"status",title:"Navigation guardrail",detail:Xo(s),status:"info"})},instrumentationOptions:e.mode==="safe"?{observeInlineMutations:!1}:void 0});let n=new MessageChannel;lc(n.port1,{getSnapshot:()=>ze.getSnapshot(),getPageData:async s=>{let i=ce||e,a=Number(s?.tabId),u=H?.getLocalLogicalTabId();if(!Number.isFinite(a)||a<=0||a===u||!H)return ze.getPageData(s);let p=H.listTabs().find(_=>_.logicalTabId===a);if(!p)return Wo(i,{logicalTabId:a,external:!0},"target_tab_missing");if(p.runtimeId===Se)return ze.getPageData(s);if(p.external&&i.externalNavigationPolicy!=="allow")return Wo(i,p,"external_domain_inaccessible");if(!p.runtimeId||!H.isTabAlive(a))return Wo(i,p,"target_tab_inactive");try{return await H.sendCrossTabRpc(p.runtimeId,"getPageData",s,15e3)}catch{return Wo(i,p,"cross_tab_rpc_failed")}},executeTool:async s=>{let i=ce||e,a=H?.getActiveLogicalTabId(),u=H?.getLocalLogicalTabId();if(!a||a===u||!H)return ze.executeTool(s.call,s.payload);let p=H.listTabs().find(_=>_.logicalTabId===a);if(!p)return Vo(i,{logicalTabId:a,external:!0},"target_tab_missing");if(p.external&&i.externalNavigationPolicy!=="allow")return Vo(i,p,"external_tab_action_blocked");if(p.runtimeId===Se)return ze.executeTool(s.call,s.payload);if(!p.runtimeId||!H.isTabAlive(a))return Vo(i,p,"target_tab_inactive");try{return await H.sendCrossTabRpc(p.runtimeId,"executeTool",s,2e4)}catch{return Vo(i,p,"cross_tab_execute_failed")}},executeClientTool:s=>ze.executeClientTool(s.name,s.args),listClientTools:()=>ze.listClientTools(),getTabContext:()=>{let s=H?.getLocalLogicalTabId(),i=H?.getActiveLogicalTabId();return{id:s||1,logicalTabId:s||1,activeLogicalTabId:i||s||1,runtimeId:Se,mode:pt,url:window.location.href,title:document.title}},listSessionTabs:()=>H?.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 a=new Blob([`import '${r}';`],{type:"application/javascript"});o=URL.createObjectURL(a)}}catch{}if(Ie=new Worker(o,{type:"module"}),Ie.postMessage({type:"init",config:e,port:n.port2},[n.port2]),ge=hc({onSend:s=>{zo(s)},onRequestControl:()=>{H?.requestControl()??!1?Ye({kind:"status",title:"Control requested",detail:"This tab is now the active Rover controller.",status:"info"}):Wt("system","Unable to acquire control right now. Try again in a moment.",!0)},onCancelRun:()=>{w?.pendingRun&&(Ie?.postMessage({type:"cancel_run",runId:w.pendingRun.id}),H?.releaseWorkflowLock(w.pendingRun.id),H?.setActiveRun(void 0),Dt(void 0),kt("Task cancelled."),Wt("system","Task cancelled.",!0))},onNewTask:()=>{Wr({reason:"manual_new_task",clearUi:!0})},onEndTask:()=>{is({reason:"manual_end_task"})},onTaskSuggestionPrimary:()=>{let s=Mr;s&&zo(s.text,{bypassSuggestion:!0,startNewTask:!0,reason:s.reason})},onTaskSuggestionSecondary:()=>{let s=Mr;s&&zo(s.text,{bypassSuggestion:!0})},showTaskControls:e.ui?.showTaskControls!==!1,muted:e.ui?.muted,agent:{name:e.ui?.agent?.name},mascot:{disabled:e.ui?.mascot?.disabled,mp4Url:e.ui?.mascot?.mp4Url,webmUrl:e.ui?.mascot?.webmUrl},onOpen:()=>{w&&(w.uiOpen=!0,w.uiHidden=!1,Re()),Ce("open")},onClose:()=>{w&&(w.uiOpen=!1,Re()),Ce("close")}}),$n(),w?.uiMessages?.length&&ni(w.uiMessages),w?.timeline?.length&&ri(w.timeline),w?.uiStatus&&ge.setStatus(w.uiStatus),w?.executionMode&&ge.setExecutionMode(w.executionMode,{localLogicalTabId:H?.getLocalLogicalTabId(),activeLogicalTabId:H?.getActiveLogicalTabId(),controllerRuntimeId:H?.getCurrentHolderRuntimeId(),canTakeControl:!0,canComposeInObserver:Dc(),note:Oc(w.executionMode)}),Ie.onmessage=s=>{Mf(s.data||{})},H){let s=()=>{H?.registerCurrentTab(window.location.href,document.title),H?.broadcastNavigation(window.location.href,document.title)},i=history.pushState.bind(history),a=history.replaceState.bind(history);history.pushState=function(...u){let v=i(...u);return setTimeout(s,0),v},history.replaceState=function(...u){let v=a(...u);return setTimeout(s,0),v},window.addEventListener("popstate",s)}w?.uiHidden?ge.hide():(ge.show(),w?.uiOpen??!!e.openOnInit?ge.open():ge.close()),w&&(w.uiHidden=!!w.uiHidden,w.uiOpen=!!w.uiOpen,Re()),H&&(oi(H.getState(),"remote"),Ur(H.getRole(),{localLogicalTabId:H.getLocalLogicalTabId(),activeLogicalTabId:H.getActiveLogicalTabId(),holderRuntimeId:H.getCurrentHolderRuntimeId()}))}function Fr(e){if(gn)return ns(e),gn;Bn=wc(),Se=Zd(e.siteId),lt=Cc(e),ur=rf(e.siteId);let t=Ef(ur),n=e.sessionId?.trim(),r=!n&&!t?.sessionId&&e.sessionScope!=="tab"&&lt?nf(e.siteId,lt):void 0,o=n||t?.sessionId||r||crypto.randomUUID();w=Dr(t,o,Se),n&&w.sessionId!==n&&(w=Lc(n,Se)),ce={...e,visitorId:lt||e.visitorId,sessionId:n||w.sessionId,taskRouting:{mode:e.taskRouting?.mode||"act",actHeuristicThreshold:e.taskRouting?.actHeuristicThreshold,plannerOnActError:e.taskRouting?.plannerOnActError},taskContext:{...e.taskContext}},w.sessionId=ce.sessionId,w.runtimeId=Se,w.executionMode=w.executionMode||"controller",w.timeline=Nr(w.timeline),w.uiMessages=Lr(w.uiMessages),w.activeTask=Hr(w.activeTask,En("boot")),w.taskEpoch=Math.max(1,Number(w.taskEpoch)||1),pt=w.executionMode,Re();try{sessionStorage.setItem(`rover:tab-alive:${e.siteId}`,"1")}catch{}if(wn=!1,Wn=!1,Lf(ce),ur&&kf(ur),_f(),gn={boot:Fr,init:si,update:ns,shutdown:ii,open:Br,close:ss,show:ai,hide:ci,send:li,newTask:Wr,endTask:is,getState:ui,registerTool:di,on:Sc},qo.length){for(let s of qo)Mc(s);qo.length=0}return gn}function si(e){return Fr(e)}function ns(e){!gn||!Ie||!ce||(ce={...ce,...e,taskRouting:{...ce.taskRouting,...e.taskRouting},taskContext:{...ce.taskContext,...e.taskContext},ui:{...ce.ui,...e.ui,agent:{...ce.ui?.agent,...e.ui?.agent},panel:{...ce.ui?.panel,...e.ui?.panel}},tools:{...ce.tools,...e.tools,client:e.tools?.client??ce.tools?.client,web:{...ce.tools?.web,...e.tools?.web}}},lt=Cc(ce),lt&&(ce.visitorId=lt),e.sessionId&&w?(w.sessionId=e.sessionId,Re(),ts(ce)):(e.sessionScope||e.tabPolicy)&&ts(ce),Vc(ce),ti(ce),ze&&(typeof e.allowActions=="boolean"&&ze.setAllowActions(e.allowActions&&pt==="controller"),(e.allowedDomains||e.domainScopeMode||e.externalNavigationPolicy)&&ze.setNavigationPolicy({allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy})),Ie.postMessage({type:"update_config",config:e}),typeof e.openOnInit=="boolean"&&(e.openOnInit?Br():ss()))}function ii(){$n(),Re(),os(!0),ei(),wt?.markDirty(),wt?.syncNow(),wt?.stop(),wt=null,H?.stop(),H=null,Ie?.terminate(),Ie=null,ge?.destroy(),ge=null,ze=null,ce=null,wn=!1,Wn=!1,Se="",lt=void 0,Qo=!1,Go=!1,dr=!1,Et=[],kc=0,pt="controller",Mr=null,Bn=null,gn=null}function Br(){ge?.show(),ge?.open(),w&&(w.uiHidden=!1,w.uiOpen=!0,Re())}function ss(){ge?.close(),w&&(w.uiOpen=!1,Re())}function ai(){ge?.show(),w&&(w.uiHidden=!1,Re())}function ci(){ge?.hide(),w&&(w.uiHidden=!0,w.uiOpen=!1,Re())}function li(e){e?.trim()&&zo(e)}function Wr(e){if(!w)return;let t=e?.reason||"manual_new_task",n=e?.clearUi!==!1,r=Math.max(1,Number(w.taskEpoch)||1)+1,o=En(t);w.pendingRun&&(Ie?.postMessage({type:"cancel_run",runId:w.pendingRun.id}),H?.releaseWorkflowLock(w.pendingRun.id)),Wn=!1,w.taskEpoch=r,w.activeTask=o,w.pendingRun=void 0,w.workerState=void 0,n&&(w.uiMessages=[],w.timeline=[],w.uiStatus=void 0,Pc()),H?.startNewTask({taskId:o.taskId,startedAt:o.startedAt,boundaryReason:t,status:"running",lastUserAt:void 0,lastAssistantAt:void 0}),H?.setActiveRun(void 0),H?.setWorkerContext(void 0),kt("New task started."),Re(),Ie?.postMessage({type:"start_new_task",taskId:o.taskId}),Ye({kind:"info",title:"Started new task",detail:t,status:"info"}),Ce("task_started",{taskId:o.taskId,reason:t,taskEpoch:r})}function is(e){if(!w)return;let t=e?.reason||"manual_end_task",n=Pr("manual_end_task");n&&(n.status="ended",n.endedAt=Date.now(),n.boundaryReason=t,w.pendingRun&&(Ie?.postMessage({type:"cancel_run",runId:w.pendingRun.id}),H?.releaseWorkflowLock(w.pendingRun.id)),w.pendingRun=void 0,$n(),kt("Task ended. Start a new task to continue."),H?.endTask(t),H?.setActiveRun(void 0),Re(),Ye({kind:"info",title:"Task ended",detail:"Start a new task when you are ready.",status:"info"}),Ce("task_ended",{taskId:n.taskId,reason:t,endedAt:n.endedAt}))}function ui(){return{mode:pt,runtimeId:Se,runtimeState:w?Wc(w):null,sharedState:H?.getState()||null,pendingTaskSuggestion:Mr}}function di(e,t){let n=Jd(e);if(!gn||!ze||!Ie){qo.push({def:n,handler:t});return}Mc({def:n,handler:t})}function Nf(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 $c(){let e=window,t=e.rover,n=((r,...o)=>{let s=Nf(r),i=s?n[s]:void 0;if(typeof i=="function")return i(...o)});if(n.boot=Fr,n.init=si,n.update=ns,n.shutdown=ii,n.open=Br,n.close=ss,n.show=ai,n.hide=ci,n.send=li,n.newTask=Wr,n.endTask=is,n.getState=ui,n.registerTool=di,n.on=Sc,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(!gn){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},a=r.getAttribute("data-allowed-domains");a&&(i.allowedDomains=a.split(",").map(p=>p.trim()).filter(Boolean));let u=r.getAttribute("data-site-key-id");u&&(i.siteKeyId=u);let v=r.getAttribute("data-worker-url");v&&(i.workerUrl=v),Fr(i)}}}}$c();return jc(Df);})();