module.exports=[23889,r=>{"use strict";var e=r.i(33405),t=r.i(22734),s=r.i(14747),n=r.i(92509);let c={get url(){return`file://${r.P("src/utils/agent-browser.ts")}`}};function a(){let r=(0,n.fileURLToPath)(c.url),e=(0,s.dirname)((0,s.dirname)((0,s.dirname)(r))),a=(0,s.join)(e,"node_modules",".bin","agent-browser");return(0,t.existsSync)(a)?a:"agent-browser"}async function o(r,t={}){let s,n=[...(s=[],t.headed&&s.push("--headed"),t.cdpPort&&s.push("--cdp",String(t.cdpPort)),t.session&&s.push("--session",t.session),s.push("--json"),s),...r],c=t.timeout||3e4,i=a();return new Promise((r,t)=>{let s=(0,e.spawn)(i,n,{stdio:["pipe","pipe","pipe"],timeout:c}),a="",o="";s.stdout?.on("data",r=>{a+=r.toString()}),s.stderr?.on("data",r=>{o+=r.toString()}),s.on("close",e=>{0===e?r(a):t(Error(`agent-browser failed (code ${e}): ${o||a}`))}),s.on("error",r=>{t(Error(`agent-browser spawn error: ${r.message}`))})})}async function i(r,e={}){try{let t=await o(["open",r],e);return{success:!0,output:t}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}async function u(r={}){let e=["snapshot"];!1!==r.interactive&&e.push("-i"),r.compact&&e.push("-c");let t=await o(e,r),s=[];try{let r=JSON.parse(t);if(r.success&&r.data?.refs)for(let[e,t]of Object.entries(r.data.refs))s.push({ref:`@${e}`,role:t.role||"unknown",name:t.name,text:t.text});return{elements:s,raw:r.data?.snapshot||t}}catch{for(let r of t.matchAll(/@(\w+)\s+(\w+)(?:\s+"([^"]*)")?/g))s.push({ref:`@${r[1]}`,role:r[2],name:r[3]});return{elements:s,raw:t}}}async function l(r,e={}){try{let t=await o(["click",r],e);return{success:!0,output:t}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}async function f(r,e={}){try{let t=await o(["type",r],e);return{success:!0,output:t}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}async function g(r,e,t={}){try{let s=await o(["fill",r,e],t);return{success:!0,output:s}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}async function y(r,e,t={}){try{let s=["scroll",r];e&&s.push(String(e));let n=await o(s,t);return{success:!0,output:n}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}async function h(r,e={}){try{let n=(0,s.dirname)(r);(0,t.existsSync)(n)||(0,t.mkdirSync)(n,{recursive:!0});let c=["screenshot",r];return e.fullPage&&c.push("--full-page"),await o(c,e),{success:!0,path:r}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}async function p(r={}){try{let e=await o(["console"],r),t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}async function w(r={}){try{let e=await o(["errors"],r),t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}async function m(r={}){try{let e=await o(["back"],r);return{success:!0,output:e}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}async function d(r={}){try{let e=await o(["forward"],r);return{success:!0,output:e}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}async function S(r={}){try{let e=await o(["reload"],r);return{success:!0,output:e}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}async function E(r={}){try{let e=await o(["close"],r);return{success:!0,output:e}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}async function b(r={}){try{return(await o(["url"],r)).trim()}catch{return null}}async function A(r={}){try{return(await o(["title"],r)).trim()}catch{return null}}async function P(r,e={}){try{let t=await o(["evaluate",r],e);return{success:!0,output:t}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}async function $(r,e={}){try{let t=["wait",r];e.timeout&&t.push("--timeout",String(e.timeout));let s=await o(t,e);return{success:!0,output:s}}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r)}}}function k(){try{let r=a();return(0,e.execSync)(`"${r}" --help`,{stdio:"pipe"}),!0}catch{return!1}}function v(){return a()}r.s(["back",()=>m,"click",()=>l,"close",()=>E,"evaluate",()=>P,"fill",()=>g,"forward",()=>d,"getAgentBrowserBinaryPath",()=>v,"getConsoleMessages",()=>p,"getCurrentUrl",()=>b,"getErrors",()=>w,"getTitle",()=>A,"isAgentBrowserAvailable",()=>k,"openUrl",()=>i,"reload",()=>S,"screenshot",()=>h,"scroll",()=>y,"snapshot",()=>u,"type",()=>f,"waitFor",()=>$])}];

//# sourceMappingURL=src_utils_agent-browser_ts_cc00e0d8._.js.map