@rtrvr-ai/rover 1.3.0 → 1.3.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 +37 -18
- package/dist/rover.js +905 -151
- package/dist/worker/rover-worker.js +586 -141
- package/package.json +1 -1
package/dist/embed.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
var __ROVER_SCRIPT_EL__=document.currentScript||null;var __ROVER_SCRIPT_URL__=(__ROVER_SCRIPT_EL__&&__ROVER_SCRIPT_EL__.src)||'';
|
|
2
|
-
"use strict";var __roverSDK=(()=>{var To=Object.defineProperty;var uu=Object.getOwnPropertyDescriptor;var du=Object.getOwnPropertyNames;var fu=Object.prototype.hasOwnProperty;var pu=(e,t,n)=>t in e?To(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var hu=(e,t)=>{for(var n in t)To(e,n,{get:t[n],enumerable:!0})},mu=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of du(t))!fu.call(e,o)&&o!==n&&To(e,o,{get:()=>t[o],enumerable:!(r=uu(t,o))||r.enumerable});return e};var gu=e=>mu(To({},"__esModule",{value:!0}),e);var W=(e,t,n)=>pu(e,typeof t!="symbol"?t+"":t,n);var kh={};hu(kh,{boot:()=>bo,close:()=>zi,endTask:()=>Yi,getState:()=>pa,hide:()=>da,identify:()=>aa,init:()=>ca,installGlobal:()=>lu,newTask:()=>$r,open:()=>vo,registerTool:()=>ha,send:()=>fa,show:()=>ua,shutdown:()=>la,update:()=>Bi});var M;(function(e){e.click_element="click_element",e.type_into_element="type_into_element",e.type_and_enter="type_and_enter",e.select_dropdown_value="select_dropdown_value",e.clear_element="clear_element",e.focus_element="focus_element",e.check_field_validity="check_field_validity",e.select_text="select_text",e.hover_element="hover_element",e.right_click_element="right_click_element",e.double_click_element="double_click_element",e.press_key="press_key",e.mouse_wheel="mouse_wheel",e.dispatch_pointer_path="dispatch_pointer_path",e.drag_element="drag_element",e.drag_and_drop="drag_and_drop",e.adjust_slider="adjust_slider",e.scroll_page="scroll_page",e.scroll_to_element="scroll_to_element",e.swipe_element="swipe_element",e.long_press_element="long_press_element",e.pinch_zoom="pinch_zoom",e.go_back="go_back",e.go_forward="go_forward",e.goto_url="goto_url",e.refresh_page="refresh_page",e.open_new_tab="open_new_tab",e.switch_tab="switch_tab",e.close_tab="close_tab",e.describe_images="describe_images",e.google_search="google_search",e.network_run_recipe="network_run_recipe",e.copy_text="copy_text",e.paste_text="paste_text",e.wait_action="wait_action",e.wait_for_element="wait_for_element",e.answer_task="answer_task",e.upload_file="upload_file",e.solve_captcha="solve_captcha"})(M||(M={}));var Ih=new Set(Object.values(M)),_o=["element_id","source_element_id","target_element_id","center_element_id","element_ids"],bu=40;function ga(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,bu)}var Wt;(function(e){e[e.Unknown=0]="Unknown",e[e.React=1]="React",e[e.Vue=2]="Vue",e[e.Angular=3]="Angular",e[e.Svelte=4]="Svelte",e[e.JQuery=5]="JQuery"})(Wt||(Wt={}));var ba={[Wt.Unknown]:"unknown",[Wt.React]:"react",[Wt.Vue]:"vue",[Wt.Angular]:"angular",[Wt.Svelte]:"svelte",[Wt.JQuery]:"jquery"},ji={react:Wt.React,vue:Wt.Vue,angular:Wt.Angular,svelte:Wt.Svelte,jquery:Wt.JQuery},et;(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"})(et||(et={}));var Nh={[et.Other]:"other",[et.Inline]:"inline",[et.Delegated]:"delegated",[et.React]:"react",[et.Vue]:"vue",[et.Angular]:"angular",[et.Svelte]:"svelte",[et.JQuery]:"jquery",[et.Native]:"native"},Lh={inline:et.Inline,delegated:et.Delegated,react:et.React,vue:et.Vue,angular:et.Angular,svelte:et.Svelte,jquery:et.JQuery,other:et.Other,native:et.Native},be;(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"})(be||(be={}));var xo={[M.click_element]:be.click_element,[M.type_into_element]:be.type_into_element,[M.type_and_enter]:be.type_and_enter,[M.select_dropdown_value]:be.select_dropdown_value,[M.clear_element]:be.clear_element,[M.focus_element]:be.focus_element,[M.hover_element]:be.hover_element,[M.right_click_element]:be.right_click_element,[M.double_click_element]:be.double_click_element,[M.long_press_element]:be.long_press_element,[M.drag_element]:be.drag_element,[M.drag_and_drop]:be.drag_and_drop,[M.swipe_element]:be.swipe_element,[M.adjust_slider]:be.adjust_slider,[M.describe_images]:be.describe_images,[M.scroll_to_element]:be.scroll_to_element,[M.paste_text]:be.paste_text,[M.check_field_validity]:be.check_field_validity,[M.select_text]:be.select_text,[M.mouse_wheel]:be.mouse_wheel,[M.copy_text]:be.copy_text,[M.upload_file]:be.upload_file,[M.go_back]:be.go_back,[M.go_forward]:be.go_forward,[M.refresh_page]:be.refresh_page,[M.press_key]:be.press_key,[M.scroll_page]:be.scroll_page,[M.wait_action]:be.wait_action,[M.wait_for_element]:be.wait_for_element,[M.pinch_zoom]:be.pinch_zoom,[M.goto_url]:be.goto_url,[M.google_search]:be.google_search,[M.open_new_tab]:be.open_new_tab,[M.switch_tab]:be.switch_tab,[M.close_tab]:be.close_tab,[M.solve_captcha]:be.solve_captcha,[M.answer_task]:be.answer_task,[M.dispatch_pointer_path]:be.dispatch_pointer_path,[M.network_run_recipe]:be.network_run_recipe},Ea=Object.fromEntries(Object.entries(xo).map(([e,t])=>[t,e]));function Ro(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 wa={semanticIdStart:1,interactiveIdStart:1,includeFrameContents:!0,clearIframes:!0,frameContextLabel:null,signalProvider:null,disableDomAnnotations:!1},It={...wa},So=globalThis;function va(e){It={...wa,...e||{}}}function rr(){return It.signalProvider??null}function st(){try{return typeof So.document<"u"?So.document:null}catch{return null}}function yn(){try{return typeof So.window<"u"?So.window:null}catch{return null}}function z(e,t){if(e&&typeof e=="object"){let n=e.ownerDocument;if(n)return n;if(e.nodeType===9)return e}return t??st()??{}}function de(e,t){return z(e,t?t.document:null)?.defaultView??t??yn()??{}}function j(e,t){return e?.defaultView??t??yn()??{}}function Io(e,t){try{return e?.getElementById?.(t)??null}catch{return null}}function Ao(e,t){try{return e?.querySelector?.(t)??null}catch{return null}}function Xi(e,t){try{return Array.from(e?.querySelectorAll?.(t)??[])}catch{return[]}}function Vr(e){try{return e.contentDocument||(e.contentWindow?.document??null)}catch{return null}}function Co(e,t){let n=e.CSS?.escape;return typeof n=="function"?n(t):t.replace(/([^\w-])/g,"\\$1")}function Vt(e,t){try{return e[t]}catch{return}}function wn(e,t){return!!e&&String(e.tagName||"").toUpperCase()===t.toUpperCase()}function Ta(e,t){let n=Vt(t,"HTMLAnchorElement");return n?e instanceof n:wn(e,"A")}function Zt(e,t){let n=Vt(t,"HTMLInputElement");return n?e instanceof n:wn(e,"INPUT")}function ln(e,t){let n=Vt(t,"HTMLTextAreaElement");return n?e instanceof n:wn(e,"TEXTAREA")}function _a(e,t){let n=Vt(t,"HTMLLabelElement");return n?e instanceof n:wn(e,"LABEL")}function xa(e,t){let n=Vt(t,"HTMLSelectElement");return n?e instanceof n:wn(e,"SELECT")}function Ra(e,t){let n=Vt(t,"HTMLSlotElement");return n?e instanceof n:wn(e,"SLOT")}function ka(e,t){let n=Vt(t,"HTMLButtonElement");return n?e instanceof n:wn(e,"BUTTON")}function Sa(e,t){let n=Vt(t,"HTMLImageElement");return n?e instanceof n:wn(e,"IMG")}function Ia(e,t){let n=Vt(t,"HTMLVideoElement");return n?e instanceof n:wn(e,"VIDEO")}function Aa(e,t){let n=Vt(t,"HTMLCanvasElement");return n?e instanceof n:wn(e,"CANVAS")}function tt(e,t){if(!e||e.nodeType!==1)return!1;let n=Vt(t,"HTMLElement");return n?e instanceof n:typeof e.tagName=="string"}function Gt(e){return!!e&&e.nodeType===11&&typeof e.host=="object"&&typeof e.mode=="string"}function or(e){if(!e||e.nodeType!==1)return!1;let t=z(e),r=j(t).Element;return r?e instanceof r:typeof e.tagName=="string"}function Gr(e){if(!e||e.nodeType!==1)return!1;let t=z(e),r=j(t).HTMLIFrameElement;return r&&e instanceof r?!0:String(e.tagName||"").toUpperCase()==="IFRAME"}function Eu(e,t){if(!e)return!1;if(e.nodeType===9)return!0;let n=Vt(t,"Document");return n?e instanceof n:!1}function yu(e,t){if(!e)return!1;let n=Vt(t,"Window");if(n)return e instanceof n;try{return e.window===e}catch{return!1}}function No(e){try{return e.document}catch{return null}}function Lo(e,t){if(Eu(e,t))try{return e.documentElement}catch{return null}if(yu(e,t)){let n=No(e);if(!n)return null;try{return n.documentElement}catch{return null}}return null}function ko(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 ya(e,t,n){try{let r=z(t,n);return new URL(e,r.baseURI).href}catch{return e}}function Mo(e,t){let n=e.tagName.includes("-"),r=e.getAttribute("href")||e.getAttribute("src")||e.getAttribute("data")||e.getAttribute("action");if(r){let o=ya(r,e,t);return o.trim().toLowerCase().startsWith("javascript:")?null:o}if(n)return null;try{let o=e,i=ko(o.href)||ko(o.src)||ko(o.data)||ko(o.action);return i?ya(i,e,t):null}catch{return null}}var Ca=["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"],Ie={};Ca.forEach((e,t)=>{Ie[e]=t});var Nn={};Ca.forEach((e,t)=>{Nn[t]=e});function ir(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,i]=r.split("~"),s=Number(o);if(!Number.isFinite(s))continue;let a=i&&parseInt(i,36)||0;n.push({id:s,mask:a})}return n.length?{entries:n}:null}function wu(e){let t=ir(e);if(t){let n=new Set;for(let{id:r}of t.entries)n.add(r);return[...n]}return[]}function zr(e){return xr(e).map(n=>Nn[n]).filter(n=>!!n)}function xr(e){let t=rr();if(t?.getEventHandlerIds)try{let o=t.getEventHandlerIds(e);if(o&&o.length)return o}catch{}let n=e.getAttribute(zn),r=wu(n);return!r||r.length===0?[]:r}var Ki=["media"],Na=new Set(Ki),Qi=["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 La=new Set(Qi),Ln=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"]),Yr=new Set(["group","region","section","banner","contentinfo","main","navigation","complementary","form","article","document","presentation","none"]);var Ma=["none","presentation"],xe;(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"})(xe||(xe={}));var Da={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"]},jr={heading:{selector:"h6,h1,h3,h2,h5,h4"},checkbox:{conditionalSelectors:[{selector:"input",conditions:[{type:xe.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:xe.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"grid"}]},{selector:"td",conditions:[{type:xe.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"treegrid"}]},{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:xe.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"treegrid"},{type:xe.HAS_TABLE_COLUMN_DATA,hasData:!0},{type:xe.HAS_TABLE_ROW_DATA,hasData:!0}]}]},slider:{conditionalSelectors:[{selector:"input",conditions:[{type:xe.PROPERTY_VALUE_MATCH,property:"type",values:["range"]}]}]},listitem:{selector:"li"},contentinfo:{conditionalSelectors:[{selector:"footer",conditions:[{type:xe.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:xe.PROPERTY_VALUE_MATCH,property:"type",values:["submit","reset","image","button"]}]}]},status:{selector:"output"},form:{conditionalSelectors:[{selector:"form",conditions:[{type:xe.HAS_ACCESSIBLE_NAME}]}]},article:{selector:"article"},textbox:{selector:"textarea",conditionalSelectors:[{selector:"input:not([list])",conditions:[{type:xe.PROPERTY_VALUE_MATCH,property:"type",values:["url","text","tel","email"]}]}]},radio:{conditionalSelectors:[{selector:"input",conditions:[{type:xe.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:xe.HAS_TABLE_ROW_DATA,hasData:!1}]}]},list:{selector:"ul,ol,menu"},region:{conditionalSelectors:[{selector:"section",conditions:[{type:xe.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:xe.PROPERTY_VALUE_MATCH,property:"type",values:["search"]}]}]},cell:{conditionalSelectors:[{selector:"td",conditions:[{type:xe.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"table"}]},{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:xe.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"table"},{type:xe.HAS_TABLE_COLUMN_DATA,hasData:!0},{type:xe.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:xe.HAS_TABLE_COLUMN_DATA,hasData:!1},{type:xe.HAS_TABLE_ROW_DATA,hasData:!0}]}]},dialog:{selector:"dialog"},listbox:{selector:"select[multiple],datalist",conditionalSelectors:[{selector:"select",conditions:[{type:xe.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:xe.PROPERTY_VALUE_MATCH,property:"type",values:["number"]}]}]},math:{selector:"math"},combobox:{selector:"select:not([size]):not([multiple])",conditionalSelectors:[{selector:"select:not([multiple])",conditions:[{type:xe.ATTRIBUTE_LESS_THAN,attribute:"size",value:2}]},{selector:"input[list]",conditions:[{type:xe.PROPERTY_VALUE_MATCH,property:"type",values:["url","text","tel","search","email"]}]}]},banner:{conditionalSelectors:[{selector:"header",conditions:[{type:xe.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"}},zn="rtrvr-ls",Mn="rtrvr-ro",Ji="rtrvr-mw-ready",Xr="rtrvr-mw-busy",Zi="rtrvr-mwa-ready",Oa=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"]),Pa=["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"],Ha=["h1","h2","h3","h4","h5","h6"],Ua="http://www.w3.org/1999/xhtml",Fa="http://www.w3.org/2000/svg",_t="rtrvr-label";var Po=new Set(["NOSCRIPT","SCRIPT","STYLE","META"]),sr="CODE",ar="PRE",Ba="aria-hidden",qa="target";var Do;(function(e){e[e.value=0]="value",e[e.alt=1]="alt",e[e.list=2]="list",e[e.title=3]="title"})(Do||(Do={}));var Rr;(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"})(Rr||(Rr={}));var Oo;(function(e){e[e.VALUENOW=0]="VALUENOW",e[e.VALUETEXT=1]="VALUETEXT"})(Oo||(Oo={}));var es=new Set([Ie.click,Ie.dblclick,Ie.doubleclick,Ie.contextmenu,Ie.auxclick,Ie.pointerdown,Ie.pointerup,Ie.mousedown,Ie.mouseup,Ie.touchstart,Ie.touchend,Ie.keydown,Ie.keyup,Ie.input,Ie.beforeinput,Ie.change,Ie.submit,Ie.reset,Ie.paste,Ie.dragstart,Ie.dragend,Ie.drop]),$a=new Set([...es,Ie.scroll,Ie.wheel,Ie.mouseenter,Ie.mouseover,Ie.focus,Ie.blur,Ie.focusin,Ie.focusout]),Ho=new Set(["click","dblclick","auxclick","contextmenu","mousedown","mouseup","pointerdown","pointerup","touchstart","touchend"]),ts=new Set(["input","change","beforeinput","keydown","keyup","keypress","paste","compositionstart","compositionend"]),ns=new Set(["drag","dragstart","dragend","dragenter","dragleave","dragover","drop"]);var Yn;(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"})(Yn||(Yn={}));var Kr;(function(e){e[e.HTML=0]="HTML",e[e.SVG=1]="SVG"})(Kr||(Kr={}));var Uo;(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"})(Uo||(Uo={}));var Fo;(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"})(Fo||(Fo={}));var Nt;(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"})(Nt||(Nt={}));var bt;(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"})(bt||(bt={}));var Dn;(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"})(Dn||(Dn={}));var vu=[...Qi,...Object.keys(jr),...Ki],Wa=[...new Set(vu)],kr={};Wa.forEach((e,t)=>{kr[e]=t});var Qr={};Wa.forEach((e,t)=>{Qr[t]=e});var Bo=class{constructor(t=1){W(this,"currentId");this.currentId=t}generateId(){let t=this.currentId;return this.currentId++,t}initialize(t=1){this.currentId=t}getCurrentValue(){return this.currentId}};function Jr(e){let t=rr();if(t?.getRoleHint)try{let o=t.getRoleHint(e);if(o)return o}catch{}let n=e.getAttribute(Mn);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 i=Qr[o];if(i)return i}}return r}function Sr(e){return Array.from(new Set(e))}function Va(e,t){if(!e||e.length===0)return Sr(t);let n=new Set([...e,...t]);return Sr(Array.from(n))}function zt(e,t){let r=rr()?.getEventHandlerIds?.(e)??xr(e),o=r.length>0&&r.some(a=>es.has(a)),i=qo(e),s=t?Yr.has(t):!1;return{element:e,semanticRole:t,eventHandlerIndices:r,isEditableRegion:i,hasNodeWorthyHandlers:o,isLikelyStructuralContainer:s}}var Tu=new Set(["text","search","url","tel","password","email","number","date","datetime-local","time","month","week","color"]);function _u(e){let n=de(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 xu(e){let t=de(e);if(!Zt(e,t))return!1;let n=(e.type||"text").toLowerCase();return Tu.has(n)?!e.disabled&&!e.readOnly:!1}function Ru(e){let t=de(e);return ln(e,t)&&!e.disabled&&!e.readOnly}function ku(e){let t=e;return!(!t.isContentEditable||t.getAttribute("aria-readonly")==="true"||t.getAttribute("aria-disabled")==="true")}function qo(e){return!e||!_u(e)?!1:!!(xu(e)||Ru(e)||ku(e))}function Zr(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,i=e.slice(Math.max(0,o-30),o);if(/iframeRoot\s*=\s*$/.test(i)||i.includes("iframeRoot="))continue;let s=parseInt(r[1],10);if(Number.isFinite(s))return s}try{let o=e.match(LABEL_ID_PATTERN);if(o?.[1]){let i=parseInt(o[1],10);return Number.isFinite(i)?i:null}}catch{}return null}function eo(e){let t=String(e??"").replace(/[\n\r\t]/g," ").replace(/\s+/g," ").trim();return t=t.replace(/\[/g,"[").replace(/\]/g,"]"),t}function Ga({element:e,elementID:t,frameContextLabel:n}){let r=!It.disableDomAnnotations,o=[`[id=${t}]`],i=de(e);if(Gr(e)){let u=eo(e.id||e.getAttribute("name")||"unnamed");o.push(`[iframe=${u}]`)}if(n){let u=eo(n);o.push(`[iframeRoot=${u}]`)}if(Sa(e,i)&&o.push(`[size=${e.clientWidth}x${e.clientHeight}]`),(Ia(e,i)||Aa(e,i))&&o.push(`[size=${e.clientWidth}x${e.clientHeight}]`),Zt(e,i)||ln(e,i)){let u=Su(e);o.push(...u)}e.getAttribute(Ba)==="true"&&o.push("[aria-hidden=true]"),e.disabled&&o.push("[disabled]"),r&&Ta(e,i)&&e.setAttribute(qa,"_self");let a=o.join(" ");return r&&e.setAttribute(_t,a),a}function Su(e){let t=[],n=de(e),r=Zt(e,n);if(r&&e.type&&e.type!=="text"&&t.push(`[type=${e.type}]`),e.name){let o=eo(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=eo(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 i=eo(o).replace(/\\/g,"\\\\").replace(/"/g,'\\"');t.push(`[value="${i}"]`)}return t}var cr=new Bo,rs=new WeakMap;function za(){rs=new WeakMap}function $o(e){let t=rs.get(e);if(t)return t;let n=cr.generateId();return rs.set(e,n),n}var Wo=new Map,os=new WeakMap;function Ya(){Wo.clear(),os=new WeakMap}function is(e,t){try{typeof WeakRef<"u"?Wo.set(e,new WeakRef(t)):Wo.set(e,t)}catch{}}function to(e){let t=Wo.get(e);if(!t)return null;let n=t instanceof WeakRef?t.deref():t;return!n||n.isConnected===!1?null:n}function jn(e){let t=null,n=$o(e);if(It.frameContextLabel)t=It.frameContextLabel;else{let o=st();if(o&&e.ownerDocument!==o)try{let s=e.ownerDocument?.defaultView?.frameElement?.getAttribute(_t)||"",a=s?Zr(s):null;t=a?String(a):null}catch{t=""}}let r=Ga({element:e,elementID:n,frameContextLabel:t});if(is(n,e),r)try{os.set(e,r)}catch{}return r}function ja(e){return os.get(e)??null}function ss(e,t){try{e.querySelectorAll?.(`[${_t}]`)?.forEach(r=>r.removeAttribute(_t))}catch{}if(t.includeShadow)try{let n=e.querySelectorAll?.("*");if(n)for(let r of Array.from(n))try{let o=r.shadowRoot;o&&ss(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=Vr(r);o?.body&&ss(o.body,t)}catch{}}catch{}}function Xa(e,t={}){if(It.disableDomAnnotations)return;let n=or(e)?de(e):j(e)??window,r=Lo(e,n)??e;if(r){try{r.removeAttribute?.(_t)}catch{}ss(r,{includeShadow:t.includeShadow??!0,includeIframes:t.includeIframes??!0})}}var vn={},as=new WeakMap,Vo=new WeakSet;function Ka(){vn={},as=new WeakMap,Vo=new WeakSet,za()}function xt({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:i,originatedFromParent:s,elementContext:a}){let u=$o(e);is(u,e);let m=vn[u];if(s){if(!m){let p={nodeCategory:e.nodeType,provisionalFromParent:!0},v=e.nodeName;v&&v.trim()&&(p.elementName=v);let I=e.getAttribute("role");I&&(p.preservedAttributes={1:I});let A=e.tagName;A&&(p.elementTag=A),vn[u]=p}}else{if(m&&!m.provisionalFromParent){if((o||Ir(e))&&(m.isFrameElement=!0,i&&i.length>0&&(m.frameContent=i)),a){let{eventHandlerIndices:p,isEditableRegion:v}=a;if(p&&p.length>0){let I=Sr(p);I.length>0&&(m.eventHandlers=Va(m.eventHandlers,I))}v&&(m.isEditable=!0)}return u}if(Vo.has(e))return u;Vo.add(e);try{vn[u]=Qa({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:i,elementContext:a})}finally{Vo.delete(e)}}return u}function no(e){let t=as.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 i=cr.generateId(),s={textContent:r,nodeCategory:e.nodeType};return o&&o!==r&&(s.rawData=o),vn[i]=s,as.set(e,i),i}function Za(e,t){let n=tc(e),{minY:r,maxY:o}=n.getCellBounds(t);return n.getRows().slice(r,o+1).some(i=>i.some(ro))}function ec(e,t){let n=tc(e),{minX:r,maxX:o}=n.getCellBounds(t);return n.getRows().some(i=>i.slice(r,o+1).some(ro))}var zo=class{constructor(t=[]){W(this,"cells");W(this,"getCellAt",(t,n)=>this.getRowAt(n)[t]);W(this,"setCellAt",(t,n,r)=>{this.getRowAt(n)[t]=r});W(this,"getRowAt",t=>(this.cells[t]===void 0&&(this.cells[t]=[]),this.cells[t]));W(this,"getRows",()=>this.cells);W(this,"getCellBounds",t=>{let n=this.columnCount,r=this.rowCount,o=-1,i=-1;for(let s=0;s<this.rowCount;s++){let a=this.getRowAt(s),u=a.indexOf(t);u!==-1&&(o=Math.max(o,a.lastIndexOf(t)),i=Math.max(i,s),n=Math.min(n,u),r=Math.min(r,s))}return{minX:n,minY:r,maxX:o,maxY:i}});W(this,"merge",t=>{this.cells=this.getRows().concat(t.getRows())});this.cells=t}get rowCount(){return this.cells.length}get columnCount(){return Math.max(...this.cells.map(t=>t.length))}};function tc(e){let n=de(e).TableGrid||zo,r=new n;e.tHead!==null&&r.merge(Go(e.tHead.rows)),Array.from(e.tBodies).forEach(i=>{r.merge(Go(i.rows))});let o=[];for(let i of Array.from(e.children))cs(i)&&lr(i,"tr")&&o.push(i);return r.merge(Go(o)),e.tFoot!==null&&r.merge(Go(e.tFoot.rows)),r}function Go(e){let t=new zo,n=[];for(let r=0;r<e.length;r++){let o=0;for(let i of Array.from(e[r].cells)){for(;t.getCellAt(o,r)||n[o];)!ro(t.getCellAt(o,r))&&n[o]&&t.setCellAt(o,r,n[o]),o++;for(let s=o;s<o+i.colSpan;s++){Ja(i)===0&&(n[s]=i,t.setCellAt(s,r,i));for(let a=r;a<r+Ja(i);a++)ro(t.getCellAt(s,a))||t.setCellAt(s,a,i)}o+=i.colSpan}for(let i=o;i<t.columnCount;i++){let s=n[i];s!==void 0&&!ro(t.getCellAt(i,r))&&t.setCellAt(i,r,s)}}return t}function Ja(e){let t=e.getAttribute("rowSpan");if(t===null||t.trim()==="")return 1;let n=Number(t);return isNaN(n)?1:n}function ro(e){return e!==void 0&&lr(e,"td")}function un(e){let t=e.tagName?.toLowerCase();if(t==="code"||t==="pre"){let r=Pu(e);if(r)return r}let n=nc(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"),i=e.querySelector("desc"),s=e.hasAttribute("aria-label"),a=e.hasAttribute("role");return o||i||s||a||xr(e).length>0||e.getAttribute("tabindex")!==null?"img":null}if(xr(e).length>0){let o=e.tagName.toLowerCase();if(["div","span","li","p","i","em","strong","b"].includes(o))return Iu(e)}}if(t==="td"&&e.getAttribute("role")===null)return"cell";if(n!==null&&t==="th"){let r=e.getAttribute("role");if(r&&rc(r))return r;let o=e;return o.scope==="col"||o.hasAttribute("aria-sort")?"columnheader":o.scope==="row"?"rowheader":"cell"}return n}function Iu(e){return Jr(e)??null}function nc(e){let t=e.getAttribute("role");if(t!==null)return Ma.includes(t)||!rc(t)?null:t;let n=e.tagName.toLowerCase();return(Da[n]??[]).find(o=>Au(e,o))||null}function Au(e,t){let n=jr[t],r=n?.selector;if(r&&Yo(e,r))return!0;let o=n?.conditionalSelectors;return o?o.some(s=>Yo(e,s.selector)&&s.conditions.every(u=>Nu(e,u))):!1}function Cu(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let r=e.getRootNode?.();if(Gt(r)){let o=de(e),i=`#${Co(o,n)}`,s=Ao(r,i);if(s)return s}}catch{}return Io(z(e),n)}function Nu(e,t){switch(t.type){case xe.ATTRIBUTE_GREATER_THAN:{let n=e.getAttribute(t.attribute);return n!==null&&Number(n)>t.value}case xe.ATTRIBUTE_LESS_THAN:{let n=e.getAttribute(t.attribute);return n!==null&&Number(n)<t.value}case xe.HAS_ACCESSIBLE_NAME:return e.hasAttribute("aria-label")?!0:(e.getAttribute("aria-labelledby")||"").split(/\s+/).filter(Boolean).some(r=>Cu(e,r)!=null);case xe.FORBIDDEN_ANCESTORS:return On(e,t.selector)===null;case xe.BOOLEAN_PROPERTY:return e[t.property]===t.value;case xe.PROPERTY_VALUE_MATCH:return t.values.some(n=>n===e[t.property]);case xe.ANCESTOR_ROLE_REQUIRED:{let n=e.parentElement;if(n===null)return!1;let r=On(n,t.tag);return r!==null&&nc(r)===t.role}case xe.HAS_TABLE_COLUMN_DATA:{let n=On(e,"table");return n===null?!1:t.hasData===ec(n,e)}case xe.HAS_TABLE_ROW_DATA:{let n=On(e,"table");return n===null?!1:t.hasData===Za(n,e)}default:return Lu(t),!1}}function Lu(e){throw new Error(`unexpected value ${e}!`)}function rc(e){return Du(e)||Ou(e)||Mu(e)}function Mu(e){return Na.has(e)}function Du(e){return La.has(e)}function Ou(e){return jr.hasOwnProperty(e)}function Pu(e){if(e.tagName!==sr&&e.tagName!==ar)return null;if(zr(e).some(r=>r==="click"||r==="copy"))return"button";let n=e.getAttribute("tabindex");return n!==null&&parseInt(n,10)>=0?"button":e.tagName===ar||e.tagName===sr&&e.closest("pre")?"code":null}var Hu={[bt.display]:[bt.beforeDisplay,bt.afterDisplay],[bt.content]:[bt.beforeContent,bt.afterContent]},ls=new Map,Uu={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 Fu(e,t){if(!ls.has(e)){let n=Uu[t]||t.replace(/([A-Z])/g,"-$1").toLowerCase();ls.set(e,n)}return ls.get(e)}var Bu={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 sc(e,t,n){let r=Bu[e];return r?r(t,n):t.trim()!==""&&!["initial","inherit","unset"].includes(t)}function ac(e){let t={},n=de(e);if(!tt(e,n))return t;let r=n.getComputedStyle(e),o=new Map([[bt.beforeDisplay,n.getComputedStyle(e,"::before")],[bt.afterDisplay,n.getComputedStyle(e,"::after")],[bt.beforeContent,n.getComputedStyle(e,"::before")],[bt.afterContent,n.getComputedStyle(e,"::after")]]);for(let i in bt)if(isNaN(Number(i))){let s=bt[i],a=Fu(s,i),u=Hu[s];u?((s===bt.display||s===bt.content)&&oc(r,a,s,i,t,e),ic(o.get(u[0]),a,u[0],"beforeContent",t),ic(o.get(u[1]),a,u[1],"afterContent",t)):oc(r,a,s,i,t,e)}return t}function oc(e,t,n,r,o,i){if(e){let s=e.getPropertyValue(t);s&&sc(r,s,i)&&(o[n]=s)}}function ic(e,t,n,r,o){if(e){let i=e.getPropertyValue(t);(t==="content"&&i&&i!=="none"&&i!=='""'&&i!=="''"||i&&sc(r,i))&&(o[n]=i)}}function ur(e,t){let n=de(e);if(!tt(e,n))return!0;if(t&&Ln.has(t))return!1;if(e.hasAttribute("hidden")||On(e,"[hidden]")!==null||On(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(),i=1e6;return Math.abs(o.left)>i||Math.abs(o.top)>i}function oo(e){return dn(e)&&e.classList.contains("jasmine_html-reporter")}function qu(e){let t=e.getAttribute("role");return t==="presentation"||t==="none"}function cc(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).map(t=>t.replace(/^#/,"")):[]}function lc(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let o=e.getRootNode?.();if(Gt(o)){let i=de(e),s=`#${Co(i,n)}`,a=Ao(o,s);if(a)return a}}catch{}let r=z(e);return Io(r,n)}function us(e){let n=[];for(let r=0;r<arguments.length;r++){let o=arguments[r];if(Array.isArray(o))for(let i=0;i<o.length;i+=8192){let s=$u(o,i,i+8192),a=us.apply(null,s);for(let u=0;u<a.length;u++)n.push(a[u])}else n.push(o)}return n}function $u(e,t,n){return arguments.length<=2?Array.prototype.slice.call(e,t):Array.prototype.slice.call(e,t,n)}function uc(e,t){return Wu(e,t).concat(Vu(e))}function Wu(e,t){return us(fs(e).map(r=>bc(r)&&dn(r)?dc(r,t):r))}function dc(e,t){if(!e||ur(e,t))return[];if(!qu(e))return[e];let n=Array.from(e.children);return us(n.map(r=>dc(r,t)))}function fc(e){let t=cc(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 i=lc(e,o);i&&i!==e&&n.push(i)}return n}function Vu(e){let t=fc(e);for(let n of t)n["aria-owned-by"]=e;return t}function pc(e){let t=de(e),n=z(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)<=ju(e))return!1;let o=Gu(e);return!o||!Yu(o)||!Ku(e)||o.getAttribute("role")==="dialog"||e.getAttribute("role")==="dialog"?!1:Xu(e)}function Gu(e){return[e.previousElementSibling,e.nextElementSibling,...Array.from(e.children),...e.parentElement?[e.parentElement.previousElementSibling,e.parentElement.nextElementSibling]:[]].filter(n=>n!==null).find(zu)||null}function zu(e){if(ur(e))return!1;let n=de(e).getComputedStyle(e);return(n?.position==="fixed"||n?.position==="absolute")&&n?.backgroundColor!=="rgba(0, 0, 0, 0)"&&n?.backgroundColor!=="transparent"&&n?.pointerEvents!=="none"}function Yu(e){let t=de(e),n=e.getBoundingClientRect();return n.top<=0&&n.left<=0&&n.bottom>=t.innerHeight&&n.right>=t.innerWidth}function ju(e){let t=z(e),n=de(e),r=n?.getComputedStyle;if(!r)return 0;let o=Xi(t,"*").filter(i=>i!==e&&!ur(i)).map(i=>parseInt(r.call(n,i)?.zIndex,10)).filter(i=>Number.isFinite(i)&&!isNaN(i));return o.length?Math.max(...o):0}function Xu(e){return e.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])').length>0}function Ku(e){let t=e.parentElement;if(!t)return!1;for(let n of Array.from(t.children))if(n!==e&&!ur(n)&&n.getAttribute("aria-hidden")!=="true")return!1;return!0}function Qu(){try{let t=st()?.querySelector?.("dialog:modal");return'[aria-modal="true"], dialog:modal'}catch{return'[aria-modal="true"]'}}var hc=Qu();function Ju(e){return e.getAttribute("aria-disabled")==="true"||e.hasAttribute("disabled")}function ds(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=z(e),r=new URL(t,n.baseURI);return r.protocol==="javascript:"&&(r.pathname.trim()!==""||r.search.trim()!==""||r.hash.trim()!=="")}catch{return!1}}function mc(e){return Oa.has(e)}function Zu(e){let t=e.parentElement,n=z(e);if(!(!t||t===n.body||t===n.documentElement))return xt({targetElement:t,originatedFromParent:!0})}function Qa({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:i,elementContext:s}){let a={nodeCategory:e.nodeType},u=t||Ju(e),m=Zu(e);if(m&&(a.parent=m),n){let ve=kr[n];typeof ve=="number"?a.semanticRole=ve:a.semanticRole=n}if(u&&(a.isDisabled=!0),s){let{eventHandlerIndices:ve,isEditableRegion:Me}=s,ze=Sr(ve);ze.length>0&&(a.eventHandlers=ze),Me&&(a.isEditable=!0)}let p=td(e);p&&Object.keys(p).length>0&&(a.ariaProperties=p);let v=nd(e);v&&Object.keys(v).length>0&&(a.ariaStates=v);let I=e.nodeName;I&&I.trim()&&(a.elementName=I);let A=ac(e);A&&Object.keys(A).length>0&&(a.computedStyles=A),ur(e)&&(a.isInvisible=!0);let x=ed(e,n);x&&Object.keys(x).length>0&&(a.preservedAttributes=x),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 S=e.getAttribute("class");if(S?.trim()){S.includes("handle")&&(a.isDragHandle=!0),a.supportsHorizontalSwipe||(S.includes("horizontal")||S.includes("carousel"))&&(a.supportsHorizontalSwipe=!0),a.supportsVerticalSwipe||(S.includes("vertical")||S.includes("feed"))&&(a.supportsVerticalSwipe=!0),S.includes("dismissible")&&(a.supportsDismissSwipe=!0),(S.includes("long-press")||S.includes("hold")||S.includes("press-hold"))&&(a.supportsLongPress=!0);let ve=a.inputType||a.preservedAttributes?.[Nt.type];ve==="submit"||ve==="reset"||ve==="clear"||(S.includes("submit")&&(a.preservedAttributes={...a.preservedAttributes||{},[Nt.type]:"submit"}),S.includes("clear")&&(a.preservedAttributes={...a.preservedAttributes||{},[Nt.type]:"clear"}),S.includes("reset")&&(a.preservedAttributes={...a.preservedAttributes||{},[Nt.type]:"reset"}))}let B=cd({element:e});B&&B.length>0&&(a.labelReferences=B);let Y=e.tagName;if(Y&&(a.elementTag=Y),od(e)&&(a.hasFocus=!0),!o){let ve=ps({element:e,semanticRole:n,parentDisabled:u,excludeLabels:r});ve&&ve.length>0&&(a.childElements=ve)}let F=md({element:e});F&&F.length>0&&(a.ownedElements=F);let P=Mo(e);P&&(a.resourceLocator=P),(o||Ir(e))&&(a.isFrameElement=!0),i&&i.length>0&&(a.frameContent=i);let q=e.type;q&&typeof q=="string"&&q.trim()&&(a.inputType=q);let J=e.placeholder;J&&typeof J=="string"&&J.trim()&&(a.placeholderText=J);let ae=e.value;ae&&typeof ae=="string"&&ae.trim()&&(a.elementValue=ae);let ue=ld({element:e,parentDisabled:t,semanticRole:n});if(ue&&ue.length>0&&(a.selectedOptions=ue),On(e,"select,datalist")&&(a.nearestSelectList=!0),cs(e))a.elementNamespace=Kr.HTML;else if(rd(e)){a.elementNamespace=Kr.SVG,a.svgStructure=id(e);let ve=sd(e);ve&&Object.keys(ve).length>0&&(a.preservedAttributes?a.preservedAttributes={...a.preservedAttributes,...ve}:a.preservedAttributes=ve)}let se=r?void 0:ud({element:e});se&&se.length>0&&(a.associatedLabels=se);let Ee=e.scope;Ee&&typeof Ee=="string"&&Ee.trim()&&(a.tableScope=Ee);let pe=fd({element:e});pe&&(a.tableCaption=pe);let Re=pd({element:e});Re&&(a.figureCaption=Re);let ke=hd({element:e});return ke&&(a.fieldsetLegend=ke),On(e,"table")&&(a.nearestTable=!0),a}function ed(e,t){let n={},r=new Set(Object.values(Nt).filter(a=>typeof a=="string")),o=new Set(Object.keys(Do).filter(a=>isNaN(Number(a)))),i=new Set(["_ngcontent","ng-reflect-*","data-v-*"]),s=e?.attributes?Array.from(e.attributes):[];for(let a of s){let u=a.name,m=a.value;if(u==="id"&&(!t||!Ln.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=m.trim()!=="",I=o.has(p);if(v||I){let A=Nt[p],x=i.has(p)?"true":m;n[A]=x}}}if(!n[Nt[_t]]){let a=ja(e);a&&(n[Nt[_t]]=a)}return n}function td(e){return gc(e,Uo,Oo)}function nd(e){return gc(e,Fo,null)}function gc(e,t,n){let r={};for(let o in t)if(isNaN(Number(o))){let i=t[o],a=`aria-${o.toLowerCase().replace(/_/g,"-")}`,u=e.getAttribute(a),m=!1;n!==null&&(m=Object.values(n).filter(v=>typeof v=="number").includes(i)),e.hasAttribute(a)&&m||u?.trim()?r[i]=u:a==="aria-level"&&Ha.includes(e.tagName.toLowerCase()?.trim())&&(r[i]=e.tagName.substring(1))}return r}function dn(e){return bc(e)&&e.nodeType===Yn.ELEMENT}function jo(e){return e.nodeType===Yn.TEXT}function bc(e){let t=typeof e;return t=="object"&&e!=null||t=="function"}function cs(e){return dn(e)&&(!e.namespaceURI||e.namespaceURI===Ua)}function rd(e){return dn(e)&&e.namespaceURI===Fa}function Ir(e){return e.tagName==="IFRAME"}function lr(e,t){return"tagName"in e?e.tagName?.toLowerCase()===t:e.elementTag?.toLowerCase()===t}function On(e,t){if(e.closest)return e.closest(t);for(;!Yo(e,t);){if(e.parentElement===null)return null;e=e.parentElement}return e}function Yo(e,t){return e.matches?.(t)??e.msMatchesSelector?.(t)??e.webkitMatchesSelector(t)}function od(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 id(e){let t={},n=Dn.text,r=Dn.elText;e.textContent?.trim()&&(t[n]=e.textContent);let o=e.querySelector("title"),i=e.querySelector("img");o?.textContent?.trim()?t[r]=o.textContent:i?.alt?.trim()&&(t[r]=i.alt);let s=e.getAttribute("viewBox");s&&(t[Dn.viewBox]=s);let a=e.querySelectorAll("path");a.length>0&&(t[Dn.paths]=a.length,t[Dn.pathData]=Array.from(a).slice(0,3).map(m=>m.getAttribute("d")).filter(Boolean).map(m=>m.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(([m,p])=>{if(p>0){let v=Dn[m];t[v]=p}}),Object.keys(t).length>0?t:void 0}function sd(e){let t={};if(!e?.hasAttributes())return t;for(let n of Object.values(Rr).filter(r=>typeof r=="number")){let r=Rr[n];if(r){let o=r;if(Rr.hasOwnProperty(o)&&e.hasAttribute(o)){let i=e.getAttribute(o);i?.trim()&&(t[n]=i)}}}return t}function ad({frameElement:e,parentDisabled:t,excludeLabels:n}){if(!It.includeFrameContents)return[];let r=null;try{r=e.contentWindow?.document?.body||null}catch{return[]}if(!r)return[];let o=[];for(let i of fs(r))if(!(oo(i)||Ec(i))){if(dn(i)){let s=i,a=un(s),u=zt(s,a),{shouldCreate:m,shouldAnnotate:p}=Xo(u);if(m){p&&jn(s);let v=xt({targetElement:s,parentDisabled:t,semanticRole:a??void 0,excludeLabels:n,elementContext:u});v&&o.push(v)}else{let v=ps({element:s,semanticRole:a??void 0,parentDisabled:t,excludeLabels:n});o.push(...v)}}else if(jo(i)){let s=no(i);s&&o.push(s)}}return o}function fs(e){let t=de(e);if(Ra(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||rr()?.getShadowRoot?.(e)||null;if(n){let r=Array.from(n.childNodes),o=Array.from(e.childNodes).filter(i=>!i.assignedSlot);return r.concat(o)}}catch{}return Array.from(e.childNodes)}function ps({element:e,semanticRole:t,parentDisabled:n,excludeLabels:r}){let o=[];for(let i of fs(e))if(!(oo(i)||Ec(i))){if(dn(i)){let s=i,a=un(s),u=zt(s,a);if(Ir(s)){jn(s);let v=ad({frameElement:s,parentDisabled:n,excludeLabels:r}),I=xt({targetElement:s,parentDisabled:n,semanticRole:a??void 0,excludeLabels:r,isFrameNode:!0,frameContentNodes:v,elementContext:u});I&&o.push(I);continue}let{shouldCreate:m,shouldAnnotate:p}=Xo(u);if(m){p&&jn(s);let v=xt({targetElement:s,parentDisabled:n,semanticRole:a??void 0,excludeLabels:r,elementContext:u});v&&o.push(v)}else{let v=ps({element:s,semanticRole:a??void 0,parentDisabled:n,excludeLabels:r});o.push(...v)}}else if(jo(i)){let s=no(i);s&&o.push(s)}}return o}function cd({element:e}){let t=cc(e.getAttribute("aria-labelledby")),n=new Set;for(let r of t){let o=lc(e,r);if(!(!o||o===e)&&o){let i=un(o),s=xt({targetElement:o,semanticRole:i,elementContext:zt(o,i)});n.add(s)}}return Array.from(n)}function ld({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=>xt({targetElement:o,parentDisabled:t,semanticRole:"option",elementContext:zt(o,"option")})):lr(e,"select")&&(r=Array.from(e.selectedOptions).map(o=>xt({targetElement:o,parentDisabled:t,semanticRole:"option",elementContext:zt(o,"option")})))),r}function ud({element:e}){if(Pa.includes(e.tagName)){let t=z(e),n=Xi(t,"label"),r=new Set;return Array.from(n).filter(o=>o!==e&&dd(o,e)).map(o=>{let i=un(o),s=xt({targetElement:o,semanticRole:i,excludeLabels:!0,elementContext:zt(o,i)});r.add(s)}),Array.from(r)}}function dd(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 fd({element:e}){if(lr(e,"table")){let t=e.querySelector("caption");if(t&&t!==e){let n=un(t);return xt({targetElement:t,semanticRole:n,elementContext:zt(t,n)})}}}function pd({element:e}){if(lr(e,"figure")){let t=e.querySelector("figcaption");if(t&&t!==e){let n=un(t);return xt({targetElement:t,semanticRole:n,elementContext:zt(t,n)})}}}function hd({element:e}){if(lr(e,"fieldset")){let t=e.querySelector("legend");if(t&&t!==e){let n=un(t);return xt({targetElement:t,semanticRole:n,elementContext:zt(t,n)})}}}function md({element:e}){let t=new Set,n=fc(e);for(let r of n){let o=un(r),i=xt({targetElement:r,semanticRole:o,elementContext:zt(r,o)});t.add(i)}return Array.from(t)}function Xo(e){let{semanticRole:t,eventHandlerIndices:n,isEditableRegion:r,hasNodeWorthyHandlers:o,isLikelyStructuralContainer:i}=e,s=n.length>0&&n.some(v=>$a.has(v)),u=!!t||!i&&(o||r),m=!!t&&Ln.has(t);return{shouldCreate:u,shouldAnnotate:u&&(m||r||s)}}function Ec(e){if(!dn(e))return!1;let t=e,n=t.tagName;return Po.has(n)?!0:n===sr||n===ar?gd(t):!1}function gd(e){let t=de(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 hs(e,t={}){return va(t),Ka(),Ya(),Xa(e,{includeShadow:!0,includeIframes:It.clearIframes}),cr.initialize(It.semanticIdStart),{rootNodes:yc(e),semanticNodes:vn}}function yc(e){let t=[];try{let n=z(e),o=Array.from(n.querySelectorAll(hc)).filter(i=>!ur(i)&&pc(i));if(o.length===0)t=Ar({targetElement:e});else if(o.length===1){let i=o[0];i.contains(e)?t=Ar({targetElement:e}):e.contains(i)?t=Ar({targetElement:i}):t=Ar({targetElement:e})}else t=Ar({targetElement:e})}catch(n){throw console.error("Error constructing semantic tree",n),n}return t}function Ar({targetElement:e,parentNode:t}){if(oo(e)||wc(e))return[];let n=un(e),r=zt(e,n);if(Ir(e))return[Ed({frameElement:e,role:n,parentNode:t,elementContext:r})];let o=0,{shouldCreate:i,shouldAnnotate:s}=Xo(r);i&&(s&&jn(e),o=xt({targetElement:e,parentDisabled:t?.isDisabled,semanticRole:n,elementContext:r}));let a=vn[o],u=bd(e,n,o?a:t);return o&&u.length>0&&(a.semanticChildren=u),o?[o]:u}function bd(e,t,n){let r=[],o=uc(e,t);for(let i of o)if(!(oo(i)||wc(i))){if(dn(i)){let s=Ar({targetElement:i,parentNode:n});r.push(...s)}else if(jo(i)&&Td(i,n)){let s=no(i);s&&r.push(s)}}return r}function Ed({frameElement:e,role:t,parentNode:n,elementContext:r}){jn(e);let o=yd(e);return xt({targetElement:e,parentDisabled:n?.isDisabled,semanticRole:t,isFrameNode:!0,frameContentNodes:o,elementContext:r})}function yd(e){if(!It.includeFrameContents)return[];let t=wd(e);return t.kind==="content"?yc(t.rootElement):vd(e,t.reason)}function wd(e){let t=null;try{t=e.contentDocument||e.contentWindow?.document||null}catch{return{kind:"unavailable",reason:"cross_origin_blocked"}}let n=t?.body||t?.documentElement||null;return n?{kind:"content",rootElement:n}:{kind:"unavailable",reason:"iframe_not_ready_or_empty"}}function vd(e,t){let n=cr.generateId(),r=cr.generateId(),o=e.getAttribute("title")?.trim()||e.getAttribute("name")?.trim()||e.id?.trim()||"Embedded frame",i=Mo(e)||void 0,s=t==="cross_origin_blocked"?"Iframe content is not accessible from this origin (cross-origin).":"Iframe content is not ready yet or has no readable DOM.";return vn[n]={nodeCategory:Yn.ELEMENT,semanticRole:"embedded_document_unavailable",computedName:o,syntheticKind:"embedded_container",frameContent:[r],...i?{resourceLocator:i}:{}},vn[r]={nodeCategory:Yn.TEXT,parent:n,textContent:s,preventTextMerge:!0,syntheticKind:"embedded_unavailable_text"},[n]}function Td(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"?Qr[t.semanticRole]:t.semanticRole;if(mc(r))return!1}return!0}function wc(e){if(!dn(e))return!1;let t=e,n=t.tagName;return Po.has(n)?!0:n===sr||n===ar?_d(t):!1}function _d(e){let t=de(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 Qo(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t}function xd(e){let t=e.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}function Nr(e,t,n){let r=z(e,t),o=j(r,n);try{e.focus?.({preventScroll:!0})}catch{}if(Qo(r)===e)return!0;try{let{x:i,y:s}=xd(e),a=o.PointerEvent||PointerEvent,u=o.MouseEvent||MouseEvent;e.dispatchEvent(new a("pointerdown",{bubbles:!0,cancelable:!0,composed:!0,clientX:i,clientY:s,buttons:1,button:0,pointerType:"mouse"})),e.dispatchEvent(new u("mousedown",{bubbles:!0,cancelable:!0,composed:!0,clientX:i,clientY:s,buttons:1,button:0})),e.dispatchEvent(new u("mouseup",{bubbles:!0,cancelable:!0,composed:!0,clientX:i,clientY:s,buttons:0,button:0})),e.dispatchEvent(new a("pointerup",{bubbles:!0,cancelable:!0,composed:!0,clientX:i,clientY:s,buttons:0,button:0,pointerType:"mouse"})),(e.isContentEditable||Zt(e,o)||ln(e,o)||e.getAttribute("contenteditable")==="true")&&e.dispatchEvent(new u("click",{bubbles:!0,cancelable:!0,composed:!0,clientX:i,clientY:s,button:0}))}catch{}try{e.focus?.({preventScroll:!0})}catch{}return Qo(r)===e}function io(e,t){let n=de(e),r=ln(e,n)?n.HTMLTextAreaElement.prototype:n.HTMLInputElement.prototype,o=Object.getOwnPropertyDescriptor(r,"value");o?.set?o.set.call(e,t):e.value=t}function fr(e,t,n="insertText"){let r=de(e),o=r.InputEvent||(typeof InputEvent<"u"?InputEvent:null),i=r.Event||Event;try{o?e.dispatchEvent(new o("beforeinput",{bubbles:!0,cancelable:!0,composed:!0,data:String(t??""),inputType:n})):e.dispatchEvent(new i("beforeinput",{bubbles:!0,cancelable:!0,composed:!0}))}catch{try{e.dispatchEvent(new i("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 i("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{try{e.dispatchEvent(new i("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{}}try{e.dispatchEvent(new i("change",{bubbles:!0,cancelable:!0,composed:!0}))}catch{}}function Rd(e){let n=de(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)),i=e.dispatchEvent(new n("keypress",r)),s=e.dispatchEvent(new n("keyup",r));return{canceled:!(o&&i&&s)}}function dr(e){if(!e)return!1;let t=de(e);if(ln(e,t))return!e.disabled&&!e.readOnly;if(Zt(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 ms(e){let t=de(e);if(!e||!tt(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 kd(e,t){let n=e.getRootNode();return Gt(n)?n:z(e)??t}function Sd(e,t){let n=[];for(let r of t.split(/\s+/).filter(Boolean)){let o=e.getElementById?.(r)||e.querySelector?.(`#${CSS.escape(r)}`),i=de(o);tt(o,i)&&n.push(o)}return n}function xc(e,t){if(!e)return{kind:"none",el:null,via:"no-root"};if(dr(e))return{kind:"input",el:e,via:"self-input"};if(ms(e))return{kind:"contenteditable",el:e,via:"self-contenteditable"};let n=z(e)??t,r=j(n),o=kd(e,n);if(_a(e,r)){let u=e.control;if(dr(u))return{kind:"input",el:u,via:"label.control"};let m=e.htmlFor;if(m){let p=o.getElementById?.(m)||o.querySelector?.(`#${CSS.escape(m)}`);if(dr(p))return{kind:"input",el:p,via:"label.for"}}}let i=e.getAttribute("aria-controls")||e.getAttribute("aria-owns");if(i)for(let u of Sd(o,i)){if(dr(u))return{kind:"input",el:u,via:"aria-controls/owns"};if(ms(u))return{kind:"contenteditable",el:u,via:"aria-controls/owns"};let m=u.querySelector?.("input,textarea");if(dr(m))return{kind:"input",el:m,via:"aria-controls->desc"}}let s=e.querySelector?.("input,textarea");if(dr(s))return{kind:"input",el:s,via:"descendant"};let a=e.shadowRoot||null;if(a){let u=a.querySelector?.("input,textarea");if(dr(u))return{kind:"input",el:u,via:"open-shadow-input"};let m=a.querySelector?.('[contenteditable="true"],[contenteditable=""],[role="textbox"]');if(ms(m))return{kind:"contenteditable",el:m,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 Cr(e,t,n,r=!1){let o=z(e,t),s=j(o,n).getSelection?.();if(!s)return!1;try{let a=o.createRange();return a.selectNodeContents(e),r&&a.collapse(!1),s.removeAllRanges(),s.addRange(a),!0}catch{return!1}}function pr(e){return(e.textContent??"").replace(/\u00A0/g," ").trim()}var Ko=e=>String(e??"").replace(/\s+/g," ").trim(),Rc=new MessageChannel,kc=[];Rc.port1.onmessage=()=>{let e=kc.shift();e&&e()};function vc(){return new Promise(e=>{kc.push(e),Rc.port2.postMessage(0)})}async function Tc(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 vc():await new Promise(i=>{try{t.requestAnimationFrame(()=>i())}catch{vc().then(i)}})}function Id(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 _c(e,t,n,r){let o=z(e,t),s=j(o,n).KeyboardEvent||KeyboardEvent,a=String(r??"");for(let u of a){let{code:m,which:p}=Id(u),v={key:u,code:m,bubbles:!0,cancelable:!0,composed:!0,keyCode:p,which:p};e.dispatchEvent(new s("keydown",v)),e.dispatchEvent(new s("keypress",v)),e.dispatchEvent(new s("keyup",v))}}async function Sc(e,t,n,r,o){let i=String(r??"");if(e.disabled||e.readOnly)return{success:!1,method:"type-native-setter",details:"disabled_or_readonly",allowFallback:!0};let s=String(e.value??""),a=z(e,t),u=j(a,n),m=Nr(e,a,u),p=Number.isFinite(Number(o?.settleFrames))?Math.max(0,Math.min(4,Number(o?.settleFrames))):a.hidden?1:2,v=!!o?.useKeyFallback,I=Number.isFinite(Number(o?.keyFallbackMaxLen))?Number(o?.keyFallbackMaxLen):140,A=v&&i.length>0&&i.length<=I;io(e,i),fr(e,i,"insertReplacementText"),A&&_c(e,a,u,i),await Tc(a,u,p);let x=String(e.value??""),S=Ko(s),B=Ko(x),Y=Ko(i),F=S===Y,P=B===Y,q=x!==s,J=i.length>0&&!F&&x===s,ae=1;if(!F&&!P&&!q){ae=2;try{e.focus?.({preventScroll:!0}),e.select?.()}catch{}let pe=!1;try{a.execCommand?.("selectAll",!1,void 0),pe=!!a.execCommand?.("insertText",!1,i)}catch{pe=!1}if(!pe)try{io(e,i)}catch{}try{fr(e,i,"insertReplacementText")}catch{}A&&_c(e,a,u,i),await Tc(a,u,p),x=String(e.value??"")}let me=Ko(x)===Y,se=x!==s;J=i.length>0&&!F&&x===s;let Ee=F||me||se;return{success:Ee,method:"type-native-setter",details:`focus=${m};attempts=${ae};settleFrames=${p};beforeLen=${s.length};afterLen=${x.length};changed=${se};alreadyCorrect=${F};nowCorrect=${me};reverted=${J};keyFallback=${A}`,allowFallback:Ee?void 0:!0}}function Ad(e,t,n){let o=de(e).InputEvent||InputEvent,i=new o("beforeinput",{bubbles:!0,cancelable:!0,composed:!0,data:t,inputType:n});return{ok:e.dispatchEvent(i),defaultPrevented:i.defaultPrevented}}function Ic(e,t,n,r){let o=z(e,n),i=j(o,r),s=i.InputEvent||InputEvent,a=i.Event||Event,u=String(t??""),m=pr(e),p=Nr(e,o,i),v=Cr(e,o,i,!0),I=Ad(e,u,"insertText"),A=!1,x="execCommand",S=!1,B=()=>{S=!0};try{e.addEventListener("input",B,{capture:!0})}catch{}if(I.ok&&!I.defaultPrevented)try{A=!!o.execCommand?.("insertText",!1,u)}catch{}if(!A)try{let P=i.getSelection?.(),q=P&&P.rangeCount?P.getRangeAt(0):null;if(!q||!e.contains(q.commonAncestorContainer)){Cr(e,o,i,!0);let J=i.getSelection?.();q=J&&J.rangeCount?J.getRangeAt(0):null}q&&(q.insertNode(o.createTextNode(u)),q.collapse(!1),P?.removeAllRanges(),P?.addRange(q),A=!0,x="range")}catch{}if(A&&!S){try{e.dispatchEvent(new s("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",B,{capture:!0})}catch{}let Y=pr(e);return{success:Y!==m||!!u&&Y.includes(u),method:`type-contenteditable-${x}`,details:`focus=${p};selectedWithin=${v};inserted=${A}`}}function Ac(e){let{canceled:t}=Rd(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 Cc(e,t,n){if(e.disabled||e.readOnly)return{success:!1,method:"clear-native-setter",details:"disabled_or_readonly",allowFallback:!0};let r=z(e,t),o=j(r,n),i=String(e.value??""),s=Nr(e,r,o);io(e,""),fr(e,"","deleteByCut");let a=String(e.value??""),u=a!==i;return{success:u||a.length===0,method:"clear-native-setter",details:`focus=${s};beforeLen=${i.length};afterLen=${a.length};changed=${u}`}}function Nc(e,t,n){let r=z(e,t),o=j(r,n),i=pr(e),s=Nr(e,r,o),a=Cr(e,r,o,!1),u=!1,m="execCommand";try{u=!!r.execCommand?.("delete",!1,void 0)}catch{u=!1}if(!u)try{let A=o.getSelection?.(),x=A&&A.rangeCount?A.getRangeAt(0):null;(!x||!e.contains(x.commonAncestorContainer))&&Cr(e,r,o,!1);let S=o.getSelection?.(),B=S&&S.rangeCount?S.getRangeAt(0):null;B&&(B.deleteContents(),B.collapse(!1),S?.removeAllRanges(),S?.addRange(B),u=!0,m="range")}catch{}if(!u)try{e.textContent="",u=!0,m="textContent"}catch{}fr(e,"","deleteByCut");let p=pr(e),v=p!==i;return{success:u||v||p.length===0,method:`clear-contenteditable-${m}`,details:`focus=${s};selectedWithin=${a};cleared=${u};changed=${v}`}}function Lc(e,t){if(e===t||e.contains(t))return!0;let n=t;for(;n;){let r=n.getRootNode?.();if(Gt(r)){let o=r.host;if(o===e||e.contains(o))return!0;n=o;continue}n=n.parentNode||null}return!1}var Jo;(function(e){e.FLASH_LITE="Gemini Flash Lite",e.FLASH="Gemini Flash",e.PRO="Gemini Pro"})(Jo||(Jo={}));var Mc;(function(e){e[e.NativeHostConnected=0]="NativeHostConnected",e[e.NativeHostDisconnected=1]="NativeHostDisconnected"})(Mc||(Mc={}));var Cd=["image/png","image/jpeg","image/webp"],Nd=["application/pdf","text/plain"],fg=[...Cd,...Nd];var Et;(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"})(Et||(Et={}));var ft;(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"})(ft||(ft={}));var pg={[Et.ACT]:ft.AGENTIC_SEEK,[Et.CRAWL]:ft.CRAWL_PAGES,[Et.EXTRACT]:ft.EXTRACT_PAGE,[Et.SHEETS_WORKFLOW]:ft.SHEETS_WORKFLOW,[Et.INFER_SHEET_DATA]:ft.INFER_SHEET_DATA,[Et.PDF_FILLER]:ft.PDF_FILLER,[Et.CUSTOM_TOOL_GENERATOR]:ft.CUSTOM_TOOL_GENERATOR,[Et.WEBPAGE_GENERATOR]:ft.WEBPAGE_GENERATOR,[Et.GOOGLE_DOC_GENERATOR]:ft.GOOGLE_DOC_GENERATOR,[Et.GOOGLE_SLIDES_GENERATOR]:ft.GOOGLE_SLIDES_GENERATOR,[Et.PROCESS_TEXT]:ft.PROCESS_TEXT,[Et.CREATE_SHEET_FROM_DATA]:ft.CREATE_SHEET_FROM_DATA,[Et.EXECUTE_MULTIPLE_TOOLS]:ft.EXECUTE_MULTIPLE_TOOLS,[Et.CONFIGURE_API_KEY]:ft.CONFIGURE_API_KEY,[Et.QUERY_RTRVR_AI_DOCUMENTATION]:ft.QUERY_RTRVR_AI_DOCUMENTATION};var gs=200;var hg=Jo.FLASH;var mg=ft.PLANNER;var bs="application/pdf",Es="application/gsheet";var gg=20*1024*1024;var Zo={maxParallelTabs:4,pageLoadDelay:2e3,disableAutoScroll:!1,makeNewTabsActive:!1,writeRowProcessingTime:!1,totalBudgetMs:25e3,pageDataTimeoutMs:22e3,pdfTextSelectionTimeoutMs:12e3,onlyTextContent:!1};var Ld=1,Md=9,Dd=11,ws="application/gdoc",Lr="text/html",ei="text/plain";function Od(e){return!!e&&typeof e=="object"&&e.nodeType===Md}function Dc(e){return!!e&&typeof e=="object"&&e.nodeType===Ld}function Pd(e){return!!e&&typeof e=="object"&&e.nodeType===Dd&&typeof e.host=="object"&&typeof e.mode=="string"}function Oc(e){return Dc(e)&&String(e.tagName).toUpperCase()==="IFRAME"}function ys(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 Hd(e){try{let t=e.shadowRoot;return t||globalThis?.chrome?.dom?.openOrClosedShadowRoot?.(e)||null}catch{return null}}function Ud(e,t,n={}){let r=n.traverseShadow!==!1,o=n.traverseIframes!==!1,i=n.requireOwnerDocument,s=[e],a=new WeakSet;for(;s.length;){let u=s.pop();if(u&&typeof u=="object"){if(a.has(u))continue;a.add(u)}if(Od(u)){let v=u.documentElement||u.body;v&&s.push(v);continue}if(Pd(u)){let v=u.children;if(v&&v.length)for(let I=v.length-1;I>=0;I--)s.push(v[I]);continue}if(!Dc(u))continue;let m=u;if(i&&m.ownerDocument!==i)continue;let p=m.getAttribute?.(_t);if(p&&Zr(p)===t)return m;if(r)try{let v=Hd(m);v&&s.push(v)}catch{}if(o&&Oc(m))try{let v=Vr(m);v&&s.push(v)}catch{}for(let v=m.lastElementChild;v;v=v.previousElementSibling)s.push(v)}return null}function fn(e,t,n={}){let r=ys(t);if(!r)return null;let o=to(r);return o&&(!n.requireOwnerDocument||o.ownerDocument===n.requireOwnerDocument)?o:Ud(e,r,{requireOwnerDocument:n.requireOwnerDocument,traverseShadow:n.traverseShadow,traverseIframes:n.traverseIframes})}function vs(e=document){return e.querySelector('embed[type="application/pdf"], embed[type="application/x-google-chrome-pdf"]')}function Pc(e){if(e==null)return[];if(Array.isArray(e)){let t=[];for(let n of e){let r=ys(n);r&&t.push(r)}return t}if(typeof e=="number"||typeof e=="bigint"){let t=ys(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 Pc(t)}return[]}function Mr(e,t){let n=Pc(t),r=e.defaultView||window;if(!n.length)return{doc:e,win:r,iframePath:n,resolvedPath:[],unresolvedPath:[]};let o=e,i=[];for(let s=0;s<n.length;s++){let a=n[s],u=n.length===1,m=fn(o,a,{requireOwnerDocument:u?void 0:o,traverseShadow:!0,traverseIframes:u});if(!m||!Oc(m))return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:i,unresolvedPath:n.slice(s)};let p=null;try{p=Vr(m)||null}catch{p=null}if(!p)return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:i,unresolvedPath:n.slice(s)};i.push(a),o=p}return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:i,unresolvedPath:[]}}function Hc(e){return e==="application/pdf"||e==="application/x-pdf"||e==="application/x-google-chrome-pdf"}function Fd(){return Date.now()}function en(e){return!e||!Number.isFinite(e)?Number.POSITIVE_INFINITY:Math.max(0,e-Fd())}async function Uc(e,t,n){if(!Number.isFinite(e)||e<=0)return;let r=en(n);r<=0||r<e+40||await pt(e,t)}async function Dr(e,t,n){let r=Math.max(0,Math.floor(t));return r?await Promise.race([e.then(i=>({ok:!0,value:i})),(async()=>(await pt(r,n),{ok:!1,reason:"timeout"}))()]):{ok:!1,reason:"timeout"}}var pt=(()=>{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 i=Number(r);if(!Number.isFinite(i)||i<=0)return;if(!o.hidden){let a=o.defaultView||window,u=a.setTimeout?a.setTimeout.bind(a):setTimeout;await new Promise(m=>u(m,i));return}let s=Date.now();for(;Date.now()-s<i;)await n()}})();var Bd=3e4;function Fc(e){return(String(e??"").replace(/\\/g,"/").split("/").pop()||"upload").replace(/[\u0000-\u001f\u007f]/g,"").trim()||"upload"}var Ts=class extends Error{constructor(n,r){super(n);W(this,"url");W(this,"status");W(this,"statusText");W(this,"bodySnippet");this.name="FetchFileError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.bodySnippet=r.bodySnippet}};function qd(e){return e&&e.split(";")[0].trim()||"application/octet-stream"}function $d(e){if(!e)return;let t=/filename\*\s*=\s*UTF-8''([^;]+)/i.exec(e);if(t?.[1])try{return decodeURIComponent(t[1].trim().replace(/^\"(.*)\"$/,"$1"))}catch{}let n=/filename\s*=\s*(\"?)([^\";]+)\1/i.exec(e);if(n?.[2])return n[2].trim()}function _s(e,t){try{let r=(t??window).URL||URL,i=new r(e).pathname.match(/\/o\/(.+?)(\?|$)/);if(i?.[1]){let a=decodeURIComponent(i[1]).split("/");return a[a.length-1].replace(/^\d+-/,"")}}catch{}}function Bc(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 Wd(e,t={},n,r=fetch){let o=new AbortController,i=Bd,s=!1,a=()=>{};if(n){let m=!1;a=()=>{m=!0},(async()=>{try{if(await pt(i,n),m)return;s=!0,o.abort()}catch{}})().catch(()=>{})}else{let m=setTimeout(()=>{s=!0,o.abort()},i);a=()=>clearTimeout(m)}let u=new Headers(t.headers);u.has("Accept")||u.set("Accept","*/*");try{let m=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(!m.ok){let A=await m.text().catch(()=>"");throw new Ts(`Fetch failed (${m.status})`,{url:e,status:m.status,statusText:m.statusText,bodySnippet:A.slice(0,256)})}let p=await m.arrayBuffer(),v=qd(m.headers.get("content-type")),I=$d(m.headers.get("content-disposition"))||_s(e);return{bytes:p,mimeType:v,fileName:I}}finally{a()}}async function qc(e,t,n){return await Wd(t,{referrer:n??void 0,referrerPolicy:"strict-origin-when-cross-origin"})}var Ve;(function(e){e.UP="UP",e.DOWN="DOWN",e.LEFT="LEFT",e.RIGHT="RIGHT",e.TOP="TOP",e.BOTTOM="BOTTOM"})(Ve||(Ve={}));var yt;(function(e){e.START="START",e.CENTER="CENTER",e.END="END",e.NEAREST="NEAREST"})(yt||(yt={}));function Wc(e){if(!e)return yt.CENTER;let t=typeof e=="string"?e.toUpperCase():String(e).toUpperCase();return yt&&t in yt?yt[t]:yt.CENTER}function xs(e){return globalThis.CSS&&typeof globalThis.CSS.escape=="function"?globalThis.CSS.escape(e):e.replace(/([ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}function Or(e,t){if(!e)return"";let n=z(e,t);if(e===n.documentElement)return"html";if(e===n.body)return"body";if(e.id)return`#${xs(e.id)}`;let r=[],o=e;for(;o&&o!==n.body&&o!==n.documentElement;){let i=o.tagName.toLowerCase();if(o.id){i+=`#${xs(o.id)}`,r.unshift(i);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,m)=>u.length-m.length).slice(0,3).map(xs);if(a.length)i+="."+a.join(".");else{let u=o.parentElement;if(u){let m=Array.from(u.children).filter(p=>p.tagName===o.tagName);if(m.length>1){let p=m.indexOf(o)+1;i+=`:nth-of-type(${p})`}}}r.unshift(i),o=o.parentElement}return r.join(" > ")}function hr(e){return e.scrollingElement||e.documentElement||e.body}function ti(e,t,n,r,o){let i=z(e,t),s=j(i,n),a=hr(i),u=e===i.documentElement||e===i.body||e===a,m=u?a:e,p=u?s.innerHeight:m.clientHeight,v=u?s.innerWidth:m.clientWidth,I=o??p*.8;switch(r){case Ve.DOWN:{m.scrollTop+=I;break}case Ve.UP:{m.scrollTop=Math.max(0,m.scrollTop-I);break}case Ve.LEFT:return m.scrollLeft=Math.max(0,m.scrollLeft-(o??v*.8)),{success:!0,scrollLeft:m.scrollLeft};case Ve.RIGHT:return m.scrollLeft+=o??v*.8,{success:!0,scrollLeft:m.scrollLeft};default:return{success:!1,error:`Unsupported scroll direction: ${String(r)}`}}let A=m.scrollHeight,x=u?s.innerHeight:m.clientHeight,S=A-x;return{success:!0,scrollTop:m.scrollTop,isAtTop:m.scrollTop<=5,isAtBottom:m.scrollTop>=S-5}}function Vd(e,t,n){let r=z(e,t),o=j(r,n),i=hr(r),s=e;for(;s&&s!==r.body&&s!==r.documentElement;){let u=o.getComputedStyle(s).overflowY;if((u==="auto"||u==="scroll"||u==="overlay")&&s.scrollHeight>s.clientHeight+5)return s;s=s.parentElement}return i}function $c(e,t,n){let r=z(e,t),o=j(r,n),i=hr(r),s=e===r.documentElement||e===r.body||e===i,a=s?i:e,u=a.scrollHeight,m=s?o.innerHeight:a.clientHeight,p=u-m;return a.scrollTop>=p-5}function Rs(e,t,n,r){let o=z(e,t),i=j(o,n),s=hr(o),a=Vd(e,o,i),u=a===o.documentElement||a===o.body||a===s,m=u?s:a,p=e.getBoundingClientRect(),v=u?new(i.DOMRect||DOMRect)(0,0,i.innerWidth,i.innerHeight):a.getBoundingClientRect(),I=u?i.innerHeight:a.clientHeight,A=24,x=p.top-v.top,S=m.scrollTop+x,B;switch(r){case yt.START:B=S-A;break;case yt.END:B=S+p.height-I+A;break;case yt.NEAREST:{if(p.top>=v.top&&p.bottom<=v.bottom)return{success:!0,scrollTop:m.scrollTop,isAtTop:m.scrollTop<=5,isAtBottom:$c(m,o,i)};p.top<v.top?B=S-A:B=S+p.height-I+A;break}case yt.CENTER:default:B=S-I/2+p.height/2;break}let Y=m.scrollHeight-I;return m.scrollTop=Math.max(0,Math.min(B,Y)),{success:!0,scrollTop:m.scrollTop,isAtTop:m.scrollTop<=5,isAtBottom:$c(m,o,i)}}function Vc(e){let t=Number(e);if(!Number.isFinite(t))return null;let n=Math.trunc(t);return n>0?n:null}function Gc(e){let t=[];for(let n of _o){let r=e?.[n];if(r==null)continue;if(Array.isArray(r)){for(let i of r){let s=Vc(i);s!=null&&t.push(s)}continue}let o=Vc(r);o!=null&&t.push(o)}return Array.from(new Set(t))}function Gd(e){return Gc(e).length>0}function zd(e){let t=Gc(e);return t.length?t[0]:null}var Yd=new Set([M.click_element,M.type_into_element,M.type_and_enter,M.hover_element,M.right_click_element,M.double_click_element,M.press_key,M.scroll_page,M.scroll_to_element,M.mouse_wheel,M.drag_element,M.drag_and_drop,M.swipe_element,M.long_press_element,M.adjust_slider,M.select_dropdown_value,M.clear_element,M.focus_element,M.check_field_validity,M.select_text,M.copy_text,M.paste_text,M.pinch_zoom,M.upload_file,M.dispatch_pointer_path]);(()=>{let e="__RTRVR_ACTION_EXECUTOR__";if(window[e])return;window[e]=!0;try{document.documentElement?.setAttribute(Zi,"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],i=o&&typeof o=="object"?o:{};if(!o)try{Object.defineProperty(window,r,{value:i,writable:!1,configurable:!1,enumerable:!1})}catch{window[r]=i}async function s(c){let E={};try{let y=Ea[c.opcode];if(!y)throw new Error(`Unknown tool opcode: ${c.opcode}`);let b={...c.call,name:y};E=(await S({tabIndex:c.tabIndex,call:b,elementData:x(c.elementData),payload:c.payload}))[0]?.response??{success:!1,error:"Empty tool response",allowFallback:!0}}catch(y){E={success:!1,error:y?.message||String(y),allowFallback:!0}}return E}try{Object.defineProperty(i,"actions",{value:Object.freeze({execute:s}),writable:!1,configurable:!1,enumerable:!1})}catch{}let a="__RTRVR_UPLOAD_BYTES_REQ__",u="__RTRVR_UPLOAD_BYTES_RES__",m="__RTRVR_UPLOAD_BYTES_BRIDGE__",p="__RTRVR_WINDOW_MESSAGE_MUX__";function v(c){let E=c,y=E[p];if(!y||typeof y!="object"){y={handlers:new Set,installed:!1};try{Object.defineProperty(E,p,{value:y,enumerable:!1,configurable:!1})}catch{E[p]=y}}if(!y.installed){y.installed=!0,c.addEventListener("message",b=>{if(b.source===c)for(let f of Array.from(y.handlers))try{f(b)}catch{}},!0);try{c.addEventListener("pagehide",()=>{let f=c[m]?.pending;if(f)for(let[d,g]of f){try{g.cancelTimeout()}catch{}g.reject(new Error("pagehide: upload bytes request canceled")),f.delete(d)}},!0)}catch{}}return y}function I(c){let E=c,y=E[m];if(!y||typeof y!="object"){y={pending:new Map};try{Object.defineProperty(E,m,{value:y,enumerable:!1,configurable:!1})}catch{E[m]=y}v(c).handlers.add(f=>{let d=f?.data;if(!d||typeof d!="object"||d.type!==u)return;let g=String(d.requestId||"");if(!g)return;let T=y.pending.get(g);if(!T)return;y.pending.delete(g);try{T.cancelTimeout()}catch{}if(!d.ok){T.reject(new Error(d.error||"Failed to get bytes"));return}let L=d.bytes;if(!(L instanceof ArrayBuffer)){T.reject(new Error("Invalid bytes payload (expected ArrayBuffer)"));return}if(typeof T.expectedByteLength=="number"&&L.byteLength!==T.expectedByteLength){T.reject(new Error(`Byte length mismatch: got=${L.byteLength}, expected=${T.expectedByteLength}`));return}T.resolve(L)})}return y}function A(c,E,y,b=9e4){let f=c.__ROVER_UPLOAD_BYTES__||c.rover?.uploadBytes||c.rtrvr?.uploadBytes;if(typeof f=="function")return Promise.resolve().then(()=>f({token:E,byteLength:y,timeoutMs:b})).then(C=>{if(C instanceof ArrayBuffer)return C;if(C&&C.buffer instanceof ArrayBuffer)return C.buffer;throw new Error("Upload bytes provider returned invalid buffer")});let d=I(c),g=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(16).slice(2)}`,T=Math.max(1e3,Math.min(Number(b)||9e4,18e4)),L=No(c)||document;return new Promise((C,D)=>{let U=!1,G=!1,X=()=>{G=!0};(async()=>{await pt(T,L),!(G||U)&&(d.pending.delete(g),U=!0,D(new Error("Timed out waiting for upload bytes")))})().catch(()=>{}),d.pending.set(g,{cancelTimeout:X,expectedByteLength:y,resolve:oe=>{U||(U=!0,X(),C(oe))},reject:oe=>{U||(U=!0,X(),D(oe))}}),c.postMessage({type:a,requestId:g,token:E,byteLength:y},"*")})}function x(c){if(c)return{frameworks:c.frameworks?c.frameworks.map(E=>ba[E]).filter(E=>E&&E!=="unknown"):[],listenersRaw:c.listenersRaw??"",role:c.role??void 0,pattern:c.pattern??void 0,value:c.value??void 0}}async function S({tabIndex:c,call:E,elementData:y,payload:b}){let f=(()=>{try{return yn()?.top?.document||document}catch{return document}})(),d=E.args,g=Gd(d),T,L,C=[],D=[],U=[];try{({doc:T,win:L,iframePath:C,resolvedPath:D,unresolvedPath:U}=Mr(f,d.iframe_id))}catch{if(d.iframe_id!=null){let ee=`Cannot access iframe ${d.iframe_id} (cross-origin or not found)`;return[{name:E.name,args:E.args,response:{success:!1,error:ee,allowFallback:!1,output:{success:!1,error:{code:"IFRAME_CONTEXT_UNAVAILABLE",message:ee,retryable:!1},iframe_context:{requested_iframe_id:d.iframe_id}}}}]}T=document,L=j(T)}if(d.iframe_id!=null&&U.length>0&&!g){let ce=`iframe_id unresolved: remaining=${U.join(">")||"(none)"} (cross-origin, not-ready, or not found)`;return[{name:E.name,args:E.args,response:{success:!1,error:ce,allowFallback:!1,details:`requested=${C.join(">")||"(none)"} resolved=${D.join(">")||"(none)"}`,output:{success:!1,error:{code:"IFRAME_CONTEXT_UNAVAILABLE",message:ce,retryable:!1},iframe_context:{requested_iframe_id:d.iframe_id,requested_path:C,resolved_path:D,unresolved_path:U}}}}]}let G=E.name,X=zd(d),oe=X?fn(T,X):null,we=oe?.ownerDocument??null,ne;if(!Yd.has(G))ne={success:!1,error:`Tool not promotable to main: ${G}`,allowFallback:!0};else{let ee=we??T,ce=j(ee,L);ne=await Y(G,oe,d,y,ee,ce,b)}return[{name:E.name,args:E.args,response:ne}]}async function B(c,E,y){try{let b=c.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",d=c[b]?.scroll?.execute;if(typeof d!="function")throw new Error("main-world scroll detector not available");let g=y?.doc||No(c)||document,T=Math.max(250,Math.min(Number(y?.timeoutMs??3500),8e3)),L=await Dr(Promise.resolve().then(()=>d(E)),T,g);if(!L.ok)throw new Error("scroll detector timeout");return L.value}catch(b){throw new Error(b?.message||"main-world scroll detector not available")}}async function Y(c,E,y,b,f,d,g){let T=G=>({success:G.success,error:G.success?void 0:G.details||"Action failed",allowFallback:G.success?void 0:G.allowFallback??!0}),L=c===M.press_key||c===M.scroll_page||c===M.drag_and_drop||c===M.pinch_zoom;if(!E&&!L)return T({success:!1,method:"missing-element-race",details:"Target element missing",allowFallback:!0});let C=new Set([M.type_into_element,M.type_and_enter,M.clear_element,M.focus_element,M.select_text,M.check_field_validity]),D=E,U=z(D,f);if(D&&C.has(c)){let G=xc(D,U);(G.kind==="input"||G.kind==="contenteditable")&&(D=G.el)}try{switch(c){case M.click_element:return T(J(E,f,d,b));case M.double_click_element:return T(gn(E,f,d));case M.right_click_element:return T(ye(E,f,d));case M.hover_element:return T(await Ge(E,f,d,b,y.duration));case M.type_into_element:return T(await nn(D,f,d,y.text,b));case M.type_and_enter:return T(await Dt(D,f,d,y.text,b));case M.clear_element:return T(await Ot(D,f,d,b));case M.focus_element:return T(mt(D,f,d));case M.select_dropdown_value:return T(Le(E,f,d,y.value,b));case M.adjust_slider:return T(Pt(E,f,d,b?.value??y.value,b));case M.check_field_validity:return T(Wr(D,f,d));case M.select_text:return T(xn(D,f,d,y.start_offset,y.end_offset));case M.scroll_page:return T(await qn(E,f,d,y));case M.scroll_to_element:return T(await je(E,f,d,y));case M.mouse_wheel:return T(rt(E,f,d,y.delta_x,y.delta_y));case M.drag_element:return T(await Ht(E,f,d,y,b));case M.drag_and_drop:return T(await Xt(y,E,f,d));case M.swipe_element:return T(await rn(E,f,d,y));case M.long_press_element:return T(await Rn(E,f,d,y.duration));case M.pinch_zoom:return T(await qe(E,f,d,y));case M.press_key:return T(Ut(y.key,y.modifiers,E,f,d));case M.copy_text:return T(await kn(E,f,d));case M.paste_text:return T(await Ft(E,f,d,b));case M.upload_file:return T(await Kt(y,f,d,g,E,b));case M.dispatch_pointer_path:return T(await on(y,f,d));default:return T({success:!1,method:"unhandled",details:`Unhandled ${c}`,allowFallback:!0})}}catch(G){return T({success:!1,method:"exception",details:G?.message||"exception",allowFallback:!0})}}function F(c){let E=new Map;if(!c)return E;let y=c.trim();if(!y)return E;let b=ir(y);if(b){for(let{id:f,mask:d}of b.entries){let g=Nn[f];if(!g)continue;let T=new Set(Ro(d)),L=E.get(g);if(L)for(let C of T)L.add(C);else E.set(g,T)}return E}return E}function P(c,...E){return c?E.some(y=>c.has(y)):!1}function q(c,E){let y=F(E?.listenersRaw),b=new Set;for(let[,C]of y)for(let D of C)(D==="react"||D==="vue"||D==="angular"||D==="svelte"||D==="jquery")&&b.add(D);let f=new Set;for(let[C,D]of y)if(["click","input","change","keydown","keyup","pointerdown","pointerup","mousedown","mouseup","submit","dragstart","drop","wheel","scroll"].includes(C))for(let U of D)f.add(U);let d=b.size>0||[...f].some(C=>["react","vue","angular","svelte","jquery"].includes(C)),g=P(y.get("click"),"delegated"),T=P(y.get("input"),"delegated")||P(y.get("change"),"delegated")||P(y.get("keydown"),"delegated"),L=E?.role||Jr(c)||c.getAttribute("role");return{sourcesByType:y,fws:b,isFrameworkElement:d,delegatedClick:g,delegatedInput:T,role:L}}function J(c,E,y,b){let f=q(c,b),d=z(c,E),g=j(d,y);We(c,d,g),b?.pattern==="hover-activate"&&Ge(c,d,g,b,120);let T=f.fws.has("react")||P(f.sourcesByType.get("click"),"react"),L=f.fws.has("vue")||P(f.sourcesByType.get("click"),"vue"),C=f.fws.has("angular")||P(f.sourcesByType.get("click"),"angular"),D=f.fws.has("svelte")||P(f.sourcesByType.get("click"),"svelte"),U=f.fws.has("jquery")||P(f.sourcesByType.get("click"),"jquery");return Wn(()=>ae(c,d,g),()=>ue(c,d,g),()=>T?se(c,d,g):null,()=>L?Ee(c,d,g):null,()=>C?pe(c,d,g):null,()=>D?Re(c,d,g):null,()=>U?ke(c,d,g):null)}function ae(c,E,y){let b=z(c,E),f=j(b,y),d=f.PointerEvent||PointerEvent,g=f.MouseEvent||MouseEvent,{x:T,y:L}=me(c,b,f),C={bubbles:!0,cancelable:!0,composed:!0,view:f,clientX:T,clientY:L,button:0,buttons:1};return c.focus?.({preventScroll:!0}),[new d("pointerover",C),new d("pointerenter",{...C,bubbles:!1}),new g("mouseover",C),new g("mouseenter",{...C,bubbles:!1}),new d("pointerdown",C),new g("mousedown",C),new d("pointerup",{...C,buttons:0}),new g("mouseup",{...C,buttons:0}),new g("click",{...C,buttons:0})].forEach(U=>c.dispatchEvent(U)),{success:!0,method:"pointer-mouse-click"}}function ue(c,E,y){let b=z(c,E),f=j(b,y);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 me(c,E,y){let b=z(c,E),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}],g=null;for(let T=0;T<d.length;T++){let L=d[T],C=b.elementFromPoint(L.x,L.y);if(T===0&&(g=C),C&&Lc(c,C))return{...L,hit:C,ok:!0}}return{...d[0],hit:g,ok:!1}}function se(c,E,y){let b=z(c,E),f=j(b,y);try{let d=Bt(c);if(!d)return{success:!1,method:"react-no-fiber"};let g=Tt(d),T=g.onClick||g.onClickCapture;return T?(T(qt("click",c,b,f)),{success:!0,method:"react-fiber-onClick"}):{success:!1,method:"react-no-onClick"}}catch{return{success:!1,method:"react-fiber-onClick"}}}function Ee(c,E,y){let b=z(c,E),d=j(b,y).MouseEvent||MouseEvent;try{let g=Cn(c);if(!g)return{success:!1,method:"vue-none"};let T=Vn(g);return T.click?(T.click(new d("click",{bubbles:!0})),{success:!0,method:"vue-handler"}):g.$emit?(g.$emit("click"),{success:!0,method:"vue-emit"}):{success:!1,method:"vue-no-click"}}catch{return{success:!1,method:"vue-handler"}}}function pe(c,E,y){let b=z(c,E),f=j(b,y),d=f.MouseEvent||MouseEvent;try{let g=f.ng?.getZone?.()||null;return g?.run?(g.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 Re(c,E,y){let b=z(c,E),d=j(b,y).MouseEvent||MouseEvent;try{let g=c.getBoundingClientRect(),T={bubbles:!0,cancelable:!0,view:c.ownerDocument?.defaultView||window,clientX:g.left+g.width/2,clientY:g.top+g.height/2};return c.dispatchEvent(new d("mousedown",T)),c.dispatchEvent(new d("mouseup",T)),c.dispatchEvent(new d("click",T)),{success:!0,method:"svelte-click"}}catch{return{success:!1,method:"svelte-click"}}}function ke(c,E,y){let b=z(c,E),f=j(b,y);try{return f.jQuery?.(c)?.trigger?.("click"),{success:!0,method:"jquery-trigger"}}catch{return{success:!1,method:"jquery-trigger"}}}async function Ge(c,E,y,b,f=500){let d=Math.min(Math.max(0,Number(f)||500),3e4),g=z(c,E),T=j(g,y),L=q(c,b);We(c,g,T);let C=T.PointerEvent||PointerEvent,D=T.MouseEvent||MouseEvent,U=c.getBoundingClientRect(),G=U.left+U.width/2,X=U.top+U.height/2;if(L.fws.has("react")){let ne=Bt(c),ee=ne?Tt(ne):{};ee.onMouseEnter?.(qt("mouseenter",c,g,T)),ee.onPointerEnter?.(qt("pointerenter",c,g,T))}else if(L.fws.has("vue")){let ne=Cn(c),ee=ne?Vn(ne):{};ee.mouseenter?.(new D("mouseenter",{bubbles:!0})),ee.mouseover?.(new D("mouseover",{bubbles:!0}))}let oe={bubbles:!0,cancelable:!0,composed:!0,view:T,clientX:G,clientY:X};return[new C("pointerover",oe),new C("pointerenter",{...oe,bubbles:!1}),new D("mouseover",oe),new D("mouseenter",{...oe,bubbles:!1})].forEach(ne=>c.dispatchEvent(ne)),await pt(d,g),{success:!0,method:"hover-seq"}}async function ve(c,E,y=1){await Promise.resolve();for(let b=0;b<y;b++)c.hidden?await dt():await new Promise(f=>{try{E.requestAnimationFrame(()=>f())}catch{dt().then(f)}})}let Me=c=>String(c??"").replace(/\s+/g," ").trim();function ze(c){try{if("value"in c)return String(c.value??"")}catch{}return""}function Ye(c){try{return typeof pr=="function"?pr(c):Me(c.textContent)}catch{return""}}function jt(c,E){if(!(E.isFrameworkElement||E.delegatedInput))return!1;let y=String(c??"").length;return y>0&&y<=140}async function nn(c,E,y,b,f){let d=q(c,f),g=z(c,E),T=j(g,y);if(We(c,g,T),Zt(c,T)||ln(c,T)){let C=jt(String(b??""),d),D=await Sc(c,g,T,b,{settleFrames:g.hidden?1:2,useKeyFallback:C,keyFallbackMaxLen:140});return{success:D.success,method:D.method,details:D.details,allowFallback:!D.success}}if(c.isContentEditable===!0||d.role==="textbox"&&!("value"in c)){let C=Ye(c),D=Ic(c,b,g,T);await ve(g,T,g.hidden?1:2);let U=Ye(c),G=!1;if(String(b??"").length>0&&U===C){G=!0;try{Nr(c,g,T),Cr(c,g,T,!0);try{g.execCommand?.("insertText",!1,String(b??""))}catch{}fr(c,String(b??""),"insertText")}catch{}await ve(g,T,g.hidden?1:2)}let X=Ye(c),oe=X!==C||!!String(b??"")&&X.includes(String(b??""));return{success:oe,method:D.method,details:`${D.details};beforeLen=${C.length};afterLen=${X.length};reverted=${U===C};fallback=${G}`,allowFallback:oe?void 0:!0}}return{success:!1,method:"type",details:"target not editable",allowFallback:!0}}async function Dt(c,E,y,b,f){let d=z(c,E),g=j(d,y),T=await nn(c,d,g,b,f);if(!T.success)return T;let L=Ac(c);return{success:!0,method:"type+enter",details:`${T.details};enter=${L.method}`}}async function Ot(c,E,y,b){let f=z(c,E),d=j(f,y),g=d.Event||Event;if(We(c,f,d),Zt(c,d)||ln(c,d)){let L=ze(c),C=Cc(c,f,d);if(await ve(f,d,f.hidden?1:2),ze(c)===L&&L.length>0){try{io(c,""),fr(c,"","deleteByCut")}catch{}await ve(f,d,f.hidden?1:2)}let G=ze(c),X=G.length===0||G!==L;return{success:C.success,method:C.method,details:C.details,allowFallback:!C.success}}if(c.isContentEditable===!0||q(c,b).role==="textbox"&&!("value"in c)){let L=Nc(c,f,d);return await ve(f,d,f.hidden?1:2),{success:L.success,method:L.method,details:L.details,allowFallback:!L.success}}if("value"in c){try{c.value=""}catch{}return c.dispatchEvent(new g("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new g("change",{bubbles:!0,composed:!0})),{success:!0,method:"clear-generic-value"}}return{success:!1,method:"clear",details:"target not clearable",allowFallback:!0}}function mt(c,E,y){try{let b=z(c,E),f=j(b,y),d=f.FocusEvent||FocusEvent;return We(c,b,f),c.focus?.({preventScroll:!0}),c.dispatchEvent(new d("focus",{bubbles:!0})),c.dispatchEvent(new d("focusin",{bubbles:!0})),{success:!0,method:"focus"}}catch(b){return{success:!1,method:"focus",details:b.message,allowFallback:!0}}}function Le(c,E,y,b,f){try{let d=z(c,E),g=j(d,y),T=g.Event||Event;if(!xa(c,g))return{success:!1,method:"select",details:"target not select",allowFallback:!0};We(c,d,g),c.focus?.({preventScroll:!0});let L=Array.from(c.options).find(G=>G.value===b||G.text.trim()===b.trim());if(!L)return{success:!1,method:"select",details:`Option not found: ${b}`,allowFallback:!0};L.selected=!0;let C=Object.getPrototypeOf(c),D=Object.getOwnPropertyDescriptor(C,"value");if(D?.set?D.set.call(c,L.value):c.value=L.value,c.dispatchEvent(new T("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new T("change",{bubbles:!0,composed:!0})),q(c,f).fws.has("react")){let G=Bt(c);if(G){let X=Tt(G);if(X.onChange){let oe=qt("change",c,d,g);oe.target.value=L.value,X.onChange(oe)}}}return{success:!0,method:"select"}}catch(d){return{success:!1,method:"select",details:d.message,allowFallback:!0}}}function Pt(c,E,y,b,f){try{let d=z(c,E),g=j(d,y),T=g.Event||Event;if(!Zt(c,g))return{success:!1,method:"slider",details:"target not input",allowFallback:!0};We(c,d,g),c.focus?.({preventScroll:!0});let L=Object.getPrototypeOf(c),C=Object.getOwnPropertyDescriptor(L,"value");if(C?.set?C.set.call(c,String(b)):c.value=String(b),c.dispatchEvent(new T("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new T("change",{bubbles:!0,composed:!0})),q(c,f).fws.has("react")){let U=Bt(c);if(U){let G=Tt(U);if(G.onChange){let X=qt("change",c,d,g);X.target.value=String(b),G.onChange(X)}}}return{success:!0,method:"slider"}}catch(d){return{success:!1,method:"slider",details:d.message,allowFallback:!0}}}function Wr(c,E,y){try{let b=c.checkValidity?.()??!0;return b||c.reportValidity?.(),{success:b,method:"check-validity",details:b?void 0:c.validationMessage}}catch(b){return{success:!1,method:"check-validity",details:b.message,allowFallback:!0}}}function xn(c,E,y,b,f){try{let d=z(c,E),g=j(d,y);if("setSelectionRange"in c){let C=c;C.focus?.();let D=C.value?.length??0;return C.setSelectionRange(b??0,f??D),{success:!0,method:"select-range"}}let T=g.getSelection();if(!T)return{success:!1,method:"select-range",allowFallback:!0};let L=d.createRange();return L.selectNodeContents(c),T.removeAllRanges(),T.addRange(L),{success:!0,method:"select-range-node"}}catch(d){return{success:!1,method:"select-range",details:d.message,allowFallback:!0}}}function vt(c,E,y,b,f){let d=hr((c&&z(c))??E),g=c||d,T=z(g,E),L=j(T,y),C=g===T.documentElement||g===T.body||g===d;if(b===Ve.TOP||b===Ve.BOTTOM){let D=g.scrollHeight,U=C?L.innerHeight:g.clientHeight,G=Math.max(0,D-U);return g.scrollTop=b===Ve.TOP?0:G,{success:!0,scrollTop:g.scrollTop}}return ti(g,T,L,b,f)}async function qn(c,E,y,b){let f=b.direction,d=b.amount,g=z(c,E),T=j(g,y),L=!g.hidden,C=L?"smooth":"auto";try{if(c){let U=ot(c,g,T),G=vt(U,g,T,f,d);return G?.success?{success:!0,method:"direct-element-scroll",details:JSON.stringify(G)}:{success:!1,method:"direct-element-scroll",details:G?.error||"direct scroll failed",allowFallback:!0}}if(f===Ve.TOP||f===Ve.BOTTOM){let U=await B(T,{action:"scrollTo",direction:f,options:{behavior:C,isTabActive:L}},{doc:g,timeoutMs:g.hidden?5200:2800});return{success:!0,method:"detector-scrollTo",details:JSON.stringify(U)}}let D=await B(T,{action:"scrollBy",direction:f,options:{amount:d,behavior:C,isTabActive:L}},{doc:g,timeoutMs:g.hidden?5200:2800});return{success:!0,method:"detector-scrollBy",details:JSON.stringify(D)}}catch(D){let U=g?vt(hr(g),g,T,f,d):void 0;return U?.success?{success:!0,method:"direct-primary-scroll-fallback",details:JSON.stringify(U)}:{success:!1,method:"scroll-page-failed",details:D?.message||U?.error||"scroll_page failed",allowFallback:!0}}}async function je(c,E,y,b){let f=z(c,E),d=j(f,y),g=!f.hidden,T=g?"smooth":"auto",L=Wc(b.position),C=Or(c,f);if(!C){let D=Rs(c,f,d,L);return{success:D.success,method:"direct-scrollElement-no-selector",details:D.error,allowFallback:!D.success}}try{let D=await B(d,{action:"scrollElement",selector:C,position:L,options:{behavior:T,isTabActive:g}},{doc:f,timeoutMs:f.hidden?5600:3e3});return{success:!0,method:"detector-scrollElement",details:JSON.stringify(D)}}catch(D){let U=Rs(c,f,d,L);return U.success?{success:!0,method:"direct-scrollElement-fallback",details:JSON.stringify(U)}:{success:!1,method:"scroll-to-element-failed",details:D?.message||U.error||"scroll_to_element failed",allowFallback:!0}}}function rt(c,E,y,b,f){try{let d=z(c,E),g=j(d,y),T=g.WheelEvent||WheelEvent;We(c,d,g);let L=ot(c,d,g);return L.dispatchEvent(new T("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:g,deltaX:b||0,deltaY:f||0,deltaMode:T.DOM_DELTA_PIXEL})),L.scrollBy({left:b||0,top:f||0,behavior:"auto"}),{success:!0,method:"wheel"}}catch(d){return{success:!1,method:"wheel",details:d.message,allowFallback:!0}}}function ot(c,E,y){let b=z(c,E),f=j(b,y),d=b.scrollingElement||b.documentElement||b.body,g=c;for(;g&&g!==b.body&&g!==b.documentElement;){let L=f.getComputedStyle(g).overflowY;if((L==="auto"||L==="scroll"||L==="overlay")&&g.scrollHeight>g.clientHeight+5)return g;g=g.parentElement}return d}async function Ht(c,E,y,b,f){try{let d=z(c,E),g=j(d,y),T=g.PointerEvent||PointerEvent,L=g.MouseEvent||MouseEvent,C=g.DragEvent||DragEvent,D=g.DataTransfer||DataTransfer;We(c,d,g);let U=me(c,d,g),G=tt(U.hit,g)?U.hit:c,X=c.getBoundingClientRect(),oe=Number.isFinite(Number(b?.distance))?Number(b.distance):160,we=0,ne=0;switch(String(b?.direction||"").toUpperCase()){case"UP":ne=-oe;break;case"DOWN":ne=oe;break;case"LEFT":we=-oe;break;case"RIGHT":we=oe;break;default:we=Number(b?.delta_x)||0,ne=Number(b?.delta_y)||0}let ee=(k,O)=>({x:Math.max(2,Math.min(k,g.innerWidth-3)),y:Math.max(2,Math.min(O,g.innerHeight-3))}),ce=ee(U.x,U.y),ge=ee(U.x+we,U.y+ne),Xe=500+Date.now()%1e4,he=Math.max(12,Math.min(36,Number(b?.steps)||18)),Te=(k,O)=>({bubbles:!0,cancelable:!0,composed:!0,view:g,clientX:k,clientY:O,pageX:k+(g.scrollX||0),pageY:O+(g.scrollY||0)}),_e=(k,O,V)=>({...Te(k,O),pointerId:Xe,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:V?.5:0,buttons:V,button:0}),l=(k,O,V)=>({...Te(k,O),buttons:V,button:0});G.dispatchEvent(new T("pointerdown",_e(ce.x,ce.y,1))),G.dispatchEvent(new L("mousedown",l(ce.x,ce.y,1)));try{G.setPointerCapture?.(Xe)}catch{}let w=null;try{(c.draggable||q(c,f).sourcesByType.has("dragstart"))&&(w=new D)}catch{w=null}if(w)try{c.dispatchEvent(new C("dragstart",{bubbles:!0,cancelable:!0,clientX:ce.x,clientY:ce.y,dataTransfer:w}))}catch{}let R=null;for(let k=1;k<=he;k++){let O=ce.x+(ge.x-ce.x)*k/he,V=ce.y+(ge.y-ce.y)*k/he,K=d.elementFromPoint(O,V)||c;if(K.dispatchEvent(new T("pointermove",_e(O,V,1))),K.dispatchEvent(new L("mousemove",l(O,V,1))),w)try{R&&R!==K&&R.dispatchEvent(new C("dragleave",{bubbles:!0,cancelable:!0,clientX:O,clientY:V,dataTransfer:w})),K.dispatchEvent(new C("dragover",{bubbles:!0,cancelable:!0,clientX:O,clientY:V,dataTransfer:w})),R=K}catch{}k%3===0&&await dt()}let _=d.elementFromPoint(ge.x,ge.y)||c;if(_.dispatchEvent(new T("pointerup",_e(ge.x,ge.y,0))),_.dispatchEvent(new L("mouseup",l(ge.x,ge.y,0))),w)try{c.dispatchEvent(new C("dragend",{bubbles:!0,cancelable:!0,clientX:ge.x,clientY:ge.y,dataTransfer:w}))}catch{}return{success:!0,method:"drag",details:`dx=${we};dy=${ne};steps=${he};hitOk=${U.ok}`}}catch(d){return{success:!1,method:"drag",details:d?.message||"drag failed",allowFallback:!0}}}async function Xt(c,E,y,b){try{let f=z(E,y),d=j(f,b),g=d.PointerEvent||PointerEvent,T=d.MouseEvent||MouseEvent,L=d.DragEvent||DragEvent,C=d.DataTransfer||DataTransfer,D=c?.source_element_id??c?.element_id,U=(D?fn(f,String(D)):null)||E;if(!U)return{success:!1,method:"drag-drop",details:"source missing",allowFallback:!0};let G=null,X=Number(c?.target_x),oe=Number(c?.target_y);if(c?.target_element_id){if(G=fn(f,String(c.target_element_id)),!G)return{success:!1,method:"drag-drop",details:"target missing",allowFallback:!0};let _=G.getBoundingClientRect();X=_.left+_.width/2,oe=_.top+_.height/2}if((!Number.isFinite(X)||!Number.isFinite(oe))&&!G)return{success:!1,method:"drag-drop",details:"missing target coords",allowFallback:!0};We(U,f,d),G&&We(G,f,d);let we=(_,k)=>({x:Math.max(2,Math.min(_,d.innerWidth-3)),y:Math.max(2,Math.min(k,d.innerHeight-3))}),ne=U.getBoundingClientRect(),ee=we(ne.left+ne.width/2,ne.top+ne.height/2),ce=we(Number(X),Number(oe)),ge=600+Date.now()%1e4,Xe=Math.max(14,Math.min(42,Number(c?.steps)||22)),he=(_,k)=>({bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:_,clientY:k,pageX:_+(d.scrollX||0),pageY:k+(d.scrollY||0)}),Te=(_,k,O)=>({...he(_,k),pointerId:ge,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:O?.5:0,buttons:O,button:0}),_e=(_,k,O)=>({...he(_,k),buttons:O,button:0}),l=null;try{l=new C}catch{l=null}U.dispatchEvent(new g("pointerdown",Te(ee.x,ee.y,1))),U.dispatchEvent(new T("mousedown",_e(ee.x,ee.y,1)));try{U.setPointerCapture?.(ge)}catch{}if(l)try{U.dispatchEvent(new L("dragstart",{bubbles:!0,cancelable:!0,clientX:ee.x,clientY:ee.y,dataTransfer:l}))}catch{}let w=null;for(let _=1;_<=Xe;_++){let k=ee.x+(ce.x-ee.x)*_/Xe,O=ee.y+(ce.y-ee.y)*_/Xe,V=f.elementFromPoint(k,O)||G||f.body;if(V.dispatchEvent(new g("pointermove",Te(k,O,1))),V.dispatchEvent(new T("mousemove",_e(k,O,1))),l)try{w&&w!==V&&w.dispatchEvent(new L("dragleave",{bubbles:!0,cancelable:!0,clientX:k,clientY:O,dataTransfer:l})),V.dispatchEvent(new L("dragenter",{bubbles:!0,cancelable:!0,clientX:k,clientY:O,dataTransfer:l})),V.dispatchEvent(new L("dragover",{bubbles:!0,cancelable:!0,clientX:k,clientY:O,dataTransfer:l})),w=V}catch{}_%3===0&&await dt()}let R=G||f.elementFromPoint(ce.x,ce.y)||f.body;if(l)try{R.dispatchEvent(new L("drop",{bubbles:!0,cancelable:!0,clientX:ce.x,clientY:ce.y,dataTransfer:l}))}catch{}if(R.dispatchEvent(new g("pointerup",Te(ce.x,ce.y,0))),R.dispatchEvent(new T("mouseup",_e(ce.x,ce.y,0))),l)try{U.dispatchEvent(new L("dragend",{bubbles:!0,cancelable:!0,clientX:ce.x,clientY:ce.y,dataTransfer:l}))}catch{}return{success:!0,method:"html5+pointer-dragdrop",details:`steps=${Xe};source=${String(D)}`}}catch(f){return{success:!1,method:"drag-drop",details:f?.message||"drag-drop failed",allowFallback:!0}}}async function rn(c,E,y,b){try{let f=z(c,E),d=j(f,y),g=d.PointerEvent||PointerEvent,T=d.MouseEvent||MouseEvent;We(c,f,d);let L=me(c,f,d),C={x:L.x,y:L.y},D=c.getBoundingClientRect(),U=Number.isFinite(Number(b?.distance))?Number(b.distance):Math.min(Math.max(80,Math.min(D.width,D.height)),220),G=String(b?.direction||"RIGHT").toUpperCase(),X=C.x,oe=C.y;G==="LEFT"&&(X-=U),G==="RIGHT"&&(X+=U),G==="UP"&&(oe-=U),G==="DOWN"&&(oe+=U);let we=(k,O)=>({x:Math.max(2,Math.min(k,d.innerWidth-3)),y:Math.max(2,Math.min(O,d.innerHeight-3))}),ne=we(C.x,C.y),ee=we(X,oe),ce=700+Date.now()%1e4,ge=Math.max(10,Math.min(28,Number(b?.steps)||16)),Xe=(k,O)=>({bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:k,clientY:O,pageX:k+(d.scrollX||0),pageY:O+(d.scrollY||0)}),he=(k,O,V)=>({...Xe(k,O),pointerId:ce,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:V?.5:0,buttons:V,button:0}),Te=(k,O,V)=>({...Xe(k,O),buttons:V,button:0}),_e=f.elementFromPoint(ne.x,ne.y)||c;_e.dispatchEvent(new g("pointerdown",he(ne.x,ne.y,1))),_e.dispatchEvent(new T("mousedown",Te(ne.x,ne.y,1)));let l=d.Touch,w=d.TouchEvent,R=!!l&&!!w;if(R)try{let k=new l({identifier:ce,target:_e,clientX:ne.x,clientY:ne.y,pageX:ne.x,pageY:ne.y,screenX:ne.x,screenY:ne.y,radiusX:1,radiusY:1,rotationAngle:0,force:1});_e.dispatchEvent(new w("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[k],targetTouches:[k],changedTouches:[k]}))}catch{}for(let k=1;k<=ge;k++){let O=ne.x+(ee.x-ne.x)*k/ge,V=ne.y+(ee.y-ne.y)*k/ge,K=f.elementFromPoint(O,V)||c;if(K.dispatchEvent(new g("pointermove",he(O,V,1))),K.dispatchEvent(new T("mousemove",Te(O,V,1))),R)try{let fe=new l({identifier:ce,target:K,clientX:O,clientY:V,pageX:O,pageY:V,screenX:O,screenY:V,radiusX:1,radiusY:1,rotationAngle:0,force:1});K.dispatchEvent(new w("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[fe],targetTouches:[fe],changedTouches:[fe]}))}catch{}k%3===0&&await dt()}let _=f.elementFromPoint(ee.x,ee.y)||c;if(_.dispatchEvent(new g("pointerup",he(ee.x,ee.y,0))),_.dispatchEvent(new T("mouseup",Te(ee.x,ee.y,0))),R)try{let k=new l({identifier:ce,target:_,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});_.dispatchEvent(new w("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[k]}))}catch{}return{success:!0,method:"swipe",details:`dir=${G};dist=${U};steps=${ge};hitOk=${L.ok}`}}catch(f){return{success:!1,method:"swipe",details:f?.message||"swipe failed",allowFallback:!0}}}async function qe(c,E,y,b){try{let f=c||E.body,d=z(f,E),g=j(d,y),T=g.PointerEvent||PointerEvent,L=g.WheelEvent||WheelEvent;We(f,d,g);let C=Number.isFinite(Number(b?.scale))?Number(b.scale):1.2,D=f.getBoundingClientRect(),U=D.left+D.width/2,G=D.top+D.height/2,X=24,oe=Math.max(6,Math.min(200,X*C)),we=Math.max(6,Math.min(18,Number(b?.steps)||10)),ne=g.Touch,ee=g.TouchEvent;if(!!ne&&!!ee)try{let he=(R,_)=>new ne({identifier:R,target:f,clientX:_,clientY:G,pageX:_,pageY:G,screenX:_,screenY:G,radiusX:1,radiusY:1,rotationAngle:0,force:1}),Te=he(911,U-X),_e=he(912,U+X);f.dispatchEvent(new ee("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[Te,_e],targetTouches:[Te,_e],changedTouches:[Te,_e]}));for(let R=1;R<=we;R++){let _=X+(oe-X)*R/we,k=he(911,U-_),O=he(912,U+_);f.dispatchEvent(new ee("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[k,O],targetTouches:[k,O],changedTouches:[k,O]})),R%2===0&&await dt()}let l=he(911,U-oe),w=he(912,U+oe);f.dispatchEvent(new ee("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[l,w]}))}catch{}try{let he=(Te,_e,l)=>({bubbles:!0,cancelable:!0,composed:!0,view:g,clientX:_e,clientY:G,pointerId:Te,pointerType:"touch",isPrimary:Te===821,width:1,height:1,pressure:l?.5:0,buttons:l,button:0});f.dispatchEvent(new T("pointerdown",he(821,U-X,1))),f.dispatchEvent(new T("pointerdown",he(822,U+X,1)));for(let Te=1;Te<=we;Te++){let _e=X+(oe-X)*Te/we;f.dispatchEvent(new T("pointermove",he(821,U-_e,1))),f.dispatchEvent(new T("pointermove",he(822,U+_e,1))),Te%2===0&&await dt()}f.dispatchEvent(new T("pointerup",he(821,U-oe,0))),f.dispatchEvent(new T("pointerup",he(822,U+oe,0)))}catch{}try{let ge=C>=1?-120:120;f.dispatchEvent(new L("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:g,clientX:U,clientY:G,ctrlKey:!0,deltaY:ge,deltaMode:L.DOM_DELTA_PIXEL}))}catch{}return{success:!0,method:"pinch-zoom",details:`scale=${C};steps=${we}`}}catch(f){return{success:!1,method:"pinch-zoom",details:f?.message||"pinch-zoom failed",allowFallback:!0}}}async function Rn(c,E,y,b=800){try{let f=z(c,E),d=j(f,y),g=d.PointerEvent||PointerEvent,T=d.MouseEvent||MouseEvent,L=d.FocusEvent||FocusEvent;We(c,f,d);let C=me(c,f,d),D=c;!C.ok&&tt(C.hit,d)?D=C.hit.closest?.('a,button,input,select,textarea,summary,[role="button"],[role="link"],[onclick]')||C.hit:tt(C.hit,d)&&(D=C.hit);let U=Ue(D,f,d),G=C.x,X=C.y,oe=1+Date.now()%1e4,we={bubbles:!0,cancelable:!0,composed:!0,view:d,clientX:G,clientY:X,pageX:G+(d.scrollX||0),pageY:X+(d.scrollY||0),screenX:G+(d.screenX||0),screenY:X+(d.screenY||0)},ne={...we,pointerId:oe,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:0,buttons:0,button:0};try{D.dispatchEvent(new g("pointerover",ne)),D.dispatchEvent(new g("pointerenter",{...ne,bubbles:!1}))}catch{}try{D.dispatchEvent(new T("mouseover",we)),D.dispatchEvent(new T("mouseenter",{...we,bubbles:!1}))}catch{}try{D.focus?.({preventScroll:!0}),D.dispatchEvent(new L("focus",{bubbles:!0,composed:!0})),D.dispatchEvent(new L("focusin",{bubbles:!0,composed:!0}))}catch{}try{D.dispatchEvent(new g("pointerdown",{...ne,buttons:1,pressure:.5}))}catch{}try{D.dispatchEvent(new T("mousedown",{...we,buttons:1,button:0}))}catch{}try{let he=d.Touch,Te=d.TouchEvent;if(typeof he<"u"&&typeof Te<"u"){let _e=new he({identifier:oe,target:D,clientX:G,clientY:X,pageX:G+(d.scrollX||0),pageY:X+(d.scrollY||0),screenX:G+(d.screenX||0),screenY:X+(d.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:1});D.dispatchEvent(new Te("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[_e],targetTouches:[_e],changedTouches:[_e]}))}}catch{}let ee=Number(b),ce=Number.isFinite(ee)&&ee>0?ee:800,ge=f.hidden?Math.max(ce,1200):ce;await pt(ge,f);try{D.dispatchEvent(new T("contextmenu",{...we,button:2,buttons:2}))}catch{}try{D.dispatchEvent(new g("pointerup",{...ne,buttons:0,pressure:0}))}catch{}try{D.dispatchEvent(new T("mouseup",{...we,buttons:0,button:0}))}catch{}try{let he=d.Touch,Te=d.TouchEvent;if(typeof he<"u"&&typeof Te<"u"){let _e=new he({identifier:oe,target:D,clientX:G,clientY:X,pageX:G+(d.scrollX||0),pageY:X+(d.scrollY||0),screenX:G+(d.screenX||0),screenY:X+(d.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:0});D.dispatchEvent(new Te("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[_e]}))}}catch{}let Xe=await ut(D,f,d,U);return{success:!0,method:"long-press",details:`holdMs=${ge};verified=${Xe};hitOk=${C.ok};target=${D.tagName.toLowerCase()}`}}catch(f){return{success:!1,method:"long-press",details:f?.message||"long-press failed",allowFallback:!0}}}function Ut(c,E,y,b,f){try{let d=z(y,b),T=j(d,f).KeyboardEvent||KeyboardEvent,L=y||d.activeElement||d.body||d.documentElement;L.focus?.();let C={key:c,code:sn(c),bubbles:!0,cancelable:!0,ctrlKey:E?.includes("CTRL"),altKey:E?.includes("ALT"),shiftKey:E?.includes("SHIFT"),metaKey:E?.includes("META")},D=L.dispatchEvent(new T("keydown",C)),U=L.dispatchEvent(new T("keypress",C)),G=L.dispatchEvent(new T("keyup",C));if(c==="Enter"&&!!(D&&U&&G)){let oe=L.form||L.closest?.("form");oe?.requestSubmit?oe.requestSubmit():oe?.submit?.()}return{success:!0,method:"press-key"}}catch(d){return{success:!1,method:"press-key",details:d.message,allowFallback:!0}}}async function kn(c,E,y){try{let b=c.innerText||c.value||"";if(!b)return{success:!1,method:"copy",details:"nothing to copy",allowFallback:!0};let f=z(c,E),d=j(f,y);if(d.navigator?.clipboard?.writeText)return await d.navigator.clipboard.writeText(b),{success:!0,method:"clipboard-copy"};let g=f.createRange();g.selectNodeContents(c);let T=d.getSelection?.()||(f.defaultView||window).getSelection?.();T?.removeAllRanges(),T?.addRange(g);let L=f.execCommand?.("copy")??!1;return T?.removeAllRanges(),{success:!!L,method:"execCommand-copy",allowFallback:!L}}catch(b){return{success:!1,method:"clipboard-copy",details:b.message,allowFallback:!0}}}async function Ft(c,E,y,b){try{c.focus?.();let f=z(c,E),d=j(f,y);if(d.navigator?.clipboard?.readText){let T=await d.navigator.clipboard.readText();if(T)return await nn(c,f,d,T,b)}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 Sn(c){return`${(c/1024).toFixed(1)}KB`}function nr(c,E){if(c instanceof E.defaultView.HTMLInputElement){let g=c;if((g.type||"").toLowerCase()==="file")return g}let y=c.closest?.("label"),b=y?.htmlFor||c.htmlFor||"";if(b){let g=E.getElementById(b);if(g&&(g.type||"").toLowerCase()==="file")return g}if(y){let g=y.querySelector?.('input[type="file"]');if(g)return g}let f=c.closest?.("form");if(f){let g=f.querySelector?.('input[type="file"]');if(g)return g}let d=c.closest?.("div,section,main,article")||c.parentElement;if(d){let g=d.querySelector?.('input[type="file"]');if(g)return g}return null}function mn(c,E,y){try{let b=y.HTMLInputElement?.prototype,f=b?Object.getOwnPropertyDescriptor(b,"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,E),!0):(c.files=E,!0)}catch{try{return c.files=E,!0}catch{return!1}}}async function Kt(c,E,y,b,f,d){try{let{file_url:g,element_id:T,file_name:L}=c,C=null;if(f&&(C=nr(f,E)),!C&&T!==void 0&&(C=E.querySelector(`input[type="file"][${_t}*="[id=${T}]"]`)),!C){let _=E.querySelectorAll('input[type="file"]');for(let k of _){if(k.disabled)continue;let O=k.getBoundingClientRect();if(O.width>0&&O.height>0){C=k;break}}}if(!C)return{success:!1,method:"upload-file",details:"No file input found",allowFallback:!0};if(C.disabled)return{success:!1,method:"upload-file",details:"File input is disabled",allowFallback:!0};let D=z(C,E),U=j(D,y);if(!(b?.kind==="upload_file"&&typeof b.byteLength=="number"&&b.byteLength>=0&&typeof b.mimeType=="string"&&(typeof b.inlineB64=="string"||typeof b.token=="string")))return{success:!1,method:"upload-file",details:"Missing upload payload (need inlineB64 or token)",allowFallback:!0};let X=Number(b.byteLength),oe=(b.mimeType||"application/octet-stream").split(";")[0].trim()||"application/octet-stream",we;if(b.inlineB64&&typeof b.inlineB64=="string"){let _=Bc(b.inlineB64);if(_.byteLength!==X)return{success:!1,method:"upload-file",details:`Inline bytes length mismatch: got=${_.byteLength} expected=${X}`,allowFallback:!0};we=_.buffer}else{let _=String(b.token);we=await A(U,_,X,9e4)}let ne=U.Blob||Blob,ee=new ne([we],{type:oe}),ce=L||b?.fileName;!ce&&g&&typeof g=="string"&&(ce=_s(g,U)),ce=Fc(ce||"upload");let ge=U.File||File,Xe=new ge([ee],ce,{type:oe,lastModified:Date.now()}),he=U.Event||Event,Te=U.DataTransfer||DataTransfer;if(!Te)return{success:!1,method:"upload-file",details:"DataTransfer unavailable in this context",allowFallback:!0};let _e=new Te;if(_e.items.add(Xe),!mn(C,_e.files,U))return{success:!1,method:"upload-file",details:"Failed to set input.files",allowFallback:!0};C.dispatchEvent(new he("input",{bubbles:!0,composed:!0,cancelable:!0})),C.dispatchEvent(new he("change",{bubbles:!0,composed:!0,cancelable:!0}));let w=Bt(C);if(w){let _=Tt(w);if(_.onChange){let k=qt("change",C,D,U);k.target.files=_e.files,_.onChange(k)}}let R=Cn(C);if(R){let _=Vn(R);if(_.change){let k=new he("change",{bubbles:!0});k.target=C,k.target.files=_e.files,_.change(k)}}try{let _=U.jQuery||U.$;_&&typeof _=="function"&&_(C).triggerHandler?.("change")}catch{}return C.focus?.({preventScroll:!0}),await ve(D,U,2),{success:!0,method:"upload-file",details:`Uploaded ${ce} (${Sn(ee.size)}) [token]`}}catch(g){return{success:!1,method:"upload-file",details:g?.message||"Upload failed",allowFallback:!0}}}async function on(c,E,y){let b=Array.isArray(c.path)?c.path:[];if(!b.length)return{success:!1,method:"dispatch_pointer_path",details:"Empty path",allowFallback:!0};let f=y.PointerEvent||PointerEvent,d=y.MouseEvent||MouseEvent,g=16;for(let T=0;T<b.length;T++){let L=b[T],C=Number(L.x)||0,D=Number(L.y)||0,U=Number(L.pressure)||(T===0||T===b.length-1?0:.5),G=E.elementFromPoint(C,D)||E.documentElement,X={bubbles:!0,cancelable:!0,clientX:C,clientY:D,screenX:C,screenY:D,view:y};if(T===0?(G.dispatchEvent(new f("pointerdown",{...X,pressure:U,pointerId:1,pointerType:"mouse"})),G.dispatchEvent(new d("mousedown",{...X,button:0,buttons:1}))):(G.dispatchEvent(new f("pointermove",{...X,pressure:U,pointerId:1,pointerType:"mouse"})),G.dispatchEvent(new d("mousemove",{...X,button:0,buttons:1}))),T===b.length-1&&(G.dispatchEvent(new f("pointerup",{...X,pressure:0,pointerId:1,pointerType:"mouse"})),G.dispatchEvent(new d("mouseup",{...X,button:0,buttons:0}))),T<b.length-1){let oe=Number(L.timestamp)||0,we=Number(b[T+1].timestamp)||0,ne=oe&&we?Math.max(0,Math.min(we-oe,1e3)):g;ne>0&&await pt(ne,E)}}return{success:!0,method:"dispatch_pointer_path",details:`Dispatched ${b.length} point(s)`}}function gn(c,E,y){let b=z(c,E),f=j(b,y),d=f.MouseEvent||MouseEvent;We(c,b,f),ae(c,b,f),ae(c,b,f);let g=c.getBoundingClientRect();return c.dispatchEvent(new d("dblclick",{bubbles:!0,cancelable:!0,clientX:g.left+g.width/2,clientY:g.top+g.height/2,detail:2,view:f})),{success:!0,method:"dblclick"}}function ye(c,E,y){let b=z(c,E),f=j(b,y),d=f.PointerEvent||PointerEvent,g=f.MouseEvent||MouseEvent;We(c,b,f);let T=c.getBoundingClientRect(),L=T.left+T.width/2,C=T.top+T.height/2,D={bubbles:!0,cancelable:!0,composed:!0,view:f,clientX:L,clientY:C,button:2,buttons:2};return c.dispatchEvent(new d("pointerdown",D)),c.dispatchEvent(new g("mousedown",D)),c.dispatchEvent(new d("pointerup",{...D,buttons:0})),c.dispatchEvent(new g("mouseup",{...D,buttons:0})),c.dispatchEvent(new g("contextmenu",D)),{success:!0,method:"contextmenu"}}function Ue(c,E,y){let b=z(c,E),f=j(b,y),d=c,g=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:Qo(b),rect:{w:g.width,h:g.height}}}function bn(c,E){let y=Math.abs(c.rect.w-E.rect.w)>2||Math.abs(c.rect.h-E.rect.h)>2;return c.href!==E.href||c.hash!==E.hash||c.ariaExpanded!==E.ariaExpanded||c.ariaPressed!==E.ariaPressed||c.ariaDisabled!==E.ariaDisabled||c.disabled!==E.disabled||c.open!==E.open||c.checked!==E.checked||c.value!==E.value||c.active!==E.active||y}async function ut(c,E,y,b){await Promise.resolve();let f=z(c,E),d=j(f,y);E.hidden||await dt();let g=Ue(c,f,d);return bn(b,g)}function $n(c,E,y){c.focus?.({preventScroll:!0});let b=z(c,E),f=j(b,y),T=c.getAttribute("role")==="button"||ka(c,f)||c.tagName.toLowerCase()==="button"?[" ","Enter"]:["Enter"],L=f.KeyboardEvent||KeyboardEvent;for(let C of T){let D={key:C,code:C===" "?"Space":"Enter",bubbles:!0,cancelable:!0,composed:!0};c.dispatchEvent(new L("keydown",D)),c.dispatchEvent(new L("keypress",D)),c.dispatchEvent(new L("keyup",D))}return{success:!0,method:"keyboard-activate"}}async function vr(c,E,y,...b){let f=null;for(let d of b){let g=z(c,E),T=j(g,y),L=Ue(c,g,T),C=d();if(!C||!C.success)continue;if(await ut(c,g,T,L))return{...C,details:(C.details?C.details+";":"")+"verified=true"};f=C}return f?{...f,details:(f.details?f.details+";":"")+"verified=false"}:{success:!1,method:"all-strategies-unverified",details:"no verified effect",allowFallback:!0}}function Wn(...c){for(let E of c)try{let y=E();if(y&&y.success)return y}catch{}return{success:!1,method:"all-strategies-failed",allowFallback:!0}}function We(c,E,y){let b=z(c,E),f=j(b,y),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 Tr(c,E,y,b){let f=z(c,E),g=j(f,y).KeyboardEvent||KeyboardEvent;for(let T of b){let L=String(T??""),C="";/^[a-z]$/i.test(L)?C=`Key${L.toUpperCase()}`:/^[0-9]$/.test(L)?C=`Digit${L}`:L===" "&&(C="Space");let D=L.length===1?L.charCodeAt(0):0,U={key:L,code:C,bubbles:!0,cancelable:!0,composed:!0,keyCode:D,which:D};c.dispatchEvent(new g("keydown",U)),c.dispatchEvent(new g("keypress",U)),c.dispatchEvent(new g("keyup",U))}}function _r(c,E,y){let b=z(c,E),d=j(b,y).KeyboardEvent||KeyboardEvent,g={key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0,composed:!0},T=c.dispatchEvent(new d("keydown",g)),L=c.dispatchEvent(new d("keypress",g)),C=c.dispatchEvent(new d("keyup",g));if(!!(T&&L&&C)){let U=c.form||c.closest?.("form");U?.requestSubmit?.()??U?.submit?.()}}function sn(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 In=new MessageChannel,an=[];In.port1.onmessage=()=>{let c=an.shift();c&&c()};function dt(){return new Promise(c=>{an.push(c),In.port2.postMessage(0)})}function Bt(c){let E=b=>{if(!b)return null;let f=Object.keys(b);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 b[d];return null},y=c;for(let b=0;b<4&&y;b++){let f=E(y);if(f)return f;y=y.parentElement}return null}function Tt(c){let E={},y=c,b=0;for(;y&&b++<10;){let f=[y.memoizedProps,y.pendingProps,y.stateNode?.props,y._memoizedProps,y._pendingProps,y.alternate?.memoizedProps].filter(Boolean);for(let d of f)if(!(!d||typeof d!="object"))for(let g in d)g.startsWith("on")&&typeof d[g]=="function"&&(E[g]=d[g]);if(Object.keys(E).length)break;y=y.return||y.alternate}return E}function An(c,E){let y=c;for(;y;){if(y._reactRootContainer||y.__reactContainer||y.hasAttribute("data-reactroot")||y.hasAttribute("data-react-root")||["root","app","__next"].includes(y.id))return y;y=y.parentElement}return z(c,E).querySelector("#root,#app,#__next,[data-reactroot],[data-react-root]")}function qt(c,E,y,b){let f=z(E,y),d=j(f,b),g=d.MouseEvent||MouseEvent,T=E.getBoundingClientRect(),L=new g(c,{bubbles:!0,cancelable:!0,view:d,clientX:T.left+T.width/2,clientY:T.top+T.height/2});return{type:c,target:E,currentTarget:E,bubbles:!0,cancelable:!0,nativeEvent:L,isTrusted:!0,preventDefault(){L.preventDefault()},stopPropagation(){L.stopPropagation()}}}function Cn(c){let E=c;if(E.__vue__)return E.__vue__;if(E.__vueParentComponent)return E.__vueParentComponent;if(E._vnode)return E._vnode;let y=c.parentElement;for(let b=0;b<3&&y;b++){let f=y;if(f.__vue__||f.__vueParentComponent||f._vnode)return f.__vue__||f.__vueParentComponent||f._vnode;y=y.parentElement}return null}function Vn(c){let E={};if(c?.$listeners&&Object.assign(E,c.$listeners),c?._events)for(let y in c._events){let b=c._events[y];E[y]=Array.isArray(b)?b[0]:b}if(c?.props)for(let y in c.props)y.startsWith("on")&&typeof c.props[y]=="function"&&(E[y.substring(2).toLowerCase()]=c.props[y]);if(c?.vnode?.props)for(let y in c.vnode.props)y.startsWith("on")&&typeof c.vnode.props[y]=="function"&&(E[y.substring(2).toLowerCase()]=c.vnode.props[y]);return E}})();function zc(){let e=window,t=e.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__";e[t]?.actions?.execute}async function Yc(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 ni(e,t,n={}){let{rootNodes:r,semanticNodes:o}=hs(e,{includeFrameContents:n.includeFrames??!0,clearIframes:n.includeFrames??!0,frameContextLabel:n.frameContextLabel??null,signalProvider:t.signalProvider,disableDomAnnotations:n.disableDomAnnotations??!0}),i={};for(let s of Object.keys(o)){let a=Number(s);if(!Number.isFinite(a))continue;let u=to(a);u&&(i[a]=t.getFrameworkMetadata(u))}return{rootNodes:r,semanticNodes:o,elementMeta:i}}(()=>{let e="__rtrvr_scroll_detector",t="__RTRVR_SCROLL_API__",n="__RTRVR_INTERNAL__";if(window[e])return;class r{constructor(p=document,v=window){W(this,"doc");W(this,"win");W(this,"viewport");W(this,"lastDetectedPrimary",null);W(this,"detectionCache",new Map);W(this,"lastDetectionTime",0);W(this,"CACHE_TTL",5e3);this.doc=p,this.win=v,this.viewport={width:v.innerWidth,height:v.innerHeight},this.updateViewport()}getValidPrimary(){return this.lastDetectedPrimary&&!this.doc.contains(this.lastDetectedPrimary)&&(this.lastDetectedPrimary=null),this.lastDetectedPrimary}async handleCommand(p){switch(p.action){case"detectPrimary":{let v=this.detectPrimaryScrollable();if(!v)return null;let{target:I,isRoot:A}=this.getScrollContext(v.element),x=I.scrollHeight,S=yn(),B=A&&S?S.innerHeight:I.clientHeight,Y=Math.max(0,x-B),F=I.scrollTop;return{selector:v.selector,score:v.score,type:v.type,metrics:{scrollTop:F,scrollHeight:x,clientHeight:B,isAtTop:F<=5,isAtBottom:F>=Y-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 A=Array.from(this.detectionCache.values()).sort((x,S)=>S.score-x.score)[0];if(A)return this.lastDetectedPrimary=A.element,A}this.updateViewport();let p=this.collectScrollableCandidates();if(p.length===0){let A=this.doc.scrollingElement||this.doc.documentElement||this.doc.body;if(!A)return null;let x=this.buildFeatures(A),S=z(A,this.doc),B={element:A,selector:Or(A,S),score:.5,features:x,type:"document"};return this.detectionCache.clear(),this.detectionCache.set(B.selector,B),this.lastDetectionTime=Date.now(),this.lastDetectedPrimary=A,B}let v=this.scoreCandidates(p);if(v.length===0)return null;this.detectionCache.clear();for(let A of v)this.detectionCache.set(A.selector,A);this.lastDetectionTime=Date.now();let I=v[0];return I&&(this.lastDetectedPrimary=I.element),I||null}collectAllElementsDeep(p,v=15e4){let I=[],A=[],x=p.body||p.documentElement;x&&A.push(x);let S=0,B=Y=>{try{let F=this.win.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",q=this.win[F]?.shadow?.getRoot;if(typeof q=="function"){let J=q(Y);if(J)return J}}catch{}try{return Y.shadowRoot||null}catch{return null}};for(;A.length&&!(++S>v);){let Y=A.pop();if(Gt(Y)){let q=Y.children;for(let J=q.length-1;J>=0;J--)A.push(q[J]);continue}let F=Y,P=de(F);tt(F,P)&&I.push(F);try{let q=B(F);q&&A.push(q)}catch{}for(let q=F.lastElementChild;q;q=q.previousElementSibling)A.push(q)}return I}collectScrollableCandidates(){let p=[],v=new WeakSet,I=[this.doc.scrollingElement,this.doc.documentElement,this.doc.body];for(let x of I){if(!x||v.has(x))continue;let S=this.isScrollable(x);(S.vertical||S.horizontal)&&(p.push(x),v.add(x))}let A=this.collectAllElementsDeep(this.doc);for(let x of Array.from(A)){if(v.has(x))continue;let S=x.getBoundingClientRect(),B=this.win.getComputedStyle(x);if(!this.isElementRendered(x,S,B)||!this.isScrollable(x).vertical)continue;let F=40,P=this.viewport.width*.15;if(S.height<F||S.width<P){let q=(x.className||"").toLowerCase().includes("scroll"),J=B.overflowY==="auto"||B.overflowY==="scroll"||B.overflow==="auto"||B.overflow==="scroll";if(!q&&!J)continue}p.push(x),v.add(x)}return p}isElementRendered(p,v,I){if(I.display==="none"||I.visibility==="hidden")return!1;let A=parseFloat(I.opacity||"1");return!(!Number.isNaN(A)&&A<.01||v.width<=1||v.height<=1)}isScrollable(p){let v=this.win.getComputedStyle(p),I=v.overflowY,A=v.overflowX,x=this.doc.scrollingElement,S=p===this.doc.documentElement||p===this.doc.body||!!x&&p===x,B=p.scrollHeight,Y=p.clientHeight,F=p.scrollWidth,P=p.clientWidth;if(S){let pe=this.doc.documentElement,Re=this.doc.body;B=Math.max(pe?pe.scrollHeight:0,Re?Re.scrollHeight:0),Y=this.win.innerHeight}let q=B-Y>8,J=F-P>8,ae=I==="auto"||I==="scroll"||I==="overlay",ue=A==="auto"||A==="scroll"||A==="overlay";return{vertical:S?q:q&&ae,horizontal:S?J:J&&ue,byOverflow:ae||ue}}calculateVisibleIntersection(p){let v=Math.max(0,p.left),I=Math.max(0,p.top),A=Math.min(this.viewport.width,p.right),x=Math.min(this.viewport.height,p.bottom),S=Math.max(0,A-v),B=Math.max(0,x-I);return{width:S,height:B,area:S*B}}analyzeTextContent(p,v=2e3){let I=0,A=0,x=p.ownerDocument||this.doc,B=(x.defaultView||this.win).NodeFilter||NodeFilter,Y=x.createTreeWalker(p,B.SHOW_ELEMENT|B.SHOW_TEXT,null),F=0,P=Y.currentNode,q=[];for(;P&&F<v;){if(P.nodeType===Node.TEXT_NODE){let se=(P.textContent||"").replace(/\s+/g,"").length;if(se>0){I+=se;let Ee=P.parentElement;Ee&&Ee.closest("a")&&(A+=se)}}else P.nodeType===Node.ELEMENT_NODE&&q.push(P);F++,P=Y.nextNode()}let J=q.length||1,ae=I/J,ue=I>0?A/I:0;return{textChars:I,linkChars:A,textDensity:ae,linkDensity:ue}}calculateRepetitionScore(p){let v=Array.from(p.children);if(v.length<3)return 0;let I=v.slice(0,50),A=new Map,x=new Map,S=new Map;for(let me of I){let se=de(me);if(!tt(me,se))continue;let Ee=me.getBoundingClientRect();if(Ee.height<5||Ee.width<this.viewport.width*.1)continue;let pe=Math.round(Ee.height/10)*10,Re=Math.round(Ee.width/10)*10;A.set(pe,(A.get(pe)||0)+1),x.set(Re,(x.get(Re)||0)+1);let ke=(me.className||me.tagName).toString();S.set(ke,(S.get(ke)||0)+1)}let B=I.length||1,Y=Math.max(0,...A.values()),F=Math.max(0,...x.values()),P=Math.max(0,...S.values()),q=Y/B,J=F/B,ae=P/B,ue=.4*q+.3*J+.3*ae;return Math.min(1,Math.max(0,ue))}calculateSemanticScore(p){let v=0,I=null,A=!1,x=(p.getAttribute("role")||"").toLowerCase(),S=p.tagName.toLowerCase(),B=(p.id||"").toLowerCase(),Y=(p.className||"").toLowerCase(),F=`${x} ${S} ${B} ${Y}`;return(S==="main"||x==="main")&&(v+=1.2,I="article"),S==="article"&&(v+=1,I=I||"article"),(x==="feed"||F.includes("feed"))&&(v+=1,I="feed"),(x==="log"||F.includes("chat")||F.includes("messages"))&&(v+=1,I="chat"),F.includes("content")&&(v+=.5),(F.includes("results")||F.includes("list"))&&(v+=.4),(F.includes("job")||F.includes("jobs"))&&(v+=.4),(S==="nav"||x==="navigation"||F.includes("sidebar"))&&(v-=1,A=!0),(S==="aside"||x==="complementary")&&(v-=.7,A=!0),(S==="footer"||x==="contentinfo"||F.includes("footer"))&&(v-=.8,A=!0),F.includes("header")&&(v-=.6),v=Math.max(-1,Math.min(1,v)),{semanticScore:v,typeHint:I,navLike:A}}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(I=>I!==null)}buildFeatures(p){let v=p.getBoundingClientRect(),I=this.win.getComputedStyle(p),A=this.calculateVisibleIntersection(v),x=this.viewport.width*this.viewport.height||1,S=A.area/x,B=this.viewport.width>0?A.width/this.viewport.width:0,Y=v.top+v.height/2,F=this.viewport.height/2||1,P=Math.min(1,Math.abs(Y-F)/F),q=this.isScrollable(p),J=this.doc.scrollingElement,ae=p===this.doc.documentElement||p===this.doc.body||!!J&&p===J,ue=p.scrollHeight,me=p.clientHeight;if(ae){let Ye=this.doc.documentElement,jt=this.doc.body;ue=Math.max(Ye?Ye.scrollHeight:0,jt?jt.scrollHeight:0),me=this.win.innerHeight}let se=Math.max(0,ue-me),Ee=se*A.width,pe=this.analyzeTextContent(p),Re=this.calculateRepetitionScore(p),ke=this.calculateSemanticScore(p),Ge=p.contains(this.doc.activeElement),ve=this.detectScrollListeners(p),Me=parseInt(I.zIndex||"0",10),ze=Number.isFinite(Me)?Me:0;return{geometry:{viewportCoverage:S,widthProminence:B,centerDistance:P,scrollCapacity:se,scrollSurface:Ee,zIndex:ze},content:{textDensity:pe.textDensity,linkDensity:pe.linkDensity,repetitionScore:Re,semanticScore:ke.semanticScore},interaction:{hasScrollListeners:ve,hasFocus:Ge,recentActivity:Ge?1:0}}}inferElementType(p,v,I,A){if(I)return I;let x=(p.getAttribute("role")||"").toLowerCase(),S=(p.className||"").toLowerCase(),B=p.tagName.toLowerCase(),Y=v.geometry,F=v.content;if(x==="log"||S.includes("chat")||S.includes("messages"))return"chat";let P=this.win.getComputedStyle(p);if((P.position==="fixed"||P.position==="absolute")&&Y.zIndex>100&&Y.viewportCoverage>.2&&Y.centerDistance<.4)return"modal";if(x==="feed"||F.repetitionScore>.3&&Y.scrollCapacity>400&&Y.widthProminence>=.25)return"feed";if(B==="article"||F.textDensity>40&&F.linkDensity<.4&&Y.widthProminence>.4)return"article";if(A||Y.widthProminence<.3&&F.linkDensity>.3)return"sidebar";let J=this.doc.scrollingElement;return p===this.doc.documentElement||p===this.doc.body||J&&p===J?"document":"unknown"}scoreCandidates(p){let v=[],I=[],A=[],x=[],S=[],B=[];for(let ae of p){let ue=this.buildFeatures(ae),me=ue.content.semanticScore,se=this.calculateSemanticScore(ae),Ee=this.inferElementType(ae,ue,se.typeHint,se.navLike);B.push({element:ae,features:{geometry:{...ue.geometry},content:{...ue.content,semanticScore:se.semanticScore},interaction:ue.interaction},type:Ee,navLike:se.navLike,semanticScore:se.semanticScore}),I.push(ue.geometry.scrollSurface),A.push(ue.content.textDensity),x.push(Math.abs(se.semanticScore)),S.push(ue.content.repetitionScore)}let Y=Math.max(0,...I),F=Math.max(0,...A),P=Math.max(0,...x),q=Math.max(0,...S),J=-1/0;for(let ae of B){let{element:ue,features:me,type:se,navLike:Ee,semanticScore:pe}=ae,Re=me.geometry,ke=me.content,Ge=me.interaction,ve=Y>0?Re.scrollSurface/Y:0,Me=F>0?ke.textDensity/F:0,ze=P>0?(pe/P+1)/2:.5,Ye=se==="feed"||ke.repetitionScore>.3&&Re.scrollCapacity>400,jt=ke.linkDensity>.5?(ke.linkDensity-.5)/.5:0,nn=Ye?0:jt,Dt=(Ye?1:.5)*ke.repetitionScore*Math.min(1,Re.scrollCapacity/4e3),mt={feed:.2,chat:.2,article:.08,modal:.08,document:.05,sidebar:-.12,unknown:0}[se]||0,Le=0;Le+=Re.viewportCoverage*.18,Le+=Re.widthProminence*.15,Le+=(1-Re.centerDistance)*.07,Le+=ve*.22,Le+=Dt*.18,Le+=Me*.08,Le+=(q>0?ke.repetitionScore/q:0)*.05,Le+=ze*.07,Le-=nn*.05,Ge.hasFocus&&(Le+=.05),Ge.hasScrollListeners&&(Le+=.05),Le+=mt,Ee&&(Le-=.05);let Pt=Math.max(0,Math.min(1,Le));Pt>J&&(J=Pt),v.push({element:ue,selector:Or(ue,z(ue)),score:Pt,features:me,type:se})}if(v.sort((ae,ue)=>ue.score-ae.score),v.length>=2){let ae=v[0],ue=v[1];Math.abs(ae.score-ue.score)<.08&&ae.type==="article"&&ue.type==="feed"&&(v[0]=ue,v[1]=ae)}return v}getScrollContext(p){let v=document.scrollingElement;return p===document.documentElement||p===document.body||!!v&&p===v?{target:v||document.documentElement||document.body,isRoot:!0}:{target:p,isRoot:!1}}async scrollToDirection(p,v){let I=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!I)return{success:!1,error:"No scrollable element found"};let{target:A,isRoot:x}=this.getScrollContext(I),S=z(A),B=j(S),Y=v?.isTabActive??!S.hidden,F=v?.behavior,P=Y&&F==="smooth",q=x?Math.max(S.documentElement?S.documentElement.scrollHeight:0,S.body?S.body.scrollHeight:0):A.scrollHeight,J=x?B.innerHeight:A.clientHeight,ae=Math.max(0,q-J),ue=()=>x?B.scrollY:A.scrollTop,me=se=>{if(P)try{x?B.scrollTo({top:se,behavior:"smooth"}):A.scrollTo({top:se,behavior:"smooth"})}catch{x?(S.scrollingElement||S.documentElement||S.body).scrollTop=se:A.scrollTop=se}else if(x){let Ee=S.scrollingElement||S.documentElement||S.body;Ee.scrollTop=se}else A.scrollTop=se};switch(p){case Ve.TOP:return me(0),{success:!0,scrollTop:0,isAtTop:!0};case Ve.BOTTOM:return me(ae),{success:!0,scrollTop:ae,isAtBottom:!0};default:return{success:!1,error:`Unknown direction: ${p}`}}}async scrollByAmount(p,v){let I=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!I)return{success:!1,error:"No scrollable element found"};let{target:A,isRoot:x}=this.getScrollContext(I),S=v?.isTabActive??!document.hidden,B=v?.behavior,Y=S&&B==="smooth",F=yn(),P=x&&F?F.innerHeight:A.clientHeight,q=x&&F?F.innerWidth:A.clientWidth,J=v?.amount??P*.8,ae=x?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):A.scrollHeight,ue=x&&F?F.innerHeight:A.clientHeight,me=Math.max(0,ae-ue),se=pe=>{if(Y)try{x?F?.scrollTo({top:pe,behavior:"smooth"}):A.scrollTo({top:pe,behavior:"smooth"})}catch{let Re=document.scrollingElement||document.documentElement||document.body;Re.scrollTop=pe}else{let Re=x?document.scrollingElement||document.documentElement||document.body:A;Re.scrollTop=pe}},Ee=pe=>{if(Y)try{A.scrollBy({left:pe,behavior:"smooth"})}catch{A.scrollLeft+=pe}else A.scrollLeft+=pe};switch(p){case Ve.DOWN:{let Re=(x&&F?F.scrollY:A.scrollTop)+J;se(Re);let ke=x&&F?F.scrollY:A.scrollTop;return{success:!0,scrollTop:ke,isAtTop:ke<=5,isAtBottom:ke>=me-5}}case Ve.UP:{let pe=x&&F?F.scrollY:A.scrollTop,Re=Math.max(0,pe-J);se(Re);let ke=x&&F?F.scrollY:A.scrollTop;return{success:!0,scrollTop:ke,isAtTop:ke<=5,isAtBottom:ke>=me-5}}case Ve.LEFT:{let pe=-(v?.amount??q*.8);return Ee(pe),{success:!0,scrollLeft:A.scrollLeft}}case Ve.RIGHT:{let pe=v?.amount??q*.8;return Ee(pe),{success:!0,scrollLeft:A.scrollLeft}}default:return{success:!1,error:`Unknown direction: ${p}`}}}normalizeScrollPosition(p){switch(p){case yt.START:return"start";case yt.END:return"end";case yt.NEAREST:return"nearest";case yt.CENTER:default:return"center"}}getScrollContainerForElement(p){let v=document.scrollingElement,I=p;for(;I&&I!==document.body&&I!==document.documentElement;){let S=getComputedStyle(I).overflowY,B=S==="auto"||S==="scroll"||S==="overlay",Y=I.scrollHeight-I.clientHeight>8;if(B&&Y)return{container:I,isRoot:!1};I=I.parentElement}return{container:v||document.documentElement||document.body,isRoot:!0}}scrollElementIntoView(p,v,I){let A=document.querySelector(p);if(!A)return{success:!1,error:`Element not found for selector: ${p}`};let{container:x,isRoot:S}=this.getScrollContainerForElement(A),B=de(x),Y=B?.DOMRect||DOMRect,F=S?new Y(0,0,B.innerWidth??0,B.innerHeight??0):x.getBoundingClientRect(),P=A.getBoundingClientRect(),q=24,J=P.top>=F.top+q&&P.bottom<=F.bottom-q,ae=I?.isTabActive??!document.hidden,ue=I?.behavior,me=ae&&ue==="smooth",se=this.normalizeScrollPosition(v);if(v===yt.NEAREST&&J)return{success:!0,alreadyVisible:!0,...this.getScrollMetricsForContainer(x,S)};try{A.scrollIntoView({behavior:me?"smooth":"auto",block:se,inline:"nearest"})}catch{A.scrollIntoView()}let Ee=this.getScrollMetricsForContainer(x,S);return{success:!0,position:se,...Ee}}getScrollMetricsForContainer(p,v){let I=v?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):p.scrollHeight,A=z(p),x=de(p),S=v&&x?x.innerHeight:p.clientHeight,B=Math.max(0,I-S),F=(v?A.scrollingElement||A.documentElement||A.body:p).scrollTop;return{scrollTop:F,scrollHeight:I,clientHeight:S,maxScroll:B,isAtTop:F<=5,isAtBottom:F>=B-5,scrollPercentage:B>0?F/B*100:0}}getScrollMetrics(){let p=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!p)return null;let{target:v,isRoot:I}=this.getScrollContext(p),A=z(v),x=j(A),S=I?Math.max(A.documentElement?A.documentElement.scrollHeight:0,A.body?A.body.scrollHeight:0):v.scrollHeight,B=I?x.innerHeight:v.clientHeight,Y=Math.max(0,S-B),P=(I?A.scrollingElement||A.documentElement||A.body:v).scrollTop;return{element:Or(v,A),scrollTop:P,scrollHeight:S,clientHeight:B,maxScroll:Y,isAtTop:P<=5,isAtBottom:P>=Y-5,scrollPercentage:Y>0?P/Y*100:0}}}let o=new r;window[e]=o;let i={execute:m=>o.execute(m)};try{Object.defineProperty(window,t,{value:i,writable:!1,configurable:!1,enumerable:!1})}catch{try{window[t]=i}catch{}}let s=window.__RTRVR_INTERNAL_KEY__||n,a=window[s],u=a&&typeof a=="object"?a:null;if(u){try{u.scroll=u.scroll||i}catch{}try{u.scroll||Object.defineProperty(u,"scroll",{value:i,writable:!1,configurable:!1,enumerable:!1})}catch{}}if(s!==n)try{!window[n]&&u&&Object.defineProperty(window,n,{value:u,writable:!1,configurable:!1,enumerable:!1})}catch{}})();var jd=/\[id=(\d+)\]/,nt;(function(e){e.HTML="html",e.PDF="pdf",e.GOOGLE_DOC="google_doc",e.GOOGLE_SHEET="google_sheet",e.PLAIN_TEXT="plain_text"})(nt||(nt={}));var jc=new Map;function Xd(e){let t={};for(let n of Object.keys(e)){let r=e[Number(n)],o=r?.preservedAttributes?.[Nt["rtrvr-label"]],i=r?.resourceLocator;if(typeof o=="string"&&typeof i=="string"){let s=o.match(jd);if(s?.[1]){let a=Number(s[1]);Number.isFinite(a)&&(t[a]=i)}}}return t}async function Zc(e,t,n={}){let r=e.ownerDocument||document,o=n.pageConfig||Zo,i=String(r.contentType||"").trim().toLowerCase(),s=Jd(i,r),a=Qd(s.documentType,i),u={url:r.URL,title:r.title,contentType:a},m=Kd(o);if(s.documentType!==nt.HTML){let S=Number(o?.pageDataTimeoutMs),B=Number.isFinite(S)?Math.max(200,Math.floor(S)):9e3,Y=Math.max(200,Math.min(B,en(m))),F=nf(r,s.documentType,o,m),P=await Dr(F,Y,r);if(!P.ok)return{...u,content:"",error:`non_html_timeout:${a}`,metadata:{extractionMethod:"timeout"}};let q=P.value||{},J=s.documentType===nt.GOOGLE_SHEET?Lf(r):void 0;return{...u,...q,contentType:q.contentType||u.contentType,sheetInfo:q.sheetInfo||J}}if(o?.onlyTextContent)return{...u,contentType:Lr,content:si(r)};let p=Math.max(0,Math.min(3e3,en(m))),v=performance.now(),I=!1;if(!o?.disableAutoScroll&&p>80){let S=r.hidden?900:1500,B=Math.min(S,p);B>80&&(I=await Af(r,{profile:"light",timeBudgetMs:B,delayMs:r.hidden?0:160,finalWaitMs:r.hidden?0:200}))}let A=Math.max(0,p-(performance.now()-v));A>80&&await Nf(r,{mode:"full",totalBudgetMs:Math.min(r.hidden?1400:1200,A),budgetMs:Math.min(r.hidden?650:850,A),maxPasses:r.hidden?1:2});let x=ni(e,t,{includeFrames:n.includeFrames??!0,disableDomAnnotations:n.disableDomAnnotations??!0});return sf(x.rootNodes,x.semanticNodes)?{...u,contentType:Lr,content:si(r),metadata:{scrollingPerformed:I}}:{...u,contentType:Lr,roots:x.rootNodes,nodes:x.semanticNodes,elementLinkRecord:Xd(x.semanticNodes),metadata:{scrollingPerformed:I}}}function Kd(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 Qd(e,t){switch(e){case nt.PDF:return bs;case nt.GOOGLE_DOC:return ws;case nt.GOOGLE_SHEET:return Es;case nt.PLAIN_TEXT:return ei;case nt.HTML:default:return t||Lr}}function Jd(e,t){let n=e||String(t.contentType||"").toLowerCase();return Hc(n)?{documentType:nt.PDF}:Zd(t)&&(tf(t)||ef(t.URL))?{documentType:nt.PDF}:hf(t)?{documentType:nt.GOOGLE_DOC}:mf(t)?{documentType:nt.GOOGLE_SHEET}:n.includes(ei)?{documentType:nt.PLAIN_TEXT}:{documentType:nt.HTML}}function Zd(e){try{let t=af(e);return vs(t)?!0:!!t.querySelector?.('object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]')}catch{return!1}}function ef(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 tf(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(i=>!["SCRIPT","STYLE"].includes(String(i.tagName).toUpperCase())).length<=3}catch{return!1}}async function nf(e,t,n,r){switch(t){case nt.PDF:return rf(e,n,r);case nt.GOOGLE_DOC:return of(e);case nt.GOOGLE_SHEET:return kf(e,n);case nt.PLAIN_TEXT:return{content:si(e),contentType:ei};case nt.HTML:default:return{content:si(e),contentType:Lr}}}async function rf(e,t,n){en(n)>gs+50&&await Uc(gs,e,n);let o=(()=>{let p=Number(t?.pdfTextSelectionTimeoutMs),v=Zo.pdfTextSelectionTimeoutMs;return Number.isFinite(p)?Math.max(150,Math.floor(p)):v})(),i=en(n),a=Number.isFinite(i)?Math.max(150,Math.min(o,Math.max(0,i-150))):o,u=await lf(e,a),m=!!u.success&&!!(u.data||"").trim();return{content:m&&u.data||"",contentType:bs,error:m?void 0:`pdf_extraction_failed:${u.reason||"unknown"}`}}async function of(e){return{content:Rf(),contentType:ws}}function sf(e,t){return!Array.isArray(e)||e.length===0||!t||Object.keys(t).length===0}function si(e){return e.body?.innerText||e.body?.textContent||e.documentElement?.innerText||e.documentElement?.textContent||""}function af(e){try{let t=e.defaultView||window,n=t.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",o=t[n]?.shadow?.getRoot;if(typeof o=="function"){let i=o(e.body||e.documentElement);if(i)return i}}catch{}return e}function cf(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 lf(e,t){let n=Number.isFinite(t)&&t>0?Math.floor(t):Zo.pdfTextSelectionTimeoutMs,r=cf(e),o=jc.get(r)??"";if(o.trim().length>0)return{success:!0,data:o,reason:"ok"};let i=await uf(e,n);return i.success&&i.data.trim()&&jc.set(r,i.data),i}async function uf(e,t){let n=e.defaultView||window,r=df(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)}`,i=!1,s="",a=p=>{if(i||!ff(String(p.origin||""),e))return;let v=p.data;pf(v,o)&&typeof v.selectedText=="string"&&v.selectedText.trim().length>0&&(s=v.selectedText,i=!0)};n.addEventListener("message",a);try{r.postMessage({type:"selectAll",requestId:o},"*")}catch{}let u=Date.now();for(;!i&&Date.now()-u<t;){try{r.postMessage({type:"getSelectedText",requestId:o},"*")}catch{}if(await pt(200,e),s.trim()){i=!0;break}}return n.removeEventListener("message",a),s.trim()?{success:!0,data:s,reason:"ok"}:{success:!1,data:"",reason:Date.now()-u>=t?"timeout":"no_response"}}function df(e){let t=vs(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 ff(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 pf(e,t){return!(!e||typeof e!="object"||e.type!=="getSelectedTextReply"||typeof e.selectedText!="string"||e.requestId&&e.requestId!==t)}function hf(e){try{let t=e.defaultView||yn();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 Pr(e)!==null}function mf(e){let n=(e.defaultView||yn())?.location.href??"";return/^https:\/\/docs\.google\.com\/spreadsheets\/(?:u\/\d+\/)?d\/[a-zA-Z0-9_-]+/.test(n)}function gf(e){try{return e.defaultView?.top?.document??e}catch{return e}}function ai(e){let t=[e],n=gf(e);return n!==e&&t.push(n),t}var bf=".docs-texteventtarget-iframe",Ef=".kix-cursor",yf=".docos-replyview-body",wf=".docos-replyview",vf=".docos-author",el="\u200B",Tf="\xA0";function Pr(e){for(let t of ai(e)){let n=t.querySelector(bf);if(n)return n}return null}function _f(e){for(let t of ai(e)){let n=t.querySelector(Ef);if(n)return n}return null}function ri(e){let t=_f(e);return t?(t.ownerDocument?.defaultView?.getComputedStyle(t).display??t.style.display)==="none":!1}function oi(e,t){let n=Pr(e);if(!n)return;let r=t?"ArrowUp":"ArrowDown",i={key:r,keyCode:t?38:40,altKey:!0,shiftKey:!0,code:r,bubbles:!0,cancelable:!0},s=n.contentDocument,a=n.contentWindow;if(!s)return;let u=a?.KeyboardEvent||KeyboardEvent;s.dispatchEvent(new u("keydown",i))}function Xc(e){let t=Pr(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 i=o?.KeyboardEvent||KeyboardEvent;r.dispatchEvent(new i("keydown",n))}function xf(e){let t=Pr(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},i=t.contentDocument,s=t.contentWindow;if(!i)return;let a=s?.KeyboardEvent||KeyboardEvent;i.dispatchEvent(new a("keydown",o))}function ii(e){let t=Pr(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 i=o.innerText||o.textContent||"";return String(i).replace(new RegExp(el,"g"),"")??""}function ks(e){let t=`
|
|
3
|
-
|
|
4
|
-
Comments: `,n=new Set,r=[];for(let i of
|
|
5
|
-
Author: ${
|
|
6
|
-
`)}return t.trim()}function
|
|
7
|
-
|
|
8
|
-
`)||(i+=
|
|
9
|
-
`)&&
|
|
10
|
-
`)&&(i+=u)}Xc(e);let s=ks(e).trim(),a=i.trim()+s;return a.trim()?a:o()}catch{return o()}}async function kf(e,t){let n="",r;tl(e,e.defaultView||window);let o=en(t?.deadlineEpochMs);try{let i=Math.max(250,Math.min(1500,Math.floor(o*.45))),s=await Dr(Sf(e),i,e);if(!(s.ok&&s.value))throw new Error("google_sheet_copy_failed");let u=en(t?.deadlineEpochMs),m=Math.max(250,Math.min(2500,Math.floor(u*.55)));if(n=await If(m,e),!n.trim())throw new Error("google_sheet_empty_clipboard")}catch(i){r=i instanceof Error?i.message:String(i)}return{content:n,contentType:Es,error:r}}function tl(e,t){try{t?.focus?.()}catch{}try{e?.body?.focus?.()}catch{}}function Ss(e,t){let r=e.defaultView?.KeyboardEvent||KeyboardEvent,o=new r("keydown",{bubbles:!0,cancelable:!0,...t}),i=e.activeElement;(i&&i.ownerDocument===e?i:e).dispatchEvent(o)}async function Sf(e){try{if(tl(e,e.defaultView||window),e.hidden||!e.hasFocus())return!1;Ss(e,{key:"Escape",code:"Escape"}),await pt(150,e);let t=e.querySelector(".grid-container")||Kc(e,".grid-container"),n=e.querySelector(".grid4-inner-container:last-child")||Kc(e,".grid4-inner-container:last-child");if(n){try{n.focus()}catch{}await pt(100,e)}else if(t){try{t.focus?.()}catch{}await pt(80,e)}let o=(typeof navigator<"u"?String(navigator.platform||""):"").toUpperCase().indexOf("MAC")>=0;Ss(e,{key:"a",code:"KeyA",ctrlKey:!o,metaKey:o}),await pt(200,e),Ss(e,{key:"c",code:"KeyC",ctrlKey:!o,metaKey:o}),await pt(200,e);try{e.execCommand("copy")}catch{}return!0}catch{return!1}}async function If(e,t){let n=Math.max(250,Math.min(5e3,Math.floor(e)));if(navigator?.clipboard?.readText){let i=await Dr(navigator.clipboard.readText(),n,t);if(i.ok)return i.value||""}let r=t.createElement("textarea");r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",r.style.left="-9999px",r.style.top="0",t.body?.appendChild(r),r.focus();try{t.execCommand("paste")}catch{}let o=r.value||"";return r.remove(),o}function Kc(e,t){let n=ai(e);for(let a of n)try{let u=a.querySelector(t);if(u)return u}catch{}let r=25e3,o=0,i=(a,u)=>{if(!u)return;let m=u.children;if(m)for(let p=0;p<m.length;p++)a.push(m[p])},s=[];for(let a of n)try{i(s,a.documentElement??a.body??null)}catch{}for(;s.length&&o<r;){let a=s.pop();o++;try{if(a.matches(t))return a}catch{}i(s,a);let u=a.shadowRoot;if(u&&i(s,u),String(a.tagName).toUpperCase()==="IFRAME")try{let p=a.contentDocument;p&&i(s,p.documentElement??p.body??null)}catch{}}return null}async function Af(e,t){let n=t?.profile??"light",r=!e.hidden,o=Math.max(0,Math.min(t?.timeBudgetMs??(n==="light"?1600:2800),3e3));if(o<=0)return!1;let i=Date.now(),s=()=>o-(Date.now()-i),a=t?.delayMs??(n==="light"?220:280),u=t?.finalWaitMs??(n==="light"?350:900),m=r?a:0,p=r?u:0,v=t?.amount,I=t?.maxSteps??(n==="light"?8:18),A=t?.maxDistancePx??(n==="light"?12e3:3e4),x=null;try{let F=await Qc(e,{action:"detectPrimary"});if(F?.selector){let q=Cf(e,F.selector);q&&(x=q)}let P=F?.metrics;if(P&&typeof P.scrollHeight=="number"&&typeof P.clientHeight=="number"){let q=Math.max(0,P.scrollHeight-P.clientHeight);A=Math.min(A,q||A),q<1500?I=Math.min(I,2):q<4e3?I=Math.min(I,4):q<1e4&&(I=Math.min(I,6))}}catch{}if(x||(x=e.scrollingElement||e.documentElement||e.body),!x)return!1;let S=0,B=null,Y=0;for(let F=0;F<I&&!(s()<=0);F++){let P=null;try{P=await Qc(e,{action:"scrollBy",direction:Ve.DOWN,options:{amount:v,behavior:"auto",isTabActive:r}})}catch{}if(!P||!P.success){let J=e.defaultView||window;P=ti(x,e,J,Ve.DOWN,v),Y=2}if(!P?.success)break;let q=P.scrollTop??B??0;if(B!==null){let J=Math.max(0,q-B);S+=J,Y=J===0?Y+1:0}if(B=q,P.isAtBottom||Y>=2||S>=A)break;if(m>0&&F<I-1){let J=Math.min(m,Math.max(0,s()));if(J<=0)break;await pt(J,e)}}if(p>0){let F=Math.min(p,Math.max(0,s()));F>0&&await pt(F,e)}if(s()>80)try{let F=e.scrollingElement||e.documentElement||e.body,P=e.defaultView||window,q=x===e.documentElement||x===e.body||x===F?F:x;if(q){let J=q===F?P.innerHeight:q.clientHeight||P.innerHeight,ae=Math.max(0,q.scrollHeight-J);q.scrollTop=ae}}catch{}return!0}function Cf(e,t){try{return e.querySelector(t)}catch{return null}}async function Qc(e,t){let n=e.defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",s=(n[r]?.scroll||n.__RTRVR_SCROLL_API__)?.execute;return typeof s!="function"?null:s(t)}async function Nf(e,t){let n=e.defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",i=n[r]?.flushScan;if(typeof i!="function"){try{n.rtrvrAIMarkInteractiveElements?.()}catch{}return}let s=Date.now()+Math.max(100,Math.floor(t.totalBudgetMs)),a=0;for(;a<t.maxPasses&&en(s)>0;){let u=Math.max(50,Math.min(t.budgetMs,en(s)));try{await i({mode:t.mode??"full",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:u,deadlineEpochMs:s})}catch{break}if(Jc(e)===0)break;a++}if(Jc(e)>0&&en(s)>50){let u=Math.min(120,en(s));try{await i({mode:"priority",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:u,deadlineEpochMs:s})}catch{}}}function Jc(e){let t=e.documentElement;if(!t)return 0;let n=t.getAttribute(Xr);if(!n)return 0;let r=Number.parseInt(n,10);return Number.isFinite(r)&&r>0?r:0}function Lf(e){let t=Mf(e.URL||"");if(!t?.sheetId)return;let n=Df(e),r=n?.title||"Sheet1";return{sheetId:t.sheetId,sheetTitle:e.title||n?.title||void 0,sheetTab:r,sheetTabId:t.sheetTabId??n?.id,sheetTabs:void 0}}function Mf(e){if(!e)return null;try{let t=new URL(e);if(t.hostname!=="docs.google.com")return null;let n=t.pathname.split("/"),r=n.indexOf("spreadsheets"),o=n.indexOf("d");if(r===-1||o===-1||o!==r+1||n.length<=o+1)return null;let i=n[o+1];if(!i||!/^[a-zA-Z0-9_-]+$/.test(i))return null;let s;return t.hash&&t.hash.includes("gid=")&&(s=new URLSearchParams(t.hash.substring(1)).get("gid")??void 0),!s&&t.searchParams.has("gid")&&(s=t.searchParams.get("gid")??void 0),s&&!/^\\d+$/.test(s)&&(s=void 0),{sheetId:i,sheetTabId:s?parseInt(s,10):0}}catch{return null}}function Df(e){try{let t=e.querySelector('[role="tab"][aria-selected="true"]')||e.querySelector(".docs-sheet-tab-active")||e.querySelector('.docs-sheet-tab[aria-selected="true"]');if(!t)return null;let n=t.getAttribute("aria-label")||t.textContent?.trim()||void 0,r=t.getAttribute("data-sheet-id")||t.getAttribute("data-tab-id")||void 0,o=r&&/^\d+$/.test(r)?Number(r):void 0;return{title:n,id:o}}catch{return null}}var Yt;(function(e){e[e.Native=1]="Native",e[e.Inline=2]="Inline",e[e.React=4]="React",e[e.Vue=8]="Vue",e[e.Angular=16]="Angular",e[e.Svelte=32]="Svelte",e[e.JQuery=64]="JQuery",e[e.Delegated=128]="Delegated",e[e.Other=256]="Other",e[e.Inferred=512]="Inferred"})(Yt||(Yt={}));var Of={native:Yt.Native,inline:Yt.Inline,react:Yt.React,vue:Yt.Vue,angular:Yt.Angular,svelte:Yt.Svelte,jquery:Yt.JQuery,delegated:Yt.Delegated,other:Yt.Other};(()=>{let e=window,t="__RTRVR_MAIN_WORLD_INITIALIZED__",n=new WeakMap,r={frameworks:new Set,reactRoots:new WeakSet,vueRoots:new WeakSet,angularRoots:new WeakSet,svelteRoots:new WeakSet,jqueryRoots:new WeakSet},o=new WeakMap,i=new WeakMap,s=new Set,a=500,u=200,m=0,p=0,v=new WeakSet,I="__RTRVR_ET_HOOKED__",A="__RTRVR_ATTACH_SHADOW_HOOKED__";function x(l){if(l&&!v.has(l)){v.add(l);try{S(l)}catch{}try{B(l)}catch{}}}function S(l){try{let w=l.EventTarget;if(!w?.prototype||w.prototype[I])return;w.prototype[I]=!0;let R=w.prototype.addEventListener,_=w.prototype.removeEventListener;w.prototype.addEventListener=function(k,O,V){try{je(O)||dt(this,k,V)}catch{}return R.call(this,k,O,V)},w.prototype.removeEventListener=function(k,O,V){try{Bt(this,k,V)}catch{}return _.call(this,k,O,V)};try{let k=Function.prototype.toString;w.prototype.addEventListener.toString=()=>k.call(R),w.prototype.removeEventListener.toString=()=>k.call(_)}catch{}}catch{}}function B(l){try{let w=l.Element;if(!w?.prototype?.attachShadow||w.prototype[A])return;w.prototype[A]=!0;let R=w.prototype.attachShadow;w.prototype.attachShadow=function(_){let k=R.call(this,_);try{Xe.set(this,k)}catch{}try{ne(k)}catch{}return k};try{let _=Function.prototype.toString;w.prototype.attachShadow.toString=()=>_.call(R)}catch{}}catch{}}function Y(l){let R=n.get(l)?.listenerTypeMasks;if(R&&R.size){let _=[];for(let k of R.keys()){let O=Nn[k];O&&_.push(O)}return _}return zr(l)}let F=["onclick","ondblclick","ondoubleclick","onmousedown","onmouseup","role","contenteditable","draggable","tabindex","disabled","type","aria-haspopup","aria-expanded","data-click","data-action","data-handler","data-toggle","data-target"],P=0,q=new Set,J=6,ae=["click","input","change","keydown","keyup","pointerdown","pointerup","submit","focus","blur"],ue=["mouseenter","mouseleave","mouseover","mouseout","mousedown","mouseup","wheel","scroll","dragstart","drop","touchstart","touchend"];if(e[t]){typeof e.rtrvrAIMarkInteractiveElements=="function"&&e.rtrvrAIMarkInteractiveElements();return}e[t]=!0;let me={onclick:"click",ondblclick:"dblclick",ondoubleclick:"doubleclick",onmousedown:"mousedown",onmouseup:"mouseup",onmouseenter:"mouseenter",onmouseleave:"mouseleave",onmousemove:"mousemove",onmouseover:"mouseover",onmouseout:"mouseout",oncontextmenu:"contextmenu",onauxclick:"auxclick",onkeydown:"keydown",onkeyup:"keyup",onkeypress:"keypress",oninput:"input",onchange:"change",onsubmit:"submit",onreset:"reset",onselect:"select",onsearch:"search",oninvalid:"invalid",onbeforeinput:"beforeinput",onfocus:"focus",onblur:"blur",onfocusin:"focusin",onfocusout:"focusout",ontouchstart:"touchstart",ontouchend:"touchend",ontouchmove:"touchmove",ontouchcancel:"touchcancel",onpointerdown:"pointerdown",onpointerup:"pointerup",onpointermove:"pointermove",onpointerenter:"pointerenter",onpointerleave:"pointerleave",onpointercancel:"pointercancel",onpointerover:"pointerover",ondragstart:"dragstart",ondragend:"dragend",ondrag:"drag",ondragenter:"dragenter",ondragleave:"dragleave",ondragover:"dragover",ondrop:"drop",oncopy:"copy",oncut:"cut",onpaste:"paste",onscroll:"scroll",onwheel:"wheel",onplay:"play",onpause:"pause",onended:"ended",onvolumechange:"volumechange",onseeking:"seeking",onseeked:"seeked",onanimationstart:"animationstart",onanimationend:"animationend",ontransitionend:"transitionend",ontransitionstart:"transitionstart",onresize:"resize",ontoggle:"toggle",onfullscreenchange:"fullscreenchange",onload:"load",onerror:"error",onabort:"abort",onbeforeunload:"beforeunload",onunload:"unload",onhashchange:"hashchange",onpopstate:"popstate",onstorage:"storage",onmessage:"message"};function se(l){return l?String(l).split(".")[0].toLowerCase():""}let Ee=["data-click","data-action","data-event","data-handler","data-on-click","data-onclick","data-tap","data-press","data-toggle","data-target"],pe=0,Re=null,ke=new MessageChannel,Ge=[];ke.port1.onmessage=()=>{let l=Ge.shift();l&&l()};function ve(){return Date.now()}function Me(l){return!l||!Number.isFinite(l)?Number.POSITIVE_INFINITY:Math.max(0,l-ve())}let ze=8,Ye=new MessageChannel,jt=!1;function nn(){if(!jt){jt=!0;try{Ye.port2.postMessage(0)}catch{}}}function Dt(l){let w=l.values().next();if(w.done)return null;let R=w.value;return l.delete(R),R}function Ot(){return new Promise(l=>{Ge.push(l),ke.port2.postMessage(0)})}let mt=!1;function Le(){if(!mt)try{let l=e.jQuery;l&&l.fn&&(Tt(l),mt=!0,ut("jquery"))}catch{}}function Pt(l,w){for(let R=w.lastElementChild;R;R=R.previousElementSibling)l.push(R)}function Wr(l,w,R){if(R)try{let _=he(w);_&&l.push(_)}catch{}}function xn(l,w,R){if(R&&Gr(w))try{let _=w.contentWindow||null;_&&x(_);let k=_?.document?.documentElement;k&&l.push(k)}catch{}}let vt=new WeakSet;function qn(l){l&&(typeof l=="function"||typeof l=="object")&&vt.add(l)}function je(l){return!!l&&(typeof l=="function"||typeof l=="object")&&vt.has(l)}Ye.port1.onmessage=()=>{jt=!1,rn(500);let l=performance.now();for(;q.size&&performance.now()-l<ze;){let w=Dt(q);if(!w)break;try{D(w)}catch{}finally{P=Math.max(0,P-1)}}for(;s.size&&performance.now()-l<ze;){let w=Dt(s);if(!w)break;try{$n(w)}catch{}}rt(),(q.size||s.size)&&nn()};function rt(){try{let l=st()?.documentElement;if(!l)return;l.setAttribute(Xr,String(P))}catch{}}function ot(l){let w=n.get(l);return w||(w={frameworks:new Set,listeners:new Map},n.set(l,w)),w}function Ht(l){s.add(l),nn()}function Xt(l){q.has(l)||(q.add(l),P++,rt(),nn(),q.size>8e3&&rn(3e3))}function rn(l=2e3){let w=0;for(let R of q){if(w>l)break;R.isConnected||(q.delete(R),P=Math.max(0,P-1))}w=0;for(let R of s){if(w>l)break;R.isConnected||s.delete(R)}rt()}let qe=null;function Rn(l,w,R){return`${l}|${w?1:0}|${R?1:0}`}function Ut(l){let w=l.tagName;if(w==="A"||w==="BUTTON"||w==="INPUT"||w==="SELECT"||w==="TEXTAREA"||w==="SUMMARY"||l.hasAttribute("role")||l.hasAttribute("tabindex")||l.hasAttribute("contenteditable")||l.hasAttribute("onclick")||l.getAttributeNames().some(R=>R.startsWith("on")))return!0;for(let R of Ee)if(l.hasAttribute(R))return!0;return!!(l.hasAttribute("aria-haspopup")||l.hasAttribute("aria-expanded"))}function kn(l){let w=de(l);if(!tt(l,w))return!1;let R=l.tagName;if(R!=="DIV"&&R!=="SPAN"&&R!=="LI"&&R!=="SECTION"&&R!=="ARTICLE"&&R!=="P")return!1;let _=l;if(_.__ngContext__||_.__svelte__||_.__vue__||_._vnode||_.__reactFiber$||_.__reactProps$)return!0;let k=0;for(let O in _){if(++k>30)break;if(O.startsWith("__react")||O.includes("reactFiber")||O.includes("reactProps"))return!0}return!1}function Ft(){let l=st()?.documentElement;return l?r.frameworks.size>0||l.hasAttribute("rtrvr-react")||l.hasAttribute("rtrvr-vue")||l.hasAttribute("rtrvr-angular")||l.hasAttribute("rtrvr-svelte")||l.hasAttribute("rtrvr-jquery"):!1}function Sn(l){let w=performance.now();for(;q.size&&performance.now()-w<l;){let R=Dt(q);if(!R)break;try{D(R)}catch{}finally{P=Math.max(0,P-1)}}for(;s.size&&performance.now()-w<l;){let R=Dt(s);if(!R)break;try{$n(R)}catch{}}}async function nr(l={}){rn(3e3),Le(),Te();let w=l.mode??"full",R=l.includeShadow??!0,_=l.includeSameOriginIframes??!0,k=Math.max(50,Math.min(l.budgetMs??2500,15e3)),O=l.deadlineEpochMs,V=Math.max(0,Math.min(k,Me(O))),K=Rn(w,R,_);if(V<=0){let Ke=(qe?.stack?.length??0)+q.size+s.size;return{revision:++pe,scanned:0,durationMs:0,done:Ke===0,remaining:Ke}}if((!qe||qe.optsKey!==K)&&Me(O)>30&&await X({budgetMs:18,deadlineEpochMs:O}),w==="priority"){let Ke=performance.now(),Ce=0;for(;q.size&&performance.now()-Ke<=V&&!(O&&Me(O)<=0);){let Fe=Dt(q);if(!Fe)break;try{D(Fe)}catch{}Ce++,P=Math.max(0,P-1)}for(;s.size&&performance.now()-Ke<=V&&!(O&&Me(O)<=0);){let Fe=Dt(s);if(!Fe)break;try{$n(Fe)}catch{}}return rt(),{revision:++pe,scanned:Ce,durationMs:performance.now()-Ke,done:q.size===0&&s.size===0,remaining:q.size+s.size}}if(!qe||qe.optsKey!==K){let Ke=st()?.documentElement;qe={optsKey:K,stack:Ke?[Ke]:[],scannedTotal:0}}let Ae=performance.now(),Se=0;for(P++,rt();qe.stack.length&&!(O&&Me(O)<=0);){let Ke=qe.stack.pop();if(Gt(Ke)){let Fe=Ke.children;for(let En=Fe.length-1;En>=0;En--)qe.stack.push(Fe[En]);continue}let Ce=Ke;if(!(!Ce||Ce.nodeType!==1)&&!(Ce.tagName==="SCRIPT"||Ce.tagName==="STYLE"||Ce.tagName==="META"||Ce.tagName==="NOSCRIPT")){try{(Ut(Ce)||Ft()&&kn(Ce))&&D(Ce)}catch{}try{$n(Ce)}catch{}if(q.delete(Ce)&&(P=Math.max(0,P-1)),s.delete(Ce),Se++,qe.scannedTotal++,R)try{let Fe=he(Ce);Fe&&(ne(Fe),qe.stack.push(Fe))}catch{}if(_&&Gr(Ce))try{let Fe=Ce.contentWindow||null;Fe&&x(Fe);let En=Fe?.document,N=En?.documentElement;En&&N&&(ce(En),qe.stack.push(N))}catch{}for(let Fe=Ce.lastElementChild;Fe;Fe=Fe.previousElementSibling)qe.stack.push(Fe);Se%800===0&&Me(O)>20&&await Ot()}}let De=Math.max(0,V-(performance.now()-Ae)),gt=Me(O);Sn(Math.min(250,De,gt)),P=Math.max(0,P-1),rt();let $t=qe.stack.length===0,Gn=qe.stack.length;return $t&&(qe=null),{revision:++pe,scanned:Se,durationMs:performance.now()-Ae,done:$t,remaining:Gn}}async function mn(l={}){return Re||(Re=nr(l).finally(()=>{Re=null}),Re)}e.rtrvrAIFlushScan=mn;let Kt="__RTRVR_INTERNAL__";Object(window).__RTRVR_INTERNAL_KEY__=Kt;let on=e[Kt],gn=on&&typeof on=="object"?on:{};if(!on)try{Object.defineProperty(e,Kt,{value:gn,writable:!1,configurable:!1,enumerable:!1})}catch{}try{Object.defineProperty(gn,"flushScan",{value:mn,writable:!1,configurable:!1,enumerable:!1})}catch{}function ye(l,w){let R=ot(l),_=se(w.type);if(!_)return;let k=!1,O=R.listeners.get(_);O||(O=[],R.listeners.set(_,O),k=!0);let V=O.find(fe=>fe.source===w.source&&!!fe.inferred==!!w.inferred);if(V){let fe=!!V.capture,Ae=!!V.passive,Se=!!V.once;V.capture=V.capture||w.capture,V.passive=V.passive||w.passive,V.once=V.once||w.once,(fe!==!!V.capture||Ae!==!!V.passive||Se!==!!V.once)&&(k=!0)}else O.push({...w,type:_}),k=!0;let K=Ie[_];if(K!==void 0){R.listenerTypeMasks||(R.listenerTypeMasks=new Map);let fe=0,Ae=Of[w.source];fe|=Ae!==void 0?Ae:Yt.Other,w.inferred&&(fe|=Yt.Inferred);let Se=R.listenerTypeMasks.get(K)||0,De=Se|fe;De!==Se&&(R.listenerTypeMasks.set(K,De),k=!0)}k&&(R.role=void 0,Ht(l))}function Ue(l){let w=l.listenerTypeMasks;return!w||w.size===0?null:[...w.entries()].sort((_,k)=>_[0]-k[0]).map(([_,k])=>`${_}~${(k||0).toString(36)}`).join(",")}function bn(l,w){let R=ot(l);R.frameworks.has(w)||(R.frameworks.add(w),Ht(l))}function ut(l){r.frameworks.has(l)||(r.frameworks.add(l),st()?.documentElement?.setAttribute(`rtrvr-${l}`,"1"))}function $n(l){let w=n.get(l);if(!w)return;s.delete(l);let R=Ue(w);R?R!==w.lastListenersSerialized&&(l.setAttribute(zn,R),w.lastListenersSerialized=R):w.lastListenersSerialized&&(l.removeAttribute(zn),w.lastListenersSerialized=void 0);let _=de(l);if(tt(l,_))if(w.role===void 0&&(w.role=Tr(l)),w.role){let k=kr[w.role],O=typeof k=="number"?String(k):`s:${w.role}`;O!==w.lastRoleSerialized&&(l.setAttribute(Mn,O),w.lastRoleSerialized=O)}else(w.lastRoleSerialized||l.hasAttribute(Mn))&&(l.removeAttribute(Mn),w.lastRoleSerialized=void 0)}function vr(l){let w=[],R=l;for(;R;)w.push(R),R=R.parentNode||R.host;return w}function Wn(l){let w=l.tagName.toLowerCase(),R=l.getAttribute("role"),_=R?R.toLowerCase().trim():"";if(_&&Ln.has(_)||w==="button"||(w==="a"||w==="area")&&l.hasAttribute("href"))return!0;if(w==="input")return l.type?.toLowerCase()!=="hidden";if(w==="select"||w==="textarea"||(w==="video"||w==="audio")&&l.hasAttribute("controls")||l.isContentEditable||l.hasAttribute("contenteditable"))return!0;let k=l.getAttribute("tabindex");return!!(k!==null&&!Number.isNaN(Number.parseInt(k,10))&&(Y(l).some(K=>Ho.has(K))||l.getAttributeNames().some(K=>K.startsWith("on"))))}function We(l,w=10,R=600){let _=[];for(let O=0;O<l.children.length;O++)_.push({node:l.children[O],depth:1});let k=0;for(;_.length;){let{node:O,depth:V}=_.pop();if(++k>R||Wn(O))return!0;if(!(V>=w))for(let K=0;K<O.children.length;K++)_.push({node:O.children[K],depth:V+1})}return!1}function Tr(l){let w=l.tagName.toLowerCase(),R=l.getAttribute("role"),_=R?R.toLowerCase().trim():"",k=l.type?.toLowerCase();if(_&&Ln.has(_))return _;if(_&&Yr.has(_))return null;if(w==="a"&&l.hasAttribute("href"))return"link";if(w==="button")return"button";if(w==="input")return k==="hidden"?null:k==="checkbox"?"checkbox":k==="radio"?"radio":k==="range"?"slider":k==="number"?"spinbutton":k==="search"?"searchbox":["button","submit","reset","image","file"].includes(k)?"button":l.hasAttribute("list")?"combobox":"textbox";if(w==="textarea")return"textbox";if(w==="select"){let De=l;return De.multiple||De.size&&De.size>1?"listbox":"combobox"}if(w==="option")return"option";if(w==="form")return"form";if(w==="video"||w==="audio"){let De=zr(l);return l.hasAttribute("controls")||De.length>0?"media":null}if(l.isContentEditable||l.hasAttribute("contenteditable"))return"textbox";let O=Y(l);if(!O.length)return null;let V=!1,K=!1,fe=!1;for(let De=0;De<O.length;De++){let gt=O[De];!V&&Ho.has(gt)&&(V=!0),!K&&ts.has(gt)&&(K=!0),!fe&&ns.has(gt)&&(fe=!0)}if(!V&&!K&&!fe)return null;let Ae=l.getAttribute("tabindex"),Se=Ae!==null&&!Number.isNaN(Number.parseInt(Ae,10));if(V&&(ds(l)||l.getAttribute("href")||l.closest("a[href]")))return"link";if(K){if(l.isContentEditable||l.hasAttribute("contenteditable"))return"textbox";if(_==="textbox"||_==="searchbox"||_==="combobox"||_==="spinbutton")return _;if(!V&&Se)return"textbox"}if(V){let De=l.getAttribute("aria-checked"),gt=l.getAttribute("aria-pressed");if(De!==null||gt!==null){if(_==="radio")return"radio";if(_==="menuitemradio")return"menuitemradio";if(_==="menuitemcheckbox")return"menuitemcheckbox";if(gt!==null)return"button";if(De!==null)return"checkbox"}if((Se||_==="button")&&!We(l))return"button"}return fe?"application":null}let _r=EventTarget.prototype.addEventListener,sn=EventTarget.prototype.removeEventListener;function In(l){let w=!1,R,_;return typeof l=="boolean"?w=l:l&&typeof l=="object"&&(w=!!l.capture,R=l.passive,_=l.once),{capture:w,passive:R,once:_}}function an(l){try{let w=l;if(w?.nodeType===9&&w?.documentElement)return w;let R=w?.document;if(R&&R.nodeType===9&&R.documentElement)return R}catch{}return null}function dt(l,w,R){let _=se(w);if(!_)return;let{capture:k,passive:O,once:V}=In(R),K=o.get(l);K||(K=new Map,o.set(l,K));let fe=K.get(_);if(fe?(fe.count+=1,fe.capture=fe.capture||k,fe.passive=fe.passive||O):K.set(_,{count:1,capture:k,passive:O}),or(l))try{ye(l,{type:_,source:"native",capture:k,passive:O,once:V})}catch{}let Ae=an(l);if(Ae&&(_==="click"||_==="input"||_==="keydown"))try{Ae.documentElement?.setAttribute(`rtrvr-gl-${_}`,"1")}catch{}}function Bt(l,w,R){let _=se(w);if(!_)return;let k=o.get(l);if(!k)return;let O=k.get(_);O&&(O.count-=1,O.count<=0&&k.delete(_),k.size===0&&o.delete(l))}x(window);function Tt(l){if(!l||!l.fn)return;let w=l.fn.on,R=l.fn.off;function _(O){if(!O)return[];if(typeof O=="string")return O.split(/\s/).map(V=>se(V)).filter(Boolean);if(typeof O=="object")try{return Object.keys(O).map(V=>se(V)).filter(Boolean)}catch{return[]}return[]}function k(O){try{if(!O)return null;if(or(O))return O;let V=de(O);return Lo(O,V)||null}catch{}return null}l.fn.on=function(O,V){let K=_(O),fe=typeof V=="string"&&!!V;return this.each(function(){let Ae=k(this);if(Ae){if(fe){let Se=i.get(Ae);Se||(Se=[],i.set(Ae,Se));for(let De of K){let gt=`${De}::${V}`;Se.some($t=>`${$t.type}::${$t.selector}`===gt)||(Se.push({type:De,selector:V}),Se.length>400&&Se.shift())}}else for(let Se of K)ye(Ae,{type:Se,source:"jquery"});bn(Ae,"jquery"),ut("jquery"),r.jqueryRoots.add(Ae)}}),w.apply(this,arguments)},l.fn.off=function(){return R.apply(this,arguments)},ut("jquery")}function An(l){Ee.some(R=>l.hasAttribute(R))&&(ye(l,{type:"click",source:"other",inferred:!0}),(l.tagName==="INPUT"||l.tagName==="TEXTAREA")&&(ye(l,{type:"input",source:"other",inferred:!0}),ye(l,{type:"change",source:"other",inferred:!0})))}function qt(l){let w=de(l),R=tt(l,w),_=l.getAttributeNames().some(fe=>fe.startsWith("on")),k=/^(button|a|input|select|textarea|summary)$/i.test(l.tagName),O=l,V=R&&(qo(l)||!!O.isContentEditable||l.hasAttribute("contenteditable")),K=R&&!!O.draggable;if(!_&&!k&&!V&&!K){An(l);return}for(let[fe,Ae]of Object.entries(me))typeof l[fe]=="function"&&ye(l,{type:Ae,source:"inline"});V&&(ye(l,{type:"input",source:"other",inferred:!0}),ye(l,{type:"keydown",source:"other",inferred:!0}),ye(l,{type:"keyup",source:"other",inferred:!0}),ye(l,{type:"paste",source:"other",inferred:!0})),K&&(ye(l,{type:"dragstart",source:"other",inferred:!0}),ye(l,{type:"dragend",source:"other",inferred:!0})),An(l)}function Cn(l){if(!l.startsWith("on")||l.length<=2)return null;if(l.endsWith("Capture")){let R=l.substring(2,l.length-7);return R?{type:R.toLowerCase(),capture:!0}:null}let w=l.substring(2);return w?{type:w.toLowerCase(),capture:!1}:null}function Vn(l){let w=null;if(l){for(let R in l)if(R.startsWith("__react")||R.startsWith("_react")||R.includes("reactFiber")||R.includes("reactProps")||R.includes("reactInternalInstance")){w=R;break}if(w)try{let R=l[w],_=R?.memoizedProps||R?.pendingProps;if(_&&typeof _=="object"){for(let k in _){if(typeof _[k]!="function")continue;let V=Cn(k);V&&ye(l,{type:V.type,source:"react",capture:V.capture})}or(R?.stateNode)&&r.reactRoots.add(R.stateNode),bn(l,"react"),ut("react")}}catch{}}}function c(l){let w=l,R=!1;if(w.__vue__){R=!0;let _=w.__vue__;_.$listeners&&Object.keys(_.$listeners).forEach(k=>ye(l,{type:k,source:"vue"})),_._events&&Object.keys(_._events).forEach(k=>ye(l,{type:k,source:"vue"})),_.$options?._parentListeners&&Object.keys(_.$options._parentListeners).forEach(k=>ye(l,{type:k,source:"vue"})),r.vueRoots.add(l)}if(w._vnode?.props){R=!0;let _=w._vnode.props;Object.keys(_).forEach(k=>{k.startsWith("on")&&k.length>2&&ye(l,{type:k.substring(2).toLowerCase(),source:"vue"})}),r.vueRoots.add(l)}R&&(bn(l,"vue"),ut("vue"))}function E(l){let w=l,R=!1;if(w.__ngContext__||l.hasAttribute("_ngcontent")||l.hasAttribute("ng-version")){R=!0,Array.from(l.attributes).forEach(_=>{if(_.name.startsWith("(")&&_.name.endsWith(")")){let k=_.name.slice(1,-1).split(".")[0];k&&ye(l,{type:k,source:"angular"})}if(_.name.startsWith("on-")){let k=_.name.substring(3);k&&ye(l,{type:k,source:"angular"})}if(_.name.includes(".")){let k=_.name.match(/\(([^.)]+)/);k?.[1]&&ye(l,{type:k[1],source:"angular"})}});try{if(e.ng?.getComponent){let _=e.ng.getComponent(l);_&&Object.keys(_).forEach(k=>{(k.endsWith("Output")||k.endsWith("Emitter"))&&ye(l,{type:k.replace(/(Output|Emitter)$/,"").toLowerCase(),source:"angular"})})}}catch{}}R&&(bn(l,"angular"),ut("angular"),r.angularRoots.add(l))}function y(l){let w=l,R=!1;if(w.__svelte__){R=!0,Array.from(l.attributes).forEach(_=>{if(_.name.startsWith("on:")){let k=_.name.substring(3);k&&ye(l,{type:k,source:"svelte"})}});try{let _=w.__svelte__?.$$?.callbacks;_&&typeof _=="object"&&Object.keys(_).forEach(k=>ye(l,{type:k,source:"svelte"}))}catch{}r.svelteRoots.add(l)}R&&(bn(l,"svelte"),ut("svelte"))}function b(l,w){return l?!!o.get(l)?.has(w):!1}function f(l,w,R=96){let _=se(w);if(!_)return!1;let k=z(l),O=j(k);if(b(k,_)||b(O,_))return!0;let V=0,K=l;for(;K&&V<R;){if(K.parentElement)K=K.parentElement;else{let fe=K.getRootNode?.();if(Gt(fe)){if(b(fe,_)||b(fe.host,_))return!0;K=fe.host}else break}if(K&&b(K,_))return!0}return!1}function d(l,w,R=128){let _=0,k=l;for(;k&&_<R;){if(w(k),k.parentElement){k=k.parentElement;continue}let O=k.getRootNode?.();if(Gt(O)){k=O.host;continue}break}}function g(l){let w=de(l);if(!tt(l,w))return;let R=ot(l);R.role=R.role||Tr(l);let _=f(l,"click"),k=f(l,"input"),O=f(l,"keydown"),K=z(l).documentElement;if(r.frameworks.size>0||K.hasAttribute("rtrvr-react")||K.hasAttribute("rtrvr-vue")||K.hasAttribute("rtrvr-angular")||K.hasAttribute("rtrvr-svelte")||K.hasAttribute("rtrvr-jquery")||_||k||O){let Ae=R.role||"other";_&&["button","link","checkbox","radio","switch","menuitem","menuitemcheckbox","menuitemradio","tab","option","treeitem","gridcell","cell","img","figure"].includes(Ae)&&ye(l,{type:"click",source:"delegated",inferred:!0}),["textbox","searchbox","spinbutton","code"].includes(Ae)&&(k&&(ye(l,{type:"input",source:"delegated",inferred:!0}),ye(l,{type:"change",source:"delegated",inferred:!0})),O&&ye(l,{type:"keydown",source:"delegated",inferred:!0})),["combobox","listbox"].includes(Ae)&&(_&&ye(l,{type:"click",source:"delegated",inferred:!0}),k&&ye(l,{type:"change",source:"delegated",inferred:!0})),["slider","scrollbar","progressbar","meter"].includes(Ae)&&k&&ye(l,{type:"input",source:"delegated",inferred:!0})}d(l,Ae=>{let Se=i.get(Ae);if(Se?.length)for(let{type:De,selector:gt}of Se)try{l.matches(gt)&&(ye(l,{type:De,source:"jquery",inferred:!0}),bn(l,"jquery"),ut("jquery"))}catch{}})}function T(l){let w=R=>{let _=R,k=_.composedPath&&_.composedPath()||vr(R.target),V=l==="mousemove"||l==="pointermove"||l==="scroll"||l==="wheel"?1:Math.min(k.length,J);for(let K=0;K<V;K++){let fe=k[K];or(fe)&&ye(fe,{type:l,source:"delegated",inferred:!0})}};qn(w);try{_r.call(document,l,w,{capture:!0,passive:!0})}catch{}}let L=!1;function C(){ae.forEach(T);let l=st()?.documentElement;if(!l)return;let w=()=>{if(L)return;let R=l.hasAttribute("rtrvr-react")||l.hasAttribute("rtrvr-vue")||l.hasAttribute("rtrvr-angular")||l.hasAttribute("rtrvr-svelte"),_=l.hasAttribute("rtrvr-gl-click")||l.hasAttribute("rtrvr-gl-input")||l.hasAttribute("rtrvr-gl-keydown");(R||_)&&(L=!0,ue.forEach(T))};w();try{new MutationObserver(()=>w()).observe(l,{attributes:!0,attributeFilter:["rtrvr-react","rtrvr-vue","rtrvr-angular","rtrvr-svelte","rtrvr-gl-click","rtrvr-gl-input","rtrvr-gl-keydown"]})}catch{}}function D(l){if(l.nodeType!==1)return;let w=de(l);if(tt(l,w)){let R=ot(l);R.role=void 0}qt(l),Vn(l),c(l),E(l),y(l),g(l),Ht(l)}function U(){let l=["a[href]","button","input","select","textarea","summary","details > summary",...Array.from(Ln).map(w=>`[role="${w}"]`),"[onclick]","[ondblclick]","[ondoubleclick]","[onmousedown]","[tabindex]","[contenteditable]",'[draggable="true"]',"[aria-haspopup]","[aria-expanded]","[data-click]","[data-action]","[data-handler]","[data-toggle]","[data-target]",".clickable",".interactive",".btn",".button"];P++,rt();try{let w=l.join(",");st()?.querySelectorAll(w).forEach(R=>{try{D(R)}catch{}})}finally{P=Math.max(0,P-1),rt()}}function G(l){for(let w of l){for(let R of Array.from(w.addedNodes)){if(R.nodeType!==1)continue;let _=R;Xt(_),_.querySelectorAll?.('a,button,input,select,textarea,summary,[role],[onclick],[ondblclick],[ondoubleclick],[contenteditable],[draggable="true"],[tabindex]').forEach(Xt)}if(w.type==="attributes"&&w.target.nodeType===1){let R=w.target;w.attributeName==="class"?(Ft()||Ut(R))&&Xt(R):Xt(R)}}}async function X(l={}){let w=st(),R=w?.documentElement;if(!R||!(R.hasAttribute("rtrvr-react")||R.hasAttribute("rtrvr-vue")||R.hasAttribute("rtrvr-angular")||R.hasAttribute("rtrvr-svelte")))return;let k=l.deadlineEpochMs,O=Math.max(5,Math.min(l.budgetMs??12,50));if(Math.max(0,Math.min(O,Me(k)))<=0)return;let K=performance.now();P++,rt();try{let fe=0,Ae=4e3,Se=["div","span","li","section","article","p"];for(let De of Se){let gt=w.getElementsByTagName(De)??[];for(let $t=0;$t<gt.length;$t++){if(fe++>=Ae||k&&Me(k)<=0)return;let Gn=gt[$t],Ke=Gn;(Ke.__ngContext__||Ke.__svelte__||Ke.__vue__||Ke._vnode||kn(Gn))&&D(Gn),fe%250===0&&Me(k)>20&&await Ot()}}}finally{P=Math.max(0,P-1),rt()}}let oe=new MutationObserver(G),we=new WeakMap;function ne(l){if(!we.has(l)&&!(m>=a))try{let w=j(l.ownerDocument).MutationObserver||MutationObserver,R=new w(G);we.set(l,R),m++,R.observe(l,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...F,"class"]})}catch{}}let ee=new WeakMap;function ce(l){if(!ee.has(l)&&!(p>=u))try{x(l.defaultView||null);let w=l.documentElement;if(!w)return;let R=j(l).MutationObserver||MutationObserver,_=new R(G);ee.set(l,_),p++,_.observe(w,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...F,"class"]})}catch{}}function ge(){let l=st()?.documentElement;l&&oe.observe(l,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...F,"class"]})}let Xe=new WeakMap;function he(l){return l.shadowRoot||Xe.get(l)||null}try{Object.defineProperty(gn,"shadow",{value:Object.freeze({getRoot:l=>he(l)}),writable:!1,configurable:!1,enumerable:!1})}catch{}function Te(){try{(e.React||e.__REACT_DEVTOOLS_GLOBAL_HOOK__)&&ut("react"),e.Vue&&ut("vue"),e.ng&&ut("angular"),e.jQuery&&ut("jquery"),Le()}catch{}}e.rtrvrAIMarkInteractiveElements=function(){return st()?.body?(U(),!0):!1};function _e(){let l=st();Le(),Te(),C();let w=()=>{Le(),Te(),ge(),e.rtrvrAIMarkInteractiveElements?.(),X({budgetMs:20}),l?.documentElement.setAttribute(Ji,"1")};l?.readyState==="loading"?l.addEventListener("DOMContentLoaded",w,{once:!0}):w()}_e()})();var ci=null;function Is(e){try{return e.getAttribute(zn)}catch{return null}}function nl(e){let t=Is(e);return ir(t)?.entries??[]}function rl(e){try{let t=e.getAttribute(Mn);return t&&t.trim()?t:null}catch{return null}}function Pf(e){let t=e?.ownerDocument?.defaultView,n=t?.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",o=t?.[n]?.shadow?.getRoot;if(typeof o=="function")try{return o(e)||null}catch{}return e.shadowRoot||null}function Hf(e){let t=new Set;for(let n of e){let r=Ro(n.mask);for(let o of r)(o==="react"||o==="vue"||o==="angular"||o==="svelte"||o==="jquery")&&t.add(o)}return t}function Uf(e){let t=new Set,n=e;return(n.__reactFiber||n.__reactProps||n.__reactInternalInstance||n.__reactRootContainer)&&t.add("react"),(n.__vue__||n.__vueParentComponent||n.__vnode||n.__vue_app__)&&t.add("vue"),n.__ngContext__&&t.add("angular"),(n.__svelte||n.__svelte_meta)&&t.add("svelte"),(n.__jquery||n.jQuery)&&t.add("jquery"),t}function Ff(e){let t=nl(e),n=Hf(t),r=Uf(e);for(let o of r)n.add(o);return{frameworks:[...n],listenersRaw:Is(e)||"",role:rl(e)??(e.getAttribute?.("role")||null)}}function Bf(){return{getEventHandlerIds:e=>nl(e).map(t=>t.id),getRoleHint:rl,getShadowRoot:Pf}}function ol(e={}){if(ci)return ci;if(typeof window<"u")try{window.rtrvrAIMarkInteractiveElements?.()}catch{}return ci={signalProvider:Bf(),getFrameworkMetadata:Ff,getListenerEncoding:Is,dispose:()=>{}},ci}var di=class{constructor(t={}){W(this,"root");W(this,"includeFrames");W(this,"disableDomAnnotations");W(this,"allowActions");W(this,"runtimeId");W(this,"domainScopeMode");W(this,"allowedDomains");W(this,"externalNavigationPolicy");W(this,"crossHostPolicy");W(this,"registerOpenedTab");W(this,"listKnownTabs");W(this,"switchToLogicalTab");W(this,"onNavigationGuardrail");W(this,"onBeforeAgentNavigation");W(this,"onBeforeCrossHostNavigation");W(this,"instrumentation");W(this,"highlightEl",null);W(this,"clientTools",new Map);W(this,"uploadStore",new Map);W(this,"uploadProviderInstalled",!1);W(this,"actionGateContext",{});this.root=t.root??document.body??document.documentElement,this.includeFrames=t.includeFrames??!0,this.disableDomAnnotations=t.disableDomAnnotations??!0,this.allowActions=t.allowActions??!0,this.runtimeId=t.runtimeId,this.domainScopeMode=il(t.domainScopeMode),this.allowedDomains=As(t.allowedDomains,window.location.hostname,this.domainScopeMode),this.externalNavigationPolicy=sl(t.externalNavigationPolicy),this.crossHostPolicy=al(t.crossHostPolicy),this.registerOpenedTab=t.registerOpenedTab,this.listKnownTabs=t.listKnownTabs,this.switchToLogicalTab=t.switchToLogicalTab,this.onNavigationGuardrail=t.onNavigationGuardrail,this.onBeforeAgentNavigation=t.onBeforeAgentNavigation,this.onBeforeCrossHostNavigation=t.onBeforeCrossHostNavigation,this.instrumentation=t.instrumentation??ol({includeIframes:!0,scanInlineHandlers:!0,observeInlineMutations:!0,...t.instrumentationOptions||{}}),zc(),t.uploadBytesProvider&&this.setUploadBytesProvider(t.uploadBytesProvider)}setAllowActions(t){this.allowActions=!!t}setActionGateContext(t){let n={};(t?.mode==="controller"||t?.mode==="observer")&&(n.mode=t.mode),typeof t?.controllerRuntimeId=="string"&&t.controllerRuntimeId.trim()&&(n.controllerRuntimeId=t.controllerRuntimeId.trim()),Number.isFinite(Number(t?.activeLogicalTabId))&&Number(t?.activeLogicalTabId)>0&&(n.activeLogicalTabId=Number(t?.activeLogicalTabId)),Number.isFinite(Number(t?.localLogicalTabId))&&Number(t?.localLogicalTabId)>0&&(n.localLogicalTabId=Number(t?.localLogicalTabId)),typeof t?.reason=="string"&&t.reason.trim()&&(n.reason=t.reason.trim().slice(0,240)),this.actionGateContext=n}setNavigationPolicy(t){t.domainScopeMode&&(this.domainScopeMode=il(t.domainScopeMode),t.allowedDomains||(this.allowedDomains=As(void 0,window.location.hostname,this.domainScopeMode))),t.allowedDomains&&(this.allowedDomains=As(t.allowedDomains,window.location.hostname,this.domainScopeMode)),t.externalNavigationPolicy&&(this.externalNavigationPolicy=sl(t.externalNavigationPolicy)),t.crossHostPolicy&&(this.crossHostPolicy=al(t.crossHostPolicy))}async getSnapshot(){return await ul(this.root),ni(this.root,this.instrumentation,{includeFrames:this.includeFrames,disableDomAnnotations:this.disableDomAnnotations})}async getPageData(t){return await ul(this.root),await Zc(this.root,this.instrumentation,{includeFrames:this.includeFrames,disableDomAnnotations:this.disableDomAnnotations,pageConfig:t?.pageConfig})}async executeTool(t,n){let r=qf(t?.name);if(!r)return{success:!1,error:`Unknown tool: ${String(t?.name)}`,allowFallback:!1};if(this.shouldBlockForOutOfScopeContext(r))return this.domainScopeBlockedResponse(window.location.href,"Current tab is outside the allowed navigation scope.",{fromCurrentContext:!0});if(!this.allowActions&&!ll.has(r))return{success:!1,error:"Actions disabled by configuration",allowFallback:!1,output:{reason:this.actionGateContext.mode==="observer"?"Actions are disabled because this tab is currently in observer mode.":this.actionGateContext.reason||"Actions disabled by configuration",actionGate:this.actionGateContext}};let o=await this.handleNavigationTools(r,t?.args||{});if(o)return o;if(r===M.wait_action){let x=Number(t?.args?.duration??1e3);return await new Promise(S=>setTimeout(S,Math.max(0,Math.min(x,6e4)))),{success:!0}}if(r===M.wait_for_element)return this.waitForElement(t?.args||{});if(r===M.answer_task)return{success:!0};if(r===M.solve_captcha)return ui("CAPTCHA solving requires human intervention in embed mode.","HUMAN_INTERVENTION_REQUIRED");if(r===M.network_run_recipe)return ui("network_run_recipe is not supported in embed mode.","CAPABILITY_UNAVAILABLE");let i=t?.args||{},s=Yf(i),a=Mr(document,i.iframe_id);if(i.iframe_id!=null&&a.unresolvedPath.length>0&&!s)return this.iframeContextUnavailableResponse(i.iframe_id,a);if(r===M.click_element&&i?.open_in_new_tab)return this.openElementInNewTab(i);if(r===M.click_element){let x=this.getInterceptedClickTarget(i);if(x?.targetUrl){if(x.forceOpenInNewTab)return this.openUrlInNewTab(x.targetUrl,{policyBlocked:!0,reason:x.reason});let B=x.reason;return this.externalNavigationPolicy==="open_new_tab_notice"?this.openUrlInNewTab(x.targetUrl,{policyBlocked:!0,reason:B}):this.domainScopeBlockedResponse(x.targetUrl,B)}let S=this.getClickTargetUrl(i);S?(this.notifyAgentNavigation(S),this.notifyCrossHostNavigation(S)):this.notifyAgentNavigation(window.location.href)}if(r===M.describe_images)return this.describeImages(t?.args||{});if(!(r in xo))return{success:!1,error:`Unknown tool: ${String(t?.name)}`,allowFallback:!1};let{doc:u}=a,m=Cs(i),p=m?fn(u,m):null,v;if(p){let x=this.instrumentation.getFrameworkMetadata(p),S=zf(x.listenersRaw||"",r),B=i?.value??i?.text??null;v=Gf({...x,pattern:S,value:B})}let I=xo[r];return r===M.upload_file&&!n&&(n=await this.buildUploadPayload(i).catch(()=>{})),Yc({opcode:I,call:{name:r,args:i},elementData:v,tabIndex:0,payload:n})}iframeContextUnavailableResponse(t,n){let o=`iframe_id unresolved: remaining=${n.unresolvedPath.join(">")||"(none)"} (cross-origin, not-ready, or not found)`;return{success:!1,error:o,allowFallback:!1,output:{success:!1,error:{code:"IFRAME_CONTEXT_UNAVAILABLE",message:o,retryable:!1},iframe_context:{requested_iframe_id:t,requested_path:n.iframePath,resolved_path:n.resolvedPath,unresolved_path:n.unresolvedPath}},errorDetails:{code:"IFRAME_CONTEXT_UNAVAILABLE",message:o,retryable:!1,details:{requested_iframe_id:t,requested_path:n.iframePath,resolved_path:n.resolvedPath,unresolved_path:n.unresolvedPath}}}}highlight(t){let n=fn(document,t);if(!n)return;let r=n.getBoundingClientRect();if(!this.highlightEl){let o=document.createElement("div");o.style.position="fixed",o.style.pointerEvents="none",o.style.border="2px solid #ff7a59",o.style.boxShadow="0 0 0 2px rgba(255, 122, 89, 0.2)",o.style.borderRadius="6px",o.style.zIndex="2147483647",this.highlightEl=o,document.body.appendChild(o)}this.highlightEl.style.left=`${r.left}px`,this.highlightEl.style.top=`${r.top}px`,this.highlightEl.style.width=`${Math.max(0,r.width)}px`,this.highlightEl.style.height=`${Math.max(0,r.height)}px`,this.highlightEl.style.display="block"}clearHighlight(){this.highlightEl&&(this.highlightEl.style.display="none")}setUploadBytesProvider(t){window.__ROVER_UPLOAD_BYTES__=t}registerTool(t,n){let r=typeof t=="string"?{name:t}:t;!r?.name||typeof n!="function"||this.clientTools.set(r.name,{handler:n,def:r})}async executeClientTool(t,n){let r=this.clientTools.get(t);if(!r)throw new Error(`Unknown client tool: ${t}`);return r.handler(n)}listClientTools(){return Array.from(this.clientTools.values()).map(t=>t.def)}async handleNavigationTools(t,n){switch(t){case M.goto_url:{let r=String(n.url||"").trim();if(!r)return{success:!1,error:"goto_url: missing url",allowFallback:!0};let o=li(r,window.location.href);if(!o)return{success:!1,error:`goto_url: invalid url "${r}"`,allowFallback:!0};if(this.shouldPreserveHostRuntime(o))return!pn(o,this.allowedDomains)&&this.externalNavigationPolicy==="block"?this.domainScopeBlockedResponse(o,"Navigation blocked by domain policy."):await this.openUrlInNewTab(o,{policyBlocked:!0,reason:"Opened in a new tab to preserve Rover runtime continuity across hostnames."});if(this.shouldGuardExternalNavigation(o)){let i="Navigation blocked by domain policy.";return this.externalNavigationPolicy==="open_new_tab_notice"?await this.openUrlInNewTab(o,{policyBlocked:!0,reason:i}):this.domainScopeBlockedResponse(o,i)}return this.notifyAgentNavigation(o),this.notifyCrossHostNavigation(o),window.location.href=o,{success:!0,output:{url:o,navigation:"same_tab"}}}case M.google_search:{let r=String(n.query||"").trim();if(!r)return{success:!1,error:"google_search: missing query",allowFallback:!0};let o=`https://www.google.com/search?q=${encodeURIComponent(r)}`;if(this.shouldPreserveHostRuntime(o))return!pn(o,this.allowedDomains)&&this.externalNavigationPolicy==="block"?this.domainScopeBlockedResponse(o,"Google search blocked by domain policy."):await this.openUrlInNewTab(o,{policyBlocked:!0,reason:"Opened in a new tab to preserve Rover runtime continuity across hostnames."});if(this.shouldGuardExternalNavigation(o)){let i="Google search opens outside the allowed navigation scope.";return this.externalNavigationPolicy==="open_new_tab_notice"?await this.openUrlInNewTab(o,{policyBlocked:!0,reason:i}):this.domainScopeBlockedResponse(o,i)}return this.notifyAgentNavigation(o),this.notifyCrossHostNavigation(o),window.location.href=o,{success:!0,output:{url:o,navigation:"same_tab"}}}case M.go_back:return this.notifyAgentNavigation(window.location.href),window.history.back(),{success:!0};case M.go_forward:return this.notifyAgentNavigation(window.location.href),window.history.forward(),{success:!0};case M.refresh_page:return this.notifyAgentNavigation(window.location.href),window.location.reload(),{success:!0};case M.open_new_tab:{let r=String(n.url||"").trim();if(!r)return{success:!1,error:"open_new_tab: missing url",allowFallback:!0};let o=li(r,window.location.href);return o?this.shouldConvertOpenNewTabToSameTab(o)?(this.notifyAgentNavigation(o),this.notifyCrossHostNavigation(o),window.location.assign(o),{success:!0,output:{url:o,navigation:"same_tab",convertedFrom:"open_new_tab"}}):await this.openUrlInNewTab(o,{policyBlocked:!1}):{success:!1,error:`open_new_tab: invalid url "${r}"`,allowFallback:!0}}case M.switch_tab:{let r=Number(n.logical_tab_id??n.tab_id);if(!Number.isFinite(r)||r<=0)return{success:!1,error:(typeof n._tab_id_mapping_error=="string"?String(n._tab_id_mapping_error).trim():"")||"switch_tab: missing/invalid logical_tab_id",allowFallback:!0};if(this.externalNavigationPolicy!=="allow"&&this.listKnownTabs){let o=this.listKnownTabs().find(i=>Number(i.logicalTabId)===r);if(o?.external)return this.domainScopeBlockedResponse(o.url||`logical_tab_id:${r}`,`Tab ${r} is out of scope. Direct actions are blocked for this tab.`)}if(!this.switchToLogicalTab)return ui("switch_tab requires session coordinator support.","CAPABILITY_UNAVAILABLE");try{let o=await this.switchToLogicalTab(r);return o?.ok?{success:!0,output:{logicalTabId:r,delegated:!!o.delegated,mode:o.delegated?"delegated":"local"}}:{success:!1,error:o?.reason||`switch_tab failed for logical tab ${r}`,allowFallback:!0}}catch(o){return{success:!1,error:o?.message||"switch_tab failed",allowFallback:!0}}}case M.close_tab:try{return window.close(),{success:!0}}catch{return ui("close_tab failed in embed mode.","CAPABILITY_UNAVAILABLE")}default:return null}}shouldGuardExternalNavigation(t){return this.externalNavigationPolicy==="allow"?!1:!pn(t,this.allowedDomains)}shouldPreserveHostRuntime(t){if(this.crossHostPolicy!=="open_new_tab"||pn(t,this.allowedDomains))return!1;let n=mr(window.location.href),r=mr(t);return!n||!r?!1:n!==r}shouldConvertOpenNewTabToSameTab(t){return this.crossHostPolicy!=="same_tab"||!pn(window.location.href,this.allowedDomains)?!1:pn(t,this.allowedDomains)}isCrossHostInScopeNavigation(t){let n=mr(window.location.href),r=mr(t);return!n||!r||n===r?!1:pn(t,this.allowedDomains)}notifyAgentNavigation(t){try{this.onBeforeAgentNavigation?.(t)}catch{}}notifyCrossHostNavigation(t){if(this.isCrossHostInScopeNavigation(t))try{this.onBeforeCrossHostNavigation?.(t)}catch{}}shouldBlockForOutOfScopeContext(t){return this.externalNavigationPolicy==="allow"||ll.has(t)||Vf.has(t)?!1:!pn(window.location.href,this.allowedDomains)}getInterceptedClickTarget(t){let n=this.getClickTargetUrl(t);return n?this.shouldPreserveHostRuntime(n)?!pn(n,this.allowedDomains)&&this.externalNavigationPolicy==="block"?{targetUrl:n,reason:"Blocked same-tab navigation to an out-of-scope destination.",forceOpenInNewTab:!1}:{targetUrl:n,reason:"Opened in a new tab to preserve Rover runtime continuity across hostnames.",forceOpenInNewTab:!0}:this.externalNavigationPolicy==="allow"||pn(n,this.allowedDomains)?null:{targetUrl:n,reason:"Blocked same-tab navigation to an out-of-scope destination.",forceOpenInNewTab:!1}:null}getClickTargetUrl(t){let n=Cs(t);if(!n)return null;let{doc:r}=Mr(document,t.iframe_id),o=fn(r,n);if(!o)return null;let i=cl(o),s=i?.href||i?.getAttribute("href")||"";return li(s,window.location.href)}domainScopeBlockedResponse(t,n,r){let o=this.externalNavigationPolicy==="block"?"block":"open_new_tab_notice";return this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:o,reason:n,allowedDomains:this.allowedDomains,openedInNewTab:!1}),{success:!1,error:n,allowFallback:!0,output:{success:!1,error:{code:"DOMAIN_SCOPE_BLOCKED",message:n,missing:[],next_action:o==="block"?"Stay on the configured domain or update allowedDomains/domainScopeMode.":"Use open_new_tab to access external pages without losing context.",retryable:!1},blocked_url:t,current_url:window.location.href,policy_action:o,from_current_context:!!r?.fromCurrentContext},errorDetails:{code:"DOMAIN_SCOPE_BLOCKED",message:n,retryable:!1,details:{blockedUrl:t,currentUrl:window.location.href,policyAction:o}}}}emitNavigationGuardrail(t){try{this.onNavigationGuardrail?.(t)}catch{}}async openUrlInNewTab(t,n){let r=!pn(t,this.allowedDomains),o=this.snapshotKnownTabIds(),i=this.openVerifiedPopup(t),s;if(i.opened&&this.registerOpenedTab)try{s=(await this.registerOpenedTab({url:t,title:void 0,external:r,openerRuntimeId:this.runtimeId}))?.logicalTabId}catch{}if(i.opened&&!s&&(s=await this.reconcileOpenedTab(t,o)),!i.opened){let p=await this.reconcileOpenedTab(t,o);p&&(i={opened:!0,verified:!1},s=s||p)}let a=i.opened&&!s&&!!this.registerOpenedTab;if(!i.opened){let p="Browser popup settings blocked opening a new tab.";return n?.policyBlocked&&this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:"open_new_tab_notice",reason:n.reason||p,allowedDomains:this.allowedDomains,openedInNewTab:!1}),{success:!1,error:"open_new_tab blocked by browser popup settings",allowFallback:!0,output:{url:t,external:r,logicalTabId:s},errorDetails:{code:"POPUP_BLOCKED",message:p,retryable:!0,next_action:"Allow popups for this site and try again."}}}let u=n?.policyBlocked?n.reason||"Opened in a new tab due to domain policy.":void 0;n?.policyBlocked&&this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:"open_new_tab_notice",reason:u||"Opened in new tab due to domain policy.",allowedDomains:this.allowedDomains,openedInNewTab:!0});let m=[];return a&&m.push("Tab opened but registration failed; tab may not be targetable."),i.verified||m.push("Tab open was triggered, but browser did not return a popup handle."),{success:!0,output:{url:t,external:r,logicalTabId:s,openedInNewTab:!0,openVerification:i.verified?"verified":"unverified",policyBlocked:!!n?.policyBlocked,message:u,...m.length?{warning:m.join(" ")}:{}},allowFallback:!0}}openVerifiedPopup(t){let n=window.open("about:blank","_blank");if(n){try{n.opener=null}catch{}try{n.location.href=t}catch{}return{opened:!0,verified:!0}}try{let r=window.open(t,"_blank");if(r){try{r.opener=null}catch{}return{opened:!0,verified:!0}}}catch{}try{let r=window.open(t,"_blank","noopener,noreferrer");if(r){try{r.opener=null}catch{}return{opened:!0,verified:!0}}return{opened:!0,verified:!1}}catch{}try{let r=document.createElement("a");return r.href=t,r.target="_blank",r.rel="noopener noreferrer",r.style.display="none",document.body.appendChild(r),r.click(),r.remove(),{opened:!0,verified:!1}}catch{return{opened:!1,verified:!1}}}snapshotKnownTabIds(){let t=new Set;if(!this.listKnownTabs)return t;try{let n=this.listKnownTabs();for(let r of n){let o=Number(r?.logicalTabId);!Number.isFinite(o)||o<=0||t.add(o)}}catch{return t}return t}async reconcileOpenedTab(t,n){if(!this.listKnownTabs)return;let r=mr(t),o=Date.now()+2e3;for(;Date.now()<o;){try{let i=this.listKnownTabs();for(let s of i){let a=Number(s?.logicalTabId);if(!Number.isFinite(a)||a<=0||n.has(a))continue;let u=String(s?.url||"").trim();if(!u)return a;let m=mr(u);if(!r||!m||m===r)return a}}catch{}await new Promise(i=>setTimeout(i,120))}}async openElementInNewTab(t){let n=Cs(t);if(!n)return{success:!1,error:"click_element with open_in_new_tab requires element_id.",allowFallback:!0};let{doc:r}=Mr(document,t.iframe_id),o=fn(r,n);if(!o)return{success:!1,error:`click_element: element_id ${String(n)} not found.`,allowFallback:!0};let i=cl(o),s=i?.href||i?.getAttribute("href")||"",a=li(s,window.location.href);return a?await this.openUrlInNewTab(a,{policyBlocked:!1}):{success:!1,error:"click_element open_in_new_tab only works when target resolves to a valid link URL.",allowFallback:!0}}async waitForElement(t){let n=String(t.selector||"").trim(),r=Math.max(0,Math.min(Number(t.timeout??5e3),3e4));if(!n)return{success:!1,error:"wait_for_element: missing selector",allowFallback:!0};let o=Date.now(),i=document;for(;Date.now()-o<r;){let s=null;try{s=i.querySelector(n)}catch{s=null}if(s||(s=jf(i,n)),s)return{success:!0};await new Promise(a=>setTimeout(a,200))}return{success:!1,error:`wait_for_element: not found (${n})`,allowFallback:!0}}async describeImages(t){let n=ga(t);if(!n.length)return{success:!1,error:"describe_images: element_ids is empty",allowFallback:!1};let r=[],o=[];for(let i of n){let s=fn(document,i);if(!s){o.push(`element_id ${i} not found`);continue}try{let a=await Xf(s);if(!a?.data||!a?.mimeType){o.push(`element_id ${i}: unsupported image`);continue}r.push({element_id:i,...a})}catch(a){o.push(`element_id ${i}: ${a?.message||String(a)}`)}}return r.length?{success:!0,output:{images:r,errors:o.length?o:void 0}}:{success:!1,error:o[0]||"describe_images failed",output:{images:[],errors:o}}}ensureUploadProvider(){this.uploadProviderInstalled||(this.uploadProviderInstalled=!0,this.setUploadBytesProvider(async({token:t,byteLength:n})=>{this.pruneUploadStore();let r=this.uploadStore.get(t);if(!r)throw new Error("upload bytes token not found");if(r.bytes.byteLength!==n)throw new Error("upload bytes size mismatch");return r.bytes}))}pruneUploadStore(){let t=Date.now()-6e5;for(let[n,r]of this.uploadStore.entries())r.createdAt<t&&this.uploadStore.delete(n)}async buildUploadPayload(t){let n=String(t.file_url||"").trim();if(n)try{let r=await qc(0,n,document?.referrer||null),o=r.bytes,i=o.byteLength,s=r.mimeType||t.mime_type||"application/octet-stream",a=t.file_name||r.fileName,u=1024*1024;if(i<=u)return{kind:"upload_file",inlineB64:pl(o),byteLength:i,mimeType:s,fileName:a};this.ensureUploadProvider();let m=crypto.randomUUID();return this.uploadStore.set(m,{bytes:o,createdAt:Date.now()}),{kind:"upload_file",token:m,byteLength:i,mimeType:s,fileName:a,durable:!1}}catch{return}}};function qf(e){return e==="open_url_new_tab"?M.open_new_tab:String(e||"").trim()}function il(e){return e==="host_only"?"host_only":"registrable_domain"}function sl(e){return e==="allow"||e==="block"||e==="open_new_tab_notice"?e:"open_new_tab_notice"}function al(e){return e==="same_tab"||e==="open_new_tab"?e:"same_tab"}function As(e,t,n){let r=Array.isArray(e)?e:typeof e=="string"&&e.trim()?[e]:[],o=new Set;for(let i of r){let s=String(i||"").trim().toLowerCase().replace(/^\./,"");s&&o.add(s)}if(!o.size){let i=$f(t,n);i&&o.add(i)}return Array.from(o)}function $f(e,t){let n=String(e||"").trim().toLowerCase();if(!n)return"";if(n==="localhost"||/^\\d+\\.\\d+\\.\\d+\\.\\d+$/.test(n))return`=${n}`;if(t==="host_only")return`=${n}`;let r=n.split(".").filter(Boolean);return r.length<2?n:`${r[r.length-2]}.${r[r.length-1]}`}function li(e,t){let n=String(e||"").trim();if(!n)return null;try{return new URL(n,t).toString()}catch{return null}}function pn(e,t){let n=mr(e);if(!n)return!1;if(!t.length)return!0;for(let r of t)if(Wf(n,r))return!0;return!1}function mr(e){try{return new URL(e).hostname.toLowerCase()}catch{return null}}function Wf(e,t){let n=String(t||"").trim().toLowerCase().replace(/^\./,"");if(!n)return!1;if(n==="*")return!0;if(n.startsWith("=")){let r=n.slice(1);return!!r&&e===r}if(n.startsWith("*.")){let r=n.slice(2);return r?e===r||e.endsWith(`.${r}`):!1}return e===n?!0:e.endsWith(`.${n}`)}function cl(e){if(e instanceof HTMLAnchorElement&&e.href)return e;let t=e.closest?.("a[href]");return t instanceof HTMLAnchorElement&&t.href?t:null}function ui(e,t="CAPABILITY_UNAVAILABLE"){return{success:!1,error:e,allowFallback:!0,errorDetails:{code:t,message:e,retryable:!1}}}var ll=new Set([M.describe_images,M.wait_action,M.wait_for_element,M.answer_task,M.solve_captcha,M.network_run_recipe]),Vf=new Set([M.goto_url,M.google_search,M.go_back,M.go_forward,M.refresh_page,M.open_new_tab,M.switch_tab,M.close_tab]);function Gf(e){return{frameworks:(e.frameworks||[]).filter(n=>n in ji).map(n=>ji[n]),listenersRaw:e.listenersRaw??"",role:e.role??null,pattern:e.pattern,value:e.value??null}}async function ul(e){try{let n=(e.ownerDocument||document).defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",i=n[r]?.flushScan;if(typeof i=="function"){await i({mode:"priority",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:1500});return}n.rtrvrAIMarkInteractiveElements?.()}catch{}}function zf(e,t){if(t!==M.click_element)return"standard";let n=ir(e||"");if(!n)return"standard";let r=new Set(n.entries.map(u=>Nn[u.id]).filter(u=>typeof u=="string")),o=r.has("click")||r.has("mousedown")||r.has("mouseup")||r.has("pointerdown")||r.has("pointerup")||r.has("touchend");if((r.has("mouseenter")||r.has("mouseover")||r.has("pointerenter"))&&o)return"hover-activate";let s=r.has("touchstart"),a=r.has("touchend");return s&&a?"touch-sequence":"standard"}function pl(e){let t=new Uint8Array(e),n="",r=32768;for(let o=0;o<t.length;o+=r)n+=String.fromCharCode(...t.subarray(o,o+r));return btoa(n)}function dl(e){let t=Number(e);if(!Number.isFinite(t))return null;let n=Math.trunc(t);return n>0?n:null}function hl(e){let t=[];for(let n of _o){let r=e?.[n];if(r==null)continue;if(Array.isArray(r)){for(let i of r){let s=dl(i);s!=null&&t.push(s)}continue}let o=dl(r);o!=null&&t.push(o)}return Array.from(new Set(t))}function Yf(e){return hl(e).length>0}function Cs(e){let t=hl(e);return t.length?t[0]:null}function jf(e,t){let n=t.toLowerCase(),r=["button","a","input","textarea","select","label","[role]","div","span"],o=e.querySelectorAll(r.join(","));for(let i of Array.from(o))if((i.textContent||"").trim().toLowerCase().includes(n)||(i.getAttribute("aria-label")||"").toLowerCase().includes(n))return i;return null}async function Xf(e){if(e instanceof HTMLCanvasElement){let o=e.toDataURL(),i=ml(o);if(!i)throw new Error("canvas toDataURL failed");return i}if(e instanceof SVGElement){let o=new XMLSerializer().serializeToString(e);return{data:btoa(unescape(encodeURIComponent(o))),mimeType:"image/svg+xml",displayName:"svg"}}if(e instanceof HTMLImageElement){let o=e.currentSrc||e.src;return await fl(o,e.alt||e.getAttribute("aria-label")||void 0)}let n=window.getComputedStyle(e).backgroundImage||"",r=/url\\((['\"]?)(.*?)\\1\\)/.exec(n);if(r?.[2])return await fl(r[2],e.getAttribute("aria-label")||void 0);throw new Error("unsupported element")}function ml(e){let t=/^data:([^;]+);base64,(.*)$/.exec(e);return t?{mimeType:t[1],data:t[2]}:null}async function fl(e,t){if(!e)throw new Error("missing src");if(e.startsWith("data:")){let a=ml(e);if(!a)throw new Error("invalid data url");return{...a,displayName:t}}let n=await fetch(e,{mode:"cors"});if(!n.ok)throw new Error(`fetch failed (${n.status})`);let r=await n.blob(),o=await r.arrayBuffer(),i=pl(o),s=r.type||"image/png";return{data:i,mimeType:s,displayName:t}}function gl(e,t){e.onmessage=async n=>{let r=n.data;if(!r||r.t!=="req")return;let{id:o,method:i,params:s}=r;try{let a=t[i];if(!a)throw new Error(`No handler for ${i}`);let u=await a(s);e.postMessage({t:"res",id:o,ok:!0,result:u})}catch(a){e.postMessage({t:"res",id:o,ok:!1,error:{message:a?.message||String(a)}})}}}var Kf="Rover",Qf="https://www.rtrvr.ai/rover/mascot.mp4",Jf="https://www.rtrvr.ai/rover/mascot.webm";function El(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function bl(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function Zf(e){return e.status?e.status:e.kind==="tool_start"||e.kind==="plan"||e.kind==="thought"?"pending":e.kind==="tool_result"?"success":e.kind==="error"?"error":"info"}function ep(e){let t=String(e.title||"").trim().toLowerCase();return t.startsWith("running ")?`tool:${t.replace(/^running\s+/,"").trim()}`:t.endsWith(" completed")?`tool:${t.replace(/\s+completed$/,"").trim()}`:t==="run started"||t==="run resumed"||t==="run completed"?"run":e.kind==="status"?`status:${t||"status"}`:e.id||El("trace")}function ht(e){return String(e||"").trim()}function tp(e){let t=String(e||"").trim();return t?t.slice(0,64):Kf}function np(e){let t=String(e||"").trim();return t?t[0].toUpperCase():"R"}function rp(e){return String(e||"").replace(/[^a-zA-Z0-9]/g,"").slice(0,3).toUpperCase()||"RVR"}function yl(e){let t=ht(e),n=/^(Analyze|Route|Execute|Verify|Complete):\s*(.*)$/i.exec(t);if(!n)return{plainTitle:t};let r=n[1].toLowerCase(),o=ht(n[2]||t);return{stage:r,plainTitle:o||t}}function op(e){let t=(e.title||"").toLowerCase();if(t==="run started"||t==="run resumed"||t==="run completed"||t==="started new task"||t==="execution completed")return"detail";if(e.kind==="status"){let n=yl(e.title||"");if(n.stage==="analyze"||n.stage==="route"||n.stage==="complete")return"detail"}return"primary"}function Ns(e,t){let n=/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)|\*\*(.+?)\*\*/g,r=0,o;for(;(o=n.exec(t))!==null;){if(o.index>r&&e.appendChild(document.createTextNode(t.slice(r,o.index))),o[1]&&o[2]){let i=document.createElement("a");i.className="rvLink",i.href=o[2],i.target="_blank",i.rel="noopener noreferrer",i.textContent=o[1],e.appendChild(i)}else if(o[3]){let i=document.createElement("strong");i.textContent=o[3],e.appendChild(i)}r=o.index+o[0].length}r<t.length&&e.appendChild(document.createTextNode(t.slice(r)))}function Xn(e){let t=document.createDocumentFragment(),n=e.split(`
|
|
11
|
-
`),r=null;for(let o of n){let i=o.trim();if(!i){r&&(t.appendChild(r),r=null);continue}if(i==="---"){r&&(t.appendChild(r),r=null);let
|
|
12
|
-
`),o=0,i=0;for(let
|
|
13
|
-
`),
|
|
14
|
-
`),
|
|
2
|
+
"use strict";var __roverSDK=(()=>{var Lo=Object.defineProperty;var ku=Object.getOwnPropertyDescriptor;var Ru=Object.getOwnPropertyNames;var Su=Object.prototype.hasOwnProperty;var Au=(e,t,n)=>t in e?Lo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Cu=(e,t)=>{for(var n in t)Lo(e,n,{get:t[n],enumerable:!0})},Nu=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ru(t))!Su.call(e,o)&&o!==n&&Lo(e,o,{get:()=>t[o],enumerable:!(r=ku(t,o))||r.enumerable});return e};var Lu=e=>Nu(Lo({},"__esModule",{value:!0}),e);var W=(e,t,n)=>Au(e,typeof t!="symbol"?t+"":t,n);var Wh={};Cu(Wh,{boot:()=>Ro,close:()=>rs,endTask:()=>os,getState:()=>xa,hide:()=>Ta,identify:()=>ya,init:()=>Ea,installGlobal:()=>Iu,newTask:()=>Gr,open:()=>No,registerTool:()=>Ia,send:()=>_a,show:()=>wa,shutdown:()=>va,update:()=>Ji});var D;(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"})(D||(D={}));var Gh=new Set(Object.values(D)),Mo=["element_id","source_element_id","target_element_id","center_element_id","element_ids"],Mu=40;function Ra(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,Mu)}var Gt;(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"})(Gt||(Gt={}));var Sa={[Gt.Unknown]:"unknown",[Gt.React]:"react",[Gt.Vue]:"vue",[Gt.Angular]:"angular",[Gt.Svelte]:"svelte",[Gt.JQuery]:"jquery"},is={react:Gt.React,vue:Gt.Vue,angular:Gt.Angular,svelte:Gt.Svelte,jquery:Gt.JQuery},rt;(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"})(rt||(rt={}));var Yh={[rt.Other]:"other",[rt.Inline]:"inline",[rt.Delegated]:"delegated",[rt.React]:"react",[rt.Vue]:"vue",[rt.Angular]:"angular",[rt.Svelte]:"svelte",[rt.JQuery]:"jquery",[rt.Native]:"native"},Xh={inline:rt.Inline,delegated:rt.Delegated,react:rt.React,vue:rt.Vue,angular:rt.Angular,svelte:rt.Svelte,jquery:rt.JQuery,other:rt.Other,native:rt.Native},ge;(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"})(ge||(ge={}));var Do={[D.click_element]:ge.click_element,[D.type_into_element]:ge.type_into_element,[D.type_and_enter]:ge.type_and_enter,[D.select_dropdown_value]:ge.select_dropdown_value,[D.clear_element]:ge.clear_element,[D.focus_element]:ge.focus_element,[D.hover_element]:ge.hover_element,[D.right_click_element]:ge.right_click_element,[D.double_click_element]:ge.double_click_element,[D.long_press_element]:ge.long_press_element,[D.drag_element]:ge.drag_element,[D.drag_and_drop]:ge.drag_and_drop,[D.swipe_element]:ge.swipe_element,[D.adjust_slider]:ge.adjust_slider,[D.describe_images]:ge.describe_images,[D.scroll_to_element]:ge.scroll_to_element,[D.paste_text]:ge.paste_text,[D.check_field_validity]:ge.check_field_validity,[D.select_text]:ge.select_text,[D.mouse_wheel]:ge.mouse_wheel,[D.copy_text]:ge.copy_text,[D.upload_file]:ge.upload_file,[D.go_back]:ge.go_back,[D.go_forward]:ge.go_forward,[D.refresh_page]:ge.refresh_page,[D.press_key]:ge.press_key,[D.scroll_page]:ge.scroll_page,[D.wait_action]:ge.wait_action,[D.wait_for_element]:ge.wait_for_element,[D.pinch_zoom]:ge.pinch_zoom,[D.goto_url]:ge.goto_url,[D.google_search]:ge.google_search,[D.open_new_tab]:ge.open_new_tab,[D.switch_tab]:ge.switch_tab,[D.close_tab]:ge.close_tab,[D.solve_captcha]:ge.solve_captcha,[D.answer_task]:ge.answer_task,[D.dispatch_pointer_path]:ge.dispatch_pointer_path,[D.network_run_recipe]:ge.network_run_recipe},Aa=Object.fromEntries(Object.entries(Do).map(([e,t])=>[t,e]));function Oo(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 Na={semanticIdStart:1,interactiveIdStart:1,includeFrameContents:!0,clearIframes:!0,frameContextLabel:null,signalProvider:null,disableDomAnnotations:!1},At={...Na},Po=globalThis;function La(e){At={...Na,...e||{}}}function ar(){return At.signalProvider??null}function ut(){try{return typeof Po.document<"u"?Po.document:null}catch{return null}}function _n(){try{return typeof Po.window<"u"?Po.window:null}catch{return null}}function z(e,t){if(e&&typeof e=="object"){let n=e.ownerDocument;if(n)return n;if(e.nodeType===9)return e}return t??ut()??{}}function de(e,t){return z(e,t?t.document:null)?.defaultView??t??_n()??{}}function Y(e,t){return e?.defaultView??t??_n()??{}}function Bo(e,t){try{return e?.getElementById?.(t)??null}catch{return null}}function Ho(e,t){try{return e?.querySelector?.(t)??null}catch{return null}}function ss(e,t){try{return Array.from(e?.querySelectorAll?.(t)??[])}catch{return[]}}function Qr(e){try{return e.contentDocument||(e.contentWindow?.document??null)}catch{return null}}function Fo(e,t){let n=e.CSS?.escape;return typeof n=="function"?n(t):t.replace(/([^\w-])/g,"\\$1")}function zt(e,t){try{return e[t]}catch{return}}function xn(e,t){return!!e&&String(e.tagName||"").toUpperCase()===t.toUpperCase()}function Ma(e,t){let n=zt(t,"HTMLAnchorElement");return n?e instanceof n:xn(e,"A")}function nn(e,t){let n=zt(t,"HTMLInputElement");return n?e instanceof n:xn(e,"INPUT")}function pn(e,t){let n=zt(t,"HTMLTextAreaElement");return n?e instanceof n:xn(e,"TEXTAREA")}function Da(e,t){let n=zt(t,"HTMLLabelElement");return n?e instanceof n:xn(e,"LABEL")}function Oa(e,t){let n=zt(t,"HTMLSelectElement");return n?e instanceof n:xn(e,"SELECT")}function Ua(e,t){let n=zt(t,"HTMLSlotElement");return n?e instanceof n:xn(e,"SLOT")}function Pa(e,t){let n=zt(t,"HTMLButtonElement");return n?e instanceof n:xn(e,"BUTTON")}function Ba(e,t){let n=zt(t,"HTMLImageElement");return n?e instanceof n:xn(e,"IMG")}function Ha(e,t){let n=zt(t,"HTMLVideoElement");return n?e instanceof n:xn(e,"VIDEO")}function Fa(e,t){let n=zt(t,"HTMLCanvasElement");return n?e instanceof n:xn(e,"CANVAS")}function ot(e,t){if(!e||e.nodeType!==1)return!1;let n=zt(t,"HTMLElement");return n?e instanceof n:typeof e.tagName=="string"}function jt(e){return!!e&&e.nodeType===11&&typeof e.host=="object"&&typeof e.mode=="string"}function cr(e){if(!e||e.nodeType!==1)return!1;let t=z(e),r=Y(t).Element;return r?e instanceof r:typeof e.tagName=="string"}function Jr(e){if(!e||e.nodeType!==1)return!1;let t=z(e),r=Y(t).HTMLIFrameElement;return r&&e instanceof r?!0:String(e.tagName||"").toUpperCase()==="IFRAME"}function Du(e,t){if(!e)return!1;if(e.nodeType===9)return!0;let n=zt(t,"Document");return n?e instanceof n:!1}function Ou(e,t){if(!e)return!1;let n=zt(t,"Window");if(n)return e instanceof n;try{return e.window===e}catch{return!1}}function qo(e){try{return e.document}catch{return null}}function $o(e,t){if(Du(e,t))try{return e.documentElement}catch{return null}if(Ou(e,t)){let n=qo(e);if(!n)return null;try{return n.documentElement}catch{return null}}return null}function Uo(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 Ca(e,t,n){try{let r=z(t,n);return new URL(e,r.baseURI).href}catch{return e}}function Wo(e,t){let n=e.tagName.includes("-"),r=e.getAttribute("href")||e.getAttribute("src")||e.getAttribute("data")||e.getAttribute("action");if(r){let o=Ca(r,e,t);return o.trim().toLowerCase().startsWith("javascript:")?null:o}if(n)return null;try{let o=e,i=Uo(o.href)||Uo(o.src)||Uo(o.data)||Uo(o.action);return i?Ca(i,e,t):null}catch{return null}}var qa=["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"],Ce={};qa.forEach((e,t)=>{Ce[e]=t});var Bn={};qa.forEach((e,t)=>{Bn[t]=e});function lr(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,i]=r.split("~"),a=Number(o);if(!Number.isFinite(a))continue;let s=i&&parseInt(i,36)||0;n.push({id:a,mask:s})}return n.length?{entries:n}:null}function Uu(e){let t=lr(e);if(t){let n=new Set;for(let{id:r}of t.entries)n.add(r);return[...n]}return[]}function Zr(e){return Rr(e).map(n=>Bn[n]).filter(n=>!!n)}function Rr(e){let t=ar();if(t?.getEventHandlerIds)try{let o=t.getEventHandlerIds(e);if(o&&o.length)return o}catch{}let n=e.getAttribute(Kn),r=Uu(n);return!r||r.length===0?[]:r}var as=["media"],$a=new Set(as),cs=["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 Wa=new Set(cs),Hn=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"]),eo=new Set(["group","region","section","banner","contentinfo","main","navigation","complementary","form","article","document","presentation","none"]);var Va=["none","presentation"],Te;(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"})(Te||(Te={}));var Ga={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"]},to={heading:{selector:"h6,h1,h3,h2,h5,h4"},checkbox:{conditionalSelectors:[{selector:"input",conditions:[{type:Te.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:Te.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"grid"}]},{selector:"td",conditions:[{type:Te.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"treegrid"}]},{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:Te.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"treegrid"},{type:Te.HAS_TABLE_COLUMN_DATA,hasData:!0},{type:Te.HAS_TABLE_ROW_DATA,hasData:!0}]}]},slider:{conditionalSelectors:[{selector:"input",conditions:[{type:Te.PROPERTY_VALUE_MATCH,property:"type",values:["range"]}]}]},listitem:{selector:"li"},contentinfo:{conditionalSelectors:[{selector:"footer",conditions:[{type:Te.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:Te.PROPERTY_VALUE_MATCH,property:"type",values:["submit","reset","image","button"]}]}]},status:{selector:"output"},form:{conditionalSelectors:[{selector:"form",conditions:[{type:Te.HAS_ACCESSIBLE_NAME}]}]},article:{selector:"article"},textbox:{selector:"textarea",conditionalSelectors:[{selector:"input:not([list])",conditions:[{type:Te.PROPERTY_VALUE_MATCH,property:"type",values:["url","text","tel","email"]}]}]},radio:{conditionalSelectors:[{selector:"input",conditions:[{type:Te.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:Te.HAS_TABLE_ROW_DATA,hasData:!1}]}]},list:{selector:"ul,ol,menu"},region:{conditionalSelectors:[{selector:"section",conditions:[{type:Te.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:Te.PROPERTY_VALUE_MATCH,property:"type",values:["search"]}]}]},cell:{conditionalSelectors:[{selector:"td",conditions:[{type:Te.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"table"}]},{selector:'th:not([scope="rowgroup"]):not([scope="row"]):not([scope="colgroup"]):not([scope="col"])',conditions:[{type:Te.ANCESTOR_ROLE_REQUIRED,tag:"table",role:"table"},{type:Te.HAS_TABLE_COLUMN_DATA,hasData:!0},{type:Te.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:Te.HAS_TABLE_COLUMN_DATA,hasData:!1},{type:Te.HAS_TABLE_ROW_DATA,hasData:!0}]}]},dialog:{selector:"dialog"},listbox:{selector:"select[multiple],datalist",conditionalSelectors:[{selector:"select",conditions:[{type:Te.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:Te.PROPERTY_VALUE_MATCH,property:"type",values:["number"]}]}]},math:{selector:"math"},combobox:{selector:"select:not([size]):not([multiple])",conditionalSelectors:[{selector:"select:not([multiple])",conditions:[{type:Te.ATTRIBUTE_LESS_THAN,attribute:"size",value:2}]},{selector:"input[list]",conditions:[{type:Te.PROPERTY_VALUE_MATCH,property:"type",values:["url","text","tel","search","email"]}]}]},banner:{conditionalSelectors:[{selector:"header",conditions:[{type:Te.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"}},Kn="rtrvr-ls",Fn="rtrvr-ro",ls="rtrvr-mw-ready",no="rtrvr-mw-busy",us="rtrvr-mwa-ready",za=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"]),ja=["BUTTON","INPUT","METER","OUTPUT","PROGRESS","SELECT","TEXTAREA"],Ya=["h1","h2","h3","h4","h5","h6"],Xa="http://www.w3.org/1999/xhtml",Ka="http://www.w3.org/2000/svg",xt="rtrvr-label";var zo=new Set(["NOSCRIPT","SCRIPT","STYLE","META"]),ur="CODE",dr="PRE",Qa="aria-hidden",Ja="target";var Vo;(function(e){e[e.value=0]="value",e[e.alt=1]="alt",e[e.list=2]="list",e[e.title=3]="title"})(Vo||(Vo={}));var Sr;(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"})(Sr||(Sr={}));var Go;(function(e){e[e.VALUENOW=0]="VALUENOW",e[e.VALUETEXT=1]="VALUETEXT"})(Go||(Go={}));var ds=new Set([Ce.click,Ce.dblclick,Ce.doubleclick,Ce.contextmenu,Ce.auxclick,Ce.pointerdown,Ce.pointerup,Ce.mousedown,Ce.mouseup,Ce.touchstart,Ce.touchend,Ce.keydown,Ce.keyup,Ce.input,Ce.beforeinput,Ce.change,Ce.submit,Ce.reset,Ce.paste,Ce.dragstart,Ce.dragend,Ce.drop]),Za=new Set([...ds,Ce.scroll,Ce.wheel,Ce.mouseenter,Ce.mouseover,Ce.focus,Ce.blur,Ce.focusin,Ce.focusout]),jo=new Set(["click","dblclick","auxclick","contextmenu","mousedown","mouseup","pointerdown","pointerup","touchstart","touchend"]),fs=new Set(["input","change","beforeinput","keydown","keyup","keypress","paste","compositionstart","compositionend"]),ps=new Set(["drag","dragstart","dragend","dragenter","dragleave","dragover","drop"]);var Qn;(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"})(Qn||(Qn={}));var ro;(function(e){e[e.HTML=0]="HTML",e[e.SVG=1]="SVG"})(ro||(ro={}));var Yo;(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"})(Yo||(Yo={}));var Xo;(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"})(Xo||(Xo={}));var Mt;(function(e){e[e["rtrvr-label"]=0]="rtrvr-label",e[e.role=1]="role",e[e.value=2]="value",e[e.alt=3]="alt",e[e.list=4]="list",e[e.title=5]="title",e[e["aria-label"]=6]="aria-label",e[e["aria-labelledby"]=7]="aria-labelledby",e[e["aria-description"]=8]="aria-description",e[e["aria-describedby"]=9]="aria-describedby",e[e.disabled=10]="disabled",e[e.href=11]="href",e[e.placeholder=12]="placeholder",e[e.type=13]="type",e[e.tabindex=14]="tabindex",e[e.id=15]="id",e[e._ngcontent=16]="_ngcontent",e[e["ng-reflect-*"]=17]="ng-reflect-*",e[e["data-reactroot"]=18]="data-reactroot",e[e["data-v-*"]=19]="data-v-*",e[e.required=20]="required",e[e.contenteditable=21]="contenteditable",e[e.accept=22]="accept"})(Mt||(Mt={}));var vt;(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"})(vt||(vt={}));var qn;(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"})(qn||(qn={}));var Pu=[...cs,...Object.keys(to),...as],ec=[...new Set(Pu)],Ar={};ec.forEach((e,t)=>{Ar[e]=t});var oo={};ec.forEach((e,t)=>{oo[t]=e});var Ko=class{constructor(t=1){W(this,"currentId");this.currentId=t}generateId(){let t=this.currentId;return this.currentId++,t}initialize(t=1){this.currentId=t}getCurrentValue(){return this.currentId}};function io(e){let t=ar();if(t?.getRoleHint)try{let o=t.getRoleHint(e);if(o)return o}catch{}let n=e.getAttribute(Fn);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 i=oo[o];if(i)return i}}return r}function Cr(e){return Array.from(new Set(e))}function tc(e,t){if(!e||e.length===0)return Cr(t);let n=new Set([...e,...t]);return Cr(Array.from(n))}function Yt(e,t){let r=ar()?.getEventHandlerIds?.(e)??Rr(e),o=r.length>0&&r.some(s=>ds.has(s)),i=Qo(e),a=t?eo.has(t):!1;return{element:e,semanticRole:t,eventHandlerIndices:r,isEditableRegion:i,hasNodeWorthyHandlers:o,isLikelyStructuralContainer:a}}var Bu=new Set(["text","search","url","tel","password","email","number","date","datetime-local","time","month","week","color"]);function Hu(e){let n=de(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 Fu(e){let t=de(e);if(!nn(e,t))return!1;let n=(e.type||"text").toLowerCase();return Bu.has(n)?!e.disabled&&!e.readOnly:!1}function qu(e){let t=de(e);return pn(e,t)&&!e.disabled&&!e.readOnly}function $u(e){let t=e;return!(!t.isContentEditable||t.getAttribute("aria-readonly")==="true"||t.getAttribute("aria-disabled")==="true")}function Qo(e){return!e||!Hu(e)?!1:!!(Fu(e)||qu(e)||$u(e))}function so(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,i=e.slice(Math.max(0,o-30),o);if(/iframeRoot\s*=\s*$/.test(i)||i.includes("iframeRoot="))continue;let a=parseInt(r[1],10);if(Number.isFinite(a))return a}try{let o=e.match(LABEL_ID_PATTERN);if(o?.[1]){let i=parseInt(o[1],10);return Number.isFinite(i)?i:null}}catch{}return null}function ao(e){let t=String(e??"").replace(/[\n\r\t]/g," ").replace(/\s+/g," ").trim();return t=t.replace(/\[/g,"[").replace(/\]/g,"]"),t}function nc({element:e,elementID:t,frameContextLabel:n}){let r=!At.disableDomAnnotations,o=[`[id=${t}]`],i=de(e);if(Jr(e)){let l=ao(e.id||e.getAttribute("name")||"unnamed");o.push(`[iframe=${l}]`)}if(n){let l=ao(n);o.push(`[iframeRoot=${l}]`)}if(Ba(e,i)&&o.push(`[size=${e.clientWidth}x${e.clientHeight}]`),(Ha(e,i)||Fa(e,i))&&o.push(`[size=${e.clientWidth}x${e.clientHeight}]`),nn(e,i)||pn(e,i)){let l=Wu(e);o.push(...l)}e.getAttribute(Qa)==="true"&&o.push("[aria-hidden=true]"),e.disabled&&o.push("[disabled]"),r&&Ma(e,i)&&e.setAttribute(Ja,"_self");let s=o.join(" ");return r&&e.setAttribute(xt,s),s}function Wu(e){let t=[],n=de(e),r=nn(e,n);if(r&&e.type&&e.type!=="text"&&t.push(`[type=${e.type}]`),e.name){let o=ao(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=ao(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 i=ao(o).replace(/\\/g,"\\\\").replace(/"/g,'\\"');t.push(`[value="${i}"]`)}return t}var fr=new Ko,hs=new WeakMap;function rc(){hs=new WeakMap}function Jo(e){let t=hs.get(e);if(t)return t;let n=fr.generateId();return hs.set(e,n),n}var Zo=new Map,ms=new WeakMap;function oc(){Zo.clear(),ms=new WeakMap}function gs(e,t){try{typeof WeakRef<"u"?Zo.set(e,new WeakRef(t)):Zo.set(e,t)}catch{}}function co(e){let t=Zo.get(e);if(!t)return null;let n=t instanceof WeakRef?t.deref():t;return!n||n.isConnected===!1?null:n}function Jn(e){let t=null,n=Jo(e);if(At.frameContextLabel)t=At.frameContextLabel;else{let o=ut();if(o&&e.ownerDocument!==o)try{let a=e.ownerDocument?.defaultView?.frameElement?.getAttribute(xt)||"",s=a?so(a):null;t=s?String(s):null}catch{t=""}}let r=nc({element:e,elementID:n,frameContextLabel:t});if(gs(n,e),r)try{ms.set(e,r)}catch{}return r}function ic(e){return ms.get(e)??null}function bs(e,t){try{e.querySelectorAll?.(`[${xt}]`)?.forEach(r=>r.removeAttribute(xt))}catch{}if(t.includeShadow)try{let n=e.querySelectorAll?.("*");if(n)for(let r of Array.from(n))try{let o=r.shadowRoot;o&&bs(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=Qr(r);o?.body&&bs(o.body,t)}catch{}}catch{}}function sc(e,t={}){if(At.disableDomAnnotations)return;let n=cr(e)?de(e):Y(e)??window,r=$o(e,n)??e;if(r){try{r.removeAttribute?.(xt)}catch{}bs(r,{includeShadow:t.includeShadow??!0,includeIframes:t.includeIframes??!0})}}var In={},ys=new WeakMap,ei=new WeakSet;function ac(){In={},ys=new WeakMap,ei=new WeakSet,rc()}function It({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:i,originatedFromParent:a,elementContext:s}){let l=Jo(e);gs(l,e);let p=In[l];if(a){if(!p){let d={nodeCategory:e.nodeType,provisionalFromParent:!0},y=e.nodeName;y&&y.trim()&&(d.elementName=y);let I=e.getAttribute("role");I&&(d.preservedAttributes={1:I});let g=e.tagName;g&&(d.elementTag=g),In[l]=d}}else{if(p&&!p.provisionalFromParent){if((o||Nr(e))&&(p.isFrameElement=!0,i&&i.length>0&&(p.frameContent=i)),s){let{eventHandlerIndices:d,isEditableRegion:y}=s;if(d&&d.length>0){let I=Cr(d);I.length>0&&(p.eventHandlers=tc(p.eventHandlers,I))}y&&(p.isEditable=!0)}return l}if(ei.has(e))return l;ei.add(e);try{In[l]=cc({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:i,elementContext:s})}finally{ei.delete(e)}}return l}function lo(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 i=fr.generateId(),a={textContent:r,nodeCategory:e.nodeType};return o&&o!==r&&(a.rawData=o),In[i]=a,ys.set(e,i),i}function uc(e,t){let n=fc(e),{minY:r,maxY:o}=n.getCellBounds(t);return n.getRows().slice(r,o+1).some(i=>i.some(uo))}function dc(e,t){let n=fc(e),{minX:r,maxX:o}=n.getCellBounds(t);return n.getRows().some(i=>i.slice(r,o+1).some(uo))}var ni=class{constructor(t=[]){W(this,"cells");W(this,"getCellAt",(t,n)=>this.getRowAt(n)[t]);W(this,"setCellAt",(t,n,r)=>{this.getRowAt(n)[t]=r});W(this,"getRowAt",t=>(this.cells[t]===void 0&&(this.cells[t]=[]),this.cells[t]));W(this,"getRows",()=>this.cells);W(this,"getCellBounds",t=>{let n=this.columnCount,r=this.rowCount,o=-1,i=-1;for(let a=0;a<this.rowCount;a++){let s=this.getRowAt(a),l=s.indexOf(t);l!==-1&&(o=Math.max(o,s.lastIndexOf(t)),i=Math.max(i,a),n=Math.min(n,l),r=Math.min(r,a))}return{minX:n,minY:r,maxX:o,maxY:i}});W(this,"merge",t=>{this.cells=this.getRows().concat(t.getRows())});this.cells=t}get rowCount(){return this.cells.length}get columnCount(){return Math.max(...this.cells.map(t=>t.length))}};function fc(e){let n=de(e).TableGrid||ni,r=new n;e.tHead!==null&&r.merge(ti(e.tHead.rows)),Array.from(e.tBodies).forEach(i=>{r.merge(ti(i.rows))});let o=[];for(let i of Array.from(e.children))Es(i)&&pr(i,"tr")&&o.push(i);return r.merge(ti(o)),e.tFoot!==null&&r.merge(ti(e.tFoot.rows)),r}function ti(e){let t=new ni,n=[];for(let r=0;r<e.length;r++){let o=0;for(let i of Array.from(e[r].cells)){for(;t.getCellAt(o,r)||n[o];)!uo(t.getCellAt(o,r))&&n[o]&&t.setCellAt(o,r,n[o]),o++;for(let a=o;a<o+i.colSpan;a++){lc(i)===0&&(n[a]=i,t.setCellAt(a,r,i));for(let s=r;s<r+lc(i);s++)uo(t.getCellAt(a,s))||t.setCellAt(a,s,i)}o+=i.colSpan}for(let i=o;i<t.columnCount;i++){let a=n[i];a!==void 0&&!uo(t.getCellAt(i,r))&&t.setCellAt(i,r,a)}}return t}function lc(e){let t=e.getAttribute("rowSpan");if(t===null||t.trim()==="")return 1;let n=Number(t);return isNaN(n)?1:n}function uo(e){return e!==void 0&&pr(e,"td")}function hn(e){let t=e.tagName?.toLowerCase();if(t==="code"||t==="pre"){let r=Ju(e);if(r)return r}let n=pc(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"),i=e.querySelector("desc"),a=e.hasAttribute("aria-label"),s=e.hasAttribute("role");return o||i||a||s||Rr(e).length>0||e.getAttribute("tabindex")!==null?"img":null}if(Rr(e).length>0){let o=e.tagName.toLowerCase();if(["div","span","li","p","i","em","strong","b"].includes(o))return Vu(e)}}if(t==="td"&&e.getAttribute("role")===null)return"cell";if(n!==null&&t==="th"){let r=e.getAttribute("role");if(r&&hc(r))return r;let o=e;return o.scope==="col"||o.hasAttribute("aria-sort")?"columnheader":o.scope==="row"?"rowheader":"cell"}return n}function Vu(e){return io(e)??null}function pc(e){let t=e.getAttribute("role");if(t!==null)return Va.includes(t)||!hc(t)?null:t;let n=e.tagName.toLowerCase();return(Ga[n]??[]).find(o=>Gu(e,o))||null}function Gu(e,t){let n=to[t],r=n?.selector;if(r&&ri(e,r))return!0;let o=n?.conditionalSelectors;return o?o.some(a=>ri(e,a.selector)&&a.conditions.every(l=>ju(e,l))):!1}function zu(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let r=e.getRootNode?.();if(jt(r)){let o=de(e),i=`#${Fo(o,n)}`,a=Ho(r,i);if(a)return a}}catch{}return Bo(z(e),n)}function ju(e,t){switch(t.type){case Te.ATTRIBUTE_GREATER_THAN:{let n=e.getAttribute(t.attribute);return n!==null&&Number(n)>t.value}case Te.ATTRIBUTE_LESS_THAN:{let n=e.getAttribute(t.attribute);return n!==null&&Number(n)<t.value}case Te.HAS_ACCESSIBLE_NAME:return e.hasAttribute("aria-label")?!0:(e.getAttribute("aria-labelledby")||"").split(/\s+/).filter(Boolean).some(r=>zu(e,r)!=null);case Te.FORBIDDEN_ANCESTORS:return $n(e,t.selector)===null;case Te.BOOLEAN_PROPERTY:return e[t.property]===t.value;case Te.PROPERTY_VALUE_MATCH:return t.values.some(n=>n===e[t.property]);case Te.ANCESTOR_ROLE_REQUIRED:{let n=e.parentElement;if(n===null)return!1;let r=$n(n,t.tag);return r!==null&&pc(r)===t.role}case Te.HAS_TABLE_COLUMN_DATA:{let n=$n(e,"table");return n===null?!1:t.hasData===dc(n,e)}case Te.HAS_TABLE_ROW_DATA:{let n=$n(e,"table");return n===null?!1:t.hasData===uc(n,e)}default:return Yu(t),!1}}function Yu(e){throw new Error(`unexpected value ${e}!`)}function hc(e){return Ku(e)||Qu(e)||Xu(e)}function Xu(e){return $a.has(e)}function Ku(e){return Wa.has(e)}function Qu(e){return to.hasOwnProperty(e)}function Ju(e){if(e.tagName!==ur&&e.tagName!==dr)return null;if(Zr(e).some(r=>r==="click"||r==="copy"))return"button";let n=e.getAttribute("tabindex");return n!==null&&parseInt(n,10)>=0?"button":e.tagName===dr||e.tagName===ur&&e.closest("pre")?"code":null}var Zu={[vt.display]:[vt.beforeDisplay,vt.afterDisplay],[vt.content]:[vt.beforeContent,vt.afterContent]},vs=new Map,ed={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 td(e,t){if(!vs.has(e)){let n=ed[t]||t.replace(/([A-Z])/g,"-$1").toLowerCase();vs.set(e,n)}return vs.get(e)}var nd={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 bc(e,t,n){let r=nd[e];return r?r(t,n):t.trim()!==""&&!["initial","inherit","unset"].includes(t)}function yc(e){let t={},n=de(e);if(!ot(e,n))return t;let r=n.getComputedStyle(e),o=new Map([[vt.beforeDisplay,n.getComputedStyle(e,"::before")],[vt.afterDisplay,n.getComputedStyle(e,"::after")],[vt.beforeContent,n.getComputedStyle(e,"::before")],[vt.afterContent,n.getComputedStyle(e,"::after")]]);for(let i in vt)if(isNaN(Number(i))){let a=vt[i],s=td(a,i),l=Zu[a];l?((a===vt.display||a===vt.content)&&mc(r,s,a,i,t,e),gc(o.get(l[0]),s,l[0],"beforeContent",t),gc(o.get(l[1]),s,l[1],"afterContent",t)):mc(r,s,a,i,t,e)}return t}function mc(e,t,n,r,o,i){if(e){let a=e.getPropertyValue(t);a&&bc(r,a,i)&&(o[n]=a)}}function gc(e,t,n,r,o){if(e){let i=e.getPropertyValue(t);(t==="content"&&i&&i!=="none"&&i!=='""'&&i!=="''"||i&&bc(r,i))&&(o[n]=i)}}function hr(e,t){let n=de(e);if(!ot(e,n))return!0;if(t&&Hn.has(t))return!1;if(e.hasAttribute("hidden")||$n(e,"[hidden]")!==null||$n(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(),i=1e6;return Math.abs(o.left)>i||Math.abs(o.top)>i}function fo(e){return mn(e)&&e.classList.contains("jasmine_html-reporter")}function rd(e){let t=e.getAttribute("role");return t==="presentation"||t==="none"}function Ec(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).map(t=>t.replace(/^#/,"")):[]}function vc(e,t){let n=(t||"").trim().replace(/^#/,"");if(!n)return null;try{let o=e.getRootNode?.();if(jt(o)){let i=de(e),a=`#${Fo(i,n)}`,s=Ho(o,a);if(s)return s}}catch{}let r=z(e);return Bo(r,n)}function ws(e){let n=[];for(let r=0;r<arguments.length;r++){let o=arguments[r];if(Array.isArray(o))for(let i=0;i<o.length;i+=8192){let a=od(o,i,i+8192),s=ws.apply(null,a);for(let l=0;l<s.length;l++)n.push(s[l])}else n.push(o)}return n}function od(e,t,n){return arguments.length<=2?Array.prototype.slice.call(e,t):Array.prototype.slice.call(e,t,n)}function wc(e,t){return id(e,t).concat(sd(e))}function id(e,t){return ws(_s(e).map(r=>Sc(r)&&mn(r)?Tc(r,t):r))}function Tc(e,t){if(!e||hr(e,t))return[];if(!rd(e))return[e];let n=Array.from(e.children);return ws(n.map(r=>Tc(r,t)))}function _c(e){let t=Ec(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 i=vc(e,o);i&&i!==e&&n.push(i)}return n}function sd(e){let t=_c(e);for(let n of t)n["aria-owned-by"]=e;return t}function xc(e){let t=de(e),n=z(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)<=ud(e))return!1;let o=ad(e);return!o||!ld(o)||!fd(e)||o.getAttribute("role")==="dialog"||e.getAttribute("role")==="dialog"?!1:dd(e)}function ad(e){return[e.previousElementSibling,e.nextElementSibling,...Array.from(e.children),...e.parentElement?[e.parentElement.previousElementSibling,e.parentElement.nextElementSibling]:[]].filter(n=>n!==null).find(cd)||null}function cd(e){if(hr(e))return!1;let n=de(e).getComputedStyle(e);return(n?.position==="fixed"||n?.position==="absolute")&&n?.backgroundColor!=="rgba(0, 0, 0, 0)"&&n?.backgroundColor!=="transparent"&&n?.pointerEvents!=="none"}function ld(e){let t=de(e),n=e.getBoundingClientRect();return n.top<=0&&n.left<=0&&n.bottom>=t.innerHeight&&n.right>=t.innerWidth}function ud(e){let t=z(e),n=de(e),r=n?.getComputedStyle;if(!r)return 0;let o=ss(t,"*").filter(i=>i!==e&&!hr(i)).map(i=>parseInt(r.call(n,i)?.zIndex,10)).filter(i=>Number.isFinite(i)&&!isNaN(i));return o.length?Math.max(...o):0}function dd(e){return e.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])').length>0}function fd(e){let t=e.parentElement;if(!t)return!1;for(let n of Array.from(t.children))if(n!==e&&!hr(n)&&n.getAttribute("aria-hidden")!=="true")return!1;return!0}function pd(){try{let t=ut()?.querySelector?.("dialog:modal");return'[aria-modal="true"], dialog:modal'}catch{return'[aria-modal="true"]'}}var Ic=pd();function hd(e){return e.getAttribute("aria-disabled")==="true"||e.hasAttribute("disabled")}function Ts(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=z(e),r=new URL(t,n.baseURI);return r.protocol==="javascript:"&&(r.pathname.trim()!==""||r.search.trim()!==""||r.hash.trim()!=="")}catch{return!1}}function kc(e){return za.has(e)}function md(e){let t=e.parentElement,n=z(e);if(!(!t||t===n.body||t===n.documentElement))return It({targetElement:t,originatedFromParent:!0})}function cc({targetElement:e,parentDisabled:t,semanticRole:n,excludeLabels:r,isFrameNode:o,frameContentNodes:i,elementContext:a}){let s={nodeCategory:e.nodeType},l=t||hd(e),p=md(e);if(p&&(s.parent=p),n){let we=Ar[n];typeof we=="number"?s.semanticRole=we:s.semanticRole=n}if(l&&(s.isDisabled=!0),a){let{eventHandlerIndices:we,isEditableRegion:He}=a,Xe=Cr(we);Xe.length>0&&(s.eventHandlers=Xe),He&&(s.isEditable=!0)}let d=bd(e);d&&Object.keys(d).length>0&&(s.ariaProperties=d);let y=yd(e);y&&Object.keys(y).length>0&&(s.ariaStates=y);let I=e.nodeName;I&&I.trim()&&(s.elementName=I);let g=yc(e);g&&Object.keys(g).length>0&&(s.computedStyles=g),hr(e)&&(s.isInvisible=!0);let _=gd(e,n);_&&Object.keys(_).length>0&&(s.preservedAttributes=_),e.draggable&&(s.isDraggable=!0),e.scrollWidth&&e.clientWidth&&e.scrollWidth>e.clientWidth&&(s.supportsHorizontalSwipe=!0),e.scrollHeight&&e.clientHeight&&e.scrollHeight>e.clientHeight&&(s.supportsVerticalSwipe=!0);let x=e.getAttribute("class");if(x?.trim()){x.includes("handle")&&(s.isDragHandle=!0),s.supportsHorizontalSwipe||(x.includes("horizontal")||x.includes("carousel"))&&(s.supportsHorizontalSwipe=!0),s.supportsVerticalSwipe||(x.includes("vertical")||x.includes("feed"))&&(s.supportsVerticalSwipe=!0),x.includes("dismissible")&&(s.supportsDismissSwipe=!0),(x.includes("long-press")||x.includes("hold")||x.includes("press-hold"))&&(s.supportsLongPress=!0);let we=s.inputType||s.preservedAttributes?.[Mt.type];we==="submit"||we==="reset"||we==="clear"||(x.includes("submit")&&(s.preservedAttributes={...s.preservedAttributes||{},[Mt.type]:"submit"}),x.includes("clear")&&(s.preservedAttributes={...s.preservedAttributes||{},[Mt.type]:"clear"}),x.includes("reset")&&(s.preservedAttributes={...s.preservedAttributes||{},[Mt.type]:"reset"}))}let B=xd({element:e});B&&B.length>0&&(s.labelReferences=B);let j=e.tagName;if(j&&(s.elementTag=j),vd(e)&&(s.hasFocus=!0),!o){let we=xs({element:e,semanticRole:n,parentDisabled:l,excludeLabels:r});we&&we.length>0&&(s.childElements=we)}let F=Nd({element:e});F&&F.length>0&&(s.ownedElements=F);let U=Wo(e);U&&(s.resourceLocator=U),(o||Nr(e))&&(s.isFrameElement=!0),i&&i.length>0&&(s.frameContent=i);let q=e.type;q&&typeof q=="string"&&q.trim()&&(s.inputType=q);let J=e.placeholder;J&&typeof J=="string"&&J.trim()&&(s.placeholderText=J);let ae=e.value;ae&&typeof ae=="string"&&ae.trim()&&(s.elementValue=ae);let ue=Id({element:e,parentDisabled:t,semanticRole:n});if(ue&&ue.length>0&&(s.selectedOptions=ue),$n(e,"select,datalist")&&(s.nearestSelectList=!0),Es(e))s.elementNamespace=ro.HTML;else if(Ed(e)){s.elementNamespace=ro.SVG,s.svgStructure=wd(e);let we=Td(e);we&&Object.keys(we).length>0&&(s.preservedAttributes?s.preservedAttributes={...s.preservedAttributes,...we}:s.preservedAttributes=we)}let se=r?void 0:kd({element:e});se&&se.length>0&&(s.associatedLabels=se);let be=e.scope;be&&typeof be=="string"&&be.trim()&&(s.tableScope=be);let pe=Sd({element:e});pe&&(s.tableCaption=pe);let _e=Ad({element:e});_e&&(s.figureCaption=_e);let Ie=Cd({element:e});return Ie&&(s.fieldsetLegend=Ie),$n(e,"table")&&(s.nearestTable=!0),s}function gd(e,t){let n={},r=new Set(Object.values(Mt).filter(s=>typeof s=="string")),o=new Set(Object.keys(Vo).filter(s=>isNaN(Number(s)))),i=new Set(["_ngcontent","ng-reflect-*","data-v-*"]),a=e?.attributes?Array.from(e.attributes):[];for(let s of a){let l=s.name,p=s.value;if(l==="id"&&(!t||!Hn.has(t)))continue;let d;if(r.has(l)?d=l:l.startsWith("data-v-")?d="data-v-*":l.startsWith("ng-reflect-")?d="ng-reflect-*":l.startsWith("_ngcontent")&&(d="_ngcontent"),d){let y=p.trim()!=="",I=o.has(d);if(y||I){let g=Mt[d],_=i.has(d)?"true":p;n[g]=_}}}if(!n[Mt[xt]]){let s=ic(e);s&&(n[Mt[xt]]=s)}return n}function bd(e){return Rc(e,Yo,Go)}function yd(e){return Rc(e,Xo,null)}function Rc(e,t,n){let r={};for(let o in t)if(isNaN(Number(o))){let i=t[o],s=`aria-${o.toLowerCase().replace(/_/g,"-")}`,l=e.getAttribute(s),p=!1;n!==null&&(p=Object.values(n).filter(y=>typeof y=="number").includes(i)),e.hasAttribute(s)&&p||l?.trim()?r[i]=l:s==="aria-level"&&Ya.includes(e.tagName.toLowerCase()?.trim())&&(r[i]=e.tagName.substring(1))}return r}function mn(e){return Sc(e)&&e.nodeType===Qn.ELEMENT}function oi(e){return e.nodeType===Qn.TEXT}function Sc(e){let t=typeof e;return t=="object"&&e!=null||t=="function"}function Es(e){return mn(e)&&(!e.namespaceURI||e.namespaceURI===Xa)}function Ed(e){return mn(e)&&e.namespaceURI===Ka}function Nr(e){return e.tagName==="IFRAME"}function pr(e,t){return"tagName"in e?e.tagName?.toLowerCase()===t:e.elementTag?.toLowerCase()===t}function $n(e,t){if(e.closest)return e.closest(t);for(;!ri(e,t);){if(e.parentElement===null)return null;e=e.parentElement}return e}function ri(e,t){return e.matches?.(t)??e.msMatchesSelector?.(t)??e.webkitMatchesSelector(t)}function vd(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 wd(e){let t={},n=qn.text,r=qn.elText;e.textContent?.trim()&&(t[n]=e.textContent);let o=e.querySelector("title"),i=e.querySelector("img");o?.textContent?.trim()?t[r]=o.textContent:i?.alt?.trim()&&(t[r]=i.alt);let a=e.getAttribute("viewBox");a&&(t[qn.viewBox]=a);let s=e.querySelectorAll("path");s.length>0&&(t[qn.paths]=s.length,t[qn.pathData]=Array.from(s).slice(0,3).map(p=>p.getAttribute("d")).filter(Boolean).map(p=>p.substring(0,100)));let l={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(l).forEach(([p,d])=>{if(d>0){let y=qn[p];t[y]=d}}),Object.keys(t).length>0?t:void 0}function Td(e){let t={};if(!e?.hasAttributes())return t;for(let n of Object.values(Sr).filter(r=>typeof r=="number")){let r=Sr[n];if(r){let o=r;if(Sr.hasOwnProperty(o)&&e.hasAttribute(o)){let i=e.getAttribute(o);i?.trim()&&(t[n]=i)}}}return t}function _d({frameElement:e,parentDisabled:t,excludeLabels:n}){if(!At.includeFrameContents)return[];let r=null;try{r=e.contentWindow?.document?.body||null}catch{return[]}if(!r)return[];let o=[];for(let i of _s(r))if(!(fo(i)||Ac(i))){if(mn(i)){let a=i,s=hn(a),l=Yt(a,s),{shouldCreate:p,shouldAnnotate:d}=ii(l);if(p){d&&Jn(a);let y=It({targetElement:a,parentDisabled:t,semanticRole:s??void 0,excludeLabels:n,elementContext:l});y&&o.push(y)}else{let y=xs({element:a,semanticRole:s??void 0,parentDisabled:t,excludeLabels:n});o.push(...y)}}else if(oi(i)){let a=lo(i);a&&o.push(a)}}return o}function _s(e){let t=de(e);if(Ua(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||ar()?.getShadowRoot?.(e)||null;if(n){let r=Array.from(n.childNodes),o=Array.from(e.childNodes).filter(i=>!i.assignedSlot);return r.concat(o)}}catch{}return Array.from(e.childNodes)}function xs({element:e,semanticRole:t,parentDisabled:n,excludeLabels:r}){let o=[];for(let i of _s(e))if(!(fo(i)||Ac(i))){if(mn(i)){let a=i,s=hn(a),l=Yt(a,s);if(Nr(a)){Jn(a);let y=_d({frameElement:a,parentDisabled:n,excludeLabels:r}),I=It({targetElement:a,parentDisabled:n,semanticRole:s??void 0,excludeLabels:r,isFrameNode:!0,frameContentNodes:y,elementContext:l});I&&o.push(I);continue}let{shouldCreate:p,shouldAnnotate:d}=ii(l);if(p){d&&Jn(a);let y=It({targetElement:a,parentDisabled:n,semanticRole:s??void 0,excludeLabels:r,elementContext:l});y&&o.push(y)}else{let y=xs({element:a,semanticRole:s??void 0,parentDisabled:n,excludeLabels:r});o.push(...y)}}else if(oi(i)){let a=lo(i);a&&o.push(a)}}return o}function xd({element:e}){let t=Ec(e.getAttribute("aria-labelledby")),n=new Set;for(let r of t){let o=vc(e,r);if(!(!o||o===e)&&o){let i=hn(o),a=It({targetElement:o,semanticRole:i,elementContext:Yt(o,i)});n.add(a)}}return Array.from(n)}function Id({element:e,parentDisabled:t,semanticRole:n}){let r=[];return e&&(n&&n==="listbox"?r=Array.from(e.querySelectorAll('[role="option"][aria-selected="true"]')).map(o=>It({targetElement:o,parentDisabled:t,semanticRole:"option",elementContext:Yt(o,"option")})):pr(e,"select")&&(r=Array.from(e.selectedOptions).map(o=>It({targetElement:o,parentDisabled:t,semanticRole:"option",elementContext:Yt(o,"option")})))),r}function kd({element:e}){if(ja.includes(e.tagName)){let t=z(e),n=ss(t,"label"),r=new Set;return Array.from(n).filter(o=>o!==e&&Rd(o,e)).map(o=>{let i=hn(o),a=It({targetElement:o,semanticRole:i,excludeLabels:!0,elementContext:Yt(o,i)});r.add(a)}),Array.from(r)}}function Rd(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 Sd({element:e}){if(pr(e,"table")){let t=e.querySelector("caption");if(t&&t!==e){let n=hn(t);return It({targetElement:t,semanticRole:n,elementContext:Yt(t,n)})}}}function Ad({element:e}){if(pr(e,"figure")){let t=e.querySelector("figcaption");if(t&&t!==e){let n=hn(t);return It({targetElement:t,semanticRole:n,elementContext:Yt(t,n)})}}}function Cd({element:e}){if(pr(e,"fieldset")){let t=e.querySelector("legend");if(t&&t!==e){let n=hn(t);return It({targetElement:t,semanticRole:n,elementContext:Yt(t,n)})}}}function Nd({element:e}){let t=new Set,n=_c(e);for(let r of n){let o=hn(r),i=It({targetElement:r,semanticRole:o,elementContext:Yt(r,o)});t.add(i)}return Array.from(t)}function ii(e){let{semanticRole:t,eventHandlerIndices:n,isEditableRegion:r,hasNodeWorthyHandlers:o,isLikelyStructuralContainer:i}=e,a=n.length>0&&n.some(y=>Za.has(y)),l=!!t||!i&&(o||r),p=!!t&&Hn.has(t);return{shouldCreate:l,shouldAnnotate:l&&(p||r||a)}}function Ac(e){if(!mn(e))return!1;let t=e,n=t.tagName;return zo.has(n)?!0:n===ur||n===dr?Ld(t):!1}function Ld(e){let t=de(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 La(t),ac(),oc(),sc(e,{includeShadow:!0,includeIframes:At.clearIframes}),fr.initialize(At.semanticIdStart),{rootNodes:Cc(e),semanticNodes:In}}function Cc(e){let t=[];try{let n=z(e),o=Array.from(n.querySelectorAll(Ic)).filter(i=>!hr(i)&&xc(i));if(o.length===0)t=Lr({targetElement:e});else if(o.length===1){let i=o[0];i.contains(e)?t=Lr({targetElement:e}):e.contains(i)?t=Lr({targetElement:i}):t=Lr({targetElement:e})}else t=Lr({targetElement:e})}catch(n){throw console.error("Error constructing semantic tree",n),n}return t}function Lr({targetElement:e,parentNode:t}){if(fo(e)||Nc(e))return[];let n=hn(e),r=Yt(e,n);if(Nr(e))return[Dd({frameElement:e,role:n,parentNode:t,elementContext:r})];let o=0,{shouldCreate:i,shouldAnnotate:a}=ii(r);i&&(a&&Jn(e),o=It({targetElement:e,parentDisabled:t?.isDisabled,semanticRole:n,elementContext:r}));let s=In[o],l=Md(e,n,o?s:t);return o&&l.length>0&&(s.semanticChildren=l),o?[o]:l}function Md(e,t,n){let r=[],o=wc(e,t);for(let i of o)if(!(fo(i)||Nc(i))){if(mn(i)){let a=Lr({targetElement:i,parentNode:n});r.push(...a)}else if(oi(i)&&Bd(i,n)){let a=lo(i);a&&r.push(a)}}return r}function Dd({frameElement:e,role:t,parentNode:n,elementContext:r}){Jn(e);let o=Od(e);return It({targetElement:e,parentDisabled:n?.isDisabled,semanticRole:t,isFrameNode:!0,frameContentNodes:o,elementContext:r})}function Od(e){if(!At.includeFrameContents)return[];let t=Ud(e);return t.kind==="content"?Cc(t.rootElement):Pd(e,t.reason)}function Ud(e){let t=null;try{t=e.contentDocument||e.contentWindow?.document||null}catch{return{kind:"unavailable",reason:"cross_origin_blocked"}}let n=t?.body||t?.documentElement||null;return n?{kind:"content",rootElement:n}:{kind:"unavailable",reason:"iframe_not_ready_or_empty"}}function Pd(e,t){let n=fr.generateId(),r=fr.generateId(),o=e.getAttribute("title")?.trim()||e.getAttribute("name")?.trim()||e.id?.trim()||"Embedded frame",i=Wo(e)||void 0,a=t==="cross_origin_blocked"?"Iframe content is not accessible from this origin (cross-origin).":"Iframe content is not ready yet or has no readable DOM.";return In[n]={nodeCategory:Qn.ELEMENT,semanticRole:"embedded_document_unavailable",computedName:o,syntheticKind:"embedded_container",frameContent:[r],...i?{resourceLocator:i}:{}},In[r]={nodeCategory:Qn.TEXT,parent:n,textContent:a,preventTextMerge:!0,syntheticKind:"embedded_unavailable_text"},[n]}function Bd(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"?oo[t.semanticRole]:t.semanticRole;if(kc(r))return!1}return!0}function Nc(e){if(!mn(e))return!1;let t=e,n=t.tagName;return zo.has(n)?!0:n===ur||n===dr?Hd(t):!1}function Hd(e){let t=de(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 ai(e){let t=e.activeElement;for(;t&&t.shadowRoot&&t.shadowRoot.activeElement;)t=t.shadowRoot.activeElement;return t}function Fd(e){let t=e.getBoundingClientRect();return{x:t.left+t.width/2,y:t.top+t.height/2}}function Dr(e,t,n){let r=z(e,t),o=Y(r,n);try{e.focus?.({preventScroll:!0})}catch{}if(ai(r)===e)return!0;try{let{x:i,y:a}=Fd(e),s=o.PointerEvent||PointerEvent,l=o.MouseEvent||MouseEvent;e.dispatchEvent(new s("pointerdown",{bubbles:!0,cancelable:!0,composed:!0,clientX:i,clientY:a,buttons:1,button:0,pointerType:"mouse"})),e.dispatchEvent(new l("mousedown",{bubbles:!0,cancelable:!0,composed:!0,clientX:i,clientY:a,buttons:1,button:0})),e.dispatchEvent(new l("mouseup",{bubbles:!0,cancelable:!0,composed:!0,clientX:i,clientY:a,buttons:0,button:0})),e.dispatchEvent(new s("pointerup",{bubbles:!0,cancelable:!0,composed:!0,clientX:i,clientY:a,buttons:0,button:0,pointerType:"mouse"})),(e.isContentEditable||nn(e,o)||pn(e,o)||e.getAttribute("contenteditable")==="true")&&e.dispatchEvent(new l("click",{bubbles:!0,cancelable:!0,composed:!0,clientX:i,clientY:a,button:0}))}catch{}try{e.focus?.({preventScroll:!0})}catch{}return ai(r)===e}function po(e,t){let n=de(e),r=pn(e,n)?n.HTMLTextAreaElement.prototype:n.HTMLInputElement.prototype,o=Object.getOwnPropertyDescriptor(r,"value");o?.set?o.set.call(e,t):e.value=t}function gr(e,t,n="insertText"){let r=de(e),o=r.InputEvent||(typeof InputEvent<"u"?InputEvent:null),i=r.Event||Event;try{o?e.dispatchEvent(new o("beforeinput",{bubbles:!0,cancelable:!0,composed:!0,data:String(t??""),inputType:n})):e.dispatchEvent(new i("beforeinput",{bubbles:!0,cancelable:!0,composed:!0}))}catch{try{e.dispatchEvent(new i("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 i("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{try{e.dispatchEvent(new i("input",{bubbles:!0,cancelable:!1,composed:!0}))}catch{}}try{e.dispatchEvent(new i("change",{bubbles:!0,cancelable:!0,composed:!0}))}catch{}}function qd(e){let n=de(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)),i=e.dispatchEvent(new n("keypress",r)),a=e.dispatchEvent(new n("keyup",r));return{canceled:!(o&&i&&a)}}function mr(e){if(!e)return!1;let t=de(e);if(pn(e,t))return!e.disabled&&!e.readOnly;if(nn(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 ks(e){let t=de(e);if(!e||!ot(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 $d(e,t){let n=e.getRootNode();return jt(n)?n:z(e)??t}function Wd(e,t){let n=[];for(let r of t.split(/\s+/).filter(Boolean)){let o=e.getElementById?.(r)||e.querySelector?.(`#${CSS.escape(r)}`),i=de(o);ot(o,i)&&n.push(o)}return n}function Oc(e,t){if(!e)return{kind:"none",el:null,via:"no-root"};if(mr(e))return{kind:"input",el:e,via:"self-input"};if(ks(e))return{kind:"contenteditable",el:e,via:"self-contenteditable"};let n=z(e)??t,r=Y(n),o=$d(e,n);if(Da(e,r)){let l=e.control;if(mr(l))return{kind:"input",el:l,via:"label.control"};let p=e.htmlFor;if(p){let d=o.getElementById?.(p)||o.querySelector?.(`#${CSS.escape(p)}`);if(mr(d))return{kind:"input",el:d,via:"label.for"}}}let i=e.getAttribute("aria-controls")||e.getAttribute("aria-owns");if(i)for(let l of Wd(o,i)){if(mr(l))return{kind:"input",el:l,via:"aria-controls/owns"};if(ks(l))return{kind:"contenteditable",el:l,via:"aria-controls/owns"};let p=l.querySelector?.("input,textarea");if(mr(p))return{kind:"input",el:p,via:"aria-controls->desc"}}let a=e.querySelector?.("input,textarea");if(mr(a))return{kind:"input",el:a,via:"descendant"};let s=e.shadowRoot||null;if(s){let l=s.querySelector?.("input,textarea");if(mr(l))return{kind:"input",el:l,via:"open-shadow-input"};let p=s.querySelector?.('[contenteditable="true"],[contenteditable=""],[role="textbox"]');if(ks(p))return{kind:"contenteditable",el:p,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 Mr(e,t,n,r=!1){let o=z(e,t),a=Y(o,n).getSelection?.();if(!a)return!1;try{let s=o.createRange();return s.selectNodeContents(e),r&&s.collapse(!1),a.removeAllRanges(),a.addRange(s),!0}catch{return!1}}function br(e){return(e.textContent??"").replace(/\u00A0/g," ").trim()}var si=e=>String(e??"").replace(/\s+/g," ").trim(),Uc=new MessageChannel,Pc=[];Uc.port1.onmessage=()=>{let e=Pc.shift();e&&e()};function Lc(){return new Promise(e=>{Pc.push(e),Uc.port2.postMessage(0)})}async function Mc(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 Lc():await new Promise(i=>{try{t.requestAnimationFrame(()=>i())}catch{Lc().then(i)}})}function Vd(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 Dc(e,t,n,r){let o=z(e,t),a=Y(o,n).KeyboardEvent||KeyboardEvent,s=String(r??"");for(let l of s){let{code:p,which:d}=Vd(l),y={key:l,code:p,bubbles:!0,cancelable:!0,composed:!0,keyCode:d,which:d};e.dispatchEvent(new a("keydown",y)),e.dispatchEvent(new a("keypress",y)),e.dispatchEvent(new a("keyup",y))}}async function Bc(e,t,n,r,o){let i=String(r??"");if(e.disabled||e.readOnly)return{success:!1,method:"type-native-setter",details:"disabled_or_readonly",allowFallback:!0};let a=String(e.value??""),s=z(e,t),l=Y(s,n),p=Dr(e,s,l),d=Number.isFinite(Number(o?.settleFrames))?Math.max(0,Math.min(4,Number(o?.settleFrames))):s.hidden?1:2,y=!!o?.useKeyFallback,I=Number.isFinite(Number(o?.keyFallbackMaxLen))?Number(o?.keyFallbackMaxLen):140,g=y&&i.length>0&&i.length<=I;po(e,i),gr(e,i,"insertReplacementText"),g&&Dc(e,s,l,i),await Mc(s,l,d);let _=String(e.value??""),x=si(a),B=si(_),j=si(i),F=x===j,U=B===j,q=_!==a,J=i.length>0&&!F&&_===a,ae=1;if(!F&&!U&&!q){ae=2;try{e.focus?.({preventScroll:!0}),e.select?.()}catch{}let pe=!1;try{s.execCommand?.("selectAll",!1,void 0),pe=!!s.execCommand?.("insertText",!1,i)}catch{pe=!1}if(!pe)try{po(e,i)}catch{}try{gr(e,i,"insertReplacementText")}catch{}g&&Dc(e,s,l,i),await Mc(s,l,d),_=String(e.value??"")}let he=si(_)===j,se=_!==a;J=i.length>0&&!F&&_===a;let be=F||he||se;return{success:be,method:"type-native-setter",details:`focus=${p};attempts=${ae};settleFrames=${d};beforeLen=${a.length};afterLen=${_.length};changed=${se};alreadyCorrect=${F};nowCorrect=${he};reverted=${J};keyFallback=${g}`,allowFallback:be?void 0:!0}}function Gd(e,t,n){let o=de(e).InputEvent||InputEvent,i=new o("beforeinput",{bubbles:!0,cancelable:!0,composed:!0,data:t,inputType:n});return{ok:e.dispatchEvent(i),defaultPrevented:i.defaultPrevented}}function Hc(e,t,n,r){let o=z(e,n),i=Y(o,r),a=i.InputEvent||InputEvent,s=i.Event||Event,l=String(t??""),p=br(e),d=Dr(e,o,i),y=Mr(e,o,i,!0),I=Gd(e,l,"insertText"),g=!1,_="execCommand",x=!1,B=()=>{x=!0};try{e.addEventListener("input",B,{capture:!0})}catch{}if(I.ok&&!I.defaultPrevented)try{g=!!o.execCommand?.("insertText",!1,l)}catch{}if(!g)try{let U=i.getSelection?.(),q=U&&U.rangeCount?U.getRangeAt(0):null;if(!q||!e.contains(q.commonAncestorContainer)){Mr(e,o,i,!0);let J=i.getSelection?.();q=J&&J.rangeCount?J.getRangeAt(0):null}q&&(q.insertNode(o.createTextNode(l)),q.collapse(!1),U?.removeAllRanges(),U?.addRange(q),g=!0,_="range")}catch{}if(g&&!x){try{e.dispatchEvent(new a("input",{bubbles:!0,cancelable:!1,composed:!0,data:l,inputType:"insertText"}))}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{}}try{e.removeEventListener("input",B,{capture:!0})}catch{}let j=br(e);return{success:j!==p||!!l&&j.includes(l),method:`type-contenteditable-${_}`,details:`focus=${d};selectedWithin=${y};inserted=${g}`}}function Fc(e){let{canceled:t}=qd(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 qc(e,t,n){if(e.disabled||e.readOnly)return{success:!1,method:"clear-native-setter",details:"disabled_or_readonly",allowFallback:!0};let r=z(e,t),o=Y(r,n),i=String(e.value??""),a=Dr(e,r,o);po(e,""),gr(e,"","deleteByCut");let s=String(e.value??""),l=s!==i;return{success:l||s.length===0,method:"clear-native-setter",details:`focus=${a};beforeLen=${i.length};afterLen=${s.length};changed=${l}`}}function $c(e,t,n){let r=z(e,t),o=Y(r,n),i=br(e),a=Dr(e,r,o),s=Mr(e,r,o,!1),l=!1,p="execCommand";try{l=!!r.execCommand?.("delete",!1,void 0)}catch{l=!1}if(!l)try{let g=o.getSelection?.(),_=g&&g.rangeCount?g.getRangeAt(0):null;(!_||!e.contains(_.commonAncestorContainer))&&Mr(e,r,o,!1);let x=o.getSelection?.(),B=x&&x.rangeCount?x.getRangeAt(0):null;B&&(B.deleteContents(),B.collapse(!1),x?.removeAllRanges(),x?.addRange(B),l=!0,p="range")}catch{}if(!l)try{e.textContent="",l=!0,p="textContent"}catch{}gr(e,"","deleteByCut");let d=br(e),y=d!==i;return{success:l||y||d.length===0,method:`clear-contenteditable-${p}`,details:`focus=${a};selectedWithin=${s};cleared=${l};changed=${y}`}}function Wc(e,t){if(e===t||e.contains(t))return!0;let n=t;for(;n;){let r=n.getRootNode?.();if(jt(r)){let o=r.host;if(o===e||e.contains(o))return!0;n=o;continue}n=n.parentNode||null}return!1}var ci;(function(e){e.FLASH_LITE="Gemini Flash Lite",e.FLASH="Gemini Flash",e.PRO="Gemini Pro"})(ci||(ci={}));var Vc;(function(e){e[e.NativeHostConnected=0]="NativeHostConnected",e[e.NativeHostDisconnected=1]="NativeHostDisconnected"})(Vc||(Vc={}));var zd=["image/png","image/jpeg","image/webp"],jd=["application/pdf","text/plain"],Ag=[...zd,...jd];var wt;(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"})(wt||(wt={}));var ft;(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"})(ft||(ft={}));var Cg={[wt.ACT]:ft.AGENTIC_SEEK,[wt.CRAWL]:ft.CRAWL_PAGES,[wt.EXTRACT]:ft.EXTRACT_PAGE,[wt.SHEETS_WORKFLOW]:ft.SHEETS_WORKFLOW,[wt.INFER_SHEET_DATA]:ft.INFER_SHEET_DATA,[wt.PDF_FILLER]:ft.PDF_FILLER,[wt.CUSTOM_TOOL_GENERATOR]:ft.CUSTOM_TOOL_GENERATOR,[wt.WEBPAGE_GENERATOR]:ft.WEBPAGE_GENERATOR,[wt.GOOGLE_DOC_GENERATOR]:ft.GOOGLE_DOC_GENERATOR,[wt.GOOGLE_SLIDES_GENERATOR]:ft.GOOGLE_SLIDES_GENERATOR,[wt.PROCESS_TEXT]:ft.PROCESS_TEXT,[wt.CREATE_SHEET_FROM_DATA]:ft.CREATE_SHEET_FROM_DATA,[wt.EXECUTE_MULTIPLE_TOOLS]:ft.EXECUTE_MULTIPLE_TOOLS,[wt.CONFIGURE_API_KEY]:ft.CONFIGURE_API_KEY,[wt.QUERY_RTRVR_AI_DOCUMENTATION]:ft.QUERY_RTRVR_AI_DOCUMENTATION};var Rs=200;var Ng=ci.FLASH;var Lg=ft.PLANNER;var Ss="application/pdf",As="application/gsheet";var Mg=20*1024*1024;var li={maxParallelTabs:4,pageLoadDelay:2e3,disableAutoScroll:!1,makeNewTabsActive:!1,writeRowProcessingTime:!1,totalBudgetMs:25e3,pageDataTimeoutMs:22e3,pdfTextSelectionTimeoutMs:12e3,onlyTextContent:!1};var Yd=1,Xd=9,Kd=11,Ns="application/gdoc",Or="text/html",ui="text/plain";function Qd(e){return!!e&&typeof e=="object"&&e.nodeType===Xd}function Gc(e){return!!e&&typeof e=="object"&&e.nodeType===Yd}function Jd(e){return!!e&&typeof e=="object"&&e.nodeType===Kd&&typeof e.host=="object"&&typeof e.mode=="string"}function zc(e){return Gc(e)&&String(e.tagName).toUpperCase()==="IFRAME"}function Cs(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 Zd(e){try{let t=e.shadowRoot;return t||globalThis?.chrome?.dom?.openOrClosedShadowRoot?.(e)||null}catch{return null}}function ef(e,t,n={}){let r=n.traverseShadow!==!1,o=n.traverseIframes!==!1,i=n.requireOwnerDocument,a=[e],s=new WeakSet;for(;a.length;){let l=a.pop();if(l&&typeof l=="object"){if(s.has(l))continue;s.add(l)}if(Qd(l)){let y=l.documentElement||l.body;y&&a.push(y);continue}if(Jd(l)){let y=l.children;if(y&&y.length)for(let I=y.length-1;I>=0;I--)a.push(y[I]);continue}if(!Gc(l))continue;let p=l;if(i&&p.ownerDocument!==i)continue;let d=p.getAttribute?.(xt);if(d&&so(d)===t)return p;if(r)try{let y=Zd(p);y&&a.push(y)}catch{}if(o&&zc(p))try{let y=Qr(p);y&&a.push(y)}catch{}for(let y=p.lastElementChild;y;y=y.previousElementSibling)a.push(y)}return null}function gn(e,t,n={}){let r=Cs(t);if(!r)return null;let o=co(r);return o&&(!n.requireOwnerDocument||o.ownerDocument===n.requireOwnerDocument)?o:ef(e,r,{requireOwnerDocument:n.requireOwnerDocument,traverseShadow:n.traverseShadow,traverseIframes:n.traverseIframes})}function Ls(e=document){return e.querySelector('embed[type="application/pdf"], embed[type="application/x-google-chrome-pdf"]')}function jc(e){if(e==null)return[];if(Array.isArray(e)){let t=[];for(let n of e){let r=Cs(n);r&&t.push(r)}return t}if(typeof e=="number"||typeof e=="bigint"){let t=Cs(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 jc(t)}return[]}function Ur(e,t){let n=jc(t),r=e.defaultView||window;if(!n.length)return{doc:e,win:r,iframePath:n,resolvedPath:[],unresolvedPath:[]};let o=e,i=[];for(let a=0;a<n.length;a++){let s=n[a],l=n.length===1,p=gn(o,s,{requireOwnerDocument:l?void 0:o,traverseShadow:!0,traverseIframes:l});if(!p||!zc(p))return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:i,unresolvedPath:n.slice(a)};let d=null;try{d=Qr(p)||null}catch{d=null}if(!d)return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:i,unresolvedPath:n.slice(a)};i.push(s),o=d}return{doc:o,win:o.defaultView||r,iframePath:n,resolvedPath:i,unresolvedPath:[]}}function Yc(e){return e==="application/pdf"||e==="application/x-pdf"||e==="application/x-google-chrome-pdf"}function tf(){return Date.now()}function rn(e){return!e||!Number.isFinite(e)?Number.POSITIVE_INFINITY:Math.max(0,e-tf())}async function Xc(e,t,n){if(!Number.isFinite(e)||e<=0)return;let r=rn(n);r<=0||r<e+40||await pt(e,t)}async function Pr(e,t,n){let r=Math.max(0,Math.floor(t));return r?await Promise.race([e.then(i=>({ok:!0,value:i})),(async()=>(await pt(r,n),{ok:!1,reason:"timeout"}))()]):{ok:!1,reason:"timeout"}}var pt=(()=>{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 i=Number(r);if(!Number.isFinite(i)||i<=0)return;if(!o.hidden){let s=o.defaultView||window,l=s.setTimeout?s.setTimeout.bind(s):setTimeout;await new Promise(p=>l(p,i));return}let a=Date.now();for(;Date.now()-a<i;)await n()}})();var nf=3e4;function Kc(e){return(String(e??"").replace(/\\/g,"/").split("/").pop()||"upload").replace(/[\u0000-\u001f\u007f]/g,"").trim()||"upload"}var Ms=class extends Error{constructor(n,r){super(n);W(this,"url");W(this,"status");W(this,"statusText");W(this,"bodySnippet");this.name="FetchFileError",this.url=r.url,this.status=r.status,this.statusText=r.statusText,this.bodySnippet=r.bodySnippet}};function rf(e){return e&&e.split(";")[0].trim()||"application/octet-stream"}function of(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 Ds(e,t){try{let r=(t??window).URL||URL,i=new r(e).pathname.match(/\/o\/(.+?)(\?|$)/);if(i?.[1]){let s=decodeURIComponent(i[1]).split("/");return s[s.length-1].replace(/^\d+-/,"")}}catch{}}function Qc(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 sf(e,t={},n,r=fetch){let o=new AbortController,i=nf,a=!1,s=()=>{};if(n){let p=!1;s=()=>{p=!0},(async()=>{try{if(await pt(i,n),p)return;a=!0,o.abort()}catch{}})().catch(()=>{})}else{let p=setTimeout(()=>{a=!0,o.abort()},i);s=()=>clearTimeout(p)}let l=new Headers(t.headers);l.has("Accept")||l.set("Accept","*/*");try{let p=await r(e,{method:"GET",redirect:t.redirect??"follow",cache:t.cache??"no-store",mode:t.mode??"cors",credentials:t.credentials??"include",...t,headers:l,signal:o.signal});if(!p.ok){let g=await p.text().catch(()=>"");throw new Ms(`Fetch failed (${p.status})`,{url:e,status:p.status,statusText:p.statusText,bodySnippet:g.slice(0,256)})}let d=await p.arrayBuffer(),y=rf(p.headers.get("content-type")),I=of(p.headers.get("content-disposition"))||Ds(e);return{bytes:d,mimeType:y,fileName:I}}finally{s()}}async function Jc(e,t,n){return await sf(t,{referrer:n??void 0,referrerPolicy:"strict-origin-when-cross-origin"})}var ze;(function(e){e.UP="UP",e.DOWN="DOWN",e.LEFT="LEFT",e.RIGHT="RIGHT",e.TOP="TOP",e.BOTTOM="BOTTOM"})(ze||(ze={}));var Tt;(function(e){e.START="START",e.CENTER="CENTER",e.END="END",e.NEAREST="NEAREST"})(Tt||(Tt={}));function el(e){if(!e)return Tt.CENTER;let t=typeof e=="string"?e.toUpperCase():String(e).toUpperCase();return Tt&&t in Tt?Tt[t]:Tt.CENTER}function Os(e){return globalThis.CSS&&typeof globalThis.CSS.escape=="function"?globalThis.CSS.escape(e):e.replace(/([ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~])/g,"\\$1")}function Br(e,t){if(!e)return"";let n=z(e,t);if(e===n.documentElement)return"html";if(e===n.body)return"body";if(e.id)return`#${Os(e.id)}`;let r=[],o=e;for(;o&&o!==n.body&&o!==n.documentElement;){let i=o.tagName.toLowerCase();if(o.id){i+=`#${Os(o.id)}`,r.unshift(i);break}let s=(o.classList&&o.classList.length?Array.from(o.classList):(o.className||"").toString().split(/\s+/).filter(Boolean)).filter(l=>l&&l.length<=48).sort((l,p)=>l.length-p.length).slice(0,3).map(Os);if(s.length)i+="."+s.join(".");else{let l=o.parentElement;if(l){let p=Array.from(l.children).filter(d=>d.tagName===o.tagName);if(p.length>1){let d=p.indexOf(o)+1;i+=`:nth-of-type(${d})`}}}r.unshift(i),o=o.parentElement}return r.join(" > ")}function yr(e){return e.scrollingElement||e.documentElement||e.body}function di(e,t,n,r,o){let i=z(e,t),a=Y(i,n),s=yr(i),l=e===i.documentElement||e===i.body||e===s,p=l?s:e,d=l?a.innerHeight:p.clientHeight,y=l?a.innerWidth:p.clientWidth,I=o??d*.8;switch(r){case ze.DOWN:{p.scrollTop+=I;break}case ze.UP:{p.scrollTop=Math.max(0,p.scrollTop-I);break}case ze.LEFT:return p.scrollLeft=Math.max(0,p.scrollLeft-(o??y*.8)),{success:!0,scrollLeft:p.scrollLeft};case ze.RIGHT:return p.scrollLeft+=o??y*.8,{success:!0,scrollLeft:p.scrollLeft};default:return{success:!1,error:`Unsupported scroll direction: ${String(r)}`}}let g=p.scrollHeight,_=l?a.innerHeight:p.clientHeight,x=g-_;return{success:!0,scrollTop:p.scrollTop,isAtTop:p.scrollTop<=5,isAtBottom:p.scrollTop>=x-5}}function af(e,t,n){let r=z(e,t),o=Y(r,n),i=yr(r),a=e;for(;a&&a!==r.body&&a!==r.documentElement;){let l=o.getComputedStyle(a).overflowY;if((l==="auto"||l==="scroll"||l==="overlay")&&a.scrollHeight>a.clientHeight+5)return a;a=a.parentElement}return i}function Zc(e,t,n){let r=z(e,t),o=Y(r,n),i=yr(r),a=e===r.documentElement||e===r.body||e===i,s=a?i:e,l=s.scrollHeight,p=a?o.innerHeight:s.clientHeight,d=l-p;return s.scrollTop>=d-5}function Us(e,t,n,r){let o=z(e,t),i=Y(o,n),a=yr(o),s=af(e,o,i),l=s===o.documentElement||s===o.body||s===a,p=l?a:s,d=e.getBoundingClientRect(),y=l?new(i.DOMRect||DOMRect)(0,0,i.innerWidth,i.innerHeight):s.getBoundingClientRect(),I=l?i.innerHeight:s.clientHeight,g=24,_=d.top-y.top,x=p.scrollTop+_,B;switch(r){case Tt.START:B=x-g;break;case Tt.END:B=x+d.height-I+g;break;case Tt.NEAREST:{if(d.top>=y.top&&d.bottom<=y.bottom)return{success:!0,scrollTop:p.scrollTop,isAtTop:p.scrollTop<=5,isAtBottom:Zc(p,o,i)};d.top<y.top?B=x-g:B=x+d.height-I+g;break}case Tt.CENTER:default:B=x-I/2+d.height/2;break}let j=p.scrollHeight-I;return p.scrollTop=Math.max(0,Math.min(B,j)),{success:!0,scrollTop:p.scrollTop,isAtTop:p.scrollTop<=5,isAtBottom:Zc(p,o,i)}}function tl(e){let t=Number(e);if(!Number.isFinite(t))return null;let n=Math.trunc(t);return n>0?n:null}function nl(e){let t=[];for(let n of Mo){let r=e?.[n];if(r==null)continue;if(Array.isArray(r)){for(let i of r){let a=tl(i);a!=null&&t.push(a)}continue}let o=tl(r);o!=null&&t.push(o)}return Array.from(new Set(t))}function cf(e){return nl(e).length>0}function lf(e){let t=nl(e);return t.length?t[0]:null}var uf=new Set([D.click_element,D.type_into_element,D.type_and_enter,D.hover_element,D.right_click_element,D.double_click_element,D.press_key,D.scroll_page,D.scroll_to_element,D.mouse_wheel,D.drag_element,D.drag_and_drop,D.swipe_element,D.long_press_element,D.adjust_slider,D.select_dropdown_value,D.clear_element,D.focus_element,D.check_field_validity,D.select_text,D.copy_text,D.paste_text,D.pinch_zoom,D.upload_file,D.dispatch_pointer_path]);(()=>{let e="__RTRVR_ACTION_EXECUTOR__";if(window[e])return;window[e]=!0;try{document.documentElement?.setAttribute(us,"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],i=o&&typeof o=="object"?o:{};if(!o)try{Object.defineProperty(window,r,{value:i,writable:!1,configurable:!1,enumerable:!1})}catch{window[r]=i}async function a(c){let w={};try{let E=Aa[c.opcode];if(!E)throw new Error(`Unknown tool opcode: ${c.opcode}`);let v={...c.call,name:E};w=(await x({tabIndex:c.tabIndex,call:v,elementData:_(c.elementData),payload:c.payload}))[0]?.response??{success:!1,error:"Empty tool response",allowFallback:!0}}catch(E){w={success:!1,error:E?.message||String(E),allowFallback:!0}}return w}try{Object.defineProperty(i,"actions",{value:Object.freeze({execute:a}),writable:!1,configurable:!1,enumerable:!1})}catch{}let s="__RTRVR_UPLOAD_BYTES_REQ__",l="__RTRVR_UPLOAD_BYTES_RES__",p="__RTRVR_UPLOAD_BYTES_BRIDGE__",d="__RTRVR_WINDOW_MESSAGE_MUX__";function y(c){let w=c,E=w[d];if(!E||typeof E!="object"){E={handlers:new Set,installed:!1};try{Object.defineProperty(w,d,{value:E,enumerable:!1,configurable:!1})}catch{w[d]=E}}if(!E.installed){E.installed=!0,c.addEventListener("message",v=>{if(v.source===c)for(let m of Array.from(E.handlers))try{m(v)}catch{}},!0);try{c.addEventListener("pagehide",()=>{let m=c[p]?.pending;if(m)for(let[h,b]of m){try{b.cancelTimeout()}catch{}b.reject(new Error("pagehide: upload bytes request canceled")),m.delete(h)}},!0)}catch{}}return E}function I(c){let w=c,E=w[p];if(!E||typeof E!="object"){E={pending:new Map};try{Object.defineProperty(w,p,{value:E,enumerable:!1,configurable:!1})}catch{w[p]=E}y(c).handlers.add(m=>{let h=m?.data;if(!h||typeof h!="object"||h.type!==l)return;let b=String(h.requestId||"");if(!b)return;let k=E.pending.get(b);if(!k)return;E.pending.delete(b);try{k.cancelTimeout()}catch{}if(!h.ok){k.reject(new Error(h.error||"Failed to get bytes"));return}let L=h.bytes;if(!(L instanceof ArrayBuffer)){k.reject(new Error("Invalid bytes payload (expected ArrayBuffer)"));return}if(typeof k.expectedByteLength=="number"&&L.byteLength!==k.expectedByteLength){k.reject(new Error(`Byte length mismatch: got=${L.byteLength}, expected=${k.expectedByteLength}`));return}k.resolve(L)})}return E}function g(c,w,E,v=9e4){let m=c.__ROVER_UPLOAD_BYTES__||c.rover?.uploadBytes||c.rtrvr?.uploadBytes;if(typeof m=="function")return Promise.resolve().then(()=>m({token:w,byteLength:E,timeoutMs:v})).then(C=>{if(C instanceof ArrayBuffer)return C;if(C&&C.buffer instanceof ArrayBuffer)return C.buffer;throw new Error("Upload bytes provider returned invalid buffer")});let h=I(c),b=globalThis.crypto?.randomUUID?.()??`${Date.now()}-${Math.random().toString(16).slice(2)}`,k=Math.max(1e3,Math.min(Number(v)||9e4,18e4)),L=qo(c)||document;return new Promise((C,M)=>{let H=!1,V=!1,Q=()=>{V=!0};(async()=>{await pt(k,L),!(V||H)&&(h.pending.delete(b),H=!0,M(new Error("Timed out waiting for upload bytes")))})().catch(()=>{}),h.pending.set(b,{cancelTimeout:Q,expectedByteLength:E,resolve:oe=>{H||(H=!0,Q(),C(oe))},reject:oe=>{H||(H=!0,Q(),M(oe))}}),c.postMessage({type:s,requestId:b,token:w,byteLength:E},"*")})}function _(c){if(c)return{frameworks:c.frameworks?c.frameworks.map(w=>Sa[w]).filter(w=>w&&w!=="unknown"):[],listenersRaw:c.listenersRaw??"",role:c.role??void 0,pattern:c.pattern??void 0,value:c.value??void 0}}async function x({tabIndex:c,call:w,elementData:E,payload:v}){let m=(()=>{try{return _n()?.top?.document||document}catch{return document}})(),h=w.args,b=cf(h),k,L,C=[],M=[],H=[];try{({doc:k,win:L,iframePath:C,resolvedPath:M,unresolvedPath:H}=Ur(m,h.iframe_id))}catch{if(h.iframe_id!=null){let te=`Cannot access iframe ${h.iframe_id} (cross-origin or not found)`;return[{name:w.name,args:w.args,response:{success:!1,error:te,allowFallback:!1,output:{success:!1,error:{code:"IFRAME_CONTEXT_UNAVAILABLE",message:te,retryable:!1},iframe_context:{requested_iframe_id:h.iframe_id}}}}]}k=document,L=Y(k)}if(h.iframe_id!=null&&H.length>0&&!b){let le=`iframe_id unresolved: remaining=${H.join(">")||"(none)"} (cross-origin, not-ready, or not found)`;return[{name:w.name,args:w.args,response:{success:!1,error:le,allowFallback:!1,details:`requested=${C.join(">")||"(none)"} resolved=${M.join(">")||"(none)"}`,output:{success:!1,error:{code:"IFRAME_CONTEXT_UNAVAILABLE",message:le,retryable:!1},iframe_context:{requested_iframe_id:h.iframe_id,requested_path:C,resolved_path:M,unresolved_path:H}}}}]}let V=w.name,Q=lf(h),oe=Q?gn(k,Q):null,Ee=oe?.ownerDocument??null,re;if(!uf.has(V))re={success:!1,error:`Tool not promotable to main: ${V}`,allowFallback:!0};else{let te=Ee??k,le=Y(te,L);re=await j(V,oe,h,E,te,le,v)}return[{name:w.name,args:w.args,response:re}]}async function B(c,w,E){try{let v=c.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",h=c[v]?.scroll?.execute;if(typeof h!="function")throw new Error("main-world scroll detector not available");let b=E?.doc||qo(c)||document,k=Math.max(250,Math.min(Number(E?.timeoutMs??3500),8e3)),L=await Pr(Promise.resolve().then(()=>h(w)),k,b);if(!L.ok)throw new Error("scroll detector timeout");return L.value}catch(v){throw new Error(v?.message||"main-world scroll detector not available")}}async function j(c,w,E,v,m,h,b){let k=V=>({success:V.success,error:V.success?void 0:V.details||"Action failed",allowFallback:V.success?void 0:V.allowFallback??!0}),L=c===D.press_key||c===D.scroll_page||c===D.drag_and_drop||c===D.pinch_zoom;if(!w&&!L)return k({success:!1,method:"missing-element-race",details:"Target element missing",allowFallback:!0});let C=new Set([D.type_into_element,D.type_and_enter,D.clear_element,D.focus_element,D.select_text,D.check_field_validity]),M=w,H=z(M,m);if(M&&C.has(c)){let V=Oc(M,H);(V.kind==="input"||V.kind==="contenteditable")&&(M=V.el)}try{switch(c){case D.click_element:return k(J(w,m,h,v));case D.double_click_element:return k(En(w,m,h));case D.right_click_element:return k(ye(w,m,h));case D.hover_element:return k(await Ye(w,m,h,v,E.duration));case D.type_into_element:return k(await cn(M,m,h,E.text,v));case D.type_and_enter:return k(await Ut(M,m,h,E.text,v));case D.clear_element:return k(await Pt(M,m,h,v));case D.focus_element:return k(gt(M,m,h));case D.select_dropdown_value:return k(Ue(w,m,h,E.value,v));case D.adjust_slider:return k(Bt(w,m,h,v?.value??E.value,v));case D.check_field_validity:return k(jr(M,m,h));case D.select_text:return k(Nn(M,m,h,E.start_offset,E.end_offset));case D.scroll_page:return k(await jn(w,m,h,E));case D.scroll_to_element:return k(await Qe(w,m,h,E));case D.mouse_wheel:return k(at(w,m,h,E.delta_x,E.delta_y));case D.drag_element:return k(await Ht(w,m,h,E,v));case D.drag_and_drop:return k(await Qt(E,w,m,h));case D.swipe_element:return k(await ln(w,m,h,E));case D.long_press_element:return k(await Ln(w,m,h,E.duration));case D.pinch_zoom:return k(await We(w,m,h,E));case D.press_key:return k(Ft(E.key,E.modifiers,w,m,h));case D.copy_text:return k(await Mn(w,m,h));case D.paste_text:return k(await qt(w,m,h,v));case D.upload_file:return k(await dn(E,m,h,b,w,v));case D.dispatch_pointer_path:return k(await $t(E,m,h));default:return k({success:!1,method:"unhandled",details:`Unhandled ${c}`,allowFallback:!0})}}catch(V){return k({success:!1,method:"exception",details:V?.message||"exception",allowFallback:!0})}}function F(c){let w=new Map;if(!c)return w;let E=c.trim();if(!E)return w;let v=lr(E);if(v){for(let{id:m,mask:h}of v.entries){let b=Bn[m];if(!b)continue;let k=new Set(Oo(h)),L=w.get(b);if(L)for(let C of k)L.add(C);else w.set(b,k)}return w}return w}function U(c,...w){return c?w.some(E=>c.has(E)):!1}function q(c,w){let E=F(w?.listenersRaw),v=new Set;for(let[,C]of E)for(let M of C)(M==="react"||M==="vue"||M==="angular"||M==="svelte"||M==="jquery")&&v.add(M);let m=new Set;for(let[C,M]of E)if(["click","input","change","keydown","keyup","pointerdown","pointerup","mousedown","mouseup","submit","dragstart","drop","wheel","scroll"].includes(C))for(let H of M)m.add(H);let h=v.size>0||[...m].some(C=>["react","vue","angular","svelte","jquery"].includes(C)),b=U(E.get("click"),"delegated"),k=U(E.get("input"),"delegated")||U(E.get("change"),"delegated")||U(E.get("keydown"),"delegated"),L=w?.role||io(c)||c.getAttribute("role");return{sourcesByType:E,fws:v,isFrameworkElement:h,delegatedClick:b,delegatedInput:k,role:L}}function J(c,w,E,v){let m=q(c,v),h=z(c,w),b=Y(h,E);Ve(c,h,b),v?.pattern==="hover-activate"&&Ye(c,h,b,v,120);let k=m.fws.has("react")||U(m.sourcesByType.get("click"),"react"),L=m.fws.has("vue")||U(m.sourcesByType.get("click"),"vue"),C=m.fws.has("angular")||U(m.sourcesByType.get("click"),"angular"),M=m.fws.has("svelte")||U(m.sourcesByType.get("click"),"svelte"),H=m.fws.has("jquery")||U(m.sourcesByType.get("click"),"jquery");return ir(()=>ae(c,h,b),()=>ue(c,h,b),()=>k?se(c,h,b):null,()=>L?be(c,h,b):null,()=>C?pe(c,h,b):null,()=>M?_e(c,h,b):null,()=>H?Ie(c,h,b):null)}function ae(c,w,E){let v=z(c,w),m=Y(v,E),h=m.PointerEvent||PointerEvent,b=m.MouseEvent||MouseEvent,{x:k,y:L}=he(c,v,m),C={bubbles:!0,cancelable:!0,composed:!0,view:m,clientX:k,clientY:L,button:0,buttons:1};return c.focus?.({preventScroll:!0}),[new h("pointerover",C),new h("pointerenter",{...C,bubbles:!1}),new b("mouseover",C),new b("mouseenter",{...C,bubbles:!1}),new h("pointerdown",C),new b("mousedown",C),new h("pointerup",{...C,buttons:0}),new b("mouseup",{...C,buttons:0}),new b("click",{...C,buttons:0})].forEach(H=>c.dispatchEvent(H)),{success:!0,method:"pointer-mouse-click"}}function ue(c,w,E){let v=z(c,w),m=Y(v,E);try{if(c instanceof HTMLAnchorElement){let h=c.getAttribute("target");try{c.setAttribute("target","_self"),c.click()}finally{h===null?c.removeAttribute("target"):c.setAttribute("target",h)}}else c.click?.();return{success:!0,method:"native-click"}}catch{return{success:!1,method:"native-click"}}}function he(c,w,E){let v=z(c,w),m=c.getBoundingClientRect(),h=[{x:m.left+m.width/2,y:m.top+m.height/2},{x:m.left+4,y:m.top+4},{x:m.right-4,y:m.top+4},{x:m.left+4,y:m.bottom-4},{x:m.right-4,y:m.bottom-4}],b=null;for(let k=0;k<h.length;k++){let L=h[k],C=v.elementFromPoint(L.x,L.y);if(k===0&&(b=C),C&&Wc(c,C))return{...L,hit:C,ok:!0}}return{...h[0],hit:b,ok:!1}}function se(c,w,E){let v=z(c,w),m=Y(v,E);try{let h=Rt(c);if(!h)return{success:!1,method:"react-no-fiber"};let b=Vt(h),k=b.onClick||b.onClickCapture;return k?(k(Nt("click",c,v,m)),{success:!0,method:"react-fiber-onClick"}):{success:!1,method:"react-no-onClick"}}catch{return{success:!1,method:"react-fiber-onClick"}}}function be(c,w,E){let v=z(c,w),h=Y(v,E).MouseEvent||MouseEvent;try{let b=wn(c);if(!b)return{success:!1,method:"vue-none"};let k=Un(b);return k.click?(k.click(new h("click",{bubbles:!0})),{success:!0,method:"vue-handler"}):b.$emit?(b.$emit("click"),{success:!0,method:"vue-emit"}):{success:!1,method:"vue-no-click"}}catch{return{success:!1,method:"vue-handler"}}}function pe(c,w,E){let v=z(c,w),m=Y(v,E),h=m.MouseEvent||MouseEvent;try{let b=m.ng?.getZone?.()||null;return b?.run?(b.run(()=>c.dispatchEvent(new h("click",{bubbles:!0,cancelable:!0}))),{success:!0,method:"angular-zone-click"}):(c.dispatchEvent(new h("click",{bubbles:!0,cancelable:!0})),c.click?.(),{success:!0,method:"angular-click"})}catch{return{success:!1,method:"angular-click",allowFallback:!0}}}function _e(c,w,E){let v=z(c,w),h=Y(v,E).MouseEvent||MouseEvent;try{let b=c.getBoundingClientRect(),k={bubbles:!0,cancelable:!0,view:c.ownerDocument?.defaultView||window,clientX:b.left+b.width/2,clientY:b.top+b.height/2};return c.dispatchEvent(new h("mousedown",k)),c.dispatchEvent(new h("mouseup",k)),c.dispatchEvent(new h("click",k)),{success:!0,method:"svelte-click"}}catch{return{success:!1,method:"svelte-click"}}}function Ie(c,w,E){let v=z(c,w),m=Y(v,E);try{return m.jQuery?.(c)?.trigger?.("click"),{success:!0,method:"jquery-trigger"}}catch{return{success:!1,method:"jquery-trigger"}}}async function Ye(c,w,E,v,m=500){let h=Math.min(Math.max(0,Number(m)||500),3e4),b=z(c,w),k=Y(b,E),L=q(c,v);Ve(c,b,k);let C=k.PointerEvent||PointerEvent,M=k.MouseEvent||MouseEvent,H=c.getBoundingClientRect(),V=H.left+H.width/2,Q=H.top+H.height/2;if(L.fws.has("react")){let re=Rt(c),te=re?Vt(re):{};te.onMouseEnter?.(Nt("mouseenter",c,b,k)),te.onPointerEnter?.(Nt("pointerenter",c,b,k))}else if(L.fws.has("vue")){let re=wn(c),te=re?Un(re):{};te.mouseenter?.(new M("mouseenter",{bubbles:!0})),te.mouseover?.(new M("mouseover",{bubbles:!0}))}let oe={bubbles:!0,cancelable:!0,composed:!0,view:k,clientX:V,clientY:Q};return[new C("pointerover",oe),new C("pointerenter",{...oe,bubbles:!1}),new M("mouseover",oe),new M("mouseenter",{...oe,bubbles:!1})].forEach(re=>c.dispatchEvent(re)),await pt(h,b),{success:!0,method:"hover-seq"}}async function we(c,w,E=1){await Promise.resolve();for(let v=0;v<E;v++)c.hidden?await yt():await new Promise(m=>{try{w.requestAnimationFrame(()=>m())}catch{yt().then(m)}})}let He=c=>String(c??"").replace(/\s+/g," ").trim();function Xe(c){try{if("value"in c)return String(c.value??"")}catch{}return""}function Ke(c){try{return typeof br=="function"?br(c):He(c.textContent)}catch{return""}}function Kt(c,w){if(!(w.isFrameworkElement||w.delegatedInput))return!1;let E=String(c??"").length;return E>0&&E<=140}async function cn(c,w,E,v,m){let h=q(c,m),b=z(c,w),k=Y(b,E);if(Ve(c,b,k),nn(c,k)||pn(c,k)){let C=Kt(String(v??""),h),M=await Bc(c,b,k,v,{settleFrames:b.hidden?1:2,useKeyFallback:C,keyFallbackMaxLen:140});return{success:M.success,method:M.method,details:M.details,allowFallback:!M.success}}if(c.isContentEditable===!0||h.role==="textbox"&&!("value"in c)){let C=Ke(c),M=Hc(c,v,b,k);await we(b,k,b.hidden?1:2);let H=Ke(c),V=!1;if(String(v??"").length>0&&H===C){V=!0;try{Dr(c,b,k),Mr(c,b,k,!0);try{b.execCommand?.("insertText",!1,String(v??""))}catch{}gr(c,String(v??""),"insertText")}catch{}await we(b,k,b.hidden?1:2)}let Q=Ke(c),oe=Q!==C||!!String(v??"")&&Q.includes(String(v??""));return{success:oe,method:M.method,details:`${M.details};beforeLen=${C.length};afterLen=${Q.length};reverted=${H===C};fallback=${V}`,allowFallback:oe?void 0:!0}}return{success:!1,method:"type",details:"target not editable",allowFallback:!0}}async function Ut(c,w,E,v,m){let h=z(c,w),b=Y(h,E),k=await cn(c,h,b,v,m);if(!k.success)return k;let L=Fc(c);return{success:!0,method:"type+enter",details:`${k.details};enter=${L.method}`}}async function Pt(c,w,E,v){let m=z(c,w),h=Y(m,E),b=h.Event||Event;if(Ve(c,m,h),nn(c,h)||pn(c,h)){let L=Xe(c),C=qc(c,m,h);if(await we(m,h,m.hidden?1:2),Xe(c)===L&&L.length>0){try{po(c,""),gr(c,"","deleteByCut")}catch{}await we(m,h,m.hidden?1:2)}let V=Xe(c),Q=V.length===0||V!==L;return{success:C.success,method:C.method,details:C.details,allowFallback:!C.success}}if(c.isContentEditable===!0||q(c,v).role==="textbox"&&!("value"in c)){let L=$c(c,m,h);return await we(m,h,m.hidden?1:2),{success:L.success,method:L.method,details:L.details,allowFallback:!L.success}}if("value"in c){try{c.value=""}catch{}return c.dispatchEvent(new b("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new b("change",{bubbles:!0,composed:!0})),{success:!0,method:"clear-generic-value"}}return{success:!1,method:"clear",details:"target not clearable",allowFallback:!0}}function gt(c,w,E){try{let v=z(c,w),m=Y(v,E),h=m.FocusEvent||FocusEvent;return Ve(c,v,m),c.focus?.({preventScroll:!0}),c.dispatchEvent(new h("focus",{bubbles:!0})),c.dispatchEvent(new h("focusin",{bubbles:!0})),{success:!0,method:"focus"}}catch(v){return{success:!1,method:"focus",details:v.message,allowFallback:!0}}}function Ue(c,w,E,v,m){try{let h=z(c,w),b=Y(h,E),k=b.Event||Event;if(!Oa(c,b))return{success:!1,method:"select",details:"target not select",allowFallback:!0};Ve(c,h,b),c.focus?.({preventScroll:!0});let L=Array.from(c.options).find(V=>V.value===v||V.text.trim()===v.trim());if(!L)return{success:!1,method:"select",details:`Option not found: ${v}`,allowFallback:!0};L.selected=!0;let C=Object.getPrototypeOf(c),M=Object.getOwnPropertyDescriptor(C,"value");if(M?.set?M.set.call(c,L.value):c.value=L.value,c.dispatchEvent(new k("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new k("change",{bubbles:!0,composed:!0})),q(c,m).fws.has("react")){let V=Rt(c);if(V){let Q=Vt(V);if(Q.onChange){let oe=Nt("change",c,h,b);oe.target.value=L.value,Q.onChange(oe)}}}return{success:!0,method:"select"}}catch(h){return{success:!1,method:"select",details:h.message,allowFallback:!0}}}function Bt(c,w,E,v,m){try{let h=z(c,w),b=Y(h,E),k=b.Event||Event;if(!nn(c,b))return{success:!1,method:"slider",details:"target not input",allowFallback:!0};Ve(c,h,b),c.focus?.({preventScroll:!0});let L=Object.getPrototypeOf(c),C=Object.getOwnPropertyDescriptor(L,"value");if(C?.set?C.set.call(c,String(v)):c.value=String(v),c.dispatchEvent(new k("input",{bubbles:!0,composed:!0})),c.dispatchEvent(new k("change",{bubbles:!0,composed:!0})),q(c,m).fws.has("react")){let H=Rt(c);if(H){let V=Vt(H);if(V.onChange){let Q=Nt("change",c,h,b);Q.target.value=String(v),V.onChange(Q)}}}return{success:!0,method:"slider"}}catch(h){return{success:!1,method:"slider",details:h.message,allowFallback:!0}}}function jr(c,w,E){try{let v=c.checkValidity?.()??!0;return v||c.reportValidity?.(),{success:v,method:"check-validity",details:v?void 0:c.validationMessage}}catch(v){return{success:!1,method:"check-validity",details:v.message,allowFallback:!0}}}function Nn(c,w,E,v,m){try{let h=z(c,w),b=Y(h,E);if("setSelectionRange"in c){let C=c;C.focus?.();let M=C.value?.length??0;return C.setSelectionRange(v??0,m??M),{success:!0,method:"select-range"}}let k=b.getSelection();if(!k)return{success:!1,method:"select-range",allowFallback:!0};let L=h.createRange();return L.selectNodeContents(c),k.removeAllRanges(),k.addRange(L),{success:!0,method:"select-range-node"}}catch(h){return{success:!1,method:"select-range",details:h.message,allowFallback:!0}}}function _t(c,w,E,v,m){let h=yr((c&&z(c))??w),b=c||h,k=z(b,w),L=Y(k,E),C=b===k.documentElement||b===k.body||b===h;if(v===ze.TOP||v===ze.BOTTOM){let M=b.scrollHeight,H=C?L.innerHeight:b.clientHeight,V=Math.max(0,M-H);return b.scrollTop=v===ze.TOP?0:V,{success:!0,scrollTop:b.scrollTop}}return di(b,k,L,v,m)}async function jn(c,w,E,v){let m=v.direction,h=v.amount,b=z(c,w),k=Y(b,E),L=!b.hidden,C=L?"smooth":"auto";try{if(c){let H=ct(c,b,k),V=_t(H,b,k,m,h);return V?.success?{success:!0,method:"direct-element-scroll",details:JSON.stringify(V)}:{success:!1,method:"direct-element-scroll",details:V?.error||"direct scroll failed",allowFallback:!0}}if(m===ze.TOP||m===ze.BOTTOM){let H=await B(k,{action:"scrollTo",direction:m,options:{behavior:C,isTabActive:L}},{doc:b,timeoutMs:b.hidden?5200:2800});return{success:!0,method:"detector-scrollTo",details:JSON.stringify(H)}}let M=await B(k,{action:"scrollBy",direction:m,options:{amount:h,behavior:C,isTabActive:L}},{doc:b,timeoutMs:b.hidden?5200:2800});return{success:!0,method:"detector-scrollBy",details:JSON.stringify(M)}}catch(M){let H=b?_t(yr(b),b,k,m,h):void 0;return H?.success?{success:!0,method:"direct-primary-scroll-fallback",details:JSON.stringify(H)}:{success:!1,method:"scroll-page-failed",details:M?.message||H?.error||"scroll_page failed",allowFallback:!0}}}async function Qe(c,w,E,v){let m=z(c,w),h=Y(m,E),b=!m.hidden,k=b?"smooth":"auto",L=el(v.position),C=Br(c,m);if(!C){let M=Us(c,m,h,L);return{success:M.success,method:"direct-scrollElement-no-selector",details:M.error,allowFallback:!M.success}}try{let M=await B(h,{action:"scrollElement",selector:C,position:L,options:{behavior:k,isTabActive:b}},{doc:m,timeoutMs:m.hidden?5600:3e3});return{success:!0,method:"detector-scrollElement",details:JSON.stringify(M)}}catch(M){let H=Us(c,m,h,L);return H.success?{success:!0,method:"direct-scrollElement-fallback",details:JSON.stringify(H)}:{success:!1,method:"scroll-to-element-failed",details:M?.message||H.error||"scroll_to_element failed",allowFallback:!0}}}function at(c,w,E,v,m){try{let h=z(c,w),b=Y(h,E),k=b.WheelEvent||WheelEvent;Ve(c,h,b);let L=ct(c,h,b);return L.dispatchEvent(new k("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:b,deltaX:v||0,deltaY:m||0,deltaMode:k.DOM_DELTA_PIXEL})),L.scrollBy({left:v||0,top:m||0,behavior:"auto"}),{success:!0,method:"wheel"}}catch(h){return{success:!1,method:"wheel",details:h.message,allowFallback:!0}}}function ct(c,w,E){let v=z(c,w),m=Y(v,E),h=v.scrollingElement||v.documentElement||v.body,b=c;for(;b&&b!==v.body&&b!==v.documentElement;){let L=m.getComputedStyle(b).overflowY;if((L==="auto"||L==="scroll"||L==="overlay")&&b.scrollHeight>b.clientHeight+5)return b;b=b.parentElement}return h}async function Ht(c,w,E,v,m){try{let h=z(c,w),b=Y(h,E),k=b.PointerEvent||PointerEvent,L=b.MouseEvent||MouseEvent,C=b.DragEvent||DragEvent,M=b.DataTransfer||DataTransfer;Ve(c,h,b);let H=he(c,h,b),V=ot(H.hit,b)?H.hit:c,Q=c.getBoundingClientRect(),oe=Number.isFinite(Number(v?.distance))?Number(v.distance):160,Ee=0,re=0;switch(String(v?.direction||"").toUpperCase()){case"UP":re=-oe;break;case"DOWN":re=oe;break;case"LEFT":Ee=-oe;break;case"RIGHT":Ee=oe;break;default:Ee=Number(v?.delta_x)||0,re=Number(v?.delta_y)||0}let te=(A,O)=>({x:Math.max(2,Math.min(A,b.innerWidth-3)),y:Math.max(2,Math.min(O,b.innerHeight-3))}),le=te(H.x,H.y),Ae=te(H.x+Ee,H.y+re),Le=500+Date.now()%1e4,me=Math.max(12,Math.min(36,Number(v?.steps)||18)),ve=(A,O)=>({bubbles:!0,cancelable:!0,composed:!0,view:b,clientX:A,clientY:O,pageX:A+(b.scrollX||0),pageY:O+(b.scrollY||0)}),xe=(A,O,G)=>({...ve(A,O),pointerId:Le,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:G?.5:0,buttons:G,button:0}),u=(A,O,G)=>({...ve(A,O),buttons:G,button:0});V.dispatchEvent(new k("pointerdown",xe(le.x,le.y,1))),V.dispatchEvent(new L("mousedown",u(le.x,le.y,1)));try{V.setPointerCapture?.(Le)}catch{}let T=null;try{(c.draggable||q(c,m).sourcesByType.has("dragstart"))&&(T=new M)}catch{T=null}if(T)try{c.dispatchEvent(new C("dragstart",{bubbles:!0,cancelable:!0,clientX:le.x,clientY:le.y,dataTransfer:T}))}catch{}let S=null;for(let A=1;A<=me;A++){let O=le.x+(Ae.x-le.x)*A/me,G=le.y+(Ae.y-le.y)*A/me,K=h.elementFromPoint(O,G)||c;if(K.dispatchEvent(new k("pointermove",xe(O,G,1))),K.dispatchEvent(new L("mousemove",u(O,G,1))),T)try{S&&S!==K&&S.dispatchEvent(new C("dragleave",{bubbles:!0,cancelable:!0,clientX:O,clientY:G,dataTransfer:T})),K.dispatchEvent(new C("dragover",{bubbles:!0,cancelable:!0,clientX:O,clientY:G,dataTransfer:T})),S=K}catch{}A%3===0&&await yt()}let R=h.elementFromPoint(Ae.x,Ae.y)||c;if(R.dispatchEvent(new k("pointerup",xe(Ae.x,Ae.y,0))),R.dispatchEvent(new L("mouseup",u(Ae.x,Ae.y,0))),T)try{c.dispatchEvent(new C("dragend",{bubbles:!0,cancelable:!0,clientX:Ae.x,clientY:Ae.y,dataTransfer:T}))}catch{}return{success:!0,method:"drag",details:`dx=${Ee};dy=${re};steps=${me};hitOk=${H.ok}`}}catch(h){return{success:!1,method:"drag",details:h?.message||"drag failed",allowFallback:!0}}}async function Qt(c,w,E,v){try{let m=z(w,E),h=Y(m,v),b=h.PointerEvent||PointerEvent,k=h.MouseEvent||MouseEvent,L=h.DragEvent||DragEvent,C=h.DataTransfer||DataTransfer,M=c?.source_element_id??c?.element_id,H=(M?gn(m,String(M)):null)||w;if(!H)return{success:!1,method:"drag-drop",details:"source missing",allowFallback:!0};let V=null,Q=Number(c?.target_x),oe=Number(c?.target_y);if(c?.target_element_id){if(V=gn(m,String(c.target_element_id)),!V)return{success:!1,method:"drag-drop",details:"target missing",allowFallback:!0};let R=V.getBoundingClientRect();Q=R.left+R.width/2,oe=R.top+R.height/2}if((!Number.isFinite(Q)||!Number.isFinite(oe))&&!V)return{success:!1,method:"drag-drop",details:"missing target coords",allowFallback:!0};Ve(H,m,h),V&&Ve(V,m,h);let Ee=(R,A)=>({x:Math.max(2,Math.min(R,h.innerWidth-3)),y:Math.max(2,Math.min(A,h.innerHeight-3))}),re=H.getBoundingClientRect(),te=Ee(re.left+re.width/2,re.top+re.height/2),le=Ee(Number(Q),Number(oe)),Ae=600+Date.now()%1e4,Le=Math.max(14,Math.min(42,Number(c?.steps)||22)),me=(R,A)=>({bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:R,clientY:A,pageX:R+(h.scrollX||0),pageY:A+(h.scrollY||0)}),ve=(R,A,O)=>({...me(R,A),pointerId:Ae,pointerType:"mouse",isPrimary:!0,width:1,height:1,pressure:O?.5:0,buttons:O,button:0}),xe=(R,A,O)=>({...me(R,A),buttons:O,button:0}),u=null;try{u=new C}catch{u=null}H.dispatchEvent(new b("pointerdown",ve(te.x,te.y,1))),H.dispatchEvent(new k("mousedown",xe(te.x,te.y,1)));try{H.setPointerCapture?.(Ae)}catch{}if(u)try{H.dispatchEvent(new L("dragstart",{bubbles:!0,cancelable:!0,clientX:te.x,clientY:te.y,dataTransfer:u}))}catch{}let T=null;for(let R=1;R<=Le;R++){let A=te.x+(le.x-te.x)*R/Le,O=te.y+(le.y-te.y)*R/Le,G=m.elementFromPoint(A,O)||V||m.body;if(G.dispatchEvent(new b("pointermove",ve(A,O,1))),G.dispatchEvent(new k("mousemove",xe(A,O,1))),u)try{T&&T!==G&&T.dispatchEvent(new L("dragleave",{bubbles:!0,cancelable:!0,clientX:A,clientY:O,dataTransfer:u})),G.dispatchEvent(new L("dragenter",{bubbles:!0,cancelable:!0,clientX:A,clientY:O,dataTransfer:u})),G.dispatchEvent(new L("dragover",{bubbles:!0,cancelable:!0,clientX:A,clientY:O,dataTransfer:u})),T=G}catch{}R%3===0&&await yt()}let S=V||m.elementFromPoint(le.x,le.y)||m.body;if(u)try{S.dispatchEvent(new L("drop",{bubbles:!0,cancelable:!0,clientX:le.x,clientY:le.y,dataTransfer:u}))}catch{}if(S.dispatchEvent(new b("pointerup",ve(le.x,le.y,0))),S.dispatchEvent(new k("mouseup",xe(le.x,le.y,0))),u)try{H.dispatchEvent(new L("dragend",{bubbles:!0,cancelable:!0,clientX:le.x,clientY:le.y,dataTransfer:u}))}catch{}return{success:!0,method:"html5+pointer-dragdrop",details:`steps=${Le};source=${String(M)}`}}catch(m){return{success:!1,method:"drag-drop",details:m?.message||"drag-drop failed",allowFallback:!0}}}async function ln(c,w,E,v){try{let m=z(c,w),h=Y(m,E),b=h.PointerEvent||PointerEvent,k=h.MouseEvent||MouseEvent;Ve(c,m,h);let L=he(c,m,h),C={x:L.x,y:L.y},M=c.getBoundingClientRect(),H=Number.isFinite(Number(v?.distance))?Number(v.distance):Math.min(Math.max(80,Math.min(M.width,M.height)),220),V=String(v?.direction||"RIGHT").toUpperCase(),Q=C.x,oe=C.y;V==="LEFT"&&(Q-=H),V==="RIGHT"&&(Q+=H),V==="UP"&&(oe-=H),V==="DOWN"&&(oe+=H);let Ee=(A,O)=>({x:Math.max(2,Math.min(A,h.innerWidth-3)),y:Math.max(2,Math.min(O,h.innerHeight-3))}),re=Ee(C.x,C.y),te=Ee(Q,oe),le=700+Date.now()%1e4,Ae=Math.max(10,Math.min(28,Number(v?.steps)||16)),Le=(A,O)=>({bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:A,clientY:O,pageX:A+(h.scrollX||0),pageY:O+(h.scrollY||0)}),me=(A,O,G)=>({...Le(A,O),pointerId:le,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:G?.5:0,buttons:G,button:0}),ve=(A,O,G)=>({...Le(A,O),buttons:G,button:0}),xe=m.elementFromPoint(re.x,re.y)||c;xe.dispatchEvent(new b("pointerdown",me(re.x,re.y,1))),xe.dispatchEvent(new k("mousedown",ve(re.x,re.y,1)));let u=h.Touch,T=h.TouchEvent,S=!!u&&!!T;if(S)try{let A=new u({identifier:le,target:xe,clientX:re.x,clientY:re.y,pageX:re.x,pageY:re.y,screenX:re.x,screenY:re.y,radiusX:1,radiusY:1,rotationAngle:0,force:1});xe.dispatchEvent(new T("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[A],targetTouches:[A],changedTouches:[A]}))}catch{}for(let A=1;A<=Ae;A++){let O=re.x+(te.x-re.x)*A/Ae,G=re.y+(te.y-re.y)*A/Ae,K=m.elementFromPoint(O,G)||c;if(K.dispatchEvent(new b("pointermove",me(O,G,1))),K.dispatchEvent(new k("mousemove",ve(O,G,1))),S)try{let fe=new u({identifier:le,target:K,clientX:O,clientY:G,pageX:O,pageY:G,screenX:O,screenY:G,radiusX:1,radiusY:1,rotationAngle:0,force:1});K.dispatchEvent(new T("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[fe],targetTouches:[fe],changedTouches:[fe]}))}catch{}A%3===0&&await yt()}let R=m.elementFromPoint(te.x,te.y)||c;if(R.dispatchEvent(new b("pointerup",me(te.x,te.y,0))),R.dispatchEvent(new k("mouseup",ve(te.x,te.y,0))),S)try{let A=new u({identifier:le,target:R,clientX:te.x,clientY:te.y,pageX:te.x,pageY:te.y,screenX:te.x,screenY:te.y,radiusX:1,radiusY:1,rotationAngle:0,force:0});R.dispatchEvent(new T("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[A]}))}catch{}return{success:!0,method:"swipe",details:`dir=${V};dist=${H};steps=${Ae};hitOk=${L.ok}`}}catch(m){return{success:!1,method:"swipe",details:m?.message||"swipe failed",allowFallback:!0}}}async function We(c,w,E,v){try{let m=c||w.body,h=z(m,w),b=Y(h,E),k=b.PointerEvent||PointerEvent,L=b.WheelEvent||WheelEvent;Ve(m,h,b);let C=Number.isFinite(Number(v?.scale))?Number(v.scale):1.2,M=m.getBoundingClientRect(),H=M.left+M.width/2,V=M.top+M.height/2,Q=24,oe=Math.max(6,Math.min(200,Q*C)),Ee=Math.max(6,Math.min(18,Number(v?.steps)||10)),re=b.Touch,te=b.TouchEvent;if(!!re&&!!te)try{let me=(S,R)=>new re({identifier:S,target:m,clientX:R,clientY:V,pageX:R,pageY:V,screenX:R,screenY:V,radiusX:1,radiusY:1,rotationAngle:0,force:1}),ve=me(911,H-Q),xe=me(912,H+Q);m.dispatchEvent(new te("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[ve,xe],targetTouches:[ve,xe],changedTouches:[ve,xe]}));for(let S=1;S<=Ee;S++){let R=Q+(oe-Q)*S/Ee,A=me(911,H-R),O=me(912,H+R);m.dispatchEvent(new te("touchmove",{bubbles:!0,cancelable:!0,composed:!0,touches:[A,O],targetTouches:[A,O],changedTouches:[A,O]})),S%2===0&&await yt()}let u=me(911,H-oe),T=me(912,H+oe);m.dispatchEvent(new te("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[u,T]}))}catch{}try{let me=(ve,xe,u)=>({bubbles:!0,cancelable:!0,composed:!0,view:b,clientX:xe,clientY:V,pointerId:ve,pointerType:"touch",isPrimary:ve===821,width:1,height:1,pressure:u?.5:0,buttons:u,button:0});m.dispatchEvent(new k("pointerdown",me(821,H-Q,1))),m.dispatchEvent(new k("pointerdown",me(822,H+Q,1)));for(let ve=1;ve<=Ee;ve++){let xe=Q+(oe-Q)*ve/Ee;m.dispatchEvent(new k("pointermove",me(821,H-xe,1))),m.dispatchEvent(new k("pointermove",me(822,H+xe,1))),ve%2===0&&await yt()}m.dispatchEvent(new k("pointerup",me(821,H-oe,0))),m.dispatchEvent(new k("pointerup",me(822,H+oe,0)))}catch{}try{let Ae=C>=1?-120:120;m.dispatchEvent(new L("wheel",{bubbles:!0,cancelable:!0,composed:!0,view:b,clientX:H,clientY:V,ctrlKey:!0,deltaY:Ae,deltaMode:L.DOM_DELTA_PIXEL}))}catch{}return{success:!0,method:"pinch-zoom",details:`scale=${C};steps=${Ee}`}}catch(m){return{success:!1,method:"pinch-zoom",details:m?.message||"pinch-zoom failed",allowFallback:!0}}}async function Ln(c,w,E,v=800){try{let m=z(c,w),h=Y(m,E),b=h.PointerEvent||PointerEvent,k=h.MouseEvent||MouseEvent,L=h.FocusEvent||FocusEvent;Ve(c,m,h);let C=he(c,m,h),M=c;!C.ok&&ot(C.hit,h)?M=C.hit.closest?.('a,button,input,select,textarea,summary,[role="button"],[role="link"],[onclick]')||C.hit:ot(C.hit,h)&&(M=C.hit);let H=vn(M,m,h),V=C.x,Q=C.y,oe=1+Date.now()%1e4,Ee={bubbles:!0,cancelable:!0,composed:!0,view:h,clientX:V,clientY:Q,pageX:V+(h.scrollX||0),pageY:Q+(h.scrollY||0),screenX:V+(h.screenX||0),screenY:Q+(h.screenY||0)},re={...Ee,pointerId:oe,pointerType:"touch",isPrimary:!0,width:1,height:1,pressure:0,buttons:0,button:0};try{M.dispatchEvent(new b("pointerover",re)),M.dispatchEvent(new b("pointerenter",{...re,bubbles:!1}))}catch{}try{M.dispatchEvent(new k("mouseover",Ee)),M.dispatchEvent(new k("mouseenter",{...Ee,bubbles:!1}))}catch{}try{M.focus?.({preventScroll:!0}),M.dispatchEvent(new L("focus",{bubbles:!0,composed:!0})),M.dispatchEvent(new L("focusin",{bubbles:!0,composed:!0}))}catch{}try{M.dispatchEvent(new b("pointerdown",{...re,buttons:1,pressure:.5}))}catch{}try{M.dispatchEvent(new k("mousedown",{...Ee,buttons:1,button:0}))}catch{}try{let me=h.Touch,ve=h.TouchEvent;if(typeof me<"u"&&typeof ve<"u"){let xe=new me({identifier:oe,target:M,clientX:V,clientY:Q,pageX:V+(h.scrollX||0),pageY:Q+(h.scrollY||0),screenX:V+(h.screenX||0),screenY:Q+(h.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:1});M.dispatchEvent(new ve("touchstart",{bubbles:!0,cancelable:!0,composed:!0,touches:[xe],targetTouches:[xe],changedTouches:[xe]}))}}catch{}let te=Number(v),le=Number.isFinite(te)&&te>0?te:800,Ae=m.hidden?Math.max(le,1200):le;await pt(Ae,m);try{M.dispatchEvent(new k("contextmenu",{...Ee,button:2,buttons:2}))}catch{}try{M.dispatchEvent(new b("pointerup",{...re,buttons:0,pressure:0}))}catch{}try{M.dispatchEvent(new k("mouseup",{...Ee,buttons:0,button:0}))}catch{}try{let me=h.Touch,ve=h.TouchEvent;if(typeof me<"u"&&typeof ve<"u"){let xe=new me({identifier:oe,target:M,clientX:V,clientY:Q,pageX:V+(h.scrollX||0),pageY:Q+(h.scrollY||0),screenX:V+(h.screenX||0),screenY:Q+(h.screenY||0),radiusX:1,radiusY:1,rotationAngle:0,force:0});M.dispatchEvent(new ve("touchend",{bubbles:!0,cancelable:!0,composed:!0,touches:[],targetTouches:[],changedTouches:[xe]}))}}catch{}let Le=await bt(M,m,h,H);return{success:!0,method:"long-press",details:`holdMs=${Ae};verified=${Le};hitOk=${C.ok};target=${M.tagName.toLowerCase()}`}}catch(m){return{success:!1,method:"long-press",details:m?.message||"long-press failed",allowFallback:!0}}}function Ft(c,w,E,v,m){try{let h=z(E,v),k=Y(h,m).KeyboardEvent||KeyboardEvent,L=E||h.activeElement||h.body||h.documentElement;L.focus?.();let C={key:c,code:kr(c),bubbles:!0,cancelable:!0,ctrlKey:w?.includes("CTRL"),altKey:w?.includes("ALT"),shiftKey:w?.includes("SHIFT"),metaKey:w?.includes("META")},M=L.dispatchEvent(new k("keydown",C)),H=L.dispatchEvent(new k("keypress",C)),V=L.dispatchEvent(new k("keyup",C));if(c==="Enter"&&!!(M&&H&&V)){let oe=L.form||L.closest?.("form");oe?.requestSubmit?oe.requestSubmit():oe?.submit?.()}return{success:!0,method:"press-key"}}catch(h){return{success:!1,method:"press-key",details:h.message,allowFallback:!0}}}async function Mn(c,w,E){try{let v=c.innerText||c.value||"";if(!v)return{success:!1,method:"copy",details:"nothing to copy",allowFallback:!0};let m=z(c,w),h=Y(m,E);if(h.navigator?.clipboard?.writeText)return await h.navigator.clipboard.writeText(v),{success:!0,method:"clipboard-copy"};let b=m.createRange();b.selectNodeContents(c);let k=h.getSelection?.()||(m.defaultView||window).getSelection?.();k?.removeAllRanges(),k?.addRange(b);let L=m.execCommand?.("copy")??!1;return k?.removeAllRanges(),{success:!!L,method:"execCommand-copy",allowFallback:!L}}catch(v){return{success:!1,method:"clipboard-copy",details:v.message,allowFallback:!0}}}async function qt(c,w,E,v){try{c.focus?.();let m=z(c,w),h=Y(m,E);if(h.navigator?.clipboard?.readText){let k=await h.navigator.clipboard.readText();if(k)return await cn(c,m,h,k,v)}return m.execCommand?.("paste")??!1?{success:!0,method:"execCommand-paste"}:{success:!1,method:"paste",details:"clipboard empty or denied",allowFallback:!0}}catch(m){return{success:!1,method:"paste",details:m.message,allowFallback:!0}}}function Dn(c){return`${(c/1024).toFixed(1)}KB`}function Yn(c,w){if(c instanceof w.defaultView.HTMLInputElement){let b=c;if((b.type||"").toLowerCase()==="file")return b}let E=c.closest?.("label"),v=E?.htmlFor||c.htmlFor||"";if(v){let b=w.getElementById(v);if(b&&(b.type||"").toLowerCase()==="file")return b}if(E){let b=E.querySelector?.('input[type="file"]');if(b)return b}let m=c.closest?.("form");if(m){let b=m.querySelector?.('input[type="file"]');if(b)return b}let h=c.closest?.("div,section,main,article")||c.parentElement;if(h){let b=h.querySelector?.('input[type="file"]');if(b)return b}return null}function un(c,w,E){try{let v=E.HTMLInputElement?.prototype,m=v?Object.getOwnPropertyDescriptor(v,"files")?.set:void 0;if(!m){let h=Object.getPrototypeOf(c);for(;h&&!m;)m=Object.getOwnPropertyDescriptor(h,"files")?.set,h=Object.getPrototypeOf(h)}return m?(m.call(c,w),!0):(c.files=w,!0)}catch{try{return c.files=w,!0}catch{return!1}}}async function dn(c,w,E,v,m,h){try{let{file_url:b,element_id:k,file_name:L}=c,C=null;if(m&&(C=Yn(m,w)),!C&&k!==void 0&&(C=w.querySelector(`input[type="file"][${xt}*="[id=${k}]"]`)),!C){let R=w.querySelectorAll('input[type="file"]');for(let A of R){if(A.disabled)continue;let O=A.getBoundingClientRect();if(O.width>0&&O.height>0){C=A;break}}}if(!C)return{success:!1,method:"upload-file",details:"No file input found",allowFallback:!0};if(C.disabled)return{success:!1,method:"upload-file",details:"File input is disabled",allowFallback:!0};let M=z(C,w),H=Y(M,E);if(!(v?.kind==="upload_file"&&typeof v.byteLength=="number"&&v.byteLength>=0&&typeof v.mimeType=="string"&&(typeof v.inlineB64=="string"||typeof v.token=="string")))return{success:!1,method:"upload-file",details:"Missing upload payload (need inlineB64 or token)",allowFallback:!0};let Q=Number(v.byteLength),oe=(v.mimeType||"application/octet-stream").split(";")[0].trim()||"application/octet-stream",Ee;if(v.inlineB64&&typeof v.inlineB64=="string"){let R=Qc(v.inlineB64);if(R.byteLength!==Q)return{success:!1,method:"upload-file",details:`Inline bytes length mismatch: got=${R.byteLength} expected=${Q}`,allowFallback:!0};Ee=R.buffer}else{let R=String(v.token);Ee=await g(H,R,Q,9e4)}let re=H.Blob||Blob,te=new re([Ee],{type:oe}),le=L||v?.fileName;!le&&b&&typeof b=="string"&&(le=Ds(b,H)),le=Kc(le||"upload");let Ae=H.File||File,Le=new Ae([te],le,{type:oe,lastModified:Date.now()}),me=H.Event||Event,ve=H.DataTransfer||DataTransfer;if(!ve)return{success:!1,method:"upload-file",details:"DataTransfer unavailable in this context",allowFallback:!0};let xe=new ve;if(xe.items.add(Le),!un(C,xe.files,H))return{success:!1,method:"upload-file",details:"Failed to set input.files",allowFallback:!0};C.dispatchEvent(new me("input",{bubbles:!0,composed:!0,cancelable:!0})),C.dispatchEvent(new me("change",{bubbles:!0,composed:!0,cancelable:!0}));let T=Rt(C);if(T){let R=Vt(T);if(R.onChange){let A=Nt("change",C,M,H);A.target.files=xe.files,R.onChange(A)}}let S=wn(C);if(S){let R=Un(S);if(R.change){let A=new me("change",{bubbles:!0});A.target=C,A.target.files=xe.files,R.change(A)}}try{let R=H.jQuery||H.$;R&&typeof R=="function"&&R(C).triggerHandler?.("change")}catch{}return C.focus?.({preventScroll:!0}),await we(M,H,2),{success:!0,method:"upload-file",details:`Uploaded ${le} (${Dn(te.size)}) [token]`}}catch(b){return{success:!1,method:"upload-file",details:b?.message||"Upload failed",allowFallback:!0}}}async function $t(c,w,E){let v=Array.isArray(c.path)?c.path:[];if(!v.length)return{success:!1,method:"dispatch_pointer_path",details:"Empty path",allowFallback:!0};let m=E.PointerEvent||PointerEvent,h=E.MouseEvent||MouseEvent,b=16;for(let k=0;k<v.length;k++){let L=v[k],C=Number(L.x)||0,M=Number(L.y)||0,H=Number(L.pressure)||(k===0||k===v.length-1?0:.5),V=w.elementFromPoint(C,M)||w.documentElement,Q={bubbles:!0,cancelable:!0,clientX:C,clientY:M,screenX:C,screenY:M,view:E};if(k===0?(V.dispatchEvent(new m("pointerdown",{...Q,pressure:H,pointerId:1,pointerType:"mouse"})),V.dispatchEvent(new h("mousedown",{...Q,button:0,buttons:1}))):(V.dispatchEvent(new m("pointermove",{...Q,pressure:H,pointerId:1,pointerType:"mouse"})),V.dispatchEvent(new h("mousemove",{...Q,button:0,buttons:1}))),k===v.length-1&&(V.dispatchEvent(new m("pointerup",{...Q,pressure:0,pointerId:1,pointerType:"mouse"})),V.dispatchEvent(new h("mouseup",{...Q,button:0,buttons:0}))),k<v.length-1){let oe=Number(L.timestamp)||0,Ee=Number(v[k+1].timestamp)||0,re=oe&&Ee?Math.max(0,Math.min(Ee-oe,1e3)):b;re>0&&await pt(re,w)}}return{success:!0,method:"dispatch_pointer_path",details:`Dispatched ${v.length} point(s)`}}function En(c,w,E){let v=z(c,w),m=Y(v,E),h=m.MouseEvent||MouseEvent;Ve(c,v,m),ae(c,v,m),ae(c,v,m);let b=c.getBoundingClientRect();return c.dispatchEvent(new h("dblclick",{bubbles:!0,cancelable:!0,clientX:b.left+b.width/2,clientY:b.top+b.height/2,detail:2,view:m})),{success:!0,method:"dblclick"}}function ye(c,w,E){let v=z(c,w),m=Y(v,E),h=m.PointerEvent||PointerEvent,b=m.MouseEvent||MouseEvent;Ve(c,v,m);let k=c.getBoundingClientRect(),L=k.left+k.width/2,C=k.top+k.height/2,M={bubbles:!0,cancelable:!0,composed:!0,view:m,clientX:L,clientY:C,button:2,buttons:2};return c.dispatchEvent(new h("pointerdown",M)),c.dispatchEvent(new b("mousedown",M)),c.dispatchEvent(new h("pointerup",{...M,buttons:0})),c.dispatchEvent(new b("mouseup",{...M,buttons:0})),c.dispatchEvent(new b("contextmenu",M)),{success:!0,method:"contextmenu"}}function vn(c,w,E){let v=z(c,w),m=Y(v,E),h=c,b=c.getBoundingClientRect();return{href:String(m.location.href),hash:String(m.location.hash),ariaExpanded:c.getAttribute("aria-expanded"),ariaPressed:c.getAttribute("aria-pressed"),ariaDisabled:c.getAttribute("aria-disabled"),disabled:!!h.disabled,open:typeof h.open<"u"?h.open:void 0,checked:typeof h.checked<"u"?h.checked:void 0,value:typeof h.value<"u"?h.value:void 0,active:ai(v),rect:{w:b.width,h:b.height}}}function Pe(c,w){let E=Math.abs(c.rect.w-w.rect.w)>2||Math.abs(c.rect.h-w.rect.h)>2;return c.href!==w.href||c.hash!==w.hash||c.ariaExpanded!==w.ariaExpanded||c.ariaPressed!==w.ariaPressed||c.ariaDisabled!==w.ariaDisabled||c.disabled!==w.disabled||c.open!==w.open||c.checked!==w.checked||c.value!==w.value||c.active!==w.active||E}async function bt(c,w,E,v){await Promise.resolve();let m=z(c,w),h=Y(m,E);w.hidden||await yt();let b=vn(c,m,h);return Pe(v,b)}function Xn(c,w,E){c.focus?.({preventScroll:!0});let v=z(c,w),m=Y(v,E),k=c.getAttribute("role")==="button"||Pa(c,m)||c.tagName.toLowerCase()==="button"?[" ","Enter"]:["Enter"],L=m.KeyboardEvent||KeyboardEvent;for(let C of k){let M={key:C,code:C===" "?"Space":"Enter",bubbles:!0,cancelable:!0,composed:!0};c.dispatchEvent(new L("keydown",M)),c.dispatchEvent(new L("keypress",M)),c.dispatchEvent(new L("keyup",M))}return{success:!0,method:"keyboard-activate"}}async function Yr(c,w,E,...v){let m=null;for(let h of v){let b=z(c,w),k=Y(b,E),L=vn(c,b,k),C=h();if(!C||!C.success)continue;if(await bt(c,b,k,L))return{...C,details:(C.details?C.details+";":"")+"verified=true"};m=C}return m?{...m,details:(m.details?m.details+";":"")+"verified=false"}:{success:!1,method:"all-strategies-unverified",details:"no verified effect",allowFallback:!0}}function ir(...c){for(let w of c)try{let E=w();if(E&&E.success)return E}catch{}return{success:!1,method:"all-strategies-failed",allowFallback:!0}}function Ve(c,w,E){let v=z(c,w),m=Y(v,E),h=c.getBoundingClientRect();h.top>=0&&h.left>=0&&h.bottom<=m.innerHeight&&h.right<=m.innerWidth||(c.scrollIntoView({behavior:"auto",block:"center",inline:"center"}),c.offsetHeight)}function sr(c,w,E,v){let m=z(c,w),b=Y(m,E).KeyboardEvent||KeyboardEvent;for(let k of v){let L=String(k??""),C="";/^[a-z]$/i.test(L)?C=`Key${L.toUpperCase()}`:/^[0-9]$/.test(L)?C=`Digit${L}`:L===" "&&(C="Space");let M=L.length===1?L.charCodeAt(0):0,H={key:L,code:C,bubbles:!0,cancelable:!0,composed:!0,keyCode:M,which:M};c.dispatchEvent(new b("keydown",H)),c.dispatchEvent(new b("keypress",H)),c.dispatchEvent(new b("keyup",H))}}function Xr(c,w,E){let v=z(c,w),h=Y(v,E).KeyboardEvent||KeyboardEvent,b={key:"Enter",code:"Enter",keyCode:13,which:13,bubbles:!0,cancelable:!0,composed:!0},k=c.dispatchEvent(new h("keydown",b)),L=c.dispatchEvent(new h("keypress",b)),C=c.dispatchEvent(new h("keyup",b));if(!!(k&&L&&C)){let H=c.form||c.closest?.("form");H?.requestSubmit?.()??H?.submit?.()}}function kr(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 Wt=new MessageChannel,On=[];Wt.port1.onmessage=()=>{let c=On.shift();c&&c()};function yt(){return new Promise(c=>{On.push(c),Wt.port2.postMessage(0)})}function Rt(c){let w=v=>{if(!v)return null;let m=Object.keys(v);for(let h of m)if(h.startsWith("__reactFiber")||h.startsWith("__reactInternalInstance")||h.includes("reactFiber")||h.includes("reactProps")||h.includes("reactEventHandlers")||/^__r\d+/.test(h))return v[h];return null},E=c;for(let v=0;v<4&&E;v++){let m=w(E);if(m)return m;E=E.parentElement}return null}function Vt(c){let w={},E=c,v=0;for(;E&&v++<10;){let m=[E.memoizedProps,E.pendingProps,E.stateNode?.props,E._memoizedProps,E._pendingProps,E.alternate?.memoizedProps].filter(Boolean);for(let h of m)if(!(!h||typeof h!="object"))for(let b in h)b.startsWith("on")&&typeof h[b]=="function"&&(w[b]=h[b]);if(Object.keys(w).length)break;E=E.return||E.alternate}return w}function Jt(c,w){let E=c;for(;E;){if(E._reactRootContainer||E.__reactContainer||E.hasAttribute("data-reactroot")||E.hasAttribute("data-react-root")||["root","app","__next"].includes(E.id))return E;E=E.parentElement}return z(c,w).querySelector("#root,#app,#__next,[data-reactroot],[data-react-root]")}function Nt(c,w,E,v){let m=z(w,E),h=Y(m,v),b=h.MouseEvent||MouseEvent,k=w.getBoundingClientRect(),L=new b(c,{bubbles:!0,cancelable:!0,view:h,clientX:k.left+k.width/2,clientY:k.top+k.height/2});return{type:c,target:w,currentTarget:w,bubbles:!0,cancelable:!0,nativeEvent:L,isTrusted:!0,preventDefault(){L.preventDefault()},stopPropagation(){L.stopPropagation()}}}function wn(c){let w=c;if(w.__vue__)return w.__vue__;if(w.__vueParentComponent)return w.__vueParentComponent;if(w._vnode)return w._vnode;let E=c.parentElement;for(let v=0;v<3&&E;v++){let m=E;if(m.__vue__||m.__vueParentComponent||m._vnode)return m.__vue__||m.__vueParentComponent||m._vnode;E=E.parentElement}return null}function Un(c){let w={};if(c?.$listeners&&Object.assign(w,c.$listeners),c?._events)for(let E in c._events){let v=c._events[E];w[E]=Array.isArray(v)?v[0]:v}if(c?.props)for(let E in c.props)E.startsWith("on")&&typeof c.props[E]=="function"&&(w[E.substring(2).toLowerCase()]=c.props[E]);if(c?.vnode?.props)for(let E in c.vnode.props)E.startsWith("on")&&typeof c.vnode.props[E]=="function"&&(w[E.substring(2).toLowerCase()]=c.vnode.props[E]);return w}})();function rl(){let e=window,t=e.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__";e[t]?.actions?.execute}async function ol(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 fi(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}),i={};for(let a of Object.keys(o)){let s=Number(a);if(!Number.isFinite(s))continue;let l=co(s);l&&(i[s]=t.getFrameworkMetadata(l))}return{rootNodes:r,semanticNodes:o,elementMeta:i}}(()=>{let e="__rtrvr_scroll_detector",t="__RTRVR_SCROLL_API__",n="__RTRVR_INTERNAL__";if(window[e])return;class r{constructor(d=document,y=window){W(this,"doc");W(this,"win");W(this,"viewport");W(this,"lastDetectedPrimary",null);W(this,"detectionCache",new Map);W(this,"lastDetectionTime",0);W(this,"CACHE_TTL",5e3);this.doc=d,this.win=y,this.viewport={width:y.innerWidth,height:y.innerHeight},this.updateViewport()}getValidPrimary(){return this.lastDetectedPrimary&&!this.doc.contains(this.lastDetectedPrimary)&&(this.lastDetectedPrimary=null),this.lastDetectedPrimary}async handleCommand(d){switch(d.action){case"detectPrimary":{let y=this.detectPrimaryScrollable();if(!y)return null;let{target:I,isRoot:g}=this.getScrollContext(y.element),_=I.scrollHeight,x=_n(),B=g&&x?x.innerHeight:I.clientHeight,j=Math.max(0,_-B),F=I.scrollTop;return{selector:y.selector,score:y.score,type:y.type,metrics:{scrollTop:F,scrollHeight:_,clientHeight:B,isAtTop:F<=5,isAtBottom:F>=j-5}}}case"scrollTo":if(!d.direction)throw new Error("scrollTo requires direction");return this.scrollToDirection(d.direction,d.options);case"scrollBy":if(!d.direction)throw new Error("scrollBy requires direction");return this.scrollByAmount(d.direction,d.options);case"scrollElement":if(!d.selector)throw new Error("scrollElement requires selector");return this.scrollElementIntoView(d.selector,d.position,d.options);case"getMetrics":return this.getScrollMetrics();default:throw new Error(`Unknown command: ${d.action}`)}}updateViewport(){this.viewport={width:this.win.innerWidth,height:this.win.innerHeight}}async execute(d){return this.handleCommand(d)}detectPrimaryScrollable(){if(Date.now()-this.lastDetectionTime<this.CACHE_TTL&&this.detectionCache.size>0){let g=Array.from(this.detectionCache.values()).sort((_,x)=>x.score-_.score)[0];if(g)return this.lastDetectedPrimary=g.element,g}this.updateViewport();let d=this.collectScrollableCandidates();if(d.length===0){let g=this.doc.scrollingElement||this.doc.documentElement||this.doc.body;if(!g)return null;let _=this.buildFeatures(g),x=z(g,this.doc),B={element:g,selector:Br(g,x),score:.5,features:_,type:"document"};return this.detectionCache.clear(),this.detectionCache.set(B.selector,B),this.lastDetectionTime=Date.now(),this.lastDetectedPrimary=g,B}let y=this.scoreCandidates(d);if(y.length===0)return null;this.detectionCache.clear();for(let g of y)this.detectionCache.set(g.selector,g);this.lastDetectionTime=Date.now();let I=y[0];return I&&(this.lastDetectedPrimary=I.element),I||null}collectAllElementsDeep(d,y=15e4){let I=[],g=[],_=d.body||d.documentElement;_&&g.push(_);let x=0,B=j=>{try{let F=this.win.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",q=this.win[F]?.shadow?.getRoot;if(typeof q=="function"){let J=q(j);if(J)return J}}catch{}try{return j.shadowRoot||null}catch{return null}};for(;g.length&&!(++x>y);){let j=g.pop();if(jt(j)){let q=j.children;for(let J=q.length-1;J>=0;J--)g.push(q[J]);continue}let F=j,U=de(F);ot(F,U)&&I.push(F);try{let q=B(F);q&&g.push(q)}catch{}for(let q=F.lastElementChild;q;q=q.previousElementSibling)g.push(q)}return I}collectScrollableCandidates(){let d=[],y=new WeakSet,I=[this.doc.scrollingElement,this.doc.documentElement,this.doc.body];for(let _ of I){if(!_||y.has(_))continue;let x=this.isScrollable(_);(x.vertical||x.horizontal)&&(d.push(_),y.add(_))}let g=this.collectAllElementsDeep(this.doc);for(let _ of Array.from(g)){if(y.has(_))continue;let x=_.getBoundingClientRect(),B=this.win.getComputedStyle(_);if(!this.isElementRendered(_,x,B)||!this.isScrollable(_).vertical)continue;let F=40,U=this.viewport.width*.15;if(x.height<F||x.width<U){let q=(_.className||"").toLowerCase().includes("scroll"),J=B.overflowY==="auto"||B.overflowY==="scroll"||B.overflow==="auto"||B.overflow==="scroll";if(!q&&!J)continue}d.push(_),y.add(_)}return d}isElementRendered(d,y,I){if(I.display==="none"||I.visibility==="hidden")return!1;let g=parseFloat(I.opacity||"1");return!(!Number.isNaN(g)&&g<.01||y.width<=1||y.height<=1)}isScrollable(d){let y=this.win.getComputedStyle(d),I=y.overflowY,g=y.overflowX,_=this.doc.scrollingElement,x=d===this.doc.documentElement||d===this.doc.body||!!_&&d===_,B=d.scrollHeight,j=d.clientHeight,F=d.scrollWidth,U=d.clientWidth;if(x){let pe=this.doc.documentElement,_e=this.doc.body;B=Math.max(pe?pe.scrollHeight:0,_e?_e.scrollHeight:0),j=this.win.innerHeight}let q=B-j>8,J=F-U>8,ae=I==="auto"||I==="scroll"||I==="overlay",ue=g==="auto"||g==="scroll"||g==="overlay";return{vertical:x?q:q&&ae,horizontal:x?J:J&&ue,byOverflow:ae||ue}}calculateVisibleIntersection(d){let y=Math.max(0,d.left),I=Math.max(0,d.top),g=Math.min(this.viewport.width,d.right),_=Math.min(this.viewport.height,d.bottom),x=Math.max(0,g-y),B=Math.max(0,_-I);return{width:x,height:B,area:x*B}}analyzeTextContent(d,y=2e3){let I=0,g=0,_=d.ownerDocument||this.doc,B=(_.defaultView||this.win).NodeFilter||NodeFilter,j=_.createTreeWalker(d,B.SHOW_ELEMENT|B.SHOW_TEXT,null),F=0,U=j.currentNode,q=[];for(;U&&F<y;){if(U.nodeType===Node.TEXT_NODE){let se=(U.textContent||"").replace(/\s+/g,"").length;if(se>0){I+=se;let be=U.parentElement;be&&be.closest("a")&&(g+=se)}}else U.nodeType===Node.ELEMENT_NODE&&q.push(U);F++,U=j.nextNode()}let J=q.length||1,ae=I/J,ue=I>0?g/I:0;return{textChars:I,linkChars:g,textDensity:ae,linkDensity:ue}}calculateRepetitionScore(d){let y=Array.from(d.children);if(y.length<3)return 0;let I=y.slice(0,50),g=new Map,_=new Map,x=new Map;for(let he of I){let se=de(he);if(!ot(he,se))continue;let be=he.getBoundingClientRect();if(be.height<5||be.width<this.viewport.width*.1)continue;let pe=Math.round(be.height/10)*10,_e=Math.round(be.width/10)*10;g.set(pe,(g.get(pe)||0)+1),_.set(_e,(_.get(_e)||0)+1);let Ie=(he.className||he.tagName).toString();x.set(Ie,(x.get(Ie)||0)+1)}let B=I.length||1,j=Math.max(0,...g.values()),F=Math.max(0,..._.values()),U=Math.max(0,...x.values()),q=j/B,J=F/B,ae=U/B,ue=.4*q+.3*J+.3*ae;return Math.min(1,Math.max(0,ue))}calculateSemanticScore(d){let y=0,I=null,g=!1,_=(d.getAttribute("role")||"").toLowerCase(),x=d.tagName.toLowerCase(),B=(d.id||"").toLowerCase(),j=(d.className||"").toLowerCase(),F=`${_} ${x} ${B} ${j}`;return(x==="main"||_==="main")&&(y+=1.2,I="article"),x==="article"&&(y+=1,I=I||"article"),(_==="feed"||F.includes("feed"))&&(y+=1,I="feed"),(_==="log"||F.includes("chat")||F.includes("messages"))&&(y+=1,I="chat"),F.includes("content")&&(y+=.5),(F.includes("results")||F.includes("list"))&&(y+=.4),(F.includes("job")||F.includes("jobs"))&&(y+=.4),(x==="nav"||_==="navigation"||F.includes("sidebar"))&&(y-=1,g=!0),(x==="aside"||_==="complementary")&&(y-=.7,g=!0),(x==="footer"||_==="contentinfo"||F.includes("footer"))&&(y-=.8,g=!0),F.includes("header")&&(y-=.6),y=Math.max(-1,Math.min(1,y)),{semanticScore:y,typeHint:I,navLike:g}}detectScrollListeners(d){return[d.querySelector('[class*="infinite"]'),d.querySelector('[class*="load-more"]'),d.querySelector("[data-infinite]"),d.querySelector('[loading="lazy"]'),d.querySelector(".observer-target"),d.querySelector("[data-scroll]")].some(I=>I!==null)}buildFeatures(d){let y=d.getBoundingClientRect(),I=this.win.getComputedStyle(d),g=this.calculateVisibleIntersection(y),_=this.viewport.width*this.viewport.height||1,x=g.area/_,B=this.viewport.width>0?g.width/this.viewport.width:0,j=y.top+y.height/2,F=this.viewport.height/2||1,U=Math.min(1,Math.abs(j-F)/F),q=this.isScrollable(d),J=this.doc.scrollingElement,ae=d===this.doc.documentElement||d===this.doc.body||!!J&&d===J,ue=d.scrollHeight,he=d.clientHeight;if(ae){let Ke=this.doc.documentElement,Kt=this.doc.body;ue=Math.max(Ke?Ke.scrollHeight:0,Kt?Kt.scrollHeight:0),he=this.win.innerHeight}let se=Math.max(0,ue-he),be=se*g.width,pe=this.analyzeTextContent(d),_e=this.calculateRepetitionScore(d),Ie=this.calculateSemanticScore(d),Ye=d.contains(this.doc.activeElement),we=this.detectScrollListeners(d),He=parseInt(I.zIndex||"0",10),Xe=Number.isFinite(He)?He:0;return{geometry:{viewportCoverage:x,widthProminence:B,centerDistance:U,scrollCapacity:se,scrollSurface:be,zIndex:Xe},content:{textDensity:pe.textDensity,linkDensity:pe.linkDensity,repetitionScore:_e,semanticScore:Ie.semanticScore},interaction:{hasScrollListeners:we,hasFocus:Ye,recentActivity:Ye?1:0}}}inferElementType(d,y,I,g){if(I)return I;let _=(d.getAttribute("role")||"").toLowerCase(),x=(d.className||"").toLowerCase(),B=d.tagName.toLowerCase(),j=y.geometry,F=y.content;if(_==="log"||x.includes("chat")||x.includes("messages"))return"chat";let U=this.win.getComputedStyle(d);if((U.position==="fixed"||U.position==="absolute")&&j.zIndex>100&&j.viewportCoverage>.2&&j.centerDistance<.4)return"modal";if(_==="feed"||F.repetitionScore>.3&&j.scrollCapacity>400&&j.widthProminence>=.25)return"feed";if(B==="article"||F.textDensity>40&&F.linkDensity<.4&&j.widthProminence>.4)return"article";if(g||j.widthProminence<.3&&F.linkDensity>.3)return"sidebar";let J=this.doc.scrollingElement;return d===this.doc.documentElement||d===this.doc.body||J&&d===J?"document":"unknown"}scoreCandidates(d){let y=[],I=[],g=[],_=[],x=[],B=[];for(let ae of d){let ue=this.buildFeatures(ae),he=ue.content.semanticScore,se=this.calculateSemanticScore(ae),be=this.inferElementType(ae,ue,se.typeHint,se.navLike);B.push({element:ae,features:{geometry:{...ue.geometry},content:{...ue.content,semanticScore:se.semanticScore},interaction:ue.interaction},type:be,navLike:se.navLike,semanticScore:se.semanticScore}),I.push(ue.geometry.scrollSurface),g.push(ue.content.textDensity),_.push(Math.abs(se.semanticScore)),x.push(ue.content.repetitionScore)}let j=Math.max(0,...I),F=Math.max(0,...g),U=Math.max(0,..._),q=Math.max(0,...x),J=-1/0;for(let ae of B){let{element:ue,features:he,type:se,navLike:be,semanticScore:pe}=ae,_e=he.geometry,Ie=he.content,Ye=he.interaction,we=j>0?_e.scrollSurface/j:0,He=F>0?Ie.textDensity/F:0,Xe=U>0?(pe/U+1)/2:.5,Ke=se==="feed"||Ie.repetitionScore>.3&&_e.scrollCapacity>400,Kt=Ie.linkDensity>.5?(Ie.linkDensity-.5)/.5:0,cn=Ke?0:Kt,Ut=(Ke?1:.5)*Ie.repetitionScore*Math.min(1,_e.scrollCapacity/4e3),gt={feed:.2,chat:.2,article:.08,modal:.08,document:.05,sidebar:-.12,unknown:0}[se]||0,Ue=0;Ue+=_e.viewportCoverage*.18,Ue+=_e.widthProminence*.15,Ue+=(1-_e.centerDistance)*.07,Ue+=we*.22,Ue+=Ut*.18,Ue+=He*.08,Ue+=(q>0?Ie.repetitionScore/q:0)*.05,Ue+=Xe*.07,Ue-=cn*.05,Ye.hasFocus&&(Ue+=.05),Ye.hasScrollListeners&&(Ue+=.05),Ue+=gt,be&&(Ue-=.05);let Bt=Math.max(0,Math.min(1,Ue));Bt>J&&(J=Bt),y.push({element:ue,selector:Br(ue,z(ue)),score:Bt,features:he,type:se})}if(y.sort((ae,ue)=>ue.score-ae.score),y.length>=2){let ae=y[0],ue=y[1];Math.abs(ae.score-ue.score)<.08&&ae.type==="article"&&ue.type==="feed"&&(y[0]=ue,y[1]=ae)}return y}getScrollContext(d){let y=document.scrollingElement;return d===document.documentElement||d===document.body||!!y&&d===y?{target:y||document.documentElement||document.body,isRoot:!0}:{target:d,isRoot:!1}}async scrollToDirection(d,y){let I=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!I)return{success:!1,error:"No scrollable element found"};let{target:g,isRoot:_}=this.getScrollContext(I),x=z(g),B=Y(x),j=y?.isTabActive??!x.hidden,F=y?.behavior,U=j&&F==="smooth",q=_?Math.max(x.documentElement?x.documentElement.scrollHeight:0,x.body?x.body.scrollHeight:0):g.scrollHeight,J=_?B.innerHeight:g.clientHeight,ae=Math.max(0,q-J),ue=()=>_?B.scrollY:g.scrollTop,he=se=>{if(U)try{_?B.scrollTo({top:se,behavior:"smooth"}):g.scrollTo({top:se,behavior:"smooth"})}catch{_?(x.scrollingElement||x.documentElement||x.body).scrollTop=se:g.scrollTop=se}else if(_){let be=x.scrollingElement||x.documentElement||x.body;be.scrollTop=se}else g.scrollTop=se};switch(d){case ze.TOP:return he(0),{success:!0,scrollTop:0,isAtTop:!0};case ze.BOTTOM:return he(ae),{success:!0,scrollTop:ae,isAtBottom:!0};default:return{success:!1,error:`Unknown direction: ${d}`}}}async scrollByAmount(d,y){let I=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!I)return{success:!1,error:"No scrollable element found"};let{target:g,isRoot:_}=this.getScrollContext(I),x=y?.isTabActive??!document.hidden,B=y?.behavior,j=x&&B==="smooth",F=_n(),U=_&&F?F.innerHeight:g.clientHeight,q=_&&F?F.innerWidth:g.clientWidth,J=y?.amount??U*.8,ae=_?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):g.scrollHeight,ue=_&&F?F.innerHeight:g.clientHeight,he=Math.max(0,ae-ue),se=pe=>{if(j)try{_?F?.scrollTo({top:pe,behavior:"smooth"}):g.scrollTo({top:pe,behavior:"smooth"})}catch{let _e=document.scrollingElement||document.documentElement||document.body;_e.scrollTop=pe}else{let _e=_?document.scrollingElement||document.documentElement||document.body:g;_e.scrollTop=pe}},be=pe=>{if(j)try{g.scrollBy({left:pe,behavior:"smooth"})}catch{g.scrollLeft+=pe}else g.scrollLeft+=pe};switch(d){case ze.DOWN:{let _e=(_&&F?F.scrollY:g.scrollTop)+J;se(_e);let Ie=_&&F?F.scrollY:g.scrollTop;return{success:!0,scrollTop:Ie,isAtTop:Ie<=5,isAtBottom:Ie>=he-5}}case ze.UP:{let pe=_&&F?F.scrollY:g.scrollTop,_e=Math.max(0,pe-J);se(_e);let Ie=_&&F?F.scrollY:g.scrollTop;return{success:!0,scrollTop:Ie,isAtTop:Ie<=5,isAtBottom:Ie>=he-5}}case ze.LEFT:{let pe=-(y?.amount??q*.8);return be(pe),{success:!0,scrollLeft:g.scrollLeft}}case ze.RIGHT:{let pe=y?.amount??q*.8;return be(pe),{success:!0,scrollLeft:g.scrollLeft}}default:return{success:!1,error:`Unknown direction: ${d}`}}}normalizeScrollPosition(d){switch(d){case Tt.START:return"start";case Tt.END:return"end";case Tt.NEAREST:return"nearest";case Tt.CENTER:default:return"center"}}getScrollContainerForElement(d){let y=document.scrollingElement,I=d;for(;I&&I!==document.body&&I!==document.documentElement;){let x=getComputedStyle(I).overflowY,B=x==="auto"||x==="scroll"||x==="overlay",j=I.scrollHeight-I.clientHeight>8;if(B&&j)return{container:I,isRoot:!1};I=I.parentElement}return{container:y||document.documentElement||document.body,isRoot:!0}}scrollElementIntoView(d,y,I){let g=document.querySelector(d);if(!g)return{success:!1,error:`Element not found for selector: ${d}`};let{container:_,isRoot:x}=this.getScrollContainerForElement(g),B=de(_),j=B?.DOMRect||DOMRect,F=x?new j(0,0,B.innerWidth??0,B.innerHeight??0):_.getBoundingClientRect(),U=g.getBoundingClientRect(),q=24,J=U.top>=F.top+q&&U.bottom<=F.bottom-q,ae=I?.isTabActive??!document.hidden,ue=I?.behavior,he=ae&&ue==="smooth",se=this.normalizeScrollPosition(y);if(y===Tt.NEAREST&&J)return{success:!0,alreadyVisible:!0,...this.getScrollMetricsForContainer(_,x)};try{g.scrollIntoView({behavior:he?"smooth":"auto",block:se,inline:"nearest"})}catch{g.scrollIntoView()}let be=this.getScrollMetricsForContainer(_,x);return{success:!0,position:se,...be}}getScrollMetricsForContainer(d,y){let I=y?Math.max(document.documentElement?document.documentElement.scrollHeight:0,document.body?document.body.scrollHeight:0):d.scrollHeight,g=z(d),_=de(d),x=y&&_?_.innerHeight:d.clientHeight,B=Math.max(0,I-x),F=(y?g.scrollingElement||g.documentElement||g.body:d).scrollTop;return{scrollTop:F,scrollHeight:I,clientHeight:x,maxScroll:B,isAtTop:F<=5,isAtBottom:F>=B-5,scrollPercentage:B>0?F/B*100:0}}getScrollMetrics(){let d=this.getValidPrimary()||this.detectPrimaryScrollable()?.element;if(!d)return null;let{target:y,isRoot:I}=this.getScrollContext(d),g=z(y),_=Y(g),x=I?Math.max(g.documentElement?g.documentElement.scrollHeight:0,g.body?g.body.scrollHeight:0):y.scrollHeight,B=I?_.innerHeight:y.clientHeight,j=Math.max(0,x-B),U=(I?g.scrollingElement||g.documentElement||g.body:y).scrollTop;return{element:Br(y,g),scrollTop:U,scrollHeight:x,clientHeight:B,maxScroll:j,isAtTop:U<=5,isAtBottom:U>=j-5,scrollPercentage:j>0?U/j*100:0}}}let o=new r;window[e]=o;let i={execute:p=>o.execute(p)};try{Object.defineProperty(window,t,{value:i,writable:!1,configurable:!1,enumerable:!1})}catch{try{window[t]=i}catch{}}let a=window.__RTRVR_INTERNAL_KEY__||n,s=window[a],l=s&&typeof s=="object"?s:null;if(l){try{l.scroll=l.scroll||i}catch{}try{l.scroll||Object.defineProperty(l,"scroll",{value:i,writable:!1,configurable:!1,enumerable:!1})}catch{}}if(a!==n)try{!window[n]&&l&&Object.defineProperty(window,n,{value:l,writable:!1,configurable:!1,enumerable:!1})}catch{}})();var df=/\[id=(\d+)\]/,it;(function(e){e.HTML="html",e.PDF="pdf",e.GOOGLE_DOC="google_doc",e.GOOGLE_SHEET="google_sheet",e.PLAIN_TEXT="plain_text"})(it||(it={}));var il=new Map;function ff(e){let t={};for(let n of Object.keys(e)){let r=e[Number(n)],o=r?.preservedAttributes?.[Mt["rtrvr-label"]],i=r?.resourceLocator;if(typeof o=="string"&&typeof i=="string"){let a=o.match(df);if(a?.[1]){let s=Number(a[1]);Number.isFinite(s)&&(t[s]=i)}}}return t}async function ul(e,t,n={}){let r=e.ownerDocument||document,o=n.pageConfig||li,i=String(r.contentType||"").trim().toLowerCase(),a=mf(i,r),s=hf(a.documentType,i),l={url:r.URL,title:r.title,contentType:s},p=pf(o);if(a.documentType!==it.HTML){let x=Number(o?.pageDataTimeoutMs),B=Number.isFinite(x)?Math.max(200,Math.floor(x)):9e3,j=Math.max(200,Math.min(B,rn(p))),F=Ef(r,a.documentType,o,p),U=await Pr(F,j,r);if(!U.ok)return{...l,content:"",error:`non_html_timeout:${s}`,metadata:{extractionMethod:"timeout"}};let q=U.value||{},J=a.documentType===it.GOOGLE_SHEET?Yf(r):void 0;return{...l,...q,contentType:q.contentType||l.contentType,sheetInfo:q.sheetInfo||J}}if(o?.onlyTextContent)return{...l,contentType:Or,content:gi(r)};let d=Math.max(0,Math.min(3e3,rn(p))),y=performance.now(),I=!1;if(!o?.disableAutoScroll&&d>80){let x=r.hidden?900:1500,B=Math.min(x,d);B>80&&(I=await Gf(r,{profile:"light",timeBudgetMs:B,delayMs:r.hidden?0:160,finalWaitMs:r.hidden?0:200}))}let g=Math.max(0,d-(performance.now()-y));g>80&&await jf(r,{mode:"full",totalBudgetMs:Math.min(r.hidden?1400:1200,g),budgetMs:Math.min(r.hidden?650:850,g),maxPasses:r.hidden?1:2});let _=fi(e,t,{includeFrames:n.includeFrames??!0,disableDomAnnotations:n.disableDomAnnotations??!0});return Tf(_.rootNodes,_.semanticNodes)?{...l,contentType:Or,content:gi(r),metadata:{scrollingPerformed:I}}:{...l,contentType:Or,roots:_.rootNodes,nodes:_.semanticNodes,elementLinkRecord:ff(_.semanticNodes),metadata:{scrollingPerformed:I}}}function pf(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 hf(e,t){switch(e){case it.PDF:return Ss;case it.GOOGLE_DOC:return Ns;case it.GOOGLE_SHEET:return As;case it.PLAIN_TEXT:return ui;case it.HTML:default:return t||Or}}function mf(e,t){let n=e||String(t.contentType||"").toLowerCase();return Yc(n)?{documentType:it.PDF}:gf(t)&&(yf(t)||bf(t.URL))?{documentType:it.PDF}:Cf(t)?{documentType:it.GOOGLE_DOC}:Nf(t)?{documentType:it.GOOGLE_SHEET}:n.includes(ui)?{documentType:it.PLAIN_TEXT}:{documentType:it.HTML}}function gf(e){try{let t=_f(e);return Ls(t)?!0:!!t.querySelector?.('object[type="application/pdf"],object[type="application/x-google-chrome-pdf"]')}catch{return!1}}function bf(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 yf(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(i=>!["SCRIPT","STYLE"].includes(String(i.tagName).toUpperCase())).length<=3}catch{return!1}}async function Ef(e,t,n,r){switch(t){case it.PDF:return vf(e,n,r);case it.GOOGLE_DOC:return wf(e);case it.GOOGLE_SHEET:return $f(e,n);case it.PLAIN_TEXT:return{content:gi(e),contentType:ui};case it.HTML:default:return{content:gi(e),contentType:Or}}}async function vf(e,t,n){rn(n)>Rs+50&&await Xc(Rs,e,n);let o=(()=>{let d=Number(t?.pdfTextSelectionTimeoutMs),y=li.pdfTextSelectionTimeoutMs;return Number.isFinite(d)?Math.max(150,Math.floor(d)):y})(),i=rn(n),s=Number.isFinite(i)?Math.max(150,Math.min(o,Math.max(0,i-150))):o,l=await If(e,s),p=!!l.success&&!!(l.data||"").trim();return{content:p&&l.data||"",contentType:Ss,error:p?void 0:`pdf_extraction_failed:${l.reason||"unknown"}`}}async function wf(e){return{content:qf(),contentType:Ns}}function Tf(e,t){return!Array.isArray(e)||e.length===0||!t||Object.keys(t).length===0}function gi(e){return e.body?.innerText||e.body?.textContent||e.documentElement?.innerText||e.documentElement?.textContent||""}function _f(e){try{let t=e.defaultView||window,n=t.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",o=t[n]?.shadow?.getRoot;if(typeof o=="function"){let i=o(e.body||e.documentElement);if(i)return i}}catch{}return e}function xf(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 If(e,t){let n=Number.isFinite(t)&&t>0?Math.floor(t):li.pdfTextSelectionTimeoutMs,r=xf(e),o=il.get(r)??"";if(o.trim().length>0)return{success:!0,data:o,reason:"ok"};let i=await kf(e,n);return i.success&&i.data.trim()&&il.set(r,i.data),i}async function kf(e,t){let n=e.defaultView||window,r=Rf(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)}`,i=!1,a="",s=d=>{if(i||!Sf(String(d.origin||""),e))return;let y=d.data;Af(y,o)&&typeof y.selectedText=="string"&&y.selectedText.trim().length>0&&(a=y.selectedText,i=!0)};n.addEventListener("message",s);try{r.postMessage({type:"selectAll",requestId:o},"*")}catch{}let l=Date.now();for(;!i&&Date.now()-l<t;){try{r.postMessage({type:"getSelectedText",requestId:o},"*")}catch{}if(await pt(200,e),a.trim()){i=!0;break}}return n.removeEventListener("message",s),a.trim()?{success:!0,data:a,reason:"ok"}:{success:!1,data:"",reason:Date.now()-l>=t?"timeout":"no_response"}}function Rf(e){let t=Ls(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 Sf(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 Af(e,t){return!(!e||typeof e!="object"||e.type!=="getSelectedTextReply"||typeof e.selectedText!="string"||e.requestId&&e.requestId!==t)}function Cf(e){try{let t=e.defaultView||_n();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 Hr(e)!==null}function Nf(e){let n=(e.defaultView||_n())?.location.href??"";return/^https:\/\/docs\.google\.com\/spreadsheets\/(?:u\/\d+\/)?d\/[a-zA-Z0-9_-]+/.test(n)}function Lf(e){try{return e.defaultView?.top?.document??e}catch{return e}}function bi(e){let t=[e],n=Lf(e);return n!==e&&t.push(n),t}var Mf=".docs-texteventtarget-iframe",Df=".kix-cursor",Of=".docos-replyview-body",Uf=".docos-replyview",Pf=".docos-author",dl="\u200B",Bf="\xA0";function Hr(e){for(let t of bi(e)){let n=t.querySelector(Mf);if(n)return n}return null}function Hf(e){for(let t of bi(e)){let n=t.querySelector(Df);if(n)return n}return null}function pi(e){let t=Hf(e);return t?(t.ownerDocument?.defaultView?.getComputedStyle(t).display??t.style.display)==="none":!1}function hi(e,t){let n=Hr(e);if(!n)return;let r=t?"ArrowUp":"ArrowDown",i={key:r,keyCode:t?38:40,altKey:!0,shiftKey:!0,code:r,bubbles:!0,cancelable:!0},a=n.contentDocument,s=n.contentWindow;if(!a)return;let l=s?.KeyboardEvent||KeyboardEvent;a.dispatchEvent(new l("keydown",i))}function sl(e){let t=Hr(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 i=o?.KeyboardEvent||KeyboardEvent;r.dispatchEvent(new i("keydown",n))}function Ff(e){let t=Hr(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},i=t.contentDocument,a=t.contentWindow;if(!i)return;let s=a?.KeyboardEvent||KeyboardEvent;i.dispatchEvent(new s("keydown",o))}function mi(e){let t=Hr(e);if(!t)return"";let n=t.contentDocument,r=t.contentWindow,o=n?.body;if(!n||!o)return"";try{let s=r?.ClipboardEvent||ClipboardEvent,l=new s("copy",{bubbles:!0,cancelable:!0});o.firstChild?.dispatchEvent?.(l),o.firstChild?.dispatchEvent||o.dispatchEvent(l)}catch{}let i=o.innerText||o.textContent||"";return String(i).replace(new RegExp(dl,"g"),"")??""}function Ps(e){let t=`
|
|
3
|
+
|
|
4
|
+
Comments: `,n=new Set,r=[];for(let i of bi(e))try{let a=Array.from(i.querySelectorAll(Of));for(let s of a)n.has(s)||(n.add(s),r.push(s))}catch{}let o=r.filter(i=>i.textContent);if(o.length===0)return"";for(let i of o){let a=i.closest(Uf);if(!a)continue;let s=a.querySelector(Pf);s&&s.textContent&&(t+=`
|
|
5
|
+
Author: ${s.textContent} `),i.textContent&&(t+=`Comment: ${i.textContent}
|
|
6
|
+
`)}return t.trim()}function qf(){let e=ut()||document,t=Hr(e),n=t?.contentDocument,r=t?.contentWindow,o=()=>{let i=n?.body,a=ut(),s=i?.innerText||i?.textContent||""||a?.body?.innerText||a?.body?.textContent||"";return String(s).replace(new RegExp(dl,"g"),"")+Ps(e)};try{try{r?.focus(),n?.body?.focus?.()}catch{}if(Ff(e),pi(e)){let l=mi(e);if(l.trim()!==""){let p=Ps(e).trim();return l+p}else sl(e)}let i="";if(hi(e,!0),pi(e)){let l=mi(e);l.endsWith(`
|
|
7
|
+
|
|
8
|
+
`)||(i+=l.trimEnd())}if(hi(e,!1),pi(e)?mi(e).endsWith(Bf+`
|
|
9
|
+
`)&&hi(e,!1):hi(e,!1),pi(e)){let l=mi(e);l.trim()!==""&&!l.startsWith(`
|
|
10
|
+
`)&&(i+=l)}sl(e);let a=Ps(e).trim(),s=i.trim()+a;return s.trim()?s:o()}catch{return o()}}async function $f(e,t){let n="",r;fl(e,e.defaultView||window);let o=rn(t?.deadlineEpochMs);try{let i=Math.max(250,Math.min(1500,Math.floor(o*.45))),a=await Pr(Wf(e),i,e);if(!(a.ok&&a.value))throw new Error("google_sheet_copy_failed");let l=rn(t?.deadlineEpochMs),p=Math.max(250,Math.min(2500,Math.floor(l*.55)));if(n=await Vf(p,e),!n.trim())throw new Error("google_sheet_empty_clipboard")}catch(i){r=i instanceof Error?i.message:String(i)}return{content:n,contentType:As,error:r}}function fl(e,t){try{t?.focus?.()}catch{}try{e?.body?.focus?.()}catch{}}function Bs(e,t){let r=e.defaultView?.KeyboardEvent||KeyboardEvent,o=new r("keydown",{bubbles:!0,cancelable:!0,...t}),i=e.activeElement;(i&&i.ownerDocument===e?i:e).dispatchEvent(o)}async function Wf(e){try{if(fl(e,e.defaultView||window),e.hidden||!e.hasFocus())return!1;Bs(e,{key:"Escape",code:"Escape"}),await pt(150,e);let t=e.querySelector(".grid-container")||al(e,".grid-container"),n=e.querySelector(".grid4-inner-container:last-child")||al(e,".grid4-inner-container:last-child");if(n){try{n.focus()}catch{}await pt(100,e)}else if(t){try{t.focus?.()}catch{}await pt(80,e)}let o=(typeof navigator<"u"?String(navigator.platform||""):"").toUpperCase().indexOf("MAC")>=0;Bs(e,{key:"a",code:"KeyA",ctrlKey:!o,metaKey:o}),await pt(200,e),Bs(e,{key:"c",code:"KeyC",ctrlKey:!o,metaKey:o}),await pt(200,e);try{e.execCommand("copy")}catch{}return!0}catch{return!1}}async function Vf(e,t){let n=Math.max(250,Math.min(5e3,Math.floor(e)));if(navigator?.clipboard?.readText){let i=await Pr(navigator.clipboard.readText(),n,t);if(i.ok)return i.value||""}let r=t.createElement("textarea");r.style.position="fixed",r.style.opacity="0",r.style.pointerEvents="none",r.style.left="-9999px",r.style.top="0",t.body?.appendChild(r),r.focus();try{t.execCommand("paste")}catch{}let o=r.value||"";return r.remove(),o}function al(e,t){let n=bi(e);for(let s of n)try{let l=s.querySelector(t);if(l)return l}catch{}let r=25e3,o=0,i=(s,l)=>{if(!l)return;let p=l.children;if(p)for(let d=0;d<p.length;d++)s.push(p[d])},a=[];for(let s of n)try{i(a,s.documentElement??s.body??null)}catch{}for(;a.length&&o<r;){let s=a.pop();o++;try{if(s.matches(t))return s}catch{}i(a,s);let l=s.shadowRoot;if(l&&i(a,l),String(s.tagName).toUpperCase()==="IFRAME")try{let d=s.contentDocument;d&&i(a,d.documentElement??d.body??null)}catch{}}return null}async function Gf(e,t){let n=t?.profile??"light",r=!e.hidden,o=Math.max(0,Math.min(t?.timeBudgetMs??(n==="light"?1600:2800),3e3));if(o<=0)return!1;let i=Date.now(),a=()=>o-(Date.now()-i),s=t?.delayMs??(n==="light"?220:280),l=t?.finalWaitMs??(n==="light"?350:900),p=r?s:0,d=r?l:0,y=t?.amount,I=t?.maxSteps??(n==="light"?8:18),g=t?.maxDistancePx??(n==="light"?12e3:3e4),_=null;try{let F=await cl(e,{action:"detectPrimary"});if(F?.selector){let q=zf(e,F.selector);q&&(_=q)}let U=F?.metrics;if(U&&typeof U.scrollHeight=="number"&&typeof U.clientHeight=="number"){let q=Math.max(0,U.scrollHeight-U.clientHeight);g=Math.min(g,q||g),q<1500?I=Math.min(I,2):q<4e3?I=Math.min(I,4):q<1e4&&(I=Math.min(I,6))}}catch{}if(_||(_=e.scrollingElement||e.documentElement||e.body),!_)return!1;let x=0,B=null,j=0;for(let F=0;F<I&&!(a()<=0);F++){let U=null;try{U=await cl(e,{action:"scrollBy",direction:ze.DOWN,options:{amount:y,behavior:"auto",isTabActive:r}})}catch{}if(!U||!U.success){let J=e.defaultView||window;U=di(_,e,J,ze.DOWN,y),j=2}if(!U?.success)break;let q=U.scrollTop??B??0;if(B!==null){let J=Math.max(0,q-B);x+=J,j=J===0?j+1:0}if(B=q,U.isAtBottom||j>=2||x>=g)break;if(p>0&&F<I-1){let J=Math.min(p,Math.max(0,a()));if(J<=0)break;await pt(J,e)}}if(d>0){let F=Math.min(d,Math.max(0,a()));F>0&&await pt(F,e)}if(a()>80)try{let F=e.scrollingElement||e.documentElement||e.body,U=e.defaultView||window,q=_===e.documentElement||_===e.body||_===F?F:_;if(q){let J=q===F?U.innerHeight:q.clientHeight||U.innerHeight,ae=Math.max(0,q.scrollHeight-J);q.scrollTop=ae}}catch{}return!0}function zf(e,t){try{return e.querySelector(t)}catch{return null}}async function cl(e,t){let n=e.defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",a=(n[r]?.scroll||n.__RTRVR_SCROLL_API__)?.execute;return typeof a!="function"?null:a(t)}async function jf(e,t){let n=e.defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",i=n[r]?.flushScan;if(typeof i!="function"){try{n.rtrvrAIMarkInteractiveElements?.()}catch{}return}let a=Date.now()+Math.max(100,Math.floor(t.totalBudgetMs)),s=0;for(;s<t.maxPasses&&rn(a)>0;){let l=Math.max(50,Math.min(t.budgetMs,rn(a)));try{await i({mode:t.mode??"full",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:l,deadlineEpochMs:a})}catch{break}if(ll(e)===0)break;s++}if(ll(e)>0&&rn(a)>50){let l=Math.min(120,rn(a));try{await i({mode:"priority",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:l,deadlineEpochMs:a})}catch{}}}function ll(e){let t=e.documentElement;if(!t)return 0;let n=t.getAttribute(no);if(!n)return 0;let r=Number.parseInt(n,10);return Number.isFinite(r)&&r>0?r:0}function Yf(e){let t=Xf(e.URL||"");if(!t?.sheetId)return;let n=Kf(e),r=n?.title||"Sheet1";return{sheetId:t.sheetId,sheetTitle:e.title||n?.title||void 0,sheetTab:r,sheetTabId:t.sheetTabId??n?.id,sheetTabs:void 0}}function Xf(e){if(!e)return null;try{let t=new URL(e);if(t.hostname!=="docs.google.com")return null;let n=t.pathname.split("/"),r=n.indexOf("spreadsheets"),o=n.indexOf("d");if(r===-1||o===-1||o!==r+1||n.length<=o+1)return null;let i=n[o+1];if(!i||!/^[a-zA-Z0-9_-]+$/.test(i))return null;let a;return t.hash&&t.hash.includes("gid=")&&(a=new URLSearchParams(t.hash.substring(1)).get("gid")??void 0),!a&&t.searchParams.has("gid")&&(a=t.searchParams.get("gid")??void 0),a&&!/^\\d+$/.test(a)&&(a=void 0),{sheetId:i,sheetTabId:a?parseInt(a,10):0}}catch{return null}}function Kf(e){try{let t=e.querySelector('[role="tab"][aria-selected="true"]')||e.querySelector(".docs-sheet-tab-active")||e.querySelector('.docs-sheet-tab[aria-selected="true"]');if(!t)return null;let n=t.getAttribute("aria-label")||t.textContent?.trim()||void 0,r=t.getAttribute("data-sheet-id")||t.getAttribute("data-tab-id")||void 0,o=r&&/^\d+$/.test(r)?Number(r):void 0;return{title:n,id:o}}catch{return null}}var Xt;(function(e){e[e.Native=1]="Native",e[e.Inline=2]="Inline",e[e.React=4]="React",e[e.Vue=8]="Vue",e[e.Angular=16]="Angular",e[e.Svelte=32]="Svelte",e[e.JQuery=64]="JQuery",e[e.Delegated=128]="Delegated",e[e.Other=256]="Other",e[e.Inferred=512]="Inferred"})(Xt||(Xt={}));var Qf={native:Xt.Native,inline:Xt.Inline,react:Xt.React,vue:Xt.Vue,angular:Xt.Angular,svelte:Xt.Svelte,jquery:Xt.JQuery,delegated:Xt.Delegated,other:Xt.Other};(()=>{let e=window,t="__RTRVR_MAIN_WORLD_INITIALIZED__",n=new WeakMap,r={frameworks:new Set,reactRoots:new WeakSet,vueRoots:new WeakSet,angularRoots:new WeakSet,svelteRoots:new WeakSet,jqueryRoots:new WeakSet},o=new WeakMap,i=new WeakMap,a=new Set,s=500,l=200,p=0,d=0,y=new WeakSet,I="__RTRVR_ET_HOOKED__",g="__RTRVR_ATTACH_SHADOW_HOOKED__";function _(u){if(u&&!y.has(u)){y.add(u);try{x(u)}catch{}try{B(u)}catch{}}}function x(u){try{let T=u.EventTarget;if(!T?.prototype||T.prototype[I])return;T.prototype[I]=!0;let S=T.prototype.addEventListener,R=T.prototype.removeEventListener;T.prototype.addEventListener=function(A,O,G){try{Qe(O)||yt(this,A,G)}catch{}return S.call(this,A,O,G)},T.prototype.removeEventListener=function(A,O,G){try{Rt(this,A,G)}catch{}return R.call(this,A,O,G)};try{let A=Function.prototype.toString;T.prototype.addEventListener.toString=()=>A.call(S),T.prototype.removeEventListener.toString=()=>A.call(R)}catch{}}catch{}}function B(u){try{let T=u.Element;if(!T?.prototype?.attachShadow||T.prototype[g])return;T.prototype[g]=!0;let S=T.prototype.attachShadow;T.prototype.attachShadow=function(R){let A=S.call(this,R);try{Le.set(this,A)}catch{}try{re(A)}catch{}return A};try{let R=Function.prototype.toString;T.prototype.attachShadow.toString=()=>R.call(S)}catch{}}catch{}}function j(u){let S=n.get(u)?.listenerTypeMasks;if(S&&S.size){let R=[];for(let A of S.keys()){let O=Bn[A];O&&R.push(O)}return R}return Zr(u)}let F=["onclick","ondblclick","ondoubleclick","onmousedown","onmouseup","role","contenteditable","draggable","tabindex","disabled","type","aria-haspopup","aria-expanded","data-click","data-action","data-handler","data-toggle","data-target"],U=0,q=new Set,J=6,ae=["click","input","change","keydown","keyup","pointerdown","pointerup","submit","focus","blur"],ue=["mouseenter","mouseleave","mouseover","mouseout","mousedown","mouseup","wheel","scroll","dragstart","drop","touchstart","touchend"];if(e[t]){typeof e.rtrvrAIMarkInteractiveElements=="function"&&e.rtrvrAIMarkInteractiveElements();return}e[t]=!0;let he={onclick:"click",ondblclick:"dblclick",ondoubleclick:"doubleclick",onmousedown:"mousedown",onmouseup:"mouseup",onmouseenter:"mouseenter",onmouseleave:"mouseleave",onmousemove:"mousemove",onmouseover:"mouseover",onmouseout:"mouseout",oncontextmenu:"contextmenu",onauxclick:"auxclick",onkeydown:"keydown",onkeyup:"keyup",onkeypress:"keypress",oninput:"input",onchange:"change",onsubmit:"submit",onreset:"reset",onselect:"select",onsearch:"search",oninvalid:"invalid",onbeforeinput:"beforeinput",onfocus:"focus",onblur:"blur",onfocusin:"focusin",onfocusout:"focusout",ontouchstart:"touchstart",ontouchend:"touchend",ontouchmove:"touchmove",ontouchcancel:"touchcancel",onpointerdown:"pointerdown",onpointerup:"pointerup",onpointermove:"pointermove",onpointerenter:"pointerenter",onpointerleave:"pointerleave",onpointercancel:"pointercancel",onpointerover:"pointerover",ondragstart:"dragstart",ondragend:"dragend",ondrag:"drag",ondragenter:"dragenter",ondragleave:"dragleave",ondragover:"dragover",ondrop:"drop",oncopy:"copy",oncut:"cut",onpaste:"paste",onscroll:"scroll",onwheel:"wheel",onplay:"play",onpause:"pause",onended:"ended",onvolumechange:"volumechange",onseeking:"seeking",onseeked:"seeked",onanimationstart:"animationstart",onanimationend:"animationend",ontransitionend:"transitionend",ontransitionstart:"transitionstart",onresize:"resize",ontoggle:"toggle",onfullscreenchange:"fullscreenchange",onload:"load",onerror:"error",onabort:"abort",onbeforeunload:"beforeunload",onunload:"unload",onhashchange:"hashchange",onpopstate:"popstate",onstorage:"storage",onmessage:"message"};function se(u){return u?String(u).split(".")[0].toLowerCase():""}let be=["data-click","data-action","data-event","data-handler","data-on-click","data-onclick","data-tap","data-press","data-toggle","data-target"],pe=0,_e=null,Ie=new MessageChannel,Ye=[];Ie.port1.onmessage=()=>{let u=Ye.shift();u&&u()};function we(){return Date.now()}function He(u){return!u||!Number.isFinite(u)?Number.POSITIVE_INFINITY:Math.max(0,u-we())}let Xe=8,Ke=new MessageChannel,Kt=!1;function cn(){if(!Kt){Kt=!0;try{Ke.port2.postMessage(0)}catch{}}}function Ut(u){let T=u.values().next();if(T.done)return null;let S=T.value;return u.delete(S),S}function Pt(){return new Promise(u=>{Ye.push(u),Ie.port2.postMessage(0)})}let gt=!1;function Ue(){if(!gt)try{let u=e.jQuery;u&&u.fn&&(Vt(u),gt=!0,bt("jquery"))}catch{}}function Bt(u,T){for(let S=T.lastElementChild;S;S=S.previousElementSibling)u.push(S)}function jr(u,T,S){if(S)try{let R=me(T);R&&u.push(R)}catch{}}function Nn(u,T,S){if(S&&Jr(T))try{let R=T.contentWindow||null;R&&_(R);let A=R?.document?.documentElement;A&&u.push(A)}catch{}}let _t=new WeakSet;function jn(u){u&&(typeof u=="function"||typeof u=="object")&&_t.add(u)}function Qe(u){return!!u&&(typeof u=="function"||typeof u=="object")&&_t.has(u)}Ke.port1.onmessage=()=>{Kt=!1,ln(500);let u=performance.now();for(;q.size&&performance.now()-u<Xe;){let T=Ut(q);if(!T)break;try{M(T)}catch{}finally{U=Math.max(0,U-1)}}for(;a.size&&performance.now()-u<Xe;){let T=Ut(a);if(!T)break;try{Xn(T)}catch{}}at(),(q.size||a.size)&&cn()};function at(){try{let u=ut()?.documentElement;if(!u)return;u.setAttribute(no,String(U))}catch{}}function ct(u){let T=n.get(u);return T||(T={frameworks:new Set,listeners:new Map},n.set(u,T)),T}function Ht(u){a.add(u),cn()}function Qt(u){q.has(u)||(q.add(u),U++,at(),cn(),q.size>8e3&&ln(3e3))}function ln(u=2e3){let T=0;for(let S of q){if(T>u)break;S.isConnected||(q.delete(S),U=Math.max(0,U-1))}T=0;for(let S of a){if(T>u)break;S.isConnected||a.delete(S)}at()}let We=null;function Ln(u,T,S){return`${u}|${T?1:0}|${S?1:0}`}function Ft(u){let T=u.tagName;if(T==="A"||T==="BUTTON"||T==="INPUT"||T==="SELECT"||T==="TEXTAREA"||T==="SUMMARY"||u.hasAttribute("role")||u.hasAttribute("tabindex")||u.hasAttribute("contenteditable")||u.hasAttribute("onclick")||u.getAttributeNames().some(S=>S.startsWith("on")))return!0;for(let S of be)if(u.hasAttribute(S))return!0;return!!(u.hasAttribute("aria-haspopup")||u.hasAttribute("aria-expanded"))}function Mn(u){let T=de(u);if(!ot(u,T))return!1;let S=u.tagName;if(S!=="DIV"&&S!=="SPAN"&&S!=="LI"&&S!=="SECTION"&&S!=="ARTICLE"&&S!=="P")return!1;let R=u;if(R.__ngContext__||R.__svelte__||R.__vue__||R._vnode||R.__reactFiber$||R.__reactProps$)return!0;let A=0;for(let O in R){if(++A>30)break;if(O.startsWith("__react")||O.includes("reactFiber")||O.includes("reactProps"))return!0}return!1}function qt(){let u=ut()?.documentElement;return u?r.frameworks.size>0||u.hasAttribute("rtrvr-react")||u.hasAttribute("rtrvr-vue")||u.hasAttribute("rtrvr-angular")||u.hasAttribute("rtrvr-svelte")||u.hasAttribute("rtrvr-jquery"):!1}function Dn(u){let T=performance.now();for(;q.size&&performance.now()-T<u;){let S=Ut(q);if(!S)break;try{M(S)}catch{}finally{U=Math.max(0,U-1)}}for(;a.size&&performance.now()-T<u;){let S=Ut(a);if(!S)break;try{Xn(S)}catch{}}}async function Yn(u={}){ln(3e3),Ue(),ve();let T=u.mode??"full",S=u.includeShadow??!0,R=u.includeSameOriginIframes??!0,A=Math.max(50,Math.min(u.budgetMs??2500,15e3)),O=u.deadlineEpochMs,G=Math.max(0,Math.min(A,He(O))),K=Ln(T,S,R);if(G<=0){let tt=(We?.stack?.length??0)+q.size+a.size;return{revision:++pe,scanned:0,durationMs:0,done:tt===0,remaining:tt}}if((!We||We.optsKey!==K)&&He(O)>30&&await Q({budgetMs:18,deadlineEpochMs:O}),T==="priority"){let tt=performance.now(),Fe=0;for(;q.size&&performance.now()-tt<=G&&!(O&&He(O)<=0);){let Oe=Ut(q);if(!Oe)break;try{M(Oe)}catch{}Fe++,U=Math.max(0,U-1)}for(;a.size&&performance.now()-tt<=G&&!(O&&He(O)<=0);){let Oe=Ut(a);if(!Oe)break;try{Xn(Oe)}catch{}}return at(),{revision:++pe,scanned:Fe,durationMs:performance.now()-tt,done:q.size===0&&a.size===0,remaining:q.size+a.size}}if(!We||We.optsKey!==K){let tt=ut()?.documentElement;We={optsKey:K,stack:tt?[tt]:[],scannedTotal:0}}let Ne=performance.now(),De=0;for(U++,at();We.stack.length&&!(O&&He(O)<=0);){let tt=We.stack.pop();if(jt(tt)){let Oe=tt.children;for(let Tn=Oe.length-1;Tn>=0;Tn--)We.stack.push(Oe[Tn]);continue}let Fe=tt;if(!(!Fe||Fe.nodeType!==1)&&!(Fe.tagName==="SCRIPT"||Fe.tagName==="STYLE"||Fe.tagName==="META"||Fe.tagName==="NOSCRIPT")){try{(Ft(Fe)||qt()&&Mn(Fe))&&M(Fe)}catch{}try{Xn(Fe)}catch{}if(q.delete(Fe)&&(U=Math.max(0,U-1)),a.delete(Fe),De++,We.scannedTotal++,S)try{let Oe=me(Fe);Oe&&(re(Oe),We.stack.push(Oe))}catch{}if(R&&Jr(Fe))try{let Oe=Fe.contentWindow||null;Oe&&_(Oe);let Tn=Oe?.document,Kr=Tn?.documentElement;Tn&&Kr&&(le(Tn),We.stack.push(Kr))}catch{}for(let Oe=Fe.lastElementChild;Oe;Oe=Oe.previousElementSibling)We.stack.push(Oe);De%800===0&&He(O)>20&&await Pt()}}let Me=Math.max(0,G-(performance.now()-Ne)),Et=He(O);Dn(Math.min(250,Me,Et)),U=Math.max(0,U-1),at();let Zt=We.stack.length===0,Pn=We.stack.length;return Zt&&(We=null),{revision:++pe,scanned:De,durationMs:performance.now()-Ne,done:Zt,remaining:Pn}}async function un(u={}){return _e||(_e=Yn(u).finally(()=>{_e=null}),_e)}e.rtrvrAIFlushScan=un;let dn="__RTRVR_INTERNAL__";Object(window).__RTRVR_INTERNAL_KEY__=dn;let $t=e[dn],En=$t&&typeof $t=="object"?$t:{};if(!$t)try{Object.defineProperty(e,dn,{value:En,writable:!1,configurable:!1,enumerable:!1})}catch{}try{Object.defineProperty(En,"flushScan",{value:un,writable:!1,configurable:!1,enumerable:!1})}catch{}function ye(u,T){let S=ct(u),R=se(T.type);if(!R)return;let A=!1,O=S.listeners.get(R);O||(O=[],S.listeners.set(R,O),A=!0);let G=O.find(fe=>fe.source===T.source&&!!fe.inferred==!!T.inferred);if(G){let fe=!!G.capture,Ne=!!G.passive,De=!!G.once;G.capture=G.capture||T.capture,G.passive=G.passive||T.passive,G.once=G.once||T.once,(fe!==!!G.capture||Ne!==!!G.passive||De!==!!G.once)&&(A=!0)}else O.push({...T,type:R}),A=!0;let K=Ce[R];if(K!==void 0){S.listenerTypeMasks||(S.listenerTypeMasks=new Map);let fe=0,Ne=Qf[T.source];fe|=Ne!==void 0?Ne:Xt.Other,T.inferred&&(fe|=Xt.Inferred);let De=S.listenerTypeMasks.get(K)||0,Me=De|fe;Me!==De&&(S.listenerTypeMasks.set(K,Me),A=!0)}A&&(S.role=void 0,Ht(u))}function vn(u){let T=u.listenerTypeMasks;return!T||T.size===0?null:[...T.entries()].sort((R,A)=>R[0]-A[0]).map(([R,A])=>`${R}~${(A||0).toString(36)}`).join(",")}function Pe(u,T){let S=ct(u);S.frameworks.has(T)||(S.frameworks.add(T),Ht(u))}function bt(u){r.frameworks.has(u)||(r.frameworks.add(u),ut()?.documentElement?.setAttribute(`rtrvr-${u}`,"1"))}function Xn(u){let T=n.get(u);if(!T)return;a.delete(u);let S=vn(T);S?S!==T.lastListenersSerialized&&(u.setAttribute(Kn,S),T.lastListenersSerialized=S):T.lastListenersSerialized&&(u.removeAttribute(Kn),T.lastListenersSerialized=void 0);let R=de(u);if(ot(u,R))if(T.role===void 0&&(T.role=sr(u)),T.role){let A=Ar[T.role],O=typeof A=="number"?String(A):`s:${T.role}`;O!==T.lastRoleSerialized&&(u.setAttribute(Fn,O),T.lastRoleSerialized=O)}else(T.lastRoleSerialized||u.hasAttribute(Fn))&&(u.removeAttribute(Fn),T.lastRoleSerialized=void 0)}function Yr(u){let T=[],S=u;for(;S;)T.push(S),S=S.parentNode||S.host;return T}function ir(u){let T=u.tagName.toLowerCase(),S=u.getAttribute("role"),R=S?S.toLowerCase().trim():"";if(R&&Hn.has(R)||T==="button"||(T==="a"||T==="area")&&u.hasAttribute("href"))return!0;if(T==="input")return u.type?.toLowerCase()!=="hidden";if(T==="select"||T==="textarea"||(T==="video"||T==="audio")&&u.hasAttribute("controls")||u.isContentEditable||u.hasAttribute("contenteditable"))return!0;let A=u.getAttribute("tabindex");return!!(A!==null&&!Number.isNaN(Number.parseInt(A,10))&&(j(u).some(K=>jo.has(K))||u.getAttributeNames().some(K=>K.startsWith("on"))))}function Ve(u,T=10,S=600){let R=[];for(let O=0;O<u.children.length;O++)R.push({node:u.children[O],depth:1});let A=0;for(;R.length;){let{node:O,depth:G}=R.pop();if(++A>S||ir(O))return!0;if(!(G>=T))for(let K=0;K<O.children.length;K++)R.push({node:O.children[K],depth:G+1})}return!1}function sr(u){let T=u.tagName.toLowerCase(),S=u.getAttribute("role"),R=S?S.toLowerCase().trim():"",A=u.type?.toLowerCase();if(R&&Hn.has(R))return R;if(R&&eo.has(R))return null;if(T==="a"&&u.hasAttribute("href"))return"link";if(T==="button")return"button";if(T==="input")return A==="hidden"?null:A==="checkbox"?"checkbox":A==="radio"?"radio":A==="range"?"slider":A==="number"?"spinbutton":A==="search"?"searchbox":["button","submit","reset","image","file"].includes(A)?"button":u.hasAttribute("list")?"combobox":"textbox";if(T==="textarea")return"textbox";if(T==="select"){let Me=u;return Me.multiple||Me.size&&Me.size>1?"listbox":"combobox"}if(T==="option")return"option";if(T==="form")return"form";if(T==="video"||T==="audio"){let Me=Zr(u);return u.hasAttribute("controls")||Me.length>0?"media":null}if(u.isContentEditable||u.hasAttribute("contenteditable"))return"textbox";let O=j(u);if(!O.length)return null;let G=!1,K=!1,fe=!1;for(let Me=0;Me<O.length;Me++){let Et=O[Me];!G&&jo.has(Et)&&(G=!0),!K&&fs.has(Et)&&(K=!0),!fe&&ps.has(Et)&&(fe=!0)}if(!G&&!K&&!fe)return null;let Ne=u.getAttribute("tabindex"),De=Ne!==null&&!Number.isNaN(Number.parseInt(Ne,10));if(G&&(Ts(u)||u.getAttribute("href")||u.closest("a[href]")))return"link";if(K){if(u.isContentEditable||u.hasAttribute("contenteditable"))return"textbox";if(R==="textbox"||R==="searchbox"||R==="combobox"||R==="spinbutton")return R;if(!G&&De)return"textbox"}if(G){let Me=u.getAttribute("aria-checked"),Et=u.getAttribute("aria-pressed");if(Me!==null||Et!==null){if(R==="radio")return"radio";if(R==="menuitemradio")return"menuitemradio";if(R==="menuitemcheckbox")return"menuitemcheckbox";if(Et!==null)return"button";if(Me!==null)return"checkbox"}if((De||R==="button")&&!Ve(u))return"button"}return fe?"application":null}let Xr=EventTarget.prototype.addEventListener,kr=EventTarget.prototype.removeEventListener;function Wt(u){let T=!1,S,R;return typeof u=="boolean"?T=u:u&&typeof u=="object"&&(T=!!u.capture,S=u.passive,R=u.once),{capture:T,passive:S,once:R}}function On(u){try{let T=u;if(T?.nodeType===9&&T?.documentElement)return T;let S=T?.document;if(S&&S.nodeType===9&&S.documentElement)return S}catch{}return null}function yt(u,T,S){let R=se(T);if(!R)return;let{capture:A,passive:O,once:G}=Wt(S),K=o.get(u);K||(K=new Map,o.set(u,K));let fe=K.get(R);if(fe?(fe.count+=1,fe.capture=fe.capture||A,fe.passive=fe.passive||O):K.set(R,{count:1,capture:A,passive:O}),cr(u))try{ye(u,{type:R,source:"native",capture:A,passive:O,once:G})}catch{}let Ne=On(u);if(Ne&&(R==="click"||R==="input"||R==="keydown"))try{Ne.documentElement?.setAttribute(`rtrvr-gl-${R}`,"1")}catch{}}function Rt(u,T,S){let R=se(T);if(!R)return;let A=o.get(u);if(!A)return;let O=A.get(R);O&&(O.count-=1,O.count<=0&&A.delete(R),A.size===0&&o.delete(u))}_(window);function Vt(u){if(!u||!u.fn)return;let T=u.fn.on,S=u.fn.off;function R(O){if(!O)return[];if(typeof O=="string")return O.split(/\s/).map(G=>se(G)).filter(Boolean);if(typeof O=="object")try{return Object.keys(O).map(G=>se(G)).filter(Boolean)}catch{return[]}return[]}function A(O){try{if(!O)return null;if(cr(O))return O;let G=de(O);return $o(O,G)||null}catch{}return null}u.fn.on=function(O,G){let K=R(O),fe=typeof G=="string"&&!!G;return this.each(function(){let Ne=A(this);if(Ne){if(fe){let De=i.get(Ne);De||(De=[],i.set(Ne,De));for(let Me of K){let Et=`${Me}::${G}`;De.some(Zt=>`${Zt.type}::${Zt.selector}`===Et)||(De.push({type:Me,selector:G}),De.length>400&&De.shift())}}else for(let De of K)ye(Ne,{type:De,source:"jquery"});Pe(Ne,"jquery"),bt("jquery"),r.jqueryRoots.add(Ne)}}),T.apply(this,arguments)},u.fn.off=function(){return S.apply(this,arguments)},bt("jquery")}function Jt(u){be.some(S=>u.hasAttribute(S))&&(ye(u,{type:"click",source:"other",inferred:!0}),(u.tagName==="INPUT"||u.tagName==="TEXTAREA")&&(ye(u,{type:"input",source:"other",inferred:!0}),ye(u,{type:"change",source:"other",inferred:!0})))}function Nt(u){let T=de(u),S=ot(u,T),R=u.getAttributeNames().some(fe=>fe.startsWith("on")),A=/^(button|a|input|select|textarea|summary)$/i.test(u.tagName),O=u,G=S&&(Qo(u)||!!O.isContentEditable||u.hasAttribute("contenteditable")),K=S&&!!O.draggable;if(!R&&!A&&!G&&!K){Jt(u);return}for(let[fe,Ne]of Object.entries(he))typeof u[fe]=="function"&&ye(u,{type:Ne,source:"inline"});G&&(ye(u,{type:"input",source:"other",inferred:!0}),ye(u,{type:"keydown",source:"other",inferred:!0}),ye(u,{type:"keyup",source:"other",inferred:!0}),ye(u,{type:"paste",source:"other",inferred:!0})),K&&(ye(u,{type:"dragstart",source:"other",inferred:!0}),ye(u,{type:"dragend",source:"other",inferred:!0})),Jt(u)}function wn(u){if(!u.startsWith("on")||u.length<=2)return null;if(u.endsWith("Capture")){let S=u.substring(2,u.length-7);return S?{type:S.toLowerCase(),capture:!0}:null}let T=u.substring(2);return T?{type:T.toLowerCase(),capture:!1}:null}function Un(u){let T=null;if(u){for(let S in u)if(S.startsWith("__react")||S.startsWith("_react")||S.includes("reactFiber")||S.includes("reactProps")||S.includes("reactInternalInstance")){T=S;break}if(T)try{let S=u[T],R=S?.memoizedProps||S?.pendingProps;if(R&&typeof R=="object"){for(let A in R){if(typeof R[A]!="function")continue;let G=wn(A);G&&ye(u,{type:G.type,source:"react",capture:G.capture})}cr(S?.stateNode)&&r.reactRoots.add(S.stateNode),Pe(u,"react"),bt("react")}}catch{}}}function c(u){let T=u,S=!1;if(T.__vue__){S=!0;let R=T.__vue__;R.$listeners&&Object.keys(R.$listeners).forEach(A=>ye(u,{type:A,source:"vue"})),R._events&&Object.keys(R._events).forEach(A=>ye(u,{type:A,source:"vue"})),R.$options?._parentListeners&&Object.keys(R.$options._parentListeners).forEach(A=>ye(u,{type:A,source:"vue"})),r.vueRoots.add(u)}if(T._vnode?.props){S=!0;let R=T._vnode.props;Object.keys(R).forEach(A=>{A.startsWith("on")&&A.length>2&&ye(u,{type:A.substring(2).toLowerCase(),source:"vue"})}),r.vueRoots.add(u)}S&&(Pe(u,"vue"),bt("vue"))}function w(u){let T=u,S=!1;if(T.__ngContext__||u.hasAttribute("_ngcontent")||u.hasAttribute("ng-version")){S=!0,Array.from(u.attributes).forEach(R=>{if(R.name.startsWith("(")&&R.name.endsWith(")")){let A=R.name.slice(1,-1).split(".")[0];A&&ye(u,{type:A,source:"angular"})}if(R.name.startsWith("on-")){let A=R.name.substring(3);A&&ye(u,{type:A,source:"angular"})}if(R.name.includes(".")){let A=R.name.match(/\(([^.)]+)/);A?.[1]&&ye(u,{type:A[1],source:"angular"})}});try{if(e.ng?.getComponent){let R=e.ng.getComponent(u);R&&Object.keys(R).forEach(A=>{(A.endsWith("Output")||A.endsWith("Emitter"))&&ye(u,{type:A.replace(/(Output|Emitter)$/,"").toLowerCase(),source:"angular"})})}}catch{}}S&&(Pe(u,"angular"),bt("angular"),r.angularRoots.add(u))}function E(u){let T=u,S=!1;if(T.__svelte__){S=!0,Array.from(u.attributes).forEach(R=>{if(R.name.startsWith("on:")){let A=R.name.substring(3);A&&ye(u,{type:A,source:"svelte"})}});try{let R=T.__svelte__?.$$?.callbacks;R&&typeof R=="object"&&Object.keys(R).forEach(A=>ye(u,{type:A,source:"svelte"}))}catch{}r.svelteRoots.add(u)}S&&(Pe(u,"svelte"),bt("svelte"))}function v(u,T){return u?!!o.get(u)?.has(T):!1}function m(u,T,S=96){let R=se(T);if(!R)return!1;let A=z(u),O=Y(A);if(v(A,R)||v(O,R))return!0;let G=0,K=u;for(;K&&G<S;){if(K.parentElement)K=K.parentElement;else{let fe=K.getRootNode?.();if(jt(fe)){if(v(fe,R)||v(fe.host,R))return!0;K=fe.host}else break}if(K&&v(K,R))return!0}return!1}function h(u,T,S=128){let R=0,A=u;for(;A&&R<S;){if(T(A),A.parentElement){A=A.parentElement;continue}let O=A.getRootNode?.();if(jt(O)){A=O.host;continue}break}}function b(u){let T=de(u);if(!ot(u,T))return;let S=ct(u);S.role=S.role||sr(u);let R=m(u,"click"),A=m(u,"input"),O=m(u,"keydown"),K=z(u).documentElement;if(r.frameworks.size>0||K.hasAttribute("rtrvr-react")||K.hasAttribute("rtrvr-vue")||K.hasAttribute("rtrvr-angular")||K.hasAttribute("rtrvr-svelte")||K.hasAttribute("rtrvr-jquery")||R||A||O){let Ne=S.role||"other";R&&["button","link","checkbox","radio","switch","menuitem","menuitemcheckbox","menuitemradio","tab","option","treeitem","gridcell","cell","img","figure"].includes(Ne)&&ye(u,{type:"click",source:"delegated",inferred:!0}),["textbox","searchbox","spinbutton","code"].includes(Ne)&&(A&&(ye(u,{type:"input",source:"delegated",inferred:!0}),ye(u,{type:"change",source:"delegated",inferred:!0})),O&&ye(u,{type:"keydown",source:"delegated",inferred:!0})),["combobox","listbox"].includes(Ne)&&(R&&ye(u,{type:"click",source:"delegated",inferred:!0}),A&&ye(u,{type:"change",source:"delegated",inferred:!0})),["slider","scrollbar","progressbar","meter"].includes(Ne)&&A&&ye(u,{type:"input",source:"delegated",inferred:!0})}h(u,Ne=>{let De=i.get(Ne);if(De?.length)for(let{type:Me,selector:Et}of De)try{u.matches(Et)&&(ye(u,{type:Me,source:"jquery",inferred:!0}),Pe(u,"jquery"),bt("jquery"))}catch{}})}function k(u){let T=S=>{let R=S,A=R.composedPath&&R.composedPath()||Yr(S.target),G=u==="mousemove"||u==="pointermove"||u==="scroll"||u==="wheel"?1:Math.min(A.length,J);for(let K=0;K<G;K++){let fe=A[K];cr(fe)&&ye(fe,{type:u,source:"delegated",inferred:!0})}};jn(T);try{Xr.call(document,u,T,{capture:!0,passive:!0})}catch{}}let L=!1;function C(){ae.forEach(k);let u=ut()?.documentElement;if(!u)return;let T=()=>{if(L)return;let S=u.hasAttribute("rtrvr-react")||u.hasAttribute("rtrvr-vue")||u.hasAttribute("rtrvr-angular")||u.hasAttribute("rtrvr-svelte"),R=u.hasAttribute("rtrvr-gl-click")||u.hasAttribute("rtrvr-gl-input")||u.hasAttribute("rtrvr-gl-keydown");(S||R)&&(L=!0,ue.forEach(k))};T();try{new MutationObserver(()=>T()).observe(u,{attributes:!0,attributeFilter:["rtrvr-react","rtrvr-vue","rtrvr-angular","rtrvr-svelte","rtrvr-gl-click","rtrvr-gl-input","rtrvr-gl-keydown"]})}catch{}}function M(u){if(u.nodeType!==1)return;let T=de(u);if(ot(u,T)){let S=ct(u);S.role=void 0}Nt(u),Un(u),c(u),w(u),E(u),b(u),Ht(u)}function H(){let u=["a[href]","button","input","select","textarea","summary","details > summary",...Array.from(Hn).map(T=>`[role="${T}"]`),"[onclick]","[ondblclick]","[ondoubleclick]","[onmousedown]","[tabindex]","[contenteditable]",'[draggable="true"]',"[aria-haspopup]","[aria-expanded]","[data-click]","[data-action]","[data-handler]","[data-toggle]","[data-target]",".clickable",".interactive",".btn",".button"];U++,at();try{let T=u.join(",");ut()?.querySelectorAll(T).forEach(S=>{try{M(S)}catch{}})}finally{U=Math.max(0,U-1),at()}}function V(u){for(let T of u){for(let S of Array.from(T.addedNodes)){if(S.nodeType!==1)continue;let R=S;Qt(R),R.querySelectorAll?.('a,button,input,select,textarea,summary,[role],[onclick],[ondblclick],[ondoubleclick],[contenteditable],[draggable="true"],[tabindex]').forEach(Qt)}if(T.type==="attributes"&&T.target.nodeType===1){let S=T.target;T.attributeName==="class"?(qt()||Ft(S))&&Qt(S):Qt(S)}}}async function Q(u={}){let T=ut(),S=T?.documentElement;if(!S||!(S.hasAttribute("rtrvr-react")||S.hasAttribute("rtrvr-vue")||S.hasAttribute("rtrvr-angular")||S.hasAttribute("rtrvr-svelte")))return;let A=u.deadlineEpochMs,O=Math.max(5,Math.min(u.budgetMs??12,50));if(Math.max(0,Math.min(O,He(A)))<=0)return;let K=performance.now();U++,at();try{let fe=0,Ne=4e3,De=["div","span","li","section","article","p"];for(let Me of De){let Et=T.getElementsByTagName(Me)??[];for(let Zt=0;Zt<Et.length;Zt++){if(fe++>=Ne||A&&He(A)<=0)return;let Pn=Et[Zt],tt=Pn;(tt.__ngContext__||tt.__svelte__||tt.__vue__||tt._vnode||Mn(Pn))&&M(Pn),fe%250===0&&He(A)>20&&await Pt()}}}finally{U=Math.max(0,U-1),at()}}let oe=new MutationObserver(V),Ee=new WeakMap;function re(u){if(!Ee.has(u)&&!(p>=s))try{let T=Y(u.ownerDocument).MutationObserver||MutationObserver,S=new T(V);Ee.set(u,S),p++,S.observe(u,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...F,"class"]})}catch{}}let te=new WeakMap;function le(u){if(!te.has(u)&&!(d>=l))try{_(u.defaultView||null);let T=u.documentElement;if(!T)return;let S=Y(u).MutationObserver||MutationObserver,R=new S(V);te.set(u,R),d++,R.observe(T,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...F,"class"]})}catch{}}function Ae(){let u=ut()?.documentElement;u&&oe.observe(u,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[...F,"class"]})}let Le=new WeakMap;function me(u){return u.shadowRoot||Le.get(u)||null}try{Object.defineProperty(En,"shadow",{value:Object.freeze({getRoot:u=>me(u)}),writable:!1,configurable:!1,enumerable:!1})}catch{}function ve(){try{(e.React||e.__REACT_DEVTOOLS_GLOBAL_HOOK__)&&bt("react"),e.Vue&&bt("vue"),e.ng&&bt("angular"),e.jQuery&&bt("jquery"),Ue()}catch{}}e.rtrvrAIMarkInteractiveElements=function(){return ut()?.body?(H(),!0):!1};function xe(){let u=ut();Ue(),ve(),C();let T=()=>{Ue(),ve(),Ae(),e.rtrvrAIMarkInteractiveElements?.(),Q({budgetMs:20}),u?.documentElement.setAttribute(ls,"1")};u?.readyState==="loading"?u.addEventListener("DOMContentLoaded",T,{once:!0}):T()}xe()})();var yi=null;function Hs(e){try{return e.getAttribute(Kn)}catch{return null}}function pl(e){let t=Hs(e);return lr(t)?.entries??[]}function hl(e){try{let t=e.getAttribute(Fn);return t&&t.trim()?t:null}catch{return null}}function Jf(e){let t=e?.ownerDocument?.defaultView,n=t?.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",o=t?.[n]?.shadow?.getRoot;if(typeof o=="function")try{return o(e)||null}catch{}return e.shadowRoot||null}function Zf(e){let t=new Set;for(let n of e){let r=Oo(n.mask);for(let o of r)(o==="react"||o==="vue"||o==="angular"||o==="svelte"||o==="jquery")&&t.add(o)}return t}function ep(e){let t=new Set,n=e;return(n.__reactFiber||n.__reactProps||n.__reactInternalInstance||n.__reactRootContainer)&&t.add("react"),(n.__vue__||n.__vueParentComponent||n.__vnode||n.__vue_app__)&&t.add("vue"),n.__ngContext__&&t.add("angular"),(n.__svelte||n.__svelte_meta)&&t.add("svelte"),(n.__jquery||n.jQuery)&&t.add("jquery"),t}function tp(e){let t=pl(e),n=Zf(t),r=ep(e);for(let o of r)n.add(o);return{frameworks:[...n],listenersRaw:Hs(e)||"",role:hl(e)??(e.getAttribute?.("role")||null)}}function np(){return{getEventHandlerIds:e=>pl(e).map(t=>t.id),getRoleHint:hl,getShadowRoot:Jf}}function ml(e={}){if(yi)return yi;if(typeof window<"u")try{window.rtrvrAIMarkInteractiveElements?.()}catch{}return yi={signalProvider:np(),getFrameworkMetadata:tp,getListenerEncoding:Hs,dispose:()=>{}},yi}var wi=class{constructor(t={}){W(this,"root");W(this,"includeFrames");W(this,"disableDomAnnotations");W(this,"allowActions");W(this,"runtimeId");W(this,"domainScopeMode");W(this,"allowedDomains");W(this,"externalNavigationPolicy");W(this,"crossHostPolicy");W(this,"registerOpenedTab");W(this,"listKnownTabs");W(this,"switchToLogicalTab");W(this,"onNavigationGuardrail");W(this,"onBeforeAgentNavigation");W(this,"onBeforeCrossHostNavigation");W(this,"instrumentation");W(this,"highlightEl",null);W(this,"clientTools",new Map);W(this,"uploadStore",new Map);W(this,"uploadProviderInstalled",!1);W(this,"actionGateContext",{});this.root=t.root??document.body??document.documentElement,this.includeFrames=t.includeFrames??!0,this.disableDomAnnotations=t.disableDomAnnotations??!0,this.allowActions=t.allowActions??!0,this.runtimeId=t.runtimeId,this.domainScopeMode=gl(t.domainScopeMode),this.allowedDomains=Fs(t.allowedDomains,window.location.hostname,this.domainScopeMode),this.externalNavigationPolicy=bl(t.externalNavigationPolicy),this.crossHostPolicy=yl(t.crossHostPolicy),this.registerOpenedTab=t.registerOpenedTab,this.listKnownTabs=t.listKnownTabs,this.switchToLogicalTab=t.switchToLogicalTab,this.onNavigationGuardrail=t.onNavigationGuardrail,this.onBeforeAgentNavigation=t.onBeforeAgentNavigation,this.onBeforeCrossHostNavigation=t.onBeforeCrossHostNavigation,this.instrumentation=t.instrumentation??ml({includeIframes:!0,scanInlineHandlers:!0,observeInlineMutations:!0,...t.instrumentationOptions||{}}),rl(),t.uploadBytesProvider&&this.setUploadBytesProvider(t.uploadBytesProvider)}setAllowActions(t){this.allowActions=!!t}setActionGateContext(t){let n={};(t?.mode==="controller"||t?.mode==="observer")&&(n.mode=t.mode),typeof t?.controllerRuntimeId=="string"&&t.controllerRuntimeId.trim()&&(n.controllerRuntimeId=t.controllerRuntimeId.trim()),Number.isFinite(Number(t?.activeLogicalTabId))&&Number(t?.activeLogicalTabId)>0&&(n.activeLogicalTabId=Number(t?.activeLogicalTabId)),Number.isFinite(Number(t?.localLogicalTabId))&&Number(t?.localLogicalTabId)>0&&(n.localLogicalTabId=Number(t?.localLogicalTabId)),typeof t?.reason=="string"&&t.reason.trim()&&(n.reason=t.reason.trim().slice(0,240)),this.actionGateContext=n}setNavigationPolicy(t){t.domainScopeMode&&(this.domainScopeMode=gl(t.domainScopeMode),t.allowedDomains||(this.allowedDomains=Fs(void 0,window.location.hostname,this.domainScopeMode))),t.allowedDomains&&(this.allowedDomains=Fs(t.allowedDomains,window.location.hostname,this.domainScopeMode)),t.externalNavigationPolicy&&(this.externalNavigationPolicy=bl(t.externalNavigationPolicy)),t.crossHostPolicy&&(this.crossHostPolicy=yl(t.crossHostPolicy))}async getSnapshot(){return await wl(this.root),fi(this.root,this.instrumentation,{includeFrames:this.includeFrames,disableDomAnnotations:this.disableDomAnnotations})}async getPageData(t){return await wl(this.root),await ul(this.root,this.instrumentation,{includeFrames:this.includeFrames,disableDomAnnotations:this.disableDomAnnotations,pageConfig:t?.pageConfig})}async executeTool(t,n){let r=rp(t?.name);if(!r)return{success:!1,error:`Unknown tool: ${String(t?.name)}`,allowFallback:!1};if(this.shouldBlockForOutOfScopeContext(r))return this.domainScopeBlockedResponse(window.location.href,"Current tab is outside the allowed navigation scope.",{fromCurrentContext:!0});if(!this.allowActions&&!vl.has(r))return{success:!1,error:"Actions disabled by configuration",allowFallback:!1,output:{reason:this.actionGateContext.mode==="observer"?"Actions are disabled because this tab is currently in observer mode.":this.actionGateContext.reason||"Actions disabled by configuration",actionGate:this.actionGateContext}};let o=await this.handleNavigationTools(r,t?.args||{});if(o)return o;if(r===D.wait_action){let _=Number(t?.args?.duration??1e3);return await new Promise(x=>setTimeout(x,Math.max(0,Math.min(_,6e4)))),{success:!0}}if(r===D.wait_for_element)return this.waitForElement(t?.args||{});if(r===D.answer_task)return{success:!0};if(r===D.solve_captcha)return vi("CAPTCHA solving requires human intervention in embed mode.","HUMAN_INTERVENTION_REQUIRED");if(r===D.network_run_recipe)return vi("network_run_recipe is not supported in embed mode.","CAPABILITY_UNAVAILABLE");let i=t?.args||{},a=lp(i),s=Ur(document,i.iframe_id);if(i.iframe_id!=null&&s.unresolvedPath.length>0&&!a)return this.iframeContextUnavailableResponse(i.iframe_id,s);if(r===D.click_element&&i?.open_in_new_tab)return this.openElementInNewTab(i);if(r===D.click_element){let _=this.getInterceptedClickTarget(i);if(_?.targetUrl){if(_.forceOpenInNewTab)return this.openUrlInNewTab(_.targetUrl,{policyBlocked:!0,reason:_.reason});let B=_.reason;return this.externalNavigationPolicy==="open_new_tab_notice"?this.openUrlInNewTab(_.targetUrl,{policyBlocked:!0,reason:B}):this.domainScopeBlockedResponse(_.targetUrl,B)}let x=this.getClickTargetUrl(i);if(x){let B=this.buildNavigationIntent(x);this.notifyAgentNavigation(B),this.notifyCrossHostNavigation(B)}}if(r===D.describe_images)return this.describeImages(t?.args||{});if(!(r in Do))return{success:!1,error:`Unknown tool: ${String(t?.name)}`,allowFallback:!1};let{doc:l}=s,p=qs(i),d=p?gn(l,p):null,y;if(d){let _=this.instrumentation.getFrameworkMetadata(d),x=cp(_.listenersRaw||"",r),B=i?.value??i?.text??null;y=ap({..._,pattern:x,value:B})}let I=Do[r];return r===D.upload_file&&!n&&(n=await this.buildUploadPayload(i).catch(()=>{})),ol({opcode:I,call:{name:r,args:i},elementData:y,tabIndex:0,payload:n})}iframeContextUnavailableResponse(t,n){let o=`iframe_id unresolved: remaining=${n.unresolvedPath.join(">")||"(none)"} (cross-origin, not-ready, or not found)`;return{success:!1,error:o,allowFallback:!1,output:{success:!1,error:{code:"IFRAME_CONTEXT_UNAVAILABLE",message:o,retryable:!1},iframe_context:{requested_iframe_id:t,requested_path:n.iframePath,resolved_path:n.resolvedPath,unresolved_path:n.unresolvedPath}},errorDetails:{code:"IFRAME_CONTEXT_UNAVAILABLE",message:o,retryable:!1,details:{requested_iframe_id:t,requested_path:n.iframePath,resolved_path:n.resolvedPath,unresolved_path:n.unresolvedPath}}}}highlight(t){let n=gn(document,t);if(!n)return;let r=n.getBoundingClientRect();if(!this.highlightEl){let o=document.createElement("div");o.style.position="fixed",o.style.pointerEvents="none",o.style.border="2px solid #ff7a59",o.style.boxShadow="0 0 0 2px rgba(255, 122, 89, 0.2)",o.style.borderRadius="6px",o.style.zIndex="2147483647",this.highlightEl=o,document.body.appendChild(o)}this.highlightEl.style.left=`${r.left}px`,this.highlightEl.style.top=`${r.top}px`,this.highlightEl.style.width=`${Math.max(0,r.width)}px`,this.highlightEl.style.height=`${Math.max(0,r.height)}px`,this.highlightEl.style.display="block"}clearHighlight(){this.highlightEl&&(this.highlightEl.style.display="none")}setUploadBytesProvider(t){window.__ROVER_UPLOAD_BYTES__=t}registerTool(t,n){let r=typeof t=="string"?{name:t}:t;!r?.name||typeof n!="function"||this.clientTools.set(r.name,{handler:n,def:r})}async executeClientTool(t,n){let r=this.clientTools.get(t);if(!r)throw new Error(`Unknown client tool: ${t}`);return r.handler(n)}listClientTools(){return Array.from(this.clientTools.values()).map(t=>t.def)}async handleNavigationTools(t,n){switch(t){case D.goto_url:{let r=String(n.url||"").trim();if(!r)return{success:!1,error:"goto_url: missing url",allowFallback:!0};let o=Ei(r,window.location.href);if(!o)return{success:!1,error:`goto_url: invalid url "${r}"`,allowFallback:!0};if(this.shouldPreserveHostRuntime(o))return!bn(o,this.allowedDomains)&&this.externalNavigationPolicy==="block"?this.domainScopeBlockedResponse(o,"Navigation blocked by domain policy."):await this.openUrlInNewTab(o,{policyBlocked:!0,reason:"Opened in a new tab to preserve Rover runtime continuity across hostnames."});if(this.shouldGuardExternalNavigation(o)){let a="Navigation blocked by domain policy.";return this.externalNavigationPolicy==="open_new_tab_notice"?await this.openUrlInNewTab(o,{policyBlocked:!0,reason:a}):this.domainScopeBlockedResponse(o,a)}let i=this.buildNavigationIntent(o);return this.notifyAgentNavigation(i),this.notifyCrossHostNavigation(i),window.location.href=o,{success:!0,output:{url:o,navigation:"same_tab"}}}case D.google_search:{let r=String(n.query||"").trim();if(!r)return{success:!1,error:"google_search: missing query",allowFallback:!0};let o=`https://www.google.com/search?q=${encodeURIComponent(r)}`;if(this.shouldPreserveHostRuntime(o))return!bn(o,this.allowedDomains)&&this.externalNavigationPolicy==="block"?this.domainScopeBlockedResponse(o,"Google search blocked by domain policy."):await this.openUrlInNewTab(o,{policyBlocked:!0,reason:"Opened in a new tab to preserve Rover runtime continuity across hostnames."});if(this.shouldGuardExternalNavigation(o)){let a="Google search opens outside the allowed navigation scope.";return this.externalNavigationPolicy==="open_new_tab_notice"?await this.openUrlInNewTab(o,{policyBlocked:!0,reason:a}):this.domainScopeBlockedResponse(o,a)}let i=this.buildNavigationIntent(o);return this.notifyAgentNavigation(i),this.notifyCrossHostNavigation(i),window.location.href=o,{success:!0,output:{url:o,navigation:"same_tab"}}}case D.go_back:return this.notifyAgentNavigation(this.buildNavigationIntent(window.location.href,{isCrossHost:!1})),window.history.back(),{success:!0};case D.go_forward:return this.notifyAgentNavigation(this.buildNavigationIntent(window.location.href,{isCrossHost:!1})),window.history.forward(),{success:!0};case D.refresh_page:return this.notifyAgentNavigation(this.buildNavigationIntent(window.location.href,{isCrossHost:!1})),window.location.reload(),{success:!0};case D.open_new_tab:{let r=String(n.url||"").trim();if(!r)return{success:!1,error:"open_new_tab: missing url",allowFallback:!0};let o=Ei(r,window.location.href);if(!o)return{success:!1,error:`open_new_tab: invalid url "${r}"`,allowFallback:!0};if(this.shouldConvertOpenNewTabToSameTab(o)){let i=this.buildNavigationIntent(o);return this.notifyAgentNavigation(i),this.notifyCrossHostNavigation(i),window.location.assign(o),{success:!0,output:{url:o,navigation:"same_tab",convertedFrom:"open_new_tab"}}}return await this.openUrlInNewTab(o,{policyBlocked:!1})}case D.switch_tab:{let r=Number(n.logical_tab_id??n.tab_id);if(!Number.isFinite(r)||r<=0)return{success:!1,error:(typeof n._tab_id_mapping_error=="string"?String(n._tab_id_mapping_error).trim():"")||"switch_tab: missing/invalid logical_tab_id",allowFallback:!0};if(this.externalNavigationPolicy!=="allow"&&this.listKnownTabs){let o=this.listKnownTabs().find(i=>Number(i.logicalTabId)===r);if(o?.external)return this.domainScopeBlockedResponse(o.url||`logical_tab_id:${r}`,`Tab ${r} is out of scope. Direct actions are blocked for this tab.`)}if(!this.switchToLogicalTab)return vi("switch_tab requires session coordinator support.","CAPABILITY_UNAVAILABLE");try{let o=await this.switchToLogicalTab(r);return o?.ok?{success:!0,output:{logicalTabId:r,delegated:!!o.delegated,mode:o.delegated?"delegated":"local"}}:{success:!1,error:o?.reason||`switch_tab failed for logical tab ${r}`,allowFallback:!0}}catch(o){return{success:!1,error:o?.message||"switch_tab failed",allowFallback:!0}}}case D.close_tab:try{return window.close(),{success:!0}}catch{return vi("close_tab failed in embed mode.","CAPABILITY_UNAVAILABLE")}default:return null}}shouldGuardExternalNavigation(t){return this.externalNavigationPolicy==="allow"?!1:!bn(t,this.allowedDomains)}shouldPreserveHostRuntime(t){if(this.crossHostPolicy!=="open_new_tab"||bn(t,this.allowedDomains))return!1;let n=Er(window.location.href),r=Er(t);return!n||!r?!1:n!==r}shouldConvertOpenNewTabToSameTab(t){return this.crossHostPolicy!=="same_tab"||!bn(window.location.href,this.allowedDomains)?!1:bn(t,this.allowedDomains)}isCrossHostInScopeNavigation(t){let n=Er(window.location.href),r=Er(t);return!n||!r||n===r?!1:bn(t,this.allowedDomains)}buildNavigationIntent(t,n){let r="";try{r=crypto.randomUUID()}catch{r=`handoff_${Date.now()}_${Math.floor(Math.random()*1e5)}`}return{handoffId:r,targetUrl:t,sourceRuntimeId:this.runtimeId,sourceLogicalTabId:this.actionGateContext.localLogicalTabId,runId:n?.runId,isCrossHost:n?.isCrossHost??this.isCrossHostInScopeNavigation(t),ts:Date.now()}}notifyAgentNavigation(t){try{this.onBeforeAgentNavigation?.(t)}catch{}}notifyCrossHostNavigation(t){if(t.isCrossHost)try{this.onBeforeCrossHostNavigation?.(t)}catch{}}shouldBlockForOutOfScopeContext(t){return this.externalNavigationPolicy==="allow"||vl.has(t)||sp.has(t)?!1:!bn(window.location.href,this.allowedDomains)}getInterceptedClickTarget(t){let n=this.getClickTargetUrl(t);return n?this.shouldPreserveHostRuntime(n)?!bn(n,this.allowedDomains)&&this.externalNavigationPolicy==="block"?{targetUrl:n,reason:"Blocked same-tab navigation to an out-of-scope destination.",forceOpenInNewTab:!1}:{targetUrl:n,reason:"Opened in a new tab to preserve Rover runtime continuity across hostnames.",forceOpenInNewTab:!0}:this.externalNavigationPolicy==="allow"||bn(n,this.allowedDomains)?null:{targetUrl:n,reason:"Blocked same-tab navigation to an out-of-scope destination.",forceOpenInNewTab:!1}:null}getClickTargetUrl(t){let n=qs(t);if(!n)return null;let{doc:r}=Ur(document,t.iframe_id),o=gn(r,n);if(!o)return null;let i=El(o),a=i?.href||i?.getAttribute("href")||"";return Ei(a,window.location.href)}domainScopeBlockedResponse(t,n,r){let o=this.externalNavigationPolicy==="block"?"block":"open_new_tab_notice";return this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:o,reason:n,allowedDomains:this.allowedDomains,openedInNewTab:!1}),{success:!1,error:n,allowFallback:!0,output:{success:!1,error:{code:"DOMAIN_SCOPE_BLOCKED",message:n,missing:[],next_action:o==="block"?"Stay on the configured domain or update allowedDomains/domainScopeMode.":"Use open_new_tab to access external pages without losing context.",retryable:!1},blocked_url:t,current_url:window.location.href,policy_action:o,from_current_context:!!r?.fromCurrentContext},errorDetails:{code:"DOMAIN_SCOPE_BLOCKED",message:n,retryable:!1,details:{blockedUrl:t,currentUrl:window.location.href,policyAction:o}}}}emitNavigationGuardrail(t){try{this.onNavigationGuardrail?.(t)}catch{}}async openUrlInNewTab(t,n){let r=!bn(t,this.allowedDomains),o=this.snapshotKnownTabIds(),i=this.openVerifiedPopup(t),a;if(i.opened&&this.registerOpenedTab)try{a=(await this.registerOpenedTab({url:t,title:void 0,external:r,openerRuntimeId:this.runtimeId}))?.logicalTabId}catch{}if(i.opened&&!a&&(a=await this.reconcileOpenedTab(t,o)),!i.opened){let d=await this.reconcileOpenedTab(t,o);d&&(i={opened:!0,verified:!1},a=a||d)}let s=i.opened&&!a&&!!this.registerOpenedTab;if(!i.opened){let d="Browser popup settings blocked opening a new tab.";return n?.policyBlocked&&this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:"open_new_tab_notice",reason:n.reason||d,allowedDomains:this.allowedDomains,openedInNewTab:!1}),{success:!1,error:"open_new_tab blocked by browser popup settings",allowFallback:!0,output:{url:t,external:r,logicalTabId:a},errorDetails:{code:"POPUP_BLOCKED",message:d,retryable:!0,next_action:"Allow popups for this site and try again."}}}let l=n?.policyBlocked?n.reason||"Opened in a new tab due to domain policy.":void 0;n?.policyBlocked&&this.emitNavigationGuardrail({blockedUrl:t,currentUrl:window.location.href,policyAction:"open_new_tab_notice",reason:l||"Opened in new tab due to domain policy.",allowedDomains:this.allowedDomains,openedInNewTab:!0});let p=[];return s&&p.push("Tab opened but registration failed; tab may not be targetable."),i.verified||p.push("Tab open was triggered, but browser did not return a popup handle."),{success:!0,output:{url:t,external:r,logicalTabId:a,openedInNewTab:!0,openVerification:i.verified?"verified":"unverified",policyBlocked:!!n?.policyBlocked,message:l,...p.length?{warning:p.join(" ")}:{}},allowFallback:!0}}openVerifiedPopup(t){let n=window.open("about:blank","_blank");if(n){try{n.opener=null}catch{}try{n.location.href=t}catch{}return{opened:!0,verified:!0}}try{let r=window.open(t,"_blank");if(r){try{r.opener=null}catch{}return{opened:!0,verified:!0}}}catch{}try{let r=window.open(t,"_blank","noopener,noreferrer");if(r){try{r.opener=null}catch{}return{opened:!0,verified:!0}}return{opened:!0,verified:!1}}catch{}try{let r=document.createElement("a");return r.href=t,r.target="_blank",r.rel="noopener noreferrer",r.style.display="none",document.body.appendChild(r),r.click(),r.remove(),{opened:!0,verified:!1}}catch{return{opened:!1,verified:!1}}}snapshotKnownTabIds(){let t=new Set;if(!this.listKnownTabs)return t;try{let n=this.listKnownTabs();for(let r of n){let o=Number(r?.logicalTabId);!Number.isFinite(o)||o<=0||t.add(o)}}catch{return t}return t}async reconcileOpenedTab(t,n){if(!this.listKnownTabs)return;let r=Er(t),o=Date.now()+2e3;for(;Date.now()<o;){try{let i=this.listKnownTabs();for(let a of i){let s=Number(a?.logicalTabId);if(!Number.isFinite(s)||s<=0||n.has(s))continue;let l=String(a?.url||"").trim();if(!l)return s;let p=Er(l);if(!r||!p||p===r)return s}}catch{}await new Promise(i=>setTimeout(i,120))}}async openElementInNewTab(t){let n=qs(t);if(!n)return{success:!1,error:"click_element with open_in_new_tab requires element_id.",allowFallback:!0};let{doc:r}=Ur(document,t.iframe_id),o=gn(r,n);if(!o)return{success:!1,error:`click_element: element_id ${String(n)} not found.`,allowFallback:!0};let i=El(o),a=i?.href||i?.getAttribute("href")||"",s=Ei(a,window.location.href);return s?await this.openUrlInNewTab(s,{policyBlocked:!1}):{success:!1,error:"click_element open_in_new_tab only works when target resolves to a valid link URL.",allowFallback:!0}}async waitForElement(t){let n=String(t.selector||"").trim(),r=Math.max(0,Math.min(Number(t.timeout??5e3),3e4));if(!n)return{success:!1,error:"wait_for_element: missing selector",allowFallback:!0};let o=Date.now(),i=document;for(;Date.now()-o<r;){let a=null;try{a=i.querySelector(n)}catch{a=null}if(a||(a=up(i,n)),a)return{success:!0};await new Promise(s=>setTimeout(s,200))}return{success:!1,error:`wait_for_element: not found (${n})`,allowFallback:!0}}async describeImages(t){let n=Ra(t);if(!n.length)return{success:!1,error:"describe_images: element_ids is empty",allowFallback:!1};let r=[],o=[];for(let i of n){let a=gn(document,i);if(!a){o.push(`element_id ${i} not found`);continue}try{let s=await dp(a);if(!s?.data||!s?.mimeType){o.push(`element_id ${i}: unsupported image`);continue}r.push({element_id:i,...s})}catch(s){o.push(`element_id ${i}: ${s?.message||String(s)}`)}}return r.length?{success:!0,output:{images:r,errors:o.length?o:void 0}}:{success:!1,error:o[0]||"describe_images failed",output:{images:[],errors:o}}}ensureUploadProvider(){this.uploadProviderInstalled||(this.uploadProviderInstalled=!0,this.setUploadBytesProvider(async({token:t,byteLength:n})=>{this.pruneUploadStore();let r=this.uploadStore.get(t);if(!r)throw new Error("upload bytes token not found");if(r.bytes.byteLength!==n)throw new Error("upload bytes size mismatch");return r.bytes}))}pruneUploadStore(){let t=Date.now()-6e5;for(let[n,r]of this.uploadStore.entries())r.createdAt<t&&this.uploadStore.delete(n)}async buildUploadPayload(t){let n=String(t.file_url||"").trim();if(n)try{let r=await Jc(0,n,document?.referrer||null),o=r.bytes,i=o.byteLength,a=r.mimeType||t.mime_type||"application/octet-stream",s=t.file_name||r.fileName,l=1024*1024;if(i<=l)return{kind:"upload_file",inlineB64:xl(o),byteLength:i,mimeType:a,fileName:s};this.ensureUploadProvider();let p=crypto.randomUUID();return this.uploadStore.set(p,{bytes:o,createdAt:Date.now()}),{kind:"upload_file",token:p,byteLength:i,mimeType:a,fileName:s,durable:!1}}catch{return}}};function rp(e){return e==="open_url_new_tab"?D.open_new_tab:String(e||"").trim()}function gl(e){return e==="host_only"?"host_only":"registrable_domain"}function bl(e){return e==="allow"||e==="block"||e==="open_new_tab_notice"?e:"open_new_tab_notice"}function yl(e){return e==="same_tab"||e==="open_new_tab"?e:"same_tab"}function Fs(e,t,n){let r=Array.isArray(e)?e:typeof e=="string"&&e.trim()?[e]:[],o=new Set;for(let i of r){let a=String(i||"").trim().toLowerCase().replace(/^\./,"");a&&o.add(a)}if(!o.size){let i=op(t,n);i&&o.add(i)}return Array.from(o)}function op(e,t){let n=String(e||"").trim().toLowerCase();if(!n)return"";if(n==="localhost"||/^\\d+\\.\\d+\\.\\d+\\.\\d+$/.test(n))return`=${n}`;if(t==="host_only")return`=${n}`;let r=n.split(".").filter(Boolean);return r.length<2?n:`${r[r.length-2]}.${r[r.length-1]}`}function Ei(e,t){let n=String(e||"").trim();if(!n)return null;try{return new URL(n,t).toString()}catch{return null}}function bn(e,t){let n=Er(e);if(!n)return!1;if(!t.length)return!0;for(let r of t)if(ip(n,r))return!0;return!1}function Er(e){try{return new URL(e).hostname.toLowerCase()}catch{return null}}function ip(e,t){let n=String(t||"").trim().toLowerCase().replace(/^\./,"");if(!n)return!1;if(n==="*")return!0;if(n.startsWith("=")){let r=n.slice(1);return!!r&&e===r}if(n.startsWith("*.")){let r=n.slice(2);return r?e===r||e.endsWith(`.${r}`):!1}return e===n?!0:e.endsWith(`.${n}`)}function El(e){if(e instanceof HTMLAnchorElement&&e.href)return e;let t=e.closest?.("a[href]");return t instanceof HTMLAnchorElement&&t.href?t:null}function vi(e,t="CAPABILITY_UNAVAILABLE"){return{success:!1,error:e,allowFallback:!0,errorDetails:{code:t,message:e,retryable:!1}}}var vl=new Set([D.describe_images,D.wait_action,D.wait_for_element,D.answer_task,D.solve_captcha,D.network_run_recipe]),sp=new Set([D.goto_url,D.google_search,D.go_back,D.go_forward,D.refresh_page,D.open_new_tab,D.switch_tab,D.close_tab]);function ap(e){return{frameworks:(e.frameworks||[]).filter(n=>n in is).map(n=>is[n]),listenersRaw:e.listenersRaw??"",role:e.role??null,pattern:e.pattern,value:e.value??null}}async function wl(e){try{let n=(e.ownerDocument||document).defaultView||window,r=n.__RTRVR_INTERNAL_KEY__||"__RTRVR_INTERNAL__",i=n[r]?.flushScan;if(typeof i=="function"){await i({mode:"priority",includeShadow:!0,includeSameOriginIframes:!0,budgetMs:1500});return}n.rtrvrAIMarkInteractiveElements?.()}catch{}}function cp(e,t){if(t!==D.click_element)return"standard";let n=lr(e||"");if(!n)return"standard";let r=new Set(n.entries.map(l=>Bn[l.id]).filter(l=>typeof l=="string")),o=r.has("click")||r.has("mousedown")||r.has("mouseup")||r.has("pointerdown")||r.has("pointerup")||r.has("touchend");if((r.has("mouseenter")||r.has("mouseover")||r.has("pointerenter"))&&o)return"hover-activate";let a=r.has("touchstart"),s=r.has("touchend");return a&&s?"touch-sequence":"standard"}function xl(e){let t=new Uint8Array(e),n="",r=32768;for(let o=0;o<t.length;o+=r)n+=String.fromCharCode(...t.subarray(o,o+r));return btoa(n)}function Tl(e){let t=Number(e);if(!Number.isFinite(t))return null;let n=Math.trunc(t);return n>0?n:null}function Il(e){let t=[];for(let n of Mo){let r=e?.[n];if(r==null)continue;if(Array.isArray(r)){for(let i of r){let a=Tl(i);a!=null&&t.push(a)}continue}let o=Tl(r);o!=null&&t.push(o)}return Array.from(new Set(t))}function lp(e){return Il(e).length>0}function qs(e){let t=Il(e);return t.length?t[0]:null}function up(e,t){let n=t.toLowerCase(),r=["button","a","input","textarea","select","label","[role]","div","span"],o=e.querySelectorAll(r.join(","));for(let i of Array.from(o))if((i.textContent||"").trim().toLowerCase().includes(n)||(i.getAttribute("aria-label")||"").toLowerCase().includes(n))return i;return null}async function dp(e){if(e instanceof HTMLCanvasElement){let o=e.toDataURL(),i=kl(o);if(!i)throw new Error("canvas toDataURL failed");return i}if(e instanceof SVGElement){let o=new XMLSerializer().serializeToString(e);return{data:btoa(unescape(encodeURIComponent(o))),mimeType:"image/svg+xml",displayName:"svg"}}if(e instanceof HTMLImageElement){let o=e.currentSrc||e.src;return await _l(o,e.alt||e.getAttribute("aria-label")||void 0)}let n=window.getComputedStyle(e).backgroundImage||"",r=/url\\((['\"]?)(.*?)\\1\\)/.exec(n);if(r?.[2])return await _l(r[2],e.getAttribute("aria-label")||void 0);throw new Error("unsupported element")}function kl(e){let t=/^data:([^;]+);base64,(.*)$/.exec(e);return t?{mimeType:t[1],data:t[2]}:null}async function _l(e,t){if(!e)throw new Error("missing src");if(e.startsWith("data:")){let s=kl(e);if(!s)throw new Error("invalid data url");return{...s,displayName:t}}let n=await fetch(e,{mode:"cors"});if(!n.ok)throw new Error(`fetch failed (${n.status})`);let r=await n.blob(),o=await r.arrayBuffer(),i=xl(o),a=r.type||"image/png";return{data:i,mimeType:a,displayName:t}}function Rl(e,t){e.onmessage=async n=>{let r=n.data;if(!r||r.t!=="req")return;let{id:o,method:i,params:a}=r;try{let s=t[i];if(!s)throw new Error(`No handler for ${i}`);let l=await s(a);e.postMessage({t:"res",id:o,ok:!0,result:l})}catch(s){e.postMessage({t:"res",id:o,ok:!1,error:{message:s?.message||String(s)}})}}}var fp="Rover",pp="https://www.rtrvr.ai/rover/mascot.mp4",hp="https://www.rtrvr.ai/rover/mascot.webm";function Al(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Sl(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function mp(e){return e.status?e.status:e.kind==="tool_start"||e.kind==="plan"||e.kind==="thought"?"pending":e.kind==="tool_result"?"success":e.kind==="error"?"error":"info"}function gp(e){let t=String(e.title||"").trim().toLowerCase();return t.startsWith("running ")?`tool:${t.replace(/^running\s+/,"").trim()}`:t.endsWith(" completed")?`tool:${t.replace(/\s+completed$/,"").trim()}`:t==="run started"||t==="run resumed"||t==="run completed"?"run":e.kind==="status"?`status:${t||"status"}`:e.id||Al("trace")}function ht(e){return String(e||"").trim()}function bp(e){let t=String(e||"").trim();return t?t.slice(0,64):fp}function yp(e){let t=String(e||"").trim();return t?t[0].toUpperCase():"R"}function Ep(e){return String(e||"").replace(/[^a-zA-Z0-9]/g,"").slice(0,3).toUpperCase()||"RVR"}function Cl(e){let t=ht(e),n=/^(Analyze|Route|Execute|Verify|Complete):\s*(.*)$/i.exec(t);if(!n)return{plainTitle:t};let r=n[1].toLowerCase(),o=ht(n[2]||t);return{stage:r,plainTitle:o||t}}function vp(e){let t=(e.title||"").toLowerCase();if(t==="run started"||t==="run resumed"||t==="run completed"||t==="started new task"||t==="execution completed")return"detail";if(e.kind==="status"){let n=Cl(e.title||"");if(n.stage==="analyze"||n.stage==="route"||n.stage==="complete")return"detail"}return"primary"}function $s(e,t){let n=/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)|\*\*(.+?)\*\*/g,r=0,o;for(;(o=n.exec(t))!==null;){if(o.index>r&&e.appendChild(document.createTextNode(t.slice(r,o.index))),o[1]&&o[2]){let i=document.createElement("a");i.className="rvLink",i.href=o[2],i.target="_blank",i.rel="noopener noreferrer",i.textContent=o[1],e.appendChild(i)}else if(o[3]){let i=document.createElement("strong");i.textContent=o[3],e.appendChild(i)}r=o.index+o[0].length}r<t.length&&e.appendChild(document.createTextNode(t.slice(r)))}function Zn(e){let t=document.createDocumentFragment(),n=e.split(`
|
|
11
|
+
`),r=null;for(let o of n){let i=o.trim();if(!i){r&&(t.appendChild(r),r=null);continue}if(i==="---"){r&&(t.appendChild(r),r=null);let l=document.createElement("hr");l.className="rvSep",t.appendChild(l);continue}if(i.startsWith("- ")){r||(r=document.createElement("ul"),r.className="rvList");let l=document.createElement("li");$s(l,i.slice(2)),r.appendChild(l);continue}if(r&&(t.appendChild(r),r=null),/^Step \d+/i.test(i)){let l=document.createElement("div");l.className="rvStepHeader",l.textContent=i,t.appendChild(l);continue}if(i.startsWith("[error] ")){let l=document.createElement("div");l.className="rvError",l.textContent=i.slice(8),t.appendChild(l);continue}if(i.startsWith("[next] ")){let l=document.createElement("div");l.className="rvNext",l.textContent=i.slice(7),t.appendChild(l);continue}let a=i.match(/^\*\*(.+?):\*\*\s*(.*)$/);if(a){let l=document.createElement("div");l.className="rvKv";let p=document.createElement("span");p.className="rvKvLabel",p.textContent=a[1];let d=document.createElement("span");d.className="rvKvValue",$s(d,a[2]),l.appendChild(p),l.appendChild(d),t.appendChild(l);continue}let s=document.createElement("div");s.className="rvLine",$s(s,i),t.appendChild(s)}return r&&t.appendChild(r),t}function _i(e,t){let n=document.createElement("div");if(n.className="expandableWrap",e.length<=t)return n.appendChild(Zn(e)),n;let r=e.split(`
|
|
12
|
+
`),o=0,i=0;for(let p=0;p<r.length;p++)if(o+=r[p].length+1,o>=t){i=p+1;break}i===0&&(i=1);let a=r.slice(0,i).join(`
|
|
13
|
+
`),s=r.slice(i).join(`
|
|
14
|
+
`),l=document.createElement("div");if(l.className="expandPreview",l.appendChild(Zn(a)),n.appendChild(l),s.trim()){let p=document.createElement("div");p.className="expandRest",p.appendChild(Zn(s)),p.style.display="none",n.appendChild(p);let d=document.createElement("button");d.type="button",d.className="expandToggle",d.textContent="...Show more",d.addEventListener("click",y=>{y.stopPropagation();let I=p.style.display==="none";p.style.display=I?"block":"none",d.textContent=I?" Show less":"...Show more"}),n.appendChild(d)}return n}function xi(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Ti(e){if(e==null)return"null";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return`[${e.length} item${e.length===1?"":"s"}]`;if(xi(e)){let t=Object.keys(e);return t.length?`{ ${t.slice(0,4).join(", ")}${t.length>4?", ...":""} }`:"{}"}try{return String(e)}catch{return"value"}}function wp(e){try{let t=new WeakSet;return JSON.stringify(e,(n,r)=>!r||typeof r!="object"?r:t.has(r)?"[Circular]":(t.add(r),r),2)||"null"}catch{return Ti(e)}}function Nl(e){let t=document.createElement("button");return t.type="button",t.className="rvStructuredMore",t.textContent=`Show ${Math.min(25,e.total-e.shown)} more (${e.total-e.shown} left)`,t.addEventListener("click",n=>{n.stopPropagation(),e.onLoadMore()}),t}function Tp(e){let t=document.createElement("div");t.className="rvRawToggleWrap";let n=document.createElement("button");n.type="button",n.className="rvRawToggle",n.textContent="View raw JSON";let r=document.createElement("pre");return r.className="rvRawJson",r.textContent=wp(e),r.style.display="none",n.addEventListener("click",o=>{o.stopPropagation();let i=r.style.display==="none";r.style.display=i?"block":"none",n.textContent=i?"Hide raw JSON":"View raw JSON"}),t.appendChild(n),t.appendChild(r),t}function _p(e){let t=document.createElement("div");if(t.className="rvStructuredPrimitive",e===null)return t.textContent="null",t.classList.add("isNull"),t;if(typeof e=="string"){let n=ht(e);return n?(n.length>280?t.appendChild(_i(n,280)):t.appendChild(Zn(n)),t):(t.textContent='""',t)}return t.textContent=String(e),t}function xp(e){let t=e.slice(0,25);if(!t.length)return;let n=[];for(let r of t){if(!xi(r))return;for(let o of Object.keys(r))n.includes(o)||n.push(o);if(n.length>8)return}for(let r of t){let o=r;for(let i of n){let a=o[i];if(a!=null&&!(typeof a=="string"||typeof a=="number"||typeof a=="boolean"))return}}return n.length?n:void 0}function Ip(e,t,n){let r=document.createElement("div");if(r.className="rvStructuredArray",!e.length){let p=document.createElement("div");return p.className="rvStructuredEmpty",p.textContent="No items",r.appendChild(p),r}let o=xp(e),i=Math.min(25,e.length),a=document.createElement("div");a.className=o?"rvStructuredTable":"rvStructuredList",r.appendChild(a);let s=document.createElement("div");s.className="rvStructuredControls",r.appendChild(s);let l=()=>{if(a.innerHTML="",o){let p=document.createElement("table");p.className="rvTable";let d=document.createElement("thead"),y=document.createElement("tr"),I=document.createElement("th");I.textContent="#",y.appendChild(I);for(let _ of o){let x=document.createElement("th");x.textContent=_,y.appendChild(x)}d.appendChild(y),p.appendChild(d);let g=document.createElement("tbody");for(let _=0;_<i;_+=1){let x=document.createElement("tr"),B=document.createElement("td");B.textContent=String(_+1),x.appendChild(B);let j=e[_]||{};for(let F of o){let U=document.createElement("td"),q=j[F];q==null?U.textContent="\u2014":U.textContent=Ti(q),x.appendChild(U)}g.appendChild(x)}p.appendChild(g),a.appendChild(p)}else for(let p=0;p<i;p+=1){let d=e[p],y=document.createElement("div");y.className="rvStructuredItem";let I=document.createElement("div");I.className="rvStructuredItemLabel",I.textContent=`#${p+1}`,y.appendChild(I);let g=document.createElement("div");g.className="rvStructuredItemBody",g.appendChild(n(d,t+1)),y.appendChild(g),a.appendChild(y)}s.innerHTML="",i<e.length&&s.appendChild(Nl({total:e.length,shown:i,onLoadMore:()=>{i=Math.min(e.length,i+25),l()}}))};return l(),r}function kp(e,t,n){let r=document.createElement("div");r.className="rvStructuredObject";let o=Object.entries(e);if(!o.length){let p=document.createElement("div");return p.className="rvStructuredEmpty",p.textContent="No fields",r.appendChild(p),r}let i=Math.min(25,o.length),a=document.createElement("div");a.className="rvStructuredObjectRows",r.appendChild(a);let s=document.createElement("div");s.className="rvStructuredControls",r.appendChild(s);let l=()=>{a.innerHTML="";for(let p=0;p<i;p+=1){let[d,y]=o[p],I=document.createElement("div");I.className="rvStructuredRow";let g=document.createElement("div");g.className="rvStructuredKey",g.textContent=d;let _=document.createElement("div");_.className="rvStructuredValue",_.appendChild(n(y,t+1)),I.appendChild(g),I.appendChild(_),a.appendChild(I)}s.innerHTML="",i<o.length&&s.appendChild(Nl({total:o.length,shown:i,onLoadMore:()=>{i=Math.min(o.length,i+25),l()}}))};return l(),r}function Ws(e,t=0){if(t>=4){let r=document.createElement("div");return r.className="rvStructuredCapped",r.textContent=Ti(e),r}if(e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean")return _p(e);if(Array.isArray(e))return Ip(e,t,Ws);if(xi(e))return kp(e,t,Ws);let n=document.createElement("div");return n.className="rvStructuredPrimitive",n.textContent=Ti(e),n}function Ll(e){if(e.type==="text"){let a=ht(e.text);return a?_i(a,280):void 0}let t=document.createElement("section");t.className="rvStructuredCard";let n=document.createElement("div");n.className="rvStructuredHeader";let r=document.createElement("span");r.className="rvStructuredLabel",r.textContent=ht(e.label||(e.type==="tool_output"?e.toolName?`${e.toolName} output`:"Tool output":"JSON output")),n.appendChild(r);let o=document.createElement("span");o.className="rvStructuredType",Array.isArray(e.data)?o.textContent=`array \xB7 ${e.data.length}`:xi(e.data)?o.textContent=`object \xB7 ${Object.keys(e.data).length}`:o.textContent=typeof e.data,n.appendChild(o),t.appendChild(n);let i=document.createElement("div");return i.className="rvStructuredBody",i.appendChild(Ws(e.data)),t.appendChild(i),t.appendChild(Tp(e.data)),t}function Rp(e,t){let n=document.createDocumentFragment(),r=Array.isArray(t)?t:[],o=!1;for(let s of r){let l=Ll(s);l&&(o=!0,n.appendChild(l))}if(!o){let s=ht(e);return s&&(s.length>280?n.appendChild(_i(s,280)):n.appendChild(Zn(s))),n}let i=ht(e),a=r.some(s=>s.type==="text"&&ht(s.text)===i);if(i&&!a){let s=document.createElement("div");s.className="rvLine",s.appendChild(Zn(i)),n.insertBefore(s,n.firstChild)}return n}function Ml(e){let t=bp(e.agent?.name),n=yp(t),r=Ep(t),o=e.visitorName,i=document.createElement("div");i.id="rover-widget-root",document.documentElement.appendChild(i);let a=i.attachShadow({mode:"closed"}),s=document.createElement("style");s.textContent=`
|
|
15
15
|
@font-face {
|
|
16
16
|
font-family: 'Manrope';
|
|
17
17
|
font-style: normal;
|
|
@@ -19,7 +19,7 @@ Author: ${a.textContent} `),i.textContent&&(t+=`Comment: ${i.textContent}
|
|
|
19
19
|
font-display: swap;
|
|
20
20
|
src: url('https://rover.rtrvr.ai/rover/fonts/manrope-latin.woff2') format('woff2');
|
|
21
21
|
}
|
|
22
|
-
`,document.head.appendChild(
|
|
22
|
+
`,document.head.appendChild(s);let l=document.createElement("style");l.textContent=`
|
|
23
23
|
/* \u2500\u2500 Step 2: Self-hosted font \u2500\u2500 */
|
|
24
24
|
@font-face {
|
|
25
25
|
font-family: 'Manrope';
|
|
@@ -1072,12 +1072,29 @@ Author: ${a.textContent} `),i.textContent&&(t+=`Comment: ${i.textContent}
|
|
|
1072
1072
|
display: flex;
|
|
1073
1073
|
justify-content: flex-end;
|
|
1074
1074
|
align-items: center;
|
|
1075
|
+
gap: 8px;
|
|
1075
1076
|
position: sticky;
|
|
1076
1077
|
bottom: 0;
|
|
1077
1078
|
padding-top: 2px;
|
|
1078
1079
|
background: linear-gradient(to bottom, rgba(255, 247, 242, 0), rgba(255, 247, 242, 0.94) 40%);
|
|
1079
1080
|
}
|
|
1080
1081
|
|
|
1082
|
+
.questionPromptCancel {
|
|
1083
|
+
border: 1px solid var(--rv-border-strong);
|
|
1084
|
+
background: rgba(255, 255, 255, 0.88);
|
|
1085
|
+
color: var(--rv-text-secondary);
|
|
1086
|
+
border-radius: var(--rv-radius-sm);
|
|
1087
|
+
font-size: 12px;
|
|
1088
|
+
font-weight: 700;
|
|
1089
|
+
letter-spacing: 0.01em;
|
|
1090
|
+
padding: 6px 10px;
|
|
1091
|
+
cursor: pointer;
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
.questionPromptCancel:hover {
|
|
1095
|
+
background: rgba(242, 246, 250, 0.95);
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1081
1098
|
.questionPromptSubmit {
|
|
1082
1099
|
border: 1px solid var(--rv-accent-border);
|
|
1083
1100
|
background: var(--rv-accent-soft);
|
|
@@ -1624,13 +1641,15 @@ Author: ${a.textContent} `),i.textContent&&(t+=`Comment: ${i.textContent}
|
|
|
1624
1641
|
padding: 8px 22px 8px 10px;
|
|
1625
1642
|
}
|
|
1626
1643
|
}
|
|
1627
|
-
`;let
|
|
1644
|
+
`;let p=document.createElement("div");p.className="rover",p.dataset.mood="idle";let d=document.createElement("button");d.className="launcher",d.setAttribute("aria-label",`Open ${t} assistant`);let y=e.mascot?.disabled===!0,I=null;if(!y){I=document.createElement("video"),I.autoplay=!0,I.muted=!0,I.loop=!0,I.playsInline=!0,I.preload="metadata";let N=document.createElement("source");N.src=e.mascot?.mp4Url||pp,N.type="video/mp4";let $=document.createElement("source");$.src=e.mascot?.webmUrl||hp,$.type="video/webm",I.appendChild(N),I.appendChild($),d.appendChild(I)}let g=document.createElement("span");g.className="launcherFallback",g.textContent=r;let _=document.createElement("div");_.className="launcherShine",d.appendChild(g),d.appendChild(_);let x=document.createElement("div");x.className="greetingBubble";let B=document.createElement("span");B.className="greetingText";let j=document.createElement("button");j.type="button",j.className="greetingClose",j.textContent="\xD7",j.setAttribute("aria-label","Dismiss");let F=document.createElement("div");F.className="greetingDots";for(let N=0;N<3;N++){let $=document.createElement("span");$.className="greetingDot",F.appendChild($)}x.appendChild(F),x.appendChild(B),x.appendChild(j);let U=document.createElement("div");U.className="panel";let q=document.createElement("div");q.className="header";let J=document.createElement("div");J.className="avatar";let ae=null;!y&&I&&(ae=I.cloneNode(!0),J.appendChild(ae));let ue=document.createElement("span");ue.className="avatarFallback",ue.textContent=n,J.appendChild(ue);let he=document.createElement("div");he.className="meta";let se=document.createElement("div");se.className="title",se.textContent=t;let be=document.createElement("div");be.className="status";let pe=document.createElement("span");pe.className="statusDot";let _e=document.createElement("span");_e.textContent="ready",be.appendChild(pe),be.appendChild(_e),he.appendChild(se),he.appendChild(be);let Ie=document.createElement("div");Ie.className="headerActions";let Ye=document.createElement("span");Ye.className="modeBadge controller",Ye.textContent="active";let we=document.createElement("button");we.type="button",we.className="overflowBtn",we.setAttribute("aria-label","More options"),we.innerHTML="⋯";let He=document.createElement("button");He.type="button",He.className="closeBtn",He.setAttribute("aria-label","Close Rover panel"),He.textContent="\xD7";let Xe=document.createElement("button");Xe.type="button",Xe.className="muteBtn",Xe.setAttribute("aria-label","Toggle sound");let Ke=e.muted??!1;try{let N=localStorage.getItem("rover:muted");N!==null&&(Ke=N!=="false")}catch{}let Kt='<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><line x1="23" y1="9" x2="17" y2="15"/><line x1="17" y1="9" x2="23" y2="15"/></svg>',cn='<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14"/><path d="M15.54 8.46a5 5 0 0 1 0 7.07"/></svg>';function Ut(){Xe.innerHTML=Ke?Kt:cn,Xe.setAttribute("aria-label",Ke?"Unmute":"Mute"),I&&(I.muted=Ke),ae&&(ae.muted=Ke)}Ut(),Xe.addEventListener("click",N=>{N.stopPropagation(),Ke=!Ke;try{localStorage.setItem("rover:muted",String(Ke))}catch{}Ut()});let Pt=document.createElement("button");Pt.type="button",Pt.className="stopBtn",Pt.setAttribute("aria-label","Cancel task"),Pt.textContent="\u25A0",Ie.appendChild(Pt),Ie.appendChild(Ye),Ie.appendChild(Xe),Ie.appendChild(we),Ie.appendChild(He);let gt=document.createElement("div");gt.className="overflowMenu";let Ue=document.createElement("button");Ue.type="button",Ue.className="menuItem",Ue.textContent="New task";let Bt=document.createElement("button");Bt.type="button",Bt.className="menuItem danger",Bt.textContent="End task";let jr=document.createElement("div");jr.className="menuDivider";let Nn=document.createElement("button");Nn.type="button",Nn.className="menuItem",Nn.textContent="Show details";let _t=document.createElement("button");_t.type="button",_t.className="menuItem",_t.textContent="Take control",_t.style.display="none",gt.appendChild(Ue),gt.appendChild(Bt),gt.appendChild(jr),gt.appendChild(Nn),gt.appendChild(_t),e.showTaskControls===!1&&(Ue.style.display="none",Bt.style.display="none"),q.appendChild(J),q.appendChild(he),q.appendChild(Ie),q.appendChild(gt);let jn=document.createElement("div");jn.style.cssText="position:relative;flex:1;min-height:0;display:flex;flex-direction:column;";let Qe=document.createElement("div");Qe.className="feed";let at=document.createElement("div");at.className="typingIndicator";for(let N=0;N<3;N++){let $=document.createElement("span");$.className="typingDot",at.appendChild($)}Qe.appendChild(at);let ct=document.createElement("button");ct.type="button",ct.className="scrollBtn",ct.setAttribute("aria-label","Scroll to bottom"),ct.innerHTML='<svg viewBox="0 0 24 24"><polyline points="6 9 12 15 18 9"></polyline></svg>',jn.appendChild(Qe),jn.appendChild(ct);let Ht=document.createElement("div");Ht.className="taskSuggestion",Ht.innerHTML=`
|
|
1628
1645
|
<div class="taskSuggestionText"></div>
|
|
1629
1646
|
<div class="taskSuggestionActions">
|
|
1630
1647
|
<button type="button" class="taskSuggestionBtn primary">Start new</button>
|
|
1631
1648
|
<button type="button" class="taskSuggestionBtn secondary">Continue</button>
|
|
1632
1649
|
</div>
|
|
1633
|
-
`;let Xt=document.createElement("div");Xt.className="shortcutsEmptyState";let rn=document.createElement("div");rn.className="shortcutsHeading",rn.textContent=o?`Hey ${o}! What can I help with?`:`What can ${t} help you with?`;let qe=document.createElement("div");qe.className="shortcutsGrid",Xt.appendChild(rn),Xt.appendChild(qe),je.appendChild(Xt);let Rn=document.createElement("div");Rn.className="shortcutsBar";let Ut=document.createElement("div");Ut.className="questionPrompt";let kn=document.createElement("div");kn.className="questionPromptTitle",kn.textContent="Need a bit more info";let Ft=document.createElement("form");Ft.className="questionPromptForm";let Sn=document.createElement("div");Sn.className="questionPromptList",Ft.appendChild(Sn);let nr=document.createElement("div");nr.className="questionPromptActions";let mn=document.createElement("button");mn.type="submit",mn.className="questionPromptSubmit",mn.textContent="Continue",nr.appendChild(mn),Ft.appendChild(nr),Ut.appendChild(kn),Ut.appendChild(Ft);let Kt=document.createElement("form");Kt.className="composer";let on=document.createElement("textarea");on.rows=1,on.placeholder=`Ask ${t} to act on this website...`,Kt.appendChild(on);let gn=document.createElement("button");gn.type="submit",gn.className="sendBtn",gn.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>',Kt.appendChild(gn);let ye=document.createElement("div");ye.className="resizeHandle",ye.setAttribute("aria-hidden","true"),P.appendChild(q),P.appendChild(qn),P.appendChild(Ht),P.appendChild(Rn),P.appendChild(Ut),P.appendChild(Kt),P.appendChild(ye),m.appendChild(p),m.appendChild(S),m.appendChild(P),s.appendChild(u),s.appendChild(m);let Ue=on,bn=Ht.querySelector(".taskSuggestionText"),ut=Ht.querySelector(".taskSuggestionBtn.primary"),$n=Ht.querySelector(".taskSuggestionBtn.secondary"),vr=new Set,Wn=new Map,We=[],Tr="controller",_r=!1,sn=!1,In=!1,an=e.shortcuts?.slice(0,12)||[],dt=null,Bt=!1,Tt=null,An=!1,qt=!1,Cn=0,Vn=!1,c=null,E=null,y=!1,b=null,f=null,d={};function g(){An=!An,mt.classList.toggle("visible",An)}function T(){An=!1,mt.classList.remove("visible")}function L(N){an=N.filter($=>$&&$.enabled!==!1).slice(0,12),qe.innerHTML="";for(let $ of an){let Q=document.createElement("button");if(Q.type="button",Q.className="shortcutCard",$.icon){let ie=document.createElement("span");ie.className="shortcutCardIcon",ie.textContent=$.icon,Q.appendChild(ie)}let le=document.createElement("span");if(le.className="shortcutCardLabel",le.textContent=$.label,Q.appendChild(le),$.description){let ie=document.createElement("span");ie.className="shortcutCardDesc",ie.textContent=$.description,Q.appendChild(ie)}Q.addEventListener("click",()=>e.onShortcutClick?.($)),qe.appendChild(Q)}Rn.innerHTML="";for(let $ of an){let Q=document.createElement("button");if(Q.type="button",Q.className="shortcutChip",$.icon){let ie=document.createElement("span");ie.className="shortcutChipIcon",ie.textContent=$.icon,Q.appendChild(ie)}let le=document.createTextNode($.label);Q.appendChild(le),Q.addEventListener("click",()=>e.onShortcutClick?.($)),Rn.appendChild(Q)}C()}function C(){let N=an.length>0,$=!!b?.questions?.length,Q=N&&!In&&!sn,le=N&&In&&!sn&&!$;Xt.classList.toggle("visible",Q),Rn.classList.toggle("visible",le)}function D(N){let $=ht(N);if($){if(B.textContent=$,S.classList.contains("visible")){S.classList.add("textVisible");return}Vn||P.classList.contains("open")||(Vn=!0,S.classList.remove("dismissing","textVisible"),S.classList.add("visible"),E&&(clearTimeout(E),E=null),E=setTimeout(()=>{E=null,S.classList.add("textVisible")},800))}}function U(){if(E&&(clearTimeout(E),E=null),!S.classList.contains("visible"))return;S.classList.add("dismissing");let N=()=>{S.classList.remove("visible","dismissing"),S.removeEventListener("animationend",N)};S.addEventListener("animationend",N),c&&(clearTimeout(c),c=null)}function G(N){o=N||void 0,o?rn.textContent=`Hey ${o}! What can I help with?`:rn.textContent=`What can ${t} help you with?`}function X(N){if(!N||!Array.isArray(N.questions))return[];let $=[],Q=new Set;for(let le=0;le<N.questions.length;le+=1){let ie=N.questions[le];if(!ie||typeof ie!="object")continue;let Qe=String(ie.key||ie.id||"").trim()||`clarification_${le+1}`,He=String(ie.query||ie.question||"").trim();if(!He)continue;let Ze=typeof ie.required=="boolean",St=typeof ie.optional=="boolean",Je=Ze?!!ie.required:St?!ie.optional:!0;Q.has(Qe)||(Q.add(Qe),$.push({key:Qe,query:He,...typeof ie.id=="string"&&ie.id.trim()?{id:ie.id.trim()}:{},...typeof ie.question=="string"&&ie.question.trim()?{question:ie.question.trim()}:{},...Array.isArray(ie.choices)?{choices:ie.choices}:{},required:Je}))}return $.slice(0,6)}function oe(N){return N.map($=>{let Q=Array.isArray($.choices)?$.choices.map(ie=>ht(String(ie||""))).filter(Boolean).join("|"):"",le=$.required===!1?"optional":"required";return`${$.key}::${ht($.query)}::${Q}::${le}`}).join("||")}function we(N){let $=ht(N.query||N.question||"");if(!$)return`Answer for ${N.key}`;let Q=$.replace(/\s+/g," ").replace(/[?.!:\s]+$/,"").slice(0,72);return Q?`Answer: ${Q}`:`Answer for ${N.key}`}function ne(N){for(let $ of Array.from(Ft.querySelectorAll(".questionPromptInput"))){let Q=$;if(Q.dataset.key===N)return Q}return null}function ee(N){let $=X(N),Q=document.activeElement,le=Q instanceof HTMLInputElement&&Q.classList.contains("questionPromptInput")&&Ut.contains(Q)?Q:null,ie=le?.dataset.key,Qe=le?.selectionStart??null,He=le?.selectionEnd??null;if(!$.length){b=null,f=null,d={},Sn.innerHTML="",Ut.classList.remove("visible"),C();return}let Ze=oe($),St=Ze!==f||!b;if(b={questions:$},St){let Je=d;d={},Sn.innerHTML="";for(let it of b.questions){let Qt=document.createElement("label");Qt.className="questionPromptItem";let Jt=document.createElement("span");Jt.className="questionPromptLabel",Jt.textContent=it.required===!1?`${it.query} (optional)`:it.query,Qt.appendChild(Jt);let Ct=document.createElement("input");Ct.type="text",Ct.className="questionPromptInput",Ct.dataset.key=it.key,Ct.placeholder=we(it),Ct.required=it.required!==!1;let cn=String(Je[it.key]||"");d[it.key]=cn,Ct.value=cn,Ct.addEventListener("input",()=>{d[it.key]=Ct.value,Ct.classList.remove("invalid")}),Qt.appendChild(Ct),Sn.appendChild(Qt)}f=Ze}if(Ut.classList.add("visible"),Te(),C(),ie){let Je=ne(ie);if(Je){if(Je.focus(),Qe!==null||He!==null){let it=Qe??Je.value.length,Qt=He??it;try{Je.setSelectionRange(it,Qt)}catch{}}return}}if(St){let it=b.questions.find(Ct=>!ht(d[Ct.key]||""))?.key||b.questions[0]?.key;if(!it)return;let Qt=ne(it),Jt=!Q||Q===document.body||!P.contains(Q);Qt&&Jt&&Qt.focus()}}function ce(){sn&&y?(rt.classList.add("visible"),je.appendChild(rt),he()):rt.classList.remove("visible")}function ge(N,$=0){m.dataset.mood=N,Tt!=null&&(window.clearTimeout(Tt),Tt=null),$>0&&N!=="idle"&&(Tt=window.setTimeout(()=>{m.dataset.mood="idle",ce(),Tt=null},$))}function Xe(){return je.scrollHeight-je.scrollTop-je.clientHeight<60}function he(){qt?ot.classList.add("visible"):(requestAnimationFrame(()=>{je.scrollTo({top:je.scrollHeight,behavior:"smooth"}),Cn=Date.now()}),ot.classList.remove("visible"))}je.addEventListener("scroll",()=>{Date.now()-Cn<200||(Xe()?(qt=!1,ot.classList.remove("visible")):(qt=!0,ot.classList.add("visible")))},{passive:!0}),ot.addEventListener("click",()=>{qt=!1,Cn=Date.now(),je.scrollTo({top:je.scrollHeight,behavior:"smooth"}),ot.classList.remove("visible")});function Te(){let N=Tr==="observer"&&!_r;Ue.disabled=N,mn.disabled=N;for(let $ of Array.from(Ft.querySelectorAll(".questionPromptInput")))$.disabled=N}function _e(N){Bt=N,m.dataset.showDetails=N?"true":"false",xn.textContent=Bt?"Hide details":"Show details";for(let $ of We){let Q=$.dataset.status,le=Q==="success"||Q==="error"||Q==="info";$.classList.toggle("compact",!Bt&&le)}}function l(){m.style.display="",P.classList.remove("closing"),P.classList.add("open"),U(),ge("idle"),e.onOpen?.(),Ue.disabled||Ue.focus()}function w(){if(T(),!P.classList.contains("open")){e.onClose?.();return}P.classList.remove("open"),P.classList.add("closing"),ge("idle");let N=()=>{P.classList.remove("closing"),P.removeEventListener("animationend",N)};P.addEventListener("animationend",N),e.onClose?.()}function R(){m.style.display=""}function _(){w(),m.style.display="none"}function k(N,$,Q){let le=ht($),ie=Q?.blocks;if(!le&&(!ie||ie.length===0))return;let Qe=document.createElement("div");Qe.className=`entry message ${N}`;let He=document.createElement("div");He.className="bubble",N==="assistant"?He.appendChild(dp(le,ie)):He.textContent=le;let Ze=document.createElement("div");Ze.className="stamp",Ze.textContent=bl(Date.now()),Qe.appendChild(He),Qe.appendChild(Ze),je.appendChild(Qe),N==="assistant"&&sn&&y&&(y=!1,ce()),In=!0,C(),N==="user"?ge("typing",1200):N==="assistant"?ge("success",1400):ge("running",900),he()}function O(){for(let N of Array.from(je.querySelectorAll(".entry.message")))N.remove();In=!1,ee(void 0),C()}function V(N){let $=Wn.get(N);if($)return $;let Q=document.createElement("div");Q.className="entry trace pending";let le=document.createElement("div");le.className="traceTop";let ie=document.createElement("div");ie.className="traceMeta";let Qe=document.createElement("span");Qe.className="traceStage",Qe.textContent="step";let He=document.createElement("div");He.className="traceTitle";let Ze=document.createElement("div");Ze.className="traceTs",ie.appendChild(Qe),ie.appendChild(He),le.appendChild(ie),le.appendChild(Ze);let St=document.createElement("div");return St.className="traceDetail",Q.appendChild(le),Q.appendChild(St),Wn.set(N,Q),We.push(Q),je.appendChild(Q),Q}function K(N,$){let Q=Number($.ts)||Date.now(),le=Zf($),ie=N.querySelector(".traceTop"),He=ie.querySelector(".traceMeta").querySelector(".traceStage"),Ze=ie.querySelector(".traceTitle"),St=ie.querySelector(".traceTs"),Je=N.querySelector(".traceDetail"),it=yl($.title||"");Ze.textContent=it.plainTitle||"Step",He.textContent=it.stage||$.kind||"step",He.style.display=it.stage||$.kind==="status"||$.kind==="plan"||$.kind==="thought"?"":"none",St.textContent=bl(Q),Je.innerHTML="";let Qt=Array.isArray($.detailBlocks)?$.detailBlocks:[],Jt=ht($.detail||"");if(Qt.length>0){for(let cn of Qt){let ma=vl(cn);ma&&Je.appendChild(ma)}if(Jt){let cn=document.createElement("div");cn.className="rvLine",cn.appendChild(Xn(Jt)),Je.insertBefore(cn,Je.firstChild)}Je.style.display=""}else if(Jt){let cn=$.kind==="thought"?150:$.kind==="tool_start"||$.kind==="tool_result"?100:280;Jt.length>cn?Je.appendChild(pi(Jt,cn)):Je.appendChild(Xn(Jt)),Je.style.display=""}else Je.style.display="none";N.classList.remove("pending","success","error","info"),N.classList.add(le),N.dataset.status=le,N.dataset.kind=$.kind,N.dataset.visibility=op($);let Ct=le==="success"||le==="error"||le==="info";N.classList.toggle("compact",!Bt&&Ct),le==="error"?ge("error",2200):le==="success"?ge("success",1200):le==="pending"&&ge("running",800)}function fe(N){let $=ht(N.title||"");if(!$||$.toLowerCase()==="assistant update")return;let Q=N.id||El("timeline");if(N.id&&vr.has(Q))return;vr.add(Q);let le=ep(N),ie=le==="run"||le.startsWith("tool:")||N.kind==="tool_result"||N.kind==="status"&&Wn.has(le),Qe=V(ie?le:`${le}:${Q}`);K(Qe,{...N,title:$}),N.kind==="thought"&&sn&&y&&(y=!1,ce()),$.toLowerCase()==="run completed"&&_e(!1),he()}function Ae(){vr.clear(),Wn.clear(),We.length=0;for(let N of Array.from(je.querySelectorAll(".entry.trace")))N.remove()}function Se(N){let $=!!N?.visible;Ht.classList.toggle("visible",$),bn.textContent=N?.text||"Looks like a new request. Start a new task?",ut.textContent=N?.primaryLabel||"Start new",$n.textContent=N?.secondaryLabel||"Continue"}function De(N){let $=String(N||"ready");Re.textContent=$;let Q=$.toLowerCase();Q.includes("error")||Q.includes("failed")?ge("error",1800):Q==="ready"||Q.includes("complete")?ge("idle"):ge("running",1e3)}function gt(N){sn=N,N?y=!0:y=!1,ce(),Ot.classList.toggle("visible",N),Ge.style.display=N?"none":"",C()}function $t(N,$){Tr=N,_r=N==="observer"?$?.canComposeInObserver===!0:!0,Te(),Ge.classList.remove("controller","observer"),Ge.classList.add(N),N==="controller"?(Ge.textContent="active",vt.style.display="none",Ue.placeholder=`Ask ${t} to act on this website...`):(Ge.textContent="observer",$?.canTakeControl!==!1?vt.style.display="":vt.style.display="none",$?.note?Ue.placeholder=$.note:_r?Ue.placeholder="Send to take control and run here.":$?.activeLogicalTabId&&$?.localLogicalTabId&&$.activeLogicalTabId!==$.localLogicalTabId?Ue.placeholder=`Observing: ${t} is acting in tab #${$.activeLogicalTabId}`:Ue.placeholder="Observer mode. Take control to run actions here.")}function Gn(){Tt!=null&&(window.clearTimeout(Tt),Tt=null),E&&(window.clearTimeout(E),E=null),c&&(window.clearTimeout(c),c=null),document.removeEventListener("keydown",Ke),a.remove(),i.remove()}p.addEventListener("click",()=>{P.classList.contains("open")?w():l()}),Y.addEventListener("click",N=>{N.stopPropagation(),U()}),S.addEventListener("click",()=>{U(),l()}),Me.addEventListener("click",()=>w()),ve.addEventListener("click",N=>{N.stopPropagation(),g()}),m.addEventListener("click",N=>{An&&!mt.contains(N.target)&&N.target!==ve&&T()}),Le.addEventListener("click",()=>{T(),sn&&e.onCancelRun?(dt="new_task",Se({visible:!0,text:"A task is in progress. Cancel it and start new?",primaryLabel:"Cancel & start new",secondaryLabel:"Keep running"})):e.onNewTask?.()}),Pt.addEventListener("click",()=>{T(),sn&&e.onCancelRun?(dt="end_task",Se({visible:!0,text:"A task is in progress. Cancel and end it?",primaryLabel:"Cancel & end",secondaryLabel:"Keep running"})):e.onEndTask?.()}),xn.addEventListener("click",()=>{T(),_e(!Bt)}),vt.addEventListener("click",()=>{T(),e.onRequestControl?.()}),Ot.addEventListener("click",()=>{e.onCancelRun?.()}),ut.addEventListener("click",()=>{if(dt){let N=dt;dt=null,Se({visible:!1}),e.onCancelRun?.(),N==="new_task"?e.onNewTask?.():N==="end_task"&&e.onEndTask?.();return}e.onTaskSuggestionPrimary?.()}),$n.addEventListener("click",()=>{if(dt){dt=null,Se({visible:!1});return}e.onTaskSuggestionSecondary?.()}),Ue.addEventListener("input",()=>{Ue.style.height="auto",Ue.style.height=`${Math.min(96,Math.max(44,Ue.scrollHeight))}px`}),Ft.addEventListener("submit",N=>{if(N.preventDefault(),Ue.disabled||!b?.questions?.length)return;let $={},Q=[],le=null;for(let He of b.questions){let Ze=ne(He.key);if(!Ze)continue;let St=ht(Ze.value),Je=He.required!==!1;if(!St&&Je){Ze.classList.add("invalid"),le||(le=Ze);continue}if(!St){Ze.classList.remove("invalid"),delete d[He.key];continue}Ze.classList.remove("invalid"),d[He.key]=St,$[He.key]=St,Q.push(`${He.key}: ${St}`)}if(le){le.focus();return}let ie=b.questions.map(He=>He.key),Qe=Q.join(`
|
|
1634
|
-
`);e.onSend(Qe,{askUserAnswers:{answersByKey:$,rawText:Qe,keys:ie}}),ee(void 0)}),Ue.addEventListener("keydown",N=>{N.key==="Enter"&&!N.shiftKey&&!N.isComposing&&(N.preventDefault(),Kt.requestSubmit())}),Kt.addEventListener("submit",N=>{if(N.preventDefault(),Ue.disabled)return;let $=ht(Ue.value);$&&(Se({visible:!1}),e.onSend($),Ue.value="",Ue.style.height="44px")}),s.addEventListener("keydown",N=>{let $=N;$.key==="Escape"&&P.classList.contains("open")&&($.stopPropagation(),w())});let Ke=N=>{N.code==="Period"&&N.shiftKey&&(N.metaKey||N.ctrlKey)&&(N.preventDefault(),N.stopPropagation(),P.classList.contains("open")?w():l())};document.addEventListener("keydown",Ke);let Ce=null,Fe=N=>{if(!Ce)return;let $=Ce.startX-N.clientX,Q=N.clientY-Ce.startY,le=Math.max(320,Math.min(window.innerWidth-16,Ce.startW+$)),ie=Math.max(460,Math.min(window.innerHeight-16,Ce.startH+Q));P.style.width=`${le}px`,P.style.height=`${ie}px`},En=()=>{Ce=null,window.removeEventListener("pointermove",Fe),window.removeEventListener("pointerup",En)};if(ye.addEventListener("pointerdown",N=>{window.matchMedia("(max-width: 640px)").matches||(N.preventDefault(),Ce={startX:N.clientX,startY:N.clientY,startW:P.getBoundingClientRect().width,startH:P.getBoundingClientRect().height},window.addEventListener("pointermove",Fe),window.addEventListener("pointerup",En))}),I){let N=()=>{I.style.display="none",A.style.display="grid"};I.addEventListener("error",N,{once:!0}),A.style.display="none"}if(ae){let N=()=>{ae.style.display="none",ue.style.display="grid"};ae.addEventListener("error",N,{once:!0}),ue.style.display="none"}return $t("controller"),_e(!1),an.length>0&&L(an),{addMessage:k,setQuestionPrompt:ee,clearMessages:O,addTimelineEvent:fe,clearTimeline:Ae,setTaskSuggestion:Se,setStatus:De,setRunning:gt,setExecutionMode:$t,setShortcuts:L,showGreeting:D,dismissGreeting:U,setVisitorName:G,open:l,close:w,show:R,hide:_,destroy:Gn}}var fp="rover:shared:",pp="rover:channel:";function re(){return Date.now()}function Tn(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Ms(e){let t=String(e||"").trim();if(!t)return"";try{return new URL(t,window.location.href).toString()}catch{return t}}function _l(e){try{return new URL(e).hostname.toLowerCase()}catch{return""}}function Rl(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)||re(),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 kl(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 mi(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(!n||typeof n!="object")continue;let r=n.type;if(r==="text"){let o=String(n.text||"");if(!o)continue;t.push({type:"text",text:o});continue}if(r==="tool_output"||r==="json"){let o=kl(n.data);t.push({type:r,data:o,label:typeof n.label=="string"?n.label:void 0,toolName:typeof n.toolName=="string"?n.toolName:void 0})}}return t.length?t:void 0}function xl(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e.slice(-t)){let o=kl(r);o!==void 0&&n.push(o)}return n}function Sl(e){if(!e||typeof e!="object")return;let t=Array.isArray(e.pendingAskUser?.questions)?e.pendingAskUser.questions.map((s,a)=>{let u=String(s?.key||s?.id||"").trim()||`clarification_${a+1}`,m=String(s?.query||s?.question||"").trim();if(m)return{key:u,query:m,id:typeof s?.id=="string"?s.id:void 0,question:typeof s?.question=="string"?s.question:void 0,choices:Array.isArray(s?.choices)?s.choices:void 0}}).filter(s=>!!s).slice(0,6):[],n=s=>s.slice(-80).map(a=>({role:typeof a?.role=="string"?a.role:"assistant",content:typeof a?.content=="string"?a.content:""})).filter(a=>!!a.content),r=Array.isArray(e.history)?n(e.history):[],o=xl(e.plannerHistory,40),i=xl(e.agentPrevSteps,80);return{trajectoryId:typeof e.trajectoryId=="string"?e.trajectoryId:void 0,history:r,plannerHistory:o,agentPrevSteps:i,pendingAskUser:t.length?{questions:t,source:e.pendingAskUser?.source==="planner"?"planner":"act",askedAt:Number(e.pendingAskUser?.askedAt)||re()}:void 0,updatedAt:Number(e.updatedAt)||re()}}function Ds(e,t){return{version:2,siteId:e,sessionId:t,seq:1,updatedAt:re(),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 Hr(e,t,n){let r=Ds(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)||re(),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)||re(),updatedAt:Number(a?.updatedAt)||re(),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||Tn("msg")),role:a?.role==="user"||a?.role==="assistant"||a?.role==="system"?a.role:"system",text:String(a?.text||""),blocks:mi(a?.blocks),ts:Number(a?.ts)||re(),sourceRuntimeId:typeof a?.sourceRuntimeId=="string"?a.sourceRuntimeId:void 0})).filter(a=>!!a.text||!!a.blocks?.length):[],timeline:Array.isArray(e.timeline)?e.timeline.map(a=>({id:String(a?.id||Tn("timeline")),kind:String(a?.kind||"status"),title:String(a?.title||"Step"),detail:typeof a?.detail=="string"?a.detail:void 0,detailBlocks:mi(a?.detailBlocks),status:a?.status==="pending"||a?.status==="success"||a?.status==="error"||a?.status==="info"?a.status:void 0,ts:Number(a?.ts)||re(),sourceRuntimeId:typeof a?.sourceRuntimeId=="string"?a.sourceRuntimeId:void 0})).filter(a=>!!a.title):[],taskEpoch:Math.max(1,Number(e.taskEpoch)||1),task:Rl(e.task),workerContext:Sl(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)||re(),updatedAt:Number(e.activeRun.updatedAt)||re()}: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)||re()}: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)||re(),expiresAt:Number(e.workflowLock.expiresAt)||0}:void 0},i=o.tabs.length,s=new Set;return o.tabs=o.tabs.filter(a=>s.has(a.logicalTabId)?!1:(s.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),i>0&&o.tabs.length<i&&console.warn(`[rover] sanitizeSharedState: dropped ${i-o.tabs.length} invalid/duplicate tab entries`),o}var bi=class bi{constructor(t){W(this,"siteId");W(this,"sessionId");W(this,"runtimeId");W(this,"leaseMs");W(this,"heartbeatMs");W(this,"maxMessages");W(this,"maxTimeline");W(this,"onRoleChange");W(this,"onStateChange");W(this,"onSwitchRequested");W(this,"key");W(this,"channelName");W(this,"state");W(this,"channel",null);W(this,"heartbeatTimer",null);W(this,"storageHandler",null);W(this,"localLogicalTabId");W(this,"closing",!1);W(this,"started",!1);W(this,"pendingRpcRequests",new Map);W(this,"rpcRequestHandler");W(this,"lastNotifiedRole");W(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=`${fp}${this.siteId}:${this.sessionId}`,this.channelName=`${pp}${this.siteId}:${this.sessionId}`,this.state=this.loadState()}pruneDetachedTabs(t,n){let r=!!n?.dropRuntimeDetached,o=!!n?.dropAllDetachedExternal,i=re(),s=t.tabs.length;t.tabs=t.tabs.filter(a=>a.runtimeId?a.runtimeId===this.runtimeId?!0:i-Math.max(a.updatedAt||0,a.openedAt||0)<=45e3:r&&a.openerRuntimeId===this.runtimeId?!1:a.external?o?!1:i-Math.max(a.updatedAt||0,a.openedAt||0)<=12e4:i-Math.max(a.updatedAt||0,a.openedAt||0)<=6e5),s!==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:Tn("task"),status:"running",startedAt:re(),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=Hr(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=Hr(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<=re()?!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=Rl(t)||r.task)})}hydrateExternalState(t){let n=Hr(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 i=this.state.seq!==r||this.state.updatedAt!==o;if(!i&&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})}),i=this.state.tabs.length!==a}return i?(this.persistState(),this.localLogicalTabId||this.registerCurrentTab(window.location.href,document.title||void 0),!0):!1}listTabs(){let t=re();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)||re(),r={taskId:String(t.taskId||Tn("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:re()},r.activeRun=void 0,n=r.task)}),n}markTaskActivity(t,n=re()){t!=="system"&&this.mutate("local",r=>{if(!r.task){r.task={taskId:Tn("task"),status:"running",startedAt:n,boundaryReason:"implicit",lastUserAt:t==="user"?n:void 0,lastAssistantAt:t==="assistant"?n:void 0};return}r.task.status==="running"&&(t==="user"&&(r.task.lastUserAt=n),t==="assistant"&&(r.task.lastAssistantAt=n))})}setWorkerContext(t){this.mutate("local",n=>{if(!t){n.workerContext=void 0;return}n.workerContext=Sl(t)})}setStatus(t){this.mutate("local",n=>{n.uiStatus=t||void 0})}appendMessage(t){let n={id:t.id||Tn("msg"),role:t.role,text:String(t.text||""),blocks:mi(t.blocks),ts:Number(t.ts)||re(),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:Tn("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||Tn("timeline"),kind:String(t.kind||"status"),title:String(t.title||"Step"),detail:t.detail?String(t.detail):void 0,detailBlocks:mi(t.detailBlocks),status:t.status,ts:Number(t.ts)||re(),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}if(n.task&&n.task.status!=="running"){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:re(),updatedAt:re()},n.task||(n.task={taskId:Tn("task"),status:"running",startedAt:re()})})}requestControl(){return this.claimLease(!0)}registerCurrentTab(t,n){let r=Ms(t),o;return this.mutate("local",i=>{let s=i.tabs.find(a=>a.runtimeId===this.runtimeId);if(s)s.url=r||s.url,s.title=n||s.title,s.updatedAt=re(),o=s.logicalTabId;else{let a=i.tabs.find(u=>!u.runtimeId&&u.url===r&&re()-u.openedAt<18e4);if(!a){let u=_l(r);a=i.tabs.filter(p=>!p.runtimeId&&u&&_l(p.url)===u&&re()-p.updatedAt<1e4).sort((p,v)=>v.updatedAt-p.updatedAt)[0]}if(a)a.runtimeId=this.runtimeId,a.url=r||a.url,a.title=n||a.title,a.updatedAt=re(),o=a.logicalTabId;else{let u=i.nextLogicalTabId++;i.tabs.push({logicalTabId:u,runtimeId:this.runtimeId,url:r,title:n,openedAt:re(),updatedAt:re(),external:!1}),o=u}}i.activeLogicalTabId||(i.activeLogicalTabId=o)}),this.notifyRoleChange(),this.localLogicalTabId||o||1}registerOpenedTab(t){let n=Ms(t.url),r=0;return this.mutate("local",o=>{let i=o.tabs.find(s=>!s.runtimeId&&!!s.external==!!t.external&&s.url===n);if(i){i.title=t.title||i.title,i.updatedAt=re(),i.openerRuntimeId=t.openerRuntimeId||i.openerRuntimeId,r=i.logicalTabId;return}r=o.nextLogicalTabId++,o.tabs.push({logicalTabId:r,runtimeId:void 0,url:n,title:t.title,openedAt:re(),updatedAt:re(),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(i=>i.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:re()+this.leaseMs,updatedAt:re()},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:re()+this.leaseMs,updatedAt:re()},n={ok:!0,delegated:!1}}),this.notifyRoleChange(),n}sendCrossTabRpc(t,n,r,o=15e3){return new Promise((i,s)=>{if(!this.channel){s(new Error("BroadcastChannel not available"));return}let a=Tn("rpc"),u=window.setTimeout(()=>{this.pendingRpcRequests.delete(a),s(new Error(`Cross-tab RPC timed out after ${o}ms (method=${n}, target=${t})`))},o);this.pendingRpcRequests.set(a,{resolve:i,reject:s,timer:u}),this.channel.postMessage({type:"rpc_request",requestId:a,sourceRuntimeId:this.runtimeId,targetRuntimeId:t,method:n,params:r,timeoutMs:o,createdAt:re()})})}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=>{let n=t.tabs.find(r=>r.runtimeId===this.runtimeId);n&&(n.runtimeId=void 0,n.updatedAt=re())}),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>re()-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>re()){let i=r.tabs.find(a=>a.runtimeId===o.runtimeId);if(i&&i.updatedAt>re()-2*this.heartbeatMs){n=!1;return}}r.workflowLock={runtimeId:this.runtimeId,runId:t,lockedAt:re(),expiresAt:re()+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>re()}getWorkflowLockInfo(){let t=this.state.workflowLock;return!t||t.expiresAt<=re()?{locked:!1}:{locked:!0,holderRuntimeId:t.runtimeId,runId:t.runId}}async handleInboundRpcRequest(t){let{requestId:n,sourceRuntimeId:r,method:o,params:i}=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 s=await this.rpcRequestHandler({method:o,params:i});this.channel?.postMessage({type:"rpc_response",requestId:n,sourceRuntimeId:this.runtimeId,targetRuntimeId:r,ok:!0,result:s})}catch(s){this.channel?.postMessage({type:"rpc_response",requestId:n,sourceRuntimeId:this.runtimeId,targetRuntimeId:r,ok:!1,error:{message:s?.message||String(s)}})}}handleInboundRpcResponse(t){let{requestId:n,ok:r,result:o,error:i}=t,s=this.pendingRpcRequests.get(n);s&&(this.pendingRpcRequests.delete(n),window.clearTimeout(s.timer),r?s.resolve(o):s.reject(new Error(i?.message||"Cross-tab RPC failed")))}handleRemoteNavigation(t){let{runtimeId:n,url:r,title:o}=t;this.mutate("local",i=>{let s=i.tabs.find(a=>a.runtimeId===n);s&&(s.url=r||s.url,s.title=o||s.title,s.updatedAt=re())})}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=Ms(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=re();else{let a=r.nextLogicalTabId++;r.tabs.push({logicalTabId:a,runtimeId:this.runtimeId,url:t,title:n,openedAt:re(),updatedAt:re(),external:!1})}let i=r.lease;(!i||i.expiresAt<=re()||i?.holderRuntimeId===this.runtimeId)&&(r.lease={holderRuntimeId:this.runtimeId,expiresAt:re()+this.leaseMs,updatedAt:re()},!r.activeLogicalTabId&&this.localLogicalTabId&&(r.activeLogicalTabId=this.localLogicalTabId)),r.workflowLock?.runtimeId===this.runtimeId&&(r.workflowLock.expiresAt=re()+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,i=!o||o.expiresAt<=re();(t||i||o?.holderRuntimeId===this.runtimeId)&&(r.lease={holderRuntimeId:this.runtimeId,expiresAt:re()+this.leaseMs,updatedAt:re()},!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}))},bi.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 i=Hr(JSON.parse(o),this.siteId,this.sessionId);(i.seq>this.state.seq||i.seq===this.state.seq&&i.updatedAt>this.state.updatedAt)&&(this.state=i)}}catch{}let r=Hr(this.state,this.siteId,this.sessionId);n(r),r.seq=Math.max(1,Number(r.seq)||1)+(t==="local"?1:0),r.updatedAt=re(),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 Ds(this.siteId,this.sessionId);let n=JSON.parse(t);return Hr(n,this.siteId,this.sessionId)}catch(t){return console.warn("[rover] Failed to load shared state from localStorage:",t),Ds(this.siteId,this.sessionId)}}persistState(){try{window.localStorage.setItem(this.key,JSON.stringify(this.state))}catch{}}};W(bi,"ROLE_CHANGE_DEBOUNCE_MS",200);var gi=bi;var hp="https://extensionrouter.rtrvr.ai";function Ur(e,t){let n=Number(e);return Number.isFinite(n)?n:t}function Il(e,t=8e3){let n=String(e??"");return n.length<=t?n:`${n.slice(0,t)}\u2026`}function mp(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,Ur(e.updatedAt,0),t,n,r,o].join(":")}function gp(e){let t=hp,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 Os(e,t){let n=new Error(e);return n.details=t,n}var Ei=class{constructor(t){W(this,"endpoint");W(this,"token");W(this,"siteId");W(this,"visitorId");W(this,"ttlHours");W(this,"flushIntervalMs");W(this,"pullIntervalMs");W(this,"minFlushIntervalMs");W(this,"shouldWrite");W(this,"buildCheckpoint");W(this,"onCheckpoint");W(this,"onStateChange");W(this,"onError");W(this,"started",!1);W(this,"dirty",!1);W(this,"flushTimer",null);W(this,"pullTimer",null);W(this,"lastFlushAt",0);W(this,"lastPullAt",0);W(this,"lastUploadedRevision","");W(this,"lastAppliedRemoteUpdatedAt",0);W(this,"pushInFlight",!1);W(this,"pullInFlight",!1);W(this,"state","active");let n=String(t.authToken||t.apiKey||"").trim();if(!n)throw Os("Rover cloud checkpoint requires apiKey or authToken.");this.endpoint=gp(t.apiBase),this.token=n,this.siteId=t.siteId,this.visitorId=t.visitorId,this.ttlHours=Math.max(1,Math.min(168,Math.floor(Ur(t.ttlHours,1)))),this.flushIntervalMs=Math.max(2e3,Math.floor(Ur(t.flushIntervalMs,8e3))),this.pullIntervalMs=Math.max(2e3,Math.floor(Ur(t.pullIntervalMs,9e3))),this.minFlushIntervalMs=Math.max(1e3,Math.floor(Ur(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=mp(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(Ur(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 i;try{i=await r.json()}catch{let s=await r.text().catch(()=>"");i=s?{error:Il(s,2e3)}:void 0}throw Os(`Checkpoint HTTP ${r.status}`,{action:t,status:r.status,payload:i})}let o=await r.json();if(o?.success===!1)throw Os("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,i=o?.errorCode||o?.errorDetails?.code||o?.error?.code||o?.code,s=o?.error||o?.errorDetails?.message||o?.error?.message||n?.message||"Checkpoint request failed",a=Number(r?.status);return{code:typeof i=="string"?i:void 0,message:Il(s,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 bp="rover-runtime-state-db",yi="runtime-state",Ps=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{}}},Hs=class{constructor(){W(this,"dbPromise",null)}openDb(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((t,n)=>{if(typeof indexedDB>"u"){n(new Error("indexedDB unavailable"));return}let r=indexedDB.open(bp,1);r.onupgradeneeded=()=>{let o=r.result;o.objectStoreNames.contains(yi)||o.createObjectStore(yi)},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,i)=>{let s=r.transaction(yi,t),a=s.objectStore(yi);n(a,o,i),s.onerror=()=>{i(s.error||new Error("indexedDB transaction failed"))}})}async read(t){try{return await this.withStore("readonly",(n,r,o)=>{let i=n.get(t);i.onsuccess=()=>{let s=i.result;r(s??null)},i.onerror=()=>{o(i.error||new Error("indexedDB read failed"))}})}catch{return null}}async write(t,n){await this.withStore("readwrite",(r,o,i)=>{let s=r.put(n,t);s.onsuccess=()=>o(),s.onerror=()=>{i(s.error||new Error("indexedDB write failed"))}}).catch(()=>{})}async remove(t){await this.withStore("readwrite",(n,r,o)=>{let i=n.delete(t);i.onsuccess=()=>r(),i.onerror=()=>{o(i.error||new Error("indexedDB delete failed"))}}).catch(()=>{})}};function Al(){let e=new Ps,t=new Hs;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 Ep="rover_xdr_";function Cl(e){let t=e.split(".").filter(Boolean);return t.length<2?e:`${t[t.length-2]}.${t[t.length-1]}`}function Us(e){return`${Ep}${e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,40)}`}function Fs(e,t){try{let n=Us(e),r=Cl(window.location.hostname),o=encodeURIComponent(JSON.stringify(t)),i=window.location.protocol==="https:",s=[`${n}=${o}`,"path=/",`domain=.${r}`,"max-age=120","SameSite=Lax"];i&&s.push("Secure"),document.cookie=s.join("; ")}catch{}}function Nl(e){try{let t=Us(e),n=document.cookie.split(";");for(let r of n){let[o,...i]=r.trim().split("=");if(o===t){let s=i.join("="),a=JSON.parse(decodeURIComponent(s));if(a.timestamp&&Date.now()-a.timestamp<120*1e3)return a}}}catch{}return null}function Ll(e){try{let t=Us(e),n=Cl(window.location.hostname),r=window.location.protocol==="https:",o=[`${t}=`,"path=/",`domain=.${n}`,"max-age=0","SameSite=Lax"];r&&o.push("Secure"),document.cookie=o.join("; ")}catch{}}function Ml(e){return e==="completed"||e==="ended"}function Dl(e){return e==="running"}function Ol(e){return!(e.taskStatus!=="running"||!e.activeRunId||!e.activeRunText||e.hasPendingRun||e.ignoredRunIds?.has(e.activeRunId))}function Bs(e){return!!(e.localTaskStatus!=="running"||e.remoteTaskStatus&&e.remoteTaskStatus!=="running"||e.mode==="observer"&&!e.hasRemoteActiveRun)}function Pl(e){let{type:t,messageRunId:n,pendingRunId:r,sharedActiveRunId:o,taskStatus:i,ignoredRunIds:s}=e;return!n&&t!=="run_started"?!1:n&&s?.has(n)?!0:t==="run_started"?n?r?r!==n:!0:!1:n?t==="run_completed"?i!=="running"?!0:r?r!==n:!(o&&o===n):r?r!==n:!0:!1}var Ys=1,yp="rover:runtime:",wp="rover:runtime-id:",$l="rover:visitor-id:",qs=160,$s=240,Wl=80,Ci=40,vp=8e3,Tp=15*6e4,_p=12,xp=3600*24*365,Rp=1,kp=3e3,Sp=9e4,Ip=12e3,Ap=30,Ni=240,Hl=5*6e4,Li=100,Mi=12,Cp=80,Np=200,Lp=700,Mp=8,Dp=240,Kn=null,$e=null,Pe=null,te=null,Z=null,Fr=null,h=null,br=null,Oe="",H=null,Mt=null,Ri=null,Lt=[],ki=!1,Br=!1,Vl=0,kt,_n,Jn=!1,gr=!1,co=null,lo=null,Er=null,Di=!1,lt="controller",tr=!1,Hn=!1,ct=null,Ul=!1,qr=null,wi="",Gl,Pn=new Map,Qn=new Set,Op=new Set(["run_started","run_completed","assistant","status","tool_start","tool_result","auth_required","navigation_guardrail","error"]),Si=[],Ii=new Map;function Be(e,t){zp(e,t);let n=Ii.get(e);if(n)for(let r of n)try{r(t)}catch{}}function zl(e,t){Ii.has(e)||Ii.set(e,new Set);let n=Ii.get(e);return n.add(t),()=>{n.delete(t)}}function Pp(e){return typeof e=="string"?{name:e}:e}function Zn(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Hp(e){let t=`${wp}${e}`;try{let n=window.sessionStorage.getItem(t);if(n&&n.trim())return n.trim();let r=Zn("runtime");return window.sessionStorage.setItem(t,r),r}catch{return Zn("runtime")}}function Oi(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 vi(e){return String(e||"").trim().replace(/[^a-zA-Z0-9._:-]/g,"").slice(0,180)}function Yl(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]||""):void 0}catch{return}}function Fl(e,t,n){try{let r=n?`; domain=${n}`:"";return document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${xp}; samesite=lax${r}`,Yl(e)===t}catch{return!1}}function Up(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 Fp(e,t){let n=`rover_vid_${Oi(e)}`;for(let r of Up(window.location.hostname))if(Fl(n,t,r))return;Fl(n,t)}function Ti(e,t){let n=`${$l}${e}`;try{window.localStorage.setItem(n,t)}catch{}try{window.sessionStorage.setItem(n,t)}catch{}Fp(e,t)}function jl(e,t){h&&(h.visitor=t,Ne());try{localStorage.setItem(`rover:visitor:${e}`,JSON.stringify(t))}catch{}}function Bp(e){if(h?.visitor?.name||h?.visitor?.email)return h.visitor;try{let t=localStorage.getItem(`rover:visitor:${e}`);return t?JSON.parse(t):void 0}catch{return}}function Xl(e){let t=vi(e.visitorId||"");if(t)return t;if(e.checkpointing?.autoVisitorId===!1)return;let n=`${$l}${e.siteId}`,r=`rover_vid_${Oi(e.siteId)}`,o=vi(Yl(r)||"");if(o)return Ti(e.siteId,o),o;try{let s=vi(window.localStorage.getItem(n)||"");if(s)return Ti(e.siteId,s),s}catch{}try{let s=vi(window.sessionStorage.getItem(n)||"");if(s)return Ti(e.siteId,s),s}catch{}let i=`v_${Oi(`${e.siteId}:${Zn("visitor")}`)}_${Date.now().toString(36)}`;return Ti(e.siteId,i),i}function qp(e,t){return`visitor-${Oi(`${e}:${t}`)}`}function Kl(e){!$e||!Pe||($e.registerTool(e.def,e.handler),Pe.postMessage({type:"register_tool",tool:e.def}))}function $p(e){return`${yp}${e}`}function Fn(e="session_start"){let t=Date.now();return{taskId:Zn("task"),status:"running",startedAt:t,lastUserAt:void 0,lastAssistantAt:void 0,boundaryReason:e,endedAt:void 0}}function Ws(e,t){return{version:Ys,sessionId:e,runtimeId:t,uiOpen:!1,uiHidden:!1,uiStatus:void 0,uiMessages:[],timeline:[],executionMode:"controller",workerState:void 0,pendingRun:void 0,taskEpoch:1,activeTask:Fn(),lastRoutingDecision:void 0,updatedAt:Date.now()}}function At(e,t=vp){return e.length<=t?e:`${e.slice(0,t)}\u2026`}function Ai(e){if(e!=null){if(typeof e=="string")return At(e,1200);try{return At(JSON.stringify(e),1200)}catch{try{return At(String(e),1200)}catch{return}}}}function qi(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),i=Number.isFinite(o)?Math.min(6e4,Math.max(2e3,Math.floor(o))):Ip,s=Number(t?.maxBatchSize),a=Number.isFinite(s)?Math.min(80,Math.max(1,Math.floor(s))):Ap;return{enabled:t?.enabled!==!1,sampleRate:r,flushIntervalMs:i,maxBatchSize:a,includePayloads:t?.includePayloads===!0}}function js(e){return e==="same_tab"||e==="open_new_tab"?e:"same_tab"}function Xs(e,t){return e==="observer"?"This tab is in observer mode because another tab currently holds Rover action control.":t?"Controller tab ready for actions.":"Actions are disabled by configuration (allowActions=false)."}function Ks(e){return e==="auto"||e==="confirm"||e==="never"?e:"confirm"}function Qs(e){return!(!e||!qi(e).enabled||!(e.authToken||e.apiKey))}function Bl(e){if(e!=null){if(typeof e=="string")return At(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 i=e?.[o];i!=null&&(typeof i=="string"?n[o]=At(i,180):(typeof i=="number"||typeof i=="boolean")&&(n[o]=i))}return n}}}function Wp(e,t){if(!t)return Bl(e);let n=ea(e);if(n!=null)return typeof n=="string"?At(n,1e3):typeof n=="number"||typeof n=="boolean"?n:Array.isArray(n)?{type:"array",length:n.length}:typeof n=="object"?n:Bl(e)}function Js(){Ri&&(clearInterval(Ri),Ri=null)}var Vp="https://extensionrouter.rtrvr.ai";function Ql(e){let t=Vp,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 Gp(e){return Ql(e.apiBase)}async function $i(e=!1){if(ki||Br)return;if(!Z||!Qs(Z)){Lt=[];return}if(!Lt.length)return;let t=qi(Z),n=String(Z.authToken||Z.apiKey||"").trim();if(!n)return;let r=Lt.splice(0,t.maxBatchSize);if(r.length){ki=!0;try{let o=await fetch(Gp(Z),{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({action:"roverTelemetryIngest",data:{siteId:Z.siteId,runtimeId:Oe,sessionId:h?.sessionId,visitorId:kt,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?Br=!0:Lt=[...r,...Lt].slice(-Ni);return}let i=await o.json().catch(()=>{});if(i?.success===!1){let s=String(i?.errorCode||i?.errorDetails?.code||"").toUpperCase();(s==="INVALID_API_KEY"||s==="MISSING_API_KEY"||s==="UNAUTHENTICATED"||s==="PERMISSION_DENIED")&&(Br=!0);return}}catch{Lt=[...r,...Lt].slice(-Ni)}finally{ki=!1}}}function Zs(e){if(Js(),Br=!1,!Qs(e)){Lt=[];return}let t=qi(e);Ri=setInterval(()=>{$i(!1)},t.flushIntervalMs)}function zp(e,t){if(!Qs(Z)||Br)return;let n=qi(Z);if(n.sampleRate<1&&Math.random()>n.sampleRate)return;let r={name:e,ts:Date.now(),seq:++Vl,payload:Wp(t,n.includePayloads)};Lt.push(r),Lt.length>Ni&&(Lt=Lt.slice(-Ni)),Lt.length>=n.maxBatchSize&&$i(!1)}function _i(e,t,n="tab_not_accessible"){let r=Number(t?.logicalTabId)||void 0,o=t?.url||"",i=t?.title||(t?.external?"External Tab (Inaccessible)":"Inactive Tab"),s=String(n||"").trim(),a=s?` Reason: ${s}.`:"",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:i,contentType:"text/html",content:u,metadata:{inaccessible:!0,external:!!t?.external,accessMode:t?.external?"external_placeholder":"inactive_tab",reason:n,logicalTabId:r}}}function xi(e,t,n="tab_not_accessible"){let r=Number(t?.logicalTabId)||0,o=t?.url||"",i=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.`,s=t?.external?"DOMAIN_SCOPE_BLOCKED":"TAB_NOT_ACCESSIBLE";return{success:!1,error:i,allowFallback:!0,output:{success:!1,error:{code:s,message:i,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:s,message:i,retryable:!1,details:{logicalTabId:r,blockedUrl:o,external:!!t?.external,reason:n}}}}function Yp(e){if(e==="analyze"||e==="route"||e==="execute"||e==="verify"||e==="complete")return e}function jp(e){return e?e==="analyze"?"Analyze":e==="route"?"Route":e==="execute"?"Execute":e==="verify"?"Verify":e==="complete"?"Complete":"Status":"Status"}function Xp(e,t,n){return[String(t||""),String(e||"").trim().toLowerCase(),String(n||"").trim().toLowerCase()].join("|")}function Kp(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 Qp(){return h?.pendingRun?.id}function tn(e){if(e)for(Qn.add(e);Qn.size>80;){let t=Qn.values().next().value;if(!t)break;Qn.delete(t)}}function Jl(e){e&&Qn.delete(e)}function so(){return h?.activeTask?.status==="running"}function Zl(){let e=H?.getState()?.activeRun;return!!(e&&e.runtimeId&&e.runtimeId!==Oe)}function eu(){return!Zl()}function tu(e){if(e==="observer")return Zl()?"Observing active run in another tab...":"Send to take control and run here."}function Jp(e){let t=typeof e?.type=="string"?e.type:"";if(!Op.has(t))return!1;let n=typeof e?.runId=="string"&&e.runId?e.runId:void 0;return Pl({type:t,messageRunId:n,pendingRunId:Qp(),sharedActiveRunId:H?.getState()?.activeRun?.runId,taskStatus:h?.activeTask?.status,ignoredRunIds:Qn})}function Eo(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let r=0;r<e.length;r+=1){let o=e[r];if(!o||typeof o!="object")continue;let i=String(o.key||o.id||"").trim()||`clarification_${r+1}`,s=String(o.query||o.question||"").trim();if(!s)continue;let a=typeof o.required=="boolean",u=typeof o.optional=="boolean",m=a?!!o.required:u?!o.optional:!0,p=`${i}::${s}`.toLowerCase();if(n.has(p))continue;n.add(p);let v={key:i,query:s,...typeof o.id=="string"&&o.id.trim()?{id:o.id.trim()}:{},...typeof o.question=="string"&&o.question.trim()?{question:o.question.trim()}:{},...Array.isArray(o.choices)?{choices:o.choices}:{}};m||(v.required=!1),t.push(v)}return t.slice(0,6)}function Zp(e){if(!e||typeof e!="object")return{taskComplete:!1,needsUserInput:!1};let t=e.needsUserInput===!0,n=e.taskComplete===!0&&!t,r=Eo(e.questions);return{taskComplete:n,needsUserInput:t,...r.length?{questions:r}:{}}}function eh(e){if(e&&Pn.has(e))return Pn.get(e);if(h?.uiMessages?.length)for(let t=h.uiMessages.length-1;t>=0;t-=1){let n=h.uiMessages[t];if(n.role==="assistant"){if(n.text)return n.text;let r=ta(n.blocks);if(r)return r}}}function th(e){return br?br.readSync(e):null}function ea(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 er(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(!n||typeof n!="object")continue;let r=n.type;if(r==="text"){let o=String(n.text||"");if(!o)continue;t.push({type:"text",text:o});continue}(r==="tool_output"||r==="json")&&t.push({type:r,data:ea(n.data),label:typeof n.label=="string"?n.label:void 0,toolName:typeof n.toolName=="string"?n.toolName:void 0})}return t.length?t:void 0}function ql(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=Object.entries(e).filter(([,i])=>i!=null);if(t.length!==1)return!1;let[n,r]=t[0];return typeof r!="string"||!r.trim()?!1:new Set(["response","message","summary","text","content","result","description"]).has(n)}function nh(e,t){if(e==null)return!1;if(typeof e=="string"){let n=e.trim();return n?!t||n!==t.trim():!1}if(Array.isArray(e)){let n=e.filter(r=>r!=null);if(n.length===1){let r=n[0];if(typeof r=="string"||typeof r=="number"||typeof r=="boolean"||ql(r))return!1}return!0}return!ql(e)}function ta(e){if(!Array.isArray(e)||!e.length)return;let t=e.filter(r=>r.type==="text").map(r=>String(r.text||"").trim()).filter(Boolean);if(t.length)return t.join(`
|
|
1650
|
+
`;let Qt=document.createElement("div");Qt.className="shortcutsEmptyState";let ln=document.createElement("div");ln.className="shortcutsHeading",ln.textContent=o?`Hey ${o}! What can I help with?`:`What can ${t} help you with?`;let We=document.createElement("div");We.className="shortcutsGrid",Qt.appendChild(ln),Qt.appendChild(We),Qe.appendChild(Qt);let Ln=document.createElement("div");Ln.className="shortcutsBar";let Ft=document.createElement("div");Ft.className="questionPrompt";let Mn=document.createElement("div");Mn.className="questionPromptTitle",Mn.textContent="Need a bit more info";let qt=document.createElement("form");qt.className="questionPromptForm";let Dn=document.createElement("div");Dn.className="questionPromptList",qt.appendChild(Dn);let Yn=document.createElement("div");Yn.className="questionPromptActions";let un=document.createElement("button");un.type="button",un.className="questionPromptCancel",un.textContent="Cancel",Yn.appendChild(un);let dn=document.createElement("button");dn.type="submit",dn.className="questionPromptSubmit",dn.textContent="Continue",Yn.appendChild(dn),qt.appendChild(Yn),Ft.appendChild(Mn),Ft.appendChild(qt);let $t=document.createElement("form");$t.className="composer";let En=document.createElement("textarea");En.rows=1,En.placeholder=`Ask ${t} to act on this website...`,$t.appendChild(En);let ye=document.createElement("button");ye.type="submit",ye.className="sendBtn",ye.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(ye);let vn=document.createElement("div");vn.className="resizeHandle",vn.setAttribute("aria-hidden","true"),U.appendChild(q),U.appendChild(jn),U.appendChild(Ht),U.appendChild(Ln),U.appendChild(Ft),U.appendChild($t),U.appendChild(vn),p.appendChild(d),p.appendChild(x),p.appendChild(U),a.appendChild(l),a.appendChild(p);let Pe=En,bt=Ht.querySelector(".taskSuggestionText"),Xn=Ht.querySelector(".taskSuggestionBtn.primary"),Yr=Ht.querySelector(".taskSuggestionBtn.secondary"),ir=new Set,Ve=new Map,sr=[],Xr="controller",kr=!1,Wt=!1,On=!1,yt=e.shortcuts?.slice(0,12)||[],Rt=null,Vt=!1,Jt=null,Nt=!1,wn=!1,Un=0,c=!1,w=null,E=null,v=!1,m=null,h=null,b={};function k(){Nt=!Nt,gt.classList.toggle("visible",Nt)}function L(){Nt=!1,gt.classList.remove("visible")}function C(N){yt=N.filter($=>$&&$.enabled!==!1).slice(0,12),We.innerHTML="";for(let $ of yt){let X=document.createElement("button");if(X.type="button",X.className="shortcutCard",$.icon){let ie=document.createElement("span");ie.className="shortcutCardIcon",ie.textContent=$.icon,X.appendChild(ie)}let ce=document.createElement("span");if(ce.className="shortcutCardLabel",ce.textContent=$.label,X.appendChild(ce),$.description){let ie=document.createElement("span");ie.className="shortcutCardDesc",ie.textContent=$.description,X.appendChild(ie)}X.addEventListener("click",()=>e.onShortcutClick?.($)),We.appendChild(X)}Ln.innerHTML="";for(let $ of yt){let X=document.createElement("button");if(X.type="button",X.className="shortcutChip",$.icon){let ie=document.createElement("span");ie.className="shortcutChipIcon",ie.textContent=$.icon,X.appendChild(ie)}let ce=document.createTextNode($.label);X.appendChild(ce),X.addEventListener("click",()=>e.onShortcutClick?.($)),Ln.appendChild(X)}M()}function M(){let N=yt.length>0,$=!!m?.questions?.length,X=N&&!On&&!Wt,ce=N&&On&&!Wt&&!$;Qt.classList.toggle("visible",X),Ln.classList.toggle("visible",ce)}function H(N){let $=ht(N);if($){if(B.textContent=$,x.classList.contains("visible")){x.classList.add("textVisible");return}c||U.classList.contains("open")||(c=!0,x.classList.remove("dismissing","textVisible"),x.classList.add("visible"),E&&(clearTimeout(E),E=null),E=setTimeout(()=>{E=null,x.classList.add("textVisible")},800))}}function V(){if(E&&(clearTimeout(E),E=null),!x.classList.contains("visible"))return;x.classList.add("dismissing");let N=()=>{x.classList.remove("visible","dismissing"),x.removeEventListener("animationend",N)};x.addEventListener("animationend",N),w&&(clearTimeout(w),w=null)}function Q(N){o=N||void 0,o?ln.textContent=`Hey ${o}! What can I help with?`:ln.textContent=`What can ${t} help you with?`}function oe(N){if(!N||!Array.isArray(N.questions))return[];let $=[],X=new Set;for(let ce=0;ce<N.questions.length;ce+=1){let ie=N.questions[ce];if(!ie||typeof ie!="object")continue;let Je=String(ie.key||ie.id||"").trim()||`clarification_${ce+1}`,Be=String(ie.query||ie.question||"").trim();if(!Be)continue;let nt=typeof ie.required=="boolean",St=typeof ie.optional=="boolean",Ze=nt?!!ie.required:St?!ie.optional:!0;X.has(Je)||(X.add(Je),$.push({key:Je,query:Be,...typeof ie.id=="string"&&ie.id.trim()?{id:ie.id.trim()}:{},...typeof ie.question=="string"&&ie.question.trim()?{question:ie.question.trim()}:{},...Array.isArray(ie.choices)?{choices:ie.choices}:{},required:Ze}))}return $.slice(0,6)}function Ee(N){return N.map($=>{let X=Array.isArray($.choices)?$.choices.map(ie=>ht(String(ie||""))).filter(Boolean).join("|"):"",ce=$.required===!1?"optional":"required";return`${$.key}::${ht($.query)}::${X}::${ce}`}).join("||")}function re(N){let $=ht(N.query||N.question||"");if(!$)return`Answer for ${N.key}`;let X=$.replace(/\s+/g," ").replace(/[?.!:\s]+$/,"").slice(0,72);return X?`Answer: ${X}`:`Answer for ${N.key}`}function te(N){for(let $ of Array.from(qt.querySelectorAll(".questionPromptInput"))){let X=$;if(X.dataset.key===N)return X}return null}function le(N){let $=oe(N),X=document.activeElement,ce=X instanceof HTMLInputElement&&X.classList.contains("questionPromptInput")&&Ft.contains(X)?X:null,ie=ce?.dataset.key,Je=ce?.selectionStart??null,Be=ce?.selectionEnd??null;if(!$.length){m=null,h=null,b={},Dn.innerHTML="",Ft.classList.remove("visible"),M();return}let nt=Ee($),St=nt!==h||!m;if(m={questions:$},St){let Ze=b;b={},Dn.innerHTML="";for(let lt of m.questions){let en=document.createElement("label");en.className="questionPromptItem";let tn=document.createElement("span");tn.className="questionPromptLabel",tn.textContent=lt.required===!1?`${lt.query} (optional)`:lt.query,en.appendChild(tn);let Lt=document.createElement("input");Lt.type="text",Lt.className="questionPromptInput",Lt.dataset.key=lt.key,Lt.placeholder=re(lt),Lt.required=lt.required!==!1;let fn=String(Ze[lt.key]||"");b[lt.key]=fn,Lt.value=fn,Lt.addEventListener("input",()=>{b[lt.key]=Lt.value,Lt.classList.remove("invalid")}),en.appendChild(Lt),Dn.appendChild(en)}h=nt}if(Ft.classList.add("visible"),xe(),M(),ie){let Ze=te(ie);if(Ze){if(Ze.focus(),Je!==null||Be!==null){let lt=Je??Ze.value.length,en=Be??lt;try{Ze.setSelectionRange(lt,en)}catch{}}return}}if(St){let lt=m.questions.find(Lt=>!ht(b[Lt.key]||""))?.key||m.questions[0]?.key;if(!lt)return;let en=te(lt),tn=!X||X===document.body||!U.contains(X);en&&tn&&en.focus()}}function Ae(){Wt&&v?(at.classList.add("visible"),Qe.appendChild(at),ve()):at.classList.remove("visible")}function Le(N,$=0){p.dataset.mood=N,Jt!=null&&(window.clearTimeout(Jt),Jt=null),$>0&&N!=="idle"&&(Jt=window.setTimeout(()=>{p.dataset.mood="idle",Ae(),Jt=null},$))}function me(){return Qe.scrollHeight-Qe.scrollTop-Qe.clientHeight<60}function ve(){wn?ct.classList.add("visible"):(requestAnimationFrame(()=>{Qe.scrollTo({top:Qe.scrollHeight,behavior:"smooth"}),Un=Date.now()}),ct.classList.remove("visible"))}Qe.addEventListener("scroll",()=>{Date.now()-Un<200||(me()?(wn=!1,ct.classList.remove("visible")):(wn=!0,ct.classList.add("visible")))},{passive:!0}),ct.addEventListener("click",()=>{wn=!1,Un=Date.now(),Qe.scrollTo({top:Qe.scrollHeight,behavior:"smooth"}),ct.classList.remove("visible")});function xe(){let N=Xr==="observer"&&!kr;Pe.disabled=N,un.disabled=N,dn.disabled=N;for(let $ of Array.from(qt.querySelectorAll(".questionPromptInput")))$.disabled=N}function u(N){Vt=N,p.dataset.showDetails=N?"true":"false",Nn.textContent=Vt?"Hide details":"Show details";for(let $ of sr){let X=$.dataset.status,ce=X==="success"||X==="error"||X==="info";$.classList.toggle("compact",!Vt&&ce)}}function T(){p.style.display="",U.classList.remove("closing"),U.classList.add("open"),V(),Le("idle"),e.onOpen?.(),Pe.disabled||Pe.focus()}function S(){if(L(),!U.classList.contains("open")){e.onClose?.();return}U.classList.remove("open"),U.classList.add("closing"),Le("idle");let N=()=>{U.classList.remove("closing"),U.removeEventListener("animationend",N)};U.addEventListener("animationend",N),e.onClose?.()}function R(){p.style.display=""}function A(){S(),p.style.display="none"}function O(N,$,X){let ce=ht($),ie=X?.blocks;if(!ce&&(!ie||ie.length===0))return;let Je=document.createElement("div");Je.className=`entry message ${N}`;let Be=document.createElement("div");Be.className="bubble",N==="assistant"?Be.appendChild(Rp(ce,ie)):Be.textContent=ce;let nt=document.createElement("div");nt.className="stamp",nt.textContent=Sl(Date.now()),Je.appendChild(Be),Je.appendChild(nt),Qe.appendChild(Je),N==="assistant"&&Wt&&v&&(v=!1,Ae()),On=!0,M(),N==="user"?Le("typing",1200):N==="assistant"?Le("success",1400):Le("running",900),ve()}function G(){for(let N of Array.from(Qe.querySelectorAll(".entry.message")))N.remove();On=!1,le(void 0),M()}function K(N){let $=Ve.get(N);if($)return $;let X=document.createElement("div");X.className="entry trace pending";let ce=document.createElement("div");ce.className="traceTop";let ie=document.createElement("div");ie.className="traceMeta";let Je=document.createElement("span");Je.className="traceStage",Je.textContent="step";let Be=document.createElement("div");Be.className="traceTitle";let nt=document.createElement("div");nt.className="traceTs",ie.appendChild(Je),ie.appendChild(Be),ce.appendChild(ie),ce.appendChild(nt);let St=document.createElement("div");return St.className="traceDetail",X.appendChild(ce),X.appendChild(St),Ve.set(N,X),sr.push(X),Qe.appendChild(X),X}function fe(N,$){let X=Number($.ts)||Date.now(),ce=mp($),ie=N.querySelector(".traceTop"),Be=ie.querySelector(".traceMeta").querySelector(".traceStage"),nt=ie.querySelector(".traceTitle"),St=ie.querySelector(".traceTs"),Ze=N.querySelector(".traceDetail"),lt=Cl($.title||"");nt.textContent=lt.plainTitle||"Step",Be.textContent=lt.stage||$.kind||"step",Be.style.display=lt.stage||$.kind==="status"||$.kind==="plan"||$.kind==="thought"?"":"none",St.textContent=Sl(X),Ze.innerHTML="";let en=Array.isArray($.detailBlocks)?$.detailBlocks:[],tn=ht($.detail||"");if(en.length>0){for(let fn of en){let ka=Ll(fn);ka&&Ze.appendChild(ka)}if(tn){let fn=document.createElement("div");fn.className="rvLine",fn.appendChild(Zn(tn)),Ze.insertBefore(fn,Ze.firstChild)}Ze.style.display=""}else if(tn){let fn=$.kind==="thought"?150:$.kind==="tool_start"||$.kind==="tool_result"?100:280;tn.length>fn?Ze.appendChild(_i(tn,fn)):Ze.appendChild(Zn(tn)),Ze.style.display=""}else Ze.style.display="none";N.classList.remove("pending","success","error","info"),N.classList.add(ce),N.dataset.status=ce,N.dataset.kind=$.kind,N.dataset.visibility=vp($);let Lt=ce==="success"||ce==="error"||ce==="info";N.classList.toggle("compact",!Vt&&Lt),ce==="error"?Le("error",2200):ce==="success"?Le("success",1200):ce==="pending"&&Le("running",800)}function Ne(N){let $=ht(N.title||"");if(!$||$.toLowerCase()==="assistant update")return;let X=N.id||Al("timeline");if(N.id&&ir.has(X))return;ir.add(X);let ce=gp(N),ie=ce==="run"||ce.startsWith("tool:")||N.kind==="tool_result"||N.kind==="status"&&Ve.has(ce),Je=K(ie?ce:`${ce}:${X}`);fe(Je,{...N,title:$}),N.kind==="thought"&&Wt&&v&&(v=!1,Ae()),$.toLowerCase()==="run completed"&&u(!1),ve()}function De(){ir.clear(),Ve.clear(),sr.length=0;for(let N of Array.from(Qe.querySelectorAll(".entry.trace")))N.remove()}function Me(N){let $=!!N?.visible;Ht.classList.toggle("visible",$),bt.textContent=N?.text||"Looks like a new request. Start a new task?",Xn.textContent=N?.primaryLabel||"Start new",Yr.textContent=N?.secondaryLabel||"Continue"}function Et(N){let $=String(N||"ready");_e.textContent=$;let X=$.toLowerCase();X.includes("error")||X.includes("failed")?Le("error",1800):X==="ready"||X.includes("complete")?Le("idle"):Le("running",1e3)}function Zt(N){Wt=N,N?v=!0:v=!1,Ae(),Pt.classList.toggle("visible",N),Ye.style.display=N?"none":"",M()}function Pn(N,$){Xr=N,kr=N==="observer"?$?.canComposeInObserver===!0:!0,xe(),Ye.classList.remove("controller","observer"),Ye.classList.add(N),N==="controller"?(Ye.textContent="active",_t.style.display="none",Pe.placeholder=`Ask ${t} to act on this website...`):(Ye.textContent="observer",$?.canTakeControl!==!1?_t.style.display="":_t.style.display="none",$?.note?Pe.placeholder=$.note:kr?Pe.placeholder="Send to take control and run here.":$?.activeLogicalTabId&&$?.localLogicalTabId&&$.activeLogicalTabId!==$.localLogicalTabId?Pe.placeholder=`Observing: ${t} is acting in tab #${$.activeLogicalTabId}`:Pe.placeholder="Observer mode. Take control to run actions here.")}function tt(){Jt!=null&&(window.clearTimeout(Jt),Jt=null),E&&(window.clearTimeout(E),E=null),w&&(window.clearTimeout(w),w=null),document.removeEventListener("keydown",Fe),s.remove(),i.remove()}d.addEventListener("click",()=>{U.classList.contains("open")?S():T()}),j.addEventListener("click",N=>{N.stopPropagation(),V()}),x.addEventListener("click",()=>{V(),T()}),He.addEventListener("click",()=>S()),we.addEventListener("click",N=>{N.stopPropagation(),k()}),p.addEventListener("click",N=>{Nt&&!gt.contains(N.target)&&N.target!==we&&L()}),Ue.addEventListener("click",()=>{L(),Wt&&e.onCancelRun?(Rt="new_task",Me({visible:!0,text:"A task is in progress. Cancel it and start new?",primaryLabel:"Cancel & start new",secondaryLabel:"Keep running"})):e.onNewTask?.()}),Bt.addEventListener("click",()=>{L(),Wt&&e.onCancelRun?(Rt="end_task",Me({visible:!0,text:"A task is in progress. Cancel and end it?",primaryLabel:"Cancel & end",secondaryLabel:"Keep running"})):e.onEndTask?.()}),Nn.addEventListener("click",()=>{L(),u(!Vt)}),_t.addEventListener("click",()=>{L(),e.onRequestControl?.()}),Pt.addEventListener("click",()=>{e.onCancelRun?.()}),Xn.addEventListener("click",()=>{if(Rt){let N=Rt;Rt=null,Me({visible:!1}),e.onCancelRun?.(),N==="new_task"?e.onNewTask?.():N==="end_task"&&e.onEndTask?.();return}e.onTaskSuggestionPrimary?.()}),Yr.addEventListener("click",()=>{if(Rt){Rt=null,Me({visible:!1});return}e.onTaskSuggestionSecondary?.()}),Pe.addEventListener("input",()=>{Pe.style.height="auto",Pe.style.height=`${Math.min(96,Math.max(44,Pe.scrollHeight))}px`}),qt.addEventListener("submit",N=>{if(N.preventDefault(),Pe.disabled||!m?.questions?.length)return;let $={},X=[],ce=null;for(let Be of m.questions){let nt=te(Be.key);if(!nt)continue;let St=ht(nt.value),Ze=Be.required!==!1;if(!St&&Ze){nt.classList.add("invalid"),ce||(ce=nt);continue}if(!St){nt.classList.remove("invalid"),delete b[Be.key],X.push(`${Be.key}: (no answer provided)`);continue}nt.classList.remove("invalid"),b[Be.key]=St,$[Be.key]=St,X.push(`${Be.key}: ${St}`)}if(ce){ce.focus();return}let ie=m.questions.map(Be=>Be.key),Je=X.length?X.join(`
|
|
1651
|
+
`):ie.map(Be=>`${Be}: (no answer provided)`).join(`
|
|
1652
|
+
`);e.onSend(Je,{askUserAnswers:{answersByKey:$,rawText:Je,keys:ie}})}),un.addEventListener("click",()=>{if(!Pe.disabled){if(e.onCancelQuestionFlow){e.onCancelQuestionFlow();return}e.onCancelRun?.()}}),Pe.addEventListener("keydown",N=>{N.key==="Enter"&&!N.shiftKey&&!N.isComposing&&(N.preventDefault(),$t.requestSubmit())}),$t.addEventListener("submit",N=>{if(N.preventDefault(),Pe.disabled)return;let $=ht(Pe.value);$&&(Me({visible:!1}),e.onSend($),Pe.value="",Pe.style.height="44px")}),a.addEventListener("keydown",N=>{let $=N;$.key==="Escape"&&U.classList.contains("open")&&($.stopPropagation(),S())});let Fe=N=>{N.code==="Period"&&N.shiftKey&&(N.metaKey||N.ctrlKey)&&(N.preventDefault(),N.stopPropagation(),U.classList.contains("open")?S():T())};document.addEventListener("keydown",Fe);let Oe=null,Tn=N=>{if(!Oe)return;let $=Oe.startX-N.clientX,X=N.clientY-Oe.startY,ce=Math.max(320,Math.min(window.innerWidth-16,Oe.startW+$)),ie=Math.max(460,Math.min(window.innerHeight-16,Oe.startH+X));U.style.width=`${ce}px`,U.style.height=`${ie}px`},Kr=()=>{Oe=null,window.removeEventListener("pointermove",Tn),window.removeEventListener("pointerup",Kr)};if(vn.addEventListener("pointerdown",N=>{window.matchMedia("(max-width: 640px)").matches||(N.preventDefault(),Oe={startX:N.clientX,startY:N.clientY,startW:U.getBoundingClientRect().width,startH:U.getBoundingClientRect().height},window.addEventListener("pointermove",Tn),window.addEventListener("pointerup",Kr))}),I){let N=()=>{I.style.display="none",g.style.display="grid"};I.addEventListener("error",N,{once:!0}),g.style.display="none"}if(ae){let N=()=>{ae.style.display="none",ue.style.display="grid"};ae.addEventListener("error",N,{once:!0}),ue.style.display="none"}return Pn("controller"),u(!1),yt.length>0&&C(yt),{addMessage:O,setQuestionPrompt:le,clearMessages:G,addTimelineEvent:Ne,clearTimeline:De,setTaskSuggestion:Me,setStatus:Et,setRunning:Zt,setExecutionMode:Pn,setShortcuts:C,showGreeting:H,dismissGreeting:V,setVisitorName:Q,open:T,close:S,show:R,hide:A,destroy:tt}}var Sp="rover:shared:",Ap="rover:channel:";function ne(){return Date.now()}function kn(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function Ii(e){let t=String(e||"").trim();if(!t)return"";try{return new URL(t,window.location.href).toString()}catch{return t}}function Ol(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)||ne(),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 Ul(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 ki(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(!n||typeof n!="object")continue;let r=n.type;if(r==="text"){let o=String(n.text||"");if(!o)continue;t.push({type:"text",text:o});continue}if(r==="tool_output"||r==="json"){let o=Ul(n.data);t.push({type:r,data:o,label:typeof n.label=="string"?n.label:void 0,toolName:typeof n.toolName=="string"?n.toolName:void 0})}}return t.length?t:void 0}function Dl(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e.slice(-t)){let o=Ul(r);o!==void 0&&n.push(o)}return n}function Pl(e){if(!e||typeof e!="object")return;let t=Array.isArray(e.pendingAskUser?.questions)?e.pendingAskUser.questions.map((p,d)=>{let y=String(p?.key||p?.id||"").trim()||`clarification_${d+1}`,I=String(p?.query||p?.question||"").trim();if(I)return{key:y,query:I,id:typeof p?.id=="string"?p.id:void 0,question:typeof p?.question=="string"?p.question:void 0,choices:Array.isArray(p?.choices)?p.choices:void 0}}).filter(p=>!!p).slice(0,6):[],n=e.pendingAskUser?.stepRef,r=n&&Number.isFinite(Number(n.stepIndex))&&Number(n.stepIndex)>=0&&Number.isFinite(Number(n.functionIndex))&&Number(n.functionIndex)>=0?{stepIndex:Number(n.stepIndex),functionIndex:Number(n.functionIndex),...typeof n.accTreeId=="string"&&n.accTreeId.trim()?{accTreeId:n.accTreeId.trim()}:{}}:void 0,o=p=>p.slice(-80).map(d=>({role:typeof d?.role=="string"?d.role:"assistant",content:typeof d?.content=="string"?d.content:""})).filter(d=>!!d.content),i=Array.isArray(e.history)?o(e.history):[],a=Dl(e.plannerHistory,40),s=Dl(e.agentPrevSteps,80),l=typeof e.rootUserInput=="string"?e.rootUserInput.trim():"";return{trajectoryId:typeof e.trajectoryId=="string"?e.trajectoryId:void 0,taskBoundaryId:typeof e.taskBoundaryId=="string"&&e.taskBoundaryId.trim()?e.taskBoundaryId.trim():void 0,rootUserInput:l||void 0,history:i,plannerHistory:a,agentPrevSteps:s,pendingAskUser:t.length?{questions:t,source:e.pendingAskUser?.source==="planner"?"planner":"act",askedAt:Number(e.pendingAskUser?.askedAt)||ne(),boundaryId:typeof e.pendingAskUser?.boundaryId=="string"&&e.pendingAskUser.boundaryId.trim()?e.pendingAskUser.boundaryId.trim():void 0,...r?{stepRef:r}:{}}:void 0,updatedAt:Number(e.updatedAt)||ne()}}function Vs(e,t){return{version:2,siteId:e,sessionId:t,seq:1,updatedAt:ne(),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 Fr(e,t,n){let r=Vs(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)||ne(),tabs:Array.isArray(e.tabs)?e.tabs.map(s=>({logicalTabId:Math.max(1,Number(s?.logicalTabId)||0),runtimeId:typeof s?.runtimeId=="string"?s.runtimeId:void 0,url:String(s?.url||""),title:typeof s?.title=="string"?s.title:void 0,openedAt:Number(s?.openedAt)||ne(),updatedAt:Number(s?.updatedAt)||ne(),external:!!s?.external,openerRuntimeId:typeof s?.openerRuntimeId=="string"?s.openerRuntimeId:void 0,detachedAt:Number(s?.detachedAt)||void 0,detachedReason:s?.detachedReason==="navigation_handoff"||s?.detachedReason==="tab_close"||s?.detachedReason==="opened_pending_attach"||s?.detachedReason==="unknown"?s.detachedReason:void 0,handoffId:typeof s?.handoffId=="string"?s.handoffId:void 0,handoffRunId:typeof s?.handoffRunId=="string"?s.handoffRunId:void 0,handoffTargetUrl:typeof s?.handoffTargetUrl=="string"?s.handoffTargetUrl:void 0,handoffCreatedAt:Number(s?.handoffCreatedAt)||void 0})).filter(s=>!!s.logicalTabId):[],nextLogicalTabId:Math.max(1,Number(e.nextLogicalTabId)||1),activeLogicalTabId:Number(e.activeLogicalTabId)||void 0,uiMessages:Array.isArray(e.uiMessages)?e.uiMessages.map(s=>({id:String(s?.id||kn("msg")),role:s?.role==="user"||s?.role==="assistant"||s?.role==="system"?s.role:"system",text:String(s?.text||""),blocks:ki(s?.blocks),ts:Number(s?.ts)||ne(),sourceRuntimeId:typeof s?.sourceRuntimeId=="string"?s.sourceRuntimeId:void 0})).filter(s=>!!s.text||!!s.blocks?.length):[],timeline:Array.isArray(e.timeline)?e.timeline.map(s=>({id:String(s?.id||kn("timeline")),kind:String(s?.kind||"status"),title:String(s?.title||"Step"),detail:typeof s?.detail=="string"?s.detail:void 0,detailBlocks:ki(s?.detailBlocks),status:s?.status==="pending"||s?.status==="success"||s?.status==="error"||s?.status==="info"?s.status:void 0,ts:Number(s?.ts)||ne(),sourceRuntimeId:typeof s?.sourceRuntimeId=="string"?s.sourceRuntimeId:void 0})).filter(s=>!!s.title):[],taskEpoch:Math.max(1,Number(e.taskEpoch)||1),task:Ol(e.task),workerContext:Pl(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)||ne(),updatedAt:Number(e.activeRun.updatedAt)||ne()}: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)||ne()}: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)||ne(),expiresAt:Number(e.workflowLock.expiresAt)||0}:void 0},i=o.tabs.length,a=new Set;return o.tabs=o.tabs.filter(s=>a.has(s.logicalTabId)?!1:(a.add(s.logicalTabId),!0)),o.nextLogicalTabId<=(o.tabs.at(-1)?.logicalTabId??0)&&(o.nextLogicalTabId=o.tabs.reduce((s,l)=>Math.max(s,l.logicalTabId),0)+1),i>0&&o.tabs.length<i&&console.warn(`[rover] sanitizeSharedState: dropped ${i-o.tabs.length} invalid/duplicate tab entries`),o}var Si=class Si{constructor(t){W(this,"siteId");W(this,"sessionId");W(this,"runtimeId");W(this,"leaseMs");W(this,"heartbeatMs");W(this,"maxMessages");W(this,"maxTimeline");W(this,"onRoleChange");W(this,"onStateChange");W(this,"onSwitchRequested");W(this,"key");W(this,"channelName");W(this,"state");W(this,"channel",null);W(this,"heartbeatTimer",null);W(this,"storageHandler",null);W(this,"localLogicalTabId");W(this,"closing",!1);W(this,"started",!1);W(this,"pendingRpcRequests",new Map);W(this,"rpcRequestHandler");W(this,"lastNotifiedRole");W(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=`${Sp}${this.siteId}:${this.sessionId}`,this.channelName=`${Ap}${this.siteId}:${this.sessionId}`,this.state=this.loadState(),this.normalizeDraftTabs(this.state)}tabFreshnessTs(t){return Math.max(Number(t.updatedAt)||0,Number(t.openedAt)||0,Number(t.detachedAt)||0)}isBetterTabCandidate(t,n){if(!n)return!0;let r=this.tabFreshnessTs(t),o=this.tabFreshnessTs(n);return r!==o?r>o:!!t.runtimeId!=!!n.runtimeId?!!t.runtimeId:t.logicalTabId<n.logicalTabId}isRuntimeTabFresh(t,n){return t.runtimeId?t.runtimeId===this.runtimeId?!0:n-this.tabFreshnessTs(t)<=45e3:!1}isTabVisibleInScope(t,n,r){return t.runtimeId?this.isRuntimeTabFresh(t,n):t.external?n-this.tabFreshnessTs(t)<=12e4:t.detachedReason==="opened_pending_attach"?n-this.tabFreshnessTs(t)<=2e4:r==="context"?!1:t.detachedReason==="navigation_handoff"?n-this.tabFreshnessTs(t)<=45e3:n-this.tabFreshnessTs(t)<=9e4}normalizeDraftTabs(t){let n=new Map;for(let g of t.tabs){if(!Number.isFinite(Number(g.logicalTabId))||Number(g.logicalTabId)<=0)continue;let _=n.get(g.logicalTabId);this.isBetterTabCandidate(g,_)&&n.set(g.logicalTabId,g)}let r=[],o=new Set;for(let g of t.tabs){if(o.has(g.logicalTabId))continue;let _=n.get(g.logicalTabId);_&&_===g&&(r.push(_),o.add(_.logicalTabId))}for(let[g,_]of n.entries())o.has(g)||(r.push(_),o.add(g));let i=new Map;for(let g of r){if(!g.runtimeId)continue;let _=i.get(g.runtimeId);this.isBetterTabCandidate(g,_)&&i.set(g.runtimeId,g)}if(t.tabs=r.filter(g=>!g.runtimeId||i.get(g.runtimeId)===g).sort((g,_)=>g.logicalTabId-_.logicalTabId),!t.tabs.length){t.activeLogicalTabId=void 0,t.nextLogicalTabId=1;return}let a=ne(),s=t.activeLogicalTabId?t.tabs.find(g=>g.logicalTabId===t.activeLogicalTabId):void 0,l=t.tabs.find(g=>g.runtimeId===this.runtimeId),d=[...t.tabs.filter(g=>this.isRuntimeTabFresh(g,a))].sort((g,_)=>this.tabFreshnessTs(_)-this.tabFreshnessTs(g))[0],y=s?.logicalTabId;s?(!s.runtimeId||!this.isRuntimeTabFresh(s,a))&&(y=l?.logicalTabId||d?.logicalTabId||s.logicalTabId):y=l?.logicalTabId||d?.logicalTabId||t.tabs[0]?.logicalTabId,t.activeLogicalTabId=y;let I=t.tabs.reduce((g,_)=>Math.max(g,_.logicalTabId),0);t.nextLogicalTabId=Math.max(Number(t.nextLogicalTabId)||1,I+1)}pruneDetachedTabs(t,n){let r=!!n?.dropRuntimeDetached,o=!!n?.dropAllDetachedExternal,i=!!n?.keepOnlyActiveLiveTab,a=!!n?.keepRecentExternalPlaceholders,s=ne();if(t.tabs=t.tabs.filter(l=>{if(l.runtimeId)return this.isRuntimeTabFresh(l,s);if(r&&!l.external&&l.openerRuntimeId===this.runtimeId)return!1;if(l.external)return o?!1:s-this.tabFreshnessTs(l)<=12e4;let p=s-this.tabFreshnessTs(l);return l.detachedReason==="navigation_handoff"?p<=45e3:l.detachedReason==="opened_pending_attach"?p<=2e4:p<=9e4}),i){this.normalizeDraftTabs(t);let l=t.tabs.filter(g=>this.isRuntimeTabFresh(g,s)),p=l.find(g=>g.logicalTabId===t.activeLogicalTabId),d=l.find(g=>g.runtimeId===this.runtimeId),y=[...l].sort((g,_)=>this.tabFreshnessTs(_)-this.tabFreshnessTs(g))[0],I=p?.logicalTabId||d?.logicalTabId||y?.logicalTabId;t.tabs=t.tabs.filter(g=>g.runtimeId?!!I&&g.logicalTabId===I:g.external?a&&s-this.tabFreshnessTs(g)<=12e4:!1),t.activeLogicalTabId=I||t.tabs.find(g=>g.runtimeId)?.logicalTabId||t.tabs[0]?.logicalTabId}this.normalizeDraftTabs(t)}resetDraftToSingleCurrentTab(t,n,r){let o=ne(),i=Ii(n),a=t.tabs.find(l=>l.runtimeId===this.runtimeId),s=Number(a?.openedAt)||o;t.tabs=[{logicalTabId:1,runtimeId:this.runtimeId,url:i||a?.url||"",title:r||a?.title,openedAt:s,updatedAt:o,external:!1,detachedAt:void 0,detachedReason:void 0}],t.activeLogicalTabId=1,t.nextLogicalTabId=2,t.lease={holderRuntimeId:this.runtimeId,expiresAt:o+this.leaseMs,updatedAt:o}}start(t){this.started||(this.started=!0,this.mutate("local",n=>{this.pruneDetachedTabs(n,{dropRuntimeDetached:!0,dropAllDetachedExternal:!0})}),this.registerCurrentTab(window.location.href,document.title||void 0,t),this.claimLease(!1),this.state.task||this.mutate("local",n=>{n.task={taskId:kn("task"),status:"running",startedAt:ne(),boundaryReason:"session_start"}}),typeof BroadcastChannel<"u"&&(this.channel=new BroadcastChannel(this.channelName),this.channel.onmessage=n=>{let r=n.data;if(!(!r||typeof r!="object")){if(r.type==="state"&&r.state){let o=Fr(r.state,this.siteId,this.sessionId);this.applyIncomingState(o)}r.type==="switch_request"&&r.targetRuntimeId===this.runtimeId&&this.onSwitchRequested?.(Number(r.logicalTabId)||0),r.type==="rpc_request"&&r.targetRuntimeId===this.runtimeId&&this.handleInboundRpcRequest(r),r.type==="rpc_response"&&r.targetRuntimeId===this.runtimeId&&this.handleInboundRpcResponse(r),r.type==="tab_navigated"&&r.runtimeId&&r.runtimeId!==this.runtimeId&&this.handleRemoteNavigation(r),r.type==="tab_closing"&&r.runtimeId&&r.runtimeId!==this.runtimeId&&this.handleRemoteTabClosing(r)}}),this.storageHandler=n=>{if(!(n.key!==this.key||!n.newValue))try{let r=Fr(JSON.parse(n.newValue),this.siteId,this.sessionId);this.applyIncomingState(r)}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<=ne()?!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=Ol(t)||r.task)})}hydrateExternalState(t){let n=Fr(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 i=this.state.seq!==r||this.state.updatedAt!==o;if(!i&&this.state.tabs.some(s=>s.runtimeId?!1:s.external?!0:s.openerRuntimeId===this.runtimeId)){let s=this.state.tabs.length;this.mutate("local",l=>{this.pruneDetachedTabs(l,{dropRuntimeDetached:!0,dropAllDetachedExternal:!0})}),i=this.state.tabs.length!==s}return i?(this.persistState(),this.localLogicalTabId||this.registerCurrentTab(window.location.href,document.title||void 0),!0):!1}listTabs(t){let n=t?.scope==="all"?"all":"context",r=ne();return this.state.tabs.filter(o=>this.isTabVisibleInScope(o,r,n))}pruneTabs(t){this.mutate("local",n=>{this.pruneDetachedTabs(n,t)})}resetTabsToCurrent(t,n){return this.mutate("local",r=>{this.resetDraftToSingleCurrentTab(r,t,n)}),this.notifyRoleChange(),this.localLogicalTabId||1}startNewTask(t){let n=Number(t.startedAt)||ne(),r={taskId:String(t.taskId||kn("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.resetDraftToSingleCurrentTab(o,window.location.href,document.title||void 0)}),r}endTask(t){let n;return this.mutate("local",r=>{r.task&&(r.task={...r.task,status:"ended",boundaryReason:t||r.task.boundaryReason,endedAt:ne()},r.activeRun=void 0,n=r.task)}),n}markTaskActivity(t,n=ne()){t!=="system"&&this.mutate("local",r=>{if(!r.task){r.task={taskId:kn("task"),status:"running",startedAt:n,boundaryReason:"implicit",lastUserAt:t==="user"?n:void 0,lastAssistantAt:t==="assistant"?n:void 0};return}r.task.status==="running"&&(t==="user"&&(r.task.lastUserAt=n),t==="assistant"&&(r.task.lastAssistantAt=n))})}setWorkerContext(t){this.mutate("local",n=>{if(!t){n.workerContext=void 0;return}n.workerContext=Pl(t)})}setStatus(t){this.mutate("local",n=>{n.uiStatus=t||void 0})}appendMessage(t){let n={id:t.id||kn("msg"),role:t.role,text:String(t.text||""),blocks:ki(t.blocks),ts:Number(t.ts)||ne(),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:kn("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||kn("timeline"),kind:String(t.kind||"status"),title:String(t.title||"Step"),detail:t.detail?String(t.detail):void 0,detailBlocks:ki(t.detailBlocks),status:t.status,ts:Number(t.ts)||ne(),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}if(n.task&&n.task.status!=="running"){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:ne(),updatedAt:ne()},n.task||(n.task={taskId:kn("task"),status:"running",startedAt:ne()})})}requestControl(){return this.claimLease(!0)}registerCurrentTab(t,n,r){let o=Ii(t),i=typeof r?.handoffId=="string"?r.handoffId.trim():"",a=Number(r?.sourceLogicalTabId),s;return this.mutate("local",l=>{let p=ne(),y=!!(l.lease&&l.lease.expiresAt>p)?l.lease?.holderRuntimeId:void 0,I=!y||y===this.runtimeId,g=l.tabs.find(x=>x.runtimeId===this.runtimeId);if(g)g.url=o||g.url,g.title=n||g.title,g.updatedAt=p,g.detachedAt=void 0,g.detachedReason=void 0,g.handoffId=void 0,g.handoffRunId=void 0,g.handoffTargetUrl=void 0,g.handoffCreatedAt=void 0,s=g.logicalTabId;else{let x;if(i&&(x=l.tabs.find(B=>{if(B.runtimeId||String(B.handoffId||"").trim()!==i||Number.isFinite(a)&&a>0&&B.logicalTabId!==a)return!1;let j=p-Number(B.handoffCreatedAt||B.updatedAt||B.openedAt||0);return j>=0&&j<=3e4})),x||(x=l.tabs.find(B=>!B.runtimeId&&!B.external&&B.url===o&&p-B.openedAt<18e4)),x)x.runtimeId=this.runtimeId,x.url=o||x.url,x.title=n||x.title,x.updatedAt=p,x.detachedAt=void 0,x.detachedReason=void 0,x.handoffId=void 0,x.handoffRunId=void 0,x.handoffTargetUrl=void 0,x.handoffCreatedAt=void 0,s=x.logicalTabId;else{let B=l.nextLogicalTabId++;l.tabs.push({logicalTabId:B,runtimeId:this.runtimeId,url:o,title:n,openedAt:p,updatedAt:p,external:!1,detachedAt:void 0,detachedReason:void 0}),s=B}}let _=l.activeLogicalTabId?l.tabs.find(x=>x.logicalTabId===l.activeLogicalTabId):void 0;(!_||!_.runtimeId||_.logicalTabId===s||I)&&(l.activeLogicalTabId=s)}),this.notifyRoleChange(),this.localLogicalTabId||s||1}registerOpenedTab(t){let n=Ii(t.url),r=0;return this.mutate("local",o=>{let i=ne(),a=o.tabs.find(s=>!s.runtimeId&&!!s.external==!!t.external&&s.url===n);if(a){a.title=t.title||a.title,a.updatedAt=i,a.openerRuntimeId=t.openerRuntimeId||a.openerRuntimeId,a.detachedAt=a.detachedAt||i,a.detachedReason="opened_pending_attach",r=a.logicalTabId;return}r=o.nextLogicalTabId++,o.tabs.push({logicalTabId:r,runtimeId:void 0,url:n,title:t.title,openedAt:i,updatedAt:i,external:!!t.external,openerRuntimeId:t.openerRuntimeId,detachedAt:i,detachedReason:"opened_pending_attach"})}),{logicalTabId:r}}switchToLogicalTab(t){let n={ok:!1,reason:"Unknown tab"};return this.mutate("local",r=>{let o=r.tabs.find(i=>i.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:ne()+this.leaseMs,updatedAt:ne()},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:ne()+this.leaseMs,updatedAt:ne()},n={ok:!0,delegated:!1}}),this.notifyRoleChange(),n}sendCrossTabRpc(t,n,r,o=15e3){return new Promise((i,a)=>{if(!this.channel){a(new Error("BroadcastChannel not available"));return}let s=kn("rpc"),l=window.setTimeout(()=>{this.pendingRpcRequests.delete(s),a(new Error(`Cross-tab RPC timed out after ${o}ms (method=${n}, target=${t})`))},o);this.pendingRpcRequests.set(s,{resolve:i,reject:a,timer:l}),this.channel.postMessage({type:"rpc_request",requestId:s,sourceRuntimeId:this.runtimeId,targetRuntimeId:t,method:n,params:r,timeoutMs:o,createdAt:ne()})})}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(t){this.closing=!0,this.mutate("local",n=>{let r=ne(),o=n.tabs.find(i=>i.runtimeId===this.runtimeId);o&&(o.runtimeId=void 0,o.updatedAt=r,o.detachedAt=r,o.detachedReason=t?"navigation_handoff":"tab_close",o.handoffId=typeof t?.handoffId=="string"?t.handoffId:void 0,o.handoffRunId=typeof t?.runId=="string"?t.runId:void 0,o.handoffTargetUrl=typeof t?.targetUrl=="string"?t.targetUrl:void 0,o.handoffCreatedAt=Number(t?.ts)||r),n.lease?.holderRuntimeId===this.runtimeId&&(n.lease=void 0)}),this.channel&&this.channel.postMessage({type:"tab_closing",runtimeId:this.runtimeId,logicalTabId:this.localLogicalTabId,handoff:t})}isTabAlive(t){let n=this.state.tabs.find(r=>r.logicalTabId===t);return n?n.updatedAt>ne()-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>ne()){let i=r.tabs.find(s=>s.runtimeId===o.runtimeId);if(i&&i.updatedAt>ne()-2*this.heartbeatMs){n=!1;return}}r.workflowLock={runtimeId:this.runtimeId,runId:t,lockedAt:ne(),expiresAt:ne()+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>ne()}getWorkflowLockInfo(){let t=this.state.workflowLock;return!t||t.expiresAt<=ne()?{locked:!1}:{locked:!0,holderRuntimeId:t.runtimeId,runId:t.runId}}async handleInboundRpcRequest(t){let{requestId:n,sourceRuntimeId:r,method:o,params:i}=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 a=await this.rpcRequestHandler({method:o,params:i});this.channel?.postMessage({type:"rpc_response",requestId:n,sourceRuntimeId:this.runtimeId,targetRuntimeId:r,ok:!0,result:a})}catch(a){this.channel?.postMessage({type:"rpc_response",requestId:n,sourceRuntimeId:this.runtimeId,targetRuntimeId:r,ok:!1,error:{message:a?.message||String(a)}})}}handleInboundRpcResponse(t){let{requestId:n,ok:r,result:o,error:i}=t,a=this.pendingRpcRequests.get(n);a&&(this.pendingRpcRequests.delete(n),window.clearTimeout(a.timer),r?a.resolve(o):a.reject(new Error(i?.message||"Cross-tab RPC failed")))}handleRemoteNavigation(t){let{runtimeId:n,url:r,title:o}=t;this.mutate("local",i=>{let a=i.tabs.find(s=>s.runtimeId===n);a&&(a.url=r||a.url,a.title=o||a.title,a.updatedAt=ne())})}handleRemoteTabClosing(t){let{runtimeId:n}=t,r=t?.handoff,o=typeof r?.handoffId=="string"&&r.handoffId.trim()?r.handoffId.trim():void 0,i=typeof r?.runId=="string"&&r.runId.trim()?r.runId.trim():void 0,a=typeof r?.targetUrl=="string"&&r.targetUrl.trim()?r.targetUrl.trim():void 0,s=Number(r?.ts)||ne();this.mutate("local",l=>{let p=ne(),d=l.tabs.find(y=>y.runtimeId===n);d&&(d.runtimeId=void 0,d.updatedAt=p,d.detachedAt=p,d.detachedReason=o?"navigation_handoff":"tab_close",d.handoffId=o,d.handoffRunId=i,d.handoffTargetUrl=a,d.handoffCreatedAt=s),l.lease?.holderRuntimeId===n&&(l.lease=void 0),l.workflowLock?.runtimeId===n&&(l.workflowLock=void 0),l.activeRun?.runtimeId===n&&(l.activeRun=void 0),l.activeLogicalTabId&&!l.tabs.some(y=>y.logicalTabId===l.activeLogicalTabId)&&(l.activeLogicalTabId=this.localLogicalTabId||l.tabs[0]?.logicalTabId)}),this.notifyRoleChange()}heartbeat(){if(this.closing)return;let t=Ii(window.location.href),n=document.title||void 0;this.mutate("local",r=>{let o=r.tabs.find(g=>g.runtimeId===this.runtimeId);if(o)o.url=t||o.url,o.title=n||o.title,o.updatedAt=ne(),o.detachedAt=void 0,o.detachedReason=void 0;else{let g=ne(),_=r.nextLogicalTabId++;r.tabs.push({logicalTabId:_,runtimeId:this.runtimeId,url:t,title:n,openedAt:g,updatedAt:g,external:!1,detachedAt:void 0,detachedReason:void 0})}let i=r.lease,a=!i||i.expiresAt<=ne(),s=i&&i.holderRuntimeId!==this.runtimeId&&i.expiresAt>ne()?i.holderRuntimeId:void 0,l=s?r.tabs.find(g=>g.runtimeId===s):void 0,p=!!(l&&l.updatedAt>ne()-2*this.heartbeatMs),d=!!(r.activeRun?.runtimeId&&r.activeRun.runtimeId!==this.runtimeId),y=!!(r.workflowLock&&r.workflowLock.runtimeId!==this.runtimeId&&r.workflowLock.expiresAt>ne()),I=!!(s&&!p&&!d&&!y);(a||i?.holderRuntimeId===this.runtimeId||I)&&(r.lease={holderRuntimeId:this.runtimeId,expiresAt:ne()+this.leaseMs,updatedAt:ne()},!r.activeLogicalTabId&&this.localLogicalTabId&&(r.activeLogicalTabId=this.localLogicalTabId)),r.workflowLock?.runtimeId===this.runtimeId&&(r.workflowLock.expiresAt=ne()+this.leaseMs*5),this.pruneDetachedTabs(r)}),this.notifyRoleChange()}reloadFromStorage(){let t=this.loadState();return this.normalizeDraftTabs(t),(t.seq>this.state.seq||t.seq===this.state.seq&&t.updatedAt>this.state.updatedAt)&&(this.state=t,this.syncLocalLogicalTabId(),this.onStateChange?.(this.state,"remote")),this.closing=!1,this.state}claimLease(t){let n=!1;return this.mutate("local",r=>{let o=r.lease,i=!o||o.expiresAt<=ne();(t||i||o?.holderRuntimeId===this.runtimeId)&&(r.lease={holderRuntimeId:this.runtimeId,expiresAt:ne()+this.leaseMs,updatedAt:ne()},!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}))},Si.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 i=Fr(JSON.parse(o),this.siteId,this.sessionId);(i.seq>this.state.seq||i.seq===this.state.seq&&i.updatedAt>this.state.updatedAt)&&(this.state=i)}}catch{}let r=Fr(this.state,this.siteId,this.sessionId);n(r),this.normalizeDraftTabs(r),r.seq=Math.max(1,Number(r.seq)||1)+(t==="local"?1:0),r.updatedAt=ne(),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.normalizeDraftTabs(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 Vs(this.siteId,this.sessionId);let n=JSON.parse(t);return Fr(n,this.siteId,this.sessionId)}catch(t){return console.warn("[rover] Failed to load shared state from localStorage:",t),Vs(this.siteId,this.sessionId)}}persistState(){try{window.localStorage.setItem(this.key,JSON.stringify(this.state))}catch{}}};W(Si,"ROLE_CHANGE_DEBOUNCE_MS",200);var Ri=Si;var Cp="https://extensionrouter.rtrvr.ai";function qr(e,t){let n=Number(e);return Number.isFinite(n)?n:t}function Bl(e,t=8e3){let n=String(e??"");return n.length<=t?n:`${n.slice(0,t)}\u2026`}function Np(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,qr(e.updatedAt,0),t,n,r,o].join(":")}function Lp(e){let t=Cp,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 Gs(e,t){let n=new Error(e);return n.details=t,n}var Ai=class{constructor(t){W(this,"endpoint");W(this,"token");W(this,"siteId");W(this,"visitorId");W(this,"ttlHours");W(this,"flushIntervalMs");W(this,"pullIntervalMs");W(this,"minFlushIntervalMs");W(this,"shouldWrite");W(this,"buildCheckpoint");W(this,"onCheckpoint");W(this,"onStateChange");W(this,"onError");W(this,"started",!1);W(this,"dirty",!1);W(this,"flushTimer",null);W(this,"pullTimer",null);W(this,"lastFlushAt",0);W(this,"lastPullAt",0);W(this,"lastUploadedRevision","");W(this,"lastAppliedRemoteUpdatedAt",0);W(this,"pushInFlight",!1);W(this,"pullInFlight",!1);W(this,"state","active");let n=String(t.authToken||t.apiKey||"").trim();if(!n)throw Gs("Rover cloud checkpoint requires apiKey or authToken.");this.endpoint=Lp(t.apiBase),this.token=n,this.siteId=t.siteId,this.visitorId=t.visitorId,this.ttlHours=Math.max(1,Math.min(168,Math.floor(qr(t.ttlHours,1)))),this.flushIntervalMs=Math.max(2e3,Math.floor(qr(t.flushIntervalMs,8e3))),this.pullIntervalMs=Math.max(2e3,Math.floor(qr(t.pullIntervalMs,9e3))),this.minFlushIntervalMs=Math.max(1e3,Math.floor(qr(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=Np(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(qr(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 i;try{i=await r.json()}catch{let a=await r.text().catch(()=>"");i=a?{error:Bl(a,2e3)}:void 0}throw Gs(`Checkpoint HTTP ${r.status}`,{action:t,status:r.status,payload:i})}let o=await r.json();if(o?.success===!1)throw Gs("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,i=o?.errorCode||o?.errorDetails?.code||o?.error?.code||o?.code,a=o?.error||o?.errorDetails?.message||o?.error?.message||n?.message||"Checkpoint request failed",s=Number(r?.status);return{code:typeof i=="string"?i:void 0,message:Bl(a,1e3),status:Number.isFinite(s)?s: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 Mp="rover-runtime-state-db",Ci="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{}}},js=class{constructor(){W(this,"dbPromise",null)}openDb(){return this.dbPromise?this.dbPromise:(this.dbPromise=new Promise((t,n)=>{if(typeof indexedDB>"u"){n(new Error("indexedDB unavailable"));return}let r=indexedDB.open(Mp,1);r.onupgradeneeded=()=>{let o=r.result;o.objectStoreNames.contains(Ci)||o.createObjectStore(Ci)},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,i)=>{let a=r.transaction(Ci,t),s=a.objectStore(Ci);n(s,o,i),a.onerror=()=>{i(a.error||new Error("indexedDB transaction failed"))}})}async read(t){try{return await this.withStore("readonly",(n,r,o)=>{let i=n.get(t);i.onsuccess=()=>{let a=i.result;r(a??null)},i.onerror=()=>{o(i.error||new Error("indexedDB read failed"))}})}catch{return null}}async write(t,n){await this.withStore("readwrite",(r,o,i)=>{let a=r.put(n,t);a.onsuccess=()=>o(),a.onerror=()=>{i(a.error||new Error("indexedDB write failed"))}}).catch(()=>{})}async remove(t){await this.withStore("readwrite",(n,r,o)=>{let i=n.delete(t);i.onsuccess=()=>r(),i.onerror=()=>{o(i.error||new Error("indexedDB delete failed"))}}).catch(()=>{})}};function Hl(){let e=new zs,t=new js;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 Dp="rover_xdr_";function Fl(e){let t=e.split(".").filter(Boolean);return t.length<2?e:`${t[t.length-2]}.${t[t.length-1]}`}function Ys(e){return`${Dp}${e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,40)}`}function Xs(e,t){try{let n=Ys(e),r=Fl(window.location.hostname),o=encodeURIComponent(JSON.stringify(t)),i=window.location.protocol==="https:",a=[`${n}=${o}`,"path=/",`domain=.${r}`,"max-age=120","SameSite=Lax"];i&&a.push("Secure"),document.cookie=a.join("; ")}catch{}}function ql(e){try{let t=Ys(e),n=document.cookie.split(";");for(let r of n){let[o,...i]=r.trim().split("=");if(o===t){let a=i.join("="),s=JSON.parse(decodeURIComponent(a));if(s.timestamp&&Date.now()-s.timestamp<120*1e3)return s}}}catch{}return null}function $l(e){try{let t=Ys(e),n=Fl(window.location.hostname),r=window.location.protocol==="https:",o=[`${t}=`,"path=/",`domain=.${n}`,"max-age=0","SameSite=Lax"];r&&o.push("Secure"),document.cookie=o.join("; ")}catch{}}function on(e){return String(e||"").trim()||void 0}function Op(e){let t=on(e.incomingBoundaryId),n=on(e.currentBoundaryId);return!t||t===n?!1:n?e.taskEpochAdvanced===!0&&e.hasPendingRun!==!0:e.allowBootstrapAdoption!==!1}function Wl(e){let t=on(e.incomingBoundaryId),n=on(e.currentBoundaryId);return t&&n&&t===n?{accept:!0,reason:"match"}:t?Op(e)?{accept:!0,adoptedBoundaryId:t,reason:n?"epoch_adopt":"bootstrap_adopt"}:{accept:!1,reason:"mismatch"}:!n&&e.allowBootstrapAdoption!==!1?{accept:!0,reason:"bootstrap_adopt"}:{accept:!1,reason:"missing_incoming"}}function Vl(e){return e==="completed"||e==="ended"}function Gl(e){return e==="running"}function zl(e){return!(e.taskStatus!=="running"||!e.activeRunId||!e.activeRunText||e.hasPendingRun||e.ignoredRunIds?.has(e.activeRunId))}function Ks(e){return!!(e.localTaskStatus!=="running"||e.remoteTaskStatus&&e.remoteTaskStatus!=="running"||e.mode==="observer"&&!e.hasRemoteActiveRun)}function jl(e){let{type:t,messageRunId:n,messageTaskBoundaryId:r,currentTaskBoundaryId:o,pendingRunId:i,sharedActiveRunId:a,taskStatus:s,ignoredRunIds:l}=e,p=on(o),d=on(r);return(t==="run_started"||t==="run_completed")&&p&&(!d||d!==p)?!0:!n&&t!=="run_started"?!1:n&&l?.has(n)?!0:t==="run_started"?n?i?i!==n:!0:!1:n?t==="run_completed"?s!=="running"?!0:i?i!==n:!(a&&a===n):i?i!==n:!0:!1}var ra=1,Up="rover:runtime:",Pp="rover:runtime-id:",nu="rover:visitor-id:",Js=160,Zs=240,ru=80,$i=40,Bp=8e3,Hp=15*6e4,Fp=12,qp=3600*24*365,$p=1,Wp=3e3,Vp=9e4,Gp=12e3,zp=30,Wi=240,Yl=5*6e4,Vi=100,Gi=12,jp=80,Yp=200,Xp=700,Kp=8,Qp=240,er=null,Ge=null,Se=null,ee=null,Z=null,$r=null,f=null,Tr=null,qe="",P=null,Ot=null,Ui=null,Dt=[],Pi=!1,Wr=!1,ou=0,kt,Rn,nr=!1,vr=!1,go=null,bo=null,_r=null,zi=!1,dt="controller",Cn=!1,Vn=!1,yo=!1,ke="",je=null,Xl=!1,Vr=null,Ni="",iu,Wn=new Map,tr=new Set,Jp=new Set(["run_started","run_completed","assistant","status","tool_start","tool_result","auth_required","navigation_guardrail","error"]),Bi=[],Hi=new Map;function $e(e,t){uh(e,t);let n=Hi.get(e);if(n)for(let r of n)try{r(t)}catch{}}function su(e,t){Hi.has(e)||Hi.set(e,new Set);let n=Hi.get(e);return n.add(t),()=>{n.delete(t)}}function Zp(e){return typeof e=="string"?{name:e}:e}function Gn(e){try{return`${e}-${crypto.randomUUID()}`}catch{return`${e}-${Date.now()}-${Math.floor(Math.random()*1e5)}`}}function xr(){return Gn("task-boundary")}function zr(e){if(!e||typeof e!="object")return;let t=typeof e.handoffId=="string"?e.handoffId.trim():"",n=typeof e.targetUrl=="string"?e.targetUrl.trim():"";if(!t||!n)return;let r=Number(e.sourceLogicalTabId);return{handoffId:t,targetUrl:n,sourceLogicalTabId:Number.isFinite(r)&&r>0?r:void 0,runId:typeof e.runId=="string"&&e.runId.trim()?e.runId.trim():void 0,createdAt:Number(e.createdAt)||Date.now(),consumed:e.consumed===!0}}function au(e){if(e)return{handoffId:e.handoffId,targetUrl:e.targetUrl,sourceLogicalTabId:e.sourceLogicalTabId,runId:e.runId,ts:e.createdAt}}function Kl(e){return{handoffId:e.handoffId,targetUrl:e.targetUrl,sourceLogicalTabId:e.sourceLogicalTabId,runId:e.runId,createdAt:Number(e.ts)||Date.now(),consumed:!1}}function Zi(e){let t=typeof e?.pendingRun?.taskBoundaryId=="string"?e.pendingRun.taskBoundaryId:void 0;if(t)return on(t);let n=typeof e?.workerState?.taskBoundaryId=="string"?e.workerState.taskBoundaryId:void 0;if(n)return on(n)}function eh(e){let t=Zi(e);return t||xr()}function cu(){return on(ke)||Zi(f)}function wr(e){let t=Wl({source:e.source,incomingBoundaryId:e.incomingBoundaryId,currentBoundaryId:cu(),taskEpochAdvanced:e.taskEpochAdvanced,hasPendingRun:!!f?.pendingRun,taskStatus:f?.activeTask?.status,allowBootstrapAdoption:e.allowBootstrapAdoption});return t.accept?(t.adoptedBoundaryId&&(ke=t.adoptedBoundaryId),!0):!1}function oa(e=12e4){let t=zr(f?.lastNavigationHandoff);if(!t||t.consumed===!0)return;let n=Date.now()-Number(t.createdAt||0);if(!(!Number.isFinite(n)||n<-5e3||n>e))return t}function Eo(e){let t=an(f?.pendingRun)?.taskBoundaryId;if(t){ke=t;return}let n=An(f?.workerState)?.taskBoundaryId;if(n){ke=n;return}(!ke||e?.rotateIfMissing)&&(ke=xr())}function th(e){let t=`${Pp}${e}`;try{let n=window.sessionStorage.getItem(t);if(n&&n.trim())return n.trim();let r=Gn("runtime");return window.sessionStorage.setItem(t,r),r}catch{return Gn("runtime")}}function ji(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 Li(e){return String(e||"").trim().replace(/[^a-zA-Z0-9._:-]/g,"").slice(0,180)}function lu(e){try{let t=document.cookie.match(new RegExp(`(?:^|; )${e}=([^;]*)`));return t?decodeURIComponent(t[1]||""):void 0}catch{return}}function Ql(e,t,n){try{let r=n?`; domain=${n}`:"";return document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${qp}; samesite=lax${r}`,lu(e)===t}catch{return!1}}function nh(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 rh(e,t){let n=`rover_vid_${ji(e)}`;for(let r of nh(window.location.hostname))if(Ql(n,t,r))return;Ql(n,t)}function Mi(e,t){let n=`${nu}${e}`;try{window.localStorage.setItem(n,t)}catch{}try{window.sessionStorage.setItem(n,t)}catch{}rh(e,t)}function uu(e,t){f&&(f.visitor=t,Re());try{localStorage.setItem(`rover:visitor:${e}`,JSON.stringify(t))}catch{}}function oh(e){if(f?.visitor?.name||f?.visitor?.email)return f.visitor;try{let t=localStorage.getItem(`rover:visitor:${e}`);return t?JSON.parse(t):void 0}catch{return}}function du(e){let t=Li(e.visitorId||"");if(t)return t;if(e.checkpointing?.autoVisitorId===!1)return;let n=`${nu}${e.siteId}`,r=`rover_vid_${ji(e.siteId)}`,o=Li(lu(r)||"");if(o)return Mi(e.siteId,o),o;try{let a=Li(window.localStorage.getItem(n)||"");if(a)return Mi(e.siteId,a),a}catch{}try{let a=Li(window.sessionStorage.getItem(n)||"");if(a)return Mi(e.siteId,a),a}catch{}let i=`v_${ji(`${e.siteId}:${Gn("visitor")}`)}_${Date.now().toString(36)}`;return Mi(e.siteId,i),i}function ih(e,t){return`visitor-${ji(`${e}:${t}`)}`}function fu(e){!Ge||!Se||(Ge.registerTool(e.def,e.handler),Se.postMessage({type:"register_tool",tool:e.def}))}function sh(e){return`${Up}${e}`}function zn(e="session_start"){let t=Date.now();return{taskId:Gn("task"),status:"running",startedAt:t,lastUserAt:void 0,lastAssistantAt:void 0,boundaryReason:e,endedAt:void 0}}function ea(e,t){return{version:ra,sessionId:e,runtimeId:t,uiOpen:!1,uiHidden:!1,uiStatus:void 0,uiMessages:[],timeline:[],executionMode:"controller",workerState:void 0,pendingRun:void 0,lastNavigationHandoff:void 0,taskEpoch:1,activeTask:zn(),lastRoutingDecision:void 0,updatedAt:Date.now()}}function Ct(e,t=Bp){return e.length<=t?e:`${e.slice(0,t)}\u2026`}function Fi(e){if(e!=null){if(typeof e=="string")return Ct(e,1200);try{return Ct(JSON.stringify(e),1200)}catch{try{return Ct(String(e),1200)}catch{return}}}}function es(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),i=Number.isFinite(o)?Math.min(6e4,Math.max(2e3,Math.floor(o))):Gp,a=Number(t?.maxBatchSize),s=Number.isFinite(a)?Math.min(80,Math.max(1,Math.floor(a))):zp;return{enabled:t?.enabled!==!1,sampleRate:r,flushIntervalMs:i,maxBatchSize:s,includePayloads:t?.includePayloads===!0}}function ia(e){return e==="same_tab"||e==="open_new_tab"?e:"same_tab"}function sa(e,t){return e==="observer"?"This tab is in observer mode because another tab currently holds Rover action control.":t?"Controller tab ready for actions.":"Actions are disabled by configuration (allowActions=false)."}function aa(e){return e==="auto"||e==="confirm"||e==="never"?e:"confirm"}function ca(e){return!(!e||!es(e).enabled||!(e.authToken||e.apiKey))}function Jl(e){if(e!=null){if(typeof e=="string")return Ct(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 i=e?.[o];i!=null&&(typeof i=="string"?n[o]=Ct(i,180):(typeof i=="number"||typeof i=="boolean")&&(n[o]=i))}return n}}}function ah(e,t){if(!t)return Jl(e);let n=da(e);if(n!=null)return typeof n=="string"?Ct(n,1e3):typeof n=="number"||typeof n=="boolean"?n:Array.isArray(n)?{type:"array",length:n.length}:typeof n=="object"?n:Jl(e)}function la(){Ui&&(clearInterval(Ui),Ui=null)}var ch="https://extensionrouter.rtrvr.ai";function pu(e){let t=ch,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 lh(e){return pu(e.apiBase)}async function ts(e=!1){if(Pi||Wr)return;if(!Z||!ca(Z)){Dt=[];return}if(!Dt.length)return;let t=es(Z),n=String(Z.authToken||Z.apiKey||"").trim();if(!n)return;let r=Dt.splice(0,t.maxBatchSize);if(r.length){Pi=!0;try{let o=await fetch(lh(Z),{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({action:"roverTelemetryIngest",data:{siteId:Z.siteId,runtimeId:qe,sessionId:f?.sessionId,visitorId:kt,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?Wr=!0:Dt=[...r,...Dt].slice(-Wi);return}let i=await o.json().catch(()=>{});if(i?.success===!1){let a=String(i?.errorCode||i?.errorDetails?.code||"").toUpperCase();(a==="INVALID_API_KEY"||a==="MISSING_API_KEY"||a==="UNAUTHENTICATED"||a==="PERMISSION_DENIED")&&(Wr=!0);return}}catch{Dt=[...r,...Dt].slice(-Wi)}finally{Pi=!1}}}function ua(e){if(la(),Wr=!1,!ca(e)){Dt=[];return}let t=es(e);Ui=setInterval(()=>{ts(!1)},t.flushIntervalMs)}function uh(e,t){if(!ca(Z)||Wr)return;let n=es(Z);if(n.sampleRate<1&&Math.random()>n.sampleRate)return;let r={name:e,ts:Date.now(),seq:++ou,payload:ah(t,n.includePayloads)};Dt.push(r),Dt.length>Wi&&(Dt=Dt.slice(-Wi)),Dt.length>=n.maxBatchSize&&ts(!1)}function Di(e,t,n="tab_not_accessible"){let r=Number(t?.logicalTabId)||void 0,o=t?.url||"",i=t?.title||(t?.external?"External Tab (Inaccessible)":"Inactive Tab"),a=String(n||"").trim(),s=a?` Reason: ${a}.`:"",l=t?.external?`This external tab is tracked in virtual mode only. Live DOM control and accessibility-tree access are unavailable here.${s}`:`This tab is currently not attached to an active Rover runtime. Switch to a live tab or reopen it.${s}`;return{url:o,title:i,contentType:"text/html",content:l,metadata:{inaccessible:!0,external:!!t?.external,accessMode:t?.external?"external_placeholder":"inactive_tab",reason:n,logicalTabId:r}}}function Oi(e,t,n="tab_not_accessible"){let r=Number(t?.logicalTabId)||0,o=t?.url||"",i=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.`,a=t?.external?"DOMAIN_SCOPE_BLOCKED":"TAB_NOT_ACCESSIBLE";return{success:!1,error:i,allowFallback:!0,output:{success:!1,error:{code:a,message:i,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:a,message:i,retryable:!1,details:{logicalTabId:r,blockedUrl:o,external:!!t?.external,reason:n}}}}function dh(e){if(e==="analyze"||e==="route"||e==="execute"||e==="verify"||e==="complete")return e}function fh(e){return e?e==="analyze"?"Analyze":e==="route"?"Route":e==="execute"?"Execute":e==="verify"?"Verify":e==="complete"?"Complete":"Status":"Status"}function ph(e,t,n){return[String(t||""),String(e||"").trim().toLowerCase(),String(n||"").trim().toLowerCase()].join("|")}function hh(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 mh(){return f?.pendingRun?.id}function sn(e){if(e)for(tr.add(e);tr.size>80;){let t=tr.values().next().value;if(!t)break;tr.delete(t)}}function hu(e){e&&tr.delete(e)}function ho(){return f?.activeTask?.status==="running"}function mu(){let e=P?.getState()?.activeRun;return!!(e&&e.runtimeId&&e.runtimeId!==qe)}function gu(){return!mu()}function bu(e){if(e==="observer")return mu()?"Observing active run in another tab...":"Send to take control and run here."}function gh(e){let t=typeof e?.type=="string"?e.type:"";if(!Jp.has(t))return!1;let n=typeof e?.runId=="string"&&e.runId?e.runId:void 0,r=typeof e?.taskBoundaryId=="string"&&e.taskBoundaryId?e.taskBoundaryId:void 0;return jl({type:t,messageRunId:n,messageTaskBoundaryId:r,currentTaskBoundaryId:cu(),pendingRunId:mh(),sharedActiveRunId:P?.getState()?.activeRun?.runId,taskStatus:f?.activeTask?.status,ignoredRunIds:tr})}function rr(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let r=0;r<e.length;r+=1){let o=e[r];if(!o||typeof o!="object")continue;let i=String(o.key||o.id||"").trim()||`clarification_${r+1}`,a=String(o.query||o.question||"").trim();if(!a)continue;let s=typeof o.required=="boolean",l=typeof o.optional=="boolean",p=s?!!o.required:l?!o.optional:!0,d=`${i}::${a}`.toLowerCase();if(n.has(d))continue;n.add(d);let y={key:i,query:a,...typeof o.id=="string"&&o.id.trim()?{id:o.id.trim()}:{},...typeof o.question=="string"&&o.question.trim()?{question:o.question.trim()}:{},...Array.isArray(o.choices)?{choices:o.choices}:{}};p||(y.required=!1),t.push(y)}return t.slice(0,6)}function bh(e,t){let n=String(e||"").trim();if(n)return n;if(!t||typeof t!="object")return"";let r=t.answersByKey&&typeof t.answersByKey=="object"?t.answersByKey:{},o=rr(f?.workerState?.pendingAskUser?.questions),a=(Array.isArray(t.keys)?t.keys:[]).map(p=>String(p||"").trim()).filter(Boolean);if(a.length===0)for(let p of o){let d=String(p.key||"").trim();d&&a.push(d)}if(a.length===0)for(let p of Object.keys(r)){let d=String(p||"").trim();d&&a.push(d)}let s=[],l=new Set;for(let p of a){let d=String(p||"").trim();if(!d||l.has(d))continue;l.add(d);let y=String(r[d]||"").trim();s.push(`${d}: ${y||"(no answer provided)"}`)}return s.length>0?s.join(`
|
|
1653
|
+
`):String(t.rawText||"").trim()}function Zl(e){if(!e||typeof e!="object")return{taskComplete:!1,needsUserInput:!1,terminalState:"in_progress",contextResetRecommended:!1};let t=String(e.terminalState||"").trim().toLowerCase(),n=e.needsUserInput===!0,r=t==="waiting_input"||t==="in_progress"||t==="completed"||t==="failed"?t:n?"waiting_input":e.taskComplete===!0?"completed":e.ok===!1?"failed":"in_progress",o=r==="completed"||e.taskComplete===!0&&r!=="waiting_input",i=rr(e.questions);return{taskComplete:o,needsUserInput:r==="waiting_input"||n,terminalState:r,contextResetRecommended:e.contextResetRecommended===!0||r==="completed",...i.length?{questions:i}:{}}}function yh(e){if(e&&Wn.has(e))return Wn.get(e);if(f?.uiMessages?.length)for(let t=f.uiMessages.length-1;t>=0;t-=1){let n=f.uiMessages[t];if(n.role==="assistant"){if(n.text)return n.text;let r=fa(n.blocks);if(r)return r}}}function Eh(e){return Tr?Tr.readSync(e):null}function da(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 or(e){if(!Array.isArray(e))return;let t=[];for(let n of e){if(!n||typeof n!="object")continue;let r=n.type;if(r==="text"){let o=String(n.text||"");if(!o)continue;t.push({type:"text",text:o});continue}(r==="tool_output"||r==="json")&&t.push({type:r,data:da(n.data),label:typeof n.label=="string"?n.label:void 0,toolName:typeof n.toolName=="string"?n.toolName:void 0})}return t.length?t:void 0}function eu(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;let t=Object.entries(e).filter(([,i])=>i!=null);if(t.length!==1)return!1;let[n,r]=t[0];return typeof r!="string"||!r.trim()?!1:new Set(["response","message","summary","text","content","result","description"]).has(n)}function vh(e,t){if(e==null)return!1;if(typeof e=="string"){let n=e.trim();return n?!t||n!==t.trim():!1}if(Array.isArray(e)){let n=e.filter(r=>r!=null);if(n.length===1){let r=n[0];if(typeof r=="string"||typeof r=="number"||typeof r=="boolean"||eu(r))return!1}return!0}return!eu(e)}function fa(e){if(!Array.isArray(e)||!e.length)return;let t=e.filter(r=>r.type==="text").map(r=>String(r.text||"").trim()).filter(Boolean);if(t.length)return t.join(`
|
|
1635
1654
|
|
|
1636
|
-
`);let n=e.find(r=>r.type==="tool_output"||r.type==="json");if(n)return Array.isArray(n.data)?`Received ${n.data.length} item(s).`:n.data&&typeof n.data=="object"?`Received ${Object.keys(n.data).length} field(s).`:typeof n.data=="string"?n.data:String(n.data??"Done.")}function rh(e){if(e==null)return;let t=e?.output??e?.generatedContentRef??e?.schemaHeaderSheetInfo??e,n=ta(er([{type:"tool_output",data:t}]));if(nh(t,n))return er([{type:"tool_output",label:typeof e?.name=="string"?`${e.name} output`:"Tool output",data:t}])}function nu(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 Pi(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e.slice(-t)){let o=ea(r);o!==void 0&&n.push(o)}return n}async function oh(e){if(!br)return null;try{return await br.readAsync(e)}catch{return null}}function uo(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-qs)){let r=n?.role;r!=="user"&&r!=="assistant"&&r!=="system"||t.push({id:typeof n?.id=="string"&&n.id?n.id:Zn("msg"),role:r,text:String(n?.text||""),blocks:er(n?.blocks),ts:Number(n?.ts)||Date.now(),sourceRuntimeId:typeof n?.sourceRuntimeId=="string"?n.sourceRuntimeId:void 0})}return t.filter(n=>!!n.text||!!n.blocks?.length)}function fo(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-$s)){let r=At(String(n?.title||""),400);if(!r)continue;let o=String(n?.kind||"status"),i=n?.status;t.push({id:typeof n?.id=="string"&&n.id?n.id:Zn("timeline"),kind:o,title:r,detail:n?.detail?String(n.detail):void 0,detailBlocks:er(n?.detailBlocks),status:i==="pending"||i==="success"||i==="error"||i==="info"?i:void 0,ts:Number(n?.ts)||Date.now(),sourceRuntimeId:typeof n?.sourceRuntimeId=="string"?n.sourceRuntimeId:void 0})}return t}function yr(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(-Wl).map(m=>nu(m)).filter(m=>!!m),i=Pi(n,Ci),s=Pi(r,Ci*2),a=Eo(e?.pendingAskUser?.questions),u=a.length?{questions:a,source:e?.pendingAskUser?.source==="planner"?"planner":"act",askedAt:Number(e?.pendingAskUser?.askedAt)||Date.now()}:void 0;return{trajectoryId:typeof e.trajectoryId=="string"?e.trajectoryId:void 0,history:o,plannerHistory:i,agentPrevSteps:s,lastToolPreviousSteps:s,pendingAskUser:u,updatedAt:Number(e.updatedAt)||Date.now()}}function po(e,t,n){if(!e||typeof e!="object")return Ws(t,n);let r=Fn(),o=yo(e.activeTask,r),i=Bn(e.pendingRun),s=o.status==="running"?i:void 0;return{version:Ys,sessionId:typeof e.sessionId=="string"&&e.sessionId?e.sessionId:t,runtimeId:typeof e.runtimeId=="string"&&e.runtimeId?e.runtimeId:n,uiOpen:!!e.uiOpen,uiHidden:!!e.uiHidden,uiStatus:typeof e.uiStatus=="string"?At(e.uiStatus,300):void 0,uiMessages:uo(e.uiMessages),timeline:fo(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:yr(e.workerState),pendingRun:s,taskEpoch:Math.max(1,Number(e.taskEpoch)||1),activeTask:o,lastRoutingDecision:e.lastRoutingDecision&&(e.lastRoutingDecision.mode==="act"||e.lastRoutingDecision.mode==="planner")?{mode:e.lastRoutingDecision.mode,score:Number(e.lastRoutingDecision.score)||void 0,reason:typeof e.lastRoutingDecision.reason=="string"?At(e.lastRoutingDecision.reason,200):void 0,ts:Number(e.lastRoutingDecision.ts)||Date.now()}:void 0,updatedAt:Number(e.updatedAt)||Date.now()}}function yo(e,t){if(!e||typeof e!="object")return t;let n=typeof e.taskId=="string"&&e.taskId.trim()?e.taskId.trim():t.taskId,r=e.status==="ended"||e.status==="completed"||e.status==="running"?e.status:"running";return{taskId:n,status:r,startedAt:Number(e.startedAt)||t.startedAt,lastUserAt:Number(e.lastUserAt)||void 0,lastAssistantAt:Number(e.lastAssistantAt)||void 0,boundaryReason:typeof e.boundaryReason=="string"?At(e.boundaryReason,120):t.boundaryReason,endedAt:Number(e.endedAt)||void 0}}function ih(e,t){return yo(e,t)}function ru(e){if(!e)return;let t=Eo(e.pendingAskUser?.questions);return{trajectoryId:e.trajectoryId,history:Array.isArray(e.history)?e.history.slice(-Wl).map(n=>nu(n)).filter(n=>!!n):[],plannerHistory:Pi(e.plannerHistory,Ci),agentPrevSteps:Pi(e.agentPrevSteps,Ci*2),pendingAskUser:t.length?{questions:t,source:e.pendingAskUser?.source==="planner"?"planner":"act",askedAt:Number(e.pendingAskUser?.askedAt)||Date.now()}:void 0,updatedAt:Number(e.updatedAt)||Date.now()}}function Bn(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,resumeRequired:e.resumeRequired===!0,resumeReason:e.resumeReason==="cross_host_navigation"||e.resumeReason==="handoff"||e.resumeReason==="page_reload"?e.resumeReason:void 0}}function Ne(){if(!(!h||!Fr))try{h.updatedAt=Date.now(),br?.write(Fr,h),Di||Mt?.markDirty()}catch{}}function sh(){if(Ul)return;Ul=!0;let e=()=>{if(h?.pendingRun?.autoResume){let n=Bn({...h.pendingRun,resumeRequired:!0,resumeReason:h.pendingRun.resumeReason||"page_reload"});h.pendingRun=n,n&&H?.clearActiveRunRuntimeId(n.id)}H?.broadcastClosing(),h?.pendingRun&&H?.releaseWorkflowLock(h.pendingRun.id),Ne(),h?.pendingRun&&Z?.siteId&&Fs(Z.siteId,{sessionId:h.sessionId,pendingRun:{id:h.pendingRun.id,text:h.pendingRun.text,startedAt:h.pendingRun.startedAt,attempts:h.pendingRun.attempts},activeTask:h.activeTask?{taskId:h.activeTask.taskId,status:h.activeTask.status}:void 0,taskEpoch:h.taskEpoch,timestamp:Date.now()}),$i(!0),Js(),Mt?.markDirty(),Mt?.syncNow(),Mt?.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)),Hn=!1,Z&&Zs(Z))};window.addEventListener("pageshow",t)}function Wi(e="implicit"){if(h)return h.activeTask||(h.activeTask=Fn(e),h.taskEpoch=Math.max(1,Number(h.taskEpoch)||1)),h.activeTask}function ah(e,t=Date.now()){if(!h||e==="system")return;let n=Wi("implicit");n&&n.status==="running"&&(e==="user"&&(n.lastUserAt=t),e==="assistant"&&(n.lastAssistantAt=t))}function Vs(e="worker_task_active",t=Date.now()){if(!h)return;let n=Wi(e);n&&(n.status="running",n.endedAt=void 0,n.boundaryReason=e,!n.lastUserAt&&!n.lastAssistantAt&&(n.lastAssistantAt=t),H?.syncTask({...n},h.taskEpoch),Ne())}function ch(e="worker_task_complete",t=Date.now()){if(!h)return;let n=Wi(e);n&&(n.status="completed",n.endedAt=t,n.boundaryReason=e,H?.syncTask({...n},h.taskEpoch),Ne())}function Un(){qr=null,te?.setTaskSuggestion({visible:!1})}function lh(e){qr={kind:"resume_run",runId:e.id,text:e.text,createdAt:Date.now()},te?.setTaskSuggestion({visible:!0,text:"Previous task was interrupted by navigation. Resume it?",primaryLabel:"Resume",secondaryLabel:"Start fresh"}),Rt("Task paused after navigation. Resume to continue.")}function ou(){te?.clearMessages(),te?.clearTimeline(),te?.setQuestionPrompt(void 0),Un()}function Vi(){let e=Eo(h?.workerState?.pendingAskUser?.questions);if(!e.length){te?.setQuestionPrompt(void 0);return}te?.setQuestionPrompt({questions:e})}function uh(){let e=h?.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!==Oe)return!0;let n=Date.now()-Number(e.startedAt||0);return n>=0&&n<=kp}function dh(){if(!h?.pendingRun||uh()||!H)return;let e=h.pendingRun,t=Date.now()-Number(e.startedAt||0);!Number.isFinite(t)||t<Sp||(tn(e.id),wt(void 0),H?.clearActiveRunRuntimeId(e.id),H?.releaseWorkflowLock(e.id),H?.setActiveRun(void 0))}function hn(e,t,n=!0,r){let o=String(t||""),i=er(r?.blocks);if(!o&&(!i||i.length===0))return;let s={id:r?.id||Zn("msg"),role:e,text:o,blocks:i,ts:r?.ts||Date.now(),sourceRuntimeId:r?.sourceRuntimeId};return te?.addMessage(s.role,s.text,{blocks:s.blocks}),h&&n&&(h.uiMessages.push(s),h.uiMessages.length>qs&&(h.uiMessages=h.uiMessages.slice(-qs)),ah(s.role,s.ts),Ne()),H&&r?.publishShared!==!1&&(H.appendMessage({id:s.id,role:s.role,text:s.text,blocks:s.blocks,ts:s.ts}),H.markTaskActivity(s.role,s.ts)),s}function na(e){for(let t of e)hn(t.role,t.text,!1,{id:t.id,ts:t.ts,sourceRuntimeId:t.sourceRuntimeId,publishShared:!1,blocks:t.blocks})}function at(e,t=!0){let n={id:e.id||Zn("timeline"),kind:e.kind,title:At(e.title,400),detail:e.detail?String(e.detail):void 0,detailBlocks:er(e.detailBlocks),status:e.status,ts:e.ts||Date.now(),sourceRuntimeId:e.sourceRuntimeId};return te?.addTimelineEvent(n),h&&t&&(h.timeline.push(n),h.timeline.length>$s&&(h.timeline=h.timeline.slice(-$s)),Ne()),H&&e.publishShared!==!1&&H.appendTimeline({id:n.id,kind:n.kind,title:n.title,detail:n.detail,detailBlocks:n.detailBlocks,status:n.status,ts:n.ts}),n}function ra(e){te?.clearTimeline();for(let t of e)at({id:t.id,kind:t.kind,title:t.title,detail:t.detail,detailBlocks:t.detailBlocks,status:t.status,ts:t.ts,sourceRuntimeId:t.sourceRuntimeId,publishShared:!1},!1)}function Rt(e,t){te?.setStatus(e),h&&(h.uiStatus=At(e,300),Ne()),H&&t?.publishShared!==!1&&H.setStatus(e)}function ho(e,t){lt=e,h&&(h.executionMode=e,Ne()),te?.setExecutionMode(e,{controllerRuntimeId:t?.holderRuntimeId??H?.getCurrentHolderRuntimeId(),localLogicalTabId:t?.localLogicalTabId??H?.getLocalLogicalTabId(),activeLogicalTabId:t?.activeLogicalTabId??H?.getActiveLogicalTabId(),canTakeControl:!0,canComposeInObserver:eu(),note:tu(e)}),Be("mode_change",{mode:e,...t})}function wt(e){h&&(h.pendingRun=e,Ne())}function Hi(e,t){let n=String(e||"").trim();if(!n||!Pe)return;if(lt==="observer"&&!(H?.requestControl()??!1)){hn("system","Unable to take control right now because another tab is still running Rover actions.",!0),at({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,i=t?.appendUserMessage!==!1;Jl(r),i&&hn("user",n,!0);let s=h?.pendingRun?.id===r?h.pendingRun.attempts:0;wt({id:r,text:n,startedAt:Date.now(),attempts:o?s+1:0,autoResume:t?.autoResume!==!1,resumeRequired:!1,resumeReason:void 0}),Vs(o?"worker_task_resumed":"worker_task_active"),Gl=n,H?.acquireWorkflowLock(r),H?.setActiveRun({runId:r,text:n}),Pe.postMessage({type:"run",text:n,runId:r,resume:o,routing:t?.routing,askUserAnswers:t?.askUserAnswers}),ct&&clearTimeout(ct);let a=r;ct=setTimeout(()=>{h?.pendingRun?.id===a&&(tn(a),wt(void 0),H?.releaseWorkflowLock(a),H?.setActiveRun(void 0),Rt("Task timed out."),hn("system","Task timed out after 5 minutes with no response.",!0),Be("error",{message:"Run safety timeout"})),ct=null},5*6e4)}function ao(e,t){let n=String(e||"").trim();if(!n)return;dh();let r=h?.activeTask?.status,o=!!t?.startNewTask||Ml(r);if(H?.pruneTabs({dropRuntimeDetached:!0,dropAllDetachedExternal:o}),o){let i=t?.reason||(r==="completed"?"auto_after_task_complete":"auto_after_task_end");$r({reason:i,clearUi:!0})}Un(),Hi(n,{appendUserMessage:!0,resume:!1,autoResume:!0,routing:t?.routing,askUserAnswers:t?.askUserAnswers})}function Ui(){if(lt==="observer")return;let e=H?.getState()?.activeRun;if(e?.runtimeId&&e.runtimeId!==Oe&&!(h?.pendingRun?.id===e.runId)||!tr||!Pe||Hn||!h?.pendingRun||!Dl(h.activeTask?.status))return;let t=h.pendingRun;if(!t.autoResume)return;let n=Ks(Z?.task?.autoResumePolicy);if(n==="never"){tn(t.id),wt(void 0),H?.setActiveRun(void 0),Rt("Previous task dismissed after navigation.");return}let r=t.resumeReason==="cross_host_navigation"||t.resumeReason==="agent_navigation",o=Z?.siteId||"";if(!!!sessionStorage.getItem(`rover:tab-alive:${o}`)&&!r&&!(H?.listTabs()||[]).some(m=>m.runtimeId!==Oe&&m.updatedAt>Date.now()-2*2e3)&&h?.pendingRun){tn(h.pendingRun.id),wt(void 0),Rt("Previous task expired.");return}if(Date.now()-t.startedAt>Tp){tn(t.id),wt(void 0),Rt("Previous task expired after navigation.");return}if(t.attempts>=_p){tn(t.id),wt(void 0),hn("system","Auto-resume stopped after too many navigation attempts.",!0);return}if(r){Hn=!0,Rt("Resuming task after navigation..."),Hi(t.text,{runId:t.id,resume:!0,appendUserMessage:!1,autoResume:!0});return}if(n==="confirm"){Hn=!0,lh(t);return}Hn=!0,Rt("Resuming previous task after navigation..."),Hi(t.text,{runId:t.id,resume:!0,appendUserMessage:!1,autoResume:!0})}async function fh(e){if(!h)return;let t=await oh(e);if(!t||!h)return;let n=Number(h.updatedAt)||0,r=po({...t,sessionId:h.sessionId,runtimeId:Oe},h.sessionId,Oe);(Number(r.updatedAt)||0)<=n+200||(h=po({...h,...r,sessionId:h.sessionId,runtimeId:Oe},h.sessionId,Oe),Ne(),te&&(te.clearMessages(),na(h.uiMessages),ra(h.timeline),h.uiStatus&&te.setStatus(h.uiStatus),Vi(),h.uiHidden?te.hide():(te.show(),h.uiOpen?te.open():te.close())),tr&&Pe&&h.workerState&<==="controller"&&(Pe.postMessage({type:"hydrate_state",state:h.workerState}),Be("context_restored",{source:"indexeddb_checkpoint",ts:Date.now()})))}function oa(e,t){if(h){if(t==="remote"){let n=Math.max(1,Number(h.taskEpoch)||1),r=Math.max(1,Number(e.taskEpoch)||1),o=r>n;h.taskEpoch=Math.max(n,r);let i=h.activeTask||Fn("shared_sync");h.activeTask=ih(e.task,i),o&&(h.uiMessages=[],h.timeline=[],ou(),wt(void 0),Un());let s=uo(e.uiMessages),a=new Set(s.map(x=>x.id));if(s.length<h.uiMessages.length||h.uiMessages.some(x=>!a.has(x.id)))h.uiMessages=s,te?.clearMessages(),na(h.uiMessages);else{let x=new Set(h.uiMessages.map(S=>S.id));for(let S of s)x.has(S.id)||(hn(S.role,S.text,!0,{id:S.id,ts:S.ts,sourceRuntimeId:S.sourceRuntimeId,publishShared:!1,blocks:S.blocks}),x.add(S.id))}let m=fo(e.timeline),p=new Set(m.map(x=>x.id));if(m.length<h.timeline.length||h.timeline.some(x=>!p.has(x.id)))h.timeline=m,ra(h.timeline);else{let x=new Set(h.timeline.map(S=>S.id));for(let S of m)x.has(S.id)||(at({id:S.id,kind:S.kind,title:S.title,detail:S.detail,detailBlocks:S.detailBlocks,status:S.status,ts:S.ts,sourceRuntimeId:S.sourceRuntimeId,publishShared:!1},!0),x.add(S.id))}typeof e.uiStatus=="string"&&Rt(e.uiStatus,{publishShared:!1});let I=h.activeTask?.status,A=e.task?.status;if(e.activeRun&&e.activeRun.runtimeId!==Oe&&!Bs({localTaskStatus:I,remoteTaskStatus:A,mode:lt,hasRemoteActiveRun:!0})?wt(Bn({id:e.activeRun.runId,text:e.activeRun.text,startedAt:e.activeRun.startedAt,attempts:h.pendingRun?.attempts||0,autoResume:!0})):Bs({localTaskStatus:I,remoteTaskStatus:A,mode:lt,hasRemoteActiveRun:!!e.activeRun})&&(h.pendingRun?.id&&tn(h.pendingRun.id),wt(void 0)),lt==="observer"&&ho("observer",{localLogicalTabId:H?.getLocalLogicalTabId(),activeLogicalTabId:H?.getActiveLogicalTabId(),holderRuntimeId:H?.getCurrentHolderRuntimeId()}),e.workerContext){let x=yr(e.workerContext),S=Number(h.workerState?.updatedAt)||0,B=Number(x?.updatedAt)||0;x&&B>S+100&&(h.workerState=x,tr&&Pe&<==="controller"&&(Pe.postMessage({type:"hydrate_state",state:x}),Be("context_restored",{source:"shared_session",ts:Date.now()})))}}h.uiMessages=uo(h.uiMessages),h.timeline=fo(h.timeline),h.workerState=yr(h.workerState),Vi(),h.activeTask=yo(h.activeTask,Fn("implicit")),Ne()}}function iu(e){let t=Fn("checkpoint_clone");return{version:Ys,sessionId:e.sessionId,runtimeId:e.runtimeId,uiOpen:!!e.uiOpen,uiHidden:!!e.uiHidden,uiStatus:typeof e.uiStatus=="string"?At(e.uiStatus,300):void 0,uiMessages:uo(e.uiMessages),timeline:fo(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:yr(e.workerState),pendingRun:Bn(e.pendingRun),taskEpoch:Math.max(1,Number(e.taskEpoch)||1),activeTask:yo(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 ph(e){return!(e.sessionScope==="tab"||e.checkpointing?.enabled!==!0||!(e.apiKey||e.authToken)||!kt)}function hh(){if(!h||!Z||!kt)return null;let e=H?.getState(),t=iu(h),n=Math.max(Number(e?.updatedAt||0),Number(t.updatedAt||0),Date.now());return{version:Rp,siteId:Z.siteId,visitorId:kt,sessionId:h.sessionId,updatedAt:n,sharedState:e,runtimeState:t}}function mh(e){if(!e||typeof e!="object"||!h||!Z||e.siteId&&e.siteId!==Z.siteId||kt&&e.visitorId&&e.visitorId!==kt)return;let t=typeof e.sessionId=="string"&&e.sessionId.trim()?e.sessionId.trim():h.sessionId;Di=!0;try{if(t&&h.sessionId!==t&&(h.sessionId=t,Z={...Z,sessionId:t},Fi(Z),Pe?.postMessage({type:"update_config",config:{sessionId:t}})),e.sharedState&&H&&H.hydrateExternalState(e.sharedState)&&(oa(H.getState(),"remote"),ho(H.getRole(),{localLogicalTabId:H.getLocalLogicalTabId(),activeLogicalTabId:H.getActiveLogicalTabId(),holderRuntimeId:H.getCurrentHolderRuntimeId()})),e.runtimeState&&typeof e.runtimeState=="object"){let n=po({...e.runtimeState,sessionId:t,runtimeId:Oe},t,Oe),r=Number(h.updatedAt)||0;(Number(n.updatedAt)||0)>r+200&&(h=po({...h,...n,sessionId:t,runtimeId:Oe},t,Oe),Ne(),h.uiStatus&&te?.setStatus(h.uiStatus),h.uiHidden?te?.hide():(te?.show(),h.uiOpen?te?.open():te?.close()),tr&&h.workerState&&(Pe?.postMessage({type:"hydrate_state",state:h.workerState}),Be("context_restored",{source:"cloud_checkpoint",ts:Date.now()})),lt==="controller"&&Ui())}}finally{Di=!1}}function su(e){if(Mt?.stop(),Mt=null,!!ph(e)&&kt)try{let t=n=>{Be("checkpoint_state",n),e.checkpointing?.onStateChange?.(n)};Mt=new Ei({apiBase:e.apiBase,apiKey:e.apiKey,authToken:e.authToken,siteId:e.siteId,visitorId:kt,ttlHours:e.checkpointing?.ttlHours??1,flushIntervalMs:e.checkpointing?.flushIntervalMs,pullIntervalMs:e.checkpointing?.pullIntervalMs,minFlushIntervalMs:e.checkpointing?.minFlushIntervalMs,shouldWrite:()=>lt==="controller",buildCheckpoint:()=>hh(),onCheckpoint:n=>{mh(n)},onStateChange:(n,r)=>{t({state:n,reason:r.reason,action:r.action,code:r.code,message:r.message}),n==="paused_auth"&&Be("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||Be("checkpoint_error",{action:r.action,code:r.code,message:r.message,status:r.status,disabled:!1,reason:"transient_failure"})}}),Mt.start(),Mt.markDirty()}catch{Mt=null}}function Fi(e){if(h){if(H?.stop(),H=null,e.sessionScope==="tab"){ho("controller");return}H=new gi({siteId:e.siteId,sessionId:h.sessionId,runtimeId:Oe,leaseMs:e.tabPolicy?.actionLeaseMs,onRoleChange:(t,n)=>{ho(t,n);let r=t==="controller"&&(Z?.allowActions??!0);if($e?.setAllowActions(r),$e?.setActionGateContext?.({mode:t,controllerRuntimeId:n?.holderRuntimeId??H?.getCurrentHolderRuntimeId(),activeLogicalTabId:n?.activeLogicalTabId??H?.getActiveLogicalTabId(),localLogicalTabId:n?.localLogicalTabId??H?.getLocalLogicalTabId(),reason:Xs(t,r)}),t==="controller"){let o=H?.getWorkerContext();if(o){let i=yr(o),s=Number(h?.workerState?.updatedAt)||0,a=Number(i?.updatedAt)||0;i&&a>s+100&&(h&&(h.workerState=i,Ne()),tr&&Pe&&(Pe.postMessage({type:"hydrate_state",state:i}),Be("context_restored",{source:"controller_handoff",ts:Date.now()})))}Ui()}},onStateChange:(t,n)=>{oa(t,n)},onSwitchRequested:t=>{t>0&&(vo(),at({kind:"status",title:`Switched to tab #${t}`,status:"info"}))}}),H.start(),H.setRpcRequestHandler(async t=>{if(!$e)throw new Error("Bridge not available");if(t.method==="getPageData")return $e.getPageData(t.params);if(t.method==="executeTool")return $e.executeTool(t.params.call,t.params.payload);throw new Error(`Unknown RPC method: ${t.method}`)}),h?.activeTask&&H.syncTask({...h.activeTask,taskId:h.activeTask.taskId},h.taskEpoch),h?.workerState&&H.setWorkerContext(ru(h.workerState))}}function gh(e){let t=At(eh(e)||"Done.",1200);te?.clearTimeline(),h&&(h.timeline=[]),H?.clearTimeline()}function bh(e){if(!(!e||typeof e!="object")&&!Jp(e)){if(e.type==="assistant"){let t=er(e.blocks),n=String(e.text||ta(t)||"");if(typeof e.runId=="string"&&e.runId&&(Pn.set(e.runId,n),Pn.size>80)){let r=Pn.keys().next().value;r&&Pn.delete(r)}hn("assistant",n,!0,{blocks:t}),at({kind:"tool_result",title:"Assistant update",detail:n,detailBlocks:t,status:"success"});return}if(e.type==="status"){let t=Yp(e.stage),n=e.message?String(e.message):void 0,r=e.compactThought?String(e.compactThought):void 0,o=Xp(n,t,r);if(n&&Rt(n),o&&o!==wi&&(wi=o,n)){let i=!!(e.thought||r),s=r||(e.thought?String(e.thought):"");if(i&&t!=="analyze"&&t!=="route"&&t!=="complete"&&!Kp(s,Gl))at({kind:"thought",title:s,detail:e.thought?String(e.thought):r,status:"pending"});else{let u=t?`${jp(t)}: ${n}`:n;at({kind:"status",title:u,detail:r||(e.thought?String(e.thought):void 0),status:t==="complete"?"success":"info"})}}Be("status",e);return}if(e.type==="tool_start"){at({kind:"tool_start",title:`Running ${e.call?.name||"tool"}`,detail:Ai(e.call?.args),status:"pending"}),Be("tool_start",e);return}if(e.type==="tool_result"){let t=er(e.detailBlocks)||rh(e.result);at({kind:"tool_result",title:`${e.call?.name||"tool"} completed`,detail:Ai(e.result),detailBlocks:t,status:e?.result?.success===!1?"error":"success"}),Be("tool_result",e);return}if(e.type==="auth_required"){Be("auth_required",e.error),e.error?.message&&(hn("system",`Auth required: ${e.error.message}`,!0),at({kind:"error",title:"Auth required",detail:String(e.error.message),status:"error"}));return}if(e.type==="navigation_guardrail"){Be("navigation_guardrail",e),at({kind:"status",title:"Navigation guardrail",detail:Ai(e),status:"info"});return}if(e.type==="error"){hn("system",`Error: ${e.message||"unknown"}`,!0),at({kind:"error",title:"Execution error",detail:String(e.message||"unknown"),status:"error"}),Be("error",e);return}if(e.type==="state_snapshot"){if(h){h.workerState=yr({...e.state||{},updatedAt:Date.now()});let t=typeof e?.activeRun?.runId=="string"&&e.activeRun.runId?e.activeRun.runId:void 0,n=typeof e?.activeRun?.text=="string"?e.activeRun.text:void 0,r=Ol({taskStatus:h.activeTask?.status,hasPendingRun:!!h.pendingRun,activeRunId:t,activeRunText:n,ignoredRunIds:Qn});r&&(h.pendingRun=Bn({id:t,text:n,startedAt:e.activeRun.startedAt,attempts:0,autoResume:!0})),t&&n&&r?H?.setActiveRun({runId:t,text:n}):t&&(!so()||Qn.has(t))&&H?.setActiveRun(void 0),!so()&&h.pendingRun&&wt(void 0),h.workerState&&H?.setWorkerContext(ru(h.workerState)),Vi(),Ne()}return}if(e.type==="task_started"){Be("task_started",{taskId:e.taskId,reason:"worker"});return}if(e.type==="run_started"){if(wi="",Un(),typeof e.runId=="string"&&e.runId&&Pn.delete(e.runId),!so()){H?.setActiveRun(void 0);return}let t=h?.pendingRun;typeof e.runId=="string"&&e.runId&&Jl(e.runId),wt(Bn({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||"")}),te?.setRunning(!0),te?.setQuestionPrompt(void 0);let n=`run:${String(e.runId||"")}:start`;h?.timeline.some(r=>r.id===n)||at({id:n,kind:"plan",title:e.resume?"Run resumed":"Run started",detail:String(e.text||""),status:"pending"});return}if(e.type==="run_completed"){wi="",Hn=!1,te?.setRunning(!1),ct&&(clearTimeout(ct),ct=null),h?.pendingRun?.id===e.runId&&wt(void 0),typeof e.runId=="string"&&e.runId&&H?.releaseWorkflowLock(e.runId),h&&e?.route&&(e.route.mode==="act"||e.route.mode==="planner")&&(h.lastRoutingDecision={mode:e.route.mode,score:Number(e.route.score)||void 0,reason:typeof e.route.reason=="string"?At(e.route.reason,200):void 0,ts:Date.now()},Ne()),H?.setActiveRun(void 0);let t=typeof e.runId=="string"&&e.runId?e.runId:void 0;if(t&&tn(t),!e.ok&&e.error){if(t&&Pn.delete(t),!so())return;te?.setQuestionPrompt(void 0),Vs("worker_run_failed"),Rt(`Task failed: ${String(e.error)}`),t&&Pn.delete(t),at({kind:"error",title:"Run failed",detail:String(e.error),status:"error"})}else if(e.ok){if(!so())return;let n=Zp(e),r=n.taskComplete,o=n.needsUserInput,i=n.questions||Eo(e.questions);r?(te?.setQuestionPrompt(void 0),ch("worker_task_complete"),H?.pruneTabs({dropRuntimeDetached:!0,dropAllDetachedExternal:!0}),Rt("Task completed"),gh(typeof e.runId=="string"?e.runId:void 0)):(Vs(o?"worker_waiting_for_input":"worker_continuation"),o&&i.length>0?te?.setQuestionPrompt({questions:i}):te?.setQuestionPrompt(void 0),Rt(o?"Need more input to continue":"Execution finished. Continue when ready."),at({kind:"status",title:o?"Waiting for your input":"Continuation available",detail:o?i.length?`Please answer: ${i.map(s=>`${s.key} (${s.query})`).join("; ")}`:"Planner requested more information before marking the task complete.":"Task is still active and will continue with your next message.",status:"info"}))}return}if(e.type==="ready"){tr=!0,Rt("ready"),Be("ready"),Z&&cu(Z);let t=H?.getWorkerContext(),n=yr(t),r=Number(h?.workerState?.updatedAt)||0,o=Number(n?.updatedAt)||0,i=n&&o>r+100?n:h?.workerState;h&&i&&i!==h.workerState&&(h.workerState=i,Ne()),i?(Pe?.postMessage({type:"hydrate_state",state:i}),Be("context_restored",{source:"runtime_start",ts:Date.now()})):Ui();return}if(e.type==="hydrated"){Ui();return}e.type==="updated"&&Be("updated")}}function Gs(e,t){let n=Number(e);return Number.isFinite(n)?Math.max(t.min,Math.min(t.max,Math.floor(n))):t.fallback}function ia(e){if(!e||typeof e!="object")return;let t=Gs(e.shortcutMaxStored,{min:1,max:Li,fallback:Li}),n=Gs(e.shortcutMaxRendered,{min:1,max:Mi,fallback:Mi});return{shortcutMaxStored:t,shortcutMaxRendered:n}}function wo(){co&&(clearTimeout(co),co=null),lo&&(clearTimeout(lo),lo=null)}function Eh(e){try{let t=localStorage.getItem(`rover:site-config:${e}`);if(t){let n=JSON.parse(t);return!n||typeof n.ts!="number"||typeof n.data!="object"||!n.data||Date.now()-n.ts>Hl?null:{shortcuts:wr(n.data.shortcuts),greeting:mo(n.data.greeting),limits:ia(n.data.limits),version:typeof n.version=="string"?n.version:void 0}}}catch{}try{let t=localStorage.getItem(`rover:shortcuts:${e}`);if(!t)return null;let n=JSON.parse(t);return!n||typeof n.ts!="number"||!Array.isArray(n.data)||Date.now()-n.ts>Hl?null:{shortcuts:wr(n.data)}}catch{return null}}function yh(e,t){try{localStorage.setItem(`rover:site-config:${e}`,JSON.stringify({ts:Date.now(),version:t.version,data:{shortcuts:wr(t.shortcuts),greeting:mo(t.greeting),limits:ia(t.limits)}}))}catch{}}function mo(e){if(!e||typeof e!="object")return;let t={},n=String(e.text||"").trim();n&&(t.text=n.slice(0,Dp));let r=Number(e.delay);Number.isFinite(r)&&(t.delay=Math.max(0,Math.min(6e4,Math.floor(r))));let o=Number(e.duration);return Number.isFinite(o)&&(t.duration=Math.max(1200,Math.min(6e4,Math.floor(o)))),typeof e.disabled=="boolean"&&(t.disabled=e.disabled),Object.keys(t).length?t:void 0}function wh(e){if(!e||typeof e!="object")return null;let t=String(e.id||"").trim().slice(0,80),n=String(e.label||"").trim().slice(0,Cp),r=String(e.prompt||"").trim().slice(0,Lp);if(!t||!n||!r)return null;let o={id:t,label:n,prompt:r,enabled:e.enabled!==!1};e.description&&(o.description=String(e.description).trim().slice(0,Np)),e.icon&&(o.icon=String(e.icon).trim().slice(0,Mp)),(e.routing==="auto"||e.routing==="act"||e.routing==="planner")&&(o.routing=e.routing);let i=Number(e.order);return Number.isFinite(i)&&(o.order=Math.trunc(i)),o}function wr(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let r of e){if(t.length>=Li)break;let o=wh(r);!o||n.has(o.id)||(n.add(o.id),t.push(o))}return t}function vh(e){return e.map((t,n)=>({item:t,index:n})).sort((t,n)=>{let r=Number.isFinite(t.item.order),o=Number.isFinite(n.item.order);return r&&o?Number(t.item.order)-Number(n.item.order):r?-1:o?1:t.index-n.index}).map(t=>t.item)}function Th(e,t){let n=new Map;for(let r of t)n.set(r.id,r);for(let r of e){let o=n.get(r.id);n.set(r.id,o?{...o,...r}:r)}return vh(Array.from(n.values())).slice(0,Li)}function au(e){let t=Gs(Er?.limits?.shortcutMaxRendered,{min:1,max:Mi,fallback:Mi});return e.filter(n=>n.enabled!==!1).slice(0,t)}function Gi(e){if(!e)return;let t=mo(Er?.greeting),n=mo(e.ui?.greeting);if(!(!t&&!n))return{...t||{},...n||{}}}function sa(e){let t=_n?.name,n=e?.text;return n?n.replace(/\{name\}/g,t||"").trim()||(t?`Hey ${t}! Need any help?`:"Hey! Need any help?"):t?`Hey ${t}! Need any help?`:"Hey! Need any help?"}function go(){if(Jn||!te||!Z||h?.uiOpen)return;let e=Gi(Z);if(e?.disabled===!0)return;let t=`rover:greeting-shown:${Z.siteId}`;try{if(sessionStorage.getItem(t)){gr=!0;return}}catch{}if(gr)return;wo();let n=e?.delay??3e3,r=e?.duration??8e3,o=sa(e);co=setTimeout(()=>{if(co=null,!(Jn||h?.uiOpen)){te?.showGreeting(o),gr=!0;try{sessionStorage.setItem(t,"1")}catch{}lo=setTimeout(()=>{lo=null,te?.dismissGreeting()},r)}},n)}function zs(e){let t=wr(e.ui?.shortcuts||[]),n=wr(Er?.shortcuts||[]),r=Th(t,n);te?.setShortcuts(au(r))}async function _h(e){let t=String(e.authToken||e.apiKey||"").trim();if(!t)return null;let n=await fetch(Ql(e.apiBase),{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({action:"roverGetSiteConfig",data:{siteId:e.siteId,siteKeyId:e.siteKeyId}})});if(!n.ok)return null;let r=await n.json();if(!r?.success)return null;let o=r.data?.siteConfig&&typeof r.data.siteConfig=="object"?r.data.siteConfig:r.data;return{shortcuts:wr(o?.shortcuts),greeting:mo(o?.greeting),limits:ia(o?.limits),version:o?.version!=null?String(o.version):void 0}}function cu(e){let t=Eh(e.siteId);t&&(Er=t),zs(e),go(),_h(e).then(n=>{if(n&&(Er=n,yh(e.siteId,n),zs(e),!Jn)){let r=Gi(e);gr&&!h?.uiOpen?te?.showGreeting(sa(r)):go()}}).catch(()=>{})}function aa(e){if(!Z)return;let t={..._n,...e};t.name&&(t.name=String(t.name).trim().slice(0,120)),t.email&&(t.email=String(t.email).trim().slice(0,240)),_n=t,jl(Z.siteId,_n),te?.setVisitorName(_n.name||""),Jn||(gr&&!h?.uiOpen?te?.showGreeting(sa(Gi(Z))):go())}function xh(e){if(Fi(e),H){let s=H.getRole();lt=s,h&&(h.executionMode=s)}su(e),Zs(e);let t=(e.allowActions??!0)&&(H?H.isController():!0);$e=new di({allowActions:t,runtimeId:Oe,allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy,crossHostPolicy:js(e.navigation?.crossHostPolicy),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=>{Be("navigation_guardrail",s),at({kind:"status",title:"Navigation guardrail",detail:Ai(s),status:"info"})},onBeforeAgentNavigation:s=>{if(!h?.pendingRun)return;let a=new URL(window.location.href).hostname,u=new URL(s,window.location.href).hostname;a===u&&(h.pendingRun=Bn({...h.pendingRun,resumeRequired:!0,resumeReason:"agent_navigation"}))},onBeforeCrossHostNavigation:s=>{!h||!Z||(h.pendingRun&&(h.pendingRun=Bn({...h.pendingRun,resumeRequired:!0,resumeReason:"cross_host_navigation"})),Fs(Z.siteId,{sessionId:h.sessionId,pendingRun:h.pendingRun?{id:h.pendingRun.id,text:h.pendingRun.text,startedAt:h.pendingRun.startedAt,attempts:h.pendingRun.attempts}:void 0,activeTask:h.activeTask?{taskId:h.activeTask.taskId,status:h.activeTask.status}:void 0,taskEpoch:h.taskEpoch,timestamp:Date.now()}),Ne())},instrumentationOptions:e.mode==="safe"?{observeInlineMutations:!1}:void 0});let n=lt==="observer"?"observer":"controller";$e?.setActionGateContext?.({mode:n,controllerRuntimeId:H?.getCurrentHolderRuntimeId(),activeLogicalTabId:H?.getActiveLogicalTabId(),localLogicalTabId:H?.getLocalLogicalTabId(),reason:Xs(n,t)});let r=new MessageChannel;gl(r.port1,{getSnapshot:()=>$e.getSnapshot(),getPageData:async s=>{let a=Z||e,u=Number(s?.tabId),m=H?.getLocalLogicalTabId();if(!Number.isFinite(u)||u<=0||u===m||!H)return $e.getPageData(s);let v=H.listTabs().find(I=>I.logicalTabId===u);if(!v)return _i(a,{logicalTabId:u,external:!0},"target_tab_missing");if(v.runtimeId===Oe)return $e.getPageData(s);if(v.external&&a.externalNavigationPolicy!=="allow")return _i(a,v,"external_domain_inaccessible");if(!v.runtimeId||!H.isTabAlive(u))return _i(a,v,"target_tab_inactive");try{return await H.sendCrossTabRpc(v.runtimeId,"getPageData",s,15e3)}catch{return _i(a,v,"cross_tab_rpc_failed")}},executeTool:async s=>{let a=Z||e;if(s?.payload?.forceLocal===!0)return $e.executeTool(s.call,s.payload);let m=Number(s?.call?.args?.tab_id),p=H?.getActiveLogicalTabId(),v=Number.isFinite(m)&&m>0?m:p,I=H?.getLocalLogicalTabId();if(!v||v===I||!H)return $e.executeTool(s.call,s.payload);let x=H.listTabs().find(S=>S.logicalTabId===v);if(!x)return xi(a,{logicalTabId:v,external:!0},"target_tab_missing");if(x.external&&a.externalNavigationPolicy!=="allow")return xi(a,x,"external_tab_action_blocked");if(x.runtimeId===Oe)return $e.executeTool(s.call,s.payload);if(!x.runtimeId||!H.isTabAlive(v))return xi(a,x,"target_tab_inactive");try{return await H.sendCrossTabRpc(x.runtimeId,"executeTool",s,2e4)}catch{return xi(a,x,"cross_tab_execute_failed")}},executeClientTool:s=>$e.executeClientTool(s.name,s.args),listClientTools:()=>$e.listClientTools(),getTabContext:()=>{let s=H?.getLocalLogicalTabId(),a=H?.getActiveLogicalTabId();return{id:s||1,logicalTabId:s||1,activeLogicalTabId:a||s||1,runtimeId:Oe,mode:lt,url:window.location.href,title:document.title}},listSessionTabs:()=>H?.listTabs()||[]}),r.port1.start?.();let o=e.workerUrl?e.workerUrl:new URL("./worker/worker.js",__ROVER_SCRIPT_URL__).toString(),i=o;try{let s=window.location.origin,a=new URL(o).origin;if(s!==a){let u=new Blob([`import '${o}';`],{type:"application/javascript"});i=URL.createObjectURL(u)}}catch{}if(Pe=new Worker(i,{type:"module"}),Pe.postMessage({type:"init",config:e,port:r.port2},[r.port2]),te=Tl({shortcuts:au(wr(e.ui?.shortcuts||[])),greeting:Gi(e),visitorName:_n?.name,onShortcutClick:s=>{let a=String(s.prompt||"").trim();a&&ao(a,{routing:s.routing})},onSend:(s,a)=>{ao(s,{askUserAnswers:a?.askUserAnswers})},onRequestControl:()=>{H?.requestControl()??!1?at({kind:"status",title:"Control requested",detail:"This tab is now the active Rover controller.",status:"info"}):hn("system","Unable to acquire control right now. Try again in a moment.",!0)},onCancelRun:()=>{h?.pendingRun&&(tn(h.pendingRun.id),Pe?.postMessage({type:"cancel_run",runId:h.pendingRun.id}),H?.releaseWorkflowLock(h.pendingRun.id),H?.setActiveRun(void 0),wt(void 0),ct&&(clearTimeout(ct),ct=null),te?.setRunning(!1),te?.setQuestionPrompt(void 0),Rt("Task cancelled."),hn("system","Task cancelled.",!0),at({kind:"info",title:"Run cancelled",status:"info"}))},onNewTask:()=>{$r({reason:"manual_new_task",clearUi:!0})},onEndTask:()=>{Yi({reason:"manual_end_task"})},onTaskSuggestionPrimary:()=>{let s=qr;if(s){if(s.kind==="resume_run"){Un(),Hi(s.text,{runId:s.runId,resume:!0,appendUserMessage:!1,autoResume:!0});return}ao(s.text,{bypassSuggestion:!0,startNewTask:!0,reason:s.reason})}},onTaskSuggestionSecondary:()=>{let s=qr;if(s){if(s.kind==="resume_run"){h?.pendingRun?.id===s.runId&&(tn(s.runId),H?.releaseWorkflowLock(s.runId),H?.setActiveRun(void 0),wt(void 0)),ct&&(clearTimeout(ct),ct=null),Un(),$r({reason:"resume_declined_start_fresh",clearUi:!0});return}ao(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:()=>{Jn=!0,wo(),h&&(h.uiOpen=!0,h.uiHidden=!1,Ne()),Be("open")},onClose:()=>{h&&(h.uiOpen=!1,Ne()),Be("close")}}),Un(),h?.uiMessages?.length&&na(h.uiMessages),h?.timeline?.length&&ra(h.timeline),h?.uiStatus&&te.setStatus(h.uiStatus),Vi(),h?.executionMode&&te.setExecutionMode(h.executionMode,{localLogicalTabId:H?.getLocalLogicalTabId(),activeLogicalTabId:H?.getActiveLogicalTabId(),controllerRuntimeId:H?.getCurrentHolderRuntimeId(),canTakeControl:!0,canComposeInObserver:eu(),note:tu(h.executionMode)}),Pe.onmessage=s=>{bh(s.data||{})},H){let s=()=>{H?.registerCurrentTab(window.location.href,document.title),H?.broadcastNavigation(window.location.href,document.title)},a=history.pushState.bind(history),u=history.replaceState.bind(history);history.pushState=function(...m){let p=a(...m);return setTimeout(s,0),p},history.replaceState=function(...m){let p=u(...m);return setTimeout(s,0),p},window.addEventListener("popstate",s)}h?.uiHidden?te.hide():(te.show(),h?.uiOpen??!!e.openOnInit?te.open():te.close()),h&&(h.uiHidden=!!h.uiHidden,h.uiOpen=!!h.uiOpen,Ne()),H&&(oa(H.getState(),"remote"),ho(H.getRole(),{localLogicalTabId:H.getLocalLogicalTabId(),activeLogicalTabId:H.getActiveLogicalTabId(),holderRuntimeId:H.getCurrentHolderRuntimeId()})),go()}function bo(e){if(Kn)return Bi(e),Kn;br=Al(),Oe=Hp(e.siteId),kt=Xl(e),_n=e.visitor||Bp(e.siteId),Jn=!1,gr=!1,wo(),Er=null,Fr=$p(e.siteId);let t=th(Fr),n=t?null:Nl(e.siteId);n&&Ll(e.siteId);let r=e.sessionId?.trim(),o=!r&&!t?.sessionId&&!n?.sessionId&&e.sessionScope!=="tab"&&kt?qp(e.siteId,kt):void 0,i=r||t?.sessionId||n?.sessionId||o||crypto.randomUUID(),s=t;if(!t&&n){let a=Ws(n.sessionId,Oe);n.pendingRun&&(a.pendingRun=Bn({...n.pendingRun,autoResume:!0,resumeRequired:!0,resumeReason:"cross_host_navigation"})),n.activeTask&&(a.activeTask={...Fn("cross_domain_resume"),taskId:n.activeTask.taskId,status:n.activeTask.status}),a.taskEpoch=n.taskEpoch||1,a.uiOpen=!0,s=a}h=po(s,i,Oe),r&&h.sessionId!==r&&(h=Ws(r,Oe)),Z={...e,visitorId:kt||e.visitorId,sessionId:r||h.sessionId,taskRouting:{mode:e.taskRouting?.mode||"act",actHeuristicThreshold:e.taskRouting?.actHeuristicThreshold,plannerOnActError:e.taskRouting?.plannerOnActError},navigation:{crossHostPolicy:js(e.navigation?.crossHostPolicy)},task:{autoResumePolicy:Ks(e.task?.autoResumePolicy)},taskContext:{...e.taskContext}},h.sessionId=Z.sessionId,h.runtimeId=Oe,h.executionMode=h.executionMode||"controller",h.timeline=fo(h.timeline),h.uiMessages=uo(h.uiMessages),h.activeTask=yo(h.activeTask,Fn("boot")),h.taskEpoch=Math.max(1,Number(h.taskEpoch)||1),lt=h.executionMode,_n&&jl(e.siteId,_n),Ne();try{sessionStorage.setItem(`rover:tab-alive:${e.siteId}`,"1")}catch{}if(tr=!1,Hn=!1,xh(Z),Fr&&fh(Fr),sh(),Kn={boot:bo,init:ca,update:Bi,shutdown:la,open:vo,close:zi,show:ua,hide:da,send:fa,newTask:$r,endTask:Yi,getState:pa,registerTool:ha,identify:aa,on:zl},Si.length){for(let a of Si)Kl(a);Si.length=0}return Kn}function ca(e){return bo(e)}function Bi(e){if(!Kn||!Pe||!Z)return;Z={...Z,...e,taskRouting:{...Z.taskRouting,...e.taskRouting},navigation:{...Z.navigation,...e.navigation,crossHostPolicy:js(e.navigation?.crossHostPolicy??Z.navigation?.crossHostPolicy)},task:{...Z.task,...e.task,autoResumePolicy:Ks(e.task?.autoResumePolicy??Z.task?.autoResumePolicy)},taskContext:{...Z.taskContext,...e.taskContext},ui:{...Z.ui,...e.ui,agent:{...Z.ui?.agent,...e.ui?.agent},panel:{...Z.ui?.panel,...e.ui?.panel}},tools:{...Z.tools,...e.tools,client:e.tools?.client??Z.tools?.client,web:{...Z.tools?.web,...e.tools?.web}}},kt=Xl(Z),kt&&(Z.visitorId=kt),e.sessionId&&h?(h.sessionId=e.sessionId,Ne(),Fi(Z)):(e.sessionScope||e.tabPolicy)&&Fi(Z),su(Z),Zs(Z);let t=e.apiBase!==void 0||e.apiKey!==void 0||e.authToken!==void 0||e.siteId!==void 0||e.siteKeyId!==void 0||e.ui?.shortcuts!==void 0||e.ui?.greeting!==void 0;if($e){typeof e.allowActions=="boolean"&&$e.setAllowActions(e.allowActions&<==="controller");let n=lt==="controller"&&(Z?.allowActions??!0),r=lt==="observer"?"observer":"controller";$e?.setActionGateContext?.({mode:r,controllerRuntimeId:H?.getCurrentHolderRuntimeId(),activeLogicalTabId:H?.getActiveLogicalTabId(),localLogicalTabId:H?.getLocalLogicalTabId(),reason:Xs(r,n)}),(e.allowedDomains||e.domainScopeMode||e.externalNavigationPolicy||e.navigation?.crossHostPolicy)&&$e.setNavigationPolicy({allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy,crossHostPolicy:e.navigation?.crossHostPolicy})}Pe.postMessage({type:"update_config",config:e}),zs(Z),t?cu(Z):go(),e.visitor&&aa(e.visitor),typeof e.openOnInit=="boolean"&&(e.openOnInit?vo():zi())}function la(){Un(),Ne(),$i(!0),Js(),Mt?.markDirty(),Mt?.syncNow(),Mt?.stop(),Mt=null,H?.stop(),H=null,Pe?.terminate(),Pe=null,te?.destroy(),te=null,$e=null,Z=null,tr=!1,Hn=!1,Oe="",kt=void 0,_n=void 0,Jn=!1,gr=!1,wo(),Er=null,Di=!1,ki=!1,Br=!1,Lt=[],Vl=0,lt="controller",qr=null,br=null,Kn=null}function vo(){Jn=!0,wo(),te?.show(),te?.open(),h&&(h.uiHidden=!1,h.uiOpen=!0,Ne())}function zi(){te?.close(),h&&(h.uiOpen=!1,Ne())}function ua(){te?.show(),h&&(h.uiHidden=!1,Ne())}function da(){te?.hide(),h&&(h.uiHidden=!0,h.uiOpen=!1,Ne())}function fa(e){e?.trim()&&ao(e)}function $r(e){if(!h)return;let t=e?.reason||"manual_new_task",n=e?.clearUi!==!1,r=Math.max(1,Number(h.taskEpoch)||1)+1,o=Fn(t);h.pendingRun&&(tn(h.pendingRun.id),Pe?.postMessage({type:"cancel_run",runId:h.pendingRun.id}),H?.releaseWorkflowLock(h.pendingRun.id)),ct&&(clearTimeout(ct),ct=null),te?.setRunning(!1),te?.setQuestionPrompt(void 0),Hn=!1,h.taskEpoch=r,h.activeTask=o,wt(void 0),h.workerState=void 0,n&&(h.uiMessages=[],h.timeline=[],h.uiStatus=void 0,ou()),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),Rt("New task started."),Ne(),Pe?.postMessage({type:"start_new_task",taskId:o.taskId}),Be("task_started",{taskId:o.taskId,reason:t,taskEpoch:r})}function Yi(e){if(!h)return;let t=e?.reason||"manual_end_task",n=Wi("manual_end_task");n&&(n.status="ended",n.endedAt=Date.now(),n.boundaryReason=t,h.pendingRun&&(tn(h.pendingRun.id),Pe?.postMessage({type:"cancel_run",runId:h.pendingRun.id}),H?.releaseWorkflowLock(h.pendingRun.id)),wt(void 0),h.workerState=void 0,ct&&(clearTimeout(ct),ct=null),te?.setRunning(!1),te?.setQuestionPrompt(void 0),Un(),Rt("Task ended. Start a new task to continue."),H?.endTask(t),H?.setActiveRun(void 0),H?.setWorkerContext(void 0),Ne(),at({kind:"info",title:"Task ended",detail:"Start a new task when you are ready.",status:"info"}),Be("task_ended",{taskId:n.taskId,reason:t,endedAt:n.endedAt}))}function pa(){return{mode:lt,runtimeId:Oe,runtimeState:h?iu(h):null,sharedState:H?.getState()||null,pendingTaskSuggestion:qr}}function ha(e,t){let n=Pp(e);if(!Kn||!$e||!Pe){Si.push({def:n,handler:t});return}Kl({def:n,handler:t})}function Rh(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 lu(){let e=window,t=e.rover,n=((r,...o)=>{let i=Rh(r),s=i?n[i]:void 0;if(typeof s=="function")return s(...o)});if(n.boot=bo,n.init=ca,n.update=Bi,n.shutdown=la,n.open=vo,n.close=zi,n.show=ua,n.hide=da,n.send=fa,n.newTask=$r,n.endTask=Yi,n.getState=pa,n.registerTool=ha,n.on=zl,e.rover=n,typeof t=="function"&&Array.isArray(t.q))for(let r of t.q){let[o,...i]=Array.isArray(r)?r:Array.from(r);typeof o=="string"&&n(o,...i)}if(!Kn){let r=typeof globalThis.__ROVER_SCRIPT_EL__<"u"?globalThis.__ROVER_SCRIPT_EL__:null;if(r){let o=r.getAttribute("data-site-id"),i=r.getAttribute("data-api-key");if(o&&i){let s={siteId:o,apiKey:i},a=r.getAttribute("data-allowed-domains");a&&(s.allowedDomains=a.split(",").map(p=>p.trim()).filter(Boolean));let u=r.getAttribute("data-site-key-id");u&&(s.siteKeyId=u);let m=r.getAttribute("data-worker-url");m&&(s.workerUrl=m),bo(s)}}}}lu();return gu(kh);})();
|
|
1655
|
+
`);let n=e.find(r=>r.type==="tool_output"||r.type==="json");if(n)return Array.isArray(n.data)?`Received ${n.data.length} item(s).`:n.data&&typeof n.data=="object"?`Received ${Object.keys(n.data).length} field(s).`:typeof n.data=="string"?n.data:String(n.data??"Done.")}function wh(e){if(e==null)return;let t=e?.output??e?.generatedContentRef??e?.schemaHeaderSheetInfo??e,n=fa(or([{type:"tool_output",data:t}]));if(vh(t,n))return or([{type:"tool_output",label:typeof e?.name=="string"?`${e.name} output`:"Tool output",data:t}])}function yu(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 Yi(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e.slice(-t)){let o=da(r);o!==void 0&&n.push(o)}return n}async function Th(e){if(!Tr)return null;try{return await Tr.readAsync(e)}catch{return null}}function vo(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:Gn("msg"),role:r,text:String(n?.text||""),blocks:or(n?.blocks),ts:Number(n?.ts)||Date.now(),sourceRuntimeId:typeof n?.sourceRuntimeId=="string"?n.sourceRuntimeId:void 0})}return t.filter(n=>!!n.text||!!n.blocks?.length)}function wo(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(-Zs)){let r=Ct(String(n?.title||""),400);if(!r)continue;let o=String(n?.kind||"status"),i=n?.status;t.push({id:typeof n?.id=="string"&&n.id?n.id:Gn("timeline"),kind:o,title:r,detail:n?.detail?String(n.detail):void 0,detailBlocks:or(n?.detailBlocks),status:i==="pending"||i==="success"||i==="error"||i==="info"?i:void 0,ts:Number(n?.ts)||Date.now(),sourceRuntimeId:typeof n?.sourceRuntimeId=="string"?n.sourceRuntimeId:void 0})}return t}function An(e){if(!e||typeof e!="object")return;let t=String(e.taskBoundaryId||"").trim(),n=Array.isArray(e.history)?e.history:[],r=Array.isArray(e.plannerHistory)?e.plannerHistory:[],o=Array.isArray(e.agentPrevSteps)?e.agentPrevSteps:Array.isArray(e.lastToolPreviousSteps)?e.lastToolPreviousSteps:[],i=n.slice(-ru).map(g=>yu(g)).filter(g=>!!g),a=Yi(r,$i),s=Yi(o,$i*2),l=rr(e?.pendingAskUser?.questions),p=e?.pendingAskUser?.stepRef,d=p&&Number.isFinite(Number(p.stepIndex))&&Number(p.stepIndex)>=0&&Number.isFinite(Number(p.functionIndex))&&Number(p.functionIndex)>=0?{stepIndex:Number(p.stepIndex),functionIndex:Number(p.functionIndex),...typeof p.accTreeId=="string"&&p.accTreeId.trim()?{accTreeId:p.accTreeId.trim()}:{}}:void 0,y=l.length?{questions:l,source:e?.pendingAskUser?.source==="planner"?"planner":"act",askedAt:Number(e?.pendingAskUser?.askedAt)||Date.now(),boundaryId:typeof e?.pendingAskUser?.boundaryId=="string"&&e.pendingAskUser.boundaryId.trim()?e.pendingAskUser.boundaryId.trim():void 0,...d?{stepRef:d}:{}}:void 0,I=typeof e.rootUserInput=="string"?e.rootUserInput.trim():"";return{trajectoryId:typeof e.trajectoryId=="string"?e.trajectoryId:void 0,taskBoundaryId:t||void 0,rootUserInput:I||void 0,history:i,plannerHistory:a,agentPrevSteps:s,lastToolPreviousSteps:s,pendingAskUser:y,updatedAt:Number(e.updatedAt)||Date.now()}}function To(e,t,n){if(!e||typeof e!="object")return ea(t,n);let r=zn(),o=So(e.activeTask,r),i=an(e.pendingRun),a=o.status==="running"?i:void 0;return{version:ra,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"?Ct(e.uiStatus,300):void 0,uiMessages:vo(e.uiMessages),timeline:wo(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:An(e.workerState),pendingRun:a,lastNavigationHandoff:zr(e.lastNavigationHandoff),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"?Ct(e.lastRoutingDecision.reason,200):void 0,ts:Number(e.lastRoutingDecision.ts)||Date.now()}:void 0,updatedAt:Number(e.updatedAt)||Date.now()}}function So(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"?Ct(e.boundaryReason,120):t.boundaryReason,endedAt:Number(e.endedAt)||void 0}}function _h(e,t){return So(e,t)}function Eu(e){if(!e)return;let t=rr(e.pendingAskUser?.questions);return{trajectoryId:e.trajectoryId,taskBoundaryId:typeof e.taskBoundaryId=="string"?e.taskBoundaryId:void 0,rootUserInput:typeof e.rootUserInput=="string"?e.rootUserInput:void 0,history:Array.isArray(e.history)?e.history.slice(-ru).map(n=>yu(n)).filter(n=>!!n):[],plannerHistory:Yi(e.plannerHistory,$i),agentPrevSteps:Yi(e.agentPrevSteps,$i*2),pendingAskUser:t.length?{questions:t,source:e.pendingAskUser?.source==="planner"?"planner":"act",askedAt:Number(e.pendingAskUser?.askedAt)||Date.now(),boundaryId:typeof e.pendingAskUser?.boundaryId=="string"&&e.pendingAskUser.boundaryId.trim()?e.pendingAskUser.boundaryId.trim():void 0,...e.pendingAskUser?.stepRef&&Number.isFinite(Number(e.pendingAskUser.stepRef.stepIndex))&&Number(e.pendingAskUser.stepRef.stepIndex)>=0&&Number.isFinite(Number(e.pendingAskUser.stepRef.functionIndex))&&Number(e.pendingAskUser.stepRef.functionIndex)>=0?{stepRef:{stepIndex:Number(e.pendingAskUser.stepRef.stepIndex),functionIndex:Number(e.pendingAskUser.stepRef.functionIndex),...typeof e.pendingAskUser.stepRef.accTreeId=="string"&&e.pendingAskUser.stepRef.accTreeId.trim()?{accTreeId:e.pendingAskUser.stepRef.accTreeId.trim()}:{}}}:{}}:void 0,updatedAt:Number(e.updatedAt)||Date.now()}}function an(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():"",r=typeof e.taskBoundaryId=="string"&&e.taskBoundaryId.trim()?e.taskBoundaryId.trim():void 0;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,taskBoundaryId:r,resumeRequired:e.resumeRequired===!0,resumeReason:e.resumeReason==="cross_host_navigation"||e.resumeReason==="agent_navigation"||e.resumeReason==="handoff"||e.resumeReason==="page_reload"?e.resumeReason:void 0}}function Re(){if(!(!f||!$r))try{f.updatedAt=Date.now(),Tr?.write($r,f),zi||Ot?.markDirty()}catch{}}function xh(){if(Xl)return;Xl=!0;let e=()=>{if(f?.pendingRun?.autoResume){let r=f.pendingRun.resumeReason||(yo?"agent_navigation":"page_reload"),o=an({...f.pendingRun,resumeRequired:!0,resumeReason:r});f.pendingRun=o,o&&P?.clearActiveRunRuntimeId(o.id)}let n=oa();P?.broadcastClosing(au(n)),f?.pendingRun&&P?.releaseWorkflowLock(f.pendingRun.id),Re(),f?.pendingRun&&Z?.siteId&&Xs(Z.siteId,{sessionId:f.sessionId,pendingRun:{id:f.pendingRun.id,text:f.pendingRun.text,startedAt:f.pendingRun.startedAt,attempts:f.pendingRun.attempts,taskBoundaryId:f.pendingRun.taskBoundaryId||ke},handoff:n?{handoffId:n.handoffId,sourceLogicalTabId:n.sourceLogicalTabId,runId:n.runId,targetUrl:n.targetUrl,createdAt:n.createdAt}:void 0,activeTask:f.activeTask?{taskId:f.activeTask.taskId,status:f.activeTask.status}:void 0,taskEpoch:f.taskEpoch,timestamp:Date.now()}),ts(!0),la(),Ot?.markDirty(),Ot?.syncNow(),Ot?.stop(),P?.stop()};window.addEventListener("pagehide",e,{capture:!0});let t=n=>{n.persisted&&(P&&(P.reloadFromStorage(),P.registerCurrentTab(window.location.href,document.title||void 0),P.claimLease(!1)),Vn=!1,Z&&ua(Z))};window.addEventListener("pageshow",t)}function Ao(e="implicit"){if(f)return f.activeTask||(f.activeTask=zn(e),f.taskEpoch=Math.max(1,Number(f.taskEpoch)||1)),f.activeTask}function Ih(e,t=Date.now()){if(!f||e==="system")return;let n=Ao("implicit");n&&n.status==="running"&&(e==="user"&&(n.lastUserAt=t),e==="assistant"&&(n.lastAssistantAt=t))}function qi(e="worker_task_active",t=Date.now()){if(!f)return;let n=Ao(e);n&&(n.status="running",n.endedAt=void 0,n.boundaryReason=e,!n.lastUserAt&&!n.lastAssistantAt&&(n.lastAssistantAt=t),P?.syncTask({...n},f.taskEpoch),Re())}function Qs(e="worker_task_complete",t=Date.now()){if(!f)return;let n=Ao(e);n&&(n.status="completed",n.endedAt=t,n.boundaryReason=e,P?.syncTask({...n},f.taskEpoch),Re())}function Sn(){Vr=null,ee?.setTaskSuggestion({visible:!1})}function kh(e){Vr={kind:"resume_run",runId:e.id,text:e.text,createdAt:Date.now()},ee?.setTaskSuggestion({visible:!0,text:"Previous task was interrupted by navigation. Resume it?",primaryLabel:"Resume",secondaryLabel:"Start fresh"}),st("Task paused after navigation. Resume to continue.")}function vu(){ee?.clearMessages(),ee?.clearTimeline(),ee?.setQuestionPrompt(void 0),Sn()}function _o(){let e=rr(f?.workerState?.pendingAskUser?.questions);if(!e.length){ee?.setQuestionPrompt(void 0);return}ee?.setQuestionPrompt({questions:e})}function Rh(){let e=f?.pendingRun;if(!e)return!1;if(!P)return!0;let t=P?.getState()?.activeRun;if(t?.runId&&t.runId===e.id||t?.runtimeId&&t.runtimeId!==qe)return!0;let n=Date.now()-Number(e.startedAt||0);return n>=0&&n<=Wp}function Sh(){if(!f?.pendingRun||Rh()||!P)return;let e=f.pendingRun,t=Date.now()-Number(e.startedAt||0);!Number.isFinite(t)||t<Vp||(sn(e.id),mt(void 0),P?.clearActiveRunRuntimeId(e.id),P?.releaseWorkflowLock(e.id),P?.setActiveRun(void 0))}function yn(e,t,n=!0,r){let o=String(t||""),i=or(r?.blocks);if(!o&&(!i||i.length===0))return;let a={id:r?.id||Gn("msg"),role:e,text:o,blocks:i,ts:r?.ts||Date.now(),sourceRuntimeId:r?.sourceRuntimeId};return ee?.addMessage(a.role,a.text,{blocks:a.blocks}),f&&n&&(f.uiMessages.push(a),f.uiMessages.length>Js&&(f.uiMessages=f.uiMessages.slice(-Js)),Ih(a.role,a.ts),Re()),P&&r?.publishShared!==!1&&(P.appendMessage({id:a.id,role:a.role,text:a.text,blocks:a.blocks,ts:a.ts}),P.markTaskActivity(a.role,a.ts)),a}function pa(e){for(let t of e)yn(t.role,t.text,!1,{id:t.id,ts:t.ts,sourceRuntimeId:t.sourceRuntimeId,publishShared:!1,blocks:t.blocks})}function et(e,t=!0){let n={id:e.id||Gn("timeline"),kind:e.kind,title:Ct(e.title,400),detail:e.detail?String(e.detail):void 0,detailBlocks:or(e.detailBlocks),status:e.status,ts:e.ts||Date.now(),sourceRuntimeId:e.sourceRuntimeId};return ee?.addTimelineEvent(n),f&&t&&(f.timeline.push(n),f.timeline.length>Zs&&(f.timeline=f.timeline.slice(-Zs)),Re()),P&&e.publishShared!==!1&&P.appendTimeline({id:n.id,kind:n.kind,title:n.title,detail:n.detail,detailBlocks:n.detailBlocks,status:n.status,ts:n.ts}),n}function ha(e){ee?.clearTimeline();for(let t of e)et({id:t.id,kind:t.kind,title:t.title,detail:t.detail,detailBlocks:t.detailBlocks,status:t.status,ts:t.ts,sourceRuntimeId:t.sourceRuntimeId,publishShared:!1},!1)}function st(e,t){ee?.setStatus(e),f&&(f.uiStatus=Ct(e,300),Re()),P&&t?.publishShared!==!1&&P.setStatus(e)}function xo(e,t){dt=e,f&&(f.executionMode=e,Re()),ee?.setExecutionMode(e,{controllerRuntimeId:t?.holderRuntimeId??P?.getCurrentHolderRuntimeId(),localLogicalTabId:t?.localLogicalTabId??P?.getLocalLogicalTabId(),activeLogicalTabId:t?.activeLogicalTabId??P?.getActiveLogicalTabId(),canTakeControl:!0,canComposeInObserver:gu(),note:bu(e)}),$e("mode_change",{mode:e,...t})}function mt(e){f&&(e?f.pendingRun=an({...e,taskBoundaryId:e.taskBoundaryId||ke}):f.pendingRun=void 0,Re())}function tu(e){f&&(f.lastNavigationHandoff=zr(e),Re())}function Xi(e,t){let n=String(e||"").trim();if(!n||!Se)return;if(dt==="observer"&&!(P?.requestControl()??!1)){yn("system","Unable to take control right now because another tab is still running Rover actions.",!0),et({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,i=t?.appendUserMessage!==!1;hu(r),i&&yn("user",n,!0);let a=f?.pendingRun?.id===r?f.pendingRun.attempts:0,s=f?.pendingRun?.id===r&&f.pendingRun.taskBoundaryId||ke;yo=!1,mt({id:r,text:n,startedAt:Date.now(),attempts:o?a+1:0,autoResume:t?.autoResume!==!1,taskBoundaryId:s,resumeRequired:!1,resumeReason:void 0}),qi(o?"worker_task_resumed":"worker_task_active"),iu=n,P?.acquireWorkflowLock(r),P?.setActiveRun({runId:r,text:n}),Se.postMessage({type:"run",text:n,runId:r,resume:o,routing:t?.routing,askUserAnswers:t?.askUserAnswers}),je&&clearTimeout(je);let l=r;je=setTimeout(()=>{f?.pendingRun?.id===l&&(sn(l),mt(void 0),P?.releaseWorkflowLock(l),P?.setActiveRun(void 0),st("Task timed out."),yn("system","Task timed out after 5 minutes with no response.",!0),$e("error",{message:"Run safety timeout"})),je=null},5*6e4)}function mo(e,t){let n=bh(e,t?.askUserAnswers);if(!n)return;Sh();let r=f?.activeTask?.status,o=!!t?.startNewTask||Vl(r);if(P?.pruneTabs(o?{dropRuntimeDetached:!0,keepOnlyActiveLiveTab:!0,keepRecentExternalPlaceholders:!0}:{dropRuntimeDetached:!0}),o){let i=t?.reason||(r==="completed"?"auto_after_task_complete":"auto_after_task_end");Gr({reason:i,clearUi:!0})}Sn(),Xi(n,{appendUserMessage:!0,resume:!1,autoResume:!0,routing:t?.routing,askUserAnswers:t?.askUserAnswers})}function Ki(){if(dt==="observer")return;let e=P?.getState()?.activeRun;if(e?.runtimeId&&e.runtimeId!==qe&&!(f?.pendingRun?.id===e.runId)||!Cn||!Se||Vn||!f?.pendingRun||!Gl(f.activeTask?.status))return;let t=f.pendingRun;if(!t.autoResume)return;let n=aa(Z?.task?.autoResumePolicy);if(n==="never"){sn(t.id),mt(void 0),P?.setActiveRun(void 0),st("Previous task dismissed after navigation.");return}let r=t.resumeReason==="cross_host_navigation"||t.resumeReason==="agent_navigation",o=Z?.siteId||"";if(!!!sessionStorage.getItem(`rover:tab-alive:${o}`)&&!r&&!(P?.listTabs()||[]).some(p=>p.runtimeId!==qe&&p.updatedAt>Date.now()-2*2e3)&&f?.pendingRun){sn(f.pendingRun.id),mt(void 0),st("Previous task expired.");return}if(Date.now()-t.startedAt>Hp){sn(t.id),mt(void 0),st("Previous task expired after navigation.");return}if(t.attempts>=Fp){sn(t.id),mt(void 0),yn("system","Auto-resume stopped after too many navigation attempts.",!0);return}if(r){Vn=!0,st("Resuming task after navigation..."),Xi(t.text,{runId:t.id,resume:!0,appendUserMessage:!1,autoResume:!0});return}if(n==="confirm"){Vn=!0,kh(t);return}Vn=!0,st("Resuming previous task after navigation..."),Xi(t.text,{runId:t.id,resume:!0,appendUserMessage:!1,autoResume:!0})}async function Ah(e){if(!f)return;let t=await Th(e);if(!t||!f)return;let n=Number(f.updatedAt)||0,r=To({...t,sessionId:f.sessionId,runtimeId:qe},f.sessionId,qe);if((Number(r.updatedAt)||0)<=n+200)return;let i=Math.max(1,Number(f.taskEpoch)||1),a=Math.max(1,Number(r.taskEpoch)||1),s=Zi(r);wr({source:"indexeddb_checkpoint",incomingBoundaryId:s,taskEpochAdvanced:a>i,allowBootstrapAdoption:!0})&&(f=To({...f,...r,sessionId:f.sessionId,runtimeId:qe},f.sessionId,qe),Eo({rotateIfMissing:!ke}),Re(),ee&&(ee.clearMessages(),pa(f.uiMessages),ha(f.timeline),f.uiStatus&&ee.setStatus(f.uiStatus),_o(),f.uiHidden?ee.hide():(ee.show(),f.uiOpen?ee.open():ee.close())),Cn&&Se&&Se.postMessage({type:"update_config",config:{taskBoundaryId:ke}}),Cn&&Se&&f.workerState&&dt==="controller"&&(Se.postMessage({type:"hydrate_state",state:f.workerState}),$e("context_restored",{source:"indexeddb_checkpoint",ts:Date.now()})))}function ma(e,t){if(f){if(t==="remote"){let n=Math.max(1,Number(f.taskEpoch)||1),r=Math.max(1,Number(e.taskEpoch)||1),o=r>n;f.taskEpoch=Math.max(n,r);let i=f.activeTask||zn("shared_sync");f.activeTask=_h(e.task,i),o&&(f.uiMessages=[],f.timeline=[],vu(),mt(void 0),f.workerState=void 0,ke=xr(),Se?.postMessage({type:"update_config",config:{taskBoundaryId:ke}}),Sn());let a=vo(e.uiMessages),s=new Set(a.map(_=>_.id));if(a.length<f.uiMessages.length||f.uiMessages.some(_=>!s.has(_.id)))f.uiMessages=a,ee?.clearMessages(),pa(f.uiMessages);else{let _=new Set(f.uiMessages.map(x=>x.id));for(let x of a)_.has(x.id)||(yn(x.role,x.text,!0,{id:x.id,ts:x.ts,sourceRuntimeId:x.sourceRuntimeId,publishShared:!1,blocks:x.blocks}),_.add(x.id))}let p=wo(e.timeline),d=new Set(p.map(_=>_.id));if(p.length<f.timeline.length||f.timeline.some(_=>!d.has(_.id)))f.timeline=p,ha(f.timeline);else{let _=new Set(f.timeline.map(x=>x.id));for(let x of p)_.has(x.id)||(et({id:x.id,kind:x.kind,title:x.title,detail:x.detail,detailBlocks:x.detailBlocks,status:x.status,ts:x.ts,sourceRuntimeId:x.sourceRuntimeId,publishShared:!1},!0),_.add(x.id))}typeof e.uiStatus=="string"&&st(e.uiStatus,{publishShared:!1});let I=f.activeTask?.status,g=e.task?.status;if(e.activeRun&&e.activeRun.runtimeId!==qe&&!Ks({localTaskStatus:I,remoteTaskStatus:g,mode:dt,hasRemoteActiveRun:!0})?mt(an({id:e.activeRun.runId,text:e.activeRun.text,startedAt:e.activeRun.startedAt,attempts:f.pendingRun?.attempts||0,autoResume:!0,resumeReason:f.pendingRun?.resumeReason})):Ks({localTaskStatus:I,remoteTaskStatus:g,mode:dt,hasRemoteActiveRun:!!e.activeRun})&&(f.pendingRun?.id&&sn(f.pendingRun.id),mt(void 0)),dt==="observer"&&xo("observer",{localLogicalTabId:P?.getLocalLogicalTabId(),activeLogicalTabId:P?.getActiveLogicalTabId(),holderRuntimeId:P?.getCurrentHolderRuntimeId()}),e.workerContext){let _=An(e.workerContext),x=Number(f.workerState?.updatedAt)||0,B=Number(_?.updatedAt)||0;_&&B>x+100&&wr({source:"shared_worker_context",incomingBoundaryId:_.taskBoundaryId,taskEpochAdvanced:o,allowBootstrapAdoption:!0})&&(f.workerState=_,Eo(),Cn&&Se&&dt==="controller"&&(Se.postMessage({type:"update_config",config:{taskBoundaryId:ke}}),Se.postMessage({type:"hydrate_state",state:_}),$e("context_restored",{source:"shared_session",ts:Date.now()})))}}f.uiMessages=vo(f.uiMessages),f.timeline=wo(f.timeline),f.workerState=An(f.workerState),Eo(),_o(),f.activeTask=So(f.activeTask,zn("implicit")),Re()}}function wu(e){let t=zn("checkpoint_clone");return{version:ra,sessionId:e.sessionId,runtimeId:e.runtimeId,uiOpen:!!e.uiOpen,uiHidden:!!e.uiHidden,uiStatus:typeof e.uiStatus=="string"?Ct(e.uiStatus,300):void 0,uiMessages:vo(e.uiMessages),timeline:wo(e.timeline),executionMode:e.executionMode==="observer"||e.executionMode==="controller"?e.executionMode:"controller",workerState:An(e.workerState),pendingRun:an(e.pendingRun),lastNavigationHandoff:zr(e.lastNavigationHandoff),taskEpoch:Math.max(1,Number(e.taskEpoch)||1),activeTask:So(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 Ch(e){return!(e.sessionScope==="tab"||e.checkpointing?.enabled!==!0||!(e.apiKey||e.authToken)||!kt)}function Nh(){if(!f||!Z||!kt)return null;let e=P?.getState(),t=wu(f),n=Math.max(Number(e?.updatedAt||0),Number(t.updatedAt||0),Date.now());return{version:$p,siteId:Z.siteId,visitorId:kt,sessionId:f.sessionId,updatedAt:n,sharedState:e,runtimeState:t}}function Lh(e){if(!e||typeof e!="object"||!f||!Z||e.siteId&&e.siteId!==Z.siteId||kt&&e.visitorId&&e.visitorId!==kt)return;let t=typeof e.sessionId=="string"&&e.sessionId.trim()?e.sessionId.trim():f.sessionId;zi=!0;try{if(t&&f.sessionId!==t&&(f.sessionId=t,Z={...Z,sessionId:t},Qi(Z),Se?.postMessage({type:"update_config",config:{sessionId:t,taskBoundaryId:ke}})),e.sharedState&&P&&P.hydrateExternalState(e.sharedState)&&(ma(P.getState(),"remote"),xo(P.getRole(),{localLogicalTabId:P.getLocalLogicalTabId(),activeLogicalTabId:P.getActiveLogicalTabId(),holderRuntimeId:P.getCurrentHolderRuntimeId()})),e.runtimeState&&typeof e.runtimeState=="object"){let n=To({...e.runtimeState,sessionId:t,runtimeId:qe},t,qe),r=Number(f.updatedAt)||0;if((Number(n.updatedAt)||0)>r+200){let i=Math.max(1,Number(f.taskEpoch)||1),a=Math.max(1,Number(n.taskEpoch)||1),s=Zi(n);if(!wr({source:"cloud_checkpoint",incomingBoundaryId:s,taskEpochAdvanced:a>i,allowBootstrapAdoption:!0}))return;f=To({...f,...n,sessionId:t,runtimeId:qe},t,qe),Eo(),Re(),f.uiStatus&&ee?.setStatus(f.uiStatus),f.uiHidden?ee?.hide():(ee?.show(),f.uiOpen?ee?.open():ee?.close()),Cn&&Se?.postMessage({type:"update_config",config:{taskBoundaryId:ke}}),Cn&&f.workerState&&(Se?.postMessage({type:"hydrate_state",state:f.workerState}),$e("context_restored",{source:"cloud_checkpoint",ts:Date.now()})),dt==="controller"&&Ki()}}}finally{zi=!1}}function Tu(e){if(Ot?.stop(),Ot=null,!!Ch(e)&&kt)try{let t=n=>{$e("checkpoint_state",n),e.checkpointing?.onStateChange?.(n)};Ot=new Ai({apiBase:e.apiBase,apiKey:e.apiKey,authToken:e.authToken,siteId:e.siteId,visitorId:kt,ttlHours:e.checkpointing?.ttlHours??1,flushIntervalMs:e.checkpointing?.flushIntervalMs,pullIntervalMs:e.checkpointing?.pullIntervalMs,minFlushIntervalMs:e.checkpointing?.minFlushIntervalMs,shouldWrite:()=>dt==="controller",buildCheckpoint:()=>Nh(),onCheckpoint:n=>{Lh(n)},onStateChange:(n,r)=>{t({state:n,reason:r.reason,action:r.action,code:r.code,message:r.message}),n==="paused_auth"&&$e("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||$e("checkpoint_error",{action:r.action,code:r.code,message:r.message,status:r.status,disabled:!1,reason:"transient_failure"})}}),Ot.start(),Ot.markDirty()}catch{Ot=null}}function Qi(e){if(!f)return;if(P?.stop(),P=null,e.sessionScope==="tab"){xo("controller");return}P=new Ri({siteId:e.siteId,sessionId:f.sessionId,runtimeId:qe,leaseMs:e.tabPolicy?.actionLeaseMs,onRoleChange:(n,r)=>{xo(n,r);let o=n==="controller"&&(Z?.allowActions??!0);if(Ge?.setAllowActions(o),Ge?.setActionGateContext?.({mode:n,controllerRuntimeId:r?.holderRuntimeId??P?.getCurrentHolderRuntimeId(),activeLogicalTabId:r?.activeLogicalTabId??P?.getActiveLogicalTabId(),localLogicalTabId:r?.localLogicalTabId??P?.getLocalLogicalTabId(),reason:sa(n,o)}),n==="controller"){let i=P?.getWorkerContext();if(i){let a=An(i),s=Number(f?.workerState?.updatedAt)||0,l=Number(a?.updatedAt)||0;a&&l>s+100&&wr({source:"controller_handoff",incomingBoundaryId:a.taskBoundaryId,allowBootstrapAdoption:!0})&&(f&&(f.workerState=a,Eo(),Re()),Cn&&Se&&(Se.postMessage({type:"update_config",config:{taskBoundaryId:ke}}),Se.postMessage({type:"hydrate_state",state:a}),$e("context_restored",{source:"controller_handoff",ts:Date.now()})))}Ki()}},onStateChange:(n,r)=>{ma(n,r)},onSwitchRequested:n=>{n>0&&(No(),et({kind:"status",title:`Switched to tab #${n}`,status:"info"}))}});let t=oa();P.start(au(t)),f?.lastNavigationHandoff&&t&&(f.lastNavigationHandoff=zr({...f.lastNavigationHandoff,consumed:!0}),Re()),P.setRpcRequestHandler(async n=>{if(!Ge)throw new Error("Bridge not available");if(n.method==="getPageData")return Ge.getPageData(n.params);if(n.method==="executeTool")return Ge.executeTool(n.params.call,n.params.payload);throw new Error(`Unknown RPC method: ${n.method}`)}),f?.activeTask&&P.syncTask({...f.activeTask,taskId:f.activeTask.taskId},f.taskEpoch),f?.workerState&&P.setWorkerContext(Eu(f.workerState))}function Mh(e){let t=Ct(yh(e)||"Done.",1200);ee?.clearTimeline(),f&&(f.timeline=[]),P?.clearTimeline()}function Dh(e){if(!(!e||typeof e!="object")&&!gh(e)){if(e.type==="assistant"){let t=or(e.blocks),n=String(e.text||fa(t)||"");if(typeof e.runId=="string"&&e.runId&&(Wn.set(e.runId,n),Wn.size>80)){let r=Wn.keys().next().value;r&&Wn.delete(r)}yn("assistant",n,!0,{blocks:t}),et({kind:"tool_result",title:"Assistant update",detail:n,detailBlocks:t,status:"success"});return}if(e.type==="status"){let t=dh(e.stage),n=e.message?String(e.message):void 0,r=e.compactThought?String(e.compactThought):void 0,o=ph(n,t,r);if(n&&st(n),o&&o!==Ni&&(Ni=o,n)){let i=!!(e.thought||r),a=r||(e.thought?String(e.thought):"");if(i&&t!=="analyze"&&t!=="route"&&t!=="complete"&&!hh(a,iu))et({kind:"thought",title:a,detail:e.thought?String(e.thought):r,status:"pending"});else{let l=t?`${fh(t)}: ${n}`:n;et({kind:"status",title:l,detail:r||(e.thought?String(e.thought):void 0),status:t==="complete"?"success":"info"})}}$e("status",e);return}if(e.type==="tool_start"){et({kind:"tool_start",title:`Running ${e.call?.name||"tool"}`,detail:Fi(e.call?.args),status:"pending"}),$e("tool_start",e);return}if(e.type==="tool_result"){let t=or(e.detailBlocks)||wh(e.result);et({kind:"tool_result",title:`${e.call?.name||"tool"} completed`,detail:Fi(e.result),detailBlocks:t,status:e?.result?.success===!1?"error":"success"}),$e("tool_result",e);return}if(e.type==="auth_required"){$e("auth_required",e.error),e.error?.message&&(yn("system",`Auth required: ${e.error.message}`,!0),et({kind:"error",title:"Auth required",detail:String(e.error.message),status:"error"}));return}if(e.type==="navigation_guardrail"){$e("navigation_guardrail",e),et({kind:"status",title:"Navigation guardrail",detail:Fi(e),status:"info"});return}if(e.type==="error"){yn("system",`Error: ${e.message||"unknown"}`,!0),et({kind:"error",title:"Execution error",detail:String(e.message||"unknown"),status:"error"}),$e("error",e);return}if(e.type==="state_snapshot"){if(f){let t=An({...e.state||{},updatedAt:Date.now()});if(!t||!wr({source:"worker_snapshot",incomingBoundaryId:t.taskBoundaryId,allowBootstrapAdoption:!0}))return;f.workerState=t;let n=typeof e?.activeRun?.runId=="string"&&e.activeRun.runId?e.activeRun.runId:void 0,r=typeof e?.activeRun?.text=="string"?e.activeRun.text:void 0,o=zl({taskStatus:f.activeTask?.status,hasPendingRun:!!f.pendingRun,activeRunId:n,activeRunText:r,ignoredRunIds:tr});o&&(f.pendingRun=an({id:n,text:r,startedAt:e.activeRun.startedAt,attempts:0,autoResume:!0})),n&&r&&o?P?.setActiveRun({runId:n,text:r}):n&&(!ho()||tr.has(n))&&P?.setActiveRun(void 0),!ho()&&f.pendingRun&&mt(void 0),f.workerState&&P?.setWorkerContext(Eu(f.workerState)),_o(),Re()}return}if(e.type==="task_started"){$e("task_started",{taskId:e.taskId,reason:"worker"});return}if(e.type==="run_started"){if(Ni="",Sn(),typeof e.runId=="string"&&e.runId&&Wn.delete(e.runId),!ho()){P?.setActiveRun(void 0);return}let t=f?.pendingRun,n=typeof e?.taskBoundaryId=="string"?on(e.taskBoundaryId):void 0;typeof e.runId=="string"&&e.runId&&hu(e.runId),mt(an({id:e.runId,text:e.text,startedAt:t?.startedAt||Date.now(),attempts:t?.attempts||0,autoResume:t?.autoResume!==!1,taskBoundaryId:n||t?.taskBoundaryId||ke,resumeReason:t?.resumeReason,resumeRequired:t?.resumeRequired})),P?.setActiveRun({runId:e.runId,text:String(e.text||"")}),ee?.setRunning(!0),ee?.setQuestionPrompt(void 0);let r=`run:${String(e.runId||"")}:start`;f?.timeline.some(o=>o.id===r)||et({id:r,kind:"plan",title:e.resume?"Run resumed":"Run started",detail:String(e.text||""),status:"pending"});return}if(e.type==="run_completed"){Ni="",Vn=!1,ee?.setRunning(!1),je&&(clearTimeout(je),je=null),f?.pendingRun?.id===e.runId&&mt(void 0),typeof e.runId=="string"&&e.runId&&P?.releaseWorkflowLock(e.runId),f&&e?.route&&(e.route.mode==="act"||e.route.mode==="planner")&&(f.lastRoutingDecision={mode:e.route.mode,score:Number(e.route.score)||void 0,reason:typeof e.route.reason=="string"?Ct(e.route.reason,200):void 0,ts:Date.now()},Re()),P?.setActiveRun(void 0);let t=typeof e.runId=="string"&&e.runId?e.runId:void 0;if(t&&sn(t),!e.ok&&e.error){if(t&&Wn.delete(t),!ho())return;let n=Zl(e);ee?.setQuestionPrompt(void 0),n.contextResetRecommended?(Qs("worker_run_failed_terminal"),P?.resetTabsToCurrent(window.location.href,document.title||void 0),st(`Task failed: ${String(e.error)}. Start a new task to continue.`)):(qi("worker_run_failed"),st(`Task failed: ${String(e.error)}`)),t&&Wn.delete(t),et({kind:"error",title:"Run failed",detail:String(e.error),status:"error"})}else if(e.ok){if(!ho())return;let n=Zl(e),r=n.taskComplete,o=n.needsUserInput,i=n.terminalState,a=n.questions||rr(e.questions),s=rr(f?.workerState?.pendingAskUser?.questions),l=a.length?a:o?s:[];i==="failed"?(ee?.setQuestionPrompt(void 0),n.contextResetRecommended?(Qs("worker_run_failed_terminal"),P?.resetTabsToCurrent(window.location.href,document.title||void 0),st("Task failed. Start a new task to continue.")):(qi("worker_run_failed"),st("Task failed.")),et({kind:"error",title:"Run failed",detail:typeof e.error=="string"?e.error:"Run reported failure state.",status:"error"})):r||i==="completed"?(ee?.setQuestionPrompt(void 0),Qs("worker_task_complete"),P?.resetTabsToCurrent(window.location.href,document.title||void 0),st("Task completed"),Mh(typeof e.runId=="string"?e.runId:void 0)):(qi(o?"worker_waiting_for_input":i==="in_progress"?"worker_continuation":"worker_task_active"),o&&l.length>0?ee?.setQuestionPrompt({questions:l}):o?_o():ee?.setQuestionPrompt(void 0),st(o?"Need more input to continue":"Execution finished. Continue when ready."),et({kind:"status",title:o?"Waiting for your input":"Continuation available",detail:o?l.length?`Please answer: ${l.map(d=>`${d.key} (${d.query})`).join("; ")}`:"Planner requested more information before marking the task complete.":"Task is still active and will continue with your next message.",status:"info"}))}return}if(e.type==="ready"){Cn=!0,st("ready"),$e("ready"),Z&&xu(Z);let t=P?.getWorkerContext(),n=An(t),r=n&&wr({source:"ready_hydrate",incomingBoundaryId:n.taskBoundaryId,allowBootstrapAdoption:!0})?n:void 0,o=An(f?.workerState),i=o&&wr({source:"ready_hydrate",incomingBoundaryId:o.taskBoundaryId,allowBootstrapAdoption:!0})?o:void 0,a=Number(i?.updatedAt)||0,s=Number(r?.updatedAt)||0,l=r&&s>a+100?r:i;f&&(l&&l!==f.workerState?(f.workerState=l,Re()):!l&&f.workerState&&(f.workerState=void 0,Re())),l?(Se?.postMessage({type:"hydrate_state",state:l}),$e("context_restored",{source:"runtime_start",ts:Date.now()})):Ki();return}if(e.type==="hydrated"){Ki();return}e.type==="updated"&&$e("updated")}}function ta(e,t){let n=Number(e);return Number.isFinite(n)?Math.max(t.min,Math.min(t.max,Math.floor(n))):t.fallback}function ga(e){if(!e||typeof e!="object")return;let t=ta(e.shortcutMaxStored,{min:1,max:Vi,fallback:Vi}),n=ta(e.shortcutMaxRendered,{min:1,max:Gi,fallback:Gi});return{shortcutMaxStored:t,shortcutMaxRendered:n}}function Co(){go&&(clearTimeout(go),go=null),bo&&(clearTimeout(bo),bo=null)}function Oh(e){try{let t=localStorage.getItem(`rover:site-config:${e}`);if(t){let n=JSON.parse(t);return!n||typeof n.ts!="number"||typeof n.data!="object"||!n.data||Date.now()-n.ts>Yl?null:{shortcuts:Ir(n.data.shortcuts),greeting:Io(n.data.greeting),limits:ga(n.data.limits),version:typeof n.version=="string"?n.version:void 0}}}catch{}try{let t=localStorage.getItem(`rover:shortcuts:${e}`);if(!t)return null;let n=JSON.parse(t);return!n||typeof n.ts!="number"||!Array.isArray(n.data)||Date.now()-n.ts>Yl?null:{shortcuts:Ir(n.data)}}catch{return null}}function Uh(e,t){try{localStorage.setItem(`rover:site-config:${e}`,JSON.stringify({ts:Date.now(),version:t.version,data:{shortcuts:Ir(t.shortcuts),greeting:Io(t.greeting),limits:ga(t.limits)}}))}catch{}}function Io(e){if(!e||typeof e!="object")return;let t={},n=String(e.text||"").trim();n&&(t.text=n.slice(0,Qp));let r=Number(e.delay);Number.isFinite(r)&&(t.delay=Math.max(0,Math.min(6e4,Math.floor(r))));let o=Number(e.duration);return Number.isFinite(o)&&(t.duration=Math.max(1200,Math.min(6e4,Math.floor(o)))),typeof e.disabled=="boolean"&&(t.disabled=e.disabled),Object.keys(t).length?t:void 0}function Ph(e){if(!e||typeof e!="object")return null;let t=String(e.id||"").trim().slice(0,80),n=String(e.label||"").trim().slice(0,jp),r=String(e.prompt||"").trim().slice(0,Xp);if(!t||!n||!r)return null;let o={id:t,label:n,prompt:r,enabled:e.enabled!==!1};e.description&&(o.description=String(e.description).trim().slice(0,Yp)),e.icon&&(o.icon=String(e.icon).trim().slice(0,Kp)),(e.routing==="auto"||e.routing==="act"||e.routing==="planner")&&(o.routing=e.routing);let i=Number(e.order);return Number.isFinite(i)&&(o.order=Math.trunc(i)),o}function Ir(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let r of e){if(t.length>=Vi)break;let o=Ph(r);!o||n.has(o.id)||(n.add(o.id),t.push(o))}return t}function Bh(e){return e.map((t,n)=>({item:t,index:n})).sort((t,n)=>{let r=Number.isFinite(t.item.order),o=Number.isFinite(n.item.order);return r&&o?Number(t.item.order)-Number(n.item.order):r?-1:o?1:t.index-n.index}).map(t=>t.item)}function Hh(e,t){let n=new Map;for(let r of t)n.set(r.id,r);for(let r of e){let o=n.get(r.id);n.set(r.id,o?{...o,...r}:r)}return Bh(Array.from(n.values())).slice(0,Vi)}function _u(e){let t=ta(_r?.limits?.shortcutMaxRendered,{min:1,max:Gi,fallback:Gi});return e.filter(n=>n.enabled!==!1).slice(0,t)}function ns(e){if(!e)return;let t=Io(_r?.greeting),n=Io(e.ui?.greeting);if(!(!t&&!n))return{...t||{},...n||{}}}function ba(e){let t=Rn?.name,n=e?.text;return n?n.replace(/\{name\}/g,t||"").trim()||(t?`Hey ${t}! Need any help?`:"Hey! Need any help?"):t?`Hey ${t}! Need any help?`:"Hey! Need any help?"}function ko(){if(nr||!ee||!Z||f?.uiOpen)return;let e=ns(Z);if(e?.disabled===!0)return;let t=`rover:greeting-shown:${Z.siteId}`;try{if(sessionStorage.getItem(t)){vr=!0;return}}catch{}if(vr)return;Co();let n=e?.delay??3e3,r=e?.duration??8e3,o=ba(e);go=setTimeout(()=>{if(go=null,!(nr||f?.uiOpen)){ee?.showGreeting(o),vr=!0;try{sessionStorage.setItem(t,"1")}catch{}bo=setTimeout(()=>{bo=null,ee?.dismissGreeting()},r)}},n)}function na(e){let t=Ir(e.ui?.shortcuts||[]),n=Ir(_r?.shortcuts||[]),r=Hh(t,n);ee?.setShortcuts(_u(r))}async function Fh(e){let t=String(e.authToken||e.apiKey||"").trim();if(!t)return null;let n=await fetch(pu(e.apiBase),{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({action:"roverGetSiteConfig",data:{siteId:e.siteId,siteKeyId:e.siteKeyId}})});if(!n.ok)return null;let r=await n.json();if(!r?.success)return null;let o=r.data?.siteConfig&&typeof r.data.siteConfig=="object"?r.data.siteConfig:r.data;return{shortcuts:Ir(o?.shortcuts),greeting:Io(o?.greeting),limits:ga(o?.limits),version:o?.version!=null?String(o.version):void 0}}function xu(e){let t=Oh(e.siteId);t&&(_r=t),na(e),ko(),Fh(e).then(n=>{if(n&&(_r=n,Uh(e.siteId,n),na(e),!nr)){let r=ns(e);vr&&!f?.uiOpen?ee?.showGreeting(ba(r)):ko()}}).catch(()=>{})}function ya(e){if(!Z)return;let t={...Rn,...e};t.name&&(t.name=String(t.name).trim().slice(0,120)),t.email&&(t.email=String(t.email).trim().slice(0,240)),Rn=t,uu(Z.siteId,Rn),ee?.setVisitorName(Rn.name||""),nr||(vr&&!f?.uiOpen?ee?.showGreeting(ba(ns(Z))):ko())}function qh(e){if(Qi(e),P){let s=P.getRole();dt=s,f&&(f.executionMode=s)}Tu(e),ua(e);let t=(e.allowActions??!0)&&(P?P.isController():!0);Ge=new wi({allowActions:t,runtimeId:qe,allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy,crossHostPolicy:ia(e.navigation?.crossHostPolicy),registerOpenedTab:s=>P?.registerOpenedTab(s),switchToLogicalTab:s=>P?.switchToLogicalTab(s)||{ok:!1,reason:"No session coordinator"},listKnownTabs:()=>(P?.listTabs()||[]).map(s=>({logicalTabId:s.logicalTabId,runtimeId:s.runtimeId,url:s.url,title:s.title,external:!!s.external})),onNavigationGuardrail:s=>{$e("navigation_guardrail",s),et({kind:"status",title:"Navigation guardrail",detail:Fi(s),status:"info"})},onBeforeAgentNavigation:s=>{yo=!0,f&&(tu(Kl(s)),f.pendingRun&&(s.isCrossHost||(f.pendingRun=an({...f.pendingRun,taskBoundaryId:f.pendingRun.taskBoundaryId||ke,resumeRequired:!0,resumeReason:"agent_navigation"}),Re())))},onBeforeCrossHostNavigation:s=>{if(yo=!0,!f||!Z)return;tu(Kl(s));let l=oa();f.pendingRun&&(f.pendingRun=an({...f.pendingRun,taskBoundaryId:f.pendingRun.taskBoundaryId||ke,resumeRequired:!0,resumeReason:"cross_host_navigation"})),Xs(Z.siteId,{sessionId:f.sessionId,pendingRun:f.pendingRun?{id:f.pendingRun.id,text:f.pendingRun.text,startedAt:f.pendingRun.startedAt,attempts:f.pendingRun.attempts,taskBoundaryId:f.pendingRun.taskBoundaryId||ke}:void 0,handoff:l?{handoffId:l.handoffId,sourceLogicalTabId:l.sourceLogicalTabId,runId:l.runId,targetUrl:l.targetUrl,createdAt:l.createdAt}:void 0,activeTask:f.activeTask?{taskId:f.activeTask.taskId,status:f.activeTask.status}:void 0,taskEpoch:f.taskEpoch,timestamp:Date.now()}),Re()},instrumentationOptions:e.mode==="safe"?{observeInlineMutations:!1}:void 0});let n=dt==="observer"?"observer":"controller";Ge?.setActionGateContext?.({mode:n,controllerRuntimeId:P?.getCurrentHolderRuntimeId(),activeLogicalTabId:P?.getActiveLogicalTabId(),localLogicalTabId:P?.getLocalLogicalTabId(),reason:sa(n,t)});let r=new MessageChannel;Rl(r.port1,{getSnapshot:()=>Ge.getSnapshot(),getPageData:async s=>{let l=Z||e,p=Number(s?.tabId),d=P?.getLocalLogicalTabId();if(!Number.isFinite(p)||p<=0||p===d||!P)return Ge.getPageData(s);let I=P.listTabs().find(g=>g.logicalTabId===p);if(!I)return Di(l,{logicalTabId:p,external:!0},"target_tab_missing");if(I.runtimeId===qe)return Ge.getPageData(s);if(I.external&&l.externalNavigationPolicy!=="allow")return Di(l,I,"external_domain_inaccessible");if(!I.runtimeId||!P.isTabAlive(p))return Di(l,I,"target_tab_inactive");try{return await P.sendCrossTabRpc(I.runtimeId,"getPageData",s,15e3)}catch{return Di(l,I,"cross_tab_rpc_failed")}},executeTool:async s=>{let l=Z||e;if(s?.payload?.forceLocal===!0)return Ge.executeTool(s.call,s.payload);let d=Number(s?.call?.args?.tab_id),y=P?.getActiveLogicalTabId(),I=Number.isFinite(d)&&d>0?d:y,g=P?.getLocalLogicalTabId();if(!I||I===g||!P)return Ge.executeTool(s.call,s.payload);let x=P.listTabs().find(B=>B.logicalTabId===I);if(!x)return Oi(l,{logicalTabId:I,external:!0},"target_tab_missing");if(x.external&&l.externalNavigationPolicy!=="allow")return Oi(l,x,"external_tab_action_blocked");if(x.runtimeId===qe)return Ge.executeTool(s.call,s.payload);if(!x.runtimeId||!P.isTabAlive(I))return Oi(l,x,"target_tab_inactive");try{return await P.sendCrossTabRpc(x.runtimeId,"executeTool",s,2e4)}catch{return Oi(l,x,"cross_tab_execute_failed")}},executeClientTool:s=>Ge.executeClientTool(s.name,s.args),listClientTools:()=>Ge.listClientTools(),getTabContext:()=>{let s=P?.getLocalLogicalTabId(),l=P?.getActiveLogicalTabId();return{id:s||1,logicalTabId:s||1,activeLogicalTabId:l||s||1,runtimeId:qe,mode:dt,url:window.location.href,title:document.title}},listSessionTabs:()=>P?.listTabs({scope:"context"})||[]}),r.port1.start?.();let o=e.workerUrl?e.workerUrl:new URL("./worker/worker.js",__ROVER_SCRIPT_URL__).toString(),i=o;try{let s=window.location.origin,l=new URL(o).origin;if(s!==l){let p=new Blob([`import '${o}';`],{type:"application/javascript"});i=URL.createObjectURL(p)}}catch{}Se=new Worker(i,{type:"module"}),Se.postMessage({type:"init",config:{...e,taskBoundaryId:ke},port:r.port2},[r.port2]);let a=(s="manual_cancel_task")=>{if(!f)return;let l=f.pendingRun;if(l){sn(l.id),Se?.postMessage({type:"cancel_run",runId:l.id}),P?.releaseWorkflowLock(l.id),P?.setActiveRun(void 0),mt(void 0),f.workerState=void 0,P?.setWorkerContext(void 0),ke=xr(),Se?.postMessage({type:"update_config",config:{taskBoundaryId:ke}}),je&&(clearTimeout(je),je=null),ee?.setRunning(!1),ee?.setQuestionPrompt(void 0),st("Task cancelled."),yn("system","Task cancelled.",!0),et({kind:"info",title:"Run cancelled",status:"info"}),Re();return}let p=rr(f.workerState?.pendingAskUser?.questions).length>0,d=f.activeTask?.status;if(!p&&d!=="running")return;ke=xr(),f.workerState=void 0,Se?.postMessage({type:"update_config",config:{taskBoundaryId:ke}}),je&&(clearTimeout(je),je=null),ee?.setRunning(!1),ee?.setQuestionPrompt(void 0),Sn(),mt(void 0);let y=Ao(s);y&&(y.status="ended",y.endedAt=Date.now(),y.boundaryReason=s),P?.endTask(s),P?.setActiveRun(void 0),P?.setWorkerContext(void 0),st(s==="question_prompt_cancel"?"Input request cancelled.":"Task cancelled."),et({kind:"info",title:s==="question_prompt_cancel"?"Input request cancelled":"Task cancelled",status:"info"}),Re()};if(ee=Ml({shortcuts:_u(Ir(e.ui?.shortcuts||[])),greeting:ns(e),visitorName:Rn?.name,onShortcutClick:s=>{let l=String(s.prompt||"").trim();l&&mo(l,{routing:s.routing})},onSend:(s,l)=>{mo(s,{askUserAnswers:l?.askUserAnswers})},onRequestControl:()=>{P?.requestControl()??!1?et({kind:"status",title:"Control requested",detail:"This tab is now the active Rover controller.",status:"info"}):yn("system","Unable to acquire control right now. Try again in a moment.",!0)},onCancelRun:()=>{a("manual_cancel_task")},onCancelQuestionFlow:()=>{a("question_prompt_cancel")},onNewTask:()=>{Gr({reason:"manual_new_task",clearUi:!0})},onEndTask:()=>{os({reason:"manual_end_task"})},onTaskSuggestionPrimary:()=>{let s=Vr;if(s){if(s.kind==="resume_run"){Sn(),Xi(s.text,{runId:s.runId,resume:!0,appendUserMessage:!1,autoResume:!0});return}mo(s.text,{bypassSuggestion:!0,startNewTask:!0,reason:s.reason})}},onTaskSuggestionSecondary:()=>{let s=Vr;if(s){if(s.kind==="resume_run"){f?.pendingRun?.id===s.runId&&(sn(s.runId),P?.releaseWorkflowLock(s.runId),P?.setActiveRun(void 0),mt(void 0)),je&&(clearTimeout(je),je=null),Sn(),Gr({reason:"resume_declined_start_fresh",clearUi:!0});return}mo(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:()=>{nr=!0,Co(),f&&(f.uiOpen=!0,f.uiHidden=!1,Re()),$e("open")},onClose:()=>{f&&(f.uiOpen=!1,Re()),$e("close")}}),Sn(),f?.uiMessages?.length&&pa(f.uiMessages),f?.timeline?.length&&ha(f.timeline),f?.uiStatus&&ee.setStatus(f.uiStatus),_o(),f?.executionMode&&ee.setExecutionMode(f.executionMode,{localLogicalTabId:P?.getLocalLogicalTabId(),activeLogicalTabId:P?.getActiveLogicalTabId(),controllerRuntimeId:P?.getCurrentHolderRuntimeId(),canTakeControl:!0,canComposeInObserver:gu(),note:bu(f.executionMode)}),Se.onmessage=s=>{Dh(s.data||{})},P){let s=()=>{P?.registerCurrentTab(window.location.href,document.title),P?.broadcastNavigation(window.location.href,document.title)},l=history.pushState.bind(history),p=history.replaceState.bind(history);history.pushState=function(...d){let y=l(...d);return setTimeout(s,0),y},history.replaceState=function(...d){let y=p(...d);return setTimeout(s,0),y},window.addEventListener("popstate",s)}f?.uiHidden?ee.hide():(ee.show(),f?.uiOpen??!!e.openOnInit?ee.open():ee.close()),f&&(f.uiHidden=!!f.uiHidden,f.uiOpen=!!f.uiOpen,Re()),P&&(ma(P.getState(),"remote"),xo(P.getRole(),{localLogicalTabId:P.getLocalLogicalTabId(),activeLogicalTabId:P.getActiveLogicalTabId(),holderRuntimeId:P.getCurrentHolderRuntimeId()})),ko()}function Ro(e){if(er)return Ji(e),er;Tr=Hl(),qe=th(e.siteId),kt=du(e),Rn=e.visitor||oh(e.siteId),nr=!1,vr=!1,Co(),_r=null,$r=sh(e.siteId);let t=Eh($r),n=t?null:ql(e.siteId);n&&$l(e.siteId);let r=e.sessionId?.trim(),o=!r&&!t?.sessionId&&!n?.sessionId&&e.sessionScope!=="tab"&&kt?ih(e.siteId,kt):void 0,i=r||t?.sessionId||n?.sessionId||o||crypto.randomUUID(),a=t;if(!t&&n){let s=ea(n.sessionId,qe);n.pendingRun&&(s.pendingRun=an({...n.pendingRun,autoResume:!0,taskBoundaryId:n.pendingRun.taskBoundaryId,resumeRequired:!0,resumeReason:"cross_host_navigation"})),n.handoff&&(s.lastNavigationHandoff=zr({...n.handoff,createdAt:n.handoff.createdAt})),n.activeTask&&(s.activeTask={...zn("cross_domain_resume"),taskId:n.activeTask.taskId,status:n.activeTask.status}),s.taskEpoch=n.taskEpoch||1,s.uiOpen=!0,a=s}f=To(a,i,qe),r&&f.sessionId!==r&&(f=ea(r,qe)),ke=eh(f),f.pendingRun&&!f.pendingRun.taskBoundaryId&&(f.pendingRun=an({...f.pendingRun,taskBoundaryId:ke})),f.workerState&&!f.workerState.taskBoundaryId&&(f.workerState=An({...f.workerState,taskBoundaryId:ke})),Z={...e,visitorId:kt||e.visitorId,sessionId:r||f.sessionId,taskRouting:{mode:e.taskRouting?.mode||"act",actHeuristicThreshold:e.taskRouting?.actHeuristicThreshold,plannerOnActError:e.taskRouting?.plannerOnActError},navigation:{crossHostPolicy:ia(e.navigation?.crossHostPolicy)},task:{autoResumePolicy:aa(e.task?.autoResumePolicy)},taskContext:{...e.taskContext}},f.sessionId=Z.sessionId,f.runtimeId=qe,f.executionMode=f.executionMode||"controller",f.timeline=wo(f.timeline),f.uiMessages=vo(f.uiMessages),f.activeTask=So(f.activeTask,zn("boot")),f.taskEpoch=Math.max(1,Number(f.taskEpoch)||1),dt=f.executionMode,Rn&&uu(e.siteId,Rn),Re();try{sessionStorage.setItem(`rover:tab-alive:${e.siteId}`,"1")}catch{}if(Cn=!1,Vn=!1,qh(Z),$r&&Ah($r),xh(),er={boot:Ro,init:Ea,update:Ji,shutdown:va,open:No,close:rs,show:wa,hide:Ta,send:_a,newTask:Gr,endTask:os,getState:xa,registerTool:Ia,identify:ya,on:su},Bi.length){for(let s of Bi)fu(s);Bi.length=0}return er}function Ea(e){return Ro(e)}function Ji(e){if(!er||!Se||!Z)return;Z={...Z,...e,taskRouting:{...Z.taskRouting,...e.taskRouting},navigation:{...Z.navigation,...e.navigation,crossHostPolicy:ia(e.navigation?.crossHostPolicy??Z.navigation?.crossHostPolicy)},task:{...Z.task,...e.task,autoResumePolicy:aa(e.task?.autoResumePolicy??Z.task?.autoResumePolicy)},taskContext:{...Z.taskContext,...e.taskContext},ui:{...Z.ui,...e.ui,agent:{...Z.ui?.agent,...e.ui?.agent},panel:{...Z.ui?.panel,...e.ui?.panel}},tools:{...Z.tools,...e.tools,client:e.tools?.client??Z.tools?.client,web:{...Z.tools?.web,...e.tools?.web}}},kt=du(Z),kt&&(Z.visitorId=kt),e.sessionId&&f?(f.sessionId=e.sessionId,Re(),Qi(Z)):(e.sessionScope||e.tabPolicy)&&Qi(Z),Tu(Z),ua(Z);let t=e.apiBase!==void 0||e.apiKey!==void 0||e.authToken!==void 0||e.siteId!==void 0||e.siteKeyId!==void 0||e.ui?.shortcuts!==void 0||e.ui?.greeting!==void 0;if(Ge){typeof e.allowActions=="boolean"&&Ge.setAllowActions(e.allowActions&&dt==="controller");let n=dt==="controller"&&(Z?.allowActions??!0),r=dt==="observer"?"observer":"controller";Ge?.setActionGateContext?.({mode:r,controllerRuntimeId:P?.getCurrentHolderRuntimeId(),activeLogicalTabId:P?.getActiveLogicalTabId(),localLogicalTabId:P?.getLocalLogicalTabId(),reason:sa(r,n)}),(e.allowedDomains||e.domainScopeMode||e.externalNavigationPolicy||e.navigation?.crossHostPolicy)&&Ge.setNavigationPolicy({allowedDomains:e.allowedDomains,domainScopeMode:e.domainScopeMode,externalNavigationPolicy:e.externalNavigationPolicy,crossHostPolicy:e.navigation?.crossHostPolicy})}Se.postMessage({type:"update_config",config:{...e,taskBoundaryId:ke}}),na(Z),t?xu(Z):ko(),e.visitor&&ya(e.visitor),typeof e.openOnInit=="boolean"&&(e.openOnInit?No():rs())}function va(){Sn(),Re(),ts(!0),la(),Ot?.markDirty(),Ot?.syncNow(),Ot?.stop(),Ot=null,P?.stop(),P=null,Se?.terminate(),Se=null,ee?.destroy(),ee=null,Ge=null,Z=null,Cn=!1,Vn=!1,yo=!1,ke="",qe="",kt=void 0,Rn=void 0,nr=!1,vr=!1,Co(),_r=null,zi=!1,Pi=!1,Wr=!1,Dt=[],ou=0,dt="controller",Vr=null,Tr=null,er=null}function No(){nr=!0,Co(),ee?.show(),ee?.open(),f&&(f.uiHidden=!1,f.uiOpen=!0,Re())}function rs(){ee?.close(),f&&(f.uiOpen=!1,Re())}function wa(){ee?.show(),f&&(f.uiHidden=!1,Re())}function Ta(){ee?.hide(),f&&(f.uiHidden=!0,f.uiOpen=!1,Re())}function _a(e){e?.trim()&&mo(e)}function Gr(e){if(!f)return;let t=e?.reason||"manual_new_task",n=e?.clearUi!==!1,r=Math.max(1,Number(f.taskEpoch)||1)+1,o=zn(t);f.pendingRun&&(sn(f.pendingRun.id),Se?.postMessage({type:"cancel_run",runId:f.pendingRun.id}),P?.releaseWorkflowLock(f.pendingRun.id)),je&&(clearTimeout(je),je=null),ee?.setRunning(!1),ee?.setQuestionPrompt(void 0),Vn=!1,ke=xr(),f.taskEpoch=r,f.activeTask=o,mt(void 0),f.workerState=void 0,n&&(f.uiMessages=[],f.timeline=[],f.uiStatus=void 0,vu()),P?.startNewTask({taskId:o.taskId,startedAt:o.startedAt,boundaryReason:t,status:"running",lastUserAt:void 0,lastAssistantAt:void 0}),P?.setActiveRun(void 0),P?.setWorkerContext(void 0),st("New task started."),Re(),Se?.postMessage({type:"start_new_task",taskId:o.taskId,taskBoundaryId:ke}),$e("task_started",{taskId:o.taskId,reason:t,taskEpoch:r})}function os(e){if(!f)return;let t=e?.reason||"manual_end_task",n=Ao("manual_end_task");n&&(n.status="ended",n.endedAt=Date.now(),n.boundaryReason=t,f.pendingRun&&(sn(f.pendingRun.id),Se?.postMessage({type:"cancel_run",runId:f.pendingRun.id}),P?.releaseWorkflowLock(f.pendingRun.id)),mt(void 0),ke=xr(),f.workerState=void 0,Se?.postMessage({type:"update_config",config:{taskBoundaryId:ke}}),je&&(clearTimeout(je),je=null),ee?.setRunning(!1),ee?.setQuestionPrompt(void 0),Sn(),st("Task ended. Start a new task to continue."),P?.endTask(t),P?.setActiveRun(void 0),P?.setWorkerContext(void 0),Re(),et({kind:"info",title:"Task ended",detail:"Start a new task when you are ready.",status:"info"}),$e("task_ended",{taskId:n.taskId,reason:t,endedAt:n.endedAt}))}function xa(){return{mode:dt,runtimeId:qe,runtimeState:f?wu(f):null,sharedState:P?.getState()||null,pendingTaskSuggestion:Vr}}function Ia(e,t){let n=Zp(e);if(!er||!Ge||!Se){Bi.push({def:n,handler:t});return}fu({def:n,handler:t})}function $h(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 Iu(){let e=window,t=e.rover,n=((r,...o)=>{let i=$h(r),a=i?n[i]:void 0;if(typeof a=="function")return a(...o)});if(n.boot=Ro,n.init=Ea,n.update=Ji,n.shutdown=va,n.open=No,n.close=rs,n.show=wa,n.hide=Ta,n.send=_a,n.newTask=Gr,n.endTask=os,n.getState=xa,n.registerTool=Ia,n.on=su,e.rover=n,typeof t=="function"&&Array.isArray(t.q))for(let r of t.q){let[o,...i]=Array.isArray(r)?r:Array.from(r);typeof o=="string"&&n(o,...i)}if(!er){let r=typeof globalThis.__ROVER_SCRIPT_EL__<"u"?globalThis.__ROVER_SCRIPT_EL__:null;if(r){let o=r.getAttribute("data-site-id"),i=r.getAttribute("data-api-key");if(o&&i){let a={siteId:o,apiKey:i},s=r.getAttribute("data-allowed-domains");s&&(a.allowedDomains=s.split(",").map(d=>d.trim()).filter(Boolean));let l=r.getAttribute("data-site-key-id");l&&(a.siteKeyId=l);let p=r.getAttribute("data-worker-url");p&&(a.workerUrl=p),Ro(a)}}}}Iu();return Lu(Wh);})();
|